2024 Clojure状态调查中分享您的想法!

欢迎!请参阅关于页面以获取更多关于此功能的信息。

+1 投票
Clojure

repro.clj

(defn create-application []
  (let [credential (com.microsoft.aad.msal4j.ClientCredentialFactory/createFromSecret "sekrit")
        builder (com.microsoft.aad.msal4j.ConfidentialClientApplication/builder "client id" credential)
        authority "some authority"]
    (->
      builder
      (.authority ^String authority)
      (.build))))

(create-application)

运行

clj -Sdeps '{:deps {com.microsoft.azure/msal4j {:mvn/version "1.8.1"}}}' repro.clj

实现类源代码在https://github.com/AzureAD/microsoft-authentication-library-for-java/blob/dev/src/main/java/com/microsoft/aad/msal4j/ConfidentialClientApplication.java

而基类在https://github.com/AzureAD/microsoft-authentication-library-for-java/blob/dev/src/main/java/com/microsoft/aad/msal4j/AbstractClientApplicationBase.java,其中权限字段使用Lombok Accessor注解声明...

1 答案

0 投票

编辑

您看起来在调用setter,但Lombok accessor只定义了getter

user=> (for [m (.getMethods com.microsoft.aad.msal4j.AbstractClientApplicationBase) :when (= (.getName m) "authority")] m)
(#object[java.lang.reflect.Method 0x6136998b "public java.lang.String com.microsoft.aad.msal4j.AbstractClientApplicationBase.authority()"])

user=> (for [m (.getMethods com.microsoft.aad.msal4j.ConfidentialClientApplication) :when (= (.getName m) "authority")] m)
(#object[java.lang.reflect.Method 0x676ff3b0 "public java.lang.String com.microsoft.aad.msal4j.ConfidentialClientApplication.authority()"])

编辑

我的错误,当然您实际上使用的是builder(一个名为Builder的静态内部类),它有一个setter。反射器似乎找到了它

user=> (clojure.lang.Reflector/getMethods com.microsoft.aad.msal4j.ConfidentialClientApplication$Builder 1 "authority" false)
[#object[java.lang.reflect.Method 0x6b760460 "public com.microsoft.aad.msal4j.AbstractClientApplicationBase$Builder com.microsoft.aad.msal4j.AbstractClientApplicationBase$Builder.authority(java.lang.String) throws java.net.MalformedURLException"]]
...