vscode-java-test icon indicating copy to clipboard operation
vscode-java-test copied to clipboard

Errors in JUnit5TestSearcher

Open jdneo opened this issue 3 years ago • 1 comments

java.lang.NullPointerException: Cannot read the array length because "this.fields" is null
	at org.eclipse.jdt.internal.compiler.lookup.BinaryTypeBinding.getField(BinaryTypeBinding.java:1426)
	at org.eclipse.jdt.internal.compiler.lookup.AnnotationBinding.buildTargetAnnotation(AnnotationBinding.java:179)
	at org.eclipse.jdt.internal.compiler.lookup.AnnotationBinding.addStandardAnnotations(AnnotationBinding.java:83)
	at org.eclipse.jdt.internal.compiler.lookup.BinaryTypeBinding.retrieveAnnotations(BinaryTypeBinding.java:1855)
	at org.eclipse.jdt.internal.compiler.lookup.ReferenceBinding.getAnnotations(ReferenceBinding.java:1067)
	at org.eclipse.jdt.core.dom.TypeBinding.getAnnotations(TypeBinding.java:122)
	at com.microsoft.java.test.plugin.searcher.JUnit5TestSearcher.matchesNameInAnnotationHierarchy(JUnit5TestSearcher.java:110)
	at com.microsoft.java.test.plugin.searcher.JUnit5TestSearcher.findAnnotation(JUnit5TestSearcher.java:85)
	at com.microsoft.java.test.plugin.searcher.JUnit5TestSearcher.isTestMethod(JUnit5TestSearcher.java:69)
	at com.microsoft.java.test.plugin.util.TestSearchUtils.findTestItemsInTypeBinding(TestSearchUtils.java:382)
	at com.microsoft.java.test.plugin.util.TestSearchUtils.findTestTypesAndMethods(TestSearchUtils.java:360)
	at com.microsoft.java.test.plugin.handler.TestDelegateCommandHandler.executeCommand(TestDelegateCommandHandler.java:60)
	at org.eclipse.jdt.ls.core.internal.handlers.WorkspaceExecuteCommandHandler$1.run(WorkspaceExecuteCommandHandler.java:215)
java.lang.NullPointerException: Cannot assign field "mayTolerateMissingType" because "this.env" is null
	at org.eclipse.jdt.internal.compiler.lookup.UnresolvedAnnotationBinding.resolve(UnresolvedAnnotationBinding.java:34)
	at org.eclipse.jdt.internal.compiler.lookup.UnresolvedAnnotationBinding.getAnnotationType(UnresolvedAnnotationBinding.java:41)
	at org.eclipse.jdt.internal.compiler.lookup.AnnotationBinding.addStandardAnnotations(AnnotationBinding.java:47)
	at org.eclipse.jdt.internal.compiler.lookup.BinaryTypeBinding.retrieveAnnotations(BinaryTypeBinding.java:1855)
	at org.eclipse.jdt.internal.compiler.lookup.ReferenceBinding.getAnnotations(ReferenceBinding.java:1067)
	at org.eclipse.jdt.core.dom.TypeBinding.getAnnotations(TypeBinding.java:122)
	at com.microsoft.java.test.plugin.searcher.JUnit5TestSearcher.matchesNameInAnnotationHierarchy(JUnit5TestSearcher.java:110)
	at com.microsoft.java.test.plugin.searcher.JUnit5TestSearcher.findAnnotation(JUnit5TestSearcher.java:85)
	at com.microsoft.java.test.plugin.searcher.JUnit5TestSearcher.isTestMethod(JUnit5TestSearcher.java:69)
	at com.microsoft.java.test.plugin.util.TestSearchUtils.findTestItemsInTypeBinding(TestSearchUtils.java:382)
	at com.microsoft.java.test.plugin.util.TestSearchUtils.findTestTypesAndMethods(TestSearchUtils.java:360)
	at com.microsoft.java.test.plugin.handler.TestDelegateCommandHandler.executeCommand(TestDelegateCommandHandler.java:60)

jdneo avatar Apr 06 '22 08:04 jdneo

Another trace:

