Uploaded image for project: 'JDK'
  1. JDK
  2. JDK-8006704

Method parameters inconsistent for inner classes

XMLWordPrintable

    • Icon: Bug Bug
    • Resolution: Duplicate
    • Icon: P3 P3
    • None
    • None
    • tools
    • 8

      Given the test class below, the compiler generates a MethodParameters attribute
      for the 'arg' parameter of the constructor of the inner class InnerTest$Inner, recording
      no name for the implicit first argument (ref to enclosing class).

      However, for the anonymous inner class InnerTest$1, it generates a MethodParameters
      attribute for one argument (x0) - I'm not sure if this is the name synthesized for the first or
      second parameter. In any case, this name is synthesized.

      For both classes, the MethodParameters attribute length is one less than the parameter list.
      I'm not sure what the correct attribute would be, but it seems that it can't be correct in both
      cases.

      To reproduce. Compile the following class with -parameters option.
      The class can be examined with javap or using the ClassFile library
      (the issue is in the classfile, not in javap outut which reflect the class file content).

      class InnerTest {

          public class Inner {
      public Inner(String arg) { }
      public String m(String s) { return s.trim(); }
          }

          public InnerTest(String... strs) {
      for (String s : strs) new Inner(s) {
                  public String m(String y) { return y; }
      }.m(s);
          }
      }

            emc Eric Mccorkle
            strarup Peter Jensen (Inactive)
            Votes:
            0 Vote for this issue
            Watchers:
            3 Start watching this issue

              Created:
              Updated:
              Resolved: