Sorry that I don't have any answers, but I have some comments.
Johan Compagner wrote:
No the HomePage cant be raw type anymore more
So it must be typed.. Why that is..?
<? extends Page<?>>
then the last <?> seem to say that for that Class it must be filled in with
a real Type
So it must be HomePage extends Page<String>
This HomePage is not a 'raw type' it is a non-generic type extending the
generic type Page with the type parameter String.
The term 'raw type' only applies when the type is generic.
http://www.angelikalanger.com/GenericsFAQ/FAQSections/ParameterizedTypes.html#What%20is%20the%20raw%20type?
class HomePage extends Page<?> is syntactically wrong a super type may not
specify any wildcard whatsoever.
http://www.angelikalanger.com/GenericsFAQ/FAQSections/ParameterizedTypes.html#Can%20I%20derive%20from%20a%20wildcard%20instantiation%20of%20a%20parameterized%20type?
and you can't do:
foo.bar(Component<String>.class)
because that doesnt mean anything
http://www.angelikalanger.com/GenericsFAQ/FAQSections/ParameterizedTypes.html#Why%20is%20there%20no%20class%20literal%20for%20the%20concrete%20instantiation%20of%20a%20parameterized%20type?
+
http://www.angelikalanger.com/GenericsFAQ/FAQSections/ParameterizedTypes.html#Why%20is%20there%20no%20class%20literal%20for%20wildcard%20instantiations%20of%20a%20parameterized%20type?
So
HomePage<T> extends Page<T>
then homePage class is still raw type
It is not raw, s.o.
and HomePage extends Page<String>
then the class it self is generified
Depends on how you define generified, but it is not generic, thats for sure.
and somehow <?> in a class definition does apply only to a Generified class
not a raw type class.
I think it is all in that area that it is a Class..
johan
my 50 cent,
Martin
On Fri, Jun 6, 2008 at 1:31 PM, Martin Funk <[EMAIL PROTECTED]>
wrote:
2008/6/6 Sebastiaan van Erk <[EMAIL PROTECTED]>:
Martin Funk wrote:
Jeremy Thomerson wrote:
I haven't read the whole thread, but you should be fine as long as your
returned page class uses generics...
Here's what I use in one app, no warnings, no casts:
@Override
public Class<? extends Page<?>> getHomePage() {
return Home.class;
}
public class Home extends WebPage<Void> {
}
Hi Jeremy,
I'm still picking on the words. What do you mean by 'uses generics'?
I think the point is class Home has to be a non generic type subclassing
the generic class WebPage with a concrete type parameter.
Why should the HomePage class be "non generic", and why should you use a
"concrete type parameter"?
I'm not good in explaining why HomePage has to be non generic yet, but
there
seems to be experimental evidence, see:
http://cwiki.apache.org/confluence/display/WICKET/generics#generics-Variationsof%27publicvoidfoo%28Class%3C%3FextendsComponent%3C%3F%3E%3Eclazz%29%27
But the given class Home definitely is not generic!
Class<? extends Page<?>> means "class of (anything that extends (page of
anything))".
I'm not so sure.
That means your home page can have as many type parameters as you wish
(or
none at all), as long as it extends Page<?>. This also means you you can
define a generic HomePage like this:
class HomePage<T> extends WebPage<T> { ... }
see
foo.bar(Component.class);
foo.bar(IntegerComponent.class);
foo.bar(GenericComponent.class);
foo.bar(GenericIntegerComponent.class);
in the given example page above.
if you feel like it, and don't have to use a concrete type.
But if you chose to make class HomePage non-generic you have to decide on a
concrete type parameter for WebPage.
And I still really don't understand why java has a problem with this:
class HomePage extends WebPage { ... }
since here it *is still* the case that HomePage is a subtype of
WebPage<?>
(you prove this by the assignment:
WebPage<?> wp = new HomePage();
which works fine). So you would expect to be able to return this in the
getHomePage() method. But you can't because the compiler chokes on it. I
have not seen a convincing reason why this shouldn't work yet, though.
Me neither, but we are working on it.
Martin
Regards,
Sebastiaan
mf
---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]