March 12th, 2008

Captain Obvious

iPhone firmware 2.0 jailbroken - before it's even available for download.

This is just getting silly, don't you think? The iPhone Dev Team has once again proven their totally gnarly talents by freeing up the latest firmware before it's even the latest firmware. Dev chat room chatter claims that the 2.0 is now fully unlocked as well.

Z0MG zero day iPhone firmwarezZz d00dz!!! ;]
  • Current Music
    Elliot Murphy - People Don't Learn
  • Tags
Trajedy... for YOUUUUUUUUUUUU!!!!

Java Generics and Downcasting - FAIL.

Suppose you have an ArrayList of MimeMessages:

ArrayList<MimeMessage> messages = new ArrayList<MimeMessage>(20);

You add some messages to it...


...and then the method you're coding up has to return a list of messages. This has to be a MimeMessage[] array, and you can't change that due to hysterical porpoises. So how do you do this?

Well, hey, this should be easy, right? ArrayList has a toArray() method. So just...

return messages.toArray();

...and Bob's your uncle. Right?


HAHAHAHAHAHAHA, YOU STUPID, DELUDED FOOL! toArray() returns an array of Object, not an array of what you created the ArrayList as! I mean, what were you thinking - expecting a collection of type Foo to convert into an array of Foos? That's just crazy talk!

No, Java doesn't care that your ArrayList was template instantiated on MimeMessage, thus ensuring beyond any possible doubt - at compile time - that every item in message Is-A MimeMessage! And no, Java doesn't care that it has Run-Time Type Identification and thus also knows damn well at run-time exactly what type of objects are in your ArrayList! But no, in spite of all that, .toArray() still will not return a list of MimeMessages!

Now... just GUESS which of the following syntaxes you must use to make this stupid little bullshit operation actually work the way it should:

Collapse )
  • Current Music
    Deathklok - Hatredy