UnsupportedOperationException was thrown when serializing a Throwable variable using XStream

59 Views Asked by At

When I tried using XStream 1.4.9 to serialize an IllegalArgumentException type variable, there is a java.lang.UnsupportedOperationException.

Below is the stack trace information. I have no idea what this could mean. Information from online is limited.

java.lang.UnsupportedOperationException: Not supported. Pass in the cause using the constructors instead.
    at com.oracle.truffle.api.exception.AbstractTruffleException.initCause(AbstractTruffleException.java:413)
    at com.thoughtworks.xstream.converters.extended.ThrowableConverter.marshal(ThrowableConverter.java:56)
    at com.thoughtworks.xstream.core.AbstractReferenceMarshaller.convert(AbstractReferenceMarshaller.java:68)
        try {
            final ScriptEngine scriptEngine = new ScriptEngineManager()
                    .getEngineByName("JavaScript");

            Objects.toString(scriptEngine.eval("X"), null);
        } catch (Exception e) {
            XStream xstream = new XStream();
            System.err.println(xstream.toXML(e));
        }

This is a minimum example that I see. I realize that whenever I used js-scriptengine dependency, XStream fails to serialize it, while removing such dependency, everything works

1

There are 1 best solutions below

0
a stand-out flamingo On

I think it's due to Graalvm's implementation of "javax.script.ScriptEngine" class, which are not implemented as what jdk has implemented. Removing Graalvm dependency, everything works fine.