From b38c9e37927a5708f610bef4d6a255ce71a53468 Mon Sep 17 00:00:00 2001 From: Stephan Herrmann Date: Tue, 26 Mar 2019 20:07:24 +0100 Subject: Bug 541772 - In Eclipse 2018-09, Maven "runtime" scoped dependencies cause compilation errors even when not used - make test even meaner and implementation even safer Change-Id: I1c0db4a74ff39f946d28290b7e4fff2fb619b1db --- .../tests/compiler/regression/GenericTypeTest.java | 88 ++++++++++++++++++++++ 1 file changed, 88 insertions(+) (limited to 'org.eclipse.jdt.core.tests.compiler/src') diff --git a/org.eclipse.jdt.core.tests.compiler/src/org/eclipse/jdt/core/tests/compiler/regression/GenericTypeTest.java b/org.eclipse.jdt.core.tests.compiler/src/org/eclipse/jdt/core/tests/compiler/regression/GenericTypeTest.java index 6a2b6438dc..20da9ff124 100644 --- a/org.eclipse.jdt.core.tests.compiler/src/org/eclipse/jdt/core/tests/compiler/regression/GenericTypeTest.java +++ b/org.eclipse.jdt.core.tests.compiler/src/org/eclipse/jdt/core/tests/compiler/regression/GenericTypeTest.java @@ -52498,4 +52498,92 @@ public void testBug541772() { getCompilerOptions(), null /*customRequestor*/); } +public void testBug541772_typeannotations() { + if (this.complianceLevel < ClassFileConstants.JDK1_8) { + return; + } + runConformTest( + new String[] { + "bug541772Runtime/GeneratedMessage.java", + "package bug541772Runtime;\n" + + "\n" + + "public class GeneratedMessage {\n" + + " public class Builder {\n" + + " }\n" + + "}\n" + + "", + }, + "", + getCompilerOptions() + ); + + runConformTest( + new String[] { + "token/Ann.java", + "package token;\n" + + "import java.lang.annotation.*;\n" + + "@Target(ElementType.TYPE_USE)\n" + + "@Retention(RetentionPolicy.CLASS)\n" + + "@interface Ann {}\n", + "token/Token.java", + "package token;\n" + + "\n" + + "public class Token {\n" + + " \n" + + " public Token() {\n" + + " }\n" + + "\n" + + " public Token(TokenProto tokenPB) {\n" + + " tokenPB.hashCode();\n" + + " }\n" + + " public Token(String x) {\n" + + " x.hashCode();\n" + + " }\n" + + "}\n" + + "", + "token/TokenProto.java", + "package token;\n" + + "\n" + + "import bug541772Runtime.GeneratedMessage;\n" + + "\n" + + "public class TokenProto {\n" + + "\n" + + " public TokenProto(GeneratedMessage.@Ann Builder builder) {\n" + + " builder.hashCode();\n" + + " }\n" + + "}\n" + + "", + }, + "", + null /*classLibraries*/, + false /*shouldFlushOutputDirectory*/, + null /*vmArguments*/, + getCompilerOptions(), + null /*customRequestor*/); + + Util.flushDirectoryContent(new File(OUTPUT_DIR + File.separator + "bug541772Runtime")); + + Map compilerOptions = getCompilerOptions(); + compilerOptions.put(JavaCore.COMPILER_ANNOTATION_NULL_ANALYSIS, JavaCore.ENABLED); + runConformTest( + new String[] { + "pkg/Example.java", + "package pkg;\n" + + "\n" + + "import token.Token;\n" + + "\n" + + "public abstract class Example {\n" + + " public static void setConnectorInfo() {\n" + + " new Token(\"\");\n" + + " }\n" + + "}\n" + + "", + }, + "", + null /*classLibraries*/, + false /*shouldFlushOutputDirectory*/, + null /*vmArguments*/, + compilerOptions, + null /*customRequestor*/); +} } -- cgit v1.2.3