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 e720f9fb5fed8edd7a2dc1ffb3191fa86c45bd3b..d6340f34c145920d39a00fc3a35c91469935807a 100644 --- a/src/share/classes/com/sun/tools/javac/comp/Attr.java +++ b/src/share/classes/com/sun/tools/javac/comp/Attr.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 1999, 2013, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 1999, 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 @@ -4653,10 +4653,19 @@ public class Attr extends JCTree.Visitor { private void initTypeIfNeeded(JCTree that) { if (that.type == null) { - that.type = syms.unknownType; + if (that.hasTag(METHODDEF)) { + that.type = dummyMethodType(); + } else { + that.type = syms.unknownType; + } } } + private Type dummyMethodType() { + return new MethodType(List.nil(), syms.unknownType, + List.nil(), syms.methodClass); + } + @Override public void scan(JCTree tree) { if (tree == null) return; @@ -4712,7 +4721,8 @@ public class Attr extends JCTree.Visitor { @Override public void visitNewClass(JCNewClass that) { if (that.constructor == null) { - that.constructor = new MethodSymbol(0, names.init, syms.unknownType, syms.noSymbol); + that.constructor = new MethodSymbol(0, names.init, + dummyMethodType(), syms.noSymbol); } if (that.constructorType == null) { that.constructorType = syms.unknownType; @@ -4722,22 +4732,28 @@ public class Attr extends JCTree.Visitor { @Override public void visitAssignop(JCAssignOp that) { - if (that.operator == null) - that.operator = new OperatorSymbol(names.empty, syms.unknownType, -1, syms.noSymbol); + if (that.operator == null) { + that.operator = new OperatorSymbol(names.empty, dummyMethodType(), + -1, syms.noSymbol); + } super.visitAssignop(that); } @Override public void visitBinary(JCBinary that) { - if (that.operator == null) - that.operator = new OperatorSymbol(names.empty, syms.unknownType, -1, syms.noSymbol); + if (that.operator == null) { + that.operator = new OperatorSymbol(names.empty, dummyMethodType(), + -1, syms.noSymbol); + } super.visitBinary(that); } @Override public void visitUnary(JCUnary that) { - if (that.operator == null) - that.operator = new OperatorSymbol(names.empty, syms.unknownType, -1, syms.noSymbol); + if (that.operator == null) { + that.operator = new OperatorSymbol(names.empty, dummyMethodType(), + -1, syms.noSymbol); + } super.visitUnary(that); } @@ -4753,7 +4769,8 @@ public class Attr extends JCTree.Visitor { public void visitReference(JCMemberReference that) { super.visitReference(that); if (that.sym == null) { - that.sym = new MethodSymbol(0, names.empty, syms.unknownType, syms.noSymbol); + that.sym = new MethodSymbol(0, names.empty, dummyMethodType(), + syms.noSymbol); } if (that.targets == null) { that.targets = List.nil(); 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 eb697352f16204b6a9c910eb6ca54a82a3968313..9ae4fcec7f10f2f19cae15c78ee3eb250f754153 100644 --- a/src/share/classes/com/sun/tools/javac/comp/Check.java +++ b/src/share/classes/com/sun/tools/javac/comp/Check.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 1999, 2013, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 1999, 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 @@ -2779,7 +2779,7 @@ public class Check { validateDocumented(t.tsym, s, pos); validateInherited(t.tsym, s, pos); validateTarget(t.tsym, s, pos); - validateDefault(t.tsym, s, pos); + validateDefault(t.tsym, pos); } private void validateValue(TypeSymbol container, TypeSymbol contained, DiagnosticPosition pos) { @@ -2898,7 +2898,9 @@ public class Check { /** Checks that s is a subset of t, with respect to ElementType - * semantics, specifically {ANNOTATION_TYPE} is a subset of {TYPE} + * semantics, specifically {ANNOTATION_TYPE} is a subset of {TYPE}, + * and {TYPE_USE} covers the set {ANNOTATION_TYPE, TYPE, TYPE_USE, + * TYPE_PARAMETER}. */ private boolean isTargetSubsetOf(Set s, Set t) { // Check that all elements in s are present in t @@ -2911,6 +2913,12 @@ public class Check { } else if (n1 == names.TYPE && n2 == names.ANNOTATION_TYPE) { currentElementOk = true; break; + } else if (n1 == names.TYPE_USE && + (n2 == names.TYPE || + n2 == names.ANNOTATION_TYPE || + n2 == names.TYPE_PARAMETER)) { + currentElementOk = true; + break; } } if (!currentElementOk) @@ -2919,7 +2927,7 @@ public class Check { return true; } - private void validateDefault(Symbol container, Symbol contained, DiagnosticPosition pos) { + private void validateDefault(Symbol container, DiagnosticPosition pos) { // validate that all other elements of containing type has defaults Scope scope = container.members(); for(Symbol elm : scope.getElements()) { 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 0c1b2d2997052ea6b93a06e4fc9beec22b1b9b4f..aa528a4f283ebbdcbcd830f01e61c46ceeca8bc5 100644 --- a/src/share/classes/com/sun/tools/javac/comp/Flow.java +++ b/src/share/classes/com/sun/tools/javac/comp/Flow.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 1999, 2013, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 1999, 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 @@ -1461,9 +1461,19 @@ public class Flow { this.names = names; } + private boolean isInitialConstructor = false; + @Override protected void markDead(JCTree tree) { - inits.inclRange(returnadr, nextadr); + if (!isInitialConstructor) { + inits.inclRange(returnadr, nextadr); + } else { + for (int address = returnadr; address < nextadr; address++) { + if (!(isFinalUninitializedStaticField(vardecls[address].sym))) { + inits.incl(address); + } + } + } uninits.inclRange(returnadr, nextadr); } @@ -1476,8 +1486,17 @@ public class Flow { return sym.pos >= startPos && ((sym.owner.kind == MTH || - ((sym.flags() & (FINAL | HASINIT | PARAMETER)) == FINAL && - classDef.sym.isEnclosedBy((ClassSymbol)sym.owner)))); + isFinalUninitializedField(sym))); + } + + boolean isFinalUninitializedField(VarSymbol sym) { + return sym.owner.kind == TYP && + ((sym.flags() & (FINAL | HASINIT | PARAMETER)) == FINAL && + classDef.sym.isEnclosedBy((ClassSymbol)sym.owner)); + } + + boolean isFinalUninitializedStaticField(VarSymbol sym) { + return isFinalUninitializedField(sym) && sym.isStatic(); } /** Initialize new trackable variable by setting its address field @@ -1731,10 +1750,9 @@ public class Flow { int returnadrPrev = returnadr; Assert.check(pendingExits.isEmpty()); - + boolean lastInitialConstructor = isInitialConstructor; try { - boolean isInitialConstructor = - TreeInfo.isInitialConstructor(tree); + isInitialConstructor = TreeInfo.isInitialConstructor(tree); if (!isInitialConstructor) { firstadr = nextadr; @@ -1789,6 +1807,7 @@ public class Flow { nextadr = nextadrPrev; firstadr = firstadrPrev; returnadr = returnadrPrev; + isInitialConstructor = lastInitialConstructor; } } 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 8aa6f5169d86c45646fe7e7fdf991408cd0165e7..242a591a80ae2a546eec4f35aa6cf4bd8b7b4b6a 100644 --- a/src/share/classes/com/sun/tools/javac/comp/LambdaToMethod.java +++ b/src/share/classes/com/sun/tools/javac/comp/LambdaToMethod.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2010, 2013, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2010, 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 @@ -96,6 +96,9 @@ public class LambdaToMethod extends TreeTranslator { /** dump statistics about lambda code generation */ private boolean dumpLambdaToMethodStats; + /** force serializable representation, for stress testing **/ + private final boolean forceSerializable; + /** Flag for alternate metafactories indicating the lambda object is intended to be serializable */ public static final int FLAG_SERIALIZABLE = 1 << 0; @@ -131,6 +134,7 @@ public class LambdaToMethod extends TreeTranslator { Options options = Options.instance(context); dumpLambdaToMethodStats = options.isSet("dumpLambdaToMethodStats"); attr = Attr.instance(context); + forceSerializable = options.isSet("forceSerializable"); } // @@ -1694,6 +1698,9 @@ public class LambdaToMethod extends TreeTranslator { /** does this functional expression require serialization support? */ boolean isSerializable() { + if (forceSerializable) { + return true; + } for (Type target : tree.targets) { if (types.asSuper(target, syms.serializableType.tsym) != null) { return true; diff --git a/src/share/classes/com/sun/tools/javac/processing/JavacRoundEnvironment.java b/src/share/classes/com/sun/tools/javac/processing/JavacRoundEnvironment.java index b4b385657eafeac6dd4b8be13325d0f7baa3da19..3853ac04807b4fb98bed9d87e25e4973eff1cc10 100644 --- a/src/share/classes/com/sun/tools/javac/processing/JavacRoundEnvironment.java +++ b/src/share/classes/com/sun/tools/javac/processing/JavacRoundEnvironment.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2005, 2013, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2005, 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 @@ -26,11 +26,8 @@ package com.sun.tools.javac.processing; import java.lang.annotation.Annotation; -import com.sun.tools.javac.tree.JCTree.*; import javax.annotation.processing.*; import javax.lang.model.element.*; -import javax.lang.model.type.DeclaredType; -import javax.lang.model.type.TypeMirror; import javax.lang.model.util.*; import java.util.*; @@ -114,58 +111,48 @@ public class JavacRoundEnvironment implements RoundEnvironment { */ public Set getElementsAnnotatedWith(TypeElement a) { Set result = Collections.emptySet(); - Types typeUtil = processingEnv.getTypeUtils(); if (a.getKind() != ElementKind.ANNOTATION_TYPE) throw new IllegalArgumentException(NOT_AN_ANNOTATION_TYPE + a); - DeclaredType annotationTypeElement; - TypeMirror tm = a.asType(); - if ( tm instanceof DeclaredType ) - annotationTypeElement = (DeclaredType) a.asType(); - else - throw new AssertionError("Bad implementation type for " + tm); - - ElementScanner8, DeclaredType> scanner = - new AnnotationSetScanner(result, typeUtil); + ElementScanner8, TypeElement> scanner = + new AnnotationSetScanner(result); for (Element element : rootElements) - result = scanner.scan(element, annotationTypeElement); + result = scanner.scan(element, a); return result; } // Could be written as a local class inside getElementsAnnotatedWith private class AnnotationSetScanner extends - ElementScanner8, DeclaredType> { + ElementScanner8, TypeElement> { // Insertion-order preserving set Set annotatedElements = new LinkedHashSet(); - Types typeUtil; - AnnotationSetScanner(Set defaultSet, Types typeUtil) { + AnnotationSetScanner(Set defaultSet) { super(defaultSet); - this.typeUtil = typeUtil; } @Override - public Set visitType(TypeElement e, DeclaredType p) { + public Set visitType(TypeElement e, TypeElement p) { // Type parameters are not considered to be enclosed by a type scan(e.getTypeParameters(), p); return scan(e.getEnclosedElements(), p); } @Override - public Set visitExecutable(ExecutableElement e, DeclaredType p) { + public Set visitExecutable(ExecutableElement e, TypeElement p) { // Type parameters are not considered to be enclosed by an executable scan(e.getTypeParameters(), p); return scan(e.getEnclosedElements(), p); } @Override - public Set scan(Element e, DeclaredType p) { + public Set scan(Element e, TypeElement p) { java.util.List annotationMirrors = processingEnv.getElementUtils().getAllAnnotationMirrors(e); for (AnnotationMirror annotationMirror : annotationMirrors) { - if (typeUtil.isSameType(annotationMirror.getAnnotationType(), p)) + if (p.equals(annotationMirror.getAnnotationType().asElement())) annotatedElements.add(e); } e.accept(this, p); diff --git a/test/tools/javac/T8030816/CrashLambdaExpressionWithNonAccessibleIdTest.java b/test/tools/javac/T8030816/CrashLambdaExpressionWithNonAccessibleIdTest.java new file mode 100644 index 0000000000000000000000000000000000000000..f873f2dbe8f2ec0f853f4e102c9fc45ef61a9d6a --- /dev/null +++ b/test/tools/javac/T8030816/CrashLambdaExpressionWithNonAccessibleIdTest.java @@ -0,0 +1,22 @@ +/* + * @test /nodynamiccopyright/ + * @bug 8030816 + * @summary javac can't compile program with lambda expression + * @compile/fail/ref=CrashLambdaExpressionWithNonAccessibleIdTest.out -XDrawDiagnostics CrashLambdaExpressionWithNonAccessibleIdTest.java + */ + +/* This test must make sure that javac won't crash when compiling lambda + * containing an anonymous innerclass based on an unresolvable type. + */ +public class CrashLambdaExpressionWithNonAccessibleIdTest { + void m() { + m1(()-> { + new A(){ + public void m11() {} + }; + }); + + } + + void m1(Runnable r) {} +} diff --git a/test/tools/javac/T8030816/CrashLambdaExpressionWithNonAccessibleIdTest.out b/test/tools/javac/T8030816/CrashLambdaExpressionWithNonAccessibleIdTest.out new file mode 100644 index 0000000000000000000000000000000000000000..d253b9c660b192d504cacbdda73010cb01323eef --- /dev/null +++ b/test/tools/javac/T8030816/CrashLambdaExpressionWithNonAccessibleIdTest.out @@ -0,0 +1,3 @@ +CrashLambdaExpressionWithNonAccessibleIdTest.java:15:35: compiler.err.missing.ret.stmt +CrashLambdaExpressionWithNonAccessibleIdTest.java:14:17: compiler.err.cant.resolve.location: kindname.class, A, , , (compiler.misc.location: kindname.class, CrashLambdaExpressionWithNonAccessibleIdTest, null) +2 errors diff --git a/test/tools/javac/annotations/repeatingAnnotations/8029017/TypeUseTarget.java b/test/tools/javac/annotations/repeatingAnnotations/8029017/TypeUseTarget.java new file mode 100644 index 0000000000000000000000000000000000000000..5af979dd5e6fff4c26e6f2f9f7be7795cff97494 --- /dev/null +++ b/test/tools/javac/annotations/repeatingAnnotations/8029017/TypeUseTarget.java @@ -0,0 +1,129 @@ +/* + * 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 8029017 + * @summary sanity testing of ElementType validation for repeating annotations + * @compile TypeUseTarget.java + */ + +import java.lang.annotation.*; + +public class TypeUseTarget {} + + +// Case 1: +@Target({ + ElementType.TYPE_USE, +}) +@Repeatable(Case1Container.class) +@interface Case1 {} + +@Target({ + ElementType.ANNOTATION_TYPE, + ElementType.TYPE, + ElementType.TYPE_USE, + ElementType.TYPE_PARAMETER, +}) +@interface Case1Container { + Case1[] value(); +} + + +// Case 2: +@Target({ + ElementType.TYPE_USE, +}) +@Repeatable(Case2Container.class) +@interface Case2 {} + +@Target({ + ElementType.ANNOTATION_TYPE, + ElementType.TYPE, + ElementType.TYPE_USE, +}) +@interface Case2Container { + Case2[] value(); +} + + +// Case 3: +@Target({ + ElementType.TYPE_USE, +}) +@Repeatable(Case3Container.class) +@interface Case3 {} + +@Target({ + ElementType.ANNOTATION_TYPE, + ElementType.TYPE, +}) +@interface Case3Container { + Case3[] value(); +} + + +// Case 4: +@Target({ + ElementType.TYPE_USE, +}) +@Repeatable(Case4Container.class) +@interface Case4 {} + +@Target({ + ElementType.ANNOTATION_TYPE, +}) +@interface Case4Container { + Case4[] value(); +} + + +// Case 5: +@Target({ + ElementType.TYPE_USE, +}) +@Repeatable(Case5Container.class) +@interface Case5 {} + +@Target({ + ElementType.TYPE, +}) +@interface Case5Container { + Case5[] value(); +} + + +// Case 6: +@Target({ + ElementType.TYPE_USE, +}) +@Repeatable(Case6Container.class) +@interface Case6 {} + +@Target({ + ElementType.TYPE_PARAMETER, +}) +@interface Case6Container { + Case6[] value(); +} diff --git a/test/tools/javac/annotations/repeatingAnnotations/8029017/TypeUseTargetNeg.java b/test/tools/javac/annotations/repeatingAnnotations/8029017/TypeUseTargetNeg.java new file mode 100644 index 0000000000000000000000000000000000000000..02b57d0e8cd8295987e90b1fde5d2890cdad93ad --- /dev/null +++ b/test/tools/javac/annotations/repeatingAnnotations/8029017/TypeUseTargetNeg.java @@ -0,0 +1,100 @@ +/** + * @test /nodynamiccopyright/ + * @bug 8029017 + * @summary sanity testing of ElementType validation for repeating annotations + * @compile/fail/ref=TypeUseTargetNeg.out -XDrawDiagnostics TypeUseTargetNeg.java + */ + +import java.lang.annotation.*; + +public class TypeUseTargetNeg {} + +// Case 1: +@Target({ + ElementType.TYPE_USE, +}) +@Repeatable(FooContainer.class) +@interface Foo {} + +@Target({ + ElementType.ANNOTATION_TYPE, + ElementType.TYPE, + ElementType.TYPE_USE, + ElementType.TYPE_PARAMETER, + ElementType.FIELD, + +}) +@interface FooContainer { + Foo[] value(); +} + + +// Case 2: +@Target({ + ElementType.TYPE_USE, +}) +@Repeatable(BarContainer.class) +@interface Bar {} + +@Target({ + ElementType.ANNOTATION_TYPE, + ElementType.TYPE, + ElementType.TYPE_USE, + ElementType.METHOD, +}) +@interface BarContainer { + Bar[] value(); +} + + +// Case 3: +@Target({ + ElementType.TYPE_USE, +}) +@Repeatable(BazContainer.class) +@interface Baz {} + +@Target({ + ElementType.ANNOTATION_TYPE, + ElementType.TYPE, + ElementType.PARAMETER, +}) +@interface BazContainer { + Baz[] value(); +} + + +// Case 4: +@Target({ + ElementType.TYPE_USE, +}) +@Repeatable(QuxContainer.class) +@interface Qux {} + +@interface QuxContainer { + Qux[] value(); +} + + +// Case 5: +@Target({}) +@Repeatable(QuuxContainer.class) +@interface Quux {} + +@Target({ + ElementType.TYPE_PARAMETER, +}) +@interface QuuxContainer { + Quux[] value(); +} + +// Case 6: +@Repeatable(QuuuxContainer.class) +@interface Quuux {} + +@Target({ + ElementType.TYPE_USE, +}) +@interface QuuuxContainer { + Quuux[] value(); +} diff --git a/test/tools/javac/annotations/repeatingAnnotations/8029017/TypeUseTargetNeg.out b/test/tools/javac/annotations/repeatingAnnotations/8029017/TypeUseTargetNeg.out new file mode 100644 index 0000000000000000000000000000000000000000..8bf41706954408ef30fbc5477949622726955f1f --- /dev/null +++ b/test/tools/javac/annotations/repeatingAnnotations/8029017/TypeUseTargetNeg.out @@ -0,0 +1,7 @@ +TypeUseTargetNeg.java:16:1: compiler.err.invalid.repeatable.annotation.incompatible.target: FooContainer, Foo +TypeUseTargetNeg.java:36:1: compiler.err.invalid.repeatable.annotation.incompatible.target: BarContainer, Bar +TypeUseTargetNeg.java:54:1: compiler.err.invalid.repeatable.annotation.incompatible.target: BazContainer, Baz +TypeUseTargetNeg.java:71:1: compiler.err.invalid.repeatable.annotation.incompatible.target: QuxContainer, Qux +TypeUseTargetNeg.java:81:1: compiler.err.invalid.repeatable.annotation.incompatible.target: QuuxContainer, Quux +TypeUseTargetNeg.java:92:1: compiler.err.invalid.repeatable.annotation.incompatible.target: QuuuxContainer, Quuux +6 errors diff --git a/test/tools/javac/annotations/repeatingAnnotations/combo/TargetAnnoCombo.java b/test/tools/javac/annotations/repeatingAnnotations/combo/TargetAnnoCombo.java index 058b48910cd05a32ff17f61ff058c27f9a5fc512..66e1c1440b116531ff357d4f58fc1fa7931447f8 100644 --- a/test/tools/javac/annotations/repeatingAnnotations/combo/TargetAnnoCombo.java +++ b/test/tools/javac/annotations/repeatingAnnotations/combo/TargetAnnoCombo.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2013, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2013, 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 @@ -23,7 +23,7 @@ /* * @test - * @bug 7151010 8006547 8007766 + * @bug 7151010 8006547 8007766 8029017 * @summary Default test cases for running combinations for Target values * @build Helper * @run main TargetAnnoCombo @@ -145,11 +145,19 @@ public class TargetAnnoCombo { Set tempBaseSet = EnumSet.noneOf(ElementType.class); tempBaseSet.addAll(baseAnnotations); + // If BaseAnno has TYPE, then ANNOTATION_TYPE is allowed by default. if (baseAnnotations.contains(TYPE)) { tempBaseSet.add(ANNOTATION_TYPE); } + // If BaseAnno has TYPE_USE, then add the extra allowed types + if (baseAnnotations.contains(TYPE_USE)) { + tempBaseSet.add(ANNOTATION_TYPE); + tempBaseSet.add(TYPE); + tempBaseSet.add(TYPE_PARAMETER); + } + // If containerAnno has no @Target, only valid case if baseAnnoTarget has // all targets defined else invalid set. if (containerAnnotations == null) { diff --git a/test/tools/javac/api/TestJavacTaskScanner.java b/test/tools/javac/api/TestJavacTaskScanner.java index 7103ba74cdd765c0f7e3cc245b709788eec11428..a02ca67a0339daa9b98407d80dd60e911513c845 100644 --- a/test/tools/javac/api/TestJavacTaskScanner.java +++ b/test/tools/javac/api/TestJavacTaskScanner.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2005, 2013, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2005, 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 @@ -23,7 +23,7 @@ /* * @test - * @bug 4813736 + * @bug 4813736 8013256 * @summary Additional functionality test of task and JSR 269 * @author Peter von der Ah\u00e9 * @library ./lib diff --git a/test/tools/javac/flow/T8030218/CompileTimeErrorForNonAssignedStaticFieldTest.java b/test/tools/javac/flow/T8030218/CompileTimeErrorForNonAssignedStaticFieldTest.java new file mode 100644 index 0000000000000000000000000000000000000000..e139fb7c1777d8923a793d98948de65a36973f2d --- /dev/null +++ b/test/tools/javac/flow/T8030218/CompileTimeErrorForNonAssignedStaticFieldTest.java @@ -0,0 +1,29 @@ +/* + * @test /nodynamiccopyright/ + * @bug 8030218 + * @summary javac, compile time error isn't shown when final static field is not assigned, follow-up + * @compile/fail/ref=CompileTimeErrorForNonAssignedStaticFieldTest.out -XDrawDiagnostics CompileTimeErrorForNonAssignedStaticFieldTest.java + */ + +public class CompileTimeErrorForNonAssignedStaticFieldTest { + private final static int i; + + public CompileTimeErrorForNonAssignedStaticFieldTest() + throws InstantiationException { + throw new InstantiationException("Can't instantiate"); + } + + static class Inner { + private final int j; + public Inner(int x) + throws InstantiationException { + if (x == 0) { + throw new InstantiationException("Can't instantiate"); + } else { + j = 1; + } + System.out.println(j); + } + } + +} diff --git a/test/tools/javac/flow/T8030218/CompileTimeErrorForNonAssignedStaticFieldTest.out b/test/tools/javac/flow/T8030218/CompileTimeErrorForNonAssignedStaticFieldTest.out new file mode 100644 index 0000000000000000000000000000000000000000..7821299792fb9dc0dac4483b00f2232cae755c67 --- /dev/null +++ b/test/tools/javac/flow/T8030218/CompileTimeErrorForNonAssignedStaticFieldTest.out @@ -0,0 +1,2 @@ +CompileTimeErrorForNonAssignedStaticFieldTest.java:14:5: compiler.err.var.might.not.have.been.initialized: i +1 error diff --git a/test/tools/javac/lambda/InnerConstructor.java b/test/tools/javac/lambda/InnerConstructor.java index 3675020c9d8acbc4b70c5f358ef7820167b4ec6b..28a33908a080812301935463491c7e86359d7f2b 100644 --- a/test/tools/javac/lambda/InnerConstructor.java +++ b/test/tools/javac/lambda/InnerConstructor.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2012, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2012, 2014, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -23,7 +23,7 @@ /* * @test - * @bug 8003280 + * @bug 8003280 8003306 * @summary Add lambda tests * Regression test JDK-8003306 inner class constructor in lambda * @author Robert Field diff --git a/test/tools/javac/lambda/intersection/IntersectionTargetTypeTest.java b/test/tools/javac/lambda/intersection/IntersectionTargetTypeTest.java index 36e18611ba5decf7e3c29036606e278fd26b98a0..4b8ec208d158af2060915a8e78373855786fdfc0 100644 --- a/test/tools/javac/lambda/intersection/IntersectionTargetTypeTest.java +++ b/test/tools/javac/lambda/intersection/IntersectionTargetTypeTest.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2012, 2013, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2012, 2014, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -23,7 +23,7 @@ /* * @test - * @bug 8002099 + * @bug 8002099 8010822 * @summary Add support for intersection types in cast expression */ diff --git a/test/tools/javac/lambda/separate/Test.java b/test/tools/javac/lambda/separate/Test.java index 7aa6b2c5c0885f2b3532b01996dc69a7e8d12d28..14bfd493500f8b4aeaa1b07ab9471ccb7479bafd 100644 --- a/test/tools/javac/lambda/separate/Test.java +++ b/test/tools/javac/lambda/separate/Test.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2012, 2013, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2012, 2014, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -23,6 +23,7 @@ /* * @test + * @bug 8008708 * @compile Foo.java * @compile Test.java */ diff --git a/test/tools/javac/processing/environment/round/BuriedAnnotations.java b/test/tools/javac/processing/environment/round/BuriedAnnotations.java index fe52282cb07813023986b16d5a8c4b22cb72234d..f122d92432651516d7cb7cee0ebd7cbe821f683d 100644 --- a/test/tools/javac/processing/environment/round/BuriedAnnotations.java +++ b/test/tools/javac/processing/environment/round/BuriedAnnotations.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2006, 2007, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2006, 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 @@ -22,7 +22,7 @@ */ /** - * Class to hold annotations for ElementsAnnotatedWithTest. + * Class to hold annotations for TestElementsAnnotatedWith. */ @AnnotatedElementInfo(annotationName="java.lang.SuppressWarnings", diff --git a/test/tools/javac/processing/environment/round/ErroneousAnnotations.java b/test/tools/javac/processing/environment/round/ErroneousAnnotations.java new file mode 100644 index 0000000000000000000000000000000000000000..156b88d36c93d9d43a192042fdf3182ee0117828 --- /dev/null +++ b/test/tools/javac/processing/environment/round/ErroneousAnnotations.java @@ -0,0 +1,12 @@ +/** /nodynamiccopyright/ + * Class to hold annotations for TestElementsAnnotatedWith. + */ + +@AnnotatedElementInfo(annotationName="java.lang.SuppressWarnings", + expectedSize=0, + names={}) +@Undefined +public class ErroneousAnnotations { + @Undefined + private void foo() {return;} +} diff --git a/test/tools/javac/processing/environment/round/ErroneousAnnotations.out b/test/tools/javac/processing/environment/round/ErroneousAnnotations.out new file mode 100644 index 0000000000000000000000000000000000000000..923c4ef78373187073ae7a2bcf386d64e31703ed --- /dev/null +++ b/test/tools/javac/processing/environment/round/ErroneousAnnotations.out @@ -0,0 +1,4 @@ +ErroneousAnnotations.java:8:2: compiler.err.cant.resolve: kindname.class, Undefined, , +ErroneousAnnotations.java:10:6: compiler.err.cant.resolve.location: kindname.class, Undefined, , , (compiler.misc.location: kindname.class, ErroneousAnnotations, null) +2 errors +Results: [] diff --git a/test/tools/javac/processing/environment/round/Part1.java b/test/tools/javac/processing/environment/round/Part1.java index ffb9d20643b4dba00f4917fe51a9fca94613b4ef..5d050e9683475c1dca75a414dbfce2929ea63c4f 100644 --- a/test/tools/javac/processing/environment/round/Part1.java +++ b/test/tools/javac/processing/environment/round/Part1.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2006, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2006, 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 @@ -22,7 +22,7 @@ */ /** - * Class to hold annotations for ElementsAnnotatedWithTest. + * Class to hold annotations for TestElementsAnnotatedWith. */ @AnnotatedElementInfo(annotationName="java.lang.SuppressWarnings", diff --git a/test/tools/javac/processing/environment/round/Part2.java b/test/tools/javac/processing/environment/round/Part2.java index 2047b871eed66e94225c39f51324b277583b3951..db9f44dee4951499f887dd753e27bffbf15c57c9 100644 --- a/test/tools/javac/processing/environment/round/Part2.java +++ b/test/tools/javac/processing/environment/round/Part2.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2006, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2006, 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 @@ -22,7 +22,7 @@ */ /** - * Class to hold annotations for ElementsAnnotatedWithTest. + * Class to hold annotations for TestElementsAnnotatedWith. */ @SuppressWarnings("") public class Part2 { diff --git a/test/tools/javac/processing/environment/round/SurfaceAnnotations.java b/test/tools/javac/processing/environment/round/SurfaceAnnotations.java index ce351a28e4c6e7b3ec6a0269fb2b83aa517894c1..a7c60581c01ffd0d7d67d05eced7aefba27deb32 100644 --- a/test/tools/javac/processing/environment/round/SurfaceAnnotations.java +++ b/test/tools/javac/processing/environment/round/SurfaceAnnotations.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2006, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2006, 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 @@ -22,7 +22,7 @@ */ /** - * Class to hold annotations for ElementsAnnotatedWithTest. + * Class to hold annotations for TestElementsAnnotatedWith. */ @AnnotatedElementInfo(annotationName="java.lang.SuppressWarnings", diff --git a/test/tools/javac/processing/environment/round/TestElementsAnnotatedWith.java b/test/tools/javac/processing/environment/round/TestElementsAnnotatedWith.java index e658e2ab71db4fd13b168e50a2fad5a7d75ac8e3..3a020060d222ae6a9e365c876833428fddba12b7 100644 --- a/test/tools/javac/processing/environment/round/TestElementsAnnotatedWith.java +++ b/test/tools/javac/processing/environment/round/TestElementsAnnotatedWith.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2006, 2013, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2006, 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 @@ -23,7 +23,7 @@ /* * @test - * @bug 6397298 6400986 6425592 6449798 6453386 6508401 6498938 6911854 + * @bug 6397298 6400986 6425592 6449798 6453386 6508401 6498938 6911854 8030049 * @summary Tests that getElementsAnnotatedWith works properly. * @author Joseph D. Darcy * @library /tools/javac/lib @@ -37,23 +37,18 @@ * @compile -processor TestElementsAnnotatedWith -proc:only C2.java * @compile -processor TestElementsAnnotatedWith -proc:only Foo.java * @compile -processor TestElementsAnnotatedWith -proc:only TypeParameterAnnotations.java + * @compile/fail/ref=ErroneousAnnotations.out -processor TestElementsAnnotatedWith -proc:only -XDrawDiagnostics ErroneousAnnotations.java * @compile Foo.java * @compile/process -processor TestElementsAnnotatedWith -proc:only Foo */ import java.lang.annotation.Annotation; -import java.io.*; import java.util.Collections; import java.util.Set; import java.util.HashSet; -import java.util.List; -import java.util.ArrayList; import java.util.Arrays; import javax.annotation.processing.*; -import javax.tools.*; -import javax.lang.model.SourceVersion; import javax.lang.model.element.*; -import javax.lang.model.util.*; import static javax.lang.model.util.ElementFilter.*; /** diff --git a/test/tools/javac/processing/environment/round/TypeParameterAnnotations.java b/test/tools/javac/processing/environment/round/TypeParameterAnnotations.java index 0b3ef05ceef9bb9f342623c738f14914c568a29c..ecefb3b3a5ab3c49cf93ad152d3e5b63bd23471d 100644 --- a/test/tools/javac/processing/environment/round/TypeParameterAnnotations.java +++ b/test/tools/javac/processing/environment/round/TypeParameterAnnotations.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2013, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2013, 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 @@ -22,7 +22,7 @@ */ /** - * Class to hold annotations for ElementsAnnotatedWithTest. + * Class to hold annotations for TestElementsAnnotatedWith. */ @AnnotatedElementInfo(annotationName="TpAnno", diff --git a/test/tools/javac/resolve/ResolveHarness.java b/test/tools/javac/resolve/ResolveHarness.java index 2512f54f0810eea128f72b9047e52be575d32160..7d79f1c851fc11758754b8599cfcebf4aff6f4aa 100644 --- a/test/tools/javac/resolve/ResolveHarness.java +++ b/test/tools/javac/resolve/ResolveHarness.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2011, 2013, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2011, 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 @@ -23,7 +23,7 @@ /* * @test - * @bug 7098660 + * @bug 7098660 8014649 * @summary Write better overload resolution/inference tests * @library /tools/javac/lib * @build JavacTestingAbstractProcessor ResolveHarness