Is it possible to use clojure's gen-class macro to generate a class with static fields?

423 Views Asked by At

Can the following class be generated using Clojure's gen-class macro?

public class Test {
    public static final String TEST_NAME = "This test's name.";
}

If not, why not?

1

There are 1 best solutions below

0
On

No, gen-class can't generate static fields because gen-class is for introp. It attempts to give you the power to create the kind of classes demanded by other java libs. It is rare for a java lib to require that you provide a class with a particular static field.