use of com.android.dx.dex.DexOptions 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.minSdkVersion = 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);
}
}
use of com.android.dx.dex.DexOptions in project UniverseCore by EB-wilson.
the class DexMaker method generate.
/**
* Generates a dex file and returns its bytes.
*/
public byte[] generate() {
if (outputDex == null) {
DexOptions options = new DexOptions();
options.minSdkVersion = 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);
}
}
use of com.android.dx.dex.DexOptions in project UniverseCore by EB-wilson.
the class DexMaker method getDexFile.
DexFile getDexFile() {
if (outputDex == null) {
DexOptions options = new DexOptions();
options.minSdkVersion = DexFormat.API_NO_EXTENDED_OPCODES;
outputDex = new DexFile(options);
}
return outputDex;
}
use of com.android.dx.dex.DexOptions in project QTool by Hicores.
the class DiscreteFilesClassLoader method findClass.
/**
*/
public Class findClass(String name) throws ClassNotFoundException {
// Load it if it's one of our classes
ClassSource source = map.get(name);
if (source != null) {
byte[] code = source.getCode(name);
try {
DexOptions dexOptions = new DexOptions();
DexFile dexFile = new DexFile(dexOptions);
DxContext dxContext = new DxContext();
DirectClassFile directClassFile = new DirectClassFile(code, String.format("%s.class", name.replace(".", "/")), true);
directClassFile.setAttributeFactory(StdAttributeFactory.THE_ONE);
dexFile.add(CfTranslator.translate(dxContext, directClassFile, code, new CfOptions(), dexOptions, dexFile));
ByteArrayOutputStream byteArrayOutputStream = new ByteArrayOutputStream();
dexFile.writeTo(byteArrayOutputStream, null, true);
byteArrayOutputStream.close();
byte[] byteArray = byteArrayOutputStream.toByteArray();
if (byteArray != null) {
ClassLoader mLoader = new InMemoryDexClassLoader(ByteBuffer.wrap(byteArray), new FixClassloader(getClass().getClassLoader(), this.classManager));
Class<?> loadClass = mLoader.loadClass(name);
this.classManager.classMap.put(name, loadClass);
return loadClass;
}
return defineClass(name, code, 0, code.length);
} catch (Exception ioe) {
}
return defineClass(name, code, 0, code.length);
} else
// to find the class...
return super.findClass(name);
}
Aggregations