请在 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 访问器注解声明...

1 答案

0

编辑

您似乎在调用设置器,Lombok 访问器只定义了获取器

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 的静态内部类)它确实有设置器。反射器似乎可以找到它

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"]]
...