[module-imports] Improved Shadowing Behavior

Remi Forax forax at univ-mlv.fr
Fri Oct 11 20:01:58 UTC 2024


----- Original Message -----
> From: "Gavin Bierman" <gavin.bierman at oracle.com>
> To: "amber-spec-experts" <amber-spec-experts at openjdk.org>
> Sent: Thursday, October 10, 2024 3:09:09 PM
> Subject: [module-imports] Improved Shadowing Behavior

> Dear experts,
> 
> We are used to single type imports shadowing a type imported from a package
> import, i.e.
> 
> import java.awt.*;
> import java.util.List;      // Shadows the List from java.awt package
> 
> The design intent is that the more specific import can shadow the less specific
> import.
> 
> With module imports there is a new case that I think we should support, where a
> package import can shadow a module import, e.g.
> 
> import module java.desktop;
> import java.util.*;
> 
> // List is resolved to java.util.List
> 
> This seems in spirit with the original design intent - the more specific import
> can shadow the less specific import - we probably should have had this in the
> first
> preview.
> 
> This also helps users who have used package imports up to this point be robust
> against a future where a module import is added to their code.
> 
> I have updated the draft JEP to reflect this change:
> https://openjdk.org/jeps/8335987
> 
> Please send any comments or suggestions to the list or to me directly.
> 
> Many thanks,
> Gavin

I agree, it should have been in the first preview :)

Rémi


More information about the amber-spec-experts mailing list