Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Understanding method signature in NoSuchMethod exception

I got this exception but resolved it.

java.lang.NoSuchMethodError: antlr.NoViableAltForCharException.<init>
(CLjava/lang/String;II)V

But i'd like to know how to interpret these kind of messages: "(CLjava/lang/String;II)V" Also, does this "init" mention the constructor of NoViableAltForCharException class??

Thanks.

like image 699
popcoder Avatar asked Dec 01 '11 15:12

popcoder


People also ask

What does add exception to method signature mean?

If a method declares an exception in its signature, you cannot use this method without handling the exception - you can't compile the program. Example 1: The program did not handle the exception declared, resutled in compilation error. import java. util. Scanner; import java.

Is exception part of method signature?

The mechanics. When a call is made to method1() , you must make the call from within a try/catch block. In this case, it's a checked exception because you must catch it. Checked exceptions are always declared as thrown in the method signature.

What do you mean by method signature with example?

In Java, a method signature is part of the method declaration. It's the combination of the method name and the parameter list. The reason for the emphasis on just the method name and parameter list is because of overloading. It's the ability to write methods that have the same name but accept different parameters.

What is method of signature?

The method signature in java is defined as the structure of the method that is designed by the programmer. The method signature is the combination of the method name and the parameter list. The method signature depicts the behavior of the method i.e types of values of the method, return type of the method, etc.


1 Answers

Type Signatures - taken from this page.

The JNI uses the Java VM’s representation of type signatures. Table 3-2 shows these type signatures.

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

For example, the Java method:

long f (int n, String s, int[] arr);

has the following type signature:

(ILjava/lang/String;[I)J
like image 67
gkamal Avatar answered Sep 28 '22 06:09

gkamal