Share

Search Java Code Snippets


  Help us in improving the repository. Add new snippets through 'Submit Code Snippet ' link.





#Java - Code Snippets for '#Reflection' - 4 code snippet(s) found

 Sample 1. Loading Class using Class.forName ( Reflection )

Class clazz = null;
try {
   clazz = Class.forName("sun.awt.windows.WEmbeddedFrame");
} catch (Throwable e) {
}

Constructor constructor = null;
try {
   constructor = clazz.getConstructor(new Class[] { Integer.TYPE });
} catch (Throwable localThrowable1) {
}

   Like      Feedback     Class.forName  Reflection


 Sample 2. Usage of java.lang.reflect.Field;

Form form1 = resources.getForm("fr", "", "", "testForm1_fr");
Field field1 = form1.getField("testProperty1");

   Like      Feedback     Reflection   java.lang.reflect.Field


 Sample 3. Usage of java.lang.reflect.Modifier

Field f = DomainValidator.class.getDeclaredField(arrayName);
final boolean isPrivate = Modifier.isPrivate(f.getModifiers());
if (isPrivate) {
f.setAccessible(true);
}

   Like      Feedback     Reflection  java.lang.reflect.Modifier


 Sample 4. Usage of java.lang.reflect.ParameterizedType

ParameterizedType ptype = (ParameterizedType)type;
Class raw = (Class)ptype.getRawType();

   Like      Feedback     Reflection  ParameterizedType



Subscribe to Java News and Posts. Get latest updates and posts on Java from Buggybread.com
Enter your email address:
Delivered by FeedBurner



comments powered by Disqus