Uploaded image for project: 'JDK'
  1. JDK
  2. JDK-8286277

CDS VerifyError when calling clone() on object array

    XMLWordPrintable

Details

    • b24
    • x86_64
    • linux

    Backports

      Description

        ADDITIONAL SYSTEM INFORMATION :
        Linux (Fedora 35), verified against Java 18 and 17.0.3

        A DESCRIPTION OF THE PROBLEM :
        While trying to use AppCDS with an application with several dependencies outside of our control, we found a VerifyError that happens when a specific Kotlin class is loaded from a shared archive.


        STEPS TO FOLLOW TO REPRODUCE THE PROBLEM :
        Download the following popular Kotlin jars from Maven Central:

        https://search.maven.org/remotecontent?filepath=com/squareup/okio/okio/2.10.0/okio-2.10.0.jar
        https://search.maven.org/remotecontent?filepath=com/squareup/okhttp3/okhttp/4.9.3/okhttp-4.9.3.jar
        https://search.maven.org/remotecontent?filepath=org/jetbrains/kotlin/kotlin-stdlib/1.6.21/kotlin-stdlib-1.6.21.jar

        Compile the attached source code against third-party JARs:
        % javac -cp okhttp-4.9.3.jar:kotlin-stdlib-1.6.21.jar KtCdsVerifyError.java

        Create a JAR for CDS:
        % jar -cf KtCdsVerifyError.jar KtCdsVerifyError.class

        Create a shared archive:
        % java -XX:ArchiveClassesAtExit=ktcds.jsa -cp okio-2.10.0.jar:okhttp-4.9.3.jar:kotlin-stdlib-1.6.21.jar:KtCdsVerifyError.jar KtCdsVerifyError

        Re-execute the program using the shared archive:
        % java -XX:SharedArchiveFile=ktcds.jsa -cp okio-2.10.0.jar:okhttp-4.9.3.jar:kotlin-stdlib-1.6.21.jar:KtCdsVerifyError.jar KtCdsVerifyError


        EXPECTED VERSUS ACTUAL BEHAVIOR :
        EXPECTED -
        The program should run successfully with no output whether launched with a shared archive or not.
        ACTUAL -
        When run with the created shared archive, the program fails:

        Exception in thread "main" java.lang.VerifyError: Bad type on operand stack
        Exception Details:
          Location:
            okhttp3/internal/Util
          Reason:
            Type '[Ljava/lang/Object;' is not assignable to 'okhttp3/internal/Util'

        at okhttp3.HttpUrl$Builder.parse$okhttp(HttpUrl.kt:1239)
        at okhttp3.HttpUrl$Companion.get(HttpUrl.kt:1633)
        at okhttp3.HttpUrl.get(HttpUrl.kt)
        at KtCdsVerifyError.main(KtCdsVerifyError.java:5)


        ---------- BEGIN SOURCE ----------
        import okhttp3.HttpUrl;

        public class KtCdsVerifyError {
            public static void main(final String[] args) {
                HttpUrl.get("http://example.com");
            }
        }

        ---------- END SOURCE ----------

        CUSTOMER SUBMITTED WORKAROUND :
        Avoid loading Kotlin classes at CDS archive time.

        FREQUENCY : always


        Attachments

          Issue Links

            Activity

              People

                iklam Ioi Lam
                webbuggrp Webbug Group
                Votes:
                0 Vote for this issue
                Watchers:
                7 Start watching this issue

                Dates

                  Created:
                  Updated:
                  Resolved: