Skip to content

Instantly share code, notes, and snippets.

@fogus
Created February 14, 2024 14:25
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save fogus/2b3e8ae9c6f0643f615284084e9b37e2 to your computer and use it in GitHub Desktop.
Save fogus/2b3e8ae9c6f0643f615284084e9b37e2 to your computer and use it in GitHub Desktop.
ls
test$__STAR_.class
test$__STAR__STAR_.class
test$_main.class
test$loading__6798__auto____138.class
test__init.class
test$_init.class
test$fn__140.class
test.class
% javap test
public class foo.Test {
public final java.lang.Object ***;
public static {};
public foo.Test();
public boolean equals(java.lang.Object);
public java.lang.String toString();
public int hashCode();
public java.lang.Object clone();
}
(def t (foo.Test.))
(.-*** t)
Execution error (IllegalArgumentException) at user/eval150 (REPL:1).
No matching field found: _STAR__STAR__STAR_ for class foo.Test
(clojure.lang.Reflector/getField foo.Test "***" false)
#object[java.lang.reflect.Field 0x551de37d "public final java.lang.Object foo.Test.***"]
(-> t .getClass (.getDeclaredField "***") (.get t) deref)
42
(ns foo.test
(:gen-class))
(gen-class
:name "foo.Test"
:state "***"
:init "init"
:prefix "-"
;; :methods [[* [] String] uncommenting causes compilation error
;; [** [] String]]
)
(defn -init []
[[] (atom 42)])
(defn -* [this]
"one star")
(defn -**
[this]
"two stars")
(defn -main [& args]
(-*)
(-**))
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment