Bug 102422 - Exception referencing class in large jar files
Summary: Exception referencing class in large jar files
Status: VERIFIED FIXED
Alias: None
Product: JDT
Classification: Eclipse Project
Component: Core (show other bugs)
Version: 3.1   Edit
Hardware: PC Windows XP
: P3 normal (vote)
Target Milestone: 3.1.1   Edit
Assignee: Jerome Lanneluc CLA
QA Contact:
URL:
Whiteboard:
Keywords:
: 110840 (view as bug list)
Depends on:
Blocks:
 
Reported: 2005-06-30 19:35 EDT by Carl McConnell CLA
Modified: 2005-09-30 11:42 EDT (History)
2 users (show)

See Also:


Attachments
Ensure that JarPackageFragmentRoot make it into the cache before its contents. (1.67 KB, patch)
2005-08-01 21:12 EDT, Theodora Yeung CLA
no flags Details | Diff

Note You need to log in before you can comment on or make changes to this bug.
Description Carl McConnell CLA 2005-06-30 19:35:00 EDT
(This is in 3.1 RC1.) The build path of a project in my workspace includes a 48
Mb jar with 30,000 files in it scattered among 1000-2000 packages. (The jar file
is proprietary so I can't attach it.) The Java editor frequently indicates that
references to classes in this jar cannot be resolved, even though the classes
are there. The attached stack trace shows what seems to be the root cause of
this behavior. (The JavaModelException is caught and ignored.)
Comment 1 Carl McConnell CLA 2005-06-30 19:41:23 EDT
Thread [Text Viewer Hover Presenter] (Suspended (breakpoint at line 468 in
JavaElement))
	JarPackageFragment(JavaElement).newNotPresentException() line: 468
	JarPackageFragment(JavaElement).openWhenClosed(Object, IProgressMonitor) line: 499
	JarPackageFragment(JavaElement).getElementInfo(IProgressMonitor) line: 232
	JarPackageFragment(JavaElement).getElementInfo() line: 218
	JarPackageFragment(JavaElement).getChildren() line: 173
	JarPackageFragment(JavaElement).getChildrenOfType(int) line: 187
	JarPackageFragment.getClassFiles() line: 120
	NameLookup.seekTypesInBinaryPackage(String, IPackageFragment, boolean, int,
IJavaElementRequestor) line: 792
	NameLookup.seekTypes(String, IPackageFragment, boolean, int,
IJavaElementRequestor) line: 769
	NameLookup.findType(String, IPackageFragment, boolean, int) line: 542
	NameLookup.findType(String, String, boolean, int) line: 501
	SearchableEnvironment.find(String, String) line: 85
	SearchableEnvironment.findType(char[], char[][]) line: 188
	LookupEnvironment.askForType(PackageBinding, char[]) line: 119
	PackageBinding.getTypeOrPackage(char[]) line: 178
	ClassScope(Scope).getPackage(char[][]) line: 2211
	QualifiedTypeReference.getTypeBinding(Scope) line: 62
	QualifiedTypeReference(TypeReference).resolveType(ClassScope) line: 141
	QualifiedTypeReference(TypeReference).resolveSuperType(ClassScope) line: 104
	ClassScope.findSupertype(TypeReference) line: 1072
	ClassScope.connectSuperclass() line: 741
	ClassScope.connectTypeHierarchy() line: 878
	CompilationUnitScope.connectTypeHierarchy() line: 274
	LookupEnvironment.completeTypeBindings(CompilationUnitDeclaration, boolean)
line: 250
	SelectionEngine.select(ICompilationUnit, int, int) line: 657
	CompilationUnit(Openable).codeSelect(ICompilationUnit, int, int,
WorkingCopyOwner) line: 165
	CompilationUnit.codeSelect(int, int, WorkingCopyOwner) line: 314
	CompilationUnit.codeSelect(int, int) line: 308
	JavadocHover(AbstractJavaEditorTextHover).getHoverInfo(ITextViewer, IRegion)
line: 110
	BestMatchHover.getHoverInfo(ITextViewer, IRegion) line: 102
	JavaEditorTextHoverProxy.getHoverInfo(ITextViewer, IRegion) line: 69
	TextViewerHoverManager$4.run() line: 160
Comment 2 Carl McConnell CLA 2005-07-11 15:09:21 EDT
FWIW, to me this looked like a bug in JavaModelCache and friends: the huge jar
file gets dropped from the cache, and isn't correctly brought back in when needed.
Comment 3 Carl McConnell CLA 2005-07-11 15:21:59 EDT
As supporting evidence, I forgot to mention that when I reduced the size of the
jar file from 48 Mb to 36 Mb by removing unneeded stuff, the problem went away.
Comment 4 Jess Garms CLA 2005-07-28 16:50:00 EDT
I've been working on getting to the root of this problem, and have found
something interesting: if the jar is uncompressed, the problem appears to go
away. Carl, could you give this a try?

Also, though we can't attach the proprietary jar directly, we can provide it
directly to a JDT member working on this bug.
Comment 5 Carl McConnell CLA 2005-07-28 20:50:42 EDT
Yep, exploding the jar made the problem go away for me.
Comment 6 Theodora Yeung CLA 2005-08-01 21:12:48 EDT
Created attachment 25542 [details]
Ensure that JarPackageFragmentRoot make it into the cache before its contents. 

The problem is believed to reside in the LRU package cache. When a
JarPackageFragment is flushed from the cache before its root
(JarPackageFragmentRoot) is added to the cache, the cache will be left in an
inconsistent state. 

Do not quite understand why the problem does not occur with an uncompressed
jar. Could be related to the hash code though.
Comment 7 Jerome Lanneluc CLA 2005-08-17 09:53:39 EDT
Patch is good. Released it in both HEAD and 3.1 maintenance branches.
Thanks a lot for investigating and providing the patch Theodora.

Note it is not possible to write a regression test as the bug is dependent on
the implementation of HashMap.
Comment 8 David Audel CLA 2005-09-21 09:08:18 EDT
Verified in I20050920-0010 for 3.2M2.
Verified by looking code.
Comment 9 Olivier Thomann CLA 2005-09-26 10:39:44 EDT
Verified for 3.1.1 using M20050923-1430.
Comment 10 Jerome Lanneluc CLA 2005-09-30 11:42:18 EDT
*** Bug 110840 has been marked as a duplicate of this bug. ***