I attempted to reproduce based on the code above and it failed to reproduce
% cat A.java
public class A {
public int af() { return 2; }
public int af1(int x) { return x+2; }
public int a = 1;
static public int as;
static public int afs() { return 20; }
static public int afs1(int x) { return x+20; }
}
% javac A.java
% clojure -Scp "."
Error: Could not find or load main class clojure.main
Caused by: java.lang.ClassNotFoundException: clojure.main
zsh: exit 1 clojure -Scp "."
% clojure -Sdeps '{:paths ["."]}'
Clojure 1.10.2
user=> (import A)
A
user=> (def a (A.))
#'user/a
user=> (def x (A.))
#'user/x
user=> (def a1 (A.))
#'user/a1
user=> (.a a1)
1
user=> (.a x)
1
user=> (.a a)
1
user=>
It looks like your clojure
script is not the tools.deps clojure script, since that has no -cp option, what script is it and what else is it doing besides launching clojure? Your repl also doesn't print the version of clojure when you start it, what repl are you using, what version of clojure?