Bug 89448 - Java Generics code throws a java.lang.NoClassDefFoundError
Summary: Java Generics code throws a java.lang.NoClassDefFoundError
Status: VERIFIED FIXED
Alias: None
Product: JDT
Classification: Eclipse Project
Component: Core (show other bugs)
Version: 3.1   Edit
Hardware: PC Windows XP
: P3 normal (vote)
Target Milestone: 3.1 M6   Edit
Assignee: Philipe Mulet CLA
QA Contact:
URL:
Whiteboard:
Keywords:
Depends on:
Blocks:
 
Reported: 2005-03-29 22:00 EST by Tushar Pokle CLA
Modified: 2005-03-31 20:39 EST (History)
0 users

See Also:


Attachments
Apply on HEAD (1.41 KB, patch)
2005-03-29 22:33 EST, Olivier Thomann CLA
no flags Details | Diff

Note You need to log in before you can comment on or make changes to this bug.
Description Tushar Pokle CLA 2005-03-29 22:00:48 EST
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);
        }
    }

}
Comment 1 Tushar Pokle CLA 2005-03-29 22:05:15 EST
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.
Comment 2 Olivier Thomann CLA 2005-03-29 22:31:01 EST
Reproduced with I20050329-2000.
Comment 3 Olivier Thomann CLA 2005-03-29 22:33:08 EST
Created attachment 19303 [details]
Apply on HEAD

Proposed patch.
Comment 4 Philipe Mulet CLA 2005-03-31 08:17:38 EST
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.
Comment 5 Philipe Mulet CLA 2005-03-31 08:19:09 EST
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.
Comment 6 Philipe Mulet CLA 2005-03-31 08:30:24 EST
Fixed
Comment 7 Philipe Mulet CLA 2005-03-31 16:15:21 EST
Will target M6.
Comment 8 Olivier Thomann CLA 2005-03-31 20:39:39 EST
Verified in I20050331-2000