Full source scan of "catch (Throwable";

  remove lots of instances, or make the catch statement more
  specific, e.g. replace Throwable by IOException.
parent 7aee31cf
......@@ -294,23 +294,16 @@ public abstract class AbstractArray extends LispObject
@Override
public int psxhash()
{
try {
long result = 128387; // Chosen at random.
final int rank = getRank();
int limit = rank < 4 ? rank : 4;
for (int i = 0; i < limit; i++)
result = mix(result, getDimension(i));
final int length = getTotalSize();
limit = length < 4 ? length : 4;
for (int i = 0; i < length; i++)
result = mix(result, AREF(i).psxhash());
return (int) (result & 0x7fffffff);
}
catch (Throwable t) {
// Shouldn't happen.
Debug.trace(t);
return 0;
}
long result = 128387; // Chosen at random.
final int rank = getRank();
int limit = rank < 4 ? rank : 4;
for (int i = 0; i < limit; i++)
result = mix(result, getDimension(i));
final int length = getTotalSize();
limit = length < 4 ? length : 4;
for (int i = 0; i < length; i++)
result = mix(result, AREF(i).psxhash());
return (int) (result & 0x7fffffff);
}
/** Returns a newly allocated array or the current array with
......
......@@ -276,21 +276,12 @@ public abstract class AbstractVector extends AbstractArray
@Override
public int psxhash()
{
try
{
final int length = length();
final int limit = length < 4 ? length : 4;
long result = 48920713; // Chosen at random.
for (int i = 0; i < limit; i++)
result = mix(result, AREF(i).psxhash());
return (int) (result & 0x7fffffff);
}
catch (Throwable t)
{
// Shouldn't happen.
Debug.trace(t);
return 0;
}
final int length = length();
final int limit = length < 4 ? length : 4;
long result = 48920713; // Chosen at random.
for (int i = 0; i < limit; i++)
result = mix(result, AREF(i).psxhash());
return (int) (result & 0x7fffffff);
}
public abstract AbstractArray adjustArray(int size,
......
......@@ -291,13 +291,6 @@ public class BuiltInClass extends LispClass
static
{
try
{
StandardClass.initializeStandardClasses();
}
catch (Throwable t)
{
Debug.trace(t);
}
StandardClass.initializeStandardClasses();
}
}
......@@ -98,15 +98,8 @@ public class Condition extends StandardObject
{
super(StandardClass.CONDITION);
Debug.assertTrue(slots.length == 2);
try
{
setFormatControl(message);
setFormatArguments(NIL);
}
catch (Throwable t)
{
Debug.trace(t);
}
setFormatControl(message);
setFormatArguments(NIL);
}
public final LispObject getFormatControl()
......@@ -177,11 +170,7 @@ public class Condition extends StandardObject
LispObject formatControl = getFormatControl();
if (formatControl != NIL)
{
try
{
return format(formatControl, getFormatArguments());
}
catch (Throwable t) {}
return format(formatControl, getFormatArguments());
}
return unreadableString(typeOf().writeToString());
}
......
......@@ -57,15 +57,9 @@ public final class Go extends ControlTransfer
@Override
public LispObject getCondition()
{
try {
StringBuffer sb = new StringBuffer("No tag named ");
sb.append(tag.writeToString());
sb.append(" is currently visible");
return new ControlError(sb.toString());
}
catch (Throwable t) {
Debug.trace(t);
return new Condition();
}
StringBuffer sb = new StringBuffer("No tag named ");
sb.append(tag.writeToString());
sb.append(" is currently visible");
return new ControlError(sb.toString());
}
}
......@@ -75,31 +75,28 @@ public final class Interpreter
if (interpreter != null)
return null;
interpreter = new Interpreter();
try {
if (args != null)
preprocessCommandLineArguments(args);
if (!noinform) {
Stream out = getStandardOutput();
out._writeString(banner());
out._finishOutput();
}
if (noinform)
_NOINFORM_.setSymbolValue(T);
else {
double uptime = (System.currentTimeMillis() - Main.startTimeMillis) / 1000.0;
getStandardOutput()._writeString("Low-level initialization completed in " +
uptime + " seconds.\n");
}
initializeLisp();
initializeTopLevel();
if (!noinit)
processInitializationFile();
if (args != null)
postprocessCommandLineArguments(args);
if (args != null)
preprocessCommandLineArguments(args);
if (!noinform) {
Stream out = getStandardOutput();
out._writeString(banner());
out._finishOutput();
}
catch (Throwable t) {
t.printStackTrace();
if (noinform)
_NOINFORM_.setSymbolValue(T);
else {
double uptime = (System.currentTimeMillis() - Main.startTimeMillis) / 1000.0;
getStandardOutput()._writeString("Low-level initialization completed in " +
uptime + " seconds.\n");
}
initializeLisp();
initializeTopLevel();
if (!noinit)
processInitializationFile();
if (args != null)
postprocessCommandLineArguments(args);
return interpreter;
}
......@@ -112,15 +109,12 @@ public final class Interpreter
if (interpreter != null)
return null;
interpreter = new Interpreter(in, out, initialDirectory);
try {
Stream stdout = getStandardOutput();
stdout._writeLine(version);
stdout._writeString(banner());
stdout._finishOutput();
}
catch (Throwable t) {
t.printStackTrace();
}
Stream stdout = getStandardOutput();
stdout._writeLine(version);
stdout._writeString(banner());
stdout._finishOutput();
initializeJLisp();
initializeTopLevel();
processInitializationFile();
......@@ -144,12 +138,7 @@ public final class Interpreter
new Stream(outputStream, Symbol.CHARACTER));
if (!initialDirectory.endsWith(File.separator))
initialDirectory = initialDirectory.concat(File.separator);
try {
Symbol.DEFAULT_PATHNAME_DEFAULTS.setSymbolValue(new Pathname(initialDirectory));
}
catch (Throwable t) {
Debug.trace(t);
}
Symbol.DEFAULT_PATHNAME_DEFAULTS.setSymbolValue(new Pathname(initialDirectory));
}
// Interface.
......@@ -170,17 +159,17 @@ public final class Interpreter
public static synchronized void initializeJLisp()
{
if (!initialized) {
Symbol.FEATURES.setSymbolValue(new Cons(Keyword.J,
Symbol.FEATURES.getSymbolValue()));
Load.loadSystemFile("boot.lisp", false, false, false);
try {
Symbol.FEATURES.setSymbolValue(new Cons(Keyword.J,
Symbol.FEATURES.getSymbolValue()));
Load.loadSystemFile("boot.lisp", false, false, false);
Class.forName("org.armedbear.j.LispAPI");
Load.loadSystemFile("j.lisp");
}
catch (Throwable t) {
// ### FIXME exception
t.printStackTrace();
}
catch (ClassNotFoundException e) { } // FIXME: what to do?
Load.loadSystemFile("j.lisp");
initialized = true;
}
}
......@@ -190,18 +179,14 @@ public final class Interpreter
private static synchronized void initializeTopLevel()
{
if (!topLevelInitialized) {
try {
// Resolve top-level-loop autoload.
Symbol TOP_LEVEL_LOOP = intern("TOP-LEVEL-LOOP", PACKAGE_TPL);
LispObject tplFun = TOP_LEVEL_LOOP.getSymbolFunction();
if (tplFun instanceof Autoload) {
Autoload autoload = (Autoload) tplFun;
autoload.load();
}
}
catch (Throwable t) {
t.printStackTrace();
// Resolve top-level-loop autoload.
Symbol TOP_LEVEL_LOOP = intern("TOP-LEVEL-LOOP", PACKAGE_TPL);
LispObject tplFun = TOP_LEVEL_LOOP.getSymbolFunction();
if (tplFun instanceof Autoload) {
Autoload autoload = (Autoload) tplFun;
autoload.load();
}
topLevelInitialized = true;
}
}
......@@ -216,8 +201,8 @@ public final class Interpreter
return;
}
}
catch (Throwable t) {
t.printStackTrace();
catch (IOException e) {
e.printStackTrace();
}
}
......@@ -385,36 +370,26 @@ public final class Interpreter
private static void reportError(ControlTransfer c, LispThread thread)
{
try {
getStandardInput().clearInput();
Stream out = getStandardOutput();
out.freshLine();
Condition condition = (Condition) c.getCondition();
out._writeLine("Error: unhandled condition: " +
condition.writeToString());
if (thread != null)
thread.printBacktrace();
}
catch (Throwable t) {
}
getStandardInput().clearInput();
Stream out = getStandardOutput();
out.freshLine();
Condition condition = (Condition) c.getCondition();
out._writeLine("Error: unhandled condition: " +
condition.writeToString());
if (thread != null)
thread.printBacktrace();
}
private static void reportError(UnhandledCondition c, LispThread thread)
{
try {
getStandardInput().clearInput();
Stream out = getStandardOutput();
out.freshLine();
Condition condition = (Condition) c.getCondition();
out._writeLine("Error: unhandled condition: " +
condition.writeToString());
if (thread != null)
thread.printBacktrace();
}
catch (Throwable t) {
}
getStandardInput().clearInput();
Stream out = getStandardOutput();
out.freshLine();
Condition condition = (Condition) c.getCondition();
out._writeLine("Error: unhandled condition: " +
condition.writeToString());
if (thread != null)
thread.printBacktrace();
}
public void kill()
......@@ -500,7 +475,7 @@ public final class Interpreter
condition.typeOf().writeToString() + ':');
Debug.trace(" " + condition.writeToString());
}
catch (Throwable t) {}
catch (Throwable t) {} // catch any exception to throw below
finally {
thread.resetSpecialBindings(mark);
}
......@@ -511,13 +486,8 @@ public final class Interpreter
public static final LispObject readFromString(String s)
{
try {
return new StringInputStream(s).read(true, NIL, false,
LispThread.currentThread());
}
catch (Throwable t) {
return null;
}
return new StringInputStream(s).read(true, NIL, false,
LispThread.currentThread());
}
// For j.
......
......@@ -696,30 +696,23 @@ public final class Java
if (args.length < 1)
error(new WrongNumberOfArgumentsException(this));
LispObject object = args[0];
try {
if (args.length > 1) {
LispObject type = args[1];
if (type == Keyword.BOOLEAN) {
if (object == NIL)
return JavaObject.getInstance(Boolean.FALSE);
else
return JavaObject.getInstance(Boolean.TRUE);
}
if (type == Keyword.REF) {
if (object == NIL)
return JavaObject.getInstance(null);
else
throw new Error();
}
// other special cases come here
if (args.length > 1) {
LispObject type = args[1];
if (type == Keyword.BOOLEAN) {
if (object == NIL)
return JavaObject.getInstance(Boolean.FALSE);
else
return JavaObject.getInstance(Boolean.TRUE);
}
return JavaObject.getInstance(object.javaInstance());
}
catch (Throwable t) {
error(new LispError("MAKE-IMMEDIATE-OBJECT: not implemented"));
if (type == Keyword.REF) {
if (object == NIL)
return JavaObject.getInstance(null);
else
error(new LispError("MAKE-IMMEDIATE-OBJECT: not implemented"));
}
// other special cases come here
}
// Not reached.
return NIL;
return JavaObject.getInstance(object.javaInstance());
}
};
......
......@@ -33,6 +33,8 @@
package org.armedbear.lisp;
import static org.armedbear.lisp.Lisp.*;
import java.util.Collections;
import java.util.HashSet;
import java.util.Set;
......@@ -70,7 +72,7 @@ public class JavaClassLoader extends ClassLoader {
}
public Class<?> loadClassFromByteArray(byte[] classbytes) {
return loadClassFromByteArray(null, classbytes);
return loadClassFromByteArray(null, classbytes);
}
public Class<?> loadClassFromByteArray(String className,
......@@ -87,9 +89,9 @@ public class JavaClassLoader extends ClassLoader {
}
}
}
catch (LinkageError e) {
throw e;
}
catch (LinkageError e) {
throw e;
}
catch (Throwable t) {
Debug.trace(t);
}
......@@ -106,6 +108,10 @@ public class JavaClassLoader extends ClassLoader {
return c;
}
}
catch (VerifyError e)
{
error(new LispError("Class verification failed: " + e.getMessage()));
}
catch (Throwable t) {
Debug.trace(t);
}
......
......@@ -49,31 +49,16 @@ public final class Layout extends LispObject
{
this.lispClass = lispClass;
Debug.assertTrue(instanceSlots.listp());
int length = 0;
try
{
length = instanceSlots.length();
}
catch (Throwable t)
{
// Shouldn't happen.
Debug.trace(t);
}
int length = instanceSlots.length();
slotNames = new LispObject[length];
int i = 0;
try
{
while (instanceSlots != NIL)
{
slotNames[i++] = instanceSlots.car();
instanceSlots = instanceSlots.cdr();
}
}
catch (Throwable t)
while (instanceSlots != NIL)
{
// Shouldn't happen.
Debug.trace(t);
slotNames[i++] = instanceSlots.car();
instanceSlots = instanceSlots.cdr();
}
Debug.assertTrue(i == length);
this.sharedSlots = sharedSlots;
slotTable = initializeSlotTable(slotNames);
......@@ -153,16 +138,9 @@ public final class Layout extends LispObject
protected LispObject generateSlotDefinitions()
{
LispObject list = NIL;
try
{
for (int i = slotNames.length; i-- > 0;)
list = list.push(new SlotDefinition(slotNames[i], NIL));
}
catch (Throwable t)
{
// Shouldn't happen.
Debug.trace(t);
}
for (int i = slotNames.length; i-- > 0;)
list = list.push(new SlotDefinition(slotNames[i], NIL));
return list;
}
......
This diff is collapsed.
......@@ -121,7 +121,7 @@ public class LispStackFrame
try {
result = unreadableString(LISP_STACK_FRAME + " "
+ toLispString().getStringValue());
} catch (Throwable t) {
} catch (Throwable t) { // error while printing stack
Debug.trace("Serious printing error: ");
Debug.trace(t);
result = unreadableString(LISP_STACK_FRAME);
......@@ -192,7 +192,7 @@ public class LispStackFrame
String result;
try {
result = this.toLispList().writeToString();
} catch (Throwable t) {
} catch (Throwable t) { // error while printing stack
Debug.trace("Serious printing error: ");
Debug.trace(t);
result = unreadableString("LISP-STACK-FRAME");
......
......@@ -90,7 +90,7 @@ public final class LispThread extends LispObject
catch (ThreadDestroyed ignored) {
// Might happen.
}
catch (Throwable t) {
catch (Throwable t) { // any error: process thread interrupts
if (isInterrupted()) {
processThreadInterrupts();
}
......@@ -723,29 +723,24 @@ public final class LispThread extends LispObject
public void printBacktrace(int limit)
{
if (stack != null) {
try {
int count = 0;
Stream out =
checkCharacterOutputStream(Symbol.TRACE_OUTPUT.symbolValue());
out._writeLine("Evaluation stack:");
int count = 0;
Stream out =
checkCharacterOutputStream(Symbol.TRACE_OUTPUT.symbolValue());
out._writeLine("Evaluation stack:");
out._finishOutput();
StackFrame s = stack;
while (s != null) {
out._writeString(" ");
out._writeString(String.valueOf(count));
out._writeString(": ");
pprint(s.toLispList(), out.getCharPos(), out);
out.terpri();
out._finishOutput();
StackFrame s = stack;
while (s != null) {
out._writeString(" ");
out._writeString(String.valueOf(count));
out._writeString(": ");
pprint(s.toLispList(), out.getCharPos(), out);
out.terpri();
out._finishOutput();
if (limit > 0 && ++count == limit)
break;
s = s.next;
}
}
catch (Throwable t) {
t.printStackTrace();
if (limit > 0 && ++count == limit)
break;
s = s.next;
}
}
}
......@@ -755,17 +750,12 @@ public final class LispThread extends LispObject
LispObject result = NIL;
if (stack != null) {
int count = 0;
try {
StackFrame s = stack;
while (s != null) {
result = result.push(s);
if (limit > 0 && ++count == limit)
break;
s = s.getNext();
}
}
catch (Throwable t) {
t.printStackTrace();
StackFrame s = stack;
while (s != null) {
result = result.push(s);
if (limit > 0 && ++count == limit)
break;
s = s.getNext();
}
}
return result.nreverse();
......
......@@ -179,7 +179,7 @@ public final class Load
try {
zipfile = ZipCache.getZip(zipFileName);
}
catch (Throwable t) {
catch (IOException e) {
return error (new FileError("Zip file not found: " + filename, pathname));
}
ZipEntry entry = zipfile.getEntry(zipEntryName);
......@@ -373,10 +373,8 @@ public final class Load
catch (ZipException e) {
// Fall through.
}
catch (Throwable t) {
Debug.trace(t);
in = null;
// Fall through.
catch (IOException e) {
// fall through
}
}
if (in == null) {
......@@ -672,7 +670,7 @@ public final class Load
&& bytes[2] == 0x03
&& bytes[3] == 0x04);
}
catch (Throwable t) {
catch (Throwable t) { // any error probably means 'no'
return false;
}
finally {
......@@ -680,7 +678,7 @@ public final class Load
try {
in.close();
}
catch (Throwable t) {}
catch (IOException e) {} // ignore exceptions
}
}
}
......
......@@ -268,23 +268,11 @@ public final class MathFunctions
im);
}
if (arg instanceof SingleFloat) {
try {
double d = Math.sinh(((SingleFloat)arg).value);
return new SingleFloat((float)d);
}
catch (Throwable t) {
Debug.trace(t);
// Fall through...
}
double d = Math.sinh(((SingleFloat)arg).value);
return new SingleFloat((float)d);
} else if (arg instanceof DoubleFloat) {
try {
double d = Math.sinh(((DoubleFloat)arg).value);
return new DoubleFloat(d);
}
catch (Throwable t) {
Debug.trace(t);
// Fall through...
}
double d = Math.sinh(((DoubleFloat)arg).value);
return new DoubleFloat(d);
}
LispObject result = exp(arg);
result = result.subtract(exp(arg.multiplyBy(Fixnum.MINUS_ONE)));
......@@ -318,23 +306,11 @@ public final class MathFunctions
im);
}
if (arg instanceof SingleFloat) {
try {
double d = Math.cosh(((SingleFloat)arg).value);
return new SingleFloat((float)d);
}
catch (Throwable t) {
Debug.trace(t);
// Fall through...
}
double d = Math.cosh(((SingleFloat)arg).value);
return new SingleFloat((float)d);
} else if (arg instanceof DoubleFloat) {
try {
double d = Math.cosh(((DoubleFloat)arg).value);
return new DoubleFloat(d);
}
catch (Throwable t) {
Debug.trace(t);
// Fall through...
}
double d = Math.cosh(((DoubleFloat)arg).value);
return new DoubleFloat(d);
}
LispObject result = exp(arg);
result = result.add(exp(arg.multiplyBy(Fixnum.MINUS_ONE)));
......@@ -356,23 +332,11 @@ public final class MathFunctions
public LispObject execute(LispObject arg)
{
if (arg instanceof SingleFloat) {
try {
double d = Math.tanh(((SingleFloat)arg).value);
return new SingleFloat((float)d);
}
catch (Throwable t) {
Debug.trace(t);
// Fall through...