Skip to main content
aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorManoj Palat2021-01-04 14:22:45 +0000
committerManoj Palat2021-01-04 14:22:45 +0000
commit91101dd574ca19af4e8a65ab863924c39fdcb90a (patch)
treea5953de58a715af1b7697aaba57505ce38c6658f
parent9007a83c2488885d0ccac052ef8a8c04f1cd5736 (diff)
downloadeclipse.jdt.core-91101dd574ca19af4e8a65ab863924c39fdcb90a.tar.gz
eclipse.jdt.core-91101dd574ca19af4e8a65ab863924c39fdcb90a.tar.xz
eclipse.jdt.core-91101dd574ca19af4e8a65ab863924c39fdcb90a.zip
Bug 570049 - [16] jdt test failures in gerrit
Change-Id: I8f8734dc9da564a645230579a4b756cade925f8f Signed-off-by: Manoj Palat <manpalat@in.ibm.com>
-rw-r--r--org.eclipse.jdt.core.tests.compiler/src/org/eclipse/jdt/core/tests/compiler/regression/AutoBoxingTest.java60
-rw-r--r--org.eclipse.jdt.core.tests.compiler/src/org/eclipse/jdt/core/tests/compiler/regression/ConditionalExpressionTest.java8
-rw-r--r--org.eclipse.jdt.core.tests.compiler/src/org/eclipse/jdt/core/tests/compiler/regression/NullAnnotationTest.java49
-rw-r--r--org.eclipse.jdt.core.tests.compiler/src/org/eclipse/jdt/core/tests/compiler/regression/SwitchExpressionsYieldTest.java18
4 files changed, 94 insertions, 41 deletions
diff --git a/org.eclipse.jdt.core.tests.compiler/src/org/eclipse/jdt/core/tests/compiler/regression/AutoBoxingTest.java b/org.eclipse.jdt.core.tests.compiler/src/org/eclipse/jdt/core/tests/compiler/regression/AutoBoxingTest.java
index bbb2bce8e7..ed4242c3dc 100644
--- a/org.eclipse.jdt.core.tests.compiler/src/org/eclipse/jdt/core/tests/compiler/regression/AutoBoxingTest.java
+++ b/org.eclipse.jdt.core.tests.compiler/src/org/eclipse/jdt/core/tests/compiler/regression/AutoBoxingTest.java
@@ -1,5 +1,5 @@
/*******************************************************************************
- * Copyright (c) 2005, 2020 IBM Corporation and others.
+ * Copyright (c) 2005, 2021 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
*******************************************************************************/
@@ -534,7 +538,7 @@ public class AutoBoxingTest extends AbstractComparableTest {
" @SuppressWarnings(\"deprecation\")\n" +
" public static void main(String[] s) {\n" +
" new Y().test(1, 1);\n" + // reference to test is ambiguous, both method test(java.lang.Integer,int) in Y and method test(int,java.lang.Integer) in Y match
- " new Y().test(new Integer(1), new Integer(1));\n" + // reference to test is ambiguous
+ " new Y().test(Integer.valueOf(1), Integer.valueOf(1));\n" + // reference to test is ambiguous
" }\n" +
"}\n" +
"class Y {\n" +
@@ -549,7 +553,7 @@ public class AutoBoxingTest extends AbstractComparableTest {
"The method test(Integer, int) is ambiguous for the type Y\n" +
"----------\n" +
"2. ERROR in X.java (at line 5)\n" +
- " new Y().test(new Integer(1), new Integer(1));\n" +
+ " new Y().test(Integer.valueOf(1), Integer.valueOf(1));\n" +
" ^^^^\n" +
"The method test(Integer, int) is ambiguous for the type Y\n" +
"----------\n"
@@ -760,20 +764,20 @@ public class AutoBoxingTest extends AbstractComparableTest {
"public class X {\n" +
" @SuppressWarnings(\"deprecation\")\n" +
" public static void main(String[] args) {\n" +
- " Float f = args.length == 0 ? new Float(0) : 0;\n" +
+ " Float f = args.length == 0 ? Float.valueOf(0) : 0;\n" +
" System.out.println((int)f);\n" +
" }\n" +
"}\n",
},
"----------\n" +
"1. WARNING in X.java (at line 4)\n" +
- " Float f = args.length == 0 ? new Float(0) : 0;\n" +
- " ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^\n" +
+ " Float f = args.length == 0 ? Float.valueOf(0) : 0;\n" +
+ " ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^\n" +
"The expression of type float is boxed into Float\n" +
"----------\n" +
"2. WARNING in X.java (at line 4)\n" +
- " Float f = args.length == 0 ? new Float(0) : 0;\n" +
- " ^^^^^^^^^^^^\n" +
+ " Float f = args.length == 0 ? Float.valueOf(0) : 0;\n" +
+ " ^^^^^^^^^^^^^^^^\n" +
"The expression of type Float is unboxed into float\n" +
"----------\n" +
"3. ERROR in X.java (at line 5)\n" +
@@ -1926,7 +1930,7 @@ public class AutoBoxingTest extends AbstractComparableTest {
"public class X {\n" +
" @SuppressWarnings(\"deprecation\")\n" +
" public static void main(String[] args) {\n" +
- " a(new Integer(1), 2);\n" +
+ " a(Integer.valueOf(1), 2);\n" +
" }\n" +
" public static void a(int a, int b) { System.out.println(\"SUCCESS\"); }\n" +
" public static void a(Object a, Object b) {}\n" +
@@ -1934,7 +1938,7 @@ public class AutoBoxingTest extends AbstractComparableTest {
},
"----------\n" +
"1. ERROR in X.java (at line 4)\n" +
- " a(new Integer(1), 2);\n" +
+ " a(Integer.valueOf(1), 2);\n" +
" ^\n" +
"The method a(int, int) is ambiguous for the type X\n" +
"----------\n"
@@ -2757,9 +2761,9 @@ public class AutoBoxingTest extends AbstractComparableTest {
" @SuppressWarnings(\"deprecation\")\n" +
" public static void main(String[] args) {\n" +
" boolean b = true;\n" +
- " Character _Character = new Character(\' \');\n" +
+ " Character _Character = Character.valueOf(\' \');\n" +
" char c = \' \';\n" +
- " Integer _Integer = new Integer(2);\n" +
+ " Integer _Integer = Integer.valueOf(2);\n" +
" if ((b ? _Character : _Integer) == c) {\n" +
" System.out.println(zork);\n" +
" } else {\n" +
@@ -2930,8 +2934,8 @@ public class AutoBoxingTest extends AbstractComparableTest {
" @SuppressWarnings(\"deprecation\")\n" +
" public static void main(String[] args) {\n" +
" new X().foo(1);\n" +
- " new X().foo(new Integer(1));\n" +
- " new X().foo(1, new Integer(1));\n" +
+ " new X().foo(Integer.valueOf(1));\n" +
+ " new X().foo(1, Integer.valueOf(1));\n" +
" }\n" +
"}\n",
},
@@ -2942,12 +2946,12 @@ public class AutoBoxingTest extends AbstractComparableTest {
"The method foo(Object[]) is ambiguous for the type X\n" +
"----------\n" +
"2. ERROR in X.java (at line 7)\n" +
- " new X().foo(new Integer(1));\n" +
+ " new X().foo(Integer.valueOf(1));\n" +
" ^^^\n" +
"The method foo(Object[]) is ambiguous for the type X\n" +
"----------\n" +
"3. ERROR in X.java (at line 8)\n" +
- " new X().foo(1, new Integer(1));\n" +
+ " new X().foo(1, Integer.valueOf(1));\n" +
" ^^^\n" +
"The method foo(Object[]) is ambiguous for the type X\n" +
"----------\n");
@@ -2960,8 +2964,8 @@ public class AutoBoxingTest extends AbstractComparableTest {
" @SuppressWarnings(\"deprecation\")\n" +
" public static void main(String[] args) {\n" +
" new X().foo(1);\n" +
- " new X().foo(new Integer(1));\n" +
- " new X().foo(1, new Integer(1));\n" +
+ " new X().foo(Integer.valueOf(1));\n" +
+ " new X().foo(1, Integer.valueOf(1));\n" +
" }\n" +
"}\n",
},
@@ -2972,12 +2976,12 @@ public class AutoBoxingTest extends AbstractComparableTest {
"The method foo(Number[]) is ambiguous for the type X\n" +
"----------\n" +
"2. ERROR in X.java (at line 7)\n" +
- " new X().foo(new Integer(1));\n" +
+ " new X().foo(Integer.valueOf(1));\n" +
" ^^^\n" +
"The method foo(Number[]) is ambiguous for the type X\n" +
"----------\n" +
"3. ERROR in X.java (at line 8)\n" +
- " new X().foo(1, new Integer(1));\n" +
+ " new X().foo(1, Integer.valueOf(1));\n" +
" ^^^\n" +
"The method foo(Number[]) is ambiguous for the type X\n" +
"----------\n"
@@ -2991,8 +2995,8 @@ public class AutoBoxingTest extends AbstractComparableTest {
" @SuppressWarnings(\"deprecation\")\n" +
" public static void main(String[] args) {\n" +
" new X().foo(1);\n" +
- " new X().foo(new Integer(1));\n" +
- " new X().foo(1, new Integer(1));\n" +
+ " new X().foo(Integer.valueOf(1));\n" +
+ " new X().foo(1, Integer.valueOf(1));\n" +
" }\n" +
"}\n",
},
@@ -3003,12 +3007,12 @@ public class AutoBoxingTest extends AbstractComparableTest {
"The method foo(int, Object[]) is ambiguous for the type X\n" +
"----------\n" +
"2. ERROR in X.java (at line 7)\n" +
- " new X().foo(new Integer(1));\n" +
+ " new X().foo(Integer.valueOf(1));\n" +
" ^^^\n" +
"The method foo(int, Object[]) is ambiguous for the type X\n" +
"----------\n" +
"3. ERROR in X.java (at line 8)\n" +
- " new X().foo(1, new Integer(1));\n" +
+ " new X().foo(1, Integer.valueOf(1));\n" +
" ^^^\n" +
"The method foo(int, Object[]) is ambiguous for the type X\n" +
"----------\n"
@@ -5157,7 +5161,7 @@ public void test168() {
"public class X {\n" +
" <T extends Integer> T a() { return 35; }\n" +
" <T extends Integer> T[] b() { return new int[]{35}; }\n" +
- " <T extends Integer> T c() { return new Integer(35); }\n" +
+ " <T extends Integer> T c() { return Integer.valueOf(35); }\n" +
" <T extends Integer> T[] d() { return new Integer[]{35}; }\n" +
"}\n",
},
@@ -5183,13 +5187,13 @@ public void test168() {
"Type mismatch: cannot convert from int[] to T[]\n" +
"----------\n" +
"5. WARNING in X.java (at line 5)\n" +
- " <T extends Integer> T c() { return new Integer(35); }\n" +
+ " <T extends Integer> T c() { return Integer.valueOf(35); }\n" +
" ^^^^^^^\n" +
"The type parameter T should not be bounded by the final type Integer. Final types cannot be further extended\n" +
"----------\n" +
"6. ERROR in X.java (at line 5)\n" +
- " <T extends Integer> T c() { return new Integer(35); }\n" +
- " ^^^^^^^^^^^^^^^\n" +
+ " <T extends Integer> T c() { return Integer.valueOf(35); }\n" +
+ " ^^^^^^^^^^^^^^^^^^^\n" +
"Type mismatch: cannot convert from Integer to T\n" +
"----------\n" +
"7. WARNING in X.java (at line 6)\n" +
diff --git a/org.eclipse.jdt.core.tests.compiler/src/org/eclipse/jdt/core/tests/compiler/regression/ConditionalExpressionTest.java b/org.eclipse.jdt.core.tests.compiler/src/org/eclipse/jdt/core/tests/compiler/regression/ConditionalExpressionTest.java
index 0cba2a22e4..2490ff3f6a 100644
--- a/org.eclipse.jdt.core.tests.compiler/src/org/eclipse/jdt/core/tests/compiler/regression/ConditionalExpressionTest.java
+++ b/org.eclipse.jdt.core.tests.compiler/src/org/eclipse/jdt/core/tests/compiler/regression/ConditionalExpressionTest.java
@@ -1,5 +1,5 @@
/*******************************************************************************
- * Copyright (c) 2005, 2016 IBM Corporation and others.
+ * Copyright (c) 2005, 2021 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
*******************************************************************************/
@@ -534,7 +538,7 @@ public class ConditionalExpressionTest extends AbstractRegressionTest {
"public class X {\n" +
" public void error(Collection<Object> c) {\n" +
" boolean b =true;\n" +
- " c.add(b ? new Integer(1)\n" +
+ " c.add(b ? Integer.valueOf(1)\n" +
" : c==null ? null \n" +
" : c instanceof List ? Integer.valueOf(1) \n" +
" : o()); \n" +
diff --git a/org.eclipse.jdt.core.tests.compiler/src/org/eclipse/jdt/core/tests/compiler/regression/NullAnnotationTest.java b/org.eclipse.jdt.core.tests.compiler/src/org/eclipse/jdt/core/tests/compiler/regression/NullAnnotationTest.java
index 3d38fc2b3d..b77b358ca7 100644
--- a/org.eclipse.jdt.core.tests.compiler/src/org/eclipse/jdt/core/tests/compiler/regression/NullAnnotationTest.java
+++ b/org.eclipse.jdt.core.tests.compiler/src/org/eclipse/jdt/core/tests/compiler/regression/NullAnnotationTest.java
@@ -1,5 +1,5 @@
/*******************************************************************************
- * Copyright (c) 2010, 2019 GK Software AG and others.
+ * Copyright (c) 2010, 2021 GK Software AG 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:
* Stephan Herrmann - initial API and implementation
* Till Brychcy <register.eclipse@brychcy.de> - Contribution for
@@ -9560,9 +9564,22 @@ public void testBug530970_return_bin() {
"public class X {\n" +
" @NonNullByDefault(DefaultLocation.RETURN_TYPE)\n" +
" Number test(Number in) {\n" +
- " return new Integer(13);\n" +
+ " return new MyInteger(13);\n" +
" }\n" +
+ "}\n" +
+ "class MyInteger extends Number {\n" +
+ "private static final long serialVersionUID = 1L;\n" +
+ " public MyInteger(int i) {}\n" +
+ " @Override\n" +
+ " public int intValue() { return 0;}\n" +
+ " @Override\n" +
+ " public long longValue() { return 0; }\n" +
+ " @Override\n" +
+ " public float floatValue() { return 0;}\n" +
+ " @Override\n" +
+ " public double doubleValue() { return 0; }\n" +
"}\n"
+
},
customOptions,
"");
@@ -9630,7 +9647,19 @@ public void testBug530970_field_bin() {
"import annotation.*;\n" +
"@NonNullByDefault(DefaultLocation.FIELD)\n" +
"public class X {\n" +
- " Number field = new Double(1.1);\n" +
+ " Number field = new MyDouble(1.1);\n" +
+ "}\n" +
+ "class MyDouble extends Number {\n" +
+ "private static final long serialVersionUID = 1L;\n" +
+ " public MyDouble(double d) {}\n" +
+ " @Override\n" +
+ " public int intValue() { return 0;}\n" +
+ " @Override\n" +
+ " public long longValue() { return 0; }\n" +
+ " @Override\n" +
+ " public float floatValue() { return 0;}\n" +
+ " @Override\n" +
+ " public double doubleValue() { return 0; }\n" +
"}\n"
},
customOptions,
@@ -9701,10 +9730,22 @@ public void testBug530970_default_bin() {
"import annotation.*;\n" +
"@NonNullByDefault\n" +
"public class X {\n" +
- " Number field = new Long(13);\n" +
+ " Number field = new MyLong(13);\n" +
" void test1(Number[] ns) {\n" +
" ns[0] = null; // OK since not affected by default\n" +
" }\n" +
+ "}\n" +
+ "class MyLong extends Number {\n" +
+ "private static final long serialVersionUID = 1L;\n" +
+ " public MyLong(long l) {}\n" +
+ " @Override\n" +
+ " public int intValue() { return 0;}\n" +
+ " @Override\n" +
+ " public long longValue() { return 0; }\n" +
+ " @Override\n" +
+ " public float floatValue() { return 0;}\n" +
+ " @Override\n" +
+ " public double doubleValue() { return 0; }\n" +
"}\n"
},
customOptions,
diff --git a/org.eclipse.jdt.core.tests.compiler/src/org/eclipse/jdt/core/tests/compiler/regression/SwitchExpressionsYieldTest.java b/org.eclipse.jdt.core.tests.compiler/src/org/eclipse/jdt/core/tests/compiler/regression/SwitchExpressionsYieldTest.java
index 7cb9cfa4f4..279ec1d9e3 100644
--- a/org.eclipse.jdt.core.tests.compiler/src/org/eclipse/jdt/core/tests/compiler/regression/SwitchExpressionsYieldTest.java
+++ b/org.eclipse.jdt.core.tests.compiler/src/org/eclipse/jdt/core/tests/compiler/regression/SwitchExpressionsYieldTest.java
@@ -1,5 +1,5 @@
/*******************************************************************************
- * Copyright (c) 2019, 2020 IBM Corporation and others.
+ * Copyright (c) 2019, 2021 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
@@ -7,6 +7,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
*******************************************************************************/
@@ -5827,8 +5831,8 @@ public class SwitchExpressionsYieldTest extends AbstractRegressionTest {
" @SuppressWarnings(\"deprecation\")\n" +
" public void bar(int i) {\n" +
" boolean b = foo( switch(i+1) {\n" +
- " case 0 -> new Short((short)0);\n" +
- " default -> new Double(2.0d);\n" +
+ " case 0 -> Short.valueOf((short)0);\n" +
+ " default -> Double.valueOf(2.0d);\n" +
" });\n" +
" System.out.println(b);\n" +
" }\n" +
@@ -5846,8 +5850,8 @@ public class SwitchExpressionsYieldTest extends AbstractRegressionTest {
"The method foo(short) in the type X is not applicable for the arguments (double)\n" +
"----------\n" +
"2. ERROR in X.java (at line 9)\n" +
- " default -> new Double(2.0d);\n" +
- " ^^^^^^^^^^^^^^^^\n" +
+ " default -> Double.valueOf(2.0d);\n" +
+ " ^^^^^^^^^^^^^^^^^^^^\n" +
"Type mismatch: cannot convert from Double to short\n" +
"----------\n"
);
@@ -5863,7 +5867,7 @@ public class SwitchExpressionsYieldTest extends AbstractRegressionTest {
" @SuppressWarnings(\"deprecation\")\n" +
" public void bar(int i) {\n" +
" boolean b = foo( switch(i+1) {\n" +
- " case 0 -> new Short((short)0);\n" +
+ " case 0 -> Short.valueOf((short)0);\n" +
" default -> 2.0d;\n" +
" });\n" +
" System.out.println(b);\n" +
@@ -5900,7 +5904,7 @@ public class SwitchExpressionsYieldTest extends AbstractRegressionTest {
" @SuppressWarnings(\"deprecation\")\n" +
" public void bar(int i) {\n" +
" boolean b = foo( switch(i+1) {\n" +
- " case 0 : yield new Short((short)0);\n" +
+ " case 0 : yield Short.valueOf((short)0);\n" +
" default : yield 2.0d;\n" +
" });\n" +
" System.out.println(b);\n" +

Back to the top