nrepl

https://github.com/nrepl/nrepl || https://nrepl.org
phreed 2019-07-19T17:45:16.043800Z

@bozhidar I am having a problem running that..

java.lang.ExceptionInInitializerError
	at clojure.lang.RT.baseLoader(RT.java:2179)
	at clojure.lang.RT.load(RT.java:432)
	at clojure.lang.RT.load(RT.java:424)
	at clojure.lang.RT.<clinit>(RT.java:338)
	at edu.vanderbilt.isis.MdInspectPlugin.init(MdInspectPlugin.java:58)
	at com.nomagic.magicdraw.plugins.q.b(q.java:721)
...etc...
	at com.nomagic.launcher.Launcher.main(Launcher.java:70)
Caused by: java.lang.ClassCastException: org.eclipse.osgi.internal.framework.EquinoxConfiguration$1 cannot be cast to java.lang.String
	at clojure.lang.Compiler.<clinit>(Compiler.java:274)
The context is that this is being run as part of a plugin in a modeling tool (MagicDraw). The failing code at line 58 is:
RT.var("clojure.core", "require")
                .invoke(Symbol.intern("nrepl.cmdline"));

phreed 2019-07-19T18:02:19.044400Z

I have also tried this style http://clojure.github.io/clojure/javadoc/clojure/java/api/package-summary.html with similar results.

final IFn plus = Clojure.var("clojure.core", "+");

phreed 2019-07-19T18:15:01.044600Z

I think I see the problem. https://github.com/clojure/clojure/blob/master/src/jvm/clojure/lang/Compiler.java#L274 The value of some of the system properties is null.

phreed 2019-07-19T19:01:38.044900Z

Here is the code that seems to work for me:

public void init()
    {
        <http://log.info|log.info>("init for plugin");
        for (Map.Entry entry : System.getProperties().entrySet())
        {
            String name = (String) entry.getKey();
            try
            {
                String value = (String) entry.getValue();
                <http://log.info|log.info>("key: {}, value: {}", name, value);
            } catch (ClassCastException ex) {
                //javax.swing.JOptionPane.showMessageDialog(
                //        null,
                //        entry.getKey().toString() + " : " + entry.getValue().toString());
                entry.setValue("");
                <http://log.info|log.info>("key: {}, null value", name);
            }

        }

        // (clojure.core/+ 1 2)
        final IFn plus = Clojure.var("clojure.core", "+");
        final Object object = plus.invoke(1, 2);

        log.debug("plus invoked, result was: {}", object);

        // (clojure.core/require clojure.tools.nrepl.server)
        final IFn require = Clojure.var("clojure.core", "require");
        require.invoke(Clojure.read("nrepl.server"));

        // (clojure.tools.nrepl.server/start-server :port 12000)
        final IFn server = Clojure.var("nrepl.server", "start-server");
        server.invoke(Clojure.read(":port"), Clojure.read("12000"));
I needed the following dependencies:
implementation(group="org.clojure", name="clojure", version=clojure_version)
    implementation(group="org.clojure", name="spec.alpha", version=spec_version)
    implementation(group="org.clojure", name="core.specs.alpha", version=core_specs_version)
	implementation(group="nrepl", name="nrepl", version=nrepl_version)

phreed 2019-07-19T19:02:39.045100Z

Note that I needed both core.specs.alpha and spec.alpha.