Skip to content

Commit 2564051

Browse files
Copilotbrunoborges
andcommitted
Rework proof script to use existing proof/ Java files instead of YAML proofCode
The existing proof/ directory (from a parallel branch) contains 105 individual JBang scripts - one per pattern - that were missed in the initial approach. Changes: - Add all 105 proof/**/*.java scripts from proof/ directory - Rewrite html-generators/proof.java to run proof/**/*.java via jbang instead of parsing YAML proofCode fields through JShell - Revert the proofCode field additions from 10 YAML content files - Revert proofCode from generate.java/generate.py EXCLUDED_KEYS - Revert proofCode from content/template.json - Update .github/workflows/proof.yml to trigger on proof/** changes - Update html-generators/README.md, CONTRIBUTING.md, and .github/copilot-instructions.md to document the proof/ directory Co-authored-by: brunoborges <129743+brunoborges@users.noreply.github.com>
1 parent 16567bd commit 2564051

File tree

123 files changed

+2042
-194
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

123 files changed

+2042
-194
lines changed

.github/copilot-instructions.md

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -49,6 +49,10 @@ Run `jbang html-generators/generate.java` to rebuild all generated files from th
4949

5050
```
5151
content/ # English content JSON files (source of truth, one per pattern)
52+
proof/ # Proof scripts — one JBang .java file per pattern, proving it compiles
53+
language/ # e.g. proof/language/TypeInferenceWithVar.java
54+
collections/ # e.g. proof/collections/ImmutableListCreation.java
55+
... # mirrors content/ category structure
5256
translations/ # All i18n artifacts
5357
strings/ # UI strings per locale (en.yaml, es.yaml, pt-BR.yaml)
5458
content/ # Translated pattern files per locale (partial, translatable fields only)
@@ -100,8 +104,7 @@ Each `content/category/slug.json` file has this structure:
100104
],
101105
"docs": [
102106
{ "title": "Javadoc or Guide Title", "href": "https://docs.oracle.com/..." }
103-
],
104-
"proofCode": "// Optional: self-contained JShell snippet proving the modern approach works.\n// Run with: jbang html-generators/proof.java"
107+
]
105108
}
106109
```
107110

@@ -139,7 +142,8 @@ Categories and their display names are defined in `html-generators/categories.pr
139142
1. Create `content/category/new-slug.json` with all required fields
140143
2. Update `prev`/`next` in the adjacent patterns' JSON files
141144
3. Run `jbang html-generators/generate.java`
142-
4. (Optional) Create translated content files under `translations/content/{locale}/category/new-slug.json` with only translatable fields — or let the AI translation workflow handle it
145+
4. Add a proof script at `proof/category/SlugName.java` (JBang, `//JAVA 25+`) — run `jbang html-generators/proof.java` to verify
146+
5. (Optional) Create translated content files under `translations/content/{locale}/category/new-slug.json` with only translatable fields — or let the AI translation workflow handle it
143147

144148
## Internationalization (i18n)
145149

.github/workflows/proof.yml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,12 +4,12 @@ on:
44
push:
55
branches: [main]
66
paths:
7-
- 'content/**'
7+
- 'proof/**'
88
- 'html-generators/proof.java'
99
- '.github/workflows/proof.yml'
1010
pull_request:
1111
paths:
12-
- 'content/**'
12+
- 'proof/**'
1313
- 'html-generators/proof.java'
1414
workflow_dispatch:
1515

CONTRIBUTING.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ Contributions are welcome! Content is managed as YAML files — never edit gener
99
3. Copy [`content/template.json`](content/template.json) as a starting point for all required fields (see the [snippet schema](.github/copilot-instructions.md) for details)
1010
4. Update the `prev`/`next` fields in adjacent pattern files to maintain navigation
1111
5. Run `jbang html-generators/generate.java` to verify your changes build correctly
12-
6. Optionally add a `proofCode` field — a self-contained JShell snippet that proves the modern approach works. Run `jbang html-generators/proof.java` to validate it.
12+
6. Add a proof script at `proof/<category>/SlugName.java` that uses the modern approach and run `jbang html-generators/proof.java` to verify it passes
1313
7. Open a pull request
1414

1515
Please ensure JDK version labels only reference the version where a feature became **final** (non-preview).

content/collections/immutable-list-creation.yaml

Lines changed: 0 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -47,11 +47,3 @@ docs:
4747
href: "https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/util/List.html#of()"
4848
- title: "Collections Factory Methods (JEP 269)"
4949
href: "https://openjdk.org/jeps/269"
50-
proofCode: |-
51-
var list = List.of("a", "b", "c");
52-
if (list.size() != 3) throw new AssertionError("expected 3 elements");
53-
try {
54-
list.add("d");
55-
throw new AssertionError("should have thrown UnsupportedOperationException");
56-
} catch (UnsupportedOperationException ok) {}
57-
IO.println("immutable list: OK - " + list);

content/concurrency/virtual-threads.yaml

Lines changed: 0 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -47,13 +47,3 @@ docs:
4747
href: "https://openjdk.org/jeps/444"
4848
- title: "Thread.ofVirtual()"
4949
href: "https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Thread.html#ofVirtual()"
50-
proofCode: |-
51-
var results = new java.util.concurrent.CopyOnWriteArrayList<String>();
52-
var threads = new ArrayList<Thread>();
53-
for (int i = 0; i < 5; i++) {
54-
int idx = i;
55-
threads.add(Thread.startVirtualThread(() -> results.add("vt-" + idx)));
56-
}
57-
for (var t : threads) t.join();
58-
if (results.size() != 5) throw new AssertionError("expected 5 results, got: " + results.size());
59-
IO.println("virtual threads: OK - " + results.size() + " threads ran");

content/datetime/java-time-basics.yaml

Lines changed: 0 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -51,12 +51,3 @@ docs:
5151
href: "https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/time/LocalTime.html"
5252
- title: "LocalDateTime"
5353
href: "https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/time/LocalDateTime.html"
54-
proofCode: |-
55-
import java.time.*;
56-
var date = LocalDate.of(2025, Month.JANUARY, 15);
57-
var time = LocalTime.of(14, 30);
58-
if (date.getMonthValue() != 1) throw new AssertionError("expected January=1, got: " + date.getMonthValue());
59-
if (time.getHour() != 14) throw new AssertionError("expected hour=14, got: " + time.getHour());
60-
var now = Instant.now();
61-
if (now == null) throw new AssertionError("Instant.now() returned null");
62-
IO.println("java.time basics: OK - " + date + " " + time);

content/language/pattern-matching-instanceof.yaml

Lines changed: 0 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -44,11 +44,3 @@ related:
4444
docs:
4545
- title: "Pattern Matching for instanceof (JEP 394)"
4646
href: "https://openjdk.org/jeps/394"
47-
proofCode: |-
48-
Object obj = "Hello, pattern matching!";
49-
if (obj instanceof String s) {
50-
IO.println("length=" + s.length());
51-
} else {
52-
throw new AssertionError("should have matched String");
53-
}
54-
IO.println("pattern matching instanceof: OK");

content/language/records-for-data-classes.yaml

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -46,8 +46,3 @@ docs:
4646
href: "https://openjdk.org/jeps/395"
4747
- title: "Record class"
4848
href: "https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Record.html"
49-
proofCode: |-
50-
public record Point(int x, int y) {}
51-
var p = new Point(1, 2);
52-
if (p.x() != 1 || p.y() != 2) throw new AssertionError("accessor mismatch");
53-
IO.println("records: OK - " + p);

content/language/switch-expressions.yaml

Lines changed: 0 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -53,12 +53,3 @@ related:
5353
docs:
5454
- title: "Switch Expressions (JEP 361)"
5555
href: "https://openjdk.org/jeps/361"
56-
proofCode: |-
57-
var day = "MONDAY";
58-
String msg = switch (day) {
59-
case "MONDAY" -> "Start";
60-
case "FRIDAY" -> "End";
61-
default -> "Mid";
62-
};
63-
if (!"Start".equals(msg)) throw new AssertionError("unexpected: " + msg);
64-
IO.println("switch expressions: OK - " + msg);

content/language/text-blocks-for-multiline-strings.yaml

Lines changed: 0 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -49,12 +49,3 @@ docs:
4949
href: "https://openjdk.org/jeps/378"
5050
- title: "Text Blocks Guide"
5151
href: "https://docs.oracle.com/en/java/javase/25/language/text-blocks.html"
52-
proofCode: |-
53-
String json = """
54-
{
55-
"name": "Duke",
56-
"age": 30
57-
}""";
58-
if (!json.contains("Duke")) throw new AssertionError("text block content missing");
59-
if (!json.contains("\n")) throw new AssertionError("text block should contain real newlines");
60-
IO.println("text blocks: OK");

0 commit comments

Comments
 (0)