diff --git a/jep511/broken/TwoStarImports.java b/jep511/broken/TwoStarImports.java new file mode 100644 index 0000000..f08c040 --- /dev/null +++ b/jep511/broken/TwoStarImports.java @@ -0,0 +1,9 @@ +import java.util.*; +import java.sql.*; + +public class TwoStarImports { + public static void main(String[] args) { + Date d = new Date(0L); // the same clash, with the old on-demand imports + System.out.println(d); + } +} diff --git a/jep511/output/02-ambiguity.txt b/jep511/output/02-ambiguity.txt index e1886c5..92f30dd 100644 --- a/jep511/output/02-ambiguity.txt +++ b/jep511/output/02-ambiguity.txt @@ -34,6 +34,28 @@ broken/AmbiguousList.java:6: error: reference to List is ambiguous both class java.awt.List in java.awt and interface java.util.List in java.util match 1 error +$ javac broken/TwoStarImports.java (25.0.4.1+1-LTS) +broken/TwoStarImports.java:6: error: reference to Date is ambiguous + Date d = new Date(0L); // the same clash, with the old on-demand imports + ^ + both class java.sql.Date in java.sql and class java.util.Date in java.util match +broken/TwoStarImports.java:6: error: reference to Date is ambiguous + Date d = new Date(0L); // the same clash, with the old on-demand imports + ^ + both class java.sql.Date in java.sql and class java.util.Date in java.util match +2 errors + +$ javac broken/TwoStarImports.java (27+35) +broken/TwoStarImports.java:6: error: reference to Date is ambiguous + Date d = new Date(0L); // the same clash, with the old on-demand imports + ^ + both class java.sql.Date in java.sql and class java.util.Date in java.util match +broken/TwoStarImports.java:6: error: reference to Date is ambiguous + Date d = new Date(0L); // the same clash, with the old on-demand imports + ^ + both class java.sql.Date in java.sql and class java.util.Date in java.util match +2 errors + $ javac src/FixedDate.java && java FixedDate (25.0.4.1+1-LTS) java.util.Date java.sql.Date diff --git a/jep511/output/04-what-a-module-import-brings-in.txt b/jep511/output/04-what-a-module-import-brings-in.txt index 83db5c1..13512f3 100644 --- a/jep511/output/04-what-a-module-import-brings-in.txt +++ b/jep511/output/04-what-a-module-import-brings-in.txt @@ -1,11 +1,14 @@ +$ java --describe-module java.base | grep -c '^exports' (25.0.4.1+1-LTS) +58 + $ java --describe-module java.sql (25.0.4.1+1-LTS) java.sql@25.0.4.1 exports java.sql exports javax.sql -requires java.xml transitive -requires java.logging transitive requires java.transaction.xa transitive requires java.base mandated +requires java.xml transitive +requires java.logging transitive uses java.sql.Driver $ java --describe-module java.se | grep -c 'requires' (25.0.4.1+1-LTS) diff --git a/jep511/output/09-jshell.txt b/jep511/output/09-jshell.txt index c8ebd25..1a04b2e 100644 --- a/jep511/output/09-jshell.txt +++ b/jep511/output/09-jshell.txt @@ -10,12 +10,19 @@ $ jshell --feedback concise src/imports.jsh (21.0.10+7-Ubuntu-124.04) import java.util.regex.* import java.util.stream.* [2, 4] +Error: +cannot find symbol + symbol: variable LocalDate +System.out.println(LocalDate.of(2026, 9, 15)) + ^-------^ $ jshell --feedback concise src/imports.jsh (25.0.4.1+1-LTS) import java.base [2, 4] +2026-09-15 $ jshell --feedback concise src/imports.jsh (27+35) import java.base [2, 4] +2026-09-15 diff --git a/jep511/run.sh b/jep511/run.sh index ad75300..3b7b680 100755 --- a/jep511/run.sh +++ b/jep511/run.sh @@ -23,7 +23,7 @@ both() { local fn="$1"; shift; "$fn" "$JDK25" "$@"; echo; "$fn" "$JDK27" "$@"; } { both cr src/OldWay.java OldWay; echo; both cr src/NewWay.java NewWay; } > "$OUT/01-old-vs-new.txt" # 02 - ambiguity: two modules export a class with the same simple name -{ both co broken/AmbiguousDate.java; echo; both co broken/AmbiguousList.java; echo; both cr src/FixedDate.java FixedDate; } > "$OUT/02-ambiguity.txt" +{ both co broken/AmbiguousDate.java; echo; both co broken/AmbiguousList.java; echo; both co broken/TwoStarImports.java; echo; both cr src/FixedDate.java FixedDate; } > "$OUT/02-ambiguity.txt" # 03 - precedence: who wins when several imports offer the same simple name { both cr src/StarImportWins.java StarImportWins; echo; both cr src/StarImportWinsSql.java StarImportWinsSql; echo @@ -31,7 +31,8 @@ both() { local fn="$1"; shift; "$fn" "$JDK25" "$@"; echo; "$fn" "$JDK27" "$@"; } both cr src/DuplicateImports.java DuplicateImports; } > "$OUT/03-precedence.txt" # 04 - what one module import actually brings in -{ echo "\$ java --describe-module java.sql ($(t "$JDK25"))"; "$JDK25/bin/java" --describe-module java.sql; echo +{ echo "\$ java --describe-module java.base | grep -c '^exports' ($(t "$JDK25"))"; "$JDK25/bin/java" --describe-module java.base | grep -c '^exports'; echo + echo "\$ java --describe-module java.sql ($(t "$JDK25"))"; "$JDK25/bin/java" --describe-module java.sql; echo echo "\$ java --describe-module java.se | grep -c 'requires' ($(t "$JDK25"))"; "$JDK25/bin/java" --describe-module java.se | grep -c requires; echo echo "\$ java --describe-module java.se | grep -c exports ($(t "$JDK25"))"; "$JDK25/bin/java" --describe-module java.se | grep -c exports; echo both cr src/Transitive.java Transitive; echo; both co broken/SqlDoesNotGiveBase.java; echo diff --git a/jep511/src/imports.jsh b/jep511/src/imports.jsh index 3da7fb5..d66b8cc 100644 --- a/jep511/src/imports.jsh +++ b/jep511/src/imports.jsh @@ -1,3 +1,4 @@ /imports System.out.println(List.of(1, 2).stream().map(x -> x * 2).collect(Collectors.toList())) +System.out.println(LocalDate.of(2026, 9, 15)) /exit