From c1902d36b3355d1ea2688cfae27e5b0490a595b5 Mon Sep 17 00:00:00 2001 From: Fox2Code Date: Tue, 26 Nov 2024 21:33:34 +0100 Subject: [PATCH] Add some ModuleDescriptor Builder stubs --- .../java_base/J_L_M_ModuleDescriptor.java | 20 +++++++++++++++++++ 1 file changed, 20 insertions(+) diff --git a/java-api/src/java9/java/xyz/wagyourtail/jvmdg/j9/stub/java_base/J_L_M_ModuleDescriptor.java b/java-api/src/java9/java/xyz/wagyourtail/jvmdg/j9/stub/java_base/J_L_M_ModuleDescriptor.java index 78dd70c..367d900 100644 --- a/java-api/src/java9/java/xyz/wagyourtail/jvmdg/j9/stub/java_base/J_L_M_ModuleDescriptor.java +++ b/java-api/src/java9/java/xyz/wagyourtail/jvmdg/j9/stub/java_base/J_L_M_ModuleDescriptor.java @@ -239,6 +239,26 @@ public String toString() { return sb.toString(); } + public static Builder newModule(String name, Set ms) { + Set mods = new HashSet<>(ms); + if (mods.contains(Modifier.AUTOMATIC) && mods.size() > 1) { + throw new IllegalArgumentException("AUTOMATIC cannot be used with other modifiers"); + } + return new Builder(name, true, mods); + } + + public static Builder newModule(String name) { + return new Builder(name, true, Collections.emptySet()); + } + + public static Builder newOpenModule(String name) { + return new Builder(name, true, Collections.singleton(Modifier.OPEN)); + } + + public static Builder newAutomaticModule(String name) { + return new Builder(name, true, Collections.singleton(Modifier.AUTOMATIC)); + } + @Adapter("java/lang/module/ModuleDescriptor$Modifier") public enum Modifier { OPEN, AUTOMATIC, SYNTHETIC, MANDATED