Some Eclipse Foundation services are deprecated, or will be soon. Please ensure you've read this important communication.

Bug 330278

Summary: PackageFinder.findPackagesInClassFiles may produce invalid package names
Product: [Eclipse Project] PDE Reporter: Gunnar Wagenknecht <gunnar>
Component: UIAssignee: Curtis Windatt <curtis.windatt.public>
Status: VERIFIED FIXED QA Contact:
Severity: normal    
Priority: P3 CC: curtis.windatt.public
Version: 3.7Keywords: contributed
Target Milestone: 3.8 M1   
Hardware: All   
OS: All   
Whiteboard:
Bug Depends on:    
Bug Blocks: 330256    
Attachments:
Description Flags
patch for PackageFinder
none
patch for PackageFinder curtis.windatt.public: iplog+

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