JDK-8282241 : Invalid generic signature for redefined classes
  • Type: Bug
  • Component: hotspot
  • Sub-Component: jvmti
  • Affected Version: 17
  • Priority: P3
  • Status: Closed
  • Resolution: Fixed
  • OS: generic
  • CPU: generic
  • Submitted: 2022-02-11
  • Updated: 2022-03-31
  • Resolved: 2022-03-23
The Version table provides details related to the release that this issue/RFE will be addressed.

Unresolved : Release in which this issue/RFE will be addressed.
Resolved: Release in which this issue/RFE has been resolved.
Fixed : Release in which this issue/RFE has been fixed. The release containing this fix may be available for download as an Early Access Release or a General Availability Release.

To download the current JDK release, click here.
JDK 19
19 b16Fixed
Related Reports
Cloners :  
Relates :  
Relates :  
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



Comments
Changeset: f0177395 Author: Alex Menkov <amenkov@openjdk.org> Date: 2022-03-23 18:31:34 +0000 URL: https://git.openjdk.java.net/jdk/commit/f01773956fbc092b00c18392735a020ca05257ed
23-03-2022

Additional Information from submitter: =========================== To run the New Relic Java agent with Java 18+, add the following to the java command: -Dnewrelic.config.experimental_runtime=true
07-03-2022

A pull request was submitted for review. URL: https://git.openjdk.java.net/jdk/pull/7676 Date: 2022-03-03 15:07:05 +0000
03-03-2022

Developed small reproducer. jdk19 is affected.
25-02-2022

But the message "Java version is: 18. This version of the New Relic Agent does not support versions of Java greater than 17" looks confusing. Maybe for jdk18 & jdk19 the agent doesn't instrument classes. Trying to develop small test to reproduce the issue
25-02-2022

Not able to reproduce with jdk19 and 18: java version "19-internal" 2022-09-20 Java(TM) SE Runtime Environment (fastdebug build 19-internal+0-2022-02-09-1159095.AMENKOV...) Java HotSpot(TM) 64-Bit Server VM (fastdebug build 19-internal+0-2022-02-09-1159095.AMENKOV..., mixed mode, sharing) ---------- ---------- getGenericSignature0: <T:Ljava/lang/Object;>Ljava/lang/Object;Ljava/util/concurrent/Future<TT;>;Ljava/util/concurrent/CompletionStage<TT;>; expected: <T:Ljava/lang/Object;>Ljava/lang/Object;Ljava/util/concurrent/Future<TT;>;Ljava/util/concurrent/CompletionStage<TT;>; OK TYPE: java.util.concurrent.CompletableFuture<java.util.List<java.lang.String>> openjdk version "18" 2022-03-22 OpenJDK Runtime Environment (build 18+36-2087) OpenJDK 64-Bit Server VM (build 18+36-2087, mixed mode, sharing) ---------- Java version is: 18. This version of the New Relic Agent does not support versions of Java greater than 17. ---------- getGenericSignature0: <T:Ljava/lang/Object;>Ljava/lang/Object;Ljava/util/concurrent/Future<TT;>;Ljava/util/concurrent/CompletionStage<TT;>; expected: <T:Ljava/lang/Object;>Ljava/lang/Object;Ljava/util/concurrent/Future<TT;>;Ljava/util/concurrent/CompletionStage<TT;>; OK TYPE: java.util.concurrent.CompletableFuture<java.util.List<java.lang.String>>
25-02-2022

Looking at the history I would have to suspect JDK-8267555 may be involved.
22-02-2022

I tried to reproduce the issue. Execute run.sh to minimize the effort to reproduce the issue. I got exception when I tried with JDK 17.0.2. See attached logs. Following are my observation: JDK 11 - pass (correct output - TYPE: java.util.concurrent.CompletableFuture<java.util.List<java.lang.String>>) JDK 16 - pass (correct output - TYPE: java.util.concurrent.CompletableFuture<java.util.List<java.lang.String>>) JDK 17 - fails (exception occured Exception in thread "main" java.lang.reflect.GenericSignatureFormatError: Signature Parse error: expected a class type) This is a regression.
22-02-2022