microsoft-authentication-library-for-java icon indicating copy to clipboard operation
microsoft-authentication-library-for-java copied to clipboard

Use `java.nio.charset.StandardCharsets` instead of `com.nimbusds.jose.util.StandardCharset` in persistence msal4extensions

Open HerrDerb opened this issue 2 months ago • 3 comments

In the persitence msal4extensions, a unusual StandardCharset is used instead of the default java.nio. This causes issues e.g. during native build.

Error: Discovered unresolved type during parsing: com.nimbusds.jose.util.StandardCharset. This error is reported at image build time because class com.microsoft.aad.msal4jextensions.PersistenceTokenCacheAccessAspect is registered for linking at image build time by command line and command line.
Error encountered while parsing com.microsoft.aad.msal4jextensions.PersistenceTokenCacheAccessAspect.afterCacheAccess(PersistenceTokenCacheAccessAspect.java:143) 

There seems no reason to use com.nimbusds.jose.util.StandardCharset over java.nio. Therefor the import should be changed to avoid dependency issues.

https://github.com/AzureAD/microsoft-authentication-library-for-java/blob/b6f54ca13957b8d9e20823bf5c776de543518fa7/msal4j-persistence-extension/src/main/java/com/microsoft/aad/msal4jextensions/PersistenceTokenCacheAccessAspect.java#L127C84-L127C99

Current workaround is to provide a stupid implementation with the same classpath for native build:

package com.nimbusds.jose.util;

import java.nio.charset.Charset;
import java.nio.charset.StandardCharsets;

public class StandardCharset {

    public static Charset UTF_8 = StandardCharsets.UTF_8;
}

HerrDerb avatar Sep 29 '25 08:09 HerrDerb