Bug 70056 - [1.5] Please support varargs
Summary: [1.5] Please support varargs
Status: VERIFIED FIXED
Alias: None
Product: JDT
Classification: Eclipse Project
Component: Core (show other bugs)
Version: 3.0   Edit
Hardware: PC Windows XP
: P3 normal with 1 vote (vote)
Target Milestone: 3.1 M3   Edit
Assignee: Kent Johnson CLA
QA Contact:
URL:
Whiteboard:
Keywords:
Depends on:
Blocks:
 
Reported: 2004-07-14 15:21 EDT by Stefan Matthias Aust CLA
Modified: 2004-11-04 11:01 EST (History)
0 users

See Also:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Stefan Matthias Aust CLA 2004-07-14 15:21:15 EDT
First of all, it would be nice, if varargs would be supported really soon now :)
Perhaps writing bug reports where others could cc to or vote for would help you
to priorize your work...

These statements should work:

 java.lang.reflect.Method m;
 m.invoke(obj);
 m.invoke(obj, m);
 m.invoke(obj, m, m, m);

This statement should raise a warning:

 m.invoke(obj, null);

Right now, Cheetah will only accept the last statement but javac will raise a
warning: non-varargs call of varargs method with inexact argument type for last
parameter.
Comment 1 Kent Johnson CLA 2004-10-12 12:11:46 EDT
Released initial support for varargs into today's integration build.

But the warning case is not supported yet. I find it strange that javac does 
not warn when the var arg type is int, as in:

void count(int ... v) {}

count(null); // no warning

but does here:

void count(Object ... v) {}

count(null); // warning
Comment 2 Jens Elkner CLA 2004-10-12 21:51:35 EDT
well - it is the same like:

void count(int ai[]) {}
and
void count2(Object aobj[])

In count(null) the compiler seems to know, that null means a "null pointer"
to an array, since native stuff can not be null.
In count2(null) it does not known, whether you mean a "null pointer" or a
pointer to an array with one "null object" ...
Comment 3 Jens Elkner CLA 2004-10-14 21:31:38 EDT
I tried vargs with eclipse-gtk-3.1-I20041013. Most of the time it seems to work.
However, in some cases, the IDE still flags none-existing error (i.e. source
compiles without problems with Suns's javac 1.5.0).

E.g.:

public class Message {
    public static String format(ResourceBundle bundle, String key) {}
    public static String format(ResourceBundle bundle, String key, Object...
args) {}
}

public class Test {
    int type = 0;
    String[] T_NAMES = new String { "foo", "bar" };
    String error = "error";
    ...
    Message.format(i18n, "E_UNSUPPORTED_CONV", type); // error
    Message.format(i18n, "E_SAVE", T_NAMES[type], error); // error
    ...
}
Comment 4 Kent Johnson CLA 2004-10-15 12:46:47 EDT
This call will fail because it requires autoboxing (which we don't support 
yet):

    Message.format(i18n, "E_UNSUPPORTED_CONV", type); // error

An int is not an Object. Try:

    Message.format(i18n, "E_UNSUPPORTED_CONV", new Integer(type)); // error

As for the second case, it worked fine for me.
Comment 5 Jens Elkner CLA 2004-10-15 16:58:08 EDT
Oops, didn't know that. Is there a public web page, which show the status
of 1.5 support? Perhaps this would help to avoid unnecessary questions ...
Comment 6 Kent Johnson CLA 2004-11-02 12:56:45 EST
Closing this one for now since the initial support is handling the known cases.

Future problems will be captured in new PRs.
Comment 7 Frederic Fusier CLA 2004-11-04 11:01:18 EST
Verified for 3.1 M3 with build I200411040800