// Decompiled by Jad v1.5.8e. Copyright 2001 Pavel Kouznetsov. // Jad home page: http://www.geocities.com/kpdus/jad.html // Decompiler options: braces fieldsfirst space lnc package org.apache.commons.lang3.reflect; import java.lang.reflect.InvocationTargetException; import java.lang.reflect.Method; import java.lang.reflect.Modifier; import java.util.Arrays; import java.util.Iterator; import java.util.LinkedHashSet; import java.util.Set; import org.apache.commons.lang3.ArrayUtils; import org.apache.commons.lang3.ClassUtils; import org.apache.commons.lang3.Validate; // Referenced classes of package org.apache.commons.lang3.reflect: // MemberUtils, TypeUtils public class MethodUtils { public MethodUtils() { } public static transient Method getAccessibleMethod(Class class1, String s, Class aclass[]) { try { class1 = getAccessibleMethod(class1.getMethod(s, aclass)); } // Misplaced declaration of an exception variable catch (Class class1) { return null; } return class1; } public static Method getAccessibleMethod(Method method) { Method method1; if (!MemberUtils.isAccessible(method)) { method1 = null; } else { Class class1 = method.getDeclaringClass(); method1 = method; if (!Modifier.isPublic(class1.getModifiers())) { String s = method.getName(); Class aclass[] = method.getParameterTypes(); method = getAccessibleMethodFromInterfaceNest(class1, s, aclass); method1 = method; if (method == null) { return getAccessibleMethodFromSuperclass(class1, s, aclass); } } } return method1; } private static transient Method getAccessibleMethodFromInterfaceNest(Class class1, String s, Class aclass[]) { _L6: Class aclass1[]; int i; if (class1 == null) { break; /* Loop/switch isn't completed */ } aclass1 = class1.getInterfaces(); i = 0; _L2: if (i >= aclass1.length) { break MISSING_BLOCK_LABEL_76; } if (Modifier.isPublic(aclass1[i].getModifiers())) { break; /* Loop/switch isn't completed */ } _L4: i++; if (true) goto _L2; else goto _L1 _L1: Method method = aclass1[i].getDeclaredMethod(s, aclass); return method; NoSuchMethodException nosuchmethodexception; nosuchmethodexception; nosuchmethodexception = getAccessibleMethodFromInterfaceNest(aclass1[i], s, aclass); if (nosuchmethodexception == null) goto _L4; else goto _L3 _L3: return nosuchmethodexception; class1 = class1.getSuperclass(); if (true) goto _L6; else goto _L5 _L5: return null; } private static transient Method getAccessibleMethodFromSuperclass(Class class1, String s, Class aclass[]) { Object obj = null; class1 = class1.getSuperclass(); do { label0: { Method method = obj; if (class1 != null) { if (!Modifier.isPublic(class1.getModifiers())) { break label0; } try { method = class1.getMethod(s, aclass); } // Misplaced declaration of an exception variable catch (Class class1) { return null; } } return method; } class1 = class1.getSuperclass(); } while (true); } public static transient Method getMatchingAccessibleMethod(Class class1, String s, Class aclass[]) { Method method; try { method = class1.getMethod(s, aclass); MemberUtils.setAccessibleWorkaround(method); } catch (NoSuchMethodException nosuchmethodexception) { Object obj = null; Method amethod[] = class1.getMethods(); int j = amethod.length; int i = 0; for (class1 = ((Class) (obj)); i < j; class1 = ((Class) (obj))) { label0: { Method method1 = amethod[i]; obj = class1; if (!method1.getName().equals(s)) { break label0; } obj = class1; if (!ClassUtils.isAssignable(aclass, method1.getParameterTypes(), true)) { break label0; } method1 = getAccessibleMethod(method1); obj = class1; if (method1 == null) { break label0; } if (class1 != null) { obj = class1; if (MemberUtils.compareParameterTypes(method1.getParameterTypes(), class1.getParameterTypes(), aclass) >= 0) { break label0; } } obj = method1; } i++; } if (class1 != null) { MemberUtils.setAccessibleWorkaround(class1); } return class1; } return method; } public static Set getOverrideHierarchy(Method method, org.apache.commons.lang3.ClassUtils.Interfaces interfaces) { Validate.notNull(method); LinkedHashSet linkedhashset = new LinkedHashSet(); linkedhashset.add(method); Class aclass[] = method.getParameterTypes(); Class class1 = method.getDeclaringClass(); interfaces = ClassUtils.hierarchy(class1, interfaces).iterator(); interfaces.next(); label0: do { if (!interfaces.hasNext()) { break; } Method method1 = getMatchingAccessibleMethod((Class)interfaces.next(), method.getName(), aclass); if (method1 == null) { continue; } if (Arrays.equals(method1.getParameterTypes(), aclass)) { linkedhashset.add(method1); continue; } java.util.Map map = TypeUtils.getTypeArguments(class1, method1.getDeclaringClass()); for (int i = 0; i < aclass.length; i++) { if (!TypeUtils.equals(TypeUtils.unrollVariables(map, method.getGenericParameterTypes()[i]), TypeUtils.unrollVariables(map, method1.getGenericParameterTypes()[i]))) { continue label0; } } linkedhashset.add(method1); } while (true); return linkedhashset; } public static transient Object invokeExactMethod(Object obj, String s, Object aobj[]) throws NoSuchMethodException, IllegalAccessException, InvocationTargetException { aobj = ArrayUtils.nullToEmpty(aobj); return invokeExactMethod(obj, s, aobj, ClassUtils.toClass(aobj)); } public static Object invokeExactMethod(Object obj, String s, Object aobj[], Class aclass[]) throws NoSuchMethodException, IllegalAccessException, InvocationTargetException { aobj = ArrayUtils.nullToEmpty(aobj); aclass = ArrayUtils.nullToEmpty(aclass); aclass = getAccessibleMethod(obj.getClass(), s, aclass); if (aclass == null) { throw new NoSuchMethodException((new StringBuilder()).append("No such accessible method: ").append(s).append("() on object: ").append(obj.getClass().getName()).toString()); } else { return aclass.invoke(obj, aobj); } } public static transient Object invokeExactStaticMethod(Class class1, String s, Object aobj[]) throws NoSuchMethodException, IllegalAccessException, InvocationTargetException { aobj = ArrayUtils.nullToEmpty(aobj); return invokeExactStaticMethod(class1, s, aobj, ClassUtils.toClass(aobj)); } public static Object invokeExactStaticMethod(Class class1, String s, Object aobj[], Class aclass[]) throws NoSuchMethodException, IllegalAccessException, InvocationTargetException { aobj = ArrayUtils.nullToEmpty(aobj); aclass = getAccessibleMethod(class1, s, ArrayUtils.nullToEmpty(aclass)); if (aclass == null) { throw new NoSuchMethodException((new StringBuilder()).append("No such accessible method: ").append(s).append("() on class: ").append(class1.getName()).toString()); } else { return aclass.invoke(null, aobj); } } public static transient Object invokeMethod(Object obj, String s, Object aobj[]) throws NoSuchMethodException, IllegalAccessException, InvocationTargetException { aobj = ArrayUtils.nullToEmpty(aobj); return invokeMethod(obj, s, aobj, ClassUtils.toClass(aobj)); } public static Object invokeMethod(Object obj, String s, Object aobj[], Class aclass[]) throws NoSuchMethodException, IllegalAccessException, InvocationTargetException { aclass = ArrayUtils.nullToEmpty(aclass); aobj = ArrayUtils.nullToEmpty(aobj); aclass = getMatchingAccessibleMethod(obj.getClass(), s, aclass); if (aclass == null) { throw new NoSuchMethodException((new StringBuilder()).append("No such accessible method: ").append(s).append("() on object: ").append(obj.getClass().getName()).toString()); } else { return aclass.invoke(obj, aobj); } } public static transient Object invokeStaticMethod(Class class1, String s, Object aobj[]) throws NoSuchMethodException, IllegalAccessException, InvocationTargetException { aobj = ArrayUtils.nullToEmpty(aobj); return invokeStaticMethod(class1, s, aobj, ClassUtils.toClass(aobj)); } public static Object invokeStaticMethod(Class class1, String s, Object aobj[], Class aclass[]) throws NoSuchMethodException, IllegalAccessException, InvocationTargetException { aobj = ArrayUtils.nullToEmpty(aobj); aclass = getMatchingAccessibleMethod(class1, s, ArrayUtils.nullToEmpty(aclass)); if (aclass == null) { throw new NoSuchMethodException((new StringBuilder()).append("No such accessible method: ").append(s).append("() on class: ").append(class1.getName()).toString()); } else { return aclass.invoke(null, aobj); } } }