Type Specialization of Java Generics - What If Casts Have Teeth ?
summary
Patch to javac propagates type arguments at runtime, creating an AR field per parameterized instance and inserting method-entry checks and cast checks; the experimental Diego prototype rewrites constructors and synthetic bridge methods so recompiled classes interoperate with legacy jars. Running it against a JDK build shows many failing checkcast insertions, mostly from enforcing method-entry/exit and from shared singletons (immutable empty lists, optional.empty) and tricky generic casts in stream/collection APIs, so full reification breaks substantial existing Java code.
AI-written summary · about
chapters (14)
- 0:00Introduction and context
- 1:35The problem: generics vs value types
- 4:21Defining the spectrum of specialization
- 10:48Experimentation with Diego
- 14:53Prototype architecture
- 17:49Implementation details
- 21:30Adding runtime checks
- 24:14Handling separate compilation
- 27:09Inheritance and raw types
- 31:02Compiler modifications
- 33:39Results of the experiment
- 35:48Fixing common language issues
- 39:49Challenges in upgrading legacy code
- 42:31Conclusion and Q&A








