use of org.apache.xbean.asm9.ClassReader in project tomee by apache.
the class ValidationKeysAuditorTest method file.
private static void file(final File file, final KeysAnnotationVisitor visitor) {
try {
final InputStream in = IO.read(file);
try {
final ClassReader classReader = new ClassReader(in);
classReader.accept(visitor, ClassWriter.COMPUTE_FRAMES);
} finally {
IO.close(in);
}
} catch (final IOException e) {
e.printStackTrace();
}
}
use of org.apache.xbean.asm9.ClassReader in project tomee by apache.
the class JpaTest method addNewField.
public static byte[] addNewField(final byte[] origBytes) {
final ClassWriter classWriter = new ClassWriter(ClassWriter.COMPUTE_FRAMES);
final FieldAdderClassVisitor visitor = new FieldAdderClassVisitor(classWriter);
final ClassReader classReader = new ClassReader(origBytes);
classReader.accept(visitor, 0);
return classWriter.toByteArray();
}
use of org.apache.xbean.asm9.ClassReader in project tomee by apache.
the class DynamicSubclass method copyMethodAnnotations.
public static void copyMethodAnnotations(final Class<?> classToProxy, final Map<String, MethodVisitor> visitors) throws ProxyGenerationException {
// Move all the annotations onto the newly implemented methods
// Ensures CDI and JAX-RS and JAX-WS still work
Class clazz = classToProxy;
while (clazz != null && !clazz.equals(Object.class)) {
try {
final ClassReader classReader = new ClassReader(readClassFile(clazz));
final ClassVisitor copyMethodAnnotations = new CopyMethodAnnotations(visitors);
classReader.accept(copyMethodAnnotations, ClassReader.SKIP_CODE);
} catch (final IOException e) {
throw new ProxyGenerationException(e);
}
clazz = clazz.getSuperclass();
}
}
use of org.apache.xbean.asm9.ClassReader in project geronimo-xbean by apache.
the class XbeanAsmParameterNameLoader method createClassReader.
private static ClassReader createClassReader(Class declaringClass) throws IOException {
InputStream in = null;
try {
ClassLoader classLoader = declaringClass.getClassLoader();
in = classLoader.getResourceAsStream(declaringClass.getName().replace('.', '/') + ".class");
ClassReader reader = new ClassReader(in);
return reader;
} finally {
if (in != null) {
try {
in.close();
} catch (IOException ignored) {
}
}
}
}
use of org.apache.xbean.asm9.ClassReader in project jodd by oblac.
the class ProxyAspectData method getCachedAdviceClassReader.
/**
* Returns class reader for advice.
*/
private ClassReader getCachedAdviceClassReader(Class<? extends ProxyAdvice> advice) {
if (adviceClassReaderCache == null) {
adviceClassReaderCache = new HashMap<>();
}
ClassReader adviceReader = adviceClassReaderCache.get(advice);
if (adviceReader == null) {
adviceReader = createAdviceClassReader(advice);
adviceClassReaderCache.put(advice, adviceReader);
}
return adviceReader;
}
Aggregations