/** * 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); } }
private boolean addClassToDex(ClassDefItem clazz) { synchronized (outputDex) { outputDex.add(clazz); } return true; }
private boolean addClassToDex(ClassDefItem clazz) { synchronized (outputDex) { outputDex.add(clazz); } return true; }
private boolean addClassToDex(ClassDefItem clazz) { synchronized (outputDex) { outputDex.add(clazz); } return true; }
@Override public byte[] processBytecode(String s, byte[] bytes) { ClassDefItem classDefItem = CfTranslator.translate(s + ".class", bytes, cfOptions, dexOptions); dexFile.add(classDefItem); classNames.add(s); return bytes; } });
/** * Returns a .dex formatted file. */ public byte[] generate() { DexFile outputDex = new DexFile(new DexOptions()); for (TypeDeclaration typeDeclaration : types.values()) { outputDex.add(typeDeclaration.toClassDefItem()); } try { return outputDex.toDex(null, false); } catch (IOException e) { throw new RuntimeException(e); } }
/** * Generates a dex file and returns its bytes. */ public byte[] generate() { DexOptions options = new DexOptions(); options.targetApiLevel = DexFormat.API_NO_EXTENDED_OPCODES; DexFile 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); } }
cf.getMagic(); file.add(CfTranslator.translate(cf, bytes, cf_options, dex_options, file));
/** * 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); } }
items.add(CfTranslator.translate(cf, bytes, cf_options, dex_options, dexFile)); for(ClassDefItem item : items) dexFile.add(item);
/** * {@inheritDoc} */ public void register(String name, byte[] binaryRepresentation) { DirectClassFile directClassFile = new DirectClassFile(binaryRepresentation, name.replace('.', '/') + CLASS_FILE_EXTENSION, NON_STRICT); directClassFile.setAttributeFactory(new StdAttributeFactory()); dexFile.add(CfTranslator.translate(directClassFile, binaryRepresentation, dexCompilerOptions, dexFileOptions, new DexFile(dexFileOptions))); }
/** * Processes one classfile. * * @param name {@code non-null;} name of the file, clipped such that it * <i>should</i> correspond to the name of the class it contains * @param bytes {@code non-null;} contents of the file * @return whether processing was successful */ private static boolean processClass(String name, byte[] bytes) { if (! args.coreLibrary) { checkClassName(name); } try { ClassDefItem clazz = CfTranslator.translate(name, bytes, args.cfOptions, args.dexOptions); synchronized (outputDex) { outputDex.add(clazz); } return true; } catch (ParseException ex) { DxConsole.err.println("\ntrouble processing:"); if (args.debug) { ex.printStackTrace(DxConsole.err); } else { ex.printContext(DxConsole.err); } } warnings++; return false; }
private static final byte[] dex(String className, byte[] classData) throws ClassFormatError { try { DexOptions dexOptions = new DexOptions(); DexFile dxFile = new DexFile(dexOptions); CfOptions cfOptions = new CfOptions(); dxFile.add(CfTranslator.translate(className.replace('.', '/') + ".class", classData, cfOptions, dexOptions)); StringWriter out = BridJ.debug ? new StringWriter() : null; byte[] dexData = dxFile.toDex(out, false); if (BridJ.debug) { BridJ.info("Dex output for class " + className + " : " + out); } return dexData; } catch (IOException ex) { throw new ClassFormatError("Unable to convert class data to Dalvik code using Dex : " + ex); } }
/** * Processes one classfile. * * @param name {@code non-null;} name of the file, clipped such that it * <i>should</i> correspond to the name of the class it contains * @param bytes {@code non-null;} contents of the file * @return whether processing was successful */ private static boolean processClass(String name, byte[] bytes) { if (! args.coreLibrary) { checkClassName(name); } try { ClassDefItem clazz = CfTranslator.translate(name, bytes, args.cfOptions); outputDex.add(clazz); return true; } catch (ParseException ex) { DxConsole.err.println("\ntrouble processing:"); if (args.debug) { ex.printStackTrace(DxConsole.err); } else { ex.printContext(DxConsole.err); } } warnings++; return false; }
ClassDefItem item= CfTranslator.translate(relativePath, classFile.getDataAsBytes(), options); DexFile dexFile= new DexFile(); dexFile.add(item); try
CfTranslator.translate(cf, bytes, args.cfOptions, args.dexOptions, outputDex); synchronized (outputDex) { outputDex.add(clazz);