Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Eclipse Projects » Sirius » Bug in DynamicJavaModuleCreator::extractArgumentSignatureString?
Bug in DynamicJavaModuleCreator::extractArgumentSignatureString? [message #1756402] Thu, 16 March 2017 12:38 Go to next message
Wilbert Alberts is currently offline Wilbert AlbertsFriend
Messages: 209
Registered: June 2010
Senior Member
Hi,

I have a vsp that depends on a number of java services. The java service contains a method with the following signature:
public void execute(Collection<? extends EObject> selections, Map<String, Object> parameters)


When creating a diagram representation I ran into the following exception:

I ran into an exception inside the extractArgumentSignatureString method.

    private static String extractArgumentSignatureString(String signature) {
        final int argStart = signature.indexOf('(') + 1;
        final int argEnd = signature.indexOf(')');

        final String argString = signature.substring(argStart, argEnd);

        String[] arguments = argString.split(COMMA);
        arguments = handleGenericArguments(arguments);

        final StringBuilder argumentsBuffer = new StringBuilder();
        for (int i = 0; i < arguments.length; i++) {
            final String argument = arguments[i];
            argumentsBuffer.append(ARGUMENT_PREFIX).append(i).append(':');

            argumentsBuffer.append(inferOCLType(argument));

            if (i != arguments.length - 1) {
                argumentsBuffer.append(COMMA);
            }
        }

        return argumentsBuffer.toString();
    }


It was given the following signature: "java.util.Collection<org.eclipse.emf.ecore.EObject>,java.util.Map<java.lang.String,java.lang.Object>". I expected the arguments array also to have two arguments. However it turned out to have three. The first one corresponded with 'selections' and 'parameters'; the third one was NULL which leads to an exception inside inferOCLType.

I inspected handleGenericArguments as well and when providing that one with the string presented above, it seems to return the array with three arguments. This method calculates a newArguments ArrayList and is correct until the last statement:
        return newArguments.toArray(arguments);


As arguments has three arguments, newArguments is also put in an array consisting of three arguments. Obviously, the last element then is assigned to null. So either it should return a new array like
        return newArguments.toArray();
or extractArgumentSignatureString should stop processing arguments when it encounters a null value I think.

Is this indeed a bug?

Greetings,
Wilbert.
Re: Bug in DynamicJavaModuleCreator::extractArgumentSignatureString? [message #1756403 is a reply to message #1756402] Thu, 16 March 2017 12:49 Go to previous messageGo to next message
Pierre-Charles David is currently offline Pierre-Charles DavidFriend
Messages: 703
Registered: July 2009
Senior Member
Hi,

Service methods must follow some specific rules, listed at https://www.eclipse.org/sirius/doc/specifier/general/Writing_Queries.html#service_methods, that your "execute()" method does seem to follow:
* the first argument *must* be an EObject (or some more domain-specific type): it will be used to pass the "self" value to your service;
* the method *must* return something. If you don't have any relevant value to return, declare the return type as "EObject" and "return self;" (the first argument).

My guess is that extractArgumentSignatureString() assumes the service method follows those rules, and fails in non-obivous ways because your execute() method does not.

Regards,
Pierre-Charles David (Obeo)


Pierre-Charles David - Obeo

Need training or professional services for Sirius?
http://www.obeodesigner.com/sirius
Re: Bug in DynamicJavaModuleCreator::extractArgumentSignatureString? [message #1756463 is a reply to message #1756403] Fri, 17 March 2017 10:04 Go to previous message
Wilbert Alberts is currently offline Wilbert AlbertsFriend
Messages: 209
Registered: June 2010
Senior Member
Hi Pierre-Charles,

You are definitely correct in your analysis. I added a java file as service that actually only provided java actions.

Sorry for the confusion.

Greetings,
Wilbert
Previous Topic:Run the models in Sirius
Next Topic:Using EEF with Sirius
Goto Forum:
  


Current Time: Thu Apr 25 09:46:38 GMT 2024

Powered by FUDForum. Page generated in 0.02824 seconds
.:: Contact :: Home ::.

Powered by: FUDforum 3.0.2.
Copyright ©2001-2010 FUDforum Bulletin Board Software

Back to the top