Skip to main content
aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorJay Arthanareeswaran2019-02-06 14:50:02 +0000
committerJay Arthanareeswaran2019-02-06 16:05:47 +0000
commitdf9c8b671968162a64690b6ba582d3f7c770decf (patch)
tree16a341713af9af43a13bc0acfdae019f708b8027 /org.eclipse.jdt.core.tests.compiler/src
parenta519aa3b8cea3146ae2b7db64a0fab2f79cf33a4 (diff)
downloadeclipse.jdt.core-df9c8b671968162a64690b6ba582d3f7c770decf.tar.gz
eclipse.jdt.core-df9c8b671968162a64690b6ba582d3f7c770decf.tar.xz
eclipse.jdt.core-df9c8b671968162a64690b6ba582d3f7c770decf.zip
Bug 544162 - [12] Failures in GenericTypeTest with JRE 12Y20190206-2200
Change-Id: I40e0ec918eec8c78e284acb6b0b6bdc95aae58ea Signed-off-by: Jay Arthanareeswaran <jarthana@in.ibm.com>
Diffstat (limited to 'org.eclipse.jdt.core.tests.compiler/src')
-rw-r--r--org.eclipse.jdt.core.tests.compiler/src/org/eclipse/jdt/core/tests/compiler/regression/AbstractComparableTest.java29
-rw-r--r--org.eclipse.jdt.core.tests.compiler/src/org/eclipse/jdt/core/tests/compiler/regression/GenericTypeTest.java28
-rw-r--r--org.eclipse.jdt.core.tests.compiler/src/org/eclipse/jdt/core/tests/compiler/regression/JEP286Test.java12
-rw-r--r--org.eclipse.jdt.core.tests.compiler/src/org/eclipse/jdt/core/tests/compiler/regression/VarargsTest.java8
-rw-r--r--org.eclipse.jdt.core.tests.compiler/src/org/eclipse/jdt/core/tests/util/AbstractCompilerTest.java8
5 files changed, 65 insertions, 20 deletions
diff --git a/org.eclipse.jdt.core.tests.compiler/src/org/eclipse/jdt/core/tests/compiler/regression/AbstractComparableTest.java b/org.eclipse.jdt.core.tests.compiler/src/org/eclipse/jdt/core/tests/compiler/regression/AbstractComparableTest.java
index c0e95a3c06..b6dcf42ad3 100644
--- a/org.eclipse.jdt.core.tests.compiler/src/org/eclipse/jdt/core/tests/compiler/regression/AbstractComparableTest.java
+++ b/org.eclipse.jdt.core.tests.compiler/src/org/eclipse/jdt/core/tests/compiler/regression/AbstractComparableTest.java
@@ -1,5 +1,5 @@
/*******************************************************************************
- * Copyright (c) 2000, 2018 IBM Corporation and others.
+ * Copyright (c) 2000, 2019 IBM Corporation and others.
*
* This program and the accompanying materials
* are made available under the terms of the Eclipse Public License 2.0
@@ -8,6 +8,10 @@
*
* SPDX-License-Identifier: EPL-2.0
*
+ * This is an implementation of an early-draft specification developed under the Java
+ * Community Process (JCP) and is made available for testing and evaluation purposes
+ * only. The code is not compatible with any specification of the JCP.
+ *
* Contributors:
* IBM Corporation - initial API and implementation
* Stephan Herrmann - Contribution for
@@ -110,6 +114,29 @@ public class AbstractComparableTest extends AbstractRegressionTest {
}
protected String intersection(String... types) {
+ // From JDK 12, Comparable gets two new super interfaces, namely Constable and ConstantDesc.
+ // The idea is to append Comparable with &Constable&ConstantDesc automatically.
+ if (isJRE12Plus) {
+ int index = -1;
+ for(int i = 0; i < types.length; i++) {
+ if (types[i].startsWith("Comparable") && !types[i].endsWith("ConstantDesc")) {
+ if ((types.length <= i+1) || !types[i+1].startsWith("CharSequence")) {
+ index = i;
+ break;
+ }
+ }
+ }
+ if (index >= 0) {
+ index++;
+ String[] temp = new String[types.length + 2];
+ System.arraycopy(types, 0, temp, 0, index);
+ temp[index] = "Constable";
+ temp[index+1] = "ConstantDesc";
+ if (index < types.length)
+ System.arraycopy(types, index, temp, index+2, types.length - index);
+ types = temp;
+ }
+ }
if (this.complianceLevel >= ClassFileConstants.JDK1_8)
return String.join(" & ", types);
return String.join("&", types);
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 10d7a54ce5..de0df414ab 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
@@ -1,5 +1,5 @@
/*******************************************************************************
- * Copyright (c) 2000, 2018 IBM Corporation and others.
+ * Copyright (c) 2000, 2019 IBM Corporation and others.
*
* This program and the accompanying materials
* are made available under the terms of the Eclipse Public License 2.0
@@ -15337,7 +15337,9 @@ public void test0499(){
"1. ERROR in X.java (at line 6)\n" +
" Integer[] var = cond ? tab1 : tab2;\n" +
" ^^^^^^^^^^^^^^^^^^\n" +
- "Type mismatch: cannot convert from Object&Serializable&Comparable<? extends Object&Serializable&Comparable<?>>[] to Integer[]\n" +
+ "Type mismatch: cannot convert from Object&Serializable&" +
+ "" + intersection("Comparable<? extends Object&Serializable&" + intersection("Comparable<?>") + ">") +
+ "[] to Integer[]\n" +
"----------\n":
"----------\n" +
"1. ERROR in X.java (at line 6)\n" +
@@ -19815,7 +19817,7 @@ public void test0617() {
"1. ERROR in X.java (at line 10)\n" +
" String s = l1 != null ? foo(l1, l2) : l3;\n" +
" ^^^^^^^^^^^\n" +
- "Type mismatch: cannot convert from List<capture#2-of ? extends Number & Comparable<?>> to String\n" +
+ "Type mismatch: cannot convert from List<capture#2-of ? extends Number & "+intersection("Comparable<?>")+"> to String\n" +
"----------\n");
}
// https://bugs.eclipse.org/bugs/show_bug.cgi?id=92556
@@ -25439,7 +25441,7 @@ public void test0790() {
"1. ERROR in X.java (at line 7)\n" +
" if (isGreater(i, d)) \n" +
" ^^^^^^^^^\n" +
- "Bound mismatch: The generic method isGreater(T, T) of type X is not applicable for the arguments (Integer, Double). The inferred type Number&Comparable<?> is not a valid substitute for the bounded parameter <T extends Comparable<T>>\n" +
+ "Bound mismatch: The generic method isGreater(T, T) of type X is not applicable for the arguments (Integer, Double). The inferred type "+ intersection("Number", "Comparable<?>") +" is not a valid substitute for the bounded parameter <T extends Comparable<T>>\n" +
"----------\n" +
"2. ERROR in X.java (at line 15)\n" +
" isGreater(c1, c2);\n" +
@@ -26064,7 +26066,9 @@ public void test0805() {
"2. ERROR in X.java (at line 14)\n" +
" String s2 = foo(integers, floats);\n" +
" ^^^^^^^^^^^^^^^^^^^^^\n" +
- "Type mismatch: cannot convert from "+intersection("Number","Comparable<? extends "+intersection("Number","Comparable<?>")+">[]")+" to String\n" +
+ "Type mismatch: cannot convert from "+intersection("Number",
+ intersection("Comparable<? extends "+intersection("Number","Comparable<?>")+">")
+ )+"[] to String\n" +
"----------\n");
}
//https://bugs.eclipse.org/bugs/show_bug.cgi?id=107079
@@ -33564,12 +33568,12 @@ public void test1000() {
"4. WARNING in X.java (at line 14)\n" +
" Iterator<Number> it2 = X.chain(l1.iterator(), l2.iterator());\n" +
" ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^\n" +
- "Type safety: A generic array of Iterator<? extends Number&Comparable<?>> is created for a varargs parameter\n" +
+ "Type safety: A generic array of Iterator<? extends "+ intersection("Number", "Comparable<?>") +"> is created for a varargs parameter\n" +
"----------\n" +
"5. ERROR in X.java (at line 14)\n" +
" Iterator<Number> it2 = X.chain(l1.iterator(), l2.iterator());\n" +
" ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^\n" +
- "Type mismatch: cannot convert from Iterator<Number&Comparable<?>> to Iterator<Number>\n" +
+ "Type mismatch: cannot convert from Iterator<"+ intersection("Number", "Comparable<?>") +"> to Iterator<Number>\n" +
"----------\n" +
"6. WARNING in X.java (at line 18)\n" +
" Iterator<Number> it2 = X.chain(l1.iterator(), l1.iterator());\n" +
@@ -33606,12 +33610,12 @@ public void test1000() {
"5. WARNING in X.java (at line 14)\n" +
" Iterator<Number> it2 = X.chain(l1.iterator(), l2.iterator());\n" +
" ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^\n" +
- "Type safety: A generic array of Iterator<? extends Number&Comparable<?>> is created for a varargs parameter\n" +
+ "Type safety: A generic array of Iterator<? extends Number&"+ intersection("Comparable<?>") +"> is created for a varargs parameter\n" +
"----------\n" +
"6. ERROR in X.java (at line 14)\n" +
" Iterator<Number> it2 = X.chain(l1.iterator(), l2.iterator());\n" +
" ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^\n" +
- "Type mismatch: cannot convert from Iterator<Number&Comparable<?>> to Iterator<Number>\n" +
+ "Type mismatch: cannot convert from Iterator<Number&"+ intersection("Comparable<?>") +"> to Iterator<Number>\n" +
"----------\n" +
"7. WARNING in X.java (at line 18)\n" +
" Iterator<Number> it2 = X.chain(l1.iterator(), l1.iterator());\n" +
@@ -34746,7 +34750,7 @@ public void test1029() {
"1. ERROR in X.java (at line 10)\n" +
" List<Number> name = makeNumberList(5, 5D);\n" +
" ^^^^^^^^^^^^^^^^^^^^^\n" +
- "Type mismatch: cannot convert from List<Number&Comparable<?>> to List<Number>\n" +
+ "Type mismatch: cannot convert from List<"+ intersection("Number", "Comparable<?>") +"> to List<Number>\n" +
"----------\n",
null,
true,
@@ -39658,7 +39662,7 @@ public void test1136() {
"1. ERROR in X.java (at line 4)\n" +
" List<Object> l1 = Arrays.asList(1, \"X\");\n" +
" ^^^^^^^^^^^^^^^^^^^^^\n" +
- "Type mismatch: cannot convert from List<Object&Comparable<?>&Serializable> to List<Object>\n" +
+ "Type mismatch: cannot convert from List<Object&"+ intersection("Comparable<?>") +"&Serializable> to List<Object>\n" +
"----------\n" +
"2. ERROR in X.java (at line 8)\n" +
" List<Object> l2 = Arrays.asList(b, c);\n" +
@@ -43202,7 +43206,7 @@ public void test1227() {
"1. WARNING in X.java (at line 4)\n" +
" Arrays.asList(String.class, Integer.class);\n" +
" ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^\n" +
- "Type safety: A generic array of Class<? extends Object&Serializable&Comparable<?>> is created for a varargs parameter\n" +
+ "Type safety: A generic array of Class<? extends Object&Serializable&"+ intersection("Comparable<?>") +"> is created for a varargs parameter\n" +
"----------\n" +
"2. ERROR in X.java (at line 6)\n" +
" Zork z;\n" +
diff --git a/org.eclipse.jdt.core.tests.compiler/src/org/eclipse/jdt/core/tests/compiler/regression/JEP286Test.java b/org.eclipse.jdt.core.tests.compiler/src/org/eclipse/jdt/core/tests/compiler/regression/JEP286Test.java
index d7c3fb22de..891f9e4de6 100644
--- a/org.eclipse.jdt.core.tests.compiler/src/org/eclipse/jdt/core/tests/compiler/regression/JEP286Test.java
+++ b/org.eclipse.jdt.core.tests.compiler/src/org/eclipse/jdt/core/tests/compiler/regression/JEP286Test.java
@@ -1,11 +1,15 @@
/*******************************************************************************
- * Copyright (c) 2018 Jesper Steen Møller and others.
+ * Copyright (c) 2018, 2019 Jesper Steen Møller and others.
*
* This program and the accompanying materials
* are made available under the terms of the Eclipse Public License 2.0
* which accompanies this distribution, and is available at
* https://www.eclipse.org/legal/epl-2.0/
*
+ * This is an implementation of an early-draft specification developed under the Java
+ * Community Process (JCP) and is made available for testing and evaluation purposes
+ * only. The code is not compatible with any specification of the JCP.
+ *
* SPDX-License-Identifier: EPL-2.0
*
* Contributors:
@@ -69,7 +73,11 @@ static {
simpleTypeNames.put("ComparableAny", "Comparable<?>");
simpleTypeNames.put("CollectionExt_ComparableAny", "Collection<? extends Comparable<?>>");
simpleTypeNames.put("CollectionSuperComparableAny", "Collection<? super Comparable<?>>");
- simpleTypeNames.put("IntLongFloat", "java.lang.Number & Comparable<?>");
+ isJRE12Plus = isJRELevel(F_12);
+ if (isJRE12Plus)
+ simpleTypeNames.put("IntLongFloat", "java.lang.Number & Comparable<?> & java.lang.constant.Constable & java.lang.constant.ConstantDesc");
+ else
+ simpleTypeNames.put("IntLongFloat", "java.lang.Number & Comparable<?>");
simpleTypeNames.put("ListTestAndSerializable", "List<? extends Z & java.io.Serializable>");
simpleTypeNames.put("TestAndSerializable", "Z & java.io.Serializable");
}
diff --git a/org.eclipse.jdt.core.tests.compiler/src/org/eclipse/jdt/core/tests/compiler/regression/VarargsTest.java b/org.eclipse.jdt.core.tests.compiler/src/org/eclipse/jdt/core/tests/compiler/regression/VarargsTest.java
index d0e2f2824d..6e7d315d3c 100644
--- a/org.eclipse.jdt.core.tests.compiler/src/org/eclipse/jdt/core/tests/compiler/regression/VarargsTest.java
+++ b/org.eclipse.jdt.core.tests.compiler/src/org/eclipse/jdt/core/tests/compiler/regression/VarargsTest.java
@@ -1,5 +1,5 @@
/*******************************************************************************
- * Copyright (c) 2005, 2016 IBM Corporation and others.
+ * Copyright (c) 2005, 2019 IBM Corporation and others.
*
* This program and the accompanying materials
* are made available under the terms of the Eclipse Public License 2.0
@@ -50,7 +50,11 @@ public class VarargsTest extends AbstractComparableTest {
public static Class testClass() {
return VarargsTest.class;
}
-
+ protected String intersection(String... types) {
+ if (this.complianceLevel >= ClassFileConstants.JDK1_8)
+ return String.join(" & ", types);
+ return String.join("&", types);
+ }
public void test001() {
this.runConformTest(
new String[] {
diff --git a/org.eclipse.jdt.core.tests.compiler/src/org/eclipse/jdt/core/tests/util/AbstractCompilerTest.java b/org.eclipse.jdt.core.tests.compiler/src/org/eclipse/jdt/core/tests/util/AbstractCompilerTest.java
index 7991fa08ed..eec4716a5a 100644
--- a/org.eclipse.jdt.core.tests.compiler/src/org/eclipse/jdt/core/tests/util/AbstractCompilerTest.java
+++ b/org.eclipse.jdt.core.tests.compiler/src/org/eclipse/jdt/core/tests/util/AbstractCompilerTest.java
@@ -1,5 +1,5 @@
/*******************************************************************************
- * Copyright (c) 2000, 2018 IBM Corporation and others.
+ * Copyright (c) 2000, 2019 IBM Corporation and others.
*
* This program and the accompanying materials
* are made available under the terms of the Eclipse Public License 2.0
@@ -58,6 +58,7 @@ public class AbstractCompilerTest extends TestCase {
protected boolean enableAPT = false;
protected static boolean isJRE9Plus = false; // Stop gap, so tests need not be run at 9, but some tests can be adjusted for JRE 9
protected static boolean isJRE11Plus = false;
+ protected static boolean isJRE12Plus = false;
protected static boolean reflectNestedClassUseDollar;
/**
@@ -158,6 +159,7 @@ public class AbstractCompilerTest extends TestCase {
int lessthan9 = F_1_3 | F_1_4 | F_1_5 | F_1_6 | F_1_7 | F_1_8;
isJRE9Plus = !isJRELevel(lessthan9);
isJRE11Plus = isJRELevel(F_11);
+ isJRE12Plus = isJRELevel(F_12);
}
/**
@@ -422,8 +424,8 @@ public class AbstractCompilerTest extends TestCase {
public static int getPossibleComplianceLevels() {
if (possibleComplianceLevels == UNINITIALIZED) {
String specVersion = System.getProperty("java.specification.version");
- isJRE11Plus = CompilerOptions.VERSION_11.equals(specVersion) ||
- CompilerOptions.VERSION_12.equals(specVersion);
+ isJRE12Plus = CompilerOptions.VERSION_12.equals(specVersion);
+ isJRE11Plus = isJRE12Plus || CompilerOptions.VERSION_11.equals(specVersion);
isJRE9Plus = isJRE11Plus || CompilerOptions.VERSION_9.equals(specVersion)
|| CompilerOptions.VERSION_10.equals(specVersion);
initReflectionVersion();

Back to the top