JDK-8006704 : Method parameters inconsistent for inner classes
  • Type: Bug
  • Component: tools
  • Sub-Component: javac
  • Priority: P3
  • Status: Closed
  • Resolution: Duplicate
  • Submitted: 2013-01-22
  • Updated: 2013-01-22
  • Resolved: 2013-01-22
Related Reports
Duplicate :  
Description
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);
    }
}


Comments
This is a known issue, which will be fixed after M6
22-01-2013