There is an existing answer to determine whether a method is overriden if there is no generics involved.
Java will remove generic type entirely due to type erasure. So the bytecode would be:
class FooImpl implements Foo<java.lang.String> {
FooImpl();
Code:
0: aload_0
1: invokespecial #10 // Method java/lang/Object."<init>":()V
4: return
public void doStuff(java.lang.String);
Code:
0: return
public void doStuff(java.lang.Object);
Code:
0: aload_0
1: aload_1
2: checkcast #21 // class java/lang/String
5: invokevirtual #23 // Method doStuff:(Ljava/lang/String;)V
8: return
}
There is two doStuff method. It is a bridge method. It simply do type cast and invoke the void doStuff(java.lang.String), so actually void doStuff(java.lang.String) is not overriden, but void doStuff(java.lang.Object) is. When you use polymorphism like:
Foo foo = new FooImpl();
foo.doStuff("ABC")
It actually calls void doStuff(java.lang.Object). So if you use the above link to detect whether void doStuff(java.lang.Object) is overriden, it will report yes.
public static void main(java.lang.String[]);
Code:
0: new #1 // class FooImpl
3: dup
4: invokespecial #22 // Method "<init>":()V
7: astore_1
8: aload_1
9: ldc #23 // String ABC
11: invokeinterface #25, 2 // InterfaceMethod Foo.doStuff:(Ljava/lang/Object;)V
16: return