Merge

Thu, 10 Mar 2011 20:51:07 -0800

author
lana
date
Thu, 10 Mar 2011 20:51:07 -0800
changeset 917
d7dfa105f159
parent 888
0d056b7b93de
parent 916
cb9493a80341
child 920
3d7acdbb72ca

Merge

test/tools/javac/T6900037.java file | annotate | diff | comparison | revisions
test/tools/javac/T6900037.out file | annotate | diff | comparison | revisions
test/tools/javac/diags/examples/DiamondInvalidArg.java file | annotate | diff | comparison | revisions
test/tools/javac/diags/examples/DiamondInvalidArgs.java file | annotate | diff | comparison | revisions
test/tools/javac/generics/diamond/neg/Neg12.java file | annotate | diff | comparison | revisions
test/tools/javac/generics/diamond/neg/Neg12.out file | annotate | diff | comparison | revisions
test/tools/javac/multicatch/Neg05.java file | annotate | diff | comparison | revisions
test/tools/javac/multicatch/Neg05.out file | annotate | diff | comparison | revisions
     1.1 --- a/src/share/classes/com/sun/tools/apt/main/AptJavaCompiler.java	Thu Mar 10 17:11:19 2011 -0800
     1.2 +++ b/src/share/classes/com/sun/tools/apt/main/AptJavaCompiler.java	Thu Mar 10 20:51:07 2011 -0800
     1.3 @@ -1,5 +1,5 @@
     1.4  /*
     1.5 - * Copyright (c) 2004, 2010, Oracle and/or its affiliates. All rights reserved.
     1.6 + * Copyright (c) 2004, 2011, Oracle and/or its affiliates. All rights reserved.
     1.7   * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
     1.8   *
     1.9   * This code is free software; you can redistribute it and/or modify it
    1.10 @@ -280,7 +280,7 @@
    1.11          }
    1.12  
    1.13          if (verbose)
    1.14 -            printVerbose("total", Long.toString(System.currentTimeMillis() - msec));
    1.15 +            log.printVerbose("total", Long.toString(System.currentTimeMillis() - msec));
    1.16  
    1.17          chk.reportDeferredDiagnostics();
    1.18  
     2.1 --- a/src/share/classes/com/sun/tools/apt/util/Bark.java	Thu Mar 10 17:11:19 2011 -0800
     2.2 +++ b/src/share/classes/com/sun/tools/apt/util/Bark.java	Thu Mar 10 20:51:07 2011 -0800
     2.3 @@ -1,5 +1,5 @@
     2.4  /*
     2.5 - * Copyright (c) 2004, 2008, Oracle and/or its affiliates. All rights reserved.
     2.6 + * Copyright (c) 2004, 2011, Oracle and/or its affiliates. All rights reserved.
     2.7   * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
     2.8   *
     2.9   * This code is free software; you can redistribute it and/or modify it
    2.10 @@ -48,15 +48,15 @@
    2.11       * Preregisters factories to create and use a Bark object for use as
    2.12       * both a Log and a Bark.
    2.13       */
    2.14 -    public static void preRegister(final Context context) {
    2.15 +    public static void preRegister(Context context) {
    2.16          context.put(barkKey, new Context.Factory<Bark>() {
    2.17 -            public Bark make() {
    2.18 -                return new Bark(context);
    2.19 +            public Bark make(Context c) {
    2.20 +                return new Bark(c);
    2.21              }
    2.22          });
    2.23          context.put(Log.logKey, new Context.Factory<Log>() {
    2.24 -            public Log make() {
    2.25 -                return Bark.instance(context);
    2.26 +            public Log make(Context c) {
    2.27 +                return Bark.instance(c);
    2.28              }
    2.29          });
    2.30      }
     3.1 --- a/src/share/classes/com/sun/tools/doclets/formats/html/HtmlDocletWriter.java	Thu Mar 10 17:11:19 2011 -0800
     3.2 +++ b/src/share/classes/com/sun/tools/doclets/formats/html/HtmlDocletWriter.java	Thu Mar 10 20:51:07 2011 -0800
     3.3 @@ -1,5 +1,5 @@
     3.4  /*
     3.5 - * Copyright (c) 1998, 2010, Oracle and/or its affiliates. All rights reserved.
     3.6 + * Copyright (c) 1998, 2011, Oracle and/or its affiliates. All rights reserved.
     3.7   * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
     3.8   *
     3.9   * This code is free software; you can redistribute it and/or modify it
    3.10 @@ -156,7 +156,7 @@
    3.11          if (index < 0) {
    3.12              return htmlstr;
    3.13          }
    3.14 -        StringBuffer buf = new StringBuffer();
    3.15 +        StringBuilder buf = new StringBuilder();
    3.16          int previndex = 0;
    3.17          while (true) {
    3.18              // Search for lowercase version of {@docRoot}
    3.19 @@ -2279,7 +2279,7 @@
    3.20       */
    3.21      public String commentTagsToString(Tag holderTag, Doc doc, Tag[] tags,
    3.22              boolean isFirstSentence) {
    3.23 -        StringBuffer result = new StringBuffer();
    3.24 +        StringBuilder result = new StringBuilder();
    3.25          // Array of all possible inline tags for this javadoc run
    3.26          configuration.tagletManager.checkTags(doc, tags, true);
    3.27          for (int i = 0; i < tags.length; i++) {
    3.28 @@ -2315,7 +2315,7 @@
    3.29                  StringTokenizer lines = new StringTokenizer(text, "\r\n", true);
    3.30                  StringBuffer textBuff = new StringBuffer();
    3.31                  while (lines.hasMoreTokens()) {
    3.32 -                    StringBuffer line = new StringBuffer(lines.nextToken());
    3.33 +                    StringBuilder line = new StringBuilder(lines.nextToken());
    3.34                      Util.replaceTabs(configuration.sourcetab, line);
    3.35                      textBuff.append(line.toString());
    3.36                  }
    3.37 @@ -2473,7 +2473,7 @@
    3.38                  return text;
    3.39              }
    3.40              int endindex = startindex + tobe.length();
    3.41 -            StringBuffer replaced = new StringBuffer();
    3.42 +            StringBuilder replaced = new StringBuilder();
    3.43              if (startindex > 0) {
    3.44                  replaced.append(text.substring(0, startindex));
    3.45              }
     4.1 --- a/src/share/classes/com/sun/tools/doclets/formats/html/HtmlSerialFieldWriter.java	Thu Mar 10 17:11:19 2011 -0800
     4.2 +++ b/src/share/classes/com/sun/tools/doclets/formats/html/HtmlSerialFieldWriter.java	Thu Mar 10 20:51:07 2011 -0800
     4.3 @@ -1,5 +1,5 @@
     4.4  /*
     4.5 - * Copyright (c) 1998, 2010, Oracle and/or its affiliates. All rights reserved.
     4.6 + * Copyright (c) 1998, 2011, 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 @@ -30,7 +30,6 @@
    4.11  import com.sun.javadoc.*;
    4.12  import com.sun.tools.doclets.internal.toolkit.*;
    4.13  import com.sun.tools.doclets.internal.toolkit.taglets.*;
    4.14 -import com.sun.tools.doclets.internal.toolkit.util.*;
    4.15  import com.sun.tools.doclets.formats.html.markup.*;
    4.16  
    4.17  /**
    4.18 @@ -53,7 +52,7 @@
    4.19      }
    4.20  
    4.21      public List<FieldDoc> members(ClassDoc cd) {
    4.22 -        return Util.asList(cd.serializableFields());
    4.23 +        return Arrays.asList(cd.serializableFields());
    4.24      }
    4.25  
    4.26      protected void printTypeLinkNoDimension(Type type) {
     5.1 --- a/src/share/classes/com/sun/tools/doclets/formats/html/SourceToHTMLConverter.java	Thu Mar 10 17:11:19 2011 -0800
     5.2 +++ b/src/share/classes/com/sun/tools/doclets/formats/html/SourceToHTMLConverter.java	Thu Mar 10 20:51:07 2011 -0800
     5.3 @@ -1,5 +1,5 @@
     5.4  /*
     5.5 - * Copyright (c) 2001, 2010, Oracle and/or its affiliates. All rights reserved.
     5.6 + * Copyright (c) 2001, 2011, Oracle and/or its affiliates. All rights reserved.
     5.7   * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
     5.8   *
     5.9   * This code is free software; you can redistribute it and/or modify it
    5.10 @@ -266,7 +266,7 @@
    5.11      private static void addLine(Content pre, String line, int tabLength,
    5.12              int currentLineNo) {
    5.13          if (line != null) {
    5.14 -            StringBuffer lineBuffer = new StringBuffer(Util.escapeHtmlChars(line));
    5.15 +            StringBuilder lineBuffer = new StringBuilder(Util.escapeHtmlChars(line));
    5.16              Util.replaceTabs(tabLength, lineBuffer);
    5.17              pre.addContent(new RawHtml(lineBuffer.toString()));
    5.18              Content anchor = HtmlTree.A_NAME("line." + Integer.toString(currentLineNo));
     6.1 --- a/src/share/classes/com/sun/tools/doclets/internal/toolkit/builders/SerializedFormBuilder.java	Thu Mar 10 17:11:19 2011 -0800
     6.2 +++ b/src/share/classes/com/sun/tools/doclets/internal/toolkit/builders/SerializedFormBuilder.java	Thu Mar 10 20:51:07 2011 -0800
     6.3 @@ -1,5 +1,5 @@
     6.4  /*
     6.5 - * Copyright (c) 2003, 2010, Oracle and/or its affiliates. All rights reserved.
     6.6 + * Copyright (c) 2003, 2011, Oracle and/or its affiliates. All rights reserved.
     6.7   * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
     6.8   *
     6.9   * This code is free software; you can redistribute it and/or modify it
    6.10 @@ -375,8 +375,7 @@
    6.11       */
    6.12      public void buildFieldSerializationOverview(ClassDoc classDoc, Content classContentTree) {
    6.13          if (classDoc.definesSerializableFields()) {
    6.14 -            FieldDoc serialPersistentField =
    6.15 -                Util.asList(classDoc.serializableFields()).get(0);
    6.16 +            FieldDoc serialPersistentField = classDoc.serializableFields()[0];
    6.17              // Check to see if there are inline comments, tags or deprecation
    6.18              // information to be printed.
    6.19              if (fieldWriter.shouldPrintOverview(serialPersistentField)) {
     7.1 --- a/src/share/classes/com/sun/tools/doclets/internal/toolkit/util/Util.java	Thu Mar 10 17:11:19 2011 -0800
     7.2 +++ b/src/share/classes/com/sun/tools/doclets/internal/toolkit/util/Util.java	Thu Mar 10 20:51:07 2011 -0800
     7.3 @@ -1,5 +1,5 @@
     7.4  /*
     7.5 - * Copyright (c) 1999, 2010, Oracle and/or its affiliates. All rights reserved.
     7.6 + * Copyright (c) 1999, 2011, Oracle and/or its affiliates. All rights reserved.
     7.7   * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
     7.8   *
     7.9   * This code is free software; you can redistribute it and/or modify it
    7.10 @@ -382,7 +382,7 @@
    7.11                  out.close();
    7.12              }
    7.13          } catch (IOException ie) {
    7.14 -            ie.printStackTrace();
    7.15 +            ie.printStackTrace(System.err);
    7.16              throw new DocletAbortException();
    7.17          }
    7.18      }
    7.19 @@ -399,12 +399,12 @@
    7.20              String pkgPath = DirectoryManager.getDirectoryPath(pkgDoc);
    7.21              String completePath = new SourcePath(configuration.sourcepath).
    7.22                  getDirectory(pkgPath) + DirectoryManager.URL_FILE_SEPARATOR;
    7.23 -            //Make sure that both paths are using the same seperators.
    7.24 +            //Make sure that both paths are using the same separators.
    7.25              completePath = Util.replaceText(completePath, File.separator,
    7.26                      DirectoryManager.URL_FILE_SEPARATOR);
    7.27              pkgPath = Util.replaceText(pkgPath, File.separator,
    7.28                      DirectoryManager.URL_FILE_SEPARATOR);
    7.29 -            return completePath.substring(0, completePath.indexOf(pkgPath));
    7.30 +            return completePath.substring(0, completePath.lastIndexOf(pkgPath));
    7.31          } catch (Exception e){
    7.32              return "";
    7.33          }
    7.34 @@ -536,15 +536,6 @@
    7.35              findAllInterfaceTypes(results, (ClassDoc) type, true, configuration);
    7.36      }
    7.37  
    7.38 -
    7.39 -    public static <T extends ProgramElementDoc> List<T> asList(T[] members) {
    7.40 -        List<T> list = new ArrayList<T>();
    7.41 -        for (int i = 0; i < members.length; i++) {
    7.42 -            list.add(members[i]);
    7.43 -        }
    7.44 -        return list;
    7.45 -    }
    7.46 -
    7.47      /**
    7.48       * Enclose in quotes, used for paths and filenames that contains spaces
    7.49       */
    7.50 @@ -583,14 +574,7 @@
    7.51          if (oldStr == null || newStr == null || oldStr.equals(newStr)) {
    7.52              return originalStr;
    7.53          }
    7.54 -        StringBuffer result = new StringBuffer(originalStr);
    7.55 -        int startIndex = 0;
    7.56 -        while ((startIndex = result.indexOf(oldStr, startIndex)) != -1) {
    7.57 -            result = result.replace(startIndex, startIndex + oldStr.length(),
    7.58 -                    newStr);
    7.59 -            startIndex += newStr.length();
    7.60 -        }
    7.61 -        return result.toString();
    7.62 +        return originalStr.replace(oldStr, newStr);
    7.63      }
    7.64  
    7.65      /**
    7.66 @@ -833,19 +817,17 @@
    7.67       * @param tabLength the length of each tab.
    7.68       * @param s the String to scan.
    7.69       */
    7.70 -    public static void replaceTabs(int tabLength, StringBuffer s) {
    7.71 -        int index, col;
    7.72 -        StringBuffer whitespace;
    7.73 -        while ((index = s.indexOf("\t")) != -1) {
    7.74 -            whitespace = new StringBuffer();
    7.75 -            col = index;
    7.76 -            do {
    7.77 -                whitespace.append(" ");
    7.78 -                col++;
    7.79 -            } while ((col%tabLength) != 0);
    7.80 -            s.replace(index, index+1, whitespace.toString());
    7.81 +    public static void replaceTabs(int tabLength, StringBuilder s) {
    7.82 +        if (whitespace == null || whitespace.length() < tabLength)
    7.83 +            whitespace = String.format("%" + tabLength + "s", " ");
    7.84 +        int index = 0;
    7.85 +        while ((index = s.indexOf("\t", index)) != -1) {
    7.86 +            int spaceCount = tabLength - index % tabLength;
    7.87 +            s.replace(index, index+1, whitespace.substring(0, spaceCount));
    7.88 +            index += spaceCount;
    7.89          }
    7.90      }
    7.91 +    private static String whitespace;
    7.92  
    7.93      /**
    7.94       * The documentation for values() and valueOf() in Enums are set by the
     8.1 --- a/src/share/classes/com/sun/tools/javac/api/JavacTool.java	Thu Mar 10 17:11:19 2011 -0800
     8.2 +++ b/src/share/classes/com/sun/tools/javac/api/JavacTool.java	Thu Mar 10 20:51:07 2011 -0800
     8.3 @@ -1,5 +1,5 @@
     8.4  /*
     8.5 - * Copyright (c) 2005, 2010, Oracle and/or its affiliates. All rights reserved.
     8.6 + * Copyright (c) 2005, 2011, Oracle and/or its affiliates. All rights reserved.
     8.7   * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
     8.8   *
     8.9   * This code is free software; you can redistribute it and/or modify it
    8.10 @@ -157,19 +157,19 @@
    8.11      /**
    8.12       * Register that a compilation is about to start.
    8.13       */
    8.14 -    void beginContext(final Context context) {
    8.15 +    void beginContext(Context context) {
    8.16          if (compilationInProgress)
    8.17              throw new IllegalStateException("Compilation in progress");
    8.18          compilationInProgress = true;
    8.19          final JavaFileManager givenFileManager = context.get(JavaFileManager.class);
    8.20          context.put(JavaFileManager.class, (JavaFileManager)null);
    8.21          context.put(JavaFileManager.class, new Context.Factory<JavaFileManager>() {
    8.22 -            public JavaFileManager make() {
    8.23 +            public JavaFileManager make(Context c) {
    8.24                  if (givenFileManager != null) {
    8.25 -                    context.put(JavaFileManager.class, givenFileManager);
    8.26 +                    c.put(JavaFileManager.class, givenFileManager);
    8.27                      return givenFileManager;
    8.28                  } else {
    8.29 -                    return new JavacFileManager(context, true, null);
    8.30 +                    return new JavacFileManager(c, true, null);
    8.31                  }
    8.32              }
    8.33          });
     9.1 --- a/src/share/classes/com/sun/tools/javac/code/Flags.java	Thu Mar 10 17:11:19 2011 -0800
     9.2 +++ b/src/share/classes/com/sun/tools/javac/code/Flags.java	Thu Mar 10 20:51:07 2011 -0800
     9.3 @@ -43,7 +43,7 @@
     9.4      private Flags() {} // uninstantiable
     9.5  
     9.6      public static String toString(long flags) {
     9.7 -        StringBuffer buf = new StringBuffer();
     9.8 +        StringBuilder buf = new StringBuilder();
     9.9          String sep = "";
    9.10          for (Flag s : asFlagSet(flags)) {
    9.11              buf.append(sep);
    10.1 --- a/src/share/classes/com/sun/tools/javac/code/Kinds.java	Thu Mar 10 17:11:19 2011 -0800
    10.2 +++ b/src/share/classes/com/sun/tools/javac/code/Kinds.java	Thu Mar 10 20:51:07 2011 -0800
    10.3 @@ -1,5 +1,5 @@
    10.4  /*
    10.5 - * Copyright (c) 1999, 2010, Oracle and/or its affiliates. All rights reserved.
    10.6 + * Copyright (c) 1999, 2011, Oracle and/or its affiliates. All rights reserved.
    10.7   * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
    10.8   *
    10.9   * This code is free software; you can redistribute it and/or modify it
   10.10 @@ -163,6 +163,7 @@
   10.11          case PARAMETER:
   10.12          case LOCAL_VARIABLE:
   10.13          case EXCEPTION_PARAMETER:
   10.14 +        case RESOURCE_VARIABLE:
   10.15              return KindName.VAR;
   10.16  
   10.17          case CONSTRUCTOR:
    11.1 --- a/src/share/classes/com/sun/tools/javac/code/Symbol.java	Thu Mar 10 17:11:19 2011 -0800
    11.2 +++ b/src/share/classes/com/sun/tools/javac/code/Symbol.java	Thu Mar 10 20:51:07 2011 -0800
    11.3 @@ -831,6 +831,8 @@
    11.4                  ClassType t = (ClassType)type;
    11.5                  if (t.interfaces_field == null) // FIXME: shouldn't be null
    11.6                      t.interfaces_field = List.nil();
    11.7 +                if (t.all_interfaces_field != null)
    11.8 +                    return Type.getModelTypes(t.all_interfaces_field);
    11.9                  return t.interfaces_field;
   11.10              } else {
   11.11                  return List.nil();
   11.12 @@ -846,7 +848,7 @@
   11.13                  // An interface has no superclass; its supertype is Object.
   11.14                  return t.isInterface()
   11.15                      ? Type.noType
   11.16 -                    : t.supertype_field;
   11.17 +                    : t.supertype_field.getModelType();
   11.18              } else {
   11.19                  return Type.noType;
   11.20              }
    12.1 --- a/src/share/classes/com/sun/tools/javac/code/Symtab.java	Thu Mar 10 17:11:19 2011 -0800
    12.2 +++ b/src/share/classes/com/sun/tools/javac/code/Symtab.java	Thu Mar 10 20:51:07 2011 -0800
    12.3 @@ -1,5 +1,5 @@
    12.4  /*
    12.5 - * Copyright (c) 1999, 2010, Oracle and/or its affiliates. All rights reserved.
    12.6 + * Copyright (c) 1999, 2011, Oracle and/or its affiliates. All rights reserved.
    12.7   * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
    12.8   *
    12.9   * This code is free software; you can redistribute it and/or modify it
   12.10 @@ -26,6 +26,8 @@
   12.11  package com.sun.tools.javac.code;
   12.12  
   12.13  import java.util.*;
   12.14 +import javax.lang.model.type.TypeVisitor;
   12.15 +import javax.lang.model.element.ElementVisitor;
   12.16  
   12.17  import com.sun.tools.javac.util.*;
   12.18  import com.sun.tools.javac.util.List;
   12.19 @@ -345,7 +347,12 @@
   12.20          target = Target.instance(context);
   12.21  
   12.22          // Create the unknown type
   12.23 -        unknownType = new Type(TypeTags.UNKNOWN, null);
   12.24 +        unknownType = new Type(TypeTags.UNKNOWN, null) {
   12.25 +            @Override
   12.26 +            public <R, P> R accept(TypeVisitor<R, P> v, P p) {
   12.27 +                return v.visitUnknown(this, p);
   12.28 +            }
   12.29 +        };
   12.30  
   12.31          // create the basic builtin symbols
   12.32          rootPackage = new PackageSymbol(names.empty, null);
   12.33 @@ -355,13 +362,20 @@
   12.34                      return messages.getLocalizedString("compiler.misc.unnamed.package");
   12.35                  }
   12.36              };
   12.37 -        noSymbol = new TypeSymbol(0, names.empty, Type.noType, rootPackage);
   12.38 +        noSymbol = new TypeSymbol(0, names.empty, Type.noType, rootPackage) {
   12.39 +            public <R, P> R accept(ElementVisitor<R, P> v, P p) {
   12.40 +                return v.visitUnknown(this, p);
   12.41 +            }
   12.42 +        };
   12.43          noSymbol.kind = Kinds.NIL;
   12.44  
   12.45          // create the error symbols
   12.46          errSymbol = new ClassSymbol(PUBLIC|STATIC|ACYCLIC, names.any, null, rootPackage);
   12.47 +        errType = new ErrorType(errSymbol, Type.noType);
   12.48 +
   12.49          unknownSymbol = new ClassSymbol(PUBLIC|STATIC|ACYCLIC, names.fromString("<any?>"), null, rootPackage);
   12.50 -        errType = new ErrorType(errSymbol, Type.noType);
   12.51 +        unknownSymbol.members_field = new Scope.ErrorScope(unknownSymbol);
   12.52 +        unknownSymbol.type = unknownType;
   12.53  
   12.54          // initialize builtin types
   12.55          initType(byteType, "byte", "Byte");
   12.56 @@ -382,9 +396,11 @@
   12.57  
   12.58          // VGJ
   12.59          boundClass = new ClassSymbol(PUBLIC|ACYCLIC, names.Bound, noSymbol);
   12.60 +        boundClass.members_field = new Scope.ErrorScope(boundClass);
   12.61  
   12.62          // the builtin class of all methods
   12.63          methodClass = new ClassSymbol(PUBLIC|ACYCLIC, names.Method, noSymbol);
   12.64 +        methodClass.members_field = new Scope.ErrorScope(boundClass);
   12.65  
   12.66          // Create class to hold all predefined constants and operations.
   12.67          predefClass = new ClassSymbol(PUBLIC|ACYCLIC, names.empty, rootPackage);
    13.1 --- a/src/share/classes/com/sun/tools/javac/code/Type.java	Thu Mar 10 17:11:19 2011 -0800
    13.2 +++ b/src/share/classes/com/sun/tools/javac/code/Type.java	Thu Mar 10 20:51:07 2011 -0800
    13.3 @@ -93,6 +93,22 @@
    13.4          return null;
    13.5      }
    13.6  
    13.7 +    /**
    13.8 +     * Get the representation of this type used for modelling purposes.
    13.9 +     * By default, this is itself. For ErrorType, a different value
   13.10 +     * may be provided,
   13.11 +     */
   13.12 +    public Type getModelType() {
   13.13 +        return this;
   13.14 +    }
   13.15 +
   13.16 +    public static List<Type> getModelTypes(List<Type> ts) {
   13.17 +        ListBuffer<Type> lb = new ListBuffer<Type>();
   13.18 +        for (Type t: ts)
   13.19 +            lb.append(t.getModelType());
   13.20 +        return lb.toList();
   13.21 +    }
   13.22 +
   13.23      public <R,S> R accept(Type.Visitor<R,S> v, S s) { return v.visitType(this, s); }
   13.24  
   13.25      /** Define a type given its tag and type symbol
   13.26 @@ -190,7 +206,7 @@
   13.27          if (ts.isEmpty()) {
   13.28              return "";
   13.29          } else {
   13.30 -            StringBuffer buf = new StringBuffer();
   13.31 +            StringBuilder buf = new StringBuilder();
   13.32              buf.append(ts.head.toString());
   13.33              for (List<Type> l = ts.tail; l.nonEmpty(); l = l.tail)
   13.34                  buf.append(",").append(l.head.toString());
   13.35 @@ -464,7 +480,7 @@
   13.36  
   13.37          boolean isPrintingBound = false;
   13.38          public String toString() {
   13.39 -            StringBuffer s = new StringBuffer();
   13.40 +            StringBuilder s = new StringBuilder();
   13.41              s.append(kind.toString());
   13.42              if (kind != UNBOUND)
   13.43                  s.append(type);
   13.44 @@ -538,6 +554,10 @@
   13.45           */
   13.46          public List<Type> interfaces_field;
   13.47  
   13.48 +        /** All the interfaces of this class, including missing ones.
   13.49 +         */
   13.50 +        public List<Type> all_interfaces_field;
   13.51 +
   13.52          public ClassType(Type outer, List<Type> typarams, TypeSymbol tsym) {
   13.53              super(CLASS, tsym);
   13.54              this.outer_field = outer;
   13.55 @@ -578,7 +598,7 @@
   13.56          /** The Java source which this type represents.
   13.57           */
   13.58          public String toString() {
   13.59 -            StringBuffer buf = new StringBuffer();
   13.60 +            StringBuilder buf = new StringBuilder();
   13.61              if (getEnclosingType().tag == CLASS && tsym.owner.kind == TYP) {
   13.62                  buf.append(getEnclosingType().toString());
   13.63                  buf.append(".");
   13.64 @@ -596,7 +616,7 @@
   13.65  //where
   13.66              private String className(Symbol sym, boolean longform) {
   13.67                  if (sym.name.isEmpty() && (sym.flags() & COMPOUND) != 0) {
   13.68 -                    StringBuffer s = new StringBuffer(supertype_field.toString());
   13.69 +                    StringBuilder s = new StringBuilder(supertype_field.toString());
   13.70                      for (List<Type> is=interfaces_field; is.nonEmpty(); is = is.tail) {
   13.71                          s.append("&");
   13.72                          s.append(is.head.toString());
    14.1 --- a/src/share/classes/com/sun/tools/javac/code/Types.java	Thu Mar 10 17:11:19 2011 -0800
    14.2 +++ b/src/share/classes/com/sun/tools/javac/code/Types.java	Thu Mar 10 20:51:07 2011 -0800
    14.3 @@ -1992,7 +1992,11 @@
    14.4       * @return true if t is a sub signature of s.
    14.5       */
    14.6      public boolean isSubSignature(Type t, Type s) {
    14.7 -        return hasSameArgs(t, s) || hasSameArgs(t, erasure(s));
    14.8 +        return isSubSignature(t, s, true);
    14.9 +    }
   14.10 +
   14.11 +    public boolean isSubSignature(Type t, Type s, boolean strict) {
   14.12 +        return hasSameArgs(t, s, strict) || hasSameArgs(t, erasure(s), strict);
   14.13      }
   14.14  
   14.15      /**
   14.16 @@ -2129,10 +2133,24 @@
   14.17       * where correspondence is by position in the type parameter list.
   14.18       */
   14.19      public boolean hasSameArgs(Type t, Type s) {
   14.20 +        return hasSameArgs(t, s, true);
   14.21 +    }
   14.22 +
   14.23 +    public boolean hasSameArgs(Type t, Type s, boolean strict) {
   14.24 +        return hasSameArgs(t, s, strict ? hasSameArgs_strict : hasSameArgs_nonstrict);
   14.25 +    }
   14.26 +
   14.27 +    private boolean hasSameArgs(Type t, Type s, TypeRelation hasSameArgs) {
   14.28          return hasSameArgs.visit(t, s);
   14.29      }
   14.30      // where
   14.31 -        private TypeRelation hasSameArgs = new TypeRelation() {
   14.32 +        private class HasSameArgs extends TypeRelation {
   14.33 +
   14.34 +            boolean strict;
   14.35 +
   14.36 +            public HasSameArgs(boolean strict) {
   14.37 +                this.strict = strict;
   14.38 +            }
   14.39  
   14.40              public Boolean visitType(Type t, Type s) {
   14.41                  throw new AssertionError();
   14.42 @@ -2147,7 +2165,7 @@
   14.43              @Override
   14.44              public Boolean visitForAll(ForAll t, Type s) {
   14.45                  if (s.tag != FORALL)
   14.46 -                    return false;
   14.47 +                    return strict ? false : visitMethodType(t.asMethodType(), s);
   14.48  
   14.49                  ForAll forAll = (ForAll)s;
   14.50                  return hasSameBounds(t, forAll)
   14.51 @@ -2159,6 +2177,10 @@
   14.52                  return false;
   14.53              }
   14.54          };
   14.55 +
   14.56 +        TypeRelation hasSameArgs_strict = new HasSameArgs(true);
   14.57 +        TypeRelation hasSameArgs_nonstrict = new HasSameArgs(false);
   14.58 +
   14.59      // </editor-fold>
   14.60  
   14.61      // <editor-fold defaultstate="collapsed" desc="subst">
   14.62 @@ -2534,7 +2556,7 @@
   14.63      }
   14.64      // where
   14.65          private String typaramsString(List<Type> tvars) {
   14.66 -            StringBuffer s = new StringBuffer();
   14.67 +            StringBuilder s = new StringBuilder();
   14.68              s.append('<');
   14.69              boolean first = true;
   14.70              for (Type t : tvars) {
   14.71 @@ -2545,7 +2567,7 @@
   14.72              s.append('>');
   14.73              return s.toString();
   14.74          }
   14.75 -        private void appendTyparamString(TypeVar t, StringBuffer buf) {
   14.76 +        private void appendTyparamString(TypeVar t, StringBuilder buf) {
   14.77              buf.append(t);
   14.78              if (t.bound == null ||
   14.79                  t.bound.tsym.getQualifiedName() == names.java_lang_Object)
   14.80 @@ -2832,12 +2854,26 @@
   14.81              while (ts.head.tag != CLASS && ts.head.tag != TYPEVAR)
   14.82                  ts = ts.tail;
   14.83              Assert.check(!ts.isEmpty());
   14.84 -            List<Type> cl = closure(ts.head);
   14.85 +            //step 1 - compute erased candidate set (EC)
   14.86 +            List<Type> cl = erasedSupertypes(ts.head);
   14.87              for (Type t : ts.tail) {
   14.88                  if (t.tag == CLASS || t.tag == TYPEVAR)
   14.89 -                    cl = intersect(cl, closure(t));
   14.90 +                    cl = intersect(cl, erasedSupertypes(t));
   14.91              }
   14.92 -            return compoundMin(cl);
   14.93 +            //step 2 - compute minimal erased candidate set (MEC)
   14.94 +            List<Type> mec = closureMin(cl);
   14.95 +            //step 3 - for each element G in MEC, compute lci(Inv(G))
   14.96 +            List<Type> candidates = List.nil();
   14.97 +            for (Type erasedSupertype : mec) {
   14.98 +                List<Type> lci = List.of(asSuper(ts.head, erasedSupertype.tsym));
   14.99 +                for (Type t : ts) {
  14.100 +                    lci = intersect(lci, List.of(asSuper(t, erasedSupertype.tsym)));
  14.101 +                }
  14.102 +                candidates = candidates.appendList(lci);
  14.103 +            }
  14.104 +            //step 4 - let MEC be { G1, G2 ... Gn }, then we have that
  14.105 +            //lub = lci(Inv(G1)) & lci(Inv(G2)) & ... & lci(Inv(Gn))
  14.106 +            return compoundMin(candidates);
  14.107  
  14.108          default:
  14.109              // calculate lub(A, B[])
  14.110 @@ -2851,6 +2887,18 @@
  14.111          }
  14.112      }
  14.113      // where
  14.114 +        List<Type> erasedSupertypes(Type t) {
  14.115 +            ListBuffer<Type> buf = lb();
  14.116 +            for (Type sup : closure(t)) {
  14.117 +                if (sup.tag == TYPEVAR) {
  14.118 +                    buf.append(sup);
  14.119 +                } else {
  14.120 +                    buf.append(erasure(sup));
  14.121 +                }
  14.122 +            }
  14.123 +            return buf.toList();
  14.124 +        }
  14.125 +
  14.126          private Type arraySuperType = null;
  14.127          private Type arraySuperType() {
  14.128              // initialized lazily to avoid problems during compiler startup
    15.1 --- a/src/share/classes/com/sun/tools/javac/comp/Attr.java	Thu Mar 10 17:11:19 2011 -0800
    15.2 +++ b/src/share/classes/com/sun/tools/javac/comp/Attr.java	Thu Mar 10 20:51:07 2011 -0800
    15.3 @@ -1425,7 +1425,7 @@
    15.4                              // qualifier omitted; check for existence
    15.5                              // of an appropriate implicit qualifier.
    15.6                              rs.resolveImplicitThis(tree.meth.pos(),
    15.7 -                                                   localEnv, site);
    15.8 +                                                   localEnv, site, true);
    15.9                          }
   15.10                      } else if (tree.meth.getTag() == JCTree.SELECT) {
   15.11                          log.error(tree.meth.pos(), "illegal.qual.not.icls",
   15.12 @@ -1581,15 +1581,7 @@
   15.13          // symbol + type back into the attributed tree.
   15.14          Type clazztype = attribType(clazz, env);
   15.15          Pair<Scope,Scope> mapping = getSyntheticScopeMapping(clazztype, cdef != null);
   15.16 -        if (!TreeInfo.isDiamond(tree)) {
   15.17 -            clazztype = chk.checkClassType(
   15.18 -                tree.clazz.pos(), clazztype, true);
   15.19 -        } else if (!clazztype.isErroneous() &&
   15.20 -                !clazztype.tsym.type.isParameterized()) {
   15.21 -            log.error(tree.clazz.pos(),
   15.22 -                    "cant.apply.diamond.1",
   15.23 -                    clazztype, diags.fragment("diamond.non.generic", clazztype));
   15.24 -        }
   15.25 +        clazztype = chk.checkDiamond(tree, clazztype);
   15.26          chk.validate(clazz, localEnv);
   15.27          if (tree.encl != null) {
   15.28              // We have to work in this case to store
   15.29 @@ -1614,10 +1606,12 @@
   15.30          List<Type> argtypes = attribArgs(tree.args, localEnv);
   15.31          List<Type> typeargtypes = attribTypes(tree.typeargs, localEnv);
   15.32  
   15.33 -        if (TreeInfo.isDiamond(tree) && clazztype.tsym.type.isParameterized()) {
   15.34 +        if (TreeInfo.isDiamond(tree) && !clazztype.isErroneous()) {
   15.35              clazztype = attribDiamond(localEnv, tree, clazztype, mapping, argtypes, typeargtypes);
   15.36              clazz.type = clazztype;
   15.37          } else if (allowDiamondFinder &&
   15.38 +                tree.def == null &&
   15.39 +                !clazztype.isErroneous() &&
   15.40                  clazztype.getTypeArguments().nonEmpty() &&
   15.41                  findDiamonds) {
   15.42              boolean prevDeferDiags = log.deferDiagnostics;
   15.43 @@ -1641,8 +1635,7 @@
   15.44              if (inferred != null &&
   15.45                      !inferred.isErroneous() &&
   15.46                      inferred.tag == CLASS &&
   15.47 -                    types.isAssignable(inferred, pt.tag == NONE ? clazztype : pt, Warner.noWarnings) &&
   15.48 -                    chk.checkDiamond((ClassType)inferred).isEmpty()) {
   15.49 +                    types.isAssignable(inferred, pt.tag == NONE ? clazztype : pt, Warner.noWarnings)) {
   15.50                  String key = types.isSameType(clazztype, inferred) ?
   15.51                      "diamond.redundant.args" :
   15.52                      "diamond.redundant.args.1";
   15.53 @@ -1857,34 +1850,9 @@
   15.54                          ex.diagnostic);
   15.55              }
   15.56          }
   15.57 -        clazztype = chk.checkClassType(tree.clazz.pos(),
   15.58 +        return chk.checkClassType(tree.clazz.pos(),
   15.59                  clazztype,
   15.60                  true);
   15.61 -        if (clazztype.tag == CLASS) {
   15.62 -            List<Type> invalidDiamondArgs = chk.checkDiamond((ClassType)clazztype);
   15.63 -            if (!clazztype.isErroneous() && invalidDiamondArgs.nonEmpty()) {
   15.64 -                //one or more types inferred in the previous steps is either a
   15.65 -                //captured type or an intersection type --- we need to report an error.
   15.66 -                String subkey = invalidDiamondArgs.size() > 1 ?
   15.67 -                    "diamond.invalid.args" :
   15.68 -                    "diamond.invalid.arg";
   15.69 -                //The error message is of the kind:
   15.70 -                //
   15.71 -                //cannot infer type arguments for {clazztype}<>;
   15.72 -                //reason: {subkey}
   15.73 -                //
   15.74 -                //where subkey is a fragment of the kind:
   15.75 -                //
   15.76 -                //type argument(s) {invalidDiamondArgs} inferred for {clazztype}<> is not allowed in this context
   15.77 -                log.error(tree.clazz.pos(),
   15.78 -                            "cant.apply.diamond.1",
   15.79 -                            diags.fragment("diamond", clazztype.tsym),
   15.80 -                            diags.fragment(subkey,
   15.81 -                                           invalidDiamondArgs,
   15.82 -                                           diags.fragment("diamond", clazztype.tsym)));
   15.83 -            }
   15.84 -        }
   15.85 -        return clazztype;
   15.86      }
   15.87  
   15.88      /** Creates a synthetic scope containing fake generic constructors.
   15.89 @@ -2806,7 +2774,7 @@
   15.90                                    sym.location());
   15.91                  owntype = new MethodType(owntype.getParameterTypes(),
   15.92                                           types.erasure(owntype.getReturnType()),
   15.93 -                                         owntype.getThrownTypes(),
   15.94 +                                         types.erasure(owntype.getThrownTypes()),
   15.95                                           syms.methodClass);
   15.96              }
   15.97              if (useVarargs) {
   15.98 @@ -2980,7 +2948,7 @@
   15.99              // (see comment for TypeVar.bound).
  15.100              // In this case, generate a class tree that represents the
  15.101              // bound class, ...
  15.102 -            JCTree extending;
  15.103 +            JCExpression extending;
  15.104              List<JCExpression> implementing;
  15.105              if ((bs.head.tsym.flags() & INTERFACE) == 0) {
  15.106                  extending = tree.bounds.head;
    16.1 --- a/src/share/classes/com/sun/tools/javac/comp/Check.java	Thu Mar 10 17:11:19 2011 -0800
    16.2 +++ b/src/share/classes/com/sun/tools/javac/comp/Check.java	Thu Mar 10 20:51:07 2011 -0800
    16.3 @@ -664,40 +664,25 @@
    16.4              return true;
    16.5      }
    16.6  
    16.7 -    /** Check that the type inferred using the diamond operator does not contain
    16.8 -     *  non-denotable types such as captured types or intersection types.
    16.9 -     *  @param t the type inferred using the diamond operator
   16.10 +    /** Check that usage of diamond operator is correct (i.e. diamond should not
   16.11 +     * be used with non-generic classes or in anonymous class creation expressions)
   16.12       */
   16.13 -    List<Type> checkDiamond(ClassType t) {
   16.14 -        DiamondTypeChecker dtc = new DiamondTypeChecker();
   16.15 -        ListBuffer<Type> buf = ListBuffer.lb();
   16.16 -        for (Type arg : t.getTypeArguments()) {
   16.17 -            if (!dtc.visit(arg, null)) {
   16.18 -                buf.append(arg);
   16.19 -            }
   16.20 -        }
   16.21 -        return buf.toList();
   16.22 -    }
   16.23 -
   16.24 -    static class DiamondTypeChecker extends Types.SimpleVisitor<Boolean, Void> {
   16.25 -        public Boolean visitType(Type t, Void s) {
   16.26 -            return true;
   16.27 -        }
   16.28 -        @Override
   16.29 -        public Boolean visitClassType(ClassType t, Void s) {
   16.30 -            if (t.isCompound()) {
   16.31 -                return false;
   16.32 -            }
   16.33 -            for (Type targ : t.getTypeArguments()) {
   16.34 -                if (!visit(targ, s)) {
   16.35 -                    return false;
   16.36 -                }
   16.37 -            }
   16.38 -            return true;
   16.39 -        }
   16.40 -        @Override
   16.41 -        public Boolean visitCapturedType(CapturedType t, Void s) {
   16.42 -            return false;
   16.43 +    Type checkDiamond(JCNewClass tree, Type t) {
   16.44 +        if (!TreeInfo.isDiamond(tree) ||
   16.45 +                t.isErroneous()) {
   16.46 +            return checkClassType(tree.clazz.pos(), t, true);
   16.47 +        } else if (tree.def != null) {
   16.48 +            log.error(tree.clazz.pos(),
   16.49 +                    "cant.apply.diamond.1",
   16.50 +                    t, diags.fragment("diamond.and.anon.class", t));
   16.51 +            return types.createErrorType(t);
   16.52 +        } else if (!t.tsym.type.isParameterized()) {
   16.53 +            log.error(tree.clazz.pos(),
   16.54 +                "cant.apply.diamond.1",
   16.55 +                t, diags.fragment("diamond.non.generic", t));
   16.56 +            return types.createErrorType(t);
   16.57 +        } else {
   16.58 +            return t;
   16.59          }
   16.60      }
   16.61  
   16.62 @@ -1679,7 +1664,8 @@
   16.63                              "(" + types.memberType(t2, s2).getParameterTypes() + ")");
   16.64                          return s2;
   16.65                      }
   16.66 -                } else if (checkNameClash((ClassSymbol)site.tsym, s1, s2)) {
   16.67 +                } else if (checkNameClash((ClassSymbol)site.tsym, s1, s2) &&
   16.68 +                        !checkCommonOverriderIn(s1, s2, site)) {
   16.69                      log.error(pos,
   16.70                              "name.clash.same.erasure.no.override",
   16.71                              s1, s1.location(),
   16.72 @@ -2113,7 +2099,7 @@
   16.73                  if (s1 == s2 || !sym.overrides(s2, site.tsym, types, false)) continue;
   16.74                  //if (i) the signature of 'sym' is not a subsignature of m1 (seen as
   16.75                  //a member of 'site') and (ii) m1 has the same erasure as m2, issue an error
   16.76 -                if (!types.isSubSignature(sym.type, types.memberType(site, s1)) &&
   16.77 +                if (!types.isSubSignature(sym.type, types.memberType(site, s1), false) &&
   16.78                          types.hasSameArgs(s1.erasure(types), s2.erasure(types))) {
   16.79                      sym.flags_field |= CLASH;
   16.80                      String key = s2 == sym ?
   16.81 @@ -2145,7 +2131,7 @@
   16.82          for (Symbol s : types.membersClosure(site).getElementsByName(sym.name, cf)) {
   16.83              //if (i) the signature of 'sym' is not a subsignature of m1 (seen as
   16.84              //a member of 'site') and (ii) 'sym' has the same erasure as m1, issue an error
   16.85 -            if (!types.isSubSignature(sym.type, types.memberType(site, s)) &&
   16.86 +            if (!types.isSubSignature(sym.type, types.memberType(site, s), false) &&
   16.87                      types.hasSameArgs(s.erasure(types), sym.erasure(types))) {
   16.88                  log.error(pos,
   16.89                          "name.clash.same.erasure.no.hide",
   16.90 @@ -2666,7 +2652,7 @@
   16.91                  if ((sym.flags() & VARARGS) != (e.sym.flags() & VARARGS)) {
   16.92                      varargsDuplicateError(pos, sym, e.sym);
   16.93                      return true;
   16.94 -                } else if (sym.kind == MTH && !hasSameSignature(sym.type, e.sym.type)) {
   16.95 +                } else if (sym.kind == MTH && !types.hasSameArgs(sym.type, e.sym.type, false)) {
   16.96                      duplicateErasureError(pos, sym, e.sym);
   16.97                      sym.flags_field |= CLASH;
   16.98                      return true;
   16.99 @@ -2678,15 +2664,6 @@
  16.100          }
  16.101          return true;
  16.102      }
  16.103 -    //where
  16.104 -        boolean hasSameSignature(Type mt1, Type mt2) {
  16.105 -            if (mt1.tag == FORALL && mt2.tag == FORALL) {
  16.106 -                ForAll fa1 = (ForAll)mt1;
  16.107 -                ForAll fa2 = (ForAll)mt2;
  16.108 -                mt2 = types.subst(fa2, fa2.tvars, fa1.tvars);
  16.109 -            }
  16.110 -            return types.hasSameArgs(mt1.asMethodType(), mt2.asMethodType());
  16.111 -        }
  16.112  
  16.113      /** Report duplicate declaration error.
  16.114       */
    17.1 --- a/src/share/classes/com/sun/tools/javac/comp/Flow.java	Thu Mar 10 17:11:19 2011 -0800
    17.2 +++ b/src/share/classes/com/sun/tools/javac/comp/Flow.java	Thu Mar 10 20:51:07 2011 -0800
    17.3 @@ -272,7 +272,7 @@
    17.4  
    17.5      /** The list of unreferenced automatic resources.
    17.6       */
    17.7 -    Map<VarSymbol, JCVariableDecl> unrefdResources;
    17.8 +    Scope unrefdResources;
    17.9  
   17.10      /** Set when processing a loop body the second time for DU analysis. */
   17.11      boolean loopPassTwo = false;
   17.12 @@ -804,14 +804,16 @@
   17.13          ListBuffer<PendingExit> prevPendingExits = pendingExits;
   17.14          boolean prevLoopPassTwo = loopPassTwo;
   17.15          pendingExits = new ListBuffer<PendingExit>();
   17.16 +        int prevErrors = log.nerrors;
   17.17          do {
   17.18              Bits uninitsEntry = uninits.dup();
   17.19 +            uninitsEntry.excludeFrom(nextadr);
   17.20              scanStat(tree.body);
   17.21              alive |= resolveContinues(tree);
   17.22              scanCond(tree.cond);
   17.23 -            if (log.nerrors != 0 ||
   17.24 +            if (log.nerrors !=  prevErrors ||
   17.25                  loopPassTwo ||
   17.26 -                uninitsEntry.diffSet(uninitsWhenTrue).nextBit(firstadr)==-1)
   17.27 +                uninitsEntry.dup().diffSet(uninitsWhenTrue).nextBit(firstadr)==-1)
   17.28                  break;
   17.29              inits = initsWhenTrue;
   17.30              uninits = uninitsEntry.andSet(uninitsWhenTrue);
   17.31 @@ -831,8 +833,10 @@
   17.32          Bits initsCond;
   17.33          Bits uninitsCond;
   17.34          pendingExits = new ListBuffer<PendingExit>();
   17.35 +        int prevErrors = log.nerrors;
   17.36          do {
   17.37              Bits uninitsEntry = uninits.dup();
   17.38 +            uninitsEntry.excludeFrom(nextadr);
   17.39              scanCond(tree.cond);
   17.40              initsCond = initsWhenFalse;
   17.41              uninitsCond = uninitsWhenFalse;
   17.42 @@ -841,9 +845,9 @@
   17.43              alive = !tree.cond.type.isFalse();
   17.44              scanStat(tree.body);
   17.45              alive |= resolveContinues(tree);
   17.46 -            if (log.nerrors != 0 ||
   17.47 +            if (log.nerrors != prevErrors ||
   17.48                  loopPassTwo ||
   17.49 -                uninitsEntry.diffSet(uninits).nextBit(firstadr) == -1)
   17.50 +                uninitsEntry.dup().diffSet(uninits).nextBit(firstadr) == -1)
   17.51                  break;
   17.52              uninits = uninitsEntry.andSet(uninits);
   17.53              loopPassTwo = true;
   17.54 @@ -864,8 +868,10 @@
   17.55          Bits initsCond;
   17.56          Bits uninitsCond;
   17.57          pendingExits = new ListBuffer<PendingExit>();
   17.58 +        int prevErrors = log.nerrors;
   17.59          do {
   17.60              Bits uninitsEntry = uninits.dup();
   17.61 +            uninitsEntry.excludeFrom(nextadr);
   17.62              if (tree.cond != null) {
   17.63                  scanCond(tree.cond);
   17.64                  initsCond = initsWhenFalse;
   17.65 @@ -883,7 +889,7 @@
   17.66              scanStat(tree.body);
   17.67              alive |= resolveContinues(tree);
   17.68              scan(tree.step);
   17.69 -            if (log.nerrors != 0 ||
   17.70 +            if (log.nerrors != prevErrors ||
   17.71                  loopPassTwo ||
   17.72                  uninitsEntry.dup().diffSet(uninits).nextBit(firstadr) == -1)
   17.73                  break;
   17.74 @@ -897,8 +903,6 @@
   17.75          alive = resolveBreaks(tree, prevPendingExits) ||
   17.76              tree.cond != null && !tree.cond.type.isTrue();
   17.77          nextadr = nextadrPrev;
   17.78 -        inits.excludeFrom(nextadr);
   17.79 -        uninits.excludeFrom(nextadr);
   17.80      }
   17.81  
   17.82      public void visitForeachLoop(JCEnhancedForLoop tree) {
   17.83 @@ -913,13 +917,15 @@
   17.84  
   17.85          letInit(tree.pos(), tree.var.sym);
   17.86          pendingExits = new ListBuffer<PendingExit>();
   17.87 +        int prevErrors = log.nerrors;
   17.88          do {
   17.89              Bits uninitsEntry = uninits.dup();
   17.90 +            uninitsEntry.excludeFrom(nextadr);
   17.91              scanStat(tree.body);
   17.92              alive |= resolveContinues(tree);
   17.93 -            if (log.nerrors != 0 ||
   17.94 +            if (log.nerrors != prevErrors ||
   17.95                  loopPassTwo ||
   17.96 -                uninitsEntry.diffSet(uninits).nextBit(firstadr) == -1)
   17.97 +                uninitsEntry.dup().diffSet(uninits).nextBit(firstadr) == -1)
   17.98                  break;
   17.99              uninits = uninitsEntry.andSet(uninits);
  17.100              loopPassTwo = true;
  17.101 @@ -992,7 +998,6 @@
  17.102      public void visitTry(JCTry tree) {
  17.103          List<Type> caughtPrev = caught;
  17.104          List<Type> thrownPrev = thrown;
  17.105 -        Map<VarSymbol, JCVariableDecl> unrefdResourcesPrev = unrefdResources;
  17.106          thrown = List.nil();
  17.107          for (List<JCCatch> l = tree.catchers; l.nonEmpty(); l = l.tail) {
  17.108              List<JCExpression> subClauses = TreeInfo.isMultiCatch(l.head) ?
  17.109 @@ -1002,17 +1007,18 @@
  17.110                  caught = chk.incl(ct.type, caught);
  17.111              }
  17.112          }
  17.113 +        ListBuffer<JCVariableDecl> resourceVarDecls = ListBuffer.lb();
  17.114          Bits uninitsTryPrev = uninitsTry;
  17.115          ListBuffer<PendingExit> prevPendingExits = pendingExits;
  17.116          pendingExits = new ListBuffer<PendingExit>();
  17.117          Bits initsTry = inits.dup();
  17.118          uninitsTry = uninits.dup();
  17.119 -        unrefdResources = new LinkedHashMap<VarSymbol, JCVariableDecl>();
  17.120          for (JCTree resource : tree.resources) {
  17.121              if (resource instanceof JCVariableDecl) {
  17.122                  JCVariableDecl vdecl = (JCVariableDecl) resource;
  17.123                  visitVarDef(vdecl);
  17.124 -                unrefdResources.put(vdecl.sym, vdecl);
  17.125 +                unrefdResources.enter(vdecl.sym);
  17.126 +                resourceVarDecls.append(vdecl);
  17.127              } else if (resource instanceof JCExpression) {
  17.128                  scanExpr((JCExpression) resource);
  17.129              } else {
  17.130 @@ -1049,11 +1055,14 @@
  17.131          Bits uninitsEnd = uninits;
  17.132          int nextadrCatch = nextadr;
  17.133  
  17.134 -        if (!unrefdResources.isEmpty() &&
  17.135 +        if (!resourceVarDecls.isEmpty() &&
  17.136                  lint.isEnabled(Lint.LintCategory.TRY)) {
  17.137 -            for (Map.Entry<VarSymbol, JCVariableDecl> e : unrefdResources.entrySet()) {
  17.138 -                log.warning(Lint.LintCategory.TRY, e.getValue().pos(),
  17.139 -                            "try.resource.not.referenced", e.getKey());
  17.140 +            for (JCVariableDecl resVar : resourceVarDecls) {
  17.141 +                if (unrefdResources.includes(resVar.sym)) {
  17.142 +                    log.warning(Lint.LintCategory.TRY, resVar.pos(),
  17.143 +                                "try.resource.not.referenced", resVar.sym);
  17.144 +                    unrefdResources.remove(resVar.sym);
  17.145 +                }
  17.146              }
  17.147          }
  17.148  
  17.149 @@ -1143,7 +1152,6 @@
  17.150              while (exits.nonEmpty()) pendingExits.append(exits.next());
  17.151          }
  17.152          uninitsTry.andSet(uninitsTryPrev).andSet(uninits);
  17.153 -        unrefdResources = unrefdResourcesPrev;
  17.154      }
  17.155  
  17.156      public void visitConditional(JCConditional tree) {
  17.157 @@ -1369,9 +1377,7 @@
  17.158      }
  17.159  
  17.160      void referenced(Symbol sym) {
  17.161 -        if (unrefdResources != null && unrefdResources.containsKey(sym)) {
  17.162 -            unrefdResources.remove(sym);
  17.163 -        }
  17.164 +        unrefdResources.remove(sym);
  17.165      }
  17.166  
  17.167      public void visitTypeCast(JCTypeCast tree) {
  17.168 @@ -1430,6 +1436,7 @@
  17.169              alive = true;
  17.170              this.thrown = this.caught = null;
  17.171              this.classDef = null;
  17.172 +            unrefdResources = new Scope(env.enclClass.sym);
  17.173              scan(tree);
  17.174          } finally {
  17.175              // note that recursive invocations of this method fail hard
  17.176 @@ -1444,6 +1451,7 @@
  17.177              this.make = null;
  17.178              this.thrown = this.caught = null;
  17.179              this.classDef = null;
  17.180 +            unrefdResources = null;
  17.181          }
  17.182      }
  17.183  }
    18.1 --- a/src/share/classes/com/sun/tools/javac/comp/Infer.java	Thu Mar 10 17:11:19 2011 -0800
    18.2 +++ b/src/share/classes/com/sun/tools/javac/comp/Infer.java	Thu Mar 10 20:51:07 2011 -0800
    18.3 @@ -465,10 +465,9 @@
    18.4              // quantify result type with them
    18.5              final List<Type> inferredTypes = insttypes.toList();
    18.6              final List<Type> all_tvars = tvars; //this is the wrong tvars
    18.7 -            final MethodType mt2 = new MethodType(mt.argtypes, null, mt.thrown, syms.methodClass);
    18.8 -            mt2.restype = new ForAll(restvars.toList(), mt.restype) {
    18.9 +            return new UninferredMethodType(mt, restvars.toList()) {
   18.10                  @Override
   18.11 -                public List<Type> getConstraints(TypeVar tv, ConstraintKind ck) {
   18.12 +                List<Type> getConstraints(TypeVar tv, ConstraintKind ck) {
   18.13                      for (Type t : restundet.toList()) {
   18.14                          UndetVar uv = (UndetVar)t;
   18.15                          if (uv.qtype == tv) {
   18.16 @@ -481,21 +480,17 @@
   18.17                      }
   18.18                      return List.nil();
   18.19                  }
   18.20 -
   18.21                  @Override
   18.22 -                public Type inst(List<Type> inferred, Types types) throws NoInstanceException {
   18.23 -                    List<Type> formals = types.subst(mt2.argtypes, tvars, inferred);
   18.24 +                void check(List<Type> inferred, Types types) throws NoInstanceException {
   18.25                      // check that actuals conform to inferred formals
   18.26 -                    checkArgumentsAcceptable(env, capturedArgs, formals, allowBoxing, useVarargs, warn);
   18.27 +                    checkArgumentsAcceptable(env, capturedArgs, getParameterTypes(), allowBoxing, useVarargs, warn);
   18.28                      // check that inferred bounds conform to their bounds
   18.29                      checkWithinBounds(all_tvars,
   18.30                             types.subst(inferredTypes, tvars, inferred), warn);
   18.31                      if (useVarargs) {
   18.32 -                        chk.checkVararg(env.tree.pos(), formals, msym);
   18.33 +                        chk.checkVararg(env.tree.pos(), getParameterTypes(), msym);
   18.34                      }
   18.35 -                    return super.inst(inferred, types);
   18.36              }};
   18.37 -            return mt2;
   18.38          }
   18.39          else {
   18.40              // check that actuals conform to inferred formals
   18.41 @@ -506,6 +501,62 @@
   18.42      }
   18.43      //where
   18.44  
   18.45 +        /**
   18.46 +         * A delegated type representing a partially uninferred method type.
   18.47 +         * The return type of a partially uninferred method type is a ForAll
   18.48 +         * type - when the return type is instantiated (see Infer.instantiateExpr)
   18.49 +         * the underlying method type is also updated.
   18.50 +         */
   18.51 +        static abstract class UninferredMethodType extends DelegatedType {
   18.52 +
   18.53 +            final List<Type> tvars;
   18.54 +
   18.55 +            public UninferredMethodType(MethodType mtype, List<Type> tvars) {
   18.56 +                super(METHOD, new MethodType(mtype.argtypes, null, mtype.thrown, mtype.tsym));
   18.57 +                this.tvars = tvars;
   18.58 +                asMethodType().restype = new UninferredReturnType(tvars, mtype.restype);
   18.59 +            }
   18.60 +
   18.61 +            @Override
   18.62 +            public MethodType asMethodType() {
   18.63 +                return qtype.asMethodType();
   18.64 +            }
   18.65 +
   18.66 +            @Override
   18.67 +            public Type map(Mapping f) {
   18.68 +                return qtype.map(f);
   18.69 +            }
   18.70 +
   18.71 +            void instantiateReturnType(Type restype, List<Type> inferred, Types types) throws NoInstanceException {
   18.72 +                //update method type with newly inferred type-arguments
   18.73 +                qtype = new MethodType(types.subst(getParameterTypes(), tvars, inferred),
   18.74 +                                       restype,
   18.75 +                                       types.subst(UninferredMethodType.this.getThrownTypes(), tvars, inferred),
   18.76 +                                       UninferredMethodType.this.qtype.tsym);
   18.77 +                check(inferred, types);
   18.78 +            }
   18.79 +
   18.80 +            abstract void check(List<Type> inferred, Types types) throws NoInstanceException;
   18.81 +
   18.82 +            abstract List<Type> getConstraints(TypeVar tv, ConstraintKind ck);
   18.83 +
   18.84 +            class UninferredReturnType extends ForAll {
   18.85 +                public UninferredReturnType(List<Type> tvars, Type restype) {
   18.86 +                    super(tvars, restype);
   18.87 +                }
   18.88 +                @Override
   18.89 +                public Type inst(List<Type> actuals, Types types) {
   18.90 +                    Type newRestype = super.inst(actuals, types);
   18.91 +                    instantiateReturnType(newRestype, actuals, types);
   18.92 +                    return newRestype;
   18.93 +                }
   18.94 +                @Override
   18.95 +                public List<Type> getConstraints(TypeVar tv, ConstraintKind ck) {
   18.96 +                    return UninferredMethodType.this.getConstraints(tv, ck);
   18.97 +                }
   18.98 +            }
   18.99 +        }
  18.100 +
  18.101          private void checkArgumentsAcceptable(Env<AttrContext> env, List<Type> actuals, List<Type> formals,
  18.102                  boolean allowBoxing, boolean useVarargs, Warner warn) {
  18.103              try {
  18.104 @@ -518,25 +569,25 @@
  18.105              }
  18.106          }
  18.107  
  18.108 -        /** Try to instantiate argument type `that' to given type `to'.
  18.109 -         *  If this fails, try to insantiate `that' to `to' where
  18.110 -         *  every occurrence of a type variable in `tvars' is replaced
  18.111 -         *  by an unknown type.
  18.112 -         */
  18.113 -        private Type instantiateArg(ForAll that,
  18.114 -                                    Type to,
  18.115 -                                    List<Type> tvars,
  18.116 -                                    Warner warn) throws InferenceException {
  18.117 -            List<Type> targs;
  18.118 -            try {
  18.119 -                return instantiateExpr(that, to, warn);
  18.120 -            } catch (NoInstanceException ex) {
  18.121 -                Type to1 = to;
  18.122 -                for (List<Type> l = tvars; l.nonEmpty(); l = l.tail)
  18.123 -                    to1 = types.subst(to1, List.of(l.head), List.of(syms.unknownType));
  18.124 -                return instantiateExpr(that, to1, warn);
  18.125 -            }
  18.126 +    /** Try to instantiate argument type `that' to given type `to'.
  18.127 +     *  If this fails, try to insantiate `that' to `to' where
  18.128 +     *  every occurrence of a type variable in `tvars' is replaced
  18.129 +     *  by an unknown type.
  18.130 +     */
  18.131 +    private Type instantiateArg(ForAll that,
  18.132 +                                Type to,
  18.133 +                                List<Type> tvars,
  18.134 +                                Warner warn) throws InferenceException {
  18.135 +        List<Type> targs;
  18.136 +        try {
  18.137 +            return instantiateExpr(that, to, warn);
  18.138 +        } catch (NoInstanceException ex) {
  18.139 +            Type to1 = to;
  18.140 +            for (List<Type> l = tvars; l.nonEmpty(); l = l.tail)
  18.141 +                to1 = types.subst(to1, List.of(l.head), List.of(syms.unknownType));
  18.142 +            return instantiateExpr(that, to1, warn);
  18.143          }
  18.144 +    }
  18.145  
  18.146      /** check that type parameters are within their bounds.
  18.147       */
  18.148 @@ -616,4 +667,4 @@
  18.149                      return t;
  18.150                  }
  18.151          };
  18.152 -}
  18.153 +    }
    19.1 --- a/src/share/classes/com/sun/tools/javac/comp/Lower.java	Thu Mar 10 17:11:19 2011 -0800
    19.2 +++ b/src/share/classes/com/sun/tools/javac/comp/Lower.java	Thu Mar 10 20:51:07 2011 -0800
    19.3 @@ -2817,8 +2817,8 @@
    19.4                      // local class or this() call
    19.5                      thisArg = makeThis(tree.meth.pos(), c.type.getEnclosingType().tsym);
    19.6                  } else {
    19.7 -                    // super() call of nested class
    19.8 -                    thisArg = makeOwnerThis(tree.meth.pos(), c, false);
    19.9 +                    // super() call of nested class - never pick 'this'
   19.10 +                    thisArg = makeOwnerThisN(tree.meth.pos(), c, false);
   19.11                  }
   19.12                  tree.args = tree.args.prepend(thisArg);
   19.13              }
    20.1 --- a/src/share/classes/com/sun/tools/javac/comp/MemberEnter.java	Thu Mar 10 17:11:19 2011 -0800
    20.2 +++ b/src/share/classes/com/sun/tools/javac/comp/MemberEnter.java	Thu Mar 10 20:51:07 2011 -0800
    20.3 @@ -889,10 +889,11 @@
    20.4                  : (c.fullname == names.java_lang_Object)
    20.5                  ? Type.noType
    20.6                  : syms.objectType;
    20.7 -            ct.supertype_field = supertype;
    20.8 +            ct.supertype_field = modelMissingTypes(supertype, tree.extending, false);
    20.9  
   20.10              // Determine interfaces.
   20.11              ListBuffer<Type> interfaces = new ListBuffer<Type>();
   20.12 +            ListBuffer<Type> all_interfaces = null; // lazy init
   20.13              Set<Type> interfaceSet = new HashSet<Type>();
   20.14              List<JCExpression> interfaceTrees = tree.implementing;
   20.15              if ((tree.mods.flags & Flags.ENUM) != 0 && target.compilerBootstrap(c)) {
   20.16 @@ -909,13 +910,22 @@
   20.17                  Type i = attr.attribBase(iface, baseEnv, false, true, true);
   20.18                  if (i.tag == CLASS) {
   20.19                      interfaces.append(i);
   20.20 +                    if (all_interfaces != null) all_interfaces.append(i);
   20.21                      chk.checkNotRepeated(iface.pos(), types.erasure(i), interfaceSet);
   20.22 +                } else {
   20.23 +                    if (all_interfaces == null)
   20.24 +                        all_interfaces = new ListBuffer<Type>().appendList(interfaces);
   20.25 +                    all_interfaces.append(modelMissingTypes(i, iface, true));
   20.26                  }
   20.27              }
   20.28 -            if ((c.flags_field & ANNOTATION) != 0)
   20.29 +            if ((c.flags_field & ANNOTATION) != 0) {
   20.30                  ct.interfaces_field = List.of(syms.annotationType);
   20.31 -            else
   20.32 +                ct.all_interfaces_field = ct.interfaces_field;
   20.33 +            }  else {
   20.34                  ct.interfaces_field = interfaces.toList();
   20.35 +                ct.all_interfaces_field = (all_interfaces == null)
   20.36 +                        ? ct.interfaces_field : all_interfaces.toList();
   20.37 +            }
   20.38  
   20.39              if (c.fullname == names.java_lang_Object) {
   20.40                  if (tree.extending != null) {
   20.41 @@ -1066,6 +1076,125 @@
   20.42          return result;
   20.43      }
   20.44  
   20.45 +    Type modelMissingTypes(Type t, final JCExpression tree, final boolean interfaceExpected) {
   20.46 +        if (t.tag != ERROR)
   20.47 +            return t;
   20.48 +
   20.49 +        return new ErrorType(((ErrorType) t).getOriginalType(), t.tsym) {
   20.50 +            private Type modelType;
   20.51 +
   20.52 +            @Override
   20.53 +            public Type getModelType() {
   20.54 +                if (modelType == null)
   20.55 +                    modelType = new Synthesizer(getOriginalType(), interfaceExpected).visit(tree);
   20.56 +                return modelType;
   20.57 +            }
   20.58 +        };
   20.59 +    }
   20.60 +    // where
   20.61 +    private class Synthesizer extends JCTree.Visitor {
   20.62 +        Type originalType;
   20.63 +        boolean interfaceExpected;
   20.64 +        List<ClassSymbol> synthesizedSymbols = List.nil();
   20.65 +        Type result;
   20.66 +
   20.67 +        Synthesizer(Type originalType, boolean interfaceExpected) {
   20.68 +            this.originalType = originalType;
   20.69 +            this.interfaceExpected = interfaceExpected;
   20.70 +        }
   20.71 +
   20.72 +        Type visit(JCTree tree) {
   20.73 +            tree.accept(this);
   20.74 +            return result;
   20.75 +        }
   20.76 +
   20.77 +        List<Type> visit(List<? extends JCTree> trees) {
   20.78 +            ListBuffer<Type> lb = new ListBuffer<Type>();
   20.79 +            for (JCTree t: trees)
   20.80 +                lb.append(visit(t));
   20.81 +            return lb.toList();
   20.82 +        }
   20.83 +
   20.84 +        @Override
   20.85 +        public void visitTree(JCTree tree) {
   20.86 +            result = syms.errType;
   20.87 +        }
   20.88 +
   20.89 +        @Override
   20.90 +        public void visitIdent(JCIdent tree) {
   20.91 +            if (tree.type.tag != ERROR) {
   20.92 +                result = tree.type;
   20.93 +            } else {
   20.94 +                result = synthesizeClass(tree.name, syms.unnamedPackage).type;
   20.95 +            }
   20.96 +        }
   20.97 +
   20.98 +        @Override
   20.99 +        public void visitSelect(JCFieldAccess tree) {
  20.100 +            if (tree.type.tag != ERROR) {
  20.101 +                result = tree.type;
  20.102 +            } else {
  20.103 +                Type selectedType;
  20.104 +                boolean prev = interfaceExpected;
  20.105 +                try {
  20.106 +                    interfaceExpected = false;
  20.107 +                    selectedType = visit(tree.selected);
  20.108 +                } finally {
  20.109 +                    interfaceExpected = prev;
  20.110 +                }
  20.111 +                ClassSymbol c = synthesizeClass(tree.name, selectedType.tsym);
  20.112 +                result = c.type;
  20.113 +            }
  20.114 +        }
  20.115 +
  20.116 +        @Override
  20.117 +        public void visitTypeApply(JCTypeApply tree) {
  20.118 +            if (tree.type.tag != ERROR) {
  20.119 +                result = tree.type;
  20.120 +            } else {
  20.121 +                ClassType clazzType = (ClassType) visit(tree.clazz);
  20.122 +                if (synthesizedSymbols.contains(clazzType.tsym))
  20.123 +                    synthesizeTyparams((ClassSymbol) clazzType.tsym, tree.arguments.size());
  20.124 +                final List<Type> actuals = visit(tree.arguments);
  20.125 +                result = new ErrorType(tree.type, clazzType.tsym) {
  20.126 +                    @Override
  20.127 +                    public List<Type> getTypeArguments() {
  20.128 +                        return actuals;
  20.129 +                    }
  20.130 +                };
  20.131 +            }
  20.132 +        }
  20.133 +
  20.134 +        ClassSymbol synthesizeClass(Name name, Symbol owner) {
  20.135 +            int flags = interfaceExpected ? INTERFACE : 0;
  20.136 +            ClassSymbol c = new ClassSymbol(flags, name, owner);
  20.137 +            c.members_field = new Scope.ErrorScope(c);
  20.138 +            c.type = new ErrorType(originalType, c) {
  20.139 +                @Override
  20.140 +                public List<Type> getTypeArguments() {
  20.141 +                    return typarams_field;
  20.142 +                }
  20.143 +            };
  20.144 +            synthesizedSymbols = synthesizedSymbols.prepend(c);
  20.145 +            return c;
  20.146 +        }
  20.147 +
  20.148 +        void synthesizeTyparams(ClassSymbol sym, int n) {
  20.149 +            ClassType ct = (ClassType) sym.type;
  20.150 +            Assert.check(ct.typarams_field.isEmpty());
  20.151 +            if (n == 1) {
  20.152 +                TypeVar v = new TypeVar(names.fromString("T"), sym, syms.botType);
  20.153 +                ct.typarams_field = ct.typarams_field.prepend(v);
  20.154 +            } else {
  20.155 +                for (int i = n; i > 0; i--) {
  20.156 +                    TypeVar v = new TypeVar(names.fromString("T" + i), sym, syms.botType);
  20.157 +                    ct.typarams_field = ct.typarams_field.prepend(v);
  20.158 +                }
  20.159 +            }
  20.160 +        }
  20.161 +    }
  20.162 +
  20.163 +
  20.164  /* ***************************************************************************
  20.165   * tree building
  20.166   ****************************************************************************/
    21.1 --- a/src/share/classes/com/sun/tools/javac/comp/Resolve.java	Thu Mar 10 17:11:19 2011 -0800
    21.2 +++ b/src/share/classes/com/sun/tools/javac/comp/Resolve.java	Thu Mar 10 20:51:07 2011 -0800
    21.3 @@ -45,7 +45,9 @@
    21.4  import javax.lang.model.element.ElementVisitor;
    21.5  
    21.6  import java.util.Map;
    21.7 +import java.util.Set;
    21.8  import java.util.HashMap;
    21.9 +import java.util.HashSet;
   21.10  
   21.11  /** Helper class for name resolution, used mostly by the attribution phase.
   21.12   *
   21.13 @@ -896,7 +898,8 @@
   21.14                            bestSoFar,
   21.15                            allowBoxing,
   21.16                            useVarargs,
   21.17 -                          operator);
   21.18 +                          operator,
   21.19 +                          new HashSet<TypeSymbol>());
   21.20      }
   21.21      // where
   21.22      private Symbol findMethod(Env<AttrContext> env,
   21.23 @@ -909,11 +912,13 @@
   21.24                                Symbol bestSoFar,
   21.25                                boolean allowBoxing,
   21.26                                boolean useVarargs,
   21.27 -                              boolean operator) {
   21.28 +                              boolean operator,
   21.29 +                              Set<TypeSymbol> seen) {
   21.30          for (Type ct = intype; ct.tag == CLASS || ct.tag == TYPEVAR; ct = types.supertype(ct)) {
   21.31              while (ct.tag == TYPEVAR)
   21.32                  ct = ct.getUpperBound();
   21.33              ClassSymbol c = (ClassSymbol)ct.tsym;
   21.34 +            if (!seen.add(c)) return bestSoFar;
   21.35              if ((c.flags() & (ABSTRACT | INTERFACE | ENUM)) == 0)
   21.36                  abstractok = false;
   21.37              for (Scope.Entry e = c.members().lookup(name);
   21.38 @@ -942,7 +947,7 @@
   21.39                      bestSoFar = findMethod(env, site, name, argtypes,
   21.40                                             typeargtypes,
   21.41                                             l.head, abstractok, bestSoFar,
   21.42 -                                           allowBoxing, useVarargs, operator);
   21.43 +                                           allowBoxing, useVarargs, operator, seen);
   21.44                  }
   21.45                  if (concrete != bestSoFar &&
   21.46                      concrete.kind < ERR  && bestSoFar.kind < ERR &&
   21.47 @@ -1736,24 +1741,26 @@
   21.48       */
   21.49      Symbol resolveSelfContaining(DiagnosticPosition pos,
   21.50                                   Env<AttrContext> env,
   21.51 -                                 Symbol member) {
   21.52 +                                 Symbol member,
   21.53 +                                 boolean isSuperCall) {
   21.54          Name name = names._this;
   21.55 -        Env<AttrContext> env1 = env;
   21.56 +        Env<AttrContext> env1 = isSuperCall ? env.outer : env;
   21.57          boolean staticOnly = false;
   21.58 -        while (env1.outer != null) {
   21.59 -            if (isStatic(env1)) staticOnly = true;
   21.60 -            if (env1.enclClass.sym.isSubClass(member.owner, types) &&
   21.61 -                isAccessible(env, env1.enclClass.sym.type, member)) {
   21.62 -                Symbol sym = env1.info.scope.lookup(name).sym;
   21.63 -                if (sym != null) {
   21.64 -                    if (staticOnly) sym = new StaticError(sym);
   21.65 -                    return access(sym, pos, env.enclClass.sym.type,
   21.66 -                                  name, true);
   21.67 +        if (env1 != null) {
   21.68 +            while (env1 != null && env1.outer != null) {
   21.69 +                if (isStatic(env1)) staticOnly = true;
   21.70 +                if (env1.enclClass.sym.isSubClass(member.owner, types)) {
   21.71 +                    Symbol sym = env1.info.scope.lookup(name).sym;
   21.72 +                    if (sym != null) {
   21.73 +                        if (staticOnly) sym = new StaticError(sym);
   21.74 +                        return access(sym, pos, env.enclClass.sym.type,
   21.75 +                                      name, true);
   21.76 +                    }
   21.77                  }
   21.78 +                if ((env1.enclClass.sym.flags() & STATIC) != 0)
   21.79 +                    staticOnly = true;
   21.80 +                env1 = env1.outer;
   21.81              }
   21.82 -            if ((env1.enclClass.sym.flags() & STATIC) != 0)
   21.83 -                staticOnly = true;
   21.84 -            env1 = env1.outer;
   21.85          }
   21.86          log.error(pos, "encl.class.required", member);
   21.87          return syms.errSymbol;
   21.88 @@ -1764,9 +1771,13 @@
   21.89       * JLS2 8.8.5.1 and 15.9.2
   21.90       */
   21.91      Type resolveImplicitThis(DiagnosticPosition pos, Env<AttrContext> env, Type t) {
   21.92 +        return resolveImplicitThis(pos, env, t, false);
   21.93 +    }
   21.94 +
   21.95 +    Type resolveImplicitThis(DiagnosticPosition pos, Env<AttrContext> env, Type t, boolean isSuperCall) {
   21.96          Type thisType = (((t.tsym.owner.kind & (MTH|VAR)) != 0)
   21.97                           ? resolveSelf(pos, env, t.getEnclosingType().tsym, names._this)
   21.98 -                         : resolveSelfContaining(pos, env, t.tsym)).type;
   21.99 +                         : resolveSelfContaining(pos, env, t.tsym, isSuperCall)).type;
  21.100          if (env.info.isSelfCall && thisType.tsym == env.enclClass.sym)
  21.101              log.error(pos, "cant.ref.before.ctor.called", "this");
  21.102          return thisType;
    22.1 --- a/src/share/classes/com/sun/tools/javac/file/CacheFSInfo.java	Thu Mar 10 17:11:19 2011 -0800
    22.2 +++ b/src/share/classes/com/sun/tools/javac/file/CacheFSInfo.java	Thu Mar 10 20:51:07 2011 -0800
    22.3 @@ -44,13 +44,13 @@
    22.4  public class CacheFSInfo extends FSInfo {
    22.5  
    22.6      /**
    22.7 -     * Register a Context.Factory to create a singleton CacheFSInfo.
    22.8 +     * Register a Context.Factory to create a CacheFSInfo.
    22.9       */
   22.10 -    public static void preRegister(final Context context) {
   22.11 +    public static void preRegister(Context context) {
   22.12          context.put(FSInfo.class, new Context.Factory<FSInfo>() {
   22.13 -            public FSInfo make() {
   22.14 +            public FSInfo make(Context c) {
   22.15                  FSInfo instance = new CacheFSInfo();
   22.16 -                context.put(FSInfo.class, instance);
   22.17 +                c.put(FSInfo.class, instance);
   22.18                  return instance;
   22.19              }
   22.20          });
    23.1 --- a/src/share/classes/com/sun/tools/javac/file/JavacFileManager.java	Thu Mar 10 17:11:19 2011 -0800
    23.2 +++ b/src/share/classes/com/sun/tools/javac/file/JavacFileManager.java	Thu Mar 10 20:51:07 2011 -0800
    23.3 @@ -129,10 +129,10 @@
    23.4      /**
    23.5       * Register a Context.Factory to create a JavacFileManager.
    23.6       */
    23.7 -    public static void preRegister(final Context context) {
    23.8 +    public static void preRegister(Context context) {
    23.9          context.put(JavaFileManager.class, new Context.Factory<JavaFileManager>() {
   23.10 -            public JavaFileManager make() {
   23.11 -                return new JavacFileManager(context, true, null);
   23.12 +            public JavaFileManager make(Context c) {
   23.13 +                return new JavacFileManager(c, true, null);
   23.14              }
   23.15          });
   23.16      }
    24.1 --- a/src/share/classes/com/sun/tools/javac/jvm/ClassReader.java	Thu Mar 10 17:11:19 2011 -0800
    24.2 +++ b/src/share/classes/com/sun/tools/javac/jvm/ClassReader.java	Thu Mar 10 20:51:07 2011 -0800
    24.3 @@ -2183,7 +2183,7 @@
    24.4                  }
    24.5                  currentClassFile = classfile;
    24.6                  if (verbose) {
    24.7 -                    printVerbose("loading", currentClassFile.toString());
    24.8 +                    log.printVerbose("loading", currentClassFile.toString());
    24.9                  }
   24.10                  if (classfile.getKind() == JavaFileObject.Kind.CLASS) {
   24.11                      filling = true;
   24.12 @@ -2452,13 +2452,13 @@
   24.13                      for (File file : fm.getLocation(SOURCE_PATH)) {
   24.14                          path = path.prepend(file);
   24.15                      }
   24.16 -                    printVerbose("sourcepath", path.reverse().toString());
   24.17 +                    log.printVerbose("sourcepath", path.reverse().toString());
   24.18                  } else if (wantSourceFiles) {
   24.19                      List<File> path = List.nil();
   24.20                      for (File file : fm.getLocation(CLASS_PATH)) {
   24.21                          path = path.prepend(file);
   24.22                      }
   24.23 -                    printVerbose("sourcepath", path.reverse().toString());
   24.24 +                    log.printVerbose("sourcepath", path.reverse().toString());
   24.25                  }
   24.26                  if (wantClassFiles) {
   24.27                      List<File> path = List.nil();
   24.28 @@ -2468,7 +2468,7 @@
   24.29                      for (File file : fm.getLocation(CLASS_PATH)) {
   24.30                          path = path.prepend(file);
   24.31                      }
   24.32 -                    printVerbose("classpath",  path.reverse().toString());
   24.33 +                    log.printVerbose("classpath",  path.reverse().toString());
   24.34                  }
   24.35              }
   24.36          }
   24.37 @@ -2519,14 +2519,6 @@
   24.38              }
   24.39          }
   24.40  
   24.41 -    /** Output for "-verbose" option.
   24.42 -     *  @param key The key to look up the correct internationalized string.
   24.43 -     *  @param arg An argument for substitution into the output string.
   24.44 -     */
   24.45 -    private void printVerbose(String key, CharSequence arg) {
   24.46 -        log.printNoteLines("verbose." + key, arg);
   24.47 -    }
   24.48 -
   24.49      /** Output for "-checkclassfile" option.
   24.50       *  @param key The key to look up the correct internationalized string.
   24.51       *  @param arg An argument for substitution into the output string.
    25.1 --- a/src/share/classes/com/sun/tools/javac/jvm/ClassWriter.java	Thu Mar 10 17:11:19 2011 -0800
    25.2 +++ b/src/share/classes/com/sun/tools/javac/jvm/ClassWriter.java	Thu Mar 10 20:51:07 2011 -0800
    25.3 @@ -1447,7 +1447,7 @@
    25.4          try {
    25.5              writeClassFile(out, c);
    25.6              if (verbose)
    25.7 -                log.printErrLines("verbose.wrote.file", outFile);
    25.8 +                log.printVerbose("wrote.file", outFile);
    25.9              out.close();
   25.10              out = null;
   25.11          } finally {
    26.1 --- a/src/share/classes/com/sun/tools/javac/main/JavaCompiler.java	Thu Mar 10 17:11:19 2011 -0800
    26.2 +++ b/src/share/classes/com/sun/tools/javac/main/JavaCompiler.java	Thu Mar 10 20:51:07 2011 -0800
    26.3 @@ -299,6 +299,13 @@
    26.4      protected JavaCompiler delegateCompiler;
    26.5  
    26.6      /**
    26.7 +     * Command line options.
    26.8 +     */
    26.9 +    protected Options options;
   26.10 +
   26.11 +    protected Context context;
   26.12 +
   26.13 +    /**
   26.14       * Flag set if any annotation processing occurred.
   26.15       **/
   26.16      protected boolean annotationProcessingOccurred;
   26.17 @@ -308,11 +315,9 @@
   26.18       **/
   26.19      protected boolean implicitSourceFilesRead;
   26.20  
   26.21 -    protected Context context;
   26.22 -
   26.23      /** Construct a new compiler using a shared context.
   26.24       */
   26.25 -    public JavaCompiler(final Context context) {
   26.26 +    public JavaCompiler(Context context) {
   26.27          this.context = context;
   26.28          context.put(compilerKey, this);
   26.29  
   26.30 @@ -354,7 +359,7 @@
   26.31  
   26.32          reader.sourceCompleter = this;
   26.33  
   26.34 -        Options options = Options.instance(context);
   26.35 +        options = Options.instance(context);
   26.36  
   26.37          verbose       = options.isSet(VERBOSE);
   26.38          sourceOutput  = options.isSet(PRINTSOURCE); // used to be -s
   26.39 @@ -580,7 +585,7 @@
   26.40                                        null, List.<JCTree>nil());
   26.41          if (content != null) {
   26.42              if (verbose) {
   26.43 -                printVerbose("parsing.started", filename);
   26.44 +                log.printVerbose("parsing.started", filename);
   26.45              }
   26.46              if (taskListener != null) {
   26.47                  TaskEvent e = new TaskEvent(TaskEvent.Kind.PARSE, filename);
   26.48 @@ -589,7 +594,7 @@
   26.49              Parser parser = parserFactory.newParser(content, keepComments(), genEndPos, lineDebugInfo);
   26.50              tree = parser.parseCompilationUnit();
   26.51              if (verbose) {
   26.52 -                printVerbose("parsing.done", Long.toString(elapsed(msec)));
   26.53 +                log.printVerbose("parsing.done", Long.toString(elapsed(msec)));
   26.54              }
   26.55          }
   26.56  
   26.57 @@ -676,7 +681,7 @@
   26.58              try {
   26.59                  new Pretty(out, true).printUnit(env.toplevel, cdef);
   26.60                  if (verbose)
   26.61 -                    printVerbose("wrote.file", outFile);
   26.62 +                    log.printVerbose("wrote.file", outFile);
   26.63              } finally {
   26.64                  out.close();
   26.65              }
   26.66 @@ -792,6 +797,11 @@
   26.67              throw new AssertionError("attempt to reuse JavaCompiler");
   26.68          hasBeenUsed = true;
   26.69  
   26.70 +        // forcibly set the equivalent of -Xlint:-options, so that no further
   26.71 +        // warnings about command line options are generated from this point on
   26.72 +        options.put(XLINT_CUSTOM + "-" + LintCategory.OPTIONS.option, "true");
   26.73 +        options.remove(XLINT_CUSTOM + LintCategory.OPTIONS.option);
   26.74 +
   26.75          start_msec = now();
   26.76  
   26.77          try {
   26.78 @@ -857,7 +867,7 @@
   26.79  
   26.80          if (verbose) {
   26.81              elapsed_msec = elapsed(start_msec);
   26.82 -            printVerbose("total", Long.toString(elapsed_msec));
   26.83 +            log.printVerbose("total", Long.toString(elapsed_msec));
   26.84          }
   26.85  
   26.86          reportDeferredDiagnostics();
   26.87 @@ -963,7 +973,6 @@
   26.88      public void initProcessAnnotations(Iterable<? extends Processor> processors) {
   26.89          // Process annotations if processing is not disabled and there
   26.90          // is at least one Processor available.
   26.91 -        Options options = Options.instance(context);
   26.92          if (options.isSet(PROC, "none")) {
   26.93              processAnnotations = false;
   26.94          } else if (procEnvImpl == null) {
   26.95 @@ -1022,7 +1031,6 @@
   26.96              // If there are no annotation processors present, and
   26.97              // annotation processing is to occur with compilation,
   26.98              // emit a warning.
   26.99 -            Options options = Options.instance(context);
  26.100              if (options.isSet(PROC, "only")) {
  26.101                  log.warning("proc.proc-only.requested.no.procs");
  26.102                  todo.clear();
  26.103 @@ -1108,9 +1116,13 @@
  26.104      }
  26.105  
  26.106      boolean explicitAnnotationProcessingRequested() {
  26.107 -        Options options = Options.instance(context);
  26.108          return
  26.109              explicitAnnotationProcessingRequested ||
  26.110 +            explicitAnnotationProcessingRequested(options);
  26.111 +    }
  26.112 +
  26.113 +    static boolean explicitAnnotationProcessingRequested(Options options) {
  26.114 +        return
  26.115              options.isSet(PROCESSOR) ||
  26.116              options.isSet(PROCESSORPATH) ||
  26.117              options.isSet(PROC, "only") ||
  26.118 @@ -1142,7 +1154,7 @@
  26.119          if (verboseCompilePolicy)
  26.120              printNote("[attribute " + env.enclClass.sym + "]");
  26.121          if (verbose)
  26.122 -            printVerbose("checking.attribution", env.enclClass.sym);
  26.123 +            log.printVerbose("checking.attribution", env.enclClass.sym);
  26.124  
  26.125          if (taskListener != null) {
  26.126              TaskEvent e = new TaskEvent(TaskEvent.Kind.ANALYZE, env.toplevel, env.enclClass.sym);
  26.127 @@ -1508,7 +1520,8 @@
  26.128          }
  26.129  
  26.130      public void reportDeferredDiagnostics() {
  26.131 -        if (annotationProcessingOccurred
  26.132 +        if (errorCount() == 0
  26.133 +                && annotationProcessingOccurred
  26.134                  && implicitSourceFilesRead
  26.135                  && implicitSourcePolicy == ImplicitSourcePolicy.UNSET) {
  26.136              if (explicitAnnotationProcessingRequested())
  26.137 @@ -1562,14 +1575,6 @@
  26.138          Log.printLines(log.noticeWriter, lines);
  26.139      }
  26.140  
  26.141 -    /** Output for "-verbose" option.
  26.142 -     *  @param key The key to look up the correct internationalized string.
  26.143 -     *  @param arg An argument for substitution into the output string.
  26.144 -     */
  26.145 -    protected void printVerbose(String key, Object arg) {
  26.146 -        log.printNoteLines("verbose." + key, arg);
  26.147 -    }
  26.148 -
  26.149      /** Print numbers of errors and warnings.
  26.150       */
  26.151      protected void printCount(String kind, int count) {
    27.1 --- a/src/share/classes/com/sun/tools/javac/main/Main.java	Thu Mar 10 17:11:19 2011 -0800
    27.2 +++ b/src/share/classes/com/sun/tools/javac/main/Main.java	Thu Mar 10 20:51:07 2011 -0800
    27.3 @@ -1,5 +1,5 @@
    27.4  /*
    27.5 - * Copyright (c) 1999, 2010, Oracle and/or its affiliates. All rights reserved.
    27.6 + * Copyright (c) 1999, 2011, Oracle and/or its affiliates. All rights reserved.
    27.7   * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
    27.8   *
    27.9   * This code is free software; you can redistribute it and/or modify it
   27.10 @@ -367,7 +367,11 @@
   27.11                          || options.isSet(VERSION)
   27.12                          || options.isSet(FULLVERSION))
   27.13                          return EXIT_OK;
   27.14 -                    error("err.no.source.files");
   27.15 +                    if (JavaCompiler.explicitAnnotationProcessingRequested(options)) {
   27.16 +                        error("err.no.source.files.classes");
   27.17 +                    } else {
   27.18 +                        error("err.no.source.files");
   27.19 +                    }
   27.20                      return EXIT_CMDERR;
   27.21                  }
   27.22              } catch (java.io.FileNotFoundException e) {
    28.1 --- a/src/share/classes/com/sun/tools/javac/main/OptionName.java	Thu Mar 10 17:11:19 2011 -0800
    28.2 +++ b/src/share/classes/com/sun/tools/javac/main/OptionName.java	Thu Mar 10 20:51:07 2011 -0800
    28.3 @@ -88,6 +88,7 @@
    28.4      O("-O"),
    28.5      XJCOV("-Xjcov"),
    28.6      XD("-XD"),
    28.7 +    AT("@"),
    28.8      SOURCEFILE("sourcefile");
    28.9  
   28.10      public final String optionName;
    29.1 --- a/src/share/classes/com/sun/tools/javac/main/RecognizedOptions.java	Thu Mar 10 17:11:19 2011 -0800
    29.2 +++ b/src/share/classes/com/sun/tools/javac/main/RecognizedOptions.java	Thu Mar 10 20:51:07 2011 -0800
    29.3 @@ -168,6 +168,7 @@
    29.4          O,
    29.5          XJCOV,
    29.6          XD,
    29.7 +        AT,
    29.8          SOURCEFILE);
    29.9  
   29.10      static Set<OptionName> javacFileManagerOptions = EnumSet.of(
   29.11 @@ -565,12 +566,27 @@
   29.12              }
   29.13          },
   29.14  
   29.15 +        // This option exists only for the purpose of documenting itself.
   29.16 +        // It's actually implemented by the CommandLine class.
   29.17 +        new Option(AT,                   "opt.arg.file",         "opt.AT") {
   29.18 +            @Override
   29.19 +            String helpSynopsis() {
   29.20 +                hasSuffix = true;
   29.21 +                return super.helpSynopsis();
   29.22 +            }
   29.23 +            @Override
   29.24 +            public boolean process(Options options, String option) {
   29.25 +                throw new AssertionError
   29.26 +                    ("the @ flag should be caught by CommandLine.");
   29.27 +            }
   29.28 +        },
   29.29 +
   29.30          /*
   29.31           * TODO: With apt, the matches method accepts anything if
   29.32           * -XclassAsDecls is used; code elsewhere does the lookup to
   29.33           * see if the class name is both legal and found.
   29.34           *
   29.35 -         * In apt, the process method adds the candiate class file
   29.36 +         * In apt, the process method adds the candidate class file
   29.37           * name to a separate list.
   29.38           */
   29.39          new HiddenOption(SOURCEFILE) {
    30.1 --- a/src/share/classes/com/sun/tools/javac/parser/JavacParser.java	Thu Mar 10 17:11:19 2011 -0800
    30.2 +++ b/src/share/classes/com/sun/tools/javac/parser/JavacParser.java	Thu Mar 10 20:51:07 2011 -0800
    30.3 @@ -2357,7 +2357,7 @@
    30.4  
    30.5          List<JCTypeParameter> typarams = typeParametersOpt();
    30.6  
    30.7 -        JCTree extending = null;
    30.8 +        JCExpression extending = null;
    30.9          if (S.token() == EXTENDS) {
   30.10              S.nextToken();
   30.11              extending = parseType();
    31.1 --- a/src/share/classes/com/sun/tools/javac/processing/JavacProcessingEnvironment.java	Thu Mar 10 17:11:19 2011 -0800
    31.2 +++ b/src/share/classes/com/sun/tools/javac/processing/JavacProcessingEnvironment.java	Thu Mar 10 20:51:07 2011 -0800
    31.3 @@ -807,8 +807,6 @@
    31.4          final JavaCompiler compiler;
    31.5          /** The log for the round. */
    31.6          final Log log;
    31.7 -        /** The number of warnings in the previous round. */
    31.8 -        final int priorWarnings;
    31.9  
   31.10          /** The ASTs to be compiled. */
   31.11          List<JCCompilationUnit> roots;
   31.12 @@ -826,10 +824,10 @@
   31.13          private Round(Context context, int number, int priorWarnings) {
   31.14              this.context = context;
   31.15              this.number = number;
   31.16 -            this.priorWarnings = priorWarnings;
   31.17  
   31.18              compiler = JavaCompiler.instance(context);
   31.19              log = Log.instance(context);
   31.20 +            log.nwarnings += priorWarnings;
   31.21              log.deferDiagnostics = true;
   31.22  
   31.23              // the following is for the benefit of JavacProcessingEnvironment.getContext()
   31.24 @@ -904,8 +902,8 @@
   31.25          JavaCompiler finalCompiler(boolean errorStatus) {
   31.26              try {
   31.27                  JavaCompiler c = JavaCompiler.instance(nextContext());
   31.28 +                c.log.nwarnings += compiler.log.nwarnings;
   31.29                  if (errorStatus) {
   31.30 -                    c.log.nwarnings += priorWarnings + compiler.log.nwarnings;
   31.31                      c.log.nerrors += compiler.log.nerrors;
   31.32                  }
   31.33                  return c;
   31.34 @@ -1045,7 +1043,7 @@
   31.35           * other values are implicitly reset.
   31.36           */
   31.37          private Context nextContext() {
   31.38 -            Context next = new Context();
   31.39 +            Context next = new Context(context);
   31.40  
   31.41              Options options = Options.instance(context);
   31.42              Assert.checkNonNull(options);
    32.1 --- a/src/share/classes/com/sun/tools/javac/resources/compiler.properties	Thu Mar 10 17:11:19 2011 -0800
    32.2 +++ b/src/share/classes/com/sun/tools/javac/resources/compiler.properties	Thu Mar 10 20:51:07 2011 -0800
    32.3 @@ -1588,14 +1588,6 @@
    32.4  compiler.misc.diamond.non.generic=\
    32.5      cannot use ''<>'' with non-generic class {0}
    32.6  
    32.7 -# 0: list of type, 1: message segment
    32.8 -compiler.misc.diamond.invalid.arg=\
    32.9 -    type argument {0} inferred for {1} is not allowed in this context
   32.10 -
   32.11 -# 0: list of type, 1: message segment
   32.12 -compiler.misc.diamond.invalid.args=\
   32.13 -    type arguments {0} inferred for {1} are not allowed in this context
   32.14 -
   32.15  # 0: type, 1: list of type
   32.16  compiler.misc.explicit.param.do.not.conform.to.bounds=\
   32.17      explicit type argument {0} does not conform to declared bound(s) {1}
   32.18 @@ -1803,8 +1795,8 @@
   32.19  compiler.misc.varargs.clash.with=\
   32.20      {0} in {1} overrides {2} in {3}
   32.21  
   32.22 -compiler.misc.non.denotable.type=\
   32.23 -    Non-denotable type {0} not allowed here
   32.24 +compiler.misc.diamond.and.anon.class=\
   32.25 +    cannot use ''<>'' with anonymous inner classes
   32.26  
   32.27  # 0: symbol kind, 1: symbol, 2: symbol, 3: message segment
   32.28  compiler.misc.inapplicable.method=\
    33.1 --- a/src/share/classes/com/sun/tools/javac/resources/javac.properties	Thu Mar 10 17:11:19 2011 -0800
    33.2 +++ b/src/share/classes/com/sun/tools/javac/resources/javac.properties	Thu Mar 10 20:51:07 2011 -0800
    33.3 @@ -1,5 +1,5 @@
    33.4  #
    33.5 -# Copyright (c) 1999, 2010, Oracle and/or its affiliates. All rights reserved.
    33.6 +# Copyright (c) 1999, 2011, Oracle and/or its affiliates. All rights reserved.
    33.7  # DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
    33.8  #
    33.9  # This code is free software; you can redistribute it and/or modify it
   33.10 @@ -146,6 +146,8 @@
   33.11      Print information about which annotations a processor is asked to process
   33.12  javac.opt.prefer=\
   33.13      Specify which file to read when both a source file and class file are found for an implicitly compiled class
   33.14 +javac.opt.AT=\
   33.15 +    Read options and filenames from file
   33.16  
   33.17  ## errors
   33.18  
   33.19 @@ -161,6 +163,8 @@
   33.20      invalid target release: {0}
   33.21  javac.err.no.source.files=\
   33.22      no source files
   33.23 +javac.err.no.source.files.classes=\
   33.24 +    no source files or class names
   33.25  javac.err.req.arg=\
   33.26      {0} requires an argument
   33.27  javac.err.invalid.source=\
    34.1 --- a/src/share/classes/com/sun/tools/javac/tree/JCTree.java	Thu Mar 10 17:11:19 2011 -0800
    34.2 +++ b/src/share/classes/com/sun/tools/javac/tree/JCTree.java	Thu Mar 10 20:51:07 2011 -0800
    34.3 @@ -567,14 +567,14 @@
    34.4          public JCModifiers mods;
    34.5          public Name name;
    34.6          public List<JCTypeParameter> typarams;
    34.7 -        public JCTree extending;
    34.8 +        public JCExpression extending;
    34.9          public List<JCExpression> implementing;
   34.10          public List<JCTree> defs;
   34.11          public ClassSymbol sym;
   34.12          protected JCClassDecl(JCModifiers mods,
   34.13                             Name name,
   34.14                             List<JCTypeParameter> typarams,
   34.15 -                           JCTree extending,
   34.16 +                           JCExpression extending,
   34.17                             List<JCExpression> implementing,
   34.18                             List<JCTree> defs,
   34.19                             ClassSymbol sym)
   34.20 @@ -2104,7 +2104,7 @@
   34.21          JCClassDecl ClassDef(JCModifiers mods,
   34.22                            Name name,
   34.23                            List<JCTypeParameter> typarams,
   34.24 -                          JCTree extending,
   34.25 +                          JCExpression extending,
   34.26                            List<JCExpression> implementing,
   34.27                            List<JCTree> defs);
   34.28          JCMethodDecl MethodDef(JCModifiers mods,
    35.1 --- a/src/share/classes/com/sun/tools/javac/tree/TreeCopier.java	Thu Mar 10 17:11:19 2011 -0800
    35.2 +++ b/src/share/classes/com/sun/tools/javac/tree/TreeCopier.java	Thu Mar 10 20:51:07 2011 -0800
    35.3 @@ -135,7 +135,7 @@
    35.4          JCClassDecl t = (JCClassDecl) node;
    35.5          JCModifiers mods = copy(t.mods, p);
    35.6          List<JCTypeParameter> typarams = copy(t.typarams, p);
    35.7 -        JCTree extending = copy(t.extending, p);
    35.8 +        JCExpression extending = copy(t.extending, p);
    35.9          List<JCExpression> implementing = copy(t.implementing, p);
   35.10          List<JCTree> defs = copy(t.defs, p);
   35.11          return M.at(t.pos).ClassDef(mods, t.name, typarams, extending, implementing, defs);
    36.1 --- a/src/share/classes/com/sun/tools/javac/tree/TreeMaker.java	Thu Mar 10 17:11:19 2011 -0800
    36.2 +++ b/src/share/classes/com/sun/tools/javac/tree/TreeMaker.java	Thu Mar 10 20:51:07 2011 -0800
    36.3 @@ -146,7 +146,7 @@
    36.4      public JCClassDecl ClassDef(JCModifiers mods,
    36.5                                  Name name,
    36.6                                  List<JCTypeParameter> typarams,
    36.7 -                                JCTree extending,
    36.8 +                                JCExpression extending,
    36.9                                  List<JCExpression> implementing,
   36.10                                  List<JCTree> defs)
   36.11      {
    37.1 --- a/src/share/classes/com/sun/tools/javac/util/Context.java	Thu Mar 10 17:11:19 2011 -0800
    37.2 +++ b/src/share/classes/com/sun/tools/javac/util/Context.java	Thu Mar 10 20:51:07 2011 -0800
    37.3 @@ -108,7 +108,7 @@
    37.4       * instance.
    37.5       */
    37.6      public static interface Factory<T> {
    37.7 -        T make();
    37.8 +        T make(Context c);
    37.9      };
   37.10  
   37.11      /**
   37.12 @@ -124,6 +124,8 @@
   37.13          Object old = ht.put(key, fac);
   37.14          if (old != null)
   37.15              throw new AssertionError("duplicate context value");
   37.16 +        checkState(ft);
   37.17 +        ft.put(key, fac); // cannot be duplicate if unique in ht
   37.18      }
   37.19  
   37.20      /** Set the value for the key in this context. */
   37.21 @@ -142,7 +144,7 @@
   37.22          Object o = ht.get(key);
   37.23          if (o instanceof Factory<?>) {
   37.24              Factory<?> fac = (Factory<?>)o;
   37.25 -            o = fac.make();
   37.26 +            o = fac.make(this);
   37.27              if (o instanceof Factory<?>)
   37.28                  throw new AssertionError("T extends Context.Factory");
   37.29              Assert.check(ht.get(key) == o);
   37.30 @@ -158,6 +160,20 @@
   37.31  
   37.32      public Context() {}
   37.33  
   37.34 +    /**
   37.35 +     * The table of preregistered factories.
   37.36 +     */
   37.37 +    private Map<Key<?>,Factory<?>> ft = new HashMap<Key<?>,Factory<?>>();
   37.38 +
   37.39 +    public Context(Context prev) {
   37.40 +        kt.putAll(prev.kt);     // retain all implicit keys
   37.41 +        ft.putAll(prev.ft);     // retain all factory objects
   37.42 +        ht.putAll(prev.ft);     // init main table with factories
   37.43 +    }
   37.44 +
   37.45 +    /*
   37.46 +     * The key table, providing a unique Key<T> for each Class<T>.
   37.47 +     */
   37.48      private Map<Class<?>, Key<?>> kt = new HashMap<Class<?>, Key<?>>();
   37.49  
   37.50      private <T> Key<T> key(Class<T> clss) {
   37.51 @@ -198,6 +214,7 @@
   37.52      public void clear() {
   37.53          ht = null;
   37.54          kt = null;
   37.55 +        ft = null;
   37.56      }
   37.57  
   37.58      private static void checkState(Map<?,?> t) {
    38.1 --- a/src/share/classes/com/sun/tools/javac/util/Log.java	Thu Mar 10 17:11:19 2011 -0800
    38.2 +++ b/src/share/classes/com/sun/tools/javac/util/Log.java	Thu Mar 10 20:51:07 2011 -0800
    38.3 @@ -1,5 +1,5 @@
    38.4  /*
    38.5 - * Copyright (c) 1999, 2010, Oracle and/or its affiliates. All rights reserved.
    38.6 + * Copyright (c) 1999, 2011, Oracle and/or its affiliates. All rights reserved.
    38.7   * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
    38.8   *
    38.9   * This code is free software; you can redistribute it and/or modify it
   38.10 @@ -329,7 +329,6 @@
   38.11          printLines(errWriter, localize(key, args));
   38.12      }
   38.13  
   38.14 -
   38.15      /** Print the text of a message to the noticeWriter stream,
   38.16       *  translating newlines appropriately for the platform.
   38.17       */
   38.18 @@ -337,6 +336,14 @@
   38.19          printLines(noticeWriter, localize(key, args));
   38.20      }
   38.21  
   38.22 +    /**
   38.23 +     * Print the localized text of a "verbose" message to the
   38.24 +     * noticeWriter stream.
   38.25 +     */
   38.26 +    public void printVerbose(String key, Object... args) {
   38.27 +        printLines(noticeWriter, localize("verbose." + key, args));
   38.28 +    }
   38.29 +
   38.30      protected void directError(String key, Object... args) {
   38.31          printErrLines(key, args);
   38.32          errWriter.flush();
    39.1 --- a/src/share/classes/com/sun/tools/javadoc/AnnotationDescImpl.java	Thu Mar 10 17:11:19 2011 -0800
    39.2 +++ b/src/share/classes/com/sun/tools/javadoc/AnnotationDescImpl.java	Thu Mar 10 20:51:07 2011 -0800
    39.3 @@ -1,5 +1,5 @@
    39.4  /*
    39.5 - * Copyright (c) 2003, 2004, Oracle and/or its affiliates. All rights reserved.
    39.6 + * Copyright (c) 2003, 2011, Oracle and/or its affiliates. All rights reserved.
    39.7   * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
    39.8   *
    39.9   * This code is free software; you can redistribute it and/or modify it
   39.10 @@ -92,8 +92,9 @@
   39.11       *     @com.example.foo
   39.12       * Omit parens for marker annotations, and omit "value=" when allowed.
   39.13       */
   39.14 +    @Override
   39.15      public String toString() {
   39.16 -        StringBuffer sb = new StringBuffer("@");
   39.17 +        StringBuilder sb = new StringBuilder("@");
   39.18          sb.append(annotation.type.tsym);
   39.19  
   39.20          ElementValuePair vals[] = elementValues();
   39.21 @@ -153,6 +154,7 @@
   39.22           * Returns a string representation of this pair
   39.23           * of the form "name=value".
   39.24           */
   39.25 +        @Override
   39.26          public String toString() {
   39.27              return meth.name + "=" + value();
   39.28          }
    40.1 --- a/src/share/classes/com/sun/tools/javadoc/AnnotationValueImpl.java	Thu Mar 10 17:11:19 2011 -0800
    40.2 +++ b/src/share/classes/com/sun/tools/javadoc/AnnotationValueImpl.java	Thu Mar 10 20:51:07 2011 -0800
    40.3 @@ -1,5 +1,5 @@
    40.4  /*
    40.5 - * Copyright (c) 2003, 2004, Oracle and/or its affiliates. All rights reserved.
    40.6 + * Copyright (c) 2003, 2011, Oracle and/or its affiliates. All rights reserved.
    40.7   * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
    40.8   *
    40.9   * This code is free software; you can redistribute it and/or modify it
   40.10 @@ -30,7 +30,6 @@
   40.11  
   40.12  import com.sun.tools.javac.code.Attribute;
   40.13  import com.sun.tools.javac.code.Symbol.*;
   40.14 -import com.sun.tools.javac.code.Type;
   40.15  import com.sun.tools.javac.code.TypeTags;
   40.16  
   40.17  
   40.18 @@ -114,6 +113,7 @@
   40.19       * @return the text of a Java language annotation value expression
   40.20       *          whose value is the value of this annotation type element.
   40.21       */
   40.22 +    @Override
   40.23      public String toString() {
   40.24          ToStringVisitor tv = new ToStringVisitor();
   40.25          attr.accept(tv);
   40.26 @@ -121,8 +121,9 @@
   40.27      }
   40.28  
   40.29      private class ToStringVisitor implements Attribute.Visitor {
   40.30 -        private final StringBuffer sb = new StringBuffer();
   40.31 +        private final StringBuilder sb = new StringBuilder();
   40.32  
   40.33 +        @Override
   40.34          public String toString() {
   40.35              return sb.toString();
   40.36          }
    41.1 --- a/src/share/classes/com/sun/tools/javadoc/ClassDocImpl.java	Thu Mar 10 17:11:19 2011 -0800
    41.2 +++ b/src/share/classes/com/sun/tools/javadoc/ClassDocImpl.java	Thu Mar 10 20:51:07 2011 -0800
    41.3 @@ -1,5 +1,5 @@
    41.4  /*
    41.5 - * Copyright (c) 1997, 2010, Oracle and/or its affiliates. All rights reserved.
    41.6 + * Copyright (c) 1997, 2011, Oracle and/or its affiliates. All rights reserved.
    41.7   * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
    41.8   *
    41.9   * This code is free software; you can redistribute it and/or modify it
   41.10 @@ -64,7 +64,6 @@
   41.11  import com.sun.tools.javac.util.Names;
   41.12  import com.sun.tools.javac.util.Position;
   41.13  
   41.14 -import static com.sun.tools.javac.code.Flags.*;
   41.15  import static com.sun.tools.javac.code.Kinds.*;
   41.16  
   41.17  /**
   41.18 @@ -147,6 +146,7 @@
   41.19      /**
   41.20       * Return true if this is a class, not an interface.
   41.21       */
   41.22 +    @Override
   41.23      public boolean isClass() {
   41.24          return !Modifier.isInterface(getModifiers());
   41.25      }
   41.26 @@ -155,6 +155,7 @@
   41.27       * Return true if this is a ordinary class,
   41.28       * not an enumeration, exception, an error, or an interface.
   41.29       */
   41.30 +    @Override
   41.31      public boolean isOrdinaryClass() {
   41.32          if (isEnum() || isInterface() || isAnnotationType()) {
   41.33              return false;
   41.34 @@ -172,6 +173,7 @@
   41.35       * Return true if this is an enumeration.
   41.36       * (For legacy doclets, return false.)
   41.37       */
   41.38 +    @Override
   41.39      public boolean isEnum() {
   41.40          return (getFlags() & Flags.ENUM) != 0
   41.41                 &&
   41.42 @@ -182,6 +184,7 @@
   41.43       * Return true if this is an interface, but not an annotation type.
   41.44       * Overridden by AnnotationTypeDocImpl.
   41.45       */
   41.46 +    @Override
   41.47      public boolean isInterface() {
   41.48          return Modifier.isInterface(getModifiers());
   41.49      }
   41.50 @@ -189,6 +192,7 @@
   41.51      /**
   41.52       * Return true if this is an exception class
   41.53       */
   41.54 +    @Override
   41.55      public boolean isException() {
   41.56          if (isEnum() || isInterface() || isAnnotationType()) {
   41.57              return false;
   41.58 @@ -204,6 +208,7 @@
   41.59      /**
   41.60       * Return true if this is an error class
   41.61       */
   41.62 +    @Override
   41.63      public boolean isError() {
   41.64          if (isEnum() || isInterface() || isAnnotationType()) {
   41.65              return false;
   41.66 @@ -275,6 +280,7 @@
   41.67      /**
   41.68       * Return the package that this class is contained in.
   41.69       */
   41.70 +    @Override
   41.71      public PackageDoc containingPackage() {
   41.72          PackageDocImpl p = env.getPackageDoc(tsym.packge());
   41.73          if (p.setDocPath == false) {
   41.74 @@ -374,6 +380,7 @@
   41.75       * Return the qualified name and any type parameters.
   41.76       * Each parameter is a type variable with optional bounds.
   41.77       */
   41.78 +    @Override
   41.79      public String toString() {
   41.80          return classToString(env, tsym, true);
   41.81      }
   41.82 @@ -401,7 +408,7 @@
   41.83       * qualified by their enclosing class(es) only.
   41.84       */
   41.85      static String classToString(DocEnv env, ClassSymbol c, boolean full) {
   41.86 -        StringBuffer s = new StringBuffer();
   41.87 +        StringBuilder s = new StringBuilder();
   41.88          if (!c.isInner()) {             // if c is not an inner class
   41.89              s.append(getClassName(c, full));
   41.90          } else {
   41.91 @@ -449,10 +456,12 @@
   41.92       * Return the modifier string for this class. If it's an interface
   41.93       * exclude 'abstract' keyword from the modifier string
   41.94       */
   41.95 +    @Override
   41.96      public String modifiers() {
   41.97          return Modifier.toString(modifierSpecifier());
   41.98      }
   41.99  
  41.100 +    @Override
  41.101      public int modifierSpecifier() {
  41.102          int modifiers = getModifiers();
  41.103          return (isInterface() || isAnnotationType())
  41.104 @@ -1285,6 +1294,7 @@
  41.105       * Return the source position of the entity, or null if
  41.106       * no position is available.
  41.107       */
  41.108 +    @Override
  41.109      public SourcePosition position() {
  41.110          if (tsym.sourcefile == null) return null;
  41.111          return SourcePositionImpl.make(tsym.sourcefile,
    42.1 --- a/src/share/classes/com/sun/tools/javadoc/DocImpl.java	Thu Mar 10 17:11:19 2011 -0800
    42.2 +++ b/src/share/classes/com/sun/tools/javadoc/DocImpl.java	Thu Mar 10 20:51:07 2011 -0800
    42.3 @@ -1,5 +1,5 @@
    42.4  /*
    42.5 - * Copyright (c) 1997, 2009, Oracle and/or its affiliates. All rights reserved.
    42.6 + * Copyright (c) 1997, 2011, Oracle and/or its affiliates. All rights reserved.
    42.7   * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
    42.8   *
    42.9   * This code is free software; you can redistribute it and/or modify it
   42.10 @@ -25,6 +25,7 @@
   42.11  
   42.12  package com.sun.tools.javadoc;
   42.13  
   42.14 +import java.io.DataInputStream;
   42.15  import java.io.InputStream;
   42.16  import java.io.IOException;
   42.17  import java.text.CollationKey;
   42.18 @@ -33,6 +34,8 @@
   42.19  import com.sun.javadoc.*;
   42.20  
   42.21  import com.sun.tools.javac.util.Position;
   42.22 +import java.util.regex.Matcher;
   42.23 +import java.util.regex.Pattern;
   42.24  
   42.25  /**
   42.26   * abstract base class of all Doc classes.  Doc item's are representations
   42.27 @@ -166,51 +169,28 @@
   42.28       * Utility for subclasses which read HTML documentation files.
   42.29       */
   42.30      String readHTMLDocumentation(InputStream input, FileObject filename) throws IOException {
   42.31 -        int filesize = input.available();
   42.32 -        byte[] filecontents = new byte[filesize];
   42.33 -        input.read(filecontents, 0, filesize);
   42.34 -        input.close();
   42.35 +        byte[] filecontents = new byte[input.available()];
   42.36 +        try {
   42.37 +            DataInputStream dataIn = new DataInputStream(input);
   42.38 +            dataIn.readFully(filecontents);
   42.39 +        } finally {
   42.40 +            input.close();
   42.41 +        }
   42.42          String encoding = env.getEncoding();
   42.43          String rawDoc = (encoding!=null)
   42.44              ? new String(filecontents, encoding)
   42.45              : new String(filecontents);
   42.46 -        String upper = null;
   42.47 -        int bodyIdx = rawDoc.indexOf("<body");
   42.48 -        if (bodyIdx == -1) {
   42.49 -            bodyIdx = rawDoc.indexOf("<BODY");
   42.50 -            if (bodyIdx == -1) {
   42.51 -                upper = rawDoc.toUpperCase();
   42.52 -                bodyIdx = upper.indexOf("<BODY");
   42.53 -                if (bodyIdx == -1) {
   42.54 -                    env.error(SourcePositionImpl.make(filename, Position.NOPOS, null),
   42.55 -                                       "javadoc.Body_missing_from_html_file");
   42.56 -                    return "";
   42.57 -                }
   42.58 -            }
   42.59 -        }
   42.60 -        bodyIdx = rawDoc.indexOf('>', bodyIdx);
   42.61 -        if (bodyIdx == -1) {
   42.62 -            env.error(SourcePositionImpl.make(filename, Position.NOPOS, null),
   42.63 -                               "javadoc.Body_missing_from_html_file");
   42.64 +        Pattern bodyPat = Pattern.compile("(?is).*<body\\b[^>]*>(.*)</body\\b.*");
   42.65 +        Matcher m = bodyPat.matcher(rawDoc);
   42.66 +        if (m.matches()) {
   42.67 +            return m.group(1);
   42.68 +        } else {
   42.69 +            String key = rawDoc.matches("(?is).*<body\\b.*")
   42.70 +                    ? "javadoc.End_body_missing_from_html_file"
   42.71 +                    : "javadoc.Body_missing_from_html_file";
   42.72 +            env.error(SourcePositionImpl.make(filename, Position.NOPOS, null), key);
   42.73              return "";
   42.74          }
   42.75 -        ++bodyIdx;
   42.76 -        int endIdx = rawDoc.indexOf("</body", bodyIdx);
   42.77 -        if (endIdx == -1) {
   42.78 -            endIdx = rawDoc.indexOf("</BODY", bodyIdx);
   42.79 -            if (endIdx == -1) {
   42.80 -                if (upper == null) {
   42.81 -                    upper = rawDoc.toUpperCase();
   42.82 -                }
   42.83 -                endIdx = upper.indexOf("</BODY", bodyIdx);
   42.84 -                if (endIdx == -1) {
   42.85 -                    env.error(SourcePositionImpl.make(filename, Position.NOPOS, null),
   42.86 -                                       "javadoc.End_body_missing_from_html_file");
   42.87 -                    return "";
   42.88 -                }
   42.89 -            }
   42.90 -        }
   42.91 -        return rawDoc.substring(bodyIdx, endIdx);
   42.92      }
   42.93  
   42.94      /**
   42.95 @@ -256,6 +236,7 @@
   42.96      /**
   42.97       * Returns a string representation of this Doc item.
   42.98       */
   42.99 +    @Override
  42.100      public String toString() {
  42.101          return qualifiedName();
  42.102      }
    43.1 --- a/src/share/classes/com/sun/tools/javadoc/DocletInvoker.java	Thu Mar 10 17:11:19 2011 -0800
    43.2 +++ b/src/share/classes/com/sun/tools/javadoc/DocletInvoker.java	Thu Mar 10 20:51:07 2011 -0800
    43.3 @@ -1,5 +1,5 @@
    43.4  /*
    43.5 - * Copyright (c) 1998, 2010, Oracle and/or its affiliates. All rights reserved.
    43.6 + * Copyright (c) 1998, 2011, Oracle and/or its affiliates. All rights reserved.
    43.7   * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
    43.8   *
    43.9   * This code is free software; you can redistribute it and/or modify it
   43.10 @@ -31,14 +31,13 @@
   43.11  
   43.12  import com.sun.tools.javac.util.List;
   43.13  
   43.14 -import java.net.*;
   43.15 +import java.io.File;
   43.16  import java.lang.reflect.Method;
   43.17  import java.lang.reflect.Modifier;
   43.18  import java.lang.reflect.InvocationTargetException;
   43.19 +import java.net.URL;
   43.20 +import java.net.URLClassLoader;
   43.21  
   43.22 -import java.io.File;
   43.23 -import java.io.IOException;
   43.24 -import java.util.StringTokenizer;
   43.25  
   43.26  /**
   43.27   * Class creates, controls and invokes doclets.
    44.1 --- a/src/share/classes/com/sun/tools/javadoc/ExecutableMemberDocImpl.java	Thu Mar 10 17:11:19 2011 -0800
    44.2 +++ b/src/share/classes/com/sun/tools/javadoc/ExecutableMemberDocImpl.java	Thu Mar 10 20:51:07 2011 -0800
    44.3 @@ -1,5 +1,5 @@
    44.4  /*
    44.5 - * Copyright (c) 1997, 2009, Oracle and/or its affiliates. All rights reserved.
    44.6 + * Copyright (c) 1997, 2011, Oracle and/or its affiliates. All rights reserved.
    44.7   * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
    44.8   *
    44.9   * This code is free software; you can redistribute it and/or modify it
   44.10 @@ -226,7 +226,7 @@
   44.11      }
   44.12  
   44.13      private String makeSignature(boolean full) {
   44.14 -        StringBuffer result = new StringBuffer();
   44.15 +        StringBuilder result = new StringBuilder();
   44.16          result.append("(");
   44.17          for (List<Type> types = sym.type.getParameterTypes(); types.nonEmpty(); ) {
   44.18              Type t = types.head;
   44.19 @@ -251,6 +251,7 @@
   44.20      /**
   44.21       * Generate a key for sorting.
   44.22       */
   44.23 +    @Override
   44.24      CollationKey generateKey() {
   44.25          String k = name() + flatSignature() + typeParametersString();
   44.26          // ',' and '&' are between '$' and 'a':  normalize to spaces.
   44.27 @@ -263,6 +264,7 @@
   44.28       * Return the source position of the entity, or null if
   44.29       * no position is available.
   44.30       */
   44.31 +    @Override
   44.32      public SourcePosition position() {
   44.33          if (sym.enclClass().sourcefile == null) return null;
   44.34          return SourcePositionImpl.make(sym.enclClass().sourcefile,
    45.1 --- a/src/share/classes/com/sun/tools/javadoc/FieldDocImpl.java	Thu Mar 10 17:11:19 2011 -0800
    45.2 +++ b/src/share/classes/com/sun/tools/javadoc/FieldDocImpl.java	Thu Mar 10 20:51:07 2011 -0800
    45.3 @@ -1,5 +1,5 @@
    45.4  /*
    45.5 - * Copyright (c) 1997, 2009, Oracle and/or its affiliates. All rights reserved.
    45.6 + * Copyright (c) 1997, 2011, Oracle and/or its affiliates. All rights reserved.
    45.7   * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
    45.8   *
    45.9   * This code is free software; you can redistribute it and/or modify it
   45.10 @@ -142,7 +142,7 @@
   45.11              return v + (suffix == 'f' || suffix == 'F' ? "" + suffix : "");
   45.12          }
   45.13          private static String sourceForm(char c) {
   45.14 -            StringBuffer buf = new StringBuffer(8);
   45.15 +            StringBuilder buf = new StringBuilder(8);
   45.16              buf.append('\'');
   45.17              sourceChar(c, buf);
   45.18              buf.append('\'');
   45.19 @@ -152,7 +152,7 @@
   45.20              return "0x" + Integer.toString(c & 0xff, 16);
   45.21          }
   45.22          private static String sourceForm(String s) {
   45.23 -            StringBuffer buf = new StringBuffer(s.length() + 5);
   45.24 +            StringBuilder buf = new StringBuilder(s.length() + 5);
   45.25              buf.append('\"');
   45.26              for (int i=0; i<s.length(); i++) {
   45.27                  char c = s.charAt(i);
   45.28 @@ -161,7 +161,7 @@
   45.29              buf.append('\"');
   45.30              return buf.toString();
   45.31          }
   45.32 -        private static void sourceChar(char c, StringBuffer buf) {
   45.33 +        private static void sourceChar(char c, StringBuilder buf) {
   45.34              switch (c) {
   45.35              case '\b': buf.append("\\b"); return;
   45.36              case '\t': buf.append("\\t"); return;
   45.37 @@ -179,7 +179,7 @@
   45.38                  return;
   45.39              }
   45.40          }
   45.41 -        private static void unicodeEscape(char c, StringBuffer buf) {
   45.42 +        private static void unicodeEscape(char c, StringBuilder buf) {
   45.43              final String chars = "0123456789abcdef";
   45.44              buf.append("\\u");
   45.45              buf.append(chars.charAt(15 & (c>>12)));
   45.46 @@ -201,6 +201,7 @@
   45.47      /**
   45.48       * Is this Doc item a field (but not an enum constant?
   45.49       */
   45.50 +    @Override
   45.51      public boolean isField() {
   45.52          return !isEnumConstant();
   45.53      }
   45.54 @@ -209,6 +210,7 @@
   45.55       * Is this Doc item an enum constant?
   45.56       * (For legacy doclets, return false.)
   45.57       */
   45.58 +    @Override
   45.59      public boolean isEnumConstant() {
   45.60          return (getFlags() & Flags.ENUM) != 0 &&
   45.61                 !env.legacyDoclet;
   45.62 @@ -257,6 +259,7 @@
   45.63       * Return the source position of the entity, or null if
   45.64       * no position is available.
   45.65       */
   45.66 +    @Override
   45.67      public SourcePosition position() {
   45.68          if (sym.enclClass().sourcefile == null) return null;
   45.69          return SourcePositionImpl.make(sym.enclClass().sourcefile,
    46.1 --- a/src/share/classes/com/sun/tools/javadoc/JavadocClassReader.java	Thu Mar 10 17:11:19 2011 -0800
    46.2 +++ b/src/share/classes/com/sun/tools/javadoc/JavadocClassReader.java	Thu Mar 10 20:51:07 2011 -0800
    46.3 @@ -1,5 +1,5 @@
    46.4  /*
    46.5 - * Copyright (c) 2001, 2010, Oracle and/or its affiliates. All rights reserved.
    46.6 + * Copyright (c) 2001, 2011, Oracle and/or its affiliates. All rights reserved.
    46.7   * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
    46.8   *
    46.9   * This code is free software; you can redistribute it and/or modify it
   46.10 @@ -44,10 +44,10 @@
   46.11          return (JavadocClassReader)instance;
   46.12      }
   46.13  
   46.14 -    public static void preRegister(final Context context) {
   46.15 +    public static void preRegister(Context context) {
   46.16          context.put(classReaderKey, new Context.Factory<ClassReader>() {
   46.17 -            public ClassReader make() {
   46.18 -                return new JavadocClassReader(context);
   46.19 +            public ClassReader make(Context c) {
   46.20 +                return new JavadocClassReader(c);
   46.21              }
   46.22          });
   46.23      }
    47.1 --- a/src/share/classes/com/sun/tools/javadoc/JavadocEnter.java	Thu Mar 10 17:11:19 2011 -0800
    47.2 +++ b/src/share/classes/com/sun/tools/javadoc/JavadocEnter.java	Thu Mar 10 20:51:07 2011 -0800
    47.3 @@ -1,5 +1,5 @@
    47.4  /*
    47.5 - * Copyright (c) 2001, 2008, Oracle and/or its affiliates. All rights reserved.
    47.6 + * Copyright (c) 2001, 2011, Oracle and/or its affiliates. All rights reserved.
    47.7   * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
    47.8   *
    47.9   * This code is free software; you can redistribute it and/or modify it
   47.10 @@ -48,10 +48,10 @@
   47.11          return (JavadocEnter)instance;
   47.12      }
   47.13  
   47.14 -    public static void preRegister(final Context context) {
   47.15 +    public static void preRegister(Context context) {
   47.16          context.put(enterKey, new Context.Factory<Enter>() {
   47.17 -               public Enter make() {
   47.18 -                   return new JavadocEnter(context);
   47.19 +               public Enter make(Context c) {
   47.20 +                   return new JavadocEnter(c);
   47.21                 }
   47.22          });
   47.23      }
    48.1 --- a/src/share/classes/com/sun/tools/javadoc/JavadocMemberEnter.java	Thu Mar 10 17:11:19 2011 -0800
    48.2 +++ b/src/share/classes/com/sun/tools/javadoc/JavadocMemberEnter.java	Thu Mar 10 20:51:07 2011 -0800
    48.3 @@ -1,5 +1,5 @@
    48.4  /*
    48.5 - * Copyright (c) 2003, 2008, Oracle and/or its affiliates. All rights reserved.
    48.6 + * Copyright (c) 2003, 2011, Oracle and/or its affiliates. All rights reserved.
    48.7   * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
    48.8   *
    48.9   * This code is free software; you can redistribute it and/or modify it
   48.10 @@ -46,10 +46,10 @@
   48.11          return (JavadocMemberEnter)instance;
   48.12      }
   48.13  
   48.14 -    public static void preRegister(final Context context) {
   48.15 +    public static void preRegister(Context context) {
   48.16          context.put(memberEnterKey, new Context.Factory<MemberEnter>() {
   48.17 -               public MemberEnter make() {
   48.18 -                   return new JavadocMemberEnter(context);
   48.19 +               public MemberEnter make(Context c) {
   48.20 +                   return new JavadocMemberEnter(c);
   48.21                 }
   48.22          });
   48.23      }
    49.1 --- a/src/share/classes/com/sun/tools/javadoc/JavadocTodo.java	Thu Mar 10 17:11:19 2011 -0800
    49.2 +++ b/src/share/classes/com/sun/tools/javadoc/JavadocTodo.java	Thu Mar 10 20:51:07 2011 -0800
    49.3 @@ -1,5 +1,5 @@
    49.4  /*
    49.5 - * Copyright (c) 2003, 2008, Oracle and/or its affiliates. All rights reserved.
    49.6 + * Copyright (c) 2003, 2011, Oracle and/or its affiliates. All rights reserved.
    49.7   * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
    49.8   *
    49.9   * This code is free software; you can redistribute it and/or modify it
   49.10 @@ -34,10 +34,10 @@
   49.11   *  @author Neal Gafter
   49.12   */
   49.13  public class JavadocTodo extends Todo {
   49.14 -    public static void preRegister(final Context context) {
   49.15 +    public static void preRegister(Context context) {
   49.16          context.put(todoKey, new Context.Factory<Todo>() {
   49.17 -               public Todo make() {
   49.18 -                   return new JavadocTodo(context);
   49.19 +               public Todo make(Context c) {
   49.20 +                   return new JavadocTodo(c);
   49.21                 }
   49.22          });
   49.23      }
    50.1 --- a/src/share/classes/com/sun/tools/javadoc/Messager.java	Thu Mar 10 17:11:19 2011 -0800
    50.2 +++ b/src/share/classes/com/sun/tools/javadoc/Messager.java	Thu Mar 10 20:51:07 2011 -0800
    50.3 @@ -1,5 +1,5 @@
    50.4  /*
    50.5 - * Copyright (c) 1997, 2010, Oracle and/or its affiliates. All rights reserved.
    50.6 + * Copyright (c) 1997, 2011, Oracle and/or its affiliates. All rights reserved.
    50.7   * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
    50.8   *
    50.9   * This code is free software; you can redistribute it and/or modify it
   50.10 @@ -57,23 +57,23 @@
   50.11          return (Messager)instance;
   50.12      }
   50.13  
   50.14 -    public static void preRegister(final Context context,
   50.15 +    public static void preRegister(Context context,
   50.16                                     final String programName) {
   50.17          context.put(logKey, new Context.Factory<Log>() {
   50.18 -            public Log make() {
   50.19 -                return new Messager(context,
   50.20 +            public Log make(Context c) {
   50.21 +                return new Messager(c,
   50.22                                      programName);
   50.23              }
   50.24          });
   50.25      }
   50.26 -    public static void preRegister(final Context context,
   50.27 +    public static void preRegister(Context context,
   50.28                                     final String programName,
   50.29                                     final PrintWriter errWriter,
   50.30                                     final PrintWriter warnWriter,
   50.31                                     final PrintWriter noticeWriter) {
   50.32          context.put(logKey, new Context.Factory<Log>() {
   50.33 -            public Log make() {
   50.34 -                return new Messager(context,
   50.35 +            public Log make(Context c) {
   50.36 +                return new Messager(c,
   50.37                                      programName,
   50.38                                      errWriter,
   50.39                                      warnWriter,
   50.40 @@ -143,11 +143,9 @@
   50.41       * if needed.
   50.42       */
   50.43      private String getString(String key) {
   50.44 -        ResourceBundle messageRB = this.messageRB;
   50.45          if (messageRB == null) {
   50.46              try {
   50.47 -                this.messageRB = messageRB =
   50.48 -                    ResourceBundle.getBundle(
   50.49 +                messageRB = ResourceBundle.getBundle(
   50.50                            "com.sun.tools.javadoc.resources.javadoc");
   50.51              } catch (MissingResourceException e) {
   50.52                  throw new Error("Fatal: Resource for javadoc is missing");
   50.53 @@ -456,8 +454,6 @@
   50.54       * Print exit message.
   50.55       */
   50.56      public void exitNotice() {
   50.57 -        int nerrors = nerrors();
   50.58 -        int nwarnings = nwarnings();
   50.59          if (nerrors > 0) {
   50.60              notice((nerrors > 1) ? "main.errors" : "main.error",
   50.61                     "" + nerrors);
    51.1 --- a/src/share/classes/com/sun/tools/javadoc/ParameterizedTypeImpl.java	Thu Mar 10 17:11:19 2011 -0800
    51.2 +++ b/src/share/classes/com/sun/tools/javadoc/ParameterizedTypeImpl.java	Thu Mar 10 20:51:07 2011 -0800
    51.3 @@ -1,5 +1,5 @@
    51.4  /*
    51.5 - * Copyright (c) 2003, 2005, Oracle and/or its affiliates. All rights reserved.
    51.6 + * Copyright (c) 2003, 2011, Oracle and/or its affiliates. All rights reserved.
    51.7   * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
    51.8   *
    51.9   * This code is free software; you can redistribute it and/or modify it
   51.10 @@ -25,15 +25,11 @@
   51.11  
   51.12  package com.sun.tools.javadoc;
   51.13  
   51.14 -
   51.15  import com.sun.javadoc.*;
   51.16  
   51.17 -import static com.sun.javadoc.LanguageVersion.*;
   51.18 -
   51.19  import com.sun.tools.javac.code.Symbol.ClassSymbol;
   51.20  import com.sun.tools.javac.code.Type;
   51.21  import com.sun.tools.javac.code.Type.ClassType;
   51.22 -import com.sun.tools.javac.util.List;
   51.23  
   51.24  import static com.sun.tools.javac.code.TypeTags.*;
   51.25  
   51.26 @@ -55,6 +51,7 @@
   51.27      /**
   51.28       * Return the generic class or interface that declared this type.
   51.29       */
   51.30 +    @Override
   51.31      public ClassDoc asClassDoc() {
   51.32          return env.getClassDoc((ClassSymbol)type.tsym);
   51.33      }
   51.34 @@ -111,14 +108,17 @@
   51.35      // Asking for the "name" of a parameterized type doesn't exactly make
   51.36      // sense.  It's a type expression.  Return the name of its generic
   51.37      // type.
   51.38 +    @Override
   51.39      public String typeName() {
   51.40          return TypeMaker.getTypeName(type, false);
   51.41      }
   51.42  
   51.43 +    @Override
   51.44      public ParameterizedType asParameterizedType() {
   51.45          return this;
   51.46      }
   51.47  
   51.48 +    @Override
   51.49      public String toString() {
   51.50          return parameterizedTypeToString(env, (ClassType)type, true);
   51.51      }
   51.52 @@ -128,7 +128,7 @@
   51.53          if (env.legacyDoclet) {
   51.54              return TypeMaker.getTypeName(cl, full);
   51.55          }
   51.56 -        StringBuffer s = new StringBuffer();
   51.57 +        StringBuilder s = new StringBuilder();
   51.58          if (cl.getEnclosingType().tag != CLASS) {               // if not an inner class...
   51.59              s.append(TypeMaker.getTypeName(cl, full));
   51.60          } else {
    52.1 --- a/src/share/classes/com/sun/tools/javadoc/RootDocImpl.java	Thu Mar 10 17:11:19 2011 -0800
    52.2 +++ b/src/share/classes/com/sun/tools/javadoc/RootDocImpl.java	Thu Mar 10 20:51:07 2011 -0800
    52.3 @@ -1,5 +1,5 @@
    52.4  /*
    52.5 - * Copyright (c) 1997, 2009, Oracle and/or its affiliates. All rights reserved.
    52.6 + * Copyright (c) 1997, 2011, Oracle and/or its affiliates. All rights reserved.
    52.7   * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
    52.8   *
    52.9   * This code is free software; you can redistribute it and/or modify it
   52.10 @@ -322,6 +322,7 @@
   52.11      /**
   52.12       * Do lazy initialization of "documentation" string.
   52.13       */
   52.14 +    @Override
   52.15      protected String documentation() {
   52.16          if (documentation == null) {
   52.17              int cnt = options.length();
   52.18 @@ -348,6 +349,7 @@
   52.19       * Return the source position of the entity, or null if
   52.20       * no position is available.
   52.21       */
   52.22 +    @Override
   52.23      public SourcePosition position() {
   52.24          JavaFileObject path;
   52.25          return ((path = getOverviewPath()) == null) ?
    53.1 --- a/src/share/classes/com/sun/tools/javadoc/SeeTagImpl.java	Thu Mar 10 17:11:19 2011 -0800
    53.2 +++ b/src/share/classes/com/sun/tools/javadoc/SeeTagImpl.java	Thu Mar 10 20:51:07 2011 -0800
    53.3 @@ -1,5 +1,5 @@
    53.4  /*
    53.5 - * Copyright (c) 1997, 2008, Oracle and/or its affiliates. All rights reserved.
    53.6 + * Copyright (c) 1997, 2011, Oracle and/or its affiliates. All rights reserved.
    53.7   * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
    53.8   *
    53.9   * This code is free software; you can redistribute it and/or modify it
   53.10 @@ -358,14 +358,14 @@
   53.11  
   53.12          String parameters;
   53.13  
   53.14 -        StringBuffer typeId;
   53.15 +        StringBuilder typeId;
   53.16  
   53.17          ListBuffer<String> paramList;
   53.18  
   53.19          ParameterParseMachine(String parameters) {
   53.20              this.parameters = parameters;
   53.21              this.paramList = new ListBuffer<String>();
   53.22 -            typeId = new StringBuffer();
   53.23 +            typeId = new StringBuilder();
   53.24          }
   53.25  
   53.26          public String[] parseParameters() {
   53.27 @@ -464,6 +464,7 @@
   53.28      /**
   53.29       * Return the kind of this tag.
   53.30       */
   53.31 +    @Override
   53.32      public String kind() {
   53.33          return "@see";
   53.34      }
    54.1 --- a/src/share/classes/com/sun/tools/javadoc/Start.java	Thu Mar 10 17:11:19 2011 -0800
    54.2 +++ b/src/share/classes/com/sun/tools/javadoc/Start.java	Thu Mar 10 20:51:07 2011 -0800
    54.3 @@ -1,5 +1,5 @@
    54.4  /*
    54.5 - * Copyright (c) 1997, 2010, Oracle and/or its affiliates. All rights reserved.
    54.6 + * Copyright (c) 1997, 2011, Oracle and/or its affiliates. All rights reserved.
    54.7   * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
    54.8   *
    54.9   * This code is free software; you can redistribute it and/or modify it
   54.10 @@ -396,6 +396,10 @@
   54.11          boolean ok = root != null;
   54.12          if (ok) ok = docletInvoker.start(root);
   54.13  
   54.14 +        Messager docletMessager = Messager.instance0(context);
   54.15 +        messager.nwarnings += docletMessager.nwarnings;
   54.16 +        messager.nerrors += docletMessager.nerrors;
   54.17 +
   54.18          // We're done.
   54.19          if (compOpts.get("-verbose") != null) {
   54.20              tm = System.currentTimeMillis() - tm;
    55.1 --- a/src/share/classes/com/sun/tools/javadoc/TypeMaker.java	Thu Mar 10 17:11:19 2011 -0800
    55.2 +++ b/src/share/classes/com/sun/tools/javadoc/TypeMaker.java	Thu Mar 10 20:51:07 2011 -0800
    55.3 @@ -1,5 +1,5 @@
    55.4  /*
    55.5 - * Copyright (c) 1997, 2009, Oracle and/or its affiliates. All rights reserved.
    55.6 + * Copyright (c) 1997, 2011, Oracle and/or its affiliates. All rights reserved.
    55.7   * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
    55.8   *
    55.9   * This code is free software; you can redistribute it and/or modify it
   55.10 @@ -27,15 +27,12 @@
   55.11  
   55.12  import com.sun.javadoc.*;
   55.13  
   55.14 -import static com.sun.javadoc.LanguageVersion.*;
   55.15 -
   55.16  import com.sun.tools.javac.code.Symbol;
   55.17  import com.sun.tools.javac.code.Symbol.ClassSymbol;
   55.18  import com.sun.tools.javac.code.Type;
   55.19  import com.sun.tools.javac.code.Type.ClassType;
   55.20  import com.sun.tools.javac.code.Type.TypeVar;
   55.21  import com.sun.tools.javac.code.Type.ArrayType;
   55.22 -import com.sun.tools.javac.code.Types;
   55.23  import com.sun.tools.javac.util.List;
   55.24  
   55.25  import static com.sun.tools.javac.code.TypeTags.*;
   55.26 @@ -109,12 +106,13 @@
   55.27      public static String getTypeName(Type t, boolean full) {
   55.28          switch (t.tag) {
   55.29          case ARRAY:
   55.30 -            StringBuffer dimension = new StringBuffer();
   55.31 +            StringBuilder s = new StringBuilder();
   55.32              while (t.tag == ARRAY) {
   55.33 -                dimension = dimension.append("[]");
   55.34 +                s.append("[]");
   55.35                  t = ((ArrayType)t).elemtype;
   55.36              }
   55.37 -            return getTypeName(t, full) + dimension;
   55.38 +            s.insert(0, getTypeName(t, full));
   55.39 +            return s.toString();
   55.40          case CLASS:
   55.41              return ClassDocImpl.getClassName((ClassSymbol)t.tsym, full);
   55.42          default:
   55.43 @@ -130,12 +128,13 @@
   55.44      static String getTypeString(DocEnv env, Type t, boolean full) {
   55.45          switch (t.tag) {
   55.46          case ARRAY:
   55.47 -            StringBuffer dimension = new StringBuffer();
   55.48 +            StringBuilder s = new StringBuilder();
   55.49              while (t.tag == ARRAY) {
   55.50 -                dimension = dimension.append("[]");
   55.51 +                s.append("[]");
   55.52                  t = env.types.elemtype(t);
   55.53              }
   55.54 -            return getTypeString(env, t, full) + dimension;
   55.55 +            s.insert(0, getTypeString(env, t, full));
   55.56 +            return s.toString();
   55.57          case CLASS:
   55.58              return ParameterizedTypeImpl.
   55.59                          parameterizedTypeToString(env, (ClassType)t, full);
   55.60 @@ -157,7 +156,7 @@
   55.61          if (env.legacyDoclet || sym.type.getTypeArguments().isEmpty()) {
   55.62              return "";
   55.63          }
   55.64 -        StringBuffer s = new StringBuffer();
   55.65 +        StringBuilder s = new StringBuilder();
   55.66          for (Type t : sym.type.getTypeArguments()) {
   55.67              s.append(s.length() == 0 ? "<" : ", ");
   55.68              s.append(TypeVariableImpl.typeVarToString(env, (TypeVar)t, full));
   55.69 @@ -175,7 +174,7 @@
   55.70          if (env.legacyDoclet || cl.getTypeArguments().isEmpty()) {
   55.71              return "";
   55.72          }
   55.73 -        StringBuffer s = new StringBuffer();
   55.74 +        StringBuilder s = new StringBuilder();
   55.75          for (Type t : cl.getTypeArguments()) {
   55.76              s.append(s.length() == 0 ? "<" : ", ");
   55.77              s.append(getTypeString(env, t, full));
   55.78 @@ -213,9 +212,9 @@
   55.79           * For example, a two dimensional array of String returns '[][]'.
   55.80           */
   55.81          public String dimension() {
   55.82 -            StringBuffer dimension = new StringBuffer();
   55.83 +            StringBuilder dimension = new StringBuilder();
   55.84              for (Type t = arrayType; t.tag == ARRAY; t = env.types.elemtype(t)) {
   55.85 -                dimension = dimension.append("[]");
   55.86 +                dimension.append("[]");
   55.87              }
   55.88              return dimension.toString();
   55.89          }
   55.90 @@ -304,6 +303,7 @@
   55.91           *
   55.92           * @return name of type including any dimension information.
   55.93           */
   55.94 +        @Override
   55.95          public String toString() {
   55.96              return qualifiedTypeName() + dimension();
   55.97          }
    56.1 --- a/src/share/classes/com/sun/tools/javadoc/TypeVariableImpl.java	Thu Mar 10 17:11:19 2011 -0800
    56.2 +++ b/src/share/classes/com/sun/tools/javadoc/TypeVariableImpl.java	Thu Mar 10 20:51:07 2011 -0800
    56.3 @@ -1,5 +1,5 @@
    56.4  /*
    56.5 - * Copyright (c) 2003, 2008, Oracle and/or its affiliates. All rights reserved.
    56.6 + * Copyright (c) 2003, 2011, Oracle and/or its affiliates. All rights reserved.
    56.7   * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
    56.8   *
    56.9   * This code is free software; you can redistribute it and/or modify it
   56.10 @@ -78,14 +78,17 @@
   56.11      /**
   56.12       * Return the ClassDoc of the erasure of this type variable.
   56.13       */
   56.14 +    @Override
   56.15      public ClassDoc asClassDoc() {
   56.16          return env.getClassDoc((ClassSymbol)env.types.erasure(type).tsym);
   56.17      }
   56.18  
   56.19 +    @Override
   56.20      public TypeVariable asTypeVariable() {
   56.21          return this;
   56.22      }
   56.23  
   56.24 +    @Override
   56.25      public String toString() {
   56.26          return typeVarToString(env, (TypeVar)type, true);
   56.27      }
   56.28 @@ -96,7 +99,7 @@
   56.29       * "extends" clause.  Class names are qualified if "full" is true.
   56.30       */
   56.31      static String typeVarToString(DocEnv env, TypeVar v, boolean full) {
   56.32 -        StringBuffer s = new StringBuffer(v.toString());
   56.33 +        StringBuilder s = new StringBuilder(v.toString());
   56.34          List<Type> bounds = getBounds(v, env);
   56.35          if (bounds.nonEmpty()) {
   56.36              boolean first = true;
    57.1 --- a/src/share/classes/com/sun/tools/javadoc/WildcardTypeImpl.java	Thu Mar 10 17:11:19 2011 -0800
    57.2 +++ b/src/share/classes/com/sun/tools/javadoc/WildcardTypeImpl.java	Thu Mar 10 20:51:07 2011 -0800
    57.3 @@ -1,5 +1,5 @@
    57.4  /*
    57.5 - * Copyright (c) 2003, 2005, Oracle and/or its affiliates. All rights reserved.
    57.6 + * Copyright (c) 2003, 2011, Oracle and/or its affiliates. All rights reserved.
    57.7   * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
    57.8   *
    57.9   * This code is free software; you can redistribute it and/or modify it
   57.10 @@ -28,8 +28,6 @@
   57.11  
   57.12  import com.sun.javadoc.*;
   57.13  
   57.14 -import static com.sun.javadoc.LanguageVersion.*;
   57.15 -
   57.16  import com.sun.tools.javac.code.Symbol.ClassSymbol;
   57.17  import com.sun.tools.javac.code.Type;
   57.18  import com.sun.tools.javac.util.List;
   57.19 @@ -69,18 +67,24 @@
   57.20      /**
   57.21       * Return the ClassDoc of the erasure of this wildcard type.
   57.22       */
   57.23 +    @Override
   57.24      public ClassDoc asClassDoc() {
   57.25          return env.getClassDoc((ClassSymbol)env.types.erasure(type).tsym);
   57.26      }
   57.27  
   57.28 +    @Override
   57.29      public WildcardType asWildcardType() {
   57.30          return this;
   57.31      }
   57.32  
   57.33 +    @Override
   57.34      public String typeName()            { return "?"; }
   57.35 +    @Override
   57.36      public String qualifiedTypeName()   { return "?"; }
   57.37 +    @Override
   57.38      public String simpleTypeName()      { return "?"; }
   57.39  
   57.40 +    @Override
   57.41      public String toString() {
   57.42          return wildcardTypeToString(env, (Type.WildcardType)type, true);
   57.43      }
   57.44 @@ -96,7 +100,7 @@
   57.45          if (env.legacyDoclet) {
   57.46              return TypeMaker.getTypeName(env.types.erasure(wildThing), full);
   57.47          }
   57.48 -        StringBuffer s = new StringBuffer("?");
   57.49 +        StringBuilder s = new StringBuilder("?");
   57.50          List<Type> bounds = getExtendsBounds(wildThing);
   57.51          if (bounds.nonEmpty()) {
   57.52              s.append(" extends ");
    58.1 --- a/src/share/classes/com/sun/tools/javadoc/resources/javadoc.properties	Thu Mar 10 17:11:19 2011 -0800
    58.2 +++ b/src/share/classes/com/sun/tools/javadoc/resources/javadoc.properties	Thu Mar 10 20:51:07 2011 -0800
    58.3 @@ -1,5 +1,5 @@
    58.4  #
    58.5 -# Copyright (c) 1997, 2010, Oracle and/or its affiliates. All rights reserved.
    58.6 +# Copyright (c) 1997, 2011, Oracle and/or its affiliates. All rights reserved.
    58.7  # DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
    58.8  #
    58.9  # This code is free software; you can redistribute it and/or modify it
   58.10 @@ -104,7 +104,7 @@
   58.11  tag.End_delimiter_missing_for_possible_SeeTag=End Delimiter } missing for possible See Tag in comment string: "{0}"
   58.12  tag.Improper_Use_Of_Link_Tag=Missing closing ''}'' character for inline tag: "{0}"
   58.13  javadoc.File_Read_Error=Error while reading file {0}
   58.14 -javadoc.Body_missing_from_html_file=Body tag missing from HTML
   58.15 +javadoc.Body_missing_from_html_file=Body tag missing from HTML file
   58.16  javadoc.End_body_missing_from_html_file=Close body tag missing from HTML file
   58.17  javadoc.Multiple_package_comments=Multiple sources of package comments found for package "{0}"
   58.18  javadoc.class_not_found=Class {0} not found.
    59.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
    59.2 +++ b/test/tools/javac/7023703/T7023703neg.java	Thu Mar 10 20:51:07 2011 -0800
    59.3 @@ -0,0 +1,71 @@
    59.4 +/*
    59.5 + * Copyright (c) 2011, 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 +/* @test
   59.28 + * @bug 7023703
   59.29 + * @summary Valid code doesn't compile
   59.30 + * @compile/fail/ref=T7023703neg.out -XDrawDiagnostics T7023703neg.java
   59.31 + */
   59.32 +
   59.33 +class T7023703neg {
   59.34 +
   59.35 +    void testForLoop(boolean cond) {
   59.36 +        final int bug;
   59.37 +        final int bug2;
   59.38 +        for (;cond;) {
   59.39 +            final int item = 0;
   59.40 +            bug2 = 1; //error
   59.41 +        }
   59.42 +        bug = 0; //ok
   59.43 +    }
   59.44 +
   59.45 +    void testForEachLoop(java.util.Collection<Integer> c) {
   59.46 +        final int bug;
   59.47 +        final int bug2;
   59.48 +        for (Integer i : c) {
   59.49 +            final int item = 0;
   59.50 +            bug2 = 1; //error
   59.51 +        }
   59.52 +        bug = 0; //ok
   59.53 +    }
   59.54 +
   59.55 +    void testWhileLoop(boolean cond) {
   59.56 +        final int bug;
   59.57 +        final int bug2;
   59.58 +        while (cond) {
   59.59 +            final int item = 0;
   59.60 +            bug2 = 1; //error
   59.61 +        }
   59.62 +        bug = 0; //ok
   59.63 +    }
   59.64 +
   59.65 +    void testDoWhileLoop(boolean cond) {
   59.66 +        final int bug;
   59.67 +        final int bug2;
   59.68 +        do {
   59.69 +            final int item = 0;
   59.70 +            bug2 = 1; //error
   59.71 +        } while (cond);
   59.72 +        bug = 0; //ok
   59.73 +    }
   59.74 +}
    60.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
    60.2 +++ b/test/tools/javac/7023703/T7023703neg.out	Thu Mar 10 20:51:07 2011 -0800
    60.3 @@ -0,0 +1,5 @@
    60.4 +T7023703neg.java:37:13: compiler.err.var.might.be.assigned.in.loop: bug2
    60.5 +T7023703neg.java:47:13: compiler.err.var.might.be.assigned.in.loop: bug2
    60.6 +T7023703neg.java:57:13: compiler.err.var.might.be.assigned.in.loop: bug2
    60.7 +T7023703neg.java:67:13: compiler.err.var.might.be.assigned.in.loop: bug2
    60.8 +4 errors
    61.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
    61.2 +++ b/test/tools/javac/7023703/T7023703pos.java	Thu Mar 10 20:51:07 2011 -0800
    61.3 @@ -0,0 +1,73 @@
    61.4 +/*
    61.5 + * Copyright (c) 2011, 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 +/* @test
   61.28 + * @bug 7023703
   61.29 + * @summary Valid code doesn't compile
   61.30 + * @compile T7023703pos.java
   61.31 + */
   61.32 +
   61.33 +class T7023703pos {
   61.34 +
   61.35 +    void testForLoop() {
   61.36 +        final int bug;
   61.37 +        for (;"a".equals("b");) {
   61.38 +            final int item = 0;
   61.39 +        }
   61.40 +        bug = 0; //ok
   61.41 +    }
   61.42 +
   61.43 +    void testForEachLoop(boolean cond, java.util.Collection<Integer> c) {
   61.44 +        final int bug;
   61.45 +        for (Integer i : c) {
   61.46 +            if (cond) {
   61.47 +                final int item = 0;
   61.48 +            }
   61.49 +        }
   61.50 +        bug = 0; //ok
   61.51 +    }
   61.52 +
   61.53 +    void testWhileLoop() {
   61.54 +        final int bug;
   61.55 +        while ("a".equals("b")) {
   61.56 +            final int item = 0;
   61.57 +        }
   61.58 +        bug = 0; //ok
   61.59 +    }
   61.60 +
   61.61 +    void testDoWhileLoop() {
   61.62 +        final int bug;
   61.63 +        do {
   61.64 +            final int item = 0;
   61.65 +        } while ("a".equals("b"));
   61.66 +        bug = 0; //ok
   61.67 +    }
   61.68 +
   61.69 +    private static class Inner {
   61.70 +        private final int a, b, c, d, e;
   61.71 +
   61.72 +        public Inner() {
   61.73 +            a = b = c = d = e = 0;
   61.74 +        }
   61.75 +    }
   61.76 +}
    62.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
    62.2 +++ b/test/tools/javac/7024568/T7024568.java	Thu Mar 10 20:51:07 2011 -0800
    62.3 @@ -0,0 +1,46 @@
    62.4 +/*
    62.5 + * Copyright (c) 2011, 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 +/* @test
   62.28 + * @bug 7024568
   62.29 + * @summary Very long method resolution causing OOM error
   62.30 + * @compile/fail/ref=T7024568.out -XDrawDiagnostics T7024568.java
   62.31 + */
   62.32 +
   62.33 +class Main {
   62.34 +    void test(Obj o) {
   62.35 +        o.test(0, 0, 0, 0, 0, 0, 0, 0, undefined);
   62.36 +    }
   62.37 +}
   62.38 +
   62.39 +interface Test {
   62.40 +    public void test(int i1, int i2, int i3, int i4, int i5, int i6, int i7, int i8, String str);
   62.41 +    public void test(int i1, int i2, int i3, int i4, int i5, int i6, int i7, int i8, long l);
   62.42 +}
   62.43 +
   62.44 +interface Obj extends Test, A, B, C, D, E {}
   62.45 +interface A extends Test {}
   62.46 +interface B extends A, Test {}
   62.47 +interface C extends A, B, Test {}
   62.48 +interface D extends A, B, C, Test {}
   62.49 +interface E extends A, B, C, D, Test {}
    63.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
    63.2 +++ b/test/tools/javac/7024568/T7024568.out	Thu Mar 10 20:51:07 2011 -0800
    63.3 @@ -0,0 +1,2 @@
    63.4 +T7024568.java:32:40: compiler.err.cant.resolve.location: kindname.variable, undefined, , , (compiler.misc.location: kindname.class, Main, null)
    63.5 +1 error
    64.1 --- a/test/tools/javac/AnonStaticMember_2.java	Thu Mar 10 17:11:19 2011 -0800
    64.2 +++ b/test/tools/javac/AnonStaticMember_2.java	Thu Mar 10 20:51:07 2011 -0800
    64.3 @@ -1,6 +1,6 @@
    64.4  /*
    64.5   * @test  /nodynamiccopyright/
    64.6 - * @bug 4279339
    64.7 + * @bug 4279339 6969184
    64.8   * @summary Verify that an anonymous class cannot contain a static method.
    64.9   * @author maddox
   64.10   *
    65.1 --- a/test/tools/javac/InterfaceInInner.java	Thu Mar 10 17:11:19 2011 -0800
    65.2 +++ b/test/tools/javac/InterfaceInInner.java	Thu Mar 10 20:51:07 2011 -0800
    65.3 @@ -1,6 +1,6 @@
    65.4  /*
    65.5   * @test  /nodynamiccopyright/
    65.6 - * @bug 4063740
    65.7 + * @bug 4063740 6969184
    65.8   * @summary Interfaces may only be declared in top level classes.
    65.9   * @author turnidge
   65.10   *
    66.1 --- a/test/tools/javac/QualifiedNew.java	Thu Mar 10 17:11:19 2011 -0800
    66.2 +++ b/test/tools/javac/QualifiedNew.java	Thu Mar 10 20:51:07 2011 -0800
    66.3 @@ -1,6 +1,6 @@
    66.4  /*
    66.5   * @test  /nodynamiccopyright/
    66.6 - * @bug 4406966
    66.7 + * @bug 4406966 6969184
    66.8   * @summary null qualifying inner instance creation should be error.
    66.9   * @author gafter
   66.10   *
    67.1 --- a/test/tools/javac/T6900037.java	Thu Mar 10 17:11:19 2011 -0800
    67.2 +++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
    67.3 @@ -1,34 +0,0 @@
    67.4 -/*
    67.5 - * Copyright (c) 2010, Oracle and/or its affiliates. All rights reserved.
    67.6 - * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
    67.7 - *
    67.8 - * This code is free software; you can redistribute it and/or modify it
    67.9 - * under the terms of the GNU General Public License version 2 only, as
   67.10 - * published by the Free Software Foundation.
   67.11 - *
   67.12 - * This code is distributed in the hope that it will be useful, but WITHOUT
   67.13 - * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
   67.14 - * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
   67.15 - * version 2 for more details (a copy is included in the LICENSE file that
   67.16 - * accompanied this code).
   67.17 - *
   67.18 - * You should have received a copy of the GNU General Public License version
   67.19 - * 2 along with this work; if not, write to the Free Software Foundation,
   67.20 - * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
   67.21 - *
   67.22 - * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
   67.23 - * or visit www.oracle.com if you need additional information or have any
   67.24 - * questions.
   67.25 - */
   67.26 -
   67.27 -/*
   67.28 - * @test
   67.29 - * @bug 6900037
   67.30 - * @summary javac should warn if earlier -source is used and bootclasspath not set
   67.31 - * @compile T6900037.java
   67.32 - * @compile -source 1.6 T6900037.java
   67.33 - * @compile/fail/ref=T6900037.out -XDrawDiagnostics -Werror -source 1.6 T6900037.java
   67.34 - * @compile -Werror -source 1.6 -Xlint:-options T6900037.java
   67.35 - */
   67.36 -
   67.37 -class T6900037 { }
    68.1 --- a/test/tools/javac/T6900037.out	Thu Mar 10 17:11:19 2011 -0800
    68.2 +++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
    68.3 @@ -1,4 +0,0 @@
    68.4 -- compiler.warn.source.no.bootclasspath: 1.6
    68.5 -- compiler.err.warnings.and.werror
    68.6 -1 error
    68.7 -1 warning
    69.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
    69.2 +++ b/test/tools/javac/TryWithResources/T7022711.java	Thu Mar 10 20:51:07 2011 -0800
    69.3 @@ -0,0 +1,20 @@
    69.4 +/*
    69.5 + * @test /nodynamiccopyright/
    69.6 + * @bug 7022711
    69.7 + * @summary compiler crash in try-with-resources
    69.8 + * @compile/fail/ref=T7022711.out -XDrawDiagnostics T7022711.java
    69.9 + */
   69.10 +
   69.11 +import java.io.*;
   69.12 +
   69.13 +class T7022711 {
   69.14 +    public static void main (String args[]) throws Exception {
   69.15 +        try (DataInputStream is = new DataInputStream(new FileInputStream("x"))) {
   69.16 +            while (true) {
   69.17 +                is.getChar();  // method not found
   69.18 +            }
   69.19 +        } catch (EOFException e) {
   69.20 +        }
   69.21 +    }
   69.22 +}
   69.23 +
    70.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
    70.2 +++ b/test/tools/javac/TryWithResources/T7022711.out	Thu Mar 10 20:51:07 2011 -0800
    70.3 @@ -0,0 +1,2 @@
    70.4 +T7022711.java:14:19: compiler.err.cant.resolve.location.args: kindname.method, getChar, , , (compiler.misc.location.1: kindname.variable, is, java.io.DataInputStream)
    70.5 +1 error
    71.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
    71.2 +++ b/test/tools/javac/TryWithResources/UnusedResourcesTest.java	Thu Mar 10 20:51:07 2011 -0800
    71.3 @@ -0,0 +1,250 @@
    71.4 +/*
    71.5 + * Copyright (c) 2011, Oracle and/or its affiliates. All rights reserved.
    71.6 + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
    71.7 + *
    71.8 + * This code is free software; you can redistribute it and/or modify it
    71.9 + * under the terms of the GNU General Public License version 2 only, as
   71.10 + * published by the Free Software Foundation.
   71.11 + *
   71.12 + * This code is distributed in the hope that it will be useful, but WITHOUT
   71.13 + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
   71.14 + * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
   71.15 + * version 2 for more details (a copy is included in the LICENSE file that
   71.16 + * accompanied this code).
   71.17 + *
   71.18 + * You should have received a copy of the GNU General Public License version
   71.19 + * 2 along with this work; if not, write to the Free Software Foundation,
   71.20 + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
   71.21 + *
   71.22 + * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
   71.23 + * or visit www.oracle.com if you need additional information or have any
   71.24 + * questions.
   71.25 + */
   71.26 +
   71.27 +/*
   71.28 + * @test
   71.29 + * @bug 7023233
   71.30 + * @summary False positive for -Xlint:try with nested try with resources blocks
   71.31 + */
   71.32 +
   71.33 +import com.sun.source.util.JavacTask;
   71.34 +import com.sun.tools.javac.api.JavacTool;
   71.35 +import com.sun.tools.javac.util.JCDiagnostic;
   71.36 +import java.net.URI;
   71.37 +import java.util.Arrays;
   71.38 +import javax.tools.Diagnostic;
   71.39 +import javax.tools.JavaCompiler;
   71.40 +import javax.tools.JavaFileObject;
   71.41 +import javax.tools.SimpleJavaFileObject;
   71.42 +import javax.tools.StandardJavaFileManager;
   71.43 +import javax.tools.ToolProvider;
   71.44 +
   71.45 +public class UnusedResourcesTest {
   71.46 +
   71.47 +    enum XlintOption {
   71.48 +        NONE("none"),
   71.49 +        TRY("try");
   71.50 +
   71.51 +        String opt;
   71.52 +
   71.53 +        XlintOption(String opt) {
   71.54 +            this.opt = opt;
   71.55 +        }
   71.56 +
   71.57 +        String getXlintOption() {
   71.58 +            return "-Xlint:" + opt;
   71.59 +        }
   71.60 +    }
   71.61 +
   71.62 +    enum TwrStmt {
   71.63 +        TWR1("res1"),
   71.64 +        TWR2("res2"),
   71.65 +        TWR3("res3");
   71.66 +
   71.67 +        final String resourceName;
   71.68 +
   71.69 +        private TwrStmt(String resourceName) {
   71.70 +            this.resourceName = resourceName;
   71.71 +        }
   71.72 +    }
   71.73 +
   71.74 +    enum SuppressLevel {
   71.75 +        NONE,
   71.76 +        SUPPRESS;
   71.77 +
   71.78 +        String getSuppressAnno() {
   71.79 +            return this == SUPPRESS ?
   71.80 +                "@SuppressWarnings(\"try\")" :
   71.81 +                "";
   71.82 +        }
   71.83 +    }
   71.84 +
   71.85 +    enum ResourceUsage {
   71.86 +        NONE(null),
   71.87 +        USE_R1(TwrStmt.TWR1),
   71.88 +        USE_R2(TwrStmt.TWR2),
   71.89 +        USE_R3(TwrStmt.TWR3);
   71.90 +
   71.91 +        TwrStmt stmt;
   71.92 +
   71.93 +        private ResourceUsage(TwrStmt stmt) {
   71.94 +            this.stmt = stmt;
   71.95 +        }
   71.96 +
   71.97 +        String usedResourceName() {
   71.98 +            return stmt != null ? stmt.resourceName : null;
   71.99 +        }
  71.100 +
  71.101 +        boolean isUsedIn(TwrStmt res, TwrStmt stmt) {
  71.102 +            return this.stmt == res &&
  71.103 +                    stmt.ordinal() >= this.stmt.ordinal();
  71.104 +        }
  71.105 +
  71.106 +        String getUsage(TwrStmt stmt) {
  71.107 +            return this != NONE && stmt.ordinal() >= this.stmt.ordinal() ?
  71.108 +                "use(" + usedResourceName() + ");" :
  71.109 +                "";
  71.110 +        }
  71.111 +    }
  71.112 +
  71.113 +    static class JavaSource extends SimpleJavaFileObject {
  71.114 +
  71.115 +        String template = "class Resource implements AutoCloseable {\n" +
  71.116 +                              "public void close() {}\n" +
  71.117 +                          "}\n" +
  71.118 +                          "class Test {\n" +
  71.119 +                              "void use(Resource r) {}\n" +
  71.120 +                              "#S void test() {\n" +
  71.121 +                                 "try (Resource #R1 = new Resource()) {\n" +
  71.122 +                                    "#U1_R1\n" +
  71.123 +                                    "#U1_R2\n" +
  71.124 +                                    "#U1_R3\n" +
  71.125 +                                    "try (Resource #R2 = new Resource()) {\n" +
  71.126 +                                       "#U2_R1\n" +
  71.127 +                                       "#U2_R2\n" +
  71.128 +                                       "#U2_R3\n" +
  71.129 +                                       "try (Resource #R3 = new Resource()) {\n" +
  71.130 +                                           "#U3_R1\n" +
  71.131 +                                           "#U3_R2\n" +
  71.132 +                                           "#U3_R3\n" +
  71.133 +                                       "}\n" +
  71.134 +                                    "}\n" +
  71.135 +                                 "}\n" +
  71.136 +                              "}\n" +
  71.137 +                          "}\n";
  71.138 +
  71.139 +        String source;
  71.140 +
  71.141 +        public JavaSource(SuppressLevel suppressLevel, ResourceUsage usage1,
  71.142 +                ResourceUsage usage2, ResourceUsage usage3) {
  71.143 +            super(URI.create("myfo:/Test.java"), JavaFileObject.Kind.SOURCE);
  71.144 +            source = template.replace("#S", suppressLevel.getSuppressAnno()).
  71.145 +                    replace("#R1", TwrStmt.TWR1.resourceName).
  71.146 +                    replace("#R2", TwrStmt.TWR2.resourceName).
  71.147 +                    replace("#R3", TwrStmt.TWR3.resourceName).
  71.148 +                    replace("#U1_R1", usage1.getUsage(TwrStmt.TWR1)).
  71.149 +                    replace("#U1_R2", usage2.getUsage(TwrStmt.TWR1)).
  71.150 +                    replace("#U1_R3", usage3.getUsage(TwrStmt.TWR1)).
  71.151 +                    replace("#U2_R1", usage1.getUsage(TwrStmt.TWR2)).
  71.152 +                    replace("#U2_R2", usage2.getUsage(TwrStmt.TWR2)).
  71.153 +                    replace("#U2_R3", usage3.getUsage(TwrStmt.TWR2)).
  71.154 +                    replace("#U3_R1", usage1.getUsage(TwrStmt.TWR3)).
  71.155 +                    replace("#U3_R2", usage2.getUsage(TwrStmt.TWR3)).
  71.156 +                    replace("#U3_R3", usage3.getUsage(TwrStmt.TWR3));
  71.157 +        }
  71.158 +
  71.159 +        @Override
  71.160 +        public CharSequence getCharContent(boolean ignoreEncodingErrors) {
  71.161 +            return source;
  71.162 +        }
  71.163 +    }
  71.164 +
  71.165 +    public static void main(String... args) throws Exception {
  71.166 +        for (XlintOption xlint : XlintOption.values()) {
  71.167 +            for (SuppressLevel suppressLevel : SuppressLevel.values()) {
  71.168 +                for (ResourceUsage usage1 : ResourceUsage.values()) {
  71.169 +                    for (ResourceUsage usage2 : ResourceUsage.values()) {
  71.170 +                        for (ResourceUsage usage3 : ResourceUsage.values()) {
  71.171 +                                test(xlint,
  71.172 +                                        suppressLevel,
  71.173 +                                        usage1,
  71.174 +                                        usage2,
  71.175 +                                        usage3);
  71.176 +                        }
  71.177 +                    }
  71.178 +                }
  71.179 +            }
  71.180 +        }
  71.181 +    }
  71.182 +
  71.183 +    // Create a single file manager and reuse it for each compile to save time.
  71.184 +    static StandardJavaFileManager fm = JavacTool.create().getStandardFileManager(null, null, null);
  71.185 +
  71.186 +    static void test(XlintOption xlint, SuppressLevel suppressLevel, ResourceUsage usage1,
  71.187 +                ResourceUsage usage2, ResourceUsage usage3) throws Exception {
  71.188 +        final JavaCompiler tool = ToolProvider.getSystemJavaCompiler();
  71.189 +        JavaSource source = new JavaSource(suppressLevel, usage1, usage2, usage3);
  71.190 +        DiagnosticChecker dc = new DiagnosticChecker();
  71.191 +        JavacTask ct = (JavacTask)tool.getTask(null, fm, dc,
  71.192 +                Arrays.asList(xlint.getXlintOption()), null, Arrays.asList(source));
  71.193 +        ct.analyze();
  71.194 +        check(source, xlint, suppressLevel, usage1, usage2, usage3, dc);
  71.195 +    }
  71.196 +
  71.197 +    static void check(JavaSource source, XlintOption xlint, SuppressLevel suppressLevel,
  71.198 +                ResourceUsage usage1, ResourceUsage usage2, ResourceUsage usage3, DiagnosticChecker dc) {
  71.199 +
  71.200 +        ResourceUsage[] usages = { usage1, usage2, usage3 };
  71.201 +        boolean[] unusedFound = { dc.unused_r1, dc.unused_r2, dc.unused_r3 };
  71.202 +        boolean[] usedResources = { false, false, false };
  71.203 +
  71.204 +        for (TwrStmt res : TwrStmt.values()) {
  71.205 +            outer: for (TwrStmt stmt : TwrStmt.values()) {
  71.206 +                for (ResourceUsage usage : usages) {
  71.207 +                    if (usage.isUsedIn(res, stmt)) {
  71.208 +                        usedResources[res.ordinal()] = true;
  71.209 +                        break outer;
  71.210 +                    }
  71.211 +                }
  71.212 +            }
  71.213 +        }
  71.214 +
  71.215 +        for (TwrStmt stmt : TwrStmt.values()) {
  71.216 +            boolean unused = !usedResources[stmt.ordinal()] &&
  71.217 +                    xlint == XlintOption.TRY &&
  71.218 +                    suppressLevel != SuppressLevel.SUPPRESS;
  71.219 +            if (unused != unusedFound[stmt.ordinal()]) {
  71.220 +                throw new Error("invalid diagnostics for source:\n" +
  71.221 +                    source.getCharContent(true) +
  71.222 +                    "\nOptions: " + xlint.getXlintOption() +
  71.223 +                    "\nFound unused res1: " + unusedFound[0] +
  71.224 +                    "\nFound unused res2: " + unusedFound[1] +
  71.225 +                    "\nFound unused res3: " + unusedFound[2] +
  71.226 +                    "\nExpected unused res1: " + !usedResources[0] +
  71.227 +                    "\nExpected unused res2: " + !usedResources[1] +
  71.228 +                    "\nExpected unused res3: " + !usedResources[2]);
  71.229 +            }
  71.230 +        }
  71.231 +    }
  71.232 +
  71.233 +    static class DiagnosticChecker implements javax.tools.DiagnosticListener<JavaFileObject> {
  71.234 +
  71.235 +        boolean unused_r1 = false;
  71.236 +        boolean unused_r2 = false;
  71.237 +        boolean unused_r3 = false;
  71.238 +
  71.239 +        public void report(Diagnostic<? extends JavaFileObject> diagnostic) {
  71.240 +            if (diagnostic.getKind() == Diagnostic.Kind.WARNING &&
  71.241 +                    diagnostic.getCode().contains("try.resource.not.referenced")) {
  71.242 +                String varName = ((JCDiagnostic)diagnostic).getArgs()[0].toString();
  71.243 +                if (varName.equals(TwrStmt.TWR1.resourceName)) {
  71.244 +                    unused_r1 = true;
  71.245 +                } else if (varName.equals(TwrStmt.TWR2.resourceName)) {
  71.246 +                    unused_r2 = true;
  71.247 +                } else if (varName.equals(TwrStmt.TWR3.resourceName)) {
  71.248 +                    unused_r3 = true;
  71.249 +                }
  71.250 +            }
  71.251 +        }
  71.252 +    }
  71.253 +}
    72.1 --- a/test/tools/javac/api/6557752/T6557752.java	Thu Mar 10 17:11:19 2011 -0800
    72.2 +++ b/test/tools/javac/api/6557752/T6557752.java	Thu Mar 10 20:51:07 2011 -0800
    72.3 @@ -1,5 +1,5 @@
    72.4  /*
    72.5 - * Copyright (c) 2006, 2008, Oracle and/or its affiliates. All rights reserved.
    72.6 + * Copyright (c) 2006, 2011, 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 @@ -119,7 +119,7 @@
   72.11                  Types types = task.getTypes();
   72.12  
   72.13                  if (types.asElement(trees.getOriginalType((ErrorType)typeMirror)) != null) {
   72.14 -                    throw new AssertionError("Ttypes.asElement() error!");
   72.15 +                    throw new AssertionError("Types.asElement() error!");
   72.16                  }
   72.17                  foundError = true;
   72.18                }
    73.1 --- a/test/tools/javac/diags/ArgTypeCompilerFactory.java	Thu Mar 10 17:11:19 2011 -0800
    73.2 +++ b/test/tools/javac/diags/ArgTypeCompilerFactory.java	Thu Mar 10 20:51:07 2011 -0800
    73.3 @@ -34,6 +34,7 @@
    73.4  import com.sun.tools.javac.code.*;
    73.5  import com.sun.tools.javac.file.*;
    73.6  import com.sun.tools.javac.main.Main;
    73.7 +import com.sun.tools.javac.main.JavaCompiler;
    73.8  import com.sun.tools.javac.parser.Token;
    73.9  import com.sun.tools.javac.util.*;
   73.10  import com.sun.tools.javac.util.AbstractDiagnosticFormatter.SimpleConfiguration;
   73.11 @@ -107,8 +108,7 @@
   73.12              JavacTaskImpl t = (JavacTaskImpl) tool.getTask(out, fm, null, opts, null, fos);
   73.13              Context c = t.getContext();
   73.14              ArgTypeMessages.preRegister(c);
   73.15 -            Options options = Options.instance(c);
   73.16 -            Log.instance(c).setDiagnosticFormatter(new ArgTypeDiagnosticFormatter(options));
   73.17 +            ArgTypeJavaCompiler.preRegister(c);
   73.18              Boolean ok = t.call();
   73.19  
   73.20              return ok;
   73.21 @@ -144,7 +144,7 @@
   73.22                  }
   73.23              };
   73.24              JavacFileManager.preRegister(c); // can't create it until Log has been set up
   73.25 -            ArgTypeDiagnosticFormatter.preRegister(c);
   73.26 +            ArgTypeJavaCompiler.preRegister(c);
   73.27              ArgTypeMessages.preRegister(c);
   73.28              int result = main.compile(args.toArray(new String[args.size()]), c);
   73.29  
   73.30 @@ -170,7 +170,7 @@
   73.31  
   73.32              Context c = new Context();
   73.33              JavacFileManager.preRegister(c); // can't create it until Log has been set up
   73.34 -            ArgTypeDiagnosticFormatter.preRegister(c);
   73.35 +            ArgTypeJavaCompiler.preRegister(c);
   73.36              ArgTypeMessages.preRegister(c);
   73.37              com.sun.tools.javac.main.Main m = new com.sun.tools.javac.main.Main("javac", out);
   73.38              int rc = m.compile(args.toArray(new String[args.size()]), c);
   73.39 @@ -189,17 +189,6 @@
   73.40       * arg types.
   73.41       */
   73.42      static class ArgTypeDiagnosticFormatter extends AbstractDiagnosticFormatter {
   73.43 -        static void preRegister(final Context context) {
   73.44 -            context.put(Log.logKey, new Context.Factory<Log>() {
   73.45 -                public Log make() {
   73.46 -                    Log log = new Log(context) { };
   73.47 -                    Options options = Options.instance(context);
   73.48 -                    log.setDiagnosticFormatter(new ArgTypeDiagnosticFormatter(options));
   73.49 -                    return log;
   73.50 -                }
   73.51 -            });
   73.52 -
   73.53 -        }
   73.54  
   73.55          ArgTypeDiagnosticFormatter(Options options) {
   73.56              super(null, new SimpleConfiguration(options,
   73.57 @@ -246,14 +235,37 @@
   73.58      }
   73.59  
   73.60      /**
   73.61 +     * Trivial subtype of JavaCompiler to get access to the protected compilerKey field.
   73.62 +     * The factory is used to ensure that the log is initialized with an instance of
   73.63 +     * ArgTypeDiagnosticFormatter before we create the required JavaCompiler.
   73.64 +     */
   73.65 +    static class ArgTypeJavaCompiler extends JavaCompiler {
   73.66 +        static void preRegister(Context context) {
   73.67 +            context.put(compilerKey, new Context.Factory<JavaCompiler>() {
   73.68 +                public JavaCompiler make(Context c) {
   73.69 +                    Log log = Log.instance(c);
   73.70 +                    Options options = Options.instance(c);
   73.71 +                    log.setDiagnosticFormatter(new ArgTypeDiagnosticFormatter(options));
   73.72 +                    return new JavaCompiler(c);
   73.73 +                }
   73.74 +            });
   73.75 +        }
   73.76 +
   73.77 +        // not used
   73.78 +        private ArgTypeJavaCompiler() {
   73.79 +            super(null);
   73.80 +        }
   73.81 +    }
   73.82 +
   73.83 +    /**
   73.84       * Diagnostic formatter which "localizes" a message as a line
   73.85       * containing a key, and a possibly empty set of descriptive strings for the
   73.86       * arg types.
   73.87       */
   73.88      static class ArgTypeMessages extends JavacMessages {
   73.89 -        static void preRegister(final Context c) {
   73.90 -            c.put(JavacMessages.messagesKey, new Context.Factory<JavacMessages>() {
   73.91 -                public JavacMessages make() {
   73.92 +        static void preRegister(Context context) {
   73.93 +            context.put(JavacMessages.messagesKey, new Context.Factory<JavacMessages>() {
   73.94 +                public JavacMessages make(Context c) {
   73.95                      return new ArgTypeMessages(c) {
   73.96                          @Override
   73.97                          public String getLocalizedString(Locale l, String key, Object... args) {
    74.1 --- a/test/tools/javac/diags/CheckResourceKeys.java	Thu Mar 10 17:11:19 2011 -0800
    74.2 +++ b/test/tools/javac/diags/CheckResourceKeys.java	Thu Mar 10 20:51:07 2011 -0800
    74.3 @@ -23,7 +23,7 @@
    74.4  
    74.5  /*
    74.6   * @test
    74.7 - * @bug 6964768 6964461 6964469 6964487 6964460 6964481
    74.8 + * @bug 6964768 6964461 6964469 6964487 6964460 6964481 6980021
    74.9   * @summary need test program to validate javac resource bundles
   74.10   */
   74.11  
    75.1 --- a/test/tools/javac/diags/Example.java	Thu Mar 10 17:11:19 2011 -0800
    75.2 +++ b/test/tools/javac/diags/Example.java	Thu Mar 10 20:51:07 2011 -0800
    75.3 @@ -486,7 +486,7 @@
    75.4              if (verbose)
    75.5                  System.err.println("run_simple: " + opts + " " + files);
    75.6  
    75.7 -            List<String> args = new ArrayList<String>(opts);
    75.8 +            List<String> args = new ArrayList<String>();
    75.9  
   75.10              if (out != null && raw)
   75.11                  args.add("-XDrawDiagnostics");
   75.12 @@ -522,10 +522,10 @@
   75.13                  super(context);
   75.14              }
   75.15  
   75.16 -            static void preRegister(final Context c, final Set<String> keys) {
   75.17 +            static void preRegister(Context c, final Set<String> keys) {
   75.18                  if (keys != null) {
   75.19                      c.put(JavacMessages.messagesKey, new Context.Factory<JavacMessages>() {
   75.20 -                        public JavacMessages make() {
   75.21 +                        public JavacMessages make(Context c) {
   75.22                              return new MessageTracker(c) {
   75.23                                  @Override
   75.24                                  public String getLocalizedString(Locale l, String key, Object... args) {
    76.1 --- a/test/tools/javac/diags/examples.not-yet.txt	Thu Mar 10 17:11:19 2011 -0800
    76.2 +++ b/test/tools/javac/diags/examples.not-yet.txt	Thu Mar 10 20:51:07 2011 -0800
    76.3 @@ -70,7 +70,6 @@
    76.4  compiler.misc.kindname.type.variable
    76.5  compiler.misc.kindname.type.variable.bound
    76.6  compiler.misc.kindname.value
    76.7 -compiler.misc.non.denotable.type
    76.8  compiler.misc.no.unique.minimal.instance.exists
    76.9  compiler.misc.resume.abort                              # prompt for a response
   76.10  compiler.misc.source.unavailable                        # DiagnosticSource
    77.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
    77.2 +++ b/test/tools/javac/diags/examples/DiamondAndAnonClass.java	Thu Mar 10 20:51:07 2011 -0800
    77.3 @@ -0,0 +1,33 @@
    77.4 +/*
    77.5 + * Copyright (c) 2011, Oracle and/or its affiliates. All rights reserved.
    77.6 + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
    77.7 + *
    77.8 + * This code is free software; you can redistribute it and/or modify it
    77.9 + * under the terms of the GNU General Public License version 2 only, as
   77.10 + * published by the Free Software Foundation.
   77.11 + *
   77.12 + * This code is distributed in the hope that it will be useful, but WITHOUT
   77.13 + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
   77.14 + * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
   77.15 + * version 2 for more details (a copy is included in the LICENSE file that
   77.16 + * accompanied this code).
   77.17 + *
   77.18 + * You should have received a copy of the GNU General Public License version
   77.19 + * 2 along with this work; if not, write to the Free Software Foundation,
   77.20 + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
   77.21 + *
   77.22 + * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
   77.23 + * or visit www.oracle.com if you need additional information or have any
   77.24 + * questions.
   77.25 + */
   77.26 +
   77.27 +// key: compiler.misc.diamond.and.anon.class
   77.28 +// key: compiler.err.cant.apply.diamond.1
   77.29 +
   77.30 +import java.util.*;
   77.31 +
   77.32 +class DiamondAndAnonClass {
   77.33 +    void m() {
   77.34 +        List<String> list = new ArrayList<>() {};
   77.35 +    }
   77.36 +}
    78.1 --- a/test/tools/javac/diags/examples/DiamondInvalidArg.java	Thu Mar 10 17:11:19 2011 -0800
    78.2 +++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
    78.3 @@ -1,31 +0,0 @@
    78.4 -/*
    78.5 - * Copyright (c) 2010, Oracle and/or its affiliates. All rights reserved.
    78.6 - * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
    78.7 - *
    78.8 - * This code is free software; you can redistribute it and/or modify it
    78.9 - * under the terms of the GNU General Public License version 2 only, as
   78.10 - * published by the Free Software Foundation.
   78.11 - *
   78.12 - * This code is distributed in the hope that it will be useful, but WITHOUT
   78.13 - * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
   78.14 - * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
   78.15 - * version 2 for more details (a copy is included in the LICENSE file that
   78.16 - * accompanied this code).
   78.17 - *
   78.18 - * You should have received a copy of the GNU General Public License version
   78.19 - * 2 along with this work; if not, write to the Free Software Foundation,
   78.20 - * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
   78.21 - *
   78.22 - * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
   78.23 - * or visit www.oracle.com if you need additional information or have any
   78.24 - * questions.
   78.25 - */
   78.26 -
   78.27 -// key: compiler.misc.diamond.invalid.arg
   78.28 -// key: compiler.misc.diamond
   78.29 -// key: compiler.err.cant.apply.diamond.1
   78.30 -
   78.31 -class DiamondInvalidArg {
   78.32 -    static class Foo<X extends Number & Comparable<Number>> { }
   78.33 -    Foo<?> foo = new Foo<>();
   78.34 -}
    79.1 --- a/test/tools/javac/diags/examples/DiamondInvalidArgs.java	Thu Mar 10 17:11:19 2011 -0800
    79.2 +++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
    79.3 @@ -1,32 +0,0 @@
    79.4 -/*
    79.5 - * Copyright (c) 2010, Oracle and/or its affiliates. All rights reserved.
    79.6 - * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
    79.7 - *
    79.8 - * This code is free software; you can redistribute it and/or modify it
    79.9 - * under the terms of the GNU General Public License version 2 only, as
   79.10 - * published by the Free Software Foundation.
   79.11 - *
   79.12 - * This code is distributed in the hope that it will be useful, but WITHOUT
   79.13 - * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
   79.14 - * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
   79.15 - * version 2 for more details (a copy is included in the LICENSE file that
   79.16 - * accompanied this code).
   79.17 - *
   79.18 - * You should have received a copy of the GNU General Public License version
   79.19 - * 2 along with this work; if not, write to the Free Software Foundation,
   79.20 - * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
   79.21 - *
   79.22 - * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
   79.23 - * or visit www.oracle.com if you need additional information or have any
   79.24 - * questions.
   79.25 - */
   79.26 -
   79.27 -// key: compiler.misc.diamond.invalid.args
   79.28 -// key: compiler.misc.diamond
   79.29 -// key: compiler.err.cant.apply.diamond.1
   79.30 -
   79.31 -class DiamondInvalidArgs {
   79.32 -    static class Foo<X extends Number & Comparable<Number>,
   79.33 -                           Y extends Number & Comparable<Number>> { }
   79.34 -    Foo<?,?> foo = new Foo<>();
   79.35 -}
    80.1 --- a/test/tools/javac/generics/6969184/T6969184.java	Thu Mar 10 17:11:19 2011 -0800
    80.2 +++ b/test/tools/javac/generics/6969184/T6969184.java	Thu Mar 10 20:51:07 2011 -0800
    80.3 @@ -1,6 +1,6 @@
    80.4  /*
    80.5   * @test /nodynamiccopyright/
    80.6 - * @bug 6956758
    80.7 + * @bug 6969184
    80.8   *
    80.9   * @summary  poor error recovery after symbol not found
   80.10   * @author Maurizio Cimadamore
    81.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
    81.2 +++ b/test/tools/javac/generics/7015430/T7015430.java	Thu Mar 10 20:51:07 2011 -0800
    81.3 @@ -0,0 +1,131 @@
    81.4 +/*
    81.5 + * @test /nodynamiccopyright/
    81.6 + * @bug 7015430
    81.7 + *
    81.8 + * @summary  Incorrect thrown type determined for unchecked invocations
    81.9 + * @author Daniel Smith
   81.10 + * @compile/fail/ref=T7015430.out -Xlint:unchecked -XDrawDiagnostics T7015430.java
   81.11 + *
   81.12 + */
   81.13 +
   81.14 +class T7015430 {
   81.15 +    static <E extends Exception> Iterable<E> empty(Iterable<E> arg) throws E {
   81.16 +        return null;
   81.17 +    }
   81.18 +
   81.19 +    <E extends Exception> T7015430(Iterable<E> arg) throws E { }
   81.20 +
   81.21 +    static <E extends Exception> Iterable<E> empty2(Iterable x) throws E {
   81.22 +        return null;
   81.23 +    }
   81.24 +
   81.25 +    static class Foo<X extends Exception> {
   81.26 +        Foo() throws X {}
   81.27 +    }
   81.28 +
   81.29 +    /**
   81.30 +    * Method invocation, no unchecked
   81.31 +    * inferred: RuntimeException - should pass
   81.32 +    */
   81.33 +    void m1() {
   81.34 +        Iterable<RuntimeException> i = java.util.Collections.emptyList();
   81.35 +        empty(i);
   81.36 +    }
   81.37 +
   81.38 +    /**
   81.39 +    * Method invocation, unchecked, inferred arguments
   81.40 +    * inferred: Exception - should fail
   81.41 +    */
   81.42 +    void m2() {
   81.43 +        Iterable i = java.util.Collections.EMPTY_LIST;
   81.44 +        empty(i);
   81.45 +    }
   81.46 +
   81.47 +    /**
   81.48 +    * Method invocation, unchecked, explicit arguments
   81.49 +    * inferred: RuntimeException - should pass
   81.50 +    */
   81.51 +    void m3() {
   81.52 +        Iterable i = java.util.Collections.EMPTY_LIST;
   81.53 +        T7015430.<RuntimeException>empty(i);
   81.54 +    }
   81.55 +
   81.56 +    /**
   81.57 +    * Constructor invocation, no unchecked
   81.58 +    * inferred: RuntimeException - should pass
   81.59 +    */
   81.60 +    void m4() {
   81.61 +        Iterable<RuntimeException> i = java.util.Collections.emptyList();
   81.62 +        new T7015430(i);
   81.63 +    }
   81.64 +
   81.65 +    /**
   81.66 +    * Constructor invocation, unchecked, inferred arguments
   81.67 +    * inferred: Exception - should fail
   81.68 +    */
   81.69 +    void m5() {
   81.70 +        Iterable i = java.util.Collections.EMPTY_LIST;
   81.71 +        new T7015430(i);
   81.72 +    }
   81.73 +
   81.74 +    /**
   81.75 +    * Constructor invocation, unchecked, explicit arguments
   81.76 +    * inferred: RuntimeException - should pass
   81.77 +    */
   81.78 +    void m6() {
   81.79 +        Iterable i = java.util.Collections.EMPTY_LIST;
   81.80 +        new <RuntimeException>T7015430(i);
   81.81 +    }
   81.82 +
   81.83 +    /**
   81.84 +    * Method invocation, no unchecked, inferred arguments
   81.85 +    * inferred: RuntimeException - should pass
   81.86 +    */
   81.87 +    void m7() {
   81.88 +        Iterable i = java.util.Collections.EMPTY_LIST;
   81.89 +        Iterable<RuntimeException> e = empty2(i);
   81.90 +    }
   81.91 +
   81.92 +    /**
   81.93 +    * Method invocation, no unchecked, inferred arguments
   81.94 +    * inferred: Exception - should fail
   81.95 +    */
   81.96 +    void m8() {
   81.97 +        Iterable i = java.util.Collections.EMPTY_LIST;
   81.98 +        empty2(i);
   81.99 +    }
  81.100 +
  81.101 +    /**
  81.102 +    * Constructor invocation, unchecked, explicit arguments
  81.103 +    * inferred: RuntimeException - should pass
  81.104 +    */
  81.105 +    void m9() {
  81.106 +        Iterable i = java.util.Collections.EMPTY_LIST;
  81.107 +        new <RuntimeException> T7015430(i);
  81.108 +    }
  81.109 +
  81.110 +    /**
  81.111 +    * Constructor invocation, unchecked, inferred arguments
  81.112 +    * inferred: Exception - should fail
  81.113 +    */
  81.114 +    void m10() {
  81.115 +        Iterable i = java.util.Collections.EMPTY_LIST;
  81.116 +        new T7015430(i);
  81.117 +    }
  81.118 +
  81.119 +    /**
  81.120 +    * Constructor invocation, no unchecked, inferred arguments (diamond)
  81.121 +    * inferred: RuntimeException - should pass
  81.122 +    */
  81.123 +    void m11() {
  81.124 +        Foo<RuntimeException>  o = new Foo<>();
  81.125 +    }
  81.126 +
  81.127 +    /**
  81.128 +    * Constructor invocation, no unchecked, inferred arguments (diamond)
  81.129 +    * inferred: Exception - should fail
  81.130 +    */
  81.131 +    void m12() {
  81.132 +        new Foo<>();
  81.133 +    }
  81.134 +}
    82.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
    82.2 +++ b/test/tools/javac/generics/7015430/T7015430.out	Thu Mar 10 20:51:07 2011 -0800
    82.3 @@ -0,0 +1,19 @@
    82.4 +T7015430.java:41:15: compiler.warn.prob.found.req: (compiler.misc.unchecked.assign), java.lang.Iterable, java.lang.Iterable<E>
    82.5 +T7015430.java:41:14: compiler.warn.unchecked.meth.invocation.applied: kindname.method, empty, java.lang.Iterable<E>, java.lang.Iterable, kindname.class, T7015430
    82.6 +T7015430.java:50:42: compiler.warn.prob.found.req: (compiler.misc.unchecked.assign), java.lang.Iterable, java.lang.Iterable<java.lang.RuntimeException>
    82.7 +T7015430.java:50:41: compiler.warn.unchecked.meth.invocation.applied: kindname.method, empty, java.lang.Iterable<E>, java.lang.Iterable, kindname.class, T7015430
    82.8 +T7015430.java:68:22: compiler.warn.prob.found.req: (compiler.misc.unchecked.assign), java.lang.Iterable, java.lang.Iterable<E>
    82.9 +T7015430.java:68:9: compiler.warn.unchecked.meth.invocation.applied: kindname.constructor, <init>, java.lang.Iterable<E>, java.lang.Iterable, kindname.class, T7015430
   82.10 +T7015430.java:77:40: compiler.warn.prob.found.req: (compiler.misc.unchecked.assign), java.lang.Iterable, java.lang.Iterable<java.lang.RuntimeException>
   82.11 +T7015430.java:77:9: compiler.warn.unchecked.meth.invocation.applied: kindname.constructor, <init>, java.lang.Iterable<E>, java.lang.Iterable, kindname.class, T7015430
   82.12 +T7015430.java:104:41: compiler.warn.prob.found.req: (compiler.misc.unchecked.assign), java.lang.Iterable, java.lang.Iterable<java.lang.RuntimeException>
   82.13 +T7015430.java:104:9: compiler.warn.unchecked.meth.invocation.applied: kindname.constructor, <init>, java.lang.Iterable<E>, java.lang.Iterable, kindname.class, T7015430
   82.14 +T7015430.java:113:22: compiler.warn.prob.found.req: (compiler.misc.unchecked.assign), java.lang.Iterable, java.lang.Iterable<E>
   82.15 +T7015430.java:113:9: compiler.warn.unchecked.meth.invocation.applied: kindname.constructor, <init>, java.lang.Iterable<E>, java.lang.Iterable, kindname.class, T7015430
   82.16 +T7015430.java:41:14: compiler.err.unreported.exception.need.to.catch.or.throw: java.lang.Exception
   82.17 +T7015430.java:68:9: compiler.err.unreported.exception.need.to.catch.or.throw: java.lang.Exception
   82.18 +T7015430.java:95:15: compiler.err.unreported.exception.need.to.catch.or.throw: java.lang.Exception
   82.19 +T7015430.java:113:9: compiler.err.unreported.exception.need.to.catch.or.throw: java.lang.Exception
   82.20 +T7015430.java:129:9: compiler.err.unreported.exception.need.to.catch.or.throw: java.lang.Exception
   82.21 +5 errors
   82.22 +12 warnings
    83.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
    83.2 +++ b/test/tools/javac/generics/7020657/T7020657neg.java	Thu Mar 10 20:51:07 2011 -0800
    83.3 @@ -0,0 +1,23 @@
    83.4 +/*
    83.5 + * @test /nodynamiccopyright/
    83.6 + * @bug 7020657 6985719
    83.7 + *
    83.8 + * @summary  Javac rejects a fairly common idiom with raw override and interfaces
    83.9 + * @author Maurizio Cimadamore
   83.10 + * @compile/fail/ref=T7020657neg.out -XDrawDiagnostics T7020657neg.java
   83.11 + *
   83.12 + */
   83.13 +
   83.14 +import java.util.*;
   83.15 +
   83.16 +class T7020657neg {
   83.17 +    interface A {
   83.18 +        int get(List<String> l);
   83.19 +    }
   83.20 +
   83.21 +    interface B  {
   83.22 +        int get(List<Integer> l);
   83.23 +    }
   83.24 +
   83.25 +    interface C extends A, B { }
   83.26 +}
    84.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
    84.2 +++ b/test/tools/javac/generics/7020657/T7020657neg.out	Thu Mar 10 20:51:07 2011 -0800
    84.3 @@ -0,0 +1,2 @@
    84.4 +T7020657neg.java:22:5: compiler.err.name.clash.same.erasure.no.override: get(java.util.List<java.lang.Integer>), T7020657neg.B, get(java.util.List<java.lang.String>), T7020657neg.A
    84.5 +1 error
    85.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
    85.2 +++ b/test/tools/javac/generics/7020657/T7020657pos.java	Thu Mar 10 20:51:07 2011 -0800
    85.3 @@ -0,0 +1,48 @@
    85.4 +/*
    85.5 + * Copyright (c) 2011, Oracle and/or its affiliates. All rights reserved.
    85.6 + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
    85.7 + *
    85.8 + * This code is free software; you can redistribute it and/or modify it
    85.9 + * under the terms of the GNU General Public License version 2 only, as
   85.10 + * published by the Free Software Foundation.
   85.11 + *
   85.12 + * This code is distributed in the hope that it will be useful, but WITHOUT
   85.13 + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
   85.14 + * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
   85.15 + * version 2 for more details (a copy is included in the LICENSE file that
   85.16 + * accompanied this code).
   85.17 + *
   85.18 + * You should have received a copy of the GNU General Public License version
   85.19 + * 2 along with this work; if not, write to the Free Software Foundation,
   85.20 + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
   85.21 + *
   85.22 + * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
   85.23 + * or visit www.oracle.com if you need additional information or have any
   85.24 + * questions.
   85.25 + */
   85.26 +
   85.27 +/*
   85.28 + * @test
   85.29 + * @bug 7020657 6985719
   85.30 + *
   85.31 + * @summary  Javac rejects a fairly common idiom with raw override and interfaces
   85.32 + * @author Robert Field
   85.33 + * @compile T7020657pos.java
   85.34 + *
   85.35 + */
   85.36 +
   85.37 +import java.util.*;
   85.38 +
   85.39 +class T7020657pos {
   85.40 +    interface A {
   85.41 +        int get(List<String> l);
   85.42 +    }
   85.43 +
   85.44 +    interface B  {
   85.45 +        int get(List<Integer> l);
   85.46 +    }
   85.47 +
   85.48 +    interface C extends A, B {
   85.49 +        int get(List l);
   85.50 +    }
   85.51 +}
    86.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
    86.2 +++ b/test/tools/javac/generics/7022054/T7022054neg1.java	Thu Mar 10 20:51:07 2011 -0800
    86.3 @@ -0,0 +1,17 @@
    86.4 +/*
    86.5 + * @test /nodynamiccopyright/
    86.6 + * @bug 7022054
    86.7 + *
    86.8 + * @summary  Invalid compiler error on covariant overriding methods with the same erasure
    86.9 + * @compile/fail/ref=T7022054neg1.out -XDrawDiagnostics T7022054neg1.java
   86.10 + *
   86.11 + */
   86.12 +
   86.13 +class T7022054neg1 {
   86.14 +    static class A {
   86.15 +        A m(String s) { return null; }
   86.16 +    }
   86.17 +    static class B extends A {
   86.18 +        <X extends String> A m(X s) { return null; }
   86.19 +    }
   86.20 +}
    87.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
    87.2 +++ b/test/tools/javac/generics/7022054/T7022054neg1.out	Thu Mar 10 20:51:07 2011 -0800
    87.3 @@ -0,0 +1,2 @@
    87.4 +T7022054neg1.java:15:30: compiler.err.name.clash.same.erasure.no.override: <X>m(X), T7022054neg1.B, m(java.lang.String), T7022054neg1.A, <X>m(X), T7022054neg1.B
    87.5 +1 error
    88.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
    88.2 +++ b/test/tools/javac/generics/7022054/T7022054neg2.java	Thu Mar 10 20:51:07 2011 -0800
    88.3 @@ -0,0 +1,17 @@
    88.4 +/*
    88.5 + * @test /nodynamiccopyright/
    88.6 + * @bug 7022054
    88.7 + *
    88.8 + * @summary  Invalid compiler error on covariant overriding methods with the same erasure
    88.9 + * @compile/fail/ref=T7022054neg2.out -XDrawDiagnostics T7022054neg2.java
   88.10 + *
   88.11 + */
   88.12 +
   88.13 +class T7022054neg2 {
   88.14 +    static class A {
   88.15 +        static A m(String s) { return null; }
   88.16 +    }
   88.17 +    static class B extends A {
   88.18 +        static <X extends String> A m(X s) { return null; }
   88.19 +    }
   88.20 +}
    89.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
    89.2 +++ b/test/tools/javac/generics/7022054/T7022054neg2.out	Thu Mar 10 20:51:07 2011 -0800
    89.3 @@ -0,0 +1,2 @@
    89.4 +T7022054neg2.java:15:37: compiler.err.name.clash.same.erasure.no.hide: <X>m(X), T7022054neg2.B, m(java.lang.String), T7022054neg2.A
    89.5 +1 error
    90.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
    90.2 +++ b/test/tools/javac/generics/7022054/T7022054pos1.java	Thu Mar 10 20:51:07 2011 -0800
    90.3 @@ -0,0 +1,40 @@
    90.4 +/*
    90.5 + * Copyright (c) 2011, Oracle and/or its affiliates. All rights reserved.
    90.6 + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
    90.7 + *
    90.8 + * This code is free software; you can redistribute it and/or modify it
    90.9 + * under the terms of the GNU General Public License version 2 only, as
   90.10 + * published by the Free Software Foundation.
   90.11 + *
   90.12 + * This code is distributed in the hope that it will be useful, but WITHOUT
   90.13 + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
   90.14 + * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
   90.15 + * version 2 for more details (a copy is included in the LICENSE file that
   90.16 + * accompanied this code).
   90.17 + *
   90.18 + * You should have received a copy of the GNU General Public License version
   90.19 + * 2 along with this work; if not, write to the Free Software Foundation,
   90.20 + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
   90.21 + *
   90.22 + * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
   90.23 + * or visit www.oracle.com if you need additional information or have any
   90.24 + * questions.
   90.25 + */
   90.26 +
   90.27 +/*
   90.28 + * @test
   90.29 + * @bug 7022054
   90.30 + *
   90.31 + * @summary  Invalid compiler error on covariant overriding methods with the same erasure
   90.32 + * @compile T7022054pos1.java
   90.33 + *
   90.34 + */
   90.35 +
   90.36 +class T7022054pos1 {
   90.37 +    static class A {
   90.38 +        A m(String s) { return null; }
   90.39 +    }
   90.40 +    static class B extends A {
   90.41 +        <X extends B> X m(String s) { return null; }
   90.42 +    }
   90.43 +}
    91.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
    91.2 +++ b/test/tools/javac/generics/7022054/T7022054pos2.java	Thu Mar 10 20:51:07 2011 -0800
    91.3 @@ -0,0 +1,40 @@
    91.4 +/*
    91.5 + * Copyright (c) 2011, 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 7022054
   91.30 + *
   91.31 + * @summary  Invalid compiler error on covariant overriding methods with the same erasure
   91.32 + * @compile T7022054pos2.java
   91.33 + *
   91.34 + */
   91.35 +
   91.36 +class T7022054pos2 {
   91.37 +    static class A {
   91.38 +        static A m(String s) { return null; }
   91.39 +    }
   91.40 +    static class B extends A {
   91.41 +        static <X extends B> X m(String s) { return null; }
   91.42 +    }
   91.43 +}
    92.1 --- a/test/tools/javac/generics/diamond/6996914/T6996914a.java	Thu Mar 10 17:11:19 2011 -0800
    92.2 +++ b/test/tools/javac/generics/diamond/6996914/T6996914a.java	Thu Mar 10 20:51:07 2011 -0800
    92.3 @@ -1,5 +1,5 @@
    92.4  /*
    92.5 - * Copyright (c) 2010, Oracle and/or its affiliates. All rights reserved.
    92.6 + * Copyright (c) 2010, 2011, Oracle and/or its affiliates. All rights reserved.
    92.7   * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
    92.8   *
    92.9   * This code is free software; you can redistribute it and/or modify it
   92.10 @@ -23,7 +23,7 @@
   92.11  
   92.12  /*
   92.13   * @test
   92.14 - * @bug 6996914
   92.15 + * @bug 6996914 7020044
   92.16   * @summary  Diamond inference: problem when accessing protected constructor
   92.17   * @run main T6996914a
   92.18   */
   92.19 @@ -53,17 +53,6 @@
   92.20          }
   92.21      }
   92.22  
   92.23 -    enum DiamondKind {
   92.24 -        STANDARD("new Foo<>();"),
   92.25 -        ANON("new Foo<>() {};");
   92.26 -
   92.27 -        String expr;
   92.28 -
   92.29 -        DiamondKind(String expr) {
   92.30 -            this.expr = expr;
   92.31 -        }
   92.32 -    }
   92.33 -
   92.34      enum ConstructorKind {
   92.35          PACKAGE(""),
   92.36          PROTECTED("protected"),
   92.37 @@ -104,14 +93,14 @@
   92.38          final static String sourceStub =
   92.39                          "#I\n" +
   92.40                          "class Test {\n" +
   92.41 -                        "  Foo<String> fs = #D\n" +
   92.42 +                        "  Foo<String> fs = new Foo<>();\n" +
   92.43                          "}\n";
   92.44  
   92.45          String source;
   92.46  
   92.47 -        public ClientClass(PackageKind pk, DiamondKind dk) {
   92.48 +        public ClientClass(PackageKind pk) {
   92.49              super(URI.create("myfo:/Test.java"), JavaFileObject.Kind.SOURCE);
   92.50 -            source = sourceStub.replace("#I", pk.importDecl).replace("#D", dk.expr);
   92.51 +            source = sourceStub.replace("#I", pk.importDecl);
   92.52          }
   92.53  
   92.54          @Override
   92.55 @@ -123,22 +112,20 @@
   92.56      public static void main(String... args) throws Exception {
   92.57          for (PackageKind pk : PackageKind.values()) {
   92.58              for (ConstructorKind ck : ConstructorKind.values()) {
   92.59 -                for (DiamondKind dk : DiamondKind.values()) {
   92.60 -                    compileAndCheck(pk, ck, dk);
   92.61 -                }
   92.62 +                    compileAndCheck(pk, ck);
   92.63              }
   92.64          }
   92.65      }
   92.66  
   92.67 -    static void compileAndCheck(PackageKind pk, ConstructorKind ck, DiamondKind dk) throws Exception {
   92.68 +    static void compileAndCheck(PackageKind pk, ConstructorKind ck) throws Exception {
   92.69          FooClass foo = new FooClass(pk, ck);
   92.70 -        ClientClass client = new ClientClass(pk, dk);
   92.71 +        ClientClass client = new ClientClass(pk);
   92.72          final JavaCompiler tool = ToolProvider.getSystemJavaCompiler();
   92.73          ErrorListener el = new ErrorListener();
   92.74          JavacTask ct = (JavacTask)tool.getTask(null, null, el,
   92.75                  null, null, Arrays.asList(foo, client));
   92.76          ct.analyze();
   92.77 -        if (el.errors > 0 == check(pk, ck, dk)) {
   92.78 +        if (el.errors > 0 == check(pk, ck)) {
   92.79              String msg = el.errors > 0 ?
   92.80                  "Error compiling files" :
   92.81                  "No error when compiling files";
   92.82 @@ -146,10 +133,9 @@
   92.83          }
   92.84      }
   92.85  
   92.86 -    static boolean check(PackageKind pk, ConstructorKind ck, DiamondKind dk) {
   92.87 +    static boolean check(PackageKind pk, ConstructorKind ck) {
   92.88          switch (pk) {
   92.89 -            case A: return ck == ConstructorKind.PUBLIC ||
   92.90 -                    (ck  == ConstructorKind.PROTECTED && dk == DiamondKind.ANON);
   92.91 +            case A: return ck == ConstructorKind.PUBLIC;
   92.92              case DEFAULT: return ck != ConstructorKind.PRIVATE;
   92.93              default: throw new AssertionError("Unknown package kind");
   92.94          }
    93.1 --- a/test/tools/javac/generics/diamond/6996914/T6996914b.java	Thu Mar 10 17:11:19 2011 -0800
    93.2 +++ b/test/tools/javac/generics/diamond/6996914/T6996914b.java	Thu Mar 10 20:51:07 2011 -0800
    93.3 @@ -1,5 +1,5 @@
    93.4  /*
    93.5 - * Copyright (c) 2010, Oracle and/or its affiliates. All rights reserved.
    93.6 + * Copyright (c) 2010, 2011, Oracle and/or its affiliates. All rights reserved.
    93.7   * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
    93.8   *
    93.9   * This code is free software; you can redistribute it and/or modify it
   93.10 @@ -23,7 +23,7 @@
   93.11  
   93.12  /*
   93.13   * @test
   93.14 - * @bug 6996914
   93.15 + * @bug 6996914 7020044
   93.16   * @summary  Diamond inference: problem when accessing protected constructor
   93.17   * @compile T6996914b.java
   93.18   */
   93.19 @@ -35,5 +35,4 @@
   93.20  
   93.21  class Test {
   93.22      Super<String,Integer> ssi1 = new Super<>(1, "", 2);
   93.23 -    Super<String,Integer> ssi2 = new Super<>(1, "", 2) {};
   93.24  }
    94.1 --- a/test/tools/javac/generics/diamond/T6939780.java	Thu Mar 10 17:11:19 2011 -0800
    94.2 +++ b/test/tools/javac/generics/diamond/T6939780.java	Thu Mar 10 20:51:07 2011 -0800
    94.3 @@ -1,6 +1,6 @@
    94.4  /*
    94.5   * @test /nodynamiccopyright/
    94.6 - * @bug 6939780
    94.7 + * @bug 6939780 7020044
    94.8   *
    94.9   * @summary  add a warning to detect diamond sites
   94.10   * @author mcimadamore
    95.1 --- a/test/tools/javac/generics/diamond/T6939780.out	Thu Mar 10 17:11:19 2011 -0800
    95.2 +++ b/test/tools/javac/generics/diamond/T6939780.out	Thu Mar 10 20:51:07 2011 -0800
    95.3 @@ -1,5 +1,3 @@
    95.4  T6939780.java:19:28: compiler.warn.diamond.redundant.args: Foo<java.lang.Number>, Foo<java.lang.Number>
    95.5  T6939780.java:20:28: compiler.warn.diamond.redundant.args.1: Foo<java.lang.Integer>, Foo<java.lang.Number>
    95.6 -T6939780.java:22:28: compiler.warn.diamond.redundant.args: Foo<java.lang.Number>, Foo<java.lang.Number>
    95.7 -T6939780.java:23:28: compiler.warn.diamond.redundant.args.1: Foo<java.lang.Integer>, Foo<java.lang.Number>
    95.8 -4 warnings
    95.9 +2 warnings
    96.1 --- a/test/tools/javac/generics/diamond/neg/Neg01.java	Thu Mar 10 17:11:19 2011 -0800
    96.2 +++ b/test/tools/javac/generics/diamond/neg/Neg01.java	Thu Mar 10 20:51:07 2011 -0800
    96.3 @@ -1,8 +1,9 @@
    96.4  /*
    96.5   * @test /nodynamiccopyright/
    96.6 - * @bug 6939620
    96.7 + * @bug 6939620 7020044
    96.8   *
    96.9 - * @summary  Switch to 'complex' diamond inference scheme
   96.10 + * @summary  Check that diamond fails when inference violates declared bounds
   96.11 + *           (basic test with nested class, generic/non-generic constructors)
   96.12   * @author mcimadamore
   96.13   * @compile/fail/ref=Neg01.out Neg01.java -XDrawDiagnostics
   96.14   *
   96.15 @@ -20,19 +21,9 @@
   96.16          Neg01<?> n3 = new Neg01<>("");
   96.17          Neg01<? super String> n4 = new Neg01<>("");
   96.18  
   96.19 -        Neg01<String> n5 = new Neg01<>(""){};
   96.20 -        Neg01<? extends String> n6 = new Neg01<>(""){};
   96.21 -        Neg01<?> n7 = new Neg01<>(""){};
   96.22 -        Neg01<? super String> n8 = new Neg01<>(""){};
   96.23 -
   96.24 -        Neg01<String> n9 = new Neg01<>("", "");
   96.25 -        Neg01<? extends String> n10 = new Neg01<>("", "");
   96.26 -        Neg01<?> n11 = new Neg01<>("", "");
   96.27 -        Foo<? super String> n12 = new Neg01<>("", "");
   96.28 -
   96.29 -        Neg01<String> n13 = new Neg01<>("", ""){};
   96.30 -        Neg01<? extends String> n14 = new Neg01<>("", ""){};
   96.31 -        Neg01<?> n15 = new Neg01<>("", ""){};
   96.32 -        Neg01<? super String> n16 = new Neg01<>("", ""){};
   96.33 +        Neg01<String> n5 = new Neg01<>("", "");
   96.34 +        Neg01<? extends String> n6 = new Neg01<>("", "");
   96.35 +        Neg01<?> n7 = new Neg01<>("", "");
   96.36 +        Foo<? super String> n8 = new Neg01<>("", "");
   96.37      }
   96.38  }
    97.1 --- a/test/tools/javac/generics/diamond/neg/Neg01.out	Thu Mar 10 17:11:19 2011 -0800
    97.2 +++ b/test/tools/javac/generics/diamond/neg/Neg01.out	Thu Mar 10 20:51:07 2011 -0800
    97.3 @@ -1,29 +1,15 @@
    97.4 -Neg01.java:18:15: compiler.err.not.within.bounds: java.lang.String, X
    97.5 -Neg01.java:18:28: compiler.err.cant.apply.diamond: (compiler.misc.diamond: Neg01), null
    97.6 -Neg01.java:19:15: compiler.err.not.within.bounds: ? extends java.lang.String, X
    97.7 -Neg01.java:19:38: compiler.err.cant.apply.diamond: (compiler.misc.diamond: Neg01), null
    97.8 -Neg01.java:20:23: compiler.err.cant.apply.diamond: (compiler.misc.diamond: Neg01), null
    97.9 -Neg01.java:21:15: compiler.err.not.within.bounds: ? super java.lang.String, X
   97.10 -Neg01.java:21:36: compiler.err.cant.apply.diamond: (compiler.misc.diamond: Neg01), null
   97.11 -Neg01.java:23:15: compiler.err.not.within.bounds: java.lang.String, X
   97.12 -Neg01.java:23:28: compiler.err.cant.apply.diamond: (compiler.misc.diamond: Neg01), null
   97.13 -Neg01.java:24:15: compiler.err.not.within.bounds: ? extends java.lang.String, X
   97.14 -Neg01.java:24:38: compiler.err.cant.apply.diamond: (compiler.misc.diamond: Neg01), null
   97.15 -Neg01.java:25:23: compiler.err.cant.apply.diamond: (compiler.misc.diamond: Neg01), null
   97.16 -Neg01.java:26:15: compiler.err.not.within.bounds: ? super java.lang.String, X
   97.17 -Neg01.java:26:36: compiler.err.cant.apply.diamond: (compiler.misc.diamond: Neg01), null
   97.18 -Neg01.java:28:15: compiler.err.not.within.bounds: java.lang.String, X
   97.19 -Neg01.java:28:28: compiler.err.cant.apply.diamond: (compiler.misc.diamond: Neg01), null
   97.20 -Neg01.java:29:15: compiler.err.not.within.bounds: ? extends java.lang.String, X
   97.21 -Neg01.java:29:39: compiler.err.cant.apply.diamond: (compiler.misc.diamond: Neg01), null
   97.22 -Neg01.java:30:24: compiler.err.cant.apply.diamond: (compiler.misc.diamond: Neg01), null
   97.23 -Neg01.java:31:9: compiler.err.cant.resolve.location: kindname.class, Foo, , , (compiler.misc.location: kindname.class, Neg01<X>, null)
   97.24 -Neg01.java:31:35: compiler.err.cant.apply.diamond: (compiler.misc.diamond: Neg01), null
   97.25 -Neg01.java:33:15: compiler.err.not.within.bounds: java.lang.String, X
   97.26 -Neg01.java:33:29: compiler.err.cant.apply.diamond: (compiler.misc.diamond: Neg01), null
   97.27 -Neg01.java:34:15: compiler.err.not.within.bounds: ? extends java.lang.String, X
   97.28 -Neg01.java:34:39: compiler.err.cant.apply.diamond: (compiler.misc.diamond: Neg01), null
   97.29 -Neg01.java:35:24: compiler.err.cant.apply.diamond: (compiler.misc.diamond: Neg01), null
   97.30 -Neg01.java:36:15: compiler.err.not.within.bounds: ? super java.lang.String, X
   97.31 -Neg01.java:36:37: compiler.err.cant.apply.diamond: (compiler.misc.diamond: Neg01), null
   97.32 -28 errors
   97.33 +Neg01.java:19:15: compiler.err.not.within.bounds: java.lang.String, X
   97.34 +Neg01.java:19:28: compiler.err.cant.apply.diamond: (compiler.misc.diamond: Neg01), null
   97.35 +Neg01.java:20:15: compiler.err.not.within.bounds: ? extends java.lang.String, X
   97.36 +Neg01.java:20:38: compiler.err.cant.apply.diamond: (compiler.misc.diamond: Neg01), null
   97.37 +Neg01.java:21:23: compiler.err.cant.apply.diamond: (compiler.misc.diamond: Neg01), null
   97.38 +Neg01.java:22:15: compiler.err.not.within.bounds: ? super java.lang.String, X
   97.39 +Neg01.java:22:36: compiler.err.cant.apply.diamond: (compiler.misc.diamond: Neg01), null
   97.40 +Neg01.java:24:15: compiler.err.not.within.bounds: java.lang.String, X
   97.41 +Neg01.java:24:28: compiler.err.cant.apply.diamond: (compiler.misc.diamond: Neg01), null
   97.42 +Neg01.java:25:15: compiler.err.not.within.bounds: ? extends java.lang.String, X
   97.43 +Neg01.java:25:38: compiler.err.cant.apply.diamond: (compiler.misc.diamond: Neg01), null
   97.44 +Neg01.java:26:23: compiler.err.cant.apply.diamond: (compiler.misc.diamond: Neg01), null
   97.45 +Neg01.java:27:9: compiler.err.cant.resolve.location: kindname.class, Foo, , , (compiler.misc.location: kindname.class, Neg01<X>, null)
   97.46 +Neg01.java:27:34: compiler.err.cant.apply.diamond: (compiler.misc.diamond: Neg01), null
   97.47 +14 errors
    98.1 --- a/test/tools/javac/generics/diamond/neg/Neg02.java	Thu Mar 10 17:11:19 2011 -0800
    98.2 +++ b/test/tools/javac/generics/diamond/neg/Neg02.java	Thu Mar 10 20:51:07 2011 -0800
    98.3 @@ -1,8 +1,9 @@
    98.4  /*
    98.5   * @test /nodynamiccopyright/
    98.6 - * @bug 6939620
    98.7 + * @bug 6939620 7020044
    98.8   *
    98.9 - * @summary  Switch to 'complex' diamond inference scheme
   98.10 + * @summary  Check that diamond fails when inference violates declared bounds
   98.11 + *           (test with nested class, qualified/simple type expressions)
   98.12   * @author mcimadamore
   98.13   * @compile/fail/ref=Neg02.out Neg02.java -XDrawDiagnostics
   98.14   *
   98.15 @@ -21,20 +22,10 @@
   98.16          Foo<?> f3 = new Foo<>("");
   98.17          Foo<? super String> f4 = new Foo<>("");
   98.18  
   98.19 -        Foo<String> f5 = new Foo<>(""){};
   98.20 -        Foo<? extends String> f6 = new Foo<>(""){};
   98.21 -        Foo<?> f7 = new Foo<>(""){};
   98.22 -        Foo<? super String> f8 = new Foo<>(""){};
   98.23 -
   98.24 -        Foo<String> f9 = new Foo<>("", "");
   98.25 -        Foo<? extends String> f10 = new Foo<>("", "");
   98.26 -        Foo<?> f11 = new Foo<>("", "");
   98.27 -        Foo<? super String> f12 = new Foo<>("", "");
   98.28 -
   98.29 -        Foo<String> f13 = new Foo<>("", ""){};
   98.30 -        Foo<? extends String> f14 = new Foo<>("", ""){};
   98.31 -        Foo<?> f15 = new Foo<>("", ""){};
   98.32 -        Foo<? super String> f16 = new Foo<>("", ""){};
   98.33 +        Foo<String> f5 = new Foo<>("", "");
   98.34 +        Foo<? extends String> f6 = new Foo<>("", "");
   98.35 +        Foo<?> f7 = new Foo<>("", "");
   98.36 +        Foo<? super String> f8 = new Foo<>("", "");
   98.37      }
   98.38  
   98.39      void testQualified() {
   98.40 @@ -43,19 +34,9 @@
   98.41          Foo<?> f3 = new Neg02.Foo<>("");
   98.42          Foo<? super String> f4 = new Neg02.Foo<>("");
   98.43  
   98.44 -        Foo<String> f5 = new Neg02.Foo<>(""){};
   98.45 -        Foo<? extends String> f6 = new Neg02.Foo<>(""){};
   98.46 -        Foo<?> f7 = new Neg02.Foo<>(""){};
   98.47 -        Foo<? super String> f8 = new Neg02.Foo<>(""){};
   98.48 -
   98.49 -        Foo<String> f9 = new Neg02.Foo<>("", "");
   98.50 -        Foo<? extends String> f10 = new Neg02.Foo<>("", "");
   98.51 -        Foo<?> f11 = new Neg02.Foo<>("", "");
   98.52 -        Foo<? super String> f12 = new Neg02.Foo<>("", "");
   98.53 -
   98.54 -        Foo<String> f13 = new Neg02.Foo<>("", ""){};
   98.55 -        Foo<? extends String> f14 = new Neg02.Foo<>("", ""){};
   98.56 -        Foo<?> f15 = new Neg02.Foo<>("", ""){};
   98.57 -        Foo<? super String> f16 = new Neg02.Foo<>("", ""){};
   98.58 +        Foo<String> f5 = new Neg02.Foo<>("", "");
   98.59 +        Foo<? extends String> f6 = new Neg02.Foo<>("", "");
   98.60 +        Foo<?> f7 = new Neg02.Foo<>("", "");
   98.61 +        Foo<? super String> f8 = new Neg02.Foo<>("", "");
   98.62      }
   98.63  }
    99.1 --- a/test/tools/javac/generics/diamond/neg/Neg02.out	Thu Mar 10 17:11:19 2011 -0800
    99.2 +++ b/test/tools/javac/generics/diamond/neg/Neg02.out	Thu Mar 10 20:51:07 2011 -0800
    99.3 @@ -1,57 +1,29 @@
    99.4 -Neg02.java:19:13: compiler.err.not.within.bounds: java.lang.String, X
    99.5 -Neg02.java:19:26: compiler.err.cant.apply.diamond: (compiler.misc.diamond: Neg02.Foo), null
    99.6 -Neg02.java:20:13: compiler.err.not.within.bounds: ? extends java.lang.String, X
    99.7 -Neg02.java:20:36: compiler.err.cant.apply.diamond: (compiler.misc.diamond: Neg02.Foo), null
    99.8 -Neg02.java:21:21: compiler.err.cant.apply.diamond: (compiler.misc.diamond: Neg02.Foo), null
    99.9 -Neg02.java:22:13: compiler.err.not.within.bounds: ? super java.lang.String, X
   99.10 -Neg02.java:22:34: compiler.err.cant.apply.diamond: (compiler.misc.diamond: Neg02.Foo), null
   99.11 -Neg02.java:24:13: compiler.err.not.within.bounds: java.lang.String, X
   99.12 -Neg02.java:24:26: compiler.err.cant.apply.diamond: (compiler.misc.diamond: Neg02.Foo), null
   99.13 -Neg02.java:25:13: compiler.err.not.within.bounds: ? extends java.lang.String, X
   99.14 -Neg02.java:25:36: compiler.err.cant.apply.diamond: (compiler.misc.diamond: Neg02.Foo), null
   99.15 -Neg02.java:26:21: compiler.err.cant.apply.diamond: (compiler.misc.diamond: Neg02.Foo), null
   99.16 -Neg02.java:27:13: compiler.err.not.within.bounds: ? super java.lang.String, X
   99.17 -Neg02.java:27:34: compiler.err.cant.apply.diamond: (compiler.misc.diamond: Neg02.Foo), null
   99.18 -Neg02.java:29:13: compiler.err.not.within.bounds: java.lang.String, X
   99.19 -Neg02.java:29:26: compiler.err.cant.apply.diamond: (compiler.misc.diamond: Neg02.Foo), null
   99.20 -Neg02.java:30:13: compiler.err.not.within.bounds: ? extends java.lang.String, X
   99.21 -Neg02.java:30:37: compiler.err.cant.apply.diamond: (compiler.misc.diamond: Neg02.Foo), null
   99.22 -Neg02.java:31:22: compiler.err.cant.apply.diamond: (compiler.misc.diamond: Neg02.Foo), null
   99.23 -Neg02.java:32:13: compiler.err.not.within.bounds: ? super java.lang.String, X
   99.24 -Neg02.java:32:35: compiler.err.cant.apply.diamond: (compiler.misc.diamond: Neg02.Foo), null
   99.25 -Neg02.java:34:13: compiler.err.not.within.bounds: java.lang.String, X
   99.26 -Neg02.java:34:27: compiler.err.cant.apply.diamond: (compiler.misc.diamond: Neg02.Foo), null
   99.27 -Neg02.java:35:13: compiler.err.not.within.bounds: ? extends java.lang.String, X
   99.28 -Neg02.java:35:37: compiler.err.cant.apply.diamond: (compiler.misc.diamond: Neg02.Foo), null
   99.29 -Neg02.java:36:22: compiler.err.cant.apply.diamond: (compiler.misc.diamond: Neg02.Foo), null
   99.30 -Neg02.java:37:13: compiler.err.not.within.bounds: ? super java.lang.String, X
   99.31 -Neg02.java:37:35: compiler.err.cant.apply.diamond: (compiler.misc.diamond: Neg02.Foo), null
   99.32 -Neg02.java:41:13: compiler.err.not.within.bounds: java.lang.String, X
   99.33 -Neg02.java:41:26: compiler.err.cant.apply.diamond: (compiler.misc.diamond: Neg02.Foo), null
   99.34 -Neg02.java:42:13: compiler.err.not.within.bounds: ? extends java.lang.String, X
   99.35 -Neg02.java:42:36: compiler.err.cant.apply.diamond: (compiler.misc.diamond: Neg02.Foo), null
   99.36 -Neg02.java:43:21: compiler.err.cant.apply.diamond: (compiler.misc.diamond: Neg02.Foo), null
   99.37 -Neg02.java:44:13: compiler.err.not.within.bounds: ? super java.lang.String, X
   99.38 -Neg02.java:44:34: compiler.err.cant.apply.diamond: (compiler.misc.diamond: Neg02.Foo), null
   99.39 -Neg02.java:46:13: compiler.err.not.within.bounds: java.lang.String, X
   99.40 -Neg02.java:46:26: compiler.err.cant.apply.diamond: (compiler.misc.diamond: Neg02.Foo), null
   99.41 -Neg02.java:47:13: compiler.err.not.within.bounds: ? extends java.lang.String, X
   99.42 -Neg02.java:47:36: compiler.err.cant.apply.diamond: (compiler.misc.diamond: Neg02.Foo), null
   99.43 -Neg02.java:48:21: compiler.err.cant.apply.diamond: (compiler.misc.diamond: Neg02.Foo), null
   99.44 -Neg02.java:49:13: compiler.err.not.within.bounds: ? super java.lang.String, X
   99.45 -Neg02.java:49:34: compiler.err.cant.apply.diamond: (compiler.misc.diamond: Neg02.Foo), null
   99.46 -Neg02.java:51:13: compiler.err.not.within.bounds: java.lang.String, X
   99.47 -Neg02.java:51:26: compiler.err.cant.apply.diamond: (compiler.misc.diamond: Neg02.Foo), null
   99.48 -Neg02.java:52:13: compiler.err.not.within.bounds: ? extends java.lang.String, X
   99.49 -Neg02.java:52:37: compiler.err.cant.apply.diamond: (compiler.misc.diamond: Neg02.Foo), null
   99.50 -Neg02.java:53:22: compiler.err.cant.apply.diamond: (compiler.misc.diamond: Neg02.Foo), null
   99.51 -Neg02.java:54:13: compiler.err.not.within.bounds: ? super java.lang.String, X
   99.52 -Neg02.java:54:35: compiler.err.cant.apply.diamond: (compiler.misc.diamond: Neg02.Foo), null
   99.53 -Neg02.java:56:13: compiler.err.not.within.bounds: java.lang.String, X
   99.54 -Neg02.java:56:27: compiler.err.cant.apply.diamond: (compiler.misc.diamond: Neg02.Foo), null
   99.55 -Neg02.java:57:13: compiler.err.not.within.bounds: ? extends java.lang.String, X
   99.56 -Neg02.java:57:37: compiler.err.cant.apply.diamond: (compiler.misc.diamond: Neg02.Foo), null
   99.57 -Neg02.java:58:22: compiler.err.cant.apply.diamond: (compiler.misc.diamond: Neg02.Foo), null
   99.58 -Neg02.java:59:13: compiler.err.not.within.bounds: ? super java.lang.String, X
   99.59 -Neg02.java:59:35: compiler.err.cant.apply.diamond: (compiler.misc.diamond: Neg02.Foo), null
   99.60 -56 errors
   99.61 +Neg02.java:20:13: compiler.err.not.within.bounds: java.lang.String, X
   99.62 +Neg02.java:20:26: compiler.err.cant.apply.diamond: (compiler.misc.diamond: Neg02.Foo), null
   99.63 +Neg02.java:21:13: compiler.err.not.within.bounds: ? extends java.lang.String, X
   99.64 +Neg02.java:21:36: compiler.err.cant.apply.diamond: (compiler.misc.diamond: Neg02.Foo), null
   99.65 +Neg02.java:22:21: compiler.err.cant.apply.diamond: (compiler.misc.diamond: Neg02.Foo), null
   99.66 +Neg02.java:23:13: compiler.err.not.within.bounds: ? super java.lang.String, X
   99.67 +Neg02.java:23:34: compiler.err.cant.apply.diamond: (compiler.misc.diamond: Neg02.Foo), null
   99.68 +Neg02.java:25:13: compiler.err.not.within.bounds: java.lang.String, X
   99.69 +Neg02.java:25:26: compiler.err.cant.apply.diamond: (compiler.misc.diamond: Neg02.Foo), null
   99.70 +Neg02.java:26:13: compiler.err.not.within.bounds: ? extends java.lang.String, X
   99.71 +Neg02.java:26:36: compiler.err.cant.apply.diamond: (compiler.misc.diamond: Neg02.Foo), null
   99.72 +Neg02.java:27:21: compiler.err.cant.apply.diamond: (compiler.misc.diamond: Neg02.Foo), null
   99.73 +Neg02.java:28:13: compiler.err.not.within.bounds: ? super java.lang.String, X
   99.74 +Neg02.java:28:34: compiler.err.cant.apply.diamond: (compiler.misc.diamond: Neg02.Foo), null
   99.75 +Neg02.java:32:13: compiler.err.not.within.bounds: java.lang.String, X
   99.76 +Neg02.java:32:26: compiler.err.cant.apply.diamond: (compiler.misc.diamond: Neg02.Foo), null
   99.77 +Neg02.java:33:13: compiler.err.not.within.bounds: ? extends java.lang.String, X
   99.78 +Neg02.java:33:36: compiler.err.cant.apply.diamond: (compiler.misc.diamond: Neg02.Foo), null
   99.79 +Neg02.java:34:21: compiler.err.cant.apply.diamond: (compiler.misc.diamond: Neg02.Foo), null
   99.80 +Neg02.java:35:13: compiler.err.not.within.bounds: ? super java.lang.String, X
   99.81 +Neg02.java:35:34: compiler.err.cant.apply.diamond: (compiler.misc.diamond: Neg02.Foo), null
   99.82 +Neg02.java:37:13: compiler.err.not.within.bounds: java.lang.String, X
   99.83 +Neg02.java:37:26: compiler.err.cant.apply.diamond: (compiler.misc.diamond: Neg02.Foo), null
   99.84 +Neg02.java:38:13: compiler.err.not.within.bounds: ? extends java.lang.String, X
   99.85 +Neg02.java:38:36: compiler.err.cant.apply.diamond: (compiler.misc.diamond: Neg02.Foo), null
   99.86 +Neg02.java:39:21: compiler.err.cant.apply.diamond: (compiler.misc.diamond: Neg02.Foo), null
   99.87 +Neg02.java:40:13: compiler.err.not.within.bounds: ? super java.lang.String, X
   99.88 +Neg02.java:40:34: compiler.err.cant.apply.diamond: (compiler.misc.diamond: Neg02.Foo), null
   99.89 +28 errors
   100.1 --- a/test/tools/javac/generics/diamond/neg/Neg03.java	Thu Mar 10 17:11:19 2011 -0800
   100.2 +++ b/test/tools/javac/generics/diamond/neg/Neg03.java	Thu Mar 10 20:51:07 2011 -0800
   100.3 @@ -1,8 +1,9 @@
   100.4  /*
   100.5   * @test /nodynamiccopyright/
   100.6 - * @bug 6939620
   100.7 + * @bug 6939620 7020044
   100.8   *
   100.9 - * @summary  Switch to 'complex' diamond inference scheme
  100.10 + * @summary  Check that diamond fails when inference violates declared bounds
  100.11 + *           (test with inner class, qualified/simple type expressions)
  100.12   * @author mcimadamore
  100.13   * @compile/fail/ref=Neg03.out Neg03.java -XDrawDiagnostics
  100.14   *
  100.15 @@ -21,20 +22,10 @@
  100.16          Foo<?> f3 = new Foo<>("");
  100.17          Foo<? super String> f4 = new Foo<>("");
  100.18  
  100.19 -        Foo<String> f5 = new Foo<>(""){};
  100.20 -        Foo<? extends String> f6 = new Foo<>(""){};
  100.21 -        Foo<?> f7 = new Foo<>(""){};
  100.22 -        Foo<? super String> f8 = new Foo<>(""){};
  100.23 -
  100.24 -        Foo<String> f9 = new Foo<>("", "");
  100.25 -        Foo<? extends String> f10 = new Foo<>("", "");
  100.26 -        Foo<?> f11 = new Foo<>("", "");
  100.27 -        Foo<? super String> f12 = new Foo<>("", "");
  100.28 -
  100.29 -        Foo<String> f13 = new Foo<>("", ""){};
  100.30 -        Foo<? extends String> f14 = new Foo<>("", ""){};
  100.31 -        Foo<?> f15 = new Foo<>("", ""){};
  100.32 -        Foo<? super String> f16 = new Foo<>("", ""){};
  100.33 +        Foo<String> f5 = new Foo<>("", "");
  100.34 +        Foo<? extends String> f6 = new Foo<>("", "");
  100.35 +        Foo<?> f7 = new Foo<>("", "");
  100.36 +        Foo<? super String> f8 = new Foo<>("", "");
  100.37      }
  100.38  
  100.39      void testQualified_1() {
  100.40 @@ -43,20 +34,10 @@
  100.41          Foo<?> f3 = new Neg03<U>.Foo<>("");
  100.42          Foo<? super String> f4 = new Neg03<U>.Foo<>("");
  100.43  
  100.44 -        Foo<String> f5 = new Neg03<U>.Foo<>(""){};
  100.45 -        Foo<? extends String> f6 = new Neg03<U>.Foo<>(""){};
  100.46 -        Foo<?> f7 = new Neg03<U>.Foo<>(""){};
  100.47 -        Foo<? super String> f8 = new Neg03<U>.Foo<>(""){};
  100.48 -
  100.49 -        Foo<String> f9 = new Neg03<U>.Foo<>("", "");
  100.50 -        Foo<? extends String> f10 = new Neg03<U>.Foo<>("", "");
  100.51 -        Foo<?> f11 = new Neg03<U>.Foo<>("", "");
  100.52 -        Foo<? super String> f12 = new Neg03<U>.Foo<>("", "");
  100.53 -
  100.54 -        Foo<String> f13 = new Neg03<U>.Foo<>("", ""){};
  100.55 -        Foo<? extends String> f14 = new Neg03<U>.Foo<>("", ""){};
  100.56 -        Foo<?> f15 = new Neg03<U>.Foo<>("", ""){};
  100.57 -        Foo<? super String> f16 = new Neg03<U>.Foo<>("", ""){};
  100.58 +        Foo<String> f5 = new Neg03<U>.Foo<>("", "");
  100.59 +        Foo<? extends String> f6 = new Neg03<U>.Foo<>("", "");
  100.60 +        Foo<?> f7 = new Neg03<U>.Foo<>("", "");
  100.61 +        Foo<? super String> f8 = new Neg03<U>.Foo<>("", "");
  100.62      }
  100.63  
  100.64      void testQualified_2(Neg03<U> n) {
  100.65 @@ -65,19 +46,9 @@
  100.66          Foo<?> f3 = n.new Foo<>("");
  100.67          Foo<? super String> f4 = n.new Foo<>("");
  100.68  
  100.69 -        Foo<String> f5 = n.new Foo<>(""){};
  100.70 -        Foo<? extends String> f6 = n.new Foo<>(""){};
  100.71 -        Foo<?> f7 = n.new Foo<>(""){};
  100.72 -        Foo<? super String> f8 = n.new Foo<>(""){};
  100.73 -
  100.74 -        Foo<String> f9 = n.new Foo<>("", "");
  100.75 -        Foo<? extends String> f10 = n.new Foo<>("", "");
  100.76 -        Foo<?> f11 = n.new Foo<>("", "");
  100.77 -        Foo<? super String> f12 = n.new Foo<>("", "");
  100.78 -
  100.79 -        Foo<String> f13 = n.new Foo<>("", ""){};
  100.80 -        Foo<? extends String> f14 = n.new Foo<>("", ""){};
  100.81 -        Foo<?> f15 = n.new Foo<>("", ""){};
  100.82 -        Foo<? super String> f16 = n.new Foo<>("", ""){};
  100.83 +        Foo<String> f5 = n.new Foo<>("", "");
  100.84 +        Foo<? extends String> f6 = n.new Foo<>("", "");
  100.85 +        Foo<?> f7 = n.new Foo<>("", "");
  100.86 +        Foo<? super String> f8 = n.new Foo<>("", "");
  100.87      }
  100.88  }
   101.1 --- a/test/tools/javac/generics/diamond/neg/Neg03.out	Thu Mar 10 17:11:19 2011 -0800
   101.2 +++ b/test/tools/javac/generics/diamond/neg/Neg03.out	Thu Mar 10 20:51:07 2011 -0800
   101.3 @@ -1,85 +1,43 @@
   101.4 -Neg03.java:19:13: compiler.err.not.within.bounds: java.lang.String, V
   101.5 -Neg03.java:19:26: compiler.err.cant.apply.diamond: (compiler.misc.diamond: Neg03.Foo), null
   101.6 -Neg03.java:20:13: compiler.err.not.within.bounds: ? extends java.lang.String, V
   101.7 -Neg03.java:20:36: compiler.err.cant.apply.diamond: (compiler.misc.diamond: Neg03.Foo), null
   101.8 -Neg03.java:21:21: compiler.err.cant.apply.diamond: (compiler.misc.diamond: Neg03.Foo), null
   101.9 -Neg03.java:22:13: compiler.err.not.within.bounds: ? super java.lang.String, V
  101.10 -Neg03.java:22:34: compiler.err.cant.apply.diamond: (compiler.misc.diamond: Neg03.Foo), null
  101.11 -Neg03.java:24:13: compiler.err.not.within.bounds: java.lang.String, V
  101.12 -Neg03.java:24:26: compiler.err.cant.apply.diamond: (compiler.misc.diamond: Neg03.Foo), null
  101.13 -Neg03.java:25:13: compiler.err.not.within.bounds: ? extends java.lang.String, V
  101.14 -Neg03.java:25:36: compiler.err.cant.apply.diamond: (compiler.misc.diamond: Neg03.Foo), null
  101.15 -Neg03.java:26:21: compiler.err.cant.apply.diamond: (compiler.misc.diamond: Neg03.Foo), null
  101.16 -Neg03.java:27:13: compiler.err.not.within.bounds: ? super java.lang.String, V
  101.17 -Neg03.java:27:34: compiler.err.cant.apply.diamond: (compiler.misc.diamond: Neg03.Foo), null
  101.18 -Neg03.java:29:13: compiler.err.not.within.bounds: java.lang.String, V
  101.19 -Neg03.java:29:26: compiler.err.cant.apply.diamond: (compiler.misc.diamond: Neg03.Foo), null
  101.20 -Neg03.java:30:13: compiler.err.not.within.bounds: ? extends java.lang.String, V
  101.21 -Neg03.java:30:37: compiler.err.cant.apply.diamond: (compiler.misc.diamond: Neg03.Foo), null
  101.22 -Neg03.java:31:22: compiler.err.cant.apply.diamond: (compiler.misc.diamond: Neg03.Foo), null
  101.23 -Neg03.java:32:13: compiler.err.not.within.bounds: ? super java.lang.String, V
  101.24 -Neg03.java:32:35: compiler.err.cant.apply.diamond: (compiler.misc.diamond: Neg03.Foo), null
  101.25 -Neg03.java:34:13: compiler.err.not.within.bounds: java.lang.String, V
  101.26 -Neg03.java:34:27: compiler.err.cant.apply.diamond: (compiler.misc.diamond: Neg03.Foo), null
  101.27 -Neg03.java:35:13: compiler.err.not.within.bounds: ? extends java.lang.String, V
  101.28 -Neg03.java:35:37: compiler.err.cant.apply.diamond: (compiler.misc.diamond: Neg03.Foo), null
  101.29 -Neg03.java:36:22: compiler.err.cant.apply.diamond: (compiler.misc.diamond: Neg03.Foo), null
  101.30 -Neg03.java:37:13: compiler.err.not.within.bounds: ? super java.lang.String, V
  101.31 -Neg03.java:37:35: compiler.err.cant.apply.diamond: (compiler.misc.diamond: Neg03.Foo), null
  101.32 -Neg03.java:41:13: compiler.err.not.within.bounds: java.lang.String, V
  101.33 -Neg03.java:41:26: compiler.err.cant.apply.diamond: (compiler.misc.diamond: Neg03.Foo), null
  101.34 -Neg03.java:42:13: compiler.err.not.within.bounds: ? extends java.lang.String, V
  101.35 -Neg03.java:42:36: compiler.err.cant.apply.diamond: (compiler.misc.diamond: Neg03.Foo), null
  101.36 -Neg03.java:43:21: compiler.err.cant.apply.diamond: (compiler.misc.diamond: Neg03.Foo), null
  101.37 -Neg03.java:44:13: compiler.err.not.within.bounds: ? super java.lang.String, V
  101.38 -Neg03.java:44:34: compiler.err.cant.apply.diamond: (compiler.misc.diamond: Neg03.Foo), null
  101.39 -Neg03.java:46:13: compiler.err.not.within.bounds: java.lang.String, V
  101.40 -Neg03.java:46:26: compiler.err.cant.apply.diamond: (compiler.misc.diamond: Neg03.Foo), null
  101.41 -Neg03.java:47:13: compiler.err.not.within.bounds: ? extends java.lang.String, V
  101.42 +Neg03.java:20:13: compiler.err.not.within.bounds: java.lang.String, V
  101.43 +Neg03.java:20:26: compiler.err.cant.apply.diamond: (compiler.misc.diamond: Neg03.Foo), null
  101.44 +Neg03.java:21:13: compiler.err.not.within.bounds: ? extends java.lang.String, V
  101.45 +Neg03.java:21:36: compiler.err.cant.apply.diamond: (compiler.misc.diamond: Neg03.Foo), null
  101.46 +Neg03.java:22:21: compiler.err.cant.apply.diamond: (compiler.misc.diamond: Neg03.Foo), null
  101.47 +Neg03.java:23:13: compiler.err.not.within.bounds: ? super java.lang.String, V
  101.48 +Neg03.java:23:34: compiler.err.cant.apply.diamond: (compiler.misc.diamond: Neg03.Foo), null
  101.49 +Neg03.java:25:13: compiler.err.not.within.bounds: java.lang.String, V
  101.50 +Neg03.java:25:26: compiler.err.cant.apply.diamond: (compiler.misc.diamond: Neg03.Foo), null
  101.51 +Neg03.java:26:13: compiler.err.not.within.bounds: ? extends java.lang.String, V
  101.52 +Neg03.java:26:36: compiler.err.cant.apply.diamond: (compiler.misc.diamond: Neg03.Foo), null
  101.53 +Neg03.java:27:21: compiler.err.cant.apply.diamond: (compiler.misc.diamond: Neg03.Foo), null
  101.54 +Neg03.java:28:13: compiler.err.not.within.bounds: ? super java.lang.String, V
  101.55 +Neg03.java:28:34: compiler.err.cant.apply.diamond: (compiler.misc.diamond: Neg03.Foo), null
  101.56 +Neg03.java:32:13: compiler.err.not.within.bounds: java.lang.String, V
  101.57 +Neg03.java:32:26: compiler.err.cant.apply.diamond: (compiler.misc.diamond: Neg03.Foo), null
  101.58 +Neg03.java:33:13: compiler.err.not.within.bounds: ? extends java.lang.String, V
  101.59 +Neg03.java:33:36: compiler.err.cant.apply.diamond: (compiler.misc.diamond: Neg03.Foo), null
  101.60 +Neg03.java:34:21: compiler.err.cant.apply.diamond: (compiler.misc.diamond: Neg03.Foo), null
  101.61 +Neg03.java:35:13: compiler.err.not.within.bounds: ? super java.lang.String, V
  101.62 +Neg03.java:35:34: compiler.err.cant.apply.diamond: (compiler.misc.diamond: Neg03.Foo), null
  101.63 +Neg03.java:37:13: compiler.err.not.within.bounds: java.lang.String, V
  101.64 +Neg03.java:37:26: compiler.err.cant.apply.diamond: (compiler.misc.diamond: Neg03.Foo), null
  101.65 +Neg03.java:38:13: compiler.err.not.within.bounds: ? extends java.lang.String, V
  101.66 +Neg03.java:38:36: compiler.err.cant.apply.diamond: (compiler.misc.diamond: Neg03.Foo), null
  101.67 +Neg03.java:39:21: compiler.err.cant.apply.diamond: (compiler.misc.diamond: Neg03.Foo), null
  101.68 +Neg03.java:40:13: compiler.err.not.within.bounds: ? super java.lang.String, V
  101.69 +Neg03.java:40:34: compiler.err.cant.apply.diamond: (compiler.misc.diamond: Neg03.Foo), null
  101.70 +Neg03.java:44:13: compiler.err.not.within.bounds: java.lang.String, V
  101.71 +Neg03.java:44:28: compiler.err.cant.apply.diamond: (compiler.misc.diamond: Neg03.Foo), null
  101.72 +Neg03.java:45:13: compiler.err.not.within.bounds: ? extends java.lang.String, V
  101.73 +Neg03.java:45:38: compiler.err.cant.apply.diamond: (compiler.misc.diamond: Neg03.Foo), null
  101.74 +Neg03.java:46:23: compiler.err.cant.apply.diamond: (compiler.misc.diamond: Neg03.Foo), null
  101.75 +Neg03.java:47:13: compiler.err.not.within.bounds: ? super java.lang.String, V
  101.76  Neg03.java:47:36: compiler.err.cant.apply.diamond: (compiler.misc.diamond: Neg03.Foo), null
  101.77 -Neg03.java:48:21: compiler.err.cant.apply.diamond: (compiler.misc.diamond: Neg03.Foo), null
  101.78 -Neg03.java:49:13: compiler.err.not.within.bounds: ? super java.lang.String, V
  101.79 -Neg03.java:49:34: compiler.err.cant.apply.diamond: (compiler.misc.diamond: Neg03.Foo), null
  101.80 -Neg03.java:51:13: compiler.err.not.within.bounds: java.lang.String, V
  101.81 -Neg03.java:51:26: compiler.err.cant.apply.diamond: (compiler.misc.diamond: Neg03.Foo), null
  101.82 -Neg03.java:52:13: compiler.err.not.within.bounds: ? extends java.lang.String, V
  101.83 -Neg03.java:52:37: compiler.err.cant.apply.diamond: (compiler.misc.diamond: Neg03.Foo), null
  101.84 -Neg03.java:53:22: compiler.err.cant.apply.diamond: (compiler.misc.diamond: Neg03.Foo), null
  101.85 -Neg03.java:54:13: compiler.err.not.within.bounds: ? super java.lang.String, V
  101.86 -Neg03.java:54:35: compiler.err.cant.apply.diamond: (compiler.misc.diamond: Neg03.Foo), null
  101.87 -Neg03.java:56:13: compiler.err.not.within.bounds: java.lang.String, V
  101.88 -Neg03.java:56:27: compiler.err.cant.apply.diamond: (compiler.misc.diamond: Neg03.Foo), null
  101.89 -Neg03.java:57:13: compiler.err.not.within.bounds: ? extends java.lang.String, V
  101.90 -Neg03.java:57:37: compiler.err.cant.apply.diamond: (compiler.misc.diamond: Neg03.Foo), null
  101.91 -Neg03.java:58:22: compiler.err.cant.apply.diamond: (compiler.misc.diamond: Neg03.Foo), null
  101.92 -Neg03.java:59:13: compiler.err.not.within.bounds: ? super java.lang.String, V
  101.93 -Neg03.java:59:35: compiler.err.cant.apply.diamond: (compiler.misc.diamond: Neg03.Foo), null
  101.94 -Neg03.java:63:13: compiler.err.not.within.bounds: java.lang.String, V
  101.95 -Neg03.java:63:28: compiler.err.cant.apply.diamond: (compiler.misc.diamond: Neg03.Foo), null
  101.96 -Neg03.java:64:13: compiler.err.not.within.bounds: ? extends java.lang.String, V
  101.97 -Neg03.java:64:38: compiler.err.cant.apply.diamond: (compiler.misc.diamond: Neg03.Foo), null
  101.98 -Neg03.java:65:23: compiler.err.cant.apply.diamond: (compiler.misc.diamond: Neg03.Foo), null
  101.99 -Neg03.java:66:13: compiler.err.not.within.bounds: ? super java.lang.String, V
 101.100 -Neg03.java:66:36: compiler.err.cant.apply.diamond: (compiler.misc.diamond: Neg03.Foo), null
 101.101 -Neg03.java:68:13: compiler.err.not.within.bounds: java.lang.String, V
 101.102 -Neg03.java:68:28: compiler.err.cant.apply.diamond: (compiler.misc.diamond: Neg03.Foo), null
 101.103 -Neg03.java:69:13: compiler.err.not.within.bounds: ? extends java.lang.String, V
 101.104 -Neg03.java:69:38: compiler.err.cant.apply.diamond: (compiler.misc.diamond: Neg03.Foo), null
 101.105 -Neg03.java:70:23: compiler.err.cant.apply.diamond: (compiler.misc.diamond: Neg03.Foo), null
 101.106 -Neg03.java:71:13: compiler.err.not.within.bounds: ? super java.lang.String, V
 101.107 -Neg03.java:71:36: compiler.err.cant.apply.diamond: (compiler.misc.diamond: Neg03.Foo), null
 101.108 -Neg03.java:73:13: compiler.err.not.within.bounds: java.lang.String, V
 101.109 -Neg03.java:73:28: compiler.err.cant.apply.diamond: (compiler.misc.diamond: Neg03.Foo), null
 101.110 -Neg03.java:74:13: compiler.err.not.within.bounds: ? extends java.lang.String, V
 101.111 -Neg03.java:74:39: compiler.err.cant.apply.diamond: (compiler.misc.diamond: Neg03.Foo), null
 101.112 -Neg03.java:75:24: compiler.err.cant.apply.diamond: (compiler.misc.diamond: Neg03.Foo), null
 101.113 -Neg03.java:76:13: compiler.err.not.within.bounds: ? super java.lang.String, V
 101.114 -Neg03.java:76:37: compiler.err.cant.apply.diamond: (compiler.misc.diamond: Neg03.Foo), null
 101.115 -Neg03.java:78:13: compiler.err.not.within.bounds: java.lang.String, V
 101.116 -Neg03.java:78:29: compiler.err.cant.apply.diamond: (compiler.misc.diamond: Neg03.Foo), null
 101.117 -Neg03.java:79:13: compiler.err.not.within.bounds: ? extends java.lang.String, V
 101.118 -Neg03.java:79:39: compiler.err.cant.apply.diamond: (compiler.misc.diamond: Neg03.Foo), null
 101.119 -Neg03.java:80:24: compiler.err.cant.apply.diamond: (compiler.misc.diamond: Neg03.Foo), null
 101.120 -Neg03.java:81:13: compiler.err.not.within.bounds: ? super java.lang.String, V
 101.121 -Neg03.java:81:37: compiler.err.cant.apply.diamond: (compiler.misc.diamond: Neg03.Foo), null
 101.122 -84 errors
 101.123 +Neg03.java:49:13: compiler.err.not.within.bounds: java.lang.String, V
 101.124 +Neg03.java:49:28: compiler.err.cant.apply.diamond: (compiler.misc.diamond: Neg03.Foo), null
 101.125 +Neg03.java:50:13: compiler.err.not.within.bounds: ? extends java.lang.String, V
 101.126 +Neg03.java:50:38: compiler.err.cant.apply.diamond: (compiler.misc.diamond: Neg03.Foo), null
 101.127 +Neg03.java:51:23: compiler.err.cant.apply.diamond: (compiler.misc.diamond: Neg03.Foo), null
 101.128 +Neg03.java:52:13: compiler.err.not.within.bounds: ? super java.lang.String, V
 101.129 +Neg03.java:52:36: compiler.err.cant.apply.diamond: (compiler.misc.diamond: Neg03.Foo), null
 101.130 +42 errors
   102.1 --- a/test/tools/javac/generics/diamond/neg/Neg04.java	Thu Mar 10 17:11:19 2011 -0800
   102.2 +++ b/test/tools/javac/generics/diamond/neg/Neg04.java	Thu Mar 10 20:51:07 2011 -0800
   102.3 @@ -1,8 +1,9 @@
   102.4  /*
   102.5   * @test /nodynamiccopyright/
   102.6 - * @bug 6939620
   102.7 + * @bug 6939620 7020044
   102.8   *
   102.9 - * @summary  Switch to 'complex' diamond inference scheme
  102.10 + * @summary  Check that diamond fails when inference violates declared bounds
  102.11 + *           (test with local class, qualified/simple type expressions)
  102.12   * @author mcimadamore
  102.13   * @compile/fail/ref=Neg04.out Neg04.java -XDrawDiagnostics
  102.14   *
  102.15 @@ -20,19 +21,9 @@
  102.16          Foo<?> n3 = new Foo<>("");
  102.17          Foo<? super String> n4 = new Foo<>("");
  102.18  
  102.19 -        Foo<String> n5 = new Foo<>(""){};
  102.20 -        Foo<? extends String> n6 = new Foo<>(""){};
  102.21 -        Foo<?> n7 = new Foo<>(""){};
  102.22 -        Foo<? super String> n8 = new Foo<>(""){};
  102.23 -
  102.24 -        Foo<String> n9 = new Foo<>("", "");
  102.25 -        Foo<? extends String> n10 = new Foo<>("", "");
  102.26 -        Foo<?> n11 = new Foo<>("", "");
  102.27 -        Foo<? super String> n12 = new Foo<>("", "");
  102.28 -
  102.29 -        Foo<String> n13 = new Foo<>("", ""){};
  102.30 -        Foo<? extends String> n14 = new Foo<>("", ""){};
  102.31 -        Foo<?> n15 = new Foo<>("", ""){};
  102.32 -        Foo<? super String> n16 = new Foo<>("", ""){};
  102.33 +        Foo<String> n5 = new Foo<>("", "");
  102.34 +        Foo<? extends String> n6 = new Foo<>("", "");
  102.35 +        Foo<?> n7 = new Foo<>("", "");
  102.36 +        Foo<? super String> n8 = new Foo<>("", "");
  102.37      }
  102.38  }
   103.1 --- a/test/tools/javac/generics/diamond/neg/Neg04.out	Thu Mar 10 17:11:19 2011 -0800
   103.2 +++ b/test/tools/javac/generics/diamond/neg/Neg04.out	Thu Mar 10 20:51:07 2011 -0800
   103.3 @@ -1,29 +1,15 @@
   103.4 -Neg04.java:18:13: compiler.err.not.within.bounds: java.lang.String, V
   103.5 -Neg04.java:18:26: compiler.err.cant.apply.diamond: (compiler.misc.diamond: Foo), null
   103.6 -Neg04.java:19:13: compiler.err.not.within.bounds: ? extends java.lang.String, V
   103.7 -Neg04.java:19:36: compiler.err.cant.apply.diamond: (compiler.misc.diamond: Foo), null
   103.8 -Neg04.java:20:21: compiler.err.cant.apply.diamond: (compiler.misc.diamond: Foo), null
   103.9 -Neg04.java:21:13: compiler.err.not.within.bounds: ? super java.lang.String, V
  103.10 -Neg04.java:21:34: compiler.err.cant.apply.diamond: (compiler.misc.diamond: Foo), null
  103.11 -Neg04.java:23:13: compiler.err.not.within.bounds: java.lang.String, V
  103.12 -Neg04.java:23:26: compiler.err.cant.apply.diamond: (compiler.misc.diamond: Foo), null
  103.13 -Neg04.java:24:13: compiler.err.not.within.bounds: ? extends java.lang.String, V
  103.14 -Neg04.java:24:36: compiler.err.cant.apply.diamond: (compiler.misc.diamond: Foo), null
  103.15 -Neg04.java:25:21: compiler.err.cant.apply.diamond: (compiler.misc.diamond: Foo), null
  103.16 -Neg04.java:26:13: compiler.err.not.within.bounds: ? super java.lang.String, V
  103.17 -Neg04.java:26:34: compiler.err.cant.apply.diamond: (compiler.misc.diamond: Foo), null
  103.18 -Neg04.java:28:13: compiler.err.not.within.bounds: java.lang.String, V
  103.19 -Neg04.java:28:26: compiler.err.cant.apply.diamond: (compiler.misc.diamond: Foo), null
  103.20 -Neg04.java:29:13: compiler.err.not.within.bounds: ? extends java.lang.String, V
  103.21 -Neg04.java:29:37: compiler.err.cant.apply.diamond: (compiler.misc.diamond: Foo), null
  103.22 -Neg04.java:30:22: compiler.err.cant.apply.diamond: (compiler.misc.diamond: Foo), null
  103.23 -Neg04.java:31:13: compiler.err.not.within.bounds: ? super java.lang.String, V
  103.24 -Neg04.java:31:35: compiler.err.cant.apply.diamond: (compiler.misc.diamond: Foo), null
  103.25 -Neg04.java:33:13: compiler.err.not.within.bounds: java.lang.String, V
  103.26 -Neg04.java:33:27: compiler.err.cant.apply.diamond: (compiler.misc.diamond: Foo), null
  103.27 -Neg04.java:34:13: compiler.err.not.within.bounds: ? extends java.lang.String, V
  103.28 -Neg04.java:34:37: compiler.err.cant.apply.diamond: (compiler.misc.diamond: Foo), null
  103.29 -Neg04.java:35:22: compiler.err.cant.apply.diamond: (compiler.misc.diamond: Foo), null
  103.30 -Neg04.java:36:13: compiler.err.not.within.bounds: ? super java.lang.String, V
  103.31 -Neg04.java:36:35: compiler.err.cant.apply.diamond: (compiler.misc.diamond: Foo), null
  103.32 -28 errors
  103.33 +Neg04.java:19:13: compiler.err.not.within.bounds: java.lang.String, V
  103.34 +Neg04.java:19:26: compiler.err.cant.apply.diamond: (compiler.misc.diamond: Foo), null
  103.35 +Neg04.java:20:13: compiler.err.not.within.bounds: ? extends java.lang.String, V
  103.36 +Neg04.java:20:36: compiler.err.cant.apply.diamond: (compiler.misc.diamond: Foo), null
  103.37 +Neg04.java:21:21: compiler.err.cant.apply.diamond: (compiler.misc.diamond: Foo), null
  103.38 +Neg04.java:22:13: compiler.err.not.within.bounds: ? super java.lang.String, V
  103.39 +Neg04.java:22:34: compiler.err.cant.apply.diamond: (compiler.misc.diamond: Foo), null
  103.40 +Neg04.java:24:13: compiler.err.not.within.bounds: java.lang.String, V
  103.41 +Neg04.java:24:26: compiler.err.cant.apply.diamond: (compiler.misc.diamond: Foo), null
  103.42 +Neg04.java:25:13: compiler.err.not.within.bounds: ? extends java.lang.String, V
  103.43 +Neg04.java:25:36: compiler.err.cant.apply.diamond: (compiler.misc.diamond: Foo), null
  103.44 +Neg04.java:26:21: compiler.err.cant.apply.diamond: (compiler.misc.diamond: Foo), null
  103.45 +Neg04.java:27:13: compiler.err.not.within.bounds: ? super java.lang.String, V
  103.46 +Neg04.java:27:34: compiler.err.cant.apply.diamond: (compiler.misc.diamond: Foo), null
  103.47 +14 errors
   104.1 --- a/test/tools/javac/generics/diamond/neg/Neg05.java	Thu Mar 10 17:11:19 2011 -0800
   104.2 +++ b/test/tools/javac/generics/diamond/neg/Neg05.java	Thu Mar 10 20:51:07 2011 -0800
   104.3 @@ -1,8 +1,8 @@
   104.4  /*
   104.5   * @test /nodynamiccopyright/
   104.6 - * @bug 6939620
   104.7 + * @bug 6939620 7020044
   104.8   *
   104.9 - * @summary  Switch to 'complex' diamond inference scheme
  104.10 + * @summary  Check that usage of rare types doesn't cause spurious diamond diagnostics
  104.11   * @author mcimadamore
  104.12   * @compile/fail/ref=Neg05.out Neg05.java -XDrawDiagnostics
  104.13   *
  104.14 @@ -21,20 +21,10 @@
  104.15          Neg05<?>.Foo<?> f3 = new Neg05.Foo<>("");
  104.16          Neg05<?>.Foo<? super String> f4 = new Neg05.Foo<>("");
  104.17  
  104.18 -        Neg05<?>.Foo<String> f5 = new Neg05.Foo<>(""){};
  104.19 -        Neg05<?>.Foo<? extends String> f6 = new Neg05.Foo<>(""){};
  104.20 -        Neg05<?>.Foo<?> f7 = new Neg05.Foo<>(""){};
  104.21 -        Neg05<?>.Foo<? super String> f8 = new Neg05.Foo<>(""){};
  104.22 -
  104.23 -        Neg05<?>.Foo<String> f9 = new Neg05.Foo<>("", "");
  104.24 -        Neg05<?>.Foo<? extends String> f10 = new Neg05.Foo<>("", "");
  104.25 -        Neg05<?>.Foo<?> f11 = new Neg05.Foo<>("", "");
  104.26 -        Neg05<?>.Foo<? super String> f12 = new Neg05.Foo<>("", "");
  104.27 -
  104.28 -        Neg05<?>.Foo<String> f13 = new Neg05.Foo<>("", ""){};
  104.29 -        Neg05<?>.Foo<? extends String> f14 = new Neg05.Foo<>("", ""){};
  104.30 -        Neg05<?>.Foo<?> f15 = new Neg05.Foo<>("", ""){};
  104.31 -        Neg05<?>.Foo<? super String> f16 = new Neg05.Foo<>("", ""){};
  104.32 +        Neg05<?>.Foo<String> f5 = new Neg05.Foo<>("", "");
  104.33 +        Neg05<?>.Foo<? extends String> f6 = new Neg05.Foo<>("", "");
  104.34 +        Neg05<?>.Foo<?> f7 = new Neg05.Foo<>("", "");
  104.35 +        Neg05<?>.Foo<? super String> f8 = new Neg05.Foo<>("", "");
  104.36      }
  104.37  
  104.38      void testRare_2(Neg05 n) {
  104.39 @@ -43,19 +33,9 @@
  104.40          Neg05<?>.Foo<?> f3 = n.new Foo<>("");
  104.41          Neg05<?>.Foo<? super String> f4 = n.new Foo<>("");
  104.42  
  104.43 -        Neg05<?>.Foo<String> f5 = n.new Foo<>(""){};
  104.44 -        Neg05<?>.Foo<? extends String> f6 = n.new Foo<>(""){};
  104.45 -        Neg05<?>.Foo<?> f7 = n.new Foo<>(""){};
  104.46 -        Neg05<?>.Foo<? super String> f8 = n.new Foo<>(""){};
  104.47 -
  104.48 -        Neg05<?>.Foo<String> f9 = n.new Foo<>("", "");
  104.49 -        Neg05<?>.Foo<? extends String> f10 = n.new Foo<>("", "");
  104.50 -        Neg05<?>.Foo<?> f11 = n.new Foo<>("", "");
  104.51 -        Neg05<?>.Foo<? super String> f12 = n.new Foo<>("", "");
  104.52 -
  104.53 -        Neg05<?>.Foo<String> f13 = n.new Foo<>("", ""){};
  104.54 -        Neg05<?>.Foo<? extends String> f14 = n.new Foo<>("", ""){};
  104.55 -        Neg05<?>.Foo<?> f15 = n.new Foo<>("", ""){};
  104.56 -        Neg05<?>.Foo<? super String> f16 = n.new Foo<>("", ""){};
  104.57 +        Neg05<?>.Foo<String> f5 = n.new Foo<>("", "");
  104.58 +        Neg05<?>.Foo<? extends String> f6 = n.new Foo<>("", "");
  104.59 +        Neg05<?>.Foo<?> f7 = n.new Foo<>("", "");
  104.60 +        Neg05<?>.Foo<? super String> f8 = n.new Foo<>("", "");
  104.61      }
  104.62  }
   105.1 --- a/test/tools/javac/generics/diamond/neg/Neg05.out	Thu Mar 10 17:11:19 2011 -0800
   105.2 +++ b/test/tools/javac/generics/diamond/neg/Neg05.out	Thu Mar 10 20:51:07 2011 -0800
   105.3 @@ -7,43 +7,19 @@
   105.4  Neg05.java:22:56: compiler.err.improperly.formed.type.inner.raw.param
   105.5  Neg05.java:22:43: compiler.err.prob.found.req: (compiler.misc.incompatible.types), Neg05.Foo<java.lang.String>, Neg05<?>.Foo<? super java.lang.String>
   105.6  Neg05.java:24:48: compiler.err.improperly.formed.type.inner.raw.param
   105.7 -Neg05.java:24:35: compiler.err.prob.found.req: (compiler.misc.incompatible.types), compiler.misc.anonymous.class: Neg05.Foo<java.lang.String>, Neg05<?>.Foo<java.lang.String>
   105.8 +Neg05.java:24:35: compiler.err.prob.found.req: (compiler.misc.incompatible.types), Neg05.Foo<java.lang.String>, Neg05<?>.Foo<java.lang.String>
   105.9  Neg05.java:25:58: compiler.err.improperly.formed.type.inner.raw.param
  105.10 -Neg05.java:25:45: compiler.err.prob.found.req: (compiler.misc.incompatible.types), compiler.misc.anonymous.class: Neg05.Foo<java.lang.String>, Neg05<?>.Foo<? extends java.lang.String>
  105.11 +Neg05.java:25:45: compiler.err.prob.found.req: (compiler.misc.incompatible.types), Neg05.Foo<java.lang.String>, Neg05<?>.Foo<? extends java.lang.String>
  105.12  Neg05.java:26:43: compiler.err.improperly.formed.type.inner.raw.param
  105.13 -Neg05.java:26:30: compiler.err.prob.found.req: (compiler.misc.incompatible.types), compiler.misc.anonymous.class: Neg05.Foo<java.lang.String>, Neg05<?>.Foo<?>
  105.14 +Neg05.java:26:30: compiler.err.prob.found.req: (compiler.misc.incompatible.types), Neg05.Foo<java.lang.String>, Neg05<?>.Foo<?>
  105.15  Neg05.java:27:56: compiler.err.improperly.formed.type.inner.raw.param
  105.16 -Neg05.java:27:43: compiler.err.prob.found.req: (compiler.misc.incompatible.types), compiler.misc.anonymous.class: Neg05.Foo<java.lang.String>, Neg05<?>.Foo<? super java.lang.String>
  105.17 -Neg05.java:29:48: compiler.err.improperly.formed.type.inner.raw.param
  105.18 -Neg05.java:29:35: compiler.err.prob.found.req: (compiler.misc.incompatible.types), Neg05.Foo<java.lang.String>, Neg05<?>.Foo<java.lang.String>
  105.19 -Neg05.java:30:59: compiler.err.improperly.formed.type.inner.raw.param
  105.20 -Neg05.java:30:46: compiler.err.prob.found.req: (compiler.misc.incompatible.types), Neg05.Foo<java.lang.String>, Neg05<?>.Foo<? extends java.lang.String>
  105.21 -Neg05.java:31:44: compiler.err.improperly.formed.type.inner.raw.param
  105.22 -Neg05.java:31:31: compiler.err.prob.found.req: (compiler.misc.incompatible.types), Neg05.Foo<java.lang.String>, Neg05<?>.Foo<?>
  105.23 -Neg05.java:32:57: compiler.err.improperly.formed.type.inner.raw.param
  105.24 -Neg05.java:32:44: compiler.err.prob.found.req: (compiler.misc.incompatible.types), Neg05.Foo<java.lang.String>, Neg05<?>.Foo<? super java.lang.String>
  105.25 -Neg05.java:34:49: compiler.err.improperly.formed.type.inner.raw.param
  105.26 -Neg05.java:34:36: compiler.err.prob.found.req: (compiler.misc.incompatible.types), compiler.misc.anonymous.class: Neg05.Foo<java.lang.String>, Neg05<?>.Foo<java.lang.String>
  105.27 -Neg05.java:35:59: compiler.err.improperly.formed.type.inner.raw.param
  105.28 -Neg05.java:35:46: compiler.err.prob.found.req: (compiler.misc.incompatible.types), compiler.misc.anonymous.class: Neg05.Foo<java.lang.String>, Neg05<?>.Foo<? extends java.lang.String>
  105.29 -Neg05.java:36:44: compiler.err.improperly.formed.type.inner.raw.param
  105.30 -Neg05.java:36:31: compiler.err.prob.found.req: (compiler.misc.incompatible.types), compiler.misc.anonymous.class: Neg05.Foo<java.lang.String>, Neg05<?>.Foo<?>
  105.31 -Neg05.java:37:57: compiler.err.improperly.formed.type.inner.raw.param
  105.32 -Neg05.java:37:44: compiler.err.prob.found.req: (compiler.misc.incompatible.types), compiler.misc.anonymous.class: Neg05.Foo<java.lang.String>, Neg05<?>.Foo<? super java.lang.String>
  105.33 -Neg05.java:41:37: compiler.err.improperly.formed.type.inner.raw.param
  105.34 -Neg05.java:42:47: compiler.err.improperly.formed.type.inner.raw.param
  105.35 -Neg05.java:43:32: compiler.err.improperly.formed.type.inner.raw.param
  105.36 -Neg05.java:44:45: compiler.err.improperly.formed.type.inner.raw.param
  105.37 -Neg05.java:46:37: compiler.err.improperly.formed.type.inner.raw.param
  105.38 -Neg05.java:47:47: compiler.err.improperly.formed.type.inner.raw.param
  105.39 -Neg05.java:48:32: compiler.err.improperly.formed.type.inner.raw.param
  105.40 -Neg05.java:49:45: compiler.err.improperly.formed.type.inner.raw.param
  105.41 -Neg05.java:51:37: compiler.err.improperly.formed.type.inner.raw.param
  105.42 -Neg05.java:52:48: compiler.err.improperly.formed.type.inner.raw.param
  105.43 -Neg05.java:53:33: compiler.err.improperly.formed.type.inner.raw.param
  105.44 -Neg05.java:54:46: compiler.err.improperly.formed.type.inner.raw.param
  105.45 -Neg05.java:56:38: compiler.err.improperly.formed.type.inner.raw.param
  105.46 -Neg05.java:57:48: compiler.err.improperly.formed.type.inner.raw.param
  105.47 -Neg05.java:58:33: compiler.err.improperly.formed.type.inner.raw.param
  105.48 -Neg05.java:59:46: compiler.err.improperly.formed.type.inner.raw.param
  105.49 -48 errors
  105.50 +Neg05.java:27:43: compiler.err.prob.found.req: (compiler.misc.incompatible.types), Neg05.Foo<java.lang.String>, Neg05<?>.Foo<? super java.lang.String>
  105.51 +Neg05.java:31:37: compiler.err.improperly.formed.type.inner.raw.param
  105.52 +Neg05.java:32:47: compiler.err.improperly.formed.type.inner.raw.param
  105.53 +Neg05.java:33:32: compiler.err.improperly.formed.type.inner.raw.param
  105.54 +Neg05.java:34:45: compiler.err.improperly.formed.type.inner.raw.param
  105.55 +Neg05.java:36:37: compiler.err.improperly.formed.type.inner.raw.param
  105.56 +Neg05.java:37:47: compiler.err.improperly.formed.type.inner.raw.param
  105.57 +Neg05.java:38:32: compiler.err.improperly.formed.type.inner.raw.param
  105.58 +Neg05.java:39:45: compiler.err.improperly.formed.type.inner.raw.param
  105.59 +24 errors
   106.1 --- a/test/tools/javac/generics/diamond/neg/Neg06.java	Thu Mar 10 17:11:19 2011 -0800
   106.2 +++ b/test/tools/javac/generics/diamond/neg/Neg06.java	Thu Mar 10 20:51:07 2011 -0800
   106.3 @@ -1,21 +1,17 @@
   106.4  /*
   106.5   * @test /nodynamiccopyright/
   106.6 - * @bug 6939620
   106.7 + * @bug 6939620 7020044
   106.8   *
   106.9 - * @summary  Switch to 'complex' diamond inference scheme
  106.10 + * @summary  Check that diamond works where LHS is supertype of RHS (nilary constructor)
  106.11   * @author mcimadamore
  106.12   * @compile/fail/ref=Neg06.out Neg06.java -XDrawDiagnostics
  106.13   *
  106.14   */
  106.15  
  106.16  class Neg06 {
  106.17 -   interface ISuperFoo<X> {}
  106.18 -   interface IFoo<X extends Number> extends ISuperFoo<X> {}
  106.19  
  106.20     static class CSuperFoo<X> {}
  106.21     static class CFoo<X extends Number> extends CSuperFoo<X> {}
  106.22  
  106.23 -   ISuperFoo<String> isf = new IFoo<>() {};
  106.24     CSuperFoo<String> csf1 = new CFoo<>();
  106.25 -   CSuperFoo<String> csf2 = new CFoo<>() {};
  106.26  }
   107.1 --- a/test/tools/javac/generics/diamond/neg/Neg06.out	Thu Mar 10 17:11:19 2011 -0800
   107.2 +++ b/test/tools/javac/generics/diamond/neg/Neg06.out	Thu Mar 10 20:51:07 2011 -0800
   107.3 @@ -1,4 +1,2 @@
   107.4 -Neg06.java:18:36: compiler.err.cant.apply.diamond.1: (compiler.misc.diamond: Neg06.IFoo), (compiler.misc.infer.no.conforming.instance.exists: X, Neg06.IFoo<X>, Neg06.ISuperFoo<java.lang.String>)
   107.5 -Neg06.java:19:37: compiler.err.cant.apply.diamond.1: (compiler.misc.diamond: Neg06.CFoo), (compiler.misc.infer.no.conforming.instance.exists: X, Neg06.CFoo<X>, Neg06.CSuperFoo<java.lang.String>)
   107.6 -Neg06.java:20:37: compiler.err.cant.apply.diamond.1: (compiler.misc.diamond: Neg06.CFoo), (compiler.misc.infer.no.conforming.instance.exists: X, Neg06.CFoo<X>, Neg06.CSuperFoo<java.lang.String>)
   107.7 -3 errors
   107.8 +Neg06.java:16:37: compiler.err.cant.apply.diamond.1: (compiler.misc.diamond: Neg06.CFoo), (compiler.misc.infer.no.conforming.instance.exists: X, Neg06.CFoo<X>, Neg06.CSuperFoo<java.lang.String>)
   107.9 +1 error
   108.1 --- a/test/tools/javac/generics/diamond/neg/Neg07.java	Thu Mar 10 17:11:19 2011 -0800
   108.2 +++ b/test/tools/javac/generics/diamond/neg/Neg07.java	Thu Mar 10 20:51:07 2011 -0800
   108.3 @@ -1,8 +1,8 @@
   108.4  /*
   108.5   * @test /nodynamiccopyright/
   108.6 - * @bug 6939620
   108.7 + * @bug 6939620 7020044
   108.8   *
   108.9 - * @summary  Switch to 'complex' diamond inference scheme
  108.10 + * @summary  Check that diamond works where LHS is supertype of RHS (1-ary constructor)
  108.11   * @author mcimadamore
  108.12   * @compile/fail/ref=Neg07.out Neg07.java -XDrawDiagnostics
  108.13   *
  108.14 @@ -15,5 +15,4 @@
  108.15     }
  108.16  
  108.17     SuperFoo<String> sf1 = new Foo<>("");
  108.18 -   SuperFoo<String> sf2 = new Foo<>("") {};
  108.19  }
   109.1 --- a/test/tools/javac/generics/diamond/neg/Neg07.out	Thu Mar 10 17:11:19 2011 -0800
   109.2 +++ b/test/tools/javac/generics/diamond/neg/Neg07.out	Thu Mar 10 20:51:07 2011 -0800
   109.3 @@ -1,3 +1,2 @@
   109.4  Neg07.java:17:27: compiler.err.cant.apply.diamond.1: (compiler.misc.diamond: Neg07.Foo), (compiler.misc.inferred.do.not.conform.to.bounds: java.lang.String, java.lang.Number)
   109.5 -Neg07.java:18:27: compiler.err.cant.apply.diamond.1: (compiler.misc.diamond: Neg07.Foo), (compiler.misc.inferred.do.not.conform.to.bounds: java.lang.String, java.lang.Number)
   109.6 -2 errors
   109.7 +1 error
   110.1 --- a/test/tools/javac/generics/diamond/neg/Neg08.java	Thu Mar 10 17:11:19 2011 -0800
   110.2 +++ b/test/tools/javac/generics/diamond/neg/Neg08.java	Thu Mar 10 20:51:07 2011 -0800
   110.3 @@ -1,30 +1,15 @@
   110.4  /*
   110.5   * @test /nodynamiccopyright/
   110.6 - * @bug 6939620 6894753
   110.7 + * @bug 7020043 7020044
   110.8   *
   110.9 - * @summary  Switch to 'complex' diamond inference scheme
  110.10 - * @author mcimadamore
  110.11 + * @summary  Check that diamond is not allowed with non-generic class types
  110.12 + * @author R&eacute;mi Forax
  110.13   * @compile/fail/ref=Neg08.out Neg08.java -XDrawDiagnostics
  110.14   *
  110.15   */
  110.16  
  110.17  class Neg08 {
  110.18 -    static class Foo<X> {
  110.19 -        Foo(X x) {  }
  110.20 -    }
  110.21 -
  110.22 -    static class DoubleFoo<X,Y> {
  110.23 -        DoubleFoo(X x,Y y) {  }
  110.24 -    }
  110.25 -
  110.26 -    static class TripleFoo<X,Y,Z> {
  110.27 -        TripleFoo(X x,Y y,Z z) {  }
  110.28 -    }
  110.29 -
  110.30 -    Foo<? extends Integer> fi = new Foo<>(1);
  110.31 -    Foo<?> fw = new Foo<>(fi);
  110.32 -    Foo<? extends Double> fd = new Foo<>(3.0);
  110.33 -    DoubleFoo<?,?> dw = new DoubleFoo<>(fi,fd);
  110.34 -    Foo<String> fs = new Foo<>("one");
  110.35 -    TripleFoo<?,?,?> tw = new TripleFoo<>(fi,fd,fs);
  110.36 +   public static void main(String[] args) {
  110.37 +     String s = new String<>("foo");
  110.38 +   }
  110.39  }
   111.1 --- a/test/tools/javac/generics/diamond/neg/Neg08.out	Thu Mar 10 17:11:19 2011 -0800
   111.2 +++ b/test/tools/javac/generics/diamond/neg/Neg08.out	Thu Mar 10 20:51:07 2011 -0800
   111.3 @@ -1,4 +1,2 @@
   111.4 -Neg08.java:25:24: compiler.err.cant.apply.diamond.1: (compiler.misc.diamond: Neg08.Foo), (compiler.misc.diamond.invalid.arg: Neg08.Foo<compiler.misc.type.captureof: 1, ? extends java.lang.Integer>, (compiler.misc.diamond: Neg08.Foo))
   111.5 -Neg08.java:27:38: compiler.err.cant.apply.diamond.1: (compiler.misc.diamond: Neg08.DoubleFoo), (compiler.misc.diamond.invalid.args: Neg08.Foo<compiler.misc.type.captureof: 1, ? extends java.lang.Integer>,Neg08.Foo<compiler.misc.type.captureof: 2, ? extends java.lang.Double>, (compiler.misc.diamond: Neg08.DoubleFoo))
   111.6 -Neg08.java:29:40: compiler.err.cant.apply.diamond.1: (compiler.misc.diamond: Neg08.TripleFoo), (compiler.misc.diamond.invalid.args: Neg08.Foo<compiler.misc.type.captureof: 1, ? extends java.lang.Integer>,Neg08.Foo<compiler.misc.type.captureof: 2, ? extends java.lang.Double>, (compiler.misc.diamond: Neg08.TripleFoo))
   111.7 -3 errors
   111.8 +Neg08.java:13:27: compiler.err.cant.apply.diamond.1: java.lang.String, (compiler.misc.diamond.non.generic: java.lang.String)
   111.9 +1 error
   112.1 --- a/test/tools/javac/generics/diamond/neg/Neg09.java	Thu Mar 10 17:11:19 2011 -0800
   112.2 +++ b/test/tools/javac/generics/diamond/neg/Neg09.java	Thu Mar 10 20:51:07 2011 -0800
   112.3 @@ -1,22 +1,25 @@
   112.4  /*
   112.5   * @test /nodynamiccopyright/
   112.6 - * @bug 6939620 6894753
   112.7 + * @bug 7020044
   112.8   *
   112.9 - * @summary  Switch to 'complex' diamond inference scheme
  112.10 - * @author mcimadamore
  112.11 + * @summary  Check that diamond is not allowed with anonymous inner class expressions
  112.12 + * @author Maurizio Cimadamore
  112.13   * @compile/fail/ref=Neg09.out Neg09.java -XDrawDiagnostics
  112.14   *
  112.15   */
  112.16  
  112.17  class Neg09 {
  112.18 -    static class Foo<X extends Number & Comparable<Number>> {}
  112.19 -    static class DoubleFoo<X extends Number & Comparable<Number>,
  112.20 -                           Y extends Number & Comparable<Number>> {}
  112.21 -    static class TripleFoo<X extends Number & Comparable<Number>,
  112.22 -                           Y extends Number & Comparable<Number>,
  112.23 -                           Z> {}
  112.24 +    class Member<X> {}
  112.25  
  112.26 -    Foo<?> fw = new Foo<>();
  112.27 -    DoubleFoo<?,?> dw = new DoubleFoo<>();
  112.28 -    TripleFoo<?,?,?> tw = new TripleFoo<>();
  112.29 +    static class Nested<X> {}
  112.30 +
  112.31 +    void testSimple() {
  112.32 +        Member<?> m1 = new Member<>() {};
  112.33 +        Nested<?> m2 = new Nested<>() {};
  112.34 +    }
  112.35 +
  112.36 +    void testQualified() {
  112.37 +        Member<?> m1 = this.new Member<>() {};
  112.38 +        Nested<?> m2 = new Neg09.Nested<>() {};
  112.39 +    }
  112.40  }
   113.1 --- a/test/tools/javac/generics/diamond/neg/Neg09.out	Thu Mar 10 17:11:19 2011 -0800
   113.2 +++ b/test/tools/javac/generics/diamond/neg/Neg09.out	Thu Mar 10 20:51:07 2011 -0800
   113.3 @@ -1,4 +1,5 @@
   113.4 -Neg09.java:19:24: compiler.err.cant.apply.diamond.1: (compiler.misc.diamond: Neg09.Foo), (compiler.misc.diamond.invalid.arg: java.lang.Number&java.lang.Comparable<java.lang.Number>, (compiler.misc.diamond: Neg09.Foo))
   113.5 -Neg09.java:20:38: compiler.err.cant.apply.diamond.1: (compiler.misc.diamond: Neg09.DoubleFoo), (compiler.misc.diamond.invalid.args: java.lang.Number&java.lang.Comparable<java.lang.Number>,java.lang.Number&java.lang.Comparable<java.lang.Number>, (compiler.misc.diamond: Neg09.DoubleFoo))
   113.6 -Neg09.java:21:40: compiler.err.cant.apply.diamond.1: (compiler.misc.diamond: Neg09.TripleFoo), (compiler.misc.diamond.invalid.args: java.lang.Number&java.lang.Comparable<java.lang.Number>,java.lang.Number&java.lang.Comparable<java.lang.Number>, (compiler.misc.diamond: Neg09.TripleFoo))
   113.7 -3 errors
   113.8 +Neg09.java:17:34: compiler.err.cant.apply.diamond.1: Neg09.Member, (compiler.misc.diamond.and.anon.class: Neg09.Member)
   113.9 +Neg09.java:18:34: compiler.err.cant.apply.diamond.1: Neg09.Nested, (compiler.misc.diamond.and.anon.class: Neg09.Nested)
  113.10 +Neg09.java:22:39: compiler.err.cant.apply.diamond.1: Neg09.Member, (compiler.misc.diamond.and.anon.class: Neg09.Member)
  113.11 +Neg09.java:23:40: compiler.err.cant.apply.diamond.1: Neg09.Nested, (compiler.misc.diamond.and.anon.class: Neg09.Nested)
  113.12 +4 errors
   114.1 --- a/test/tools/javac/generics/diamond/neg/Neg10.java	Thu Mar 10 17:11:19 2011 -0800
   114.2 +++ b/test/tools/javac/generics/diamond/neg/Neg10.java	Thu Mar 10 20:51:07 2011 -0800
   114.3 @@ -1,8 +1,8 @@
   114.4  /*
   114.5   * @test /nodynamiccopyright/
   114.6 - * @bug 6939620
   114.7 + * @bug 6939620 7020044
   114.8   *
   114.9 - * @summary  Switch to 'complex' diamond inference scheme
  114.10 + * @summary  Check that 'complex' diamond can infer type that is too specific
  114.11   * @author mcimadamore
  114.12   * @compile/fail/ref=Neg10.out Neg10.java -XDrawDiagnostics
  114.13   *
   115.1 --- a/test/tools/javac/generics/diamond/neg/Neg11.java	Thu Mar 10 17:11:19 2011 -0800
   115.2 +++ b/test/tools/javac/generics/diamond/neg/Neg11.java	Thu Mar 10 20:51:07 2011 -0800
   115.3 @@ -1,8 +1,8 @@
   115.4  /*
   115.5   * @test /nodynamiccopyright/
   115.6 - * @bug 6939620
   115.7 + * @bug 6939620 7020044
   115.8   *
   115.9 - * @summary  Switch to 'complex' diamond inference scheme
  115.10 + * @summary  Check that unresolved symbols doesn't cause spurious diamond diagnostics
  115.11   * @author mcimadamore
  115.12   * @compile/fail/ref=Neg11.out Neg11.java -XDrawDiagnostics
  115.13   *
   116.1 --- a/test/tools/javac/generics/diamond/neg/Neg12.java	Thu Mar 10 17:11:19 2011 -0800
   116.2 +++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
   116.3 @@ -1,15 +0,0 @@
   116.4 -/*
   116.5 - * @test /nodynamiccopyright/
   116.6 - * @bug 7020043
   116.7 - *
   116.8 - * @summary  Project Coin: diamond allowed on non-generic type
   116.9 - * @author R&eacute;mi Forax
  116.10 - * @compile/fail/ref=Neg12.out Neg12.java -XDrawDiagnostics
  116.11 - *
  116.12 - */
  116.13 -
  116.14 -class DiamondRaw {
  116.15 -   public static void main(String[] args) {
  116.16 -     String s = new String<>("foo");
  116.17 -   }
  116.18 -}
   117.1 --- a/test/tools/javac/generics/diamond/neg/Neg12.out	Thu Mar 10 17:11:19 2011 -0800
   117.2 +++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
   117.3 @@ -1,2 +0,0 @@
   117.4 -Neg12.java:13:27: compiler.err.cant.apply.diamond.1: java.lang.String, (compiler.misc.diamond.non.generic: java.lang.String)
   117.5 -1 error
   118.1 --- a/test/tools/javac/generics/diamond/pos/Pos01.java	Thu Mar 10 17:11:19 2011 -0800
   118.2 +++ b/test/tools/javac/generics/diamond/pos/Pos01.java	Thu Mar 10 20:51:07 2011 -0800
   118.3 @@ -1,5 +1,5 @@
   118.4  /*
   118.5 - * Copyright (c) 2010, Oracle and/or its affiliates. All rights reserved.
   118.6 + * Copyright (c) 2010, 2011, Oracle and/or its affiliates. All rights reserved.
   118.7   * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
   118.8   *
   118.9   * This code is free software; you can redistribute it and/or modify it
  118.10 @@ -23,9 +23,9 @@
  118.11  
  118.12  /*
  118.13   * @test
  118.14 - * @bug 6939620
  118.15 + * @bug 6939620 7020044
  118.16   *
  118.17 - * @summary  Switch to 'complex' diamond inference scheme
  118.18 + * @summary  basic test for diamond (generic/non-generic constructors)
  118.19   * @author mcimadamore
  118.20   * @compile Pos01.java
  118.21   * @run main Pos01
  118.22 @@ -44,20 +44,10 @@
  118.23          Pos01<?> p3 = new Pos01<>(1);
  118.24          Pos01<? super Integer> p4 = new Pos01<>(1);
  118.25  
  118.26 -        Pos01<Integer> p5 = new Pos01<>(1){};
  118.27 -        Pos01<? extends Integer> p6 = new Pos01<>(1){};
  118.28 -        Pos01<?> p7 = new Pos01<>(1){};
  118.29 -        Pos01<? super Integer> p8 = new Pos01<>(1){};
  118.30 -
  118.31 -        Pos01<Integer> p9 = new Pos01<>(1, "");
  118.32 -        Pos01<? extends Integer> p10 = new Pos01<>(1, "");
  118.33 -        Pos01<?> p11 = new Pos01<>(1, "");
  118.34 -        Pos01<? super Integer> p12 = new Pos01<>(1, "");
  118.35 -
  118.36 -        Pos01<Integer> p13 = new Pos01<>(1, ""){};
  118.37 -        Pos01<? extends Integer> p14= new Pos01<>(1, ""){};
  118.38 -        Pos01<?> p15 = new Pos01<>(1, ""){};
  118.39 -        Pos01<? super Integer> p16 = new Pos01<>(1, ""){};
  118.40 +        Pos01<Integer> p5 = new Pos01<>(1, "");
  118.41 +        Pos01<? extends Integer> p6 = new Pos01<>(1, "");
  118.42 +        Pos01<?> p7 = new Pos01<>(1, "");
  118.43 +        Pos01<? super Integer> p8 = new Pos01<>(1, "");
  118.44      }
  118.45  
  118.46      public static void main(String[] args) {
   119.1 --- a/test/tools/javac/generics/diamond/pos/Pos02.java	Thu Mar 10 17:11:19 2011 -0800
   119.2 +++ b/test/tools/javac/generics/diamond/pos/Pos02.java	Thu Mar 10 20:51:07 2011 -0800
   119.3 @@ -1,5 +1,5 @@
   119.4  /*
   119.5 - * Copyright (c) 2010, Oracle and/or its affiliates. All rights reserved.
   119.6 + * Copyright (c) 2010, 2011, Oracle and/or its affiliates. All rights reserved.
   119.7   * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
   119.8   *
   119.9   * This code is free software; you can redistribute it and/or modify it
  119.10 @@ -23,9 +23,9 @@
  119.11  
  119.12  /*
  119.13   * @test
  119.14 - * @bug 6939620
  119.15 + * @bug 6939620 7020044
  119.16   *
  119.17 - * @summary  Switch to 'complex' diamond inference scheme
  119.18 + * @summary  basic test for diamond (simple/qualified type-expressions)
  119.19   * @author mcimadamore
  119.20   * @compile Pos02.java
  119.21   * @run main Pos02
  119.22 @@ -44,20 +44,10 @@
  119.23          Foo<?> f3 = new Foo<>(1);
  119.24          Foo<? super Integer> f4 = new Foo<>(1);
  119.25  
  119.26 -        Foo<Integer> f5 = new Foo<>(1){};
  119.27 -        Foo<? extends Integer> f6 = new Foo<>(1){};
  119.28 -        Foo<?> f7 = new Foo<>(1){};
  119.29 -        Foo<? super Integer> f8 = new Foo<>(1){};
  119.30 -
  119.31 -        Foo<Integer> f9 = new Foo<>(1, "");
  119.32 -        Foo<? extends Integer> f10 = new Foo<>(1, "");
  119.33 -        Foo<?> f11 = new Foo<>(1, "");
  119.34 -        Foo<? super Integer> f12 = new Foo<>(1, "");
  119.35 -
  119.36 -        Foo<Integer> f13 = new Foo<>(1, ""){};
  119.37 -        Foo<? extends Integer> f14 = new Foo<>(1, ""){};
  119.38 -        Foo<?> f15 = new Foo<>(1, ""){};
  119.39 -        Foo<? super Integer> f16 = new Foo<>(1, ""){};
  119.40 +        Foo<Integer> f5 = new Foo<>(1, "");
  119.41 +        Foo<? extends Integer> f6 = new Foo<>(1, "");
  119.42 +        Foo<?> f7 = new Foo<>(1, "");
  119.43 +        Foo<? super Integer> f8 = new Foo<>(1, "");
  119.44      }
  119.45  
  119.46      void testQualified() {
  119.47 @@ -66,20 +56,10 @@
  119.48          Foo<?> f3 = new Pos02.Foo<>(1);
  119.49          Foo<? super Integer> f4 = new Pos02.Foo<>(1);
  119.50  
  119.51 -        Foo<Integer> f5 = new Pos02.Foo<>(1){};
  119.52 -        Foo<? extends Integer> f6 = new Pos02.Foo<>(1){};
  119.53 -        Foo<?> f7 = new Pos02.Foo<>(1){};
  119.54 -        Foo<? super Integer> f8 = new Pos02.Foo<>(1){};
  119.55 -
  119.56 -        Foo<Integer> f9 = new Pos02.Foo<>(1, "");
  119.57 -        Foo<? extends Integer> f10 = new Pos02.Foo<>(1, "");
  119.58 -        Foo<?> f11 = new Pos02.Foo<>(1, "");
  119.59 -        Foo<? super Integer> f12 = new Pos02.Foo<>(1, "");
  119.60 -
  119.61 -        Foo<Integer> f13 = new Pos02.Foo<>(1, ""){};
  119.62 -        Foo<? extends Integer> f14 = new Pos02.Foo<>(1, ""){};
  119.63 -        Foo<?> f15 = new Pos02.Foo<>(1, ""){};
  119.64 -        Foo<? super Integer> f16 = new Pos02.Foo<>(1, ""){};
  119.65 +        Foo<Integer> f5 = new Pos02.Foo<>(1, "");
  119.66 +        Foo<? extends Integer> f6 = new Pos02.Foo<>(1, "");
  119.67 +        Foo<?> f7 = new Pos02.Foo<>(1, "");
  119.68 +        Foo<? super Integer> f8 = new Pos02.Foo<>(1, "");
  119.69      }
  119.70  
  119.71      public static void main(String[] args) {
   120.1 --- a/test/tools/javac/generics/diamond/pos/Pos03.java	Thu Mar 10 17:11:19 2011 -0800
   120.2 +++ b/test/tools/javac/generics/diamond/pos/Pos03.java	Thu Mar 10 20:51:07 2011 -0800
   120.3 @@ -1,5 +1,5 @@
   120.4  /*
   120.5 - * Copyright (c) 2010, Oracle and/or its affiliates. All rights reserved.
   120.6 + * Copyright (c) 2010, 2011, Oracle and/or its affiliates. All rights reserved.
   120.7   * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
   120.8   *
   120.9   * This code is free software; you can redistribute it and/or modify it
  120.10 @@ -23,9 +23,9 @@
  120.11  
  120.12  /*
  120.13   * @test
  120.14 - * @bug 6939620
  120.15 + * @bug 6939620 7020044
  120.16   *
  120.17 - * @summary  Switch to 'complex' diamond inference scheme
  120.18 + * @summary  basic test for diamond (simple/qualified type-expressions, member inner)
  120.19   * @author mcimadamore
  120.20   * @compile Pos03.java
  120.21   * @run main Pos03
  120.22 @@ -45,20 +45,10 @@
  120.23          Foo<?> f3 = new Foo<>(1);
  120.24          Foo<? super Integer> f4 = new Foo<>(1);
  120.25  
  120.26 -        Foo<Integer> f5 = new Foo<>(1){};
  120.27 -        Foo<? extends Integer> f6 = new Foo<>(1){};
  120.28 -        Foo<?> f7 = new Foo<>(1){};
  120.29 -        Foo<? super Integer> f8 = new Foo<>(1){};
  120.30 -
  120.31 -        Foo<Integer> f9 = new Foo<>(1, "");
  120.32 -        Foo<? extends Integer> f10 = new Foo<>(1, "");
  120.33 -        Foo<?> f11 = new Foo<>(1, "");
  120.34 -        Foo<? super Integer> f12 = new Foo<>(1, "");
  120.35 -
  120.36 -        Foo<Integer> f13 = new Foo<>(1, ""){};
  120.37 -        Foo<? extends Integer> f14 = new Foo<>(1, ""){};
  120.38 -        Foo<?> f15 = new Foo<>(1, ""){};
  120.39 -        Foo<? super Integer> f16 = new Foo<>(1, ""){};
  120.40 +        Foo<Integer> f5 = new Foo<>(1, "");
  120.41 +        Foo<? extends Integer> f6 = new Foo<>(1, "");
  120.42 +        Foo<?> f7 = new Foo<>(1, "");
  120.43 +        Foo<? super Integer> f8 = new Foo<>(1, "");
  120.44      }
  120.45  
  120.46      void testQualified_1() {
  120.47 @@ -67,20 +57,10 @@
  120.48          Foo<?> f3 = new Pos03<U>.Foo<>(1);
  120.49          Foo<? super Integer> f4 = new Pos03<U>.Foo<>(1);
  120.50  
  120.51 -        Foo<Integer> f5 = new Pos03<U>.Foo<>(1){};
  120.52 -        Foo<? extends Integer> f6 = new Pos03<U>.Foo<>(1){};
  120.53 -        Foo<?> f7 = new Pos03<U>.Foo<>(1){};
  120.54 -        Foo<? super Integer> f8 = new Pos03<U>.Foo<>(1){};
  120.55 -
  120.56 -        Foo<Integer> f9 = new Pos03<U>.Foo<>(1, "");
  120.57 -        Foo<? extends Integer> f10 = new Pos03<U>.Foo<>(1, "");
  120.58 -        Foo<?> f11 = new Pos03<U>.Foo<>(1, "");
  120.59 -        Foo<? super Integer> f12 = new Pos03<U>.Foo<>(1, "");
  120.60 -
  120.61 -        Foo<Integer> f13 = new Pos03<U>.Foo<>(1, ""){};
  120.62 -        Foo<? extends Integer> f14 = new Pos03<U>.Foo<>(1, ""){};
  120.63 -        Foo<?> f15 = new Pos03<U>.Foo<>(1, ""){};
  120.64 -        Foo<? super Integer> f16 = new Pos03<U>.Foo<>(1, ""){};
  120.65 +        Foo<Integer> f5 = new Pos03<U>.Foo<>(1, "");
  120.66 +        Foo<? extends Integer> f6 = new Pos03<U>.Foo<>(1, "");
  120.67 +        Foo<?> f7 = new Pos03<U>.Foo<>(1, "");
  120.68 +        Foo<? super Integer> f8 = new Pos03<U>.Foo<>(1, "");
  120.69      }
  120.70  
  120.71      void testQualified_2(Pos03<U> p) {
  120.72 @@ -89,20 +69,10 @@
  120.73          Foo<?> f3 = p.new Foo<>(1);
  120.74          Foo<? super Integer> f4 = p.new Foo<>(1);
  120.75  
  120.76 -        Foo<Integer> f5 = p.new Foo<>(1){};
  120.77 -        Foo<? extends Integer> f6 = p.new Foo<>(1){};
  120.78 -        Foo<?> f7 = p.new Foo<>(1){};
  120.79 -        Foo<? super Integer> f8 = p.new Foo<>(1){};
  120.80 -
  120.81 -        Foo<Integer> f9 = p.new Foo<>(1, "");
  120.82 -        Foo<? extends Integer> f10 = p.new Foo<>(1, "");
  120.83 -        Foo<?> f11 = p.new Foo<>(1, "");
  120.84 -        Foo<? super Integer> f12 = p.new Foo<>(1, "");
  120.85 -
  120.86 -        Foo<Integer> f13 = p.new Foo<>(1, ""){};
  120.87 -        Foo<? extends Integer> f14 = p.new Foo<>(1, ""){};
  120.88 -        Foo<?> f15 = p.new Foo<>(1, ""){};
  120.89 -        Foo<? super Integer> f16 = p.new Foo<>(1, ""){};
  120.90 +        Foo<Integer> f5 = p.new Foo<>(1, "");
  120.91 +        Foo<? extends Integer> f6 = p.new Foo<>(1, "");
  120.92 +        Foo<?> f7 = p.new Foo<>(1, "");
  120.93 +        Foo<? super Integer> f8 = p.new Foo<>(1, "");
  120.94      }
  120.95  
  120.96      public static void main(String[] args) {
   121.1 --- a/test/tools/javac/generics/diamond/pos/Pos04.java	Thu Mar 10 17:11:19 2011 -0800
   121.2 +++ b/test/tools/javac/generics/diamond/pos/Pos04.java	Thu Mar 10 20:51:07 2011 -0800
   121.3 @@ -1,5 +1,5 @@
   121.4  /*
   121.5 - * Copyright (c) 2010, Oracle and/or its affiliates. All rights reserved.
   121.6 + * Copyright (c) 2010, 2011, Oracle and/or its affiliates. All rights reserved.
   121.7   * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
   121.8   *
   121.9   * This code is free software; you can redistribute it and/or modify it
  121.10 @@ -23,9 +23,9 @@
  121.11  
  121.12  /*
  121.13   * @test
  121.14 - * @bug 6939620
  121.15 + * @bug 6939620 7020044
  121.16   *
  121.17 - * @summary  Switch to 'complex' diamond inference scheme
  121.18 + * @summary  basic test for diamond (simple/qualified type-expressions, local class)
  121.19   * @author mcimadamore
  121.20   * @compile Pos04.java
  121.21   * @run main Pos04
  121.22 @@ -44,20 +44,10 @@
  121.23          Foo<?> p3 = new Foo<>(1);
  121.24          Foo<? super Integer> p4 = new Foo<>(1);
  121.25  
  121.26 -        Foo<Integer> p5 = new Foo<>(1){};
  121.27 -        Foo<? extends Integer> p6 = new Foo<>(1){};
  121.28 -        Foo<?> p7 = new Foo<>(1){};
  121.29 -        Foo<? super Integer> p8 = new Foo<>(1){};
  121.30 -
  121.31 -        Foo<Integer> p9 = new Foo<>(1, "");
  121.32 -        Foo<? extends Integer> p10 = new Foo<>(1, "");
  121.33 -        Foo<?> p11 = new Foo<>(1, "");
  121.34 -        Foo<? super Integer> p12 = new Foo<>(1, "");
  121.35 -
  121.36 -        Foo<Integer> p13 = new Foo<>(1, ""){};
  121.37 -        Foo<? extends Integer> p14 = new Foo<>(1, ""){};
  121.38 -        Foo<?> p15 = new Foo<>(1, ""){};
  121.39 -        Foo<? super Integer> p16 = new Foo<>(1, ""){};
  121.40 +        Foo<Integer> p5 = new Foo<>(1, "");
  121.41 +        Foo<? extends Integer> p6 = new Foo<>(1, "");
  121.42 +        Foo<?> p7 = new Foo<>(1, "");
  121.43 +        Foo<? super Integer> p8 = new Foo<>(1, "");
  121.44      }
  121.45  
  121.46      public static void main(String[] args) {
   122.1 --- a/test/tools/javac/generics/diamond/pos/Pos05.java	Thu Mar 10 17:11:19 2011 -0800
   122.2 +++ b/test/tools/javac/generics/diamond/pos/Pos05.java	Thu Mar 10 20:51:07 2011 -0800
   122.3 @@ -1,5 +1,5 @@
   122.4  /*
   122.5 - * Copyright (c) 2010, Oracle and/or its affiliates. All rights reserved.
   122.6 + * Copyright (c) 2010, 2011, Oracle and/or its affiliates. All rights reserved.
   122.7   * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
   122.8   *
   122.9   * This code is free software; you can redistribute it and/or modify it
  122.10 @@ -23,9 +23,9 @@
  122.11  
  122.12  /*
  122.13   * @test
  122.14 - * @bug 6939620
  122.15 + * @bug 6939620 7020044
  122.16   *
  122.17 - * @summary  Switch to 'complex' diamond inference scheme
  122.18 + * @summary  Check that 'complex' inference sometimes works in method context
  122.19   * @author mcimadamore
  122.20   * @compile Pos05.java
  122.21   *
   123.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
   123.2 +++ b/test/tools/javac/generics/diamond/pos/Pos06.java	Thu Mar 10 20:51:07 2011 -0800
   123.3 @@ -0,0 +1,53 @@
   123.4 +/*
   123.5 + * Copyright (c) 2011, Oracle and/or its affiliates. All rights reserved.
   123.6 + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
   123.7 + *
   123.8 + * This code is free software; you can redistribute it and/or modify it
   123.9 + * under the terms of the GNU General Public License version 2 only, as
  123.10 + * published by the Free Software Foundation.
  123.11 + *
  123.12 + * This code is distributed in the hope that it will be useful, but WITHOUT
  123.13 + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
  123.14 + * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
  123.15 + * version 2 for more details (a copy is included in the LICENSE file that
  123.16 + * accompanied this code).
  123.17 + *
  123.18 + * You should have received a copy of the GNU General Public License version
  123.19 + * 2 along with this work; if not, write to the Free Software Foundation,
  123.20 + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
  123.21 + *
  123.22 + * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
  123.23 + * or visit www.oracle.com if you need additional information or have any
  123.24 + * questions.
  123.25 + */
  123.26 +
  123.27 +/*
  123.28 + * @test
  123.29 + * @bug 6939620 6894753 7020044
  123.30 + *
  123.31 + * @summary  Diamond and subtyping
  123.32 + * @author mcimadamore
  123.33 + * @compile Pos06.java
  123.34 + *
  123.35 + */
  123.36 +
  123.37 +class Pos06 {
  123.38 +    static class Foo<X> {
  123.39 +        Foo(X x) {  }
  123.40 +    }
  123.41 +
  123.42 +    static class DoubleFoo<X,Y> {
  123.43 +        DoubleFoo(X x,Y y) {  }
  123.44 +    }
  123.45 +
  123.46 +    static class TripleFoo<X,Y,Z> {
  123.47 +        TripleFoo(X x,Y y,Z z) {  }
  123.48 +    }
  123.49 +
  123.50 +    Foo<? extends Integer> fi = new Foo<>(1);
  123.51 +    Foo<?> fw = new Foo<>(fi);
  123.52 +    Foo<? extends Double> fd = new Foo<>(3.0);
  123.53 +    DoubleFoo<?,?> dw = new DoubleFoo<>(fi,fd);
  123.54 +    Foo<String> fs = new Foo<>("one");
  123.55 +    TripleFoo<?,?,?> tw = new TripleFoo<>(fi,fd,fs);
  123.56 +}
   124.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
   124.2 +++ b/test/tools/javac/generics/diamond/pos/Pos07.java	Thu Mar 10 20:51:07 2011 -0800
   124.3 @@ -0,0 +1,45 @@
   124.4 +/*
   124.5 + * Copyright (c) 2011, Oracle and/or its affiliates. All rights reserved.
   124.6 + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
   124.7 + *
   124.8 + * This code is free software; you can redistribute it and/or modify it
   124.9 + * under the terms of the GNU General Public License version 2 only, as
  124.10 + * published by the Free Software Foundation.
  124.11 + *
  124.12 + * This code is distributed in the hope that it will be useful, but WITHOUT
  124.13 + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
  124.14 + * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
  124.15 + * version 2 for more details (a copy is included in the LICENSE file that
  124.16 + * accompanied this code).
  124.17 + *
  124.18 + * You should have received a copy of the GNU General Public License version
  124.19 + * 2 along with this work; if not, write to the Free Software Foundation,
  124.20 + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
  124.21 + *
  124.22 + * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
  124.23 + * or visit www.oracle.com if you need additional information or have any
  124.24 + * questions.
  124.25 + */
  124.26 +
  124.27 +/*
  124.28 + * @test
  124.29 + * @bug 6939620 6894753 7020044
  124.30 + *
  124.31 + * @summary  Diamond and intersection types
  124.32 + * @author mcimadamore
  124.33 + * @compile Pos07.java
  124.34 + *
  124.35 + */
  124.36 +
  124.37 +class Pos07 {
  124.38 +    static class Foo<X extends Number & Comparable<Number>> {}
  124.39 +    static class DoubleFoo<X extends Number & Comparable<Number>,
  124.40 +                           Y extends Number & Comparable<Number>> {}
  124.41 +    static class TripleFoo<X extends Number & Comparable<Number>,
  124.42 +                           Y extends Number & Comparable<Number>,
  124.43 +                           Z> {}
  124.44 +
  124.45 +    Foo<?> fw = new Foo<>();
  124.46 +    DoubleFoo<?,?> dw = new DoubleFoo<>();
  124.47 +    TripleFoo<?,?,?> tw = new TripleFoo<>();
  124.48 +}
   125.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
   125.2 +++ b/test/tools/javac/generics/inference/T7015715.java	Thu Mar 10 20:51:07 2011 -0800
   125.3 @@ -0,0 +1,46 @@
   125.4 +/*
   125.5 + * Copyright (c) 2011, Oracle and/or its affiliates. All rights reserved.
   125.6 + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
   125.7 + *
   125.8 + * This code is free software; you can redistribute it and/or modify it
   125.9 + * under the terms of the GNU General Public License version 2 only, as
  125.10 + * published by the Free Software Foundation.
  125.11 + *
  125.12 + * This code is distributed in the hope that it will be useful, but WITHOUT
  125.13 + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
  125.14 + * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
  125.15 + * version 2 for more details (a copy is included in the LICENSE file that
  125.16 + * accompanied this code).
  125.17 + *
  125.18 + * You should have received a copy of the GNU General Public License version
  125.19 + * 2 along with this work; if not, write to the Free Software Foundation,
  125.20 + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
  125.21 + *
  125.22 + * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
  125.23 + * or visit www.oracle.com if you need additional information or have any
  125.24 + * questions.
  125.25 + */
  125.26 +
  125.27 +/*
  125.28 + * @test
  125.29 + * @bug 7015715
  125.30 + *
  125.31 + * @summary lub gets stuck on type with complex supertype
  125.32 + * @author Neal Gafter
  125.33 + * @compile T7015715.java
  125.34 + *
  125.35 + */
  125.36 +
  125.37 +class T7015715 {
  125.38 +
  125.39 +    interface I<T> {}
  125.40 +
  125.41 +    interface A<T> extends I<A<A<T>>>{}
  125.42 +
  125.43 +    static abstract class X {
  125.44 +       abstract <T> T foo(T x, T y);
  125.45 +       void bar(A<Integer> x, A<String> y){
  125.46 +           foo(x, y);
  125.47 +       }
  125.48 +    }
  125.49 +}
   126.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
   126.2 +++ b/test/tools/javac/implicitThis/6541876/T6541876a.java	Thu Mar 10 20:51:07 2011 -0800
   126.3 @@ -0,0 +1,43 @@
   126.4 +/*
   126.5 + * Copyright (c) 2011, Oracle and/or its affiliates. All rights reserved.
   126.6 + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
   126.7 + *
   126.8 + * This code is free software; you can redistribute it and/or modify it
   126.9 + * under the terms of the GNU General Public License version 2 only, as
  126.10 + * published by the Free Software Foundation.
  126.11 + *
  126.12 + * This code is distributed in the hope that it will be useful, but WITHOUT
  126.13 + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
  126.14 + * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
  126.15 + * version 2 for more details (a copy is included in the LICENSE file that
  126.16 + * accompanied this code).
  126.17 + *
  126.18 + * You should have received a copy of the GNU General Public License version
  126.19 + * 2 along with this work; if not, write to the Free Software Foundation,
  126.20 + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
  126.21 + *
  126.22 + * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
  126.23 + * or visit www.oracle.com if you need additional information or have any
  126.24 + * questions.
  126.25 + */
  126.26 +
  126.27 +/**
  126.28 + * @test
  126.29 + * @bug 6541876
  126.30 + * @summary  "Enclosing Instance" error new in 1.6
  126.31 + *
  126.32 + */
  126.33 +
  126.34 +public class T6541876a {
  126.35 +    class X {
  126.36 +        class Y {}
  126.37 +    }
  126.38 +
  126.39 +    class A extends X {
  126.40 +        class B extends X.Y {}
  126.41 +    }
  126.42 +
  126.43 +    public static void main(String[] args) {
  126.44 +        new T6541876a().new A().new B();
  126.45 +    }
  126.46 +}
   127.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
   127.2 +++ b/test/tools/javac/implicitThis/6541876/T6541876b.java	Thu Mar 10 20:51:07 2011 -0800
   127.3 @@ -0,0 +1,54 @@
   127.4 +/*
   127.5 + * Copyright (c) 2011, Oracle and/or its affiliates. All rights reserved.
   127.6 + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
   127.7 + *
   127.8 + * This code is free software; you can redistribute it and/or modify it
   127.9 + * under the terms of the GNU General Public License version 2 only, as
  127.10 + * published by the Free Software Foundation.
  127.11 + *
  127.12 + * This code is distributed in the hope that it will be useful, but WITHOUT
  127.13 + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
  127.14 + * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
  127.15 + * version 2 for more details (a copy is included in the LICENSE file that
  127.16 + * accompanied this code).
  127.17 + *
  127.18 + * You should have received a copy of the GNU General Public License version
  127.19 + * 2 along with this work; if not, write to the Free Software Foundation,
  127.20 + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
  127.21 + *
  127.22 + * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
  127.23 + * or visit www.oracle.com if you need additional information or have any
  127.24 + * questions.
  127.25 + */
  127.26 +
  127.27 +/**
  127.28 + * @test
  127.29 + * @bug 6541876 6569091
  127.30 + * @summary  "Enclosing Instance" error new in 1.6
  127.31 + *
  127.32 + */
  127.33 +
  127.34 +public class T6541876b {
  127.35 +
  127.36 +    enum ENUM {
  127.37 +        ENUM_CONST {
  127.38 +            public AbstractClass method() {
  127.39 +                return new AbstractClass() {
  127.40 +                    public boolean method() {
  127.41 +                        return true;
  127.42 +                    }
  127.43 +                };
  127.44 +            }
  127.45 +        };
  127.46 +
  127.47 +        public abstract AbstractClass method();
  127.48 +
  127.49 +        private abstract class AbstractClass {
  127.50 +            public abstract boolean method();
  127.51 +        }
  127.52 +    }
  127.53 +
  127.54 +    public static void main(String[] args) {
  127.55 +        ENUM.ENUM_CONST.method();
  127.56 +    }
  127.57 +}
   128.1 --- a/test/tools/javac/implicitThis/NewBeforeOuterConstructed3.java	Thu Mar 10 17:11:19 2011 -0800
   128.2 +++ b/test/tools/javac/implicitThis/NewBeforeOuterConstructed3.java	Thu Mar 10 20:51:07 2011 -0800
   128.3 @@ -1,5 +1,5 @@
   128.4  /*
   128.5 - * Copyright (c) 2002, 2005, Oracle and/or its affiliates. All rights reserved.
   128.6 + * Copyright (c) 2002, 2011, Oracle and/or its affiliates. All rights reserved.
   128.7   * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
   128.8   *
   128.9   * This code is free software; you can redistribute it and/or modify it
  128.10 @@ -25,7 +25,6 @@
  128.11   * @test
  128.12   * @bug 4704371 6313120
  128.13   * @summary compiler generates unverifiable code for implicit reference to uninit'd this
  128.14 - * @compile/fail NewBeforeOuterConstructed3.java
  128.15   */
  128.16  
  128.17  public class NewBeforeOuterConstructed3 {
   129.1 --- a/test/tools/javac/multicatch/Neg05.java	Thu Mar 10 17:11:19 2011 -0800
   129.2 +++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
   129.3 @@ -1,33 +0,0 @@
   129.4 -/*
   129.5 - * @test /nodynamiccopyright/
   129.6 - * @bug 6943289
   129.7 - *
   129.8 - * @summary Project Coin: Improved Exception Handling for Java (aka 'multicatch')
   129.9 - * @author mcimadamore
  129.10 - * @compile/fail/ref=Neg05.out -XDrawDiagnostics Neg05.java
  129.11 - *
  129.12 - */
  129.13 -
  129.14 -class Neg02 {
  129.15 -
  129.16 -    static class Foo<X> {
  129.17 -       Foo(X x) {}
  129.18 -    }
  129.19 -
  129.20 -    static interface Base<X> {}
  129.21 -    static class A extends Exception implements Base<String> {}
  129.22 -    static class B extends Exception implements Base<Integer> {}
  129.23 -
  129.24 -    void m() {
  129.25 -        try {
  129.26 -            if (true) {
  129.27 -                throw new A();
  129.28 -            }
  129.29 -            else {
  129.30 -                throw new B();
  129.31 -            }
  129.32 -        } catch (A | B ex) {
  129.33 -            Foo<?> f = new Foo<>(ex);
  129.34 -        }
  129.35 -    }
  129.36 -}
   130.1 --- a/test/tools/javac/multicatch/Neg05.out	Thu Mar 10 17:11:19 2011 -0800
   130.2 +++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
   130.3 @@ -1,2 +0,0 @@
   130.4 -Neg05.java:30:31: compiler.err.cant.apply.diamond.1: (compiler.misc.diamond: Neg02.Foo), (compiler.misc.diamond.invalid.arg: java.lang.Exception&Neg02.Base<? extends java.lang.Object&java.io.Serializable&java.lang.Comparable<? extends java.lang.Object&java.io.Serializable&java.lang.Comparable<?>>>, (compiler.misc.diamond: Neg02.Foo))
   130.5 -1 error
   131.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
   131.2 +++ b/test/tools/javac/multicatch/Pos09.java	Thu Mar 10 20:51:07 2011 -0800
   131.3 @@ -0,0 +1,56 @@
   131.4 +/*
   131.5 + * Copyright (c) 2010, 2011, Oracle and/or its affiliates. All rights reserved.
   131.6 + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
   131.7 + *
   131.8 + * This code is free software; you can redistribute it and/or modify it
   131.9 + * under the terms of the GNU General Public License version 2 only, as
  131.10 + * published by the Free Software Foundation.
  131.11 + *
  131.12 + * This code is distributed in the hope that it will be useful, but WITHOUT
  131.13 + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
  131.14 + * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
  131.15 + * version 2 for more details (a copy is included in the LICENSE file that
  131.16 + * accompanied this code).
  131.17 + *
  131.18 + * You should have received a copy of the GNU General Public License version
  131.19 + * 2 along with this work; if not, write to the Free Software Foundation,
  131.20 + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
  131.21 + *
  131.22 + * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
  131.23 + * or visit www.oracle.com if you need additional information or have any
  131.24 + * questions.
  131.25 + */
  131.26 +
  131.27 +/*
  131.28 + * @test
  131.29 + * @bug 6943289 7020044
  131.30 + *
  131.31 + * @summary Project Coin: Improved Exception Handling for Java (aka 'multicatch')
  131.32 + * @author mcimadamore
  131.33 + * @compile Pos09.java
  131.34 + *
  131.35 + */
  131.36 +
  131.37 +class Pos09 {
  131.38 +
  131.39 +    static class Foo<X> {
  131.40 +       Foo(X x) {}
  131.41 +    }
  131.42 +
  131.43 +    static interface Base<X> {}
  131.44 +    static class A extends Exception implements Base<String> {}
  131.45 +    static class B extends Exception implements Base<Integer> {}
  131.46 +
  131.47 +    void m() {
  131.48 +        try {
  131.49 +            if (true) {
  131.50 +                throw new A();
  131.51 +            }
  131.52 +            else {
  131.53 +                throw new B();
  131.54 +            }
  131.55 +        } catch (A | B ex) {
  131.56 +            Foo<?> f = new Foo<>(ex);
  131.57 +        }
  131.58 +    }
  131.59 +}
   132.1 --- a/test/tools/javac/nested/4903103/T4903103.java	Thu Mar 10 17:11:19 2011 -0800
   132.2 +++ b/test/tools/javac/nested/4903103/T4903103.java	Thu Mar 10 20:51:07 2011 -0800
   132.3 @@ -1,5 +1,5 @@
   132.4  /*
   132.5 - * Copyright (c) 2005, 2007, Oracle and/or its affiliates. All rights reserved.
   132.6 + * Copyright (c) 2005, 2011, Oracle and/or its affiliates. All rights reserved.
   132.7   * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
   132.8   *
   132.9   * This code is free software; you can redistribute it and/or modify it
  132.10 @@ -25,11 +25,14 @@
  132.11   * @test
  132.12   * @bug     4903103
  132.13   * @summary Can't compile subclasses of inner classes
  132.14 - * @compile T4903103.java
  132.15   */
  132.16  
  132.17  public class T4903103 {
  132.18      private class InnerSuperclass extends T4903103 {}
  132.19  
  132.20      private class InnerSubclass extends InnerSuperclass {}
  132.21 +
  132.22 +    public static void main(String[] args) {
  132.23 +        new T4903103().new InnerSubclass();
  132.24 +    }
  132.25  }
   133.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
   133.2 +++ b/test/tools/javac/options/T6900037.java	Thu Mar 10 20:51:07 2011 -0800
   133.3 @@ -0,0 +1,34 @@
   133.4 +/*
   133.5 + * Copyright (c) 2010, Oracle and/or its affiliates. All rights reserved.
   133.6 + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
   133.7 + *
   133.8 + * This code is free software; you can redistribute it and/or modify it
   133.9 + * under the terms of the GNU General Public License version 2 only, as
  133.10 + * published by the Free Software Foundation.
  133.11 + *
  133.12 + * This code is distributed in the hope that it will be useful, but WITHOUT
  133.13 + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
  133.14 + * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
  133.15 + * version 2 for more details (a copy is included in the LICENSE file that
  133.16 + * accompanied this code).
  133.17 + *
  133.18 + * You should have received a copy of the GNU General Public License version
  133.19 + * 2 along with this work; if not, write to the Free Software Foundation,
  133.20 + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
  133.21 + *
  133.22 + * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
  133.23 + * or visit www.oracle.com if you need additional information or have any
  133.24 + * questions.
  133.25 + */
  133.26 +
  133.27 +/*
  133.28 + * @test
  133.29 + * @bug 6900037
  133.30 + * @summary javac should warn if earlier -source is used and bootclasspath not set
  133.31 + * @compile T6900037.java
  133.32 + * @compile -source 1.6 T6900037.java
  133.33 + * @compile/fail/ref=T6900037.out -XDrawDiagnostics -Werror -source 1.6 T6900037.java
  133.34 + * @compile -Werror -source 1.6 -Xlint:-options T6900037.java
  133.35 + */
  133.36 +
  133.37 +class T6900037 { }
   134.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
   134.2 +++ b/test/tools/javac/options/T6900037.out	Thu Mar 10 20:51:07 2011 -0800
   134.3 @@ -0,0 +1,4 @@
   134.4 +- compiler.warn.source.no.bootclasspath: 1.6
   134.5 +- compiler.err.warnings.and.werror
   134.6 +1 error
   134.7 +1 warning
   135.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
   135.2 +++ b/test/tools/javac/options/T6986895.java	Thu Mar 10 20:51:07 2011 -0800
   135.3 @@ -0,0 +1,66 @@
   135.4 +/*
   135.5 + * Copyright (c) 2011, Oracle and/or its affiliates. All rights reserved.
   135.6 + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
   135.7 + *
   135.8 + * This code is free software; you can redistribute it and/or modify it
   135.9 + * under the terms of the GNU General Public License version 2 only, as
  135.10 + * published by the Free Software Foundation.
  135.11 + *
  135.12 + * This code is distributed in the hope that it will be useful, but WITHOUT
  135.13 + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
  135.14 + * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
  135.15 + * version 2 for more details (a copy is included in the LICENSE file that
  135.16 + * accompanied this code).
  135.17 + *
  135.18 + * You should have received a copy of the GNU General Public License version
  135.19 + * 2 along with this work; if not, write to the Free Software Foundation,
  135.20 + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
  135.21 + *
  135.22 + * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
  135.23 + * or visit www.oracle.com if you need additional information or have any
  135.24 + * questions.
  135.25 + */
  135.26 +
  135.27 +/*
  135.28 + * @test
  135.29 + * @bug 6986895
  135.30 + * @summary compiler gives misleading message for no input files
  135.31 + */
  135.32 +
  135.33 +import java.io.*;
  135.34 +import java.util.*;
  135.35 +
  135.36 +public class T6986895 {
  135.37 +    public static void main(String... args) throws Exception {
  135.38 +        new T6986895().run();
  135.39 +    }
  135.40 +
  135.41 +    String noSourceFiles = "no source files";
  135.42 +    String noSourceFilesOrClasses = "no source files or class names";
  135.43 +
  135.44 +    void run() throws Exception {
  135.45 +        Locale prev = Locale.getDefault();
  135.46 +        try {
  135.47 +            Locale.setDefault(Locale.ENGLISH);
  135.48 +            test(noSourceFiles,           "-Werror");
  135.49 +            test(noSourceFilesOrClasses,  "-Werror", "-Xprint");
  135.50 +        } finally {
  135.51 +            Locale.setDefault(prev);
  135.52 +        }
  135.53 +    }
  135.54 +
  135.55 +    void test(String expect, String... args) throws Exception {
  135.56 +        System.err.println("Test " + expect + ": " + Arrays.asList(args));
  135.57 +        StringWriter sw = new StringWriter();
  135.58 +        PrintWriter pw = new PrintWriter(sw);
  135.59 +        int rc = com.sun.tools.javac.Main.compile(args, pw);
  135.60 +        pw.close();
  135.61 +        System.err.println("compilation failed; rc=" + rc);
  135.62 +        String out = sw.toString();
  135.63 +        if (!out.isEmpty())
  135.64 +            System.err.println(out);
  135.65 +        if (!out.contains(expect))
  135.66 +            throw new Exception("expected text not found: " + expect);
  135.67 +        System.err.println();
  135.68 +    }
  135.69 +}
   136.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
   136.2 +++ b/test/tools/javac/options/T7022337.java	Thu Mar 10 20:51:07 2011 -0800
   136.3 @@ -0,0 +1,107 @@
   136.4 +/*
   136.5 + * Copyright (c) 2011, Oracle and/or its affiliates. All rights reserved.
   136.6 + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
   136.7 + *
   136.8 + * This code is free software; you can redistribute it and/or modify it
   136.9 + * under the terms of the GNU General Public License version 2 only, as
  136.10 + * published by the Free Software Foundation.
  136.11 + *
  136.12 + * This code is distributed in the hope that it will be useful, but WITHOUT
  136.13 + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
  136.14 + * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
  136.15 + * version 2 for more details (a copy is included in the LICENSE file that
  136.16 + * accompanied this code).
  136.17 + *
  136.18 + * You should have received a copy of the GNU General Public License version
  136.19 + * 2 along with this work; if not, write to the Free Software Foundation,
  136.20 + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
  136.21 + *
  136.22 + * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
  136.23 + * or visit www.oracle.com if you need additional information or have any
  136.24 + * questions.
  136.25 + */
  136.26 +
  136.27 +
  136.28 +/*
  136.29 + * @test
  136.30 + * @bug 7022337
  136.31 + * @summary repeated warnings about bootclasspath not set
  136.32 + * @library ../lib
  136.33 + * @build JavacTestingAbstractProcessor T7022337
  136.34 + * @run main T7022337
  136.35 + */
  136.36 +
  136.37 +import java.io.*;
  136.38 +import java.util.*;
  136.39 +import javax.annotation.processing.*;
  136.40 +import javax.lang.model.element.*;
  136.41 +import javax.tools.*;
  136.42 +
  136.43 +public class T7022337 extends JavacTestingAbstractProcessor {
  136.44 +    public static void main(String... args) throws Exception {
  136.45 +        new T7022337().run();
  136.46 +    }
  136.47 +
  136.48 +    void run() throws Exception {
  136.49 +        String myName = T7022337.class.getSimpleName();
  136.50 +        File testSrc = new File(System.getProperty("test.src"));
  136.51 +        File file = new File(testSrc, myName + ".java");
  136.52 +
  136.53 +        String out = compile(
  136.54 +            "-XDrawDiagnostics",
  136.55 +            "-d", ".",
  136.56 +            "-processor", myName,
  136.57 +            "-source", "6", // explicit use of older source value without bootclasspath
  136.58 +            file.getPath());
  136.59 +
  136.60 +        int count = 0;
  136.61 +        for (String line: out.split("[\r\n]+")) {
  136.62 +            if (line.contains("compiler.warn.source.no.bootclasspath"))
  136.63 +                count++;
  136.64 +        }
  136.65 +        if (count != 1)
  136.66 +            throw new Exception("unexpected number of warnings found: " + count + ", expected: 1");
  136.67 +    }
  136.68 +
  136.69 +    String compile(String... args) throws Exception {
  136.70 +        StringWriter sw = new StringWriter();
  136.71 +        PrintWriter pw = new PrintWriter(sw);
  136.72 +        int rc = com.sun.tools.javac.Main.compile(args, pw);
  136.73 +        pw.close();
  136.74 +        String out = sw.toString();
  136.75 +        if (!out.isEmpty())
  136.76 +            System.err.println(out);
  136.77 +        if (rc != 0)
  136.78 +            throw new Exception("compilation failed unexpectedly: rc=" + rc);
  136.79 +        return out;
  136.80 +    }
  136.81 +
  136.82 +    // ----------
  136.83 +
  136.84 +    int round = 0;
  136.85 +
  136.86 +    @Override
  136.87 +    public boolean process(Set<? extends TypeElement> annotations, RoundEnvironment roundEnv) {
  136.88 +        round++;
  136.89 +
  136.90 +        final int MAXROUNDS = 3;
  136.91 +        if (round < MAXROUNDS)
  136.92 +            generate("Gen" + round);
  136.93 +
  136.94 +        return true;
  136.95 +    }
  136.96 +
  136.97 +    void generate(String name) {
  136.98 +        try {
  136.99 +            JavaFileObject fo = filer.createSourceFile(name);
 136.100 +            Writer out = fo.openWriter();
 136.101 +            try {
 136.102 +                out.write("class " + name + " { }");
 136.103 +            } finally {
 136.104 +                out.close();
 136.105 +            }
 136.106 +        } catch (IOException e) {
 136.107 +            throw new Error(e);
 136.108 +        }
 136.109 +    }
 136.110 +}
   137.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
   137.2 +++ b/test/tools/javac/processing/TestWarnErrorCount.java	Thu Mar 10 20:51:07 2011 -0800
   137.3 @@ -0,0 +1,340 @@
   137.4 +/*
   137.5 + * Copyright (c) 2011, Oracle and/or its affiliates. All rights reserved.
   137.6 + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
   137.7 + *
   137.8 + * This code is free software; you can redistribute it and/or modify it
   137.9 + * under the terms of the GNU General Public License version 2 only, as
  137.10 + * published by the Free Software Foundation.
  137.11 + *
  137.12 + * This code is distributed in the hope that it will be useful, but WITHOUT
  137.13 + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
  137.14 + * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
  137.15 + * version 2 for more details (a copy is included in the LICENSE file that
  137.16 + * accompanied this code).
  137.17 + *
  137.18 + * You should have received a copy of the GNU General Public License version
  137.19 + * 2 along with this work; if not, write to the Free Software Foundation,
  137.20 + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
  137.21 + *
  137.22 + * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
  137.23 + * or visit www.oracle.com if you need additional information or have any
  137.24 + * questions.
  137.25 + */
  137.26 +
  137.27 +
  137.28 +/*
  137.29 + * @test
  137.30 + * @bug 7022337
  137.31 + * @summary repeated warnings about bootclasspath not set
  137.32 + * @library ../lib
  137.33 + * @build JavacTestingAbstractProcessor TestWarnErrorCount
  137.34 + * @run main TestWarnErrorCount
  137.35 + */
  137.36 +
  137.37 +import java.io.*;
  137.38 +import java.util.*;
  137.39 +import javax.annotation.processing.*;
  137.40 +import javax.lang.model.element.*;
  137.41 +import javax.tools.*;
  137.42 +
  137.43 +@SupportedOptions({"errKind", "msgrWarnKind", "javaWarnKind"})
  137.44 +public class TestWarnErrorCount extends JavacTestingAbstractProcessor {
  137.45 +    public static void main(String... args) throws Exception {
  137.46 +        new TestWarnErrorCount().run(args);
  137.47 +    }
  137.48 +
  137.49 +    final int MAX_GEN = 10;
  137.50 +    final int ERROR_ROUND = MAX_GEN / 2; // when to generate error
  137.51 +
  137.52 +    /**
  137.53 +     * Type of errors to generate in test case.
  137.54 +     */
  137.55 +    enum ErrorKind {
  137.56 +        /** No errors. */
  137.57 +        NONE,
  137.58 +        /** Source code errors. */
  137.59 +        JAVA,
  137.60 +        /** Errors reported to Messager. */
  137.61 +        MESSAGER,
  137.62 +        /** Error as a result of using -Werror. */
  137.63 +        WERROR,
  137.64 +    }
  137.65 +
  137.66 +    /**
  137.67 +     * Frequency of warnings in test case.
  137.68 +     */
  137.69 +    enum WarnKind {
  137.70 +        /** No warnings. */
  137.71 +        NONE {
  137.72 +            boolean warn(int round) { return false; }
  137.73 +            int count(int start, int end) { return 0; }
  137.74 +        },
  137.75 +        /** Generate a warning if round count is a multiple of 2. */
  137.76 +        EVERY_TWO {
  137.77 +            boolean warn(int round) { return (round % 2) == 0; }
  137.78 +            int count(int start, int end) { return (end / 2) - ((start - 1)/ 2); }
  137.79 +        },
  137.80 +        /** Generate a warning if round count is a multiple of 3. */
  137.81 +        EVERY_THREE {
  137.82 +            boolean warn(int round) { return (round % 3) == 0; }
  137.83 +            int count(int start, int end) { return (end / 3) - ((start - 1)/ 3); }
  137.84 +        },
  137.85 +        /** Generate a warning every round. */
  137.86 +        ALL {
  137.87 +            boolean warn(int round) { return true; }
  137.88 +            int count(int start, int end) { return (end - start + 1); }
  137.89 +        };
  137.90 +
  137.91 +        /** whether to generate a warning in round 'round'. */
  137.92 +        abstract boolean warn(int round);
  137.93 +
  137.94 +        /** number of warnings generated in a range of rounds, inclusive. */
  137.95 +        abstract int count(int start, int end);
  137.96 +    }
  137.97 +
  137.98 +
  137.99 +    /**
 137.100 +     * Run test.
 137.101 +     * @param args provide ability to specify particular test cases for debugging.
 137.102 +     */
 137.103 +    void run(String... args) throws Exception {
 137.104 +        for (String arg: args) {
 137.105 +            if (arg.matches("[0-9]+")) {
 137.106 +                if (testCases == null)
 137.107 +                    testCases = new HashSet<Integer>();
 137.108 +                testCases.add(Integer.valueOf(arg));
 137.109 +            } else if (arg.equals("-stopOnError")) {
 137.110 +                stopOnError = true;
 137.111 +            } else
 137.112 +                throw new IllegalArgumentException(arg);
 137.113 +        }
 137.114 +
 137.115 +        run ();
 137.116 +
 137.117 +        if (errors > 0)
 137.118 +            throw new Exception(errors + " errors found");
 137.119 +    }
 137.120 +
 137.121 +    /**
 137.122 +     * Run test.
 137.123 +     */
 137.124 +    void run() throws Exception {
 137.125 +        for (ErrorKind ek: ErrorKind.values()) {
 137.126 +            for (WarnKind mwk: WarnKind.values()) {
 137.127 +                for (WarnKind jwk: WarnKind.values()) {
 137.128 +                    test(ek, mwk, jwk);
 137.129 +                    if (stopOnError && errors > 0)
 137.130 +                        throw new Exception(errors + " errors found");
 137.131 +                }
 137.132 +            }
 137.133 +        }
 137.134 +    }
 137.135 +
 137.136 +    boolean stopOnError;
 137.137 +    Set<Integer> testCases;
 137.138 +    int testNum = 0;
 137.139 +
 137.140 +    /**
 137.141 +     * Run a test case.
 137.142 +     * @param ek    The type of errors to generate
 137.143 +     * @param mwk   The frequency of Messager warnings to generate
 137.144 +     * @param jwk   The frequency of Java warnings to generate
 137.145 +     */
 137.146 +    void test(ErrorKind ek, WarnKind mwk, WarnKind jwk) {
 137.147 +        testNum++;
 137.148 +
 137.149 +        if (testCases != null && !testCases.contains(testNum))
 137.150 +            return;
 137.151 +
 137.152 +        System.err.println("Test " + testNum + ": ek:" + ek + " mwk:" + mwk + " jwk:" + jwk);
 137.153 +
 137.154 +        File testDir = new File("test" + testNum);
 137.155 +        testDir.mkdirs();
 137.156 +
 137.157 +        String myName = TestWarnErrorCount.class.getSimpleName();
 137.158 +        File testSrc = new File(System.getProperty("test.src"));
 137.159 +        File file = new File(testSrc, myName + ".java");
 137.160 +
 137.161 +        List<String> args = new ArrayList<String>();
 137.162 +        args.addAll(Arrays.asList(
 137.163 +            "-XDrawDiagnostics",
 137.164 +            "-d", testDir.getPath(),
 137.165 +            "-processor", myName,
 137.166 +//            "-XprintRounds",
 137.167 +            "-Xlint:all,-path",
 137.168 +            "-AerrKind=" + ek,
 137.169 +            "-AmsgrWarnKind=" + mwk,
 137.170 +            "-AjavaWarnKind=" + jwk));
 137.171 +        if (ek == ErrorKind.WERROR)
 137.172 +            args.add("-Werror");
 137.173 +        args.add(file.getPath());
 137.174 +
 137.175 +        String out = compile(args.toArray(new String[args.size()]));
 137.176 +
 137.177 +        int errsFound = 0;
 137.178 +        int errsReported = 0;
 137.179 +        int warnsFound = 0;
 137.180 +        int warnsReported = 0;
 137.181 +
 137.182 +        // Scan the output looking for messages of interest.
 137.183 +
 137.184 +        for (String line: out.split("[\r\n]+")) {
 137.185 +            if (line.contains("compiler.err.")) {
 137.186 +                errsFound++;
 137.187 +            } else if (line.contains("compiler.warn.")) {
 137.188 +                warnsFound++;
 137.189 +            } else if (line.matches("[0-9]+ error(?:s?)")) {
 137.190 +                errsReported = Integer.valueOf(line.substring(0, line.indexOf("error")).trim());
 137.191 +            } else if (line.matches("[0-9]+ warning(?:s?)")) {
 137.192 +                warnsReported = Integer.valueOf(line.substring(0, line.indexOf("warning")).trim());
 137.193 +            }
 137.194 +        }
 137.195 +
 137.196 +        // Compute the expected number of errors and warnings, based on
 137.197 +        // the test case parameters.
 137.198 +        // This is highly specific to the annotation processor below, and to
 137.199 +        // the files it generates.
 137.200 +        // Generally, the rules are:
 137.201 +        // -- errors stop annotation processing, allowing for one extra "last round"
 137.202 +        // -- messager warnings are immediate
 137.203 +        // -- javac warnings are not shown before the final compilation
 137.204 +        //      (FIXME?  -Werror does not stop processing for java warnings)
 137.205 +        int errsExpected;
 137.206 +        int msgrWarnsExpected;
 137.207 +        int javaWarnsExpected;
 137.208 +        switch (ek) {
 137.209 +            case NONE:
 137.210 +                errsExpected = 0;
 137.211 +                msgrWarnsExpected = mwk.count(1, 1 + MAX_GEN + 1);
 137.212 +                javaWarnsExpected = jwk.count(2, 1 + MAX_GEN);
 137.213 +                break;
 137.214 +            case MESSAGER:
 137.215 +                errsExpected = 1;
 137.216 +                msgrWarnsExpected = mwk.count(1, ERROR_ROUND + 1);
 137.217 +                javaWarnsExpected = 0;
 137.218 +                break;
 137.219 +            case JAVA:
 137.220 +                errsExpected = 2;
 137.221 +                msgrWarnsExpected = mwk.count(1, ERROR_ROUND + 1);
 137.222 +                javaWarnsExpected = 0;
 137.223 +                break;
 137.224 +            case WERROR:
 137.225 +                errsExpected = (mwk != WarnKind.NONE || jwk != WarnKind.NONE) ? 1 : 0;
 137.226 +                switch (mwk) {
 137.227 +                    case NONE:
 137.228 +                        msgrWarnsExpected = 0;
 137.229 +                        javaWarnsExpected = (jwk == WarnKind.NONE)
 137.230 +                                ? 0
 137.231 +                                : 1;  // this is surprising: javac only reports warning in first file
 137.232 +                        break;
 137.233 +                    case EVERY_TWO:
 137.234 +                        msgrWarnsExpected = mwk.count(1, 2 + 1);
 137.235 +                        javaWarnsExpected = 0;
 137.236 +                        break;
 137.237 +                    case EVERY_THREE:
 137.238 +                        msgrWarnsExpected = mwk.count(1, 3 + 1);
 137.239 +                        javaWarnsExpected = 0;
 137.240 +                        break;
 137.241 +                    case ALL:
 137.242 +                        msgrWarnsExpected = mwk.count(1, 1 + 1);
 137.243 +                        javaWarnsExpected = 0;
 137.244 +                        break;
 137.245 +                    default:
 137.246 +                        throw new IllegalStateException();
 137.247 +                }
 137.248 +                break;
 137.249 +            default:
 137.250 +                throw new IllegalStateException();
 137.251 +        }
 137.252 +
 137.253 +        int warnsExpected = msgrWarnsExpected + javaWarnsExpected;
 137.254 +        System.err.println("mwk: " + msgrWarnsExpected
 137.255 +                + ", jwk: " + javaWarnsExpected
 137.256 +                + ", total: " + warnsExpected);
 137.257 +
 137.258 +        boolean ok;
 137.259 +        ok  = checkEqual("errors", "reported", errsFound, errsReported);
 137.260 +        ok &= checkEqual("errors", "expected", errsFound, errsExpected);
 137.261 +        ok &= checkEqual("warnings", "reported", warnsFound, warnsReported);
 137.262 +        ok &= checkEqual("warnings", "expected", warnsFound, warnsExpected);
 137.263 +        if (ok)
 137.264 +            System.err.println("OK");
 137.265 +
 137.266 +        System.err.println();
 137.267 +    }
 137.268 +
 137.269 +    String compile(String... args) {
 137.270 +        StringWriter sw = new StringWriter();
 137.271 +        PrintWriter pw = new PrintWriter(sw);
 137.272 +        int rc = com.sun.tools.javac.Main.compile(args, pw);
 137.273 +        pw.close();
 137.274 +        String out = sw.toString();
 137.275 +        if (!out.isEmpty())
 137.276 +            System.err.println(out);
 137.277 +        if (rc != 0)
 137.278 +            System.err.println("compilation failed: rc=" + rc);
 137.279 +        return out;
 137.280 +    }
 137.281 +
 137.282 +    boolean checkEqual(String l1, String l2, int i1, int i2) {
 137.283 +        if (i1 != i2)
 137.284 +            error("number of " + l1 + " found, " + i1 + ", does not match number " + l2 + ", " + i2);
 137.285 +        return (i1 == i2);
 137.286 +    }
 137.287 +
 137.288 +    void error(String msg) {
 137.289 +        System.err.println("Error: " + msg);
 137.290 +        errors++;
 137.291 +    }
 137.292 +
 137.293 +    int errors = 0;
 137.294 +
 137.295 +    // ----- Annotation processor -----
 137.296 +
 137.297 +    int round = 0;
 137.298 +
 137.299 +    @Override
 137.300 +    public boolean process(Set<? extends TypeElement> annotations, RoundEnvironment roundEnv) {
 137.301 +        round++;
 137.302 +
 137.303 +        ErrorKind ek = ErrorKind.valueOf(options.get("errKind"));
 137.304 +        WarnKind mwk = WarnKind.valueOf(options.get("msgrWarnKind"));
 137.305 +        WarnKind jwk = WarnKind.valueOf(options.get("javaWarnKind"));
 137.306 +        messager.printMessage(Diagnostic.Kind.NOTE,
 137.307 +                "Round " + round
 137.308 +                + " " + roundEnv.getRootElements()
 137.309 +                + ", last round: " + roundEnv.processingOver());
 137.310 +        messager.printMessage(Diagnostic.Kind.NOTE,
 137.311 +                "ek: " + ek + ", mwk: " + mwk + ", jwk: " + jwk);
 137.312 +
 137.313 +        if (round <= MAX_GEN && !roundEnv.processingOver())
 137.314 +            generate("Gen" + round,
 137.315 +                    (ek == ErrorKind.JAVA) && (round == ERROR_ROUND),
 137.316 +                    jwk.warn(round));
 137.317 +
 137.318 +        if (mwk.warn(round))
 137.319 +            messager.printMessage(Diagnostic.Kind.WARNING, "round " + round);
 137.320 +
 137.321 +        if ((ek == ErrorKind.MESSAGER) && (round == ERROR_ROUND))
 137.322 +            messager.printMessage(Diagnostic.Kind.ERROR, "round " + round);
 137.323 +
 137.324 +        return true;
 137.325 +    }
 137.326 +
 137.327 +    void generate(String name, boolean error, boolean warn) {
 137.328 +        try {
 137.329 +            JavaFileObject fo = filer.createSourceFile(name);
 137.330 +            Writer out = fo.openWriter();
 137.331 +            try {
 137.332 +                out.write("class " + name + " {\n"
 137.333 +                        + (warn ? "    int i = (int) 0;\n" : "")
 137.334 +                        + (error ? "   ERROR\n" : "")
 137.335 +                        + "}\n");
 137.336 +            } finally {
 137.337 +                out.close();
 137.338 +            }
 137.339 +        } catch (IOException e) {
 137.340 +            throw new Error(e);
 137.341 +        }
 137.342 +    }
 137.343 +}
   138.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
   138.2 +++ b/test/tools/javac/processing/model/TestSymtabItems.java	Thu Mar 10 20:51:07 2011 -0800
   138.3 @@ -0,0 +1,221 @@
   138.4 +/*
   138.5 + * Copyright (c) 2011, Oracle and/or its affiliates. All rights reserved.
   138.6 + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
   138.7 + *
   138.8 + * This code is free software; you can redistribute it and/or modify it
   138.9 + * under the terms of the GNU General Public License version 2 only, as
  138.10 + * published by the Free Software Foundation.
  138.11 + *
  138.12 + * This code is distributed in the hope that it will be useful, but WITHOUT
  138.13 + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
  138.14 + * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
  138.15 + * version 2 for more details (a copy is included in the LICENSE file that
  138.16 + * accompanied this code).
  138.17 + *
  138.18 + * You should have received a copy of the GNU General Public License version
  138.19 + * 2 along with this work; if not, write to the Free Software Foundation,
  138.20 + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
  138.21 + *
  138.22 + * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
  138.23 + * or visit www.oracle.com if you need additional information or have any
  138.24 + * questions.
  138.25 + */
  138.26 +
  138.27 +/*
  138.28 + * @test
  138.29 + * @bug 7021183
  138.30 + * @summary 269: assertion failure getting enclosing element of an undefined name
  138.31 + */
  138.32 +
  138.33 +import java.lang.reflect.Field;
  138.34 +import javax.lang.model.element.Element;
  138.35 +import javax.lang.model.element.ExecutableElement;
  138.36 +import javax.lang.model.element.PackageElement;
  138.37 +import javax.lang.model.element.TypeElement;
  138.38 +import javax.lang.model.element.TypeParameterElement;
  138.39 +import javax.lang.model.element.UnknownElementException;
  138.40 +import javax.lang.model.element.VariableElement;
  138.41 +import javax.lang.model.type.TypeMirror;
  138.42 +import javax.lang.model.type.UnknownTypeException;
  138.43 +import javax.lang.model.util.ElementScanner7;
  138.44 +import javax.lang.model.util.SimpleTypeVisitor7;
  138.45 +import javax.lang.model.util.Types;
  138.46 +
  138.47 +import com.sun.tools.javac.code.Symbol.ClassSymbol;
  138.48 +import com.sun.tools.javac.code.Symtab;
  138.49 +import com.sun.tools.javac.file.JavacFileManager;
  138.50 +import com.sun.tools.javac.model.JavacTypes;
  138.51 +import com.sun.tools.javac.util.Context;
  138.52 +
  138.53 +/**
  138.54 + * Scan javac Symtab looking for TypeMirrors and Elements, and ensure that
  138.55 + * no exceptions are thrown when used with javax.lang.model visitors.
  138.56 + *
  138.57 + */
  138.58 +public class TestSymtabItems {
  138.59 +    public static void main(String... args) throws Exception {
  138.60 +        new TestSymtabItems().run();
  138.61 +    }
  138.62 +
  138.63 +    void run() throws Exception {
  138.64 +        Context c = new Context();
  138.65 +        JavacFileManager.preRegister(c);
  138.66 +        Symtab syms = Symtab.instance(c);
  138.67 +        JavacTypes types = JavacTypes.instance(c);
  138.68 +
  138.69 +//        print("noSymbol", syms.noSymbol);
  138.70 +//        print("errSymbol", syms.errSymbol);
  138.71 +//        print("unknownSymbol", syms.unknownSymbol);
  138.72 +//        print("botType", syms.botType);
  138.73 +//        print("errType", syms.errType);
  138.74 +//        print("unknownType", syms.unknownType);
  138.75 +
  138.76 +        for (Field f: Symtab.class.getDeclaredFields()) {
  138.77 +//            System.err.println(f.getType() + " " + f.getName());
  138.78 +
  138.79 +            // Temporarily ignore methodHandle and transientMethodHandle
  138.80 +            // during API evolution
  138.81 +            if (f.getName().toLowerCase().contains("methodhandle"))
  138.82 +                continue;
  138.83 +
  138.84 +            Class<?> ft = f.getType();
  138.85 +            if (TypeMirror.class.isAssignableFrom(ft))
  138.86 +                print(f.getName(), (TypeMirror) f.get(syms), types);
  138.87 +            else if(Element.class.isAssignableFrom(ft))
  138.88 +                print(f.getName(), (Element) f.get(syms));
  138.89 +        }
  138.90 +
  138.91 +        if (errors > 0)
  138.92 +            throw new Exception(errors + " errors occurred");
  138.93 +    }
  138.94 +
  138.95 +    void print(String label, Element e) {
  138.96 +        ElemPrinter ep = new ElemPrinter();
  138.97 +        System.err.println("Test " + label);
  138.98 +        ep.visit(e);
  138.99 +        System.err.println();
 138.100 +    }
 138.101 +
 138.102 +    void print(String label, TypeMirror t, Types types) {
 138.103 +        TypePrinter tp = new TypePrinter();
 138.104 +        System.err.println("Test " + label);
 138.105 +        tp.visit(t, types);
 138.106 +        System.err.println();
 138.107 +    }
 138.108 +
 138.109 +    void error(String msg) {
 138.110 +        System.err.println("Error: " + msg);
 138.111 +        errors++;
 138.112 +    }
 138.113 +
 138.114 +    int errors;
 138.115 +
 138.116 +    class ElemPrinter extends ElementScanner7<Void, Void> {
 138.117 +        @Override
 138.118 +        public Void visitPackage(PackageElement e, Void p) {
 138.119 +            show("package", e);
 138.120 +            indent(+1);
 138.121 +            super.visitPackage(e, p);
 138.122 +            indent(-1);
 138.123 +            return null;
 138.124 +        }
 138.125 +
 138.126 +        @Override
 138.127 +        public Void visitType(TypeElement e, Void p) {
 138.128 +            show("type", e);
 138.129 +            indent(+1);
 138.130 +            super.visitType(e, p);
 138.131 +            indent(-1);
 138.132 +            return null;
 138.133 +        }
 138.134 +
 138.135 +        @Override
 138.136 +        public Void visitVariable(VariableElement e, Void p) {
 138.137 +            show("variable", e);
 138.138 +            indent(+1);
 138.139 +            super.visitVariable(e, p);
 138.140 +            indent(-1);
 138.141 +            return null;
 138.142 +        }
 138.143 +
 138.144 +        @Override
 138.145 +        public Void visitExecutable(ExecutableElement e, Void p) {
 138.146 +            show("executable", e);
 138.147 +            indent(+1);
 138.148 +            super.visitExecutable(e, p);
 138.149 +            indent(-1);
 138.150 +            return null;
 138.151 +        }
 138.152 +
 138.153 +        @Override
 138.154 +        public Void visitTypeParameter(TypeParameterElement e, Void p) {
 138.155 +            show("type parameter", e);
 138.156 +            indent(+1);
 138.157 +            super.visitTypeParameter(e, p);
 138.158 +            indent(-1);
 138.159 +            return null;
 138.160 +        }
 138.161 +
 138.162 +        @Override
 138.163 +        public Void visitUnknown(Element e, Void p) {
 138.164 +            show("unknown", e);
 138.165 +            indent(+1);
 138.166 +            try {
 138.167 +                super.visitUnknown(e, p);
 138.168 +            } catch (UnknownElementException ex) {
 138.169 +                System.err.println("caught " + ex);
 138.170 +            }
 138.171 +            indent(-1);
 138.172 +            return null;
 138.173 +        }
 138.174 +
 138.175 +        void indent(int i) {
 138.176 +            indent += i;
 138.177 +        }
 138.178 +
 138.179 +        String sp(int w) {
 138.180 +            StringBuilder sb = new StringBuilder();
 138.181 +            for (int i = 0; i < w; i++)
 138.182 +                sb.append("    ");
 138.183 +            return sb.toString();
 138.184 +        }
 138.185 +
 138.186 +        void show(String label, Element e) {
 138.187 +            System.err.println(sp(indent) + label
 138.188 +                    + ": mods:" + e.getModifiers()
 138.189 +                    + " " + e.getSimpleName()
 138.190 +                    + ", kind: " + e.getKind()
 138.191 +                    + ", type: " + e.asType()
 138.192 +                    + ", encl: " + e.getEnclosingElement());
 138.193 +
 138.194 +            // The following checks help establish why NPE might occur when trying to scan children
 138.195 +            if (e instanceof ClassSymbol) {
 138.196 +                ClassSymbol csym = (ClassSymbol) e;
 138.197 +                if (csym.members_field == null)
 138.198 +                    error("members_field is null");
 138.199 +                if (csym.type == null)
 138.200 +                    System.err.println("type is null");
 138.201 +            }
 138.202 +        }
 138.203 +
 138.204 +        int indent;
 138.205 +    };
 138.206 +
 138.207 +    class TypePrinter extends SimpleTypeVisitor7<Void, Types> {
 138.208 +        @Override
 138.209 +        public Void defaultAction(TypeMirror m, Types types) {
 138.210 +            System.err.println(m.getKind() + " " + m + " " + types.asElement(m));
 138.211 +            return null;
 138.212 +        }
 138.213 +
 138.214 +        @Override
 138.215 +        public Void visitUnknown(TypeMirror t, Types types) {
 138.216 +            try {
 138.217 +                return super.visitUnknown(t, types);
 138.218 +            } catch (UnknownTypeException ex) {
 138.219 +                System.err.println("caught " + ex);
 138.220 +                return null;
 138.221 +            }
 138.222 +        }
 138.223 +    };
 138.224 +}
   139.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
   139.2 +++ b/test/tools/javac/processing/model/element/TestMissingElement/InvalidSource.java	Thu Mar 10 20:51:07 2011 -0800
   139.3 @@ -0,0 +1,108 @@
   139.4 +/*
   139.5 + * Copyright (c) 2011, Oracle and/or its affiliates. All rights reserved.
   139.6 + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
   139.7 + *
   139.8 + * This code is free software; you can redistribute it and/or modify it
   139.9 + * under the terms of the GNU General Public License version 2 only, as
  139.10 + * published by the Free Software Foundation.
  139.11 + *
  139.12 + * This code is distributed in the hope that it will be useful, but WITHOUT
  139.13 + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
  139.14 + * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
  139.15 + * version 2 for more details (a copy is included in the LICENSE file that
  139.16 + * accompanied this code).
  139.17 + *
  139.18 + * You should have received a copy of the GNU General Public License version
  139.19 + * 2 along with this work; if not, write to the Free Software Foundation,
  139.20 + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
  139.21 + *
  139.22 + * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
  139.23 + * or visit www.oracle.com if you need additional information or have any
  139.24 + * questions.
  139.25 + */
  139.26 +
  139.27 +import java.util.*;
  139.28 +
  139.29 +@interface ExpectInterfaces {
  139.30 +    String value();
  139.31 +}
  139.32 +
  139.33 +@interface ExpectSupertype {
  139.34 +    String value();
  139.35 +}
  139.36 +
  139.37 +interface OK {
  139.38 +    void m();
  139.39 +}
  139.40 +
  139.41 +class InvalidSource {
  139.42 +    /*
  139.43 +     * The following annotations contain a simple description of the expected
  139.44 +     * representation of the superclass and superinterfaces of the corresponding
  139.45 +     * elements.
  139.46 +     * The strings contain a comma-separated list of descriptions.
  139.47 +     * Descriptions are composed as follows:
  139.48 +     * A leading "!:" indicates the type mirror has kind ERROR.
  139.49 +     * "empty" means that the corresponding element has no enclosed elements.
  139.50 +     * "clss", "intf" and "tvar" indicate the name refers to a class, interface
  139.51 +     * or type variable. Each is followed by the declared name of the element.
  139.52 +     * "pkg" indicates the name of a package element.
  139.53 +     * An enclosing element is shown in parentheses.
  139.54 +     * A trailing "!" indicates that the element's type has kind ERROR.
  139.55 +     */
  139.56 +
  139.57 +    @ExpectSupertype("!:empty clss A!")
  139.58 +    class TestClassMissingClassA extends A { }
  139.59 +
  139.60 +    @ExpectSupertype("!:empty clss (pkg A).B!")
  139.61 +    class TestClassMissingClassAB extends A.B { }
  139.62 +
  139.63 +    @ExpectSupertype("!:empty clss (pkg java.util).A!")
  139.64 +    class TestClassMissingClass_juA extends java.util.A { }
  139.65 +
  139.66 +    @ExpectSupertype("!:empty clss A!<tvar T>")
  139.67 +    class TestClassTMissingClassAT<T> extends A<T> { }
  139.68 +
  139.69 +    @ExpectInterfaces("!:empty intf A!")
  139.70 +    class TestClassMissingIntfA implements A { }
  139.71 +
  139.72 +    @ExpectInterfaces("!:empty intf (pkg A).B!")
  139.73 +    class TestClassMissingIntfAB implements A.B { }
  139.74 +
  139.75 +    @ExpectInterfaces("!:empty intf A!, intf OK")
  139.76 +    abstract class TestClassMissingIntfAOK implements A, OK { }
  139.77 +
  139.78 +    @ExpectInterfaces("intf OK, !:empty intf A!")
  139.79 +    abstract class TestClassOKMissingIntfA implements OK, A { }
  139.80 +
  139.81 +    @ExpectInterfaces("!:empty intf A!, !:empty intf B!")
  139.82 +    class TestClassMissingIntfA_B implements A, B { }
  139.83 +
  139.84 +    @ExpectInterfaces("!:empty intf A!")
  139.85 +    interface TestIntfMissingIntfA extends A { }
  139.86 +
  139.87 +    @ExpectInterfaces("!:empty intf A!, intf OK")
  139.88 +    interface TestIntfMissingIntfAOK extends A, OK { }
  139.89 +
  139.90 +    @ExpectInterfaces("intf OK, !:empty intf A!")
  139.91 +    interface TestIntfOKMissingIntfA extends OK, A { }
  139.92 +
  139.93 +    @ExpectInterfaces("!:empty intf A!, !:empty intf B!")
  139.94 +    interface TestIntfMissingIntfAB extends A, B { }
  139.95 +
  139.96 +    @ExpectInterfaces("!:empty intf A!<tvar T>")
  139.97 +    class TestClassTMissingIntfAT<T> implements A<T> { }
  139.98 +
  139.99 +    @ExpectInterfaces("!:empty intf A!<tvar T>, !:empty intf B!")
 139.100 +    class TestClassTMissingIntfAT_B<T> implements A<T>, B { }
 139.101 +
 139.102 +    @ExpectInterfaces("!:empty intf A!<tvar T>")
 139.103 +    interface TestIntfTMissingIntfAT<T> extends A<T> { }
 139.104 +
 139.105 +    @ExpectInterfaces("!:empty intf A!<tvar T>, !:empty intf B!")
 139.106 +    interface TestIntfTMissingIntfAT_B<T> extends A<T>, B { }
 139.107 +
 139.108 +    @ExpectInterfaces("intf (pkg java.util).List<!:empty clss X!>")
 139.109 +    abstract class TestClassListMissingX implements List<X> { }
 139.110 +}
 139.111 +
   140.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
   140.2 +++ b/test/tools/javac/processing/model/element/TestMissingElement/TestMissingElement.java	Thu Mar 10 20:51:07 2011 -0800
   140.3 @@ -0,0 +1,185 @@
   140.4 +/*
   140.5 + * Copyright (c) 2011, Oracle and/or its affiliates. All rights reserved.
   140.6 + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
   140.7 + *
   140.8 + * This code is free software; you can redistribute it and/or modify it
   140.9 + * under the terms of the GNU General Public License version 2 only, as
  140.10 + * published by the Free Software Foundation.
  140.11 + *
  140.12 + * This code is distributed in the hope that it will be useful, but WITHOUT
  140.13 + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
  140.14 + * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
  140.15 + * version 2 for more details (a copy is included in the LICENSE file that
  140.16 + * accompanied this code).
  140.17 + *
  140.18 + * You should have received a copy of the GNU General Public License version
  140.19 + * 2 along with this work; if not, write to the Free Software Foundation,
  140.20 + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
  140.21 + *
  140.22 + * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
  140.23 + * or visit www.oracle.com if you need additional information or have any
  140.24 + * questions.
  140.25 + */
  140.26 +
  140.27 +
  140.28 +/*
  140.29 + * @test
  140.30 + * @bug 6639645
  140.31 + * @summary Modeling type implementing missing interfaces
  140.32 + * @library ../../../../lib
  140.33 + * @build JavacTestingAbstractProcessor TestMissingElement
  140.34 + * @compile -proc:only -XprintRounds -processor TestMissingElement InvalidSource.java
  140.35 + */
  140.36 +
  140.37 +import java.util.*;
  140.38 +import javax.annotation.processing.*;
  140.39 +import javax.lang.model.element.*;
  140.40 +import javax.lang.model.type.*;
  140.41 +import javax.lang.model.util.*;
  140.42 +import static javax.tools.Diagnostic.Kind.*;
  140.43 +
  140.44 +public class TestMissingElement extends JavacTestingAbstractProcessor {
  140.45 +    @Override
  140.46 +    public boolean process(Set<? extends TypeElement> annotations, RoundEnvironment roundEnv) {
  140.47 +        for (TypeElement te: ElementFilter.typesIn(roundEnv.getRootElements())) {
  140.48 +            if (isSimpleName(te, "InvalidSource")) {
  140.49 +                for (Element c: te.getEnclosedElements()) {
  140.50 +                    for (AnnotationMirror am: c.getAnnotationMirrors()) {
  140.51 +                        Element ate = am.getAnnotationType().asElement();
  140.52 +                        if (isSimpleName(ate, "ExpectInterfaces")) {
  140.53 +                            checkInterfaces((TypeElement) c, getValue(am));
  140.54 +                        } else if (isSimpleName(ate, "ExpectSupertype")) {
  140.55 +                            checkSupertype((TypeElement) c, getValue(am));
  140.56 +                        }
  140.57 +                    }
  140.58 +                }
  140.59 +            }
  140.60 +        }
  140.61 +        return true;
  140.62 +    }
  140.63 +
  140.64 +    private boolean isSimpleName(Element e, String name) {
  140.65 +        return e.getSimpleName().contentEquals(name);
  140.66 +    }
  140.67 +
  140.68 +    private String getValue(AnnotationMirror am) {
  140.69 +        Map<? extends ExecutableElement, ? extends AnnotationValue> map = am.getElementValues();
  140.70 +        if (map.size() != 1) throw new IllegalArgumentException();
  140.71 +        AnnotationValue v = map.values().iterator().next();
  140.72 +        return (String) v.getValue();
  140.73 +    }
  140.74 +
  140.75 +    private void checkInterfaces(TypeElement te, String expect) {
  140.76 +        System.err.println("check interfaces: " + te + " -- " + expect);
  140.77 +        String found = asString(te.getInterfaces(), ", ");
  140.78 +        checkEqual("interfaces", te, found, expect);
  140.79 +    }
  140.80 +
  140.81 +    private void checkSupertype(TypeElement te, String expect) {
  140.82 +        System.err.println("check supertype: " + te + " -- " + expect);
  140.83 +        String found = asString(te.getSuperclass());
  140.84 +        checkEqual("supertype", te, found, expect);
  140.85 +    }
  140.86 +
  140.87 +    private void checkEqual(String label, TypeElement te, String found, String expect) {
  140.88 +        if (found.equals(expect)) {
  140.89 +//            messager.printMessage(NOTE, "expected " + label + " found: " + expect, te);
  140.90 +        } else {
  140.91 +            System.err.println("unexpected " + label + ": " + te + "\n"
  140.92 +                    + " found: " + found + "\n"
  140.93 +                    + "expect: " + expect);
  140.94 +            messager.printMessage(ERROR, "unexpected " + label + " found: " + found + "; expected: " + expect, te);
  140.95 +        }
  140.96 +    }
  140.97 +
  140.98 +    private String asString(List<? extends TypeMirror> ts, String sep) {
  140.99 +        StringBuilder sb = new StringBuilder();
 140.100 +        for (TypeMirror t: ts) {
 140.101 +            if (sb.length() != 0) sb.append(sep);
 140.102 +            sb.append(asString(t));
 140.103 +        }
 140.104 +        return sb.toString();
 140.105 +    }
 140.106 +
 140.107 +    private String asString(TypeMirror t) {
 140.108 +        if (t == null)
 140.109 +            return "[typ:null]";
 140.110 +        return t.accept(new SimpleTypeVisitor7<String, Void>() {
 140.111 +            @Override
 140.112 +            public String defaultAction(TypeMirror t, Void ignore) {
 140.113 +                return "[typ:" + t.toString() + "]";
 140.114 +            }
 140.115 +
 140.116 +            @Override
 140.117 +            public String visitDeclared(DeclaredType t, Void ignore) {
 140.118 +                String s = asString(t.asElement());
 140.119 +                List<? extends TypeMirror> args = t.getTypeArguments();
 140.120 +                if (!args.isEmpty())
 140.121 +                    s += "<" + asString(args, ",") + ">";
 140.122 +                return s;
 140.123 +            }
 140.124 +
 140.125 +            @Override
 140.126 +            public String visitTypeVariable(TypeVariable t, Void ignore) {
 140.127 +                return "tvar " + t;
 140.128 +            }
 140.129 +
 140.130 +            @Override
 140.131 +            public String visitError(ErrorType t, Void ignore) {
 140.132 +                return "!:" + visitDeclared(t, ignore);
 140.133 +            }
 140.134 +        }, null);
 140.135 +    }
 140.136 +
 140.137 +    private String asString(Element e) {
 140.138 +        if (e == null)
 140.139 +            return "[elt:null]";
 140.140 +        return e.accept(new SimpleElementVisitor7<String, Void>() {
 140.141 +            @Override
 140.142 +            public String defaultAction(Element e, Void ignore) {
 140.143 +                return "[elt:" + e.getKind() + " " + e.toString() + "]";
 140.144 +            }
 140.145 +            @Override
 140.146 +            public String visitPackage(PackageElement e, Void ignore) {
 140.147 +                return "pkg " + e.getQualifiedName();
 140.148 +            }
 140.149 +            @Override
 140.150 +            public String visitType(TypeElement e, Void ignore) {
 140.151 +                StringBuilder sb = new StringBuilder();
 140.152 +                if (e.getEnclosedElements().isEmpty())
 140.153 +                    sb.append("empty ");
 140.154 +                ElementKind ek = e.getKind();
 140.155 +                switch (ek) {
 140.156 +                    case CLASS:
 140.157 +                        sb.append("clss");
 140.158 +                        break;
 140.159 +                    case INTERFACE:
 140.160 +                        sb.append("intf");
 140.161 +                        break;
 140.162 +                    default:
 140.163 +                        sb.append(ek);
 140.164 +                        break;
 140.165 +                }
 140.166 +                sb.append(" ");
 140.167 +                Element encl = e.getEnclosingElement();
 140.168 +                if (!isUnnamedPackage(encl) && encl.asType().getKind() != TypeKind.NONE) {
 140.169 +                    sb.append("(");
 140.170 +                    sb.append(asString(encl));
 140.171 +                    sb.append(")");
 140.172 +                    sb.append(".");
 140.173 +                }
 140.174 +                sb.append(e.getSimpleName());
 140.175 +                if (e.asType().getKind() == TypeKind.ERROR) sb.append("!");
 140.176 +                return sb.toString();
 140.177 +            }
 140.178 +        }, null);
 140.179 +    }
 140.180 +
 140.181 +    boolean isUnnamedPackage(Element e) {
 140.182 +        return (e != null && e.getKind() == ElementKind.PACKAGE
 140.183 +                && ((PackageElement) e).isUnnamed());
 140.184 +    }
 140.185 +}
 140.186 +
 140.187 +
 140.188 +
   141.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
   141.2 +++ b/test/tools/javac/processing/model/element/TestMissingElement2/Generator.java	Thu Mar 10 20:51:07 2011 -0800
   141.3 @@ -0,0 +1,111 @@
   141.4 +/*
   141.5 + * Copyright (c) 2011, Oracle and/or its affiliates. All rights reserved.
   141.6 + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
   141.7 + *
   141.8 + * This code is free software; you can redistribute it and/or modify it
   141.9 + * under the terms of the GNU General Public License version 2 only, as
  141.10 + * published by the Free Software Foundation.
  141.11 + *
  141.12 + * This code is distributed in the hope that it will be useful, but WITHOUT
  141.13 + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
  141.14 + * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
  141.15 + * version 2 for more details (a copy is included in the LICENSE file that
  141.16 + * accompanied this code).
  141.17 + *
  141.18 + * You should have received a copy of the GNU General Public License version
  141.19 + * 2 along with this work; if not, write to the Free Software Foundation,
  141.20 + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
  141.21 + *
  141.22 + * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
  141.23 + * or visit www.oracle.com if you need additional information or have any
  141.24 + * questions.
  141.25 + */
  141.26 +
  141.27 +import java.io.*;
  141.28 +import java.util.*;
  141.29 +import javax.annotation.processing.*;
  141.30 +import javax.lang.model.element.*;
  141.31 +import javax.lang.model.type.*;
  141.32 +import javax.lang.model.util.*;
  141.33 +import javax.tools.*;
  141.34 +
  141.35 +public class Generator extends JavacTestingAbstractProcessor {
  141.36 +
  141.37 +    @Override
  141.38 +    public boolean process(Set<? extends TypeElement> annotations, RoundEnvironment roundEnv) {
  141.39 +        for (TypeElement te: ElementFilter.typesIn(roundEnv.getRootElements())) {
  141.40 +            System.err.println(te);
  141.41 +            generateIfMissing(te.getSuperclass());
  141.42 +            generateIfMissing(te.getInterfaces());
  141.43 +        }
  141.44 +        return true;
  141.45 +    }
  141.46 +
  141.47 +    void generateIfMissing(List<? extends TypeMirror> ts) {
  141.48 +        for (TypeMirror t: ts)
  141.49 +            generateIfMissing(t);
  141.50 +    }
  141.51 +
  141.52 +    void generateIfMissing(TypeMirror t) {
  141.53 +        if (t == null)
  141.54 +            return;
  141.55 +        if (t.getKind() == TypeKind.ERROR) {
  141.56 +            Element e = ((ErrorType) t).asElement();
  141.57 +            if (e == null)
  141.58 +                return;
  141.59 +            if (e.asType().getKind() == TypeKind.ERROR)
  141.60 +                createFile((TypeElement) e);
  141.61 +        }
  141.62 +    }
  141.63 +
  141.64 +    void createFile(TypeElement e) {
  141.65 +        try {
  141.66 +            JavaFileObject fo = filer.createSourceFile(e.getSimpleName());
  141.67 +            Writer out = fo.openWriter();
  141.68 +            try {
  141.69 +                switch (e.getKind()) {
  141.70 +                    case CLASS:
  141.71 +                        out.write("import java.util.*;\n");
  141.72 +                        out.write("class " + signature(e) + " {\n");
  141.73 +                        out.write("    public void run() {\n");
  141.74 +                        out.write("        Class<?> c = getClass();\n");
  141.75 +                        out.write("        System.out.println(\"class: \" + c);\n");
  141.76 +                        out.write("        System.out.println(\"superclass: \" + c.getSuperclass());\n");
  141.77 +                        out.write("        System.out.println(\"generic superclass: \" +c.getGenericSuperclass());\n");
  141.78 +                        out.write("        System.out.println(\"interfaces: \" + Arrays.asList(c.getInterfaces()));\n");
  141.79 +                        out.write("        System.out.println(\"generic interfaces: \" + Arrays.asList(c.getGenericInterfaces()));\n");
  141.80 +                        out.write("    }\n");
  141.81 +                        out.write("}\n");
  141.82 +                        break;
  141.83 +                    case INTERFACE:
  141.84 +                        out.write("interface " + signature(e) + " {\n");
  141.85 +                        out.write("    void run();\n");
  141.86 +                        out.write("}\n");
  141.87 +                        break;
  141.88 +                }
  141.89 +            } finally {
  141.90 +                out.close();
  141.91 +            }
  141.92 +        } catch (IOException ex) {
  141.93 +            messager.printMessage(Diagnostic.Kind.ERROR, "problem writing file: " + ex);
  141.94 +        }
  141.95 +    }
  141.96 +
  141.97 +    String signature(TypeElement e) {
  141.98 +        System.err.println("signature: " + e + " " + e.getTypeParameters());
  141.99 +        StringBuilder sb = new StringBuilder();
 141.100 +        sb.append(e.getSimpleName());
 141.101 +        if (!e.getTypeParameters().isEmpty()) {
 141.102 +            sb.append("<");
 141.103 +            String sep = "";
 141.104 +            for (TypeParameterElement t : e.getTypeParameters()) {
 141.105 +                sb.append(sep);
 141.106 +                sb.append(t);
 141.107 +                sep = ",";
 141.108 +            }
 141.109 +            sb.append(">");
 141.110 +        }
 141.111 +        return sb.toString();
 141.112 +    }
 141.113 +}
 141.114 +
   142.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
   142.2 +++ b/test/tools/javac/processing/model/element/TestMissingElement2/TestMissingClass.java	Thu Mar 10 20:51:07 2011 -0800
   142.3 @@ -0,0 +1,38 @@
   142.4 +/*
   142.5 + * Copyright (c) 2011, Oracle and/or its affiliates. All rights reserved.
   142.6 + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
   142.7 + *
   142.8 + * This code is free software; you can redistribute it and/or modify it
   142.9 + * under the terms of the GNU General Public License version 2 only, as
  142.10 + * published by the Free Software Foundation.
  142.11 + *
  142.12 + * This code is distributed in the hope that it will be useful, but WITHOUT
  142.13 + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
  142.14 + * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
  142.15 + * version 2 for more details (a copy is included in the LICENSE file that
  142.16 + * accompanied this code).
  142.17 + *
  142.18 + * You should have received a copy of the GNU General Public License version
  142.19 + * 2 along with this work; if not, write to the Free Software Foundation,
  142.20 + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
  142.21 + *
  142.22 + * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
  142.23 + * or visit www.oracle.com if you need additional information or have any
  142.24 + * questions.
  142.25 + */
  142.26 +
  142.27 +/*
  142.28 + * @test
  142.29 + * @bug 6639645
  142.30 + * @summary Modeling type implementing missing interfaces
  142.31 + * @library ../../../../lib
  142.32 + * @build JavacTestingAbstractProcessor Generator
  142.33 + * @compile -XprintRounds -processor Generator TestMissingClass.java
  142.34 + * @run main TestMissingClass
  142.35 + */
  142.36 +
  142.37 +public class TestMissingClass extends MissingClass {
  142.38 +    public static void main(String... args) {
  142.39 +        new TestMissingClass().run();
  142.40 +    }
  142.41 +}
   143.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
   143.2 +++ b/test/tools/javac/processing/model/element/TestMissingElement2/TestMissingGenericClass1.java	Thu Mar 10 20:51:07 2011 -0800
   143.3 @@ -0,0 +1,39 @@
   143.4 +/*
   143.5 + * Copyright (c) 2011, Oracle and/or its affiliates. All rights reserved.
   143.6 + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
   143.7 + *
   143.8 + * This code is free software; you can redistribute it and/or modify it
   143.9 + * under the terms of the GNU General Public License version 2 only, as
  143.10 + * published by the Free Software Foundation.
  143.11 + *
  143.12 + * This code is distributed in the hope that it will be useful, but WITHOUT
  143.13 + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
  143.14 + * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
  143.15 + * version 2 for more details (a copy is included in the LICENSE file that
  143.16 + * accompanied this code).
  143.17 + *
  143.18 + * You should have received a copy of the GNU General Public License version
  143.19 + * 2 along with this work; if not, write to the Free Software Foundation,
  143.20 + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
  143.21 + *
  143.22 + * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
  143.23 + * or visit www.oracle.com if you need additional information or have any
  143.24 + * questions.
  143.25 + */
  143.26 +
  143.27 +/*
  143.28 + * @test
  143.29 + * @bug 6639645
  143.30 + * @summary Modeling type implementing missing interfaces
  143.31 + * @library ../../../../lib
  143.32 + * @clean MissingGenericClass1
  143.33 + * @build JavacTestingAbstractProcessor Generator
  143.34 + * @compile -XprintRounds -processor Generator TestMissingGenericClass1.java
  143.35 + * @run main TestMissingGenericClass1
  143.36 + */
  143.37 +
  143.38 +public class TestMissingGenericClass1 extends MissingGenericClass1<String> {
  143.39 +    public static void main(String... args) {
  143.40 +        new TestMissingGenericClass1().run();
  143.41 +    }
  143.42 +}
   144.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
   144.2 +++ b/test/tools/javac/processing/model/element/TestMissingElement2/TestMissingGenericClass2.java	Thu Mar 10 20:51:07 2011 -0800
   144.3 @@ -0,0 +1,39 @@
   144.4 +/*
   144.5 + * Copyright (c) 2011, Oracle and/or its affiliates. All rights reserved.
   144.6 + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
   144.7 + *
   144.8 + * This code is free software; you can redistribute it and/or modify it
   144.9 + * under the terms of the GNU General Public License version 2 only, as
  144.10 + * published by the Free Software Foundation.
  144.11 + *
  144.12 + * This code is distributed in the hope that it will be useful, but WITHOUT
  144.13 + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
  144.14 + * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
  144.15 + * version 2 for more details (a copy is included in the LICENSE file that
  144.16 + * accompanied this code).
  144.17 + *
  144.18 + * You should have received a copy of the GNU General Public License version
  144.19 + * 2 along with this work; if not, write to the Free Software Foundation,
  144.20 + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
  144.21 + *
  144.22 + * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
  144.23 + * or visit www.oracle.com if you need additional information or have any
  144.24 + * questions.
  144.25 + */
  144.26 +
  144.27 +/*
  144.28 + * @test
  144.29 + * @bug 6639645
  144.30 + * @summary Modeling type implementing missing interfaces
  144.31 + * @library ../../../../lib
  144.32 + * @clean MissingGenericClass2
  144.33 + * @build JavacTestingAbstractProcessor Generator
  144.34 + * @compile -XprintRounds -processor Generator TestMissingGenericClass2.java
  144.35 + * @run main TestMissingGenericClass2
  144.36 + */
  144.37 +
  144.38 +public class TestMissingGenericClass2 extends MissingGenericClass2<String,Integer> {
  144.39 +    public static void main(String... args) {
  144.40 +        new TestMissingGenericClass2().run();
  144.41 +    }
  144.42 +}
   145.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
   145.2 +++ b/test/tools/javac/processing/model/element/TestMissingElement2/TestMissingGenericInterface1.java	Thu Mar 10 20:51:07 2011 -0800
   145.3 @@ -0,0 +1,52 @@
   145.4 +/*
   145.5 + * Copyright (c) 2011, Oracle and/or its affiliates. All rights reserved.
   145.6 + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
   145.7 + *
   145.8 + * This code is free software; you can redistribute it and/or modify it
   145.9 + * under the terms of the GNU General Public License version 2 only, asrm
  145.10 + * published by the Free Software Foundation.
  145.11 + *
  145.12 + * This code is distributed in the hope that it will be useful, but WITHOUT
  145.13 + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
  145.14 + * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
  145.15 + * version 2 for more details (a copy is included in the LICENSE file that
  145.16 + * accompanied this code).
  145.17 + *
  145.18 + * You should have received a copy of the GNU General Public License version
  145.19 + * 2 along with this work; if not, write to the Free Software Foundation,
  145.20 + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
  145.21 + *
  145.22 + * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
  145.23 + * or visit www.oracle.com if you need additional information or have any
  145.24 + * questions.
  145.25 + */
  145.26 +
  145.27 +/*
  145.28 + * @test
  145.29 + * @bug 6639645
  145.30 + * @summary Modeling type implementing missing interfaces
  145.31 + * @library ../../../../lib
  145.32 + * @clean MissingGenericInterface1
  145.33 + * @build JavacTestingAbstractProcessor Generator
  145.34 + * @compile -XprintRounds -processor Generator TestMissingGenericInterface1.java
  145.35 + * @run main TestMissingGenericInterface1
  145.36 + */
  145.37 +
  145.38 +import java.util.*;
  145.39 +
  145.40 +public class TestMissingGenericInterface1 implements MissingGenericInterface1<String> {
  145.41 +    public static void main(String... args) {
  145.42 +        new TestMissingGenericInterface1().run();
  145.43 +    }
  145.44 +
  145.45 +    @Override
  145.46 +    public void run() {
  145.47 +        Class<?> c = getClass();
  145.48 +        System.out.println("class: " + c);
  145.49 +        System.out.println("superclass: " + c.getSuperclass());
  145.50 +        System.out.println("generic superclass: " +c.getGenericSuperclass());
  145.51 +        System.out.println("interfaces: " + Arrays.asList(c.getInterfaces()));
  145.52 +        System.out.println("generic interfaces: " + Arrays.asList(c.getGenericInterfaces()));
  145.53 +    }
  145.54 +
  145.55 +}
   146.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
   146.2 +++ b/test/tools/javac/processing/model/element/TestMissingElement2/TestMissingGenericInterface2.java	Thu Mar 10 20:51:07 2011 -0800
   146.3 @@ -0,0 +1,52 @@
   146.4 +/*
   146.5 + * Copyright (c) 2011, Oracle and/or its affiliates. All rights reserved.
   146.6 + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
   146.7 + *
   146.8 + * This code is free software; you can redistribute it and/or modify it
   146.9 + * under the terms of the GNU General Public License version 2 only, asrm
  146.10 + * published by the Free Software Foundation.
  146.11 + *
  146.12 + * This code is distributed in the hope that it will be useful, but WITHOUT
  146.13 + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
  146.14 + * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
  146.15 + * version 2 for more details (a copy is included in the LICENSE file that
  146.16 + * accompanied this code).
  146.17 + *
  146.18 + * You should have received a copy of the GNU General Public License version
  146.19 + * 2 along with this work; if not, write to the Free Software Foundation,
  146.20 + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
  146.21 + *
  146.22 + * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
  146.23 + * or visit www.oracle.com if you need additional information or have any
  146.24 + * questions.
  146.25 + */
  146.26 +
  146.27 +/*
  146.28 + * @test
  146.29 + * @bug 6639645
  146.30 + * @summary Modeling type implementing missing interfaces
  146.31 + * @library ../../../../lib
  146.32 + * @clean MissingGenericInterface2
  146.33 + * @build JavacTestingAbstractProcessor Generator
  146.34 + * @compile -XprintRounds -processor Generator TestMissingGenericInterface2.java
  146.35 + * @run main TestMissingGenericInterface2
  146.36 + */
  146.37 +
  146.38 +import java.util.*;
  146.39 +
  146.40 +public class TestMissingGenericInterface2 implements MissingGenericInterface2<Integer,String> {
  146.41 +    public static void main(String... args) {
  146.42 +        new TestMissingGenericInterface2().run();
  146.43 +    }
  146.44 +
  146.45 +    @Override
  146.46 +    public void run() {
  146.47 +        Class<?> c = getClass();
  146.48 +        System.out.println("class: " + c);
  146.49 +        System.out.println("superclass: " + c.getSuperclass());
  146.50 +        System.out.println("generic superclass: " +c.getGenericSuperclass());
  146.51 +        System.out.println("interfaces: " + Arrays.asList(c.getInterfaces()));
  146.52 +        System.out.println("generic interfaces: " + Arrays.asList(c.getGenericInterfaces()));
  146.53 +    }
  146.54 +
  146.55 +}
   147.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
   147.2 +++ b/test/tools/javac/processing/model/element/TestMissingElement2/TestMissingInterface.java	Thu Mar 10 20:51:07 2011 -0800
   147.3 @@ -0,0 +1,51 @@
   147.4 +/*
   147.5 + * Copyright (c) 2011, Oracle and/or its affiliates. All rights reserved.
   147.6 + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
   147.7 + *
   147.8 + * This code is free software; you can redistribute it and/or modify it
   147.9 + * under the terms of the GNU General Public License version 2 only, asrm
  147.10 + * published by the Free Software Foundation.
  147.11 + *
  147.12 + * This code is distributed in the hope that it will be useful, but WITHOUT
  147.13 + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
  147.14 + * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
  147.15 + * version 2 for more details (a copy is included in the LICENSE file that
  147.16 + * accompanied this code).
  147.17 + *
  147.18 + * You should have received a copy of the GNU General Public License version
  147.19 + * 2 along with this work; if not, write to the Free Software Foundation,
  147.20 + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
  147.21 + *
  147.22 + * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
  147.23 + * or visit www.oracle.com if you need additional information or have any
  147.24 + * questions.
  147.25 + */
  147.26 +
  147.27 +/*
  147.28 + * @test
  147.29 + * @bug 6639645
  147.30 + * @summary Modeling type implementing missing interfaces
  147.31 + * @library ../../../../lib
  147.32 + * @build JavacTestingAbstractProcessor Generator
  147.33 + * @compile -XprintRounds -processor Generator TestMissingInterface.java
  147.34 + * @run main TestMissingInterface
  147.35 + */
  147.36 +
  147.37 +import java.util.*;
  147.38 +
  147.39 +public class TestMissingInterface implements MissingInterface {
  147.40 +    public static void main(String... args) {
  147.41 +        new TestMissingInterface().run();
  147.42 +    }
  147.43 +
  147.44 +    @Override
  147.45 +    public void run() {
  147.46 +        Class<?> c = getClass();
  147.47 +        System.out.println("class: " + c);
  147.48 +        System.out.println("superclass: " + c.getSuperclass());
  147.49 +        System.out.println("generic superclass: " +c.getGenericSuperclass());
  147.50 +        System.out.println("interfaces: " + Arrays.asList(c.getInterfaces()));
  147.51 +        System.out.println("generic interfaces: " + Arrays.asList(c.getGenericInterfaces()));
  147.52 +    }
  147.53 +
  147.54 +}
   148.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
   148.2 +++ b/test/tools/javac/processing/warnings/UseImplicit/C1.java	Thu Mar 10 20:51:07 2011 -0800
   148.3 @@ -0,0 +1,24 @@
   148.4 +/*
   148.5 + * Copyright (c) 2011, Oracle and/or its affiliates. All rights reserved.
   148.6 + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
   148.7 + *
   148.8 + * This code is free software; you can redistribute it and/or modify it
   148.9 + * under the terms of the GNU General Public License version 2 only, as
  148.10 + * published by the Free Software Foundation.
  148.11 + *
  148.12 + * This code is distributed in the hope that it will be useful, but WITHOUT
  148.13 + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
  148.14 + * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
  148.15 + * version 2 for more details (a copy is included in the LICENSE file that
  148.16 + * accompanied this code).
  148.17 + *
  148.18 + * You should have received a copy of the GNU General Public License version
  148.19 + * 2 along with this work; if not, write to the Free Software Foundation,
  148.20 + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
  148.21 + *
  148.22 + * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
  148.23 + * or visit www.oracle.com if you need additional information or have any
  148.24 + * questions.
  148.25 + */
  148.26 +
  148.27 +class C1 extends p.C2 { }
   149.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
   149.2 +++ b/test/tools/javac/processing/warnings/UseImplicit/TestProcUseImplicitWarning.java	Thu Mar 10 20:51:07 2011 -0800
   149.3 @@ -0,0 +1,59 @@
   149.4 +/*
   149.5 + * Copyright (c) 2011, Oracle and/or its affiliates. All rights reserved.
   149.6 + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
   149.7 + *
   149.8 + * This code is free software; you can redistribute it and/or modify it
   149.9 + * under the terms of the GNU General Public License version 2 only, as
  149.10 + * published by the Free Software Foundation.
  149.11 + *
  149.12 + * This code is distributed in the hope that it will be useful, but WITHOUT
  149.13 + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
  149.14 + * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
  149.15 + * version 2 for more details (a copy is included in the LICENSE file that
  149.16 + * accompanied this code).
  149.17 + *
  149.18 + * You should have received a copy of the GNU General Public License version
  149.19 + * 2 along with this work; if not, write to the Free Software Foundation,
  149.20 + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
  149.21 + *
  149.22 + * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
  149.23 + * or visit www.oracle.com if you need additional information or have any
  149.24 + * questions.
  149.25 + */
  149.26 +
  149.27 +/*
  149.28 + * @test
  149.29 + * @bug 6986892
  149.30 + * @summary confusing warning given after errors in annotation processing
  149.31 + * @library ../../../lib
  149.32 + * @build JavacTestingAbstractProcessor TestProcUseImplicitWarning
  149.33 + * @clean C1 p.C2
  149.34 + * @compile/fail/ref=err.out -XDrawDiagnostics -processor TestProcUseImplicitWarning -Aerror C1.java
  149.35 + * @clean C1 p.C2
  149.36 + * @compile/ref=warn.out     -XDrawDiagnostics -processor TestProcUseImplicitWarning         C1.java
  149.37 + */
  149.38 +
  149.39 +import java.util.*;
  149.40 +import javax.annotation.processing.*;
  149.41 +import javax.lang.model.element.*;
  149.42 +import static javax.tools.Diagnostic.Kind.*;
  149.43 +
  149.44 +@SupportedOptions("error")
  149.45 +public class TestProcUseImplicitWarning extends JavacTestingAbstractProcessor {
  149.46 +
  149.47 +    int round = 0;
  149.48 +
  149.49 +    @Override
  149.50 +    public boolean process(Set<? extends TypeElement> annotations, RoundEnvironment roundEnv) {
  149.51 +        round++;
  149.52 +
  149.53 +        if (round == 1) {
  149.54 +            boolean error = options.containsKey("error");
  149.55 +            if (error)
  149.56 +                messager.printMessage(ERROR, "error generated per option");
  149.57 +        }
  149.58 +
  149.59 +        return false;
  149.60 +    }
  149.61 +
  149.62 +}
   150.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
   150.2 +++ b/test/tools/javac/processing/warnings/UseImplicit/err.out	Thu Mar 10 20:51:07 2011 -0800
   150.3 @@ -0,0 +1,2 @@
   150.4 +- compiler.err.proc.messager: error generated per option
   150.5 +1 error
   151.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
   151.2 +++ b/test/tools/javac/processing/warnings/UseImplicit/p/C2.java	Thu Mar 10 20:51:07 2011 -0800
   151.3 @@ -0,0 +1,26 @@
   151.4 +/*
   151.5 + * Copyright (c) 2011, Oracle and/or its affiliates. All rights reserved.
   151.6 + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
   151.7 + *
   151.8 + * This code is free software; you can redistribute it and/or modify it
   151.9 + * under the terms of the GNU General Public License version 2 only, as
  151.10 + * published by the Free Software Foundation.
  151.11 + *
  151.12 + * This code is distributed in the hope that it will be useful, but WITHOUT
  151.13 + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
  151.14 + * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
  151.15 + * version 2 for more details (a copy is included in the LICENSE file that
  151.16 + * accompanied this code).
  151.17 + *
  151.18 + * You should have received a copy of the GNU General Public License version
  151.19 + * 2 along with this work; if not, write to the Free Software Foundation,
  151.20 + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
  151.21 + *
  151.22 + * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
  151.23 + * or visit www.oracle.com if you need additional information or have any
  151.24 + * questions.
  151.25 + */
  151.26 +
  151.27 +package p;
  151.28 +
  151.29 +public class C2 { }
   152.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
   152.2 +++ b/test/tools/javac/processing/warnings/UseImplicit/warn.out	Thu Mar 10 20:51:07 2011 -0800
   152.3 @@ -0,0 +1,2 @@
   152.4 +- compiler.warn.proc.use.implicit
   152.5 +1 warning
   153.1 --- a/test/tools/javac/processing/warnings/gold_0.out	Thu Mar 10 17:11:19 2011 -0800
   153.2 +++ b/test/tools/javac/processing/warnings/gold_0.out	Thu Mar 10 20:51:07 2011 -0800
   153.3 @@ -1,1 +1,2 @@
   153.4  - compiler.warn.proc.messager: No SourceVersion option given
   153.5 +1 warning
   154.1 --- a/test/tools/javac/processing/warnings/gold_sv_warn_0_2.out	Thu Mar 10 17:11:19 2011 -0800
   154.2 +++ b/test/tools/javac/processing/warnings/gold_sv_warn_0_2.out	Thu Mar 10 20:51:07 2011 -0800
   154.3 @@ -1,1 +1,2 @@
   154.4  - compiler.warn.proc.processor.incompatible.source.version: RELEASE_0, TestSourceVersionWarnings, 1.2
   154.5 +1 warning
   155.1 --- a/test/tools/javac/processing/warnings/gold_sv_warn_2_3.out	Thu Mar 10 17:11:19 2011 -0800
   155.2 +++ b/test/tools/javac/processing/warnings/gold_sv_warn_2_3.out	Thu Mar 10 20:51:07 2011 -0800
   155.3 @@ -1,1 +1,2 @@
   155.4  - compiler.warn.proc.processor.incompatible.source.version: RELEASE_2, TestSourceVersionWarnings, 1.3
   155.5 +1 warning
   156.1 --- a/test/tools/javac/processing/warnings/gold_sv_warn_5_6.out	Thu Mar 10 17:11:19 2011 -0800
   156.2 +++ b/test/tools/javac/processing/warnings/gold_sv_warn_5_6.out	Thu Mar 10 20:51:07 2011 -0800
   156.3 @@ -1,1 +1,2 @@
   156.4  - compiler.warn.proc.processor.incompatible.source.version: RELEASE_5, TestSourceVersionWarnings, 1.6
   156.5 +1 warning
   157.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
   157.2 +++ b/test/tools/javac/util/context/T7021650.java	Thu Mar 10 20:51:07 2011 -0800
   157.3 @@ -0,0 +1,216 @@
   157.4 +/*
   157.5 + * Copyright (c) 2011, Oracle and/or its affiliates. All rights reserved.
   157.6 + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
   157.7 + *
   157.8 + * This code is free software; you can redistribute it and/or modify it
   157.9 + * under the terms of the GNU General Public License version 2 only, as
  157.10 + * published by the Free Software Foundation.
  157.11 + *
  157.12 + * This code is distributed in the hope that it will be useful, but WITHOUT
  157.13 + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
  157.14 + * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
  157.15 + * version 2 for more details (a copy is included in the LICENSE file that
  157.16 + * accompanied this code).
  157.17 + *
  157.18 + * You should have received a copy of the GNU General Public License version
  157.19 + * 2 along with this work; if not, write to the Free Software Foundation,
  157.20 + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
  157.21 + *
  157.22 + * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
  157.23 + * or visit www.oracle.com if you need additional information or have any
  157.24 + * questions.
  157.25 + */
  157.26 +
  157.27 +/**
  157.28 + * @test
  157.29 + * @bug 7021650
  157.30 + * @summary Fix Context issues
  157.31 + * @library ../../lib
  157.32 + * @build JavacTestingAbstractProcessor T7021650
  157.33 + * @run main T7021650
  157.34 + */
  157.35 +
  157.36 +import java.io.*;
  157.37 +import java.net.*;
  157.38 +import java.util.*;
  157.39 +import javax.annotation.processing.*;
  157.40 +import javax.lang.model.element.*;
  157.41 +import javax.tools.*;
  157.42 +
  157.43 +import com.sun.tools.javac.comp.Attr;
  157.44 +import com.sun.tools.javac.file.JavacFileManager;
  157.45 +import com.sun.tools.javac.main.Main;
  157.46 +import com.sun.tools.javac.processing.JavacProcessingEnvironment;
  157.47 +import com.sun.tools.javac.util.Context;
  157.48 +
  157.49 +public class T7021650 extends JavacTestingAbstractProcessor {
  157.50 +    public static void main(String... args) throws Exception {
  157.51 +        new T7021650().run();
  157.52 +    }
  157.53 +
  157.54 +    static File testSrc = new File(System.getProperty("test.src"));
  157.55 +    static final int MAX_ROUNDS = 3;
  157.56 +
  157.57 +    /**
  157.58 +     * Perform a compilation with custom factories registered in the context,
  157.59 +     * and verify that corresponding objects are created in each round.
  157.60 +     */
  157.61 +    void run() throws Exception {
  157.62 +        Counter demoCounter = new Counter();
  157.63 +        Counter myAttrCounter = new Counter();
  157.64 +
  157.65 +        Context context = new Context();
  157.66 +        // Use a custom file manager which creates classloaders for annotation
  157.67 +        // processors with a sensible delegation parent, so that all instances
  157.68 +        // of test classes come from the same class loader. This is important
  157.69 +        // because the test performs class checks on the instances of classes
  157.70 +        // found in the context for each round or processing.
  157.71 +        context.put(JavaFileManager.class, new Context.Factory<JavaFileManager>() {
  157.72 +            public JavaFileManager make(Context c) {
  157.73 +                return new JavacFileManager(c, true, null) {
  157.74 +                    @Override
  157.75 +                    protected ClassLoader getClassLoader(URL[] urls) {
  157.76 +                        return new URLClassLoader(urls, T7021650.class.getClassLoader());
  157.77 +                    }
  157.78 +                };
  157.79 +            }
  157.80 +        });
  157.81 +
  157.82 +        Demo.preRegister(context, demoCounter);
  157.83 +        MyAttr.preRegister(context, myAttrCounter);
  157.84 +
  157.85 +        String[] args = {
  157.86 +            "-d", ".",
  157.87 +            "-processor", T7021650.class.getName(),
  157.88 +            "-XprintRounds",
  157.89 +            new File(testSrc, T7021650.class.getName() + ".java").getPath()
  157.90 +        };
  157.91 +
  157.92 +        compile(context, args);
  157.93 +
  157.94 +        // Expect to create Demo for initial round, then MAX_ROUNDS in which
  157.95 +        // GenX files are generated, then standard final round of processing.
  157.96 +        checkEqual("demoCounter", demoCounter.count, MAX_ROUNDS + 2);
  157.97 +
  157.98 +        // Expect to create MyAttr for same processing rounds as for Demo,
  157.99 +        // plus additional context for final compilation.
 157.100 +        checkEqual("myAttrCounter", myAttrCounter.count, MAX_ROUNDS + 3);
 157.101 +    }
 157.102 +
 157.103 +    void compile(Context context, String... args) throws Exception {
 157.104 +        StringWriter sw = new StringWriter();
 157.105 +        PrintWriter pw = new PrintWriter(sw);
 157.106 +        Main m = new Main("javac", pw);
 157.107 +        int rc = m.compile(args, context);
 157.108 +        pw.close();
 157.109 +        String out = sw.toString();
 157.110 +        if (!out.isEmpty())
 157.111 +            System.err.println(out);
 157.112 +        if (rc != 0)
 157.113 +            throw new Exception("compilation failed unexpectedly: rc=" + rc);
 157.114 +    }
 157.115 +
 157.116 +    void checkEqual(String label, int found, int expect) throws Exception {
 157.117 +        if (found != expect)
 157.118 +            throw new Exception("unexpected value for " + label
 157.119 +                    + ": expected " + expect
 157.120 +                    + ": found " + found);
 157.121 +    }
 157.122 +
 157.123 +    //---------------
 157.124 +
 157.125 +    /*
 157.126 +     * A custom class unknown to javac but nonetheless registered in the context.
 157.127 +     */
 157.128 +    static class Demo {
 157.129 +        static void preRegister(Context context, final Counter counter) {
 157.130 +            context.put(Demo.class, new Context.Factory<Demo>() {
 157.131 +                public Demo make(Context c) {
 157.132 +                    counter.count++;
 157.133 +                    return new Demo(c);
 157.134 +                }
 157.135 +            });
 157.136 +        }
 157.137 +
 157.138 +        Demo(Context c) {
 157.139 +            c.put(Demo.class, this);
 157.140 +        }
 157.141 +
 157.142 +        static Demo instance(Context context) {
 157.143 +            return context.get(Demo.class);
 157.144 +        }
 157.145 +    }
 157.146 +
 157.147 +    /**
 157.148 +     * A custom version of a standard javac component.
 157.149 +     */
 157.150 +    static class MyAttr extends Attr {
 157.151 +        static void preRegister(Context context, final Counter counter) {
 157.152 +            context.put(attrKey, new Context.Factory<Attr>() {
 157.153 +                public Attr make(Context c) {
 157.154 +                    counter.count++;
 157.155 +                    return new MyAttr(c);
 157.156 +                }
 157.157 +            });
 157.158 +        }
 157.159 +
 157.160 +        MyAttr(Context c) {
 157.161 +            super(c);
 157.162 +        }
 157.163 +    }
 157.164 +
 157.165 +    static class Counter {
 157.166 +        int count;
 157.167 +    }
 157.168 +
 157.169 +    //---------------
 157.170 +
 157.171 +    int round = 0;
 157.172 +
 157.173 +    @Override
 157.174 +    public boolean process(Set<? extends TypeElement> annotations, RoundEnvironment roundEnv) {
 157.175 +        round++;
 157.176 +
 157.177 +        Context context = ((JavacProcessingEnvironment) processingEnv).getContext();
 157.178 +
 157.179 +        // verify items in context as expected
 157.180 +        check("Demo", Demo.instance(context), Demo.class);
 157.181 +        check("Attr", Attr.instance(context), MyAttr.class);
 157.182 +
 157.183 +        // For a few rounds, generate new source files, so that we can check whether
 157.184 +        // values in the context are correctly handled in subsequent processing rounds
 157.185 +        if (round <= MAX_ROUNDS) {
 157.186 +            String pkg = "p";
 157.187 +            String currClass = "Gen" + round;
 157.188 +            String curr = pkg + "." + currClass;
 157.189 +            String next = (pkg + ".Gen" + (round + 1));
 157.190 +            StringBuilder text = new StringBuilder();
 157.191 +            text.append("package ").append(pkg).append(";\n");
 157.192 +            text.append("public class ").append(currClass).append(" {\n");
 157.193 +            if (round < MAX_ROUNDS)
 157.194 +                text.append("    ").append(next).append(" x;\n");
 157.195 +            text.append("}\n");
 157.196 +
 157.197 +            try {
 157.198 +                JavaFileObject fo = filer.createSourceFile(curr);
 157.199 +                Writer out = fo.openWriter();
 157.200 +                try {
 157.201 +                    out.write(text.toString());
 157.202 +                } finally {
 157.203 +                    out.close();
 157.204 +                }
 157.205 +            } catch (IOException e) {
 157.206 +                throw new Error(e);
 157.207 +            }
 157.208 +        }
 157.209 +
 157.210 +        return true;
 157.211 +    }
 157.212 +
 157.213 +    void check(String label, Object o, Class<?> clazz) {
 157.214 +        if (o == null)
 157.215 +            throw new IllegalStateException(label + ": no item found");
 157.216 +        if (!clazz.isAssignableFrom(o.getClass()))
 157.217 +            throw new IllegalStateException(label + ": unexpected class: " + o.getClass());
 157.218 +    }
 157.219 +}
   158.1 --- a/test/tools/javac/varargs/6199075/T6199075.java	Thu Mar 10 17:11:19 2011 -0800
   158.2 +++ b/test/tools/javac/varargs/6199075/T6199075.java	Thu Mar 10 20:51:07 2011 -0800
   158.3 @@ -37,6 +37,7 @@
   158.4  import com.sun.tools.classfile.Code_attribute;
   158.5  import com.sun.tools.classfile.ConstantPool.*;
   158.6  import com.sun.tools.classfile.Method;
   158.7 +import com.sun.tools.javac.api.JavacTool;
   158.8  import com.sun.tools.javac.util.List;
   158.9  
  158.10  import java.io.File;
  158.11 @@ -47,6 +48,7 @@
  158.12  import javax.tools.JavaCompiler;
  158.13  import javax.tools.JavaFileObject;
  158.14  import javax.tools.SimpleJavaFileObject;
  158.15 +import javax.tools.StandardJavaFileManager;
  158.16  import javax.tools.ToolProvider;
  158.17  
  158.18  public class T6199075 {
  158.19 @@ -157,11 +159,14 @@
  158.20          System.out.println("Bytecode checks made: " + bytecodeCheckCount);
  158.21      }
  158.22  
  158.23 +    // Create a single file manager and reuse it for each compile to save time.
  158.24 +    StandardJavaFileManager fm = JavacTool.create().getStandardFileManager(null, null, null);
  158.25 +
  158.26      void compileAndCheck(VarargsMethod m1, VarargsMethod m2, TypeKind actual, ArgumentsArity argsArity) throws Exception {
  158.27          final JavaCompiler tool = ToolProvider.getSystemJavaCompiler();
  158.28          JavaSource source = new JavaSource(m1, m2, actual, argsArity);
  158.29          ErrorChecker ec = new ErrorChecker();
  158.30 -        JavacTask ct = (JavacTask)tool.getTask(null, null, ec,
  158.31 +        JavacTask ct = (JavacTask)tool.getTask(null, fm, ec,
  158.32                  null, null, Arrays.asList(source));
  158.33          ct.generate();
  158.34          check(source, ec, m1, m2, actual, argsArity);
   159.1 --- a/test/tools/javac/varargs/warning/Warn4.java	Thu Mar 10 17:11:19 2011 -0800
   159.2 +++ b/test/tools/javac/varargs/warning/Warn4.java	Thu Mar 10 20:51:07 2011 -0800
   159.3 @@ -29,6 +29,7 @@
   159.4   * @run main Warn4
   159.5   */
   159.6  import com.sun.source.util.JavacTask;
   159.7 +import com.sun.tools.javac.api.JavacTool;
   159.8  import java.net.URI;
   159.9  import java.util.Arrays;
  159.10  import java.util.Set;
  159.11 @@ -37,6 +38,7 @@
  159.12  import javax.tools.JavaCompiler;
  159.13  import javax.tools.JavaFileObject;
  159.14  import javax.tools.SimpleJavaFileObject;
  159.15 +import javax.tools.StandardJavaFileManager;
  159.16  import javax.tools.ToolProvider;
  159.17  
  159.18  public class Warn4 {
  159.19 @@ -187,12 +189,15 @@
  159.20          }
  159.21      }
  159.22  
  159.23 +    // Create a single file manager and reuse it for each compile to save time.
  159.24 +    static StandardJavaFileManager fm = JavacTool.create().getStandardFileManager(null, null, null);
  159.25 +
  159.26      static void test(SourceLevel sourceLevel, TrustMe trustMe, SuppressLevel suppressLevelClient,
  159.27              SuppressLevel suppressLevelDecl, ModifierKind modKind, Signature vararg_meth, Signature client_meth) throws Exception {
  159.28          final JavaCompiler tool = ToolProvider.getSystemJavaCompiler();
  159.29          JavaSource source = new JavaSource(trustMe, suppressLevelClient, suppressLevelDecl, modKind, vararg_meth, client_meth);
  159.30          DiagnosticChecker dc = new DiagnosticChecker();
  159.31 -        JavacTask ct = (JavacTask)tool.getTask(null, null, dc,
  159.32 +        JavacTask ct = (JavacTask)tool.getTask(null, fm, dc,
  159.33                  Arrays.asList("-Xlint:unchecked", "-source", sourceLevel.sourceKey),
  159.34                  null, Arrays.asList(source));
  159.35          ct.generate(); //to get mandatory notes
   160.1 --- a/test/tools/javac/varargs/warning/Warn5.java	Thu Mar 10 17:11:19 2011 -0800
   160.2 +++ b/test/tools/javac/varargs/warning/Warn5.java	Thu Mar 10 20:51:07 2011 -0800
   160.3 @@ -29,6 +29,7 @@
   160.4   * @run main Warn5
   160.5   */
   160.6  import com.sun.source.util.JavacTask;
   160.7 +import com.sun.tools.javac.api.JavacTool;
   160.8  import java.net.URI;
   160.9  import java.util.ArrayList;
  160.10  import java.util.Arrays;
  160.11 @@ -36,6 +37,7 @@
  160.12  import javax.tools.JavaCompiler;
  160.13  import javax.tools.JavaFileObject;
  160.14  import javax.tools.SimpleJavaFileObject;
  160.15 +import javax.tools.StandardJavaFileManager;
  160.16  import javax.tools.ToolProvider;
  160.17  
  160.18  public class Warn5 {
  160.19 @@ -207,12 +209,15 @@
  160.20          }
  160.21      }
  160.22  
  160.23 +    // Create a single file manager and reuse it for each compile to save time.
  160.24 +    static StandardJavaFileManager fm = JavacTool.create().getStandardFileManager(null, null, null);
  160.25 +
  160.26      static void test(SourceLevel sourceLevel, XlintOption xlint, TrustMe trustMe, SuppressLevel suppressLevel,
  160.27              ModifierKind modKind, MethodKind methKind, SignatureKind sig, BodyKind body) throws Exception {
  160.28          final JavaCompiler tool = ToolProvider.getSystemJavaCompiler();
  160.29          JavaSource source = new JavaSource(trustMe, suppressLevel, modKind, methKind, sig, body);
  160.30          DiagnosticChecker dc = new DiagnosticChecker();
  160.31 -        JavacTask ct = (JavacTask)tool.getTask(null, null, dc,
  160.32 +        JavacTask ct = (JavacTask)tool.getTask(null, fm, dc,
  160.33                  Arrays.asList(xlint.getXlintOption(), "-source", sourceLevel.sourceKey), null, Arrays.asList(source));
  160.34          ct.analyze();
  160.35          check(sourceLevel, dc, source, xlint, trustMe,
   161.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
   161.2 +++ b/test/tools/javadoc/6227454/Test.java	Thu Mar 10 20:51:07 2011 -0800
   161.3 @@ -0,0 +1,141 @@
   161.4 +/*
   161.5 + * Copyright (c) 2011, Oracle and/or its affiliates. All rights reserved.
   161.6 + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
   161.7 + *
   161.8 + * This code is free software; you can redistribute it and/or modify it
   161.9 + * under the terms of the GNU General Public License version 2 only, as
  161.10 + * published by the Free Software Foundation.
  161.11 + *
  161.12 + * This code is distributed in the hope that it will be useful, but WITHOUT
  161.13 + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
  161.14 + * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
  161.15 + * version 2 for more details (a copy is included in the LICENSE file that
  161.16 + * accompanied this code).
  161.17 + *
  161.18 + * You should have received a copy of the GNU General Public License version
  161.19 + * 2 along with this work; if not, write to the Free Software Foundation,
  161.20 + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
  161.21 + *
  161.22 + * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
  161.23 + * or visit www.oracle.com if you need additional information or have any
  161.24 + * questions.
  161.25 + */
  161.26 +
  161.27 +/*
  161.28 + * @test
  161.29 + * @bug 6227454
  161.30 + * @summary package.html and overview.html may not be read fully
  161.31 + */
  161.32 +
  161.33 +import java.io.*;
  161.34 +
  161.35 +import com.sun.javadoc.Doclet;
  161.36 +import com.sun.javadoc.RootDoc;
  161.37 +
  161.38 +public class Test extends Doclet {
  161.39 +    public static void main(String... args) throws Exception {
  161.40 +        new Test().run();
  161.41 +    }
  161.42 +
  161.43 +    void run() throws Exception {
  161.44 +        test("<html><body>ABC      XYZ</body></html>");
  161.45 +        test("<html><body>ABC      XYZ</BODY></html>");
  161.46 +        test("<html><BODY>ABC      XYZ</body></html>");
  161.47 +        test("<html><BODY>ABC      XYZ</BODY></html>");
  161.48 +        test("<html><BoDy>ABC      XYZ</bOdY></html>");
  161.49 +        test("<html>      ABC      XYZ</bOdY></html>", "Body tag missing from HTML");
  161.50 +        test("<html><body>ABC      XYZ       </html>", "Close body tag missing from HTML");
  161.51 +        test("<html>      ABC      XYZ       </html>", "Body tag missing from HTML");
  161.52 +        test("<html><body>ABC" + bigText(8192, 40) + "XYZ</body></html>");
  161.53 +
  161.54 +        if (errors > 0)
  161.55 +            throw new Exception(errors + " errors occurred");
  161.56 +    }
  161.57 +
  161.58 +    void test(String text) throws IOException {
  161.59 +        test(text, null);
  161.60 +    }
  161.61 +
  161.62 +    void test(String text, String expectError) throws IOException {
  161.63 +        testNum++;
  161.64 +        System.err.println("test " + testNum);
  161.65 +        File file = writeFile("overview" + testNum + ".html", text);
  161.66 +        String thisClassName = Test.class.getName();
  161.67 +        File testSrc = new File(System.getProperty("test.src"));
  161.68 +        String[] args = {
  161.69 +            "-bootclasspath",
  161.70 +                System.getProperty("java.class.path")
  161.71 +                + File.pathSeparator
  161.72 +                + System.getProperty("sun.boot.class.path"),
  161.73 +            "-classpath", ".",
  161.74 +            "-package",
  161.75 +            "-overview", file.getPath(),
  161.76 +            new File(testSrc, thisClassName + ".java").getPath()
  161.77 +        };
  161.78 +
  161.79 +        StringWriter sw = new StringWriter();
  161.80 +        PrintWriter pw = new PrintWriter(sw);
  161.81 +        int rc = com.sun.tools.javadoc.Main.execute(
  161.82 +                "javadoc",
  161.83 +                pw, pw, pw,
  161.84 +                thisClassName,
  161.85 +                args);
  161.86 +        pw.close();
  161.87 +        String out = sw.toString();
  161.88 +        if (!out.isEmpty())
  161.89 +            System.err.println(out);
  161.90 +        System.err.println("javadoc exit: rc=" + rc);
  161.91 +
  161.92 +        if (expectError == null) {
  161.93 +            if (rc != 0)
  161.94 +                error("unexpected exit from javadoc; rc:" + rc);
  161.95 +        } else {
  161.96 +            if (!out.contains(expectError))
  161.97 +                error("expected error text not found: " + expectError);
  161.98 +        }
  161.99 +    }
 161.100 +
 161.101 +    String bigText(int lines, int lineLength) {
 161.102 +        StringBuilder sb = new StringBuilder();
 161.103 +        for (int i = 0; i < lineLength; i++)
 161.104 +            sb.append(String.valueOf(i % 10));
 161.105 +        sb.append("\n");
 161.106 +        String line = sb.toString();
 161.107 +        sb.setLength(0);
 161.108 +        for (int i = 0; i < lines; i++)
 161.109 +            sb.append(line);
 161.110 +        return sb.toString();
 161.111 +    }
 161.112 +
 161.113 +    File writeFile(String path, String body) throws IOException {
 161.114 +        File f = new File(path);
 161.115 +        FileWriter out = new FileWriter(f);
 161.116 +        try {
 161.117 +            out.write(body);
 161.118 +        } finally {
 161.119 +            out.close();
 161.120 +        }
 161.121 +        return f;
 161.122 +    }
 161.123 +
 161.124 +    void error(String msg) {
 161.125 +        System.err.println("Error: " + msg);
 161.126 +        errors++;
 161.127 +    }
 161.128 +
 161.129 +    int testNum;
 161.130 +    int errors;
 161.131 +
 161.132 +    public static boolean start(RootDoc root) {
 161.133 +        String text = root.commentText();
 161.134 +        if (text.length() < 64)
 161.135 +            System.err.println("text: '" + text + "'");
 161.136 +        else
 161.137 +            System.err.println("text: '"
 161.138 +                    + text.substring(0, 20)
 161.139 +                    + "..."
 161.140 +                    + text.substring(text.length() - 20)
 161.141 +                    + "'");
 161.142 +        return text.startsWith("ABC") && text.endsWith("XYZ");
 161.143 +    }
 161.144 +}
   162.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
   162.2 +++ b/test/tools/javadoc/6964914/Error.java	Thu Mar 10 20:51:07 2011 -0800
   162.3 @@ -0,0 +1,26 @@
   162.4 +/*
   162.5 + * Copyright (c) 2010, 2011, Oracle and/or its affiliates. All rights reserved.
   162.6 + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
   162.7 + *
   162.8 + * This code is free software; you can redistribute it and/or modify it
   162.9 + * under the terms of the GNU General Public License version 2 only, as
  162.10 + * published by the Free Software Foundation.
  162.11 + *
  162.12 + * This code is distributed in the hope that it will be useful, but WITHOUT
  162.13 + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
  162.14 + * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
  162.15 + * version 2 for more details (a copy is included in the LICENSE file that
  162.16 + * accompanied this code).
  162.17 + *
  162.18 + * You should have received a copy of the GNU General Public License version
  162.19 + * 2 along with this work; if not, write to the Free Software Foundation,
  162.20 + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
  162.21 + *
  162.22 + * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
  162.23 + * or visit www.oracle.com if you need additional information or have any
  162.24 + * questions.
  162.25 + */
  162.26 +
  162.27 +public class Error {
  162.28 +    Object x // no semicolon
  162.29 +}
   163.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
   163.2 +++ b/test/tools/javadoc/6964914/JavacWarning.java	Thu Mar 10 20:51:07 2011 -0800
   163.3 @@ -0,0 +1,26 @@
   163.4 +/*
   163.5 + * Copyright (c) 2010, 2011, Oracle and/or its affiliates. All rights reserved.
   163.6 + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
   163.7 + *
   163.8 + * This code is free software; you can redistribute it and/or modify it
   163.9 + * under the terms of the GNU General Public License version 2 only, as
  163.10 + * published by the Free Software Foundation.
  163.11 + *
  163.12 + * This code is distributed in the hope that it will be useful, but WITHOUT
  163.13 + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
  163.14 + * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
  163.15 + * version 2 for more details (a copy is included in the LICENSE file that
  163.16 + * accompanied this code).
  163.17 + *
  163.18 + * You should have received a copy of the GNU General Public License version
  163.19 + * 2 along with this work; if not, write to the Free Software Foundation,
  163.20 + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
  163.21 + *
  163.22 + * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
  163.23 + * or visit www.oracle.com if you need additional information or have any
  163.24 + * questions.
  163.25 + */
  163.26 +
  163.27 +public class JavacWarning {
  163.28 +    int enum;  // warning in source 1.4
  163.29 +}
   164.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
   164.2 +++ b/test/tools/javadoc/6964914/JavadocWarning.java	Thu Mar 10 20:51:07 2011 -0800
   164.3 @@ -0,0 +1,27 @@
   164.4 +/*
   164.5 + * Copyright (c) 2010, 2011, Oracle and/or its affiliates. All rights reserved.
   164.6 + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
   164.7 + *
   164.8 + * This code is free software; you can redistribute it and/or modify it
   164.9 + * under the terms of the GNU General Public License version 2 only, as
  164.10 + * published by the Free Software Foundation.
  164.11 + *
  164.12 + * This code is distributed in the hope that it will be useful, but WITHOUT
  164.13 + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
  164.14 + * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
  164.15 + * version 2 for more details (a copy is included in the LICENSE file that
  164.16 + * accompanied this code).
  164.17 + *
  164.18 + * You should have received a copy of the GNU General Public License version
  164.19 + * 2 along with this work; if not, write to the Free Software Foundation,
  164.20 + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
  164.21 + *
  164.22 + * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
  164.23 + * or visit www.oracle.com if you need additional information or have any
  164.24 + * questions.
  164.25 + */
  164.26 +
  164.27 +public class JavadocWarning {
  164.28 +    /** @see DoesNotExist */
  164.29 +    int x;
  164.30 +}
   165.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
   165.2 +++ b/test/tools/javadoc/6964914/Test.java	Thu Mar 10 20:51:07 2011 -0800
   165.3 @@ -0,0 +1,78 @@
   165.4 +/*
   165.5 + * Copyright (c) 2010, 2011, Oracle and/or its affiliates. All rights reserved.
   165.6 + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
   165.7 + *
   165.8 + * This code is free software; you can redistribute it and/or modify it
   165.9 + * under the terms of the GNU General Public License version 2 only, as
  165.10 + * published by the Free Software Foundation.
  165.11 + *
  165.12 + * This code is distributed in the hope that it will be useful, but WITHOUT
  165.13 + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
  165.14 + * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
  165.15 + * version 2 for more details (a copy is included in the LICENSE file that
  165.16 + * accompanied this code).
  165.17 + *
  165.18 + * You should have received a copy of the GNU General Public License version
  165.19 + * 2 along with this work; if not, write to the Free Software Foundation,
  165.20 + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
  165.21 + *
  165.22 + * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
  165.23 + * or visit www.oracle.com if you need additional information or have any
  165.24 + * questions.
  165.25 + */
  165.26 +
  165.27 +/*
  165.28 + * @test
  165.29 + * @bug 6964914
  165.30 + * @summary javadoc does not output number of warnings using user written doclet
  165.31 + */
  165.32 +
  165.33 +import java.io.*;
  165.34 +
  165.35 +public class Test {
  165.36 +    public static void main(String... args) throws Exception {
  165.37 +        new Test().run();
  165.38 +    }
  165.39 +
  165.40 +    public void run() throws Exception {
  165.41 +        javadoc("Error.java", "1 error");
  165.42 +        javadoc("JavacWarning.java", "1 warning");
  165.43 +        javadoc("JavadocWarning.java", "1 warning");
  165.44 +        if (errors > 0)
  165.45 +            throw new Exception(errors + " errors found");
  165.46 +    }
  165.47 +
  165.48 +    void javadoc(String path, String expect) {
  165.49 +        File testSrc = new File(System.getProperty("test.src"));
  165.50 +        String[] args = {
  165.51 +            "-source", "1.4", // enables certain Parser warnings
  165.52 +            "-bootclasspath", System.getProperty("sun.boot.class.path"),
  165.53 +            "-classpath", ".",
  165.54 +            "-package",
  165.55 +            new File(testSrc, path).getPath()
  165.56 +        };
  165.57 +
  165.58 +        StringWriter sw = new StringWriter();
  165.59 +        PrintWriter pw = new PrintWriter(sw);
  165.60 +        int rc = com.sun.tools.javadoc.Main.execute(
  165.61 +                "javadoc",
  165.62 +                pw, pw, pw,
  165.63 +                com.sun.tools.doclets.standard.Standard.class.getName(),
  165.64 +                args);
  165.65 +        pw.close();
  165.66 +        String out = sw.toString();
  165.67 +        if (!out.isEmpty())
  165.68 +            System.err.println(out);
  165.69 +        System.err.println("javadoc exit: rc=" + rc);
  165.70 +
  165.71 +        if (!out.contains(expect))
  165.72 +            error("expected text not found: " + expect);
  165.73 +    }
  165.74 +
  165.75 +    void error(String msg) {
  165.76 +        System.err.println("Error: " + msg);
  165.77 +        errors++;
  165.78 +    }
  165.79 +
  165.80 +    int errors;
  165.81 +}
   166.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
   166.2 +++ b/test/tools/javadoc/6964914/TestStdDoclet.java	Thu Mar 10 20:51:07 2011 -0800
   166.3 @@ -0,0 +1,100 @@
   166.4 +/*
   166.5 + * Copyright (c) 2011, Oracle and/or its affiliates. All rights reserved.
   166.6 + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
   166.7 + *
   166.8 + * This code is free software; you can redistribute it and/or modify it
   166.9 + * under the terms of the GNU General Public License version 2 only, as
  166.10 + * published by the Free Software Foundation.
  166.11 + *
  166.12 + * This code is distributed in the hope that it will be useful, but WITHOUT
  166.13 + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
  166.14 + * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
  166.15 + * version 2 for more details (a copy is included in the LICENSE file that
  166.16 + * accompanied this code).
  166.17 + *
  166.18 + * You should have received a copy of the GNU General Public License version
  166.19 + * 2 along with this work; if not, write to the Free Software Foundation,
  166.20 + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
  166.21 + *
  166.22 + * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
  166.23 + * or visit www.oracle.com if you need additional information or have any
  166.24 + * questions.
  166.25 + */
  166.26 +
  166.27 +/*
  166.28 + * @test
  166.29 + * @bug 6964914
  166.30 + * @summary javadoc does not output number of warnings using user written doclet
  166.31 + */
  166.32 +
  166.33 +import java.io.*;
  166.34 +
  166.35 +/**
  166.36 + * Dummy javadoc comment.
  166.37 + * @author jjg
  166.38 + * @see DoesNotExist
  166.39 + */
  166.40 +public class TestStdDoclet {
  166.41 +    public static void main(String... args) throws Exception {
  166.42 +        new TestStdDoclet().run();
  166.43 +    }
  166.44 +
  166.45 +    /**
  166.46 +     * More dummy comments.
  166.47 +     * @throws DoesNotExist   oops, javadoc does not see this
  166.48 +     * @see DoesNotExist
  166.49 +     */
  166.50 +    void run() throws Exception {
  166.51 +        File javaHome = new File(System.getProperty("java.home"));
  166.52 +        if (javaHome.getName().equals("jre"))
  166.53 +            javaHome = javaHome.getParentFile();
  166.54 +        File javadoc = new File(new File(javaHome, "bin"), "javadoc");
  166.55 +        File testSrc = new File(System.getProperty("test.src"));
  166.56 +
  166.57 +        // run javadoc in separate process to ensure doclet executed under
  166.58 +        // normal user conditions w.r.t. classloader
  166.59 +        String thisClassName = TestStdDoclet.class.getName();
  166.60 +        Process p = new ProcessBuilder()
  166.61 +            .command(javadoc.getPath(),
  166.62 +                "-J-Xbootclasspath:" + System.getProperty("sun.boot.class.path"),
  166.63 +                "-package",
  166.64 +                new File(testSrc, thisClassName + ".java").getPath())
  166.65 +            .redirectErrorStream(true)
  166.66 +            .start();
  166.67 +
  166.68 +        int actualDocletWarnCount = 0;
  166.69 +        int reportedDocletWarnCount = 0;
  166.70 +        BufferedReader in = new BufferedReader(new InputStreamReader(p.getInputStream()));
  166.71 +        try {
  166.72 +            String line;
  166.73 +            while ((line = in.readLine()) != null) {
  166.74 +                System.err.println(line);
  166.75 +                if (line.contains("DoesNotExist"))
  166.76 +                    actualDocletWarnCount++;
  166.77 +                if (line.matches("[0-9]+ warning(s)?"))
  166.78 +                    reportedDocletWarnCount =
  166.79 +                            Integer.valueOf(line.substring(0, line.indexOf(" ")));
  166.80 +            }
  166.81 +        } finally {
  166.82 +            in.close();
  166.83 +        }
  166.84 +        int rc = p.waitFor();
  166.85 +        if (rc != 0)
  166.86 +            System.err.println("javadoc failed, rc:" + rc);
  166.87 +
  166.88 +        int expectedDocletWarnCount = 2;
  166.89 +        checkEqual("actual", actualDocletWarnCount, "expected", expectedDocletWarnCount);
  166.90 +        checkEqual("actual", actualDocletWarnCount, "reported", reportedDocletWarnCount);
  166.91 +    }
  166.92 +
  166.93 +    /**
  166.94 +     * Private method should not cause a warning.
  166.95 +     * @see DoesNotExist
  166.96 +     */
  166.97 +    private void checkEqual(String l1, int i1, String l2, int i2) throws Exception {
  166.98 +        if (i1 != i2)
  166.99 +            throw new Exception(l1 + " warn count, " + i1 + ", does not match "
 166.100 +                        + l2 + " warn count, " + i2);
 166.101 +    }
 166.102 +
 166.103 +}
   167.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
   167.2 +++ b/test/tools/javadoc/6964914/TestUserDoclet.java	Thu Mar 10 20:51:07 2011 -0800
   167.3 @@ -0,0 +1,99 @@
   167.4 +/*
   167.5 + * Copyright (c) 2011, Oracle and/or its affiliates. All rights reserved.
   167.6 + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
   167.7 + *
   167.8 + * This code is free software; you can redistribute it and/or modify it
   167.9 + * under the terms of the GNU General Public License version 2 only, as
  167.10 + * published by the Free Software Foundation.
  167.11 + *
  167.12 + * This code is distributed in the hope that it will be useful, but WITHOUT
  167.13 + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
  167.14 + * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
  167.15 + * version 2 for more details (a copy is included in the LICENSE file that
  167.16 + * accompanied this code).
  167.17 + *
  167.18 + * You should have received a copy of the GNU General Public License version
  167.19 + * 2 along with this work; if not, write to the Free Software Foundation,
  167.20 + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
  167.21 + *
  167.22 + * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
  167.23 + * or visit www.oracle.com if you need additional information or have any
  167.24 + * questions.
  167.25 + */
  167.26 +
  167.27 +/*
  167.28 + * @test
  167.29 + * @bug 6964914
  167.30 + * @summary javadoc does not output number of warnings using user written doclet
  167.31 + */
  167.32 +
  167.33 +import java.io.*;
  167.34 +import com.sun.javadoc.Doclet;
  167.35 +import com.sun.javadoc.RootDoc;
  167.36 +
  167.37 +public class TestUserDoclet extends Doclet {
  167.38 +    public static void main(String... args) throws Exception {
  167.39 +        new TestUserDoclet().run();
  167.40 +    }
  167.41 +
  167.42 +    static final String docletWarning = "warning from test doclet";
  167.43 +
  167.44 +    /** Main doclet method. */
  167.45 +    public static boolean start(RootDoc root) {
  167.46 +        root.printWarning(null, docletWarning);
  167.47 +        return true;
  167.48 +    }
  167.49 +
  167.50 +    /** Main test method. */
  167.51 +    void run() throws Exception {
  167.52 +        File javaHome = new File(System.getProperty("java.home"));
  167.53 +        if (javaHome.getName().equals("jre"))
  167.54 +            javaHome = javaHome.getParentFile();
  167.55 +        File javadoc = new File(new File(javaHome, "bin"), "javadoc");
  167.56 +        File testSrc = new File(System.getProperty("test.src"));
  167.57 +        File testClasses = new File(System.getProperty("test.classes"));
  167.58 +
  167.59 +        // run javadoc in separate process to ensure doclet executed under
  167.60 +        // normal user conditions w.r.t. classloader
  167.61 +        String thisClassName = TestUserDoclet.class.getName();
  167.62 +        Process p = new ProcessBuilder()
  167.63 +            .command(javadoc.getPath(),
  167.64 +                "-J-Xbootclasspath:" + System.getProperty("sun.boot.class.path"),
  167.65 +                "-doclet", thisClassName,
  167.66 +                "-docletpath", testClasses.getPath(),
  167.67 +                new File(testSrc, thisClassName + ".java").getPath())
  167.68 +            .redirectErrorStream(true)
  167.69 +            .start();
  167.70 +
  167.71 +        int actualDocletWarnCount = 0;
  167.72 +        int reportedDocletWarnCount = 0;
  167.73 +        BufferedReader in = new BufferedReader(new InputStreamReader(p.getInputStream()));
  167.74 +        try {
  167.75 +            String line;
  167.76 +            while ((line = in.readLine()) != null) {
  167.77 +                System.err.println(line);
  167.78 +                if (line.contains(docletWarning))
  167.79 +                    actualDocletWarnCount++;
  167.80 +                if (line.matches("[0-9]+ warning(s)?"))
  167.81 +                    reportedDocletWarnCount =
  167.82 +                            Integer.valueOf(line.substring(0, line.indexOf(" ")));
  167.83 +            }
  167.84 +        } finally {
  167.85 +            in.close();
  167.86 +        }
  167.87 +        int rc = p.waitFor();
  167.88 +        if (rc != 0)
  167.89 +            System.err.println("javadoc failed, rc:" + rc);
  167.90 +
  167.91 +        int expectedDocletWarnCount = 1;
  167.92 +        checkEqual("actual", actualDocletWarnCount, "expected", expectedDocletWarnCount);
  167.93 +        checkEqual("actual", actualDocletWarnCount, "reported", reportedDocletWarnCount);
  167.94 +    }
  167.95 +
  167.96 +    void checkEqual(String l1, int i1, String l2, int i2) throws Exception {
  167.97 +        if (i1 != i2)
  167.98 +            throw new Exception(l1 + " warn count, " + i1 + ", does not match "
  167.99 +                        + l2 + " warn count, " + i2);
 167.100 +    }
 167.101 +
 167.102 +}
   168.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
   168.2 +++ b/test/tools/javadoc/T6968833.java	Thu Mar 10 20:51:07 2011 -0800
   168.3 @@ -0,0 +1,56 @@
   168.4 +/*
   168.5 + * Copyright (c) 2002, 2011, Oracle and/or its affiliates. All rights reserved.
   168.6 + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
   168.7 + *
   168.8 + * This code is free software; you can redistribute it and/or modify it
   168.9 + * under the terms of the GNU General Public License version 2 only, as
  168.10 + * published by the Free Software Foundation.
  168.11 + *
  168.12 + * This code is distributed in the hope that it will be useful, but WITHOUT
  168.13 + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
  168.14 + * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
  168.15 + * version 2 for more details (a copy is included in the LICENSE file that
  168.16 + * accompanied this code).
  168.17 + *
  168.18 + * You should have received a copy of the GNU General Public License version
  168.19 + * 2 along with this work; if not, write to the Free Software Foundation,
  168.20 + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
  168.21 + *
  168.22 + * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
  168.23 + * or visit www.oracle.com if you need additional information or have any
  168.24 + * questions.
  168.25 + */
  168.26 +
  168.27 +/*
  168.28 + * @test
  168.29 + * @bug 6968833
  168.30 + * @summary javadoc reports error but still returns 0
  168.31 + */
  168.32 +
  168.33 +import java.io.*;
  168.34 +
  168.35 +public class T6968833 {
  168.36 +    public static void main(String... args) throws IOException {
  168.37 +        new T6968833().run();
  168.38 +    }
  168.39 +
  168.40 +    void run() throws IOException {
  168.41 +        File srcDir = new File("src");
  168.42 +        // following file causes error: No public or protected classes found to document.
  168.43 +        File f = writeFile(srcDir, "Foo.java", "class Foo { }");
  168.44 +        String[] args = { f.getPath() };
  168.45 +        int rc = com.sun.tools.javadoc.Main.execute(args);
  168.46 +        if (rc == 0)
  168.47 +            throw new Error("Unexpected exit from javadoc: " + rc);
  168.48 +    }
  168.49 +
  168.50 +    File writeFile(File dir, String path, String s) throws IOException {
  168.51 +        File f = new File(dir, path);
  168.52 +        f.getParentFile().mkdirs();
  168.53 +        try (Writer out = new FileWriter(f)) {
  168.54 +            out.write(s);
  168.55 +        }
  168.56 +        return f;
  168.57 +    }
  168.58 +}
  168.59 +

mercurial