Download
Getting Started
Members
Projects
Community
Marketplace
Events
Planet Eclipse
Newsletter
Videos
Participate
Report a Bug
Forums
Mailing Lists
Wiki
IRC
How to Contribute
Working Groups
Automotive
Internet of Things
LocationTech
Long-Term Support
PolarSys
Science
OpenMDM
More
Community
Marketplace
Events
Planet Eclipse
Newsletter
Videos
Participate
Report a Bug
Forums
Mailing Lists
Wiki
IRC
How to Contribute
Working Groups
Automotive
Internet of Things
LocationTech
Long-Term Support
PolarSys
Science
OpenMDM
Toggle navigation
Bugzilla – Attachment 42060 Details for
Bug 142653
[1.5][compiler] JDT Internal Compiler Error: NullPointerException in MethodVerifier.computeInheritedMethods(), Eclipe 3.2RC4
Home
|
New
|
Browse
|
Search
|
[?]
|
Reports
|
Requests
|
Help
|
Log In
[x]
|
Terms of Use
|
Copyright Agent
[patch]
Patch
patch.txt (text/plain), 16.00 KB, created by
Kent Johnson
on 2006-05-19 14:26:04 EDT
(
hide
)
Description:
Patch
Filename:
MIME Type:
Creator:
Kent Johnson
Created:
2006-05-19 14:26:04 EDT
Size:
16.00 KB
patch
obsolete
>### Eclipse Workspace Patch 1.0 >#P org.eclipse.jdt.core >Index: compiler/org/eclipse/jdt/internal/compiler/lookup/MethodVerifier15.java >=================================================================== >RCS file: /home/eclipse/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/lookup/MethodVerifier15.java,v >retrieving revision 1.59 >diff -u -r1.59 MethodVerifier15.java >--- compiler/org/eclipse/jdt/internal/compiler/lookup/MethodVerifier15.java 2 May 2006 19:19:08 -0000 1.59 >+++ compiler/org/eclipse/jdt/internal/compiler/lookup/MethodVerifier15.java 19 May 2006 18:22:35 -0000 >@@ -11,6 +11,7 @@ > package org.eclipse.jdt.internal.compiler.lookup; > > import org.eclipse.jdt.internal.compiler.util.HashtableOfObject; >+import org.eclipse.jdt.internal.compiler.util.SimpleSet; > > class MethodVerifier15 extends MethodVerifier { > >@@ -528,6 +529,71 @@ > && inheritedMethod.returnType == existingMethod.returnType > && super.isInterfaceMethodImplemented(inheritedMethod, existingMethod, superType); > } >+SimpleSet findSuperinterfaceCollisions(ReferenceBinding superclass, ReferenceBinding[] superInterfaces) { >+ ReferenceBinding[] interfacesToVisit = null; >+ int nextPosition = 0; >+ ReferenceBinding[] itsInterfaces = superInterfaces; >+ if (itsInterfaces != Binding.NO_SUPERINTERFACES) { >+ nextPosition = itsInterfaces.length; >+ interfacesToVisit = itsInterfaces; >+ } >+ >+ ReferenceBinding superType = superclass; >+ while (superType != null && superType.isValidBinding()) { >+ if ((itsInterfaces = superType.superInterfaces()) != Binding.NO_SUPERINTERFACES) { >+ if (interfacesToVisit == null) { >+ interfacesToVisit = itsInterfaces; >+ nextPosition = interfacesToVisit.length; >+ } else { >+ int itsLength = itsInterfaces.length; >+ if (nextPosition + itsLength >= interfacesToVisit.length) >+ System.arraycopy(interfacesToVisit, 0, interfacesToVisit = new ReferenceBinding[nextPosition + itsLength + 5], 0, nextPosition); >+ nextInterface : for (int a = 0; a < itsLength; a++) { >+ ReferenceBinding next = itsInterfaces[a]; >+ for (int b = 0; b < nextPosition; b++) >+ if (next == interfacesToVisit[b]) continue nextInterface; >+ interfacesToVisit[nextPosition++] = next; >+ } >+ } >+ } >+ superType = superType.superclass(); >+ } >+ >+ for (int i = 0; i < nextPosition; i++) { >+ superType = interfacesToVisit[i]; >+ if (superType.isValidBinding()) { >+ if ((itsInterfaces = superType.superInterfaces()) != Binding.NO_SUPERINTERFACES) { >+ int itsLength = itsInterfaces.length; >+ if (nextPosition + itsLength >= interfacesToVisit.length) >+ System.arraycopy(interfacesToVisit, 0, interfacesToVisit = new ReferenceBinding[nextPosition + itsLength + 5], 0, nextPosition); >+ nextInterface : for (int a = 0; a < itsLength; a++) { >+ ReferenceBinding next = itsInterfaces[a]; >+ for (int b = 0; b < nextPosition; b++) >+ if (next == interfacesToVisit[b]) continue nextInterface; >+ interfacesToVisit[nextPosition++] = next; >+ } >+ } >+ } >+ } >+ >+ SimpleSet copy = null; >+ for (int i = 0; i < nextPosition; i++) { >+ ReferenceBinding current = interfacesToVisit[i]; >+ if (current.isValidBinding()) { >+ TypeBinding erasure = current.erasure(); >+ for (int j = i + 1; j < nextPosition; j++) { >+ ReferenceBinding next = interfacesToVisit[j]; >+ if (next.isValidBinding() && next.erasure() == erasure) { >+ if (copy == null) >+ copy = new SimpleSet(nextPosition); >+ copy.add(interfacesToVisit[i]); >+ copy.add(interfacesToVisit[j]); >+ } >+ } >+ } >+ } >+ return copy; >+} > boolean reportIncompatibleReturnTypeError(MethodBinding currentMethod, MethodBinding inheritedMethod) { > if (currentMethod.typeVariables == Binding.NO_TYPE_VARIABLES > && inheritedMethod.original().typeVariables != Binding.NO_TYPE_VARIABLES >Index: compiler/org/eclipse/jdt/internal/compiler/lookup/ClassScope.java >=================================================================== >RCS file: /home/eclipse/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/lookup/ClassScope.java,v >retrieving revision 1.136 >diff -u -r1.136 ClassScope.java >--- compiler/org/eclipse/jdt/internal/compiler/lookup/ClassScope.java 28 Apr 2006 14:53:28 -0000 1.136 >+++ compiler/org/eclipse/jdt/internal/compiler/lookup/ClassScope.java 19 May 2006 18:22:35 -0000 >@@ -625,36 +625,18 @@ > // check for parameterized interface collisions (when different parameterizations occur) > SourceTypeBinding sourceType = referenceContext.binding; > ReferenceBinding[] interfaces = sourceType.superInterfaces; >- int count = interfaces.length; > Map invocations = new HashMap(2); > ReferenceBinding itsSuperclass = sourceType.isInterface() ? null : sourceType.superclass; >- nextInterface: for (int i = 0, length = count; i < length; i++) { >+ nextInterface: for (int i = 0, length = interfaces.length; i < length; i++) { > ReferenceBinding one = interfaces[i]; > if (one == null) continue nextInterface; >- if (itsSuperclass != null && hasErasedCandidatesCollisions(itsSuperclass, one, invocations, sourceType, referenceContext)) { >- interfaces[i] = null; >- count--; >+ if (itsSuperclass != null && hasErasedCandidatesCollisions(itsSuperclass, one, invocations, sourceType, referenceContext)) > continue nextInterface; >- } > nextOtherInterface: for (int j = 0; j < i; j++) { > ReferenceBinding two = interfaces[j]; > if (two == null) continue nextOtherInterface; >- if (hasErasedCandidatesCollisions(one, two, invocations, sourceType, referenceContext)) { >- interfaces[i] = null; >- count--; >+ if (hasErasedCandidatesCollisions(one, two, invocations, sourceType, referenceContext)) > continue nextInterface; >- } >- } >- } >- if (count < interfaces.length) { >- if (count == 0) { >- sourceType.superInterfaces = Binding.NO_SUPERINTERFACES; >- } else { >- ReferenceBinding[] newInterfaceBindings = new ReferenceBinding[count]; >- for (int i = 0, j = 0, l = interfaces.length; i < l; i++) >- if (interfaces[i] != null) >- newInterfaceBindings[j++] = interfaces[i]; >- sourceType.superInterfaces = newInterfaceBindings; > } > } > >Index: compiler/org/eclipse/jdt/internal/compiler/lookup/MethodVerifier.java >=================================================================== >RCS file: /home/eclipse/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/lookup/MethodVerifier.java,v >retrieving revision 1.78 >diff -u -r1.78 MethodVerifier.java >--- compiler/org/eclipse/jdt/internal/compiler/lookup/MethodVerifier.java 2 May 2006 19:46:54 -0000 1.78 >+++ compiler/org/eclipse/jdt/internal/compiler/lookup/MethodVerifier.java 19 May 2006 18:22:35 -0000 >@@ -16,6 +16,7 @@ > import org.eclipse.jdt.internal.compiler.impl.CompilerOptions; > import org.eclipse.jdt.internal.compiler.problem.ProblemReporter; > import org.eclipse.jdt.internal.compiler.util.HashtableOfObject; >+import org.eclipse.jdt.internal.compiler.util.SimpleSet; > > public class MethodVerifier { > SourceTypeBinding type; >@@ -501,10 +502,13 @@ > } > superType = superType.superclass(); > } >+ if (nextPosition == 0) return; > >+ SimpleSet skip = findSuperinterfaceCollisions(superclass, superInterfaces); > for (int i = 0; i < nextPosition; i++) { > superType = interfacesToVisit[i]; > if (superType.isValidBinding()) { >+ if (skip != null && skip.includes(superType)) continue; > if ((itsInterfaces = superType.superInterfaces()) != Binding.NO_SUPERINTERFACES) { > int itsLength = itsInterfaces.length; > if (nextPosition + itsLength >= interfacesToVisit.length) >@@ -614,6 +618,9 @@ > reporter.referenceContext = currentMethod.sourceMethod(); > return reporter; > } >+SimpleSet findSuperinterfaceCollisions(ReferenceBinding superclass, ReferenceBinding[] superInterfaces) { >+ return null; // noop in 1.4 >+} > boolean reportIncompatibleReturnTypeError(MethodBinding currentMethod, MethodBinding inheritedMethod) { > problemReporter(currentMethod).incompatibleReturnType(currentMethod, inheritedMethod); > return true; >#P org.eclipse.jdt.core.tests.compiler >Index: src/org/eclipse/jdt/core/tests/compiler/regression/MethodVerifyTest.java >=================================================================== >RCS file: /home/eclipse/org.eclipse.jdt.core.tests.compiler/src/org/eclipse/jdt/core/tests/compiler/regression/MethodVerifyTest.java,v >retrieving revision 1.84 >diff -u -r1.84 MethodVerifyTest.java >--- src/org/eclipse/jdt/core/tests/compiler/regression/MethodVerifyTest.java 21 Apr 2006 22:11:46 -0000 1.84 >+++ src/org/eclipse/jdt/core/tests/compiler/regression/MethodVerifyTest.java 19 May 2006 18:22:41 -0000 >@@ -5057,4 +5057,42 @@ > "----------\n" > ); > } >+ // https://bugs.eclipse.org/bugs/show_bug.cgi?id=142653 - variation >+ public void test088() { >+ this.runNegativeTest( >+ new String[] { >+ "X.java",//=================== >+ "import java.util.*;\n" + >+ "public class X<T0> extends ArrayList<T0> implements I<T0>,Runnable {\n" + >+ " \n" + >+ " void foo() {\n" + >+ " this.add(new Object());\n" + >+ " this.add(null);\n" + >+ " }\n" + >+ "}\n" + >+ "interface I<T1> extends Collection<String> {\n" + >+ "}\n" , // =================, // ================= >+ }, >+ "----------\n" + >+ "1. ERROR in X.java (at line 2)\n" + >+ " public class X<T0> extends ArrayList<T0> implements I<T0>,Runnable {\n" + >+ " ^\n" + >+ "The interface Collection cannot be implemented more than once with different arguments: Collection<T0> and Collection<String>\n" + >+ "----------\n" + >+ "2. ERROR in X.java (at line 2)\n" + >+ " public class X<T0> extends ArrayList<T0> implements I<T0>,Runnable {\n" + >+ " ^\n" + >+ "The type X<T0> must implement the inherited abstract method Runnable.run()\n" + >+ "----------\n" + >+ "3. WARNING in X.java (at line 2)\n" + >+ " public class X<T0> extends ArrayList<T0> implements I<T0>,Runnable {\n" + >+ " ^\n" + >+ "The serializable class X does not declare a static final serialVersionUID field of type long\n" + >+ "----------\n" + >+ "4. ERROR in X.java (at line 5)\n" + >+ " this.add(new Object());\n" + >+ " ^^^\n" + >+ "The method add(T0) in the type ArrayList<T0> is not applicable for the arguments (Object)\n" + >+ "----------\n"); >+ } > } >Index: src/org/eclipse/jdt/core/tests/compiler/regression/GenericTypeTest.java >=================================================================== >RCS file: /home/eclipse/org.eclipse.jdt.core.tests.compiler/src/org/eclipse/jdt/core/tests/compiler/regression/GenericTypeTest.java,v >retrieving revision 1.492 >diff -u -r1.492 GenericTypeTest.java >--- src/org/eclipse/jdt/core/tests/compiler/regression/GenericTypeTest.java 18 May 2006 15:28:25 -0000 1.492 >+++ src/org/eclipse/jdt/core/tests/compiler/regression/GenericTypeTest.java 19 May 2006 18:22:41 -0000 >@@ -31228,4 +31228,110 @@ > "The return type is incompatible with AbstractEditPart.getViewer()\n" + > "----------\n"); > } >+// https://bugs.eclipse.org/bugs/show_bug.cgi?id=142653 >+public void test0989() { >+ this.runNegativeTest( >+ new String[] { >+ "Child.java",//=================== >+ "public class Child extends Parent<Object> {}\n" + >+ "abstract class Parent<T> extends Grandparent<T> implements IParent {}\n" + >+ "interface IParent<T> extends IGrandparent<T> {}\n" + >+ "abstract class Grandparent<T> implements IGrandparent<T> {}\n" + >+ "interface IGrandparent<T> {}", // =================, // ================= >+ }, >+ "----------\n" + >+ "1. ERROR in Child.java (at line 2)\n" + >+ " abstract class Parent<T> extends Grandparent<T> implements IParent {}\n" + >+ " ^^^^^^\n" + >+ "The interface IGrandparent cannot be implemented more than once with different arguments: IGrandparent<T> and IGrandparent\n" + >+ "----------\n" + >+ "2. WARNING in Child.java (at line 2)\n" + >+ " abstract class Parent<T> extends Grandparent<T> implements IParent {}\n" + >+ " ^^^^^^^\n" + >+ "IParent is a raw type. References to generic type IParent<T> should be parameterized\n" + >+ "----------\n"); >+} >+//https://bugs.eclipse.org/bugs/show_bug.cgi?id=142653 - variation >+public void test0990() { >+ this.runNegativeTest( >+ new String[] { >+ "Child.java",//=================== >+ "public class Child extends Parent<Object> {}\n" + >+ "abstract class Parent<T> extends Grandparent<T> implements IParent<?> {}\n" + >+ "interface IParent<T> extends IGrandparent<T> {}\n" + >+ "abstract class Grandparent<T> implements IGrandparent<T> {}\n" + >+ "interface IGrandparent<T> {}", // =================, // ================= >+ }, >+ "----------\n" + >+ "1. ERROR in Child.java (at line 1)\n" + >+ " public class Child extends Parent<Object> {}\n" + >+ " ^^^^^\n" + >+ "The hierarchy of the type Child is inconsistent\n" + >+ "----------\n" + >+ "2. ERROR in Child.java (at line 2)\n" + >+ " abstract class Parent<T> extends Grandparent<T> implements IParent<?> {}\n" + >+ " ^^^^^^^\n" + >+ "The type Parent cannot extend or implement IParent<?>. A supertype may not specify any wildcard\n" + >+ "----------\n"); >+} >+//https://bugs.eclipse.org/bugs/show_bug.cgi?id=142653 - variation >+public void test0991() { >+ this.runNegativeTest( >+ new String[] { >+ "X.java",//=================== >+ "public class X extends SX<String> implements IX<Object> {}\n" + >+ "class SX<T> extends TX<Thread> implements IX<T> {}\n" + >+ "class TX<U> implements IX<U> {}\n" + >+ "interface IX<V> {}\n", // =================, // ================= >+ }, >+ "----------\n" + >+ "1. ERROR in X.java (at line 1)\n" + >+ " public class X extends SX<String> implements IX<Object> {}\n" + >+ " ^\n" + >+ "The interface IX cannot be implemented more than once with different arguments: IX<Thread> and IX<Object>\n" + >+ "----------\n" + >+ "2. ERROR in X.java (at line 2)\n" + >+ " class SX<T> extends TX<Thread> implements IX<T> {}\n" + >+ " ^^\n" + >+ "The interface IX cannot be implemented more than once with different arguments: IX<Thread> and IX<T>\n" + >+ "----------\n"); >+} >+//https://bugs.eclipse.org/bugs/show_bug.cgi?id=142653 - variation >+public void test0992() { >+ this.runNegativeTest( >+ new String[] { >+ "X.java",//=================== >+ "import java.util.*;\n" + >+ "public abstract class X<T0> implements Collection, I<T0> {\n" + >+ " \n" + >+ " void foo() {\n" + >+ " this.add(new Object());\n" + >+ " this.add(null);\n" + >+ " }\n" + >+ "}\n" + >+ "interface I<T1> extends Collection<String> {\n" + >+ "}\n", // =================, // ================= >+ }, >+ "----------\n" + >+ "1. ERROR in X.java (at line 2)\n" + >+ " public abstract class X<T0> implements Collection, I<T0> {\n" + >+ " ^\n" + >+ "The interface Collection cannot be implemented more than once with different arguments: Collection<String> and Collection\n" + >+ "----------\n" + >+ "2. WARNING in X.java (at line 2)\n" + >+ " public abstract class X<T0> implements Collection, I<T0> {\n" + >+ " ^^^^^^^^^^\n" + >+ "Collection is a raw type. References to generic type Collection<E> should be parameterized\n" + >+ "----------\n" + >+ "3. WARNING in X.java (at line 5)\n" + >+ " this.add(new Object());\n" + >+ " ^^^^^^^^^^^^^^^^^^^^^^\n" + >+ "Type safety: The method add(Object) belongs to the raw type Collection. References to generic type Collection<E> should be parameterized\n" + >+ "----------\n" + >+ "4. WARNING in X.java (at line 6)\n" + >+ " this.add(null);\n" + >+ " ^^^^^^^^^^^^^^\n" + >+ "Type safety: The method add(Object) belongs to the raw type Collection. References to generic type Collection<E> should be parameterized\n" + >+ "----------\n"); >+} > }
You cannot view the attachment while viewing its details because your browser does not support IFRAMEs.
View the attachment on a separate page
.
View Attachment As Diff
View Attachment As Raw
Actions:
View
|
Diff
Attachments on
bug 142653
:
42000
|
42001
| 42060