use of org.apache.xbean.asm6.ClassReader in project tomee by apache.
the class DynamicSubclass method copyClassAnnotations.
private static void copyClassAnnotations(final Class<?> clazz, final ClassVisitor newClass) throws ProxyGenerationException {
try {
final ClassReader classReader = new ClassReader(readClassFile(clazz));
final ClassVisitor visitor = new CopyClassAnnotations(newClass);
classReader.accept(visitor, ClassReader.SKIP_CODE);
} catch (final IOException e) {
throw new ProxyGenerationException(e);
}
}
use of org.apache.xbean.asm6.ClassReader in project tomee by apache.
the class DependenceValidationTest method file.
private static void file(final File file, final DependencyVisitor dependencyVisitor) {
try {
final InputStream in = IO.read(file);
try {
final ClassReader classReader = new ClassReader(in);
classReader.accept(dependencyVisitor, ClassWriter.COMPUTE_MAXS);
} finally {
IO.close(in);
}
} catch (final IOException e) {
e.printStackTrace();
fail(e.getMessage());
}
}
use of org.apache.xbean.asm6.ClassReader in project component-runtime by Talend.
the class ProxyGenerator method findJavaVersion.
private int findJavaVersion(final Class<?> from) {
final String resource = from.getName().replace('.', '/') + ".class";
try (final InputStream stream = from.getClassLoader().getResourceAsStream(resource)) {
if (stream == null) {
return javaVersion;
}
final ClassReader reader = new ClassReader(stream);
final VersionVisitor visitor = new VersionVisitor();
reader.accept(visitor, SKIP_DEBUG);
if (visitor.version != 0) {
return visitor.version;
}
} catch (final Exception e) {
// no-op
}
// version
return javaVersion;
}
use of org.apache.xbean.asm6.ClassReader in project component-runtime by Talend.
the class BeamIOTransformer method rewrite.
private byte[] rewrite(final ConfigurableClassLoader loader, final String className, final byte[] classfileBuffer, final ClassLoader tmpLoader) {
final String plugin = loader.getId();
final ClassReader reader = new ClassReader(classfileBuffer);
final ComponentClassWriter writer = new ComponentClassWriter(className.replace('/', '.'), tmpLoader, reader, ClassWriter.COMPUTE_FRAMES);
final ComponentClassVisitor visitor = new ComponentClassVisitor(writer, plugin);
reader.accept(visitor, ClassReader.SKIP_FRAMES);
return writer.toByteArray();
}
Aggregations