openjdk icon indicating copy to clipboard operation
openjdk copied to clipboard

using Microsoft JDK can error due to a missing Packages directory

Open SingingBush opened this issue 3 years ago • 8 comments

I've had some users of Intellij D Language plugin report problems when using the Microsoft JDK. The project is built using Gradle and when doing the gradle build the resulting error is output:

/home/********/.sdkman/candidates/java/11.0.13-ms/Packages does not exist.

Adding a directory named Packages to the root of the ms JDK solves the problem: https://github.com/intellij-dlanguage/intellij-dlanguage/issues/652#issuecomment-1312112121

I'm submitting here as there really shouldn't be a need for users to add a directory to their jdk and this 'Packages' directory is non-standard.

SingingBush avatar Nov 12 '22 12:11 SingingBush

@SingingBush That looks like an SDKMan packaging issue to me, I think you'll need to report it there.

karianna avatar Nov 12 '22 21:11 karianna

The linked comment had the path C:\Program Files\Microsoft\jdk-17.0.1.12-hotspot\Packages which isn't sdkman.

SingingBush avatar Nov 12 '22 22:11 SingingBush

@SingingBush That directory doesn't come from the Microsoft MSI installer so I think it's SDKMan that's adding it.

karianna avatar Nov 13 '22 00:11 karianna

This issue has caused me to switch away from the Microsoft distribution of OpenJDK. This is only an issue on the Microsoft distribution of the JDK, and it's unclear to me why it would be any different than any other vendor in this case.

Marking this issue as invalid feels unproductive to me when you are the only vendor who has this issue.

aaronjyoder avatar Mar 09 '25 20:03 aaronjyoder

@aaronjyoder That folder structure doesn't come from our installers so I can only conclude that it's being added in error somehow via SDKman. Have you reported the issue there?

karianna avatar Mar 17 '25 04:03 karianna

That's actually the point of my initial report, that the folder is not created by the installer. The point is that for some reason the Microsoft JDK expects it be there.

Adding it manually fixes the problem. So Microsoft either need to ensure the directory is created during installation or change the code that expects it to already exist and just create it when needed.

SingingBush avatar Mar 17 '25 06:03 SingingBush

I wonder if it's something to do with this https://github.com/microsoft/openjdk-jdk11u/blob/659a4669208645420e151e78ab5fd3ac3808b310/src/java.base/share/classes/jdk/internal/jrtfs/ExplodedImage.java#L57

The javadoc mention that the modules folder will be under JAVA_HOME so presumably it expects the same for packages.

SingingBush avatar Mar 17 '25 07:03 SingingBush

@brianjstafford & @brunoborges - I'm now unsure if this is an issue with how we explode our JDK (presumedly SDK man takes our zip archive as opposed to our MSI archive here).

@brunoborges - IIRC you had some familiarity with sdkman?

karianna avatar Mar 18 '25 03:03 karianna

@SingingBush, I tried to reproduce the issue but nothing.

Also, I noticed that the folder structure of the Microsoft JDK is pretty much the same as others, and I did not see any other JDK with the folder Packages.

Please let me know if this is still an issue, and if you could, I'd love to be able to reproduce the issue on my end.

brunoborges avatar Jul 03 '25 05:07 brunoborges

I just tested this locally on Fedora with a fresh download of the jdk-21.0.7 tarball. clone the repo of the intellij-dlanguage project and run ./gradlew runIde using the microsoft JDK:

JAVA_HOME=/opt/microsoft-jdk-21.0.7 ./gradlew runIde

resulted in Caused by: : /opt/microsoft-jdk-21.0.7/Packages does not exist.

Here's some of the stack trace:

2: Task failed with an exception.
-----------
* What went wrong:
Execution failed for task ':debugger:instrumentCode'.
> /opt/microsoft-jdk-21.0.7/Packages does not exist.

* Try:
> Run with --debug option to get more log output.
> Run with --scan to get full insights.
> Get more help at https://help.gradle.org.

