public E getIndexedValue(int index) throws IllegalAccessException, IllegalArgumentException, InvocationTargetException { if (!canIndexedRead()) { throw new IllegalAccessException(); } Object validInstance = Beans.getInstanceOf(instance, indexedGetter.getDeclaringClass()); return PropertySupport.cast(getElementType(), indexedGetter.invoke(validInstance, index)); }
public T getValue() throws IllegalAccessException, IllegalArgumentException, InvocationTargetException { if (!canRead()) { throw new IllegalAccessException(); } Object validInstance = Beans.getInstanceOf(instance, getter.getDeclaringClass()); return PropertySupport.cast(getValueType(), getter.invoke(validInstance)); }
public T getValue() throws IllegalAccessException, IllegalArgumentException, InvocationTargetException { if (getter == null) { throw new IllegalAccessException(); } Object valideInstance = Beans.getInstanceOf(instance, getter.getDeclaringClass()); try { try { return cast(getValueType(), getter.invoke(valideInstance)); } catch (IllegalAccessException ex) { try { getter.setAccessible(true); return cast(getValueType(), getter.invoke(valideInstance)); } finally { getter.setAccessible(false); } } } catch (IllegalArgumentException iae) { //Provide a better message for debugging StringBuffer sb = new StringBuffer("Attempted to invoke method "); sb.append(getter.getName()); sb.append(" from class "); sb.append(getter.getDeclaringClass().getName()); sb.append(" on an instance of "); sb.append(valideInstance.getClass().getName()); sb.append(" Problem:"); sb.append(iae.getMessage()); throw (IllegalArgumentException) new IllegalArgumentException(sb.toString()).initCause(iae); } }