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 3 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

@Avery-Dunn do you find time to have a look at this? Would be very much appreciated

HerrDerb avatar Oct 06 '25 09:10 HerrDerb

Sorry for the delay, I just merged in your PR. We don't have an ETA for the release as there are some other small changes we want to get in, but I'll update this thread once it's out.

Avery-Dunn avatar Oct 07 '25 15:10 Avery-Dunn

@Avery-Dunn all good 🙂 Thank you very much 👍

HerrDerb avatar Oct 07 '25 15:10 HerrDerb

Close as merged

HerrDerb avatar Nov 20 '25 14:11 HerrDerb