Get JNI Signature for methods of nested classes

2019-05-31 21:55发布

Lets say I have a class called Scope that has a nested class called Variable, how exactly do I use javap -s to get the JNI signatures of the classes inside? I've tried doing

javap -classpath <classpath> -s Scope$Variable

, but this does not seem to work. It seems to just get me the same information as if I only typed "Scope" rather than "Scope$Variable".

Thanks for any help

2条回答
爷的心禁止访问
2楼-- · 2019-05-31 22:19

If you are running javap in a Linux/Unix environment, then the $ will be interpreted by the shell and not by javap. Therefore it mus be escaped. Simplest solution would be:

javap -classpath <classpath> -s 'Scope$Variable'

Without the quotes the shell (I assume a *sh offspring) will try to substitute the $Variable part with the contents of the environment variable Variable. I assume that no such variable exists and there fore nothing (as in "empty string") is substituted. Hence javap sees only

javap -classpath <classpath> -s Scope

If you are running the command from Windows, then this is not an issue, because the magical character would be %.

BTW: I don't know why JNI is involved here.

查看更多
放荡不羁爱自由
3楼-- · 2019-05-31 22:21

Works for me: javap -s com.oracle.net.Sdp$SdpSocket:

Compiled from "Sdp.java"
class com.oracle.net.Sdp$SdpSocket extends java.net.Socket{
com.oracle.net.Sdp$SdpSocket(java.net.SocketImpl)   throws java.net.SocketExcept
ion;
  Signature: (Ljava/net/SocketImpl;)V
}
查看更多
登录 后发表回答