From 564807c643b5f561411f537ca4f8ae77832b175e Mon Sep 17 00:00:00 2001 From: Athijegannathan Sundararajan Date: Tue, 19 Oct 2010 11:47:17 +0530 Subject: [PATCH 01/11] 6551367: javadoc throws ClassCastException when an @link tries to reference constructor Reviewed-by: jjg, mcimadamore --- .../com/sun/tools/javadoc/ClassDocImpl.java | 7 ++- .../classes/com/sun/tools/javadoc/DocEnv.java | 2 + langtools/test/tools/javadoc/T6551367.java | 54 +++++++++++++++++++ 3 files changed, 62 insertions(+), 1 deletion(-) create mode 100644 langtools/test/tools/javadoc/T6551367.java diff --git a/langtools/src/share/classes/com/sun/tools/javadoc/ClassDocImpl.java b/langtools/src/share/classes/com/sun/tools/javadoc/ClassDocImpl.java index b0908b9b2f7..0b083af6d8c 100644 --- a/langtools/src/share/classes/com/sun/tools/javadoc/ClassDocImpl.java +++ b/langtools/src/share/classes/com/sun/tools/javadoc/ClassDocImpl.java @@ -850,6 +850,12 @@ public class ClassDocImpl extends ProgramElementDocImpl implements ClassDoc { String[] paramTypes, Set searched) { //### Note that this search is not necessarily what the compiler would do! + Names names = tsym.name.table.names; + // do not match constructors + if (names.init.contentEquals(methodName)) { + return null; + } + ClassDocImpl cdi; MethodDocImpl mdi; @@ -876,7 +882,6 @@ public class ClassDocImpl extends ProgramElementDocImpl implements ClassDoc { *---------------------------------*/ // search current class - Names names = tsym.name.table.names; Scope.Entry e = tsym.members().lookup(names.fromString(methodName)); //### Using modifier filter here isn't really correct, diff --git a/langtools/src/share/classes/com/sun/tools/javadoc/DocEnv.java b/langtools/src/share/classes/com/sun/tools/javadoc/DocEnv.java index 5673bcfc92d..b10e2d740a6 100644 --- a/langtools/src/share/classes/com/sun/tools/javadoc/DocEnv.java +++ b/langtools/src/share/classes/com/sun/tools/javadoc/DocEnv.java @@ -637,6 +637,7 @@ public class DocEnv { * Should be called only on symbols representing methods. */ public MethodDocImpl getMethodDoc(MethodSymbol meth) { + assert !meth.isConstructor() : "not expecting a constructor symbol"; MethodDocImpl result = (MethodDocImpl)methodMap.get(meth); if (result != null) return result; result = new MethodDocImpl(this, meth); @@ -665,6 +666,7 @@ public class DocEnv { * Should be called only on symbols representing constructors. */ public ConstructorDocImpl getConstructorDoc(MethodSymbol meth) { + assert meth.isConstructor() : "expecting a constructor symbol"; ConstructorDocImpl result = (ConstructorDocImpl)methodMap.get(meth); if (result != null) return result; result = new ConstructorDocImpl(this, meth); diff --git a/langtools/test/tools/javadoc/T6551367.java b/langtools/test/tools/javadoc/T6551367.java new file mode 100644 index 00000000000..04e6bdc1bde --- /dev/null +++ b/langtools/test/tools/javadoc/T6551367.java @@ -0,0 +1,54 @@ +/* + * Copyright (c) 2010, 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 6551367 + * @summary javadoc throws ClassCastException when an link tag tries to reference constructor. + * @author A. Sundararajan + * @run main T6551367 T6551367.java + */ + +import com.sun.javadoc.*; +import java.io.File; +import static com.sun.tools.javadoc.Main.execute; + +public class T6551367 extends com.sun.tools.doclets.standard.Standard { + public T6551367() {} + + /** Here, in the javadoc for this method, I try to link to + * {@link # a constructor}. + */ + public static void main(String... args) { + File testSrc = new File(System.getProperty("test.src", ".")); + File destDir = new File(System.getProperty("user.dir", ".")); + for (String file : args) { + File source = new File(testSrc, file); + int rc = execute("javadoc", "T6551367", + T6551367.class.getClassLoader(), + new String[]{source.getPath(), "-d", destDir.getAbsolutePath()}); + if (rc != 0) + throw new Error("unexpected exit from javadoc: " + rc); + } + } +} From bf00a77f2d540434970d23379f92dd152f49a0ee Mon Sep 17 00:00:00 2001 From: Jonathan Gibbons Date: Tue, 19 Oct 2010 15:02:48 -0700 Subject: [PATCH 02/11] 6987760: remove 308 support from JDK7 Reviewed-by: darcy, mcimadamore --- .../sun/source/tree/AnnotatedTypeTree.java | 47 -- .../com/sun/source/tree/MethodTree.java | 2 +- .../classes/com/sun/source/tree/Tree.java | 2 +- .../com/sun/source/tree/TreeVisitor.java | 2 +- .../sun/source/tree/TypeParameterTree.java | 2 +- .../source/util/AbstractTypeProcessor.java | 245 ---------- .../sun/source/util/SimpleTreeVisitor.java | 6 +- .../com/sun/source/util/TreeScanner.java | 16 +- .../sun/tools/javac/code/TypeAnnotations.java | 14 +- .../sun/tools/javac/parser/JavacParser.java | 422 +++--------------- .../JavacProcessingEnvironment.java | 6 +- .../tools/javac/resources/compiler.properties | 6 +- .../com/sun/tools/javac/tree/JCTree.java | 17 +- .../com/sun/tools/javac/tree/TreeCopier.java | 12 +- langtools/test/tools/javac/T6985181.java | 86 ---- .../javac/annotations/6881115/T6881115.java | 4 +- .../javac/annotations/6881115/T6881115.out | 7 +- .../examples/TypeAnnotationsNotSupported.java | 33 -- .../model/element/TestAnonClassNames.java | 9 +- .../test/tools/javac/tree/TreePosTest.java | 4 +- .../javac/treeannotests/AnnoTreeTests.java | 44 -- .../typeAnnotations/6967002/T6967002.java | 35 -- .../typeAnnotations/6967002/T6967002.out | 8 - .../javac/typeAnnotations/InnerClass.java | 59 --- .../typeAnnotations/MultipleTargets.java | 41 -- .../typeAnnotations/TypeParameterTarget.java | 46 -- .../javac/typeAnnotations/TypeUseTarget.java | 55 --- .../typeAnnotations/attribution/Scopes.java | 38 -- .../typeAnnotations/classfile/DeadCode.java | 181 -------- .../failures/AnnotationVersion.java | 12 - .../failures/AnnotationVersion.out | 2 - .../failures/IncompleteArray.java | 12 - .../failures/IncompleteArray.out | 2 - .../failures/IncompleteVararg.java | 13 - .../failures/IncompleteVararg.out | 2 - .../typeAnnotations/failures/IndexArray.java | 13 - .../typeAnnotations/failures/IndexArray.out | 2 - .../typeAnnotations/failures/LintCast.java | 42 -- .../typeAnnotations/failures/LintCast.out | 6 - .../typeAnnotations/failures/OldArray.java | 35 -- .../typeAnnotations/failures/Scopes.java | 10 - .../javac/typeAnnotations/failures/Scopes.out | 2 - .../failures/StaticFields.java | 13 - .../typeAnnotations/failures/StaticFields.out | 2 - .../failures/StaticMethods.java | 12 - .../failures/StaticMethods.out | 2 - .../failures/VoidGenericMethod.java | 35 -- .../arrayclass/DuplicateAnnotationValue.java | 14 - .../arrayclass/DuplicateAnnotationValue.out | 2 - .../arrayclass/DuplicateTypeAnnotation.java | 15 - .../arrayclass/DuplicateTypeAnnotation.out | 2 - .../common/arrayclass/InvalidLocation.java | 16 - .../common/arrayclass/InvalidLocation.out | 2 - .../arrayclass/MissingAnnotationValue.java | 14 - .../arrayclass/MissingAnnotationValue.out | 2 - .../arrays/DuplicateAnnotationValue.java | 14 - .../arrays/DuplicateAnnotationValue.out | 2 - .../arrays/DuplicateTypeAnnotation.java | 15 - .../common/arrays/DuplicateTypeAnnotation.out | 2 - .../common/arrays/InvalidLocation.java | 16 - .../common/arrays/InvalidLocation.out | 2 - .../common/arrays/MissingAnnotationValue.java | 14 - .../common/arrays/MissingAnnotationValue.out | 2 - .../DuplicateAnnotationValue.java | 14 - .../DuplicateAnnotationValue.out | 2 - .../DuplicateTypeAnnotation.java | 14 - .../DuplicateTypeAnnotation.out | 2 - .../innertypeparams/InvalidLocation.java | 15 - .../innertypeparams/InvalidLocation.out | 2 - .../MissingAnnotationValue.java | 14 - .../MissingAnnotationValue.out | 2 - .../newarray/DuplicateAnnotationValue.java | 14 - .../newarray/DuplicateAnnotationValue.out | 2 - .../newarray/DuplicateTypeAnnotation.java | 15 - .../newarray/DuplicateTypeAnnotation.out | 2 - .../common/newarray/InvalidLocation.java | 16 - .../common/newarray/InvalidLocation.out | 2 - .../newarray/MissingAnnotationValue.java | 14 - .../newarray/MissingAnnotationValue.out | 2 - .../parambounds/DuplicateAnnotationValue.java | 11 - .../parambounds/DuplicateAnnotationValue.out | 2 - .../parambounds/DuplicateTypeAnnotation.java | 12 - .../parambounds/DuplicateTypeAnnotation.out | 2 - .../common/parambounds/InvalidLocation.java | 13 - .../common/parambounds/InvalidLocation.out | 2 - .../parambounds/MissingAnnotationValue.java | 11 - .../parambounds/MissingAnnotationValue.out | 2 - .../receiver/DuplicateAnnotationValue.java | 12 - .../receiver/DuplicateAnnotationValue.out | 2 - .../receiver/DuplicateTypeAnnotation.java | 13 - .../receiver/DuplicateTypeAnnotation.out | 2 - .../common/receiver/InvalidLocation.java | 15 - .../common/receiver/InvalidLocation.out | 2 - .../receiver/MissingAnnotationValue.java | 12 - .../receiver/MissingAnnotationValue.out | 2 - .../common/rest/DuplicateAnnotationValue.java | 14 - .../common/rest/DuplicateAnnotationValue.out | 2 - .../common/rest/DuplicateTypeAnnotation.java | 15 - .../common/rest/DuplicateTypeAnnotation.out | 2 - .../failures/common/rest/InvalidLocation.java | 16 - .../failures/common/rest/InvalidLocation.out | 2 - .../common/rest/MissingAnnotationValue.java | 14 - .../common/rest/MissingAnnotationValue.out | 2 - .../typeArgs/DuplicateAnnotationValue.java | 12 - .../typeArgs/DuplicateAnnotationValue.out | 2 - .../typeArgs/DuplicateTypeAnnotation.java | 13 - .../typeArgs/DuplicateTypeAnnotation.out | 2 - .../common/typeArgs/InvalidLocation.java | 14 - .../common/typeArgs/InvalidLocation.out | 2 - .../typeArgs/MissingAnnotationValue.java | 12 - .../typeArgs/MissingAnnotationValue.out | 2 - .../typeparams/DuplicateAnnotationValue.java | 11 - .../typeparams/DuplicateAnnotationValue.out | 2 - .../typeparams/DuplicateTypeAnnotation.java | 12 - .../typeparams/DuplicateTypeAnnotation.out | 2 - .../common/typeparams/InvalidLocation.java | 13 - .../common/typeparams/InvalidLocation.out | 2 - .../typeparams/MissingAnnotationValue.java | 11 - .../typeparams/MissingAnnotationValue.out | 2 - .../wildcards/DuplicateAnnotationValue.java | 12 - .../wildcards/DuplicateAnnotationValue.out | 2 - .../wildcards/DuplicateTypeAnnotation.java | 13 - .../wildcards/DuplicateTypeAnnotation.out | 2 - .../common/wildcards/InvalidLocation.java | 14 - .../common/wildcards/InvalidLocation.out | 2 - .../wildcards/MissingAnnotationValue.java | 12 - .../wildcards/MissingAnnotationValue.out | 2 - .../failures/target/Constructor.java | 17 - .../failures/target/Constructor.out | 2 - .../failures/target/IncompleteArray.java | 12 - .../failures/target/IncompleteArray.out | 2 - .../failures/target/NotTypeParameter.java | 17 - .../failures/target/NotTypeParameter.out | 3 - .../failures/target/NotTypeUse.java | 17 - .../failures/target/NotTypeUse.out | 2 - .../failures/target/VoidMethod.java | 17 - .../failures/target/VoidMethod.out | 2 - .../newlocations/BasicTest.java | 4 +- .../newlocations/BasicTest.out | 66 +++ .../newlocations/ClassExtends.java | 40 -- .../newlocations/ClassLiterals.java | 48 -- .../newlocations/ClassParameters.java | 56 --- .../newlocations/ConstructorTypeArgs.java | 55 --- .../newlocations/Expressions.java | 75 ---- .../typeAnnotations/newlocations/Fields.java | 69 --- .../newlocations/LocalVariables.java | 77 ---- .../newlocations/MethodReturnType.java | 71 --- .../newlocations/MethodTypeArgs.java | 62 --- .../newlocations/MethodTypeParameters.java | 48 -- .../newlocations/Parameters.java | 51 --- .../newlocations/Receivers.java | 56 --- .../typeAnnotations/newlocations/Throws.java | 47 -- .../newlocations/TypeCasts.java | 44 -- .../newlocations/TypeParameters.java | 50 --- .../newlocations/Wildcards.java | 70 --- .../typeAnnotations/ArrayClassLiterals.java | 183 -------- .../typeAnnotations/ArrayClassLiterals2.java | 82 ---- .../javap/typeAnnotations/ClassLiterals.java | 174 -------- .../typeAnnotations/JSR175Annotations.java | 152 ------- .../tools/javap/typeAnnotations/NewArray.java | 175 -------- .../tools/javap/typeAnnotations/Presence.java | 189 -------- .../javap/typeAnnotations/PresenceInner.java | 185 -------- .../tools/javap/typeAnnotations/T6855990.java | 51 --- .../javap/typeAnnotations/Visibility.java | 139 ------ 164 files changed, 179 insertions(+), 4518 deletions(-) delete mode 100644 langtools/src/share/classes/com/sun/source/tree/AnnotatedTypeTree.java delete mode 100644 langtools/src/share/classes/com/sun/source/util/AbstractTypeProcessor.java delete mode 100644 langtools/test/tools/javac/T6985181.java delete mode 100644 langtools/test/tools/javac/diags/examples/TypeAnnotationsNotSupported.java delete mode 100644 langtools/test/tools/javac/treeannotests/AnnoTreeTests.java delete mode 100644 langtools/test/tools/javac/typeAnnotations/6967002/T6967002.java delete mode 100644 langtools/test/tools/javac/typeAnnotations/6967002/T6967002.out delete mode 100644 langtools/test/tools/javac/typeAnnotations/InnerClass.java delete mode 100644 langtools/test/tools/javac/typeAnnotations/MultipleTargets.java delete mode 100644 langtools/test/tools/javac/typeAnnotations/TypeParameterTarget.java delete mode 100644 langtools/test/tools/javac/typeAnnotations/TypeUseTarget.java delete mode 100644 langtools/test/tools/javac/typeAnnotations/attribution/Scopes.java delete mode 100644 langtools/test/tools/javac/typeAnnotations/classfile/DeadCode.java delete mode 100644 langtools/test/tools/javac/typeAnnotations/failures/AnnotationVersion.java delete mode 100644 langtools/test/tools/javac/typeAnnotations/failures/AnnotationVersion.out delete mode 100644 langtools/test/tools/javac/typeAnnotations/failures/IncompleteArray.java delete mode 100644 langtools/test/tools/javac/typeAnnotations/failures/IncompleteArray.out delete mode 100644 langtools/test/tools/javac/typeAnnotations/failures/IncompleteVararg.java delete mode 100644 langtools/test/tools/javac/typeAnnotations/failures/IncompleteVararg.out delete mode 100644 langtools/test/tools/javac/typeAnnotations/failures/IndexArray.java delete mode 100644 langtools/test/tools/javac/typeAnnotations/failures/IndexArray.out delete mode 100644 langtools/test/tools/javac/typeAnnotations/failures/LintCast.java delete mode 100644 langtools/test/tools/javac/typeAnnotations/failures/LintCast.out delete mode 100644 langtools/test/tools/javac/typeAnnotations/failures/OldArray.java delete mode 100644 langtools/test/tools/javac/typeAnnotations/failures/Scopes.java delete mode 100644 langtools/test/tools/javac/typeAnnotations/failures/Scopes.out delete mode 100644 langtools/test/tools/javac/typeAnnotations/failures/StaticFields.java delete mode 100644 langtools/test/tools/javac/typeAnnotations/failures/StaticFields.out delete mode 100644 langtools/test/tools/javac/typeAnnotations/failures/StaticMethods.java delete mode 100644 langtools/test/tools/javac/typeAnnotations/failures/StaticMethods.out delete mode 100644 langtools/test/tools/javac/typeAnnotations/failures/VoidGenericMethod.java delete mode 100644 langtools/test/tools/javac/typeAnnotations/failures/common/arrayclass/DuplicateAnnotationValue.java delete mode 100644 langtools/test/tools/javac/typeAnnotations/failures/common/arrayclass/DuplicateAnnotationValue.out delete mode 100644 langtools/test/tools/javac/typeAnnotations/failures/common/arrayclass/DuplicateTypeAnnotation.java delete mode 100644 langtools/test/tools/javac/typeAnnotations/failures/common/arrayclass/DuplicateTypeAnnotation.out delete mode 100644 langtools/test/tools/javac/typeAnnotations/failures/common/arrayclass/InvalidLocation.java delete mode 100644 langtools/test/tools/javac/typeAnnotations/failures/common/arrayclass/InvalidLocation.out delete mode 100644 langtools/test/tools/javac/typeAnnotations/failures/common/arrayclass/MissingAnnotationValue.java delete mode 100644 langtools/test/tools/javac/typeAnnotations/failures/common/arrayclass/MissingAnnotationValue.out delete mode 100644 langtools/test/tools/javac/typeAnnotations/failures/common/arrays/DuplicateAnnotationValue.java delete mode 100644 langtools/test/tools/javac/typeAnnotations/failures/common/arrays/DuplicateAnnotationValue.out delete mode 100644 langtools/test/tools/javac/typeAnnotations/failures/common/arrays/DuplicateTypeAnnotation.java delete mode 100644 langtools/test/tools/javac/typeAnnotations/failures/common/arrays/DuplicateTypeAnnotation.out delete mode 100644 langtools/test/tools/javac/typeAnnotations/failures/common/arrays/InvalidLocation.java delete mode 100644 langtools/test/tools/javac/typeAnnotations/failures/common/arrays/InvalidLocation.out delete mode 100644 langtools/test/tools/javac/typeAnnotations/failures/common/arrays/MissingAnnotationValue.java delete mode 100644 langtools/test/tools/javac/typeAnnotations/failures/common/arrays/MissingAnnotationValue.out delete mode 100644 langtools/test/tools/javac/typeAnnotations/failures/common/innertypeparams/DuplicateAnnotationValue.java delete mode 100644 langtools/test/tools/javac/typeAnnotations/failures/common/innertypeparams/DuplicateAnnotationValue.out delete mode 100644 langtools/test/tools/javac/typeAnnotations/failures/common/innertypeparams/DuplicateTypeAnnotation.java delete mode 100644 langtools/test/tools/javac/typeAnnotations/failures/common/innertypeparams/DuplicateTypeAnnotation.out delete mode 100644 langtools/test/tools/javac/typeAnnotations/failures/common/innertypeparams/InvalidLocation.java delete mode 100644 langtools/test/tools/javac/typeAnnotations/failures/common/innertypeparams/InvalidLocation.out delete mode 100644 langtools/test/tools/javac/typeAnnotations/failures/common/innertypeparams/MissingAnnotationValue.java delete mode 100644 langtools/test/tools/javac/typeAnnotations/failures/common/innertypeparams/MissingAnnotationValue.out delete mode 100644 langtools/test/tools/javac/typeAnnotations/failures/common/newarray/DuplicateAnnotationValue.java delete mode 100644 langtools/test/tools/javac/typeAnnotations/failures/common/newarray/DuplicateAnnotationValue.out delete mode 100644 langtools/test/tools/javac/typeAnnotations/failures/common/newarray/DuplicateTypeAnnotation.java delete mode 100644 langtools/test/tools/javac/typeAnnotations/failures/common/newarray/DuplicateTypeAnnotation.out delete mode 100644 langtools/test/tools/javac/typeAnnotations/failures/common/newarray/InvalidLocation.java delete mode 100644 langtools/test/tools/javac/typeAnnotations/failures/common/newarray/InvalidLocation.out delete mode 100644 langtools/test/tools/javac/typeAnnotations/failures/common/newarray/MissingAnnotationValue.java delete mode 100644 langtools/test/tools/javac/typeAnnotations/failures/common/newarray/MissingAnnotationValue.out delete mode 100644 langtools/test/tools/javac/typeAnnotations/failures/common/parambounds/DuplicateAnnotationValue.java delete mode 100644 langtools/test/tools/javac/typeAnnotations/failures/common/parambounds/DuplicateAnnotationValue.out delete mode 100644 langtools/test/tools/javac/typeAnnotations/failures/common/parambounds/DuplicateTypeAnnotation.java delete mode 100644 langtools/test/tools/javac/typeAnnotations/failures/common/parambounds/DuplicateTypeAnnotation.out delete mode 100644 langtools/test/tools/javac/typeAnnotations/failures/common/parambounds/InvalidLocation.java delete mode 100644 langtools/test/tools/javac/typeAnnotations/failures/common/parambounds/InvalidLocation.out delete mode 100644 langtools/test/tools/javac/typeAnnotations/failures/common/parambounds/MissingAnnotationValue.java delete mode 100644 langtools/test/tools/javac/typeAnnotations/failures/common/parambounds/MissingAnnotationValue.out delete mode 100644 langtools/test/tools/javac/typeAnnotations/failures/common/receiver/DuplicateAnnotationValue.java delete mode 100644 langtools/test/tools/javac/typeAnnotations/failures/common/receiver/DuplicateAnnotationValue.out delete mode 100644 langtools/test/tools/javac/typeAnnotations/failures/common/receiver/DuplicateTypeAnnotation.java delete mode 100644 langtools/test/tools/javac/typeAnnotations/failures/common/receiver/DuplicateTypeAnnotation.out delete mode 100644 langtools/test/tools/javac/typeAnnotations/failures/common/receiver/InvalidLocation.java delete mode 100644 langtools/test/tools/javac/typeAnnotations/failures/common/receiver/InvalidLocation.out delete mode 100644 langtools/test/tools/javac/typeAnnotations/failures/common/receiver/MissingAnnotationValue.java delete mode 100644 langtools/test/tools/javac/typeAnnotations/failures/common/receiver/MissingAnnotationValue.out delete mode 100644 langtools/test/tools/javac/typeAnnotations/failures/common/rest/DuplicateAnnotationValue.java delete mode 100644 langtools/test/tools/javac/typeAnnotations/failures/common/rest/DuplicateAnnotationValue.out delete mode 100644 langtools/test/tools/javac/typeAnnotations/failures/common/rest/DuplicateTypeAnnotation.java delete mode 100644 langtools/test/tools/javac/typeAnnotations/failures/common/rest/DuplicateTypeAnnotation.out delete mode 100644 langtools/test/tools/javac/typeAnnotations/failures/common/rest/InvalidLocation.java delete mode 100644 langtools/test/tools/javac/typeAnnotations/failures/common/rest/InvalidLocation.out delete mode 100644 langtools/test/tools/javac/typeAnnotations/failures/common/rest/MissingAnnotationValue.java delete mode 100644 langtools/test/tools/javac/typeAnnotations/failures/common/rest/MissingAnnotationValue.out delete mode 100644 langtools/test/tools/javac/typeAnnotations/failures/common/typeArgs/DuplicateAnnotationValue.java delete mode 100644 langtools/test/tools/javac/typeAnnotations/failures/common/typeArgs/DuplicateAnnotationValue.out delete mode 100644 langtools/test/tools/javac/typeAnnotations/failures/common/typeArgs/DuplicateTypeAnnotation.java delete mode 100644 langtools/test/tools/javac/typeAnnotations/failures/common/typeArgs/DuplicateTypeAnnotation.out delete mode 100644 langtools/test/tools/javac/typeAnnotations/failures/common/typeArgs/InvalidLocation.java delete mode 100644 langtools/test/tools/javac/typeAnnotations/failures/common/typeArgs/InvalidLocation.out delete mode 100644 langtools/test/tools/javac/typeAnnotations/failures/common/typeArgs/MissingAnnotationValue.java delete mode 100644 langtools/test/tools/javac/typeAnnotations/failures/common/typeArgs/MissingAnnotationValue.out delete mode 100644 langtools/test/tools/javac/typeAnnotations/failures/common/typeparams/DuplicateAnnotationValue.java delete mode 100644 langtools/test/tools/javac/typeAnnotations/failures/common/typeparams/DuplicateAnnotationValue.out delete mode 100644 langtools/test/tools/javac/typeAnnotations/failures/common/typeparams/DuplicateTypeAnnotation.java delete mode 100644 langtools/test/tools/javac/typeAnnotations/failures/common/typeparams/DuplicateTypeAnnotation.out delete mode 100644 langtools/test/tools/javac/typeAnnotations/failures/common/typeparams/InvalidLocation.java delete mode 100644 langtools/test/tools/javac/typeAnnotations/failures/common/typeparams/InvalidLocation.out delete mode 100644 langtools/test/tools/javac/typeAnnotations/failures/common/typeparams/MissingAnnotationValue.java delete mode 100644 langtools/test/tools/javac/typeAnnotations/failures/common/typeparams/MissingAnnotationValue.out delete mode 100644 langtools/test/tools/javac/typeAnnotations/failures/common/wildcards/DuplicateAnnotationValue.java delete mode 100644 langtools/test/tools/javac/typeAnnotations/failures/common/wildcards/DuplicateAnnotationValue.out delete mode 100644 langtools/test/tools/javac/typeAnnotations/failures/common/wildcards/DuplicateTypeAnnotation.java delete mode 100644 langtools/test/tools/javac/typeAnnotations/failures/common/wildcards/DuplicateTypeAnnotation.out delete mode 100644 langtools/test/tools/javac/typeAnnotations/failures/common/wildcards/InvalidLocation.java delete mode 100644 langtools/test/tools/javac/typeAnnotations/failures/common/wildcards/InvalidLocation.out delete mode 100644 langtools/test/tools/javac/typeAnnotations/failures/common/wildcards/MissingAnnotationValue.java delete mode 100644 langtools/test/tools/javac/typeAnnotations/failures/common/wildcards/MissingAnnotationValue.out delete mode 100644 langtools/test/tools/javac/typeAnnotations/failures/target/Constructor.java delete mode 100644 langtools/test/tools/javac/typeAnnotations/failures/target/Constructor.out delete mode 100644 langtools/test/tools/javac/typeAnnotations/failures/target/IncompleteArray.java delete mode 100644 langtools/test/tools/javac/typeAnnotations/failures/target/IncompleteArray.out delete mode 100644 langtools/test/tools/javac/typeAnnotations/failures/target/NotTypeParameter.java delete mode 100644 langtools/test/tools/javac/typeAnnotations/failures/target/NotTypeParameter.out delete mode 100644 langtools/test/tools/javac/typeAnnotations/failures/target/NotTypeUse.java delete mode 100644 langtools/test/tools/javac/typeAnnotations/failures/target/NotTypeUse.out delete mode 100644 langtools/test/tools/javac/typeAnnotations/failures/target/VoidMethod.java delete mode 100644 langtools/test/tools/javac/typeAnnotations/failures/target/VoidMethod.out create mode 100644 langtools/test/tools/javac/typeAnnotations/newlocations/BasicTest.out delete mode 100644 langtools/test/tools/javac/typeAnnotations/newlocations/ClassExtends.java delete mode 100644 langtools/test/tools/javac/typeAnnotations/newlocations/ClassLiterals.java delete mode 100644 langtools/test/tools/javac/typeAnnotations/newlocations/ClassParameters.java delete mode 100644 langtools/test/tools/javac/typeAnnotations/newlocations/ConstructorTypeArgs.java delete mode 100644 langtools/test/tools/javac/typeAnnotations/newlocations/Expressions.java delete mode 100644 langtools/test/tools/javac/typeAnnotations/newlocations/Fields.java delete mode 100644 langtools/test/tools/javac/typeAnnotations/newlocations/LocalVariables.java delete mode 100644 langtools/test/tools/javac/typeAnnotations/newlocations/MethodReturnType.java delete mode 100644 langtools/test/tools/javac/typeAnnotations/newlocations/MethodTypeArgs.java delete mode 100644 langtools/test/tools/javac/typeAnnotations/newlocations/MethodTypeParameters.java delete mode 100644 langtools/test/tools/javac/typeAnnotations/newlocations/Parameters.java delete mode 100644 langtools/test/tools/javac/typeAnnotations/newlocations/Receivers.java delete mode 100644 langtools/test/tools/javac/typeAnnotations/newlocations/Throws.java delete mode 100644 langtools/test/tools/javac/typeAnnotations/newlocations/TypeCasts.java delete mode 100644 langtools/test/tools/javac/typeAnnotations/newlocations/TypeParameters.java delete mode 100644 langtools/test/tools/javac/typeAnnotations/newlocations/Wildcards.java delete mode 100644 langtools/test/tools/javap/typeAnnotations/ArrayClassLiterals.java delete mode 100644 langtools/test/tools/javap/typeAnnotations/ArrayClassLiterals2.java delete mode 100644 langtools/test/tools/javap/typeAnnotations/ClassLiterals.java delete mode 100644 langtools/test/tools/javap/typeAnnotations/JSR175Annotations.java delete mode 100644 langtools/test/tools/javap/typeAnnotations/NewArray.java delete mode 100644 langtools/test/tools/javap/typeAnnotations/Presence.java delete mode 100644 langtools/test/tools/javap/typeAnnotations/PresenceInner.java delete mode 100644 langtools/test/tools/javap/typeAnnotations/T6855990.java delete mode 100644 langtools/test/tools/javap/typeAnnotations/Visibility.java diff --git a/langtools/src/share/classes/com/sun/source/tree/AnnotatedTypeTree.java b/langtools/src/share/classes/com/sun/source/tree/AnnotatedTypeTree.java deleted file mode 100644 index 08683fb4dd5..00000000000 --- a/langtools/src/share/classes/com/sun/source/tree/AnnotatedTypeTree.java +++ /dev/null @@ -1,47 +0,0 @@ -/* - * Copyright (c) 2008, 2009, Oracle and/or its affiliates. All rights reserved. - * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. - * - * This code is free software; you can redistribute it and/or modify it - * under the terms of the GNU General Public License version 2 only, as - * published by the Free Software Foundation. Oracle designates this - * particular file as subject to the "Classpath" exception as provided - * by Oracle in the LICENSE file that accompanied this code. - * - * This code is distributed in the hope that it will be useful, but WITHOUT - * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or - * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License - * version 2 for more details (a copy is included in the LICENSE file that - * accompanied this code). - * - * You should have received a copy of the GNU General Public License version - * 2 along with this work; if not, write to the Free Software Foundation, - * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. - * - * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA - * or visit www.oracle.com if you need additional information or have any - * questions. - */ - -package com.sun.source.tree; - -import java.util.List; - -/** - * A tree node for an annotated type - * - * For example: - *
- *    {@code @}annotationType String
- *    {@code @}annotationType ( arguments ) Date
- * 
- * - * @see "JSR 308: Annotations on Java Types" - * - * @author Mahmood Ali - * @since 1.7 - */ -public interface AnnotatedTypeTree extends ExpressionTree { - List getAnnotations(); - ExpressionTree getUnderlyingType(); -} diff --git a/langtools/src/share/classes/com/sun/source/tree/MethodTree.java b/langtools/src/share/classes/com/sun/source/tree/MethodTree.java index 2e7cf4addb3..7f597606b66 100644 --- a/langtools/src/share/classes/com/sun/source/tree/MethodTree.java +++ b/langtools/src/share/classes/com/sun/source/tree/MethodTree.java @@ -53,7 +53,7 @@ public interface MethodTree extends Tree { Tree getReturnType(); List getTypeParameters(); List getParameters(); - List getReceiverAnnotations(); +//308 List getReceiverAnnotations(); List getThrows(); BlockTree getBody(); Tree getDefaultValue(); // for annotation types diff --git a/langtools/src/share/classes/com/sun/source/tree/Tree.java b/langtools/src/share/classes/com/sun/source/tree/Tree.java index 7e5ede9bf0a..95b2d85c9e6 100644 --- a/langtools/src/share/classes/com/sun/source/tree/Tree.java +++ b/langtools/src/share/classes/com/sun/source/tree/Tree.java @@ -46,7 +46,7 @@ public interface Tree { */ public enum Kind { - ANNOTATED_TYPE(AnnotatedTypeTree.class), +//308 ANNOTATED_TYPE(AnnotatedTypeTree.class), /** * Used for instances of {@link AnnotationTree}. diff --git a/langtools/src/share/classes/com/sun/source/tree/TreeVisitor.java b/langtools/src/share/classes/com/sun/source/tree/TreeVisitor.java index d36b3690232..6aba5d310e4 100644 --- a/langtools/src/share/classes/com/sun/source/tree/TreeVisitor.java +++ b/langtools/src/share/classes/com/sun/source/tree/TreeVisitor.java @@ -57,7 +57,7 @@ package com.sun.source.tree; * @since 1.6 */ public interface TreeVisitor { - R visitAnnotatedType(AnnotatedTypeTree node, P p); +//308 R visitAnnotatedType(AnnotatedTypeTree node, P p); R visitAnnotation(AnnotationTree node, P p); R visitMethodInvocation(MethodInvocationTree node, P p); R visitAssert(AssertTree node, P p); diff --git a/langtools/src/share/classes/com/sun/source/tree/TypeParameterTree.java b/langtools/src/share/classes/com/sun/source/tree/TypeParameterTree.java index 24f6e36884f..1ead8fa3e0c 100644 --- a/langtools/src/share/classes/com/sun/source/tree/TypeParameterTree.java +++ b/langtools/src/share/classes/com/sun/source/tree/TypeParameterTree.java @@ -47,5 +47,5 @@ import javax.lang.model.element.Name; public interface TypeParameterTree extends Tree { Name getName(); List getBounds(); - List getAnnotations(); +//308 List getAnnotations(); } diff --git a/langtools/src/share/classes/com/sun/source/util/AbstractTypeProcessor.java b/langtools/src/share/classes/com/sun/source/util/AbstractTypeProcessor.java deleted file mode 100644 index 2e1053f3232..00000000000 --- a/langtools/src/share/classes/com/sun/source/util/AbstractTypeProcessor.java +++ /dev/null @@ -1,245 +0,0 @@ -/* - * Copyright (c) 2009, Oracle and/or its affiliates. All rights reserved. - * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. - * - * This code is free software; you can redistribute it and/or modify it - * under the terms of the GNU General Public License version 2 only, as - * published by the Free Software Foundation. Oracle designates this - * particular file as subject to the "Classpath" exception as provided - * by Oracle in the LICENSE file that accompanied this code. - * - * This code is distributed in the hope that it will be useful, but WITHOUT - * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or - * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License - * version 2 for more details (a copy is included in the LICENSE file that - * accompanied this code). - * - * You should have received a copy of the GNU General Public License version - * 2 along with this work; if not, write to the Free Software Foundation, - * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. - * - * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA - * or visit www.oracle.com if you need additional information or have any - * questions. - */ - -package com.sun.source.util; - -import java.util.ArrayList; -import java.util.HashSet; -import java.util.List; -import java.util.Set; - -import javax.annotation.processing.*; -import javax.lang.model.element.Name; -import javax.lang.model.element.TypeElement; -import javax.lang.model.util.ElementFilter; - -import com.sun.tools.javac.processing.JavacProcessingEnvironment; -import com.sun.tools.javac.util.Context; -import com.sun.tools.javac.util.Log; - -import com.sun.source.tree.ClassTree; - -/** - * This class is an abstract annotation processor designed to be a - * convenient superclass for concrete "type processors", processors that - * require the type information in the processed source. - * - *

Type processing occurs in one round after the tool (e.g. java compiler) - * analyzes the source (all sources taken as input to the tool and sources - * generated by other annotation processors). - * - *

The tool infrastructure will interact with classes extending this abstract - * class as follows: - * - *

    - * [1-3: Identical to {@link Processor} life cycle] - * - *
  1. If an existing {@code Processor} object is not being used, to - * create an instance of a processor the tool calls the no-arg - * constructor of the processor class. - * - *
  2. Next, the tool calls the {@link #init init} method with - * an appropriate {@code ProcessingEnvironment}. - * - *
  3. Afterwards, the tool calls {@link #getSupportedAnnotationTypes - * getSupportedAnnotationTypes}, {@link #getSupportedOptions - * getSupportedOptions}, and {@link #getSupportedSourceVersion - * getSupportedSourceVersion}. These methods are only called once per - * run, not on each round. - * - * [4-5Unique to {@code AbstractTypeProcessor} subclasses] - * - *
  4. For each class containing a supported annotation, the tool calls - * {@link #typeProcess(TypeElement, TreePath) typeProcess} method on the - * {@code Processor}. The class is guaranteed to be type-checked Java code - * and all the tree type and symbol information is resolved. - * - *
  5. Finally, the tools calls the - * {@link #typeProcessingOver() typeProcessingOver} method - * on the {@code Processor}. - * - *
- * - *

The tool is permitted to ask type processors to process a class once - * it is analyzed before the rest of classes are analyzed. The tool is also - * permitted to stop type processing immediately if any errors are raised, - * without invoking {@code typeProcessingOver} - * - *

A subclass may override any of the methods in this class, as long as the - * general {@link javax.annotation.processing.Processor Processor} - * contract is obeyed, with one notable exception. - * {@link #process(Set, RoundEnvironment)} may not be overridden, as it - * is called during the regular annotation phase before classes are analyzed. - * - * @author Mahmood Ali - * @since 1.7 - */ -public abstract class AbstractTypeProcessor extends AbstractProcessor { - private final Set elements = new HashSet(); - private boolean hasInvokedTypeProcessingOver = false; - private JavacProcessingEnvironment env; - private final AttributionTaskListener listener = new AttributionTaskListener(); - - /** - * Constructor for subclasses to call. - */ - protected AbstractTypeProcessor() { } - - /** - * {@inheritDoc} - */ - @Override - public void init(ProcessingEnvironment env) { - super.init(env); - this.env = (JavacProcessingEnvironment)env; - prepareContext(this.env.getContext()); - } - - /** - * The use of this method is obsolete in type processors. The method is - * called during regular annotation processing phase only. - */ - @Override - public final boolean process(Set annotations, - RoundEnvironment roundEnv) { - for (TypeElement elem : ElementFilter.typesIn(roundEnv.getRootElements())) { - elements.add(elem.getQualifiedName()); - } - return false; - } - - /** - * Processes a fully analyzed class that contains a supported annotation - * (look {@link #getSupportedAnnotationTypes()}). - * - *

The passed class is always a valid type-checked Java code. - * - * @param element element of the analyzed class - * @param tree the tree path to the element, with the leaf being a - * {@link ClassTree} - */ - public abstract void typeProcess(TypeElement element, TreePath tree); - - /** - * A method to be called once all the classes are processed and no error - * is reported. - * - *

Subclasses may override this method to do any aggregate analysis - * (e.g. generate report, persistence) or resource deallocation. - * - *

If an error (a Java error or a processor error) is reported, this - * method is not guaranteed to be invoked. - */ - public void typeProcessingOver() { } - - /** - * adds a listener for attribution. - */ - private void prepareContext(Context context) { - TaskListener otherListener = context.get(TaskListener.class); - if (otherListener == null) { - context.put(TaskListener.class, listener); - } else { - // handle cases of multiple listeners - context.put(TaskListener.class, (TaskListener)null); - TaskListeners listeners = new TaskListeners(); - listeners.add(otherListener); - listeners.add(listener); - context.put(TaskListener.class, listeners); - } - } - - /** - * A task listener that invokes the processor whenever a class is fully - * analyzed. - */ - private final class AttributionTaskListener implements TaskListener { - - @Override - public void finished(TaskEvent e) { - Log log = Log.instance(env.getContext()); - - if (!hasInvokedTypeProcessingOver && elements.isEmpty() && log.nerrors == 0) { - typeProcessingOver(); - hasInvokedTypeProcessingOver = true; - } - - if (e.getKind() != TaskEvent.Kind.ANALYZE) - return; - - if (e.getTypeElement() == null) - throw new AssertionError("event task without a type element"); - if (e.getCompilationUnit() == null) - throw new AssertionError("even task without compilation unit"); - - if (!elements.remove(e.getTypeElement().getQualifiedName())) - return; - - if (log.nerrors != 0) - return; - - TypeElement elem = e.getTypeElement(); - TreePath p = Trees.instance(env).getPath(elem); - - typeProcess(elem, p); - - if (!hasInvokedTypeProcessingOver && elements.isEmpty() && log.nerrors == 0) { - typeProcessingOver(); - hasInvokedTypeProcessingOver = true; - } - } - - @Override - public void started(TaskEvent e) { } - - } - - /** - * A task listener multiplexer. - */ - private static class TaskListeners implements TaskListener { - private final List listeners = new ArrayList(); - - public void add(TaskListener listener) { - listeners.add(listener); - } - - public void remove(TaskListener listener) { - listeners.remove(listener); - } - - @Override - public void finished(TaskEvent e) { - for (TaskListener listener : listeners) - listener.finished(e); - } - - @Override - public void started(TaskEvent e) { - for (TaskListener listener : listeners) - listener.started(e); - } - } -} diff --git a/langtools/src/share/classes/com/sun/source/util/SimpleTreeVisitor.java b/langtools/src/share/classes/com/sun/source/util/SimpleTreeVisitor.java index fb60b890542..70b3435f9c8 100644 --- a/langtools/src/share/classes/com/sun/source/util/SimpleTreeVisitor.java +++ b/langtools/src/share/classes/com/sun/source/util/SimpleTreeVisitor.java @@ -248,9 +248,9 @@ public class SimpleTreeVisitor implements TreeVisitor { return defaultAction(node, p); } - public R visitAnnotatedType(AnnotatedTypeTree node, P p) { - return defaultAction(node, p); - } +//308 public R visitAnnotatedType(AnnotatedTypeTree node, P p) { +//308 return defaultAction(node, p); +//308 } public R visitErroneous(ErroneousTree node, P p) { return defaultAction(node, p); diff --git a/langtools/src/share/classes/com/sun/source/util/TreeScanner.java b/langtools/src/share/classes/com/sun/source/util/TreeScanner.java index 3a8f07aca99..4b537ed4614 100644 --- a/langtools/src/share/classes/com/sun/source/util/TreeScanner.java +++ b/langtools/src/share/classes/com/sun/source/util/TreeScanner.java @@ -138,7 +138,7 @@ public class TreeScanner implements TreeVisitor { r = scanAndReduce(node.getReturnType(), p, r); r = scanAndReduce(node.getTypeParameters(), p, r); r = scanAndReduce(node.getParameters(), p, r); - r = scanAndReduce(node.getReceiverAnnotations(), p, r); +//308 r = scanAndReduce(node.getReceiverAnnotations(), p, r); r = scanAndReduce(node.getThrows(), p, r); r = scanAndReduce(node.getBody(), p, r); r = scanAndReduce(node.getDefaultValue(), p, r); @@ -361,8 +361,8 @@ public class TreeScanner implements TreeVisitor { } public R visitTypeParameter(TypeParameterTree node, P p) { - R r = scan(node.getAnnotations(), p); - r = scanAndReduce(node.getBounds(), p, r); + R r = scan(node.getBounds(), p); +//308 R r = scanAndReduce(node.getAnnotations(), p, r); return r; } @@ -380,11 +380,11 @@ public class TreeScanner implements TreeVisitor { return r; } - public R visitAnnotatedType(AnnotatedTypeTree node, P p) { - R r = scan(node.getAnnotations(), p); - r = scanAndReduce(node.getUnderlyingType(), p, r); - return r; - } +//308 public R visitAnnotatedType(AnnotatedTypeTree node, P p) { +//308 R r = scan(node.getAnnotations(), p); +//308 r = scanAndReduce(node.getUnderlyingType(), p, r); +//308 return r; +//308 } public R visitOther(Tree node, P p) { return null; diff --git a/langtools/src/share/classes/com/sun/tools/javac/code/TypeAnnotations.java b/langtools/src/share/classes/com/sun/tools/javac/code/TypeAnnotations.java index d43828ae274..23aaed349c4 100644 --- a/langtools/src/share/classes/com/sun/tools/javac/code/TypeAnnotations.java +++ b/langtools/src/share/classes/com/sun/tools/javac/code/TypeAnnotations.java @@ -55,8 +55,8 @@ public class TypeAnnotations { } public void taFillAndLift(JCClassDecl tree, boolean visitBodies) { - new TypeAnnotationPositions().scan(tree); - new TypeAnnotationLift().scan(tree); +//308 new TypeAnnotationPositions().scan(tree); +//308 new TypeAnnotationLift().scan(tree); } private static class TypeAnnotationPositions extends TreeScanner { @@ -208,11 +208,11 @@ public class TypeAnnotations { } return p; - case ANNOTATED_TYPE: { - List newPath = path.tail; - return resolveFrame(newPath.head, newPath.tail.head, - newPath, p); - } +//308 case ANNOTATED_TYPE: { +//308 List newPath = path.tail; +//308 return resolveFrame(newPath.head, newPath.tail.head, +//308 newPath, p); +//308 } case METHOD_INVOCATION: { JCMethodInvocation invocation = (JCMethodInvocation)frame; diff --git a/langtools/src/share/classes/com/sun/tools/javac/parser/JavacParser.java b/langtools/src/share/classes/com/sun/tools/javac/parser/JavacParser.java index d4ec62a19a9..ab123e1fae5 100644 --- a/langtools/src/share/classes/com/sun/tools/javac/parser/JavacParser.java +++ b/langtools/src/share/classes/com/sun/tools/javac/parser/JavacParser.java @@ -75,42 +75,6 @@ public class JavacParser implements Parser { /** The name table. */ private Names names; - // Because of javac's limited lookahead, some contexts are ambiguous in - // the presence of type annotations even though they are not ambiguous - // in the absence of type annotations. Consider this code: - // void m(String [] m) { } - // void m(String ... m) { } - // After parsing "String", javac calls bracketsOpt which immediately - // returns if the next character is not '['. Similarly, javac can see - // if the next token is ... and in that case parse an ellipsis. But in - // the presence of type annotations: - // void m(String @A [] m) { } - // void m(String @A ... m) { } - // no finite lookahead is enough to determine whether to read array - // levels or an ellipsis. Furthermore, if you call bracketsOpt, then - // bracketsOpt first reads all the leading annotations and only then - // discovers that it needs to fail. bracketsOpt needs a way to push - // back the extra annotations that it read. (But, bracketsOpt should - // not *always* be allowed to push back extra annotations that it finds - // -- in most contexts, any such extra annotation is an error. - // Another similar case occurs with arrays and receiver annotations: - // String b() @Array [] @Receiver { } - // String b() @Receiver { } - // - // The following two variables permit type annotations that have - // already been read to be stored for later use. Alternate - // implementations are possible but would cause much larger changes to - // the parser. - /** Type annotations that have already been read but have not yet been used. **/ - private List typeAnnotationsPushedBack = null; - /** - * If the parser notices extra annotations, then it either immediately - * issues an error (if this variable is false) or places the extra - * annotations in variable typeAnnotationsPushedBack (if this variable - * is true). - */ - private boolean permitTypeAnnotationsPushBack = false; - /** Construct a parser from a given scanner, tree factory and log. */ protected JavacParser(ParserFactory fac, @@ -134,19 +98,13 @@ public class JavacParser implements Parser { this.allowTWR = source.allowTryWithResources(); this.allowDiamond = source.allowDiamond(); this.allowMulticatch = source.allowMulticatch(); - this.allowTypeAnnotations = source.allowTypeAnnotations(); this.keepDocComments = keepDocComments; if (keepDocComments) docComments = new HashMap(); this.keepLineMap = keepLineMap; this.errorTree = F.Erroneous(); - this.debugJSR308 = fac.options.get("TA:parser") != null; } - /** Switch: debug output for type-annotations operations - */ - boolean debugJSR308; - /** Switch: Should generics be recognized? */ boolean allowGenerics; @@ -183,10 +141,6 @@ public class JavacParser implements Parser { */ boolean allowAnnotations; - /** Switch: should we recognize type annotations? - */ - boolean allowTypeAnnotations; - /** Switch: should we recognize automatic resource management? */ boolean allowTWR; @@ -620,33 +574,7 @@ public class JavacParser implements Parser { return term(EXPR); } - /** - * parses (optional) type annotations followed by a type. If the - * annotations are present before the type and are not consumed during array - * parsing, this method returns a {@link JCAnnotatedType} consisting of - * these annotations and the underlying type. Otherwise, it returns the - * underlying type. - * - *

- * - * Note that this method sets {@code mode} to {@code TYPE} first, before - * parsing annotations. - */ public JCExpression parseType() { - List annotations = typeAnnotationsOpt(); - return parseType(annotations); - } - - public JCExpression parseType(List annotations) { - JCExpression result = unannotatedType(); - - if (!annotations.isEmpty()) - result = F.AnnotatedType(annotations, result); - - return result; - } - - public JCExpression unannotatedType() { return term(TYPE); } @@ -895,8 +823,8 @@ public class JavacParser implements Parser { * | [TypeArguments] THIS [Arguments] * | [TypeArguments] SUPER SuperSuffix * | NEW [TypeArguments] Creator - * | [Annotations] Ident { "." Ident } - * [ [Annotations] "[" ( "]" BracketsOpt "." CLASS | Expression "]" ) + * | Ident { "." Ident } + * [ "[" ( "]" BracketsOpt "." CLASS | Expression "]" ) * | Arguments * | "." ( CLASS | THIS | [TypeArguments] SUPER Arguments | NEW [TypeArguments] InnerCreator ) * ] @@ -1047,62 +975,23 @@ public class JavacParser implements Parser { typeArgs = null; } else return illegal(); break; - case MONKEYS_AT: - - // only annotated targetting class literals or cast types are valid - List typeAnnos = typeAnnotationsOpt(); - if (typeAnnos.isEmpty()) { - // else there would be no '@' - throw new AssertionError("type annos is empty"); - } - - JCExpression expr = term3(); - - // Type annotations: If term3 just parsed a non-type, expect a - // class literal (and issue a syntax error if there is no class - // literal). Otherwise, create a JCAnnotatedType. - if ((mode & TYPE) == 0) { - if (expr.getTag() != JCTree.SELECT) - return illegal(typeAnnos.head.pos); - JCFieldAccess sel = (JCFieldAccess)expr; - if (sel.name != names._class) - return illegal(); - else { - sel.selected = F.AnnotatedType(typeAnnos, sel.selected); - t = expr; - } - } else { - // type annotation targeting a cast - t = toP(F.at(S.pos()).AnnotatedType(typeAnnos, expr)); - } - break; case IDENTIFIER: case ASSERT: case ENUM: if (typeArgs != null) return illegal(); t = toP(F.at(S.pos()).Ident(ident())); loop: while (true) { pos = S.pos(); - final List annos = typeAnnotationsOpt(); - - // need to report an error later if LBRACKET is for array - // index access rather than array creation level - if (!annos.isEmpty() && S.token() != LBRACKET && S.token() != ELLIPSIS) - return illegal(annos.head.pos); switch (S.token()) { case LBRACKET: S.nextToken(); - if (S.token() == RBRACKET) { - S.nextToken(); - - t = bracketsOpt(t, annos); + t = bracketsOpt(t); t = toP(F.at(pos).TypeArray(t)); t = bracketsSuffix(t); } else { if ((mode & EXPR) != 0) { mode = EXPR; JCExpression t1 = term(); - if (!annos.isEmpty()) t = illegal(annos.head.pos); t = to(F.at(pos).Indexed(t, t1)); } accept(RBRACKET); @@ -1155,14 +1044,6 @@ public class JavacParser implements Parser { // typeArgs saved for next loop iteration. t = toP(F.at(pos).Select(t, ident())); break; - case ELLIPSIS: - if (this.permitTypeAnnotationsPushBack) { - this.typeAnnotationsPushedBack = annos; - } else if (annos.nonEmpty()) { - // Don't return here -- error recovery attempt - illegal(annos.head.pos); - } - break loop; default: break loop; } @@ -1201,18 +1082,14 @@ public class JavacParser implements Parser { if (typeArgs != null) illegal(); while (true) { int pos1 = S.pos(); - - final List annos = typeAnnotationsOpt(); - if (S.token() == LBRACKET) { S.nextToken(); - if ((mode & TYPE) != 0) { int oldmode = mode; mode = TYPE; if (S.token() == RBRACKET) { S.nextToken(); - t = bracketsOpt(t, annos); + t = bracketsOpt(t); t = toP(F.at(pos1).TypeArray(t)); return t; } @@ -1247,12 +1124,6 @@ public class JavacParser implements Parser { typeArgs = null; } } else { - if (!annos.isEmpty()) { - if (permitTypeAnnotationsPushBack) - typeAnnotationsPushedBack = annos; - else - return illegal(annos.head.pos); - } break; } } @@ -1262,7 +1133,6 @@ public class JavacParser implements Parser { S.token() == PLUSPLUS ? JCTree.POSTINC : JCTree.POSTDEC, t)); S.nextToken(); } - return toP(t); } @@ -1400,26 +1270,24 @@ public class JavacParser implements Parser { } /** TypeArgument = Type - * | [Annotations] "?" - * | [Annotations] "?" EXTENDS Type {"&" Type} - * | [Annotations] "?" SUPER Type + * | "?" + * | "?" EXTENDS Type {"&" Type} + * | "?" SUPER Type */ JCExpression typeArgument() { - List annotations = typeAnnotationsOpt(); - if (S.token() != QUES) return parseType(annotations); + if (S.token() != QUES) return parseType(); int pos = S.pos(); S.nextToken(); - JCExpression result; if (S.token() == EXTENDS) { TypeBoundKind t = to(F.at(pos).TypeBoundKind(BoundKind.EXTENDS)); S.nextToken(); JCExpression bound = parseType(); - result = F.at(pos).Wildcard(t, bound); + return F.at(pos).Wildcard(t, bound); } else if (S.token() == SUPER) { TypeBoundKind t = to(F.at(pos).TypeBoundKind(BoundKind.SUPER)); S.nextToken(); JCExpression bound = parseType(); - result = F.at(pos).Wildcard(t, bound); + return F.at(pos).Wildcard(t, bound); } else if (S.token() == IDENTIFIER) { //error recovery reportSyntaxError(S.prevEndPos(), "expected3", @@ -1427,14 +1295,11 @@ public class JavacParser implements Parser { TypeBoundKind t = F.at(Position.NOPOS).TypeBoundKind(BoundKind.UNBOUND); JCExpression wc = toP(F.at(pos).Wildcard(t, null)); JCIdent id = toP(F.at(S.pos()).Ident(ident())); - result = F.at(pos).Erroneous(List.of(wc, id)); + return F.at(pos).Erroneous(List.of(wc, id)); } else { TypeBoundKind t = toP(F.at(pos).TypeBoundKind(BoundKind.UNBOUND)); - result = toP(F.at(pos).Wildcard(t, null)); + return toP(F.at(pos).Wildcard(t, null)); } - if (!annotations.isEmpty()) - result = toP(F.at(annotations.head.pos).AnnotatedType(annotations,result)); - return result; } JCTypeApply typeArguments(JCExpression t) { @@ -1443,47 +1308,21 @@ public class JavacParser implements Parser { return toP(F.at(pos).TypeApply(t, args)); } - /** - * BracketsOpt = { [Annotations] "[" "]" } - * - *

- * - * annotations is the list of annotations targeting - * the expression t. + /** BracketsOpt = {"[" "]"} */ - private JCExpression bracketsOpt(JCExpression t, - List annotations) { - List nextLevelAnnotations = typeAnnotationsOpt(); - + private JCExpression bracketsOpt(JCExpression t) { if (S.token() == LBRACKET) { int pos = S.pos(); S.nextToken(); - - JCExpression orig = t; - t = bracketsOptCont(t, pos, nextLevelAnnotations); - } else if (!nextLevelAnnotations.isEmpty()) { - if (permitTypeAnnotationsPushBack) { - this.typeAnnotationsPushedBack = nextLevelAnnotations; - } else - return illegal(nextLevelAnnotations.head.pos); + t = bracketsOptCont(t, pos); + F.at(pos); } - - int apos = S.pos(); - if (!annotations.isEmpty()) - t = F.at(apos).AnnotatedType(annotations, t); return t; } - /** BracketsOpt = {"[" TypeAnnotations "]"} - */ - private JCExpression bracketsOpt(JCExpression t) { - return bracketsOpt(t, List.nil()); - } - - private JCArrayTypeTree bracketsOptCont(JCExpression t, int pos, - List annotations) { + private JCArrayTypeTree bracketsOptCont(JCExpression t, int pos) { accept(RBRACKET); - t = bracketsOpt(t, annotations); + t = bracketsOpt(t); return toP(F.at(pos).TypeArray(t)); } @@ -1517,29 +1356,18 @@ public class JavacParser implements Parser { return t; } - /** Creator = [Annotations] Qualident [TypeArguments] ( ArrayCreatorRest | ClassCreatorRest ) + /** Creator = Qualident [TypeArguments] ( ArrayCreatorRest | ClassCreatorRest ) */ JCExpression creator(int newpos, List typeArgs) { - - List newAnnotations = typeAnnotationsOpt(); - switch (S.token()) { case BYTE: case SHORT: case CHAR: case INT: case LONG: case FLOAT: case DOUBLE: case BOOLEAN: - if (typeArgs == null) { - if (newAnnotations.isEmpty()) - return arrayCreatorRest(newpos, basicType()); - else - return arrayCreatorRest(newpos, F.AnnotatedType(newAnnotations, basicType())); - } + if (typeArgs == null) + return arrayCreatorRest(newpos, basicType()); break; default: } JCExpression t = qualident(); - // handle type annotations for non primitive arrays - if (!newAnnotations.isEmpty()) - t = F.AnnotatedType(newAnnotations, t); - int oldmode = mode; mode = TYPE | DIAMOND; if (S.token() == LT) { @@ -1556,7 +1384,7 @@ public class JavacParser implements Parser { } } mode = oldmode; - if (S.token() == LBRACKET || S.token() == MONKEYS_AT) { + if (S.token() == LBRACKET) { JCExpression e = arrayCreatorRest(newpos, t); if (typeArgs != null) { int pos = newpos; @@ -1572,15 +1400,7 @@ public class JavacParser implements Parser { } return e; } else if (S.token() == LPAREN) { - JCNewClass newClass = classCreatorRest(newpos, null, typeArgs, t); - if (newClass.def != null) { - assert newClass.def.mods.annotations.isEmpty(); - if (newAnnotations.nonEmpty()) { - newClass.def.mods.pos = earlier(newClass.def.mods.pos, newAnnotations.head.pos); - newClass.def.mods.annotations = List.convert(JCAnnotation.class, newAnnotations); - } - } - return newClass; + return classCreatorRest(newpos, null, typeArgs, t); } else { reportSyntaxError(S.pos(), "expected2", LPAREN, LBRACKET); @@ -1603,67 +1423,34 @@ public class JavacParser implements Parser { return classCreatorRest(newpos, encl, typeArgs, t); } - /** ArrayCreatorRest = [Annotations] "[" ( "]" BracketsOpt ArrayInitializer - * | Expression "]" {[Annotations] "[" Expression "]"} BracketsOpt ) + /** ArrayCreatorRest = "[" ( "]" BracketsOpt ArrayInitializer + * | Expression "]" {"[" Expression "]"} BracketsOpt ) */ JCExpression arrayCreatorRest(int newpos, JCExpression elemtype) { - - List topAnnos = List.nil(); - if (elemtype.getTag() == JCTree.ANNOTATED_TYPE) { - JCAnnotatedType atype = (JCAnnotatedType) elemtype; - topAnnos = atype.annotations; - elemtype = atype.underlyingType; - } - - List annos = typeAnnotationsOpt(); - accept(LBRACKET); - if (S.token() == RBRACKET) { accept(RBRACKET); - - elemtype = bracketsOpt(elemtype, annos); - + elemtype = bracketsOpt(elemtype); if (S.token() == LBRACE) { - JCNewArray na = (JCNewArray)arrayInitializer(newpos, elemtype); - - na.annotations = topAnnos; - - return na; + return arrayInitializer(newpos, elemtype); } else { return syntaxError(S.pos(), "array.dimension.missing"); } } else { ListBuffer dims = new ListBuffer(); - - // maintain array dimension type annotations - ListBuffer> dimAnnotations = ListBuffer.lb(); - dimAnnotations.append(annos); - dims.append(parseExpression()); accept(RBRACKET); - while (S.token() == LBRACKET - || (S.token() == MONKEYS_AT)) { - List maybeDimAnnos = typeAnnotationsOpt(); + while (S.token() == LBRACKET) { int pos = S.pos(); S.nextToken(); if (S.token() == RBRACKET) { - elemtype = bracketsOptCont(elemtype, pos, maybeDimAnnos); + elemtype = bracketsOptCont(elemtype, pos); } else { - if (S.token() == RBRACKET) { // no dimension - elemtype = bracketsOptCont(elemtype, pos, maybeDimAnnos); - } else { - dimAnnotations.append(maybeDimAnnos); - dims.append(parseExpression()); - accept(RBRACKET); - } + dims.append(parseExpression()); + accept(RBRACKET); } } - - JCNewArray na = toP(F.at(newpos).NewArray(elemtype, dims.toList(), null)); - na.annotations = topAnnos; - na.dimAnnotations = dimAnnotations.toList(); - return na; + return toP(F.at(newpos).NewArray(elemtype, dims.toList(), null)); } } @@ -2142,32 +1929,17 @@ public class JavacParser implements Parser { new ListBuffer()).toList(); } - enum AnnotationKind { DEFAULT_ANNO, TYPE_ANNO }; - /** AnnotationsOpt = { '@' Annotation } */ - List annotationsOpt(AnnotationKind kind) { + List annotationsOpt() { if (S.token() != MONKEYS_AT) return List.nil(); // optimization ListBuffer buf = new ListBuffer(); - int prevmode = mode; while (S.token() == MONKEYS_AT) { int pos = S.pos(); S.nextToken(); - buf.append(annotation(pos, kind)); + buf.append(annotation(pos)); } - lastmode = mode; - mode = prevmode; - List annotations = buf.toList(); - - if (debugJSR308 && kind == AnnotationKind.TYPE_ANNO) - System.out.println("TA: parsing " + annotations - + " in " + log.currentSourceFile()); - return annotations; - } - - List typeAnnotationsOpt() { - List annotations = annotationsOpt(AnnotationKind.TYPE_ANNO); - return List.convert(JCTypeAnnotation.class, annotations); + return buf.toList(); } /** ModifiersOpt = { Modifier } @@ -2219,7 +1991,7 @@ public class JavacParser implements Parser { if (flag == Flags.ANNOTATION) { checkAnnotations(); if (S.token() != INTERFACE) { - JCAnnotation ann = annotation(lastPos, AnnotationKind.DEFAULT_ANNO); + JCAnnotation ann = annotation(lastPos); // if first modifier is an annotation, set pos to annotation's. if (flags == 0 && annotations.isEmpty()) pos = ann.pos; @@ -2250,18 +2022,12 @@ public class JavacParser implements Parser { /** Annotation = "@" Qualident [ "(" AnnotationFieldValues ")" ] * @param pos position of "@" token */ - JCAnnotation annotation(int pos, AnnotationKind kind) { + JCAnnotation annotation(int pos) { // accept(AT); // AT consumed by caller checkAnnotations(); - if (kind == AnnotationKind.TYPE_ANNO) - checkTypeAnnotations(); JCTree ident = qualident(); List fieldValues = annotationFieldValuesOpt(); - JCAnnotation ann; - if (kind == AnnotationKind.DEFAULT_ANNO) - ann = F.at(pos).Annotation(ident, fieldValues); - else - ann = F.at(pos).TypeAnnotation(ident, fieldValues); + JCAnnotation ann = F.at(pos).Annotation(ident, fieldValues); storeEnd(ann, S.prevEndPos()); return ann; } @@ -2314,7 +2080,7 @@ public class JavacParser implements Parser { case MONKEYS_AT: pos = S.pos(); S.nextToken(); - return annotation(pos, AnnotationKind.DEFAULT_ANNO); + return annotation(pos); case LBRACE: pos = S.pos(); accept(LBRACE); @@ -2705,7 +2471,7 @@ public class JavacParser implements Parser { S.resetDeprecatedFlag(); } int pos = S.pos(); - List annotations = annotationsOpt(AnnotationKind.DEFAULT_ANNO); + List annotations = annotationsOpt(); JCModifiers mods = F.at(annotations.isEmpty() ? Position.NOPOS : pos).Modifiers(flags, annotations); List typeArgs = typeArgumentsOpt(); int identPos = S.pos(); @@ -2802,25 +2568,15 @@ public class JavacParser implements Parser { } else { pos = S.pos(); List typarams = typeParametersOpt(); - List annosAfterParams = annotationsOpt(AnnotationKind.DEFAULT_ANNO); - Name name = S.name(); pos = S.pos(); JCExpression type; boolean isVoid = S.token() == VOID; if (isVoid) { - if (annosAfterParams.nonEmpty()) - illegal(annosAfterParams.head.pos); type = to(F.at(pos).TypeIdent(TypeTags.VOID)); S.nextToken(); } else { - if (annosAfterParams.nonEmpty()) { - mods.annotations = mods.annotations.appendList(annosAfterParams); - if (mods.pos == Position.NOPOS) - mods.pos = mods.annotations.head.pos; - } - // method returns types are un-annotated types - type = unannotatedType(); + type = parseType(); } if (S.token() == LPAREN && !isInterface && type.getTag() == JCTree.IDENT) { if (isInterface || name != className) @@ -2856,15 +2612,15 @@ public class JavacParser implements Parser { } /** MethodDeclaratorRest = - * FormalParameters BracketsOpt [Annotations] [Throws TypeList] ( MethodBody | [DEFAULT AnnotationValue] ";") + * FormalParameters BracketsOpt [Throws TypeList] ( MethodBody | [DEFAULT AnnotationValue] ";") * VoidMethodDeclaratorRest = - * FormalParameters [Annotations] [Throws TypeList] ( MethodBody | ";") + * FormalParameters [Throws TypeList] ( MethodBody | ";") * InterfaceMethodDeclaratorRest = - * FormalParameters BracketsOpt [Annotations] [THROWS TypeList] ";" + * FormalParameters BracketsOpt [THROWS TypeList] ";" * VoidInterfaceMethodDeclaratorRest = - * FormalParameters [Annotations] [THROWS TypeList] ";" + * FormalParameters [THROWS TypeList] ";" * ConstructorDeclaratorRest = - * "(" FormalParameterListOpt ")" [Annotations] [THROWS TypeList] MethodBody + * "(" FormalParameterListOpt ")" [THROWS TypeList] MethodBody */ JCTree methodDeclaratorRest(int pos, JCModifiers mods, @@ -2874,22 +2630,7 @@ public class JavacParser implements Parser { boolean isInterface, boolean isVoid, String dc) { List params = formalParameters(); - - List receiverAnnotations; - if (!isVoid) { - // need to distinguish between receiver anno and array anno - // look at typeAnnotationsPushedBack comment - this.permitTypeAnnotationsPushBack = true; - type = methodReturnArrayRest(type); - this.permitTypeAnnotationsPushBack = false; - if (typeAnnotationsPushedBack == null) - receiverAnnotations = List.nil(); - else - receiverAnnotations = typeAnnotationsPushedBack; - typeAnnotationsPushedBack = null; - } else - receiverAnnotations = typeAnnotationsOpt(); - + if (!isVoid) type = bracketsOpt(type); List thrown = List.nil(); if (S.token() == THROWS) { S.nextToken(); @@ -2919,51 +2660,20 @@ public class JavacParser implements Parser { JCMethodDecl result = toP(F.at(pos).MethodDef(mods, name, type, typarams, - params, receiverAnnotations, thrown, + params, thrown, body, defaultValue)); attach(result, dc); return result; } - /** Parses the array levels after the format parameters list, and append - * them to the return type, while preseving the order of type annotations - */ - private JCExpression methodReturnArrayRest(JCExpression type) { - if (type.getTag() != JCTree.TYPEARRAY) - return bracketsOpt(type); - - JCArrayTypeTree baseArray = (JCArrayTypeTree)type; - while (TreeInfo.typeIn(baseArray.elemtype) instanceof JCArrayTypeTree) - baseArray = (JCArrayTypeTree)TreeInfo.typeIn(baseArray.elemtype); - - if (baseArray.elemtype.getTag() == JCTree.ANNOTATED_TYPE) { - JCAnnotatedType at = (JCAnnotatedType)baseArray.elemtype; - at.underlyingType = bracketsOpt(at.underlyingType); - } else { - baseArray.elemtype = bracketsOpt(baseArray.elemtype); - } - - return type; - } - - /** QualidentList = [Annotations] Qualident {"," [Annotations] Qualident} + /** QualidentList = Qualident {"," Qualident} */ List qualidentList() { ListBuffer ts = new ListBuffer(); - - List typeAnnos = typeAnnotationsOpt(); - if (!typeAnnos.isEmpty()) - ts.append(F.AnnotatedType(typeAnnos, qualident())); - else - ts.append(qualident()); + ts.append(qualident()); while (S.token() == COMMA) { S.nextToken(); - - typeAnnos = typeAnnotationsOpt(); - if (!typeAnnos.isEmpty()) - ts.append(F.AnnotatedType(typeAnnos, qualident())); - else - ts.append(qualident()); + ts.append(qualident()); } return ts.toList(); } @@ -2987,13 +2697,12 @@ public class JavacParser implements Parser { } } - /** TypeParameter = [Annotations] TypeVariable [TypeParameterBound] + /** TypeParameter = TypeVariable [TypeParameterBound] * TypeParameterBound = EXTENDS Type {"&" Type} * TypeVariable = Ident */ JCTypeParameter typeParameter() { int pos = S.pos(); - List annos = typeAnnotationsOpt(); Name name = ident(); ListBuffer bounds = new ListBuffer(); if (S.token() == EXTENDS) { @@ -3004,7 +2713,7 @@ public class JavacParser implements Parser { bounds.append(parseType()); } } - return toP(F.at(pos).TypeParameter(name, bounds.toList(), annos)); + return toP(F.at(pos).TypeParameter(name, bounds.toList())); } /** FormalParameters = "(" [ FormalParameterList ] ")" @@ -3038,31 +2747,12 @@ public class JavacParser implements Parser { */ JCVariableDecl formalParameter() { JCModifiers mods = optFinal(Flags.PARAMETER); - // need to distinguish between vararg annos and array annos - // look at typeAnnotaitonsPushedBack comment - this.permitTypeAnnotationsPushBack = true; JCExpression type = parseType(); - this.permitTypeAnnotationsPushBack = false; - if (S.token() == ELLIPSIS) { - List varargsAnnos = typeAnnotationsPushedBack; - typeAnnotationsPushedBack = null; checkVarargs(); mods.flags |= Flags.VARARGS; - // insert var arg type annotations - if (varargsAnnos != null && varargsAnnos.nonEmpty()) - type = F.at(S.pos()).AnnotatedType(varargsAnnos, type); type = to(F.at(S.pos()).TypeArray(type)); - S.nextToken(); - } else { - // if not a var arg, then typeAnnotationsPushedBack should be null - if (typeAnnotationsPushedBack != null - && !typeAnnotationsPushedBack.isEmpty()) { - reportSyntaxError(typeAnnotationsPushedBack.head.pos, - "illegal.start.of.type"); - } - typeAnnotationsPushedBack = null; } return variableDeclaratorId(mods, type); } @@ -3259,12 +2949,6 @@ public class JavacParser implements Parser { allowAnnotations = true; } } - void checkTypeAnnotations() { - if (!allowTypeAnnotations) { - log.error(S.pos(), "type.annotations.not.supported.in.source", source.name); - allowTypeAnnotations = true; - } - } void checkDiamond() { if (!allowDiamond) { log.error(S.pos(), "diamond.not.supported.in.source", source.name); diff --git a/langtools/src/share/classes/com/sun/tools/javac/processing/JavacProcessingEnvironment.java b/langtools/src/share/classes/com/sun/tools/javac/processing/JavacProcessingEnvironment.java index 7b7f362413b..20d6fad6718 100644 --- a/langtools/src/share/classes/com/sun/tools/javac/processing/JavacProcessingEnvironment.java +++ b/langtools/src/share/classes/com/sun/tools/javac/processing/JavacProcessingEnvironment.java @@ -49,11 +49,11 @@ import javax.tools.StandardJavaFileManager; import javax.tools.JavaFileObject; import javax.tools.DiagnosticListener; -import com.sun.tools.javac.api.JavacTrees; -import com.sun.source.util.AbstractTypeProcessor; +//308 import com.sun.source.util.AbstractTypeProcessor; import com.sun.source.util.TaskEvent; import com.sun.source.util.TaskListener; import com.sun.tools.javac.api.JavacTaskImpl; +import com.sun.tools.javac.api.JavacTrees; import com.sun.tools.javac.code.*; import com.sun.tools.javac.code.Symbol.*; import com.sun.tools.javac.file.JavacFileManager; @@ -712,7 +712,7 @@ public class JavacProcessingEnvironment implements ProcessingEnvironment, Closea } if (matchedNames.size() > 0 || ps.contributed) { - foundTypeProcessors = foundTypeProcessors || (ps.processor instanceof AbstractTypeProcessor); +//308 foundTypeProcessors = foundTypeProcessors || (ps.processor instanceof AbstractTypeProcessor); boolean processingResult = callProcessor(ps.processor, typeElements, renv); ps.contributed = true; ps.removeSupportedOptions(unmatchedProcessorOptions); diff --git a/langtools/src/share/classes/com/sun/tools/javac/resources/compiler.properties b/langtools/src/share/classes/com/sun/tools/javac/resources/compiler.properties index 36309876dbc..7bfcc95cc86 100644 --- a/langtools/src/share/classes/com/sun/tools/javac/resources/compiler.properties +++ b/langtools/src/share/classes/com/sun/tools/javac/resources/compiler.properties @@ -1299,9 +1299,9 @@ compiler.err.annotations.not.supported.in.source=\ annotations are not supported in -source {0}\n\ (use -source 5 or higher to enable annotations) -compiler.err.type.annotations.not.supported.in.source=\ - type annotations are not supported in -source {0}\n\ -(use -source 7 or higher to enable type annotations) +#308 compiler.err.type.annotations.not.supported.in.source=\ +#308 type annotations are not supported in -source {0}\n\ +#308 (use -source 7 or higher to enable type annotations) compiler.err.foreach.not.supported.in.source=\ for-each loops are not supported in -source {0}\n\ diff --git a/langtools/src/share/classes/com/sun/tools/javac/tree/JCTree.java b/langtools/src/share/classes/com/sun/tools/javac/tree/JCTree.java index 209544d3cf1..96ef9ebfd1e 100644 --- a/langtools/src/share/classes/com/sun/tools/javac/tree/JCTree.java +++ b/langtools/src/share/classes/com/sun/tools/javac/tree/JCTree.java @@ -2067,17 +2067,23 @@ public abstract class JCTree implements Tree, Cloneable, DiagnosticPosition { } } - public static class JCAnnotatedType extends JCExpression implements com.sun.source.tree.AnnotatedTypeTree { + public static class JCAnnotatedType extends JCExpression +//308 implements com.sun.source.tree.AnnotatedTypeTree + { public List annotations; public JCExpression underlyingType; protected JCAnnotatedType(List annotations, JCExpression underlyingType) { - this.annotations = annotations; - this.underlyingType = underlyingType; + throw new UnsupportedOperationException(); +//308 this.annotations = annotations; +//308 this.underlyingType = underlyingType; } @Override public void accept(Visitor v) { v.visitAnnotatedType(this); } - public Kind getKind() { return Kind.ANNOTATED_TYPE; } + public Kind getKind() { + throw new UnsupportedOperationException(); +//308 return Kind.ANNOTATED_TYPE; + } public List getAnnotations() { return annotations; } @@ -2086,7 +2092,8 @@ public abstract class JCTree implements Tree, Cloneable, DiagnosticPosition { } @Override public R accept(TreeVisitor v, D d) { - return v.visitAnnotatedType(this, d); + throw new UnsupportedOperationException(); +//308 return v.visitAnnotatedType(this, d); } @Override public int getTag() { diff --git a/langtools/src/share/classes/com/sun/tools/javac/tree/TreeCopier.java b/langtools/src/share/classes/com/sun/tools/javac/tree/TreeCopier.java index 6abbfdbec9c..63b9ae06130 100644 --- a/langtools/src/share/classes/com/sun/tools/javac/tree/TreeCopier.java +++ b/langtools/src/share/classes/com/sun/tools/javac/tree/TreeCopier.java @@ -71,12 +71,12 @@ public class TreeCopier

implements TreeVisitor { return lb.toList(); } - public JCTree visitAnnotatedType(AnnotatedTypeTree node, P p) { - JCAnnotatedType t = (JCAnnotatedType) node; - List annotations = copy(t.annotations, p); - JCExpression underlyingType = copy(t.underlyingType, p); - return M.at(t.pos).AnnotatedType(annotations, underlyingType); - } +//308 public JCTree visitAnnotatedType(AnnotatedTypeTree node, P p) { +//308 JCAnnotatedType t = (JCAnnotatedType) node; +//308 List annotations = copy(t.annotations, p); +//308 JCExpression underlyingType = copy(t.underlyingType, p); +//308 return M.at(t.pos).AnnotatedType(annotations, underlyingType); +//308 } public JCTree visitAnnotation(AnnotationTree node, P p) { JCAnnotation t = (JCAnnotation) node; diff --git a/langtools/test/tools/javac/T6985181.java b/langtools/test/tools/javac/T6985181.java deleted file mode 100644 index fd588d1d71f..00000000000 --- a/langtools/test/tools/javac/T6985181.java +++ /dev/null @@ -1,86 +0,0 @@ -/* - * Copyright (c) 2010, 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 6985181 - * @summary Annotations lost from classfile - */ - -import java.io.*; -import java.util.*; - -public class T6985181 { - public static void main(String... args) throws Exception{ - new T6985181().run(); - } - - public void run() throws Exception { - String code = "@interface Simple { }\ninterface Test<@Simple T> { }"; - - File srcFile = writeFile("Test.java", code); - File classesDir = new File("classes"); - classesDir.mkdirs(); - compile("-d", classesDir.getPath(), srcFile.getPath()); - String out = javap(new File(classesDir, srcFile.getName().replace(".java", ".class"))); - if (!out.contains("RuntimeInvisibleTypeAnnotations")) - throw new Exception("RuntimeInvisibleTypeAnnotations not found"); - } - - void compile(String... args) throws Exception { - StringWriter sw = new StringWriter(); - PrintWriter pw = new PrintWriter(sw); - int rc = com.sun.tools.javac.Main.compile(args, pw); - pw.close(); - String out = sw.toString(); - if (out.length() > 0) - System.err.println(out); - if (rc != 0) - throw new Exception("Compilation failed: rc=" + rc); - } - - String javap(File classFile) throws Exception { - StringWriter sw = new StringWriter(); - PrintWriter pw = new PrintWriter(sw); - String[] args = { "-v", classFile.getPath() }; - int rc = com.sun.tools.javap.Main.run(args, pw); - pw.close(); - String out = sw.toString(); - if (out.length() > 0) - System.err.println(out); - if (rc != 0) - throw new Exception("javap failed: rc=" + rc); - return out; - } - - File writeFile(String path, String body) throws IOException { - File f = new File(path); - FileWriter out = new FileWriter(f); - try { - out.write(body); - } finally { - out.close(); - } - return f; - } -} diff --git a/langtools/test/tools/javac/annotations/6881115/T6881115.java b/langtools/test/tools/javac/annotations/6881115/T6881115.java index a0b9960c2fe..2f779c4ac46 100644 --- a/langtools/test/tools/javac/annotations/6881115/T6881115.java +++ b/langtools/test/tools/javac/annotations/6881115/T6881115.java @@ -16,5 +16,5 @@ } @A(b = @B(b2 = 1, b2 = 2), b_arr = {@B(), @B(b2 = 1, b2 = 2)}) -class T6881115<@A(b = @B(b2 = 1, b2 = 2), - b_arr = {@B(), @B(b2 = 1, b2 = 2)}) X> {} +class T6881115 {} diff --git a/langtools/test/tools/javac/annotations/6881115/T6881115.out b/langtools/test/tools/javac/annotations/6881115/T6881115.out index 4cece230577..93b90cff473 100644 --- a/langtools/test/tools/javac/annotations/6881115/T6881115.out +++ b/langtools/test/tools/javac/annotations/6881115/T6881115.out @@ -8,9 +8,4 @@ T6881115.java:17:8: compiler.err.annotation.missing.default.value: B, b1 T6881115.java:18:13: compiler.err.annotation.missing.default.value.1: B, b1,b2 T6881115.java:18:30: compiler.err.duplicate.annotation.member.value: b2, B T6881115.java:18:19: compiler.err.annotation.missing.default.value: B, b1 -T6881115.java:19:34: compiler.err.duplicate.annotation.member.value: b2, B -T6881115.java:19:23: compiler.err.annotation.missing.default.value: B, b1 -T6881115.java:20:28: compiler.err.annotation.missing.default.value.1: B, b1,b2 -T6881115.java:20:45: compiler.err.duplicate.annotation.member.value: b2, B -T6881115.java:20:34: compiler.err.annotation.missing.default.value: B, b1 -15 errors +10 errors diff --git a/langtools/test/tools/javac/diags/examples/TypeAnnotationsNotSupported.java b/langtools/test/tools/javac/diags/examples/TypeAnnotationsNotSupported.java deleted file mode 100644 index 8f028cbd1de..00000000000 --- a/langtools/test/tools/javac/diags/examples/TypeAnnotationsNotSupported.java +++ /dev/null @@ -1,33 +0,0 @@ -/* - * Copyright (c) 2010, 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.type.annotations.not.supported.in.source -// options: -source 6 - -@interface Anno { } - -class TypeAnnotationsNotSupported { - void m() { - int i = (@Anno int) 3.14; - } -} diff --git a/langtools/test/tools/javac/processing/model/element/TestAnonClassNames.java b/langtools/test/tools/javac/processing/model/element/TestAnonClassNames.java index f5bddff0a45..d602bc08ead 100644 --- a/langtools/test/tools/javac/processing/model/element/TestAnonClassNames.java +++ b/langtools/test/tools/javac/processing/model/element/TestAnonClassNames.java @@ -78,7 +78,7 @@ public class TestAnonClassNames { @Nesting(LOCAL) class LocalClass{}; - Object o = new @Nesting(ANONYMOUS) Object() { // An anonymous annotated class + Object o = new /*@Nesting(ANONYMOUS)*/ Object() { // An anonymous annotated class public String toString() { return "I have no name!"; } @@ -95,9 +95,10 @@ public class TestAnonClassNames { for(Class clazz : classes) { String name = clazz.getName(); + Nesting anno = clazz.getAnnotation(Nesting.class); System.out.format("%s is %s%n", clazz.getName(), - clazz.getAnnotation(Nesting.class).value()); + anno == null ? "(unset/ANONYMOUS)" : anno.value()); testClassName(name); } } @@ -161,8 +162,8 @@ class ClassNameProber extends JavacTestingAbstractProcessor { typeElt.getQualifiedName().toString(), typeElt.getKind().toString(), nestingKind.toString()); - - if (typeElt.getAnnotation(Nesting.class).value() != nestingKind) { + Nesting anno = typeElt.getAnnotation(Nesting.class); + if ((anno == null ? NestingKind.ANONYMOUS : anno.value()) != nestingKind) { throw new RuntimeException("Mismatch of expected and reported nesting kind."); } } diff --git a/langtools/test/tools/javac/tree/TreePosTest.java b/langtools/test/tools/javac/tree/TreePosTest.java index b83c4c68250..9f586185334 100644 --- a/langtools/test/tools/javac/tree/TreePosTest.java +++ b/langtools/test/tools/javac/tree/TreePosTest.java @@ -357,7 +357,9 @@ public class TreePosTest { check("encl.start <= start", encl, self, encl.start <= self.start); check("start <= pos", encl, self, self.start <= self.pos); if (!(self.tag == JCTree.TYPEARRAY - && (encl.tag == JCTree.VARDEF || encl.tag == JCTree.TYPEARRAY))) { + && (encl.tag == JCTree.VARDEF || + encl.tag == JCTree.METHODDEF || + encl.tag == JCTree.TYPEARRAY))) { check("encl.pos <= start || end <= encl.pos", encl, self, encl.pos <= self.start || self.end <= encl.pos); } diff --git a/langtools/test/tools/javac/treeannotests/AnnoTreeTests.java b/langtools/test/tools/javac/treeannotests/AnnoTreeTests.java deleted file mode 100644 index fcfb4e55d56..00000000000 --- a/langtools/test/tools/javac/treeannotests/AnnoTreeTests.java +++ /dev/null @@ -1,44 +0,0 @@ -/* - * Copyright (c) 2010, 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 - * @build DA TA Test TestProcessor - * @compile -proc:only -processor TestProcessor AnnoTreeTests.java - */ - -@Test(6) -class AnnoTreeTests { - // primitive types - @DA("int") int i1; - int i2 = (@TA("int") int) 0; - - // simple array types - @DA("int[]") int[] a1; - int @TA("int") [] a2; - int[] a3 = (@TA("int[]") int[]) a1; - int[] a4 = (int @TA("int") []) a1; - - // multi-dimensional array types - // (still to come) -} diff --git a/langtools/test/tools/javac/typeAnnotations/6967002/T6967002.java b/langtools/test/tools/javac/typeAnnotations/6967002/T6967002.java deleted file mode 100644 index 317cf34199e..00000000000 --- a/langtools/test/tools/javac/typeAnnotations/6967002/T6967002.java +++ /dev/null @@ -1,35 +0,0 @@ -/* - * Copyright (c) 2010, 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 6967002 - * @summary JDK7 b99 javac compilation error (java.lang.AssertionError) - * @author Maurizio Cimadamore - * @compile/fail/ref=T6967002.out -XDrawDiagnostics T6967002.java - */ -class Test { - private static void m(byte[] octets) { - return m(octets..., ?); - } -} diff --git a/langtools/test/tools/javac/typeAnnotations/6967002/T6967002.out b/langtools/test/tools/javac/typeAnnotations/6967002/T6967002.out deleted file mode 100644 index 18b75307f04..00000000000 --- a/langtools/test/tools/javac/typeAnnotations/6967002/T6967002.out +++ /dev/null @@ -1,8 +0,0 @@ -T6967002.java:33:22: compiler.err.expected: ')' -T6967002.java:33:25: compiler.err.illegal.start.of.expr -T6967002.java:33:28: compiler.err.illegal.start.of.expr -T6967002.java:33:29: compiler.err.illegal.start.of.expr -T6967002.java:33:27: compiler.err.not.stmt -T6967002.java:33:30: compiler.err.expected: ';' -T6967002.java:35:2: compiler.err.premature.eof -7 errors diff --git a/langtools/test/tools/javac/typeAnnotations/InnerClass.java b/langtools/test/tools/javac/typeAnnotations/InnerClass.java deleted file mode 100644 index e373eae58f4..00000000000 --- a/langtools/test/tools/javac/typeAnnotations/InnerClass.java +++ /dev/null @@ -1,59 +0,0 @@ -/* - * Copyright (c) 2009, 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 6843077 - * @summary compiler crashes when visiting inner classes - * @author Mahmood Ali - * @compile -source 1.7 InnerClass.java - */ - -class InnerClass { - - InnerClass() {} - InnerClass(Object o) {} - - private void a() { - new Object() { - public void method() { } - }; - } - - Object f1 = new InnerClass() { - void method() { } - }; - - Object f2 = new InnerClass() { - <@A R> void method() { } - }; - - Object f3 = new InnerClass(null) { - void method() { } - }; - - Object f4 = new InnerClass(null) { - <@A R> void method() { } - }; - @interface A { } -} diff --git a/langtools/test/tools/javac/typeAnnotations/MultipleTargets.java b/langtools/test/tools/javac/typeAnnotations/MultipleTargets.java deleted file mode 100644 index c0982c10bd6..00000000000 --- a/langtools/test/tools/javac/typeAnnotations/MultipleTargets.java +++ /dev/null @@ -1,41 +0,0 @@ -/* - * Copyright (c) 2008, 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 6843077 - * @summary check that type annotations may appear on void method if it is a - * method annotation too. - * @author Mahmood Ali - * @compile -source 1.7 MultipleTargets.java - */ - -import java.lang.annotation.Target; -import java.lang.annotation.ElementType; - -class TypeUseTarget { - @A void voidMethod() { } -} - -@Target({ElementType.TYPE_USE, ElementType.METHOD}) -@interface A { } diff --git a/langtools/test/tools/javac/typeAnnotations/TypeParameterTarget.java b/langtools/test/tools/javac/typeAnnotations/TypeParameterTarget.java deleted file mode 100644 index e1de7a1f006..00000000000 --- a/langtools/test/tools/javac/typeAnnotations/TypeParameterTarget.java +++ /dev/null @@ -1,46 +0,0 @@ -/* - * Copyright (c) 2008, 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 6843077 - * @summary check that type annotations may appear on all type parameter - * @author Mahmood Ali - * @compile -source 1.7 TypeParameterTarget.java - */ - -import java.lang.annotation.Target; -import java.lang.annotation.ElementType; - -class TypeUseTarget<@A K extends Object> { - String[] field; - - <@A K, @A V> String genericMethod(K k) { return null; } -} - -interface MyInterface { } - -@interface MyAnnotation { } - -@Target(ElementType.TYPE_PARAMETER) -@interface A { } diff --git a/langtools/test/tools/javac/typeAnnotations/TypeUseTarget.java b/langtools/test/tools/javac/typeAnnotations/TypeUseTarget.java deleted file mode 100644 index 2b87d99fb75..00000000000 --- a/langtools/test/tools/javac/typeAnnotations/TypeUseTarget.java +++ /dev/null @@ -1,55 +0,0 @@ -/* - * Copyright (c) 2008, 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 6843077 - * @summary check that type annotations may appear on all type declarations - * @author Mahmood Ali - * @compile -source 1.7 TypeUseTarget.java - */ - -import java.lang.annotation.Target; -import java.lang.annotation.ElementType; - -@A -class TypeUseTarget { - @A String @A [] field; - - @A String test(@A String param, @A String @A ... vararg) @A { - @A Object o = new @A String @A [3]; - TypeUseTarget<@A String> target; - return (@A String) null; - } - - @A String genericMethod(K k) { return null; } -} - -@A -interface MyInterface { } - -@A -@interface MyAnnotation { } - -@Target(ElementType.TYPE_USE) -@interface A { } diff --git a/langtools/test/tools/javac/typeAnnotations/attribution/Scopes.java b/langtools/test/tools/javac/typeAnnotations/attribution/Scopes.java deleted file mode 100644 index 5b3e56bd1f7..00000000000 --- a/langtools/test/tools/javac/typeAnnotations/attribution/Scopes.java +++ /dev/null @@ -1,38 +0,0 @@ -/* - * Copyright (c) 2008, 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 6843077 - * @summary test scopes of attribution - * @author Mahmood Ali - * @compile -source 1.7 Scopes.java - */ -class Scopes { - - void test() @A(VALUE) { } - void test1() @A(value=VALUE) { } - - private static final int VALUE = 1; - @interface A { int value(); } -} diff --git a/langtools/test/tools/javac/typeAnnotations/classfile/DeadCode.java b/langtools/test/tools/javac/typeAnnotations/classfile/DeadCode.java deleted file mode 100644 index d7451f425b2..00000000000 --- a/langtools/test/tools/javac/typeAnnotations/classfile/DeadCode.java +++ /dev/null @@ -1,181 +0,0 @@ -/* - * Copyright (c) 2009, 2010, 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. - */ - -import java.io.*; -import java.net.URL; -import java.util.List; - -import com.sun.tools.classfile.*; - -/* - * @test - * @bug 6917130 - * @summary test that optimized away annotations are not emited to classfile - */ - -public class DeadCode { - public static void main(String[] args) throws Exception { - new DeadCode().run(); - } - - public void run() throws Exception { - ClassFile cf = getClassFile("DeadCode$Test.class"); - test(cf); - for (Field f : cf.fields) { - test(cf, f); - } - for (Method m: cf.methods) { - test(cf, m); - } - - countAnnotations(); - - if (errors > 0) - throw new Exception(errors + " errors found"); - System.out.println("PASSED"); - } - - ClassFile getClassFile(String name) throws IOException, ConstantPoolException { - URL url = getClass().getResource(name); - InputStream in = url.openStream(); - try { - return ClassFile.read(in); - } finally { - in.close(); - } - } - - /************ Helper annotations counting methods ******************/ - void test(ClassFile cf) { - test(cf, Attribute.RuntimeVisibleTypeAnnotations, true); - test(cf, Attribute.RuntimeInvisibleTypeAnnotations, false); - } - - void test(ClassFile cf, Method m) { - test(cf, m, Attribute.RuntimeVisibleTypeAnnotations, true); - test(cf, m, Attribute.RuntimeInvisibleTypeAnnotations, false); - } - - void test(ClassFile cf, Field m) { - test(cf, m, Attribute.RuntimeVisibleTypeAnnotations, true); - test(cf, m, Attribute.RuntimeInvisibleTypeAnnotations, false); - } - - // test the result of Attributes.getIndex according to expectations - // encoded in the method's name - void test(ClassFile cf, String name, boolean visible) { - int index = cf.attributes.getIndex(cf.constant_pool, name); - if (index != -1) { - Attribute attr = cf.attributes.get(index); - assert attr instanceof RuntimeTypeAnnotations_attribute; - RuntimeTypeAnnotations_attribute tAttr = (RuntimeTypeAnnotations_attribute)attr; - all += tAttr.annotations.length; - if (visible) - visibles += tAttr.annotations.length; - else - invisibles += tAttr.annotations.length; - } - } - - // test the result of Attributes.getIndex according to expectations - // encoded in the method's name - void test(ClassFile cf, Method m, String name, boolean visible) { - int index = m.attributes.getIndex(cf.constant_pool, name); - if (index != -1) { - Attribute attr = m.attributes.get(index); - assert attr instanceof RuntimeTypeAnnotations_attribute; - RuntimeTypeAnnotations_attribute tAttr = (RuntimeTypeAnnotations_attribute)attr; - all += tAttr.annotations.length; - if (visible) - visibles += tAttr.annotations.length; - else - invisibles += tAttr.annotations.length; - } - } - - // test the result of Attributes.getIndex according to expectations - // encoded in the method's name - void test(ClassFile cf, Field m, String name, boolean visible) { - int index = m.attributes.getIndex(cf.constant_pool, name); - if (index != -1) { - Attribute attr = m.attributes.get(index); - assert attr instanceof RuntimeTypeAnnotations_attribute; - RuntimeTypeAnnotations_attribute tAttr = (RuntimeTypeAnnotations_attribute)attr; - all += tAttr.annotations.length; - if (visible) - visibles += tAttr.annotations.length; - else - invisibles += tAttr.annotations.length; - } - } - - void countAnnotations() { - int expected_all = expected_visibles + expected_invisibles; - - if (expected_all != all) { - errors++; - System.err.println("expected " + expected_all - + " annotations but found " + all); - } - - if (expected_visibles != visibles) { - errors++; - System.err.println("expected " + expected_visibles - + " visibles annotations but found " + visibles); - } - - if (expected_invisibles != invisibles) { - errors++; - System.err.println("expected " + expected_invisibles - + " invisibles annotations but found " + invisibles); - } - - } - - int errors; - int all; - int visibles; - int invisibles; - - /*********************** Test class *************************/ - static int expected_invisibles = 1; - static int expected_visibles = 0; - static class Test { - @interface A {} - - void test() { - List o = null; - o.toString(); - - @A String m; - if (false) { - @A String a; - @A String b = "m"; - b.toString(); - List c = null; - c.toString(); - } - } - } - -} diff --git a/langtools/test/tools/javac/typeAnnotations/failures/AnnotationVersion.java b/langtools/test/tools/javac/typeAnnotations/failures/AnnotationVersion.java deleted file mode 100644 index d9d74acca60..00000000000 --- a/langtools/test/tools/javac/typeAnnotations/failures/AnnotationVersion.java +++ /dev/null @@ -1,12 +0,0 @@ -/* - * @test /nodynamiccopyright/ - * @bug 6843077 - * @summary test that only java 7 allows type annotations - * @author Mahmood Ali - * @compile/fail/ref=AnnotationVersion.out -XDrawDiagnostics -source 1.6 AnnotationVersion.java - */ -class AnnotationVersion { - public void method() @A { } -} - -@interface A { } diff --git a/langtools/test/tools/javac/typeAnnotations/failures/AnnotationVersion.out b/langtools/test/tools/javac/typeAnnotations/failures/AnnotationVersion.out deleted file mode 100644 index 521a5eb8005..00000000000 --- a/langtools/test/tools/javac/typeAnnotations/failures/AnnotationVersion.out +++ /dev/null @@ -1,2 +0,0 @@ -AnnotationVersion.java:9:25: compiler.err.type.annotations.not.supported.in.source: 1.6 -1 error diff --git a/langtools/test/tools/javac/typeAnnotations/failures/IncompleteArray.java b/langtools/test/tools/javac/typeAnnotations/failures/IncompleteArray.java deleted file mode 100644 index 8edb60807d4..00000000000 --- a/langtools/test/tools/javac/typeAnnotations/failures/IncompleteArray.java +++ /dev/null @@ -1,12 +0,0 @@ -/* - * @test /nodynamiccopyright/ - * @bug 6843077 - * @summary test incomplete array declaration - * @author Mahmood Ali - * @compile/fail/ref=IncompleteArray.out -XDrawDiagnostics -source 1.7 IncompleteArray.java - */ -class IncompleteArray { - int @A [] @A var; -} - -@interface A { } diff --git a/langtools/test/tools/javac/typeAnnotations/failures/IncompleteArray.out b/langtools/test/tools/javac/typeAnnotations/failures/IncompleteArray.out deleted file mode 100644 index a03a09283ee..00000000000 --- a/langtools/test/tools/javac/typeAnnotations/failures/IncompleteArray.out +++ /dev/null @@ -1,2 +0,0 @@ -IncompleteArray.java:9:13: compiler.err.illegal.start.of.type -1 error diff --git a/langtools/test/tools/javac/typeAnnotations/failures/IncompleteVararg.java b/langtools/test/tools/javac/typeAnnotations/failures/IncompleteVararg.java deleted file mode 100644 index b54df921ec4..00000000000 --- a/langtools/test/tools/javac/typeAnnotations/failures/IncompleteVararg.java +++ /dev/null @@ -1,13 +0,0 @@ -/* - * @test /nodynamiccopyright/ - * @bug 6843077 - * @summary test incomplete vararg declaration - * @author Mahmood Ali - * @compile/fail/ref=IncompleteVararg.out -XDrawDiagnostics -source 1.7 IncompleteVararg.java - */ -class IncompleteArray { - // the last variable may be vararg - void method(int @A test) { } -} - -@interface A { } diff --git a/langtools/test/tools/javac/typeAnnotations/failures/IncompleteVararg.out b/langtools/test/tools/javac/typeAnnotations/failures/IncompleteVararg.out deleted file mode 100644 index 7cec6c9ee78..00000000000 --- a/langtools/test/tools/javac/typeAnnotations/failures/IncompleteVararg.out +++ /dev/null @@ -1,2 +0,0 @@ -IncompleteVararg.java:10:19: compiler.err.illegal.start.of.type -1 error diff --git a/langtools/test/tools/javac/typeAnnotations/failures/IndexArray.java b/langtools/test/tools/javac/typeAnnotations/failures/IndexArray.java deleted file mode 100644 index 5cb324d0cdb..00000000000 --- a/langtools/test/tools/javac/typeAnnotations/failures/IndexArray.java +++ /dev/null @@ -1,13 +0,0 @@ -/* - * @test /nodynamiccopyright/ - * @bug 6843077 - * @summary test indexing of an array - * @author Mahmood Ali - * @compile/fail/ref=IndexArray.out -XDrawDiagnostics -source 1.7 IndexArray.java - */ -class IndexArray { - int[] var; - int a = var @A [1]; -} - -@interface A { } diff --git a/langtools/test/tools/javac/typeAnnotations/failures/IndexArray.out b/langtools/test/tools/javac/typeAnnotations/failures/IndexArray.out deleted file mode 100644 index 762f38b15a8..00000000000 --- a/langtools/test/tools/javac/typeAnnotations/failures/IndexArray.out +++ /dev/null @@ -1,2 +0,0 @@ -IndexArray.java:10:15: compiler.err.illegal.start.of.expr -1 error diff --git a/langtools/test/tools/javac/typeAnnotations/failures/LintCast.java b/langtools/test/tools/javac/typeAnnotations/failures/LintCast.java deleted file mode 100644 index 4830de3ebf2..00000000000 --- a/langtools/test/tools/javac/typeAnnotations/failures/LintCast.java +++ /dev/null @@ -1,42 +0,0 @@ -import java.util.List; - -/* - * @test /nodynamiccopyright/ - * @bug 6843077 - * @summary test that compiler doesn't warn about annotated redundant casts - * @author Mahmood Ali - * @compile/ref=LintCast.out -Xlint:cast -XDrawDiagnostics -source 1.7 LintCast.java - */ -class LintCast { - void unparameterized() { - String s = "m"; - String s1 = (String)s; - String s2 = (@A String)s; - } - - void parameterized() { - List l = null; - List l1 = (List)l; - List l2 = (List<@A String>)l; - } - - void array() { - int @A [] a = null; - int[] a1 = (int[])a; - int[] a2 = (int @A [])a; - } - - void sameAnnotations() { - @A String annotated = null; - String unannotated = null; - - // compiler ignore annotated casts even if redundant - @A String anno1 = (@A String)annotated; - - // warn if redundant without an annotation - String anno2 = (String)annotated; - String unanno2 = (String)unannotated; - } -} - -@interface A { } diff --git a/langtools/test/tools/javac/typeAnnotations/failures/LintCast.out b/langtools/test/tools/javac/typeAnnotations/failures/LintCast.out deleted file mode 100644 index 67388ab2f4d..00000000000 --- a/langtools/test/tools/javac/typeAnnotations/failures/LintCast.out +++ /dev/null @@ -1,6 +0,0 @@ -LintCast.java:13:21: compiler.warn.redundant.cast: java.lang.String -LintCast.java:19:27: compiler.warn.redundant.cast: java.util.List -LintCast.java:25:20: compiler.warn.redundant.cast: int[] -LintCast.java:37:24: compiler.warn.redundant.cast: java.lang.String -LintCast.java:38:26: compiler.warn.redundant.cast: java.lang.String -5 warnings diff --git a/langtools/test/tools/javac/typeAnnotations/failures/OldArray.java b/langtools/test/tools/javac/typeAnnotations/failures/OldArray.java deleted file mode 100644 index 746a6d47496..00000000000 --- a/langtools/test/tools/javac/typeAnnotations/failures/OldArray.java +++ /dev/null @@ -1,35 +0,0 @@ -/* - * Copyright (c) 2008, 2009, 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 6843077 - * @summary test old array syntax - * @author Mahmood Ali - * @compile/fail -XDrawDiagnostics -source 1.7 OldArray.java - */ -class OldArray { - String [@A] s() { return null; } -} - -@interface A { } diff --git a/langtools/test/tools/javac/typeAnnotations/failures/Scopes.java b/langtools/test/tools/javac/typeAnnotations/failures/Scopes.java deleted file mode 100644 index 71eda33a775..00000000000 --- a/langtools/test/tools/javac/typeAnnotations/failures/Scopes.java +++ /dev/null @@ -1,10 +0,0 @@ -/* - * @test /nodynamiccopyright/ - * @bug 6843077 - * @summary check that A is accessible in the class type parameters - * @author Mahmood Ali - * @compile/fail/ref=Scopes.out -XDrawDiagnostics -source 1.7 Scopes.java - */ -class Scopes { - @interface UniqueInner { }; -} diff --git a/langtools/test/tools/javac/typeAnnotations/failures/Scopes.out b/langtools/test/tools/javac/typeAnnotations/failures/Scopes.out deleted file mode 100644 index 3335f6ecff1..00000000000 --- a/langtools/test/tools/javac/typeAnnotations/failures/Scopes.out +++ /dev/null @@ -1,2 +0,0 @@ -Scopes.java:8:25: compiler.err.cant.resolve: kindname.class, UniqueInner, , -1 error diff --git a/langtools/test/tools/javac/typeAnnotations/failures/StaticFields.java b/langtools/test/tools/javac/typeAnnotations/failures/StaticFields.java deleted file mode 100644 index 8b96bf6c2f1..00000000000 --- a/langtools/test/tools/javac/typeAnnotations/failures/StaticFields.java +++ /dev/null @@ -1,13 +0,0 @@ -/* - * @test /nodynamiccopyright/ - * @bug 6843077 - * @summary static field access isn't a valid location - * @author Mahmood Ali - * @compile/fail/ref=StaticFields.out -XDrawDiagnostics -source 1.7 StaticFields.java - */ -class C { - int f; - int a = @A C.f; -} - -@interface A { } diff --git a/langtools/test/tools/javac/typeAnnotations/failures/StaticFields.out b/langtools/test/tools/javac/typeAnnotations/failures/StaticFields.out deleted file mode 100644 index 3364c661fdb..00000000000 --- a/langtools/test/tools/javac/typeAnnotations/failures/StaticFields.out +++ /dev/null @@ -1,2 +0,0 @@ -StaticFields.java:10:17: compiler.err.illegal.start.of.expr -1 error diff --git a/langtools/test/tools/javac/typeAnnotations/failures/StaticMethods.java b/langtools/test/tools/javac/typeAnnotations/failures/StaticMethods.java deleted file mode 100644 index 045601c97a7..00000000000 --- a/langtools/test/tools/javac/typeAnnotations/failures/StaticMethods.java +++ /dev/null @@ -1,12 +0,0 @@ -/* - * @test /nodynamiccopyright/ - * @bug 6843077 - * @summary static methods don't have receivers - * @author Mahmood Ali - * @compile/fail/ref=StaticMethods.out -XDrawDiagnostics -source 1.7 StaticMethods.java - */ -class StaticMethods { - static void main() @A { } -} - -@interface A { } diff --git a/langtools/test/tools/javac/typeAnnotations/failures/StaticMethods.out b/langtools/test/tools/javac/typeAnnotations/failures/StaticMethods.out deleted file mode 100644 index d3ec9a5538f..00000000000 --- a/langtools/test/tools/javac/typeAnnotations/failures/StaticMethods.out +++ /dev/null @@ -1,2 +0,0 @@ -StaticMethods.java:9:22: compiler.err.annotation.type.not.applicable -1 error diff --git a/langtools/test/tools/javac/typeAnnotations/failures/VoidGenericMethod.java b/langtools/test/tools/javac/typeAnnotations/failures/VoidGenericMethod.java deleted file mode 100644 index b48c33e2e1a..00000000000 --- a/langtools/test/tools/javac/typeAnnotations/failures/VoidGenericMethod.java +++ /dev/null @@ -1,35 +0,0 @@ -/* - * Copyright (c) 2008, 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 6843077 - * @summary test type annotation on void generic methods - * @author Mahmood Ali - * @compile/fail -source 1.7 VoidGenericMethod.java - */ -class VoidGenericMethod { - public @A void method() { } -} - -@interface A { } diff --git a/langtools/test/tools/javac/typeAnnotations/failures/common/arrayclass/DuplicateAnnotationValue.java b/langtools/test/tools/javac/typeAnnotations/failures/common/arrayclass/DuplicateAnnotationValue.java deleted file mode 100644 index 129bf3f8f0e..00000000000 --- a/langtools/test/tools/javac/typeAnnotations/failures/common/arrayclass/DuplicateAnnotationValue.java +++ /dev/null @@ -1,14 +0,0 @@ -/* - * @test /nodynamiccopyright/ - * @bug 6843077 6919944 - * @summary check for duplicate annotation values - * @author Mahmood Ali - * @compile/fail/ref=DuplicateAnnotationValue.out -XDrawDiagnostics -source 1.7 DuplicateAnnotationValue.java - */ -class DuplicateAnnotationValue { - void test() { - Object a = String @A(value = 2, value = 1) [].class; - } -} - -@interface A { int value(); } diff --git a/langtools/test/tools/javac/typeAnnotations/failures/common/arrayclass/DuplicateAnnotationValue.out b/langtools/test/tools/javac/typeAnnotations/failures/common/arrayclass/DuplicateAnnotationValue.out deleted file mode 100644 index 16493d988cc..00000000000 --- a/langtools/test/tools/javac/typeAnnotations/failures/common/arrayclass/DuplicateAnnotationValue.out +++ /dev/null @@ -1,2 +0,0 @@ -DuplicateAnnotationValue.java:10:37: compiler.err.duplicate.annotation.member.value: value, A -1 error diff --git a/langtools/test/tools/javac/typeAnnotations/failures/common/arrayclass/DuplicateTypeAnnotation.java b/langtools/test/tools/javac/typeAnnotations/failures/common/arrayclass/DuplicateTypeAnnotation.java deleted file mode 100644 index 1b79248293e..00000000000 --- a/langtools/test/tools/javac/typeAnnotations/failures/common/arrayclass/DuplicateTypeAnnotation.java +++ /dev/null @@ -1,15 +0,0 @@ -/* - * @test /nodynamiccopyright/ - * @bug 6843077 - * @summary check for duplicate annotations - * @author Mahmood Ali - * @compile/fail/ref=DuplicateTypeAnnotation.out -XDrawDiagnostics -source 1.7 DuplicateTypeAnnotation.java - */ - -class DuplicateTypeAnnotation { - void test() { - Object a = String @A @A [].class; - } -} - -@interface A { } diff --git a/langtools/test/tools/javac/typeAnnotations/failures/common/arrayclass/DuplicateTypeAnnotation.out b/langtools/test/tools/javac/typeAnnotations/failures/common/arrayclass/DuplicateTypeAnnotation.out deleted file mode 100644 index f9ae0eda9de..00000000000 --- a/langtools/test/tools/javac/typeAnnotations/failures/common/arrayclass/DuplicateTypeAnnotation.out +++ /dev/null @@ -1,2 +0,0 @@ -DuplicateTypeAnnotation.java:11:26: compiler.err.duplicate.annotation -1 error diff --git a/langtools/test/tools/javac/typeAnnotations/failures/common/arrayclass/InvalidLocation.java b/langtools/test/tools/javac/typeAnnotations/failures/common/arrayclass/InvalidLocation.java deleted file mode 100644 index 1f7477d3945..00000000000 --- a/langtools/test/tools/javac/typeAnnotations/failures/common/arrayclass/InvalidLocation.java +++ /dev/null @@ -1,16 +0,0 @@ -/* - * @test /nodynamiccopyright/ - * @bug 6843077 - * @summary check for invalid annotatins given the target - * @author Mahmood Ali - * @compile/fail/ref=InvalidLocation.out -XDrawDiagnostics -source 1.7 InvalidLocation.java - */ - -class InvalidLocation { - void test() { - Object a = String @A [].class; - } -} - -@java.lang.annotation.Target(java.lang.annotation.ElementType.TYPE) -@interface A { } diff --git a/langtools/test/tools/javac/typeAnnotations/failures/common/arrayclass/InvalidLocation.out b/langtools/test/tools/javac/typeAnnotations/failures/common/arrayclass/InvalidLocation.out deleted file mode 100644 index 20d6f4835dd..00000000000 --- a/langtools/test/tools/javac/typeAnnotations/failures/common/arrayclass/InvalidLocation.out +++ /dev/null @@ -1,2 +0,0 @@ -InvalidLocation.java:11:23: compiler.err.annotation.type.not.applicable -1 error diff --git a/langtools/test/tools/javac/typeAnnotations/failures/common/arrayclass/MissingAnnotationValue.java b/langtools/test/tools/javac/typeAnnotations/failures/common/arrayclass/MissingAnnotationValue.java deleted file mode 100644 index 798df949c41..00000000000 --- a/langtools/test/tools/javac/typeAnnotations/failures/common/arrayclass/MissingAnnotationValue.java +++ /dev/null @@ -1,14 +0,0 @@ -/* - * @test /nodynamiccopyright/ - * @bug 6843077 - * @summary check for missing annotation value - * @author Mahmood Ali - * @compile/fail/ref=MissingAnnotationValue.out -XDrawDiagnostics -source 1.7 MissingAnnotationValue.java - */ -class MissingAnnotationValue { - void test() { - Object a = String @A [].class; - } -} - -@interface A { int field(); } diff --git a/langtools/test/tools/javac/typeAnnotations/failures/common/arrayclass/MissingAnnotationValue.out b/langtools/test/tools/javac/typeAnnotations/failures/common/arrayclass/MissingAnnotationValue.out deleted file mode 100644 index 6b00f8c7904..00000000000 --- a/langtools/test/tools/javac/typeAnnotations/failures/common/arrayclass/MissingAnnotationValue.out +++ /dev/null @@ -1,2 +0,0 @@ -MissingAnnotationValue.java:10:23: compiler.err.annotation.missing.default.value: A, field -1 error diff --git a/langtools/test/tools/javac/typeAnnotations/failures/common/arrays/DuplicateAnnotationValue.java b/langtools/test/tools/javac/typeAnnotations/failures/common/arrays/DuplicateAnnotationValue.java deleted file mode 100644 index 9f67df1c3fe..00000000000 --- a/langtools/test/tools/javac/typeAnnotations/failures/common/arrays/DuplicateAnnotationValue.java +++ /dev/null @@ -1,14 +0,0 @@ -/* - * @test /nodynamiccopyright/ - * @bug 6843077 6919944 - * @summary check for duplicate annotation values - * @author Mahmood Ali - * @compile/fail/ref=DuplicateAnnotationValue.out -XDrawDiagnostics -source 1.7 DuplicateAnnotationValue.java - */ -class DuplicateAnnotationValue { - void test() { - String @A(value = 2, value = 1) [] s; - } -} - -@interface A { int value(); } diff --git a/langtools/test/tools/javac/typeAnnotations/failures/common/arrays/DuplicateAnnotationValue.out b/langtools/test/tools/javac/typeAnnotations/failures/common/arrays/DuplicateAnnotationValue.out deleted file mode 100644 index 240239e566b..00000000000 --- a/langtools/test/tools/javac/typeAnnotations/failures/common/arrays/DuplicateAnnotationValue.out +++ /dev/null @@ -1,2 +0,0 @@ -DuplicateAnnotationValue.java:10:26: compiler.err.duplicate.annotation.member.value: value, A -1 error diff --git a/langtools/test/tools/javac/typeAnnotations/failures/common/arrays/DuplicateTypeAnnotation.java b/langtools/test/tools/javac/typeAnnotations/failures/common/arrays/DuplicateTypeAnnotation.java deleted file mode 100644 index 79cf843d62a..00000000000 --- a/langtools/test/tools/javac/typeAnnotations/failures/common/arrays/DuplicateTypeAnnotation.java +++ /dev/null @@ -1,15 +0,0 @@ -/* - * @test /nodynamiccopyright/ - * @bug 6843077 - * @summary check for duplicate annotations - * @author Mahmood Ali - * @compile/fail/ref=DuplicateTypeAnnotation.out -XDrawDiagnostics -source 1.7 DuplicateTypeAnnotation.java - */ - -class DuplicateTypeAnnotation { - void test() { - String @A @A [] s; - } -} - -@interface A { } diff --git a/langtools/test/tools/javac/typeAnnotations/failures/common/arrays/DuplicateTypeAnnotation.out b/langtools/test/tools/javac/typeAnnotations/failures/common/arrays/DuplicateTypeAnnotation.out deleted file mode 100644 index 5647c04430e..00000000000 --- a/langtools/test/tools/javac/typeAnnotations/failures/common/arrays/DuplicateTypeAnnotation.out +++ /dev/null @@ -1,2 +0,0 @@ -DuplicateTypeAnnotation.java:11:15: compiler.err.duplicate.annotation -1 error diff --git a/langtools/test/tools/javac/typeAnnotations/failures/common/arrays/InvalidLocation.java b/langtools/test/tools/javac/typeAnnotations/failures/common/arrays/InvalidLocation.java deleted file mode 100644 index 08a88db5e3e..00000000000 --- a/langtools/test/tools/javac/typeAnnotations/failures/common/arrays/InvalidLocation.java +++ /dev/null @@ -1,16 +0,0 @@ -/* - * @test /nodynamiccopyright/ - * @bug 6843077 - * @summary check for invalid annotatins given the target - * @author Mahmood Ali - * @compile/fail/ref=InvalidLocation.out -XDrawDiagnostics -source 1.7 InvalidLocation.java - */ - -class InvalidLocation { - void test() { - String @A [] s; - } -} - -@java.lang.annotation.Target(java.lang.annotation.ElementType.TYPE) -@interface A { } diff --git a/langtools/test/tools/javac/typeAnnotations/failures/common/arrays/InvalidLocation.out b/langtools/test/tools/javac/typeAnnotations/failures/common/arrays/InvalidLocation.out deleted file mode 100644 index 868ab979837..00000000000 --- a/langtools/test/tools/javac/typeAnnotations/failures/common/arrays/InvalidLocation.out +++ /dev/null @@ -1,2 +0,0 @@ -InvalidLocation.java:11:12: compiler.err.annotation.type.not.applicable -1 error diff --git a/langtools/test/tools/javac/typeAnnotations/failures/common/arrays/MissingAnnotationValue.java b/langtools/test/tools/javac/typeAnnotations/failures/common/arrays/MissingAnnotationValue.java deleted file mode 100644 index dc73272adba..00000000000 --- a/langtools/test/tools/javac/typeAnnotations/failures/common/arrays/MissingAnnotationValue.java +++ /dev/null @@ -1,14 +0,0 @@ -/* - * @test /nodynamiccopyright/ - * @bug 6843077 - * @summary check for missing annotation value - * @author Mahmood Ali - * @compile/fail/ref=MissingAnnotationValue.out -XDrawDiagnostics -source 1.7 MissingAnnotationValue.java - */ -class MissingAnnotationValue { - void test() { - String @A [] s; - } -} - -@interface A { int field(); } diff --git a/langtools/test/tools/javac/typeAnnotations/failures/common/arrays/MissingAnnotationValue.out b/langtools/test/tools/javac/typeAnnotations/failures/common/arrays/MissingAnnotationValue.out deleted file mode 100644 index 74a7ef7340b..00000000000 --- a/langtools/test/tools/javac/typeAnnotations/failures/common/arrays/MissingAnnotationValue.out +++ /dev/null @@ -1,2 +0,0 @@ -MissingAnnotationValue.java:10:12: compiler.err.annotation.missing.default.value: A, field -1 error diff --git a/langtools/test/tools/javac/typeAnnotations/failures/common/innertypeparams/DuplicateAnnotationValue.java b/langtools/test/tools/javac/typeAnnotations/failures/common/innertypeparams/DuplicateAnnotationValue.java deleted file mode 100644 index 62ef4189d4b..00000000000 --- a/langtools/test/tools/javac/typeAnnotations/failures/common/innertypeparams/DuplicateAnnotationValue.java +++ /dev/null @@ -1,14 +0,0 @@ -/* - * @test /nodynamiccopyright/ - * @bug 6843077 6919944 - * @summary check for duplicate annotation values for type parameter - * @author Mahmood Ali - * @compile/fail/ref=DuplicateAnnotationValue.out -XDrawDiagnostics -source 1.7 DuplicateAnnotationValue.java - */ -class DuplicateAnnotationValue { - void method() { - class Inner<@A(value = 2, value = 1) K> {} - } -} - -@interface A { int value(); } diff --git a/langtools/test/tools/javac/typeAnnotations/failures/common/innertypeparams/DuplicateAnnotationValue.out b/langtools/test/tools/javac/typeAnnotations/failures/common/innertypeparams/DuplicateAnnotationValue.out deleted file mode 100644 index d717c98c486..00000000000 --- a/langtools/test/tools/javac/typeAnnotations/failures/common/innertypeparams/DuplicateAnnotationValue.out +++ /dev/null @@ -1,2 +0,0 @@ -DuplicateAnnotationValue.java:10:31: compiler.err.duplicate.annotation.member.value: value, A -1 error diff --git a/langtools/test/tools/javac/typeAnnotations/failures/common/innertypeparams/DuplicateTypeAnnotation.java b/langtools/test/tools/javac/typeAnnotations/failures/common/innertypeparams/DuplicateTypeAnnotation.java deleted file mode 100644 index 66cb0bd7fd9..00000000000 --- a/langtools/test/tools/javac/typeAnnotations/failures/common/innertypeparams/DuplicateTypeAnnotation.java +++ /dev/null @@ -1,14 +0,0 @@ -/* - * @test /nodynamiccopyright/ - * @bug 6843077 - * @summary check for duplicate annotations - * @author Mahmood Ali - * @compile/fail/ref=DuplicateTypeAnnotation.out -XDrawDiagnostics -source 1.7 DuplicateTypeAnnotation.java - */ -class DuplicateTypeAnno { - void innermethod() { - class Inner<@A @A K> { } - } -} - -@interface A { } diff --git a/langtools/test/tools/javac/typeAnnotations/failures/common/innertypeparams/DuplicateTypeAnnotation.out b/langtools/test/tools/javac/typeAnnotations/failures/common/innertypeparams/DuplicateTypeAnnotation.out deleted file mode 100644 index accba46be32..00000000000 --- a/langtools/test/tools/javac/typeAnnotations/failures/common/innertypeparams/DuplicateTypeAnnotation.out +++ /dev/null @@ -1,2 +0,0 @@ -DuplicateTypeAnnotation.java:10:20: compiler.err.duplicate.annotation -1 error diff --git a/langtools/test/tools/javac/typeAnnotations/failures/common/innertypeparams/InvalidLocation.java b/langtools/test/tools/javac/typeAnnotations/failures/common/innertypeparams/InvalidLocation.java deleted file mode 100644 index d93fb8dff15..00000000000 --- a/langtools/test/tools/javac/typeAnnotations/failures/common/innertypeparams/InvalidLocation.java +++ /dev/null @@ -1,15 +0,0 @@ -/* - * @test /nodynamiccopyright/ - * @bug 6843077 - * @summary check for invalid annotatins given the target - * @author Mahmood Ali - * @compile/fail/ref=InvalidLocation.out -XDrawDiagnostics -source 1.7 InvalidLocation.java - */ -class InvalidLocation { - void innermethod() { - class Inner<@A K> {} - } -} - -@java.lang.annotation.Target(java.lang.annotation.ElementType.TYPE) -@interface A { } diff --git a/langtools/test/tools/javac/typeAnnotations/failures/common/innertypeparams/InvalidLocation.out b/langtools/test/tools/javac/typeAnnotations/failures/common/innertypeparams/InvalidLocation.out deleted file mode 100644 index b74ad54ba94..00000000000 --- a/langtools/test/tools/javac/typeAnnotations/failures/common/innertypeparams/InvalidLocation.out +++ /dev/null @@ -1,2 +0,0 @@ -InvalidLocation.java:10:17: compiler.err.annotation.type.not.applicable -1 error diff --git a/langtools/test/tools/javac/typeAnnotations/failures/common/innertypeparams/MissingAnnotationValue.java b/langtools/test/tools/javac/typeAnnotations/failures/common/innertypeparams/MissingAnnotationValue.java deleted file mode 100644 index da47aeaa705..00000000000 --- a/langtools/test/tools/javac/typeAnnotations/failures/common/innertypeparams/MissingAnnotationValue.java +++ /dev/null @@ -1,14 +0,0 @@ -/* - * @test /nodynamiccopyright/ - * @bug 6843077 - * @summary check for missing annotation value - * @author Mahmood Ali - * @compile/fail/ref=MissingAnnotationValue.out -XDrawDiagnostics -source 1.7 MissingAnnotationValue.java - */ -class MissingAnnotationValue { - void innermethod() { - class Inner<@A K> { } - } -} - -@interface A { int field(); } diff --git a/langtools/test/tools/javac/typeAnnotations/failures/common/innertypeparams/MissingAnnotationValue.out b/langtools/test/tools/javac/typeAnnotations/failures/common/innertypeparams/MissingAnnotationValue.out deleted file mode 100644 index 637ff4acc0a..00000000000 --- a/langtools/test/tools/javac/typeAnnotations/failures/common/innertypeparams/MissingAnnotationValue.out +++ /dev/null @@ -1,2 +0,0 @@ -MissingAnnotationValue.java:10:17: compiler.err.annotation.missing.default.value: A, field -1 error diff --git a/langtools/test/tools/javac/typeAnnotations/failures/common/newarray/DuplicateAnnotationValue.java b/langtools/test/tools/javac/typeAnnotations/failures/common/newarray/DuplicateAnnotationValue.java deleted file mode 100644 index 3574e79d8a1..00000000000 --- a/langtools/test/tools/javac/typeAnnotations/failures/common/newarray/DuplicateAnnotationValue.java +++ /dev/null @@ -1,14 +0,0 @@ -/* - * @test /nodynamiccopyright/ - * @bug 6843077 6919944 - * @summary check for duplicate annotation values - * @author Mahmood Ali - * @compile/fail/ref=DuplicateAnnotationValue.out -XDrawDiagnostics -source 1.7 DuplicateAnnotationValue.java - */ -class DuplicateAnnotationValue { - void test() { - String[] a = new String @A(value = 2, value = 1) [5] ; - } -} - -@interface A { int value(); } diff --git a/langtools/test/tools/javac/typeAnnotations/failures/common/newarray/DuplicateAnnotationValue.out b/langtools/test/tools/javac/typeAnnotations/failures/common/newarray/DuplicateAnnotationValue.out deleted file mode 100644 index 1852f279ef1..00000000000 --- a/langtools/test/tools/javac/typeAnnotations/failures/common/newarray/DuplicateAnnotationValue.out +++ /dev/null @@ -1,2 +0,0 @@ -DuplicateAnnotationValue.java:10:43: compiler.err.duplicate.annotation.member.value: value, A -1 error diff --git a/langtools/test/tools/javac/typeAnnotations/failures/common/newarray/DuplicateTypeAnnotation.java b/langtools/test/tools/javac/typeAnnotations/failures/common/newarray/DuplicateTypeAnnotation.java deleted file mode 100644 index d8ad961afaa..00000000000 --- a/langtools/test/tools/javac/typeAnnotations/failures/common/newarray/DuplicateTypeAnnotation.java +++ /dev/null @@ -1,15 +0,0 @@ -/* - * @test /nodynamiccopyright/ - * @bug 6843077 - * @summary check for duplicate annotations - * @author Mahmood Ali - * @compile/fail/ref=DuplicateTypeAnnotation.out -XDrawDiagnostics -source 1.7 DuplicateTypeAnnotation.java - */ - -class DuplicateTypeAnnotation { - void test() { - String[] a = new String @A @A [5] ; - } -} - -@interface A { } diff --git a/langtools/test/tools/javac/typeAnnotations/failures/common/newarray/DuplicateTypeAnnotation.out b/langtools/test/tools/javac/typeAnnotations/failures/common/newarray/DuplicateTypeAnnotation.out deleted file mode 100644 index 7b13962b5d0..00000000000 --- a/langtools/test/tools/javac/typeAnnotations/failures/common/newarray/DuplicateTypeAnnotation.out +++ /dev/null @@ -1,2 +0,0 @@ -DuplicateTypeAnnotation.java:11:32: compiler.err.duplicate.annotation -1 error diff --git a/langtools/test/tools/javac/typeAnnotations/failures/common/newarray/InvalidLocation.java b/langtools/test/tools/javac/typeAnnotations/failures/common/newarray/InvalidLocation.java deleted file mode 100644 index 7071e9a0c24..00000000000 --- a/langtools/test/tools/javac/typeAnnotations/failures/common/newarray/InvalidLocation.java +++ /dev/null @@ -1,16 +0,0 @@ -/* - * @test /nodynamiccopyright/ - * @bug 6843077 - * @summary check for invalid annotatins given the target - * @author Mahmood Ali - * @compile/fail/ref=InvalidLocation.out -XDrawDiagnostics -source 1.7 InvalidLocation.java - */ - -class InvalidLocation { - void test() { - String[] s = new String @A [5] ; - } -} - -@java.lang.annotation.Target(java.lang.annotation.ElementType.TYPE) -@interface A { } diff --git a/langtools/test/tools/javac/typeAnnotations/failures/common/newarray/InvalidLocation.out b/langtools/test/tools/javac/typeAnnotations/failures/common/newarray/InvalidLocation.out deleted file mode 100644 index 1d98d174319..00000000000 --- a/langtools/test/tools/javac/typeAnnotations/failures/common/newarray/InvalidLocation.out +++ /dev/null @@ -1,2 +0,0 @@ -InvalidLocation.java:11:29: compiler.err.annotation.type.not.applicable -1 error diff --git a/langtools/test/tools/javac/typeAnnotations/failures/common/newarray/MissingAnnotationValue.java b/langtools/test/tools/javac/typeAnnotations/failures/common/newarray/MissingAnnotationValue.java deleted file mode 100644 index 3817df58223..00000000000 --- a/langtools/test/tools/javac/typeAnnotations/failures/common/newarray/MissingAnnotationValue.java +++ /dev/null @@ -1,14 +0,0 @@ -/* - * @test /nodynamiccopyright/ - * @bug 6843077 - * @summary check for missing annotation value - * @author Mahmood Ali - * @compile/fail/ref=MissingAnnotationValue.out -XDrawDiagnostics -source 1.7 MissingAnnotationValue.java - */ -class MissingAnnotationValue { - void test() { - String[] a = new String @A [5]; - } -} - -@interface A { int field(); } diff --git a/langtools/test/tools/javac/typeAnnotations/failures/common/newarray/MissingAnnotationValue.out b/langtools/test/tools/javac/typeAnnotations/failures/common/newarray/MissingAnnotationValue.out deleted file mode 100644 index 6865348250b..00000000000 --- a/langtools/test/tools/javac/typeAnnotations/failures/common/newarray/MissingAnnotationValue.out +++ /dev/null @@ -1,2 +0,0 @@ -MissingAnnotationValue.java:10:29: compiler.err.annotation.missing.default.value: A, field -1 error diff --git a/langtools/test/tools/javac/typeAnnotations/failures/common/parambounds/DuplicateAnnotationValue.java b/langtools/test/tools/javac/typeAnnotations/failures/common/parambounds/DuplicateAnnotationValue.java deleted file mode 100644 index 83a064c416a..00000000000 --- a/langtools/test/tools/javac/typeAnnotations/failures/common/parambounds/DuplicateAnnotationValue.java +++ /dev/null @@ -1,11 +0,0 @@ -/* - * @test /nodynamiccopyright/ - * @bug 6843077 6919944 - * @summary check for duplicate annotation values for type parameter - * @author Mahmood Ali - * @compile/fail/ref=DuplicateAnnotationValue.out -XDrawDiagnostics -source 1.7 DuplicateAnnotationValue.java - */ -class DuplicateAnnotationValue { -} - -@interface A { int value(); } diff --git a/langtools/test/tools/javac/typeAnnotations/failures/common/parambounds/DuplicateAnnotationValue.out b/langtools/test/tools/javac/typeAnnotations/failures/common/parambounds/DuplicateAnnotationValue.out deleted file mode 100644 index 01a2f1603e7..00000000000 --- a/langtools/test/tools/javac/typeAnnotations/failures/common/parambounds/DuplicateAnnotationValue.out +++ /dev/null @@ -1,2 +0,0 @@ -DuplicateAnnotationValue.java:8:56: compiler.err.duplicate.annotation.member.value: value, A -1 error diff --git a/langtools/test/tools/javac/typeAnnotations/failures/common/parambounds/DuplicateTypeAnnotation.java b/langtools/test/tools/javac/typeAnnotations/failures/common/parambounds/DuplicateTypeAnnotation.java deleted file mode 100644 index 7fdb5c992da..00000000000 --- a/langtools/test/tools/javac/typeAnnotations/failures/common/parambounds/DuplicateTypeAnnotation.java +++ /dev/null @@ -1,12 +0,0 @@ -/* - * @test /nodynamiccopyright/ - * @bug 6843077 - * @summary check for duplicate annotations - * @author Mahmood Ali - * @compile/fail/ref=DuplicateTypeAnnotation.out -XDrawDiagnostics -source 1.7 DuplicateTypeAnnotation.java - */ - -class DuplicateTypeAnno { -} - -@interface A { } diff --git a/langtools/test/tools/javac/typeAnnotations/failures/common/parambounds/DuplicateTypeAnnotation.out b/langtools/test/tools/javac/typeAnnotations/failures/common/parambounds/DuplicateTypeAnnotation.out deleted file mode 100644 index 3b97ec81f46..00000000000 --- a/langtools/test/tools/javac/typeAnnotations/failures/common/parambounds/DuplicateTypeAnnotation.out +++ /dev/null @@ -1,2 +0,0 @@ -DuplicateTypeAnnotation.java:9:38: compiler.err.duplicate.annotation -1 error diff --git a/langtools/test/tools/javac/typeAnnotations/failures/common/parambounds/InvalidLocation.java b/langtools/test/tools/javac/typeAnnotations/failures/common/parambounds/InvalidLocation.java deleted file mode 100644 index 30a43321dc2..00000000000 --- a/langtools/test/tools/javac/typeAnnotations/failures/common/parambounds/InvalidLocation.java +++ /dev/null @@ -1,13 +0,0 @@ -/* - * @test /nodynamiccopyright/ - * @bug 6843077 - * @summary check for invalid annotatins given the target - * @author Mahmood Ali - * @compile/fail/ref=InvalidLocation.out -XDrawDiagnostics -source 1.7 InvalidLocation.java - */ - -class InvalidLocation { -} - -@java.lang.annotation.Target(java.lang.annotation.ElementType.TYPE) -@interface A { } diff --git a/langtools/test/tools/javac/typeAnnotations/failures/common/parambounds/InvalidLocation.out b/langtools/test/tools/javac/typeAnnotations/failures/common/parambounds/InvalidLocation.out deleted file mode 100644 index d474f174346..00000000000 --- a/langtools/test/tools/javac/typeAnnotations/failures/common/parambounds/InvalidLocation.out +++ /dev/null @@ -1,2 +0,0 @@ -InvalidLocation.java:9:33: compiler.err.annotation.type.not.applicable -1 error diff --git a/langtools/test/tools/javac/typeAnnotations/failures/common/parambounds/MissingAnnotationValue.java b/langtools/test/tools/javac/typeAnnotations/failures/common/parambounds/MissingAnnotationValue.java deleted file mode 100644 index ac73a70035f..00000000000 --- a/langtools/test/tools/javac/typeAnnotations/failures/common/parambounds/MissingAnnotationValue.java +++ /dev/null @@ -1,11 +0,0 @@ -/* - * @test /nodynamiccopyright/ - * @bug 6843077 - * @summary check for missing annotation value - * @author Mahmood Ali - * @compile/fail/ref=MissingAnnotationValue.out -XDrawDiagnostics -source 1.7 MissingAnnotationValue.java - */ -class MissingAnnotationValue { -} - -@interface A { int field(); } diff --git a/langtools/test/tools/javac/typeAnnotations/failures/common/parambounds/MissingAnnotationValue.out b/langtools/test/tools/javac/typeAnnotations/failures/common/parambounds/MissingAnnotationValue.out deleted file mode 100644 index b6d727e835f..00000000000 --- a/langtools/test/tools/javac/typeAnnotations/failures/common/parambounds/MissingAnnotationValue.out +++ /dev/null @@ -1,2 +0,0 @@ -MissingAnnotationValue.java:8:40: compiler.err.annotation.missing.default.value: A, field -1 error diff --git a/langtools/test/tools/javac/typeAnnotations/failures/common/receiver/DuplicateAnnotationValue.java b/langtools/test/tools/javac/typeAnnotations/failures/common/receiver/DuplicateAnnotationValue.java deleted file mode 100644 index 27844e6eed0..00000000000 --- a/langtools/test/tools/javac/typeAnnotations/failures/common/receiver/DuplicateAnnotationValue.java +++ /dev/null @@ -1,12 +0,0 @@ -/* - * @test /nodynamiccopyright/ - * @bug 6843077 6919944 - * @summary check for duplicate annotation values in receiver - * @author Mahmood Ali - * @compile/fail/ref=DuplicateAnnotationValue.out -XDrawDiagnostics -source 1.7 DuplicateAnnotationValue.java - */ -class DuplicateAnnotationValue { - void test() @A(value = 2, value = 1) { } -} - -@interface A { int value(); } diff --git a/langtools/test/tools/javac/typeAnnotations/failures/common/receiver/DuplicateAnnotationValue.out b/langtools/test/tools/javac/typeAnnotations/failures/common/receiver/DuplicateAnnotationValue.out deleted file mode 100644 index c1df363dd2e..00000000000 --- a/langtools/test/tools/javac/typeAnnotations/failures/common/receiver/DuplicateAnnotationValue.out +++ /dev/null @@ -1,2 +0,0 @@ -DuplicateAnnotationValue.java:9:29: compiler.err.duplicate.annotation.member.value: value, A -1 error diff --git a/langtools/test/tools/javac/typeAnnotations/failures/common/receiver/DuplicateTypeAnnotation.java b/langtools/test/tools/javac/typeAnnotations/failures/common/receiver/DuplicateTypeAnnotation.java deleted file mode 100644 index 791497cd445..00000000000 --- a/langtools/test/tools/javac/typeAnnotations/failures/common/receiver/DuplicateTypeAnnotation.java +++ /dev/null @@ -1,13 +0,0 @@ -/* - * @test /nodynamiccopyright/ - * @bug 6843077 - * @summary check for duplicate annotations in receiver - * @author Mahmood Ali - * @compile/fail/ref=DuplicateTypeAnnotation.out -XDrawDiagnostics -source 1.7 DuplicateTypeAnnotation.java - */ - -class DuplicateTypeAnnotation { - void test() @A @A { } -} - -@interface A { } diff --git a/langtools/test/tools/javac/typeAnnotations/failures/common/receiver/DuplicateTypeAnnotation.out b/langtools/test/tools/javac/typeAnnotations/failures/common/receiver/DuplicateTypeAnnotation.out deleted file mode 100644 index 565aae06318..00000000000 --- a/langtools/test/tools/javac/typeAnnotations/failures/common/receiver/DuplicateTypeAnnotation.out +++ /dev/null @@ -1,2 +0,0 @@ -DuplicateTypeAnnotation.java:10:18: compiler.err.duplicate.annotation -1 error diff --git a/langtools/test/tools/javac/typeAnnotations/failures/common/receiver/InvalidLocation.java b/langtools/test/tools/javac/typeAnnotations/failures/common/receiver/InvalidLocation.java deleted file mode 100644 index 8ffd9e244aa..00000000000 --- a/langtools/test/tools/javac/typeAnnotations/failures/common/receiver/InvalidLocation.java +++ /dev/null @@ -1,15 +0,0 @@ -/* - * @test /nodynamiccopyright/ - * @bug 6843077 - * @summary check for invalid annotatins given the target - * @author Mahmood Ali - * @compile/fail/ref=InvalidLocation.out -XDrawDiagnostics -source 1.7 InvalidLocation.java - */ - -class InvalidLocation { - void test() @A { - } -} - -@java.lang.annotation.Target(java.lang.annotation.ElementType.TYPE) -@interface A { } diff --git a/langtools/test/tools/javac/typeAnnotations/failures/common/receiver/InvalidLocation.out b/langtools/test/tools/javac/typeAnnotations/failures/common/receiver/InvalidLocation.out deleted file mode 100644 index c82f335cfa3..00000000000 --- a/langtools/test/tools/javac/typeAnnotations/failures/common/receiver/InvalidLocation.out +++ /dev/null @@ -1,2 +0,0 @@ -InvalidLocation.java:10:15: compiler.err.annotation.type.not.applicable -1 error diff --git a/langtools/test/tools/javac/typeAnnotations/failures/common/receiver/MissingAnnotationValue.java b/langtools/test/tools/javac/typeAnnotations/failures/common/receiver/MissingAnnotationValue.java deleted file mode 100644 index e4b8536ef65..00000000000 --- a/langtools/test/tools/javac/typeAnnotations/failures/common/receiver/MissingAnnotationValue.java +++ /dev/null @@ -1,12 +0,0 @@ -/* - * @test /nodynamiccopyright/ - * @bug 6843077 - * @summary check for missing annotation value - * @author Mahmood Ali - * @compile/fail/ref=MissingAnnotationValue.out -XDrawDiagnostics -source 1.7 MissingAnnotationValue.java - */ -class MissingAnnotationValue { - void test() @A { } -} - -@interface A { int field(); } diff --git a/langtools/test/tools/javac/typeAnnotations/failures/common/receiver/MissingAnnotationValue.out b/langtools/test/tools/javac/typeAnnotations/failures/common/receiver/MissingAnnotationValue.out deleted file mode 100644 index f3f66d2e428..00000000000 --- a/langtools/test/tools/javac/typeAnnotations/failures/common/receiver/MissingAnnotationValue.out +++ /dev/null @@ -1,2 +0,0 @@ -MissingAnnotationValue.java:9:15: compiler.err.annotation.missing.default.value: A, field -1 error diff --git a/langtools/test/tools/javac/typeAnnotations/failures/common/rest/DuplicateAnnotationValue.java b/langtools/test/tools/javac/typeAnnotations/failures/common/rest/DuplicateAnnotationValue.java deleted file mode 100644 index 70621e74940..00000000000 --- a/langtools/test/tools/javac/typeAnnotations/failures/common/rest/DuplicateAnnotationValue.java +++ /dev/null @@ -1,14 +0,0 @@ -/* - * @test /nodynamiccopyright/ - * @bug 6843077 - * @summary check for Duplicate annotation value - * @author Mahmood Ali - * @compile/fail/ref=DuplicateAnnotationValue.out -XDrawDiagnostics -source 1.7 DuplicateAnnotationValue.java - */ -class DuplicateAnnotationValue { - void test() { - new @A String(); - } -} - -@interface A { int field(); } diff --git a/langtools/test/tools/javac/typeAnnotations/failures/common/rest/DuplicateAnnotationValue.out b/langtools/test/tools/javac/typeAnnotations/failures/common/rest/DuplicateAnnotationValue.out deleted file mode 100644 index 0b3be7cc3fd..00000000000 --- a/langtools/test/tools/javac/typeAnnotations/failures/common/rest/DuplicateAnnotationValue.out +++ /dev/null @@ -1,2 +0,0 @@ -DuplicateAnnotationValue.java:10:9: compiler.err.annotation.missing.default.value: A, field -1 error diff --git a/langtools/test/tools/javac/typeAnnotations/failures/common/rest/DuplicateTypeAnnotation.java b/langtools/test/tools/javac/typeAnnotations/failures/common/rest/DuplicateTypeAnnotation.java deleted file mode 100644 index ae541996fd4..00000000000 --- a/langtools/test/tools/javac/typeAnnotations/failures/common/rest/DuplicateTypeAnnotation.java +++ /dev/null @@ -1,15 +0,0 @@ -/* - * @test /nodynamiccopyright/ - * @bug 6843077 - * @summary check for duplicate annotations - * @author Mahmood Ali - * @compile/fail/ref=DuplicateTypeAnnotation.out -XDrawDiagnostics -source 1.7 DuplicateTypeAnnotation.java - */ - -class DuplicateTypeAnnotation { - void test() { - new @A @A String(); - } -} - -@interface A { } diff --git a/langtools/test/tools/javac/typeAnnotations/failures/common/rest/DuplicateTypeAnnotation.out b/langtools/test/tools/javac/typeAnnotations/failures/common/rest/DuplicateTypeAnnotation.out deleted file mode 100644 index 13b6046e94c..00000000000 --- a/langtools/test/tools/javac/typeAnnotations/failures/common/rest/DuplicateTypeAnnotation.out +++ /dev/null @@ -1,2 +0,0 @@ -DuplicateTypeAnnotation.java:11:12: compiler.err.duplicate.annotation -1 error diff --git a/langtools/test/tools/javac/typeAnnotations/failures/common/rest/InvalidLocation.java b/langtools/test/tools/javac/typeAnnotations/failures/common/rest/InvalidLocation.java deleted file mode 100644 index 92f38ae479c..00000000000 --- a/langtools/test/tools/javac/typeAnnotations/failures/common/rest/InvalidLocation.java +++ /dev/null @@ -1,16 +0,0 @@ -/* - * @test /nodynamiccopyright/ - * @bug 6843077 - * @summary check for invalid annotatins given the target - * @author Mahmood Ali - * @compile/fail/ref=InvalidLocation.out -XDrawDiagnostics -source 1.7 InvalidLocation.java - */ - -class InvalidLocation { - void test() { - new @A String(); - } -} - -@java.lang.annotation.Target(java.lang.annotation.ElementType.TYPE) -@interface A { } diff --git a/langtools/test/tools/javac/typeAnnotations/failures/common/rest/InvalidLocation.out b/langtools/test/tools/javac/typeAnnotations/failures/common/rest/InvalidLocation.out deleted file mode 100644 index ad9861c2f6f..00000000000 --- a/langtools/test/tools/javac/typeAnnotations/failures/common/rest/InvalidLocation.out +++ /dev/null @@ -1,2 +0,0 @@ -InvalidLocation.java:11:9: compiler.err.annotation.type.not.applicable -1 error diff --git a/langtools/test/tools/javac/typeAnnotations/failures/common/rest/MissingAnnotationValue.java b/langtools/test/tools/javac/typeAnnotations/failures/common/rest/MissingAnnotationValue.java deleted file mode 100644 index 6b64f2d54c8..00000000000 --- a/langtools/test/tools/javac/typeAnnotations/failures/common/rest/MissingAnnotationValue.java +++ /dev/null @@ -1,14 +0,0 @@ -/* - * @test /nodynamiccopyright/ - * @bug 6843077 - * @summary check for missing annotation value - * @author Mahmood Ali - * @compile/fail/ref=MissingAnnotationValue.out -XDrawDiagnostics -source 1.7 MissingAnnotationValue.java - */ -class MissingAnnotationValue { - void test() { - new @A String(); - } -} - -@interface A { int field(); } diff --git a/langtools/test/tools/javac/typeAnnotations/failures/common/rest/MissingAnnotationValue.out b/langtools/test/tools/javac/typeAnnotations/failures/common/rest/MissingAnnotationValue.out deleted file mode 100644 index f83f6dfa58a..00000000000 --- a/langtools/test/tools/javac/typeAnnotations/failures/common/rest/MissingAnnotationValue.out +++ /dev/null @@ -1,2 +0,0 @@ -MissingAnnotationValue.java:10:9: compiler.err.annotation.missing.default.value: A, field -1 error diff --git a/langtools/test/tools/javac/typeAnnotations/failures/common/typeArgs/DuplicateAnnotationValue.java b/langtools/test/tools/javac/typeAnnotations/failures/common/typeArgs/DuplicateAnnotationValue.java deleted file mode 100644 index e09ee4e2f00..00000000000 --- a/langtools/test/tools/javac/typeAnnotations/failures/common/typeArgs/DuplicateAnnotationValue.java +++ /dev/null @@ -1,12 +0,0 @@ -/* - * @test /nodynamiccopyright/ - * @bug 6843077 6919944 - * @summary check for duplicate annotation values for type parameter - * @author Mahmood Ali - * @compile/fail/ref=DuplicateAnnotationValue.out -XDrawDiagnostics -source 1.7 DuplicateAnnotationValue.java - */ -class DuplicateAnnotationValue { - DuplicateAnnotationValue<@A(value = 2, value = 1) String> l; -} - -@interface A { int value(); } diff --git a/langtools/test/tools/javac/typeAnnotations/failures/common/typeArgs/DuplicateAnnotationValue.out b/langtools/test/tools/javac/typeAnnotations/failures/common/typeArgs/DuplicateAnnotationValue.out deleted file mode 100644 index e2ecdfb4829..00000000000 --- a/langtools/test/tools/javac/typeAnnotations/failures/common/typeArgs/DuplicateAnnotationValue.out +++ /dev/null @@ -1,2 +0,0 @@ -DuplicateAnnotationValue.java:9:42: compiler.err.duplicate.annotation.member.value: value, A -1 error diff --git a/langtools/test/tools/javac/typeAnnotations/failures/common/typeArgs/DuplicateTypeAnnotation.java b/langtools/test/tools/javac/typeAnnotations/failures/common/typeArgs/DuplicateTypeAnnotation.java deleted file mode 100644 index 3877a001b47..00000000000 --- a/langtools/test/tools/javac/typeAnnotations/failures/common/typeArgs/DuplicateTypeAnnotation.java +++ /dev/null @@ -1,13 +0,0 @@ -/* - * @test /nodynamiccopyright/ - * @bug 6843077 - * @summary check for duplicate annotations - * @author Mahmood Ali - * @compile/fail/ref=DuplicateTypeAnnotation.out -XDrawDiagnostics -source 1.7 DuplicateTypeAnnotation.java - */ - -class DuplicateTypeAnno { - DuplicateTypeAnno<@A @A String> l; -} - -@interface A { } diff --git a/langtools/test/tools/javac/typeAnnotations/failures/common/typeArgs/DuplicateTypeAnnotation.out b/langtools/test/tools/javac/typeAnnotations/failures/common/typeArgs/DuplicateTypeAnnotation.out deleted file mode 100644 index 738591669fe..00000000000 --- a/langtools/test/tools/javac/typeAnnotations/failures/common/typeArgs/DuplicateTypeAnnotation.out +++ /dev/null @@ -1,2 +0,0 @@ -DuplicateTypeAnnotation.java:10:24: compiler.err.duplicate.annotation -1 error diff --git a/langtools/test/tools/javac/typeAnnotations/failures/common/typeArgs/InvalidLocation.java b/langtools/test/tools/javac/typeAnnotations/failures/common/typeArgs/InvalidLocation.java deleted file mode 100644 index 7affd108e72..00000000000 --- a/langtools/test/tools/javac/typeAnnotations/failures/common/typeArgs/InvalidLocation.java +++ /dev/null @@ -1,14 +0,0 @@ -/* - * @test /nodynamiccopyright/ - * @bug 6843077 - * @summary check for invalid annotatins given the target - * @author Mahmood Ali - * @compile/fail/ref=InvalidLocation.out -XDrawDiagnostics -source 1.7 InvalidLocation.java - */ - -class InvalidLocation { - InvalidLocation<@A String> l; -} - -@java.lang.annotation.Target(java.lang.annotation.ElementType.TYPE) -@interface A { } diff --git a/langtools/test/tools/javac/typeAnnotations/failures/common/typeArgs/InvalidLocation.out b/langtools/test/tools/javac/typeAnnotations/failures/common/typeArgs/InvalidLocation.out deleted file mode 100644 index 30841b78f0f..00000000000 --- a/langtools/test/tools/javac/typeAnnotations/failures/common/typeArgs/InvalidLocation.out +++ /dev/null @@ -1,2 +0,0 @@ -InvalidLocation.java:10:19: compiler.err.annotation.type.not.applicable -1 error diff --git a/langtools/test/tools/javac/typeAnnotations/failures/common/typeArgs/MissingAnnotationValue.java b/langtools/test/tools/javac/typeAnnotations/failures/common/typeArgs/MissingAnnotationValue.java deleted file mode 100644 index fe078ab98fe..00000000000 --- a/langtools/test/tools/javac/typeAnnotations/failures/common/typeArgs/MissingAnnotationValue.java +++ /dev/null @@ -1,12 +0,0 @@ -/* - * @test /nodynamiccopyright/ - * @bug 6843077 - * @summary check for missing annotation value - * @author Mahmood Ali - * @compile/fail/ref=MissingAnnotationValue.out -XDrawDiagnostics -source 1.7 MissingAnnotationValue.java - */ -class MissingAnnotationValue { - MissingAnnotationValue<@A String> l; -} - -@interface A { int field(); } diff --git a/langtools/test/tools/javac/typeAnnotations/failures/common/typeArgs/MissingAnnotationValue.out b/langtools/test/tools/javac/typeAnnotations/failures/common/typeArgs/MissingAnnotationValue.out deleted file mode 100644 index 749442f45b6..00000000000 --- a/langtools/test/tools/javac/typeAnnotations/failures/common/typeArgs/MissingAnnotationValue.out +++ /dev/null @@ -1,2 +0,0 @@ -MissingAnnotationValue.java:9:26: compiler.err.annotation.missing.default.value: A, field -1 error diff --git a/langtools/test/tools/javac/typeAnnotations/failures/common/typeparams/DuplicateAnnotationValue.java b/langtools/test/tools/javac/typeAnnotations/failures/common/typeparams/DuplicateAnnotationValue.java deleted file mode 100644 index 2f40f713a7c..00000000000 --- a/langtools/test/tools/javac/typeAnnotations/failures/common/typeparams/DuplicateAnnotationValue.java +++ /dev/null @@ -1,11 +0,0 @@ -/* - * @test /nodynamiccopyright/ - * @bug 6843077 6919944 - * @summary check for duplicate annotation values for type parameter - * @author Mahmood Ali - * @compile/fail/ref=DuplicateAnnotationValue.out -XDrawDiagnostics -source 1.7 DuplicateAnnotationValue.java - */ -class DuplicateAnnotationValue<@A(value = 2, value = 1) K> { -} - -@interface A { int value(); } diff --git a/langtools/test/tools/javac/typeAnnotations/failures/common/typeparams/DuplicateAnnotationValue.out b/langtools/test/tools/javac/typeAnnotations/failures/common/typeparams/DuplicateAnnotationValue.out deleted file mode 100644 index a9846317257..00000000000 --- a/langtools/test/tools/javac/typeAnnotations/failures/common/typeparams/DuplicateAnnotationValue.out +++ /dev/null @@ -1,2 +0,0 @@ -DuplicateAnnotationValue.java:8:46: compiler.err.duplicate.annotation.member.value: value, A -1 error diff --git a/langtools/test/tools/javac/typeAnnotations/failures/common/typeparams/DuplicateTypeAnnotation.java b/langtools/test/tools/javac/typeAnnotations/failures/common/typeparams/DuplicateTypeAnnotation.java deleted file mode 100644 index 1fb65c74f33..00000000000 --- a/langtools/test/tools/javac/typeAnnotations/failures/common/typeparams/DuplicateTypeAnnotation.java +++ /dev/null @@ -1,12 +0,0 @@ -/* - * @test /nodynamiccopyright/ - * @bug 6843077 - * @summary check for duplicate annotations - * @author Mahmood Ali - * @compile/fail/ref=DuplicateTypeAnnotation.out -XDrawDiagnostics -source 1.7 DuplicateTypeAnnotation.java - */ - -class DuplicateTypeAnno<@A @A K> { -} - -@interface A { } diff --git a/langtools/test/tools/javac/typeAnnotations/failures/common/typeparams/DuplicateTypeAnnotation.out b/langtools/test/tools/javac/typeAnnotations/failures/common/typeparams/DuplicateTypeAnnotation.out deleted file mode 100644 index 6e7a1af2bd3..00000000000 --- a/langtools/test/tools/javac/typeAnnotations/failures/common/typeparams/DuplicateTypeAnnotation.out +++ /dev/null @@ -1,2 +0,0 @@ -DuplicateTypeAnnotation.java:9:28: compiler.err.duplicate.annotation -1 error diff --git a/langtools/test/tools/javac/typeAnnotations/failures/common/typeparams/InvalidLocation.java b/langtools/test/tools/javac/typeAnnotations/failures/common/typeparams/InvalidLocation.java deleted file mode 100644 index c9d00c4f55c..00000000000 --- a/langtools/test/tools/javac/typeAnnotations/failures/common/typeparams/InvalidLocation.java +++ /dev/null @@ -1,13 +0,0 @@ -/* - * @test /nodynamiccopyright/ - * @bug 6843077 - * @summary check for invalid annotatins given the target - * @author Mahmood Ali - * @compile/fail/ref=InvalidLocation.out -XDrawDiagnostics -source 1.7 InvalidLocation.java - */ - -class InvalidLocation<@A K> { -} - -@java.lang.annotation.Target(java.lang.annotation.ElementType.TYPE) -@interface A { } diff --git a/langtools/test/tools/javac/typeAnnotations/failures/common/typeparams/InvalidLocation.out b/langtools/test/tools/javac/typeAnnotations/failures/common/typeparams/InvalidLocation.out deleted file mode 100644 index 87d42a278c4..00000000000 --- a/langtools/test/tools/javac/typeAnnotations/failures/common/typeparams/InvalidLocation.out +++ /dev/null @@ -1,2 +0,0 @@ -InvalidLocation.java:9:23: compiler.err.annotation.type.not.applicable -1 error diff --git a/langtools/test/tools/javac/typeAnnotations/failures/common/typeparams/MissingAnnotationValue.java b/langtools/test/tools/javac/typeAnnotations/failures/common/typeparams/MissingAnnotationValue.java deleted file mode 100644 index 9d4cbef2e9a..00000000000 --- a/langtools/test/tools/javac/typeAnnotations/failures/common/typeparams/MissingAnnotationValue.java +++ /dev/null @@ -1,11 +0,0 @@ -/* - * @test /nodynamiccopyright/ - * @bug 6843077 - * @summary check for missing annotation value - * @author Mahmood Ali - * @compile/fail/ref=MissingAnnotationValue.out -XDrawDiagnostics -source 1.7 MissingAnnotationValue.java - */ -class MissingAnnotationValue<@A K> { -} - -@interface A { int field(); } diff --git a/langtools/test/tools/javac/typeAnnotations/failures/common/typeparams/MissingAnnotationValue.out b/langtools/test/tools/javac/typeAnnotations/failures/common/typeparams/MissingAnnotationValue.out deleted file mode 100644 index acac021869b..00000000000 --- a/langtools/test/tools/javac/typeAnnotations/failures/common/typeparams/MissingAnnotationValue.out +++ /dev/null @@ -1,2 +0,0 @@ -MissingAnnotationValue.java:8:30: compiler.err.annotation.missing.default.value: A, field -1 error diff --git a/langtools/test/tools/javac/typeAnnotations/failures/common/wildcards/DuplicateAnnotationValue.java b/langtools/test/tools/javac/typeAnnotations/failures/common/wildcards/DuplicateAnnotationValue.java deleted file mode 100644 index 44321123cb5..00000000000 --- a/langtools/test/tools/javac/typeAnnotations/failures/common/wildcards/DuplicateAnnotationValue.java +++ /dev/null @@ -1,12 +0,0 @@ -/* - * @test /nodynamiccopyright/ - * @bug 6843077 6919944 - * @summary check for duplicate annotation values for type parameter - * @author Mahmood Ali - * @compile/fail/ref=DuplicateAnnotationValue.out -XDrawDiagnostics -source 1.7 DuplicateAnnotationValue.java - */ -class DuplicateAnnotationValue { - DuplicateAnnotationValue<@A(value = 2, value = 1) ?> l; -} - -@interface A { int value(); } diff --git a/langtools/test/tools/javac/typeAnnotations/failures/common/wildcards/DuplicateAnnotationValue.out b/langtools/test/tools/javac/typeAnnotations/failures/common/wildcards/DuplicateAnnotationValue.out deleted file mode 100644 index e2ecdfb4829..00000000000 --- a/langtools/test/tools/javac/typeAnnotations/failures/common/wildcards/DuplicateAnnotationValue.out +++ /dev/null @@ -1,2 +0,0 @@ -DuplicateAnnotationValue.java:9:42: compiler.err.duplicate.annotation.member.value: value, A -1 error diff --git a/langtools/test/tools/javac/typeAnnotations/failures/common/wildcards/DuplicateTypeAnnotation.java b/langtools/test/tools/javac/typeAnnotations/failures/common/wildcards/DuplicateTypeAnnotation.java deleted file mode 100644 index b6a2e47d87a..00000000000 --- a/langtools/test/tools/javac/typeAnnotations/failures/common/wildcards/DuplicateTypeAnnotation.java +++ /dev/null @@ -1,13 +0,0 @@ -/* - * @test /nodynamiccopyright/ - * @bug 6843077 - * @summary check for duplicate annotations - * @author Mahmood Ali - * @compile/fail/ref=DuplicateTypeAnnotation.out -XDrawDiagnostics -source 1.7 DuplicateTypeAnnotation.java - */ - -class DuplicateTypeAnno { - DuplicateTypeAnno<@A @A ?> l; -} - -@interface A { } diff --git a/langtools/test/tools/javac/typeAnnotations/failures/common/wildcards/DuplicateTypeAnnotation.out b/langtools/test/tools/javac/typeAnnotations/failures/common/wildcards/DuplicateTypeAnnotation.out deleted file mode 100644 index 738591669fe..00000000000 --- a/langtools/test/tools/javac/typeAnnotations/failures/common/wildcards/DuplicateTypeAnnotation.out +++ /dev/null @@ -1,2 +0,0 @@ -DuplicateTypeAnnotation.java:10:24: compiler.err.duplicate.annotation -1 error diff --git a/langtools/test/tools/javac/typeAnnotations/failures/common/wildcards/InvalidLocation.java b/langtools/test/tools/javac/typeAnnotations/failures/common/wildcards/InvalidLocation.java deleted file mode 100644 index addb1e8dcff..00000000000 --- a/langtools/test/tools/javac/typeAnnotations/failures/common/wildcards/InvalidLocation.java +++ /dev/null @@ -1,14 +0,0 @@ -/* - * @test /nodynamiccopyright/ - * @bug 6843077 - * @summary check for invalid annotatins given the target - * @author Mahmood Ali - * @compile/fail/ref=InvalidLocation.out -XDrawDiagnostics -source 1.7 InvalidLocation.java - */ - -class InvalidLocation { - InvalidLocation<@A ?> l; -} - -@java.lang.annotation.Target(java.lang.annotation.ElementType.TYPE) -@interface A { } diff --git a/langtools/test/tools/javac/typeAnnotations/failures/common/wildcards/InvalidLocation.out b/langtools/test/tools/javac/typeAnnotations/failures/common/wildcards/InvalidLocation.out deleted file mode 100644 index 30841b78f0f..00000000000 --- a/langtools/test/tools/javac/typeAnnotations/failures/common/wildcards/InvalidLocation.out +++ /dev/null @@ -1,2 +0,0 @@ -InvalidLocation.java:10:19: compiler.err.annotation.type.not.applicable -1 error diff --git a/langtools/test/tools/javac/typeAnnotations/failures/common/wildcards/MissingAnnotationValue.java b/langtools/test/tools/javac/typeAnnotations/failures/common/wildcards/MissingAnnotationValue.java deleted file mode 100644 index 1178294799f..00000000000 --- a/langtools/test/tools/javac/typeAnnotations/failures/common/wildcards/MissingAnnotationValue.java +++ /dev/null @@ -1,12 +0,0 @@ -/* - * @test /nodynamiccopyright/ - * @bug 6843077 - * @summary check for missing annotation value - * @author Mahmood Ali - * @compile/fail/ref=MissingAnnotationValue.out -XDrawDiagnostics -source 1.7 MissingAnnotationValue.java - */ -class MissingAnnotationValue { - MissingAnnotationValue<@A ?> l; -} - -@interface A { int field(); } diff --git a/langtools/test/tools/javac/typeAnnotations/failures/common/wildcards/MissingAnnotationValue.out b/langtools/test/tools/javac/typeAnnotations/failures/common/wildcards/MissingAnnotationValue.out deleted file mode 100644 index 749442f45b6..00000000000 --- a/langtools/test/tools/javac/typeAnnotations/failures/common/wildcards/MissingAnnotationValue.out +++ /dev/null @@ -1,2 +0,0 @@ -MissingAnnotationValue.java:9:26: compiler.err.annotation.missing.default.value: A, field -1 error diff --git a/langtools/test/tools/javac/typeAnnotations/failures/target/Constructor.java b/langtools/test/tools/javac/typeAnnotations/failures/target/Constructor.java deleted file mode 100644 index 284a9649a1b..00000000000 --- a/langtools/test/tools/javac/typeAnnotations/failures/target/Constructor.java +++ /dev/null @@ -1,17 +0,0 @@ -/* - * @test /nodynamiccopyright/ - * @bug 6843077 - * @summary test invalid location of TypeUse - * @author Mahmood Ali - * @compile/fail/ref=Constructor.out -XDrawDiagnostics -source 1.7 Constructor.java - */ - -import java.lang.annotation.Target; -import java.lang.annotation.ElementType; - -class Constructor { - @A Constructor() { } -} - -@Target(ElementType.TYPE_USE) -@interface A { } diff --git a/langtools/test/tools/javac/typeAnnotations/failures/target/Constructor.out b/langtools/test/tools/javac/typeAnnotations/failures/target/Constructor.out deleted file mode 100644 index 5114f23816f..00000000000 --- a/langtools/test/tools/javac/typeAnnotations/failures/target/Constructor.out +++ /dev/null @@ -1,2 +0,0 @@ -Constructor.java:13:3: compiler.err.annotation.type.not.applicable -1 error diff --git a/langtools/test/tools/javac/typeAnnotations/failures/target/IncompleteArray.java b/langtools/test/tools/javac/typeAnnotations/failures/target/IncompleteArray.java deleted file mode 100644 index 8edb60807d4..00000000000 --- a/langtools/test/tools/javac/typeAnnotations/failures/target/IncompleteArray.java +++ /dev/null @@ -1,12 +0,0 @@ -/* - * @test /nodynamiccopyright/ - * @bug 6843077 - * @summary test incomplete array declaration - * @author Mahmood Ali - * @compile/fail/ref=IncompleteArray.out -XDrawDiagnostics -source 1.7 IncompleteArray.java - */ -class IncompleteArray { - int @A [] @A var; -} - -@interface A { } diff --git a/langtools/test/tools/javac/typeAnnotations/failures/target/IncompleteArray.out b/langtools/test/tools/javac/typeAnnotations/failures/target/IncompleteArray.out deleted file mode 100644 index a03a09283ee..00000000000 --- a/langtools/test/tools/javac/typeAnnotations/failures/target/IncompleteArray.out +++ /dev/null @@ -1,2 +0,0 @@ -IncompleteArray.java:9:13: compiler.err.illegal.start.of.type -1 error diff --git a/langtools/test/tools/javac/typeAnnotations/failures/target/NotTypeParameter.java b/langtools/test/tools/javac/typeAnnotations/failures/target/NotTypeParameter.java deleted file mode 100644 index 457a7ef6730..00000000000 --- a/langtools/test/tools/javac/typeAnnotations/failures/target/NotTypeParameter.java +++ /dev/null @@ -1,17 +0,0 @@ -/* - * @test /nodynamiccopyright/ - * @bug 6843077 - * @summary test invalid location of TypeUse - * @author Mahmood Ali - * @compile/fail/ref=NotTypeParameter.out -XDrawDiagnostics -source 1.7 NotTypeParameter.java - */ - -import java.lang.annotation.Target; -import java.lang.annotation.ElementType; - -class VoidMethod<@A K> { - @A void test() { } -} - -@Target(ElementType.TYPE_USE) -@interface A { } diff --git a/langtools/test/tools/javac/typeAnnotations/failures/target/NotTypeParameter.out b/langtools/test/tools/javac/typeAnnotations/failures/target/NotTypeParameter.out deleted file mode 100644 index 8c6dcaf8b39..00000000000 --- a/langtools/test/tools/javac/typeAnnotations/failures/target/NotTypeParameter.out +++ /dev/null @@ -1,3 +0,0 @@ -NotTypeParameter.java:13:3: compiler.err.annotation.type.not.applicable -NotTypeParameter.java:12:18: compiler.err.annotation.type.not.applicable -2 errors diff --git a/langtools/test/tools/javac/typeAnnotations/failures/target/NotTypeUse.java b/langtools/test/tools/javac/typeAnnotations/failures/target/NotTypeUse.java deleted file mode 100644 index 407c0b218dd..00000000000 --- a/langtools/test/tools/javac/typeAnnotations/failures/target/NotTypeUse.java +++ /dev/null @@ -1,17 +0,0 @@ -/* - * @test /nodynamiccopyright/ - * @bug 6843077 - * @summary test invalid location of TypeUse - * @author Mahmood Ali - * @compile/fail/ref=NotTypeUse.out -XDrawDiagnostics -source 1.7 NotTypeUse.java - */ - -import java.lang.annotation.Target; -import java.lang.annotation.ElementType; - -class VoidMethod { - @A void test() { } -} - -@Target(ElementType.TYPE) -@interface A { } diff --git a/langtools/test/tools/javac/typeAnnotations/failures/target/NotTypeUse.out b/langtools/test/tools/javac/typeAnnotations/failures/target/NotTypeUse.out deleted file mode 100644 index 9728d3589ec..00000000000 --- a/langtools/test/tools/javac/typeAnnotations/failures/target/NotTypeUse.out +++ /dev/null @@ -1,2 +0,0 @@ -NotTypeUse.java:13:3: compiler.err.annotation.type.not.applicable -1 error diff --git a/langtools/test/tools/javac/typeAnnotations/failures/target/VoidMethod.java b/langtools/test/tools/javac/typeAnnotations/failures/target/VoidMethod.java deleted file mode 100644 index a16bf1917fe..00000000000 --- a/langtools/test/tools/javac/typeAnnotations/failures/target/VoidMethod.java +++ /dev/null @@ -1,17 +0,0 @@ -/* - * @test /nodynamiccopyright/ - * @bug 6843077 - * @summary test invalid location of TypeUse - * @author Mahmood Ali - * @compile/fail/ref=VoidMethod.out -XDrawDiagnostics -source 1.7 VoidMethod.java - */ - -import java.lang.annotation.Target; -import java.lang.annotation.ElementType; - -class VoidMethod { - @A void test() { } -} - -@Target(ElementType.TYPE_USE) -@interface A { } diff --git a/langtools/test/tools/javac/typeAnnotations/failures/target/VoidMethod.out b/langtools/test/tools/javac/typeAnnotations/failures/target/VoidMethod.out deleted file mode 100644 index b7569540158..00000000000 --- a/langtools/test/tools/javac/typeAnnotations/failures/target/VoidMethod.out +++ /dev/null @@ -1,2 +0,0 @@ -VoidMethod.java:13:3: compiler.err.annotation.type.not.applicable -1 error diff --git a/langtools/test/tools/javac/typeAnnotations/newlocations/BasicTest.java b/langtools/test/tools/javac/typeAnnotations/newlocations/BasicTest.java index 24175fa1f0c..deaa4015c44 100644 --- a/langtools/test/tools/javac/typeAnnotations/newlocations/BasicTest.java +++ b/langtools/test/tools/javac/typeAnnotations/newlocations/BasicTest.java @@ -27,7 +27,7 @@ * @bug 6843077 * @summary random tests for new locations * @author Matt Papi - * @compile -source 1.7 BasicTest.java + * @compile/fail/ref=BasicTest.out -XDrawDiagnostics BasicTest.java */ import java.util.*; @@ -38,6 +38,8 @@ import java.io.*; @interface C {} @interface D {} +//308: Test inverted to verify that type annotations can not be parsed yet. + /** * Tests basic JSR 308 parser functionality. We don't really care about what * the parse tree looks like, just that these annotations can be parsed. diff --git a/langtools/test/tools/javac/typeAnnotations/newlocations/BasicTest.out b/langtools/test/tools/javac/typeAnnotations/newlocations/BasicTest.out new file mode 100644 index 00000000000..9973f328fbd --- /dev/null +++ b/langtools/test/tools/javac/typeAnnotations/newlocations/BasicTest.out @@ -0,0 +1,66 @@ +BasicTest.java:47:27: compiler.err.illegal.start.of.type +BasicTest.java:47:28: compiler.err.expected: '{' +BasicTest.java:47:36: compiler.err.expected: token.identifier +BasicTest.java:47:38: compiler.err.illegal.start.of.type +BasicTest.java:47:45: compiler.err.expected: token.identifier +BasicTest.java:47:47: compiler.err.expected: ';' +BasicTest.java:47:62: compiler.err.expected: token.identifier +BasicTest.java:47:84: compiler.err.expected: token.identifier +BasicTest.java:52:22: compiler.err.illegal.start.of.expr +BasicTest.java:52:31: compiler.err.expected: ';' +BasicTest.java:52:37: compiler.err.expected: token.identifier +BasicTest.java:53:21: compiler.err.illegal.start.of.expr +BasicTest.java:53:23: compiler.err.expected: ';' +BasicTest.java:53:30: compiler.err.expected: token.identifier +BasicTest.java:53:32: compiler.err.illegal.start.of.type +BasicTest.java:53:37: compiler.err.expected: token.identifier +BasicTest.java:53:38: compiler.err.expected: ';' +BasicTest.java:56:17: compiler.err.expected: token.identifier +BasicTest.java:56:23: compiler.err.expected: token.identifier +BasicTest.java:56:24: compiler.err.expected2: '(', '[' +BasicTest.java:56:25: compiler.err.expected: ';' +BasicTest.java:56:27: compiler.err.invalid.meth.decl.ret.type.req +BasicTest.java:56:34: compiler.err.illegal.start.of.type +BasicTest.java:58:34: compiler.err.illegal.start.of.type +BasicTest.java:61:16: compiler.err.illegal.start.of.type +BasicTest.java:61:18: compiler.err.expected: ';' +BasicTest.java:61:24: compiler.err.illegal.start.of.type +BasicTest.java:61:26: compiler.err.expected: ';' +BasicTest.java:61:33: compiler.err.expected: token.identifier +BasicTest.java:61:34: compiler.err.illegal.start.of.type +BasicTest.java:61:35: compiler.err.expected: token.identifier +BasicTest.java:61:37: compiler.err.expected: ';' +BasicTest.java:61:45: compiler.err.expected: token.identifier +BasicTest.java:61:50: compiler.err.expected: token.identifier +BasicTest.java:62:16: compiler.err.expected: token.identifier +BasicTest.java:62:17: compiler.err.expected2: '(', '[' +BasicTest.java:62:18: compiler.err.expected: ';' +BasicTest.java:62:28: compiler.err.illegal.start.of.type +BasicTest.java:62:30: compiler.err.expected: ';' +BasicTest.java:62:36: compiler.err.illegal.start.of.type +BasicTest.java:62:38: compiler.err.expected: ';' +BasicTest.java:62:45: compiler.err.expected: token.identifier +BasicTest.java:62:46: compiler.err.illegal.start.of.type +BasicTest.java:62:47: compiler.err.expected: token.identifier +BasicTest.java:62:49: compiler.err.expected: ';' +BasicTest.java:62:57: compiler.err.expected: token.identifier +BasicTest.java:62:58: compiler.err.illegal.start.of.type +BasicTest.java:62:59: compiler.err.expected: token.identifier +BasicTest.java:64:25: compiler.err.illegal.start.of.type +BasicTest.java:64:27: compiler.err.expected: ';' +BasicTest.java:64:34: compiler.err.expected: token.identifier +BasicTest.java:64:38: compiler.err.expected: token.identifier +BasicTest.java:64:41: compiler.err.illegal.start.of.expr +BasicTest.java:64:50: compiler.err.expected: ';' +BasicTest.java:64:56: compiler.err.expected: token.identifier +BasicTest.java:69:17: compiler.err.expected: ';' +BasicTest.java:69:24: compiler.err.illegal.start.of.type +BasicTest.java:69:30: compiler.err.expected: ';' +BasicTest.java:69:59: compiler.err.expected: token.identifier +BasicTest.java:69:74: compiler.err.expected: ';' +BasicTest.java:74:22: compiler.err.expected: token.identifier +BasicTest.java:74:24: compiler.err.expected: ';' +BasicTest.java:74:25: compiler.err.illegal.start.of.type +BasicTest.java:74:33: compiler.err.expected: ';' +BasicTest.java:77:2: compiler.err.premature.eof +65 errors diff --git a/langtools/test/tools/javac/typeAnnotations/newlocations/ClassExtends.java b/langtools/test/tools/javac/typeAnnotations/newlocations/ClassExtends.java deleted file mode 100644 index 3f029ee9602..00000000000 --- a/langtools/test/tools/javac/typeAnnotations/newlocations/ClassExtends.java +++ /dev/null @@ -1,40 +0,0 @@ -/* - * Copyright (c) 2008, 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 6843077 - * @summary new type annotation location: class extends/implements - * @author Mahmood Ali - * @compile -source 1.7 ClassExtends.java - */ -abstract class MyClass extends @A ParameterizedClass<@B String> - implements @B CharSequence, @A ParameterizedInterface<@B String> { } - -interface MyInterface extends @A ParameterizedInterface<@A String>, - @B CharSequence { } - -class ParameterizedClass {} -interface ParameterizedInterface {} -@interface A {} -@interface B {} diff --git a/langtools/test/tools/javac/typeAnnotations/newlocations/ClassLiterals.java b/langtools/test/tools/javac/typeAnnotations/newlocations/ClassLiterals.java deleted file mode 100644 index 3558a0166ca..00000000000 --- a/langtools/test/tools/javac/typeAnnotations/newlocations/ClassLiterals.java +++ /dev/null @@ -1,48 +0,0 @@ -/* - * Copyright (c) 2008, 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 6843077 - * @summary new type annotation location: class literals - * @author Mahmood Ali - * @compile -source 1.7 ClassLiterals.java - */ - -class ClassLiterals { - - public static void main(String[] args) { - if (String.class != @A String.class) throw new Error(); - if (@A int.class != int.class) throw new Error(); - if (@A int.class != Integer.TYPE) throw new Error(); - if (@A int @B(0) [].class != int[].class) throw new Error(); - - if (String[].class != @A String[].class) throw new Error(); - if (String[].class != String @A [].class) throw new Error(); - if (@A int[].class != int[].class) throw new Error(); - if (@A int @B(0) [].class != int[].class) throw new Error(); - } -} - -@interface A {} -@interface B { int value(); } diff --git a/langtools/test/tools/javac/typeAnnotations/newlocations/ClassParameters.java b/langtools/test/tools/javac/typeAnnotations/newlocations/ClassParameters.java deleted file mode 100644 index 729a1533555..00000000000 --- a/langtools/test/tools/javac/typeAnnotations/newlocations/ClassParameters.java +++ /dev/null @@ -1,56 +0,0 @@ -/* - * Copyright (c) 2008, 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 6843077 - * @summary new type annotation location: class type parameter bounds - * @author Mahmood Ali - * @compile -source 1.7 ClassParameters.java - */ -class Unannotated { } - -class ExtendsBound { } -class ExtendsGeneric> { } -class TwoBounds { } - -class Complex1 { } -class Complex2 { } -class ComplexBoth { } - -class Outer { - void inner() { - class Unannotated { } - - class ExtendsBound { } - class ExtendsGeneric> { } - class TwoBounds { } - - class Complex1 { } - class Complex2 { } - class ComplexBoth { } - } -} - -@interface A { } -@interface B { } diff --git a/langtools/test/tools/javac/typeAnnotations/newlocations/ConstructorTypeArgs.java b/langtools/test/tools/javac/typeAnnotations/newlocations/ConstructorTypeArgs.java deleted file mode 100644 index 9191b00be8b..00000000000 --- a/langtools/test/tools/javac/typeAnnotations/newlocations/ConstructorTypeArgs.java +++ /dev/null @@ -1,55 +0,0 @@ -/* - * Copyright (c) 2008, 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 6843077 - * @summary new type annotation location: constructor type args - * @author Mahmood Ali - * @compile -source 1.7 ConstructorTypeArgs.java - */ - -class ConstructorTypeArgs { - void oneArg() { - new @A MyList<@A String>(); - new MyList<@A MyList<@B(0) String>>(); - } - - void twoArg() { - new MyMap(); - new MyMap<@A String, @B(0) MyList<@A String>>(); - } - - void withArraysIn() { - new MyList(); - new MyList<@A String @B(0) [] @A []>(); - - new MyMap<@A String[], @B(0) MyList<@A String> @A []>(); - } -} - -class MyList { } -class MyMap { } - -@interface A { } -@interface B { int value(); } diff --git a/langtools/test/tools/javac/typeAnnotations/newlocations/Expressions.java b/langtools/test/tools/javac/typeAnnotations/newlocations/Expressions.java deleted file mode 100644 index 012e65c2110..00000000000 --- a/langtools/test/tools/javac/typeAnnotations/newlocations/Expressions.java +++ /dev/null @@ -1,75 +0,0 @@ -/* - * Copyright (c) 2008, 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 6843077 - * @summary new type annotation location: expressions - * @author Mahmood Ali - * @compile -source 1.7 Expressions.java - */ -class Expressions { - void instanceOf() { - Object o = null; - boolean a = o instanceof @A String; - boolean b = o instanceof @B(0) String; - } - - void instanceOfArray() { - Object o = null; - boolean a1 = o instanceof @A String []; - boolean a2 = o instanceof @B(0) String []; - - boolean b1 = o instanceof String @A []; - boolean b2 = o instanceof String @B(0) []; - } - - void objectCreation() { - new @A String(); - new @B(0) String(); - } - - void objectCreationArray() { - Object a1 = new @A String [] [] { }; - Object a2 = new @A String [1] []; - Object a3 = new @A String [1] [2]; - - Object b1 = new @A String @B(0) [] [] { }; - Object b2 = new @A String @B(0) [1] []; - Object b3 = new @A String @B(0) [1] [2]; - - Object c1 = new @A String [] @B(0) [] { }; - Object c2 = new @A String [1] @B(0) []; - Object c3 = new @A String [1] @B(0) [2]; - - Object d1 = new @A String @B(0) [] @B(0) [] { }; - Object d2 = new @A String @B(0) [1] @B(0) []; - Object d3 = new @A String @B(0) [1] @B(0) [2]; - - Object rand = new @A String @B(value = 0) [1] @B(value = 0) [2]; - - } -} - -@interface A { } -@interface B { int value(); } diff --git a/langtools/test/tools/javac/typeAnnotations/newlocations/Fields.java b/langtools/test/tools/javac/typeAnnotations/newlocations/Fields.java deleted file mode 100644 index d5d39c71b0f..00000000000 --- a/langtools/test/tools/javac/typeAnnotations/newlocations/Fields.java +++ /dev/null @@ -1,69 +0,0 @@ -/* - * Copyright (c) 2008, 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 6843077 - * @summary new type annotation location: field type array/generics - * @author Mahmood Ali - * @compile -source 1.7 Fields.java - */ - -class DefaultScope { - Parameterized unannotated; - Parameterized<@A String, String> firstTypeArg; - Parameterized secondTypeArg; - Parameterized<@A String, @B String> bothTypeArgs; - - Parameterized<@A Parameterized<@A String, @B String>, @B String> - nestedParameterized; - - @A String [] array1; - @A String @B [] array1Deep; - @A String [] [] array2; - @A String @A [] @B [] array2Deep; - String @A [] [] array2First; - String [] @B [] array2Second; -} - -class ModifiedScoped { - public final Parameterized unannotated = null; - public final Parameterized<@A String, String> firstTypeArg = null; - public final Parameterized secondTypeArg = null; - public final Parameterized<@A String, @B String> bothTypeArgs = null; - - public final Parameterized<@A Parameterized<@A String, @B String>, @B String> - nestedParameterized = null; - - public final @A String [] array1 = null; - public final @A String @B [] array1Deep = null; - public final @A String [] [] array2 = null; - public final @A String @A [] @B [] array2Deep = null; - public final String @A [] [] array2First = null; - public final String [] @B [] array2Second = null; -} - -class Parameterized { } - -@interface A { } -@interface B { } diff --git a/langtools/test/tools/javac/typeAnnotations/newlocations/LocalVariables.java b/langtools/test/tools/javac/typeAnnotations/newlocations/LocalVariables.java deleted file mode 100644 index 2676bd0ec08..00000000000 --- a/langtools/test/tools/javac/typeAnnotations/newlocations/LocalVariables.java +++ /dev/null @@ -1,77 +0,0 @@ -/* - * Copyright (c) 2008, 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 6843077 - * @summary new type annotation location: local variables array/generics - * @author Mahmood Ali - * @compile -source 1.7 LocalVariables.java - */ - -class DefaultScope { - void parameterized() { - Parameterized unannotated; - Parameterized<@A String, String> firstTypeArg; - Parameterized secondTypeArg; - Parameterized<@A String, @B String> bothTypeArgs; - - Parameterized<@A Parameterized<@A String, @B String>, @B String> - nestedParameterized; - } - - void arrays() { - @A String [] array1; - @A String @B [] array1Deep; - @A String [] [] array2; - @A String @A [] @B [] array2Deep; - String @A [] [] array2First; - String [] @B [] array2Second; - } -} - -class ModifiedVars { - void parameterized() { - final Parameterized unannotated = null; - final Parameterized<@A String, String> firstTypeArg = null; - final Parameterized secondTypeArg = null; - final Parameterized<@A String, @B String> bothTypeArgs = null; - - final Parameterized<@A Parameterized<@A String, @B String>, @B String> - nestedParameterized = null; - } - - void arrays() { - final @A String [] array1 = null; - final @A String @B [] array1Deep = null; - final @A String [] [] array2 = null; - final @A String @A [] @B [] array2Deep = null; - final String @A [] [] array2First = null; - final String [] @B [] array2Second = null; - } -} - -class Parameterized { } - -@interface A { } -@interface B { } diff --git a/langtools/test/tools/javac/typeAnnotations/newlocations/MethodReturnType.java b/langtools/test/tools/javac/typeAnnotations/newlocations/MethodReturnType.java deleted file mode 100644 index ee35f875792..00000000000 --- a/langtools/test/tools/javac/typeAnnotations/newlocations/MethodReturnType.java +++ /dev/null @@ -1,71 +0,0 @@ -/* - * Copyright (c) 2008, 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 6843077 - * @summary new type annotation location: method return type array/generics - * @author Mahmood Ali - * @compile -source 1.7 MethodReturnType.java - */ - -class DefaultScope { - Parameterized unannotated() { return null; } - Parameterized<@A String, String> firstTypeArg() { return null; } - Parameterized secondTypeArg() { return null; } - Parameterized<@A String, @B String> bothTypeArgs() { return null; } - - Parameterized<@A Parameterized<@A String, @B String>, @B String> - nestedParameterized() { return null; } - - public @A String method() { return null; } - - @A String [] array1() { return null; } - @A String @B [] array1Deep() { return null; } - @A String [] [] array2() { return null; } - @A String @A [] @B [] array2Deep() { return null; } - String @A [] [] array2First() { return null; } - String [] @B [] array2Second() { return null; } -} - -class ModifiedScoped { - public final Parameterized unannotated() { return null; } - public final Parameterized<@A String, String> firstTypeArg() { return null; } - public final Parameterized secondTypeArg() { return null; } - public final Parameterized<@A String, @B String> bothTypeArgs() { return null; } - - public final Parameterized<@A Parameterized<@A String, @B String>, @B String> - nestedParameterized() { return null; } - - public final @A String [] array1() { return null; } - public final @A String @B [] array1Deep() { return null; } - public final @A String [] [] array2() { return null; } - public final @A String @A [] @B [] array2Deep() { return null; } - public final String @A [] [] array2First() { return null; } - public final String [] @B [] array2Second() { return null; } -} - -class Parameterized { } - -@interface A { } -@interface B { } diff --git a/langtools/test/tools/javac/typeAnnotations/newlocations/MethodTypeArgs.java b/langtools/test/tools/javac/typeAnnotations/newlocations/MethodTypeArgs.java deleted file mode 100644 index f901dc13466..00000000000 --- a/langtools/test/tools/javac/typeAnnotations/newlocations/MethodTypeArgs.java +++ /dev/null @@ -1,62 +0,0 @@ -/* - * Copyright (c) 2008, 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 6843077 - * @summary new type annotation location: method type args - * @author Mahmood Ali - * @compile -source 1.7 MethodTypeArgs.java - */ - -class MethodTypeArgs { - void oneArg() { - this.<@A String>newList(); - this.<@A MyList<@B(0) String>>newList(); - - MethodTypeArgs.<@A String>newList(); - MethodTypeArgs.<@A MyList<@B(0) String>>newList(); - } - - void twoArg() { - this.newMap(); - this.<@A String, @B(0) MyList<@A String>>newMap(); - - MethodTypeArgs.newMap(); - MethodTypeArgs.<@A String, @B(0) MyList<@A String>>newMap(); - } - - void withArraysIn() { - this.newList(); - this.<@A String @B(0) [] @A []>newList(); - - this.<@A String[], @B(0) MyList<@A String> @A []>newMap(); - } - - static void newList() { } - static void newMap() { } -} - -class MyList { } -@interface A { } -@interface B { int value(); } diff --git a/langtools/test/tools/javac/typeAnnotations/newlocations/MethodTypeParameters.java b/langtools/test/tools/javac/typeAnnotations/newlocations/MethodTypeParameters.java deleted file mode 100644 index 48f52496213..00000000000 --- a/langtools/test/tools/javac/typeAnnotations/newlocations/MethodTypeParameters.java +++ /dev/null @@ -1,48 +0,0 @@ -/* - * Copyright (c) 2008, 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 6843077 - * @summary new type annotation location: method type parameter bounds - * @author Mahmood Ali - * @compile -source 1.7 MethodTypeParameters.java - */ - -class UnscopedUnmodified { - void methodExtends() {} - > void nestedExtends() {} - > void dual() {} - > void dualOneAnno() {} -} - -class PublicModifiedMethods { - public final void methodExtends() {} - public final > void nestedExtends() {} - public final > void dual() {} - public final > void dualOneAnno() {} -} - -class Parameterized { } -@interface A { } -@interface B { } diff --git a/langtools/test/tools/javac/typeAnnotations/newlocations/Parameters.java b/langtools/test/tools/javac/typeAnnotations/newlocations/Parameters.java deleted file mode 100644 index feda414b75d..00000000000 --- a/langtools/test/tools/javac/typeAnnotations/newlocations/Parameters.java +++ /dev/null @@ -1,51 +0,0 @@ -/* - * Copyright (c) 2008, 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 6843077 - * @summary new type annotation location: parameter type array/generics - * @author Mahmood Ali - * @compile -source 1.7 Parameters.java - */ - -class Parameters { - void unannotated(Parameterized a) {} - void firstTypeArg(Parameterized<@A String, String> a) {} - void secondTypeArg(Parameterized a) {} - void bothTypeArgs(Parameterized<@A String, @B String> both) {} - - void nestedParameterized(Parameterized<@A Parameterized<@A String, @B String>, @B String> a) {} - - void array1(@A String [] a) {} - void array1Deep(@A String @B [] a) {} - void array2(@A String [] [] a) {} - void array2Deep(@A String @A [] @B [] a) {} - void array2First(String @A [] [] a) {} - void array2Second(String [] @B [] a) {} -} - -class Parameterized { } - -@interface A { } -@interface B { } diff --git a/langtools/test/tools/javac/typeAnnotations/newlocations/Receivers.java b/langtools/test/tools/javac/typeAnnotations/newlocations/Receivers.java deleted file mode 100644 index 700f946d5b1..00000000000 --- a/langtools/test/tools/javac/typeAnnotations/newlocations/Receivers.java +++ /dev/null @@ -1,56 +0,0 @@ -/* - * Copyright (c) 2008, 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 6843077 - * @summary new type annotation location: receivers - * @author Mahmood Ali - * @compile -source 1.7 Receivers.java - */ -class DefaultUnmodified { - void plain() @A { } - void generic() @A { } - void withException() @A throws Exception { } - String nonVoid() @A { return null; } - void accept(T r) @A throws Exception { } -} - -class PublicModified { - public final void plain() @A { } - public final void generic() @A { } - public final void withException() @A throws Exception { } - public final String nonVoid() @A { return null; } - public final void accept(T r) @A throws Exception { } -} - -class WithValue { - void plain() @B("m") { } - void generic() @B("m") { } - void withException() @B("m") throws Exception { } - String nonVoid() @B("m") { return null; } - void accept(T r) @B("m") throws Exception { } -} - -@interface A {} -@interface B { String value(); } diff --git a/langtools/test/tools/javac/typeAnnotations/newlocations/Throws.java b/langtools/test/tools/javac/typeAnnotations/newlocations/Throws.java deleted file mode 100644 index 2477d913c2f..00000000000 --- a/langtools/test/tools/javac/typeAnnotations/newlocations/Throws.java +++ /dev/null @@ -1,47 +0,0 @@ -/* - * Copyright (c) 2008, 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 6843077 - * @summary new type annotation location: throw clauses - * @author Mahmood Ali - * @compile -source 1.7 Throws.java - */ -class DefaultUnmodified { - void oneException() throws @A Exception {} - void twoExceptions() throws @A RuntimeException, @A Exception {} -} - -class PublicModified { - public final void oneException(String a) throws @A Exception {} - public final void twoExceptions(String a) throws @A RuntimeException, @A Exception {} -} - -class WithValue { - void oneException() throws @B("m") Exception {} - void twoExceptions() throws @B(value="m") RuntimeException, @A Exception {} -} - -@interface A {} -@interface B { String value(); } diff --git a/langtools/test/tools/javac/typeAnnotations/newlocations/TypeCasts.java b/langtools/test/tools/javac/typeAnnotations/newlocations/TypeCasts.java deleted file mode 100644 index aef203e01e8..00000000000 --- a/langtools/test/tools/javac/typeAnnotations/newlocations/TypeCasts.java +++ /dev/null @@ -1,44 +0,0 @@ -/* - * Copyright (c) 2008, 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 6843077 - * @summary new type annotation location: type casts - * @author Mahmood Ali - * @compile -source 1.7 TypeCasts.java - */ -class TypeCasts { - void methodA() { - String s = (@A String) null; - Object o = (@A Class<@A String>) null; - } - - void methodB() { - String s = (@B("m") String) null; - Object o = (@B("m") Class<@B("m") String>) null; - } -} - -@interface A { } -@interface B { String value(); } diff --git a/langtools/test/tools/javac/typeAnnotations/newlocations/TypeParameters.java b/langtools/test/tools/javac/typeAnnotations/newlocations/TypeParameters.java deleted file mode 100644 index 8faf3fb0e5b..00000000000 --- a/langtools/test/tools/javac/typeAnnotations/newlocations/TypeParameters.java +++ /dev/null @@ -1,50 +0,0 @@ -/* - * Copyright (c) 2008, 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 6843077 - * @summary new type annotation location: class and method type parameters - * @author Mahmood Ali - * @compile -source 1.7 TypeParameters.java - */ - -class Unannotated { } -class OneAnnotated<@A K> { } -class TwoAnnotated<@A K, @A V> { } -class SecondAnnotated { } - -class TestMethods { - void unannotated() { } - <@A K> void oneAnnotated() { } - <@A K, @B("m") V> void twoAnnotated() { } - void secondAnnotated() { } -} - -class UnannotatedB { } -class OneAnnotatedB<@B("m") K> { } -class TwoAnnotatedB<@B("m") K, @B("m") V> { } -class SecondAnnotatedB { } - -@interface A { } -@interface B { String value(); } diff --git a/langtools/test/tools/javac/typeAnnotations/newlocations/Wildcards.java b/langtools/test/tools/javac/typeAnnotations/newlocations/Wildcards.java deleted file mode 100644 index 1efad06ac0e..00000000000 --- a/langtools/test/tools/javac/typeAnnotations/newlocations/Wildcards.java +++ /dev/null @@ -1,70 +0,0 @@ -/* - * Copyright (c) 2008, 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 6843077 - * @summary new type annotation location: wildcard bound - * @author Mahmood Ali - * @compile -source 1.7 Wildcards.java - */ -class BoundTest { - void wcExtends(MyList l) { } - void wcSuper(MyList l) { } - - MyList returnWcExtends() { return null; } - MyList returnWcSuper() { return null; } - MyList> complex() { return null; } -} - -class BoundWithValue { - void wcExtends(MyList l) { } - void wcSuper(MyList l) { } - - MyList returnWcExtends() { return null; } - MyList returnWcSuper() { return null; } - MyList> complex() { return null; } -} - -class SelfTest { - void wcExtends(MyList<@A ?> l) { } - void wcSuper(MyList<@A ?> l) { } - - MyList<@A ?> returnWcExtends() { return null; } - MyList<@A ?> returnWcSuper() { return null; } - MyList<@A ? extends @A MyList<@B("m") ?>> complex() { return null; } -} - -class SelfWithValue { - void wcExtends(MyList<@B("m") ?> l) { } - void wcSuper(MyList<@B(value="m") ?> l) { } - - MyList<@B("m") ?> returnWcExtends() { return null; } - MyList<@B(value="m") ?> returnWcSuper() { return null; } - MyList<@B("m") ? extends MyList<@B("m") ? super String>> complex() { return null; } -} - -class MyList { } - -@interface A { } -@interface B { String value(); } diff --git a/langtools/test/tools/javap/typeAnnotations/ArrayClassLiterals.java b/langtools/test/tools/javap/typeAnnotations/ArrayClassLiterals.java deleted file mode 100644 index 24d414aa55b..00000000000 --- a/langtools/test/tools/javap/typeAnnotations/ArrayClassLiterals.java +++ /dev/null @@ -1,183 +0,0 @@ -/* - * Copyright (c) 2009, 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. - */ - -import java.io.*; -import com.sun.tools.classfile.*; - -/* - * @test ArrayClassLiterals - * @bug 6863814 - * @summary test that class literals array doesn't crash javap - */ - -public class ArrayClassLiterals { - public static void main(String[] args) throws Exception { - new ArrayClassLiterals().run(); - } - - public void run() throws Exception { - File javaFile = writeTestFile(); - File classFile = compileTestFile(javaFile); - - ClassFile cf = ClassFile.read(classFile); - test(cf); - for (Field f : cf.fields) { - test(cf, f); - } - for (Method m: cf.methods) { - test(cf, m); - } - - countAnnotations(); - - if (errors > 0) - throw new Exception(errors + " errors found"); - System.out.println("PASSED"); - } - - void test(ClassFile cf) { - test(cf, Attribute.RuntimeVisibleTypeAnnotations, true); - test(cf, Attribute.RuntimeInvisibleTypeAnnotations, false); - } - - void test(ClassFile cf, Method m) { - test(cf, m, Attribute.RuntimeVisibleTypeAnnotations, true); - test(cf, m, Attribute.RuntimeInvisibleTypeAnnotations, false); - } - - void test(ClassFile cf, Field m) { - test(cf, m, Attribute.RuntimeVisibleTypeAnnotations, true); - test(cf, m, Attribute.RuntimeInvisibleTypeAnnotations, false); - } - - // test the result of Attributes.getIndex according to expectations - // encoded in the method's name - void test(ClassFile cf, String name, boolean visible) { - int index = cf.attributes.getIndex(cf.constant_pool, name); - if (index != -1) { - Attribute attr = cf.attributes.get(index); - assert attr instanceof RuntimeTypeAnnotations_attribute; - RuntimeTypeAnnotations_attribute tAttr = (RuntimeTypeAnnotations_attribute)attr; - all += tAttr.annotations.length; - if (visible) - visibles += tAttr.annotations.length; - else - invisibles += tAttr.annotations.length; - - for (ExtendedAnnotation anno : tAttr.annotations) - anno.position.toString(); - } - } - - // test the result of Attributes.getIndex according to expectations - // encoded in the method's name - void test(ClassFile cf, Method m, String name, boolean visible) { - int index = m.attributes.getIndex(cf.constant_pool, name); - if (index != -1) { - Attribute attr = m.attributes.get(index); - assert attr instanceof RuntimeTypeAnnotations_attribute; - RuntimeTypeAnnotations_attribute tAttr = (RuntimeTypeAnnotations_attribute)attr; - all += tAttr.annotations.length; - if (visible) - visibles += tAttr.annotations.length; - else - invisibles += tAttr.annotations.length; - - for (ExtendedAnnotation anno : tAttr.annotations) - anno.position.toString(); - } - } - - // test the result of Attributes.getIndex according to expectations - // encoded in the method's name - void test(ClassFile cf, Field m, String name, boolean visible) { - int index = m.attributes.getIndex(cf.constant_pool, name); - if (index != -1) { - Attribute attr = m.attributes.get(index); - assert attr instanceof RuntimeTypeAnnotations_attribute; - RuntimeTypeAnnotations_attribute tAttr = (RuntimeTypeAnnotations_attribute)attr; - all += tAttr.annotations.length; - if (visible) - visibles += tAttr.annotations.length; - else - invisibles += tAttr.annotations.length; - - for (ExtendedAnnotation anno : tAttr.annotations) - anno.position.toString(); - } - } - - File writeTestFile() throws IOException { - File f = new File("Testa.java"); - PrintWriter out = new PrintWriter(new BufferedWriter(new FileWriter(f))); - out.println("import java.util.*;"); - out.println("class Testa { "); - out.println(" @interface A { }"); - - out.println(" void test() {"); - out.println(" Object a = @A String.class;"); - out.println(" Object b = @A String @A [] @A [].class;"); - out.println(" }"); - out.println("}"); - - out.close(); - return f; - } - - File compileTestFile(File f) { - int rc = com.sun.tools.javac.Main.compile(new String[] { "-source", "1.7", "-g", f.getPath() }); - if (rc != 0) - throw new Error("compilation failed. rc=" + rc); - String path = f.getPath(); - return new File(path.substring(0, path.length() - 5) + ".class"); - } - - void countAnnotations() { - int expected_visibles = 0, expected_invisibles = 4; - int expected_all = expected_visibles + expected_invisibles; - - if (expected_all != all) { - errors++; - System.err.println("expected " + expected_all - + " annotations but found " + all); - } - - if (expected_visibles != visibles) { - errors++; - System.err.println("expected " + expected_visibles - + " visibles annotations but found " + visibles); - } - - if (expected_invisibles != invisibles) { - errors++; - System.err.println("expected " + expected_invisibles - + " invisibles annotations but found " + invisibles); - } - - } - - int errors; - int all; - int visibles; - int invisibles; -} diff --git a/langtools/test/tools/javap/typeAnnotations/ArrayClassLiterals2.java b/langtools/test/tools/javap/typeAnnotations/ArrayClassLiterals2.java deleted file mode 100644 index 1e3c277fa0d..00000000000 --- a/langtools/test/tools/javap/typeAnnotations/ArrayClassLiterals2.java +++ /dev/null @@ -1,82 +0,0 @@ -/* - * Copyright (c) 2009, 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 6918625 - * @summary javap dumps type information of array class literals - */ - -import java.io.*; - -public class ArrayClassLiterals2 { - public static void main(String[] args) throws Exception { - new ArrayClassLiterals2().run(); - } - - public void run() throws IOException { - File classFile = new File(System.getProperty("test.classes"), "ArrayClassLiterals2$Test.class"); - - verify(classFile, - "RuntimeInvisibleTypeAnnotations:", - "CLASS_LITERAL_GENERIC_OR_ARRAY" - ); - - if (errors > 0) - throw new Error(errors + " found."); - } - - String javap(File f) { - StringWriter sw = new StringWriter(); - PrintWriter out = new PrintWriter(sw); - int rc = com.sun.tools.javap.Main.run(new String[] { "-v", f.getPath() }, out); - if (rc != 0) - throw new Error("javap failed. rc=" + rc); - out.close(); - return sw.toString(); - } - - void verify(File classFile, String... expects) { - String output = javap(classFile); - for (String expect: expects) { - if (output.indexOf(expect)< 0) - error(expect + " not found"); - } - } - - void error(String msg) { - System.err.println(msg); - errors++; - } - - int errors; - - - /*********************** Test class *************************/ - static class Test { - @interface A { } - void test() { - Object a = @A String @A [] @A [].class; - } - } -} diff --git a/langtools/test/tools/javap/typeAnnotations/ClassLiterals.java b/langtools/test/tools/javap/typeAnnotations/ClassLiterals.java deleted file mode 100644 index 5c3fd7c8a49..00000000000 --- a/langtools/test/tools/javap/typeAnnotations/ClassLiterals.java +++ /dev/null @@ -1,174 +0,0 @@ -/* - * Copyright (c) 2008, 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. - */ - -import java.io.*; -import com.sun.tools.classfile.*; - -/* - * @test ClassLiterals - * @bug 6843077 - * @summary test that all type annotations are present in the classfile - */ - -public class ClassLiterals { - public static void main(String[] args) throws Exception { - new ClassLiterals().run(); - } - - public void run() throws Exception { - File javaFile = writeTestFile(); - File classFile = compileTestFile(javaFile); - - ClassFile cf = ClassFile.read(classFile); - test(cf); - for (Field f : cf.fields) { - test(cf, f); - } - for (Method m: cf.methods) { - test(cf, m); - } - - countAnnotations(); - - if (errors > 0) - throw new Exception(errors + " errors found"); - System.out.println("PASSED"); - } - - void test(ClassFile cf) { - test(cf, Attribute.RuntimeVisibleTypeAnnotations, true); - test(cf, Attribute.RuntimeInvisibleTypeAnnotations, false); - } - - void test(ClassFile cf, Method m) { - test(cf, m, Attribute.RuntimeVisibleTypeAnnotations, true); - test(cf, m, Attribute.RuntimeInvisibleTypeAnnotations, false); - } - - void test(ClassFile cf, Field m) { - test(cf, m, Attribute.RuntimeVisibleTypeAnnotations, true); - test(cf, m, Attribute.RuntimeInvisibleTypeAnnotations, false); - } - - // test the result of Attributes.getIndex according to expectations - // encoded in the method's name - void test(ClassFile cf, String name, boolean visible) { - int index = cf.attributes.getIndex(cf.constant_pool, name); - if (index != -1) { - Attribute attr = cf.attributes.get(index); - assert attr instanceof RuntimeTypeAnnotations_attribute; - RuntimeTypeAnnotations_attribute tAttr = (RuntimeTypeAnnotations_attribute)attr; - all += tAttr.annotations.length; - if (visible) - visibles += tAttr.annotations.length; - else - invisibles += tAttr.annotations.length; - } - } - - // test the result of Attributes.getIndex according to expectations - // encoded in the method's name - void test(ClassFile cf, Method m, String name, boolean visible) { - int index = m.attributes.getIndex(cf.constant_pool, name); - if (index != -1) { - Attribute attr = m.attributes.get(index); - assert attr instanceof RuntimeTypeAnnotations_attribute; - RuntimeTypeAnnotations_attribute tAttr = (RuntimeTypeAnnotations_attribute)attr; - all += tAttr.annotations.length; - if (visible) - visibles += tAttr.annotations.length; - else - invisibles += tAttr.annotations.length; - } - } - - // test the result of Attributes.getIndex according to expectations - // encoded in the method's name - void test(ClassFile cf, Field m, String name, boolean visible) { - int index = m.attributes.getIndex(cf.constant_pool, name); - if (index != -1) { - Attribute attr = m.attributes.get(index); - assert attr instanceof RuntimeTypeAnnotations_attribute; - RuntimeTypeAnnotations_attribute tAttr = (RuntimeTypeAnnotations_attribute)attr; - all += tAttr.annotations.length; - if (visible) - visibles += tAttr.annotations.length; - else - invisibles += tAttr.annotations.length; - } - } - - File writeTestFile() throws IOException { - File f = new File("Testa.java"); - PrintWriter out = new PrintWriter(new BufferedWriter(new FileWriter(f))); - out.println("import java.util.*;"); - out.println("class Testa { "); - out.println(" @interface A { }"); - - out.println(" void test() {"); - out.println(" Object a = @A String.class;"); - out.println(" Object b = @A String @A [] @A [].class;"); - out.println(" }"); - out.println("}"); - - out.close(); - return f; - } - - File compileTestFile(File f) { - int rc = com.sun.tools.javac.Main.compile(new String[] { "-source", "1.7", "-g", f.getPath() }); - if (rc != 0) - throw new Error("compilation failed. rc=" + rc); - String path = f.getPath(); - return new File(path.substring(0, path.length() - 5) + ".class"); - } - - void countAnnotations() { - int expected_visibles = 0, expected_invisibles = 4; - int expected_all = expected_visibles + expected_invisibles; - - if (expected_all != all) { - errors++; - System.err.println("expected " + expected_all - + " annotations but found " + all); - } - - if (expected_visibles != visibles) { - errors++; - System.err.println("expected " + expected_visibles - + " visibles annotations but found " + visibles); - } - - if (expected_invisibles != invisibles) { - errors++; - System.err.println("expected " + expected_invisibles - + " invisibles annotations but found " + invisibles); - } - - } - - int errors; - int all; - int visibles; - int invisibles; -} diff --git a/langtools/test/tools/javap/typeAnnotations/JSR175Annotations.java b/langtools/test/tools/javap/typeAnnotations/JSR175Annotations.java deleted file mode 100644 index fe3c65f1965..00000000000 --- a/langtools/test/tools/javap/typeAnnotations/JSR175Annotations.java +++ /dev/null @@ -1,152 +0,0 @@ -/* - * Copyright (c) 2008, 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. - */ - -import java.io.*; -import com.sun.tools.classfile.*; - -/* - * @test JSR175Annotations - * @bug 6843077 - * @summary test that only type annotations are recorded as such in classfile - */ - -public class JSR175Annotations { - public static void main(String[] args) throws Exception { - new JSR175Annotations().run(); - } - - public void run() throws Exception { - File javaFile = writeTestFile(); - File classFile = compileTestFile(javaFile); - - ClassFile cf = ClassFile.read(classFile); - for (Field f : cf.fields) { - test(cf, f); - } - for (Method m: cf.methods) { - test(cf, m); - } - - countAnnotations(); - - if (errors > 0) - throw new Exception(errors + " errors found"); - System.out.println("PASSED"); - } - - void test(ClassFile cf, Method m) { - test(cf, m, Attribute.RuntimeVisibleTypeAnnotations, true); - test(cf, m, Attribute.RuntimeInvisibleTypeAnnotations, false); - } - - void test(ClassFile cf, Field m) { - test(cf, m, Attribute.RuntimeVisibleTypeAnnotations, true); - test(cf, m, Attribute.RuntimeInvisibleTypeAnnotations, false); - } - - // test the result of Attributes.getIndex according to expectations - // encoded in the method's name - void test(ClassFile cf, Method m, String name, boolean visible) { - int index = m.attributes.getIndex(cf.constant_pool, name); - if (index != -1) { - Attribute attr = m.attributes.get(index); - assert attr instanceof RuntimeTypeAnnotations_attribute; - RuntimeTypeAnnotations_attribute tAttr = (RuntimeTypeAnnotations_attribute)attr; - all += tAttr.annotations.length; - if (visible) - visibles += tAttr.annotations.length; - else - invisibles += tAttr.annotations.length; - } - } - - // test the result of Attributes.getIndex according to expectations - // encoded in the method's name - void test(ClassFile cf, Field m, String name, boolean visible) { - int index = m.attributes.getIndex(cf.constant_pool, name); - if (index != -1) { - Attribute attr = m.attributes.get(index); - assert attr instanceof RuntimeTypeAnnotations_attribute; - RuntimeTypeAnnotations_attribute tAttr = (RuntimeTypeAnnotations_attribute)attr; - all += tAttr.annotations.length; - if (visible) - visibles += tAttr.annotations.length; - else - invisibles += tAttr.annotations.length; - } - } - - File writeTestFile() throws IOException { - File f = new File("Test.java"); - PrintWriter out = new PrintWriter(new BufferedWriter(new FileWriter(f))); - out.println("import java.lang.annotation.Retention;"); - out.println("import java.lang.annotation.RetentionPolicy;"); - out.println("abstract class Test { "); - out.println(" @Retention(RetentionPolicy.RUNTIME)"); - out.println(" @interface A { }"); - out.println(" @A String m;"); - out.println(" @A String method(@A String a) {"); - out.println(" return a;"); - out.println(" }"); - out.println("}"); - out.close(); - return f; - } - - File compileTestFile(File f) { - int rc = com.sun.tools.javac.Main.compile(new String[] { "-source", "1.7", "-g", f.getPath() }); - if (rc != 0) - throw new Error("compilation failed. rc=" + rc); - String path = f.getPath(); - return new File(path.substring(0, path.length() - 5) + ".class"); - } - - void countAnnotations() { - int expected_visibles = 0, expected_invisibles = 0; - int expected_all = expected_visibles + expected_invisibles; - - if (expected_all != all) { - errors++; - System.err.println("expected " + expected_all - + " annotations but found " + all); - } - - if (expected_visibles != visibles) { - errors++; - System.err.println("expected " + expected_visibles - + " visibles annotations but found " + visibles); - } - - if (expected_invisibles != invisibles) { - errors++; - System.err.println("expected " + expected_invisibles - + " invisibles annotations but found " + invisibles); - } - - } - - int errors; - int all; - int visibles; - int invisibles; -} diff --git a/langtools/test/tools/javap/typeAnnotations/NewArray.java b/langtools/test/tools/javap/typeAnnotations/NewArray.java deleted file mode 100644 index aa15b89f550..00000000000 --- a/langtools/test/tools/javap/typeAnnotations/NewArray.java +++ /dev/null @@ -1,175 +0,0 @@ -/* - * Copyright (c) 2008, 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. - */ - -import java.io.*; -import com.sun.tools.classfile.*; - -/* - * @test NewArray - * @bug 6843077 - * @summary test that all type annotations are present in the classfile - */ - -public class NewArray { - public static void main(String[] args) throws Exception { - new NewArray().run(); - } - - public void run() throws Exception { - File javaFile = writeTestFile(); - File classFile = compileTestFile(javaFile); - - ClassFile cf = ClassFile.read(classFile); - test(cf); - for (Field f : cf.fields) { - test(cf, f); - } - for (Method m: cf.methods) { - test(cf, m); - } - - countAnnotations(); - - if (errors > 0) - throw new Exception(errors + " errors found"); - System.out.println("PASSED"); - } - - void test(ClassFile cf) { - test(cf, Attribute.RuntimeVisibleTypeAnnotations, true); - test(cf, Attribute.RuntimeInvisibleTypeAnnotations, false); - } - - void test(ClassFile cf, Method m) { - test(cf, m, Attribute.RuntimeVisibleTypeAnnotations, true); - test(cf, m, Attribute.RuntimeInvisibleTypeAnnotations, false); - } - - void test(ClassFile cf, Field m) { - test(cf, m, Attribute.RuntimeVisibleTypeAnnotations, true); - test(cf, m, Attribute.RuntimeInvisibleTypeAnnotations, false); - } - - // test the result of Attributes.getIndex according to expectations - // encoded in the method's name - void test(ClassFile cf, String name, boolean visible) { - int index = cf.attributes.getIndex(cf.constant_pool, name); - if (index != -1) { - Attribute attr = cf.attributes.get(index); - assert attr instanceof RuntimeTypeAnnotations_attribute; - RuntimeTypeAnnotations_attribute tAttr = (RuntimeTypeAnnotations_attribute)attr; - all += tAttr.annotations.length; - if (visible) - visibles += tAttr.annotations.length; - else - invisibles += tAttr.annotations.length; - } - } - - // test the result of Attributes.getIndex according to expectations - // encoded in the method's name - void test(ClassFile cf, Method m, String name, boolean visible) { - int index = m.attributes.getIndex(cf.constant_pool, name); - if (index != -1) { - Attribute attr = m.attributes.get(index); - assert attr instanceof RuntimeTypeAnnotations_attribute; - RuntimeTypeAnnotations_attribute tAttr = (RuntimeTypeAnnotations_attribute)attr; - all += tAttr.annotations.length; - if (visible) - visibles += tAttr.annotations.length; - else - invisibles += tAttr.annotations.length; - } - } - - // test the result of Attributes.getIndex according to expectations - // encoded in the method's name - void test(ClassFile cf, Field m, String name, boolean visible) { - int index = m.attributes.getIndex(cf.constant_pool, name); - if (index != -1) { - Attribute attr = m.attributes.get(index); - assert attr instanceof RuntimeTypeAnnotations_attribute; - RuntimeTypeAnnotations_attribute tAttr = (RuntimeTypeAnnotations_attribute)attr; - all += tAttr.annotations.length; - if (visible) - visibles += tAttr.annotations.length; - else - invisibles += tAttr.annotations.length; - } - } - - File writeTestFile() throws IOException { - File f = new File("Test.java"); - PrintWriter out = new PrintWriter(new BufferedWriter(new FileWriter(f))); - out.println("import java.util.*;"); - out.println("class Test { "); - out.println(" @interface A { }"); - - out.println(" void test() {"); - out.println(" Object a = new @A String @A [5] @A [];"); - out.println(" Object b = new @A String @A [5] @A [3];"); - out.println(" Object c = new @A String @A [] @A [] {};"); - out.println(" }"); - out.println("}"); - - out.close(); - return f; - } - - File compileTestFile(File f) { - int rc = com.sun.tools.javac.Main.compile(new String[] { "-source", "1.7", "-g", f.getPath() }); - if (rc != 0) - throw new Error("compilation failed. rc=" + rc); - String path = f.getPath(); - return new File(path.substring(0, path.length() - 5) + ".class"); - } - - void countAnnotations() { - int expected_visibles = 0, expected_invisibles = 9; - int expected_all = expected_visibles + expected_invisibles; - - if (expected_all != all) { - errors++; - System.err.println("expected " + expected_all - + " annotations but found " + all); - } - - if (expected_visibles != visibles) { - errors++; - System.err.println("expected " + expected_visibles - + " visibles annotations but found " + visibles); - } - - if (expected_invisibles != invisibles) { - errors++; - System.err.println("expected " + expected_invisibles - + " invisibles annotations but found " + invisibles); - } - - } - - int errors; - int all; - int visibles; - int invisibles; -} diff --git a/langtools/test/tools/javap/typeAnnotations/Presence.java b/langtools/test/tools/javap/typeAnnotations/Presence.java deleted file mode 100644 index 6fdf5c0cc4d..00000000000 --- a/langtools/test/tools/javap/typeAnnotations/Presence.java +++ /dev/null @@ -1,189 +0,0 @@ -/* - * Copyright (c) 2008, 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. - */ - -import java.io.*; -import com.sun.tools.classfile.*; - -/* - * @test Presence - * @bug 6843077 - * @summary test that all type annotations are present in the classfile - */ - -public class Presence { - public static void main(String[] args) throws Exception { - new Presence().run(); - } - - public void run() throws Exception { - File javaFile = writeTestFile(); - File classFile = compileTestFile(javaFile); - - ClassFile cf = ClassFile.read(classFile); - test(cf); - for (Field f : cf.fields) { - test(cf, f); - } - for (Method m: cf.methods) { - test(cf, m); - } - - countAnnotations(); - - if (errors > 0) - throw new Exception(errors + " errors found"); - System.out.println("PASSED"); - } - - void test(ClassFile cf) { - test(cf, Attribute.RuntimeVisibleTypeAnnotations, true); - test(cf, Attribute.RuntimeInvisibleTypeAnnotations, false); - } - - void test(ClassFile cf, Method m) { - test(cf, m, Attribute.RuntimeVisibleTypeAnnotations, true); - test(cf, m, Attribute.RuntimeInvisibleTypeAnnotations, false); - } - - void test(ClassFile cf, Field m) { - test(cf, m, Attribute.RuntimeVisibleTypeAnnotations, true); - test(cf, m, Attribute.RuntimeInvisibleTypeAnnotations, false); - } - - // test the result of Attributes.getIndex according to expectations - // encoded in the method's name - void test(ClassFile cf, String name, boolean visible) { - int index = cf.attributes.getIndex(cf.constant_pool, name); - if (index != -1) { - Attribute attr = cf.attributes.get(index); - assert attr instanceof RuntimeTypeAnnotations_attribute; - RuntimeTypeAnnotations_attribute tAttr = (RuntimeTypeAnnotations_attribute)attr; - all += tAttr.annotations.length; - if (visible) - visibles += tAttr.annotations.length; - else - invisibles += tAttr.annotations.length; - } - } - - // test the result of Attributes.getIndex according to expectations - // encoded in the method's name - void test(ClassFile cf, Method m, String name, boolean visible) { - int index = m.attributes.getIndex(cf.constant_pool, name); - if (index != -1) { - Attribute attr = m.attributes.get(index); - assert attr instanceof RuntimeTypeAnnotations_attribute; - RuntimeTypeAnnotations_attribute tAttr = (RuntimeTypeAnnotations_attribute)attr; - all += tAttr.annotations.length; - if (visible) - visibles += tAttr.annotations.length; - else - invisibles += tAttr.annotations.length; - } - } - - // test the result of Attributes.getIndex according to expectations - // encoded in the method's name - void test(ClassFile cf, Field m, String name, boolean visible) { - int index = m.attributes.getIndex(cf.constant_pool, name); - if (index != -1) { - Attribute attr = m.attributes.get(index); - assert attr instanceof RuntimeTypeAnnotations_attribute; - RuntimeTypeAnnotations_attribute tAttr = (RuntimeTypeAnnotations_attribute)attr; - all += tAttr.annotations.length; - if (visible) - visibles += tAttr.annotations.length; - else - invisibles += tAttr.annotations.length; - } - } - - File writeTestFile() throws IOException { - File f = new File("Test.java"); - PrintWriter out = new PrintWriter(new BufferedWriter(new FileWriter(f))); - out.println("import java.util.*;"); - out.println("class Test<@Test.A T extends @Test.A List<@Test.A String>> { "); - out.println(" @interface A { }"); - - out.println(" Map<@A String, Map<@A String, @A String>> f1;"); - - out.println(" <@A T extends @A List<@A String>>"); - out.println(" Map<@A String, @A List<@A String>>"); - out.println(" method(List<@A String> @A [] param1, String @A [] @A ... param2) @A"); - out.println(" throws @A Exception {"); - out.println(" @A String lc1 = null;"); - out.println(" @A List<@A String> lc2 = null;"); - out.println(" @A String @A [] [] @A[] lc3 = null;"); - out.println(" List> lc4 = null;"); - out.println(" Object lc5 = (@A List<@A String>) null;"); - out.println(" boolean lc6 = lc1 instanceof @A String;"); - out.println(" boolean lc7 = lc5 instanceof @A String @A [] @A [];"); - out.println(" new @A ArrayList<@A String>();"); - out.println(" Object lc8 = new @A String @A [4];"); - out.println(" Object lc9 = @A String.class;"); - out.println(" Object lc10 = @A int.class;"); - out.println(" return null;"); - out.println(" }"); - out.println(" void vararg1(String @A ... t) { } "); - out.println("}"); - out.close(); - return f; - } - - File compileTestFile(File f) { - int rc = com.sun.tools.javac.Main.compile(new String[] { "-source", "1.7", "-g", f.getPath() }); - if (rc != 0) - throw new Error("compilation failed. rc=" + rc); - String path = f.getPath(); - return new File(path.substring(0, path.length() - 5) + ".class"); - } - - void countAnnotations() { - int expected_visibles = 0, expected_invisibles = 39; - int expected_all = expected_visibles + expected_invisibles; - - if (expected_all != all) { - errors++; - System.err.println("expected " + expected_all - + " annotations but found " + all); - } - - if (expected_visibles != visibles) { - errors++; - System.err.println("expected " + expected_visibles - + " visibles annotations but found " + visibles); - } - - if (expected_invisibles != invisibles) { - errors++; - System.err.println("expected " + expected_invisibles - + " invisibles annotations but found " + invisibles); - } - - } - - int errors; - int all; - int visibles; - int invisibles; -} diff --git a/langtools/test/tools/javap/typeAnnotations/PresenceInner.java b/langtools/test/tools/javap/typeAnnotations/PresenceInner.java deleted file mode 100644 index 50ae3a9ad8c..00000000000 --- a/langtools/test/tools/javap/typeAnnotations/PresenceInner.java +++ /dev/null @@ -1,185 +0,0 @@ -/* - * Copyright (c) 2009, 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. - */ - -import java.io.*; -import com.sun.tools.classfile.*; - -/* - * @test PresenceInner - * @bug 6843077 - * @summary test that annotations in inner types count only once - */ - -public class PresenceInner { - public static void main(String[] args) throws Exception { - new PresenceInner().run(); - } - - public void run() throws Exception { - File javaFile = writeTestFile(); - File classFile = compileTestFile(javaFile); - - ClassFile cf = ClassFile.read(classFile); - test(cf); - for (Field f : cf.fields) { - test(cf, f); - } - for (Method m: cf.methods) { - test(cf, m); - } - - // counts are zero when vising outer class - countAnnotations(0); - - // visit inner class - File innerFile = new File("Test$1Inner.class"); - ClassFile icf = ClassFile.read(innerFile); - test(icf); - for (Field f : icf.fields) { - test(cf, f); - } - for (Method m: icf.methods) { - test(cf, m); - } - - countAnnotations(1); - if (errors > 0) - throw new Exception(errors + " errors found"); - System.out.println("PASSED"); - } - - void test(ClassFile cf) { - test(cf, Attribute.RuntimeVisibleTypeAnnotations, true); - test(cf, Attribute.RuntimeInvisibleTypeAnnotations, false); - } - - void test(ClassFile cf, Method m) { - test(cf, m, Attribute.RuntimeVisibleTypeAnnotations, true); - test(cf, m, Attribute.RuntimeInvisibleTypeAnnotations, false); - } - - void test(ClassFile cf, Field m) { - test(cf, m, Attribute.RuntimeVisibleTypeAnnotations, true); - test(cf, m, Attribute.RuntimeInvisibleTypeAnnotations, false); - } - - // test the result of Attributes.getIndex according to expectations - // encoded in the method's name - void test(ClassFile cf, String name, boolean visible) { - int index = cf.attributes.getIndex(cf.constant_pool, name); - if (index != -1) { - Attribute attr = cf.attributes.get(index); - assert attr instanceof RuntimeTypeAnnotations_attribute; - RuntimeTypeAnnotations_attribute tAttr = (RuntimeTypeAnnotations_attribute)attr; - all += tAttr.annotations.length; - if (visible) - visibles += tAttr.annotations.length; - else - invisibles += tAttr.annotations.length; - } - } - - // test the result of Attributes.getIndex according to expectations - // encoded in the method's name - void test(ClassFile cf, Method m, String name, boolean visible) { - int index = m.attributes.getIndex(cf.constant_pool, name); - if (index != -1) { - Attribute attr = m.attributes.get(index); - assert attr instanceof RuntimeTypeAnnotations_attribute; - RuntimeTypeAnnotations_attribute tAttr = (RuntimeTypeAnnotations_attribute)attr; - all += tAttr.annotations.length; - if (visible) - visibles += tAttr.annotations.length; - else - invisibles += tAttr.annotations.length; - } - } - - // test the result of Attributes.getIndex according to expectations - // encoded in the method's name - void test(ClassFile cf, Field m, String name, boolean visible) { - int index = m.attributes.getIndex(cf.constant_pool, name); - if (index != -1) { - Attribute attr = m.attributes.get(index); - assert attr instanceof RuntimeTypeAnnotations_attribute; - RuntimeTypeAnnotations_attribute tAttr = (RuntimeTypeAnnotations_attribute)attr; - all += tAttr.annotations.length; - if (visible) - visibles += tAttr.annotations.length; - else - invisibles += tAttr.annotations.length; - } - } - - File writeTestFile() throws IOException { - File f = new File("Test.java"); - PrintWriter out = new PrintWriter(new BufferedWriter(new FileWriter(f))); - - out.println("class Test {"); - out.println(" void method() {"); - out.println(" class Inner { }"); - out.println(" }"); - out.println("}"); - out.println("@interface A { }"); - out.close(); - System.out.println(f.getAbsolutePath()); - return f; - } - - File compileTestFile(File f) { - int rc = com.sun.tools.javac.Main.compile(new String[] { "-source", "1.7", "-g", f.getPath() }); - if (rc != 0) - throw new Error("compilation failed. rc=" + rc); - String path = f.getPath(); - return new File(path.substring(0, path.length() - 5) + ".class"); - } - - void countAnnotations(int expected_invisibles) { - int expected_visibles = 0; - int expected_all = expected_visibles + expected_invisibles; - - if (expected_all != all) { - errors++; - System.err.println("expected " + expected_all - + " annotations but found " + all); - } - - if (expected_visibles != visibles) { - errors++; - System.err.println("expected " + expected_visibles - + " visibles annotations but found " + visibles); - } - - if (expected_invisibles != invisibles) { - errors++; - System.err.println("expected " + expected_invisibles - + " invisibles annotations but found " + invisibles); - } - - } - - int errors; - int all; - int visibles; - int invisibles; -} diff --git a/langtools/test/tools/javap/typeAnnotations/T6855990.java b/langtools/test/tools/javap/typeAnnotations/T6855990.java deleted file mode 100644 index 66ffb67110e..00000000000 --- a/langtools/test/tools/javap/typeAnnotations/T6855990.java +++ /dev/null @@ -1,51 +0,0 @@ -/* - * Copyright (c) 2009, 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. - */ - -import java.io.*; - -/* - * @test - * @bug 6855990 - * @summary InstructionDetailWriter should support new 308 annotations attribute - */ - -public class T6855990 { - public static void main(String[] args) throws Exception { - new T6855990().run(); - } - - public void run() throws Exception { - @Simple String[] args = { "-c", "-XDdetails:typeAnnotations", "T6855990" }; - StringWriter sw = new StringWriter(); - PrintWriter pw = new PrintWriter(sw); - int rc = com.sun.tools.javap.Main.run(args, pw); - pw.close(); - String out = sw.toString(); - System.out.println(out); - if (out.indexOf("@Simple: LOCAL_VARIABLE") == -1) - throw new Exception("expected output not found"); - } -} - -@interface Simple { } - diff --git a/langtools/test/tools/javap/typeAnnotations/Visibility.java b/langtools/test/tools/javap/typeAnnotations/Visibility.java deleted file mode 100644 index 49b619c386e..00000000000 --- a/langtools/test/tools/javap/typeAnnotations/Visibility.java +++ /dev/null @@ -1,139 +0,0 @@ -/* - * Copyright (c) 2008, 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. - */ - -import java.io.*; -import com.sun.tools.classfile.*; - -/* - * @test Visibility - * @bug 6843077 - * @summary test that type annotations are recorded in the classfile - */ - -public class Visibility { - public static void main(String[] args) throws Exception { - new Visibility().run(); - } - - public void run() throws Exception { - File javaFile = writeTestFile(); - File classFile = compileTestFile(javaFile); - - ClassFile cf = ClassFile.read(classFile); - for (Method m: cf.methods) { - test(cf, m); - } - - countAnnotations(); - - if (errors > 0) - throw new Exception(errors + " errors found"); - System.out.println("PASSED"); - } - - void test(ClassFile cf, Method m) { - test(cf, m, Attribute.RuntimeVisibleTypeAnnotations, true); - test(cf, m, Attribute.RuntimeInvisibleTypeAnnotations, false); - } - - // test the result of Attributes.getIndex according to expectations - // encoded in the method's name - void test(ClassFile cf, Method m, String name, boolean visible) { - int index = m.attributes.getIndex(cf.constant_pool, name); - if (index != -1) { - Attribute attr = m.attributes.get(index); - assert attr instanceof RuntimeTypeAnnotations_attribute; - RuntimeTypeAnnotations_attribute tAttr = (RuntimeTypeAnnotations_attribute)attr; - all += tAttr.annotations.length; - if (visible) - visibles += tAttr.annotations.length; - else - invisibles += tAttr.annotations.length; - } - } - - File writeTestFile() throws IOException { - File f = new File("Test.java"); - PrintWriter out = new PrintWriter(new BufferedWriter(new FileWriter(f))); - out.println("import java.lang.annotation.Retention;"); - out.println("import java.lang.annotation.RetentionPolicy;"); - out.println("abstract class Test { "); - // visible annotations: RUNTIME - out.println(" @Retention(RetentionPolicy.RUNTIME)"); - out.println(" @interface A { }"); - out.println(" void visible() @A { }"); - - // invisible annotations: CLASS - out.println(" @Retention(RetentionPolicy.CLASS)"); - out.println(" @interface B { }"); - out.println(" void invisible() @B { }"); - - // source annotations - out.println(" @Retention(RetentionPolicy.SOURCE)"); - out.println(" @interface C { }"); - out.println(" void source() @C { }"); - - // default visibility: CLASS - out.println(" @interface D { }"); - out.println(" void def() @D { }"); - out.println("}"); - out.close(); - return f; - } - - File compileTestFile(File f) { - int rc = com.sun.tools.javac.Main.compile(new String[] { "-source", "1.7", "-g", f.getPath() }); - if (rc != 0) - throw new Error("compilation failed. rc=" + rc); - String path = f.getPath(); - return new File(path.substring(0, path.length() - 5) + ".class"); - } - - void countAnnotations() { - int expected_all = 3, expected_visibles = 1, expected_invisibles = 2; - - if (expected_all != all) { - errors++; - System.err.println("expected " + expected_all - + " annotations but found " + all); - } - - if (expected_visibles != visibles) { - errors++; - System.err.println("expected " + expected_visibles - + " visibles annotations but found " + visibles); - } - - if (expected_invisibles != invisibles) { - errors++; - System.err.println("expected " + expected_invisibles - + " invisibles annotations but found " + invisibles); - } - - } - - int errors; - int all; - int visibles; - int invisibles; -} From 35cc8afcf96f338b2cf22415b592ecc1bd7af1ce Mon Sep 17 00:00:00 2001 From: Jonathan Gibbons Date: Fri, 22 Oct 2010 14:04:33 -0700 Subject: [PATCH 03/11] 6993301: catch parameters do not have correct kind (i.e. ElementKind.EXCEPTION_PARAMETER) Reviewed-by: mcimadamore --- .../com/sun/tools/javac/comp/Attr.java | 2 +- langtools/test/tools/javac/T6993301.java | 105 ++++++++++++++++++ 2 files changed, 106 insertions(+), 1 deletion(-) create mode 100644 langtools/test/tools/javac/T6993301.java diff --git a/langtools/src/share/classes/com/sun/tools/javac/comp/Attr.java b/langtools/src/share/classes/com/sun/tools/javac/comp/Attr.java index 7e80d2693cb..3319b7f7ba1 100644 --- a/langtools/src/share/classes/com/sun/tools/javac/comp/Attr.java +++ b/langtools/src/share/classes/com/sun/tools/javac/comp/Attr.java @@ -1055,7 +1055,7 @@ public class Attr extends JCTree.Visitor { } c.param.sym.flags_field = c.param.sym.flags() | DISJOINT; } - if (c.param.type.tsym.kind == Kinds.VAR) { + if (c.param.sym.kind == Kinds.VAR) { c.param.sym.setData(ElementKind.EXCEPTION_PARAMETER); } chk.checkType(c.param.vartype.pos(), diff --git a/langtools/test/tools/javac/T6993301.java b/langtools/test/tools/javac/T6993301.java new file mode 100644 index 00000000000..ab5d532a3d5 --- /dev/null +++ b/langtools/test/tools/javac/T6993301.java @@ -0,0 +1,105 @@ +/* + * Copyright (c) 2010, 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 6993301 + * @summary catch parameters do not have correct kind (i.e. ElementKind.EXCEPTION_PARAMETER) + */ + +import com.sun.source.tree.CompilationUnitTree; +import com.sun.source.tree.IdentifierTree; +import com.sun.source.tree.VariableTree; +import com.sun.source.util.TreePathScanner; +import com.sun.source.util.Trees; +import com.sun.tools.javac.api.JavacTaskImpl; +import java.io.IOException; +import java.net.URI; +import java.util.Arrays; +import javax.lang.model.element.Element; +import javax.lang.model.element.ElementKind; +import javax.tools.JavaCompiler; +import javax.tools.JavaFileObject; +import javax.tools.SimpleJavaFileObject; +import javax.tools.ToolProvider; + +/** + * + * @author Jan Lahoda + */ +public class T6993301 { + public static void main(String... args) throws Exception { + new T6993301().testExceptionParameterCorrectKind(); + } + + static class MyFileObject extends SimpleJavaFileObject { + private String text; + public MyFileObject(String text) { + super(URI.create("myfo:/Test.java"), JavaFileObject.Kind.SOURCE); + this.text = text; + } + @Override + public CharSequence getCharContent(boolean ignoreEncodingErrors) { + return text; + } + } + + public void testExceptionParameterCorrectKind() throws IOException { + final String bootPath = System.getProperty("sun.boot.class.path"); + final JavaCompiler tool = ToolProvider.getSystemJavaCompiler(); + assert tool != null; + + String code = "package test; public class Test { { try { } catch (NullPointerException ex) {} } }"; + + final JavacTaskImpl ct = (JavacTaskImpl)tool.getTask(null, null, null, + Arrays.asList("-bootclasspath", bootPath), + null, Arrays.asList(new MyFileObject(code))); + CompilationUnitTree cut = ct.parse().iterator().next(); + + ct.analyze(); + + new TreePathScanner() { + @Override + public Void visitVariable(VariableTree node, Void p) { + Element el = Trees.instance(ct).getElement(getCurrentPath()); + + assertNotNull(el); + assertEquals(ElementKind.EXCEPTION_PARAMETER, el.getKind()); + + return super.visitVariable(node, p); + } + }.scan(cut, null); + } + + private void assertNotNull(Object o) { + if (o == null) + throw new AssertionError(); + } + + private void assertEquals(T expected, T actual) { + if (expected == null ? actual == null : expected.equals(actual)) + return; + throw new AssertionError("expected: " + expected + ", actual: " + actual); + } + +} From efaaa59c32f72e13af65be5dd62eac548f24ed04 Mon Sep 17 00:00:00 2001 From: Jonathan Gibbons Date: Tue, 26 Oct 2010 14:29:48 -0700 Subject: [PATCH 04/11] 6949587: rename "DisjointType" to "DisjunctType" Reviewed-by: mcimadamore --- ...TypeTree.java => DisjunctiveTypeTree.java} | 6 ++-- .../classes/com/sun/source/tree/Tree.java | 4 +-- .../com/sun/source/tree/TreeVisitor.java | 2 +- .../sun/source/util/SimpleTreeVisitor.java | 2 +- .../com/sun/source/util/TreeScanner.java | 4 +-- .../com/sun/tools/javac/code/Flags.java | 4 +-- .../com/sun/tools/javac/comp/Attr.java | 8 ++--- .../com/sun/tools/javac/comp/Flow.java | 6 ++-- .../classes/com/sun/tools/javac/jvm/Gen.java | 2 +- .../sun/tools/javac/parser/JavacParser.java | 2 +- .../com/sun/tools/javac/tree/JCTree.java | 30 +++++++++---------- .../com/sun/tools/javac/tree/Pretty.java | 4 +-- .../com/sun/tools/javac/tree/TreeCopier.java | 8 ++--- .../com/sun/tools/javac/tree/TreeInfo.java | 2 +- .../com/sun/tools/javac/tree/TreeMaker.java | 4 +-- .../com/sun/tools/javac/tree/TreeScanner.java | 4 +-- .../sun/tools/javac/tree/TreeTranslator.java | 4 +-- 17 files changed, 48 insertions(+), 48 deletions(-) rename langtools/src/share/classes/com/sun/source/tree/{DisjointTypeTree.java => DisjunctiveTypeTree.java} (87%) diff --git a/langtools/src/share/classes/com/sun/source/tree/DisjointTypeTree.java b/langtools/src/share/classes/com/sun/source/tree/DisjunctiveTypeTree.java similarity index 87% rename from langtools/src/share/classes/com/sun/source/tree/DisjointTypeTree.java rename to langtools/src/share/classes/com/sun/source/tree/DisjunctiveTypeTree.java index 6d122aaee48..ae8e5813845 100644 --- a/langtools/src/share/classes/com/sun/source/tree/DisjointTypeTree.java +++ b/langtools/src/share/classes/com/sun/source/tree/DisjunctiveTypeTree.java @@ -28,13 +28,13 @@ package com.sun.source.tree; import java.util.List; /** - * A tree node for a disjoint type expression in a multicatch var declaration. + * A tree node for a disjunctive type expression in a multicatch var declaration. * * * @author Maurizio Cimadamore * * @since 1.7 */ -public interface DisjointTypeTree extends Tree { - List getTypeComponents(); +public interface DisjunctiveTypeTree extends Tree { + List getTypeAlternatives(); } diff --git a/langtools/src/share/classes/com/sun/source/tree/Tree.java b/langtools/src/share/classes/com/sun/source/tree/Tree.java index 95b2d85c9e6..dd51f976e8c 100644 --- a/langtools/src/share/classes/com/sun/source/tree/Tree.java +++ b/langtools/src/share/classes/com/sun/source/tree/Tree.java @@ -234,9 +234,9 @@ public interface Tree { PARAMETERIZED_TYPE(ParameterizedTypeTree.class), /** - * Used for instances of {@link DisjointTypeTree}. + * Used for instances of {@link DisjunctiveTypeTree}. */ - DISJOINT_TYPE(DisjointTypeTree.class), + DISJUNCTIVE_TYPE(DisjunctiveTypeTree.class), /** * Used for instances of {@link TypeCastTree}. diff --git a/langtools/src/share/classes/com/sun/source/tree/TreeVisitor.java b/langtools/src/share/classes/com/sun/source/tree/TreeVisitor.java index 6aba5d310e4..ef95a9ff78e 100644 --- a/langtools/src/share/classes/com/sun/source/tree/TreeVisitor.java +++ b/langtools/src/share/classes/com/sun/source/tree/TreeVisitor.java @@ -96,7 +96,7 @@ public interface TreeVisitor { R visitCompilationUnit(CompilationUnitTree node, P p); R visitTry(TryTree node, P p); R visitParameterizedType(ParameterizedTypeTree node, P p); - R visitDisjointType(DisjointTypeTree node, P p); + R visitDisjunctiveType(DisjunctiveTypeTree node, P p); R visitArrayType(ArrayTypeTree node, P p); R visitTypeCast(TypeCastTree node, P p); R visitPrimitiveType(PrimitiveTypeTree node, P p); diff --git a/langtools/src/share/classes/com/sun/source/util/SimpleTreeVisitor.java b/langtools/src/share/classes/com/sun/source/util/SimpleTreeVisitor.java index 70b3435f9c8..c2554b77985 100644 --- a/langtools/src/share/classes/com/sun/source/util/SimpleTreeVisitor.java +++ b/langtools/src/share/classes/com/sun/source/util/SimpleTreeVisitor.java @@ -228,7 +228,7 @@ public class SimpleTreeVisitor implements TreeVisitor { return defaultAction(node, p); } - public R visitDisjointType(DisjointTypeTree node, P p) { + public R visitDisjunctiveType(DisjunctiveTypeTree node, P p) { return defaultAction(node, p); } diff --git a/langtools/src/share/classes/com/sun/source/util/TreeScanner.java b/langtools/src/share/classes/com/sun/source/util/TreeScanner.java index 4b537ed4614..ccbce17cca5 100644 --- a/langtools/src/share/classes/com/sun/source/util/TreeScanner.java +++ b/langtools/src/share/classes/com/sun/source/util/TreeScanner.java @@ -356,8 +356,8 @@ public class TreeScanner implements TreeVisitor { return r; } - public R visitDisjointType(DisjointTypeTree node, P p) { - return scan(node.getTypeComponents(), p); + public R visitDisjunctiveType(DisjunctiveTypeTree node, P p) { + return scan(node.getTypeAlternatives(), p); } public R visitTypeParameter(TypeParameterTree node, P p) { diff --git a/langtools/src/share/classes/com/sun/tools/javac/code/Flags.java b/langtools/src/share/classes/com/sun/tools/javac/code/Flags.java index 48e6a86f29d..5b0b8bad260 100644 --- a/langtools/src/share/classes/com/sun/tools/javac/code/Flags.java +++ b/langtools/src/share/classes/com/sun/tools/javac/code/Flags.java @@ -231,9 +231,9 @@ public class Flags { public static final long PROPRIETARY = 1L<<38; /** - * Flag that marks a disjoint var in a multi-catch clause + * Flag that marks a disjunction var in a multi-catch clause */ - public static final long DISJOINT = 1L<<39; + public static final long DISJUNCTION = 1L<<39; /** * Flag that marks a signature-polymorphic invoke method. diff --git a/langtools/src/share/classes/com/sun/tools/javac/comp/Attr.java b/langtools/src/share/classes/com/sun/tools/javac/comp/Attr.java index 3319b7f7ba1..e0ba0061537 100644 --- a/langtools/src/share/classes/com/sun/tools/javac/comp/Attr.java +++ b/langtools/src/share/classes/com/sun/tools/javac/comp/Attr.java @@ -1053,7 +1053,7 @@ public class Attr extends JCTree.Visitor { if ((c.param.sym.flags() & FINAL) == 0) { log.error(c.param.pos(), "multicatch.param.must.be.final", c.param.sym); } - c.param.sym.flags_field = c.param.sym.flags() | DISJOINT; + c.param.sym.flags_field = c.param.sym.flags() | DISJUNCTION; } if (c.param.sym.kind == Kinds.VAR) { c.param.sym.setData(ElementKind.EXCEPTION_PARAMETER); @@ -2839,9 +2839,9 @@ public class Attr extends JCTree.Visitor { result = check(tree, owntype, TYP, pkind, pt); } - public void visitTypeDisjoint(JCTypeDisjoint tree) { - List componentTypes = attribTypes(tree.components, env); - tree.type = result = check(tree, types.lub(componentTypes), TYP, pkind, pt); + public void visitTypeDisjunction(JCTypeDisjunction tree) { + List alternatives = attribTypes(tree.alternatives, env); + tree.type = result = check(tree, types.lub(alternatives), TYP, pkind, pt); } public void visitTypeParameter(JCTypeParameter tree) { diff --git a/langtools/src/share/classes/com/sun/tools/javac/comp/Flow.java b/langtools/src/share/classes/com/sun/tools/javac/comp/Flow.java index ea97cac9dbc..fad6dad34af 100644 --- a/langtools/src/share/classes/com/sun/tools/javac/comp/Flow.java +++ b/langtools/src/share/classes/com/sun/tools/javac/comp/Flow.java @@ -371,7 +371,7 @@ public class Flow extends TreeScanner { if (sym.adr >= firstadr && trackable(sym)) { if ((sym.flags() & FINAL) != 0) { if ((sym.flags() & PARAMETER) != 0) { - if ((sym.flags() & DISJOINT) != 0) { //multi-catch parameter + if ((sym.flags() & DISJUNCTION) != 0) { //multi-catch parameter log.error(pos, "multicatch.parameter.may.not.be.assigned", sym); } @@ -983,7 +983,7 @@ public class Flow extends TreeScanner { thrown = List.nil(); for (List l = tree.catchers; l.nonEmpty(); l = l.tail) { List subClauses = TreeInfo.isMultiCatch(l.head) ? - ((JCTypeDisjoint)l.head.param.vartype).components : + ((JCTypeDisjunction)l.head.param.vartype).alternatives : List.of(l.head.param.vartype); for (JCExpression ct : subClauses) { caught = chk.incl(ct.type, caught); @@ -1049,7 +1049,7 @@ public class Flow extends TreeScanner { alive = true; JCVariableDecl param = l.head.param; List subClauses = TreeInfo.isMultiCatch(l.head) ? - ((JCTypeDisjoint)l.head.param.vartype).components : + ((JCTypeDisjunction)l.head.param.vartype).alternatives : List.of(l.head.param.vartype); List ctypes = List.nil(); List rethrownTypes = chk.diff(thrownInTry, caughtInTry); diff --git a/langtools/src/share/classes/com/sun/tools/javac/jvm/Gen.java b/langtools/src/share/classes/com/sun/tools/javac/jvm/Gen.java index 572380a49e1..f676edd6a69 100644 --- a/langtools/src/share/classes/com/sun/tools/javac/jvm/Gen.java +++ b/langtools/src/share/classes/com/sun/tools/javac/jvm/Gen.java @@ -1456,7 +1456,7 @@ public class Gen extends JCTree.Visitor { List gaps) { if (startpc != endpc) { List subClauses = TreeInfo.isMultiCatch(tree) ? - ((JCTypeDisjoint)tree.param.vartype).components : + ((JCTypeDisjunction)tree.param.vartype).alternatives : List.of(tree.param.vartype); while (gaps.nonEmpty()) { for (JCExpression subCatch : subClauses) { diff --git a/langtools/src/share/classes/com/sun/tools/javac/parser/JavacParser.java b/langtools/src/share/classes/com/sun/tools/javac/parser/JavacParser.java index ab123e1fae5..30fcbe3d0b6 100644 --- a/langtools/src/share/classes/com/sun/tools/javac/parser/JavacParser.java +++ b/langtools/src/share/classes/com/sun/tools/javac/parser/JavacParser.java @@ -1827,7 +1827,7 @@ public class JavacParser implements Parser { JCModifiers mods = optFinal(Flags.PARAMETER); List catchTypes = catchTypes(); JCExpression paramType = catchTypes.size() > 1 ? - toP(F.at(catchTypes.head.getStartPosition()).TypeDisjoint(catchTypes)) : + toP(F.at(catchTypes.head.getStartPosition()).TypeDisjunction(catchTypes)) : catchTypes.head; JCVariableDecl formal = variableDeclaratorId(mods, paramType); accept(RPAREN); diff --git a/langtools/src/share/classes/com/sun/tools/javac/tree/JCTree.java b/langtools/src/share/classes/com/sun/tools/javac/tree/JCTree.java index 96ef9ebfd1e..114fe76293c 100644 --- a/langtools/src/share/classes/com/sun/tools/javac/tree/JCTree.java +++ b/langtools/src/share/classes/com/sun/tools/javac/tree/JCTree.java @@ -236,13 +236,13 @@ public abstract class JCTree implements Tree, Cloneable, DiagnosticPosition { */ public static final int TYPEAPPLY = TYPEARRAY + 1; - /** Disjunctive types, of type TypeDisjoint. + /** Disjunction types, of type TypeDisjunction */ - public static final int TYPEDISJOINT = TYPEAPPLY + 1; + public static final int TYPEDISJUNCTION = TYPEAPPLY + 1; /** Formal type parameters, of type TypeParameter. */ - public static final int TYPEPARAMETER = TYPEDISJOINT + 1; + public static final int TYPEPARAMETER = TYPEDISJUNCTION + 1; /** Type argument. */ @@ -1888,30 +1888,30 @@ public abstract class JCTree implements Tree, Cloneable, DiagnosticPosition { } /** - * A disjoint type, T1 | T2 | ... Tn (used in multicatch statements) + * A disjunction type, T1 | T2 | ... Tn (used in multicatch statements) */ - public static class JCTypeDisjoint extends JCExpression implements DisjointTypeTree { + public static class JCTypeDisjunction extends JCExpression implements DisjunctiveTypeTree { - public List components; + public List alternatives; - protected JCTypeDisjoint(List components) { - this.components = components; + protected JCTypeDisjunction(List components) { + this.alternatives = components; } @Override - public void accept(Visitor v) { v.visitTypeDisjoint(this); } + public void accept(Visitor v) { v.visitTypeDisjunction(this); } - public Kind getKind() { return Kind.DISJOINT_TYPE; } + public Kind getKind() { return Kind.DISJUNCTIVE_TYPE; } - public List getTypeComponents() { - return components; + public List getTypeAlternatives() { + return alternatives; } @Override public R accept(TreeVisitor v, D d) { - return v.visitDisjointType(this, d); + return v.visitDisjunctiveType(this, d); } @Override public int getTag() { - return TYPEDISJOINT; + return TYPEDISJUNCTION; } } @@ -2284,7 +2284,7 @@ public abstract class JCTree implements Tree, Cloneable, DiagnosticPosition { public void visitTypeIdent(JCPrimitiveTypeTree that) { visitTree(that); } public void visitTypeArray(JCArrayTypeTree that) { visitTree(that); } public void visitTypeApply(JCTypeApply that) { visitTree(that); } - public void visitTypeDisjoint(JCTypeDisjoint that) { visitTree(that); } + public void visitTypeDisjunction(JCTypeDisjunction that) { visitTree(that); } public void visitTypeParameter(JCTypeParameter that) { visitTree(that); } public void visitWildcard(JCWildcard that) { visitTree(that); } public void visitTypeBoundKind(TypeBoundKind that) { visitTree(that); } diff --git a/langtools/src/share/classes/com/sun/tools/javac/tree/Pretty.java b/langtools/src/share/classes/com/sun/tools/javac/tree/Pretty.java index 66f6e56104d..2f2d9ba30f2 100644 --- a/langtools/src/share/classes/com/sun/tools/javac/tree/Pretty.java +++ b/langtools/src/share/classes/com/sun/tools/javac/tree/Pretty.java @@ -1195,9 +1195,9 @@ public class Pretty extends JCTree.Visitor { } } - public void visitTypeDisjoint(JCTypeDisjoint tree) { + public void visitTypeDisjunction(JCTypeDisjunction tree) { try { - printExprs(tree.components, " | "); + printExprs(tree.alternatives, " | "); } catch (IOException e) { throw new UncheckedIOException(e); } diff --git a/langtools/src/share/classes/com/sun/tools/javac/tree/TreeCopier.java b/langtools/src/share/classes/com/sun/tools/javac/tree/TreeCopier.java index 63b9ae06130..077e3fec390 100644 --- a/langtools/src/share/classes/com/sun/tools/javac/tree/TreeCopier.java +++ b/langtools/src/share/classes/com/sun/tools/javac/tree/TreeCopier.java @@ -346,10 +346,10 @@ public class TreeCopier

implements TreeVisitor { return M.at(t.pos).TypeApply(clazz, arguments); } - public JCTree visitDisjointType(DisjointTypeTree node, P p) { - JCTypeDisjoint t = (JCTypeDisjoint) node; - List components = copy(t.components, p); - return M.at(t.pos).TypeDisjoint(components); + public JCTree visitDisjunctiveType(DisjunctiveTypeTree node, P p) { + JCTypeDisjunction t = (JCTypeDisjunction) node; + List components = copy(t.alternatives, p); + return M.at(t.pos).TypeDisjunction(components); } public JCTree visitArrayType(ArrayTypeTree node, P p) { diff --git a/langtools/src/share/classes/com/sun/tools/javac/tree/TreeInfo.java b/langtools/src/share/classes/com/sun/tools/javac/tree/TreeInfo.java index d522dc8f256..eda05d58379 100644 --- a/langtools/src/share/classes/com/sun/tools/javac/tree/TreeInfo.java +++ b/langtools/src/share/classes/com/sun/tools/javac/tree/TreeInfo.java @@ -119,7 +119,7 @@ public class TreeInfo { } public static boolean isMultiCatch(JCCatch catchClause) { - return catchClause.param.vartype.getTag() == JCTree.TYPEDISJOINT; + return catchClause.param.vartype.getTag() == JCTree.TYPEDISJUNCTION; } /** Is statement an initializer for a synthetic field? diff --git a/langtools/src/share/classes/com/sun/tools/javac/tree/TreeMaker.java b/langtools/src/share/classes/com/sun/tools/javac/tree/TreeMaker.java index 6ca4e0d41d0..b5b7c220cff 100644 --- a/langtools/src/share/classes/com/sun/tools/javac/tree/TreeMaker.java +++ b/langtools/src/share/classes/com/sun/tools/javac/tree/TreeMaker.java @@ -451,8 +451,8 @@ public class TreeMaker implements JCTree.Factory { return tree; } - public JCTypeDisjoint TypeDisjoint(List components) { - JCTypeDisjoint tree = new JCTypeDisjoint(components); + public JCTypeDisjunction TypeDisjunction(List components) { + JCTypeDisjunction tree = new JCTypeDisjunction(components); tree.pos = pos; return tree; } diff --git a/langtools/src/share/classes/com/sun/tools/javac/tree/TreeScanner.java b/langtools/src/share/classes/com/sun/tools/javac/tree/TreeScanner.java index 53eb5118fb3..0d6e8e3bbc0 100644 --- a/langtools/src/share/classes/com/sun/tools/javac/tree/TreeScanner.java +++ b/langtools/src/share/classes/com/sun/tools/javac/tree/TreeScanner.java @@ -276,8 +276,8 @@ public class TreeScanner extends Visitor { scan(tree.arguments); } - public void visitTypeDisjoint(JCTypeDisjoint tree) { - scan(tree.components); + public void visitTypeDisjunction(JCTypeDisjunction tree) { + scan(tree.alternatives); } public void visitTypeParameter(JCTypeParameter tree) { diff --git a/langtools/src/share/classes/com/sun/tools/javac/tree/TreeTranslator.java b/langtools/src/share/classes/com/sun/tools/javac/tree/TreeTranslator.java index ffb219b6a63..115ac06a4eb 100644 --- a/langtools/src/share/classes/com/sun/tools/javac/tree/TreeTranslator.java +++ b/langtools/src/share/classes/com/sun/tools/javac/tree/TreeTranslator.java @@ -368,8 +368,8 @@ public class TreeTranslator extends JCTree.Visitor { result = tree; } - public void visitTypeDisjoint(JCTypeDisjoint tree) { - tree.components = translate(tree.components); + public void visitTypeDisjunction(JCTypeDisjunction tree) { + tree.alternatives = translate(tree.alternatives); result = tree; } From 3e7e25e084c0f137d4119fe95a5d8b196a0ebd3d Mon Sep 17 00:00:00 2001 From: Per Bothner Date: Thu, 28 Oct 2010 10:17:47 -0700 Subject: [PATCH 05/11] 6460352: Reintroduce Scope.dble Reviewed-by: mcimadamore, jjg --- .../com/sun/tools/javac/code/Scope.java | 121 ++++++++++++------ 1 file changed, 82 insertions(+), 39 deletions(-) diff --git a/langtools/src/share/classes/com/sun/tools/javac/code/Scope.java b/langtools/src/share/classes/com/sun/tools/javac/code/Scope.java index 8bbc73d84d8..72ffbac8916 100644 --- a/langtools/src/share/classes/com/sun/tools/javac/code/Scope.java +++ b/langtools/src/share/classes/com/sun/tools/javac/code/Scope.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 1999, 2008, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 1999, 2010, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -31,7 +31,8 @@ import java.util.Iterator; /** A scope represents an area of visibility in a Java program. The * Scope class is a container for symbols which provides * efficient access to symbols given their names. Scopes are implemented - * as hash tables. Scopes can be nested; the next field of a scope points + * as hash tables with "open addressing" and "double hashing". + * Scopes can be nested; the next field of a scope points * to its next outer scope. Nested scopes can share their hash tables. * *

This is NOT part of any supported API. @@ -67,6 +68,7 @@ public class Scope { public Entry elems; /** The number of elements in this scope. + * This includes deleted elements, whose value is the sentinel. */ public int nelems = 0; @@ -109,7 +111,8 @@ public class Scope { } } - /** Every hash bucket is a list of Entry's which ends in sentinel. + /** Use as a "not-found" result for lookup. + * Also used to mark deleted entries in the table. */ private static final Entry sentinel = new Entry(null, null, null, null); @@ -130,12 +133,15 @@ public class Scope { this.owner = owner; this.table = table; this.hashMask = table.length - 1; - this.elems = null; - this.nelems = 0; - this.shared = 0; this.scopeCounter = scopeCounter; } + /** Convenience constructor used for dup and dupUnshared. */ + private Scope(Scope next, Symbol owner, Entry[] table) { + this(next, owner, table, next.scopeCounter); + this.nelems = next.nelems; + } + /** Construct a new scope, within scope next, with given owner, * using a fresh table of length INITIAL_SIZE. */ @@ -145,7 +151,6 @@ public class Scope { protected Scope(Symbol owner, ScopeCounter scopeCounter) { this(null, owner, new Entry[INITIAL_SIZE], scopeCounter); - for (int i = 0; i < INITIAL_SIZE; i++) table[i] = sentinel; } /** Construct a fresh scope within this scope, with same owner, @@ -154,11 +159,7 @@ public class Scope { * of fresh tables. */ public Scope dup() { - Scope result = new Scope(this, this.owner, this.table, scopeCounter); - shared++; - // System.out.println("====> duping scope " + this.hashCode() + " owned by " + this.owner + " to " + result.hashCode()); - // new Error().printStackTrace(System.out); - return result; + return dup(this.owner); } /** Construct a fresh scope within this scope, with new owner, @@ -167,7 +168,7 @@ public class Scope { * of fresh tables. */ public Scope dup(Symbol newOwner) { - Scope result = new Scope(this, newOwner, this.table, scopeCounter); + Scope result = new Scope(this, newOwner, this.table); shared++; // System.out.println("====> duping scope " + this.hashCode() + " owned by " + newOwner + " to " + result.hashCode()); // new Error().printStackTrace(System.out); @@ -179,7 +180,7 @@ public class Scope { * the table of its outer scope. */ public Scope dupUnshared() { - return new Scope(this, this.owner, this.table.clone(), scopeCounter); + return new Scope(this, this.owner, this.table.clone()); } /** Remove all entries of this scope from its table, if shared @@ -189,7 +190,7 @@ public class Scope { assert shared == 0; if (table != next.table) return next; while (elems != null) { - int hash = elems.sym.name.hashCode() & hashMask; + int hash = getIndex(elems.sym.name); Entry e = table[hash]; assert e == elems : elems.sym; table[hash] = elems.shadowed; @@ -197,6 +198,7 @@ public class Scope { } assert next.shared > 0; next.shared--; + next.nelems = nelems; // System.out.println("====> leaving scope " + this.hashCode() + " owned by " + this.owner + " to " + next.hashCode()); // new Error().printStackTrace(System.out); return next; @@ -215,19 +217,17 @@ public class Scope { s.hashMask = newtable.length - 1; } } - for (int i = 0; i < newtable.length; i++) newtable[i] = sentinel; - for (int i = 0; i < oldtable.length; i++) copy(oldtable[i]); - } - - /** Copy the given entry and all entries shadowed by it to table - */ - private void copy(Entry e) { - if (e.sym != null) { - copy(e.shadowed); - int hash = e.sym.name.hashCode() & hashMask; - e.shadowed = table[hash]; - table[hash] = e; + int n = 0; + for (int i = oldtable.length; --i >= 0; ) { + Entry e = oldtable[i]; + if (e != null && e != sentinel) { + table[getIndex(e.sym.name)] = e; + n++; + } } + // We don't need to update nelems for shared inherited scopes, + // since that gets handled by leave(). + nelems = n; } /** Enter symbol sym in this scope. @@ -248,13 +248,17 @@ public class Scope { */ public void enter(Symbol sym, Scope s, Scope origin) { assert shared == 0; - // Temporarily disabled (bug 6460352): - // if (nelems * 3 >= hashMask * 2) dble(); - int hash = sym.name.hashCode() & hashMask; - Entry e = makeEntry(sym, table[hash], elems, s, origin); + if (nelems * 3 >= hashMask * 2) + dble(); + int hash = getIndex(sym.name); + Entry old = table[hash]; + if (old == null) { + old = sentinel; + nelems++; + } + Entry e = makeEntry(sym, old, elems, s, origin); table[hash] = e; elems = e; - nelems++; scopeCounter.inc(); } @@ -268,15 +272,15 @@ public class Scope { public void remove(Symbol sym) { assert shared == 0; Entry e = lookup(sym.name); - while (e.scope == this && e.sym != sym) e = e.next(); if (e.scope == null) return; scopeCounter.inc(); // remove e from table and shadowed list; - Entry te = table[sym.name.hashCode() & hashMask]; + int i = getIndex(sym.name); + Entry te = table[i]; if (te == e) - table[sym.name.hashCode() & hashMask] = e.shadowed; + table[i] = e.shadowed; else while (true) { if (te.shadowed == e) { te.shadowed = e.shadowed; @@ -335,12 +339,50 @@ public class Scope { return lookup(name, noFilter); } public Entry lookup(Name name, Filter sf) { - Entry e = table[name.hashCode() & hashMask]; + Entry e = table[getIndex(name)]; + if (e == null || e == sentinel) + return sentinel; while (e.scope != null && (e.sym.name != name || !sf.accepts(e.sym))) e = e.shadowed; return e; } + /*void dump (java.io.PrintStream out) { + out.println(this); + for (int l=0; l < table.length; l++) { + Entry le = table[l]; + out.print("#"+l+": "); + if (le==sentinel) out.println("sentinel"); + else if(le == null) out.println("null"); + else out.println(""+le+" s:"+le.sym); + } + }*/ + + /** Look for slot in the table. + * We use open addressing with double hashing. + */ + int getIndex (Name name) { + int h = name.hashCode(); + int i = h & hashMask; + // The expression below is always odd, so it is guaranteed + // be be mutually prime with table.length, a power of 2. + int x = hashMask - ((h + (h >> 16)) << 1); + int d = -1; // Index of a deleted item. + for (;;) { + Entry e = table[i]; + if (e == null) + return d >= 0 ? d : i; + if (e == sentinel) { + // We have to keep searching even if we see a deleted item. + // However, remember the index in case we fail to find the name. + if (d < 0) + d = i; + } else if (e.sym.name == name) + return i; + i = (i + x) & hashMask; + } + } + public Iterable getElements() { return getElements(noFilter); } @@ -470,10 +512,11 @@ public class Scope { } public Entry lookup(Name name) { - Entry e = table[name.hashCode() & hashMask]; + Entry e = table[getIndex(name)]; + if (e == null) + return sentinel; while (e.scope != null && - (e.sym.name != name || - /* Since an inner class will show up in package and + (/* Since an inner class will show up in package and * import scopes until its inner class attribute has * been processed, we have to weed it out here. This * is done by comparing the owners of the entry's From 49e996e3c1b9b3b28ab1ce25403db119f6de1675 Mon Sep 17 00:00:00 2001 From: Jonathan Gibbons Date: Thu, 28 Oct 2010 18:58:43 -0700 Subject: [PATCH 06/11] 6994946: option to specify only syntax errors as unrecoverable Reviewed-by: darcy, mcimadamore --- .../sun/tools/javac/main/JavaCompiler.java | 2 +- .../sun/tools/javac/parser/JavacParser.java | 65 +++++++++++-------- .../JavacProcessingEnvironment.java | 2 +- .../com/sun/tools/javac/util/AbstractLog.java | 14 ++++ .../sun/tools/javac/util/JCDiagnostic.java | 23 ++++++- .../6994946/SemanticErrorTest.1.out | 2 + .../6994946/SemanticErrorTest.2.out | 4 ++ .../processing/6994946/SemanticErrorTest.java | 13 ++++ .../processing/6994946/SyntaxErrorTest.java | 13 ++++ .../processing/6994946/SyntaxErrorTest.out | 2 + .../processing/6994946/TestProcessor.java | 40 ++++++++++++ 11 files changed, 148 insertions(+), 32 deletions(-) create mode 100644 langtools/test/tools/javac/processing/6994946/SemanticErrorTest.1.out create mode 100644 langtools/test/tools/javac/processing/6994946/SemanticErrorTest.2.out create mode 100644 langtools/test/tools/javac/processing/6994946/SemanticErrorTest.java create mode 100644 langtools/test/tools/javac/processing/6994946/SyntaxErrorTest.java create mode 100644 langtools/test/tools/javac/processing/6994946/SyntaxErrorTest.out create mode 100644 langtools/test/tools/javac/processing/6994946/TestProcessor.java diff --git a/langtools/src/share/classes/com/sun/tools/javac/main/JavaCompiler.java b/langtools/src/share/classes/com/sun/tools/javac/main/JavaCompiler.java index e439e8ed9a9..03996018d58 100644 --- a/langtools/src/share/classes/com/sun/tools/javac/main/JavaCompiler.java +++ b/langtools/src/share/classes/com/sun/tools/javac/main/JavaCompiler.java @@ -1090,7 +1090,7 @@ public class JavaCompiler implements ClassReader.SourceCompleter { private boolean unrecoverableError() { for (JCDiagnostic d: log.deferredDiagnostics) { - if (d.getKind() == JCDiagnostic.Kind.ERROR && !d.isFlagSet(RESOLVE_ERROR)) + if (d.getKind() == JCDiagnostic.Kind.ERROR && !d.isFlagSet(RECOVERABLE)) return true; } return false; diff --git a/langtools/src/share/classes/com/sun/tools/javac/parser/JavacParser.java b/langtools/src/share/classes/com/sun/tools/javac/parser/JavacParser.java index 30fcbe3d0b6..214ee9757bf 100644 --- a/langtools/src/share/classes/com/sun/tools/javac/parser/JavacParser.java +++ b/langtools/src/share/classes/com/sun/tools/javac/parser/JavacParser.java @@ -30,6 +30,7 @@ import java.util.*; import com.sun.tools.javac.tree.*; import com.sun.tools.javac.code.*; import com.sun.tools.javac.util.*; +import com.sun.tools.javac.util.JCDiagnostic.DiagnosticFlag; import com.sun.tools.javac.util.List; import static com.sun.tools.javac.util.ListBuffer.lb; @@ -266,9 +267,9 @@ public class JavacParser implements Parser { private void reportSyntaxError(int pos, String key, Object... args) { if (pos > S.errPos() || pos == Position.NOPOS) { if (S.token() == EOF) - log.error(pos, "premature.eof"); + error(pos, "premature.eof"); else - log.error(pos, key, args); + error(pos, key, args); } S.errPos(pos); if (S.pos() == errorPos) @@ -324,7 +325,7 @@ public class JavacParser implements Parser { void checkNoMods(long mods) { if (mods != 0) { long lowestMod = mods & -mods; - log.error(S.pos(), "mod.not.allowed.here", + error(S.pos(), "mod.not.allowed.here", Flags.asFlagSet(lowestMod)); } } @@ -418,22 +419,22 @@ public class JavacParser implements Parser { return name; } else if (S.token() == ASSERT) { if (allowAsserts) { - log.error(S.pos(), "assert.as.identifier"); + error(S.pos(), "assert.as.identifier"); S.nextToken(); return names.error; } else { - log.warning(S.pos(), "assert.as.identifier"); + warning(S.pos(), "assert.as.identifier"); Name name = S.name(); S.nextToken(); return name; } } else if (S.token() == ENUM) { if (allowEnums) { - log.error(S.pos(), "enum.as.identifier"); + error(S.pos(), "enum.as.identifier"); S.nextToken(); return names.error; } else { - log.warning(S.pos(), "enum.as.identifier"); + warning(S.pos(), "enum.as.identifier"); Name name = S.name(); S.nextToken(); return name; @@ -479,7 +480,7 @@ public class JavacParser implements Parser { TypeTags.INT, Convert.string2int(strval(prefix), S.radix())); } catch (NumberFormatException ex) { - log.error(S.pos(), "int.number.too.large", strval(prefix)); + error(S.pos(), "int.number.too.large", strval(prefix)); } break; case LONGLITERAL: @@ -488,7 +489,7 @@ public class JavacParser implements Parser { TypeTags.LONG, new Long(Convert.string2long(strval(prefix), S.radix()))); } catch (NumberFormatException ex) { - log.error(S.pos(), "int.number.too.large", strval(prefix)); + error(S.pos(), "int.number.too.large", strval(prefix)); } break; case FLOATLITERAL: { @@ -501,9 +502,9 @@ public class JavacParser implements Parser { n = Float.NaN; } if (n.floatValue() == 0.0f && !isZero(proper)) - log.error(S.pos(), "fp.number.too.small"); + error(S.pos(), "fp.number.too.small"); else if (n.floatValue() == Float.POSITIVE_INFINITY) - log.error(S.pos(), "fp.number.too.large"); + error(S.pos(), "fp.number.too.large"); else t = F.at(pos).Literal(TypeTags.FLOAT, n); break; @@ -518,9 +519,9 @@ public class JavacParser implements Parser { n = Double.NaN; } if (n.doubleValue() == 0.0d && !isZero(proper)) - log.error(S.pos(), "fp.number.too.small"); + error(S.pos(), "fp.number.too.small"); else if (n.doubleValue() == Double.POSITIVE_INFINITY) - log.error(S.pos(), "fp.number.too.large"); + error(S.pos(), "fp.number.too.large"); else t = F.at(pos).Literal(TypeTags.DOUBLE, n); break; @@ -1581,7 +1582,7 @@ public class JavacParser implements Parser { case ENUM: case ASSERT: if (allowEnums && S.token() == ENUM) { - log.error(S.pos(), "local.enum"); + error(S.pos(), "local.enum"); stats. append(classOrInterfaceOrEnumDeclaration(modifiersOpt(), S.docComment())); @@ -1728,9 +1729,9 @@ public class JavacParser implements Parser { } else { if (allowTWR) { if (resources.isEmpty()) - log.error(pos, "try.without.catch.finally.or.resource.decls"); + error(pos, "try.without.catch.finally.or.resource.decls"); } else - log.error(pos, "try.without.catch.or.finally"); + error(pos, "try.without.catch.or.finally"); } return F.at(pos).Try(resources, body, catchers.toList(), finalizer); } @@ -1985,7 +1986,7 @@ public class JavacParser implements Parser { case MONKEYS_AT : flag = Flags.ANNOTATION; break; default: break loop; } - if ((flags & flag) != 0) log.error(S.pos(), "repeated.modifier"); + if ((flags & flag) != 0) error(S.pos(), "repeated.modifier"); lastPos = S.pos(); S.nextToken(); if (flag == Flags.ANNOTATION) { @@ -2331,7 +2332,7 @@ public class JavacParser implements Parser { } } else { if (S.token() == ENUM) { - log.error(S.pos(), "enums.not.supported.in.source", source.name); + error(S.pos(), "enums.not.supported.in.source", source.name); allowEnums = true; return enumDeclaration(mods, dc); } @@ -2580,7 +2581,7 @@ public class JavacParser implements Parser { } if (S.token() == LPAREN && !isInterface && type.getTag() == JCTree.IDENT) { if (isInterface || name != className) - log.error(pos, "invalid.meth.decl.ret.type.req"); + error(pos, "invalid.meth.decl.ret.type.req"); return List.of(methodDeclaratorRest( pos, mods, null, names.init, typarams, isInterface, true, dc)); @@ -2759,6 +2760,14 @@ public class JavacParser implements Parser { /* ---------- auxiliary methods -------------- */ + void error(int pos, String key, Object ... args) { + log.error(DiagnosticFlag.SYNTAX, pos, key, args); + } + + void warning(int pos, String key, Object ... args) { + log.warning(pos, key, args); + } + /** Check that given tree is a legal expression statement. */ protected JCExpression checkExprStat(JCExpression t) { @@ -2774,7 +2783,7 @@ public class JavacParser implements Parser { case JCTree.ERRONEOUS: return t; default: - log.error(t.pos, "not.stmt"); + error(t.pos, "not.stmt"); return F.at(t.pos).Erroneous(List.of(t)); } } @@ -2921,49 +2930,49 @@ public class JavacParser implements Parser { void checkGenerics() { if (!allowGenerics) { - log.error(S.pos(), "generics.not.supported.in.source", source.name); + error(S.pos(), "generics.not.supported.in.source", source.name); allowGenerics = true; } } void checkVarargs() { if (!allowVarargs) { - log.error(S.pos(), "varargs.not.supported.in.source", source.name); + error(S.pos(), "varargs.not.supported.in.source", source.name); allowVarargs = true; } } void checkForeach() { if (!allowForeach) { - log.error(S.pos(), "foreach.not.supported.in.source", source.name); + error(S.pos(), "foreach.not.supported.in.source", source.name); allowForeach = true; } } void checkStaticImports() { if (!allowStaticImport) { - log.error(S.pos(), "static.import.not.supported.in.source", source.name); + error(S.pos(), "static.import.not.supported.in.source", source.name); allowStaticImport = true; } } void checkAnnotations() { if (!allowAnnotations) { - log.error(S.pos(), "annotations.not.supported.in.source", source.name); + error(S.pos(), "annotations.not.supported.in.source", source.name); allowAnnotations = true; } } void checkDiamond() { if (!allowDiamond) { - log.error(S.pos(), "diamond.not.supported.in.source", source.name); + error(S.pos(), "diamond.not.supported.in.source", source.name); allowDiamond = true; } } void checkMulticatch() { if (!allowMulticatch) { - log.error(S.pos(), "multicatch.not.supported.in.source", source.name); + error(S.pos(), "multicatch.not.supported.in.source", source.name); allowMulticatch = true; } } void checkAutomaticResourceManagement() { if (!allowTWR) { - log.error(S.pos(), "automatic.resource.management.not.supported.in.source", source.name); + error(S.pos(), "automatic.resource.management.not.supported.in.source", source.name); allowTWR = true; } } diff --git a/langtools/src/share/classes/com/sun/tools/javac/processing/JavacProcessingEnvironment.java b/langtools/src/share/classes/com/sun/tools/javac/processing/JavacProcessingEnvironment.java index 20d6fad6718..8e5884ded9b 100644 --- a/langtools/src/share/classes/com/sun/tools/javac/processing/JavacProcessingEnvironment.java +++ b/langtools/src/share/classes/com/sun/tools/javac/processing/JavacProcessingEnvironment.java @@ -939,7 +939,7 @@ public class JavacProcessingEnvironment implements ProcessingEnvironment, Closea break; case ERROR: - if (fatalErrors || !d.isFlagSet(RESOLVE_ERROR)) + if (fatalErrors || !d.isFlagSet(RECOVERABLE)) return true; break; } diff --git a/langtools/src/share/classes/com/sun/tools/javac/util/AbstractLog.java b/langtools/src/share/classes/com/sun/tools/javac/util/AbstractLog.java index 1a902a1f01d..3082024a379 100644 --- a/langtools/src/share/classes/com/sun/tools/javac/util/AbstractLog.java +++ b/langtools/src/share/classes/com/sun/tools/javac/util/AbstractLog.java @@ -30,6 +30,7 @@ import java.util.Map; import javax.tools.JavaFileObject; import com.sun.tools.javac.code.Lint.LintCategory; +import com.sun.tools.javac.util.JCDiagnostic.DiagnosticFlag; import com.sun.tools.javac.util.JCDiagnostic.DiagnosticPosition; import com.sun.tools.javac.util.JCDiagnostic.SimpleDiagnosticPosition; @@ -103,6 +104,19 @@ public abstract class AbstractLog { report(diags.error(source, wrap(pos), key, args)); } + /** Report an error, unless another error was already reported at same + * source position. + * @param flag A flag to set on the diagnostic + * @param pos The source position at which to report the error. + * @param key The key for the localized error message. + * @param args Fields of the error message. + */ + public void error(DiagnosticFlag flag, int pos, String key, Object ... args) { + JCDiagnostic d = diags.error(source, wrap(pos), key, args); + d.setFlag(flag); + report(d); + } + /** Report a warning, unless suppressed by the -nowarn option or the * maximum number of warnings has been reached. * @param pos The source position at which to report the warning. diff --git a/langtools/src/share/classes/com/sun/tools/javac/util/JCDiagnostic.java b/langtools/src/share/classes/com/sun/tools/javac/util/JCDiagnostic.java index 57146c83a39..9df3730d718 100644 --- a/langtools/src/share/classes/com/sun/tools/javac/util/JCDiagnostic.java +++ b/langtools/src/share/classes/com/sun/tools/javac/util/JCDiagnostic.java @@ -63,17 +63,23 @@ public class JCDiagnostic implements Diagnostic { DiagnosticFormatter formatter; final String prefix; + final Set defaultErrorFlags; /** Create a new diagnostic factory. */ protected Factory(Context context) { this(JavacMessages.instance(context), "compiler"); context.put(diagnosticFactoryKey, this); + + Options options = Options.instance(context); + if (options.isSet("onlySyntaxErrorsUnrecoverable")) + defaultErrorFlags.add(DiagnosticFlag.RECOVERABLE); } /** Create a new diagnostic factory. */ public Factory(JavacMessages messages, String prefix) { this.prefix = prefix; this.formatter = new BasicDiagnosticFormatter(messages); + defaultErrorFlags = EnumSet.of(DiagnosticFlag.MANDATORY); } /** @@ -85,7 +91,7 @@ public class JCDiagnostic implements Diagnostic { */ public JCDiagnostic error( DiagnosticSource source, DiagnosticPosition pos, String key, Object... args) { - return create(ERROR, null, EnumSet.of(DiagnosticFlag.MANDATORY), source, pos, key, args); + return create(ERROR, null, defaultErrorFlags, source, pos, key, args); } /** @@ -331,7 +337,9 @@ public class JCDiagnostic implements Diagnostic { public enum DiagnosticFlag { MANDATORY, - RESOLVE_ERROR + RESOLVE_ERROR, + SYNTAX, + RECOVERABLE } private final DiagnosticType type; @@ -547,6 +555,17 @@ public class JCDiagnostic implements Diagnostic { public void setFlag(DiagnosticFlag flag) { flags.add(flag); + + if (type == DiagnosticType.ERROR) { + switch (flag) { + case SYNTAX: + flags.remove(DiagnosticFlag.RECOVERABLE); + break; + case RESOLVE_ERROR: + flags.add(DiagnosticFlag.RECOVERABLE); + break; + } + } } public boolean isFlagSet(DiagnosticFlag flag) { diff --git a/langtools/test/tools/javac/processing/6994946/SemanticErrorTest.1.out b/langtools/test/tools/javac/processing/6994946/SemanticErrorTest.1.out new file mode 100644 index 00000000000..d91ade61e69 --- /dev/null +++ b/langtools/test/tools/javac/processing/6994946/SemanticErrorTest.1.out @@ -0,0 +1,2 @@ +SemanticErrorTest.java:11:46: compiler.err.repeated.interface +1 error diff --git a/langtools/test/tools/javac/processing/6994946/SemanticErrorTest.2.out b/langtools/test/tools/javac/processing/6994946/SemanticErrorTest.2.out new file mode 100644 index 00000000000..6a48a0e137b --- /dev/null +++ b/langtools/test/tools/javac/processing/6994946/SemanticErrorTest.2.out @@ -0,0 +1,4 @@ +SemanticErrorTest.java:11:46: compiler.err.repeated.interface +- compiler.err.proc.messager: Deliberate Error +SemanticErrorTest.java:11:46: compiler.err.repeated.interface +1 error diff --git a/langtools/test/tools/javac/processing/6994946/SemanticErrorTest.java b/langtools/test/tools/javac/processing/6994946/SemanticErrorTest.java new file mode 100644 index 00000000000..43a0521bba1 --- /dev/null +++ b/langtools/test/tools/javac/processing/6994946/SemanticErrorTest.java @@ -0,0 +1,13 @@ +/* + * @test /nodynamiccopyright/ + * @bug 6994946 + * @summary option to specify only syntax errors as unrecoverable + * @library ../../lib + * @build JavacTestingAbstractProcessor TestProcessor + * @compile/fail/ref=SemanticErrorTest.1.out -XDrawDiagnostics -processor TestProcessor SemanticErrorTest.java + * @compile/fail/ref=SemanticErrorTest.2.out -XDrawDiagnostics -XDonlySyntaxErrorsUnrecoverable -processor TestProcessor SemanticErrorTest.java + */ + +class SemanticErrorTest implements Runnable, Runnable { + public void run() { } +} diff --git a/langtools/test/tools/javac/processing/6994946/SyntaxErrorTest.java b/langtools/test/tools/javac/processing/6994946/SyntaxErrorTest.java new file mode 100644 index 00000000000..44d67b62775 --- /dev/null +++ b/langtools/test/tools/javac/processing/6994946/SyntaxErrorTest.java @@ -0,0 +1,13 @@ +/* + * @test /nodynamiccopyright/ + * @bug 6994946 + * @summary option to specify only syntax errors as unrecoverable + * @library ../../lib + * @build JavacTestingAbstractProcessor TestProcessor + * @compile/fail/ref=SyntaxErrorTest.out -XDrawDiagnostics -processor TestProcessor SyntaxErrorTest.java + * @compile/fail/ref=SyntaxErrorTest.out -XDrawDiagnostics -XDonlySyntaxErrorsUnrecoverable -processor TestProcessor SyntaxErrorTest.java + */ + +class SyntaxErrorTest { + int i +} diff --git a/langtools/test/tools/javac/processing/6994946/SyntaxErrorTest.out b/langtools/test/tools/javac/processing/6994946/SyntaxErrorTest.out new file mode 100644 index 00000000000..2b02bac18bc --- /dev/null +++ b/langtools/test/tools/javac/processing/6994946/SyntaxErrorTest.out @@ -0,0 +1,2 @@ +SyntaxErrorTest.java:12:10: compiler.err.expected: ';' +1 error diff --git a/langtools/test/tools/javac/processing/6994946/TestProcessor.java b/langtools/test/tools/javac/processing/6994946/TestProcessor.java new file mode 100644 index 00000000000..a6527a416d9 --- /dev/null +++ b/langtools/test/tools/javac/processing/6994946/TestProcessor.java @@ -0,0 +1,40 @@ +/* + * Copyright (c) 2010, 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. + */ + +import java.util.*; +import javax.annotation.processing.*; +import javax.lang.model.*; +import javax.lang.model.element.*; +import static javax.tools.Diagnostic.Kind.*; + +public class TestProcessor extends JavacTestingAbstractProcessor { + private int round = 0; + + public boolean process(Set annotations, + RoundEnvironment roundEnv) { + if (++round == 1) + messager.printMessage(ERROR, "Deliberate Error"); + return false; + } +} + From af760db4640bb16395e21a0fc499c3e3e625d0a1 Mon Sep 17 00:00:00 2001 From: Jonathan Gibbons Date: Fri, 29 Oct 2010 12:47:49 -0700 Subject: [PATCH 07/11] 6993304: JavacTrees.getAttrContext not updated to Tree.Kind.{ANNOTATION_TYPE,ENUM,INTERFACE} Reviewed-by: mcimadamore --- .../src/share/classes/com/sun/tools/javac/api/JavacTrees.java | 3 ++- .../classes/com/sun/tools/javac/code/TypeAnnotations.java | 3 ++- 2 files changed, 4 insertions(+), 2 deletions(-) diff --git a/langtools/src/share/classes/com/sun/tools/javac/api/JavacTrees.java b/langtools/src/share/classes/com/sun/tools/javac/api/JavacTrees.java index e1c6053b27b..a61630bf9cc 100644 --- a/langtools/src/share/classes/com/sun/tools/javac/api/JavacTrees.java +++ b/langtools/src/share/classes/com/sun/tools/javac/api/JavacTrees.java @@ -282,9 +282,10 @@ public class JavacTrees extends Trees { // System.err.println("COMP: " + ((JCCompilationUnit)tree).sourcefile); env = enter.getTopLevelEnv((JCCompilationUnit)tree); break; + case ANNOTATION_TYPE: case CLASS: - case INTERFACE: case ENUM: + case INTERFACE: // System.err.println("CLASS: " + ((JCClassDecl)tree).sym.getSimpleName()); env = enter.getClassEnv(((JCClassDecl)tree).sym); break; diff --git a/langtools/src/share/classes/com/sun/tools/javac/code/TypeAnnotations.java b/langtools/src/share/classes/com/sun/tools/javac/code/TypeAnnotations.java index 23aaed349c4..628c63851d3 100644 --- a/langtools/src/share/classes/com/sun/tools/javac/code/TypeAnnotations.java +++ b/langtools/src/share/classes/com/sun/tools/javac/code/TypeAnnotations.java @@ -113,9 +113,10 @@ public class TypeAnnotations { p.pos = frame.pos; return p; + case ANNOTATION_TYPE: case CLASS: - case INTERFACE: case ENUM: + case INTERFACE: p.pos = frame.pos; if (((JCClassDecl)frame).extending == tree) { p.type = TargetType.CLASS_EXTENDS; From 8954a44a0522fd9b19da7fb317aa1159448beb37 Mon Sep 17 00:00:00 2001 From: Jonathan Gibbons Date: Fri, 29 Oct 2010 13:12:38 -0700 Subject: [PATCH 08/11] 6994608: javah no longer accepts parameter files as input Reviewed-by: mcimadamore --- .../com/sun/tools/javah/JavahTask.java | 18 +++- .../sun/tools/javah/resources/l10n.properties | 2 + langtools/test/tools/javah/T6994608.java | 89 +++++++++++++++++++ 3 files changed, 107 insertions(+), 2 deletions(-) create mode 100644 langtools/test/tools/javah/T6994608.java diff --git a/langtools/src/share/classes/com/sun/tools/javah/JavahTask.java b/langtools/src/share/classes/com/sun/tools/javah/JavahTask.java index 51c290d027a..ebd144413ec 100644 --- a/langtools/src/share/classes/com/sun/tools/javah/JavahTask.java +++ b/langtools/src/share/classes/com/sun/tools/javah/JavahTask.java @@ -26,6 +26,7 @@ package com.sun.tools.javah; import java.io.File; +import java.io.FileNotFoundException; import java.io.IOException; import java.io.OutputStream; import java.io.PrintWriter; @@ -74,6 +75,7 @@ import javax.tools.ToolProvider; import static javax.tools.Diagnostic.Kind.*; import com.sun.tools.javac.code.Symbol.CompletionFailure; +import com.sun.tools.javac.main.CommandLine; /** * Javah generates support files for native methods. @@ -362,7 +364,7 @@ public class JavahTask implements NativeHeaderTool.NativeHeaderTask { if (fileManager == null) fileManager = getDefaultFileManager(diagnosticListener, log); - Iterator iter = args.iterator(); + Iterator iter = expandAtArgs(args).iterator(); noArgs = !iter.hasNext(); while (iter.hasNext()) { @@ -416,6 +418,18 @@ public class JavahTask implements NativeHeaderTool.NativeHeaderTask { throw new BadArgs("err.unknown.option", name).showUsage(true); } + private Iterable expandAtArgs(Iterable args) throws BadArgs { + try { + List l = new ArrayList(); + for (String arg: args) l.add(arg); + return Arrays.asList(CommandLine.parse(l.toArray(new String[l.size()]))); + } catch (FileNotFoundException e) { + throw new BadArgs("at.args.file.not.found", e.getLocalizedMessage()); + } catch (IOException e) { + throw new BadArgs("at.args.io.exception", e.getLocalizedMessage()); + } + } + public Boolean call() { return run(); } @@ -607,8 +621,8 @@ public class JavahTask implements NativeHeaderTool.NativeHeaderTask { } }; - } + private String getMessage(String key, Object... args) { return getMessage(task_locale, key, args); } diff --git a/langtools/src/share/classes/com/sun/tools/javah/resources/l10n.properties b/langtools/src/share/classes/com/sun/tools/javah/resources/l10n.properties index 297e2821146..632cd1581f9 100644 --- a/langtools/src/share/classes/com/sun/tools/javah/resources/l10n.properties +++ b/langtools/src/share/classes/com/sun/tools/javah/resources/l10n.properties @@ -30,6 +30,8 @@ cant.create.dir=\ The directory {0} could not be create for output. at.args.cant.read=\ Can''t read command line arguments from file {1}. +at.args.file.not.found=\ + Can''t find file {0}. at.args.io.exception=\ The following I/O problem was encountered when processing an @ \ argument on the command line: {0}. diff --git a/langtools/test/tools/javah/T6994608.java b/langtools/test/tools/javah/T6994608.java new file mode 100644 index 00000000000..91a9fdb74cd --- /dev/null +++ b/langtools/test/tools/javah/T6994608.java @@ -0,0 +1,89 @@ +/* + * Copyright (c) 2010, 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 6994608 + * @summary javah no longer accepts parameter files as input + */ + +import java.io.*; +import java.util.*; + +public class T6994608 { + public static void main(String... args) throws Exception { + new T6994608().run(); + } + + void run() throws Exception { + Locale prev = Locale.getDefault(); + Locale.setDefault(Locale.ENGLISH); + try { + File f = writeFile(new File("classList"), "java.lang.Object"); + test(Arrays.asList("@" + f.getPath()), 0, null); + test(Arrays.asList("@badfile"), 1, "Can't find file badfile"); + if (errors > 0) + throw new Exception(errors + " errors occurred"); + } finally { + Locale.setDefault(prev); + } + } + + void test(List args, int expectRC, String expectOut) { + System.err.println("Test: " + args + + " rc:" + expectRC + + ((expectOut != null) ? " out:" + expectOut : "")); + + StringWriter sw = new StringWriter(); + PrintWriter pw = new PrintWriter(sw); + int rc = com.sun.tools.javah.Main.run(args.toArray(new String[args.size()]), pw); + pw.close(); + String out = sw.toString(); + if (!out.isEmpty()) + System.err.println(out); + + if (rc != expectRC) + error("Unexpected exit code: " + rc + "; expected: " + expectRC); + if (expectOut != null && !out.contains(expectOut)) + error("Expected string not found: " + expectOut); + + System.err.println(); + } + + File writeFile(File f, String s) throws IOException { + if (f.getParentFile() != null) + f.getParentFile().mkdirs(); + try (FileWriter out = new FileWriter(f)) { + out.write(s); + } + return f; + } + + void error(String msg) { + System.err.println(msg); + errors++; + } + + int errors; +} + From efcecaa50a27fc0949e7e4a5f92ec049e1a3d965 Mon Sep 17 00:00:00 2001 From: Jonathan Gibbons Date: Mon, 1 Nov 2010 19:28:40 -0700 Subject: [PATCH 09/11] 6996626: Scope fix issues for ImportScope Reviewed-by: darcy --- .../com/sun/tools/javac/code/Scope.java | 121 ++++++------------ 1 file changed, 39 insertions(+), 82 deletions(-) diff --git a/langtools/src/share/classes/com/sun/tools/javac/code/Scope.java b/langtools/src/share/classes/com/sun/tools/javac/code/Scope.java index 72ffbac8916..8bbc73d84d8 100644 --- a/langtools/src/share/classes/com/sun/tools/javac/code/Scope.java +++ b/langtools/src/share/classes/com/sun/tools/javac/code/Scope.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 1999, 2010, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 1999, 2008, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -31,8 +31,7 @@ import java.util.Iterator; /** A scope represents an area of visibility in a Java program. The * Scope class is a container for symbols which provides * efficient access to symbols given their names. Scopes are implemented - * as hash tables with "open addressing" and "double hashing". - * Scopes can be nested; the next field of a scope points + * as hash tables. Scopes can be nested; the next field of a scope points * to its next outer scope. Nested scopes can share their hash tables. * *

This is NOT part of any supported API. @@ -68,7 +67,6 @@ public class Scope { public Entry elems; /** The number of elements in this scope. - * This includes deleted elements, whose value is the sentinel. */ public int nelems = 0; @@ -111,8 +109,7 @@ public class Scope { } } - /** Use as a "not-found" result for lookup. - * Also used to mark deleted entries in the table. + /** Every hash bucket is a list of Entry's which ends in sentinel. */ private static final Entry sentinel = new Entry(null, null, null, null); @@ -133,15 +130,12 @@ public class Scope { this.owner = owner; this.table = table; this.hashMask = table.length - 1; + this.elems = null; + this.nelems = 0; + this.shared = 0; this.scopeCounter = scopeCounter; } - /** Convenience constructor used for dup and dupUnshared. */ - private Scope(Scope next, Symbol owner, Entry[] table) { - this(next, owner, table, next.scopeCounter); - this.nelems = next.nelems; - } - /** Construct a new scope, within scope next, with given owner, * using a fresh table of length INITIAL_SIZE. */ @@ -151,6 +145,7 @@ public class Scope { protected Scope(Symbol owner, ScopeCounter scopeCounter) { this(null, owner, new Entry[INITIAL_SIZE], scopeCounter); + for (int i = 0; i < INITIAL_SIZE; i++) table[i] = sentinel; } /** Construct a fresh scope within this scope, with same owner, @@ -159,7 +154,11 @@ public class Scope { * of fresh tables. */ public Scope dup() { - return dup(this.owner); + Scope result = new Scope(this, this.owner, this.table, scopeCounter); + shared++; + // System.out.println("====> duping scope " + this.hashCode() + " owned by " + this.owner + " to " + result.hashCode()); + // new Error().printStackTrace(System.out); + return result; } /** Construct a fresh scope within this scope, with new owner, @@ -168,7 +167,7 @@ public class Scope { * of fresh tables. */ public Scope dup(Symbol newOwner) { - Scope result = new Scope(this, newOwner, this.table); + Scope result = new Scope(this, newOwner, this.table, scopeCounter); shared++; // System.out.println("====> duping scope " + this.hashCode() + " owned by " + newOwner + " to " + result.hashCode()); // new Error().printStackTrace(System.out); @@ -180,7 +179,7 @@ public class Scope { * the table of its outer scope. */ public Scope dupUnshared() { - return new Scope(this, this.owner, this.table.clone()); + return new Scope(this, this.owner, this.table.clone(), scopeCounter); } /** Remove all entries of this scope from its table, if shared @@ -190,7 +189,7 @@ public class Scope { assert shared == 0; if (table != next.table) return next; while (elems != null) { - int hash = getIndex(elems.sym.name); + int hash = elems.sym.name.hashCode() & hashMask; Entry e = table[hash]; assert e == elems : elems.sym; table[hash] = elems.shadowed; @@ -198,7 +197,6 @@ public class Scope { } assert next.shared > 0; next.shared--; - next.nelems = nelems; // System.out.println("====> leaving scope " + this.hashCode() + " owned by " + this.owner + " to " + next.hashCode()); // new Error().printStackTrace(System.out); return next; @@ -217,17 +215,19 @@ public class Scope { s.hashMask = newtable.length - 1; } } - int n = 0; - for (int i = oldtable.length; --i >= 0; ) { - Entry e = oldtable[i]; - if (e != null && e != sentinel) { - table[getIndex(e.sym.name)] = e; - n++; - } + for (int i = 0; i < newtable.length; i++) newtable[i] = sentinel; + for (int i = 0; i < oldtable.length; i++) copy(oldtable[i]); + } + + /** Copy the given entry and all entries shadowed by it to table + */ + private void copy(Entry e) { + if (e.sym != null) { + copy(e.shadowed); + int hash = e.sym.name.hashCode() & hashMask; + e.shadowed = table[hash]; + table[hash] = e; } - // We don't need to update nelems for shared inherited scopes, - // since that gets handled by leave(). - nelems = n; } /** Enter symbol sym in this scope. @@ -248,17 +248,13 @@ public class Scope { */ public void enter(Symbol sym, Scope s, Scope origin) { assert shared == 0; - if (nelems * 3 >= hashMask * 2) - dble(); - int hash = getIndex(sym.name); - Entry old = table[hash]; - if (old == null) { - old = sentinel; - nelems++; - } - Entry e = makeEntry(sym, old, elems, s, origin); + // Temporarily disabled (bug 6460352): + // if (nelems * 3 >= hashMask * 2) dble(); + int hash = sym.name.hashCode() & hashMask; + Entry e = makeEntry(sym, table[hash], elems, s, origin); table[hash] = e; elems = e; + nelems++; scopeCounter.inc(); } @@ -272,15 +268,15 @@ public class Scope { public void remove(Symbol sym) { assert shared == 0; Entry e = lookup(sym.name); + while (e.scope == this && e.sym != sym) e = e.next(); if (e.scope == null) return; scopeCounter.inc(); // remove e from table and shadowed list; - int i = getIndex(sym.name); - Entry te = table[i]; + Entry te = table[sym.name.hashCode() & hashMask]; if (te == e) - table[i] = e.shadowed; + table[sym.name.hashCode() & hashMask] = e.shadowed; else while (true) { if (te.shadowed == e) { te.shadowed = e.shadowed; @@ -339,50 +335,12 @@ public class Scope { return lookup(name, noFilter); } public Entry lookup(Name name, Filter sf) { - Entry e = table[getIndex(name)]; - if (e == null || e == sentinel) - return sentinel; + Entry e = table[name.hashCode() & hashMask]; while (e.scope != null && (e.sym.name != name || !sf.accepts(e.sym))) e = e.shadowed; return e; } - /*void dump (java.io.PrintStream out) { - out.println(this); - for (int l=0; l < table.length; l++) { - Entry le = table[l]; - out.print("#"+l+": "); - if (le==sentinel) out.println("sentinel"); - else if(le == null) out.println("null"); - else out.println(""+le+" s:"+le.sym); - } - }*/ - - /** Look for slot in the table. - * We use open addressing with double hashing. - */ - int getIndex (Name name) { - int h = name.hashCode(); - int i = h & hashMask; - // The expression below is always odd, so it is guaranteed - // be be mutually prime with table.length, a power of 2. - int x = hashMask - ((h + (h >> 16)) << 1); - int d = -1; // Index of a deleted item. - for (;;) { - Entry e = table[i]; - if (e == null) - return d >= 0 ? d : i; - if (e == sentinel) { - // We have to keep searching even if we see a deleted item. - // However, remember the index in case we fail to find the name. - if (d < 0) - d = i; - } else if (e.sym.name == name) - return i; - i = (i + x) & hashMask; - } - } - public Iterable getElements() { return getElements(noFilter); } @@ -512,11 +470,10 @@ public class Scope { } public Entry lookup(Name name) { - Entry e = table[getIndex(name)]; - if (e == null) - return sentinel; + Entry e = table[name.hashCode() & hashMask]; while (e.scope != null && - (/* Since an inner class will show up in package and + (e.sym.name != name || + /* Since an inner class will show up in package and * import scopes until its inner class attribute has * been processed, we have to weed it out here. This * is done by comparing the owners of the entry's From ac9f97939fad8fc68a19c1edfd96963b98f0adce Mon Sep 17 00:00:00 2001 From: Maurizio Cimadamore Date: Tue, 2 Nov 2010 12:00:54 +0000 Subject: [PATCH 10/11] 6996415: Override bridges causes compiler-generated code to end up with synthetic infinite loop Temporarily disable fix for override bridges (6337171) Reviewed-by: jjg --- .../src/share/classes/com/sun/tools/javac/comp/TransTypes.java | 3 ++- langtools/test/tools/javac/generics/OverrideBridge.java | 3 ++- 2 files changed, 4 insertions(+), 2 deletions(-) diff --git a/langtools/src/share/classes/com/sun/tools/javac/comp/TransTypes.java b/langtools/src/share/classes/com/sun/tools/javac/comp/TransTypes.java index 184ab6608aa..00727ca2c87 100644 --- a/langtools/src/share/classes/com/sun/tools/javac/comp/TransTypes.java +++ b/langtools/src/share/classes/com/sun/tools/javac/comp/TransTypes.java @@ -876,7 +876,8 @@ public class TransTypes extends TreeTranslator { make.at(tree.pos); if (addBridges) { ListBuffer bridges = new ListBuffer(); - bridges.appendList(addOverrideBridgesIfNeeded(tree, c)); + if (false) //see CR: 6996415 + bridges.appendList(addOverrideBridgesIfNeeded(tree, c)); if ((tree.sym.flags() & INTERFACE) == 0) addBridges(tree.pos(), tree.sym, bridges); tree.defs = bridges.toList().prependList(tree.defs); diff --git a/langtools/test/tools/javac/generics/OverrideBridge.java b/langtools/test/tools/javac/generics/OverrideBridge.java index 548057540c7..43c1f5e67e8 100644 --- a/langtools/test/tools/javac/generics/OverrideBridge.java +++ b/langtools/test/tools/javac/generics/OverrideBridge.java @@ -23,7 +23,8 @@ /* * @test - * @bug 6337171 + * @bug 6337171 6996415 + * @ignore fix has been disabled as a consequence of 6996415 * @summary javac should create bridge methods when type variable bounds restricted * @run main OverrideBridge */ From 9b7bc21bb0875c6b65c078bb09a53525dfaf2f18 Mon Sep 17 00:00:00 2001 From: Maurizio Cimadamore Date: Tue, 2 Nov 2010 12:01:35 +0000 Subject: [PATCH 11/11] 6939780: add a warning to detect diamond sites Added hidden compiler flag '-XDfindDiamond' to detect 'diamondifiable' sites Reviewed-by: jjg --- .../com/sun/tools/javac/comp/Attr.java | 30 +++++++++++++++++++ .../tools/javac/resources/compiler.properties | 7 +++++ .../diags/examples/DiamondRedundantArgs.java | 29 ++++++++++++++++++ .../diags/examples/DiamondRedundantArgs1.java | 29 ++++++++++++++++++ .../javac/generics/diamond/T6939780.java | 25 ++++++++++++++++ .../tools/javac/generics/diamond/T6939780.out | 5 ++++ 6 files changed, 125 insertions(+) create mode 100644 langtools/test/tools/javac/diags/examples/DiamondRedundantArgs.java create mode 100644 langtools/test/tools/javac/diags/examples/DiamondRedundantArgs1.java create mode 100644 langtools/test/tools/javac/generics/diamond/T6939780.java create mode 100644 langtools/test/tools/javac/generics/diamond/T6939780.out diff --git a/langtools/src/share/classes/com/sun/tools/javac/comp/Attr.java b/langtools/src/share/classes/com/sun/tools/javac/comp/Attr.java index e0ba0061537..610698b8fb4 100644 --- a/langtools/src/share/classes/com/sun/tools/javac/comp/Attr.java +++ b/langtools/src/share/classes/com/sun/tools/javac/comp/Attr.java @@ -121,6 +121,8 @@ public class Attr extends JCTree.Visitor { sourceName = source.name; relax = (options.isSet("-retrofit") || options.isSet("-relax")); + findDiamonds = options.get("findDiamond") != null && + source.allowDiamond(); useBeforeDeclarationWarning = options.isSet("useBeforeDeclarationWarning"); enableSunApiLintControl = options.isSet("enableSunApiLintControl"); } @@ -154,6 +156,16 @@ public class Attr extends JCTree.Visitor { */ boolean allowAnonOuterThis; + /** Switch: generates a warning if diamond can be safely applied + * to a given new expression + */ + boolean findDiamonds; + + /** + * Internally enables/disables diamond finder feature + */ + static final boolean allowDiamondFinder = true; + /** * Switch: warn about use of variable before declaration? * RFE: 6425594 @@ -1572,6 +1584,24 @@ public class Attr extends JCTree.Visitor { if (TreeInfo.isDiamond(tree)) { clazztype = attribDiamond(localEnv, tree, clazztype, mapping, argtypes, typeargtypes); clazz.type = clazztype; + } else if (allowDiamondFinder && + clazztype.getTypeArguments().nonEmpty() && + findDiamonds) { + Type inferred = attribDiamond(localEnv, + tree, + clazztype, + mapping, + argtypes, + typeargtypes); + if (!inferred.isErroneous() && + inferred.tag == CLASS && + types.isAssignable(inferred, pt.tag == NONE ? clazztype : pt, Warner.noWarnings) && + chk.checkDiamond((ClassType)inferred).isEmpty()) { + String key = types.isSameType(clazztype, inferred) ? + "diamond.redundant.args" : + "diamond.redundant.args.1"; + log.warning(tree.clazz.pos(), key, clazztype, inferred); + } } // If we have made no mistakes in the class type... diff --git a/langtools/src/share/classes/com/sun/tools/javac/resources/compiler.properties b/langtools/src/share/classes/com/sun/tools/javac/resources/compiler.properties index 7bfcc95cc86..175c69a9c7c 100644 --- a/langtools/src/share/classes/com/sun/tools/javac/resources/compiler.properties +++ b/langtools/src/share/classes/com/sun/tools/javac/resources/compiler.properties @@ -873,6 +873,13 @@ compiler.warn.raw.class.use=\ found raw type: {0}\n\ missing type parameters for generic class {1} +compiler.warn.diamond.redundant.args=\ + redundant type arguments in new expression (use diamond operator instead). +compiler.warn.diamond.redundant.args.1=\ + redundant type arguments in new expression (use diamond operator instead).\n\ + explicit: {0}\n\ + inferred: {1} + ##### ## The following are tokens which are non-terminals in the language. They should diff --git a/langtools/test/tools/javac/diags/examples/DiamondRedundantArgs.java b/langtools/test/tools/javac/diags/examples/DiamondRedundantArgs.java new file mode 100644 index 00000000000..d8502c319ce --- /dev/null +++ b/langtools/test/tools/javac/diags/examples/DiamondRedundantArgs.java @@ -0,0 +1,29 @@ +/* + * Copyright (c) 2010, 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.warn.diamond.redundant.args +// options: -XDfindDiamond + +class Foo { + Foo fs = new Foo(); +} diff --git a/langtools/test/tools/javac/diags/examples/DiamondRedundantArgs1.java b/langtools/test/tools/javac/diags/examples/DiamondRedundantArgs1.java new file mode 100644 index 00000000000..ddc8502f92f --- /dev/null +++ b/langtools/test/tools/javac/diags/examples/DiamondRedundantArgs1.java @@ -0,0 +1,29 @@ +/* + * Copyright (c) 2010, 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.warn.diamond.redundant.args.1 +// options: -XDfindDiamond + +class Foo { + Foo fs = new Foo(); +} diff --git a/langtools/test/tools/javac/generics/diamond/T6939780.java b/langtools/test/tools/javac/generics/diamond/T6939780.java new file mode 100644 index 00000000000..82020228460 --- /dev/null +++ b/langtools/test/tools/javac/generics/diamond/T6939780.java @@ -0,0 +1,25 @@ +/* + * @test /nodynamiccopyright/ + * @bug 6939780 + * + * @summary add a warning to detect diamond sites + * @author mcimadamore + * @compile/ref=T6939780.out T6939780.java -XDrawDiagnostics -XDfindDiamond + * + */ + +class T6939780 { + + void test() { + class Foo { + Foo() {} + Foo(X x) {} + } + Foo f1 = new Foo(1); + Foo f2 = new Foo(); + Foo f3 = new Foo(); + Foo f4 = new Foo(1) {}; + Foo f5 = new Foo() {}; + Foo f6 = new Foo() {}; + } +} diff --git a/langtools/test/tools/javac/generics/diamond/T6939780.out b/langtools/test/tools/javac/generics/diamond/T6939780.out new file mode 100644 index 00000000000..d3043fb70b3 --- /dev/null +++ b/langtools/test/tools/javac/generics/diamond/T6939780.out @@ -0,0 +1,5 @@ +T6939780.java:19:28: compiler.warn.diamond.redundant.args: Foo, Foo +T6939780.java:20:28: compiler.warn.diamond.redundant.args.1: Foo, Foo +T6939780.java:22:28: compiler.warn.diamond.redundant.args: Foo, Foo +T6939780.java:23:28: compiler.warn.diamond.redundant.args.1: Foo, Foo +4 warnings