getting the java Class from its node<ClassConcept> definition? (reflection / dynamic class loading)

Hello!

In MPS I have a solution "A" that needs to dynamically load a java class "C" defined in one of its dependencies (let's call it solution "B"). Solution "A" has only the interface of class "C" defined in its language. The implemention of "C" is in solution "B". 

From solution "A", I am able to find in "B" the node (of type node<ClassConcept>) corresponding to "C". Now I'd like to create an instance of the class "C". How Can I achieve it ?

 

Thanks and best regards!

Etienne

 

ps: 

I have attempted the following to get the java Class: 

Class c = classNode.getThisType().getClass(smodule)

And it throws an illegalstate exception from java reflective api.

2 comments

You have to change the solution kind in the module properties of your solution "B".

 

Only if it is set to a value other than "None", MPS allows to load classes from that solution.

0

Please sign in to leave a comment.