Search code examples
javajava-native-interfacebytecode.class-filejavap

Given a class file, how to detect it uses JNI or not?


I have some Java benchmarks with only class files.

I would like to find which benchmarks have JNI calls.

I thought maybe this can be done from the bytecode level with the help of javap -c, but not sure.

Any ideas?


Solution

  • Thanks for all the answers.

    I found a simple way as below:

    java -verbose:jni -jar foo.jar

    Basically, it prints a trace message to the console showing the JNI methods.

    Here is the details about this option from HotSpot : ref