类org.apache.commons.lang3.reflect.MethodUtils源码实例Demo

下面列出了怎么用org.apache.commons.lang3.reflect.MethodUtils的API类实例代码及写法,或者点击链接到github查看源代码。

源代码1 项目: pmd-designer   文件: TreeViewWrapper.java
private void initialiseTreeViewReflection() {

        // we can't use wrapped.getSkin() because it may be null.
        // we don't care about the specific instance, we just want the class
        @SuppressWarnings("PMD.UselessOverridingMethod")
        Skin<?> dftSkin = new TreeView<Object>() {
            @Override
            protected Skin<?> createDefaultSkin() {
                return super.createDefaultSkin();
            }
        }.createDefaultSkin();

        Object flow = getVirtualFlow(dftSkin);

        if (flow == null) {
            return;
        }

        treeViewFirstVisibleMethod = MethodUtils.getMatchingMethod(flow.getClass(), "getFirstVisibleCell");
        treeViewLastVisibleMethod = MethodUtils.getMatchingMethod(flow.getClass(), "getLastVisibleCell");
    }
 
@Override
public Object[] assembleRequest(BeforeEvent event) {
    Object invocation;
    if (ON_RESPONSE.equals(event.javaMethodName)) {
        // for record parameter assemble
        // onResponse(Result appResponse, Invoker<?> invoker, Invocation invocation) {}
        invocation = event.argumentArray[2];
    } else {
        // for repeater parameter assemble
        // invoke(Invoker<?> invoker, Invocation invocation)
        invocation = event.argumentArray[1];
    }
    try {
        return (Object[]) MethodUtils.invokeMethod(invocation, "getArguments");
    } catch (Exception e) {
        // ignore
        LogUtil.error("error occurred when assemble dubbo request", e);
    }
    return null;
}
 
源代码3 项目: htmlunit   文件: AppletClassLoader.java
/**
 * The constructor.
 * @param window the window containing this applet
 * @param parent the parent class loader for delegation
 */
public AppletClassLoader(final Window window, final ClassLoader parent) {
    super(new URL[0], parent);

    if (window.getWebWindow().getWebClient().getOptions().isUseInsecureSSL()) {
        if (LOG.isWarnEnabled()) {
            LOG.warn("AppletClassLoader: your WebClient accepts ssl connections without certificate checking."
                    + " If you like to load applet archives from a SSL/HTTPS connection you have to configure"
                    + " your jvm to accept untrusted certificate for SSL/HTTPS connections also.");
        }
    }

    try {
        loadOurNetscapeStuff("netscape.javascript.JSException");
        final Class<?> jsObjectClass = loadOurNetscapeStuff("netscape.javascript.JSObject");
        MethodUtils.invokeExactStaticMethod(jsObjectClass, "setWindow", window);
    }
    catch (final Exception e) {
        LOG.error(e.getMessage(), e);
    }
}
 
源代码4 项目: htmlunit   文件: JQueryExtractor.java
/**
 * Main method.
 * @param args program arguments
 * @throws Exception s
 */
public static void main(final String[] args) throws Exception {
    // final Class<? extends WebDriverTestCase> testClass = JQuery1x8x2Test.class;
    // final Class<? extends WebDriverTestCase> testClass = JQuery1x11x3Test.class;
    final Class<? extends WebDriverTestCase> testClass = JQuery3x3x1Test.class;

    final String version = (String) MethodUtils.invokeExactMethod(testClass.newInstance(), "getVersion");
    final File baseDir = new File("src/test/resources/libraries/jQuery/" + version + "/expectations");

    for (String browser : new String[] {"CHROME", "FF", "FF68", "FF60", "IE"}) {
        final File out = new File(baseDir, browser + ".out");
        final File results = new File(baseDir, "results." + browser + ".txt");
        extractExpectations(out, results);
    }

    generateTestCases(testClass, baseDir);
}
 
源代码5 项目: TakinRPC   文件: Javassis.java
/** 
 * 
 * 快捷调用公共方法(性能较差) 
 *  
 * @param host 
 *            宿主对象 
 * @param name 
 *            方法名 
 * @param args 
 *            方法参数 
 * @return 执行结果 
 * @throws NoSuchMethodException 
 *             如果没有相应的方法 
 */
