RFR: 8276184: Add CDS test on lambda proxy class with java agent

Ioi Lam iklam at openjdk.java.net
Tue Nov 2 05:56:12 UTC 2021


On Tue, 2 Nov 2021 01:54:00 GMT, Calvin Cheung <ccheung at openjdk.org> wrote:

> Adding a test when an interface (major version 49) of a lambda proxy class is being transformed by a java agent during
> CDS dump time and run time. The java agent will update the version of the interface to 50.  During dump time, the
> interface will be included in the CDS archive. During run time, any transformed classes will not be loaded from the
> archive.
> 
> The new tests passed tiers 1,2,3,4 testing.

Hi Calvin, the reason I suggested adding more tests for lambda proxies (for JDK-8274944) is for these two cases in SystemDictionaryShared::check_for_exclusion_impl():


  if (has_been_redefined(k)) {
    return warn_excluded(k, "Has been redefined");    <<<<<< HERE
  }
  if (k->signers() != NULL) {
    // We cannot include signed classes in the archive because the certificates
    // used during dump time may be different than those used during
    // runtime (due to expiration, etc).
    return warn_excluded(k, "Signed JAR");  <<<< HERE
  }


The second case should be pretty easy to test for:


class SignedFoo {
    public static void main(final String... args) {
        System.out.println(getRunnable());
    }

    public static Runnable getRunnable() {
        return () -> {};
    }
}

$ java -cp . SignedFoo
SignedFoo$$Lambda$1/0x0000000800c009f0 at 7344699f

Since we don't archive SignedFoo, we should also not archive the lambda proxy class generated for SignedFoo.

The first case would be a bit more involved:


class RedefinedFoo {
    public static void main(final String... args) {
        System.out.println(getRunnable());   // line A
        try_to_redefine_this_class();              // line B
    }

    public static Runnable getRunnable() {
        return () -> {};
    }
}


At line A, the lambda proxy is generated. At line B, InstanceKlass::has_been_redefined() will return true for RedefinedFoo. This should cause RedefinedFoo to be excluded from the archive, and thus the lambda proxy should be excluded as well.

For these test cases, I think it would be better to use dynamic dump, since it's legal for program to perform these actions while running with -XX:ArchiveClassesAtExit=foo.jsa.

-------------

PR: https://git.openjdk.java.net/jdk/pull/6205


More information about the hotspot-runtime-dev mailing list