Getting return type of method which specializes the interface's return type
I did this test with the following version of JRockit:
java version "1.6.0_33"
Java(TM) SE Runtime Environment (build 1.6.0_33-b03)
Oracle JRockit(R) (build R28.2.4-14-151097-1.6.0_33-20120618-1634-windows-x86_64, compiled mode)
Given the classes below:
--- Base.java ---
public interface Base {
public Object getSomething();
}
-- Derived.java ---
public class Derived implements Base {
public Long getSomething() {
return 1L;
}
}
-- Main.java ---
import java.beans.*;
public class Main {
public static void main(String s[]) throws Exception {
BeanInfo info = Introspector.getBeanInfo(Derived.class);
for (PropertyDescriptor pd: info.getPropertyDescriptors()){
System.out.printf("%s - %s\n", pd.getReadMethod().getName(), pd.getReadMethod().getReturnType());
}
}
}
when executing Main, I see the following output:
getClass - class java.lang.Class
getSomething - class java.lang.Object
I would expect the second line to be "getSomething - class java.lang.Long". Should I consider this a bug?
Greetings,
Gianluca