Repository navigation
Use jrt:/ file system as fallback for missing jmods - #541
Conversation
There was a problem hiding this comment.
I hope the new tests in InputReaderTest are realistic, but if possible please also run this (manually?) with an integration test setup in case you have one.
I have done a bit integration testing locally and it seems to work as expected. Make sure to run with -verbose to see the new "Using jrt:/ file system fallback ..." log message.
| DataEntryReader reader; | ||
| DataEntrySource source = maybeGetJrtFallback(classPathFile, classPathEntry.isJmod()); | ||
| if (source != null) { | ||
| reader = DataEntryReaderFactory.applyGeneralFilter(classPathEntry, dataEntryReader); |
There was a problem hiding this comment.
I hope it suffices to just use applyGeneralFilter (respectively ClassPathEntry#getFilter) here. Not sure if it is necessary to also apply any file-extension specific filters, e.g. getJarFilter() or getJmodFilter().
| val dest = pathPieces.fold(destDir, Path::resolve) | ||
| Files.createDirectories(dest.parent) | ||
| // Some of the copied files are > 100 MB; for better performance just create a hardlink | ||
| Files.createLink(dest, source) |
There was a problem hiding this comment.
I hope creating a hardlink instead of copying the files is fine here. That should not cause any problems I think, unless some program or the user were to try modify the file (other than deleting it), which would modify the actual JDK.
Could maybe reduce the risk by additionally making the hardlinked file read-only / non-writable but that might make cleanup of the tempdir more cumbersome.
There was a problem hiding this comment.
The hardlinks don't work on my Linux machine:
java.nio.file.FileSystemException: /tmp/proguard.InputReaderTest7748393587331681400/lib/jrt-fs.jar -> /home/fergal/.jdks/corretto-11.0.21/lib/jrt-fs.jar: Invalid cross-device link
Using a symbolic link instead fixes it for me. If that doesn't work universally, it may be worth creating minimal jmods/jars/modules for ProGuard to load, either building them in the test or adding them as resource files.
There was a problem hiding this comment.
Thanks for letting me know! I have changed it to try creating a symlink as fallback now (the comment in code explains the rationale). Can you please try if that solves it for you?
I currently don't have a local test setup where creating the hardlink fails, but when I temporarily changed it to always create the symlink, loading it as jrt file system seemed to work for me on Linux.
Regarding creating a minimal lib/modules file: Not sure how easy that is, and I am afraid that would make the test harder to maintain so for now I would like to avoid that.
|
You can rebase your PR, JRtDataSource should now be available to PG |
|
Did a regular merge for now; if you want I can squash all commits in the end though. (In case you are not doing that anyway when the PR is merged.) |
Not a problem indeed, will squash merge if needed 👍 We will have a thorough review in the next couple days just fyi. Thanks again for looking into it. |
|
The test dependency issue should not cause tests to fail for your PR anymore, after syncing |
| val dest = pathPieces.fold(destDir, Path::resolve) | ||
| Files.createDirectories(dest.parent) | ||
| // Some of the copied files are > 100 MB; for better performance just create a hardlink | ||
| Files.createLink(dest, source) |
There was a problem hiding this comment.
The hardlinks don't work on my Linux machine:
java.nio.file.FileSystemException: /tmp/proguard.InputReaderTest7748393587331681400/lib/jrt-fs.jar -> /home/fergal/.jdks/corretto-11.0.21/lib/jrt-fs.jar: Invalid cross-device link
Using a symbolic link instead fixes it for me. If that doesn't work universally, it may be worth creating minimal jmods/jars/modules for ProGuard to load, either building them in the test or adding them as resource files.
|
- Select the jmod profile by java.base.jmod existence instead of a JDK version range; the java24+ profile left ProGuard with no JDK classes. - Add java9+-without-jmods profile which extracts java.base from jrt:/ into a jar (src/build/ExtractJdk.java) for JDKs shipped without jmods (JEP 493; e.g., Temurin 24+). To be removed once ProGuard falls back to jrt:/ by itself: Guardsquare/proguard#541 - Update parent, proguard-base 7.10.0, proguard-core 9.4.1, and plugins. - docker.maven.sh: accept <tag> <phase>, allocate a tty only when present. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
|
Also verified this on Macos JDK ✅ |



Needs Guardsquare/proguard-core#186
See also original POC #504
Resolves #473 (hopefully)