-
Bug
-
Resolution: Fixed
-
P3
-
21.0.1, 22
-
b16
-
generic
-
generic
The following record parameter annotation will cause a ClassFileFormat error, if the class is put through Instrumentation.retransformation, even if no class file transformer is registered.
class Sample {
@interface MyAnnotation{}
public record MyRecord(@MyAnnotation Object o, Object other) {}
public static void main(String[] args) throws Exception {
Instrumentation inst = ByteBuddyAgent.install();
inst.retransformClasses(MyRecord.class);
}
}
This can also be seen if using javap where the relevant segment is displayed as follows:
Record: length = 0xE (java.lang.reflect.InvocationTargetException)
00 02 00 0B 00 0C 00 01 00 0F 00 0C 00 00
If the annotation is declared with runtime retention, the problem goes away.
class Sample {
@interface MyAnnotation{}
public record MyRecord(@MyAnnotation Object o, Object other) {}
public static void main(String[] args) throws Exception {
Instrumentation inst = ByteBuddyAgent.install();
inst.retransformClasses(MyRecord.class);
}
}
This can also be seen if using javap where the relevant segment is displayed as follows:
Record: length = 0xE (java.lang.reflect.InvocationTargetException)
00 02 00 0B 00 0C 00 01 00 0F 00 0C 00 00
If the annotation is declared with runtime retention, the problem goes away.