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 "Minjat Florian (Consultant)" <fl...@consultant.volvo.com> on 2008/04/08 16:37:56 UTC
Java Source Reflection - getLines doesn't work ?
Hi,
I need to use reflextion on a source file to extract information and
generate an xml file. I found the jaxme project and especially its Java
Source Reflection part very interresting.
I especially liked the possibility to use Reflection on a method body.
But by looking deeper in the API, it doesn't seem to be possible to read
the metamodel of a method body, only to write it (addIf, newJavaField,
...).
My next step was to get the bare contents of a JavaMethod and get the
information I need with regular expression. But when I call getLines on
a JavaMethod I get an empty list. This fonctionality doesn't exist or do
I misuse the API ?
Here is my code :
JavaMethod rr = myJavaSource.getMethod("myMeth", new JavaQName[]
{JavaQNameImpl.getInstance("com.bla.bla","myParam")});
Iterator it = rr.getLines();
It.hasNext(); => false
I could get the method code using regular expression directly on the
source file but it's sad getLines doesn't work this way. Is there
another way ?
Thanks in advance for your answer,
Florian