@Nonnull public static DexBackedDexFile fromInputStream(@Nullable Opcodes opcodes, @Nonnull InputStream is) throws IOException { DexUtil.verifyDexHeader(is); byte[] buf = ByteStreams.toByteArray(is); return new DexBackedDexFile(opcodes, buf, 0, false); }
for (Dex dex : owners) { Set<String> descOfChangedClassesInCurrDex = ownerToDescOfChangedClassesMap.get(dex); DexFile dexFile = new DexBackedDexFile(org.jf.dexlib2.Opcodes.forApi(20), dex.getBytes()); boolean isCurrentDexHasChangedClass = false; for (org.jf.dexlib2.iface.ClassDef classDef : dexFile.getClasses()) {
DexBackedClassDef def2 = new DexBackedDexFile(new Opcodes(14, false), data).getClasses().iterator().next(); DexBackedClassDef def2 = new DexBackedDexFile(new Opcodes(14, false), data).getClasses().iterator().next();
@Nonnull public static DexBackedDexFile fromInputStream(@Nullable Opcodes opcodes, @Nonnull InputStream is) throws IOException { DexUtil.verifyDexHeader(is); byte[] buf = ByteStreams.toByteArray(is); return new DexBackedDexFile(opcodes, buf, 0, false); }
public VdexRewriterModule(Vdex.QuickenDex odex, Opcodes opcodes) { mOdex = odex; mDex = new DexBackedDexFile(opcodes, odex.getBytes()); mGiIter = odex.quickeningInfoList.listIterator(); }
public static DexBackedDexFile fromInputStream(@Nonnull Opcodes opcodes, @Nonnull InputStream is) throws IOException { if (!is.markSupported()) { throw new IllegalArgumentException("InputStream must support mark"); } is.mark(44); byte[] partialHeader = new byte[44]; try { ByteStreams.readFully(is, partialHeader); } catch (EOFException ex) { throw new NotADexFile("File is too short"); } finally { is.reset(); } verifyMagicAndByteOrder(partialHeader, 0); byte[] buf = ByteStreams.toByteArray(is); return new DexBackedDexFile(opcodes, buf, 0, false); }
private VdexRewriterModule(Vdex.QuickenDex odex, VdexRewriterModule module) { mOdex = odex; mDex = new DexBackedDexFile(module.mDex.getOpcodes(), odex.getBytes()); mGiIter = module.mGiIter; mQiIter = module.mQiIter; }
/** * Get list of DexFile objects from an Oat file. * * @param oat Oat file * @param opcodes Opcodes for the API level (if null, guessed from oat file) * @return List of DexFile objects * @throws IOException Wrong file format */ @Nonnull public static DexFile[] getOdexFromOat(@Nonnull Oat oat, @Nullable Opcodes opcodes) throws IOException { if (opcodes == null) { opcodes = getOpcodes(oat); } final DexFile[] dexFiles = new DexFile[oat.oatDexFiles.length]; for (int i = 0; i < oat.oatDexFiles.length; i++) { final Dex dex = oat.dexFiles[i]; final DexBackedDexFile dexFile = new DexBackedDexFile(opcodes, dex.getBytes()); if (!DexUtil.verifyStringOffset(dexFile)) { LLog.i("Bad string offset."); throw new IOException("The dex does not have formal format in: " + oat.srcFile); } dexFiles[i] = dexFile; } return dexFiles; }
return new DexBackedDexFile(opcodes, dexBytes); } catch (IOException ex) {
dexFiles.add(oat.dexFiles[i]); if (!isBoot) { deOpt.addDexToClassPath(new DexBackedDexFile(opcodes, oat.dexFiles[i].getBytes())); LLog.i("De-optimizing " + jarName + (i > 1 ? (" part-" + classesIdx) : "")); final DexFile d = deOpt.rewriteDexFile( new DexBackedDexFile(opcodes, dex.getBytes())); if (OdexRewriter.isInvalid(d)) { LLog.i("convertToDexJar: skip " + jarName);
@Nonnull protected DexBackedDexFile getInputDexFile(@Nonnull String testName, @Nonnull BaksmaliOptions options) { try { // Load file from resources as a stream byte[] inputBytes = BaksmaliTestUtils.readResourceBytesFully(getInputFilename(testName)); return new DexBackedDexFile(Opcodes.forApi(options.apiLevel), inputBytes); } catch (IOException ex) { Assert.fail(); } return null; } }
for (int i = 0; i < oat.dexFiles.length; i++) { final Dex df = oat.dexFiles[i]; dexFiles.add(new DexBackedDexFile(opc, df.getBytes())); if (outputNames != null) { final String dexName = OatUtil.getOutputNameForSubDex( final Opcodes opc = getOpcodes(Math.max(Oat.Version.O_80.api, apiLevel)); for (Dex dex : vdex.dexFiles) { dexFiles.add(new DexBackedDexFile(opc, dex.getBytes()));
MemoryDexFileItemPointer pointer = NativeFunction .queryDexFileItemPointer(mCookie); DexBackedDexFile mmDexFile = new DexBackedDexFile(opcodes, pointer, reader);
@Test public void testAnnotationElementOrder() { // Elements are out of order wrt to the element name ImmutableSet<ImmutableAnnotationElement> elements = ImmutableSet.of(new ImmutableAnnotationElement("zabaglione", ImmutableNullEncodedValue.INSTANCE), new ImmutableAnnotationElement("blah", ImmutableNullEncodedValue.INSTANCE)); ImmutableAnnotation annotation = new ImmutableAnnotation(AnnotationVisibility.RUNTIME, "Lorg/test/anno;", elements); ImmutableClassDef classDef = new ImmutableClassDef("Lorg/test/blah;", 0, "Ljava/lang/Object;", null, null, ImmutableSet.of(annotation), null, null); MemoryDataStore dataStore = new MemoryDataStore(); try { DexPool.writeTo(dataStore, new ImmutableDexFile(Opcodes.getDefault(), ImmutableSet.of(classDef))); } catch (IOException ex) { throw new RuntimeException(ex); } DexBackedDexFile dexFile = new DexBackedDexFile(Opcodes.getDefault(), dataStore.getBuffer()); ClassDef dbClassDef = Iterables.getFirst(dexFile.getClasses(), null); Assert.assertNotNull(dbClassDef); Annotation dbAnnotation = Iterables.getFirst(dbClassDef.getAnnotations(), null); Assert.assertNotNull(dbAnnotation); List<AnnotationElement> dbElements = Lists.newArrayList(dbAnnotation.getElements()); // Ensure that the elements were written out in sorted order Assert.assertEquals(2, dbElements.size()); Assert.assertEquals("blah", dbElements.get(0).getName()); Assert.assertEquals("zabaglione", dbElements.get(1).getName()); }
for (Dex dex : owners) { Set<String> descOfChangedClassesInCurrDex = ownerToDescOfChangedClassesMap.get(dex); DexFile dexFile = new DexBackedDexFile(org.jf.dexlib2.Opcodes.forApi(20), dex.getBytes()); for (org.jf.dexlib2.iface.ClassDef classDef : dexFile.getClasses()) { if (!descOfChangedClassesInCurrDex.contains(classDef.getType())) {
DexBackedDexFile dexFile = new DexBackedDexFile(Opcodes.getDefault(), dataStore.getBuffer()); ClassDef dbClassDef = Iterables.getFirst(dexFile.getClasses(), null); Assert.assertNotNull(dbClassDef);
DexBackedDexFile dexFile = new DexBackedDexFile(Opcodes.forApi(apiLevel), dataStore.getBuffer());
DexBackedDexFile dexFile = new DexBackedDexFile(Opcodes.forApi(apiLevel), dataStore.getBuffer());
dexBuilder.writeTo(dexStore); DexBackedDexFile dexFile = new DexBackedDexFile(Opcodes.getDefault(), dexStore.getBuffer());
dexBuilder.writeTo(dexStore); DexBackedDexFile dexFile = new DexBackedDexFile(Opcodes.getDefault(), dexStore.getBuffer());