public static Object invokePublic(Object host, String name, Object... args) throws NoSuchMethodException {
    final Class<?> clazz = host instanceof Class ? (Class<?>) host : host.getClass();
    args = args == null ? new Object[] { null } : args;
    Class<?>[] paramTypes = new Class[args.length];
    for (int i = 0; i < paramTypes.length; i++) {
        paramTypes[i] = args[i] == null ? null : args[i].getClass();
    }
    int[] keys = new int[3];
    keys[0] = clazz.hashCode();
    keys[1] = name.hashCode();
    keys[2] = Arrays.hashCode(paramTypes);
    int key = Arrays.hashCode(keys);
    Invoker invoker = PUBLIC_INVOKER_MAP.get(key);
    if (invoker == null) {
        Method method = MethodUtils.getMatchingAccessibleMethod(clazz, name, paramTypes);
        if (method == null) {
            throw new NoSuchMethodException(clazz.getName() + "." + name + argumentTypesToString(paramTypes));
        }
        invoker = newInvoker(method);
        PUBLIC_INVOKER_MAP.put(key, invoker);
    }
    return invoker.invoke(host, args);
}
 
源代码6 项目: o2oa   文件: ApiBuilder.java
private List<Class<?>> scanJaxrsClass() throws Exception {
	try (ScanResult scanResult = new ClassGraph().disableJarScanning().enableAnnotationInfo().scan()) {
		SetUniqueList<Class<?>> classes = SetUniqueList.setUniqueList(new ArrayList<Class<?>>());
		for (ClassInfo info : scanResult.getClassesWithAnnotation(ApplicationPath.class.getName())) {
			Class<?> applicationPathClass = ClassUtils.getClass(info.getName());
			for (Class<?> o : (Set<Class<?>>) MethodUtils.invokeMethod(applicationPathClass.newInstance(),
					"getClasses")) {
				Path path = o.getAnnotation(Path.class);
				JaxrsDescribe jaxrsDescribe = o.getAnnotation(JaxrsDescribe.class);
				if (null != path && null != jaxrsDescribe) {
					classes.add(o);
				}
			}
		}
		return classes;
	}
}
 
源代码7 项目: o2oa   文件: Describe.java
private List<Class<?>> scanJaxrsClass(String name) throws Exception {
	// String pack = "com." + name.replaceAll("_", ".");
	String pack = "";
	if (StringUtils.startsWith(name, "o2_")) {
		pack = name.replaceAll("_", ".");
	} else {
		pack = "com." + name.replaceAll("_", ".");
	}
	try (ScanResult scanResult = new ClassGraph().whitelistPackages(pack).enableAllInfo().scan()) {
		SetUniqueList<Class<?>> classes = SetUniqueList.setUniqueList(new ArrayList<Class<?>>());
		for (ClassInfo info : scanResult.getClassesWithAnnotation(ApplicationPath.class.getName())) {
			Class<?> applicationPathClass = ClassUtils.getClass(info.getName());
			for (Class<?> o : (Set<Class<?>>) MethodUtils.invokeMethod(applicationPathClass.newInstance(),
					"getClasses")) {
				Path path = o.getAnnotation(Path.class);
				JaxrsDescribe jaxrsDescribe = o.getAnnotation(JaxrsDescribe.class);
				if (null != path && null != jaxrsDescribe) {
					classes.add(o);
				}
			}
		}
		return classes;
	}
}
 
源代码8 项目: o2oa   文件: DescribeBuilder.java
private List<Class<?>> scanJaxrsClass() throws Exception {
	try (ScanResult scanResult = new ClassGraph().disableJarScanning().enableAnnotationInfo().scan()) {
		SetUniqueList<Class<?>> classes = SetUniqueList.setUniqueList(new ArrayList<Class<?>>());
		for (ClassInfo info : scanResult.getClassesWithAnnotation(ApplicationPath.class.getName())) {
			Class<?> applicationPathClass = ClassUtils.getClass(info.getName());
			for (Class<?> o : (Set<Class<?>>) MethodUtils.invokeMethod(applicationPathClass.newInstance(),
					"getClasses")) {
				Path path = o.getAnnotation(Path.class);
				JaxrsDescribe jaxrsDescribe = o.getAnnotation(JaxrsDescribe.class);
				if (null != path && null != jaxrsDescribe) {
					classes.add(o);
				}
			}
		}
		return classes;
	}
}
 
