Safely Shoot Yourself in the Foot with Java 9
summary
Java 9 replaces many Unsafe uses with VarHandle vs Unsafe for faster, checked access but Unsafe remains reachable; MethodHandles.privateLookupIn lets code deep-reflect and read or copy private byte[] string contents (final fields still resist direct reassignment). Memory-mapped files still require unmapping and calling the manual Cleaner unmap trick can produce segmentation faults. Other specifics: Striped64/LongAdder and ThreadLocalRandom probe fields change contention behavior, JShell scripting and module flags like --add-opens/--patch-module enable hacks, and CMS removal pushes users toward G1.
AI-written summary · about
chapters (15)
- 0:00Introduction and welcome
- 1:13Java 9 security improvements
- 3:41Unsafe and its dangers
- 7:37Variable handles in Java 9
- 11:10LongAdder and contended fields
- 14:23ThreadLocalRandom and hacks
- 17:18Deep reflection with VarHandles
- 23:13Bypassing module restrictions
- 26:52JShell for scripting
- 30:04Memory-mapped files in Java
- 37:20Java Flight Recorder changes
- 38:22Modifying JDK internals
- 41:13Parallel streams pitfalls
- 42:41BigInteger private method hack
- 45:43Q&A session
related talks
48mSafely Shoot Yourself in the Foot with Java 9
46mUnsafe (and Java 9/10) (RU)
41mJava 9 VarHandles Best practices, and why?
18mThe Secret History and Tragic Fate of sun.misc.Unsafe
49mA Post Apocalyptic sun misc Unsafe World
39mSafety first
42mJava 9 - What are we going to love/hate this time
48mJava 9 Performance
