<!DOCTYPE html><html><head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
  </head>
  <body>
    <p><br>
    </p>
    <div class="moz-cite-prefix">On 2/13/25 4:25 PM, Charles Oliver
      Nutter wrote:<br>
    </div>
    <blockquote type="cite" cite="mid:CAE-f1xQJboygq6qEoSDq4azC9yH7q-yCWLTb75zRJJVCn+Qr9A@mail.gmail.com">
      
      <div dir="ltr">
        <div dir="ltr">On Wed, Feb 12, 2025 at 4:22 PM Charles Oliver
          Nutter <<a href="mailto:headius@headius.com" moz-do-not-send="true" class="moz-txt-link-freetext">headius@headius.com</a>>
          wrote:</div>
        <div class="gmail_quote gmail_quote_container">
          <blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex">
            <div dir="ltr">
              <div class="gmail_quote">
                <blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex">
                  <div>
                    <p>Have you tried the -XX:+AutoCreateSharedArchive
                      flag? It should recreate the dynamic archive if
                      you have updated the app's JAR files or updated to
                      a new JDK.<br>
                    </p>
                  </div>
                </blockquote>
                <div>This is definitely what we want for the JRuby
                  launcher! I've integrated it into the launcher and it
                  seems to work well (my log redirects must still be
                  included to silence CDS warnings, though):</div>
              </div>
            </div>
          </blockquote>
          <div><br>
          </div>
          <div>I am seeing two peculiar warnings in the log file while
            using this flag:</div>
          <div><br>
          </div>
          [0.001s][info][cds] optimized module handling: disabled due to
          incompatible property:
          jdk.module.path=/Users/headius/work/jruby/lib/jruby.jar</div>
        <div class="gmail_quote gmail_quote_container"><br>
        </div>
        <div class="gmail_quote gmail_quote_container">This is not a
          property I'm setting. The full command line for this JRuby
          execution is here:</div>
        <div class="gmail_quote gmail_quote_container"><br>
        </div>
        <div class="gmail_quote gmail_quote_container">/Library/Java/JavaVirtualMachines/zulu-21.jdk/Contents/Home/bin/java
          @/Users/headius/work/jruby/bin/.jruby.java_opts
          @/Users/headius/work/jruby/bin/.jruby.module_opts -Xss2048k
          -XX:+AutoCreateSharedArchive
          -XX:SharedArchiveFile=/Users/headius/work/jruby/lib/jruby.jsa
          -Xlog:cds=off -Xlog:cds+dynamic=off
          -Djffi.boot.library.path=/Users/headius/work/jruby/lib/jni
          -Djava.security.egd=<a class="moz-txt-link-freetext" href="file:/dev/urandom">file:/dev/urandom</a> --module-path
          /Users/headius/work/jruby/lib/jruby.jar -classpath :
          -Djruby.home=/Users/headius/work/jruby
          -Djruby.lib=/Users/headius/work/jruby/lib -Djruby.script=jruby
          -Djruby.shell=/bin/sh org.jruby.Main -e 1</div>
        <div class="gmail_quote gmail_quote_container"><br>
        </div>
      </div>
    </blockquote>
    <p>That message is a bit cryptic. Basically "--module-path dir" gets
      translated to "-Djdk.module.path=dir" by the Java launcher.
      Because of that, the archived module graph in the default CDS
      archive cannot be used. This is normal in your use case.<br>
    </p>
    <p><br>
    </p>
    <blockquote type="cite" cite="mid:CAE-f1xQJboygq6qEoSDq4azC9yH7q-yCWLTb75zRJJVCn+Qr9A@mail.gmail.com">
      <div dir="ltr">
        <div class="gmail_quote gmail_quote_container">The java_opts
          file is empty and the module_opts file just has some add-opens
          we need.</div>
        <div class="gmail_quote gmail_quote_container"><br>
          [0.001s][warning][cds] AutoCreateSharedArchive is ignored
          because /Users/headius/work/jruby/lib/jruby.jsa is a static
          archive<br>
          <div><br>
          </div>
          <div>I have no idea what this means. Once I get in this state
            it complains every startup and will also refuse to overwrite
            the "bad" jsa file. I had thought that it would overwrite
            the file if it could not use it, so I don't have to manually
            separate CDS archives from different JDKs... did I
            misunderstand?</div>
        </div>
      </div>
    </blockquote>
    <p><br>
    </p>
    <p>Did you create /Users/headius/work/jruby/lib/jruby.jsa with "java
      -Xshare:dump" or "java -XX:AOTMode=create"? If so, it will be
      recognized as a "static archive". </p>
    <p>I created <a class="moz-txt-link-freetext" href="https://bugs.openjdk.org/browse/JDK-8350057">https://bugs.openjdk.org/browse/JDK-8350057</a> to address
      this issue.</p>
    <p>If you want to work around this bug, you can check the magic
      number of the file:</p>
    <p><a class="moz-txt-link-freetext" href="https://github.com/openjdk/jdk/blob/ff52859d2ad65b97c56dd19323213a0d07be47ae/src/hotspot/share/include/cds.h#L39-L40">https://github.com/openjdk/jdk/blob/ff52859d2ad65b97c56dd19323213a0d07be47ae/src/hotspot/share/include/cds.h#L39-L40</a></p>
    <p>#define CDS_ARCHIVE_MAGIC 0xf00baba2<br>
      #define CDS_DYNAMIC_ARCHIVE_MAGIC 0xf00baba8<br>
    </p>
    <p>If the magic number is not 0xf00baba8, you can delete the file
      before running with "java -XX:+AutoCreateSharedArchive
      -XX:SharedArchiveFile=..."</p>
    <p>Thanks</p>
    <p>- Ioi<br>
    </p>
  </body>
</html>