You are viewing a plain text version of this content. The canonical link for it is here.
Posted to jaxme-dev@ws.apache.org by Frederic Ahring <FA...@de.ibm.com> on 2005/07/08 16:04:49 UTC
Source Reflection: handling of multidimensional arrays
Hello
I'm new to this list and rather new to JAXME, too, so please point me to
an appropriate manual if I'm missing something. I did a quick look at the
archive, but found nothing about this.
What I want to do is Java source reflection, with JaxMeJs, for proxy
generation.
I noticed that the parser can't handle multidimensional arrays as input
parameter for methods. Possibly also elsewhere, but I did only look at
this specific subject.
public void testArray2Nested(de.ahring.generated.Test_InNested[][] foo2)
throws RemoteException;
when I parse the source (js.parse), get the list of methods
(js.getMethods), get the parameters of this method (method.getParams) and
look at the returned type (param.getType) the type is
de.ahring.generated.Text_InNested[] - so only one dimension is read.
I did a bit of debugging and found that in JavaParser.java,
parseIdentifier(AST, StringBuffer) the JavaToken 'DOT' is used with a
loop, getting all childelements, whereas the JavaToken 'ARRAY_DECLARATOR'
only appends '[]' one time, then quits.
case JavaTokenTypes.ARRAY_DECLARATOR:
sb.append("[]");
break;
The AST - without having looked into the complete source I assume this is
the preparsed structure the ANTLR generates - does have the second '[', in
the down-AST. So I changed it to:
case JavaTokenTypes.ARRAY_DECLARATOR:
sb.append("[]");
// 08.07.2005 FAHRING Hack for multi dimension arrays
for (AST child = pAST.getFirstChild(); child != null;
child = child.getNextSibling()) {
parseIdentifier(child, sb);
}
// END HACK
break;
Now it get's parsed correctly: type is JavaQNameImpl@ArrayImpl, holding
itself an JavaQNameImpl@ArrayImpl and only then the
JavaQNameImpl@StandardImpl
I have not yet checked what sideeffects this might have nor if it would be
necessary to make other changes as well to fully support it.
I would like to hear your opinion of this. was it a missing feature (bug)
or left out on purpose? Would my hack fix it or break things in other
places? Feel free to comment.
If it's a good idea, commit it to the CVS. Frankly, I've no idea how to do
this since I've never done it before :)
:Frederic:
---------------------------------------------------------------------
To unsubscribe, e-mail: jaxme-dev-unsubscribe@ws.apache.org
For additional commands, e-mail: jaxme-dev-help@ws.apache.org
Re: Source Reflection: handling of multidimensional arrays
Posted by Jochen Wiedmann <jo...@gmail.com>.
Hi, Frederic,
rein neugierdehalber: Was hast Du mit dem JavaParser denn vor?
Gruß und nochmals danke für den Bugreport,
Jochen
---------------------------------------------------------------------
To unsubscribe, e-mail: jaxme-dev-unsubscribe@ws.apache.org
For additional commands, e-mail: jaxme-dev-help@ws.apache.org
Re: Source Reflection: handling of multidimensional arrays
Posted by Jochen Wiedmann <jo...@gmail.com>.
Thanks, excellent evaluation! Applied to 0.4 branch and HEAD.
---------------------------------------------------------------------
To unsubscribe, e-mail: jaxme-dev-unsubscribe@ws.apache.org
For additional commands, e-mail: jaxme-dev-help@ws.apache.org