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


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!




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.

Comment actions Permalink

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.

Comment actions Permalink

Many thanks it is working now!


Please sign in to leave a comment.