Hi,

On Thu, Nov 5, 2015 at 1:33 AM, Alan Bateman <alan.bate...@oracle.com>
wrote:

>
>
> On 04/11/2015 16:26, Ali Ebrahimi wrote:
>
> :
>
> Yes, I got it. But should not upper level descriptors win over lower
> descriptors regards to current configuration.
> What I missed here?
>
> (Changing the subject line so that it's clearer what this discussion is
> about).
>
> In your implied readability mail then I think you have:
>
> configuration1/layer1:
>   com.bar@1
>   com.baz requires public com.bar
>
> configuration2:
>   com.bar@2
>   com.foo requires com.baz
>
> The readability graph for configuration2 is:
>
>   com.bar@2 requires java.base
>   com.foo reads java.base
>   com.foo reads com.baz
>   com.foo reads com.bar@1
>
> Instantiating this configuration (as a layer) means locating the
> jlr.Module for com.bar@1. For now, and it's temporary, it is found by
> matching the ModuleDescriptor starting in the configuration and working
> through the stack of layers. I say temporary because we need an API change
> to expose the layer of the source module. That will eliminate the search
> and will fix the corner case that arises when modules in different layers
> have equal ModuleDescriptor objects. We'll get to this soon.
>

So you say com.bar@2 does not override com.bar@1 in layer2 and types will
be loaded from com.bar@1 in layer2 for com.foo?
This is changed from yesterday?
I now get
bar1
bar1
instead of
bar1
bar2
for my yesterday sample code. quite supersizing!

Second, what can you say for this test case:

public static void testLayerWithRequiresPublic4() {

    // cf1: m1 and m2@1, m1 requires public m2

    ModuleDescriptor descriptor1
            = new ModuleDescriptor.Builder("m1")
            .requires(ModuleDescriptor.Requires.Modifier.PUBLIC, "m2")
            .build();

    ModuleDescriptor descriptor2_v1
            = new ModuleDescriptor.Builder("m2")
            .version("1")
            .build();

    ModuleFinder finder1 = ModuleUtils.finderOf(descriptor1, descriptor2_v1);

    Configuration cf1
            = Configuration.resolve(finder1, boot(),
ModuleFinder.empty(), "m1");

    ClassLoader cl1 = new ClassLoader() { };
    Layer layer1 = Layer.create(cf1, mn -> cl1);


    // cf2: m3 and m2@2, m3 requires m1

    ModuleDescriptor descriptor2_v2
            = new ModuleDescriptor.Builder("m2")
            .version("2")
            .build();

    ModuleDescriptor descriptor3
            = new ModuleDescriptor.Builder("m3")
            .requires("m1")
            .build();

    ModuleFinder finder2 = ModuleUtils.finderOf(descriptor2_v2, descriptor3);

    Configuration cf2
            = Configuration.resolve(finder2, layer1,
ModuleFinder.empty(), "m3");

    ClassLoader cl2 = new ClassLoader() { };
    Layer layer2 = Layer.create(cf2, mn -> cl2);


    Module m1 = layer1.findModule("m1").get();
    Module m2_v1 = layer1.findModule("m2").get();
    Module m2_v2 = layer2.findModule("m2").get();
    Module m3 = layer2.findModule("m3").get();

    assertTrue(m2_v2.getLayer() == layer2);
    assertFalse(m1.canRead(m2_v2));
    assertFalse(m2_v1.canRead(m2_v2));
    assertFalse(m2_v2.canRead(m2_v1));
    assertFalse(m3.canRead(m2_v2));
}




-- 

Best Regards,
Ali Ebrahimi

Reply via email to