Fork me on GitHub

Oh, I see what he means by visibility now. When the debugger has a reference to a classloader in the debugged JVM, it can call visibleClasses() to get a list of classes visible to the classloader. Unfortunately all this seems to be in a package which is not part of the public JDI API.


Yeah, debugging that, it’s getting down to the wire protocol level. But according to that call, the DCL only has 13 classes visible, and it sounds like it should have all the JDK classes as well.


@cfleming but before alpha5 all classes were visible?


Just checking that now…


@ghadi So… no. But there are more classes visible, including Object.


0 = {} "class user$eval147$fn__148 (loaded by instance of clojure.lang.DynamicClassLoader(id=2791))"
1 = {} "class java.lang.Object (no class loader)"
2 = {} "array class java.lang.Object[] (no class loader)"
3 = {} "array class java.lang.Object[][] (no class loader)"
4 = {} "class clojure.lang.AFunction (loaded by instance of sun.misc.Launcher$AppClassLoader(id=2675))"
5 = {} "class user$eval147 (loaded by instance of clojure.lang.DynamicClassLoader(id=2791))"
6 = {} "array class boolean[] (no class loader)"
7 = {} "array class byte[] (no class loader)"
8 = {} "array class byte[][] (no class loader)"
9 = {} "array class char[] (no class loader)"
10 = {} "array class int[] (no class loader)"
11 = {} "array class short[] (no class loader)"
12 = {} "array class long[] (no class loader)"
13 = {} "array class long[][] (no class loader)"
14 = {} "array class float[] (no class loader)"
15 = {} "array class double[] (no class loader)"


That’s before


0 = {} "class user$eval147 (loaded by instance of clojure.lang.DynamicClassLoader(id=2790))"
1 = {} "class clojure.lang.AFunction (loaded by instance of sun.misc.Launcher$AppClassLoader(id=2677))"
2 = {} "class user$eval147$fn__148 (loaded by instance of clojure.lang.DynamicClassLoader(id=2790))"
3 = {} "array class boolean[] (no class loader)"
4 = {} "array class byte[] (no class loader)"
5 = {} "array class byte[][] (no class loader)"
6 = {} "array class char[] (no class loader)"
7 = {} "array class int[] (no class loader)"
8 = {} "array class short[] (no class loader)"
9 = {} "array class long[] (no class loader)"
10 = {} "array class long[][] (no class loader)"
11 = {} "array class float[] (no class loader)"
12 = {} "array class double[] (no class loader)"


That’s after.


I assume the classes with “no class loader” have been loaded by JDI when required rather than by the app, but I’m only guessing.


This is getting down to the black magic level unfortunately.


Here’s the javadoc of the exception. It’s pretty clear that it is normal for classes not to be visible - this is why they do the evaluation in a loop.


But I don’t understand why the DCL can’t see Object - Object must obviously be loaded, I provoke this bug after executing Clojure code so all the basic classes must be there.


Object, Object[], and Object[][] all disappear.


(watching this debugging discussion is quite fascinating -- thank you for doing this out in the open)


No worries, I’m just hoping someone else sees something I’ve missed 🙂


I’m basically stuck at the “needs someone who actually understands this bit” stage now.


I suspect there are like a dozen people in the world who understand JDI at this level - I’m hoping Egor is one of them.


Which version of ASM is vendored in at the moment?


"vendor asm to sha 88a0aa8a79df7370cd178281bdf690ac2361c19a" but i actually can't find that commit in their tree


The issue seems to be with how Compiler.eval switches classloaders - it’s Saturday here and I haven’t had time to investigate properly, but I’ll report back later. The good thing is there seems to be a workaround on the Cursive side, but I guess any other JDI interface would have to do the same. It does seem like the classes Clojure generates are suspect under some circumstances, perhaps due to the new (well, new in Java 6) verifier.

Alex Miller (Clojure team)21:01:53

we should be using bytecode version 52 though now (java 1.8)?

Alex Miller (Clojure team)21:01:12

oh, he just means that’s when it starts failing

Alex Miller (Clojure team)21:01:58

we’re just using ASM in pretty normal ways so not sure what we’re doing that’s weird