diff --git a/picocli-codegen/src/main/java/picocli/codegen/annotation/processing/AbstractCommandSpecProcessor.java b/picocli-codegen/src/main/java/picocli/codegen/annotation/processing/AbstractCommandSpecProcessor.java index 32f8012af..741462bf6 100644 --- a/picocli-codegen/src/main/java/picocli/codegen/annotation/processing/AbstractCommandSpecProcessor.java +++ b/picocli-codegen/src/main/java/picocli/codegen/annotation/processing/AbstractCommandSpecProcessor.java @@ -4,6 +4,7 @@ import picocli.CommandLine.Command; import picocli.CommandLine.IFactory; import picocli.CommandLine.Mixin; +import picocli.CommandLine.Model; import picocli.CommandLine.Model.ArgGroupSpec; import picocli.CommandLine.Model.CommandSpec; import picocli.CommandLine.Model.IAnnotatedElement; @@ -179,7 +180,7 @@ private static String stacktrace(Exception e) { } private boolean tryProcess(Set annotations, RoundEnvironment roundEnv) { - + Model.Messages.loadBundles = false; new AnnotationValidator(processingEnv).validateAnnotations(roundEnv); Context context = new Context(); diff --git a/src/main/java/picocli/CommandLine.java b/src/main/java/picocli/CommandLine.java index d366723aa..f4b302339 100644 --- a/src/main/java/picocli/CommandLine.java +++ b/src/main/java/picocli/CommandLine.java @@ -11599,6 +11599,7 @@ public T getExtension(Class cls) { * @see CommandSpec#qualifiedName(String) * @since 3.6 */ public static class Messages { + public static boolean loadBundles = true; private final CommandSpec spec; private final String bundleBaseName; private final ResourceBundle rb; @@ -11620,7 +11621,20 @@ public Messages(CommandSpec spec, String baseName, ResourceBundle rb) { } } private static ResourceBundle createBundle(String baseName) { - return ResourceBundle.getBundle(baseName); + if ( loadBundles ) { + return ResourceBundle.getBundle(baseName); + } else { + return new ResourceBundle() { + @Override + protected Object handleGetObject(String key) { + return null; + } + @Override + public Enumeration getKeys() { + return new Vector().elements(); + } + }; + } } private static String extractName(ResourceBundle rb) { try { // ResourceBundle.getBaseBundleName was introduced in Java 8