Bug 76441 - [1.5] varargs in the Java model
Summary: [1.5] varargs in the Java model
Status: RESOLVED WONTFIX
Alias: None
Product: JDT
Classification: Eclipse Project
Component: Core (show other bugs)
Version: 3.0   Edit
Hardware: PC Windows XP
: P3 normal (vote)
Target Milestone: 3.1 M3   Edit
Assignee: JDT-Core-Inbox CLA
QA Contact:
URL:
Whiteboard:
Keywords:
Depends on:
Blocks:
 
Reported: 2004-10-17 08:21 EDT by Martin Aeschlimann CLA
Modified: 2004-10-27 06:36 EDT (History)
1 user (show)

See Also:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Martin Aeschlimann CLA 2004-10-17 08:21:06 EDT
20041017

I just updated the JDT UI label provider for var-args.

In the Java Models 'IMethod', Var args are signalled in a bit in the method's
flags (Flags.isVarargs(method.getFlags()). If this bit is set, this means that
parameter types (method.getParameterTypes()) have to be rendered differently.
foo(Object x, Object... y) returns parameter types 'Object,Object[]'. The
renderer has then to substract one dimension from the last parameters type and
render ellipses instead.

I understand why this like that and I shows you a lot about how the new
construct is internally modelled. But for the Java model being is a source model
- Wouldn't it be better to have the varargs information in the signature of the
last parameter type? 
- Flags.toString() now says you have to pass 'flags & ~AccVarargs'. The current
implementation doesn't add 'varargs' yet, but if it would, clients would all
have to update the code that uses the result directly in code.

I think having the varargs information in the last parameter types signature
would make it much easier for Java model clients. As Signature.asString(typeSig)
does return the correct type string, they would not even have to change something.
Also note that the AST also has the information in the parameter node.
Comment 1 Philipe Mulet CLA 2004-10-18 04:53:31 EDT
We are actually following the language spec which dictates this behavior. The
varargs modifier is carried by the method itself.
Comment 2 Martin Aeschlimann CLA 2004-10-18 05:28:31 EDT
Dirk, your opinion?
I like the solution chosen for the DOM AST. When you ask a IMethod for its 
parameter types, it should return what is found in the source and not how the 
compiler sees the thing.
Comment 3 Philipe Mulet CLA 2004-10-18 09:07:47 EDT
Then how would you represent the signature of a vararg parameter ? 

Beside, on signature front, you have to be prepared to the fact that AccVarargs
is colliding with AccTransient (for fields), and do the adequate change if you
don't want to see transient methods !?
This is no different from what is occurring in the binaries, and is sticking
close to the language spec spirit. The DOM AST doesn't need to harmonize with
binaries.