* Exception is:
org.gradle.api.tasks.TaskExecutionException: Execution failed for task ':debugger:instrumentCode'.
        at org.gradle.api.internal.tasks.execution.ExecuteActionsTaskExecuter.lambda$executeIfValid$1(ExecuteActionsTaskExecuter.java:130)
        at org.gradle.internal.Try$Failure.ifSuccessfulOrElse(Try.java:293)
        at org.gradle.api.internal.tasks.execution.ExecuteActionsTaskExecuter.executeIfValid(ExecuteActionsTaskExecuter.java:128)
        at org.gradle.api.internal.tasks.execution.ExecuteActionsTaskExecuter.execute(ExecuteActionsTaskExecuter.java:116)
        at org.gradle.api.internal.tasks.execution.FinalizePropertiesTaskExecuter.execute(FinalizePropertiesTaskExecuter.java:46)
        at org.gradle.api.internal.tasks.execution.ResolveTaskExecutionModeExecuter.execute(ResolveTaskExecutionModeExecuter.java:51)
        at org.gradle.api.internal.tasks.execution.SkipTaskWithNoActionsExecuter.execute(SkipTaskWithNoActionsExecuter.java:57)
        at org.gradle.api.internal.tasks.execution.SkipOnlyIfTaskExecuter.execute(SkipOnlyIfTaskExecuter.java:74)
        at org.gradle.api.internal.tasks.execution.CatchExceptionTaskExecuter.execute(CatchExceptionTaskExecuter.java:36)
        at org.gradle.api.internal.tasks.execution.EventFiringTaskExecuter$1.executeTask(EventFiringTaskExecuter.java:77)
        at org.gradle.api.internal.tasks.execution.EventFiringTaskExecuter$1.call(EventFiringTaskExecuter.java:55)
        at org.gradle.api.internal.tasks.execution.EventFiringTaskExecuter$1.call(EventFiringTaskExecuter.java:52)
        at org.gradle.internal.operations.DefaultBuildOperationRunner$CallableBuildOperationWorker.execute(DefaultBuildOperationRunner.java:209)
        at org.gradle.internal.operations.DefaultBuildOperationRunner$CallableBuildOperationWorker.execute(DefaultBuildOperationRunner.java:204)
        at org.gradle.internal.operations.DefaultBuildOperationRunner$2.execute(DefaultBuildOperationRunner.java:66)
        at org.gradle.internal.operations.DefaultBuildOperationRunner$2.execute(DefaultBuildOperationRunner.java:59)
        at org.gradle.internal.operations.DefaultBuildOperationRunner.execute(DefaultBuildOperationRunner.java:166)
        at org.gradle.internal.operations.DefaultBuildOperationRunner.execute(DefaultBuildOperationRunner.java:59)
        at org.gradle.internal.operations.DefaultBuildOperationRunner.call(DefaultBuildOperationRunner.java:53)
        at org.gradle.api.internal.tasks.execution.EventFiringTaskExecuter.execute(EventFiringTaskExecuter.java:52)
        at org.gradle.execution.plan.LocalTaskNodeExecutor.execute(LocalTaskNodeExecutor.java:42)
        at org.gradle.execution.taskgraph.DefaultTaskExecutionGraph$InvokeNodeExecutorsAction.execute(DefaultTaskExecutionGraph.java:331)
        at org.gradle.execution.taskgraph.DefaultTaskExecutionGraph$InvokeNodeExecutorsAction.execute(DefaultTaskExecutionGraph.java:318)
        at org.gradle.execution.taskgraph.DefaultTaskExecutionGraph$BuildOperationAwareExecutionAction.lambda$execute$0(DefaultTaskExecutionGraph.java:314)
        at org.gradle.internal.operations.CurrentBuildOperationRef.with(CurrentBuildOperationRef.java:85)
        at org.gradle.execution.taskgraph.DefaultTaskExecutionGraph$BuildOperationAwareExecutionAction.execute(DefaultTaskExecutionGraph.java:314)
        at org.gradle.execution.taskgraph.DefaultTaskExecutionGraph$BuildOperationAwareExecutionAction.execute(DefaultTaskExecutionGraph.java:303)
        at org.gradle.execution.plan.DefaultPlanExecutor$ExecutorWorker.execute(DefaultPlanExecutor.java:459)
        at org.gradle.execution.plan.DefaultPlanExecutor$ExecutorWorker.run(DefaultPlanExecutor.java:376)
        at org.gradle.internal.concurrent.ExecutorPolicy$CatchAndRecordFailures.onExecute(ExecutorPolicy.java:64)
        at org.gradle.internal.concurrent.AbstractManagedExecutor$1.run(AbstractManagedExecutor.java:48)
        at java.base/java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1144)
        at java.base/java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:642)
        at java.base/java.lang.Thread.run(Thread.java:1583)
Caused by: : /opt/microsoft-jdk-21.0.7/Packages does not exist.

I tried to recreate the issue with a smaller Gradle project but couldn't. I suspect the intellij-platform-gradle-plugin is doing something with Gradle that surfaces this problem in the MS JDK that isn't present in other JDK's such as OpenJDK.

SingingBush avatar Jul 04 '25 00:07 SingingBush

@SingingBush could you please test with the latest release?

brunoborges avatar Nov 27 '25 04:11 brunoborges

My project now requires JDK 21 so I downloaded https://aka.ms/download-jdk/microsoft-jdk-21.0.9-linux-x64.tar.gz and used it to run the gradle wrapper in my project (latest commit in develop):

JAVA_HOME=~/dev/tools/microsoft-jdk-21.0.9-linux-x64/jdk-21.0.9+10 ./gradlew runIde

(this project also requires the dmd compiler to be installed)

I see the same problem:

FAILURE: Build completed with 2 failures.

1: Task failed with an exception.
-----------
* What went wrong:
Execution failed for task ':utils:instrumentCode'.
> /home/******/dev/tools/microsoft-jdk-21.0.9-linux-x64/jdk-21.0.9+10/Packages does not exist.

* Try:
> Run with --stacktrace option to get the stack trace.
> Run with --debug option to get more log output.
> Run with --scan to generate a Build Scan (Powered by Develocity).
> Get more help at https://help.gradle.org.
==============================================================================

2: Task failed with an exception.
-----------
* What went wrong:
Execution failed for task ':debugger:instrumentCode'.
> /home/******/dev/tools/microsoft-jdk-21.0.9-linux-x64/jdk-21.0.9+10/Packages does not exist.

* Try:
> Run with --stacktrace option to get the stack trace.
> Run with --debug option to get more log output.
> Run with --scan to generate a Build Scan (Powered by Develocity).
> Get more help at https://help.gradle.org.
==============================================================================

BUILD FAILED in 1s
41 actionable tasks: 24 executed, 17 from cache
Configuration cache entry reused.

SingingBush avatar Nov 29 '25 00:11 SingingBush

Hey @SingingBush - I'll have someone try to reproduce and investigate the issue this sprint.

brianjstafford avatar Nov 29 '25 00:11 brianjstafford