public class

AccessibleMethod

extends Object
java.lang.Object
   ↳ sun.swing.AccessibleMethod

Class Overview

A utility for accessing and invoking methods, via reflection, that would otherwise be unaccessible.

Summary

Public Constructors
AccessibleMethod(Class klass, String methodName, Class... paramTypes)
Construct an instance for the given params.
Public Methods
Object invoke(Object obj, Object... args)
Invoke the method that this object represents.
Object invokeNoChecked(Object obj, Object... args)
Invoke the method that this object represents, with the expectation that the method being called throws no checked exceptions.
[Expand]
Inherited Methods
From class java.lang.Object

Public Constructors

public AccessibleMethod (Class klass, String methodName, Class... paramTypes)

Construct an instance for the given params.

Parameters
klass the class to which the method belongs
methodName the name of the method
paramTypes the paramater type array
Throws
NullPointerException if klass or name is null
NoSuchMethodException if the method can't be found

Public Methods

public Object invoke (Object obj, Object... args)

Invoke the method that this object represents. Has the same behavior and throws the same exceptions as java.lang.reflect.Method.invoke with one exception: This method does not throw IllegalAccessException since the target method has already been made accessible.

Parameters
obj the object the underlying method is invoked from
args the arguments used for the method call
Returns
  • the result of dispatching the method represented by this object on obj with parameters args

public Object invokeNoChecked (Object obj, Object... args)

Invoke the method that this object represents, with the expectation that the method being called throws no checked exceptions.

Simply calls this.invoke(obj, args) but catches any InvocationTargetException and returns the cause wrapped in a runtime exception.

Parameters
obj the object the underlying method is invoked from
args the arguments used for the method call
Returns
  • the result of dispatching the method represented by this object on obj with parameters args