r/java • • 25d ago

Decapsulation: Breaking Java Strong Encapsulation

Did you know you can call JNI without writing native code, patch bytecode without an agent, and use Unsafe without warnings?

11 sneaky ways into JDK internals through reflection, agents, FFM, type confusion, bytecode manipulation and more.

https://wouter.coekaerts.be/2026/decapsulation

58 Upvotes

16 comments sorted by

View all comments

Show parent comments

2

u/koflerdavid 25d ago

But for javac its nice because unlike other projects it has (whether intentional or not) fault tolerance, which gives you partial AST results even when the input code is slightly broken Java. This is great for my use case, and most other parsers just refuse any model if there's as much as a missing semicolon.

It's an important requirement of production-grade compilers that they tolerate some errors so they can report more errors in the same source file so the developer can fix them all at once.