graalvm

Discuss GraalVM related topics. Use clojure 1.10.2 or newer for all new projects. Contribute to https://github.com/clj-easy/graal-docs and https://github.com/BrunoBonacci/graalvm-clojure. GraalVM slack: https://www.graalvm.org/slack-invitation/.
borkdude 2020-03-04T08:35:43.213400Z

> MethodHandles are currently not supported in native-image. This has been documented in https://github.com/oracle/graal/blob/master/substratevm/LIMITATIONS.md#invokedynamic-bytecode-and-method-handles. We are however looking to address this issue in the future From https://github.com/oracle/graal/issues/2214

ghadi 2020-03-04T19:23:43.216800Z

@borkdude it can't see through the isJava8() predicate and determine which MH is chosen in Reflector.java

borkdude 2020-03-04T19:24:32.217900Z

yeah

ghadi 2020-03-04T19:24:39.218Z

I'm no longer convinced that code in Reflector is accurate enough. There are some warnings it fails to catch.

ghadi 2020-03-04T19:24:55.218400Z

(the canAccess() logic)

borkdude 2020-03-04T19:25:19.218800Z

do we really care about the module system from a clojure perspective?

ghadi 2020-03-04T19:25:39.219100Z

it's not about caring about module system

ghadi 2020-03-04T19:25:48.219400Z

it's about the module system changed visibility rules

ghadi 2020-03-04T19:26:07.219900Z

and we have to be sensitive to them -- otherwise IllegalAccess

borkdude 2020-03-04T19:26:30.220600Z

why is catching it in Reflector.java better than IllegalAccess?

ghadi 2020-03-04T19:26:44.221Z

public class in the module system is only public if its package is exported by the module

ghadi 2020-03-04T19:27:02.221300Z

whereas on java8 public class is... public

ghadi 2020-03-04T19:27:56.222100Z

the Reflector shouldn't select/link methods it cannot call

borkdude 2020-03-04T19:28:38.222700Z

Java / JVM itself will give an error about this. Why not let it crash there?

ghadi 2020-03-04T19:29:01.223200Z

because there often is a public method you can call

ghadi 2020-03-04T19:30:03.224700Z

scenario: public class Impl in a non-exported package, with a method foo() that it implements from public exported interface IFoo

ghadi 2020-03-04T19:30:48.225700Z

if the Reflector selects Impl.foo() it is wrong, it needs to walk up the class hierarchy to find the IFoo.foo() method

borkdude 2020-03-04T19:30:57.226100Z

ah right.

borkdude 2020-03-04T19:31:04.226400Z

get it now

ghadi 2020-03-04T19:31:22.227100Z

groovy does this:

ghadi 2020-03-04T19:32:04.228600Z

which is more correct IMHO, but they also dynamically load the class containing that method

borkdude 2020-03-04T19:32:11.228800Z

For sci I've made a slight variation of clojure.lang.Reflector packaged as a library (for internal use). I've made two releases of this library: one for jdk8 and one for jdk11 so they can both work with GraalVM. That could be one approach of dealing with JVM-specific things.

borkdude 2020-03-04T19:32:56.229100Z

I'm not sure how the rest of the Java world deals with these problems

borkdude 2020-03-04T19:33:26.229400Z

thanks for sharing the Groovy example

borkdude 2020-03-04T19:37:49.230400Z

@ghadi How does Groovy deal with Java8/Java11 compatibility?

ghadi 2020-03-04T19:38:05.230600Z

¯\(ツ)

ghadi 2020-03-04T19:38:34.231300Z

if i were to make something up, I'd guess that they do Java8 baseline and don't depend on anything above that

ghadi 2020-03-04T19:39:03.231900Z

that class above ^ is in a directory called "vmplugin/v9" which appears to be conditionally loaded

borkdude 2020-03-04T19:46:08.232300Z

( btw thanks for the latest Cognicast, enjoyed listening to it today )

1➕
ghadi 2020-03-04T19:52:06.232600Z

cool thanks! lvh is a hoot