use of org.reflections.ReflectionsException in project reflections by ronmamo.
the class Utils method getFieldFromString.
public static Field getFieldFromString(String field, ClassLoader... classLoaders) {
String className = field.substring(0, field.lastIndexOf('.'));
String fieldName = field.substring(field.lastIndexOf('.') + 1);
try {
return forName(className, classLoaders).getDeclaredField(fieldName);
} catch (NoSuchFieldException e) {
throw new ReflectionsException("Can't resolve field named " + fieldName, e);
}
}
use of org.reflections.ReflectionsException in project reflections by ronmamo.
the class JavassistAdapter method getOfCreateClassObject.
public ClassFile getOfCreateClassObject(final Vfs.File file) {
InputStream inputStream = null;
try {
inputStream = file.openInputStream();
DataInputStream dis = new DataInputStream(new BufferedInputStream(inputStream));
return new ClassFile(dis);
} catch (IOException e) {
throw new ReflectionsException("could not create class file from " + file.getName(), e);
} finally {
Utils.close(inputStream);
}
}
use of org.reflections.ReflectionsException in project reflections by ronmamo.
the class MemberUsageScanner method scan.
@Override
public void scan(Object cls) {
try {
CtClass ctClass = getClassPool().get(getMetadataAdapter().getClassName(cls));
for (CtBehavior member : ctClass.getDeclaredConstructors()) {
scanMember(member);
}
for (CtBehavior member : ctClass.getDeclaredMethods()) {
scanMember(member);
}
ctClass.detach();
} catch (Exception e) {
throw new ReflectionsException("Could not scan method usage for " + getMetadataAdapter().getClassName(cls), e);
}
}
use of org.reflections.ReflectionsException in project reflections by ronmamo.
the class JavaCodeSerializer method resolveField.
public static Field resolveField(final Class aField) {
try {
String name = aField.getSimpleName();
Class<?> declaringClass = aField.getDeclaringClass().getDeclaringClass();
return resolveClassOf(declaringClass).getDeclaredField(name);
} catch (Exception e) {
throw new ReflectionsException("could not resolve to field " + aField.getName(), e);
}
}
use of org.reflections.ReflectionsException in project reflections by ronmamo.
the class MemberUsageScanner method scan.
@Override
public List<Map.Entry<String, String>> scan(ClassFile classFile) {
List<Map.Entry<String, String>> entries = new ArrayList<>();
CtClass ctClass = null;
try {
ctClass = getClassPool().get(classFile.getName());
for (CtBehavior member : ctClass.getDeclaredConstructors()) {
scanMember(member, entries);
}
for (CtBehavior member : ctClass.getDeclaredMethods()) {
scanMember(member, entries);
}
} catch (Exception e) {
throw new ReflectionsException("Could not scan method usage for " + classFile.getName(), e);
} finally {
if (ctClass != null) {
ctClass.detach();
}
}
return entries;
}
Aggregations