Bug 104695

Summary: [1.5][compiler] Compiler allows instanceof with non-reifiable array type
Product: [Eclipse Project] JDT Reporter: Markus Keller <markus.kell.r>
Component: CoreAssignee: Philipe Mulet <philippe_mulet>
Status: VERIFIED FIXED QA Contact:
Severity: normal    
Priority: P3    
Version: 3.1   
Target Milestone: 3.1.1   
Hardware: PC   
OS: Windows XP   
Whiteboard:
Attachments:
Description Flags
Proposed fix none

Description Markus Keller CLA 2005-07-21 13:40:59 EDT
N20050721-0010

class Bug<E> {
    void method(Object o) {
        if (o instanceof E[]) { //incorrect: cannot test non-reifiable type
            E[] es= (E[]) o;
        }
        if (o instanceof List<E>[]) { //incorrect too
            List<E>[] es= (List<E>[]) o; 
        }
    }
}
Comment 1 Olivier Thomann CLA 2005-08-19 10:23:49 EDT
Created attachment 26297 [details]
Proposed fix

This patch is passing all existing generic type tests.
Comment 2 Philipe Mulet CLA 2005-09-05 10:32:20 EDT
Fix is rather to improve TypeBinding#isReifiable() and to also use it in
instanceof expression.
Comment 3 Philipe Mulet CLA 2005-09-05 10:44:37 EDT
Also, the second assignment (to List<E>[] es) should issue an unchecked cast
warning.

Added GenericTypeTest#test814
Comment 4 Philipe Mulet CLA 2005-09-05 12:27:50 EDT
Addressed unchecked warning as well.
Also added GenericTypeTest#test815-817
Comment 5 Philipe Mulet CLA 2005-09-05 12:28:59 EDT
Fixed
Comment 6 David Audel CLA 2005-09-21 10:02:48 EDT
Verified in I20050920-0010 for 3.2M2
Comment 7 David Audel CLA 2005-09-26 11:52:25 EDT
Verified using M20050923-1430 for 3.1.1