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

Retransformation of lambdas causes verifier errors and no class def found errors

XMLWordPrintable

    • x86
    • linux_ubuntu

      FULL PRODUCT VERSION :


      A DESCRIPTION OF THE PROBLEM :
      When a class that is loaded by an anonymous class loader (e.g. a lambda expression's class) is retransformed, the retransformation process causes the class to loose its properties as an anonymous class. As a result, verifier errors or no class def found errors are triggered.

      STEPS TO FOLLOW TO REPRODUCE THE PROBLEM :
      Run the below code example from a Java agent in order to get hold of an instance of the instrumentation interface.

      EXPECTED VERSUS ACTUAL BEHAVIOR :
      EXPECTED -
      The transformation should be a no-op, i.e. the transformation should not have an effect.
      ACTUAL -
      Errors are thrown.

      REPRODUCIBILITY :
      This bug can be reproduced always.

      ---------- BEGIN SOURCE ----------
      class Foo {
          void notFoundAfterRetransform() throws Exception {
              Instrumentation instrumentation = ... // run via an agent.
              instrumentation.addTransformer((loader, className, classBeingRedefined, protectionDomain, classfileBuffer) -> null, true); // No-op

              instrumentation.retransformClasses(fooHolder().getClass()); // instrumentation.isModifiableClass(type) == true

              fooHolder().getClass();
          }

        void verifierErrorOnRetransform() throws Exception {
              Instrumentation instrumentation = ByteBuddyAgent.install();
              instrumentation.addTransformer((loader, className, classBeingRedefined, protectionDomain, classfileBuffer) -> null, true); // No-op

              instrumentation.retransformClasses(barHolder().getClass()); // instrumentation.isModifiableClass(type) == true
          }

          Function<?, ?> fooHolder() {
              return this::foo;
          }

          public Object foo(Object p) {
              return null;
          }

          Function<?, ?> barHolder() {
              return this::bar;
          }

          private Object bar(Object p) {
              return null;
          }
      }
      ---------- END SOURCE ----------

            fmatte Fairoz Matte
            webbuggrp Webbug Group
            Votes:
            0 Vote for this issue
            Watchers:
            2 Start watching this issue

              Created:
              Updated:
              Resolved: