Bug 79144 - [1.5][compiler] generic type checking not performed for method return array types
Summary: [1.5][compiler] generic type checking not performed for method return array t...
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 M5   Edit
Assignee: Philipe Mulet CLA
QA Contact:
URL:
Whiteboard:
Keywords:
Depends on:
Blocks:
 
Reported: 2004-11-21 08:20 EST by mike andrews CLA
Modified: 2005-02-15 06:01 EST (History)
1 user (show)

See Also:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description mike andrews CLA 2004-11-21 08:20:53 EST
the following code MUST generate a compiler error or warning, but doesn't:

public Set<String>[] test() {
   Set[] sets = new Set[10];
   return sets;
}
Comment 1 Dave Latham CLA 2004-11-29 12:55:06 EST
I think the same problem applies for all array assignments, for example, this
code produces no warnings, but gives a run time class cast exception:

public class GenericArrayTrouble {
    public static void main(String[] args) {
        List<Integer>[] nums = new List[] {Collections.singletonList("Uh oh")};
        System.out.println(nums[0].get(0).intValue());
    } 
}
Comment 2 Philipe Mulet CLA 2005-01-15 09:24:29 EST
We did not properly check array types.
Added support, we now report: 

Type safety: The expression of type Set[] needs unchecked conversion to conform
to Set<String>[].

Added GenericTypeTest#test462.

Comment 3 Philipe Mulet CLA 2005-01-15 09:26:06 EST
Second scenario is the same issue indeed.
Added GenericTypeTest#test463.

Fixed
Comment 4 Philipe Mulet CLA 2005-01-15 09:27:30 EST
Tests are actually: test463 & test464.
Comment 5 Jerome Lanneluc CLA 2005-02-15 06:01:14 EST
Verified in I20050214