The resources are mainly images and XML files, located in separate packages. By adding the opens clause it works fine for Class B (called from module a) - however, it does not work for Class A (returns null). I wonder if this is the intended behavior?

-Wolfgang


Looks like I'm having an encapsulation issue with resources. Class B belongs to module b and extends Class A in module a. Class B provides resources which should be loaded from base class A.

However, calling

  getInstance().getClass().getResource(...)

from a static method in class A fails while calling from class B works fine. Because getInstance() returns Class B I wonder why the resource can't be loaded. Any recommendation on how to get this working?
The details are in the javadoc but in summary:

Code in `b` can locate any resource in `b`.

Code in `a` can any locate any ".class" resource in `b`. It can also locate any resources in "non-package" locations such as META-INF/**. Resources that are located in b's packages are encapsulated and so `b` needs to `opens <package> to a` to allow code in module `a` to locate the resources.

-Alan.





Reply via email to