private JSONObject getPostDataHelper(AdType adType, @Nullable Map<String, Set<String>> contextDataDictionary, @Nullable Set<String> contextKeywordsSet, @Nullable AdSize minSizePerc, @Nullable VideoBaseAdUnit.Parameters parameters) throws NoSuchMethodException, IllegalAccessException, InvocationTargetException {

        PrebidMobile.setApplicationContext(activity.getApplicationContext());

        server.enqueue(new MockResponse().setResponseCode(200).setBody(MockPrebidServerResponses.noBid()));

        DemandAdapter.DemandAdapterListener mockListener = mock(DemandAdapter.DemandAdapterListener.class);
        PrebidServerAdapter adapter = new PrebidServerAdapter();
        HashSet<AdSize> sizes = new HashSet<>();
        sizes.add(new AdSize(300, 250));

        RequestParams requestParams = new RequestParams("67890", adType, sizes, contextDataDictionary, contextKeywordsSet, minSizePerc, parameters);
        String uuid = UUID.randomUUID().toString();
        adapter.requestDemand(requestParams, mockListener, uuid);
        @SuppressWarnings("unchecked")
        ArrayList<PrebidServerAdapter.ServerConnector> connectors = (ArrayList<PrebidServerAdapter.ServerConnector>) FieldUtils.readDeclaredField(adapter, "serverConnectors", true);
        PrebidServerAdapter.ServerConnector connector = connectors.get(0);

        JSONObject postData = (JSONObject) MethodUtils.invokeMethod(connector, true, "getPostData");
        return postData;
    }
 
源代码10 项目: pragmatic-java-engineer   文件: CommonsExample.java
public static void lang() throws NoSuchMethodException, IllegalAccessException, InvocationTargetException {
    String[] strs = new String[]{"1", "4", "2"};
    ArrayUtils.addAll(strs, "3");

    RandomUtils.nextInt(0, 10);
    RandomStringUtils.random(3);

    StopWatch stopWatch = new StopWatch();
    stopWatch.start();
    stopWatch.split();
    stopWatch.getSplitTime();
    stopWatch.suspend();
    stopWatch.resume();
    stopWatch.stop();
    stopWatch.getTime();

    long max = NumberUtils.max(new long[]{1, 5, 10}); //计算数组最大值

    MethodUtils.invokeStaticMethod(StringUtils.class, "isNotBlank", "test"); //调用静态方法
    MethodUtils.invokeMethod(StringUtils.class, "isNotBlank", "test"); //调用静态方法

    DateUtils.truncate(new Date(), Calendar.HOUR);
    DateFormatUtils.format(new Date(), "yyyyMMdd");
}
 
源代码11 项目: sling-whiteboard   文件: ModelPersistorImpl.java
private static String getJcrPath(Object obj) {
    String path = (String) getAnnotatedValue(obj, Path.class);
    if (path != null) {
        return path;
    }

    try {
        Method pathGetter = MethodUtils.getMatchingMethod(obj.getClass(), "getPath");
        if (pathGetter != null) {
            return (String) MethodUtils.invokeMethod(obj, "getPath");
        }

        Field pathField = FieldUtils.getDeclaredField(obj.getClass(), "path");
        if (pathField != null) {
            return (String) FieldUtils.readField(pathField, obj, true);
        }
    } catch (IllegalArgumentException | NoSuchMethodException | InvocationTargetException | IllegalAccessException ex) {
        LOGGER.warn("exception caught", ex);
    }
    LOGGER.warn("Object of type {} does NOT contain a Path attribute or a path property - multiple instances may conflict", obj.getClass());
    return null;
}
 
源代码12 项目: cuba   文件: LinkCellClickListener.java
protected Method findLinkInvokeMethod(Class cls, String methodName) {
    Method exactMethod = MethodUtils.getAccessibleMethod(cls, methodName, Entity.class, String.class);
    if (exactMethod != null) {
        return exactMethod;
    }

    // search through all methods
    Method[] methods = cls.getMethods();
    for (Method availableMethod : methods) {
        if (availableMethod.getName().equals(methodName)) {
            if (availableMethod.getParameterCount() == 2
                    && Void.TYPE.equals(availableMethod.getReturnType())) {
                if (Entity.class.isAssignableFrom(availableMethod.getParameterTypes()[0]) &&
                        String.class == availableMethod.getParameterTypes()[1]) {
                    // get accessible version of method
                    return MethodUtils.getAccessibleMethod(availableMethod);
                }
            }
        }
    }
    return null;
}
 
