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 162740 Details for
Bug 306196
[search] NPE while searching for annotation references in rt.jar of JRE 6.0
Home
|
New
|
Browse
|
Search
|
[?]
|
Reports
|
Requests
|
Help
|
Log In
[x]
|
Terms of Use
|
Copyright Agent
[patch]
Proposed patch
patch1.txt (text/plain), 8.21 KB, created by
Satyam Kandula
on 2010-03-23 01:25:46 EDT
(
hide
)
Description:
Proposed patch
Filename:
MIME Type:
Creator:
Satyam Kandula
Created:
2010-03-23 01:25:46 EDT
Size:
8.21 KB
patch
obsolete
>### Eclipse Workspace Patch 1.0 >#P org.eclipse.jdt.core >Index: search/org/eclipse/jdt/internal/core/search/matching/MatchLocator.java >=================================================================== >RCS file: /cvsroot/eclipse/org.eclipse.jdt.core/search/org/eclipse/jdt/internal/core/search/matching/MatchLocator.java,v >retrieving revision 1.329 >diff -u -r1.329 MatchLocator.java >--- search/org/eclipse/jdt/internal/core/search/matching/MatchLocator.java 1 Dec 2009 10:45:48 -0000 1.329 >+++ search/org/eclipse/jdt/internal/core/search/matching/MatchLocator.java 22 Mar 2010 14:09:44 -0000 >@@ -1,5 +1,5 @@ > /******************************************************************************* >- * Copyright (c) 2000, 2009 IBM Corporation and others. >+ * Copyright (c) 2000, 2010 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 >@@ -436,48 +436,48 @@ > // fall thru if its a constructor with a synthetic argument... find it the slower way > ClassFileReader reader = classFileReader(type); > if (reader != null) { >- IBinaryMethod[] methods = reader.getMethods(); >- if (methods != null) { >- // build arguments names >- boolean firstIsSynthetic = false; >- if (reader.isMember() && method.isConstructor() && !Flags.isStatic(reader.getModifiers())) { // see https://bugs.eclipse.org/bugs/show_bug.cgi?id=48261 >- firstIsSynthetic = true; >- argCount++; >- } >- char[][] argumentTypeNames = new char[argCount][]; >- for (int i = 0; i < argCount; i++) { >- char[] typeName = null; >- if (i == 0 && firstIsSynthetic) { >- typeName = type.getDeclaringType().getFullyQualifiedName().toCharArray(); >- } else if (arguments != null) { >- TypeReference typeRef = arguments[firstIsSynthetic ? i - 1 : i].type; >- typeName = CharOperation.concatWith(typeRef.getTypeName(), '.'); >- for (int k = 0, dim = typeRef.dimensions(); k < dim; k++) >- typeName = CharOperation.concat(typeName, new char[] {'[', ']'}); >- } >- if (typeName == null) { >- // invalid type name >- return null; >- } >- argumentTypeNames[i] = typeName; >- } >- >- // return binary method >- IMethod binaryMethod = createBinaryMethodHandle(type, method.selector, argumentTypeNames); >- if (binaryMethod == null) { >- // when first attempt fails, try with similar matches if any... >- PossibleMatch similarMatch = this.currentPossibleMatch.getSimilarMatch(); >- while (similarMatch != null) { >- type = ((ClassFile)similarMatch.openable).getType(); >- binaryMethod = createBinaryMethodHandle(type, method.selector, argumentTypeNames); >- if (binaryMethod != null) { >- return binaryMethod; >- } >- similarMatch = similarMatch.getSimilarMatch(); >+ // build arguments names >+ boolean firstIsSynthetic = false; >+ if (reader.isMember() && method.isConstructor() && !Flags.isStatic(reader.getModifiers())) { // see https://bugs.eclipse.org/bugs/show_bug.cgi?id=48261 >+ firstIsSynthetic = true; >+ argCount++; >+ } >+ char[][] argumentTypeNames = new char[argCount][]; >+ for (int i = 0; i < argCount; i++) { >+ char[] typeName = null; >+ if (i == 0 && firstIsSynthetic) { >+ typeName = type.getDeclaringType().getFullyQualifiedName().toCharArray(); >+ } else if (arguments != null) { >+ TypeReference typeRef = arguments[firstIsSynthetic ? i - 1 : i].type; >+ typeName = CharOperation.concatWith(typeRef.getTypeName(), '.'); >+ for (int k = 0, dim = typeRef.dimensions(); k < dim; k++) >+ typeName = CharOperation.concat(typeName, new char[] {'[', ']'}); >+ } >+ if (typeName == null) { >+ // invalid type name >+ return null; >+ } >+ argumentTypeNames[i] = typeName; >+ } >+ // return binary method >+ IMethod binaryMethod = createBinaryMethodHandle(type, method.selector, argumentTypeNames); >+ if (binaryMethod == null) { >+ // when first attempt fails, try with similar matches if any... >+ PossibleMatch similarMatch = this.currentPossibleMatch.getSimilarMatch(); >+ while (similarMatch != null) { >+ type = ((ClassFile)similarMatch.openable).getType(); >+ binaryMethod = createBinaryMethodHandle(type, method.selector, argumentTypeNames); >+ if (binaryMethod != null) { >+ return binaryMethod; > } >+ similarMatch = similarMatch.getSimilarMatch(); > } >- return binaryMethod; > } >+ return binaryMethod; >+ } >+ if (BasicSearchEngine.VERBOSE) { >+ System.out.println("Not able to createHandle for the method " + //$NON-NLS-1$ >+ CharOperation.charToString(method.selector) + " May miss some results"); //$NON-NLS-1$ > } > return null; > } >@@ -2145,7 +2145,9 @@ > if (enclosingElement == null) { > enclosingElement = createHandle(method, parent); > } >- reportMatching(typeParameters, enclosingElement, parent, method.binding, nodeSet); >+ if (enclosingElement != null) { >+ reportMatching(typeParameters, enclosingElement, parent, method.binding, nodeSet); >+ } > } > > // report annotations >@@ -2153,7 +2155,9 @@ > if (enclosingElement == null) { > enclosingElement = createHandle(method, parent); > } >- reportMatching(method.annotations, enclosingElement, null, method.binding, nodeSet, true, true); >+ if (enclosingElement != null) { >+ reportMatching(method.annotations, enclosingElement, null, method.binding, nodeSet, true, true); >+ } > } > > // references in this method >#P org.eclipse.jdt.core.tests.model >Index: src/org/eclipse/jdt/core/tests/model/JavaSearchBugsTests.java >=================================================================== >RCS file: /cvsroot/eclipse/org.eclipse.jdt.core.tests.model/src/org/eclipse/jdt/core/tests/model/JavaSearchBugsTests.java,v >retrieving revision 1.191 >diff -u -r1.191 JavaSearchBugsTests.java >--- src/org/eclipse/jdt/core/tests/model/JavaSearchBugsTests.java 8 Mar 2010 14:27:50 -0000 1.191 >+++ src/org/eclipse/jdt/core/tests/model/JavaSearchBugsTests.java 22 Mar 2010 14:09:54 -0000 >@@ -11533,4 +11533,37 @@ > getWorkspace().setDescription(preferences); > } > } >+ >+/** >+ * @bug 288174: [search] NPE while searching for annotation references in >+ * rt.jar of JRE 6.0 >+ * @test Ensure that no NPE occurs when searching for both ANNOTATION_TYPE >+ * and TYPE references from an inner enum declared in a binary type. >+ * This same test also ensures that there is no NPE even if the source >+ * has a method that does not exist in the class file. >+ * @see "https://bugs.eclipse.org/bugs/show_bug.cgi?id=306196" >+ */ >+public void testBug306196() throws Exception { >+ final String libPath = "/JavaSearchBugs/lib/b306196.jar"; >+ addLibraryEntry(JAVA_PROJECT, libPath, false); >+ try { >+ IPackageFragmentRoot root = getPackageFragmentRoot(libPath); >+ IJavaSearchScope scope = SearchEngine.createJavaSearchScope(new IJavaElement[] { root }); >+ SearchPattern leftPattern = createPattern("*", ANNOTATION_TYPE, REFERENCES, false); >+ SearchPattern rightPattern = createPattern("*", TYPE, REFERENCES, false); >+ new SearchEngine().search(SearchPattern.createOrPattern( leftPattern, rightPattern), >+ new SearchParticipant[] { SearchEngine.getDefaultSearchParticipant() }, scope, >+ this.resultCollector, null); >+ assertSearchResults("lib/b306196.jar java.lang.String pkg.<anonymous>.aFunc(java.lang.Object) EXACT_MATCH\n" >+ + "lib/b306196.jar java.lang.String pkg.<anonymous>.aFunc(java.lang.Object) EXACT_MATCH\n" >+ + "lib/b306196.jar java.lang.String pkg.<anonymous>.aFunc(java.lang.Object) EXACT_MATCH\n" >+ + "lib/b306196.jar java.lang.String pkg.<anonymous>.aFunc(java.lang.Object) EXACT_MATCH\n" >+ + "lib/b306196.jar java.lang.String pkg.<anonymous>.aFunc(java.lang.Object) EXACT_MATCH\n" >+ + "lib/b306196.jar java.lang.String pkg.<anonymous>.aFunc(java.lang.Object) EXACT_MATCH\n" >+ + "lib/b306196.jar java.lang.String pkg.B306196$anEnum.aFunc(java.lang.Object) EXACT_MATCH\n" >+ + "lib/b306196.jar java.lang.String pkg.B306196$anEnum.aFunc(java.lang.Object) EXACT_MATCH"); >+ } finally { >+ removeClasspathEntry(JAVA_PROJECT, new Path(libPath)); >+ } >+} > } >\ No newline at end of file
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
Flags:
frederic_fusier
:
iplog+
frederic_fusier
:
review+
Actions:
View
|
Diff
Attachments on
bug 306196
:
162301
| 162740 |
162741