com.android.dx.dex.cf.CfTranslator Java Examples
The following examples show how to use
com.android.dx.dex.cf.CfTranslator.
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: BaseAndroidClassLoader.java From rhino-android with Apache License 2.0 | 6 votes |
/** * {@inheritDoc} */ @Override public Class<?> defineClass(String name, byte[] data) { try { DexOptions dexOptions = new DexOptions(); DexFile dexFile = new DexFile(dexOptions); DirectClassFile classFile = new DirectClassFile(data, name.replace('.', '/') + ".class", true); classFile.setAttributeFactory(StdAttributeFactory.THE_ONE); classFile.getMagic(); DxContext context = new DxContext(); dexFile.add(CfTranslator.translate(context, classFile, null, new CfOptions(), dexOptions, dexFile)); Dex dex = new Dex(dexFile.toDex(null, false)); Dex oldDex = getLastDex(); if (oldDex != null) { dex = new DexMerger(new Dex[]{dex, oldDex}, CollisionPolicy.KEEP_FIRST, context).merge(); } return loadClass(dex, name); } catch (IOException | ClassNotFoundException e) { throw new FatalLoadingException(e); } }
Example #2
Source File: Main.java From Box with Apache License 2.0 | 5 votes |
private ClassDefItem translateClass(byte[] bytes, DirectClassFile cf) { try { return CfTranslator.translate(context, cf, bytes, args.cfOptions, args.dexOptions, outputDex); } catch (ParseException ex) { context.err.println("\ntrouble processing:"); if (args.debug) { ex.printStackTrace(context.err); } else { ex.printContext(context.err); } } errors.incrementAndGet(); return null; }
Example #3
Source File: Main.java From Box with Apache License 2.0 | 5 votes |
private ClassDefItem translateClass(byte[] bytes, DirectClassFile cf) { try { return CfTranslator.translate(context, cf, bytes, args.cfOptions, args.dexOptions, outputDex); } catch (ParseException ex) { context.err.println("\ntrouble processing:"); if (args.debug) { ex.printStackTrace(context.err); } else { ex.printContext(context.err); } } errors.incrementAndGet(); return null; }
Example #4
Source File: MainActivity.java From lua-for-android with BSD 3-Clause "New" or "Revised" License | 5 votes |
public DexFile generateDexFile(List<byte[]> classByteCodes){ DxContext dxContext=new DxContext(); DexOptions dexOptions=new DexOptions(); CfOptions cfOptions=new CfOptions(); DexFile dexFile=new DexFile(dexOptions); for (byte[] cls:classByteCodes){ DirectClassFile directClassFile=new DirectClassFile(cls,"",false); directClassFile.setAttributeFactory(StdAttributeFactory.THE_ONE); directClassFile.getMagic(); dexFile.add(CfTranslator.translate(dxContext,directClassFile,cls,cfOptions,dexOptions,dexFile)); } return dexFile; }
Example #5
Source File: Main.java From J2ME-Loader with Apache License 2.0 | 5 votes |
private ClassDefItem translateClass(byte[] bytes, DirectClassFile cf) { try { return CfTranslator.translate(context, cf, bytes, args.cfOptions, args.dexOptions, outputDex); } catch (ParseException ex) { context.err.println("\ntrouble processing:"); if (args.debug) { ex.printStackTrace(context.err); } else { ex.printContext(context.err); } } errors.incrementAndGet(); return null; }
Example #6
Source File: Dexifier.java From knopflerfish.org with BSD 3-Clause "New" or "Revised" License | 5 votes |
private void addToDexFile(DexFile dexFile, String name, byte[] bytes) { DirectClassFile cf = new DirectClassFile(bytes, name, cfOptions.strictNameCheck); cf.setAttributeFactory(StdAttributeFactory.THE_ONE); cf.getMagic(); int numMethodIds = dexFile.getMethodIds().items().size(); int numFieldIds = dexFile.getFieldIds().items().size(); int constantPoolSize = cf.getConstantPool().size(); int maxMethodIdsInDex = numMethodIds + constantPoolSize + cf.getMethods().size() + MAX_METHOD_ADDED_DURING_DEX_CREATION; int maxFieldIdsInDex = numFieldIds + constantPoolSize + cf.getFields().size() + MAX_FIELD_ADDED_DURING_DEX_CREATION; if ((dexFile.getClassDefs().items().size() > 0) && ((maxMethodIdsInDex > MAX_NUMBER_OF_IDX_PER_DEX) || (maxFieldIdsInDex > MAX_NUMBER_OF_IDX_PER_DEX))) { throw new RuntimeException("TODO multi dex!"); } try { ClassDefItem clazz = CfTranslator.translate(cf, bytes, cfOptions , dexOptions, dexFile); synchronized (dexFile) { dexFile.add(clazz); } } catch (ParseException ex) { Main.exit("Parse error, " + name, ex); } }
Example #7
Source File: Dexing.java From bazel with Apache License 2.0 | 5 votes |
public ClassDefItem addToDexFile(DexFile dest, DirectClassFile classFile) { ClassDefItem result = CfTranslator.translate( context, classFile, (byte[]) null /*ignored*/, cfOptions, dest.getDexOptions(), dest); dest.add(result); return result; }
Example #8
Source File: Main.java From buck with Apache License 2.0 | 5 votes |
private ClassDefItem translateClass(byte[] bytes, DirectClassFile cf) { try { return CfTranslator.translate(context, cf, bytes, args.cfOptions, args.dexOptions, outputDex); } catch (ParseException ex) { context.err.println("\ntrouble processing:"); if (args.debug) { ex.printStackTrace(context.err); } else { ex.printContext(context.err); } } errors.incrementAndGet(); return null; }