-
Bug
-
Resolution: Duplicate
-
P3
-
8u31
-
x86_64
-
windows_7
FULL PRODUCT VERSION :
1.8.0_31
A DESCRIPTION OF THE PROBLEM :
Annotation with target TYPE_USE seems to be copied to bridge methods. As bridge methods only delegate back to the overloaded method, these annotations are typically invalid. The reproducer shows that the type annotations specifies a PC range which is longer than the byte code of the method.
Probably type annotations shouldn't be copied to bridge methods. Please find reproducer, decompiled class file and analysis here:
https://gist.github.com/marchof/070ee2c2077bd095ba96
ERROR MESSAGES/STACK TRACES THAT OCCUR :
Byte code processing tools like ASM file to parse files with invalid annotations.
REPRODUCIBILITY :
This bug can be reproduced always.
REPRODUCER:
The annotation with target TYPE_USE in the method doit(java.lang.Runnable) is copied
to the bridge method doit(java.lang.Object). While the bridge method only has 8
instructions, the range of the type annotation has a length of 15.
---------- BEGIN SOURCE ----------
import java.lang.annotation.ElementType;
import java.lang.annotation.Retention;
import java.lang.annotation.RetentionPolicy;
import java.lang.annotation.Target;
public class ClassWithBridgeMethod<T extends Runnable> implements ParameterizedInterface<T> {
@Override
public void doit(final T t) {
@TypeUseAnnotation
Object x = null;
// Some instructions just to widen the scope of annotation for x
System.out.println(x);
System.out.println(x);
}
}
interface ParameterizedInterface<T> {
void doit(T arg);
}
@Target({ ElementType.TYPE_USE })
@Retention(RetentionPolicy.CLASS)
@interface TypeUseAnnotation {
}
---------- END SOURCE ----------
1.8.0_31
A DESCRIPTION OF THE PROBLEM :
Annotation with target TYPE_USE seems to be copied to bridge methods. As bridge methods only delegate back to the overloaded method, these annotations are typically invalid. The reproducer shows that the type annotations specifies a PC range which is longer than the byte code of the method.
Probably type annotations shouldn't be copied to bridge methods. Please find reproducer, decompiled class file and analysis here:
https://gist.github.com/marchof/070ee2c2077bd095ba96
ERROR MESSAGES/STACK TRACES THAT OCCUR :
Byte code processing tools like ASM file to parse files with invalid annotations.
REPRODUCIBILITY :
This bug can be reproduced always.
REPRODUCER:
The annotation with target TYPE_USE in the method doit(java.lang.Runnable) is copied
to the bridge method doit(java.lang.Object). While the bridge method only has 8
instructions, the range of the type annotation has a length of 15.
---------- BEGIN SOURCE ----------
import java.lang.annotation.ElementType;
import java.lang.annotation.Retention;
import java.lang.annotation.RetentionPolicy;
import java.lang.annotation.Target;
public class ClassWithBridgeMethod<T extends Runnable> implements ParameterizedInterface<T> {
@Override
public void doit(final T t) {
@TypeUseAnnotation
Object x = null;
// Some instructions just to widen the scope of annotation for x
System.out.println(x);
System.out.println(x);
}
}
interface ParameterizedInterface<T> {
void doit(T arg);
}
@Target({ ElementType.TYPE_USE })
@Retention(RetentionPolicy.CLASS)
@interface TypeUseAnnotation {
}
---------- END SOURCE ----------
- duplicates
-
JDK-8160928 javac incorrectly copies over interior type annotations to bridge method
-
- Closed
-