Java Magazine, July/August 2018
ORACLE COM JAVAMAGAZINE JULY AUGUST 2018 55 libraries Dependencies on unresolved Java EE modules Historically the JDK contained a few APIs that belonged to Java EE for example JavaBeans Activation Framework JAF JTA JAXB JAX WS and CORBA To more clearly separate Java SE and Java EE and in preparation for Java EEs move away from Oracles aegis these APIs were deprecated in Java 9 and will be removed in Java 11 If your library depends on these APIs being present in the JDK you will get errors like this when building your code on Java 9 or later releases error package javax xml bind is not visible import javax xml bind JAXBException package javax xml bind is declared in module java xml bind which is not in the module graph 1 error Although it is possible to fix the error with the command line flag add modules that will help you only until Java 11 The long term solution is to pick an implementation of the API you need and add it as a regular dependency Failing casts to URLClassLoader Some libraries interact with the class path for example to examine its content or add additional JAR files They often do that by casting the system class loader to URLClassLoader because it has the needed methods But Java 9 changed the classloading strategy and it uses a diferent class loader Therefore such casts will fail with an error similar to this Exception in thread main java lang ClassCastException java base jdk internal loader ClassLoaders AppClassLoader cannot be cast to java base java net URLClassLoader at monitor Main logClassPathContent Main java 46 at monitor Main main Main java 28 The solution depends on what exactly you want to do with the class loader including the following
You must have JavaScript enabled to view digital editions.