Skip to content

Commit

Permalink
Fix NPE and bug in setLastError()
Browse files Browse the repository at this point in the history
831ec18 did not fix the NPE
  • Loading branch information
fniephaus committed Mar 11, 2021
1 parent 7599fe2 commit 6a294dd
Showing 1 changed file with 4 additions and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -1603,18 +1603,18 @@ protected static final long identityHashCode(@SuppressWarnings("unused") final O
@GenerateNodeFactory
@SqueakPrimitive(names = "primitiveGetLastError")
protected abstract static class PrimGetLastErrorNode extends AbstractPrimitiveNode {
private static final Exception NO_EXCEPTION = new Exception("No exception");
private static Exception lastError = NO_EXCEPTION;
private static Exception lastError = new Exception("No exception");

@Specialization
@TruffleBoundary
protected static final NativeObject doGetLastError(@SuppressWarnings("unused") final Object receiver,
@CachedContext(SqueakLanguage.class) final SqueakImageContext image) {
return image.asByteString(lastError.getMessage());
final String message = lastError.getMessage();
return image.asByteString(message != null ? message : lastError.toString());
}

protected static final void setLastError(final Exception e) {
lastError = e != null ? lastError : NO_EXCEPTION;
lastError = e;
LogUtils.INTEROP.fine(() -> MiscUtils.toString(lastError));
}
}
Expand Down

0 comments on commit 6a294dd

Please sign in to comment.