use of com.android.dx.dex.file.DexFile in project byte-buddy by raphw.
the class AndroidClassLoadingStrategyTest method testObjectProperties.
@Test
public void testObjectProperties() throws Exception {
ObjectPropertyAssertion.of(AndroidClassLoadingStrategy.DexProcessor.ForSdkCompiler.class).apply();
ObjectPropertyAssertion.of(AndroidClassLoadingStrategy.DexProcessor.ForSdkCompiler.Conversion.class).create(new ObjectPropertyAssertion.Creator<DexFile>() {
@Override
public DexFile create() {
return new DexFile(new DexOptions());
}
}).apply();
}
use of com.android.dx.dex.file.DexFile in project J2ME-Loader by nikita36078.
the class Main method runMonoDex.
private int runMonoDex() throws IOException {
File incrementalOutFile = null;
if (args.incremental) {
if (args.outName == null) {
context.err.println("error: no incremental output name specified");
return -1;
}
incrementalOutFile = new File(args.outName);
if (incrementalOutFile.exists()) {
minimumFileAge = incrementalOutFile.lastModified();
}
}
if (!processAllFiles()) {
return 1;
}
if (args.incremental && !anyFilesProcessed) {
// this was a no-op incremental build
return 0;
}
// this array is null if no classes were defined
byte[] outArray = null;
if (!outputDex.isEmpty() || (args.humanOutName != null)) {
outArray = writeDex(outputDex);
if (outArray == null) {
return 2;
}
}
if (args.incremental) {
outArray = mergeIncremental(outArray, incrementalOutFile);
}
outArray = mergeLibraryDexBuffers(outArray);
if (args.jarOutput) {
// Effectively free up the (often massive) DexFile memory.
outputDex = null;
if (outArray != null) {
outputResources.put(DexFormat.DEX_IN_JAR_NAME, outArray);
}
if (!createJar(args.outName)) {
return 3;
}
} else if (outArray != null && args.outName != null) {
OutputStream out = openOutput(args.outName);
out.write(outArray);
closeOutput(out);
}
return 0;
}
use of com.android.dx.dex.file.DexFile in project J2ME-Loader by nikita36078.
the class Main method runMultiDex.
private int runMultiDex() throws IOException {
assert !args.incremental;
if (args.mainDexListFile != null) {
classesInMainDex = new HashSet<String>();
readPathsFromFile(args.mainDexListFile, classesInMainDex);
}
dexOutPool = Executors.newFixedThreadPool(args.numThreads);
if (!processAllFiles()) {
return 1;
}
if (!libraryDexBuffers.isEmpty()) {
throw new DexException("Library dex files are not supported in multi-dex mode");
}
if (outputDex != null) {
// this array is null if no classes were defined
dexOutputFutures.add(dexOutPool.submit(new DexWriter(outputDex)));
// Effectively free up the (often massive) DexFile memory.
outputDex = null;
}
try {
dexOutPool.shutdown();
if (!dexOutPool.awaitTermination(600L, TimeUnit.SECONDS)) {
throw new RuntimeException("Timed out waiting for dex writer threads.");
}
for (Future<byte[]> f : dexOutputFutures) {
dexOutputArrays.add(f.get());
}
} catch (InterruptedException ex) {
dexOutPool.shutdownNow();
throw new RuntimeException("A dex writer thread has been interrupted.");
} catch (Exception e) {
dexOutPool.shutdownNow();
throw new RuntimeException("Unexpected exception in dex writer thread");
}
if (args.jarOutput) {
for (int i = 0; i < dexOutputArrays.size(); i++) {
outputResources.put(getDexFileName(i), dexOutputArrays.get(i));
}
if (!createJar(args.outName)) {
return 3;
}
} else if (args.outName != null) {
File outDir = new File(args.outName);
assert outDir.isDirectory();
for (int i = 0; i < dexOutputArrays.size(); i++) {
OutputStream out = new FileOutputStream(new File(outDir, getDexFileName(i)));
try {
out.write(dexOutputArrays.get(i));
} finally {
closeOutput(out);
}
}
}
return 0;
}
use of com.android.dx.dex.file.DexFile in project dexmaker by linkedin.
the class DexMaker method generate.
/**
* Generates a dex file and returns its bytes.
*/
public byte[] generate() {
if (outputDex == null) {
DexOptions options = new DexOptions();
options.targetApiLevel = DexFormat.API_NO_EXTENDED_OPCODES;
outputDex = new DexFile(options);
}
for (TypeDeclaration typeDeclaration : types.values()) {
outputDex.add(typeDeclaration.toClassDefItem());
}
try {
return outputDex.toDex(null, false);
} catch (IOException e) {
throw new RuntimeException(e);
}
}
Aggregations