Some Eclipse Foundation services are deprecated, or will be soon. Please ensure you've read this important communication.
Bug 330278 - PackageFinder.findPackagesInClassFiles may produce invalid package names
Summary: PackageFinder.findPackagesInClassFiles may produce invalid package names
Status: VERIFIED FIXED
Alias: None
Product: PDE
Classification: Eclipse Project
Component: UI (show other bugs)
Version: 3.7   Edit
Hardware: All All
: P3 normal (vote)
Target Milestone: 3.8 M1   Edit
Assignee: Curtis Windatt CLA
QA Contact:
URL:
Whiteboard:
Keywords: contributed
Depends on:
Blocks: 330256
  Show dependency tree
 
Reported: 2010-11-15 14:53 EST by Gunnar Wagenknecht CLA
Modified: 2011-08-04 17:00 EDT (History)
1 user (show)

See Also:


Attachments
patch for PackageFinder (5.06 KB, patch)
2010-11-15 15:12 EST, Gunnar Wagenknecht CLA
no flags Details | Diff
patch for PackageFinder (5.08 KB, patch)
2010-11-15 15:21 EST, Gunnar Wagenknecht CLA
curtis.windatt.public: iplog+
Details | Diff

Note You need to log in before you can comment on or make changes to this bug.
Description Gunnar Wagenknecht CLA 2010-11-15 14:53:50 EST
While working on bug 330256 I noticed some weird package names when scanning for dependencies in binary class files. I traced it down to org.eclipse.pde.internal.ui.search.dependencies.PackageFinder.findPackagesInClassFiles(IClassFile[], IProgressMonitor).

Here is the call stack:

PackageFinder.getPackage(String) line: 185	
PackageFinder.computeReferencedTypes(IClassFileReader, Set) line: 82	
PackageFinder.findPackagesInClassFiles(IClassFile[], IProgressMonitor) line: 34	
OrganizeManifestsProcessor$2(AddNewBinaryDependenciesOperation).findSecondaryDependencies(String[], Set, Map, Set, IBundle, boolean, IProgressMonitor) line: 40	
OrganizeManifestsProcessor$2(AddNewDependenciesOperation).execute(IProgressMonitor) line: 84	
...

The root cause seems to be in #extractFullyQualifiedType().

example input:
  extractFullyQualifiedType("Lcom/abc/MyClass$1;")

resulting output:
  "new com.abc$MyClass(){}"
Comment 1 Gunnar Wagenknecht CLA 2010-11-15 15:12:10 EST
Created attachment 183158 [details]
patch for PackageFinder

Anonymous as well as inner classes aren't relevant for the package scanning. I therefor changed the implementation to remove everything after the '$' and renamed the methods to better indicate the intent.
Comment 2 Gunnar Wagenknecht CLA 2010-11-15 15:21:21 EST
Created attachment 183159 [details]
patch for PackageFinder

updated patch
Comment 3 Curtis Windatt CLA 2011-07-13 17:10:09 EDT
At first I was concerned with changing the result of the method.  However, in all cases we only care about the package.  There might be some optimizing that could be done here, but the patch corrects the problem as described.

Fixed in HEAD.
Comment 4 Curtis Windatt CLA 2011-08-04 17:00:53 EDT
Verified in I20110802-2000