源代码13 项目: cuba   文件: DeclarativeColumnGenerator.java
@Nullable
protected Method findGeneratorMethod(Class cls, String methodName) {
    Method exactMethod = MethodUtils.getAccessibleMethod(cls, methodName, Entity.class);
    if (exactMethod != null) {
        return exactMethod;
    }

    // search through all methods
    Method[] methods = cls.getMethods();
    for (Method availableMethod : methods) {
        if (availableMethod.getName().equals(methodName)) {
            if (availableMethod.getParameterCount() == 1
                    && Component.class.isAssignableFrom(availableMethod.getReturnType())) {
                if (Entity.class.isAssignableFrom(availableMethod.getParameterTypes()[0])) {
                    // get accessible version of method
                    return MethodUtils.getAccessibleMethod(availableMethod);
                }
            }
        }
    }
    return null;
}
 
源代码14 项目: webanno   文件: AeroRemoteApiController.java
private static void forceOverwriteSofa(CAS aCas, String aValue)
{
    try {
        Sofa sofa = (Sofa) aCas.getSofa();
        MethodHandle _FH_sofaString = (MethodHandle) FieldUtils.readField(sofa,
                "_FH_sofaString", true);
        Method method = MethodUtils.getMatchingMethod(Sofa.class, "wrapGetIntCatchException",
                MethodHandle.class);
        int adjOffset;
        try {
            method.setAccessible(true);
            adjOffset = (int) method.invoke(null, _FH_sofaString);
        }
        finally {
            method.setAccessible(false);
        }
        sofa._setStringValueNcWj(adjOffset, aValue);
    }
    catch (Exception e) {
        throw new IllegalStateException("Cannot force-update SofA string", e);
    }
}
 
源代码15 项目: feilong-core   文件: MethodUtil.java
/**
 * Do with no such method exception.
 *
 * @param <T>
 *            the generic type
 * @param klass
 *            the klass
 * @param staticMethodName
 *            the static method name
 * @param args
 *            the args
 * @param parameterTypes
 *            the parameter types
 * @return the t
 * @throws ReflectException
 *             the reflect exception
 * @since 1.11.5
 */
@SuppressWarnings("unchecked")
private static <T> T doWithNoSuchMethodException(Class<?> klass,String staticMethodName,Object[] args,Class<?>[] parameterTypes){
    try{
        Method matchingMethod = MethodUtils.getMatchingMethod(klass, staticMethodName, parameterTypes);
        if (null == matchingMethod){
            throw new NoSuchMethodException("No such method:[" + staticMethodName + "()] on class: " + klass.getName());
        }

        //---------------------------------------------------------------

        if (LOGGER.isDebugEnabled()){
            LOGGER.debug("bingo,from class:[{}],find name [{}] method", klass.getSimpleName(), staticMethodName);
        }

        //---------------------------------------------------------------
        matchingMethod.setAccessible(true);
        return (T) matchingMethod.invoke(null, args);
    }catch (Exception e){
        throw new ReflectException(buildMessage(klass, staticMethodName, args, parameterTypes), e);
    }
}
 
源代码16 项目: coroutines   文件: SearchUtilsTest.java
@Test
public void mustFindLocalVariableNodeForInstruction() {
    MethodNode methodNode = findMethodsWithName(classNode.methods, "localVariablesTest").get(0);
    List<AbstractInsnNode> insns = findInvocationsOf(methodNode.instructions,
            MethodUtils.getAccessibleMethod(PrintStream.class, "println", String.class));
    
    AbstractInsnNode insnNode = insns.get(0);
    
    LocalVariableNode lvn0 = findLocalVariableNodeForInstruction(methodNode.localVariables, methodNode.instructions, insnNode, 0);
    LocalVariableNode lvn1 = findLocalVariableNodeForInstruction(methodNode.localVariables, methodNode.instructions, insnNode, 1);
    LocalVariableNode lvn2 = findLocalVariableNodeForInstruction(methodNode.localVariables, methodNode.instructions, insnNode, 2);
    
    assertEquals(lvn0.name, "this");
    assertEquals(lvn1.name, "val1");
    assertEquals(lvn2.name, "val2");
}
 
