[Date Prev][Date Next] [Thread Prev][Thread Next] [Date Index] [Thread Index]

Bug#423160: gij-4.1: bug in EnumMap implementation



Package: gij-4.1
Version: 4.1.2-6
Severity: normal

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));
	}
}
=== Cut ===

tmp $ gcj-4.1 -C Test.java

tmp $ gij-4.1 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. gij-4.2 from experimental
gives the same error.

-- 
With best wishes
Dmitry Baryshkov


-- System Information:
Debian Release: lenny/sid
  APT prefers unstable
  APT policy: (500, 'unstable'), (150, 'experimental')
Architecture: i386 (i686)

Kernel: Linux 2.6.20-1-686 (SMP w/1 CPU core)
Locale: LANG=ru_RU.UTF-8, LC_CTYPE=ru_RU.UTF-8 (charmap=UTF-8)
Shell: /bin/sh linked to /bin/bash

Versions of packages gij-4.1 depends on:
ii  gcj-4.1-base            4.1.2-6          The GNU Compiler Collection (gcj b
ii  libc6                   2.5-7            GNU C Library: Shared libraries
ii  libgcc1                 1:4.2-20070405-1 GCC support library
ii  libgcj7-1               4.1.2-6          Java runtime library for use with 
ii  libmagic1               4.20-5           File type determination library us
ii  zlib1g                  1:1.2.3-13       compression library - runtime

Versions of packages gij-4.1 recommends:
ii  libgcj7-1-awt                 4.1.2-6    AWT peer runtime libraries for use

-- no debconf information



Reply to: