Add proof files for all compilable pattern slugs#98
Add proof files for all compilable pattern slugs#98Copilot wants to merge 4 commits intoslug-prooffrom
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.
| void main() { | ||
| byte byteValue = 0x48; | ||
| var hex = HexFormat.of() | ||
| .withUpperCase(); | ||
| String s = hex.toHexDigits( | ||
| byteValue); | ||
| byte[] bytes = | ||
| hex.parseHex("48656C6C6F"); |
There was a problem hiding this comment.
Missing import statement for HexFormat. The HexFormat class is in java.util package and requires an explicit import statement. Add import java.util.HexFormat; at the top of the file after the jbang directives.
| class WebConfig implements WebMvcConfigurer { | ||
| @Override | ||
| public void configureApiVersioning( | ||
| ApiVersionConfigurer config) { | ||
| config.useRequestHeader("X-API-Version"); | ||
| } | ||
| } |
There was a problem hiding this comment.
Potential API availability issue: The APIs used here (WebMvcConfigurer.configureApiVersioning(), ApiVersionConfigurer class, and the 'version' attribute on @GetMapping) are documented as Spring Framework 7.0 features, but their existence should be verified. If these APIs don't exist in Spring 7.0.5, this file will not compile. Please verify these are actual APIs in the spring-webmvc:7.0.5 dependency, or update to use the correct API if the Spring Framework 7 implementation differs from what's shown in the pattern documentation.
This issue also appears on line 35 of the same file.
| //DEPS org.junit.jupiter:junit-jupiter-api:5.11.4 | ||
| //DEPS org.jspecify:jspecify:1.0.0 |
There was a problem hiding this comment.
Version mismatch: The content pattern describes this as a JUnit 6 feature (available since October 2025), but the proof file uses JUnit 5.11.4 dependency (org.junit.jupiter:junit-jupiter-api:5.11.4). If JUnit 6 has been released with @NullMarked support as described in the pattern, the dependency should be updated to junit-jupiter-api:6.x.x. Alternatively, if JUnit 6 hasn't been released yet, this pattern may be premature and should be removed or marked as future.
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 5.11.4 and JSpecify 1.0.0 dependencies.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.