源代码17 项目: spliceengine   文件: SpliceDefaultCompactor.java
/**
 *
 * This only overwrites favored nodes when there are none supplied.  I believe in later versions the favoredNodes are
 * populated for region groups.  When this happens, we will pass those favored nodes along.  Until then, we attempt to put the local
 * node in the favored nodes since sometimes Spark Tasks will run compactions remotely.
 *
 * @return
 * @throws IOException
 */
protected InetSocketAddress[] getFavoredNodes() throws IOException {
    try {
        RegionServerServices rsServices = (RegionServerServices) FieldUtils.readField(((HStore) store).getHRegion(), "rsServices", true);
        InetSocketAddress[] returnAddresses = (InetSocketAddress[]) MethodUtils.invokeMethod(rsServices,"getFavoredNodesForRegion",store.getRegionInfo().getEncodedName());
        if ( (returnAddresses == null || returnAddresses.length == 0)
                && store.getFileSystem() instanceof HFileSystem
                && ((HFileSystem)store.getFileSystem()).getBackingFs() instanceof DistributedFileSystem) {
            String[] txvr = conf.get("dfs.datanode.address").split(":"); // hack
            if (txvr.length == 2) {
                returnAddresses = new InetSocketAddress[1];
                returnAddresses[0] = new InetSocketAddress(hostName, Integer.parseInt(txvr[1]));
            }
            else {
                SpliceLogUtils.warn(LOG,"dfs.datanode.address is expected to have form hostname:port but is %s",txvr);
            }
        }
        return returnAddresses;
    } catch (Exception e) {
        SpliceLogUtils.error(LOG,e);
        throw new IOException(e);
    }

}
 
源代码18 项目: coroutines   文件: DebugGeneratorsTest.java
@Test
public void mustNotCrashOnMarker() throws Exception {
    // Augment signature
    methodNode.desc = Type.getMethodDescriptor(Type.VOID_TYPE, new Type[] { });
    
    // Initialize variable table
    VariableTable varTable = new VariableTable(classNode, methodNode);

    methodNode.instructions
            = merge(
                    // test marker of each type
                    debugMarker(MarkerType.NONE, "marker1"),
                    debugMarker(MarkerType.CONSTANT, "marker2"),
                    debugMarker(MarkerType.STDOUT, "marker3"),
                    returnVoid()
            );
    
    // Write to JAR file + load up in classloader -- then execute tests
    try (URLClassLoader cl = createJarAndLoad(classNode)) {
        Object obj = cl.loadClass(STUB_CLASSNAME).newInstance();
        MethodUtils.invokeMethod(obj, STUB_METHOD_NAME);
    }
}
 
源代码19 项目: coroutines   文件: DebugGeneratorsTest.java
@Test
public void mustNotCrashOnDebugPrint() throws Exception {
    // Augment signature
    methodNode.desc = Type.getMethodDescriptor(Type.VOID_TYPE, new Type[] { });
    
    // Initialize variable table
    VariableTable varTable = new VariableTable(classNode, methodNode);

    methodNode.instructions
            = merge(
                    // test marker of each type
                    debugPrint(loadStringConst("marker1")),
                    returnVoid()
            );
    
    // Write to JAR file + load up in classloader -- then execute tests
    try (URLClassLoader cl = createJarAndLoad(classNode)) {
        Object obj = cl.loadClass(STUB_CLASSNAME).newInstance();
        MethodUtils.invokeMethod(obj, STUB_METHOD_NAME);
    }
}
 
源代码20 项目: yarg   文件: AbstractObjectToStringConverter.java
protected Object convertFromStringUnresolved(Class<?> parameterClass, String paramValueStr) {
    try {
        Constructor constructor = ConstructorUtils.getAccessibleConstructor(parameterClass, String.class);
        if (constructor != null) {
            return constructor.newInstance(paramValueStr);
        } else {
            Method valueOf = MethodUtils.getAccessibleMethod(parameterClass, "valueOf", String.class);
            if (valueOf != null) {
                return valueOf.invoke(null, paramValueStr);
            }
        }
    } catch (ReflectiveOperationException e) {
        throw new ReportingException(
                String.format("Could not instantiate object with class [%s] from [%s] string.",
                        parameterClass.getCanonicalName(),
                        paramValueStr));
    }
    return paramValueStr;
}
 
