- edited description
ZonedDateTime not supported
Hi,
I use the nimbus-jose-jwt
library v8.19.
It seems I can’t use ZonedDateTime objects for the claims of a JWT. Example:
import com.nimbusds.jwt.JWT;
import com.nimbusds.jwt.JWTClaimsSet;
import com.nimbusds.jwt.PlainJWT;
import java.time.ZonedDateTime;
public class Test {
public static void main(String... args) {
final JWTClaimsSet.Builder builder = new JWTClaimsSet.Builder();
builder.claim("key", ZonedDateTime.now());
JWTClaimsSet claims = builder.build();
JWT jwt = new PlainJWT(claims);
System.out.println(jwt.serialize());
}
}
It throws the following exception:
Exception in thread "main" java.lang.IllegalAccessError: class net.minidev.asm.java.time.ZonedDateTimeAccAccess tried to access private field java.time.ZonedDateTime.offset (net.minidev.asm.java.time.ZonedDateTimeAccAccess is in unnamed module of loader net.minidev.asm.DynamicClassLoader @9660f4e; java.time.ZonedDateTime is in module java.base of loader 'bootstrap')
at net.minidev.asm.java.time.ZonedDateTimeAccAccess.get(Unknown Source)
at net.minidev.json.reader.BeansWriterASM.writeJSONString(BeansWriterASM.java:21)
at net.minidev.json.JSONValue.writeJSONString(JSONValue.java:586)
Am I missing something?
Thanks.
Best regards,
Jérôme
Comments (7)
-
reporter -
Hi Jerome,
According to the JavaDocs the ZonedDateTime class is from Java 8 and at present the lib is set to Java 7 level.
https://docs.oracle.com/javase/8/docs/api/java/time/ZonedDateTime.html
-
Making this a feature for a future release which upgrades to Java 8+
-
reporter Thanks for the feedback. When the upgrade to Java 8 will be available?
-
Hi!
No concrete plans for Java 8 yet, we have just this and several other tickets to take advantage of new classes and features in Java 8.
Do you reckon you can work around this?
The next major release (complete, waiting to be merged) will be removing the JSON smart dependency, by shading it.
-
reporter Sure. We can deal with that, turning ZoneDameTime into the old Date object for example.
-
Issue
#437was marked as a duplicate of this issue. - Log in to comment