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

HHH-14858 - Implement JRT Module Readers #4265

Closed
wants to merge 3 commits into from

Conversation

GedMarc
Copy link

@GedMarc GedMarc commented Sep 29, 2021

This PR allows reading the JRT virtual file system, which uses a new URL format structure to reference to files located in the module VFS

@hibernate-github-bot
Copy link

hibernate-github-bot bot commented Sep 29, 2021

Thanks for your pull request!

This pull request does not follow the contribution rules. Could you have a look?

❌ All commit messages should start with a JIRA issue key matching pattern HHH-\d+
    ↳ Offending commits: [5273cc5, d21a026, 6eb0210]

› This message was automatically generated.

Copy link
Member

@sebersole sebersole left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don't know much about the JRT format, but lgtm

@yrodiere
Copy link
Member

Maybe a test would be a good idea? :)

@GedMarc
Copy link
Author

GedMarc commented Sep 29, 2021

Yeah definitely - difficult to do though as you need a 100% module-info chain to create a native runtime, and gradle is not quite there yet with jlink, jpackage and jmod support

Hmm, can fong the test though, as it's just a URL handler with a string extract - will get one in for you @yrodiere, but without building a JLink/JMod package, you never see the JRT filesystem ;) Would this be acceptable or do we need a non-flaky non-fudged test xD

Can I do something like we did for Jackson? (https://github.com/FasterXML/jackson-jdk11-compat-test)

I had to create a separate project that builds up the JLink artifact, and then executes the tests through the native runtime to replicate all JRT related issues (being a fully read only filesystem)

@yrodiere
Copy link
Member

That seems awfully complicated; no, I don't think this is worth creating a new module and trying to use jlink.

But jrt:/ URLs only require your test to run in the modulepath, right? You don't need jlink, native compilation, or anything like that?

There already is a module that runs tests in the modulepath: hibernate-integrationtest-java-modules. So you could just add a (unit) test in hibernate-integrationtest-java-modules/src/test/java. I would keep it simple: just instantiate JRTInputStreamBasedArchiveDescriptor, pass it a jrt:/ URL to a random module that you know will be in the modulepath, and check that it collects an entry that you know should be there.

Maybe that won't reliably test that your use case is addressed, but at least this will check that your implementation successfully retrieves entries from jrt:/ URLs.

@GedMarc
Copy link
Author

GedMarc commented Sep 29, 2021

I definitely agree with you that's it is awfully complicated :)
The JRT only exists for native runtimes, so JLink etc, no other way to access that VFS or use/create the jrt:// urls that I know of ;)
Under class path mode (or loose module mode, a.k.a. not a physical module distribution but running off JAR's instead of compiled JMOD's), the JRT system isn't even included as loaded on a JDK (cause you can't use the new fast-class constructor, the new SPI service, resource finder etc and all the other pretty things that come with native modules and do not operate or even load with classpath/jar files)

What we are looking at here is similar to this https://stackoverflow.com/questions/54140750/java-nio-cant-read-files-from-jrt-image - except it's a jar archive read instead of an Io resource read

I'm creating a URLStreamHandlerProvider that will fudge the JRT URL and locate accordingly in a jar file, that will at least give us an authentic test on the URL handling and reading :)

@GedMarc GedMarc changed the title Implement JRT Module Readers HHH-14858 - Implement JRT Module Readers Sep 29, 2021
@GedMarc
Copy link
Author

GedMarc commented Sep 29, 2021

recreating under correct commit strategy with test cases

@GedMarc GedMarc closed this Sep 29, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
4 participants