Ayrx / JNIAnalyzer

Analysis scripts for Ghidra to work with Android NDK libraries.
320 stars 29 forks source link

module java.base does not "opens java.util" to unnamed module #15

Closed ChongChengAC closed 1 year ago

ChongChengAC commented 1 year ago

I met this error while running JNIAnalyzer.java. Google said I need to run java with --add-opens java.base/java.util=ALL-UNNAMED like this:

java --add-opens java.base/java.util=ALL-UNNAMED TestReflect.java

Is there a way to run with given arguments in ghidra's Script Manager? Or could you please update source codes and fix the error?

detail:

java.lang.ExceptionInInitializerError
    at jadx.core.dex.instructions.InsnDecoder.invoke(InsnDecoder.java:678)
    at jadx.core.dex.instructions.InsnDecoder.decode(InsnDecoder.java:533)
    at jadx.core.dex.instructions.InsnDecoder.process(InsnDecoder.java:77)
    at jadx.core.dex.nodes.MethodNode.load(MethodNode.java:124)
    at jadx.core.dex.nodes.ClassNode.load(ClassNode.java:249)
    at jadx.core.ProcessClass.process(ProcessClass.java:27)
    at jadx.api.JadxDecompiler.processClass(JadxDecompiler.java:311)
    at jadx.api.JavaClass.decompile(JavaClass.java:62)
    at jadx.api.JavaClass.getMethods(JavaClass.java:249)
    at me.ayrx.jnianalyzer.ParseJNIMethods.parse(ParseJNIMethods.java:24)
    at JNIAnalyzer.run(JNIAnalyzer.java:41)
    at ghidra.app.script.GhidraScript.executeNormal(GhidraScript.java:395)
    at ghidra.app.script.GhidraScript.doExecute(GhidraScript.java:250)
    at ghidra.app.script.GhidraScript.execute(GhidraScript.java:228)
    at ghidra.app.plugin.core.script.RunScriptTask.run(RunScriptTask.java:47)
    at ghidra.util.task.Task.monitoredRun(Task.java:134)
    at ghidra.util.task.TaskRunner.lambda$startTaskThread$0(TaskRunner.java:106)
    at java.base/java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1144)
    at java.base/java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:642)
    at java.base/java.lang.Thread.run(Thread.java:1589)
Caused by: java.lang.reflect.InaccessibleObjectException: Unable to make field private transient java.util.NavigableMap java.util.TreeSet.m accessible: module java.base does not "opens java.util" to unnamed module @b7d5b91
    at java.base/java.lang.reflect.AccessibleObject.throwInaccessibleObjectException(AccessibleObject.java:387)
    at java.base/java.lang.reflect.AccessibleObject.checkCanSetAccessible(AccessibleObject.java:363)
    at java.base/java.lang.reflect.AccessibleObject.checkCanSetAccessible(AccessibleObject.java:311)
    at java.base/java.lang.reflect.Field.checkCanSetAccessible(Field.java:180)
    at java.base/java.lang.reflect.Field.setAccessible(Field.java:174)
    at com.rits.cloning.Cloner.addAll(Cloner.java:563)
    at com.rits.cloning.Cloner.allFields(Cloner.java:577)
    at com.rits.cloning.Cloner.registerStaticFields(Cloner.java:209)
    at com.rits.cloning.Cloner.registerKnownConstants(Cloner.java:190)
    at com.rits.cloning.Cloner.init(Cloner.java:85)
    at com.rits.cloning.Cloner.<init>(Cloner.java:56)
    at jadx.core.dex.nodes.InsnNode.<clinit>(InsnNode.java:30)
    ... 20 more

---------------------------------------------------
Build Date: 2022-Nov-12 2231 CET
Ghidra Version: 10.2.1
Java Home: /usr/lib/jvm/java-19-openjdk
JVM Version: N/A 19.0.1
OS: Linux 5.19.17-2-MANJARO amd64

java-17-openjdk also has this error. It is said that it will report an error in versions above java8.

NamPNQ commented 1 year ago

Add line VMARGS=--add-opens java.base/java.util=ALL-UNNAMED in file ghidra/support/launch.properties

ChongChengAC commented 1 year ago

Add line VMARGS=--add-opens java.base/java.util=ALL-UNNAMED in file ghidra/support/launch.properties

Thanks! It works.