Bug 89448

Summary: Java Generics code throws a java.lang.NoClassDefFoundError
Product: [Eclipse Project] JDT Reporter: Tushar Pokle <tushar.pokle>
Component: CoreAssignee: Philipe Mulet <philippe_mulet>
Status: VERIFIED FIXED QA Contact:
Severity: normal    
Priority: P3    
Version: 3.1   
Target Milestone: 3.1 M6   
Hardware: PC   
OS: Windows XP   
Whiteboard:
Attachments:
Description Flags
Apply on HEAD none

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