Here is a patch to complete the functionality of this filter.
ChangeLog
2006-06-09 Kyle Galloway <[EMAIL PROTECTED]>
* gnu/classpath/jdwp/event/filters/ExceptionOnlyFilter.java:
Fixed matches method to match instead of throwing exception
Index: gnu/classpath/jdwp/event/filters/ExceptionOnlyFilter.java
===================================================================
RCS file: /sources/classpath/classpath/gnu/classpath/jdwp/event/filters/ExceptionOnlyFilter.java,v
retrieving revision 1.2
diff -u -r1.2 ExceptionOnlyFilter.java
--- gnu/classpath/jdwp/event/filters/ExceptionOnlyFilter.java 9 Mar 2006 23:18:29 -0000 1.2
+++ gnu/classpath/jdwp/event/filters/ExceptionOnlyFilter.java 9 Jun 2006 17:36:28 -0000
@@ -1,40 +1,40 @@
-/* ExceptionOnlyFilter.java --
- Copyright (C) 2005 Free Software Foundation
+/* ExceptionOnlyFilter.java -- filter for exception events
+ Copyright (C) 2005 Free Software Foundation
-This file is part of GNU Classpath.
+ This file is part of GNU Classpath.
-GNU Classpath is free software; you can redistribute it and/or modify
-it under the terms of the GNU General Public License as published by
-the Free Software Foundation; either version 2, or (at your option)
-any later version.
-
-GNU Classpath is distributed in the hope that it will be useful, but
-WITHOUT ANY WARRANTY; without even the implied warranty of
-MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
-General Public License for more details.
-
-You should have received a copy of the GNU General Public License
-along with GNU Classpath; see the file COPYING. If not, write to the
-Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
-02110-1301 USA.
-
-Linking this library statically or dynamically with other modules is
-making a combined work based on this library. Thus, the terms and
-conditions of the GNU General Public License cover the whole
-combination.
-
-As a special exception, the copyright holders of this library give you
-permission to link this library with independent modules to produce an
-executable, regardless of the license terms of these independent
-modules, and to copy and distribute the resulting executable under
-terms of your choice, provided that you also meet, for each linked
-terms of your choice, provided that you also meet, for each linked
-independent module, the terms and conditions of the license of that
-module. An independent module is a module which is not derived from
-or based on this library. If you modify this library, you may extend
-this exception to your version of the library, but you are not
-obligated to do so. If you do not wish to do so, delete this
-exception statement from your version. */
+ GNU Classpath is free software; you can redistribute it and/or modify
+ it under the terms of the GNU General Public License as published by
+ the Free Software Foundation; either version 2, or (at your option)
+ any later version.
+
+ GNU Classpath is distributed in the hope that it will be useful, but
+ WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ General Public License for more details.
+
+ You should have received a copy of the GNU General Public License
+ along with GNU Classpath; see the file COPYING. If not, write to the
+ Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
+ 02110-1301 USA.
+
+ Linking this library statically or dynamically with other modules is
+ making a combined work based on this library. Thus, the terms and
+ conditions of the GNU General Public License cover the whole
+ combination.
+
+ As a special exception, the copyright holders of this library give you
+ permission to link this library with independent modules to produce an
+ executable, regardless of the license terms of these independent
+ modules, and to copy and distribute the resulting executable under
+ terms of your choice, provided that you also meet, for each linked
+ terms of your choice, provided that you also meet, for each linked
+ independent module, the terms and conditions of the license of that
+ module. An independent module is a module which is not derived from
+ or based on this library. If you modify this library, you may extend
+ this exception to your version of the library, but you are not
+ obligated to do so. If you do not wish to do so, delete this
+ exception statement from your version. */
package gnu.classpath.jdwp.event.filters;
@@ -42,36 +42,37 @@
import gnu.classpath.jdwp.event.Event;
import gnu.classpath.jdwp.exception.InvalidClassException;
import gnu.classpath.jdwp.id.ReferenceTypeId;
+import gnu.classpath.jdwp.event.filters.ClassOnlyFilter;
/**
- * Restricts reported exceptions by their class and whether they are caught
- * or uncaught.
+ * Restricts reported exceptions by their class and whether they are caught or
+ * uncaught. This modifier can be used with exception event kinds only.
*
- * This modifier can be used with exception event kinds only.
- *
- * @author Keith Seitz ([EMAIL PROTECTED])
+ * @author Keith Seitz ([EMAIL PROTECTED])
*/
public class ExceptionOnlyFilter
- implements IEventFilter
+ implements IEventFilter
{
private ReferenceTypeId _refId;
+
private boolean _caught;
+
private boolean _uncaught;
/**
* Constructs a new ExceptionOnlyFilter
- *
- * @param refId ID of the exception to report
- * @param caught Report caught exceptions
- * @param uncaught Report uncaught exceptions
+ *
+ * @param refId ID of the exception to report
+ * @param caught Report caught exceptions
+ * @param uncaught Report uncaught exceptions
* @throws InvalidClassException if refid is invalid
*/
- public ExceptionOnlyFilter (ReferenceTypeId refId, boolean caught,
- boolean uncaught)
- throws InvalidClassException
+ public ExceptionOnlyFilter(ReferenceTypeId refId, boolean caught,
+ 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;
@@ -80,42 +81,75 @@
/**
* Returns the exception class to report (<code>null</code> for all)
- *
+ *
* @return the class's ID
*/
- public ReferenceTypeId getType ()
+ public ReferenceTypeId getType()
{
return _refId;
}
/**
* Report caught exceptions?
- *
+ *
* @return whether to report caught exceptions
*/
- public boolean forCaught ()
+ public boolean forCaught()
{
return _caught;
}
/**
* Report uncaught exceptions?
- *
+ *
* @return whether to report uncaught exceptions
*/
- public boolean forUncaught ()
+ 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;
+ // check to see if the class is matched correctly if required
+ if (_refId != null)
+ {
+ try
+ {
+ ClassOnlyFilter cof = new ClassOnlyFilter(_refId);
+ classMatch = cof.matches(event);
+ }
+ catch (InvalidClassException ex)
+ {
+ return false;
+ }
+ }
+ // if the class doesn't match the event doesn't match
+ if (classMatch == false)
+ return false;
+ // otherwise continue to check caught/uncaught status and filter
+ Object exception = event.getParameter(Event.EVENT_EXCEPTION_CLASS);
+ Boolean caught = (Boolean) event.getParameter(Event.EVENT_EXCEPTION_CAUGHT);
+
+ // if the exception was caught
+ if (caught.booleanValue())
+ {
+ if (_caught)
+ return true;
+ }
+ // if the exception was uncaught
+ else
+ {
+ if (_uncaught)
+ return true;
+ }
+
+ return false;
}
}