Java Method Call invokeGetClasspathMethodIfItExists(ClassLoader cl)

Here you can find the source of invokeGetClasspathMethodIfItExists(ClassLoader cl)

Description

invoke Get Classpath Method If It Exists

License

Open Source License

Declaration

private static String invokeGetClasspathMethodIfItExists(ClassLoader cl) 

Method Source Code

//package com.java2s;
// Licensed under the Apache License, Version 2.0 (the "License");

import java.lang.reflect.InvocationTargetException;
import java.lang.reflect.Method;

public class Main {
    private static String invokeGetClasspathMethodIfItExists(ClassLoader cl) {
        Class<?> clazz = cl.getClass();
        try {/*  w w w  . j a v  a  2  s.  c  om*/
            Method m = clazz.getMethod("getClasspath");
            Object returnValue = m.invoke(cl);
            if (returnValue instanceof String) {
                return (String) returnValue;
            } else {
                return null;
            }
        } catch (NoSuchMethodException e) {
            return null;
        } catch (InvocationTargetException e) {
            return null;
        } catch (IllegalAccessException e) {
            return null;
        }
    }
}

Related

  1. invokeExactMethod(Object object, String methodName, Object[] args, Class[] parameterTypes)
  2. invokeFunction(Object iFunction, String funcName, String param)
  3. invokeFunctions(Object iFunction, String funcName)
  4. invokeGenericMethodOneArg(final Object obj, final String methodName, final Object arg)
  5. invokeGet(Object o, String fieldName)
  6. invokeGetMethodWithSameName(Object object, Method method)
  7. invokeHeritedMethod(Object target, String method, Class klass)
  8. invokeInstanceMethod(Object target, String methodName, Class type, Object arg)
  9. invokeIteratorCallable(String callableClassName, ClassLoader cl)