Repository navigation
Fix Clojure protocols on records (a #27 regression), and an unloaded ClassCastException - #36
Merged
Merged
Conversation
emit-<class> names a class's superclass and interfaces with class-symbol-for-reference, which only searched the defining loader's parent chain. A class from a loader outside that chain -- Clojure makes a DynamicClassLoader per evaluation, so a defprotocol's interface and a defrecord implementing it come from sibling loaders -- was missed, a fresh symbol was interned in the new class's package, and the interface was then dropped from its supers. The record was no instance of the protocol's interface: (instance? user.Area (->Sq 5)) was false and calling the protocol method failed. This came in with #27, when user loaders stopped sharing a package. class-symbol-for-reference now falls back to %resolve-class, which asks the defining loader's loadClass, and names the class in its own package. Co-Authored-By: Claude Opus 5.5 <[email protected]>
A ClassCastException from a checkcast in a method with no handler for it, caught further up as RuntimeException, failed with "There is no class named OPENLDK::|java/lang/ClassCastException|" when nothing had loaded that class yet. %make-throwable now loads the class first. Co-Authored-By: Claude Opus 5.5 <[email protected]>
Closed
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Two bugs found while building a Clojure warm image for #4.
1. A class implementing an interface from a sibling loader (regression from #27)
Clojure makes a
DynamicClassLoaderper evaluation, so adefprotocol's interface and adefrecordimplementing it come from sibling loaders. On master:emit-<class>names a class's superclass and interfaces withclass-symbol-for-reference, which only searched the defining loader's parent chain. The interface's loader isn't in that chain, so the lookup missed, interned a fresh symbol in the new class's package, and thefind-classfilter then dropped the interface from the class's supers. Before #27 all user loaders shared one package, so the fresh symbol happened to be the interface's own; this came in when each loader got its own package.Fix:
class-symbol-for-referencefalls back to%resolve-class, which asks the defining loader'sloadClass(Clojure'sDynamicClassLoaderfinds the interface in its class cache), and names the class in its own package.2.
ClassCastExceptionbefore anything has loaded itOn master this failed with
There is no class named OPENLDK::|java/lang/ClassCastException|:%make-throwableinstantiated the exception class without loading it. Acatch (ClassCastException e)loads it, which is why this rarely showed. Fix:%make-throwableloads the class if needed.Tests
aaa/crossloader.java: an interface from one loader, implemented by a class a sibling loader defines, whoseloadClassasks the first. ChecksisInstance,isAssignableFrom, and a cast to the interface. JVMOK; master crashes (on bug 2, after bug 1's failed cast); this branchOK.aaa/castfail.java. JVMOK; master fails as above; this branchOK.25,true, matching the JVM.siblingloaders,childfirstandlazyloaderstill pass.make check-regressionruns in CI.🤖 Generated with Claude Code