Here you can find the source of isExceptionObject(Class o)
public static boolean isExceptionObject(Class o) throws AssertionError
//package com.java2s; /*//www.j ava 2 s.c om * Copyright 2013, The Sporting Exchange Limited * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ public class Main { public static boolean isExceptionObject(Class o) throws AssertionError { /*if (o.getName().equalsIgnoreCase("java.lang.Exception")|| o.getName().equalsIgnoreCase("javax.xml.soap.SOAPException")|| o.getName().equalsIgnoreCase("com.sun.xml.messaging.saaj.SOAPExceptionImpl") ||o.getName().equalsIgnoreCase("com.sun.xml.internal.messaging.saaj.SOAPExceptionImpl")) { return true; } return false;*/ final String behaviourString = "java.lang.Exception"; Class<?> behaviour; try { behaviour = Class.forName(behaviourString); } catch (ClassNotFoundException e) { throw new RuntimeException("Unable to determine interface behaviour from : " + behaviourString, e); } return checkBehaviour(o, behaviour); } /** * Check that the specified class implements a given interface or extends a given parent class as the behaviour * * @param clazz * @param behaviour * @return */ public static boolean checkBehaviour(Class<?> clazz, Class<?> behaviour) { boolean behaviourFlag = false; while (clazz != null) { if (clazz == behaviour) { behaviourFlag = true; break; } else { Class<?>[] interfaces = clazz.getInterfaces(); for (Class<?> cls : interfaces) { if (cls == behaviour) { behaviourFlag = true; break; } } if (behaviourFlag) { break; } clazz = clazz.getSuperclass(); } } return behaviourFlag; } }