Upon OutOfMemoryError or StackOverflowError, unwind the stack

  to the first enclosing HANDLER-BIND, allowing it to bind a
  handler to STORAGE-CONDITION.
parent 6bb7cc6a
......@@ -930,7 +930,28 @@ public final class Java
}
}
};
private static final Primitive JRUN_EXCEPTION_PROTECTED =
new Primitive("jrun-exception-protected", PACKAGE_JAVA, true,
"closure") {
@Override
public LispObject execute(LispObject closure) {
Function fun = checkFunction(closure);
try {
return LispThread.currentThread().execute(closure);
}
catch (OutOfMemoryError oom) {
return error(new StorageCondition("Out of memory."));
}
catch (StackOverflowError oos) {
return error(new StorageCondition("Stack overflow."));
}
}
};
private static PropertyDescriptor getPropertyDescriptor(Object obj, LispObject propertyName) throws IntrospectionException {
String prop = ((AbstractString) propertyName).getStringValue();
BeanInfo beanInfo = Introspector.getBeanInfo(obj.getClass());
......
......@@ -105,8 +105,10 @@
(cons (list ,@(mapcar (lambda (x) `(cons ',(car x) ,(cadr x)))
bindings))
*handler-clusters*)))
(progn
,@forms)))
(java:jrun-exception-protected
(lambda ()
(progn
,@forms)))))
(defmacro handler-case (form &rest cases)
(let ((no-error-clause (assoc ':no-error cases)))
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment