diff --git a/core/src/main/java/org/teavm/backend/c/generate/BufferedCodeWriter.java b/core/src/main/java/org/teavm/backend/c/generate/BufferedCodeWriter.java index 39ae8fcc2..2ec3b60e9 100644 --- a/core/src/main/java/org/teavm/backend/c/generate/BufferedCodeWriter.java +++ b/core/src/main/java/org/teavm/backend/c/generate/BufferedCodeWriter.java @@ -131,7 +131,7 @@ public class BufferedCodeWriter extends CodeWriter { return; } if (isNewLine) { - if (pendingFileName != null || pendingLineNumber >= 0) { + if (pendingFileName != null && pendingLineNumber >= 0) { printLineDirective(pendingFileName, pendingLineNumber); pendingLineNumber = -1; pendingFileName = null; diff --git a/core/src/main/java/org/teavm/runtime/ExceptionHandling.java b/core/src/main/java/org/teavm/runtime/ExceptionHandling.java index 4ce6bc8c7..f22926d02 100644 --- a/core/src/main/java/org/teavm/runtime/ExceptionHandling.java +++ b/core/src/main/java/org/teavm/runtime/ExceptionHandling.java @@ -55,21 +55,23 @@ public final class ExceptionHandling { while (location != null) { MethodLocation methodLocation = location.method; - Console.printString(" at "); - if (methodLocation.className == null || methodLocation.methodName == null) { - Console.printString("(Unknown method)"); - } else { - Console.printString(methodLocation.className.value); - Console.printString("."); - Console.printString(methodLocation.methodName.value); + if (methodLocation != null) { + Console.printString(" at "); + if (methodLocation.className == null || methodLocation.methodName == null) { + Console.printString("(Unknown method)"); + } else { + Console.printString(methodLocation.className.value); + Console.printString("."); + Console.printString(methodLocation.methodName.value); + } + Console.printString("("); + if (methodLocation.fileName != null && location.lineNumber >= 0) { + Console.printString(methodLocation.fileName.value); + Console.printString(":"); + Console.printInt(location.lineNumber); + } + Console.printString(")\n"); } - Console.printString("("); - if (methodLocation.fileName != null && location.lineNumber >= 0) { - Console.printString(methodLocation.fileName.value); - Console.printString(":"); - Console.printInt(location.lineNumber); - } - Console.printString(")\n"); location = location.next; }