Constructing records through reflection and module restrictions

Alex Buckley alex.buckley at oracle.com
Thu Jan 2 17:57:03 UTC 2025


On 12/26/2024 8:44 AM, Florian Weimer wrote:
> * Brian Goetz:
> 
>> The `opens` clause of a module descriptor indeed can be qualified, just
>> as the exports clause can:
>>
>> ModuleDirective:
>>       requires {RequiresModifier} ModuleName ;
>>       exports PackageName [to ModuleName {, ModuleName}] ;
>>       opens PackageName [to ModuleName {, ModuleName}] ;
>>       uses TypeName ;
>>       provides TypeName with TypeName {, TypeName} ;
> 
> I think the limitation here is that PackageName cannot be *.

The framework owner has a choice about what they recommend to users:

- Tell users to make their modules `open`, so that all packages are open 
for deep reflective access to everyone, including the framework. Easy.

- Tell users to open individual packages (or perhaps all of them, one by 
one) to a module belonging to the framework. That framework module can 
then use Module.addOpens(String,Module) to further open the packages to 
other modules in the framework. That is, openness is not transitive by 
default, but can be made transitive very easily.

Alex


More information about the amber-dev mailing list