JvmTypesBuilder generate final parameters [message #1002252] |
Fri, 18 January 2013 08:52 |
Davide Poletti Messages: 4 Registered: August 2009 |
Junior Member |
|
|
Im'm tring to generate, using the Xtend Xbase API, a simple Java mathod.
This is the Xtend code.
var jvmMethod = element.toMethod("fromSap",element.newTypeRef(element.dtoFullName))[
var jvmTypeReference= fromSap.sapType;
var param = toParameter("sapOb",jvmTypeReference)
parameters+=param
body = ['''....''')]
everything works fine except the parameter that has the final modifier.
This is the generated code:
public class DTOTest {
public DTOTest fromSap(final String sapOb) {
DTOTest result = new DTOTest();
return result;
}
}
I tried to add:
but I got
This expression is not allowed in this context, since it doesn't cause any side effects.
at compile time
Can someone help me to remove the final modifier from the generated code?
Davide
[Updated on: Fri, 18 January 2013 08:59] Report message to a moderator
|
|
|
Re: JvmTypesBuilder generate final parameters [message #1002304 is a reply to message #1002252] |
Fri, 18 January 2013 11:04 |
Sebastian Zarnekow Messages: 3118 Registered: July 2009 |
Senior Member |
|
|
Hi Davide,
parameters are considered to be final in the linking / scoping of the
expression that are contained in your method. If they weren't final,
none of the could be used from within lambda expressions. Unfortunately
there is no means of 'final' in the reflective API (java.lang.reflect)
for parameters. Therefore no property 'isFinal' can be exposed. Why do
you want to generate non-final parameters in the first place?
Regards,
Sebastian
--
Looking for professional support for Xtext, Xtend or Eclipse Modeling?
Go visit: http://xtext.itemis.com
Am 18.01.13 09:52, schrieb Davide Poletti:
> Im'm tring to generate, using the Xtend Xbase API, a simple Java mathod.
> This is the Xtend code.
>
> var jvmMethod =
> element.toMethod("fromSap",element.newTypeRef(element.dtoFullName))[
> var jvmTypeReference= fromSap.sapType;
>
> var param = toParameter("sapOb",jvmTypeReference)
> parameters+=param
> body = ['''....''')]
>
>
>
> everything works fine except the parameter that has the final modifier.
> This is the generated code:
>
> public class DTOTest {
> public DTOTest fromSap(final String sapOb) {
> DTOTest result = new DTOTest();
> return result;
> }
> }
>
>
> I tried to add:
> param.setFinal(false);
>
> but I got
>
> This expression is not allowed in this context, since it doesn't cause
> any side effects.
>
>
> at compile time
>
> Davide
>
|
|
|
|
Powered by
FUDForum. Page generated in 0.03017 seconds