1.1 --- a/src/share/classes/com/sun/tools/javac/jvm/ClassReader.java Fri Dec 28 22:25:21 2012 -0800 1.2 +++ b/src/share/classes/com/sun/tools/javac/jvm/ClassReader.java Sat Dec 29 17:33:17 2012 -0800 1.3 @@ -217,6 +217,13 @@ 1.4 */ 1.5 boolean haveParameterNameIndices; 1.6 1.7 + /** Set this to false every time we start reading a method 1.8 + * and are saving parameter names. Set it to true when we see 1.9 + * MethodParameters, if it's set when we see a LocalVariableTable, 1.10 + * then we ignore the parameter names from the LVT. 1.11 + */ 1.12 + boolean sawMethodParameters; 1.13 + 1.14 /** 1.15 * The set of attribute names for which warnings have been generated for the current class 1.16 */ 1.17 @@ -984,7 +991,7 @@ 1.18 new AttributeReader(names.LocalVariableTable, V45_3, CLASS_OR_MEMBER_ATTRIBUTE) { 1.19 protected void read(Symbol sym, int attrLen) { 1.20 int newbp = bp + attrLen; 1.21 - if (saveParameterNames) { 1.22 + if (saveParameterNames && !sawMethodParameters) { 1.23 // Pick up parameter names from the variable table. 1.24 // Parameter names are not explicitly identified as such, 1.25 // but all parameter name entries in the LocalVariableTable 1.26 @@ -1017,6 +1024,25 @@ 1.27 } 1.28 }, 1.29 1.30 + new AttributeReader(names.MethodParameters, V52, MEMBER_ATTRIBUTE) { 1.31 + protected void read(Symbol sym, int attrlen) { 1.32 + int newbp = bp + attrlen; 1.33 + if (saveParameterNames) { 1.34 + sawMethodParameters = true; 1.35 + int numEntries = nextByte(); 1.36 + parameterNameIndices = new int[numEntries]; 1.37 + haveParameterNameIndices = true; 1.38 + for (int i = 0; i < numEntries; i++) { 1.39 + int nameIndex = nextChar(); 1.40 + int flags = nextInt(); 1.41 + parameterNameIndices[i] = nameIndex; 1.42 + } 1.43 + } 1.44 + bp = newbp; 1.45 + } 1.46 + }, 1.47 + 1.48 + 1.49 new AttributeReader(names.SourceFile, V45_3, CLASS_ATTRIBUTE) { 1.50 protected void read(Symbol sym, int attrLen) { 1.51 ClassSymbol c = (ClassSymbol) sym; 1.52 @@ -1826,6 +1852,7 @@ 1.53 } else 1.54 Arrays.fill(parameterNameIndices, 0); 1.55 haveParameterNameIndices = false; 1.56 + sawMethodParameters = false; 1.57 } 1.58 1.59 /** 1.60 @@ -1845,12 +1872,16 @@ 1.61 // if no names were found in the class file, there's nothing more to do 1.62 if (!haveParameterNameIndices) 1.63 return; 1.64 - 1.65 - int firstParam = ((sym.flags() & STATIC) == 0) ? 1 : 0; 1.66 - // the code in readMethod may have skipped the first parameter when 1.67 - // setting up the MethodType. If so, we make a corresponding allowance 1.68 - // here for the position of the first parameter. Note that this 1.69 - // assumes the skipped parameter has a width of 1 -- i.e. it is not 1.70 + // If we get parameter names from MethodParameters, then we 1.71 + // don't need to skip. 1.72 + int firstParam = 0; 1.73 + if (!sawMethodParameters) { 1.74 + firstParam = ((sym.flags() & STATIC) == 0) ? 1 : 0; 1.75 + // the code in readMethod may have skipped the first 1.76 + // parameter when setting up the MethodType. If so, we 1.77 + // make a corresponding allowance here for the position of 1.78 + // the first parameter. Note that this assumes the 1.79 + // skipped parameter has a width of 1 -- i.e. it is not 1.80 // a double width type (long or double.) 1.81 if (sym.name == names.init && currentOwner.hasOuterInstance()) { 1.82 // Sometimes anonymous classes don't have an outer 1.83 @@ -1861,17 +1892,20 @@ 1.84 } 1.85 1.86 if (sym.type != jvmType) { 1.87 - // reading the method attributes has caused the symbol's type to 1.88 - // be changed. (i.e. the Signature attribute.) This may happen if 1.89 - // there are hidden (synthetic) parameters in the descriptor, but 1.90 - // not in the Signature. The position of these hidden parameters 1.91 - // is unspecified; for now, assume they are at the beginning, and 1.92 - // so skip over them. The primary case for this is two hidden 1.93 - // parameters passed into Enum constructors. 1.94 + // reading the method attributes has caused the 1.95 + // symbol's type to be changed. (i.e. the Signature 1.96 + // attribute.) This may happen if there are hidden 1.97 + // (synthetic) parameters in the descriptor, but not 1.98 + // in the Signature. The position of these hidden 1.99 + // parameters is unspecified; for now, assume they are 1.100 + // at the beginning, and so skip over them. The 1.101 + // primary case for this is two hidden parameters 1.102 + // passed into Enum constructors. 1.103 int skip = Code.width(jvmType.getParameterTypes()) 1.104 - Code.width(sym.type.getParameterTypes()); 1.105 firstParam += skip; 1.106 } 1.107 + } 1.108 List<Name> paramNames = List.nil(); 1.109 int index = firstParam; 1.110 for (Type t: sym.type.getParameterTypes()) {