Re: How to load resources from base module

2017-05-22 Thread Alan Bateman
On 22/05/2017 09:05, wzberger wrote: ClassA acts as a kind of resource loader and only the resource string is passed - is it possible to include the module name in the resource string something like "module!resource"? The module name isn't unique either. Can you say a bit more about ClassA?

Re: How to load resources from base module

2017-05-22 Thread wzberger
ClassA acts as a kind of resource loader and only the resource string is passed - is it possible to include the module name in the resource string something like "module!resource"? -Wolfgang Am 22.05.2017 um 09:55 schrieb Alan Bateman: On 22/05/2017 08:45, wzberger wrote: Hm, so how can

Re: How to load resources from base module

2017-05-22 Thread Alan Bateman
On 22/05/2017 08:45, wzberger wrote: Hm, so how can ClassA access the resource from module com.b directly - without having a class instance of module b? Does the code in ClassA have any context to work this? How does it know the resource is in com.b? The APIs allow you to locate a resource in

Re: How to load resources from base module

2017-05-22 Thread wzberger
Hm, so how can ClassA access the resource from module com.b directly - without having a class instance of module b? -Wolfgang On 18/05/2017 08:16, wzberger wrote: : public class ClassA{ public ClassA() { //success

Re: How to load resources from base module

2017-05-18 Thread Peter Levart
Hi Wolfgang, You are using instance method Class#getResource(String) which states in javadoc: /If this class is in a named Module then this method will attempt to find the resource *in the module*./ "this class" is the class represented by the Class object which is the receiver of the

Re: How to load resources from base module

2017-05-18 Thread Alan Bateman
On 18/05/2017 08:16, wzberger wrote: : public class ClassA{ public ClassA() { //success System.out.println(getClass().getResource("/com/b/resources/test.txt")); The test creates an instance of ClassB (extends ClassA) and so getClass() returns ClassB here, not ClassA. So when

Re: How to load resources from base module

2017-05-18 Thread wzberger
Here is a simple example which demonstrates the issue - still something missing? // MODULE A module com.a { exports com.a; } package com.a; public class ClassA{ public ClassA() { //success System.out.println(getClass().getResource("/com/b/resources/test.txt")); //fail

Re: How to load resources from base module

2017-05-17 Thread Alan Bateman
On 17/05/2017 18:22, wzberger wrote: 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? I'm

Re: How to load resources from base module

2017-05-17 Thread wzberger
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

Re: How to load resources from base module

2017-05-17 Thread Alan Bateman
On 17/05/2017 10:54, wzberger wrote: 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(...)

How to load resources from base module

2017-05-17 Thread wzberger
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