Java 5

Posted on August 5, 2005


I like Java for many reasons, but not Java 5.
Autoboxing is a new feature and it just introduced a bug in my code. I wrote a small test case Assert.assertEquals(dao.getAsList(), 100) and it compiled! How the hell can you compare object and primitive? With java 5 you can :-(. Method assertEquals accepts two objects as a parameter Assert.assertEquals(Object a, Object b). Java in it’s infinite wisdom now automagically converts primitive datatype like int to object like Integer. This sucks because is impossible to detect this kind of mistakes in compile time only at runtime (and my build runs more th a minute on my laptop).

I think too many people asked Sun to copy stupid things from C# and now we have to eat same shit Microsoft programmers eat.

Annotations for example. For my tests I used testng ,with testng you can either prefix your test method with @Test annotation and use it only with Java 5 or put @Test to JavaDoc comment and use it with any Java version. Why add additional complexity?

Generics.. Fuck. Such a nice concept. Well done in C++. MyClass<int> x. Wonderful! But I can’t do the same thing with Java 5 because when you say type T Java means Object. So when I need to implement method that for example sorts primitives I still have to write one method per type (boolean, byte, char, double, float, int, long, short). That’s exactly what generics is supposed to eliminate. Or if you want to accept only List as a parameter you can write T<extends List> but you can simply accept interface as a parameter and scrap generics nightmare.

public abstract class AbsComputation {
  public abstract <A, DataT extends AbsData><A> <A> DataT compute(DataT data);
}

Can you understant this? I can’t, so why should I bother with clumsy syntax and no obious benefit?
Sun, please deprecate this while you still can!

Filed Under Uncategorized |

2 Comments so far
  1. Skrud August 8, 2005 12:43 am

    The duality between Java’s primitive types and Object wrappers and they way it’s handled is something that never ceases to piss me off.

  2. Iouri Goussev August 8, 2005 1:55 pm

    Yeah, pearls like java.lang.Void used for object representation of null make my day ;-)
    On the other hand Ruby exception handling are done like this just to be different:

    begin
    b()
    rescue => detail
    print detail.backtrace.join(”\n”)
    end

    IMHO try/catch/throw is much better.

Leave a Comment

If you would like to make a comment, please fill out the form below.

Name

Email

Website

Comments

For spam detection purposes, please copy the number 5125 to the field below:

© Copyright 0xDEADBEEFCAFE • Powered by Wordpress • Design by Sebastin.

free web hit counter