use of org.reflections.ReflectionsException in project reflections by ronmamo.
the class MemberUsageScanner method scanMember.
private void scanMember(CtBehavior member, List<Map.Entry<String, String>> entries) throws CannotCompileException {
// key contains this$/val$ means local field/parameter closure
final String key = member.getDeclaringClass().getName() + "." + member.getMethodInfo().getName() + "(" + parameterNames(member.getMethodInfo()) + // + " #" + member.getMethodInfo().getLineNumber(0)
")";
member.instrument(new ExprEditor() {
@Override
public void edit(NewExpr e) {
try {
add(entries, e.getConstructor().getDeclaringClass().getName() + "." + "<init>" + "(" + parameterNames(e.getConstructor().getMethodInfo()) + ")", key + " #" + e.getLineNumber());
} catch (NotFoundException e1) {
throw new ReflectionsException("Could not find new instance usage in " + key, e1);
}
}
@Override
public void edit(MethodCall m) {
try {
add(entries, m.getMethod().getDeclaringClass().getName() + "." + m.getMethodName() + "(" + parameterNames(m.getMethod().getMethodInfo()) + ")", key + " #" + m.getLineNumber());
} catch (NotFoundException e) {
throw new ReflectionsException("Could not find member " + m.getClassName() + " in " + key, e);
}
}
@Override
public void edit(ConstructorCall c) {
try {
add(entries, c.getConstructor().getDeclaringClass().getName() + "." + "<init>" + "(" + parameterNames(c.getConstructor().getMethodInfo()) + ")", key + " #" + c.getLineNumber());
} catch (NotFoundException e) {
throw new ReflectionsException("Could not find member " + c.getClassName() + " in " + key, e);
}
}
@Override
public void edit(FieldAccess f) {
try {
add(entries, f.getField().getDeclaringClass().getName() + "." + f.getFieldName(), key + " #" + f.getLineNumber());
} catch (NotFoundException e) {
throw new ReflectionsException("Could not find member " + f.getFieldName() + " in " + key, e);
}
}
});
}
use of org.reflections.ReflectionsException in project reflections by ronmamo.
the class JarInputDir method getFiles.
public Iterable<Vfs.File> getFiles() {
return () -> new Iterator<Vfs.File>() {
{
try {
jarInputStream = new JarInputStream(url.openConnection().getInputStream());
} catch (Exception e) {
throw new ReflectionsException("Could not open url connection", e);
}
}
Vfs.File entry = null;
@Override
public boolean hasNext() {
return entry != null || (entry = computeNext()) != null;
}
@Override
public Vfs.File next() {
Vfs.File next = entry;
entry = null;
return next;
}
private Vfs.File computeNext() {
while (true) {
try {
ZipEntry entry = jarInputStream.getNextJarEntry();
if (entry == null) {
return null;
}
long size = entry.getSize();
// JDK-6916399
if (size < 0)
size = 0xffffffffl + size;
nextCursor += size;
if (!entry.isDirectory()) {
return new JarInputFile(entry, JarInputDir.this, cursor, nextCursor);
}
} catch (IOException e) {
throw new ReflectionsException("could not get next zip entry", e);
}
}
}
};
}
Aggregations