Mercurial > hg > openjdk > aarch64-port > langtools
changeset 2896:550cf3f0e2a8
Merge
author | asaha |
---|---|
date | Mon, 08 Jun 2015 12:24:57 -0700 |
parents | 50e8eb362040 (diff) 1daaf30ef532 (current diff) |
children | 73be26884127 |
files | .hgtags |
diffstat | 72 files changed, 1277 insertions(+), 799 deletions(-) [+] |
line wrap: on
line diff
--- a/.hgtags Mon Jun 08 11:10:05 2015 -0700 +++ b/.hgtags Mon Jun 08 12:24:57 2015 -0700 @@ -418,3 +418,22 @@ f3a44c7deac2b23a53f0fd35b22a5d9181291616 jdk8u51-b14 f77e8d012e8d6ee3432515ad68dd4f630dd08d56 jdk8u51-b15 e27a094cb423a3bf32906969e9e454e061ce94d4 jdk8u51-b16 +0c514d1fd006fc79d35b670de10c370c8d559db7 jdk8u60-b00 +0ba07c272e33c93377a5d7ed98b9de873cc91980 jdk8u60-b01 +387cf62ce7895dd5e067aaa51faa93d5c078583e jdk8u60-b02 +e59ced856c92d542b6ea11a3a76e2f0a1ffae17a jdk8u60-b03 +27bb4c63fd70483bb63a6d830c595e691bf28a34 jdk8u60-b04 +fc98314cff57ce33bfe3093441804ee0a3446622 jdk8u60-b05 +44d168f9ad16609062e359ee70c6699ec4525b45 jdk8u60-b06 +39b47ffeb7780407561c0b189c3b3ab497868518 jdk8u60-b07 +e5b93c508212e0db2301cc25f5ada882367d1d9b jdk8u60-b08 +76adee5ad278e33675fdd236179fa83f20de5cc3 jdk8u60-b09 +ba758e1ffa6960266e5c619b7771ca779ee5d148 jdk8u60-b10 +ac218cf56d8ba365ba341132933629c10dbfcc06 jdk8u60-b11 +84eb517777335f079ba16c1fa49e7c36f0c444aa jdk8u60-b12 +9df2a728410bb8603d0cc39bdebed8fa93430cb2 jdk8u60-b13 +a136ed2f3041e48f340d891208cc8ac0171a7816 jdk8u60-b14 +248db113703a917fd38b637d384848a5e458ebcc jdk8u60-b15 +ecb7e46b820f293bb644f92bc1af3ede53bceced jdk8u60-b16 +87dcdc1fd75bf827c8a4596b183de7ea73cb75e1 jdk8u60-b17 +e7e42c79861ea1ab7495de5f238c01f98035a8a8 jdk8u60-b18
--- a/src/share/classes/com/sun/tools/doclets/formats/html/SubWriterHolderWriter.java Mon Jun 08 11:10:05 2015 -0700 +++ b/src/share/classes/com/sun/tools/doclets/formats/html/SubWriterHolderWriter.java Mon Jun 08 12:24:57 2015 -0700 @@ -113,7 +113,7 @@ Content captionSpan; Content span; if (type.isDefaultTab()) { - captionSpan = HtmlTree.SPAN(new StringContent(type.text())); + captionSpan = HtmlTree.SPAN(configuration.getResource(type.resourceKey())); span = HtmlTree.SPAN(type.tabId(), HtmlStyle.activeTableTab, captionSpan); } else { @@ -136,7 +136,7 @@ */ public Content getMethodTypeLinks(MethodTypes methodType) { String jsShow = "javascript:show(" + methodType.value() +");"; - HtmlTree link = HtmlTree.A(jsShow, new StringContent(methodType.text())); + HtmlTree link = HtmlTree.A(jsShow, configuration.getResource(methodType.resourceKey())); return link; }
--- a/src/share/classes/com/sun/tools/doclets/formats/html/markup/HtmlWriter.java Mon Jun 08 11:10:05 2015 -0700 +++ b/src/share/classes/com/sun/tools/doclets/formats/html/markup/HtmlWriter.java Mon Jun 08 12:24:57 2015 -0700 @@ -471,10 +471,10 @@ for (Map.Entry<String,Integer> entry : typeMap.entrySet()) { vars.append(sep); sep = ","; - vars.append("\""); - vars.append(entry.getKey()); - vars.append("\":"); - vars.append(entry.getValue()); + vars.append("\"") + .append(entry.getKey()) + .append("\":") + .append(entry.getValue()); } vars.append("};").append(DocletConstants.NL); sep = ""; @@ -482,11 +482,19 @@ for (MethodTypes entry : methodTypes) { vars.append(sep); sep = ","; - vars.append(entry.value()).append(":"); - vars.append("[").append("\"").append(entry.tabId()); - vars.append("\"").append(sep).append("\"").append(entry.text()).append("\"]"); + vars.append(entry.value()) + .append(":") + .append("[") + .append("\"") + .append(entry.tabId()) + .append("\"") + .append(sep) + .append("\"") + .append(configuration.getText(entry.resourceKey())) + .append("\"]"); } - vars.append("};").append(DocletConstants.NL); + vars.append("};") + .append(DocletConstants.NL); addStyles(HtmlStyle.altColor, vars); addStyles(HtmlStyle.rowColor, vars); addStyles(HtmlStyle.tableTab, vars);
--- a/src/share/classes/com/sun/tools/doclets/internal/toolkit/resources/doclets.properties Mon Jun 08 11:10:05 2015 -0700 +++ b/src/share/classes/com/sun/tools/doclets/internal/toolkit/resources/doclets.properties Mon Jun 08 12:24:57 2015 -0700 @@ -150,6 +150,13 @@ doclet.Constructors=Constructors doclet.methods=methods doclet.Methods=Methods +doclet.All_Methods=All Methods +doclet.Static_Methods=Static Methods +doclet.Instance_Methods=Instance Methods +doclet.Abstract_Methods=Abstract Methods +doclet.Concrete_Methods=Concrete Methods +doclet.Default_Methods=Default Methods +doclet.Deprecated_Methods=Deprecated Methods doclet.annotation_type_optional_members=optional elements doclet.Annotation_Type_Optional_Members=Optional Elements doclet.annotation_type_required_members=required elements
--- a/src/share/classes/com/sun/tools/doclets/internal/toolkit/resources/stylesheet.css Mon Jun 08 11:10:05 2015 -0700 +++ b/src/share/classes/com/sun/tools/doclets/internal/toolkit/resources/stylesheet.css Mon Jun 08 12:24:57 2015 -0700 @@ -463,7 +463,6 @@ .useSummary td, .constantsSummary td, .deprecatedSummary td { text-align:left; padding:0px 0px 12px 10px; - width:100%; } th.colOne, th.colFirst, th.colLast, .useSummary th, .constantsSummary th, td.colOne, td.colFirst, td.colLast, .useSummary td, .constantsSummary td{ @@ -488,6 +487,7 @@ font-size:13px; } .overviewSummary td.colFirst, .overviewSummary th.colFirst, +.useSummary td.colFirst, .useSummary th.colFirst, .overviewSummary td.colOne, .overviewSummary th.colOne, .memberSummary td.colFirst, .memberSummary th.colFirst, .memberSummary td.colOne, .memberSummary th.colOne,
--- a/src/share/classes/com/sun/tools/doclets/internal/toolkit/util/MethodTypes.java Mon Jun 08 11:10:05 2015 -0700 +++ b/src/share/classes/com/sun/tools/doclets/internal/toolkit/util/MethodTypes.java Mon Jun 08 12:24:57 2015 -0700 @@ -1,5 +1,5 @@ /* - * Copyright (c) 2012, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2012, 2015, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -31,22 +31,22 @@ * @author Bhavesh Patel */ public enum MethodTypes { - ALL(0xffff, "All Methods", "t0", true), - STATIC(0x1, "Static Methods", "t1", false), - INSTANCE(0x2, "Instance Methods", "t2", false), - ABSTRACT(0x4, "Abstract Methods", "t3", false), - CONCRETE(0x8, "Concrete Methods", "t4", false), - DEFAULT(0x10, "Default Methods", "t5", false), - DEPRECATED(0x20, "Deprecated Methods", "t6", false); + ALL(0xffff, "doclet.All_Methods", "t0", true), + STATIC(0x1, "doclet.Static_Methods", "t1", false), + INSTANCE(0x2, "doclet.Instance_Methods", "t2", false), + ABSTRACT(0x4, "doclet.Abstract_Methods", "t3", false), + CONCRETE(0x8, "doclet.Concrete_Methods", "t4", false), + DEFAULT(0x10, "doclet.Default_Methods", "t5", false), + DEPRECATED(0x20, "doclet.Deprecated_Methods", "t6", false); private final int value; - private final String text; + private final String resourceKey; private final String tabId; private final boolean isDefaultTab; - MethodTypes(int v, String t, String id, boolean dt) { + MethodTypes(int v, String k, String id, boolean dt) { this.value = v; - this.text = t; + this.resourceKey = k; this.tabId = id; this.isDefaultTab = dt; } @@ -55,8 +55,8 @@ return value; } - public String text() { - return text; + public String resourceKey() { + return resourceKey; } public String tabId() {
--- a/src/share/classes/com/sun/tools/javac/code/Symbol.java Mon Jun 08 11:10:05 2015 -0700 +++ b/src/share/classes/com/sun/tools/javac/code/Symbol.java Mon Jun 08 12:24:57 2015 -0700 @@ -1153,6 +1153,16 @@ public <R, P> R accept(Symbol.Visitor<R, P> v, P p) { return v.visitClassSymbol(this, p); } + + public void markAbstractIfNeeded(Types types) { + if (types.enter.getEnv(this) != null && + (flags() & ENUM) != 0 && types.supertype(type).tsym == types.syms.enumSym && + (flags() & (FINAL | ABSTRACT)) == 0) { + if (types.firstUnimplementedAbstract(this) != null) + // add the ABSTRACT flag to an enum + flags_field |= ABSTRACT; + } + } }
--- a/src/share/classes/com/sun/tools/javac/code/Types.java Mon Jun 08 11:10:05 2015 -0700 +++ b/src/share/classes/com/sun/tools/javac/code/Types.java Mon Jun 08 12:24:57 2015 -0700 @@ -47,6 +47,7 @@ import com.sun.tools.javac.util.*; import static com.sun.tools.javac.code.BoundKind.*; import static com.sun.tools.javac.code.Flags.*; +import static com.sun.tools.javac.code.Kinds.MTH; import static com.sun.tools.javac.code.Scope.*; import static com.sun.tools.javac.code.Symbol.*; import static com.sun.tools.javac.code.Type.*; @@ -85,6 +86,7 @@ final boolean allowBoxing; final boolean allowCovariantReturns; final boolean allowObjectToPrimitiveCast; + final boolean allowDefaultMethods; final ClassReader reader; final Check chk; final Enter enter; @@ -111,6 +113,7 @@ allowBoxing = source.allowBoxing(); allowCovariantReturns = source.allowCovariantReturns(); allowObjectToPrimitiveCast = source.allowObjectToPrimitiveCast(); + allowDefaultMethods = source.allowDefaultMethods(); reader = ClassReader.instance(context); chk = Check.instance(context); enter = Enter.instance(context); @@ -2763,6 +2766,59 @@ // </editor-fold> + /** Return first abstract member of class `sym'. + */ + public MethodSymbol firstUnimplementedAbstract(ClassSymbol sym) { + try { + return firstUnimplementedAbstractImpl(sym, sym); + } catch (CompletionFailure ex) { + chk.completionError(enter.getEnv(sym).tree.pos(), ex); + return null; + } + } + //where: + private MethodSymbol firstUnimplementedAbstractImpl(ClassSymbol impl, ClassSymbol c) { + MethodSymbol undef = null; + // Do not bother to search in classes that are not abstract, + // since they cannot have abstract members. + if (c == impl || (c.flags() & (ABSTRACT | INTERFACE)) != 0) { + Scope s = c.members(); + for (Scope.Entry e = s.elems; + undef == null && e != null; + e = e.sibling) { + if (e.sym.kind == MTH && + (e.sym.flags() & (ABSTRACT|IPROXY|DEFAULT)) == ABSTRACT) { + MethodSymbol absmeth = (MethodSymbol)e.sym; + MethodSymbol implmeth = absmeth.implementation(impl, this, true); + if (implmeth == null || implmeth == absmeth) { + //look for default implementations + if (allowDefaultMethods) { + MethodSymbol prov = interfaceCandidates(impl.type, absmeth).head; + if (prov != null && prov.overrides(absmeth, impl, this, true)) { + implmeth = prov; + } + } + } + if (implmeth == null || implmeth == absmeth) { + undef = absmeth; + } + } + } + if (undef == null) { + Type st = supertype(c.type); + if (st.hasTag(CLASS)) + undef = firstUnimplementedAbstractImpl(impl, (ClassSymbol)st.tsym); + } + for (List<Type> l = interfaces(c.type); + undef == null && l.nonEmpty(); + l = l.tail) { + undef = firstUnimplementedAbstractImpl(impl, (ClassSymbol)l.head.tsym); + } + } + return undef; + } + + //where public List<MethodSymbol> interfaceCandidates(Type site, MethodSymbol ms) { Filter<Symbol> filter = new MethodFilter(ms, site);
--- a/src/share/classes/com/sun/tools/javac/comp/Attr.java Mon Jun 08 11:10:05 2015 -0700 +++ b/src/share/classes/com/sun/tools/javac/comp/Attr.java Mon Jun 08 12:24:57 2015 -0700 @@ -4269,6 +4269,8 @@ chk.validate(tree.implementing, env); } + c.markAbstractIfNeeded(types); + // If this is a non-abstract class, check that it has no abstract // methods or unimplemented methods of an implemented interface. if ((c.flags() & (ABSTRACT | INTERFACE)) == 0) {
--- a/src/share/classes/com/sun/tools/javac/comp/Check.java Mon Jun 08 11:10:05 2015 -0700 +++ b/src/share/classes/com/sun/tools/javac/comp/Check.java Mon Jun 08 12:24:57 2015 -0700 @@ -2049,70 +2049,15 @@ * @param c The class. */ void checkAllDefined(DiagnosticPosition pos, ClassSymbol c) { - try { - MethodSymbol undef = firstUndef(c, c); - if (undef != null) { - if ((c.flags() & ENUM) != 0 && - types.supertype(c.type).tsym == syms.enumSym && - (c.flags() & FINAL) == 0) { - // add the ABSTRACT flag to an enum - c.flags_field |= ABSTRACT; - } else { - MethodSymbol undef1 = - new MethodSymbol(undef.flags(), undef.name, - types.memberType(c.type, undef), undef.owner); - log.error(pos, "does.not.override.abstract", - c, undef1, undef1.location()); - } - } - } catch (CompletionFailure ex) { - completionError(pos, ex); + MethodSymbol undef = types.firstUnimplementedAbstract(c); + if (undef != null) { + MethodSymbol undef1 = + new MethodSymbol(undef.flags(), undef.name, + types.memberType(c.type, undef), undef.owner); + log.error(pos, "does.not.override.abstract", + c, undef1, undef1.location()); } } -//where - /** Return first abstract member of class `c' that is not defined - * in `impl', null if there is none. - */ - private MethodSymbol firstUndef(ClassSymbol impl, ClassSymbol c) { - MethodSymbol undef = null; - // Do not bother to search in classes that are not abstract, - // since they cannot have abstract members. - if (c == impl || (c.flags() & (ABSTRACT | INTERFACE)) != 0) { - Scope s = c.members(); - for (Scope.Entry e = s.elems; - undef == null && e != null; - e = e.sibling) { - if (e.sym.kind == MTH && - (e.sym.flags() & (ABSTRACT|IPROXY|DEFAULT)) == ABSTRACT) { - MethodSymbol absmeth = (MethodSymbol)e.sym; - MethodSymbol implmeth = absmeth.implementation(impl, types, true); - if (implmeth == null || implmeth == absmeth) { - //look for default implementations - if (allowDefaultMethods) { - MethodSymbol prov = types.interfaceCandidates(impl.type, absmeth).head; - if (prov != null && prov.overrides(absmeth, impl, types, true)) { - implmeth = prov; - } - } - } - if (implmeth == null || implmeth == absmeth) { - undef = absmeth; - } - } - } - if (undef == null) { - Type st = types.supertype(c.type); - if (st.hasTag(CLASS)) - undef = firstUndef(impl, (ClassSymbol)st.tsym); - } - for (List<Type> l = types.interfaces(c.type); - undef == null && l.nonEmpty(); - l = l.tail) { - undef = firstUndef(impl, (ClassSymbol)l.head.tsym); - } - } - return undef; - } void checkNonCyclicDecl(JCClassDecl tree) { CycleChecker cc = new CycleChecker();
--- a/src/share/classes/com/sun/tools/javac/comp/DeferredAttr.java Mon Jun 08 11:10:05 2015 -0700 +++ b/src/share/classes/com/sun/tools/javac/comp/DeferredAttr.java Mon Jun 08 12:24:57 2015 -0700 @@ -1,5 +1,5 @@ /* - * Copyright (c) 2012, 2014, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2012, 2015, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -224,7 +224,8 @@ DeferredStuckPolicy deferredStuckPolicy; if (resultInfo.pt.hasTag(NONE) || resultInfo.pt.isErroneous()) { deferredStuckPolicy = dummyStuckPolicy; - } else if (resultInfo.checkContext.deferredAttrContext().mode == AttrMode.SPECULATIVE) { + } else if (resultInfo.checkContext.deferredAttrContext().mode == AttrMode.SPECULATIVE || + resultInfo.checkContext.deferredAttrContext().insideOverloadPhase()) { deferredStuckPolicy = new OverloadStuckPolicy(resultInfo, this); } else { deferredStuckPolicy = new CheckStuckPolicy(resultInfo, this);
--- a/src/share/classes/com/sun/tools/javac/comp/Infer.java Mon Jun 08 11:10:05 2015 -0700 +++ b/src/share/classes/com/sun/tools/javac/comp/Infer.java Mon Jun 08 12:24:57 2015 -0700 @@ -315,11 +315,9 @@ for (Type aLowerBound : from.getBounds(InferenceBound.LOWER)) { for (Type anotherLowerBound : from.getBounds(InferenceBound.LOWER)) { if (aLowerBound != anotherLowerBound && - commonSuperWithDiffParameterization(aLowerBound, anotherLowerBound)) { - /* self comment check if any lower bound may be and undetVar, - * in that case the result of this call may be a false positive. - * Should this be restricted to non free types? - */ + !inferenceContext.free(aLowerBound) && + !inferenceContext.free(anotherLowerBound) && + commonSuperWithDiffParameterization(aLowerBound, anotherLowerBound)) { return generateReferenceToTargetConstraint(tree, from, to, resultInfo, inferenceContext); }
--- a/src/share/classes/com/sun/tools/javac/comp/LambdaToMethod.java Mon Jun 08 11:10:05 2015 -0700 +++ b/src/share/classes/com/sun/tools/javac/comp/LambdaToMethod.java Mon Jun 08 12:24:57 2015 -0700 @@ -265,7 +265,7 @@ @Override public void visitLambda(JCLambda tree) { LambdaTranslationContext localContext = (LambdaTranslationContext)context; - MethodSymbol sym = (MethodSymbol)localContext.translatedSym; + MethodSymbol sym = localContext.translatedSym; MethodType lambdaType = (MethodType) sym.type; { @@ -1755,7 +1755,7 @@ Map<LambdaSymbolKind, Map<Symbol, Symbol>> translatedSymbols; /** the synthetic symbol for the method hoisting the translated lambda */ - Symbol translatedSym; + MethodSymbol translatedSym; List<JCVariableDecl> syntheticParams; @@ -1883,7 +1883,7 @@ * Translate a symbol of a given kind into something suitable for the * synthetic lambda body */ - Symbol translate(Name name, final Symbol sym, LambdaSymbolKind skind) { + Symbol translate(final Symbol sym, LambdaSymbolKind skind) { Symbol ret; switch (skind) { case CAPTURED_THIS: @@ -1891,7 +1891,7 @@ break; case TYPE_VAR: // Just erase the type var - ret = new VarSymbol(sym.flags(), name, + ret = new VarSymbol(sym.flags(), sym.name, types.erasure(sym.type), sym.owner); /* this information should also be kept for LVT generation at Gen @@ -1900,7 +1900,7 @@ ((VarSymbol)ret).pos = ((VarSymbol)sym).pos; break; case CAPTURED_VAR: - ret = new VarSymbol(SYNTHETIC | FINAL | PARAMETER, name, types.erasure(sym.type), translatedSym) { + ret = new VarSymbol(SYNTHETIC | FINAL | PARAMETER, sym.name, types.erasure(sym.type), translatedSym) { @Override public Symbol baseSymbol() { //keep mapping with original captured symbol @@ -1909,16 +1909,16 @@ }; break; case LOCAL_VAR: - ret = new VarSymbol(sym.flags() & FINAL, name, sym.type, translatedSym); + ret = new VarSymbol(sym.flags() & FINAL, sym.name, sym.type, translatedSym); ((VarSymbol) ret).pos = ((VarSymbol) sym).pos; break; case PARAM: - ret = new VarSymbol((sym.flags() & FINAL) | PARAMETER, name, types.erasure(sym.type), translatedSym); + ret = new VarSymbol((sym.flags() & FINAL) | PARAMETER, sym.name, types.erasure(sym.type), translatedSym); ((VarSymbol) ret).pos = ((VarSymbol) sym).pos; break; default: - ret = makeSyntheticVar(FINAL, name, types.erasure(sym.type), translatedSym); - ((VarSymbol) ret).pos = ((VarSymbol) sym).pos; + Assert.error(skind.name()); + throw new AssertionError(); } if (ret != sym) { ret.setDeclarationAttributes(sym.getRawAttributes()); @@ -1929,27 +1929,8 @@ void addSymbol(Symbol sym, LambdaSymbolKind skind) { Map<Symbol, Symbol> transMap = getSymbolMap(skind); - Name preferredName; - switch (skind) { - case CAPTURED_THIS: - preferredName = names.fromString("encl$" + transMap.size()); - break; - case CAPTURED_VAR: - preferredName = names.fromString("cap$" + transMap.size()); - break; - case LOCAL_VAR: - preferredName = sym.name; - break; - case PARAM: - preferredName = sym.name; - break; - case TYPE_VAR: - preferredName = sym.name; - break; - default: throw new AssertionError(); - } if (!transMap.containsKey(sym)) { - transMap.put(sym, translate(preferredName, sym, skind)); + transMap.put(sym, translate(sym, skind)); } } @@ -1997,6 +1978,7 @@ //compute synthetic params ListBuffer<JCVariableDecl> params = new ListBuffer<>(); + ListBuffer<VarSymbol> parameterSymbols = new ListBuffer<>(); // The signature of the method is augmented with the following // synthetic parameters: @@ -2005,19 +1987,16 @@ // 2) enclosing locals captured by the lambda expression for (Symbol thisSym : getSymbolMap(CAPTURED_VAR).values()) { params.append(make.VarDef((VarSymbol) thisSym, null)); - } - if (methodReferenceReceiver != null) { - params.append(make.VarDef( - make.Modifiers(PARAMETER|FINAL), - names.fromString("$rcvr$"), - make.Type(methodReferenceReceiver.type), - null)); + parameterSymbols.append((VarSymbol) thisSym); } for (Symbol thisSym : getSymbolMap(PARAM).values()) { params.append(make.VarDef((VarSymbol) thisSym, null)); + parameterSymbols.append((VarSymbol) thisSym); } syntheticParams = params.toList(); + translatedSym.params = parameterSymbols.toList(); + // Compute and set the lambda name translatedSym.name = isSerializable() ? serializedLambdaName()
--- a/src/share/classes/com/sun/tools/javac/comp/Lower.java Mon Jun 08 11:10:05 2015 -0700 +++ b/src/share/classes/com/sun/tools/javac/comp/Lower.java Mon Jun 08 12:24:57 2015 -0700 @@ -2540,7 +2540,7 @@ currentMethodSym = currentMethodSymPrev; // Return empty block {} as a placeholder for an inner class. - result = make_at(tree.pos()).Block(0, List.<JCStatement>nil()); + result = make_at(tree.pos()).Block(SYNTHETIC, List.<JCStatement>nil()); } /** Translate an enum class. */
--- a/src/share/classes/com/sun/tools/javac/comp/Resolve.java Mon Jun 08 11:10:05 2015 -0700 +++ b/src/share/classes/com/sun/tools/javac/comp/Resolve.java Mon Jun 08 12:24:57 2015 -0700 @@ -836,20 +836,19 @@ List<Type> formals, Warner warn) { super.argumentsAcceptable(env, deferredAttrContext, argtypes, formals, warn); - //should we expand formals? + // should we check varargs element type accessibility? if (deferredAttrContext.phase.isVarargsRequired()) { - Type typeToCheck = null; - if (!checkVarargsAccessAfterResolution) { - typeToCheck = types.elemtype(formals.last()); - } else if (deferredAttrContext.mode == AttrMode.CHECK) { - typeToCheck = types.erasure(types.elemtype(formals.last())); - } - if (typeToCheck != null) { - varargsAccessible(env, typeToCheck, deferredAttrContext.inferenceContext); + if (deferredAttrContext.mode == AttrMode.CHECK || !checkVarargsAccessAfterResolution) { + varargsAccessible(env, types.elemtype(formals.last()), deferredAttrContext.inferenceContext); } } } + /** + * Test that the runtime array element type corresponding to 't' is accessible. 't' should be the + * varargs element type of either the method invocation type signature (after inference completes) + * or the method declaration signature (before inference completes). + */ private void varargsAccessible(final Env<AttrContext> env, final Type t, final InferenceContext inferenceContext) { if (inferenceContext.free(t)) { inferenceContext.addFreeTypeListener(List.of(t), new FreeTypeListener() { @@ -859,7 +858,7 @@ } }); } else { - if (!isAccessible(env, t)) { + if (!isAccessible(env, types.erasure(t))) { Symbol location = env.enclClass.sym; reportMC(env.tree, MethodCheckDiag.INACCESSIBLE_VARARGS, inferenceContext, t, Kinds.kindName(location), location); } @@ -4087,7 +4086,7 @@ s : new MethodSymbol( s.flags(), s.name, - types.createMethodTypeWithThrown(mt, allThrown), + types.createMethodTypeWithThrown(s.type, allThrown), s.owner); } }
--- a/src/share/classes/com/sun/tools/javac/jvm/ClassReader.java Mon Jun 08 11:10:05 2015 -0700 +++ b/src/share/classes/com/sun/tools/javac/jvm/ClassReader.java Mon Jun 08 12:24:57 2015 -0700 @@ -1,5 +1,5 @@ /* - * Copyright (c) 1999, 2014, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 1999, 2015, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -1779,15 +1779,17 @@ // The method wasn't found: emit a warning and recover JavaFileObject prevSource = log.useSource(requestingOwner.classfile); try { - if (failure == null) { - log.warning("annotation.method.not.found", - container, - name); - } else { - log.warning("annotation.method.not.found.reason", - container, - name, - failure.getDetailValue());//diagnostic, if present + if (lintClassfile) { + if (failure == null) { + log.warning("annotation.method.not.found", + container, + name); + } else { + log.warning("annotation.method.not.found.reason", + container, + name, + failure.getDetailValue()); //diagnostic, if present + } } } finally { log.useSource(prevSource);
--- a/src/share/classes/com/sun/tools/javac/jvm/ClassWriter.java Mon Jun 08 11:10:05 2015 -0700 +++ b/src/share/classes/com/sun/tools/javac/jvm/ClassWriter.java Mon Jun 08 12:24:57 2015 -0700 @@ -1,5 +1,5 @@ /* - * Copyright (c) 1999, 2013, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 1999, 2015, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -1027,6 +1027,7 @@ l.nonEmpty(); l = l.tail) { ClassSymbol inner = l.head; + inner.markAbstractIfNeeded(types); char flags = (char) adjustFlags(inner.flags_field); if ((flags & INTERFACE) != 0) flags |= ABSTRACT; // Interfaces are always ABSTRACT if (inner.name.isEmpty()) flags &= ~FINAL; // Anonymous class: unset FINAL flag @@ -1186,7 +1187,7 @@ Assert.check(r.start_pc >= 0 && r.start_pc <= code.cp); databuf.appendChar(r.start_pc); - Assert.check(r.length >= 0 + Assert.check(r.length > 0 && (r.start_pc + r.length) <= code.cp); databuf.appendChar(r.length); VarSymbol sym = var.sym;
--- a/src/share/classes/com/sun/tools/javac/jvm/Code.java Mon Jun 08 11:10:05 2015 -0700 +++ b/src/share/classes/com/sun/tools/javac/jvm/Code.java Mon Jun 08 12:24:57 2015 -0700 @@ -1,5 +1,5 @@ /* - * Copyright (c) 1999, 2014, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 1999, 2015, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -182,8 +182,6 @@ final MethodSymbol meth; - final LVTRanges lvtRanges; - /** Construct a code object, given the settings of the fatcode, * debugging info switches and the CharacterRangeTable. */ @@ -196,8 +194,7 @@ CRTable crt, Symtab syms, Types types, - Pool pool, - LVTRanges lvtRanges) { + Pool pool) { this.meth = meth; this.fatcode = fatcode; this.lineMap = lineMap; @@ -219,7 +216,6 @@ state = new State(); lvar = new LocalVar[20]; this.pool = pool; - this.lvtRanges = lvtRanges; } @@ -1193,7 +1189,9 @@ public int entryPoint(State state) { int pc = curCP(); alive = true; - this.state = state.dup(); + State newState = state.dup(); + setDefined(newState.defined); + this.state = newState; Assert.check(state.stacksize <= max_stack); if (debugCode) System.err.println("entry point " + state); pendingStackMap = needStackMap; @@ -1206,7 +1204,9 @@ public int entryPoint(State state, Type pushed) { int pc = curCP(); alive = true; - this.state = state.dup(); + State newState = state.dup(); + setDefined(newState.defined); + this.state = newState; Assert.check(state.stacksize <= max_stack); this.state.push(pushed); if (debugCode) System.err.println("entry point " + state); @@ -2008,27 +2008,6 @@ state.defined.excl(adr); } - - public void closeAliveRanges(JCTree tree) { - closeAliveRanges(tree, cp); - } - - public void closeAliveRanges(JCTree tree, int closingCP) { - List<VarSymbol> locals = lvtRanges.getVars(meth, tree); - for (LocalVar localVar: lvar) { - for (VarSymbol aliveLocal : locals) { - if (localVar != null) { - if (localVar.sym == aliveLocal && localVar.lastRange() != null) { - char length = (char)(closingCP - localVar.lastRange().start_pc); - if (length < Character.MAX_VALUE) { - localVar.closeRange(length); - } - } - } - } - } - } - void adjustAliveRanges(int oldCP, int delta) { for (LocalVar localVar: lvar) { if (localVar != null) { @@ -2193,7 +2172,11 @@ boolean keepLocalVariables = varDebugInfo || (var.sym.isExceptionParameter() && var.sym.hasTypeAnnotations()); if (!keepLocalVariables) return; - if ((var.sym.flags() & Flags.SYNTHETIC) != 0) return; + //don't keep synthetic vars, unless they are lambda method parameters + boolean ignoredSyntheticVar = (var.sym.flags() & Flags.SYNTHETIC) != 0 && + ((var.sym.owner.flags() & Flags.LAMBDA_METHOD) == 0 || + (var.sym.flags() & Flags.PARAMETER) == 0); + if (ignoredSyntheticVar) return; if (varBuffer == null) varBuffer = new LocalVar[20]; else
--- a/src/share/classes/com/sun/tools/javac/jvm/Gen.java Mon Jun 08 11:10:05 2015 -0700 +++ b/src/share/classes/com/sun/tools/javac/jvm/Gen.java Mon Jun 08 12:24:57 2015 -0700 @@ -1,5 +1,5 @@ /* - * Copyright (c) 1999, 2014, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 1999, 2015, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -101,10 +101,6 @@ */ private Pool pool; - /** LVTRanges info. - */ - private LVTRanges lvtRanges; - private final boolean typeAnnoAsserts; protected Gen(Context context) { @@ -137,9 +133,6 @@ options.isUnset(G_CUSTOM) ? options.isSet(G) : options.isSet(G_CUSTOM, "vars"); - if (varDebugInfo) { - lvtRanges = LVTRanges.instance(context); - } genCrt = options.isSet(XJCOV); debugCode = options.isSet("debugcode"); allowInvokedynamic = target.hasInvokedynamic() || options.isSet("invokedynamic"); @@ -493,7 +486,7 @@ JCBlock block = (JCBlock)def; if ((block.flags & STATIC) != 0) clinitCode.append(block); - else + else if ((block.flags & SYNTHETIC) == 0) initCode.append(block); break; case METHODDEF: @@ -1103,8 +1096,7 @@ : null, syms, types, - pool, - varDebugInfo ? lvtRanges : null); + pool); items = new Items(pool, code, syms, types); if (code.debugCode) { System.err.println(meth + " for body " + tree); @@ -1207,30 +1199,14 @@ Chain loopDone = c.jumpFalse(); code.resolve(c.trueJumps); genStat(body, loopEnv, CRT_STATEMENT | CRT_FLOW_TARGET); - if (varDebugInfo) { - checkLoopLocalVarRangeEnding(loop, body, - LoopLocalVarRangeEndingPoint.BEFORE_STEPS); - } code.resolve(loopEnv.info.cont); genStats(step, loopEnv); - if (varDebugInfo) { - checkLoopLocalVarRangeEnding(loop, body, - LoopLocalVarRangeEndingPoint.AFTER_STEPS); - } code.resolve(code.branch(goto_), startpc); code.resolve(loopDone); } else { genStat(body, loopEnv, CRT_STATEMENT | CRT_FLOW_TARGET); - if (varDebugInfo) { - checkLoopLocalVarRangeEnding(loop, body, - LoopLocalVarRangeEndingPoint.BEFORE_STEPS); - } code.resolve(loopEnv.info.cont); genStats(step, loopEnv); - if (varDebugInfo) { - checkLoopLocalVarRangeEnding(loop, body, - LoopLocalVarRangeEndingPoint.AFTER_STEPS); - } CondItem c; if (cond != null) { code.statBegin(cond.pos); @@ -1247,44 +1223,6 @@ } } - private enum LoopLocalVarRangeEndingPoint { - BEFORE_STEPS, - AFTER_STEPS, - } - - /** - * Checks whether we have reached an alive range ending point for local - * variables after a loop. - * - * Local variables alive range ending point for loops varies depending - * on the loop type. The range can be closed before or after the code - * for the steps sentences has been generated. - * - * - While loops has no steps so in that case the range is closed just - * after the body of the loop. - * - * - For-like loops may have steps so as long as the steps sentences - * can possibly contain non-synthetic local variables, the alive range - * for local variables must be closed after the steps in this case. - */ - private void checkLoopLocalVarRangeEnding(JCTree loop, JCTree body, - LoopLocalVarRangeEndingPoint endingPoint) { - if (varDebugInfo && lvtRanges.containsKey(code.meth, body)) { - switch (endingPoint) { - case BEFORE_STEPS: - if (!loop.hasTag(FORLOOP)) { - code.closeAliveRanges(body); - } - break; - case AFTER_STEPS: - if (loop.hasTag(FORLOOP)) { - code.closeAliveRanges(body); - } - break; - } - } - } - public void visitForeachLoop(JCEnhancedForLoop tree) { throw new AssertionError(); // should have been removed by Lower. } @@ -1398,9 +1336,6 @@ // Generate code for the statements in this case. genStats(c.stats, switchEnv, CRT_FLOW_TARGET); - if (varDebugInfo && lvtRanges.containsKey(code.meth, c.stats.last())) { - code.closeAliveRanges(c.stats.last()); - } } // Resolve all breaks. @@ -1557,9 +1492,6 @@ genFinalizer(env); code.statBegin(TreeInfo.endPos(env.tree)); Chain exitChain = code.branch(goto_); - if (varDebugInfo && lvtRanges.containsKey(code.meth, body)) { - code.closeAliveRanges(body); - } endFinalizerGap(env); if (startpc != endpc) for (List<JCCatch> l = catchers; l.nonEmpty(); l = l.tail) { // start off with exception on stack @@ -1815,17 +1747,11 @@ code.resolve(c.trueJumps); genStat(tree.thenpart, env, CRT_STATEMENT | CRT_FLOW_TARGET); thenExit = code.branch(goto_); - if (varDebugInfo && lvtRanges.containsKey(code.meth, tree.thenpart)) { - code.closeAliveRanges(tree.thenpart, code.cp); - } } if (elseChain != null) { code.resolve(elseChain); if (tree.elsepart != null) { genStat(tree.elsepart, env,CRT_STATEMENT | CRT_FLOW_TARGET); - if (varDebugInfo && lvtRanges.containsKey(code.meth, tree.elsepart)) { - code.closeAliveRanges(tree.elsepart); - } } } code.resolve(thenExit); @@ -2514,16 +2440,6 @@ localEnv.toplevel = env.toplevel; localEnv.enclClass = cdef; - /* We must not analyze synthetic methods - */ - if (varDebugInfo && (cdef.sym.flags() & SYNTHETIC) == 0) { - try { - new LVTAssignAnalyzer().analyzeTree(localEnv); - } catch (Throwable e) { - throw e; - } - } - for (List<JCTree> l = cdef.defs; l.nonEmpty(); l = l.tail) { genDef(l.head, localEnv); } @@ -2609,282 +2525,4 @@ } } - class LVTAssignAnalyzer - extends Flow.AbstractAssignAnalyzer<LVTAssignAnalyzer.LVTAssignPendingExit> { - - final LVTBits lvtInits; - - /* This class is anchored to a context dependent tree. The tree can - * vary inside the same instruction for example in the switch instruction - * the same FlowBits instance can be anchored to the whole tree, or - * to a given case. The aim is to always anchor the bits to the tree - * capable of closing a DA range. - */ - class LVTBits extends Bits { - - JCTree currentTree; - private int[] oldBits = null; - BitsState stateBeforeOp; - - @Override - public void clear() { - generalOp(null, -1, BitsOpKind.CLEAR); - } - - @Override - protected void internalReset() { - super.internalReset(); - oldBits = null; - } - - @Override - public Bits assign(Bits someBits) { - // bits can be null - oldBits = bits; - stateBeforeOp = currentState; - super.assign(someBits); - changed(); - return this; - } - - @Override - public void excludeFrom(int start) { - generalOp(null, start, BitsOpKind.EXCL_RANGE); - } - - @Override - public void excl(int x) { - Assert.check(x >= 0); - generalOp(null, x, BitsOpKind.EXCL_BIT); - } - - @Override - public Bits andSet(Bits xs) { - return generalOp(xs, -1, BitsOpKind.AND_SET); - } - - @Override - public Bits orSet(Bits xs) { - return generalOp(xs, -1, BitsOpKind.OR_SET); - } - - @Override - public Bits diffSet(Bits xs) { - return generalOp(xs, -1, BitsOpKind.DIFF_SET); - } - - @Override - public Bits xorSet(Bits xs) { - return generalOp(xs, -1, BitsOpKind.XOR_SET); - } - - private Bits generalOp(Bits xs, int i, BitsOpKind opKind) { - Assert.check(currentState != BitsState.UNKNOWN); - oldBits = dupBits(); - stateBeforeOp = currentState; - switch (opKind) { - case AND_SET: - super.andSet(xs); - break; - case OR_SET: - super.orSet(xs); - break; - case XOR_SET: - super.xorSet(xs); - break; - case DIFF_SET: - super.diffSet(xs); - break; - case CLEAR: - super.clear(); - break; - case EXCL_BIT: - super.excl(i); - break; - case EXCL_RANGE: - super.excludeFrom(i); - break; - } - changed(); - return this; - } - - /* The tree we need to anchor the bits instance to. - */ - LVTBits at(JCTree tree) { - this.currentTree = tree; - return this; - } - - /* If the instance should be changed but the tree is not a closing - * tree then a reset is needed or the former tree can mistakingly be - * used. - */ - LVTBits resetTree() { - this.currentTree = null; - return this; - } - - /** This method will be called after any operation that causes a change to - * the bits. Subclasses can thus override it in order to extract information - * from the changes produced to the bits by the given operation. - */ - public void changed() { - if (currentTree != null && - stateBeforeOp != BitsState.UNKNOWN && - trackTree(currentTree)) { - List<VarSymbol> locals = lvtRanges - .getVars(currentMethod, currentTree); - locals = locals != null ? - locals : List.<VarSymbol>nil(); - for (JCVariableDecl vardecl : vardecls) { - //once the first is null, the rest will be so. - if (vardecl == null) { - break; - } - if (trackVar(vardecl.sym) && bitChanged(vardecl.sym.adr)) { - locals = locals.prepend(vardecl.sym); - } - } - if (!locals.isEmpty()) { - lvtRanges.setEntry(currentMethod, - currentTree, locals); - } - } - } - - boolean bitChanged(int x) { - boolean isMemberOfBits = isMember(x); - int[] tmp = bits; - bits = oldBits; - boolean isMemberOfOldBits = isMember(x); - bits = tmp; - return (!isMemberOfBits && isMemberOfOldBits); - } - - boolean trackVar(VarSymbol var) { - return (var.owner.kind == MTH && - (var.flags() & PARAMETER) == 0 && - trackable(var)); - } - - boolean trackTree(JCTree tree) { - switch (tree.getTag()) { - // of course a method closes the alive range of a local variable. - case METHODDEF: - // for while loops we want only the body - case WHILELOOP: - return false; - } - return true; - } - - } - - public class LVTAssignPendingExit extends - Flow.AbstractAssignAnalyzer<LVTAssignPendingExit>.AbstractAssignPendingExit { - - LVTAssignPendingExit(JCTree tree, final Bits inits, final Bits uninits) { - super(tree, inits, uninits); - } - - @Override - public void resolveJump(JCTree tree) { - lvtInits.at(tree); - super.resolveJump(tree); - } - } - - private LVTAssignAnalyzer() { - flow.super(); - lvtInits = new LVTBits(); - inits = lvtInits; - } - - @Override - protected void markDead(JCTree tree) { - lvtInits.at(tree).inclRange(returnadr, nextadr); - super.markDead(tree); - } - - @Override - protected void merge(JCTree tree) { - lvtInits.at(tree); - super.merge(tree); - } - - boolean isSyntheticOrMandated(Symbol sym) { - return (sym.flags() & (SYNTHETIC | MANDATED)) != 0; - } - - @Override - protected boolean trackable(VarSymbol sym) { - if (isSyntheticOrMandated(sym)) { - //fast check to avoid tracking synthetic or mandated variables - return false; - } - return super.trackable(sym); - } - - @Override - protected void initParam(JCVariableDecl def) { - if (!isSyntheticOrMandated(def.sym)) { - super.initParam(def); - } - } - - @Override - protected void assignToInits(JCTree tree, Bits bits) { - lvtInits.at(tree); - lvtInits.assign(bits); - } - - @Override - protected void andSetInits(JCTree tree, Bits bits) { - lvtInits.at(tree); - lvtInits.andSet(bits); - } - - @Override - protected void orSetInits(JCTree tree, Bits bits) { - lvtInits.at(tree); - lvtInits.orSet(bits); - } - - @Override - protected void exclVarFromInits(JCTree tree, int adr) { - lvtInits.at(tree); - lvtInits.excl(adr); - } - - @Override - protected LVTAssignPendingExit createNewPendingExit(JCTree tree, Bits inits, Bits uninits) { - return new LVTAssignPendingExit(tree, inits, uninits); - } - - MethodSymbol currentMethod; - - @Override - public void visitMethodDef(JCMethodDecl tree) { - if ((tree.sym.flags() & (SYNTHETIC | GENERATEDCONSTR)) != 0 - && (tree.sym.flags() & LAMBDA_METHOD) == 0) { - return; - } - if (tree.name.equals(names.clinit)) { - return; - } - boolean enumClass = (tree.sym.owner.flags() & ENUM) != 0; - if (enumClass && - (tree.name.equals(names.valueOf) || - tree.name.equals(names.values) || - tree.name.equals(names.init))) { - return; - } - currentMethod = tree.sym; - - super.visitMethodDef(tree); - } - - } - }
--- a/src/share/classes/com/sun/tools/javac/jvm/LVTRanges.java Mon Jun 08 11:10:05 2015 -0700 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,129 +0,0 @@ -/* - * Copyright (c) 2013, Oracle and/or its affiliates. All rights reserved. - * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. - * - * This code is free software; you can redistribute it and/or modify it - * under the terms of the GNU General Public License version 2 only, as - * published by the Free Software Foundation. Oracle designates this - * particular file as subject to the "Classpath" exception as provided - * by Oracle in the LICENSE file that accompanied this code. - * - * This code is distributed in the hope that it will be useful, but WITHOUT - * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or - * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License - * version 2 for more details (a copy is included in the LICENSE file that - * accompanied this code). - * - * You should have received a copy of the GNU General Public License version - * 2 along with this work; if not, write to the Free Software Foundation, - * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. - * - * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA - * or visit www.oracle.com if you need additional information or have any - * questions. - */ - -package com.sun.tools.javac.jvm; - -import java.util.Map; -import java.util.Map.Entry; -import java.util.WeakHashMap; - -import com.sun.tools.javac.code.Symbol.MethodSymbol; -import com.sun.tools.javac.code.Symbol.VarSymbol; -import com.sun.tools.javac.tree.JCTree; -import com.sun.tools.javac.util.Context; -import com.sun.tools.javac.util.List; - -/** This class contains a one to many relation between a tree and a set of variables. - * The relation implies that the given tree closes the DA (definite assignment) - * range for the set of variables. - * - * <p><b>This is NOT part of any supported API. - * If you write code that depends on this, you do so at your own risk. - * This code and its internal interfaces are subject to change or - * deletion without notice.</b> - */ -public class LVTRanges { - /** The context key for the LVT ranges. */ - protected static final Context.Key<LVTRanges> lvtRangesKey = new Context.Key<>(); - - /** Get the LVTRanges instance for this context. */ - public static LVTRanges instance(Context context) { - LVTRanges instance = context.get(lvtRangesKey); - if (instance == null) { - instance = new LVTRanges(context); - } - return instance; - } - - private static final long serialVersionUID = 1812267524140424433L; - - protected Context context; - - protected Map<MethodSymbol, Map<JCTree, List<VarSymbol>>> - aliveRangeClosingTrees = new WeakHashMap<>(); - - public LVTRanges(Context context) { - this.context = context; - context.put(lvtRangesKey, this); - } - - public List<VarSymbol> getVars(MethodSymbol method, JCTree tree) { - Map<JCTree, List<VarSymbol>> varMap = aliveRangeClosingTrees.get(method); - return (varMap != null) ? varMap.get(tree) : null; - } - - public boolean containsKey(MethodSymbol method, JCTree tree) { - Map<JCTree, List<VarSymbol>> varMap = aliveRangeClosingTrees.get(method); - if (varMap == null) { - return false; - } - return varMap.containsKey(tree); - } - - public void setEntry(MethodSymbol method, JCTree tree, List<VarSymbol> vars) { - Map<JCTree, List<VarSymbol>> varMap = aliveRangeClosingTrees.get(method); - if (varMap != null) { - varMap.put(tree, vars); - } else { - varMap = new WeakHashMap<>(); - varMap.put(tree, vars); - aliveRangeClosingTrees.put(method, varMap); - } - } - - public List<VarSymbol> removeEntry(MethodSymbol method, JCTree tree) { - Map<JCTree, List<VarSymbol>> varMap = aliveRangeClosingTrees.get(method); - if (varMap != null) { - List<VarSymbol> result = varMap.remove(tree); - if (varMap.isEmpty()) { - aliveRangeClosingTrees.remove(method); - } - return result; - } - return null; - } - - /* This method should be used for debugging LVT related issues. - */ - @Override - public String toString() { - String result = ""; - for (Entry<MethodSymbol, Map<JCTree, List<VarSymbol>>> mainEntry: aliveRangeClosingTrees.entrySet()) { - result += "Method: \n" + mainEntry.getKey().flatName() + "\n"; - int i = 1; - for (Entry<JCTree, List<VarSymbol>> treeEntry: mainEntry.getValue().entrySet()) { - result += " Tree " + i + ": \n" + treeEntry.getKey().toString() + "\n"; - result += " Variables closed:\n"; - for (VarSymbol var: treeEntry.getValue()) { - result += " " + var.toString(); - } - result += "\n"; - i++; - } - } - return result; - } - -}
--- a/src/share/classes/com/sun/tools/javac/parser/JavacParser.java Mon Jun 08 11:10:05 2015 -0700 +++ b/src/share/classes/com/sun/tools/javac/parser/JavacParser.java Mon Jun 08 12:24:57 2015 -0700 @@ -2720,7 +2720,7 @@ } else { JCExpression t = term(EXPR | TYPE); if ((lastmode & TYPE) != 0 && LAX_IDENTIFIER.accepts(token.kind)) { - return variableDeclarators(modifiersOpt(), t, stats).toList(); + return variableDeclarators(mods(pos, 0, List.<JCAnnotation>nil()), t, stats).toList(); } else if ((lastmode & TYPE) != 0 && token.kind == COLON) { error(pos, "bad.initializer", "for-loop"); return List.of((JCStatement)F.at(pos).VarDef(null, null, t, null)); @@ -2829,16 +2829,20 @@ default: break; } - /* A modifiers tree with no modifier tokens or annotations - * has no text position. */ - if ((flags & (Flags.ModifierFlags | Flags.ANNOTATION)) == 0 && annotations.isEmpty()) - pos = Position.NOPOS; - - JCModifiers mods = F.at(pos).Modifiers(flags, annotations.toList()); - if (pos != Position.NOPOS) - storeEnd(mods, S.prevToken().endPos); - return mods; + return mods(pos, flags, annotations.toList()); } + //where + JCModifiers mods(int pos, long flags, List<JCAnnotation> annotations) { + /* A modifiers tree with no modifier tokens or annotations + * has no text position. */ + if ((flags & (Flags.ModifierFlags | Flags.ANNOTATION)) == 0 && annotations.isEmpty()) + pos = Position.NOPOS; + + JCModifiers mods = F.at(pos).Modifiers(flags, annotations); + if (pos != Position.NOPOS) + storeEnd(mods, S.prevToken().endPos); + return mods; + } /** Annotation = "@" Qualident [ "(" AnnotationFieldValues ")" ] *
--- a/src/share/classes/com/sun/tools/javac/resources/javac.properties Mon Jun 08 11:10:05 2015 -0700 +++ b/src/share/classes/com/sun/tools/javac/resources/javac.properties Mon Jun 08 12:24:57 2015 -0700 @@ -232,8 +232,8 @@ javac.msg.bug=\ An exception has occurred in the compiler ({0}). \ -Please file a bug at the Java Developer Connection (http://java.sun.com/webapps/bugreport) \ -after checking the Bug Parade for duplicates. \ +Please file a bug at the Java Bug Database (http://bugreport.java.com/bugreport/) \ +after checking the database for duplicates. \ Include your program and the following diagnostic in your report. Thank you. javac.msg.io=\
--- a/src/share/classes/com/sun/tools/jdeps/Analyzer.java Mon Jun 08 11:10:05 2015 -0700 +++ b/src/share/classes/com/sun/tools/jdeps/Analyzer.java Mon Jun 08 12:24:57 2015 -0700 @@ -223,7 +223,7 @@ Archive targetArchive = findArchive(t); if (filter.accepts(o, archive, t, targetArchive)) { addDep(o, t); - if (!requires.contains(targetArchive)) { + if (archive != targetArchive && !requires.contains(targetArchive)) { requires.add(targetArchive); } }
--- a/src/share/classes/com/sun/tools/jdeps/JdepsTask.java Mon Jun 08 11:10:05 2015 -0700 +++ b/src/share/classes/com/sun/tools/jdeps/JdepsTask.java Mon Jun 08 12:24:57 2015 -0700 @@ -489,9 +489,11 @@ List<Archive> archives = new ArrayList<>(); Deque<String> roots = new LinkedList<>(); + List<Path> paths = new ArrayList<>(); for (String s : classes) { Path p = Paths.get(s); if (Files.exists(p)) { + paths.add(p); archives.add(Archive.getInstance(p)); } else { if (isValidClassName(s)) { @@ -504,7 +506,7 @@ sourceLocations.addAll(archives); List<Archive> classpaths = new ArrayList<>(); // for class file lookup - classpaths.addAll(getClassPathArchives(options.classpath)); + classpaths.addAll(getClassPathArchives(options.classpath, paths)); if (options.includePattern != null) { archives.addAll(classpaths); } @@ -545,6 +547,9 @@ deque.add(cn); } a.addClass(d.getOrigin(), d.getTarget()); + } else { + // ensure that the parsed class is added the archive + a.addClass(d.getOrigin()); } } for (String name : a.reader().skippedEntries()) { @@ -592,6 +597,9 @@ if (!doneClasses.contains(cn) && !deque.contains(cn)) { deque.add(cn); } + } else { + // ensure that the parsed class is added the archive + a.addClass(d.getOrigin()); } } } @@ -743,36 +751,52 @@ } } - private List<Archive> getClassPathArchives(String paths) throws IOException { + /* + * Returns the list of Archive specified in cpaths and not included + * initialArchives + */ + private List<Archive> getClassPathArchives(String cpaths, List<Path> initialArchives) + throws IOException + { List<Archive> result = new ArrayList<>(); - if (paths.isEmpty()) { + if (cpaths.isEmpty()) { return result; } - for (String p : paths.split(File.pathSeparator)) { + + List<Path> paths = new ArrayList<>(); + for (String p : cpaths.split(File.pathSeparator)) { if (p.length() > 0) { - List<Path> files = new ArrayList<>(); // wildcard to parse all JAR files e.g. -classpath dir/* int i = p.lastIndexOf(".*"); if (i > 0) { Path dir = Paths.get(p.substring(0, i)); try (DirectoryStream<Path> stream = Files.newDirectoryStream(dir, "*.jar")) { for (Path entry : stream) { - files.add(entry); + paths.add(entry); } } } else { - files.add(Paths.get(p)); - } - for (Path f : files) { - if (Files.exists(f)) { - result.add(Archive.getInstance(f)); - } + paths.add(Paths.get(p)); } } } + for (Path p : paths) { + if (Files.exists(p) && !hasSameFile(initialArchives, p)) { + result.add(Archive.getInstance(p)); + } + } return result; } + private boolean hasSameFile(List<Path> paths, Path p2) throws IOException { + for (Path p1 : paths) { + if (Files.isSameFile(p1, p2)) { + return true; + } + } + return false; + } + class RawOutputFormatter implements Analyzer.Visitor { private final PrintWriter writer; private String pkg = "";
--- a/src/share/classes/com/sun/tools/jdeps/PlatformClassPath.java Mon Jun 08 11:10:05 2015 -0700 +++ b/src/share/classes/com/sun/tools/jdeps/PlatformClassPath.java Mon Jun 08 12:24:57 2015 -0700 @@ -46,7 +46,7 @@ */ class PlatformClassPath { private static final List<String> NON_PLATFORM_JARFILES = - Arrays.asList("alt-rt.jar", "jfxrt.jar", "ant-javafx.jar", "javafx-mx.jar"); + Arrays.asList("alt-rt.jar", "ant-javafx.jar", "javafx-mx.jar"); private static final List<Archive> javaHomeArchives = init(); static List<Archive> getArchives() { @@ -124,6 +124,14 @@ */ static class JDKArchive extends Archive { private static List<String> PROFILE_JARS = Arrays.asList("rt.jar", "jce.jar"); + // Workaround: The following packages are not annotated as jdk.Exported + private static List<String> EXPORTED_PACKAGES = Arrays.asList( + "javax.jnlp", + "org.w3c.dom.css", + "org.w3c.dom.html", + "org.w3c.dom.stylesheets", + "org.w3c.dom.xpath" + ); public static boolean isProfileArchive(Archive archive) { if (archive instanceof JDKArchive) { return PROFILE_JARS.contains(archive.getName()); @@ -155,7 +163,11 @@ * Tests if a given package name is exported. */ public boolean isExportedPackage(String pn) { - if (Profile.getProfile(pn) != null || "javax.jnlp".equals(pn)) { + if (Profile.getProfile(pn) != null) { + return true; + } + // special case for JavaFX and APIs that are not annotated with @jdk.Exported) + if (EXPORTED_PACKAGES.contains(pn) || pn.startsWith("javafx.")) { return true; } return exportedPackages.containsKey(pn) ? exportedPackages.get(pn) : false;
--- a/test/Makefile Mon Jun 08 11:10:05 2015 -0700 +++ b/test/Makefile Mon Jun 08 12:24:57 2015 -0700 @@ -21,7 +21,6 @@ ifeq ($(OSNAME), SunOS) SLASH_JAVA = /java PLATFORM = solaris - JT_PLATFORM = solaris ARCH = $(shell uname -p) ifeq ($(ARCH), i386) ARCH=i586 @@ -30,7 +29,6 @@ ifeq ($(OSNAME), Linux) SLASH_JAVA = /java PLATFORM = linux - JT_PLATFORM = linux ARCH = $(shell uname -m) ifeq ($(ARCH), i386) ARCH=i586 @@ -38,7 +36,6 @@ endif ifeq ($(OSNAME), Darwin) PLATFORM = bsd - JT_PLATFORM = linux ARCH = $(shell uname -m) ifeq ($(ARCH), i386) ARCH=i586 @@ -55,7 +52,6 @@ ifeq ($(PLATFORM), windows) SLASH_JAVA = J: - JT_PLATFORM = win32 ifeq ($(word 1, $(PROCESSOR_IDENTIFIER)),ia64) ARCH=ia64 else @@ -93,8 +89,8 @@ else JTREG_HOME = $(SLASH_JAVA)/re/jtreg/4.1/promoted/latest/binaries/jtreg endif -JTREG = $(JTREG_HOME)/$(JT_PLATFORM)/bin/jtreg -JTDIFF = $(JTREG_HOME)/$(JT_PLATFORM)/bin/jtdiff +JTREG = $(JTREG_HOME)/bin/jtreg +JTDIFF = $(JTREG_HOME)/bin/jtdiff # Default JCK to run ifdef JPRT_JCK_HOME
--- a/test/com/sun/javadoc/testStylesheet/TestStylesheet.java Mon Jun 08 11:10:05 2015 -0700 +++ b/test/com/sun/javadoc/testStylesheet/TestStylesheet.java Mon Jun 08 12:24:57 2015 -0700 @@ -1,5 +1,5 @@ /* - * Copyright (c) 2005, 2013, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2005, 2015, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -23,7 +23,7 @@ /* * @test - * @bug 4494033 7028815 7052425 8007338 8023608 8008164 8016549 + * @bug 4494033 7028815 7052425 8007338 8023608 8008164 8016549 8072461 * @summary Run tests on doclet stylesheet. * @author jamieh * @library ../lib/ @@ -34,7 +34,7 @@ public class TestStylesheet extends JavadocTester { //Test information. - private static final String BUG_ID = "4494033-7028815-7052425-8007338"; + private static final String BUG_ID = "4494033-7028815-7052425-8007338-8072461"; //Javadoc arguments. private static final String[] ARGS = new String[] { @@ -123,6 +123,23 @@ "}"}, {BUG_ID + FS + "stylesheet.css", "@import url('resources/fonts/dejavu.css');"}, + // Test the formatting styles for proper content display in use and constant values pages. + {BUG_ID + FS + "stylesheet.css", + ".overviewSummary td.colFirst, .overviewSummary th.colFirst," + NL + + ".useSummary td.colFirst, .useSummary th.colFirst," + NL + + ".overviewSummary td.colOne, .overviewSummary th.colOne," + NL + + ".memberSummary td.colFirst, .memberSummary th.colFirst," + NL + + ".memberSummary td.colOne, .memberSummary th.colOne," + NL + + ".typeSummary td.colFirst{" + NL + + " width:25%;" + NL + + " vertical-align:top;" + NL + + "}"}, + {BUG_ID + FS + "stylesheet.css", + ".overviewSummary td, .memberSummary td, .typeSummary td," + NL + + ".useSummary td, .constantsSummary td, .deprecatedSummary td {" + NL + + " text-align:left;" + NL + + " padding:0px 0px 12px 10px;" + NL + + "}"}, // Test whether a link to the stylesheet file is inserted properly // in the class documentation. {BUG_ID + FS + "pkg" + FS + "A.html",
--- a/test/tools/javac/MethodParameters/ClassFileVisitor.java Mon Jun 08 11:10:05 2015 -0700 +++ b/test/tools/javac/MethodParameters/ClassFileVisitor.java Mon Jun 08 12:24:57 2015 -0700 @@ -147,6 +147,7 @@ public int mAttrs; public int mNumParams; public boolean mSynthetic; + public boolean mIsLambda; public boolean mIsConstructor; public boolean mIsClinit; public boolean mIsBridge; @@ -165,6 +166,7 @@ mIsClinit = mName.equals("<clinit>"); prefix = cname + "." + mName + "() - "; mIsBridge = method.access_flags.is(AccessFlags.ACC_BRIDGE); + mIsLambda = mSynthetic && mName.startsWith("lambda$"); if (mIsClinit) { sb = new StringBuilder(); // Discard output @@ -225,7 +227,7 @@ // IMPL: Whether MethodParameters attributes will be generated // for some synthetics is unresolved. For now, assume no. - if (mSynthetic) { + if (mSynthetic && !mIsLambda) { warn(prefix + "synthetic has MethodParameter attribute"); } @@ -349,10 +351,12 @@ } else if (isEnum && mNumParams == 1 && index == 0 && mName.equals("valueOf")) { expect = "name"; allowMandated = true; - } else if (mIsBridge) { + } else if (mIsBridge || mIsLambda) { allowSynthetic = true; /* you can't expect an special name for bridges' parameters. - * The name of the original parameters are now copied. + * The name of the original parameters are now copied. Likewise + * for a method encoding the lambda expression, names are derived + * from source lambda's parameters and captured enclosing locals. */ expect = null; }
--- a/test/tools/javac/MethodParameters/LambdaTest.java Mon Jun 08 11:10:05 2015 -0700 +++ b/test/tools/javac/MethodParameters/LambdaTest.java Mon Jun 08 12:24:57 2015 -0700 @@ -1,5 +1,5 @@ /* - * Copyright (c) 2013, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2013, 2015, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -23,7 +23,7 @@ /* * @test - * @bug 8006582 + * @bug 8006582 8037546 * @summary javac should generate method parameters correctly. * @build Tester * @compile -parameters LambdaTest.java @@ -31,8 +31,8 @@ */ /** - * Parameter names are not recorded for lambdas. This test verifies - * that there are no MethodParameters attribute for lambdas. + * Post https://bugs.openjdk.java.net/browse/JDK-8037546, this test verifies + * that MethodParameters attribute for lambdas are emitted properly. */ class LambdaTest {
--- a/test/tools/javac/MethodParameters/LambdaTest.out Mon Jun 08 11:10:05 2015 -0700 +++ b/test/tools/javac/MethodParameters/LambdaTest.out Mon Jun 08 12:24:57 2015 -0700 @@ -1,7 +1,7 @@ class LambdaTest -- LambdaTest.<init>() LambdaTest.foo(i) -LambdaTest.lambda$static$1(arg0)/*synthetic*/ -LambdaTest.lambda$null$0(arg0, arg1)/*synthetic*/ +LambdaTest.lambda$static$1(x1/*synthetic*/)/*synthetic*/ +LambdaTest.lambda$null$0(final x1/*synthetic*/, x2/*synthetic*/)/*synthetic*/ static interface LambdaTest$I -- inner LambdaTest$I.m(x)
--- a/test/tools/javac/MethodParameters/ReflectionVisitor.java Mon Jun 08 11:10:05 2015 -0700 +++ b/test/tools/javac/MethodParameters/ReflectionVisitor.java Mon Jun 08 12:24:57 2015 -0700 @@ -277,7 +277,7 @@ param = "final " + param; } sb.append(sep).append(param); - if (!m.isBridge() && !expect.equals(param)) { + if (!m.isBridge() && !m.getName().startsWith("lambda$") && !expect.equals(param)) { error(prefix + "param[" + i + "]='" + param + "' expected '" + expect + "'"); break;
--- a/test/tools/javac/annotations/6214965/T6214965.java Mon Jun 08 11:10:05 2015 -0700 +++ b/test/tools/javac/annotations/6214965/T6214965.java Mon Jun 08 12:24:57 2015 -0700 @@ -1,5 +1,5 @@ /* - * Copyright (c) 2005, 2010, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2005, 2015, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -23,9 +23,10 @@ /** * @test - * @bug 6214965 6365854 + * @bug 6214965 6365854 8068639 * @summary Compiler crash on redefing nested annotation types * @compile CompilerAnnotationTest.java CompilerAnnotationTest2.java * @compile CompilerAnnotationTest2bad.java - * @compile/ref=T6214965.out -XDrawDiagnostics CompilerAnnotationTest2bad.java + * @compile/ref=T6214965.out -XDrawDiagnostics -Xlint:classfile CompilerAnnotationTest2bad.java + * @compile -Werror CompilerAnnotationTest2bad.java */
--- a/test/tools/javac/annotations/6365854/T6365854.java Mon Jun 08 11:10:05 2015 -0700 +++ b/test/tools/javac/annotations/6365854/T6365854.java Mon Jun 08 12:24:57 2015 -0700 @@ -1,5 +1,5 @@ /* - * Copyright (c) 2005, 2010, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2005, 2015, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -23,7 +23,7 @@ /** * @test - * @bug 6365854 + * @bug 6365854 8068639 * @summary javac crashes when compiling against an annotated class * @compile TestAnnotation.java TestCore.java * @clean test.annotation.TestAnnotation @@ -33,11 +33,11 @@ * * @compile TestAnnotation.java TestCore.java * @clean test.annotation.TestAnnotation - * @compile/ref=test1.out -XDrawDiagnostics T6365854.java + * @compile/ref=test1.out -XDrawDiagnostics -Xlint:classfile T6365854.java * @run main T6365854 - * @compile/ref=test2.out -XDrawDiagnostics evolve/TestAnnotation.java T6365854.java + * @compile/ref=test2.out -XDrawDiagnostics -Xlint:classfile evolve/TestAnnotation.java T6365854.java * @run main T6365854 - * @compile/ref=test2.out -XDrawDiagnostics T6365854.java + * @compile/ref=test2.out -XDrawDiagnostics -Xlint:classfile T6365854.java * @run main T6365854 */
--- a/test/tools/javac/annotations/typeAnnotations/classfile/TestAnonInnerClasses.java Mon Jun 08 11:10:05 2015 -0700 +++ b/test/tools/javac/annotations/typeAnnotations/classfile/TestAnonInnerClasses.java Mon Jun 08 12:24:57 2015 -0700 @@ -1,5 +1,5 @@ /* - * Copyright (c) 2013 Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2013, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/test/tools/javac/classfiles/InnerClasses/T8068517.java Mon Jun 08 12:24:57 2015 -0700 @@ -0,0 +1,126 @@ +/* + * Copyright (c) 2015, Oracle and/or its affiliates. All rights reserved. + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * This code is free software; you can redistribute it and/or modify it + * under the terms of the GNU General Public License version 2 only, as + * published by the Free Software Foundation. + * + * This code is distributed in the hope that it will be useful, but WITHOUT + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License + * version 2 for more details (a copy is included in the LICENSE file that + * accompanied this code). + * + * You should have received a copy of the GNU General Public License version + * 2 along with this work; if not, write to the Free Software Foundation, + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. + * + * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA + * or visit www.oracle.com if you need additional information or have any + * questions. + */ + +/** @test + * @bug 8068517 + * @summary Verify that nested enums have correct abstract flag in the InnerClasses attribute. + * @library /tools/javac/lib + * @build ToolBox T8068517 + * @run main T8068517 + */ + +import com.sun.tools.javac.util.Assert; +import java.io.File; +import java.nio.file.Files; +import java.util.Arrays; +import java.util.List; +import java.util.stream.Collectors; +import java.util.stream.Stream; +import javax.tools.JavaCompiler; +import javax.tools.ToolProvider; + +public class T8068517 { + + public static void main(String[] args) throws Exception { + new T8068517().run(); + } + + void run() throws Exception { + runTest("class A {\n" + + " enum AInner implements Runnable {\n" + + " A {\n" + + " public void run() {}\n" + + " };\n" + + " }\n" + + "}\n", + "class B {\n" + + " A.AInner a;\n" + + "}"); + runTest("class A {\n" + + " enum AInner implements Runnable {\n" + + " A {\n" + + " public void run() {}\n" + + " };\n" + + " }\n" + + " AInner aInner;\n" + + "}\n", + "class B {\n" + + " void test(A a) {;\n" + + " switch (a.aInner) {\n" + + " case A: break;\n" + + " }\n" + + " };\n" + + "}"); + runTest("class A {\n" + + " enum AInner implements Runnable {\n" + + " A {\n" + + " public void run() {}\n" + + " };\n" + + " }\n" + + " AInner aInner;\n" + + "}\n", + "class B {\n" + + " void test(A a) {;\n" + + " System.err.println(a.aInner.toString());\n" + + " };\n" + + "}"); + runTest("class A {\n" + + " enum AInner implements Runnable {\n" + + " A {\n" + + " public void run() {}\n" + + " };\n" + + " }\n" + + " AInner aInner() {\n" + + " return null;\n" + + " }\n" + + "}\n", + "class B {\n" + + " void test(A a) {;\n" + + " System.err.println(a.aInner().toString());\n" + + " };\n" + + "}"); + } + + JavaCompiler compiler = ToolProvider.getSystemJavaCompiler(); + int testN = 0; + + void runTest(String aJava, String bJava) throws Exception { + File testClasses = new File(System.getProperty("test.classes")); + File target1 = new File(testClasses, "T8068517s" + testN++); + doCompile(target1, aJava, bJava); + File target2 = new File(testClasses, "T8068517s" + testN++); + doCompile(target2, bJava, aJava); + + Assert.check(Arrays.equals(Files.readAllBytes(new File(target1, "B.class").toPath()), + Files.readAllBytes(new File(target2, "B.class").toPath()))); + } + + void doCompile(File target, String... sources) throws Exception { + target.mkdirs(); + List<String> options = Arrays.asList("-d", target.getAbsolutePath()); + List<ToolBox.JavaSource> files = Stream.of(sources) + .map(ToolBox.JavaSource::new) + .collect(Collectors.toList()); + compiler.getTask(null, null, null, options, null, files).call(); + } +}
--- a/test/tools/javac/diags/examples/MrefInferAndExplicitParams.java Mon Jun 08 11:10:05 2015 -0700 +++ b/test/tools/javac/diags/examples/MrefInferAndExplicitParams.java Mon Jun 08 12:24:57 2015 -0700 @@ -8,7 +8,7 @@ * * This code is distributed in the hope that it will be useful, but WITHOUT * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or - * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License * version 2 for more details (a copy is included in the LICENSE file that * accompanied this code). *
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/test/tools/javac/enum/8069181/T8069181.java Mon Jun 08 12:24:57 2015 -0700 @@ -0,0 +1,45 @@ +/* + * Copyright (c) 2015, Oracle and/or its affiliates. All rights reserved. + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * This code is free software; you can redistribute it and/or modify it + * under the terms of the GNU General Public License version 2 only, as + * published by the Free Software Foundation. Oracle designates this + * particular file as subject to the "Classpath" exception as provided + * by Oracle in the LICENSE file that accompanied this code. + * + * This code is distributed in the hope that it will be useful, but WITHOUT + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License + * version 2 for more details (a copy is included in the LICENSE file that + * accompanied this code). + * + * You should have received a copy of the GNU General Public License version + * 2 along with this work; if not, write to the Free Software Foundation, + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. + * + * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA + * or visit www.oracle.com if you need additional information or have any + * questions. + */ + +/* + * @test + * @bug 8069181 + * @summary java.lang.AssertionError when compiling JDK 1.4 code in JDK 8 + * + * @compile -source 1.4 T8069181.java + */ +import java.util.Enumeration; +import java.util.Hashtable; +class T8069181 { + void test() { + Hashtable hTable = new Hashtable(); + hTable.put("hello", "value"); + for (Enumeration enum = hTable.keys();;){ + if(!enum.hasMoreElements()) + break; + enum.nextElement(); + } + } +}
--- a/test/tools/javac/flow/LVTHarness.java Mon Jun 08 11:10:05 2015 -0700 +++ b/test/tools/javac/flow/LVTHarness.java Mon Jun 08 12:24:57 2015 -0700 @@ -1,5 +1,5 @@ /* - * Copyright (c) 2013, 2014, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2013, 2015, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -23,7 +23,7 @@ /* * @test - * @bug 7047734 8027660 8037937 8047719 8058708 + * @bug 7047734 8027660 8037937 8047719 8058708 8064857 * @summary The LVT is not generated correctly during some try/catch scenarios * javac crash while creating LVT entry for a local variable defined in * an inner block @@ -144,7 +144,7 @@ } void checkMethod(ConstantPool constantPool, Method method, AliveRanges ranges) - throws InvalidIndex, UnexpectedEntry { + throws InvalidIndex, UnexpectedEntry, ConstantPoolException { Code_attribute code = (Code_attribute) method.attributes.get(Attribute.Code); LocalVariableTable_attribute lvt = (LocalVariableTable_attribute) (code.attributes.get(Attribute.LocalVariableTable)); @@ -166,7 +166,7 @@ } if (i < infoFromRanges.size()) { - error(infoFromLVT, infoFromRanges); + error(infoFromLVT, infoFromRanges, method.getName(constantPool).toString()); } } @@ -202,9 +202,10 @@ return sb.toString(); } - protected void error(List<String> infoFromLVT, List<String> infoFromRanges) { + protected void error(List<String> infoFromLVT, List<String> infoFromRanges, String methodName) { nerrors++; System.err.printf("Error occurred while checking file: %s\n", jfo.getName()); + System.err.printf("at method: %s\n", methodName); System.err.println("The range info from the annotations is"); printStringListToErrOutput(infoFromRanges); System.err.println();
--- a/test/tools/javac/flow/tests/TestCaseFor.java Mon Jun 08 11:10:05 2015 -0700 +++ b/test/tools/javac/flow/tests/TestCaseFor.java Mon Jun 08 12:24:57 2015 -0700 @@ -2,7 +2,7 @@ public class TestCaseFor { - @AliveRange(varName="o", bytecodeStart=10, bytecodeLength=8) + @AliveRange(varName="o", bytecodeStart=10, bytecodeLength=11) @AliveRange(varName="o", bytecodeStart=24, bytecodeLength=1) void m1(String[] args) { Object o; @@ -13,7 +13,7 @@ o = ""; } - @AliveRange(varName="o", bytecodeStart=10, bytecodeLength=8) + @AliveRange(varName="o", bytecodeStart=10, bytecodeLength=11) @AliveRange(varName="o", bytecodeStart=24, bytecodeLength=1) void m2(String[] args) { Object o;
--- a/test/tools/javac/flow/tests/TestCaseForEach.java Mon Jun 08 11:10:05 2015 -0700 +++ b/test/tools/javac/flow/tests/TestCaseForEach.java Mon Jun 08 12:24:57 2015 -0700 @@ -2,7 +2,7 @@ public class TestCaseForEach { - @AliveRange(varName="o", bytecodeStart=25, bytecodeLength=8) + @AliveRange(varName="o", bytecodeStart=25, bytecodeLength=11) @AliveRange(varName="o", bytecodeStart=39, bytecodeLength=1) void m(String[] args) { Object o;
--- a/test/tools/javac/flow/tests/TestCaseIfElse.java Mon Jun 08 11:10:05 2015 -0700 +++ b/test/tools/javac/flow/tests/TestCaseIfElse.java Mon Jun 08 12:24:57 2015 -0700 @@ -60,4 +60,19 @@ } return null; } + + @AliveRange(varName="i", bytecodeStart=6, bytecodeLength=2) + int m4(boolean flag) { + int i; + label: + { + if (flag) { + i = 1; + } else { + break label; + } + return i; + } + return -1; + } }
--- a/test/tools/javac/flow/tests/TestCaseSwitch.java Mon Jun 08 11:10:05 2015 -0700 +++ b/test/tools/javac/flow/tests/TestCaseSwitch.java Mon Jun 08 12:24:57 2015 -0700 @@ -81,4 +81,26 @@ o = "finish"; } + @AliveRange(varName="oCache", bytecodeStart=30, bytecodeLength=6) + @AliveRange(varName="cache", bytecodeStart=41, bytecodeLength=3) + @AliveRange(varName="cache", bytecodeStart=54, bytecodeLength=2) + @AliveRange(varName="service", bytecodeStart=39, bytecodeLength=5) + Object m4(int i) { + Object cache; + switch (i) { + case 0: + Object oCache = null; + if (oCache != null) { + return oCache; + } + case 1: + Object service = null; + cache = null; + break; + default: + throw new AssertionError(""); + } + return cache; + } + }
--- a/test/tools/javac/flow/tests/TestCaseTry.java Mon Jun 08 11:10:05 2015 -0700 +++ b/test/tools/javac/flow/tests/TestCaseTry.java Mon Jun 08 12:24:57 2015 -0700 @@ -17,7 +17,8 @@ } @AliveRange(varName="o", bytecodeStart=3, bytecodeLength=16) - @AliveRange(varName="o", bytecodeStart=23, bytecodeLength=23) + @AliveRange(varName="o", bytecodeStart=23, bytecodeLength=8) + @AliveRange(varName="o", bytecodeStart=35, bytecodeLength=11) void m1() { Object o; try { @@ -33,7 +34,8 @@ } @AliveRange(varName="o", bytecodeStart=3, bytecodeLength=16) - @AliveRange(varName="o", bytecodeStart=23, bytecodeLength=31) + @AliveRange(varName="o", bytecodeStart=23, bytecodeLength=16) + @AliveRange(varName="o", bytecodeStart=43, bytecodeLength=11) void m2() { Object o; try { @@ -51,7 +53,8 @@ } @AliveRange(varName="o", bytecodeStart=22, bytecodeLength=38) - @AliveRange(varName="o", bytecodeStart=103, bytecodeLength=8) + @AliveRange(varName="o", bytecodeStart=103, bytecodeLength=3) + @AliveRange(varName="o", bytecodeStart=110, bytecodeLength=1) void m3() { Object o; try (BufferedReader br =
--- a/test/tools/javac/flow/tests/TestCaseWhile.java Mon Jun 08 11:10:05 2015 -0700 +++ b/test/tools/javac/flow/tests/TestCaseWhile.java Mon Jun 08 12:24:57 2015 -0700 @@ -2,7 +2,7 @@ public class TestCaseWhile { - @AliveRange(varName="o", bytecodeStart=9, bytecodeLength=5) + @AliveRange(varName="o", bytecodeStart=9, bytecodeLength=8) @AliveRange(varName="o", bytecodeStart=20, bytecodeLength=1) void m(String[] args) { Object o;
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/test/tools/javac/generics/8064803/T8064803.java Mon Jun 08 12:24:57 2015 -0700 @@ -0,0 +1,53 @@ +/* + * Copyright (c) 2014, Oracle and/or its affiliates. All rights reserved. + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * This code is free software; you can redistribute it and/or modify it + * under the terms of the GNU General Public License version 2 only, as + * published by the Free Software Foundation. Oracle designates this + * particular file as subject to the "Classpath" exception as provided + * by Oracle in the LICENSE file that accompanied this code. + * + * This code is distributed in the hope that it will be useful, but WITHOUT + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License + * version 2 for more details (a copy is included in the LICENSE file that + * accompanied this code). + * + * You should have received a copy of the GNU General Public License version + * 2 along with this work; if not, write to the Free Software Foundation, + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. + * + * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA + * or visit www.oracle.com if you need additional information or have any + * questions. + */ + +/* + * @test + * @bug 8064803 + * @summary Javac erroneously uses instantiated signatures when merging abstract most-specific methods + */ +public class T8064803 { + interface ParentA<T> { + T process() throws Exception; + } + + interface ParentB<T> { + T process() throws Exception; + } + + interface Child<T> extends ParentA<T>, ParentB<T> { } + + static class ChildImpl<T> implements Child<T> { + @Override + public T process() { + return null; + } + } + + public static void main(String[] args) throws Exception { + Child<String> child = new ChildImpl<String>(); + child.process(); + } +}
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/test/tools/javac/generics/inference/8055963/T8055963.java Mon Jun 08 12:24:57 2015 -0700 @@ -0,0 +1,41 @@ +/* + * Copyright (c) 2014, Oracle and/or its affiliates. All rights reserved. + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * This code is free software; you can redistribute it and/or modify it + * under the terms of the GNU General Public License version 2 only, as + * published by the Free Software Foundation. Oracle designates this + * particular file as subject to the "Classpath" exception as provided + * by Oracle in the LICENSE file that accompanied this code. + * + * This code is distributed in the hope that it will be useful, but WITHOUT + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License + * version 2 for more details (a copy is included in the LICENSE file that + * accompanied this code). + * + * You should have received a copy of the GNU General Public License version + * 2 along with this work; if not, write to the Free Software Foundation, + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. + * + * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA + * or visit www.oracle.com if you need additional information or have any + * questions. + */ + +/** + * @test + * @bug 8055963 + * @summary Inference failure with nested invocation + * @compile T8055963.java + */ +class T8055963 { + + static class C<T> {} + + <T> T choose(T first, T second) { return null; } + + void test() { + C<String> cs = choose(new C<String>(), new C<>()); + } +}
--- a/test/tools/javac/lambda/8016177/T8016177g.java Mon Jun 08 11:10:05 2015 -0700 +++ b/test/tools/javac/lambda/8016177/T8016177g.java Mon Jun 08 12:24:57 2015 -0700 @@ -1,6 +1,6 @@ /* * @test /nodynamiccopyright/ - * @bug 8016081 8016178 + * @bug 8016081 8016178 8069545 * @summary structural most specific and stuckness * @compile/fail/ref=T8016177g.out -XDrawDiagnostics T8016177g.java */
--- a/test/tools/javac/lambda/8016177/T8016177g.out Mon Jun 08 11:10:05 2015 -0700 +++ b/test/tools/javac/lambda/8016177/T8016177g.out Mon Jun 08 12:24:57 2015 -0700 @@ -1,2 +1,3 @@ -T8016177g.java:35:20: compiler.err.prob.found.req: (compiler.misc.possible.loss.of.precision: double, int) -1 error +T8016177g.java:34:14: compiler.err.cant.apply.symbol: kindname.method, print, java.lang.String, Test.Person, kindname.class, Test, (compiler.misc.no.conforming.assignment.exists: (compiler.misc.inferred.do.not.conform.to.upper.bounds: Test.Person, java.lang.String,java.lang.Object)) +T8016177g.java:35:20: compiler.err.cant.apply.symbol: kindname.method, abs, int, java.lang.Double, kindname.class, Test, (compiler.misc.no.conforming.assignment.exists: (compiler.misc.infer.no.conforming.instance.exists: , R, int)) +2 errors
--- a/test/tools/javac/lambda/8023389/T8023389.java Mon Jun 08 11:10:05 2015 -0700 +++ b/test/tools/javac/lambda/8023389/T8023389.java Mon Jun 08 12:24:57 2015 -0700 @@ -8,7 +8,7 @@ * * This code is distributed in the hope that it will be useful, but WITHOUT * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or - * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License * version 2 for more details (a copy is included in the LICENSE file that * accompanied this code). *
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/test/tools/javac/lambda/8068399/T8068399.java Mon Jun 08 12:24:57 2015 -0700 @@ -0,0 +1,119 @@ +/* + * Copyright (c) 2015, Oracle and/or its affiliates. All rights reserved. + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * This code is free software; you can redistribute it and/or modify it + * under the terms of the GNU General Public License version 2 only, as + * published by the Free Software Foundation. Oracle designates this + * particular file as subject to the "Classpath" exception as provided + * by Oracle in the LICENSE file that accompanied this code. + * + * This code is distributed in the hope that it will be useful, but WITHOUT + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License + * version 2 for more details (a copy is included in the LICENSE file that + * accompanied this code). + * + * You should have received a copy of the GNU General Public License version + * 2 along with this work; if not, write to the Free Software Foundation, + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. + * + * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA + * or visit www.oracle.com if you need additional information or have any + * questions. + */ +/* + * @test + * @bug 8068399 + * @summary structural most specific and stuckness + */ + +import java.util.function.Function; +import java.util.stream.IntStream; +import java.util.stream.Stream; + +public class T8068399 { + + public static class Spectrum { + public double[] getEnergy() { + return new double[0]; + } + } + + protected Spectrum spectrum; + + public static class Ref<T> { + + T value; + + public Ref() { + } + + public Ref(T value) { + this.value = value; + } + + public boolean isNull() { + return value == null; + } + + public T get() { + return value; + } + + public void set(T value) { + this.value = value; + } + } + + public static <T>T maxKey(Stream<T> stream, Function<T, Double> function) { + Ref<Double> max = new Ref<>(); + Ref<T> index = new Ref<>(); + stream.forEach(v -> { + Double value = function.apply(v); + + if (max.isNull() || value > max.get()) { + max.set(value); + index.set(v); + } + }); + + return index.get(); + } + + public static int interpolate(int x, int x0, int x1, int y0, int y1) { + return y0 + (x - x0) * (y1 - y0) / (x1 - x0); + } + + public static double interpolate(double x, double x0, double x1, double y0, double y1) { + return y0 + (x - x0) * (y1 - y0) / (x1 - x0); + } + + protected int getXByFrequency(double frequency) { + return (int) Math.round(interpolate(frequency, + getMinSpectrumCoord(), + getMaxSpectrumCoord(), + 0, getWidth())); + } + + private int getWidth() { + return 0; + } + + private double getMaxSpectrumCoord() { + return 0; + } + + private double getMinSpectrumCoord() { + return 0; + } + + void foo() { + int maxBpmIndex = 0; + int xcur = getXByFrequency(maxKey(IntStream.range(0, maxBpmIndex).boxed(), + i -> Math.abs(spectrum.getEnergy()[i]))); + } + + public static void main(String [] args) { + } +}
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/test/tools/javac/lambda/8068430/T8068430.java Mon Jun 08 12:24:57 2015 -0700 @@ -0,0 +1,46 @@ +/* + * Copyright (c) 2015, Oracle and/or its affiliates. All rights reserved. + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * This code is free software; you can redistribute it and/or modify it + * under the terms of the GNU General Public License version 2 only, as + * published by the Free Software Foundation. Oracle designates this + * particular file as subject to the "Classpath" exception as provided + * by Oracle in the LICENSE file that accompanied this code. + * + * This code is distributed in the hope that it will be useful, but WITHOUT + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License + * version 2 for more details (a copy is included in the LICENSE file that + * accompanied this code). + * + * You should have received a copy of the GNU General Public License version + * 2 along with this work; if not, write to the Free Software Foundation, + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. + * + * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA + * or visit www.oracle.com if you need additional information or have any + * questions. + */ + +/* + * @test + * @bug 8068430 + * @summary structural most specific and stuckness + */ + +import java.util.HashMap; +import java.util.Map; + +public class T8068430 { + public static void main(String[] args) { + Map<Integer, String> mp = new HashMap<>(); + mp.put(1, "a"); + mp.put(2, "b"); + mp.put(3, "c"); + mp.put(4, "d"); + System.out.println(mp.entrySet().stream().reduce(0, + (i, e) -> i + e.getKey(), + (i1, i2) -> i1 + i2)); + } +} \ No newline at end of file
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/test/tools/javac/lambda/8071432/T8071432.java Mon Jun 08 12:24:57 2015 -0700 @@ -0,0 +1,50 @@ +/* + * @test /nodynamiccopyright/ + * @bug 8071432 + * @summary structural most specific and stuckness + * @compile/fail/ref=T8071432.out -XDrawDiagnostics T8071432.java + */ + +import java.util.Arrays; +import java.util.Collection; + +class T8071432 { + + static class Point { + + private double x, y; + + public Point(double x, double y) { + this.x = x; + this.y = y; + } + + public double getX() { + return x; + } + + public double getY() { + return y; + } + + public double distance(Point p) { + return Math.sqrt((this.x - p.x) * (this.x - p.x) + + (this.y - p.y) * (this.y - p.y)); + } + + public double distance() { + return Math.sqrt(this.x * this.x + this.y * this.y); + } + + public String toString() { + return "(" + x + ":" + y + ")"; + } + } + + public static void main(String[] args) { + Collection<Point> c = Arrays.asList(new Point(1.0, 0.1)); + System.out.println("------- 1 ---------------"); + System.out.println(c.stream().reduce(0.0, + (s, p) -> s += p.distance(), (d1, d2) -> 0)); + } +}
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/test/tools/javac/lambda/8071432/T8071432.out Mon Jun 08 12:24:57 2015 -0700 @@ -0,0 +1,3 @@ +T8071432.java:47:45: compiler.err.prob.found.req: (compiler.misc.infer.no.conforming.assignment.exists: U, (compiler.misc.incompatible.ret.type.in.lambda: (compiler.misc.inconvertible.types: int, java.lang.Double))) +T8071432.java:47:27: compiler.err.cant.apply.symbol: kindname.method, println, java.lang.Object, <any>, kindname.class, java.io.PrintStream, (compiler.misc.no.conforming.assignment.exists: (compiler.misc.infer.no.conforming.assignment.exists: U, (compiler.misc.incompatible.ret.type.in.lambda: (compiler.misc.inconvertible.types: int, java.lang.Double)))) +2 errors
--- a/test/tools/javac/lambda/LambdaExprLeadsToMissingClassFilesTest.java Mon Jun 08 11:10:05 2015 -0700 +++ b/test/tools/javac/lambda/LambdaExprLeadsToMissingClassFilesTest.java Mon Jun 08 12:24:57 2015 -0700 @@ -1,5 +1,5 @@ /* - * Copyright (c) 2012, 2014 Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2012, 2014, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it
--- a/test/tools/javac/lambda/LocalVariableTable.java Mon Jun 08 11:10:05 2015 -0700 +++ b/test/tools/javac/lambda/LocalVariableTable.java Mon Jun 08 12:24:57 2015 -0700 @@ -23,7 +23,7 @@ /* * @test - * @bug 8025998 8026749 + * @bug 8025998 8026749 8054220 8058227 * @summary Missing LV table in lambda bodies * @compile -g LocalVariableTable.java * @run main LocalVariableTable @@ -183,7 +183,7 @@ Run1 r = (a) -> { int x = a; }; } - @Expect({ "a", "x" }) + @Expect({ "a", "x", "v" }) static class Lambda_Args1_Local1_Captured1 { void m() { int v = 0; @@ -191,7 +191,7 @@ } } - @Expect({ "a1", "a2", "x1", "x2", "this" }) + @Expect({ "a1", "a2", "x1", "x2", "this", "v1", "v2" }) static class Lambda_Args2_Local2_Captured2_this { int v; void m() { @@ -204,7 +204,7 @@ } } - @Expect({ "e" }) + @Expect({ "e", "c" }) static class Lambda_Try_Catch { private static Runnable asUncheckedRunnable(Closeable c) { return () -> {
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/test/tools/javac/linenumbers/NestedLineNumberTest.java Mon Jun 08 12:24:57 2015 -0700 @@ -0,0 +1,81 @@ +/* + * Copyright (c) 2014, Oracle and/or its affiliates. All rights reserved. + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * This code is free software; you can redistribute it and/or modify it + * under the terms of the GNU General Public License version 2 only, as + * published by the Free Software Foundation. Oracle designates this + * particular file as subject to the "Classpath" exception as provided + * by Oracle in the LICENSE file that accompanied this code. + * + * This code is distributed in the hope that it will be useful, but WITHOUT + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License + * version 2 for more details (a copy is included in the LICENSE file that + * accompanied this code). + * + * You should have received a copy of the GNU General Public License version + * 2 along with this work; if not, write to the Free Software Foundation, + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. + * + * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA + * or visit www.oracle.com if you need additional information or have any + * questions. + */ + +/* + * @test + * @bug 8061778 + * @summary Wrong LineNumberTable for default constructors + */ + +import com.sun.tools.classfile.ClassFile; +import com.sun.tools.classfile.ConstantPoolException; +import com.sun.tools.classfile.Method; +import com.sun.tools.classfile.Attribute; +import com.sun.tools.classfile.Code_attribute; +import com.sun.tools.classfile.LineNumberTable_attribute; +import com.sun.tools.classfile.LineNumberTable_attribute.Entry; + +import java.io.IOException; + +public class NestedLineNumberTest { + + public static void main(String[] args) throws Exception { + Entry[] lines = findEntries(); + if (lines == null || lines.length != 1) { + int found = lines == null ? 0 : lines.length; + error(String.format("LineNumberTable contains wrong number of entries - expected %d, found %d", 1, found)); + } + + int line = lines[0].line_number; + if (line != 78) { + error(String.format("LineNumberTable contains wrong line number - expected %d, found %d", 78, line)); + } + } + + static Entry[] findEntries() throws IOException, ConstantPoolException { + ClassFile self = ClassFile.read(NestedLineNumberTest.Test.class.getResourceAsStream("NestedLineNumberTest$Test.class")); + for (Method m : self.methods) { + if ("<init>".equals(m.getName(self.constant_pool))) { + Code_attribute code_attribute = (Code_attribute)m.attributes.get(Attribute.Code); + for (Attribute at : code_attribute.attributes) { + if (Attribute.LineNumberTable.equals(at.getName(self.constant_pool))) { + return ((LineNumberTable_attribute)at).line_number_table; + } + } + } + } + return null; + } + + static void error(String msg) { + throw new AssertionError(msg); + } + + // The default constructor in this class should get only one LineNumberTable entry, + // pointing to the first line of the declaration of class Test. + static class Test { + static class Empty { } + } +}
--- a/test/tools/javac/resolve/tests/PrimitiveVsReferenceSamePhase.java Mon Jun 08 11:10:05 2015 -0700 +++ b/test/tools/javac/resolve/tests/PrimitiveVsReferenceSamePhase.java Mon Jun 08 12:24:57 2015 -0700 @@ -1,5 +1,5 @@ /* - * Copyright (c) 2014 Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2014, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it
--- a/test/tools/javac/varargs/T8049075/VarargsAndWildcardParameterizedTypeTest.java Mon Jun 08 11:10:05 2015 -0700 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,40 +0,0 @@ -/* - * Copyright (c) 2014, Oracle and/or its affiliates. All rights reserved. - * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. - * - * This code is free software; you can redistribute it and/or modify it - * under the terms of the GNU General Public License version 2 only, as - * published by the Free Software Foundation. - * - * This code is distributed in the hope that it will be useful, but WITHOUT - * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or - * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License - * version 2 for more details (a copy is included in the LICENSE file that - * accompanied this code). - * - * You should have received a copy of the GNU General Public License version - * 2 along with this work; if not, write to the Free Software Foundation, - * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. - * - * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA - * or visit www.oracle.com if you need additional information or have any - * questions. - */ - -/* - * @test - * @bug 8049075 - * @summary javac, wildcards and generic vararg method invocation not accepted - * @compile VarargsAndWildcardParameterizedTypeTest.java - */ - -class VarargsAndWildcardParameterizedTypeTest { - interface I<T> { - String m(T... t); - } - - void m() { - I<? super Integer> i = null; - i.m(Integer.valueOf(1), Integer.valueOf(1)); - } -}
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/test/tools/javac/varargs/access/OtherPackage.java Mon Jun 08 12:24:57 2015 -0700 @@ -0,0 +1,36 @@ +/* + * Copyright (c) 2015, Oracle and/or its affiliates. All rights reserved. + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * This code is free software; you can redistribute it and/or modify it + * under the terms of the GNU General Public License version 2 only, as + * published by the Free Software Foundation. + * + * This code is distributed in the hope that it will be useful, but WITHOUT + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License + * version 2 for more details (a copy is included in the LICENSE file that + * accompanied this code). + * + * You should have received a copy of the GNU General Public License version + * 2 along with this work; if not, write to the Free Software Foundation, + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. + * + * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA + * or visit www.oracle.com if you need additional information or have any + * questions. + */ + +/* + * Auxiliary file for VarargsInferredPrivateType + */ + +package otherpackage; + +public class OtherPackage { + public static Private getPrivate() { + return new Private(); + } + + private static class Private {} +} \ No newline at end of file
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/test/tools/javac/varargs/access/VarargsAndWildcardParameterizedTypeTest.java Mon Jun 08 12:24:57 2015 -0700 @@ -0,0 +1,42 @@ +/* + * Copyright (c) 2014, Oracle and/or its affiliates. All rights reserved. + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * This code is free software; you can redistribute it and/or modify it + * under the terms of the GNU General Public License version 2 only, as + * published by the Free Software Foundation. + * + * This code is distributed in the hope that it will be useful, but WITHOUT + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License + * version 2 for more details (a copy is included in the LICENSE file that + * accompanied this code). + * + * You should have received a copy of the GNU General Public License version + * 2 along with this work; if not, write to the Free Software Foundation, + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. + * + * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA + * or visit www.oracle.com if you need additional information or have any + * questions. + */ + +/* + * @test + * @bug 8049075 + * @summary javac, wildcards and generic vararg method invocation not accepted + * @compile VarargsAndWildcardParameterizedTypeTest.java + * @compile -source 8 VarargsAndWildcardParameterizedTypeTest.java + * @compile -source 7 VarargsAndWildcardParameterizedTypeTest.java + */ + +class VarargsAndWildcardParameterizedTypeTest { + interface I<T> { + String m(T... t); + } + + void m() { + I<? super Integer> i = null; + i.m(Integer.valueOf(1), Integer.valueOf(1)); + } +}
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/test/tools/javac/varargs/access/VarargsAndWildcardParameterizedTypeTest2.java Mon Jun 08 12:24:57 2015 -0700 @@ -0,0 +1,45 @@ +/* + * Copyright (c) 2015, Oracle and/or its affiliates. All rights reserved. + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * This code is free software; you can redistribute it and/or modify it + * under the terms of the GNU General Public License version 2 only, as + * published by the Free Software Foundation. + * + * This code is distributed in the hope that it will be useful, but WITHOUT + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License + * version 2 for more details (a copy is included in the LICENSE file that + * accompanied this code). + * + * You should have received a copy of the GNU General Public License version + * 2 along with this work; if not, write to the Free Software Foundation, + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. + * + * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA + * or visit www.oracle.com if you need additional information or have any + * questions. + */ + +/* + * @test + * @bug 8075520 + * @summary Varargs access check mishandles capture variables + * @compile VarargsAndWildcardParameterizedTypeTest2.java + * @compile -source 8 VarargsAndWildcardParameterizedTypeTest2.java + * @compile -source 7 VarargsAndWildcardParameterizedTypeTest2.java + */ + +class VarargsAndWildcardParameterizedTypeTest2 { + interface I { + <T> void m(T... t); + } + + interface Box<T> { + T get(); + } + + void m(I i, Box<? extends Number> b) { + i.m(b.get()); + } +}
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/test/tools/javac/varargs/access/VarargsAndWildcardParameterizedTypeTest3.java Mon Jun 08 12:24:57 2015 -0700 @@ -0,0 +1,43 @@ +/* + * Copyright (c) 2015, Oracle and/or its affiliates. All rights reserved. + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * This code is free software; you can redistribute it and/or modify it + * under the terms of the GNU General Public License version 2 only, as + * published by the Free Software Foundation. + * + * This code is distributed in the hope that it will be useful, but WITHOUT + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License + * version 2 for more details (a copy is included in the LICENSE file that + * accompanied this code). + * + * You should have received a copy of the GNU General Public License version + * 2 along with this work; if not, write to the Free Software Foundation, + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. + * + * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA + * or visit www.oracle.com if you need additional information or have any + * questions. + */ + +/* + * @test + * @bug 8075520 + * @summary Varargs access check mishandles capture variables + * @compile VarargsAndWildcardParameterizedTypeTest3.java + * @compile -source 8 VarargsAndWildcardParameterizedTypeTest3.java + * @compile -source 7 VarargsAndWildcardParameterizedTypeTest3.java + */ + +class VarargsAndWildcardParameterizedTypeTest2 { + interface I { + <T> void m(Box<? extends T> iter, T... t); + } + + interface Box<T> {} + + void m(I i, Box<? extends Number> b) { + i.m(b); + } +}
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/test/tools/javac/varargs/access/VarargsAndWildcardParameterizedTypeTest4.java Mon Jun 08 12:24:57 2015 -0700 @@ -0,0 +1,43 @@ +/* + * Copyright (c) 2015, Oracle and/or its affiliates. All rights reserved. + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * This code is free software; you can redistribute it and/or modify it + * under the terms of the GNU General Public License version 2 only, as + * published by the Free Software Foundation. + * + * This code is distributed in the hope that it will be useful, but WITHOUT + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License + * version 2 for more details (a copy is included in the LICENSE file that + * accompanied this code). + * + * You should have received a copy of the GNU General Public License version + * 2 along with this work; if not, write to the Free Software Foundation, + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. + * + * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA + * or visit www.oracle.com if you need additional information or have any + * questions. + */ + +/* + * @test + * @bug 8075520 + * @summary Varargs access check mishandles capture variables + * @compile VarargsAndWildcardParameterizedTypeTest4.java + * @compile -source 8 VarargsAndWildcardParameterizedTypeTest4.java + * @compile -source 7 VarargsAndWildcardParameterizedTypeTest4.java + */ + +class VarargsAndWildcardParameterizedTypeTest2 { + interface I { + <T> void m(Box<T> iter, T... t); + } + + interface Box<T> {} + + void m(I i, Box<? extends Number> b) { + i.m(b); + } +}
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/test/tools/javac/varargs/access/VarargsInferredPrivateType-source7.out Mon Jun 08 12:24:57 2015 -0700 @@ -0,0 +1,4 @@ +VarargsInferredPrivateType.java:16:10: compiler.err.cant.apply.symbol: kindname.method, m, T[], otherpackage.OtherPackage.Private, kindname.interface, VarargsInferredPrivateType.I, (compiler.misc.inaccessible.varargs.type: otherpackage.OtherPackage.Private, kindname.class, VarargsInferredPrivateType) +- compiler.note.unchecked.filename: VarargsInferredPrivateType.java +- compiler.note.unchecked.recompile +1 error
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/test/tools/javac/varargs/access/VarargsInferredPrivateType.java Mon Jun 08 12:24:57 2015 -0700 @@ -0,0 +1,18 @@ +/* + * @test /nodynamiccopyright/ + * @bug 8077786 + * @summary Check varargs access against inferred signature + * @compile/fail/ref=VarargsInferredPrivateType.out -nowarn -XDrawDiagnostics VarargsInferredPrivateType.java OtherPackage.java + * @compile/fail/ref=VarargsInferredPrivateType.out -source 8 -nowarn -XDrawDiagnostics VarargsInferredPrivateType.java OtherPackage.java + * @compile/fail/ref=VarargsInferredPrivateType-source7.out -source 7 -nowarn -XDrawDiagnostics VarargsInferredPrivateType.java OtherPackage.java + */ + +class VarargsInferredPrivateType { + interface I { + <T> void m(T... t); + } + + void m(I i) { + i.m(otherpackage.OtherPackage.getPrivate()); + } +}
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/test/tools/javac/varargs/access/VarargsInferredPrivateType.out Mon Jun 08 12:24:57 2015 -0700 @@ -0,0 +1,4 @@ +VarargsInferredPrivateType.java:16:12: compiler.err.prob.found.req: (compiler.misc.inaccessible.varargs.type: otherpackage.OtherPackage.Private, kindname.class, VarargsInferredPrivateType) +- compiler.note.unchecked.filename: VarargsInferredPrivateType.java +- compiler.note.unchecked.recompile +1 error
--- a/test/tools/jdeps/APIDeps.java Mon Jun 08 11:10:05 2015 -0700 +++ b/test/tools/jdeps/APIDeps.java Mon Jun 08 12:24:57 2015 -0700 @@ -90,8 +90,9 @@ new String[] {"-classpath", testDir.getPath(), "-verbose:class", "-filter:none", "-P"}); test(new File(mDir, "Gee.class"), new String[] {"g.G", "sun.misc.Lock", "com.sun.tools.classfile.ClassFile", - "com.sun.management.ThreadMXBean", "com.sun.source.tree.BinaryTree"}, - new String[] {testDirBasename, "JDK internal API", "compact3", ""}, + "com.sun.management.ThreadMXBean", "com.sun.source.tree.BinaryTree", + "org.w3c.dom.css.CSSValue"}, + new String[] {testDirBasename, "JDK internal API", "compact2", "compact3", ""}, new String[] {"-classpath", testDir.getPath(), "-verbose", "-P"}); // -jdkinternals
--- a/test/tools/jdeps/Basic.java Mon Jun 08 11:10:05 2015 -0700 +++ b/test/tools/jdeps/Basic.java Mon Jun 08 12:24:57 2015 -0700 @@ -23,9 +23,9 @@ /* * @test - * @bug 8003562 8005428 8015912 8027481 8048063 + * @bug 8003562 8005428 8015912 8027481 8048063 8068937 * @summary Basic tests for jdeps tool - * @build Test p.Foo p.Bar javax.activity.NotCompactProfile + * @build Test p.Foo p.Bar p.C p.SubClass q.Gee javax.activity.NotCompactProfile * @run main Basic */ @@ -111,6 +111,19 @@ new String[] {"compact1"}, new String[] {"-verbose:package", "-e", "java\\.lang\\..*"}); + // parse p.C, p.SubClass and q.* + // p.SubClass have no dependency other than p.C + // q.Gee depends on p.SubClass that should be found + test(testDir, + new String[] {"java.lang", "p"}, + new String[] {"compact1", testDir.getName()}, + new String[] {"-include", "p.C|p.SubClass|q\\..*"}); + test(testDir, + new String[] {"java.lang", "p"}, + new String[] {"compact1", testDir.getName()}, + new String[] {"-classpath", testDir.getPath(), "-include", "p.C|p.SubClass|q\\..*"}); + + // test -classpath and -include options test(null, new String[] {"java.lang", "java.util", "java.lang.management",
--- a/test/tools/jdeps/m/Gee.java Mon Jun 08 11:10:05 2015 -0700 +++ b/test/tools/jdeps/m/Gee.java Mon Jun 08 12:24:57 2015 -0700 @@ -29,4 +29,5 @@ public com.sun.tools.classfile.ClassFile cf; // @jdk.Exported(false) public com.sun.source.tree.BinaryTree tree; // @jdk.Exported public com.sun.management.ThreadMXBean mxbean; // @jdk.Exported on package-info + public org.w3c.dom.css.CSSValue value; // special case }
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/test/tools/jdeps/p/C.java Mon Jun 08 12:24:57 2015 -0700 @@ -0,0 +1,30 @@ +/* + * Copyright (c) 2015, Oracle and/or its affiliates. All rights reserved. + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * This code is free software; you can redistribute it and/or modify it + * under the terms of the GNU General Public License version 2 only, as + * published by the Free Software Foundation. + * + * This code is distributed in the hope that it will be useful, but WITHOUT + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License + * version 2 for more details (a copy is included in the LICENSE file that + * accompanied this code). + * + * You should have received a copy of the GNU General Public License version + * 2 along with this work; if not, write to the Free Software Foundation, + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. + * + * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA + * or visit www.oracle.com if you need additional information or have any + * questions. + */ + +package p; + +public class C { + public String name() { + return "C"; + } +}
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/test/tools/jdeps/p/SubClass.java Mon Jun 08 12:24:57 2015 -0700 @@ -0,0 +1,28 @@ +/* + * Copyright (c) 2015, Oracle and/or its affiliates. All rights reserved. + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * This code is free software; you can redistribute it and/or modify it + * under the terms of the GNU General Public License version 2 only, as + * published by the Free Software Foundation. + * + * This code is distributed in the hope that it will be useful, but WITHOUT + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License + * version 2 for more details (a copy is included in the LICENSE file that + * accompanied this code). + * + * You should have received a copy of the GNU General Public License version + * 2 along with this work; if not, write to the Free Software Foundation, + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. + * + * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA + * or visit www.oracle.com if you need additional information or have any + * questions. + */ + +package p; + +// SubClass only references types in package p +public class SubClass extends C { +}
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/test/tools/jdeps/q/Gee.java Mon Jun 08 12:24:57 2015 -0700 @@ -0,0 +1,27 @@ +/* + * Copyright (c) 2015, Oracle and/or its affiliates. All rights reserved. + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * This code is free software; you can redistribute it and/or modify it + * under the terms of the GNU General Public License version 2 only, as + * published by the Free Software Foundation. + * + * This code is distributed in the hope that it will be useful, but WITHOUT + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License + * version 2 for more details (a copy is included in the LICENSE file that + * accompanied this code). + * + * You should have received a copy of the GNU General Public License version + * 2 along with this work; if not, write to the Free Software Foundation, + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. + * + * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA + * or visit www.oracle.com if you need additional information or have any + * questions. + */ + +package q; + +public class Gee extends p.SubClass { +}