Merge jdk8-b69

Fri, 14 Dec 2012 13:15:39 -0800

author
lana
date
Fri, 14 Dec 2012 13:15:39 -0800
changeset 1446
d7360bf35ee1
parent 1440
13ccb5269f3d
parent 1445
376d6c1b49e5
child 1447
2001991b1b40
child 1448
7d34e91f66bb
child 1462
573b38691a74

Merge

     1.1 --- a/src/share/classes/com/sun/tools/classfile/Opcode.java	Thu Dec 13 09:05:43 2012 -0800
     1.2 +++ b/src/share/classes/com/sun/tools/classfile/Opcode.java	Fri Dec 14 13:15:39 2012 -0800
     1.3 @@ -448,10 +448,10 @@
     1.4  
     1.5      }
     1.6  
     1.7 -    private static Opcode[] stdOpcodes = new Opcode[256];
     1.8 -    private static Opcode[] wideOpcodes = new Opcode[256];
     1.9 -    private static Opcode[] nonPrivOpcodes = new Opcode[256];
    1.10 -    private static Opcode[] privOpcodes = new Opcode[256];
    1.11 +    private static final Opcode[] stdOpcodes = new Opcode[256];
    1.12 +    private static final Opcode[] wideOpcodes = new Opcode[256];
    1.13 +    private static final Opcode[] nonPrivOpcodes = new Opcode[256];
    1.14 +    private static final Opcode[] privOpcodes = new Opcode[256];
    1.15      static {
    1.16          for (Opcode o: values())
    1.17              getOpcodeBlock(o.opcode >> 8)[o.opcode & 0xff] = o;
     2.1 --- a/src/share/classes/com/sun/tools/doclets/internal/toolkit/util/DocFileFactory.java	Thu Dec 13 09:05:43 2012 -0800
     2.2 +++ b/src/share/classes/com/sun/tools/doclets/internal/toolkit/util/DocFileFactory.java	Fri Dec 14 13:15:39 2012 -0800
     2.3 @@ -46,7 +46,7 @@
     2.4   * @since 1.8
     2.5   */
     2.6  abstract class DocFileFactory {
     2.7 -    private static Map<Configuration, DocFileFactory> factories =
     2.8 +    private static final Map<Configuration, DocFileFactory> factories =
     2.9              new WeakHashMap<Configuration, DocFileFactory>();
    2.10  
    2.11      /**
     3.1 --- a/src/share/classes/com/sun/tools/javac/Server.java	Thu Dec 13 09:05:43 2012 -0800
     3.2 +++ b/src/share/classes/com/sun/tools/javac/Server.java	Fri Dec 14 13:15:39 2012 -0800
     3.3 @@ -1,5 +1,5 @@
     3.4  /*
     3.5 - * Copyright (c) 2005, 2008, Oracle and/or its affiliates. All rights reserved.
     3.6 + * Copyright (c) 2005, 2012, 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 @@ -49,7 +49,7 @@
    3.11      private final OutputStream out;
    3.12      private final boolean isSocket;
    3.13      private static final JavaCompiler tool = ToolProvider.getSystemJavaCompiler();
    3.14 -    private static Logger logger = Logger.getLogger("com.sun.tools.javac");
    3.15 +    private static final Logger logger = Logger.getLogger("com.sun.tools.javac");
    3.16      static class CwdFileManager extends ForwardingJavaFileManager<JavaFileManager> {
    3.17          String cwd;
    3.18          CwdFileManager(JavaFileManager fileManager) {
    3.19 @@ -69,7 +69,7 @@
    3.20  //      }
    3.21      }
    3.22      // static CwdFileManager fm = new CwdFileManager(tool.getStandardFileManager());
    3.23 -    static StandardJavaFileManager fm = tool.getStandardFileManager(null, null, null);
    3.24 +    static final StandardJavaFileManager fm = tool.getStandardFileManager(null, null, null);
    3.25      static {
    3.26          // Use the same file manager for all compilations.  This will
    3.27          // cache jar files in the standard file manager.  Use
     4.1 --- a/src/share/classes/com/sun/tools/javac/code/Annotations.java	Thu Dec 13 09:05:43 2012 -0800
     4.2 +++ b/src/share/classes/com/sun/tools/javac/code/Annotations.java	Fri Dec 14 13:15:39 2012 -0800
     4.3 @@ -74,12 +74,12 @@
     4.4       */
     4.5      private List<Attribute.Compound> attributes = NOT_STARTED;
     4.6      /*
     4.7 -     * The Symbol this Annotatios belong to
     4.8 +     * The Symbol this Annotations belong to
     4.9       */
    4.10 -    private final Symbol s;
    4.11 +    private final Symbol sym;
    4.12  
    4.13 -    public Annotations(Symbol s) {
    4.14 -        this.s = s;
    4.15 +    public Annotations(Symbol sym) {
    4.16 +        this.sym = sym;
    4.17      }
    4.18  
    4.19      public List<Attribute.Compound> getAttributes() {
    4.20 @@ -102,7 +102,7 @@
    4.21      }
    4.22  
    4.23      public void setAttributesWithCompletion(final Annotate.AnnotateRepeatedContext ctx) {
    4.24 -        Assert.check(pendingCompletion() || (!isStarted() && s.kind == PCK));
    4.25 +        Assert.check(pendingCompletion() || (!isStarted() && sym.kind == PCK));
    4.26  
    4.27          Map<Symbol.TypeSymbol, ListBuffer<Attribute.Compound>> annotated = ctx.annotated;
    4.28          boolean atLeastOneRepeated = false;
    4.29 @@ -111,7 +111,7 @@
    4.30              if (lb.size() == 1) {
    4.31                  buf = buf.prepend(lb.first());
    4.32              } else { // repeated
    4.33 -                buf = buf.prepend(new Placeholder(lb.toList(), s));
    4.34 +                buf = buf.prepend(new Placeholder(lb.toList(), sym));
    4.35                  atLeastOneRepeated = true;
    4.36              }
    4.37          }
    4.38 @@ -141,7 +141,7 @@
    4.39  
    4.40                  @Override
    4.41                  public String toString() {
    4.42 -                    return "repeated annotation pass of: " + s + " in: " + s.owner;
    4.43 +                    return "repeated annotation pass of: " + sym + " in: " + sym.owner;
    4.44                  }
    4.45  
    4.46                  @Override
    4.47 @@ -253,7 +253,7 @@
    4.48  
    4.49          // Process repeated annotations
    4.50          Attribute.Compound validRepeated =
    4.51 -                ctx.processRepeatedAnnotations(placeholder.getPlaceholderFor());
    4.52 +            ctx.processRepeatedAnnotations(placeholder.getPlaceholderFor(), sym);
    4.53  
    4.54          if (validRepeated != null) {
    4.55              // Check that the container isn't manually
     5.1 --- a/src/share/classes/com/sun/tools/javac/code/Flags.java	Thu Dec 13 09:05:43 2012 -0800
     5.2 +++ b/src/share/classes/com/sun/tools/javac/code/Flags.java	Fri Dec 14 13:15:39 2012 -0800
     5.3 @@ -307,7 +307,7 @@
     5.4      }
     5.5  
     5.6      // Cache of modifier sets.
     5.7 -    private static Map<Long, Set<Modifier>> modifierSets =
     5.8 +    private static final Map<Long, Set<Modifier>> modifierSets =
     5.9          new java.util.concurrent.ConcurrentHashMap<Long, Set<Modifier>>(64);
    5.10  
    5.11      public static boolean isStatic(Symbol symbol) {
    5.12 @@ -356,7 +356,7 @@
    5.13          VARARGS("varargs"),
    5.14          PACKAGE("package");
    5.15  
    5.16 -        String name;
    5.17 +        private final String name;
    5.18  
    5.19          Flag(String name) {
    5.20              this.name = name;
     6.1 --- a/src/share/classes/com/sun/tools/javac/code/Kinds.java	Thu Dec 13 09:05:43 2012 -0800
     6.2 +++ b/src/share/classes/com/sun/tools/javac/code/Kinds.java	Fri Dec 14 13:15:39 2012 -0800
     6.3 @@ -110,7 +110,7 @@
     6.4          INSTANCE_INIT("kindname.instance.init"),
     6.5          PACKAGE("kindname.package");
     6.6  
     6.7 -        private String name;
     6.8 +        private final String name;
     6.9  
    6.10          KindName(String name) {
    6.11              this.name = name;
     7.1 --- a/src/share/classes/com/sun/tools/javac/code/Lint.java	Thu Dec 13 09:05:43 2012 -0800
     7.2 +++ b/src/share/classes/com/sun/tools/javac/code/Lint.java	Fri Dec 14 13:15:39 2012 -0800
     7.3 @@ -28,11 +28,14 @@
     7.4  import java.util.EnumSet;
     7.5  import java.util.HashMap;
     7.6  import java.util.Map;
     7.7 +import java.util.Set;
     7.8 +import javax.lang.model.element.Modifier;
     7.9  import com.sun.tools.javac.code.Symbol.*;
    7.10  import com.sun.tools.javac.util.Context;
    7.11  import com.sun.tools.javac.util.List;
    7.12  import com.sun.tools.javac.util.Options;
    7.13  import com.sun.tools.javac.util.Pair;
    7.14 +
    7.15  import static com.sun.tools.javac.code.Flags.*;
    7.16  
    7.17  
    7.18 @@ -95,7 +98,8 @@
    7.19      private final EnumSet<LintCategory> values;
    7.20      private final EnumSet<LintCategory> suppressedValues;
    7.21  
    7.22 -    private static Map<String, LintCategory> map = new HashMap<String,LintCategory>();
    7.23 +    private static final Map<String, LintCategory> map =
    7.24 +            new java.util.concurrent.ConcurrentHashMap<String, LintCategory>(20);
    7.25  
    7.26  
    7.27      protected Lint(Context context) {
     8.1 --- a/src/share/classes/com/sun/tools/javac/code/Source.java	Thu Dec 13 09:05:43 2012 -0800
     8.2 +++ b/src/share/classes/com/sun/tools/javac/code/Source.java	Fri Dec 14 13:15:39 2012 -0800
     8.3 @@ -87,7 +87,7 @@
     8.4  
     8.5      public final String name;
     8.6  
     8.7 -    private static Map<String,Source> tab = new HashMap<String,Source>();
     8.8 +    private static final Map<String,Source> tab = new HashMap<String,Source>();
     8.9      static {
    8.10          for (Source s : values()) {
    8.11              tab.put(s.name, s);
     9.1 --- a/src/share/classes/com/sun/tools/javac/code/TargetType.java	Thu Dec 13 09:05:43 2012 -0800
     9.2 +++ b/src/share/classes/com/sun/tools/javac/code/TargetType.java	Fri Dec 14 13:15:39 2012 -0800
     9.3 @@ -166,7 +166,7 @@
     9.4      static final int MAXIMUM_TARGET_TYPE_VALUE = 0x22;
     9.5  
     9.6      private final int targetTypeValue;
     9.7 -    private Set<TargetAttribute> flags;
     9.8 +    private final Set<TargetAttribute> flags;
     9.9  
    9.10      TargetType(int targetTypeValue, TargetAttribute... attributes) {
    9.11          if (targetTypeValue < Byte.MIN_VALUE
    9.12 @@ -233,10 +233,10 @@
    9.13          return this.targetTypeValue;
    9.14      }
    9.15  
    9.16 -    private static TargetType[] targets = null;
    9.17 +    private static final TargetType[] targets;
    9.18  
    9.19 -    private static TargetType[] buildTargets() {
    9.20 -        TargetType[] targets = new TargetType[MAXIMUM_TARGET_TYPE_VALUE + 1];
    9.21 +    static {
    9.22 +        targets = new TargetType[MAXIMUM_TARGET_TYPE_VALUE + 1];
    9.23          TargetType[] alltargets = values();
    9.24          for (TargetType target : alltargets) {
    9.25              if (target.targetTypeValue >= 0)
    9.26 @@ -246,13 +246,9 @@
    9.27              if (targets[i] == null)
    9.28                  targets[i] = UNKNOWN;
    9.29          }
    9.30 -        return targets;
    9.31      }
    9.32  
    9.33      public static boolean isValidTargetTypeValue(int tag) {
    9.34 -        if (targets == null)
    9.35 -            targets = buildTargets();
    9.36 -
    9.37          if (((byte)tag) == ((byte)UNKNOWN.targetTypeValue))
    9.38              return true;
    9.39  
    9.40 @@ -260,9 +256,6 @@
    9.41      }
    9.42  
    9.43      public static TargetType fromTargetTypeValue(int tag) {
    9.44 -        if (targets == null)
    9.45 -            targets = buildTargets();
    9.46 -
    9.47          if (((byte)tag) == ((byte)UNKNOWN.targetTypeValue))
    9.48              return UNKNOWN;
    9.49  
    10.1 --- a/src/share/classes/com/sun/tools/javac/code/TypeTag.java	Thu Dec 13 09:05:43 2012 -0800
    10.2 +++ b/src/share/classes/com/sun/tools/javac/code/TypeTag.java	Fri Dec 14 13:15:39 2012 -0800
    10.3 @@ -135,9 +135,11 @@
    10.4      /** This field will only be used for tags related with numeric types for
    10.5       *  optimization reasons.
    10.6       */
    10.7 -    private int order = 0;
    10.8 +    private final int order;
    10.9  
   10.10 -    private TypeTag() {}
   10.11 +    private TypeTag() {
   10.12 +        this(0);
   10.13 +    }
   10.14  
   10.15      private TypeTag(int order) {
   10.16          this.order = order;
    11.1 --- a/src/share/classes/com/sun/tools/javac/code/Types.java	Thu Dec 13 09:05:43 2012 -0800
    11.2 +++ b/src/share/classes/com/sun/tools/javac/code/Types.java	Fri Dec 14 13:15:39 2012 -0800
    11.3 @@ -2849,7 +2849,7 @@
    11.4          }
    11.5          return tvars1;
    11.6      }
    11.7 -    static private Mapping newInstanceFun = new Mapping("newInstanceFun") {
    11.8 +    private static final Mapping newInstanceFun = new Mapping("newInstanceFun") {
    11.9              public Type apply(Type t) { return new TypeVar(t.tsym, t.getUpperBound(), t.getLowerBound()); }
   11.10          };
   11.11      // </editor-fold>
    12.1 --- a/src/share/classes/com/sun/tools/javac/comp/Annotate.java	Thu Dec 13 09:05:43 2012 -0800
    12.2 +++ b/src/share/classes/com/sun/tools/javac/comp/Annotate.java	Fri Dec 14 13:15:39 2012 -0800
    12.3 @@ -26,7 +26,6 @@
    12.4  package com.sun.tools.javac.comp;
    12.5  
    12.6  import java.util.Map;
    12.7 -
    12.8  import com.sun.tools.javac.util.*;
    12.9  import com.sun.tools.javac.util.JCDiagnostic.DiagnosticPosition;
   12.10  import com.sun.tools.javac.code.*;
   12.11 @@ -171,8 +170,8 @@
   12.12           * @param repeatingAnnotations a List of repeating annotations
   12.13           * @return a new Attribute.Compound that is the container for the repeatingAnnotations
   12.14           */
   12.15 -        public Attribute.Compound processRepeatedAnnotations(List<Attribute.Compound> repeatingAnnotations) {
   12.16 -            return Annotate.this.processRepeatedAnnotations(repeatingAnnotations, this);
   12.17 +        public Attribute.Compound processRepeatedAnnotations(List<Attribute.Compound> repeatingAnnotations, Symbol sym) {
   12.18 +            return Annotate.this.processRepeatedAnnotations(repeatingAnnotations, this, sym);
   12.19          }
   12.20  
   12.21          /**
   12.22 @@ -339,10 +338,11 @@
   12.23       * annotation are invalid.  This method reports errors/warnings.
   12.24       */
   12.25      private Attribute.Compound processRepeatedAnnotations(List<Attribute.Compound> annotations,
   12.26 -            AnnotateRepeatedContext ctx) {
   12.27 +                                                          AnnotateRepeatedContext ctx,
   12.28 +                                                          Symbol on) {
   12.29          Attribute.Compound firstOccurrence = annotations.head;
   12.30          List<Attribute> repeated = List.nil();
   12.31 -        Type origAnnoType;
   12.32 +        Type origAnnoType = null;
   12.33          Type arrayOfOrigAnnoType = null;
   12.34          Type targetContainerType = null;
   12.35          MethodSymbol containerValueSymbol = null;
   12.36 @@ -390,6 +390,13 @@
   12.37                                                        new Attribute.Array(arrayOfOrigAnnoType, repeated));
   12.38              annoTree = m.Annotation(new Attribute.Compound(targetContainerType,
   12.39                      List.of(p)));
   12.40 +
   12.41 +            if (!chk.annotationApplicable(annoTree, on))
   12.42 +                log.error(annoTree.pos(), "invalid.containedby.annotation.incompatible.target", targetContainerType, origAnnoType);
   12.43 +
   12.44 +            if (!chk.validateAnnotationDeferErrors(annoTree))
   12.45 +                log.error(annoTree.pos(), "duplicate.annotation.invalid.repeated", origAnnoType);
   12.46 +
   12.47              Attribute.Compound c = enterAnnotation(annoTree,
   12.48                                                     targetContainerType,
   12.49                                                     ctx.env);
   12.50 @@ -410,7 +417,7 @@
   12.51          // annotation's declaration, or null if it has none
   12.52          Attribute.Compound ca = origAnnoDecl.attribute(syms.containedByType.tsym);
   12.53          if (ca == null) { // has no ContainedBy annotation
   12.54 -            log.error(pos, "duplicate.annotation.missing.container", origAnnoType);
   12.55 +            log.error(pos, "duplicate.annotation.missing.container", origAnnoType, syms.containedByType);
   12.56              return null;
   12.57          }
   12.58  
    13.1 --- a/src/share/classes/com/sun/tools/javac/comp/Check.java	Thu Dec 13 09:05:43 2012 -0800
    13.2 +++ b/src/share/classes/com/sun/tools/javac/comp/Check.java	Fri Dec 14 13:15:39 2012 -0800
    13.3 @@ -1833,13 +1833,15 @@
    13.4          for (Scope.Entry e1 = t1.tsym.members().elems; e1 != null; e1 = e1.sibling) {
    13.5              Symbol s1 = e1.sym;
    13.6              Type st1 = null;
    13.7 -            if (s1.kind != MTH || !s1.isInheritedIn(site.tsym, types)) continue;
    13.8 +            if (s1.kind != MTH || !s1.isInheritedIn(site.tsym, types) ||
    13.9 +                    (s1.flags() & SYNTHETIC) != 0) continue;
   13.10              Symbol impl = ((MethodSymbol)s1).implementation(site.tsym, types, false);
   13.11              if (impl != null && (impl.flags() & ABSTRACT) == 0) continue;
   13.12              for (Scope.Entry e2 = t2.tsym.members().lookup(s1.name); e2.scope != null; e2 = e2.next()) {
   13.13                  Symbol s2 = e2.sym;
   13.14                  if (s1 == s2) continue;
   13.15 -                if (s2.kind != MTH || !s2.isInheritedIn(site.tsym, types)) continue;
   13.16 +                if (s2.kind != MTH || !s2.isInheritedIn(site.tsym, types) ||
   13.17 +                        (s2.flags() & SYNTHETIC) != 0) continue;
   13.18                  if (st1 == null) st1 = types.memberType(t1, s1);
   13.19                  Type st2 = types.memberType(t2, s2);
   13.20                  if (types.overrideEquivalent(st1, st2)) {
   13.21 @@ -2890,39 +2892,54 @@
   13.22      }
   13.23  
   13.24      /** Check an annotation value.
   13.25 +     *
   13.26 +     * @param a The annotation tree to check
   13.27 +     * @return true if this annotation tree is valid, otherwise false
   13.28       */
   13.29 -    public void validateAnnotation(JCAnnotation a) {
   13.30 -        // collect an inventory of the members (sorted alphabetically)
   13.31 -        Set<MethodSymbol> members = new TreeSet<MethodSymbol>(new Comparator<Symbol>() {
   13.32 -            public int compare(Symbol t, Symbol t1) {
   13.33 -                return t.name.compareTo(t1.name);
   13.34 -            }
   13.35 -        });
   13.36 +    public boolean validateAnnotationDeferErrors(JCAnnotation a) {
   13.37 +        boolean res = false;
   13.38 +        final Log.DiagnosticHandler diagHandler = new Log.DiscardDiagnosticHandler(log);
   13.39 +        try {
   13.40 +            res = validateAnnotation(a);
   13.41 +        } finally {
   13.42 +            log.popDiagnosticHandler(diagHandler);
   13.43 +        }
   13.44 +        return res;
   13.45 +    }
   13.46 +
   13.47 +    private boolean validateAnnotation(JCAnnotation a) {
   13.48 +        boolean isValid = true;
   13.49 +        // collect an inventory of the annotation elements
   13.50 +        Set<MethodSymbol> members = new LinkedHashSet<MethodSymbol>();
   13.51          for (Scope.Entry e = a.annotationType.type.tsym.members().elems;
   13.52               e != null;
   13.53               e = e.sibling)
   13.54              if (e.sym.kind == MTH)
   13.55                  members.add((MethodSymbol) e.sym);
   13.56  
   13.57 -        // count them off as they're annotated
   13.58 +        // remove the ones that are assigned values
   13.59          for (JCTree arg : a.args) {
   13.60              if (!arg.hasTag(ASSIGN)) continue; // recovery
   13.61              JCAssign assign = (JCAssign) arg;
   13.62              Symbol m = TreeInfo.symbol(assign.lhs);
   13.63              if (m == null || m.type.isErroneous()) continue;
   13.64 -            if (!members.remove(m))
   13.65 +            if (!members.remove(m)) {
   13.66 +                isValid = false;
   13.67                  log.error(assign.lhs.pos(), "duplicate.annotation.member.value",
   13.68                            m.name, a.type);
   13.69 +            }
   13.70          }
   13.71  
   13.72          // all the remaining ones better have default values
   13.73 -        ListBuffer<Name> missingDefaults = ListBuffer.lb();
   13.74 +        List<Name> missingDefaults = List.nil();
   13.75          for (MethodSymbol m : members) {
   13.76              if (m.defaultValue == null && !m.type.isErroneous()) {
   13.77 -                missingDefaults.append(m.name);
   13.78 +                missingDefaults = missingDefaults.append(m.name);
   13.79              }
   13.80          }
   13.81 +        missingDefaults = missingDefaults.reverse();
   13.82          if (missingDefaults.nonEmpty()) {
   13.83 +            isValid = false;
   13.84              String key = (missingDefaults.size() > 1)
   13.85                      ? "annotation.missing.default.value.1"
   13.86                      : "annotation.missing.default.value";
   13.87 @@ -2933,21 +2950,23 @@
   13.88          // repeated values in its value member
   13.89          if (a.annotationType.type.tsym != syms.annotationTargetType.tsym ||
   13.90              a.args.tail == null)
   13.91 -            return;
   13.92 +            return isValid;
   13.93  
   13.94 -        if (!a.args.head.hasTag(ASSIGN)) return; // error recovery
   13.95 +        if (!a.args.head.hasTag(ASSIGN)) return false; // error recovery
   13.96          JCAssign assign = (JCAssign) a.args.head;
   13.97          Symbol m = TreeInfo.symbol(assign.lhs);
   13.98 -        if (m.name != names.value) return;
   13.99 +        if (m.name != names.value) return false;
  13.100          JCTree rhs = assign.rhs;
  13.101 -        if (!rhs.hasTag(NEWARRAY)) return;
  13.102 +        if (!rhs.hasTag(NEWARRAY)) return false;
  13.103          JCNewArray na = (JCNewArray) rhs;
  13.104          Set<Symbol> targets = new HashSet<Symbol>();
  13.105          for (JCTree elem : na.elems) {
  13.106              if (!targets.add(TreeInfo.symbol(elem))) {
  13.107 +                isValid = false;
  13.108                  log.error(elem.pos(), "repeated.annotation.target");
  13.109              }
  13.110          }
  13.111 +        return isValid;
  13.112      }
  13.113  
  13.114      void checkDeprecatedAnnotation(DiagnosticPosition pos, Symbol s) {
    14.1 --- a/src/share/classes/com/sun/tools/javac/comp/ConstFold.java	Thu Dec 13 09:05:43 2012 -0800
    14.2 +++ b/src/share/classes/com/sun/tools/javac/comp/ConstFold.java	Fri Dec 14 13:15:39 2012 -0800
    14.3 @@ -62,9 +62,9 @@
    14.4          syms = Symtab.instance(context);
    14.5      }
    14.6  
    14.7 -    static Integer minusOne = -1;
    14.8 -    static Integer zero     = 0;
    14.9 -    static Integer one      = 1;
   14.10 +    static final Integer minusOne = -1;
   14.11 +    static final Integer zero     = 0;
   14.12 +    static final Integer one      = 1;
   14.13  
   14.14     /** Convert boolean to integer (true = 1, false = 0).
   14.15      */
    15.1 --- a/src/share/classes/com/sun/tools/javac/comp/Flow.java	Thu Dec 13 09:05:43 2012 -0800
    15.2 +++ b/src/share/classes/com/sun/tools/javac/comp/Flow.java	Fri Dec 14 13:15:39 2012 -0800
    15.3 @@ -246,8 +246,8 @@
    15.4           */
    15.5          SPECULATIVE_LOOP("var.might.be.assigned.in.loop", true);
    15.6  
    15.7 -        String errKey;
    15.8 -        boolean isFinal;
    15.9 +        final String errKey;
   15.10 +        final boolean isFinal;
   15.11  
   15.12          FlowKind(String errKey, boolean isFinal) {
   15.13              this.errKey = errKey;
   15.14 @@ -295,7 +295,7 @@
   15.15                  }
   15.16              };
   15.17  
   15.18 -            JCTree.Tag treeTag;
   15.19 +            final JCTree.Tag treeTag;
   15.20  
   15.21              private JumpKind(Tag treeTag) {
   15.22                  this.treeTag = treeTag;
    16.1 --- a/src/share/classes/com/sun/tools/javac/comp/Resolve.java	Thu Dec 13 09:05:43 2012 -0800
    16.2 +++ b/src/share/classes/com/sun/tools/javac/comp/Resolve.java	Fri Dec 14 13:15:39 2012 -0800
    16.3 @@ -156,7 +156,7 @@
    16.4          OBJECT_INIT("object-init"),
    16.5          INTERNAL("internal");
    16.6  
    16.7 -        String opt;
    16.8 +        final String opt;
    16.9  
   16.10          private VerboseResolutionMode(String opt) {
   16.11              this.opt = opt;
   16.12 @@ -3381,8 +3381,8 @@
   16.13              }
   16.14          };
   16.15  
   16.16 -        boolean isBoxingRequired;
   16.17 -        boolean isVarargsRequired;
   16.18 +        final boolean isBoxingRequired;
   16.19 +        final boolean isVarargsRequired;
   16.20  
   16.21          MethodResolutionPhase(boolean isBoxingRequired, boolean isVarargsRequired) {
   16.22             this.isBoxingRequired = isBoxingRequired;
    17.1 --- a/src/share/classes/com/sun/tools/javac/file/ZipFileIndex.java	Thu Dec 13 09:05:43 2012 -0800
    17.2 +++ b/src/share/classes/com/sun/tools/javac/file/ZipFileIndex.java	Fri Dec 14 13:15:39 2012 -0800
    17.3 @@ -83,7 +83,7 @@
    17.4      public final static long NOT_MODIFIED = Long.MIN_VALUE;
    17.5  
    17.6  
    17.7 -    private static boolean NON_BATCH_MODE = System.getProperty("nonBatchMode") != null;// TODO: Use -XD compiler switch for this.
    17.8 +    private static final boolean NON_BATCH_MODE = System.getProperty("nonBatchMode") != null;// TODO: Use -XD compiler switch for this.
    17.9  
   17.10      private Map<RelativeDirectory, DirectoryEntry> directories =
   17.11              Collections.<RelativeDirectory, DirectoryEntry>emptyMap();
    18.1 --- a/src/share/classes/com/sun/tools/javac/jvm/ClassReader.java	Thu Dec 13 09:05:43 2012 -0800
    18.2 +++ b/src/share/classes/com/sun/tools/javac/jvm/ClassReader.java	Fri Dec 14 13:15:39 2012 -0800
    18.3 @@ -1360,6 +1360,16 @@
    18.4      void attachAnnotationDefault(final Symbol sym) {
    18.5          final MethodSymbol meth = (MethodSymbol)sym; // only on methods
    18.6          final Attribute value = readAttributeValue();
    18.7 +
    18.8 +        // The default value is set later during annotation. It might
    18.9 +        // be the case that the Symbol sym is annotated _after_ the
   18.10 +        // repeating instances that depend on this default value,
   18.11 +        // because of this we set an interim value that tells us this
   18.12 +        // element (most likely) has a default.
   18.13 +        //
   18.14 +        // Set interim value for now, reset just before we do this
   18.15 +        // properly at annotate time.
   18.16 +        meth.defaultValue = value;
   18.17          annotate.normal(new AnnotationDefaultCompleter(meth, value));
   18.18      }
   18.19  
   18.20 @@ -1680,6 +1690,9 @@
   18.21          public void enterAnnotation() {
   18.22              JavaFileObject previousClassFile = currentClassFile;
   18.23              try {
   18.24 +                // Reset the interim value set earlier in
   18.25 +                // attachAnnotationDefault().
   18.26 +                sym.defaultValue = null;
   18.27                  currentClassFile = classFile;
   18.28                  sym.defaultValue = deproxy(sym.type.getReturnType(), value);
   18.29              } finally {
    19.1 --- a/src/share/classes/com/sun/tools/javac/jvm/Code.java	Thu Dec 13 09:05:43 2012 -0800
    19.2 +++ b/src/share/classes/com/sun/tools/javac/jvm/Code.java	Fri Dec 14 13:15:39 2012 -0800
    19.3 @@ -1545,10 +1545,10 @@
    19.4      public void compressCatchTable() {
    19.5          ListBuffer<char[]> compressedCatchInfo = ListBuffer.lb();
    19.6          List<Integer> handlerPcs = List.nil();
    19.7 -        for (char[] catchEntry : catchInfo.elems) {
    19.8 +        for (char[] catchEntry : catchInfo) {
    19.9              handlerPcs = handlerPcs.prepend((int)catchEntry[2]);
   19.10          }
   19.11 -        for (char[] catchEntry : catchInfo.elems) {
   19.12 +        for (char[] catchEntry : catchInfo) {
   19.13              int startpc = catchEntry[0];
   19.14              int endpc = catchEntry[1];
   19.15              if (startpc == endpc ||
   19.16 @@ -1825,7 +1825,7 @@
   19.17          }
   19.18      }
   19.19  
   19.20 -    static Type jsrReturnValue = new Type(INT, null);
   19.21 +    static final Type jsrReturnValue = new Type(INT, null);
   19.22  
   19.23  
   19.24  /* **************************************************************************
    20.1 --- a/src/share/classes/com/sun/tools/javac/jvm/Target.java	Thu Dec 13 09:05:43 2012 -0800
    20.2 +++ b/src/share/classes/com/sun/tools/javac/jvm/Target.java	Fri Dec 14 13:15:39 2012 -0800
    20.3 @@ -86,17 +86,15 @@
    20.4          return instance;
    20.5      }
    20.6  
    20.7 -    private static Target MIN;
    20.8 +    private static final Target MIN = values()[0];
    20.9      public static Target MIN() { return MIN; }
   20.10  
   20.11 -    private static Target MAX;
   20.12 +    private static final Target MAX = values()[values().length - 1];
   20.13      public static Target MAX() { return MAX; }
   20.14  
   20.15 -    private static Map<String,Target> tab = new HashMap<String,Target>();
   20.16 +    private static final Map<String,Target> tab = new HashMap<String,Target>();
   20.17      static {
   20.18          for (Target t : values()) {
   20.19 -            if (MIN == null) MIN = t;
   20.20 -            MAX = t;
   20.21              tab.put(t.name, t);
   20.22          }
   20.23          tab.put("5", JDK1_5);
    21.1 --- a/src/share/classes/com/sun/tools/javac/main/JavaCompiler.java	Thu Dec 13 09:05:43 2012 -0800
    21.2 +++ b/src/share/classes/com/sun/tools/javac/main/JavaCompiler.java	Fri Dec 14 13:15:39 2012 -0800
    21.3 @@ -189,7 +189,7 @@
    21.4          }
    21.5      }
    21.6  
    21.7 -    private static CompilePolicy DEFAULT_COMPILE_POLICY = CompilePolicy.BY_TODO;
    21.8 +    private static final CompilePolicy DEFAULT_COMPILE_POLICY = CompilePolicy.BY_TODO;
    21.9  
   21.10      protected static enum ImplicitSourcePolicy {
   21.11          /** Don't generate or process implicitly read source files. */
   21.12 @@ -543,7 +543,7 @@
   21.13          public static CompileState max(CompileState a, CompileState b) {
   21.14              return a.value > b.value ? a : b;
   21.15          }
   21.16 -        private int value;
   21.17 +        private final int value;
   21.18      };
   21.19      /** Partial map to record which compiler phases have been executed
   21.20       * for each compilation unit. Used for ATTR and FLOW phases.
    22.1 --- a/src/share/classes/com/sun/tools/javac/main/Option.java	Thu Dec 13 09:05:43 2012 -0800
    22.2 +++ b/src/share/classes/com/sun/tools/javac/main/Option.java	Fri Dec 14 13:15:39 2012 -0800
    22.3 @@ -167,7 +167,6 @@
    22.4      ENCODING("-encoding", "opt.arg.encoding", "opt.encoding", STANDARD, FILEMANAGER) {
    22.5          @Override
    22.6          public boolean process(OptionHelper helper, String option, String operand) {
    22.7 -//            System.err.println("process encoding " + operand);
    22.8              return super.process(helper, option, operand);
    22.9          }
   22.10  
   22.11 @@ -246,9 +245,7 @@
   22.12          }
   22.13      },
   22.14  
   22.15 -    A("-A", "opt.arg.key.equals.value", "opt.A", STANDARD, BASIC) {
   22.16 -        { hasSuffix = true; }
   22.17 -
   22.18 +    A("-A", "opt.arg.key.equals.value", "opt.A", STANDARD, BASIC, true) {
   22.19          @Override
   22.20          public boolean matches(String arg) {
   22.21              return arg.startsWith("-A");
   22.22 @@ -293,8 +290,6 @@
   22.23      // This option exists only for the purpose of documenting itself.
   22.24      // It's actually implemented by the launcher.
   22.25      J("-J", "opt.arg.flag", "opt.J", STANDARD, INFO) {
   22.26 -        { hasSuffix = true; }
   22.27 -
   22.28          @Override
   22.29          public boolean process(OptionHelper helper, String option) {
   22.30              throw new AssertionError
   22.31 @@ -302,10 +297,6 @@
   22.32          }
   22.33      },
   22.34  
   22.35 -    // stop after parsing and attributing.
   22.36 -    // new HiddenOption("-attrparseonly"),
   22.37 -
   22.38 -    // new Option("-moreinfo",                                      "opt.moreinfo") {
   22.39      MOREINFO("-moreinfo", null, HIDDEN, BASIC) {
   22.40          @Override
   22.41          public boolean process(OptionHelper helper, String option) {
   22.42 @@ -317,23 +308,6 @@
   22.43      // treat warnings as errors
   22.44      WERROR("-Werror", "opt.Werror", STANDARD, BASIC),
   22.45  
   22.46 -//    // use complex inference from context in the position of a method call argument
   22.47 -//    COMPLEXINFERENCE("-complexinference", null, HIDDEN, BASIC),
   22.48 -
   22.49 -    // generare source stubs
   22.50 -    // new HiddenOption("-stubs"),
   22.51 -
   22.52 -    // relax some constraints to allow compiling from stubs
   22.53 -    // new HiddenOption("-relax"),
   22.54 -
   22.55 -    // output source after translating away inner classes
   22.56 -    // new Option("-printflat",                             "opt.printflat"),
   22.57 -    // new HiddenOption("-printflat"),
   22.58 -
   22.59 -    // display scope search details
   22.60 -    // new Option("-printsearch",                           "opt.printsearch"),
   22.61 -    // new HiddenOption("-printsearch"),
   22.62 -
   22.63      // prompt after each error
   22.64      // new Option("-prompt",                                        "opt.prompt"),
   22.65      PROMPT("-prompt", null, HIDDEN, BASIC),
   22.66 @@ -342,13 +316,8 @@
   22.67      DOE("-doe", null, HIDDEN, BASIC),
   22.68  
   22.69      // output source after type erasure
   22.70 -    // new Option("-s",                                     "opt.s"),
   22.71      PRINTSOURCE("-printsource", null, HIDDEN, BASIC),
   22.72  
   22.73 -    // output shrouded class files
   22.74 -    // new Option("-scramble",                              "opt.scramble"),
   22.75 -    // new Option("-scrambleall",                           "opt.scrambleall"),
   22.76 -
   22.77      // display warnings for generic unchecked operations
   22.78      WARNUNCHECKED("-warnunchecked", null, HIDDEN, BASIC) {
   22.79          @Override
   22.80 @@ -408,18 +377,16 @@
   22.81       * -XDx sets the option x to the value x.
   22.82       */
   22.83      XD("-XD", null, HIDDEN, BASIC) {
   22.84 -        String s;
   22.85          @Override
   22.86          public boolean matches(String s) {
   22.87 -            this.s = s;
   22.88              return s.startsWith(text);
   22.89          }
   22.90          @Override
   22.91          public boolean process(OptionHelper helper, String option) {
   22.92 -            s = s.substring(text.length());
   22.93 -            int eq = s.indexOf('=');
   22.94 -            String key = (eq < 0) ? s : s.substring(0, eq);
   22.95 -            String value = (eq < 0) ? s : s.substring(eq+1);
   22.96 +            option = option.substring(text.length());
   22.97 +            int eq = option.indexOf('=');
   22.98 +            String key = (eq < 0) ? option : option.substring(0, eq);
   22.99 +            String value = (eq < 0) ? option : option.substring(eq+1);
  22.100              helper.put(key, value);
  22.101              return false;
  22.102          }
  22.103 @@ -428,8 +395,6 @@
  22.104      // This option exists only for the purpose of documenting itself.
  22.105      // It's actually implemented by the CommandLine class.
  22.106      AT("@", "opt.arg.file", "opt.AT", STANDARD, INFO) {
  22.107 -        { hasSuffix = true; }
  22.108 -
  22.109          @Override
  22.110          public boolean process(OptionHelper helper, String option) {
  22.111              throw new AssertionError("the @ flag should be caught by CommandLine.");
  22.112 @@ -445,17 +410,15 @@
  22.113       * name to a separate list.
  22.114       */
  22.115      SOURCEFILE("sourcefile", null, HIDDEN, INFO) {
  22.116 -        String s;
  22.117          @Override
  22.118          public boolean matches(String s) {
  22.119 -            this.s = s;
  22.120              return s.endsWith(".java")  // Java source file
  22.121                  || SourceVersion.isName(s);   // Legal type name
  22.122          }
  22.123          @Override
  22.124          public boolean process(OptionHelper helper, String option) {
  22.125 -            if (s.endsWith(".java") ) {
  22.126 -                File f = new File(s);
  22.127 +            if (option.endsWith(".java") ) {
  22.128 +                File f = new File(option);
  22.129                  if (!f.exists()) {
  22.130                      helper.error("err.file.not.found", f);
  22.131                      return true;
  22.132 @@ -465,9 +428,9 @@
  22.133                      return true;
  22.134                  }
  22.135                  helper.addFile(f);
  22.136 +            } else {
  22.137 +                helper.addClassName(option);
  22.138              }
  22.139 -            else
  22.140 -                helper.addClassName(s);
  22.141              return false;
  22.142          }
  22.143      };
  22.144 @@ -521,7 +484,7 @@
  22.145  
  22.146      /** Suffix option (-foo=bar or -foo:bar)
  22.147       */
  22.148 -    boolean hasSuffix;
  22.149 +    final boolean hasSuffix;
  22.150  
  22.151      /** The kind of choices for this option, if any.
  22.152       */
  22.153 @@ -535,24 +498,30 @@
  22.154  
  22.155      Option(String text, String descrKey,
  22.156              OptionKind kind, OptionGroup group) {
  22.157 -        this(text, null, descrKey, kind, group, null, null);
  22.158 +        this(text, null, descrKey, kind, group, null, null, false);
  22.159      }
  22.160  
  22.161      Option(String text, String argsNameKey, String descrKey,
  22.162              OptionKind kind, OptionGroup group) {
  22.163 -        this(text, argsNameKey, descrKey, kind, group, null, null);
  22.164 +        this(text, argsNameKey, descrKey, kind, group, null, null, false);
  22.165 +    }
  22.166 +
  22.167 +    Option(String text, String argsNameKey, String descrKey,
  22.168 +            OptionKind kind, OptionGroup group, boolean doHasSuffix) {
  22.169 +        this(text, argsNameKey, descrKey, kind, group, null, null, doHasSuffix);
  22.170      }
  22.171  
  22.172      Option(String text, String descrKey,
  22.173              OptionKind kind, OptionGroup group,
  22.174              ChoiceKind choiceKind, Map<String,Boolean> choices) {
  22.175 -        this(text, null, descrKey, kind, group, choiceKind, choices);
  22.176 +        this(text, null, descrKey, kind, group, choiceKind, choices, false);
  22.177      }
  22.178  
  22.179      Option(String text, String descrKey,
  22.180              OptionKind kind, OptionGroup group,
  22.181              ChoiceKind choiceKind, String... choices) {
  22.182 -        this(text, null, descrKey, kind, group, choiceKind, createChoices(choices));
  22.183 +        this(text, null, descrKey, kind, group, choiceKind,
  22.184 +                createChoices(choices), false);
  22.185      }
  22.186      // where
  22.187          private static Map<String,Boolean> createChoices(String... choices) {
  22.188 @@ -564,7 +533,8 @@
  22.189  
  22.190      private Option(String text, String argsNameKey, String descrKey,
  22.191              OptionKind kind, OptionGroup group,
  22.192 -            ChoiceKind choiceKind, Map<String,Boolean> choices) {
  22.193 +            ChoiceKind choiceKind, Map<String,Boolean> choices,
  22.194 +            boolean doHasSuffix) {
  22.195          this.text = text;
  22.196          this.argsNameKey = argsNameKey;
  22.197          this.descrKey = descrKey;
  22.198 @@ -573,7 +543,7 @@
  22.199          this.choiceKind = choiceKind;
  22.200          this.choices = choices;
  22.201          char lastChar = text.charAt(text.length()-1);
  22.202 -        hasSuffix = lastChar == ':' || lastChar == '=';
  22.203 +        this.hasSuffix = doHasSuffix || lastChar == ':' || lastChar == '=';
  22.204      }
  22.205  
  22.206      public String getText() {
    23.1 --- a/src/share/classes/com/sun/tools/javac/parser/JavaTokenizer.java	Thu Dec 13 09:05:43 2012 -0800
    23.2 +++ b/src/share/classes/com/sun/tools/javac/parser/JavaTokenizer.java	Fri Dec 14 13:15:39 2012 -0800
    23.3 @@ -44,7 +44,7 @@
    23.4   */
    23.5  public class JavaTokenizer {
    23.6  
    23.7 -    private static boolean scannerDebug = false;
    23.8 +    private static final boolean scannerDebug = false;
    23.9  
   23.10      /** Allow hex floating-point literals.
   23.11       */
    24.1 --- a/src/share/classes/com/sun/tools/javac/parser/JavacParser.java	Thu Dec 13 09:05:43 2012 -0800
    24.2 +++ b/src/share/classes/com/sun/tools/javac/parser/JavacParser.java	Fri Dec 14 13:15:39 2012 -0800
    24.3 @@ -818,9 +818,7 @@
    24.4       *                  | "*" | "/" | "%"
    24.5       */
    24.6      JCExpression term2Rest(JCExpression t, int minprec) {
    24.7 -        List<JCExpression[]> savedOd = odStackSupply.elems;
    24.8          JCExpression[] odStack = newOdStack();
    24.9 -        List<Token[]> savedOp = opStackSupply.elems;
   24.10          Token[] opStack = newOpStack();
   24.11  
   24.12          // optimization, was odStack = new Tree[...]; opStack = new Tree[...];
   24.13 @@ -851,8 +849,8 @@
   24.14              }
   24.15          }
   24.16  
   24.17 -        odStackSupply.elems = savedOd; // optimization
   24.18 -        opStackSupply.elems = savedOp; // optimization
   24.19 +        odStackSupply.add(odStack);
   24.20 +        opStackSupply.add(opStack);
   24.21          return t;
   24.22      }
   24.23  //where
   24.24 @@ -906,23 +904,19 @@
   24.25          /** optimization: To save allocating a new operand/operator stack
   24.26           *  for every binary operation, we use supplys.
   24.27           */
   24.28 -        ListBuffer<JCExpression[]> odStackSupply = new ListBuffer<JCExpression[]>();
   24.29 -        ListBuffer<Token[]> opStackSupply = new ListBuffer<Token[]>();
   24.30 +        ArrayList<JCExpression[]> odStackSupply = new ArrayList<JCExpression[]>();
   24.31 +        ArrayList<Token[]> opStackSupply = new ArrayList<Token[]>();
   24.32  
   24.33          private JCExpression[] newOdStack() {
   24.34 -            if (odStackSupply.elems == odStackSupply.last)
   24.35 -                odStackSupply.append(new JCExpression[infixPrecedenceLevels + 1]);
   24.36 -            JCExpression[] odStack = odStackSupply.elems.head;
   24.37 -            odStackSupply.elems = odStackSupply.elems.tail;
   24.38 -            return odStack;
   24.39 +            if (odStackSupply.isEmpty())
   24.40 +                return new JCExpression[infixPrecedenceLevels + 1];
   24.41 +            return odStackSupply.remove(odStackSupply.size() - 1);
   24.42          }
   24.43  
   24.44          private Token[] newOpStack() {
   24.45 -            if (opStackSupply.elems == opStackSupply.last)
   24.46 -                opStackSupply.append(new Token[infixPrecedenceLevels + 1]);
   24.47 -            Token[] opStack = opStackSupply.elems.head;
   24.48 -            opStackSupply.elems = opStackSupply.elems.tail;
   24.49 -            return opStack;
   24.50 +            if (opStackSupply.isEmpty())
   24.51 +                return new Token[infixPrecedenceLevels + 1];
   24.52 +            return opStackSupply.remove(opStackSupply.size() - 1);
   24.53          }
   24.54  
   24.55      /**
   24.56 @@ -2001,7 +1995,7 @@
   24.57                  ListBuffer<JCStatement> stats =
   24.58                          variableDeclarators(mods, t, new ListBuffer<JCStatement>());
   24.59                  // A "LocalVariableDeclarationStatement" subsumes the terminating semicolon
   24.60 -                storeEnd(stats.elems.last(), token.endPos);
   24.61 +                storeEnd(stats.last(), token.endPos);
   24.62                  accept(SEMI);
   24.63                  return stats.toList();
   24.64              }
   24.65 @@ -2042,7 +2036,7 @@
   24.66                  ListBuffer<JCStatement> stats =
   24.67                          variableDeclarators(mods, t, new ListBuffer<JCStatement>());
   24.68                  // A "LocalVariableDeclarationStatement" subsumes the terminating semicolon
   24.69 -                storeEnd(stats.elems.last(), token.endPos);
   24.70 +                storeEnd(stats.last(), token.endPos);
   24.71                  accept(SEMI);
   24.72                  return stats.toList();
   24.73              } else {
   24.74 @@ -2577,7 +2571,7 @@
   24.75          vdefs.append(variableDeclaratorRest(pos, mods, type, name, reqInit, dc));
   24.76          while (token.kind == COMMA) {
   24.77              // All but last of multiple declarators subsume a comma
   24.78 -            storeEnd((JCTree)vdefs.elems.last(), token.endPos);
   24.79 +            storeEnd((JCTree)vdefs.last(), token.endPos);
   24.80              nextToken();
   24.81              vdefs.append(variableDeclarator(mods, type, reqInit, dc));
   24.82          }
   24.83 @@ -2632,7 +2626,7 @@
   24.84          defs.append(resource());
   24.85          while (token.kind == SEMI) {
   24.86              // All but last of multiple declarators must subsume a semicolon
   24.87 -            storeEnd(defs.elems.last(), token.endPos);
   24.88 +            storeEnd(defs.last(), token.endPos);
   24.89              int semiColonPos = token.pos;
   24.90              nextToken();
   24.91              if (token.kind == RPAREN) { // Optional trailing semicolon
   24.92 @@ -2710,7 +2704,7 @@
   24.93          JCTree.JCCompilationUnit toplevel = F.at(firstToken.pos).TopLevel(packageAnnotations, pid, defs.toList());
   24.94          if (!consumedToplevelDoc)
   24.95              attach(toplevel, firstToken.comment(CommentStyle.JAVADOC));
   24.96 -        if (defs.elems.isEmpty())
   24.97 +        if (defs.isEmpty())
   24.98              storeEnd(toplevel, S.prevToken().endPos);
   24.99          if (keepDocComments)
  24.100              toplevel.docComments = docComments;
    25.1 --- a/src/share/classes/com/sun/tools/javac/processing/JavacProcessingEnvironment.java	Thu Dec 13 09:05:43 2012 -0800
    25.2 +++ b/src/share/classes/com/sun/tools/javac/processing/JavacProcessingEnvironment.java	Fri Dec 14 13:15:39 2012 -0800
    25.3 @@ -1336,7 +1336,7 @@
    25.4          return nodes;
    25.5      }
    25.6  
    25.7 -    private static TreeScanner treeCleaner = new TreeScanner() {
    25.8 +    private static final TreeScanner treeCleaner = new TreeScanner() {
    25.9              public void scan(JCTree node) {
   25.10                  super.scan(node);
   25.11                  if (node != null)
    26.1 --- a/src/share/classes/com/sun/tools/javac/resources/compiler.properties	Thu Dec 13 09:05:43 2012 -0800
    26.2 +++ b/src/share/classes/com/sun/tools/javac/resources/compiler.properties	Fri Dec 14 13:15:39 2012 -0800
    26.3 @@ -307,13 +307,17 @@
    26.4  compiler.err.duplicate.annotation=\
    26.5      duplicate annotation
    26.6  
    26.7 +# 0: type
    26.8 +compiler.err.duplicate.annotation.invalid.repeated=\
    26.9 +    annotation {0} cannot be repeated\nIt does not define a valid containing annotation.
   26.10 +
   26.11  # 0: name, 1: type
   26.12  compiler.err.duplicate.annotation.member.value=\
   26.13      duplicate annotation member value {0} in {1}
   26.14  
   26.15 -# 0: type
   26.16 +# 0: type, 1: type
   26.17  compiler.err.duplicate.annotation.missing.container=\
   26.18 -    duplicate annotation, the declaration of {0} does not have a ContainedBy annotation
   26.19 +    duplicate annotation, the declaration of {0} does not have a valid {1} annotation
   26.20  
   26.21  # 0: type, 1: type
   26.22  compiler.err.invalid.container.no.containedby=\
    27.1 --- a/src/share/classes/com/sun/tools/javac/tree/JCTree.java	Thu Dec 13 09:05:43 2012 -0800
    27.2 +++ b/src/share/classes/com/sun/tools/javac/tree/JCTree.java	Fri Dec 14 13:15:39 2012 -0800
    27.3 @@ -340,15 +340,17 @@
    27.4           */
    27.5          LETEXPR;                         // ala scheme
    27.6  
    27.7 -        private Tag noAssignTag;
    27.8 +        private final Tag noAssignTag;
    27.9  
   27.10 -        private static int numberOfOperators = MOD.ordinal() - POS.ordinal() + 1;
   27.11 +        private static final int numberOfOperators = MOD.ordinal() - POS.ordinal() + 1;
   27.12  
   27.13          private Tag(Tag noAssignTag) {
   27.14              this.noAssignTag = noAssignTag;
   27.15          }
   27.16  
   27.17 -        private Tag() { }
   27.18 +        private Tag() {
   27.19 +            this(null);
   27.20 +        }
   27.21  
   27.22          public static int getNumberOfOperators() {
   27.23              return numberOfOperators;
   27.24 @@ -1838,8 +1840,8 @@
   27.25              /** Toplevel # new */
   27.26              TOPLEVEL(ReferenceMode.NEW, false);
   27.27  
   27.28 -            ReferenceMode mode;
   27.29 -            boolean unbound;
   27.30 +            final ReferenceMode mode;
   27.31 +            final boolean unbound;
   27.32  
   27.33              private ReferenceKind(ReferenceMode mode, boolean unbound) {
   27.34                  this.mode = mode;
    28.1 --- a/src/share/classes/com/sun/tools/javac/util/BaseFileManager.java	Thu Dec 13 09:05:43 2012 -0800
    28.2 +++ b/src/share/classes/com/sun/tools/javac/util/BaseFileManager.java	Fri Dec 14 13:15:39 2012 -0800
    28.3 @@ -1,5 +1,5 @@
    28.4  /*
    28.5 - * Copyright (c) 2009, 2011, Oracle and/or its affiliates. All rights reserved.
    28.6 + * Copyright (c) 2009, 2012, Oracle and/or its affiliates. All rights reserved.
    28.7   * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
    28.8   *
    28.9   * This code is free software; you can redistribute it and/or modify it
   28.10 @@ -181,7 +181,7 @@
   28.11          return false;
   28.12      }
   28.13      // where
   28.14 -        private static Set<Option> javacFileManagerOptions =
   28.15 +        private static final Set<Option> javacFileManagerOptions =
   28.16              Option.getJavacFileManagerOptions();
   28.17  
   28.18      public int isSupportedOption(String option) {
    29.1 --- a/src/share/classes/com/sun/tools/javac/util/List.java	Thu Dec 13 09:05:43 2012 -0800
    29.2 +++ b/src/share/classes/com/sun/tools/javac/util/List.java	Fri Dec 14 13:15:39 2012 -0800
    29.3 @@ -74,7 +74,7 @@
    29.4          return (List<A>)EMPTY_LIST;
    29.5      }
    29.6  
    29.7 -    private static List<?> EMPTY_LIST = new List<Object>(null,null) {
    29.8 +    private static final List<?> EMPTY_LIST = new List<Object>(null,null) {
    29.9          public List<Object> setTail(List<Object> tail) {
   29.10              throw new UnsupportedOperationException();
   29.11          }
   29.12 @@ -391,7 +391,7 @@
   29.13          return (List<T>)list;
   29.14      }
   29.15  
   29.16 -    private static Iterator<?> EMPTYITERATOR = new Iterator<Object>() {
   29.17 +    private static final Iterator<?> EMPTYITERATOR = new Iterator<Object>() {
   29.18              public boolean hasNext() {
   29.19                  return false;
   29.20              }
    30.1 --- a/src/share/classes/com/sun/tools/javac/util/ListBuffer.java	Thu Dec 13 09:05:43 2012 -0800
    30.2 +++ b/src/share/classes/com/sun/tools/javac/util/ListBuffer.java	Fri Dec 14 13:15:39 2012 -0800
    30.3 @@ -1,5 +1,5 @@
    30.4  /*
    30.5 - * Copyright (c) 1999, 2008, Oracle and/or its affiliates. All rights reserved.
    30.6 + * Copyright (c) 1999, 2012, Oracle and/or its affiliates. All rights reserved.
    30.7   * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
    30.8   *
    30.9   * This code is free software; you can redistribute it and/or modify it
   30.10 @@ -52,19 +52,20 @@
   30.11  
   30.12      /** The list of elements of this buffer.
   30.13       */
   30.14 -    public List<A> elems;
   30.15 +    private List<A> elems;
   30.16  
   30.17 -    /** A pointer pointing to the last, sentinel element of `elems'.
   30.18 +    /** A pointer pointing to the last element of 'elems' containing data,
   30.19 +     *  or null if the list is empty.
   30.20       */
   30.21 -    public List<A> last;
   30.22 +    private List<A> last;
   30.23  
   30.24      /** The number of element in this buffer.
   30.25       */
   30.26 -    public int count;
   30.27 +    private int count;
   30.28  
   30.29      /** Has a list been created from this buffer yet?
   30.30       */
   30.31 -    public boolean shared;
   30.32 +    private boolean shared;
   30.33  
   30.34      /** Create a new initially empty list buffer.
   30.35       */
   30.36 @@ -73,8 +74,8 @@
   30.37      }
   30.38  
   30.39      public final void clear() {
   30.40 -        this.elems = new List<A>(null,null);
   30.41 -        this.last = this.elems;
   30.42 +        this.elems = List.nil();
   30.43 +        this.last = null;
   30.44          count = 0;
   30.45          shared = false;
   30.46      }
   30.47 @@ -103,22 +104,23 @@
   30.48      /** Copy list and sets last.
   30.49       */
   30.50      private void copy() {
   30.51 -        List<A> p = elems = new List<A>(elems.head, elems.tail);
   30.52 -        while (true) {
   30.53 -            List<A> tail = p.tail;
   30.54 -            if (tail == null) break;
   30.55 -            tail = new List<A>(tail.head, tail.tail);
   30.56 -            p.setTail(tail);
   30.57 -            p = tail;
   30.58 +        if (elems.nonEmpty()) {
   30.59 +            List<A> orig = elems;
   30.60 +
   30.61 +            elems = last = List.<A>of(orig.head);
   30.62 +
   30.63 +            while ((orig = orig.tail).nonEmpty()) {
   30.64 +                last.tail = List.<A>of(orig.head);
   30.65 +                last = last.tail;
   30.66 +            }
   30.67          }
   30.68 -        last = p;
   30.69 -        shared = false;
   30.70      }
   30.71  
   30.72      /** Prepend an element to buffer.
   30.73       */
   30.74      public ListBuffer<A> prepend(A x) {
   30.75          elems = elems.prepend(x);
   30.76 +        if (last == null) last = elems;
   30.77          count++;
   30.78          return this;
   30.79      }
   30.80 @@ -128,9 +130,13 @@
   30.81      public ListBuffer<A> append(A x) {
   30.82          x.getClass(); // null check
   30.83          if (shared) copy();
   30.84 -        last.head = x;
   30.85 -        last.setTail(new List<A>(null,null));
   30.86 -        last = last.tail;
   30.87 +        List<A> newLast = List.<A>of(x);
   30.88 +        if (last != null) {
   30.89 +            last.tail = newLast;
   30.90 +            last = newLast;
   30.91 +        } else {
   30.92 +            elems = last = newLast;
   30.93 +        }
   30.94          count++;
   30.95          return this;
   30.96      }
   30.97 @@ -192,8 +198,9 @@
   30.98       */
   30.99      public A next() {
  30.100          A x = elems.head;
  30.101 -        if (elems != last) {
  30.102 +        if (!elems.isEmpty()) {
  30.103              elems = elems.tail;
  30.104 +            if (elems.isEmpty()) last = null;
  30.105              count--;
  30.106          }
  30.107          return x;
  30.108 @@ -205,10 +212,10 @@
  30.109          return new Iterator<A>() {
  30.110              List<A> elems = ListBuffer.this.elems;
  30.111              public boolean hasNext() {
  30.112 -                return elems != last;
  30.113 +                return !elems.isEmpty();
  30.114              }
  30.115              public A next() {
  30.116 -                if (elems == last)
  30.117 +                if (elems.isEmpty())
  30.118                      throw new NoSuchElementException();
  30.119                  A elem = elems.head;
  30.120                  elems = elems.tail;
  30.121 @@ -263,4 +270,8 @@
  30.122      public A peek() {
  30.123          return first();
  30.124      }
  30.125 +
  30.126 +    public A last() {
  30.127 +        return last != null ? last.head : null;
  30.128 +    }
  30.129  }
    31.1 --- a/src/share/classes/com/sun/tools/javac/util/MandatoryWarningHandler.java	Thu Dec 13 09:05:43 2012 -0800
    31.2 +++ b/src/share/classes/com/sun/tools/javac/util/MandatoryWarningHandler.java	Fri Dec 14 13:15:39 2012 -0800
    31.3 @@ -1,5 +1,5 @@
    31.4  /*
    31.5 - * Copyright (c) 2005, 2010, Oracle and/or its affiliates. All rights reserved.
    31.6 + * Copyright (c) 2005, 2012, Oracle and/or its affiliates. All rights reserved.
    31.7   * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
    31.8   *
    31.9   * This code is free software; you can redistribute it and/or modify it
   31.10 @@ -91,7 +91,7 @@
   31.11          DeferredDiagnosticKind(String v) { value = v; }
   31.12          String getKey(String prefix) { return prefix + value; }
   31.13  
   31.14 -        private String value;
   31.15 +        private final String value;
   31.16      }
   31.17  
   31.18  
    32.1 --- a/src/share/classes/com/sun/tools/javac/util/RichDiagnosticFormatter.java	Thu Dec 13 09:05:43 2012 -0800
    32.2 +++ b/src/share/classes/com/sun/tools/javac/util/RichDiagnosticFormatter.java	Fri Dec 14 13:15:39 2012 -0800
    32.3 @@ -249,7 +249,7 @@
    32.4          INTERSECTION("where.description.intersection");
    32.5  
    32.6          /** resource key for this where clause kind */
    32.7 -        private String key;
    32.8 +        private final String key;
    32.9  
   32.10          WhereClauseKind(String key) {
   32.11              this.key = key;
    33.1 --- a/src/share/classes/com/sun/tools/javadoc/AnnotationTypeDocImpl.java	Thu Dec 13 09:05:43 2012 -0800
    33.2 +++ b/src/share/classes/com/sun/tools/javadoc/AnnotationTypeDocImpl.java	Fri Dec 14 13:15:39 2012 -0800
    33.3 @@ -27,13 +27,13 @@
    33.4  
    33.5  import com.sun.javadoc.*;
    33.6  
    33.7 +import com.sun.source.util.TreePath;
    33.8  import com.sun.tools.javac.code.Kinds;
    33.9  import com.sun.tools.javac.code.Scope;
   33.10  import com.sun.tools.javac.code.Symbol.*;
   33.11  import com.sun.tools.javac.tree.JCTree.*;
   33.12  import com.sun.tools.javac.util.List;
   33.13  import com.sun.tools.javac.util.Names;
   33.14 -import com.sun.tools.javac.util.Position;
   33.15  
   33.16  /**
   33.17   * Represents an annotation type.
   33.18 @@ -51,12 +51,11 @@
   33.19          extends ClassDocImpl implements AnnotationTypeDoc {
   33.20  
   33.21      public AnnotationTypeDocImpl(DocEnv env, ClassSymbol sym) {
   33.22 -        this(env, sym, null, null, null);
   33.23 +        this(env, sym, null);
   33.24      }
   33.25  
   33.26 -    public AnnotationTypeDocImpl(DocEnv env, ClassSymbol sym,
   33.27 -                          String doc, JCClassDecl tree, Position.LineMap lineMap) {
   33.28 -        super(env, sym, doc, tree, lineMap);
   33.29 +    public AnnotationTypeDocImpl(DocEnv env, ClassSymbol sym, TreePath treePath) {
   33.30 +        super(env, sym, treePath);
   33.31      }
   33.32  
   33.33      /**
    34.1 --- a/src/share/classes/com/sun/tools/javadoc/AnnotationTypeElementDocImpl.java	Thu Dec 13 09:05:43 2012 -0800
    34.2 +++ b/src/share/classes/com/sun/tools/javadoc/AnnotationTypeElementDocImpl.java	Fri Dec 14 13:15:39 2012 -0800
    34.3 @@ -27,9 +27,9 @@
    34.4  
    34.5  import com.sun.javadoc.*;
    34.6  
    34.7 +import com.sun.source.util.TreePath;
    34.8  import com.sun.tools.javac.code.Symbol.*;
    34.9  import com.sun.tools.javac.tree.JCTree.*;
   34.10 -import com.sun.tools.javac.util.Position;
   34.11  
   34.12  /**
   34.13   * Represents an element of an annotation type.
   34.14 @@ -50,9 +50,8 @@
   34.15          super(env, sym);
   34.16      }
   34.17  
   34.18 -    public AnnotationTypeElementDocImpl(DocEnv env, MethodSymbol sym,
   34.19 -                                 String doc, JCMethodDecl tree, Position.LineMap lineMap) {
   34.20 -        super(env, sym, doc, tree, lineMap);
   34.21 +    public AnnotationTypeElementDocImpl(DocEnv env, MethodSymbol sym, TreePath treePath) {
   34.22 +        super(env, sym, treePath);
   34.23      }
   34.24  
   34.25      /**
    35.1 --- a/src/share/classes/com/sun/tools/javadoc/ClassDocImpl.java	Thu Dec 13 09:05:43 2012 -0800
    35.2 +++ b/src/share/classes/com/sun/tools/javadoc/ClassDocImpl.java	Fri Dec 14 13:15:39 2012 -0800
    35.3 @@ -31,13 +31,14 @@
    35.4  import java.net.URI;
    35.5  import java.util.HashSet;
    35.6  import java.util.Set;
    35.7 +
    35.8  import javax.tools.FileObject;
    35.9  import javax.tools.JavaFileManager.Location;
   35.10  import javax.tools.StandardJavaFileManager;
   35.11  import javax.tools.StandardLocation;
   35.12  
   35.13  import com.sun.javadoc.*;
   35.14 -
   35.15 +import com.sun.source.util.TreePath;
   35.16  import com.sun.tools.javac.code.Flags;
   35.17  import com.sun.tools.javac.code.Kinds;
   35.18  import com.sun.tools.javac.code.Scope;
   35.19 @@ -45,22 +46,17 @@
   35.20  import com.sun.tools.javac.code.Symbol.*;
   35.21  import com.sun.tools.javac.code.Type;
   35.22  import com.sun.tools.javac.code.Type.ClassType;
   35.23 -
   35.24  import com.sun.tools.javac.comp.AttrContext;
   35.25  import com.sun.tools.javac.comp.Env;
   35.26 -
   35.27  import com.sun.tools.javac.tree.JCTree;
   35.28 -import com.sun.tools.javac.tree.JCTree.JCClassDecl;
   35.29  import com.sun.tools.javac.tree.JCTree.JCFieldAccess;
   35.30  import com.sun.tools.javac.tree.JCTree.JCImport;
   35.31  import com.sun.tools.javac.tree.TreeInfo;
   35.32 -
   35.33  import com.sun.tools.javac.util.List;
   35.34  import com.sun.tools.javac.util.ListBuffer;
   35.35  import com.sun.tools.javac.util.Name;
   35.36  import com.sun.tools.javac.util.Names;
   35.37  import com.sun.tools.javac.util.Position;
   35.38 -
   35.39  import static com.sun.tools.javac.code.Kinds.*;
   35.40  import static com.sun.tools.javac.code.TypeTag.CLASS;
   35.41  import static com.sun.tools.javac.tree.JCTree.Tag.*;
   35.42 @@ -100,15 +96,14 @@
   35.43       * Constructor
   35.44       */
   35.45      public ClassDocImpl(DocEnv env, ClassSymbol sym) {
   35.46 -        this(env, sym, null, null, null);
   35.47 +        this(env, sym, null);
   35.48      }
   35.49  
   35.50      /**
   35.51       * Constructor
   35.52       */
   35.53 -    public ClassDocImpl(DocEnv env, ClassSymbol sym, String documentation,
   35.54 -                        JCClassDecl tree, Position.LineMap lineMap) {
   35.55 -        super(env, sym, documentation, tree, lineMap);
   35.56 +    public ClassDocImpl(DocEnv env, ClassSymbol sym, TreePath treePath) {
   35.57 +        super(env, sym, treePath);
   35.58          this.type = (ClassType)sym.type;
   35.59          this.tsym = sym;
   35.60      }
    36.1 --- a/src/share/classes/com/sun/tools/javadoc/ConstructorDocImpl.java	Thu Dec 13 09:05:43 2012 -0800
    36.2 +++ b/src/share/classes/com/sun/tools/javadoc/ConstructorDocImpl.java	Fri Dec 14 13:15:39 2012 -0800
    36.3 @@ -27,10 +27,9 @@
    36.4  
    36.5  import com.sun.javadoc.*;
    36.6  
    36.7 +import com.sun.source.util.TreePath;
    36.8  import com.sun.tools.javac.code.Symbol.ClassSymbol;
    36.9  import com.sun.tools.javac.code.Symbol.MethodSymbol;
   36.10 -import com.sun.tools.javac.tree.JCTree.JCMethodDecl;
   36.11 -import com.sun.tools.javac.util.Position;
   36.12  
   36.13  /**
   36.14   * Represents a constructor of a java class.
   36.15 @@ -58,9 +57,8 @@
   36.16      /**
   36.17       * constructor.
   36.18       */
   36.19 -    public ConstructorDocImpl(DocEnv env, MethodSymbol sym,
   36.20 -                              String docComment, JCMethodDecl tree, Position.LineMap lineMap) {
   36.21 -        super(env, sym, docComment, tree, lineMap);
   36.22 +    public ConstructorDocImpl(DocEnv env, MethodSymbol sym, TreePath treePath) {
   36.23 +        super(env, sym, treePath);
   36.24      }
   36.25  
   36.26      /**
    37.1 --- a/src/share/classes/com/sun/tools/javadoc/DocEnv.java	Thu Dec 13 09:05:43 2012 -0800
    37.2 +++ b/src/share/classes/com/sun/tools/javadoc/DocEnv.java	Fri Dec 14 13:15:39 2012 -0800
    37.3 @@ -27,18 +27,20 @@
    37.4  
    37.5  import java.lang.reflect.Modifier;
    37.6  import java.util.*;
    37.7 +
    37.8  import javax.tools.JavaFileManager;
    37.9  
   37.10  import com.sun.javadoc.*;
   37.11 -
   37.12 +import com.sun.source.util.TreePath;
   37.13 +import com.sun.tools.javac.api.JavacTrees;
   37.14  import com.sun.tools.javac.code.*;
   37.15  import com.sun.tools.javac.code.Symbol.*;
   37.16  import com.sun.tools.javac.code.Type.ClassType;
   37.17  import com.sun.tools.javac.comp.Check;
   37.18 +import com.sun.tools.javac.tree.JCTree;
   37.19  import com.sun.tools.javac.tree.JCTree.*;
   37.20  import com.sun.tools.javac.util.Context;
   37.21  import com.sun.tools.javac.util.Names;
   37.22 -import com.sun.tools.javac.util.Position;
   37.23  
   37.24  /**
   37.25   * Holds the environment for a run of javadoc.
   37.26 @@ -104,6 +106,8 @@
   37.27      JavaFileManager fileManager;
   37.28      Context context;
   37.29  
   37.30 +    WeakHashMap<JCTree, TreePath> treePaths = new WeakHashMap<JCTree, TreePath>();
   37.31 +
   37.32      /** Allow documenting from class files? */
   37.33      boolean docClasses = false;
   37.34  
   37.35 @@ -540,13 +544,12 @@
   37.36      /**
   37.37       * Create the PackageDoc (or a subtype) for a package symbol.
   37.38       */
   37.39 -    void makePackageDoc(PackageSymbol pack, String docComment, JCCompilationUnit tree) {
   37.40 +    void makePackageDoc(PackageSymbol pack, TreePath treePath) {
   37.41          PackageDocImpl result = packageMap.get(pack);
   37.42          if (result != null) {
   37.43 -            if (docComment != null) result.setRawCommentText(docComment);
   37.44 -            if (tree != null) result.setTree(tree);
   37.45 +            if (treePath != null) result.setTreePath(treePath);
   37.46          } else {
   37.47 -            result = new PackageDocImpl(this, pack, docComment, tree);
   37.48 +            result = new PackageDocImpl(this, pack, treePath);
   37.49              packageMap.put(pack, result);
   37.50          }
   37.51      }
   37.52 @@ -572,17 +575,16 @@
   37.53      /**
   37.54       * Create the ClassDoc (or a subtype) for a class symbol.
   37.55       */
   37.56 -    protected void makeClassDoc(ClassSymbol clazz, String docComment, JCClassDecl tree, Position.LineMap lineMap) {
   37.57 +    protected void makeClassDoc(ClassSymbol clazz, TreePath treePath) {
   37.58          ClassDocImpl result = classMap.get(clazz);
   37.59          if (result != null) {
   37.60 -            if (docComment != null) result.setRawCommentText(docComment);
   37.61 -            if (tree != null) result.setTree(tree);
   37.62 +            if (treePath != null) result.setTreePath(treePath);
   37.63              return;
   37.64          }
   37.65 -        if (isAnnotationType(tree)) {   // flags of clazz may not yet be set
   37.66 -            result = new AnnotationTypeDocImpl(this, clazz, docComment, tree, lineMap);
   37.67 +        if (isAnnotationType((JCClassDecl) treePath.getLeaf())) {   // flags of clazz may not yet be set
   37.68 +            result = new AnnotationTypeDocImpl(this, clazz, treePath);
   37.69          } else {
   37.70 -            result = new ClassDocImpl(this, clazz, docComment, tree, lineMap);
   37.71 +            result = new ClassDocImpl(this, clazz, treePath);
   37.72          }
   37.73          classMap.put(clazz, result);
   37.74      }
   37.75 @@ -610,13 +612,12 @@
   37.76      /**
   37.77       * Create a FieldDoc for a var symbol.
   37.78       */
   37.79 -    protected void makeFieldDoc(VarSymbol var, String docComment, JCVariableDecl tree, Position.LineMap lineMap) {
   37.80 +    protected void makeFieldDoc(VarSymbol var, TreePath treePath) {
   37.81          FieldDocImpl result = fieldMap.get(var);
   37.82          if (result != null) {
   37.83 -            if (docComment != null) result.setRawCommentText(docComment);
   37.84 -            if (tree != null) result.setTree(tree);
   37.85 +            if (treePath != null) result.setTreePath(treePath);
   37.86          } else {
   37.87 -            result = new FieldDocImpl(this, var, docComment, tree, lineMap);
   37.88 +            result = new FieldDocImpl(this, var, treePath);
   37.89              fieldMap.put(var, result);
   37.90          }
   37.91      }
   37.92 @@ -627,14 +628,12 @@
   37.93       * Create a MethodDoc for this MethodSymbol.
   37.94       * Should be called only on symbols representing methods.
   37.95       */
   37.96 -    protected void makeMethodDoc(MethodSymbol meth, String docComment,
   37.97 -                       JCMethodDecl tree, Position.LineMap lineMap) {
   37.98 +    protected void makeMethodDoc(MethodSymbol meth, TreePath treePath) {
   37.99          MethodDocImpl result = (MethodDocImpl)methodMap.get(meth);
  37.100          if (result != null) {
  37.101 -            if (docComment != null) result.setRawCommentText(docComment);
  37.102 -            if (tree != null) result.setTree(tree);
  37.103 +            if (treePath != null) result.setTreePath(treePath);
  37.104          } else {
  37.105 -            result = new MethodDocImpl(this, meth, docComment, tree, lineMap);
  37.106 +            result = new MethodDocImpl(this, meth, treePath);
  37.107              methodMap.put(meth, result);
  37.108          }
  37.109      }
  37.110 @@ -656,14 +655,12 @@
  37.111       * Create the ConstructorDoc for a MethodSymbol.
  37.112       * Should be called only on symbols representing constructors.
  37.113       */
  37.114 -    protected void makeConstructorDoc(MethodSymbol meth, String docComment,
  37.115 -                            JCMethodDecl tree, Position.LineMap lineMap) {
  37.116 +    protected void makeConstructorDoc(MethodSymbol meth, TreePath treePath) {
  37.117          ConstructorDocImpl result = (ConstructorDocImpl)methodMap.get(meth);
  37.118          if (result != null) {
  37.119 -            if (docComment != null) result.setRawCommentText(docComment);
  37.120 -            if (tree != null) result.setTree(tree);
  37.121 +            if (treePath != null) result.setTreePath(treePath);
  37.122          } else {
  37.123 -            result = new ConstructorDocImpl(this, meth, docComment, tree, lineMap);
  37.124 +            result = new ConstructorDocImpl(this, meth, treePath);
  37.125              methodMap.put(meth, result);
  37.126          }
  37.127      }
  37.128 @@ -685,16 +682,14 @@
  37.129       * Create the AnnotationTypeElementDoc for a MethodSymbol.
  37.130       * Should be called only on symbols representing annotation type elements.
  37.131       */
  37.132 -    protected void makeAnnotationTypeElementDoc(MethodSymbol meth,
  37.133 -                                      String docComment, JCMethodDecl tree, Position.LineMap lineMap) {
  37.134 +    protected void makeAnnotationTypeElementDoc(MethodSymbol meth, TreePath treePath) {
  37.135          AnnotationTypeElementDocImpl result =
  37.136              (AnnotationTypeElementDocImpl)methodMap.get(meth);
  37.137          if (result != null) {
  37.138 -            if (docComment != null) result.setRawCommentText(docComment);
  37.139 -            if (tree != null) result.setTree(tree);
  37.140 +            if (treePath != null) result.setTreePath(treePath);
  37.141          } else {
  37.142              result =
  37.143 -                new AnnotationTypeElementDocImpl(this, meth, docComment, tree, lineMap);
  37.144 +                new AnnotationTypeElementDocImpl(this, meth, treePath);
  37.145              methodMap.put(meth, result);
  37.146          }
  37.147      }
  37.148 @@ -730,6 +725,18 @@
  37.149  //      return result;
  37.150      }
  37.151  
  37.152 +    TreePath getTreePath(JCCompilationUnit tree) {
  37.153 +        TreePath p = treePaths.get(tree);
  37.154 +        if (p == null)
  37.155 +            treePaths.put(tree, p = new TreePath(tree));
  37.156 +        return p;
  37.157 +    }
  37.158 +
  37.159 +    TreePath getTreePath(JCCompilationUnit toplevel, JCTree tree) {
  37.160 +        // don't bother to cache paths for classes and members
  37.161 +        return new TreePath(getTreePath(toplevel), tree);
  37.162 +    }
  37.163 +
  37.164      /**
  37.165       * Set the encoding.
  37.166       */
    38.1 --- a/src/share/classes/com/sun/tools/javadoc/DocImpl.java	Thu Dec 13 09:05:43 2012 -0800
    38.2 +++ b/src/share/classes/com/sun/tools/javadoc/DocImpl.java	Fri Dec 14 13:15:39 2012 -0800
    38.3 @@ -35,6 +35,9 @@
    38.4  import javax.tools.FileObject;
    38.5  
    38.6  import com.sun.javadoc.*;
    38.7 +import com.sun.source.util.TreePath;
    38.8 +import com.sun.tools.javac.tree.JCTree;
    38.9 +import com.sun.tools.javac.tree.JCTree.JCCompilationUnit;
   38.10  import com.sun.tools.javac.util.Position;
   38.11  
   38.12  /**
   38.13 @@ -61,6 +64,12 @@
   38.14      protected final DocEnv env;   //### Rename this everywhere to 'docenv' ?
   38.15  
   38.16      /**
   38.17 +     * Back pointer to the tree node for this doc item.
   38.18 +     * May be null if there is no associated tree.
   38.19 +     */
   38.20 +    protected TreePath treePath;
   38.21 +
   38.22 +    /**
   38.23       *  The complex comment object, lazily initialized.
   38.24       */
   38.25      private Comment comment;
   38.26 @@ -88,11 +97,21 @@
   38.27      /**
   38.28       * Constructor.
   38.29       */
   38.30 -    DocImpl(DocEnv env, String documentation) {
   38.31 -        this.documentation = documentation;
   38.32 +    DocImpl(DocEnv env, TreePath treePath) {
   38.33 +        this.treePath = treePath;
   38.34 +        this.documentation = getCommentText(treePath);
   38.35          this.env = env;
   38.36      }
   38.37  
   38.38 +    private static String getCommentText(TreePath p) {
   38.39 +        if (p == null)
   38.40 +            return null;
   38.41 +
   38.42 +        JCCompilationUnit topLevel = (JCCompilationUnit) p.getCompilationUnit();
   38.43 +        JCTree tree = (JCTree) p.getLeaf();
   38.44 +        return topLevel.docComments.getCommentText(tree);
   38.45 +    }
   38.46 +
   38.47      /**
   38.48       * So subclasses have the option to do lazy initialization of
   38.49       * "documentation" string.
   38.50 @@ -213,11 +232,21 @@
   38.51       * operations like internalization.
   38.52       */
   38.53      public void setRawCommentText(String rawDocumentation) {
   38.54 +        treePath = null;
   38.55          documentation = rawDocumentation;
   38.56          comment = null;
   38.57      }
   38.58  
   38.59      /**
   38.60 +     * Set the full unprocessed text of the comment and tree path.
   38.61 +     */
   38.62 +    void setTreePath(TreePath treePath) {
   38.63 +        this.treePath = treePath;
   38.64 +        documentation = getCommentText(treePath);
   38.65 +        comment = null;
   38.66 +    }
   38.67 +
   38.68 +    /**
   38.69       * return a key for sorting.
   38.70       */
   38.71      CollationKey key() {
    39.1 --- a/src/share/classes/com/sun/tools/javadoc/ExecutableMemberDocImpl.java	Thu Dec 13 09:05:43 2012 -0800
    39.2 +++ b/src/share/classes/com/sun/tools/javadoc/ExecutableMemberDocImpl.java	Fri Dec 14 13:15:39 2012 -0800
    39.3 @@ -30,13 +30,12 @@
    39.4  
    39.5  import com.sun.javadoc.*;
    39.6  
    39.7 +import com.sun.source.util.TreePath;
    39.8  import com.sun.tools.javac.code.Flags;
    39.9  import com.sun.tools.javac.code.Symbol.*;
   39.10  import com.sun.tools.javac.code.Type;
   39.11 -import com.sun.tools.javac.tree.JCTree.JCMethodDecl;
   39.12  import com.sun.tools.javac.util.List;
   39.13  import com.sun.tools.javac.util.ListBuffer;
   39.14 -import com.sun.tools.javac.util.Position;
   39.15  
   39.16  /**
   39.17   * Represents a method or constructor of a java class.
   39.18 @@ -60,9 +59,8 @@
   39.19      /**
   39.20       * Constructor.
   39.21       */
   39.22 -    public ExecutableMemberDocImpl(DocEnv env, MethodSymbol sym,
   39.23 -                                   String rawDocs, JCMethodDecl tree, Position.LineMap lineMap) {
   39.24 -        super(env, sym, rawDocs, tree, lineMap);
   39.25 +    public ExecutableMemberDocImpl(DocEnv env, MethodSymbol sym, TreePath treePath) {
   39.26 +        super(env, sym, treePath);
   39.27          this.sym = sym;
   39.28      }
   39.29  
   39.30 @@ -70,7 +68,7 @@
   39.31       * Constructor.
   39.32       */
   39.33      public ExecutableMemberDocImpl(DocEnv env, MethodSymbol sym) {
   39.34 -        this(env, sym, null, null, null);
   39.35 +        this(env, sym, null);
   39.36      }
   39.37  
   39.38      /**
    40.1 --- a/src/share/classes/com/sun/tools/javadoc/FieldDocImpl.java	Thu Dec 13 09:05:43 2012 -0800
    40.2 +++ b/src/share/classes/com/sun/tools/javadoc/FieldDocImpl.java	Fri Dec 14 13:15:39 2012 -0800
    40.3 @@ -25,6 +25,7 @@
    40.4  
    40.5  package com.sun.tools.javadoc;
    40.6  
    40.7 +import com.sun.source.util.TreePath;
    40.8  import java.lang.reflect.Modifier;
    40.9  
   40.10  import com.sun.javadoc.*;
   40.11 @@ -61,9 +62,8 @@
   40.12      /**
   40.13       * Constructor.
   40.14       */
   40.15 -    public FieldDocImpl(DocEnv env, VarSymbol sym,
   40.16 -                        String rawDocs, JCVariableDecl tree, Position.LineMap lineMap) {
   40.17 -        super(env, sym, rawDocs, tree, lineMap);
   40.18 +    public FieldDocImpl(DocEnv env, VarSymbol sym, TreePath treePath) {
   40.19 +        super(env, sym, treePath);
   40.20          this.sym = sym;
   40.21      }
   40.22  
   40.23 @@ -71,7 +71,7 @@
   40.24       * Constructor.
   40.25       */
   40.26      public FieldDocImpl(DocEnv env, VarSymbol sym) {
   40.27 -        this(env, sym, null, null, null);
   40.28 +        this(env, sym, null);
   40.29      }
   40.30  
   40.31      /**
    41.1 --- a/src/share/classes/com/sun/tools/javadoc/JavadocEnter.java	Thu Dec 13 09:05:43 2012 -0800
    41.2 +++ b/src/share/classes/com/sun/tools/javadoc/JavadocEnter.java	Fri Dec 14 13:15:39 2012 -0800
    41.3 @@ -25,13 +25,14 @@
    41.4  
    41.5  package com.sun.tools.javadoc;
    41.6  
    41.7 +
    41.8  import javax.tools.JavaFileObject;
    41.9  
   41.10 +import com.sun.source.util.TreePath;
   41.11  import com.sun.tools.javac.code.Kinds;
   41.12  import com.sun.tools.javac.code.Symbol.*;
   41.13  import com.sun.tools.javac.comp.Enter;
   41.14  import com.sun.tools.javac.tree.JCTree.*;
   41.15 -import com.sun.tools.javac.tree.TreeInfo;
   41.16  import com.sun.tools.javac.util.Context;
   41.17  import com.sun.tools.javac.util.JCDiagnostic.DiagnosticPosition;
   41.18  import com.sun.tools.javac.util.List;
   41.19 @@ -85,8 +86,7 @@
   41.20      public void visitTopLevel(JCCompilationUnit tree) {
   41.21          super.visitTopLevel(tree);
   41.22          if (tree.sourcefile.isNameCompatible("package-info", JavaFileObject.Kind.SOURCE)) {
   41.23 -            String comment = TreeInfo.getCommentText(env, tree);
   41.24 -            docenv.makePackageDoc(tree.packge, comment, tree);
   41.25 +            docenv.makePackageDoc(tree.packge, docenv.getTreePath(tree));
   41.26          }
   41.27      }
   41.28  
   41.29 @@ -95,9 +95,8 @@
   41.30          super.visitClassDef(tree);
   41.31          if (tree.sym == null) return;
   41.32          if (tree.sym.kind == Kinds.TYP || tree.sym.kind == Kinds.ERR) {
   41.33 -            String comment = TreeInfo.getCommentText(env, tree);
   41.34              ClassSymbol c = tree.sym;
   41.35 -            docenv.makeClassDoc(c, comment, tree, env.toplevel.lineMap);
   41.36 +            docenv.makeClassDoc(c, docenv.getTreePath(env.toplevel, tree));
   41.37          }
   41.38      }
   41.39  
    42.1 --- a/src/share/classes/com/sun/tools/javadoc/JavadocMemberEnter.java	Thu Dec 13 09:05:43 2012 -0800
    42.2 +++ b/src/share/classes/com/sun/tools/javadoc/JavadocMemberEnter.java	Fri Dec 14 13:15:39 2012 -0800
    42.3 @@ -25,14 +25,13 @@
    42.4  
    42.5  package com.sun.tools.javadoc;
    42.6  
    42.7 +import com.sun.source.util.TreePath;
    42.8  import com.sun.tools.javac.code.Flags;
    42.9  import com.sun.tools.javac.code.Kinds;
   42.10  import com.sun.tools.javac.code.Symbol.*;
   42.11  import com.sun.tools.javac.comp.MemberEnter;
   42.12  import com.sun.tools.javac.tree.JCTree.*;
   42.13 -import com.sun.tools.javac.tree.TreeInfo;
   42.14  import com.sun.tools.javac.util.Context;
   42.15 -import com.sun.tools.javac.util.Position;
   42.16  
   42.17  /**
   42.18   *  Javadoc's own memberEnter phase does a few things above and beyond that
   42.19 @@ -73,14 +72,13 @@
   42.20          super.visitMethodDef(tree);
   42.21          MethodSymbol meth = tree.sym;
   42.22          if (meth == null || meth.kind != Kinds.MTH) return;
   42.23 -        String docComment = TreeInfo.getCommentText(env, tree);
   42.24 -        Position.LineMap lineMap = env.toplevel.lineMap;
   42.25 +        TreePath treePath = docenv.getTreePath(env.toplevel, tree);
   42.26          if (meth.isConstructor())
   42.27 -            docenv.makeConstructorDoc(meth, docComment, tree, lineMap);
   42.28 +            docenv.makeConstructorDoc(meth, treePath);
   42.29          else if (isAnnotationTypeElement(meth))
   42.30 -            docenv.makeAnnotationTypeElementDoc(meth, docComment, tree, lineMap);
   42.31 +            docenv.makeAnnotationTypeElementDoc(meth, treePath);
   42.32          else
   42.33 -            docenv.makeMethodDoc(meth, docComment, tree, lineMap);
   42.34 +            docenv.makeMethodDoc(meth, treePath);
   42.35  
   42.36          // release resources
   42.37          tree.body = null;
   42.38 @@ -92,9 +90,7 @@
   42.39          if (tree.sym != null &&
   42.40                  tree.sym.kind == Kinds.VAR &&
   42.41                  !isParameter(tree.sym)) {
   42.42 -            String docComment = TreeInfo.getCommentText(env, tree);
   42.43 -            Position.LineMap lineMap = env.toplevel.lineMap;
   42.44 -            docenv.makeFieldDoc(tree.sym, docComment, tree, lineMap);
   42.45 +            docenv.makeFieldDoc(tree.sym, docenv.getTreePath(env.toplevel, tree));
   42.46          }
   42.47      }
   42.48  
    43.1 --- a/src/share/classes/com/sun/tools/javadoc/MemberDocImpl.java	Thu Dec 13 09:05:43 2012 -0800
    43.2 +++ b/src/share/classes/com/sun/tools/javadoc/MemberDocImpl.java	Fri Dec 14 13:15:39 2012 -0800
    43.3 @@ -27,9 +27,8 @@
    43.4  
    43.5  import com.sun.javadoc.*;
    43.6  
    43.7 +import com.sun.source.util.TreePath;
    43.8  import com.sun.tools.javac.code.Symbol;
    43.9 -import com.sun.tools.javac.tree.JCTree;
   43.10 -import com.sun.tools.javac.util.Position;
   43.11  
   43.12  /**
   43.13   * Represents a member of a java class: field, constructor, or method.
   43.14 @@ -57,8 +56,8 @@
   43.15      /**
   43.16       * constructor.
   43.17       */
   43.18 -    public MemberDocImpl(DocEnv env, Symbol sym, String doc, JCTree tree, Position.LineMap lineMap) {
   43.19 -        super(env, sym, doc, tree, lineMap);
   43.20 +    public MemberDocImpl(DocEnv env, Symbol sym, TreePath treePath) {
   43.21 +        super(env, sym, treePath);
   43.22      }
   43.23  
   43.24      /**
    44.1 --- a/src/share/classes/com/sun/tools/javadoc/MethodDocImpl.java	Thu Dec 13 09:05:43 2012 -0800
    44.2 +++ b/src/share/classes/com/sun/tools/javadoc/MethodDocImpl.java	Fri Dec 14 13:15:39 2012 -0800
    44.3 @@ -28,12 +28,10 @@
    44.4  import java.lang.reflect.Modifier;
    44.5  
    44.6  import com.sun.javadoc.*;
    44.7 +import com.sun.source.util.TreePath;
    44.8  import com.sun.tools.javac.code.*;
    44.9  import com.sun.tools.javac.code.Symbol.*;
   44.10  import com.sun.tools.javac.code.Type;
   44.11 -import com.sun.tools.javac.tree.JCTree.JCMethodDecl;
   44.12 -import com.sun.tools.javac.util.Position;
   44.13 -
   44.14  import static com.sun.tools.javac.code.TypeTag.CLASS;
   44.15  
   44.16  /**
   44.17 @@ -62,9 +60,8 @@
   44.18      /**
   44.19       * constructor.
   44.20       */
   44.21 -    public MethodDocImpl(DocEnv env, MethodSymbol sym,
   44.22 -                         String docComment, JCMethodDecl tree, Position.LineMap lineMap) {
   44.23 -        super(env, sym, docComment, tree, lineMap);
   44.24 +    public MethodDocImpl(DocEnv env, MethodSymbol sym, TreePath treePath) {
   44.25 +        super(env, sym, treePath);
   44.26      }
   44.27  
   44.28      /**
    45.1 --- a/src/share/classes/com/sun/tools/javadoc/PackageDocImpl.java	Thu Dec 13 09:05:43 2012 -0800
    45.2 +++ b/src/share/classes/com/sun/tools/javadoc/PackageDocImpl.java	Fri Dec 14 13:15:39 2012 -0800
    45.3 @@ -31,6 +31,7 @@
    45.4  import javax.tools.FileObject;
    45.5  
    45.6  import com.sun.javadoc.*;
    45.7 +import com.sun.source.util.TreePath;
    45.8  import com.sun.tools.javac.code.Attribute;
    45.9  import com.sun.tools.javac.code.Scope;
   45.10  import com.sun.tools.javac.code.Symbol.ClassSymbol;
   45.11 @@ -75,17 +76,16 @@
   45.12       * Constructor
   45.13       */
   45.14      public PackageDocImpl(DocEnv env, PackageSymbol sym) {
   45.15 -        this(env, sym, null, null);
   45.16 +        this(env, sym, null);
   45.17      }
   45.18  
   45.19      /**
   45.20       * Constructor
   45.21       */
   45.22 -    public PackageDocImpl(DocEnv env, PackageSymbol sym,
   45.23 -                          String documentation, JCTree tree) {
   45.24 -        super(env, documentation);
   45.25 +    public PackageDocImpl(DocEnv env, PackageSymbol sym, TreePath treePath) {
   45.26 +        super(env, treePath);
   45.27          this.sym = sym;
   45.28 -        this.tree = (JCCompilationUnit) tree;
   45.29 +        this.tree = (treePath == null) ? null : (JCCompilationUnit) treePath.getCompilationUnit();
   45.30          foundDoc = (documentation != null);
   45.31      }
   45.32  
   45.33 @@ -93,8 +93,8 @@
   45.34          this.tree = (JCCompilationUnit) tree;
   45.35      }
   45.36  
   45.37 -    public void setRawCommentText(String rawDocumentation) {
   45.38 -        super.setRawCommentText(rawDocumentation);
   45.39 +    public void setTreePath(TreePath treePath) {
   45.40 +        super.setTreePath(treePath);
   45.41          checkDoc();
   45.42      }
   45.43  
    46.1 --- a/src/share/classes/com/sun/tools/javadoc/ProgramElementDocImpl.java	Thu Dec 13 09:05:43 2012 -0800
    46.2 +++ b/src/share/classes/com/sun/tools/javadoc/ProgramElementDocImpl.java	Fri Dec 14 13:15:39 2012 -0800
    46.3 @@ -29,10 +29,12 @@
    46.4  import java.text.CollationKey;
    46.5  
    46.6  import com.sun.javadoc.*;
    46.7 +import com.sun.source.util.TreePath;
    46.8  import com.sun.tools.javac.code.Attribute;
    46.9  import com.sun.tools.javac.code.Symbol;
   46.10  import com.sun.tools.javac.code.Symbol.ClassSymbol;
   46.11  import com.sun.tools.javac.tree.JCTree;
   46.12 +import com.sun.tools.javac.tree.JCTree.JCCompilationUnit;
   46.13  import com.sun.tools.javac.util.Position;
   46.14  
   46.15  /**
   46.16 @@ -66,16 +68,20 @@
   46.17      // Cache for getModifiers().
   46.18      private int modifiers = -1;
   46.19  
   46.20 -    protected ProgramElementDocImpl(DocEnv env, Symbol sym,
   46.21 -                                    String doc, JCTree tree, Position.LineMap lineMap) {
   46.22 -        super(env, doc);
   46.23 +    protected ProgramElementDocImpl(DocEnv env, Symbol sym, TreePath treePath) {
   46.24 +        super(env, treePath);
   46.25          this.sym = sym;
   46.26 -        this.tree = tree;
   46.27 -        this.lineMap = lineMap;
   46.28 +        if (treePath != null) {
   46.29 +            tree = (JCTree) treePath.getLeaf();
   46.30 +            lineMap = ((JCCompilationUnit) treePath.getCompilationUnit()).lineMap;
   46.31 +        }
   46.32      }
   46.33  
   46.34 -    void setTree(JCTree tree) {
   46.35 -        this.tree = tree;
   46.36 +    @Override
   46.37 +    void setTreePath(TreePath treePath) {
   46.38 +        super.setTreePath(treePath);
   46.39 +        this.tree = (JCTree) treePath.getLeaf();
   46.40 +        this.lineMap = ((JCCompilationUnit) treePath.getCompilationUnit()).lineMap;
   46.41      }
   46.42  
   46.43      /**
    47.1 --- a/src/share/classes/com/sun/tools/javadoc/RootDocImpl.java	Thu Dec 13 09:05:43 2012 -0800
    47.2 +++ b/src/share/classes/com/sun/tools/javadoc/RootDocImpl.java	Fri Dec 14 13:15:39 2012 -0800
    47.3 @@ -331,7 +331,6 @@
    47.4      @Override
    47.5      protected String documentation() {
    47.6          if (documentation == null) {
    47.7 -            int cnt = options.length();
    47.8              JavaFileObject overviewPath = getOverviewPath();
    47.9              if (overviewPath == null) {
   47.10                  // no doc file to be had
    48.1 --- a/src/share/classes/com/sun/tools/javah/JavahTask.java	Thu Dec 13 09:05:43 2012 -0800
    48.2 +++ b/src/share/classes/com/sun/tools/javah/JavahTask.java	Fri Dec 14 13:15:39 2012 -0800
    48.3 @@ -147,7 +147,7 @@
    48.4          }
    48.5      }
    48.6  
    48.7 -    static Option[] recognizedOptions = {
    48.8 +    static final Option[] recognizedOptions = {
    48.9          new Option(true, "-o") {
   48.10              void process(JavahTask task, String opt, String arg) {
   48.11                  task.ofile = new File(arg);
    49.1 --- a/src/share/classes/com/sun/tools/javap/JavapTask.java	Thu Dec 13 09:05:43 2012 -0800
    49.2 +++ b/src/share/classes/com/sun/tools/javap/JavapTask.java	Fri Dec 14 13:15:39 2012 -0800
    49.3 @@ -117,7 +117,7 @@
    49.4          final String[] aliases;
    49.5      }
    49.6  
    49.7 -    static Option[] recognizedOptions = {
    49.8 +    static final Option[] recognizedOptions = {
    49.9  
   49.10          new Option(false, "-help", "--help", "-?") {
   49.11              void process(JavapTask task, String opt, String arg) {
    50.1 --- a/src/share/classes/javax/lang/model/element/Modifier.java	Thu Dec 13 09:05:43 2012 -0800
    50.2 +++ b/src/share/classes/javax/lang/model/element/Modifier.java	Fri Dec 14 13:15:39 2012 -0800
    50.3 @@ -1,5 +1,5 @@
    50.4  /*
    50.5 - * Copyright (c) 2005, 2006, Oracle and/or its affiliates. All rights reserved.
    50.6 + * Copyright (c) 2005, 2012, 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 @@ -61,16 +61,10 @@
   50.11      /** The modifier {@code native} */          NATIVE,
   50.12      /** The modifier {@code strictfp} */        STRICTFP;
   50.13  
   50.14 -
   50.15 -    private String lowercase = null;    // modifier name in lowercase
   50.16 -
   50.17      /**
   50.18       * Returns this modifier's name in lowercase.
   50.19       */
   50.20      public String toString() {
   50.21 -        if (lowercase == null) {
   50.22 -           lowercase = name().toLowerCase(java.util.Locale.US);
   50.23 -        }
   50.24 -        return lowercase;
   50.25 +        return name().toLowerCase(java.util.Locale.US);
   50.26      }
   50.27  }
    51.1 --- a/src/share/classes/javax/lang/model/util/ElementFilter.java	Thu Dec 13 09:05:43 2012 -0800
    51.2 +++ b/src/share/classes/javax/lang/model/util/ElementFilter.java	Fri Dec 14 13:15:39 2012 -0800
    51.3 @@ -66,19 +66,19 @@
    51.4  public class ElementFilter {
    51.5      private ElementFilter() {} // Do not instantiate.
    51.6  
    51.7 -    private static Set<ElementKind> CONSTRUCTOR_KIND =
    51.8 +    private static final Set<ElementKind> CONSTRUCTOR_KIND =
    51.9          Collections.unmodifiableSet(EnumSet.of(ElementKind.CONSTRUCTOR));
   51.10  
   51.11 -    private static Set<ElementKind> FIELD_KINDS =
   51.12 +    private static final Set<ElementKind> FIELD_KINDS =
   51.13          Collections.unmodifiableSet(EnumSet.of(ElementKind.FIELD,
   51.14                                                 ElementKind.ENUM_CONSTANT));
   51.15 -    private static Set<ElementKind> METHOD_KIND =
   51.16 +    private static final Set<ElementKind> METHOD_KIND =
   51.17          Collections.unmodifiableSet(EnumSet.of(ElementKind.METHOD));
   51.18  
   51.19 -    private static Set<ElementKind> PACKAGE_KIND =
   51.20 +    private static final Set<ElementKind> PACKAGE_KIND =
   51.21          Collections.unmodifiableSet(EnumSet.of(ElementKind.PACKAGE));
   51.22  
   51.23 -    private static Set<ElementKind> TYPE_KINDS =
   51.24 +    private static final Set<ElementKind> TYPE_KINDS =
   51.25          Collections.unmodifiableSet(EnumSet.of(ElementKind.CLASS,
   51.26                                                 ElementKind.ENUM,
   51.27                                                 ElementKind.INTERFACE,
    52.1 --- a/src/share/classes/javax/tools/StandardLocation.java	Thu Dec 13 09:05:43 2012 -0800
    52.2 +++ b/src/share/classes/javax/tools/StandardLocation.java	Fri Dec 14 13:15:39 2012 -0800
    52.3 @@ -97,7 +97,7 @@
    52.4          return locations.get(name);
    52.5      }
    52.6      //where
    52.7 -        private static ConcurrentMap<String,Location> locations
    52.8 +        private static final ConcurrentMap<String,Location> locations
    52.9              = new ConcurrentHashMap<String,Location>();
   52.10  
   52.11      public String getName() { return name(); }
    53.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
    53.2 +++ b/test/tools/javac/T8003967/DetectMutableStaticFields.java	Fri Dec 14 13:15:39 2012 -0800
    53.3 @@ -0,0 +1,242 @@
    53.4 +/*
    53.5 + * Copyright (c) 2006, 2012, Oracle and/or its affiliates. All rights reserved.
    53.6 + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
    53.7 + *
    53.8 + * This code is free software; you can redistribute it and/or modify it
    53.9 + * under the terms of the GNU General Public License version 2 only, as
   53.10 + * published by the Free Software Foundation.  Oracle designates this
   53.11 + * particular file as subject to the "Classpath" exception as provided
   53.12 + * by Oracle in the LICENSE file that accompanied this code.
   53.13 + *
   53.14 + * This code is distributed in the hope that it will be useful, but WITHOUT
   53.15 + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
   53.16 + * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
   53.17 + * version 2 for more details (a copy is included in the LICENSE file that
   53.18 + * accompanied this code).
   53.19 + *
   53.20 + * You should have received a copy of the GNU General Public License version
   53.21 + * 2 along with this work; if not, write to the Free Software Foundation,
   53.22 + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
   53.23 + *
   53.24 + * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
   53.25 + * or visit www.oracle.com if you need additional information or have any
   53.26 + * questions.
   53.27 + */
   53.28 +
   53.29 +/*
   53.30 + * @test
   53.31 + * @bug 8003967
   53.32 + * @summary detect and remove all mutable implicit static enum fields in langtools
   53.33 + * @run main DetectMutableStaticFields
   53.34 + */
   53.35 +
   53.36 +import java.io.File;
   53.37 +import java.io.IOException;
   53.38 +import java.net.URI;
   53.39 +import java.net.URISyntaxException;
   53.40 +import java.util.ArrayList;
   53.41 +import java.util.Arrays;
   53.42 +import java.util.EnumSet;
   53.43 +import java.util.HashMap;
   53.44 +import java.util.List;
   53.45 +import java.util.Map;
   53.46 +import javax.tools.JavaCompiler;
   53.47 +import javax.tools.JavaFileManager;
   53.48 +import javax.tools.JavaFileObject;
   53.49 +import javax.tools.StandardJavaFileManager;
   53.50 +import javax.tools.StandardLocation;
   53.51 +import javax.tools.ToolProvider;
   53.52 +import com.sun.tools.classfile.ClassFile;
   53.53 +import com.sun.tools.classfile.ConstantPoolException;
   53.54 +import com.sun.tools.classfile.Descriptor;
   53.55 +import com.sun.tools.classfile.Descriptor.InvalidDescriptor;
   53.56 +import com.sun.tools.classfile.Field;
   53.57 +
   53.58 +import static javax.tools.JavaFileObject.Kind.CLASS;
   53.59 +import static com.sun.tools.classfile.AccessFlags.ACC_ENUM;
   53.60 +import static com.sun.tools.classfile.AccessFlags.ACC_FINAL;
   53.61 +import static com.sun.tools.classfile.AccessFlags.ACC_STATIC;
   53.62 +
   53.63 +public class DetectMutableStaticFields {
   53.64 +
   53.65 +    private static final String keyResource =
   53.66 +            "com/sun/tools/javac/tree/JCTree.class";
   53.67 +
   53.68 +    private String[] packagesToSeekFor = new String[] {
   53.69 +        "javax.tools",
   53.70 +        "javax.lang.model",
   53.71 +        "com.sun.javadoc",
   53.72 +        "com.sun.source",
   53.73 +        "com.sun.tools.classfile",
   53.74 +        "com.sun.tools.doclets",
   53.75 +        "com.sun.tools.javac",
   53.76 +        "com.sun.tools.javadoc",
   53.77 +        "com.sun.tools.javah",
   53.78 +        "com.sun.tools.javap",
   53.79 +    };
   53.80 +
   53.81 +    private static final Map<String, List<String>> classFieldsToIgnoreMap = new HashMap<>();
   53.82 +
   53.83 +    static {
   53.84 +        classFieldsToIgnoreMap.
   53.85 +                put("javax/tools/ToolProvider",
   53.86 +                    Arrays.asList("instance"));
   53.87 +        classFieldsToIgnoreMap.
   53.88 +                put("com/sun/tools/javah/JavahTask",
   53.89 +                    Arrays.asList("versionRB"));
   53.90 +        classFieldsToIgnoreMap.
   53.91 +                put("com/sun/tools/classfile/Dependencies$DefaultFilter",
   53.92 +                    Arrays.asList("instance"));
   53.93 +        classFieldsToIgnoreMap.
   53.94 +                put("com/sun/tools/javap/JavapTask",
   53.95 +                    Arrays.asList("versionRB"));
   53.96 +        classFieldsToIgnoreMap.
   53.97 +                put("com/sun/tools/doclets/formats/html/HtmlDoclet",
   53.98 +                    Arrays.asList("docletToStart"));
   53.99 +        classFieldsToIgnoreMap.
  53.100 +                put("com/sun/tools/javac/util/JCDiagnostic",
  53.101 +                    Arrays.asList("fragmentFormatter"));
  53.102 +        classFieldsToIgnoreMap.
  53.103 +                put("com/sun/tools/javac/util/JavacMessages",
  53.104 +                    Arrays.asList("defaultBundle", "defaultMessages"));
  53.105 +        classFieldsToIgnoreMap.
  53.106 +                put("com/sun/tools/javac/file/ZipFileIndexCache",
  53.107 +                    Arrays.asList("sharedInstance"));
  53.108 +        classFieldsToIgnoreMap.
  53.109 +                put("com/sun/tools/javac/main/JavaCompiler",
  53.110 +                    Arrays.asList("versionRB"));
  53.111 +        classFieldsToIgnoreMap.
  53.112 +                put("com/sun/tools/javac/code/Type",
  53.113 +                    Arrays.asList("moreInfo"));
  53.114 +        classFieldsToIgnoreMap.
  53.115 +                put("com/sun/tools/javac/util/SharedNameTable",
  53.116 +                    Arrays.asList("freelist"));
  53.117 +        classFieldsToIgnoreMap.
  53.118 +                put("com/sun/tools/javac/util/Log",
  53.119 +                    Arrays.asList("useRawMessages"));
  53.120 +    }
  53.121 +
  53.122 +    private List<String> errors = new ArrayList<>();
  53.123 +
  53.124 +    public static void main(String[] args) {
  53.125 +        try {
  53.126 +            new DetectMutableStaticFields().run();
  53.127 +        } catch (Exception ex) {
  53.128 +            throw new AssertionError(
  53.129 +                    "Exception during test execution with cause ",
  53.130 +                    ex.getCause());
  53.131 +        }
  53.132 +    }
  53.133 +
  53.134 +    private void run()
  53.135 +        throws
  53.136 +            IOException,
  53.137 +            ConstantPoolException,
  53.138 +            InvalidDescriptor,
  53.139 +            URISyntaxException {
  53.140 +
  53.141 +        URI resource = findResource(keyResource);
  53.142 +        if (resource == null) {
  53.143 +            throw new AssertionError("Resource " + keyResource +
  53.144 +                "not found in the class path");
  53.145 +        }
  53.146 +        analyzeResource(resource);
  53.147 +
  53.148 +        if (errors.size() > 0) {
  53.149 +            for (String error: errors) {
  53.150 +                System.err.println(error);
  53.151 +            }
  53.152 +            throw new AssertionError("There are mutable fields, "
  53.153 +                + "please check output");
  53.154 +        }
  53.155 +    }
  53.156 +
  53.157 +    URI findResource(String className) throws URISyntaxException {
  53.158 +        URI uri = getClass().getClassLoader().getResource(className).toURI();
  53.159 +        if (uri.getScheme().equals("jar")) {
  53.160 +            String ssp = uri.getRawSchemeSpecificPart();
  53.161 +            int sep = ssp.lastIndexOf("!");
  53.162 +            uri = new URI(ssp.substring(0, sep));
  53.163 +        } else if (uri.getScheme().equals("file")) {
  53.164 +            uri = new URI(uri.getPath().substring(0,
  53.165 +                    uri.getPath().length() - keyResource.length()));
  53.166 +        }
  53.167 +        return uri;
  53.168 +    }
  53.169 +
  53.170 +    boolean shouldAnalyzePackage(String packageName) {
  53.171 +        for (String aPackage: packagesToSeekFor) {
  53.172 +            if (packageName.contains(aPackage)) {
  53.173 +                return true;
  53.174 +            }
  53.175 +        }
  53.176 +        return false;
  53.177 +    }
  53.178 +
  53.179 +    void analyzeResource(URI resource)
  53.180 +        throws
  53.181 +            IOException,
  53.182 +            ConstantPoolException,
  53.183 +            InvalidDescriptor {
  53.184 +        JavaCompiler tool = ToolProvider.getSystemJavaCompiler();
  53.185 +        StandardJavaFileManager fm = tool.getStandardFileManager(null, null, null);
  53.186 +        JavaFileManager.Location location =
  53.187 +                StandardLocation.locationFor(resource.getPath());
  53.188 +        fm.setLocation(location, com.sun.tools.javac.util.List.of(
  53.189 +                new File(resource.getPath())));
  53.190 +
  53.191 +        for (JavaFileObject file : fm.list(location, "", EnumSet.of(CLASS), true)) {
  53.192 +            String className = fm.inferBinaryName(location, file);
  53.193 +            int index = className.lastIndexOf('.');
  53.194 +            String pckName = index == -1 ? "" : className.substring(0, index);
  53.195 +            if (shouldAnalyzePackage(pckName)) {
  53.196 +                analyzeClassFile(ClassFile.read(file.openInputStream()));
  53.197 +            }
  53.198 +        }
  53.199 +    }
  53.200 +
  53.201 +    List<String> currentFieldsToIgnore;
  53.202 +
  53.203 +    boolean ignoreField(String field) {
  53.204 +        if (currentFieldsToIgnore != null) {
  53.205 +            for (String fieldToIgnore : currentFieldsToIgnore) {
  53.206 +                if (field.equals(fieldToIgnore)) {
  53.207 +                    return true;
  53.208 +                }
  53.209 +            }
  53.210 +        }
  53.211 +        return false;
  53.212 +    }
  53.213 +
  53.214 +    void analyzeClassFile(ClassFile classFileToCheck)
  53.215 +        throws
  53.216 +            IOException,
  53.217 +            ConstantPoolException,
  53.218 +            Descriptor.InvalidDescriptor {
  53.219 +        boolean enumClass =
  53.220 +                (classFileToCheck.access_flags.flags & ACC_ENUM) != 0;
  53.221 +        boolean nonFinalStaticEnumField;
  53.222 +        boolean nonFinalStaticField;
  53.223 +
  53.224 +        currentFieldsToIgnore =
  53.225 +                classFieldsToIgnoreMap.get(classFileToCheck.getName());
  53.226 +
  53.227 +        for (Field field : classFileToCheck.fields) {
  53.228 +            if (ignoreField(field.getName(classFileToCheck.constant_pool))) {
  53.229 +                continue;
  53.230 +            }
  53.231 +            nonFinalStaticEnumField =
  53.232 +                    (field.access_flags.flags & (ACC_ENUM | ACC_FINAL)) == 0;
  53.233 +            nonFinalStaticField =
  53.234 +                    (field.access_flags.flags & ACC_STATIC) != 0 &&
  53.235 +                    (field.access_flags.flags & ACC_FINAL) == 0;
  53.236 +            if (enumClass ? nonFinalStaticEnumField : nonFinalStaticField) {
  53.237 +                errors.add("There is a mutable field named " +
  53.238 +                        field.getName(classFileToCheck.constant_pool) +
  53.239 +                        ", at class " +
  53.240 +                        classFileToCheck.getName());
  53.241 +            }
  53.242 +        }
  53.243 +    }
  53.244 +
  53.245 +}
    54.1 --- a/test/tools/javac/annotations/repeatingAnnotations/MissingDefaultCase1.java	Thu Dec 13 09:05:43 2012 -0800
    54.2 +++ b/test/tools/javac/annotations/repeatingAnnotations/MissingDefaultCase1.java	Fri Dec 14 13:15:39 2012 -0800
    54.3 @@ -20,4 +20,3 @@
    54.4  
    54.5  @Foo @Foo
    54.6  public class MissingDefaultCase1 {}
    54.7 -
    55.1 --- a/test/tools/javac/annotations/repeatingAnnotations/MissingDefaultCase1.out	Thu Dec 13 09:05:43 2012 -0800
    55.2 +++ b/test/tools/javac/annotations/repeatingAnnotations/MissingDefaultCase1.out	Fri Dec 14 13:15:39 2012 -0800
    55.3 @@ -1,2 +1,3 @@
    55.4 +MissingDefaultCase1.java:21:1: compiler.err.duplicate.annotation.invalid.repeated: Foo
    55.5  MissingDefaultCase1.java:12:1: compiler.err.invalid.containedby.annotation.elem.nondefault: FooContainer, other()
    55.6 -1 error
    55.7 +2 errors
    56.1 --- a/test/tools/javac/annotations/repeatingAnnotations/MissingDefaultCase2.java	Thu Dec 13 09:05:43 2012 -0800
    56.2 +++ b/test/tools/javac/annotations/repeatingAnnotations/MissingDefaultCase2.java	Fri Dec 14 13:15:39 2012 -0800
    56.3 @@ -20,4 +20,3 @@
    56.4  
    56.5  @Foo @Foo
    56.6  public class MissingDefaultCase2 {}
    56.7 -
    57.1 --- a/test/tools/javac/annotations/repeatingAnnotations/MissingDefaultCase2.out	Thu Dec 13 09:05:43 2012 -0800
    57.2 +++ b/test/tools/javac/annotations/repeatingAnnotations/MissingDefaultCase2.out	Fri Dec 14 13:15:39 2012 -0800
    57.3 @@ -1,2 +1,3 @@
    57.4 +MissingDefaultCase2.java:21:1: compiler.err.duplicate.annotation.invalid.repeated: Foo
    57.5  MissingDefaultCase2.java:12:1: compiler.err.invalid.containedby.annotation.elem.nondefault: FooContainer, other()
    57.6 -1 error
    57.7 +2 errors
    58.1 --- a/test/tools/javac/annotations/repeatingAnnotations/NoRepeatableAnno.out	Thu Dec 13 09:05:43 2012 -0800
    58.2 +++ b/test/tools/javac/annotations/repeatingAnnotations/NoRepeatableAnno.out	Fri Dec 14 13:15:39 2012 -0800
    58.3 @@ -1,3 +1,3 @@
    58.4 -NoRepeatableAnno.java:11:1: compiler.err.duplicate.annotation.missing.container: Foo
    58.5 -NoRepeatableAnno.java:11:6: compiler.err.duplicate.annotation.missing.container: Foo
    58.6 +NoRepeatableAnno.java:11:1: compiler.err.duplicate.annotation.missing.container: Foo, java.lang.annotation.ContainedBy
    58.7 +NoRepeatableAnno.java:11:6: compiler.err.duplicate.annotation.missing.container: Foo, java.lang.annotation.ContainedBy
    58.8  2 errors
    59.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
    59.2 +++ b/test/tools/javac/annotations/repeatingAnnotations/RepeatingTargetNotAllowed.java	Fri Dec 14 13:15:39 2012 -0800
    59.3 @@ -0,0 +1,45 @@
    59.4 +/*
    59.5 + * Copyright (c) 2012, Oracle and/or its affiliates. All rights reserved.
    59.6 + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
    59.7 + *
    59.8 + * This code is free software; you can redistribute it and/or modify it
    59.9 + * under the terms of the GNU General Public License version 2 only, as
   59.10 + * published by the Free Software Foundation.
   59.11 + *
   59.12 + * This code is distributed in the hope that it will be useful, but WITHOUT
   59.13 + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
   59.14 + * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
   59.15 + * version 2 for more details (a copy is included in the LICENSE file that
   59.16 + * accompanied this code).
   59.17 + *
   59.18 + * You should have received a copy of the GNU General Public License version
   59.19 + * 2 along with this work; if not, write to the Free Software Foundation,
   59.20 + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
   59.21 + *
   59.22 + * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
   59.23 + * or visit www.oracle.com if you need additional information or have any
   59.24 + * questions.
   59.25 + */
   59.26 +
   59.27 +/**
   59.28 + * @test
   59.29 + * @summary Container annotation is not checked for semantic correctness
   59.30 + * @bug 8001114
   59.31 + *
   59.32 + * @compile/fail/ref=RepeatingTargetNotAllowed.out -XDrawDiagnostics RepeatingTargetNotAllowed.java
   59.33 + */
   59.34 +
   59.35 +import java.lang.annotation.*;
   59.36 +
   59.37 +@ContainedBy(Foos.class)
   59.38 +@interface Foo {}
   59.39 +
   59.40 +@ContainerFor(Foo.class)
   59.41 +@Target(ElementType.ANNOTATION_TYPE)
   59.42 +@interface Foos {
   59.43 +    Foo[] value();
   59.44 +}
   59.45 +
   59.46 +public class RepeatingTargetNotAllowed {
   59.47 +    @Foo @Foo int f = 0;
   59.48 +}
    60.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
    60.2 +++ b/test/tools/javac/annotations/repeatingAnnotations/RepeatingTargetNotAllowed.out	Fri Dec 14 13:15:39 2012 -0800
    60.3 @@ -0,0 +1,2 @@
    60.4 +RepeatingTargetNotAllowed.java:44:5: compiler.err.invalid.containedby.annotation.incompatible.target: Foos, Foo
    60.5 +1 error
    61.1 --- a/test/tools/javac/diags/examples/ContainedByNonDefault.java	Thu Dec 13 09:05:43 2012 -0800
    61.2 +++ b/test/tools/javac/diags/examples/ContainedByNonDefault.java	Fri Dec 14 13:15:39 2012 -0800
    61.3 @@ -31,6 +31,4 @@
    61.4  @ContainerFor(Anno.class)
    61.5  @interface Annos { Anno[] value(); String foo(); }
    61.6  
    61.7 -@Anno
    61.8 -@Anno
    61.9  class ContainedByNonDefault { }
    62.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
    62.2 +++ b/test/tools/javac/diags/examples/InvalidDuplicateAnnotation.java	Fri Dec 14 13:15:39 2012 -0800
    62.3 @@ -0,0 +1,40 @@
    62.4 +/*
    62.5 + * Copyright (c) 2012, Oracle and/or its affiliates. All rights reserved.
    62.6 + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
    62.7 + *
    62.8 + * This code is free software; you can redistribute it and/or modify it
    62.9 + * under the terms of the GNU General Public License version 2 only, as
   62.10 + * published by the Free Software Foundation.
   62.11 + *
   62.12 + * This code is distributed in the hope that it will be useful, but WITHOUT
   62.13 + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
   62.14 + * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
   62.15 + * version 2 for more details (a copy is included in the LICENSE file that
   62.16 + * accompanied this code).
   62.17 + *
   62.18 + * You should have received a copy of the GNU General Public License version
   62.19 + * 2 along with this work; if not, write to the Free Software Foundation,
   62.20 + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
   62.21 + *
   62.22 + * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
   62.23 + * or visit www.oracle.com if you need additional information or have any
   62.24 + * questions.
   62.25 + */
   62.26 +
   62.27 +// key: compiler.err.duplicate.annotation.invalid.repeated
   62.28 +// key: compiler.err.invalid.containedby.annotation.elem.nondefault
   62.29 +//
   62.30 +// We need an almost valid containing annotation. The easiest way to get
   62.31 +// one close enough to valid is by forgetting a default.
   62.32 +
   62.33 +import java.lang.annotation.*;
   62.34 +
   62.35 +@ContainedBy(Annos.class)
   62.36 +@interface Anno { }
   62.37 +
   62.38 +@ContainerFor(Anno.class)
   62.39 +@interface Annos { Anno[] value(); String foo(); }
   62.40 +
   62.41 +@Anno
   62.42 +@Anno
   62.43 +class InvalidDuplicateAnnotation { }
    63.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
    63.2 +++ b/test/tools/javac/generics/8004094/B.java	Fri Dec 14 13:15:39 2012 -0800
    63.3 @@ -0,0 +1,47 @@
    63.4 +/*
    63.5 + * Copyright (c) 2012, Oracle and/or its affiliates. All rights reserved.
    63.6 + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
    63.7 + *
    63.8 + * This code is free software; you can redistribute it and/or modify it
    63.9 + * under the terms of the GNU General Public License version 2 only, as
   63.10 + * published by the Free Software Foundation.
   63.11 + *
   63.12 + * This code is distributed in the hope that it will be useful, but WITHOUT
   63.13 + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
   63.14 + * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
   63.15 + * version 2 for more details (a copy is included in the LICENSE file that
   63.16 + * accompanied this code).
   63.17 + *
   63.18 + * You should have received a copy of the GNU General Public License version
   63.19 + * 2 along with this work; if not, write to the Free Software Foundation,
   63.20 + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
   63.21 + *
   63.22 + * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
   63.23 + * or visit www.oracle.com if you need additional information or have any
   63.24 + * questions.
   63.25 + */
   63.26 +abstract class A {
   63.27 +
   63.28 +    private static String s = null;
   63.29 +
   63.30 +    static void test() {
   63.31 +        new Object() {
   63.32 +            void m() {
   63.33 +                Object o = s;
   63.34 +            }
   63.35 +        };
   63.36 +    }
   63.37 +}
   63.38 +
   63.39 +public abstract class B<T> extends A {
   63.40 +
   63.41 +    private static Integer i = null;
   63.42 +
   63.43 +    static void test() {
   63.44 +        new Object() {
   63.45 +            void m() {
   63.46 +                Object o = i;
   63.47 +            }
   63.48 +        };
   63.49 +    }
   63.50 +}
    64.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
    64.2 +++ b/test/tools/javac/generics/8004094/T8004094.java	Fri Dec 14 13:15:39 2012 -0800
    64.3 @@ -0,0 +1,32 @@
    64.4 +/*
    64.5 + * Copyright (c) 2012, Oracle and/or its affiliates. All rights reserved.
    64.6 + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
    64.7 + *
    64.8 + * This code is free software; you can redistribute it and/or modify it
    64.9 + * under the terms of the GNU General Public License version 2 only, as
   64.10 + * published by the Free Software Foundation.
   64.11 + *
   64.12 + * This code is distributed in the hope that it will be useful, but WITHOUT
   64.13 + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
   64.14 + * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
   64.15 + * version 2 for more details (a copy is included in the LICENSE file that
   64.16 + * accompanied this code).
   64.17 + *
   64.18 + * You should have received a copy of the GNU General Public License version
   64.19 + * 2 along with this work; if not, write to the Free Software Foundation,
   64.20 + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
   64.21 + *
   64.22 + * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
   64.23 + * or visit www.oracle.com if you need additional information or have any
   64.24 + * questions.
   64.25 + */
   64.26 +
   64.27 +/*
   64.28 + * @test
   64.29 + * @bug 8004094
   64.30 + * @summary Javac compiler error - synthetic method accessor generated with duplicate name
   64.31 + *
   64.32 + * @compile B.java T8004094.java
   64.33 + */
   64.34 +
   64.35 +public class T8004094 extends B<Object> { }
    65.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
    65.2 +++ b/test/tools/javac/util/list/ListBufferTest.java	Fri Dec 14 13:15:39 2012 -0800
    65.3 @@ -0,0 +1,112 @@
    65.4 +/*
    65.5 + * Copyright (c) 2012, Oracle and/or its affiliates. All rights reserved.
    65.6 + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
    65.7 + *
    65.8 + * This code is free software; you can redistribute it and/or modify it
    65.9 + * under the terms of the GNU General Public License version 2 only, as
   65.10 + * published by the Free Software Foundation.
   65.11 + *
   65.12 + * This code is distributed in the hope that it will be useful, but WITHOUT
   65.13 + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
   65.14 + * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
   65.15 + * version 2 for more details (a copy is included in the LICENSE file that
   65.16 + * accompanied this code).
   65.17 + *
   65.18 + * You should have received a copy of the GNU General Public License version
   65.19 + * 2 along with this work; if not, write to the Free Software Foundation,
   65.20 + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
   65.21 + *
   65.22 + * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
   65.23 + * or visit www.oracle.com if you need additional information or have any
   65.24 + * questions.
   65.25 + */
   65.26 +
   65.27 +/*
   65.28 + * @test
   65.29 + * @bug 8004504
   65.30 + * @summary Ensure that ListBuffer is working properly
   65.31 + */
   65.32 +
   65.33 +import com.sun.tools.javac.util.List;
   65.34 +import com.sun.tools.javac.util.ListBuffer;
   65.35 +import java.util.Iterator;
   65.36 +import java.util.Objects;
   65.37 +
   65.38 +public class ListBufferTest {
   65.39 +    public static void main(String... args) {
   65.40 +        testRemove();
   65.41 +        testCopiedEndsWithList_nil();
   65.42 +    }
   65.43 +
   65.44 +    private static void testCopiedEndsWithList_nil() {
   65.45 +        ListBuffer<String> lb = new ListBuffer<>();
   65.46 +
   65.47 +        lb.add("a");
   65.48 +        lb.add("b");
   65.49 +        lb.add("c");
   65.50 +
   65.51 +        List<String> l1 = lb.toList();
   65.52 +
   65.53 +        assertListEquals(l1, "a", "b", "c");
   65.54 +        assertEndsWithNil(l1);
   65.55 +
   65.56 +        lb.add("d");
   65.57 +
   65.58 +        List<String> l2 = lb.toList();
   65.59 +        assertListEquals(l2, "a", "b", "c", "d");
   65.60 +        assertEndsWithNil(l2);
   65.61 +        assertListEquals(l1, "a", "b", "c");
   65.62 +    }
   65.63 +
   65.64 +    private static void testRemove() {
   65.65 +        ListBuffer<String> lb1 = new ListBuffer<>();
   65.66 +
   65.67 +        lb1.add("a");
   65.68 +        lb1.add("b");
   65.69 +        lb1.add("c");
   65.70 +
   65.71 +        assertListEquals(lb1.toList(), "a", "b", "c");
   65.72 +        assertEquals(lb1.next(), "a");
   65.73 +        assertListEquals(lb1.toList(), "b", "c");
   65.74 +        assertEquals(lb1.next(), "b");
   65.75 +        assertListEquals(lb1.toList(), "c");
   65.76 +        assertEquals(lb1.next(), "c");
   65.77 +        assertListEquals(lb1.toList());
   65.78 +        assertEquals(lb1.next(), null);
   65.79 +
   65.80 +        lb1.add("d");
   65.81 +
   65.82 +        assertEquals(lb1.next(), "d");
   65.83 +    }
   65.84 +
   65.85 +    private static void assertEndsWithNil(List<?> list) {
   65.86 +        while (!list.isEmpty()) {
   65.87 +            list = list.tail;
   65.88 +        }
   65.89 +
   65.90 +        if (list != List.nil()) throw new IllegalStateException("Not ending with List.nil()");
   65.91 +    }
   65.92 +
   65.93 +    private static <T> void assertListEquals(Iterable<T> list, T... data) {
   65.94 +        int i = 0;
   65.95 +        Iterator<T> it = list.iterator();
   65.96 +
   65.97 +        while (it.hasNext() && i < data.length) {
   65.98 +            assertEquals(it.next(), data[i++]);
   65.99 +        }
  65.100 +
  65.101 +        if (it.hasNext()) {
  65.102 +            throw new IllegalStateException("Too many elements in the list");
  65.103 +        }
  65.104 +
  65.105 +        if (i < data.length) {
  65.106 +            throw new IllegalStateException("Too few elements in the list");
  65.107 +        }
  65.108 +    }
  65.109 +
  65.110 +    private static void assertEquals(Object expected, Object actual) {
  65.111 +        if (!Objects.equals(expected, actual)) {
  65.112 +            throw new IllegalStateException("Incorrect content. Expected: " + expected + ", actual: " + actual);
  65.113 +        }
  65.114 +    }
  65.115 +}

mercurial