code.tool.java.compile
class->path
added in 3.0
(class->path cls)creates a file path from a class
(class->path test.Dog) => “test/Dog.class”
(class->path ’test.Cat) => “test/Cat.class”
class-manager
added in 3.0
(class-manager manager cache)creates a ForwardingJavaFileManager
(let compiler (javax.tools.ToolProvider/getSystemJavaCompiler) collector (javax.tools.DiagnosticCollector.) manager (.getStandardFileManager compiler collector nil nil) cache (atom {}) (class-manager manager cache)) => javax.tools.ForwardingJavaFileManager
class-object
added in 3.0
(class-object class-name baos)creates a class object for use with compiler
(class-object “test.Cat” (fs/read-all-bytes “target/classes/test/Cat.class”)) => javax.tools.SimpleJavaFileObject
java-sources
added in 3.0
(java-sources {dirs :java-source-paths})lists source classes in a project
(->> (java-sources (project/project)) (keys) (filter (comp #(.startsWith % “test”) str)) (sort)) => (contains ’test.Cat test.Dog test.DogBuilder test.Person test.PersonBuilder test.Pet)
javac
added in 3.0
(javac)(javac entry)(javac packages {:keys [output reload], :or {reload false}, :as opts})(javac packages {:keys [reload output], :as opts} sources)compiles classes using the built-in compiler
(javac ’test {:output “target/classes” :reload false}) ;;=> outputs .class files in target directory
javac-process
added in 3.0
(javac-process bytes-lu {:keys [reload output], :as opts})processes compilation, either reloading
(javac-process {“test.Pet” (fs/read-all-bytes “target/classes/test/Pet.class”) “test.Cat” (fs/read-all-bytes “target/classes/test/Cat.class”)} {:output “target/classes” :reload false})
path->class
added in 3.0
(path->class path)Creates a class symbol from a file
(path->class “test/Dog.java”) => ’test.Dog
(path->class “test/Cat.class”) => ’test.Cat
supers
added in 3.0
(supers bytecode)finds supers of a class given it’s bytecode
(supers (fs/read-all-bytes “target/classes/test/Cat.class”)) => #{“java.lang.Object” “test.Pet”}