To make my question more clear, consider following use-case: Suppose there is a package that permits a set of operations on a given platform, for example a class to edit the registry on Windows. This package does not exist on other platforms, as there is no equivalent operation on other operating system. For the sake of simplicity, consider windows/Registry.java and
Tag: classloader
Why are log4j classes loaded by two class loaders?
I have a maven project for an application, which I run in a WildFly server. The project has log4j dependencies: I would like to get the LoggerContext like this: However, this results in ClassCastException: After some debugging, I have discovered that the problem is that the class LoggerContext is loaded via two different classloaders. How could this be possible? At
Java: Reading from getResourceAsStream gets too many bytes
I’m trying to read a binary file, using getResourceAsStream. The problem is I get too many bytes back. The file is 56374 bytes long, according to ls, but when I read it in my code, I consistently get 85194 bytes. I get the same result with similar code: If I run the code without the resource, everything is fine, I
How do I give Drools access to dynamically loaded classes?
I am trying to use a ClassLoader to load classes from .class files at runtime and use them in Drools rules (Drools 7.52.0). I am using this custom ClassLoader which reads from a file and uses ClassLoader.defineClass() to load a class. It’s similar to a URLClassLoader: I can use the ClassLoader to load a class, construct an instance, and access
Resource won’t load when exported as a JAR
Using the following code to set a system property: ClassLoader classLoader = StartMain.class.getClassLoader(); URL resource = classLoader.getResource(“com/myname/lib/chromedriver/…
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 …
How does ServiceLoader.load work with class loaders in JPMS?
I have two JPMS layers: Boot layer with module A loaded by ClassLoaders$AppClassLoader@4fca772d Child layer with module B that provides cervices and loaded by Loader@6b58b9e9 The parent classloader …
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 …