Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

how to reload aot compiled classes without resetting the repl?

Tags:

clojure

I've defined a java class using gen-class and it get compile everytime I start the repl. However, if I wish to make changes to the class, I find that I have to restart and recompile the class. Is there anyway to do this without closing down the repl?

An example

I am working on this https://github.com/zcaudate/hara/blob/master/src/hara/ova/impl.clj

and there is a line in project. clj

:aot [hara.ova.impl]

So say the file is already loaded and I can do:

(import hara.ova.Ova)
(def a (Ova.))

I wanted to add another method bar to the class, I just wish to define -bar in the hara.ova.impl namespace, call a compile-gen-class function to reload the class and then do this without reloading the repl:

(import hara.ova.Ova)
(def a (Ova.))
(.bar a)

right now, C-c C-k doesn't allow that.

like image 531
zcaudate Avatar asked Apr 15 '13 03:04

zcaudate


1 Answers

You need to call the compile function on the namespace.

(ns test) (gen-class :name test.Cls) (comment (compile 'test))

The call to compile needs to be commented out so it won't recursively call itself. I often leave these in my development files to quickly recompile definitions by evaluating that compile expression.

like image 112
Jeremie Pelletier Avatar answered Dec 31 '22 18:12

Jeremie Pelletier