# HG changeset patch # Parent 78b6cac476d9ce01916f23f7a87d0d3083bb8be2 8007720: Names are not load correctly for method parameters if the parameters have annotations Reviewed-by: TBD diff -r 78b6cac476d9 src/share/classes/com/sun/tools/javac/code/Symbol.java --- a/src/jdk.compiler/share/classes/com/sun/tools/javac/code/Symbol.java Tue Jan 21 09:25:10 2014 +0100 +++ b/src/jdk.compiler/share/classes/com/sun/tools/javac/code/Symbol.java Wed Jan 22 16:00:26 2014 +0100 @@ -1290,9 +1290,6 @@ /** The parameters of the method. */ public List params = null; - /** The names of the parameters */ - public List savedParameterNames; - /** For an attribute field accessor, its default value if any. * The value is null if none appeared in the method * declaration. @@ -1528,59 +1525,19 @@ public List params() { owner.complete(); if (params == null) { - // If ClassReader.saveParameterNames has been set true, then - // savedParameterNames will be set to a list of names that - // matches the types in type.getParameterTypes(). If any names - // were not found in the class file, those names in the list will - // be set to the empty name. - // If ClassReader.saveParameterNames has been set false, then - // savedParameterNames will be null. - List paramNames = savedParameterNames; - savedParameterNames = null; - // discard the provided names if the list of names is the wrong size. - if (paramNames == null || paramNames.size() != type.getParameterTypes().size()) { - paramNames = List.nil(); - } - ListBuffer buf = new ListBuffer<>(); - List remaining = paramNames; - // assert: remaining and paramNames are both empty or both - // have same cardinality as type.getParameterTypes() + ListBuffer newParams = new ListBuffer<>(); int i = 0; for (Type t : type.getParameterTypes()) { - Name paramName; - if (remaining.isEmpty()) { - // no names for any parameters available - paramName = createArgName(i, paramNames); - } else { - paramName = remaining.head; - remaining = remaining.tail; - if (paramName.isEmpty()) { - // no name for this specific parameter - paramName = createArgName(i, paramNames); - } - } - buf.append(new VarSymbol(PARAMETER, paramName, t, this)); - i++; + Name paramName = name.table.fromString("arg" + i); + VarSymbol param = new VarSymbol(PARAMETER, paramName, t, this); + newParams.append(param); } - params = buf.toList(); + params = newParams.toList(); } + Assert.checkNonNull(params); return params; } - // Create a name for the argument at position 'index' that is not in - // the exclude list. In normal use, either no names will have been - // provided, in which case the exclude list is empty, or all the names - // will have been provided, in which case this method will not be called. - private Name createArgName(int index, List exclude) { - String prefix = "arg"; - while (true) { - Name argName = name.table.fromString(prefix + index); - if (!exclude.contains(argName)) - return argName; - prefix += "$"; - } - } - public Symbol asMemberOf(Type site, Types types) { return new MethodSymbol(flags_field, name, types.memberType(site, this), owner); } diff -r 78b6cac476d9 src/share/classes/com/sun/tools/javac/jvm/ClassReader.java --- a/src/jdk.compiler/share/classes/com/sun/tools/javac/jvm/ClassReader.java Tue Jan 21 09:25:10 2014 +0100 +++ b/src/jdk.compiler/share/classes/com/sun/tools/javac/jvm/ClassReader.java Wed Jan 22 16:00:26 2014 +0100 @@ -213,8 +213,9 @@ */ int[] parameterNameIndices; + List[] parameterAnnotations; + /** - * Whether or not any parameter names have been found. */ boolean haveParameterNameIndices; @@ -1159,7 +1160,7 @@ new AttributeReader(names.RuntimeInvisibleParameterAnnotations, V49, CLASS_OR_MEMBER_ATTRIBUTE) { protected void read(Symbol sym, int attrLen) { - attachParameterAnnotations(sym); + readParameterAnnotations(sym); } }, @@ -1171,7 +1172,7 @@ new AttributeReader(names.RuntimeVisibleParameterAnnotations, V49, CLASS_OR_MEMBER_ATTRIBUTE) { protected void read(Symbol sym, int attrLen) { - attachParameterAnnotations(sym); + readParameterAnnotations(sym); } }, @@ -1420,21 +1421,26 @@ } } - /** Attach parameter annotations. + /** Read parameter annotations. */ - void attachParameterAnnotations(final Symbol method) { - final MethodSymbol meth = (MethodSymbol)method; + @SuppressWarnings({"rawtypes", "unchecked"}) + void readParameterAnnotations(final Symbol method) { int numParameters = buf[bp++] & 0xFF; - List parameters = meth.params(); - int pnum = 0; - while (parameters.tail != null) { - attachAnnotations(parameters.head); - parameters = parameters.tail; - pnum++; + if (parameterAnnotations == null) + parameterAnnotations = new List[numParameters]; + for (int pnum = 0; pnum < numParameters; pnum++) { + int numAttributes = nextChar(); + if (numAttributes != 0) { + ListBuffer proxies = new ListBuffer<>(); + for (int i = 0; i