Merge

Fri, 31 Jul 2009 17:20:06 -0700

author
tbell
date
Fri, 31 Jul 2009 17:20:06 -0700
changeset 347
dbf8a2816201
parent 335
95c1212b07e3
parent 346
e33efb09ed75
child 348
743f17b55b44

Merge

     1.1 --- a/src/share/classes/com/sun/tools/classfile/AccessFlags.java	Thu Jul 30 23:41:19 2009 -0700
     1.2 +++ b/src/share/classes/com/sun/tools/classfile/AccessFlags.java	Fri Jul 31 17:20:06 2009 -0700
     1.3 @@ -76,6 +76,10 @@
     1.4          return (flags & mask) != 0;
     1.5      }
     1.6  
     1.7 +    public int byteLength() {
     1.8 +        return 2;
     1.9 +    }
    1.10 +
    1.11      private static final int[] classModifiers = {
    1.12          ACC_PUBLIC, ACC_FINAL, ACC_ABSTRACT, ACC_MODULE
    1.13      };
     2.1 --- a/src/share/classes/com/sun/tools/classfile/Attribute.java	Thu Jul 30 23:41:19 2009 -0700
     2.2 +++ b/src/share/classes/com/sun/tools/classfile/Attribute.java	Fri Jul 31 17:20:06 2009 -0700
     2.3 @@ -166,6 +166,10 @@
     2.4  
     2.5      public abstract <R,D> R accept(Attribute.Visitor<R,D> visitor, D data);
     2.6  
     2.7 +    public int byteLength() {
     2.8 +        return 6 + attribute_length;
     2.9 +    }
    2.10 +
    2.11      public final int attribute_name_index;
    2.12      public final int attribute_length;
    2.13  
     3.1 --- a/src/share/classes/com/sun/tools/classfile/Attributes.java	Thu Jul 30 23:41:19 2009 -0700
     3.2 +++ b/src/share/classes/com/sun/tools/classfile/Attributes.java	Fri Jul 31 17:20:06 2009 -0700
     3.3 @@ -95,6 +95,13 @@
     3.4          return attrs.length;
     3.5      }
     3.6  
     3.7 +    public int byteLength() {
     3.8 +        int length = 2;
     3.9 +        for (Attribute a: attrs)
    3.10 +            length += a.byteLength();
    3.11 +        return length;
    3.12 +    }
    3.13 +
    3.14      public final Attribute[] attrs;
    3.15      public final Map<String, Attribute> map;
    3.16  }
     4.1 --- a/src/share/classes/com/sun/tools/classfile/CharacterRangeTable_attribute.java	Thu Jul 30 23:41:19 2009 -0700
     4.2 +++ b/src/share/classes/com/sun/tools/classfile/CharacterRangeTable_attribute.java	Fri Jul 31 17:20:06 2009 -0700
     4.3 @@ -58,7 +58,7 @@
     4.4      }
     4.5  
     4.6      public CharacterRangeTable_attribute(int name_index, Entry[] character_range_table) {
     4.7 -        super(name_index, character_range_table.length * Entry.length());
     4.8 +        super(name_index, 2 + character_range_table.length * Entry.length());
     4.9          this.character_range_table = character_range_table;
    4.10      }
    4.11  
     5.1 --- a/src/share/classes/com/sun/tools/classfile/ClassFile.java	Thu Jul 30 23:41:19 2009 -0700
     5.2 +++ b/src/share/classes/com/sun/tools/classfile/ClassFile.java	Fri Jul 31 17:20:06 2009 -0700
     5.3 @@ -139,6 +139,38 @@
     5.4          return access_flags.is(ACC_INTERFACE);
     5.5      }
     5.6  
     5.7 +    public int byteLength() {
     5.8 +        return  4 +     // magic
     5.9 +                2 +     // minor
    5.10 +                2 +     // major
    5.11 +                constant_pool.byteLength() +
    5.12 +                2 +     // access flags
    5.13 +                2 +     // this_class
    5.14 +                2 +     // super_class
    5.15 +                byteLength(interfaces) +
    5.16 +                byteLength(fields) +
    5.17 +                byteLength(methods) +
    5.18 +                attributes.byteLength();
    5.19 +    }
    5.20 +
    5.21 +    private int byteLength(int[] indices) {
    5.22 +        return 2 + 2 * indices.length;
    5.23 +    }
    5.24 +
    5.25 +    private int byteLength(Field[] fields) {
    5.26 +        int length = 2;
    5.27 +        for (Field f: fields)
    5.28 +            length += f.byteLength();
    5.29 +        return length;
    5.30 +    }
    5.31 +
    5.32 +    private int byteLength(Method[] methods) {
    5.33 +        int length = 2;
    5.34 +        for (Method m: methods)
    5.35 +            length += m.byteLength();
    5.36 +        return length;
    5.37 +    }
    5.38 +
    5.39      public final int magic;
    5.40      public final int minor_version;
    5.41      public final int major_version;
     6.1 --- a/src/share/classes/com/sun/tools/classfile/ConstantPool.java	Thu Jul 30 23:41:19 2009 -0700
     6.2 +++ b/src/share/classes/com/sun/tools/classfile/ConstantPool.java	Fri Jul 31 17:20:06 2009 -0700
     6.3 @@ -25,7 +25,9 @@
     6.4  
     6.5  package com.sun.tools.classfile;
     6.6  
     6.7 +import java.io.DataOutputStream;
     6.8  import java.io.IOException;
     6.9 +import java.io.OutputStream;
    6.10  import java.util.Iterator;
    6.11  
    6.12  /**
    6.13 @@ -179,6 +181,16 @@
    6.14          return pool.length;
    6.15      }
    6.16  
    6.17 +    public int byteLength() {
    6.18 +        int length = 2;
    6.19 +        for (int i = 1; i < size(); ) {
    6.20 +            CPInfo cpInfo = pool[i];
    6.21 +            length += cpInfo.byteLength();
    6.22 +            i += cpInfo.size();
    6.23 +        }
    6.24 +        return length;
    6.25 +    }
    6.26 +
    6.27      public CPInfo get(int index) throws InvalidIndex {
    6.28          if (index <= 0 || index >= pool.length)
    6.29              throw new InvalidIndex(index);
    6.30 @@ -291,6 +303,8 @@
    6.31              return 1;
    6.32          }
    6.33  
    6.34 +        public abstract int byteLength();
    6.35 +
    6.36          public abstract <R,D> R accept(Visitor<R,D> visitor, D data);
    6.37  
    6.38          protected final ConstantPool cp;
    6.39 @@ -315,6 +329,10 @@
    6.40              return tag;
    6.41          }
    6.42  
    6.43 +        public int byteLength() {
    6.44 +            return 5;
    6.45 +        }
    6.46 +
    6.47          public CONSTANT_Class_info getClassInfo() throws ConstantPoolException {
    6.48              return cp.getClassInfo(class_index);
    6.49          }
    6.50 @@ -347,6 +365,10 @@
    6.51              return CONSTANT_Class;
    6.52          }
    6.53  
    6.54 +        public int  byteLength() {
    6.55 +            return 3;
    6.56 +        }
    6.57 +
    6.58          public String getName() throws ConstantPoolException {
    6.59              return cp.getUTF8Value(name_index);
    6.60          }
    6.61 @@ -390,6 +412,10 @@
    6.62              return CONSTANT_Double;
    6.63          }
    6.64  
    6.65 +        public int  byteLength() {
    6.66 +            return 9;
    6.67 +        }
    6.68 +
    6.69          @Override
    6.70          public int size() {
    6.71              return 2;
    6.72 @@ -439,6 +465,10 @@
    6.73              return CONSTANT_Float;
    6.74          }
    6.75  
    6.76 +        public int byteLength() {
    6.77 +            return 5;
    6.78 +        }
    6.79 +
    6.80          @Override
    6.81          public String toString() {
    6.82              return "CONSTANT_Float_info[value: " + value + "]";
    6.83 @@ -464,6 +494,10 @@
    6.84              return CONSTANT_Integer;
    6.85          }
    6.86  
    6.87 +        public int byteLength() {
    6.88 +            return 5;
    6.89 +        }
    6.90 +
    6.91          @Override
    6.92          public String toString() {
    6.93              return "CONSTANT_Integer_info[value: " + value + "]";
    6.94 @@ -513,6 +547,10 @@
    6.95              return 2;
    6.96          }
    6.97  
    6.98 +        public int byteLength() {
    6.99 +            return 9;
   6.100 +        }
   6.101 +
   6.102          @Override
   6.103          public String toString() {
   6.104              return "CONSTANT_Long_info[value: " + value + "]";
   6.105 @@ -561,6 +599,10 @@
   6.106              return CONSTANT_NameAndType;
   6.107          }
   6.108  
   6.109 +        public int byteLength() {
   6.110 +            return 5;
   6.111 +        }
   6.112 +
   6.113          public String getName() throws ConstantPoolException {
   6.114              return cp.getUTF8Value(name_index);
   6.115          }
   6.116 @@ -597,6 +639,10 @@
   6.117              return CONSTANT_String;
   6.118          }
   6.119  
   6.120 +        public int byteLength() {
   6.121 +            return 3;
   6.122 +        }
   6.123 +
   6.124          public String getString() throws ConstantPoolException {
   6.125              return cp.getUTF8Value(string_index);
   6.126          }
   6.127 @@ -626,6 +672,20 @@
   6.128              return CONSTANT_Utf8;
   6.129          }
   6.130  
   6.131 +        public int byteLength() {
   6.132 +            class SizeOutputStream extends OutputStream {
   6.133 +                @Override
   6.134 +                public void write(int b) throws IOException {
   6.135 +                    size++;
   6.136 +                }
   6.137 +                int size;
   6.138 +            }
   6.139 +            SizeOutputStream sizeOut = new SizeOutputStream();
   6.140 +            DataOutputStream out = new DataOutputStream(sizeOut);
   6.141 +            try { out.writeUTF(value); } catch (IOException ignore) { }
   6.142 +            return 1 + sizeOut.size;
   6.143 +        }
   6.144 +
   6.145          @Override
   6.146          public String toString() {
   6.147              if (value.length() < 32 && isPrintableAscii(value))
     7.1 --- a/src/share/classes/com/sun/tools/classfile/ExtendedAnnotation.java	Thu Jul 30 23:41:19 2009 -0700
     7.2 +++ b/src/share/classes/com/sun/tools/classfile/ExtendedAnnotation.java	Fri Jul 31 17:20:06 2009 -0700
     7.3 @@ -260,9 +260,6 @@
     7.4          // For generic/array types.
     7.5          public List<Integer> location = new ArrayList<Integer>();
     7.6  
     7.7 -        // Tree position.
     7.8 -        public int pos = -1;
     7.9 -
    7.10          // For typecasts, type tests, new (and locals, as start_pc).
    7.11          public int offset = -1;
    7.12  
    7.13 @@ -391,9 +388,6 @@
    7.14                  sb.append(")");
    7.15              }
    7.16  
    7.17 -            sb.append(", pos = ");
    7.18 -            sb.append(pos);
    7.19 -
    7.20              sb.append(']');
    7.21              return sb.toString();
    7.22          }
     8.1 --- a/src/share/classes/com/sun/tools/classfile/Field.java	Thu Jul 30 23:41:19 2009 -0700
     8.2 +++ b/src/share/classes/com/sun/tools/classfile/Field.java	Fri Jul 31 17:20:06 2009 -0700
     8.3 @@ -50,6 +50,10 @@
     8.4          this.attributes = attributes;
     8.5      }
     8.6  
     8.7 +    public int byteLength() {
     8.8 +        return 6 + attributes.byteLength();
     8.9 +    }
    8.10 +
    8.11      public String getName(ConstantPool constant_pool) throws ConstantPoolException {
    8.12          return constant_pool.getUTF8Value(name_index);
    8.13      }
     9.1 --- a/src/share/classes/com/sun/tools/classfile/LineNumberTable_attribute.java	Thu Jul 30 23:41:19 2009 -0700
     9.2 +++ b/src/share/classes/com/sun/tools/classfile/LineNumberTable_attribute.java	Fri Jul 31 17:20:06 2009 -0700
     9.3 @@ -50,7 +50,7 @@
     9.4      }
     9.5  
     9.6      public LineNumberTable_attribute(int name_index, Entry[] line_number_table) {
     9.7 -        super(name_index, line_number_table.length * Entry.length());
     9.8 +        super(name_index, 2 + line_number_table.length * Entry.length());
     9.9          this.line_number_table_length = line_number_table.length;
    9.10          this.line_number_table = line_number_table;
    9.11      }
    10.1 --- a/src/share/classes/com/sun/tools/classfile/LocalVariableTable_attribute.java	Thu Jul 30 23:41:19 2009 -0700
    10.2 +++ b/src/share/classes/com/sun/tools/classfile/LocalVariableTable_attribute.java	Fri Jul 31 17:20:06 2009 -0700
    10.3 @@ -50,7 +50,7 @@
    10.4      }
    10.5  
    10.6      public LocalVariableTable_attribute(int name_index, Entry[] local_variable_table) {
    10.7 -        super(name_index, local_variable_table.length * Entry.length());
    10.8 +        super(name_index, 2 + local_variable_table.length * Entry.length());
    10.9          this.local_variable_table_length = local_variable_table.length;
   10.10          this.local_variable_table = local_variable_table;
   10.11      }
    11.1 --- a/src/share/classes/com/sun/tools/classfile/LocalVariableTypeTable_attribute.java	Thu Jul 30 23:41:19 2009 -0700
    11.2 +++ b/src/share/classes/com/sun/tools/classfile/LocalVariableTypeTable_attribute.java	Fri Jul 31 17:20:06 2009 -0700
    11.3 @@ -50,7 +50,7 @@
    11.4      }
    11.5  
    11.6      public LocalVariableTypeTable_attribute(int name_index, Entry[] local_variable_table) {
    11.7 -        super(name_index, local_variable_table.length * Entry.length());
    11.8 +        super(name_index, 2 + local_variable_table.length * Entry.length());
    11.9          this.local_variable_table_length = local_variable_table.length;
   11.10          this.local_variable_table = local_variable_table;
   11.11      }
    12.1 --- a/src/share/classes/com/sun/tools/classfile/Method.java	Thu Jul 30 23:41:19 2009 -0700
    12.2 +++ b/src/share/classes/com/sun/tools/classfile/Method.java	Fri Jul 31 17:20:06 2009 -0700
    12.3 @@ -50,6 +50,10 @@
    12.4          this.attributes = attributes;
    12.5      }
    12.6  
    12.7 +    public int byteLength() {
    12.8 +        return 6 + attributes.byteLength();
    12.9 +    }
   12.10 +
   12.11      public String getName(ConstantPool constant_pool) throws ConstantPoolException {
   12.12          return constant_pool.getUTF8Value(name_index);
   12.13      }
    13.1 --- a/src/share/classes/com/sun/tools/classfile/ModuleExportTable_attribute.java	Thu Jul 30 23:41:19 2009 -0700
    13.2 +++ b/src/share/classes/com/sun/tools/classfile/ModuleExportTable_attribute.java	Fri Jul 31 17:20:06 2009 -0700
    13.3 @@ -50,7 +50,7 @@
    13.4      }
    13.5  
    13.6      public ModuleExportTable_attribute(int name_index, int[] export_type_table) {
    13.7 -        super(name_index, 2 * export_type_table.length);
    13.8 +        super(name_index, 2 + 2 * export_type_table.length);
    13.9          this.export_type_table = export_type_table;
   13.10      }
   13.11  
    14.1 --- a/src/share/classes/com/sun/tools/classfile/ModuleMemberTable_attribute.java	Thu Jul 30 23:41:19 2009 -0700
    14.2 +++ b/src/share/classes/com/sun/tools/classfile/ModuleMemberTable_attribute.java	Fri Jul 31 17:20:06 2009 -0700
    14.3 @@ -49,7 +49,7 @@
    14.4      }
    14.5  
    14.6      public ModuleMemberTable_attribute(int name_index, int[] package_member_table) {
    14.7 -        super(name_index, 2 * package_member_table.length);
    14.8 +        super(name_index, 2 + 2 * package_member_table.length);
    14.9          this.package_member_table = package_member_table;
   14.10      }
   14.11  
    15.1 --- a/src/share/classes/com/sun/tools/javac/code/Symbol.java	Thu Jul 30 23:41:19 2009 -0700
    15.2 +++ b/src/share/classes/com/sun/tools/javac/code/Symbol.java	Fri Jul 31 17:20:06 2009 -0700
    15.3 @@ -1197,21 +1197,9 @@
    15.4           *  as possible implementations.
    15.5           */
    15.6          public MethodSymbol implementation(TypeSymbol origin, Types types, boolean checkResult) {
    15.7 -            for (Type t = origin.type; t.tag == CLASS || t.tag == TYPEVAR; t = types.supertype(t)) {
    15.8 -                while (t.tag == TYPEVAR)
    15.9 -                    t = t.getUpperBound();
   15.10 -                TypeSymbol c = t.tsym;
   15.11 -                for (Scope.Entry e = c.members().lookup(name);
   15.12 -                     e.scope != null;
   15.13 -                     e = e.next()) {
   15.14 -                    if (e.sym.kind == MTH) {
   15.15 -                        MethodSymbol m = (MethodSymbol) e.sym;
   15.16 -                        if (m.overrides(this, origin, types, checkResult) &&
   15.17 -                            (m.flags() & SYNTHETIC) == 0)
   15.18 -                            return m;
   15.19 -                    }
   15.20 -                }
   15.21 -            }
   15.22 +            MethodSymbol res = types.implementation(this, origin, types, checkResult);
   15.23 +            if (res != null)
   15.24 +                return res;
   15.25              // if origin is derived from a raw type, we might have missed
   15.26              // an implementation because we do not know enough about instantiations.
   15.27              // in this case continue with the supertype as origin.
    16.1 --- a/src/share/classes/com/sun/tools/javac/code/Types.java	Thu Jul 30 23:41:19 2009 -0700
    16.2 +++ b/src/share/classes/com/sun/tools/javac/code/Types.java	Fri Jul 31 17:20:06 2009 -0700
    16.3 @@ -25,10 +25,9 @@
    16.4  
    16.5  package com.sun.tools.javac.code;
    16.6  
    16.7 +import java.lang.ref.SoftReference;
    16.8  import java.util.*;
    16.9  
   16.10 -import com.sun.tools.javac.api.Messages;
   16.11 -
   16.12  import com.sun.tools.javac.util.*;
   16.13  import com.sun.tools.javac.util.List;
   16.14  
   16.15 @@ -1442,7 +1441,7 @@
   16.16          return (sym.flags() & STATIC) != 0
   16.17              ? sym.type
   16.18              : memberType.visit(t, sym);
   16.19 -    }
   16.20 +        }
   16.21      // where
   16.22          private SimpleVisitor<Type,Symbol> memberType = new SimpleVisitor<Type,Symbol>() {
   16.23  
   16.24 @@ -1552,7 +1551,7 @@
   16.25              return t; /* fast special case */
   16.26          else
   16.27              return erasure.visit(t, recurse);
   16.28 -    }
   16.29 +        }
   16.30      // where
   16.31          private SimpleVisitor<Type, Boolean> erasure = new SimpleVisitor<Type, Boolean>() {
   16.32              public Type visitType(Type t, Boolean recurse) {
   16.33 @@ -1946,6 +1945,45 @@
   16.34              hasSameArgs(t, erasure(s)) || hasSameArgs(erasure(t), s);
   16.35      }
   16.36  
   16.37 +    private WeakHashMap<MethodSymbol, SoftReference<Map<TypeSymbol, MethodSymbol>>> implCache_check =
   16.38 +            new WeakHashMap<MethodSymbol, SoftReference<Map<TypeSymbol, MethodSymbol>>>();
   16.39 +
   16.40 +    private WeakHashMap<MethodSymbol, SoftReference<Map<TypeSymbol, MethodSymbol>>> implCache_nocheck =
   16.41 +            new WeakHashMap<MethodSymbol, SoftReference<Map<TypeSymbol, MethodSymbol>>>();
   16.42 +
   16.43 +    public MethodSymbol implementation(MethodSymbol ms, TypeSymbol origin, Types types, boolean checkResult) {
   16.44 +        Map<MethodSymbol, SoftReference<Map<TypeSymbol, MethodSymbol>>> implCache = checkResult ?
   16.45 +            implCache_check : implCache_nocheck;
   16.46 +        SoftReference<Map<TypeSymbol, MethodSymbol>> ref_cache = implCache.get(ms);
   16.47 +        Map<TypeSymbol, MethodSymbol> cache = ref_cache != null ? ref_cache.get() : null;
   16.48 +        if (cache == null) {
   16.49 +            cache = new HashMap<TypeSymbol, MethodSymbol>();
   16.50 +            implCache.put(ms, new SoftReference<Map<TypeSymbol, MethodSymbol>>(cache));
   16.51 +        }
   16.52 +        MethodSymbol impl = cache.get(origin);
   16.53 +        if (impl == null) {
   16.54 +            for (Type t = origin.type; t.tag == CLASS || t.tag == TYPEVAR; t = types.supertype(t)) {
   16.55 +                while (t.tag == TYPEVAR)
   16.56 +                    t = t.getUpperBound();
   16.57 +                TypeSymbol c = t.tsym;
   16.58 +                for (Scope.Entry e = c.members().lookup(ms.name);
   16.59 +                     e.scope != null;
   16.60 +                     e = e.next()) {
   16.61 +                    if (e.sym.kind == Kinds.MTH) {
   16.62 +                        MethodSymbol m = (MethodSymbol) e.sym;
   16.63 +                        if (m.overrides(ms, origin, types, checkResult) &&
   16.64 +                            (m.flags() & SYNTHETIC) == 0) {
   16.65 +                            impl = m;
   16.66 +                            cache.put(origin, m);
   16.67 +                            return impl;
   16.68 +                        }
   16.69 +                    }
   16.70 +                }
   16.71 +            }
   16.72 +        }
   16.73 +        return impl;
   16.74 +    }
   16.75 +
   16.76      /**
   16.77       * Does t have the same arguments as s?  It is assumed that both
   16.78       * types are (possibly polymorphic) method types.  Monomorphic
    17.1 --- a/src/share/classes/com/sun/tools/javac/comp/MemberEnter.java	Thu Jul 30 23:41:19 2009 -0700
    17.2 +++ b/src/share/classes/com/sun/tools/javac/comp/MemberEnter.java	Fri Jul 31 17:20:06 2009 -0700
    17.3 @@ -1040,15 +1040,6 @@
    17.4                      JavaFileObject prev = log.useSource(env.toplevel.sourcefile);
    17.5                      try {
    17.6                          enterTypeAnnotations(annotations);
    17.7 -
    17.8 -                        // enrich type parameter symbols... easier for annotation processors
    17.9 -                        if (tree instanceof JCTypeParameter) {
   17.10 -                            JCTypeParameter typeparam = (JCTypeParameter)tree;
   17.11 -                            ListBuffer<Attribute.Compound> buf = ListBuffer.lb();
   17.12 -                            for (JCTypeAnnotation anno : annotations)
   17.13 -                                buf.add(anno.attribute_field);
   17.14 -                            typeparam.type.tsym.attributes_field = buf.toList();
   17.15 -                        }
   17.16                      } finally {
   17.17                          log.useSource(prev);
   17.18                      }
    18.1 --- a/src/share/classes/com/sun/tools/javac/comp/TransTypes.java	Thu Jul 30 23:41:19 2009 -0700
    18.2 +++ b/src/share/classes/com/sun/tools/javac/comp/TransTypes.java	Fri Jul 31 17:20:06 2009 -0700
    18.3 @@ -817,6 +817,23 @@
    18.4              pop();
    18.5          }
    18.6  
    18.7 +        private boolean inClass = false;
    18.8 +
    18.9 +        @Override
   18.10 +        public void visitClassDef(JCClassDecl tree) {
   18.11 +           if (!inClass) {
   18.12 +               // Do not recurse into nested and inner classes since
   18.13 +               // TransTypes.visitClassDef makes an invocation for each class
   18.14 +               // separately.
   18.15 +               inClass = true;
   18.16 +               try {
   18.17 +                   super.visitClassDef(tree);
   18.18 +               } finally {
   18.19 +                   inClass = false;
   18.20 +               }
   18.21 +           }
   18.22 +        }
   18.23 +
   18.24          private TypeAnnotationPosition resolveFrame(JCTree tree, JCTree frame,
   18.25                  List<JCTree> path, TypeAnnotationPosition p) {
   18.26              switch (frame.getKind()) {
    19.1 --- a/src/share/classes/com/sun/tools/javac/resources/compiler.properties	Thu Jul 30 23:41:19 2009 -0700
    19.2 +++ b/src/share/classes/com/sun/tools/javac/resources/compiler.properties	Fri Jul 31 17:20:06 2009 -0700
    19.3 @@ -1003,7 +1003,7 @@
    19.4      inferred: {0}\n\
    19.5      bound(s): {1}
    19.6  compiler.misc.inferred.do.not.conform.to.params=\
    19.7 -    actual arguments do not conforms to inferred formal arguments\n\
    19.8 +    actual arguments do not conform to inferred formal arguments\n\
    19.9      required: {0}\n\
   19.10      found: {1}
   19.11  
    20.1 --- a/src/share/classes/com/sun/tools/javac/util/RichDiagnosticFormatter.java	Thu Jul 30 23:41:19 2009 -0700
    20.2 +++ b/src/share/classes/com/sun/tools/javac/util/RichDiagnosticFormatter.java	Fri Jul 31 17:20:06 2009 -0700
    20.3 @@ -208,6 +208,32 @@
    20.4          }
    20.5          return clauses.reverse();
    20.6      }
    20.7 +
    20.8 +    private int indexOf(Type type, WhereClauseKind kind) {
    20.9 +        int index = 1;
   20.10 +        for (Type t : whereClauses.get(kind).keySet()) {
   20.11 +            if (t.tsym == type.tsym) {
   20.12 +                return index;
   20.13 +            }
   20.14 +            if (kind != WhereClauseKind.TYPEVAR ||
   20.15 +                    t.toString().equals(type.toString())) {
   20.16 +                index++;
   20.17 +            }
   20.18 +        }
   20.19 +        return -1;
   20.20 +    }
   20.21 +
   20.22 +    private boolean unique(TypeVar typevar) {
   20.23 +        int found = 0;
   20.24 +        for (Type t : whereClauses.get(WhereClauseKind.TYPEVAR).keySet()) {
   20.25 +            if (t.toString().equals(typevar.toString())) {
   20.26 +                found++;
   20.27 +            }
   20.28 +        }
   20.29 +        if (found < 1)
   20.30 +            throw new AssertionError("Missing type variable in where clause " + typevar);
   20.31 +        return found == 1;
   20.32 +    }
   20.33      //where
   20.34      /**
   20.35       * This enum defines all posssible kinds of where clauses that can be
   20.36 @@ -366,33 +392,6 @@
   20.37              }
   20.38          }
   20.39  
   20.40 -        private int indexOf(Type type, WhereClauseKind kind) {
   20.41 -            int index = 0;
   20.42 -            boolean found = false;
   20.43 -            for (Type t : whereClauses.get(kind).keySet()) {
   20.44 -                if (t == type) {
   20.45 -                    found = true;
   20.46 -                    break;
   20.47 -                }
   20.48 -                index++;
   20.49 -            }
   20.50 -            if (!found)
   20.51 -                throw new AssertionError("Missing symbol in where clause " + type);
   20.52 -            return index + 1;
   20.53 -        }
   20.54 -
   20.55 -        private boolean unique(TypeVar typevar) {
   20.56 -            int found = 0;
   20.57 -            for (Type t : whereClauses.get(WhereClauseKind.TYPEVAR).keySet()) {
   20.58 -                if (t.toString().equals(typevar.toString())) {
   20.59 -                    found++;
   20.60 -                }
   20.61 -            }
   20.62 -            if (found < 1)
   20.63 -                throw new AssertionError("Missing type variable in where clause " + typevar);
   20.64 -            return found == 1;
   20.65 -        }
   20.66 -
   20.67          @Override
   20.68          protected String printMethodArgs(List<Type> args, boolean varArgs, Locale locale) {
   20.69              return super.printMethodArgs(args, varArgs, locale);
   20.70 @@ -492,7 +491,7 @@
   20.71  
   20.72          @Override
   20.73          public Void visitCapturedType(CapturedType t, Void ignored) {
   20.74 -            if (!whereClauses.get(WhereClauseKind.CAPTURED).containsKey(t)) {
   20.75 +            if (indexOf(t, WhereClauseKind.CAPTURED) == -1) {
   20.76                  String suffix = t.lower == syms.botType ? ".1" : "";
   20.77                  JCDiagnostic d = diags.fragment("where.captured"+ suffix, t, t.bound, t.lower, t.wildcard);
   20.78                  whereClauses.get(WhereClauseKind.CAPTURED).put(t, d);
   20.79 @@ -506,7 +505,7 @@
   20.80          @Override
   20.81          public Void visitClassType(ClassType t, Void ignored) {
   20.82              if (t.isCompound()) {
   20.83 -                if (!whereClauses.get(WhereClauseKind.INTERSECTION).containsKey(t)) {
   20.84 +                if (indexOf(t, WhereClauseKind.INTERSECTION) == -1) {
   20.85                      Type supertype = types.supertype(t);
   20.86                      List<Type> interfaces = types.interfaces(t);
   20.87                      JCDiagnostic d = diags.fragment("where.intersection", t, interfaces.prepend(supertype));
   20.88 @@ -524,11 +523,17 @@
   20.89  
   20.90          @Override
   20.91          public Void visitTypeVar(TypeVar t, Void ignored) {
   20.92 -            if (!whereClauses.get(WhereClauseKind.TYPEVAR).containsKey(t)) {
   20.93 +            if (indexOf(t, WhereClauseKind.TYPEVAR) == -1) {
   20.94 +                //access the bound type and skip error types
   20.95                  Type bound = t.bound;
   20.96                  while ((bound instanceof ErrorType))
   20.97                      bound = ((ErrorType)bound).getOriginalType();
   20.98 -                List<Type> bounds  = types.getBounds(t);
   20.99 +                //retrieve the bound list - if the type variable
  20.100 +                //has not been attributed the bound is not set
  20.101 +                List<Type> bounds = bound != null ?
  20.102 +                    types.getBounds(t) :
  20.103 +                    List.<Type>nil();
  20.104 +
  20.105                  nameSimplifier.addUsage(t.tsym);
  20.106  
  20.107                  boolean boundErroneous = bounds.head == null ||
    21.1 --- a/src/share/classes/com/sun/tools/javap/AnnotationWriter.java	Thu Jul 30 23:41:19 2009 -0700
    21.2 +++ b/src/share/classes/com/sun/tools/javap/AnnotationWriter.java	Fri Jul 31 17:20:06 2009 -0700
    21.3 @@ -32,6 +32,10 @@
    21.4  import com.sun.tools.classfile.Annotation.Class_element_value;
    21.5  import com.sun.tools.classfile.Annotation.Enum_element_value;
    21.6  import com.sun.tools.classfile.Annotation.Primitive_element_value;
    21.7 +import com.sun.tools.classfile.ConstantPool;
    21.8 +import com.sun.tools.classfile.ConstantPoolException;
    21.9 +import com.sun.tools.classfile.Descriptor;
   21.10 +import com.sun.tools.classfile.Descriptor.InvalidDescriptor;
   21.11  
   21.12  /**
   21.13   *  A writer for writing annotations as text.
   21.14 @@ -51,71 +55,243 @@
   21.15  
   21.16      protected AnnotationWriter(Context context) {
   21.17          super(context);
   21.18 +        classWriter = ClassWriter.instance(context);
   21.19 +        constantWriter = ConstantWriter.instance(context);
   21.20      }
   21.21  
   21.22      public void write(Annotation annot) {
   21.23 -        print("#" + annot.type_index + "(");
   21.24 +        write(annot, false);
   21.25 +    }
   21.26 +
   21.27 +    public void write(Annotation annot, boolean resolveIndices) {
   21.28 +        writeDescriptor(annot.type_index, resolveIndices);
   21.29 +        boolean showParens = annot.num_element_value_pairs > 0 || !resolveIndices;
   21.30 +        if (showParens)
   21.31 +            print("(");
   21.32          for (int i = 0; i < annot.num_element_value_pairs; i++) {
   21.33              if (i > 0)
   21.34                  print(",");
   21.35 -            write(annot.element_value_pairs[i]);
   21.36 +            write(annot.element_value_pairs[i], resolveIndices);
   21.37          }
   21.38 -        print(")");
   21.39 +        if (showParens)
   21.40 +            print(")");
   21.41      }
   21.42  
   21.43      public void write(ExtendedAnnotation annot) {
   21.44 -        write(annot.annotation);
   21.45 -        print('@');
   21.46 -        print(annot.position.toString());
   21.47 +        write(annot, true, false);
   21.48 +    }
   21.49 +
   21.50 +    public void write(ExtendedAnnotation annot, boolean showOffsets, boolean resolveIndices) {
   21.51 +        write(annot.annotation, resolveIndices);
   21.52 +        print(": ");
   21.53 +        write(annot.position, showOffsets);
   21.54 +    }
   21.55 +
   21.56 +    public void write(ExtendedAnnotation.Position pos, boolean showOffsets) {
   21.57 +        print(pos.type);
   21.58 +
   21.59 +        switch (pos.type) {
   21.60 +        // type case
   21.61 +        case TYPECAST:
   21.62 +        case TYPECAST_GENERIC_OR_ARRAY:
   21.63 +        // object creation
   21.64 +        case INSTANCEOF:
   21.65 +        case INSTANCEOF_GENERIC_OR_ARRAY:
   21.66 +        // new expression
   21.67 +        case NEW:
   21.68 +        case NEW_GENERIC_OR_ARRAY:
   21.69 +        case NEW_TYPE_ARGUMENT:
   21.70 +        case NEW_TYPE_ARGUMENT_GENERIC_OR_ARRAY:
   21.71 +            if (showOffsets) {
   21.72 +                print(", offset=");
   21.73 +                print(pos.offset);
   21.74 +            }
   21.75 +            break;
   21.76 +         // local variable
   21.77 +        case LOCAL_VARIABLE:
   21.78 +        case LOCAL_VARIABLE_GENERIC_OR_ARRAY:
   21.79 +            print(", {");
   21.80 +            for (int i = 0; i < pos.lvarOffset.length; ++i) {
   21.81 +                if (i != 0) print("; ");
   21.82 +                if (showOffsets) {
   21.83 +                    print(", start_pc=");
   21.84 +                    print(pos.lvarOffset[i]);
   21.85 +                }
   21.86 +                print(", length=");
   21.87 +                print(pos.lvarLength[i]);
   21.88 +                print(", index=");
   21.89 +                print(pos.lvarIndex[i]);
   21.90 +            }
   21.91 +            print("}");
   21.92 +            break;
   21.93 +         // method receiver
   21.94 +        case METHOD_RECEIVER:
   21.95 +            // Do nothing
   21.96 +            break;
   21.97 +        // type parameters
   21.98 +        case CLASS_TYPE_PARAMETER:
   21.99 +        case METHOD_TYPE_PARAMETER:
  21.100 +            print(", param_index=");
  21.101 +            print(pos.parameter_index);
  21.102 +            break;
  21.103 +        // type parameters bound
  21.104 +        case CLASS_TYPE_PARAMETER_BOUND:
  21.105 +        case CLASS_TYPE_PARAMETER_BOUND_GENERIC_OR_ARRAY:
  21.106 +        case METHOD_TYPE_PARAMETER_BOUND:
  21.107 +        case METHOD_TYPE_PARAMETER_BOUND_GENERIC_OR_ARRAY:
  21.108 +            print(", param_index=");
  21.109 +            print(pos.parameter_index);
  21.110 +            print(", bound_index=");
  21.111 +            print(pos.bound_index);
  21.112 +            break;
  21.113 +         // wildcard
  21.114 +        case WILDCARD_BOUND:
  21.115 +        case WILDCARD_BOUND_GENERIC_OR_ARRAY:
  21.116 +            print(", wild_card=");
  21.117 +            print(pos.wildcard_position);
  21.118 +            break;
  21.119 +         // Class extends and implements clauses
  21.120 +        case CLASS_EXTENDS:
  21.121 +        case CLASS_EXTENDS_GENERIC_OR_ARRAY:
  21.122 +            print(", type_index=");
  21.123 +            print(pos.type_index);
  21.124 +            break;
  21.125 +        // throws
  21.126 +        case THROWS:
  21.127 +            print(", type_index=");
  21.128 +            print(pos.type_index);
  21.129 +            break;
  21.130 +        case CLASS_LITERAL:
  21.131 +            if (showOffsets) {
  21.132 +                print(", offset=");
  21.133 +                print(pos.offset);
  21.134 +            }
  21.135 +            break;
  21.136 +        // method parameter: not specified
  21.137 +        case METHOD_PARAMETER_GENERIC_OR_ARRAY:
  21.138 +            print(", param_index=");
  21.139 +            print(pos.parameter_index);
  21.140 +            break;
  21.141 +        // method type argument: wasn't specified
  21.142 +        case METHOD_TYPE_ARGUMENT:
  21.143 +        case METHOD_TYPE_ARGUMENT_GENERIC_OR_ARRAY:
  21.144 +            if (showOffsets) {
  21.145 +                print(", offset=");
  21.146 +                print(pos.offset);
  21.147 +            }
  21.148 +            print(", type_index=");
  21.149 +            print(pos.type_index);
  21.150 +            break;
  21.151 +        // We don't need to worry abut these
  21.152 +        case METHOD_RETURN_GENERIC_OR_ARRAY:
  21.153 +        case FIELD_GENERIC_OR_ARRAY:
  21.154 +            break;
  21.155 +        case UNKNOWN:
  21.156 +            break;
  21.157 +        default:
  21.158 +            throw new AssertionError("unknown type: " + pos.type);
  21.159 +        }
  21.160 +
  21.161 +        // Append location data for generics/arrays.
  21.162 +        if (pos.type.hasLocation()) {
  21.163 +            print(", location=");
  21.164 +            print(pos.location);
  21.165 +        }
  21.166      }
  21.167  
  21.168      public void write(Annotation.element_value_pair pair) {
  21.169 -        print("#" + pair.element_name_index + ":");
  21.170 -        write(pair.value);
  21.171 +        write(pair, false);
  21.172 +    }
  21.173 +
  21.174 +    public void write(Annotation.element_value_pair pair, boolean resolveIndices) {
  21.175 +        writeIndex(pair.element_name_index, resolveIndices);
  21.176 +        print("=");
  21.177 +        write(pair.value, resolveIndices);
  21.178      }
  21.179  
  21.180      public void write(Annotation.element_value value) {
  21.181 -        ev_writer.write(value);
  21.182 +        write(value, false);
  21.183 +    }
  21.184 +
  21.185 +    public void write(Annotation.element_value value, boolean resolveIndices) {
  21.186 +        ev_writer.write(value, resolveIndices);
  21.187 +    }
  21.188 +
  21.189 +    private void writeDescriptor(int index, boolean resolveIndices) {
  21.190 +        if (resolveIndices) {
  21.191 +            try {
  21.192 +                ConstantPool constant_pool = classWriter.getClassFile().constant_pool;
  21.193 +                Descriptor d = new Descriptor(index);
  21.194 +                print(d.getFieldType(constant_pool));
  21.195 +                return;
  21.196 +            } catch (ConstantPoolException ignore) {
  21.197 +            } catch (InvalidDescriptor ignore) {
  21.198 +            }
  21.199 +        }
  21.200 +
  21.201 +        print("#" + index);
  21.202 +    }
  21.203 +
  21.204 +    private void writeIndex(int index, boolean resolveIndices) {
  21.205 +        if (resolveIndices) {
  21.206 +            print(constantWriter.stringValue(index));
  21.207 +        } else
  21.208 +            print("#" + index);
  21.209      }
  21.210  
  21.211      element_value_Writer ev_writer = new element_value_Writer();
  21.212  
  21.213 -    class element_value_Writer implements Annotation.element_value.Visitor<Void,Void> {
  21.214 -        public void write(Annotation.element_value value) {
  21.215 -            value.accept(this, null);
  21.216 +    class element_value_Writer implements Annotation.element_value.Visitor<Void,Boolean> {
  21.217 +        public void write(Annotation.element_value value, boolean resolveIndices) {
  21.218 +            value.accept(this, resolveIndices);
  21.219          }
  21.220  
  21.221 -        public Void visitPrimitive(Primitive_element_value ev, Void p) {
  21.222 -            print(((char) ev.tag) + "#" + ev.const_value_index);
  21.223 +        public Void visitPrimitive(Primitive_element_value ev, Boolean resolveIndices) {
  21.224 +            if (resolveIndices)
  21.225 +                writeIndex(ev.const_value_index, resolveIndices);
  21.226 +            else
  21.227 +                print(((char) ev.tag) + "#" + ev.const_value_index);
  21.228              return null;
  21.229          }
  21.230  
  21.231 -        public Void visitEnum(Enum_element_value ev, Void p) {
  21.232 -            print(((char) ev.tag) + "#" + ev.type_name_index + ".#" + ev.const_name_index);
  21.233 +        public Void visitEnum(Enum_element_value ev, Boolean resolveIndices) {
  21.234 +            if (resolveIndices) {
  21.235 +                writeIndex(ev.type_name_index, resolveIndices);
  21.236 +                print(".");
  21.237 +                writeIndex(ev.const_name_index, resolveIndices);
  21.238 +            } else
  21.239 +                print(((char) ev.tag) + "#" + ev.type_name_index + ".#" + ev.const_name_index);
  21.240              return null;
  21.241          }
  21.242  
  21.243 -        public Void visitClass(Class_element_value ev, Void p) {
  21.244 -            print(((char) ev.tag) + "#" + ev.class_info_index);
  21.245 +        public Void visitClass(Class_element_value ev, Boolean resolveIndices) {
  21.246 +            if (resolveIndices) {
  21.247 +                writeIndex(ev.class_info_index, resolveIndices);
  21.248 +                print(".class");
  21.249 +            } else
  21.250 +                print(((char) ev.tag) + "#" + ev.class_info_index);
  21.251              return null;
  21.252          }
  21.253  
  21.254 -        public Void visitAnnotation(Annotation_element_value ev, Void p) {
  21.255 +        public Void visitAnnotation(Annotation_element_value ev, Boolean resolveIndices) {
  21.256              print((char) ev.tag);
  21.257 -            AnnotationWriter.this.write(ev.annotation_value);
  21.258 +            AnnotationWriter.this.write(ev.annotation_value, resolveIndices);
  21.259              return null;
  21.260          }
  21.261  
  21.262 -        public Void visitArray(Array_element_value ev, Void p) {
  21.263 +        public Void visitArray(Array_element_value ev, Boolean resolveIndices) {
  21.264              print("[");
  21.265              for (int i = 0; i < ev.num_values; i++) {
  21.266                  if (i > 0)
  21.267                      print(",");
  21.268 -                write(ev.values[i]);
  21.269 +                write(ev.values[i], resolveIndices);
  21.270              }
  21.271              print("]");
  21.272              return null;
  21.273          }
  21.274  
  21.275      }
  21.276 +
  21.277 +    private ClassWriter classWriter;
  21.278 +    private ConstantWriter constantWriter;
  21.279  }
    22.1 --- a/src/share/classes/com/sun/tools/javap/CodeWriter.java	Thu Jul 30 23:41:19 2009 -0700
    22.2 +++ b/src/share/classes/com/sun/tools/javap/CodeWriter.java	Fri Jul 31 17:20:06 2009 -0700
    22.3 @@ -64,6 +64,7 @@
    22.4          stackMapWriter = StackMapWriter.instance(context);
    22.5          localVariableTableWriter = LocalVariableTableWriter.instance(context);
    22.6          localVariableTypeTableWriter = LocalVariableTypeTableWriter.instance(context);
    22.7 +        typeAnnotationWriter = TypeAnnotationWriter.instance(context);
    22.8          options = Options.instance(context);
    22.9      }
   22.10  
   22.11 @@ -253,6 +254,11 @@
   22.12              detailWriters.add(tryBlockWriter);
   22.13          }
   22.14  
   22.15 +        if (options.details.contains(InstructionDetailWriter.Kind.TYPE_ANNOS)) {
   22.16 +            typeAnnotationWriter.reset(attr);
   22.17 +            detailWriters.add(typeAnnotationWriter);
   22.18 +        }
   22.19 +
   22.20          return detailWriters;
   22.21      }
   22.22  
   22.23 @@ -261,6 +267,7 @@
   22.24      private ConstantWriter constantWriter;
   22.25      private LocalVariableTableWriter localVariableTableWriter;
   22.26      private LocalVariableTypeTableWriter localVariableTypeTableWriter;
   22.27 +    private TypeAnnotationWriter typeAnnotationWriter;
   22.28      private SourceWriter sourceWriter;
   22.29      private StackMapWriter stackMapWriter;
   22.30      private TryBlockWriter tryBlockWriter;
    23.1 --- a/src/share/classes/com/sun/tools/javap/InstructionDetailWriter.java	Thu Jul 30 23:41:19 2009 -0700
    23.2 +++ b/src/share/classes/com/sun/tools/javap/InstructionDetailWriter.java	Fri Jul 31 17:20:06 2009 -0700
    23.3 @@ -42,7 +42,8 @@
    23.4          LOCAL_VAR_TYPES("localVariableTypes"),
    23.5          SOURCE("source"),
    23.6          STACKMAPS("stackMaps"),
    23.7 -        TRY_BLOCKS("tryBlocks");
    23.8 +        TRY_BLOCKS("tryBlocks"),
    23.9 +        TYPE_ANNOS("typeAnnotations");
   23.10          Kind(String option) {
   23.11              this.option = option;
   23.12          }
    24.1 --- a/src/share/classes/com/sun/tools/javap/JavapFileManager.java	Thu Jul 30 23:41:19 2009 -0700
    24.2 +++ b/src/share/classes/com/sun/tools/javap/JavapFileManager.java	Fri Jul 31 17:20:06 2009 -0700
    24.3 @@ -41,13 +41,13 @@
    24.4   *  This code and its internal interfaces are subject to change or
    24.5   *  deletion without notice.</b>
    24.6   */
    24.7 -class JavapFileManager extends JavacFileManager {
    24.8 +public class JavapFileManager extends JavacFileManager {
    24.9      private JavapFileManager(Context context, Charset charset) {
   24.10          super(context, true, charset);
   24.11          setIgnoreSymbolFile(true);
   24.12      }
   24.13  
   24.14 -    static JavapFileManager create(final DiagnosticListener<? super JavaFileObject> dl, PrintWriter log, Options options) {
   24.15 +    public static JavapFileManager create(final DiagnosticListener<? super JavaFileObject> dl, PrintWriter log) {
   24.16          Context javac_context = new Context();
   24.17  
   24.18          if (dl != null)
    25.1 --- a/src/share/classes/com/sun/tools/javap/JavapTask.java	Thu Jul 30 23:41:19 2009 -0700
    25.2 +++ b/src/share/classes/com/sun/tools/javap/JavapTask.java	Fri Jul 31 17:20:06 2009 -0700
    25.3 @@ -289,6 +289,12 @@
    25.4              void process(JavapTask task, String opt, String arg) {
    25.5                  task.options.showConstants = true;
    25.6              }
    25.7 +        },
    25.8 +
    25.9 +        new Option(false, "-XDinner") {
   25.10 +            void process(JavapTask task, String opt, String arg) {
   25.11 +                task.options.showInnerClasses = true;
   25.12 +            }
   25.13          }
   25.14  
   25.15      };
   25.16 @@ -316,17 +322,17 @@
   25.17              Iterable<String> classes) {
   25.18          this(out, fileManager, diagnosticListener);
   25.19  
   25.20 +        this.classes = new ArrayList<String>();
   25.21 +        for (String classname: classes) {
   25.22 +            classname.getClass(); // null-check
   25.23 +            this.classes.add(classname);
   25.24 +        }
   25.25 +
   25.26          try {
   25.27              handleOptions(options, false);
   25.28          } catch (BadArgs e) {
   25.29              throw new IllegalArgumentException(e.getMessage());
   25.30          }
   25.31 -
   25.32 -        this.classes = new ArrayList<String>();
   25.33 -        for (String classname: classes) {
   25.34 -            classname.getClass(); // null-check
   25.35 -            this.classes.add(classname);
   25.36 -        }
   25.37      }
   25.38  
   25.39      public void setLocale(Locale locale) {
   25.40 @@ -372,10 +378,18 @@
   25.41          final PrintWriter pw = getPrintWriterForWriter(w);
   25.42          return new DiagnosticListener<JavaFileObject> () {
   25.43              public void report(Diagnostic<? extends JavaFileObject> diagnostic) {
   25.44 -                if (diagnostic.getKind() == Diagnostic.Kind.ERROR) {
   25.45 +                switch (diagnostic.getKind()) {
   25.46 +                    case ERROR:
   25.47                          pw.print(getMessage("err.prefix"));
   25.48 -                    pw.print(" ");
   25.49 +                        break;
   25.50 +                    case WARNING:
   25.51 +                        pw.print(getMessage("warn.prefix"));
   25.52 +                        break;
   25.53 +                    case NOTE:
   25.54 +                        pw.print(getMessage("note.prefix"));
   25.55 +                        break;
   25.56                  }
   25.57 +                pw.print(" ");
   25.58                  pw.println(diagnostic.getMessage(null));
   25.59              }
   25.60          };
   25.61 @@ -405,7 +419,7 @@
   25.62              boolean ok = run();
   25.63              return ok ? EXIT_OK : EXIT_ERROR;
   25.64          } catch (BadArgs e) {
   25.65 -            diagnosticListener.report(createDiagnostic(e.key, e.args));
   25.66 +            reportError(e.key, e.args);
   25.67              if (e.showUsage) {
   25.68                  log.println(getMessage("main.usage.summary", progname));
   25.69              }
   25.70 @@ -419,7 +433,7 @@
   25.71                  e_args[0] = e.getCause();
   25.72                  System.arraycopy(e.args, 0, e_args, 1, e.args.length);
   25.73              }
   25.74 -            diagnosticListener.report(createDiagnostic("err.internal.error", e_args));
   25.75 +            reportError("err.internal.error", e_args);
   25.76              return EXIT_ABNORMAL;
   25.77          } finally {
   25.78              log.flush();
   25.79 @@ -521,64 +535,37 @@
   25.80          SourceWriter sourceWriter = SourceWriter.instance(context);
   25.81          sourceWriter.setFileManager(fileManager);
   25.82  
   25.83 +        attributeFactory.setCompat(options.compat);
   25.84 +        attributeFactory.setJSR277(options.jsr277);
   25.85 +
   25.86          boolean ok = true;
   25.87  
   25.88          for (String className: classes) {
   25.89              JavaFileObject fo;
   25.90              try {
   25.91 -                if (className.endsWith(".class")) {
   25.92 -                    if (fileManager instanceof StandardJavaFileManager) {
   25.93 -                        StandardJavaFileManager sfm = (StandardJavaFileManager) fileManager;
   25.94 -                        fo = sfm.getJavaFileObjects(className).iterator().next();
   25.95 -                    } else {
   25.96 -                       diagnosticListener.report(createDiagnostic("err.not.standard.file.manager", className));
   25.97 -                       ok = false;
   25.98 -                       continue;
   25.99 -                    }
  25.100 -                } else {
  25.101 -                    fo = getClassFileObject(className);
  25.102 -                    if (fo == null) {
  25.103 -                        // see if it is an inner class, by replacing dots to $, starting from the right
  25.104 -                        String cn = className;
  25.105 -                        int lastDot;
  25.106 -                        while (fo == null && (lastDot = cn.lastIndexOf(".")) != -1) {
  25.107 -                            cn = cn.substring(0, lastDot) + "$" + cn.substring(lastDot + 1);
  25.108 -                            fo = getClassFileObject(cn);
  25.109 -                        }
  25.110 -                    }
  25.111 -                    if (fo == null) {
  25.112 -                       diagnosticListener.report(createDiagnostic("err.class.not.found", className));
  25.113 -                       ok = false;
  25.114 -                       continue;
  25.115 -                    }
  25.116 -                }
  25.117 -                attributeFactory.setCompat(options.compat);
  25.118 -                attributeFactory.setJSR277(options.jsr277);
  25.119 -
  25.120 -                write(read(fo));
  25.121 -
  25.122 +                writeClass(classWriter, className);
  25.123              } catch (ConstantPoolException e) {
  25.124 -                diagnosticListener.report(createDiagnostic("err.bad.constant.pool", className, e.getLocalizedMessage()));
  25.125 +                reportError("err.bad.constant.pool", className, e.getLocalizedMessage());
  25.126                  ok = false;
  25.127              } catch (EOFException e) {
  25.128 -                diagnosticListener.report(createDiagnostic("err.end.of.file", className));
  25.129 +                reportError("err.end.of.file", className);
  25.130                  ok = false;
  25.131              } catch (FileNotFoundException e) {
  25.132 -                diagnosticListener.report(createDiagnostic("err.file.not.found", e.getLocalizedMessage()));
  25.133 +                reportError("err.file.not.found", e.getLocalizedMessage());
  25.134                  ok = false;
  25.135              } catch (IOException e) {
  25.136                  //e.printStackTrace();
  25.137                  Object msg = e.getLocalizedMessage();
  25.138                  if (msg == null)
  25.139                      msg = e;
  25.140 -                diagnosticListener.report(createDiagnostic("err.ioerror", className, msg));
  25.141 +                reportError("err.ioerror", className, msg);
  25.142                  ok = false;
  25.143              } catch (Throwable t) {
  25.144                  StringWriter sw = new StringWriter();
  25.145                  PrintWriter pw = new PrintWriter(sw);
  25.146                  t.printStackTrace(pw);
  25.147                  pw.close();
  25.148 -                diagnosticListener.report(createDiagnostic("err.crash", t.toString(), sw.toString()));
  25.149 +                reportError("err.crash", t.toString(), sw.toString());
  25.150                  ok = false;
  25.151              }
  25.152          }
  25.153 @@ -586,6 +573,76 @@
  25.154          return ok;
  25.155      }
  25.156  
  25.157 +    protected boolean writeClass(ClassWriter classWriter, String className)
  25.158 +            throws IOException, ConstantPoolException {
  25.159 +        JavaFileObject fo;
  25.160 +        if (className.endsWith(".class")) {
  25.161 +            if (fileManager instanceof StandardJavaFileManager) {
  25.162 +                StandardJavaFileManager sfm = (StandardJavaFileManager) fileManager;
  25.163 +                fo = sfm.getJavaFileObjects(className).iterator().next();
  25.164 +            } else {
  25.165 +                reportError("err.not.standard.file.manager", className);
  25.166 +                return false;
  25.167 +            }
  25.168 +        } else {
  25.169 +            fo = getClassFileObject(className);
  25.170 +            if (fo == null) {
  25.171 +                // see if it is an inner class, by replacing dots to $, starting from the right
  25.172 +                String cn = className;
  25.173 +                int lastDot;
  25.174 +                while (fo == null && (lastDot = cn.lastIndexOf(".")) != -1) {
  25.175 +                    cn = cn.substring(0, lastDot) + "$" + cn.substring(lastDot + 1);
  25.176 +                    fo = getClassFileObject(cn);
  25.177 +                }
  25.178 +            }
  25.179 +            if (fo == null) {
  25.180 +                reportError("err.class.not.found", className);
  25.181 +                return false;
  25.182 +            }
  25.183 +        }
  25.184 +
  25.185 +        ClassFileInfo cfInfo = read(fo);
  25.186 +        if (!className.endsWith(".class")) {
  25.187 +            String cfName = cfInfo.cf.getName();
  25.188 +            if (!cfName.replaceAll("[/$]", ".").equals(className.replaceAll("[/$]", ".")))
  25.189 +                reportWarning("warn.unexpected.class", className, cfName.replace('/', '.'));
  25.190 +        }
  25.191 +        write(cfInfo);
  25.192 +
  25.193 +        if (options.showInnerClasses) {
  25.194 +            ClassFile cf = cfInfo.cf;
  25.195 +            Attribute a = cf.getAttribute(Attribute.InnerClasses);
  25.196 +            if (a instanceof InnerClasses_attribute) {
  25.197 +                InnerClasses_attribute inners = (InnerClasses_attribute) a;
  25.198 +                try {
  25.199 +                    boolean ok = true;
  25.200 +                    for (int i = 0; i < inners.classes.length; i++) {
  25.201 +                        int outerIndex = inners.classes[i].outer_class_info_index;
  25.202 +                        ConstantPool.CONSTANT_Class_info outerClassInfo = cf.constant_pool.getClassInfo(outerIndex);
  25.203 +                        String outerClassName = outerClassInfo.getName();
  25.204 +                        if (outerClassName.equals(cf.getName())) {
  25.205 +                            int innerIndex = inners.classes[i].inner_class_info_index;
  25.206 +                            ConstantPool.CONSTANT_Class_info innerClassInfo = cf.constant_pool.getClassInfo(innerIndex);
  25.207 +                            String innerClassName = innerClassInfo.getName();
  25.208 +                            classWriter.println("// inner class " + innerClassName.replaceAll("[/$]", "."));
  25.209 +                            classWriter.println();
  25.210 +                            ok = ok & writeClass(classWriter, innerClassName);
  25.211 +                        }
  25.212 +                    }
  25.213 +                    return ok;
  25.214 +                } catch (ConstantPoolException e) {
  25.215 +                    reportError("err.bad.innerclasses.attribute", className);
  25.216 +                    return false;
  25.217 +                }
  25.218 +            } else if (a != null) {
  25.219 +                reportError("err.bad.innerclasses.attribute", className);
  25.220 +                return false;
  25.221 +            }
  25.222 +        }
  25.223 +
  25.224 +        return true;
  25.225 +    }
  25.226 +
  25.227      public static class ClassFileInfo {
  25.228          ClassFileInfo(JavaFileObject fo, ClassFile cf, byte[] digest, int size) {
  25.229              this.fo = fo;
  25.230 @@ -684,7 +741,7 @@
  25.231      }
  25.232  
  25.233      private JavaFileManager getDefaultFileManager(final DiagnosticListener<? super JavaFileObject> dl, PrintWriter log) {
  25.234 -        return JavapFileManager.create(dl, log, options);
  25.235 +        return JavapFileManager.create(dl, log);
  25.236      }
  25.237  
  25.238      private JavaFileObject getClassFileObject(String className) throws IOException {
  25.239 @@ -738,10 +795,23 @@
  25.240          }
  25.241      }
  25.242  
  25.243 -    private Diagnostic<JavaFileObject> createDiagnostic(final String key, final Object... args) {
  25.244 +    private void reportError(String key, Object... args) {
  25.245 +        diagnosticListener.report(createDiagnostic(Diagnostic.Kind.ERROR, key, args));
  25.246 +    }
  25.247 +
  25.248 +    private void reportNote(String key, Object... args) {
  25.249 +        diagnosticListener.report(createDiagnostic(Diagnostic.Kind.NOTE, key, args));
  25.250 +    }
  25.251 +
  25.252 +    private void reportWarning(String key, Object... args) {
  25.253 +        diagnosticListener.report(createDiagnostic(Diagnostic.Kind.WARNING, key, args));
  25.254 +    }
  25.255 +
  25.256 +    private Diagnostic<JavaFileObject> createDiagnostic(
  25.257 +            final Diagnostic.Kind kind, final String key, final Object... args) {
  25.258          return new Diagnostic<JavaFileObject>() {
  25.259              public Kind getKind() {
  25.260 -                return Diagnostic.Kind.ERROR;
  25.261 +                return kind;
  25.262              }
  25.263  
  25.264              public JavaFileObject getSource() {
  25.265 @@ -776,6 +846,11 @@
  25.266                  return JavapTask.this.getMessage(locale, key, args);
  25.267              }
  25.268  
  25.269 +            @Override
  25.270 +            public String toString() {
  25.271 +                return getClass().getName() + "[key=" + key + ",args=" + Arrays.asList(args) + "]";
  25.272 +            }
  25.273 +
  25.274          };
  25.275  
  25.276      }
    26.1 --- a/src/share/classes/com/sun/tools/javap/Options.java	Thu Jul 30 23:41:19 2009 -0700
    26.2 +++ b/src/share/classes/com/sun/tools/javap/Options.java	Fri Jul 31 17:20:06 2009 -0700
    26.3 @@ -85,6 +85,7 @@
    26.4      public boolean showAllAttrs;
    26.5      public boolean showConstants;
    26.6      public boolean sysInfo;
    26.7 +    public boolean showInnerClasses;
    26.8  
    26.9      public boolean compat;             // bug-for-bug compatibility mode with old javap
   26.10      public boolean jsr277;
    27.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
    27.2 +++ b/src/share/classes/com/sun/tools/javap/TypeAnnotationWriter.java	Fri Jul 31 17:20:06 2009 -0700
    27.3 @@ -0,0 +1,126 @@
    27.4 +/*
    27.5 + * Copyright 2009 Sun Microsystems, Inc.  All Rights Reserved.
    27.6 + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
    27.7 + *
    27.8 + * This code is free software; you can redistribute it and/or modify it
    27.9 + * under the terms of the GNU General Public License version 2 only, as
   27.10 + * published by the Free Software Foundation.  Sun designates this
   27.11 + * particular file as subject to the "Classpath" exception as provided
   27.12 + * by Sun in the LICENSE file that accompanied this code.
   27.13 + *
   27.14 + * This code is distributed in the hope that it will be useful, but WITHOUT
   27.15 + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
   27.16 + * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
   27.17 + * version 2 for more details (a copy is included in the LICENSE file that
   27.18 + * accompanied this code).
   27.19 + *
   27.20 + * You should have received a copy of the GNU General Public License version
   27.21 + * 2 along with this work; if not, write to the Free Software Foundation,
   27.22 + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
   27.23 + *
   27.24 + * Please contact Sun Microsystems, Inc., 4150 Network Circle, Santa Clara,
   27.25 + * CA 95054 USA or visit www.sun.com if you need additional information or
   27.26 + * have any questions.
   27.27 + */
   27.28 +package com.sun.tools.javap;
   27.29 +
   27.30 +import com.sun.tools.classfile.Attribute;
   27.31 +import com.sun.tools.classfile.Code_attribute;
   27.32 +import com.sun.tools.classfile.ExtendedAnnotation;
   27.33 +import com.sun.tools.classfile.ExtendedAnnotation.Position;
   27.34 +import com.sun.tools.classfile.Instruction;
   27.35 +import com.sun.tools.classfile.Method;
   27.36 +import com.sun.tools.classfile.RuntimeInvisibleTypeAnnotations_attribute;
   27.37 +import com.sun.tools.classfile.RuntimeTypeAnnotations_attribute;
   27.38 +import com.sun.tools.classfile.RuntimeVisibleTypeAnnotations_attribute;
   27.39 +import java.util.ArrayList;
   27.40 +import java.util.HashMap;
   27.41 +import java.util.List;
   27.42 +import java.util.Map;
   27.43 +
   27.44 +/**
   27.45 + * Annotate instructions with details about type annotations.
   27.46 + *
   27.47 + *  <p><b>This is NOT part of any API supported by Sun Microsystems.  If
   27.48 + *  you write code that depends on this, you do so at your own risk.
   27.49 + *  This code and its internal interfaces are subject to change or
   27.50 + *  deletion without notice.</b>
   27.51 + */
   27.52 +public class TypeAnnotationWriter extends InstructionDetailWriter {
   27.53 +    public enum NoteKind { VISIBLE, INVISIBLE };
   27.54 +    public static class Note {
   27.55 +        Note(NoteKind kind, ExtendedAnnotation anno) {
   27.56 +            this.kind = kind;
   27.57 +            this.anno = anno;
   27.58 +        }
   27.59 +        public final NoteKind kind;
   27.60 +        public final ExtendedAnnotation anno;
   27.61 +    }
   27.62 +
   27.63 +    static TypeAnnotationWriter instance(Context context) {
   27.64 +        TypeAnnotationWriter instance = context.get(TypeAnnotationWriter.class);
   27.65 +        if (instance == null)
   27.66 +            instance = new TypeAnnotationWriter(context);
   27.67 +        return instance;
   27.68 +    }
   27.69 +
   27.70 +    protected TypeAnnotationWriter(Context context) {
   27.71 +        super(context);
   27.72 +        context.put(TypeAnnotationWriter.class, this);
   27.73 +        annotationWriter = AnnotationWriter.instance(context);
   27.74 +        classWriter = ClassWriter.instance(context);
   27.75 +    }
   27.76 +
   27.77 +    public void reset(Code_attribute attr) {
   27.78 +        Method m = classWriter.getMethod();
   27.79 +        pcMap = new HashMap<Integer, List<Note>>();
   27.80 +        check(NoteKind.VISIBLE, (RuntimeVisibleTypeAnnotations_attribute) m.attributes.get(Attribute.RuntimeVisibleTypeAnnotations));
   27.81 +        check(NoteKind.INVISIBLE, (RuntimeInvisibleTypeAnnotations_attribute) m.attributes.get(Attribute.RuntimeInvisibleTypeAnnotations));
   27.82 +    }
   27.83 +
   27.84 +    private void check(NoteKind kind, RuntimeTypeAnnotations_attribute attr) {
   27.85 +        if (attr == null)
   27.86 +            return;
   27.87 +
   27.88 +        for (ExtendedAnnotation anno: attr.annotations) {
   27.89 +            Position p = anno.position;
   27.90 +            Note note = null;
   27.91 +            if (p.offset != -1)
   27.92 +                addNote(p.offset, note = new Note(kind, anno));
   27.93 +            if (p.lvarOffset != null) {
   27.94 +                for (int i = 0; i < p.lvarOffset.length; i++) {
   27.95 +                    if (note == null)
   27.96 +                        note = new Note(kind, anno);
   27.97 +                    addNote(p.lvarOffset[i], note);
   27.98 +                }
   27.99 +            }
  27.100 +        }
  27.101 +    }
  27.102 +
  27.103 +    private void addNote(int pc, Note note) {
  27.104 +        List<Note> list = pcMap.get(pc);
  27.105 +        if (list == null)
  27.106 +            pcMap.put(pc, list = new ArrayList<Note>());
  27.107 +        list.add(note);
  27.108 +    }
  27.109 +
  27.110 +    @Override
  27.111 +    void writeDetails(Instruction instr) {
  27.112 +        String indent = space(2); // get from Options?
  27.113 +        int pc = instr.getPC();
  27.114 +        List<Note> notes = pcMap.get(pc);
  27.115 +        if (notes != null) {
  27.116 +            for (Note n: notes) {
  27.117 +                print(indent);
  27.118 +                print("@");
  27.119 +                annotationWriter.write(n.anno, false, true);
  27.120 +                print(", ");
  27.121 +                println(n.kind.toString().toLowerCase());
  27.122 +            }
  27.123 +        }
  27.124 +    }
  27.125 +
  27.126 +    private AnnotationWriter annotationWriter;
  27.127 +    private ClassWriter classWriter;
  27.128 +    private Map<Integer, List<Note>> pcMap;
  27.129 +}
    28.1 --- a/src/share/classes/com/sun/tools/javap/resources/javap.properties	Thu Jul 30 23:41:19 2009 -0700
    28.2 +++ b/src/share/classes/com/sun/tools/javap/resources/javap.properties	Fri Jul 31 17:20:06 2009 -0700
    28.3 @@ -18,12 +18,22 @@
    28.4  err.verify.not.supported=-verify not supported
    28.5  err.no.SourceFile.attribute=no SourceFile attribute
    28.6  err.source.file.not.found=source file not found
    28.7 +err.bad.innerclasses.attribute=bad InnerClasses attribute for {0}
    28.8  warn.Xold.not.supported=-Xold is no longer available
    28.9  
   28.10  main.usage.summary=\
   28.11  Usage: {0} <options> <classes>\n\
   28.12  use -help for a list of possible options
   28.13  
   28.14 +warn.prefix=Warning:
   28.15 +warn.unexpected.class=Binary file {0} contains {1}
   28.16 +
   28.17 +note.prefix=Note:
   28.18 +
   28.19 +main.usage.summary=\
   28.20 +Usage: {0} <options> <classes>\n\
   28.21 +use -help for a list of possible options
   28.22 +
   28.23  main.usage=\
   28.24  Usage: {0} <options> <classes>\n\
   28.25  where possible options include:
    29.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
    29.2 +++ b/test/tools/javac/Diagnostics/6862608/T6862608a.java	Fri Jul 31 17:20:06 2009 -0700
    29.3 @@ -0,0 +1,44 @@
    29.4 +/*
    29.5 + * Copyright 2009 Sun Microsystems, Inc.  All Rights Reserved.
    29.6 + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
    29.7 + *
    29.8 + * This code is free software; you can redistribute it and/or modify it
    29.9 + * under the terms of the GNU General Public License version 2 only, as
   29.10 + * published by the Free Software Foundation.
   29.11 + *
   29.12 + * This code is distributed in the hope that it will be useful, but WITHOUT
   29.13 + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
   29.14 + * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
   29.15 + * version 2 for more details (a copy is included in the LICENSE file that
   29.16 + * accompanied this code).
   29.17 + *
   29.18 + * You should have received a copy of the GNU General Public License version
   29.19 + * 2 along with this work; if not, write to the Free Software Foundation,
   29.20 + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
   29.21 + *
   29.22 + * Please contact Sun Microsystems, Inc., 4150 Network Circle, Santa Clara,
   29.23 + * CA 95054 USA or visit www.sun.com if you need additional information or
   29.24 + * have any questions.
   29.25 + */
   29.26 +
   29.27 +/**
   29.28 + * @test
   29.29 + * @bug     6862608
   29.30 + * @summary rich diagnostic sometimes contain wrong type variable numbering
   29.31 + * @author  mcimadamore
   29.32 + * @compile/fail/ref=T6862608a.out -XDrawDiagnostics -XDdiags=disambiguateTvars,where T6862608a.java
   29.33 + */
   29.34 +
   29.35 +
   29.36 +import java.util.*;
   29.37 +
   29.38 +class T6862608a {
   29.39 +
   29.40 +    <T> Comparator<T> compound(Iterable<? extends Comparator<? super T>> it) {
   29.41 +        return null;
   29.42 +    }
   29.43 +
   29.44 +    public void test(List<Comparator<?>> x) {
   29.45 +        Comparator<String> c3 = compound(x);
   29.46 +    }
   29.47 +}
    30.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
    30.2 +++ b/test/tools/javac/Diagnostics/6862608/T6862608a.out	Fri Jul 31 17:20:06 2009 -0700
    30.3 @@ -0,0 +1,3 @@
    30.4 +T6862608a.java:42:41: compiler.err.invalid.inferred.types: T, (compiler.misc.inferred.do.not.conform.to.params: java.lang.Iterable<? extends java.util.Comparator<? super java.lang.String>>, java.util.List<java.util.Comparator<?>>)
    30.5 +- compiler.misc.where.description.typevar: T,{(compiler.misc.where.typevar: T, java.lang.Object, kindname.method, <T>compound(java.lang.Iterable<? extends java.util.Comparator<? super T>>))}
    30.6 +1 error
    31.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
    31.2 +++ b/test/tools/javac/Diagnostics/6862608/T6862608b.java	Fri Jul 31 17:20:06 2009 -0700
    31.3 @@ -0,0 +1,38 @@
    31.4 +/*
    31.5 + * Copyright 2009 Sun Microsystems, Inc.  All Rights Reserved.
    31.6 + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
    31.7 + *
    31.8 + * This code is free software; you can redistribute it and/or modify it
    31.9 + * under the terms of the GNU General Public License version 2 only, as
   31.10 + * published by the Free Software Foundation.
   31.11 + *
   31.12 + * This code is distributed in the hope that it will be useful, but WITHOUT
   31.13 + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
   31.14 + * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
   31.15 + * version 2 for more details (a copy is included in the LICENSE file that
   31.16 + * accompanied this code).
   31.17 + *
   31.18 + * You should have received a copy of the GNU General Public License version
   31.19 + * 2 along with this work; if not, write to the Free Software Foundation,
   31.20 + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
   31.21 + *
   31.22 + * Please contact Sun Microsystems, Inc., 4150 Network Circle, Santa Clara,
   31.23 + * CA 95054 USA or visit www.sun.com if you need additional information or
   31.24 + * have any questions.
   31.25 + */
   31.26 +
   31.27 +/**
   31.28 + * @test
   31.29 + * @bug     6862608
   31.30 + * @summary rich diagnostic sometimes contain wrong type variable numbering
   31.31 + * @author  mcimadamore
   31.32 + * @compile/fail/ref=T6862608b.out -XDrawDiagnostics -XDdiags=disambiguateTvars,where T6862608b.java
   31.33 + */
   31.34 +
   31.35 +class T66862608b<T extends String, S> {
   31.36 +   <S, T extends S> void foo(T t) {
   31.37 +      test(t);
   31.38 +   }
   31.39 +
   31.40 +   void test(T t) {}
   31.41 +}
    32.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
    32.2 +++ b/test/tools/javac/Diagnostics/6862608/T6862608b.out	Fri Jul 31 17:20:06 2009 -0700
    32.3 @@ -0,0 +1,3 @@
    32.4 +T6862608b.java:34:7: compiler.err.cant.apply.symbol: kindname.method, test, compiler.misc.type.var: T, 1, compiler.misc.type.var: T, 2, kindname.class, T66862608b<compiler.misc.type.var: T, 1,compiler.misc.type.var: S, 2>, null
    32.5 +- compiler.misc.where.description.typevar.1: compiler.misc.type.var: T, 1,compiler.misc.type.var: T, 2,compiler.misc.type.var: S, 1,compiler.misc.type.var: S, 2,{(compiler.misc.where.typevar: compiler.misc.type.var: T, 1, java.lang.String, kindname.class, T66862608b),(compiler.misc.where.typevar: compiler.misc.type.var: T, 2, compiler.misc.type.var: S, 1, kindname.method, <compiler.misc.type.var: S, 1,compiler.misc.type.var: T, 2>foo(compiler.misc.type.var: T, 2)),(compiler.misc.where.typevar: compiler.misc.type.var: S, 1, java.lang.Object, kindname.method, <compiler.misc.type.var: S, 1,compiler.misc.type.var: T, 2>foo(compiler.misc.type.var: T, 2)),(compiler.misc.where.typevar: compiler.misc.type.var: S, 2, java.lang.Object, kindname.class, T66862608b)}
    32.6 +1 error
    33.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
    33.2 +++ b/test/tools/javac/Diagnostics/6864382/T6864382.java	Fri Jul 31 17:20:06 2009 -0700
    33.3 @@ -0,0 +1,32 @@
    33.4 +/*
    33.5 + * Copyright 2009 Sun Microsystems, Inc.  All Rights Reserved.
    33.6 + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
    33.7 + *
    33.8 + * This code is free software; you can redistribute it and/or modify it
    33.9 + * under the terms of the GNU General Public License version 2 only, as
   33.10 + * published by the Free Software Foundation.
   33.11 + *
   33.12 + * This code is distributed in the hope that it will be useful, but WITHOUT
   33.13 + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
   33.14 + * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
   33.15 + * version 2 for more details (a copy is included in the LICENSE file that
   33.16 + * accompanied this code).
   33.17 + *
   33.18 + * You should have received a copy of the GNU General Public License version
   33.19 + * 2 along with this work; if not, write to the Free Software Foundation,
   33.20 + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
   33.21 + *
   33.22 + * Please contact Sun Microsystems, Inc., 4150 Network Circle, Santa Clara,
   33.23 + * CA 95054 USA or visit www.sun.com if you need additional information or
   33.24 + * have any questions.
   33.25 + */
   33.26 +
   33.27 +/**
   33.28 + * @test
   33.29 + * @bug     6864382
   33.30 + * @summary NullPointerException when compiling a negative java source
   33.31 + * @author  mcimadamore
   33.32 + * @compile/fail/ref=T6864382.out -XDrawDiagnostics  T6864382.java
   33.33 + */
   33.34 +
   33.35 +class T6864382<T> extends T {}
    34.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
    34.2 +++ b/test/tools/javac/Diagnostics/6864382/T6864382.out	Fri Jul 31 17:20:06 2009 -0700
    34.3 @@ -0,0 +1,2 @@
    34.4 +T6864382.java:32:27: compiler.err.type.found.req: (compiler.misc.type.parameter: T), (compiler.misc.type.req.class)
    34.5 +1 error
    35.1 --- a/test/tools/javac/typeAnnotations/InnerClass.java	Thu Jul 30 23:41:19 2009 -0700
    35.2 +++ b/test/tools/javac/typeAnnotations/InnerClass.java	Fri Jul 31 17:20:06 2009 -0700
    35.3 @@ -30,9 +30,30 @@
    35.4   */
    35.5  
    35.6  class InnerClass {
    35.7 +
    35.8 +    InnerClass() {}
    35.9 +    InnerClass(Object o) {}
   35.10 +
   35.11      private void a() {
   35.12          new Object() {
   35.13              public <R> void method() { }
   35.14          };
   35.15      }
   35.16 +
   35.17 +    Object f1 = new InnerClass() {
   35.18 +            <R> void method() { }
   35.19 +        };
   35.20 +
   35.21 +    Object f2 = new InnerClass() {
   35.22 +            <@A R> void method() { }
   35.23 +        };
   35.24 +
   35.25 +    Object f3 = new InnerClass(null) {
   35.26 +            <R> void method() { }
   35.27 +        };
   35.28 +
   35.29 +    Object f4 = new InnerClass(null) {
   35.30 +            <@A R> void method() { }
   35.31 +        };
   35.32 +    @interface A { }
   35.33  }
    36.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
    36.2 +++ b/test/tools/javap/T4777949.java	Fri Jul 31 17:20:06 2009 -0700
    36.3 @@ -0,0 +1,111 @@
    36.4 +/*
    36.5 + * Copyright 2008 Sun Microsystems, Inc.  All Rights Reserved.
    36.6 + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
    36.7 + *
    36.8 + * This code is free software; you can redistribute it and/or modify it
    36.9 + * under the terms of the GNU General Public License version 2 only, as
   36.10 + * published by the Free Software Foundation.
   36.11 + *
   36.12 + * This code is distributed in the hope that it will be useful, but WITHOUT
   36.13 + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
   36.14 + * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
   36.15 + * version 2 for more details (a copy is included in the LICENSE file that
   36.16 + * accompanied this code).
   36.17 + *
   36.18 + * You should have received a copy of the GNU General Public License version
   36.19 + * 2 along with this work; if not, write to the Free Software Foundation,
   36.20 + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
   36.21 + *
   36.22 + * Please contact Sun Microsystems, Inc., 4150 Network Circle, Santa Clara,
   36.23 + * CA 95054 USA or visit www.sun.com if you need additional information or
   36.24 + * have any questions.
   36.25 + */
   36.26 +
   36.27 +import java.io.*;
   36.28 +import java.util.*;
   36.29 +import javax.tools.*;
   36.30 +import com.sun.tools.javap.*;
   36.31 +
   36.32 +/*
   36.33 + * @test
   36.34 + * @bug 4777949
   36.35 + * @summary Warn javap usage on package with simple name
   36.36 + */
   36.37 +public class T4777949 {
   36.38 +    public static void main(String... args) throws Exception {
   36.39 +        new T4777949().run();
   36.40 +    }
   36.41 +
   36.42 +    void run() throws Exception {
   36.43 +        File javaFile = writeTestFile();
   36.44 +        File classFile = compileTestFile(javaFile);
   36.45 +
   36.46 +        test(".", "p.q.r.Test", false);
   36.47 +        test("p", "q.r.Test", true);
   36.48 +        test("p/q", "r.Test", true);
   36.49 +        test("p/q/r", "Test", true);
   36.50 +        test(".", "p.q.r.Test.Inner", false);
   36.51 +        test(".", "p.q.r.Test$Inner", false);
   36.52 +        test("p", "q.r.Test.Inner", true);
   36.53 +        test("p", "q.r.Test$Inner", true);
   36.54 +
   36.55 +        if (errors > 0)
   36.56 +            throw new Exception(errors + " errors found");
   36.57 +    }
   36.58 +
   36.59 +    void test(String classPath, String className, boolean expectWarnings) {
   36.60 +        List<Diagnostic<? extends JavaFileObject>> diags =
   36.61 +            javap(Arrays.asList("-classpath", classPath), Arrays.asList(className));
   36.62 +        boolean foundWarnings = false;
   36.63 +        for (Diagnostic<? extends JavaFileObject> d: diags) {
   36.64 +            if (d.getKind() == Diagnostic.Kind.WARNING)
   36.65 +                foundWarnings = true;
   36.66 +        }
   36.67 +    }
   36.68 +
   36.69 +
   36.70 +    File writeTestFile() throws IOException {
   36.71 +        File f = new File("Test.java");
   36.72 +        PrintWriter out = new PrintWriter(new BufferedWriter(new FileWriter(f)));
   36.73 +        out.println("package p.q.r;");
   36.74 +        out.println("class Test { class Inner { } }");
   36.75 +        out.close();
   36.76 +        return f;
   36.77 +    }
   36.78 +
   36.79 +    File compileTestFile(File f) {
   36.80 +        int rc = com.sun.tools.javac.Main.compile(new String[] { "-d", ".", f.getPath() });
   36.81 +        if (rc != 0)
   36.82 +            throw new Error("compilation failed. rc=" + rc);
   36.83 +        String path = f.getPath();
   36.84 +        return new File(path.substring(0, path.length() - 5) + ".class");
   36.85 +    }
   36.86 +
   36.87 +    List<Diagnostic<? extends JavaFileObject>> javap(List<String> args, List<String> classes) {
   36.88 +        DiagnosticCollector<JavaFileObject> dc = new DiagnosticCollector<JavaFileObject>();
   36.89 +        StringWriter sw = new StringWriter();
   36.90 +        PrintWriter pw = new PrintWriter(sw);
   36.91 +        JavaFileManager fm = JavapFileManager.create(dc, pw);
   36.92 +        JavapTask t = new JavapTask(pw, fm, dc, args, classes);
   36.93 +        boolean ok = t.run();
   36.94 +
   36.95 +        List<Diagnostic<? extends JavaFileObject>> diags = dc.getDiagnostics();
   36.96 +
   36.97 +        if (!ok)
   36.98 +            error("javap failed unexpectedly");
   36.99 +
  36.100 +        System.err.println("args=" + args + " classes=" + classes + "\n"
  36.101 +                           + diags + "\n"
  36.102 +                           + sw);
  36.103 +
  36.104 +        return diags;
  36.105 +    }
  36.106 +
  36.107 +    void error(String msg) {
  36.108 +        System.err.println("error: " + msg);
  36.109 +        errors++;
  36.110 +    }
  36.111 +
  36.112 +    int errors;
  36.113 +}
  36.114 +
    37.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
    37.2 +++ b/test/tools/javap/T4880672.java	Fri Jul 31 17:20:06 2009 -0700
    37.3 @@ -0,0 +1,86 @@
    37.4 +/*
    37.5 + * Copyright 2009 Sun Microsystems, Inc.  All Rights Reserved.
    37.6 + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
    37.7 + *
    37.8 + * This code is free software; you can redistribute it and/or modify it
    37.9 + * under the terms of the GNU General Public License version 2 only, as
   37.10 + * published by the Free Software Foundation.
   37.11 + *
   37.12 + * This code is distributed in the hope that it will be useful, but WITHOUT
   37.13 + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
   37.14 + * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
   37.15 + * version 2 for more details (a copy is included in the LICENSE file that
   37.16 + * accompanied this code).
   37.17 + *
   37.18 + * You should have received a copy of the GNU General Public License version
   37.19 + * 2 along with this work; if not, write to the Free Software Foundation,
   37.20 + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
   37.21 + *
   37.22 + * Please contact Sun Microsystems, Inc., 4150 Network Circle, Santa Clara,
   37.23 + * CA 95054 USA or visit www.sun.com if you need additional information or
   37.24 + * have any questions.
   37.25 + */
   37.26 +
   37.27 +
   37.28 +/*
   37.29 + * @test
   37.30 + * @bug 4880672
   37.31 + * @summary javap does not output inner interfaces of an interface
   37.32 + */
   37.33 +
   37.34 +import java.io.*;
   37.35 +import java.util.*;
   37.36 +
   37.37 +public class T4880672
   37.38 +{
   37.39 +    public static void main(String... args) {
   37.40 +        new T4880672().run();
   37.41 +    }
   37.42 +
   37.43 +    void run() {
   37.44 +        verify("java.util.Map", "public interface java.util.Map$Entry");
   37.45 +        verify("T4880672", "class T4880672$A$B extends java.lang.Object");
   37.46 +        verify("C", ""); // must not give error if no InnerClasses attribute
   37.47 +        if (errors > 0)
   37.48 +            throw new Error(errors + " found.");
   37.49 +    }
   37.50 +
   37.51 +    void verify(String className, String... expects) {
   37.52 +        String output = javap(className);
   37.53 +        for (String expect: expects) {
   37.54 +            if (output.indexOf(expect)< 0)
   37.55 +                error(expect + " not found");
   37.56 +        }
   37.57 +    }
   37.58 +
   37.59 +    void error(String msg) {
   37.60 +        System.err.println(msg);
   37.61 +        errors++;
   37.62 +    }
   37.63 +
   37.64 +    int errors;
   37.65 +
   37.66 +    String javap(String className) {
   37.67 +        String testClasses = System.getProperty("test.classes", ".");
   37.68 +        StringWriter sw = new StringWriter();
   37.69 +        PrintWriter out = new PrintWriter(sw);
   37.70 +        String[] args = { "-XDinner", "-classpath", testClasses, className };
   37.71 +        int rc = com.sun.tools.javap.Main.run(args, out);
   37.72 +        out.close();
   37.73 +        String output = sw.toString();
   37.74 +        System.out.println("class " + className);
   37.75 +        System.out.println(output);
   37.76 +        if (rc != 0)
   37.77 +            throw new Error("javap failed. rc=" + rc);
   37.78 +        if (output.indexOf("Error:") != -1)
   37.79 +            throw new Error("javap reported error.");
   37.80 +        return output;
   37.81 +    }
   37.82 +
   37.83 +    class A {
   37.84 +        class B { }
   37.85 +    }
   37.86 +}
   37.87 +
   37.88 +class C { }
   37.89 +
    38.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
    38.2 +++ b/test/tools/javap/T6866657.java	Fri Jul 31 17:20:06 2009 -0700
    38.3 @@ -0,0 +1,82 @@
    38.4 +/*
    38.5 + * Copyright 2009 Sun Microsystems, Inc.  All Rights Reserved.
    38.6 + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
    38.7 + *
    38.8 + * This code is free software; you can redistribute it and/or modify it
    38.9 + * under the terms of the GNU General Public License version 2 only, as
   38.10 + * published by the Free Software Foundation.
   38.11 + *
   38.12 + * This code is distributed in the hope that it will be useful, but WITHOUT
   38.13 + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
   38.14 + * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
   38.15 + * version 2 for more details (a copy is included in the LICENSE file that
   38.16 + * accompanied this code).
   38.17 + *
   38.18 + * You should have received a copy of the GNU General Public License version
   38.19 + * 2 along with this work; if not, write to the Free Software Foundation,
   38.20 + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
   38.21 + *
   38.22 + * Please contact Sun Microsystems, Inc., 4150 Network Circle, Santa Clara,
   38.23 + * CA 95054 USA or visit www.sun.com if you need additional information or
   38.24 + * have any questions.
   38.25 + */
   38.26 +
   38.27 +
   38.28 +/*
   38.29 + * @test
   38.30 + * @bug 6866657
   38.31 + * @summary add byteLength() method to primary classfile types
   38.32 + */
   38.33 +
   38.34 +import java.io.*;
   38.35 +import java.util.*;
   38.36 +import javax.tools.*;
   38.37 +import com.sun.tools.javap.*;
   38.38 +
   38.39 +public class T6866657
   38.40 +{
   38.41 +    public static void main(String... args) {
   38.42 +        new T6866657().run();
   38.43 +    }
   38.44 +
   38.45 +    void run() {
   38.46 +        verify("java.lang.Object");
   38.47 +        verify("java.lang.String");
   38.48 +        verify("java.util.List");
   38.49 +        verify("java.util.ArrayList");
   38.50 +        if (errors > 0)
   38.51 +            throw new Error(errors + " found.");
   38.52 +    }
   38.53 +
   38.54 +    void verify(String className) {
   38.55 +        try {
   38.56 +            PrintWriter log = new PrintWriter(System.out);
   38.57 +            JavaFileManager fileManager = JavapFileManager.create(null, log);
   38.58 +            JavaFileObject fo = fileManager.getJavaFileForInput(StandardLocation.PLATFORM_CLASS_PATH, className, JavaFileObject.Kind.CLASS);
   38.59 +            if (fo == null) {
   38.60 +                error("Can't find " + className);
   38.61 +            } else {
   38.62 +                JavapTask t = new JavapTask(log, fileManager, null);
   38.63 +                t.handleOptions(new String[] { "-sysinfo", className });
   38.64 +                JavapTask.ClassFileInfo cfInfo = t.read(fo);
   38.65 +                expectEqual(cfInfo.cf.byteLength(), cfInfo.size);
   38.66 +            }
   38.67 +        } catch (Exception e) {
   38.68 +            e.printStackTrace();
   38.69 +            error("Exception: " + e);
   38.70 +        }
   38.71 +    }
   38.72 +
   38.73 +    void expectEqual(int found, int expected) {
   38.74 +        if (found != expected)
   38.75 +            error("bad value found: " + found + " expected: " + expected);
   38.76 +    }
   38.77 +
   38.78 +    void error(String msg) {
   38.79 +        System.err.println(msg);
   38.80 +        errors++;
   38.81 +    }
   38.82 +
   38.83 +    int errors;
   38.84 +}
   38.85 +
    39.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
    39.2 +++ b/test/tools/javap/typeAnnotations/T6855990.java	Fri Jul 31 17:20:06 2009 -0700
    39.3 @@ -0,0 +1,51 @@
    39.4 +/*
    39.5 + * Copyright 2009 Sun Microsystems, Inc.  All Rights Reserved.
    39.6 + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
    39.7 + *
    39.8 + * This code is free software; you can redistribute it and/or modify it
    39.9 + * under the terms of the GNU General Public License version 2 only, as
   39.10 + * published by the Free Software Foundation.
   39.11 + *
   39.12 + * This code is distributed in the hope that it will be useful, but WITHOUT
   39.13 + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
   39.14 + * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
   39.15 + * version 2 for more details (a copy is included in the LICENSE file that
   39.16 + * accompanied this code).
   39.17 + *
   39.18 + * You should have received a copy of the GNU General Public License version
   39.19 + * 2 along with this work; if not, write to the Free Software Foundation,
   39.20 + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
   39.21 + *
   39.22 + * Please contact Sun Microsystems, Inc., 4150 Network Circle, Santa Clara,
   39.23 + * CA 95054 USA or visit www.sun.com if you need additional information or
   39.24 + * have any questions.
   39.25 + */
   39.26 +
   39.27 +import java.io.*;
   39.28 +
   39.29 +/*
   39.30 + * @test
   39.31 + * @bug 6855990
   39.32 + * @summary InstructionDetailWriter should support new 308 annotations attribute
   39.33 + */
   39.34 +
   39.35 +public class T6855990 {
   39.36 +    public static void main(String[] args) throws Exception {
   39.37 +        new T6855990().run();
   39.38 +    }
   39.39 +
   39.40 +    public void run() throws Exception {
   39.41 +        @Simple String[] args = { "-c", "-XDdetails:typeAnnotations", "T6855990" };
   39.42 +        StringWriter sw = new StringWriter();
   39.43 +        PrintWriter pw = new PrintWriter(sw);
   39.44 +        int rc = com.sun.tools.javap.Main.run(args, pw);
   39.45 +        pw.close();
   39.46 +        String out = sw.toString();
   39.47 +        System.out.println(out);
   39.48 +        if (out.indexOf("@Simple: LOCAL_VARIABLE") == -1)
   39.49 +            throw new Exception("expected output not found");
   39.50 +    }
   39.51 +}
   39.52 +
   39.53 +@interface Simple { }
   39.54 +

mercurial