<< Back to previous view

[CLJCLR-32] RT.load does not correctly map namespace to source file or dll name Created: 30/Jun/14  Updated: 21/Aug/14

Status: Open
Project: ClojureCLR
Component/s: None
Affects Version/s: None
Fix Version/s: None

Type: Defect Priority: Major
Reporter: Antti Karanta Assignee: David Miller
Resolution: Unresolved Votes: 0
Labels: None


When doing (from C#)

RT.load( "my.util", true );

and having directory containing my\util.clj on CLOJURE_LOAD_PATH I get

System.IO.FileNotFoundException: Could not locate my.util.clj.dll or my.util.clj on load path.

I believe the latter is wrong - it should be looking for my\util.clj on load path?

Also, there is a problem with compiled assemblies whose namespace contains -'s. For example, if I have compiled namespace myns.foo-bar (in file myns\foo_bar.clj) it produces myns.foo_bar.clj.dll. If I try to load it like so:

RT.load( "myns.foo-bar", true );
System.IO.FileNotFoundException: Could not locate myns.foo-bar.clj.dll or myns.foo-bar.clj on load path.

I think RT.load should "know" that compiling a namespace with - character in it is mapped to _ on the corresponding dll or source file name.

Comment by David Miller [ 16/Aug/14 2:35 PM ]

One should not be calling RT.load directly. Most functions in the RT namespace are not for C# code doing Clojure interop.

In the case of RT.load specifically, internally it is called only once, during system init, to load clojure/core.

Instead of direct calls, use the new interop capability to call from C# to Clojure functions.
The Clojure.var method is actually clojure.clr.api.Clojure.var

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

See if this works for you.

Comment by Antti Karanta [ 21/Aug/14 1:49 AM ]

Ah, ok, I thought RT's methods were public API, I think I picked this usage up from an example somewhere and it seemed to work. And mostly does.

I'm currently using Clojure-CLR 1.5.0 and class clojure.clr.api.Clojure does not seem to exist. I take it is new in 1.6.0? What is the recommended way to load a namespace / var in 1.5.0?

Comment by David Miller [ 21/Aug/14 10:46 AM ]

That class is indeed new in 1.6.0. In 1.50, you can do exactly what clojure.clr.api does:

private static Symbol asSym(object o)

{ String str = o as String; Symbol s = str != null ? Symbol.intern(str) : (Symbol)o; return s; }

public static IFn var(object qualifiedName)

{ Symbol s = asSym(qualifiedName); return var(s.Namespace, s.Name); }

public static IFn var(object ns, object name)

{ return Var.intern(asSym(ns), asSym(name)); }

If you have two strings, one for namespace, one for name, this simplifies to

Var x = clojure.lang.Var.intern(ns,name);

[CLJCLR-27] Add more support for attributes in gen-class Created: 07/Dec/13  Updated: 16/Aug/14  Resolved: 22/Jun/14

Status: Resolved
Project: ClojureCLR
Component/s: None
Affects Version/s: None
Fix Version/s: None

Type: Enhancement Priority: Major
Reporter: David Miller Assignee: David Miller
Resolution: Completed Votes: 1
Labels: None


For example, to support COM interop, it would be nice to annotate the gen-class'd class with

[ComImport, Guid("E436EBB3-524F-11CE-9F53-0020AF0BA770")]

We already have attribute support for definterface, deftype, gen-interface, so this should be easy to do.

Comment by Antti Karanta [ 23/Jun/14 2:05 AM ]

Great! Is there any how-to documentation for this feature as of yet?

Comment by David Miller [ 16/Aug/14 3:15 PM ]

There is some code. Look at


Also look at


Comment by David Miller [ 16/Aug/14 3:16 PM ]

And I added support for attaching attributes to gen-class'd classes in this commit:


Generated at Fri Aug 22 01:00:41 CDT 2014 using JIRA 4.4#649-r158309.