Return type of Object.getClass()
Ulf Zibis
Ulf.Zibis at gmx.de
Fri Jul 1 09:09:49 UTC 2011
Am 30.06.2011 23:16, schrieb Zhong Yu:
> Why does it return Class<? extends |X|> instead of Class<? extends X>? Quote:
>
> The actual result type is Class<? extends |X|> where |X| is the
> erasure of the static type of the expression on which getClass is
> called.
>
> This means the following code does not compile
> T obj = ...;
> Class<T> clazz = obj.getClass();
>
> What's the reason for erasure here? Thanks.
>
> Zhong Yu
Maybe this bug is additionally related:
Bug ID: 6850338 State generification of Class.forName() more precisely
<http://bugs.sun.com/bugdatabase/view_bug.do?bug_id=6850338>
-Ulf
More information about the core-libs-dev
mailing list