Skip to content

Commit 58de282

Browse files
committed
docs/claude: note that the jdk1.4 preprocessor's generic stripping leaves a generic interface implemented with the type argument's signature overriding nothing.
1 parent 239fb23 commit 58de282

1 file changed

Lines changed: 14 additions & 4 deletions

File tree

‎docs/claude/build-jdk14.md‎

Lines changed: 14 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -18,9 +18,9 @@ passes (patterns in `ant/build.regexp`) over the result. The preprocessor strips
1818
`@Override`/`@Deprecated`/`@SuppressWarnings`, rewrites `StringBuilder`→`StringBuffer`, and
1919
turns varargs *declarations* (`...`) into arrays.
2020

21-
What is therefore FINE in 1.4-reachable code: generics, `StringBuilder`, varargs
22-
declarations. What is NOT (the regexes can't fix syntax or APIs): enhanced-for loops,
23-
autoboxing, enums, covariant return overrides, varargs *call sites*, and any post-1.4 API —
21+
What is therefore FINE in 1.4-reachable code: generics (but see the erased-override trap
22+
below), `StringBuilder`, varargs declarations. What is NOT (the regexes can't fix syntax or
23+
APIs): enhanced-for loops, autoboxing, enums, covariant return overrides, varargs *call sites*, and any post-1.4 API —
2424
`String.contains`/`isEmpty`, `System.clearProperty` (use `System.getProperties().remove`),
2525
`java.nio.charset.StandardCharsets` (Java 7 — use BC `Strings.toUTF8ByteArray` /
2626
`Strings.toByteArray`; this is the single most common way a new *test* breaks this build),
@@ -35,12 +35,22 @@ or plain `Thread` + `join`), `ArrayDeque`, `ResourceBundle.Control`,
3535
exception constructors (use `Exceptions` / `SecurityExceptions` factories, or
3636
`super(msg)` + `initCause` in subclasses), and `ThreadLocal.remove()` (use `set(null)`).
3737

38-
Two 1.4-only compiler/runtime traps with no modern analogue:
38+
1.4-only compiler/runtime traps with no modern analogue:
3939

4040
- **`System.getenv` throws `java.lang.Error` on JRE 1.4** ("getenv no longer supported").
4141
The six `TestResourceFinder` copies guard their `BC_TEST_DATA_HOME` lookup with
4242
`catch (Error)` for this reason — any new env-var read in test-reachable code needs the
4343
same guard.
44+
- **Implementing a generic interface with the type argument's signature collapses.** The
45+
type parameters are stripped but the method parameters are not, so
46+
`new Comparator<IndexedHash>() { public int compare(IndexedHash l, IndexedHash r) }`
47+
becomes a raw `Comparator` declaring `compare(IndexedHash, IndexedHash)` and real 1.4 javac
48+
rejects it - "is not abstract and does not override abstract method
49+
`compare(java.lang.Object,java.lang.Object)`". Implement such an interface with the erased
50+
signature and cast inside, as `tsp/ers/ByteArrayComparator` and
51+
`SortedIndexedHashList.DigestComparator` do. Cheap check without the full build: run the
52+
`ant/build.regexp` pattern over the file and its package and compile the result with
53+
`/opt/jdk1.4.2/bin/javac`.
4454
- **JLS2 static method hiding requires identical return types.** A subclass static
4555
`getInstance(Object)` cannot narrow the parent's return type on 1.4 javac — that is why
4656
the `util/src/main/jdk1.4` cmp overlays (`CertAnnContent`, `OOBCert`,

0 commit comments

Comments
 (0)