lame java collection erasure problem

Just ran into an example of where Java’s dumb erasure strategy just didn’t cut it.

I wrote a small class to collect up vararg junk into typed collections, something like:

public class Collector {
    public Collection collect( typename... vs ) {...}
    public Collection collect( Collection collection, typename... vs ) {...}
};

This worked fine up until the point where the typename was a typed collection, at which point the second method was invoked instead.

My work around was to rename the latter to “collectInto”

Lame…

Advertisements

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Google photo

You are commenting using your Google account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s

%d bloggers like this: