Service configuration/context <was> Re: ServiceLoader.load* take 2
Paul Sandoz
paul.sandoz at oracle.com
Thu Jun 28 05:46:15 PDT 2012
On Jun 28, 2012, at 9:37 AM, Mandy Chung wrote:
> On 6/27/2012 7:52 AM, Paul Sandoz wrote:
>> [*] I notice that ContextBuilderSetBuilder is adding aliases to the map of context for module view:
>>
>> 96 private void addContextForModuleView(CB cx, ModuleView mv) {
>> 97 contextForModuleView.put(mv.id().name(), cx);
>> 98 for (ModuleId alias : mv.aliases()) {
>> 99 contextForModuleView.put(alias.name(), cx);
>> 100 }
>> 101 }
>>
>> but that information is never re-generated when a stored configuration is loaded in SimpleLibrary:
>>
>> 598 Context c = cx.build();
>> 599 assert c.name().equals(cxn);
>> 600 cf.add(c);
>> 601
>> 602 for (ModuleId m: c.modules()) {
>> 603 for (ModuleId v: c.views(m)) {
>> 604 cf.put(v.name(), c);
>> 605 }
>> 606 }
>>
>> Bug?
>
>
> In fact, the aliases information are not stored in the configuration. It's a bug - good catch. Currently the jdk implementation doesn't depend on it. This only affects ModuleClassLoader.isModulePresent("java.xml") if the parameter is an alias name.
>
OK, i just fixed it to support aliases, the simplest thing to do is ensure that aliases+views are returned by BaseContext.views(ModuleId ), thus they become stored as part of the configuration. I now see stuff like "java.<x>" in the dump config.
I think this sort of confirms we can simplify Configuration to always calculate the map of context for module view on construction in one place. Thus there is no need to have explicit methods to update that map state or pass in that map state on construction and more importantly there is no need to trust that the map state is in sync with the contexts themselves. It will also simplify Context*Set and the process of building Context instances.
> Mandy
> P.S. I'll try to look at your webrev and understand your proposed approach next week.
OK thanks, i expect by then i will have updated to also include the 2 next steps in the previous email.
I am a bit nervous about size of the changes, it's tricky to unravel this piece by piece.
Paul.
More information about the jigsaw-dev
mailing list