-
Notifications
You must be signed in to change notification settings - Fork 7
mutual dependent class not working #65 #70
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
|
I've got it fixed on my side by not throwing an exception in @Override
- public void load(ExecutionControl.ClassBytecodes[] cbcs) throws ExecutionControl.ClassInstallException {
+ public void load(ExecutionControl.ClassBytecodes[] cbcs) {
boolean[] installed = new boolean[cbcs.length];
int i = 0;
for (ExecutionControl.ClassBytecodes cbc : cbcs) {
declaredClasses.put(cbc.name(), cbc.bytecodes());
try {
Class<?> loaderClass = classLoader.findClass(cbc.name());
loadedClasses.put(cbc.name(), loaderClass);
} catch (ClassNotFoundException e) {
- throw new ExecutionControl.ClassInstallException("Unable to load class " + cbc.name()
- + ": " + e.getMessage(), installed);
+ logger.warn("Class {} not found, expected to be declared later", cbc.name());
}
installed[i++] = true;
}
} |
|
I think we are moving in the right direction. However, this fix may be too optimistic. There can be irrecoverable class loading failures too, and we should throw on those. Look inside Notice how JShell has this very precise messaging about the two classes involved: |
|
I see. We need to mark all the classes as declared first to make it possible to find them later via Index: jjava-kernel/src/main/java/org/dflib/jjava/kernel/execution/JJavaLoaderDelegate.java
IDEA additional info:
Subsystem: com.intellij.openapi.diff.impl.patch.CharsetEP
<+>UTF-8
===================================================================
diff --git a/jjava-kernel/src/main/java/org/dflib/jjava/kernel/execution/JJavaLoaderDelegate.java b/jjava-kernel/src/main/java/org/dflib/jjava/kernel/execution/JJavaLoaderDelegate.java
--- a/jjava-kernel/src/main/java/org/dflib/jjava/kernel/execution/JJavaLoaderDelegate.java (revision f04acb8d6738b2264a6af35ae0490fe803e87a85)
+++ b/jjava-kernel/src/main/java/org/dflib/jjava/kernel/execution/JJavaLoaderDelegate.java (date 1763670856855)
@@ -30,9 +30,13 @@
@Override
public void load(ExecutionControl.ClassBytecodes[] cbcs) throws ExecutionControl.ClassInstallException {
boolean[] installed = new boolean[cbcs.length];
+
+ for (ExecutionControl.ClassBytecodes cbc : cbcs) {
+ declaredClasses.put(cbc.name(), cbc.bytecodes());
+ }
+
int i = 0;
for (ExecutionControl.ClassBytecodes cbc : cbcs) {
- declaredClasses.put(cbc.name(), cbc.bytecodes());
try {
Class<?> loaderClass = classLoader.findClass(cbc.name());
loadedClasses.put(cbc.name(), loaderClass); |
be0a12d to
98c2a90
Compare
|
@m-dzianishchyts , your latest solution works the same way as JShell. I incorporated it in my PR. Thanks! |
@stariy95 , I was able to address a part of the issue - avoiding failures in the declaration snippet. However an attempt to instantiate one of the declared classes in the following cell still throws. So we need to dig a bit deeper.