Generics and amount of methods in class

Viewed 74

I have a doubt and I cannot find where in the Java specification language is defined (which I'm sure it is).

I have this hierarchy:

public interface Top<T extends Serializable>
{
    public String someMethod(T arg);
}

public class SubString implements Top<String>
{
    @Override
    public String someMethod(final String arg)
    {
        return "";
    }
}

public class SubSerializable implements Top<Serializable>
{
    @Override
    public String someMethod(final Serializable arg)
    {
        return "";
    }
}

And I execute this piece of code:

public static void main(final String[] args)
{
    System.out.println(SubString.class.getMethods().length); // outputs 11
    System.out.println(SubString.class.getDeclaredMethods().length); // outputs 2
    System.out.println(SubSerializable.class.getMethods().length); // outputs 10
    System.out.println(SubSerializable.class.getDeclaredMethods().length); // outputs 1
}

In the getMethods returning array for SubString class there are two someMethod, one with the signature Serializable and one with the signature String. Even in the declaredMethods both are present.

How could I tear apart those that are not "callable"?

1 Answers
Related