Bug 83536 - "Incompatible argument to function" at vararg function
Summary: "Incompatible argument to function" at vararg function
Status: VERIFIED FIXED
Alias: None
Product: JDT
Classification: Eclipse Project
Component: Core (show other bugs)
Version: 3.1   Edit
Hardware: PC Windows XP
: P3 major (vote)
Target Milestone: 3.1 M5   Edit
Assignee: Olivier Thomann CLA
QA Contact:
URL:
Whiteboard:
Keywords:
: 83183 (view as bug list)
Depends on:
Blocks:
 
Reported: 2005-01-24 10:02 EST by Ulrik Restorp CLA
Modified: 2005-02-16 12:30 EST (History)
1 user (show)

See Also:


Attachments
Apply on HEAD (1.11 KB, patch)
2005-01-24 10:35 EST, Olivier Thomann CLA
no flags Details | Diff

Note You need to log in before you can comment on or make changes to this bug.
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