Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Java autocomplete throws NullPointerException in Eclipse EE 2023-06 RC1 #813

Open
garretwilson opened this issue Jun 9, 2023 · 6 comments
Labels
bug Something isn't working

Comments

@garretwilson
Copy link

garretwilson commented Jun 9, 2023

I'm using Eclipse EE 2023-06 RC1 on Windows 10.

I added a library to Maven POM <dependencies> and tried to do a Ctrl+Space autocomplete on a static field of an imported class. The platform threw a NullPointerException:

eclipse.buildId=4.28.0.20230601-1200
java.version=17.0.7
java.vendor=Eclipse Adoptium
BootLoader constants: OS=win32, ARCH=x86_64, WS=win32, NL=en_US
Framework arguments:  -product org.eclipse.epp.package.jee.product
Command-line arguments:  -os win32 -ws win32 -arch x86_64 -product org.eclipse.epp.package.jee.product

org.eclipse.jdt.ui
Warning
Fri Jun 09 07:15:08 PDT 2023
The 'org.eclipse.jdt.ui.JavaAllCompletionProposalComputer' proposal computer from the 'org.eclipse.jdt.ui' plug-in did not complete normally. The extension has thrown a runtime exception.

java.lang.NullPointerException: Cannot invoke "org.eclipse.jdt.internal.compiler.lookup.TypeBinding.kind()" because "receiverType" is null
	at org.eclipse.jdt.internal.compiler.lookup.Scope.getMethod(Scope.java:3059)
	at org.eclipse.jdt.internal.compiler.ast.MessageSend.findMethodBinding(MessageSend.java:1020)
	at org.eclipse.jdt.internal.compiler.ast.MessageSend.resolveType(MessageSend.java:835)
	at org.eclipse.jdt.internal.compiler.ast.LocalDeclaration.resolve(LocalDeclaration.java:390)
	at org.eclipse.jdt.internal.compiler.ast.LocalDeclaration.resolve(LocalDeclaration.java:259)
	at org.eclipse.jdt.internal.compiler.ast.TryStatement.resolve(TryStatement.java:1125)
	at org.eclipse.jdt.internal.compiler.ast.Block.resolve(Block.java:131)
	at org.eclipse.jdt.internal.compiler.ast.LambdaExpression.resolveType(LambdaExpression.java:470)
	at org.eclipse.jdt.internal.compiler.ast.ASTNode.resolvePolyExpressionArguments(ASTNode.java:757)
	at org.eclipse.jdt.internal.compiler.ast.MessageSend.findMethodBinding(MessageSend.java:1027)
	at org.eclipse.jdt.internal.compiler.ast.MessageSend.resolveType(MessageSend.java:835)
	at org.eclipse.jdt.internal.compiler.ast.Expression.resolve(Expression.java:1113)
	at org.eclipse.jdt.internal.compiler.ast.Block.resolve(Block.java:131)
	at org.eclipse.jdt.internal.compiler.ast.AbstractMethodDeclaration.resolveStatements(AbstractMethodDeclaration.java:662)
	at org.eclipse.jdt.internal.compiler.ast.MethodDeclaration.resolveStatements(MethodDeclaration.java:388)
	at org.eclipse.jdt.internal.compiler.ast.AbstractMethodDeclaration.resolve(AbstractMethodDeclaration.java:571)
	at org.eclipse.jdt.internal.compiler.ast.TypeDeclaration.resolve(TypeDeclaration.java:1506)
	at org.eclipse.jdt.internal.compiler.ast.TypeDeclaration.resolve(TypeDeclaration.java:1631)
	at org.eclipse.jdt.internal.compiler.ast.CompilationUnitDeclaration.resolve(CompilationUnitDeclaration.java:668)
	at org.eclipse.jdt.internal.codeassist.CompletionEngine.complete(CompletionEngine.java:2340)
	at org.eclipse.jdt.internal.core.Openable.codeComplete(Openable.java:136)
	at org.eclipse.jdt.internal.core.CompilationUnit.codeComplete(CompilationUnit.java:367)
	at org.eclipse.jdt.internal.core.CompilationUnit.codeComplete(CompilationUnit.java:357)
	at org.eclipse.jdt.internal.ui.text.java.JavaCompletionProposalComputer.internalComputeCompletionProposals(JavaCompletionProposalComputer.java:256)
	at org.eclipse.jdt.internal.ui.text.java.JavaCompletionProposalComputer.computeCompletionProposals(JavaCompletionProposalComputer.java:218)
	at org.eclipse.jdt.internal.ui.text.java.JavaTypeCompletionProposalComputer.computeCompletionProposals(JavaTypeCompletionProposalComputer.java:65)
	at org.eclipse.jdt.internal.ui.text.java.CompletionProposalComputerDescriptor.computeCompletionProposals(CompletionProposalComputerDescriptor.java:348)
	at org.eclipse.jdt.internal.ui.text.java.CompletionProposalCategory.computeCompletionProposals(CompletionProposalCategory.java:340)
	at org.eclipse.jdt.internal.ui.text.java.ContentAssistProcessor.collectProposals(ContentAssistProcessor.java:333)
	at org.eclipse.jdt.internal.ui.text.java.ContentAssistProcessor.computeCompletionProposals(ContentAssistProcessor.java:289)
	at org.eclipse.jface.text.contentassist.AsyncCompletionProposalPopup.lambda$10(AsyncCompletionProposalPopup.java:378)
	at org.eclipse.core.runtime.SafeRunner.run(SafeRunner.java:45)
	at org.eclipse.jface.text.contentassist.AsyncCompletionProposalPopup.lambda$9(AsyncCompletionProposalPopup.java:377)
	at java.base/java.util.concurrent.CompletableFuture$AsyncSupply.run(CompletableFuture.java:1768)
	at java.base/java.util.concurrent.CompletableFuture$AsyncSupply.exec(CompletableFuture.java:1760)
	at java.base/java.util.concurrent.ForkJoinTask.doExec(ForkJoinTask.java:373)
	at java.base/java.util.concurrent.ForkJoinPool$WorkQueue.topLevelExec(ForkJoinPool.java:1182)
	at java.base/java.util.concurrent.ForkJoinPool.scan(ForkJoinPool.java:1655)
	at java.base/java.util.concurrent.ForkJoinPool.runWorker(ForkJoinPool.java:1622)
	at java.base/java.util.concurrent.ForkJoinWorkerThread.run(ForkJoinWorkerThread.java:165)

