Bug 563118 - NPE in MatchLocator.createHandle
Summary: NPE in MatchLocator.createHandle
Status: CLOSED MOVED
Alias: None
Product: JDT
Classification: Eclipse Project
Component: Core (show other bugs)
Version: 4.9   Edit
Hardware: All All
: P3 normal (vote)
Target Milestone: ---   Edit
Assignee: JDT-Core-Inbox CLA
QA Contact:
URL:
Whiteboard:
Keywords: needinfo
Depends on:
Blocks:
 
Reported: 2020-05-13 05:45 EDT by Christian Dietrich CLA
Modified: 2022-07-19 10:39 EDT (History)
2 users (show)

See Also:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Christian Dietrich CLA 2020-05-13 05:45:46 EDT
When i run one of our Xtext tests i am getting following NPE

java.lang.NullPointerException
	at org.eclipse.jdt.internal.core.search.matching.MatchLocator.createHandle(MatchLocator.java:511)
	at org.eclipse.jdt.internal.core.search.matching.MatchLocator.reportMatching(MatchLocator.java:2526)
	at org.eclipse.jdt.internal.core.search.matching.MatchLocator.reportMatching(MatchLocator.java:3264)
	at org.eclipse.jdt.internal.core.search.matching.MatchLocator.reportMatching(MatchLocator.java:3276)
	at org.eclipse.jdt.internal.core.search.matching.MemberDeclarationVisitor.visit(MemberDeclarationVisitor.java:330)
	at org.eclipse.jdt.internal.compiler.ast.TypeDeclaration.traverse(TypeDeclaration.java:1696)
	at org.eclipse.jdt.internal.compiler.ast.QualifiedAllocationExpression.traverse(QualifiedAllocationExpression.java:693)
	at org.eclipse.jdt.internal.compiler.ast.ReturnStatement.traverse(ReturnStatement.java:381)
	at org.eclipse.jdt.internal.compiler.ast.MethodDeclaration.traverse(MethodDeclaration.java:410)
	at org.eclipse.jdt.internal.core.search.matching.MatchLocator.reportMatching(MatchLocator.java:2567)
	at org.eclipse.jdt.internal.core.search.matching.MatchLocator.reportMatching(MatchLocator.java:3264)
	at org.eclipse.jdt.internal.core.search.matching.MatchLocator.reportMatching(MatchLocator.java:2843)
	at org.eclipse.jdt.internal.core.search.matching.MatchLocator.process(MatchLocator.java:2018)
	at org.eclipse.jdt.internal.core.search.matching.MatchLocator.locateMatches(MatchLocator.java:1293)
	at org.eclipse.jdt.internal.core.search.matching.MatchLocator.locateMatches(MatchLocator.java:1373)
	at org.eclipse.jdt.internal.core.search.matching.MatchLocator.locateMatches(MatchLocator.java:1515)
	at org.eclipse.jdt.internal.core.search.JavaSearchParticipant.locateMatches(JavaSearchParticipant.java:112)
	at org.eclipse.jdt.internal.core.search.BasicSearchEngine.findMatches(BasicSearchEngine.java:250)
	at org.eclipse.jdt.internal.core.search.BasicSearchEngine.search(BasicSearchEngine.java:595)
	at org.eclipse.jdt.core.search.SearchEngine.search(SearchEngine.java:670)
	at org.eclipse.xtext.common.types.xtext.ui.JdtBasedConstructorScope.collectContents(JdtBasedConstructorScope.java:100)

the type with

type.getDeclaringType() == null

is

MapEntry (not open) [in HashBiMap$1$MapEntry.class [in com.google.common.collect [in /data/.p2/pool/plugins/com.google.guava_27.1.0.v20190517-1946.jar]]]
Comment 1 Christian Dietrich CLA 2020-05-13 05:52:45 EDT
=> looks like

org.eclipse.jdt.internal.core.BinaryType.getDeclaringType()

does not like the 

HashBiMap$1$MapEntry.class

class file name from Guava

here is what the guava code does


  @Override
  Iterator<Entry<K, V>> entryIterator() {
    return new Itr<Entry<K, V>>() {
      @Override
      Entry<K, V> output(BiEntry<K, V> entry) {
        return new MapEntry(entry);
      }

      class MapEntry extends AbstractMapEntry<K, V> {

so we have a name class inside a anonymous ones
Comment 2 Andrey Loskutov CLA 2020-05-13 06:04:11 EDT
(In reply to Christian Dietrich from comment #1)
> => looks like
> 
> org.eclipse.jdt.internal.core.BinaryType.getDeclaringType()
> 
> does not like the 
> 
> HashBiMap$1$MapEntry.class

Can you bisect this, or at least say, when in 4.16 did it start to fail for you?
Comment 3 Christian Dietrich CLA 2020-05-13 06:07:30 EDT
as my maven build does not fail i have no idea.
so it could be the problem is even there in 4.15
Comment 4 Christian Dietrich CLA 2020-05-13 06:39:19 EDT
i checked.
this happens back to oxygen

so this seems more like a bug than a regression
Comment 5 Andrey Loskutov CLA 2020-05-13 06:41:46 EDT
So it is new Guava code that causing the Xtext test fail? Can you extract a standalone example?
Comment 6 Andrey Loskutov CLA 2022-07-19 10:39:26 EDT
Moved to https://github.com/eclipse-jdt/eclipse.jdt.core/issues/247