The proof/ directory contains one .java file per pattern slug. Each file
wraps the pattern's modern code in a compilable program, proving that every
code snippet shown on the site actually compiles with the advertised JDK version.
Only the modern code is proven — the old code is what we're moving away from.
proof/
language/
TypeInferenceWithVar.java
RecordsForDataClasses.java
SealedClasses.java
...
collections/
ImmutableListCreation.java
...
strings/
streams/
concurrency/
io/
errors/
datetime/
security/
tooling/
enterprise/
The folder structure mirrors content/ — one subfolder per category.
- Folder: matches the category name (e.g.,
language/,collections/) - File: PascalCase version of the slug (e.g.,
type-inference-with-var→TypeInferenceWithVar.java)
Each proof file follows this structure:
import java.util.*; // whatever imports the snippet needs
/// Proof: {slug}
/// Source: content/{category}/{slug}.yaml
void main() {
// modern code from the pattern, adapted to compile
}Key rules:
- Use implicit class and
void main()— Java 25 supports running single-file programs without an explicit class declaration - Add necessary imports — the snippet JSON/YAML doesn't include imports; add whatever is needed for compilation
- Add minimal scaffolding — if the snippet references variables or types not defined in the code, add stub declarations so it compiles
- Keep it minimal — the goal is compilation proof, not a full test suite
- Include the
/// Proof:and/// Source:comments — links the proof file back to the content source
- Don't add runtime assertions or test logic
- Don't restructure the modern code — keep it as close to the snippet as possible
- Don't add the old code
java --enable-preview proof/language/TypeInferenceWithVar.java# Compile every proof file and report failures
find proof -name '*.java' -exec sh -c '
echo "Compiling: $1"
java --enable-preview "$1" 2>&1 || echo "FAILED: $1"
' _ {} \;- Java 25+ — proof files use implicit classes and
void main()which require--enable-preview
When adding a new pattern:
- Create the content file under
content/category/slug.yaml - Create a proof file under
proof/category/SlugName.java - Copy the
modernCodefrom the pattern into thevoid main()body - Add imports and minimal scaffolding to make it compile
- Run
java --enable-preview proof/category/SlugName.javato verify