List of usage examples for java.lang IllegalAccessException getClass
@HotSpotIntrinsicCandidate public final native Class<?> getClass();
From source file:org.grails.datastore.mapping.reflect.ReflectionUtils.java
/** * Instantiates an object catching any relevant exceptions and rethrowing as a runtime exception * * @param clazz The class/*from w w w .j a va2 s . com*/ * @return The instantiated object or null if the class parameter was null */ @SuppressWarnings({ "rawtypes", "unchecked" }) public static Object instantiate(Class clazz) { if (clazz == null) return null; try { return clazz.getConstructor(EMPTY_CLASS_ARRAY).newInstance(); } catch (IllegalAccessException e) { throw new InstantiationException(e.getClass().getName() + " error creating instance of class [" + e.getMessage() + "]: " + e.getMessage(), e); } catch (InvocationTargetException e) { throw new InstantiationException(e.getClass().getName() + " error creating instance of class [" + e.getMessage() + "]: " + e.getMessage(), e); } catch (NoSuchMethodException e) { throw new InstantiationException(e.getClass().getName() + " error creating instance of class [" + e.getMessage() + "]: " + e.getMessage(), e); } catch (java.lang.InstantiationException e) { throw new InstantiationException(e.getClass().getName() + " error creating instance of class [" + e.getMessage() + "]: " + e.getMessage(), e); } }
From source file:com.liferay.cli.support.util.ReflectionUtils.java
/** * Get the field represented by the supplied {@link Field field object} on * the specified {@link Object target object}. In accordance with * {@link Field#get(Object)} semantics, the returned value is automatically * wrapped if the underlying field has a primitive type. * <p>//from w w w . j a va 2 s . c o m * Thrown exceptions are handled via a call to * {@link #handleReflectionException(Exception)}. * * @param field the field to get * @param target the target object from which to get the field * @return the field's current value */ public static Object getField(final Field field, final Object target) { try { return field.get(target); } catch (final IllegalAccessException ex) { handleReflectionException(ex); throw new IllegalStateException( "Unexpected reflection exception - " + ex.getClass().getName() + ": " + ex.getMessage()); } }
From source file:com.liferay.cli.support.util.ReflectionUtils.java
/** * Set the field represented by the supplied {@link Field field object} on * the specified {@link Object target object} to the specified * <code>value</code>. In accordance with {@link Field#set(Object, Object)} * semantics, the new value is automatically unwrapped if the underlying * field has a primitive type./*from w ww .j a va 2 s .co m*/ * <p> * Thrown exceptions are handled via a call to * {@link #handleReflectionException(Exception)}. * * @param field the field to set * @param target the target object on which to set the field * @param value the value to set; may be <code>null</code> */ public static void setField(final Field field, final Object target, final Object value) { try { field.set(target, value); } catch (final IllegalAccessException ex) { handleReflectionException(ex); throw new IllegalStateException( "Unexpected reflection exception - " + ex.getClass().getName() + ": " + ex.getMessage()); } }
From source file:br.com.lucasisrael.regra.reflections.TratamentoReflections.java
/** * Set the field represented by the supplied {@link Field field object} on the * specified {@link Object target object} to the specified {@code value}. * In accordance with {@link Field#set(Object, Object)} semantics, the new value * is automatically unwrapped if the underlying field has a primitive type. * <p>Thrown exceptions are handled via a call to {@link #handleReflectionException(Exception)}. * @param field the field to set//from ww w . j a va2 s . c om * @param target the target object on which to set the field * @param value the value to set; may be {@code null} */ public static void setField(Field field, Object target, Object value) { try { field.set(target, value); } catch (IllegalAccessException ex) { handleReflectionException(ex); throw new IllegalStateException( "Unexpected reflection exception - " + ex.getClass().getName() + ": " + ex.getMessage()); } }
From source file:br.com.lucasisrael.regra.reflections.TratamentoReflections.java
/** * Get the field represented by the supplied {@link Field field object} on the * specified {@link Object target object}. In accordance with {@link Field#get(Object)} * semantics, the returned value is automatically wrapped if the underlying field * has a primitive type./*from w w w.j a va 2 s. co m*/ * <p>Thrown exceptions are handled via a call to {@link #handleReflectionException(Exception)}. * @param field the field to get * @param target the target object from which to get the field * @return the field's current value */ public static Object getField(Field field, Object target) { try { return field.get(target); } catch (IllegalAccessException ex) { handleReflectionException(ex); throw new IllegalStateException( "Unexpected reflection exception - " + ex.getClass().getName() + ": " + ex.getMessage()); } }
From source file:com.feilong.taglib.util.TagUtils.java
/** * Locate and return the specified property of the specified bean, from an optionally specified scope, in the specified page context. If * an exception is/*from w w w. j av a 2 s . c om*/ * thrown, it will have already been saved via a call to <code>saveException()</code>. * * @param pageContext * Page context to be searched * @param name * Name of the bean to be retrieved * @param property * Name of the property to be retrieved, or <code>null</code> to retrieve the bean itself * @param scope * Scope to be searched (page, request, session, application) or <code>null</code> to use <code>findAttribute()</code> * instead * @return property of specified JavaBean * @throws JspException * if accessing this property causes an IllegalAccessException, IllegalArgumentException, InvocationTargetException, or * NoSuchMethodException */ public Object lookup(PageContext pageContext, String name, String property, String scope) throws JspException { // Look up the requested bean, and return if requested Object bean = lookup(pageContext, name, scope); if (property == null) { return bean; } // Locate and return the specified property try { return PropertyUtils.getProperty(bean, property); } catch (IllegalAccessException e) { log.error(e.getClass().getName(), e); } catch (InvocationTargetException e) { log.error(e.getClass().getName(), e); } catch (NoSuchMethodException e) { log.error(e.getClass().getName(), e); } return null; }
From source file:com.maverick.ssl.SSLHandshakeProtocol.java
private void onServerHelloMsg(byte[] msg) throws SSLException { try {//from w ww . j a v a2 s . c om ByteArrayInputStream in = new ByteArrayInputStream(msg); majorVersion = in.read(); minorVersion = in.read(); serverRandom = new byte[32]; in.read(serverRandom); sessionID = new byte[(in.read() & 0xFF)]; in.read(sessionID); cipherSuiteID = new SSLCipherSuiteID(in.read(), in.read()); pendingCipherSuite = (SSLCipherSuite) context.getCipherSuiteClass(cipherSuiteID).newInstance(); compressionID = in.read(); currentHandshakeStep = SERVER_HELLO_MSG; } catch (IllegalAccessException ex) { throw new SSLException(SSLException.INTERNAL_ERROR, ex.getMessage() == null ? ex.getClass().getName() : ex.getMessage()); } catch (InstantiationException ex) { throw new SSLException(SSLException.INTERNAL_ERROR, ex.getMessage() == null ? ex.getClass().getName() : ex.getMessage()); } catch (IOException ex) { throw new SSLException(SSLException.INTERNAL_ERROR, ex.getMessage() == null ? ex.getClass().getName() : ex.getMessage()); } }
From source file:org.apache.sshd.common.file.nativefs.ExtendedNativeFileSystemView.java
public ExtendedNativeFileSystemView(String userName, String rootDir, boolean caseInsensitive) { super(userName, caseInsensitive); try {//from www .j a v a 2 s.co m FieldUtils.writeField(currDirField, this, Validate.notEmpty(rootDir, "No root dir specified", ArrayUtils.EMPTY_OBJECT_ARRAY)); } catch (IllegalAccessException e) { throw new IllegalStateException( "Failed (" + e.getClass().getSimpleName() + ") to override currDir: " + e.getMessage(), e); } }
From source file:org.apache.sshd.common.file.nativefs.ExtendedNativeFileSystemView.java
public final String getUsername() { try {/* w w w . j av a 2 s . co m*/ return ExtendedFieldUtils.readTypedField(userNameField, this, String.class); } catch (IllegalAccessException e) { throw new IllegalStateException( "Failed (" + e.getClass().getSimpleName() + ") to read userName: " + e.getMessage(), e); } }
From source file:org.apache.sshd.common.file.nativefs.ExtendedNativeFileSystemView.java
public final String getCurrDir() { try {//from w w w . j a v a2 s . co m return ExtendedFieldUtils.readTypedField(currDirField, this, String.class); } catch (IllegalAccessException e) { throw new IllegalStateException( "Failed (" + e.getClass().getSimpleName() + ") to read currDir: " + e.getMessage(), e); } }