use of com.android.dx.cf.direct.DirectClassFile in project buck by facebook.
the class BlockDumper method dump.
/**
* Does the dumping.
*/
public void dump() {
byte[] bytes = getBytes();
ByteArray ba = new ByteArray(bytes);
/*
* First, parse the file completely, so we can safely refer to
* attributes, etc.
*/
classFile = new DirectClassFile(ba, getFilePath(), getStrictParse());
classFile.setAttributeFactory(StdAttributeFactory.THE_ONE);
// Force parsing to happen.
classFile.getMagic();
// Next, reparse it and observe the process.
DirectClassFile liveCf = new DirectClassFile(ba, getFilePath(), getStrictParse());
liveCf.setAttributeFactory(StdAttributeFactory.THE_ONE);
liveCf.setObserver(this);
// Force parsing to happen.
liveCf.getMagic();
}
use of com.android.dx.cf.direct.DirectClassFile in project kotlin by JetBrains.
the class DxChecker method checkFileWithDx.
private static void checkFileWithDx(byte[] bytes, @NotNull String relativePath, @NotNull Main.Arguments arguments) {
DirectClassFile cf = new DirectClassFile(bytes, relativePath, true);
cf.setAttributeFactory(StdAttributeFactory.THE_ONE);
CfTranslator.translate(cf, bytes, arguments.cfOptions, arguments.dexOptions, new DexFile(arguments.dexOptions));
}
use of com.android.dx.cf.direct.DirectClassFile in project RocooFix by dodola.
the class Path method getClass.
synchronized DirectClassFile getClass(String path) throws FileNotFoundException {
DirectClassFile classFile = null;
for (ClassPathElement element : elements) {
try {
InputStream in = element.open(path);
try {
byte[] bytes = readStream(in, baos, readBuffer);
baos.reset();
classFile = new DirectClassFile(bytes, path, false);
classFile.setAttributeFactory(StdAttributeFactory.THE_ONE);
break;
} finally {
in.close();
}
} catch (IOException e) {
// search next element
}
}
if (classFile == null) {
throw new FileNotFoundException("File \"" + path + "\" not found");
}
return classFile;
}
use of com.android.dx.cf.direct.DirectClassFile in project RocooFix by dodola.
the class ClassReferenceListBuilder method addRoots.
/**
* @param jarOfRoots Archive containing the class files resulting of the tracing, typically
* this is the result of running ProGuard.
*/
public void addRoots(ZipFile jarOfRoots) throws IOException {
// keep roots
for (Enumeration<? extends ZipEntry> entries = jarOfRoots.entries(); entries.hasMoreElements(); ) {
ZipEntry entry = entries.nextElement();
String name = entry.getName();
if (name.endsWith(CLASS_EXTENSION)) {
classNames.add(name.substring(0, name.length() - CLASS_EXTENSION.length()));
}
}
// keep direct references of roots (+ direct references hierarchy)
for (Enumeration<? extends ZipEntry> entries = jarOfRoots.entries(); entries.hasMoreElements(); ) {
ZipEntry entry = entries.nextElement();
String name = entry.getName();
if (name.endsWith(CLASS_EXTENSION)) {
DirectClassFile classFile;
try {
classFile = path.getClass(name);
addDependencies(classFile);
} catch (FileNotFoundException e) {
}
}
}
}
use of com.android.dx.cf.direct.DirectClassFile in project RocooFix by dodola.
the class Path method getClass.
synchronized DirectClassFile getClass(String path) throws FileNotFoundException {
DirectClassFile classFile = null;
for (ClassPathElement element : elements) {
try {
InputStream in = element.open(path);
try {
byte[] bytes = readStream(in, baos, readBuffer);
baos.reset();
classFile = new DirectClassFile(bytes, path, false);
classFile.setAttributeFactory(StdAttributeFactory.THE_ONE);
break;
} finally {
in.close();
}
} catch (IOException e) {
// search next element
}
}
if (classFile == null) {
throw new FileNotFoundException("File \"" + path + "\" not found");
}
return classFile;
}
Aggregations