The quickfix to fix the return type in the following code doesn't work.
import java.lang.reflect.AccessibleObject;
public class WeirdAnonymousThingy {
@Override
public void m() {
new AccessibleObject() {
public void getAnnotation(Class annotationClass) {
}
};
}
}
It's a particular nasty edge case: this anonymous class inherits a method that has a method-level type parameter with a bound set, and the return type is that type variable. (see the javadoc for AccessibleObject.getAnnotation)
Pre-1.5, the erasure of the type variable is calculated as the value that void gets replaced with. Post 1.5, the type variable is inserted in place of void, which results in invalid code, since the type variable is declared in the override implementation.
I think that ideally this quickfix should provide two options:
Returning a type variable (and properly declaring it)
The quickfix to fix the return type in the following code doesn't work.
It's a particular nasty edge case: this anonymous class inherits a method that has a method-level type parameter with a bound set, and the return type is that type variable. (see the javadoc for AccessibleObject.getAnnotation)
Pre-1.5, the erasure of the type variable is calculated as the value that
void
gets replaced with. Post 1.5, the type variable is inserted in place ofvoid
, which results in invalid code, since the type variable is declared in the override implementation.I think that ideally this quickfix should provide two options: