Bug 32392 - NPE in SourceMapper
Summary: NPE in SourceMapper
Status: VERIFIED FIXED
Alias: None
Product: JDT
Classification: Eclipse Project
Component: Core (show other bugs)
Version: 2.1   Edit
Hardware: PC Windows 2000
: P3 normal (vote)
Target Milestone: 2.1 RC2   Edit
Assignee: Olivier Thomann CLA
QA Contact:
URL:
Whiteboard:
Keywords:
Depends on:
Blocks:
 
Reported: 2003-02-20 14:56 EST by Darin Wright CLA
Modified: 2003-03-10 11:52 EST (History)
0 users

See Also:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Darin Wright CLA 2003-02-20 14:56:51 EST
I'm not sure exactly what I did, but this appeared in my console:

java.lang.NullPointerException
	at org.eclipse.jdt.internal.core.SourceMapper.enterClass
(SourceMapper.java:389)
	at 
org.eclipse.jdt.internal.compiler.SourceElementParser.notifySourceElementRequest
or(SourceElementParser.java:922)
	at 
org.eclipse.jdt.internal.compiler.SourceElementParser.notifySourceElementRequest
or(SourceElementParser.java:600)
	at 
org.eclipse.jdt.internal.compiler.SourceElementParser.parseCompilationUnit
(SourceElementParser.java:1062)
	at org.eclipse.jdt.internal.core.SourceMapper.mapSource
(SourceMapper.java:978)
	at org.eclipse.jdt.internal.core.SourceMapper.mapSource
(SourceMapper.java:923)
	at org.eclipse.jdt.internal.core.ClassFile.openBuffer
(ClassFile.java:407)
	at org.eclipse.jdt.internal.core.Openable.getBuffer(Openable.java:192)
	at org.eclipse.jdt.internal.corext.javadoc.JavaDocAccess.getJavaDoc
(JavaDocAccess.java:38)
	at org.eclipse.jdt.internal.ui.text.java.hover.JavadocHover.getHoverInfo
(JavadocHover.java:62)
	at 
org.eclipse.jdt.internal.ui.text.java.hover.AbstractJavaEditorTextHover.getHover
Info(AbstractJavaEditorTextHover.java:98)
	at 
org.eclipse.jdt.internal.ui.text.java.hover.BestMatchHover.getHoverInfo
(BestMatchHover.java:130)
	at 
org.eclipse.jdt.internal.ui.text.java.hover.JavaEditorTextHoverProxy.getHoverInf
o(JavaEditorTextHoverProxy.java:72)
	at org.eclipse.jface.text.TextViewerHoverManager$2.run
(TextViewerHoverManager.java:108)
Comment 1 Olivier Thomann CLA 2003-02-20 15:13:27 EST
Would you have the name of the .class file you tried to open? This is not a new 
problem (related to latest changes for better root path inference).
Comment 2 Olivier Thomann CLA 2003-02-20 15:23:20 EST
Do you remember what you did? I don't understand how the types collection can 
be null on the line I see in the stack trace.
It might be a concurrency problem. I need to find out if this is possible.
Comment 3 Darin Wright CLA 2003-02-20 15:24:50 EST
I did open java.lang.System - but I might have been opening something from 
there (I can't remember).
Comment 4 Olivier Thomann CLA 2003-02-20 15:37:25 EST
Can you reproduce it? I guess not, but if you get it again, please let me know 
what you have done.

It looks like the source mapper has been called twice to map source and the 
types collection have been reset before the second mapping is completed.

mapSouce sets the types collection to an array with one element. At the end in 
a finally block it resets the collection to null. But the collection cannot be 
null during the notification except if the types has been reset to null before 
the second source mapping is completed.
Comment 5 Darin Wright CLA 2003-02-20 15:40:04 EST
I have not been able to reproduce it, but will let you know if I can.
Comment 6 Olivier Thomann CLA 2003-02-20 15:45:20 EST
Which VM are you using? IBM 1.3.1?
Comment 7 Darin Wright CLA 2003-02-20 15:54:29 EST
I was using IBM 1.4 in this case.
Comment 8 Olivier Thomann CLA 2003-02-20 16:02:38 EST
I really don't see how this types collection could be null.
It doesn't seem to be a concurrency problem, because I don't think the hover
calls are done concurrently.
What version are you running? 0218?
Comment 9 Darin Wright CLA 2003-02-20 16:04:30 EST
I running the lastest JCORE from HEAD.
Comment 10 Olivier Thomann CLA 2003-02-20 16:14:31 EST
Then I have no idea how types can be null. It is set to new IType[1] at the
beginning of mapSource and set to null at the end (in the finally block). If you
have more details how you got this error, they are welcome.
Comment 11 Olivier Thomann CLA 2003-02-21 10:54:52 EST
This is a threading issue. The source mapper might be called from two different
threads. The bug is that the source mapper is not thread safe. So we need to
synchronize the method ISourceRange mapSource(IType type, char[] contents,	
IJavaElement searchedElement).
We will do that for 2.1RC2. It is too risky now for RC1.
Comment 12 Olivier Thomann CLA 2003-02-26 09:10:01 EST
Fixed and released in 2.1 stream.
I synchronize the method mapSource in the source mapper. The NPE was a 
consequence of the usage of the Source mapper instance concurrently. If you see 
it again or if you get dead-lock, please reopen it.
Comment 13 Olivier Thomann CLA 2003-03-10 11:52:43 EST
Verified. There is no test case for this PR. It is a concurrency problem.