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 42948 Details for
Bug 143259
[1.5][compiler] NullPointerException in ReferenceBinding.binarySearch , Eclipse 3.2RC4
Home
|
New
|
Browse
|
Search
|
[?]
|
Reports
|
Requests
|
Help
|
Log In
[x]
|
Terms of Use
|
Copyright Agent
[patch]
Better patch
143259.txt (text/plain), 12.29 KB, created by
Philipe Mulet
on 2006-05-30 09:35:37 EDT
(
hide
)
Description:
Better patch
Filename:
MIME Type:
Creator:
Philipe Mulet
Created:
2006-05-30 09:35:37 EDT
Size:
12.29 KB
patch
obsolete
>### Eclipse Workspace Patch 1.0 >#P org.eclipse.jdt.core >Index: compiler/org/eclipse/jdt/internal/compiler/lookup/SourceTypeBinding.java >=================================================================== >RCS file: /cvsroot/eclipse/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/lookup/SourceTypeBinding.java,v >retrieving revision 1.136 >diff -u -r1.136 SourceTypeBinding.java >--- compiler/org/eclipse/jdt/internal/compiler/lookup/SourceTypeBinding.java 28 Apr 2006 14:53:28 -0000 1.136 >+++ compiler/org/eclipse/jdt/internal/compiler/lookup/SourceTypeBinding.java 30 May 2006 13:37:08 -0000 >@@ -591,6 +591,7 @@ > return this.fields; > > int failed = 0; >+ FieldBinding[] resolvedFields = this.fields; > try { > // lazily sort fields > if ((this.tagBits & TagBits.AreFieldsSorted) == 0) { >@@ -598,24 +599,28 @@ > if (length > 1) > ReferenceBinding.sortFields(this.fields, 0, length); > this.tagBits |= TagBits.AreFieldsSorted; >- } >+ } > for (int i = 0, length = this.fields.length; i < length; i++) { > if (resolveTypeFor(this.fields[i]) == null) { >- this.fields[i] = null; >+ // do not alter original field array until resolution is over, due to reentrance (143259) >+ if (resolvedFields == this.fields) { >+ System.arraycopy(this.fields, 0, resolvedFields = new FieldBinding[length], 0, length); >+ } >+ resolvedFields[i] = null; > failed++; > } > } > } finally { > if (failed > 0) { > // ensure fields are consistent reqardless of the error >- int newSize = this.fields.length - failed; >+ int newSize = resolvedFields.length - failed; > if (newSize == 0) > return this.fields = Binding.NO_FIELDS; > > FieldBinding[] newFields = new FieldBinding[newSize]; >- for (int i = 0, j = 0, length = this.fields.length; i < length; i++) { >- if (this.fields[i] != null) >- newFields[j++] = this.fields[i]; >+ for (int i = 0, j = 0, length = resolvedFields.length; i < length; i++) { >+ if (resolvedFields[i] != null) >+ newFields[j++] = resolvedFields[i]; > } > this.fields = newFields; > } >@@ -1088,10 +1093,15 @@ > } > > int failed = 0; >+ MethodBinding[] resolvedMethods = this.methods; > try { > for (int i = 0, length = this.methods.length; i < length; i++) { > if (resolveTypesFor(this.methods[i]) == null) { >- this.methods[i] = null; // unable to resolve parameters >+ // do not alter original method array until resolution is over, due to reentrance (143259) >+ if (resolvedMethods == this.methods) { >+ System.arraycopy(this.methods, 0, resolvedMethods = new MethodBinding[length], 0, length); >+ } >+ resolvedMethods[i] = null; // unable to resolve parameters > failed++; > } > } >@@ -1099,13 +1109,13 @@ > // find & report collision cases > boolean complyTo15 = this.scope.compilerOptions().sourceLevel >= ClassFileConstants.JDK1_5; > for (int i = 0, length = this.methods.length; i < length; i++) { >- MethodBinding method = this.methods[i]; >+ MethodBinding method = resolvedMethods[i]; > if (method == null) > continue; > char[] selector = method.selector; > AbstractMethodDeclaration methodDecl = null; > nextSibling: for (int j = i + 1; j < length; j++) { >- MethodBinding method2 = this.methods[j]; >+ MethodBinding method2 = resolvedMethods[j]; > if (method2 == null) > continue nextSibling; > if (!CharOperation.equals(selector, method2.selector)) >@@ -1176,7 +1186,11 @@ > this.scope.problemReporter().duplicateMethodInType(this, methodDecl); > } > methodDecl.binding = null; >- this.methods[i] = null; >+ // do not alter original method array until resolution is over, due to reentrance (143259) >+ if (resolvedMethods == this.methods) { >+ System.arraycopy(this.methods, 0, resolvedMethods = new MethodBinding[length], 0, length); >+ } >+ resolvedMethods[i] = null; > failed++; > } > } >@@ -1188,26 +1202,34 @@ > this.scope.problemReporter().duplicateMethodInType(this, method2Decl); > } > method2Decl.binding = null; >- this.methods[j] = null; >+ // do not alter original method array until resolution is over, due to reentrance (143259) >+ if (resolvedMethods == this.methods) { >+ System.arraycopy(this.methods, 0, resolvedMethods = new MethodBinding[length], 0, length); >+ } >+ resolvedMethods[j] = null; > failed++; > } > } > if (method.returnType == null && methodDecl == null) { // forget method with invalid return type... was kept to detect possible collisions > method.sourceMethod().binding = null; >- this.methods[i] = null; >+ // do not alter original method array until resolution is over, due to reentrance (143259) >+ if (resolvedMethods == this.methods) { >+ System.arraycopy(this.methods, 0, resolvedMethods = new MethodBinding[length], 0, length); >+ } >+ resolvedMethods[i] = null; > failed++; > } > } > } finally { > if (failed > 0) { >- int newSize = this.methods.length - failed; >+ int newSize = resolvedMethods.length - failed; > if (newSize == 0) { > this.methods = Binding.NO_METHODS; > } else { > MethodBinding[] newMethods = new MethodBinding[newSize]; >- for (int i = 0, j = 0, length = this.methods.length; i < length; i++) >- if (this.methods[i] != null) >- newMethods[j++] = this.methods[i]; >+ for (int i = 0, j = 0, length = resolvedMethods.length; i < length; i++) >+ if (resolvedMethods[i] != null) >+ newMethods[j++] = resolvedMethods[i]; > this.methods = newMethods; > } > } >@@ -1249,17 +1271,17 @@ > field.type = fieldType; > field.modifiers &= ~ExtraCompilerModifiers.AccUnresolved; > if (fieldType == null) { >- fieldDecls[f].binding = null; >+ fieldDecl.binding = null; > return null; > } > if (fieldType == TypeBinding.VOID) { >- this.scope.problemReporter().variableTypeCannotBeVoid(fieldDecls[f]); >- fieldDecls[f].binding = null; >+ this.scope.problemReporter().variableTypeCannotBeVoid(fieldDecl); >+ fieldDecl.binding = null; > return null; > } > if (fieldType.isArrayType() && ((ArrayBinding) fieldType).leafComponentType == TypeBinding.VOID) { >- this.scope.problemReporter().variableTypeCannotBeVoidArray(fieldDecls[f]); >- fieldDecls[f].binding = null; >+ this.scope.problemReporter().variableTypeCannotBeVoidArray(fieldDecl); >+ fieldDecl.binding = null; > return null; > } > TypeBinding leafType = fieldType.leafComponentType(); >#P org.eclipse.jdt.core.tests.compiler >Index: src/org/eclipse/jdt/core/tests/compiler/regression/AnnotationTest.java >=================================================================== >RCS file: /cvsroot/eclipse/org.eclipse.jdt.core.tests.compiler/src/org/eclipse/jdt/core/tests/compiler/regression/AnnotationTest.java,v >retrieving revision 1.151.2.2 >diff -u -r1.151.2.2 AnnotationTest.java >--- src/org/eclipse/jdt/core/tests/compiler/regression/AnnotationTest.java 29 May 2006 15:56:19 -0000 1.151.2.2 >+++ src/org/eclipse/jdt/core/tests/compiler/regression/AnnotationTest.java 30 May 2006 13:37:12 -0000 >@@ -6644,4 +6644,175 @@ > "The annotation type X cannot override the method Annotation.toString()\n" + > "----------\n"); > } >+//https://bugs.eclipse.org/bugs/show_bug.cgi?id=143259 >+public void test202() { >+ this.runNegativeTest( >+ new String[] { >+ "X.java", >+ " public class X {\n" + >+ " @Ann(m=Object)\n" + >+ " private int foo;\n" + >+ " private NonExisting bar;\n" + >+ " }\n" + >+ " @interface Ann {\n" + >+ " String m();\n" + >+ " }\n", >+ }, >+ "----------\n" + >+ "1. ERROR in X.java (at line 2)\n" + >+ " @Ann(m=Object)\n" + >+ " ^^^^^^\n" + >+ "Object cannot be resolved\n" + >+ "----------\n" + >+ "2. ERROR in X.java (at line 4)\n" + >+ " private NonExisting bar;\n" + >+ " ^^^^^^^^^^^\n" + >+ "NonExisting cannot be resolved to a type\n" + >+ "----------\n"); >+} >+//https://bugs.eclipse.org/bugs/show_bug.cgi?id=143259 - variation >+public void test203() { >+ this.runNegativeTest( >+ new String[] { >+ "X.java", >+ "public class X {\n" + >+ " @Ann(m=Object())\n" + >+ " private void foo(){}\n" + >+ " private NonExisting bar(){}\n" + >+ "}\n" + >+ "@interface Ann {\n" + >+ " String m();\n" + >+ "}\n", >+ }, >+ "----------\n" + >+ "1. ERROR in X.java (at line 2)\n" + >+ " @Ann(m=Object())\n" + >+ " ^^^^^^\n" + >+ "The method Object() is undefined for the type X\n" + >+ "----------\n" + >+ "2. ERROR in X.java (at line 4)\n" + >+ " private NonExisting bar(){}\n" + >+ " ^^^^^^^^^^^\n" + >+ "NonExisting cannot be resolved to a type\n" + >+ "----------\n"); >+} >+//https://bugs.eclipse.org/bugs/show_bug.cgi?id=143259 - variation >+public void test204() { >+ this.runNegativeTest( >+ new String[] { >+ "X.java", >+ "public class X {\n" + >+ " @Ann(m=bar(null))\n" + >+ " private void foo(){}\n" + >+ " private NonExisting bar(NonExisting ne){}\n" + >+ "}\n" + >+ "@interface Ann {\n" + >+ " String m();\n" + >+ "}\n", >+ }, >+ "----------\n" + >+ "1. ERROR in X.java (at line 2)\n" + >+ " @Ann(m=bar(null))\n" + >+ " ^^^\n" + >+ "The method bar(null) is undefined for the type X\n" + >+ "----------\n" + >+ "2. ERROR in X.java (at line 4)\n" + >+ " private NonExisting bar(NonExisting ne){}\n" + >+ " ^^^^^^^^^^^\n" + >+ "NonExisting cannot be resolved to a type\n" + >+ "----------\n" + >+ "3. ERROR in X.java (at line 4)\n" + >+ " private NonExisting bar(NonExisting ne){}\n" + >+ " ^^^^^^^^^^^\n" + >+ "NonExisting cannot be resolved to a type\n" + >+ "----------\n"); >+} >+//https://bugs.eclipse.org/bugs/show_bug.cgi?id=143259 - variation >+public void test205() { >+ this.runNegativeTest( >+ new String[] { >+ "X.java", >+ "public class X {\n" + >+ " @Ann(m=foo())\n" + >+ " private void foo(){}\n" + >+ " private NonExisting bar(NonExisting ne){}\n" + >+ "}\n" + >+ "@interface Ann {\n" + >+ " String m();\n" + >+ "}\n", >+ }, >+ "----------\n" + >+ "1. ERROR in X.java (at line 2)\n" + >+ " @Ann(m=foo())\n" + >+ " ^^^^^\n" + >+ "Type mismatch: cannot convert from void to String\n" + >+ "----------\n" + >+ "2. ERROR in X.java (at line 4)\n" + >+ " private NonExisting bar(NonExisting ne){}\n" + >+ " ^^^^^^^^^^^\n" + >+ "NonExisting cannot be resolved to a type\n" + >+ "----------\n" + >+ "3. ERROR in X.java (at line 4)\n" + >+ " private NonExisting bar(NonExisting ne){}\n" + >+ " ^^^^^^^^^^^\n" + >+ "NonExisting cannot be resolved to a type\n" + >+ "----------\n"); >+} >+//https://bugs.eclipse.org/bugs/show_bug.cgi?id=143259 - variation >+public void test206() { >+ this.runNegativeTest( >+ new String[] { >+ "X.java", >+ "public class X {\n" + >+ " @Ann(m=bar())\n" + >+ " private void foo(){}\n" + >+ " private NonExisting bar(){}\n" + >+ "}\n" + >+ "@interface Ann {\n" + >+ " String m();\n" + >+ "}\n", >+ }, >+ "----------\n" + >+ "1. ERROR in X.java (at line 2)\n" + >+ " @Ann(m=bar())\n" + >+ " ^^^\n" + >+ "The method bar() is undefined for the type X\n" + >+ "----------\n" + >+ "2. ERROR in X.java (at line 4)\n" + >+ " private NonExisting bar(){}\n" + >+ " ^^^^^^^^^^^\n" + >+ "NonExisting cannot be resolved to a type\n" + >+ "----------\n"); >+} >+//https://bugs.eclipse.org/bugs/show_bug.cgi?id=143259 - variation >+public void test207() { >+ this.runNegativeTest( >+ new String[] { >+ "X.java", >+ " public class X {\n" + >+ "@Ann(m=foo)\n" + >+ " private NonExisting foo;\n" + >+ " private NonExisting bar;\n" + >+ " }\n" + >+ " @interface Ann {\n" + >+ " String m();\n" + >+ " }\n", >+ }, >+ "----------\n" + >+ "1. ERROR in X.java (at line 2)\n" + >+ " @Ann(m=foo)\n" + >+ " ^^^\n" + >+ "foo cannot be resolved\n" + >+ "----------\n" + >+ "2. ERROR in X.java (at line 3)\n" + >+ " private NonExisting foo;\n" + >+ " ^^^^^^^^^^^\n" + >+ "NonExisting cannot be resolved to a type\n" + >+ "----------\n" + >+ "3. ERROR in X.java (at line 4)\n" + >+ " private NonExisting bar;\n" + >+ " ^^^^^^^^^^^\n" + >+ "NonExisting cannot be resolved to a type\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 143259
:
42281
|
42299
|
42301
|
42942
| 42948