Summary: | [1.5] VerifyError when using generics and arrays | ||
---|---|---|---|
Product: | [Eclipse Project] JDT | Reporter: | Michael Forster <email> |
Component: | Core | Assignee: | Philipe Mulet <philippe_mulet> |
Status: | RESOLVED FIXED | QA Contact: | |
Severity: | normal | ||
Priority: | P3 | ||
Version: | 3.0 | ||
Target Milestone: | 3.1 M1 | ||
Hardware: | PC | ||
OS: | Windows XP | ||
Whiteboard: |
Description
Michael Forster
2004-04-30 09:11:46 EDT
Here is the bytecodes we produce using latest: void m2(A x); 0 aload_0 1 aload_1 2 new #2 X 5 dup 6 invokespecial #18 <Method X.<init>()V> 9 invokeinterface [nargs : 2] #24 <Interface method A.m1(Ljava/lang/Object;)[Ljava/lang/Object;> 14 invokevirtual #28 <Method X.m3([LX;)V> 17 return You can see that the invokeinterface method returns an array of java.lang.Object and the invokevirtual expects an array of X on the stack. javac produces: void m2(A arg); 0 aload_0 1 aload_1 2 new #2 X 5 dup 6 invokespecial #3 <Method X.<init>()V> 9 invokeinterface [nargs : 2] #4 <Interface method A.m1(Ljava/lang/Object;)[Ljava/lang/Object;> 14 checkcast #5 [LX; 17 invokevirtual #6 <Method X.m3([LX;)V> 20 return The intermediate checkcast converts the array of java.lang.Object into an array of X and then the invokevirtual call is fine. Our check for adding generic casts did only consider case where original return type was a variable. Array of variable (T[]) wasn't handled. Added regression test: GenericTypeTest#test175. Also upgraded similarily all generic cast inserted: field, name, qualified name, ... Fixed |