From pavelturk2000 at gmail.com Mon Sep 2 08:19:48 2024 From: pavelturk2000 at gmail.com (PavelTurk) Date: Mon, 2 Sep 2024 11:19:48 +0300 Subject: JDK-8322302 Message-ID: <39b8bdf2-0e8d-42e2-a62e-69763e4a9a5a@gmail.com> Hello everyone, I have a question about https://bugs.openjdk.org/browse/JDK-8322302 Can someone let us know approximately when this bug will be fixed? It is causing us a lot of problems, and having an estimated timeline would help us develop the right strategy. Best regards, Pavel From alan.bateman at oracle.com Mon Sep 2 08:44:33 2024 From: alan.bateman at oracle.com (Alan Bateman) Date: Mon, 2 Sep 2024 09:44:33 +0100 Subject: JDK-8322302 In-Reply-To: <39b8bdf2-0e8d-42e2-a62e-69763e4a9a5a@gmail.com> References: <39b8bdf2-0e8d-42e2-a62e-69763e4a9a5a@gmail.com> Message-ID: On 02/09/2024 09:19, PavelTurk wrote: > Hello everyone, > > I have a question about https://bugs.openjdk.org/browse/JDK-8322302 > > Can someone let us know approximately when this bug will be fixed? It > is causing us a lot > of problems, and having an estimated timeline would help us develop > the right strategy. No ETA on this. There is some design work required to decide how readability should work with automatic modules in child layers. There are trade-offs to consider on the question as to whether a module in a child layer can depend on (and thus read) an automatic module in a parent layer. -Alan From pavelturk2000 at gmail.com Sun Sep 8 07:59:57 2024 From: pavelturk2000 at gmail.com (PavelTurk) Date: Sun, 8 Sep 2024 10:59:57 +0300 Subject: It is safe to use same classes from same modules in different layers Message-ID: <5fd8c9ee-3935-48cd-8946-60e5d000b4dc@gmail.com> Hello everyone, Lets consider the following situation: Bootlayer (module Core) is a main application - child layer A (module A, module Foo) is a plugin A - child layer B (module B, module Foo) is a plugin B. So, the SAME module Foo (with class Foo) is used in two different child layers. Module Core provides this service { ?????? Object getInterPluginObject(); ?????? void setInterPluginObject(Object obj); } So, in plugin A I do var foo = new Foo(); coreService.setInterPluginObject(foo); and in plugin B I do var foo = (Foo) coreService.getInterPluginObject(); Could anyone say if it should work, and if yes, then how safe this approach is? Please note, that module Foo CAN NOT be added to bootlayer because main application shouldn't know anything about it. The reason of this question is that I try to find the best solution for inter plugin work where every plugin is a child layer of the bootlayer. Maybe there are other ways to do it? Best regards, Pavel From johannes.spangenberg at hotmail.de Sun Sep 8 19:37:48 2024 From: johannes.spangenberg at hotmail.de (Johannes Spangenberg) Date: Sun, 8 Sep 2024 21:37:48 +0200 Subject: It is safe to use same classes from same modules in different layers In-Reply-To: <5fd8c9ee-3935-48cd-8946-60e5d000b4dc@gmail.com> References: <5fd8c9ee-3935-48cd-8946-60e5d000b4dc@gmail.com> Message-ID: > Lets consider the following situation: > > Bootlayer (module Core) is a main application > - child layer A (module A, module Foo) is a plugin A > - child layer B (module B, module Foo) is a plugin B. If I understand you correctly, you would add module Foo to the module path of both child layers? In this case, both layers would have access to a class called Foo, but it would not be the same class in both layers. This makes sense if you consider that both layers might just as well depend on two different versions of module Foo, so they cannot share the same loaded classes. As a result, your code would run into a ClassCastException. > and in plugin B I do > var foo = (Foo) coreService.getInterPluginObject(); However, note that the JPMS is not limited to a single parent layer. You could add a separate layer containing Foo, which could be an additional parent for both, layer A and B. Depending on your context, plugin B may also declare a dependency on plugin A, and therefore get child layer A as a parent. I don't think that I can give you a proper recommendation as I don't know much about your project. (Also not that I am NOT affiliated with the OpenJDK project, I am just a fellow subscriber to this mailing list.) From pavelturk2000 at gmail.com Mon Sep 9 07:30:43 2024 From: pavelturk2000 at gmail.com (PavelTurk) Date: Mon, 9 Sep 2024 10:30:43 +0300 Subject: It is safe to use same classes from same modules in different layers In-Reply-To: References: <5fd8c9ee-3935-48cd-8946-60e5d000b4dc@gmail.com> Message-ID: > However, note that the JPMS is not limited to a single parent layer. You could add a separate layer containing Foo, which could be an additional parent for both, layer A and B. Depending on your context, plugin B may also declare a dependency on plugin A, and therefore get child layer A as a parent. I don't think that I can give you a proper recommendation as I don't know much about your project. (Also not that I am NOT affiliated with the OpenJDK project, I am just a fellow subscriber to this mailing list.) > Yes, it is possible to add different parent layers in JPMS, however, it is not a real solution for? a real application with plugins. Why? Because plugins can be added by user dynamically, for example, he can activate only plugin A, or only plugin B. Or he can activate firstly plugin B and only after activate plugin A. So, JPMS is great, but how to solve such problem in real application with plugins? Or is JPMS not supposed to be used with plugins? Best regards, Pavel From alan.bateman at oracle.com Mon Sep 9 07:35:54 2024 From: alan.bateman at oracle.com (Alan Bateman) Date: Mon, 9 Sep 2024 08:35:54 +0100 Subject: It is safe to use same classes from same modules in different layers In-Reply-To: <5fd8c9ee-3935-48cd-8946-60e5d000b4dc@gmail.com> References: <5fd8c9ee-3935-48cd-8946-60e5d000b4dc@gmail.com> Message-ID: On 08/09/2024 08:59, PavelTurk wrote: > Hello everyone, > > Lets consider the following situation: > > Bootlayer (module Core) is a main application > - child layer A (module A, module Foo) is a plugin A > - child layer B (module B, module Foo) is a plugin B. > > So, the SAME module Foo (with class Foo) is used in two different > child layers. > > Module Core provides this service { > ?????? Object getInterPluginObject(); > ?????? void setInterPluginObject(Object obj); > } > > So, in plugin A I do > var foo = new Foo(); > coreService.setInterPluginObject(foo); > > and in plugin B I do > var foo = (Foo) coreService.getInterPluginObject(); > > Could anyone say if it should work, and if yes, then how safe this > approach is? > Please note, that module Foo CAN NOT be added to bootlayer because main > application shouldn't know anything about it. I assume this arrangement will fail with ClassCastException as B can't cast a A-Foo to a B-Foo. If Core wants to provides a system-wide registry (which I think is what you are doing here) then it will need to be a Foo interface that is visible and accessible to all all users of that registry. -Alan From pavelturk2000 at gmail.com Mon Sep 9 07:43:45 2024 From: pavelturk2000 at gmail.com (PavelTurk) Date: Mon, 9 Sep 2024 10:43:45 +0300 Subject: It is safe to use same classes from same modules in different layers In-Reply-To: References: <5fd8c9ee-3935-48cd-8946-60e5d000b4dc@gmail.com> Message-ID: > I assume this arrangement will fail with ClassCastException as B can't cast a A-Foo to a B-Foo. > > If Core wants to provides a system-wide registry (which I think is what you are doing here) then it will need to be a Foo interface that is visible and accessible to all all users of that registry. > I understand you. However, this solution is not suitable for applications with plugins. As I've said, core application doesn't know what plugins do. Suppose - every plugin is developed by a separate company, so, it is not possible to provide their shared APIs in common parent layer that is a core application. Besides, all plugins are added to application the same way - one JPMS layer for one plugin with one parent that is a core application. As you understand it is absolutely impossible to create for every plugin a unique layer structure. Best regards, Pavel From pavelturk2000 at gmail.com Mon Sep 9 08:55:22 2024 From: pavelturk2000 at gmail.com (PavelTurk) Date: Mon, 9 Sep 2024 11:55:22 +0300 Subject: It is safe to use same classes from same modules in different layers In-Reply-To: References: <5fd8c9ee-3935-48cd-8946-60e5d000b4dc@gmail.com> Message-ID: <8b35b0f7-7566-4a35-a3d5-85998af4c17b@gmail.com> Alan, could you please tell if it is technically possible to substitute classes from another layer for an instance? I mean for situation with three layers I described : Bootlayer?(module?Core)?is?a?main?application -?child?layer?A?(module?A,?module?Foo)?is?a?plugin?A -?child?layer?B?(module?B,?module?Foo)?is?a?plugin?B. If class in Module B gets an instance of Foo (from module Foo) created in Module A, is is possible to substitute its class with class from module Foo in layer B? I understand that currently it is not possible. I ask if it is technically possible to implement it. The reason of my question is that real dynamic world is not as perfect as JPMS assumption that if several layers use same module then this module must be present in their common parent layer. Best regards, Pavel From alan.bateman at oracle.com Wed Sep 11 13:52:35 2024 From: alan.bateman at oracle.com (Alan Bateman) Date: Wed, 11 Sep 2024 14:52:35 +0100 Subject: It is safe to use same classes from same modules in different layers In-Reply-To: <8b35b0f7-7566-4a35-a3d5-85998af4c17b@gmail.com> References: <5fd8c9ee-3935-48cd-8946-60e5d000b4dc@gmail.com> <8b35b0f7-7566-4a35-a3d5-85998af4c17b@gmail.com> Message-ID: <2fa77614-c969-44bd-b071-4da30cebe5ed@oracle.com> On 09/09/2024 09:55, PavelTurk wrote: > Alan, could you please tell if it is technically possible to > substitute classes from another layer for an instance? > > I mean for situation with three layers I described : > Bootlayer?(module?Core)?is?a?main?application > -?child?layer?A?(module?A,?module?Foo)?is?a?plugin?A > -?child?layer?B?(module?B,?module?Foo)?is?a?plugin?B. > > If class in Module B gets an instance of Foo (from module Foo) created > in Module A, is is possible to substitute its class with class > from module Foo in layer B? I understand that currently it is not > possible. I ask if it is technically possible to implement it. > > The reason of my question is that real dynamic world is not as perfect > as JPMS assumption that if several layers use same module > then this module must be present in their common parent layer. This isn't really a module system issue. A-Foo and B-Foo are different types. They have the same class name "Foo" but have different defining class loaders. It would of course be possible for B to do the lookup and treat the returned object from the registry as an Object. To do something useful would need Foo to implement an interface that is visible and access to classes in the two module layers. -Alan From greggwon at cox.net Fri Sep 20 14:04:10 2024 From: greggwon at cox.net (Gregg Wonderly) Date: Fri, 20 Sep 2024 09:04:10 -0500 Subject: JDK-8322302 In-Reply-To: References: <39b8bdf2-0e8d-42e2-a62e-69763e4a9a5a@gmail.com> Message-ID: <84D8EA02-C425-459E-8210-2AA582809EBA@cox.net> Does this have to drift away from ClassLoader relationships? What?s driving this to include another instance of relationship? Is it about confusion with ClassLoader parents not being defined, or reachable or ?viewable? from other class loaders because of disparate code sources not being loaded from a common class loader that can build and organize something usable? In the days of JINI, before you guys killed security manager, we just built all relationships from a common parent class loader and the used the SM to limit what was accessible from what URLClassLoader instance. This allowed us to share objects between disparate code bases readily, because we could easily expose the ?data? class loader(s), as parents of the ?service? class loader(s) and limit, via permissions, what ?activities? could be performed by each service. It seems like we are now coming back around to this notion and finding out that what was ripped out, may have actually had attributes of what we need... Gregg > On Sep 2, 2024, at 3:44?AM, Alan Bateman wrote: > > > > On 02/09/2024 09:19, PavelTurk wrote: >> Hello everyone, >> >> I have a question about https://bugs.openjdk.org/browse/JDK-8322302 >> >> Can someone let us know approximately when this bug will be fixed? It is causing us a lot >> of problems, and having an estimated timeline would help us develop the right strategy. > > No ETA on this. There is some design work required to decide how readability should work with automatic modules in child layers. There are trade-offs to consider on the question as to whether a module in a child layer can depend on (and thus read) an automatic module in a parent layer. > > -Alan