> I'm gonna try to talk out the code, that is convert the statements into
> English.
[quoted text clipped - 4 lines]
> Baz is a class paramterized on one thing.
> Foo is not paramterized.
Good up to here.
> There are two methods left and that is the hairy stuff.
> Let's look at the one invoked first:
[quoted text clipped - 5 lines]
> Foo and Baz is paramterize on ? extends T. Does that mean that we need
> a subclass of a subclass?
No, you're missing an important point here. doFoo's argument is
characterized a particular subclass of Foo, and on a Baz which is itself
characterized by a subclass of *the same* subclass of Foo. The bound on
the method's type parameter doesn't really matter here, it turns out;
you could remove it altogether without fundamentally changing what I
intend to express.
> Could we write doFoo like so:
>
> public <T extends Foo> void doFoo(Bar<T, Baz<T>> bar) {
That means something different, but I could work with it if the compiler
would accept it. As you observed (elided), it does not. I have now
figured out why (see my most recent previous post), so now I just have
to determine how to handle the situation.
For what it's worth, this whole issue arose when trying to mangle
perfectly good generic code (that Eclipse handles fine) to work around
bugs in Sun's javac. Why is it that Eclipse can handle Java generics
better than Sun itself can?
[...]
> The generics stuff clearly opens up possibilites that are hard to think
> about. It's like C++ stuff. Fortunately in practice code (my code
> anyway) never gets to this point. Generics in practice seem to be
> conveniences for reducing typing casts.
I find it most useful to think about generics in terms of describing
types. That seems trivial to say, but you are bound to run into trouble
when you lose sight of it. Reducing casts, though touted as a major
benefit of generics, is just a side effect of the deep change in the
type system that generics bring. Parameterized types are a whole
conceptual level higher than unparameterized ones, and thus they do
present considerably greater challenges.

Signature
John Bollinger
jobollin@indiana.edu