Add jep511 module: module import declarations on JDK 25 and 27
Runnable sources, deliberate compile failures, three small modules and nine captured transcripts for import module (JEP 511). Co-Authored-By: Claude Sonnet 5 <[email protected]> Claude-Session: https://claude.ai/code/session_01TF9JWFvJSNm6HVzswzZU5a
This commit is contained in:
@@ -0,0 +1,6 @@
|
||||
package acme.text;
|
||||
|
||||
public final class Slug {
|
||||
private Slug() {}
|
||||
public static String of(String s) { return acme.text.internal.Helper.clean(s); }
|
||||
}
|
||||
@@ -0,0 +1,5 @@
|
||||
package acme.text.internal;
|
||||
|
||||
public final class Helper {
|
||||
public static String clean(String s) { return s.toLowerCase().replaceAll("[^a-z0-9]+", "-").replaceAll("^-|-$", ""); }
|
||||
}
|
||||
@@ -0,0 +1,3 @@
|
||||
module acme.text {
|
||||
exports acme.text; // acme.text.internal is NOT exported
|
||||
}
|
||||
@@ -0,0 +1,9 @@
|
||||
package demo;
|
||||
|
||||
import module acme.text; // imports Slug, but not acme.text.internal.Helper
|
||||
|
||||
public class App {
|
||||
public static void main(String[] args) {
|
||||
System.out.println(Slug.of("Import Module: Hello, World!"));
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,3 @@
|
||||
module demo.app {
|
||||
requires acme.text;
|
||||
}
|
||||
@@ -0,0 +1,9 @@
|
||||
package demo;
|
||||
|
||||
import module acme.text;
|
||||
|
||||
public class Bad {
|
||||
public static void main(String[] args) {
|
||||
System.out.println(Helper.clean("x")); // Helper is in the non-exported acme.text.internal
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,3 @@
|
||||
module demo.bad {
|
||||
requires acme.text;
|
||||
}
|
||||
@@ -0,0 +1,9 @@
|
||||
package demo;
|
||||
|
||||
import module java.sql; // demo.noreq never says "requires java.sql"
|
||||
|
||||
public class NoReq {
|
||||
public static void main(String[] args) {
|
||||
System.out.println(Connection.TRANSACTION_NONE);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1 @@
|
||||
module demo.noreq { }
|
||||
Reference in New Issue
Block a user