Java added generics in 2004 under a constraint that decided everything else: the class file format could not change, and code compiled before generics had to keep running beside code compiled after. The answer was erasure. The compiler checks the type arguments and then discards them, so no new classes are created for parameterized types. Almost every restriction in this folder traces back to that one sentence, and the restrictions stop looking arbitrary the moment you follow the trace.

Java is one pole of this section’s comparison. The other poles are C# reification, Go stenciling, and TypeScript erasure by construction, and the comparison itself lives in Generics, Monomorphization vs Erasure. Theory stays in Programming Language Concepts; these notes are Java engineering.

What erasure is, and why it was chosen

Start here. The rest of the folder is consequence.

What the compiler has to do to make it work

Erasure moves work from the runtime to the compiler, and these three notes are that work.

Saying what a type parameter must be

An unbounded parameter can do almost nothing. Bounds and wildcards are how you buy capability back.

Where it leaks

Four places the missing runtime type argument shows through, and what the language offers instead.

The rest of the language

The ground a Java folder needs regardless of generics, ordered from the substrate upward.

Read from the comparative layer


Any pages placed under this folder are auto-listed below by Quartz.

23 items under this folder.