[module-imports] Improved Shadowing Behavior
Gavin Bierman
gavin.bierman at oracle.com
Thu Oct 10 13:09:09 UTC 2024
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
More information about the amber-spec-experts
mailing list