Changeset 10269


Ignore:
Timestamp:
10/29/05 13:25:45 (16 years ago)
Author:
asimon
Message:

Experiment in progress: search for registered superclasses of
exceptions, and skip the reflection layer. Only JNEW is affected for
now.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/j/src/org/armedbear/lisp/Java.java

    r10266 r10269  
    33 *
    44 * Copyright (C) 2002-2005 Peter Graves, Andras Simon
    5  * $Id: Java.java,v 1.59 2005-10-28 16:45:10 piso Exp $
     5 * $Id: Java.java,v 1.60 2005-10-29 13:25:45 asimon Exp $
    66 *
    77 * This program is free software; you can redistribute it and/or
     
    5151        }
    5252    };
     53
     54
     55    private static Symbol getCondition(Class cl) throws ConditionThrowable
     56    {
     57  Class o = classForName("java.lang.Object");
     58
     59      for (Class c = cl ; c != o ; c = c.getSuperclass())
     60                if (registeredExceptions.containsKey(c))
     61      return (Symbol)registeredExceptions.get(c);
     62        return null;
     63    }
    5364
    5465    // ### jclass name-or-class-ref => class-ref
     
    377388            }
    378389            catch (Throwable t) {
    379                 Class throwableClass = t.getClass();
    380                 if (registeredExceptions.containsKey(throwableClass)) {
    381                     signal((Symbol)registeredExceptions.get(throwableClass), new SimpleString(getMessage(t)));
    382                 }
    383                 signal(new JavaException(t));
     390                if (t instanceof InvocationTargetException)
     391                    t = t.getCause();
     392                Symbol condition = getCondition(t.getClass());
     393                if (condition == null)
     394                   signal(new JavaException(t));
     395                else
     396                   signal(condition, new SimpleString(getMessage(t)));
    384397            }
    385398            // Not reached.
Note: See TracChangeset for help on using the changeset viewer.