Essential Java Generics states that the output for this code:
public interface Foo<T> {
void foo(T param);
}
public class Bar implements Foo<Bar> {
// This method will appear twice once with Object as parameter and once with Bar.
public void foo(Bar param) {
}
public static void main(String[] args) {
for (Method m : Bar.class.getMethods())
if (m.getName().startsWith("foo"))
System.out.println(m.toGenericString());
}
}
is:
public void Bar.foo(Bar)
public volatile void Bar.foo(java.lang.Object)
But when I compiled (1.7 compiler) and run the code, I have:
public void Bar.foo(Bar)
public void Bar.foo(java.lang.Object)
I re-compiled it using a 1.6 compiler. But my output is still the same.
The author's exact quote is:
$ java Bar public void Bar.foo(Bar) public volatile void Bar.foo(java.lang.Object)
So it doesn't seem like a typo error on his part.
What is causing the output to be different?