Remove equals and now final hashCode method from test compilation unit

hashCode is now final in the parent class, so we cannot override it. To
avoid an NPE in the base implementation, we need to set the owner field.
The PRIMARY working copy owner seems to be sufficient.
This commit is contained in:
Rawi01 committed 2024-02-01 21:32:55 +01:00
1 parent cad428ea74
commit dd95627811
1 file changed
+2 -9
+2 -9
View File
@@ -52,6 +52,7 @@ import org.eclipse.jdt.internal.compiler.batch.FileSystem;
import org.eclipse.jdt.internal.compiler.env.ICompilationUnit;
import org.eclipse.jdt.internal.compiler.impl.CompilerOptions;
import org.eclipse.jdt.internal.compiler.problem.DefaultProblemFactory;
import org.eclipse.jdt.internal.core.DefaultWorkingCopyOwner;
import org.eclipse.jdt.internal.core.JavaModelManager;
import org.osgi.framework.Bundle;
import org.osgi.framework.BundleContext;
@@ -308,7 +309,7 @@ public class RunTestsViaEcj extends AbstractRunTests {
private final char[] mainTypeName;
private TestCompilationUnitEclipse(String name, String source) {
super(null, name, null);
super(null, name, DefaultWorkingCopyOwner.PRIMARY);
this.source = source.toCharArray();
char[] fileNameCharArray = getFileName();
@@ -320,14 +321,6 @@ public class RunTestsViaEcj extends AbstractRunTests {
mainTypeName = CharOperation.subarray(fileNameCharArray, start, end);
}
@Override public int hashCode() {
return System.identityHashCode(this);
}
@Override public boolean equals(Object obj) {
return this == obj;
}
@Override public char[] getContents() {
return source;
}