Skip to content

Commit

Permalink
Fixed tests failing after requiring minimal 1.8 compliance, part 6
Browse files Browse the repository at this point in the history
- AddImportTest
- BindingsNameTest
- JavaElementPropertyTesterTest
- OverrideTest
- GenerateHashCodeEqualsTest
- AdvancedQuickAssistTest
- AdvancedQuickAssistTest1d7
- AssistQuickFixTest1d8
- CleanUpStressTest
- CleanUpTest1d5
- CleanUpTest1d6
- JavadocQuickFixTest
- ModifierCorrectionsQuickFixTest1d7
- QuickFixEnablementTest
- TypeParameterMismatchTest

See eclipse-jdt/eclipse.jdt.core#2536
  • Loading branch information
iloveeclipse committed Jul 26, 2024
1 parent 3d32db8 commit 05b399f
Show file tree
Hide file tree
Showing 15 changed files with 1,027 additions and 1,214 deletions.

Large diffs are not rendered by default.

Original file line number Diff line number Diff line change
Expand Up @@ -56,8 +56,9 @@ public void setUp() throws Exception {

fSourceFolder= JavaProjectHelper.addSourceContainer(fJProject1, "src");

IPackageFragment pack0= fSourceFolder.createPackageFragment("", false, null);
IPackageFragment pack0= fSourceFolder.createPackageFragment("x", false, null);
String str= """
package x;
public class X {
}
""";
Expand All @@ -66,7 +67,7 @@ public class X {
IPackageFragment pack1= fSourceFolder.createPackageFragment("test1.ae", false, null);
String str1= """
package test1.ae;
import X;
import x.X;
public class E {
public class Inner {
public class InnerInner {
Expand Down Expand Up @@ -108,8 +109,8 @@ public void getFullyQualifiedName() throws Exception {
assertEquals("java.lang.Object[]", fullNames[3]);
assertEquals("test1.ae.E.Inner.InnerInner", fullNames[4]);
assertEquals("test1.ae.E.Inner.InnerInner[][]", fullNames[5]);
assertEquals("X", fullNames[6]);
assertEquals("X[][][]", fullNames[7]);
assertEquals("x.X", fullNames[6]);
assertEquals("x.X[][][]", fullNames[7]);
}

@Test
Expand Down Expand Up @@ -164,8 +165,8 @@ public void getAllNameComponents() throws Exception {
assertEqualArray(new String[] { "java", "lang", "Object[]" }, fullNames[3]);
assertEqualArray(new String[] { "test1", "ae", "E", "Inner", "InnerInner" }, fullNames[4]);
assertEqualArray(new String[] { "test1", "ae", "E", "Inner", "InnerInner[][]" }, fullNames[5]);
assertEqualArray(new String[] { "X" }, fullNames[6]);
assertEqualArray(new String[] { "X[][][]" }, fullNames[7]);
assertEqualArray(new String[] { "x", "X" }, fullNames[6]);
assertEqualArray(new String[] { "x", "X[][][]" }, fullNames[7]);
}

@Test
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -71,7 +71,7 @@ public void setUp() throws Exception {

fJProject1= JavaProjectHelper.createJavaProject("Test", "bin");

fJDK= JavaProjectHelper.addRTJar(fJProject1);
fJDK= JavaProjectHelper.addRTJar_17(fJProject1, false);
assertNotNull("jdk not found", fJDK);
assertTrue(fJDK.exists());

Expand Down Expand Up @@ -149,12 +149,12 @@ public void javaElementPropertyTester() {
assertEquals(allElements[i].getElementName(), expectedResult4[i], actual);
}

Object[] args= { JavaCore.COMPILER_COMPLIANCE, JavaCore.VERSION_1_5 };
Object[] args= { JavaCore.COMPILER_COMPLIANCE, JavaCore.VERSION_17 };
assertEquals(true, tester.test(fJProject1, JavaElementPropertyTester.PROJECT_OPTION, args , null));
assertEquals(false, tester.test(fOtherProject, JavaElementPropertyTester.PROJECT_OPTION, args , null));
assertEquals(false, tester.test(fOtherClosedProject, JavaElementPropertyTester.PROJECT_OPTION, args , null));

fJProject1.setOption(JavaCore.COMPILER_COMPLIANCE, JavaCore.VERSION_1_6);
fJProject1.setOption(JavaCore.COMPILER_COMPLIANCE, JavaCore.VERSION_11);

assertEquals(false, tester.test(fJProject1, JavaElementPropertyTester.PROJECT_OPTION, args, null));

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -111,17 +111,17 @@ public void test14Overloaded2() throws Exception {
public interface ITop {
void m(Integer i);
}
class Middle1 implements ITop {
public void m(Integer arg) {}
}
abstract class Middle2 implements ITop {
}
class Sub1 extends Middle1 {
public void m(Integer arg) {}
}
class Sub2 extends Middle2 {
public void m(Integer arg) {}
}
Expand Down Expand Up @@ -162,7 +162,7 @@ void g2 (T t) {
System.out.println("g2 base: " + t);
}
}
public class B extends A<java.util.List<Number>> {
void g1 (java.util.List<?> t) {
System.out.println("g1 derived: " + t);
Expand Down Expand Up @@ -382,7 +382,7 @@ public void test15ClassTypeVars1() throws Exception {
class A<E extends Number, F> {
void take(E e, F f) {}
}
class B<S extends Number, T> extends A<S, T> {
void take(S e, T f) {}
void take(T f, S e) {}
Expand Down Expand Up @@ -432,7 +432,7 @@ class E extends B<Integer> {
@Override
void m(Integer t) { System.out.println("D#m(Integer): " + t); }
}
""";
ICompilationUnit cu= fPackage.createCompilationUnit("A.java", str, false, null);

Expand Down Expand Up @@ -473,7 +473,7 @@ public void test15MethodTypeVars1() throws Exception {
class A {
<E extends Number, F> void take(E e, F f) {}
}
class B extends A {
<S extends Number, T> void take(S e, T f) {}
<S extends Number, T> void take(T f, S e) {}
Expand Down Expand Up @@ -506,7 +506,7 @@ public void test15MethodTypeVars2() throws Exception {
class A {
<E extends Number, F> void take(E e, F f) {}
}
class B extends A {
<S extends Number, T extends Object> void take(S e, T f) {}
<S extends Integer, T> void take(S e, T f) {}
Expand Down Expand Up @@ -660,9 +660,10 @@ void remove(String[] s) {}

CompilationUnit astRoot= createAST(cu);
IProblem[] problems= astRoot.getProblems();
assertEquals(2, problems.length);
assertEquals(IProblem.VarargsConflict, problems[0].getID());
assertEquals(3, problems.length);
assertEquals(IProblem.PotentialHeapPollutionFromVararg, problems[0].getID());
assertEquals(IProblem.VarargsConflict, problems[1].getID());
assertEquals(IProblem.VarargsConflict, problems[2].getID());

TypeDeclaration top= (TypeDeclaration) astRoot.types().get(0);
IMethodBinding topAdd= top.getMethods()[0].resolveBinding();
Expand Down Expand Up @@ -760,21 +761,21 @@ public void test15Bug107105() throws Exception {
String str= """
package override.test;
import java.io.Serializable;
class A {
<S extends Number & Serializable & Runnable > void foo2(S s) { }
}
class B extends A {
@Override // should error
<S extends Number & Runnable> void foo2(S s) { }
}
class C extends A {
@Override // should error
<S extends Number & Runnable & Cloneable> void foo2(S s) { }
}
class D extends A {
@Override // correct
<S extends Number & Runnable & Serializable> void foo2(S s) { }
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -1883,46 +1883,17 @@ public void subTypeAndArraysIn14() throws Exception {
"\r\n" +
"public class A extends B {\r\n" +
"\r\n" +
" /**\r\n" +
" * Returns a hash code value for the array\r\n" +
" * @param array the array to create a hash code value for\r\n" +
" * @return a hash code value for the array\r\n" +
" */\r\n" +
" private static int hashCode(double[] array) {\r\n" +
" int prime = 31;\r\n" +
" if (array == null)\r\n" +
" return 0;\r\n" +
" int result = 1;\r\n" +
" for (int index = 0; index < array.length; index++) {\r\n" +
" long temp = Double.doubleToLongBits(array[index]);\r\n" +
" result = prime * result + (int) (temp ^ (temp >>> 32));\r\n" +
" }\r\n" +
" return result;\r\n" +
" }\r\n" +
" /**\r\n" +
" * Returns a hash code value for the array\r\n" +
" * @param array the array to create a hash code value for\r\n" +
" * @return a hash code value for the array\r\n" +
" */\r\n" +
" private static int hashCode(Object[] array) {\r\n" +
" int prime = 31;\r\n" +
" if (array == null)\r\n" +
" return 0;\r\n" +
" int result = 1;\r\n" +
" for (int index = 0; index < array.length; index++) {\r\n" +
" result = prime * result + (array[index] == null ? 0 : array[index].hashCode());\r\n" +
" }\r\n" +
" return result;\r\n" +
" }\r\n" +
" A[] anArray;\r\n" +
" double[] anDArray;\r\n" +
" @Override\r\n" +
" public int hashCode() {\r\n" +
" final int prime = 31;\r\n" +
" int result = super.hashCode();\r\n" +
" result = prime * result + A.hashCode(anArray);\r\n" +
" result = prime * result + A.hashCode(anDArray);\r\n" +
" result = prime * result + Arrays.hashCode(anArray);\r\n" +
" result = prime * result + Arrays.hashCode(anDArray);\r\n" +
" return result;\r\n" +
" }\r\n" +
" @Override\r\n" +
" public boolean equals(Object obj) {\r\n" +
" if (this == obj)\r\n" +
" return true;\r\n" +
Expand Down Expand Up @@ -2110,7 +2081,7 @@ public void subTypeNoFields() throws Exception {
public void insertAt() throws Exception {
String originalContent= """
package p;
public class A {
Runnable x;
\t
Expand Down
Loading

0 comments on commit 05b399f

Please sign in to comment.