use of java.lang.reflect.Field in project freeline by alibaba.
the class ReflectUtil method fieldGet.
public static Object fieldGet(Object object, String fieldName) throws Exception {
Field field = object.getClass().getDeclaredField(fieldName);
field.setAccessible(true);
return field.get(object);
}
use of java.lang.reflect.Field in project freeline by alibaba.
the class ReflectUtil method fieldSet.
public static void fieldSet(Object object, Class<?> clazz, String fieldName, Object value) throws Exception {
Field field = clazz.getDeclaredField(fieldName);
field.setAccessible(true);
field.set(object, value);
}
use of java.lang.reflect.Field in project freeline by alibaba.
the class ReflectUtil method fieldGet.
public static Object fieldGet(Object object, Class<?> clazz, String fieldName) throws Exception {
Field field = clazz.getDeclaredField(fieldName);
field.setAccessible(true);
return field.get(object);
}
use of java.lang.reflect.Field in project freeline by alibaba.
the class FreelineCore method getPackageInfo.
private static Object getPackageInfo(Application app) throws NoSuchFieldException, IllegalArgumentException, IllegalAccessException {
Context contextImpl = app.getBaseContext();
Field mPackageInfoField = contextImpl.getClass().getDeclaredField("mPackageInfo");
mPackageInfoField.setAccessible(true);
Object mPackageInfo = mPackageInfoField.get(contextImpl);
return mPackageInfo;
}
use of java.lang.reflect.Field in project dbeaver by serge-rider.
the class DBIcon method loadIcons.
public static void loadIcons(Class<?> aClass) {
Bundle iconBundle = FrameworkUtil.getBundle(aClass);
if (iconBundle == null) {
log.error("Can't find bundle for class '" + aClass.getName() + "'");
return;
}
for (Field field : aClass.getDeclaredFields()) {
if ((field.getModifiers() & Modifier.STATIC) == 0 || field.getType() != DBIcon.class) {
continue;
}
try {
DBIcon icon = (DBIcon) field.get(null);
if (!icon.path.startsWith("platform:")) {
icon.path = "platform:/plugin/" + iconBundle.getSymbolicName() + "/icons/" + icon.path;
}
URL fileURL = FileLocator.toFileURL(new URL(icon.path));
try {
String filePath = fileURL.toString().replace(" ", "%20");
File file = new File(new URI(filePath));
if (!file.exists()) {
log.warn("Bad image '" + icon.getToken() + "' location: " + icon.getLocation());
continue;
}
DBIcon.iconMap.put(icon.getToken(), icon);
} catch (URISyntaxException e) {
throw new IOException("Bad local file path: " + fileURL, e);
}
} catch (Exception e) {
log.error(e);
}
}
}
Aggregations