Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -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() {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -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;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -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) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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) {
Expand Down Expand Up @@ -311,7 +311,7 @@ private static void generate(Iterator<String> 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))) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,7 @@ public static HierarchyFilterNode generateFromModules(String[] moduleNames, Incl
private static void checkDependencies(Module module, Set<String> 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);
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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")
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -271,7 +271,7 @@ public void processEntry(EconomicMap<String, ?> entry, ConfigurationSet configur
break;
}
default:
System.err.println("Unsupported reflection method: " + function);
System.out.println("Unsupported reflection method: " + function);
}
}

Expand Down
15 changes: 15 additions & 0 deletions substratevm/src/com.oracle.svm.core/.checkstyle_checks.xml
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,21 @@
<metadata name="com.atlassw.tools.eclipse.checkstyle.comment" value="Disable Class.getSimpleName calls"/>
</module>

<module name="RegexpSinglelineJava">
<property name="id" value="systemErr"/>
<metadata name="net.sf.eclipsecs.core.comment" value="Disallow calls to System.err."/>
<property name="severity" value="error"/>
<property name="format" value="System\.err"/>
<property name="message" value="Calls to System.err are restricted. Please use logging or System.out instead. (Use &quot;// Checkstyle: allow System.err ... // Checkstyle: disallow System.err&quot; to disable this check.)"/>
<property name="ignoreComments" value="true"/>
</module>
<module name="SuppressionCommentFilter">
<property name="offCommentFormat" value="Checkstyle: allow System.err"/>
<property name="onCommentFormat" value="Checkstyle: disallow System.err"/>
<property name="idFormat" value="systemErr"/>
<metadata name="com.atlassw.tools.eclipse.checkstyle.comment" value="Disable System.err calls"/>
</module>

<module name="AvoidStarImport">
<property name="allowClassImports" value="false"/>
<property name="allowStaticMemberImports" value="false"/>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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);
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -146,7 +146,7 @@ protected void onValueUpdate(EconomicMap<OptionKey<?>, 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.");
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -107,7 +107,7 @@ public static boolean parseHostedOption(String optionPrefix, EconomicMap<String,
if (deprecationMessage != null && !deprecationMessage.isEmpty()) {
message += ": " + deprecationMessage;
}
System.err.println(message);
System.out.println(message);
}
return true;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -133,7 +133,7 @@ public void addProxyClass(Class<?>... 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;
}
});
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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);
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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 <clinit>.");
System.out.println("Trace class initialization requested for " + className + " but the class has not been instrumented with <clinit>.");
}
}
if (advisor.shouldTraceObjectInstantiation(className)) {
Expand All @@ -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.");
}
}

Expand Down Expand Up @@ -396,8 +396,8 @@ private byte[] maybeInstrumentClassWithClinit(String clazzName, byte[] clazzData
return writer.toByteArray();
} catch (Throwable e) {
String targetClazzName = clazzName != null ? clazzName : "<unknown class>";
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;
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -1415,10 +1415,10 @@ private static void performBuild(BuildConfiguration config, Function<BuildConfig
try {
build(config, nativeImageProvider);
} catch (NativeImageError e) {
NativeImage.show(System.err::println, "Error: " + e.getMessage());
NativeImage.show(System.out::println, "Error: " + e.getMessage());
Throwable cause = e.getCause();
while (cause != null) {
NativeImage.show(System.err::println, "Caused by: " + cause);
NativeImage.show(System.out::println, "Caused by: " + cause);
cause = cause.getCause();
}
if (config.getBuildArgs().contains("--verbose")) {
Expand Down Expand Up @@ -1734,7 +1734,7 @@ void showMessagePart(String message) {
}

public static void showWarning(String message) {
show(System.err::println, "Warning: " + message);
show(System.out::println, "Warning: " + message);
}

@SuppressWarnings("serial")
Expand Down
15 changes: 15 additions & 0 deletions substratevm/src/com.oracle.svm.hosted/.checkstyle_checks.xml
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,21 @@
<metadata name="com.atlassw.tools.eclipse.checkstyle.comment" value="Disable Class.getSimpleName calls"/>
</module>

<module name="RegexpSinglelineJava">
<property name="id" value="systemErr"/>
<metadata name="net.sf.eclipsecs.core.comment" value="Disallow calls to System.err."/>
<property name="severity" value="error"/>
<property name="format" value="System\.err"/>
<property name="message" value="Calls to System.err are restricted. Please use logging or System.out instead. (Use &quot;// Checkstyle: allow System.err ... // Checkstyle: disallow System.err&quot; to disable this check.)"/>
<property name="ignoreComments" value="true"/>
</module>
<module name="SuppressionCommentFilter">
<property name="offCommentFormat" value="Checkstyle: allow System.err"/>
<property name="onCommentFormat" value="Checkstyle: disallow System.err"/>
<property name="idFormat" value="systemErr"/>
<metadata name="com.atlassw.tools.eclipse.checkstyle.comment" value="Disable System.err calls"/>
</module>

<module name="AvoidStarImport">
<property name="allowClassImports" value="false"/>
<property name="allowStaticMemberImports" value="false"/>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@ private Class<?> resolveType(String typeName, boolean warn) {
}
TypeResult<Class<?>> 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();
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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));
/*
Expand Down Expand Up @@ -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) {
Expand All @@ -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();
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,7 @@ public class Log4ShellFeature implements InternalFeature {
private static final Set<String> 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<String> getPomVersion(Class<?> log4jClass) {
Expand Down
Loading