Bug 83536

Summary: "Incompatible argument to function" at vararg function
Product: [Eclipse Project] JDT Reporter: Ulrik Restorp <ulrik.restorp>
Component: CoreAssignee: Olivier Thomann <Olivier_Thomann>
Status: VERIFIED FIXED QA Contact:
Severity: major    
Priority: P3 CC: martinae
Version: 3.1   
Target Milestone: 3.1 M5   
Hardware: PC   
OS: Windows XP   
Whiteboard:
Attachments:
Description Flags
Apply on HEAD none

Description Ulrik Restorp CLA 2005-01-24 10:02:47 EST
Platform: Eclipse 3.1 M4
Code example:

package t1;
public class Test {
    public static void main (String[] args) {
        new Test ().test (new byte[5]);
    }
    private void test (Object... params) {
    }
}

The code generates the following error at runtime when started from Eclipse (and
only when started from Eclipse): 
java.lang.VerifyError: (class: t1/Test, method: main signature:
([Ljava/lang/String;)V) Incompatible argument to function

The error is eliminated if the call to method test is expressed as:
new Test ().test (new Object[] {new byte[5]});

Could it be an autoboxing issue?
Comment 1 Olivier Thomann CLA 2005-01-24 10:18:42 EST
Reproduced.
I will investigate.
Comment 2 Olivier Thomann CLA 2005-01-24 10:26:56 EST
We don't wrap the array of byte into an array of Object.

  public static void main(String[] args);
     0  new X [2]
     3  dup
     4  invokespecial X.<init>()V [16]
     7  iconst_5
     8  newarray byte [8]
    10  invokespecial X.test([Ljava/lang/Object;)V [20]
    13  return


iconst5 and newarray byte should be replace with something like:
   iconst_1
   anewarray java/lang/Object
   dup
   iconst_0
   iconst_5
   newarray byte
   aastore
Comment 3 Olivier Thomann CLA 2005-01-24 10:35:46 EST
Created attachment 17392 [details]
Apply on HEAD
Comment 4 Olivier Thomann CLA 2005-01-24 10:36:52 EST
The bug was coming from the fact that we didn't check the compatibility of the
last argument in case it was an array. We simply check the dimensions.
Philippe, could you please review the patch?
Thanks.
Comment 5 Philipe Mulet CLA 2005-01-24 13:03:13 EST
Looks good to me
Comment 6 Olivier Thomann CLA 2005-01-24 16:13:36 EST
Fixed and released in HEAD.
Regression test added in VarargsTest.test023.
Comment 7 Philipe Mulet CLA 2005-01-24 18:25:27 EST
*** Bug 83183 has been marked as a duplicate of this bug. ***
Comment 8 David Audel CLA 2005-02-16 12:30:51 EST
Verified in I20050215-2300