/** * Checks for a method implementation. * * @param methodName name of a method (different from constructor) * @param argClasses argument classes for the method * @return this Builder for method chaining * @see {@link java.lang.Class#forName(String)} * @see {@link java.lang.Class#getMethod(String, Class[])} */ public Builder hiddenImpl(Class<?> targetClass, String methodName, Class<?>... argClasses) { // don't do any work if an implementation has been found if (method != null) { return this; } try { Method hidden = targetClass.getDeclaredMethod(methodName, argClasses); AccessController.doPrivileged(new MakeAccessible(hidden)); this.method = new UnboundMethod(hidden, name); } catch (SecurityException e) { // unusable } catch (NoSuchMethodException e) { // not the right implementation } return this; }
/** * Checks for a method implementation. * * @param methodName name of a method (different from constructor) * @param argClasses argument classes for the method * @return this Builder for method chaining * @see {@link java.lang.Class#forName(String)} * @see {@link java.lang.Class#getMethod(String, Class[])} */ public Builder impl(Class<?> targetClass, String methodName, Class<?>... argClasses) { // don't do any work if an implementation has been found if (method != null) { return this; } try { this.method = new UnboundMethod( targetClass.getMethod(methodName, argClasses), name); } catch (NoSuchMethodException e) { // not the right implementation } return this; }
/** * Checks for a method implementation. * * @param methodName name of a method (different from constructor) * @param argClasses argument classes for the method * @return this Builder for method chaining * @see {@link java.lang.Class#forName(String)} * @see {@link java.lang.Class#getMethod(String, Class[])} */ public Builder impl(Class<?> targetClass, String methodName, Class<?>... argClasses) { // don't do any work if an implementation has been found if (method != null) { return this; } try { this.method = new UnboundMethod( targetClass.getMethod(methodName, argClasses), name); } catch (NoSuchMethodException e) { // not the right implementation } return this; }
/** * Checks for a method implementation. * * @param methodName name of a method (different from constructor) * @param argClasses argument classes for the method * @return this Builder for method chaining * @see {@link java.lang.Class#forName(String)} * @see {@link java.lang.Class#getMethod(String, Class[])} */ public Builder hiddenImpl(Class<?> targetClass, String methodName, Class<?>... argClasses) { // don't do any work if an implementation has been found if (method != null) { return this; } try { Method hidden = targetClass.getDeclaredMethod(methodName, argClasses); AccessController.doPrivileged(new MakeAccessible(hidden)); this.method = new UnboundMethod(hidden, name); } catch (SecurityException e) { // unusable } catch (NoSuchMethodException e) { // not the right implementation } return this; }