java.lang.NullPointerException: Cannot read the array length because "this.methods" is null
	at org.eclipse.jdt.internal.compiler.lookup.BinaryTypeBinding.getMethods(BinaryTypeBinding.java:1614)
	at org.eclipse.jdt.internal.compiler.lookup.AnnotationBinding.setMethodBindings(AnnotationBinding.java:244)
	at org.eclipse.jdt.internal.compiler.lookup.LookupEnvironment.createAnnotation(LookupEnvironment.java:1005)
	at org.eclipse.jdt.internal.compiler.lookup.AnnotationBinding.buildRetentionAnnotation(AnnotationBinding.java:132)
	at org.eclipse.jdt.internal.compiler.lookup.AnnotationBinding.addStandardAnnotations(AnnotationBinding.java:87)
	at org.eclipse.jdt.internal.compiler.lookup.BinaryTypeBinding.retrieveAnnotations(BinaryTypeBinding.java:1991)
	at org.eclipse.jdt.internal.compiler.lookup.ReferenceBinding.getAnnotations(ReferenceBinding.java:1083)
	at org.eclipse.jdt.core.dom.TypeBinding.getAnnotations(TypeBinding.java:122)
	at com.microsoft.java.test.plugin.searcher.JUnit5TestSearcher.matchesNameInAnnotationHierarchy(JUnit5TestSearcher.java:110)
	at com.microsoft.java.test.plugin.searcher.JUnit5TestSearcher.findAnnotation(JUnit5TestSearcher.java:85)
	at com.microsoft.java.test.plugin.searcher.JUnit5TestSearcher.isTestMethod(JUnit5TestSearcher.java:69)
	at com.microsoft.java.test.plugin.util.TestSearchUtils.findTestItemsInTypeBinding(TestSearchUtils.java:397)
	at com.microsoft.java.test.plugin.util.TestSearchUtils.findTestTypesAndMethods(TestSearchUtils.java:375)
	at com.microsoft.java.test.plugin.handler.TestDelegateCommandHandler.executeCommand(TestDelegateCommandHandler.java:60)
	at org.eclipse.jdt.ls.core.internal.handlers.WorkspaceExecuteCommandHandler$1.run(WorkspaceExecuteCommandHandler.java:230)
	at org.eclipse.core.runtime.SafeRunner.run(SafeRunner.java:47)
	at org.eclipse.jdt.ls.core.internal.handlers.WorkspaceExecuteCommandHandler.executeCommand(WorkspaceExecuteCommandHandler.java:220)
	at org.eclipse.jdt.ls.core.internal.handlers.JDTLanguageServer.lambda$4(JDTLanguageServer.java:616)
	at org.eclipse.jdt.ls.core.internal.BaseJDTLanguageServer.lambda$0(BaseJDTLanguageServer.java:87)
	at java.base/java.util.concurrent.CompletableFuture$UniApply.tryFire(CompletableFuture.java:646)
	at java.base/java.util.concurrent.CompletableFuture$Completion.run(CompletableFuture.java:482)
	at java.base/java.lang.Thread.run(Thread.java:1583)

jdneo avatar Feb 04 '24 04:02 jdneo

Hi @jdneo, I'm an AI Support assistant here to help with your issue. While the team reviews your request, I wanted to provide some possible tips and documentation that might help you in the meantime.

Suggestions

  • Update the Java Test Runner extension (vscode-java-test) to the latest release. A fix for the JUnit5TestSearcher NullPointerException has been tracked here:

    • https://github.com/microsoft/vscode-java-pack/issues/956
  • Verify that the JUnit 5 API (junit-jupiter-api) is correctly declared on your project’s classpath so that annotation metadata can be resolved.

  • If the problem persists with the latest extension, please open an issue on the vscode-java-test repository and include a minimal sample project that reproduces the error.

Other references with low confidence

Other references with low confidence
  • References within decompiled classes may fail to resolve: NPE in OccurrencesFinder when fRoot is null. Not directly tied to test discovery but involves JDT null fields.
    https://github.com/eclipse-jdtls/eclipse.jdt.ls/issues/3083

The team will respond to your issue shortly. I hope these suggestions are helpful in the meantime. If this comment helped you, please give it a 👍. If the suggestion was not helpful or incorrect, please give it a 👎. Your feedback helps us improve!

github-actions[bot] avatar Nov 12 '25 13:11 github-actions[bot]