Community
Participate
Working Groups
The following code throws a java.lang.NoClassDefFoundError when compiled and run within eclipse 3.1M5a, but not when compiled and run with Sun's JDK 1.5.0_02. import java.util.ArrayList; import java.util.List; public class Bug { public static void main(String[] args) { ArrayList<ArrayList<Long>> n = new ArrayList<ArrayList<Long>>(); ArrayList<Long> arr = new ArrayList<Long>(); arr.add(new Long(5)); n.add(arr); List<? extends List<Long>> m = n; // Whoa! for(Long l : m.get(0)) { System.out.println(l); } } }
Just to clarify - when I ran the code within eclipse, it was run with JDK 1.5.0_02 as well. The only difference between the two runs was the compiler.
Reproduced with I20050329-2000.
Created attachment 19303 [details] Apply on HEAD Proposed patch.
Fix would be slightly different. Either we use the receiver type erasure to clear the wildcard issue and solve this very problem, or we make the wildcard be able to act as a declaring class; which would better scale to other scenario. Added GenericTypeTest#test568.
Actually, first version is better. The second would require to have constant pool name computed for wildcard (from erasure()), and also change the modifiers to reflect AccInterface, which in turn changes type compatibility rules. So opting for first approach.
Fixed
Will target M6.
Verified in I20050331-2000