com.android.dx.cf.direct.StdAttributeFactory Java Examples
The following examples show how to use
com.android.dx.cf.direct.StdAttributeFactory.
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: ClassDumper.java From Box with Apache License 2.0 | 6 votes |
/** * Does the dumping. */ public void dump() { byte[] bytes = getBytes(); ByteArray ba = new ByteArray(bytes); DirectClassFile cf = new DirectClassFile(ba, getFilePath(), getStrictParse()); cf.setAttributeFactory(StdAttributeFactory.THE_ONE); cf.setObserver(this); cf.getMagic(); // Force parsing to happen. int readBytes = getReadBytes(); if (readBytes != bytes.length) { parsed(ba, readBytes, bytes.length - readBytes, "<extra data at end of file>"); } }
Example #2
Source File: DotDumper.java From buck with Apache License 2.0 | 6 votes |
private void run() { ByteArray ba = new ByteArray(bytes); /* * First, parse the file completely, so we can safely refer to * attributes, etc. */ classFile = new DirectClassFile(ba, filePath, strictParse); classFile.setAttributeFactory(StdAttributeFactory.THE_ONE); classFile.getMagic(); // Force parsing to happen. // Next, reparse it and observe the process. DirectClassFile liveCf = new DirectClassFile(ba, filePath, strictParse); liveCf.setAttributeFactory(StdAttributeFactory.THE_ONE); liveCf.setObserver(this); liveCf.getMagic(); // Force parsing to happen. }
Example #3
Source File: BlockDumper.java From buck with Apache License 2.0 | 6 votes |
/** * Does the dumping. */ public void dump() { byte[] bytes = getBytes(); ByteArray ba = new ByteArray(bytes); /* * First, parse the file completely, so we can safely refer to * attributes, etc. */ classFile = new DirectClassFile(ba, getFilePath(), getStrictParse()); classFile.setAttributeFactory(StdAttributeFactory.THE_ONE); classFile.getMagic(); // Force parsing to happen. // Next, reparse it and observe the process. DirectClassFile liveCf = new DirectClassFile(ba, getFilePath(), getStrictParse()); liveCf.setAttributeFactory(StdAttributeFactory.THE_ONE); liveCf.setObserver(this); liveCf.getMagic(); // Force parsing to happen. }
Example #4
Source File: ClassDumper.java From buck with Apache License 2.0 | 6 votes |
/** * Does the dumping. */ public void dump() { byte[] bytes = getBytes(); ByteArray ba = new ByteArray(bytes); DirectClassFile cf = new DirectClassFile(ba, getFilePath(), getStrictParse()); cf.setAttributeFactory(StdAttributeFactory.THE_ONE); cf.setObserver(this); cf.getMagic(); // Force parsing to happen. int at = getAt(); if (at != bytes.length) { parsed(ba, at, bytes.length - at, "<extra data at end of file>"); } }
Example #5
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 #6
Source File: DotDumper.java From Box with Apache License 2.0 | 6 votes |
private void run() { ByteArray ba = new ByteArray(bytes); /* * First, parse the file completely, so we can safely refer to * attributes, etc. */ classFile = new DirectClassFile(ba, filePath, strictParse); classFile.setAttributeFactory(StdAttributeFactory.THE_ONE); classFile.getMagic(); // Force parsing to happen. // Next, reparse it and observe the process. DirectClassFile liveCf = new DirectClassFile(ba, filePath, strictParse); liveCf.setAttributeFactory(StdAttributeFactory.THE_ONE); liveCf.setObserver(this); liveCf.getMagic(); // Force parsing to happen. }
Example #7
Source File: BlockDumper.java From Box with Apache License 2.0 | 6 votes |
/** * Does the dumping. */ public void dump() { byte[] bytes = getBytes(); ByteArray ba = new ByteArray(bytes); /* * First, parse the file completely, so we can safely refer to * attributes, etc. */ classFile = new DirectClassFile(ba, getFilePath(), getStrictParse()); classFile.setAttributeFactory(StdAttributeFactory.THE_ONE); classFile.getMagic(); // Force parsing to happen. // Next, reparse it and observe the process. DirectClassFile liveCf = new DirectClassFile(ba, getFilePath(), getStrictParse()); liveCf.setAttributeFactory(StdAttributeFactory.THE_ONE); liveCf.setObserver(this); liveCf.getMagic(); // Force parsing to happen. }
Example #8
Source File: ClassDumper.java From Box with Apache License 2.0 | 6 votes |
/** * Does the dumping. */ public void dump() { byte[] bytes = getBytes(); ByteArray ba = new ByteArray(bytes); DirectClassFile cf = new DirectClassFile(ba, getFilePath(), getStrictParse()); cf.setAttributeFactory(StdAttributeFactory.THE_ONE); cf.setObserver(this); cf.getMagic(); // Force parsing to happen. int readBytes = getReadBytes(); if (readBytes != bytes.length) { parsed(ba, readBytes, bytes.length - readBytes, "<extra data at end of file>"); } }
Example #9
Source File: DotDumper.java From Box with Apache License 2.0 | 6 votes |
private void run() { ByteArray ba = new ByteArray(bytes); /* * First, parse the file completely, so we can safely refer to * attributes, etc. */ classFile = new DirectClassFile(ba, filePath, strictParse); classFile.setAttributeFactory(StdAttributeFactory.THE_ONE); classFile.getMagic(); // Force parsing to happen. // Next, reparse it and observe the process. DirectClassFile liveCf = new DirectClassFile(ba, filePath, strictParse); liveCf.setAttributeFactory(StdAttributeFactory.THE_ONE); liveCf.setObserver(this); liveCf.getMagic(); // Force parsing to happen. }
Example #10
Source File: BlockDumper.java From Box with Apache License 2.0 | 6 votes |
/** * Does the dumping. */ public void dump() { byte[] bytes = getBytes(); ByteArray ba = new ByteArray(bytes); /* * First, parse the file completely, so we can safely refer to * attributes, etc. */ classFile = new DirectClassFile(ba, getFilePath(), getStrictParse()); classFile.setAttributeFactory(StdAttributeFactory.THE_ONE); classFile.getMagic(); // Force parsing to happen. // Next, reparse it and observe the process. DirectClassFile liveCf = new DirectClassFile(ba, getFilePath(), getStrictParse()); liveCf.setAttributeFactory(StdAttributeFactory.THE_ONE); liveCf.setObserver(this); liveCf.getMagic(); // Force parsing to happen. }
Example #11
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 #12
Source File: Main.java From J2ME-Loader with Apache License 2.0 | 5 votes |
private DirectClassFile parseClass(String name, byte[] bytes) { DirectClassFile cf = new DirectClassFile(bytes, name, args.cfOptions.strictNameCheck); cf.setAttributeFactory(StdAttributeFactory.THE_ONE); cf.getMagic(); // triggers the actual parsing return cf; }
Example #13
Source File: Main.java From Box with Apache License 2.0 | 5 votes |
private DirectClassFile parseClass(String name, byte[] bytes) { DirectClassFile cf = new DirectClassFile(bytes, name, args.cfOptions.strictNameCheck); cf.setAttributeFactory(StdAttributeFactory.THE_ONE); cf.getMagic(); // triggers the actual parsing return cf; }
Example #14
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 #15
Source File: Dexing.java From bazel with Apache License 2.0 | 5 votes |
public static DirectClassFile parseClassFile(byte[] classfile, String classfilePath) { DirectClassFile result = new DirectClassFile( new ByteArray(classfile), classfilePath, /*strictParse*/ false); result.setAttributeFactory(StdAttributeFactory.THE_ONE); result.getMagic(); // triggers the parsing return result; }
Example #16
Source File: AndroidClassLoadingStrategy.java From byte-buddy with Apache License 2.0 | 5 votes |
/** * {@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(DISPATCHER.translate(directClassFile, binaryRepresentation, dexCompilerOptions, dexFileOptions, new DexFile(dexFileOptions))); }
Example #17
Source File: Main.java From buck with Apache License 2.0 | 5 votes |
private DirectClassFile parseClass(String name, byte[] bytes) { DirectClassFile cf = new DirectClassFile(bytes, name, args.cfOptions.strictNameCheck); cf.setAttributeFactory(StdAttributeFactory.THE_ONE); cf.getMagic(); // triggers the actual parsing return cf; }
Example #18
Source File: Main.java From Box with Apache License 2.0 | 5 votes |
private DirectClassFile parseClass(String name, byte[] bytes) { DirectClassFile cf = new DirectClassFile(bytes, name, args.cfOptions.strictNameCheck); cf.setAttributeFactory(StdAttributeFactory.THE_ONE); cf.getMagic(); // triggers the actual parsing return cf; }