clojure

How to access .class? (java interop)


This is the java code I'm trying to implement in clojure:

manager.load("data/mytexture.png", Texture.class);

I've tried this:

(.load "resources/bucket.png" (.class Texture))

which yields:

Execution error (IllegalArgumentException) at bucket-drops.core/fn$fn (core.clj:79).
No matching field found: class for class java.lang.Class

and

(.load "resources/bucket.png" Texture/class)

yielding

Syntax error compiling at (bucket_drops/core.clj:79:19).
Unable to find static field: class in class com.badlogic.gdx.graphics.Texture

So, how to actually access .class?


Solution

  • I guess load is method of AssetManager from LibGDX. Import both classes:

    (:import (com.badlogic.gdx.assets AssetManager)
               (com.badlogic.gdx.graphics Texture))
    

    Then call

    (.load manager "resources/bucket.png" Texture)
    

    Or use doto:

    (doto manager
      (.load "resources/bucket.png" Texture))