理解NoSuchMethod异常中的方法签名

pop*_*der 14 java constructor exception init nosuchmethoderror

我得到了这个例外,但解决了它.

java.lang.NoSuchMethodError: antlr.NoViableAltForCharException.<init>
(CLjava/lang/String;II)V
Run Code Online (Sandbox Code Playgroud)

但是我想知道如何解释这些消息:"(CLjava/lang/String; II)V"另外,这个"init"是否提到了NoViableAltForCharException类的构造函数?

谢谢.

gka*_*mal 26

输入签名 - 取自此页面.

JNI使用Java VM的类型签名表示.表3-2显示了这些类型的签名.

Z                               boolean
B                               byte
C                               char
S                               short
I                               int
J                               long
F                               float
D                               double
L fully-qualified-class ;       fully-qualified-class
[ type                          type[]
( arg-types ) ret-type          method type
Run Code Online (Sandbox Code Playgroud)

例如,Java方法:

long f (int n, String s, int[] arr);
Run Code Online (Sandbox Code Playgroud)

具有以下类型签名:

(ILjava/lang/String;[I)J
Run Code Online (Sandbox Code Playgroud)


Pet*_*rey 7

它正在寻找一个构造函数antlr.NoViableAltForCharException(char, String, int, int)但却无法在类中找到它.

<init>方法是构造函数,<cinit>方法是静态初始化块.参数类型由@gkamal列出,添加V为void.理论上构造函数返回void的原因V是签名结束时的原因.

顺便说一句:或许很讽刺的J是,它可能是长期的,而且L是为了类,当它可能已经很L长时间和JJava类.;)