Unable to create snapshots with Java modules
Nikola Grcevski
grcevski at gmail.com
Tue Nov 29 18:51:33 UTC 2022
Thanks again Anton! I confirm that your patch works and it
is much simpler than the hacks I did in os_linux:
https://github.com/grcevski/crac/pull/1
I'm guessing since the jars are recorded in URLClassPath
and in ModuleReferences now, those mark_classpaths are
probably not needed. I did a quick experiment by commenting
out:
do_classpaths(mark_classpath_entry, &fds, Arguments::get_appclasspath());
I didn't see any issue while running by using the class path approach.
On Tue, Nov 29, 2022 at 1:08 PM Anton Kozlov <akozlov at azul.com> wrote:
>
> Hmm, I came up with the pure Java solution [1]. I'm not sure those mark_classpath functions are still actual or required.
>
> [1] https://github.com/openjdk/crac/pull/35
>
> Thanks,
> Anton
>
> On 11/29/22 18:36, Nikola Grcevski wrote:
> > I found out the issue I had with my directory, I was using a symlinked file, so
> > the parent directory doesn't match the st_ino of the file. Perhaps
> > there's a much
> > better way, but I managed to get things to work with the following addition
> > (no symlink support):
> >
> > static void mark_classpath_or_dir(FdsInfo *fds, char* cp) {
> > DIR *dir = os::opendir(cp);
> > if (!dir) {
> > mark_classpath_entry(fds, cp);
> > return;
> > }
> > os::closedir(dir);
> > mark_all_in(fds, cp);
> > }
> >
> > ...
> > do_classpaths(mark_classpath_or_dir, &fds, Arguments::get_appmodulepath());
> >
> > I also had to make a small change in do_classpaths, at the end instead
> > of calling
> > mark_classpath_entry, I changed it to call fn(fds, cp).
> >
> > On Tue, Nov 29, 2022 at 11:24 AM Nikola Grcevski <grcevski at gmail.com> wrote:
> >>
> >> Great, thanks!
> >>
> >> I started looking at it as well, I added
> >>
> >> arguments.cpp/hpp
> >> _java_module_path = new SystemProperty("jdk.module.path", "", true);
> >>
> >> and in os_linux.cpp
> >> do_classpaths(mark_classpath_entry, &fds, Arguments::get_appmodulepath());
> >>
> >> I was able to make things work if I put the expanded module path directly e.g:
> >> --module-path lib/simplemodule-1.0-SNAPSHOT.jar
> >>
> >> I'm not sure if there's a helper to expand the module path fully with
> >> directories, when I tried
> >> to create a mark function that handles both directories and files, the
> >> directory scan
> >> and mark never matches on my app lib directory on this check:
> >>
> >> if (dent->d_ino == fstat->st_ino)
> >>
> >> in os_linux::static void mark_all_in(FdsInfo *fds, char* dirpath).
> >>
> >> Thanks so much for your help.
> >> Nikola
> >>
> >> On Tue, Nov 29, 2022 at 11:11 AM Anton Kozlov <akozlov at azul.com> wrote:
> >>>
> >>> On 11/29/22 00:04, Nikola Grcevski wrote:
> >>>> However, if I try the same thing with the modules usage, the snapshot
> >>>> creation fails:
> >>>> ~/work/simplemodule$ /<path>/openjdk-17-crac+3_linux-x64/bin/java
> >>>> -XX:CRaCCheckpointTo=/tmp/simple --module-path lib --module
> >>>> simplemodule/co.elastic.simple.SimpleModule
> >>>
> >>> Hi Nikola,
> >>>
> >>> I've reproduced the problem. It seems JDK misses a piece of code for modules that is there for class loaders. It looks easy to fix, I'm looking at this.
> >>>
> >>> Meanwhile, while you're experimenting, you may disable CheckpointException by -XX:+UnlockExperimentalVMOptions -XX:-CRDoThrowCheckpointException. Of course, it's not recommended for anything beyond experiments :)
> >>>
> >>> Thanks,
> >>> Anton
More information about the crac-dev
mailing list