-
Notifications
You must be signed in to change notification settings - Fork 323
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
Calling toString
on an Enso object implementing a Java interface causes Panic
#7437
Comments
Exposing I understand that logging is problematic when |
Here is a small program that demonstrates the behavior on Python object: import org.graalvm.polyglot.Context;
import org.graalvm.polyglot.HostAccess;
public class ToString {
public interface WithX {
int x();
}
public static void main(String[] args) {
try (
var ctx = Context.newBuilder()
.allowHostAccess(HostAccess.ALL)
.build()
) {
var obj = ctx.eval("python", """
class WithX:
def __init__(self, v):
self.x = v
WithX(42)
""").as(WithX.class);
System.out.println("obj.x: " + obj.x());
var txt = obj.toString();
System.out.println("obj : " + txt);
}
}
} when executed as
Something else must be wrong in the Enso case... |
Probably related to @Override
public Object invoke(Object proxy, Method method, Object[] arguments) throws Throwable {
CompilerAsserts.neverPartOfCompilation();
Object[] resolvedArguments = arguments == null ? EMPTY : arguments;
try {
return invoke.call(languageContext, obj, method, resolvedArguments);
} catch (UnsupportedOperationException e) {
try {
return PolyglotFunctionProxyHandler.invokeDefault(this, proxy, method, resolvedArguments);
} catch (Exception innerE) {
e.addSuppressed(innerE);
throw e;
}
}
} |
so that sounds like we should be able to fix this issue in Enso, because it's not a Graal issue, right? :) That sounds nice |
Jaroslav Tulach reports a new STANDUP for yesterday (2023-08-02): Progress: - Investigating
Next Day: Benchmarking |
Jaroslav Tulach reports a new STANDUP for yesterday (2023-08-03): Progress: -
Next Day: Finish toString() & other bugfixing
|
Jaroslav Tulach reports a new STANDUP for yesterday (2023-08-04): Progress: - Investigating
Next Day: Finish toString() |
Jaroslav Tulach reports a new 🔴 DELAY for yesterday (2023-08-06): Summary: There is 7 days delay in implementation of the Calling Got additional requests to fix Delay Cause: Additional fixes were needed. More than originally estimated. Possible solutions: Working over weekend fixed all the issues (review pending). |
1 similar comment
Jaroslav Tulach reports a new 🔴 DELAY for yesterday (2023-08-06): Summary: There is 7 days delay in implementation of the Calling Got additional requests to fix Delay Cause: Additional fixes were needed. More than originally estimated. Possible solutions: Working over weekend fixed all the issues (review pending). |
Jaroslav Tulach reports a new STANDUP for yesterday (2023-08-06): Progress: -
Next Day: EnsoContext & other bugfixes |
Jaroslav Tulach reports a new STANDUP for yesterday (2023-08-07): Progress: - demo & other meetings It should be finished by 2023-08-18. Next Day: EnsoContext & other bugfixes |
Sometimes when passing Enso objects to Java, we can make them implement some interface by ensuring that the Enso object has all methods of that interface. This makes it easier to interact with Enso objects on the Java side (once can just use the interface instead of Polyglot methods).
It seems that
toString
which is expected from all Java objects is not picked up properly.I'm not exactly sure if this is a bug in Enso or Graal itself.
Repro
Let's create a file
Foo.java
:and then put it in a polyglot project, with
src/Main.enso
being:Actual behaviour
The project as described above, when run yields:
Expected behaviour
The program should execute without errors and yield:
The
toString
call on the Proxy object should delegate to theto_text
method of the Enso object. As we can see, if we pass it as anObject
that correctly happens. But if we pass it as this 'interface proxy' - that fails.The text was updated successfully, but these errors were encountered: