Merge jdk8-b73

Thu, 10 Jan 2013 15:53:02 -0800

author
lana
date
Thu, 10 Jan 2013 15:53:02 -0800
changeset 1487
8d0baee36c71
parent 1471
45fed5cfd1c3
parent 1486
7d2f628f04f1
child 1488
56c97aff46bb
child 1500
63b20bde7cd6

Merge

     1.1 --- a/make/build.properties	Thu Jan 10 09:56:09 2013 -0800
     1.2 +++ b/make/build.properties	Thu Jan 10 15:53:02 2013 -0800
     1.3 @@ -153,6 +153,7 @@
     1.4  javap.includes = \
     1.5          com/sun/tools/classfile/ \
     1.6          com/sun/tools/javap/ \
     1.7 +        com/sun/tools/jdeps/ \
     1.8          sun/tools/javap/
     1.9  
    1.10  javap.tests = \
     2.1 --- a/makefiles/BuildLangtools.gmk	Thu Jan 10 09:56:09 2013 -0800
     2.2 +++ b/makefiles/BuildLangtools.gmk	Thu Jan 10 15:53:02 2013 -0800
     2.3 @@ -75,6 +75,7 @@
     2.4  	printf "jdk=$(JDK_VERSION)\nfull=$(FULL_VERSION)\nrelease=$(RELEASE)\n" > $(LANGTOOLS_OUTPUTDIR)/gensrc/com/sun/tools/javah/resources/version.properties
     2.5  	printf "jdk=$(JDK_VERSION)\nfull=$(FULL_VERSION)\nrelease=$(RELEASE)\n" > $(LANGTOOLS_OUTPUTDIR)/gensrc/com/sun/tools/javap/resources/version.properties
     2.6  	printf "jdk=$(JDK_VERSION)\nfull=$(FULL_VERSION)\nrelease=$(RELEASE)\n" > $(LANGTOOLS_OUTPUTDIR)/gensrc/com/sun/tools/javac/resources/version.properties
     2.7 +	printf "jdk=$(JDK_VERSION)\nfull=$(FULL_VERSION)\nrelease=$(RELEASE)\n" > $(LANGTOOLS_OUTPUTDIR)/gensrc/com/sun/tools/jdeps/resources/version.properties
     2.8  	echo Compiling $(words $(PROPSOURCES) v1 v2 v3) properties into resource bundles
     2.9  	$(TOOL_COMPILEPROPS_CMD) $(PROPCMDLINE) \
    2.10  		-compile 	$(LANGTOOLS_OUTPUTDIR)/gensrc/com/sun/tools/javah/resources/version.properties \
    2.11 @@ -85,6 +86,9 @@
    2.12  				java.util.ListResourceBundle \
    2.13  		-compile	$(LANGTOOLS_OUTPUTDIR)/gensrc/com/sun/tools/javac/resources/version.properties \
    2.14  				$(LANGTOOLS_OUTPUTDIR)/gensrc/com/sun/tools/javac/resources/version.java \
    2.15 +				java.util.ListResourceBundle \
    2.16 +		-compile	$(LANGTOOLS_OUTPUTDIR)/gensrc/com/sun/tools/jdeps/resources/version.properties \
    2.17 +				$(LANGTOOLS_OUTPUTDIR)/gensrc/com/sun/tools/jdeps/resources/version.java \
    2.18  				java.util.ListResourceBundle
    2.19  	echo PROPS_ARE_CREATED=yes > $@
    2.20  
     3.1 --- a/src/share/classes/com/sun/javadoc/AnnotationDesc.java	Thu Jan 10 09:56:09 2013 -0800
     3.2 +++ b/src/share/classes/com/sun/javadoc/AnnotationDesc.java	Thu Jan 10 15:53:02 2013 -0800
     3.3 @@ -52,6 +52,12 @@
     3.4       */
     3.5      ElementValuePair[] elementValues();
     3.6  
     3.7 +    /**
     3.8 +     * Check for the synthesized bit on the annotation.
     3.9 +     *
    3.10 +     * @return true if the annotation is synthesized.
    3.11 +     */
    3.12 +    boolean isSynthesized();
    3.13  
    3.14      /**
    3.15       * Represents an association between an annotation type element
     4.1 --- a/src/share/classes/com/sun/tools/classfile/Attribute.java	Thu Jan 10 09:56:09 2013 -0800
     4.2 +++ b/src/share/classes/com/sun/tools/classfile/Attribute.java	Thu Jan 10 15:53:02 2013 -0800
     4.3 @@ -1,5 +1,5 @@
     4.4  /*
     4.5 - * Copyright (c) 2007, 2011, Oracle and/or its affiliates. All rights reserved.
     4.6 + * Copyright (c) 2007, 2012, Oracle and/or its affiliates. All rights reserved.
     4.7   * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
     4.8   *
     4.9   * This code is free software; you can redistribute it and/or modify it
    4.10 @@ -51,6 +51,7 @@
    4.11      public static final String LineNumberTable          = "LineNumberTable";
    4.12      public static final String LocalVariableTable       = "LocalVariableTable";
    4.13      public static final String LocalVariableTypeTable   = "LocalVariableTypeTable";
    4.14 +    public static final String MethodParameters         = "MethodParameters";
    4.15      public static final String RuntimeVisibleAnnotations = "RuntimeVisibleAnnotations";
    4.16      public static final String RuntimeInvisibleAnnotations = "RuntimeInvisibleAnnotations";
    4.17      public static final String RuntimeVisibleParameterAnnotations = "RuntimeVisibleParameterAnnotations";
    4.18 @@ -113,6 +114,7 @@
    4.19              standardAttributes.put(LocalVariableTypeTable, LocalVariableTypeTable_attribute.class);
    4.20  
    4.21              if (!compat) { // old javap does not recognize recent attributes
    4.22 +                standardAttributes.put(MethodParameters, MethodParameters_attribute.class);
    4.23                  standardAttributes.put(CompilationID, CompilationID_attribute.class);
    4.24                  standardAttributes.put(RuntimeInvisibleAnnotations, RuntimeInvisibleAnnotations_attribute.class);
    4.25                  standardAttributes.put(RuntimeInvisibleParameterAnnotations, RuntimeInvisibleParameterAnnotations_attribute.class);
    4.26 @@ -171,6 +173,7 @@
    4.27          R visitLineNumberTable(LineNumberTable_attribute attr, P p);
    4.28          R visitLocalVariableTable(LocalVariableTable_attribute attr, P p);
    4.29          R visitLocalVariableTypeTable(LocalVariableTypeTable_attribute attr, P p);
    4.30 +        R visitMethodParameters(MethodParameters_attribute attr, P p);
    4.31          R visitRuntimeVisibleAnnotations(RuntimeVisibleAnnotations_attribute attr, P p);
    4.32          R visitRuntimeInvisibleAnnotations(RuntimeInvisibleAnnotations_attribute attr, P p);
    4.33          R visitRuntimeVisibleParameterAnnotations(RuntimeVisibleParameterAnnotations_attribute attr, P p);
     5.1 --- a/src/share/classes/com/sun/tools/classfile/ClassWriter.java	Thu Jan 10 09:56:09 2013 -0800
     5.2 +++ b/src/share/classes/com/sun/tools/classfile/ClassWriter.java	Thu Jan 10 15:53:02 2013 -0800
     5.3 @@ -1,6 +1,6 @@
     5.4  
     5.5  /*
     5.6 - * Copyright (c) 2008, 2011, Oracle and/or its affiliates. All rights reserved.
     5.7 + * Copyright (c) 2008, 2012, Oracle and/or its affiliates. All rights reserved.
     5.8   * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
     5.9   *
    5.10   * This code is free software; you can redistribute it and/or modify it
    5.11 @@ -479,6 +479,15 @@
    5.12              out.writeShort(entry.index);
    5.13          }
    5.14  
    5.15 +        public Void visitMethodParameters(MethodParameters_attribute attr, ClassOutputStream out) {
    5.16 +            out.writeByte(attr.method_parameter_table.length);
    5.17 +            for (MethodParameters_attribute.Entry e : attr.method_parameter_table) {
    5.18 +                out.writeShort(e.name_index);
    5.19 +                out.writeInt(e.flags);
    5.20 +            }
    5.21 +            return null;
    5.22 +        }
    5.23 +
    5.24          public Void visitRuntimeVisibleAnnotations(RuntimeVisibleAnnotations_attribute attr, ClassOutputStream out) {
    5.25              annotationWriter.write(attr.annotations, out);
    5.26              return null;
     6.1 --- a/src/share/classes/com/sun/tools/classfile/Dependencies.java	Thu Jan 10 09:56:09 2013 -0800
     6.2 +++ b/src/share/classes/com/sun/tools/classfile/Dependencies.java	Thu Jan 10 15:53:02 2013 -0800
     6.3 @@ -142,6 +142,15 @@
     6.4      }
     6.5  
     6.6      /**
     6.7 +     * Get a finder to do class dependency analysis.
     6.8 +     *
     6.9 +     * @return a Class dependency finder
    6.10 +     */
    6.11 +    public static Finder getClassDependencyFinder() {
    6.12 +        return new ClassDependencyFinder();
    6.13 +    }
    6.14 +
    6.15 +    /**
    6.16       * Get the finder used to locate the dependencies for a class.
    6.17       * @return the finder
    6.18       */
    6.19 @@ -246,8 +255,6 @@
    6.20          return results;
    6.21      }
    6.22  
    6.23 -
    6.24 -
    6.25      /**
    6.26       * Find the dependencies of a class, using the current
    6.27       * {@link Dependencies#getFinder finder} and
    6.28 @@ -306,38 +313,44 @@
    6.29       * A location identifying a class.
    6.30       */
    6.31      static class SimpleLocation implements Location {
    6.32 -        public SimpleLocation(String className) {
    6.33 -            this.className = className;
    6.34 +        public SimpleLocation(String name) {
    6.35 +            this.name = name;
    6.36 +            this.className = name.replace('/', '.').replace('$', '.');
    6.37          }
    6.38  
    6.39 -        /**
    6.40 -         * Get the name of the class being depended on. This name will be used to
    6.41 -         * locate the class file for transitive dependency analysis.
    6.42 -         * @return the name of the class being depended on
    6.43 -         */
    6.44 +        public String getName() {
    6.45 +            return name;
    6.46 +        }
    6.47 +
    6.48          public String getClassName() {
    6.49              return className;
    6.50          }
    6.51  
    6.52 +        public String getPackageName() {
    6.53 +            int i = name.lastIndexOf('/');
    6.54 +            return (i > 0) ? name.substring(0, i).replace('/', '.') : "";
    6.55 +        }
    6.56 +
    6.57          @Override
    6.58          public boolean equals(Object other) {
    6.59              if (this == other)
    6.60                  return true;
    6.61              if (!(other instanceof SimpleLocation))
    6.62                  return false;
    6.63 -            return (className.equals(((SimpleLocation) other).className));
    6.64 +            return (name.equals(((SimpleLocation) other).name));
    6.65          }
    6.66  
    6.67          @Override
    6.68          public int hashCode() {
    6.69 -            return className.hashCode();
    6.70 +            return name.hashCode();
    6.71          }
    6.72  
    6.73          @Override
    6.74          public String toString() {
    6.75 -            return className;
    6.76 +            return name;
    6.77          }
    6.78  
    6.79 +        private String name;
    6.80          private String className;
    6.81      }
    6.82  
    6.83 @@ -431,9 +444,7 @@
    6.84          }
    6.85  
    6.86          public boolean accepts(Dependency dependency) {
    6.87 -            String cn = dependency.getTarget().getClassName();
    6.88 -            int lastSep = cn.lastIndexOf("/");
    6.89 -            String pn = (lastSep == -1 ? "" : cn.substring(0, lastSep));
    6.90 +            String pn = dependency.getTarget().getPackageName();
    6.91              if (packageNames.contains(pn))
    6.92                  return true;
    6.93  
    6.94 @@ -451,8 +462,6 @@
    6.95          private final boolean matchSubpackages;
    6.96      }
    6.97  
    6.98 -
    6.99 -
   6.100      /**
   6.101       * This class identifies class names directly or indirectly in the constant pool.
   6.102       */
   6.103 @@ -462,6 +471,26 @@
   6.104              for (CPInfo cpInfo: classfile.constant_pool.entries()) {
   6.105                  v.scan(cpInfo);
   6.106              }
   6.107 +            try {
   6.108 +                v.addClass(classfile.super_class);
   6.109 +                v.addClasses(classfile.interfaces);
   6.110 +                v.scan(classfile.attributes);
   6.111 +
   6.112 +                for (Field f : classfile.fields) {
   6.113 +                    v.scan(f.descriptor, f.attributes);
   6.114 +                }
   6.115 +                for (Method m : classfile.methods) {
   6.116 +                    v.scan(m.descriptor, m.attributes);
   6.117 +                    Exceptions_attribute e =
   6.118 +                        (Exceptions_attribute)m.attributes.get(Attribute.Exceptions);
   6.119 +                    if (e != null) {
   6.120 +                        v.addClasses(e.exception_index_table);
   6.121 +                    }
   6.122 +                }
   6.123 +            } catch (ConstantPoolException e) {
   6.124 +                throw new ClassFileError(e);
   6.125 +            }
   6.126 +
   6.127              return v.deps;
   6.128          }
   6.129      }
   6.130 @@ -558,9 +587,7 @@
   6.131              void scan(Descriptor d, Attributes attrs) {
   6.132                  try {
   6.133                      scan(new Signature(d.index).getType(constant_pool));
   6.134 -                    Signature_attribute sa = (Signature_attribute) attrs.get(Attribute.Signature);
   6.135 -                    if (sa != null)
   6.136 -                        scan(new Signature(sa.signature_index).getType(constant_pool));
   6.137 +                    scan(attrs);
   6.138                  } catch (ConstantPoolException e) {
   6.139                      throw new ClassFileError(e);
   6.140                  }
   6.141 @@ -574,6 +601,43 @@
   6.142                  t.accept(this, null);
   6.143              }
   6.144  
   6.145 +            void scan(Attributes attrs) {
   6.146 +                try {
   6.147 +                    Signature_attribute sa = (Signature_attribute)attrs.get(Attribute.Signature);
   6.148 +                    if (sa != null)
   6.149 +                        scan(sa.getParsedSignature().getType(constant_pool));
   6.150 +
   6.151 +                    scan((RuntimeVisibleAnnotations_attribute)
   6.152 +                            attrs.get(Attribute.RuntimeVisibleAnnotations));
   6.153 +                    scan((RuntimeVisibleParameterAnnotations_attribute)
   6.154 +                            attrs.get(Attribute.RuntimeVisibleParameterAnnotations));
   6.155 +                } catch (ConstantPoolException e) {
   6.156 +                    throw new ClassFileError(e);
   6.157 +                }
   6.158 +            }
   6.159 +
   6.160 +            private void scan(RuntimeAnnotations_attribute attr) throws ConstantPoolException {
   6.161 +                if (attr == null) {
   6.162 +                    return;
   6.163 +                }
   6.164 +                for (int i = 0; i < attr.annotations.length; i++) {
   6.165 +                    int index = attr.annotations[i].type_index;
   6.166 +                    scan(new Signature(index).getType(constant_pool));
   6.167 +                }
   6.168 +            }
   6.169 +
   6.170 +            private void scan(RuntimeParameterAnnotations_attribute attr) throws ConstantPoolException {
   6.171 +                if (attr == null) {
   6.172 +                    return;
   6.173 +                }
   6.174 +                for (int param = 0; param < attr.parameter_annotations.length; param++) {
   6.175 +                    for (int i = 0; i < attr.parameter_annotations[param].length; i++) {
   6.176 +                        int index = attr.parameter_annotations[param][i].type_index;
   6.177 +                        scan(new Signature(index).getType(constant_pool));
   6.178 +                    }
   6.179 +                }
   6.180 +            }
   6.181 +
   6.182              void addClass(int index) throws ConstantPoolException {
   6.183                  if (index != 0) {
   6.184                      String name = constant_pool.getClassInfo(index).getBaseName();
   6.185 @@ -698,6 +762,7 @@
   6.186                  findDependencies(type.paramTypes);
   6.187                  findDependencies(type.returnType);
   6.188                  findDependencies(type.throwsTypes);
   6.189 +                findDependencies(type.typeParamTypes);
   6.190                  return null;
   6.191              }
   6.192  
   6.193 @@ -709,7 +774,7 @@
   6.194  
   6.195              public Void visitClassType(ClassType type, Void p) {
   6.196                  findDependencies(type.outerType);
   6.197 -                addDependency(type.name);
   6.198 +                addDependency(type.getBinaryName());
   6.199                  findDependencies(type.typeArgs);
   6.200                  return null;
   6.201              }
     7.1 --- a/src/share/classes/com/sun/tools/classfile/Dependency.java	Thu Jan 10 09:56:09 2013 -0800
     7.2 +++ b/src/share/classes/com/sun/tools/classfile/Dependency.java	Thu Jan 10 15:53:02 2013 -0800
     7.3 @@ -71,7 +71,19 @@
     7.4           * dependency analysis.
     7.5           * @return the name of the class containing the location.
     7.6           */
     7.7 +        String getName();
     7.8 +
     7.9 +        /**
    7.10 +         * Get the fully-qualified name of the class containing the location.
    7.11 +         * @return the fully-qualified name of the class containing the location.
    7.12 +         */
    7.13          String getClassName();
    7.14 +
    7.15 +        /**
    7.16 +         * Get the package name of the class containing the location.
    7.17 +         * @return the package name of the class containing the location.
    7.18 +         */
    7.19 +        String getPackageName();
    7.20      }
    7.21  
    7.22  
     8.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
     8.2 +++ b/src/share/classes/com/sun/tools/classfile/MethodParameters_attribute.java	Thu Jan 10 15:53:02 2013 -0800
     8.3 @@ -0,0 +1,87 @@
     8.4 +/*
     8.5 + * Copyright (c) 2012, Oracle and/or its affiliates. All rights reserved.
     8.6 + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
     8.7 + *
     8.8 + * This code is free software; you can redistribute it and/or modify it
     8.9 + * under the terms of the GNU General Public License version 2 only, as
    8.10 + * published by the Free Software Foundation.  Oracle designates this
    8.11 + * particular file as subject to the "Classpath" exception as provided
    8.12 + * by Oracle in the LICENSE file that accompanied this code.
    8.13 + *
    8.14 + * This code is distributed in the hope that it will be useful, but WITHOUT
    8.15 + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
    8.16 + * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
    8.17 + * version 2 for more details (a copy is included in the LICENSE file that
    8.18 + * accompanied this code).
    8.19 + *
    8.20 + * You should have received a copy of the GNU General Public License version
    8.21 + * 2 along with this work; if not, write to the Free Software Foundation,
    8.22 + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
    8.23 + *
    8.24 + * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
    8.25 + * or visit www.oracle.com if you need additional information or have any
    8.26 + * questions.
    8.27 + */
    8.28 +
    8.29 +package com.sun.tools.classfile;
    8.30 +
    8.31 +import java.io.IOException;
    8.32 +
    8.33 +/**
    8.34 + * See JVMS, section 4.8.13.
    8.35 + *
    8.36 + *  <p><b>This is NOT part of any supported API.
    8.37 + *  If you write code that depends on this, you do so at your own risk.
    8.38 + *  This code and its internal interfaces are subject to change or
    8.39 + *  deletion without notice.</b>
    8.40 + */
    8.41 +public class MethodParameters_attribute extends Attribute {
    8.42 +
    8.43 +    public final int method_parameter_table_length;
    8.44 +    public final Entry[] method_parameter_table;
    8.45 +
    8.46 +    MethodParameters_attribute(ClassReader cr,
    8.47 +                              int name_index,
    8.48 +                              int length)
    8.49 +        throws IOException {
    8.50 +        super(name_index, length);
    8.51 +
    8.52 +        method_parameter_table_length = cr.readUnsignedByte();
    8.53 +        method_parameter_table = new Entry[method_parameter_table_length];
    8.54 +        for (int i = 0; i < method_parameter_table_length; i++)
    8.55 +            method_parameter_table[i] = new Entry(cr);
    8.56 +    }
    8.57 +
    8.58 +    public MethodParameters_attribute(ConstantPool constant_pool,
    8.59 +                                      Entry[] method_parameter_table)
    8.60 +        throws ConstantPoolException {
    8.61 +        this(constant_pool.getUTF8Index(Attribute.MethodParameters),
    8.62 +             method_parameter_table);
    8.63 +    }
    8.64 +
    8.65 +    public MethodParameters_attribute(int name_index,
    8.66 +                                      Entry[] method_parameter_table) {
    8.67 +        super(name_index, 1 + method_parameter_table.length * Entry.length());
    8.68 +        this.method_parameter_table_length = method_parameter_table.length;
    8.69 +        this.method_parameter_table = method_parameter_table;
    8.70 +    }
    8.71 +
    8.72 +    public <R, D> R accept(Visitor<R, D> visitor, D data) {
    8.73 +        return visitor.visitMethodParameters(this, data);
    8.74 +    }
    8.75 +
    8.76 +    public static class Entry {
    8.77 +        Entry(ClassReader cr) throws IOException {
    8.78 +            name_index = cr.readUnsignedShort();
    8.79 +            flags = cr.readInt();
    8.80 +        }
    8.81 +
    8.82 +        public static int length() {
    8.83 +            return 6;
    8.84 +        }
    8.85 +
    8.86 +        public final int name_index;
    8.87 +        public final int flags;
    8.88 +    }
    8.89 +
    8.90 +}
     9.1 --- a/src/share/classes/com/sun/tools/doclets/formats/html/AbstractMemberWriter.java	Thu Jan 10 09:56:09 2013 -0800
     9.2 +++ b/src/share/classes/com/sun/tools/doclets/formats/html/AbstractMemberWriter.java	Thu Jan 10 15:53:02 2013 -0800
     9.3 @@ -321,7 +321,8 @@
     9.4              code.addContent(" ");
     9.5          }
     9.6          if (member.isMethod()) {
     9.7 -            if (((MethodDoc)member).isAbstract()) {
     9.8 +            if (!(member.containingClass().isInterface()) &&
     9.9 +                    ((MethodDoc)member).isAbstract()) {
    9.10                  code.addContent("abstract ");
    9.11              }
    9.12              // This check for isDefault() and the default modifier needs to be
    9.13 @@ -329,7 +330,7 @@
    9.14              // method summary section. Once the default modifier is added
    9.15              // to the Modifier list on DocEnv and once it is updated to use the
    9.16              // javax.lang.model.element.Modifier, we will need to remove this.
    9.17 -            else if (((MethodDoc)member).isDefault()) {
    9.18 +            if (((MethodDoc)member).isDefault()) {
    9.19                  code.addContent("default ");
    9.20              }
    9.21          }
    9.22 @@ -561,11 +562,14 @@
    9.23          if (member instanceof MethodDoc && !member.isAnnotationTypeElement()) {
    9.24              int methodType = (member.isStatic()) ? MethodTypes.STATIC.value() :
    9.25                      MethodTypes.INSTANCE.value();
    9.26 -            methodType = (classdoc.isInterface() || ((MethodDoc)member).isAbstract()) ?
    9.27 -                    methodType | MethodTypes.ABSTRACT.value() :
    9.28 -                    methodType | MethodTypes.CONCRETE.value();
    9.29 -            if (((MethodDoc)member).isDefault()) {
    9.30 -                methodType = methodType | MethodTypes.DEFAULT.value();
    9.31 +            if (member.containingClass().isInterface()) {
    9.32 +                methodType = (((MethodDoc) member).isAbstract())
    9.33 +                        ? methodType | MethodTypes.ABSTRACT.value()
    9.34 +                        : methodType | MethodTypes.DEFAULT.value();
    9.35 +            } else {
    9.36 +                methodType = (((MethodDoc) member).isAbstract())
    9.37 +                        ? methodType | MethodTypes.ABSTRACT.value()
    9.38 +                        : methodType | MethodTypes.CONCRETE.value();
    9.39              }
    9.40              if (Util.isDeprecated(member) || Util.isDeprecated(classdoc)) {
    9.41                  methodType = methodType | MethodTypes.DEPRECATED.value();
    10.1 --- a/src/share/classes/com/sun/tools/doclets/formats/html/HtmlDocletWriter.java	Thu Jan 10 09:56:09 2013 -0800
    10.2 +++ b/src/share/classes/com/sun/tools/doclets/formats/html/HtmlDocletWriter.java	Thu Jan 10 15:53:02 2013 -0800
    10.3 @@ -90,6 +90,16 @@
    10.4      protected boolean printedAnnotationHeading = false;
    10.5  
    10.6      /**
    10.7 +     * To check whether the repeated annotations is documented or not.
    10.8 +     */
    10.9 +    private boolean isAnnotationDocumented = false;
   10.10 +
   10.11 +    /**
   10.12 +     * To check whether the container annotations is documented or not.
   10.13 +     */
   10.14 +    private boolean isContainerDocumented = false;
   10.15 +
   10.16 +    /**
   10.17       * Constructor to construct the HtmlStandardWriter object.
   10.18       *
   10.19       * @param path File to be generated.
   10.20 @@ -1793,50 +1803,66 @@
   10.21          StringBuilder annotation;
   10.22          for (int i = 0; i < descList.length; i++) {
   10.23              AnnotationTypeDoc annotationDoc = descList[i].annotationType();
   10.24 -            if (! Util.isDocumentedAnnotation(annotationDoc)){
   10.25 +            // If an annotation is not documented, do not add it to the list. If
   10.26 +            // the annotation is of a repeatable type, and if it is not documented
   10.27 +            // and also if its container annotation is not documented, do not add it
   10.28 +            // to the list. If an annotation of a repeatable type is not documented
   10.29 +            // but its container is documented, it will be added to the list.
   10.30 +            if (! Util.isDocumentedAnnotation(annotationDoc) &&
   10.31 +                    (!isAnnotationDocumented && !isContainerDocumented)) {
   10.32                  continue;
   10.33              }
   10.34              annotation = new StringBuilder();
   10.35 +            isAnnotationDocumented = false;
   10.36              LinkInfoImpl linkInfo = new LinkInfoImpl(configuration,
   10.37                  LinkInfoImpl.CONTEXT_ANNOTATION, annotationDoc);
   10.38 -            linkInfo.label = "@" + annotationDoc.name();
   10.39 -            annotation.append(getLink(linkInfo));
   10.40              AnnotationDesc.ElementValuePair[] pairs = descList[i].elementValues();
   10.41 -            if (pairs.length > 0) {
   10.42 -                annotation.append('(');
   10.43 +            // If the annotation is synthesized, do not print the container.
   10.44 +            if (descList[i].isSynthesized()) {
   10.45                  for (int j = 0; j < pairs.length; j++) {
   10.46 -                    if (j > 0) {
   10.47 -                        annotation.append(",");
   10.48 -                        if (linkBreak) {
   10.49 -                            annotation.append(DocletConstants.NL);
   10.50 -                            int spaces = annotationDoc.name().length() + 2;
   10.51 -                            for (int k = 0; k < (spaces + indent); k++) {
   10.52 -                                annotation.append(' ');
   10.53 -                            }
   10.54 -                        }
   10.55 -                    }
   10.56 -                    annotation.append(getDocLink(LinkInfoImpl.CONTEXT_ANNOTATION,
   10.57 -                        pairs[j].element(), pairs[j].element().name(), false));
   10.58 -                    annotation.append('=');
   10.59                      AnnotationValue annotationValue = pairs[j].value();
   10.60                      List<AnnotationValue> annotationTypeValues = new ArrayList<AnnotationValue>();
   10.61                      if (annotationValue.value() instanceof AnnotationValue[]) {
   10.62                          AnnotationValue[] annotationArray =
   10.63 -                            (AnnotationValue[]) annotationValue.value();
   10.64 -                        for (int k = 0; k < annotationArray.length; k++) {
   10.65 -                            annotationTypeValues.add(annotationArray[k]);
   10.66 -                        }
   10.67 +                                (AnnotationValue[]) annotationValue.value();
   10.68 +                        annotationTypeValues.addAll(Arrays.asList(annotationArray));
   10.69                      } else {
   10.70                          annotationTypeValues.add(annotationValue);
   10.71                      }
   10.72 -                    annotation.append(annotationTypeValues.size() == 1 ? "" : "{");
   10.73 -                    for (Iterator<AnnotationValue> iter = annotationTypeValues.iterator(); iter.hasNext(); ) {
   10.74 -                        annotation.append(annotationValueToString(iter.next()));
   10.75 -                        annotation.append(iter.hasNext() ? "," : "");
   10.76 +                    String sep = "";
   10.77 +                    for (AnnotationValue av : annotationTypeValues) {
   10.78 +                        annotation.append(sep);
   10.79 +                        annotation.append(annotationValueToString(av));
   10.80 +                        sep = " ";
   10.81                      }
   10.82 -                    annotation.append(annotationTypeValues.size() == 1 ? "" : "}");
   10.83                  }
   10.84 -                annotation.append(")");
   10.85 +            }
   10.86 +            else if (isAnnotationArray(pairs)) {
   10.87 +                // If the container has 1 or more value defined and if the
   10.88 +                // repeatable type annotation is not documented, do not print
   10.89 +                // the container.
   10.90 +                if (pairs.length == 1 && isAnnotationDocumented) {
   10.91 +                    AnnotationValue[] annotationArray =
   10.92 +                            (AnnotationValue[]) (pairs[0].value()).value();
   10.93 +                    List<AnnotationValue> annotationTypeValues = new ArrayList<AnnotationValue>();
   10.94 +                    annotationTypeValues.addAll(Arrays.asList(annotationArray));
   10.95 +                    String sep = "";
   10.96 +                    for (AnnotationValue av : annotationTypeValues) {
   10.97 +                        annotation.append(sep);
   10.98 +                        annotation.append(annotationValueToString(av));
   10.99 +                        sep = " ";
  10.100 +                    }
  10.101 +                }
  10.102 +                // If the container has 1 or more value defined and if the
  10.103 +                // repeatable type annotation is not documented, print the container.
  10.104 +                else {
  10.105 +                    addAnnotations(annotationDoc, linkInfo, annotation, pairs,
  10.106 +                        indent, false);
  10.107 +                }
  10.108 +            }
  10.109 +            else {
  10.110 +                addAnnotations(annotationDoc, linkInfo, annotation, pairs,
  10.111 +                        indent, linkBreak);
  10.112              }
  10.113              annotation.append(linkBreak ? DocletConstants.NL : "");
  10.114              results.add(annotation.toString());
  10.115 @@ -1844,6 +1870,91 @@
  10.116          return results;
  10.117      }
  10.118  
  10.119 +    /**
  10.120 +     * Add annotation to the annotation string.
  10.121 +     *
  10.122 +     * @param annotationDoc the annotation being documented
  10.123 +     * @param linkInfo the information about the link
  10.124 +     * @param annotation the annotation string to which the annotation will be added
  10.125 +     * @param pairs annotation type element and value pairs
  10.126 +     * @param indent the number of extra spaces to indent the annotations.
  10.127 +     * @param linkBreak if true, add new line between each member value
  10.128 +     */
  10.129 +    private void addAnnotations(AnnotationTypeDoc annotationDoc, LinkInfoImpl linkInfo,
  10.130 +            StringBuilder annotation, AnnotationDesc.ElementValuePair[] pairs,
  10.131 +            int indent, boolean linkBreak) {
  10.132 +        linkInfo.label = "@" + annotationDoc.name();
  10.133 +        annotation.append(getLink(linkInfo));
  10.134 +        if (pairs.length > 0) {
  10.135 +            annotation.append('(');
  10.136 +            for (int j = 0; j < pairs.length; j++) {
  10.137 +                if (j > 0) {
  10.138 +                    annotation.append(",");
  10.139 +                    if (linkBreak) {
  10.140 +                        annotation.append(DocletConstants.NL);
  10.141 +                        int spaces = annotationDoc.name().length() + 2;
  10.142 +                        for (int k = 0; k < (spaces + indent); k++) {
  10.143 +                            annotation.append(' ');
  10.144 +                        }
  10.145 +                    }
  10.146 +                }
  10.147 +                annotation.append(getDocLink(LinkInfoImpl.CONTEXT_ANNOTATION,
  10.148 +                        pairs[j].element(), pairs[j].element().name(), false));
  10.149 +                annotation.append('=');
  10.150 +                AnnotationValue annotationValue = pairs[j].value();
  10.151 +                List<AnnotationValue> annotationTypeValues = new ArrayList<AnnotationValue>();
  10.152 +                if (annotationValue.value() instanceof AnnotationValue[]) {
  10.153 +                    AnnotationValue[] annotationArray =
  10.154 +                            (AnnotationValue[]) annotationValue.value();
  10.155 +                    annotationTypeValues.addAll(Arrays.asList(annotationArray));
  10.156 +                } else {
  10.157 +                    annotationTypeValues.add(annotationValue);
  10.158 +                }
  10.159 +                annotation.append(annotationTypeValues.size() == 1 ? "" : "{");
  10.160 +                String sep = "";
  10.161 +                for (AnnotationValue av : annotationTypeValues) {
  10.162 +                    annotation.append(sep);
  10.163 +                    annotation.append(annotationValueToString(av));
  10.164 +                    sep = ",";
  10.165 +                }
  10.166 +                annotation.append(annotationTypeValues.size() == 1 ? "" : "}");
  10.167 +                isContainerDocumented = false;
  10.168 +            }
  10.169 +            annotation.append(")");
  10.170 +        }
  10.171 +    }
  10.172 +
  10.173 +    /**
  10.174 +     * Check if the annotation contains an array of annotation as a value. This
  10.175 +     * check is to verify if a repeatable type annotation is present or not.
  10.176 +     *
  10.177 +     * @param pairs annotation type element and value pairs
  10.178 +     *
  10.179 +     * @return true if the annotation contains an array of annotation as a value.
  10.180 +     */
  10.181 +    private boolean isAnnotationArray(AnnotationDesc.ElementValuePair[] pairs) {
  10.182 +        AnnotationValue annotationValue;
  10.183 +        for (int j = 0; j < pairs.length; j++) {
  10.184 +            annotationValue = pairs[j].value();
  10.185 +            if (annotationValue.value() instanceof AnnotationValue[]) {
  10.186 +                AnnotationValue[] annotationArray =
  10.187 +                        (AnnotationValue[]) annotationValue.value();
  10.188 +                if (annotationArray.length > 1) {
  10.189 +                    if (annotationArray[0].value() instanceof AnnotationDesc) {
  10.190 +                        AnnotationTypeDoc annotationDoc =
  10.191 +                                ((AnnotationDesc) annotationArray[0].value()).annotationType();
  10.192 +                        isContainerDocumented = true;
  10.193 +                        if (Util.isDocumentedAnnotation(annotationDoc)) {
  10.194 +                            isAnnotationDocumented = true;
  10.195 +                        }
  10.196 +                        return true;
  10.197 +                    }
  10.198 +                }
  10.199 +            }
  10.200 +        }
  10.201 +        return false;
  10.202 +    }
  10.203 +
  10.204      private String annotationValueToString(AnnotationValue annotationValue) {
  10.205          if (annotationValue.value() instanceof Type) {
  10.206              Type type = (Type) annotationValue.value();
    11.1 --- a/src/share/classes/com/sun/tools/javac/code/Symbol.java	Thu Jan 10 09:56:09 2013 -0800
    11.2 +++ b/src/share/classes/com/sun/tools/javac/code/Symbol.java	Thu Jan 10 15:53:02 2013 -0800
    11.3 @@ -1283,8 +1283,9 @@
    11.4                  List<Name> paramNames = savedParameterNames;
    11.5                  savedParameterNames = null;
    11.6                  // discard the provided names if the list of names is the wrong size.
    11.7 -                if (paramNames == null || paramNames.size() != type.getParameterTypes().size())
    11.8 +                if (paramNames == null || paramNames.size() != type.getParameterTypes().size()) {
    11.9                      paramNames = List.nil();
   11.10 +                }
   11.11                  ListBuffer<VarSymbol> buf = new ListBuffer<VarSymbol>();
   11.12                  List<Name> remaining = paramNames;
   11.13                  // assert: remaining and paramNames are both empty or both
    12.1 --- a/src/share/classes/com/sun/tools/javac/comp/DeferredAttr.java	Thu Jan 10 09:56:09 2013 -0800
    12.2 +++ b/src/share/classes/com/sun/tools/javac/comp/DeferredAttr.java	Thu Jan 10 15:53:02 2013 -0800
    12.3 @@ -38,6 +38,7 @@
    12.4  import javax.tools.JavaFileObject;
    12.5  
    12.6  import java.util.ArrayList;
    12.7 +import java.util.EnumSet;
    12.8  import java.util.LinkedHashSet;
    12.9  import java.util.Map;
   12.10  import java.util.Queue;
   12.11 @@ -177,29 +178,19 @@
   12.12           * attribution round must follow one or more speculative rounds.
   12.13           */
   12.14          Type check(ResultInfo resultInfo) {
   12.15 +            return check(resultInfo, stuckVars(tree, env, resultInfo), basicCompleter);
   12.16 +        }
   12.17 +
   12.18 +        Type check(ResultInfo resultInfo, List<Type> stuckVars, DeferredTypeCompleter deferredTypeCompleter) {
   12.19              DeferredAttrContext deferredAttrContext =
   12.20                      resultInfo.checkContext.deferredAttrContext();
   12.21              Assert.check(deferredAttrContext != emptyDeferredAttrContext);
   12.22 -            List<Type> stuckVars = stuckVars(tree, env, resultInfo);
   12.23              if (stuckVars.nonEmpty()) {
   12.24                  deferredAttrContext.addDeferredAttrNode(this, resultInfo, stuckVars);
   12.25                  return Type.noType;
   12.26              } else {
   12.27                  try {
   12.28 -                    switch (deferredAttrContext.mode) {
   12.29 -                        case SPECULATIVE:
   12.30 -                            Assert.check(mode == null ||
   12.31 -                                    (mode == AttrMode.SPECULATIVE &&
   12.32 -                                    speculativeType(deferredAttrContext.msym, deferredAttrContext.phase).hasTag(NONE)));
   12.33 -                            JCTree speculativeTree = attribSpeculative(tree, env, resultInfo);
   12.34 -                            speculativeCache.put(deferredAttrContext.msym, speculativeTree, deferredAttrContext.phase);
   12.35 -                            return speculativeTree.type;
   12.36 -                        case CHECK:
   12.37 -                            Assert.check(mode == AttrMode.SPECULATIVE);
   12.38 -                            return attr.attribTree(tree, env, resultInfo);
   12.39 -                    }
   12.40 -                    Assert.error();
   12.41 -                    return null;
   12.42 +                    return deferredTypeCompleter.complete(this, resultInfo, deferredAttrContext);
   12.43                  } finally {
   12.44                      mode = deferredAttrContext.mode;
   12.45                  }
   12.46 @@ -208,6 +199,43 @@
   12.47      }
   12.48  
   12.49      /**
   12.50 +     * A completer for deferred types. Defines an entry point for type-checking
   12.51 +     * a deferred type.
   12.52 +     */
   12.53 +    interface DeferredTypeCompleter {
   12.54 +        /**
   12.55 +         * Entry point for type-checking a deferred type. Depending on the
   12.56 +         * circumstances, type-checking could amount to full attribution
   12.57 +         * or partial structural check (aka potential applicability).
   12.58 +         */
   12.59 +        Type complete(DeferredType dt, ResultInfo resultInfo, DeferredAttrContext deferredAttrContext);
   12.60 +    }
   12.61 +
   12.62 +    /**
   12.63 +     * A basic completer for deferred types. This completer type-checks a deferred type
   12.64 +     * using attribution; depending on the attribution mode, this could be either standard
   12.65 +     * or speculative attribution.
   12.66 +     */
   12.67 +    DeferredTypeCompleter basicCompleter = new DeferredTypeCompleter() {
   12.68 +        public Type complete(DeferredType dt, ResultInfo resultInfo, DeferredAttrContext deferredAttrContext) {
   12.69 +            switch (deferredAttrContext.mode) {
   12.70 +                case SPECULATIVE:
   12.71 +                    Assert.check(dt.mode == null ||
   12.72 +                            (dt.mode == AttrMode.SPECULATIVE &&
   12.73 +                            dt.speculativeType(deferredAttrContext.msym, deferredAttrContext.phase).hasTag(NONE)));
   12.74 +                    JCTree speculativeTree = attribSpeculative(dt.tree, dt.env, resultInfo);
   12.75 +                    dt.speculativeCache.put(deferredAttrContext.msym, speculativeTree, deferredAttrContext.phase);
   12.76 +                    return speculativeTree.type;
   12.77 +                case CHECK:
   12.78 +                    Assert.check(dt.mode == AttrMode.SPECULATIVE);
   12.79 +                    return attr.attribTree(dt.tree, dt.env, resultInfo);
   12.80 +            }
   12.81 +            Assert.error();
   12.82 +            return null;
   12.83 +        }
   12.84 +    };
   12.85 +
   12.86 +    /**
   12.87       * The 'mode' in which the deferred type is to be type-checked
   12.88       */
   12.89      public enum AttrMode {
   12.90 @@ -498,10 +526,80 @@
   12.91                  if (resultInfo.pt.hasTag(NONE) || resultInfo.pt.isErroneous()) {
   12.92              return List.nil();
   12.93          } else {
   12.94 -            StuckChecker sc = new StuckChecker(resultInfo, env);
   12.95 +            return stuckVarsInternal(tree, resultInfo.pt, resultInfo.checkContext.inferenceContext());
   12.96 +        }
   12.97 +    }
   12.98 +    //where
   12.99 +        private List<Type> stuckVarsInternal(JCTree tree, Type pt, Infer.InferenceContext inferenceContext) {
  12.100 +            StuckChecker sc = new StuckChecker(pt, inferenceContext);
  12.101              sc.scan(tree);
  12.102              return List.from(sc.stuckVars);
  12.103          }
  12.104 +
  12.105 +    /**
  12.106 +     * A special tree scanner that would only visit portions of a given tree.
  12.107 +     * The set of nodes visited by the scanner can be customized at construction-time.
  12.108 +     */
  12.109 +    abstract static class FilterScanner extends TreeScanner {
  12.110 +
  12.111 +        final Filter<JCTree> treeFilter;
  12.112 +
  12.113 +        FilterScanner(final Set<JCTree.Tag> validTags) {
  12.114 +            this.treeFilter = new Filter<JCTree>() {
  12.115 +                public boolean accepts(JCTree t) {
  12.116 +                    return validTags.contains(t.getTag());
  12.117 +                }
  12.118 +            };
  12.119 +        }
  12.120 +
  12.121 +        @Override
  12.122 +        public void scan(JCTree tree) {
  12.123 +            if (tree != null) {
  12.124 +                if (treeFilter.accepts(tree)) {
  12.125 +                    super.scan(tree);
  12.126 +                } else {
  12.127 +                    skip(tree);
  12.128 +                }
  12.129 +            }
  12.130 +        }
  12.131 +
  12.132 +        /**
  12.133 +         * handler that is executed when a node has been discarded
  12.134 +         */
  12.135 +        abstract void skip(JCTree tree);
  12.136 +    }
  12.137 +
  12.138 +    /**
  12.139 +     * A tree scanner suitable for visiting the target-type dependent nodes of
  12.140 +     * a given argument expression.
  12.141 +     */
  12.142 +    static class PolyScanner extends FilterScanner {
  12.143 +
  12.144 +        PolyScanner() {
  12.145 +            super(EnumSet.of(CONDEXPR, PARENS, LAMBDA, REFERENCE));
  12.146 +        }
  12.147 +
  12.148 +        @Override
  12.149 +        void skip(JCTree tree) {
  12.150 +            //do nothing
  12.151 +        }
  12.152 +    }
  12.153 +
  12.154 +    /**
  12.155 +     * A tree scanner suitable for visiting the target-type dependent nodes nested
  12.156 +     * within a lambda expression body.
  12.157 +     */
  12.158 +    static class LambdaReturnScanner extends FilterScanner {
  12.159 +
  12.160 +        LambdaReturnScanner() {
  12.161 +            super(EnumSet.of(BLOCK, CASE, CATCH, DOLOOP, FOREACHLOOP,
  12.162 +                    FORLOOP, RETURN, SYNCHRONIZED, SWITCH, TRY, WHILELOOP));
  12.163 +        }
  12.164 +
  12.165 +        @Override
  12.166 +        void skip(JCTree tree) {
  12.167 +            //do nothing
  12.168 +        }
  12.169      }
  12.170  
  12.171      /**
  12.172 @@ -510,83 +608,32 @@
  12.173       * inferring types that make some of the nested expressions incompatible
  12.174       * with their corresponding instantiated target
  12.175       */
  12.176 -    class StuckChecker extends TreeScanner {
  12.177 +    class StuckChecker extends PolyScanner {
  12.178  
  12.179          Type pt;
  12.180 -        Filter<JCTree> treeFilter;
  12.181          Infer.InferenceContext inferenceContext;
  12.182          Set<Type> stuckVars = new LinkedHashSet<Type>();
  12.183 -        Env<AttrContext> env;
  12.184  
  12.185 -        final Filter<JCTree> argsFilter = new Filter<JCTree>() {
  12.186 -            public boolean accepts(JCTree t) {
  12.187 -                switch (t.getTag()) {
  12.188 -                    case CONDEXPR:
  12.189 -                    case LAMBDA:
  12.190 -                    case PARENS:
  12.191 -                    case REFERENCE:
  12.192 -                        return true;
  12.193 -                    default:
  12.194 -                        return false;
  12.195 -                }
  12.196 -            }
  12.197 -        };
  12.198 -
  12.199 -        final Filter<JCTree> lambdaBodyFilter = new Filter<JCTree>() {
  12.200 -            public boolean accepts(JCTree t) {
  12.201 -                switch (t.getTag()) {
  12.202 -                    case BLOCK: case CASE: case CATCH: case DOLOOP:
  12.203 -                    case FOREACHLOOP: case FORLOOP: case RETURN:
  12.204 -                    case SYNCHRONIZED: case SWITCH: case TRY: case WHILELOOP:
  12.205 -                        return true;
  12.206 -                    default:
  12.207 -                        return false;
  12.208 -                }
  12.209 -            }
  12.210 -        };
  12.211 -
  12.212 -        StuckChecker(ResultInfo resultInfo, Env<AttrContext> env) {
  12.213 -            this.pt = resultInfo.pt;
  12.214 -            this.inferenceContext = resultInfo.checkContext.inferenceContext();
  12.215 -            this.treeFilter = argsFilter;
  12.216 -            this.env = env;
  12.217 -        }
  12.218 -
  12.219 -        @Override
  12.220 -        public void scan(JCTree tree) {
  12.221 -            if (tree != null && treeFilter.accepts(tree)) {
  12.222 -                super.scan(tree);
  12.223 -            }
  12.224 +        StuckChecker(Type pt, Infer.InferenceContext inferenceContext) {
  12.225 +            this.pt = pt;
  12.226 +            this.inferenceContext = inferenceContext;
  12.227          }
  12.228  
  12.229          @Override
  12.230          public void visitLambda(JCLambda tree) {
  12.231 -            Type prevPt = pt;
  12.232 -            Filter<JCTree> prevFilter = treeFilter;
  12.233 -            try {
  12.234 -                if (inferenceContext.inferenceVars().contains(pt)) {
  12.235 -                    stuckVars.add(pt);
  12.236 -                }
  12.237 -                if (!types.isFunctionalInterface(pt.tsym)) {
  12.238 -                    return;
  12.239 -                }
  12.240 -                Type descType = types.findDescriptorType(pt);
  12.241 -                List<Type> freeArgVars = inferenceContext.freeVarsIn(descType.getParameterTypes());
  12.242 -                if (!TreeInfo.isExplicitLambda(tree) &&
  12.243 -                        freeArgVars.nonEmpty()) {
  12.244 -                    stuckVars.addAll(freeArgVars);
  12.245 -                }
  12.246 -                pt = descType.getReturnType();
  12.247 -                if (tree.getBodyKind() == JCTree.JCLambda.BodyKind.EXPRESSION) {
  12.248 -                    scan(tree.getBody());
  12.249 -                } else {
  12.250 -                    treeFilter = lambdaBodyFilter;
  12.251 -                    super.visitLambda(tree);
  12.252 -                }
  12.253 -            } finally {
  12.254 -                pt = prevPt;
  12.255 -                treeFilter = prevFilter;
  12.256 +            if (inferenceContext.inferenceVars().contains(pt)) {
  12.257 +                stuckVars.add(pt);
  12.258              }
  12.259 +            if (!types.isFunctionalInterface(pt.tsym)) {
  12.260 +                return;
  12.261 +            }
  12.262 +            Type descType = types.findDescriptorType(pt);
  12.263 +            List<Type> freeArgVars = inferenceContext.freeVarsIn(descType.getParameterTypes());
  12.264 +            if (!TreeInfo.isExplicitLambda(tree) &&
  12.265 +                    freeArgVars.nonEmpty()) {
  12.266 +                stuckVars.addAll(freeArgVars);
  12.267 +            }
  12.268 +            scanLambdaBody(tree, descType.getReturnType());
  12.269          }
  12.270  
  12.271          @Override
  12.272 @@ -605,16 +652,19 @@
  12.273              stuckVars.addAll(freeArgVars);
  12.274          }
  12.275  
  12.276 -        @Override
  12.277 -        public void visitReturn(JCReturn tree) {
  12.278 -            Filter<JCTree> prevFilter = treeFilter;
  12.279 -            try {
  12.280 -                treeFilter = argsFilter;
  12.281 -                if (tree.expr != null) {
  12.282 -                    scan(tree.expr);
  12.283 -                }
  12.284 -            } finally {
  12.285 -                treeFilter = prevFilter;
  12.286 +        void scanLambdaBody(JCLambda lambda, final Type pt) {
  12.287 +            if (lambda.getBodyKind() == JCTree.JCLambda.BodyKind.EXPRESSION) {
  12.288 +                stuckVars.addAll(stuckVarsInternal(lambda.body, pt, inferenceContext));
  12.289 +            } else {
  12.290 +                LambdaReturnScanner lambdaScanner = new LambdaReturnScanner() {
  12.291 +                    @Override
  12.292 +                    public void visitReturn(JCReturn tree) {
  12.293 +                        if (tree.expr != null) {
  12.294 +                            stuckVars.addAll(stuckVarsInternal(tree.expr, pt, inferenceContext));
  12.295 +                        }
  12.296 +                    }
  12.297 +                };
  12.298 +                lambdaScanner.scan(lambda.body);
  12.299              }
  12.300          }
  12.301      }
    13.1 --- a/src/share/classes/com/sun/tools/javac/comp/Infer.java	Thu Jan 10 09:56:09 2013 -0800
    13.2 +++ b/src/share/classes/com/sun/tools/javac/comp/Infer.java	Thu Jan 10 15:53:02 2013 -0800
    13.3 @@ -114,7 +114,7 @@
    13.4          }
    13.5      }
    13.6  
    13.7 -    private final InferenceException inferenceException;
    13.8 +    final InferenceException inferenceException;
    13.9  
   13.10  /***************************************************************************
   13.11   * Mini/Maximization of UndetVars
   13.12 @@ -271,15 +271,19 @@
   13.13                                    boolean allowBoxing,
   13.14                                    boolean useVarargs,
   13.15                                    Resolve.MethodResolutionContext resolveContext,
   13.16 +                                  Resolve.MethodCheck methodCheck,
   13.17                                    Warner warn) throws InferenceException {
   13.18          //-System.err.println("instantiateMethod(" + tvars + ", " + mt + ", " + argtypes + ")"); //DEBUG
   13.19          final InferenceContext inferenceContext = new InferenceContext(tvars, this, true);
   13.20          inferenceException.clear();
   13.21  
   13.22 +        DeferredAttr.DeferredAttrContext deferredAttrContext =
   13.23 +                resolveContext.deferredAttrContext(msym, inferenceContext);
   13.24 +
   13.25          try {
   13.26 -            rs.checkRawArgumentsAcceptable(env, msym, resolveContext.attrMode(), inferenceContext,
   13.27 -                    argtypes, mt.getParameterTypes(), allowBoxing, useVarargs, warn,
   13.28 -                    new InferenceCheckHandler(inferenceContext));
   13.29 +            methodCheck.argumentsAcceptable(env, deferredAttrContext, argtypes, mt.getParameterTypes(), warn);
   13.30 +
   13.31 +            deferredAttrContext.complete();
   13.32  
   13.33              // minimize as yet undetermined type variables
   13.34              for (Type t : inferenceContext.undetvars) {
   13.35 @@ -309,32 +313,6 @@
   13.36              inferenceContext.notifyChange(types);
   13.37          }
   13.38      }
   13.39 -    //where
   13.40 -
   13.41 -        /** inference check handler **/
   13.42 -        class InferenceCheckHandler implements Resolve.MethodCheckHandler {
   13.43 -
   13.44 -            InferenceContext inferenceContext;
   13.45 -
   13.46 -            public InferenceCheckHandler(InferenceContext inferenceContext) {
   13.47 -                this.inferenceContext = inferenceContext;
   13.48 -            }
   13.49 -
   13.50 -            public InapplicableMethodException arityMismatch() {
   13.51 -                return inferenceException.setMessage("infer.arg.length.mismatch", inferenceContext.inferenceVars());
   13.52 -            }
   13.53 -            public InapplicableMethodException argumentMismatch(boolean varargs, JCDiagnostic details) {
   13.54 -                String key = varargs ?
   13.55 -                        "infer.varargs.argument.mismatch" :
   13.56 -                        "infer.no.conforming.assignment.exists";
   13.57 -                return inferenceException.setMessage(key,
   13.58 -                        inferenceContext.inferenceVars(), details);
   13.59 -            }
   13.60 -            public InapplicableMethodException inaccessibleVarargs(Symbol location, Type expected) {
   13.61 -                return inferenceException.setMessage("inaccessible.varargs.type",
   13.62 -                        expected, Kinds.kindName(location), location);
   13.63 -            }
   13.64 -        }
   13.65  
   13.66      /** check that type parameters are within their bounds.
   13.67       */
    14.1 --- a/src/share/classes/com/sun/tools/javac/comp/Resolve.java	Thu Jan 10 09:56:09 2013 -0800
    14.2 +++ b/src/share/classes/com/sun/tools/javac/comp/Resolve.java	Thu Jan 10 15:53:02 2013 -0800
    14.3 @@ -506,6 +506,7 @@
    14.4                          List<Type> typeargtypes,
    14.5                          boolean allowBoxing,
    14.6                          boolean useVarargs,
    14.7 +                        MethodCheck methodCheck,
    14.8                          Warner warn) throws Infer.InferenceException {
    14.9  
   14.10          Type mt = types.memberType(site, m);
   14.11 @@ -558,10 +559,11 @@
   14.12                                      allowBoxing,
   14.13                                      useVarargs,
   14.14                                      currentResolutionContext,
   14.15 +                                    methodCheck,
   14.16                                      warn);
   14.17  
   14.18 -        checkRawArgumentsAcceptable(env, m, argtypes, mt.getParameterTypes(),
   14.19 -                                allowBoxing, useVarargs, warn);
   14.20 +        methodCheck.argumentsAcceptable(env, currentResolutionContext.deferredAttrContext(m, infer.emptyContext),
   14.21 +                                argtypes, mt.getParameterTypes(), warn);
   14.22          return mt;
   14.23      }
   14.24  
   14.25 @@ -578,7 +580,7 @@
   14.26              currentResolutionContext.attrMode = DeferredAttr.AttrMode.CHECK;
   14.27              MethodResolutionPhase step = currentResolutionContext.step = env.info.pendingResolutionPhase;
   14.28              return rawInstantiate(env, site, m, resultInfo, argtypes, typeargtypes,
   14.29 -                    step.isBoxingRequired(), step.isVarargsRequired(), warn);
   14.30 +                    step.isBoxingRequired(), step.isVarargsRequired(), resolveMethodCheck, warn);
   14.31          }
   14.32          finally {
   14.33              currentResolutionContext = prevContext;
   14.34 @@ -595,81 +597,66 @@
   14.35                       List<Type> typeargtypes,
   14.36                       boolean allowBoxing,
   14.37                       boolean useVarargs,
   14.38 +                     MethodCheck methodCheck,
   14.39                       Warner warn) {
   14.40          try {
   14.41              return rawInstantiate(env, site, m, resultInfo, argtypes, typeargtypes,
   14.42 -                                  allowBoxing, useVarargs, warn);
   14.43 +                                  allowBoxing, useVarargs, methodCheck, warn);
   14.44          } catch (InapplicableMethodException ex) {
   14.45              return null;
   14.46          }
   14.47      }
   14.48  
   14.49 -    /** Check if a parameter list accepts a list of args.
   14.50 +    /**
   14.51 +     * This interface defines an entry point that should be used to perform a
   14.52 +     * method check. A method check usually consist in determining as to whether
   14.53 +     * a set of types (actuals) is compatible with another set of types (formals).
   14.54 +     * Since the notion of compatibility can vary depending on the circumstances,
   14.55 +     * this interfaces allows to easily add new pluggable method check routines.
   14.56       */
   14.57 -    boolean argumentsAcceptable(Env<AttrContext> env,
   14.58 -                                Symbol msym,
   14.59 +    interface MethodCheck {
   14.60 +        /**
   14.61 +         * Main method check routine. A method check usually consist in determining
   14.62 +         * as to whether a set of types (actuals) is compatible with another set of
   14.63 +         * types (formals). If an incompatibility is found, an unchecked exception
   14.64 +         * is assumed to be thrown.
   14.65 +         */
   14.66 +        void argumentsAcceptable(Env<AttrContext> env,
   14.67 +                                DeferredAttrContext deferredAttrContext,
   14.68                                  List<Type> argtypes,
   14.69                                  List<Type> formals,
   14.70 -                                boolean allowBoxing,
   14.71 -                                boolean useVarargs,
   14.72 -                                Warner warn) {
   14.73 -        try {
   14.74 -            checkRawArgumentsAcceptable(env, msym, argtypes, formals, allowBoxing, useVarargs, warn);
   14.75 -            return true;
   14.76 -        } catch (InapplicableMethodException ex) {
   14.77 -            return false;
   14.78 +                                Warner warn);
   14.79 +    }
   14.80 +
   14.81 +    /**
   14.82 +     * Helper enum defining all method check diagnostics (used by resolveMethodCheck).
   14.83 +     */
   14.84 +    enum MethodCheckDiag {
   14.85 +        /**
   14.86 +         * Actuals and formals differs in length.
   14.87 +         */
   14.88 +        ARITY_MISMATCH("arg.length.mismatch", "infer.arg.length.mismatch"),
   14.89 +        /**
   14.90 +         * An actual is incompatible with a formal.
   14.91 +         */
   14.92 +        ARG_MISMATCH("no.conforming.assignment.exists", "infer.no.conforming.assignment.exists"),
   14.93 +        /**
   14.94 +         * An actual is incompatible with the varargs element type.
   14.95 +         */
   14.96 +        VARARG_MISMATCH("varargs.argument.mismatch", "infer.varargs.argument.mismatch"),
   14.97 +        /**
   14.98 +         * The varargs element type is inaccessible.
   14.99 +         */
  14.100 +        INACCESSIBLE_VARARGS("inaccessible.varargs.type", "inaccessible.varargs.type");
  14.101 +
  14.102 +        final String basicKey;
  14.103 +        final String inferKey;
  14.104 +
  14.105 +        MethodCheckDiag(String basicKey, String inferKey) {
  14.106 +            this.basicKey = basicKey;
  14.107 +            this.inferKey = inferKey;
  14.108          }
  14.109      }
  14.110 -    /**
  14.111 -     * A check handler is used by the main method applicability routine in order
  14.112 -     * to handle specific method applicability failures. It is assumed that a class
  14.113 -     * implementing this interface should throw exceptions that are a subtype of
  14.114 -     * InapplicableMethodException (see below). Such exception will terminate the
  14.115 -     * method applicability check and propagate important info outwards (for the
  14.116 -     * purpose of generating better diagnostics).
  14.117 -     */
  14.118 -    interface MethodCheckHandler {
  14.119 -        /* The number of actuals and formals differ */
  14.120 -        InapplicableMethodException arityMismatch();
  14.121 -        /* An actual argument type does not conform to the corresponding formal type */
  14.122 -        InapplicableMethodException argumentMismatch(boolean varargs, JCDiagnostic details);
  14.123 -        /* The element type of a varargs is not accessible in the current context */
  14.124 -        InapplicableMethodException inaccessibleVarargs(Symbol location, Type expected);
  14.125 -    }
  14.126 -
  14.127 -    /**
  14.128 -     * Basic method check handler used within Resolve - all methods end up
  14.129 -     * throwing InapplicableMethodException; a diagnostic fragment that describes
  14.130 -     * the cause as to why the method is not applicable is set on the exception
  14.131 -     * before it is thrown.
  14.132 -     */
  14.133 -    MethodCheckHandler resolveHandler = new MethodCheckHandler() {
  14.134 -            public InapplicableMethodException arityMismatch() {
  14.135 -                return inapplicableMethodException.setMessage("arg.length.mismatch");
  14.136 -            }
  14.137 -            public InapplicableMethodException argumentMismatch(boolean varargs, JCDiagnostic details) {
  14.138 -                String key = varargs ?
  14.139 -                        "varargs.argument.mismatch" :
  14.140 -                        "no.conforming.assignment.exists";
  14.141 -                return inapplicableMethodException.setMessage(key,
  14.142 -                        details);
  14.143 -            }
  14.144 -            public InapplicableMethodException inaccessibleVarargs(Symbol location, Type expected) {
  14.145 -                return inapplicableMethodException.setMessage("inaccessible.varargs.type",
  14.146 -                        expected, Kinds.kindName(location), location);
  14.147 -            }
  14.148 -    };
  14.149 -
  14.150 -    void checkRawArgumentsAcceptable(Env<AttrContext> env,
  14.151 -                                Symbol msym,
  14.152 -                                List<Type> argtypes,
  14.153 -                                List<Type> formals,
  14.154 -                                boolean allowBoxing,
  14.155 -                                boolean useVarargs,
  14.156 -                                Warner warn) {
  14.157 -        checkRawArgumentsAcceptable(env, msym, currentResolutionContext.attrMode(), infer.emptyContext, argtypes, formals,
  14.158 -                allowBoxing, useVarargs, warn, resolveHandler);
  14.159 -    }
  14.160  
  14.161      /**
  14.162       * Main method applicability routine. Given a list of actual types A,
  14.163 @@ -689,68 +676,94 @@
  14.164       *
  14.165       * A method check handler (see above) is used in order to report errors.
  14.166       */
  14.167 -    void checkRawArgumentsAcceptable(final Env<AttrContext> env,
  14.168 -                                Symbol msym,
  14.169 -                                DeferredAttr.AttrMode mode,
  14.170 -                                final Infer.InferenceContext inferenceContext,
  14.171 -                                List<Type> argtypes,
  14.172 -                                List<Type> formals,
  14.173 -                                boolean allowBoxing,
  14.174 -                                boolean useVarargs,
  14.175 -                                Warner warn,
  14.176 -                                final MethodCheckHandler handler) {
  14.177 -        Type varargsFormal = useVarargs ? formals.last() : null;
  14.178 -
  14.179 -        if (varargsFormal == null &&
  14.180 -                argtypes.size() != formals.size()) {
  14.181 -            throw handler.arityMismatch(); // not enough args
  14.182 -        }
  14.183 -
  14.184 -        DeferredAttr.DeferredAttrContext deferredAttrContext =
  14.185 -                deferredAttr.new DeferredAttrContext(mode, msym, currentResolutionContext.step, inferenceContext);
  14.186 -
  14.187 -        while (argtypes.nonEmpty() && formals.head != varargsFormal) {
  14.188 -            ResultInfo mresult = methodCheckResult(formals.head, allowBoxing, false, inferenceContext, deferredAttrContext, handler, warn);
  14.189 -            mresult.check(null, argtypes.head);
  14.190 -            argtypes = argtypes.tail;
  14.191 -            formals = formals.tail;
  14.192 -        }
  14.193 -
  14.194 -        if (formals.head != varargsFormal) {
  14.195 -            throw handler.arityMismatch(); // not enough args
  14.196 -        }
  14.197 -
  14.198 -        if (useVarargs) {
  14.199 -            //note: if applicability check is triggered by most specific test,
  14.200 -            //the last argument of a varargs is _not_ an array type (see JLS 15.12.2.5)
  14.201 -            final Type elt = types.elemtype(varargsFormal);
  14.202 -            ResultInfo mresult = methodCheckResult(elt, allowBoxing, true, inferenceContext, deferredAttrContext, handler, warn);
  14.203 -            while (argtypes.nonEmpty()) {
  14.204 +    MethodCheck resolveMethodCheck = new MethodCheck() {
  14.205 +        @Override
  14.206 +        public void argumentsAcceptable(final Env<AttrContext> env,
  14.207 +                                    DeferredAttrContext deferredAttrContext,
  14.208 +                                    List<Type> argtypes,
  14.209 +                                    List<Type> formals,
  14.210 +                                    Warner warn) {
  14.211 +            //should we expand formals?
  14.212 +            boolean useVarargs = deferredAttrContext.phase.isVarargsRequired();
  14.213 +
  14.214 +            //inference context used during this method check
  14.215 +            InferenceContext inferenceContext = deferredAttrContext.inferenceContext;
  14.216 +
  14.217 +            Type varargsFormal = useVarargs ? formals.last() : null;
  14.218 +
  14.219 +            if (varargsFormal == null &&
  14.220 +                    argtypes.size() != formals.size()) {
  14.221 +                report(MethodCheckDiag.ARITY_MISMATCH, inferenceContext); // not enough args
  14.222 +            }
  14.223 +
  14.224 +            while (argtypes.nonEmpty() && formals.head != varargsFormal) {
  14.225 +                ResultInfo mresult = methodCheckResult(false, formals.head, deferredAttrContext, warn);
  14.226                  mresult.check(null, argtypes.head);
  14.227                  argtypes = argtypes.tail;
  14.228 +                formals = formals.tail;
  14.229              }
  14.230 -            //check varargs element type accessibility
  14.231 -            varargsAccessible(env, elt, handler, inferenceContext);
  14.232 -        }
  14.233 -
  14.234 -        deferredAttrContext.complete();
  14.235 -    }
  14.236 -
  14.237 -    void varargsAccessible(final Env<AttrContext> env, final Type t, final Resolve.MethodCheckHandler handler, final InferenceContext inferenceContext) {
  14.238 -        if (inferenceContext.free(t)) {
  14.239 -            inferenceContext.addFreeTypeListener(List.of(t), new FreeTypeListener() {
  14.240 -                @Override
  14.241 -                public void typesInferred(InferenceContext inferenceContext) {
  14.242 -                    varargsAccessible(env, inferenceContext.asInstType(t, types), handler, inferenceContext);
  14.243 +
  14.244 +            if (formals.head != varargsFormal) {
  14.245 +                report(MethodCheckDiag.ARITY_MISMATCH, inferenceContext); // not enough args
  14.246 +            }
  14.247 +
  14.248 +            if (useVarargs) {
  14.249 +                //note: if applicability check is triggered by most specific test,
  14.250 +                //the last argument of a varargs is _not_ an array type (see JLS 15.12.2.5)
  14.251 +                final Type elt = types.elemtype(varargsFormal);
  14.252 +                ResultInfo mresult = methodCheckResult(true, elt, deferredAttrContext, warn);
  14.253 +                while (argtypes.nonEmpty()) {
  14.254 +                    mresult.check(null, argtypes.head);
  14.255 +                    argtypes = argtypes.tail;
  14.256                  }
  14.257 -            });
  14.258 -        } else {
  14.259 -            if (!isAccessible(env, t)) {
  14.260 -                Symbol location = env.enclClass.sym;
  14.261 -                throw handler.inaccessibleVarargs(location, t);
  14.262 +                //check varargs element type accessibility
  14.263 +                varargsAccessible(env, elt, inferenceContext);
  14.264              }
  14.265          }
  14.266 -    }
  14.267 +
  14.268 +        private void report(MethodCheckDiag diag, InferenceContext inferenceContext, Object... args) {
  14.269 +            boolean inferDiag = inferenceContext != infer.emptyContext;
  14.270 +            InapplicableMethodException ex = inferDiag ?
  14.271 +                    infer.inferenceException : inapplicableMethodException;
  14.272 +            if (inferDiag && (!diag.inferKey.equals(diag.basicKey))) {
  14.273 +                Object[] args2 = new Object[args.length + 1];
  14.274 +                System.arraycopy(args, 0, args2, 1, args.length);
  14.275 +                args2[0] = inferenceContext.inferenceVars();
  14.276 +                args = args2;
  14.277 +            }
  14.278 +            throw ex.setMessage(inferDiag ? diag.inferKey : diag.basicKey, args);
  14.279 +        }
  14.280 +
  14.281 +        private void varargsAccessible(final Env<AttrContext> env, final Type t, final InferenceContext inferenceContext) {
  14.282 +            if (inferenceContext.free(t)) {
  14.283 +                inferenceContext.addFreeTypeListener(List.of(t), new FreeTypeListener() {
  14.284 +                    @Override
  14.285 +                    public void typesInferred(InferenceContext inferenceContext) {
  14.286 +                        varargsAccessible(env, inferenceContext.asInstType(t, types), inferenceContext);
  14.287 +                    }
  14.288 +                });
  14.289 +            } else {
  14.290 +                if (!isAccessible(env, t)) {
  14.291 +                    Symbol location = env.enclClass.sym;
  14.292 +                    report(MethodCheckDiag.INACCESSIBLE_VARARGS, inferenceContext, t, Kinds.kindName(location), location);
  14.293 +                }
  14.294 +            }
  14.295 +        }
  14.296 +
  14.297 +        private ResultInfo methodCheckResult(final boolean varargsCheck, Type to,
  14.298 +                final DeferredAttr.DeferredAttrContext deferredAttrContext, Warner rsWarner) {
  14.299 +            CheckContext checkContext = new MethodCheckContext(!deferredAttrContext.phase.isBoxingRequired(), deferredAttrContext, rsWarner) {
  14.300 +                MethodCheckDiag methodDiag = varargsCheck ?
  14.301 +                                 MethodCheckDiag.VARARG_MISMATCH : MethodCheckDiag.ARG_MISMATCH;
  14.302 +
  14.303 +                @Override
  14.304 +                public void report(DiagnosticPosition pos, JCDiagnostic details) {
  14.305 +                    report(methodDiag, deferredAttrContext.inferenceContext, details);
  14.306 +                }
  14.307 +            };
  14.308 +            return new MethodResultInfo(to, checkContext);
  14.309 +        }
  14.310 +    };
  14.311  
  14.312      /**
  14.313       * Check context to be used during method applicability checks. A method check
  14.314 @@ -758,23 +771,24 @@
  14.315       */
  14.316      abstract class MethodCheckContext implements CheckContext {
  14.317  
  14.318 -        MethodCheckHandler handler;
  14.319 -        boolean useVarargs;
  14.320 -        Infer.InferenceContext inferenceContext;
  14.321 +        boolean strict;
  14.322          DeferredAttrContext deferredAttrContext;
  14.323          Warner rsWarner;
  14.324  
  14.325 -        public MethodCheckContext(MethodCheckHandler handler, boolean useVarargs,
  14.326 -                Infer.InferenceContext inferenceContext, DeferredAttrContext deferredAttrContext, Warner rsWarner) {
  14.327 -            this.handler = handler;
  14.328 -            this.useVarargs = useVarargs;
  14.329 -            this.inferenceContext = inferenceContext;
  14.330 -            this.deferredAttrContext = deferredAttrContext;
  14.331 -            this.rsWarner = rsWarner;
  14.332 +        public MethodCheckContext(boolean strict, DeferredAttrContext deferredAttrContext, Warner rsWarner) {
  14.333 +           this.strict = strict;
  14.334 +           this.deferredAttrContext = deferredAttrContext;
  14.335 +           this.rsWarner = rsWarner;
  14.336          }
  14.337  
  14.338 +        public boolean compatible(Type found, Type req, Warner warn) {
  14.339 +            return strict ?
  14.340 +                    types.isSubtypeUnchecked(found, deferredAttrContext.inferenceContext.asFree(req, types), warn) :
  14.341 +                    types.isConvertible(found, deferredAttrContext.inferenceContext.asFree(req, types), warn);
  14.342 +        }
  14.343 +
  14.344          public void report(DiagnosticPosition pos, JCDiagnostic details) {
  14.345 -            throw handler.argumentMismatch(useVarargs, details);
  14.346 +            throw inapplicableMethodException.setMessage(details);
  14.347          }
  14.348  
  14.349          public Warner checkWarner(DiagnosticPosition pos, Type found, Type req) {
  14.350 @@ -782,7 +796,7 @@
  14.351          }
  14.352  
  14.353          public InferenceContext inferenceContext() {
  14.354 -            return inferenceContext;
  14.355 +            return deferredAttrContext.inferenceContext;
  14.356          }
  14.357  
  14.358          public DeferredAttrContext deferredAttrContext() {
  14.359 @@ -791,56 +805,13 @@
  14.360      }
  14.361  
  14.362      /**
  14.363 -     * Subclass of method check context class that implements strict method conversion.
  14.364 -     * Strict method conversion checks compatibility between types using subtyping tests.
  14.365 +     * ResultInfo class to be used during method applicability checks. Check
  14.366 +     * for deferred types goes through special path.
  14.367       */
  14.368 -    class StrictMethodContext extends MethodCheckContext {
  14.369 -
  14.370 -        public StrictMethodContext(MethodCheckHandler handler, boolean useVarargs,
  14.371 -                Infer.InferenceContext inferenceContext, DeferredAttrContext deferredAttrContext, Warner rsWarner) {
  14.372 -            super(handler, useVarargs, inferenceContext, deferredAttrContext, rsWarner);
  14.373 -        }
  14.374 -
  14.375 -        public boolean compatible(Type found, Type req, Warner warn) {
  14.376 -            return types.isSubtypeUnchecked(found, inferenceContext.asFree(req, types), warn);
  14.377 -        }
  14.378 -    }
  14.379 -
  14.380 -    /**
  14.381 -     * Subclass of method check context class that implements loose method conversion.
  14.382 -     * Loose method conversion checks compatibility between types using method conversion tests.
  14.383 -     */
  14.384 -    class LooseMethodContext extends MethodCheckContext {
  14.385 -
  14.386 -        public LooseMethodContext(MethodCheckHandler handler, boolean useVarargs,
  14.387 -                Infer.InferenceContext inferenceContext, DeferredAttrContext deferredAttrContext, Warner rsWarner) {
  14.388 -            super(handler, useVarargs, inferenceContext, deferredAttrContext, rsWarner);
  14.389 -        }
  14.390 -
  14.391 -        public boolean compatible(Type found, Type req, Warner warn) {
  14.392 -            return types.isConvertible(found, inferenceContext.asFree(req, types), warn);
  14.393 -        }
  14.394 -    }
  14.395 -
  14.396 -    /**
  14.397 -     * Create a method check context to be used during method applicability check
  14.398 -     */
  14.399 -    ResultInfo methodCheckResult(Type to, boolean allowBoxing, boolean useVarargs,
  14.400 -            Infer.InferenceContext inferenceContext, DeferredAttr.DeferredAttrContext deferredAttrContext,
  14.401 -            MethodCheckHandler methodHandler, Warner rsWarner) {
  14.402 -        MethodCheckContext checkContext = allowBoxing ?
  14.403 -                new LooseMethodContext(methodHandler, useVarargs, inferenceContext, deferredAttrContext, rsWarner) :
  14.404 -                new StrictMethodContext(methodHandler, useVarargs, inferenceContext, deferredAttrContext, rsWarner);
  14.405 -        return new MethodResultInfo(to, checkContext, deferredAttrContext);
  14.406 -    }
  14.407 -
  14.408      class MethodResultInfo extends ResultInfo {
  14.409  
  14.410 -        DeferredAttr.DeferredAttrContext deferredAttrContext;
  14.411 -
  14.412 -        public MethodResultInfo(Type pt, CheckContext checkContext, DeferredAttr.DeferredAttrContext deferredAttrContext) {
  14.413 +        public MethodResultInfo(Type pt, CheckContext checkContext) {
  14.414              attr.super(VAL, pt, checkContext);
  14.415 -            this.deferredAttrContext = deferredAttrContext;
  14.416          }
  14.417  
  14.418          @Override
  14.419 @@ -855,12 +826,12 @@
  14.420  
  14.421          @Override
  14.422          protected MethodResultInfo dup(Type newPt) {
  14.423 -            return new MethodResultInfo(newPt, checkContext, deferredAttrContext);
  14.424 +            return new MethodResultInfo(newPt, checkContext);
  14.425          }
  14.426  
  14.427          @Override
  14.428          protected ResultInfo dup(CheckContext newContext) {
  14.429 -            return new MethodResultInfo(pt, newContext, deferredAttrContext);
  14.430 +            return new MethodResultInfo(pt, newContext);
  14.431          }
  14.432      }
  14.433  
  14.434 @@ -1071,7 +1042,7 @@
  14.435          Assert.check(sym.kind < AMBIGUOUS);
  14.436          try {
  14.437              Type mt = rawInstantiate(env, site, sym, null, argtypes, typeargtypes,
  14.438 -                               allowBoxing, useVarargs, types.noWarnings);
  14.439 +                               allowBoxing, useVarargs, resolveMethodCheck, types.noWarnings);
  14.440              if (!operator)
  14.441                  currentResolutionContext.addApplicableCandidate(sym, mt);
  14.442          } catch (InapplicableMethodException ex) {
  14.443 @@ -1151,52 +1122,20 @@
  14.444                  if (m1Abstract && !m2Abstract) return m2;
  14.445                  if (m2Abstract && !m1Abstract) return m1;
  14.446                  // both abstract or both concrete
  14.447 -                if (!m1Abstract && !m2Abstract)
  14.448 -                    return ambiguityError(m1, m2);
  14.449 -                // check that both signatures have the same erasure
  14.450 -                if (!types.isSameTypes(m1.erasure(types).getParameterTypes(),
  14.451 -                                       m2.erasure(types).getParameterTypes()))
  14.452 -                    return ambiguityError(m1, m2);
  14.453 -                // both abstract, neither overridden; merge throws clause and result type
  14.454 -                Type mst = mostSpecificReturnType(mt1, mt2);
  14.455 -                if (mst == null) {
  14.456 -                    // Theoretically, this can't happen, but it is possible
  14.457 -                    // due to error recovery or mixing incompatible class files
  14.458 -                    return ambiguityError(m1, m2);
  14.459 -                }
  14.460 -                Symbol mostSpecific = mst == mt1 ? m1 : m2;
  14.461 -                List<Type> allThrown = chk.intersect(mt1.getThrownTypes(), mt2.getThrownTypes());
  14.462 -                Type newSig = types.createMethodTypeWithThrown(mostSpecific.type, allThrown);
  14.463 -                MethodSymbol result = new MethodSymbol(
  14.464 -                        mostSpecific.flags(),
  14.465 -                        mostSpecific.name,
  14.466 -                        newSig,
  14.467 -                        mostSpecific.owner) {
  14.468 -                    @Override
  14.469 -                    public MethodSymbol implementation(TypeSymbol origin, Types types, boolean checkResult) {
  14.470 -                        if (origin == site.tsym)
  14.471 -                            return this;
  14.472 -                        else
  14.473 -                            return super.implementation(origin, types, checkResult);
  14.474 -                        }
  14.475 -                    };
  14.476 -                return result;
  14.477 +                return ambiguityError(m1, m2);
  14.478              }
  14.479              if (m1SignatureMoreSpecific) return m1;
  14.480              if (m2SignatureMoreSpecific) return m2;
  14.481              return ambiguityError(m1, m2);
  14.482          case AMBIGUOUS:
  14.483 +            //check if m1 is more specific than all ambiguous methods in m2
  14.484              AmbiguityError e = (AmbiguityError)m2;
  14.485 -            Symbol err1 = mostSpecific(argtypes, m1, e.sym, env, site, allowBoxing, useVarargs);
  14.486 -            Symbol err2 = mostSpecific(argtypes, m1, e.sym2, env, site, allowBoxing, useVarargs);
  14.487 -            if (err1 == err2) return err1;
  14.488 -            if (err1 == e.sym && err2 == e.sym2) return m2;
  14.489 -            if (err1 instanceof AmbiguityError &&
  14.490 -                err2 instanceof AmbiguityError &&
  14.491 -                ((AmbiguityError)err1).sym == ((AmbiguityError)err2).sym)
  14.492 -                return ambiguityError(m1, m2);
  14.493 -            else
  14.494 -                return ambiguityError(err1, err2);
  14.495 +            for (Symbol s : e.ambiguousSyms) {
  14.496 +                if (mostSpecific(argtypes, m1, s, env, site, allowBoxing, useVarargs) != m1) {
  14.497 +                    return e.addAmbiguousSymbol(m1);
  14.498 +                }
  14.499 +            }
  14.500 +            return m1;
  14.501          default:
  14.502              throw new AssertionError();
  14.503          }
  14.504 @@ -1274,12 +1213,19 @@
  14.505      }
  14.506      //where
  14.507      private boolean invocationMoreSpecific(Env<AttrContext> env, Type site, Symbol m2, List<Type> argtypes1, boolean allowBoxing, boolean useVarargs) {
  14.508 -        noteWarner.clear();
  14.509 -        Type mst = instantiate(env, site, m2, null,
  14.510 -                types.lowerBounds(argtypes1), null,
  14.511 -                allowBoxing, false, noteWarner);
  14.512 -        return mst != null &&
  14.513 -                !noteWarner.hasLint(Lint.LintCategory.UNCHECKED);
  14.514 +        MethodResolutionContext prevContext = currentResolutionContext;
  14.515 +        try {
  14.516 +            currentResolutionContext = new MethodResolutionContext();
  14.517 +            currentResolutionContext.step = allowBoxing ? BOX : BASIC;
  14.518 +            noteWarner.clear();
  14.519 +            Type mst = instantiate(env, site, m2, null,
  14.520 +                    types.lowerBounds(argtypes1), null,
  14.521 +                    allowBoxing, false, resolveMethodCheck, noteWarner);
  14.522 +            return mst != null &&
  14.523 +                    !noteWarner.hasLint(Lint.LintCategory.UNCHECKED);
  14.524 +        } finally {
  14.525 +            currentResolutionContext = prevContext;
  14.526 +        }
  14.527      }
  14.528      //where
  14.529      private Symbol adjustVarargs(Symbol to, Symbol from, boolean useVarargs) {
  14.530 @@ -2366,9 +2312,11 @@
  14.531          try {
  14.532              currentResolutionContext = new MethodResolutionContext();
  14.533              Name name = treeinfo.operatorName(optag);
  14.534 +            env.info.pendingResolutionPhase = currentResolutionContext.step = BASIC;
  14.535              Symbol sym = findMethod(env, syms.predefClass.type, name, argtypes,
  14.536                                      null, false, false, true);
  14.537              if (boxingEnabled && sym.kind >= WRONG_MTHS)
  14.538 +                env.info.pendingResolutionPhase = currentResolutionContext.step = BOX;
  14.539                  sym = findMethod(env, syms.predefClass.type, name, argtypes,
  14.540                                   null, true, false, true);
  14.541              return accessMethod(sym, pos, env.enclClass.sym.type, name,
  14.542 @@ -2524,6 +2472,10 @@
  14.543  
  14.544          @Override
  14.545          Symbol access(Env<AttrContext> env, DiagnosticPosition pos, Symbol location, Symbol sym) {
  14.546 +            if (sym.kind == AMBIGUOUS) {
  14.547 +                AmbiguityError a_err = (AmbiguityError)sym;
  14.548 +                sym = a_err.mergeAbstracts(site);
  14.549 +            }
  14.550              if (sym.kind >= AMBIGUOUS) {
  14.551                  //if nothing is found return the 'first' error
  14.552                  sym = accessMethod(sym, pos, location, site, name, true, argtypes, typeargtypes);
  14.553 @@ -2579,6 +2531,10 @@
  14.554          abstract JCMemberReference.ReferenceKind referenceKind(Symbol sym);
  14.555  
  14.556          Symbol access(Env<AttrContext> env, DiagnosticPosition pos, Symbol location, Symbol sym) {
  14.557 +            if (sym.kind == AMBIGUOUS) {
  14.558 +                AmbiguityError a_err = (AmbiguityError)sym;
  14.559 +                sym = a_err.mergeAbstracts(site);
  14.560 +            }
  14.561              //skip error reporting
  14.562              return sym;
  14.563          }
  14.564 @@ -3014,9 +2970,7 @@
  14.565  
  14.566          @Override
  14.567          public Symbol access(Name name, TypeSymbol location) {
  14.568 -            if (sym.kind >= AMBIGUOUS)
  14.569 -                return ((ResolveError)sym).access(name, location);
  14.570 -            else if ((sym.kind & ERRONEOUS) == 0 && (sym.kind & TYP) != 0)
  14.571 +            if ((sym.kind & ERRONEOUS) == 0 && (sym.kind & TYP) != 0)
  14.572                  return types.createErrorType(name, location, sym.type).tsym;
  14.573              else
  14.574                  return sym;
  14.575 @@ -3338,14 +3292,32 @@
  14.576       * (either methods, constructors or operands) are ambiguous
  14.577       * given an actual arguments/type argument list.
  14.578       */
  14.579 -    class AmbiguityError extends InvalidSymbolError {
  14.580 +    class AmbiguityError extends ResolveError {
  14.581  
  14.582          /** The other maximally specific symbol */
  14.583 -        Symbol sym2;
  14.584 +        List<Symbol> ambiguousSyms = List.nil();
  14.585 +
  14.586 +        @Override
  14.587 +        public boolean exists() {
  14.588 +            return true;
  14.589 +        }
  14.590  
  14.591          AmbiguityError(Symbol sym1, Symbol sym2) {
  14.592 -            super(AMBIGUOUS, sym1, "ambiguity error");
  14.593 -            this.sym2 = sym2;
  14.594 +            super(AMBIGUOUS, "ambiguity error");
  14.595 +            ambiguousSyms = flatten(sym2).appendList(flatten(sym1));
  14.596 +        }
  14.597 +
  14.598 +        private List<Symbol> flatten(Symbol sym) {
  14.599 +            if (sym.kind == AMBIGUOUS) {
  14.600 +                return ((AmbiguityError)sym).ambiguousSyms;
  14.601 +            } else {
  14.602 +                return List.of(sym);
  14.603 +            }
  14.604 +        }
  14.605 +
  14.606 +        AmbiguityError addAmbiguousSymbol(Symbol s) {
  14.607 +            ambiguousSyms = ambiguousSyms.prepend(s);
  14.608 +            return this;
  14.609          }
  14.610  
  14.611          @Override
  14.612 @@ -3356,24 +3328,60 @@
  14.613                  Name name,
  14.614                  List<Type> argtypes,
  14.615                  List<Type> typeargtypes) {
  14.616 -            AmbiguityError pair = this;
  14.617 -            while (true) {
  14.618 -                if (pair.sym.kind == AMBIGUOUS)
  14.619 -                    pair = (AmbiguityError)pair.sym;
  14.620 -                else if (pair.sym2.kind == AMBIGUOUS)
  14.621 -                    pair = (AmbiguityError)pair.sym2;
  14.622 -                else break;
  14.623 -            }
  14.624 -            Name sname = pair.sym.name;
  14.625 -            if (sname == names.init) sname = pair.sym.owner.name;
  14.626 +            List<Symbol> diagSyms = ambiguousSyms.reverse();
  14.627 +            Symbol s1 = diagSyms.head;
  14.628 +            Symbol s2 = diagSyms.tail.head;
  14.629 +            Name sname = s1.name;
  14.630 +            if (sname == names.init) sname = s1.owner.name;
  14.631              return diags.create(dkind, log.currentSource(),
  14.632                        pos, "ref.ambiguous", sname,
  14.633 -                      kindName(pair.sym),
  14.634 -                      pair.sym,
  14.635 -                      pair.sym.location(site, types),
  14.636 -                      kindName(pair.sym2),
  14.637 -                      pair.sym2,
  14.638 -                      pair.sym2.location(site, types));
  14.639 +                      kindName(s1),
  14.640 +                      s1,
  14.641 +                      s1.location(site, types),
  14.642 +                      kindName(s2),
  14.643 +                      s2,
  14.644 +                      s2.location(site, types));
  14.645 +        }
  14.646 +
  14.647 +        /**
  14.648 +         * If multiple applicable methods are found during overload and none of them
  14.649 +         * is more specific than the others, attempt to merge their signatures.
  14.650 +         */
  14.651 +        Symbol mergeAbstracts(Type site) {
  14.652 +            Symbol fst = ambiguousSyms.last();
  14.653 +            Symbol res = fst;
  14.654 +            for (Symbol s : ambiguousSyms.reverse()) {
  14.655 +                Type mt1 = types.memberType(site, res);
  14.656 +                Type mt2 = types.memberType(site, s);
  14.657 +                if ((s.flags() & ABSTRACT) == 0 ||
  14.658 +                        !types.overrideEquivalent(mt1, mt2) ||
  14.659 +                        !types.isSameTypes(fst.erasure(types).getParameterTypes(),
  14.660 +                                       s.erasure(types).getParameterTypes())) {
  14.661 +                    //ambiguity cannot be resolved
  14.662 +                    return this;
  14.663 +                } else {
  14.664 +                    Type mst = mostSpecificReturnType(mt1, mt2);
  14.665 +                    if (mst == null) {
  14.666 +                        // Theoretically, this can't happen, but it is possible
  14.667 +                        // due to error recovery or mixing incompatible class files
  14.668 +                        return this;
  14.669 +                    }
  14.670 +                    Symbol mostSpecific = mst == mt1 ? res : s;
  14.671 +                    List<Type> allThrown = chk.intersect(mt1.getThrownTypes(), mt2.getThrownTypes());
  14.672 +                    Type newSig = types.createMethodTypeWithThrown(mostSpecific.type, allThrown);
  14.673 +                    res = new MethodSymbol(
  14.674 +                            mostSpecific.flags(),
  14.675 +                            mostSpecific.name,
  14.676 +                            newSig,
  14.677 +                            mostSpecific.owner);
  14.678 +                }
  14.679 +            }
  14.680 +            return res;
  14.681 +        }
  14.682 +
  14.683 +        @Override
  14.684 +        protected Symbol access(Name name, TypeSymbol location) {
  14.685 +            return ambiguousSyms.last();
  14.686          }
  14.687      }
  14.688  
  14.689 @@ -3450,6 +3458,10 @@
  14.690              candidates = candidates.append(c);
  14.691          }
  14.692  
  14.693 +        DeferredAttrContext deferredAttrContext(Symbol sym, InferenceContext inferenceContext) {
  14.694 +            return deferredAttr.new DeferredAttrContext(attrMode, sym, step, inferenceContext);
  14.695 +        }
  14.696 +
  14.697          /**
  14.698           * This class represents an overload resolution candidate. There are two
  14.699           * kinds of candidates: applicable methods and inapplicable methods;
    15.1 --- a/src/share/classes/com/sun/tools/javac/jvm/ClassReader.java	Thu Jan 10 09:56:09 2013 -0800
    15.2 +++ b/src/share/classes/com/sun/tools/javac/jvm/ClassReader.java	Thu Jan 10 15:53:02 2013 -0800
    15.3 @@ -217,6 +217,13 @@
    15.4       */
    15.5      boolean haveParameterNameIndices;
    15.6  
    15.7 +    /** Set this to false every time we start reading a method
    15.8 +     * and are saving parameter names.  Set it to true when we see
    15.9 +     * MethodParameters, if it's set when we see a LocalVariableTable,
   15.10 +     * then we ignore the parameter names from the LVT.
   15.11 +     */
   15.12 +    boolean sawMethodParameters;
   15.13 +
   15.14      /**
   15.15       * The set of attribute names for which warnings have been generated for the current class
   15.16       */
   15.17 @@ -984,7 +991,7 @@
   15.18              new AttributeReader(names.LocalVariableTable, V45_3, CLASS_OR_MEMBER_ATTRIBUTE) {
   15.19                  protected void read(Symbol sym, int attrLen) {
   15.20                      int newbp = bp + attrLen;
   15.21 -                    if (saveParameterNames) {
   15.22 +                    if (saveParameterNames && !sawMethodParameters) {
   15.23                          // Pick up parameter names from the variable table.
   15.24                          // Parameter names are not explicitly identified as such,
   15.25                          // but all parameter name entries in the LocalVariableTable
   15.26 @@ -1017,6 +1024,25 @@
   15.27                  }
   15.28              },
   15.29  
   15.30 +            new AttributeReader(names.MethodParameters, V52, MEMBER_ATTRIBUTE) {
   15.31 +                protected void read(Symbol sym, int attrlen) {
   15.32 +                    int newbp = bp + attrlen;
   15.33 +                    if (saveParameterNames) {
   15.34 +                        sawMethodParameters = true;
   15.35 +                        int numEntries = nextByte();
   15.36 +                        parameterNameIndices = new int[numEntries];
   15.37 +                        haveParameterNameIndices = true;
   15.38 +                        for (int i = 0; i < numEntries; i++) {
   15.39 +                            int nameIndex = nextChar();
   15.40 +                            int flags = nextInt();
   15.41 +                            parameterNameIndices[i] = nameIndex;
   15.42 +                        }
   15.43 +                    }
   15.44 +                    bp = newbp;
   15.45 +                }
   15.46 +            },
   15.47 +
   15.48 +
   15.49              new AttributeReader(names.SourceFile, V45_3, CLASS_ATTRIBUTE) {
   15.50                  protected void read(Symbol sym, int attrLen) {
   15.51                      ClassSymbol c = (ClassSymbol) sym;
   15.52 @@ -1826,6 +1852,7 @@
   15.53          } else
   15.54              Arrays.fill(parameterNameIndices, 0);
   15.55          haveParameterNameIndices = false;
   15.56 +        sawMethodParameters = false;
   15.57      }
   15.58  
   15.59      /**
   15.60 @@ -1845,12 +1872,16 @@
   15.61          // if no names were found in the class file, there's nothing more to do
   15.62          if (!haveParameterNameIndices)
   15.63              return;
   15.64 -
   15.65 -        int firstParam = ((sym.flags() & STATIC) == 0) ? 1 : 0;
   15.66 -        // the code in readMethod may have skipped the first parameter when
   15.67 -        // setting up the MethodType. If so, we make a corresponding allowance
   15.68 -        // here for the position of the first parameter.  Note that this
   15.69 -        // assumes the skipped parameter has a width of 1 -- i.e. it is not
   15.70 +        // If we get parameter names from MethodParameters, then we
   15.71 +        // don't need to skip.
   15.72 +        int firstParam = 0;
   15.73 +        if (!sawMethodParameters) {
   15.74 +            firstParam = ((sym.flags() & STATIC) == 0) ? 1 : 0;
   15.75 +            // the code in readMethod may have skipped the first
   15.76 +            // parameter when setting up the MethodType. If so, we
   15.77 +            // make a corresponding allowance here for the position of
   15.78 +            // the first parameter.  Note that this assumes the
   15.79 +            // skipped parameter has a width of 1 -- i.e. it is not
   15.80          // a double width type (long or double.)
   15.81          if (sym.name == names.init && currentOwner.hasOuterInstance()) {
   15.82              // Sometimes anonymous classes don't have an outer
   15.83 @@ -1861,17 +1892,20 @@
   15.84          }
   15.85  
   15.86          if (sym.type != jvmType) {
   15.87 -            // reading the method attributes has caused the symbol's type to
   15.88 -            // be changed. (i.e. the Signature attribute.)  This may happen if
   15.89 -            // there are hidden (synthetic) parameters in the descriptor, but
   15.90 -            // not in the Signature.  The position of these hidden parameters
   15.91 -            // is unspecified; for now, assume they are at the beginning, and
   15.92 -            // so skip over them. The primary case for this is two hidden
   15.93 -            // parameters passed into Enum constructors.
   15.94 +                // reading the method attributes has caused the
   15.95 +                // symbol's type to be changed. (i.e. the Signature
   15.96 +                // attribute.)  This may happen if there are hidden
   15.97 +                // (synthetic) parameters in the descriptor, but not
   15.98 +                // in the Signature.  The position of these hidden
   15.99 +                // parameters is unspecified; for now, assume they are
  15.100 +                // at the beginning, and so skip over them. The
  15.101 +                // primary case for this is two hidden parameters
  15.102 +                // passed into Enum constructors.
  15.103              int skip = Code.width(jvmType.getParameterTypes())
  15.104                      - Code.width(sym.type.getParameterTypes());
  15.105              firstParam += skip;
  15.106          }
  15.107 +        }
  15.108          List<Name> paramNames = List.nil();
  15.109          int index = firstParam;
  15.110          for (Type t: sym.type.getParameterTypes()) {
    16.1 --- a/src/share/classes/com/sun/tools/javac/jvm/ClassWriter.java	Thu Jan 10 09:56:09 2013 -0800
    16.2 +++ b/src/share/classes/com/sun/tools/javac/jvm/ClassWriter.java	Thu Jan 10 15:53:02 2013 -0800
    16.3 @@ -725,6 +725,28 @@
    16.4          return acount;
    16.5      }
    16.6  
    16.7 +    /**
    16.8 +     * Write method parameter names attribute.
    16.9 +     */
   16.10 +    int writeMethodParametersAttr(MethodSymbol m) {
   16.11 +        if (m.params != null && 0 != m.params.length()) {
   16.12 +            int attrIndex = writeAttr(names.MethodParameters);
   16.13 +            databuf.appendByte(m.params.length());
   16.14 +            for (VarSymbol s : m.params) {
   16.15 +                // TODO: expand to cover synthesized, once we figure out
   16.16 +                // how to represent that.
   16.17 +                final int flags = (int) s.flags() & (FINAL | SYNTHETIC);
   16.18 +                // output parameter info
   16.19 +                databuf.appendChar(pool.put(s.name));
   16.20 +                databuf.appendInt(flags);
   16.21 +            }
   16.22 +            endAttr(attrIndex);
   16.23 +            return 1;
   16.24 +        } else
   16.25 +            return 0;
   16.26 +    }
   16.27 +
   16.28 +
   16.29      /** Write method parameter annotations;
   16.30       *  return number of attributes written.
   16.31       */
   16.32 @@ -1034,6 +1056,8 @@
   16.33              endAttr(alenIdx);
   16.34              acount++;
   16.35          }
   16.36 +        if (options.isSet(PARAMETERS))
   16.37 +            acount += writeMethodParametersAttr(m);
   16.38          acount += writeMemberAttrs(m);
   16.39          acount += writeParameterAttrs(m);
   16.40          endAttrs(acountIdx, acount);
    17.1 --- a/src/share/classes/com/sun/tools/javac/main/Option.java	Thu Jan 10 09:56:09 2013 -0800
    17.2 +++ b/src/share/classes/com/sun/tools/javac/main/Option.java	Thu Jan 10 15:53:02 2013 -0800
    17.3 @@ -1,5 +1,5 @@
    17.4  /*
    17.5 - * Copyright (c) 2006, 2012, Oracle and/or its affiliates. All rights reserved.
    17.6 + * Copyright (c) 2006, 2013, Oracle and/or its affiliates. All rights reserved.
    17.7   * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
    17.8   *
    17.9   * This code is free software; you can redistribute it and/or modify it
   17.10 @@ -176,6 +176,8 @@
   17.11  
   17.12      PROCESSORPATH("-processorpath", "opt.arg.path", "opt.processorpath", STANDARD, FILEMANAGER),
   17.13  
   17.14 +    PARAMETERS("-parameters","opt.parameters", STANDARD, BASIC),
   17.15 +
   17.16      D("-d", "opt.arg.directory", "opt.d", STANDARD, FILEMANAGER),
   17.17  
   17.18      S("-s", "opt.arg.directory", "opt.sourceDest", STANDARD, FILEMANAGER),
   17.19 @@ -309,7 +311,7 @@
   17.20  
   17.21      // This option exists only for the purpose of documenting itself.
   17.22      // It's actually implemented by the launcher.
   17.23 -    J("-J", "opt.arg.flag", "opt.J", STANDARD, INFO) {
   17.24 +    J("-J", "opt.arg.flag", "opt.J", STANDARD, INFO, true) {
   17.25          @Override
   17.26          public boolean process(OptionHelper helper, String option) {
   17.27              throw new AssertionError
   17.28 @@ -414,7 +416,7 @@
   17.29  
   17.30      // This option exists only for the purpose of documenting itself.
   17.31      // It's actually implemented by the CommandLine class.
   17.32 -    AT("@", "opt.arg.file", "opt.AT", STANDARD, INFO) {
   17.33 +    AT("@", "opt.arg.file", "opt.AT", STANDARD, INFO, true) {
   17.34          @Override
   17.35          public boolean process(OptionHelper helper, String option) {
   17.36              throw new AssertionError("the @ flag should be caught by CommandLine.");
    18.1 --- a/src/share/classes/com/sun/tools/javac/resources/javac.properties	Thu Jan 10 09:56:09 2013 -0800
    18.2 +++ b/src/share/classes/com/sun/tools/javac/resources/javac.properties	Thu Jan 10 15:53:02 2013 -0800
    18.3 @@ -55,6 +55,8 @@
    18.4      Specify where to find annotation processors
    18.5  javac.opt.processor=\
    18.6      Names of the annotation processors to run; bypasses default discovery process
    18.7 +javac.opt.parameters=\
    18.8 +    Generate metadata for reflection on method parameters
    18.9  javac.opt.proc.none.only=\
   18.10      Control whether annotation processing and/or compilation is done.
   18.11  javac.opt.d=\
    19.1 --- a/src/share/classes/com/sun/tools/javac/tree/Pretty.java	Thu Jan 10 09:56:09 2013 -0800
    19.2 +++ b/src/share/classes/com/sun/tools/javac/tree/Pretty.java	Thu Jan 10 15:53:02 2013 -0800
    19.3 @@ -1,5 +1,5 @@
    19.4  /*
    19.5 - * Copyright (c) 1999, 2012, Oracle and/or its affiliates. All rights reserved.
    19.6 + * Copyright (c) 1999, 2013, Oracle and/or its affiliates. All rights reserved.
    19.7   * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
    19.8   *
    19.9   * This code is free software; you can redistribute it and/or modify it
   19.10 @@ -154,12 +154,13 @@
   19.11          }
   19.12          //we need to (i) replace all line terminators with a space and (ii) remove
   19.13          //occurrences of 'missing' in the Pretty output (generated when types are missing)
   19.14 -        String res = s.toString().replaceAll("\\s+", " ").replaceAll("/\\*missing\\*/", "");
   19.15 +        String res = s.toString().trim().replaceAll("\\s+", " ").replaceAll("/\\*missing\\*/", "");
   19.16          if (res.length() < maxLength) {
   19.17              return res;
   19.18          } else {
   19.19 -            int split = (maxLength - trimSequence.length()) * 2 / 3;
   19.20 -            return res.substring(0, split) + trimSequence + res.substring(split);
   19.21 +            int head = (maxLength - trimSequence.length()) * 2 / 3;
   19.22 +            int tail = maxLength - trimSequence.length() - head;
   19.23 +            return res.substring(0, head) + trimSequence + res.substring(res.length() - tail);
   19.24          }
   19.25      }
   19.26  
    20.1 --- a/src/share/classes/com/sun/tools/javac/util/Names.java	Thu Jan 10 09:56:09 2013 -0800
    20.2 +++ b/src/share/classes/com/sun/tools/javac/util/Names.java	Thu Jan 10 15:53:02 2013 -0800
    20.3 @@ -132,6 +132,7 @@
    20.4      public final Name LineNumberTable;
    20.5      public final Name LocalVariableTable;
    20.6      public final Name LocalVariableTypeTable;
    20.7 +    public final Name MethodParameters;
    20.8      public final Name RuntimeInvisibleAnnotations;
    20.9      public final Name RuntimeInvisibleParameterAnnotations;
   20.10      public final Name RuntimeInvisibleTypeAnnotations;
   20.11 @@ -265,6 +266,7 @@
   20.12          LineNumberTable = fromString("LineNumberTable");
   20.13          LocalVariableTable = fromString("LocalVariableTable");
   20.14          LocalVariableTypeTable = fromString("LocalVariableTypeTable");
   20.15 +        MethodParameters = fromString("MethodParameters");
   20.16          RuntimeInvisibleAnnotations = fromString("RuntimeInvisibleAnnotations");
   20.17          RuntimeInvisibleParameterAnnotations = fromString("RuntimeInvisibleParameterAnnotations");
   20.18          RuntimeInvisibleTypeAnnotations = fromString("RuntimeInvisibleTypeAnnotations");
    21.1 --- a/src/share/classes/com/sun/tools/javadoc/AnnotationDescImpl.java	Thu Jan 10 09:56:09 2013 -0800
    21.2 +++ b/src/share/classes/com/sun/tools/javadoc/AnnotationDescImpl.java	Thu Jan 10 15:53:02 2013 -0800
    21.3 @@ -89,6 +89,15 @@
    21.4      }
    21.5  
    21.6      /**
    21.7 +     * Check for the synthesized bit on the annotation.
    21.8 +     *
    21.9 +     * @return true if the annotation is synthesized.
   21.10 +     */
   21.11 +    public boolean isSynthesized() {
   21.12 +        return annotation.isSynthesized();
   21.13 +    }
   21.14 +
   21.15 +    /**
   21.16       * Returns a string representation of this annotation.
   21.17       * String is of one of the forms:
   21.18       *     @com.example.foo(name1=val1, name2=val2)
    22.1 --- a/src/share/classes/com/sun/tools/javadoc/Messager.java	Thu Jan 10 09:56:09 2013 -0800
    22.2 +++ b/src/share/classes/com/sun/tools/javadoc/Messager.java	Thu Jan 10 15:53:02 2013 -0800
    22.3 @@ -1,5 +1,5 @@
    22.4  /*
    22.5 - * Copyright (c) 1997, 2012, Oracle and/or its affiliates. All rights reserved.
    22.6 + * Copyright (c) 1997, 2013, Oracle and/or its affiliates. All rights reserved.
    22.7   * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
    22.8   *
    22.9   * This code is free software; you can redistribute it and/or modify it
   22.10 @@ -133,16 +133,6 @@
   22.11          this.programName = programName;
   22.12      }
   22.13  
   22.14 -    @Override
   22.15 -    protected int getDefaultMaxErrors() {
   22.16 -        return Integer.MAX_VALUE;
   22.17 -    }
   22.18 -
   22.19 -    @Override
   22.20 -    protected int getDefaultMaxWarnings() {
   22.21 -        return Integer.MAX_VALUE;
   22.22 -    }
   22.23 -
   22.24      public void setLocale(Locale locale) {
   22.25          this.locale = locale;
   22.26      }
    23.1 --- a/src/share/classes/com/sun/tools/javadoc/MethodDocImpl.java	Thu Jan 10 09:56:09 2013 -0800
    23.2 +++ b/src/share/classes/com/sun/tools/javadoc/MethodDocImpl.java	Thu Jan 10 15:53:02 2013 -0800
    23.3 @@ -86,16 +86,7 @@
    23.4       * Return true if this method is abstract
    23.5       */
    23.6      public boolean isAbstract() {
    23.7 -        //### This is dubious, but old 'javadoc' apparently does it.
    23.8 -        //### I regard this as a bug and an obstacle to treating the
    23.9 -        //### doclet API as a proper compile-time reflection facility.
   23.10 -        //### (maddox 09/26/2000)
   23.11 -        if (containingClass().isInterface()) {
   23.12 -            //### Don't force creation of ClassDocImpl for super here.
   23.13 -            // Abstract modifier is implicit.  Strip/canonicalize it.
   23.14 -            return false;
   23.15 -        }
   23.16 -        return Modifier.isAbstract(getModifiers());
   23.17 +        return (Modifier.isAbstract(getModifiers()) && !isDefault());
   23.18      }
   23.19  
   23.20      /**
    24.1 --- a/src/share/classes/com/sun/tools/javap/AttributeWriter.java	Thu Jan 10 09:56:09 2013 -0800
    24.2 +++ b/src/share/classes/com/sun/tools/javap/AttributeWriter.java	Thu Jan 10 15:53:02 2013 -0800
    24.3 @@ -1,5 +1,5 @@
    24.4  /*
    24.5 - * Copyright (c) 2007, 2011, Oracle and/or its affiliates. All rights reserved.
    24.6 + * Copyright (c) 2007, 2012, Oracle and/or its affiliates. All rights reserved.
    24.7   * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
    24.8   *
    24.9   * This code is free software; you can redistribute it and/or modify it
   24.10 @@ -46,6 +46,7 @@
   24.11  import com.sun.tools.classfile.LineNumberTable_attribute;
   24.12  import com.sun.tools.classfile.LocalVariableTable_attribute;
   24.13  import com.sun.tools.classfile.LocalVariableTypeTable_attribute;
   24.14 +import com.sun.tools.classfile.MethodParameters_attribute;
   24.15  import com.sun.tools.classfile.RuntimeInvisibleAnnotations_attribute;
   24.16  import com.sun.tools.classfile.RuntimeInvisibleParameterAnnotations_attribute;
   24.17  import com.sun.tools.classfile.RuntimeVisibleAnnotations_attribute;
   24.18 @@ -386,6 +387,28 @@
   24.19          return null;
   24.20      }
   24.21  
   24.22 +    private static final String format = "%-31s%s";
   24.23 +
   24.24 +    public Void visitMethodParameters(MethodParameters_attribute attr,
   24.25 +                                      Void ignore) {
   24.26 +
   24.27 +        final String header = String.format(format, "Name", "Flags");
   24.28 +        println("MethodParameters:");
   24.29 +        indent(+1);
   24.30 +        println(header);
   24.31 +        for (MethodParameters_attribute.Entry entry :
   24.32 +                 attr.method_parameter_table) {
   24.33 +            String flagstr =
   24.34 +                (0 != (entry.flags & ACC_FINAL) ? " final" : "") +
   24.35 +                (0 != (entry.flags & ACC_SYNTHETIC) ? " synthetic" : "");
   24.36 +            println(String.format(format,
   24.37 +                                  constantWriter.stringValue(entry.name_index),
   24.38 +                                  flagstr));
   24.39 +        }
   24.40 +        indent(-1);
   24.41 +        return null;
   24.42 +    }
   24.43 +
   24.44      public Void visitRuntimeVisibleAnnotations(RuntimeVisibleAnnotations_attribute attr, Void ignore) {
   24.45          println("RuntimeVisibleAnnotations:");
   24.46          indent(+1);
    25.1 --- a/src/share/classes/com/sun/tools/javap/ClassWriter.java	Thu Jan 10 09:56:09 2013 -0800
    25.2 +++ b/src/share/classes/com/sun/tools/javap/ClassWriter.java	Thu Jan 10 15:53:02 2013 -0800
    25.3 @@ -1,5 +1,5 @@
    25.4  /*
    25.5 - * Copyright (c) 2007, 2011, Oracle and/or its affiliates. All rights reserved.
    25.6 + * Copyright (c) 2007, 2013, Oracle and/or its affiliates. All rights reserved.
    25.7   * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
    25.8   *
    25.9   * This code is free software; you can redistribute it and/or modify it
   25.10 @@ -206,7 +206,7 @@
   25.11              println("minor version: " + cf.minor_version);
   25.12              println("major version: " + cf.major_version);
   25.13              if (!options.compat)
   25.14 -              writeList("flags: ", flags.getClassFlags(), NEWLINE);
   25.15 +              writeList("flags: ", flags.getClassFlags(), "\n");
   25.16              indent(-1);
   25.17              constantWriter.writeConstantPool();
   25.18          } else {
   25.19 @@ -383,7 +383,7 @@
   25.20              println("Signature: " + getValue(f.descriptor));
   25.21  
   25.22          if (options.verbose && !options.compat)
   25.23 -            writeList("flags: ", flags.getFieldFlags(), NEWLINE);
   25.24 +            writeList("flags: ", flags.getFieldFlags(), "\n");
   25.25  
   25.26          if (options.showAllAttrs) {
   25.27              for (Attribute attr: f.attributes)
   25.28 @@ -480,7 +480,7 @@
   25.29          }
   25.30  
   25.31          if (options.verbose && !options.compat) {
   25.32 -            writeList("flags: ", flags.getMethodFlags(), NEWLINE);
   25.33 +            writeList("flags: ", flags.getMethodFlags(), "\n");
   25.34          }
   25.35  
   25.36          Code_attribute code = null;
   25.37 @@ -749,5 +749,4 @@
   25.38      private int size;
   25.39      private ConstantPool constant_pool;
   25.40      private Method method;
   25.41 -    private static final String NEWLINE = System.getProperty("line.separator", "\n");
   25.42  }
    26.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
    26.2 +++ b/src/share/classes/com/sun/tools/jdeps/Archive.java	Thu Jan 10 15:53:02 2013 -0800
    26.3 @@ -0,0 +1,173 @@
    26.4 +/*
    26.5 + * Copyright (c) 2012, Oracle and/or its affiliates. All rights reserved.
    26.6 + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
    26.7 + *
    26.8 + * This code is free software; you can redistribute it and/or modify it
    26.9 + * under the terms of the GNU General Public License version 2 only, as
   26.10 + * published by the Free Software Foundation.  Oracle designates this
   26.11 + * particular file as subject to the "Classpath" exception as provided
   26.12 + * by Oracle in the LICENSE file that accompanied this code.
   26.13 + *
   26.14 + * This code is distributed in the hope that it will be useful, but WITHOUT
   26.15 + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
   26.16 + * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
   26.17 + * version 2 for more details (a copy is included in the LICENSE file that
   26.18 + * accompanied this code).
   26.19 + *
   26.20 + * You should have received a copy of the GNU General Public License version
   26.21 + * 2 along with this work; if not, write to the Free Software Foundation,
   26.22 + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
   26.23 + *
   26.24 + * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
   26.25 + * or visit www.oracle.com if you need additional information or have any
   26.26 + * questions.
   26.27 + */
   26.28 +package com.sun.tools.jdeps;
   26.29 +
   26.30 +import com.sun.tools.classfile.Dependency;
   26.31 +import com.sun.tools.classfile.Dependency.Location;
   26.32 +import java.io.File;
   26.33 +import java.util.Comparator;
   26.34 +import java.util.HashMap;
   26.35 +import java.util.HashSet;
   26.36 +import java.util.Map;
   26.37 +import java.util.Set;
   26.38 +import java.util.SortedMap;
   26.39 +import java.util.SortedSet;
   26.40 +import java.util.TreeMap;
   26.41 +import java.util.TreeSet;
   26.42 +
   26.43 +/**
   26.44 + * Represents the source of the class files.
   26.45 + */
   26.46 +public class Archive {
   26.47 +    private static Map<String,Archive> archiveForClass = new HashMap<String,Archive>();
   26.48 +    public static Archive find(Location loc) {
   26.49 +        return archiveForClass.get(loc.getName());
   26.50 +    }
   26.51 +
   26.52 +    private final File file;
   26.53 +    private final String filename;
   26.54 +    private final DependencyRecorder recorder;
   26.55 +    private final ClassFileReader reader;
   26.56 +    public Archive(String name) {
   26.57 +        this.file = null;
   26.58 +        this.filename = name;
   26.59 +        this.recorder = new DependencyRecorder();
   26.60 +        this.reader = null;
   26.61 +    }
   26.62 +
   26.63 +    public Archive(File f, ClassFileReader reader) {
   26.64 +        this.file = f;
   26.65 +        this.filename = f.getName();
   26.66 +        this.recorder = new DependencyRecorder();
   26.67 +        this.reader = reader;
   26.68 +    }
   26.69 +
   26.70 +    public ClassFileReader reader() {
   26.71 +        return reader;
   26.72 +    }
   26.73 +
   26.74 +    public String getFileName() {
   26.75 +        return filename;
   26.76 +    }
   26.77 +
   26.78 +    public void addClass(String classFileName) {
   26.79 +        Archive a = archiveForClass.get(classFileName);
   26.80 +        assert(a == null || a == this); // ## issue warning?
   26.81 +        if (!archiveForClass.containsKey(classFileName)) {
   26.82 +            archiveForClass.put(classFileName, this);
   26.83 +        }
   26.84 +    }
   26.85 +
   26.86 +    public void addDependency(Dependency d) {
   26.87 +        recorder.addDependency(d);
   26.88 +    }
   26.89 +
   26.90 +    /**
   26.91 +     * Returns a sorted map of a class to its dependencies.
   26.92 +     */
   26.93 +    public SortedMap<Location, SortedSet<Location>> getDependencies() {
   26.94 +        DependencyRecorder.Filter filter = new DependencyRecorder.Filter() {
   26.95 +            public boolean accept(Location origin, Location target) {
   26.96 +                 return (archiveForClass.get(origin.getName()) !=
   26.97 +                            archiveForClass.get(target.getName()));
   26.98 +        }};
   26.99 +
  26.100 +        SortedMap<Location, SortedSet<Location>> result =
  26.101 +            new TreeMap<Location, SortedSet<Location>>(locationComparator);
  26.102 +        for (Map.Entry<Location, Set<Location>> e : recorder.dependencies().entrySet()) {
  26.103 +            Location o = e.getKey();
  26.104 +            for (Location t : e.getValue()) {
  26.105 +                if (filter.accept(o, t)) {
  26.106 +                    SortedSet<Location> odeps = result.get(o);
  26.107 +                    if (odeps == null) {
  26.108 +                        odeps = new TreeSet<Location>(locationComparator);
  26.109 +                        result.put(o, odeps);
  26.110 +                    }
  26.111 +                    odeps.add(t);
  26.112 +                }
  26.113 +            }
  26.114 +        }
  26.115 +        return result;
  26.116 +    }
  26.117 +
  26.118 +    /**
  26.119 +     * Returns the set of archives this archive requires.
  26.120 +     */
  26.121 +    public Set<Archive> getRequiredArchives() {
  26.122 +        SortedSet<Archive> deps = new TreeSet<Archive>(new Comparator<Archive>() {
  26.123 +            public int compare(Archive a1, Archive a2) {
  26.124 +                return a1.toString().compareTo(a2.toString());
  26.125 +            }
  26.126 +        });
  26.127 +
  26.128 +        for (Map.Entry<Location, Set<Location>> e : recorder.dependencies().entrySet()) {
  26.129 +            Location o = e.getKey();
  26.130 +            Archive origin = Archive.find(o);
  26.131 +            for (Location t : e.getValue()) {
  26.132 +                Archive target = Archive.find(t);
  26.133 +                assert(origin != null && target != null);
  26.134 +                if (origin != target) {
  26.135 +                    if (!deps.contains(target)) {
  26.136 +                        deps.add(target);
  26.137 +                    }
  26.138 +                }
  26.139 +            }
  26.140 +        }
  26.141 +        return deps;
  26.142 +    }
  26.143 +
  26.144 +    public String toString() {
  26.145 +        return file != null ? file.getPath() : filename;
  26.146 +    }
  26.147 +
  26.148 +    private static class DependencyRecorder {
  26.149 +        static interface Filter {
  26.150 +            boolean accept(Location origin, Location target);
  26.151 +        }
  26.152 +
  26.153 +        public void addDependency(Dependency d) {
  26.154 +            Set<Location> odeps = map.get(d.getOrigin());
  26.155 +            if (odeps == null) {
  26.156 +                odeps = new HashSet<Location>();
  26.157 +                map.put(d.getOrigin(), odeps);
  26.158 +            }
  26.159 +            odeps.add(d.getTarget());
  26.160 +        }
  26.161 +
  26.162 +        public Map<Location, Set<Location>> dependencies() {
  26.163 +            return map;
  26.164 +        }
  26.165 +
  26.166 +        private final Map<Location, Set<Location>> map =
  26.167 +            new HashMap<Location, Set<Location>>();
  26.168 +    }
  26.169 +
  26.170 +    private static Comparator<Location> locationComparator =
  26.171 +        new Comparator<Location>() {
  26.172 +            public int compare(Location o1, Location o2) {
  26.173 +                return o1.toString().compareTo(o2.toString());
  26.174 +            }
  26.175 +        };
  26.176 +}
    27.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
    27.2 +++ b/src/share/classes/com/sun/tools/jdeps/ClassFileReader.java	Thu Jan 10 15:53:02 2013 -0800
    27.3 @@ -0,0 +1,326 @@
    27.4 +/*
    27.5 + * Copyright (c) 2012, Oracle and/or its affiliates. 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.  Oracle designates this
   27.11 + * particular file as subject to the "Classpath" exception as provided
   27.12 + * by Oracle 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 Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
   27.25 + * or visit www.oracle.com if you need additional information or have any
   27.26 + * questions.
   27.27 + */
   27.28 +package com.sun.tools.jdeps;
   27.29 +
   27.30 +import com.sun.tools.classfile.ClassFile;
   27.31 +import com.sun.tools.classfile.ConstantPoolException;
   27.32 +import com.sun.tools.classfile.Dependencies.ClassFileError;
   27.33 +import java.io.*;
   27.34 +import java.nio.file.FileVisitResult;
   27.35 +import java.nio.file.Files;
   27.36 +import java.nio.file.Path;
   27.37 +import java.nio.file.SimpleFileVisitor;
   27.38 +import java.nio.file.attribute.BasicFileAttributes;
   27.39 +import java.util.*;
   27.40 +import java.util.jar.JarEntry;
   27.41 +import java.util.jar.JarFile;
   27.42 +
   27.43 +/**
   27.44 + * ClassFileReader reads ClassFile(s) of a given path that can be
   27.45 + * a .class file, a directory, or a JAR file.
   27.46 + */
   27.47 +public class ClassFileReader {
   27.48 +    /**
   27.49 +     * Returns a ClassFileReader instance of a given path.
   27.50 +     */
   27.51 +    public static ClassFileReader newInstance(File path) throws IOException {
   27.52 +        if (!path.exists()) {
   27.53 +            throw new FileNotFoundException(path.getAbsolutePath());
   27.54 +        }
   27.55 +
   27.56 +        if (path.isDirectory()) {
   27.57 +            return new DirectoryReader(path.toPath());
   27.58 +        } else if (path.getName().endsWith(".jar")) {
   27.59 +            return new JarFileReader(path.toPath());
   27.60 +        } else {
   27.61 +            return new ClassFileReader(path.toPath());
   27.62 +        }
   27.63 +    }
   27.64 +
   27.65 +    protected final Path path;
   27.66 +    protected final String baseFileName;
   27.67 +    private ClassFileReader(Path path) {
   27.68 +        this.path = path;
   27.69 +        this.baseFileName = path.getFileName() != null
   27.70 +                                ? path.getFileName().toString()
   27.71 +                                : path.toString();
   27.72 +    }
   27.73 +
   27.74 +    public String getFileName() {
   27.75 +        return baseFileName;
   27.76 +    }
   27.77 +
   27.78 +    /**
   27.79 +     * Returns the ClassFile matching the given binary name
   27.80 +     * or a fully-qualified class name.
   27.81 +     */
   27.82 +    public ClassFile getClassFile(String name) throws IOException {
   27.83 +        if (name.indexOf('.') > 0) {
   27.84 +            int i = name.lastIndexOf('.');
   27.85 +            String pathname = name.replace('.', File.separatorChar) + ".class";
   27.86 +            if (baseFileName.equals(pathname) ||
   27.87 +                    baseFileName.equals(pathname.substring(0, i) + "$" +
   27.88 +                                        pathname.substring(i+1, pathname.length()))) {
   27.89 +                return readClassFile(path);
   27.90 +            }
   27.91 +        } else {
   27.92 +            if (baseFileName.equals(name.replace('/', File.separatorChar) + ".class")) {
   27.93 +                return readClassFile(path);
   27.94 +            }
   27.95 +        }
   27.96 +        return null;
   27.97 +    }
   27.98 +
   27.99 +    public Iterable<ClassFile> getClassFiles() throws IOException {
  27.100 +        return new Iterable<ClassFile>() {
  27.101 +            public Iterator<ClassFile> iterator() {
  27.102 +                return new FileIterator();
  27.103 +            }
  27.104 +        };
  27.105 +    }
  27.106 +
  27.107 +    protected ClassFile readClassFile(Path p) throws IOException {
  27.108 +        InputStream is = null;
  27.109 +        try {
  27.110 +            is = Files.newInputStream(p);
  27.111 +            return ClassFile.read(is);
  27.112 +        } catch (ConstantPoolException e) {
  27.113 +            throw new ClassFileError(e);
  27.114 +        } finally {
  27.115 +            if (is != null) {
  27.116 +                is.close();
  27.117 +            }
  27.118 +        }
  27.119 +    }
  27.120 +
  27.121 +    class FileIterator implements Iterator<ClassFile> {
  27.122 +        int count;
  27.123 +        FileIterator() {
  27.124 +            this.count = 0;
  27.125 +        }
  27.126 +        public boolean hasNext() {
  27.127 +            return count == 0 && baseFileName.endsWith(".class");
  27.128 +        }
  27.129 +
  27.130 +        public ClassFile next() {
  27.131 +            if (!hasNext()) {
  27.132 +                throw new NoSuchElementException();
  27.133 +            }
  27.134 +            try {
  27.135 +                ClassFile cf = readClassFile(path);
  27.136 +                count++;
  27.137 +                return cf;
  27.138 +            } catch (IOException e) {
  27.139 +                throw new ClassFileError(e);
  27.140 +            }
  27.141 +        }
  27.142 +
  27.143 +        public void remove() {
  27.144 +            throw new UnsupportedOperationException("Not supported yet.");
  27.145 +        }
  27.146 +    }
  27.147 +
  27.148 +    public String toString() {
  27.149 +        return path.toString();
  27.150 +    }
  27.151 +
  27.152 +    private static class DirectoryReader extends ClassFileReader {
  27.153 +        DirectoryReader(Path path) throws IOException {
  27.154 +            super(path);
  27.155 +        }
  27.156 +
  27.157 +        public ClassFile getClassFile(String name) throws IOException {
  27.158 +            if (name.indexOf('.') > 0) {
  27.159 +                int i = name.lastIndexOf('.');
  27.160 +                String pathname = name.replace('.', File.separatorChar) + ".class";
  27.161 +                Path p = path.resolve(pathname);
  27.162 +                if (!p.toFile().exists()) {
  27.163 +                    p = path.resolve(pathname.substring(0, i) + "$" +
  27.164 +                                     pathname.substring(i+1, pathname.length()));
  27.165 +                }
  27.166 +                if (p.toFile().exists()) {
  27.167 +                    return readClassFile(p);
  27.168 +                }
  27.169 +            } else {
  27.170 +                Path p = path.resolve(name + ".class");
  27.171 +                if (p.toFile().exists()) {
  27.172 +                    return readClassFile(p);
  27.173 +                }
  27.174 +            }
  27.175 +            return null;
  27.176 +        }
  27.177 +
  27.178 +        public Iterable<ClassFile> getClassFiles() throws IOException {
  27.179 +            final Iterator<ClassFile> iter = new DirectoryIterator();
  27.180 +            return new Iterable<ClassFile>() {
  27.181 +                public Iterator<ClassFile> iterator() {
  27.182 +                    return iter;
  27.183 +                }
  27.184 +            };
  27.185 +        }
  27.186 +
  27.187 +        private List<Path> walkTree(Path dir) throws IOException {
  27.188 +            final List<Path> files = new ArrayList<Path>();
  27.189 +            Files.walkFileTree(dir, new SimpleFileVisitor<Path>() {
  27.190 +                public FileVisitResult visitFile(Path file, BasicFileAttributes attrs)
  27.191 +                        throws IOException {
  27.192 +                    if (file.toFile().getName().endsWith(".class")) {
  27.193 +                        files.add(file);
  27.194 +                    }
  27.195 +                    return FileVisitResult.CONTINUE;
  27.196 +                }
  27.197 +            });
  27.198 +            return files;
  27.199 +        }
  27.200 +
  27.201 +        class DirectoryIterator implements Iterator<ClassFile> {
  27.202 +            private List<Path> entries;
  27.203 +            private int index = 0;
  27.204 +            DirectoryIterator() throws IOException {
  27.205 +                entries = walkTree(path);
  27.206 +                index = 0;
  27.207 +            }
  27.208 +
  27.209 +            public boolean hasNext() {
  27.210 +                return index != entries.size();
  27.211 +            }
  27.212 +
  27.213 +            public ClassFile next() {
  27.214 +                if (!hasNext()) {
  27.215 +                    throw new NoSuchElementException();
  27.216 +                }
  27.217 +                Path path = entries.get(index++);
  27.218 +                try {
  27.219 +                    return readClassFile(path);
  27.220 +                } catch (IOException e) {
  27.221 +                    throw new ClassFileError(e);
  27.222 +                }
  27.223 +            }
  27.224 +
  27.225 +            public void remove() {
  27.226 +                throw new UnsupportedOperationException("Not supported yet.");
  27.227 +            }
  27.228 +        }
  27.229 +    }
  27.230 +
  27.231 +    private static class JarFileReader extends ClassFileReader {
  27.232 +        final JarFile jarfile;
  27.233 +        JarFileReader(Path path) throws IOException {
  27.234 +            super(path);
  27.235 +            this.jarfile = new JarFile(path.toFile());
  27.236 +        }
  27.237 +
  27.238 +        public ClassFile getClassFile(String name) throws IOException {
  27.239 +            if (name.indexOf('.') > 0) {
  27.240 +                int i = name.lastIndexOf('.');
  27.241 +                String entryName = name.replace('.', '/') + ".class";
  27.242 +                JarEntry e = jarfile.getJarEntry(entryName);
  27.243 +                if (e == null) {
  27.244 +                    e = jarfile.getJarEntry(entryName.substring(0, i) + "$"
  27.245 +                            + entryName.substring(i + 1, entryName.length()));
  27.246 +                }
  27.247 +                if (e != null) {
  27.248 +                    return readClassFile(e);
  27.249 +                }
  27.250 +            } else {
  27.251 +                JarEntry e = jarfile.getJarEntry(name + ".class");
  27.252 +                if (e != null) {
  27.253 +                    return readClassFile(e);
  27.254 +                }
  27.255 +            }
  27.256 +            return null;
  27.257 +        }
  27.258 +
  27.259 +        private ClassFile readClassFile(JarEntry e) throws IOException {
  27.260 +            InputStream is = null;
  27.261 +            try {
  27.262 +                is = jarfile.getInputStream(e);
  27.263 +                return ClassFile.read(is);
  27.264 +            } catch (ConstantPoolException ex) {
  27.265 +                throw new ClassFileError(ex);
  27.266 +            } finally {
  27.267 +                if (is != null)
  27.268 +                    is.close();
  27.269 +            }
  27.270 +        }
  27.271 +
  27.272 +        public Iterable<ClassFile> getClassFiles() throws IOException {
  27.273 +            final Iterator<ClassFile> iter = new JarFileIterator();
  27.274 +            return new Iterable<ClassFile>() {
  27.275 +                public Iterator<ClassFile> iterator() {
  27.276 +                    return iter;
  27.277 +                }
  27.278 +            };
  27.279 +        }
  27.280 +
  27.281 +        class JarFileIterator implements Iterator<ClassFile> {
  27.282 +            private Enumeration<JarEntry> entries;
  27.283 +            private JarEntry nextEntry;
  27.284 +            JarFileIterator() {
  27.285 +                this.entries = jarfile.entries();
  27.286 +                while (entries.hasMoreElements()) {
  27.287 +                    JarEntry e = entries.nextElement();
  27.288 +                    String name = e.getName();
  27.289 +                    if (name.endsWith(".class")) {
  27.290 +                        this.nextEntry = e;
  27.291 +                        break;
  27.292 +                    }
  27.293 +                }
  27.294 +            }
  27.295 +
  27.296 +            public boolean hasNext() {
  27.297 +                return nextEntry != null;
  27.298 +            }
  27.299 +
  27.300 +            public ClassFile next() {
  27.301 +                if (!hasNext()) {
  27.302 +                    throw new NoSuchElementException();
  27.303 +                }
  27.304 +
  27.305 +                ClassFile cf;
  27.306 +                try {
  27.307 +                    cf = readClassFile(nextEntry);
  27.308 +                } catch (IOException ex) {
  27.309 +                    throw new ClassFileError(ex);
  27.310 +                }
  27.311 +                JarEntry entry = nextEntry;
  27.312 +                nextEntry = null;
  27.313 +                while (entries.hasMoreElements()) {
  27.314 +                    JarEntry e = entries.nextElement();
  27.315 +                    String name = e.getName();
  27.316 +                    if (name.endsWith(".class")) {
  27.317 +                        nextEntry = e;
  27.318 +                        break;
  27.319 +                    }
  27.320 +                }
  27.321 +                return cf;
  27.322 +            }
  27.323 +
  27.324 +            public void remove() {
  27.325 +                throw new UnsupportedOperationException("Not supported yet.");
  27.326 +            }
  27.327 +        }
  27.328 +    }
  27.329 +}
    28.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
    28.2 +++ b/src/share/classes/com/sun/tools/jdeps/JdepsTask.java	Thu Jan 10 15:53:02 2013 -0800
    28.3 @@ -0,0 +1,650 @@
    28.4 +/*
    28.5 + * Copyright (c) 2012, Oracle and/or its affiliates. All rights reserved.
    28.6 + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
    28.7 + *
    28.8 + * This code is free software; you can redistribute it and/or modify it
    28.9 + * under the terms of the GNU General Public License version 2 only, as
   28.10 + * published by the Free Software Foundation.  Oracle designates this
   28.11 + * particular file as subject to the "Classpath" exception as provided
   28.12 + * by Oracle in the LICENSE file that accompanied this code.
   28.13 + *
   28.14 + * This code is distributed in the hope that it will be useful, but WITHOUT
   28.15 + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
   28.16 + * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
   28.17 + * version 2 for more details (a copy is included in the LICENSE file that
   28.18 + * accompanied this code).
   28.19 + *
   28.20 + * You should have received a copy of the GNU General Public License version
   28.21 + * 2 along with this work; if not, write to the Free Software Foundation,
   28.22 + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
   28.23 + *
   28.24 + * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
   28.25 + * or visit www.oracle.com if you need additional information or have any
   28.26 + * questions.
   28.27 + */
   28.28 +package com.sun.tools.jdeps;
   28.29 +
   28.30 +import com.sun.tools.classfile.ClassFile;
   28.31 +import com.sun.tools.classfile.ConstantPoolException;
   28.32 +import com.sun.tools.classfile.Dependencies;
   28.33 +import com.sun.tools.classfile.Dependencies.ClassFileError;
   28.34 +import com.sun.tools.classfile.Dependency;
   28.35 +import com.sun.tools.classfile.Dependency.Location;
   28.36 +import java.io.*;
   28.37 +import java.text.MessageFormat;
   28.38 +import java.util.*;
   28.39 +import java.util.regex.Pattern;
   28.40 +
   28.41 +/**
   28.42 + * Implementation for the jdeps tool for static class dependency analysis.
   28.43 + */
   28.44 +class JdepsTask {
   28.45 +    class BadArgs extends Exception {
   28.46 +        static final long serialVersionUID = 8765093759964640721L;
   28.47 +        BadArgs(String key, Object... args) {
   28.48 +            super(JdepsTask.this.getMessage(key, args));
   28.49 +            this.key = key;
   28.50 +            this.args = args;
   28.51 +        }
   28.52 +
   28.53 +        BadArgs showUsage(boolean b) {
   28.54 +            showUsage = b;
   28.55 +            return this;
   28.56 +        }
   28.57 +        final String key;
   28.58 +        final Object[] args;
   28.59 +        boolean showUsage;
   28.60 +    }
   28.61 +
   28.62 +    static abstract class Option {
   28.63 +        Option(boolean hasArg, String... aliases) {
   28.64 +            this.hasArg = hasArg;
   28.65 +            this.aliases = aliases;
   28.66 +        }
   28.67 +
   28.68 +        boolean isHidden() {
   28.69 +            return false;
   28.70 +        }
   28.71 +
   28.72 +        boolean matches(String opt) {
   28.73 +            for (String a : aliases) {
   28.74 +                if (a.equals(opt)) {
   28.75 +                    return true;
   28.76 +                } else if (opt.startsWith("--") && hasArg && opt.startsWith(a + "=")) {
   28.77 +                    return true;
   28.78 +                }
   28.79 +            }
   28.80 +            return false;
   28.81 +        }
   28.82 +
   28.83 +        boolean ignoreRest() {
   28.84 +            return false;
   28.85 +        }
   28.86 +
   28.87 +        abstract void process(JdepsTask task, String opt, String arg) throws BadArgs;
   28.88 +        final boolean hasArg;
   28.89 +        final String[] aliases;
   28.90 +    }
   28.91 +
   28.92 +    static abstract class HiddenOption extends Option {
   28.93 +        HiddenOption(boolean hasArg, String... aliases) {
   28.94 +            super(hasArg, aliases);
   28.95 +        }
   28.96 +
   28.97 +        boolean isHidden() {
   28.98 +            return true;
   28.99 +        }
  28.100 +    }
  28.101 +
  28.102 +    static Option[] recognizedOptions = {
  28.103 +        new Option(false, "-h", "-?", "--help") {
  28.104 +            void process(JdepsTask task, String opt, String arg) {
  28.105 +                task.options.help = true;
  28.106 +            }
  28.107 +        },
  28.108 +        new Option(false, "-s", "--summary") {
  28.109 +            void process(JdepsTask task, String opt, String arg) {
  28.110 +                task.options.showSummary = true;
  28.111 +                task.options.verbose = Options.Verbose.SUMMARY;
  28.112 +            }
  28.113 +        },
  28.114 +        new Option(false, "-v", "--verbose") {
  28.115 +            void process(JdepsTask task, String opt, String arg) {
  28.116 +                task.options.verbose = Options.Verbose.VERBOSE;
  28.117 +            }
  28.118 +        },
  28.119 +        new Option(true, "-V", "--verbose-level") {
  28.120 +            void process(JdepsTask task, String opt, String arg) throws BadArgs {
  28.121 +                switch (arg) {
  28.122 +                    case "package":
  28.123 +                        task.options.verbose = Options.Verbose.PACKAGE;
  28.124 +                        break;
  28.125 +                    case "class":
  28.126 +                        task.options.verbose = Options.Verbose.CLASS;
  28.127 +                        break;
  28.128 +                    default:
  28.129 +                        throw task.new BadArgs("err.invalid.arg.for.option", opt);
  28.130 +                }
  28.131 +            }
  28.132 +        },
  28.133 +        new Option(true, "-c", "--classpath") {
  28.134 +            void process(JdepsTask task, String opt, String arg) {
  28.135 +                task.options.classpath = arg;
  28.136 +            }
  28.137 +        },
  28.138 +        new Option(true, "-p", "--package") {
  28.139 +            void process(JdepsTask task, String opt, String arg) {
  28.140 +                task.options.packageNames.add(arg);
  28.141 +            }
  28.142 +        },
  28.143 +        new Option(true, "-e", "--regex") {
  28.144 +            void process(JdepsTask task, String opt, String arg) {
  28.145 +                task.options.regex = arg;
  28.146 +            }
  28.147 +        },
  28.148 +        new Option(false, "-P", "--profile") {
  28.149 +            void process(JdepsTask task, String opt, String arg) {
  28.150 +                task.options.showProfile = true;
  28.151 +            }
  28.152 +        },
  28.153 +        new Option(false, "-R", "--recursive") {
  28.154 +            void process(JdepsTask task, String opt, String arg) {
  28.155 +                task.options.depth = 0;
  28.156 +            }
  28.157 +        },
  28.158 +        new HiddenOption(true, "-d", "--depth") {
  28.159 +            void process(JdepsTask task, String opt, String arg) throws BadArgs {
  28.160 +                try {
  28.161 +                    task.options.depth = Integer.parseInt(arg);
  28.162 +                } catch (NumberFormatException e) {
  28.163 +                    throw task.new BadArgs("err.invalid.arg.for.option", opt);
  28.164 +                }
  28.165 +            }
  28.166 +        },
  28.167 +        new Option(false, "--version") {
  28.168 +            void process(JdepsTask task, String opt, String arg) {
  28.169 +                task.options.version = true;
  28.170 +            }
  28.171 +        },
  28.172 +        new HiddenOption(false, "--fullversion") {
  28.173 +            void process(JdepsTask task, String opt, String arg) {
  28.174 +                task.options.fullVersion = true;
  28.175 +            }
  28.176 +        },
  28.177 +
  28.178 +    };
  28.179 +
  28.180 +    private static final String PROGNAME = "jdeps";
  28.181 +    private final Options options = new Options();
  28.182 +    private final List<String> classes = new ArrayList<String>();
  28.183 +
  28.184 +    private PrintWriter log;
  28.185 +    void setLog(PrintWriter out) {
  28.186 +        log = out;
  28.187 +    }
  28.188 +
  28.189 +    /**
  28.190 +     * Result codes.
  28.191 +     */
  28.192 +    static final int EXIT_OK = 0, // Completed with no errors.
  28.193 +                     EXIT_ERROR = 1, // Completed but reported errors.
  28.194 +                     EXIT_CMDERR = 2, // Bad command-line arguments
  28.195 +                     EXIT_SYSERR = 3, // System error or resource exhaustion.
  28.196 +                     EXIT_ABNORMAL = 4;// terminated abnormally
  28.197 +
  28.198 +    int run(String[] args) {
  28.199 +        if (log == null) {
  28.200 +            log = new PrintWriter(System.out);
  28.201 +        }
  28.202 +        try {
  28.203 +            handleOptions(args);
  28.204 +            if (options.help) {
  28.205 +                showHelp();
  28.206 +            }
  28.207 +            if (options.version || options.fullVersion) {
  28.208 +                showVersion(options.fullVersion);
  28.209 +            }
  28.210 +            if (classes.isEmpty() && !options.wildcard) {
  28.211 +                if (options.help || options.version || options.fullVersion) {
  28.212 +                    return EXIT_OK;
  28.213 +                } else {
  28.214 +                    showHelp();
  28.215 +                    return EXIT_CMDERR;
  28.216 +                }
  28.217 +            }
  28.218 +            if (options.regex != null && options.packageNames.size() > 0) {
  28.219 +                showHelp();
  28.220 +                return EXIT_CMDERR;
  28.221 +            }
  28.222 +            if (options.showSummary && options.verbose != Options.Verbose.SUMMARY) {
  28.223 +                showHelp();
  28.224 +                return EXIT_CMDERR;
  28.225 +            }
  28.226 +            boolean ok = run();
  28.227 +            return ok ? EXIT_OK : EXIT_ERROR;
  28.228 +        } catch (BadArgs e) {
  28.229 +            reportError(e.key, e.args);
  28.230 +            if (e.showUsage) {
  28.231 +                log.println(getMessage("main.usage.summary", PROGNAME));
  28.232 +            }
  28.233 +            return EXIT_CMDERR;
  28.234 +        } catch (IOException e) {
  28.235 +            return EXIT_ABNORMAL;
  28.236 +        } finally {
  28.237 +            log.flush();
  28.238 +        }
  28.239 +    }
  28.240 +
  28.241 +    private final List<Archive> sourceLocations = new ArrayList<Archive>();
  28.242 +    private final Archive NOT_FOUND = new Archive(getMessage("artifact.not.found"));
  28.243 +    private boolean run() throws IOException {
  28.244 +        findDependencies();
  28.245 +        switch (options.verbose) {
  28.246 +            case VERBOSE:
  28.247 +            case CLASS:
  28.248 +                printClassDeps(log);
  28.249 +                break;
  28.250 +            case PACKAGE:
  28.251 +                printPackageDeps(log);
  28.252 +                break;
  28.253 +            case SUMMARY:
  28.254 +                for (Archive origin : sourceLocations) {
  28.255 +                    for (Archive target : origin.getRequiredArchives()) {
  28.256 +                        log.format("%-30s -> %s%n", origin, target);
  28.257 +                    }
  28.258 +                }
  28.259 +                break;
  28.260 +            default:
  28.261 +                throw new InternalError("Should not reach here");
  28.262 +        }
  28.263 +        return true;
  28.264 +    }
  28.265 +
  28.266 +    private boolean isValidClassName(String name) {
  28.267 +        if (!Character.isJavaIdentifierStart(name.charAt(0))) {
  28.268 +            return false;
  28.269 +        }
  28.270 +        for (int i=1; i < name.length(); i++) {
  28.271 +            char c = name.charAt(i);
  28.272 +            if (c != '.'  && !Character.isJavaIdentifierPart(c)) {
  28.273 +                return false;
  28.274 +            }
  28.275 +        }
  28.276 +        return true;
  28.277 +    }
  28.278 +
  28.279 +    private void findDependencies() throws IOException {
  28.280 +        Dependency.Finder finder = Dependencies.getClassDependencyFinder();
  28.281 +        Dependency.Filter filter;
  28.282 +        if (options.regex != null) {
  28.283 +            filter = Dependencies.getRegexFilter(Pattern.compile(options.regex));
  28.284 +        } else if (options.packageNames.size() > 0) {
  28.285 +            filter = Dependencies.getPackageFilter(options.packageNames, false);
  28.286 +        } else {
  28.287 +            filter = new Dependency.Filter() {
  28.288 +                public boolean accepts(Dependency dependency) {
  28.289 +                    return !dependency.getOrigin().equals(dependency.getTarget());
  28.290 +                }
  28.291 +            };
  28.292 +        }
  28.293 +
  28.294 +        List<Archive> archives = new ArrayList<Archive>();
  28.295 +        Deque<String> roots = new LinkedList<String>();
  28.296 +        for (String s : classes) {
  28.297 +            File f = new File(s);
  28.298 +            if (f.exists()) {
  28.299 +                archives.add(new Archive(f, ClassFileReader.newInstance(f)));
  28.300 +            } else {
  28.301 +                if (isValidClassName(s)) {
  28.302 +                    roots.add(s);
  28.303 +                } else {
  28.304 +                    warning("warn.invalid.arg", s);
  28.305 +                }
  28.306 +            }
  28.307 +        }
  28.308 +
  28.309 +        List<Archive> classpaths = new ArrayList<Archive>(); // for class file lookup
  28.310 +        if (options.wildcard) {
  28.311 +            // include all archives from classpath to the initial list
  28.312 +            archives.addAll(getClassPathArchives(options.classpath));
  28.313 +        } else {
  28.314 +            classpaths.addAll(getClassPathArchives(options.classpath));
  28.315 +        }
  28.316 +        classpaths.addAll(PlatformClassPath.getArchives());
  28.317 +
  28.318 +        // add all archives to the source locations for reporting
  28.319 +        sourceLocations.addAll(archives);
  28.320 +        sourceLocations.addAll(classpaths);
  28.321 +
  28.322 +        // Work queue of names of classfiles to be searched.
  28.323 +        // Entries will be unique, and for classes that do not yet have
  28.324 +        // dependencies in the results map.
  28.325 +        Deque<String> deque = new LinkedList<String>();
  28.326 +        Set<String> doneClasses = new HashSet<String>();
  28.327 +
  28.328 +        // get the immediate dependencies of the input files
  28.329 +        for (Archive a : archives) {
  28.330 +            for (ClassFile cf : a.reader().getClassFiles()) {
  28.331 +                String classFileName;
  28.332 +                try {
  28.333 +                    classFileName = cf.getName();
  28.334 +                } catch (ConstantPoolException e) {
  28.335 +                    throw new ClassFileError(e);
  28.336 +                }
  28.337 +                a.addClass(classFileName);
  28.338 +                if (!doneClasses.contains(classFileName)) {
  28.339 +                    doneClasses.add(classFileName);
  28.340 +                }
  28.341 +                for (Dependency d : finder.findDependencies(cf)) {
  28.342 +                    if (filter.accepts(d)) {
  28.343 +                        String cn = d.getTarget().getName();
  28.344 +                        if (!doneClasses.contains(cn) && !deque.contains(cn)) {
  28.345 +                            deque.add(cn);
  28.346 +                        }
  28.347 +                        a.addDependency(d);
  28.348 +                    }
  28.349 +                }
  28.350 +            }
  28.351 +        }
  28.352 +
  28.353 +        // add Archive for looking up classes from the classpath
  28.354 +        // for transitive dependency analysis
  28.355 +        Deque<String> unresolved = roots;
  28.356 +        int depth = options.depth > 0 ? options.depth : Integer.MAX_VALUE;
  28.357 +        do {
  28.358 +            String name;
  28.359 +            while ((name = unresolved.poll()) != null) {
  28.360 +                if (doneClasses.contains(name)) {
  28.361 +                    continue;
  28.362 +                }
  28.363 +                ClassFile cf = null;
  28.364 +                for (Archive a : classpaths) {
  28.365 +                    cf = a.reader().getClassFile(name);
  28.366 +                    if (cf != null) {
  28.367 +                        String classFileName;
  28.368 +                        try {
  28.369 +                            classFileName = cf.getName();
  28.370 +                        } catch (ConstantPoolException e) {
  28.371 +                            throw new ClassFileError(e);
  28.372 +                        }
  28.373 +                        a.addClass(classFileName);
  28.374 +                        if (!doneClasses.contains(classFileName)) {
  28.375 +                            // if name is a fully-qualified class name specified
  28.376 +                            // from command-line, this class might already be parsed
  28.377 +                            doneClasses.add(classFileName);
  28.378 +                            if (depth > 0) {
  28.379 +                                for (Dependency d : finder.findDependencies(cf)) {
  28.380 +                                    if (filter.accepts(d)) {
  28.381 +                                        String cn = d.getTarget().getName();
  28.382 +                                        if (!doneClasses.contains(cn) && !deque.contains(cn)) {
  28.383 +                                            deque.add(cn);
  28.384 +                                        }
  28.385 +                                        a.addDependency(d);
  28.386 +                                    }
  28.387 +                                }
  28.388 +                            }
  28.389 +                        }
  28.390 +                        break;
  28.391 +                    }
  28.392 +                }
  28.393 +                if (cf == null) {
  28.394 +                    NOT_FOUND.addClass(name);
  28.395 +                }
  28.396 +            }
  28.397 +            unresolved = deque;
  28.398 +            deque = new LinkedList<String>();
  28.399 +        } while (!unresolved.isEmpty() && depth-- > 0);
  28.400 +    }
  28.401 +
  28.402 +    private void printPackageDeps(PrintWriter out) {
  28.403 +        for (Archive source : sourceLocations) {
  28.404 +            SortedMap<Location, SortedSet<Location>> deps = source.getDependencies();
  28.405 +            if (deps.isEmpty())
  28.406 +                continue;
  28.407 +
  28.408 +            for (Archive target : source.getRequiredArchives()) {
  28.409 +                out.format("%s -> %s%n", source, target);
  28.410 +            }
  28.411 +
  28.412 +            Map<String, Archive> pkgs = new TreeMap<String, Archive>();
  28.413 +            SortedMap<String, Archive> targets = new TreeMap<String, Archive>();
  28.414 +            String pkg = "";
  28.415 +            for (Map.Entry<Location, SortedSet<Location>> e : deps.entrySet()) {
  28.416 +                String cn = e.getKey().getClassName();
  28.417 +                String p = packageOf(e.getKey());
  28.418 +                Archive origin = Archive.find(e.getKey());
  28.419 +                assert origin != null;
  28.420 +                if (!pkgs.containsKey(p)) {
  28.421 +                    pkgs.put(p, origin);
  28.422 +                } else if (pkgs.get(p) != origin) {
  28.423 +                    warning("warn.split.package", p, origin, pkgs.get(p));
  28.424 +                }
  28.425 +
  28.426 +                if (!p.equals(pkg)) {
  28.427 +                    printTargets(out, targets);
  28.428 +                    pkg = p;
  28.429 +                    targets.clear();
  28.430 +                    out.format("   %s (%s)%n", p, origin.getFileName());
  28.431 +                }
  28.432 +
  28.433 +                for (Location t : e.getValue()) {
  28.434 +                    p = packageOf(t);
  28.435 +                    Archive target = Archive.find(t);
  28.436 +                    if (!targets.containsKey(p)) {
  28.437 +                        targets.put(p, target);
  28.438 +                    }
  28.439 +                }
  28.440 +            }
  28.441 +            printTargets(out, targets);
  28.442 +            out.println();
  28.443 +        }
  28.444 +    }
  28.445 +
  28.446 +    private void printTargets(PrintWriter out, Map<String, Archive> targets) {
  28.447 +        for (Map.Entry<String, Archive> t : targets.entrySet()) {
  28.448 +            String pn = t.getKey();
  28.449 +            out.format("      -> %-40s %s%n", pn, getPackageInfo(pn, t.getValue()));
  28.450 +        }
  28.451 +    }
  28.452 +
  28.453 +    private String getPackageInfo(String pn, Archive source) {
  28.454 +        if (PlatformClassPath.contains(source)) {
  28.455 +            String name = PlatformClassPath.getProfileName(pn);
  28.456 +            if (name.isEmpty()) {
  28.457 +                return "JDK internal API (" + source.getFileName() + ")";
  28.458 +            }
  28.459 +            return options.showProfile ? name : "";
  28.460 +        }
  28.461 +        return source.getFileName();
  28.462 +    }
  28.463 +
  28.464 +    private static String packageOf(Location loc) {
  28.465 +        String pkg = loc.getPackageName();
  28.466 +        return pkg.isEmpty() ? "<unnamed>" : pkg;
  28.467 +    }
  28.468 +
  28.469 +    private void printClassDeps(PrintWriter out) {
  28.470 +        for (Archive source : sourceLocations) {
  28.471 +            SortedMap<Location, SortedSet<Location>> deps = source.getDependencies();
  28.472 +            if (deps.isEmpty())
  28.473 +                continue;
  28.474 +
  28.475 +            for (Archive target : source.getRequiredArchives()) {
  28.476 +                out.format("%s -> %s%n", source, target);
  28.477 +            }
  28.478 +            out.format("%s%n", source);
  28.479 +            for (Map.Entry<Location, SortedSet<Location>> e : deps.entrySet()) {
  28.480 +                String cn = e.getKey().getClassName();
  28.481 +                Archive origin = Archive.find(e.getKey());
  28.482 +                out.format("   %s (%s)%n", cn, origin.getFileName());
  28.483 +                for (Location t : e.getValue()) {
  28.484 +                    cn = t.getClassName();
  28.485 +                    Archive target = Archive.find(t);
  28.486 +                    out.format("      -> %-60s %s%n", cn, getPackageInfo(t.getPackageName(), target));
  28.487 +                }
  28.488 +            }
  28.489 +            out.println();
  28.490 +        }
  28.491 +    }
  28.492 +    public void handleOptions(String[] args) throws BadArgs {
  28.493 +        // process options
  28.494 +        for (int i=0; i < args.length; i++) {
  28.495 +            if (args[i].charAt(0) == '-') {
  28.496 +                String name = args[i];
  28.497 +                Option option = getOption(name);
  28.498 +                String param = null;
  28.499 +                if (option.hasArg) {
  28.500 +                    if (name.startsWith("--") && name.indexOf('=') > 0) {
  28.501 +                        param = name.substring(name.indexOf('=') + 1, name.length());
  28.502 +                    } else if (i + 1 < args.length) {
  28.503 +                        param = args[++i];
  28.504 +                    }
  28.505 +                    if (param == null || param.isEmpty() || param.charAt(0) == '-') {
  28.506 +                        throw new BadArgs("err.missing.arg", name).showUsage(true);
  28.507 +                    }
  28.508 +                }
  28.509 +                option.process(this, name, param);
  28.510 +                if (option.ignoreRest()) {
  28.511 +                    i = args.length;
  28.512 +                }
  28.513 +            } else {
  28.514 +                // process rest of the input arguments
  28.515 +                for (; i < args.length; i++) {
  28.516 +                    String name = args[i];
  28.517 +                    if (name.charAt(0) == '-') {
  28.518 +                        throw new BadArgs("err.option.after.class", name).showUsage(true);
  28.519 +                    }
  28.520 +                    if (name.equals("*") || name.equals("\"*\"")) {
  28.521 +                        options.wildcard = true;
  28.522 +                    } else {
  28.523 +                        classes.add(name);
  28.524 +                    }
  28.525 +                }
  28.526 +            }
  28.527 +        }
  28.528 +    }
  28.529 +
  28.530 +    private Option getOption(String name) throws BadArgs {
  28.531 +        for (Option o : recognizedOptions) {
  28.532 +            if (o.matches(name)) {
  28.533 +                return o;
  28.534 +            }
  28.535 +        }
  28.536 +        throw new BadArgs("err.unknown.option", name).showUsage(true);
  28.537 +    }
  28.538 +
  28.539 +    private void reportError(String key, Object... args) {
  28.540 +        log.println(getMessage("error.prefix") + " " + getMessage(key, args));
  28.541 +    }
  28.542 +
  28.543 +    private void warning(String key, Object... args) {
  28.544 +        log.println(getMessage("warn.prefix") + " " + getMessage(key, args));
  28.545 +    }
  28.546 +
  28.547 +    private void showHelp() {
  28.548 +        log.println(getMessage("main.usage", PROGNAME));
  28.549 +        for (Option o : recognizedOptions) {
  28.550 +            String name = o.aliases[0].substring(1); // there must always be at least one name
  28.551 +            name = name.charAt(0) == '-' ? name.substring(1) : name;
  28.552 +            if (o.isHidden() || name.equals("h")) {
  28.553 +                continue;
  28.554 +            }
  28.555 +            log.println(getMessage("main.opt." + name));
  28.556 +        }
  28.557 +    }
  28.558 +
  28.559 +    private void showVersion(boolean full) {
  28.560 +        log.println(version(full ? "full" : "release"));
  28.561 +    }
  28.562 +
  28.563 +    private String version(String key) {
  28.564 +        // key=version:  mm.nn.oo[-milestone]
  28.565 +        // key=full:     mm.mm.oo[-milestone]-build
  28.566 +        if (ResourceBundleHelper.versionRB == null) {
  28.567 +            return System.getProperty("java.version");
  28.568 +        }
  28.569 +        try {
  28.570 +            return ResourceBundleHelper.versionRB.getString(key);
  28.571 +        } catch (MissingResourceException e) {
  28.572 +            return getMessage("version.unknown", System.getProperty("java.version"));
  28.573 +        }
  28.574 +    }
  28.575 +
  28.576 +    public String getMessage(String key, Object... args) {
  28.577 +        try {
  28.578 +            return MessageFormat.format(ResourceBundleHelper.bundle.getString(key), args);
  28.579 +        } catch (MissingResourceException e) {
  28.580 +            throw new InternalError("Missing message: " + key);
  28.581 +        }
  28.582 +    }
  28.583 +
  28.584 +    private static class Options {
  28.585 +        enum Verbose {
  28.586 +            CLASS,
  28.587 +            PACKAGE,
  28.588 +            SUMMARY,
  28.589 +            VERBOSE
  28.590 +        };
  28.591 +
  28.592 +        boolean help;
  28.593 +        boolean version;
  28.594 +        boolean fullVersion;
  28.595 +        boolean showFlags;
  28.596 +        boolean showProfile;
  28.597 +        boolean showSummary;
  28.598 +        boolean wildcard;
  28.599 +        String regex;
  28.600 +        String classpath = "";
  28.601 +        int depth = 1;
  28.602 +        Verbose verbose = Verbose.PACKAGE;
  28.603 +        Set<String> packageNames = new HashSet<String>();
  28.604 +    }
  28.605 +
  28.606 +    private static class ResourceBundleHelper {
  28.607 +        static final ResourceBundle versionRB;
  28.608 +        static final ResourceBundle bundle;
  28.609 +
  28.610 +        static {
  28.611 +            Locale locale = Locale.getDefault();
  28.612 +            try {
  28.613 +                bundle = ResourceBundle.getBundle("com.sun.tools.jdeps.resources.jdeps", locale);
  28.614 +            } catch (MissingResourceException e) {
  28.615 +                throw new InternalError("Cannot find jdeps resource bundle for locale " + locale);
  28.616 +            }
  28.617 +            try {
  28.618 +                versionRB = ResourceBundle.getBundle("com.sun.tools.jdeps.resources.version");
  28.619 +            } catch (MissingResourceException e) {
  28.620 +                throw new InternalError("version.resource.missing");
  28.621 +            }
  28.622 +        }
  28.623 +    }
  28.624 +
  28.625 +    private List<Archive> getArchives(List<String> filenames) throws IOException {
  28.626 +        List<Archive> result = new ArrayList<Archive>();
  28.627 +        for (String s : filenames) {
  28.628 +            File f = new File(s);
  28.629 +            if (f.exists()) {
  28.630 +                result.add(new Archive(f, ClassFileReader.newInstance(f)));
  28.631 +            } else {
  28.632 +                warning("warn.file.not.exist", s);
  28.633 +            }
  28.634 +        }
  28.635 +        return result;
  28.636 +    }
  28.637 +
  28.638 +    private List<Archive> getClassPathArchives(String paths) throws IOException {
  28.639 +        List<Archive> result = new ArrayList<Archive>();
  28.640 +        if (paths.isEmpty()) {
  28.641 +            return result;
  28.642 +        }
  28.643 +        for (String p : paths.split(File.pathSeparator)) {
  28.644 +            if (p.length() > 0) {
  28.645 +                File f = new File(p);
  28.646 +                if (f.exists()) {
  28.647 +                    result.add(new Archive(f, ClassFileReader.newInstance(f)));
  28.648 +                }
  28.649 +            }
  28.650 +        }
  28.651 +        return result;
  28.652 +    }
  28.653 +}
    29.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
    29.2 +++ b/src/share/classes/com/sun/tools/jdeps/Main.java	Thu Jan 10 15:53:02 2013 -0800
    29.3 @@ -0,0 +1,66 @@
    29.4 +/*
    29.5 + * Copyright (c) 2012, Oracle and/or its affiliates. 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.  Oracle designates this
   29.11 + * particular file as subject to the "Classpath" exception as provided
   29.12 + * by Oracle in the LICENSE file that accompanied this code.
   29.13 + *
   29.14 + * This code is distributed in the hope that it will be useful, but WITHOUT
   29.15 + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
   29.16 + * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
   29.17 + * version 2 for more details (a copy is included in the LICENSE file that
   29.18 + * accompanied this code).
   29.19 + *
   29.20 + * You should have received a copy of the GNU General Public License version
   29.21 + * 2 along with this work; if not, write to the Free Software Foundation,
   29.22 + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
   29.23 + *
   29.24 + * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
   29.25 + * or visit www.oracle.com if you need additional information or have any
   29.26 + * questions.
   29.27 + */
   29.28 +
   29.29 +package com.sun.tools.jdeps;
   29.30 +
   29.31 +import java.io.*;
   29.32 +
   29.33 +/**
   29.34 + *
   29.35 + * Usage:
   29.36 + *    jdeps [options] files ...
   29.37 + * where options include:
   29.38 + *    -p package-name   restrict analysis to classes in this package
   29.39 + *                      (may be given multiple times)
   29.40 + *    -e regex          restrict analysis to packages matching pattern
   29.41 + *                      (-p and -e are exclusive)
   29.42 + *    -v                show class-level dependencies
   29.43 + *                      default: package-level dependencies
   29.44 + *    -r --recursive    transitive dependencies analysis
   29.45 + *    -classpath paths  Classpath to locate class files
   29.46 + *    -all              process all class files in the given classpath
   29.47 + */
   29.48 +public class Main {
   29.49 +    public static void main(String... args) throws Exception {
   29.50 +        JdepsTask t = new JdepsTask();
   29.51 +        int rc = t.run(args);
   29.52 +        System.exit(rc);
   29.53 +    }
   29.54 +
   29.55 +
   29.56 +    /**
   29.57 +     * Entry point that does <i>not</i> call System.exit.
   29.58 +     *
   29.59 +     * @param args command line arguments
   29.60 +     * @param out output stream
   29.61 +     * @return an exit code. 0 means success, non-zero means an error occurred.
   29.62 +     */
   29.63 +    public static int run(String[] args, PrintWriter out) {
   29.64 +        JdepsTask t = new JdepsTask();
   29.65 +        t.setLog(out);
   29.66 +        return t.run(args);
   29.67 +    }
   29.68 +}
   29.69 +
    30.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
    30.2 +++ b/src/share/classes/com/sun/tools/jdeps/PlatformClassPath.java	Thu Jan 10 15:53:02 2013 -0800
    30.3 @@ -0,0 +1,169 @@
    30.4 +/*
    30.5 + * Copyright (c) 2012, Oracle and/or its affiliates. All rights reserved.
    30.6 + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
    30.7 + *
    30.8 + * This code is free software; you can redistribute it and/or modify it
    30.9 + * under the terms of the GNU General Public License version 2 only, as
   30.10 + * published by the Free Software Foundation.  Oracle designates this
   30.11 + * particular file as subject to the "Classpath" exception as provided
   30.12 + * by Oracle in the LICENSE file that accompanied this code.
   30.13 + *
   30.14 + * This code is distributed in the hope that it will be useful, but WITHOUT
   30.15 + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
   30.16 + * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
   30.17 + * version 2 for more details (a copy is included in the LICENSE file that
   30.18 + * accompanied this code).
   30.19 + *
   30.20 + * You should have received a copy of the GNU General Public License version
   30.21 + * 2 along with this work; if not, write to the Free Software Foundation,
   30.22 + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
   30.23 + *
   30.24 + * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
   30.25 + * or visit www.oracle.com if you need additional information or have any
   30.26 + * questions.
   30.27 + */
   30.28 +package com.sun.tools.jdeps;
   30.29 +
   30.30 +import java.io.File;
   30.31 +import java.io.IOException;
   30.32 +import java.nio.file.FileVisitResult;
   30.33 +import java.nio.file.Files;
   30.34 +import java.nio.file.Path;
   30.35 +import java.nio.file.SimpleFileVisitor;
   30.36 +import java.nio.file.attribute.BasicFileAttributes;
   30.37 +import java.util.*;
   30.38 +
   30.39 +/**
   30.40 + * ClassPath for Java SE and JDK
   30.41 + */
   30.42 +class PlatformClassPath {
   30.43 +    /*
   30.44 +     * Profiles for Java SE
   30.45 +     *
   30.46 +     * This is a temporary workaround until a common API is defined for langtools
   30.47 +     * to determine which profile a given classname belongs to.  The list of
   30.48 +     * packages and profile names are hardcoded in jdk.properties and
   30.49 +     * split packages are not supported.
   30.50 +     */
   30.51 +    static class Profile {
   30.52 +        final String name;
   30.53 +        final Set<String> packages;
   30.54 +
   30.55 +        Profile(String name) {
   30.56 +            this.name = name;
   30.57 +            this.packages = new HashSet<String>();
   30.58 +        }
   30.59 +    }
   30.60 +
   30.61 +    private final static String JAVAFX = "javafx";
   30.62 +    private final static Map<String,Profile> map = getProfilePackages();
   30.63 +    static String getProfileName(String packageName) {
   30.64 +        Profile profile = map.get(packageName);
   30.65 +        if (packageName.startsWith(JAVAFX + ".")) {
   30.66 +            profile = map.get(JAVAFX);
   30.67 +        }
   30.68 +        return profile != null ? profile.name : "";
   30.69 +    }
   30.70 +
   30.71 +    private final static List<Archive> javaHomeArchives = init();
   30.72 +    static List<Archive> getArchives() {
   30.73 +        return javaHomeArchives;
   30.74 +    }
   30.75 +
   30.76 +    static boolean contains(Archive archive) {
   30.77 +        return javaHomeArchives.contains(archive);
   30.78 +    }
   30.79 +
   30.80 +    private static List<Archive> init() {
   30.81 +        List<Archive> result = new ArrayList<Archive>();
   30.82 +        String javaHome = System.getProperty("java.home");
   30.83 +        List<File> files = new ArrayList<File>();
   30.84 +        File jre = new File(javaHome, "jre");
   30.85 +        File lib = new File(javaHome, "lib");
   30.86 +
   30.87 +        try {
   30.88 +            if (jre.exists() && jre.isDirectory()) {
   30.89 +                result.addAll(addJarFiles(new File(jre, "lib")));
   30.90 +                result.addAll(addJarFiles(lib));
   30.91 +            } else if (lib.exists() && lib.isDirectory()) {
   30.92 +                // either a JRE or a jdk build image
   30.93 +                File classes = new File(javaHome, "classes");
   30.94 +                if (classes.exists() && classes.isDirectory()) {
   30.95 +                    // jdk build outputdir
   30.96 +                    result.add(new Archive(classes, ClassFileReader.newInstance(classes)));
   30.97 +                }
   30.98 +                // add other JAR files
   30.99 +                result.addAll(addJarFiles(lib));
  30.100 +            } else {
  30.101 +                throw new RuntimeException("\"" + javaHome + "\" not a JDK home");
  30.102 +            }
  30.103 +        } catch (IOException e) {
  30.104 +            throw new RuntimeException(e);
  30.105 +        }
  30.106 +
  30.107 +        // add a JavaFX profile if there is jfxrt.jar
  30.108 +        for (Archive archive : result) {
  30.109 +            if (archive.getFileName().equals("jfxrt.jar")) {
  30.110 +                map.put(JAVAFX, new Profile("jfxrt.jar"));
  30.111 +            }
  30.112 +        }
  30.113 +        return result;
  30.114 +    }
  30.115 +
  30.116 +    private static List<Archive> addJarFiles(File f) throws IOException {
  30.117 +        final List<Archive> result = new ArrayList<Archive>();
  30.118 +        final Path root = f.toPath();
  30.119 +        final Path ext = root.resolve("ext");
  30.120 +        Files.walkFileTree(root, new SimpleFileVisitor<Path>() {
  30.121 +            @Override
  30.122 +            public FileVisitResult preVisitDirectory(Path dir, BasicFileAttributes attrs)
  30.123 +                throws IOException
  30.124 +            {
  30.125 +                if (dir.equals(root) || dir.equals(ext)) {
  30.126 +                    return FileVisitResult.CONTINUE;
  30.127 +                } else {
  30.128 +                    // skip other cobundled JAR files
  30.129 +                    return FileVisitResult.SKIP_SUBTREE;
  30.130 +                }
  30.131 +            }
  30.132 +            @Override
  30.133 +            public FileVisitResult visitFile(Path file, BasicFileAttributes attrs)
  30.134 +                throws IOException
  30.135 +            {
  30.136 +                File f = file.toFile();
  30.137 +                String fn = f.getName();
  30.138 +                if (fn.endsWith(".jar") && !fn.equals("alt-rt.jar")) {
  30.139 +                    result.add(new Archive(f, ClassFileReader.newInstance(f)));
  30.140 +                }
  30.141 +                return FileVisitResult.CONTINUE;
  30.142 +            }
  30.143 +        });
  30.144 +        return result;
  30.145 +    }
  30.146 +
  30.147 +    private static Map<String,Profile> getProfilePackages() {
  30.148 +        Map<String,Profile> map = new HashMap<String,Profile>();
  30.149 +
  30.150 +        // read the properties as a ResourceBundle as the build compiles
  30.151 +        // the properties file into Java class.  Another alternative is
  30.152 +        // to load it as Properties and fix the build to exclude this file.
  30.153 +        ResourceBundle profileBundle =
  30.154 +            ResourceBundle.getBundle("com.sun.tools.jdeps.resources.jdk");
  30.155 +
  30.156 +        int i=1;
  30.157 +        String key;
  30.158 +        while (profileBundle.containsKey((key = "profile." + i + ".name"))) {
  30.159 +            Profile profile = new Profile(profileBundle.getString(key));
  30.160 +            String n = profileBundle.getString("profile." + i + ".packages");
  30.161 +            String[] pkgs = n.split("\\s+");
  30.162 +            for (String p : pkgs) {
  30.163 +                if (p.isEmpty()) continue;
  30.164 +                assert(map.containsKey(p) == false);
  30.165 +                profile.packages.add(p);
  30.166 +                map.put(p, profile);
  30.167 +            }
  30.168 +            i++;
  30.169 +        }
  30.170 +        return map;
  30.171 +    }
  30.172 +}
    31.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
    31.2 +++ b/src/share/classes/com/sun/tools/jdeps/resources/jdeps.properties	Thu Jan 10 15:53:02 2013 -0800
    31.3 @@ -0,0 +1,57 @@
    31.4 +main.usage.summary=\
    31.5 +Usage: {0} <options> <classes...>\n\
    31.6 +use -h, -? or --help for a list of possible options
    31.7 +
    31.8 +main.usage=\
    31.9 +Usage: {0} <options> <classes...>\n\
   31.10 +where <classes> can be a pathname to a .class file, a directory, a JAR file,\n\
   31.11 +or a fully-qualified classname or wildcard "*".  Possible options include:
   31.12 +
   31.13 +error.prefix=Error:
   31.14 +warn.prefix=Warning:
   31.15 +
   31.16 +main.opt.h=\
   31.17 +\  -h -?      --help                    Print this usage message
   31.18 +
   31.19 +main.opt.version=\
   31.20 +\             --version                 Version information
   31.21 +
   31.22 +main.opt.V=\
   31.23 +\  -V <level> --verbose-level=<level>   Print package-level or class-level dependencies\n\
   31.24 +\                                       Valid levels are: "package" and "class"
   31.25 +
   31.26 +main.opt.v=\
   31.27 +\  -v         --verbose                 Print additional information
   31.28 +
   31.29 +main.opt.s=\
   31.30 +\  -s         --summary                 Print dependency summary only
   31.31 +
   31.32 +main.opt.p=\
   31.33 +\  -p <pkg name> --package=<pkg name>   Restrict analysis to classes in this package\n\
   31.34 +\                                       (may be given multiple times)
   31.35 +
   31.36 +main.opt.e=\
   31.37 +\  -e <regex> --regex=<regex>           Restrict analysis to packages matching pattern\n\
   31.38 +\                                       (-p and -e are exclusive)
   31.39 +
   31.40 +main.opt.P=\
   31.41 +\  -P         --profile                 Show profile or the file containing a package
   31.42 +
   31.43 +main.opt.c=\
   31.44 +\  -c <path>  --classpath=<path>        Specify where to find class files
   31.45 +
   31.46 +main.opt.R=\
   31.47 +\  -R         --recursive               Recursively traverse all dependencies
   31.48 +
   31.49 +main.opt.d=\
   31.50 +\  -d <depth> --depth=<depth>           Specify the depth of the transitive dependency analysis
   31.51 +
   31.52 +err.unknown.option=unknown option: {0}
   31.53 +err.missing.arg=no value given for {0}
   31.54 +err.internal.error=internal error: {0} {1} {2}
   31.55 +err.invalid.arg.for.option=invalid argument for option: {0}
   31.56 +err.option.after.class=option must be specified before classes: {0}
   31.57 +warn.invalid.arg=Invalid classname or pathname not exist: {0}
   31.58 +warn.split.package=package {0} defined in {1} {2}
   31.59 +
   31.60 +artifact.not.found=not found
    32.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
    32.2 +++ b/src/share/classes/com/sun/tools/jdeps/resources/jdk.properties	Thu Jan 10 15:53:02 2013 -0800
    32.3 @@ -0,0 +1,262 @@
    32.4 +# This properties file does not need localization.
    32.5 +
    32.6 +profile.1.name = compact1
    32.7 +profile.1.packages = \
    32.8 +    java.io \
    32.9 +    java.lang \
   32.10 +    java.lang.annotation \
   32.11 +    java.lang.invoke \
   32.12 +    java.lang.ref \
   32.13 +    java.lang.reflect \
   32.14 +    java.math \
   32.15 +    java.net \
   32.16 +    java.nio \
   32.17 +    java.nio.channels \
   32.18 +    java.nio.channels.spi \
   32.19 +    java.nio.charset \
   32.20 +    java.nio.charset.spi \
   32.21 +    java.nio.file \
   32.22 +    java.nio.file.attribute \
   32.23 +    java.nio.file.spi \
   32.24 +    java.security \
   32.25 +    java.security.cert \
   32.26 +    java.security.interfaces \
   32.27 +    java.security.spec \
   32.28 +    java.text \
   32.29 +    java.text.spi \
   32.30 +    java.util \
   32.31 +    java.util.concurrent \
   32.32 +    java.util.concurrent.atomic \
   32.33 +    java.util.concurrent.locks \
   32.34 +    java.util.jar \
   32.35 +    java.util.logging \
   32.36 +    java.util.regex \
   32.37 +    java.util.spi \
   32.38 +    java.util.zip \
   32.39 +    javax.crypto \
   32.40 +    javax.crypto.interfaces \
   32.41 +    javax.crypto.spec \
   32.42 +    javax.security.auth \
   32.43 +    javax.security.auth.callback \
   32.44 +    javax.security.auth.login \
   32.45 +    javax.security.auth.spi \
   32.46 +    javax.security.auth.x500 \
   32.47 +    javax.net \
   32.48 +    javax.net.ssl \
   32.49 +    javax.security.cert \
   32.50 +    \
   32.51 +    com.sun.net.ssl \
   32.52 +    com.sun.nio.file \
   32.53 +    com.sun.nio.sctp \
   32.54 +    com.sun.security.auth \
   32.55 +    com.sun.security.auth.login
   32.56 +
   32.57 +profile.2.name = compact2
   32.58 +profile.2.packages = \
   32.59 +    java.sql \
   32.60 +    javax.sql \
   32.61 +    javax.xml \
   32.62 +    javax.xml.datatype \
   32.63 +    javax.xml.namespace \
   32.64 +    javax.xml.parsers \
   32.65 +    javax.xml.stream \
   32.66 +    javax.xml.stream.events \
   32.67 +    javax.xml.stream.util \
   32.68 +    javax.xml.transform \
   32.69 +    javax.xml.transform.dom \
   32.70 +    javax.xml.transform.sax \
   32.71 +    javax.xml.transform.stax \
   32.72 +    javax.xml.transform.stream \
   32.73 +    javax.xml.validation \
   32.74 +    javax.xml.xpath \
   32.75 +    org.w3c.dom \
   32.76 +    org.w3c.dom.bootstrap \
   32.77 +    org.w3c.dom.events \
   32.78 +    org.w3c.dom.ls \
   32.79 +    org.xml.sax \
   32.80 +    org.xml.sax.ext \
   32.81 +    org.xml.sax.helpers \
   32.82 +    java.rmi \
   32.83 +    java.rmi.activation \
   32.84 +    java.rmi.dgc \
   32.85 +    java.rmi.registry \
   32.86 +    java.rmi.server \
   32.87 +    javax.rmi.ssl \
   32.88 +    javax.transaction \
   32.89 +    javax.transaction.xa \
   32.90 +    \
   32.91 +    com.sun.net.httpserver \
   32.92 +    com.sun.net.httpserver.spi
   32.93 +
   32.94 +profile.3.name = compact3
   32.95 +profile.3.packages = \
   32.96 +    java.lang.instrument \
   32.97 +    java.lang.management \
   32.98 +    java.security.acl \
   32.99 +    java.util.prefs \
  32.100 +    javax.management \
  32.101 +    javax.management.loading \
  32.102 +    javax.management.modelmbean \
  32.103 +    javax.management.monitor \
  32.104 +    javax.management.openmbean \
  32.105 +    javax.management.relation \
  32.106 +    javax.management.remote \
  32.107 +    javax.management.remote.rmi \
  32.108 +    javax.management.timer \
  32.109 +    javax.naming \
  32.110 +    javax.naming.directory \
  32.111 +    javax.naming.event \
  32.112 +    javax.naming.ldap \
  32.113 +    javax.naming.spi \
  32.114 +    javax.sql.rowset \
  32.115 +    javax.sql.rowset.serial \
  32.116 +    javax.sql.rowset.spi \
  32.117 +    javax.security.auth.kerberos \
  32.118 +    javax.security.sasl \
  32.119 +    javax.script \
  32.120 +    javax.smartcardio \
  32.121 +    javax.xml.crypto \
  32.122 +    javax.xml.crypto.dom \
  32.123 +    javax.xml.crypto.dsig \
  32.124 +    javax.xml.crypto.dsig.dom \
  32.125 +    javax.xml.crypto.dsig.keyinfo \
  32.126 +    javax.xml.crypto.dsig.spec \
  32.127 +    javax.annotation.processing \
  32.128 +    javax.lang.model \
  32.129 +    javax.lang.model.element \
  32.130 +    javax.lang.model.type \
  32.131 +    javax.lang.model.util \
  32.132 +    javax.tools \
  32.133 +    javax.tools.annotation \
  32.134 +    org.ietf.jgss \
  32.135 +    \
  32.136 +    com.sun.management \
  32.137 +    com.sun.security.auth.callback \
  32.138 +    com.sun.security.auth.module \
  32.139 +    com.sun.security.jgss
  32.140 +
  32.141 +profile.4.name = Full JRE
  32.142 +profile.4.packages = \
  32.143 +    java.applet \
  32.144 +    java.awt \
  32.145 +    java.awt.color \
  32.146 +    java.awt.datatransfer \
  32.147 +    java.awt.dnd \
  32.148 +    java.awt.dnd.peer \
  32.149 +    java.awt.event \
  32.150 +    java.awt.font \
  32.151 +    java.awt.geom \
  32.152 +    java.awt.im \
  32.153 +    java.awt.im.spi \
  32.154 +    java.awt.image \
  32.155 +    java.awt.image.renderable \
  32.156 +    java.awt.peer \
  32.157 +    java.awt.print \
  32.158 +    java.beans \
  32.159 +    java.beans.beancontext \
  32.160 +    javax.accessibility \
  32.161 +    javax.imageio \
  32.162 +    javax.imageio.event \
  32.163 +    javax.imageio.metadata \
  32.164 +    javax.imageio.plugins.bmp \
  32.165 +    javax.imageio.plugins.jpeg \
  32.166 +    javax.imageio.spi \
  32.167 +    javax.imageio.stream \
  32.168 +    javax.print \
  32.169 +    javax.print.attribute \
  32.170 +    javax.print.attribute.standard \
  32.171 +    javax.print.event \
  32.172 +    javax.sound.midi \
  32.173 +    javax.sound.midi.spi \
  32.174 +    javax.sound.sampled \
  32.175 +    javax.sound.sampled.spi \
  32.176 +    javax.swing \
  32.177 +    javax.swing.border \
  32.178 +    javax.swing.colorchooser \
  32.179 +    javax.swing.event \
  32.180 +    javax.swing.filechooser \
  32.181 +    javax.swing.plaf \
  32.182 +    javax.swing.plaf.basic \
  32.183 +    javax.swing.plaf.metal \
  32.184 +    javax.swing.plaf.multi \
  32.185 +    javax.swing.plaf.nimbus \
  32.186 +    javax.swing.plaf.synth \
  32.187 +    javax.swing.table \
  32.188 +    javax.swing.text \
  32.189 +    javax.swing.text.html \
  32.190 +    javax.swing.text.html.parser \
  32.191 +    javax.swing.text.rtf \
  32.192 +    javax.swing.tree \
  32.193 +    javax.swing.undo \
  32.194 +    javax.activation \
  32.195 +    javax.jws \
  32.196 +    javax.jws.soap \
  32.197 +    javax.rmi \
  32.198 +    javax.rmi.CORBA \
  32.199 +    javax.xml.bind \
  32.200 +    javax.xml.bind.annotation \
  32.201 +    javax.xml.bind.annotation.adapters \
  32.202 +    javax.xml.bind.attachment \
  32.203 +    javax.xml.bind.helpers \
  32.204 +    javax.xml.bind.util \
  32.205 +    javax.xml.soap \
  32.206 +    javax.xml.ws \
  32.207 +    javax.xml.ws.handler \
  32.208 +    javax.xml.ws.handler.soap \
  32.209 +    javax.xml.ws.http \
  32.210 +    javax.xml.ws.soap \
  32.211 +    javax.xml.ws.spi \
  32.212 +    javax.xml.ws.spi.http \
  32.213 +    javax.xml.ws.wsaddressing \
  32.214 +    javax.annotation \
  32.215 +    org.omg.CORBA \
  32.216 +    org.omg.CORBA.DynAnyPackage \
  32.217 +    org.omg.CORBA.ORBPackage \
  32.218 +    org.omg.CORBA.TypeCodePackage \
  32.219 +    org.omg.CORBA.portable \
  32.220 +    org.omg.CORBA_2_3 \
  32.221 +    org.omg.CORBA_2_3.portable \
  32.222 +    org.omg.CosNaming \
  32.223 +    org.omg.CosNaming.NamingContextExtPackage \
  32.224 +    org.omg.CosNaming.NamingContextPackage \
  32.225 +    org.omg.Dynamic \
  32.226 +    org.omg.DynamicAny \
  32.227 +    org.omg.DynamicAny.DynAnyFactoryPackage \
  32.228 +    org.omg.DynamicAny.DynAnyPackage \
  32.229 +    org.omg.IOP \
  32.230 +    org.omg.IOP.CodecFactoryPackage \
  32.231 +    org.omg.IOP.CodecPackage \
  32.232 +    org.omg.Messaging \
  32.233 +    org.omg.PortableInterceptor \
  32.234 +    org.omg.PortableInterceptor.ORBInitInfoPackage \
  32.235 +    org.omg.PortableServer \
  32.236 +    org.omg.PortableServer.CurrentPackage \
  32.237 +    org.omg.PortableServer.POAManagerPackage \
  32.238 +    org.omg.PortableServer.POAPackage \
  32.239 +    org.omg.PortableServer.ServantLocatorPackage \
  32.240 +    org.omg.PortableServer.portable \
  32.241 +    org.omg.SendingContext \
  32.242 +    org.omg.stub.java.rmi \
  32.243 +    org.omg.stub.javax.management.remote.rmi
  32.244 +
  32.245 +# Remaining JDK supported API
  32.246 +profile.5.name = JDK tools
  32.247 +profile.5.packages = \
  32.248 +    com.sun.jdi \
  32.249 +    com.sun.jdi.connect \
  32.250 +    com.sun.jdi.connect.spi \
  32.251 +    com.sun.jdi.event \
  32.252 +    com.sun.jdi.request \
  32.253 +    com.sun.javadoc \
  32.254 +    com.sun.tools.doclets \
  32.255 +    com.sun.tools.doctree \
  32.256 +    com.sun.source.tree \
  32.257 +    com.sun.source.util \
  32.258 +    com.sun.tools.attach \
  32.259 +    com.sun.tools.attach.spi \
  32.260 +    com.sun.tools.jconsole \
  32.261 +    com.sun.tools.javac \
  32.262 +    com.sun.tools.javah \
  32.263 +    com.sun.tools.javap \
  32.264 +    com.sun.tools.javadoc \
  32.265 +    com.sun.servicetag
    33.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
    33.2 +++ b/src/share/classes/com/sun/tools/jdeps/resources/version.properties-template	Thu Jan 10 15:53:02 2013 -0800
    33.3 @@ -0,0 +1,28 @@
    33.4 +#
    33.5 +# Copyright (c) 2012, Oracle and/or its affiliates. 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.  Oracle designates this
   33.11 +# particular file as subject to the "Classpath" exception as provided
   33.12 +# by Oracle in the LICENSE file that accompanied this code.
   33.13 +#
   33.14 +# This code is distributed in the hope that it will be useful, but WITHOUT
   33.15 +# ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
   33.16 +# FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
   33.17 +# version 2 for more details (a copy is included in the LICENSE file that
   33.18 +# accompanied this code).
   33.19 +#
   33.20 +# You should have received a copy of the GNU General Public License version
   33.21 +# 2 along with this work; if not, write to the Free Software Foundation,
   33.22 +# Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
   33.23 +#
   33.24 +# Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
   33.25 +# or visit www.oracle.com if you need additional information or have any
   33.26 +# questions.
   33.27 +#
   33.28 +
   33.29 +jdk=$(JDK_VERSION)
   33.30 +full=$(FULL_VERSION)
   33.31 +release=$(RELEASE)
    34.1 --- a/src/share/classes/javax/lang/model/element/Element.java	Thu Jan 10 09:56:09 2013 -0800
    34.2 +++ b/src/share/classes/javax/lang/model/element/Element.java	Thu Jan 10 15:53:02 2013 -0800
    34.3 @@ -179,6 +179,10 @@
    34.4       * instance initializer}, an empty name is returned.
    34.5       *
    34.6       * @return the simple name of this element
    34.7 +     * @see PackageElement#getSimpleName
    34.8 +     * @see ExecutableElement#getSimpleName
    34.9 +     * @see TypeElement#getSimpleName
   34.10 +     * @see VariableElement#getSimpleName
   34.11       */
   34.12      Name getSimpleName();
   34.13  
   34.14 @@ -202,6 +206,11 @@
   34.15       * {@linkplain TypeParameterElement#getGenericElement the
   34.16       * generic element} of the type parameter is returned.
   34.17       *
   34.18 +     * <li> If this is a {@linkplain
   34.19 +     * VariableElement#getEnclosingElement method or constructor
   34.20 +     * parameter}, {@linkplain ExecutableElement the executable
   34.21 +     * element} which declares the parameter is returned.
   34.22 +     *
   34.23       * </ul>
   34.24       *
   34.25       * @return the enclosing element, or {@code null} if there is none
    35.1 --- a/src/share/classes/javax/lang/model/element/VariableElement.java	Thu Jan 10 09:56:09 2013 -0800
    35.2 +++ b/src/share/classes/javax/lang/model/element/VariableElement.java	Thu Jan 10 15:53:02 2013 -0800
    35.3 @@ -62,4 +62,29 @@
    35.4       * @jls 4.12.4 final Variables
    35.5       */
    35.6      Object getConstantValue();
    35.7 +
    35.8 +    /**
    35.9 +     * Returns the simple name of this variable element.
   35.10 +     *
   35.11 +     * <p>For method and constructor parameters, the name of each
   35.12 +     * parameter must be distinct from the names of all other
   35.13 +     * parameters of the same executable.  If the original source
   35.14 +     * names are not available, an implementation may synthesize names
   35.15 +     * subject to the distinctness requirement above.
   35.16 +     *
   35.17 +     * @return the simple name of this variable element
   35.18 +     */
   35.19 +    @Override
   35.20 +    Name getSimpleName();
   35.21 +
   35.22 +    /**
   35.23 +     * Returns the enclosing element of this variable.
   35.24 +     *
   35.25 +     * The enclosing element of a method or constructor parameter is
   35.26 +     * the executable declaring the parameter.
   35.27 +     *
   35.28 +     * @return the enclosing element of this variable
   35.29 +     */
   35.30 +    @Override
   35.31 +    Element getEnclosingElement();
   35.32  }
    36.1 --- a/src/share/classes/javax/lang/model/element/package-info.java	Thu Jan 10 09:56:09 2013 -0800
    36.2 +++ b/src/share/classes/javax/lang/model/element/package-info.java	Thu Jan 10 15:53:02 2013 -0800
    36.3 @@ -1,5 +1,5 @@
    36.4  /*
    36.5 - * Copyright (c) 2005, 2010, Oracle and/or its affiliates. All rights reserved.
    36.6 + * Copyright (c) 2005, 2012, Oracle and/or its affiliates. All rights reserved.
    36.7   * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
    36.8   *
    36.9   * This code is free software; you can redistribute it and/or modify it
   36.10 @@ -48,9 +48,12 @@
   36.11   * {@linkplain java.lang.annotation.RetentionPolicy#SOURCE source}
   36.12   * {@linkplain java.lang.annotation.Retention retention} cannot be
   36.13   * recovered from class files and class files might not be able to
   36.14 - * provide source position information.  The {@linkplain
   36.15 - * javax.lang.model.element.Modifier modifiers} on an element may
   36.16 - * differ in some cases including
   36.17 + * provide source position information.
   36.18 + *
   36.19 + * Names of parameters may not be recoverable from class files.
   36.20 + *
   36.21 + * The {@linkplain javax.lang.model.element.Modifier modifiers} on an
   36.22 + * element may differ in some cases including:
   36.23   *
   36.24   * <ul>
   36.25   * <li> {@code strictfp} on a class or interface
    37.1 --- a/test/Makefile	Thu Jan 10 09:56:09 2013 -0800
    37.2 +++ b/test/Makefile	Thu Jan 10 15:53:02 2013 -0800
    37.3 @@ -229,7 +229,7 @@
    37.4  all: $(JPRT_CLEAN) jtreg-tests jck-compiler-tests jck-runtime-tests $(JPRT_ARCHIVE_BUNDLE) all-summary
    37.5  	@echo "Testing completed successfully"
    37.6  
    37.7 -jtreg apt javac javadoc javah javap: $(JPRT_CLEAN) jtreg-tests $(JPRT_ARCHIVE_BUNDLE) jtreg-summary
    37.8 +jtreg apt javac javadoc javah javap jdeps: $(JPRT_CLEAN) jtreg-tests $(JPRT_ARCHIVE_BUNDLE) jtreg-summary
    37.9  	@echo "Testing completed successfully"
   37.10  
   37.11  jck-compiler: $(JPRT_CLEAN) jck-compiler-tests $(JPRT_ARCHIVE_BUNDLE) jck-compiler-summary
   37.12 @@ -246,6 +246,7 @@
   37.13  javadoc:	JTREG_TESTDIRS = tools/javadoc com/sun/javadoc
   37.14  javah:		JTREG_TESTDIRS = tools/javah
   37.15  javap:		JTREG_TESTDIRS = tools/javap
   37.16 +jdeps:		JTREG_TESTDIRS = tools/jdeps
   37.17  
   37.18  # Run jtreg tests
   37.19  #
   37.20 @@ -426,7 +427,7 @@
   37.21  
   37.22  # Phony targets (e.g. these are not filenames)
   37.23  .PHONY: all clean \
   37.24 -	jtreg javac javadoc javah javap jtreg-tests jtreg-summary check-jtreg \
   37.25 +	jtreg javac javadoc javah javap jdeps jtreg-tests jtreg-summary check-jtreg \
   37.26  	jck-compiler jck-compiler-tests jck-compiler-summary \
   37.27  	jck-runtime jck-runtime-tests jck-runtime-summary check-jck
   37.28  
    38.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
    38.2 +++ b/test/com/sun/javadoc/testAbstractMethod/TestAbstractMethod.java	Thu Jan 10 15:53:02 2013 -0800
    38.3 @@ -0,0 +1,121 @@
    38.4 +/*
    38.5 + * Copyright (c) 2012, Oracle and/or its affiliates. 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 Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
   38.23 + * or visit www.oracle.com if you need additional information or have any
   38.24 + * questions.
   38.25 + */
   38.26 +
   38.27 +/*
   38.28 + * @test
   38.29 + * @bug      8004891
   38.30 + * @summary  Make sure that the abstract method is identified correctly
   38.31 + *           if the abstract modifier is present explicitly or implicitly.
   38.32 + * @author   bpatel
   38.33 + * @library  ../lib/
   38.34 + * @build    JavadocTester TestAbstractMethod
   38.35 + * @run main TestAbstractMethod
   38.36 + */
   38.37 +
   38.38 +public class TestAbstractMethod extends JavadocTester {
   38.39 +
   38.40 +    //Test information.
   38.41 +    private static final String BUG_ID = "8004891";
   38.42 +
   38.43 +    //Javadoc arguments.
   38.44 +    private static final String[] ARGS = new String[] {
   38.45 +        "-d", BUG_ID, "-sourcepath", SRC_DIR, "pkg"
   38.46 +    };
   38.47 +
   38.48 +    //Input for string search tests.
   38.49 +    private static final String[][] TEST = {
   38.50 +        {BUG_ID + FS + "pkg" + FS + "A.html",
   38.51 +            "<td class=\"colFirst\"><code>default void</code></td>"},
   38.52 +        {BUG_ID + FS + "pkg" + FS + "A.html",
   38.53 +            "<caption><span id=\"t0\" class=\"activeTableTab\"><span>" +
   38.54 +            "All Methods</span><span class=\"tabEnd\">&nbsp;</span></span>" +
   38.55 +            "<span id=\"t2\" class=\"tableTab\"><span>" +
   38.56 +            "<a href=\"javascript:show(2);\">Instance Methods</a></span>" +
   38.57 +            "<span class=\"tabEnd\">&nbsp;</span></span><span id=\"t3\" " +
   38.58 +            "class=\"tableTab\"><span><a href=\"javascript:show(4);\">" +
   38.59 +            "Abstract Methods</a></span><span class=\"tabEnd\">&nbsp;</span>" +
   38.60 +            "</span><span id=\"t5\" class=\"tableTab\"><span>" +
   38.61 +            "<a href=\"javascript:show(16);\">Default Methods</a></span>" +
   38.62 +            "<span class=\"tabEnd\">&nbsp;</span></span></caption>"},
   38.63 +        {BUG_ID + FS + "pkg" + FS + "B.html",
   38.64 +            "<caption><span id=\"t0\" class=\"activeTableTab\"><span>" +
   38.65 +            "All Methods</span><span class=\"tabEnd\">&nbsp;</span></span>" +
   38.66 +            "<span id=\"t2\" class=\"tableTab\"><span>" +
   38.67 +            "<a href=\"javascript:show(2);\">Instance Methods</a></span>" +
   38.68 +            "<span class=\"tabEnd\">&nbsp;</span></span><span id=\"t3\" " +
   38.69 +            "class=\"tableTab\"><span><a href=\"javascript:show(4);\">Abstract " +
   38.70 +            "Methods</a></span><span class=\"tabEnd\">&nbsp;</span></span>" +
   38.71 +            "<span id=\"t4\" class=\"tableTab\"><span>" +
   38.72 +            "<a href=\"javascript:show(8);\">Concrete Methods</a></span>" +
   38.73 +            "<span class=\"tabEnd\">&nbsp;</span></span></caption>"},
   38.74 +        {BUG_ID + FS + "pkg" + FS + "B.html",
   38.75 +            "<td class=\"colFirst\"><code>abstract void</code></td>"},
   38.76 +        {BUG_ID + FS + "pkg" + FS + "C.html",
   38.77 +            "<caption><span id=\"t0\" class=\"activeTableTab\"><span>" +
   38.78 +            "All Methods</span><span class=\"tabEnd\">&nbsp;</span></span>" +
   38.79 +            "<span id=\"t2\" class=\"tableTab\"><span>" +
   38.80 +            "<a href=\"javascript:show(2);\">Instance Methods</a></span>" +
   38.81 +            "<span class=\"tabEnd\">&nbsp;</span></span>" +
   38.82 +            "<span id=\"t5\" class=\"tableTab\"><span>" +
   38.83 +            "<a href=\"javascript:show(16);\">Default Methods</a></span>" +
   38.84 +            "<span class=\"tabEnd\">&nbsp;</span></span></caption>"},
   38.85 +        {BUG_ID + FS + "pkg" + FS + "C.html",
   38.86 +            "<td class=\"colFirst\"><code>default void</code></td>"}
   38.87 +    };
   38.88 +    private static final String[][] NEGATED_TEST = {
   38.89 +        {BUG_ID + FS + "pkg" + FS + "A.html",
   38.90 +            "<td class=\"colFirst\"><code>abstract void</code></td>"},
   38.91 +        {BUG_ID + FS + "pkg" + FS + "B.html",
   38.92 +            "<span><a href=\"javascript:show(16);\">Default Methods</a></span>" +
   38.93 +            "<span class=\"tabEnd\">&nbsp;</span>"},
   38.94 +        {BUG_ID + FS + "pkg" + FS + "B.html",
   38.95 +            "<td class=\"colFirst\"><code>default void</code></td>"},
   38.96 +        {BUG_ID + FS + "pkg" + FS + "C.html",
   38.97 +            "<span><a href=\"javascript:show(4);\">Abstract Methods</a></span>" +
   38.98 +            "<span class=\"tabEnd\">&nbsp;</span>"}
   38.99 +    };
  38.100 +
  38.101 +    /**
  38.102 +     * The entry point of the test.
  38.103 +     * @param args the array of command line arguments.
  38.104 +     */
  38.105 +    public static void main(String[] args) {
  38.106 +        TestAbstractMethod tester = new TestAbstractMethod();
  38.107 +        run(tester, ARGS, TEST, NEGATED_TEST);
  38.108 +        tester.printSummary();
  38.109 +    }
  38.110 +
  38.111 +    /**
  38.112 +     * {@inheritDoc}
  38.113 +     */
  38.114 +    public String getBugId() {
  38.115 +        return BUG_ID;
  38.116 +    }
  38.117 +
  38.118 +    /**
  38.119 +     * {@inheritDoc}
  38.120 +     */
  38.121 +    public String getBugName() {
  38.122 +        return getClass().getName();
  38.123 +    }
  38.124 +}
    39.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
    39.2 +++ b/test/com/sun/javadoc/testAbstractMethod/pkg/A.java	Thu Jan 10 15:53:02 2013 -0800
    39.3 @@ -0,0 +1,31 @@
    39.4 +/*
    39.5 + * Copyright (c) 2012, Oracle and/or its affiliates. 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 Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
   39.23 + * or visit www.oracle.com if you need additional information or have any
   39.24 + * questions.
   39.25 + */
   39.26 +
   39.27 +package pkg;
   39.28 +
   39.29 +public interface A {
   39.30 +
   39.31 +    public void method1();
   39.32 +
   39.33 +    public default void defaultMethod() { }
   39.34 +}
    40.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
    40.2 +++ b/test/com/sun/javadoc/testAbstractMethod/pkg/B.java	Thu Jan 10 15:53:02 2013 -0800
    40.3 @@ -0,0 +1,31 @@
    40.4 +/*
    40.5 + * Copyright (c) 2012, Oracle and/or its affiliates. All rights reserved.
    40.6 + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
    40.7 + *
    40.8 + * This code is free software; you can redistribute it and/or modify it
    40.9 + * under the terms of the GNU General Public License version 2 only, as
   40.10 + * published by the Free Software Foundation.
   40.11 + *
   40.12 + * This code is distributed in the hope that it will be useful, but WITHOUT
   40.13 + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
   40.14 + * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
   40.15 + * version 2 for more details (a copy is included in the LICENSE file that
   40.16 + * accompanied this code).
   40.17 + *
   40.18 + * You should have received a copy of the GNU General Public License version
   40.19 + * 2 along with this work; if not, write to the Free Software Foundation,
   40.20 + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
   40.21 + *
   40.22 + * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
   40.23 + * or visit www.oracle.com if you need additional information or have any
   40.24 + * questions.
   40.25 + */
   40.26 +
   40.27 +package pkg;
   40.28 +
   40.29 +public abstract class B {
   40.30 +
   40.31 +    public abstract void method1();
   40.32 +
   40.33 +    public void method2() { }
   40.34 +}
    41.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
    41.2 +++ b/test/com/sun/javadoc/testAbstractMethod/pkg/C.java	Thu Jan 10 15:53:02 2013 -0800
    41.3 @@ -0,0 +1,29 @@
    41.4 +/*
    41.5 + * Copyright (c) 2012, Oracle and/or its affiliates. All rights reserved.
    41.6 + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
    41.7 + *
    41.8 + * This code is free software; you can redistribute it and/or modify it
    41.9 + * under the terms of the GNU General Public License version 2 only, as
   41.10 + * published by the Free Software Foundation.
   41.11 + *
   41.12 + * This code is distributed in the hope that it will be useful, but WITHOUT
   41.13 + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
   41.14 + * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
   41.15 + * version 2 for more details (a copy is included in the LICENSE file that
   41.16 + * accompanied this code).
   41.17 + *
   41.18 + * You should have received a copy of the GNU General Public License version
   41.19 + * 2 along with this work; if not, write to the Free Software Foundation,
   41.20 + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
   41.21 + *
   41.22 + * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
   41.23 + * or visit www.oracle.com if you need additional information or have any
   41.24 + * questions.
   41.25 + */
   41.26 +
   41.27 +package pkg;
   41.28 +
   41.29 +public interface C {
   41.30 +
   41.31 +    public default void onlyMethod() { }
   41.32 +}
    42.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
    42.2 +++ b/test/com/sun/javadoc/testRepeatedAnnotations/TestRepeatedAnnotations.java	Thu Jan 10 15:53:02 2013 -0800
    42.3 @@ -0,0 +1,187 @@
    42.4 +/*
    42.5 + * Copyright (c) 2012, Oracle and/or its affiliates. All rights reserved.
    42.6 + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
    42.7 + *
    42.8 + * This code is free software; you can redistribute it and/or modify it
    42.9 + * under the terms of the GNU General Public License version 2 only, as
   42.10 + * published by the Free Software Foundation.
   42.11 + *
   42.12 + * This code is distributed in the hope that it will be useful, but WITHOUT
   42.13 + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
   42.14 + * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
   42.15 + * version 2 for more details (a copy is included in the LICENSE file that
   42.16 + * accompanied this code).
   42.17 + *
   42.18 + * You should have received a copy of the GNU General Public License version
   42.19 + * 2 along with this work; if not, write to the Free Software Foundation,
   42.20 + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
   42.21 + *
   42.22 + * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
   42.23 + * or visit www.oracle.com if you need additional information or have any
   42.24 + * questions.
   42.25 + */
   42.26 +
   42.27 +/*
   42.28 + * @test
   42.29 + * @bug      8005092
   42.30 + * @summary  Test repeated annotations output.
   42.31 + * @author   bpatel
   42.32 + * @library  ../lib/
   42.33 + * @build    JavadocTester TestRepeatedAnnotations
   42.34 + * @run main TestRepeatedAnnotations
   42.35 + */
   42.36 +
   42.37 +public class TestRepeatedAnnotations extends JavadocTester {
   42.38 +
   42.39 +    //Test information.
   42.40 +    private static final String BUG_ID = "8005092";
   42.41 +
   42.42 +    //Javadoc arguments.
   42.43 +    private static final String[] ARGS = new String[] {
   42.44 +        "-d", BUG_ID, "-sourcepath", SRC_DIR, "pkg", "pkg1"
   42.45 +    };
   42.46 +
   42.47 +    //Input for string search tests.
   42.48 +    private static final String[][] TEST = {
   42.49 +        {BUG_ID + FS + "pkg" + FS + "C.html",
   42.50 +            "<a href=\"../pkg/ContaineeSynthDoc.html\" " +
   42.51 +            "title=\"annotation in pkg\">@ContaineeSynthDoc</a> " +
   42.52 +            "<a href=\"../pkg/ContaineeSynthDoc.html\" " +
   42.53 +            "title=\"annotation in pkg\">@ContaineeSynthDoc</a>"},
   42.54 +        {BUG_ID + FS + "pkg" + FS + "C.html",
   42.55 +            "<a href=\"../pkg/ContaineeRegDoc.html\" " +
   42.56 +            "title=\"annotation in pkg\">@ContaineeRegDoc</a> " +
   42.57 +            "<a href=\"../pkg/ContaineeRegDoc.html\" " +
   42.58 +            "title=\"annotation in pkg\">@ContaineeRegDoc</a>"},
   42.59 +        {BUG_ID + FS + "pkg" + FS + "C.html",
   42.60 +            "<a href=\"../pkg/RegContainerDoc.html\" " +
   42.61 +            "title=\"annotation in pkg\">@RegContainerDoc</a>" +
   42.62 +            "(<a href=\"../pkg/RegContainerDoc.html#value()\">value</a>={" +
   42.63 +            "<a href=\"../pkg/RegContaineeNotDoc.html\" " +
   42.64 +            "title=\"annotation in pkg\">@RegContaineeNotDoc</a>," +
   42.65 +            "<a href=\"../pkg/RegContaineeNotDoc.html\" " +
   42.66 +            "title=\"annotation in pkg\">@RegContaineeNotDoc</a>})"},
   42.67 +        {BUG_ID + FS + "pkg" + FS + "C.html",
   42.68 +            "<a href=\"../pkg/ContaineeSynthDoc.html\" " +
   42.69 +            "title=\"annotation in pkg\">@ContaineeSynthDoc</a> " +
   42.70 +            "<a href=\"../pkg/ContaineeSynthDoc.html\" " +
   42.71 +            "title=\"annotation in pkg\">@ContaineeSynthDoc</a> " +
   42.72 +            "<a href=\"../pkg/ContaineeSynthDoc.html\" " +
   42.73 +            "title=\"annotation in pkg\">@ContaineeSynthDoc</a>"},
   42.74 +        {BUG_ID + FS + "pkg" + FS + "C.html",
   42.75 +            "<a href=\"../pkg/ContainerSynthDoc.html\" " +
   42.76 +            "title=\"annotation in pkg\">@ContainerSynthDoc</a>(" +
   42.77 +            "<a href=\"../pkg/ContainerSynthDoc.html#value()\">value</a>=" +
   42.78 +            "<a href=\"../pkg/ContaineeSynthDoc.html\" " +
   42.79 +            "title=\"annotation in pkg\">@ContaineeSynthDoc</a>)"},
   42.80 +        {BUG_ID + FS + "pkg" + FS + "C.html",
   42.81 +            "<a href=\"../pkg/ContaineeSynthDoc.html\" " +
   42.82 +            "title=\"annotation in pkg\">@ContaineeSynthDoc</a> " +
   42.83 +            "<a href=\"../pkg/ContaineeSynthDoc.html\" " +
   42.84 +            "title=\"annotation in pkg\">@ContaineeSynthDoc</a>"},
   42.85 +
   42.86 +        {BUG_ID + FS + "pkg" + FS + "D.html",
   42.87 +            "<a href=\"../pkg/RegDoc.html\" title=\"annotation in pkg\">@RegDoc</a>" +
   42.88 +            "(<a href=\"../pkg/RegDoc.html#x()\">x</a>=1)"},
   42.89 +        {BUG_ID + FS + "pkg" + FS + "D.html",
   42.90 +            "<a href=\"../pkg/RegArryDoc.html\" title=\"annotation in pkg\">@RegArryDoc</a>" +
   42.91 +            "(<a href=\"../pkg/RegArryDoc.html#y()\">y</a>=1)"},
   42.92 +        {BUG_ID + FS + "pkg" + FS + "D.html",
   42.93 +            "<a href=\"../pkg/RegArryDoc.html\" title=\"annotation in pkg\">@RegArryDoc</a>" +
   42.94 +            "(<a href=\"../pkg/RegArryDoc.html#y()\">y</a>={1,2})"},
   42.95 +        {BUG_ID + FS + "pkg" + FS + "D.html",
   42.96 +            "<a href=\"../pkg/NonSynthDocContainer.html\" " +
   42.97 +            "title=\"annotation in pkg\">@NonSynthDocContainer</a>" +
   42.98 +            "(<a href=\"../pkg/NonSynthDocContainer.html#value()\">value</a>=" +
   42.99 +            "<a href=\"../pkg/RegArryDoc.html\" title=\"annotation in pkg\">@RegArryDoc</a>)"},
  42.100 +
  42.101 +        {BUG_ID + FS + "pkg1" + FS + "C.html",
  42.102 +            "<a href=\"../pkg1/RegContainerValDoc.html\" " +
  42.103 +            "title=\"annotation in pkg1\">@RegContainerValDoc</a>" +
  42.104 +            "(<a href=\"../pkg1/RegContainerValDoc.html#value()\">value</a>={" +
  42.105 +            "<a href=\"../pkg1/RegContaineeNotDoc.html\" " +
  42.106 +            "title=\"annotation in pkg1\">@RegContaineeNotDoc</a>," +
  42.107 +            "<a href=\"../pkg1/RegContaineeNotDoc.html\" " +
  42.108 +            "title=\"annotation in pkg1\">@RegContaineeNotDoc</a>}," +
  42.109 +            "<a href=\"../pkg1/RegContainerValDoc.html#y()\">y</a>=3)"},
  42.110 +        {BUG_ID + FS + "pkg1" + FS + "C.html",
  42.111 +            "<a href=\"../pkg1/ContainerValDoc.html\" " +
  42.112 +            "title=\"annotation in pkg1\">@ContainerValDoc</a>" +
  42.113 +            "(<a href=\"../pkg1/ContainerValDoc.html#value()\">value</a>={" +
  42.114 +            "<a href=\"../pkg1/ContaineeNotDoc.html\" " +
  42.115 +            "title=\"annotation in pkg1\">@ContaineeNotDoc</a>," +
  42.116 +            "<a href=\"../pkg1/ContaineeNotDoc.html\" " +
  42.117 +            "title=\"annotation in pkg1\">@ContaineeNotDoc</a>}," +
  42.118 +            "<a href=\"../pkg1/ContainerValDoc.html#x()\">x</a>=1)"}
  42.119 +    };
  42.120 +
  42.121 +    private static final String[][] NEGATED_TEST = {
  42.122 +        {BUG_ID + FS + "pkg" + FS + "C.html",
  42.123 +            "<a href=\"../pkg/RegContaineeDoc.html\" " +
  42.124 +            "title=\"annotation in pkg\">@RegContaineeDoc</a> " +
  42.125 +            "<a href=\"../pkg/RegContaineeDoc.html\" " +
  42.126 +            "title=\"annotation in pkg\">@RegContaineeDoc</a>"},
  42.127 +        {BUG_ID + FS + "pkg" + FS + "C.html",
  42.128 +            "<a href=\"../pkg/RegContainerNotDoc.html\" " +
  42.129 +            "title=\"annotation in pkg\">@RegContainerNotDoc</a>" +
  42.130 +            "(<a href=\"../pkg/RegContainerNotDoc.html#value()\">value</a>={" +
  42.131 +            "<a href=\"../pkg/RegContaineeNotDoc.html\" " +
  42.132 +            "title=\"annotation in pkg\">@RegContaineeNotDoc</a>," +
  42.133 +            "<a href=\"../pkg/RegContaineeNotDoc.html\" " +
  42.134 +            "title=\"annotation in pkg\">@RegContaineeNotDoc</a>})"},
  42.135 +
  42.136 +        {BUG_ID + FS + "pkg1" + FS + "C.html",
  42.137 +            "<a href=\"../pkg1/ContaineeSynthDoc.html\" " +
  42.138 +            "title=\"annotation in pkg1\">@ContaineeSynthDoc</a> " +
  42.139 +            "<a href=\"../pkg1/ContaineeSynthDoc.html\" " +
  42.140 +            "title=\"annotation in pkg1\">@ContaineeSynthDoc</a>"},
  42.141 +        {BUG_ID + FS + "pkg1" + FS + "C.html",
  42.142 +            "<a href=\"../pkg1/RegContainerValNotDoc.html\" " +
  42.143 +            "title=\"annotation in pkg1\">@RegContainerValNotDoc</a>" +
  42.144 +            "(<a href=\"../pkg1/RegContainerValNotDoc.html#value()\">value</a>={" +
  42.145 +            "<a href=\"../pkg1/RegContaineeDoc.html\" " +
  42.146 +            "title=\"annotation in pkg1\">@RegContaineeDoc</a>," +
  42.147 +            "<a href=\"../pkg1/RegContaineeDoc.html\" " +
  42.148 +            "title=\"annotation in pkg1\">@RegContaineeDoc</a>}," +
  42.149 +            "<a href=\"../pkg1/RegContainerValNotDoc.html#y()\">y</a>=4)"},
  42.150 +        {BUG_ID + FS + "pkg1" + FS + "C.html",
  42.151 +            "<a href=\"../pkg1/ContainerValNotDoc.html\" " +
  42.152 +            "title=\"annotation in pkg1\">@ContainerValNotDoc</a>" +
  42.153 +            "(<a href=\"../pkg1/ContainerValNotDoc.html#value()\">value</a>={" +
  42.154 +            "<a href=\"../pkg1/ContaineeNotDoc.html\" " +
  42.155 +            "title=\"annotation in pkg1\">@ContaineeNotDoc</a>," +
  42.156 +            "<a href=\"../pkg1/ContaineeNotDoc.html\" " +
  42.157 +            "title=\"annotation in pkg1\">@ContaineeNotDoc</a>}," +
  42.158 +            "<a href=\"../pkg1/ContainerValNotDoc.html#x()\">x</a>=2)"},
  42.159 +        {BUG_ID + FS + "pkg1" + FS + "C.html",
  42.160 +            "<a href=\"../pkg1/ContainerSynthNotDoc.html\" " +
  42.161 +            "title=\"annotation in pkg1\">@ContainerSynthNotDoc</a>(" +
  42.162 +            "<a href=\"../pkg1/ContainerSynthNotDoc.html#value()\">value</a>=" +
  42.163 +            "<a href=\"../pkg1/ContaineeSynthDoc.html\" " +
  42.164 +            "title=\"annotation in pkg1\">@ContaineeSynthDoc</a>)"}
  42.165 +    };
  42.166 +
  42.167 +    /**
  42.168 +     * The entry point of the test.
  42.169 +     * @param args the array of command line arguments.
  42.170 +     */
  42.171 +    public static void main(String[] args) {
  42.172 +        TestRepeatedAnnotations tester = new TestRepeatedAnnotations();
  42.173 +        run(tester, ARGS, TEST, NEGATED_TEST);
  42.174 +        tester.printSummary();
  42.175 +    }
  42.176 +
  42.177 +    /**
  42.178 +     * {@inheritDoc}
  42.179 +     */
  42.180 +    public String getBugId() {
  42.181 +        return BUG_ID;
  42.182 +    }
  42.183 +
  42.184 +    /**
  42.185 +     * {@inheritDoc}
  42.186 +     */
  42.187 +    public String getBugName() {
  42.188 +        return getClass().getName();
  42.189 +    }
  42.190 +}
    43.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
    43.2 +++ b/test/com/sun/javadoc/testRepeatedAnnotations/pkg/C.java	Thu Jan 10 15:53:02 2013 -0800
    43.3 @@ -0,0 +1,39 @@
    43.4 +/*
    43.5 + * Copyright (c) 2012, Oracle and/or its affiliates. All rights reserved.
    43.6 + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
    43.7 + *
    43.8 + * This code is free software; you can redistribute it and/or modify it
    43.9 + * under the terms of the GNU General Public License version 2 only, as
   43.10 + * published by the Free Software Foundation.
   43.11 + *
   43.12 + * This code is distributed in the hope that it will be useful, but WITHOUT
   43.13 + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
   43.14 + * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
   43.15 + * version 2 for more details (a copy is included in the LICENSE file that
   43.16 + * accompanied this code).
   43.17 + *
   43.18 + * You should have received a copy of the GNU General Public License version
   43.19 + * 2 along with this work; if not, write to the Free Software Foundation,
   43.20 + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
   43.21 + *
   43.22 + * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
   43.23 + * or visit www.oracle.com if you need additional information or have any
   43.24 + * questions.
   43.25 + */
   43.26 +
   43.27 +package pkg;
   43.28 +
   43.29 +@ContainerSynthDoc(value={@ContaineeSynthDoc,@ContaineeSynthDoc})
   43.30 +@ContainerRegDoc(value={@ContaineeRegDoc,@ContaineeRegDoc})
   43.31 +@RegContainerDoc(value={@RegContaineeNotDoc,@RegContaineeNotDoc})
   43.32 +@ContainerRegNotDoc(value={@RegContaineeDoc,@RegContaineeDoc})
   43.33 +@RegContainerNotDoc(value={@RegContaineeNotDoc,@RegContaineeNotDoc})
   43.34 +@ContaineeSynthDoc @ContaineeSynthDoc @ContaineeSynthDoc
   43.35 +public class C {
   43.36 +
   43.37 +    @ContainerSynthDoc(value={@ContaineeSynthDoc})
   43.38 +    public void test1() {}
   43.39 +
   43.40 +    @ContaineeSynthDoc @ContaineeSynthDoc
   43.41 +    public void test2() {}
   43.42 +}
    44.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
    44.2 +++ b/test/com/sun/javadoc/testRepeatedAnnotations/pkg/ContaineeRegDoc.java	Thu Jan 10 15:53:02 2013 -0800
    44.3 @@ -0,0 +1,36 @@
    44.4 +/*
    44.5 + * Copyright (c) 2012, Oracle and/or its affiliates. All rights reserved.
    44.6 + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
    44.7 + *
    44.8 + * This code is free software; you can redistribute it and/or modify it
    44.9 + * under the terms of the GNU General Public License version 2 only, as
   44.10 + * published by the Free Software Foundation.
   44.11 + *
   44.12 + * This code is distributed in the hope that it will be useful, but WITHOUT
   44.13 + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
   44.14 + * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
   44.15 + * version 2 for more details (a copy is included in the LICENSE file that
   44.16 + * accompanied this code).
   44.17 + *
   44.18 + * You should have received a copy of the GNU General Public License version
   44.19 + * 2 along with this work; if not, write to the Free Software Foundation,
   44.20 + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
   44.21 + *
   44.22 + * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
   44.23 + * or visit www.oracle.com if you need additional information or have any
   44.24 + * questions.
   44.25 + */
   44.26 +
   44.27 +package pkg;
   44.28 +
   44.29 +import java.lang.annotation.*;
   44.30 +
   44.31 +/**
   44.32 + * This annotation is a documented annotation contained by ContainerRegDoc.
   44.33 + * It will be used to annotate Class C using a non-synthesized form.
   44.34 + *
   44.35 + * @author Bhavesh Patel
   44.36 + */
   44.37 +@Documented
   44.38 +public @interface ContaineeRegDoc {
   44.39 +}
    45.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
    45.2 +++ b/test/com/sun/javadoc/testRepeatedAnnotations/pkg/ContaineeSynthDoc.java	Thu Jan 10 15:53:02 2013 -0800
    45.3 @@ -0,0 +1,37 @@
    45.4 +/*
    45.5 + * Copyright (c) 2012, Oracle and/or its affiliates. All rights reserved.
    45.6 + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
    45.7 + *
    45.8 + * This code is free software; you can redistribute it and/or modify it
    45.9 + * under the terms of the GNU General Public License version 2 only, as
   45.10 + * published by the Free Software Foundation.
   45.11 + *
   45.12 + * This code is distributed in the hope that it will be useful, but WITHOUT
   45.13 + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
   45.14 + * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
   45.15 + * version 2 for more details (a copy is included in the LICENSE file that
   45.16 + * accompanied this code).
   45.17 + *
   45.18 + * You should have received a copy of the GNU General Public License version
   45.19 + * 2 along with this work; if not, write to the Free Software Foundation,
   45.20 + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
   45.21 + *
   45.22 + * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
   45.23 + * or visit www.oracle.com if you need additional information or have any
   45.24 + * questions.
   45.25 + */
   45.26 +
   45.27 +package pkg;
   45.28 +
   45.29 +import java.lang.annotation.*;
   45.30 +
   45.31 +/**
   45.32 + * This annotation is a documented synthesized annotation contained by ContainerSynthDoc.
   45.33 + * It will be used to annotate Class C and a method in the class using a synthesized form.
   45.34 + *
   45.35 + * @author Bhavesh Patel
   45.36 + */
   45.37 +@Documented
   45.38 +@ContainedBy(ContainerSynthDoc.class)
   45.39 +public @interface ContaineeSynthDoc {
   45.40 +}
    46.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
    46.2 +++ b/test/com/sun/javadoc/testRepeatedAnnotations/pkg/ContainerRegDoc.java	Thu Jan 10 15:53:02 2013 -0800
    46.3 @@ -0,0 +1,38 @@
    46.4 +/*
    46.5 + * Copyright (c) 2012, Oracle and/or its affiliates. All rights reserved.
    46.6 + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
    46.7 + *
    46.8 + * This code is free software; you can redistribute it and/or modify it
    46.9 + * under the terms of the GNU General Public License version 2 only, as
   46.10 + * published by the Free Software Foundation.
   46.11 + *
   46.12 + * This code is distributed in the hope that it will be useful, but WITHOUT
   46.13 + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
   46.14 + * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
   46.15 + * version 2 for more details (a copy is included in the LICENSE file that
   46.16 + * accompanied this code).
   46.17 + *
   46.18 + * You should have received a copy of the GNU General Public License version
   46.19 + * 2 along with this work; if not, write to the Free Software Foundation,
   46.20 + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
   46.21 + *
   46.22 + * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
   46.23 + * or visit www.oracle.com if you need additional information or have any
   46.24 + * questions.
   46.25 + */
   46.26 +
   46.27 +package pkg;
   46.28 +
   46.29 +import java.lang.annotation.*;
   46.30 +
   46.31 +/**
   46.32 + * This annotation is a documented annotation container for ContaineeRegDoc.
   46.33 + * It will be used to annotate Class C using a non-synthesized form.
   46.34 + *
   46.35 + * @author Bhavesh Patel
   46.36 + */
   46.37 +@Documented
   46.38 +public @interface ContainerRegDoc {
   46.39 +
   46.40 +    ContaineeRegDoc[] value();
   46.41 +}
    47.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
    47.2 +++ b/test/com/sun/javadoc/testRepeatedAnnotations/pkg/ContainerRegNotDoc.java	Thu Jan 10 15:53:02 2013 -0800
    47.3 @@ -0,0 +1,37 @@
    47.4 +/*
    47.5 + * Copyright (c) 2012, Oracle and/or its affiliates. All rights reserved.
    47.6 + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
    47.7 + *
    47.8 + * This code is free software; you can redistribute it and/or modify it
    47.9 + * under the terms of the GNU General Public License version 2 only, as
   47.10 + * published by the Free Software Foundation.
   47.11 + *
   47.12 + * This code is distributed in the hope that it will be useful, but WITHOUT
   47.13 + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
   47.14 + * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
   47.15 + * version 2 for more details (a copy is included in the LICENSE file that
   47.16 + * accompanied this code).
   47.17 + *
   47.18 + * You should have received a copy of the GNU General Public License version
   47.19 + * 2 along with this work; if not, write to the Free Software Foundation,
   47.20 + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
   47.21 + *
   47.22 + * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
   47.23 + * or visit www.oracle.com if you need additional information or have any
   47.24 + * questions.
   47.25 + */
   47.26 +
   47.27 +package pkg;
   47.28 +
   47.29 +import java.lang.annotation.*;
   47.30 +
   47.31 +/**
   47.32 + * This annotation is a non-documented annotation container for RegContaineeDoc.
   47.33 + * It will be used to annotate Class C using a non-synthesized form.
   47.34 + *
   47.35 + * @author Bhavesh Patel
   47.36 + */
   47.37 +public @interface ContainerRegNotDoc {
   47.38 +
   47.39 +    RegContaineeDoc[] value();
   47.40 +}
    48.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
    48.2 +++ b/test/com/sun/javadoc/testRepeatedAnnotations/pkg/ContainerSynthDoc.java	Thu Jan 10 15:53:02 2013 -0800
    48.3 @@ -0,0 +1,39 @@
    48.4 +/*
    48.5 + * Copyright (c) 2012, Oracle and/or its affiliates. All rights reserved.
    48.6 + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
    48.7 + *
    48.8 + * This code is free software; you can redistribute it and/or modify it
    48.9 + * under the terms of the GNU General Public License version 2 only, as
   48.10 + * published by the Free Software Foundation.
   48.11 + *
   48.12 + * This code is distributed in the hope that it will be useful, but WITHOUT
   48.13 + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
   48.14 + * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
   48.15 + * version 2 for more details (a copy is included in the LICENSE file that
   48.16 + * accompanied this code).
   48.17 + *
   48.18 + * You should have received a copy of the GNU General Public License version
   48.19 + * 2 along with this work; if not, write to the Free Software Foundation,
   48.20 + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
   48.21 + *
   48.22 + * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
   48.23 + * or visit www.oracle.com if you need additional information or have any
   48.24 + * questions.
   48.25 + */
   48.26 +
   48.27 +package pkg;
   48.28 +
   48.29 +import java.lang.annotation.*;
   48.30 +
   48.31 +/**
   48.32 + * This annotation is a documented synthesized annotation container for ContaineeSynthDoc.
   48.33 + * It will be used to annotate Class C and a method in the class using a synthesized form.
   48.34 + *
   48.35 + * @author Bhavesh Patel
   48.36 + */
   48.37 +@Documented
   48.38 +@ContainerFor(ContaineeSynthDoc.class)
   48.39 +public @interface ContainerSynthDoc {
   48.40 +
   48.41 +    ContaineeSynthDoc[] value();
   48.42 +}
    49.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
    49.2 +++ b/test/com/sun/javadoc/testRepeatedAnnotations/pkg/D.java	Thu Jan 10 15:53:02 2013 -0800
    49.3 @@ -0,0 +1,37 @@
    49.4 +/*
    49.5 + * Copyright (c) 2012, Oracle and/or its affiliates. All rights reserved.
    49.6 + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
    49.7 + *
    49.8 + * This code is free software; you can redistribute it and/or modify it
    49.9 + * under the terms of the GNU General Public License version 2 only, as
   49.10 + * published by the Free Software Foundation.
   49.11 + *
   49.12 + * This code is distributed in the hope that it will be useful, but WITHOUT
   49.13 + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
   49.14 + * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
   49.15 + * version 2 for more details (a copy is included in the LICENSE file that
   49.16 + * accompanied this code).
   49.17 + *
   49.18 + * You should have received a copy of the GNU General Public License version
   49.19 + * 2 along with this work; if not, write to the Free Software Foundation,
   49.20 + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
   49.21 + *
   49.22 + * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
   49.23 + * or visit www.oracle.com if you need additional information or have any
   49.24 + * questions.
   49.25 + */
   49.26 +
   49.27 +package pkg;
   49.28 +
   49.29 +@RegDoc(x=1)
   49.30 +public class D {
   49.31 +
   49.32 +    @RegArryDoc(y={1})
   49.33 +    public void test1() {}
   49.34 +
   49.35 +    @RegArryDoc(y={1,2})
   49.36 +    public void test2() {}
   49.37 +
   49.38 +    @NonSynthDocContainer(value={@RegArryDoc})
   49.39 +    public void test3() {}
   49.40 +}
    50.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
    50.2 +++ b/test/com/sun/javadoc/testRepeatedAnnotations/pkg/NonSynthDocContainer.java	Thu Jan 10 15:53:02 2013 -0800
    50.3 @@ -0,0 +1,38 @@
    50.4 +/*
    50.5 + * Copyright (c) 2012, Oracle and/or its affiliates. All rights reserved.
    50.6 + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
    50.7 + *
    50.8 + * This code is free software; you can redistribute it and/or modify it
    50.9 + * under the terms of the GNU General Public License version 2 only, as
   50.10 + * published by the Free Software Foundation.
   50.11 + *
   50.12 + * This code is distributed in the hope that it will be useful, but WITHOUT
   50.13 + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
   50.14 + * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
   50.15 + * version 2 for more details (a copy is included in the LICENSE file that
   50.16 + * accompanied this code).
   50.17 + *
   50.18 + * You should have received a copy of the GNU General Public License version
   50.19 + * 2 along with this work; if not, write to the Free Software Foundation,
   50.20 + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
   50.21 + *
   50.22 + * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
   50.23 + * or visit www.oracle.com if you need additional information or have any
   50.24 + * questions.
   50.25 + */
   50.26 +
   50.27 +package pkg;
   50.28 +
   50.29 +import java.lang.annotation.*;
   50.30 +
   50.31 +/**
   50.32 + * This annotation is a documented annotation.
   50.33 + * It will be used to annotate methods in class D.
   50.34 + *
   50.35 + * @author Bhavesh Patel
   50.36 + */
   50.37 +@Documented
   50.38 +public @interface NonSynthDocContainer {
   50.39 +
   50.40 +    RegArryDoc[] value();
   50.41 +}
    51.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
    51.2 +++ b/test/com/sun/javadoc/testRepeatedAnnotations/pkg/RegArryDoc.java	Thu Jan 10 15:53:02 2013 -0800
    51.3 @@ -0,0 +1,38 @@
    51.4 +/*
    51.5 + * Copyright (c) 2012, Oracle and/or its affiliates. All rights reserved.
    51.6 + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
    51.7 + *
    51.8 + * This code is free software; you can redistribute it and/or modify it
    51.9 + * under the terms of the GNU General Public License version 2 only, as
   51.10 + * published by the Free Software Foundation.
   51.11 + *
   51.12 + * This code is distributed in the hope that it will be useful, but WITHOUT
   51.13 + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
   51.14 + * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
   51.15 + * version 2 for more details (a copy is included in the LICENSE file that
   51.16 + * accompanied this code).
   51.17 + *
   51.18 + * You should have received a copy of the GNU General Public License version
   51.19 + * 2 along with this work; if not, write to the Free Software Foundation,
   51.20 + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
   51.21 + *
   51.22 + * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
   51.23 + * or visit www.oracle.com if you need additional information or have any
   51.24 + * questions.
   51.25 + */
   51.26 +
   51.27 +package pkg;
   51.28 +
   51.29 +import java.lang.annotation.*;
   51.30 +
   51.31 +/**
   51.32 + * This annotation is a documented annotation.
   51.33 + * It will be used to annotate methods in Class D.
   51.34 + *
   51.35 + * @author Bhavesh Patel
   51.36 + */
   51.37 +@Documented
   51.38 +public @interface RegArryDoc {
   51.39 +
   51.40 +    int[] y();
   51.41 +}
    52.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
    52.2 +++ b/test/com/sun/javadoc/testRepeatedAnnotations/pkg/RegContaineeDoc.java	Thu Jan 10 15:53:02 2013 -0800
    52.3 @@ -0,0 +1,36 @@
    52.4 +/*
    52.5 + * Copyright (c) 2012, Oracle and/or its affiliates. All rights reserved.
    52.6 + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
    52.7 + *
    52.8 + * This code is free software; you can redistribute it and/or modify it
    52.9 + * under the terms of the GNU General Public License version 2 only, as
   52.10 + * published by the Free Software Foundation.
   52.11 + *
   52.12 + * This code is distributed in the hope that it will be useful, but WITHOUT
   52.13 + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
   52.14 + * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
   52.15 + * version 2 for more details (a copy is included in the LICENSE file that
   52.16 + * accompanied this code).
   52.17 + *
   52.18 + * You should have received a copy of the GNU General Public License version
   52.19 + * 2 along with this work; if not, write to the Free Software Foundation,
   52.20 + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
   52.21 + *
   52.22 + * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
   52.23 + * or visit www.oracle.com if you need additional information or have any
   52.24 + * questions.
   52.25 + */
   52.26 +
   52.27 +package pkg;
   52.28 +
   52.29 +import java.lang.annotation.*;
   52.30 +
   52.31 +/**
   52.32 + * This annotation is a documented annotation contained by ContainerRegNotDoc.
   52.33 + * It will be used to annotate Class C using a non-synthesized form.
   52.34 + *
   52.35 + * @author Bhavesh Patel
   52.36 + */
   52.37 +@Documented
   52.38 +public @interface RegContaineeDoc {
   52.39 +}
    53.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
    53.2 +++ b/test/com/sun/javadoc/testRepeatedAnnotations/pkg/RegContaineeNotDoc.java	Thu Jan 10 15:53:02 2013 -0800
    53.3 @@ -0,0 +1,36 @@
    53.4 +/*
    53.5 + * Copyright (c) 2012, Oracle and/or its affiliates. All rights reserved.
    53.6 + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
    53.7 + *
    53.8 + * This code is free software; you can redistribute it and/or modify it
    53.9 + * under the terms of the GNU General Public License version 2 only, as
   53.10 + * published by the Free Software Foundation.
   53.11 + *
   53.12 + * This code is distributed in the hope that it will be useful, but WITHOUT
   53.13 + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
   53.14 + * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
   53.15 + * version 2 for more details (a copy is included in the LICENSE file that
   53.16 + * accompanied this code).
   53.17 + *
   53.18 + * You should have received a copy of the GNU General Public License version
   53.19 + * 2 along with this work; if not, write to the Free Software Foundation,
   53.20 + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
   53.21 + *
   53.22 + * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
   53.23 + * or visit www.oracle.com if you need additional information or have any
   53.24 + * questions.
   53.25 + */
   53.26 +
   53.27 +package pkg;
   53.28 +
   53.29 +import java.lang.annotation.*;
   53.30 +
   53.31 +/**
   53.32 + * This annotation is a non-documented annotation contained by RegContainerNotDoc
   53.33 + * and RegContainerDoc.
   53.34 + * It will be used to annotate Class C using a non-synthesized form.
   53.35 + *
   53.36 + * @author Bhavesh Patel
   53.37 + */
   53.38 +public @interface RegContaineeNotDoc {
   53.39 +}
    54.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
    54.2 +++ b/test/com/sun/javadoc/testRepeatedAnnotations/pkg/RegContainerDoc.java	Thu Jan 10 15:53:02 2013 -0800
    54.3 @@ -0,0 +1,38 @@
    54.4 +/*
    54.5 + * Copyright (c) 2012, Oracle and/or its affiliates. All rights reserved.
    54.6 + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
    54.7 + *
    54.8 + * This code is free software; you can redistribute it and/or modify it
    54.9 + * under the terms of the GNU General Public License version 2 only, as
   54.10 + * published by the Free Software Foundation.
   54.11 + *
   54.12 + * This code is distributed in the hope that it will be useful, but WITHOUT
   54.13 + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
   54.14 + * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
   54.15 + * version 2 for more details (a copy is included in the LICENSE file that
   54.16 + * accompanied this code).
   54.17 + *
   54.18 + * You should have received a copy of the GNU General Public License version
   54.19 + * 2 along with this work; if not, write to the Free Software Foundation,
   54.20 + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
   54.21 + *
   54.22 + * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
   54.23 + * or visit www.oracle.com if you need additional information or have any
   54.24 + * questions.
   54.25 + */
   54.26 +
   54.27 +package pkg;
   54.28 +
   54.29 +import java.lang.annotation.*;
   54.30 +
   54.31 +/**
   54.32 + * This annotation is a documented annotation container for RegContainerDoc.
   54.33 + * It will be used to annotate Class C using a non-synthesized form.
   54.34 + *
   54.35 + * @author Bhavesh Patel
   54.36 + */
   54.37 +@Documented
   54.38 +public @interface RegContainerDoc {
   54.39 +
   54.40 +    RegContaineeNotDoc[] value();
   54.41 +}
    55.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
    55.2 +++ b/test/com/sun/javadoc/testRepeatedAnnotations/pkg/RegContainerNotDoc.java	Thu Jan 10 15:53:02 2013 -0800
    55.3 @@ -0,0 +1,37 @@
    55.4 +/*
    55.5 + * Copyright (c) 2012, Oracle and/or its affiliates. All rights reserved.
    55.6 + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
    55.7 + *
    55.8 + * This code is free software; you can redistribute it and/or modify it
    55.9 + * under the terms of the GNU General Public License version 2 only, as
   55.10 + * published by the Free Software Foundation.
   55.11 + *
   55.12 + * This code is distributed in the hope that it will be useful, but WITHOUT
   55.13 + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
   55.14 + * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
   55.15 + * version 2 for more details (a copy is included in the LICENSE file that
   55.16 + * accompanied this code).
   55.17 + *
   55.18 + * You should have received a copy of the GNU General Public License version
   55.19 + * 2 along with this work; if not, write to the Free Software Foundation,
   55.20 + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
   55.21 + *
   55.22 + * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
   55.23 + * or visit www.oracle.com if you need additional information or have any
   55.24 + * questions.
   55.25 + */
   55.26 +
   55.27 +package pkg;
   55.28 +
   55.29 +import java.lang.annotation.*;
   55.30 +
   55.31 +/**
   55.32 + * This annotation is a non-documented annotation container for RegContaineeNotDoc.
   55.33 + * It will be used to annotate Class C using a non-synthesized form.
   55.34 + *
   55.35 + * @author Bhavesh Patel
   55.36 + */
   55.37 +public @interface RegContainerNotDoc {
   55.38 +
   55.39 +    RegContaineeNotDoc[] value();
   55.40 +}
    56.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
    56.2 +++ b/test/com/sun/javadoc/testRepeatedAnnotations/pkg/RegDoc.java	Thu Jan 10 15:53:02 2013 -0800
    56.3 @@ -0,0 +1,38 @@
    56.4 +/*
    56.5 + * Copyright (c) 2012, Oracle and/or its affiliates. All rights reserved.
    56.6 + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
    56.7 + *
    56.8 + * This code is free software; you can redistribute it and/or modify it
    56.9 + * under the terms of the GNU General Public License version 2 only, as
   56.10 + * published by the Free Software Foundation.
   56.11 + *
   56.12 + * This code is distributed in the hope that it will be useful, but WITHOUT
   56.13 + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
   56.14 + * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
   56.15 + * version 2 for more details (a copy is included in the LICENSE file that
   56.16 + * accompanied this code).
   56.17 + *
   56.18 + * You should have received a copy of the GNU General Public License version
   56.19 + * 2 along with this work; if not, write to the Free Software Foundation,
   56.20 + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
   56.21 + *
   56.22 + * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
   56.23 + * or visit www.oracle.com if you need additional information or have any
   56.24 + * questions.
   56.25 + */
   56.26 +
   56.27 +package pkg;
   56.28 +
   56.29 +import java.lang.annotation.*;
   56.30 +
   56.31 +/**
   56.32 + * This annotation is a documented annotation.
   56.33 + * It will be used to annotate Class D.
   56.34 + *
   56.35 + * @author Bhavesh Patel
   56.36 + */
   56.37 +@Documented
   56.38 +public @interface RegDoc {
   56.39 +
   56.40 +    int x();
   56.41 +}
    57.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
    57.2 +++ b/test/com/sun/javadoc/testRepeatedAnnotations/pkg1/C.java	Thu Jan 10 15:53:02 2013 -0800
    57.3 @@ -0,0 +1,38 @@
    57.4 +/*
    57.5 + * Copyright (c) 2012, Oracle and/or its affiliates. All rights reserved.
    57.6 + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
    57.7 + *
    57.8 + * This code is free software; you can redistribute it and/or modify it
    57.9 + * under the terms of the GNU General Public License version 2 only, as
   57.10 + * published by the Free Software Foundation.
   57.11 + *
   57.12 + * This code is distributed in the hope that it will be useful, but WITHOUT
   57.13 + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
   57.14 + * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
   57.15 + * version 2 for more details (a copy is included in the LICENSE file that
   57.16 + * accompanied this code).
   57.17 + *
   57.18 + * You should have received a copy of the GNU General Public License version
   57.19 + * 2 along with this work; if not, write to the Free Software Foundation,
   57.20 + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
   57.21 + *
   57.22 + * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
   57.23 + * or visit www.oracle.com if you need additional information or have any
   57.24 + * questions.
   57.25 + */
   57.26 +
   57.27 +package pkg1;
   57.28 +
   57.29 +@ContainerSynthNotDoc(value={@ContaineeSynthDoc,@ContaineeSynthDoc})
   57.30 +@RegContainerValDoc(value={@RegContaineeNotDoc,@RegContaineeNotDoc},y=3)
   57.31 +@ContainerValDoc(value={@ContaineeNotDoc,@ContaineeNotDoc},x=1)
   57.32 +@RegContainerValNotDoc(value={@RegContaineeDoc,@RegContaineeDoc},y=4)
   57.33 +@ContainerValNotDoc(value={@ContaineeNotDoc,@ContaineeNotDoc},x=2)
   57.34 +public class C {
   57.35 +
   57.36 +    @ContainerSynthNotDoc(value={@ContaineeSynthDoc})
   57.37 +    public void test1() {}
   57.38 +
   57.39 +    @ContaineeSynthDoc @ContaineeSynthDoc
   57.40 +    public void test2() {}
   57.41 +}
    58.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
    58.2 +++ b/test/com/sun/javadoc/testRepeatedAnnotations/pkg1/ContaineeNotDoc.java	Thu Jan 10 15:53:02 2013 -0800
    58.3 @@ -0,0 +1,36 @@
    58.4 +/*
    58.5 + * Copyright (c) 2012, Oracle and/or its affiliates. All rights reserved.
    58.6 + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
    58.7 + *
    58.8 + * This code is free software; you can redistribute it and/or modify it
    58.9 + * under the terms of the GNU General Public License version 2 only, as
   58.10 + * published by the Free Software Foundation.
   58.11 + *
   58.12 + * This code is distributed in the hope that it will be useful, but WITHOUT
   58.13 + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
   58.14 + * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
   58.15 + * version 2 for more details (a copy is included in the LICENSE file that
   58.16 + * accompanied this code).
   58.17 + *
   58.18 + * You should have received a copy of the GNU General Public License version
   58.19 + * 2 along with this work; if not, write to the Free Software Foundation,
   58.20 + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
   58.21 + *
   58.22 + * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
   58.23 + * or visit www.oracle.com if you need additional information or have any
   58.24 + * questions.
   58.25 + */
   58.26 +
   58.27 +package pkg1;
   58.28 +
   58.29 +import java.lang.annotation.*;
   58.30 +
   58.31 +/**
   58.32 + * This annotation is a non-documented annotation contained by ContainerValNotDoc
   58.33 + * and ContainerValDoc.
   58.34 + * It will be used to annotate Class C using a non-synthesized form.
   58.35 + *
   58.36 + * @author Bhavesh Patel
   58.37 + */
   58.38 +public @interface ContaineeNotDoc {
   58.39 +}
    59.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
    59.2 +++ b/test/com/sun/javadoc/testRepeatedAnnotations/pkg1/ContaineeSynthDoc.java	Thu Jan 10 15:53:02 2013 -0800
    59.3 @@ -0,0 +1,37 @@
    59.4 +/*
    59.5 + * Copyright (c) 2012, Oracle and/or its affiliates. All rights reserved.
    59.6 + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
    59.7 + *
    59.8 + * This code is free software; you can redistribute it and/or modify it
    59.9 + * under the terms of the GNU General Public License version 2 only, as
   59.10 + * published by the Free Software Foundation.
   59.11 + *
   59.12 + * This code is distributed in the hope that it will be useful, but WITHOUT
   59.13 + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
   59.14 + * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
   59.15 + * version 2 for more details (a copy is included in the LICENSE file that
   59.16 + * accompanied this code).
   59.17 + *
   59.18 + * You should have received a copy of the GNU General Public License version
   59.19 + * 2 along with this work; if not, write to the Free Software Foundation,
   59.20 + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
   59.21 + *
   59.22 + * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
   59.23 + * or visit www.oracle.com if you need additional information or have any
   59.24 + * questions.
   59.25 + */
   59.26 +
   59.27 +package pkg1;
   59.28 +
   59.29 +import java.lang.annotation.*;
   59.30 +
   59.31 +/**
   59.32 + * This annotation is a documented synthesized annotation contained by ContainerSynthNotDoc.
   59.33 + * It will be used to annotate Class C and methods in the class using a synthesized form.
   59.34 + *
   59.35 + * @author Bhavesh Patel
   59.36 + */
   59.37 +@Documented
   59.38 +@ContainedBy(ContainerSynthNotDoc.class)
   59.39 +public @interface ContaineeSynthDoc {
   59.40 +}
    60.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
    60.2 +++ b/test/com/sun/javadoc/testRepeatedAnnotations/pkg1/ContainerSynthNotDoc.java	Thu Jan 10 15:53:02 2013 -0800
    60.3 @@ -0,0 +1,38 @@
    60.4 +/*
    60.5 + * Copyright (c) 2012, Oracle and/or its affiliates. All rights reserved.
    60.6 + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
    60.7 + *
    60.8 + * This code is free software; you can redistribute it and/or modify it
    60.9 + * under the terms of the GNU General Public License version 2 only, as
   60.10 + * published by the Free Software Foundation.
   60.11 + *
   60.12 + * This code is distributed in the hope that it will be useful, but WITHOUT
   60.13 + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
   60.14 + * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
   60.15 + * version 2 for more details (a copy is included in the LICENSE file that
   60.16 + * accompanied this code).
   60.17 + *
   60.18 + * You should have received a copy of the GNU General Public License version
   60.19 + * 2 along with this work; if not, write to the Free Software Foundation,
   60.20 + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
   60.21 + *
   60.22 + * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
   60.23 + * or visit www.oracle.com if you need additional information or have any
   60.24 + * questions.
   60.25 + */
   60.26 +
   60.27 +package pkg1;
   60.28 +
   60.29 +import java.lang.annotation.*;
   60.30 +
   60.31 +/**
   60.32 + * This annotation is a non-documented synthesized annotation container for ContaineeSynthDoc.
   60.33 + * It will be used to annotate Class C and methods in the class using a synthesized form.
   60.34 + *
   60.35 + * @author Bhavesh Patel
   60.36 + */
   60.37 +@ContainerFor(ContaineeSynthDoc.class)
   60.38 +public @interface ContainerSynthNotDoc {
   60.39 +
   60.40 +    ContaineeSynthDoc[] value();
   60.41 +}
    61.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
    61.2 +++ b/test/com/sun/javadoc/testRepeatedAnnotations/pkg1/ContainerValDoc.java	Thu Jan 10 15:53:02 2013 -0800
    61.3 @@ -0,0 +1,40 @@
    61.4 +/*
    61.5 + * Copyright (c) 2012, Oracle and/or its affiliates. All rights reserved.
    61.6 + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
    61.7 + *
    61.8 + * This code is free software; you can redistribute it and/or modify it
    61.9 + * under the terms of the GNU General Public License version 2 only, as
   61.10 + * published by the Free Software Foundation.
   61.11 + *
   61.12 + * This code is distributed in the hope that it will be useful, but WITHOUT
   61.13 + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
   61.14 + * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
   61.15 + * version 2 for more details (a copy is included in the LICENSE file that
   61.16 + * accompanied this code).
   61.17 + *
   61.18 + * You should have received a copy of the GNU General Public License version
   61.19 + * 2 along with this work; if not, write to the Free Software Foundation,
   61.20 + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
   61.21 + *
   61.22 + * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
   61.23 + * or visit www.oracle.com if you need additional information or have any
   61.24 + * questions.
   61.25 + */
   61.26 +
   61.27 +package pkg1;
   61.28 +
   61.29 +import java.lang.annotation.*;
   61.30 +
   61.31 +/**
   61.32 + * This annotation is a documented annotation container for ContaineeNotDoc.
   61.33 + * It will be used to annotate Class C using a non-synthesized form.
   61.34 + *
   61.35 + * @author Bhavesh Patel
   61.36 + */
   61.37 +@Documented
   61.38 +public @interface ContainerValDoc {
   61.39 +
   61.40 +    ContaineeNotDoc[] value();
   61.41 +
   61.42 +    int x();
   61.43 +}
    62.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
    62.2 +++ b/test/com/sun/javadoc/testRepeatedAnnotations/pkg1/ContainerValNotDoc.java	Thu Jan 10 15:53:02 2013 -0800
    62.3 @@ -0,0 +1,39 @@
    62.4 +/*
    62.5 + * Copyright (c) 2012, Oracle and/or its affiliates. All rights reserved.
    62.6 + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
    62.7 + *
    62.8 + * This code is free software; you can redistribute it and/or modify it
    62.9 + * under the terms of the GNU General Public License version 2 only, as
   62.10 + * published by the Free Software Foundation.
   62.11 + *
   62.12 + * This code is distributed in the hope that it will be useful, but WITHOUT
   62.13 + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
   62.14 + * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
   62.15 + * version 2 for more details (a copy is included in the LICENSE file that
   62.16 + * accompanied this code).
   62.17 + *
   62.18 + * You should have received a copy of the GNU General Public License version
   62.19 + * 2 along with this work; if not, write to the Free Software Foundation,
   62.20 + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
   62.21 + *
   62.22 + * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
   62.23 + * or visit www.oracle.com if you need additional information or have any
   62.24 + * questions.
   62.25 + */
   62.26 +
   62.27 +package pkg1;
   62.28 +
   62.29 +import java.lang.annotation.*;
   62.30 +
   62.31 +/**
   62.32 + * This annotation is a non-documented annotation container for ContaineeNotDoc.
   62.33 + * It will be used to annotate Class C using a non-synthesized form.
   62.34 + *
   62.35 + * @author Bhavesh Patel
   62.36 + */
   62.37 +public @interface ContainerValNotDoc {
   62.38 +
   62.39 +    ContaineeNotDoc[] value();
   62.40 +
   62.41 +    int x();
   62.42 +}
    63.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
    63.2 +++ b/test/com/sun/javadoc/testRepeatedAnnotations/pkg1/RegContaineeDoc.java	Thu Jan 10 15:53:02 2013 -0800
    63.3 @@ -0,0 +1,36 @@
    63.4 +/*
    63.5 + * Copyright (c) 2012, Oracle and/or its affiliates. All rights reserved.
    63.6 + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
    63.7 + *
    63.8 + * This code is free software; you can redistribute it and/or modify it
    63.9 + * under the terms of the GNU General Public License version 2 only, as
   63.10 + * published by the Free Software Foundation.
   63.11 + *
   63.12 + * This code is distributed in the hope that it will be useful, but WITHOUT
   63.13 + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
   63.14 + * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
   63.15 + * version 2 for more details (a copy is included in the LICENSE file that
   63.16 + * accompanied this code).
   63.17 + *
   63.18 + * You should have received a copy of the GNU General Public License version
   63.19 + * 2 along with this work; if not, write to the Free Software Foundation,
   63.20 + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
   63.21 + *
   63.22 + * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
   63.23 + * or visit www.oracle.com if you need additional information or have any
   63.24 + * questions.
   63.25 + */
   63.26 +
   63.27 +package pkg1;
   63.28 +
   63.29 +import java.lang.annotation.*;
   63.30 +
   63.31 +/**
   63.32 + * This annotation is a documented annotation contained by RegContainerValNotDoc.
   63.33 + * It will be used to annotate Class C using a non-synthesized form.
   63.34 + *
   63.35 + * @author Bhavesh Patel
   63.36 + */
   63.37 +@Documented
   63.38 +public @interface RegContaineeDoc {
   63.39 +}
    64.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
    64.2 +++ b/test/com/sun/javadoc/testRepeatedAnnotations/pkg1/RegContaineeNotDoc.java	Thu Jan 10 15:53:02 2013 -0800
    64.3 @@ -0,0 +1,35 @@
    64.4 +/*
    64.5 + * Copyright (c) 2012, Oracle and/or its affiliates. All rights reserved.
    64.6 + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
    64.7 + *
    64.8 + * This code is free software; you can redistribute it and/or modify it
    64.9 + * under the terms of the GNU General Public License version 2 only, as
   64.10 + * published by the Free Software Foundation.
   64.11 + *
   64.12 + * This code is distributed in the hope that it will be useful, but WITHOUT
   64.13 + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
   64.14 + * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
   64.15 + * version 2 for more details (a copy is included in the LICENSE file that
   64.16 + * accompanied this code).
   64.17 + *
   64.18 + * You should have received a copy of the GNU General Public License version
   64.19 + * 2 along with this work; if not, write to the Free Software Foundation,
   64.20 + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
   64.21 + *
   64.22 + * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
   64.23 + * or visit www.oracle.com if you need additional information or have any
   64.24 + * questions.
   64.25 + */
   64.26 +
   64.27 +package pkg1;
   64.28 +
   64.29 +import java.lang.annotation.*;
   64.30 +
   64.31 +/**
   64.32 + * This annotation is a non-documented annotation contained by RegContainerValDoc.
   64.33 + * It will be used to annotate Class C using a non-synthesized form.
   64.34 + *
   64.35 + * @author Bhavesh Patel
   64.36 + */
   64.37 +public @interface RegContaineeNotDoc {
   64.38 +}
    65.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
    65.2 +++ b/test/com/sun/javadoc/testRepeatedAnnotations/pkg1/RegContainerValDoc.java	Thu Jan 10 15:53:02 2013 -0800
    65.3 @@ -0,0 +1,40 @@
    65.4 +/*
    65.5 + * Copyright (c) 2012, Oracle and/or its affiliates. All rights reserved.
    65.6 + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
    65.7 + *
    65.8 + * This code is free software; you can redistribute it and/or modify it
    65.9 + * under the terms of the GNU General Public License version 2 only, as
   65.10 + * published by the Free Software Foundation.
   65.11 + *
   65.12 + * This code is distributed in the hope that it will be useful, but WITHOUT
   65.13 + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
   65.14 + * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
   65.15 + * version 2 for more details (a copy is included in the LICENSE file that
   65.16 + * accompanied this code).
   65.17 + *
   65.18 + * You should have received a copy of the GNU General Public License version
   65.19 + * 2 along with this work; if not, write to the Free Software Foundation,
   65.20 + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
   65.21 + *
   65.22 + * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
   65.23 + * or visit www.oracle.com if you need additional information or have any
   65.24 + * questions.
   65.25 + */
   65.26 +
   65.27 +package pkg1;
   65.28 +
   65.29 +import java.lang.annotation.*;
   65.30 +
   65.31 +/**
   65.32 + * This annotation is a documented annotation container for RegContaineeNotDoc.
   65.33 + * It will be used to annotate Class C using a non-synthesized form.
   65.34 + *
   65.35 + * @author Bhavesh Patel
   65.36 + */
   65.37 +@Documented
   65.38 +public @interface RegContainerValDoc {
   65.39 +
   65.40 +    RegContaineeNotDoc[] value();
   65.41 +
   65.42 +    int y();
   65.43 +}
    66.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
    66.2 +++ b/test/com/sun/javadoc/testRepeatedAnnotations/pkg1/RegContainerValNotDoc.java	Thu Jan 10 15:53:02 2013 -0800
    66.3 @@ -0,0 +1,39 @@
    66.4 +/*
    66.5 + * Copyright (c) 2012, Oracle and/or its affiliates. All rights reserved.
    66.6 + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
    66.7 + *
    66.8 + * This code is free software; you can redistribute it and/or modify it
    66.9 + * under the terms of the GNU General Public License version 2 only, as
   66.10 + * published by the Free Software Foundation.
   66.11 + *
   66.12 + * This code is distributed in the hope that it will be useful, but WITHOUT
   66.13 + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
   66.14 + * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
   66.15 + * version 2 for more details (a copy is included in the LICENSE file that
   66.16 + * accompanied this code).
   66.17 + *
   66.18 + * You should have received a copy of the GNU General Public License version
   66.19 + * 2 along with this work; if not, write to the Free Software Foundation,
   66.20 + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
   66.21 + *
   66.22 + * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
   66.23 + * or visit www.oracle.com if you need additional information or have any
   66.24 + * questions.
   66.25 + */
   66.26 +
   66.27 +package pkg1;
   66.28 +
   66.29 +import java.lang.annotation.*;
   66.30 +
   66.31 +/**
   66.32 + * This annotation is a non-documented annotation container for RegContaineeDoc.
   66.33 + * It will be used to annotate Class C using a non-synthesized form.
   66.34 + *
   66.35 + * @author Bhavesh Patel
   66.36 + */
   66.37 +public @interface RegContainerValNotDoc {
   66.38 +
   66.39 +    RegContaineeDoc[] value();
   66.40 +
   66.41 +    int y();
   66.42 +}
    67.1 --- a/test/tools/doclint/DocLintTester.java	Thu Jan 10 09:56:09 2013 -0800
    67.2 +++ b/test/tools/doclint/DocLintTester.java	Thu Jan 10 15:53:02 2013 -0800
    67.3 @@ -107,7 +107,7 @@
    67.4  
    67.5      private static final Pattern dirFileLine = Pattern.compile(
    67.6              "(?m)"                          // multi-line mode
    67.7 -            + "^([^: ]+?)"                  // directory part of file name
    67.8 +            + "^(.*?)"                      // directory part of file name
    67.9              + "([A-Za-z0-9.]+:[0-9]+:)");   // file name and line number
   67.10  
   67.11      String removeFileNames(String s) {
    68.1 --- a/test/tools/javac/Diagnostics/6769027/T6769027.java	Thu Jan 10 09:56:09 2013 -0800
    68.2 +++ b/test/tools/javac/Diagnostics/6769027/T6769027.java	Thu Jan 10 15:53:02 2013 -0800
    68.3 @@ -1,5 +1,5 @@
    68.4  /*
    68.5 - * Copyright (c) 2009, 2011, Oracle and/or its affiliates. All rights reserved.
    68.6 + * Copyright (c) 2009, 2013, Oracle and/or its affiliates. All rights reserved.
    68.7   * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
    68.8   *
    68.9   * This code is free software; you can redistribute it and/or modify it
   68.10 @@ -26,14 +26,19 @@
   68.11   * @bug     6769027
   68.12   * @summary Source line should be displayed immediately after the first diagnostic line
   68.13   * @author  Maurizio Cimadamore
   68.14 + * @library ../../lib
   68.15 + * @build JavacTestingAbstractThreadedTest
   68.16   * @run main/othervm T6769027
   68.17   */
   68.18 +
   68.19  import java.net.URI;
   68.20  import java.util.regex.Matcher;
   68.21  import javax.tools.*;
   68.22  import com.sun.tools.javac.util.*;
   68.23  
   68.24 -public class T6769027 {
   68.25 +public class T6769027
   68.26 +    extends JavacTestingAbstractThreadedTest
   68.27 +    implements Runnable {
   68.28  
   68.29      enum OutputKind {
   68.30          RAW("rawDiagnostics","rawDiagnostics"),
   68.31 @@ -314,7 +319,7 @@
   68.32  
   68.33          @Override
   68.34          protected java.io.PrintWriter getWriterForDiagnosticType(JCDiagnostic.DiagnosticType dt) {
   68.35 -            return new java.io.PrintWriter(System.out);
   68.36 +            return outWriter;
   68.37          }
   68.38  
   68.39          @Override
   68.40 @@ -323,13 +328,42 @@
   68.41          }
   68.42      }
   68.43  
   68.44 -    int nerrors = 0;
   68.45 +    OutputKind outputKind;
   68.46 +    ErrorKind errorKind;
   68.47 +    MultilineKind multiKind;
   68.48 +    MultilinePolicy multiPolicy;
   68.49 +    PositionKind posKind;
   68.50 +    XDiagsSource xdiagsSource;
   68.51 +    XDiagsCompact xdiagsCompact;
   68.52 +    CaretKind caretKind;
   68.53 +    SourceLineKind sourceLineKind;
   68.54 +    IndentKind summaryIndent;
   68.55 +    IndentKind detailsIndent;
   68.56 +    IndentKind sourceIndent;
   68.57 +    IndentKind subdiagsIndent;
   68.58  
   68.59 -    void exec(OutputKind outputKind, ErrorKind errorKind, MultilineKind multiKind,
   68.60 +    T6769027(OutputKind outputKind, ErrorKind errorKind, MultilineKind multiKind,
   68.61              MultilinePolicy multiPolicy, PositionKind posKind, XDiagsSource xdiagsSource,
   68.62              XDiagsCompact xdiagsCompact, CaretKind caretKind, SourceLineKind sourceLineKind,
   68.63              IndentKind summaryIndent, IndentKind detailsIndent, IndentKind sourceIndent,
   68.64              IndentKind subdiagsIndent) {
   68.65 +        this.outputKind = outputKind;
   68.66 +        this.errorKind = errorKind;
   68.67 +        this.multiKind = multiKind;
   68.68 +        this.multiPolicy = multiPolicy;
   68.69 +        this.posKind = posKind;
   68.70 +        this.xdiagsSource = xdiagsSource;
   68.71 +        this.xdiagsCompact = xdiagsCompact;
   68.72 +        this.caretKind = caretKind;
   68.73 +        this.sourceLineKind = sourceLineKind;
   68.74 +        this.summaryIndent = summaryIndent;
   68.75 +        this.detailsIndent = detailsIndent;
   68.76 +        this.sourceIndent = sourceIndent;
   68.77 +        this.subdiagsIndent = subdiagsIndent;
   68.78 +    }
   68.79 +
   68.80 +    @Override
   68.81 +    public void run() {
   68.82          Context ctx = new Context();
   68.83          Options options = Options.instance(ctx);
   68.84          outputKind.init(options);
   68.85 @@ -362,23 +396,10 @@
   68.86              d = new JCDiagnostic.MultilineDiagnostic(d, subdiags);
   68.87          }
   68.88          String diag = log.getDiagnosticFormatter().format(d, messages.getCurrentLocale());
   68.89 -        checkOutput(diag,
   68.90 -                outputKind,
   68.91 -                errorKind,
   68.92 -                multiKind,
   68.93 -                multiPolicy,
   68.94 -                posKind,
   68.95 -                xdiagsSource,
   68.96 -                xdiagsCompact,
   68.97 -                caretKind,
   68.98 -                sourceLineKind,
   68.99 -                summaryIndent,
  68.100 -                detailsIndent,
  68.101 -                sourceIndent,
  68.102 -                subdiagsIndent);
  68.103 +        checkOutput(diag);
  68.104      }
  68.105  
  68.106 -    void test() {
  68.107 +    public static void main(String[] args) throws Exception {
  68.108          for (OutputKind outputKind : OutputKind.values()) {
  68.109              for (ErrorKind errKind : ErrorKind.values()) {
  68.110                  for (MultilineKind multiKind : MultilineKind.values()) {
  68.111 @@ -392,7 +413,7 @@
  68.112                                                  for (IndentKind detailsIndent : IndentKind.values()) {
  68.113                                                      for (IndentKind sourceIndent : IndentKind.values()) {
  68.114                                                          for (IndentKind subdiagsIndent : IndentKind.values()) {
  68.115 -                                                            exec(outputKind,
  68.116 +                                                            pool.execute(new T6769027(outputKind,
  68.117                                                                  errKind,
  68.118                                                                  multiKind,
  68.119                                                                  multiPolicy,
  68.120 @@ -404,7 +425,7 @@
  68.121                                                                  summaryIndent,
  68.122                                                                  detailsIndent,
  68.123                                                                  sourceIndent,
  68.124 -                                                                subdiagsIndent);
  68.125 +                                                                subdiagsIndent));
  68.126                                                          }
  68.127                                                      }
  68.128                                                  }
  68.129 @@ -418,15 +439,11 @@
  68.130                  }
  68.131              }
  68.132          }
  68.133 -        if (nerrors != 0)
  68.134 -            throw new AssertionError(nerrors + " errors found");
  68.135 +
  68.136 +        checkAfterExec(false);
  68.137      }
  68.138  
  68.139 -    void printInfo(String msg, OutputKind outputKind, ErrorKind errorKind, MultilineKind multiKind,
  68.140 -            MultilinePolicy multiPolicy, PositionKind posKind, XDiagsSource xdiagsSource,
  68.141 -            XDiagsCompact xdiagsCompact, CaretKind caretKind, SourceLineKind sourceLineKind,
  68.142 -            IndentKind summaryIndent, IndentKind detailsIndent, IndentKind sourceIndent,
  68.143 -            IndentKind subdiagsIndent, String errorLine) {
  68.144 +    void printInfo(String msg, String errorLine) {
  68.145          String sep = "*********************************************************";
  68.146          String desc = "raw=" + outputKind + " pos=" + posKind + " key=" + errorKind.key() +
  68.147                  " multiline=" + multiKind +" multiPolicy=" + multiPolicy.value +
  68.148 @@ -434,18 +451,14 @@
  68.149                  " caret=" + caretKind + " sourcePosition=" + sourceLineKind +
  68.150                  " summaryIndent=" + summaryIndent + " detailsIndent=" + detailsIndent +
  68.151                  " sourceIndent=" + sourceIndent + " subdiagsIndent=" + subdiagsIndent;
  68.152 -        System.out.println(sep);
  68.153 -        System.out.println(desc);
  68.154 -        System.out.println(sep);
  68.155 -        System.out.println(msg);
  68.156 -        System.out.println("Diagnostic formatting problem - expected diagnostic...\n" + errorLine);
  68.157 +        errWriter.println(sep);
  68.158 +        errWriter.println(desc);
  68.159 +        errWriter.println(sep);
  68.160 +        errWriter.println(msg);
  68.161 +        errWriter.println("Diagnostic formatting problem - expected diagnostic...\n" + errorLine);
  68.162      }
  68.163  
  68.164 -    void checkOutput(String msg, OutputKind outputKind, ErrorKind errorKind, MultilineKind multiKind,
  68.165 -            MultilinePolicy multiPolicy, PositionKind posKind, XDiagsSource xdiagsSource,
  68.166 -            XDiagsCompact xdiagsCompact, CaretKind caretKind, SourceLineKind sourceLineKind,
  68.167 -            IndentKind summaryIndent, IndentKind detailsIndent, IndentKind sourceIndent,
  68.168 -            IndentKind subdiagsIndent) {
  68.169 +    void checkOutput(String msg) {
  68.170          boolean shouldPrintSource = posKind == PositionKind.POS &&
  68.171                  xdiagsSource != XDiagsSource.NO_SOURCE &&
  68.172                  (xdiagsSource == XDiagsSource.SOURCE ||
  68.173 @@ -453,7 +466,8 @@
  68.174          String errorLine = posKind.getOutput(outputKind) +
  68.175                  errorKind.getOutput(outputKind, summaryIndent, detailsIndent);
  68.176          if (xdiagsCompact != XDiagsCompact.COMPACT)
  68.177 -            errorLine += multiKind.getOutput(outputKind, errorKind, multiPolicy, summaryIndent, detailsIndent, subdiagsIndent);
  68.178 +            errorLine += multiKind.getOutput(outputKind, errorKind, multiPolicy,
  68.179 +                    summaryIndent, detailsIndent, subdiagsIndent);
  68.180          String[] lines = errorLine.split("\n");
  68.181          if (xdiagsCompact == XDiagsCompact.COMPACT) {
  68.182              errorLine = lines[0];
  68.183 @@ -474,26 +488,9 @@
  68.184          }
  68.185  
  68.186          if (!msg.equals(errorLine)) {
  68.187 -            printInfo(msg,
  68.188 -                    outputKind,
  68.189 -                    errorKind,
  68.190 -                    multiKind,
  68.191 -                    multiPolicy,
  68.192 -                    posKind,
  68.193 -                    xdiagsSource,
  68.194 -                    xdiagsCompact,
  68.195 -                    caretKind,
  68.196 -                    sourceLineKind,
  68.197 -                    summaryIndent,
  68.198 -                    detailsIndent,
  68.199 -                    sourceIndent,
  68.200 -                    subdiagsIndent,
  68.201 -                    errorLine);
  68.202 -            nerrors++;
  68.203 +            printInfo(msg, errorLine);
  68.204 +            errCount.incrementAndGet();
  68.205          }
  68.206      }
  68.207  
  68.208 -    public static void main(String... args) throws Exception {
  68.209 -        new T6769027().test();
  68.210 -    }
  68.211  }
    69.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
    69.2 +++ b/test/tools/javac/MethodParameters.java	Thu Jan 10 15:53:02 2013 -0800
    69.3 @@ -0,0 +1,344 @@
    69.4 +/*
    69.5 + * Copyright (c) 2012, Oracle and/or its affiliates. All rights reserved.
    69.6 + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
    69.7 + *
    69.8 + * This code is free software; you can redistribute it and/or modify it
    69.9 + * under the terms of the GNU General Public License version 2 only, as
   69.10 + * published by the Free Software Foundation.
   69.11 + *
   69.12 + * This code is distributed in the hope that it will be useful, but WITHOUT
   69.13 + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
   69.14 + * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
   69.15 + * version 2 for more details (a copy is included in the LICENSE file that
   69.16 + * accompanied this code).
   69.17 + *
   69.18 + * You should have received a copy of the GNU General Public License version
   69.19 + * 2 along with this work; if not, write to the Free Software Foundation,
   69.20 + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
   69.21 + *
   69.22 + * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
   69.23 + * or visit www.oracle.com if you need additional information or have any
   69.24 + * questions.
   69.25 + */
   69.26 +
   69.27 +/*
   69.28 + * @test
   69.29 + * @bug 8004727
   69.30 + * @summary javac should generate method parameters correctly.
   69.31 + */
   69.32 +// key: opt.arg.parameters
   69.33 +import com.sun.tools.classfile.*;
   69.34 +import com.sun.tools.javac.file.JavacFileManager;
   69.35 +import com.sun.tools.javac.main.Main;
   69.36 +import com.sun.tools.javac.util.Context;
   69.37 +import com.sun.tools.javac.util.Name;
   69.38 +import com.sun.tools.javac.util.Names;
   69.39 +import java.io.*;
   69.40 +import javax.lang.model.element.*;
   69.41 +import java.util.*;
   69.42 +
   69.43 +public class MethodParameters {
   69.44 +
   69.45 +    static final String Foo_name = "Foo";
   69.46 +    static final String Foo_contents =
   69.47 +        "public class Foo {\n" +
   69.48 +        "  Foo() {}\n" +
   69.49 +        "  void foo0() {}\n" +
   69.50 +        "  void foo2(int j, int k) {}\n" +
   69.51 +        "}";
   69.52 +    static final String Bar_name = "Bar";
   69.53 +    static final String Bar_contents =
   69.54 +        "public class Bar {\n" +
   69.55 +        "  Bar(int i) {}" +
   69.56 +        "  Foo foo() { return new Foo(); }\n" +
   69.57 +        "}";
   69.58 +    static final String Baz_name = "Baz";
   69.59 +    static final String Baz_contents =
   69.60 +        "public class Baz {\n" +
   69.61 +        "  int baz;" +
   69.62 +        "  Baz(int i) {}" +
   69.63 +        "}";
   69.64 +    static final String Qux_name = "Qux";
   69.65 +    static final String Qux_contents =
   69.66 +        "public class Qux extends Baz {\n" +
   69.67 +        "  Qux(int i) { super(i); }" +
   69.68 +        "}";
   69.69 +    static final File classesdir = new File("methodparameters");
   69.70 +
   69.71 +    public static void main(String... args) throws Exception {
   69.72 +        new MethodParameters().run();
   69.73 +    }
   69.74 +
   69.75 +    void run() throws Exception {
   69.76 +        classesdir.mkdir();
   69.77 +        final File Foo_java =
   69.78 +            writeFile(classesdir, Foo_name + ".java", Foo_contents);
   69.79 +        final File Bar_java =
   69.80 +            writeFile(classesdir, Bar_name + ".java", Bar_contents);
   69.81 +        final File Baz_java =
   69.82 +            writeFile(classesdir, Baz_name + ".java", Baz_contents);
   69.83 +        System.err.println("Test compile with -parameter");
   69.84 +        compile("-parameters", "-d", classesdir.getPath(), Foo_java.getPath());
   69.85 +        // First test: make sure javac doesn't choke to death on
   69.86 +        // MethodParameter attributes
   69.87 +        System.err.println("Test compile with classfile containing MethodParameter attributes");
   69.88 +        compile("-parameters", "-d", classesdir.getPath(),
   69.89 +                "-cp", classesdir.getPath(), Bar_java.getPath());
   69.90 +        System.err.println("Examine class foo");
   69.91 +        checkFoo();
   69.92 +        checkBar();
   69.93 +        System.err.println("Test debug information conflict");
   69.94 +        compile("-g", "-parameters", "-d", classesdir.getPath(),
   69.95 +                "-cp", classesdir.getPath(), Baz_java.getPath());
   69.96 +        System.err.println("Introducing debug information conflict");
   69.97 +        Baz_java.delete();
   69.98 +        modifyBaz(false);
   69.99 +        System.err.println("Checking language model");
  69.100 +        inspectBaz();
  69.101 +        System.err.println("Permuting attributes");
  69.102 +        modifyBaz(true);
  69.103 +        System.err.println("Checking language model");
  69.104 +        inspectBaz();
  69.105 +
  69.106 +        if(0 != errors)
  69.107 +            throw new Exception("MethodParameters test failed with " +
  69.108 +                                errors + " errors");
  69.109 +    }
  69.110 +
  69.111 +    void inspectBaz() throws Exception {
  69.112 +        final File Qux_java =
  69.113 +            writeFile(classesdir, Qux_name + ".java", Qux_contents);
  69.114 +        final String[] args = { "-XDsave-parameter-names", "-d",
  69.115 +                                classesdir.getPath(),
  69.116 +                                "-cp", classesdir.getPath(),
  69.117 +                                Qux_java.getPath() };
  69.118 +        final StringWriter sw = new StringWriter();
  69.119 +        final PrintWriter pw = new PrintWriter(sw);
  69.120 +
  69.121 +        // We need to be able to crack open javac and look at its data
  69.122 +        // structures.  We'll rig up a compiler instance, but keep its
  69.123 +        // Context, thus allowing us to get at the ClassReader.
  69.124 +        Context context = new Context();
  69.125 +        Main comp =  new Main("javac", pw);
  69.126 +        JavacFileManager.preRegister(context);
  69.127 +
  69.128 +        // Compile Qux, which uses Baz.
  69.129 +        comp.compile(args, context);
  69.130 +        pw.close();
  69.131 +        final String out = sw.toString();
  69.132 +        if (out.length() > 0)
  69.133 +            System.err.println(out);
  69.134 +
  69.135 +        // Now get the class reader, construct a name for Baz, and load it.
  69.136 +        com.sun.tools.javac.jvm.ClassReader cr =
  69.137 +            com.sun.tools.javac.jvm.ClassReader.instance(context);
  69.138 +        Name name = Names.instance(context).fromString(Baz_name);
  69.139 +
  69.140 +        // Now walk down the language model and check the name of the
  69.141 +        // parameter.
  69.142 +        final Element baz = cr.loadClass(name);
  69.143 +        for (Element e : baz.getEnclosedElements()) {
  69.144 +            if (e instanceof ExecutableElement) {
  69.145 +                final ExecutableElement ee = (ExecutableElement) e;
  69.146 +                final List<? extends VariableElement> params =
  69.147 +                    ee.getParameters();
  69.148 +                if (1 != params.size())
  69.149 +                    throw new Exception("Classfile Baz badly formed: wrong number of methods");
  69.150 +                final VariableElement param = params.get(0);
  69.151 +                if (!param.getSimpleName().contentEquals("baz")) {
  69.152 +                    errors++;
  69.153 +                    System.err.println("javac did not correctly resolve the metadata conflict, parameter's name reads as " + param.getSimpleName());
  69.154 +                } else
  69.155 +                    System.err.println("javac did correctly resolve the metadata conflict");
  69.156 +            }
  69.157 +        }
  69.158 +    }
  69.159 +
  69.160 +    void modifyBaz(boolean flip) throws Exception {
  69.161 +        final File Baz_class = new File(classesdir, Baz_name + ".class");
  69.162 +        final ClassFile baz = ClassFile.read(Baz_class);
  69.163 +        final int ind = baz.constant_pool.getUTF8Index("baz");
  69.164 +        MethodParameters_attribute mpattr = null;
  69.165 +        int mpind = 0;
  69.166 +        Code_attribute cattr = null;
  69.167 +        int cind = 0;
  69.168 +
  69.169 +        // Find the indexes of the MethodParameters and the Code attributes
  69.170 +        if (baz.methods.length != 1)
  69.171 +            throw new Exception("Classfile Baz badly formed: wrong number of methods");
  69.172 +        if (!baz.methods[0].getName(baz.constant_pool).equals("<init>"))
  69.173 +            throw new Exception("Classfile Baz badly formed: method has name " +
  69.174 +                                baz.methods[0].getName(baz.constant_pool));
  69.175 +        for (int i = 0; i < baz.methods[0].attributes.attrs.length; i++) {
  69.176 +            if (baz.methods[0].attributes.attrs[i] instanceof
  69.177 +                MethodParameters_attribute) {
  69.178 +                mpattr = (MethodParameters_attribute)
  69.179 +                    baz.methods[0].attributes.attrs[i];
  69.180 +                mpind = i;
  69.181 +            } else if (baz.methods[0].attributes.attrs[i] instanceof
  69.182 +                       Code_attribute) {
  69.183 +                cattr = (Code_attribute) baz.methods[0].attributes.attrs[i];
  69.184 +                cind = i;
  69.185 +            }
  69.186 +        }
  69.187 +        if (null == mpattr)
  69.188 +            throw new Exception("Classfile Baz badly formed: no method parameters info");
  69.189 +        if (null == cattr)
  69.190 +            throw new Exception("Classfile Baz badly formed: no local variable table");
  69.191 +
  69.192 +        int flags = mpattr.method_parameter_table[0].flags;
  69.193 +
  69.194 +        // Alter the MethodParameters attribute, changing the name of
  69.195 +        // the parameter from i to baz.  This requires Black Magic...
  69.196 +        //
  69.197 +        // The (well-designed) classfile library (correctly) does not
  69.198 +        // allow us to mess around with the attribute data structures,
  69.199 +        // or arbitrarily generate new ones.
  69.200 +        //
  69.201 +        // Instead, we install a new subclass of Attribute that
  69.202 +        // hijacks the Visitor pattern and outputs the sequence of
  69.203 +        // bytes that we want.  This only works in this particular
  69.204 +        // instance, because we know we'll only every see one kind of
  69.205 +        // visitor.
  69.206 +        //
  69.207 +        // If anyone ever changes the makeup of the Baz class, or
  69.208 +        // tries to install some kind of visitor that gets run prior
  69.209 +        // to serialization, this will break.
  69.210 +        baz.methods[0].attributes.attrs[mpind] =
  69.211 +            new Attribute(mpattr.attribute_name_index,
  69.212 +                          mpattr.attribute_length) {
  69.213 +                public <R, D> R accept(Visitor<R, D> visitor, D data) {
  69.214 +                    if (data instanceof ByteArrayOutputStream) {
  69.215 +                        ByteArrayOutputStream out =
  69.216 +                            (ByteArrayOutputStream) data;
  69.217 +                        out.write(1);
  69.218 +                        out.write((ind >> 8) & 0xff);
  69.219 +                        out.write(ind & 0xff);
  69.220 +                        out.write((flags >> 24) & 0xff);
  69.221 +                        out.write((flags >> 16) & 0xff);
  69.222 +                        out.write((flags >> 8) & 0xff);
  69.223 +                        out.write(flags & 0xff);
  69.224 +                    } else
  69.225 +                        throw new RuntimeException("Output stream is of type " + data.getClass() + ", which is not handled by this test.  Update the test and it should work.");
  69.226 +                    return null;
  69.227 +                }
  69.228 +            };
  69.229 +
  69.230 +        // Flip the code and method attributes.  This is for checking
  69.231 +        // that order doesn't matter.
  69.232 +        if (flip) {
  69.233 +            baz.methods[0].attributes.attrs[mpind] = cattr;
  69.234 +            baz.methods[0].attributes.attrs[cind] = mpattr;
  69.235 +        }
  69.236 +
  69.237 +        new ClassWriter().write(baz, Baz_class);
  69.238 +    }
  69.239 +
  69.240 +    // Run a bunch of structural tests on foo to make sure it looks right.
  69.241 +    void checkFoo() throws Exception {
  69.242 +        final File Foo_class = new File(classesdir, Foo_name + ".class");
  69.243 +        final ClassFile foo = ClassFile.read(Foo_class);
  69.244 +        for (int i = 0; i < foo.methods.length; i++) {
  69.245 +            System.err.println("Examine method Foo." + foo.methods[i].getName(foo.constant_pool));
  69.246 +            if (foo.methods[i].getName(foo.constant_pool).equals("foo2")) {
  69.247 +                for (int j = 0; j < foo.methods[i].attributes.attrs.length; j++)
  69.248 +                    if (foo.methods[i].attributes.attrs[j] instanceof
  69.249 +                        MethodParameters_attribute) {
  69.250 +                        MethodParameters_attribute mp =
  69.251 +                            (MethodParameters_attribute)
  69.252 +                            foo.methods[i].attributes.attrs[j];
  69.253 +                        System.err.println("Foo.foo2 should have 2 parameters: j and k");
  69.254 +                        if (2 != mp.method_parameter_table_length)
  69.255 +                            error("expected 2 method parameter entries in foo2, got " +
  69.256 +                                  mp.method_parameter_table_length);
  69.257 +                        else if (!foo.constant_pool.getUTF8Value(mp.method_parameter_table[0].name_index).equals("j"))
  69.258 +                            error("expected first parameter to foo2 to be \"j\", got \"" +
  69.259 +                                  foo.constant_pool.getUTF8Value(mp.method_parameter_table[0].name_index) +
  69.260 +                                  "\" instead");
  69.261 +                        else if  (!foo.constant_pool.getUTF8Value(mp.method_parameter_table[1].name_index).equals("k"))
  69.262 +                            error("expected first parameter to foo2 to be \"k\", got \"" +
  69.263 +                                  foo.constant_pool.getUTF8Value(mp.method_parameter_table[1].name_index) +
  69.264 +                                  "\" instead");
  69.265 +                    }
  69.266 +            }
  69.267 +            else if (foo.methods[i].getName(foo.constant_pool).equals("<init>")) {
  69.268 +                for (int j = 0; j < foo.methods[i].attributes.attrs.length; j++) {
  69.269 +                    if (foo.methods[i].attributes.attrs[j] instanceof
  69.270 +                        MethodParameters_attribute)
  69.271 +                        error("Zero-argument constructor shouldn't have MethodParameters");
  69.272 +                }
  69.273 +            }
  69.274 +            else if (foo.methods[i].getName(foo.constant_pool).equals("foo0")) {
  69.275 +                for (int j = 0; j < foo.methods[i].attributes.attrs.length; j++)
  69.276 +                    if (foo.methods[i].attributes.attrs[j] instanceof
  69.277 +                        MethodParameters_attribute)
  69.278 +                        error("Zero-argument method shouldn't have MethodParameters");
  69.279 +            }
  69.280 +            else
  69.281 +                error("Unknown method " + foo.methods[i].getName(foo.constant_pool) + " showed up in class Foo");
  69.282 +        }
  69.283 +    }
  69.284 +
  69.285 +    // Run a bunch of structural tests on Bar to make sure it looks right.
  69.286 +    void checkBar() throws Exception {
  69.287 +        final File Bar_class = new File(classesdir, Bar_name + ".class");
  69.288 +        final ClassFile bar = ClassFile.read(Bar_class);
  69.289 +        for (int i = 0; i < bar.methods.length; i++) {
  69.290 +            System.err.println("Examine method Bar." + bar.methods[i].getName(bar.constant_pool));
  69.291 +            if (bar.methods[i].getName(bar.constant_pool).equals("<init>")) {
  69.292 +                for (int j = 0; j < bar.methods[i].attributes.attrs.length; j++)
  69.293 +                    if (bar.methods[i].attributes.attrs[j] instanceof
  69.294 +                        MethodParameters_attribute) {
  69.295 +                        MethodParameters_attribute mp =
  69.296 +                            (MethodParameters_attribute)
  69.297 +                            bar.methods[i].attributes.attrs[j];
  69.298 +                        System.err.println("Bar constructor should have 1 parameter: i");
  69.299 +                        if (1 != mp.method_parameter_table_length)
  69.300 +                            error("expected 1 method parameter entries in constructor, got " +
  69.301 +                                  mp.method_parameter_table_length);
  69.302 +                        else if (!bar.constant_pool.getUTF8Value(mp.method_parameter_table[0].name_index).equals("i"))
  69.303 +                            error("expected first parameter to foo2 to be \"i\", got \"" +
  69.304 +                                  bar.constant_pool.getUTF8Value(mp.method_parameter_table[0].name_index) +
  69.305 +                                  "\" instead");
  69.306 +                    }
  69.307 +            }
  69.308 +            else if (bar.methods[i].getName(bar.constant_pool).equals("foo")) {
  69.309 +                for (int j = 0; j < bar.methods[i].attributes.attrs.length; j++) {
  69.310 +                    if (bar.methods[i].attributes.attrs[j] instanceof
  69.311 +                        MethodParameters_attribute)
  69.312 +                        error("Zero-argument constructor shouldn't have MethodParameters");
  69.313 +                }
  69.314 +            }
  69.315 +        }
  69.316 +    }
  69.317 +
  69.318 +    String compile(String... args) throws Exception {
  69.319 +        System.err.println("compile: " + Arrays.asList(args));
  69.320 +        StringWriter sw = new StringWriter();
  69.321 +        PrintWriter pw = new PrintWriter(sw);
  69.322 +        int rc = com.sun.tools.javac.Main.compile(args, pw);
  69.323 +        pw.close();
  69.324 +        String out = sw.toString();
  69.325 +        if (out.length() > 0)
  69.326 +            System.err.println(out);
  69.327 +        if (rc != 0)
  69.328 +            error("compilation failed, rc=" + rc);
  69.329 +        return out;
  69.330 +    }
  69.331 +
  69.332 +    File writeFile(File dir, String path, String body) throws IOException {
  69.333 +        File f = new File(dir, path);
  69.334 +        f.getParentFile().mkdirs();
  69.335 +        FileWriter out = new FileWriter(f);
  69.336 +        out.write(body);
  69.337 +        out.close();
  69.338 +        return f;
  69.339 +    }
  69.340 +
  69.341 +    void error(String msg) {
  69.342 +        System.err.println("Error: " + msg);
  69.343 +        errors++;
  69.344 +    }
  69.345 +
  69.346 +    int errors;
  69.347 +}
    70.1 --- a/test/tools/javac/T7093325.java	Thu Jan 10 09:56:09 2013 -0800
    70.2 +++ b/test/tools/javac/T7093325.java	Thu Jan 10 15:53:02 2013 -0800
    70.3 @@ -1,5 +1,5 @@
    70.4  /*
    70.5 - * Copyright (c) 2011, Oracle and/or its affiliates. All rights reserved.
    70.6 + * Copyright (c) 2011, 2013, Oracle and/or its affiliates. All rights reserved.
    70.7   * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
    70.8   *
    70.9   * This code is free software; you can redistribute it and/or modify it
   70.10 @@ -25,35 +25,29 @@
   70.11   * @test
   70.12   * @bug 7093325
   70.13   * @summary Redundant entry in bytecode exception table
   70.14 + * @library lib
   70.15 + * @build JavacTestingAbstractThreadedTest
   70.16 + * @run main T7093325
   70.17   */
   70.18  
   70.19 +import java.io.File;
   70.20 +import java.net.URI;
   70.21 +import java.util.Arrays;
   70.22 +import javax.tools.JavaCompiler;
   70.23 +import javax.tools.JavaFileObject;
   70.24 +import javax.tools.SimpleJavaFileObject;
   70.25 +import javax.tools.ToolProvider;
   70.26 +
   70.27  import com.sun.source.util.JavacTask;
   70.28  import com.sun.tools.classfile.Attribute;
   70.29  import com.sun.tools.classfile.ClassFile;
   70.30  import com.sun.tools.classfile.Code_attribute;
   70.31  import com.sun.tools.classfile.ConstantPool.*;
   70.32  import com.sun.tools.classfile.Method;
   70.33 -import com.sun.tools.javac.api.JavacTool;
   70.34  
   70.35 -import java.io.File;
   70.36 -import java.net.URI;
   70.37 -import java.util.Arrays;
   70.38 -import javax.tools.JavaCompiler;
   70.39 -import javax.tools.JavaFileObject;
   70.40 -import javax.tools.SimpleJavaFileObject;
   70.41 -import javax.tools.StandardJavaFileManager;
   70.42 -import javax.tools.ToolProvider;
   70.43 -
   70.44 -
   70.45 -public class T7093325 {
   70.46 -
   70.47 -    /** global decls ***/
   70.48 -
   70.49 -    // Create a single file manager and reuse it for each compile to save time.
   70.50 -    static StandardJavaFileManager fm = JavacTool.create().getStandardFileManager(null, null, null);
   70.51 -
   70.52 -    //statistics
   70.53 -    static int checkCount = 0;
   70.54 +public class T7093325
   70.55 +    extends JavacTestingAbstractThreadedTest
   70.56 +    implements Runnable {
   70.57  
   70.58      enum StatementKind {
   70.59          THROW("throw new RuntimeException();", false, false),
   70.60 @@ -89,7 +83,8 @@
   70.61              if (this.ordinal() == 0) {
   70.62                  return catchStr;
   70.63              } else {
   70.64 -                return CatchArity.values()[this.ordinal() - 1].catchers() + catchStr;
   70.65 +                return CatchArity.values()[this.ordinal() - 1].catchers() +
   70.66 +                        catchStr;
   70.67              }
   70.68          }
   70.69      }
   70.70 @@ -98,31 +93,36 @@
   70.71          for (CatchArity ca : CatchArity.values()) {
   70.72              for (StatementKind stmt0 : StatementKind.values()) {
   70.73                  if (ca.ordinal() == 0) {
   70.74 -                    new T7093325(ca, stmt0).compileAndCheck();
   70.75 +                    pool.execute(new T7093325(ca, stmt0));
   70.76                      continue;
   70.77                  }
   70.78                  for (StatementKind stmt1 : StatementKind.values()) {
   70.79                      if (ca.ordinal() == 1) {
   70.80 -                        new T7093325(ca, stmt0, stmt1).compileAndCheck();
   70.81 +                        pool.execute(new T7093325(ca, stmt0, stmt1));
   70.82                          continue;
   70.83                      }
   70.84                      for (StatementKind stmt2 : StatementKind.values()) {
   70.85                          if (ca.ordinal() == 2) {
   70.86 -                            new T7093325(ca, stmt0, stmt1, stmt2).compileAndCheck();
   70.87 +                            pool.execute(new T7093325(ca, stmt0, stmt1, stmt2));
   70.88                              continue;
   70.89                          }
   70.90                          for (StatementKind stmt3 : StatementKind.values()) {
   70.91                              if (ca.ordinal() == 3) {
   70.92 -                                new T7093325(ca, stmt0, stmt1, stmt2, stmt3).compileAndCheck();
   70.93 +                                pool.execute(
   70.94 +                                    new T7093325(ca, stmt0, stmt1, stmt2, stmt3));
   70.95                                  continue;
   70.96                              }
   70.97                              for (StatementKind stmt4 : StatementKind.values()) {
   70.98                                  if (ca.ordinal() == 4) {
   70.99 -                                    new T7093325(ca, stmt0, stmt1, stmt2, stmt3, stmt4).compileAndCheck();
  70.100 +                                    pool.execute(
  70.101 +                                        new T7093325(ca, stmt0, stmt1,
  70.102 +                                                     stmt2, stmt3, stmt4));
  70.103                                      continue;
  70.104                                  }
  70.105                                  for (StatementKind stmt5 : StatementKind.values()) {
  70.106 -                                    new T7093325(ca, stmt0, stmt1, stmt2, stmt3, stmt4, stmt5).compileAndCheck();
  70.107 +                                    pool.execute(
  70.108 +                                        new T7093325(ca, stmt0, stmt1, stmt2,
  70.109 +                                                     stmt3, stmt4, stmt5));
  70.110                                  }
  70.111                              }
  70.112                          }
  70.113 @@ -131,7 +131,7 @@
  70.114              }
  70.115          }
  70.116  
  70.117 -        System.out.println("Total checks made: " + checkCount);
  70.118 +        checkAfterExec();
  70.119      }
  70.120  
  70.121      /** instance decls **/
  70.122 @@ -144,17 +144,18 @@
  70.123          this.stmts = stmts;
  70.124      }
  70.125  
  70.126 -    void compileAndCheck() throws Exception {
  70.127 +    @Override
  70.128 +    public void run() {
  70.129 +        int id = checkCount.incrementAndGet();
  70.130          final JavaCompiler tool = ToolProvider.getSystemJavaCompiler();
  70.131 -        JavaSource source = new JavaSource();
  70.132 -        JavacTask ct = (JavacTask)tool.getTask(null, fm, null,
  70.133 +        JavaSource source = new JavaSource(id);
  70.134 +        JavacTask ct = (JavacTask)tool.getTask(null, fm.get(), null,
  70.135                  null, null, Arrays.asList(source));
  70.136          ct.call();
  70.137 -        verifyBytecode(source);
  70.138 +        verifyBytecode(source, id);
  70.139      }
  70.140  
  70.141 -    void verifyBytecode(JavaSource source) {
  70.142 -        checkCount++;
  70.143 +    void verifyBytecode(JavaSource source, int id) {
  70.144          boolean lastInlined = false;
  70.145          boolean hasCode = false;
  70.146          int gapsCount = 0;
  70.147 @@ -172,11 +173,12 @@
  70.148  
  70.149          //System.out.printf("gaps %d \n %s \n", gapsCount, source.toString());
  70.150  
  70.151 -        File compiledTest = new File("Test.class");
  70.152 +        File compiledTest = new File(String.format("Test%s.class", id));
  70.153          try {
  70.154              ClassFile cf = ClassFile.read(compiledTest);
  70.155              if (cf == null) {
  70.156 -                throw new Error("Classfile not found: " + compiledTest.getName());
  70.157 +                throw new Error("Classfile not found: " +
  70.158 +                                compiledTest.getName());
  70.159              }
  70.160  
  70.161              Method test_method = null;
  70.162 @@ -232,7 +234,7 @@
  70.163                  "class C extends RuntimeException {} \n" +
  70.164                  "class D extends RuntimeException {} \n" +
  70.165                  "class E extends RuntimeException {} \n" +
  70.166 -                "class Test {\n" +
  70.167 +                "class Test#ID {\n" +
  70.168                  "   void test() {\n" +
  70.169                  "   try { #S0 } #C finally { System.out.println(); }\n" +
  70.170                  "   }\n" +
  70.171 @@ -240,10 +242,12 @@
  70.172  
  70.173          String source;
  70.174  
  70.175 -        public JavaSource() {
  70.176 -            super(URI.create("myfo:/Test.java"), JavaFileObject.Kind.SOURCE);
  70.177 +        public JavaSource(int id) {
  70.178 +            super(URI.create(String.format("myfo:/Test%s.java", id)),
  70.179 +                  JavaFileObject.Kind.SOURCE);
  70.180              source = source_template.replace("#C", ca.catchers());
  70.181              source = source.replace("#S0", stmts[0].stmt);
  70.182 +            source = source.replace("#ID", String.valueOf(id));
  70.183              for (int i = 1; i < ca.ordinal() + 1; i++) {
  70.184                  source = source.replace("#S" + i, stmts[i].stmt);
  70.185              }
  70.186 @@ -259,4 +263,5 @@
  70.187              return source;
  70.188          }
  70.189      }
  70.190 +
  70.191  }
    71.1 --- a/test/tools/javac/cast/intersection/IntersectionTypeCastTest.java	Thu Jan 10 09:56:09 2013 -0800
    71.2 +++ b/test/tools/javac/cast/intersection/IntersectionTypeCastTest.java	Thu Jan 10 15:53:02 2013 -0800
    71.3 @@ -1,5 +1,5 @@
    71.4  /*
    71.5 - * Copyright (c) 2012, Oracle and/or its affiliates. All rights reserved.
    71.6 + * Copyright (c) 2012, 2013, Oracle and/or its affiliates. All rights reserved.
    71.7   * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
    71.8   *
    71.9   * This code is free software; you can redistribute it and/or modify it
   71.10 @@ -25,23 +25,26 @@
   71.11   * @test
   71.12   * @bug 8002099
   71.13   * @summary Add support for intersection types in cast expression
   71.14 + * @library ../../lib
   71.15 + * @build JavacTestingAbstractThreadedTest
   71.16 + * @run main/timeout=360 IntersectionTypeCastTest
   71.17   */
   71.18  
   71.19 -import com.sun.source.util.JavacTask;
   71.20 -import com.sun.tools.javac.util.List;
   71.21 -import com.sun.tools.javac.util.ListBuffer;
   71.22  import java.net.URI;
   71.23  import java.util.Arrays;
   71.24  import javax.tools.Diagnostic;
   71.25  import javax.tools.JavaCompiler;
   71.26  import javax.tools.JavaFileObject;
   71.27  import javax.tools.SimpleJavaFileObject;
   71.28 -import javax.tools.StandardJavaFileManager;
   71.29  import javax.tools.ToolProvider;
   71.30  
   71.31 -public class IntersectionTypeCastTest {
   71.32 +import com.sun.source.util.JavacTask;
   71.33 +import com.sun.tools.javac.util.List;
   71.34 +import com.sun.tools.javac.util.ListBuffer;
   71.35  
   71.36 -    static int checkCount = 0;
   71.37 +public class IntersectionTypeCastTest
   71.38 +    extends JavacTestingAbstractThreadedTest
   71.39 +    implements Runnable {
   71.40  
   71.41      interface Type {
   71.42          boolean subtypeOf(Type that);
   71.43 @@ -59,7 +62,8 @@
   71.44          String typeStr;
   71.45          InterfaceKind superInterface;
   71.46  
   71.47 -        InterfaceKind(String declStr, String typeStr, InterfaceKind superInterface) {
   71.48 +        InterfaceKind(String declStr, String typeStr,
   71.49 +                InterfaceKind superInterface) {
   71.50              this.declStr = declStr;
   71.51              this.typeStr = typeStr;
   71.52              this.superInterface = superInterface;
   71.53 @@ -67,7 +71,8 @@
   71.54  
   71.55          @Override
   71.56          public boolean subtypeOf(Type that) {
   71.57 -            return this == that || superInterface == that || that == ClassKind.OBJECT;
   71.58 +            return this == that || superInterface == that ||
   71.59 +                   that == ClassKind.OBJECT;
   71.60          }
   71.61  
   71.62          @Override
   71.63 @@ -88,19 +93,27 @@
   71.64  
   71.65      enum ClassKind implements Type {
   71.66          OBJECT(null, "Object"),
   71.67 -        CA("#M class CA implements A { }\n", "CA", InterfaceKind.A),
   71.68 -        CB("#M class CB implements B { }\n", "CB", InterfaceKind.B),
   71.69 -        CAB("#M class CAB implements A, B { }\n", "CAB", InterfaceKind.A, InterfaceKind.B),
   71.70 -        CC("#M class CC implements C { }\n", "CC", InterfaceKind.C, InterfaceKind.A),
   71.71 -        CCA("#M class CCA implements C, A { }\n", "CCA", InterfaceKind.C, InterfaceKind.A),
   71.72 -        CCB("#M class CCB implements C, B { }\n", "CCB", InterfaceKind.C, InterfaceKind.A, InterfaceKind.B),
   71.73 -        CCAB("#M class CCAB implements C, A, B { }\n", "CCAB", InterfaceKind.C, InterfaceKind.A, InterfaceKind.B);
   71.74 +        CA("#M class CA implements A { }\n", "CA",
   71.75 +           InterfaceKind.A),
   71.76 +        CB("#M class CB implements B { }\n", "CB",
   71.77 +           InterfaceKind.B),
   71.78 +        CAB("#M class CAB implements A, B { }\n", "CAB",
   71.79 +            InterfaceKind.A, InterfaceKind.B),
   71.80 +        CC("#M class CC implements C { }\n", "CC",
   71.81 +           InterfaceKind.C, InterfaceKind.A),
   71.82 +        CCA("#M class CCA implements C, A { }\n", "CCA",
   71.83 +            InterfaceKind.C, InterfaceKind.A),
   71.84 +        CCB("#M class CCB implements C, B { }\n", "CCB",
   71.85 +            InterfaceKind.C, InterfaceKind.A, InterfaceKind.B),
   71.86 +        CCAB("#M class CCAB implements C, A, B { }\n", "CCAB",
   71.87 +             InterfaceKind.C, InterfaceKind.A, InterfaceKind.B);
   71.88  
   71.89          String declTemplate;
   71.90          String typeStr;
   71.91          List<InterfaceKind> superInterfaces;
   71.92  
   71.93 -        ClassKind(String declTemplate, String typeStr, InterfaceKind... superInterfaces) {
   71.94 +        ClassKind(String declTemplate, String typeStr,
   71.95 +                InterfaceKind... superInterfaces) {
   71.96              this.declTemplate = declTemplate;
   71.97              this.typeStr = typeStr;
   71.98              this.superInterfaces = List.from(superInterfaces);
   71.99 @@ -114,7 +127,8 @@
  71.100  
  71.101          @Override
  71.102          public boolean subtypeOf(Type that) {
  71.103 -            return this == that || superInterfaces.contains(that) || that == OBJECT;
  71.104 +            return this == that || superInterfaces.contains(that) ||
  71.105 +                    that == OBJECT;
  71.106          }
  71.107  
  71.108          @Override
  71.109 @@ -170,9 +184,11 @@
  71.110          }
  71.111  
  71.112          String getCast() {
  71.113 -            String temp = kind.castTemplate.replaceAll("#C", types[0].asString());
  71.114 +            String temp = kind.castTemplate.replaceAll("#C",
  71.115 +                    types[0].asString());
  71.116              for (int i = 0; i < kind.interfaceBounds ; i++) {
  71.117 -                temp = temp.replace(String.format("#I%d", i), types[i + 1].asString());
  71.118 +                temp = temp.replace(String.format("#I%d", i),
  71.119 +                                    types[i + 1].asString());
  71.120              }
  71.121              return temp;
  71.122          }
  71.123 @@ -195,7 +211,8 @@
  71.124                              t1.subtypeOf(t2) ||
  71.125                              t2.subtypeOf(t1) ||
  71.126                              (t1.isInterface() && t2.isInterface()) || //side-cast (1)
  71.127 -                            (mod == ModifierKind.NONE && (t1.isInterface() != t2.isInterface())); //side-cast (2)
  71.128 +                            (mod == ModifierKind.NONE &&
  71.129 +                            (t1.isInterface() != t2.isInterface())); //side-cast (2)
  71.130                      if (!compat) return false;
  71.131                  }
  71.132              }
  71.133 @@ -204,18 +221,15 @@
  71.134      }
  71.135  
  71.136      public static void main(String... args) throws Exception {
  71.137 -        //create default shared JavaCompiler - reused across multiple compilations
  71.138 -        JavaCompiler comp = ToolProvider.getSystemJavaCompiler();
  71.139 -        StandardJavaFileManager fm = comp.getStandardFileManager(null, null, null);
  71.140 -
  71.141          for (ModifierKind mod : ModifierKind.values()) {
  71.142              for (CastInfo cast1 : allCastInfo()) {
  71.143                  for (CastInfo cast2 : allCastInfo()) {
  71.144 -                    new IntersectionTypeCastTest(mod, cast1, cast2).run(comp, fm);
  71.145 +                    pool.execute(
  71.146 +                        new IntersectionTypeCastTest(mod, cast1, cast2));
  71.147                  }
  71.148              }
  71.149          }
  71.150 -        System.out.println("Total check executed: " + checkCount);
  71.151 +        checkAfterExec();
  71.152      }
  71.153  
  71.154      static List<CastInfo> allCastInfo() {
  71.155 @@ -235,11 +249,14 @@
  71.156                          } else {
  71.157                              for (InterfaceKind intf2 : InterfaceKind.values()) {
  71.158                                  if (kind.interfaceBounds == 2) {
  71.159 -                                    buf.append(new CastInfo(kind, clazz, intf1, intf2));
  71.160 +                                    buf.append(
  71.161 +                                            new CastInfo(kind, clazz, intf1, intf2));
  71.162                                      continue;
  71.163                                  } else {
  71.164                                      for (InterfaceKind intf3 : InterfaceKind.values()) {
  71.165 -                                        buf.append(new CastInfo(kind, clazz, intf1, intf2, intf3));
  71.166 +                                        buf.append(
  71.167 +                                                new CastInfo(kind, clazz, intf1,
  71.168 +                                                             intf2, intf3));
  71.169                                          continue;
  71.170                                      }
  71.171                                  }
  71.172 @@ -265,6 +282,22 @@
  71.173          this.diagChecker = new DiagnosticChecker();
  71.174      }
  71.175  
  71.176 +    @Override
  71.177 +    public void run() {
  71.178 +        final JavaCompiler tool = ToolProvider.getSystemJavaCompiler();
  71.179 +
  71.180 +        JavacTask ct = (JavacTask)tool.getTask(null, fm.get(), diagChecker,
  71.181 +                Arrays.asList("-XDallowIntersectionTypes"),
  71.182 +                null, Arrays.asList(source));
  71.183 +        try {
  71.184 +            ct.analyze();
  71.185 +        } catch (Throwable ex) {
  71.186 +            throw new AssertionError("Error thrown when compiling the following code:\n" +
  71.187 +                    source.getCharContent(true));
  71.188 +        }
  71.189 +        check();
  71.190 +    }
  71.191 +
  71.192      class JavaSource extends SimpleJavaFileObject {
  71.193  
  71.194          String bodyTemplate = "class Test {\n" +
  71.195 @@ -282,7 +315,8 @@
  71.196              for (InterfaceKind ik : InterfaceKind.values()) {
  71.197                  source += ik.declStr;
  71.198              }
  71.199 -            source += bodyTemplate.replaceAll("#C1", cast1.getCast()).replaceAll("#C2", cast2.getCast());
  71.200 +            source += bodyTemplate.replaceAll("#C1", cast1.getCast()).
  71.201 +                    replaceAll("#C2", cast2.getCast());
  71.202          }
  71.203  
  71.204          @Override
  71.205 @@ -291,21 +325,11 @@
  71.206          }
  71.207      }
  71.208  
  71.209 -    void run(JavaCompiler tool, StandardJavaFileManager fm) throws Exception {
  71.210 -        JavacTask ct = (JavacTask)tool.getTask(null, fm, diagChecker,
  71.211 -                Arrays.asList("-XDallowIntersectionTypes"), null, Arrays.asList(source));
  71.212 -        try {
  71.213 -            ct.analyze();
  71.214 -        } catch (Throwable ex) {
  71.215 -            throw new AssertionError("Error thrown when compiling the following code:\n" + source.getCharContent(true));
  71.216 -        }
  71.217 -        check();
  71.218 -    }
  71.219 +    void check() {
  71.220 +        checkCount.incrementAndGet();
  71.221  
  71.222 -    void check() {
  71.223 -        checkCount++;
  71.224 -
  71.225 -        boolean errorExpected = cast1.hasDuplicateTypes() || cast2.hasDuplicateTypes();
  71.226 +        boolean errorExpected = cast1.hasDuplicateTypes() ||
  71.227 +                cast2.hasDuplicateTypes();
  71.228  
  71.229          errorExpected |= !cast2.compatibleWith(mod, cast1);
  71.230  
  71.231 @@ -317,7 +341,8 @@
  71.232          }
  71.233      }
  71.234  
  71.235 -    static class DiagnosticChecker implements javax.tools.DiagnosticListener<JavaFileObject> {
  71.236 +    static class DiagnosticChecker
  71.237 +        implements javax.tools.DiagnosticListener<JavaFileObject> {
  71.238  
  71.239          boolean errorFound;
  71.240  
  71.241 @@ -327,4 +352,5 @@
  71.242              }
  71.243          }
  71.244      }
  71.245 +
  71.246  }
    72.1 --- a/test/tools/javac/defaultMethods/super/TestDefaultSuperCall.java	Thu Jan 10 09:56:09 2013 -0800
    72.2 +++ b/test/tools/javac/defaultMethods/super/TestDefaultSuperCall.java	Thu Jan 10 15:53:02 2013 -0800
    72.3 @@ -1,5 +1,5 @@
    72.4  /*
    72.5 - * Copyright (c) 2012, Oracle and/or its affiliates. All rights reserved.
    72.6 + * Copyright (c) 2012, 2013, Oracle and/or its affiliates. All rights reserved.
    72.7   * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
    72.8   *
    72.9   * This code is free software; you can redistribute it and/or modify it
   72.10 @@ -24,25 +24,25 @@
   72.11  /*
   72.12   * @test
   72.13   * @summary Automatic test for checking correctness of default super/this resolution
   72.14 + * @library ../../lib
   72.15 + * @build JavacTestingAbstractThreadedTest
   72.16 + * @run main TestDefaultSuperCall
   72.17   */
   72.18  
   72.19 -import com.sun.source.util.JavacTask;
   72.20  import java.net.URI;
   72.21  import java.util.Arrays;
   72.22  import java.util.ArrayList;
   72.23  import java.util.List;
   72.24  import java.util.Locale;
   72.25 -import java.util.Map;
   72.26  import javax.tools.Diagnostic;
   72.27 -import javax.tools.JavaCompiler;
   72.28  import javax.tools.JavaFileObject;
   72.29  import javax.tools.SimpleJavaFileObject;
   72.30 -import javax.tools.StandardJavaFileManager;
   72.31 -import javax.tools.ToolProvider;
   72.32  
   72.33 -public class TestDefaultSuperCall {
   72.34 +import com.sun.source.util.JavacTask;
   72.35  
   72.36 -    static int checkCount = 0;
   72.37 +public class TestDefaultSuperCall
   72.38 +    extends JavacTestingAbstractThreadedTest
   72.39 +    implements Runnable {
   72.40  
   72.41      enum InterfaceKind {
   72.42          DEFAULT("interface A extends B { default void m() { } }"),
   72.43 @@ -212,7 +212,7 @@
   72.44          List<String> elementsWithMethod;
   72.45  
   72.46          Shape(ElementKind... elements) {
   72.47 -            System.err.println("elements = " + Arrays.toString(elements));
   72.48 +            errWriter.println("elements = " + Arrays.toString(elements));
   72.49              enclosingElements = new ArrayList<>();
   72.50              enclosingNames = new ArrayList<>();
   72.51              elementsWithMethod = new ArrayList<>();
   72.52 @@ -231,28 +231,26 @@
   72.53                      elementsWithMethod.add(prevName);
   72.54                  }
   72.55                  String element = ek.templateDecl.replaceAll("#N", name);
   72.56 -                shapeStr = shapeStr == null ? element : shapeStr.replaceAll("#B", element);
   72.57 +                shapeStr = shapeStr ==
   72.58 +                        null ? element : shapeStr.replaceAll("#B", element);
   72.59                  prevName = name;
   72.60              }
   72.61          }
   72.62  
   72.63          String getShape(QualifierKind qk, ExprKind ek) {
   72.64              String methName = ek == ExprKind.THIS ? "test" : "m";
   72.65 -            String call = qk.getQualifier(this) + "." + ek.exprStr + "." + methName + "();";
   72.66 +            String call = qk.getQualifier(this) + "." +
   72.67 +                    ek.exprStr + "." + methName + "();";
   72.68              return shapeStr.replaceAll("#B", call);
   72.69          }
   72.70  
   72.71          String enclosingAt(int index) {
   72.72 -            return index < enclosingNames.size() ? enclosingNames.get(index) : "BAD";
   72.73 +            return index < enclosingNames.size() ?
   72.74 +                    enclosingNames.get(index) : "BAD";
   72.75          }
   72.76      }
   72.77  
   72.78      public static void main(String... args) throws Exception {
   72.79 -
   72.80 -        //create default shared JavaCompiler - reused across multiple compilations
   72.81 -        JavaCompiler comp = ToolProvider.getSystemJavaCompiler();
   72.82 -        StandardJavaFileManager fm = comp.getStandardFileManager(null, null, null);
   72.83 -
   72.84          for (InterfaceKind ik : InterfaceKind.values()) {
   72.85              for (PruneKind pk : PruneKind.values()) {
   72.86                  for (ElementKind ek1 : ElementKind.values()) {
   72.87 @@ -264,10 +262,14 @@
   72.88                              for (ElementKind ek4 : ElementKind.values()) {
   72.89                                  if (!ek4.isAllowedEnclosing(ek3, false)) continue;
   72.90                                  for (ElementKind ek5 : ElementKind.values()) {
   72.91 -                                    if (!ek5.isAllowedEnclosing(ek4, false) || ek5.isClassDecl()) continue;
   72.92 +                                    if (!ek5.isAllowedEnclosing(ek4, false) ||
   72.93 +                                            ek5.isClassDecl()) continue;
   72.94                                      for (QualifierKind qk : QualifierKind.values()) {
   72.95                                          for (ExprKind ek : ExprKind.values()) {
   72.96 -                                            new TestDefaultSuperCall(ik, pk, new Shape(ek1, ek2, ek3, ek4, ek5), qk, ek).run(comp, fm);
   72.97 +                                            pool.execute(
   72.98 +                                                    new TestDefaultSuperCall(ik, pk,
   72.99 +                                                    new Shape(ek1, ek2, ek3,
  72.100 +                                                    ek4, ek5), qk, ek));
  72.101                                          }
  72.102                                      }
  72.103                                  }
  72.104 @@ -277,7 +279,8 @@
  72.105                  }
  72.106              }
  72.107          }
  72.108 -        System.out.println("Total check executed: " + checkCount);
  72.109 +
  72.110 +        checkAfterExec();
  72.111      }
  72.112  
  72.113      InterfaceKind ik;
  72.114 @@ -288,7 +291,8 @@
  72.115      JavaSource source;
  72.116      DiagnosticChecker diagChecker;
  72.117  
  72.118 -    TestDefaultSuperCall(InterfaceKind ik, PruneKind pk, Shape sh, QualifierKind qk, ExprKind ek) {
  72.119 +    TestDefaultSuperCall(InterfaceKind ik, PruneKind pk, Shape sh,
  72.120 +            QualifierKind qk, ExprKind ek) {
  72.121          this.ik = ik;
  72.122          this.pk = pk;
  72.123          this.sh = sh;
  72.124 @@ -321,13 +325,14 @@
  72.125          }
  72.126      }
  72.127  
  72.128 -    void run(JavaCompiler tool, StandardJavaFileManager fm) throws Exception {
  72.129 -        JavacTask ct = (JavacTask)tool.getTask(null, fm, diagChecker,
  72.130 +    public void run() {
  72.131 +        JavacTask ct = (JavacTask)comp.getTask(null, fm.get(), diagChecker,
  72.132                  null, null, Arrays.asList(source));
  72.133          try {
  72.134              ct.analyze();
  72.135          } catch (Throwable ex) {
  72.136 -            throw new AssertionError("Error thrown when analyzing the following source:\n" + source.getCharContent(true));
  72.137 +            processException(ex);
  72.138 +            return;
  72.139          }
  72.140          check();
  72.141      }
  72.142 @@ -370,7 +375,8 @@
  72.143  
  72.144              int lastIdx = sh.enclosingElements.size() - 1;
  72.145              boolean found = lastIdx == -1 ? false :
  72.146 -                    sh.enclosingElements.get(lastIdx).hasSuper() && qk.allowSuperCall(ik, pk);
  72.147 +                    sh.enclosingElements.get(lastIdx).hasSuper() &&
  72.148 +                    qk.allowSuperCall(ik, pk);
  72.149  
  72.150              errorExpected |= !found;
  72.151              if (!found) {
  72.152 @@ -378,9 +384,10 @@
  72.153              }
  72.154          }
  72.155  
  72.156 -        checkCount++;
  72.157 +        checkCount.incrementAndGet();
  72.158          if (diagChecker.errorFound != errorExpected) {
  72.159 -            throw new AssertionError("Problem when compiling source:\n" + source.getCharContent(true) +
  72.160 +            throw new AssertionError("Problem when compiling source:\n" +
  72.161 +                    source.getCharContent(true) +
  72.162                      "\nenclosingElems: " + sh.enclosingElements +
  72.163                      "\nenclosingNames: " + sh.enclosingNames +
  72.164                      "\nelementsWithMethod: " + sh.elementsWithMethod +
  72.165 @@ -392,15 +399,17 @@
  72.166          }
  72.167      }
  72.168  
  72.169 -    static class DiagnosticChecker implements javax.tools.DiagnosticListener<JavaFileObject> {
  72.170 +    static class DiagnosticChecker
  72.171 +        implements javax.tools.DiagnosticListener<JavaFileObject> {
  72.172  
  72.173          boolean errorFound;
  72.174  
  72.175          public void report(Diagnostic<? extends JavaFileObject> diagnostic) {
  72.176              if (diagnostic.getKind() == Diagnostic.Kind.ERROR) {
  72.177 -                System.err.println(diagnostic.getMessage(Locale.getDefault()));
  72.178 +                errWriter.println(diagnostic.getMessage(Locale.getDefault()));
  72.179                  errorFound = true;
  72.180              }
  72.181          }
  72.182      }
  72.183 +
  72.184  }
    73.1 --- a/test/tools/javac/failover/CheckAttributedTree.java	Thu Jan 10 09:56:09 2013 -0800
    73.2 +++ b/test/tools/javac/failover/CheckAttributedTree.java	Thu Jan 10 15:53:02 2013 -0800
    73.3 @@ -1,5 +1,5 @@
    73.4  /*
    73.5 - * Copyright (c) 2010, 2012, Oracle and/or its affiliates. All rights reserved.
    73.6 + * Copyright (c) 2010, 2013, Oracle and/or its affiliates. All rights reserved.
    73.7   * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
    73.8   *
    73.9   * This code is free software; you can redistribute it and/or modify it
   73.10 @@ -21,7 +21,15 @@
   73.11   * questions.
   73.12   */
   73.13  
   73.14 -import com.sun.source.util.TaskEvent;
   73.15 +/*
   73.16 + * @test
   73.17 + * @bug 6970584
   73.18 + * @summary assorted position errors in compiler syntax trees
   73.19 + * @library ../lib
   73.20 + * @build JavacTestingAbstractThreadedTest
   73.21 + * @run main CheckAttributedTree -q -r -et ERRONEOUS .
   73.22 + */
   73.23 +
   73.24  import java.awt.BorderLayout;
   73.25  import java.awt.Color;
   73.26  import java.awt.Dimension;
   73.27 @@ -34,6 +42,20 @@
   73.28  import java.awt.event.ActionListener;
   73.29  import java.awt.event.MouseAdapter;
   73.30  import java.awt.event.MouseEvent;
   73.31 +import java.io.File;
   73.32 +import java.io.IOException;
   73.33 +import java.io.PrintStream;
   73.34 +import java.io.PrintWriter;
   73.35 +import java.io.StringWriter;
   73.36 +import java.lang.reflect.Field;
   73.37 +import java.util.ArrayList;
   73.38 +import java.util.Arrays;
   73.39 +import java.util.concurrent.atomic.AtomicInteger;
   73.40 +import java.util.HashSet;
   73.41 +import java.util.List;
   73.42 +import java.util.Set;
   73.43 +
   73.44 +import javax.lang.model.element.Element;
   73.45  import javax.swing.DefaultComboBoxModel;
   73.46  import javax.swing.JComboBox;
   73.47  import javax.swing.JComponent;
   73.48 @@ -49,23 +71,14 @@
   73.49  import javax.swing.text.BadLocationException;
   73.50  import javax.swing.text.DefaultHighlighter;
   73.51  import javax.swing.text.Highlighter;
   73.52 -import java.io.File;
   73.53 -import java.io.IOException;
   73.54 -import java.io.PrintStream;
   73.55 -import java.io.PrintWriter;
   73.56 -import java.io.StringWriter;
   73.57 -import java.lang.reflect.Field;
   73.58 -import java.util.ArrayList;
   73.59 -import java.util.List;
   73.60  import javax.tools.Diagnostic;
   73.61  import javax.tools.DiagnosticListener;
   73.62  import javax.tools.JavaFileObject;
   73.63 -import javax.tools.StandardJavaFileManager;
   73.64  
   73.65  import com.sun.source.tree.CompilationUnitTree;
   73.66 +import com.sun.source.util.TaskEvent;
   73.67  import com.sun.source.util.JavacTask;
   73.68  import com.sun.source.util.TaskListener;
   73.69 -import com.sun.tools.javac.api.JavacTool;
   73.70  import com.sun.tools.javac.code.Symbol;
   73.71  import com.sun.tools.javac.code.Type;
   73.72  import com.sun.tools.javac.tree.EndPosTable;
   73.73 @@ -76,11 +89,6 @@
   73.74  import com.sun.tools.javac.tree.TreeScanner;
   73.75  import com.sun.tools.javac.util.Pair;
   73.76  
   73.77 -import java.util.Arrays;
   73.78 -import java.util.HashSet;
   73.79 -import java.util.Set;
   73.80 -import javax.lang.model.element.Element;
   73.81 -
   73.82  import static com.sun.tools.javac.tree.JCTree.Tag.*;
   73.83  
   73.84  /**
   73.85 @@ -95,13 +103,7 @@
   73.86   * covering any new language features that may be tested in this test suite.
   73.87   */
   73.88  
   73.89 -/*
   73.90 - * @test
   73.91 - * @bug 6970584
   73.92 - * @summary assorted position errors in compiler syntax trees
   73.93 - * @run main CheckAttributedTree -q -r -et ERRONEOUS .
   73.94 - */
   73.95 -public class CheckAttributedTree {
   73.96 +public class CheckAttributedTree extends JavacTestingAbstractThreadedTest {
   73.97      /**
   73.98       * Main entry point.
   73.99       * If test.src is set, program runs in jtreg mode, and will throw an Error
  73.100 @@ -110,9 +112,10 @@
  73.101       * args is the value of ${test.src}. In jtreg mode, the -r option can be
  73.102       * given to change the default base directory to the root test directory.
  73.103       */
  73.104 -    public static void main(String... args) {
  73.105 +    public static void main(String... args) throws Exception {
  73.106          String testSrc = System.getProperty("test.src");
  73.107          File baseDir = (testSrc == null) ? null : new File(testSrc);
  73.108 +        throwAssertionOnError = false;
  73.109          boolean ok = new CheckAttributedTree().run(baseDir, args);
  73.110          if (!ok) {
  73.111              if (testSrc != null)  // jtreg mode
  73.112 @@ -130,7 +133,7 @@
  73.113       * @param args command line args
  73.114       * @return true if successful or in gui mode
  73.115       */
  73.116 -    boolean run(File baseDir, String... args) {
  73.117 +    boolean run(File baseDir, String... args) throws Exception {
  73.118          if (args.length == 0) {
  73.119              usage(System.out);
  73.120              return true;
  73.121 @@ -145,8 +148,10 @@
  73.122                  gui = true;
  73.123              else if (arg.equals("-q"))
  73.124                  quiet = true;
  73.125 -            else if (arg.equals("-v"))
  73.126 +            else if (arg.equals("-v")) {
  73.127                  verbose = true;
  73.128 +                printAll = true;
  73.129 +            }
  73.130              else if (arg.equals("-t") && i + 1 < args.length)
  73.131                  tags.add(args[++i]);
  73.132              else if (arg.equals("-ef") && i + 1 < args.length)
  73.133 @@ -179,12 +184,11 @@
  73.134                  error("File not found: " + file);
  73.135          }
  73.136  
  73.137 -        if (fileCount != 1)
  73.138 -            System.err.println(fileCount + " files read");
  73.139 -        if (errors > 0)
  73.140 -            System.err.println(errors + " errors");
  73.141 +        if (fileCount.get() != 1)
  73.142 +            errWriter.println(fileCount + " files read");
  73.143 +        checkAfterExec(false);
  73.144  
  73.145 -        return (gui || errors == 0);
  73.146 +        return (gui || errCount.get() == 0);
  73.147      }
  73.148  
  73.149      /**
  73.150 @@ -215,7 +219,7 @@
  73.151       * for java files.
  73.152       * @param file the file or directory to test
  73.153       */
  73.154 -    void test(File file) {
  73.155 +    void test(final File file) {
  73.156          if (excludeFiles.contains(file)) {
  73.157              if (!quiet)
  73.158                  error("File " + file + " excluded");
  73.159 @@ -230,20 +234,24 @@
  73.160          }
  73.161  
  73.162          if (file.isFile() && file.getName().endsWith(".java")) {
  73.163 -            try {
  73.164 -                if (verbose)
  73.165 -                    System.err.println(file);
  73.166 -                fileCount++;
  73.167 -                NPETester p = new NPETester();
  73.168 -                p.test(read(file));
  73.169 -            } catch (AttributionException e) {
  73.170 -                if (!quiet) {
  73.171 -                    error("Error attributing " + file + "\n" + e.getMessage());
  73.172 +            pool.execute(new Runnable() {
  73.173 +                @Override
  73.174 +                public void run() {
  73.175 +                    try {
  73.176 +                        if (verbose)
  73.177 +                            errWriter.println(file);
  73.178 +                        fileCount.incrementAndGet();
  73.179 +                        NPETester p = new NPETester();
  73.180 +                        p.test(read(file));
  73.181 +                    } catch (AttributionException e) {
  73.182 +                        if (!quiet) {
  73.183 +                            error("Error attributing " + file + "\n" + e.getMessage());
  73.184 +                        }
  73.185 +                    } catch (IOException e) {
  73.186 +                        error("Error reading " + file + ": " + e);
  73.187 +                    }
  73.188                  }
  73.189 -            } catch (IOException e) {
  73.190 -                error("Error reading " + file + ": " + e);
  73.191 -            }
  73.192 -            return;
  73.193 +            });
  73.194          }
  73.195  
  73.196          if (!quiet)
  73.197 @@ -254,8 +262,6 @@
  73.198      StringWriter sw = new StringWriter();
  73.199      PrintWriter pw = new PrintWriter(sw);
  73.200      Reporter r = new Reporter(pw);
  73.201 -    JavacTool tool = JavacTool.create();
  73.202 -    StandardJavaFileManager fm = tool.getStandardFileManager(r, null, null);
  73.203  
  73.204      /**
  73.205       * Read a file.
  73.206 @@ -265,11 +271,10 @@
  73.207       * @throws TreePosTest.ParseException if any errors occur while parsing the file
  73.208       */
  73.209      List<Pair<JCCompilationUnit, JCTree>> read(File file) throws IOException, AttributionException {
  73.210 -        JavacTool tool = JavacTool.create();
  73.211          r.errors = 0;
  73.212 -        Iterable<? extends JavaFileObject> files = fm.getJavaFileObjects(file);
  73.213 +        Iterable<? extends JavaFileObject> files = fm.get().getJavaFileObjects(file);
  73.214          String[] opts = { "-XDshouldStopPolicy=ATTR", "-XDverboseCompilePolicy" };
  73.215 -        JavacTask task = tool.getTask(pw, fm, r, Arrays.asList(opts), null, files);
  73.216 +        JavacTask task = (JavacTask)comp.getTask(pw, fm.get(), r, Arrays.asList(opts), null, files);
  73.217          final List<Element> analyzedElems = new ArrayList<>();
  73.218          task.setTaskListener(new TaskListener() {
  73.219              public void started(TaskEvent e) {
  73.220 @@ -308,13 +313,9 @@
  73.221       */
  73.222      void error(String msg) {
  73.223          System.err.println(msg);
  73.224 -        errors++;
  73.225 +        errCount.incrementAndGet();
  73.226      }
  73.227  
  73.228 -    /** Number of files that have been analyzed. */
  73.229 -    int fileCount;
  73.230 -    /** Number of errors reported. */
  73.231 -    int errors;
  73.232      /** Flag: don't report irrelevant files. */
  73.233      boolean quiet;
  73.234      /** Flag: show errors in GUI viewer. */
  73.235 @@ -385,7 +386,8 @@
  73.236                          viewer = new Viewer();
  73.237                      viewer.addEntry(sourcefile, label, encl, self);
  73.238                  }
  73.239 -                error(label + self.toString() + " encl: " + encl.toString() + " in file: " + sourcefile + "  " + self.tree);
  73.240 +                error(label + self.toString() + " encl: " + encl.toString() +
  73.241 +                        " in file: " + sourcefile + "  " + self.tree);
  73.242              }
  73.243          }
  73.244  
  73.245 @@ -754,4 +756,8 @@
  73.246              final Info self;
  73.247          }
  73.248      }
  73.249 +
  73.250 +    /** Number of files that have been analyzed. */
  73.251 +    static AtomicInteger fileCount = new AtomicInteger();
  73.252 +
  73.253  }
    74.1 --- a/test/tools/javac/generics/diamond/7046778/DiamondAndInnerClassTest.java	Thu Jan 10 09:56:09 2013 -0800
    74.2 +++ b/test/tools/javac/generics/diamond/7046778/DiamondAndInnerClassTest.java	Thu Jan 10 15:53:02 2013 -0800
    74.3 @@ -1,5 +1,5 @@
    74.4  /*
    74.5 - * Copyright (c) 2011, Oracle and/or its affiliates. All rights reserved.
    74.6 + * Copyright (c) 2011, 2013, Oracle and/or its affiliates. All rights reserved.
    74.7   * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
    74.8   *
    74.9   * This code is free software; you can redistribute it and/or modify it
   74.10 @@ -25,21 +25,21 @@
   74.11   * @test
   74.12   * @bug 7046778
   74.13   * @summary Project Coin: problem with diamond and member inner classes
   74.14 + * @library ../../../lib
   74.15 + * @build JavacTestingAbstractThreadedTest
   74.16 + * @run main DiamondAndInnerClassTest
   74.17   */
   74.18  
   74.19  import com.sun.source.util.JavacTask;
   74.20  import java.net.URI;
   74.21  import java.util.Arrays;
   74.22  import javax.tools.Diagnostic;
   74.23 -import javax.tools.JavaCompiler;
   74.24  import javax.tools.JavaFileObject;
   74.25  import javax.tools.SimpleJavaFileObject;
   74.26 -import javax.tools.StandardJavaFileManager;
   74.27 -import javax.tools.ToolProvider;
   74.28  
   74.29 -public class DiamondAndInnerClassTest {
   74.30 -
   74.31 -    static int checkCount = 0;
   74.32 +public class DiamondAndInnerClassTest
   74.33 +    extends JavacTestingAbstractThreadedTest
   74.34 +    implements Runnable {
   74.35  
   74.36      enum TypeArgumentKind {
   74.37          NONE(""),
   74.38 @@ -151,11 +151,6 @@
   74.39      }
   74.40  
   74.41      public static void main(String... args) throws Exception {
   74.42 -
   74.43 -        //create default shared JavaCompiler - reused across multiple compilations
   74.44 -        JavaCompiler comp = ToolProvider.getSystemJavaCompiler();
   74.45 -        StandardJavaFileManager fm = comp.getStandardFileManager(null, null, null);
   74.46 -
   74.47          for (InnerClassDeclArity innerClassDeclArity : InnerClassDeclArity.values()) {
   74.48              for (TypeQualifierArity declType : TypeQualifierArity.values()) {
   74.49                  if (!declType.matches(innerClassDeclArity)) continue;
   74.50 @@ -168,53 +163,79 @@
   74.51                              //no diamond on decl site
   74.52                              if (taDecl1 == TypeArgumentKind.DIAMOND) continue;
   74.53                              for (TypeArgumentKind taSite1 : TypeArgumentKind.values()) {
   74.54 -                                boolean isSiteRaw = taSite1 == TypeArgumentKind.NONE;
   74.55 +                                boolean isSiteRaw =
   74.56 +                                        taSite1 == TypeArgumentKind.NONE;
   74.57                                  //diamond only allowed on the last type qualifier
   74.58                                  if (taSite1 == TypeArgumentKind.DIAMOND &&
   74.59 -                                        innerClassDeclArity != InnerClassDeclArity.ONE) continue;
   74.60 +                                        innerClassDeclArity !=
   74.61 +                                        InnerClassDeclArity.ONE)
   74.62 +                                    continue;
   74.63                                  for (ArgumentKind arg1 : ArgumentKind.values()) {
   74.64                                      if (innerClassDeclArity == innerClassDeclArity.ONE) {
   74.65 -                                        new DiamondAndInnerClassTest(innerClassDeclArity, declType, newClassType,
   74.66 -                                                argList, new TypeArgumentKind[] {taDecl1},
   74.67 -                                                new TypeArgumentKind[] {taSite1}, new ArgumentKind[] {arg1}).run(comp, fm);
   74.68 +                                        pool.execute(
   74.69 +                                                new DiamondAndInnerClassTest(
   74.70 +                                                innerClassDeclArity, declType,
   74.71 +                                                newClassType, argList,
   74.72 +                                                new TypeArgumentKind[] {taDecl1},
   74.73 +                                                new TypeArgumentKind[] {taSite1},
   74.74 +                                                new ArgumentKind[] {arg1}));
   74.75                                          continue;
   74.76                                      }
   74.77                                      for (TypeArgumentKind taDecl2 : TypeArgumentKind.values()) {
   74.78                                          //no rare types
   74.79 -                                        if (isDeclRaw != (taDecl2 == TypeArgumentKind.NONE)) continue;
   74.80 +                                        if (isDeclRaw != (taDecl2 == TypeArgumentKind.NONE))
   74.81 +                                            continue;
   74.82                                          //no diamond on decl site
   74.83 -                                        if (taDecl2 == TypeArgumentKind.DIAMOND) continue;
   74.84 +                                        if (taDecl2 == TypeArgumentKind.DIAMOND)
   74.85 +                                            continue;
   74.86                                          for (TypeArgumentKind taSite2 : TypeArgumentKind.values()) {
   74.87                                              //no rare types
   74.88 -                                            if (isSiteRaw != (taSite2 == TypeArgumentKind.NONE)) continue;
   74.89 +                                            if (isSiteRaw != (taSite2 == TypeArgumentKind.NONE))
   74.90 +                                                continue;
   74.91                                              //diamond only allowed on the last type qualifier
   74.92                                              if (taSite2 == TypeArgumentKind.DIAMOND &&
   74.93 -                                                    innerClassDeclArity != InnerClassDeclArity.TWO) continue;
   74.94 +                                                    innerClassDeclArity != InnerClassDeclArity.TWO)
   74.95 +                                                continue;
   74.96                                              for (ArgumentKind arg2 : ArgumentKind.values()) {
   74.97                                                  if (innerClassDeclArity == innerClassDeclArity.TWO) {
   74.98 -                                                    new DiamondAndInnerClassTest(innerClassDeclArity, declType, newClassType,
   74.99 -                                                            argList, new TypeArgumentKind[] {taDecl1, taDecl2},
  74.100 +                                                    pool.execute(
  74.101 +                                                            new DiamondAndInnerClassTest(
  74.102 +                                                            innerClassDeclArity,
  74.103 +                                                            declType,
  74.104 +                                                            newClassType,
  74.105 +                                                            argList,
  74.106 +                                                            new TypeArgumentKind[] {taDecl1, taDecl2},
  74.107                                                              new TypeArgumentKind[] {taSite1, taSite2},
  74.108 -                                                            new ArgumentKind[] {arg1, arg2}).run(comp, fm);
  74.109 +                                                            new ArgumentKind[] {arg1, arg2}));
  74.110                                                      continue;
  74.111                                                  }
  74.112                                                  for (TypeArgumentKind taDecl3 : TypeArgumentKind.values()) {
  74.113                                                      //no rare types
  74.114 -                                                    if (isDeclRaw != (taDecl3 == TypeArgumentKind.NONE)) continue;
  74.115 +                                                    if (isDeclRaw != (taDecl3 == TypeArgumentKind.NONE))
  74.116 +                                                        continue;
  74.117                                                      //no diamond on decl site
  74.118 -                                                    if (taDecl3 == TypeArgumentKind.DIAMOND) continue;
  74.119 +                                                    if (taDecl3 == TypeArgumentKind.DIAMOND)
  74.120 +                                                        continue;
  74.121                                                      for (TypeArgumentKind taSite3 : TypeArgumentKind.values()) {
  74.122                                                          //no rare types
  74.123 -                                                        if (isSiteRaw != (taSite3 == TypeArgumentKind.NONE)) continue;
  74.124 +                                                        if (isSiteRaw != (taSite3 == TypeArgumentKind.NONE))
  74.125 +                                                            continue;
  74.126                                                          //diamond only allowed on the last type qualifier
  74.127                                                          if (taSite3 == TypeArgumentKind.DIAMOND &&
  74.128 -                                                                innerClassDeclArity != InnerClassDeclArity.THREE) continue;
  74.129 +                                                            innerClassDeclArity != InnerClassDeclArity.THREE)
  74.130 +                                                            continue;
  74.131                                                          for (ArgumentKind arg3 : ArgumentKind.values()) {
  74.132 -                                                            if (innerClassDeclArity == innerClassDeclArity.THREE) {
  74.133 -                                                                new DiamondAndInnerClassTest(innerClassDeclArity, declType, newClassType,
  74.134 -                                                                        argList, new TypeArgumentKind[] {taDecl1, taDecl2, taDecl3},
  74.135 +                                                            if (innerClassDeclArity ==
  74.136 +                                                                    innerClassDeclArity.THREE) {
  74.137 +                                                                pool.execute(
  74.138 +                                                                        new DiamondAndInnerClassTest(
  74.139 +                                                                        innerClassDeclArity,
  74.140 +                                                                        declType,
  74.141 +                                                                        newClassType,
  74.142 +                                                                        argList,
  74.143 +                                                                        new TypeArgumentKind[] {taDecl1, taDecl2, taDecl3},
  74.144                                                                          new TypeArgumentKind[] {taSite1, taSite2, taSite3},
  74.145 -                                                                        new ArgumentKind[] {arg1, arg2, arg3}).run(comp, fm);
  74.146 +                                                                        new ArgumentKind[] {arg1, arg2, arg3}));
  74.147                                                                  continue;
  74.148                                                              }
  74.149                                                          }
  74.150 @@ -230,7 +251,8 @@
  74.151                  }
  74.152              }
  74.153          }
  74.154 -        System.out.println("Total check executed: " + checkCount);
  74.155 +
  74.156 +        checkAfterExec();
  74.157      }
  74.158  
  74.159      InnerClassDeclArity innerClassDeclArity;
  74.160 @@ -244,9 +266,9 @@
  74.161      DiagnosticChecker diagChecker;
  74.162  
  74.163      DiamondAndInnerClassTest(InnerClassDeclArity innerClassDeclArity,
  74.164 -            TypeQualifierArity declType, TypeQualifierArity siteType, ArgumentListArity argList,
  74.165 -            TypeArgumentKind[] declTypeArgumentKinds, TypeArgumentKind[] siteTypeArgumentKinds,
  74.166 -            ArgumentKind[] argumentKinds) {
  74.167 +            TypeQualifierArity declType, TypeQualifierArity siteType,
  74.168 +            ArgumentListArity argList, TypeArgumentKind[] declTypeArgumentKinds,
  74.169 +            TypeArgumentKind[] siteTypeArgumentKinds, ArgumentKind[] argumentKinds) {
  74.170          this.innerClassDeclArity = innerClassDeclArity;
  74.171          this.declType = declType;
  74.172          this.siteType = siteType;
  74.173 @@ -267,9 +289,9 @@
  74.174          public JavaSource() {
  74.175              super(URI.create("myfo:/Test.java"), JavaFileObject.Kind.SOURCE);
  74.176              source = innerClassDeclArity.classDeclStr.replace("#B", bodyTemplate)
  74.177 -                             .replace("#D", declType.getType(declTypeArgumentKinds))
  74.178 -                             .replace("#S", siteType.getType(siteTypeArgumentKinds))
  74.179 -                             .replace("#AL", argList.getArgs(argumentKinds));
  74.180 +                    .replace("#D", declType.getType(declTypeArgumentKinds))
  74.181 +                    .replace("#S", siteType.getType(siteTypeArgumentKinds))
  74.182 +                    .replace("#AL", argList.getArgs(argumentKinds));
  74.183          }
  74.184  
  74.185          @Override
  74.186 @@ -278,36 +300,39 @@
  74.187          }
  74.188      }
  74.189  
  74.190 -    void run(JavaCompiler tool, StandardJavaFileManager fm) throws Exception {
  74.191 -        JavacTask ct = (JavacTask)tool.getTask(null, fm, diagChecker,
  74.192 +    @Override
  74.193 +    public void run() {
  74.194 +        JavacTask ct = (JavacTask)comp.getTask(null, fm.get(), diagChecker,
  74.195                  null, null, Arrays.asList(source));
  74.196          try {
  74.197              ct.analyze();
  74.198          } catch (Throwable ex) {
  74.199 -            throw new AssertionError("Error thrown when compiling the following code:\n" + source.getCharContent(true));
  74.200 +            throw new AssertionError("Error thrown when compiling the following code:\n" +
  74.201 +                    source.getCharContent(true));
  74.202          }
  74.203          check();
  74.204      }
  74.205  
  74.206      void check() {
  74.207 -        checkCount++;
  74.208 +        checkCount.incrementAndGet();
  74.209  
  74.210          boolean errorExpected = false;
  74.211  
  74.212 -        TypeArgumentKind[] expectedArgKinds = new TypeArgumentKind[innerClassDeclArity.n];
  74.213 +        TypeArgumentKind[] expectedArgKinds =
  74.214 +                new TypeArgumentKind[innerClassDeclArity.n];
  74.215  
  74.216          for (int i = 0 ; i < innerClassDeclArity.n ; i++) {
  74.217              if (!declTypeArgumentKinds[i].compatible(siteTypeArgumentKinds[i])) {
  74.218                  errorExpected = true;
  74.219                  break;
  74.220              }
  74.221 -            expectedArgKinds[i] = siteTypeArgumentKinds[i] == TypeArgumentKind.DIAMOND ?
  74.222 +            expectedArgKinds[i] = siteTypeArgumentKinds[i] ==
  74.223 +                    TypeArgumentKind.DIAMOND ?
  74.224                  declTypeArgumentKinds[i] : siteTypeArgumentKinds[i];
  74.225          }
  74.226  
  74.227          if (!errorExpected) {
  74.228              for (int i = 0 ; i < innerClassDeclArity.n ; i++) {
  74.229 -                //System.out.println("check " + expectedArgKinds[i] + " against " + argumentKinds[i]);
  74.230                  if (!expectedArgKinds[i].compatible(argumentKinds[i])) {
  74.231                      errorExpected = true;
  74.232                      break;
  74.233 @@ -323,7 +348,8 @@
  74.234          }
  74.235      }
  74.236  
  74.237 -    static class DiagnosticChecker implements javax.tools.DiagnosticListener<JavaFileObject> {
  74.238 +    static class DiagnosticChecker
  74.239 +        implements javax.tools.DiagnosticListener<JavaFileObject> {
  74.240  
  74.241          boolean errorFound;
  74.242  
  74.243 @@ -333,4 +359,5 @@
  74.244              }
  74.245          }
  74.246      }
  74.247 +
  74.248  }
    75.1 --- a/test/tools/javac/generics/rawOverride/7062745/GenericOverrideTest.java	Thu Jan 10 09:56:09 2013 -0800
    75.2 +++ b/test/tools/javac/generics/rawOverride/7062745/GenericOverrideTest.java	Thu Jan 10 15:53:02 2013 -0800
    75.3 @@ -1,5 +1,5 @@
    75.4  /*
    75.5 - * Copyright (c) 2011, Oracle and/or its affiliates. All rights reserved.
    75.6 + * Copyright (c) 2011, 2013, Oracle and/or its affiliates. All rights reserved.
    75.7   * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
    75.8   *
    75.9   * This code is free software; you can redistribute it and/or modify it
   75.10 @@ -24,22 +24,23 @@
   75.11  /*
   75.12   * @test
   75.13   * @bug 7062745
   75.14 - * @summary  Regression: difference in overload resolution when two methods are maximally specific
   75.15 + * @summary  Regression: difference in overload resolution when two methods
   75.16 + * are maximally specific
   75.17 + * @library ../../../lib
   75.18 + * @build JavacTestingAbstractThreadedTest
   75.19 + * @run main GenericOverrideTest
   75.20   */
   75.21  
   75.22 -import com.sun.source.util.JavacTask;
   75.23  import java.net.URI;
   75.24  import java.util.Arrays;
   75.25  import javax.tools.Diagnostic;
   75.26 -import javax.tools.JavaCompiler;
   75.27  import javax.tools.JavaFileObject;
   75.28  import javax.tools.SimpleJavaFileObject;
   75.29 -import javax.tools.StandardJavaFileManager;
   75.30 -import javax.tools.ToolProvider;
   75.31 +import com.sun.source.util.JavacTask;
   75.32  
   75.33 -public class GenericOverrideTest {
   75.34 -
   75.35 -    static int checkCount = 0;
   75.36 +public class GenericOverrideTest
   75.37 +    extends JavacTestingAbstractThreadedTest
   75.38 +    implements Runnable {
   75.39  
   75.40      enum SignatureKind {
   75.41          NON_GENERIC(""),
   75.42 @@ -126,11 +127,6 @@
   75.43      }
   75.44  
   75.45      public static void main(String... args) throws Exception {
   75.46 -
   75.47 -        //create default shared JavaCompiler - reused across multiple compilations
   75.48 -        JavaCompiler comp = ToolProvider.getSystemJavaCompiler();
   75.49 -        StandardJavaFileManager fm = comp.getStandardFileManager(null, null, null);
   75.50 -
   75.51          for (SignatureKind sig1 : SignatureKind.values()) {
   75.52              for (ReturnTypeKind rt1 : ReturnTypeKind.values()) {
   75.53                  for (TypeArgumentKind ta1 : TypeArgumentKind.values()) {
   75.54 @@ -141,8 +137,12 @@
   75.55                                  if (!ta2.compatibleWith(sig2)) continue;
   75.56                                  for (ReturnTypeKind rt3 : ReturnTypeKind.values()) {
   75.57                                      for (TypeArgumentKind ta3 : TypeArgumentKind.values()) {
   75.58 -                                        if (!ta3.compatibleWith(SignatureKind.NON_GENERIC)) continue;
   75.59 -                                        new GenericOverrideTest(sig1, rt1, ta1, sig2, rt2, ta2, rt3, ta3).run(comp, fm);
   75.60 +                                        if (!ta3.compatibleWith(SignatureKind.NON_GENERIC))
   75.61 +                                            continue;
   75.62 +                                        pool.execute(
   75.63 +                                                new GenericOverrideTest(sig1,
   75.64 +                                                rt1, ta1, sig2, rt2,
   75.65 +                                                ta2, rt3, ta3));
   75.66                                      }
   75.67                                  }
   75.68                              }
   75.69 @@ -151,7 +151,8 @@
   75.70                  }
   75.71              }
   75.72          }
   75.73 -        System.out.println("Total check executed: " + checkCount);
   75.74 +
   75.75 +        checkAfterExec();
   75.76      }
   75.77  
   75.78      SignatureKind sig1, sig2;
   75.79 @@ -161,7 +162,8 @@
   75.80      DiagnosticChecker diagChecker;
   75.81  
   75.82      GenericOverrideTest(SignatureKind sig1, ReturnTypeKind rt1, TypeArgumentKind ta1,
   75.83 -            SignatureKind sig2, ReturnTypeKind rt2, TypeArgumentKind ta2, ReturnTypeKind rt3, TypeArgumentKind ta3) {
   75.84 +            SignatureKind sig2, ReturnTypeKind rt2, TypeArgumentKind ta2,
   75.85 +            ReturnTypeKind rt3, TypeArgumentKind ta3) {
   75.86          this.sig1 = sig1;
   75.87          this.sig2 = sig2;
   75.88          this.rt1 = rt1;
   75.89 @@ -204,19 +206,21 @@
   75.90          }
   75.91      }
   75.92  
   75.93 -    void run(JavaCompiler tool, StandardJavaFileManager fm) throws Exception {
   75.94 -        JavacTask ct = (JavacTask)tool.getTask(null, fm, diagChecker,
   75.95 +    @Override
   75.96 +    public void run() {
   75.97 +        JavacTask ct = (JavacTask)comp.getTask(null, fm.get(), diagChecker,
   75.98                  null, null, Arrays.asList(source));
   75.99          try {
  75.100              ct.analyze();
  75.101          } catch (Throwable ex) {
  75.102 -            throw new AssertionError("Error thrown when compiling the following code:\n" + source.getCharContent(true));
  75.103 +            throw new AssertionError("Error thrown when compiling the following code:\n" +
  75.104 +                    source.getCharContent(true));
  75.105          }
  75.106          check();
  75.107      }
  75.108  
  75.109      void check() {
  75.110 -        checkCount++;
  75.111 +        checkCount.incrementAndGet();
  75.112  
  75.113          boolean errorExpected = false;
  75.114          int mostSpecific = 0;
  75.115 @@ -234,14 +238,17 @@
  75.116          //check that either TA1 <= TA2 or TA2 <= TA1 (unless most specific return found above is raw)
  75.117          if (!errorExpected) {
  75.118              if (ta1 != ta2) {
  75.119 -                boolean useStrictCheck = ta1.moreSpecificThan(ta2, true) || ta2.moreSpecificThan(ta1, true);
  75.120 +                boolean useStrictCheck = ta1.moreSpecificThan(ta2, true) ||
  75.121 +                        ta2.moreSpecificThan(ta1, true);
  75.122                  if (!ta1.moreSpecificThan(ta2, useStrictCheck) &&
  75.123                          !ta2.moreSpecificThan(ta1, useStrictCheck)) {
  75.124                      errorExpected = true;
  75.125                  } else {
  75.126                      int mostSpecific2 = ta1.moreSpecificThan(ta2, useStrictCheck) ? 1 : 2;
  75.127                      if (mostSpecific != 0 && mostSpecific2 != mostSpecific) {
  75.128 -                        errorExpected = mostSpecific == 1 ? ta1 != TypeArgumentKind.NONE : ta2 != TypeArgumentKind.NONE;
  75.129 +                        errorExpected = mostSpecific == 1 ?
  75.130 +                                ta1 != TypeArgumentKind.NONE :
  75.131 +                                ta2 != TypeArgumentKind.NONE;
  75.132                      } else {
  75.133                          mostSpecific = mostSpecific2;
  75.134                      }
  75.135 @@ -273,7 +280,8 @@
  75.136          }
  75.137      }
  75.138  
  75.139 -    static class DiagnosticChecker implements javax.tools.DiagnosticListener<JavaFileObject> {
  75.140 +    static class DiagnosticChecker
  75.141 +        implements javax.tools.DiagnosticListener<JavaFileObject> {
  75.142  
  75.143          boolean errorFound;
  75.144  
  75.145 @@ -283,4 +291,5 @@
  75.146              }
  75.147          }
  75.148      }
  75.149 +
  75.150  }
    76.1 --- a/test/tools/javac/lambda/FunctionalInterfaceConversionTest.java	Thu Jan 10 09:56:09 2013 -0800
    76.2 +++ b/test/tools/javac/lambda/FunctionalInterfaceConversionTest.java	Thu Jan 10 15:53:02 2013 -0800
    76.3 @@ -1,5 +1,5 @@
    76.4  /*
    76.5 - * Copyright (c) 2012, Oracle and/or its affiliates. All rights reserved.
    76.6 + * Copyright (c) 2012, 2013, Oracle and/or its affiliates. All rights reserved.
    76.7   * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
    76.8   *
    76.9   * This code is free software; you can redistribute it and/or modify it
   76.10 @@ -27,20 +27,24 @@
   76.11   * @summary Add lambda tests
   76.12   *  perform several automated checks in lambda conversion, esp. around accessibility
   76.13   * @author  Maurizio Cimadamore
   76.14 + * @library ../lib
   76.15 + * @build JavacTestingAbstractThreadedTest
   76.16   * @run main FunctionalInterfaceConversionTest
   76.17   */
   76.18  
   76.19 -import com.sun.source.util.JavacTask;
   76.20 +import java.io.IOException;
   76.21  import java.net.URI;
   76.22  import java.util.Arrays;
   76.23  import javax.tools.Diagnostic;
   76.24  import javax.tools.JavaCompiler;
   76.25  import javax.tools.JavaFileObject;
   76.26  import javax.tools.SimpleJavaFileObject;
   76.27 -import javax.tools.StandardJavaFileManager;
   76.28  import javax.tools.ToolProvider;
   76.29 +import com.sun.source.util.JavacTask;
   76.30  
   76.31 -public class FunctionalInterfaceConversionTest {
   76.32 +public class FunctionalInterfaceConversionTest
   76.33 +    extends JavacTestingAbstractThreadedTest
   76.34 +    implements Runnable {
   76.35  
   76.36      enum PackageKind {
   76.37          NO_PKG(""),
   76.38 @@ -139,8 +143,6 @@
   76.39      }
   76.40  
   76.41      public static void main(String[] args) throws Exception {
   76.42 -        final JavaCompiler comp = ToolProvider.getSystemJavaCompiler();
   76.43 -        StandardJavaFileManager fm = comp.getStandardFileManager(null, null, null);
   76.44          for (PackageKind samPkg : PackageKind.values()) {
   76.45              for (ModifierKind modKind : ModifierKind.values()) {
   76.46                  for (SamKind samKind : SamKind.values()) {
   76.47 @@ -150,8 +152,11 @@
   76.48                                  for (TypeKind argType : TypeKind.values()) {
   76.49                                      for (TypeKind thrownType : TypeKind.values()) {
   76.50                                          for (ExprKind exprKind : ExprKind.values()) {
   76.51 -                                            new FunctionalInterfaceConversionTest(samPkg, modKind, samKind,
   76.52 -                                                    samMeth, clientMeth, retType, argType, thrownType, exprKind).test(comp, fm);
   76.53 +                                            pool.execute(
   76.54 +                                                new FunctionalInterfaceConversionTest(
   76.55 +                                                    samPkg, modKind, samKind,
   76.56 +                                                    samMeth, clientMeth, retType,
   76.57 +                                                    argType, thrownType, exprKind));
   76.58                                          }
   76.59                                      }
   76.60                                  }
   76.61 @@ -161,6 +166,8 @@
   76.62                  }
   76.63              }
   76.64          }
   76.65 +
   76.66 +        checkAfterExec(false);
   76.67      }
   76.68  
   76.69      PackageKind samPkg;
   76.70 @@ -175,24 +182,30 @@
   76.71      DiagnosticChecker dc;
   76.72  
   76.73      SourceFile samSourceFile = new SourceFile("Sam.java", "#P \n #C") {
   76.74 +        @Override
   76.75          public String toString() {
   76.76              return template.replaceAll("#P", samPkg.getPkgDecl()).
   76.77 -                    replaceAll("#C", samKind.getSam(samMeth.getMethod(retType, argType, thrownType)));
   76.78 +                    replaceAll("#C", samKind.getSam(
   76.79 +                    samMeth.getMethod(retType, argType, thrownType)));
   76.80          }
   76.81      };
   76.82  
   76.83 -    SourceFile pkgClassSourceFile = new SourceFile("PackageClass.java",
   76.84 -                                                   "#P\n #M class PackageClass extends Exception { }") {
   76.85 +    SourceFile pkgClassSourceFile =
   76.86 +            new SourceFile("PackageClass.java",
   76.87 +                           "#P\n #M class PackageClass extends Exception { }") {
   76.88 +        @Override
   76.89          public String toString() {
   76.90              return template.replaceAll("#P", samPkg.getPkgDecl()).
   76.91                      replaceAll("#M", modKind.modifier_str);
   76.92          }
   76.93      };
   76.94  
   76.95 -    SourceFile clientSourceFile = new SourceFile("Client.java",
   76.96 -                                                 "#I\n abstract class Client { \n" +
   76.97 -                                                 "  Sam s = #E;\n" +
   76.98 -                                                 "  #M \n }") {
   76.99 +    SourceFile clientSourceFile =
  76.100 +            new SourceFile("Client.java",
  76.101 +                           "#I\n abstract class Client { \n" +
  76.102 +                           "  Sam s = #E;\n" +
  76.103 +                           "  #M \n }") {
  76.104 +        @Override
  76.105          public String toString() {
  76.106              return template.replaceAll("#I", samPkg.getImportStat())
  76.107                      .replaceAll("#E", exprKind.exprStr)
  76.108 @@ -200,9 +213,10 @@
  76.109          }
  76.110      };
  76.111  
  76.112 -    FunctionalInterfaceConversionTest(PackageKind samPkg, ModifierKind modKind, SamKind samKind,
  76.113 -            MethodKind samMeth, MethodKind clientMeth, TypeKind retType, TypeKind argType,
  76.114 -            TypeKind thrownType, ExprKind exprKind) {
  76.115 +    FunctionalInterfaceConversionTest(PackageKind samPkg, ModifierKind modKind,
  76.116 +            SamKind samKind, MethodKind samMeth, MethodKind clientMeth,
  76.117 +            TypeKind retType, TypeKind argType, TypeKind thrownType,
  76.118 +            ExprKind exprKind) {
  76.119          this.samPkg = samPkg;
  76.120          this.modKind = modKind;
  76.121          this.samKind = samKind;
  76.122 @@ -215,12 +229,20 @@
  76.123          this.dc = new DiagnosticChecker();
  76.124      }
  76.125  
  76.126 -    void test(JavaCompiler comp, StandardJavaFileManager fm) throws Exception {
  76.127 -        JavacTask ct = (JavacTask)comp.getTask(null, fm, dc,
  76.128 -                null, null, Arrays.asList(samSourceFile, pkgClassSourceFile, clientSourceFile));
  76.129 -        ct.analyze();
  76.130 +    @Override
  76.131 +    public void run() {
  76.132 +        final JavaCompiler tool = ToolProvider.getSystemJavaCompiler();
  76.133 +
  76.134 +        JavacTask ct = (JavacTask)tool.getTask(null, fm.get(), dc, null, null,
  76.135 +                Arrays.asList(samSourceFile, pkgClassSourceFile, clientSourceFile));
  76.136 +        try {
  76.137 +            ct.analyze();
  76.138 +        } catch (IOException ex) {
  76.139 +            throw new AssertionError("Test failing with cause", ex.getCause());
  76.140 +        }
  76.141          if (dc.errorFound == checkSamConversion()) {
  76.142 -            throw new AssertionError(samSourceFile + "\n\n" + pkgClassSourceFile + "\n\n" + clientSourceFile);
  76.143 +            throw new AssertionError(samSourceFile + "\n\n" +
  76.144 +                pkgClassSourceFile + "\n\n" + clientSourceFile);
  76.145          }
  76.146      }
  76.147  
  76.148 @@ -264,13 +286,16 @@
  76.149              return toString();
  76.150          }
  76.151  
  76.152 +        @Override
  76.153          public abstract String toString();
  76.154      }
  76.155  
  76.156 -    static class DiagnosticChecker implements javax.tools.DiagnosticListener<JavaFileObject> {
  76.157 +    static class DiagnosticChecker
  76.158 +        implements javax.tools.DiagnosticListener<JavaFileObject> {
  76.159  
  76.160          boolean errorFound = false;
  76.161  
  76.162 +        @Override
  76.163          public void report(Diagnostic<? extends JavaFileObject> diagnostic) {
  76.164              if (diagnostic.getKind() == Diagnostic.Kind.ERROR) {
  76.165                  errorFound = true;
    77.1 --- a/test/tools/javac/lambda/LambdaParserTest.java	Thu Jan 10 09:56:09 2013 -0800
    77.2 +++ b/test/tools/javac/lambda/LambdaParserTest.java	Thu Jan 10 15:53:02 2013 -0800
    77.3 @@ -1,5 +1,5 @@
    77.4  /*
    77.5 - * Copyright (c) 2011, Oracle and/or its affiliates. All rights reserved.
    77.6 + * Copyright (c) 2011, 2013, Oracle and/or its affiliates. All rights reserved.
    77.7   * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
    77.8   *
    77.9   * This code is free software; you can redistribute it and/or modify it
   77.10 @@ -27,21 +27,21 @@
   77.11   * @bug 8003280
   77.12   * @summary Add lambda tests
   77.13   *  Add parser support for lambda expressions
   77.14 + * @library ../lib
   77.15 + * @build JavacTestingAbstractThreadedTest
   77.16 + * @run main LambdaParserTest
   77.17   */
   77.18  
   77.19 -import com.sun.source.util.JavacTask;
   77.20  import java.net.URI;
   77.21  import java.util.Arrays;
   77.22  import javax.tools.Diagnostic;
   77.23 -import javax.tools.JavaCompiler;
   77.24  import javax.tools.JavaFileObject;
   77.25  import javax.tools.SimpleJavaFileObject;
   77.26 -import javax.tools.StandardJavaFileManager;
   77.27 -import javax.tools.ToolProvider;
   77.28 +import com.sun.source.util.JavacTask;
   77.29  
   77.30 -public class LambdaParserTest {
   77.31 -
   77.32 -    static int checkCount = 0;
   77.33 +public class LambdaParserTest
   77.34 +    extends JavacTestingAbstractThreadedTest
   77.35 +    implements Runnable {
   77.36  
   77.37      enum LambdaKind {
   77.38          NILARY_EXPR("()->x"),
   77.39 @@ -173,25 +173,26 @@
   77.40      }
   77.41  
   77.42      public static void main(String... args) throws Exception {
   77.43 -
   77.44 -        //create default shared JavaCompiler - reused across multiple compilations
   77.45 -        JavaCompiler comp = ToolProvider.getSystemJavaCompiler();
   77.46 -        StandardJavaFileManager fm = comp.getStandardFileManager(null, null, null);
   77.47 -
   77.48          for (LambdaKind lk : LambdaKind.values()) {
   77.49              for (LambdaParameterKind pk1 : LambdaParameterKind.values()) {
   77.50 -                if (lk.arity() < 1 && pk1 != LambdaParameterKind.IMPLICIT) continue;
   77.51 +                if (lk.arity() < 1 && pk1 != LambdaParameterKind.IMPLICIT)
   77.52 +                    continue;
   77.53                  for (LambdaParameterKind pk2 : LambdaParameterKind.values()) {
   77.54 -                    if (lk.arity() < 2 && pk2 != LambdaParameterKind.IMPLICIT) continue;
   77.55 +                    if (lk.arity() < 2 && pk2 != LambdaParameterKind.IMPLICIT)
   77.56 +                        continue;
   77.57                      for (ModifierKind mk1 : ModifierKind.values()) {
   77.58 -                        if (mk1 != ModifierKind.NONE && lk.isShort()) continue;
   77.59 -                        if (lk.arity() < 1 && mk1 != ModifierKind.NONE) continue;
   77.60 +                        if (mk1 != ModifierKind.NONE && lk.isShort())
   77.61 +                            continue;
   77.62 +                        if (lk.arity() < 1 && mk1 != ModifierKind.NONE)
   77.63 +                            continue;
   77.64                          for (ModifierKind mk2 : ModifierKind.values()) {
   77.65 -                            if (lk.arity() < 2 && mk2 != ModifierKind.NONE) continue;
   77.66 +                            if (lk.arity() < 2 && mk2 != ModifierKind.NONE)
   77.67 +                                continue;
   77.68                              for (SubExprKind sk : SubExprKind.values()) {
   77.69                                  for (ExprKind ek : ExprKind.values()) {
   77.70 -                                    new LambdaParserTest(pk1, pk2, mk1, mk2, lk, sk, ek)
   77.71 -                                            .run(comp, fm);
   77.72 +                                    pool.execute(
   77.73 +                                        new LambdaParserTest(pk1, pk2, mk1,
   77.74 +                                                             mk2, lk, sk, ek));
   77.75                                  }
   77.76                              }
   77.77                          }
   77.78 @@ -199,7 +200,8 @@
   77.79                  }
   77.80              }
   77.81          }
   77.82 -        System.out.println("Total check executed: " + checkCount);
   77.83 +
   77.84 +        checkAfterExec();
   77.85      }
   77.86  
   77.87      LambdaParameterKind pk1;
   77.88 @@ -212,8 +214,9 @@
   77.89      JavaSource source;
   77.90      DiagnosticChecker diagChecker;
   77.91  
   77.92 -    LambdaParserTest(LambdaParameterKind pk1, LambdaParameterKind pk2, ModifierKind mk1,
   77.93 -            ModifierKind mk2, LambdaKind lk, SubExprKind sk, ExprKind ek) {
   77.94 +    LambdaParserTest(LambdaParameterKind pk1, LambdaParameterKind pk2,
   77.95 +            ModifierKind mk1, ModifierKind mk2, LambdaKind lk,
   77.96 +            SubExprKind sk, ExprKind ek) {
   77.97          this.pk1 = pk1;
   77.98          this.pk2 = pk2;
   77.99          this.mk1 = mk1;
  77.100 @@ -235,7 +238,8 @@
  77.101  
  77.102          public JavaSource() {
  77.103              super(URI.create("myfo:/Test.java"), JavaFileObject.Kind.SOURCE);
  77.104 -            source = template.replaceAll("#E", ek.expressionString(pk1, pk2, mk1, mk2, lk, sk));
  77.105 +            source = template.replaceAll("#E",
  77.106 +                    ek.expressionString(pk1, pk2, mk1, mk2, lk, sk));
  77.107          }
  77.108  
  77.109          @Override
  77.110 @@ -244,19 +248,20 @@
  77.111          }
  77.112      }
  77.113  
  77.114 -    void run(JavaCompiler tool, StandardJavaFileManager fm) throws Exception {
  77.115 -        JavacTask ct = (JavacTask)tool.getTask(null, fm, diagChecker,
  77.116 +    public void run() {
  77.117 +        JavacTask ct = (JavacTask)comp.getTask(null, fm.get(), diagChecker,
  77.118                  null, null, Arrays.asList(source));
  77.119          try {
  77.120              ct.parse();
  77.121          } catch (Throwable ex) {
  77.122 -            throw new AssertionError("Error thrown when parsing the following source:\n" + source.getCharContent(true));
  77.123 +            processException(ex);
  77.124 +            return;
  77.125          }
  77.126          check();
  77.127      }
  77.128  
  77.129      void check() {
  77.130 -        checkCount++;
  77.131 +        checkCount.incrementAndGet();
  77.132  
  77.133          boolean errorExpected = (lk.arity() > 0 && !mk1.compatibleWith(pk1)) ||
  77.134                  (lk.arity() > 1 && !mk2.compatibleWith(pk2));
  77.135 @@ -275,7 +280,8 @@
  77.136          }
  77.137      }
  77.138  
  77.139 -    static class DiagnosticChecker implements javax.tools.DiagnosticListener<JavaFileObject> {
  77.140 +    static class DiagnosticChecker
  77.141 +        implements javax.tools.DiagnosticListener<JavaFileObject> {
  77.142  
  77.143          boolean errorFound;
  77.144  
  77.145 @@ -285,4 +291,5 @@
  77.146              }
  77.147          }
  77.148      }
  77.149 +
  77.150  }
    78.1 --- a/test/tools/javac/lambda/MethodReferenceParserTest.java	Thu Jan 10 09:56:09 2013 -0800
    78.2 +++ b/test/tools/javac/lambda/MethodReferenceParserTest.java	Thu Jan 10 15:53:02 2013 -0800
    78.3 @@ -1,5 +1,5 @@
    78.4  /*
    78.5 - * Copyright (c) 2011, 2012, Oracle and/or its affiliates. All rights reserved.
    78.6 + * Copyright (c) 2011, 2013, Oracle and/or its affiliates. All rights reserved.
    78.7   * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
    78.8   *
    78.9   * This code is free software; you can redistribute it and/or modify it
   78.10 @@ -27,21 +27,21 @@
   78.11   * @bug 8003280
   78.12   * @summary Add lambda tests
   78.13   *  Add parser support for method references
   78.14 + * @library ../lib
   78.15 + * @build JavacTestingAbstractThreadedTest
   78.16 + * @run main MethodReferenceParserTest
   78.17   */
   78.18  
   78.19 -import com.sun.source.util.JavacTask;
   78.20  import java.net.URI;
   78.21  import java.util.Arrays;
   78.22  import javax.tools.Diagnostic;
   78.23 -import javax.tools.JavaCompiler;
   78.24  import javax.tools.JavaFileObject;
   78.25  import javax.tools.SimpleJavaFileObject;
   78.26 -import javax.tools.StandardJavaFileManager;
   78.27 -import javax.tools.ToolProvider;
   78.28 +import com.sun.source.util.JavacTask;
   78.29  
   78.30 -public class MethodReferenceParserTest {
   78.31 -
   78.32 -    static int checkCount = 0;
   78.33 +public class MethodReferenceParserTest
   78.34 +    extends JavacTestingAbstractThreadedTest
   78.35 +    implements Runnable {
   78.36  
   78.37      enum ReferenceKind {
   78.38          METHOD_REF("#Q::#Gm"),
   78.39 @@ -88,7 +88,8 @@
   78.40              this.contextTemplate = contextTemplate;
   78.41          }
   78.42  
   78.43 -        String contextString(ExprKind ek, ReferenceKind rk, QualifierKind qk, GenericKind gk, SubExprKind sk) {
   78.44 +        String contextString(ExprKind ek, ReferenceKind rk, QualifierKind qk,
   78.45 +                GenericKind gk, SubExprKind sk) {
   78.46              return contextTemplate.replaceAll("#E", ek.expressionString(rk, qk, gk, sk));
   78.47          }
   78.48      }
   78.49 @@ -165,25 +166,21 @@
   78.50      }
   78.51  
   78.52      public static void main(String... args) throws Exception {
   78.53 -
   78.54 -        //create default shared JavaCompiler - reused across multiple compilations
   78.55 -        JavaCompiler comp = ToolProvider.getSystemJavaCompiler();
   78.56 -        StandardJavaFileManager fm = comp.getStandardFileManager(null, null, null);
   78.57 -
   78.58          for (ReferenceKind rk : ReferenceKind.values()) {
   78.59              for (QualifierKind qk : QualifierKind.values()) {
   78.60                  for (GenericKind gk : GenericKind.values()) {
   78.61                      for (SubExprKind sk : SubExprKind.values()) {
   78.62                          for (ExprKind ek : ExprKind.values()) {
   78.63                              for (ContextKind ck : ContextKind.values()) {
   78.64 -                                new MethodReferenceParserTest(rk, qk, gk, sk, ek, ck).run(comp, fm);
   78.65 +                                pool.execute(new MethodReferenceParserTest(rk, qk, gk, sk, ek, ck));
   78.66                              }
   78.67                          }
   78.68                      }
   78.69                  }
   78.70              }
   78.71          }
   78.72 -        System.out.println("Total check executed: " + checkCount);
   78.73 +
   78.74 +        checkAfterExec();
   78.75      }
   78.76  
   78.77      ReferenceKind rk;
   78.78 @@ -227,19 +224,21 @@
   78.79          }
   78.80      }
   78.81  
   78.82 -    void run(JavaCompiler tool, StandardJavaFileManager fm) throws Exception {
   78.83 -        JavacTask ct = (JavacTask)tool.getTask(null, fm, diagChecker,
   78.84 +    @Override
   78.85 +    public void run() {
   78.86 +        JavacTask ct = (JavacTask)comp.getTask(null, fm.get(), diagChecker,
   78.87                  null, null, Arrays.asList(source));
   78.88          try {
   78.89              ct.parse();
   78.90          } catch (Throwable ex) {
   78.91 -            throw new AssertionError("Error thrown when parsing the following source:\n" + source.getCharContent(true));
   78.92 +            processException(ex);
   78.93 +            return;
   78.94          }
   78.95          check();
   78.96      }
   78.97  
   78.98      void check() {
   78.99 -        checkCount++;
  78.100 +        checkCount.incrementAndGet();
  78.101  
  78.102          if (diagChecker.errorFound != rk.erroneous()) {
  78.103              throw new Error("invalid diagnostics for source:\n" +
  78.104 @@ -259,4 +258,5 @@
  78.105              }
  78.106          }
  78.107      }
  78.108 +
  78.109  }
    79.1 --- a/test/tools/javac/lambda/TargetType21.java	Thu Jan 10 09:56:09 2013 -0800
    79.2 +++ b/test/tools/javac/lambda/TargetType21.java	Thu Jan 10 15:53:02 2013 -0800
    79.3 @@ -25,7 +25,7 @@
    79.4      <R,A> void call(SAM3<R,A> sam) { }
    79.5  
    79.6      void test() {
    79.7 -        call(x -> { throw new Exception(); }); //ok - resolves to call(SAM1)
    79.8 +        call(x -> { throw new Exception(); }); //ambiguous
    79.9          call(x -> { System.out.println(""); }); //ok - resolves to call(SAM2)
   79.10          call(x -> { return (Object) null; }); //error - call(SAM3) is not applicable because of cyclic inference
   79.11          call(x -> { return null; }); ////ok - resolves to call(SAM1)
    80.1 --- a/test/tools/javac/lambda/TargetType21.out	Thu Jan 10 09:56:09 2013 -0800
    80.2 +++ b/test/tools/javac/lambda/TargetType21.out	Thu Jan 10 15:53:02 2013 -0800
    80.3 @@ -1,3 +1,3 @@
    80.4  TargetType21.java:28:9: compiler.err.ref.ambiguous: call, kindname.method, call(TargetType21.SAM1), TargetType21, kindname.method, call(TargetType21.SAM2), TargetType21
    80.5 -TargetType21.java:30:9: compiler.err.cant.apply.symbols: kindname.method, call, @755,{(compiler.misc.inapplicable.method: kindname.method, TargetType21, call(TargetType21.SAM1), (compiler.misc.no.conforming.assignment.exists: (compiler.misc.incompatible.ret.type.in.lambda: (compiler.misc.inconvertible.types: java.lang.Object, java.lang.String)))),(compiler.misc.inapplicable.method: kindname.method, TargetType21, call(TargetType21.SAM2), (compiler.misc.no.conforming.assignment.exists: (compiler.misc.incompatible.ret.type.in.lambda: (compiler.misc.unexpected.ret.val)))),(compiler.misc.inapplicable.method: kindname.method, TargetType21, <R,A>call(TargetType21.SAM3<R,A>), (compiler.misc.cyclic.inference: A))}
    80.6 +TargetType21.java:30:9: compiler.err.cant.apply.symbols: kindname.method, call, @737,{(compiler.misc.inapplicable.method: kindname.method, TargetType21, call(TargetType21.SAM1), (compiler.misc.no.conforming.assignment.exists: (compiler.misc.incompatible.ret.type.in.lambda: (compiler.misc.inconvertible.types: java.lang.Object, java.lang.String)))),(compiler.misc.inapplicable.method: kindname.method, TargetType21, call(TargetType21.SAM2), (compiler.misc.no.conforming.assignment.exists: (compiler.misc.incompatible.ret.type.in.lambda: (compiler.misc.unexpected.ret.val)))),(compiler.misc.inapplicable.method: kindname.method, TargetType21, <R,A>call(TargetType21.SAM3<R,A>), (compiler.misc.cyclic.inference: A))}
    80.7  2 errors
    81.1 --- a/test/tools/javac/lambda/TestInvokeDynamic.java	Thu Jan 10 09:56:09 2013 -0800
    81.2 +++ b/test/tools/javac/lambda/TestInvokeDynamic.java	Thu Jan 10 15:53:02 2013 -0800
    81.3 @@ -1,5 +1,5 @@
    81.4  /*
    81.5 - * Copyright (c) 2012, Oracle and/or its affiliates. All rights reserved.
    81.6 + * Copyright (c) 2012, 2013, Oracle and/or its affiliates. All rights reserved.
    81.7   * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
    81.8   *
    81.9   * This code is free software; you can redistribute it and/or modify it
   81.10 @@ -28,7 +28,9 @@
   81.11   * @bug 8003280
   81.12   * @summary Add lambda tests
   81.13   *  Add back-end support for invokedynamic
   81.14 - *
   81.15 + * @library ../lib
   81.16 + * @build JavacTestingAbstractThreadedTest
   81.17 + * @run main TestInvokeDynamic
   81.18   */
   81.19  
   81.20  import com.sun.source.tree.MethodInvocationTree;
   81.21 @@ -66,7 +68,6 @@
   81.22  
   81.23  import javax.tools.Diagnostic;
   81.24  import javax.tools.JavaCompiler;
   81.25 -import javax.tools.JavaFileManager;
   81.26  import javax.tools.JavaFileObject;
   81.27  import javax.tools.SimpleJavaFileObject;
   81.28  import javax.tools.StandardJavaFileManager;
   81.29 @@ -74,69 +75,80 @@
   81.30  
   81.31  import static com.sun.tools.javac.jvm.ClassFile.*;
   81.32  
   81.33 -public class TestInvokeDynamic {
   81.34 -
   81.35 -    static int checkCount = 0;
   81.36 +public class TestInvokeDynamic
   81.37 +    extends JavacTestingAbstractThreadedTest
   81.38 +    implements Runnable {
   81.39  
   81.40      enum StaticArgumentKind {
   81.41          STRING("Hello!", "String", "Ljava/lang/String;") {
   81.42              @Override
   81.43              boolean check(CPInfo cpInfo) throws Exception {
   81.44                  return (cpInfo instanceof CONSTANT_String_info) &&
   81.45 -                        ((CONSTANT_String_info)cpInfo).getString().equals(value);
   81.46 +                        ((CONSTANT_String_info)cpInfo).getString()
   81.47 +                        .equals(value);
   81.48              }
   81.49          },
   81.50          CLASS(null, "Class<?>", "Ljava/lang/Class;") {
   81.51              @Override
   81.52              boolean check(CPInfo cpInfo) throws Exception {
   81.53                  return (cpInfo instanceof CONSTANT_Class_info) &&
   81.54 -                        ((CONSTANT_Class_info)cpInfo).getName().equals("java/lang/String");
   81.55 +                        ((CONSTANT_Class_info)cpInfo).getName()
   81.56 +                        .equals("java/lang/String");
   81.57              }
   81.58          },
   81.59          INTEGER(1, "int", "I") {
   81.60              @Override
   81.61              boolean check(CPInfo cpInfo) throws Exception {
   81.62                  return (cpInfo instanceof CONSTANT_Integer_info) &&
   81.63 -                        ((CONSTANT_Integer_info)cpInfo).value == ((Integer)value).intValue();
   81.64 +                        ((CONSTANT_Integer_info)cpInfo).value ==
   81.65 +                        ((Integer)value).intValue();
   81.66              }
   81.67          },
   81.68          LONG(1L, "long", "J") {
   81.69              @Override
   81.70              boolean check(CPInfo cpInfo) throws Exception {
   81.71                  return (cpInfo instanceof CONSTANT_Long_info) &&
   81.72 -                        ((CONSTANT_Long_info)cpInfo).value == ((Long)value).longValue();
   81.73 +                        ((CONSTANT_Long_info)cpInfo).value ==
   81.74 +                        ((Long)value).longValue();
   81.75              }
   81.76          },
   81.77          FLOAT(1.0f, "float", "F") {
   81.78              @Override
   81.79              boolean check(CPInfo cpInfo) throws Exception {
   81.80                  return (cpInfo instanceof CONSTANT_Float_info) &&
   81.81 -                        ((CONSTANT_Float_info)cpInfo).value == ((Float)value).floatValue();
   81.82 +                        ((CONSTANT_Float_info)cpInfo).value ==
   81.83 +                        ((Float)value).floatValue();
   81.84              }
   81.85          },
   81.86          DOUBLE(1.0, "double","D") {
   81.87              @Override
   81.88              boolean check(CPInfo cpInfo) throws Exception {
   81.89                  return (cpInfo instanceof CONSTANT_Double_info) &&
   81.90 -                        ((CONSTANT_Double_info)cpInfo).value == ((Double)value).doubleValue();
   81.91 +                        ((CONSTANT_Double_info)cpInfo).value ==
   81.92 +                        ((Double)value).doubleValue();
   81.93              }
   81.94          },
   81.95          METHOD_HANDLE(null, "MethodHandle", "Ljava/lang/invoke/MethodHandle;") {
   81.96              @Override
   81.97              boolean check(CPInfo cpInfo) throws Exception {
   81.98 -                if (!(cpInfo instanceof CONSTANT_MethodHandle_info)) return false;
   81.99 -                CONSTANT_MethodHandle_info handleInfo = (CONSTANT_MethodHandle_info)cpInfo;
  81.100 +                if (!(cpInfo instanceof CONSTANT_MethodHandle_info))
  81.101 +                    return false;
  81.102 +                CONSTANT_MethodHandle_info handleInfo =
  81.103 +                        (CONSTANT_MethodHandle_info)cpInfo;
  81.104                  return handleInfo.getCPRefInfo().getClassName().equals("Array") &&
  81.105                          handleInfo.reference_kind == RefKind.REF_invokeVirtual &&
  81.106 -                        handleInfo.getCPRefInfo().getNameAndTypeInfo().getName().equals("clone") &&
  81.107 -                        handleInfo.getCPRefInfo().getNameAndTypeInfo().getType().equals("()Ljava/lang/Object;");
  81.108 +                        handleInfo.getCPRefInfo()
  81.109 +                        .getNameAndTypeInfo().getName().equals("clone") &&
  81.110 +                        handleInfo.getCPRefInfo()
  81.111 +                        .getNameAndTypeInfo().getType().equals("()Ljava/lang/Object;");
  81.112              }
  81.113          },
  81.114          METHOD_TYPE(null, "MethodType", "Ljava/lang/invoke/MethodType;") {
  81.115              @Override
  81.116              boolean check(CPInfo cpInfo) throws Exception {
  81.117                  return (cpInfo instanceof CONSTANT_MethodType_info) &&
  81.118 -                        ((CONSTANT_MethodType_info)cpInfo).getType().equals("()Ljava/lang/Object;");
  81.119 +                        ((CONSTANT_MethodType_info)cpInfo).getType()
  81.120 +                        .equals("()Ljava/lang/Object;");
  81.121              }
  81.122          };
  81.123  
  81.124 @@ -144,7 +156,8 @@
  81.125          String sourceTypeStr;
  81.126          String bytecodeTypeStr;
  81.127  
  81.128 -        StaticArgumentKind(Object value, String sourceTypeStr, String bytecodeTypeStr) {
  81.129 +        StaticArgumentKind(Object value, String sourceTypeStr,
  81.130 +                String bytecodeTypeStr) {
  81.131              this.value = value;
  81.132              this.sourceTypeStr = sourceTypeStr;
  81.133              this.bytecodeTypeStr = bytecodeTypeStr;
  81.134 @@ -163,7 +176,8 @@
  81.135                  case CLASS:
  81.136                      return syms.stringType.tsym;
  81.137                  case METHOD_HANDLE:
  81.138 -                    return new Pool.MethodHandle(REF_invokeVirtual, syms.arrayCloneMethod, types);
  81.139 +                    return new Pool.MethodHandle(REF_invokeVirtual,
  81.140 +                            syms.arrayCloneMethod, types);
  81.141                  case METHOD_TYPE:
  81.142                      return syms.arrayCloneMethod.type;
  81.143                  default:
  81.144 @@ -186,23 +200,21 @@
  81.145      }
  81.146  
  81.147      public static void main(String... args) throws Exception {
  81.148 -        // Create a single file manager and compiler and reuse it for each compile to save time.
  81.149 -        StandardJavaFileManager fm = JavacTool.create().getStandardFileManager(null, null, null);
  81.150 -        final JavaCompiler tool = ToolProvider.getSystemJavaCompiler();
  81.151          for (StaticArgumentsArity arity : StaticArgumentsArity.values()) {
  81.152              if (arity.arity == 0) {
  81.153 -                new TestInvokeDynamic(arity).compileAndCheck(fm, tool);
  81.154 +                pool.execute(new TestInvokeDynamic(arity));
  81.155              } else {
  81.156                  for (StaticArgumentKind sak1 : StaticArgumentKind.values()) {
  81.157                      if (arity.arity == 1) {
  81.158 -                        new TestInvokeDynamic(arity, sak1).compileAndCheck(fm, tool);
  81.159 +                        pool.execute(new TestInvokeDynamic(arity, sak1));
  81.160                      } else {
  81.161                          for (StaticArgumentKind sak2 : StaticArgumentKind.values()) {
  81.162                              if (arity.arity == 2) {
  81.163 -                                new TestInvokeDynamic(arity, sak1, sak2).compileAndCheck(fm, tool);
  81.164 +                                pool.execute(new TestInvokeDynamic(arity, sak1, sak2));
  81.165                              } else {
  81.166                                  for (StaticArgumentKind sak3 : StaticArgumentKind.values()) {
  81.167 -                                    new TestInvokeDynamic(arity, sak1, sak2, sak3).compileAndCheck(fm, tool);
  81.168 +                                    pool.execute(
  81.169 +                                        new TestInvokeDynamic(arity, sak1, sak2, sak3));
  81.170                                  }
  81.171                              }
  81.172                          }
  81.173 @@ -211,23 +223,23 @@
  81.174              }
  81.175          }
  81.176  
  81.177 -        System.out.println("Total checks made: " + checkCount);
  81.178 +        checkAfterExec();
  81.179      }
  81.180  
  81.181      StaticArgumentsArity arity;
  81.182      StaticArgumentKind[] saks;
  81.183 -    JavaSource source;
  81.184      DiagChecker dc;
  81.185  
  81.186      TestInvokeDynamic(StaticArgumentsArity arity, StaticArgumentKind... saks) {
  81.187          this.arity = arity;
  81.188          this.saks = saks;
  81.189 -        source = new JavaSource();
  81.190          dc = new DiagChecker();
  81.191      }
  81.192  
  81.193 -    void compileAndCheck(JavaFileManager fm, JavaCompiler tool) throws Exception {
  81.194 -        JavacTaskImpl ct = (JavacTaskImpl)tool.getTask(null, fm, dc,
  81.195 +    public void run() {
  81.196 +        int id = checkCount.incrementAndGet();
  81.197 +        JavaSource source = new JavaSource(id);
  81.198 +        JavacTaskImpl ct = (JavacTaskImpl)comp.getTask(null, fm.get(), dc,
  81.199                  null, null, Arrays.asList(source));
  81.200          Context context = ct.getContext();
  81.201          Symtab syms = Symtab.instance(context);
  81.202 @@ -238,16 +250,20 @@
  81.203              ct.generate();
  81.204          } catch (Throwable t) {
  81.205              t.printStackTrace();
  81.206 -            throw new AssertionError(String.format("Error thrown when compiling following code\n%s", source.source));
  81.207 +            throw new AssertionError(
  81.208 +                    String.format("Error thrown when compiling following code\n%s",
  81.209 +                    source.source));
  81.210          }
  81.211          if (dc.diagFound) {
  81.212 -            throw new AssertionError(String.format("Diags found when compiling following code\n%s\n\n%s", source.source, dc.printDiags()));
  81.213 +            throw new AssertionError(
  81.214 +                    String.format("Diags found when compiling following code\n%s\n\n%s",
  81.215 +                    source.source, dc.printDiags()));
  81.216          }
  81.217 -        verifyBytecode();
  81.218 +        verifyBytecode(id);
  81.219      }
  81.220  
  81.221 -    void verifyBytecode() {
  81.222 -        File compiledTest = new File("Test.class");
  81.223 +    void verifyBytecode(int id) {
  81.224 +        File compiledTest = new File(String.format("Test%d.class", id));
  81.225          try {
  81.226              ClassFile cf = ClassFile.read(compiledTest);
  81.227              Method testMethod = null;
  81.228 @@ -260,7 +276,8 @@
  81.229              if (testMethod == null) {
  81.230                  throw new Error("Test method not found");
  81.231              }
  81.232 -            Code_attribute ea = (Code_attribute)testMethod.attributes.get(Attribute.Code);
  81.233 +            Code_attribute ea =
  81.234 +                    (Code_attribute)testMethod.attributes.get(Attribute.Code);
  81.235              if (testMethod == null) {
  81.236                  throw new Error("Code attribute for test() method not found");
  81.237              }
  81.238 @@ -270,10 +287,12 @@
  81.239              for (Instruction i : ea.getInstructions()) {
  81.240                  if (i.getMnemonic().equals("invokedynamic")) {
  81.241                      CONSTANT_InvokeDynamic_info indyInfo =
  81.242 -                            (CONSTANT_InvokeDynamic_info)cf.constant_pool.get(i.getShort(1));
  81.243 +                         (CONSTANT_InvokeDynamic_info)cf
  81.244 +                            .constant_pool.get(i.getShort(1));
  81.245                      bsmIdx = indyInfo.bootstrap_method_attr_index;
  81.246                      if (!indyInfo.getNameAndTypeInfo().getType().equals("()V")) {
  81.247 -                        throw new AssertionError("type mismatch for CONSTANT_InvokeDynamic_info");
  81.248 +                        throw new
  81.249 +                            AssertionError("type mismatch for CONSTANT_InvokeDynamic_info");
  81.250                      }
  81.251                  }
  81.252              }
  81.253 @@ -281,34 +300,41 @@
  81.254                  throw new Error("Missing invokedynamic in generated code");
  81.255              }
  81.256  
  81.257 -            BootstrapMethods_attribute bsm_attr = (BootstrapMethods_attribute)cf.getAttribute(Attribute.BootstrapMethods);
  81.258 +            BootstrapMethods_attribute bsm_attr =
  81.259 +                    (BootstrapMethods_attribute)cf
  81.260 +                    .getAttribute(Attribute.BootstrapMethods);
  81.261              if (bsm_attr.bootstrap_method_specifiers.length != 1) {
  81.262 -                throw new Error("Bad number of method specifiers in BootstrapMethods attribute");
  81.263 +                throw new Error("Bad number of method specifiers " +
  81.264 +                        "in BootstrapMethods attribute");
  81.265              }
  81.266              BootstrapMethods_attribute.BootstrapMethodSpecifier bsm_spec =
  81.267                      bsm_attr.bootstrap_method_specifiers[0];
  81.268  
  81.269              if (bsm_spec.bootstrap_arguments.length != arity.arity) {
  81.270 -                throw new Error("Bad number of static invokedynamic args in BootstrapMethod attribute");
  81.271 +                throw new Error("Bad number of static invokedynamic args " +
  81.272 +                        "in BootstrapMethod attribute");
  81.273              }
  81.274  
  81.275              int count = 0;
  81.276              for (StaticArgumentKind sak : saks) {
  81.277 -                if (!sak.check(cf.constant_pool.get(bsm_spec.bootstrap_arguments[count]))) {
  81.278 +                if (!sak.check(cf.constant_pool
  81.279 +                        .get(bsm_spec.bootstrap_arguments[count]))) {
  81.280                      throw new Error("Bad static argument value " + sak);
  81.281                  }
  81.282                  count++;
  81.283              }
  81.284  
  81.285              CONSTANT_MethodHandle_info bsm_handle =
  81.286 -                    (CONSTANT_MethodHandle_info)cf.constant_pool.get(bsm_spec.bootstrap_method_ref);
  81.287 +                    (CONSTANT_MethodHandle_info)cf.constant_pool
  81.288 +                    .get(bsm_spec.bootstrap_method_ref);
  81.289  
  81.290              if (bsm_handle.reference_kind != RefKind.REF_invokeStatic) {
  81.291                  throw new Error("Bad kind on boostrap method handle");
  81.292              }
  81.293  
  81.294              CONSTANT_Methodref_info bsm_ref =
  81.295 -                    (CONSTANT_Methodref_info)cf.constant_pool.get(bsm_handle.reference_index);
  81.296 +                    (CONSTANT_Methodref_info)cf.constant_pool
  81.297 +                    .get(bsm_handle.reference_index);
  81.298  
  81.299              if (!bsm_ref.getClassInfo().getName().equals("Bootstrap")) {
  81.300                  throw new Error("Bad owner of boostrap method");
  81.301 @@ -318,8 +344,11 @@
  81.302                  throw new Error("Bad boostrap method name");
  81.303              }
  81.304  
  81.305 -            if (!bsm_ref.getNameAndTypeInfo().getType().equals(asBSMSignatureString())) {
  81.306 -                throw new Error("Bad boostrap method type" + bsm_ref.getNameAndTypeInfo().getType() + " " + asBSMSignatureString());
  81.307 +            if (!bsm_ref.getNameAndTypeInfo()
  81.308 +                    .getType().equals(asBSMSignatureString())) {
  81.309 +                throw new Error("Bad boostrap method type" +
  81.310 +                        bsm_ref.getNameAndTypeInfo().getType() + " " +
  81.311 +                        asBSMSignatureString());
  81.312              }
  81.313          } catch (Exception e) {
  81.314              e.printStackTrace();
  81.315 @@ -341,20 +370,22 @@
  81.316  
  81.317          static final String source_template = "import java.lang.invoke.*;\n" +
  81.318                  "class Bootstrap {\n" +
  81.319 -                "   public static CallSite bsm(MethodHandles.Lookup lookup, String name, MethodType methodType #SARGS) {\n" +
  81.320 +                "   public static CallSite bsm(MethodHandles.Lookup lookup, " +
  81.321 +                "String name, MethodType methodType #SARGS) {\n" +
  81.322                  "       return null;\n" +
  81.323                  "   }\n" +
  81.324                  "}\n" +
  81.325 -                "class Test {\n" +
  81.326 +                "class Test#ID {\n" +
  81.327                  "   void m() { }\n" +
  81.328                  "   void test() { m(); }\n" +
  81.329                  "}";
  81.330  
  81.331          String source;
  81.332  
  81.333 -        JavaSource() {
  81.334 +        JavaSource(int id) {
  81.335              super(URI.create("myfo:/Test.java"), JavaFileObject.Kind.SOURCE);
  81.336 -            source = source_template.replace("#SARGS", asSignatureString());
  81.337 +            source = source_template.replace("#SARGS", asSignatureString())
  81.338 +                    .replace("#ID", String.valueOf(id));
  81.339          }
  81.340  
  81.341          @Override
  81.342 @@ -411,7 +442,8 @@
  81.343                  for (int i = 0; i < arity.arity ; i++) {
  81.344                      staticArgs[i] = saks[i].getValue(syms, names, types);
  81.345                  }
  81.346 -                ident.sym = new Symbol.DynamicMethodSymbol(oldSym.name, oldSym.owner, REF_invokeStatic, bsm, oldSym.type, staticArgs);
  81.347 +                ident.sym = new Symbol.DynamicMethodSymbol(oldSym.name,
  81.348 +                        oldSym.owner, REF_invokeStatic, bsm, oldSym.type, staticArgs);
  81.349              }
  81.350              return null;
  81.351          }
  81.352 @@ -426,7 +458,8 @@
  81.353          }
  81.354      }
  81.355  
  81.356 -    static class DiagChecker implements javax.tools.DiagnosticListener<JavaFileObject> {
  81.357 +    static class DiagChecker
  81.358 +        implements javax.tools.DiagnosticListener<JavaFileObject> {
  81.359  
  81.360          boolean diagFound;
  81.361          ArrayList<String> diags = new ArrayList<>();
  81.362 @@ -445,4 +478,5 @@
  81.363              return buf.toString();
  81.364          }
  81.365      }
  81.366 +
  81.367  }
    82.1 --- a/test/tools/javac/lambda/mostSpecific/StructuralMostSpecificTest.java	Thu Jan 10 09:56:09 2013 -0800
    82.2 +++ b/test/tools/javac/lambda/mostSpecific/StructuralMostSpecificTest.java	Thu Jan 10 15:53:02 2013 -0800
    82.3 @@ -1,5 +1,5 @@
    82.4  /*
    82.5 - * Copyright (c) 2012, Oracle and/or its affiliates. All rights reserved.
    82.6 + * Copyright (c) 2012, 2013, Oracle and/or its affiliates. All rights reserved.
    82.7   * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
    82.8   *
    82.9   * This code is free software; you can redistribute it and/or modify it
   82.10 @@ -26,24 +26,23 @@
   82.11   * @bug 8003280
   82.12   * @summary Add lambda tests
   82.13   *  Automatic test for checking correctness of structural most specific test routine
   82.14 - * @run main/timeout=360 StructuralMostSpecificTest
   82.15 + * @library ../../lib
   82.16 + * @build JavacTestingAbstractThreadedTest
   82.17 + * @run main/timeout=600 StructuralMostSpecificTest
   82.18   */
   82.19  
   82.20 +import java.net.URI;
   82.21 +import java.util.Arrays;
   82.22 +import javax.tools.Diagnostic;
   82.23 +import javax.tools.JavaFileObject;
   82.24 +import javax.tools.SimpleJavaFileObject;
   82.25  import com.sun.source.util.JavacTask;
   82.26  import com.sun.tools.javac.api.ClientCodeWrapper;
   82.27  import com.sun.tools.javac.util.JCDiagnostic;
   82.28 -import java.net.URI;
   82.29 -import java.util.Arrays;
   82.30 -import javax.tools.Diagnostic;
   82.31 -import javax.tools.JavaCompiler;
   82.32 -import javax.tools.JavaFileObject;
   82.33 -import javax.tools.SimpleJavaFileObject;
   82.34 -import javax.tools.StandardJavaFileManager;
   82.35 -import javax.tools.ToolProvider;
   82.36  
   82.37 -public class StructuralMostSpecificTest {
   82.38 -
   82.39 -    static int checkCount = 0;
   82.40 +public class StructuralMostSpecificTest
   82.41 +    extends JavacTestingAbstractThreadedTest
   82.42 +    implements Runnable {
   82.43  
   82.44      enum RetTypeKind {
   82.45          SHORT("short"),
   82.46 @@ -105,7 +104,7 @@
   82.47          VOID("return;"),
   82.48          SHORT("return (short)0;"),
   82.49          INT("return 0;"),
   82.50 -        INTEGER("return (Integer)null"),
   82.51 +        INTEGER("return (Integer)null;"),
   82.52          NULL("return null;");
   82.53  
   82.54          String retStr;
   82.55 @@ -142,11 +141,6 @@
   82.56      }
   82.57  
   82.58      public static void main(String... args) throws Exception {
   82.59 -
   82.60 -        //create default shared JavaCompiler - reused across multiple compilations
   82.61 -        JavaCompiler comp = ToolProvider.getSystemJavaCompiler();
   82.62 -        StandardJavaFileManager fm = comp.getStandardFileManager(null, null, null);
   82.63 -
   82.64          for (LambdaReturnKind lrk : LambdaReturnKind.values()) {
   82.65              for (RetTypeKind rk1 : RetTypeKind.values()) {
   82.66                  for (RetTypeKind rk2 : RetTypeKind.values()) {
   82.67 @@ -154,7 +148,9 @@
   82.68                          for (ExceptionKind ek2 : ExceptionKind.values()) {
   82.69                              for (ArgTypeKind ak11 : ArgTypeKind.values()) {
   82.70                                  for (ArgTypeKind ak12 : ArgTypeKind.values()) {
   82.71 -                                    new StructuralMostSpecificTest(lrk, rk1, rk2, ek1, ek2, ak11, ak12).run(comp, fm);
   82.72 +                                    pool.execute(
   82.73 +                                        new StructuralMostSpecificTest(lrk, rk1,
   82.74 +                                            rk2, ek1, ek2, ak11, ak12));
   82.75                                  }
   82.76                              }
   82.77                          }
   82.78 @@ -162,7 +158,8 @@
   82.79                  }
   82.80              }
   82.81          }
   82.82 -        System.out.println("Total check executed: " + checkCount);
   82.83 +
   82.84 +        checkAfterExec();
   82.85      }
   82.86  
   82.87      LambdaReturnKind lrk;
   82.88 @@ -218,20 +215,22 @@
   82.89          }
   82.90      }
   82.91  
   82.92 -    void run(JavaCompiler tool, StandardJavaFileManager fm) throws Exception {
   82.93 -        JavacTask ct = (JavacTask)tool.getTask(null, fm, diagChecker,
   82.94 +    public void run() {
   82.95 +        JavacTask ct = (JavacTask)comp.getTask(null, fm.get(), diagChecker,
   82.96                  Arrays.asList("-XDverboseResolution=all,-predef,-internal,-object-init"),
   82.97                  null, Arrays.asList(source));
   82.98          try {
   82.99              ct.analyze();
  82.100          } catch (Throwable ex) {
  82.101 -            throw new AssertionError("Error thron when analyzing the following source:\n" + source.getCharContent(true));
  82.102 +            throw new
  82.103 +                AssertionError("Error thron when analyzing the following source:\n" +
  82.104 +                    source.getCharContent(true));
  82.105          }
  82.106          check();
  82.107      }
  82.108  
  82.109      void check() {
  82.110 -        checkCount++;
  82.111 +        checkCount.incrementAndGet();
  82.112  
  82.113          if (!lrk.compatibleWith(rt1) || !lrk.compatibleWith(rt2))
  82.114              return;
  82.115 @@ -265,8 +264,8 @@
  82.116          }
  82.117      }
  82.118  
  82.119 -    boolean moreSpecific(RetTypeKind rk1, RetTypeKind rk2, ExceptionKind ek1, ExceptionKind ek2,
  82.120 -            ArgTypeKind ak1, ArgTypeKind ak2) {
  82.121 +    boolean moreSpecific(RetTypeKind rk1, RetTypeKind rk2, ExceptionKind ek1,
  82.122 +            ExceptionKind ek2, ArgTypeKind ak1, ArgTypeKind ak2) {
  82.123          if (!rk1.moreSpecificThan(rk2))
  82.124              return false;
  82.125  
  82.126 @@ -276,7 +275,8 @@
  82.127          return true;
  82.128      }
  82.129  
  82.130 -    static class DiagnosticChecker implements javax.tools.DiagnosticListener<JavaFileObject> {
  82.131 +    static class DiagnosticChecker
  82.132 +        implements javax.tools.DiagnosticListener<JavaFileObject> {
  82.133  
  82.134          boolean ambiguityFound;
  82.135          String mostSpecificSig;
  82.136 @@ -287,12 +287,16 @@
  82.137                          diagnostic.getCode().equals("compiler.err.ref.ambiguous")) {
  82.138                      ambiguityFound = true;
  82.139                  } else if (diagnostic.getKind() == Diagnostic.Kind.NOTE &&
  82.140 -                        diagnostic.getCode().equals("compiler.note.verbose.resolve.multi")) {
  82.141 +                        diagnostic.getCode()
  82.142 +                        .equals("compiler.note.verbose.resolve.multi")) {
  82.143                      ClientCodeWrapper.DiagnosticSourceUnwrapper dsu =
  82.144 -                            (ClientCodeWrapper.DiagnosticSourceUnwrapper)diagnostic;
  82.145 -                    JCDiagnostic.MultilineDiagnostic mdiag = (JCDiagnostic.MultilineDiagnostic)dsu.d;
  82.146 +                        (ClientCodeWrapper.DiagnosticSourceUnwrapper)diagnostic;
  82.147 +                    JCDiagnostic.MultilineDiagnostic mdiag =
  82.148 +                        (JCDiagnostic.MultilineDiagnostic)dsu.d;
  82.149                      int mostSpecificIndex = (Integer)mdiag.getArgs()[2];
  82.150 -                    mostSpecificSig = ((JCDiagnostic)mdiag.getSubdiagnostics().get(mostSpecificIndex)).getArgs()[1].toString();
  82.151 +                    mostSpecificSig =
  82.152 +                        ((JCDiagnostic)mdiag.getSubdiagnostics()
  82.153 +                            .get(mostSpecificIndex)).getArgs()[1].toString();
  82.154                  }
  82.155              } catch (RuntimeException t) {
  82.156                  t.printStackTrace();
  82.157 @@ -300,4 +304,5 @@
  82.158              }
  82.159          }
  82.160      }
  82.161 +
  82.162  }
    83.1 --- a/test/tools/javac/lambda/typeInference/combo/TypeInferenceComboTest.java	Thu Jan 10 09:56:09 2013 -0800
    83.2 +++ b/test/tools/javac/lambda/typeInference/combo/TypeInferenceComboTest.java	Thu Jan 10 15:53:02 2013 -0800
    83.3 @@ -1,5 +1,5 @@
    83.4  /*
    83.5 - * Copyright (c) 2011, Oracle and/or its affiliates. All rights reserved.
    83.6 + * Copyright (c) 2011, 2013, Oracle and/or its affiliates. All rights reserved.
    83.7   * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
    83.8   *
    83.9   * This code is free software; you can redistribute it and/or modify it
   83.10 @@ -25,22 +25,24 @@
   83.11   * @test
   83.12   * @bug 8003280
   83.13   * @summary Add lambda tests
   83.14 - *  perform automated checks in type inference in lambda expressions in different contexts
   83.15 + *  perform automated checks in type inference in lambda expressions
   83.16 + *  in different contexts
   83.17 + * @library ../../../lib
   83.18 + * @build JavacTestingAbstractThreadedTest
   83.19   * @compile  TypeInferenceComboTest.java
   83.20   * @run main/timeout=360 TypeInferenceComboTest
   83.21   */
   83.22  
   83.23 -import com.sun.source.util.JavacTask;
   83.24  import java.net.URI;
   83.25  import java.util.Arrays;
   83.26  import javax.tools.Diagnostic;
   83.27 -import javax.tools.JavaCompiler;
   83.28  import javax.tools.JavaFileObject;
   83.29  import javax.tools.SimpleJavaFileObject;
   83.30 -import javax.tools.ToolProvider;
   83.31 -import javax.tools.StandardJavaFileManager;
   83.32 +import com.sun.source.util.JavacTask;
   83.33  
   83.34 -public class TypeInferenceComboTest {
   83.35 +public class TypeInferenceComboTest
   83.36 +    extends JavacTestingAbstractThreadedTest
   83.37 +    implements Runnable {
   83.38      enum Context {
   83.39          ASSIGNMENT("SAM#Type s = #LBody;"),
   83.40          METHOD_CALL("#GenericDeclKind void method1(SAM#Type s) { }\n" +
   83.41 @@ -59,27 +61,35 @@
   83.42              this.context = context;
   83.43          }
   83.44  
   83.45 -        String getContext(SamKind sk, TypeKind samTargetT, Keyword kw, TypeKind parameterT, TypeKind returnT, LambdaKind lk, ParameterKind pk, GenericDeclKind gdk, LambdaBody lb) {
   83.46 +        String getContext(SamKind sk, TypeKind samTargetT, Keyword kw,
   83.47 +                TypeKind parameterT, TypeKind returnT, LambdaKind lk,
   83.48 +                ParameterKind pk, GenericDeclKind gdk, LambdaBody lb) {
   83.49              String result = context;
   83.50              if (sk == SamKind.GENERIC) {
   83.51                  if(this == Context.METHOD_CALL) {
   83.52 -                    result = result.replaceAll("#GenericDeclKind", gdk.getGenericDeclKind(samTargetT));
   83.53 +                    result = result.replaceAll("#GenericDeclKind",
   83.54 +                            gdk.getGenericDeclKind(samTargetT));
   83.55                      if(gdk == GenericDeclKind.NON_GENERIC)
   83.56 -                        result = result.replaceAll("#Type", "<" + samTargetT.typeStr + ">");
   83.57 +                        result = result.replaceAll("#Type", "<" +
   83.58 +                                samTargetT.typeStr + ">");
   83.59                      else //#GenericDeclKind is <T> or <T extends xxx>
   83.60                          result = result.replaceAll("#Type", "<T>");
   83.61                  }
   83.62                  else {
   83.63                      if(kw == Keyword.VOID)
   83.64 -                        result = result.replaceAll("#Type", "<" + samTargetT.typeStr + ">");
   83.65 +                        result = result.replaceAll("#Type", "<" +
   83.66 +                                samTargetT.typeStr + ">");
   83.67                      else
   83.68 -                        result = result.replaceAll("#Type", "<? " + kw.keyStr + " " + samTargetT.typeStr + ">");
   83.69 +                        result = result.replaceAll("#Type", "<? " + kw.keyStr +
   83.70 +                                " " + samTargetT.typeStr + ">");
   83.71                  }
   83.72              }
   83.73              else
   83.74 -                result = result.replaceAll("#Type", "").replaceAll("#GenericDeclKind", "");
   83.75 +                result = result.replaceAll("#Type", "").
   83.76 +                        replaceAll("#GenericDeclKind", "");
   83.77  
   83.78 -            return result.replaceAll("#LBody", lb.getLambdaBody(samTargetT, parameterT, returnT, lk, pk));
   83.79 +            return result.replaceAll("#LBody",
   83.80 +                    lb.getLambdaBody(samTargetT, parameterT, returnT, lk, pk));
   83.81          }
   83.82      }
   83.83  
   83.84 @@ -94,8 +104,10 @@
   83.85          }
   83.86  
   83.87          String getSam(TypeKind parameterT, TypeKind returnT) {
   83.88 -            return sam_str.replaceAll("#ARG", parameterT == TypeKind.VOID ? "" : parameterT.typeStr + " arg")
   83.89 -                          .replaceAll("#R", returnT.typeStr);
   83.90 +            return sam_str.replaceAll("#ARG",
   83.91 +                    parameterT == TypeKind.VOID ?
   83.92 +                        "" : parameterT.typeStr + " arg")
   83.93 +                    .replaceAll("#R", returnT.typeStr);
   83.94          }
   83.95      }
   83.96  
   83.97 @@ -104,7 +116,8 @@
   83.98          STRING("String", "\"hello\""),
   83.99          INTEGER("Integer", "1"),
  83.100          INT("int", "0"),
  83.101 -        COMPARATOR("java.util.Comparator<String>", "(java.util.Comparator<String>)(a, b) -> a.length()-b.length()"),
  83.102 +        COMPARATOR("java.util.Comparator<String>",
  83.103 +                "(java.util.Comparator<String>)(a, b) -> a.length()-b.length()"),
  83.104          SAM("SAM2", "null"),
  83.105          GENERIC("T", null);
  83.106  
  83.107 @@ -152,8 +165,10 @@
  83.108      }
  83.109  
  83.110      enum LambdaBody {
  83.111 -        RETURN_VOID("() -> #RET"),//no parameters, return type is one of the TypeKind
  83.112 -        RETURN_ARG("(#PK arg) -> #RET");//has parameters, return type is one of the TypeKind
  83.113 +        //no parameters, return type is one of the TypeKind
  83.114 +        RETURN_VOID("() -> #RET"),
  83.115 +        //has parameters, return type is one of the TypeKind
  83.116 +        RETURN_ARG("(#PK arg) -> #RET");
  83.117  
  83.118          String bodyStr;
  83.119  
  83.120 @@ -161,12 +176,14 @@
  83.121              this.bodyStr = bodyStr;
  83.122          }
  83.123  
  83.124 -        String getLambdaBody(TypeKind samTargetT, TypeKind parameterT, TypeKind returnT, LambdaKind lk, ParameterKind pk) {
  83.125 +        String getLambdaBody(TypeKind samTargetT, TypeKind parameterT,
  83.126 +                TypeKind returnT, LambdaKind lk, ParameterKind pk) {
  83.127              String result = bodyStr.replaceAll("#PK", pk.paramTemplate);
  83.128  
  83.129              if(result.contains("#TYPE")) {
  83.130                  if (parameterT == TypeKind.GENERIC && this != RETURN_VOID)
  83.131 -                    result = result.replaceAll("#TYPE", samTargetT == null? "": samTargetT.typeStr);
  83.132 +                    result = result.replaceAll("#TYPE",
  83.133 +                            samTargetT == null? "": samTargetT.typeStr);
  83.134                  else
  83.135                      result = result.replaceAll("#TYPE", parameterT.typeStr);
  83.136              }
  83.137 @@ -174,9 +191,12 @@
  83.138                  return result.replaceAll("#RET", lk.stmt.replaceAll("#VAL", "arg"));
  83.139              else {
  83.140                  if(returnT != TypeKind.GENERIC)
  83.141 -                    return result.replaceAll("#RET", lk.stmt.replaceAll("#VAL", (returnT==TypeKind.VOID && lk==LambdaKind.EXPRESSION)? "{}" : returnT.valStr));
  83.142 +                    return result.replaceAll("#RET", lk.stmt.replaceAll("#VAL",
  83.143 +                            (returnT==TypeKind.VOID &&
  83.144 +                            lk==LambdaKind.EXPRESSION) ? "{}" : returnT.valStr));
  83.145                  else
  83.146 -                    return result.replaceAll("#RET", lk.stmt.replaceAll("#VAL", samTargetT.valStr));
  83.147 +                    return result.replaceAll("#RET",
  83.148 +                            lk.stmt.replaceAll("#VAL", samTargetT.valStr));
  83.149              }
  83.150          }
  83.151      }
  83.152 @@ -203,8 +223,10 @@
  83.153          }
  83.154          else if (lambdaBodyType != LambdaBody.RETURN_ARG)
  83.155              return false;
  83.156 -        if (  genericDeclKind == GenericDeclKind.GENERIC_NOBOUND || genericDeclKind == GenericDeclKind.GENERIC_BOUND ) {
  83.157 -            if ( parameterType == TypeKind.GENERIC && parameterKind == ParameterKind.IMPLICIT) //cyclic inference
  83.158 +        if (  genericDeclKind == GenericDeclKind.GENERIC_NOBOUND ||
  83.159 +                genericDeclKind == GenericDeclKind.GENERIC_BOUND ) {
  83.160 +            if ( parameterType == TypeKind.GENERIC &&
  83.161 +                    parameterKind == ParameterKind.IMPLICIT) //cyclic inference
  83.162                  return false;
  83.163          }
  83.164          return true;
  83.165 @@ -216,7 +238,8 @@
  83.166                           "}\n";
  83.167      SourceFile samSourceFile = new SourceFile("Sam.java", templateStr) {
  83.168          public String toString() {
  83.169 -            return template.replaceAll("#C", samKind.getSam(parameterType, returnType));
  83.170 +            return template.replaceAll("#C",
  83.171 +                    samKind.getSam(parameterType, returnType));
  83.172          }
  83.173      };
  83.174  
  83.175 @@ -225,22 +248,35 @@
  83.176                                                   "    #Context\n" +
  83.177                                                   "}") {
  83.178          public String toString() {
  83.179 -            return template.replaceAll("#Context", context.getContext(samKind, samTargetType, keyword, parameterType, returnType, lambdaKind, parameterKind, genericDeclKind, lambdaBodyType));
  83.180 +            return template.replaceAll("#Context",
  83.181 +                    context.getContext(samKind, samTargetType, keyword,
  83.182 +                    parameterType, returnType, lambdaKind, parameterKind,
  83.183 +                    genericDeclKind, lambdaBodyType));
  83.184          }
  83.185      };
  83.186  
  83.187 -    void test() throws Exception {
  83.188 -        System.out.println("kk:");
  83.189 +    public void run() {
  83.190 +        outWriter.println("kk:");
  83.191          StringBuilder sb = new StringBuilder("SamKind:");
  83.192 -        sb.append(samKind).append(" SamTargetType:").append(samTargetType).append(" ParameterType:").append(parameterType)
  83.193 -            .append(" ReturnType:").append(returnType).append(" Context:").append(context).append(" LambdaKind:").append(lambdaKind)
  83.194 -            .append(" LambdaBodyType:").append(lambdaBodyType).append(" ParameterKind:").append(parameterKind).append(" Keyword:").append(keyword);
  83.195 -        System.out.println(sb);
  83.196 +        sb.append(samKind).append(" SamTargetType:")
  83.197 +            .append(samTargetType).append(" ParameterType:").append(parameterType)
  83.198 +            .append(" ReturnType:").append(returnType).append(" Context:")
  83.199 +            .append(context).append(" LambdaKind:").append(lambdaKind)
  83.200 +            .append(" LambdaBodyType:").append(lambdaBodyType)
  83.201 +            .append(" ParameterKind:").append(parameterKind).append(" Keyword:")
  83.202 +            .append(keyword);
  83.203 +        outWriter.println(sb);
  83.204          DiagnosticChecker dc = new DiagnosticChecker();
  83.205 -        JavacTask ct = (JavacTask)comp.getTask(null, fm, dc, null, null, Arrays.asList(samSourceFile, clientSourceFile));
  83.206 -        ct.analyze();
  83.207 +        JavacTask ct = (JavacTask)comp.getTask(null, fm.get(), dc,
  83.208 +                null, null, Arrays.asList(samSourceFile, clientSourceFile));
  83.209 +        try {
  83.210 +            ct.analyze();
  83.211 +        } catch (Throwable t) {
  83.212 +            processException(t);
  83.213 +        }
  83.214          if (dc.errorFound == checkTypeInference()) {
  83.215 -            throw new AssertionError(samSourceFile + "\n\n" + clientSourceFile + "\n" + parameterType + " " + returnType);
  83.216 +            throw new AssertionError(samSourceFile + "\n\n" +
  83.217 +                    clientSourceFile + "\n" + parameterType + " " + returnType);
  83.218          }
  83.219      }
  83.220  
  83.221 @@ -261,7 +297,8 @@
  83.222          public abstract String toString();
  83.223      }
  83.224  
  83.225 -    static class DiagnosticChecker implements javax.tools.DiagnosticListener<JavaFileObject> {
  83.226 +    static class DiagnosticChecker
  83.227 +        implements javax.tools.DiagnosticListener<JavaFileObject> {
  83.228  
  83.229          boolean errorFound = false;
  83.230  
  83.231 @@ -283,10 +320,9 @@
  83.232      Keyword keyword;
  83.233      GenericDeclKind genericDeclKind;
  83.234  
  83.235 -    static JavaCompiler comp = ToolProvider.getSystemJavaCompiler();
  83.236 -    static StandardJavaFileManager fm = comp.getStandardFileManager(null, null, null);
  83.237 -
  83.238 -    TypeInferenceComboTest(SamKind sk, TypeKind samTargetT, TypeKind parameterT, TypeKind returnT, LambdaBody lb, Context c, LambdaKind lk, ParameterKind pk, Keyword kw, GenericDeclKind gdk) {
  83.239 +    TypeInferenceComboTest(SamKind sk, TypeKind samTargetT, TypeKind parameterT,
  83.240 +            TypeKind returnT, LambdaBody lb, Context c, LambdaKind lk,
  83.241 +            ParameterKind pk, Keyword kw, GenericDeclKind gdk) {
  83.242          samKind = sk;
  83.243          samTargetType = samTargetT;
  83.244          parameterType = parameterT;
  83.245 @@ -308,24 +344,14 @@
  83.246                              for(LambdaKind lambdaK : LambdaKind.values()) {
  83.247                                  for (SamKind sk : SamKind.values()) {
  83.248                                      if (sk == SamKind.NON_GENERIC) {
  83.249 -                                        if(parameterT != TypeKind.GENERIC && returnT != TypeKind.GENERIC )
  83.250 -                                            new TypeInferenceComboTest(sk, null, parameterT, returnT, lb, ct, lambdaK, parameterK, null, null).test();
  83.251 +                                        generateNonGenericSAM(ct, returnT,
  83.252 +                                                parameterT, lb, parameterK,
  83.253 +                                                lambdaK, sk);
  83.254                                      }
  83.255                                      else if (sk == SamKind.GENERIC) {
  83.256 -                                        for (Keyword kw : Keyword.values()) {
  83.257 -                                            for (TypeKind samTargetT : TypeKind.values()) {
  83.258 -                                                if(samTargetT != TypeKind.VOID && samTargetT != TypeKind.INT && samTargetT != TypeKind.GENERIC
  83.259 -                                                   && (parameterT == TypeKind.GENERIC || returnT == TypeKind.GENERIC)) {
  83.260 -                                                    if(ct != Context.METHOD_CALL) {
  83.261 -                                                        new TypeInferenceComboTest(sk, samTargetT, parameterT, returnT, lb, ct, lambdaK, parameterK, kw, null).test();
  83.262 -                                                    }
  83.263 -                                                    else {//Context.METHOD_CALL
  83.264 -                                                        for (GenericDeclKind gdk : GenericDeclKind.values())
  83.265 -                                                            new TypeInferenceComboTest(sk, samTargetT, parameterT, returnT, lb, ct, lambdaK, parameterK, kw, gdk).test();
  83.266 -                                                    }
  83.267 -                                                }
  83.268 -                                            }
  83.269 -                                        }
  83.270 +                                        generateGenericSAM(ct, returnT,
  83.271 +                                                parameterT, lb, parameterK,
  83.272 +                                                lambdaK, sk);
  83.273                                      }
  83.274                                  }
  83.275                              }
  83.276 @@ -334,5 +360,44 @@
  83.277                  }
  83.278              }
  83.279          }
  83.280 +
  83.281 +        checkAfterExec(false);
  83.282      }
  83.283 +
  83.284 +    static void generateNonGenericSAM(Context ct, TypeKind returnT,
  83.285 +            TypeKind parameterT, LambdaBody lb, ParameterKind parameterK,
  83.286 +            LambdaKind lambdaK, SamKind sk) {
  83.287 +        if(parameterT != TypeKind.GENERIC && returnT != TypeKind.GENERIC ) {
  83.288 +            pool.execute(new TypeInferenceComboTest(sk, null, parameterT,
  83.289 +                    returnT, lb, ct, lambdaK, parameterK, null, null));
  83.290 +        }
  83.291 +    }
  83.292 +
  83.293 +    static void generateGenericSAM(Context ct, TypeKind returnT,
  83.294 +            TypeKind parameterT, LambdaBody lb, ParameterKind parameterK,
  83.295 +            LambdaKind lambdaK, SamKind sk) {
  83.296 +        for (Keyword kw : Keyword.values()) {
  83.297 +            for (TypeKind samTargetT : TypeKind.values()) {
  83.298 +                if(samTargetT != TypeKind.VOID &&
  83.299 +                   samTargetT != TypeKind.INT &&
  83.300 +                   samTargetT != TypeKind.GENERIC &&
  83.301 +                   (parameterT == TypeKind.GENERIC ||
  83.302 +                   returnT == TypeKind.GENERIC)) {
  83.303 +                    if(ct != Context.METHOD_CALL) {
  83.304 +                        pool.execute(
  83.305 +                            new TypeInferenceComboTest(sk, samTargetT, parameterT,
  83.306 +                                returnT, lb, ct, lambdaK, parameterK, kw, null));
  83.307 +                    } else {//Context.METHOD_CALL
  83.308 +                        for (GenericDeclKind gdk :
  83.309 +                                GenericDeclKind.values())
  83.310 +                            pool.execute(
  83.311 +                                    new TypeInferenceComboTest(sk, samTargetT,
  83.312 +                                    parameterT, returnT, lb, ct, lambdaK,
  83.313 +                                    parameterK, kw, gdk));
  83.314 +                    }
  83.315 +                }
  83.316 +            }
  83.317 +         }
  83.318 +    }
  83.319 +
  83.320  }
    84.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
    84.2 +++ b/test/tools/javac/lib/JavacTestingAbstractThreadedTest.java	Thu Jan 10 15:53:02 2013 -0800
    84.3 @@ -0,0 +1,142 @@
    84.4 +/*
    84.5 + * Copyright (c) 2010, 2013, Oracle and/or its affiliates. All rights reserved.
    84.6 + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
    84.7 + *
    84.8 + * This code is free software; you can redistribute it and/or modify it
    84.9 + * under the terms of the GNU General Public License version 2 only, as
   84.10 + * published by the Free Software Foundation.
   84.11 + *
   84.12 + * This code is distributed in the hope that it will be useful, but WITHOUT
   84.13 + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
   84.14 + * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
   84.15 + * version 2 for more details (a copy is included in the LICENSE file that
   84.16 + * accompanied this code).
   84.17 + *
   84.18 + * You should have received a copy of the GNU General Public License version
   84.19 + * 2 along with this work; if not, write to the Free Software Foundation,
   84.20 + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
   84.21 + *
   84.22 + * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
   84.23 + * or visit www.oracle.com if you need additional information or have any
   84.24 + * questions.
   84.25 + */
   84.26 +
   84.27 +import java.io.PrintWriter;
   84.28 +import java.io.StringWriter;
   84.29 +import java.util.concurrent.ExecutorService;
   84.30 +import java.util.concurrent.Executors;
   84.31 +import java.util.concurrent.ThreadFactory;
   84.32 +import java.util.concurrent.atomic.AtomicInteger;
   84.33 +import javax.tools.JavaCompiler;
   84.34 +import javax.tools.StandardJavaFileManager;
   84.35 +import javax.tools.ToolProvider;
   84.36 +
   84.37 +/**
   84.38 + * An abstract superclass for threaded tests.
   84.39 + *
   84.40 + * This class will try to read a property named test.concurrency.
   84.41 + * The property can be provided by passing this option to jtreg:
   84.42 + * -javaoption:-Dtest.concurrency=#
   84.43 + *
   84.44 + * If the property is not set the class will use a heuristic to determine the
   84.45 + * maximum number of threads that can be fired to execute a given test.
   84.46 + */
   84.47 +public abstract class JavacTestingAbstractThreadedTest {
   84.48 +
   84.49 +    protected static int getThreadPoolSize() {
   84.50 +        Integer testConc = Integer.getInteger("test.concurrency");
   84.51 +        if (testConc != null) return testConc;
   84.52 +        int cores = Runtime.getRuntime().availableProcessors();
   84.53 +        return Math.max(2, Math.min(8, cores / 2));
   84.54 +    }
   84.55 +
   84.56 +    protected static void checkAfterExec() throws InterruptedException {
   84.57 +        checkAfterExec(true);
   84.58 +    };
   84.59 +
   84.60 +    protected static boolean throwAssertionOnError = true;
   84.61 +
   84.62 +    protected static boolean printAll = false;
   84.63 +
   84.64 +    protected static StringWriter errSWriter = new StringWriter();
   84.65 +    protected static PrintWriter errWriter = new PrintWriter(errSWriter);
   84.66 +
   84.67 +    protected static StringWriter outSWriter = new StringWriter();
   84.68 +    protected static PrintWriter outWriter = new PrintWriter(outSWriter);
   84.69 +
   84.70 +    protected static void checkAfterExec(boolean printCheckCount)
   84.71 +            throws InterruptedException {
   84.72 +        pool.shutdown();
   84.73 +        while (!pool.isTerminated()) {
   84.74 +            Thread.sleep(10);
   84.75 +        }
   84.76 +        if (errCount.get() > 0) {
   84.77 +            if (throwAssertionOnError) {
   84.78 +                closePrinters();
   84.79 +                System.err.println(errSWriter.toString());
   84.80 +                throw new AssertionError(
   84.81 +                    String.format("%d errors found", errCount.get()));
   84.82 +            } else {
   84.83 +                System.err.println(
   84.84 +                        String.format("%d errors found", errCount.get()));
   84.85 +            }
   84.86 +        } else if (printCheckCount) {
   84.87 +            outWriter.println("Total check executed: " + checkCount.get());
   84.88 +        }
   84.89 +        closePrinters();
   84.90 +        if (printAll) {
   84.91 +            System.out.println(errSWriter.toString());
   84.92 +            System.out.println(outSWriter.toString());
   84.93 +        }
   84.94 +    }
   84.95 +
   84.96 +    protected static void closePrinters() {
   84.97 +        errWriter.close();
   84.98 +        outWriter.close();
   84.99 +    }
  84.100 +
  84.101 +    protected static void processException(Throwable t) {
  84.102 +        errCount.incrementAndGet();
  84.103 +        t.printStackTrace(errWriter);
  84.104 +        pool.shutdown();
  84.105 +    }
  84.106 +
  84.107 +    //number of checks executed
  84.108 +    protected static AtomicInteger checkCount = new AtomicInteger();
  84.109 +
  84.110 +    //number of errors found while running combo tests
  84.111 +    protected static AtomicInteger errCount = new AtomicInteger();
  84.112 +
  84.113 +    //create default shared JavaCompiler - reused across multiple compilations
  84.114 +    protected static JavaCompiler comp = ToolProvider.getSystemJavaCompiler();
  84.115 +
  84.116 +    protected static ExecutorService pool = Executors.newFixedThreadPool(
  84.117 +            getThreadPoolSize(), new ThreadFactory() {
  84.118 +        @Override
  84.119 +        public Thread newThread(Runnable r) {
  84.120 +            Thread t = new Thread(r);
  84.121 +            t.setUncaughtExceptionHandler(new Thread.UncaughtExceptionHandler() {
  84.122 +                @Override
  84.123 +                public void uncaughtException(Thread t, Throwable e) {
  84.124 +                    pool.shutdown();
  84.125 +                    errCount.incrementAndGet();
  84.126 +                    e.printStackTrace(System.err);
  84.127 +                }
  84.128 +            });
  84.129 +            return t;
  84.130 +        }
  84.131 +    });
  84.132 +
  84.133 +    /*
  84.134 +     * File manager is not thread-safe so it cannot be re-used across multiple
  84.135 +     * threads. However we cache per-thread FileManager to avoid excessive
  84.136 +     * object creation
  84.137 +     */
  84.138 +    protected static final ThreadLocal<StandardJavaFileManager> fm =
  84.139 +        new ThreadLocal<StandardJavaFileManager>() {
  84.140 +            @Override protected StandardJavaFileManager initialValue() {
  84.141 +                return comp.getStandardFileManager(null, null, null);
  84.142 +            }
  84.143 +        };
  84.144 +
  84.145 +}
    85.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
    85.2 +++ b/test/tools/javac/main/Option_J_At_Test.java	Thu Jan 10 15:53:02 2013 -0800
    85.3 @@ -0,0 +1,70 @@
    85.4 +
    85.5 +import java.io.PrintWriter;
    85.6 +import java.io.StringWriter;
    85.7 +
    85.8 +/*
    85.9 + * Copyright (c) 2013, Oracle and/or its affiliates. All rights reserved.
   85.10 + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
   85.11 + *
   85.12 + * This code is free software; you can redistribute it and/or modify it
   85.13 + * under the terms of the GNU General Public License version 2 only, as
   85.14 + * published by the Free Software Foundation.
   85.15 + *
   85.16 + * This code is distributed in the hope that it will be useful, but WITHOUT
   85.17 + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
   85.18 + * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
   85.19 + * version 2 for more details (a copy is included in the LICENSE file that
   85.20 + * accompanied this code).
   85.21 + *
   85.22 + * You should have received a copy of the GNU General Public License version
   85.23 + * 2 along with this work; if not, write to the Free Software Foundation,
   85.24 + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
   85.25 + *
   85.26 + * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
   85.27 + * or visit www.oracle.com if you need additional information or have any
   85.28 + * questions.
   85.29 + */
   85.30 +
   85.31 +/*
   85.32 + * @test
   85.33 + * @bug 8006037
   85.34 + * @summary extra space in javac -help for -J and @ options
   85.35 + */
   85.36 +
   85.37 +public class Option_J_At_Test {
   85.38 +    public static void main(String... args) throws Exception {
   85.39 +        new Option_J_At_Test().run();
   85.40 +    }
   85.41 +
   85.42 +    void run() throws Exception {
   85.43 +        StringWriter sw = new StringWriter();
   85.44 +        PrintWriter pw = new PrintWriter(sw);
   85.45 +        String[] help = { "-help" };
   85.46 +        int rc = com.sun.tools.javac.Main.compile(help, pw);
   85.47 +        pw.flush();
   85.48 +        String out = sw.toString();
   85.49 +        System.out.println(out);
   85.50 +        check(out, "-J<flag>",     true);
   85.51 +        check(out, "-J <flag>",    false);
   85.52 +        check(out, "@<filename>",  true);
   85.53 +        check(out, "@ <filename>", false);
   85.54 +        if (errors > 0)
   85.55 +            throw new Exception(errors + " errors found");
   85.56 +    }
   85.57 +
   85.58 +    void check(String out, String text, boolean expect) {
   85.59 +        if (out.contains(text) != expect) {
   85.60 +            if (expect)
   85.61 +                error("expected string not found: " + text);
   85.62 +            else
   85.63 +                error("unexpected string found: " + text);
   85.64 +        }
   85.65 +    }
   85.66 +
   85.67 +    void error(String msg) {
   85.68 +        System.err.println("Error: " + msg);
   85.69 +        errors++;
   85.70 +    }
   85.71 +
   85.72 +    int errors;
   85.73 +}
    86.1 --- a/test/tools/javac/multicatch/7030606/DisjunctiveTypeWellFormednessTest.java	Thu Jan 10 09:56:09 2013 -0800
    86.2 +++ b/test/tools/javac/multicatch/7030606/DisjunctiveTypeWellFormednessTest.java	Thu Jan 10 15:53:02 2013 -0800
    86.3 @@ -1,5 +1,5 @@
    86.4  /*
    86.5 - * Copyright (c) 2011, Oracle and/or its affiliates. All rights reserved.
    86.6 + * Copyright (c) 2011, 2013, Oracle and/or its affiliates. All rights reserved.
    86.7   * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
    86.8   *
    86.9   * This code is free software; you can redistribute it and/or modify it
   86.10 @@ -25,19 +25,21 @@
   86.11   * @test
   86.12   * @bug 7030606
   86.13   * @summary Project-coin: multi-catch types should be pairwise disjoint
   86.14 + * @library ../../lib
   86.15 + * @build JavacTestingAbstractThreadedTest
   86.16 + * @run main DisjunctiveTypeWellFormednessTest
   86.17   */
   86.18  
   86.19 -import com.sun.source.util.JavacTask;
   86.20  import java.net.URI;
   86.21  import java.util.Arrays;
   86.22  import javax.tools.Diagnostic;
   86.23 -import javax.tools.JavaCompiler;
   86.24  import javax.tools.JavaFileObject;
   86.25  import javax.tools.SimpleJavaFileObject;
   86.26 -import javax.tools.StandardJavaFileManager;
   86.27 -import javax.tools.ToolProvider;
   86.28 +import com.sun.source.util.JavacTask;
   86.29  
   86.30 -public class DisjunctiveTypeWellFormednessTest {
   86.31 +public class DisjunctiveTypeWellFormednessTest
   86.32 +    extends JavacTestingAbstractThreadedTest
   86.33 +    implements Runnable {
   86.34  
   86.35      enum Alternative {
   86.36          EXCEPTION("Exception"),
   86.37 @@ -92,40 +94,37 @@
   86.38      }
   86.39  
   86.40      public static void main(String... args) throws Exception {
   86.41 -
   86.42 -        //create default shared JavaCompiler - reused across multiple compilations
   86.43 -        JavaCompiler comp = ToolProvider.getSystemJavaCompiler();
   86.44 -        StandardJavaFileManager fm = comp.getStandardFileManager(null, null, null);
   86.45 -
   86.46          for (Arity arity : Arity.values()) {
   86.47              for (Alternative a1 : Alternative.values()) {
   86.48                  if (arity == Arity.ONE) {
   86.49 -                    new DisjunctiveTypeWellFormednessTest(a1).run(comp, fm);
   86.50 +                    pool.execute(new DisjunctiveTypeWellFormednessTest(a1));
   86.51                      continue;
   86.52                  }
   86.53                  for (Alternative a2 : Alternative.values()) {
   86.54                      if (arity == Arity.TWO) {
   86.55 -                        new DisjunctiveTypeWellFormednessTest(a1, a2).run(comp, fm);
   86.56 +                        pool.execute(new DisjunctiveTypeWellFormednessTest(a1, a2));
   86.57                          continue;
   86.58                      }
   86.59                      for (Alternative a3 : Alternative.values()) {
   86.60                          if (arity == Arity.THREE) {
   86.61 -                            new DisjunctiveTypeWellFormednessTest(a1, a2, a3).run(comp, fm);
   86.62 +                            pool.execute(new DisjunctiveTypeWellFormednessTest(a1, a2, a3));
   86.63                              continue;
   86.64                          }
   86.65                          for (Alternative a4 : Alternative.values()) {
   86.66                              if (arity == Arity.FOUR) {
   86.67 -                                new DisjunctiveTypeWellFormednessTest(a1, a2, a3, a4).run(comp, fm);
   86.68 +                                pool.execute(new DisjunctiveTypeWellFormednessTest(a1, a2, a3, a4));
   86.69                                  continue;
   86.70                              }
   86.71                              for (Alternative a5 : Alternative.values()) {
   86.72 -                                new DisjunctiveTypeWellFormednessTest(a1, a2, a3, a4, a5).run(comp, fm);
   86.73 +                                pool.execute(new DisjunctiveTypeWellFormednessTest(a1, a2, a3, a4, a5));
   86.74                              }
   86.75                          }
   86.76                      }
   86.77                  }
   86.78              }
   86.79          }
   86.80 +
   86.81 +        checkAfterExec(false);
   86.82      }
   86.83  
   86.84      Alternative[] alternatives;
   86.85 @@ -159,10 +158,16 @@
   86.86          }
   86.87      }
   86.88  
   86.89 -    void run(JavaCompiler tool, StandardJavaFileManager fm) throws Exception {
   86.90 -        JavacTask ct = (JavacTask)tool.getTask(null, fm, diagChecker,
   86.91 +    @Override
   86.92 +    public void run() {
   86.93 +        JavacTask ct = (JavacTask)comp.getTask(null, fm.get(), diagChecker,
   86.94                  null, null, Arrays.asList(source));
   86.95 -        ct.analyze();
   86.96 +        try {
   86.97 +            ct.analyze();
   86.98 +        } catch (Throwable t) {
   86.99 +            processException(t);
  86.100 +            return;
  86.101 +        }
  86.102          check();
  86.103      }
  86.104  
  86.105 @@ -202,4 +207,5 @@
  86.106              }
  86.107          }
  86.108      }
  86.109 +
  86.110  }
    87.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
    87.2 +++ b/test/tools/javac/tree/PrettySimpleStringTest.java	Thu Jan 10 15:53:02 2013 -0800
    87.3 @@ -0,0 +1,73 @@
    87.4 +/*
    87.5 + * Copyright (c) 2013, Oracle and/or its affiliates. All rights reserved.
    87.6 + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
    87.7 + *
    87.8 + * This code is free software; you can redistribute it and/or modify it
    87.9 + * under the terms of the GNU General Public License version 2 only, as
   87.10 + * published by the Free Software Foundation.
   87.11 + *
   87.12 + * This code is distributed in the hope that it will be useful, but WITHOUT
   87.13 + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
   87.14 + * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
   87.15 + * version 2 for more details (a copy is included in the LICENSE file that
   87.16 + * accompanied this code).
   87.17 + *
   87.18 + * You should have received a copy of the GNU General Public License version
   87.19 + * 2 along with this work; if not, write to the Free Software Foundation,
   87.20 + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
   87.21 + *
   87.22 + * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
   87.23 + * or visit www.oracle.com if you need additional information or have any
   87.24 + * questions.
   87.25 + */
   87.26 +
   87.27 +/*
   87.28 + * @test
   87.29 + * @bug 8006033
   87.30 + * @summary bug in Pretty.toSimpleString
   87.31 + */
   87.32 +
   87.33 +import java.io.File;
   87.34 +
   87.35 +import javax.tools.StandardJavaFileManager;
   87.36 +
   87.37 +import com.sun.source.tree.CompilationUnitTree;
   87.38 +import com.sun.source.util.JavacTask;
   87.39 +import com.sun.tools.javac.api.JavacTool;
   87.40 +import com.sun.tools.javac.tree.JCTree;
   87.41 +import com.sun.tools.javac.tree.Pretty;
   87.42 +
   87.43 +public class PrettySimpleStringTest {
   87.44 +    public static void main(String... args) throws Exception {
   87.45 +        new PrettySimpleStringTest().run();
   87.46 +    }
   87.47 +
   87.48 +    void run() throws Exception {
   87.49 +        File testSrc = new File(System.getProperty("test.src"));
   87.50 +        File thisFile = new File(testSrc, getClass().getName() + ".java");
   87.51 +        JavacTool tool = JavacTool.create();
   87.52 +        StandardJavaFileManager fm = tool.getStandardFileManager(null, null, null);
   87.53 +        JavacTask task = tool.getTask(null, fm, null, null, null,
   87.54 +                fm.getJavaFileObjects(thisFile));
   87.55 +        Iterable<? extends CompilationUnitTree> trees = task.parse();
   87.56 +        CompilationUnitTree thisTree = trees.iterator().next();
   87.57 +
   87.58 +        {   // test default
   87.59 +            String thisSrc = Pretty.toSimpleString((JCTree) thisTree);
   87.60 +            System.err.println(thisSrc);
   87.61 +            String expect = "import jav[...]} } }";
   87.62 +            if (!thisSrc.equals(expect)) {
   87.63 +                throw new Exception("unexpected result");
   87.64 +            }
   87.65 +        }
   87.66 +
   87.67 +        {   // test explicit length
   87.68 +            String thisSrc = Pretty.toSimpleString((JCTree) thisTree, 32);
   87.69 +            System.err.println(thisSrc);
   87.70 +            String expect = "import java.io.Fil[...]; } } } }";
   87.71 +            if (!thisSrc.equals(expect)) {
   87.72 +                throw new Exception("unexpected result");
   87.73 +            }
   87.74 +        }
   87.75 +    }
   87.76 +}
    88.1 --- a/test/tools/javac/varargs/7042566/T7042566.java	Thu Jan 10 09:56:09 2013 -0800
    88.2 +++ b/test/tools/javac/varargs/7042566/T7042566.java	Thu Jan 10 15:53:02 2013 -0800
    88.3 @@ -1,5 +1,5 @@
    88.4  /*
    88.5 - * Copyright (c) 2011, Oracle and/or its affiliates. All rights reserved.
    88.6 + * Copyright (c) 2011, 2013, Oracle and/or its affiliates. All rights reserved.
    88.7   * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
    88.8   *
    88.9   * This code is free software; you can redistribute it and/or modify it
   88.10 @@ -25,8 +25,22 @@
   88.11   * @test
   88.12   * @bug 7042566
   88.13   * @summary Unambiguous varargs method calls flagged as ambiguous
   88.14 + * @library ../../lib
   88.15 + * @build JavacTestingAbstractThreadedTest
   88.16 + * @run main T7042566
   88.17   */
   88.18  
   88.19 +import java.io.File;
   88.20 +import java.net.URI;
   88.21 +import java.util.Arrays;
   88.22 +import java.util.Locale;
   88.23 +import java.util.concurrent.atomic.AtomicInteger;
   88.24 +import javax.tools.Diagnostic;
   88.25 +import javax.tools.JavaCompiler;
   88.26 +import javax.tools.JavaFileObject;
   88.27 +import javax.tools.SimpleJavaFileObject;
   88.28 +import javax.tools.ToolProvider;
   88.29 +
   88.30  import com.sun.source.util.JavacTask;
   88.31  import com.sun.tools.classfile.Instruction;
   88.32  import com.sun.tools.classfile.Attribute;
   88.33 @@ -34,44 +48,36 @@
   88.34  import com.sun.tools.classfile.Code_attribute;
   88.35  import com.sun.tools.classfile.ConstantPool.*;
   88.36  import com.sun.tools.classfile.Method;
   88.37 -import com.sun.tools.javac.api.JavacTool;
   88.38  import com.sun.tools.javac.util.List;
   88.39  
   88.40 -import java.io.File;
   88.41 -import java.net.URI;
   88.42 -import java.util.Arrays;
   88.43 -import java.util.Locale;
   88.44 -import javax.tools.Diagnostic;
   88.45 -import javax.tools.JavaCompiler;
   88.46 -import javax.tools.JavaFileObject;
   88.47 -import javax.tools.SimpleJavaFileObject;
   88.48 -import javax.tools.StandardJavaFileManager;
   88.49 -import javax.tools.ToolProvider;
   88.50 -
   88.51 -public class T7042566 {
   88.52 +public class T7042566
   88.53 +    extends JavacTestingAbstractThreadedTest
   88.54 +    implements Runnable {
   88.55  
   88.56      VarargsMethod m1;
   88.57      VarargsMethod m2;
   88.58      TypeConfiguration actuals;
   88.59  
   88.60 -    T7042566(TypeConfiguration m1_conf, TypeConfiguration m2_conf, TypeConfiguration actuals) {
   88.61 +    T7042566(TypeConfiguration m1_conf, TypeConfiguration m2_conf,
   88.62 +            TypeConfiguration actuals) {
   88.63          this.m1 = new VarargsMethod(m1_conf);
   88.64          this.m2 = new VarargsMethod(m2_conf);
   88.65          this.actuals = actuals;
   88.66      }
   88.67  
   88.68 -    void compileAndCheck() throws Exception {
   88.69 +    @Override
   88.70 +    public void run() {
   88.71 +        int id = checkCount.incrementAndGet();
   88.72          final JavaCompiler tool = ToolProvider.getSystemJavaCompiler();
   88.73 -        JavaSource source = new JavaSource();
   88.74 +        JavaSource source = new JavaSource(id);
   88.75          ErrorChecker ec = new ErrorChecker();
   88.76 -        JavacTask ct = (JavacTask)tool.getTask(null, fm, ec,
   88.77 +        JavacTask ct = (JavacTask)tool.getTask(null, fm.get(), ec,
   88.78                  null, null, Arrays.asList(source));
   88.79          ct.call();
   88.80 -        check(source, ec);
   88.81 +        check(source, ec, id);
   88.82      }
   88.83  
   88.84 -    void check(JavaSource source, ErrorChecker ec) {
   88.85 -        checkCount++;
   88.86 +    void check(JavaSource source, ErrorChecker ec, int id) {
   88.87          boolean resolutionError = false;
   88.88          VarargsMethod selectedMethod = null;
   88.89  
   88.90 @@ -99,13 +105,13 @@
   88.91                      "\nFound error: " + ec.errorFound +
   88.92                      "\nCompiler diagnostics:\n" + ec.printDiags());
   88.93          } else if (!resolutionError) {
   88.94 -            verifyBytecode(selectedMethod, source);
   88.95 +            verifyBytecode(selectedMethod, source, id);
   88.96          }
   88.97      }
   88.98  
   88.99 -    void verifyBytecode(VarargsMethod selected, JavaSource source) {
  88.100 -        bytecodeCheckCount++;
  88.101 -        File compiledTest = new File("Test.class");
  88.102 +    void verifyBytecode(VarargsMethod selected, JavaSource source, int id) {
  88.103 +        bytecodeCheckCount.incrementAndGet();
  88.104 +        File compiledTest = new File(String.format("Test%d.class", id));
  88.105          try {
  88.106              ClassFile cf = ClassFile.read(compiledTest);
  88.107              Method testMethod = null;
  88.108 @@ -118,7 +124,8 @@
  88.109              if (testMethod == null) {
  88.110                  throw new Error("Test method not found");
  88.111              }
  88.112 -            Code_attribute ea = (Code_attribute)testMethod.attributes.get(Attribute.Code);
  88.113 +            Code_attribute ea =
  88.114 +                (Code_attribute)testMethod.attributes.get(Attribute.Code);
  88.115              if (testMethod == null) {
  88.116                  throw new Error("Code attribute for test() method not found");
  88.117              }
  88.118 @@ -127,11 +134,12 @@
  88.119                  if (i.getMnemonic().equals("invokevirtual")) {
  88.120                      int cp_entry = i.getUnsignedShort(1);
  88.121                      CONSTANT_Methodref_info methRef =
  88.122 -                            (CONSTANT_Methodref_info)cf.constant_pool.get(cp_entry);
  88.123 +                        (CONSTANT_Methodref_info)cf.constant_pool.get(cp_entry);
  88.124                      String type = methRef.getNameAndTypeInfo().getType();
  88.125                      String sig = selected.parameterTypes.bytecodeSigStr;
  88.126                      if (!type.contains(sig)) {
  88.127 -                        throw new Error("Unexpected type method call: " + type + "" +
  88.128 +                        throw new Error("Unexpected type method call: " +
  88.129 +                                        type + "" +
  88.130                                          "\nfound: " + sig +
  88.131                                          "\n" + source.getCharContent(true));
  88.132                      }
  88.133 @@ -146,7 +154,7 @@
  88.134  
  88.135      class JavaSource extends SimpleJavaFileObject {
  88.136  
  88.137 -        static final String source_template = "class Test {\n" +
  88.138 +        static final String source_template = "class Test#ID {\n" +
  88.139                  "   #V1\n" +
  88.140                  "   #V2\n" +
  88.141                  "   void test() { m(#E); }\n" +
  88.142 @@ -154,11 +162,13 @@
  88.143  
  88.144          String source;
  88.145  
  88.146 -        public JavaSource() {
  88.147 -            super(URI.create("myfo:/Test.java"), JavaFileObject.Kind.SOURCE);
  88.148 -            source = source_template.replaceAll("#V1", m1.toString()).
  88.149 -                    replaceAll("#V2", m2.toString()).
  88.150 -                    replaceAll("#E", actuals.expressionListStr);
  88.151 +        public JavaSource(int id) {
  88.152 +            super(URI.create(String.format("myfo:/Test%d.java", id)),
  88.153 +                    JavaFileObject.Kind.SOURCE);
  88.154 +            source = source_template.replaceAll("#V1", m1.toString())
  88.155 +                    .replaceAll("#V2", m2.toString())
  88.156 +                    .replaceAll("#E", actuals.expressionListStr)
  88.157 +                    .replaceAll("#ID", String.valueOf(id));
  88.158          }
  88.159  
  88.160          @Override
  88.161 @@ -167,26 +177,17 @@
  88.162          }
  88.163      }
  88.164  
  88.165 -    /** global decls ***/
  88.166 -
  88.167 -    // Create a single file manager and reuse it for each compile to save time.
  88.168 -    static StandardJavaFileManager fm = JavacTool.create().getStandardFileManager(null, null, null);
  88.169 -
  88.170 -    //statistics
  88.171 -    static int checkCount = 0;
  88.172 -    static int bytecodeCheckCount = 0;
  88.173 -
  88.174      public static void main(String... args) throws Exception {
  88.175          for (TypeConfiguration tconf1 : TypeConfiguration.values()) {
  88.176              for (TypeConfiguration tconf2 : TypeConfiguration.values()) {
  88.177                  for (TypeConfiguration tconf3 : TypeConfiguration.values()) {
  88.178 -                    new T7042566(tconf1, tconf2, tconf3).compileAndCheck();
  88.179 +                    pool.execute(new T7042566(tconf1, tconf2, tconf3));
  88.180                  }
  88.181              }
  88.182          }
  88.183  
  88.184 -        System.out.println("Total checks made: " + checkCount);
  88.185 -        System.out.println("Bytecode checks made: " + bytecodeCheckCount);
  88.186 +        outWriter.println("Bytecode checks made: " + bytecodeCheckCount.get());
  88.187 +        checkAfterExec();
  88.188      }
  88.189  
  88.190      enum TypeKind {
  88.191 @@ -326,14 +327,16 @@
  88.192          }
  88.193      }
  88.194  
  88.195 -    static class ErrorChecker implements javax.tools.DiagnosticListener<JavaFileObject> {
  88.196 +    static class ErrorChecker
  88.197 +        implements javax.tools.DiagnosticListener<JavaFileObject> {
  88.198  
  88.199          boolean errorFound;
  88.200          List<String> errDiags = List.nil();
  88.201  
  88.202          public void report(Diagnostic<? extends JavaFileObject> diagnostic) {
  88.203              if (diagnostic.getKind() == Diagnostic.Kind.ERROR) {
  88.204 -                errDiags = errDiags.append(diagnostic.getMessage(Locale.getDefault()));
  88.205 +                errDiags = errDiags
  88.206 +                        .append(diagnostic.getMessage(Locale.getDefault()));
  88.207                  errorFound = true;
  88.208              }
  88.209          }
  88.210 @@ -347,4 +350,8 @@
  88.211              return buf.toString();
  88.212          }
  88.213      }
  88.214 +
  88.215 +    //number of bytecode checks made while running combo tests
  88.216 +    static AtomicInteger bytecodeCheckCount = new AtomicInteger();
  88.217 +
  88.218  }
    89.1 --- a/test/tools/javac/varargs/warning/Warn4.java	Thu Jan 10 09:56:09 2013 -0800
    89.2 +++ b/test/tools/javac/varargs/warning/Warn4.java	Thu Jan 10 15:53:02 2013 -0800
    89.3 @@ -1,5 +1,5 @@
    89.4  /*
    89.5 - * Copyright (c) 2010, 2011, Oracle and/or its affiliates. All rights reserved.
    89.6 + * Copyright (c) 2010, 2013, Oracle and/or its affiliates. All rights reserved.
    89.7   * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
    89.8   *
    89.9   * This code is free software; you can redistribute it and/or modify it
   89.10 @@ -26,10 +26,11 @@
   89.11   * @bug     6945418 6993978
   89.12   * @summary Project Coin: Simplified Varargs Method Invocation
   89.13   * @author  mcimadamore
   89.14 + * @library ../../lib
   89.15 + * @build JavacTestingAbstractThreadedTest
   89.16   * @run main Warn4
   89.17   */
   89.18 -import com.sun.source.util.JavacTask;
   89.19 -import com.sun.tools.javac.api.JavacTool;
   89.20 +
   89.21  import java.net.URI;
   89.22  import java.util.Arrays;
   89.23  import java.util.Set;
   89.24 @@ -38,16 +39,19 @@
   89.25  import javax.tools.JavaCompiler;
   89.26  import javax.tools.JavaFileObject;
   89.27  import javax.tools.SimpleJavaFileObject;
   89.28 -import javax.tools.StandardJavaFileManager;
   89.29  import javax.tools.ToolProvider;
   89.30 +import com.sun.source.util.JavacTask;
   89.31  
   89.32 -public class Warn4 {
   89.33 +public class Warn4
   89.34 +    extends JavacTestingAbstractThreadedTest
   89.35 +    implements Runnable {
   89.36  
   89.37      final static Warning[] error = null;
   89.38      final static Warning[] none = new Warning[] {};
   89.39      final static Warning[] vararg = new Warning[] { Warning.VARARGS };
   89.40      final static Warning[] unchecked = new Warning[] { Warning.UNCHECKED };
   89.41 -    final static Warning[] both = new Warning[] { Warning.VARARGS, Warning.UNCHECKED };
   89.42 +    final static Warning[] both =
   89.43 +            new Warning[] { Warning.VARARGS, Warning.UNCHECKED };
   89.44  
   89.45      enum Warning {
   89.46          UNCHECKED("generic.array.creation"),
   89.47 @@ -59,8 +63,10 @@
   89.48              this.key = key;
   89.49          }
   89.50  
   89.51 -        boolean isSuppressed(TrustMe trustMe, SourceLevel source, SuppressLevel suppressLevelClient,
   89.52 -                SuppressLevel suppressLevelDecl, ModifierKind modKind) {
   89.53 +        boolean isSuppressed(TrustMe trustMe, SourceLevel source,
   89.54 +                SuppressLevel suppressLevelClient,
   89.55 +                SuppressLevel suppressLevelDecl,
   89.56 +                ModifierKind modKind) {
   89.57              switch(this) {
   89.58                  case VARARGS:
   89.59                      return source == SourceLevel.JDK_6 ||
   89.60 @@ -68,7 +74,8 @@
   89.61                              trustMe == TrustMe.TRUST;
   89.62                  case UNCHECKED:
   89.63                      return suppressLevelClient == SuppressLevel.UNCHECKED ||
   89.64 -                        (trustMe == TrustMe.TRUST && modKind != ModifierKind.NONE && source == SourceLevel.JDK_7);
   89.65 +                        (trustMe == TrustMe.TRUST && modKind !=
   89.66 +                            ModifierKind.NONE && source == SourceLevel.JDK_7);
   89.67              }
   89.68  
   89.69              SuppressLevel supLev = this == VARARGS ?
   89.70 @@ -172,13 +179,13 @@
   89.71                              for (Signature vararg_meth : Signature.values()) {
   89.72                                  for (Signature client_meth : Signature.values()) {
   89.73                                      if (vararg_meth.isApplicableTo(client_meth)) {
   89.74 -                                        test(sourceLevel,
   89.75 +                                        pool.execute(new Warn4(sourceLevel,
   89.76                                                  trustMe,
   89.77                                                  suppressLevelClient,
   89.78                                                  suppressLevelDecl,
   89.79                                                  modKind,
   89.80                                                  vararg_meth,
   89.81 -                                                client_meth);
   89.82 +                                                client_meth));
   89.83                                      }
   89.84                                  }
   89.85                              }
   89.86 @@ -187,63 +194,82 @@
   89.87                  }
   89.88              }
   89.89          }
   89.90 +
   89.91 +        checkAfterExec();
   89.92      }
   89.93  
   89.94 -    // Create a single file manager and reuse it for each compile to save time.
   89.95 -    static StandardJavaFileManager fm = JavacTool.create().getStandardFileManager(null, null, null);
   89.96 +    SourceLevel sourceLevel;
   89.97 +    TrustMe trustMe;
   89.98 +    SuppressLevel suppressLevelClient;
   89.99 +    SuppressLevel suppressLevelDecl;
  89.100 +    ModifierKind modKind;
  89.101 +    Signature vararg_meth;
  89.102 +    Signature client_meth;
  89.103 +    DiagnosticChecker diagChecker;
  89.104  
  89.105 -    static void test(SourceLevel sourceLevel, TrustMe trustMe, SuppressLevel suppressLevelClient,
  89.106 -            SuppressLevel suppressLevelDecl, ModifierKind modKind, Signature vararg_meth, Signature client_meth) throws Exception {
  89.107 +    public Warn4(SourceLevel sourceLevel, TrustMe trustMe,
  89.108 +            SuppressLevel suppressLevelClient, SuppressLevel suppressLevelDecl,
  89.109 +            ModifierKind modKind, Signature vararg_meth, Signature client_meth) {
  89.110 +        this.sourceLevel = sourceLevel;
  89.111 +        this.trustMe = trustMe;
  89.112 +        this.suppressLevelClient = suppressLevelClient;
  89.113 +        this.suppressLevelDecl = suppressLevelDecl;
  89.114 +        this.modKind = modKind;
  89.115 +        this.vararg_meth = vararg_meth;
  89.116 +        this.client_meth = client_meth;
  89.117 +        this.diagChecker = new DiagnosticChecker();
  89.118 +    }
  89.119 +
  89.120 +    @Override
  89.121 +    public void run() {
  89.122 +        int id = checkCount.incrementAndGet();
  89.123          final JavaCompiler tool = ToolProvider.getSystemJavaCompiler();
  89.124 -        JavaSource source = new JavaSource(trustMe, suppressLevelClient, suppressLevelDecl, modKind, vararg_meth, client_meth);
  89.125 -        DiagnosticChecker dc = new DiagnosticChecker();
  89.126 -        JavacTask ct = (JavacTask)tool.getTask(null, fm, dc,
  89.127 +        JavaSource source = new JavaSource(id);
  89.128 +        JavacTask ct = (JavacTask)tool.getTask(null, fm.get(), diagChecker,
  89.129                  Arrays.asList("-Xlint:unchecked", "-source", sourceLevel.sourceKey),
  89.130                  null, Arrays.asList(source));
  89.131 -        ct.generate(); //to get mandatory notes
  89.132 -        check(dc.warnings, sourceLevel,
  89.133 -                new boolean[] {vararg_meth.giveUnchecked(client_meth),
  89.134 -                               vararg_meth.giveVarargs(client_meth)},
  89.135 -                source, trustMe, suppressLevelClient, suppressLevelDecl, modKind);
  89.136 +        ct.call(); //to get mandatory notes
  89.137 +        check(source, new boolean[] {vararg_meth.giveUnchecked(client_meth),
  89.138 +                               vararg_meth.giveVarargs(client_meth)});
  89.139      }
  89.140  
  89.141 -    static void check(Set<Warning> warnings, SourceLevel sourceLevel, boolean[] warnArr, JavaSource source,
  89.142 -            TrustMe trustMe, SuppressLevel suppressLevelClient, SuppressLevel suppressLevelDecl, ModifierKind modKind) {
  89.143 +    void check(JavaSource source, boolean[] warnArr) {
  89.144          boolean badOutput = false;
  89.145          for (Warning wkind : Warning.values()) {
  89.146              boolean isSuppressed = wkind.isSuppressed(trustMe, sourceLevel,
  89.147                      suppressLevelClient, suppressLevelDecl, modKind);
  89.148              System.out.println("SUPPRESSED = " + isSuppressed);
  89.149 -            badOutput |= (warnArr[wkind.ordinal()] && !isSuppressed) != warnings.contains(wkind);
  89.150 +            badOutput |= (warnArr[wkind.ordinal()] && !isSuppressed) !=
  89.151 +                    diagChecker.warnings.contains(wkind);
  89.152          }
  89.153          if (badOutput) {
  89.154              throw new Error("invalid diagnostics for source:\n" +
  89.155                      source.getCharContent(true) +
  89.156                      "\nExpected unchecked warning: " + warnArr[0] +
  89.157                      "\nExpected unsafe vararg warning: " + warnArr[1] +
  89.158 -                    "\nWarnings: " + warnings +
  89.159 +                    "\nWarnings: " + diagChecker.warnings +
  89.160                      "\nSource level: " + sourceLevel);
  89.161          }
  89.162      }
  89.163  
  89.164 -    static class JavaSource extends SimpleJavaFileObject {
  89.165 +    class JavaSource extends SimpleJavaFileObject {
  89.166  
  89.167          String source;
  89.168  
  89.169 -        public JavaSource(TrustMe trustMe, SuppressLevel suppressLevelClient, SuppressLevel suppressLevelDecl,
  89.170 -                ModifierKind modKind, Signature vararg_meth, Signature client_meth) {
  89.171 -            super(URI.create("myfo:/Test.java"), JavaFileObject.Kind.SOURCE);
  89.172 +        public JavaSource(int id) {
  89.173 +            super(URI.create(String.format("myfo:/Test%d.java", id)),
  89.174 +                    JavaFileObject.Kind.SOURCE);
  89.175              String meth1 = vararg_meth.template.replace("#arity", "...");
  89.176              meth1 = meth1.replace("#name", "m");
  89.177              meth1 = meth1.replace("#body", "");
  89.178 -            meth1 = trustMe.anno + "\n" + suppressLevelDecl.getSuppressAnno() + modKind.mod + meth1;
  89.179 +            meth1 = trustMe.anno + "\n" + suppressLevelDecl.getSuppressAnno() +
  89.180 +                    modKind.mod + meth1;
  89.181              String meth2 = client_meth.template.replace("#arity", "");
  89.182              meth2 = meth2.replace("#name", "test");
  89.183              meth2 = meth2.replace("#body", "m(arg);");
  89.184              meth2 = suppressLevelClient.getSuppressAnno() + meth2;
  89.185 -            source = "import java.util.List;\n" +
  89.186 -                     "class Test {\n" + meth1 +
  89.187 -                     "\n" + meth2 + "\n}\n";
  89.188 +            source = String.format("import java.util.List;\n" +
  89.189 +                     "class Test%s {\n %s \n %s \n } \n", id, meth1, meth2);
  89.190          }
  89.191  
  89.192          @Override
  89.193 @@ -252,7 +278,8 @@
  89.194          }
  89.195      }
  89.196  
  89.197 -    static class DiagnosticChecker implements javax.tools.DiagnosticListener<JavaFileObject> {
  89.198 +    static class DiagnosticChecker
  89.199 +        implements javax.tools.DiagnosticListener<JavaFileObject> {
  89.200  
  89.201          Set<Warning> warnings = new HashSet<>();
  89.202  
  89.203 @@ -267,4 +294,5 @@
  89.204              }
  89.205          }
  89.206      }
  89.207 +
  89.208  }
    90.1 --- a/test/tools/javac/varargs/warning/Warn5.java	Thu Jan 10 09:56:09 2013 -0800
    90.2 +++ b/test/tools/javac/varargs/warning/Warn5.java	Thu Jan 10 15:53:02 2013 -0800
    90.3 @@ -1,5 +1,5 @@
    90.4  /*
    90.5 - * Copyright (c) 2010, 2011, Oracle and/or its affiliates. All rights reserved.
    90.6 + * Copyright (c) 2010, 2013, Oracle and/or its affiliates. All rights reserved.
    90.7   * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
    90.8   *
    90.9   * This code is free software; you can redistribute it and/or modify it
   90.10 @@ -26,10 +26,10 @@
   90.11   * @bug     6993978 7097436
   90.12   * @summary Project Coin: Annotation to reduce varargs warnings
   90.13   * @author  mcimadamore
   90.14 + * @library ../../lib
   90.15 + * @build JavacTestingAbstractThreadedTest
   90.16   * @run main Warn5
   90.17   */
   90.18 -import com.sun.source.util.JavacTask;
   90.19 -import com.sun.tools.javac.api.JavacTool;
   90.20  import java.net.URI;
   90.21  import java.util.Arrays;
   90.22  import java.util.EnumSet;
   90.23 @@ -37,10 +37,12 @@
   90.24  import javax.tools.JavaCompiler;
   90.25  import javax.tools.JavaFileObject;
   90.26  import javax.tools.SimpleJavaFileObject;
   90.27 -import javax.tools.StandardJavaFileManager;
   90.28  import javax.tools.ToolProvider;
   90.29 +import com.sun.source.util.JavacTask;
   90.30  
   90.31 -public class Warn5 {
   90.32 +public class Warn5
   90.33 +    extends JavacTestingAbstractThreadedTest
   90.34 +    implements Runnable {
   90.35  
   90.36      enum XlintOption {
   90.37          NONE("none"),
   90.38 @@ -161,9 +163,6 @@
   90.39          REDUNDANT_SAFEVARARGS;
   90.40      }
   90.41  
   90.42 -    // Create a single file manager and reuse it for each compile to save time.
   90.43 -    static StandardJavaFileManager fm = JavacTool.create().getStandardFileManager(null, null, null);
   90.44 -
   90.45      public static void main(String... args) throws Exception {
   90.46          for (SourceLevel sourceLevel : SourceLevel.values()) {
   90.47              for (XlintOption xlint : XlintOption.values()) {
   90.48 @@ -173,14 +172,9 @@
   90.49                              for (MethodKind methKind : MethodKind.values()) {
   90.50                                  for (SignatureKind sig : SignatureKind.values()) {
   90.51                                      for (BodyKind body : BodyKind.values()) {
   90.52 -                                        new Warn5(sourceLevel,
   90.53 -                                                xlint,
   90.54 -                                                trustMe,
   90.55 -                                                suppressLevel,
   90.56 -                                                modKind,
   90.57 -                                                methKind,
   90.58 -                                                sig,
   90.59 -                                                body).test();
   90.60 +                                        pool.execute(new Warn5(sourceLevel,
   90.61 +                                                xlint, trustMe, suppressLevel,
   90.62 +                                                modKind, methKind, sig, body));
   90.63                                      }
   90.64                                  }
   90.65                              }
   90.66 @@ -189,6 +183,8 @@
   90.67                  }
   90.68              }
   90.69          }
   90.70 +
   90.71 +        checkAfterExec(false);
   90.72      }
   90.73  
   90.74      final SourceLevel sourceLevel;
   90.75 @@ -202,7 +198,9 @@
   90.76      final JavaSource source;
   90.77      final DiagnosticChecker dc;
   90.78  
   90.79 -    public Warn5(SourceLevel sourceLevel, XlintOption xlint, TrustMe trustMe, SuppressLevel suppressLevel, ModifierKind modKind, MethodKind methKind, SignatureKind sig, BodyKind body) {
   90.80 +    public Warn5(SourceLevel sourceLevel, XlintOption xlint, TrustMe trustMe,
   90.81 +            SuppressLevel suppressLevel, ModifierKind modKind,
   90.82 +            MethodKind methKind, SignatureKind sig, BodyKind body) {
   90.83          this.sourceLevel = sourceLevel;
   90.84          this.xlint = xlint;
   90.85          this.trustMe = trustMe;
   90.86 @@ -215,24 +213,36 @@
   90.87          this.dc = new DiagnosticChecker();
   90.88      }
   90.89  
   90.90 -    void test() throws Exception {
   90.91 +    @Override
   90.92 +    public void run() {
   90.93          final JavaCompiler tool = ToolProvider.getSystemJavaCompiler();
   90.94 -        JavacTask ct = (JavacTask)tool.getTask(null, fm, dc,
   90.95 -                Arrays.asList(xlint.getXlintOption(), "-source", sourceLevel.sourceKey), null, Arrays.asList(source));
   90.96 -        ct.analyze();
   90.97 +        JavacTask ct = (JavacTask)tool.getTask(null, fm.get(), dc,
   90.98 +                Arrays.asList(xlint.getXlintOption(),
   90.99 +                    "-source", sourceLevel.sourceKey),
  90.100 +                null, Arrays.asList(source));
  90.101 +        try {
  90.102 +            ct.analyze();
  90.103 +        } catch (Throwable t) {
  90.104 +            processException(t);
  90.105 +        }
  90.106          check();
  90.107      }
  90.108  
  90.109      void check() {
  90.110  
  90.111 -        EnumSet<WarningKind> expectedWarnings = EnumSet.noneOf(WarningKind.class);
  90.112 +        EnumSet<WarningKind> expectedWarnings =
  90.113 +                EnumSet.noneOf(WarningKind.class);
  90.114  
  90.115          if (sourceLevel == SourceLevel.JDK_7 &&
  90.116                  trustMe == TrustMe.TRUST &&
  90.117                  suppressLevel != SuppressLevel.VARARGS &&
  90.118                  xlint != XlintOption.NONE &&
  90.119 -                sig.isVarargs && !sig.isReifiableArg && body.hasAliasing &&
  90.120 -                (methKind == MethodKind.CONSTRUCTOR || (methKind == MethodKind.METHOD && modKind != ModifierKind.NONE))) {
  90.121 +                sig.isVarargs &&
  90.122 +                !sig.isReifiableArg &&
  90.123 +                body.hasAliasing &&
  90.124 +                (methKind == MethodKind.CONSTRUCTOR ||
  90.125 +                (methKind == MethodKind.METHOD &&
  90.126 +                modKind != ModifierKind.NONE))) {
  90.127              expectedWarnings.add(WarningKind.UNSAFE_BODY);
  90.128          }
  90.129  
  90.130 @@ -247,7 +257,8 @@
  90.131          if (sourceLevel == SourceLevel.JDK_7 &&
  90.132                  trustMe == TrustMe.TRUST &&
  90.133                  (!sig.isVarargs ||
  90.134 -                (modKind == ModifierKind.NONE && methKind == MethodKind.METHOD))) {
  90.135 +                (modKind == ModifierKind.NONE &&
  90.136 +                methKind == MethodKind.METHOD))) {
  90.137              expectedWarnings.add(WarningKind.MALFORMED_SAFEVARARGS);
  90.138          }
  90.139  
  90.140 @@ -255,7 +266,8 @@
  90.141                  trustMe == TrustMe.TRUST &&
  90.142                  xlint != XlintOption.NONE &&
  90.143                  suppressLevel != SuppressLevel.VARARGS &&
  90.144 -                (modKind != ModifierKind.NONE || methKind == MethodKind.CONSTRUCTOR) &&
  90.145 +                (modKind != ModifierKind.NONE ||
  90.146 +                methKind == MethodKind.CONSTRUCTOR) &&
  90.147                  sig.isVarargs &&
  90.148                  sig.isReifiableArg) {
  90.149              expectedWarnings.add(WarningKind.REDUNDANT_SAFEVARARGS);
  90.150 @@ -297,19 +309,23 @@
  90.151          }
  90.152      }
  90.153  
  90.154 -    class DiagnosticChecker implements javax.tools.DiagnosticListener<JavaFileObject> {
  90.155 +    class DiagnosticChecker
  90.156 +        implements javax.tools.DiagnosticListener<JavaFileObject> {
  90.157  
  90.158          EnumSet<WarningKind> warnings = EnumSet.noneOf(WarningKind.class);
  90.159  
  90.160          public void report(Diagnostic<? extends JavaFileObject> diagnostic) {
  90.161              if (diagnostic.getKind() == Diagnostic.Kind.WARNING) {
  90.162 -                    if (diagnostic.getCode().contains("unsafe.use.varargs.param")) {
  90.163 +                    if (diagnostic.getCode().
  90.164 +                            contains("unsafe.use.varargs.param")) {
  90.165                          setWarning(WarningKind.UNSAFE_BODY);
  90.166 -                    } else if (diagnostic.getCode().contains("redundant.trustme")) {
  90.167 +                    } else if (diagnostic.getCode().
  90.168 +                            contains("redundant.trustme")) {
  90.169                          setWarning(WarningKind.REDUNDANT_SAFEVARARGS);
  90.170                      }
  90.171              } else if (diagnostic.getKind() == Diagnostic.Kind.MANDATORY_WARNING &&
  90.172 -                    diagnostic.getCode().contains("varargs.non.reifiable.type")) {
  90.173 +                    diagnostic.getCode().
  90.174 +                        contains("varargs.non.reifiable.type")) {
  90.175                  setWarning(WarningKind.UNSAFE_DECL);
  90.176              } else if (diagnostic.getKind() == Diagnostic.Kind.ERROR &&
  90.177                      diagnostic.getCode().contains("invalid.trustme")) {
  90.178 @@ -319,7 +335,8 @@
  90.179  
  90.180          void setWarning(WarningKind wk) {
  90.181              if (!warnings.add(wk)) {
  90.182 -                throw new AssertionError("Duplicate warning of kind " + wk + " in source:\n" + source);
  90.183 +                throw new AssertionError("Duplicate warning of kind " +
  90.184 +                        wk + " in source:\n" + source);
  90.185              }
  90.186          }
  90.187  
  90.188 @@ -327,4 +344,5 @@
  90.189              return warnings.contains(wk);
  90.190          }
  90.191      }
  90.192 +
  90.193  }
    91.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
    91.2 +++ b/test/tools/javadoc/MaxWarns.java	Thu Jan 10 15:53:02 2013 -0800
    91.3 @@ -0,0 +1,112 @@
    91.4 +/*
    91.5 + * Copyright (c) 2013, Oracle and/or its affiliates. All rights reserved.
    91.6 + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
    91.7 + *
    91.8 + * This code is free software; you can redistribute it and/or modify it
    91.9 + * under the terms of the GNU General Public License version 2 only, as
   91.10 + * published by the Free Software Foundation.
   91.11 + *
   91.12 + * This code is distributed in the hope that it will be useful, but WITHOUT
   91.13 + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
   91.14 + * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
   91.15 + * version 2 for more details (a copy is included in the LICENSE file that
   91.16 + * accompanied this code).
   91.17 + *
   91.18 + * You should have received a copy of the GNU General Public License version
   91.19 + * 2 along with this work; if not, write to the Free Software Foundation,
   91.20 + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
   91.21 + *
   91.22 + * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
   91.23 + * or visit www.oracle.com if you need additional information or have any
   91.24 + * questions.
   91.25 + */
   91.26 +
   91.27 +/*
   91.28 + * @test
   91.29 + * @bug 8005644
   91.30 + * @summary set default max errs and max warns
   91.31 + */
   91.32 +
   91.33 +import java.io.File;
   91.34 +import java.io.FileWriter;
   91.35 +import java.io.IOException;
   91.36 +import java.io.PrintWriter;
   91.37 +import java.io.StringWriter;
   91.38 +import java.util.regex.Matcher;
   91.39 +import java.util.regex.Pattern;
   91.40 +
   91.41 +
   91.42 +public class MaxWarns {
   91.43 +    public static void main(String... args) throws Exception {
   91.44 +        new MaxWarns().run();
   91.45 +    }
   91.46 +
   91.47 +    void run() throws Exception {
   91.48 +        final int defaultMaxWarns = 100;
   91.49 +        final int genWarns = 150;
   91.50 +        File f = genSrc(genWarns);
   91.51 +        String out = javadoc(f);
   91.52 +        check(out, defaultMaxWarns);
   91.53 +
   91.54 +        if (errors > 0)
   91.55 +            throw new Exception(errors + " errors occurred");
   91.56 +    }
   91.57 +
   91.58 +    File genSrc(int count) throws IOException {
   91.59 +        StringBuilder sb = new StringBuilder();
   91.60 +        sb.append("package p;\n")
   91.61 +            .append("public class C {\n")
   91.62 +            .append("    /**\n");
   91.63 +        for (int i = 0; i < count; i++)
   91.64 +            sb.append("     * @param i").append(i).append(" does not exist!\n");
   91.65 +        sb.append("     */\n")
   91.66 +            .append("    public void m() { }\n")
   91.67 +            .append("}\n");
   91.68 +        File srcDir = new File("src");
   91.69 +        srcDir.mkdirs();
   91.70 +        File f = new File(srcDir, "C.java");
   91.71 +        try (FileWriter fw = new FileWriter(f)) {
   91.72 +            fw.write(sb.toString());
   91.73 +        }
   91.74 +        return f;
   91.75 +    }
   91.76 +
   91.77 +    String javadoc(File f) {
   91.78 +        StringWriter sw = new StringWriter();
   91.79 +        PrintWriter pw = new PrintWriter(sw);
   91.80 +        String[] args = { "-d", "api", f.getPath() };
   91.81 +        int rc = com.sun.tools.javadoc.Main.execute("javadoc", pw, pw, pw,
   91.82 +                com.sun.tools.doclets.standard.Standard.class.getName(), args);
   91.83 +        pw.flush();
   91.84 +        return sw.toString();
   91.85 +    }
   91.86 +
   91.87 +    void check(String out, int count) {
   91.88 +        System.err.println(out);
   91.89 +        Pattern warn = Pattern.compile("warning - @param argument \"i[0-9]+\" is not a parameter name");
   91.90 +        Matcher m = warn.matcher(out);
   91.91 +        int n = 0;
   91.92 +        for (int start = 0; m.find(start); start = m.start() + 1) {
   91.93 +            n++;
   91.94 +        }
   91.95 +        if (n != count)
   91.96 +            error("unexpected number of warnings reported: " + n + "; expected: " + count);
   91.97 +
   91.98 +        Pattern warnCount = Pattern.compile("(?ms).*^([0-9]+) warnings$.*");
   91.99 +        m = warnCount.matcher(out);
  91.100 +        if (m.matches()) {
  91.101 +            n = Integer.parseInt(m.group(1));
  91.102 +            if (n != count)
  91.103 +                error("unexpected number of warnings reported: " + n + "; expected: " + count);
  91.104 +        } else
  91.105 +            error("total count not found");
  91.106 +    }
  91.107 +
  91.108 +    void error(String msg) {
  91.109 +        System.err.println("Error: " + msg);
  91.110 +        errors++;
  91.111 +    }
  91.112 +
  91.113 +    int errors;
  91.114 +}
  91.115 +
    92.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
    92.2 +++ b/test/tools/javap/MethodParameters.java	Thu Jan 10 15:53:02 2013 -0800
    92.3 @@ -0,0 +1,166 @@
    92.4 +/*
    92.5 + * Copyright (c) 2010, 2012, Oracle and/or its affiliates. All rights reserved.
    92.6 + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
    92.7 + *
    92.8 + * This code is free software; you can redistribute it and/or modify it
    92.9 + * under the terms of the GNU General Public License version 2 only, as
   92.10 + * published by the Free Software Foundation.
   92.11 + *
   92.12 + * This code is distributed in the hope that it will be useful, but WITHOUT
   92.13 + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
   92.14 + * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
   92.15 + * version 2 for more details (a copy is included in the LICENSE file that
   92.16 + * accompanied this code).
   92.17 + *
   92.18 + * You should have received a copy of the GNU General Public License version
   92.19 + * 2 along with this work; if not, write to the Free Software Foundation,
   92.20 + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
   92.21 + *
   92.22 + * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
   92.23 + * or visit www.oracle.com if you need additional information or have any
   92.24 + * questions.
   92.25 + */
   92.26 +
   92.27 +/*
   92.28 + * @test
   92.29 + * @bug 8004727 8005647
   92.30 + * @summary javac should generate method parameters correctly.
   92.31 + */
   92.32 +
   92.33 +import java.io.*;
   92.34 +import java.util.*;
   92.35 +
   92.36 +public class MethodParameters {
   92.37 +
   92.38 +    static final String Foo_name = "Foo";
   92.39 +    static final String Foo_contents =
   92.40 +        ("public class Foo {\n" +
   92.41 +         "  Foo() {}\n" +
   92.42 +         "  Foo(int i) {}\n" +
   92.43 +         "  void foo0() {}\n" +
   92.44 +         "  void foo2(int j, int k) {}\n" +
   92.45 +         "}").replaceAll(" +", " ");
   92.46 +    static final String Init0_expected =
   92.47 +        ("  Foo();\n" +
   92.48 +         "    flags: \n" +
   92.49 +         "    Code:\n" +
   92.50 +         "      stack=1, locals=1, args_size=1\n" +
   92.51 +         "         0: aload_0       \n" +
   92.52 +         "         1: invokespecial #1                  // Method java/lang/Object.\"<init>\":()V\n" +
   92.53 +         "         4: return        \n" +
   92.54 +         "      LineNumberTable:\n" +
   92.55 +         "        line 2: 0").replaceAll(" +", " ");
   92.56 +    static final String Init1_expected =
   92.57 +        ("  Foo(int);\n" +
   92.58 +         "    flags: \n" +
   92.59 +         "    Code:\n" +
   92.60 +         "      stack=1, locals=2, args_size=2\n" +
   92.61 +         "         0: aload_0       \n" +
   92.62 +         "         1: invokespecial #1                  // Method java/lang/Object.\"<init>\":()V\n" +
   92.63 +         "         4: return        \n" +
   92.64 +         "      LineNumberTable:\n" +
   92.65 +         "        line 3: 0\n" +
   92.66 +         "    MethodParameters:\n" +
   92.67 +         "      Name                                Flags\n" +
   92.68 +         "      i").replaceAll(" +", " ");
   92.69 +    static final String foo0_expected =
   92.70 +        ("  void foo0();\n" +
   92.71 +         "    flags: \n" +
   92.72 +         "    Code:\n" +
   92.73 +         "      stack=0, locals=1, args_size=1\n" +
   92.74 +         "         0: return        \n" +
   92.75 +         "      LineNumberTable:\n" +
   92.76 +         "        line 4: 0").replaceAll(" +", " ");
   92.77 +    static final String foo2_expected =
   92.78 +        ("  void foo2(int, int);\n" +
   92.79 +         "    flags: \n" +
   92.80 +         "    Code:\n" +
   92.81 +         "      stack=0, locals=3, args_size=3\n" +
   92.82 +         "         0: return        \n" +
   92.83 +         "      LineNumberTable:\n" +
   92.84 +         "        line 5: 0\n" +
   92.85 +         "    MethodParameters:\n" +
   92.86 +         "      Name                                Flags\n" +
   92.87 +         "      j                              \n" +
   92.88 +         "      k").replaceAll(" +", " ");
   92.89 +
   92.90 +    static final File classesdir = new File("methodparameters");
   92.91 +    static final String separator = System.getProperty("line.separator");
   92.92 +
   92.93 +    public static void main(String... args) throws Exception {
   92.94 +        new MethodParameters().run();
   92.95 +    }
   92.96 +
   92.97 +    void run() throws Exception {
   92.98 +        classesdir.mkdir();
   92.99 +        final File Foo_java =
  92.100 +            writeFile(classesdir, Foo_name + ".java", Foo_contents);
  92.101 +        compile("-parameters", "-d", classesdir.getPath(), Foo_java.getPath());
  92.102 +        System.out.println("Run javap");
  92.103 +        String output =
  92.104 +            javap("-c", "-verbose", "-classpath",
  92.105 +                  classesdir.getPath(), Foo_name);
  92.106 +        String normalized =
  92.107 +            output.replaceAll(separator, "\n").replaceAll(" +", " ");
  92.108 +
  92.109 +        if (!normalized.contains(Init0_expected))
  92.110 +            error("Bad output for zero-parameter constructor.  Expected\n" +
  92.111 +                  Init0_expected + "\n" + "but got\n" + normalized);
  92.112 +        if (!normalized.contains(Init1_expected))
  92.113 +           error("Bad output for one-parameter constructor.  Expected\n" +
  92.114 +                 Init1_expected + "\n" + "but got\n" + normalized);
  92.115 +        if (!normalized.contains(foo0_expected))
  92.116 +           error("Bad output for zero-parameter method.  Expected\n" +
  92.117 +                 foo0_expected + "\n" + "but got\n" + normalized);
  92.118 +        if (!normalized.contains(foo2_expected))
  92.119 +           error("Bad output for two-parameter method  Expected\n" +
  92.120 +                 foo2_expected + "\n" + "but got\n" + normalized);
  92.121 +
  92.122 +        if (0 != errors)
  92.123 +            throw new Exception("MethodParameters test failed with " +
  92.124 +                                errors + " errors");
  92.125 +    }
  92.126 +
  92.127 +    String javap(String... args) {
  92.128 +        StringWriter sw = new StringWriter();
  92.129 +        PrintWriter out = new PrintWriter(sw);
  92.130 +        //sun.tools.javap.Main.entry(args);
  92.131 +        int rc = com.sun.tools.javap.Main.run(args, out);
  92.132 +        if (rc != 0)
  92.133 +            throw new Error("javap failed. rc=" + rc);
  92.134 +        out.close();
  92.135 +        System.out.println(sw);
  92.136 +        return sw.toString();
  92.137 +    }
  92.138 +
  92.139 +    String compile(String... args) throws Exception {
  92.140 +        System.err.println("compile: " + Arrays.asList(args));
  92.141 +        StringWriter sw = new StringWriter();
  92.142 +        PrintWriter pw = new PrintWriter(sw);
  92.143 +        int rc = com.sun.tools.javac.Main.compile(args, pw);
  92.144 +        pw.close();
  92.145 +        String out = sw.toString();
  92.146 +        if (out.length() > 0)
  92.147 +            System.err.println(out);
  92.148 +        if (rc != 0)
  92.149 +            error("compilation failed, rc=" + rc);
  92.150 +        return out;
  92.151 +    }
  92.152 +
  92.153 +    File writeFile(File dir, String path, String body) throws IOException {
  92.154 +        File f = new File(dir, path);
  92.155 +        f.getParentFile().mkdirs();
  92.156 +        FileWriter out = new FileWriter(f);
  92.157 +        out.write(body);
  92.158 +        out.close();
  92.159 +        return f;
  92.160 +    }
  92.161 +
  92.162 +    void error(String msg) {
  92.163 +        System.err.println("Error: " + msg);
  92.164 +        errors++;
  92.165 +    }
  92.166 +
  92.167 +    int errors;
  92.168 +
  92.169 +}
    93.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
    93.2 +++ b/test/tools/jdeps/Basic.java	Thu Jan 10 15:53:02 2013 -0800
    93.3 @@ -0,0 +1,149 @@
    93.4 +/*
    93.5 + * Copyright (c) 2012, Oracle and/or its affiliates. All rights reserved.
    93.6 + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
    93.7 + *
    93.8 + * This code is free software; you can redistribute it and/or modify it
    93.9 + * under the terms of the GNU General Public License version 2 only, as
   93.10 + * published by the Free Software Foundation.
   93.11 + *
   93.12 + * This code is distributed in the hope that it will be useful, but WITHOUT
   93.13 + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
   93.14 + * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
   93.15 + * version 2 for more details (a copy is included in the LICENSE file that
   93.16 + * accompanied this code).
   93.17 + *
   93.18 + * You should have received a copy of the GNU General Public License version
   93.19 + * 2 along with this work; if not, write to the Free Software Foundation,
   93.20 + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
   93.21 + *
   93.22 + * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
   93.23 + * or visit www.oracle.com if you need additional information or have any
   93.24 + * questions.
   93.25 + */
   93.26 +
   93.27 +/*
   93.28 + * @test
   93.29 + * @bug 8003562
   93.30 + * @summary Basic tests for jdeps tool
   93.31 + * @build Test p.Foo
   93.32 + * @run main Basic
   93.33 + */
   93.34 +
   93.35 +import java.io.File;
   93.36 +import java.io.IOException;
   93.37 +import java.io.PrintWriter;
   93.38 +import java.io.StringWriter;
   93.39 +import java.util.*;
   93.40 +import java.util.regex.*;
   93.41 +
   93.42 +public class Basic {
   93.43 +    public static void main(String... args) throws Exception {
   93.44 +        int errors = 0;
   93.45 +
   93.46 +        errors += new Basic().run();
   93.47 +        if (errors > 0)
   93.48 +            throw new Exception(errors + " errors found");
   93.49 +    }
   93.50 +
   93.51 +    int run() throws IOException {
   93.52 +        File testDir = new File(System.getProperty("test.classes", "."));
   93.53 +        // test a .class file
   93.54 +        test(new File(testDir, "Test.class"),
   93.55 +             new String[] {"java.lang", "p"});
   93.56 +        // test a directory
   93.57 +        test(new File(testDir, "p"),
   93.58 +             new String[] {"java.lang", "java.util"});
   93.59 +        // test class-level dependency output
   93.60 +        test(new File(testDir, "Test.class"),
   93.61 +             new String[] {"java.lang.Object", "p.Foo"},
   93.62 +             new String[] {"-V", "class"});
   93.63 +        // test -p option
   93.64 +        test(new File(testDir, "Test.class"),
   93.65 +             new String[] {"p.Foo"},
   93.66 +             new String[] {"--verbose-level=class", "-p", "p"});
   93.67 +        // test -e option
   93.68 +        test(new File(testDir, "Test.class"),
   93.69 +             new String[] {"p.Foo"},
   93.70 +             new String[] {"-V", "class", "-e", "p\\..*"});
   93.71 +        test(new File(testDir, "Test.class"),
   93.72 +             new String[] {"java.lang"},
   93.73 +             new String[] {"-V", "package", "-e", "java\\.lang\\..*"});
   93.74 +        // test -classpath and -all options
   93.75 +        test(null,
   93.76 +             new String[] {"com.sun.tools.jdeps", "java.lang", "java.util",
   93.77 +                           "java.util.regex", "java.io", "p"},
   93.78 +             new String[] {"--classpath", testDir.getPath(), "*"});
   93.79 +        return errors;
   93.80 +    }
   93.81 +
   93.82 +    void test(File file, String[] expect) {
   93.83 +        test(file, expect, new String[0]);
   93.84 +    }
   93.85 +
   93.86 +    void test(File file, String[] expect, String[] options) {
   93.87 +        String[] args;
   93.88 +        if (file != null) {
   93.89 +            args = Arrays.copyOf(options, options.length+1);
   93.90 +            args[options.length] = file.getPath();
   93.91 +        } else {
   93.92 +            args = options;
   93.93 +        }
   93.94 +        String[] deps = jdeps(args);
   93.95 +        checkEqual("dependencies", expect, deps);
   93.96 +    }
   93.97 +
   93.98 +    String[] jdeps(String... args) {
   93.99 +        StringWriter sw = new StringWriter();
  93.100 +        PrintWriter pw = new PrintWriter(sw);
  93.101 +        System.err.println("jdeps " + Arrays.toString(args));
  93.102 +        int rc = com.sun.tools.jdeps.Main.run(args, pw);
  93.103 +        pw.close();
  93.104 +        String out = sw.toString();
  93.105 +        if (!out.isEmpty())
  93.106 +            System.err.println(out);
  93.107 +        if (rc != 0)
  93.108 +            throw new Error("jdeps failed: rc=" + rc);
  93.109 +        return findDeps(out);
  93.110 +    }
  93.111 +
  93.112 +    // Pattern used to parse lines
  93.113 +    private static Pattern linePattern = Pattern.compile(".*\r?\n");
  93.114 +    private static Pattern pattern = Pattern.compile("\\s+ -> (\\S+) +.*");
  93.115 +
  93.116 +    // Use the linePattern to break the given String into lines, applying
  93.117 +    // the pattern to each line to see if we have a match
  93.118 +    private static String[] findDeps(String out) {
  93.119 +        List<String> result = new ArrayList<>();
  93.120 +        Matcher lm = linePattern.matcher(out);  // Line matcher
  93.121 +        Matcher pm = null;                      // Pattern matcher
  93.122 +        int lines = 0;
  93.123 +        while (lm.find()) {
  93.124 +            lines++;
  93.125 +            CharSequence cs = lm.group();       // The current line
  93.126 +            if (pm == null)
  93.127 +                pm = pattern.matcher(cs);
  93.128 +            else
  93.129 +                pm.reset(cs);
  93.130 +            if (pm.find())
  93.131 +                result.add(pm.group(1));
  93.132 +            if (lm.end() == out.length())
  93.133 +                break;
  93.134 +        }
  93.135 +        return result.toArray(new String[0]);
  93.136 +    }
  93.137 +
  93.138 +    void checkEqual(String label, String[] expect, String[] found) {
  93.139 +        Set<String> s1 = new HashSet<>(Arrays.asList(expect));
  93.140 +        Set<String> s2 = new HashSet<>(Arrays.asList(found));
  93.141 +
  93.142 +        if (!s1.equals(s2))
  93.143 +            error("Unexpected " + label + " found: '" + s2 + "', expected: '" + s1 + "'");
  93.144 +    }
  93.145 +
  93.146 +    void error(String msg) {
  93.147 +        System.err.println("Error: " + msg);
  93.148 +        errors++;
  93.149 +    }
  93.150 +
  93.151 +    int errors;
  93.152 +}
    94.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
    94.2 +++ b/test/tools/jdeps/Test.java	Thu Jan 10 15:53:02 2013 -0800
    94.3 @@ -0,0 +1,28 @@
    94.4 +/*
    94.5 + * Copyright (c) 2012, Oracle and/or its affiliates. All rights reserved.
    94.6 + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
    94.7 + *
    94.8 + * This code is free software; you can redistribute it and/or modify it
    94.9 + * under the terms of the GNU General Public License version 2 only, as
   94.10 + * published by the Free Software Foundation.
   94.11 + *
   94.12 + * This code is distributed in the hope that it will be useful, but WITHOUT
   94.13 + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
   94.14 + * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
   94.15 + * version 2 for more details (a copy is included in the LICENSE file that
   94.16 + * accompanied this code).
   94.17 + *
   94.18 + * You should have received a copy of the GNU General Public License version
   94.19 + * 2 along with this work; if not, write to the Free Software Foundation,
   94.20 + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
   94.21 + *
   94.22 + * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
   94.23 + * or visit www.oracle.com if you need additional information or have any
   94.24 + * questions.
   94.25 + */
   94.26 +
   94.27 +public class Test {
   94.28 +    public void test() {
   94.29 +        p.Foo f = new p.Foo();
   94.30 +    }
   94.31 +}
    95.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
    95.2 +++ b/test/tools/jdeps/p/Foo.java	Thu Jan 10 15:53:02 2013 -0800
    95.3 @@ -0,0 +1,35 @@
    95.4 +/*
    95.5 + * Copyright (c) 2012, Oracle and/or its affiliates. All rights reserved.
    95.6 + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
    95.7 + *
    95.8 + * This code is free software; you can redistribute it and/or modify it
    95.9 + * under the terms of the GNU General Public License version 2 only, as
   95.10 + * published by the Free Software Foundation.
   95.11 + *
   95.12 + * This code is distributed in the hope that it will be useful, but WITHOUT
   95.13 + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
   95.14 + * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
   95.15 + * version 2 for more details (a copy is included in the LICENSE file that
   95.16 + * accompanied this code).
   95.17 + *
   95.18 + * You should have received a copy of the GNU General Public License version
   95.19 + * 2 along with this work; if not, write to the Free Software Foundation,
   95.20 + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
   95.21 + *
   95.22 + * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
   95.23 + * or visit www.oracle.com if you need additional information or have any
   95.24 + * questions.
   95.25 + */
   95.26 +
   95.27 +package p;
   95.28 +
   95.29 +import java.util.List;
   95.30 +import java.util.Collections;
   95.31 +public class Foo {
   95.32 +    public static List foo() {
   95.33 +        return Collections.emptyList();
   95.34 +    }
   95.35 +
   95.36 +    public Foo() {
   95.37 +    }
   95.38 +}

mercurial