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

Invalid generic signature for redefined classes

    XMLWordPrintable

Details

    • 17
    • b16
    • generic
    • generic
    • Fix failed

    Description

      ADDITIONAL SYSTEM INFORMATION :
      MacOS 11.6.3 (x64)/ Linux Debian 9 (x64 VM)
      Java: Temurin 17.0.2 / Oracle 17.0.2

      A DESCRIPTION OF THE PROBLEM :
      At New Relic we instrument classes to send telemetry data to our servers. We use ASM for bytecode manipulation.

      We instrument CompletableFuture, and since Java 17 it has returned an improper value when Class#getGenericSignature0() is called.
      This works fine when the running on Java 16 or lower.

      The following has a repro app and more information on the investigation done.
      https://github.com/meiao/genericSignature-jdk17-bug

      Note that the source code added in the ticket will not reproduce the issue by itself. Use the repro app that will download the New Relic agent and execute the app in a way that the bug will occur.

      REGRESSION : Last worked in version 16

      STEPS TO FOLLOW TO REPRODUCE THE PROBLEM :
      Modify CompletableFuture using a Java agent.
      Using reflection, call Class#getGenericSignature0() on CompletableFuture.class.
      Check the returned String.

      EXPECTED VERSUS ACTUAL BEHAVIOR :
      EXPECTED -
      <T:Ljava/lang/Object;>Ljava/lang/Object;Ljava/util/concurrent/Future<TT;>;Ljava/util/concurrent/CompletionStage<TT;>;
      ACTUAL -
      java/util/concurrent/CompletableFuture

      ---------- BEGIN SOURCE ----------
      import java.lang.invoke.MethodHandle;
      import java.lang.invoke.MethodHandles;
      import java.lang.invoke.MethodType;
      import java.lang.reflect.Type;
      import java.util.List;
      import java.util.concurrent.CompletableFuture;

      public class Tester {

          public static void main(String... args) throws Throwable {

              MethodHandles.Lookup lookup = MethodHandles.lookup();
              MethodHandles.Lookup classLookup = MethodHandles.privateLookupIn(Class.class, lookup);
              MethodHandle getGenericSignature0 = classLookup.findVirtual(Class.class, "getGenericSignature0", MethodType.methodType(String.class));
              Object genericSignature = getGenericSignature0.invoke(CompletableFuture.class);

              System.out.println();
              System.out.println("getGenericSignature0: " + genericSignature);
              System.out.println("expected: <T:Ljava/lang/Object;>Ljava/lang/Object;Ljava/util/concurrent/Future<TT;>;Ljava/util/concurrent/CompletionStage<TT;>;");
              System.out.println();

              Type type = Tester.class.getDeclaredMethod("testing").getGenericReturnType();
              System.out.println("TYPE: " + type);
          }

          public CompletableFuture<List<String>> testing() {
              return null;
          }
      }

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

      CUSTOMER SUBMITTED WORKAROUND :
      Not modifying the CompletableFuture class. Which is not desirable.

      FREQUENCY : always


      Attachments

        1. genericSignature-jdk17-bug-main.zip
          87 kB
        2. JDK-11.log
          2 kB
        3. JDK-16.log
          2 kB
        4. JDK-17.log
          4 kB

        Issue Links

          Activity

            People

              amenkov Alex Menkov
              webbuggrp Webbug Group
              Votes:
              0 Vote for this issue
              Watchers:
              8 Start watching this issue

              Dates

                Created:
                Updated:
                Resolved: