redhat-developer / redhat-developer/vscode-java

Partial jdk classes cannot be resolved. It is indirectly reference from required ...

Open
#3,365 0 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Dominant language
TypeScript
Stars
2.3k
Forks
546
Avg merge
20h 1m
Merged PRs (30d)
11

Description

  1. Open spring-petclinic project in VS Code and observe the compilation error below.
[{
	"resource": "/C:/Work/Code/spring-petclinic/src/test/java/org/springframework/samples/petclinic/PetClinicIntegrationTests.java",
	"owner": "_generated_diagnostic_collection_name_#4",
	"code": "16777563",
	"severity": 8,
	"message": "The type java.lang.Enum cannot be resolved. It is indirectly referenced from required type org.springframework.boot.test.context.SpringBootTest.WebEnvironment",
	"source": "Java",
	"startLineNumber": 1,
	"startColumn": 1,
	"endLineNumber": 1,
	"endColumn": 2
}]

image

  1. In the Java Projects view, Enum.class is also not resolved in the JRE tree view.

image

  1. Click Enum.class in the JRE tree view, Java extension reports error as below.
!ENTRY org.eclipse.jdt.ls.core 4 0 2023-10-26 16:12:15.657
!MESSAGE Enum.class [in java.lang [in <module:java.base>]] does not exist
!STACK 1
Java Model Exception: Error in Java Model (code 969): Enum.class [in java.lang [in <module:java.base>]] does not exist
	at org.eclipse.jdt.internal.core.JavaElement.newNotPresentException(JavaElement.java:550)
	at org.eclipse.jdt.internal.core.ClassFile.getBinaryTypeInfo(ClassFile.java:203)
	at org.eclipse.jdt.internal.core.ClassFile.buildStructure(ClassFile.java:92)
	at org.eclipse.jdt.internal.core.Openable.generateInfos(Openable.java:266)
	at org.eclipse.jdt.internal.core.JavaElement.openWhenClosed(JavaElement.java:573)
	at org.eclipse.jdt.internal.core.JavaElement.getElementInfo(JavaElement.java:304)
	at org.eclipse.jdt.internal.core.JavaElement.getElementInfo(JavaElement.java:290)
	at org.eclipse.jdt.internal.core.Openable.getBuffer(Openable.java:296)
	at org.eclipse.jdt.internal.core.AbstractClassFile.getBuffer(AbstractClassFile.java:245)
	at org.eclipse.jdt.internal.core.AbstractClassFile.getSourceRange(AbstractClassFile.java:371)
	at org.eclipse.jdt.ls.core.internal.JDTUtils.resolveTypeRoot(JDTUtils.java:452)
	at org.eclipse.jdt.ls.core.internal.handlers.FoldingRangeHandler.foldingRange(FoldingRangeHandler.java:66)
	at org.eclipse.jdt.ls.core.internal.handlers.JDTLanguageServer.lambda$30(JDTLanguageServer.java:1027)
	at org.eclipse.jdt.ls.core.internal.handlers.JDTLanguageServer.lambda$59(JDTLanguageServer.java:1216)
	at java.base/java.util.concurrent.CompletableFuture$UniApply.tryFire(Unknown Source)
	at java.base/java.util.concurrent.CompletableFuture$Completion.exec(Unknown Source)
	at java.base/java.util.concurrent.ForkJoinTask.doExec(Unknown Source)
	at java.base/java.util.concurrent.ForkJoinPool$WorkQueue.topLevelExec(Unknown Source)
	at java.base/java.util.concurrent.ForkJoinPool.scan(Unknown Source)
	at java.base/java.util.concurrent.ForkJoinPool.runWorker(Unknown Source)
	at java.base/java.util.concurrent.ForkJoinWorkerThread.run(Unknown Source)
!SUBENTRY 1 org.eclipse.jdt.core 4 969 2023-10-26 16:12:15.657
!MESSAGE Enum.class [in java.lang [in <module:java.base>]] does not exist
  1. I cannot reproduce this issue consistently, but I encountered it twice in my local environment recently. Reloading the window usually fixes it. I am opening this issue to see if anyone else has the same problem.

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Reproduce the issue in the spring-petclinic project and inspect the diagnostic for PetClinicIntegrationTests.java alongside the Java Projects JRE tree. Start with the missing Enum.class report and the org.eclipse.jdt.ls.core stack trace, then compare behavior before and after reloading the VS Code window. Done means the partial JDK classes no longer produce the reported resolution error.

Written by the indexing model from the issue text.

Assessment

Tech stack
java, vscode
Domain
devtools, tooling
Issue type
Bug
Difficulty
4/5
Estimated time
3-5 days
Activity status
Stale
Clarity
Needs clarification
Newbie friendliness
30/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.