Summary: | [1.5][compiler] Should insert generic cast in presence of multi-bounded types | ||
---|---|---|---|
Product: | [Eclipse Project] JDT | Reporter: | Philipe Mulet <philippe_mulet> |
Component: | Core | Assignee: | Philipe Mulet <philippe_mulet> |
Status: | RESOLVED WONTFIX | QA Contact: | |
Severity: | normal | ||
Priority: | P3 | ||
Version: | 3.1 | ||
Target Milestone: | 3.2 M2 | ||
Hardware: | PC | ||
OS: | Windows XP | ||
Whiteboard: |
Description
Philipe Mulet
2005-09-08 16:05:13 EDT
Actually, any expression yielding a type variable as its type (possibly resulting from capture as well) is to be checked before used, in case some type assumptions would need to be enforced. e.g. import java.io.Serializable; public class X<T extends Serializable & Runnable, V extends T> { void foo(T t) { Runnable r1 = t; bar(t); } void bar(Runnable r) {} public static void main(String[] args) { new X<A, A>().foo(new A()); } } class A implements Serializable, Runnable { public void run() { System.out.println("AA"); } } Affected types are: type variables with multipe bounds (directly or indirectly), captures and intersection types. Actually, maybe casts are not mandated. Bytecode verifiers seem to defer the check until runtime (similar to standard situation arising from binary compatibility problems). So even though the bytecode looks troublesome, at runtime the proper object types are available and no cast is required. Added GenericTypeTest#test821-test825 Closing |