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

AppCDS build step with JDK 17 source/target uses absolute classpath #33069

Closed
jerboaa opened this issue May 2, 2023 · 1 comment · Fixed by #33070
Closed

AppCDS build step with JDK 17 source/target uses absolute classpath #33069

jerboaa opened this issue May 2, 2023 · 1 comment · Fixed by #33070
Labels
area/core kind/bug Something isn't working
Milestone

Comments

@jerboaa
Copy link
Contributor

jerboaa commented May 2, 2023

Describe the bug

When creating an AppCDS jsa archive Quarkus' AppCDSBuildStep class uses absolute paths for the class path when the dynamic archive is being dumped with -XX:ArchiveClassesAtExit=<jsa-file>. This makes the feature less usable, since on systems where the exact same classpath would be available, yet the absolute path to the jar file is different mapping the CDS archive fails.

The JDK is smart enough to handle the relative class path use-case, thus, using relative paths would be the preferred option. Using the older -Xshare:dump with classlist file doesn't seem to have that problem.

Expected behavior

AppCDS archive usable if JDK matches, classpath matches, yet the absolute path to the jar(s) is different.

Actual behavior

JVM fails to map the CDS archive. Example with -Xshare:on so as to provoke a JVM start error when mapping fails:

$ java -Xlog:cds,class+path -Xshare:on -XX:SharedArchiveFile=app-cds.jsa -jar getting-started-1.0.0-SNAPSHOT-runner.jar 
[0.001s][info][class,path] bootstrap loader class path=/usr/lib/jvm/java-17-openjdk-17.0.6.0.10-1.fc37.x86_64/lib/modules
[0.005s][info][cds       ] trying to map /usr/lib/jvm/java-17-openjdk-17.0.6.0.10-1.fc37.x86_64/lib/server/classes.jsa
[0.005s][info][cds       ] Opened archive /usr/lib/jvm/java-17-openjdk-17.0.6.0.10-1.fc37.x86_64/lib/server/classes.jsa.
[0.005s][info][cds       ] Archive was created with UseCompressedOops = 1, UseCompressedClassPointers = 1
[0.005s][info][cds       ] Core region alignment: 4096
[0.005s][info][cds       ] trying to map app-cds.jsa
[0.005s][info][cds       ] Opened archive app-cds.jsa.
[0.005s][info][cds       ] Archive was created with UseCompressedOops = 1, UseCompressedClassPointers = 1
[0.005s][info][cds       ] Reserved archive_space_rs [0x0000000800000000 - 0x0000000801c00000] (29360128) bytes
[0.005s][info][cds       ] Reserved class_space_rs   [0x0000000801c00000 - 0x0000000841c00000] (1073741824) bytes
[0.005s][info][cds       ] Mapped static  region #0 at base 0x0000000800000000 top 0x0000000800458000 (ReadWrite)
[0.005s][info][cds       ] Mapped static  region #1 at base 0x0000000800458000 top 0x0000000800be1000 (ReadOnly)
[0.005s][info][class,path] Expecting BOOT path=/usr/lib/jvm/java-17-openjdk-17.0.6.0.10-1.fc37.x86_64/lib/modules
[0.005s][info][class,path] Expecting -Djava.class.path=
[0.005s][info][class,path] checking shared classpath entry: /usr/lib/jvm/java-17-openjdk-17.0.6.0.10-1.fc37.x86_64/lib/modules
[0.005s][info][class,path] ok
[0.005s][info][cds       ] Mapped dynamic region #0 at base 0x0000000800be1000 top 0x0000000801180000 (ReadWrite)
[0.005s][info][cds       ] Mapped dynamic region #1 at base 0x0000000801180000 top 0x0000000801941000 (ReadOnly)
[0.005s][info][class,path] Expecting BOOT path=/usr/lib/jvm/java-17-openjdk-17.0.6.0.10-1.fc37.x86_64/lib/modules
[0.005s][info][class,path] Expecting -Djava.class.path=/home/sgehwolf/Documents/openjdk/quarkus/quarkus-quickstarts/getting-started/target/getting-started-1.0.0-SNAPSHOT-runner.jar
[0.005s][info][class,path] checking shared classpath entry: /usr/lib/jvm/java-17-openjdk-17.0.6.0.10-1.fc37.x86_64/lib/modules
[0.005s][info][class,path] ok
[0.005s][info][class,path] checking shared classpath entry: /home/sgehwolf/Documents/openjdk/quarkus/quarkus-quickstarts/getting-started/target/getting-started-1.0.0-SNAPSHOT-runner.jar
[0.005s][info][class,path] ok
[0.005s][info][class,path] [APP classpath mismatch, actual: -Djava.class.path=getting-started-1.0.0-SNAPSHOT-runner.jar
An error has occurred while processing the shared archive file.
shared class paths mismatch (hint: enable -Xlog:class+path=info to diagnose the failure)
Error occurred during initialization of VM
Unable to use shared archive.

How to Reproduce?

Reproducer

  1. Build with -Dmaven.compiler.source=17 -Dmaven.compiler.target=17 -Dquarkus.package.create-appcds=true -Dquarkus.package.type=uber-jar (e.g. getting-started from quarkus-quickstarts)
  2. cd target
  3. mkdir test && cp -a app-cds.jsa getting-started*.jar test && cd test
  4. java -Xshare:on -XX:SharedArchiveFile=app-cds.jsa -jar getting-started-1.0.0-SNAPSHOT-runner.jar

Note that if run from the target folder, not the subfolder test (i.e. build time identical), using the CDS archive works.

Output of uname -a or ver

No response

Output of java -version

17.0.7

GraalVM version (if different from Java)

No response

Quarkus version or git rev

6c7268b

Build tool (ie. output of mvnw --version or gradlew --version)

maven

Additional information

No response

@jerboaa jerboaa added the kind/bug Something isn't working label May 2, 2023
jerboaa added a commit to jerboaa/quarkus that referenced this issue May 2, 2023
This makes the AppCDS feature more portable where the build and
deployment paths differ, but are otherwise identical (for example s2i
use-case).

Closes: quarkusio#33069
@quarkus-bot
Copy link

quarkus-bot bot commented May 9, 2023

/cc @Sanne (core), @aloubyansky (core), @geoand (core), @gsmet (core), @radcortez (core), @stuartwdouglas (core)

jerboaa added a commit to jerboaa/quarkus that referenced this issue May 9, 2023
This makes the AppCDS feature more portable where the build and
deployment paths differ, but are otherwise identical (for example s2i
use-case).

Closes: quarkusio#33069
@quarkus-bot quarkus-bot bot added this to the 3.1 - main milestone May 9, 2023
manofthepeace pushed a commit to manofthepeace/quarkus that referenced this issue May 16, 2023
This makes the AppCDS feature more portable where the build and
deployment paths differ, but are otherwise identical (for example s2i
use-case).

Closes: quarkusio#33069
jerboaa added a commit to jerboaa/quarkus-quickstarts that referenced this issue Oct 23, 2023
JDK 17-based AppCDS dump uses absolute paths. See:
quarkusio/quarkus#33069
jerboaa added a commit to jerboaa/quarkus-quickstarts that referenced this issue Oct 23, 2023
fast-jar doesn't work well due to:
quarkusio/quarkus#32877 or
https://bugs.openjdk.org/browse/JDK-8265602. We cannot use
JDK 17 based AppCDS dump due to
quarkusio/quarkus#33069

Lets use static dump and uber jar for the demo.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
area/core kind/bug Something isn't working
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants