Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Modeling » Epsilon » eol standalone failed to run native types
eol standalone failed to run native types [message #1771536] Sun, 27 August 2017 06:44 Go to next message
Banafsheh Azizi is currently offline Banafsheh AziziFriend
Messages: 328
Registered: July 2016
Senior Member
Hi,

I wanna to use eol standalone [1] to run my eol code with java. However, It failed to run native types. e.g., if I have the below code in my eol program:
var interfaceRule : new Native("layout.interfaceRule");
var mode : String = interfaceRule.callMode();

I have the below error:
Exception in thread "main" Type 'layout.interfaceRule' not found
	at (/Users/apple/Desktop/w5/standalone1/src/org/eclipse/epsilon/examples/standalone/eol/Demo.eol@5:24-5:54)
	at (/Users/apple/Desktop/w5/standalone1/src/org/eclipse/epsilon/examples/standalone/eol/Demo.eol@5:0-5:55)

	at org.eclipse.epsilon.eol.types.EolNativeType.<init>(EolNativeType.java:37)
	at org.eclipse.epsilon.eol.dom.TypeExpression.execute(TypeExpression.java:51)
	at org.eclipse.epsilon.eol.execute.ExecutorFactory.executeAST(ExecutorFactory.java:109)
	at org.eclipse.epsilon.eol.dom.VariableDeclaration.execute(VariableDeclaration.java:58)
	at org.eclipse.epsilon.eol.execute.ExecutorFactory.executeAST(ExecutorFactory.java:109)
	at org.eclipse.epsilon.eol.dom.ExpressionStatement.execute(ExpressionStatement.java:19)
	at org.eclipse.epsilon.eol.execute.ExecutorFactory.executeAST(ExecutorFactory.java:109)
	at org.eclipse.epsilon.eol.dom.StatementBlock.execute(StatementBlock.java:43)
	at org.eclipse.epsilon.eol.execute.ExecutorFactory.executeAST(ExecutorFactory.java:109)
	at org.eclipse.epsilon.eol.EolModule.execute(EolModule.java:55)
	at org.eclipse.epsilon.examples.standalone.EpsilonStandaloneExample.execute(EpsilonStandaloneExample.java:81)
	at org.eclipse.epsilon.examples.standalone.EpsilonStandaloneExample.execute(EpsilonStandaloneExample.java:69)
	at org.eclipse.epsilon.examples.standalone.eol.EolStandaloneExample.main(EolStandaloneExample.java:30)

I have an eol program which calls several native types. Is there any way to eol standalone can handle these statements?
[1]. https://eclipse.org/epsilon/examples/index.php?example=org.eclipse.epsilon.examples.standalone


Member of MDSE Research Group
http://mdse.ui.ac.ir

[Updated on: Sun, 27 August 2017 07:10]

Report message to a moderator

Re: eol standalone failed to run native types [message #1771541 is a reply to message #1771536] Sun, 27 August 2017 10:31 Go to previous messageGo to next message
Athanasios Zolotas is currently offline Athanasios ZolotasFriend
Messages: 52
Registered: November 2016
Location: York
Member
Hi,

You can certainly call native types in EOL programs executed from Java. For example, you can try the following code in you script and check if it works:

var frame = new Native("javax.swing.JFrame");
frame.title = "Opened with EOL";
frame.setBounds(100,100,300,200);
frame.visible = true; 


One possible reason for the error might be passing a wrong package name in the new Native(argument) method. Could you please provide a minimal example [1] so we can investigate more?

Thanks,
Thanos

[1]: https://www.eclipse.org/epsilon/doc/articles/minimal-examples/
Re: eol standalone failed to run native types [message #1771543 is a reply to message #1771541] Sun, 27 August 2017 10:51 Go to previous messageGo to next message
Banafsheh Azizi is currently offline Banafsheh AziziFriend
Messages: 328
Registered: July 2016
Senior Member
No Message Body

Member of MDSE Research Group
http://mdse.ui.ac.ir

[Updated on: Sun, 27 August 2017 11:18]

Report message to a moderator

Re: eol standalone failed to run native types [message #1771709 is a reply to message #1771541] Tue, 29 August 2017 18:18 Go to previous messageGo to next message
Banafsheh Azizi is currently offline Banafsheh AziziFriend
Messages: 328
Registered: July 2016
Senior Member
When I run your code, it doesn't have an error. However, e.g., with running the main function of EolStandaloneExample class of the attached minimal example, it has an error although the Native type is shown on Tools. I also attached the jar file of plugin.

Moreover, I read at the end of https://www.eclipse.org/epsilon/doc/articles/call-java-from-epsilon/ about adding the line of code "context.getNativeTypeDelegates().add(new ExtensionPointToolNativeTypeDelegate());". I don't really know where I should insert the line of code. By the way, when I insert "module.getContext().getNativeTypeDelegates().add(new ExtensionPointToolNativeTypeDelegate());" in the EpsilonStandaloneExample class. It doesn't effect (I still have an error because of the Native type).


Member of MDSE Research Group
http://mdse.ui.ac.ir

[Updated on: Tue, 29 August 2017 18:39]

Report message to a moderator

Re: eol standalone failed to run native types [message #1771768 is a reply to message #1771709] Wed, 30 August 2017 09:31 Go to previous messageGo to next message
Athanasios Zolotas is currently offline Athanasios ZolotasFriend
Messages: 52
Registered: November 2016
Location: York
Member
Hi,

To be honest I got a little bit confused with the example you provided but we will figure this out eventually.

I did this first:
I imported in my Eclipse the project and the haetae plugin. I found out that the org.eclipse.epsilon.common.dt tool extension that points to the tool class was missing so I created it. In addition, the jar file was not in the classpath. I added it and launched a new Eclipse instance. I created an EOL file in a new project . The tool was there but when I executed the command var tool1 : new Native("org.eclipse.epsilon.eol.visitor.printer.impl.EolPrinter"); I got an exception. However, the exception was caused because another required by haetea plugin (called org.eclipse.epsilon.haetae.eol.metamodel.visitor) was missing. When I checked out this plugin from Github in my first Eclipse instance and added it the the project dependencies, I relaunced the new Eclipse instance and my EOL program was executed succesfully.

I then tried to figure out if the project you provided is working or not. In my new Eclipse instance (this is important because I don't have haetae installed so in order to load all the plugins from the source code I checked-out I need to run a new Eclipse instance) I imported the project and run the main. I got no exception and everything was printed as normal. What's the exception you get when running the Demo.eol file? Is there any chance that you get the same exception I got in the first step that is caused by the org.eclipse.epsilon.haetae.eol.metamodel.visitor.AbortStatementVisitor class missing? Are you sure that you have everything needed by the haetae plugin loaded when you try to run your standalone epsilon program?

I wish I could help more.

Maybe explaining what exactly you are trying to do would allow me to help more.

Regards,
Thanos
Re: eol standalone failed to run native types [message #1771778 is a reply to message #1771709] Wed, 30 August 2017 10:26 Go to previous messageGo to next message
Horacio Hoyos is currently offline Horacio HoyosFriend
Messages: 240
Registered: October 2009
Location: Mexico
Senior Member

Hi Banafsheh,

The native java support is implemented to work within Eclipse, so you will need a bit of extra work to make it work. In the current implementation, when you want to use your own Java native types you use an extension point to register your java class so that the EOL engine can find it when you do
var interfaceRule : new Native("layout.interfaceRule");


The ExtensionPointToolNativeTypeDelegate() you mention in your comment is the class responsible for find the native types. It does so by asking Eclipse about all plugins that have used the extension point to register native classes.

For a standalone scenario I think you need to provide your own type delegate, in the lines of:
public class MyNativeTypeDelegate extends AbstractToolNativeTypeDelegate{
	

	public MyNativeTypeDelegate() {
	}
	
	public Object createInstance(String clazz, List<Object> parameters) throws EolRuntimeException {
		return new InterfaceRule();
	}

	public boolean knowsAbout(String clazz) {
		if (clazz == "layout.interfaceRule")
                    return true;
                return false 
	}

}


The knowsAbout method is first called to test if the TypeDelegate knows how to create instances of that class, and the createInstance method instantiates the class. Note that this implementation is very fragile. Basically think of it as a factory for your Native types. You could improve it by supporting more types and passing the parameters to the constructor.

With your NativeTypeDelegate in place, then you can use it in your EOL standalone implementation:
...
public void execute() throws Exception {
		
		module = createModule();
		module.parse(getFileURI(getSource()));
		if (module.getParseProblems().size() > 0) {
			System.err.println("Parse errors occured...");
			for (ParseProblem problem : module.getParseProblems()) {
				System.err.println(problem.toString());
			}
			return;
		}
		
		
		module.getContext().getNativeTypeDelegates().
		  add(new MyNativeTypeDelegate());
		
		for (IModel model : getModels()) {
			module.getContext().getModelRepository().addModel(model);
		}
		
		for (Variable parameter : parameters) {
			module.getContext().getFrameStack().put(parameter);
		}
		
		preProcess();
		result = execute(module);
		postProcess();
		
		module.getContext().getModelRepository().dispose();
	}
...


Note that you could have many TypeDelegates.

Another option, which might work, is using the EolClasspathNativeTypeDelegate, which adds the class path to the available native types. Which should in turn make all the classes in your standalone jar path available.

Cheers,


Horacio Hoyos Rodriguez
Kinori Tech
Need professional support for Epsilon, EMF?
Go to: https://kinori.tech
Re: eol standalone failed to run native types [message #1771829 is a reply to message #1771778] Thu, 31 August 2017 07:53 Go to previous messageGo to next message
Banafsheh Azizi is currently offline Banafsheh AziziFriend
Messages: 328
Registered: July 2016
Senior Member
Thanks all.

Thanos Zolotas wrote on Wed, 30 August 2017 09:31

I then tried to figure out if the project you provided is working or not. In my new Eclipse instance (this is important because I don't have haetae installed so in order to load all the plugins from the source code I checked-out I need to run a new Eclipse instance) I imported the project and run the main.


Do you import the pure project I send in new eclipse? Or you add some dependencies to it?
would you please share your project to I run it and check whether I have an error?


Member of MDSE Research Group
http://mdse.ui.ac.ir

[Updated on: Thu, 31 August 2017 08:53]

Report message to a moderator

Re: eol standalone failed to run native types [message #1771849 is a reply to message #1771829] Thu, 31 August 2017 11:44 Go to previous messageGo to next message
Athanasios Zolotas is currently offline Athanasios ZolotasFriend
Messages: 52
Registered: November 2016
Location: York
Member
Hi,

I combined Horacio's suggestions to your project, added the necessary dependencies to the manifest and I attach the project that executes the Demo.eol file without throwing exceptions.

With this combined solution you can simply import the project in the Eclipse instance you have Epsilon and Haetae installed. What I've done is that in my Epsilon Eclipse I just checked-out and imported haetae from the Github repository [1] (If you have this installed from the update site it should work, too). I then imported the attached project in this instance without needing to run a new one.

I still don't know what exactly you're trying to do so I am definitely not sure if this is what you're actually looking for.

Regards,
Thanos

[1]: https://github.com/epsilonlabs/haetae
Re: eol standalone failed to run native types [message #1771893 is a reply to message #1771849] Thu, 31 August 2017 18:48 Go to previous message
Banafsheh Azizi is currently offline Banafsheh AziziFriend
Messages: 328
Registered: July 2016
Senior Member
Thanks a million.

My problem was solved. It seems without MyNativeTypeDelegate class also it works well.


Member of MDSE Research Group
http://mdse.ui.ac.ir
Previous Topic:set the aliases of metamodel in standalone
Next Topic:How to store all root elements in a variable using EOL?
Goto Forum:
  


Current Time: Thu Mar 28 23:37:11 GMT 2024

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

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

Back to the top