Thursday, April 20, 2006

// import java.util.Iterator;

Generics, here I come! Strange, for how long I've been a (silent) opponent of Java 5 new features. This came to pass, as I'm converting a huge body of code to use Generics. Find that experience strangely satisfying. Oh, yeah, I remember now why I've been in opposition: I was afraid that tool vendors will not keep up with this syntax change, and/or that our favourite IDEs will be slower due to extra burden on parser... Yep, this is a price to pay. Need to submit a bit of code to JetBrains: IntelliJ will not parse properly a small bit of code with parameterized Collections (maybe this bug has already been filed, though; need to check first).

Update: found a caveat in how immutable instances of empty parameterized collections are to be handled when they are created. The usual Collections.EMPTY_SET will generate a warning. While an example in JavaDocs is working fine when there is assignment: Set<String> s = Collections.emptySet();, it does not in a context like this: callSomeMethod(Collections.emptySet());, if method signature is callSomeMethod(Set<String> input);. Unfortunately, the following contraption is needed then: callSomeMethod((Set<String>) Collections.emptySet()). Now compiler is happy, it has enough information to derive type of the collection.

Update: it was not a bug really, just some cache staleness occured. Restarting IntelliJ has resolved the issue. But while IDEA was restarting, I took a look at JetBrains' bug database. The list of bugs is quite long... Which got me thinking, how sad that each software company, no matter how bright, ends up drowned in bugs allowing competition a chance to hold some proving ground. No, JetBrains is nowhere near "drowning" in bugs yet, but I think it's inevitable, someday they will.

0 Comments:

Post a Comment

<< Home