bolson: (Default)
2007-08-17 08:00 am
Entry tags:

Java ate my brain

Java's generics are hard. And I think they're defined wrong.
HashMap<String,String>[] arrayOfHashMap; // Ok, I can declare this
arrayOfHashMap[0] = new HashMap<String,String>(); // this compiles just fine
HashMap<String,String> instanceOfHashMap = arrayOfHashMap[0]; // this works fine in code too
arrayOfHashMap = new HashMap<String,String>[]; // but this always is a compiler error!
arrayOfHashMap = new HashMap[]; // and this is a warning! I can't win!

This is clearly a bug in the design of the language.

Also, ObjectInputStream.readObject(), which returns Object, appears to have no way of assigning to a templated type without warning without adding the annotation @SuppressWarnings({"unchecked"}) to the function. Hmpf. Shoulda stuck with Java 1.4
bolson: (Default)
2007-02-03 08:27 pm
Entry tags:

Things I Do For Fun

Developing a Java Servlet webapp with DB back-end in parallel for portability between PostgreSQL, MySQL and Derby (and I'd be using Oracle too if their free demo worked on Mac). I don't know what it is about these exercises I find so engaging, but I do it anyway.