Merged trunk changes jshell_support_jdk9
authorSvata Dedic <sdedic@netbeans.org>
Fri, 02 Sep 2016 23:58:32 +0200
branchjshell_support_jdk9
changeset 4861979a22ff13d4
parent 4851 151fd13d5839
parent 4857 5adb7ccf0e8e
Merged trunk changes
src/jdk.compiler/share/classes/com/sun/tools/javac/code/Symbol.java
     1.1 --- a/make/netbeans/nb-javac/nbproject/build-impl.xml	Mon Aug 22 16:08:34 2016 +0200
     1.2 +++ b/make/netbeans/nb-javac/nbproject/build-impl.xml	Fri Sep 02 23:58:32 2016 +0200
     1.3 @@ -159,6 +159,7 @@
     1.4          <property name="application.args" value=""/>
     1.5          <property name="source.encoding" value="${file.encoding}"/>
     1.6          <property name="runtime.encoding" value="${source.encoding}"/>
     1.7 +        <property name="manifest.encoding" value="${source.encoding}"/>
     1.8          <condition property="javadoc.encoding.used" value="${javadoc.encoding}">
     1.9              <and>
    1.10                  <isset property="javadoc.encoding"/>
    1.11 @@ -846,7 +847,7 @@
    1.12                      </chainedmapper>
    1.13                  </pathconvert>
    1.14                  <taskdef classname="org.netbeans.modules.java.j2seproject.copylibstask.CopyLibs" classpath="${libs.CopyLibs.classpath}" name="copylibs"/>
    1.15 -                <copylibs compress="${jar.compress}" excludeFromCopy="${copylibs.excludes}" index="${jar.index}" indexMetaInf="${jar.index.metainf}" jarfile="${dist.jar}" manifest="@{manifest}" rebase="${copylibs.rebase}" runtimeclasspath="${run.classpath.without.build.classes.dir}">
    1.16 +                <copylibs compress="${jar.compress}" excludeFromCopy="${copylibs.excludes}" index="${jar.index}" indexMetaInf="${jar.index.metainf}" jarfile="${dist.jar}" manifest="@{manifest}" manifestencoding="UTF-8" rebase="${copylibs.rebase}" runtimeclasspath="${run.classpath.without.build.classes.dir}">
    1.17                      <fileset dir="${build.classes.dir}" excludes="${dist.archive.excludes}"/>
    1.18                      <manifest>
    1.19                          <attribute name="Class-Path" value="${jar.classpath}"/>
    1.20 @@ -858,7 +859,7 @@
    1.21      </target>
    1.22      <target name="-init-presetdef-jar">
    1.23          <presetdef name="jar" uri="http://www.netbeans.org/ns/j2se-project/1">
    1.24 -            <jar compress="${jar.compress}" index="${jar.index}" jarfile="${dist.jar}">
    1.25 +            <jar compress="${jar.compress}" index="${jar.index}" jarfile="${dist.jar}" manifestencoding="UTF-8">
    1.26                  <j2seproject1:fileset dir="${build.classes.dir}" excludes="${dist.archive.excludes}"/>
    1.27              </jar>
    1.28          </presetdef>
    1.29 @@ -984,15 +985,15 @@
    1.30      </target>
    1.31      <target depends="init" if="do.archive+manifest.available" name="-do-jar-copy-manifest">
    1.32          <tempfile deleteonexit="true" destdir="${build.dir}" property="tmp.manifest.file"/>
    1.33 -        <copy file="${manifest.file}" tofile="${tmp.manifest.file}"/>
    1.34 +        <copy encoding="${manifest.encoding}" file="${manifest.file}" outputencoding="UTF-8" tofile="${tmp.manifest.file}"/>
    1.35      </target>
    1.36      <target depends="init,-do-jar-create-manifest,-do-jar-copy-manifest" if="do.archive+main.class.available" name="-do-jar-set-mainclass">
    1.37 -        <manifest file="${tmp.manifest.file}" mode="update">
    1.38 +        <manifest encoding="UTF-8" file="${tmp.manifest.file}" mode="update">
    1.39              <attribute name="Main-Class" value="${main.class}"/>
    1.40          </manifest>
    1.41      </target>
    1.42      <target depends="init,-do-jar-create-manifest,-do-jar-copy-manifest" if="do.archive+profile.available" name="-do-jar-set-profile">
    1.43 -        <manifest file="${tmp.manifest.file}" mode="update">
    1.44 +        <manifest encoding="UTF-8" file="${tmp.manifest.file}" mode="update">
    1.45              <attribute name="Profile" value="${javac.profile}"/>
    1.46          </manifest>
    1.47      </target>
    1.48 @@ -1000,7 +1001,7 @@
    1.49          <basename file="${application.splash}" property="splashscreen.basename"/>
    1.50          <mkdir dir="${build.classes.dir}/META-INF"/>
    1.51          <copy failonerror="false" file="${application.splash}" todir="${build.classes.dir}/META-INF"/>
    1.52 -        <manifest file="${tmp.manifest.file}" mode="update">
    1.53 +        <manifest encoding="UTF-8" file="${tmp.manifest.file}" mode="update">
    1.54              <attribute name="SplashScreen-Image" value="META-INF/${splashscreen.basename}"/>
    1.55          </manifest>
    1.56      </target>
     2.1 --- a/make/netbeans/nb-javac/nbproject/genfiles.properties	Mon Aug 22 16:08:34 2016 +0200
     2.2 +++ b/make/netbeans/nb-javac/nbproject/genfiles.properties	Fri Sep 02 23:58:32 2016 +0200
     2.3 @@ -4,5 +4,5 @@
     2.4  # This file is used by a NetBeans-based IDE to track changes in generated files such as build-impl.xml.
     2.5  # Do not edit this file. You may delete it but then the IDE will never regenerate such files for you.
     2.6  nbproject/build-impl.xml.data.CRC32=716b253f
     2.7 -nbproject/build-impl.xml.script.CRC32=5b505b7d
     2.8 -nbproject/build-impl.xml.stylesheet.CRC32=2b19b096@1.80.0.48
     2.9 +nbproject/build-impl.xml.script.CRC32=18f4d488
    2.10 +nbproject/build-impl.xml.stylesheet.CRC32=042cf44b@1.80.0.48
     3.1 --- a/src/jdk.compiler/share/classes/com/sun/tools/javac/api/JavacTaskImpl.java	Mon Aug 22 16:08:34 2016 +0200
     3.2 +++ b/src/jdk.compiler/share/classes/com/sun/tools/javac/api/JavacTaskImpl.java	Fri Sep 02 23:58:32 2016 +0200
     3.3 @@ -746,6 +746,8 @@
     3.4          compiler.deferredDiagnosticHandler = null;
     3.5          Enter enter = Enter.instance(context);
     3.6          enter.shadowTypeEnvs(true);
     3.7 +        ArgumentAttr argumentAttr = ArgumentAttr.instance(context);
     3.8 +        ArgumentAttr.LocalCacheContext cacheContext = argumentAttr.withLocalCacheContext();
     3.9          try {
    3.10              Type type = tree instanceof JCExpression
    3.11                      ? attr.attribExpr(tree, env, Type.noType)
    3.12 @@ -754,6 +756,7 @@
    3.13                  compiler.processAnnotations(List.<JCCompilationUnit>nil());
    3.14              return type;
    3.15          } finally {
    3.16 +            cacheContext.leave();
    3.17              enter.shadowTypeEnvs(false);
    3.18              compiler.deferredDiagnosticHandler = deferredHandler;
    3.19              log.popDiagnosticHandler(discardHandler);
    3.20 @@ -770,12 +773,15 @@
    3.21          compiler.deferredDiagnosticHandler = null;
    3.22          Enter enter = Enter.instance(context);
    3.23          enter.shadowTypeEnvs(true);
    3.24 +        ArgumentAttr argumentAttr = ArgumentAttr.instance(context);
    3.25 +        ArgumentAttr.LocalCacheContext cacheContext = argumentAttr.withLocalCacheContext();
    3.26          try {
    3.27              Env<AttrContext> ret = tree instanceof JCExpression ? attr.attribExprToTree(tree, env, to) : attr.attribStatToTree(tree, env, to);
    3.28              if (!compiler.skipAnnotationProcessing && compiler.deferredDiagnosticHandler != null && compiler.toProcessAnnotations.nonEmpty())
    3.29                  compiler.processAnnotations(List.<JCCompilationUnit>nil());
    3.30              return new JavacScope(ret);
    3.31          } finally {
    3.32 +            cacheContext.leave();
    3.33              enter.shadowTypeEnvs(false);
    3.34              compiler.deferredDiagnosticHandler = deferredHandler;
    3.35              log.popDiagnosticHandler(discardHandler);
     4.1 --- a/src/jdk.compiler/share/classes/com/sun/tools/javac/api/JavacTrees.java	Mon Aug 22 16:08:34 2016 +0200
     4.2 +++ b/src/jdk.compiler/share/classes/com/sun/tools/javac/api/JavacTrees.java	Fri Sep 02 23:58:32 2016 +0200
     4.3 @@ -49,7 +49,6 @@
     4.4  import javax.tools.Diagnostic;
     4.5  import javax.tools.FileObject;
     4.6  import javax.tools.ForwardingFileObject;
     4.7 -import javax.tools.ForwardingJavaFileObject;
     4.8  import javax.tools.JavaCompiler;
     4.9  import javax.tools.JavaFileManager;
    4.10  import javax.tools.JavaFileObject;
    4.11 @@ -62,6 +61,7 @@
    4.12  import com.sun.source.tree.CompilationUnitTree;
    4.13  import com.sun.source.tree.Scope;
    4.14  import com.sun.source.tree.Tree;
    4.15 +import com.sun.source.tree.VariableTree;
    4.16  import com.sun.source.util.DocSourcePositions;
    4.17  import com.sun.source.util.DocTreePath;
    4.18  import com.sun.source.util.DocTreeScanner;
    4.19 @@ -141,6 +141,7 @@
    4.20  
    4.21  import static com.sun.tools.javac.code.Kinds.Kind.*;
    4.22  import static com.sun.tools.javac.code.TypeTag.*;
    4.23 +import com.sun.tools.javac.comp.ArgumentAttr;
    4.24  import com.sun.tools.javac.comp.TypeEnter;
    4.25  
    4.26  /**
    4.27 @@ -162,6 +163,7 @@
    4.28      private TypeEnter typeEnter;
    4.29      private MemberEnter memberEnter;
    4.30      private Attr attr;
    4.31 +    private ArgumentAttr argumentAttr;
    4.32      private TreeMaker treeMaker;
    4.33      private JavacElements elements;
    4.34      private JavacTaskImpl javacTaskImpl;
    4.35 @@ -208,6 +210,7 @@
    4.36          //Need ensure ClassReader is initialized before Symtab:
    4.37          ClassReader.instance(context);
    4.38          attr = Attr.instance(context);
    4.39 +        argumentAttr = ArgumentAttr.instance(context);
    4.40          enter = Enter.instance(context);
    4.41          elements = JavacElements.instance(context);
    4.42          log = Log.instance(context);
    4.43 @@ -971,12 +974,14 @@
    4.44          Log.DeferredDiagnosticHandler deferredHandler = compiler.deferredDiagnosticHandler;
    4.45          compiler.deferredDiagnosticHandler = null;
    4.46          enter.shadowTypeEnvs(true);
    4.47 +        ArgumentAttr.LocalCacheContext cacheContext = argumentAttr.withLocalCacheContext();
    4.48          try {
    4.49              Env<AttrContext> ret = attr.attribStatToTree(stat, env, tree);
    4.50              if (!compiler.skipAnnotationProcessing && compiler.deferredDiagnosticHandler != null && compiler.toProcessAnnotations.nonEmpty())
    4.51                  compiler.processAnnotations(List.<JCCompilationUnit>nil());
    4.52              return ret;
    4.53          } finally {
    4.54 +            cacheContext.leave();
    4.55              enter.shadowTypeEnvs(false);
    4.56              compiler.deferredDiagnosticHandler = deferredHandler;
    4.57              log.popDiagnosticHandler(discardHandler);
    4.58 @@ -990,12 +995,14 @@
    4.59          Log.DeferredDiagnosticHandler deferredHandler = compiler.deferredDiagnosticHandler;
    4.60          compiler.deferredDiagnosticHandler = null;
    4.61          enter.shadowTypeEnvs(true);
    4.62 +        ArgumentAttr.LocalCacheContext cacheContext = argumentAttr.withLocalCacheContext();
    4.63          try {
    4.64              Env<AttrContext> ret = attr.attribExprToTree(expr, env, tree);
    4.65              if (!compiler.skipAnnotationProcessing && compiler.deferredDiagnosticHandler != null && compiler.toProcessAnnotations.nonEmpty())
    4.66                  compiler.processAnnotations(List.<JCCompilationUnit>nil());
    4.67              return ret;
    4.68          } finally {
    4.69 +            cacheContext.leave();
    4.70              enter.shadowTypeEnvs(false);
    4.71              compiler.deferredDiagnosticHandler = deferredHandler;
    4.72              log.popDiagnosticHandler(discardHandler);
    4.73 @@ -1123,6 +1130,15 @@
    4.74                  leafCopy = t2;
    4.75              return t2;
    4.76          }
    4.77 +
    4.78 +        @Override
    4.79 +        public JCTree visitVariable(VariableTree node, JCTree p) {
    4.80 +            JCTree var = super.visitVariable(node, p);
    4.81 +            if (node instanceof JCVariableDecl && ((JCVariableDecl)node).sym != null) {
    4.82 +                ((JCVariableDecl)var).mods.flags |= ((JCVariableDecl)node).sym.flags_field & Flags.EFFECTIVELY_FINAL;
    4.83 +            }
    4.84 +            return var;
    4.85 +        }
    4.86      }
    4.87  
    4.88      protected Copier createCopier(TreeMaker maker) {
     5.1 --- a/src/jdk.compiler/share/classes/com/sun/tools/javac/code/Symbol.java	Mon Aug 22 16:08:34 2016 +0200
     5.2 +++ b/src/jdk.compiler/share/classes/com/sun/tools/javac/code/Symbol.java	Fri Sep 02 23:58:32 2016 +0200
     5.3 @@ -487,10 +487,9 @@
     5.4  
     5.5      private boolean hiddenIn(ClassSymbol clazz, Types types) {
     5.6          Symbol sym = hiddenInInternal(clazz, types);
     5.7 -        Assert.check(sym != null, "the result of hiddenInInternal() can't be null");
     5.8          /* If we find the current symbol then there is no symbol hiding it
     5.9           */
    5.10 -        return sym != this;
    5.11 +        return sym != null && sym != this;
    5.12      }
    5.13  
    5.14      /** This method looks in the supertypes graph that has the current class as the
     6.1 --- a/src/jdk.compiler/share/classes/com/sun/tools/javac/code/TypeAnnotations.java	Mon Aug 22 16:08:34 2016 +0200
     6.2 +++ b/src/jdk.compiler/share/classes/com/sun/tools/javac/code/TypeAnnotations.java	Fri Sep 02 23:58:32 2016 +0200
     6.3 @@ -245,9 +245,7 @@
     6.4              // Type annotations and declaration annotations on an
     6.5              // Element
     6.6          } else {
     6.7 -            Assert.error("annotationTargetType(): unrecognized Attribute name " + e.value.name +
     6.8 -                    " (" + e.value.name.getClass() + ")");
     6.9 -            return AnnotationType.DECLARATION;
    6.10 +            return AnnotationType.NONE;
    6.11          }
    6.12          return AnnotationType.NONE;
    6.13      }
    6.14 @@ -1394,15 +1392,6 @@
    6.15          }
    6.16  
    6.17  
    6.18 -        @Override
    6.19 -        public void visitErroneous(JCErroneous tree) {
    6.20 -            if (tree.errs != null) {
    6.21 -                for (List<? extends JCTree> l = tree.errs; l.nonEmpty(); l = l.tail) {
    6.22 -                    super.scan(l.head);
    6.23 -                }
    6.24 -            }
    6.25 -        }
    6.26 -        
    6.27          private void findTypeCompoundPosition(JCTree tree, JCTree frame, List<Attribute.TypeCompound> annotations) {
    6.28              if (!annotations.isEmpty()) {
    6.29                  final TypeAnnotationPosition p =
     7.1 --- a/src/jdk.compiler/share/classes/com/sun/tools/javac/code/Types.java	Mon Aug 22 16:08:34 2016 +0200
     7.2 +++ b/src/jdk.compiler/share/classes/com/sun/tools/javac/code/Types.java	Fri Sep 02 23:58:32 2016 +0200
     7.3 @@ -185,6 +185,172 @@
     7.4      }
     7.5      // </editor-fold>
     7.6  
     7.7 +    // <editor-fold defaultstate="collapsed" desc="projections">
     7.8 +    class TypeProjection extends TypeMapping<Boolean> {
     7.9 +
    7.10 +        List<Type> vars;
    7.11 +        Set<Type> seen = new HashSet<>();
    7.12 +
    7.13 +        public TypeProjection(List<Type> vars) {
    7.14 +            this.vars = vars;
    7.15 +        }
    7.16 +
    7.17 +        @Override
    7.18 +        public Type visitClassType(ClassType t, Boolean upward) {
    7.19 +            if (upward && !t.isCompound() && t.tsym.name.isEmpty()) {
    7.20 +                //lift anonymous class type to first supertype (class or interface)
    7.21 +                return directSupertypes(t).last();
    7.22 +            } else if (t.isCompound()) {
    7.23 +                List<Type> components = directSupertypes(t);
    7.24 +                List<Type> components1 = components.stream()
    7.25 +                        .map(c -> c.map(this, upward))
    7.26 +                        .collect(List.collector());
    7.27 +                if (components == components1) return t;
    7.28 +                else return makeIntersectionType(components1);
    7.29 +            } else {
    7.30 +                Type outer = t.getEnclosingType();
    7.31 +                Type outer1 = visit(outer, upward);
    7.32 +                List<Type> typarams = t.getTypeArguments();
    7.33 +                List<Type> typarams1 = typarams.stream()
    7.34 +                        .map(ta -> mapTypeArgument(ta, upward))
    7.35 +                        .collect(List.collector());
    7.36 +                if (typarams1.stream().anyMatch(ta -> ta.hasTag(BOT))) {
    7.37 +                    //not defined
    7.38 +                    return syms.botType;
    7.39 +                }
    7.40 +                if (outer1 == outer && typarams1 == typarams) return t;
    7.41 +                else return new ClassType(outer1, typarams1, t.tsym, t.metadata) {
    7.42 +                    @Override
    7.43 +                    protected boolean needsStripping() {
    7.44 +                        return true;
    7.45 +                    }
    7.46 +                };
    7.47 +            }
    7.48 +        }
    7.49 +
    7.50 +        protected Type makeWildcard(Type upper, Type lower) {
    7.51 +            BoundKind bk;
    7.52 +            Type bound;
    7.53 +            if (upper.hasTag(BOT)) {
    7.54 +                upper = syms.objectType;
    7.55 +            }
    7.56 +            boolean isUpperObject = isSameType(upper, syms.objectType);
    7.57 +            if (!lower.hasTag(BOT) && isUpperObject) {
    7.58 +                bound = lower;
    7.59 +                bk = SUPER;
    7.60 +            } else {
    7.61 +                bound = upper;
    7.62 +                bk = isUpperObject ? UNBOUND : EXTENDS;
    7.63 +            }
    7.64 +            return new WildcardType(bound, bk, syms.boundClass);
    7.65 +        }
    7.66 +
    7.67 +        @Override
    7.68 +        public Type visitTypeVar(TypeVar t, Boolean upward) {
    7.69 +            if (vars.contains(t)) {
    7.70 +                try {
    7.71 +                    if (seen.add(t)) {
    7.72 +                        return upward ?
    7.73 +                                t.getUpperBound().map(this, upward) :
    7.74 +                                t.getLowerBound().map(this, upward);
    7.75 +                    } else {
    7.76 +                        //cycle
    7.77 +                        return syms.objectType;
    7.78 +                    }
    7.79 +                } finally {
    7.80 +                    seen.remove(t);
    7.81 +                }
    7.82 +            } else {
    7.83 +                return t;
    7.84 +            }
    7.85 +        }
    7.86 +
    7.87 +        @Override
    7.88 +        public Type visitWildcardType(WildcardType wt, Boolean upward) {
    7.89 +            if (upward) {
    7.90 +                return wt.isExtendsBound() ?
    7.91 +                        wt.type.map(this, upward) :
    7.92 +                        syms.objectType;
    7.93 +            } else {
    7.94 +                return wt.isSuperBound() ?
    7.95 +                        wt.type.map(this, upward) :
    7.96 +                        syms.botType;
    7.97 +            }
    7.98 +        }
    7.99 +
   7.100 +        private Type mapTypeArgument(Type t, boolean upward) {
   7.101 +            if (!t.containsAny(vars)) {
   7.102 +                return t;
   7.103 +            } else if (!t.hasTag(WILDCARD) && !upward) {
   7.104 +                //not defined
   7.105 +                return syms.botType;
   7.106 +            } else {
   7.107 +                Type upper = t.map(this, upward);
   7.108 +                Type lower = t.map(this, !upward);
   7.109 +                return makeWildcard(upper, lower);
   7.110 +            }
   7.111 +        }
   7.112 +    }
   7.113 +
   7.114 +    public Type upward(Type t, List<Type> vars) {
   7.115 +        return t.map(new TypeProjection(vars), true);
   7.116 +    }
   7.117 +    
   7.118 +    public List<Type> captures(Type t) {
   7.119 +        CaptureScanner cs = new CaptureScanner();
   7.120 +        Set<Type> captures = new HashSet<>();
   7.121 +        cs.visit(t, captures);
   7.122 +        return List.from(captures);
   7.123 +    }
   7.124 +
   7.125 +    class CaptureScanner extends SimpleVisitor<Void, Set<Type>> {
   7.126 +
   7.127 +        @Override
   7.128 +        public Void visitType(Type t, Set<Type> types) {
   7.129 +            return null;
   7.130 +        }
   7.131 +
   7.132 +        @Override
   7.133 +        public Void visitClassType(ClassType t, Set<Type> seen) {
   7.134 +            if (t.isCompound()) {
   7.135 +                directSupertypes(t).forEach(s -> visit(s, seen));
   7.136 +            } else {
   7.137 +                t.allparams().forEach(ta -> visit(ta, seen));
   7.138 +            }
   7.139 +            return null;
   7.140 +        }
   7.141 +
   7.142 +        @Override
   7.143 +        public Void visitArrayType(ArrayType t, Set<Type> seen) {
   7.144 +            return visit(t.elemtype, seen);
   7.145 +        }
   7.146 +
   7.147 +        @Override
   7.148 +        public Void visitWildcardType(WildcardType t, Set<Type> seen) {
   7.149 +            visit(t.type, seen);
   7.150 +            return null;
   7.151 +        }
   7.152 +
   7.153 +        @Override
   7.154 +        public Void visitTypeVar(TypeVar t, Set<Type> seen) {
   7.155 +            if ((t.tsym.flags() & SYNTHETIC) != 0 && seen.add(t)) {
   7.156 +                visit(t.getUpperBound(), seen);
   7.157 +            }
   7.158 +            return null;
   7.159 +        }
   7.160 +
   7.161 +        @Override
   7.162 +        public Void visitCapturedType(CapturedType t, Set<Type> seen) {
   7.163 +            if (seen.add(t)) {
   7.164 +                visit(t.getUpperBound(), seen);
   7.165 +                visit(t.getLowerBound(), seen);
   7.166 +            }
   7.167 +            return null;
   7.168 +        }
   7.169 +    }
   7.170 +
   7.171 +    // </editor-fold>
   7.172 +
   7.173      // <editor-fold defaultstate="collapsed" desc="isUnbounded">
   7.174      /**
   7.175       * Checks that all the arguments to a class are unbounded
     8.1 --- a/src/jdk.compiler/share/classes/com/sun/tools/javac/comp/Analyzer.java	Mon Aug 22 16:08:34 2016 +0200
     8.2 +++ b/src/jdk.compiler/share/classes/com/sun/tools/javac/comp/Analyzer.java	Fri Sep 02 23:58:32 2016 +0200
     8.3 @@ -276,10 +276,11 @@
     8.4          @Override
     8.5          boolean match (JCNewClass tree){
     8.6              Type clazztype = tree.clazz.type;
     8.7 -            return tree.def != null &&
     8.8 +            return tree.def != null && clazztype != null &&
     8.9                      clazztype.hasTag(CLASS) &&
    8.10                      types.isFunctionalInterface(clazztype.tsym) &&
    8.11 -                    decls(tree.def).length() == 1;
    8.12 +                    decls(tree.def).length() == 1
    8.13 +                    && decls(tree.def).head.hasTag(METHODDEF);
    8.14          }
    8.15          //where
    8.16              private List<JCTree> decls(JCClassDecl decl) {
     9.1 --- a/src/jdk.compiler/share/classes/com/sun/tools/javac/comp/ArgumentAttr.java	Mon Aug 22 16:08:34 2016 +0200
     9.2 +++ b/src/jdk.compiler/share/classes/com/sun/tools/javac/comp/ArgumentAttr.java	Fri Sep 02 23:58:32 2016 +0200
     9.3 @@ -161,7 +161,7 @@
     9.4       * the risk of polluting enclosing contexts. This is useful when attempting speculative
     9.5       * attribution of potentially erroneous expressions, which could end up polluting the cache.
     9.6       */
     9.7 -    LocalCacheContext withLocalCacheContext() {
     9.8 +    public LocalCacheContext withLocalCacheContext() {
     9.9          return new LocalCacheContext();
    9.10      }
    9.11  
    9.12 @@ -169,7 +169,7 @@
    9.13       * Local cache context; this class keeps track of the previous cache and reverts to it
    9.14       * when the {@link LocalCacheContext#leave()} method is called.
    9.15       */
    9.16 -    class LocalCacheContext {
    9.17 +    public class LocalCacheContext {
    9.18          Map<UniquePos, ArgumentType<?>> prevCache;
    9.19  
    9.20          public LocalCacheContext() {
    10.1 --- a/src/jdk.compiler/share/classes/com/sun/tools/javac/comp/Attr.java	Mon Aug 22 16:08:34 2016 +0200
    10.2 +++ b/src/jdk.compiler/share/classes/com/sun/tools/javac/comp/Attr.java	Fri Sep 02 23:58:32 2016 +0200
    10.3 @@ -428,9 +428,11 @@
    10.4  
    10.5      public static class BreakAttr extends RuntimeException {
    10.6          static final long serialVersionUID = -6924771130405446405L;
    10.7 -        private Env<AttrContext> env;
    10.8 -        private BreakAttr(Env<AttrContext> env) {
    10.9 +        private final Env<AttrContext> env;
   10.10 +        private final Type result;
   10.11 +        private BreakAttr(Env<AttrContext> env, Type result) {
   10.12              this.env = env;
   10.13 +            this.result = result;
   10.14          }
   10.15      }
   10.16  
   10.17 @@ -635,7 +637,7 @@
   10.18              resultInfo.attr(tree, env);
   10.19              if (tree == breakTree &&
   10.20                      resultInfo.checkContext.deferredAttrContext().mode == AttrMode.CHECK) {
   10.21 -                throw new BreakAttr(copyEnv(env));
   10.22 +                throw new BreakAttr(copyEnv(env), result);
   10.23              }
   10.24              return result;
   10.25          } catch (CompletionFailure ex) {
   10.26 @@ -734,11 +736,18 @@
   10.27      KindSelector attribArgs(KindSelector initialKind, List<JCExpression> trees, Env<AttrContext> env, ListBuffer<Type> argtypes) {
   10.28          KindSelector kind = initialKind;
   10.29          for (JCExpression arg : trees) {
   10.30 -            Type argtype = chk.checkNonVoid(arg, attribTree(arg, env, allowPoly ? methodAttrInfo : unknownExprInfo));
   10.31 -            if (argtype.hasTag(DEFERRED)) {
   10.32 -                kind = KindSelector.of(KindSelector.POLY, kind);
   10.33 +            try {
   10.34 +                Type argtype = chk.checkNonVoid(arg, attribTree(arg, env, allowPoly ? methodAttrInfo : unknownExprInfo));
   10.35 +                if (argtype.hasTag(DEFERRED)) {
   10.36 +                    kind = KindSelector.of(KindSelector.POLY, kind);
   10.37 +                }
   10.38 +                argtypes.append(argtype);
   10.39 +            } catch (BreakAttr ba) {
   10.40 +                if (ba.result != null && !ba.result.hasTag(PACKAGE) && !ba.result.hasTag(METHOD) && env.tree == ba.env.tree) {
   10.41 +                    argtypes.append(chk.checkNonVoid(arg, ba.result));
   10.42 +                }
   10.43 +                throw ba;
   10.44              }
   10.45 -            argtypes.append(argtype);
   10.46          }
   10.47          return kind;
   10.48      }
   10.49 @@ -815,6 +824,9 @@
   10.50                  = deferredLintHandler.setPos(variable.pos());
   10.51  
   10.52          try {
   10.53 +            if (variable.init == null) {
   10.54 +                return null;
   10.55 +            }
   10.56              Type itype = attribExpr(variable.init, env, type);
   10.57              if (itype.constValue() != null) {
   10.58                  return coerce(itype, type).constValue();
   10.59 @@ -1341,7 +1353,7 @@
   10.60                  }
   10.61                  if (c == breakTree &&
   10.62                          resultInfo.checkContext.deferredAttrContext().mode == AttrMode.CHECK)
   10.63 -                    throw new BreakAttr(env);
   10.64 +                    throw new BreakAttr(env, null);
   10.65                  Env<AttrContext> caseEnv =
   10.66                      switchEnv.dup(c, env.info.dup(switchEnv.info.scope.dup()));
   10.67                  boolean baCatched = false;
   10.68 @@ -2573,7 +2585,7 @@
   10.69                  JCBlock body = (JCBlock)that.body;
   10.70                  if (body == breakTree &&
   10.71                          resultInfo.checkContext.deferredAttrContext().mode == AttrMode.CHECK) {
   10.72 -                    throw new BreakAttr(copyEnv(localEnv));
   10.73 +                    throw new BreakAttr(copyEnv(localEnv), null);
   10.74                  }
   10.75                  attribStats(body.stats, localEnv);
   10.76              }
    11.1 --- a/src/jdk.compiler/share/classes/com/sun/tools/javac/comp/Check.java	Mon Aug 22 16:08:34 2016 +0200
    11.2 +++ b/src/jdk.compiler/share/classes/com/sun/tools/javac/comp/Check.java	Fri Sep 02 23:58:32 2016 +0200
    11.3 @@ -3324,7 +3324,9 @@
    11.4              for (JCTree def : tree.defs) {
    11.5                  if (!def.hasTag(METHODDEF)) continue;
    11.6                  JCMethodDecl meth = (JCMethodDecl)def;
    11.7 -                checkAnnotationResType(meth.pos(), meth.restype.type);
    11.8 +                if (meth.restype != null) {
    11.9 +                    checkAnnotationResType(meth.pos(), meth.restype.type);
   11.10 +                }
   11.11              }
   11.12          } finally {
   11.13              tree.sym.flags_field &= ~LOCKED;
    12.1 --- a/src/jdk.compiler/share/classes/com/sun/tools/javac/comp/Resolve.java	Mon Aug 22 16:08:34 2016 +0200
    12.2 +++ b/src/jdk.compiler/share/classes/com/sun/tools/javac/comp/Resolve.java	Fri Sep 02 23:58:32 2016 +0200
    12.3 @@ -1385,7 +1385,7 @@
    12.4          Symbol bestSoFar = varNotFound;
    12.5          Env<AttrContext> env1 = env;
    12.6          boolean staticOnly = false;
    12.7 -        while (env1.outer != null) {
    12.8 +        while (env1.outer != null && env1.enclClass.sym != null) {
    12.9              Symbol sym = null;
   12.10              if (isStatic(env1)) staticOnly = true;
   12.11              for (Symbol s : env1.info.scope.getSymbolsByName(name)) {
    13.1 --- a/src/jdk.compiler/share/classes/com/sun/tools/javac/jvm/ClassWriter.java	Mon Aug 22 16:08:34 2016 +0200
    13.2 +++ b/src/jdk.compiler/share/classes/com/sun/tools/javac/jvm/ClassWriter.java	Fri Sep 02 23:58:32 2016 +0200
    13.3 @@ -903,8 +903,13 @@
    13.4          }
    13.5          public void visitArray(Attribute.Array array) {
    13.6              databuf.appendByte('[');
    13.7 -            databuf.appendChar(array.values.length);
    13.8 +            int count = array.values.length;
    13.9              for (Attribute a : array.values) {
   13.10 +                if (a instanceof Attribute.Error) count--;
   13.11 +            }
   13.12 +            databuf.appendChar(count);
   13.13 +            for (Attribute a : array.values) {
   13.14 +                if (a instanceof Attribute.Error) continue;
   13.15                  a.accept(this);
   13.16              }
   13.17          }
    14.1 --- a/src/jdk.compiler/share/classes/com/sun/tools/javac/model/JavacElements.java	Mon Aug 22 16:08:34 2016 +0200
    14.2 +++ b/src/jdk.compiler/share/classes/com/sun/tools/javac/model/JavacElements.java	Fri Sep 02 23:58:32 2016 +0200
    14.3 @@ -109,11 +109,18 @@
    14.4  
    14.5      public ClassSymbol getTypeElementByBinaryName (final CharSequence binaryName) {
    14.6          final String strName = binaryName instanceof String ? (String) binaryName : binaryName.toString();
    14.7 -        int index = strName.indexOf('$');   //NOI18N
    14.8 -        final String owner = index < 0 ? strName : strName.substring(0,index);
    14.9 -        return SourceVersion.isName(owner)
   14.10 -            ? binaryNameToClassSymbol(strName, owner)
   14.11 -            : null;
   14.12 +        int index = strName.lastIndexOf('.');    //NOI18N
   14.13 +        do {
   14.14 +            index = strName.indexOf('$', index+1);   //NOI18N
   14.15 +            final String owner = index < 0 ? strName : strName.substring(0,index);
   14.16 +            if (SourceVersion.isName(owner)) {
   14.17 +                ClassSymbol clz = binaryNameToClassSymbol(strName, owner);
   14.18 +                if (clz != null) {
   14.19 +                    return clz;
   14.20 +                }
   14.21 +            }
   14.22 +        } while (index >= 0);
   14.23 +        return null;
   14.24      }
   14.25  
   14.26      private ClassSymbol binaryNameToClassSymbol (final String binaryName, final String owner) {
    15.1 --- a/src/jdk.compiler/share/classes/com/sun/tools/javac/parser/JavacParser.java	Mon Aug 22 16:08:34 2016 +0200
    15.2 +++ b/src/jdk.compiler/share/classes/com/sun/tools/javac/parser/JavacParser.java	Fri Sep 02 23:58:32 2016 +0200
    15.3 @@ -3059,7 +3059,7 @@
    15.4          else if (reqInit) syntaxError(token.pos, "expected", EQ);
    15.5          JCVariableDecl result;
    15.6          if (newType.hasTag(ERRONEOUS)) {
    15.7 -            result = F.at(pos).VarDef(mods, name, type, init);
    15.8 +            result = toP(F.at(pos).VarDef(mods, name, type, init));
    15.9          } else {
   15.10              result = toP(F.at(pos).VarDef(mods, name, newType, init));
   15.11          }
    16.1 --- a/src/jdk.compiler/share/classes/com/sun/tools/javac/tree/TreeMaker.java	Mon Aug 22 16:08:34 2016 +0200
    16.2 +++ b/src/jdk.compiler/share/classes/com/sun/tools/javac/tree/TreeMaker.java	Fri Sep 02 23:58:32 2016 +0200
    16.3 @@ -791,7 +791,7 @@
    16.4              result = Literal(LONG, value).
    16.5                  setType(syms.longType.constType(value));
    16.6          } else if (value instanceof Byte) {
    16.7 -            result = Literal(BYTE, value).
    16.8 +            result = Literal(INT, ((Byte) value).intValue()).
    16.9                  setType(syms.byteType.constType(value));
   16.10          } else if (value instanceof Character) {
   16.11              int v = (int) (((Character) value).toString().charAt(0));
   16.12 @@ -804,7 +804,7 @@
   16.13              result = Literal(FLOAT, value).
   16.14                  setType(syms.floatType.constType(value));
   16.15          } else if (value instanceof Short) {
   16.16 -            result = Literal(SHORT, value).
   16.17 +            result = Literal(INT, ((Short) value).intValue()).
   16.18                  setType(syms.shortType.constType(value));
   16.19          } else if (value instanceof Boolean) {
   16.20              int v = ((Boolean) value) ? 1 : 0;