public inbox for java-prs@sourceware.org
help / color / mirror / Atom feed
* [Bug java/32862]  New: bug in EnumMap implementation
@ 2007-07-23  8:02 debian-gcc at lists dot debian dot org
  2007-07-23 16:11 ` [Bug java/32862] " tromey at gcc dot gnu dot org
                   ` (2 more replies)
  0 siblings, 3 replies; 4+ messages in thread
From: debian-gcc at lists dot debian dot org @ 2007-07-23  8:02 UTC (permalink / raw)
  To: java-prs

[forwarded from http://bugs.debian.org/423160]

seen with trunk 20070720

The gij implementation of EnumMap class contains a flaw: it returns
strange java.lang.Object classes for missing elements. The error can be
demonstrated with this program:

=== Cut ===
import java.util.*;

public class Test {
        enum TestEnum {
                FIRST, SECOND
        }

        public static void main(String[] args) {
                Map<TestEnum, String> map = new EnumMap<TestEnum,
String>(TestEnum.class);
                map.put(TestEnum.FIRST, "first");
                System.out.println(map);
                System.out.println(map.containsKey(TestEnum.SECOND));
                System.out.println(map.get(TestEnum.SECOND));
        }
}

$ gcj -C Test.java

tmp $ gij Test
{FIRST=first}
false
Exception in thread "main" java.lang.ClassCastException:
java.lang.Object cannot be cast to java.lang.String
   at Test.main(Test.java:13)

tmp $ java Test
{FIRST=first}
false
null

=== Cut ===

As you can see, Sun Java (the last call) returns correct null, while
GNU libgcj returns bogus java.lang.Object.


-- 
           Summary: bug in EnumMap implementation
           Product: gcc
           Version: 4.3.0
            Status: UNCONFIRMED
          Severity: normal
          Priority: P3
         Component: java
        AssignedTo: unassigned at gcc dot gnu dot org
        ReportedBy: debian-gcc at lists dot debian dot org


http://gcc.gnu.org/bugzilla/show_bug.cgi?id=32862


^ permalink raw reply	[flat|nested] 4+ messages in thread

end of thread, other threads:[~2007-08-07 17:38 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2007-07-23  8:02 [Bug java/32862] New: bug in EnumMap implementation debian-gcc at lists dot debian dot org
2007-07-23 16:11 ` [Bug java/32862] " tromey at gcc dot gnu dot org
2007-07-24 15:27 ` cvs-commit at developer dot classpath dot org
2007-08-07 17:38 ` tromey at gcc dot gnu dot org

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).