Bug in DynamicJavaModuleCreator::extractArgumentSignatureString? [message #1756402] |
Thu, 16 March 2017 12:38 |
Wilbert Alberts 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.
|
|
|
|
|
Powered by
FUDForum. Page generated in 0.02824 seconds