Can't call public method of non-public class: public (Google gcloud library)

前端 未结 4 951
没有蜡笔的小新
没有蜡笔的小新 2021-01-06 13:46

I am attempting to use the gcloud library.

(ns firengine.state
  (:import
   [com.google.cloud AuthCredentials]
   [com.google.cloud.datastore DatastoreOpti         


        
4条回答
  •  清歌不尽
    2021-01-06 14:42

    so, i am a complete Clojure noob and ran into a similar error using Caffeine Cache: "IllegalArgumentException Can't call public method of non-public class: public default void com.github.benmanes.caffeine.cache.LocalManualCache.put(java.lang.Object,java.lang.Object) clojure.lang.Reflector.invokeMatchingMethod (Reflector.java:88)"

    my original function signature was this:

    (defn get
      [cache key]
      (.getIfPresent cache key)
      )
    

    and i think the issue is that Clojure could not figure out where to apply Cache's .getIfPresent function. Adding the type fixed it:

    (defn get
      [^Cache cache key]
      (.getIfPresent cache key)
      )
    

    Even though it's not a direct answer and your question went over my head, I hope this helps.

提交回复
热议问题