Skip to main content
aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorSasikanth Bharadwaj2016-11-24 09:14:33 +0000
committerSasikanth Bharadwaj2016-11-24 09:39:39 +0000
commit30f7fbb7f1e3845d31ba25b4ce8dc4eb4bcb844e (patch)
tree36fc3a0319df998009ac0f2e5521a1e898635125
parent5ae7fcda5c081ce33e4d54b7d9de9f963e3c03bf (diff)
downloadeclipse.jdt.core-30f7fbb7f1e3845d31ba25b4ce8dc4eb4bcb844e.tar.gz
eclipse.jdt.core-30f7fbb7f1e3845d31ba25b4ce8dc4eb4bcb844e.tar.xz
eclipse.jdt.core-30f7fbb7f1e3845d31ba25b4ce8dc4eb4bcb844e.zip
Bug 488663 - Adjust error messages in tests to fix failures when runY20161124-1000
-rw-r--r--org.eclipse.jdt.core.tests.compiler/src/org/eclipse/jdt/core/tests/compiler/regression/GenericsRegressionTest.java68
-rw-r--r--org.eclipse.jdt.core.tests.compiler/src/org/eclipse/jdt/core/tests/compiler/regression/GenericsRegressionTest_1_7.java42
-rw-r--r--org.eclipse.jdt.core.tests.compiler/src/org/eclipse/jdt/core/tests/compiler/regression/GenericsRegressionTest_1_8.java19
3 files changed, 94 insertions, 35 deletions
diff --git a/org.eclipse.jdt.core.tests.compiler/src/org/eclipse/jdt/core/tests/compiler/regression/GenericsRegressionTest.java b/org.eclipse.jdt.core.tests.compiler/src/org/eclipse/jdt/core/tests/compiler/regression/GenericsRegressionTest.java
index 9110ec6697..3a7c006723 100644
--- a/org.eclipse.jdt.core.tests.compiler/src/org/eclipse/jdt/core/tests/compiler/regression/GenericsRegressionTest.java
+++ b/org.eclipse.jdt.core.tests.compiler/src/org/eclipse/jdt/core/tests/compiler/regression/GenericsRegressionTest.java
@@ -2063,6 +2063,21 @@ public void test339478n() {
"----------\n");
}
public void test339478o() {
+ String log_18 =
+ "----------\n" +
+ "1. ERROR in X.java (at line 3)\n" +
+ " new X<>(){\n" +
+ " ^\n" +
+ "\'<>\' cannot be used with anonymous classes\n" +
+ "----------\n";
+ String log_9 =
+ "----------\n" +
+ "1. ERROR in X.java (at line 4)\n" +
+ " void newMethod(){\n" +
+ " ^^^^^^^^^^^\n" +
+ "The method newMethod() of type new X<Object>(){} must override or implement a supertype method\n" +
+ "----------\n";
+ String errorMsg = this.complianceLevel < ClassFileConstants.JDK9 ? log_18 : log_9;
this.runNegativeTest(
new String[] {
"X.java",
@@ -2090,14 +2105,42 @@ public void test339478o() {
" ^\n" +
"\'<>\' cannot be used with anonymous classes\n" +
"----------\n":
- "----------\n" +
- "1. ERROR in X.java (at line 3)\n" +
- " new X<>(){\n" +
- " ^\n" +
- "\'<>\' cannot be used with anonymous classes\n" +
- "----------\n");
+ errorMsg);
}
public void test339478p() {
+ String log_18 =
+ "----------\n" +
+ "1. WARNING in X.java (at line 3)\n" +
+ " X Test = new X<>(){\n" +
+ " ^\n" +
+ "X is a raw type. References to generic type X<T> should be parameterized\n" +
+ "----------\n" +
+ "2. ERROR in X.java (at line 3)\n" +
+ " X Test = new X<>(){\n" +
+ " ^\n" +
+ "\'<>\' cannot be used with anonymous classes\n" +
+ "----------\n";
+ String log_9 =
+ "----------\n" +
+ "1. WARNING in X.java (at line 3)\n" +
+ " X Test = new X<>(){\n" +
+ " ^\n" +
+ "X is a raw type. References to generic type X<T> should be parameterized\n" +
+ "----------\n" +
+ "2. ERROR in X.java (at line 3)\n" +
+ " X Test = new X<>(){\n" +
+ " void newMethod(){\n" +
+ " }\n" +
+ " }.testFunction(\"SUCCESS\");\n" +
+ " ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^\n" +
+ "Type mismatch: cannot convert from void to X\n" +
+ "----------\n" +
+ "3. ERROR in X.java (at line 4)\n" +
+ " void newMethod(){\n" +
+ " ^^^^^^^^^^^\n" +
+ "The method newMethod() of type new X<Object>(){} must override or implement a supertype method\n" +
+ "----------\n";
+ String errorMsg = this.complianceLevel < ClassFileConstants.JDK9 ? log_18 : log_9;
this.runNegativeTest(
new String[] {
"X.java",
@@ -2130,17 +2173,7 @@ public void test339478p() {
" ^\n" +
"\'<>\' cannot be used with anonymous classes\n" +
"----------\n" :
- "----------\n" +
- "1. WARNING in X.java (at line 3)\n" +
- " X Test = new X<>(){\n" +
- " ^\n" +
- "X is a raw type. References to generic type X<T> should be parameterized\n" +
- "----------\n" +
- "2. ERROR in X.java (at line 3)\n" +
- " X Test = new X<>(){\n" +
- " ^\n" +
- "\'<>\' cannot be used with anonymous classes\n" +
- "----------\n");
+ errorMsg);
}
public void test339478q() {
this.runNegativeTest(
@@ -5998,6 +6031,7 @@ public void testBug469297() {
" return list;\n" +
" }\n" +
" \n" +
+ " @SuppressWarnings(\"deprecation\")\n" +
" static final <L extends List<?>> L newList(Class<L> type) {\n" +
" try {\n" +
" return type.newInstance();\n" +
diff --git a/org.eclipse.jdt.core.tests.compiler/src/org/eclipse/jdt/core/tests/compiler/regression/GenericsRegressionTest_1_7.java b/org.eclipse.jdt.core.tests.compiler/src/org/eclipse/jdt/core/tests/compiler/regression/GenericsRegressionTest_1_7.java
index 805dd1070f..a9b72111ba 100644
--- a/org.eclipse.jdt.core.tests.compiler/src/org/eclipse/jdt/core/tests/compiler/regression/GenericsRegressionTest_1_7.java
+++ b/org.eclipse.jdt.core.tests.compiler/src/org/eclipse/jdt/core/tests/compiler/regression/GenericsRegressionTest_1_7.java
@@ -513,12 +513,19 @@ public void test004b() {
" }\n" +
"}",
},
+ this.complianceLevel < ClassFileConstants.JDK9 ?
"----------\n" +
"1. ERROR in X.java (at line 5)\n" +
" new X<>().new X2<>(){\n" +
" ^^\n" +
"\'<>\' cannot be used with anonymous classes\n" +
- "----------\n");
+ "----------\n":
+ "----------\n" +
+ "1. ERROR in X.java (at line 6)\n" +
+ " void newMethod(){\n" +
+ " ^^^^^^^^^^^\n" +
+ "The method newMethod() of type new X<Object>.X2<Object>(){} must override or implement a supertype method\n" +
+ "----------\n");
}
public void test004c() {
this.runConformTest(
@@ -1219,8 +1226,7 @@ public void test0027() {
}
// https://bugs.eclipse.org/bugs/show_bug.cgi?id=345239
public void test0028() {
- this.runNegativeTest(
- new String[] {
+ String[] testFiles = new String[] {
"X.java",
"public class X<T> {\n" +
" X<String> x = new X<> () {}\n;" +
@@ -1228,18 +1234,24 @@ public void test0028() {
" }\n" +
" X<String>.Y<String> y = x.new Y<>() {};\n" +
"}\n"
- },
- "----------\n" +
- "1. ERROR in X.java (at line 2)\n" +
- " X<String> x = new X<> () {}\n" +
- " ^\n" +
- "\'<>\' cannot be used with anonymous classes\n" +
- "----------\n" +
- "2. ERROR in X.java (at line 5)\n" +
- " X<String>.Y<String> y = x.new Y<>() {};\n" +
- " ^\n" +
- "\'<>\' cannot be used with anonymous classes\n" +
- "----------\n");
+ };
+ if (this.complianceLevel < ClassFileConstants.JDK9) {
+ this.runNegativeTest(
+ testFiles,
+ "----------\n" +
+ "1. ERROR in X.java (at line 2)\n" +
+ " X<String> x = new X<> () {}\n" +
+ " ^\n" +
+ "\'<>\' cannot be used with anonymous classes\n" +
+ "----------\n" +
+ "2. ERROR in X.java (at line 5)\n" +
+ " X<String>.Y<String> y = x.new Y<>() {};\n" +
+ " ^\n" +
+ "\'<>\' cannot be used with anonymous classes\n" +
+ "----------\n");
+ } else {
+ this.runConformTest(testFiles);
+ }
}
// https://bugs.eclipse.org/bugs/show_bug.cgi?id=345359
public void test0029() {
diff --git a/org.eclipse.jdt.core.tests.compiler/src/org/eclipse/jdt/core/tests/compiler/regression/GenericsRegressionTest_1_8.java b/org.eclipse.jdt.core.tests.compiler/src/org/eclipse/jdt/core/tests/compiler/regression/GenericsRegressionTest_1_8.java
index 5cfdecbdfb..b737b6b7fe 100644
--- a/org.eclipse.jdt.core.tests.compiler/src/org/eclipse/jdt/core/tests/compiler/regression/GenericsRegressionTest_1_8.java
+++ b/org.eclipse.jdt.core.tests.compiler/src/org/eclipse/jdt/core/tests/compiler/regression/GenericsRegressionTest_1_8.java
@@ -7313,8 +7313,7 @@ public void testBug499725() {
public void testBug488663() {
Map<String, String> options = getCompilerOptions();
options.put(CompilerOptions.OPTION_ReportRedundantSpecificationOfTypeArguments, CompilerOptions.ERROR);
- this.runConformTest(
- new String[] {
+ String[] testFiles = new String[] {
"C.java",
"import java.util.Comparator;\n" +
"public class C {\n" +
@@ -7325,7 +7324,21 @@ public void testBug488663() {
" }\n" +
" };\n" +
"}"
- },
+ };
+ if (this.complianceLevel < ClassFileConstants.JDK9) {
+ this.runConformTest(
+ testFiles,
"", options);
+ } else {
+ this.runNegativeTest(
+ testFiles,
+ "----------\n" +
+ "1. ERROR in C.java (at line 3)\n" +
+ " Comparator<String> comparator = new Comparator<String>() { //\n" +
+ " ^^^^^^^^^^\n" +
+ "Redundant specification of type arguments <String>\n" +
+ "----------\n",
+ null, true, options);
+ }
}
}

Back to the top