源代码21 项目: jvm-sandbox-repeater   文件: LocaleHandle.java
private Object readResolve() {
    try {
        Method method = MethodUtils.getMatchingMethod(Locale.class, "getInstance", String.class, String.class, String.class);
        boolean accessible = method.isAccessible();
        method.setAccessible(true);
        Object locale = method.invoke(null, language, country, variant);
        method.setAccessible(accessible);
        return locale;
    } catch (Throwable t) {
        // ignore
        return new Locale(language, country, variant);
    }
}
 
源代码22 项目: jvm-sandbox-repeater   文件: DubboEventListener.java
@Override
protected Invocation initInvocation(BeforeEvent event) {
    DubboInvocation dubboInvocation = new DubboInvocation();
    // onResponse(Result appResponse, Invoker<?> invoker, Invocation invocation) {}
    Object invoker = event.argumentArray[1];
    Object invocation = event.argumentArray[2];
    try {
        Object url = MethodUtils.invokeMethod(invoker, "getUrl");
        @SuppressWarnings("unchecked")
        Map<String, String> parameters = (Map<String, String>) MethodUtils.invokeMethod(url, "getParameters");
        String protocol =  (String)MethodUtils.invokeMethod(url, "getProtocol");
        // methodName
        String methodName = (String) MethodUtils.invokeMethod(invocation, "getMethodName");
        Class<?>[] parameterTypes = (Class<?>[]) MethodUtils.invokeMethod(invocation, "getParameterTypes");
        // interfaceName
        String interfaceName = ((Class) MethodUtils.invokeMethod(invoker, "getInterface")).getCanonicalName();
        dubboInvocation.setProtocol(protocol);
        dubboInvocation.setInterfaceName(interfaceName);
        dubboInvocation.setMethodName(methodName);
        dubboInvocation.setParameters(parameters);
        dubboInvocation.setVersion(parameters.get("version"));
        dubboInvocation.setParameterTypes(transformClass(parameterTypes));
        // todo find a right way to get address and group
    } catch (Exception e) {
        LogUtil.error("error occurred when init dubbo invocation", e);
    }
    return dubboInvocation;
}
 
@Override
public Identity assembleIdentity(BeforeEvent event) {
    Object invoker;
    Object invocation;
    if (ON_RESPONSE.equals(event.javaMethodName)) {
        // for record identity assemble
        // onResponse(Result appResponse, Invoker<?> invoker, Invocation invocation) {}
        invoker = event.argumentArray[1];
        invocation = event.argumentArray[2];
    } else {
        // for repeater identity assemble
        // invoke(Invoker<?> invoker, Invocation invocation)
        invoker = event.argumentArray[0];
        invocation = event.argumentArray[1];
    }

    try {
        // methodName
        String methodName = (String) MethodUtils.invokeMethod(invocation, "getMethodName");
        Class<?>[] parameterTypes = (Class<?>[]) MethodUtils.invokeMethod(invocation, "getParameterTypes");
        // interfaceName
        String  interfaceName = ((Class)MethodUtils.invokeMethod(invoker, "getInterface")).getCanonicalName();
        return new Identity(InvokeType.DUBBO.name(), interfaceName, getMethodDesc(methodName, parameterTypes), getExtra());
    } catch (Exception e) {
        // ignore
        LogUtil.error("error occurred when assemble dubbo request", e);
    }
    return new Identity(InvokeType.DUBBO.name(), "unknown", "unknown", null);
}
 
@Override
public Object assembleResponse(Event event) {
    // 在onResponse的before事件中组装response
    if (event.type == Event.Type.BEFORE) {
        Object appResponse = ((BeforeEvent) event).argumentArray[0];
        try {
            return MethodUtils.invokeMethod(appResponse, "getValue");
        } catch (Exception e) {
            // ignore
            LogUtil.error("error occurred when assemble dubbo response", e);
        }
    }
    return null;
}
 
