tags:

views:

243

answers:

2

I have a jar loaded in my classpath (in iReport if it matters) that I am certain has the desired method yet when I try to test the connection, thus calling the jar, I get a java.lang.NoSuchMethodError, saying it is referencing the class

Lorg/springframework/web/context/WebApplicationContext

I'm not sure if this is related to the problem or not but where did the 'L' at the beginning come from? Another time I was referencing a class there was a 'V' after the class. Where are these letters coming from and what do they mean?

Start of the stack trace:

java.lang.NoSuchMethodError:  
org.springframework.web.context.ContextLoader
.getCurrentWebApplicationContext()Lorg/springframework/web/context/WebApplicationContext;
+14  A: 

These letters are used by Java to encode the method signature internally. E.g., an "L" announces a following "Object", which is specified by its full class name and followed by a semicolon. The "V" should have been preceeded by parentheses and describes a return type of "void".

Take your example:

java.lang.NoSuchMethodError:
org.springframework.web.context.ContextLoader .getCurrentWebApplicationContext()Lorg/springframework/web/context/WebApplicationContext;

It says, that there is no method in class org.springframework.web.context.ContextLoader called getCurrentWebApplicationContext that accepts no arguments [denoted by ()] and returns an object (announced by L) called `org/springframework/web/context/WebApplicationContext (closed by ';').

EDIT: The list of all codes is in Table 3.2 of the JNI specs.

EDIT2: Even more authoritive: section 4.3 Descriptors of the JVM specification contains a complete reference of the format and codes.

janko
Is there a good reference for the letter codes? I was going to post essentially the same answer, but I didn't want to make unsubstantiated statements.
Michael Myers
Ah, that is a good reference.
Michael Myers
+3  A: 

The L character is used to signify a classname in Java's internal class specification.

See the Java VM spec for details.

And a table of the field types:

BaseType
B     byte (signed byte)
C     char (Unicode character)
D     double (double-precision floating-point value)
F     float (single-precision floating-point value)
I     int (integer)
J     long (long integer)
L<classname>;     reference (an instance of class <classname>)
S     short (signed short)
Z     boolean (true or false)
[     reference (one array dimension )
Rich Seller