2009-10-02 94 views
12

我有一個罐子在我的類路徑加載(在iReport的,如果它事項),我敢肯定有希望的方法,但當我試圖測試連接,從而調用罐子,我得到一個java.lang.NoSuchMethodError,說它正在引用該類爲什麼將「L」添加到我的Java路徑中?

Lorg/springframework/web/context/WebApplicationContext 

我不確定這是否與問題有關,但是開頭的'L'來自哪裏?另一次我參考一個課時,課後有一個'V'。這些信件來自哪裏,它們是什麼意思?

開始的堆棧跟蹤:

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

回答

24

這些字母都使用Java來在內部編碼方法簽名。例如,一個「L」宣佈一個後面的「對象」,由它的全部類名指定,後面跟着一個分號。 「V」應該先括號括起來,並描述返回類型「void」。

把你的例子:

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

它說,有名爲getCurrentWebApplicationContextorg.springframework.web.context.ContextLoader類沒有方法不接受任何參數[由()表示],並返回調用的對象(由L公佈)`組織/ springframework/web/context/WebApplicationContext(由';'結尾)。

編輯:所有代碼清單在JNI specs的表3.2中。

EDIT2:更具權威性:JVM規範的4.3 Descriptors部分包含格式和代碼的完整參考。

+2

是否有字母代碼一個很好的參考?我打算髮表基本相同的答案,但我不想做不成立的陳述。 – 2009-10-02 14:53:15

+0

啊,這是一個很好的參考。 – 2009-10-02 15:38:51

8

L字符用來表示在Java中的內部類規範類名。

Java VM spec瞭解詳情。

而字段類型的table

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) 
+0

我還發現: P - 項目 F - 文件夾 – Seagull 2017-11-14 14:39:43