如何解决类java.util.Collections$SingletonList不能强制转换为类java.lang.String?

kb5ga3dv  于 2023-04-10  发布在  Java
关注(0)|答案(1)|浏览(384)

我已经将项目-https://github.com/Microsoft/Partner-Center-Java-Samples/tree/master/secure-app-model/keyvault从GIT克隆到本地Eclipse。
当我在本地服务器上运行partnerconsent项目时,我收到以下异常:
类java.util.Collections$SingletonList不能强制转换为类java.lang.String(java.util.Collections$SingletonList和java.lang.String在加载程序“bootstrap”的模块java.base中)

栈迹

java.lang.ClassCastException: class java.util.Collections$SingletonList cannot be cast to class java.lang.String (java.util.Collections$SingletonList and java.lang.String are in module java.base of loader 'bootstrap')
    at com.nimbusds.oauth2.sdk.util.URLUtils.serializeParameters(URLUtils.java:103)
    at com.microsoft.aad.adal4j.AdalTokenRequest.toOAuthRequest(AdalTokenRequest.java:160)
    at com.microsoft.aad.adal4j.AdalTokenRequest.executeOAuthRequestAndProcessResponse(AdalTokenRequest.java:86)
    at com.microsoft.aad.adal4j.AuthenticationContext.acquireTokenCommon(AuthenticationContext.java:930)
    at com.microsoft.aad.adal4j.AcquireTokenCallable.execute(AcquireTokenCallable.java:70)
    at com.microsoft.aad.adal4j.AcquireTokenCallable.execute(AcquireTokenCallable.java:38)
    at com.microsoft.aad.adal4j.AdalCallable.call(AdalCallable.java:47)
    at java.base/java.util.concurrent.FutureTask.run(FutureTask.java:264)
    at java.base/java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1136)
    at java.base/java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:635)
    at java.base/java.lang.Thread.run(Thread.java:833)
sauutmhj

sauutmhj1#

java

string str = "A"; // No space character.
(string) str.split(" "); // Error
(ArrayList<string>) str.split(" "); // Error
(List<string>) str.split(" "); // No Error

Kotlin

val str = "A" // No space character.
str.split(" ") as String // Error
str.split(" ") as ArrayList<String> // Error
str.split(" ") as List<String> // No Error

相关问题