Mercurial > hg > openjdk > lambda > langtools
changeset 2485:5a05c8801ecb
Merge
line wrap: on
line diff
--- a/.hgtags Wed Oct 02 13:26:54 2013 -0700 +++ b/.hgtags Fri Oct 11 15:29:02 2013 -0700 @@ -156,6 +156,10 @@ be069d72dde2bfe6f996c46325a320961ca854c2 jdk8-b32 46831c72b7f6c69fef2cc2935001863643a65f94 jdk8-b33 6b105afbb77ca9600a99eade31f686d070c70581 jdk8-b34 +42a7a264130d63029c7cd29c24379b32d147cdb3 lambda-b45 +68da3a8292fc7e068f1ca2fd5ad95d90e2872845 lambda-b48 +92ef69a3ba61b4252c2c129bed190f3d2e91d6c9 lambda-b50 +92ef69a3ba61b4252c2c129bed190f3d2e91d6c9 lambda-b56 defd666a786334465496c8901fa302b779c7e045 jdk8-b35 94bbaa67686f44a124cd16fd9f1e8a6a3f684d2d jdk8-b36 5891b38985e8b2502296fc29e726b527d03116d2 jdk8-b37
--- a/.jcheck/conf Wed Oct 02 13:26:54 2013 -0700 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,1 +0,0 @@ -project=jdk8
--- a/src/share/classes/com/sun/tools/javac/code/Types.java Wed Oct 02 13:26:54 2013 -0700 +++ b/src/share/classes/com/sun/tools/javac/code/Types.java Fri Oct 11 15:29:02 2013 -0700 @@ -26,6 +26,7 @@ package com.sun.tools.javac.code; import java.lang.ref.SoftReference; +import java.util.Comparator; import java.util.HashSet; import java.util.HashMap; import java.util.Locale; @@ -33,6 +34,7 @@ import java.util.Set; import java.util.WeakHashMap; +import javax.lang.model.type.TypeKind; import javax.tools.JavaFileObject; import com.sun.tools.javac.code.Attribute.RetentionPolicy;
--- a/src/share/classes/com/sun/tools/javac/comp/Attr.java Wed Oct 02 13:26:54 2013 -0700 +++ b/src/share/classes/com/sun/tools/javac/comp/Attr.java Fri Oct 11 15:29:02 2013 -0700 @@ -2835,7 +2835,7 @@ boolean isSpeculativeRound = resultInfo.checkContext.deferredAttrContext().mode == DeferredAttr.AttrMode.SPECULATIVE; checkReferenceCompatible(that, desc, refType, resultInfo.checkContext, isSpeculativeRound); - if (!isSpeculativeRound) { + if (!isSpeculativeRound && target != Type.recoveryType) { checkAccessibleTypes(that, localEnv, resultInfo.checkContext.inferenceContext(), desc, target); } result = check(that, target, VAL, resultInfo);
--- a/src/share/classes/com/sun/tools/javac/comp/DeferredAttr.java Wed Oct 02 13:26:54 2013 -0700 +++ b/src/share/classes/com/sun/tools/javac/comp/DeferredAttr.java Fri Oct 11 15:29:02 2013 -0700 @@ -503,6 +503,25 @@ } } } + + /** + * Get the list of stuck variables that do not depend on the target + * type - this means that inference will lead to same results during + * both OVERLOAD and CHECK modes. + */ + List<Type> targetFreevars() { + List<Type> freevars = msym.type.getTypeArguments(); + ListBuffer<Type> targetVars = ListBuffer.lb(); + outer: for (Type t : inferenceContext.inferencevars) { + for (Type t2 : freevars) { + if (msym.type.getReturnType().contains(t2) && + t.tsym == t2.tsym) { + targetVars.append(t); + } + } + } + return targetVars.toList(); + } } /**
--- a/src/share/classes/com/sun/tools/javac/comp/Infer.java Wed Oct 02 13:26:54 2013 -0700 +++ b/src/share/classes/com/sun/tools/javac/comp/Infer.java Fri Oct 11 15:29:02 2013 -0700 @@ -1048,41 +1048,6 @@ }; return g.nodes.get(0); } - - boolean isSubtype(Type s, Type t, Warner warn, Infer infer) { - return doIncorporationOp(IncorporationBinaryOpKind.IS_SUBTYPE, s, t, warn, infer); - } - - boolean isSameType(Type s, Type t, Infer infer) { - return doIncorporationOp(IncorporationBinaryOpKind.IS_SAME_TYPE, s, t, null, infer); - } - - void addBound(InferenceBound ib, UndetVar uv, Type b, Infer infer) { - doIncorporationOp(opFor(ib), uv, b, null, infer); - } - - IncorporationBinaryOpKind opFor(InferenceBound boundKind) { - switch (boundKind) { - case EQ: - return IncorporationBinaryOpKind.ADD_EQ_BOUND; - case LOWER: - return IncorporationBinaryOpKind.ADD_LOWER_BOUND; - case UPPER: - return IncorporationBinaryOpKind.ADD_UPPER_BOUND; - default: - Assert.error("Can't get here!"); - return null; - } - } - - boolean doIncorporationOp(IncorporationBinaryOpKind opKind, Type op1, Type op2, Warner warn, Infer infer) { - IncorporationBinaryOp newOp = infer.new IncorporationBinaryOp(opKind, op1, op2); - Boolean res = infer.incorporationCache.get(newOp); - if (res == null) { - infer.incorporationCache.put(newOp, res = newOp.apply(warn)); - } - return res; - } } /** @@ -1208,7 +1173,7 @@ THROWS(InferenceBound.UPPER) { @Override public boolean accepts(UndetVar t, InferenceContext inferenceContext) { - if ((t.qtype.tsym.flags() & Flags.THROWS) == 0) { + if (t.isCaptured() || (t.qtype.tsym.flags() & Flags.THROWS) == 0) { //not a throws undet var return false; }
--- a/src/share/classes/com/sun/tools/javac/comp/LambdaToMethod.java Wed Oct 02 13:26:54 2013 -0700 +++ b/src/share/classes/com/sun/tools/javac/comp/LambdaToMethod.java Fri Oct 11 15:29:02 2013 -0700 @@ -91,7 +91,10 @@ /** info about the current class being processed */ private KlassInfo kInfo; - /** dump statistics about lambda code generation */ + /** for testing purposes force all lambdas to take a serializable form */ + private boolean forceSerializableRepresentation; + + /** dump statistics about lambda code generation */ private boolean dumpLambdaToMethodStats; /** Flag for alternate metafactories indicating the lambda object is intended to be serializable */ @@ -165,6 +168,7 @@ make = TreeMaker.instance(context); types = Types.instance(context); transTypes = TransTypes.instance(context); + // forceSerializableRepresentation = true; analyzer = new LambdaAnalyzerPreprocessor(); Options options = Options.instance(context); dumpLambdaToMethodStats = options.isSet("dumpLambdaToMethodStats"); @@ -588,10 +592,10 @@ DiagnosticPosition pos, List<Object> staticArgs, MethodType indyType) { String functionalInterfaceClass = classSig(targetType); String functionalInterfaceMethodName = samSym.getSimpleName().toString(); - String functionalInterfaceMethodSignature = methodSig(types.erasure(samSym.type)); + String functionalInterfaceMethodSignature = typeSig(types.erasure(samSym.type)); String implClass = classSig(types.erasure(refSym.owner.type)); String implMethodName = refSym.getQualifiedName().toString(); - String implMethodSignature = methodSig(types.erasure(refSym.type)); + String implMethodSignature = typeSig(types.erasure(refSym.type)); JCExpression kindTest = eqTest(syms.intType, deserGetter("getImplMethodKind", syms.intType), make.Literal(implMethodKind)); ListBuffer<JCExpression> serArgs = new ListBuffer<>(); @@ -1099,8 +1103,21 @@ * keep the count of lambda expression defined in given context (used to * generate unambiguous names for serializable lambdas) */ - private Map<String, Integer> serializableLambdaCounts = - new HashMap<String, Integer>(); + private class SyntheticMethodNameCounter { + private Map<String, Integer> map = new HashMap<String, Integer>(); + int getIndex(StringBuilder buf) { + String temp = buf.toString(); + Integer count = map.get(temp); + if (count == null) { + count = 0; + } + ++count; + map.put(temp, count); + return count; + } + } + private SyntheticMethodNameCounter syntheticMethodNameCounts = + new SyntheticMethodNameCounter(); private Map<Symbol, JCClassDecl> localClassDefs; @@ -1134,13 +1151,13 @@ @Override public void visitClassDef(JCClassDecl tree) { List<Frame> prevStack = frameStack; - Map<String, Integer> prevSerializableLambdaCount = - serializableLambdaCounts; + SyntheticMethodNameCounter prevSyntheticMethodNameCounts = + syntheticMethodNameCounts; Map<ClassSymbol, Symbol> prevClinits = clinits; DiagnosticSource prevSource = log.currentSource(); try { log.useSource(tree.sym.sourcefile); - serializableLambdaCounts = new HashMap<String, Integer>(); + syntheticMethodNameCounts = new SyntheticMethodNameCounter(); prevClinits = new HashMap<ClassSymbol, Symbol>(); if (tree.sym.owner.kind == MTH) { localClassDefs.put(tree.sym, tree); @@ -1166,7 +1183,7 @@ finally { log.useSource(prevSource.getFile()); frameStack = prevStack; - serializableLambdaCounts = prevSerializableLambdaCount; + syntheticMethodNameCounts = prevSyntheticMethodNameCounts; clinits = prevClinits; } } @@ -1389,50 +1406,6 @@ } } - private Name lambdaName() { - return names.lambda.append(names.fromString("" + lambdaCount++)); - } - - /** - * For a serializable lambda, generate a name which maximizes name - * stability across deserialization. - * @param owner - * @return Name to use for the synthetic lambda method name - */ - private Name serializedLambdaName(Symbol owner) { - StringBuilder buf = new StringBuilder(); - buf.append(names.lambda); - // Append the name of the method enclosing the lambda. - String methodName = owner.name.toString(); - if (methodName.equals("<clinit>")) - methodName = "static"; - else if (methodName.equals("<init>")) - methodName = "new"; - buf.append(methodName); - buf.append('$'); - // Append a hash of the enclosing method signature to differentiate - // overloaded enclosing methods. For lambdas enclosed in lambdas, - // the generated lambda method will not have type yet, but the - // enclosing method's name will have been generated with this same - // method, so it will be unique and never be overloaded. - Assert.check(owner.type != null || directlyEnclosingLambda() != null); - if (owner.type != null) { - int methTypeHash = methodSig(owner.type).hashCode(); - buf.append(Integer.toHexString(methTypeHash)); - } - buf.append('$'); - // The above appended name components may not be unique, append a - // count based on the above name components. - String temp = buf.toString(); - Integer count = serializableLambdaCounts.get(temp); - if (count == null) { - count = 0; - } - buf.append(count++); - serializableLambdaCounts.put(temp, count); - return names.fromString(buf.toString()); - } - /** * Return a valid owner given the current declaration stack * (required to skip synthetic lambda symbols) @@ -1649,19 +1622,19 @@ private abstract class TranslationContext<T extends JCFunctionalExpression> { /** the underlying (untranslated) tree */ - T tree; + final T tree; /** points to the adjusted enclosing scope in which this lambda/mref expression occurs */ - Symbol owner; + final Symbol owner; /** the depth of this lambda expression in the frame stack */ - int depth; + final int depth; /** the enclosing translation context (set for nested lambdas/mref) */ - TranslationContext<?> prev; + final TranslationContext<?> prev; /** list of methods to be bridged by the meta-factory */ - List<Symbol> bridges; + final List<Symbol> bridges; TranslationContext(T tree) { this.tree = tree; @@ -1682,6 +1655,9 @@ /** does this functional expression require serialization support? */ boolean isSerializable() { + if (forceSerializableRepresentation) { + return true; + } for (Type target : tree.targets) { if (types.asSuper(target, syms.serializableType.tsym) != null) { return true; @@ -1689,6 +1665,31 @@ } return false; } + + /** + * @return Name of the enclosing method to be folded into synthetic + * method name + */ + String enclosingMethodName() { + return syntheticMethodNameComponent(owner.name); + } + + /** + * @return Method name in a form that can be folded into a + * component of a synthetic method name + */ + String syntheticMethodNameComponent(Name name) { + if (name == null) { + return "null"; + } + String methodName = name.toString(); + if (methodName.equals("<clinit>")) { + methodName = "static"; + } else if (methodName.equals("<init>")) { + methodName = "new"; + } + return methodName; + } } /** @@ -1699,43 +1700,136 @@ */ private class LambdaTranslationContext extends TranslationContext<JCLambda> { + /** variable declaration in the enclosing context to which this lambda is assigned */ + final Symbol self; + /** variable in the enclosing context to which this lambda is assigned */ - Symbol self; + final Symbol assignedTo; /** map from original to translated lambda parameters */ - Map<Symbol, Symbol> lambdaParams = new LinkedHashMap<Symbol, Symbol>(); + final Map<Symbol, Symbol> lambdaParams = new LinkedHashMap<Symbol, Symbol>(); /** map from original to translated lambda locals */ - Map<Symbol, Symbol> lambdaLocals = new LinkedHashMap<Symbol, Symbol>(); + final Map<Symbol, Symbol> lambdaLocals = new LinkedHashMap<Symbol, Symbol>(); /** map from variables in enclosing scope to translated synthetic parameters */ - Map<Symbol, Symbol> capturedLocals = new LinkedHashMap<Symbol, Symbol>(); + final Map<Symbol, Symbol> capturedLocals = new LinkedHashMap<Symbol, Symbol>(); /** map from class symbols to translated synthetic parameters (for captured member access) */ - Map<Symbol, Symbol> capturedThis = new LinkedHashMap<Symbol, Symbol>(); + final Map<Symbol, Symbol> capturedThis = new LinkedHashMap<Symbol, Symbol>(); /** map from original to translated lambda locals */ - Map<Symbol, Symbol> typeVars = new LinkedHashMap<Symbol, Symbol>(); + final Map<Symbol, Symbol> typeVars = new LinkedHashMap<Symbol, Symbol>(); /** the synthetic symbol for the method hoisting the translated lambda */ - Symbol translatedSym; + final Symbol translatedSym; List<JCVariableDecl> syntheticParams; LambdaTranslationContext(JCLambda tree) { super(tree); Frame frame = frameStack.head; - if (frame.tree.hasTag(VARDEF)) { - self = ((JCVariableDecl)frame.tree).sym; + switch (frame.tree.getTag()) { + case VARDEF: + assignedTo = self = ((JCVariableDecl) frame.tree).sym; + break; + case ASSIGN: + self = null; + assignedTo = TreeInfo.symbol(((JCAssign) frame.tree).getVariable()); + break; + default: + assignedTo = self = null; + break; } - Name name = isSerializable() ? serializedLambdaName(owner) : lambdaName(); - this.translatedSym = makeSyntheticMethod(0, name, null, owner.enclClass()); + + // This symbol will be filled-in in complete + this.translatedSym = makeSyntheticMethod(0, null, null, owner.enclClass()); + if (dumpLambdaToMethodStats) { log.note(tree, "lambda.stat", needsAltMetafactory(), translatedSym); } } /** + * For a serializable lambda, generate a disambiguating string + * which maximizes stability across deserialization. + * + * @return String to differentiate synthetic lambda method names + */ + private String serializedLambdaDisambiguation() { + StringBuilder buf = new StringBuilder(); + // Append the enclosing method signature to differentiate + // overloaded enclosing methods. For lambdas enclosed in + // lambdas, the generated lambda method will not have type yet, + // but the enclosing method's name will have been generated + // with this same method, so it will be unique and never be + // overloaded. + Assert.check( + owner.type != null || + directlyEnclosingLambda() != null); + if (owner.type != null) { + buf.append(typeSig(owner.type)); + buf.append(":"); + } + + // Add target type info + buf.append(types.findDescriptorSymbol(tree.type.tsym).owner.flatName()); + buf.append(" "); + + // Add variable assigned to + if (assignedTo != null) { + buf.append(assignedTo.flatName()); + buf.append("="); + } + + //add captured locals info: type, name, order + for (Symbol fv : getSymbolMap(CAPTURED_VAR).keySet()) { + if (fv != self) { + buf.append(typeSig(fv.type)); + buf.append(" "); + buf.append(fv.flatName()); + buf.append(","); + } + } + + return buf.toString(); + } + + /** + * For a non-serializable lambda, generate a simple method. + * + * @return Name to use for the synthetic lambda method name + */ + private Name lambdaName() { + return names.lambda.append(names.fromString(enclosingMethodName() + "$" + lambdaCount++)); + } + + /** + * For a serializable lambda, generate a method name which maximizes + * name stability across deserialization. + * + * @return Name to use for the synthetic lambda method name + */ + private Name serializedLambdaName() { + StringBuilder buf = new StringBuilder(); + buf.append(names.lambda); + // Append the name of the method enclosing the lambda. + buf.append(enclosingMethodName()); + buf.append('$'); + // Append a hash of the disambiguating string : enclosing method + // signature, etc. + String disam = serializedLambdaDisambiguation(); + 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(); + //System.err.printf("serializedLambdaName: %s -- %s\n", result, disam); + return names.fromString(result); + } + + /** * Translate a symbol of a given kind into something suitable for the * synthetic lambda body */ @@ -1864,6 +1958,11 @@ syntheticParams = params.toList(); + // Compute and set the lambda name + translatedSym.name = isSerializable() ? + serializedLambdaName() + : lambdaName(); + //prepend synthetic args to translated lambda method signature translatedSym.type = types.createMethodTypeWithParameters( generatedLambdaSig(), @@ -1891,7 +1990,7 @@ this.isSuper = tree.hasKind(ReferenceKind.SUPER); this.bridgeSym = needsBridge() ? makeSyntheticMethod(isSuper ? 0 : STATIC, - lambdaName().append(names.fromString("$bridge")), null, + referenceBridgeName(), null, owner.enclClass()) : null; if (dumpLambdaToMethodStats) { @@ -1911,6 +2010,63 @@ boolean needsVarArgsConversion() { return tree.varargsElement != null; } + + /** + * 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 brdieg + 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(); + //System.err.printf("referenceBridgeName: %s -- %s\n", result, disam); + return names.fromString(result); + } /** * @return Is this an array operation like clone() @@ -1967,7 +2123,7 @@ * **************************************************************** */ - private String methodSig(Type type) { + private String typeSig(Type type) { L2MSignatureGenerator sg = new L2MSignatureGenerator(); sg.assembleSig(type); return sg.toString();
--- a/src/share/classes/com/sun/tools/javac/comp/Resolve.java Wed Oct 02 13:26:54 2013 -0700 +++ b/src/share/classes/com/sun/tools/javac/comp/Resolve.java Fri Oct 11 15:29:02 2013 -0700 @@ -867,6 +867,12 @@ } }; + /** + * This class handles method reference applicability checks; since during + * these checks it's sometime possible to have inference variables on + * the actual argument types list, the method applicability check must be + * extended so that inference variables are 'opened' as needed. + */ class MethodReferenceCheck extends AbstractMethodCheck { InferenceContext pendingInferenceContext; @@ -1000,7 +1006,7 @@ class MostSpecificCheck implements MethodCheck { boolean strict; - List<Type> actuals; + List<Type> actuals; Symbol other; MostSpecificCheck(boolean strict, List<Type> actuals) { this.strict = strict;
--- a/src/share/classes/com/sun/tools/javac/comp/TransTypes.java Wed Oct 02 13:26:54 2013 -0700 +++ b/src/share/classes/com/sun/tools/javac/comp/TransTypes.java Fri Oct 11 15:29:02 2013 -0700 @@ -29,6 +29,7 @@ import com.sun.tools.javac.code.*; import com.sun.tools.javac.code.Symbol.*; +import com.sun.tools.javac.code.Type.ForAll; import com.sun.tools.javac.tree.*; import com.sun.tools.javac.tree.JCTree.*; import com.sun.tools.javac.util.*; @@ -38,6 +39,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.CLASS; +import static com.sun.tools.javac.code.TypeTag.FORALL; import static com.sun.tools.javac.code.TypeTag.TYPEVAR; import static com.sun.tools.javac.code.TypeTag.VOID; import static com.sun.tools.javac.comp.CompileStates.CompileState; @@ -480,6 +482,10 @@ /** Visitor argument: proto-type. */ private Type pt; + + /** Visitor argument: additional synthetic functional interfaces. + */ + private List<JCTree> bridgedFunctionalInterfaces; /** Visitor method: perform a type translation on tree. */
--- a/test/Makefile Wed Oct 02 13:26:54 2013 -0700 +++ b/test/Makefile Fri Oct 11 15:29:02 2013 -0700 @@ -7,7 +7,7 @@ # A full product build (or "control" build) creates a complete JDK image. # To test a product build, set TESTJAVA to the path for the image. # -# A langtools build just builds the langtools components of a JDK. +# A langtools build just builds the langtools components of a JDK. # To test a langtools build, set TESTJAVA to the path for a recent JDK # build, and set TESTBOOTCLASSPATH to the compiled langtools classes -- # for example build/classes or dist/lib/classes.jar. @@ -122,10 +122,10 @@ TESTJAVA = $(SLASH_JAVA)/re/jdk/1.7.0/promoted/latest/binaries/$(PLATFORM)-$(ARCH) endif -# PRODUCT_HOME is a JPRT variable pointing to a directory containing the output from +# PRODUCT_HOME is a JPRT variable pointing to a directory containing the output from # make/Makefile # For langtools, this is a directory containing build and dist -# For a control build, this is build/$(PRODUCT)-$(ARCH)/XYZ-image +# For a control build, this is build/$(PRODUCT)-$(ARCH)/XYZ-image # (i.e, j2sdk-image or jdk-module-image) ifdef PRODUCT_HOME ifeq ($(shell [ -r $(PRODUCT_HOME)/dist/lib/classes.jar ]; echo $$?),0) @@ -139,13 +139,13 @@ ifdef TESTBOOTCLASSPATH JTREG_OPTIONS += -Xbootclasspath/p:$(TESTBOOTCLASSPATH) ### In the following, -refvmoptions is an undocumented option -### The following does not work JCK 7 b30 2/6/2010. Awaiting b31. +### The following does not work JCK 7 b30 2/6/2010. Awaiting b31. JCK_OPTIONS += \ -vmoptions:-Xbootclasspath/p:$(TESTBOOTCLASSPATH) \ -refvmoptions:-Xbootclasspath/p:$(TESTBOOTCLASSPATH) endif -# Concurrency is the number of tests that can execute at once. +# Concurrency is the number of tests that can execute at once. # On an otherwise empty machine, suggest setting to (#cpus + 2) # If unset, the default is (#cpus) ### RFE: determine and use #cpus @@ -206,7 +206,7 @@ # Exit -- used for final "normal" exit from "make". Redefine to "true" to avoid # having make exit with non-zero return code. EXIT = exit -# Function to exit shell if exit code of preceding command is greater than or equal +# Function to exit shell if exit code of preceding command is greater than or equal # to a given level. Redefine function or preceding FATAL_*_EXIT codes as needed. EXIT_IF_FATAL = status=$$?; if [ $$status -ge $(1) ]; then exit $$status ; fi @@ -250,12 +250,12 @@ # Run jtreg tests # -# JTREG_HOME +# JT_HOME # Installed location of jtreg # JT_JAVA # Version of java used to run jtreg. Should normally be the same as TESTJAVA # TESTJAVA -# Version of java to be tested. +# Version of java to be tested. # JTREG_OPTIONS # Additional options for jtreg # JTREG_TESTDIRS @@ -311,7 +311,7 @@ # Version of java used to run JCK. Should normally be the same as TESTJAVA # Default is JDK 7 # TESTJAVA -# Version of java to be tested. +# Version of java to be tested. # JCK_COMPILER_OPTIONS # Additional options for JCK-compiler # JCK_COMPILER_TESTDIRS @@ -360,7 +360,7 @@ # JT_JAVA # Version of java used to run JCK. Should normally be the same as TESTJAVA # TESTJAVA -# Version of java to be tested. +# Version of java to be tested. # JCK_RUNTIME_OPTIONS # Additional options for JCK-runtime # JCK_RUNTIME_TESTDIRS @@ -434,4 +434,3 @@ # No use of suffix rules .SUFFIXES: -
--- a/test/tools/javac/6889255/T6889255.java Wed Oct 02 13:26:54 2013 -0700 +++ b/test/tools/javac/6889255/T6889255.java Fri Oct 11 15:29:02 2013 -0700 @@ -417,6 +417,9 @@ String getExpectedName(VarSymbol v, int i) { // special cases: + // bridge methods use argN. No LVT for them anymore + if ((v.owner.flags() & Flags.BRIDGE) != 0) + return "arg" + (i - 1); // synthetic method if (((v.owner.owner.flags() & Flags.ENUM) != 0) && v.owner.name.toString().equals("valueOf")) @@ -428,10 +431,7 @@ // abstract methods don't have saved names // -- no Code attribute for the LocalVariableTable attribute if ((v.owner.flags() & Flags.ABSTRACT) != 0) - return "arg" + (i - 1); - // bridge methods use argN. No LVT for them anymore - if ((v.owner.flags() & Flags.BRIDGE) != 0) - return "arg" + (i - 1); + return "arg" + (i - 1); // The rest of this method assumes the local conventions in the test program Type t = v.type;
--- a/test/tools/javac/Diagnostics/compressed/T8012003c.java Wed Oct 02 13:26:54 2013 -0700 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,24 +0,0 @@ -/** - * @test /nodynamiccopyright/ - * @bug 8012003 - * @summary Method diagnostics resolution need to be simplified in some cases - * test simplification of lambda type-checking error leading to resolution failure - * @compile/fail/ref=T8012003c.out -XDrawDiagnostics -Xdiags:compact T8012003c.java - */ - -class T8012003c { - - interface I { - void m(P p); - } - - void m(I i) { } - - void test() { - m(p->p.m()); - } -} - -class P { - private void m() { } -}
--- a/test/tools/javac/Diagnostics/compressed/T8012003c.out Wed Oct 02 13:26:54 2013 -0700 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,2 +0,0 @@ -T8012003c.java:18:15: compiler.err.report.access: m(), private, P -1 error
--- a/test/tools/javac/T8019486/WrongLVTForLambdaTest.java Wed Oct 02 13:26:54 2013 -0700 +++ b/test/tools/javac/T8019486/WrongLVTForLambdaTest.java Fri Oct 11 15:29:02 2013 -0700 @@ -61,8 +61,6 @@ {9, 0}, //number -> number / 1 }; - static final String methodToLookFor = "lambda$0"; - public static void main(String[] args) throws Exception { new WrongLVTForLambdaTest().run(); } @@ -70,7 +68,7 @@ void run() throws Exception { compileTestClass(); checkClassFile(new File(Paths.get(System.getProperty("user.dir"), - "Foo.class").toUri()), methodToLookFor); + "Foo.class").toUri())); } void compileTestClass() throws Exception { @@ -79,12 +77,12 @@ ToolBox.javac(javacSuccessArgs); } - void checkClassFile(final File cfile, String methodToFind) throws Exception { + void checkClassFile(final File cfile) throws Exception { ClassFile classFile = ClassFile.read(cfile); - boolean methodFound = false; + int methodsFound = 0; for (Method method : classFile.methods) { - if (method.getName(classFile.constant_pool).equals(methodToFind)) { - methodFound = true; + if (method.getName(classFile.constant_pool).startsWith("lambda$")) { + ++methodsFound; Code_attribute code = (Code_attribute) method.attributes.get("Code"); LineNumberTable_attribute lnt = (LineNumberTable_attribute) code.attributes.get("LineNumberTable"); @@ -101,7 +99,7 @@ } } } - Assert.check(methodFound, "The seek method was not found"); + Assert.check(methodsFound == 1, "Expected to find one lambda method, found " + methodsFound); } void error(String msg) {
--- a/test/tools/javac/api/TestJavacTaskScanner.java Wed Oct 02 13:26:54 2013 -0700 +++ b/test/tools/javac/api/TestJavacTaskScanner.java Fri Oct 11 15:29:02 2013 -0700 @@ -40,7 +40,10 @@ import java.nio.*; import java.nio.charset.Charset; import java.util.Arrays; +import java.util.Stack; import javax.lang.model.element.Element; +import javax.lang.model.element.ElementKind; +import javax.lang.model.element.Modifier; import javax.lang.model.element.TypeElement; import javax.lang.model.type.DeclaredType; import javax.lang.model.type.TypeMirror;
--- a/test/tools/javac/defaultMethods/TestNoBridgeOnDefaults.java Wed Oct 02 13:26:54 2013 -0700 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,85 +0,0 @@ -/* - * Copyright (c) 2011, 2013, Oracle and/or its affiliates. All rights reserved. - * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. - * - * This code is free software; you can redistribute it and/or modify it - * under the terms of the GNU General Public License version 2 only, as - * published by the Free Software Foundation. - * - * 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 7192246 - * @summary check that javac does not generate bridge methods for defaults - */ - -import com.sun.tools.classfile.ClassFile; -import com.sun.tools.classfile.ConstantPool.*; -import com.sun.tools.classfile.Method; - -import java.io.*; - -public class TestNoBridgeOnDefaults { - - interface A<X> { - default <Y> A<X> m(X x, Y y) { return Impl.<X,Y>m1(this, x, y); } - } - - static abstract class B<X> implements A<X> { } - - interface C<X> extends A<X> { - default <Y> C<X> m(X x, Y y) { return Impl.<X,Y>m2(this, x, y); } - } - - static abstract class D<X> extends B<X> implements C<X> { } - - static class Impl { - static <X, Y> A<X> m1(A<X> rec, X x, Y y) { return null; } - static <X, Y> C<X> m2(C<X> rec, X x, Y y) { return null; } - } - - static final String[] SUBTEST_NAMES = { B.class.getName() + ".class", D.class.getName() + ".class" }; - static final String TEST_METHOD_NAME = "m"; - - public static void main(String... args) throws Exception { - new TestNoBridgeOnDefaults().run(); - } - - public void run() throws Exception { - String workDir = System.getProperty("test.classes"); - for (int i = 0 ; i < SUBTEST_NAMES.length ; i ++) { - File compiledTest = new File(workDir, SUBTEST_NAMES[i]); - checkNoBridgeOnDefaults(compiledTest); - } - } - - void checkNoBridgeOnDefaults(File f) { - System.err.println("check: " + f); - try { - ClassFile cf = ClassFile.read(f); - for (Method m : cf.methods) { - String mname = m.getName(cf.constant_pool); - if (mname.equals(TEST_METHOD_NAME)) { - throw new Error("unexpected bridge method found " + m); - } - } - } catch (Exception e) { - e.printStackTrace(); - throw new Error("error reading " + f +": " + e); - } - } -}
--- a/test/tools/javac/defaultMethods/separate/Separate.java Wed Oct 02 13:26:54 2013 -0700 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,41 +0,0 @@ -/* - * Copyright (c) 2010, 2013, Oracle and/or its affiliates. All rights reserved. - * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. - * - * This code is free software; you can redistribute it and/or modify it - * under the terms of the GNU General Public License version 2 only, as - * published by the Free Software Foundation. - * - * 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 7192246 - * @summary smoke test for separate compilation of default methods - * @author Maurizio Cimadamore - * @compile pkg1/A.java - * @compile Separate.java - */ - -import pkg1.A; - -class Separate { - interface B extends A.I { - default void m() { A.m(this); } - } - - interface C extends A.I, B { } -}
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/test/tools/javac/defaultMethods/separate/Separate01.java Fri Oct 11 15:29:02 2013 -0700 @@ -0,0 +1,41 @@ +/* + * Copyright (c) 2010, 2013, Oracle and/or its affiliates. All rights reserved. + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * This code is free software; you can redistribute it and/or modify it + * under the terms of the GNU General Public License version 2 only, as + * published by the Free Software Foundation. + * + * 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 7192246 + * @summary smoke test for separate compilation of default methods + * @author Maurizio Cimadamore + * @compile pkg1/A.java + * @compile Separate01.java + */ + +import pkg1.A; + +class Separate01 { + interface B extends A.I { + default void m() { A.m(this); } + } + + interface C extends A.I, B { } +}
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/test/tools/javac/defaultMethods/separate/Separate02.java Fri Oct 11 15:29:02 2013 -0700 @@ -0,0 +1,34 @@ +/* + * Copyright (c) 2013, Oracle and/or its affiliates. All rights reserved. + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * This code is free software; you can redistribute it and/or modify it + * under the terms of the GNU General Public License version 2 only, as + * published by the Free Software Foundation. + * + * 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 8013789 + * @summary Compiler should emit bridges in interfaces + * @compile pkg2/B.java + * @compile Separate02.java + */ + +import pkg2.B; + +class Separate02 implements B { }
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/test/tools/javac/defaultMethods/separate/pkg2/A.java Fri Oct 11 15:29:02 2013 -0700 @@ -0,0 +1,28 @@ +/* + * Copyright (c) 2013, Oracle and/or its affiliates. All rights reserved. + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * This code is free software; you can redistribute it and/or modify it + * under the terms of the GNU General Public License version 2 only, as + * published by the Free Software Foundation. + * + * This code is distributed in the hope that it will be useful, but WITHOUT + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License + * version 2 for more details (a copy is included in the LICENSE file that + * accompanied this code). + * + * You should have received a copy of the GNU General Public License version + * 2 along with this work; if not, write to the Free Software Foundation, + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. + * + * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA + * or visit www.oracle.com if you need additional information or have any + * questions. + */ + +package pkg2; + +public interface A { + Object m(); +}
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/test/tools/javac/defaultMethods/separate/pkg2/B.java Fri Oct 11 15:29:02 2013 -0700 @@ -0,0 +1,28 @@ +/* + * Copyright (c) 2013, Oracle and/or its affiliates. All rights reserved. + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * This code is free software; you can redistribute it and/or modify it + * under the terms of the GNU General Public License version 2 only, as + * published by the Free Software Foundation. + * + * This code is distributed in the hope that it will be useful, but WITHOUT + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License + * version 2 for more details (a copy is included in the LICENSE file that + * accompanied this code). + * + * You should have received a copy of the GNU General Public License version + * 2 along with this work; if not, write to the Free Software Foundation, + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. + * + * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA + * or visit www.oracle.com if you need additional information or have any + * questions. + */ + +package pkg2; + +public interface B extends A { + default String m() { return ""; } +}
--- a/test/tools/javac/defaultMethods/static/hiding/InterfaceMethodHidingTest.java Wed Oct 02 13:26:54 2013 -0700 +++ b/test/tools/javac/defaultMethods/static/hiding/InterfaceMethodHidingTest.java Fri Oct 11 15:29:02 2013 -0700 @@ -199,7 +199,7 @@ void run(JavaCompiler tool, StandardJavaFileManager fm) throws Exception { JavacTask ct = (JavacTask)tool.getTask(null, fm, diagChecker, - Arrays.asList("-XDallowStaticInterfaceMethods"), null, Arrays.asList(source)); + null, null, Arrays.asList(source)); try { ct.analyze(); } catch (Throwable ex) {
--- a/test/tools/javac/defaultMethods/syntax/TestDefaultMethodsSyntax.java Wed Oct 02 13:26:54 2013 -0700 +++ b/test/tools/javac/defaultMethods/syntax/TestDefaultMethodsSyntax.java Fri Oct 11 15:29:02 2013 -0700 @@ -54,7 +54,7 @@ } List<String> getOptions() { - return Arrays.asList("-XDallowStaticInterfaceMethods", "-source", versionString); + return Arrays.asList("-source", versionString); } }
--- a/test/tools/javac/diags/examples.not-yet.txt Wed Oct 02 13:26:54 2013 -0700 +++ b/test/tools/javac/diags/examples.not-yet.txt Fri Oct 11 15:29:02 2013 -0700 @@ -111,4 +111,3 @@ compiler.warn.unknown.enum.constant # in bad class file compiler.warn.unknown.enum.constant.reason # in bad class file compiler.warn.override.equals.but.not.hashcode # when a class overrides equals but not hashCode method from Object -
--- a/test/tools/javac/diags/examples/BadArgTypesInLambda.java Wed Oct 02 13:26:54 2013 -0700 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,38 +0,0 @@ -/* - * Copyright (c) 2013, Oracle and/or its affiliates. All rights reserved. - * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. - * - * This code is free software; you can redistribute it and/or modify it - * under the terms of the GNU General Public License version 2 only, as - * published by the Free Software Foundation. - * - * 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. - */ - -// key: compiler.err.prob.found.req -// key: compiler.misc.inconvertible.types -// options: -Xdiags:verbose - -class BadArgTypesInLambda { - interface SAM { - void m(Integer i); - } - - void g(SAM s) { } - - void test() { - g(x->{ String s = x; }); - } -}
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/test/tools/javac/lambda/8023364/T8023364a.java Fri Oct 11 15:29:02 2013 -0700 @@ -0,0 +1,39 @@ +/* + * Copyright (c) 2013, Oracle and/or its affiliates. All rights reserved. + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * This code is free software; you can redistribute it and/or modify it + * under the terms of the GNU General Public License version 2 only, as + * published by the Free Software Foundation. + * + * 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 8023364 + * @summary Exception in thread "main" java.lang.BootstrapMethodError: call site initialization exception + * @compile T8023364a.java + */ +public class T8023364a { + interface SAM<T> { + T get(); + } + + public static void main(String[] args) { + SAM<SAM> sam = new SAM<SAM>() { public SAM get() { return null; } }; + SAM temp = sam.get()::get; + } +}
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/test/tools/javac/lambda/8023364/T8023364b.java Fri Oct 11 15:29:02 2013 -0700 @@ -0,0 +1,59 @@ +/* + * Copyright (c) 2013, Oracle and/or its affiliates. All rights reserved. + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * This code is free software; you can redistribute it and/or modify it + * under the terms of the GNU General Public License version 2 only, as + * published by the Free Software Foundation. + * + * 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 8023364 + * @summary Exception in thread "main" java.lang.BootstrapMethodError: call site initialization exception + * @compile T8023364b.java + */ +class Test { + + interface Supplier<X> { + X get(); + } + + static class A { + public A(Supplier<B> supplier) { } + } + + static class B { } + + static class C { + public B getB() { + return new B(); + } + } + + public static void main(String[] args) { + new Test().test(Test::getC); + } + + private static C getC() { + return new C(); + } + + public void test(Supplier<C> supplier) { + new A(supplier.get()::getB); + } +}
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/test/tools/javac/lambda/BadConv01.out Fri Oct 11 15:29:02 2013 -0700 @@ -0,0 +1,2 @@ +BadConv01.java:35:13: compiler.err.prob.found.req: (compiler.misc.incompatible.types.1: (compiler.misc.invalid.generic.target.for.lambda.conv: m, kindname.interface, BadConv01.Bar)), #int(T), BadConv01.Bar +1 error
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/test/tools/javac/lambda/BadConv02.out Fri Oct 11 15:29:02 2013 -0700 @@ -0,0 +1,3 @@ +BadConv02.java:44:15: compiler.err.cant.apply.symbol: kindname.constructor, FooImpl, int, compiler.misc.no.args, kindname.class, BadConv02.FooImpl, null +BadConv02.java:45:15: compiler.err.prob.found.req: (compiler.misc.incompatible.types.1: (compiler.misc.target.for.lambda.conv.must.have.default.constr: null, kindname.class, BadConv02.Foo)), #int(), BadConv02.Foo +2 errors
--- a/test/tools/javac/lambda/LambdaParserTest.java Wed Oct 02 13:26:54 2013 -0700 +++ b/test/tools/javac/lambda/LambdaParserTest.java Fri Oct 11 15:29:02 2013 -0700 @@ -29,7 +29,7 @@ * temporarily workaround combo tests are causing time out in several platforms * @library ../lib * @build JavacTestingAbstractThreadedTest - * @run main/othervm LambdaParserTest + * @run main/othervm/timeout=800 LambdaParserTest */ // use /othervm to avoid jtreg timeout issues (CODETOOLS-7900047) @@ -51,10 +51,10 @@ NILARY_STMT("()->{ return x; }"), ONEARY_SHORT_EXPR("#PN->x"), ONEARY_SHORT_STMT("#PN->{ return x; }"), - ONEARY_EXPR("(#M1 #T1 #PN)->x"), - ONEARY_STMT("(#M1 #T1 #PN)->{ return x; }"), - TWOARY_EXPR("(#M1 #T1 #PN, #M2 #T2 y)->x"), - TWOARY_STMT("(#M1 #T1 #PN, #M2 #T2 y)->{ return x; }"); + ONEARY_EXPR("(#A1 #M1 #T1 #PN)->x"), + ONEARY_STMT("(#A1 #M1 #T1 #PN)->{ return x; }"), + TWOARY_EXPR("(#A1 #M1 #T1 #PN, #A2 #M2 #T2 y)->x"), + TWOARY_STMT("(#A1 #M1 #T1 #PN, #A2 #M2 #T2 y)->{ return x; }"); String lambdaTemplate; @@ -63,9 +63,12 @@ } String getLambdaString(LambdaParameterKind pk1, LambdaParameterKind pk2, - ModifierKind mk1, ModifierKind mk2, LambdaParameterName pn) { + ModifierKind mk1, AnnotationKind ak1, ModifierKind mk2, AnnotationKind ak2, + LambdaParameterName pn) { return lambdaTemplate.replaceAll("#M1", mk1.modifier) + .replaceAll("#A1", ak1.anno) .replaceAll("#M2", mk2.modifier) + .replaceAll("#A2", ak2.anno) .replaceAll("#T1", pk1.parameterType) .replaceAll("#T2", pk2.parameterType) .replaceAll("#PN", pn.nameStr); @@ -129,6 +132,22 @@ this == EXPLICIT_GENERIC2_VARARGS; } } + + enum AnnotationKind { + NONE(""), + ANNO("@Anno"); + + String anno; + + AnnotationKind(String anno) { + this.anno = anno; + } + + boolean compatibleWith(LambdaParameterKind pk) { + return pk != LambdaParameterKind.IMPLICIT || + this == NONE; + } + } enum ModifierKind { NONE(""), @@ -166,8 +185,9 @@ } String expressionString(LambdaParameterKind pk1, LambdaParameterKind pk2, - ModifierKind mk1, ModifierKind mk2, LambdaKind lk, LambdaParameterName pn, SubExprKind sk) { - return expressionTemplate.replaceAll("#L", lk.getLambdaString(pk1, pk2, mk1, mk2, pn)) + ModifierKind mk1, AnnotationKind ak1, ModifierKind mk2, AnnotationKind ak2, + LambdaKind lk, LambdaParameterName pn, SubExprKind sk) { + return expressionTemplate.replaceAll("#L", lk.getLambdaString(pk1, pk2, mk1, ak1, mk2, ak2, pn)) .replaceAll("#S", sk.subExpression); } } @@ -198,17 +218,19 @@ continue; for (ModifierKind mk1 : ModifierKind.values()) { if (mk1 != ModifierKind.NONE && lk.isShort()) - continue; - if (lk.arity() < 1 && mk1 != ModifierKind.NONE) - continue; - for (ModifierKind mk2 : ModifierKind.values()) { - if (lk.arity() < 2 && mk2 != ModifierKind.NONE) - continue; - for (SubExprKind sk : SubExprKind.values()) { - for (ExprKind ek : ExprKind.values()) { - pool.execute( - new LambdaParserTest(pk1, pk2, mk1, - mk2, lk, sk, ek, pn)); + continue; + for (AnnotationKind ak1 : AnnotationKind.values()) { + if (lk.arity() < 1 && mk1 != ModifierKind.NONE) + continue; + for (ModifierKind mk2 : ModifierKind.values()) { + for (AnnotationKind ak2 : AnnotationKind.values()) { + if (lk.arity() < 2 && mk2 != ModifierKind.NONE) + continue; + for (SubExprKind sk : SubExprKind.values()) { + for (ExprKind ek : ExprKind.values()) { + pool.execute(new LambdaParserTest(pk1, pk2, mk1, ak1, mk2, ak2, lk, pn, sk, ek)); + } + } } } } @@ -223,8 +245,8 @@ LambdaParameterKind pk1; LambdaParameterKind pk2; - ModifierKind mk1; - ModifierKind mk2; + ModifierKind mk1, mk2; + AnnotationKind ak1, ak2; LambdaKind lk; LambdaParameterName pn; SubExprKind sk; @@ -232,13 +254,15 @@ JavaSource source; DiagnosticChecker diagChecker; - LambdaParserTest(LambdaParameterKind pk1, LambdaParameterKind pk2, - ModifierKind mk1, ModifierKind mk2, LambdaKind lk, - SubExprKind sk, ExprKind ek, LambdaParameterName pn) { + LambdaParserTest(LambdaParameterKind pk1, LambdaParameterKind pk2, ModifierKind mk1, + AnnotationKind ak1, ModifierKind mk2, AnnotationKind ak2, LambdaKind lk, + LambdaParameterName pn, SubExprKind sk, ExprKind ek) { this.pk1 = pk1; this.pk2 = pk2; this.mk1 = mk1; + this.ak1 = ak1; this.mk2 = mk2; + this.ak2 = ak2; this.lk = lk; this.pn = pn; this.sk = sk; @@ -249,7 +273,8 @@ class JavaSource extends SimpleJavaFileObject { - String template = "class Test {\n" + + String template = "@interface Anno { }\n" + + "class Test {\n" + " SAM s = #E;\n" + "}"; @@ -257,8 +282,7 @@ public JavaSource() { super(URI.create("myfo:/Test.java"), JavaFileObject.Kind.SOURCE); - source = template.replaceAll("#E", - ek.expressionString(pk1, pk2, mk1, mk2, lk, pn, sk)); + source = template.replaceAll("#E", ek.expressionString(pk1, pk2, mk1, ak1, mk2, ak2, lk, pn, sk)); } @Override @@ -284,16 +308,19 @@ boolean errorExpected = (lk.arity() > 0 && !mk1.compatibleWith(pk1)) || (lk.arity() > 1 && !mk2.compatibleWith(pk2)); - + + errorExpected |= !lk.isShort() && ((lk.arity() > 0 && !ak1.compatibleWith(pk1)) || + (lk.arity() > 1 && !ak2.compatibleWith(pk2))); + + errorExpected |= pn == LambdaParameterName.UNDERSCORE && + lk.arity() > 0; + if (lk.arity() == 2 && (pk1.explicit() != pk2.explicit() || pk1.isVarargs())) { errorExpected = true; } - errorExpected |= pn == LambdaParameterName.UNDERSCORE && - lk.arity() > 0; - if (errorExpected != diagChecker.errorFound) { throw new Error("invalid diagnostics for source:\n" + source.getCharContent(true) +
--- a/test/tools/javac/lambda/methodReference/SamConversionComboTest.java Wed Oct 02 13:26:54 2013 -0700 +++ b/test/tools/javac/lambda/methodReference/SamConversionComboTest.java Fri Oct 11 15:29:02 2013 -0700 @@ -7,7 +7,7 @@ * 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 + * ANY WARRANTY; without even the implied warranty of MERzCHANTABILITY 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).
--- a/test/tools/javac/lambda/mostSpecific/StructuralMostSpecificTest.java Wed Oct 02 13:26:54 2013 -0700 +++ b/test/tools/javac/lambda/mostSpecific/StructuralMostSpecificTest.java Fri Oct 11 15:29:02 2013 -0700 @@ -165,7 +165,7 @@ checkAfterExec(); } - + LambdaReturnKind lrk; RetTypeKind rt1, rt2; ArgTypeKind ak1, ak2; @@ -235,6 +235,12 @@ void check() { checkCount.incrementAndGet(); + + if (ak1 != ak2) + return; + + if (ak1 != ak2) + return; if (ak1 != ak2) return;