diff options
Diffstat (limited to 'libjava/classpath/gnu/classpath/jdwp/event/filters/ExceptionOnlyFilter.java')
-rw-r--r-- | libjava/classpath/gnu/classpath/jdwp/event/filters/ExceptionOnlyFilter.java | 62 |
1 files changed, 32 insertions, 30 deletions
diff --git a/libjava/classpath/gnu/classpath/jdwp/event/filters/ExceptionOnlyFilter.java b/libjava/classpath/gnu/classpath/jdwp/event/filters/ExceptionOnlyFilter.java index cf6c0704daf..8bb56ed78f7 100644 --- a/libjava/classpath/gnu/classpath/jdwp/event/filters/ExceptionOnlyFilter.java +++ b/libjava/classpath/gnu/classpath/jdwp/event/filters/ExceptionOnlyFilter.java @@ -1,5 +1,5 @@ -/* ExceptionOnlyFilter.java -- - Copyright (C) 2005 Free Software Foundation +/* ExceptionOnlyFilter.java -- filter for excetions by caught/uncaught and type + Copyright (C) 2005, 2006 Free Software Foundation This file is part of GNU Classpath. @@ -61,7 +61,7 @@ public class ExceptionOnlyFilter /** * Constructs a new ExceptionOnlyFilter * - * @param refId ID of the exception to report + * @param refId ID of the exception to report(null for all exceptions) * @param caught Report caught exceptions * @param uncaught Report uncaught exceptions * @throws InvalidClassException if refid is invalid @@ -70,8 +70,8 @@ public class ExceptionOnlyFilter boolean uncaught) throws InvalidClassException { - if (refId == null || refId.getReference().get () == null) - throw new InvalidClassException (refId.getId ()); + if (refId != null && refId.getReference().get() == null) + throw new InvalidClassException(refId.getId()); _refId = refId; _caught = caught; @@ -88,34 +88,36 @@ public class ExceptionOnlyFilter return _refId; } - /** - * Report caught exceptions? - * - * @return whether to report caught exceptions - */ - public boolean forCaught () - { - return _caught; - } - - /** - * Report uncaught exceptions? - * - * @return whether to report uncaught exceptions - */ - public boolean forUncaught () - { - return _uncaught; - } - + /** * Does the given event match the filter? - * - * @param event the <code>Event</code> to scrutinize + * + * @param event the <code>Event</code> to scrutinize */ - public boolean matches (Event event) + public boolean matches(Event event) { - // FIXME - throw new RuntimeException ("ExceptionOnlyFilter.matches not implemented"); + boolean classMatch = true; + + // if not allowing all exceptions check if the exception matches + if (_refId != null) + { + try + { + Class klass + = (Class) event.getParameter(Event.EVENT_EXCEPTION_CLASS); + classMatch = klass == _refId.getType(); + } + catch (InvalidClassException ex) + { + classMatch = false; + } + } + + // check against the caught and uncaught options + Boolean caught + = (Boolean) event.getParameter(Event.EVENT_EXCEPTION_CAUGHT); + + return classMatch && ((caught.booleanValue()) ? _caught : _uncaught); } + } |