Example usage for java.lang IllegalAccessException getMessage

List of usage examples for java.lang IllegalAccessException getMessage

Introduction

In this page you can find the example usage for java.lang IllegalAccessException getMessage.

Prototype

public String getMessage() 

Source Link

Document

Returns the detail message string of this throwable.

Usage

From source file:com.xyz.util.ReflectionUtil.java

/**
 * ?,private/protected,??getter./*from   w  w w .ja  v a  2  s  .  c o  m*/
 */
public static Object getFieldValue(final Object object, final String fieldName) {
    Field field = getDeclaredField(object, fieldName);

    if (field == null)
        throw new IllegalArgumentException(
                "Could not find field [" + fieldName + "] on target [" + object + "]");

    makeAccessible(field);

    Object result = null;
    try {
        result = field.get(object);
    } catch (IllegalAccessException e) {
        logger.error("??" + e.getMessage());
    }
    return result;
}

From source file:com.xyz.util.ReflectionUtil.java

/**
 * ,private/protected./*from ww  w  .  jav a 2  s.  c o m*/
 */
public static Object invokeMethod(final Object object, final String methodName, final Class<?>[] parameterTypes,
        final Object[] parameters) throws InvocationTargetException {
    Method method = getDeclaredMethod(object, methodName, parameterTypes);
    if (method == null)
        throw new IllegalArgumentException(
                "Could not find method [" + methodName + "] on target [" + object + "]");

    method.setAccessible(true);

    try {
        return method.invoke(object, parameters);
    } catch (IllegalAccessException e) {
        logger.error("??:" + e.getMessage());
    }

    return null;
}

From source file:com.abssh.util.ReflectionUtils.java

/**
 * , private/protected, ??setter.//from  w  w w .j  av  a 2  s . c  om
 */
public static void setFieldValue(final Object object, final String fieldName, final Object value) {
    Field field = getDeclaredField(object, fieldName);

    if (field == null) {
        throw new IllegalArgumentException(
                "Could not find field [" + fieldName + "] on target [" + object + "]");
    }

    makeAccessible(field);

    try {
        field.set(object, value);
    } catch (IllegalAccessException e) {
        logger.error("??:{}", e.getMessage());
    }
}

From source file:com.abssh.util.ReflectionUtils.java

/**
 * ?, private/protected, ??getter.//w  w  w .  j av a 2s  . c  o m
 */
public static Object getFieldValue(final Object object, final String fieldName) {
    Field field = getDeclaredField(object, fieldName);

    if (field == null) {
        throw new IllegalArgumentException(
                "Could not find field [" + fieldName + "] on target [" + object + "]");
    }

    makeAccessible(field);

    Object result = null;
    try {
        result = field.get(object);
    } catch (IllegalAccessException e) {
        logger.error("??{}", e.getMessage());
    }
    return result;
}

From source file:oecp.framework.util.ReflectionUtils.java

/**
 * ?, private/protected, ??getter./*  ww  w  . ja v a2 s. com*/
 */
public static Object getFieldValue(final Object obj, final String fieldName) {
    Field field = getAccessibleField(obj, fieldName);

    Object result = null;
    if (field == null) {
        return invokeGetterMethod(obj, fieldName);
    }

    try {
        result = field.get(obj);
        if (result == null) {// null?getter
            result = invokeGetterMethod(obj, fieldName);
        }
    } catch (IllegalAccessException e) {
        logger.error("??{}", e.getMessage());
    }
    return result;
}

From source file:com.taobao.android.builder.tasks.manager.transform.TransformManager.java

public static void replaceTransformTask(TransformTask transformTask, Transform newTransform) {

    Field transfromField = FieldUtils.getDeclaredField(TransformTask.class, "transform", true);
    if (null != transfromField) {
        try {/* ww w .j a v a  2 s . c  o m*/
            transfromField.set(transformTask, newTransform);
        } catch (IllegalAccessException e) {
            throw new GradleException(e.getMessage(), e);
        }
    }
}

From source file:com.silverpeas.util.CollectionUtil.java

/**
 * Value converted from a bean property.
 * @param bean bean/*from  w w w. j a va 2s  .co  m*/
 * @param propertyName
 */
private static synchronized Object getPropertyAsObject(final Object bean, final String propertyName) {
    // Synchronized as PropertyEditor is not thread-safe.
    Object property = null;
    try {
        property = PropertyUtils.getProperty(bean, propertyName);
    } catch (final IllegalAccessException e) {
        throw new RuntimeException(e.getMessage(), e);
    } catch (final InvocationTargetException e) {
        throw new RuntimeException(e.getMessage(), e);
    } catch (final NoSuchMethodException e) {
        throw new RuntimeException(e.getMessage(), e);
    } catch (final NestedNullException e) {
        // In the case of a.b, with a == null, null is returned
        property = null;
    }
    if (property == null) {
        return null;
    }
    return property;
}

From source file:cn.com.qiqi.order.utils.Reflections.java

/**
 * , private/protected, ??setter.//from w w w .ja v a  2s  .  c  om
 */
public static void setFieldValue(final Object obj, final String fieldName, final Object value) {
    Field field = getAccessibleField(obj, fieldName);

    if (field == null) {
        throw new IllegalArgumentException("Could not find field [" + fieldName + "] on target [" + obj + "]");
    }

    try {
        field.set(obj, value);
    } catch (IllegalAccessException e) {
        logger.error("??:{}", e.getMessage());
    }
}

From source file:cn.com.qiqi.order.utils.Reflections.java

/**
 * ?, private/protected, ??getter./* w w  w  .  ja v  a2  s. c  o  m*/
 */
public static Object getFieldValue(final Object obj, final String fieldName) {
    Field field = getAccessibleField(obj, fieldName);

    if (field == null) {
        throw new IllegalArgumentException("Could not find field [" + fieldName + "] on target [" + obj + "]");
    }

    Object result = null;
    try {
        result = field.get(obj);
    } catch (IllegalAccessException e) {
        logger.error("??{}", e.getMessage());
    }
    return result;
}

From source file:org.apdplat.platform.util.ReflectionUtils.java

/**
 * ,private/protected,??setter./*  w  w  w  . j  av a2s .  c  o  m*/
 */
public static <T> void setFieldValue(final T object, final Field field, final Object value) {
    makeAccessible(field);

    try {
        field.set(object, value);
    } catch (IllegalAccessException e) {
        LOG.error("??:{}", e.getMessage());
    }
}