[Java Spec Report] bridge methods for non-overridden methods
"Timothy Hanson" <[email protected]> Tue, 15 Jun 2004 13:53:50 -0700
| Newsgroups | gmane.comp.java.spec-report |
|---|---|
| Message-ID | <[email protected]> |
What is the rationale for providing a bridge method for a method that is not overridden?
For example given two classes C & D:
----------------------------
class D<T> {
T foo(T t) {...}
}
class C extends D<String> {}
-------------------------------
Currently, javac adds a bridge method to C that looks like:
---------------------------------
Object foo(Object o) {
return super.foo((String)o);
}
---------------------------------
It casts the parameter types as needed, but not the return type. Why is this needed at all? It seems that the compiler provides all the type checking that is needed, why add the extra runtime type checking via the cast?
This only seems to catch the case of assigning a C instance to a raw D instance. This is generally an unsafe thing to do, but no where else does it provide runtime type checking (at least on the parameters).
Thanks,
Tim
------------------------ Yahoo! Groups Sponsor --------------------~-->
Yahoo! Domains - Claim yours for only $14.70
http://us.click.yahoo.com/Z1wmxD/DREIAA/yQLSAA/5cFolB/TM
--------------------------------------------------------------------~->
To unsubscribe from this mailing list, send an email to:
[email protected]
Yahoo! Groups Links
<*> To visit your group on the web, go to:
http://groups.yahoo.com/group/java-spec-report/
<*> To unsubscribe from this group, send an email to:
[email protected]
<*> Your use of Yahoo! Groups is subject to:
http://docs.yahoo.com/info/terms/