diff --git a/substratevm/src/com.oracle.graal.pointsto.standalone/src/com/oracle/graal/pointsto/standalone/PointsToAnalyzer.java b/substratevm/src/com.oracle.graal.pointsto.standalone/src/com/oracle/graal/pointsto/standalone/PointsToAnalyzer.java index ed8716cdadc3..8e0a88f521da 100644 --- a/substratevm/src/com.oracle.graal.pointsto.standalone/src/com/oracle/graal/pointsto/standalone/PointsToAnalyzer.java +++ b/substratevm/src/com.oracle.graal.pointsto.standalone/src/com/oracle/graal/pointsto/standalone/PointsToAnalyzer.java @@ -306,8 +306,8 @@ public static void main(String[] args) { } protected static void reportException(Throwable e) { - System.err.print("Exception:"); - e.printStackTrace(); + System.out.print("Exception:"); + e.printStackTrace(System.out); } public ClassLoader getClassLoader() { diff --git a/substratevm/src/com.oracle.graal.pointsto/src/com/oracle/graal/pointsto/meta/AnalysisType.java b/substratevm/src/com.oracle.graal.pointsto/src/com/oracle/graal/pointsto/meta/AnalysisType.java index 42e1d9c44bc5..cbc22e5f721d 100644 --- a/substratevm/src/com.oracle.graal.pointsto/src/com/oracle/graal/pointsto/meta/AnalysisType.java +++ b/substratevm/src/com.oracle.graal.pointsto/src/com/oracle/graal/pointsto/meta/AnalysisType.java @@ -449,7 +449,7 @@ public static boolean verifyAssignableTypes(BigBang bb) { } }); if (!mismatchedAssignableResults.isEmpty()) { - mismatchedAssignableResults.forEach(System.err::println); + mismatchedAssignableResults.forEach(System.out::println); throw new AssertionError("Verification of all-instantiated type flows failed"); } return true; @@ -1166,7 +1166,7 @@ public boolean isLocal() { try { return wrapped.isLocal(); } catch (InternalError e) { - System.err.println("warning: unknown locality of class " + wrapped.getName() + ", assuming class is not local. To remove the warning report an issue " + + System.out.println("Warning: unknown locality of class " + wrapped.getName() + ", assuming class is not local. To remove the warning report an issue " + "to the library or language author. The issue is caused by " + wrapped.getName() + " which is not following the naming convention."); return false; } diff --git a/substratevm/src/com.oracle.objectfile/src/com/oracle/objectfile/pecoff/PECoffUserDefinedSection.java b/substratevm/src/com.oracle.objectfile/src/com/oracle/objectfile/pecoff/PECoffUserDefinedSection.java index 4d34aa1ee8a9..7d7c62d564cf 100644 --- a/substratevm/src/com.oracle.objectfile/src/com/oracle/objectfile/pecoff/PECoffUserDefinedSection.java +++ b/substratevm/src/com.oracle.objectfile/src/com/oracle/objectfile/pecoff/PECoffUserDefinedSection.java @@ -185,6 +185,6 @@ public void markRelocationSite(int offset, ByteBuffer bb, ObjectFile.RelocationK * @param msg warning message that is printed. */ private static void warn(String msg) { - System.err.println("Warning: " + msg); + System.out.println("Warning: " + msg); } } diff --git a/substratevm/src/com.oracle.svm.agent/src/com/oracle/svm/agent/NativeImageAgent.java b/substratevm/src/com.oracle.svm.agent/src/com/oracle/svm/agent/NativeImageAgent.java index 2c09b2f1d9a3..addf1ebdd4bd 100644 --- a/substratevm/src/com.oracle.svm.agent/src/com/oracle/svm/agent/NativeImageAgent.java +++ b/substratevm/src/com.oracle.svm.agent/src/com/oracle/svm/agent/NativeImageAgent.java @@ -402,7 +402,9 @@ protected int onLoadCallback(JNIJavaVM vm, JvmtiEnv jvmti, JvmtiEventCallbacks c } private static void inform(String message) { + // Checkstyle: allow System.err System.err.println(AGENT_NAME + ": " + message); + // Checkstyle: disallow System.err } private static void warn(String message) { diff --git a/substratevm/src/com.oracle.svm.configure/src/com/oracle/svm/configure/ConfigurationTool.java b/substratevm/src/com.oracle.svm.configure/src/com/oracle/svm/configure/ConfigurationTool.java index a94b9401e174..09b2b66df05b 100644 --- a/substratevm/src/com.oracle.svm.configure/src/com/oracle/svm/configure/ConfigurationTool.java +++ b/substratevm/src/com.oracle.svm.configure/src/com/oracle/svm/configure/ConfigurationTool.java @@ -116,7 +116,7 @@ public static void main(String[] args) { throw new UsageException("Unknown subcommand: " + first); } } catch (UsageException e) { - System.err.println(e.getMessage() + System.lineSeparator() + + System.out.println(e.getMessage() + System.lineSeparator() + "Use 'native-image-configure help' for usage."); System.exit(2); } catch (Exception e) { @@ -311,7 +311,7 @@ private static void generate(Iterator argsIter, boolean acceptTraceFileA } if (outputCollection.isEmpty()) { - System.err.println("Warning: no outputs specified, validating inputs only."); + System.out.println("Warning: no outputs specified, validating inputs only."); } for (URI uri : outputCollection.getReflectConfigPaths()) { try (JsonWriter writer = new JsonWriter(Paths.get(uri))) { diff --git a/substratevm/src/com.oracle.svm.configure/src/com/oracle/svm/configure/filters/ModuleFilterTools.java b/substratevm/src/com.oracle.svm.configure/src/com/oracle/svm/configure/filters/ModuleFilterTools.java index 079f50d64ad2..b13f35fb7e2e 100644 --- a/substratevm/src/com.oracle.svm.configure/src/com/oracle/svm/configure/filters/ModuleFilterTools.java +++ b/substratevm/src/com.oracle.svm.configure/src/com/oracle/svm/configure/filters/ModuleFilterTools.java @@ -58,7 +58,7 @@ public static HierarchyFilterNode generateFromModules(String[] moduleNames, Incl private static void checkDependencies(Module module, Set includedModuleNames) { for (ModuleDescriptor.Requires require : module.getDescriptor().requires()) { if (!includedModuleNames.contains(require.name())) { - System.err.println("Warning: dependency missing from input set of modules: " + module.getName() + " -> " + require.name()); + System.out.println("Warning: dependency missing from input set of modules: " + module.getName() + " -> " + require.name()); checkDependencies(module.getLayer().findModule(require.name()).get(), includedModuleNames); } } diff --git a/substratevm/src/com.oracle.svm.configure/src/com/oracle/svm/configure/trace/AbstractProcessor.java b/substratevm/src/com.oracle.svm.configure/src/com/oracle/svm/configure/trace/AbstractProcessor.java index 57c3c4f3e38e..0288aafd700b 100644 --- a/substratevm/src/com.oracle.svm.configure/src/com/oracle/svm/configure/trace/AbstractProcessor.java +++ b/substratevm/src/com.oracle.svm.configure/src/com/oracle/svm/configure/trace/AbstractProcessor.java @@ -42,7 +42,7 @@ void setInLivePhase(@SuppressWarnings("unused") boolean live) { } static void logWarning(String warning) { - System.err.println("Warning: " + warning); + System.out.println("Warning: " + warning); } @SuppressWarnings("unchecked") diff --git a/substratevm/src/com.oracle.svm.configure/src/com/oracle/svm/configure/trace/ReflectionProcessor.java b/substratevm/src/com.oracle.svm.configure/src/com/oracle/svm/configure/trace/ReflectionProcessor.java index 704f46ecd856..dbbcf5cbad05 100644 --- a/substratevm/src/com.oracle.svm.configure/src/com/oracle/svm/configure/trace/ReflectionProcessor.java +++ b/substratevm/src/com.oracle.svm.configure/src/com/oracle/svm/configure/trace/ReflectionProcessor.java @@ -271,7 +271,7 @@ public void processEntry(EconomicMap entry, ConfigurationSet configur break; } default: - System.err.println("Unsupported reflection method: " + function); + System.out.println("Unsupported reflection method: " + function); } } diff --git a/substratevm/src/com.oracle.svm.core/.checkstyle_checks.xml b/substratevm/src/com.oracle.svm.core/.checkstyle_checks.xml index 293f176e4b72..d71556be7e25 100644 --- a/substratevm/src/com.oracle.svm.core/.checkstyle_checks.xml +++ b/substratevm/src/com.oracle.svm.core/.checkstyle_checks.xml @@ -54,6 +54,21 @@ + + + + + + + + + + + + + + + diff --git a/substratevm/src/com.oracle.svm.core/src/com/oracle/svm/core/FallbackExecutor.java b/substratevm/src/com.oracle.svm.core/src/com/oracle/svm/core/FallbackExecutor.java index decc55655884..c98dac349e62 100644 --- a/substratevm/src/com.oracle.svm.core/src/com/oracle/svm/core/FallbackExecutor.java +++ b/substratevm/src/com.oracle.svm.core/src/com/oracle/svm/core/FallbackExecutor.java @@ -135,7 +135,7 @@ private static Path getJavaExecutable() { } private static void showError(String s) { - System.err.println("Error: " + s); + System.out.println("Error: " + s); System.exit(1); } } diff --git a/substratevm/src/com.oracle.svm.core/src/com/oracle/svm/core/JavaMainWrapper.java b/substratevm/src/com.oracle.svm.core/src/com/oracle/svm/core/JavaMainWrapper.java index e6fb30ca62ca..b704085221e3 100644 --- a/substratevm/src/com.oracle.svm.core/src/com/oracle/svm/core/JavaMainWrapper.java +++ b/substratevm/src/com.oracle.svm.core/src/com/oracle/svm/core/JavaMainWrapper.java @@ -147,7 +147,7 @@ private static int runCore0() { System.out.println("Heap dump created at '" + absoluteHeapDumpPath + "'."); return 0; } else { - System.err.println("Unable to dump heap. Heap dumping is only supported for native executables built with `" + VMInspectionOptions.getHeapdumpsCommandArgument() + "`."); + System.out.println("Unable to dump heap. Heap dumping is only supported for native executables built with `" + VMInspectionOptions.getHeapdumpsCommandArgument() + "`."); return 1; } } diff --git a/substratevm/src/com.oracle.svm.core/src/com/oracle/svm/core/configure/ConfigurationParser.java b/substratevm/src/com.oracle.svm.core/src/com/oracle/svm/core/configure/ConfigurationParser.java index 682a3c358345..3f6173e9ca84 100644 --- a/substratevm/src/com.oracle.svm.core/src/com/oracle/svm/core/configure/ConfigurationParser.java +++ b/substratevm/src/com.oracle.svm.core/src/com/oracle/svm/core/configure/ConfigurationParser.java @@ -130,7 +130,7 @@ protected void warnOrFail(String message) { if (strictConfiguration) { throw new JSONParserException(message); } else { - System.err.println("Warning: " + message); + System.out.println("Warning: " + message); } } diff --git a/substratevm/src/com.oracle.svm.core/src/com/oracle/svm/core/configure/ReflectionConfigurationParser.java b/substratevm/src/com.oracle.svm.core/src/com/oracle/svm/core/configure/ReflectionConfigurationParser.java index 471eb18c5056..65c5562518ae 100644 --- a/substratevm/src/com.oracle.svm.core/src/com/oracle/svm/core/configure/ReflectionConfigurationParser.java +++ b/substratevm/src/com.oracle.svm.core/src/com/oracle/svm/core/configure/ReflectionConfigurationParser.java @@ -291,6 +291,6 @@ private static void handleError(String msg, Throwable cause) { if (cause != null) { message += " Reason: " + formatError(cause) + '.'; } - System.err.println("Warning: " + message); + System.out.println("Warning: " + message); } } diff --git a/substratevm/src/com.oracle.svm.core/src/com/oracle/svm/core/graal/snippets/CEntryPointSnippets.java b/substratevm/src/com.oracle.svm.core/src/com/oracle/svm/core/graal/snippets/CEntryPointSnippets.java index e99967118b0d..923efe5c35c9 100644 --- a/substratevm/src/com.oracle.svm.core/src/com/oracle/svm/core/graal/snippets/CEntryPointSnippets.java +++ b/substratevm/src/com.oracle.svm.core/src/com/oracle/svm/core/graal/snippets/CEntryPointSnippets.java @@ -344,8 +344,8 @@ private static int initializeIsolate(CEntryPointCreateIsolateParameters paramete try { RuntimeSupport.executeInitializationHooks(); } catch (Throwable t) { - System.err.println("Uncaught exception while running initialization hooks:"); - t.printStackTrace(); + System.out.println("Uncaught exception while running initialization hooks:"); + t.printStackTrace(System.out); CEntryPointActions.leaveTearDownIsolate(); return CEntryPointErrors.ISOLATE_INITIALIZATION_FAILED; } diff --git a/substratevm/src/com.oracle.svm.core/src/com/oracle/svm/core/hub/ClassLoadingExceptionSupport.java b/substratevm/src/com.oracle.svm.core/src/com/oracle/svm/core/hub/ClassLoadingExceptionSupport.java index bc9f8b20712d..a03008f18280 100644 --- a/substratevm/src/com.oracle.svm.core/src/com/oracle/svm/core/hub/ClassLoadingExceptionSupport.java +++ b/substratevm/src/com.oracle.svm.core/src/com/oracle/svm/core/hub/ClassLoadingExceptionSupport.java @@ -69,7 +69,7 @@ public static Throwable getExceptionForClass(String className, Throwable origina } private static void terminateUnconfigured(String className) { - System.err.println("Missing metadata error: Unable to process Class.forName invocation for class name " + className); + System.out.println("Missing metadata error: Unable to process Class.forName invocation for class name " + className); System.exit(EXIT_CODE); } } diff --git a/substratevm/src/com.oracle.svm.core/src/com/oracle/svm/core/jdk/TimeZoneSubstitutions.java b/substratevm/src/com.oracle.svm.core/src/com/oracle/svm/core/jdk/TimeZoneSubstitutions.java index 45b434926743..b225d88cc882 100644 --- a/substratevm/src/com.oracle.svm.core/src/com/oracle/svm/core/jdk/TimeZoneSubstitutions.java +++ b/substratevm/src/com.oracle.svm.core/src/com/oracle/svm/core/jdk/TimeZoneSubstitutions.java @@ -146,7 +146,7 @@ protected void onValueUpdate(EconomicMap, Object> values, String ol }; private static void printWarning() { - System.err.println("-H:IncludeAllTimeZones and -H:IncludeTimeZones are now deprecated. Native-image includes all timezones" + + System.out.println("-H:IncludeAllTimeZones and -H:IncludeTimeZones are now deprecated. Native-image includes all timezones" + " by default."); } } diff --git a/substratevm/src/com.oracle.svm.core/src/com/oracle/svm/core/jfr/JfrFeature.java b/substratevm/src/com.oracle.svm.core/src/com/oracle/svm/core/jfr/JfrFeature.java index 405cc7027057..43f8814660d7 100644 --- a/substratevm/src/com.oracle.svm.core/src/com/oracle/svm/core/jfr/JfrFeature.java +++ b/substratevm/src/com.oracle.svm.core/src/com/oracle/svm/core/jfr/JfrFeature.java @@ -115,7 +115,7 @@ public static boolean isInConfiguration(boolean allowPrinting) { boolean runtimeEnabled = VMInspectionOptions.hasJfrSupport(); if (HOSTED_ENABLED && !runtimeEnabled) { if (allowPrinting) { - System.err.println("Warning: When FlightRecoder is used to profile the image generator, it is also automatically enabled in the native image at run time. " + + System.out.println("Warning: When FlightRecoder is used to profile the image generator, it is also automatically enabled in the native image at run time. " + "This can affect the measurements because it can can make the image larger and image build time longer."); } runtimeEnabled = true; diff --git a/substratevm/src/com.oracle.svm.core/src/com/oracle/svm/core/option/SubstrateOptionsParser.java b/substratevm/src/com.oracle.svm.core/src/com/oracle/svm/core/option/SubstrateOptionsParser.java index 62fada7890e8..44a77798f8cb 100644 --- a/substratevm/src/com.oracle.svm.core/src/com/oracle/svm/core/option/SubstrateOptionsParser.java +++ b/substratevm/src/com.oracle.svm.core/src/com/oracle/svm/core/option/SubstrateOptionsParser.java @@ -107,7 +107,7 @@ public static boolean parseHostedOption(String optionPrefix, EconomicMap... interfaces) { return clazz; } catch (Throwable t) { - System.err.println("Warning: Could not create a proxy class from list of interfaces: " + Arrays.toString(interfaces) + ". Reason: " + t.getMessage()); + System.out.println("Warning: Could not create a proxy class from list of interfaces: " + Arrays.toString(interfaces) + ". Reason: " + t.getMessage()); return t; } }); diff --git a/substratevm/src/com.oracle.svm.core/src/com/oracle/svm/core/thread/JavaThreads.java b/substratevm/src/com.oracle.svm.core/src/com/oracle/svm/core/thread/JavaThreads.java index 2c0f772b9fab..d8edf20312f7 100644 --- a/substratevm/src/com.oracle.svm.core/src/com/oracle/svm/core/thread/JavaThreads.java +++ b/substratevm/src/com.oracle.svm.core/src/com/oracle/svm/core/thread/JavaThreads.java @@ -237,8 +237,8 @@ public static void dispatchUncaughtException(Thread thread, Throwable throwable) } } else { /* If no uncaught exception handler is present, then just report the throwable. */ - System.err.print("Exception in thread \"" + Thread.currentThread().getName() + "\" "); - throwable.printStackTrace(); + System.out.print("Exception in thread \"" + Thread.currentThread().getName() + "\" "); + throwable.printStackTrace(System.out); } } diff --git a/substratevm/src/com.oracle.svm.diagnosticsagent/src/com/oracle/svm/diagnosticsagent/NativeImageDiagnosticsAgent.java b/substratevm/src/com.oracle.svm.diagnosticsagent/src/com/oracle/svm/diagnosticsagent/NativeImageDiagnosticsAgent.java index b14465bfe396..01ba36b70ca9 100644 --- a/substratevm/src/com.oracle.svm.diagnosticsagent/src/com/oracle/svm/diagnosticsagent/NativeImageDiagnosticsAgent.java +++ b/substratevm/src/com.oracle.svm.diagnosticsagent/src/com/oracle/svm/diagnosticsagent/NativeImageDiagnosticsAgent.java @@ -191,7 +191,7 @@ private void onClassPrepareCallback(JvmtiEnv jvmti, JNIEnvironment jni, JNIObjec clinitClassMap.put(clinitMethodId.rawValue(), classHandleHolder); check(jvmti.getFunctions().SetBreakpoint().invoke(jvmti, clinitMethodId, 0L)); } else { - System.err.println("Trace class initialization requested for " + className + " but the class has not been instrumented with ."); + System.out.println("Trace class initialization requested for " + className + " but the class has not been instrumented with ."); } } if (advisor.shouldTraceObjectInstantiation(className)) { @@ -211,7 +211,7 @@ private void setConstructorBreakpointsForClass(JvmtiEnv jvmti, JNIEnvironment jn } } else { /* This should never happen. */ - System.err.println("Trace object instantiation requested for " + className + " but the class has no constructors."); + System.out.println("Trace object instantiation requested for " + className + " but the class has no constructors."); } } @@ -396,8 +396,8 @@ private byte[] maybeInstrumentClassWithClinit(String clazzName, byte[] clazzData return writer.toByteArray(); } catch (Throwable e) { String targetClazzName = clazzName != null ? clazzName : ""; - System.err.println("[native-image-diagnostics-agent] Failed to instrument class " + targetClazzName + ": "); - e.printStackTrace(System.err); + System.out.println("[native-image-diagnostics-agent] Failed to instrument class " + targetClazzName + ": "); + e.printStackTrace(System.out); return null; } } diff --git a/substratevm/src/com.oracle.svm.driver/src/com/oracle/svm/driver/NativeImage.java b/substratevm/src/com.oracle.svm.driver/src/com/oracle/svm/driver/NativeImage.java index bdee4637071c..ab2cb5b39c59 100644 --- a/substratevm/src/com.oracle.svm.driver/src/com/oracle/svm/driver/NativeImage.java +++ b/substratevm/src/com.oracle.svm.driver/src/com/oracle/svm/driver/NativeImage.java @@ -1415,10 +1415,10 @@ private static void performBuild(BuildConfiguration config, Function + + + + + + + + + + + + + + + diff --git a/substratevm/src/com.oracle.svm.hosted/src/com/oracle/svm/hosted/ConfigurationTypeResolver.java b/substratevm/src/com.oracle.svm.hosted/src/com/oracle/svm/hosted/ConfigurationTypeResolver.java index 32a650fc7db6..91177c2fec6a 100644 --- a/substratevm/src/com.oracle.svm.hosted/src/com/oracle/svm/hosted/ConfigurationTypeResolver.java +++ b/substratevm/src/com.oracle.svm.hosted/src/com/oracle/svm/hosted/ConfigurationTypeResolver.java @@ -53,7 +53,7 @@ private Class resolveType(String typeName, boolean warn) { } TypeResult> typeResult = classLoader.findClass(name); if (warn && !typeResult.isPresent()) { - System.err.println("Warning: Could not resolve " + name + " for " + configurationType + "."); + System.out.println("Warning: Could not resolve " + name + " for " + configurationType + "."); } return typeResult.get(); } diff --git a/substratevm/src/com.oracle.svm.hosted/src/com/oracle/svm/hosted/DeadlockWatchdog.java b/substratevm/src/com.oracle.svm.hosted/src/com/oracle/svm/hosted/DeadlockWatchdog.java index a67228d3ab10..92c7b8306ea8 100644 --- a/substratevm/src/com.oracle.svm.hosted/src/com/oracle/svm/hosted/DeadlockWatchdog.java +++ b/substratevm/src/com.oracle.svm.hosted/src/com/oracle/svm/hosted/DeadlockWatchdog.java @@ -76,19 +76,19 @@ void watchdogThread() { while (!stopped) { long now = System.currentTimeMillis(); if (enabled && now >= nextDeadline) { - System.err.println(); - System.err.println("=== Image generator watchdog detected no activity. This can be a sign of a deadlock during image building. Dumping all stack traces. Current time: " + new Date()); + System.out.println(); + System.out.println("=== Image generator watchdog detected no activity. This can be a sign of a deadlock during image building. Dumping all stack traces. Current time: " + new Date()); threadDump(); Runtime runtime = Runtime.getRuntime(); final long heapSizeUnit = 1024 * 1024; long usedHeapSize = runtime.totalMemory() / heapSizeUnit; long freeHeapSize = runtime.freeMemory() / heapSizeUnit; long maximumHeapSize = runtime.maxMemory() / heapSizeUnit; - System.err.printf("=== Memory statistics (in MB):%n=== Used heap size: %d%n=== Free heap size: %d%n=== Maximum heap size: %d%n", usedHeapSize, freeHeapSize, maximumHeapSize); - System.err.flush(); + System.out.printf("=== Memory statistics (in MB):%n=== Used heap size: %d%n=== Free heap size: %d%n=== Maximum heap size: %d%n", usedHeapSize, freeHeapSize, maximumHeapSize); + System.out.flush(); if (watchdogExitOnTimeout) { - System.err.println("=== Image generator watchdog is aborting image generation. To configure the watchdog, use the options " + + System.out.println("=== Image generator watchdog is aborting image generation. To configure the watchdog, use the options " + SubstrateOptionsParser.commandArgument(SubstrateOptions.DeadlockWatchdogInterval, Integer.toString(watchdogInterval), null) + " and " + SubstrateOptionsParser.commandArgument(SubstrateOptions.DeadlockWatchdogExitOnTimeout, "+", null)); /* @@ -125,7 +125,7 @@ private static void threadDump() { printThreadInfo(ti); printLockInfo(ti.getLockedSynchronizers()); } - System.err.println(); + System.out.println(); } private static void printThreadInfo(ThreadInfo ti) { @@ -139,33 +139,33 @@ private static void printThreadInfo(ThreadInfo ti) { if (ti.isInNative()) { sb.append(" (running in native)"); } - System.err.println(sb.toString()); + System.out.println(sb.toString()); if (ti.getLockOwnerName() != null) { - System.err.println(" owned by " + ti.getLockOwnerName() + " Id=" + ti.getLockOwnerId()); + System.out.println(" owned by " + ti.getLockOwnerName() + " Id=" + ti.getLockOwnerId()); } StackTraceElement[] stacktrace = ti.getStackTrace(); MonitorInfo[] monitors = ti.getLockedMonitors(); for (int i = 0; i < stacktrace.length; i++) { StackTraceElement ste = stacktrace[i]; - System.err.println(" at " + ste.toString()); + System.out.println(" at " + ste.toString()); for (MonitorInfo mi : monitors) { if (mi.getLockedStackDepth() == i) { - System.err.println(" - locked " + mi); + System.out.println(" - locked " + mi); } } } - System.err.println(); + System.out.println(); } private static void printLockInfo(LockInfo[] locks) { if (locks.length > 0) { - System.err.println(" Locked synchronizers: count = " + locks.length); + System.out.println(" Locked synchronizers: count = " + locks.length); for (LockInfo li : locks) { - System.err.println(" - " + li); + System.out.println(" - " + li); } - System.err.println(); + System.out.println(); } } } diff --git a/substratevm/src/com.oracle.svm.hosted/src/com/oracle/svm/hosted/Log4ShellFeature.java b/substratevm/src/com.oracle.svm.hosted/src/com/oracle/svm/hosted/Log4ShellFeature.java index 53e5fcc9e25f..c5af2ea75d53 100644 --- a/substratevm/src/com.oracle.svm.hosted/src/com/oracle/svm/hosted/Log4ShellFeature.java +++ b/substratevm/src/com.oracle.svm.hosted/src/com/oracle/svm/hosted/Log4ShellFeature.java @@ -62,7 +62,7 @@ public class Log4ShellFeature implements InternalFeature { private static final Set targetMethods = Set.of("debug", "error", "fatal", "info", "log", "trace", "warn"); private static void warn(String warning) { - System.err.println(warning); + System.out.println(warning); } private static Optional getPomVersion(Class log4jClass) { diff --git a/substratevm/src/com.oracle.svm.hosted/src/com/oracle/svm/hosted/NativeImageClassLoaderSupport.java b/substratevm/src/com.oracle.svm.hosted/src/com/oracle/svm/hosted/NativeImageClassLoaderSupport.java index f02f9823bf3c..dd7ca217fc60 100644 --- a/substratevm/src/com.oracle.svm.hosted/src/com/oracle/svm/hosted/NativeImageClassLoaderSupport.java +++ b/substratevm/src/com.oracle.svm.hosted/src/com/oracle/svm/hosted/NativeImageClassLoaderSupport.java @@ -700,7 +700,7 @@ private void loadClassesFromPath(URI container, Path root, Path excludeRoot, Set boolean useFilter = root.equals(excludeRoot); if (useFilter) { String excludesStr = excludes.stream().map(Path::toString).collect(Collectors.joining(", ")); - System.err.println("Warning: Using directory " + excludeRoot + " on classpath is discouraged." + + System.out.println("Warning: Using directory " + excludeRoot + " on classpath is discouraged." + " Reading classes/resources from directories " + excludesStr + " will be suppressed."); } FileVisitor visitor = new SimpleFileVisitor<>() { diff --git a/substratevm/src/com.oracle.svm.hosted/src/com/oracle/svm/hosted/NativeImageGeneratorRunner.java b/substratevm/src/com.oracle.svm.hosted/src/com/oracle/svm/hosted/NativeImageGeneratorRunner.java index 8c412ba4f92a..a33b6753e2fc 100644 --- a/substratevm/src/com.oracle.svm.hosted/src/com/oracle/svm/hosted/NativeImageGeneratorRunner.java +++ b/substratevm/src/com.oracle.svm.hosted/src/com/oracle/svm/hosted/NativeImageGeneratorRunner.java @@ -445,7 +445,7 @@ private int buildImage(ImageClassLoader classLoader) { } if (pee.getExceptions().size() > 1) { - System.err.println(pee.getExceptions().size() + " fatal errors detected:"); + System.out.println(pee.getExceptions().size() + " fatal errors detected:"); } for (Throwable exception : pee.getExceptions()) { NativeImageGeneratorRunner.reportFatalError(exception); @@ -537,7 +537,7 @@ public static String getJavaVersion() { * @param e error to be reported. */ protected static void reportFatalError(Throwable e) { - System.err.print("Fatal error: "); + System.out.print("Fatal error: "); e.printStackTrace(); } @@ -548,7 +548,7 @@ protected static void reportFatalError(Throwable e) { * @param msg message to report. */ protected static void reportFatalError(Throwable e, String msg) { - System.err.print("Fatal error: " + msg); + System.out.print("Fatal error: " + msg); e.printStackTrace(); } @@ -558,7 +558,7 @@ protected static void reportFatalError(Throwable e, String msg) { * @param msg error message that is printed. */ public static void reportUserError(String msg) { - System.err.println("Error: " + msg); + System.out.println("Error: " + msg); } /** @@ -603,7 +603,7 @@ private static void info(String msg) { * @param msg warning message that is printed. */ private static void warn(String msg) { - System.err.println("Warning: " + msg); + System.out.println("Warning: " + msg); } public int build(ImageClassLoader imageClassLoader) { diff --git a/substratevm/src/com.oracle.svm.hosted/src/com/oracle/svm/hosted/NativeImageSystemIOWrappers.java b/substratevm/src/com.oracle.svm.hosted/src/com/oracle/svm/hosted/NativeImageSystemIOWrappers.java index 77e2a7f80744..b28a1acdf481 100644 --- a/substratevm/src/com.oracle.svm.hosted/src/com/oracle/svm/hosted/NativeImageSystemIOWrappers.java +++ b/substratevm/src/com.oracle.svm.hosted/src/com/oracle/svm/hosted/NativeImageSystemIOWrappers.java @@ -40,13 +40,17 @@ public class NativeImageSystemIOWrappers { NativeImageSystemIOWrappers() { outWrapper = new StdioWrapper(System.out); + // Checkstyle: allow System.err errWrapper = new StdioWrapper(System.err); + // Checkstyle: disallow System.err } void verifySystemOutErrReplacement() { String format = "%s was changed during image building. This is not allowed."; UserError.guarantee(System.out == outWrapper, format, "System.out"); + // Checkstyle: allow System.err UserError.guarantee(System.err == errWrapper, format, "System.err"); + // Checkstyle: disallow System.err } void replaceSystemOutErr() { diff --git a/substratevm/src/com.oracle.svm.hosted/src/com/oracle/svm/hosted/c/libc/HostedMuslLibC.java b/substratevm/src/com.oracle.svm.hosted/src/com/oracle/svm/hosted/c/libc/HostedMuslLibC.java index 8c65c19e18a1..dce1f1f76561 100644 --- a/substratevm/src/com.oracle.svm.hosted/src/com/oracle/svm/hosted/c/libc/HostedMuslLibC.java +++ b/substratevm/src/com.oracle.svm.hosted/src/com/oracle/svm/hosted/c/libc/HostedMuslLibC.java @@ -51,7 +51,7 @@ public boolean requiresLibCSpecificStaticJDKLibraries() { @Override public void checkIfLibCSupported() { if (!SubstrateOptions.StaticExecutable.getValue()) { - System.err.println("Warning: Cross-compiling a musl-based native-image that is not an executable is an experimental feature!" + + System.out.println("Warning: Cross-compiling a musl-based native-image that is not an executable is an experimental feature!" + "If omitting --static wasn't the intention, then --static should be used when compiling with --libc=musl"); } } diff --git a/substratevm/src/com.oracle.svm.hosted/src/com/oracle/svm/hosted/classinitialization/ClassInitializationFeature.java b/substratevm/src/com.oracle.svm.hosted/src/com/oracle/svm/hosted/classinitialization/ClassInitializationFeature.java index a8f6d3275819..0247454db160 100644 --- a/substratevm/src/com.oracle.svm.hosted/src/com/oracle/svm/hosted/classinitialization/ClassInitializationFeature.java +++ b/substratevm/src/com.oracle.svm.hosted/src/com/oracle/svm/hosted/classinitialization/ClassInitializationFeature.java @@ -190,7 +190,7 @@ public void afterAnalysis(AfterAnalysisAccess access) { .map(Class::getTypeName) .collect(Collectors.toList()); if (!unspecifiedClasses.isEmpty()) { - System.err.println("The following classes have unspecified initialization policy:" + System.lineSeparator() + String.join(System.lineSeparator(), unspecifiedClasses)); + System.out.println("The following classes have unspecified initialization policy:" + System.lineSeparator() + String.join(System.lineSeparator(), unspecifiedClasses)); UserError.abort("To fix the error either specify the initialization policy for given classes or set %s", SubstrateOptionsParser.commandArgument(ClassInitializationOptions.AssertInitializationSpecifiedForAllClasses, "-")); } diff --git a/substratevm/src/com.oracle.svm.hosted/src/com/oracle/svm/hosted/meta/TypeCheckBuilder.java b/substratevm/src/com.oracle.svm.hosted/src/com/oracle/svm/hosted/meta/TypeCheckBuilder.java index d80de19f4573..b4ba4803f44c 100644 --- a/substratevm/src/com.oracle.svm.hosted/src/com/oracle/svm/hosted/meta/TypeCheckBuilder.java +++ b/substratevm/src/com.oracle.svm.hosted/src/com/oracle/svm/hosted/meta/TypeCheckBuilder.java @@ -1746,7 +1746,7 @@ static boolean compareTypeIDResults(List types) { } }); if (!mismatchedTypes.isEmpty()) { - mismatchedTypes.forEach(System.err::println); + mismatchedTypes.forEach(System.out::println); throw new AssertionError("Verification of type assignment failed"); } } diff --git a/substratevm/src/com.oracle.svm.hosted/src/com/oracle/svm/hosted/reflect/serialize/SerializationFeature.java b/substratevm/src/com.oracle.svm.hosted/src/com/oracle/svm/hosted/reflect/serialize/SerializationFeature.java index ac3b4a973d19..cce4d02bca1b 100644 --- a/substratevm/src/com.oracle.svm.hosted/src/com/oracle/svm/hosted/reflect/serialize/SerializationFeature.java +++ b/substratevm/src/com.oracle.svm.hosted/src/com/oracle/svm/hosted/reflect/serialize/SerializationFeature.java @@ -259,7 +259,7 @@ public void beforeCompilation(BeforeCompilationAccess access) { } static void warn(String str) { - System.err.println("Warning: " + str); + System.out.println("Warning: " + str); } } diff --git a/substratevm/src/org.graalvm.polyglot.nativeapi/src/org/graalvm/polyglot/nativeapi/PolyglotNativeAPIFeature.java b/substratevm/src/org.graalvm.polyglot.nativeapi/src/org/graalvm/polyglot/nativeapi/PolyglotNativeAPIFeature.java index b7a65d588c14..8eb6a8da51a0 100644 --- a/substratevm/src/org.graalvm.polyglot.nativeapi/src/org/graalvm/polyglot/nativeapi/PolyglotNativeAPIFeature.java +++ b/substratevm/src/org.graalvm.polyglot.nativeapi/src/org/graalvm/polyglot/nativeapi/PolyglotNativeAPIFeature.java @@ -69,15 +69,14 @@ public void afterImageWrite(AfterImageWriteAccess access) { // on Darwin, change the `id` install name String id = System.getProperty("org.graalvm.polyglot.install_name_id"); if (id == null) { - String msg = String.format("Warning: no id passed through `org.graalvm.polyglot.install_name_id`:" + - "\n%s might include its absolute path as id (see man install_name_tool)", imagePath); - System.err.println(msg); + System.out.printf("Warning: no id passed through `org.graalvm.polyglot.install_name_id`:%n" + + "%s might include its absolute path as id (see man install_name_tool)%n", imagePath); } else { List command = Arrays.asList("install_name_tool", "-id", id, imagePath.toString()); try { int exitCode = FileUtils.executeCommand(command); if (exitCode != 0) { - System.err.printf("Failed to set `id` install name. install_name_tool exited with code %d%n", exitCode); + System.out.printf("Failed to set `id` install name. install_name_tool exited with code %d%n", exitCode); } } catch (IOException e) { throw new RuntimeException(e);