Bug 318841 - Calling java methods fails when multiple parameters are given
Summary: Calling java methods fails when multiple parameters are given
Status: CLOSED FIXED
Alias: None
Product: Acceleo
Classification: Modeling
Component: Core (show other bugs)
Version: 3.0.0   Edit
Hardware: PC Windows XP
: P3 normal
Target Milestone: ---   Edit
Assignee: Project Inbox CLA
QA Contact:
URL:
Whiteboard:
Keywords: contributed
Depends on:
Blocks:
 
Reported: 2010-07-05 04:13 EDT by heppg CLA
Modified: 2010-08-05 03:19 EDT (History)
1 user (show)

See Also:


Attachments
stack trace (6.15 KB, text/plain)
2010-07-05 04:15 EDT, heppg CLA
no flags Details
mylyn/context/zip (787 bytes, application/octet-stream)
2010-08-04 12:20 EDT, Tristan Faure CLA
no flags Details
the correct patch (1.11 KB, patch)
2010-08-04 12:22 EDT, Tristan Faure CLA
laurent.goubet: iplog+
Details | Diff

Note You need to log in before you can comment on or make changes to this bug.
Description heppg CLA 2010-07-05 04:13:53 EDT
Build Identifier: acceleo 3.0.0

acceleo 3.0.0
When calling java-Methods with multiple parameters, the call fails with Exception
org.eclipse.acceleo.engine.AcceleoEvaluationException: Undefined result for expression ... see stack trace

In mtl, the call is [type.getStereotypeValue('native','schema')/]

The query definition is
[query private getStereotypeValue(arg0 : Element, arg1 : String, arg2 : String) : 
               String = invoke('org.acceleo.modules.uml2.services.Uml2ServicesX', 
                                'getStereotypeValue(org.eclipse.uml2.uml.Element, java.lang.String, java.lang.String)', 
                                Sequence{arg0, arg1, arg2})
/]

The java-code signature is
	public String getStereotypeValue(org.eclipse.uml2.uml.Element elt, String stereotype,
			String property) throws Exception{ ... }

The java-method is not called.

In order to validate the setup, a modified java-method was created which does not need the two Strings as arguments:

	public String getStereotypeValueNS(Element elt) throws Exception {
		log("getStereotypeValueNSN");
		return getStereotypeValue(elt, "native", "schema");
	}
The query for this is:
[query private getStereotypeValueNS(arg0 : Element) : 
               String = invoke('org.acceleo.modules.uml2.services.Uml2ServicesX', 
                                'getStereotypeValueNS(org.eclipse.uml2.uml.Element)', 
                                Sequence{arg0})
/]

This modified method/query returns the correct results --> java code is correct.





Reproducible: Always

Steps to Reproduce:
1. create mtl-file and java-code
2. run mtl directly or run java-code produced from mtl.
Comment 1 heppg CLA 2010-07-05 04:15:05 EDT
Created attachment 173390 [details]
stack trace
Comment 2 Laurent Goubet CLA 2010-07-06 05:24:54 EDT
Hi,

This closely resembles a known issue with multiple parameters calls. Namely, you cannot use 

[type.getStereotypeValue('native','schema')/]

but should use

[getStereotypeValue(type, 'native','schema')/]

instead.

We are trying to narrow down and fix this issue. Could you confirm that this change fixes the issue for your case too?
Comment 3 heppg CLA 2010-07-06 07:40:26 EDT
...
> Namely, you cannot use 
> [type.getStereotypeValue('native','schema')/]
> but should use
> [getStereotypeValue(type, 'native','schema')/]
> ..
> Could you confirm that this change fixes the issue for your 
> case too?

I checked this, but I get this Exception too. So both
 [type.getStereotypeValue('native','schema')/]
 [getStereotypeValue(type, 'native','schema')/]
produce the same error message.
Comment 4 Laurent Goubet CLA 2010-07-06 07:42:16 EDT
Thanks for the verification ... which means this indeed is a separate issue :'(.
Comment 5 Tristan Faure CLA 2010-08-04 12:19:43 EDT
Hi i have also the same problem there is a bug in org.eclipse.acceleo.engine.internal.environment.AcceleoLibraryOperationVisitor. In indexOf method the character to find and the offset were inverted. With this inevrsion the list of arguments are not correctly parsed

I spent a little time to understand why indexOf returned -1 ^^

I send you the patch
Comment 6 Tristan Faure CLA 2010-08-04 12:20:09 EDT
Created attachment 175847 [details]
mylyn/context/zip

this is the patch fixing the problem
Comment 7 Tristan Faure CLA 2010-08-04 12:22:33 EDT
Created attachment 175849 [details]
the correct patch

sorry this is the patch
Comment 8 Laurent Goubet CLA 2010-08-05 03:17:56 EDT
Thanks Tristan!

This has been committed on HEAD, and will soon be committed on the 3.0 maintenance branch.

Looking at the code I wrote (and which you patched), I believe I was a little sleepy that day :p. I should set up my Eclipse to forbid me from relying on autoboxing ^^.