源代码25 项目: bleachhack-1.14   文件: FabricReflect.java
public static Object invokeMethod(Object target, String obfName, String deobfName, Object... args) {
/* i just gave up here */
Object o = null;
      try { o = MethodUtils.invokeMethod(target, true, obfName, args); } catch (Exception e) {
      	try { o = MethodUtils.invokeMethod(target, true, deobfName, args); } catch (Exception e1) {}}
      return o;
  }
 
源代码26 项目: bleachhack-1.14   文件: FabricReflect.java
public static Object invokeMethod(Object target, String obfName, String deobfName, Object... args) {
/* i just gave up here */
Object o = null;
      try { o = MethodUtils.invokeMethod(target, true, obfName, args); } catch (Exception e) {
      	try { o = MethodUtils.invokeMethod(target, true, deobfName, args); } catch (Exception e1) {}}
      return o;
  }
 
源代码27 项目: bleachhack-1.14   文件: FabricReflect.java
public static Object invokeMethod(Object target, String obfName, String deobfName, Object... args) {
/* i just gave up here */
Object o = null;
      try { o = MethodUtils.invokeMethod(target, true, obfName, args); } catch (Exception e) {
      	try { o = MethodUtils.invokeMethod(target, true, deobfName, args); } catch (Exception e1) {}}
      return o;
  }
 
源代码28 项目: bartworks   文件: LuVTierEnhancer.java
private static void addDreamcraftItemListItems(Collection LuVMachines){
    try {
        Class customItemListClass = Class.forName("com.dreammaster.gthandler.CustomItemList");
        Method hasnotBeenSet = MethodUtils.getAccessibleMethod(customItemListClass, "hasBeenSet");
        Method get = MethodUtils.getAccessibleMethod(customItemListClass, "get", long.class, Object[].class);
        for (Enum customItemList : (Enum[]) FieldUtils.getField(customItemListClass, "$VALUES", true).get(null)) {
            if (customItemList.toString().contains("LuV") && (boolean) hasnotBeenSet.invoke(customItemList))
                LuVMachines.add((ItemStack) get.invoke(customItemList, 1, new Object[0]));
        }
    } catch (IllegalAccessException | ClassNotFoundException | InvocationTargetException e) {
        e.printStackTrace();
    }
}
 
源代码29 项目: Raincat   文件: TxCompensationServiceImpl.java
@SuppressWarnings("unchecked")
private void compensatoryTransfer(final TransactionRecover transactionRecover) {
    if (Objects.nonNull(transactionRecover)) {
        final TransactionInvocation transactionInvocation = transactionRecover.getTransactionInvocation();
        if (Objects.nonNull(transactionInvocation)) {
            final Class clazz = transactionInvocation.getTargetClazz();
            final String method = transactionInvocation.getMethod();
            final Object[] argumentValues = transactionInvocation.getArgumentValues();
            final Class[] argumentTypes = transactionInvocation.getArgumentTypes();
            final Object bean = SpringBeanUtils.getInstance().getBean(clazz);
            try {
                CompensationLocal.getInstance().setCompensationId(CommonConstant.COMPENSATE_ID);
                MethodUtils.invokeMethod(bean, method, argumentValues, argumentTypes);
                //通知tm自身已经完成提交 //删除本地信息
                final Boolean success = txManagerMessageService.completeCommitTxTransaction(transactionRecover.getGroupId(),
                        transactionRecover.getTaskId(), TransactionStatusEnum.COMMIT.getCode());
                if (success) {
                    transactionRecoverRepository.remove(transactionRecover.getId());
                }

            } catch (NoSuchMethodException | IllegalAccessException | InvocationTargetException e) {
                e.printStackTrace();
                LogUtil.error(LOGGER, "补偿方法反射调用失败!{}", e::getMessage);
            }

        }
    }

}
 
源代码30 项目: jigsaw-payment   文件: JdbcProtobufTemplate.java
private Descriptors.Descriptor getDescriptor(Class<M> messageClass) {
	try {
		return (Descriptors.Descriptor) MethodUtils.invokeStaticMethod(
				messageClass, "getDescriptor");
	} catch (NoSuchMethodException | IllegalAccessException
			| InvocationTargetException ex) {
		throw new RuntimeException(ex);
	}
}
 
 类所在包
 同包方法