diff options
author | Denis S. Fokin <Denis.Fokin@gmail.com> | 2015-10-29 13:36:56 +0300 |
---|---|---|
committer | Denis S. Fokin <Denis.Fokin@gmail.com> | 2015-10-29 13:36:56 +0300 |
commit | 4d41f4353881d713b5bfc4ab8213bb66cb5a7c2c (patch) | |
tree | b7350008aa3162adabbfae8199bfd7c1f4c0d4f3 | |
parent | 30018af7ea5b2a4f9498bda80328ce94f922adc2 (diff) | |
parent | e72c0106d4fef447a927aea6b7c0880092c50d4e (diff) | |
download | jdk8u_langtools-4d41f4353881d713b5bfc4ab8213bb66cb5a7c2c.tar.gz |
Merge with default before merge with jdk8u60
--HG--
branch : 8u40-verified-fixes
70 files changed, 2458 insertions, 720 deletions
@@ -309,6 +309,70 @@ e92effa22ecee1cb9965c278e45e2b1a6fbe0766 jdk8u20-b20 7de1481c6cd88b42d815ae65e2d5b1cd918e11d1 jdk8u20-b21 61fb0d8b169164ad5db15b6c497489cb30efb9c6 jdk8u20-b22 5c1d6da1445aa3a2e5cf6101c70e79bfbe2745a5 jdk8u20-b23 +9239118487dfb47ee850d2cc9b10a0a2e510da3c jdk8u20-b24 +9239118487dfb47ee850d2cc9b10a0a2e510da3c jdk8u20-b25 +5e6d409a72327a31b8a8f9aa0b32ef213c8b629c jdk8u20-b26 +7302299fa9c4fa48af02b6477ff3ccbb01f2d4ea jdk8u20-b31 +2f9120236904ce5bd8ebfde755c1b2edcc4dfdd6 jdk8u20-b32 +f491f1581f196950c2cb858508dd06601968c417 jdk8u25-b00 +5bc865e0a2e3c59c1c8bc41e731509e1737ddea1 jdk8u25-b01 +4dec0c684a9ead80ea2bca6b042682367c1abf90 jdk8u25-b02 +1d039298d33f8062a0aa75442bd39434e16ee2df jdk8u25-b03 +5c806c4b2830056caaca3329e634ff040bfe1c7b jdk8u25-b04 +f1625806cabab809993fbc650b77c5a28d70035d jdk8u25-b05 +7a6309461a7294cc78789f547b0a652757d17156 jdk8u25-b06 +aad835b33337c22f4d632c2531c453de00a8f778 jdk8u25-b07 +224b8260b2c72e2902e48522240c97de11b3570a jdk8u25-b08 +a5fa1a2bd63cfcce67dae074c07cd0f2baa8ddc0 jdk8u25-b09 +0dfd4099658397efa118918cd43f79e194c320ea jdk8u25-b10 +eee8277448304f5d785310edff072d993a0c1868 jdk8u25-b11 +664a10268f61616b682985855015663c30d0476f jdk8u25-b12 +89b2f04998c7a1f987cadb4c42801d1ec500a870 jdk8u25-b13 +a340d68b020585cad7aa6e38d1aafb19ad0e4e07 jdk8u25-b14 +6e0c19cd42d7c4d307bea26840ee831cbd14e2fc jdk8u25-b15 +7fa6fa7cc204de988e224c6f8f75e62128fa84cd jdk8u25-b16 +53ca196be1ae098466976c017b166d4ce180c36f jdk8u25-b17 +a4f0c6dd8f97d4dd89baf09463c748abea9b3ed7 jdk8u25-b18 +c4de614efd7affc001715aa5a7040620924ac44a jdk8u25-b31 +c4bd223559aad3d152968a09d56241175d82c561 jdk8u31-b00 +6b5e2c190f3023162a33b798e57a0d78e027c843 jdk8u31-b01 +8b4ea00b438d7f99ecd6a8345cb018d8a0379620 jdk8u31-b02 +6ce4f2acf83e17d084b9b9bce2ef98438e984064 jdk8u31-b03 +c271515197807db2f0496945241f0b09885af99b jdk8u31-b04 +2deb2110e81fc38f5b45842fd478aae168d2d27a jdk8u31-b05 +fe1980c653be1fa9fb50353c5a5305855dcd7bd4 jdk8u31-b06 +03b8ef4cf0c00aa040db27c7d8e68fa8b6133afd jdk8u31-b07 +05824e9d8171e3d50fd5d1a495169cb38b64cf08 jdk8u31-b08 +26c46688ce4a0909f65dc341df4315bf34a92202 jdk8u31-b09 +99c3209f228e1f9aa874b6bd0908fd5d9ebf7078 jdk8u31-b10 +e72be544fa9e247fba3c6bb61e291d80e127a461 jdk8u31-b11 +c956b12b30ee21a4fc5df1871fa3b01e84310ebe jdk8u31-b12 +7a34ec7bb1c831e82ac88da578a028572b676260 jdk8u31-b13 d231957fe3103e790465fcf058fb8cb33bbc4c4e jdk8u40-b00 bf89a471779d13a9407f7d1c86f7716258bc4aa6 jdk8u40-b01 0b6cc4ea670f5d17b56c088f202869bdbb80a5ce jdk8u40-b02 +5183e8b58a03206ca65b4b211be85b3740a70c39 jdk8u40-b03 +cde557bc48f5cd0c6b6aa70bdbc7563677379347 jdk8u40-b04 +a36fce70b505ec15be8353d40d417d331fcce740 jdk8u40-b05 +7c3d27120b92b6abbd2df910722405dfb02d4399 jdk8u40-b06 +2fa3858a281f9deae15bcc49224efd5b951b745d jdk8u40-b07 +d3515520e68e26c1012fca18eef190f8aff3a7a1 jdk8u40-b08 +8bb38a35072279618aa2cacd4fea74155a6dccf9 jdk8u40-b09 +69b84370397fbb5a66b99578242c47da7f8b3cb5 jdk8u40-b10 +d3c93dc64c5e1ffd610fb31362a78bedfd8097ba jdk8u40-b11 +e7560bceb36a933f5eb6ce8c33dce030ba0288f2 jdk8u40-b12 +88ce114c6adc387dc7fc5831b8263f152f0412fb jdk8u40-b13 +f18c5b47f27b387d94487890684abe5a554b0d9b jdk8u40-b14 +682a6c1aefd766eaf774ffeb1207a5189edf94d6 jdk8u40-b15 +74c51ff270c51d17732250411fe9cd5392bc925e jdk8u40-b16 +a12a9932f649dd3df174d3e340527433d3695c49 jdk8u40-b17 +94f30e5fde53e3ddcd3c4e9842349318eae8fe10 jdk8u40-b18 +0c514d1fd006fc79d35b670de10c370c8d559db7 jdk8u40-b19 +c3d6d1a5339952fbe4124e700407b7211446c99c jdk8u40-b20 +9113c7c8d902ec94b28ca0ef4a6466bdba65fcfc jdk8u40-b21 +79177246b3dbe5296fb53755d8695acdaef59fc8 jdk8u40-b22 +fb294b49373bda0b3afc7f011d64ecefed73b42e jdk8u40-b23 +c5d4ffa220f3824c2ea5d39dc99d41a9df9e5ae5 jdk8u40-b24 +991141080b2078e67179ff307a5051e59431762c jdk8u40-b25 +2904142783dd0a9e12195a84c7dcdb3d8278b1b1 jdk8u40-b26 +83eca922346e27ec42645e9630c04fbaec5eaf0f jdk8u40-b27 diff --git a/THIRD_PARTY_README b/THIRD_PARTY_README index 6d1c60f2..c34ce6b3 100644 --- a/THIRD_PARTY_README +++ b/THIRD_PARTY_README @@ -3385,7 +3385,7 @@ with JRE 8, JDK 8, and OpenJDK 8. included with JRE 8, JDK 8, and OpenJDK 8. Apache Commons Math 3.2 - Apache Derby 10.10.1.3 + Apache Derby 10.11.1.2 Apache Jakarta BCEL 5.1 Apache Jakarta Regexp 1.4 Apache Santuario XML Security for Java 1.5.4 diff --git a/src/share/classes/com/sun/source/doctree/package-info.java b/src/share/classes/com/sun/source/doctree/package-info.java index 47de9376..9e728566 100644 --- a/src/share/classes/com/sun/source/doctree/package-info.java +++ b/src/share/classes/com/sun/source/doctree/package-info.java @@ -29,7 +29,7 @@ * * @author Jonathan Gibbons * @since 1.8 - * @see <a href="http://download.oracle.com/javase/6/docs/technotes/tools/solaris/javadoc.html#javadoctags">http://download.oracle.com/javase/6/docs/technotes/tools/solaris/javadoc.html#javadoctags</a> + * @see <a href="https://docs.oracle.com/javase/6/docs/technotes/tools/solaris/javadoc.html#javadoctags">https://docs.oracle.com/javase/6/docs/technotes/tools/solaris/javadoc.html#javadoctags</a> */ @jdk.Exported package com.sun.source.doctree; diff --git a/src/share/classes/com/sun/tools/classfile/BootstrapMethods_attribute.java b/src/share/classes/com/sun/tools/classfile/BootstrapMethods_attribute.java index 69d03478..85948c10 100644 --- a/src/share/classes/com/sun/tools/classfile/BootstrapMethods_attribute.java +++ b/src/share/classes/com/sun/tools/classfile/BootstrapMethods_attribute.java @@ -29,7 +29,7 @@ import java.io.IOException; /** * See JVMS 4.7.21 - * http://docs.oracle.com/javase/specs/jvms/se7/html/jvms-4.html#jvms-4.7.21 + * https://docs.oracle.com/javase/specs/jvms/se7/html/jvms-4.html#jvms-4.7.21 * * <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. diff --git a/src/share/classes/com/sun/tools/javac/code/Types.java b/src/share/classes/com/sun/tools/javac/code/Types.java index 48bcc9ca..a9354648 100644 --- a/src/share/classes/com/sun/tools/javac/code/Types.java +++ b/src/share/classes/com/sun/tools/javac/code/Types.java @@ -1892,7 +1892,12 @@ public class Types { * Mapping to take element type of an arraytype */ private Mapping elemTypeFun = new Mapping ("elemTypeFun") { - public Type apply(Type t) { return elemtype(t); } + public Type apply(Type t) { + while (t.hasTag(TYPEVAR)) { + t = t.getUpperBound(); + } + return elemtype(t); + } }; /** @@ -3521,40 +3526,46 @@ public class Types { } /** - * Return the least upper bound of pair of types. if the lub does + * Return the least upper bound of list of types. if the lub does * not exist return null. */ - public Type lub(Type t1, Type t2) { - return lub(List.of(t1, t2)); + public Type lub(List<Type> ts) { + return lub(ts.toArray(new Type[ts.length()])); } /** * Return the least upper bound (lub) of set of types. If the lub * does not exist return the type of null (bottom). */ - public Type lub(List<Type> ts) { + public Type lub(Type... ts) { + final int UNKNOWN_BOUND = 0; final int ARRAY_BOUND = 1; final int CLASS_BOUND = 2; - int boundkind = 0; - for (Type t : ts) { + + int[] kinds = new int[ts.length]; + + int boundkind = UNKNOWN_BOUND; + for (int i = 0 ; i < ts.length ; i++) { + Type t = ts[i]; switch (t.getTag()) { case CLASS: - boundkind |= CLASS_BOUND; + boundkind |= kinds[i] = CLASS_BOUND; break; case ARRAY: - boundkind |= ARRAY_BOUND; + boundkind |= kinds[i] = ARRAY_BOUND; break; case TYPEVAR: do { t = t.getUpperBound(); } while (t.hasTag(TYPEVAR)); if (t.hasTag(ARRAY)) { - boundkind |= ARRAY_BOUND; + boundkind |= kinds[i] = ARRAY_BOUND; } else { - boundkind |= CLASS_BOUND; + boundkind |= kinds[i] = CLASS_BOUND; } break; default: + kinds[i] = UNKNOWN_BOUND; if (t.isPrimitive()) return syms.errType; } @@ -3565,15 +3576,16 @@ public class Types { case ARRAY_BOUND: // calculate lub(A[], B[]) - List<Type> elements = Type.map(ts, elemTypeFun); - for (Type t : elements) { - if (t.isPrimitive()) { + Type[] elements = new Type[ts.length]; + for (int i = 0 ; i < ts.length ; i++) { + Type elem = elements[i] = elemTypeFun.apply(ts[i]); + if (elem.isPrimitive()) { // if a primitive type is found, then return // arraySuperType unless all the types are the // same - Type first = ts.head; - for (Type s : ts.tail) { - if (!isSameType(first, s)) { + Type first = ts[0]; + for (int j = 1 ; j < ts.length ; j++) { + if (!isSameType(first, ts[j])) { // lub(int[], B[]) is Cloneable & Serializable return arraySuperType(); } @@ -3588,13 +3600,20 @@ public class Types { case CLASS_BOUND: // calculate lub(A, B) - while (!ts.head.hasTag(CLASS) && !ts.head.hasTag(TYPEVAR)) { - ts = ts.tail; + int startIdx = 0; + for (int i = 0; i < ts.length ; i++) { + Type t = ts[i]; + if (t.hasTag(CLASS) || t.hasTag(TYPEVAR)) { + break; + } else { + startIdx++; + } } - Assert.check(!ts.isEmpty()); + Assert.check(startIdx < ts.length); //step 1 - compute erased candidate set (EC) - List<Type> cl = erasedSupertypes(ts.head); - for (Type t : ts.tail) { + List<Type> cl = erasedSupertypes(ts[startIdx]); + for (int i = startIdx + 1 ; i < ts.length ; i++) { + Type t = ts[i]; if (t.hasTag(CLASS) || t.hasTag(TYPEVAR)) cl = intersect(cl, erasedSupertypes(t)); } @@ -3603,9 +3622,10 @@ public class Types { //step 3 - for each element G in MEC, compute lci(Inv(G)) List<Type> candidates = List.nil(); for (Type erasedSupertype : mec) { - List<Type> lci = List.of(asSuper(ts.head, erasedSupertype.tsym)); - for (Type t : ts) { - lci = intersect(lci, List.of(asSuper(t, erasedSupertype.tsym))); + List<Type> lci = List.of(asSuper(ts[startIdx], erasedSupertype.tsym)); + for (int i = startIdx + 1 ; i < ts.length ; i++) { + Type superType = asSuper(ts[i], erasedSupertype.tsym); + lci = intersect(lci, superType != null ? List.of(superType) : List.<Type>nil()); } candidates = candidates.appendList(lci); } @@ -3616,9 +3636,9 @@ public class Types { default: // calculate lub(A, B[]) List<Type> classes = List.of(arraySuperType()); - for (Type t : ts) { - if (!t.hasTag(ARRAY)) // Filter out any arrays - classes = classes.prepend(t); + for (int i = 0 ; i < ts.length ; i++) { + if (kinds[i] != ARRAY_BOUND) // Filter out any arrays + classes = classes.prepend(ts[i]); } // lub(A, B[]) is lub(A, arraySuperType) return lub(classes); diff --git a/src/share/classes/com/sun/tools/javac/comp/Attr.java b/src/share/classes/com/sun/tools/javac/comp/Attr.java index 8eb976d7..f5d52595 100644 --- a/src/share/classes/com/sun/tools/javac/comp/Attr.java +++ b/src/share/classes/com/sun/tools/javac/comp/Attr.java @@ -287,7 +287,7 @@ public class Attr extends JCTree.Visitor { * @param env The current environment. */ boolean isAssignableAsBlankFinal(VarSymbol v, Env<AttrContext> env) { - Symbol owner = owner(env); + Symbol owner = env.info.scope.owner; // owner refers to the innermost variable, method or // initializer block declaration at this point. return @@ -302,41 +302,6 @@ public class Attr extends JCTree.Visitor { ((v.flags() & STATIC) != 0) == Resolve.isStatic(env)); } - /** - * Return the innermost enclosing owner symbol in a given attribution context - */ - Symbol owner(Env<AttrContext> env) { - while (true) { - switch (env.tree.getTag()) { - case VARDEF: - //a field can be owner - VarSymbol vsym = ((JCVariableDecl)env.tree).sym; - if (vsym.owner.kind == TYP) { - return vsym; - } - break; - case METHODDEF: - //method def is always an owner - return ((JCMethodDecl)env.tree).sym; - case CLASSDEF: - //class def is always an owner - return ((JCClassDecl)env.tree).sym; - case BLOCK: - //static/instance init blocks are owner - Symbol blockSym = env.info.scope.owner; - if ((blockSym.flags() & BLOCK) != 0) { - return blockSym; - } - break; - case TOPLEVEL: - //toplevel is always an owner (for pkge decls) - return env.info.scope.owner; - } - Assert.checkNonNull(env.next); - env = env.next; - } - } - /** Check that variable can be assigned to. * @param pos The current source code position. * @param v The assigned varaible @@ -1045,8 +1010,12 @@ public class Attr extends JCTree.Visitor { // parameters have already been entered env.info.scope.enter(tree.sym); } else { - memberEnter.memberEnter(tree, env); - annotate.flush(); + try { + annotate.enterStart(); + memberEnter.memberEnter(tree, env); + } finally { + annotate.enterDone(); + } } } else { if (tree.init != null) { @@ -3257,8 +3226,9 @@ public class Attr extends JCTree.Visitor { elt = ((ArrayType)elt.unannotatedType()).elemtype; if (elt.hasTag(TYPEVAR)) { log.error(tree.pos(), "type.var.cant.be.deref"); - result = types.createErrorType(tree.type); - return; + result = tree.type = types.createErrorType(tree.name, site.tsym, site); + tree.sym = tree.type.tsym; + return ; } } @@ -3274,6 +3244,10 @@ public class Attr extends JCTree.Visitor { // Determine the symbol represented by the selection. env.info.pendingResolutionPhase = null; Symbol sym = selectSym(tree, sitesym, site, env, resultInfo); + if (sym.kind == VAR && sym.name != names._super && env.info.defaultSuperCallSite != null) { + log.error(tree.selected.pos(), "not.encl.class", site.tsym); + sym = syms.errSymbol; + } if (sym.exists() && !isType(sym) && (pkind() & (PCK | TYP)) != 0) { site = capture(site); sym = selectSym(tree, sitesym, site, env, resultInfo); @@ -3660,7 +3634,7 @@ public class Attr extends JCTree.Visitor { // and are subject to definite assignment checking. if ((env.info.enclVar == v || v.pos > tree.pos) && v.owner.kind == TYP && - canOwnInitializer(owner(env)) && + enclosingInitEnv(env) != null && v.owner == env.info.scope.owner.enclClass() && ((v.flags() & STATIC) != 0) == Resolve.isStatic(env) && (!env.tree.hasTag(ASSIGN) || @@ -3680,6 +3654,36 @@ public class Attr extends JCTree.Visitor { } /** + * Returns the enclosing init environment associated with this env (if any). An init env + * can be either a field declaration env or a static/instance initializer env. + */ + Env<AttrContext> enclosingInitEnv(Env<AttrContext> env) { + while (true) { + switch (env.tree.getTag()) { + case VARDEF: + JCVariableDecl vdecl = (JCVariableDecl)env.tree; + if (vdecl.sym.owner.kind == TYP) { + //field + return env; + } + break; + case BLOCK: + if (env.next.tree.hasTag(CLASSDEF)) { + //instance/static initializer + return env; + } + break; + case METHODDEF: + case CLASSDEF: + case TOPLEVEL: + return null; + } + Assert.checkNonNull(env.next); + env = env.next; + } + } + + /** * Check for illegal references to static members of enum. In * an enum type, constructors and initializers may not * reference its static members unless they are constant. @@ -3732,17 +3736,6 @@ public class Attr extends JCTree.Visitor { v.name != names._class; } - /** Can the given symbol be the owner of code which forms part - * if class initialization? This is the case if the symbol is - * a type or field, or if the symbol is the synthetic method. - * owning a block. - */ - private boolean canOwnInitializer(Symbol sym) { - return - (sym.kind & (VAR | TYP)) != 0 || - (sym.kind == MTH && (sym.flags() & BLOCK) != 0); - } - Warner noteWarner = new Warner(); /** @@ -4511,14 +4504,15 @@ public class Attr extends JCTree.Visitor { super.visitTypeTest(tree); } public void visitNewClass(JCNewClass tree) { - if (tree.clazz.hasTag(ANNOTATED_TYPE)) { - checkForDeclarationAnnotations(((JCAnnotatedType) tree.clazz).annotations, - tree.clazz.type.tsym); - } - if (tree.def != null) { - checkForDeclarationAnnotations(tree.def.mods.annotations, tree.clazz.type.tsym); - } - if (tree.clazz.type != null) { + if (tree.clazz != null && tree.clazz.type != null) { + if (tree.clazz.hasTag(ANNOTATED_TYPE)) { + checkForDeclarationAnnotations(((JCAnnotatedType) tree.clazz).annotations, + tree.clazz.type.tsym); + } + if (tree.def != null) { + checkForDeclarationAnnotations(tree.def.mods.annotations, tree.clazz.type.tsym); + } + validateAnnotatedType(tree.clazz, tree.clazz.type); } super.visitNewClass(tree); diff --git a/src/share/classes/com/sun/tools/javac/comp/Check.java b/src/share/classes/com/sun/tools/javac/comp/Check.java index d4a62249..141b5573 100644 --- a/src/share/classes/com/sun/tools/javac/comp/Check.java +++ b/src/share/classes/com/sun/tools/javac/comp/Check.java @@ -1715,7 +1715,12 @@ public class Check { // Warn if a deprecated method overridden by a non-deprecated one. if (!isDeprecatedOverrideIgnorable(other, origin)) { - checkDeprecated(TreeInfo.diagnosticPositionFor(m, tree), m, other); + Lint prevLint = setLint(lint.augment(m)); + try { + checkDeprecated(TreeInfo.diagnosticPositionFor(m, tree), m, other); + } finally { + setLint(prevLint); + } } } // where diff --git a/src/share/classes/com/sun/tools/javac/comp/DeferredAttr.java b/src/share/classes/com/sun/tools/javac/comp/DeferredAttr.java index 01c04ad3..a8946e4e 100644 --- a/src/share/classes/com/sun/tools/javac/comp/DeferredAttr.java +++ b/src/share/classes/com/sun/tools/javac/comp/DeferredAttr.java @@ -497,13 +497,11 @@ public class DeferredAttr extends JCTree.Visitor { } } if (!progress) { - DeferredAttrContext dac = this; - while (dac != emptyDeferredAttrContext) { - if (dac.mode == AttrMode.SPECULATIVE) { - //unsticking does not take place during overload - break; + if (insideOverloadPhase()) { + for (DeferredAttrNode deferredNode: deferredAttrNodes) { + deferredNode.dt.tree.type = Type.noType; } - dac = dac.parent; + return; } //remove all variables that have already been instantiated //from the list of stuck variables @@ -519,6 +517,17 @@ public class DeferredAttr extends JCTree.Visitor { } } } + + private boolean insideOverloadPhase() { + DeferredAttrContext dac = this; + if (dac == emptyDeferredAttrContext) { + return false; + } + if (dac.mode == AttrMode.SPECULATIVE) { + return true; + } + return dac.parent.insideOverloadPhase(); + } } /** @@ -579,6 +588,8 @@ public class DeferredAttr extends JCTree.Visitor { return false; } } else { + Assert.check(!deferredAttrContext.insideOverloadPhase(), + "attribution shouldn't be happening here"); ResultInfo instResultInfo = resultInfo.dup(deferredAttrContext.inferenceContext.asInstType(resultInfo.pt)); dt.check(instResultInfo, dummyStuckPolicy, basicCompleter); @@ -1314,6 +1325,12 @@ public class DeferredAttr extends JCTree.Visitor { site = env.enclClass.sym.type; } + while (site.hasTag(TYPEVAR)) { + site = site.getUpperBound(); + } + + site = types.capture(site); + List<Type> args = rs.dummyArgs(tree.args.length()); Name name = TreeInfo.name(tree.meth); @@ -1337,7 +1354,9 @@ public class DeferredAttr extends JCTree.Visitor { @Override public Symbol process(MethodSymbol ms) { ArgumentExpressionKind kind = ArgumentExpressionKind.methodKind(ms, types); - return kind != ArgumentExpressionKind.POLY ? ms.getReturnType().tsym : null; + if (kind == ArgumentExpressionKind.POLY || ms.getReturnType().hasTag(TYPEVAR)) + return null; + return ms.getReturnType().tsym; } @Override public Symbol reduce(Symbol s1, Symbol s2) { diff --git a/src/share/classes/com/sun/tools/javac/comp/Flow.java b/src/share/classes/com/sun/tools/javac/comp/Flow.java index f0d26d53..0406d0be 100644 --- a/src/share/classes/com/sun/tools/javac/comp/Flow.java +++ b/src/share/classes/com/sun/tools/javac/comp/Flow.java @@ -208,7 +208,7 @@ public class Flow { public void analyzeTree(Env<AttrContext> env, TreeMaker make) { new AliveAnalyzer().analyzeTree(env, make); - new AssignAnalyzer(log, syms, lint, names, enforceThisDotInit).analyzeTree(env); + new AssignAnalyzer().analyzeTree(env); new FlowAnalyzer().analyzeTree(env, make); new CaptureAnalyzer().analyzeTree(env, make); } @@ -241,13 +241,19 @@ public class Flow { //related errors, which will allow for more errors to be detected Log.DiagnosticHandler diagHandler = new Log.DiscardDiagnosticHandler(log); try { - new AssignAnalyzer(log, syms, lint, names, enforceThisDotInit) { + new AssignAnalyzer() { + Scope enclosedSymbols = new Scope(env.enclClass.sym); + @Override + public void visitVarDef(JCVariableDecl tree) { + enclosedSymbols.enter(tree.sym); + super.visitVarDef(tree); + } @Override protected boolean trackable(VarSymbol sym) { - return !env.info.scope.includes(sym) && + return enclosedSymbols.includes(sym) && sym.owner.kind == MTH; } - }.analyzeTree(env); + }.analyzeTree(env, that); LambdaFlowAnalyzer flowAnalyzer = new LambdaFlowAnalyzer(); flowAnalyzer.analyzeTree(env, that, make); return flowAnalyzer.inferredThrownTypes; @@ -1373,12 +1379,12 @@ public class Flow { * effectively-final local variables/parameters. */ - public abstract static class AbstractAssignAnalyzer<P extends AbstractAssignAnalyzer.AbstractAssignPendingExit> + public abstract class AbstractAssignAnalyzer<P extends AbstractAssignAnalyzer<P>.AbstractAssignPendingExit> extends BaseAnalyzer<P> { /** The set of definitely assigned variables. */ - protected final Bits inits; + protected Bits inits; /** The set of definitely unassigned variables. */ @@ -1432,13 +1438,7 @@ public class Flow { /** The starting position of the analysed tree */ int startPos; - final Symtab syms; - - protected Names names; - - final boolean enforceThisDotInit; - - public static class AbstractAssignPendingExit extends BaseAnalyzer.PendingExit { + public class AbstractAssignPendingExit extends BaseAnalyzer.PendingExit { final Bits inits; final Bits uninits; @@ -1460,17 +1460,14 @@ public class Flow { } } - public AbstractAssignAnalyzer(Bits inits, Symtab syms, Names names, boolean enforceThisDotInit) { - this.inits = inits; + public AbstractAssignAnalyzer() { + this.inits = new Bits(); uninits = new Bits(); uninitsTry = new Bits(); initsWhenTrue = new Bits(true); initsWhenFalse = new Bits(true); uninitsWhenTrue = new Bits(true); uninitsWhenFalse = new Bits(true); - this.syms = syms; - this.names = names; - this.enforceThisDotInit = enforceThisDotInit; } private boolean isInitialConstructor = false; @@ -2439,26 +2436,15 @@ public class Flow { } } - public static class AssignAnalyzer - extends AbstractAssignAnalyzer<AssignAnalyzer.AssignPendingExit> { - - Log log; - Lint lint; + public class AssignAnalyzer extends AbstractAssignAnalyzer<AssignAnalyzer.AssignPendingExit> { - public static class AssignPendingExit - extends AbstractAssignAnalyzer.AbstractAssignPendingExit { + public class AssignPendingExit extends AbstractAssignAnalyzer<AssignPendingExit>.AbstractAssignPendingExit { public AssignPendingExit(JCTree tree, final Bits inits, final Bits uninits) { super(tree, inits, uninits); } } - public AssignAnalyzer(Log log, Symtab syms, Lint lint, Names names, boolean enforceThisDotInit) { - super(new Bits(), syms, names, enforceThisDotInit); - this.log = log; - this.lint = lint; - } - @Override protected AssignPendingExit createNewPendingExit(JCTree tree, Bits inits, Bits uninits) { diff --git a/src/share/classes/com/sun/tools/javac/comp/Infer.java b/src/share/classes/com/sun/tools/javac/comp/Infer.java index 9a932ce1..9d7a01d8 100644 --- a/src/share/classes/com/sun/tools/javac/comp/Infer.java +++ b/src/share/classes/com/sun/tools/javac/comp/Infer.java @@ -784,7 +784,10 @@ public class Infer { while (tmpTail.nonEmpty()) { Type b1 = boundList.head; Type b2 = tmpTail.head; - if (b1 != b2) { + /* This wildcard check is temporary workaround. This code may need to be + * revisited once spec bug JDK-7034922 is fixed. + */ + if (b1 != b2 && !b1.hasTag(WILDCARD) && !b2.hasTag(WILDCARD)) { Pair<Type, Type> commonSupers = infer.getParameterizedSupers(b1, b2); if (commonSupers != null) { List<Type> allParamsSuperBound1 = commonSupers.fst.allparams(); diff --git a/src/share/classes/com/sun/tools/javac/comp/LambdaToMethod.java b/src/share/classes/com/sun/tools/javac/comp/LambdaToMethod.java index 980843fc..10e9a127 100644 --- a/src/share/classes/com/sun/tools/javac/comp/LambdaToMethod.java +++ b/src/share/classes/com/sun/tools/javac/comp/LambdaToMethod.java @@ -41,6 +41,7 @@ import com.sun.tools.javac.code.Symbol.VarSymbol; import com.sun.tools.javac.code.Symtab; import com.sun.tools.javac.code.Type; import com.sun.tools.javac.code.Type.MethodType; +import com.sun.tools.javac.code.Type.TypeVar; import com.sun.tools.javac.code.Types; import com.sun.tools.javac.comp.LambdaToMethod.LambdaAnalyzerPreprocessor.*; import com.sun.tools.javac.comp.Lower.BasicFreeVarCollector; @@ -61,6 +62,7 @@ import static com.sun.tools.javac.code.Flags.*; import static com.sun.tools.javac.code.Kinds.*; import static com.sun.tools.javac.code.TypeTag.*; import static com.sun.tools.javac.tree.JCTree.Tag.*; +import javax.lang.model.type.TypeKind; /** * This pass desugars lambda expressions into static methods @@ -321,7 +323,9 @@ public class LambdaToMethod extends TreeTranslator { ListBuffer<JCExpression> syntheticInits = new ListBuffer<>(); - if (!sym.isStatic()) { + if (localContext.methodReferenceReceiver != null) { + syntheticInits.append(localContext.methodReferenceReceiver); + } else if (!sym.isStatic()) { syntheticInits.append(makeThis( sym.owner.enclClass().asType(), localContext.owner.enclClass())); @@ -364,17 +368,10 @@ public class LambdaToMethod extends TreeTranslator { //first determine the method symbol to be used to generate the sam instance //this is either the method reference symbol, or the bridged reference symbol - Symbol refSym = localContext.needsBridge() - ? localContext.bridgeSym - : localContext.isSignaturePolymorphic() + Symbol refSym = localContext.isSignaturePolymorphic() ? localContext.sigPolySym : tree.sym; - //build the bridge method, if needed - if (localContext.needsBridge()) { - bridgeMemberReference(tree, localContext); - } - //the qualifying expression is treated as a special captured arg JCExpression init; switch(tree.kind) { @@ -744,126 +741,146 @@ public class LambdaToMethod extends TreeTranslator { // </editor-fold> /** - * Generate an adapter method "bridge" for a method reference which cannot - * be used directly. + * Converts a method reference which cannot be used directly into a lambda */ - private class MemberReferenceBridger { + private class MemberReferenceToLambda { private final JCMemberReference tree; private final ReferenceTranslationContext localContext; + private final Symbol owner; private final ListBuffer<JCExpression> args = new ListBuffer<>(); private final ListBuffer<JCVariableDecl> params = new ListBuffer<>(); - MemberReferenceBridger(JCMemberReference tree, ReferenceTranslationContext localContext) { + private JCExpression receiverExpression = null; + + MemberReferenceToLambda(JCMemberReference tree, ReferenceTranslationContext localContext, Symbol owner) { this.tree = tree; this.localContext = localContext; + this.owner = owner; } - /** - * Generate the bridge - */ - JCMethodDecl bridge() { + JCLambda lambda() { int prevPos = make.pos; try { make.at(tree); - Type samDesc = localContext.bridgedRefSig(); - List<Type> samPTypes = samDesc.getParameterTypes(); - - //an extra argument is prepended to the signature of the bridge in case - //the member reference is an instance method reference (in which case - //the receiver expression is passed to the bridge itself). - Type recType = null; - switch (tree.kind) { - case IMPLICIT_INNER: - recType = tree.sym.owner.type.getEnclosingType(); - break; - case BOUND: - recType = tree.getQualifierExpression().type; - break; - case UNBOUND: - recType = samPTypes.head; - samPTypes = samPTypes.tail; - break; - } - - //generate the parameter list for the bridged member reference - the - //bridge signature will match the signature of the target sam descriptor - VarSymbol rcvr = (recType == null) - ? null - : addParameter("rec$", recType, false); + //body generation - this can be either a method call or a + //new instance creation expression, depending on the member reference kind + VarSymbol rcvr = addParametersReturnReceiver(); + JCExpression expr = (tree.getMode() == ReferenceMode.INVOKE) + ? expressionInvoke(rcvr) + : expressionNew(); - List<Type> refPTypes = tree.sym.type.getParameterTypes(); - int refSize = refPTypes.size(); - int samSize = samPTypes.size(); - // Last parameter to copy from referenced method - int last = localContext.needsVarArgsConversion() ? refSize - 1 : refSize; + JCLambda slam = make.Lambda(params.toList(), expr); + slam.targets = tree.targets; + slam.type = tree.type; + slam.pos = tree.pos; + return slam; + } finally { + make.at(prevPos); + } + } - List<Type> l = refPTypes; - // Use parameter types of the referenced method, excluding final var args - for (int i = 0; l.nonEmpty() && i < last; ++i) { - addParameter("x$" + i, l.head, true); - l = l.tail; - } - // Flatten out the var args - for (int i = last; i < samSize; ++i) { - addParameter("xva$" + i, tree.varargsElement, true); + /** + * Generate the parameter list for the converted member reference. + * + * @return The receiver variable symbol, if any + */ + VarSymbol addParametersReturnReceiver() { + Type samDesc = localContext.bridgedRefSig(); + List<Type> samPTypes = samDesc.getParameterTypes(); + List<Type> descPTypes = tree.getDescriptorType(types).getParameterTypes(); + + // Determine the receiver, if any + VarSymbol rcvr; + switch (tree.kind) { + case BOUND: + // The receiver is explicit in the method reference + rcvr = addParameter("rec$", tree.getQualifierExpression().type, false); + receiverExpression = attr.makeNullCheck(tree.getQualifierExpression()); + break; + case UNBOUND: + // The receiver is the first parameter, extract it and + // adjust the SAM and unerased type lists accordingly + rcvr = addParameter("rec$", samDesc.getParameterTypes().head, false); + samPTypes = samPTypes.tail; + descPTypes = descPTypes.tail; + break; + default: + rcvr = null; + break; + } + List<Type> implPTypes = tree.sym.type.getParameterTypes(); + int implSize = implPTypes.size(); + int samSize = samPTypes.size(); + // Last parameter to copy from referenced method, exclude final var args + int last = localContext.needsVarArgsConversion() ? implSize - 1 : implSize; + + // Failsafe -- assure match-up + boolean checkForIntersection = tree.varargsElement != null || implSize == descPTypes.size(); + + // Use parameter types of the implementation method unless the unerased + // SAM parameter type is an intersection type, in that case use the + // erased SAM parameter type so that the supertype relationship + // the implementation method parameters is not obscured. + // Note: in this loop, the lists implPTypes, samPTypes, and descPTypes + // are used as pointers to the current parameter type information + // and are thus not usable afterwards. + for (int i = 0; implPTypes.nonEmpty() && i < last; ++i) { + // By default use the implementation method parmeter type + Type parmType = implPTypes.head; + // If the unerased parameter type is a type variable whose + // bound is an intersection (eg. <T extends A & B>) then + // use the SAM parameter type + if (checkForIntersection && descPTypes.head.getKind() == TypeKind.TYPEVAR) { + TypeVar tv = (TypeVar) descPTypes.head; + if (tv.bound.getKind() == TypeKind.INTERSECTION) { + parmType = samPTypes.head; + } } + addParameter("x$" + i, parmType, true); - //generate the bridge method declaration - JCMethodDecl bridgeDecl = make.MethodDef(make.Modifiers(localContext.bridgeSym.flags()), - localContext.bridgeSym.name, - make.QualIdent(samDesc.getReturnType().tsym), - List.<JCTypeParameter>nil(), - params.toList(), - tree.sym.type.getThrownTypes() == null - ? List.<JCExpression>nil() - : make.Types(tree.sym.type.getThrownTypes()), - null, - null); - bridgeDecl.sym = (MethodSymbol) localContext.bridgeSym; - bridgeDecl.type = localContext.bridgeSym.type = - types.createMethodTypeWithParameters(samDesc, TreeInfo.types(params.toList())); + // Advance to the next parameter + implPTypes = implPTypes.tail; + samPTypes = samPTypes.tail; + descPTypes = descPTypes.tail; + } + // Flatten out the var args + for (int i = last; i < samSize; ++i) { + addParameter("xva$" + i, tree.varargsElement, true); + } - //bridge method body generation - this can be either a method call or a - //new instance creation expression, depending on the member reference kind - JCExpression bridgeExpr = (tree.getMode() == ReferenceMode.INVOKE) - ? bridgeExpressionInvoke(makeReceiver(rcvr)) - : bridgeExpressionNew(); + return rcvr; + } - //the body is either a return expression containing a method call, - //or the method call itself, depending on whether the return type of - //the bridge is non-void/void. - bridgeDecl.body = makeLambdaExpressionBody(bridgeExpr, bridgeDecl); + JCExpression getReceiverExpression() { + return receiverExpression; + } - return bridgeDecl; - } finally { - make.at(prevPos); + private JCExpression makeReceiver(VarSymbol rcvr) { + if (rcvr == null) return null; + JCExpression rcvrExpr = make.Ident(rcvr); + Type rcvrType = tree.sym.enclClass().type; + if (rcvrType == syms.arrayClass.type) { + // Map the receiver type to the actually type, not just "array" + rcvrType = tree.getQualifierExpression().type; } - } - //where - private JCExpression makeReceiver(VarSymbol rcvr) { - if (rcvr == null) return null; - JCExpression rcvrExpr = make.Ident(rcvr); - Type rcvrType = tree.sym.enclClass().type; - if (!rcvr.type.tsym.isSubClass(rcvrType.tsym, types)) { - rcvrExpr = make.TypeCast(make.Type(rcvrType), rcvrExpr).setType(rcvrType); - } - return rcvrExpr; + if (!rcvr.type.tsym.isSubClass(rcvrType.tsym, types)) { + rcvrExpr = make.TypeCast(make.Type(rcvrType), rcvrExpr).setType(rcvrType); } + return rcvrExpr; + } /** - * determine the receiver of the bridged method call - the receiver can - * be either the synthetic receiver parameter or a type qualifier; the - * original qualifier expression is never used here, as it might refer - * to symbols not available in the static context of the bridge + * determine the receiver of the method call - the receiver can + * be a type qualifier, the synthetic receiver parameter or 'super'. */ - private JCExpression bridgeExpressionInvoke(JCExpression rcvr) { + private JCExpression expressionInvoke(VarSymbol rcvr) { JCExpression qualifier = tree.sym.isStatic() ? make.Type(tree.sym.owner.type) : (rcvr != null) ? - rcvr : + makeReceiver(rcvr) : tree.getQualifierExpression(); //create the qualifier expression @@ -882,10 +899,9 @@ public class LambdaToMethod extends TreeTranslator { } /** - * the enclosing expression is either 'null' (no enclosing type) or set - * to the first bridge synthetic parameter + * Lambda body to use for a 'new'. */ - private JCExpression bridgeExpressionNew() { + private JCExpression expressionNew() { if (tree.kind == ReferenceKind.ARRAY_CTOR) { //create the array creation expression JCNewArray newArr = make.NewArray( @@ -895,15 +911,10 @@ public class LambdaToMethod extends TreeTranslator { newArr.type = tree.getQualifierExpression().type; return newArr; } else { - JCExpression encl = null; - switch (tree.kind) { - case UNBOUND: - case IMPLICIT_INNER: - encl = make.Ident(params.first()); - } - //create the instance creation expression - JCNewClass newClass = make.NewClass(encl, + //note that method reference syntax does not allow an explicit + //enclosing class (so the enclosing class is null) + JCNewClass newClass = make.NewClass(null, List.<JCExpression>nil(), make.Type(tree.getQualifierExpression().type), convertArgs(tree.sym, args.toList(), tree.varargsElement), @@ -917,7 +928,8 @@ public class LambdaToMethod extends TreeTranslator { } private VarSymbol addParameter(String name, Type p, boolean genArg) { - VarSymbol vsym = new VarSymbol(0, names.fromString(name), p, localContext.bridgeSym); + VarSymbol vsym = new VarSymbol(PARAMETER | SYNTHETIC, names.fromString(name), p, owner); + vsym.pos = tree.pos; params.append(make.VarDef(vsym, null)); if (genArg) { args.append(make.Ident(vsym)); @@ -926,15 +938,6 @@ public class LambdaToMethod extends TreeTranslator { } } - /** - * Bridges a member reference - this is needed when: - * * Var args in the referenced method need to be flattened away - * * super is used - */ - private void bridgeMemberReference(JCMemberReference tree, ReferenceTranslationContext localContext) { - kInfo.addMethod(new MemberReferenceBridger(tree, localContext).bridge()); - } - private MethodType typeToMethodType(Type mt) { Type type = types.erasure(mt); return new MethodType(type.getParameterTypes(), @@ -1254,9 +1257,25 @@ public class LambdaToMethod extends TreeTranslator { @Override public void visitLambda(JCLambda tree) { + analyzeLambda(tree, "lambda.stat"); + } + + private void analyzeLambda(JCLambda tree, JCExpression methodReferenceReceiver) { + // Translation of the receiver expression must occur first + JCExpression rcvr = translate(methodReferenceReceiver); + LambdaTranslationContext context = analyzeLambda(tree, "mref.stat.1"); + if (rcvr != null) { + context.methodReferenceReceiver = rcvr; + } + } + + private LambdaTranslationContext analyzeLambda(JCLambda tree, String statKey) { List<Frame> prevStack = frameStack; try { - LambdaTranslationContext context = (LambdaTranslationContext)makeLambdaContext(tree); + LambdaTranslationContext context = new LambdaTranslationContext(tree); + if (dumpLambdaToMethodStats) { + log.note(tree, statKey, context.needsAltMetafactory(), context.translatedSym); + } frameStack = frameStack.prepend(new Frame(tree)); for (JCVariableDecl param : tree.params) { context.addSymbol(param.sym, PARAM); @@ -1265,6 +1284,7 @@ public class LambdaToMethod extends TreeTranslator { contextMap.put(tree, context); super.visitLambda(tree); context.complete(); + return context; } finally { frameStack = prevStack; @@ -1353,47 +1373,24 @@ public class LambdaToMethod extends TreeTranslator { * information added in the LambdaToMethod pass will have the wrong * signature. Hooks between Lower and LambdaToMethod have been added to * handle normal "new" in this case. This visitor converts potentially - * effected method references into a lambda containing a normal "new" of - * the class. + * affected method references into a lambda containing a normal + * expression. * * @param tree */ @Override public void visitReference(JCMemberReference tree) { - if (tree.getMode() == ReferenceMode.NEW - && tree.kind != ReferenceKind.ARRAY_CTOR - && tree.sym.owner.isLocal()) { - MethodSymbol consSym = (MethodSymbol) tree.sym; - List<Type> ptypes = ((MethodType) consSym.type).getParameterTypes(); - Type classType = consSym.owner.type; - - // Build lambda parameters - // partially cloned from TreeMaker.Params until 8014021 is fixed - Symbol owner = owner(); - ListBuffer<JCVariableDecl> paramBuff = new ListBuffer<JCVariableDecl>(); - int i = 0; - for (List<Type> l = ptypes; l.nonEmpty(); l = l.tail) { - JCVariableDecl param = make.Param(make.paramName(i++), l.head, owner); - param.sym.pos = tree.pos; - paramBuff.append(param); - } - List<JCVariableDecl> params = paramBuff.toList(); - - // Make new-class call - JCNewClass nc = makeNewClass(classType, make.Idents(params)); - nc.pos = tree.pos; - - // Make lambda holding the new-class call - JCLambda slam = make.Lambda(params, nc); - slam.targets = tree.targets; - slam.type = tree.type; - slam.pos = tree.pos; - - // Now it is a lambda, process as such - visitLambda(slam); + ReferenceTranslationContext rcontext = new ReferenceTranslationContext(tree); + contextMap.put(tree, rcontext); + if (rcontext.needsConversionToLambda()) { + // Convert to a lambda, and process as such + MemberReferenceToLambda conv = new MemberReferenceToLambda(tree, rcontext, owner()); + analyzeLambda(conv.lambda(), conv.getReceiverExpression()); } else { super.visitReference(tree); - contextMap.put(tree, makeReferenceContext(tree)); + if (dumpLambdaToMethodStats) { + log.note(tree, "mref.stat", rcontext.needsAltMetafactory(), null); + } } } @@ -1648,14 +1645,6 @@ public class LambdaToMethod extends TreeTranslator { } } - private TranslationContext<JCLambda> makeLambdaContext(JCLambda tree) { - return new LambdaTranslationContext(tree); - } - - private TranslationContext<JCMemberReference> makeReferenceContext(JCMemberReference tree) { - return new ReferenceTranslationContext(tree); - } - private class Frame { final JCTree tree; List<Symbol> locals; @@ -1775,6 +1764,13 @@ public class LambdaToMethod extends TreeTranslator { */ final Set<Symbol> freeVarProcessedLocalClasses; + /** + * For method references converted to lambdas. The method + * reference receiver expression. Must be treated like a captured + * variable. + */ + JCExpression methodReferenceReceiver; + LambdaTranslationContext(JCLambda tree) { super(tree); Frame frame = frameStack.head; @@ -1794,9 +1790,6 @@ public class LambdaToMethod extends TreeTranslator { // This symbol will be filled-in in complete this.translatedSym = makePrivateSyntheticMethod(0, null, null, owner.enclClass()); - if (dumpLambdaToMethodStats) { - log.note(tree, "lambda.stat", needsAltMetafactory(), translatedSym); - } translatedSymbols = new EnumMap<>(LambdaSymbolKind.class); translatedSymbols.put(PARAM, new LinkedHashMap<Symbol, Symbol>()); @@ -2013,6 +2006,13 @@ public class LambdaToMethod extends TreeTranslator { 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)); + } for (Symbol thisSym : getSymbolMap(PARAM).values()) { params.append(make.VarDef((VarSymbol) thisSym, null)); } @@ -2040,40 +2040,27 @@ public class LambdaToMethod extends TreeTranslator { * and the used by the main translation routines in order to adjust method * references (i.e. in case a bridge is needed) */ - private class ReferenceTranslationContext extends TranslationContext<JCMemberReference> { + private final class ReferenceTranslationContext extends TranslationContext<JCMemberReference> { final boolean isSuper; - final Symbol bridgeSym; final Symbol sigPolySym; ReferenceTranslationContext(JCMemberReference tree) { super(tree); this.isSuper = tree.hasKind(ReferenceKind.SUPER); - this.bridgeSym = needsBridge() - ? makePrivateSyntheticMethod(isSuper ? 0 : STATIC, - referenceBridgeName(), null, - owner.enclClass()) - : null; this.sigPolySym = isSignaturePolymorphic() ? makePrivateSyntheticMethod(tree.sym.flags(), tree.sym.name, bridgedRefSig(), tree.sym.enclClass()) : null; - if (dumpLambdaToMethodStats) { - String key = bridgeSym == null ? - "mref.stat" : "mref.stat.1"; - log.note(tree, key, needsAltMetafactory(), bridgeSym); - } } /** * Get the opcode associated with this method reference */ int referenceKind() { - return LambdaToMethod.this.referenceKind(needsBridge() - ? bridgeSym - : tree.sym); + return LambdaToMethod.this.referenceKind(tree.sym); } boolean needsVarArgsConversion() { @@ -2081,62 +2068,6 @@ public class LambdaToMethod extends TreeTranslator { } /** - * Generate a disambiguating string to increase stability (important - * if serialized) - * - * @return String to differentiate synthetic lambda method names - */ - private String referenceBridgeDisambiguation() { - StringBuilder buf = new StringBuilder(); - // Append the enclosing method signature to differentiate - // overloaded enclosing methods. - if (owner.type != null) { - buf.append(typeSig(owner.type)); - buf.append(":"); - } - - // Append qualifier type - buf.append(classSig(tree.sym.owner.type)); - - // Note static/instance - buf.append(tree.sym.isStatic()? " S " : " I "); - - // Append referenced signature - buf.append(typeSig(tree.sym.erasure(types))); - - return buf.toString(); - } - - /** - * Construct a unique stable name for the method reference bridge - * - * @return Name to use for the synthetic method name - */ - private Name referenceBridgeName() { - StringBuilder buf = new StringBuilder(); - // Append lambda ID, this is semantically significant - buf.append(names.lambda); - // Note that it is a method reference bridge - buf.append("MR$"); - // Append the enclosing method name - buf.append(enclosingMethodName()); - buf.append('$'); - // Append the referenced method name - buf.append(syntheticMethodNameComponent(tree.sym.name)); - buf.append('$'); - // Append a hash of the disambiguating string : enclosing method - // signature, etc. - String disam = referenceBridgeDisambiguation(); - buf.append(Integer.toHexString(disam.hashCode())); - buf.append('$'); - // The above appended name components may not be unique, append - // a count based on the above name components. - buf.append(syntheticMethodNameCounts.getIndex(buf)); - String result = buf.toString(); - return names.fromString(result); - } - - /** * @return Is this an array operation like clone() */ boolean isArrayOp() { @@ -2171,13 +2102,40 @@ public class LambdaToMethod extends TreeTranslator { } /** - * Does this reference needs a bridge (i.e. var args need to be - * expanded or "super" is used) + * Erasure destroys the implementation parameter subtype + * relationship for intersection types + */ + boolean interfaceParameterIsIntersectionType() { + List<Type> tl = tree.getDescriptorType(types).getParameterTypes(); + if (tree.kind == ReferenceKind.UNBOUND) { + tl = tl.tail; + } + for (; tl.nonEmpty(); tl = tl.tail) { + Type pt = tl.head; + if (pt.getKind() == TypeKind.TYPEVAR) { + TypeVar tv = (TypeVar) pt; + if (tv.bound.getKind() == TypeKind.INTERSECTION) { + return true; + } + } + } + return false; + } + + /** + * Does this reference need to be converted to a lambda + * (i.e. var args need to be expanded or "super" is used) */ - final boolean needsBridge() { - return isSuper || needsVarArgsConversion() || isArrayOp() || + final boolean needsConversionToLambda() { + return interfaceParameterIsIntersectionType() || + isSuper || + needsVarArgsConversion() || + isArrayOp() || isPrivateInOtherClass() || - !receiverAccessible(); + !receiverAccessible() || + (tree.getMode() == ReferenceMode.NEW && + tree.kind != ReferenceKind.ARRAY_CTOR && + (tree.sym.owner.isLocal() || tree.sym.owner.isInner())); } Type generatedRefSig() { diff --git a/src/share/classes/com/sun/tools/javac/comp/MemberEnter.java b/src/share/classes/com/sun/tools/javac/comp/MemberEnter.java index a7825dd7..466897c9 100644 --- a/src/share/classes/com/sun/tools/javac/comp/MemberEnter.java +++ b/src/share/classes/com/sun/tools/javac/comp/MemberEnter.java @@ -575,51 +575,46 @@ public class MemberEnter extends JCTree.Visitor implements Completer { Env<AttrContext> localEnv = methodEnv(tree, env); - annotate.enterStart(); + DiagnosticPosition prevLintPos = deferredLintHandler.setPos(tree.pos()); try { - DiagnosticPosition prevLintPos = deferredLintHandler.setPos(tree.pos()); - try { - // Compute the method type - m.type = signature(m, tree.typarams, tree.params, - tree.restype, tree.recvparam, - tree.thrown, - localEnv); - } finally { - deferredLintHandler.setPos(prevLintPos); - } + // Compute the method type + m.type = signature(m, tree.typarams, tree.params, + tree.restype, tree.recvparam, + tree.thrown, + localEnv); + } finally { + deferredLintHandler.setPos(prevLintPos); + } - if (types.isSignaturePolymorphic(m)) { - m.flags_field |= SIGNATURE_POLYMORPHIC; - } + if (types.isSignaturePolymorphic(m)) { + m.flags_field |= SIGNATURE_POLYMORPHIC; + } - // Set m.params - ListBuffer<VarSymbol> params = new ListBuffer<VarSymbol>(); - JCVariableDecl lastParam = null; - for (List<JCVariableDecl> l = tree.params; l.nonEmpty(); l = l.tail) { - JCVariableDecl param = lastParam = l.head; - params.append(Assert.checkNonNull(param.sym)); - } - m.params = params.toList(); + // Set m.params + ListBuffer<VarSymbol> params = new ListBuffer<VarSymbol>(); + JCVariableDecl lastParam = null; + for (List<JCVariableDecl> l = tree.params; l.nonEmpty(); l = l.tail) { + JCVariableDecl param = lastParam = l.head; + params.append(Assert.checkNonNull(param.sym)); + } + m.params = params.toList(); - // mark the method varargs, if necessary - if (lastParam != null && (lastParam.mods.flags & Flags.VARARGS) != 0) - m.flags_field |= Flags.VARARGS; + // mark the method varargs, if necessary + if (lastParam != null && (lastParam.mods.flags & Flags.VARARGS) != 0) + m.flags_field |= Flags.VARARGS; - localEnv.info.scope.leave(); - if (chk.checkUnique(tree.pos(), m, enclScope)) { - enclScope.enter(m); - } + localEnv.info.scope.leave(); + if (chk.checkUnique(tree.pos(), m, enclScope)) { + enclScope.enter(m); + } - annotateLater(tree.mods.annotations, localEnv, m, tree.pos()); - // Visit the signature of the method. Note that - // TypeAnnotate doesn't descend into the body. - typeAnnotate(tree, localEnv, m, tree.pos()); + annotateLater(tree.mods.annotations, localEnv, m, tree.pos()); + // Visit the signature of the method. Note that + // TypeAnnotate doesn't descend into the body. + typeAnnotate(tree, localEnv, m, tree.pos()); - if (tree.defaultValue != null) - annotateDefaultValueLater(tree.defaultValue, localEnv, m); - } finally { - annotate.enterDone(); - } + if (tree.defaultValue != null) + annotateDefaultValueLater(tree.defaultValue, localEnv, m); } /** Create a fresh environment for method bodies. @@ -647,54 +642,49 @@ public class MemberEnter extends JCTree.Visitor implements Completer { localEnv.info.staticLevel++; } DiagnosticPosition prevLintPos = deferredLintHandler.setPos(tree.pos()); - annotate.enterStart(); try { - try { - if (TreeInfo.isEnumInit(tree)) { - attr.attribIdentAsEnumType(localEnv, (JCIdent)tree.vartype); - } else { - attr.attribType(tree.vartype, localEnv); - if (TreeInfo.isReceiverParam(tree)) - checkReceiver(tree, localEnv); - } - } finally { - deferredLintHandler.setPos(prevLintPos); + if (TreeInfo.isEnumInit(tree)) { + attr.attribIdentAsEnumType(localEnv, (JCIdent)tree.vartype); + } else { + attr.attribType(tree.vartype, localEnv); + if (TreeInfo.isReceiverParam(tree)) + checkReceiver(tree, localEnv); } + } finally { + deferredLintHandler.setPos(prevLintPos); + } - if ((tree.mods.flags & VARARGS) != 0) { - //if we are entering a varargs parameter, we need to - //replace its type (a plain array type) with the more - //precise VarargsType --- we need to do it this way - //because varargs is represented in the tree as a - //modifier on the parameter declaration, and not as a - //distinct type of array node. - ArrayType atype = (ArrayType)tree.vartype.type.unannotatedType(); - tree.vartype.type = atype.makeVarargs(); - } - Scope enclScope = enter.enterScope(env); - VarSymbol v = - new VarSymbol(0, tree.name, tree.vartype.type, enclScope.owner); - v.flags_field = chk.checkFlags(tree.pos(), tree.mods.flags, v, tree); - tree.sym = v; - if (tree.init != null) { - v.flags_field |= HASINIT; - if ((v.flags_field & FINAL) != 0 && - needsLazyConstValue(tree.init)) { - Env<AttrContext> initEnv = getInitEnv(tree, env); - initEnv.info.enclVar = v; - v.setLazyConstValue(initEnv(tree, initEnv), attr, tree); - } - } - if (chk.checkUnique(tree.pos(), v, enclScope)) { - chk.checkTransparentVar(tree.pos(), v, enclScope); - enclScope.enter(v); + if ((tree.mods.flags & VARARGS) != 0) { + //if we are entering a varargs parameter, we need to + //replace its type (a plain array type) with the more + //precise VarargsType --- we need to do it this way + //because varargs is represented in the tree as a + //modifier on the parameter declaration, and not as a + //distinct type of array node. + ArrayType atype = (ArrayType)tree.vartype.type.unannotatedType(); + tree.vartype.type = atype.makeVarargs(); + } + Scope enclScope = enter.enterScope(env); + VarSymbol v = + new VarSymbol(0, tree.name, tree.vartype.type, enclScope.owner); + v.flags_field = chk.checkFlags(tree.pos(), tree.mods.flags, v, tree); + tree.sym = v; + if (tree.init != null) { + v.flags_field |= HASINIT; + if ((v.flags_field & FINAL) != 0 && + needsLazyConstValue(tree.init)) { + Env<AttrContext> initEnv = getInitEnv(tree, env); + initEnv.info.enclVar = v; + v.setLazyConstValue(initEnv(tree, initEnv), attr, tree); } - annotateLater(tree.mods.annotations, localEnv, v, tree.pos()); - typeAnnotate(tree.vartype, env, v, tree.pos()); - v.pos = tree.pos; - } finally { - annotate.enterDone(); } + if (chk.checkUnique(tree.pos(), v, enclScope)) { + chk.checkTransparentVar(tree.pos(), v, enclScope); + enclScope.enter(v); + } + annotateLater(tree.mods.annotations, localEnv, v, tree.pos()); + typeAnnotate(tree.vartype, env, v, tree.pos()); + v.pos = tree.pos; } // where void checkType(JCTree tree, Type type, String diag) { @@ -1030,189 +1020,194 @@ public class MemberEnter extends JCTree.Visitor implements Completer { JCClassDecl tree = (JCClassDecl)env.tree; boolean wasFirst = isFirst; isFirst = false; - - JavaFileObject prev = log.useSource(env.toplevel.sourcefile); - DiagnosticPosition prevLintPos = deferredLintHandler.setPos(tree.pos()); try { - // Save class environment for later member enter (2) processing. - halfcompleted.append(env); + annotate.enterStart(); - // Mark class as not yet attributed. - c.flags_field |= UNATTRIBUTED; + JavaFileObject prev = log.useSource(env.toplevel.sourcefile); + DiagnosticPosition prevLintPos = deferredLintHandler.setPos(tree.pos()); + try { + // Save class environment for later member enter (2) processing. + halfcompleted.append(env); - // If this is a toplevel-class, make sure any preceding import - // clauses have been seen. - if (c.owner.kind == PCK) { - memberEnter(env.toplevel, env.enclosing(TOPLEVEL)); - todo.append(env); - } + // Mark class as not yet attributed. + c.flags_field |= UNATTRIBUTED; - if (c.owner.kind == TYP) - c.owner.complete(); - - // create an environment for evaluating the base clauses - Env<AttrContext> baseEnv = baseEnv(tree, env); - - if (tree.extending != null) - typeAnnotate(tree.extending, baseEnv, sym, tree.pos()); - for (JCExpression impl : tree.implementing) - typeAnnotate(impl, baseEnv, sym, tree.pos()); - annotate.flush(); - - // Determine supertype. - Type supertype = - (tree.extending != null) - ? attr.attribBase(tree.extending, baseEnv, true, false, true) - : ((tree.mods.flags & Flags.ENUM) != 0) - ? attr.attribBase(enumBase(tree.pos, c), baseEnv, - true, false, false) - : (c.fullname == names.java_lang_Object) - ? Type.noType - : syms.objectType; - ct.supertype_field = modelMissingTypes(supertype, tree.extending, false); - - // Determine interfaces. - ListBuffer<Type> interfaces = new ListBuffer<Type>(); - ListBuffer<Type> all_interfaces = null; // lazy init - Set<Type> interfaceSet = new HashSet<Type>(); - List<JCExpression> interfaceTrees = tree.implementing; - for (JCExpression iface : interfaceTrees) { - Type i = attr.attribBase(iface, baseEnv, false, true, true); - if (i.hasTag(CLASS)) { - interfaces.append(i); - if (all_interfaces != null) all_interfaces.append(i); - chk.checkNotRepeated(iface.pos(), types.erasure(i), interfaceSet); - } else { - if (all_interfaces == null) - all_interfaces = new ListBuffer<Type>().appendList(interfaces); - all_interfaces.append(modelMissingTypes(i, iface, true)); + // If this is a toplevel-class, make sure any preceding import + // clauses have been seen. + if (c.owner.kind == PCK) { + memberEnter(env.toplevel, env.enclosing(TOPLEVEL)); + todo.append(env); } - } - if ((c.flags_field & ANNOTATION) != 0) { - ct.interfaces_field = List.of(syms.annotationType); - ct.all_interfaces_field = ct.interfaces_field; - } else { - ct.interfaces_field = interfaces.toList(); - ct.all_interfaces_field = (all_interfaces == null) - ? ct.interfaces_field : all_interfaces.toList(); - } - if (c.fullname == names.java_lang_Object) { - if (tree.extending != null) { - chk.checkNonCyclic(tree.extending.pos(), - supertype); - ct.supertype_field = Type.noType; + if (c.owner.kind == TYP) + c.owner.complete(); + + // create an environment for evaluating the base clauses + Env<AttrContext> baseEnv = baseEnv(tree, env); + + if (tree.extending != null) + typeAnnotate(tree.extending, baseEnv, sym, tree.pos()); + for (JCExpression impl : tree.implementing) + typeAnnotate(impl, baseEnv, sym, tree.pos()); + annotate.flush(); + + // Determine supertype. + Type supertype = + (tree.extending != null) + ? attr.attribBase(tree.extending, baseEnv, true, false, true) + : ((tree.mods.flags & Flags.ENUM) != 0) + ? attr.attribBase(enumBase(tree.pos, c), baseEnv, + true, false, false) + : (c.fullname == names.java_lang_Object) + ? Type.noType + : syms.objectType; + ct.supertype_field = modelMissingTypes(supertype, tree.extending, false); + + // Determine interfaces. + ListBuffer<Type> interfaces = new ListBuffer<Type>(); + ListBuffer<Type> all_interfaces = null; // lazy init + Set<Type> interfaceSet = new HashSet<Type>(); + List<JCExpression> interfaceTrees = tree.implementing; + for (JCExpression iface : interfaceTrees) { + Type i = attr.attribBase(iface, baseEnv, false, true, true); + if (i.hasTag(CLASS)) { + interfaces.append(i); + if (all_interfaces != null) all_interfaces.append(i); + chk.checkNotRepeated(iface.pos(), types.erasure(i), interfaceSet); + } else { + if (all_interfaces == null) + all_interfaces = new ListBuffer<Type>().appendList(interfaces); + all_interfaces.append(modelMissingTypes(i, iface, true)); + } } - else if (tree.implementing.nonEmpty()) { - chk.checkNonCyclic(tree.implementing.head.pos(), - ct.interfaces_field.head); - ct.interfaces_field = List.nil(); + if ((c.flags_field & ANNOTATION) != 0) { + ct.interfaces_field = List.of(syms.annotationType); + ct.all_interfaces_field = ct.interfaces_field; + } else { + ct.interfaces_field = interfaces.toList(); + ct.all_interfaces_field = (all_interfaces == null) + ? ct.interfaces_field : all_interfaces.toList(); } - } - // Annotations. - // In general, we cannot fully process annotations yet, but we - // can attribute the annotation types and then check to see if the - // @Deprecated annotation is present. - attr.attribAnnotationTypes(tree.mods.annotations, baseEnv); - if (hasDeprecatedAnnotation(tree.mods.annotations)) - c.flags_field |= DEPRECATED; - annotateLater(tree.mods.annotations, baseEnv, c, tree.pos()); - // class type parameters use baseEnv but everything uses env - - chk.checkNonCyclicDecl(tree); - - attr.attribTypeVariables(tree.typarams, baseEnv); - // Do this here, where we have the symbol. - for (JCTypeParameter tp : tree.typarams) - typeAnnotate(tp, baseEnv, sym, tree.pos()); - - // Add default constructor if needed. - if ((c.flags() & INTERFACE) == 0 && - !TreeInfo.hasConstructors(tree.defs)) { - List<Type> argtypes = List.nil(); - List<Type> typarams = List.nil(); - List<Type> thrown = List.nil(); - long ctorFlags = 0; - boolean based = false; - boolean addConstructor = true; - JCNewClass nc = null; - if (c.name.isEmpty()) { - nc = (JCNewClass)env.next.tree; - if (nc.constructor != null) { - addConstructor = nc.constructor.kind != ERR; - Type superConstrType = types.memberType(c.type, - nc.constructor); - argtypes = superConstrType.getParameterTypes(); - typarams = superConstrType.getTypeArguments(); - ctorFlags = nc.constructor.flags() & VARARGS; - if (nc.encl != null) { - argtypes = argtypes.prepend(nc.encl.type); - based = true; - } - thrown = superConstrType.getThrownTypes(); + if (c.fullname == names.java_lang_Object) { + if (tree.extending != null) { + chk.checkNonCyclic(tree.extending.pos(), + supertype); + ct.supertype_field = Type.noType; + } + else if (tree.implementing.nonEmpty()) { + chk.checkNonCyclic(tree.implementing.head.pos(), + ct.interfaces_field.head); + ct.interfaces_field = List.nil(); } } - if (addConstructor) { - MethodSymbol basedConstructor = nc != null ? - (MethodSymbol)nc.constructor : null; - JCTree constrDef = DefaultConstructor(make.at(tree.pos), c, - basedConstructor, - typarams, argtypes, thrown, - ctorFlags, based); - tree.defs = tree.defs.prepend(constrDef); + + // Annotations. + // In general, we cannot fully process annotations yet, but we + // can attribute the annotation types and then check to see if the + // @Deprecated annotation is present. + attr.attribAnnotationTypes(tree.mods.annotations, baseEnv); + if (hasDeprecatedAnnotation(tree.mods.annotations)) + c.flags_field |= DEPRECATED; + annotateLater(tree.mods.annotations, baseEnv, c, tree.pos()); + // class type parameters use baseEnv but everything uses env + + chk.checkNonCyclicDecl(tree); + + attr.attribTypeVariables(tree.typarams, baseEnv); + // Do this here, where we have the symbol. + for (JCTypeParameter tp : tree.typarams) + typeAnnotate(tp, baseEnv, sym, tree.pos()); + + // Add default constructor if needed. + if ((c.flags() & INTERFACE) == 0 && + !TreeInfo.hasConstructors(tree.defs)) { + List<Type> argtypes = List.nil(); + List<Type> typarams = List.nil(); + List<Type> thrown = List.nil(); + long ctorFlags = 0; + boolean based = false; + boolean addConstructor = true; + JCNewClass nc = null; + if (c.name.isEmpty()) { + nc = (JCNewClass)env.next.tree; + if (nc.constructor != null) { + addConstructor = nc.constructor.kind != ERR; + Type superConstrType = types.memberType(c.type, + nc.constructor); + argtypes = superConstrType.getParameterTypes(); + typarams = superConstrType.getTypeArguments(); + ctorFlags = nc.constructor.flags() & VARARGS; + if (nc.encl != null) { + argtypes = argtypes.prepend(nc.encl.type); + based = true; + } + thrown = superConstrType.getThrownTypes(); + } + } + if (addConstructor) { + MethodSymbol basedConstructor = nc != null ? + (MethodSymbol)nc.constructor : null; + JCTree constrDef = DefaultConstructor(make.at(tree.pos), c, + basedConstructor, + typarams, argtypes, thrown, + ctorFlags, based); + tree.defs = tree.defs.prepend(constrDef); + } } - } - // enter symbols for 'this' into current scope. - VarSymbol thisSym = - new VarSymbol(FINAL | HASINIT, names._this, c.type, c); - thisSym.pos = Position.FIRSTPOS; - env.info.scope.enter(thisSym); - // if this is a class, enter symbol for 'super' into current scope. - if ((c.flags_field & INTERFACE) == 0 && - ct.supertype_field.hasTag(CLASS)) { - VarSymbol superSym = - new VarSymbol(FINAL | HASINIT, names._super, - ct.supertype_field, c); - superSym.pos = Position.FIRSTPOS; - env.info.scope.enter(superSym); - } + // enter symbols for 'this' into current scope. + VarSymbol thisSym = + new VarSymbol(FINAL | HASINIT, names._this, c.type, c); + thisSym.pos = Position.FIRSTPOS; + env.info.scope.enter(thisSym); + // if this is a class, enter symbol for 'super' into current scope. + if ((c.flags_field & INTERFACE) == 0 && + ct.supertype_field.hasTag(CLASS)) { + VarSymbol superSym = + new VarSymbol(FINAL | HASINIT, names._super, + ct.supertype_field, c); + superSym.pos = Position.FIRSTPOS; + env.info.scope.enter(superSym); + } - // check that no package exists with same fully qualified name, - // but admit classes in the unnamed package which have the same - // name as a top-level package. - if (checkClash && - c.owner.kind == PCK && c.owner != syms.unnamedPackage && - reader.packageExists(c.fullname)) { - log.error(tree.pos, "clash.with.pkg.of.same.name", Kinds.kindName(sym), c); - } - if (c.owner.kind == PCK && (c.flags_field & PUBLIC) == 0 && - !env.toplevel.sourcefile.isNameCompatible(c.name.toString(),JavaFileObject.Kind.SOURCE)) { - c.flags_field |= AUXILIARY; + // check that no package exists with same fully qualified name, + // but admit classes in the unnamed package which have the same + // name as a top-level package. + if (checkClash && + c.owner.kind == PCK && c.owner != syms.unnamedPackage && + reader.packageExists(c.fullname)) { + log.error(tree.pos, "clash.with.pkg.of.same.name", Kinds.kindName(sym), c); + } + if (c.owner.kind == PCK && (c.flags_field & PUBLIC) == 0 && + !env.toplevel.sourcefile.isNameCompatible(c.name.toString(),JavaFileObject.Kind.SOURCE)) { + c.flags_field |= AUXILIARY; + } + } catch (CompletionFailure ex) { + chk.completionError(tree.pos(), ex); + } finally { + deferredLintHandler.setPos(prevLintPos); + log.useSource(prev); } - } catch (CompletionFailure ex) { - chk.completionError(tree.pos(), ex); - } finally { - deferredLintHandler.setPos(prevLintPos); - log.useSource(prev); - } - // Enter all member fields and methods of a set of half completed - // classes in a second phase. - if (wasFirst) { - try { - while (halfcompleted.nonEmpty()) { - Env<AttrContext> toFinish = halfcompleted.next(); - finish(toFinish); - if (allowTypeAnnos) { - typeAnnotations.organizeTypeAnnotationsSignatures(toFinish, (JCClassDecl)toFinish.tree); - typeAnnotations.validateTypeAnnotationsSignatures(toFinish, (JCClassDecl)toFinish.tree); + // Enter all member fields and methods of a set of half completed + // classes in a second phase. + if (wasFirst) { + try { + while (halfcompleted.nonEmpty()) { + Env<AttrContext> toFinish = halfcompleted.next(); + finish(toFinish); + if (allowTypeAnnos) { + typeAnnotations.organizeTypeAnnotationsSignatures(toFinish, (JCClassDecl)toFinish.tree); + typeAnnotations.validateTypeAnnotationsSignatures(toFinish, (JCClassDecl)toFinish.tree); + } } + } finally { + isFirst = true; } - } finally { - isFirst = true; } + } finally { + annotate.enterDone(); } } diff --git a/src/share/classes/com/sun/tools/javac/comp/Resolve.java b/src/share/classes/com/sun/tools/javac/comp/Resolve.java index ef50a2ab..87a29320 100644 --- a/src/share/classes/com/sun/tools/javac/comp/Resolve.java +++ b/src/share/classes/com/sun/tools/javac/comp/Resolve.java @@ -3045,7 +3045,7 @@ public class Resolve { /** * Should lookup stop at given phase with given result */ - protected boolean shouldStop(Symbol sym, MethodResolutionPhase phase) { + final boolean shouldStop(Symbol sym, MethodResolutionPhase phase) { return phase.ordinal() > maxPhase.ordinal() || sym.kind < ERRONEOUS || sym.kind == AMBIGUOUS; } @@ -3220,7 +3220,7 @@ public class Resolve { super(referenceTree, name, site, argtypes.tail, typeargtypes, maxPhase); if (site.isRaw() && !argtypes.head.hasTag(NONE)) { Type asSuperSite = types.asSuper(argtypes.head, site.tsym); - this.site = asSuperSite; + this.site = types.capture(asSuperSite); } } @@ -4228,15 +4228,39 @@ public class Resolve { VARARITY(true, true) { @Override public Symbol mergeResults(Symbol bestSoFar, Symbol sym) { - switch (sym.kind) { - case WRONG_MTH: - return (bestSoFar.kind == WRONG_MTH || bestSoFar.kind == WRONG_MTHS) ? - bestSoFar : - sym; - case ABSENT_MTH: - return bestSoFar; - default: - return sym; + //Check invariants (see {@code LookupHelper.shouldStop}) + Assert.check(bestSoFar.kind >= ERRONEOUS && bestSoFar.kind != AMBIGUOUS); + if (sym.kind < ERRONEOUS) { + //varargs resolution successful + return sym; + } else { + //pick best error + switch (bestSoFar.kind) { + case WRONG_MTH: + case WRONG_MTHS: + //Override previous errors if they were caused by argument mismatch. + //This generally means preferring current symbols - but we need to pay + //attention to the fact that the varargs lookup returns 'less' candidates + //than the previous rounds, and adjust that accordingly. + switch (sym.kind) { + case WRONG_MTH: + //if the previous round matched more than one method, return that + //result instead + return bestSoFar.kind == WRONG_MTHS ? + bestSoFar : sym; + case ABSENT_MTH: + //do not override erroneous symbol if the arity lookup did not + //match any method + return bestSoFar; + case WRONG_MTHS: + default: + //safe to override + return sym; + } + default: + //otherwise, return first error + return bestSoFar; + } } } }; diff --git a/src/share/classes/com/sun/tools/javac/jvm/Code.java b/src/share/classes/com/sun/tools/javac/jvm/Code.java index 044a9983..b2a29e79 100644 --- a/src/share/classes/com/sun/tools/javac/jvm/Code.java +++ b/src/share/classes/com/sun/tools/javac/jvm/Code.java @@ -2017,13 +2017,12 @@ public class Code { List<VarSymbol> locals = lvtRanges.getVars(meth, tree); for (LocalVar localVar: lvar) { for (VarSymbol aliveLocal : locals) { - if (localVar == null) { - return; - } - if (localVar.sym == aliveLocal && localVar.lastRange() != null) { - char length = (char)(closingCP - localVar.lastRange().start_pc); - if (length < Character.MAX_VALUE) { - localVar.closeRange(length); + 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); + } } } } @@ -2032,12 +2031,11 @@ public class Code { void adjustAliveRanges(int oldCP, int delta) { for (LocalVar localVar: lvar) { - if (localVar == null) { - return; - } - for (LocalVar.Range range: localVar.aliveRanges) { - if (range.closed() && range.start_pc + range.length >= oldCP) { - range.length += delta; + if (localVar != null) { + for (LocalVar.Range range: localVar.aliveRanges) { + if (range.closed() && range.start_pc + range.length >= oldCP) { + range.length += delta; + } } } } diff --git a/src/share/classes/com/sun/tools/javac/jvm/Gen.java b/src/share/classes/com/sun/tools/javac/jvm/Gen.java index 0bf2b9e9..74a9fa82 100644 --- a/src/share/classes/com/sun/tools/javac/jvm/Gen.java +++ b/src/share/classes/com/sun/tools/javac/jvm/Gen.java @@ -74,6 +74,7 @@ public class Gen extends JCTree.Visitor { private Name accessDollar; private final Types types; private final Lower lower; + private final Flow flow; /** Switch: GJ mode? */ @@ -125,6 +126,7 @@ public class Gen extends JCTree.Visitor { stringBufferAppend = new HashMap<Type,Symbol>(); accessDollar = names. fromString("access" + target.syntheticNameChar()); + flow = Flow.instance(context); lower = Lower.instance(context); Options options = Options.instance(context); @@ -2516,9 +2518,7 @@ public class Gen extends JCTree.Visitor { */ if (varDebugInfo && (cdef.sym.flags() & SYNTHETIC) == 0) { try { - LVTAssignAnalyzer lvtAssignAnalyzer = LVTAssignAnalyzer.make( - lvtRanges, syms, names); - lvtAssignAnalyzer.analyzeTree(localEnv); + new LVTAssignAnalyzer().analyzeTree(localEnv); } catch (Throwable e) { throw e; } @@ -2609,11 +2609,10 @@ public class Gen extends JCTree.Visitor { } } - static class LVTAssignAnalyzer + class LVTAssignAnalyzer extends Flow.AbstractAssignAnalyzer<LVTAssignAnalyzer.LVTAssignPendingExit> { final LVTBits lvtInits; - final LVTRanges lvtRanges; /* This class is anchored to a context dependent tree. The tree can * vary inside the same instruction for example in the switch instruction @@ -2621,35 +2620,12 @@ public class Gen extends JCTree.Visitor { * to a given case. The aim is to always anchor the bits to the tree * capable of closing a DA range. */ - static class LVTBits extends Bits { - - enum BitsOpKind { - INIT, - CLEAR, - INCL_BIT, - EXCL_BIT, - ASSIGN, - AND_SET, - OR_SET, - DIFF_SET, - XOR_SET, - INCL_RANGE, - EXCL_RANGE, - } + class LVTBits extends Bits { JCTree currentTree; - LVTAssignAnalyzer analyzer; private int[] oldBits = null; BitsState stateBeforeOp; - LVTBits() { - super(false); - } - - LVTBits(int[] bits, BitsState initState) { - super(bits, initState); - } - @Override public void clear() { generalOp(null, -1, BitsOpKind.CLEAR); @@ -2757,12 +2733,11 @@ public class Gen extends JCTree.Visitor { if (currentTree != null && stateBeforeOp != BitsState.UNKNOWN && trackTree(currentTree)) { - List<VarSymbol> locals = - analyzer.lvtRanges - .getVars(analyzer.currentMethod, currentTree); + List<VarSymbol> locals = lvtRanges + .getVars(currentMethod, currentTree); locals = locals != null ? locals : List.<VarSymbol>nil(); - for (JCVariableDecl vardecl : analyzer.vardecls) { + for (JCVariableDecl vardecl : vardecls) { //once the first is null, the rest will be so. if (vardecl == null) { break; @@ -2772,7 +2747,7 @@ public class Gen extends JCTree.Visitor { } } if (!locals.isEmpty()) { - analyzer.lvtRanges.setEntry(analyzer.currentMethod, + lvtRanges.setEntry(currentMethod, currentTree, locals); } } @@ -2790,7 +2765,7 @@ public class Gen extends JCTree.Visitor { boolean trackVar(VarSymbol var) { return (var.owner.kind == MTH && (var.flags() & PARAMETER) == 0 && - analyzer.trackable(var)); + trackable(var)); } boolean trackTree(JCTree tree) { @@ -2806,7 +2781,8 @@ public class Gen extends JCTree.Visitor { } - public class LVTAssignPendingExit extends Flow.AssignAnalyzer.AssignPendingExit { + public class LVTAssignPendingExit extends + Flow.AbstractAssignAnalyzer<LVTAssignPendingExit>.AbstractAssignPendingExit { LVTAssignPendingExit(JCTree tree, final Bits inits, final Bits uninits) { super(tree, inits, uninits); @@ -2819,16 +2795,10 @@ public class Gen extends JCTree.Visitor { } } - private LVTAssignAnalyzer(LVTRanges lvtRanges, Symtab syms, Names names) { - super(new LVTBits(), syms, names, false); - lvtInits = (LVTBits)inits; - this.lvtRanges = lvtRanges; - } - - public static LVTAssignAnalyzer make(LVTRanges lvtRanges, Symtab syms, Names names) { - LVTAssignAnalyzer result = new LVTAssignAnalyzer(lvtRanges, syms, names); - result.lvtInits.analyzer = result; - return result; + private LVTAssignAnalyzer() { + flow.super(); + lvtInits = new LVTBits(); + inits = lvtInits; } @Override diff --git a/src/share/classes/com/sun/tools/javac/parser/DocCommentParser.java b/src/share/classes/com/sun/tools/javac/parser/DocCommentParser.java index 8df975dd..80697a6b 100644 --- a/src/share/classes/com/sun/tools/javac/parser/DocCommentParser.java +++ b/src/share/classes/com/sun/tools/javac/parser/DocCommentParser.java @@ -1039,7 +1039,7 @@ public class DocCommentParser { } /** - * @see <a href="http://docs.oracle.com/javase/7/docs/technotes/tools/solaris/javadoc.html#javadoctags">Javadoc Tags</a> + * @see <a href="https://docs.oracle.com/javase/7/docs/technotes/tools/solaris/javadoc.html#javadoctags">Javadoc Tags</a> */ private void initTagParsers() { TagParser[] parsers = { diff --git a/src/share/classes/com/sun/tools/javac/resources/compiler_ja.properties b/src/share/classes/com/sun/tools/javac/resources/compiler_ja.properties index abe569ba..2f2d16c2 100644 --- a/src/share/classes/com/sun/tools/javac/resources/compiler_ja.properties +++ b/src/share/classes/com/sun/tools/javac/resources/compiler_ja.properties @@ -1534,7 +1534,7 @@ compiler.warn.override.unchecked.ret={0}\n\u623B\u308A\u5024\u306E\u578B\u306F{1 compiler.warn.override.unchecked.thrown={0}\n\u30AA\u30FC\u30D0\u30FC\u30E9\u30A4\u30C9\u3055\u308C\u305F\u30E1\u30BD\u30C3\u30C9\u306F{1}\u3092\u30B9\u30ED\u30FC\u3057\u307E\u305B\u3093 # 0: symbol -compiler.warn.override.equals.but.not.hashcode=\u30AF\u30E9\u30B9{0}\u306F\u7B49\u53F7\u3092\u30AA\u30FC\u30D0\u30FC\u30E9\u30A4\u30C9\u3057\u307E\u3059\u304C\u3001\u3053\u306E\u30AF\u30E9\u30B9\u3082\u30B9\u30FC\u30D1\u30FC\u30AF\u30E9\u30B9\u3082hashCode\u30E1\u30BD\u30C3\u30C9\u3092\u30AA\u30FC\u30D0\u30FC\u30E9\u30A4\u30C9\u3057\u307E\u305B\u3093 +compiler.warn.override.equals.but.not.hashcode=\u30AF\u30E9\u30B9{0}\u306Fequals\u3092\u30AA\u30FC\u30D0\u30FC\u30E9\u30A4\u30C9\u3057\u307E\u3059\u304C\u3001\u3053\u306E\u30AF\u30E9\u30B9\u3082\u3001\u307E\u305F\u3001\u3044\u304B\u306A\u308B\u30B9\u30FC\u30D1\u30FC\u30AF\u30E9\u30B9\u3082\u3001hashCode\u30E1\u30BD\u30C3\u30C9\u3092\u30AA\u30FC\u30D0\u30FC\u30E9\u30A4\u30C9\u3057\u307E\u305B\u3093 ## The following are all possible strings for the first argument ({0}) of the ## above strings. @@ -1677,6 +1677,9 @@ compiler.err.intersection.types.in.cast.not.supported.in.source=\u30AD\u30E3\u30 # 0: string compiler.err.static.intf.methods.not.supported.in.source=static\u30A4\u30F3\u30BF\u30D5\u30A7\u30FC\u30B9\u306F-source {0}\u3067\u30B5\u30DD\u30FC\u30C8\u3055\u308C\u3066\u3044\u307E\u305B\u3093\n(static\u30A4\u30F3\u30BF\u30D5\u30A7\u30FC\u30B9\u3092\u4F7F\u7528\u53EF\u80FD\u306B\u3059\u308B\u306B\u306F\u3001-source 8\u4EE5\u4E0A\u3092\u4F7F\u7528\u3057\u3066\u304F\u3060\u3055\u3044) +# 0: string +compiler.err.static.intf.method.invoke.not.supported.in.source=static\u30A4\u30F3\u30BF\u30D5\u30A7\u30FC\u30B9\u30FB\u30E1\u30BD\u30C3\u30C9\u547C\u51FA\u3057\u306F-source {0}\u3067\u30B5\u30DD\u30FC\u30C8\u3055\u308C\u3066\u3044\u307E\u305B\u3093\n(static\u30A4\u30F3\u30BF\u30D5\u30A7\u30FC\u30B9\u30FB\u30E1\u30BD\u30C3\u30C9\u547C\u51FA\u3057\u3092\u4F7F\u7528\u53EF\u80FD\u306B\u3059\u308B\u306B\u306F\u3001-source 8\u4EE5\u4E0A\u3092\u4F7F\u7528\u3057\u3066\u304F\u3060\u3055\u3044) + ######################################## # Diagnostics for verbose resolution # used by Resolve (debug only) diff --git a/src/share/classes/com/sun/tools/javac/resources/compiler_zh_CN.properties b/src/share/classes/com/sun/tools/javac/resources/compiler_zh_CN.properties index bd08ba57..27b1a5e1 100644 --- a/src/share/classes/com/sun/tools/javac/resources/compiler_zh_CN.properties +++ b/src/share/classes/com/sun/tools/javac/resources/compiler_zh_CN.properties @@ -1534,7 +1534,7 @@ compiler.warn.override.unchecked.ret={0}\n\u8FD4\u56DE\u7C7B\u578B\u9700\u8981\u compiler.warn.override.unchecked.thrown={0}\n\u88AB\u8986\u76D6\u7684\u65B9\u6CD5\u672A\u629B\u51FA{1} # 0: symbol -compiler.warn.override.equals.but.not.hashcode=\u7C7B{0}\u8986\u76D6\u4E86\u7B49\u53F7, \u4F46\u8BE5\u7C7B\u6216\u4EFB\u4F55\u8D85\u7C7B\u90FD\u672A\u8986\u76D6 hashCode \u65B9\u6CD5 +compiler.warn.override.equals.but.not.hashcode=\u7C7B{0}\u8986\u76D6\u4E86 equals, \u4F46\u8BE5\u7C7B\u6216\u4EFB\u4F55\u8D85\u7C7B\u90FD\u672A\u8986\u76D6 hashCode \u65B9\u6CD5 ## The following are all possible strings for the first argument ({0}) of the ## above strings. @@ -1677,6 +1677,9 @@ compiler.err.intersection.types.in.cast.not.supported.in.source=-source {0} \u4E # 0: string compiler.err.static.intf.methods.not.supported.in.source=-source {0} \u4E2D\u4E0D\u652F\u6301\u9759\u6001\u63A5\u53E3\u65B9\u6CD5\n(\u8BF7\u4F7F\u7528 -source 8 \u6216\u66F4\u9AD8\u7248\u672C\u4EE5\u542F\u7528\u9759\u6001\u63A5\u53E3\u65B9\u6CD5) +# 0: string +compiler.err.static.intf.method.invoke.not.supported.in.source=-source {0} \u4E2D\u4E0D\u652F\u6301\u9759\u6001\u63A5\u53E3\u65B9\u6CD5\u8C03\u7528\n(\u8BF7\u4F7F\u7528 -source 8 \u6216\u66F4\u9AD8\u7248\u672C\u4EE5\u542F\u7528\u9759\u6001\u63A5\u53E3\u65B9\u6CD5\u8C03\u7528) + ######################################## # Diagnostics for verbose resolution # used by Resolve (debug only) diff --git a/src/share/classes/com/sun/tools/javac/resources/javac_ja.properties b/src/share/classes/com/sun/tools/javac/resources/javac_ja.properties index 506adc60..17d96af7 100644 --- a/src/share/classes/com/sun/tools/javac/resources/javac_ja.properties +++ b/src/share/classes/com/sun/tools/javac/resources/javac_ja.properties @@ -37,7 +37,7 @@ javac.opt.bootclasspath=\u30D6\u30FC\u30C8\u30B9\u30C8\u30E9\u30C3\u30D7\u30FB\u javac.opt.Xbootclasspath.p=\u30D6\u30FC\u30C8\u30B9\u30C8\u30E9\u30C3\u30D7\u30FB\u30AF\u30E9\u30B9\u30FB\u30D1\u30B9\u306B\u4ED8\u52A0\u3059\u308B javac.opt.Xbootclasspath.a=\u30D6\u30FC\u30C8\u30B9\u30C8\u30E9\u30C3\u30D7\u30FB\u30AF\u30E9\u30B9\u30FB\u30D1\u30B9\u306B\u8FFD\u52A0\u3059\u308B javac.opt.endorseddirs=\u63A8\u5968\u898F\u683C\u30D1\u30B9\u306E\u5834\u6240\u3092\u30AA\u30FC\u30D0\u30FC\u30E9\u30A4\u30C9\u3059\u308B -javac.opt.extdirs=\u30A4\u30F3\u30B9\u30C8\u30FC\u30EB\u6E08\u307F\u62E1\u5F35\u6A5F\u80FD\u306E\u5834\u6240\u3092\u30AA\u30FC\u30D0\u30FC\u30E9\u30A4\u30C9\u3059\u308B +javac.opt.extdirs=\u30A4\u30F3\u30B9\u30C8\u30FC\u30EB\u6E08\u62E1\u5F35\u6A5F\u80FD\u306E\u5834\u6240\u3092\u30AA\u30FC\u30D0\u30FC\u30E9\u30A4\u30C9\u3059\u308B javac.opt.processorpath=\u6CE8\u91C8\u30D7\u30ED\u30BB\u30C3\u30B5\u3092\u691C\u7D22\u3059\u308B\u4F4D\u7F6E\u3092\u6307\u5B9A\u3059\u308B javac.opt.processor=\u5B9F\u884C\u3059\u308B\u6CE8\u91C8\u30D7\u30ED\u30BB\u30C3\u30B5\u306E\u540D\u524D\u3002\u30C7\u30D5\u30A9\u30EB\u30C8\u306E\u691C\u51FA\u51E6\u7406\u3092\u30D0\u30A4\u30D1\u30B9 javac.opt.parameters=\u30E1\u30BD\u30C3\u30C9\u30FB\u30D1\u30E9\u30E1\u30FC\u30BF\u306B\u30EA\u30D5\u30EC\u30AF\u30B7\u30E7\u30F3\u7528\u306E\u30E1\u30BF\u30C7\u30FC\u30BF\u3092\u751F\u6210\u3057\u307E\u3059 diff --git a/src/share/classes/com/sun/tools/javac/util/Bits.java b/src/share/classes/com/sun/tools/javac/util/Bits.java index f8db31a4..4319aad3 100644 --- a/src/share/classes/com/sun/tools/javac/util/Bits.java +++ b/src/share/classes/com/sun/tools/javac/util/Bits.java @@ -84,6 +84,20 @@ public class Bits { } + public enum BitsOpKind { + INIT, + CLEAR, + INCL_BIT, + EXCL_BIT, + ASSIGN, + AND_SET, + OR_SET, + DIFF_SET, + XOR_SET, + INCL_RANGE, + EXCL_RANGE, + } + private final static int wordlen = 32; private final static int wordshift = 5; private final static int wordmask = wordlen - 1; diff --git a/src/share/classes/com/sun/tools/javac/util/Convert.java b/src/share/classes/com/sun/tools/javac/util/Convert.java index c4725f35..3d08119f 100644 --- a/src/share/classes/com/sun/tools/javac/util/Convert.java +++ b/src/share/classes/com/sun/tools/javac/util/Convert.java @@ -36,9 +36,9 @@ package com.sun.tools.javac.util; * <p> * See also: * <ul> - * <li><a href="http://docs.oracle.com/javase/specs/jvms/se7/html/jvms-4.html#jvms-4.4.7"> + * <li><a href="https://docs.oracle.com/javase/specs/jvms/se7/html/jvms-4.html#jvms-4.4.7"> * JVMS 4.4.7 </a></li> - * <li><a href="http://docs.oracle.com/javase/7/docs/api/java/io/DataInput.html#modified-utf-8"> + * <li><a href="https://docs.oracle.com/javase/7/docs/api/java/io/DataInput.html#modified-utf-8"> java.io.DataInput: Modified UTF-8 </a></li> <li><a href="https://en.wikipedia.org/wiki/UTF-8#Modified_UTF-8"> Modified UTF-8 (wikipedia) </a></li> diff --git a/src/share/classes/com/sun/tools/jdeps/PlatformClassPath.java b/src/share/classes/com/sun/tools/jdeps/PlatformClassPath.java index 55b9e8ab..115f87e3 100644 --- a/src/share/classes/com/sun/tools/jdeps/PlatformClassPath.java +++ b/src/share/classes/com/sun/tools/jdeps/PlatformClassPath.java @@ -155,7 +155,7 @@ class PlatformClassPath { * Tests if a given package name is exported. */ public boolean isExportedPackage(String pn) { - if (Profile.getProfile(pn) != null) { + if (Profile.getProfile(pn) != null || "javax.jnlp".equals(pn)) { return true; } return exportedPackages.containsKey(pn) ? exportedPackages.get(pn) : false; diff --git a/src/share/classes/com/sun/tools/jdeps/resources/jdeps_ja.properties b/src/share/classes/com/sun/tools/jdeps/resources/jdeps_ja.properties index a5f27a0e..123d68da 100644 --- a/src/share/classes/com/sun/tools/jdeps/resources/jdeps_ja.properties +++ b/src/share/classes/com/sun/tools/jdeps/resources/jdeps_ja.properties @@ -1,4 +1,4 @@ -main.usage.summary=\u4F7F\u7528\u65B9\u6CD5: {0} <options> <classes...>\n\u4F7F\u7528\u53EF\u80FD\u306A\u30AA\u30D7\u30B7\u30E7\u30F3\u306E\u30EA\u30B9\u30C8\u306B\u3064\u3044\u3066\u306F\u3001-h\u3001-?\u307E\u305F\u306F--help\u3092\u4F7F\u7528\u3057\u307E\u3059 +main.usage.summary=\u4F7F\u7528\u65B9\u6CD5: {0} <options> <classes...>\n\u4F7F\u7528\u53EF\u80FD\u306A\u30AA\u30D7\u30B7\u30E7\u30F3\u306E\u30EA\u30B9\u30C8\u306B\u3064\u3044\u3066\u306F\u3001-h\u3001-?\u307E\u305F\u306F-help\u3092\u4F7F\u7528\u3057\u307E\u3059 main.usage=\u4F7F\u7528\u65B9\u6CD5: {0} <options> <classes...>\n<classes>\u306B\u306F\u3001.class\u30D5\u30A1\u30A4\u30EB\u306E\u30D1\u30B9\u540D\u3001\u30C7\u30A3\u30EC\u30AF\u30C8\u30EA\u3001JAR\u30D5\u30A1\u30A4\u30EB\u307E\u305F\u306F\u5B8C\u5168\u4FEE\u98FE\n\u30AF\u30E9\u30B9\u540D\u3092\u6307\u5B9A\u3067\u304D\u307E\u3059\u3002\u4F7F\u7528\u3067\u304D\u308B\u30AA\u30D7\u30B7\u30E7\u30F3\u306F\u6B21\u306E\u3068\u304A\u308A\u3067\u3059: @@ -9,21 +9,23 @@ main.opt.h=\ -h -? -help \u3053\u306E\u4F7F\u7528\u65B9\ main.opt.version=\ -version \u30D0\u30FC\u30B8\u30E7\u30F3\u60C5\u5831 -main.opt.v=\ -v -verbose \u30AF\u30E9\u30B9\u30FB\u30EC\u30D9\u30EB\u306E\u4F9D\u5B58\u6027\u3092\u3059\u3079\u3066\u51FA\u529B\u3057\u307E\u3059\n -verbose:package \u30D1\u30C3\u30B1\u30FC\u30B8\u30FB\u30EC\u30D9\u30EB\u306E\u4F9D\u5B58\u6027\u3092\u51FA\u529B\u3057\u307E\u3059\n (\u540C\u3058\u30A2\u30FC\u30AB\u30A4\u30D6\u5185\u306E\u4F9D\u5B58\u6027\u3092\u9664\u304F)\n -verbose:class \u30AF\u30E9\u30B9\u30FB\u30EC\u30D9\u30EB\u306E\u4F9D\u5B58\u6027\u3092\u51FA\u529B\u3057\u307E\u3059\n (\u540C\u3058\u30A2\u30FC\u30AB\u30A4\u30D6\u5185\u306E\u4F9D\u5B58\u6027\u3092\u9664\u304F) +main.opt.v=\ -v -verbose \u30AF\u30E9\u30B9\u30FB\u30EC\u30D9\u30EB\u306E\u4F9D\u5B58\u6027\u3092\u3059\u3079\u3066\u51FA\u529B\u3057\u307E\u3059\n -verbose:class -filter:none\u3068\u540C\u7B49\u3067\u3059\u3002\n -verbose:package \u30D1\u30C3\u30B1\u30FC\u30B8\u30FB\u30EC\u30D9\u30EB\u306E\u4F9D\u5B58\u6027\u3092\u51FA\u529B\u3057\u307E\u3059\n (\u30C7\u30D5\u30A9\u30EB\u30C8\u3067\u306F\u3001\u540C\u3058\u30D1\u30C3\u30B1\u30FC\u30B8\u5185\u306E\u4F9D\u5B58\u6027\u3092\u9664\u304F)\n -verbose:class \u30AF\u30E9\u30B9\u30FB\u30EC\u30D9\u30EB\u306E\u4F9D\u5B58\u6027\u3092\u51FA\u529B\u3057\u307E\u3059\n (\u30C7\u30D5\u30A9\u30EB\u30C8\u3067\u306F\u3001\u540C\u3058\u30D1\u30C3\u30B1\u30FC\u30B8\u5185\u306E\u4F9D\u5B58\u6027\u3092\u9664\u304F) + +main.opt.f=\ -f <regex> -filter <regex> \u6307\u5B9A\u306E\u30D1\u30BF\u30FC\u30F3\u306B\u4E00\u81F4\u3059\u308B\u4F9D\u5B58\u6027\u3092\u30D5\u30A3\u30EB\u30BF\u3057\u307E\u3059\n \u8907\u6570\u56DE\u6307\u5B9A\u3055\u308C\u305F\u5834\u5408\u3001\u6700\u5F8C\u306E\u3082\u306E\u304C\u4F7F\u7528\u3055\u308C\u307E\u3059\u3002\n -filter:package \u540C\u3058\u30D1\u30C3\u30B1\u30FC\u30B8\u5185\u306E\u4F9D\u5B58\u6027\u3092\u30D5\u30A3\u30EB\u30BF\u3057\u307E\u3059(\u30C7\u30D5\u30A9\u30EB\u30C8)\n -filter:archive \u540C\u3058\u30A2\u30FC\u30AB\u30A4\u30D6\u5185\u306E\u4F9D\u5B58\u6027\u3092\u30D5\u30A3\u30EB\u30BF\u3057\u307E\u3059\n -filter:none -filter:package\u304A\u3088\u3073-filter:archive\u306E\u30D5\u30A3\u30EB\u30BF\u30EA\u30F3\u30B0\u306F\u884C\u308F\u308C\u307E\u305B\u3093\n -filter\u30AA\u30D7\u30B7\u30E7\u30F3\u3067\u6307\u5B9A\u3057\u305F\u30D5\u30A3\u30EB\u30BF\u30EA\u30F3\u30B0\u304C\u5F15\u304D\u7D9A\u304D\u9069\u7528\u3055\u308C\u307E\u3059\u3002 main.opt.s=\ -s -summary \u4F9D\u5B58\u6027\u306E\u30B5\u30DE\u30EA\u30FC\u306E\u307F\u51FA\u529B\u3057\u307E\u3059 -main.opt.p=\ -p <pkgname> -package <pkgname> \u6307\u5B9A\u306E\u30D1\u30C3\u30B1\u30FC\u30B8\u5185\u306E\u4F9D\u5B58\u6027\u3092\u691C\u51FA\u3057\u307E\u3059\n (\u8907\u6570\u56DE\u6307\u5B9A\u53EF\u80FD) +main.opt.p=\ -p <pkgname> -package <pkgname> \u6307\u5B9A\u306E\u30D1\u30C3\u30B1\u30FC\u30B8\u540D\u306B\u4E00\u81F4\u3059\u308B\u4F9D\u5B58\u6027\u3092\u691C\u51FA\u3057\u307E\u3059\n (\u8907\u6570\u56DE\u6307\u5B9A\u53EF\u80FD) -main.opt.e=\ -e <regex> -regex <regex> \u30D1\u30BF\u30FC\u30F3\u306B\u4E00\u81F4\u3059\u308B\u30D1\u30C3\u30B1\u30FC\u30B8\u5185\u306E\u4F9D\u5B58\u6027\u3092\u691C\u51FA\u3057\u307E\u3059\n (-p\u3068-e\u306F\u6392\u4ED6\u7684) +main.opt.e=\ -e <regex> -regex <regex> \u6307\u5B9A\u306E\u30D1\u30BF\u30FC\u30F3\u306B\u4E00\u81F4\u3059\u308B\u4F9D\u5B58\u6027\u3092\u691C\u51FA\u3057\u307E\u3059\n (-p\u3068-e\u306F\u6392\u4ED6\u7684) -main.opt.include=\ -include <regex> \u30D1\u30BF\u30FC\u30F3\u306B\u4E00\u81F4\u3059\u308B\u30AF\u30E9\u30B9\u306B\u5206\u6790\u3092\u5236\u9650\u3057\u307E\u3059\n \u3053\u306E\u30AA\u30D7\u30B7\u30E7\u30F3\u3092\u6307\u5B9A\u3059\u308B\u3068\u3001\u5206\u6790\u5BFE\u8C61\u30AF\u30E9\u30B9\u306E\n \u30EA\u30B9\u30C8\u304C\u30D5\u30A3\u30EB\u30BF\u51E6\u7406\u3055\u308C\u307E\u3059\u3002\u30D1\u30BF\u30FC\u30F3\u3092\u4F9D\u5B58\u6027\u306B\n \u9069\u7528\u3059\u308B-p\u304A\u3088\u3073-e\u3068\u4E00\u7DD2\u306B\u4F7F\u7528\u3067\u304D\u307E\u3059 +main.opt.include=\ -include <regex> \u30D1\u30BF\u30FC\u30F3\u306B\u4E00\u81F4\u3059\u308B\u30AF\u30E9\u30B9\u306B\u5206\u6790\u3092\u5236\u9650\u3057\u307E\u3059\n \u3053\u306E\u30AA\u30D7\u30B7\u30E7\u30F3\u3092\u6307\u5B9A\u3059\u308B\u3068\u3001\u5206\u6790\u5BFE\u8C61\u30AF\u30E9\u30B9\u306E\n \u30EA\u30B9\u30C8\u304C\u30D5\u30A3\u30EB\u30BF\u3055\u308C\u307E\u3059\u3002\u30D1\u30BF\u30FC\u30F3\u3092\u4F9D\u5B58\u6027\u306B\n \u9069\u7528\u3059\u308B-p\u304A\u3088\u3073-e\u3068\u4E00\u7DD2\u306B\u4F7F\u7528\u3067\u304D\u307E\u3059 main.opt.P=\ -P -profile \u30D7\u30ED\u30D5\u30A1\u30A4\u30EB\u3001\u307E\u305F\u306F\u30D1\u30C3\u30B1\u30FC\u30B8\u3092\u542B\u3080\u30D5\u30A1\u30A4\u30EB\u3092\u8868\u793A\u3057\u307E\u3059 main.opt.cp=\ -cp <path> -classpath <path> \u30AF\u30E9\u30B9\u30FB\u30D5\u30A1\u30A4\u30EB\u3092\u691C\u7D22\u3059\u308B\u5834\u6240\u3092\u6307\u5B9A\u3057\u307E\u3059 -main.opt.R=\ -R -recursive \u3059\u3079\u3066\u306E\u4F9D\u5B58\u6027\u3092\u53CD\u5FA9\u7684\u306B\u8D70\u67FB\u3057\u307E\u3059 +main.opt.R=\ -R -recursive \u3059\u3079\u3066\u306E\u4F9D\u5B58\u6027\u3092\u518D\u5E30\u7684\u306B\u30C8\u30E9\u30D0\u30FC\u30B9\u3057\u307E\u3059\u3002\n -R\u30AA\u30D7\u30B7\u30E7\u30F3\u306F-filter:none\u3092\u610F\u5473\u3057\u307E\u3059\u3002-p\u3001-e\u3001-f\n \u30AA\u30D7\u30B7\u30E7\u30F3\u304C\u6307\u5B9A\u3055\u308C\u3066\u3044\u308B\u5834\u5408\u3001\u4E00\u81F4\u3059\u308B\u4F9D\u5B58\u6027\u306E\u307F\n \u5206\u6790\u3055\u308C\u307E\u3059\u3002 main.opt.apionly=\ -apionly \u5206\u6790\u3092API\u3001\u3064\u307E\u308A\u3001\u30D1\u30D6\u30EA\u30C3\u30AF\u30FB\u30AF\u30E9\u30B9\u306E\n \u30D1\u30D6\u30EA\u30C3\u30AF\u30FB\u30E1\u30F3\u30D0\u30FC\u304A\u3088\u3073\u4FDD\u8B77\u3055\u308C\u305F\u30E1\u30F3\u30D0\u30FC\u306E\n \u7F72\u540D\u306B\u304A\u3051\u308B\u4F9D\u5B58\u6027(\u30D5\u30A3\u30FC\u30EB\u30C9\u30FB\u30BF\u30A4\u30D7\u3001\u30E1\u30BD\u30C3\u30C9\u30FB\n \u30D1\u30E9\u30E1\u30FC\u30BF\u30FB\u30BF\u30A4\u30D7\u3001\u623B\u3055\u308C\u305F\u30BF\u30A4\u30D7\u3001\u30C1\u30A7\u30C3\u30AF\u3055\u308C\u305F\n \u4F8B\u5916\u30BF\u30A4\u30D7\u306A\u3069)\u306B\u5236\u9650\u3057\u307E\u3059 @@ -36,13 +38,14 @@ main.opt.depth=\ -depth=<depth> \u63A8\u79FB\u7684\u306A\u4 err.unknown.option=\u4E0D\u660E\u306A\u30AA\u30D7\u30B7\u30E7\u30F3: {0} err.missing.arg={0}\u306B\u5024\u304C\u6307\u5B9A\u3055\u308C\u3066\u3044\u307E\u305B\u3093 -err.internal.error=\u5185\u90E8\u30A8\u30E9\u30FC: {0} {1} {2} err.invalid.arg.for.option=\u30AA\u30D7\u30B7\u30E7\u30F3\u306E\u5F15\u6570\u304C\u7121\u52B9\u3067\u3059: {0} err.option.after.class=\u30AA\u30D7\u30B7\u30E7\u30F3\u306F\u30AF\u30E9\u30B9\u306E\u524D\u306B\u6307\u5B9A\u3059\u308B\u5FC5\u8981\u304C\u3042\u308A\u307E\u3059: {0} err.option.unsupported={0}\u306F\u30B5\u30DD\u30FC\u30C8\u3055\u308C\u3066\u3044\u307E\u305B\u3093: {1} err.profiles.msg=\u30D7\u30ED\u30D5\u30A1\u30A4\u30EB\u60C5\u5831\u304C\u3042\u308A\u307E\u305B\u3093 -err.dot.output.path=\u7121\u52B9\u306A\u30D1\u30B9: {0} +err.invalid.path=\u7121\u52B9\u306A\u30D1\u30B9: {0} warn.invalid.arg=\u7121\u52B9\u306A\u30AF\u30E9\u30B9\u540D\u307E\u305F\u306F\u30D1\u30B9\u540D\u304C\u5B58\u5728\u3057\u307E\u305B\u3093: {0} warn.split.package=\u30D1\u30C3\u30B1\u30FC\u30B8{0}\u306F{1} {2}\u3067\u5B9A\u7FA9\u3055\u308C\u3066\u3044\u307E\u3059 +warn.replace.useJDKInternals=JDK\u5185\u90E8API\u306F\u30B5\u30DD\u30FC\u30C8\u3055\u308C\u3066\u304A\u3089\u305A\u3001JDK\u5B9F\u88C5\u5C02\u7528\u3067\u3059\u304C\u3001\u4E92\u63DB\u6027\u306A\u3057\u3067\n\u524A\u9664\u307E\u305F\u306F\u5909\u66F4\u3055\u308C\u308B\u5834\u5408\u304C\u3042\u308A\u3001\u30A2\u30D7\u30EA\u30B1\u30FC\u30B7\u30E7\u30F3\u3092\u4E2D\u65AD\u3055\u305B\u308B\u53EF\u80FD\u6027\u304C\u3042\u308A\u307E\u3059\u3002\nJDK\u5185\u90E8API\u306E\u4F9D\u5B58\u6027\u3092\u524A\u9664\u3059\u308B\u3088\u3046\u30B3\u30FC\u30C9\u3092\u5909\u66F4\u3057\u3066\u304F\u3060\u3055\u3044\u3002\nJDK\u5185\u90E8API\u306E\u7F6E\u63DB\u306B\u95A2\u3059\u308B\u6700\u65B0\u306E\u66F4\u65B0\u306B\u3064\u3044\u3066\u306F\u3001\u6B21\u3092\u78BA\u8A8D\u3057\u3066\u304F\u3060\u3055\u3044:\n{0} artifact.not.found=\u898B\u3064\u304B\u308A\u307E\u305B\u3093 +jdeps.wiki.url=https://wiki.openjdk.java.net/display/JDK8/Java+Dependency+Analysis+Tool diff --git a/src/share/classes/com/sun/tools/jdeps/resources/jdeps_zh_CN.properties b/src/share/classes/com/sun/tools/jdeps/resources/jdeps_zh_CN.properties index 6b3942aa..c51ae8a9 100644 --- a/src/share/classes/com/sun/tools/jdeps/resources/jdeps_zh_CN.properties +++ b/src/share/classes/com/sun/tools/jdeps/resources/jdeps_zh_CN.properties @@ -1,4 +1,4 @@ -main.usage.summary=\u7528\u6CD5: {0} <options> <classes...>\n\u4F7F\u7528 -h, -? \u6216 --help \u5217\u51FA\u53EF\u80FD\u7684\u9009\u9879 +main.usage.summary=\u7528\u6CD5: {0} <options> <classes...>\n\u4F7F\u7528 -h, -? \u6216 -help \u5217\u51FA\u53EF\u80FD\u7684\u9009\u9879 main.usage=\u7528\u6CD5: {0} <options> <classes...>\n\u5176\u4E2D <classes> \u53EF\u4EE5\u662F .class \u6587\u4EF6, \u76EE\u5F55, JAR \u6587\u4EF6\u7684\u8DEF\u5F84\u540D,\n\u4E5F\u53EF\u4EE5\u662F\u5168\u9650\u5B9A\u7C7B\u540D\u3002\u53EF\u80FD\u7684\u9009\u9879\u5305\u62EC: @@ -9,13 +9,15 @@ main.opt.h=\ -h -? -help \u8F93\u51FA\u6B64\u7528\u6CD5\ main.opt.version=\ -version \u7248\u672C\u4FE1\u606F -main.opt.v=\ -v -verbose \u8F93\u51FA\u6240\u6709\u7C7B\u7EA7\u522B\u88AB\u4F9D\u8D56\u5BF9\u8C61\n -verbose:package \u8F93\u51FA\u7A0B\u5E8F\u5305\u7EA7\u522B\u88AB\u4F9D\u8D56\u5BF9\u8C61, \u4E0D\u5305\u62EC\n \u540C\u4E00\u6863\u6848\u4E2D\u7684\u88AB\u4F9D\u8D56\u5BF9\u8C61\n -verbose:class \u8F93\u51FA\u7C7B\u7EA7\u522B\u88AB\u4F9D\u8D56\u5BF9\u8C61, \u4E0D\u5305\u62EC\n \u540C\u4E00\u6863\u6848\u4E2D\u7684\u88AB\u4F9D\u8D56\u5BF9\u8C61 +main.opt.v=\ -v -verbose \u8F93\u51FA\u6240\u6709\u7C7B\u7EA7\u522B\u88AB\u4F9D\u8D56\u5BF9\u8C61\n \u7B49\u540C\u4E8E -verbose:class -filter:none\u3002\n -verbose:package \u9ED8\u8BA4\u60C5\u51B5\u4E0B\u8F93\u51FA\u7A0B\u5E8F\u5305\u7EA7\u522B\u88AB\u4F9D\u8D56\u5BF9\u8C61, \n \u4E0D\u5305\u62EC\u540C\u4E00\u7A0B\u5E8F\u5305\u4E2D\u7684\u88AB\u4F9D\u8D56\u5BF9\u8C61\n -verbose:class \u9ED8\u8BA4\u60C5\u51B5\u4E0B\u8F93\u51FA\u7C7B\u7EA7\u522B\u88AB\u4F9D\u8D56\u5BF9\u8C61, \n \u4E0D\u5305\u62EC\u540C\u4E00\u7A0B\u5E8F\u5305\u4E2D\u7684\u88AB\u4F9D\u8D56\u5BF9\u8C61 + +main.opt.f=\ -f <regex> -filter <regex> \u7B5B\u9009\u4E0E\u6307\u5B9A\u6A21\u5F0F\u5339\u914D\u7684\u88AB\u4F9D\u8D56\u5BF9\u8C61\n \u5982\u679C\u591A\u6B21\u6307\u5B9A, \u5219\u5C06\u4F7F\u7528\u6700\u540E\u4E00\u4E2A\u88AB\u4F9D\u8D56\u5BF9\u8C61\u3002\n -filter:package \u7B5B\u9009\u4F4D\u4E8E\u540C\u4E00\u7A0B\u5E8F\u5305\u5185\u7684\u88AB\u4F9D\u8D56\u5BF9\u8C61 (\u9ED8\u8BA4)\n -filter:archive \u7B5B\u9009\u4F4D\u4E8E\u540C\u4E00\u6863\u6848\u5185\u7684\u88AB\u4F9D\u8D56\u5BF9\u8C61\n -filter:none \u4E0D\u4F7F\u7528 -filter:package \u548C -filter:archive \u7B5B\u9009\n \u901A\u8FC7 -filter \u9009\u9879\u6307\u5B9A\u7684\u7B5B\u9009\u4ECD\u65E7\u9002\u7528\u3002 main.opt.s=\ -s -summary \u4EC5\u8F93\u51FA\u88AB\u4F9D\u8D56\u5BF9\u8C61\u6982\u8981 -main.opt.p=\ -p <pkgname> -package <pkgname> \u67E5\u627E\u7ED9\u5B9A\u7A0B\u5E8F\u5305\u4E2D\u7684\u88AB\u4F9D\u8D56\u5BF9\u8C61\n (\u53EF\u80FD\u591A\u6B21\u6307\u5B9A) +main.opt.p=\ -p <pkgname> -package <pkgname> \u67E5\u627E\u4E0E\u7ED9\u5B9A\u7A0B\u5E8F\u5305\u540D\u79F0\u5339\u914D\u7684\u88AB\u4F9D\u8D56\u5BF9\u8C61\n (\u53EF\u591A\u6B21\u6307\u5B9A) -main.opt.e=\ -e <regex> -regex <regex> \u67E5\u627E\u4E0E\u6A21\u5F0F\u5339\u914D\u7684\u7A0B\u5E8F\u5305\u4E2D\u7684\u88AB\u4F9D\u8D56\u5BF9\u8C61\n (-p \u548C -e \u4E92\u76F8\u6392\u65A5) +main.opt.e=\ -e <regex> -regex <regex> \u67E5\u627E\u4E0E\u6307\u5B9A\u6A21\u5F0F\u5339\u914D\u7684\u88AB\u4F9D\u8D56\u5BF9\u8C61\n (-p \u548C -e \u4E92\u76F8\u6392\u65A5) main.opt.include=\ -include <regex> \u5C06\u5206\u6790\u9650\u5236\u4E3A\u4E0E\u6A21\u5F0F\u5339\u914D\u7684\u7C7B\n \u6B64\u9009\u9879\u7B5B\u9009\u8981\u5206\u6790\u7684\u7C7B\u7684\u5217\u8868\u3002\n \u5B83\u53EF\u4EE5\u4E0E\u5411\u88AB\u4F9D\u8D56\u5BF9\u8C61\u5E94\u7528\u6A21\u5F0F\u7684\n -p \u548C -e \u7ED3\u5408\u4F7F\u7528 @@ -23,7 +25,7 @@ main.opt.P=\ -P -profile \u663E\u793A\u914D\u7F6E\u6587\ main.opt.cp=\ -cp <path> -classpath <path> \u6307\u5B9A\u67E5\u627E\u7C7B\u6587\u4EF6\u7684\u4F4D\u7F6E -main.opt.R=\ -R -recursive \u9012\u5F52\u904D\u5386\u6240\u6709\u88AB\u4F9D\u8D56\u5BF9\u8C61 +main.opt.R=\ -R -recursive \u9012\u5F52\u904D\u5386\u6240\u6709\u88AB\u4F9D\u8D56\u5BF9\u8C61\u3002\n -R \u9009\u9879\u8868\u793A -filter:none\u3002\u5982\u679C\u6307\u5B9A\u4E86 -p, -e, -f\n \u9009\u9879, \u5219\u53EA\u5206\u6790\u5339\u914D\u7684\n \u88AB\u4F9D\u8D56\u5BF9\u8C61\u3002 main.opt.apionly=\ -apionly \u901A\u8FC7\u516C\u5171\u7C7B (\u5305\u62EC\u5B57\u6BB5\u7C7B\u578B, \u65B9\u6CD5\u53C2\u6570\n \u7C7B\u578B, \u8FD4\u56DE\u7C7B\u578B, \u53D7\u63A7\u5F02\u5E38\u9519\u8BEF\u7C7B\u578B\n \u7B49) \u7684\u516C\u5171\u548C\u53D7\u4FDD\u62A4\u6210\u5458\u7684\u7B7E\u540D\n \u9650\u5236\u5BF9 API (\u5373\u88AB\u4F9D\u8D56\u5BF9\u8C61)\n \u8FDB\u884C\u5206\u6790 @@ -36,13 +38,14 @@ main.opt.depth=\ -depth=<depth> \u6307\u5B9A\u8FC7\u6E21\u8 err.unknown.option=\u672A\u77E5\u9009\u9879: {0} err.missing.arg=\u6CA1\u6709\u4E3A{0}\u6307\u5B9A\u503C -err.internal.error=\u5185\u90E8\u9519\u8BEF: {0} {1} {2} err.invalid.arg.for.option=\u9009\u9879\u7684\u53C2\u6570\u65E0\u6548: {0} err.option.after.class=\u5FC5\u987B\u5728\u7C7B\u4E4B\u524D\u6307\u5B9A\u9009\u9879: {0} err.option.unsupported=\u4E0D\u652F\u6301{0}: {1} err.profiles.msg=\u6CA1\u6709\u914D\u7F6E\u6587\u4EF6\u4FE1\u606F -err.dot.output.path=\u65E0\u6548\u8DEF\u5F84: {0} +err.invalid.path=\u65E0\u6548\u8DEF\u5F84: {0} warn.invalid.arg=\u7C7B\u540D\u65E0\u6548\u6216\u8DEF\u5F84\u540D\u4E0D\u5B58\u5728: {0} warn.split.package=\u5DF2\u5728{1} {2}\u4E2D\u5B9A\u4E49\u7A0B\u5E8F\u5305{0} +warn.replace.useJDKInternals=\u4E0D\u652F\u6301 JDK \u5185\u90E8 API, \u5B83\u4EEC\u4E13\u7528\u4E8E\u901A\u8FC7\u4E0D\u517C\u5BB9\u65B9\u5F0F\u6765\u5220\u9664\n\u6216\u66F4\u6539\u7684 JDK \u5B9E\u73B0, \u53EF\u80FD\u4F1A\u635F\u574F\u60A8\u7684\u5E94\u7528\u7A0B\u5E8F\u3002\n\u8BF7\u4FEE\u6539\u60A8\u7684\u4EE3\u7801, \u6D88\u9664\u4E0E\u4EFB\u4F55 JDK \u5185\u90E8 API \u7684\u76F8\u5173\u6027\u3002\n\u6709\u5173 JDK \u5185\u90E8 API \u66FF\u6362\u7684\u6700\u65B0\u66F4\u65B0, \u8BF7\u67E5\u770B:\n{0} artifact.not.found=\u627E\u4E0D\u5230 +jdeps.wiki.url=https://wiki.openjdk.java.net/display/JDK8/Java+Dependency+Analysis+Tool diff --git a/test/com/sun/javadoc/testDocRootLink/TestDocRootLink.java b/test/com/sun/javadoc/testDocRootLink/TestDocRootLink.java index 0fa0f590..607f87f7 100644 --- a/test/com/sun/javadoc/testDocRootLink/TestDocRootLink.java +++ b/test/com/sun/javadoc/testDocRootLink/TestDocRootLink.java @@ -60,21 +60,21 @@ public class TestDocRootLink extends JavadocTester { }; private static final String[][] NEGATED_TEST1 = { {BUG_ID + FS + "pkg1" + FS + "C1.html", - "<a href=\"http://download.oracle.com/javase/7/docs/technotes/guides/index.html\">" + "<a href=\"https://docs.oracle.com/javase/7/docs/technotes/guides/index.html\">" }, {BUG_ID + FS + "pkg1" + FS + "C1.html", - "<a href=\"http://download.oracle.com/javase/7/docs/pkg2/C2.html\">" + "<a href=\"https://docs.oracle.com/javase/7/docs/pkg2/C2.html\">" }, {BUG_ID + FS + "pkg1" + FS + "package-summary.html", - "<a href=\"http://download.oracle.com/javase/7/docs/technotes/guides/index.html\">" + "<a href=\"https://docs.oracle.com/javase/7/docs/technotes/guides/index.html\">" }, {BUG_ID + FS + "pkg1" + FS + "package-summary.html", - "<a href=\"http://download.oracle.com/javase/7/docs/pkg2/C2.html\">" + "<a href=\"https://docs.oracle.com/javase/7/docs/pkg2/C2.html\">" } }; private static final String[][] TEST2 = { {BUG_ID + "-1" + FS + "pkg2" + FS + "C2.html", - "Refer <a href=\"http://download.oracle.com/javase/7/docs/technotes/guides/index.html\">Here</a>" + "Refer <a href=\"https://docs.oracle.com/javase/7/docs/technotes/guides/index.html\">Here</a>" }, {BUG_ID + "-1" + FS + "pkg2" + FS + "C2.html", "This <a href=\"../pkg1/C1.html\">Here</a> should not be replaced" + NL + @@ -85,7 +85,7 @@ public class TestDocRootLink extends JavadocTester { " <a href=\"../pkg1/C1.html\">Link 2</a>." }, {BUG_ID + "-1" + FS + "pkg2" + FS + "package-summary.html", - "<a href=\"http://download.oracle.com/javase/7/docs/technotes/guides/index.html\">" + NL + + "<a href=\"https://docs.oracle.com/javase/7/docs/technotes/guides/index.html\">" + NL + " Test document 1</a>" }, {BUG_ID + "-1" + FS + "pkg2" + FS + "package-summary.html", @@ -100,13 +100,13 @@ public class TestDocRootLink extends JavadocTester { "<a href=\"../../technotes/guides/index.html\">" }, {BUG_ID + "-1" + FS + "pkg2" + FS + "C2.html", - "<a href=\"http://download.oracle.com/javase/7/docs/pkg1/C1.html\">" + "<a href=\"https://docs.oracle.com/javase/7/docs/pkg1/C1.html\">" }, {BUG_ID + "-1" + FS + "pkg2" + FS + "package-summary.html", "<a href=\"../../technotes/guides/index.html\">" }, {BUG_ID + "-1" + FS + "pkg2" + FS + "package-summary.html", - "<a href=\"http://download.oracle.com/javase/7/docs/pkg1/C1.html\">" + "<a href=\"https://docs.oracle.com/javase/7/docs/pkg1/C1.html\">" } }; private static final String[] ARGS1 = @@ -115,7 +115,7 @@ public class TestDocRootLink extends JavadocTester { }; private static final String[] ARGS2 = new String[]{ - "-d", BUG_ID + "-1", "-Xdocrootparent", "http://download.oracle.com/javase/7/docs", "-sourcepath", SRC_DIR, "pkg1", "pkg2" + "-d", BUG_ID + "-1", "-Xdocrootparent", "https://docs.oracle.com/javase/7/docs", "-sourcepath", SRC_DIR, "pkg1", "pkg2" }; /** diff --git a/test/tools/javac/8062359/UnresolvableClassNPEInAttrTest.java b/test/tools/javac/8062359/UnresolvableClassNPEInAttrTest.java new file mode 100644 index 00000000..0880fde6 --- /dev/null +++ b/test/tools/javac/8062359/UnresolvableClassNPEInAttrTest.java @@ -0,0 +1,17 @@ +/* + * @test /nodynamiccopyright/ + * @bug 8062359 + * @summary NullPointerException in Attr when type-annotating an anonymous + * inner class in an unresolvable class + * @compile/fail/ref=UnresolvableClassNPEInAttrTest.out -XDrawDiagnostics UnresolvableClassNPEInAttrTest.java + */ + +public class UnresolvableClassNPEInAttrTest { + public static void main(String[] args) { + new Undefined() { + void test() { + new Object() {}; + } + }; + } +} diff --git a/test/tools/javac/8062359/UnresolvableClassNPEInAttrTest.out b/test/tools/javac/8062359/UnresolvableClassNPEInAttrTest.out new file mode 100644 index 00000000..efb2a277 --- /dev/null +++ b/test/tools/javac/8062359/UnresolvableClassNPEInAttrTest.out @@ -0,0 +1,2 @@ +UnresolvableClassNPEInAttrTest.java:11:13: compiler.err.cant.resolve.location: kindname.class, Undefined, , , (compiler.misc.location: kindname.class, UnresolvableClassNPEInAttrTest, null) +1 error diff --git a/test/tools/javac/T8019486/WrongLNTForLambdaTest.java b/test/tools/javac/T8019486/WrongLNTForLambdaTest.java index d3728e15..3074de42 100644 --- a/test/tools/javac/T8019486/WrongLNTForLambdaTest.java +++ b/test/tools/javac/T8019486/WrongLNTForLambdaTest.java @@ -138,7 +138,7 @@ public class WrongLNTForLambdaTest { checkClassFile(new File(Paths.get(System.getProperty("user.dir"), "Foo.class").toUri()), "$deserializeLambda$", deserializeExpectedLNT); checkClassFile(new File(Paths.get(System.getProperty("user.dir"), - "Foo.class").toUri()), "lambda$MR$variablesInLambdas$notify$8bc4f5bd$1", lambdaBridgeExpectedLNT); + "Foo.class").toUri()), "lambda$variablesInLambdas$3", lambdaBridgeExpectedLNT); checkClassFile(new File(Paths.get(System.getProperty("user.dir"), "Foo.class").toUri()), "assignLambda", assignmentExpectedLNT); checkClassFile(new File(Paths.get(System.getProperty("user.dir"), diff --git a/test/tools/javac/T8049305/WrongStackframeGenerationTest1.java b/test/tools/javac/T8049305/WrongStackframeGenerationTest1.java new file mode 100644 index 00000000..d3fbecc7 --- /dev/null +++ b/test/tools/javac/T8049305/WrongStackframeGenerationTest1.java @@ -0,0 +1,47 @@ +/* + * 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 8049305 + * @summary Verification error due to a bad stackmap frame generated by javac + */ + +public class WrongStackframeGenerationTest1 { + public static void main(String[] args) {} + + static void foo(){ + while (true) { + int i = 0; + break; + } + switch (1) { + case 1: + int j = 0; + case 2: + bar(); + } + } + + static void bar() {} +} diff --git a/test/tools/javac/T8049305/WrongStackframeGenerationTest2.java b/test/tools/javac/T8049305/WrongStackframeGenerationTest2.java new file mode 100644 index 00000000..5612217e --- /dev/null +++ b/test/tools/javac/T8049305/WrongStackframeGenerationTest2.java @@ -0,0 +1,50 @@ +/* + * 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 8049305 + * @summary Verification error due to a bad stackmap frame generated by javac + */ + +public class WrongStackframeGenerationTest2 { + public static void main(String[] args) {} + + static void foo() { + int len; + for (;;) { + try { + len = 1; + break; + } catch (Exception e) { + } + } + + try { + if (len == -1) { + len = 0; + } + } finally { + } + } +} diff --git a/test/tools/javac/T8059921/ForbidAccessToFieldUsingSuperTest.java b/test/tools/javac/T8059921/ForbidAccessToFieldUsingSuperTest.java new file mode 100644 index 00000000..5bd3171a --- /dev/null +++ b/test/tools/javac/T8059921/ForbidAccessToFieldUsingSuperTest.java @@ -0,0 +1,31 @@ +/* + * @test /nodynamiccopyright/ + * @bug 8059921 + * @summary Missing compile error in Java 8 mode for Interface.super.field access + * @compile/fail/ref=ForbidAccessToFieldUsingSuperTest.out -XDrawDiagnostics ForbidAccessToFieldUsingSuperTest.java + */ + +public class ForbidAccessToFieldUsingSuperTest { + class C { + int m() { return 0; } + } + + interface T { + int f = 0; + C c = null; + default int mm() { + return 0; + } + } + + interface T1 extends T {} + + class X implements T1 { + int i = T1.super.f; //fail + int j = T1.super.c.m(); //fail + + void foo(Runnable r) { + foo(T1.super::mm); //should'n fail + } + } +} diff --git a/test/tools/javac/T8059921/ForbidAccessToFieldUsingSuperTest.out b/test/tools/javac/T8059921/ForbidAccessToFieldUsingSuperTest.out new file mode 100644 index 00000000..b4424f97 --- /dev/null +++ b/test/tools/javac/T8059921/ForbidAccessToFieldUsingSuperTest.out @@ -0,0 +1,3 @@ +ForbidAccessToFieldUsingSuperTest.java:24:19: compiler.err.not.encl.class: ForbidAccessToFieldUsingSuperTest.T1 +ForbidAccessToFieldUsingSuperTest.java:25:19: compiler.err.not.encl.class: ForbidAccessToFieldUsingSuperTest.T1 +2 errors diff --git a/test/tools/javac/annotations/FinalStringInNested.java b/test/tools/javac/annotations/FinalStringInNested.java new file mode 100644 index 00000000..f8cf4b4e --- /dev/null +++ b/test/tools/javac/annotations/FinalStringInNested.java @@ -0,0 +1,46 @@ +/* + * 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 8054448 + * @summary Verify that constant strings in nested classes in anonymous classes + * can be used in annotations. + * @compile FinalStringInNested.java + */ + +public class FinalStringInNested { + + public void f() { + Object o = new Object() { + @FinalStringInNested.Annotation(Nested.ID) + class Nested { + static final String ID = "B"; + } + }; + } + + @interface Annotation { + String value(); + } +} diff --git a/test/tools/javac/flow/LVTHarness.java b/test/tools/javac/flow/LVTHarness.java index c176e5e8..33ab0441 100644 --- a/test/tools/javac/flow/LVTHarness.java +++ b/test/tools/javac/flow/LVTHarness.java @@ -23,7 +23,7 @@ /* * @test - * @bug 7047734 8027660 8037937 8047719 + * @bug 7047734 8027660 8037937 8047719 8058708 * @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 diff --git a/test/tools/javac/flow/T8042741/LambdaArgumentsTest.java b/test/tools/javac/flow/T8042741/LambdaArgumentsTest.java new file mode 100644 index 00000000..b63a02e8 --- /dev/null +++ b/test/tools/javac/flow/T8042741/LambdaArgumentsTest.java @@ -0,0 +1,44 @@ +/* + * 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 8054210 + * @summary NullPointerException when compiling specific code + * @compile LambdaArgumentsTest.java + */ + +public class LambdaArgumentsTest { + interface Thrower<E extends Exception> { void apply() throws E; } + interface Consumer<E> { void take(E arg); } + + <E extends Exception> + void m1(Thrower<E> a1, Consumer<E> a2) {} + + <E extends Exception> + void m2(Thrower<E> a1, Consumer<RuntimeException> a2) {} + + void test() { + m1(() -> {}, e -> {}); + m2(() -> {}, (RuntimeException e) -> {}); + } +} diff --git a/test/tools/javac/flow/T8062747.java b/test/tools/javac/flow/T8062747.java new file mode 100644 index 00000000..85747421 --- /dev/null +++ b/test/tools/javac/flow/T8062747.java @@ -0,0 +1,24 @@ +/** + * @test + * @bug 8062747 + * @summary Avoiding an error for lambdas with thrown types inference inside an anonymous class. + * @compile T8062747.java + */ +public class T8062747 { + + public interface Throwing<Y extends Exception> { + void canThrow() throws Y; + } + + public static <Y extends Exception> void wrap(Throwing<Y> action) { + } + + public static void invoke(String a) { + Runnable r = new Runnable() { + @Override + public void run() { + wrap(() -> System.out.println(a)); + } + }; + } +} diff --git a/test/tools/javac/flow/tests/TestCaseIf.java b/test/tools/javac/flow/tests/TestCaseIf.java index 9869443f..fa0a0a64 100644 --- a/test/tools/javac/flow/tests/TestCaseIf.java +++ b/test/tools/javac/flow/tests/TestCaseIf.java @@ -58,4 +58,18 @@ public class TestCaseIf { } o = ""; } + + @AliveRange(varName="finalLocal", bytecodeStart=11, bytecodeLength=6) + @AliveRange(varName="used", bytecodeStart=13, bytecodeLength=4) + void m5(Object o) { + if (o != null) { + Object notUsed; + Object used; + if (o != null) { + final Object finalLocal = null; + used = null; + if (o == null) {} + } + } + } } diff --git a/test/tools/javac/generics/inference/8058511/T8058511a.java b/test/tools/javac/generics/inference/8058511/T8058511a.java new file mode 100644 index 00000000..6c1ffeb8 --- /dev/null +++ b/test/tools/javac/generics/inference/8058511/T8058511a.java @@ -0,0 +1,38 @@ +/* + * 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 8058511 + * @summary StackOverflowError at com.sun.tools.javac.code.Types.lub + * @compile T8058511a.java + */ +class T8058511a { + <Z> void choose(Z z1, Z z2) { } + + void test(Class<Double> cd, Class<? extends double[]> cdarr) { + choose(cd, cdarr); + } +} diff --git a/test/tools/javac/generics/inference/8058511/T8058511b.java b/test/tools/javac/generics/inference/8058511/T8058511b.java new file mode 100644 index 00000000..0dd5aef4 --- /dev/null +++ b/test/tools/javac/generics/inference/8058511/T8058511b.java @@ -0,0 +1,36 @@ +/* + * 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 8058511 + * @summary StackOverflowError at com.sun.tools.javac.code.Types.lub + * @compile T8058511b.java + */ +class T8058511b { + void test(Class<Double> cd, Class<? extends double[]> cdarr) { + ((false) ? cd : cdarr).toString(); + } +} diff --git a/test/tools/javac/generics/inference/8058511/T8058511c.java b/test/tools/javac/generics/inference/8058511/T8058511c.java new file mode 100644 index 00000000..c2ed03e0 --- /dev/null +++ b/test/tools/javac/generics/inference/8058511/T8058511c.java @@ -0,0 +1,38 @@ +/* + * 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 8058511 + * @summary StackOverflowError at com.sun.tools.javac.code.Types.lub + * @compile T8058511c.java + */ +import java.util.List; + +class T8058511c { + void test(List<? extends double[]> l) { + (true ? l.get(0) : l.get(0)).toString(); + } +} diff --git a/test/tools/javac/lambda/8051958/T8051958.java b/test/tools/javac/lambda/8051958/T8051958.java new file mode 100644 index 00000000..94fd9fd9 --- /dev/null +++ b/test/tools/javac/lambda/8051958/T8051958.java @@ -0,0 +1,71 @@ +/* + * 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 8051958 + * @summary Cannot assign a value to final variable in lambda + * @compile T8051958.java + */ + +class T8051958 { + Runnable inst_r = ()-> { + final int x; + x = 1; + }; + + Runnable static_r = ()-> { + final int x; + x = 1; + }; + + { + Runnable inst_r = ()-> { + final int x; + x = 1; + }; + } + + static { + Runnable static_r = ()-> { + final int x; + x = 1; + }; + } + + void instTest() { + Runnable static_r = ()-> { + final int x; + x = 1; + }; + } + + static void staticTest() { + Runnable static_r = ()-> { + final int x; + x = 1; + }; + } +} diff --git a/test/tools/javac/lambda/MethodReferenceArrayClone.java b/test/tools/javac/lambda/MethodReferenceArrayClone.java new file mode 100644 index 00000000..0d1c03bd --- /dev/null +++ b/test/tools/javac/lambda/MethodReferenceArrayClone.java @@ -0,0 +1,67 @@ +/* + * 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 8056051 + * @summary int[]::clone causes "java.lang.NoClassDefFoundError: Array" + * @run main MethodReferenceArrayClone + */ + +import java.util.Arrays; +import java.util.function.Function; +import java.util.function.Supplier; + +public class MethodReferenceArrayClone { + public static void main(String[] args) { + int[] intArgs = new int[] {1, 2, 3, 4, 5}; + checkInt("int[]::clone", int[]::clone, intArgs); + checkInt("a -> a.clone()", a -> a.clone(), intArgs); + checkInt("intArgs::clone", intArgs::clone, intArgs); + + String[] stringArgs = new String[] {"hi", "de", "ho"}; + checkString("String[]::clone", String[]::clone, stringArgs); + checkString("a -> a.clone()", a -> a.clone(), stringArgs); + checkString("args::clone", stringArgs::clone, stringArgs); + } + + private static void checkInt(String label, Supplier<int[]> s, int[] expected) { + if (!Arrays.equals(s.get(), expected)) { + throw new RuntimeException("Unexpected value " + label + ": " + Arrays.toString(s.get())); + } + } + + private static void checkInt(String label, Function<int[], int[]> f, int[] a) { + checkInt(label, () -> f.apply(a), a); + } + + private static void checkString(String label, Supplier<String[]> s, String[] expected) { + if (!Arrays.equals(s.get(), expected)) { + throw new RuntimeException("Unexpected value " + label + ": " + Arrays.toString(s.get())); + } + } + + private static void checkString(String label, Function<String[], String[]> f, String[] a) { + checkString(label, () -> f.apply(a), a); + } +} diff --git a/test/tools/javac/lambda/T8033483/IgnoreLambdaBodyDuringResolutionTest1.java b/test/tools/javac/lambda/T8033483/IgnoreLambdaBodyDuringResolutionTest1.java new file mode 100644 index 00000000..77e6d856 --- /dev/null +++ b/test/tools/javac/lambda/T8033483/IgnoreLambdaBodyDuringResolutionTest1.java @@ -0,0 +1,31 @@ +/* + * @test /nodynamiccopyright/ + * @bug 8033483 + * @summary Should ignore nested lambda bodies during overload resolution + * @compile/fail/ref=IgnoreLambdaBodyDuringResolutionTest1.out -XDrawDiagnostics IgnoreLambdaBodyDuringResolutionTest1.java + */ + +class IgnoreLambdaBodyDuringResolutionTest1 { + interface SAM<T> { + T action(T t); + } + + <T> T m(SAM<T> op) { + return null; + } + + class B { + B x() { + return this; + } + } + + class C {} + + void foo(B arg) {} + void foo(C arg) {} + + void bar() { + foo(m(arg -> new B())); + } +} diff --git a/test/tools/javac/lambda/T8033483/IgnoreLambdaBodyDuringResolutionTest1.out b/test/tools/javac/lambda/T8033483/IgnoreLambdaBodyDuringResolutionTest1.out new file mode 100644 index 00000000..4bd68f59 --- /dev/null +++ b/test/tools/javac/lambda/T8033483/IgnoreLambdaBodyDuringResolutionTest1.out @@ -0,0 +1,2 @@ +IgnoreLambdaBodyDuringResolutionTest1.java:29:9: compiler.err.ref.ambiguous: foo, kindname.method, foo(IgnoreLambdaBodyDuringResolutionTest1.B), IgnoreLambdaBodyDuringResolutionTest1, kindname.method, foo(IgnoreLambdaBodyDuringResolutionTest1.C), IgnoreLambdaBodyDuringResolutionTest1 +1 error diff --git a/test/tools/javac/lambda/T8033483/IgnoreLambdaBodyDuringResolutionTest2.java b/test/tools/javac/lambda/T8033483/IgnoreLambdaBodyDuringResolutionTest2.java new file mode 100644 index 00000000..aee1bcdd --- /dev/null +++ b/test/tools/javac/lambda/T8033483/IgnoreLambdaBodyDuringResolutionTest2.java @@ -0,0 +1,34 @@ +/* + * @test /nodynamiccopyright/ + * @bug 8033483 + * @summary Should ignore nested lambda bodies during overload resolution + * @compile/fail/ref=IgnoreLambdaBodyDuringResolutionTest2.out -XDrawDiagnostics IgnoreLambdaBodyDuringResolutionTest2.java + */ + +class IgnoreLambdaBodyDuringResolutionTest2 { + interface SAM<S> { + boolean test(S t); + } + + <I, T extends I> I bar(final T l) { + return null; + } + + class D<D1, D2> { + void foo() { + m(bar(e -> false)); + } + + void m(Class<D1> arg) {} + void m(SAM<D2> arg) {} + } + + class F { + void foo() { + m(bar((String e) -> false)); + } + + <F1> void m(Class<F1> arg) {} + <F2> void m(SAM<F2> arg) {} + } +} diff --git a/test/tools/javac/lambda/T8033483/IgnoreLambdaBodyDuringResolutionTest2.out b/test/tools/javac/lambda/T8033483/IgnoreLambdaBodyDuringResolutionTest2.out new file mode 100644 index 00000000..5c294d0a --- /dev/null +++ b/test/tools/javac/lambda/T8033483/IgnoreLambdaBodyDuringResolutionTest2.out @@ -0,0 +1,6 @@ +IgnoreLambdaBodyDuringResolutionTest2.java:19:13: compiler.err.ref.ambiguous: m, kindname.method, m(java.lang.Class<D1>), IgnoreLambdaBodyDuringResolutionTest2.D, kindname.method, m(IgnoreLambdaBodyDuringResolutionTest2.SAM<D2>), IgnoreLambdaBodyDuringResolutionTest2.D +IgnoreLambdaBodyDuringResolutionTest2.java:19:18: compiler.err.prob.found.req: (compiler.misc.infer.no.conforming.assignment.exists: I,T, (compiler.misc.not.a.functional.intf: java.lang.Object)) +IgnoreLambdaBodyDuringResolutionTest2.java:19:14: compiler.err.cant.apply.symbol: kindname.method, m, java.lang.Class<D1>, <any>, kindname.class, IgnoreLambdaBodyDuringResolutionTest2.D<D1,D2>, (compiler.misc.no.conforming.assignment.exists: (compiler.misc.infer.no.conforming.assignment.exists: I,T, (compiler.misc.not.a.functional.intf: java.lang.Class))) +IgnoreLambdaBodyDuringResolutionTest2.java:28:13: compiler.err.ref.ambiguous: m, kindname.method, <F1>m(java.lang.Class<F1>), IgnoreLambdaBodyDuringResolutionTest2.F, kindname.method, <F2>m(IgnoreLambdaBodyDuringResolutionTest2.SAM<F2>), IgnoreLambdaBodyDuringResolutionTest2.F +IgnoreLambdaBodyDuringResolutionTest2.java:28:14: compiler.err.prob.found.req: (compiler.misc.infer.no.conforming.assignment.exists: I,T, (compiler.misc.not.a.functional.intf: java.lang.Class)) +5 errors diff --git a/test/tools/javac/lambda/T8056014.java b/test/tools/javac/lambda/T8056014.java new file mode 100644 index 00000000..41608437 --- /dev/null +++ b/test/tools/javac/lambda/T8056014.java @@ -0,0 +1,70 @@ +/* + * 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 8056014 + * @summary Verify that full type inference is used when calling a method on a type variable. + * @compile T8056014.java + * @run main T8056014 + */ + +import java.util.*; + +public class T8056014 { + public static void main(String[] args) { + new T8056014().run(); + } + + void run() { + List<S> l = Arrays.asList(new S()); + C<S> c = new C<>(new S()); + foo(l.get(0).copy(1)); + foo(c.get(0).copy(1)); + } + + void foo(S d) { + } +} + +class B { + public B copy(long j) { + throw new AssertionError("Should not get here."); + } +} + +class S extends B { + public <T> T copy(int i) { + return null; + } +} + +class C<T extends B> { + final T t; + public C(T t) { + this.t = t; + } + public T get(int i) { + return t; + } +} diff --git a/test/tools/javac/lambda/T8056984.java b/test/tools/javac/lambda/T8056984.java new file mode 100644 index 00000000..595bb657 --- /dev/null +++ b/test/tools/javac/lambda/T8056984.java @@ -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. + * + * 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 8056984 + * @summary Ensure that method resolution runs over a captured type variables when checking if + * deferred attribution is needed + * @compile T8056984.java + */ +class T8056984<T1 extends B&C, T2 extends T1> { + public T8056984(T1 t1, T2 t2) { + System.err.println(t1.hashCode()); + System.err.println(t2.hashCode()); + } +} +class B { +} +interface C { + public int hashCode(); +} diff --git a/test/tools/javac/lambda/T8057794.java b/test/tools/javac/lambda/T8057794.java new file mode 100644 index 00000000..2bf4c5ae --- /dev/null +++ b/test/tools/javac/lambda/T8057794.java @@ -0,0 +1,12 @@ +/** + * @test /nodynamiccopyright/ + * @bug 8057794 + * @summary The tree for TypeVar.class does not have a type set, which leads to an NPE when + * checking if deferred attribution is needed + * @compile/fail/ref=T8057794.out -XDrawDiagnostics T8057794.java + */ +class T8057794<T> { + void t() { + System.out.println(T.class.getSimpleName()); + } +} diff --git a/test/tools/javac/lambda/T8057794.out b/test/tools/javac/lambda/T8057794.out new file mode 100644 index 00000000..fa025a99 --- /dev/null +++ b/test/tools/javac/lambda/T8057794.out @@ -0,0 +1,2 @@ +T8057794.java:10:29: compiler.err.type.var.cant.be.deref +1 error diff --git a/test/tools/javac/lambda/T8057800/NPEMethodReferenceAndGenericsTest.java b/test/tools/javac/lambda/T8057800/NPEMethodReferenceAndGenericsTest.java new file mode 100644 index 00000000..696a811e --- /dev/null +++ b/test/tools/javac/lambda/T8057800/NPEMethodReferenceAndGenericsTest.java @@ -0,0 +1,39 @@ +/* + * 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 8057800 + * @summary Method reference with generic type creates NPE when compiling + * @compile NPEMethodReferenceAndGenericsTest.java + */ + +public class NPEMethodReferenceAndGenericsTest { + public <T> void foo(java.util.Comparator<? super T> comparator) {} + + public <C extends Comparable<? super C>> void foo() { + foo(C::compareTo); + } +} diff --git a/test/tools/javac/lambda/methodReference/MethodRef8.java b/test/tools/javac/lambda/methodReference/MethodRef8.java new file mode 100644 index 00000000..0bce841c --- /dev/null +++ b/test/tools/javac/lambda/methodReference/MethodRef8.java @@ -0,0 +1,43 @@ +/* + * 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 8063052 + * @summary Inference chokes on wildcard derived from method reference + * @compile MethodRef8.java + */ + +public class MethodRef8 { + void test(Box<? extends Box<? extends Number>> b) { + Number n1 = b.map(Box::get).get(); + Number n2 = b.<Number>map(Box::get).get(); + } + + interface Func<S,T> { T apply(S arg); } + + interface Box<T> { + T get(); + <R> Box<R> map(Func<T,R> f); + } +} diff --git a/test/tools/javac/lambda/methodReference/MethodRefNewInnerBootstrap.java b/test/tools/javac/lambda/methodReference/MethodRefNewInnerBootstrap.java new file mode 100644 index 00000000..21789e1a --- /dev/null +++ b/test/tools/javac/lambda/methodReference/MethodRefNewInnerBootstrap.java @@ -0,0 +1,72 @@ +/* + * 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 8044748 + * @summary JVM cannot access constructor though ::new reference although can call it directly + */ + +public class MethodRefNewInnerBootstrap { + + interface Constructor { + public MyTest execute(int i); + } + + public class MyTest { + public MyTest(int i) { System.out.println("Constructor executed " + i); } + } + + public Constructor getConstructor() { + return MyTest::new; + } + + public static void main(String argv[]) { + new MethodRefNewInnerBootstrap().call(); + } + + public void call() { + MyTest mt = new MyTest(0); + + Constructor c1 = MyTest::new; + c1.execute(1); + + Constructor c2 = getConstructor(); + c2.execute(2); + + Constructor c3 = new Constructor() { + public MyTest execute(int i) { + return new MyTest(3); + } + }; + c3.execute(3); + + Constructor c4 = new Constructor() { + public MyTest execute(int i) { + Constructor c = MyTest::new; + return c.execute(i); + } + }; + c4.execute(4); + } +} diff --git a/test/tools/javac/lambda/methodReference/MethodRefNewInnerInLambdaNPE1.java b/test/tools/javac/lambda/methodReference/MethodRefNewInnerInLambdaNPE1.java new file mode 100644 index 00000000..ffdff556 --- /dev/null +++ b/test/tools/javac/lambda/methodReference/MethodRefNewInnerInLambdaNPE1.java @@ -0,0 +1,48 @@ +/* + * 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 8037404 + * @summary javac NPE or VerifyError for code with constructor reference of inner class + */ + +import java.util.function.Supplier; +import java.util.stream.Stream; + +public class MethodRefNewInnerInLambdaNPE1 { + public static void main(String[] args) { + if (new MethodRefNewInnerInLambdaNPE1().getList().get().getClass() != TT.class) + throw new AssertionError("sanity failed"); + } + + Supplier<TT> getList() { + return () -> Stream.of(1).map(TT::new).findFirst().get(); + } + + class TT { + public TT(int i) { + + } + } +} diff --git a/test/tools/javac/lambda/methodReference/MethodRefNewInnerInLambdaNPE2.java b/test/tools/javac/lambda/methodReference/MethodRefNewInnerInLambdaNPE2.java new file mode 100644 index 00000000..f43a8008 --- /dev/null +++ b/test/tools/javac/lambda/methodReference/MethodRefNewInnerInLambdaNPE2.java @@ -0,0 +1,57 @@ +/* + * 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 8044737 + * @summary Lambda: NPE while obtaining method reference through lambda expression + * @compile MethodRefNewInnerInLambdaNPE2.java + */ + +public class MethodRefNewInnerInLambdaNPE2 { + + interface Constructor { + MyTest execute(); + } + + class MyTest { + MyTest() { System.out.println("Constructor executed"); } + } + + public Constructor getConstructor() { + return getConstructor(() -> { return MyTest::new; }); + } + + public static void main(String argv[]) { + MethodRefNewInnerInLambdaNPE2 t = new MethodRefNewInnerInLambdaNPE2(); + MyTest mytest = t.getConstructor().execute(); + } + + Constructor getConstructor(Wrapper arg) { + return arg.unwrap(); + } + + interface Wrapper { + Constructor unwrap(); + } +} diff --git a/test/tools/javac/lambda/methodReference/MethodRefNewInnerInLambdaVerify1.java b/test/tools/javac/lambda/methodReference/MethodRefNewInnerInLambdaVerify1.java new file mode 100644 index 00000000..c6d7cef7 --- /dev/null +++ b/test/tools/javac/lambda/methodReference/MethodRefNewInnerInLambdaVerify1.java @@ -0,0 +1,48 @@ +/* + * 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 8037404 + * @summary javac NPE or VerifyError for code with constructor reference of inner class + */ + +import java.util.function.Function; +import java.util.stream.Stream; + +public class MethodRefNewInnerInLambdaVerify1 { + public static void main(String[] args) { + if (new MethodRefNewInnerInLambdaVerify1().map().apply(1).getClass() != TT.class) + throw new AssertionError("sanity failed"); + } + + Function<Integer,TT> map() { + return (i) -> Stream.of(i).map(TT::new).findFirst().get(); + } + + class TT { + public TT(int i) { + + } + } +} diff --git a/test/tools/javac/lambda/methodReference/MethodRefNewInnerInLambdaVerify2.java b/test/tools/javac/lambda/methodReference/MethodRefNewInnerInLambdaVerify2.java new file mode 100644 index 00000000..28e4db7a --- /dev/null +++ b/test/tools/javac/lambda/methodReference/MethodRefNewInnerInLambdaVerify2.java @@ -0,0 +1,62 @@ +/* + * 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 8038776 + * @summary VerifyError when running successfully compiled java class + */ + +import java.util.function.Function; + +/** + * Derived from code by: + * @author Yawkat + */ +public class MethodRefNewInnerInLambdaVerify2 { + public static void main(String[] args) { new MethodRefNewInnerInLambdaVerify2().runTest(); } + + private void runTest() { + Worker worker = new Worker(); + run(() -> worker.check(field -> new SomeClass(field))); + run(() -> worker.check(SomeClass::new)); + } + + private void run(Runnable runnable) { + runnable.run(); + } + + private class SomeClass { + final Object field; + + SomeClass(Object field) { + this.field = field; + } + } + + private static class Worker { + void check(Function<Object, SomeClass> i) { + if (!i.apply("frank").field.equals("frank")) throw new AssertionError("sanity failed"); + } + } +} diff --git a/test/tools/javac/lambda/methodReference/MethodRefNewInnerInLambdaVerify2simple.java b/test/tools/javac/lambda/methodReference/MethodRefNewInnerInLambdaVerify2simple.java new file mode 100644 index 00000000..be6d4b25 --- /dev/null +++ b/test/tools/javac/lambda/methodReference/MethodRefNewInnerInLambdaVerify2simple.java @@ -0,0 +1,50 @@ +/* + * 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 8038776 + * @summary VerifyError when running successfully compiled java class + */ + +import java.util.function.Function; + +/** + * Derived from code by: + * @author Yawkat + */ +public class MethodRefNewInnerInLambdaVerify2simple { + public static void main(String[] args) { new MethodRefNewInnerInLambdaVerify2simple().runTest(); } + + private void runTest() { + Runnable r = (() -> { Sup w = SomeClass::new; } ); + } + + private class SomeClass { + SomeClass() { } + } +} + +interface Sup { + Object get(); +} diff --git a/test/tools/javac/lambda/methodReference/MethodRefQualifier1.java b/test/tools/javac/lambda/methodReference/MethodRefQualifier1.java new file mode 100644 index 00000000..110d78ab --- /dev/null +++ b/test/tools/javac/lambda/methodReference/MethodRefQualifier1.java @@ -0,0 +1,62 @@ +/* + * 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 8048121 + * @summary javac complex method references: revamp and simplify + */ + +public class MethodRefQualifier1 { + + interface SAM { + void m(); + } + + static int count = 0; + + static void assertTrue(boolean cond, String msg) { + if (!cond) + throw new AssertionError(msg); + } + + MethodRefQualifier1 check() { + count++; + return this; + } + + void ido(Object... args) { } + + public static void main(String[] args) { + new MethodRefQualifier1().test(); + } + + void test() { + count = 0; + SAM s = check()::ido; + assertTrue(count == 1, "creation: unexpected: " + count); + count = 0; + s.m(); + assertTrue(count == 0, "evaluation: unexpected: " + count); + } +} diff --git a/test/tools/javac/lambda/methodReference/MethodRefSingleRefEvalBridge.java b/test/tools/javac/lambda/methodReference/MethodRefSingleRefEvalBridge.java new file mode 100644 index 00000000..6970f5e1 --- /dev/null +++ b/test/tools/javac/lambda/methodReference/MethodRefSingleRefEvalBridge.java @@ -0,0 +1,70 @@ +/* + * 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 8048121 + * @summary javac complex method references: revamp and simplify + * + * Make sure that the method reference receiver is evaluated exactly once + * even in this bridging case. + */ + + public class MethodRefSingleRefEvalBridge { + + interface SAM { + int m(); + } + + class ZZ { + // private to force bridging + private int four() { return 4; } + } + + static int count = 0; + ZZ azz = new ZZ(); + + static void assertEqual(int expected, int got) { + if (got != expected) + throw new AssertionError("Expected " + expected + " got " + got); + } + + public static void main(String[] args) { + new MethodRefSingleRefEvalBridge().test(); + } + + ZZ check() { + count++; + return azz; + } + + void test() { + count = 0; + SAM s = check()::four; + assertEqual(1, count); + + count = 0; + assertEqual(4, s.m()); + assertEqual(0, count); + } +} diff --git a/test/tools/javac/lambda/methodReference/MethodRefToInner.java b/test/tools/javac/lambda/methodReference/MethodRefToInner.java new file mode 100644 index 00000000..c1a98e64 --- /dev/null +++ b/test/tools/javac/lambda/methodReference/MethodRefToInner.java @@ -0,0 +1,52 @@ +/* + * 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 8047341 + * @summary lambda reference to inner class in base class causes LambdaConversionException + */ + +import java.util.List; +import java.util.ArrayList; + +class MethodRefToInnerBase { + class TestString { + String str; + TestString(String strin) { + str = strin; + } + } +} +public class MethodRefToInner extends MethodRefToInnerBase { + public static void main(String[] args) { + new MethodRefToInner().run(); + } + MethodRefToInner() { + super(); + } + void run() { + List<String> list = new ArrayList<>(); + list.stream().forEach(TestString::new); + } +} diff --git a/test/tools/javac/lambda/methodReference/MethodReferenceComplexNullCheckTest.java b/test/tools/javac/lambda/methodReference/MethodReferenceComplexNullCheckTest.java new file mode 100644 index 00000000..44935abe --- /dev/null +++ b/test/tools/javac/lambda/methodReference/MethodReferenceComplexNullCheckTest.java @@ -0,0 +1,54 @@ +/* + * 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 8048121 + * @summary javac complex method references: revamp and simplify + * + * Make sure NPE check is done even in the convert to Lambda case + */ + +public class MethodReferenceComplexNullCheckTest { + public static void main(String[] args) { + F fr = null; + boolean npeFired = false; + try { + IForm frf = fr::doit; + } catch (NullPointerException npe) { + npeFired = true; + } finally { + if (!npeFired) throw new AssertionError( "NPE should have been thrown"); + } + } + + interface IForm { + void xyz(Object... args); + } + + class F { + private void doit(Object... args) { } + } +} diff --git a/test/tools/javac/lambda/methodReferenceExecution/MethodReferenceIntersection1.java b/test/tools/javac/lambda/methodReferenceExecution/MethodReferenceIntersection1.java new file mode 100644 index 00000000..aff05a7e --- /dev/null +++ b/test/tools/javac/lambda/methodReferenceExecution/MethodReferenceIntersection1.java @@ -0,0 +1,88 @@ +/* + * 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 8058112 + * @summary Invalid BootstrapMethod for constructor/method reference + */ + +import java.util.Arrays; +import java.util.Comparator; +import java.util.List; + +import static java.util.stream.Collectors.toList; + +public class MethodReferenceIntersection1 { + + public static void main(String[] args) { + MethodReferenceIntersection1 main = new MethodReferenceIntersection1(); + List<Info_MRI1> list = main.toInfoListError(Arrays.asList(new Base_MRI1())); + System.out.printf("result %d\n", list.size()); + } + + public <H extends B_MRI1 & A_MRI1> List<Info_MRI1> toInfoListError(List<H> list) { + Comparator<B_MRI1> byNameComparator = + (B_MRI1 b1, B_MRI1 b2) -> b1.getB().compareToIgnoreCase(b2.getB()); + return list.stream().sorted(byNameComparator).map(Info_MRI1::new).collect(toList()); + } + + public <H extends B_MRI1 & A_MRI1> List<Info_MRI1> toInfoListWorks(List<H> list) { + Comparator<B_MRI1> byNameComparator = + (B_MRI1 b1, B_MRI1 b2) -> b1.getB().compareToIgnoreCase(b2.getB()); + return list.stream().sorted(byNameComparator).map(s -> new Info_MRI1(s)).collect(toList()); + } +} + +interface B_MRI1 { + public String getB(); +} + +interface A_MRI1 { + public long getA(); +} + +class Info_MRI1 { + private final long a; + private final String b; + + <H extends A_MRI1 & B_MRI1> Info_MRI1(H h) { + a = h.getA(); + b = h.getB(); + } +} + +class Base_MRI1 implements A_MRI1, B_MRI1 { + + @Override + public long getA() { + return 7L; + } + + @Override + public String getB() { + return "hello"; + } +} diff --git a/test/tools/javac/lambda/methodReferenceExecution/MethodReferenceIntersection2.java b/test/tools/javac/lambda/methodReferenceExecution/MethodReferenceIntersection2.java new file mode 100644 index 00000000..ef594517 --- /dev/null +++ b/test/tools/javac/lambda/methodReferenceExecution/MethodReferenceIntersection2.java @@ -0,0 +1,68 @@ +/* + * 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 8058112 + * @summary Invalid BootstrapMethod for constructor/method reference + */ + +import java.util.function.Function; + +public class MethodReferenceIntersection2 { + + interface B { } + + interface A { } + + static class C implements A, B { } + + static class Info { + <H extends A & B> Info(H h) { } + + static <H extends A & B> Info info(H h) { + return new Info(h); + } + } + + public static void main(String[] args) { + test(); + } + + // Note the switch in order compared to that on Info + static <H extends B & A> void test() { + Function<H, Info> f1L = _h -> new Info(_h); + Function<H, Info> f1 = Info::new; + Function<H, Info> f2L = _h -> Info.info(_h); + Function<H, Info> f2 = Info::info; + H c = (H) new C(); + if(f1.apply(c) instanceof Info && + f2.apply(c) instanceof Info) { + System.out.println("Passes."); + } else { + throw new AssertionError(); + } + } +} diff --git a/test/tools/javac/lambda/methodReferenceExecution/MethodReferenceIntersection3.java b/test/tools/javac/lambda/methodReferenceExecution/MethodReferenceIntersection3.java new file mode 100644 index 00000000..0eeb739b --- /dev/null +++ b/test/tools/javac/lambda/methodReferenceExecution/MethodReferenceIntersection3.java @@ -0,0 +1,50 @@ +/* + * 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 8058112 + * @summary Invalid BootstrapMethod for constructor/method reference + */ + +/** + * @author Remi Forax + */ + +public class MethodReferenceIntersection3 { + interface A {} + + interface Foo { + <T extends Object & A> void foo(T t); + } + + static <T extends A> void bar(T t) { + } + + public static void main(String[] args) { + Foo foo = MethodReferenceIntersection3::bar; + foo.foo(new A(){}); + } +} diff --git a/test/tools/javac/varargs/8055514/T8055514.java b/test/tools/javac/varargs/8055514/T8055514.java new file mode 100644 index 00000000..22fa4bdf --- /dev/null +++ b/test/tools/javac/varargs/8055514/T8055514.java @@ -0,0 +1,26 @@ +/* + * @test /nodynamiccopyright/ + * @bug 8055514 + * @summary Wrong, confusing error when non-static varargs referenced in static context + * @compile/fail/ref=T8055514.out -Xlint:varargs -Werror -XDrawDiagnostics T8055514.java + */ +class T8055514 { + void m(int... args) { } + + void m2(int... args) { } + static void m2(String s) { } + + void m3(int... args) { } + static void m3(String s) { } + static void m3(Runnable r) { } + + void m4(int... args) { } + void m4(int i1, int i2, int i3) { } + + static void test() { + m(1,2,3); //only one candidate (varargs) - varargs error wins + m2(1,2,3); //two candidates - only one applicable (varargs) - varargs error wins + m3(1,2,3); //three candidates - only one applicable (varargs) - varargs error wins + m4(1,2,3); //two candidates - both applicable - basic error wins + } +} diff --git a/test/tools/javac/varargs/8055514/T8055514.out b/test/tools/javac/varargs/8055514/T8055514.out new file mode 100644 index 00000000..75837ee9 --- /dev/null +++ b/test/tools/javac/varargs/8055514/T8055514.out @@ -0,0 +1,5 @@ +T8055514.java:21:9: compiler.err.non-static.cant.be.ref: kindname.method, m(int...) +T8055514.java:22:9: compiler.err.non-static.cant.be.ref: kindname.method, m2(int...) +T8055514.java:23:9: compiler.err.non-static.cant.be.ref: kindname.method, m3(int...) +T8055514.java:24:9: compiler.err.non-static.cant.be.ref: kindname.method, m4(int,int,int) +4 errors diff --git a/test/tools/javac/warnings/suppress/Overridden.java b/test/tools/javac/warnings/suppress/Overridden.java new file mode 100644 index 00000000..8366e395 --- /dev/null +++ b/test/tools/javac/warnings/suppress/Overridden.java @@ -0,0 +1,16 @@ +/** + * @test /nodynamiccopyright/ + * @bug 8033421 + * @summary Check that \\@SuppressWarnings works properly when overriding deprecated method. + * @build VerifySuppressWarnings + * @compile/ref=Overridden.out -XDrawDiagnostics -Xlint:deprecation Overridden.java + * @run main VerifySuppressWarnings Overridden.java + */ + +public class Overridden implements Interface { + public void test() { } +} + +interface Interface { + @Deprecated void test(); +} diff --git a/test/tools/javac/warnings/suppress/Overridden.out b/test/tools/javac/warnings/suppress/Overridden.out new file mode 100644 index 00000000..a215218b --- /dev/null +++ b/test/tools/javac/warnings/suppress/Overridden.out @@ -0,0 +1,2 @@ +Overridden.java:11:17: compiler.warn.has.been.deprecated: test(), Interface +1 warning diff --git a/test/tools/javac/warnings/suppress/OverriddenSuppressed.java b/test/tools/javac/warnings/suppress/OverriddenSuppressed.java new file mode 100644 index 00000000..4d2e305e --- /dev/null +++ b/test/tools/javac/warnings/suppress/OverriddenSuppressed.java @@ -0,0 +1,38 @@ +/* + * 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 8033421 + * @summary Check that \\@SuppressWarnings works properly when overriding deprecated method. + * @compile -Werror -Xlint:deprecation OverriddenSuppressed.java + */ + +public class OverriddenSuppressed implements Interface { + @SuppressWarnings("deprecation") + public void test() { } +} + +interface Interface { + @Deprecated void test(); +} |