clj-easy / graal-docs

Scripts and tips to get Clojure latest working with GraalVM latest
Eclipse Public License 1.0
387 stars 20 forks source link

Repro of JDK11 issue with clojure.lang.Reflector #32

Closed borkdude closed 3 years ago

borkdude commented 4 years ago

Dump from Slack. This repro is based on the same steps as the repro for CLJ-1472. If Cognitect / Clojure is interested in a repro, I'll process this into a proper readable doc. cc @puredanger

12:18 AM borkdude I have a repro for the clojure.lang.Reflector issue on JDK11: (ns spec-test.core (:gen-class) (:import [clojure.lang Reflector]) (:require [clojure.java.io :as io])) (defn -main [& _args] (println clojure-version) (println (System/getProperty "java.version")) (println (System/getProperty "java.vm.version")) (println (Reflector/invokeInstanceMethod (io/file ".") "exists" (object-array [])))) reflection.json: [{ "name" : "java.io.File", "allPublicMethods" : true, "allPublicFields" : true, "allPublicConstructors" : true }] With 20.0.0 java8: $ ./spec-test {:major 1, :minor 10, :incremental 1, :qualifier patch_38bafca9_clj_1472_5} 1.8.0_242 GraalVM 20.0.0 CE true With 20.0.0 java11: $ ./spec-test {:major 1, :minor 10, :incremental 1, :qualifier patch_38bafca9_clj_1472_5} 11.0.6 GraalVM 20.0.0 CE Exception in thread "main" com.oracle.svm.core.jdk.UnsupportedFeatureError: Invoke with MethodHandle argument could not be reduced to at most a single call or single field access. The method handle must be a compile time constant, e.g., be loaded from a static final field. Method that contains the method handle invocation: java.lang.invoke.Invokers$Holder.invoke_MT(Object, Object, Object, Object) at com.oracle.svm.core.util.VMError.unsupportedFeature(VMError.java:101) at clojure.lang.Reflector.canAccess(Reflector.java:49) (edited) 12:20 AM So I've been able to work around that like here: https://github.com/lread/clj-graal-docs#jdk11-and-clojurelangreflector (edited) 12:20 AM Let me know if you want an issue for it.