Java Method Call invokeVoidNoArgMethod(Class declaringClass, String methodName, Object instance)

Here you can find the source of invokeVoidNoArgMethod(Class declaringClass, String methodName, Object instance)

Description

invoke Void No Arg Method

License

Apache License

Declaration

static void invokeVoidNoArgMethod(Class<?> declaringClass, String methodName, Object instance)
            throws Exception 

Method Source Code

//package com.java2s;
/*//  w  w  w. j  a va 2s .  co m
 * Copyright 2013 Netflix, Inc.
 *
 * 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.
 */

import java.lang.reflect.Method;

public class Main {
    static void invokeVoidNoArgMethod(Class<?> declaringClass, String methodName, Object instance)
            throws Exception {
        Method method = declaringClass.getDeclaredMethod(methodName);
        method.setAccessible(true);
        method.invoke(instance);
    }
}

Related

  1. invokeUnwrapException(final Object target, final Method method, @Nullable final Object[] args)
  2. invokeValue(AnnotatedElement element, Class annotationClass)
  3. invokeVirtual(String methodName, Object onObj, Class[] declaredArgTypes, Object... withArgs)
  4. invokeVirtual(T o, Method method, Object... pa)
  5. invokeVoid(MethodHandle mh)
  6. invokeVoidSafe(Object obj, String methodName, Class paramClass, Object param)
  7. invokeWithoutDeclaredExceptions(Method method, Object target, Object... args)
  8. invokeWithoutInvocationException(Method m, Object obj, Object... args)