Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Interpreting java.lang.NoSuchMethodError message

I get the following runtime error message (along with the first line of the stack trace, which points to line 94). I'm trying to figure out why it says no such method exists.

java.lang.NoSuchMethodError:  com.sun.tools.doclets.formats.html.SubWriterHolderWriter.printDocLinkForMenu(     ILcom/sun/javadoc/ClassDoc;Lcom/sun/javadoc/MemberDoc;     Ljava/lang/String;Z)Ljava/lang/String; at com.sun.tools.doclets.formats.html.AbstractExecutableMemberWriter.writeSummaryLink(     AbstractExecutableMemberWriter.java:94) 

Line 94 of writeSummaryLink is shown below.

QUESTIONS
What does "ILcom" or "Z" mean?
Why there are four types in parentheses (ILcom/sun/javadoc/ClassDoc;Lcom/sun/javadoc/MemberDoc;Ljava/lang/String;Z) and one after the parentheses Ljava/lang/String; when the method printDocLinkForMenu clearly has five parameters?

CODE DETAIL
The writeSummaryLink method is:

protected void writeSummaryLink(int context, ClassDoc cd, ProgramElementDoc member) {     ExecutableMemberDoc emd = (ExecutableMemberDoc)member;     String name = emd.name();     writer.strong();     writer.printDocLinkForMenu(context, cd, (MemberDoc) emd, name, false);  // 94     writer.strongEnd();     writer.displayLength = name.length();     writeParameters(emd, false); } 

Here's the method line 94 is calling:

public void printDocLinkForMenu(int context, ClassDoc classDoc, MemberDoc doc,         String label, boolean strong) {     String docLink = getDocLink(context, classDoc, doc, label, strong);     print(deleteParameterAnchors(docLink)); } 
like image 305
dougkramer Avatar asked May 31 '10 20:05

dougkramer


People also ask

What does NoSuchMethodError mean?

NoSuchMethodError is a runtime error in Java which occurs when a method is called that exists at compile-time, but does not exist at runtime. The Java Garbage Collector (GC) cannot free up the space required for a new object, which causes a java. lang. OutOfMemoryError .

What is Exception in thread main Java Lang NoSuchMethodError?

NoSuchMethodError: main Exception in thread "main" can come due to various reasons like: 1) The class which you are trying to run doesn't have the main method. 2) The signature of the main method is not correct. See here for all possible signatures of the main method in Java.


1 Answers

From section 4.3.2 of the JVM Spec:

 Character     Type          Interpretation ------------------------------------------ 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  S             short         signed short Z             boolean       true or false [             reference     one array dimension 

From section 4.3.3, Method descriptors:

A method descriptor represents the parameters that the method takes and the value that it returns:

MethodDescriptor:         ( ParameterDescriptor* ) ReturnDescriptor 

Thus,

(ILcom/sun/javadoc/ClassDoc;Lcom/sun/javadoc/MemberDoc;Ljava/lang/String;Z) Ljava/lang/String;

translates to:

A method with int, ClassDoc, MemberDoc, String and boolean as parameters, and which returns a String. Note that only reference parameters are separated with a semicolon, since the semicolon is part of their character representation.


So, to sum up:

Why there are four types in parentheses (ILcom/sun/javadoc/ClassDoc;Lcom/sun/javadoc/MemberDoc;Ljava/lang/String;Z) and one after the parentheses Ljava/lang/String; when the method printDocLinkForMenu clearly has five parameters?

There are five parameters (int, ClassDoc, MemberDoc, String, boolean) and one return type (String).

like image 121
JRL Avatar answered Sep 23 '22 19:09

JRL