Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Why is an "L" getting added to my Java path?

Tags:

java

jar

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;
like image 944
RobbR Avatar asked Oct 02 '09 14:10

RobbR


2 Answers

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.

like image 85
janko Avatar answered Oct 29 '22 19:10

janko


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 )
like image 42
Rich Seller Avatar answered Oct 29 '22 19:10

Rich Seller