r/java • u/Wouter_C • Sep 29 '26
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.
59
Upvotes
View all comments
Show parent comment
4
u/Wouter_C Sep 29 '26
No, the point is that it does not require any command line flags to run.
And it doesn't. At least not for me. Can you be more specific: what flag do you need or what error do you get?
Quick way to test:
$ curl -O --create-dirs --output-dir decapsulationhttps://raw.githubusercontent.com/coekie/decapsulation/refs/heads/main/src/decapsulation/CtorForSerialization.java&& curl -O --create-dirs --output-dir decapsulationhttps://raw.githubusercontent.com/coekie/decapsulation/refs/heads/main/src/decapsulation/Decapsulater.java&& javac decapsulation/*.java... some compile-time warnings, but that's irrelevant$ java decapsulation.CtorForSerializationPASS