Skip to content

Commit 6054d67

Browse files
Copilotbrunoborges
andcommitted
Replace stub annotations with real jbang dependencies in proof files
Co-authored-by: brunoborges <129743+brunoborges@users.noreply.github.com>
1 parent 124ed37 commit 6054d67

18 files changed

+174
-243
lines changed

proof/enterprise/EjbTimerVsJakartaScheduler.java

Lines changed: 11 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,17 @@
1-
import java.util.concurrent.*;
1+
///usr/bin/env jbang "$0" "$@" ; exit $?
2+
//JAVA 25+
3+
//DEPS jakarta.enterprise:jakarta.enterprise.cdi-api:4.1.0
4+
//DEPS jakarta.annotation:jakarta.annotation-api:3.0.0
5+
//DEPS jakarta.enterprise.concurrent:jakarta.enterprise.concurrent-api:3.1.0
6+
7+
import jakarta.enterprise.context.ApplicationScoped;
8+
import jakarta.annotation.Resource;
9+
import jakarta.annotation.PostConstruct;
10+
import jakarta.enterprise.concurrent.ManagedScheduledExecutorService;
11+
import java.util.concurrent.TimeUnit;
212

313
/// Proof: ejb-timer-vs-jakarta-scheduler
414
/// Source: content/enterprise/ejb-timer-vs-jakarta-scheduler.yaml
5-
@interface ApplicationScoped {}
6-
@interface Resource {}
7-
@interface PostConstruct {}
8-
9-
interface ManagedScheduledExecutorService
10-
extends ScheduledExecutorService {}
11-
1215
@ApplicationScoped
1316
class ReportGenerator {
1417
@Resource

proof/enterprise/EjbVsCdi.java

Lines changed: 9 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,14 @@
1+
///usr/bin/env jbang "$0" "$@" ; exit $?
2+
//JAVA 25+
3+
//DEPS jakarta.enterprise:jakarta.enterprise.cdi-api:4.1.0
4+
//DEPS jakarta.transaction:jakarta.transaction-api:2.0.1
5+
6+
import jakarta.enterprise.context.ApplicationScoped;
7+
import jakarta.inject.Inject;
8+
import jakarta.transaction.Transactional;
9+
110
/// Proof: ejb-vs-cdi
211
/// Source: content/enterprise/ejb-vs-cdi.yaml
3-
@interface ApplicationScoped {}
4-
@interface Inject {}
5-
@interface Transactional {}
6-
712
record Order(Object item) {}
813

914
class InventoryService {

proof/enterprise/JdbcResultsetVsJpaCriteria.java

Lines changed: 9 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -1,32 +1,16 @@
1+
///usr/bin/env jbang "$0" "$@" ; exit $?
2+
//JAVA 25+
3+
//DEPS jakarta.persistence:jakarta.persistence-api:3.2.0
4+
5+
import jakarta.persistence.*;
6+
import jakarta.persistence.criteria.*;
17
import java.util.*;
2-
import java.util.function.*;
38

49
/// Proof: jdbc-resultset-vs-jpa-criteria
510
/// Source: content/enterprise/jdbc-resultset-vs-jpa-criteria.yaml
6-
@interface PersistenceContext {}
7-
8-
record User(String status, int age) {}
9-
10-
interface CriteriaQuery<T> {
11-
CriteriaQuery<T> select(Root<T> root);
12-
CriteriaQuery<T> where(Object... predicates);
13-
Root<T> from(Class<T> cls);
14-
}
15-
interface Root<T> {
16-
<Y> Path<Y> get(String name);
17-
}
18-
interface Path<Y> {}
19-
interface CriteriaBuilder {
20-
<T> CriteriaQuery<T> createQuery(Class<T> cls);
21-
Object equal(Path<?> path, Object value);
22-
Object greaterThan(Path<? extends Comparable> path, Comparable value);
23-
}
24-
interface TypedQuery<T> {
25-
List<T> getResultList();
26-
}
27-
interface EntityManager {
28-
CriteriaBuilder getCriteriaBuilder();
29-
<T> TypedQuery<T> createQuery(CriteriaQuery<T> q);
11+
class User {
12+
String status;
13+
int age;
3014
}
3115

3216
class UserRepository {

proof/enterprise/JdbcVsJooq.java

Lines changed: 27 additions & 34 deletions
Original file line numberDiff line numberDiff line change
@@ -1,44 +1,37 @@
1+
///usr/bin/env jbang "$0" "$@" ; exit $?
2+
//JAVA 25+
3+
//DEPS org.jooq:jooq:3.20.11
4+
5+
import org.jooq.*;
6+
import org.jooq.impl.DSL;
7+
import javax.sql.DataSource;
18
import java.util.*;
29

310
/// Proof: jdbc-vs-jooq
411
/// Source: content/enterprise/jdbc-vs-jooq.yaml
5-
///
6-
/// Note: Uses stub types to prove the fluent API compiles without jOOQ dependency.
7-
@interface Table {}
8-
9-
// Minimal stubs for jOOQ-style API
10-
enum SQLDialect { POSTGRES }
11-
interface Field<T> {
12-
Condition eq(T val);
13-
Condition and(Condition c);
14-
Condition gt(T val);
15-
}
16-
interface Condition {}
17-
interface TableField<R, T> extends Field<T> {}
18-
interface Record {}
19-
interface SelectJoinStep<R> { SelectConditionStep<R> where(Condition c); }
20-
interface SelectConditionStep<R> { <E> List<E> fetchInto(Class<E> cls); }
21-
interface SelectSelectStep<R> { SelectJoinStep<R> from(Object table); }
22-
interface DSLContext {
23-
<R extends Record> SelectSelectStep<R> select(Object... fields);
12+
class User {
13+
Long id; String name; String email;
2414
}
2515

26-
record UserTable(
27-
Field<String> DEPARTMENT,
28-
Field<Integer> SALARY,
29-
Field<Long> ID,
30-
Field<String> NAME,
31-
Field<String> EMAIL
32-
) {}
16+
// Simulating the generated jOOQ table fields (normally produced by jOOQ codegen)
17+
class USERS {
18+
static final Field<String> DEPARTMENT = DSL.field(DSL.name("department"), String.class);
19+
static final Field<Integer> SALARY = DSL.field(DSL.name("salary"), Integer.class);
20+
static final Field<Long> ID = DSL.field(DSL.name("id"), Long.class);
21+
static final Field<String> NAME = DSL.field(DSL.name("name"), String.class);
22+
static final Field<String> EMAIL = DSL.field(DSL.name("email"), String.class);
23+
static final Table<?> TABLE = DSL.table(DSL.name("users"));
24+
}
3325

34-
record User(Long id, String name, String email) {}
26+
List<User> findByDept(DataSource ds, String department, int minSalary) {
27+
DSLContext dsl = DSL.using(ds, SQLDialect.POSTGRES);
3528

36-
class Db {
37-
static final UserTable USERS = new UserTable(
38-
null, null, null, null, null);
39-
static DSLContext dsl;
29+
return dsl
30+
.select(USERS.ID, USERS.NAME, USERS.EMAIL)
31+
.from(USERS.TABLE)
32+
.where(USERS.DEPARTMENT.eq(department)
33+
.and(USERS.SALARY.gt(minSalary)))
34+
.fetchInto(User.class);
4035
}
4136

42-
void main() {
43-
// Structural proof only — real jOOQ requires runtime dependency
44-
}
37+
void main() {}

proof/enterprise/JdbcVsJpa.java

Lines changed: 7 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1,18 +1,14 @@
1+
///usr/bin/env jbang "$0" "$@" ; exit $?
2+
//JAVA 25+
3+
//DEPS jakarta.persistence:jakarta.persistence-api:3.2.0
4+
5+
import jakarta.persistence.*;
16
import java.util.*;
27

38
/// Proof: jdbc-vs-jpa
49
/// Source: content/enterprise/jdbc-vs-jpa.yaml
5-
@interface PersistenceContext {}
6-
7-
record User(Long id, String name) {}
8-
9-
interface TypedQuery<T> {
10-
TypedQuery<T> setParameter(String name, Object value);
11-
List<T> getResultList();
12-
}
13-
interface EntityManager {
14-
<T> T find(Class<T> cls, Object id);
15-
<T> TypedQuery<T> createQuery(String jpql, Class<T> cls);
10+
class User {
11+
Long id; String name;
1612
}
1713

1814
class UserRepository {

proof/enterprise/JndiLookupVsCdiInjection.java

Lines changed: 9 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,16 +1,17 @@
1+
///usr/bin/env jbang "$0" "$@" ; exit $?
2+
//JAVA 25+
3+
//DEPS jakarta.enterprise:jakarta.enterprise.cdi-api:4.1.0
4+
//DEPS jakarta.annotation:jakarta.annotation-api:3.0.0
5+
6+
import jakarta.enterprise.context.ApplicationScoped;
7+
import jakarta.inject.Inject;
8+
import jakarta.annotation.Resource;
9+
import javax.sql.DataSource;
110
import java.sql.*;
211
import java.util.*;
312

413
/// Proof: jndi-lookup-vs-cdi-injection
514
/// Source: content/enterprise/jndi-lookup-vs-cdi-injection.yaml
6-
@interface ApplicationScoped {}
7-
@interface Inject {}
8-
@interface Resource { String name() default ""; }
9-
10-
interface DataSource {
11-
Connection getConnection() throws SQLException;
12-
}
13-
1415
record Order(String id) {}
1516

1617
@ApplicationScoped

proof/enterprise/JpaVsJakartaData.java

Lines changed: 7 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,14 @@
1+
///usr/bin/env jbang "$0" "$@" ; exit $?
2+
//JAVA 25+
3+
//DEPS jakarta.data:jakarta.data-api:1.0.1
4+
5+
import jakarta.data.repository.*;
16
import java.util.*;
27

38
/// Proof: jpa-vs-jakarta-data
49
/// Source: content/enterprise/jpa-vs-jakarta-data.yaml
5-
@interface Repository {}
6-
7-
record User(Long id, String name) {}
8-
9-
interface CrudRepository<T, ID> {
10-
T findById(ID id);
11-
List<T> findAll();
12-
T save(T entity);
10+
class User {
11+
Long id; String name;
1312
}
1413

1514
@Repository

proof/enterprise/JsfManagedBeanVsCdiNamed.java

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,14 @@
1+
///usr/bin/env jbang "$0" "$@" ; exit $?
2+
//JAVA 25+
3+
//DEPS jakarta.enterprise:jakarta.enterprise.cdi-api:4.1.0
4+
5+
import jakarta.enterprise.context.SessionScoped;
6+
import jakarta.inject.Inject;
7+
import jakarta.inject.Named;
18
import java.io.*;
29

310
/// Proof: jsf-managed-bean-vs-cdi-named
411
/// Source: content/enterprise/jsf-managed-bean-vs-cdi-named.yaml
5-
@interface Named {}
6-
@interface SessionScoped {}
7-
@interface Inject {}
8-
912
interface UserService {
1013
String findName(String id);
1114
}

proof/enterprise/ManualTransactionVsDeclarative.java

Lines changed: 11 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,20 +1,22 @@
1+
///usr/bin/env jbang "$0" "$@" ; exit $?
2+
//JAVA 25+
3+
//DEPS jakarta.enterprise:jakarta.enterprise.cdi-api:4.1.0
4+
//DEPS jakarta.persistence:jakarta.persistence-api:3.2.0
5+
//DEPS jakarta.transaction:jakarta.transaction-api:2.0.1
6+
7+
import jakarta.enterprise.context.ApplicationScoped;
8+
import jakarta.persistence.*;
9+
import jakarta.transaction.Transactional;
110
import java.math.*;
211

312
/// Proof: manual-transaction-vs-declarative
413
/// Source: content/enterprise/manual-transaction-vs-declarative.yaml
5-
@interface ApplicationScoped {}
6-
@interface PersistenceContext {}
7-
@interface Transactional {}
8-
9-
record Account(Long id, BigDecimal balance) {
14+
class Account {
15+
Long id; BigDecimal balance;
1016
Account debit(BigDecimal amount) { return this; }
1117
Account credit(BigDecimal amount) { return this; }
1218
}
1319

14-
interface EntityManager {
15-
<T> T find(Class<T> cls, Object id);
16-
}
17-
1820
@ApplicationScoped
1921
class AccountService {
2022
@PersistenceContext

proof/enterprise/MdbVsReactiveMessaging.java

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,13 @@
1+
///usr/bin/env jbang "$0" "$@" ; exit $?
2+
//JAVA 25+
3+
//DEPS jakarta.enterprise:jakarta.enterprise.cdi-api:4.1.0
4+
//DEPS org.eclipse.microprofile.reactive.messaging:microprofile-reactive-messaging-api:3.0.1
5+
6+
import jakarta.enterprise.context.ApplicationScoped;
7+
import org.eclipse.microprofile.reactive.messaging.Incoming;
8+
19
/// Proof: mdb-vs-reactive-messaging
210
/// Source: content/enterprise/mdb-vs-reactive-messaging.yaml
3-
@interface ApplicationScoped {}
4-
@interface Incoming { String value(); }
5-
611
record Order(String id) {}
712

813
void fulfillOrder(Order order) {}

0 commit comments

Comments
 (0)