Skip to content

Tag: classloader

How to load a class from module(.jmod) file at runtime?

I want to load classes from a module (.jmod) file at runtime into the application memory. I know that we can easily load classes from a (.jar) file using 🙂 The total code snippet can be found at this-repo in src omega.deassembler.JarLoader class But the problem is URLClassLoader is unable to read the modules(…

Quarkus classLoader conflicts

I am facing an error while trying to build my quarkus app. It seems to be related to the fact that there are two class loaders that have different class objects for javax/xml/namespace/QName as it is noticed in this part of the stack-trace : Caused by: java.lang.LinkageError: loader constraint violation: when…

How to avoid “Sharing is only supported for boot loader classes because bootstrap classpath has been appended” warning during debug with Java 11?

Recently I switched to the Java 11 and start to debug my app and saw this message: OpenJDK 64-Bit Server VM warning: Sharing is only supported for boot loader classes because bootstrap classpath has been appended Found only this commit and ticket, but it doesn’t tell me much. Do I need to worry about it…

Classloaders hierarchy in Java 9

As of Java 8, I know the hierarchy of the classloaders has been as follows: Bootstrap classloader → Extension classloader → Application classloader What is the change in the hierarchy of classloaders in Java 9 and how does it work? Answer The ClassLoader as revised in Java-9 states that: The Java run-time has…

What happens if import statements can not be resolved?

I am not clear on the following: A class is loaded by JVM when needed, like lazy initialization, right? Now if class A does an import of class B which class B actually is not in the file system (e.g. B.class was deleted or not delivered or any reason) then does class A get loaded and runs if no method