Skip to Main Content

Getting return type of method which specializes the interface's return type

968571Oct 16 2012
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:

--- ---
public interface Base {
public Object getSomething();

-- ---
public class Derived implements Base {
public Long getSomething() {
return 1L;

-- ---
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?

Post Details
Locked due to inactivity on Nov 13 2012
Added on Oct 16 2012