Add proof files for all compilable pattern slugs#98
Conversation
Co-authored-by: brunoborges <129743+brunoborges@users.noreply.github.com>
|
@copilot do NOT mock APIs. Instead, use jbang and add proper dependencies |
Co-authored-by: brunoborges <129743+brunoborges@users.noreply.github.com>
Done in commit
All 105 proof files still compile and run (87 via Warning Firewall rules blocked me from connecting to one or more addresses (expand for details)I tried to connect to the following addresses, but was blocked by firewall rules:
If you need me to access, download, or install something from one of these locations, you can either:
|
|
@copilot enable shebang on all these files to make them self-runnable |
Co-authored-by: brunoborges <129743+brunoborges@users.noreply.github.com>
Done in commit as the first two lines, making them directly runnable with 5 files using JDK 25 preview APIs also got: (StableValue, StructuredTaskScope, primitive patterns in switch, PEMEncoder/PEMDecoder) All 105 files are also |
There was a problem hiding this comment.
Pull request overview
This pull request adds 105 proof files that demonstrate the compilability of modern Java code snippets featured on the java.evolved site. Each proof file wraps a pattern's modern code in a self-runnable Java 25 implicit-class program using jbang, covering 11 categories (language, collections, strings, streams, concurrency, I/O, errors, datetime, security, tooling, and enterprise). Seven patterns were skipped because their modern code contains only shell commands or JVM flags with no compilable Java.
Changes:
- Adds 105 proof files with jbang shebang and
//JAVA 25+directives for self-execution - Implements preview API support with appropriate
--enable-previewflags for 5 files - Configures enterprise patterns with real Maven dependencies via jbang
//DEPSdirectives
Reviewed changes
Copilot reviewed 105 out of 105 changed files in this pull request and generated 3 comments.
Show a summary per file
| File | Description |
|---|---|
| proof/tooling/Junit6WithJspecify.java | JUnit 6 with JSpecify proof - has dependency version mismatch issue |
| proof/tooling/BuiltInHttpServer.java | Built-in HTTP server proof using SimpleFileServer API |
| proof/strings/*.java | String API proofs (7 files) - all standard String methods |
| proof/streams/*.java | Stream API proofs (11 files) - standard and modern stream operations |
| proof/security/*.java | Security API proofs (5 files) including preview PEM encoding |
| proof/language/*.java | Language feature proofs (22 files) - records, pattern matching, sealed classes, etc. |
| proof/io/*.java | I/O API proofs (10 files) - Files API, HttpClient, etc. |
| proof/errors/*.java | Error handling proofs (6 files) - Optional, multi-catch, etc. |
| proof/enterprise/*.java | Enterprise proofs (16 files) - Jakarta EE, Spring, jOOQ with real dependencies |
| proof/datetime/*.java | Date/time proofs (6 files) - has missing import issue in HexFormat |
| proof/concurrency/*.java | Concurrency proofs (10 files) - virtual threads, structured concurrency, etc. |
| proof/collections/*.java | Collections proofs (10 files) - immutable collections, sequenced collections, etc. |
Comments suppressed due to low confidence (1)
proof/enterprise/SpringApiVersioning.java:42
- Potential API availability issue: Verify that the 'version' parameter exists on
@GetMappingannotation in Spring Framework 7.0.5. If this attribute doesn't exist, the file will not compile.
Co-authored-by: brunoborges <129743+brunoborges@users.noreply.github.com>
Implements
proof/files per the proof-spec: one.javaper pattern slug, wrapping the modern code in a Java 25 implicit-class program. All 105 proof files are self-runnable via the jbang shebang and//JAVA 25+directive.Running a proof file
Any proof file can be run directly:
./proof/language/TypeInferenceWithVar.java # or jbang proof/language/TypeInferenceWithVar.javaCoverage
105 of 112 slugs covered across all 11 categories. 7 skipped — their
modernCodecontains only shell commands or JVM flags with no compilable Java (e.g.$ java -XX:AOTCacheOutput=...,$ jshell,// -XX:+UseCompactObjectHeaders).Notable adaptations
///usr/bin/env jbang "$0" "$@" ; exit $?) and//JAVA 25+for self-runnable execution.//JAVAC_OPTIONS --enable-preview --release 25and//JAVA_OPTIONS --enable-preview(StableValue, StructuredTaskScope, primitive patterns in switch, PEMEncoder/PEMDecoder).//DEPSwith real Maven coordinates: Jakarta EE (CDI 4.1, Persistence 3.2, WS-RS 4.0, Data 1.0.1, Transaction 2.0.1, Concurrent 3.1, Annotation 3.0), MicroProfile Reactive Messaging 3.0.1, jOOQ 3.20.11, Spring Boot 3.4.3 / Spring 7.0.5, JSpecify 1.0.0.TryWithResourcesEffectivelyFinal— uses jbang with H2 2.3.232 as the JDBC driver.Junit6WithJspecify— uses jbang with real JUnit Jupiter 6.0.3 (latest stable, released Feb 2026) and JSpecify 1.0.0 dependencies.proof/datetime/HexFormat.java— no explicitimport java.util.HexFormatneeded; Java 25 implicit-class programs (JEP 512) auto-import alljava.basetypes, and adding the import would conflict with the implicit class name derived from the filename.StableValuepatterns —StableValue.of(supplier)doesn't exist in JDK 25; adapted toStableValue.supplier()which returns aSupplier<T>with the same lazy init semantics.StructuredTaskScope—ShutdownOnFailurewas redesigned; usesStructuredTaskScope.open()per the JDK 25 API.KDF—KDF.HKDFParameterSpecmoved tojavax.crypto.spec.HKDFParameterSpec; no.build()call needed.ConcurrentHttpVirtual— uses an empty URL list to avoid network calls at proof time while keeping the full stream/executor pipeline intact.Example (jbang with real deps)
Example (plain Java, no external deps)
💬 We'd love your input! Share your thoughts on Copilot coding agent in our 2 minute survey.