reflection: Method/Field/MethodHandle/VarHandle demos, module and final-field rules (JEP 500 on JDK 26), JMH call-cost numbers, contract tests
Co-Authored-By: Claude Sonnet 5.5 <[email protected]> Claude-Session: https://claude.ai/code/session_017ic4b6NtPJHrkan4BXhCAM
This commit is contained in:
@@ -0,0 +1,24 @@
|
||||
$ java -cp target/classes com.ankurm.reflection.ModuleRulesDemo
|
||||
|
||||
== setAccessible on your own class ==
|
||||
Account.owner = carol
|
||||
|
||||
== setAccessible on a JDK private field ==
|
||||
String lives in module : java.base
|
||||
we live in module : unnamed module @6b95977 (unnamed=true)
|
||||
java.lang open to us : false
|
||||
trySetAccessible : false
|
||||
setAccessible threw : InaccessibleObjectException
|
||||
Unable to make field private final byte[] java.lang.String.value accessible: module java.base does not "opens java.lang" to unnamed module @6b95977
|
||||
|
||||
$ java --add-opens java.base/java.lang=ALL-UNNAMED -cp target/classes com.ankurm.reflection.ModuleRulesDemo
|
||||
|
||||
== setAccessible on your own class ==
|
||||
Account.owner = carol
|
||||
|
||||
== setAccessible on a JDK private field ==
|
||||
String lives in module : java.base
|
||||
we live in module : unnamed module @3764951d (unnamed=true)
|
||||
java.lang open to us : true
|
||||
trySetAccessible : true
|
||||
setAccessible worked, String.value is a byte[]
|
||||
Reference in New Issue
Block a user