Operator Overloading with Type Classes
summary
Project Valhalla prototypes add limited operator overloading for value classes using a invoke dynamic prototype that maps operator tokens to static methods via a witness field mapping. JDK 28 EA already contains value-type previews; type classes require value classes (BigInteger is excluded because it’s nonfinal). The design bundles operators (add/sub/mul/div, comparisons) and plans automatic conversions next. Runtime uses JVM inlining and JIT to remove indirection so performance approaches primitive speed despite bytecode opcode limits.
AI-written summary · about
chapters (9)
- 0:00Intro
- 1:25What is a Number?
- 5:10Type Classes
- 9:37Groups and Other Math
- 13:14Floating Point Numbers
- 16:35Type Class Mechanics & Performance
- 26:07Lumping vs Splitting Operations
- 33:28Neutral Elements
- 35:54Next Steps








