use of com.android.dx.dex.DexOptions in project dexmaker by linkedin.
the class DexMaker method getDexFile.
DexFile getDexFile() {
if (outputDex == null) {
DexOptions options = new DexOptions();
options.targetApiLevel = DexFormat.API_NO_EXTENDED_OPCODES;
outputDex = new DexFile(options);
}
return outputDex;
}
use of com.android.dx.dex.DexOptions in project HL4A by HL4A.
the class 基本加载器 method defineClass.
public Class<?> defineClass(String name, byte[] data) {
try {
DexOptions dexOptions = new DexOptions();
com.android.dx.dex.file.DexFile dexFile = new com.android.dx.dex.file.DexFile(dexOptions);
DirectClassFile classFile = new DirectClassFile(data, name.replace('.', '/') + ".class", true);
classFile.setAttributeFactory(StdAttributeFactory.THE_ONE);
classFile.getMagic();
dexFile.add(CfTranslator.translate(classFile, null, new CfOptions(), dexOptions, dexFile));
Dex dex = new Dex(dexFile.toDex(null, false));
if (oldDex != null) {
dex = new DexMerger(dex, oldDex, CollisionPolicy.KEEP_FIRST).merge();
}
return loadClass(dex, name);
} catch (IOException | ClassNotFoundException e) {
throw new FatalLoadingException(e);
}
}
use of com.android.dx.dex.DexOptions 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.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.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);
}
}
use of com.android.dx.dex.DexOptions in project HL4A by HL4A.
the class DEX method 单个.
public static void 单个(String $文件, String $类名, String $输出) throws IOException {
byte[] $字节 = 字节.读取($文件);
DexOptions dexOptions = new DexOptions();
com.android.dx.dex.file.DexFile dexFile = new com.android.dx.dex.file.DexFile(dexOptions);
DirectClassFile classFile = new DirectClassFile($字节, $类名.replace('.', '/') + ".class", true);
classFile.setAttributeFactory(StdAttributeFactory.THE_ONE);
classFile.getMagic();
dexFile.add(CfTranslator.translate(classFile, null, new CfOptions(), dexOptions, dexFile));
Dex dex = new Dex(dexFile.toDex(null, false));
dex.writeTo(文件.取文件对象($输出));
}
Aggregations