Interpreting java.lang.NoSuchMethodError message

后端 未结 2 1671
时光说笑
时光说笑 2020-12-04 06:35

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 exis

2条回答
  •  半阙折子戏
    2020-12-04 07:09

    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; 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).

提交回复
热议问题