use of org.objectweb.asm.ClassReader in project bazel by bazelbuild.
the class JavacTurbine method processBytecode.
/**
* Remove code attributes and private members.
*
* <p>Most code will already have been removed after parsing, but the bytecode will still contain
* e.g. lowered class and instance initializers.
*/
private static byte[] processBytecode(byte[] bytes) {
ClassWriter cw = new ClassWriter(0);
new ClassReader(bytes).accept(new PrivateMemberPruner(cw), ClassReader.SKIP_CODE | ClassReader.SKIP_FRAMES | ClassReader.SKIP_DEBUG);
return cw.toByteArray();
}
use of org.objectweb.asm.ClassReader in project auto by google.
the class AbstractMethodLister method abstractNoArgMethodsX.
private ImmutableList<String> abstractNoArgMethodsX() throws IOException {
ClassReader classReader = new ClassReader(inputStream);
RecordingClassVisitor classVisitor = new RecordingClassVisitor();
classReader.accept(classVisitor, 0);
return classVisitor.abstractNoArgMethods.build();
}
use of org.objectweb.asm.ClassReader in project gradle by gradle.
the class AbstractTestFrameworkDetector method classVisitor.
protected TestClassVisitor classVisitor(final File testClassFile) {
final TestClassVisitor classVisitor = createClassVisitor();
InputStream classStream = null;
try {
classStream = new BufferedInputStream(new FileInputStream(testClassFile));
final ClassReader classReader = new Java9ClassReader(IOUtils.toByteArray(classStream));
classReader.accept(classVisitor, ClassReader.SKIP_DEBUG | ClassReader.SKIP_CODE | ClassReader.SKIP_FRAMES);
} catch (Throwable e) {
throw new GradleException("failed to read class file " + testClassFile.getAbsolutePath(), e);
} finally {
IOUtils.closeQuietly(classStream);
}
return classVisitor;
}
use of org.objectweb.asm.ClassReader in project gradle by gradle.
the class MixInLegacyTypesClassLoader method transform.
@Override
protected byte[] transform(String className, byte[] bytes) {
ClassReader classReader = new Java9ClassReader(bytes);
ClassWriter classWriter = new ClassWriter(0);
classReader.accept(new TransformingAdapter(classWriter), 0);
bytes = classWriter.toByteArray();
return bytes;
}
use of org.objectweb.asm.ClassReader in project gradle by gradle.
the class ClassChangeProcessor method processChange.
public void processChange(final InputFileDetails input, final RecompilationSpec spec) {
if (input.isRemoved()) {
// this is a really heavyweight way of getting the dependencies of a file which was removed
// hopefully this is not going to happen too often
String className = previousCompilation.getClassName(input.getFile().getAbsolutePath());
update(input, spec, className, Collections.<Integer>emptySet());
return;
}
final ClassReader classReader;
try {
classReader = new Java9ClassReader(Files.toByteArray(input.getFile()));
String className = classReader.getClassName().replaceAll("/", ".");
Set<Integer> constants = ClassDependenciesVisitor.retrieveConstants(classReader);
update(input, spec, className, constants);
} catch (IOException e) {
throw new IllegalArgumentException(String.format("Unable to read class file: '%s'", input.getFile()));
}
}
Aggregations