Unfortunately I don't have time to send you a complete test case. Please don't think it cavalier or lazy of me. I've been busy filing Eclipse bugs left and right for days (eclipse-m2e/m2e-wtp#26, eclipse-jdt/eclipse.jdt.core#1131, eclipse-wildwebdeveloper/wildwebdeveloper#1216, eclipse-m2e/m2e-core#1414, #805, ….) At some point I have to get some work done on my own projects. I hope the stack trace can give you some hints about the problem. Good luck.

@mickaelistria
Copy link
Contributor

Looks like the complete stack is missing. Can you please share it if possible?

@garretwilson
Copy link
Author

Looks like the complete stack is missing.

Yeah, sorry; not sure what happened. I pasted the stack trace and then suddenly it disappeared and the issue was posted. Must be some secret accelerator key for the "Submit new issue" button I don't know about. Anyway I updated the ticket. Hope it's helpful.

@mickaelistria
Copy link
Contributor

Did it happen just once or is it something that happens repeatedly?

@garretwilson
Copy link
Author

garretwilson commented Jun 9, 2023

This particular thing happened only once. This is a multi-project POM. I did the following:

  1. In the project parent POM, I added the following from https://github.com/globalmentor/globalmentor-web .
<dependencyManagement>
  <dependencies>
    <dependency>
      <groupId>com.globalmentor</groupId>
      <artifactId>globalmentor-web-bom</artifactId>
      <version>0.7.0-SNAPSHOT</version>
      <type>pom</type>
      <scope>import</scope>
    </dependency>
  1. Then in the subproject I added this:
<dependencies>
  <dependency>
    <groupId>com.globalmentor</groupId>
    <artifactId>globalmentor-xml-def</artifactId>
  </dependency>
  1. Then I add this in the Java file:
import com.globalmentor.xml.def.XML;

I may have typed XML and then hit Ctrl+Space for Eclipse to add the import. Or Eclipse may have added the import and then I hit Ctrl+Space after XML. (I was ultimately looking for XML.FILENAME_EXTENSION). Actually the latter sequence of events is probably what happened.

That's about all the information I have. I understand that it may have to do with the specifics of my large workspace and decades of Eclipse workspace evolution, so it may be hard to reproduce on your end. However with the stack trace, at least you can put more preconditions up the chain so that in the future if null is passed unexpectedly at least it would be caught earlier with more logging so that you can get to the bottom of it eventually.

@garretwilson
Copy link
Author

Note that this morning my error log is full of various things, including multiple "Could not get hover information due to timeout after 1000 miliseconds" (yes, it is misspelled in the log) and "Could not get hover region due to timeout after 1000 miliseconds", both from org.ecilpse.lspr3. These may be related to my trying to Ctrl+Click on a parent POM in the new-and-not-so-improved XML editor (which made a huge leap backwards when they switched the underlying formatting engine; before it was just buggy—now it is buggy and less functional). I also see java.util.concurrent.CompletionException: org.eclipse.lsp4j.jsonrpc.ResponseErrorException: The request (id: 156, method: 'textDocument/codeLens') has been cancelled. Are they related? Probably not. Or maybe. Who knows? Could I provide you something that would allow you to reproduce this? Maybe after a week of work dedicated solely to trying to create a case. But I still owe aws/aws-sam-cli#5254 a reproducible case for AWS SAM getting confused about hashes. (sigh) What week. So … that's all I got at the moment. I'm going to go be productive now. Good luck. And have a happy Friday.

@jukzi jukzi added the bug Something isn't working label Nov 28, 2023
@jukzi
Copy link
Contributor

jukzi commented Nov 28, 2023

Why is this Bug reported on platform when the NPE happens in JDT UI?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

3 participants