Skip to content

Pb with support for @init method with multiple arguments #17

@dvojtise

Description

@dvojtise

In Java execution engine, the launcher can use an initModel method using either a single String or a List<String>, the launcher then use the carriage return as a separator in order to provide a list of strings to the init method.

In ALE (which reuse a lot of the Java engine launcher) the tooltip on the "Model Initialization arguments" field also indicates "one line per argument" but trying to have a method

@init
	def void initializeModel(Sequence(String) input) {
		('hello from initializeModel').log();
		('input='+input+' - '+input.eClass()+' - ').log();
		for(inp in input){
			('input line='+inp).log();
		}
		/// more stuff
	}

fails with a

hello from initializeModel
input=aa bb cc -  - 
java.lang.ClassCastException: java.lang.String cannot be cast to java.util.Collection
	at org.eclipse.emf.ecoretools.ale.core.interpreter.MethodEvaluator.caseForEach(MethodEvaluator.java:306)
	at org.eclipse.emf.ecoretools.ale.implementation.util.ImplementationSwitch.doSwitch(ImplementationSwitch.java:225)
	at org.eclipse.emf.ecore.util.Switch.doSwitch(Switch.java:53)
	at org.eclipse.emf.ecore.util.Switch.doSwitch(Switch.java:69)
	at org.eclipse.emf.ecoretools.ale.core.interpreter.MethodEvaluator.lambda$0(MethodEvaluator.java:116)
	at java.util.Iterator.forEachRemaining(Iterator.java:116)
	at java.util.Spliterators$IteratorSpliterator.forEachRemaining(Spliterators.java:1801)
	at java.util.stream.ReferencePipeline$Head.forEach(ReferencePipeline.java:580)
	at org.eclipse.emf.ecoretools.ale.core.interpreter.MethodEvaluator.caseBlock(MethodEvaluator.java:116)
	at org.eclipse.emf.ecoretools.ale.implementation.util.ImplementationSwitch.doSwitch(ImplementationSwitch.java:143)
	at org.eclipse.emf.ecore.util.Switch.doSwitch(Switch.java:53)
	at org.eclipse.emf.ecore.util.Switch.doSwitch(Switch.java:69)
	at org.eclipse.emf.ecoretools.ale.core.interpreter.MethodEvaluator.eval(MethodEvaluator.java:91)
	at org.eclipse.emf.ecoretools.ale.core.interpreter.ALEEngine.eval(ALEEngine.java:30)
	at org.eclipse.emf.ecoretools.ale.ALEInterpreter.doEval(ALEInterpreter.java:299)
	at org.eclipse.emf.ecoretools.ale.ALEInterpreter.eval(ALEInterpreter.java:234)
	at org.eclipse.gemoc.ale.interpreted.engine.AleEngine.initializeModel(AleEngine.java:144)

also notice that in the message, the input.eClass() does not print any information about the current type of the argument "input" (probably another bug ?)

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't working

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions