diff options
author | Stephan Herrmann | 2010-04-21 22:04:13 +0000 |
---|---|---|
committer | Stephan Herrmann | 2010-04-21 22:04:13 +0000 |
commit | 0717d57fe4d108ab39a073439c314436fe5d8a9a (patch) | |
tree | 6bb18dfe49cbf07b2ae334f7f22eb243fa43e3da /org.eclipse.jdt.core.tests.compiler | |
parent | ed07f3b80ee18c1625d42f5824fe018f349aadfe (diff) | |
download | org.eclipse.objectteams-0717d57fe4d108ab39a073439c314436fe5d8a9a.tar.gz org.eclipse.objectteams-0717d57fe4d108ab39a073439c314436fe5d8a9a.tar.xz org.eclipse.objectteams-0717d57fe4d108ab39a073439c314436fe5d8a9a.zip |
update jdt.core tests to v_A45
Diffstat (limited to 'org.eclipse.jdt.core.tests.compiler')
20 files changed, 700 insertions, 216 deletions
diff --git a/org.eclipse.jdt.core.tests.compiler/META-INF/MANIFEST.MF b/org.eclipse.jdt.core.tests.compiler/META-INF/MANIFEST.MF index f772c0f66..562d95dea 100644 --- a/org.eclipse.jdt.core.tests.compiler/META-INF/MANIFEST.MF +++ b/org.eclipse.jdt.core.tests.compiler/META-INF/MANIFEST.MF @@ -21,3 +21,4 @@ Require-Bundle: org.junit;bundle-version="3.8.1", org.eclipse.core.resources;bundle-version="[3.2.0,4.0.0)", org.eclipse.objectteams.otdt Bundle-RequiredExecutionEnvironment: J2SE-1.4 +Bundle-ActivationPolicy: lazy diff --git a/org.eclipse.jdt.core.tests.compiler/src/org/eclipse/jdt/core/tests/compiler/parser/DietRecoveryTest.java b/org.eclipse.jdt.core.tests.compiler/src/org/eclipse/jdt/core/tests/compiler/parser/DietRecoveryTest.java index 6bf9cc6af..1160b9c1a 100644 --- a/org.eclipse.jdt.core.tests.compiler/src/org/eclipse/jdt/core/tests/compiler/parser/DietRecoveryTest.java +++ b/org.eclipse.jdt.core.tests.compiler/src/org/eclipse/jdt/core/tests/compiler/parser/DietRecoveryTest.java @@ -4675,8 +4675,6 @@ public void test75() { " }\n" + " A foo(int i) {\n" + " }\n" + - " clone() {\n" + - " }\n" + " int bar() {\n" + " }\n" + "}\n"; diff --git a/org.eclipse.jdt.core.tests.compiler/src/org/eclipse/jdt/core/tests/compiler/regression/AbstractRegressionTest.java b/org.eclipse.jdt.core.tests.compiler/src/org/eclipse/jdt/core/tests/compiler/regression/AbstractRegressionTest.java index 38bb9bc3a..114475a27 100644 --- a/org.eclipse.jdt.core.tests.compiler/src/org/eclipse/jdt/core/tests/compiler/regression/AbstractRegressionTest.java +++ b/org.eclipse.jdt.core.tests.compiler/src/org/eclipse/jdt/core/tests/compiler/regression/AbstractRegressionTest.java @@ -835,9 +835,9 @@ protected static class JavacTestOptions { } else if (this.complianceLevel == ClassFileConstants.JDK1_5) { buffer.append("\" -1.5"); } else if (this.complianceLevel == ClassFileConstants.JDK1_6) { - buffer.append("\" -1.6"); + buffer.append("\" -1.6 -proc:none"); } else if (this.complianceLevel == ClassFileConstants.JDK1_7) { - buffer.append("\" -1.7"); + buffer.append("\" -1.7 -proc:none"); } buffer .append(" -preserveAllLocals -nowarn -g -classpath \"") diff --git a/org.eclipse.jdt.core.tests.compiler/src/org/eclipse/jdt/core/tests/compiler/regression/AnnotationTest.java b/org.eclipse.jdt.core.tests.compiler/src/org/eclipse/jdt/core/tests/compiler/regression/AnnotationTest.java index 3d98bcf72..e4a5ff589 100644 --- a/org.eclipse.jdt.core.tests.compiler/src/org/eclipse/jdt/core/tests/compiler/regression/AnnotationTest.java +++ b/org.eclipse.jdt.core.tests.compiler/src/org/eclipse/jdt/core/tests/compiler/regression/AnnotationTest.java @@ -3640,7 +3640,7 @@ public class AnnotationTest extends AbstractComparableTest { "----------\n" + "3. WARNING in Y.java (at line 2)\n" + " void foo(){ super.foo(); }\n" + - " ^^^^^^^^^^^\n" + + " ^^^^^\n" + "The method foo() from the type X is deprecated\n" + "----------\n" + "4. ERROR in Y.java (at line 3)\n" + @@ -3677,7 +3677,7 @@ public class AnnotationTest extends AbstractComparableTest { "----------\n" + "3. WARNING in Y.java (at line 2)\n" + " void foo(){ super.foo(); }\n" + - " ^^^^^^^^^^^\n" + + " ^^^^^\n" + "The method foo() from the type X is deprecated\n" + "----------\n" + "4. ERROR in Y.java (at line 3)\n" + @@ -4041,7 +4041,7 @@ public class AnnotationTest extends AbstractComparableTest { "----------\n" + "1. WARNING in X.java (at line 7)\n" + " W.deprecated();\n" + - " ^^^^^^^^^^^^^^\n" + + " ^^^^^^^^^^^^\n" + "The method deprecated() from the type W is deprecated\n" + "----------\n" + "2. WARNING in X.java (at line 8)\n" + @@ -4281,7 +4281,7 @@ public class AnnotationTest extends AbstractComparableTest { "----------\n" + "3. WARNING in X.java (at line 8)\n" + " W.deprecated();\n" + - " ^^^^^^^^^^^^^^\n" + + " ^^^^^^^^^^^^\n" + "The method deprecated() from the type W is deprecated\n" + "----------\n" + "4. WARNING in X.java (at line 9)\n" + @@ -4549,12 +4549,12 @@ public void test142c() { "----------\n" + "2. ERROR in X.java (at line 2)\n" + " public class X extends p.OldStuff {\n" + - " ^^^^^^^^^^\n" + + " ^^^^^^^^\n" + "The type OldStuff is deprecated\n" + "----------\n" + "3. ERROR in X.java (at line 8)\n" + " super.foo();\n" + - " ^^^^^^^^^^^\n" + + " ^^^^^\n" + "The method foo() from the type OldStuff is deprecated\n" + "----------\n", JavacTestOptions.Excuse.EclipseWarningConfiguredAsError); @@ -4581,7 +4581,7 @@ public void test143() { "----------\n" + "1. WARNING in X.java (at line 1)\n" + " public class X extends p.OldStuff {\n" + - " ^^^^^^^^^^\n" + + " ^^^^^^^^\n" + "The type OldStuff is deprecated\n" + "----------\n" + "----------\n" + @@ -6029,7 +6029,7 @@ public void test143() { "----------\n" + "1. WARNING in X.java (at line 3)\n" + " Y.initialize i;\n" + - " ^^^^^^^^^^^^\n" + + " ^^^^^^^^^^\n" + "The type Y.initialize is deprecated\n" + "----------\n" + "----------\n" + diff --git a/org.eclipse.jdt.core.tests.compiler/src/org/eclipse/jdt/core/tests/compiler/regression/BatchCompilerTest.java b/org.eclipse.jdt.core.tests.compiler/src/org/eclipse/jdt/core/tests/compiler/regression/BatchCompilerTest.java index a1a34b54e..8e5dbacd1 100644 --- a/org.eclipse.jdt.core.tests.compiler/src/org/eclipse/jdt/core/tests/compiler/regression/BatchCompilerTest.java +++ b/org.eclipse.jdt.core.tests.compiler/src/org/eclipse/jdt/core/tests/compiler/regression/BatchCompilerTest.java @@ -9263,8 +9263,8 @@ public void test231_sourcepath_vs_classpath() throws IOException, InterruptedExc "----------\n" + /* expectedErrOutputString */ "1. ERROR in ---OUTPUT_DIR_PLACEHOLDER---/Y.java (at line 3)\n" + " System.out.println(X.CONST);\n" + - " ^^^^^^^\n" + - "X.CONST cannot be resolved to a variable\n" + + " ^^^^^\n" + + "CONST cannot be resolved or is not a field\n" + "----------\n" + "1 problem (1 error)", false /* shouldFlushOutputDirectory */, @@ -9506,12 +9506,12 @@ public void test235_classpath() throws IOException, InterruptedException { sourceFilePath /* commandLine */ + " -proc:none " + commonOptions, "" /* expectedOutOutputString */, - "----------\n" + /* expectedErrOutputString */ - "1. ERROR in ---OUTPUT_DIR_PLACEHOLDER---/Y.java (at line 3)\n" + - " System.out.println(X.CONST);\n" + - " ^^^^^^^\n" + - "X.CONST cannot be resolved to a variable\n" + - "----------\n" + + "----------\n" + + "1. ERROR in ---OUTPUT_DIR_PLACEHOLDER---/Y.java (at line 3)\n" + + " System.out.println(X.CONST);\n" + + " ^^^^^\n" + + "CONST cannot be resolved or is not a field\n" + + "----------\n" + "1 problem (1 error)", false /* shouldFlushOutputDirectory */, null /* progress */); @@ -9788,61 +9788,61 @@ public void test240_jar_ref_in_jar(){ public void test241_jar_ref_in_jar(){ createCascadedJars(); this.runNegativeTest( - new String[] { - "src/p/X.java", - "package p;\n" + - "/** */\n" + - "public class X {\n" + - " int i = R.R2;\n" + - " int j = R.R3;\n" + - "}", - }, - "\"" + OUTPUT_DIR + File.separator + "src/p/X.java\"" + new String[] { + "src/p/X.java", + "package p;\n" + + "/** */\n" + + "public class X {\n" + + " int i = R.R2;\n" + + " int j = R.R3;\n" + + "}", + }, + "\"" + OUTPUT_DIR + File.separator + "src/p/X.java\"" + " -cp \"" + LIB_DIR + File.separator + "lib1.jar\"" + " -cp \"" + LIB_DIR + File.separator + "lib3.jar\"" + " -sourcepath \"" + OUTPUT_DIR + File.separator + "src\"" - + " -1.5 -g -preserveAllLocals" - + " -proceedOnError -referenceInfo" - + " -d \"" + OUTPUT_DIR + File.separator + "bin\" ", - "", - "----------\n" + - "1. ERROR in ---OUTPUT_DIR_PLACEHOLDER---/src/p/X.java (at line 5)\n" + - " int j = R.R3;\n" + - " ^^^^\n" + - "R.R3 cannot be resolved to a variable\n" + - "----------\n" + - "1 problem (1 error)", - true); + + " -1.5 -g -preserveAllLocals" + + " -proceedOnError -referenceInfo" + + " -d \"" + OUTPUT_DIR + File.separator + "bin\" ", + "", + "----------\n" + + "1. ERROR in ---OUTPUT_DIR_PLACEHOLDER---/src/p/X.java (at line 5)\n" + + " int j = R.R3;\n" + + " ^^\n" + + "R3 cannot be resolved or is not a field\n" + + "----------\n" + + "1 problem (1 error)", + true); } // https://bugs.eclipse.org/bugs/show_bug.cgi?id=97332 - jars pointed by jars // using only links, we adopt a depth first algorithm public void test242_jar_ref_in_jar(){ createCascadedJars(); this.runNegativeTest( - new String[] { - "src/p/X.java", - "package p;\n" + - "/** */\n" + - "public class X {\n" + - " int i = R.R2;\n" + - " int j = R.R3;\n" + - "}", - }, - "\"" + OUTPUT_DIR + File.separator + "src/p/X.java\"" + new String[] { + "src/p/X.java", + "package p;\n" + + "/** */\n" + + "public class X {\n" + + " int i = R.R2;\n" + + " int j = R.R3;\n" + + "}", + }, + "\"" + OUTPUT_DIR + File.separator + "src/p/X.java\"" + " -cp \"" + LIB_DIR + File.separator + "lib4.jar\"" + " -sourcepath \"" + OUTPUT_DIR + File.separator + "src\"" - + " -1.5 -g -preserveAllLocals" - + " -proceedOnError -referenceInfo" - + " -d \"" + OUTPUT_DIR + File.separator + "bin\" ", - "", - "----------\n" + - "1. ERROR in ---OUTPUT_DIR_PLACEHOLDER---/src/p/X.java (at line 5)\n" + - " int j = R.R3;\n" + - " ^^^^\n" + - "R.R3 cannot be resolved to a variable\n" + - "----------\n" + - "1 problem (1 error)", - true); + + " -1.5 -g -preserveAllLocals" + + " -proceedOnError -referenceInfo" + + " -d \"" + OUTPUT_DIR + File.separator + "bin\" ", + "", + "----------\n" + + "1. ERROR in ---OUTPUT_DIR_PLACEHOLDER---/src/p/X.java (at line 5)\n" + + " int j = R.R3;\n" + + " ^^\n" + + "R3 cannot be resolved or is not a field\n" + + "----------\n" + + "1 problem (1 error)", + true); } // https://bugs.eclipse.org/bugs/show_bug.cgi?id=97332 - jars pointed by jars // managing subdirectories and .. properly diff --git a/org.eclipse.jdt.core.tests.compiler/src/org/eclipse/jdt/core/tests/compiler/regression/Deprecated15Test.java b/org.eclipse.jdt.core.tests.compiler/src/org/eclipse/jdt/core/tests/compiler/regression/Deprecated15Test.java index 035a64efd..9f20e9e3a 100644 --- a/org.eclipse.jdt.core.tests.compiler/src/org/eclipse/jdt/core/tests/compiler/regression/Deprecated15Test.java +++ b/org.eclipse.jdt.core.tests.compiler/src/org/eclipse/jdt/core/tests/compiler/regression/Deprecated15Test.java @@ -13,10 +13,10 @@ package org.eclipse.jdt.core.tests.compiler.regression; import java.util.HashMap; import java.util.Map; -import org.eclipse.jdt.internal.compiler.impl.CompilerOptions; - import junit.framework.Test; +import org.eclipse.jdt.internal.compiler.impl.CompilerOptions; + public class Deprecated15Test extends AbstractRegressionTest { public Deprecated15Test(String name) { super(name); @@ -84,22 +84,22 @@ public void test001() { "7. WARNING in Y.java (at line 9)\n" + " p.X x;\n" + " ^^^\n" + - "The type X is deprecated\n" + + "X is a raw type. References to generic type X<T> should be parameterized\n" + "----------\n" + "8. WARNING in Y.java (at line 9)\n" + " p.X x;\n" + - " ^^^\n" + - "X is a raw type. References to generic type X<T> should be parameterized\n" + + " ^\n" + + "The type X<T> is deprecated\n" + "----------\n" + "9. WARNING in Y.java (at line 10)\n" + " p.X[] xs = { x };\n" + " ^^^\n" + - "The type X is deprecated\n" + + "X is a raw type. References to generic type X<T> should be parameterized\n" + "----------\n" + "10. WARNING in Y.java (at line 10)\n" + " p.X[] xs = { x };\n" + - " ^^^\n" + - "X is a raw type. References to generic type X<T> should be parameterized\n" + + " ^\n" + + "The type X<T> is deprecated\n" + "----------\n", null, true, @@ -138,17 +138,17 @@ public void test002() { "----------\n" + "1. ERROR in p\\M1.java (at line 4)\n" + " a.N1.N2.N3 m = null;\n" + - " ^^^^^^^\n" + + " ^^\n" + "The type N1.N2 is deprecated\n" + "----------\n" + "2. ERROR in p\\M1.java (at line 4)\n" + " a.N1.N2.N3 m = null;\n" + - " ^^^^^^^^^^\n" + + " ^^\n" + "The type N1.N2.N3 is deprecated\n" + "----------\n" + "3. ERROR in p\\M1.java (at line 5)\n" + " m.foo();\n" + - " ^^^^^^^\n" + + " ^^^^^\n" + "The method foo() from the type N1.N2.N3 is deprecated\n" + "----------\n", JavacTestOptions.Excuse.EclipseWarningConfiguredAsError); diff --git a/org.eclipse.jdt.core.tests.compiler/src/org/eclipse/jdt/core/tests/compiler/regression/DeprecatedTest.java b/org.eclipse.jdt.core.tests.compiler/src/org/eclipse/jdt/core/tests/compiler/regression/DeprecatedTest.java index 20e42fedb..44a09da14 100644 --- a/org.eclipse.jdt.core.tests.compiler/src/org/eclipse/jdt/core/tests/compiler/regression/DeprecatedTest.java +++ b/org.eclipse.jdt.core.tests.compiler/src/org/eclipse/jdt/core/tests/compiler/regression/DeprecatedTest.java @@ -164,7 +164,7 @@ public void test004() { "----------\n" + "2. WARNING in p\\Warning.java (at line 7)\n" + " dateObj.UTC(1,2,3,4,5,6);\n" + - " ^^^^^^^^^^^^^^^^^^^^^^^^\n" + + " ^^^^^^^^^^^^^^^^\n" + "The method UTC(int, int, int, int, int, int) from the type Date is deprecated\n" + "----------\n"); } @@ -197,7 +197,7 @@ public void test005() { "----------\n" + "1. WARNING in A.java (at line 1)\n" + " public class A extends X.Y {}\n" + - " ^^^\n" + + " ^\n" + "The type X.Y is deprecated\n" + "----------\n",// expected output null, @@ -549,12 +549,12 @@ public void test014() { "----------\n" + "5. WARNING in Y.java (at line 9)\n" + " p.X x;\n" + - " ^^^\n" + + " ^\n" + "The type X is deprecated\n" + "----------\n" + "6. WARNING in Y.java (at line 10)\n" + " p.X[] xs = { x };\n" + - " ^^^\n" + + " ^\n" + "The type X is deprecated\n" + "----------\n"); } @@ -594,17 +594,17 @@ public void test015() { "----------\n" + /* expected compiler log */ "1. ERROR in p\\M1.java (at line 4)\n" + " a.N1.N2.N3 m = null;\n" + - " ^^^^^^^\n" + + " ^^\n" + "The type N1.N2 is deprecated\n" + "----------\n" + "2. ERROR in p\\M1.java (at line 4)\n" + " a.N1.N2.N3 m = null;\n" + - " ^^^^^^^^^^\n" + + " ^^\n" + "The type N1.N2.N3 is deprecated\n" + "----------\n" + "3. ERROR in p\\M1.java (at line 5)\n" + " m.foo();\n" + - " ^^^^^^^\n" + + " ^^^^^\n" + "The method foo() from the type N1.N2.N3 is deprecated\n" + "----------\n", // javac options @@ -646,17 +646,17 @@ public void test016() { "----------\n" + /* expected compiler log */ "1. ERROR in p\\M1.java (at line 4)\n" + " a.N1.N2.N3 m = null;\n" + - " ^^^^^^^\n" + + " ^^\n" + "The type N1.N2 is deprecated\n" + "----------\n" + "2. ERROR in p\\M1.java (at line 4)\n" + " a.N1.N2.N3 m = null;\n" + - " ^^^^^^^^^^\n" + + " ^^\n" + "The type N1.N2.N3 is deprecated\n" + "----------\n" + "3. ERROR in p\\M1.java (at line 5)\n" + " m.foo();\n" + - " ^^^^^^^\n" + + " ^^^^^\n" + "The method foo() from the type N1.N2.N3 is deprecated\n" + "----------\n", // javac options @@ -742,17 +742,17 @@ public void test018() { "----------\n" + /* expected compiler log */ "1. ERROR in p\\M1.java (at line 4)\n" + " a.N1.N2.N3 m = null;\n" + - " ^^^^^^^\n" + + " ^^\n" + "The type N1.N2 is deprecated\n" + "----------\n" + "2. ERROR in p\\M1.java (at line 4)\n" + " a.N1.N2.N3 m = null;\n" + - " ^^^^^^^^^^\n" + + " ^^\n" + "The type N1.N2.N3 is deprecated\n" + "----------\n" + "3. ERROR in p\\M1.java (at line 5)\n" + " m.foo();\n" + - " ^^^^^^^\n" + + " ^^^^^\n" + "The method foo() from the type N1.N2.N3 is deprecated\n" + "----------\n", // javac options @@ -799,6 +799,81 @@ public void test019() { // javac options JavacTestOptions.Excuse.EclipseWarningConfiguredAsError /* javac test options */); } +// https://bugs.eclipse.org/bugs/show_bug.cgi?id=300031 +public void test020() { + Map customOptions = new HashMap(); + customOptions.put(CompilerOptions.OPTION_ReportDeprecation, CompilerOptions.ERROR); + runNegativeTest( + // test directory preparation + true /* flush output directory */, + new String[] { /* test files */ + "a.b.c.d/Deprecated.java", + "package a.b.c.d;\n" + + "public class Deprecated {\n" + + " /** @deprecated */\n" + + " public class Inner {\n" + + " /** @deprecated */\n" + + " public class Inn {\n" + + " }\n" + + " }\n" + + " /** @deprecated */\n" + + " public Deprecated foo(){ return null;}\n" + + " /** @deprecated */\n" + + " public Deprecated goo(){ return null;}\n" + + " /** @deprecated */\n" + + " public static Deprecated bar(){ return null;}\n" + + "}\n", + "a.b.c.d.e/T.java", + "package a.b.c.d.e;\n" + + "import a.b.c.d.Deprecated;\n" + + "public class T {\n" + + " a.b.c.d.Deprecated f;\n" + + " a.b.c.d.Deprecated.Inner.Inn g;\n" + + " Deprecated.Inner i;\n" + + " public void m() {\n" + + " f.foo().goo();\n" + + " a.b.c.d.Deprecated.bar();\n" + + " }\n" + + "}" + }, + // compiler options + null /* no class libraries */, + customOptions /* custom options */, + // compiler results + "----------\n" + /* expected compiler log */ + "1. ERROR in a.b.c.d.e\\T.java (at line 5)\n" + + " a.b.c.d.Deprecated.Inner.Inn g;\n" + + " ^^^^^\n" + + "The type Deprecated.Inner is deprecated\n" + + "----------\n" + + "2. ERROR in a.b.c.d.e\\T.java (at line 5)\n" + + " a.b.c.d.Deprecated.Inner.Inn g;\n" + + " ^^^\n" + + "The type Deprecated.Inner.Inn is deprecated\n" + + "----------\n" + + "3. ERROR in a.b.c.d.e\\T.java (at line 6)\n" + + " Deprecated.Inner i;\n" + + " ^^^^^\n" + + "The type Deprecated.Inner is deprecated\n" + + "----------\n" + + "4. ERROR in a.b.c.d.e\\T.java (at line 8)\n" + + " f.foo().goo();\n" + + " ^^^^^\n" + + "The method foo() from the type Deprecated is deprecated\n" + + "----------\n" + + "5. ERROR in a.b.c.d.e\\T.java (at line 8)\n" + + " f.foo().goo();\n" + + " ^^^^^\n" + + "The method goo() from the type Deprecated is deprecated\n" + + "----------\n" + + "6. ERROR in a.b.c.d.e\\T.java (at line 9)\n" + + " a.b.c.d.Deprecated.bar();\n" + + " ^^^^^\n" + + "The method bar() from the type Deprecated is deprecated\n" + + "----------\n", + // javac options + JavacTestOptions.Excuse.EclipseWarningConfiguredAsError /* javac test options */); +} public static Class testClass() { return DeprecatedTest.class; } diff --git a/org.eclipse.jdt.core.tests.compiler/src/org/eclipse/jdt/core/tests/compiler/regression/ExternalizeStringLiterals15Test.java b/org.eclipse.jdt.core.tests.compiler/src/org/eclipse/jdt/core/tests/compiler/regression/ExternalizeStringLiterals15Test.java index 6da24bdd1..07288e850 100644 --- a/org.eclipse.jdt.core.tests.compiler/src/org/eclipse/jdt/core/tests/compiler/regression/ExternalizeStringLiterals15Test.java +++ b/org.eclipse.jdt.core.tests.compiler/src/org/eclipse/jdt/core/tests/compiler/regression/ExternalizeStringLiterals15Test.java @@ -21,7 +21,7 @@ public class ExternalizeStringLiterals15Test extends AbstractRegressionTest { static { // TESTS_NAMES = new String[] { "test000" }; -// TESTS_NUMBERS = new int[] { 6 }; +// TESTS_NUMBERS = new int[] { 7 }; // TESTS_RANGE = new int[] { 11, -1 }; } public ExternalizeStringLiterals15Test(String name) { @@ -41,14 +41,14 @@ public void test001() { "import static java.lang.annotation.RetentionPolicy.*;\n" + "import java.lang.annotation.Retention;\n" + "import java.lang.annotation.Target;\n" + - "@Target({TYPE, FIELD, METHOD,\r\n" + - " PARAMETER, CONSTRUCTOR,\r\n" + - " LOCAL_VARIABLE, PACKAGE})\r\n" + - "@Retention(CLASS)\r\n" + - "public @interface X\r\n" + - "{\r\n" + - " String[] value() default {};\r\n" + - " String justification() default \"\";\r\n" + + "@Target({TYPE, FIELD, METHOD,\n" + + " PARAMETER, CONSTRUCTOR,\n" + + " LOCAL_VARIABLE, PACKAGE})\n" + + "@Retention(CLASS)\n" + + "public @interface X\n" + + "{\n" + + " String[] value() default {};\n" + + " String justification() default \"\";\n" + "}" }, "", @@ -222,6 +222,53 @@ public void test006() { customOptions, null); } +//https://bugs.eclipse.org/bugs/show_bug.cgi?id=237245 +public void test007() { + Map customOptions = getCompilerOptions(); + customOptions.put(CompilerOptions.OPTION_ReportNonExternalizedStringLiteral, CompilerOptions.ERROR); + this.runNegativeTest( + new String[] { + "X.java", + "public class X {\n" + + " @Annot({\n" + + " @A(name = \"name\", //$NON-NLS-1$\n" + + " value = \"Test\") //$NON-NLS-1$\n" + + " })\n" + + " @X2(\"\") //$NON-NLS-1$\n" + + " void foo() {\n" + + " }\n" + + "}\n" + + "@interface Annot {\n" + + " A[] value();\n" + + "}\n" + + "@interface A {\n" + + " String name();\n" + + " String value();\n" + + "}\n" + + "@interface X2 {\n" + + " String value();\n" + + "}", + }, + "----------\n" + + "1. ERROR in X.java (at line 3)\n" + + " @A(name = \"name\", //$NON-NLS-1$\n" + + " ^^^^^^^^^^^^^\n" + + "Unnecessary $NON-NLS$ tag\n" + + "----------\n" + + "2. ERROR in X.java (at line 4)\n" + + " value = \"Test\") //$NON-NLS-1$\n" + + " ^^^^^^^^^^^^^\n" + + "Unnecessary $NON-NLS$ tag\n" + + "----------\n" + + "3. ERROR in X.java (at line 6)\n" + + " @X2(\"\") //$NON-NLS-1$\n" + + " ^^^^^^^^^^^^^\n" + + "Unnecessary $NON-NLS$ tag\n" + + "----------\n", + null, + true, + customOptions); +} public static Class testClass() { return ExternalizeStringLiterals15Test.class; } diff --git a/org.eclipse.jdt.core.tests.compiler/src/org/eclipse/jdt/core/tests/compiler/regression/FieldAccessTest.java b/org.eclipse.jdt.core.tests.compiler/src/org/eclipse/jdt/core/tests/compiler/regression/FieldAccessTest.java index 29e331575..af08bb125 100644 --- a/org.eclipse.jdt.core.tests.compiler/src/org/eclipse/jdt/core/tests/compiler/regression/FieldAccessTest.java +++ b/org.eclipse.jdt.core.tests.compiler/src/org/eclipse/jdt/core/tests/compiler/regression/FieldAccessTest.java @@ -19,7 +19,7 @@ import org.eclipse.jdt.internal.compiler.impl.CompilerOptions; public class FieldAccessTest extends AbstractRegressionTest { static { // TESTS_NAMES = new String[] { "test000" }; -// TESTS_NUMBERS = new int[] { 21 }; +// TESTS_NUMBERS = new int[] { 22 }; // TESTS_RANGE = new int[] { 21, 50 }; } @@ -649,6 +649,36 @@ public void test021() { true, options); } +//https://bugs.eclipse.org/bugs/show_bug.cgi?id=303830 +public void test022() { + this.runNegativeTest( + new String[] { + "X.java", + "public class X {\n" + + " static int NEW_FIELD;\n" + + "}", + "Y.java", + "public class Y {\n" + + " void foo() {\n" + + " int i = X.OLD_FIELD;\n" + + " }\n" + + " void bar() {\n" + + " int j = X.OLD_FIELD;\n" + + " }\n" + + "}" + }, + "----------\n" + + "1. ERROR in Y.java (at line 3)\n" + + " int i = X.OLD_FIELD;\n" + + " ^^^^^^^^^\n" + + "OLD_FIELD cannot be resolved or is not a field\n" + + "----------\n" + + "2. ERROR in Y.java (at line 6)\n" + + " int j = X.OLD_FIELD;\n" + + " ^^^^^^^^^\n" + + "OLD_FIELD cannot be resolved or is not a field\n" + + "----------\n"); +} public static Class testClass() { return FieldAccessTest.class; } 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 df86df560..8c3d179cd 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 @@ -31,8 +31,8 @@ public class GenericTypeTest extends AbstractComparableTest { // Static initializer to specify tests subset using TESTS_* static variables // All specified tests which does not belong to the class are skipped... static { -// TESTS_NAMES = new String[] { "test0788" }; -// TESTS_NUMBERS = new int[] { 1455 }; +// TESTS_NAMES = new String[] { "test1245" }; +// TESTS_NUMBERS = new int[] { 1460 }; // TESTS_RANGE = new int[] { 1097, -1 }; } public static Test suite() { @@ -5326,11 +5326,6 @@ public class GenericTypeTest extends AbstractComparableTest { " } else if (t instanceof T) {\n" + " ^^^^^^^^^^^^^^\n" + "Cannot perform instanceof check against type parameter T. Use instead its erasure Object instead since further generic type information will be erased at runtime\n" + - "----------\n" + - "4. WARNING in X.java (at line 12)\n" + - " } else if (t instanceof X) {\n" + - " ^\n" + - "X is a raw type. References to generic type X<T> should be parameterized\n" + "----------\n", null, true, @@ -26650,42 +26645,37 @@ public void test0830() { "}\n", }, "----------\n" + - "1. WARNING in X.java (at line 4)\n" + - " boolean b = o instanceof X;\n" + - " ^\n" + - "X is a raw type. References to generic type X<T> should be parameterized\n" + - "----------\n" + - "2. WARNING in X.java (at line 5)\n" + + "1. WARNING in X.java (at line 5)\n" + " X x = (X) o;\n" + " ^\n" + "X is a raw type. References to generic type X<T> should be parameterized\n" + "----------\n" + - "3. WARNING in X.java (at line 5)\n" + + "2. WARNING in X.java (at line 5)\n" + " X x = (X) o;\n" + " ^\n" + "X is a raw type. References to generic type X<T> should be parameterized\n" + "----------\n" + - "4. WARNING in X.java (at line 6)\n" + + "3. WARNING in X.java (at line 6)\n" + " X<String> xs = (X<String>)o;\n" + " ^^^^^^^^^^^^\n" + "Type safety: Unchecked cast from Object to X<String>\n" + "----------\n" + - "5. ERROR in X.java (at line 7)\n" + + "4. ERROR in X.java (at line 7)\n" + " Zork z;\n" + " ^^^^\n" + "Zork cannot be resolved to a type\n" + "----------\n" + - "6. WARNING in X.java (at line 10)\n" + + "5. WARNING in X.java (at line 10)\n" + " List l = (List) al;\n" + " ^^^^\n" + "List is a raw type. References to generic type List<E> should be parameterized\n" + "----------\n" + - "7. WARNING in X.java (at line 10)\n" + + "6. WARNING in X.java (at line 10)\n" + " List l = (List) al;\n" + " ^^^^^^^^^\n" + "Unnecessary cast from ArrayList<String> to List\n" + "----------\n" + - "8. WARNING in X.java (at line 10)\n" + + "7. WARNING in X.java (at line 10)\n" + " List l = (List) al;\n" + " ^^^^\n" + "List is a raw type. References to generic type List<E> should be parameterized\n" + @@ -42629,6 +42619,11 @@ public void test1245() { " public class X<T extends Secondary.Private> {\n" + " ^^^^^^^^^^^^^^^^^\n" + "The type Secondary.Private is not visible\n" + + "----------\n" + + "2. WARNING in X.java (at line 4)\n" + + " static private class Private {}\n" + + " ^^^^^^^\n" + + "The type Secondary.Private is never used locally\n" + "----------\n"); } //https://bugs.eclipse.org/bugs/show_bug.cgi?id=216100 - variation @@ -47863,12 +47858,7 @@ public void test1398() throws Exception { "}\n", }, "----------\n" + - "1. WARNING in A.java (at line 3)\n" + - " boolean b=null instanceof A; \n" + - " ^\n" + - "A is a raw type. References to generic type A<T> should be parameterized\n" + - "----------\n" + - "2. ERROR in A.java (at line 4)\n" + + "1. ERROR in A.java (at line 4)\n" + " Zork z;\n" + " ^^^^\n" + "Zork cannot be resolved to a type\n" + @@ -50155,4 +50145,31 @@ public void test268798a() { "Type safety: Unchecked invocation someMethod() of the generic method someMethod() of type Bug268798\n" + "----------\n"); } +//https://bugs.eclipse.org/bugs/show_bug.cgi?id=307885 +public void test1460() { + this.runNegativeTest( + new String[] { + "Test.java", + "class Test<A> {\n" + + " interface MyInt<K> {\n" + + " K getKey();\n" + + " }\n" + + " class MyEntry implements MyInt<A> {\n" + + " public A getKey() { return null; }\n" + + " @Override\n" + + " public boolean equals(Object o) {\n" + + " if(!(o instanceof MyEntry))\n" + + " return false;\n" + + " return true;\n" + + " }\n" + + " }\n" + + "}" + }, + "----------\n" + + "1. ERROR in Test.java (at line 9)\n" + + " if(!(o instanceof MyEntry))\n" + + " ^^^^^^^^^^^^^^^^^^^^^^\n" + + "Cannot perform instanceof check against parameterized type Test<A>.MyEntry. Use the form Test.MyEntry instead since further generic type information will be erased at runtime\n" + + "----------\n"); +} }
\ No newline at end of file diff --git a/org.eclipse.jdt.core.tests.compiler/src/org/eclipse/jdt/core/tests/compiler/regression/InnerEmulationTest.java b/org.eclipse.jdt.core.tests.compiler/src/org/eclipse/jdt/core/tests/compiler/regression/InnerEmulationTest.java index a8adfa082..2569b3ef7 100644 --- a/org.eclipse.jdt.core.tests.compiler/src/org/eclipse/jdt/core/tests/compiler/regression/InnerEmulationTest.java +++ b/org.eclipse.jdt.core.tests.compiler/src/org/eclipse/jdt/core/tests/compiler/regression/InnerEmulationTest.java @@ -25,7 +25,7 @@ import org.eclipse.jdt.internal.compiler.impl.CompilerOptions; public class InnerEmulationTest extends AbstractRegressionTest { static { // TESTS_NAMES = new String[] { "Bug58069" }; -// TESTS_NUMBERS = new int[] { 23, 24 }; + TESTS_NUMBERS = new int[] { 173, 174 }; // TESTS_RANGE = new int[] { 144, -1 }; } public InnerEmulationTest(String name) { @@ -5491,12 +5491,12 @@ public void test135() { "----------\n" + "3. WARNING in p\\X.java (at line 6)\n" + " A.M2.MM1 mm1 = (A.M2.MM1) o;\n" + - " ^^^^\n" + + " ^^\n" + "The type A.M2 is deprecated\n" + "----------\n" + "4. WARNING in p\\X.java (at line 6)\n" + " A.M2.MM1 mm1 = (A.M2.MM1) o;\n" + - " ^^^^^^^^\n" + + " ^^^\n" + "The type A.M1.MM1 is deprecated\n" + "----------\n" + "5. WARNING in p\\X.java (at line 6)\n" + @@ -5506,12 +5506,12 @@ public void test135() { "----------\n" + "6. WARNING in p\\X.java (at line 6)\n" + " A.M2.MM1 mm1 = (A.M2.MM1) o;\n" + - " ^^^^\n" + + " ^^\n" + "The type A.M2 is deprecated\n" + "----------\n" + "7. WARNING in p\\X.java (at line 6)\n" + " A.M2.MM1 mm1 = (A.M2.MM1) o;\n" + - " ^^^^^^^^\n" + + " ^^^\n" + "The type A.M1.MM1 is deprecated\n" + "----------\n" + "8. WARNING in p\\X.java (at line 7)\n" + @@ -5521,12 +5521,12 @@ public void test135() { "----------\n" + "9. WARNING in p\\X.java (at line 7)\n" + " A.M2.MM1[] mm1s = (A.M2.MM1[]) os;\n" + - " ^^^^\n" + + " ^^\n" + "The type A.M2 is deprecated\n" + "----------\n" + "10. WARNING in p\\X.java (at line 7)\n" + " A.M2.MM1[] mm1s = (A.M2.MM1[]) os;\n" + - " ^^^^^^^^\n" + + " ^^^\n" + "The type A.M1.MM1 is deprecated\n" + "----------\n" + "11. WARNING in p\\X.java (at line 7)\n" + @@ -5536,12 +5536,12 @@ public void test135() { "----------\n" + "12. WARNING in p\\X.java (at line 7)\n" + " A.M2.MM1[] mm1s = (A.M2.MM1[]) os;\n" + - " ^^^^\n" + + " ^^\n" + "The type A.M2 is deprecated\n" + "----------\n" + "13. WARNING in p\\X.java (at line 7)\n" + " A.M2.MM1[] mm1s = (A.M2.MM1[]) os;\n" + - " ^^^^^^^^\n" + + " ^^^\n" + "The type A.M1.MM1 is deprecated\n" + "----------\n" + "14. ERROR in p\\X.java (at line 16)\n" + @@ -7065,6 +7065,60 @@ public void test172() throws Exception { "----------\n" ); } +//https://bugs.eclipse.org/bugs/show_bug.cgi?id=308245 +public void test173() throws Exception { + this.runConformTest( + new String[] { + "X.java",//======================= + "import java.util.ArrayList;\n" + + "import java.util.Comparator;\n" + + "import java.util.List;\n" + + "public class X {\n" + + " public static void main(String[] args) {\n" + + " final List yourList = new ArrayList();\n" + + " final List myList = new ArrayList();\n" + + " new Comparator() {\n" + + " public int compare(Object o1, Object o2) {\n" + + " compare(yourList != null ? yourList : myList, yourList);\n" + + " return 0;\n" + + " }\n" + + " };\n" + + " System.out.println(\"SUCCESS\");\n" + + " }\n" + + "}", + }, + "SUCCESS"); +} +//https://bugs.eclipse.org/bugs/show_bug.cgi?id=308245 +public void test174() throws Exception { + this.runConformTest( + new String[] { + "X.java",//======================= + "import java.util.Comparator;\n" + + "public class X {\n" + + " public static class MyList {\n" + + " int size;\n" + + " }\n" + + " public static void main(String[] args) {\n" + + " final MyList yourList = new MyList();\n" + + " final MyList myList = new MyList();\n" + + " new Comparator() {\n" + + " public int compare(Object o1, Object o2) {\n" + + " return compare((MyList) o1, (MyList) o2);\n" + + " }\n" + + " public int compare(MyList o1, MyList o2) {\n" + + " return foo(yourList != null ? yourList.size : myList.size, yourList.size);\n" + + " }\n" + + " private int foo(int i, int j) {\n" + + " return i - j;\n" + + " }\n" + + " };\n" + + " System.out.println(\"SUCCESS\");\n" + + " }\n" + + "}", + }, + "SUCCESS"); +} public static Class testClass() { return InnerEmulationTest.class; } diff --git a/org.eclipse.jdt.core.tests.compiler/src/org/eclipse/jdt/core/tests/compiler/regression/JavadocBugsTest.java b/org.eclipse.jdt.core.tests.compiler/src/org/eclipse/jdt/core/tests/compiler/regression/JavadocBugsTest.java index 6234f5a4f..1686c4337 100644 --- a/org.eclipse.jdt.core.tests.compiler/src/org/eclipse/jdt/core/tests/compiler/regression/JavadocBugsTest.java +++ b/org.eclipse.jdt.core.tests.compiler/src/org/eclipse/jdt/core/tests/compiler/regression/JavadocBugsTest.java @@ -3386,7 +3386,7 @@ public void testBug74369deprecated() { "----------\n" + "1. ERROR in X.java (at line 12)\n" + " new Y().bar();\n" + - " ^^^^^^^^^^^^^\n" + + " ^^^^^\n" + "The method bar() from the type Y is deprecated\n" + "----------\n", JavacTestOptions.Excuse.EclipseWarningConfiguredAsError diff --git a/org.eclipse.jdt.core.tests.compiler/src/org/eclipse/jdt/core/tests/compiler/regression/JavadocTestForConstructor.java b/org.eclipse.jdt.core.tests.compiler/src/org/eclipse/jdt/core/tests/compiler/regression/JavadocTestForConstructor.java index c61f03eba..3a429a0f9 100644 --- a/org.eclipse.jdt.core.tests.compiler/src/org/eclipse/jdt/core/tests/compiler/regression/JavadocTestForConstructor.java +++ b/org.eclipse.jdt.core.tests.compiler/src/org/eclipse/jdt/core/tests/compiler/regression/JavadocTestForConstructor.java @@ -1,5 +1,5 @@ /******************************************************************************* - * Copyright (c) 2000, 2008 IBM Corporation and others. + * Copyright (c) 2000, 2010 IBM Corporation and others. * All rights reserved. This program and the accompanying materials * are made available under the terms of the Eclipse Public License v1.0 * which accompanies this distribution, and is available at @@ -66,7 +66,7 @@ public class JavadocTestForConstructor extends JavadocTest { "----------\n" + "1. WARNING in X.java (at line 4)\n" + " new Z();\n" - + " ^^^^^^^\n" + + " ^^^\n" + "The constructor Z() is deprecated\n" + "----------\n", null, null, JavacTestOptions.Excuse.EclipseHasSomeMoreWarnings); @@ -100,7 +100,7 @@ public class JavadocTestForConstructor extends JavadocTest { "----------\n" + "1. WARNING in X.java (at line 4)\n" + " new Z(2);\n" - + " ^^^^^^^^\n" + + " ^^^^\n" + "The constructor Z(int) is deprecated\n" + "----------\n"); } @@ -135,7 +135,7 @@ public class JavadocTestForConstructor extends JavadocTest { "----------\n" + "1. WARNING in X.java (at line 4)\n" + " new Z();\n" - + " ^^^^^^^\n" + + " ^^^\n" + "The constructor Z() is deprecated\n" + "----------\n" + "----------\n" diff --git a/org.eclipse.jdt.core.tests.compiler/src/org/eclipse/jdt/core/tests/compiler/regression/JavadocTestForInterface.java b/org.eclipse.jdt.core.tests.compiler/src/org/eclipse/jdt/core/tests/compiler/regression/JavadocTestForInterface.java index 0a6b637c8..96e9f2eee 100644 --- a/org.eclipse.jdt.core.tests.compiler/src/org/eclipse/jdt/core/tests/compiler/regression/JavadocTestForInterface.java +++ b/org.eclipse.jdt.core.tests.compiler/src/org/eclipse/jdt/core/tests/compiler/regression/JavadocTestForInterface.java @@ -1,5 +1,5 @@ /******************************************************************************* - * Copyright (c) 2000, 2008 IBM Corporation and others. + * Copyright (c) 2000, 2010 IBM Corporation and others. * All rights reserved. This program and the accompanying materials * are made available under the terms of the Eclipse Public License v1.0 * which accompanies this distribution, and is available at @@ -983,7 +983,7 @@ public class JavadocTestForInterface extends JavadocTest { "----------\n" + "1. WARNING in X.java (at line 3)\n" + " x.foo();\n" - + " ^^^^^^^\n" + + " ^^^^^\n" + "The method foo() from the type IX is deprecated\n" + "----------\n", null, null, JavacTestOptions.Excuse.EclipseHasSomeMoreWarnings); @@ -1075,7 +1075,7 @@ public class JavadocTestForInterface extends JavadocTest { "----------\n" + "1. WARNING in X.java (at line 4)\n" + " x.foo(2);\n" - + " ^^^^^^^^\n" + + " ^^^^^^\n" + "The method foo(int) from the type IX is deprecated\n" + "----------\n"); } @@ -1109,7 +1109,7 @@ public class JavadocTestForInterface extends JavadocTest { "----------\n" + "1. WARNING in X.java (at line 4)\n" + " x.foo(2);\n" - + " ^^^^^^^^\n" + + " ^^^^^^\n" + "The method foo(int) from the type IX is deprecated\n" + "----------\n" + "----------\n" diff --git a/org.eclipse.jdt.core.tests.compiler/src/org/eclipse/jdt/core/tests/compiler/regression/JavadocTestForMethod.java b/org.eclipse.jdt.core.tests.compiler/src/org/eclipse/jdt/core/tests/compiler/regression/JavadocTestForMethod.java index ad353162f..f49b4f68d 100644 --- a/org.eclipse.jdt.core.tests.compiler/src/org/eclipse/jdt/core/tests/compiler/regression/JavadocTestForMethod.java +++ b/org.eclipse.jdt.core.tests.compiler/src/org/eclipse/jdt/core/tests/compiler/regression/JavadocTestForMethod.java @@ -1,5 +1,5 @@ /******************************************************************************* - * Copyright (c) 2000, 2008 IBM Corporation and others. + * Copyright (c) 2000, 2010 IBM Corporation and others. * All rights reserved. This program and the accompanying materials * are made available under the terms of the Eclipse Public License v1.0 * which accompanies this distribution, and is available at @@ -76,7 +76,7 @@ public class JavadocTestForMethod extends JavadocTest { "----------\n" + "1. WARNING in X.java (at line 4)\n" + " new Z().foo();\n" - + " ^^^^^^^^^^^^^\n" + + " ^^^^^\n" + "The method foo() from the type Z is deprecated\n" + "----------\n", null, null, JavacTestOptions.Excuse.EclipseHasSomeMoreWarnings); @@ -173,7 +173,7 @@ public class JavadocTestForMethod extends JavadocTest { "----------\n" + "1. WARNING in X.java (at line 4)\n" + " new Z().foo(2);\n" + - " ^^^^^^^^^^^^^^\n" + + " ^^^^^^\n" + "The method foo(int) from the type Z is deprecated\n" + "----------\n" ); @@ -210,7 +210,7 @@ public class JavadocTestForMethod extends JavadocTest { "----------\n" + "1. WARNING in X.java (at line 4)\n" + " new Z().foo(2);\n" + - " ^^^^^^^^^^^^^^\n" + + " ^^^^^^\n" + "The method foo(int) from the type Z is deprecated\n" + "----------\n" + "----------\n" + @@ -278,7 +278,7 @@ public class JavadocTestForMethod extends JavadocTest { "----------\n" + "1. WARNING in X.java (at line 4)\n" + " new Z().foo(2);\n" + - " ^^^^^^^^^^^^^^\n" + + " ^^^^^^\n" + "The method foo(int) from the type Z is deprecated\n" + "----------\n" ); @@ -316,7 +316,7 @@ public class JavadocTestForMethod extends JavadocTest { "----------\n" + "1. WARNING in X.java (at line 4)\n" + " new Z().foo(2);\n" + - " ^^^^^^^^^^^^^^\n" + + " ^^^^^^\n" + "The method foo(int) from the type Z is deprecated\n" + "----------\n" + "----------\n" + @@ -384,7 +384,7 @@ public class JavadocTestForMethod extends JavadocTest { "----------\n" + "1. WARNING in X.java (at line 4)\n" + " new Z().foo(2);\n" + - " ^^^^^^^^^^^^^^\n" + + " ^^^^^^\n" + "The method foo(int) from the type Z is deprecated\n" + "----------\n" ); @@ -421,7 +421,7 @@ public class JavadocTestForMethod extends JavadocTest { "----------\n" + "1. WARNING in X.java (at line 4)\n" + " new Z().foo(2);\n" + - " ^^^^^^^^^^^^^^\n" + + " ^^^^^^\n" + "The method foo(int) from the type Z is deprecated\n" + "----------\n" + "----------\n" + diff --git a/org.eclipse.jdt.core.tests.compiler/src/org/eclipse/jdt/core/tests/compiler/regression/MethodVerifyTest.java b/org.eclipse.jdt.core.tests.compiler/src/org/eclipse/jdt/core/tests/compiler/regression/MethodVerifyTest.java index 08116c580..2c81d7ff0 100644 --- a/org.eclipse.jdt.core.tests.compiler/src/org/eclipse/jdt/core/tests/compiler/regression/MethodVerifyTest.java +++ b/org.eclipse.jdt.core.tests.compiler/src/org/eclipse/jdt/core/tests/compiler/regression/MethodVerifyTest.java @@ -10832,4 +10832,79 @@ public void test207() { }, "class java.lang.Object"); } +// https://bugs.eclipse.org/bugs/show_bug.cgi?id=288658, make sure a bridge method +// is generated when a public method is inherited from a non-public class into a +// public class. +public void test208() { + this.runConformTest( + new String[] { + "Test.java", + "import java.lang.annotation.Annotation;\n"+ + "import java.lang.annotation.Retention;\n"+ + "import java.lang.annotation.RetentionPolicy;\n"+ + "import java.lang.reflect.Method;\n"+ + "\n"+ + "public class Test extends Super {\n"+ + " public static void main(String[] args) {\n"+ + " try {\n"+ + " Method m = Test.class.getMethod(\"setFoo\", String.class);\n"+ + " Annotation a = m.getAnnotation(Anno.class);\n"+ + " System.out.println(\"Annotation was \" + (a == null ? \"not \" : \"\") +\n"+ + "\"found\");\n"+ + " } catch (Exception e) {\n"+ + " e.printStackTrace();\n"+ + " }\n"+ + " }\n"+ + "}\n"+ + "\n"+ + "class Super {\n"+ + " @Anno\n"+ + " public void setFoo(String foo) {}\n"+ + "}\n"+ + "\n"+ + "@Retention(RetentionPolicy.RUNTIME)\n"+ + "@interface Anno {\n"+ + "\n"+ + "}\n" + }, + this.complianceLevel <= ClassFileConstants.JDK1_5 ? "Annotation was found" : "Annotation was not found"); +} +// https://bugs.eclipse.org/bugs/show_bug.cgi?id=288658, make sure a bridge method +// is generated when a public method is inherited from a non-public class into a +// public class. +public void test208a() { + this.runConformTest( + new String[] { + "Test.java", + "import java.lang.annotation.Annotation;\n"+ + "import java.lang.annotation.Retention;\n"+ + "import java.lang.annotation.RetentionPolicy;\n"+ + "import java.lang.reflect.Method;\n"+ + "\n"+ + "public class Test extends Super {\n"+ + " public void setFoo() {}\n" + + " public static void main(String[] args) {\n"+ + " try {\n"+ + " Method m = Test.class.getMethod(\"setFoo\", String.class);\n"+ + " Annotation a = m.getAnnotation(Anno.class);\n"+ + " System.out.println(\"Annotation was \" + (a == null ? \"not \" : \"\") +\n"+ + "\"found\");\n"+ + " } catch (Exception e) {\n"+ + " e.printStackTrace();\n"+ + " }\n"+ + " }\n"+ + "}\n"+ + "\n"+ + "class Super {\n"+ + " @Anno\n"+ + " public void setFoo(String foo) {}\n"+ + "}\n"+ + "\n"+ + "@Retention(RetentionPolicy.RUNTIME)\n"+ + "@interface Anno {\n"+ + "\n"+ + "}\n" + }, + this.complianceLevel <= ClassFileConstants.JDK1_5 ? "Annotation was found" : "Annotation was not found"); +} } diff --git a/org.eclipse.jdt.core.tests.compiler/src/org/eclipse/jdt/core/tests/compiler/regression/NullReferenceTest.java b/org.eclipse.jdt.core.tests.compiler/src/org/eclipse/jdt/core/tests/compiler/regression/NullReferenceTest.java index 33247b296..c18c349cb 100644 --- a/org.eclipse.jdt.core.tests.compiler/src/org/eclipse/jdt/core/tests/compiler/regression/NullReferenceTest.java +++ b/org.eclipse.jdt.core.tests.compiler/src/org/eclipse/jdt/core/tests/compiler/regression/NullReferenceTest.java @@ -11636,4 +11636,30 @@ public void testBug304416() throws Exception { " 12 return\n"; checkDisassembledClassFile(OUTPUT_DIR + File.separator + "X.class", "X", expectedOutput); } + +// https://bugs.eclipse.org/bugs/show_bug.cgi?id=305590 +// To verify that a "instanceof always yields false" warning is not elicited in the +// case when the expression has been assigned a non null value in the instanceof check. +public void testBug305590() { + runNegativeTest( + new String[] { + "X.java", + "public class X {\n" + + " public void foo() {\n" + + " Object str = null;\n" + + " if ((str = \"str\") instanceof String) {}\n" + // shouldn't warn + " str = null;\n" + + " if ((str = \"str\") instanceof Number) {}\n" + // shouldn't warn + " str = null;\n" + + " if (str instanceof String) {}\n" + // should warn + " }\n" + + "}"}, + "----------\n" + + "1. ERROR in X.java (at line 8)\n" + + " if (str instanceof String) {}\n" + + " ^^^\n" + + "instanceof always yields false: The variable str can only be null at this location\n" + + "----------\n", + JavacTestOptions.Excuse.EclipseWarningConfiguredAsError); +} }
\ No newline at end of file diff --git a/org.eclipse.jdt.core.tests.compiler/src/org/eclipse/jdt/core/tests/compiler/regression/ProblemTypeAndMethodTest.java b/org.eclipse.jdt.core.tests.compiler/src/org/eclipse/jdt/core/tests/compiler/regression/ProblemTypeAndMethodTest.java index 1c3937e3e..af7f856d4 100644 --- a/org.eclipse.jdt.core.tests.compiler/src/org/eclipse/jdt/core/tests/compiler/regression/ProblemTypeAndMethodTest.java +++ b/org.eclipse.jdt.core.tests.compiler/src/org/eclipse/jdt/core/tests/compiler/regression/ProblemTypeAndMethodTest.java @@ -3359,7 +3359,12 @@ public void test073() { " ^\n" + "The type Foo.Private is not visible\n" + "----------\n" + - "3. WARNING in X.java (at line 13)\n" + + "3. WARNING in X.java (at line 12)\n" + + " private class Private {\n" + + " ^^^^^^^\n" + + "The type Foo.Private is never used locally\n" + + "----------\n" + + "4. WARNING in X.java (at line 13)\n" + " private void foo(){}\n" + " ^^^^^\n" + "The method foo() from the type Foo.Private is never used locally\n" + diff --git a/org.eclipse.jdt.core.tests.compiler/src/org/eclipse/jdt/core/tests/compiler/regression/RuntimeTests.java b/org.eclipse.jdt.core.tests.compiler/src/org/eclipse/jdt/core/tests/compiler/regression/RuntimeTests.java index a9e9e4498..8388a9382 100644 --- a/org.eclipse.jdt.core.tests.compiler/src/org/eclipse/jdt/core/tests/compiler/regression/RuntimeTests.java +++ b/org.eclipse.jdt.core.tests.compiler/src/org/eclipse/jdt/core/tests/compiler/regression/RuntimeTests.java @@ -176,8 +176,7 @@ public void test0600_reflection() { " }\n" + "}\n"}, "", - "SUCCESS\n" + - "FAILURE: IllegalAccessException", + this.complianceLevel <= ClassFileConstants.JDK1_5 ? "SUCCESS\n" + "FAILURE: IllegalAccessException" : "SUCCESS\n" + "SUCCESS", "", JavacTestOptions.EclipseJustification.EclipseBug126712 ); diff --git a/org.eclipse.jdt.core.tests.compiler/src/org/eclipse/jdt/core/tests/compiler/regression/StaticImportTest.java b/org.eclipse.jdt.core.tests.compiler/src/org/eclipse/jdt/core/tests/compiler/regression/StaticImportTest.java index 0b4c1d548..a62206db1 100644 --- a/org.eclipse.jdt.core.tests.compiler/src/org/eclipse/jdt/core/tests/compiler/regression/StaticImportTest.java +++ b/org.eclipse.jdt.core.tests.compiler/src/org/eclipse/jdt/core/tests/compiler/regression/StaticImportTest.java @@ -18,8 +18,8 @@ public class StaticImportTest extends AbstractComparableTest { // All specified tests which do not belong to the class are skipped... static { // TESTS_NAMES = new String[] { "test036" }; -// TESTS_NUMBERS = new int[] { 46 }; -// TESTS_RANGE = new int[] { 169, 180 }; +// TESTS_NUMBERS = new int[] { 79 }; +// TESTS_RANGE = new int[] { 75, -1 }; } public StaticImportTest(String name) { @@ -488,46 +488,46 @@ public class StaticImportTest extends AbstractComparableTest { " public static class WW { public static final int WWW = 0; }\n" + "}\n", }, - "----------\n" + - "1. ERROR in X.java (at line 6)\r\n" + - " import static p.Y.Zz;\r\n" + - " ^^^^^^\n" + - "The import p.Y.Zz cannot be resolved\n" + - "----------\n" + - "2. ERROR in X.java (at line 7)\r\n" + - " import static p.Z.Zz.WW.*;\r\n" + - " ^^^^^^^^^\n" + - "The import p.Z.Zz.WW cannot be resolved\n" + - "----------\n" + - "3. ERROR in X.java (at line 8)\r\n" + - " import p.Y.ZZ;\r\n" + - " ^^^^^^\n" + - "The import p.Y.ZZ cannot be resolved\n" + - "----------\n" + - "4. ERROR in X.java (at line 9)\r\n" + - " import static p.Y.ZZ.*;\r\n" + - " ^^^^^^\n" + - "The import p.Y.ZZ cannot be resolved\n" + - "----------\n" + - "5. ERROR in X.java (at line 10)\r\n" + - " import static p.Y.ZZ.WW;\r\n" + - " ^^^^^^\n" + - "The import p.Y.ZZ cannot be resolved\n" + - "----------\n" + - "6. ERROR in X.java (at line 11)\r\n" + - " import static p.Y.ZZ.WW.*;\r\n" + - " ^^^^^^\n" + - "The import p.Y.ZZ cannot be resolved\n" + - "----------\n" + - "7. ERROR in X.java (at line 12)\r\n" + - " import static p.Y.ZZ.ZZZ;\r\n" + - " ^^^^^^\n" + - "The import p.Y.ZZ cannot be resolved\n" + - "----------\n" + - "8. ERROR in X.java (at line 13)\r\n" + - " import static p.Y.ZZ.WW.WWW;\r\n" + - " ^^^^^^\n" + - "The import p.Y.ZZ cannot be resolved\n" + + "----------\n" + + "1. ERROR in X.java (at line 6)\n" + + " import static p.Y.Zz;\n" + + " ^^^^^^\n" + + "The import p.Y.Zz cannot be resolved\n" + + "----------\n" + + "2. ERROR in X.java (at line 7)\n" + + " import static p.Z.Zz.WW.*;\n" + + " ^^^^^^^^^\n" + + "The import p.Z.Zz.WW cannot be resolved\n" + + "----------\n" + + "3. ERROR in X.java (at line 8)\n" + + " import p.Y.ZZ;\n" + + " ^^^^^^\n" + + "The import p.Y.ZZ cannot be resolved\n" + + "----------\n" + + "4. ERROR in X.java (at line 9)\n" + + " import static p.Y.ZZ.*;\n" + + " ^^^^^^\n" + + "The import p.Y.ZZ cannot be resolved\n" + + "----------\n" + + "5. ERROR in X.java (at line 10)\n" + + " import static p.Y.ZZ.WW;\n" + + " ^^^^^^\n" + + "The import p.Y.ZZ cannot be resolved\n" + + "----------\n" + + "6. ERROR in X.java (at line 11)\n" + + " import static p.Y.ZZ.WW.*;\n" + + " ^^^^^^\n" + + "The import p.Y.ZZ cannot be resolved\n" + + "----------\n" + + "7. ERROR in X.java (at line 12)\n" + + " import static p.Y.ZZ.ZZZ;\n" + + " ^^^^^^\n" + + "The import p.Y.ZZ cannot be resolved\n" + + "----------\n" + + "8. ERROR in X.java (at line 13)\n" + + " import static p.Y.ZZ.WW.WWW;\n" + + " ^^^^^^\n" + + "The import p.Y.ZZ cannot be resolved\n" + "----------\n" ); } @@ -590,8 +590,8 @@ public class StaticImportTest extends AbstractComparableTest { "public class X {}\n" }, "----------\n" + - "1. ERROR in X.java (at line 1)\r\n" + - " import static java.lang.*;\r\n" + + "1. ERROR in X.java (at line 1)\n" + + " import static java.lang.*;\n" + " ^^^^^^^^^\n" + "Only a type can be imported. java.lang resolves to a package\n" + "----------\n" @@ -887,8 +887,8 @@ public class StaticImportTest extends AbstractComparableTest { "public class C { public static void m() {} }\n" }, "----------\n" + - "1. ERROR in p\\B.java (at line 5)\r\n" + - " public class B { public static void main(String[] args) { m(); } }\r\n" + + "1. ERROR in p\\B.java (at line 5)\n" + + " public class B { public static void main(String[] args) { m(); } }\n" + " ^\n" + "The method m() is ambiguous for the type B\n" + "----------\n" @@ -1154,8 +1154,8 @@ public class StaticImportTest extends AbstractComparableTest { "}\n" }, "----------\n" + - "1. ERROR in X2.java (at line 3)\r\n" + - " public class X2 { void test() {foo();} }\r\n" + + "1. ERROR in X2.java (at line 3)\n" + + " public class X2 { void test() {foo();} }\n" + " ^^^\n" + "The method foo() is ambiguous for the type X2\n" + "----------\n" @@ -1313,8 +1313,8 @@ public class StaticImportTest extends AbstractComparableTest { "}\n" }, "----------\n" + - "1. ERROR in C.java (at line 6)\r\n" + - " void test() { foo(1); }\r\n" + + "1. ERROR in C.java (at line 6)\n" + + " void test() { foo(1); }\n" + " ^^^\n" + "The method foo(Object, String) in the type A.B is not applicable for the arguments (int)\n" + "----------\n"); @@ -1464,18 +1464,18 @@ public class StaticImportTest extends AbstractComparableTest { "class B { public static int foo_B() { return 2;} }", }, "----------\n" + - "1. ERROR in X.java (at line 1)\r\n" + - " import static p.A.foo_I;\r\n" + + "1. ERROR in X.java (at line 1)\n" + + " import static p.A.foo_I;\n" + " ^^^^^^^^^\n" + "The import p.A.foo_I cannot be resolved\n" + "----------\n" + - "2. ERROR in X.java (at line 4)\r\n" + - " static int i = p.A.foo_I();\r\n" + + "2. ERROR in X.java (at line 4)\n" + + " static int i = p.A.foo_I();\n" + " ^^^^^^^^^^^\n" + "Cannot make a static reference to the non-static method foo_I() from the type I\n" + "----------\n" + - "3. ERROR in X.java (at line 6)\r\n" + - " static int m = foo_I();\r\n" + + "3. ERROR in X.java (at line 6)\n" + + " static int m = foo_I();\n" + " ^^^^^\n" + "The method foo_I() is undefined for the type X\n" + "----------\n"); @@ -1567,8 +1567,8 @@ public class StaticImportTest extends AbstractComparableTest { "}\n", }, "----------\n" + - "1. ERROR in ImportTest.java (at line 4)\r\n" + - " static void printArgs(Object... args) { toString2(args); }\r\n" + + "1. ERROR in ImportTest.java (at line 4)\n" + + " static void printArgs(Object... args) { toString2(args); }\n" + " ^^^^^^^^^\n" + "The method toString2() in the type SuperTest is not applicable for the arguments (Object[])\n" + "----------\n" @@ -1715,8 +1715,8 @@ public class StaticImportTest extends AbstractComparableTest { "public class Three extends Two { public static void test(String s) { arrayList(s); } }\n", }, "----------\n" + - "1. ERROR in test\\Three.java (at line 3)\r\n" + - " public class Three extends Two { public static void test(String s) { arrayList(s); } }\r\n" + + "1. ERROR in test\\Three.java (at line 3)\n" + + " public class Three extends Two { public static void test(String s) { arrayList(s); } }\n" + " ^^^^^^^^^\n" + "The method arrayList(int) in the type Two is not applicable for the arguments (String)\n" + "----------\n" @@ -2221,8 +2221,8 @@ public class StaticImportTest extends AbstractComparableTest { "}\n", }, "----------\n" + - "1. ERROR in p\\X.java (at line 2)\r\n" + - " import static q.A.a;\r\n" + + "1. ERROR in p\\X.java (at line 2)\n" + + " import static q.A.a;\n" + " ^^^^^\n" + "The import q.A.a cannot be resolved\n" + "----------\n"); @@ -2358,8 +2358,8 @@ public class StaticImportTest extends AbstractComparableTest { "}", }, "----------\n" + - "1. ERROR in X.java (at line 1)\r\n" + - " import static p.I.E.C;\r\n" + + "1. ERROR in X.java (at line 1)\n" + + " import static p.I.E.C;\n" + " ^^^^^^^\n" + "The import p.I.E.C cannot be resolved\n" + "----------\n"); @@ -2533,5 +2533,162 @@ public class StaticImportTest extends AbstractComparableTest { }, ""); } + // https://bugs.eclipse.org/bugs/show_bug.cgi?id=302865 + // To verify that a static import importing a type which has already been + // imported by a single type import is reported as duplicate + // while the other static members imported by it are not shadowed. + public void test075() { + this.runNegativeTest( + new String[] { + "A/A.java", + "package A;\n" + + "import B.B.C1;\n" + + "import static B.B.C1;\n" + + "public abstract class A {\n" + + " protected void A1(Object task) {\n" + + " C1 c = C1(task);\n" + + " }\n" + + "}\n", + "B/B.java", + "package B;\n" + + "final public class B {\n" + + " private B() {}\n" + + " public static class C1 {}\n" + + " public static C1 C1(Object o) {\n" + + " return new C1();\n" + + " }\n" + + "}\n", + }, + "----------\n" + + "1. ERROR in A\\A.java (at line 3)\n" + + " import static B.B.C1;\n" + + " ^^^^^^\n" + + "The import B.B.C1 collides with another import statement\n" + + "----------\n" + ); + } + // https://bugs.eclipse.org/bugs/show_bug.cgi?id=302865 + // To verify that a static import importing a static method doesn't collide + // with a single type import importing a non-static type with the same name as the method + public void test076() { + this.runConformTest( + new String[] { + "A/A.java", + "package A;\n" + + "import B.B.C1;\n" + + "import static B.B.C1;\n" + + "public class A {\n" + + " protected void A1(Object task) {\n" + + " C1 c1;\n" + + " int c = C1(task);\n" + + " }\n" + + "}\n", + "B/B.java", + "package B;\n" + + "final public class B {\n" + + " private B() {}\n" + + " public class C1 {}\n" + + " public static int C1(Object o) {\n" + + " return 1;\n" + + " }\n" + + "}\n", + }, + ""); + } + // https://bugs.eclipse.org/bugs/show_bug.cgi?id=302865 + // To verify that two static imports importing the same type don't collide + public void test077() { + this.runConformTest( + new String[] { + "p1/X.java", + "package p1;\n" + + "import p2.A;\n" + + "import static p2.A.C;\n" + + "import static p1.B.C;\n" + + "public class X {\n" + + " public static void main(String[] args) {\n" + + " foo();\n" + + " }\n" + + " public static void foo() {\n" + + " if (C.CONST == 1) {\n" + + " System.out.println(\"SUCCESS\");\n" + + " return;\n" + + " }\n" + + " System.out.println(\"FAILED\");\n" + + " }\n" + + "}\n" + + "class B extends A {}", + "p2/A.java", + "package p2;\n" + + "public class A {\n" + + " public static class C {\n" + + " public static int CONST = 1;\n" + + " }\n" + + "}" + }, + "SUCCESS"); + } + // https://bugs.eclipse.org/bugs/show_bug.cgi?id=302865 + // To verify that a static import importing a type which has already been + // imported by a single type import is reported as duplicate + // while the other static members imported by it are not shadowed. + public void test078() { + this.runNegativeTest( + new String[] { + "A/A.java", + "package A;\n" + + "import static B.B.C1;\n" + + "import B.B.C1;\n" + + "public abstract class A {\n" + + " protected void A1(Object task) {\n" + + " C1 c = C1(task);\n" + + " }\n" + + "}\n", + "B/B.java", + "package B;\n" + + "final public class B {\n" + + " private B() {}\n" + + " public static class C1 {}\n" + + " public static C1 C1(Object o) {\n" + + " return new C1();\n" + + " }\n" + + "}\n", + }, + "----------\n" + + "1. ERROR in A\\A.java (at line 3)\n" + + " import B.B.C1;\n" + + " ^^^^^^\n" + + "The import B.B.C1 collides with another import statement\n" + + "----------\n" + ); + } + // https://bugs.eclipse.org/bugs/show_bug.cgi?id=302865 + // To verify that a static import importing a type which has already been + // imported by a single type import is reported as duplicate + public void test079() { + this.runNegativeTest( + new String[] { + "A/A.java", + "package A;\n" + + "import static B.B.C1;\n" + + "import B.B.C1;\n" + + "public abstract class A {\n" + + " protected void A1(C1 c) {\n" + + " }\n" + + "}\n", + "B/B.java", + "package B;\n" + + "final public class B {\n" + + " public static class C1 {}\n" + + "}\n", + }, + "----------\n" + + "1. ERROR in A\\A.java (at line 3)\n" + + " import B.B.C1;\n" + + " ^^^^^^\n" + + "The import B.B.C1 collides with another import statement\n" + + "----------\n" + ); + } } |