?

Log in

No account? Create an account
March 12th, 2008 - Adventures in Engineering — LiveJournal
The wanderings of a modern ronin.

Ben Cantrick
  Date: 2008-03-12 11:06
  Subject:   iPhone firmware 2.0 jailbroken - before it's even available for download.
Public
  Music:Elliot Murphy - People Don't Learn
  Tags:  digg

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.

http://www.engadget.com/2008/03/11/iphone-dev-team-jailbreaks-firmware-2-0-before-its-out/

Z0MG zero day iPhone firmwarezZz d00dz!!! ;]
3 Comments | Post A Comment | | Link



Ben Cantrick
  Date: 2008-03-12 15:34
  Subject:   Java Generics and Downcasting - FAIL.
Public
  Music:Deathklok - Hatredy

Suppose you have an ArrayList of MimeMessages:

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

You add some messages to it...

messages.add(thisMsg);
messages.add(thatMsg);


...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?

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:

Do you give up yet?Collapse )
8 Comments | Post A Comment | | Link






browse
May 2015