The Artima Developer Community
Sponsored Link

Weblogs Forum
Nasty Little JDK 1.5 Compiler Bug

1 reply on 1 page. Most recent reply: Nov 6, 2004 9:14 AM by Eamonn McManus

Welcome Guest
  Sign In

Go back to the topic listing  Back to Topic List Click to reply to this topic  Reply to this Topic Click to search messages in this forum  Search Forum Click for a threaded view of the topic  Threaded View   
Previous Topic   Next Topic
Flat View: This topic has 1 reply on 1 page
Heinz Kabutz

Posts: 46
Nickname: drbean
Registered: May, 2003

Nasty Little JDK 1.5 Compiler Bug (View in Weblogs)
Posted: Oct 12, 2004 5:10 PM
Reply to this message Reply
Summary
There is a serious error in the JDK 1.5 compiler, pointed out to me by one of my readers, Amotz Anner. Using final local variables in conjunction with ternary if-else where one side of the values is null, leads to incorrect results.
Advertisement
There is a serious error in the JDK 1.5 compiler, pointed out to me by one of my readers (of The Java Specialists' Newsletter), Amotz Anner.

Amotz has submitted a bug report already to Sun, and as soon as we have a number from Sun (may take up to three weeks) we will post that in a follow-up.

Here is the problem:

  final String name = false ? "Heinz" : null;
  System.out.println(name);

When compiled using the JDK 1.5 compiler, it will print out "Heinz". It does not matter whether you say -source 1.[234] or whether you run it using any of the JDK 1.[2345].x JVMs from Sun.

This happens only when the local variable is set to "final" and one of the values of the ternary if-else is literal null.

PLEASE let's not make this into a mud-slinging match against Sun Microsystems, ok? They are overloaded with bug reports as it is. The reason that I post this is to make you aware to NOT use the final local variables in combination with ternary if-else.


Eamonn McManus

Posts: 20
Nickname: dichotomy
Registered: Apr, 2003

Re: Nasty Little JDK 1.5 Compiler Bug Posted: Nov 6, 2004 9:14 AM
Reply to this message Reply
http://bugs.sun.com/bugdatabase/view_bug.do?bug_id=5105890
(Dated earlier than your message, but perhaps it wasn't showing up in the public bug database at the time?)

Flat View: This topic has 1 reply on 1 page
Topic: Comparative Studies – the rods we hit each other with? Previous Topic   Next Topic Topic: Why I Decided to Design a Programming Language


Sponsored Links



Google
  Web Artima.com   

Copyright © 1996-2014 Artima, Inc. All Rights Reserved. - Privacy Policy - Terms of Use - Advertise with Us