You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I have created an Ant XJC task and I am using jaxb-xjc-4.0.4. While building I am seeing below error:
java.lang.ClassCastException: class jdk.internal.loader.ClassLoaders$AppClassLoader cannot be cast to class java.io.Closeable (jdk.internal.loader.ClassLoaders$AppClassLoader and java.io.Closeable are in module java.base of loader 'bootstrap')
The text was updated successfully, but these errors were encountered:
I have this happening with ant 1.10.12 and jaxb-ri 4.0.3. Looking at ProtectedTask class, it seems that it tries to close classloader without checking that classloader implements Closeable.
The problem is that on line 89 'cl' is cast to 'Closeable' without checking whether it is an instance of 'Closeable' or not. In JDK8, classloaders were invariably a type of URLClassLoader, which is 'Closeable', but in JDK9+ this is no longer a valid assumption, causing a ClassCastException at line 89.
This issue affects anyone using the XJC task in Apache Ant who is trying to move from JDK8 to JDK9+. The fix is to change the lines 87-89 from
I'm personally held up on a project by this issue, so would be enormously grateful to see this fix released. Thanks very much in advance for your help.
I have created an Ant XJC task and I am using jaxb-xjc-4.0.4. While building I am seeing below error:
java.lang.ClassCastException: class jdk.internal.loader.ClassLoaders$AppClassLoader cannot be cast to class java.io.Closeable (jdk.internal.loader.ClassLoaders$AppClassLoader and java.io.Closeable are in module java.base of loader 'bootstrap')
The text was updated successfully, but these errors were encountered: