diff --git a/.travis.yml b/.travis.yml index c6fd13ee5..8ac2ab5a2 100644 --- a/.travis.yml +++ b/.travis.yml @@ -4,21 +4,27 @@ addons: apt: packages: - realpath + - xvfb before_install: -- git clone --depth=1 https://github.com/secure-software-engineering/DroidBench.git - /tmp/DroidBench +- git clone --depth=1 https://github.com/secure-software-engineering/DroidBench.git /tmp/DroidBench +- export M2_HOME=$HOME/apache-maven-3.5.0 +- if [ ! -d $M2_HOME/bin ]; then curl https://archive.apache.org/dist/maven/maven-3/3.5.0/binaries/apache-maven-3.5.0-bin.tar.gz | tar zxf - -C $HOME; fi +- export PATH=$M2_HOME/bin:$PATH install: - mvn clean verify -DskipTests=true -B -q script: -- xvfb-run mvn clean verify -B -q +- xvfb-run mvn clean install -B -q - bash ./dependent-projects-trigger.sh $AUTH_TOKEN +- mvn javadoc:aggregate -B -q - bash ./upload-javascript.sh $GH_TOKEN -- jdk_switcher use oraclejdk7 - ./build-maven-jars.py "install -Dgpg.skip" sudo: false cache: directories: - "$HOME/.m2" + - "$HOME/apache-maven-3.5.0" - "$TRAVIS_BUILD_DIR/com.ibm.wala.core.testdata/ocaml/ocamljava-2.0-alpha1/lib" env: - secure: GTtE6dQXwex1+nZkA9fCrBl/nrl71nwSNrwH+KXEcTWRyLnxQPmGKeCey0kLX2bpVngGu7fi2CPZbGaOOm+0tm1kHZtNUUciVkt9qeA0cwdUHz7/EhfN6Xkj7wYZwQ4XUHMhxnHo9FtHK6IliArjUv84DNcDMHJbaiGcHPEmHGo= + global: + - secure: KcugjQYnBqeZ7XenZD5QY7jhekVPO0QpQyjDUteLytaokhyRK2g6eNvr/pPerN2uWUvsPwO18P9F+oOupge1cpPZf4cEY8RzLIromyUoRWd6JA0SKciUYdN2kSqnC4uZSJGXeGLoroyEEL4Q2sqimpkbIGxgxYtVniWgJULOyR4= + - secure: jacvGPYX4ugG/HgwJEEpWnllWsS/ipX+qRJ7qM5mbDYryeqsz0eiaxBxQ6IpDyj0v6O4DUi74lSQs/UxCWcUxvOn/5AweCZfoF1U8vt1xivanR4MbC2kr6rJ6ohICuJ4PHDS4IffncgaP3Y8cfExHq6+d0tbibYkjRIiMUGpSik= diff --git a/com.ibm.wala.cast.test/harness-src/c/Makefile.configration b/com.ibm.wala.cast.test/harness-src/c/Makefile.configration deleted file mode 100644 index 308c4ec77..000000000 --- a/com.ibm.wala.cast.test/harness-src/c/Makefile.configration +++ /dev/null @@ -1 +0,0 @@ -CAST_TEST_BIN = /Users/dolby/git/WALA/com.ibm.wala.cast.test/target/classes/ diff --git a/com.ibm.wala.core.tests/src/com/ibm/wala/core/tests/ir/AnnotationTest.java b/com.ibm.wala.core.tests/src/com/ibm/wala/core/tests/ir/AnnotationTest.java index a60177120..6b26b73b6 100644 --- a/com.ibm.wala.core.tests/src/com/ibm/wala/core/tests/ir/AnnotationTest.java +++ b/com.ibm.wala.core.tests/src/com/ibm/wala/core/tests/ir/AnnotationTest.java @@ -26,6 +26,7 @@ import com.ibm.wala.core.tests.util.TestAssertions; import com.ibm.wala.core.tests.util.WalaTestCase; import com.ibm.wala.ipa.cha.ClassHierarchyException; import com.ibm.wala.ipa.cha.IClassHierarchy; +import com.ibm.wala.shrikeBT.IInstruction; import com.ibm.wala.shrikeCT.InvalidClassFileException; import com.ibm.wala.types.ClassLoaderReference; import com.ibm.wala.types.FieldReference; @@ -96,9 +97,9 @@ public class AnnotationTest extends WalaTestCase { BytecodeClass bcClassUnderTest = (BytecodeClass) classUnderTest; Collection runtimeInvisibleAnnotations = bcClassUnderTest.getAnnotations(true); - harness.assertEqualCollections(expectedRuntimeInvisibleAnnotations, runtimeInvisibleAnnotations); - Collection runtimeVisibleAnnotations = bcClassUnderTest.getAnnotations(false); + + harness.assertEqualCollections(expectedRuntimeInvisibleAnnotations, runtimeInvisibleAnnotations); harness.assertEqualCollections(expectedRuntimeVisibleAnnotations, runtimeVisibleAnnotations); } @@ -120,7 +121,7 @@ public class AnnotationTest extends WalaTestCase { IMethod methodUnderTest = cha.resolveMethod(methodRefUnderTest); harness.assertNotNull(methodRefUnderTest.toString() + " not found", methodUnderTest); harness.assertTrue(methodUnderTest + " must be IBytecodeMethod", methodUnderTest instanceof IBytecodeMethod); - IBytecodeMethod bcMethodUnderTest = (IBytecodeMethod) methodUnderTest; + IBytecodeMethod bcMethodUnderTest = (IBytecodeMethod) methodUnderTest; Collection runtimeInvisibleAnnotations = bcMethodUnderTest.getAnnotations(true); harness.assertEquals(1, runtimeInvisibleAnnotations.size()); @@ -182,7 +183,7 @@ public class AnnotationTest extends WalaTestCase { IMethod methodUnderTest = cha.resolveMethod(methodRefUnderTest); harness.assertTrue(methodRefUnderTest.toString() + " not found", methodUnderTest != null); harness.assertTrue(methodUnderTest + " must be bytecode method", methodUnderTest instanceof IBytecodeMethod); - IBytecodeMethod IBytecodeMethodUnderTest = (IBytecodeMethod) methodUnderTest; + IBytecodeMethod IBytecodeMethodUnderTest = (IBytecodeMethod) methodUnderTest; Collection[] parameterAnnotations = IBytecodeMethodUnderTest.getParameterAnnotations(); harness.assertEquals(expected.length, parameterAnnotations.length); diff --git a/com.ibm.wala.core/src/com/ibm/wala/cfg/ShrikeCFG.java b/com.ibm.wala.core/src/com/ibm/wala/cfg/ShrikeCFG.java index c8c475e9e..e5f3a0937 100644 --- a/com.ibm.wala.core/src/com/ibm/wala/cfg/ShrikeCFG.java +++ b/com.ibm.wala.core/src/com/ibm/wala/cfg/ShrikeCFG.java @@ -47,7 +47,7 @@ public class ShrikeCFG extends AbstractCFG i private int[] instruction2Block; - private final IBytecodeMethod method; + private final IBytecodeMethod method; /** * Cache this here for efficiency @@ -59,11 +59,11 @@ public class ShrikeCFG extends AbstractCFG i */ final private Set exceptionHandlers = HashSetFactory.make(10); - public static ShrikeCFG make(IBytecodeMethod m) { + public static ShrikeCFG make(IBytecodeMethod m) { return new ShrikeCFG(m); } - private ShrikeCFG(IBytecodeMethod method) throws IllegalArgumentException { + private ShrikeCFG(IBytecodeMethod method) throws IllegalArgumentException { super(method); if (method == null) { throw new IllegalArgumentException("method cannot be null"); @@ -81,7 +81,7 @@ public class ShrikeCFG extends AbstractCFG i } @Override - public IBytecodeMethod getMethod() { + public IBytecodeMethod getMethod() { return method; } diff --git a/com.ibm.wala.core/src/com/ibm/wala/cfg/cdg/ControlDependenceGraph.java b/com.ibm.wala.core/src/com/ibm/wala/cfg/cdg/ControlDependenceGraph.java index b03fc240e..d8b30293a 100644 --- a/com.ibm.wala.core/src/com/ibm/wala/cfg/cdg/ControlDependenceGraph.java +++ b/com.ibm.wala.core/src/com/ibm/wala/cfg/cdg/ControlDependenceGraph.java @@ -82,7 +82,7 @@ public class ControlDependenceGraph extends AbstractNumberedGraph { for (Iterator ss = cfg.getSuccNodes(x); ss.hasNext();) { T s = ss.next(); if (RDF.isDominatedBy(s, y)) { - labels.add(makeEdgeLabel(s)); + labels.add(makeEdgeLabel(x, y, s)); } } } @@ -92,7 +92,7 @@ public class ControlDependenceGraph extends AbstractNumberedGraph { return controlDependence; } - protected Object makeEdgeLabel(T s) { + protected Object makeEdgeLabel(@SuppressWarnings("unused") T from, @SuppressWarnings("unused") T to, T s) { return s; } diff --git a/com.ibm.wala.core/src/com/ibm/wala/classLoader/IBytecodeMethod.java b/com.ibm.wala.core/src/com/ibm/wala/classLoader/IBytecodeMethod.java index 3d80df37b..fbe76e8fe 100644 --- a/com.ibm.wala.core/src/com/ibm/wala/classLoader/IBytecodeMethod.java +++ b/com.ibm.wala.core/src/com/ibm/wala/classLoader/IBytecodeMethod.java @@ -13,7 +13,6 @@ package com.ibm.wala.classLoader; import java.util.Collection; import com.ibm.wala.shrikeBT.ExceptionHandler; -import com.ibm.wala.shrikeBT.IInstruction; import com.ibm.wala.shrikeBT.IndirectionData; import com.ibm.wala.shrikeCT.InvalidClassFileException; import com.ibm.wala.types.annotations.Annotation; @@ -21,7 +20,7 @@ import com.ibm.wala.types.annotations.Annotation; /** * A method which originated in bytecode, decoded by Shrike */ -public interface IBytecodeMethod extends IMethod { +public interface IBytecodeMethodextends IMethod { /** * @return the bytecode index corresponding to instruction i in the getInstructions() array @@ -41,7 +40,7 @@ public interface IBytecodeMethod extends IMethod { /** * @return the Shrike instructions decoded from the bytecode */ - IInstruction[] getInstructions() throws InvalidClassFileException; + I[] getInstructions() throws InvalidClassFileException; /**there * @return the call sites declared in the bytecode for this method diff --git a/com.ibm.wala.dalvik.test/source/com/ibm/wala/dalvik/test/callGraph/JVMLDalvikComparisonTest.java b/com.ibm.wala.dalvik.test/source/com/ibm/wala/dalvik/test/callGraph/JVMLDalvikComparisonTest.java index 55c07adaa..59e640ac3 100644 --- a/com.ibm.wala.dalvik.test/source/com/ibm/wala/dalvik/test/callGraph/JVMLDalvikComparisonTest.java +++ b/com.ibm.wala.dalvik.test/source/com/ibm/wala/dalvik/test/callGraph/JVMLDalvikComparisonTest.java @@ -39,6 +39,7 @@ import com.ibm.wala.ipa.callgraph.propagation.cfa.ExceptionReturnValueKey; import com.ibm.wala.ipa.cha.ClassHierarchy; import com.ibm.wala.ipa.cha.ClassHierarchyException; import com.ibm.wala.ipa.cha.ClassHierarchyFactory; +import com.ibm.wala.types.ClassLoaderReference; import com.ibm.wala.types.MethodReference; import com.ibm.wala.util.CancelException; import com.ibm.wala.util.collections.HashSetFactory; @@ -58,12 +59,16 @@ public class JVMLDalvikComparisonTest extends DalvikCallGraphTestBase { return Pair.make(CG, builder.getPointerAnalysis()); } - private static Set> edgeDiff(CallGraph from, CallGraph to) { + private static Set> edgeDiff(CallGraph from, CallGraph to, boolean userOnly) { Set> result = HashSetFactory.make(); for(CGNode f : from) { if (! f.getMethod().isSynthetic()) { outer: for(CGNode t : from) { - if (!t.getMethod().isSynthetic() && from.hasEdge(f, t)) { + if (!t.getMethod().isSynthetic() && + from.hasEdge(f, t) && + (!userOnly || + !t.getMethod().getDeclaringClass().getClassLoader().getReference().equals(ClassLoaderReference.Primordial))) + { Set fts = to.getNodes(f.getMethod().getReference()); Set tts = to.getNodes(t.getMethod().getReference()); for(CGNode x : fts) { @@ -91,10 +96,18 @@ public class JVMLDalvikComparisonTest extends DalvikCallGraphTestBase { Set androidMethods = applicationMethods(android.fst); Set javaMethods = applicationMethods(java.fst); + + Iterator> javaExtraEdges = edgeDiff(java.fst, android.fst, false).iterator(); + Assert.assertFalse(checkEdgeDiff(android, androidMethods, javaMethods, javaExtraEdges)); - Iterator> javaExtraEdges = edgeDiff(java.fst, android.fst).iterator(); - boolean fail = false; - if (javaExtraEdges.hasNext()) { + Iterator> androidExtraEdges = edgeDiff(android.fst, java.fst, true).iterator(); + Assert.assertFalse(checkEdgeDiff(java, javaMethods, androidMethods, androidExtraEdges)); + } + + private static boolean checkEdgeDiff(Pair> android, Set androidMethods, + Set javaMethods, Iterator> javaExtraEdges) { + boolean fail = false; + if (javaExtraEdges.hasNext()) { fail = true; Set javaExtraNodes = HashSetFactory.make(javaMethods); javaExtraNodes.removeAll(androidMethods); @@ -121,9 +134,8 @@ public class JVMLDalvikComparisonTest extends DalvikCallGraphTestBase { } } } - - Assert.assertTrue(!fail); - } + return fail; + } @Test public void testJLex() throws ClassHierarchyException, IllegalArgumentException, IOException, CancelException { diff --git a/com.ibm.wala.dalvik/.classpath b/com.ibm.wala.dalvik/.classpath index 7e11e65b9..a09d0f486 100644 --- a/com.ibm.wala.dalvik/.classpath +++ b/com.ibm.wala.dalvik/.classpath @@ -1,8 +1,9 @@ - - + + + diff --git a/com.ibm.wala.dalvik/META-INF/MANIFEST.MF b/com.ibm.wala.dalvik/META-INF/MANIFEST.MF index 726b2de16..bf62b5c0d 100644 --- a/com.ibm.wala.dalvik/META-INF/MANIFEST.MF +++ b/com.ibm.wala.dalvik/META-INF/MANIFEST.MF @@ -13,14 +13,19 @@ Export-Package: com.google.common.annotations, com.google.common.base.internal, com.google.common.cache, com.google.common.collect, + com.google.common.escape, com.google.common.eventbus, + com.google.common.graph, com.google.common.hash, + com.google.common.html, com.google.common.io, com.google.common.math, com.google.common.net, com.google.common.primitives, com.google.common.reflect, com.google.common.util.concurrent, + com.google.common.xml, + com.google.thirdparty.publicsuffix, com.ibm.wala.dalvik.analysis.typeInference, com.ibm.wala.dalvik.classLoader, com.ibm.wala.dalvik.dex.instructions, @@ -41,20 +46,53 @@ Export-Package: com.google.common.annotations, org.apache.commons.io.input, org.apache.commons.io.monitor, org.apache.commons.io.output, - org.jf.dexlib, - org.jf.dexlib.Code, - org.jf.dexlib.Code.Analysis, - org.jf.dexlib.Code.Format, - org.jf.dexlib.Debug, - org.jf.dexlib.EncodedValue, - org.jf.dexlib.Util + org.jf.dexlib2, + org.jf.dexlib2.analysis, + org.jf.dexlib2.analysis.reflection, + org.jf.dexlib2.analysis.reflection.util, + org.jf.dexlib2.analysis.util, + org.jf.dexlib2.base, + org.jf.dexlib2.base.reference, + org.jf.dexlib2.base.value, + org.jf.dexlib2.builder, + org.jf.dexlib2.builder.debug, + org.jf.dexlib2.builder.instruction, + org.jf.dexlib2.dexbacked, + org.jf.dexlib2.dexbacked.instruction, + org.jf.dexlib2.dexbacked.raw, + org.jf.dexlib2.dexbacked.raw.util, + org.jf.dexlib2.dexbacked.reference, + org.jf.dexlib2.dexbacked.util, + org.jf.dexlib2.dexbacked.value, + org.jf.dexlib2.iface, + org.jf.dexlib2.iface.debug, + org.jf.dexlib2.iface.instruction, + org.jf.dexlib2.iface.instruction.formats, + org.jf.dexlib2.iface.reference, + org.jf.dexlib2.iface.value, + org.jf.dexlib2.immutable, + org.jf.dexlib2.immutable.debug, + org.jf.dexlib2.immutable.instruction, + org.jf.dexlib2.immutable.reference, + org.jf.dexlib2.immutable.util, + org.jf.dexlib2.immutable.value, + org.jf.dexlib2.rewriter, + org.jf.dexlib2.util, + org.jf.dexlib2.writer, + org.jf.dexlib2.writer.builder, + org.jf.dexlib2.writer.io, + org.jf.dexlib2.writer.pool, + org.jf.dexlib2.writer.util, + org.jf.util, + org.jf.util.jcommander Bundle-ClassPath: ., lib/commons-cli-1.2.jar, lib/commons-io-2.4.jar, - lib/dexlib-1.3.4.jar, - lib/guava-13.0.1.jar, + lib/dexlib2-2.2.1.jar, + lib/util-2.2.1.jar, lib/logback-classic-1.0.9.jar, lib/logback-core-1.0.9.jar, - lib/slf4j-api-1.7.2.jar + lib/slf4j-api-1.7.2.jar, + lib/guava-22.0.jar diff --git a/com.ibm.wala.dalvik/build.properties b/com.ibm.wala.dalvik/build.properties index 685ea2292..8f9288102 100644 --- a/com.ibm.wala.dalvik/build.properties +++ b/com.ibm.wala.dalvik/build.properties @@ -2,14 +2,16 @@ bin.includes = META-INF/,\ .,\ lib/commons-cli-1.2.jar,\ lib/commons-io-2.4.jar,\ - lib/dexlib-1.3.4.jar,\ - lib/guava-13.0.1.jar,\ + lib/dexlib2-2.2.1.jar,\ + lib/util-2.2.1.jar,\ lib/logback-classic-1.0.9.jar,\ lib/logback-core-1.0.9.jar,\ lib/slf4j-api-1.7.2.jar,\ OSGI-INF/l10n/bundle.properties,\ - OSGI-INF/ + OSGI-INF/,\ + lib/guava-22.0.jar jars.compile.order = . output.. = bin/ source.. = src/ +javacProjectSettings = true diff --git a/com.ibm.wala.dalvik/pom.xml b/com.ibm.wala.dalvik/pom.xml index c35ac23c2..0a1c9bc1f 100644 --- a/com.ibm.wala.dalvik/pom.xml +++ b/com.ibm.wala.dalvik/pom.xml @@ -12,8 +12,38 @@ eclipse-plugin - - + + + maven-dependency-plugin + + + + copy + + + + + org.smali + dexlib2 + 2.2.1 + jar + false + + + org.smali + util + 2.2.1 + jar + false + + + ${basedir}/lib + + + + + + maven-antrun-plugin 1.7 @@ -38,6 +68,7 @@ system ${java.home}/../lib/tools.jar + diff --git a/com.ibm.wala.dalvik/src/com/ibm/wala/dalvik/classLoader/ActivityModelMethod.java b/com.ibm.wala.dalvik/src/com/ibm/wala/dalvik/classLoader/ActivityModelMethod.java deleted file mode 100644 index 620154773..000000000 --- a/com.ibm.wala.dalvik/src/com/ibm/wala/dalvik/classLoader/ActivityModelMethod.java +++ /dev/null @@ -1,244 +0,0 @@ -/* - * This program and the accompanying materials - * are made available under the terms of the Eclipse Public License v1.0 - * which accompanies this distribution, and is available at - * http://www.eclipse.org/legal/epl-v10.html. - * - * This file is a derivative of code released under the terms listed below. - * - */ -/* - * - * Copyright (c) 2009-2012, - * - * Steve Suh - * - * All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions are met: - * - * 1. Redistributions of source code must retain the above copyright notice, - * this list of conditions and the following disclaimer. - * - * 2. Redistributions in binary form must reproduce the above copyright notice, - * this list of conditions and the following disclaimer in the documentation - * and/or other materials provided with the distribution. - * - * 3. The names of the contributors may not be used to endorse or promote - * products derived from this software without specific prior written - * permission. - * - * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" - * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE - * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE - * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE - * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR - * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF - * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS - * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN - * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) - * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE - * POSSIBILITY OF SUCH DAMAGE. - * - * - */ - -package com.ibm.wala.dalvik.classLoader; - -import static org.jf.dexlib.ItemType.TYPE_CLASS_DEF_ITEM; - -import java.io.File; - -import org.jf.dexlib.ClassDataItem.EncodedMethod; -import org.jf.dexlib.ClassDefItem; -import org.jf.dexlib.DexFile; -import org.jf.dexlib.Section; -import org.jf.dexlib.Code.Opcode; - -import com.ibm.wala.dalvik.dex.instructions.Invoke; -import com.ibm.wala.util.io.FileProvider; - -/** - * @deprecated building the Android-Livecycle is done in the class AndroidModel now - */ -@Deprecated -public class ActivityModelMethod extends DexIMethod { - private static EncodedMethod ActivityModelM; - - public ActivityModelMethod(EncodedMethod encodedMethod, DexIClass klass) { - super(encodedMethod, klass); - } - - public static void loadActivityModel() { - if (ActivityModelM == null) { - DexFile activityModelDF; - ClassDefItem activityModelCDI = null; - try { - FileProvider fp = new FileProvider(); - File apkFile = fp.getFile("models/ActivityModel.apk", ActivityModelMethod.class.getClassLoader()); - activityModelDF = new DexFile(apkFile); - /* new DexFile(new File( - ActivityModelMethod.class.getClassLoader() - .getResource("models/ActivityModel.apk") - .toURI())); */ - } catch (Exception e) { - throw new IllegalArgumentException(e); - } - Section cldeff = activityModelDF.getSectionForType(TYPE_CLASS_DEF_ITEM); - for (ClassDefItem cdefitems : cldeff.getItems()) { - if (cdefitems.getClassType().getTypeDescriptor() - .equals("Lactivity/model/ActivityModelActivity;")) { - activityModelCDI = cdefitems; - } - } - assert (activityModelCDI != null); - // final EncodedMethod[] virtualMethods = - // ActivityModelCDI.getClassData().getVirtualMethods(); - for (EncodedMethod virtualMethod : activityModelCDI.getClassData() - .getVirtualMethods()) { - if (virtualMethod.method.getMethodName().getStringValue() - .equals("ActivityModel")) - ActivityModelM = virtualMethod; - } - assert (ActivityModelM != null); - } - } - - public static EncodedMethod getActivityModel() { - if (ActivityModelM == null) { - loadActivityModel(); - } - return ActivityModelM; - } - - // @Override - // public TypeReference[] getDeclaredExceptions() { - // return null; - // } - // - // @Override - // public MethodReference getReference() { - // if (methodReference == null) { - // // Set method name - // Atom name = Atom.findOrCreateUnicodeAtom("ActivityModel"); - // - // // Set the descriptor - // ImmutableByteArray desc = ImmutableByteArray.make("()V"); - // Descriptor D = - // Descriptor.findOrCreate(myClass.getClassLoader().getLanguage(), desc); - // methodReference = MethodReference.findOrCreate(myClass.getReference(), - // name, D); - // } - // - // return methodReference; - // } - // - // @Override - // public boolean hasExceptionHandler() { - // return false; - // } - // - // @Override - // public boolean isAbstract() { - // return false; - // } - // - // @Override - // public boolean isBridge() { - // return false; - // } - // - // @Override - // public boolean isClinit() { - // return false; - // } - // - // @Override - // public boolean isFinal() { - // return false; - // } - // - // @Override - // public boolean isInit() { - // return false; - // } - // - // @Override - // public boolean isNative() { - // return false; - // } - // - // @Override - // public boolean isPrivate() { - // return false; - // } - // - // @Override - // public boolean isProtected() { - // return false; - // } - // - // @Override - // public boolean isPublic() { - // return true; - // } - // - // @Override - // public boolean isSynchronized() { - // return false; - // } - // - // @Override - // public boolean isSynthetic() { - // return false; - // } - // - // @Override - // public boolean isStatic() { - // return false; - // } - // - // @Override - // public boolean isVolatile() { - // return false; - // } - // - // @Override - // public ExceptionHandler[][] getHandlers() throws - // InvalidClassFileException { - // this.handlers = new ExceptionHandler[instructions().size()][]; - // return handlers; - // } - // - // @Override - // public int getMaxLocals() { - // return 12; - // } - // - // @Override - // public int getReturnReg() { - // return 10; - // } - // - // @Override - // public int getExceptionReg() { - // return 11; - // } - // - // @Override - // public int getNumberOfParameterRegisters() { - // return 1; - // } - - @Override - protected void handleINVOKE_VIRTUAL(int instLoc, String cname, - String mname, String pname, int[] args, Opcode opcode) { - if (cname.equals("Lactivity/model/ActivityModelActivity")) { - cname = myClass.getName().toString(); - } - instructions.add(new Invoke.InvokeVirtual(instLoc, cname, mname, pname, - args, opcode, this)); - - } -} diff --git a/com.ibm.wala.dalvik/src/com/ibm/wala/dalvik/classLoader/DexFileModule.java b/com.ibm.wala.dalvik/src/com/ibm/wala/dalvik/classLoader/DexFileModule.java index d3d1363b2..9ec7a93c1 100644 --- a/com.ibm.wala.dalvik/src/com/ibm/wala/dalvik/classLoader/DexFileModule.java +++ b/com.ibm.wala.dalvik/src/com/ibm/wala/dalvik/classLoader/DexFileModule.java @@ -54,9 +54,10 @@ import java.util.HashSet; import java.util.Iterator; import java.util.jar.JarFile; -import org.jf.dexlib.ClassDefItem; -import org.jf.dexlib.DexFile; -import org.jf.dexlib.Section; +import org.jf.dexlib2.DexFileFactory; +import org.jf.dexlib2.Opcodes; +import org.jf.dexlib2.iface.ClassDef; +import org.jf.dexlib2.iface.DexFile; import com.ibm.wala.classLoader.Module; import com.ibm.wala.classLoader.ModuleEntry; @@ -103,7 +104,7 @@ public class DexFileModule implements Module { */ private DexFileModule(File f) throws IllegalArgumentException { try { - dexfile = new DexFile(f); + dexfile = DexFileFactory.loadDexFile(f, Opcodes.forApi(25)); } catch (IOException e) { throw new IllegalArgumentException(e); } @@ -111,8 +112,7 @@ public class DexFileModule implements Module { // create ModuleEntries from ClassDefItem entries = new HashSet<>(); - Section cldeff = dexfile.ClassDefsSection; - for (ClassDefItem cdefitems : cldeff.getItems()) { + for (ClassDef cdefitems : dexfile.getClasses()) { entries.add(new DexModuleEntry(cdefitems)); } } diff --git a/com.ibm.wala.dalvik/src/com/ibm/wala/dalvik/classLoader/DexIClass.java b/com.ibm.wala.dalvik/src/com/ibm/wala/dalvik/classLoader/DexIClass.java index 0869a7c49..f917c9785 100644 --- a/com.ibm.wala.dalvik/src/com/ibm/wala/dalvik/classLoader/DexIClass.java +++ b/com.ibm.wala.dalvik/src/com/ibm/wala/dalvik/classLoader/DexIClass.java @@ -47,29 +47,20 @@ package com.ibm.wala.dalvik.classLoader; -import static org.jf.dexlib.Util.AccessFlags.ABSTRACT; -import static org.jf.dexlib.Util.AccessFlags.INTERFACE; -import static org.jf.dexlib.Util.AccessFlags.PRIVATE; -import static org.jf.dexlib.Util.AccessFlags.PUBLIC; +import static org.jf.dexlib2.AccessFlags.*; import java.util.ArrayList; import java.util.Collection; +import java.util.LinkedList; import java.util.List; import java.util.Map; import java.util.Set; -import org.jf.dexlib.AnnotationDirectoryItem; -import org.jf.dexlib.AnnotationItem; -import org.jf.dexlib.AnnotationSetItem; -import org.jf.dexlib.AnnotationVisibility; -import org.jf.dexlib.ClassDataItem; -import org.jf.dexlib.ClassDataItem.EncodedField; -import org.jf.dexlib.ClassDataItem.EncodedMethod; -import org.jf.dexlib.ClassDefItem; -import org.jf.dexlib.FieldIdItem; -import org.jf.dexlib.MethodIdItem; -import org.jf.dexlib.TypeIdItem; -import org.jf.dexlib.TypeListItem; +import org.jf.dexlib2.AnnotationVisibility; +import org.jf.dexlib2.iface.ClassDef; +import org.jf.dexlib2.iface.Field; +import org.jf.dexlib2.iface.Method; +import org.jf.dexlib2.iface.MethodParameter; import com.ibm.wala.classLoader.BytecodeClass; import com.ibm.wala.classLoader.IClassLoader; @@ -89,7 +80,7 @@ public class DexIClass extends BytecodeClass { * Item which contains the class definitions. * (compute by DexFile, from the dexLib) */ - private final ClassDefItem classDef; + private final ClassDef classDef; /** * Bitfields of these flags are used to indicate the accessibility and overall properties of classes and class members. @@ -126,32 +117,28 @@ public class DexIClass extends BytecodeClass { //computeSuperName() // Set Super Name; - String descriptor = classDef.getSuperclass() != null? classDef.getSuperclass().getTypeDescriptor(): null; + String descriptor = classDef.getSuperclass() != null? classDef.getSuperclass(): null; if (descriptor != null && descriptor.endsWith(";")) descriptor = descriptor.substring(0,descriptor.length()-1); //remove last ';' superName = descriptor != null? ImmutableByteArray.make(descriptor): null; //computeInterfaceNames() // Set interfaceNames - final TypeListItem intfList = classDef.getInterfaces(); - int size = intfList == null ? 0 : intfList.getTypeCount(); + final List intfList = classDef.getInterfaces(); + int size = intfList == null ? 0 : intfList.size(); //if (size != 0) // System.out.println(intfList.getTypes().get(0).getTypeDescriptor()); interfaceNames = new ImmutableByteArray[size]; for (int i = 0; i < size; i++) { - TypeIdItem itf = intfList.getTypeIdItem(i); - descriptor = itf.getTypeDescriptor(); + descriptor = intfList.get(i); if (descriptor.endsWith(";")) descriptor = descriptor.substring(0, descriptor.length()-1); interfaceNames[i] = ImmutableByteArray .make(descriptor); } - //Load class data - final ClassDataItem classData = classDef.getClassData(); - // Set direct instance fields // if (classData == null) { // throw new RuntimeException("DexIClass::DexIClass(): classData is null"); @@ -178,28 +165,29 @@ public class DexIClass extends BytecodeClass { // } //computeFields() - if (classData != null) { //final EncodedField[] encInstFields = classData.getInstanceFields(); - final List encInstFields = classData.getInstanceFields(); - instanceFields = new IField[encInstFields.size()]; - for (int i = 0; i < encInstFields.size(); i++) { - instanceFields[i] = new DexIField(encInstFields.get(i),this); + final Iterable encInstFields = classDef.getInstanceFields(); + List ifs = new LinkedList<>(); + for (Field dexf : encInstFields) { + ifs.add(new DexIField(dexf,this)); } + instanceFields = ifs.toArray(new IField[ ifs.size() ]); // Set direct static fields - final List encStatFields = classData.getStaticFields(); - staticFields = new IField[encStatFields.size()]; - for (int i = 0; i < encStatFields.size(); i++) { - staticFields[i] = new DexIField(encStatFields.get(i),this); + final Iterable encStatFields = classDef.getStaticFields(); + List sfs = new LinkedList<>(); + for (Field dexf : encStatFields) { + sfs.add(new DexIField(dexf,this)); } + staticFields = sfs.toArray(new IField[ sfs.size() ]); } - } + /** * @return The classDef Item associated with this class. */ - public ClassDefItem getClassDefItem(){ + public ClassDef getClassDefItem(){ return classDef; } @@ -269,14 +257,11 @@ public class DexIClass extends BytecodeClass { return hashCode; } - Collection getAnnotations(Set types) { + Collection getAnnotations(Set types) { Set result = HashSetFactory.make(); - AnnotationDirectoryItem d = dexModuleEntry.getClassDefItem().getAnnotations(); - if (d.getClassAnnotations() != null) { - for(AnnotationItem a : d.getClassAnnotations().getAnnotations()) { - if (types == null || types.contains(a.getVisibility())) { - result.add(DexUtil.getAnnotation(a, getClassLoader().getReference())); - } + for(org.jf.dexlib2.iface.Annotation a : classDef.getAnnotations()) { + if (types == null || types.contains(AnnotationVisibility.getVisibility(a.getVisibility()))) { + result.add(DexUtil.getAnnotation(a, getClassLoader().getReference())); } } return result; @@ -284,7 +269,7 @@ public class DexIClass extends BytecodeClass { @Override public Collection getAnnotations() { - return getAnnotations((Set)null); + return getAnnotations((Set)null); } @Override @@ -292,55 +277,46 @@ public class DexIClass extends BytecodeClass { return getAnnotations(getTypes(runtimeInvisible)); } - static Set getTypes(boolean runtimeInvisible) { - Set types = HashSetFactory.make(); - types.add(AnnotationVisibility.SYSTEM); + static Set getTypes(boolean runtimeInvisible) { + Set types = HashSetFactory.make(); + types.add(AnnotationVisibility.getVisibility(AnnotationVisibility.SYSTEM)); if (runtimeInvisible) { - types.add(AnnotationVisibility.BUILD); + types.add(AnnotationVisibility.getVisibility(AnnotationVisibility.BUILD)); } else { - types.add(AnnotationVisibility.RUNTIME); + types.add(AnnotationVisibility.getVisibility(AnnotationVisibility.RUNTIME)); } return types; } - List getAnnotations(MethodIdItem m, Set types) { - List result = new ArrayList<>(); - AnnotationDirectoryItem d = dexModuleEntry.getClassDefItem().getAnnotations(); - if (d != null && d.getMethodAnnotations(m) != null) { - for(AnnotationItem a : d.getMethodAnnotations(m).getAnnotations()) { - if (types == null || types.contains(a.getVisibility())) { - result.add(a); - } + List getAnnotations(Method m, Set set) { + List result = new ArrayList<>(); + for(org.jf.dexlib2.iface.Annotation a : m.getAnnotations()) { + if (set == null || set.contains(AnnotationVisibility.getVisibility(a.getVisibility()))) { + result.add(DexUtil.getAnnotation(a, getClassLoader().getReference())); } } return result; } - List getAnnotations(FieldIdItem m) { - List result = new ArrayList<>(); - AnnotationDirectoryItem d = dexModuleEntry.getClassDefItem().getAnnotations(); - if (d != null) { - for(AnnotationItem a : d.getFieldAnnotations(m).getAnnotations()) { - result.add(a); - } + Collection getAnnotations(Field m) { + List result = new ArrayList<>(); + for(org.jf.dexlib2.iface.Annotation a : m.getAnnotations()) { + result.add(DexUtil.getAnnotation(a, getClassLoader().getReference())); } return result; } - Map> getParameterAnnotations(MethodIdItem m) { - Map> result = HashMapFactory.make(); - AnnotationDirectoryItem d = dexModuleEntry.getClassDefItem().getAnnotations(); - if (d != null) { - int i = 0; - for(AnnotationSetItem as : d.getParameterAnnotations(m).getAnnotationSets()) { - for(AnnotationItem a : as.getAnnotations()) { - if (! result.containsKey(i)) { - result.put(i, new ArrayList()); - } - result.get(i).add(a); - } - i++; + Map> getParameterAnnotations(Method m) { + Map> result = HashMapFactory.make(); + int i = 0; + for(MethodParameter as : m.getParameters()) { + for(org.jf.dexlib2.iface.Annotation a : as.getAnnotations()) { + if (! result.containsKey(i)) { + result.put(i, new ArrayList()); + } + result.get(i).add(DexUtil.getAnnotation(a, getClassLoader().getReference())); } + i++; } return result; } @@ -353,22 +329,20 @@ public class DexIClass extends BytecodeClass { protected IMethod[] computeDeclaredMethods() { ArrayList methodsAL = new ArrayList<>(); - if (methods == null && classDef.getClassData() == null) - methods = new IMethod[0]; - - if (methods == null && classDef.getClassData() != null){ + if (methods == null){ // final EncodedMethod[] directMethods = classDef.getClassData().getDirectMethods(); // final EncodedMethod[] virtualMethods = classDef.getClassData().getVirtualMethods(); - final List directMethods = classDef.getClassData().getDirectMethods(); - final List virtualMethods = classDef.getClassData().getVirtualMethods(); + final Iterable directMethods = classDef.getDirectMethods(); + final Iterable virtualMethods = classDef.getVirtualMethods(); //methods = new IMethod[dSize+vSize]; // Create Direct methods (static, private, constructor) - for (int i = 0; i < directMethods.size(); i++) { - EncodedMethod dMethod = directMethods.get(i); + int i = 0; + for (Method dMethod : directMethods) { //methods[i] = new DexIMethod(dMethod,this); - methodsAL.add(new DexIMethod(dMethod,this)); + DexIMethod method = new DexIMethod(dMethod,this); + methodsAL.add(method); //Set construcorId //if ( (dMethod.accessFlags & CONSTRUCTOR.getValue()) != 0){ @@ -376,15 +350,16 @@ public class DexIClass extends BytecodeClass { //} //Set clinitId //if (methods[i].isClinit()) - if (methodsAL.get(i).isClinit()) { + if (method.isClinit()) { clinitId = i; } + i++; } // Create virtual methods (other methods) - for (int i = 0; i < virtualMethods.size(); i++) { + for (Method dexm : virtualMethods) { //methods[dSize+i] = new DexIMethod(virtualMethods[i],this); - methodsAL.add(new DexIMethod(virtualMethods.get(i),this)); + methodsAL.add(new DexIMethod(dexm,this)); //is this enough to determine if the class is an activity? //maybe check superclass? -- but that may also not be enough //may need to keep checking superclass of superclass, etc. diff --git a/com.ibm.wala.dalvik/src/com/ibm/wala/dalvik/classLoader/DexIField.java b/com.ibm.wala.dalvik/src/com/ibm/wala/dalvik/classLoader/DexIField.java index 7bfa85c2b..2b20f2ae2 100644 --- a/com.ibm.wala.dalvik/src/com/ibm/wala/dalvik/classLoader/DexIField.java +++ b/com.ibm.wala.dalvik/src/com/ibm/wala/dalvik/classLoader/DexIField.java @@ -48,18 +48,11 @@ package com.ibm.wala.dalvik.classLoader; -import static org.jf.dexlib.Util.AccessFlags.FINAL; -import static org.jf.dexlib.Util.AccessFlags.PRIVATE; -import static org.jf.dexlib.Util.AccessFlags.PROTECTED; -import static org.jf.dexlib.Util.AccessFlags.PUBLIC; -import static org.jf.dexlib.Util.AccessFlags.STATIC; -import static org.jf.dexlib.Util.AccessFlags.VOLATILE; +import static org.jf.dexlib2.AccessFlags.*; import java.util.Collection; -import org.jf.dexlib.ClassDataItem.EncodedField; -import org.jf.dexlib.StringIdItem; -import org.jf.dexlib.TypeIdItem; +import org.jf.dexlib2.iface.Field; import com.ibm.wala.classLoader.IClass; import com.ibm.wala.classLoader.IField; @@ -75,7 +68,7 @@ public class DexIField implements IField { /* * The EncodedFied object for which this DexIField is a wrapper */ - private final EncodedField eField; + private final Field eField; /** * The declaring class for this method. @@ -97,14 +90,14 @@ public class DexIField implements IField { private Atom name; - public DexIField(EncodedField encodedField, DexIClass klass) { + public DexIField(Field encodedField, DexIClass klass) { //public DexIField(EncodedField encodedField) { eField = encodedField; myClass = klass; - StringIdItem fieldName = eField.field.getFieldName(); - name = Atom.findOrCreateUnicodeAtom(fieldName.getStringValue()); + String fieldName = eField.getName(); + name = Atom.findOrCreateUnicodeAtom(fieldName); - TypeIdItem fieldType = eField.field.getFieldType(); + String fieldType = eField.getType(); TypeName T = DexUtil.getTypeName(fieldType); TypeReference type = TypeReference.findOrCreate(myClass.getClassLoader().getReference(), T); myFieldRef = FieldReference.findOrCreate(myClass.getReference(), name, type); @@ -144,27 +137,27 @@ public class DexIField implements IField { @Override public boolean isFinal() { - return (eField.accessFlags & FINAL.getValue()) != 0; + return (eField.getAccessFlags() & FINAL.getValue()) != 0; } @Override public boolean isPrivate() { - return (eField.accessFlags & PRIVATE.getValue()) != 0; + return (eField.getAccessFlags() & PRIVATE.getValue()) != 0; } @Override public boolean isProtected() { - return (eField.accessFlags & PROTECTED.getValue()) != 0; + return (eField.getAccessFlags() & PROTECTED.getValue()) != 0; } @Override public boolean isPublic() { - return (eField.accessFlags & PUBLIC.getValue()) != 0; + return (eField.getAccessFlags() & PUBLIC.getValue()) != 0; } @Override public boolean isStatic() { - return (eField.accessFlags & STATIC.getValue()) != 0; + return (eField.getAccessFlags() & STATIC.getValue()) != 0; } @Override @@ -174,7 +167,7 @@ public class DexIField implements IField { @Override public boolean isVolatile() { - return (eField.accessFlags & VOLATILE.getValue()) != 0; + return (eField.getAccessFlags() & VOLATILE.getValue()) != 0; } @Override @@ -184,7 +177,7 @@ public class DexIField implements IField { @Override public Collection getAnnotations() { - return DexUtil.getAnnotations(myClass.getAnnotations(eField.field), myClass.getClassLoader().getReference()); + return myClass.getAnnotations(eField); } } diff --git a/com.ibm.wala.dalvik/src/com/ibm/wala/dalvik/classLoader/DexIMethod.java b/com.ibm.wala.dalvik/src/com/ibm/wala/dalvik/classLoader/DexIMethod.java index d64f62844..d243c45d0 100644 --- a/com.ibm.wala.dalvik/src/com/ibm/wala/dalvik/classLoader/DexIMethod.java +++ b/com.ibm.wala.dalvik/src/com/ibm/wala/dalvik/classLoader/DexIMethod.java @@ -6,6 +6,8 @@ * * This file is a derivative of code released under the terms listed below. * + * dexlib2 update: Julian Dolby (dolby@us.ibm.com) + * */ /* * @@ -47,63 +49,60 @@ package com.ibm.wala.dalvik.classLoader; -import static org.jf.dexlib.Util.AccessFlags.ABSTRACT; -import static org.jf.dexlib.Util.AccessFlags.BRIDGE; -import static org.jf.dexlib.Util.AccessFlags.DECLARED_SYNCHRONIZED; -import static org.jf.dexlib.Util.AccessFlags.FINAL; -import static org.jf.dexlib.Util.AccessFlags.NATIVE; -import static org.jf.dexlib.Util.AccessFlags.PRIVATE; -import static org.jf.dexlib.Util.AccessFlags.PROTECTED; -import static org.jf.dexlib.Util.AccessFlags.PUBLIC; -import static org.jf.dexlib.Util.AccessFlags.STATIC; -import static org.jf.dexlib.Util.AccessFlags.VOLATILE; +import static org.jf.dexlib2.AccessFlags.ABSTRACT; +import static org.jf.dexlib2.AccessFlags.BRIDGE; +import static org.jf.dexlib2.AccessFlags.DECLARED_SYNCHRONIZED; +import static org.jf.dexlib2.AccessFlags.FINAL; +import static org.jf.dexlib2.AccessFlags.NATIVE; +import static org.jf.dexlib2.AccessFlags.PRIVATE; +import static org.jf.dexlib2.AccessFlags.PROTECTED; +import static org.jf.dexlib2.AccessFlags.PUBLIC; +import static org.jf.dexlib2.AccessFlags.STATIC; +import static org.jf.dexlib2.AccessFlags.VOLATILE; import java.util.ArrayList; import java.util.Collection; import java.util.Collections; import java.util.List; import java.util.Map; +import java.util.Set; -import org.jf.dexlib.AnnotationItem; -import org.jf.dexlib.AnnotationSetItem; -import org.jf.dexlib.ClassDataItem.EncodedMethod; -import org.jf.dexlib.CodeItem.EncodedTypeAddrPair; -import org.jf.dexlib.CodeItem.TryItem; -import org.jf.dexlib.FieldIdItem; -import org.jf.dexlib.MethodIdItem; -import org.jf.dexlib.StringIdItem; -import org.jf.dexlib.TypeIdItem; -import org.jf.dexlib.Code.InstructionWithReference; -import org.jf.dexlib.Code.Opcode; -import org.jf.dexlib.Code.TwoRegisterInstruction; -import org.jf.dexlib.Code.Format.ArrayDataPseudoInstruction; -import org.jf.dexlib.Code.Format.Instruction10t; -import org.jf.dexlib.Code.Format.Instruction11n; -import org.jf.dexlib.Code.Format.Instruction11x; -import org.jf.dexlib.Code.Format.Instruction12x; -import org.jf.dexlib.Code.Format.Instruction20t; -import org.jf.dexlib.Code.Format.Instruction21c; -import org.jf.dexlib.Code.Format.Instruction21h; -import org.jf.dexlib.Code.Format.Instruction21s; -import org.jf.dexlib.Code.Format.Instruction21t; -import org.jf.dexlib.Code.Format.Instruction22b; -import org.jf.dexlib.Code.Format.Instruction22c; -import org.jf.dexlib.Code.Format.Instruction22s; -import org.jf.dexlib.Code.Format.Instruction22t; -import org.jf.dexlib.Code.Format.Instruction22x; -import org.jf.dexlib.Code.Format.Instruction23x; -import org.jf.dexlib.Code.Format.Instruction30t; -import org.jf.dexlib.Code.Format.Instruction31c; -import org.jf.dexlib.Code.Format.Instruction31i; -import org.jf.dexlib.Code.Format.Instruction31t; -import org.jf.dexlib.Code.Format.Instruction32x; -import org.jf.dexlib.Code.Format.Instruction35c; -import org.jf.dexlib.Code.Format.Instruction3rc; -import org.jf.dexlib.Code.Format.Instruction51l; -import org.jf.dexlib.Code.Format.PackedSwitchDataPseudoInstruction; -import org.jf.dexlib.Code.Format.SparseSwitchDataPseudoInstruction; -import org.jf.dexlib.EncodedValue.ArrayEncodedValue; -import org.jf.dexlib.EncodedValue.TypeEncodedValue; +import org.jf.dexlib2.Opcode; +import org.jf.dexlib2.iface.AnnotationElement; +import org.jf.dexlib2.iface.Method; +import org.jf.dexlib2.iface.TryBlock; +import org.jf.dexlib2.iface.instruction.SwitchPayload; +import org.jf.dexlib2.iface.instruction.TwoRegisterInstruction; +import org.jf.dexlib2.iface.instruction.formats.ArrayPayload; +import org.jf.dexlib2.iface.instruction.formats.Instruction10t; +import org.jf.dexlib2.iface.instruction.formats.Instruction11n; +import org.jf.dexlib2.iface.instruction.formats.Instruction11x; +import org.jf.dexlib2.iface.instruction.formats.Instruction12x; +import org.jf.dexlib2.iface.instruction.formats.Instruction20t; +import org.jf.dexlib2.iface.instruction.formats.Instruction21c; +import org.jf.dexlib2.iface.instruction.formats.Instruction21ih; +import org.jf.dexlib2.iface.instruction.formats.Instruction21lh; +import org.jf.dexlib2.iface.instruction.formats.Instruction21s; +import org.jf.dexlib2.iface.instruction.formats.Instruction21t; +import org.jf.dexlib2.iface.instruction.formats.Instruction22b; +import org.jf.dexlib2.iface.instruction.formats.Instruction22c; +import org.jf.dexlib2.iface.instruction.formats.Instruction22s; +import org.jf.dexlib2.iface.instruction.formats.Instruction22t; +import org.jf.dexlib2.iface.instruction.formats.Instruction22x; +import org.jf.dexlib2.iface.instruction.formats.Instruction23x; +import org.jf.dexlib2.iface.instruction.formats.Instruction30t; +import org.jf.dexlib2.iface.instruction.formats.Instruction31c; +import org.jf.dexlib2.iface.instruction.formats.Instruction31i; +import org.jf.dexlib2.iface.instruction.formats.Instruction31t; +import org.jf.dexlib2.iface.instruction.formats.Instruction32x; +import org.jf.dexlib2.iface.instruction.formats.Instruction35c; +import org.jf.dexlib2.iface.instruction.formats.Instruction3rc; +import org.jf.dexlib2.iface.instruction.formats.Instruction51l; +import org.jf.dexlib2.iface.reference.FieldReference; +import org.jf.dexlib2.iface.reference.StringReference; +import org.jf.dexlib2.iface.value.ArrayEncodedValue; +import org.jf.dexlib2.iface.value.EncodedValue; +import org.jf.dexlib2.iface.value.TypeEncodedValue; import com.ibm.wala.classLoader.CallSiteReference; import com.ibm.wala.classLoader.IBytecodeMethod; @@ -138,7 +137,6 @@ import com.ibm.wala.dalvik.dex.instructions.UnaryOperation; import com.ibm.wala.dalvik.dex.instructions.UnaryOperation.OpID; import com.ibm.wala.ipa.cha.IClassHierarchy; import com.ibm.wala.shrikeBT.ExceptionHandler; -import com.ibm.wala.shrikeBT.IInstruction; import com.ibm.wala.shrikeBT.IndirectionData; import com.ibm.wala.types.ClassLoaderReference; import com.ibm.wala.types.Descriptor; @@ -154,12 +152,12 @@ import com.ibm.wala.util.strings.ImmutableByteArray; /** * A wrapper around a EncodedMethod object (from dexlib) that represents a method. */ -public class DexIMethod implements IBytecodeMethod { +public class DexIMethod implements IBytecodeMethod { /** * The EncodedMethod object for which this DexIMethod is a wrapper. */ - private final EncodedMethod eMethod; + private final Method eMethod; /** * The declaring class for this method. @@ -186,7 +184,7 @@ public class DexIMethod implements IBytecodeMethod { private static int totalInsts = 0; - public DexIMethod(EncodedMethod encodedMethod, DexIClass klass) { + public DexIMethod(Method encodedMethod, DexIClass klass) { eMethod = encodedMethod; myClass = klass; } @@ -202,7 +200,7 @@ public class DexIMethod implements IBytecodeMethod { /** * @return the EncodedMethod object for which this DexIMethod is a wrapper. */ - public EncodedMethod toEncodedMethod() { + public Method toEncodedMethod() { return eMethod; } @@ -215,21 +213,20 @@ public class DexIMethod implements IBytecodeMethod { public TypeReference[] getDeclaredExceptions() throws UnsupportedOperationException { /** BEGIN Custom change: Variable Names in synth. methods */ - assert (eMethod.method != null); if (myClass.getClassDefItem().getAnnotations() == null) { return null; } ArrayList strings = new ArrayList<>(); - AnnotationSetItem annotationSet = myClass.getClassDefItem().getAnnotations().getMethodAnnotations(eMethod.method); + Set annotationSet = eMethod.getAnnotations(); /** END Custom change: Variable Names in synth. methods */ - if (annotationSet != null) { - for (AnnotationItem annotationItem: annotationSet.getAnnotations()) + if (annotationSet != null) { + for (org.jf.dexlib2.iface.Annotation annotationItem: annotationSet) { - if (annotationItem.getEncodedAnnotation().annotationType.getTypeDescriptor().contentEquals("Ldalvik/annotation/Throws;")) { - for (int i = 0; i < annotationItem.getEncodedAnnotation().values.length; i++) { - for (int j = 0; j < ((ArrayEncodedValue)annotationItem.getEncodedAnnotation().values[i]).values.length; j++) { - String tname = ((TypeEncodedValue)((ArrayEncodedValue)annotationItem.getEncodedAnnotation().values[i]).values[j]).value.getTypeDescriptor(); + if (annotationItem.getType().contentEquals("Ldalvik/annotation/Throws;")) { + for (AnnotationElement e : annotationItem.getElements()) { + for (EncodedValue v : ((ArrayEncodedValue)e.getValue()).getValue()) { + String tname = ((TypeEncodedValue)v).getValue(); if (tname.endsWith(";")) tname = tname.substring(0,tname.length()-1); strings.add(tname); @@ -263,15 +260,15 @@ public class DexIMethod implements IBytecodeMethod { * @see com.ibm.wala.classLoader.ShrikeCTMethod#getMaxLocals() */ public int getMaxLocals() { - return eMethod.codeItem.getRegisterCount() + 2; + return eMethod.getImplementation().getRegisterCount() + 2; } public int getReturnReg() { - return eMethod.codeItem.getRegisterCount(); + return eMethod.getImplementation().getRegisterCount(); } public int getExceptionReg() { - return eMethod.codeItem.getRegisterCount()+1; + return eMethod.getImplementation().getRegisterCount()+1; } /* @@ -309,21 +306,17 @@ public class DexIMethod implements IBytecodeMethod { return number; } - //returns the number of registers it takes for the parameters + the "this" register. public int getNumberOfParameterRegisters() { - final int number; + int number = isStatic() || isClinit() ? 0 : 1; - - if (isStatic() || isClinit()) { - number = eMethod.method.getPrototype().getParameterRegisterCount(); - } else { - number = eMethod.method.getPrototype().getParameterRegisterCount() + 1; + for(int i = 0; i < getReference().getNumberOfParameters(); i++) { + TypeReference ref = getReference().getParameterType(i); + number += ref.equals(TypeReference.Double) || ref.equals(TypeReference.Long) ? 2 : 1; } + return number; } - - /* * (non-Javadoc) * @see com.ibm.wala.classLoader.IMethod#getParameterType(int) @@ -350,14 +343,13 @@ public class DexIMethod implements IBytecodeMethod { //Compute the method reference from the MethodIdItem if (methodReference == null) { // Set method name - Atom name = Atom.findOrCreateUnicodeAtom(eMethod.method.getMethodName().getStringValue()); + Atom name = Atom.findOrCreateUnicodeAtom(eMethod.getName()); // // Set the descriptor // Descriptor descriptor = Descriptor.findOrCreateUTF8(eMethod.method.getPrototype().getPrototypeString()); // methodReference = MethodReference.findOrCreate(myClass.getReference(),name, descriptor); - ImmutableByteArray desc = ImmutableByteArray.make(eMethod.method.getPrototype().getPrototypeString()); - Descriptor D = Descriptor.findOrCreate(myClass.getClassLoader().getLanguage(), desc); + Descriptor D = Descriptor.findOrCreate(myClass.getClassLoader().getLanguage(), ImmutableByteArray.make(DexUtil.getSignature(eMethod))); methodReference = MethodReference.findOrCreate(myClass.getReference(), name, D); } @@ -404,8 +396,8 @@ public class DexIMethod implements IBytecodeMethod { */ @Override public boolean hasExceptionHandler() { - TryItem[] tries = eMethod.codeItem.getTries(); - return tries==null?false:tries.length > 0; + List> tries = eMethod.getImplementation().getTryBlocks(); + return tries==null?false:tries.size() > 0; } /* @@ -426,7 +418,7 @@ public class DexIMethod implements IBytecodeMethod { */ @Override public boolean isAbstract() { - return (eMethod.accessFlags & ABSTRACT.getValue()) != 0; + return (eMethod.getAccessFlags() & ABSTRACT.getValue()) != 0; } /* @@ -435,7 +427,7 @@ public class DexIMethod implements IBytecodeMethod { */ @Override public boolean isClinit() { - return eMethod.method.getMethodName().getStringValue().equals(MethodReference.clinitName.toString()); + return eMethod.getName().equals(MethodReference.clinitName.toString()); } /* @@ -444,7 +436,7 @@ public class DexIMethod implements IBytecodeMethod { */ @Override public boolean isFinal() { - return (eMethod.accessFlags & FINAL.getValue()) != 0; + return (eMethod.getAccessFlags() & FINAL.getValue()) != 0; } /* @@ -453,7 +445,7 @@ public class DexIMethod implements IBytecodeMethod { */ @Override public boolean isInit() { - return eMethod.method.getMethodName().getStringValue().equals(MethodReference.initAtom.toString()); + return eMethod.getName().equals(MethodReference.initAtom.toString()); } /* @@ -462,7 +454,7 @@ public class DexIMethod implements IBytecodeMethod { */ @Override public boolean isNative() { - return (eMethod.accessFlags & NATIVE.getValue()) != 0; + return (eMethod.getAccessFlags() & NATIVE.getValue()) != 0; } /* @@ -471,7 +463,7 @@ public class DexIMethod implements IBytecodeMethod { */ @Override public boolean isBridge() { - return (eMethod.accessFlags & BRIDGE.getValue()) != 0; + return (eMethod.getAccessFlags() & BRIDGE.getValue()) != 0; } /* @@ -480,7 +472,7 @@ public class DexIMethod implements IBytecodeMethod { */ @Override public boolean isPrivate() { - return (eMethod.accessFlags & PRIVATE.getValue()) != 0; + return (eMethod.getAccessFlags() & PRIVATE.getValue()) != 0; } /* @@ -489,7 +481,7 @@ public class DexIMethod implements IBytecodeMethod { */ @Override public boolean isProtected() { - return (eMethod.accessFlags & PROTECTED.getValue()) != 0; + return (eMethod.getAccessFlags() & PROTECTED.getValue()) != 0; } /* @@ -499,7 +491,7 @@ public class DexIMethod implements IBytecodeMethod { */ @Override public boolean isPublic() { - return (eMethod.accessFlags & PUBLIC.getValue()) != 0; + return (eMethod.getAccessFlags() & PUBLIC.getValue()) != 0; } /* @@ -508,7 +500,7 @@ public class DexIMethod implements IBytecodeMethod { */ @Override public boolean isSynchronized() { - return (eMethod.accessFlags & DECLARED_SYNCHRONIZED.getValue()) != 0; + return (eMethod.getAccessFlags() & DECLARED_SYNCHRONIZED.getValue()) != 0; } /* @@ -526,7 +518,7 @@ public class DexIMethod implements IBytecodeMethod { */ @Override public boolean isStatic() { - return (eMethod.accessFlags & STATIC.getValue()) != 0; + return (eMethod.getAccessFlags() & STATIC.getValue()) != 0; } /* @@ -534,7 +526,7 @@ public class DexIMethod implements IBytecodeMethod { * @see com.ibm.wala.classLoader.IMember#isVolatile() */ public boolean isVolatile() { - return (eMethod.accessFlags & VOLATILE.getValue()) != 0; + return (eMethod.getAccessFlags() & VOLATILE.getValue()) != 0; } /* @@ -625,7 +617,7 @@ public class DexIMethod implements IBytecodeMethod { //ExceptionHandler[][] handlers = new ExceptionHandler[eMethod.codeItem.getInstructions().length][]; - TryItem[] tries = eMethod.codeItem.getTries(); + List> tryBlocks = eMethod.getImplementation().getTryBlocks(); // // if (tries == null){ @@ -642,7 +634,7 @@ public class DexIMethod implements IBytecodeMethod { // } this.handlers = new ExceptionHandler[instructions().size()][]; - if (tries == null){ + if (tryBlocks == null){ // return new ExceptionHandler[instructions.size()][]; return handlers; } @@ -652,9 +644,9 @@ public class DexIMethod implements IBytecodeMethod { temp_array.add(new ArrayList()); } - for (TryItem tryItem: tries) { + for (TryBlock tryItem: tryBlocks) { int startAddress = tryItem.getStartCodeAddress(); - int endAddress = tryItem.getStartCodeAddress() + tryItem.getTryLength(); + int endAddress = tryItem.getStartCodeAddress() + tryItem.getCodeUnitCount(); /** * The end address points to the address immediately after the end of the last * instruction that the try block covers. We want the .catch directive and end_try @@ -672,7 +664,11 @@ public class DexIMethod implements IBytecodeMethod { */ if (endAddress > getAddressFromIndex(instructions().size()-1)) { endInst = instructions().size()-1; - if (endAddress != (getAddressFromIndex(endInst) + (eMethod.codeItem.getInstructions())[endInst].getSize(getAddressFromIndex(endInst)))) + int endSize = 0; + for(org.jf.dexlib2.iface.instruction.Instruction inst : eMethod.getImplementation().getInstructions()) { + endSize = inst.getCodeUnits(); + } + if (endAddress != (getAddressFromIndex(endInst) + endSize)) throw new RuntimeException("Invalid code offset " + endAddress + " for the try block end address"); } else { @@ -681,23 +677,10 @@ public class DexIMethod implements IBytecodeMethod { for (int i = startInst; i <= endInst; i++) { //add the rest of the handlers - for (EncodedTypeAddrPair etaps: tryItem.encodedCatchHandler.handlers) { - temp_array.get(i).add(new ExceptionHandler( getInstructionIndex(etaps.getHandlerAddress()), etaps.exceptionType.getTypeDescriptor() )); + for (org.jf.dexlib2.iface.ExceptionHandler etaps: tryItem.getExceptionHandlers()) { + temp_array.get(i).add(new ExceptionHandler( getInstructionIndex(etaps.getHandlerCodeAddress()), etaps.getExceptionType() )); } } - //add the catch all handler if it exists - int catchAllAddress = tryItem.encodedCatchHandler.getCatchAllHandlerAddress(); - if (catchAllAddress != -1) { - // CatchMethodItem catchAllMethodItem = new CatchMethodItem(labelCache, lastInstructionAddress, null, - // startAddress, endAddress, catchAllAddress); - // methodItems.add(catchAllMethodItem); - // System.out.println("Method: " + this.getSignature() + " - address: " + catchAllAddress); - // System.out.println("Start: " + startInst + " End: " + endInst); - for (int i = startInst; i<=endInst; i++) { - temp_array.get(i).add(new ExceptionHandler(getInstructionIndex(catchAllAddress), null)); - } - //throw new UnimplementedError("DexIMethod->handlers: getCatchAllHandlerAddress() not yet implemented"); - } } @@ -720,18 +703,17 @@ public class DexIMethod implements IBytecodeMethod { @Override - public IInstruction[] getInstructions() { + public Instruction[] getInstructions() { if (instructions == null) parseBytecode(); - throw new UnsupportedOperationException( - "DexMethod doesn't use IInstruction - try getDexInstructions instead"); + return instructions.toArray(new Instruction[ instructions.size() ]); } protected void parseBytecode() { - org.jf.dexlib.Code.Instruction[] instrucs = eMethod.codeItem.getInstructions(); + Iterable instrucs = eMethod.getImplementation().getInstructions(); // for (org.jfmethod.getInstructionIndex(.dexlib.Code.Instruction inst: instrucs) // { @@ -848,26 +830,29 @@ public class DexIMethod implements IBytecodeMethod { int instCounter = -1; //int pc = 0; int currentCodeAddress = 0; - for (org.jf.dexlib.Code.Instruction inst: instrucs) + for (org.jf.dexlib2.iface.instruction.Instruction inst: instrucs) { totalInsts++; instCounter++; // instLoc = pc - instCounter; instLoc = currentCodeAddress; //pc += inst.getFormat().size; - switch(inst.opcode) + switch(inst.getOpcode()) { case NOP: - switch (inst.getFormat()) + case ARRAY_PAYLOAD: + case PACKED_SWITCH_PAYLOAD: + case SPARSE_SWITCH_PAYLOAD: + switch (inst.getOpcode().format) { - case ArrayData: + case ArrayPayload: { for (int i = 0; i < instructions.size(); i++) { if (instructions.getFromId(i) instanceof ArrayFill) if (instLoc == (((ArrayFill)getInstructionFromIndex(i)).tableAddressOffset + getAddressFromIndex(i))) { - ((ArrayFill)getInstructionFromIndex(i)).setArrayDataTable((ArrayDataPseudoInstruction)inst); + ((ArrayFill)getInstructionFromIndex(i)).setArrayDataTable((ArrayPayload)inst); @@ -892,27 +877,31 @@ public class DexIMethod implements IBytecodeMethod { } break; } - case PackedSwitchData: + case PackedSwitchPayload: for (int i = 0; i < instructions.size(); i++) { if (instructions.getFromId(i) instanceof Switch) if (instLoc == (((Switch)getInstructionFromIndex(i)).tableAddressOffset + getAddressFromIndex(i))) { - ((Switch)getInstructionFromIndex(i)).setSwitchPad(new PackedSwitchPad(((PackedSwitchDataPseudoInstruction)inst), - getAddressFromIndex(i+1) - getAddressFromIndex(i))); + ((Switch)getInstructionFromIndex(i)) + .setSwitchPad(new PackedSwitchPad( + (SwitchPayload)inst, + getAddressFromIndex(i+1) - getAddressFromIndex(i))); break; } } break; - case SparseSwitchData: + case SparseSwitchPayload: { for (int i = 0; i < instructions.size(); i++) { if (instructions.getFromId(i) instanceof Switch) if (instLoc == (((Switch)getInstructionFromIndex(i)).tableAddressOffset + getAddressFromIndex(i))) { - ((Switch)getInstructionFromIndex(i)).setSwitchPad(new SparseSwitchPad(((SparseSwitchDataPseudoInstruction)inst), - getAddressFromIndex(i+1) - getAddressFromIndex(i))); + ((Switch)getInstructionFromIndex(i)).setSwitchPad( + new SparseSwitchPad( + (SwitchPayload)inst, + getAddressFromIndex(i+1) - getAddressFromIndex(i))); break; } } @@ -925,147 +914,150 @@ public class DexIMethod implements IBytecodeMethod { // } break; } - case UnresolvedOdexInstruction: - throw new RuntimeException("UnresolvedOdexInstruction" - + inst.opcode.toString() + inst.getFormat()); default: - instructions.add(new Instruction(currentCodeAddress, Opcode.NOP, this) { + class NOPInstruction extends Instruction { + private NOPInstruction(int pc, Opcode op, DexIMethod method) { + super(pc, op, method); + } + @Override public void visit(Visitor visitor) { // no op } - }); + } + + instructions.add(new NOPInstruction(currentCodeAddress, Opcode.NOP, this)); break; } break; case MOVE: instructions.add(new UnaryOperation(instLoc, UnaryOperation.OpID.MOVE, ((Instruction12x)inst).getRegisterA(), - ((Instruction12x)inst).getRegisterB(), inst.opcode, this)); + ((Instruction12x)inst).getRegisterB(), inst.getOpcode(), this)); break; case MOVE_FROM16: instructions.add(new UnaryOperation(instLoc, UnaryOperation.OpID.MOVE, ((Instruction22x)inst).getRegisterA(), - ((Instruction22x)inst).getRegisterB(), inst.opcode, this)); + ((Instruction22x)inst).getRegisterB(), inst.getOpcode(), this)); break; case MOVE_16: instructions.add(new UnaryOperation(instLoc, UnaryOperation.OpID.MOVE, ((Instruction32x)inst).getRegisterA(), - ((Instruction32x)inst).getRegisterB(), inst.opcode, this)); + ((Instruction32x)inst).getRegisterB(), inst.getOpcode(), this)); break; case MOVE_WIDE: instructions.add(new UnaryOperation(instLoc, UnaryOperation.OpID.MOVE_WIDE, - ((Instruction12x)inst).getRegisterA(), ((Instruction12x)inst).getRegisterB(), inst.opcode, this)); + ((Instruction12x)inst).getRegisterA(), ((Instruction12x)inst).getRegisterB(), inst.getOpcode(), this)); break; case MOVE_WIDE_FROM16: instructions.add(new UnaryOperation(instLoc, UnaryOperation.OpID.MOVE_WIDE, - ((Instruction22x)inst).getRegisterA(), ((Instruction22x)inst).getRegisterB(), inst.opcode, this)); + ((Instruction22x)inst).getRegisterA(), ((Instruction22x)inst).getRegisterB(), inst.getOpcode(), this)); break; case MOVE_WIDE_16: instructions.add(new UnaryOperation(instLoc, UnaryOperation.OpID.MOVE_WIDE, - ((Instruction32x)inst).getRegisterA(), ((Instruction32x)inst).getRegisterB(), inst.opcode, this)); + ((Instruction32x)inst).getRegisterA(), ((Instruction32x)inst).getRegisterB(), inst.getOpcode(), this)); break; case MOVE_OBJECT: instructions.add(new UnaryOperation(instLoc, UnaryOperation.OpID.MOVE, ((Instruction12x)inst).getRegisterA(), - ((Instruction12x)inst).getRegisterB(), inst.opcode, this)); + ((Instruction12x)inst).getRegisterB(), inst.getOpcode(), this)); break; case MOVE_OBJECT_FROM16: instructions.add(new UnaryOperation(instLoc, UnaryOperation.OpID.MOVE, ((Instruction22x)inst).getRegisterA(), - ((Instruction22x)inst).getRegisterB(), inst.opcode, this)); + ((Instruction22x)inst).getRegisterB(), inst.getOpcode(), this)); break; case MOVE_OBJECT_16: instructions.add(new UnaryOperation(instLoc, UnaryOperation.OpID.MOVE, ((Instruction32x)inst).getRegisterA(), - ((Instruction32x)inst).getRegisterB(), inst.opcode, this)); + ((Instruction32x)inst).getRegisterB(), inst.getOpcode(), this)); break; case MOVE_RESULT: //register b set as return register, -1; instructions.add(new UnaryOperation(instLoc, - UnaryOperation.OpID.MOVE, ((Instruction11x)inst).getRegisterA(), getReturnReg(), inst.opcode, this)); + UnaryOperation.OpID.MOVE, ((Instruction11x)inst).getRegisterA(), getReturnReg(), inst.getOpcode(), this)); break; case MOVE_RESULT_WIDE: instructions.add(new UnaryOperation(instLoc, UnaryOperation.OpID.MOVE_WIDE, - ((Instruction11x)inst).getRegisterA(), getReturnReg(), inst.opcode, this)); + ((Instruction11x)inst).getRegisterA(), getReturnReg(), inst.getOpcode(), this)); break; case MOVE_RESULT_OBJECT: instructions.add(new UnaryOperation(instLoc, UnaryOperation.OpID.MOVE, ((Instruction11x)inst).getRegisterA(), - getReturnReg(), inst.opcode, this)); + getReturnReg(), inst.getOpcode(), this)); break; case MOVE_EXCEPTION: instructions.add(new UnaryOperation(instLoc, UnaryOperation.OpID.MOVE_EXCEPTION, ((Instruction11x)inst).getRegisterA(), - getExceptionReg(), inst.opcode, this)); + getExceptionReg(), inst.getOpcode(), this)); break; case RETURN_VOID: - instructions.add(new Return.ReturnVoid(instLoc, inst.opcode, this)); + instructions.add(new Return.ReturnVoid(instLoc, inst.getOpcode(), this)); break; case RETURN: //I think only primitives call return, and objects call return-object instructions.add(new Return.ReturnSingle(instLoc, - ((Instruction11x)inst).getRegisterA(), true, inst.opcode, this)); + ((Instruction11x)inst).getRegisterA(), true, inst.getOpcode(), this)); break; case RETURN_WIDE: //+1 to second parameter okay? instructions.add(new Return.ReturnDouble(instLoc, - ((Instruction11x)inst).getRegisterA(), ((Instruction11x)inst).getRegisterA()+1, inst.opcode, this)); + ((Instruction11x)inst).getRegisterA(), ((Instruction11x)inst).getRegisterA()+1, inst.getOpcode(), this)); break; case RETURN_OBJECT: instructions.add(new Return.ReturnSingle(instLoc, - ((Instruction11x)inst).getRegisterA(), false, inst.opcode, this)); + ((Instruction11x)inst).getRegisterA(), false, inst.getOpcode(), this)); break; case CONST_4: { instructions.add(new Constant.IntConstant(instLoc, - (int)((Instruction11n)inst).getLiteral(),((Instruction11n)inst).getRegisterA(), inst.opcode, this)); + ((Instruction11n)inst).getNarrowLiteral(),((Instruction11n)inst).getRegisterA(), inst.getOpcode(), this)); break; } case CONST_16: instructions.add(new Constant.IntConstant(instLoc, - (int)((Instruction21s)inst).getLiteral(), ((Instruction21s)inst).getRegisterA(), inst.opcode, this)); + ((Instruction21s)inst).getNarrowLiteral(), ((Instruction21s)inst).getRegisterA(), inst.getOpcode(), this)); break; case CONST: instructions.add(new Constant.IntConstant(instLoc, - (int)((Instruction31i)inst).getLiteral(), ((Instruction31i)inst).getRegisterA(), inst.opcode, this)); + ((Instruction31i)inst).getNarrowLiteral(), ((Instruction31i)inst).getRegisterA(), inst.getOpcode(), this)); break; case CONST_HIGH16: instructions.add(new Constant.IntConstant(instLoc, - (int)((Instruction21h)inst).getLiteral() << 16, ((Instruction21h)inst).getRegisterA(), inst.opcode, this)); + ((Instruction21ih)inst).getHatLiteral() << 16, ((Instruction21ih)inst).getRegisterA(), inst.getOpcode(), this)); break; case CONST_WIDE_16: instructions.add(new Constant.LongConstant(instLoc, - ((Instruction21s)inst).getLiteral(), ((Instruction21s)inst).getRegisterA(), inst.opcode, this)); + ((Instruction21s)inst).getWideLiteral(), ((Instruction21s)inst).getRegisterA(), inst.getOpcode(), this)); break; case CONST_WIDE_32: instructions.add(new Constant.LongConstant(instLoc, - ((Instruction31i)inst).getLiteral(), ((Instruction31i)inst).getRegisterA(), inst.opcode, this)); + ((Instruction31i)inst).getWideLiteral(), ((Instruction31i)inst).getRegisterA(), inst.getOpcode(), this)); break; case CONST_WIDE: instructions.add(new Constant.LongConstant(instLoc, - ((Instruction51l)inst).getLiteral(), ((Instruction51l)inst).getRegisterA(), inst.opcode, this)); + ((Instruction51l)inst).getWideLiteral(), ((Instruction51l)inst).getRegisterA(), inst.getOpcode(), this)); break; case CONST_WIDE_HIGH16: instructions.add(new Constant.LongConstant(instLoc, - ((Instruction21h)inst).getLiteral() << 16, ((Instruction21h)inst).getRegisterA(), inst.opcode, this)); + ((Instruction21lh)inst).getWideLiteral() << 16, ((Instruction21lh)inst).getRegisterA(), inst.getOpcode(), this)); break; case CONST_STRING: instructions.add(new Constant.StringConstant(instLoc, - ((StringIdItem)((Instruction21c)inst).getReferencedItem()).getStringValue(), - ((Instruction21c)inst).getRegisterA(), inst.opcode, this)); + ((StringReference)((Instruction21c)inst).getReference()).getString(), + ((Instruction21c)inst).getRegisterA(), inst.getOpcode(), this)); break; case CONST_STRING_JUMBO: instructions.add(new Constant.StringConstant(instLoc, - ((StringIdItem)((Instruction31c)inst).getReferencedItem()).getStringValue(), - ((Instruction31c)inst).getRegisterA(), inst.opcode, this)); + ((StringReference)((Instruction31c)inst).getReference()).getString(), + ((Instruction31c)inst).getRegisterA(), inst.getOpcode(), this)); break; case CONST_CLASS: { - String cname = ((TypeIdItem)((Instruction21c)inst).getReferencedItem()).getTypeDescriptor(); + String cname = ((org.jf.dexlib2.iface.reference.TypeReference)((Instruction21c)inst).getReference()).getType(); if (cname.endsWith(";")) cname = cname.substring(0,cname.length()-1); @@ -1073,18 +1065,18 @@ public class DexIMethod implements IBytecodeMethod { TypeReference typeRef = TypeReference.findOrCreate(myClass.getClassLoader().getReference(), cname); instructions.add(new Constant.ClassConstant(instLoc, - typeRef, ((Instruction21c)inst).getRegisterA(), inst.opcode, this)); + typeRef, ((Instruction21c)inst).getRegisterA(), inst.getOpcode(), this)); //logger.debug("myClass found name: " + this.myClass.loader.lookupClass(TypeName.findOrCreate(cname)).toString()); break; } case MONITOR_ENTER: - instructions.add(new Monitor(instLoc, true, ((Instruction11x)inst).getRegisterA(), inst.opcode, this)); + instructions.add(new Monitor(instLoc, true, ((Instruction11x)inst).getRegisterA(), inst.getOpcode(), this)); break; case MONITOR_EXIT: - instructions.add(new Monitor(instLoc, false, ((Instruction11x)inst).getRegisterA(), inst.opcode, this)); + instructions.add(new Monitor(instLoc, false, ((Instruction11x)inst).getRegisterA(), inst.getOpcode(), this)); break; case CHECK_CAST: { - String cname = ((TypeIdItem)((Instruction21c)inst).getReferencedItem()).getTypeDescriptor(); + String cname = ((org.jf.dexlib2.iface.reference.TypeReference)((Instruction21c)inst).getReference()).getType(); if (cname.endsWith(";")) cname = cname.substring(0,cname.length()-1); @@ -1092,35 +1084,35 @@ public class DexIMethod implements IBytecodeMethod { //retrieving type reference correctly? instructions.add(new CheckCast(instLoc, TypeReference.findOrCreate(myClass.getClassLoader().getReference(), cname), - ((Instruction21c)inst).getRegisterA(), inst.opcode, this)); + ((Instruction21c)inst).getRegisterA(), inst.getOpcode(), this)); break; } case INSTANCE_OF: { - String cname = ((TypeIdItem)((Instruction22c)inst).getReferencedItem()).getTypeDescriptor(); + String cname = ((org.jf.dexlib2.iface.reference.TypeReference)((Instruction22c)inst).getReference()).getType(); if (cname.endsWith(";")) cname = cname.substring(0,cname.length()-1); instructions.add(new InstanceOf(instLoc, ((Instruction22c)inst).getRegisterA(), TypeReference.findOrCreate(myClass.getClassLoader().getReference(), cname), - ((Instruction22c)inst).getRegisterB(), inst.opcode, this)); + ((Instruction22c)inst).getRegisterB(), inst.getOpcode(), this)); break; } case ARRAY_LENGTH: instructions.add(new ArrayLength(instLoc, ((Instruction12x)inst).getRegisterA(), - ((Instruction12x)inst).getRegisterB(), inst.opcode, this)); + ((Instruction12x)inst).getRegisterB(), inst.getOpcode(), this)); break; case NEW_INSTANCE: { //newsitereference use instLoc or pc? - String cname = ((TypeIdItem)((Instruction21c)inst).getReferencedItem()).getTypeDescriptor(); + String cname = ((org.jf.dexlib2.iface.reference.TypeReference)((Instruction21c)inst).getReference()).getType(); if (cname.endsWith(";")) cname = cname.substring(0,cname.length()-1); instructions.add(new New(instLoc, ((Instruction21c)inst).getRegisterA(), NewSiteReference.make(instLoc, TypeReference.findOrCreate(myClass.getClassLoader().getReference(), - cname)), inst.opcode, this)); + cname)), inst.getOpcode(), this)); break; } case NEW_ARRAY: @@ -1129,7 +1121,7 @@ public class DexIMethod implements IBytecodeMethod { params[0] = ((Instruction22c)inst).getRegisterB(); // MyLogger.log(LogLevel.INFO, "Type: " +((TypeIdItem)((Instruction22c)inst).getReferencedItem()).getTypeDescriptor()); - String cname = ((TypeIdItem)((Instruction22c)inst).getReferencedItem()).getTypeDescriptor(); + String cname = ((org.jf.dexlib2.iface.reference.TypeReference)((Instruction22c)inst).getReference()).getType(); if (cname.endsWith(";")) cname = cname.substring(0,cname.length()-1); @@ -1137,12 +1129,12 @@ public class DexIMethod implements IBytecodeMethod { ((Instruction22c)inst).getRegisterA(), NewSiteReference.make(instLoc, TypeReference.findOrCreate(myClass.getClassLoader().getReference(), cname)), - params, inst.opcode, this)); + params, inst.getOpcode(), this)); break; } //TODO: FILLED ARRAYS case FILLED_NEW_ARRAY: { - int registerCount = ((Instruction35c)inst).getRegCount(); + int registerCount = ((Instruction35c)inst).getRegisterCount(); int[] params = new int[1]; params[0] = registerCount; int[] args = new int[registerCount]; @@ -1163,7 +1155,7 @@ public class DexIMethod implements IBytecodeMethod { args[3] = ((Instruction35c)inst).getRegisterG(); break; case 4: - args[4] = ((Instruction35c)inst).getRegisterA(); + args[4] = ((Instruction35c)inst).getRegisterC(); break; default: throw new RuntimeException("Illegal instruction at " @@ -1171,7 +1163,7 @@ public class DexIMethod implements IBytecodeMethod { } } - String cname = ((TypeIdItem)((Instruction35c)inst).getReferencedItem()).getTypeDescriptor(); + String cname = ((org.jf.dexlib2.iface.reference.TypeReference)((Instruction35c)inst).getReference()).getType(); if (cname.endsWith(";")) cname = cname.substring(0,cname.length()-1); @@ -1180,11 +1172,11 @@ public class DexIMethod implements IBytecodeMethod { TypeReference myTypeRef = TypeReference.findOrCreate(myClass.getClassLoader().getReference(), newSiteRef.getDeclaredType().getArrayElementType().getName().toString()); instructions.add(new NewArrayFilled(instLoc, getReturnReg(), - newSiteRef, myTypeRef, params, args, inst.opcode, this)); + newSiteRef, myTypeRef, params, args, inst.getOpcode(), this)); break; } case FILLED_NEW_ARRAY_RANGE: { - int registerCount = ((Instruction3rc)inst).getRegCount(); + int registerCount = ((Instruction3rc)inst).getRegisterCount(); int[] params = new int[1]; params[0] = registerCount; int[] args = new int[registerCount]; @@ -1192,7 +1184,7 @@ public class DexIMethod implements IBytecodeMethod { for (int i = 0; i < registerCount; i++) args[i] = ((Instruction3rc)inst).getStartRegister() + i; - String cname = ((TypeIdItem)((Instruction3rc)inst).getReferencedItem()).getTypeDescriptor(); + String cname = ((org.jf.dexlib2.iface.reference.TypeReference)((Instruction3rc)inst).getReference()).getType(); if (cname.endsWith(";")) cname = cname.substring(0,cname.length()-1); @@ -1202,175 +1194,175 @@ public class DexIMethod implements IBytecodeMethod { TypeReference myTypeRef = TypeReference.findOrCreate(myClass.getClassLoader().getReference(), newSiteRef.getDeclaredType().getArrayElementType().getName().toString()); - instructions.add(new NewArrayFilled(instLoc, getReturnReg(), newSiteRef, myTypeRef, params, args, inst.opcode, this)); + instructions.add(new NewArrayFilled(instLoc, getReturnReg(), newSiteRef, myTypeRef, params, args, inst.getOpcode(), this)); break; } case FILL_ARRAY_DATA: - // System.out.println("Array Reference: " + ((Instruction31t)inst).getRegisterA()); - // System.out.println("Table Address Offset: " + ((Instruction31t)inst).getTargetAddressOffset()); + System.out.println("Array Reference: " + ((Instruction31t)inst).getRegisterA()); + System.out.println("Table Address Offset: " + ((Instruction31t)inst).getCodeOffset()); - TypeReference arrayElementType = findOutArrayElementType(instrucs, instructions.toArray(new Instruction[0]), instCounter); - instructions.add(new ArrayFill(instLoc, ((Instruction31t)inst).getRegisterA(), ((Instruction31t)inst).getTargetAddressOffset(), - TypeReference.findOrCreate(myClass.getClassLoader().getReference(), arrayElementType.getName().toString()), inst.opcode, this)); + TypeReference arrayElementType = findOutArrayElementType(inst, instructions.toArray(new Instruction[0]), instCounter); + instructions.add(new ArrayFill(instLoc, ((Instruction31t)inst).getRegisterA(), ((Instruction31t)inst).getCodeOffset(), + TypeReference.findOrCreate(myClass.getClassLoader().getReference(), arrayElementType.getName().toString()), inst.getOpcode(), this)); break; case THROW: - instructions.add(new Throw(instLoc, ((Instruction11x)inst).getRegisterA(), inst.opcode, this)); + instructions.add(new Throw(instLoc, ((Instruction11x)inst).getRegisterA(), inst.getOpcode(), this)); break; case GOTO: - instructions.add(new Goto(instLoc, ((Instruction10t)inst).getTargetAddressOffset(), inst.opcode, this)); + instructions.add(new Goto(instLoc, ((Instruction10t)inst).getCodeOffset(), inst.getOpcode(), this)); break; case GOTO_16: - instructions.add(new Goto(instLoc, ((Instruction20t)inst).getTargetAddressOffset(), inst.opcode, this)); + instructions.add(new Goto(instLoc, ((Instruction20t)inst).getCodeOffset(), inst.getOpcode(), this)); break; case GOTO_32: - instructions.add(new Goto(instLoc, ((Instruction30t)inst).getTargetAddressOffset(), inst.opcode, this)); + instructions.add(new Goto(instLoc, ((Instruction30t)inst).getCodeOffset(), inst.getOpcode(), this)); break; case PACKED_SWITCH: case SPARSE_SWITCH: - instructions.add(new Switch(instLoc, ((Instruction31t)inst).getRegisterA(), ((Instruction31t)inst).getTargetAddressOffset(), inst.opcode, this)); + instructions.add(new Switch(instLoc, ((Instruction31t)inst).getRegisterA(), ((Instruction31t)inst).getCodeOffset(), inst.getOpcode(), this)); break; case CMPL_FLOAT: instructions.add(new BinaryOperation(instLoc, BinaryOperation.OpID.CMPL_FLOAT, ((Instruction23x)inst).getRegisterA(), - ((Instruction23x)inst).getRegisterB(), ((Instruction23x)inst).getRegisterC(), inst.opcode, this)); + ((Instruction23x)inst).getRegisterB(), ((Instruction23x)inst).getRegisterC(), inst.getOpcode(), this)); break; case CMPG_FLOAT: instructions.add(new BinaryOperation(instLoc, BinaryOperation.OpID.CMPG_FLOAT, ((Instruction23x)inst).getRegisterA(), - ((Instruction23x)inst).getRegisterB(), ((Instruction23x)inst).getRegisterC(), inst.opcode, this)); + ((Instruction23x)inst).getRegisterB(), ((Instruction23x)inst).getRegisterC(), inst.getOpcode(), this)); break; case CMPL_DOUBLE: instructions.add(new BinaryOperation(instLoc, BinaryOperation.OpID.CMPL_DOUBLE, ((Instruction23x)inst).getRegisterA(), - ((Instruction23x)inst).getRegisterB(), ((Instruction23x)inst).getRegisterC(), inst.opcode, this)); + ((Instruction23x)inst).getRegisterB(), ((Instruction23x)inst).getRegisterC(), inst.getOpcode(), this)); break; case CMPG_DOUBLE: instructions.add(new BinaryOperation(instLoc, BinaryOperation.OpID.CMPG_DOUBLE, ((Instruction23x)inst).getRegisterA(), - ((Instruction23x)inst).getRegisterB(), ((Instruction23x)inst).getRegisterC(), inst.opcode, this)); + ((Instruction23x)inst).getRegisterB(), ((Instruction23x)inst).getRegisterC(), inst.getOpcode(), this)); break; case CMP_LONG: instructions.add(new BinaryOperation(instLoc, BinaryOperation.OpID.CMPL_LONG, ((Instruction23x)inst).getRegisterA(), - ((Instruction23x)inst).getRegisterB(), ((Instruction23x)inst).getRegisterC(), inst.opcode, this)); + ((Instruction23x)inst).getRegisterB(), ((Instruction23x)inst).getRegisterC(), inst.getOpcode(), this)); break; case IF_EQ: - instructions.add(new Branch.BinaryBranch(instLoc, ((Instruction22t)inst).getTargetAddressOffset(), + instructions.add(new Branch.BinaryBranch(instLoc, ((Instruction22t)inst).getCodeOffset(), Branch.BinaryBranch.CompareOp.EQ, ((Instruction22t)inst).getRegisterA(), - ((Instruction22t)inst).getRegisterB(), inst.opcode, this)); + ((Instruction22t)inst).getRegisterB(), inst.getOpcode(), this)); break; case IF_NE: - instructions.add(new Branch.BinaryBranch(instLoc, ((Instruction22t)inst).getTargetAddressOffset(), + instructions.add(new Branch.BinaryBranch(instLoc, ((Instruction22t)inst).getCodeOffset(), Branch.BinaryBranch.CompareOp.NE, ((Instruction22t)inst).getRegisterA(), - ((Instruction22t)inst).getRegisterB(), inst.opcode, this)); + ((Instruction22t)inst).getRegisterB(), inst.getOpcode(), this)); break; case IF_LT: - instructions.add(new Branch.BinaryBranch(instLoc, ((Instruction22t)inst).getTargetAddressOffset(), + instructions.add(new Branch.BinaryBranch(instLoc, ((Instruction22t)inst).getCodeOffset(), Branch.BinaryBranch.CompareOp.LT, ((Instruction22t)inst).getRegisterA(), - ((Instruction22t)inst).getRegisterB(), inst.opcode, this)); + ((Instruction22t)inst).getRegisterB(), inst.getOpcode(), this)); break; case IF_GE: - instructions.add(new Branch.BinaryBranch(instLoc, ((Instruction22t)inst).getTargetAddressOffset(), + instructions.add(new Branch.BinaryBranch(instLoc, ((Instruction22t)inst).getCodeOffset(), Branch.BinaryBranch.CompareOp.GE, ((Instruction22t)inst).getRegisterA(), - ((Instruction22t)inst).getRegisterB(), inst.opcode, this)); + ((Instruction22t)inst).getRegisterB(), inst.getOpcode(), this)); break; case IF_GT: - instructions.add(new Branch.BinaryBranch(instLoc, ((Instruction22t)inst).getTargetAddressOffset(), + instructions.add(new Branch.BinaryBranch(instLoc, ((Instruction22t)inst).getCodeOffset(), Branch.BinaryBranch.CompareOp.GT, ((Instruction22t)inst).getRegisterA(), - ((Instruction22t)inst).getRegisterB(), inst.opcode, this)); + ((Instruction22t)inst).getRegisterB(), inst.getOpcode(), this)); break; case IF_LE: - instructions.add(new Branch.BinaryBranch(instLoc, ((Instruction22t)inst).getTargetAddressOffset(), + instructions.add(new Branch.BinaryBranch(instLoc, ((Instruction22t)inst).getCodeOffset(), Branch.BinaryBranch.CompareOp.LE, ((Instruction22t)inst).getRegisterA(), - ((Instruction22t)inst).getRegisterB(), inst.opcode, this)); + ((Instruction22t)inst).getRegisterB(), inst.getOpcode(), this)); break; case IF_EQZ: instructions.add(new Branch.UnaryBranch(instLoc, - ((Instruction21t)inst).getTargetAddressOffset(), Branch.UnaryBranch.CompareOp.EQZ, - ((Instruction21t)inst).getRegisterA(), inst.opcode, this)); + ((Instruction21t)inst).getCodeOffset(), Branch.UnaryBranch.CompareOp.EQZ, + ((Instruction21t)inst).getRegisterA(), inst.getOpcode(), this)); break; case IF_NEZ: instructions.add(new Branch.UnaryBranch(instLoc, - ((Instruction21t)inst).getTargetAddressOffset(), Branch.UnaryBranch.CompareOp.NEZ, - ((Instruction21t)inst).getRegisterA(), inst.opcode, this)); + ((Instruction21t)inst).getCodeOffset(), Branch.UnaryBranch.CompareOp.NEZ, + ((Instruction21t)inst).getRegisterA(), inst.getOpcode(), this)); break; case IF_LTZ: instructions.add(new Branch.UnaryBranch(instLoc, - ((Instruction21t)inst).getTargetAddressOffset(), Branch.UnaryBranch.CompareOp.LTZ, - ((Instruction21t)inst).getRegisterA(), inst.opcode, this)); + ((Instruction21t)inst).getCodeOffset(), Branch.UnaryBranch.CompareOp.LTZ, + ((Instruction21t)inst).getRegisterA(), inst.getOpcode(), this)); break; case IF_GEZ: instructions.add(new Branch.UnaryBranch(instLoc, - ((Instruction21t)inst).getTargetAddressOffset(), Branch.UnaryBranch.CompareOp.GEZ, - ((Instruction21t)inst).getRegisterA(), inst.opcode, this)); + ((Instruction21t)inst).getCodeOffset(), Branch.UnaryBranch.CompareOp.GEZ, + ((Instruction21t)inst).getRegisterA(), inst.getOpcode(), this)); break; case IF_GTZ: instructions.add(new Branch.UnaryBranch(instLoc, - ((Instruction21t)inst).getTargetAddressOffset(), Branch.UnaryBranch.CompareOp.GTZ, - ((Instruction21t)inst).getRegisterA(), inst.opcode, this)); + ((Instruction21t)inst).getCodeOffset(), Branch.UnaryBranch.CompareOp.GTZ, + ((Instruction21t)inst).getRegisterA(), inst.getOpcode(), this)); break; case IF_LEZ: instructions.add(new Branch.UnaryBranch(instLoc, - ((Instruction21t)inst).getTargetAddressOffset(), Branch.UnaryBranch.CompareOp.LEZ, - ((Instruction21t)inst).getRegisterA(), inst.opcode, this)); + ((Instruction21t)inst).getCodeOffset(), Branch.UnaryBranch.CompareOp.LEZ, + ((Instruction21t)inst).getRegisterA(), inst.getOpcode(), this)); break; case AGET: instructions.add(new ArrayGet(instLoc, ((Instruction23x)inst).getRegisterA(), - ((Instruction23x)inst).getRegisterB(), ((Instruction23x)inst).getRegisterC(), Type.t_int, inst.opcode, this)); + ((Instruction23x)inst).getRegisterB(), ((Instruction23x)inst).getRegisterC(), Type.t_int, inst.getOpcode(), this)); break; case AGET_WIDE: instructions.add(new ArrayGet(instLoc, ((Instruction23x)inst).getRegisterA(), - ((Instruction23x)inst).getRegisterB(), ((Instruction23x)inst).getRegisterC(), Type.t_wide, inst.opcode, this)); + ((Instruction23x)inst).getRegisterB(), ((Instruction23x)inst).getRegisterC(), Type.t_wide, inst.getOpcode(), this)); break; case AGET_OBJECT: instructions.add(new ArrayGet(instLoc, ((Instruction23x)inst).getRegisterA(), - ((Instruction23x)inst).getRegisterB(), ((Instruction23x)inst).getRegisterC(), Type.t_object, inst.opcode, this)); + ((Instruction23x)inst).getRegisterB(), ((Instruction23x)inst).getRegisterC(), Type.t_object, inst.getOpcode(), this)); break; case AGET_BOOLEAN: instructions.add(new ArrayGet(instLoc, ((Instruction23x)inst).getRegisterA(), - ((Instruction23x)inst).getRegisterB(), ((Instruction23x)inst).getRegisterC(), Type.t_boolean, inst.opcode, this)); + ((Instruction23x)inst).getRegisterB(), ((Instruction23x)inst).getRegisterC(), Type.t_boolean, inst.getOpcode(), this)); break; case AGET_BYTE: instructions.add(new ArrayGet(instLoc, ((Instruction23x)inst).getRegisterA(), - ((Instruction23x)inst).getRegisterB(), ((Instruction23x)inst).getRegisterC(), Type.t_byte, inst.opcode, this)); + ((Instruction23x)inst).getRegisterB(), ((Instruction23x)inst).getRegisterC(), Type.t_byte, inst.getOpcode(), this)); break; case AGET_CHAR: instructions.add(new ArrayGet(instLoc, ((Instruction23x)inst).getRegisterA(), - ((Instruction23x)inst).getRegisterB(), ((Instruction23x)inst).getRegisterC(), Type.t_char, inst.opcode, this)); + ((Instruction23x)inst).getRegisterB(), ((Instruction23x)inst).getRegisterC(), Type.t_char, inst.getOpcode(), this)); break; case AGET_SHORT: instructions.add(new ArrayGet(instLoc, ((Instruction23x)inst).getRegisterA(), - ((Instruction23x)inst).getRegisterB(), ((Instruction23x)inst).getRegisterC(), Type.t_short, inst.opcode, this)); + ((Instruction23x)inst).getRegisterB(), ((Instruction23x)inst).getRegisterC(), Type.t_short, inst.getOpcode(), this)); break; case APUT: instructions.add(new ArrayPut(instLoc, ((Instruction23x)inst).getRegisterA(), - ((Instruction23x)inst).getRegisterB(), ((Instruction23x)inst).getRegisterC(), Type.t_int, inst.opcode, this)); + ((Instruction23x)inst).getRegisterB(), ((Instruction23x)inst).getRegisterC(), Type.t_int, inst.getOpcode(), this)); break; case APUT_WIDE: instructions.add(new ArrayPut(instLoc, ((Instruction23x)inst).getRegisterA(), - ((Instruction23x)inst).getRegisterB(), ((Instruction23x)inst).getRegisterC(), Type.t_wide, inst.opcode, this)); + ((Instruction23x)inst).getRegisterB(), ((Instruction23x)inst).getRegisterC(), Type.t_wide, inst.getOpcode(), this)); break; case APUT_OBJECT: instructions.add(new ArrayPut(instLoc, ((Instruction23x)inst).getRegisterA(), - ((Instruction23x)inst).getRegisterB(), ((Instruction23x)inst).getRegisterC(), Type.t_object, inst.opcode, this)); + ((Instruction23x)inst).getRegisterB(), ((Instruction23x)inst).getRegisterC(), Type.t_object, inst.getOpcode(), this)); break; case APUT_BOOLEAN: instructions.add(new ArrayPut(instLoc, ((Instruction23x)inst).getRegisterA(), - ((Instruction23x)inst).getRegisterB(), ((Instruction23x)inst).getRegisterC(), Type.t_boolean, inst.opcode, this)); + ((Instruction23x)inst).getRegisterB(), ((Instruction23x)inst).getRegisterC(), Type.t_boolean, inst.getOpcode(), this)); break; case APUT_BYTE: instructions.add(new ArrayPut(instLoc, ((Instruction23x)inst).getRegisterA(), - ((Instruction23x)inst).getRegisterB(), ((Instruction23x)inst).getRegisterC(), Type.t_byte, inst.opcode, this)); + ((Instruction23x)inst).getRegisterB(), ((Instruction23x)inst).getRegisterC(), Type.t_byte, inst.getOpcode(), this)); break; case APUT_CHAR: instructions.add(new ArrayPut(instLoc, ((Instruction23x)inst).getRegisterA(), - ((Instruction23x)inst).getRegisterB(), ((Instruction23x)inst).getRegisterC(), Type.t_char, inst.opcode, this)); + ((Instruction23x)inst).getRegisterB(), ((Instruction23x)inst).getRegisterC(), Type.t_char, inst.getOpcode(), this)); break; case APUT_SHORT: instructions.add(new ArrayPut(instLoc, ((Instruction23x)inst).getRegisterA(), - ((Instruction23x)inst).getRegisterB(), ((Instruction23x)inst).getRegisterC(), Type.t_short, inst.opcode, this)); + ((Instruction23x)inst).getRegisterB(), ((Instruction23x)inst).getRegisterC(), Type.t_short, inst.getOpcode(), this)); break; case IGET: case IGET_WIDE: @@ -1379,9 +1371,9 @@ public class DexIMethod implements IBytecodeMethod { case IGET_BYTE: case IGET_CHAR: case IGET_SHORT: { - String cname = ((FieldIdItem)((Instruction22c)inst).getReferencedItem()).getContainingClass().getTypeDescriptor(); - String fname = ((FieldIdItem)((Instruction22c)inst).getReferencedItem()).getFieldName().getStringValue(); - String ftname = ((FieldIdItem)((Instruction22c)inst).getReferencedItem()).getFieldType().getTypeDescriptor(); + String cname = ((FieldReference)((Instruction22c)inst).getReference()).getDefiningClass(); + String fname = ((FieldReference)((Instruction22c)inst).getReference()).getName(); + String ftname = ((FieldReference)((Instruction22c)inst).getReference()).getType(); if (cname.endsWith(";")) cname = cname.substring(0,cname.length()-1); @@ -1392,7 +1384,7 @@ public class DexIMethod implements IBytecodeMethod { instructions.add(new GetField.GetInstanceField( instLoc, ((Instruction22c)inst).getRegisterA(), ((Instruction22c)inst).getRegisterB(), - cname, fname, ftname, inst.opcode, this)); + cname, fname, ftname, inst.getOpcode(), this)); break; } case IPUT: @@ -1402,9 +1394,9 @@ public class DexIMethod implements IBytecodeMethod { case IPUT_BYTE: case IPUT_CHAR: case IPUT_SHORT: { - String cname = ((FieldIdItem)((InstructionWithReference)inst).getReferencedItem()).getContainingClass().getTypeDescriptor(); - String fname = ((FieldIdItem)((InstructionWithReference)inst).getReferencedItem()).getFieldName().getStringValue(); - String ftname = ((FieldIdItem)((InstructionWithReference)inst).getReferencedItem()).getFieldType().getTypeDescriptor(); + String cname = ((FieldReference)((Instruction22c)inst).getReference()).getDefiningClass(); + String fname = ((FieldReference)((Instruction22c)inst).getReference()).getName(); + String ftname = ((FieldReference)((Instruction22c)inst).getReference()).getType(); if (cname.endsWith(";")) cname = cname.substring(0,cname.length()-1); @@ -1415,7 +1407,7 @@ public class DexIMethod implements IBytecodeMethod { instructions.add(new PutField.PutInstanceField( instLoc, ((TwoRegisterInstruction)inst).getRegisterA(), ((TwoRegisterInstruction)inst).getRegisterB(), - cname, fname, ftname, inst.opcode, this)); + cname, fname, ftname, inst.getOpcode(), this)); break; } case SGET: @@ -1425,9 +1417,9 @@ public class DexIMethod implements IBytecodeMethod { case SGET_BYTE: case SGET_CHAR: case SGET_SHORT: { - String cname = ((FieldIdItem)((Instruction21c)inst).getReferencedItem()).getContainingClass().getTypeDescriptor(); - String fname = ((FieldIdItem)((Instruction21c)inst).getReferencedItem()).getFieldName().getStringValue(); - String ftname = ((FieldIdItem)((Instruction21c)inst).getReferencedItem()).getFieldType().getTypeDescriptor(); + String cname = ((FieldReference)((Instruction21c)inst).getReference()).getDefiningClass(); + String fname = ((FieldReference)((Instruction21c)inst).getReference()).getName(); + String ftname = ((FieldReference)((Instruction21c)inst).getReference()).getType(); if (cname.endsWith(";")) cname = cname.substring(0,cname.length()-1); @@ -1437,7 +1429,7 @@ public class DexIMethod implements IBytecodeMethod { ftname = ftname.substring(0,ftname.length()-1); instructions.add(new GetField.GetStaticField(instLoc, - ((Instruction21c)inst).getRegisterA(), cname, fname, ftname, inst.opcode, this)); + ((Instruction21c)inst).getRegisterA(), cname, fname, ftname, inst.getOpcode(), this)); break; } case SPUT: @@ -1447,9 +1439,9 @@ public class DexIMethod implements IBytecodeMethod { case SPUT_BYTE: case SPUT_CHAR: case SPUT_SHORT: { - String cname = ((FieldIdItem)((Instruction21c)inst).getReferencedItem()).getContainingClass().getTypeDescriptor(); - String fname = ((FieldIdItem)((Instruction21c)inst).getReferencedItem()).getFieldName().getStringValue(); - String ftname = ((FieldIdItem)((Instruction21c)inst).getReferencedItem()).getFieldType().getTypeDescriptor(); + String cname = ((FieldReference)((Instruction21c)inst).getReference()).getDefiningClass(); + String fname = ((FieldReference)((Instruction21c)inst).getReference()).getName(); + String ftname = ((FieldReference)((Instruction21c)inst).getReference()).getType(); if (cname.endsWith(";")) cname = cname.substring(0,cname.length()-1); @@ -1459,30 +1451,30 @@ public class DexIMethod implements IBytecodeMethod { ftname = ftname.substring(0,ftname.length()-1); instructions.add(new PutField.PutStaticField(instLoc, - ((Instruction21c)inst).getRegisterA(), cname, fname, ftname, inst.opcode, this)); + ((Instruction21c)inst).getRegisterA(), cname, fname, ftname, inst.getOpcode(), this)); break; } case INVOKE_VIRTUAL: { - int registerCount = ((Instruction35c)inst).getRegCount(); + int registerCount = ((Instruction35c)inst).getRegisterCount(); int[] args = new int[registerCount]; for (int i = 0; i < registerCount; i++) { switch(i) { case 0: - args[0] = ((Instruction35c)inst).getRegisterD(); + args[0] = ((Instruction35c)inst).getRegisterC(); break; case 1: - args[1] = ((Instruction35c)inst).getRegisterE(); + args[1] = ((Instruction35c)inst).getRegisterD(); break; case 2: - args[2] = ((Instruction35c)inst).getRegisterF(); + args[2] = ((Instruction35c)inst).getRegisterE(); break; case 3: - args[3] = ((Instruction35c)inst).getRegisterG(); + args[3] = ((Instruction35c)inst).getRegisterF(); break; case 4: - args[4] = ((Instruction35c)inst).getRegisterA(); + args[4] = ((Instruction35c)inst).getRegisterG(); break; default: throw new RuntimeException("Illegal instruction at " @@ -1490,9 +1482,9 @@ public class DexIMethod implements IBytecodeMethod { } } - String cname = ((MethodIdItem)((Instruction35c)inst).getReferencedItem()).getContainingClass().getTypeDescriptor(); - String mname = ((MethodIdItem)((Instruction35c)inst).getReferencedItem()).getMethodName().getStringValue(); - String pname = ((MethodIdItem)((Instruction35c)inst).getReferencedItem()).getPrototype().getPrototypeString(); + String cname = ((org.jf.dexlib2.iface.reference.MethodReference)((Instruction35c)inst).getReference()).getDefiningClass(); + String mname = ((org.jf.dexlib2.iface.reference.MethodReference)((Instruction35c)inst).getReference()).getName(); + String pname = DexUtil.getSignature((org.jf.dexlib2.iface.reference.MethodReference)((Instruction35c)inst).getReference()); if (cname.endsWith(";")) cname = cname.substring(0,cname.length()-1); @@ -1504,33 +1496,33 @@ public class DexIMethod implements IBytecodeMethod { // for (IMethod m: this.myClass.loader.lookupClass(TypeName.findOrCreate(cname)).getDeclaredMethods()) // System.out.println(m.getDescriptor().toString()); - handleINVOKE_VIRTUAL(instLoc, cname, mname, pname, args, inst.opcode); + handleINVOKE_VIRTUAL(instLoc, cname, mname, pname, args, inst.getOpcode()); //instructions.add(new Invoke.InvokeVirtual(instLoc, cname, mname, pname, args, inst.opcode, this)); //logger.debug("\t" + inst.opcode.toString() + " class: "+ cname + ", method name: " + mname + ", prototype string: " + pname); break; } case INVOKE_SUPER: { - int registerCount = ((Instruction35c)inst).getRegCount(); + int registerCount = ((Instruction35c)inst).getRegisterCount(); int[] args = new int[registerCount]; for (int i = 0; i < registerCount; i++) { switch(i) { case 0: - args[0] = ((Instruction35c)inst).getRegisterD(); + args[0] = ((Instruction35c)inst).getRegisterC(); break; case 1: - args[1] = ((Instruction35c)inst).getRegisterE(); + args[1] = ((Instruction35c)inst).getRegisterD(); break; case 2: - args[2] = ((Instruction35c)inst).getRegisterF(); + args[2] = ((Instruction35c)inst).getRegisterE(); break; case 3: - args[3] = ((Instruction35c)inst).getRegisterG(); + args[3] = ((Instruction35c)inst).getRegisterF(); break; case 4: - args[4] = ((Instruction35c)inst).getRegisterA(); + args[4] = ((Instruction35c)inst).getRegisterG(); break; default: throw new RuntimeException("Illegal instruction at " @@ -1538,39 +1530,39 @@ public class DexIMethod implements IBytecodeMethod { } } - String cname = ((MethodIdItem)((Instruction35c)inst).getReferencedItem()).getContainingClass().getTypeDescriptor(); - String mname = ((MethodIdItem)((Instruction35c)inst).getReferencedItem()).getMethodName().getStringValue(); - String pname = ((MethodIdItem)((Instruction35c)inst).getReferencedItem()).getPrototype().getPrototypeString(); + String cname = ((org.jf.dexlib2.iface.reference.MethodReference)((Instruction35c)inst).getReference()).getDefiningClass(); + String mname = ((org.jf.dexlib2.iface.reference.MethodReference)((Instruction35c)inst).getReference()).getName(); + String pname = DexUtil.getSignature((org.jf.dexlib2.iface.reference.MethodReference)((Instruction35c)inst).getReference()); if (cname.endsWith(";")) cname = cname.substring(0,cname.length()-1); instructions.add(new Invoke.InvokeSuper(instLoc, - cname, mname, pname, args, inst.opcode, this)); + cname, mname, pname, args, inst.getOpcode(), this)); break; } case INVOKE_DIRECT: { - int registerCount = ((Instruction35c)inst).getRegCount(); + int registerCount = ((Instruction35c)inst).getRegisterCount(); int[] args = new int[registerCount]; for (int i = 0; i < registerCount; i++) { switch(i) { case 0: - args[0] = ((Instruction35c)inst).getRegisterD(); + args[0] = ((Instruction35c)inst).getRegisterC(); break; case 1: - args[1] = ((Instruction35c)inst).getRegisterE(); + args[1] = ((Instruction35c)inst).getRegisterD(); break; case 2: - args[2] = ((Instruction35c)inst).getRegisterF(); + args[2] = ((Instruction35c)inst).getRegisterE(); break; case 3: - args[3] = ((Instruction35c)inst).getRegisterG(); + args[3] = ((Instruction35c)inst).getRegisterF(); break; case 4: - args[4] = ((Instruction35c)inst).getRegisterA(); + args[4] = ((Instruction35c)inst).getRegisterG(); break; default: throw new RuntimeException("Illegal instruction at " @@ -1579,40 +1571,40 @@ public class DexIMethod implements IBytecodeMethod { } // logger.debug(inst.opcode.toString() + " class: "+((MethodIdItem)((Instruction35c)inst).getReferencedItem()).getContainingClass().getTypeDescriptor() + ", method name: " + ((MethodIdItem)((Instruction35c)inst).getReferencedItem()).getMethodName().getStringValue() + ", prototype string: " + ((MethodIdItem)((Instruction35c)inst).getReferencedItem()).getPrototype().getPrototypeString()); - String cname = ((MethodIdItem)((Instruction35c)inst).getReferencedItem()).getContainingClass().getTypeDescriptor(); - String mname = ((MethodIdItem)((Instruction35c)inst).getReferencedItem()).getMethodName().getStringValue(); - String pname = ((MethodIdItem)((Instruction35c)inst).getReferencedItem()).getPrototype().getPrototypeString(); + String cname = ((org.jf.dexlib2.iface.reference.MethodReference)((Instruction35c)inst).getReference()).getDefiningClass(); + String mname = ((org.jf.dexlib2.iface.reference.MethodReference)((Instruction35c)inst).getReference()).getName(); + String pname = DexUtil.getSignature((org.jf.dexlib2.iface.reference.MethodReference)((Instruction35c)inst).getReference()); if (cname.endsWith(";")) cname = cname.substring(0,cname.length()-1); instructions.add(new Invoke.InvokeDirect(instLoc, - cname, mname, pname, args, inst.opcode, this)); + cname, mname, pname, args, inst.getOpcode(), this)); break; } case INVOKE_STATIC: { - int registerCount = ((Instruction35c)inst).getRegCount(); + int registerCount = ((Instruction35c)inst).getRegisterCount(); int[] args = new int[registerCount]; for (int i = 0; i < registerCount; i++) { switch(i) { case 0: - args[0] = ((Instruction35c)inst).getRegisterD(); + args[0] = ((Instruction35c)inst).getRegisterC(); break; case 1: - args[1] = ((Instruction35c)inst).getRegisterE(); + args[1] = ((Instruction35c)inst).getRegisterD(); break; case 2: - args[2] = ((Instruction35c)inst).getRegisterF(); + args[2] = ((Instruction35c)inst).getRegisterE(); break; case 3: - args[3] = ((Instruction35c)inst).getRegisterG(); + args[3] = ((Instruction35c)inst).getRegisterF(); break; case 4: - args[4] = ((Instruction35c)inst).getRegisterA(); + args[4] = ((Instruction35c)inst).getRegisterG(); break; default: throw new RuntimeException("Illegal instruction at " @@ -1621,40 +1613,40 @@ public class DexIMethod implements IBytecodeMethod { } //logger.debug(inst.opcode.toString() + " class: "+((MethodIdItem)((Instruction35c)inst).getReferencedItem()).getContainingClass().getTypeDescriptor() + ", method name: " + ((MethodIdItem)((Instruction35c)inst).getReferencedItem()).getMethodName().getStringValue() + ", prototype string: " + ((MethodIdItem)((Instruction35c)inst).getReferencedItem()).getPrototype().getPrototypeString()); - String cname = ((MethodIdItem)((Instruction35c)inst).getReferencedItem()).getContainingClass().getTypeDescriptor(); - String mname = ((MethodIdItem)((Instruction35c)inst).getReferencedItem()).getMethodName().getStringValue(); - String pname = ((MethodIdItem)((Instruction35c)inst).getReferencedItem()).getPrototype().getPrototypeString(); + String cname = ((org.jf.dexlib2.iface.reference.MethodReference)((Instruction35c)inst).getReference()).getDefiningClass(); + String mname = ((org.jf.dexlib2.iface.reference.MethodReference)((Instruction35c)inst).getReference()).getName(); + String pname = DexUtil.getSignature((org.jf.dexlib2.iface.reference.MethodReference)((Instruction35c)inst).getReference()); if (cname.endsWith(";")) cname = cname.substring(0,cname.length()-1); - instructions.add(new Invoke.InvokeStatic(instLoc, cname, mname, pname, args, inst.opcode, this)); + instructions.add(new Invoke.InvokeStatic(instLoc, cname, mname, pname, args, inst.getOpcode(), this)); break; } case INVOKE_INTERFACE: { - int registerCount = ((Instruction35c)inst).getRegCount(); + int registerCount = ((Instruction35c)inst).getRegisterCount(); int[] args = new int[registerCount]; for (int i = 0; i < registerCount; i++) { switch(i) { case 0: - args[0] = ((Instruction35c)inst).getRegisterD(); + args[0] = ((Instruction35c)inst).getRegisterC(); break; case 1: - args[1] = ((Instruction35c)inst).getRegisterE(); + args[1] = ((Instruction35c)inst).getRegisterD(); break; case 2: - args[2] = ((Instruction35c)inst).getRegisterF(); + args[2] = ((Instruction35c)inst).getRegisterE(); break; case 3: - args[3] = ((Instruction35c)inst).getRegisterG(); + args[3] = ((Instruction35c)inst).getRegisterF(); break; case 4: - args[4] = ((Instruction35c)inst).getRegisterA(); + args[4] = ((Instruction35c)inst).getRegisterG(); break; default: throw new RuntimeException("Illegal instruction at " @@ -1662,634 +1654,634 @@ public class DexIMethod implements IBytecodeMethod { } } - String cname = ((MethodIdItem)((Instruction35c)inst).getReferencedItem()).getContainingClass().getTypeDescriptor(); - String mname = ((MethodIdItem)((Instruction35c)inst).getReferencedItem()).getMethodName().getStringValue(); - String pname = ((MethodIdItem)((Instruction35c)inst).getReferencedItem()).getPrototype().getPrototypeString(); + String cname = ((org.jf.dexlib2.iface.reference.MethodReference)((Instruction35c)inst).getReference()).getDefiningClass(); + String mname = ((org.jf.dexlib2.iface.reference.MethodReference)((Instruction35c)inst).getReference()).getName(); + String pname = DexUtil.getSignature((org.jf.dexlib2.iface.reference.MethodReference)((Instruction35c)inst).getReference()); if (cname.endsWith(";")) cname = cname.substring(0,cname.length()-1); instructions.add(new Invoke.InvokeInterface(instLoc, - cname, mname, pname, args, inst.opcode, this)); + cname, mname, pname, args, inst.getOpcode(), this)); break; } case INVOKE_VIRTUAL_RANGE: { - int registerCount = ((Instruction3rc)inst).getRegCount(); + int registerCount = ((Instruction3rc)inst).getRegisterCount(); int[] args = new int[registerCount]; for (int i = 0; i < registerCount; i++) args[i] = ((Instruction3rc)inst).getStartRegister() + i; - String cname = ((MethodIdItem)((Instruction3rc)inst).getReferencedItem()).getContainingClass().getTypeDescriptor(); - String mname = ((MethodIdItem)((Instruction3rc)inst).getReferencedItem()).getMethodName().getStringValue(); - String pname = ((MethodIdItem)((Instruction3rc)inst).getReferencedItem()).getPrototype().getPrototypeString(); + String cname = ((org.jf.dexlib2.iface.reference.MethodReference)((Instruction3rc)inst).getReference()).getDefiningClass(); + String mname = ((org.jf.dexlib2.iface.reference.MethodReference)((Instruction3rc)inst).getReference()).getName(); + String pname = DexUtil.getSignature((org.jf.dexlib2.iface.reference.MethodReference)((Instruction3rc)inst).getReference()); if (cname.endsWith(";")) cname = cname.substring(0,cname.length()-1); instructions.add(new Invoke.InvokeVirtual(instLoc, - cname, mname, pname, args, inst.opcode, this)); + cname, mname, pname, args, inst.getOpcode(), this)); break; } case INVOKE_SUPER_RANGE: { - int registerCount = ((Instruction3rc)inst).getRegCount(); + int registerCount = ((Instruction3rc)inst).getRegisterCount(); int[] args = new int[registerCount]; for (int i = 0; i < registerCount; i++) args[i] = ((Instruction3rc)inst).getStartRegister() + i; - String cname = ((MethodIdItem)((Instruction3rc)inst).getReferencedItem()).getContainingClass().getTypeDescriptor(); - String mname = ((MethodIdItem)((Instruction3rc)inst).getReferencedItem()).getMethodName().getStringValue(); - String pname = ((MethodIdItem)((Instruction3rc)inst).getReferencedItem()).getPrototype().getPrototypeString(); + String cname = ((org.jf.dexlib2.iface.reference.MethodReference)((Instruction3rc)inst).getReference()).getDefiningClass(); + String mname = ((org.jf.dexlib2.iface.reference.MethodReference)((Instruction3rc)inst).getReference()).getName(); + String pname = ((org.jf.dexlib2.iface.reference.MethodReference)((Instruction3rc)inst).getReference()).getReturnType(); if (cname.endsWith(";")) cname = cname.substring(0,cname.length()-1); instructions.add(new Invoke.InvokeSuper(instLoc, - cname, mname, pname, args, inst.opcode, this)); + cname, mname, pname, args, inst.getOpcode(), this)); break; } case INVOKE_DIRECT_RANGE: { - int registerCount = ((Instruction3rc)inst).getRegCount(); + int registerCount = ((Instruction3rc)inst).getRegisterCount(); int[] args = new int[registerCount]; for (int i = 0; i < registerCount; i++) args[i] = ((Instruction3rc)inst).getStartRegister() + i; - String cname = ((MethodIdItem)((Instruction3rc)inst).getReferencedItem()).getContainingClass().getTypeDescriptor(); - String mname = ((MethodIdItem)((Instruction3rc)inst).getReferencedItem()).getMethodName().getStringValue(); - String pname = ((MethodIdItem)((Instruction3rc)inst).getReferencedItem()).getPrototype().getPrototypeString(); + String cname = ((org.jf.dexlib2.iface.reference.MethodReference)((Instruction3rc)inst).getReference()).getDefiningClass(); + String mname = ((org.jf.dexlib2.iface.reference.MethodReference)((Instruction3rc)inst).getReference()).getName(); + String pname = DexUtil.getSignature((org.jf.dexlib2.iface.reference.MethodReference)((Instruction3rc)inst).getReference()); if (cname.endsWith(";")) cname = cname.substring(0,cname.length()-1); instructions.add(new Invoke.InvokeDirect(instLoc, - cname, mname, pname, args, inst.opcode, this)); + cname, mname, pname, args, inst.getOpcode(), this)); break; } case INVOKE_STATIC_RANGE: { - int registerCount = ((Instruction3rc)inst).getRegCount(); + int registerCount = ((Instruction3rc)inst).getRegisterCount(); int[] args = new int[registerCount]; for (int i = 0; i < registerCount; i++) args[i] = ((Instruction3rc)inst).getStartRegister() + i; - String cname = ((MethodIdItem)((Instruction3rc)inst).getReferencedItem()).getContainingClass().getTypeDescriptor(); - String mname = ((MethodIdItem)((Instruction3rc)inst).getReferencedItem()).getMethodName().getStringValue(); - String pname = ((MethodIdItem)((Instruction3rc)inst).getReferencedItem()).getPrototype().getPrototypeString(); + String cname = ((org.jf.dexlib2.iface.reference.MethodReference)((Instruction3rc)inst).getReference()).getDefiningClass(); + String mname = ((org.jf.dexlib2.iface.reference.MethodReference)((Instruction3rc)inst).getReference()).getName(); + String pname = DexUtil.getSignature((org.jf.dexlib2.iface.reference.MethodReference)((Instruction3rc)inst).getReference()); if (cname.endsWith(";")) cname = cname.substring(0,cname.length()-1); - instructions.add(new Invoke.InvokeStatic(instLoc, cname, mname, pname, args, inst.opcode, this)); + instructions.add(new Invoke.InvokeStatic(instLoc, cname, mname, pname, args, inst.getOpcode(), this)); break; } case INVOKE_INTERFACE_RANGE: { - int registerCount = ((Instruction3rc)inst).getRegCount(); + int registerCount = ((Instruction3rc)inst).getRegisterCount(); int[] args = new int[registerCount]; for (int i = 0; i < registerCount; i++) args[i] = ((Instruction3rc)inst).getStartRegister() + i; - String cname = ((MethodIdItem)((Instruction3rc)inst).getReferencedItem()).getContainingClass().getTypeDescriptor(); - String mname = ((MethodIdItem)((Instruction3rc)inst).getReferencedItem()).getMethodName().getStringValue(); - String pname = ((MethodIdItem)((Instruction3rc)inst).getReferencedItem()).getPrototype().getPrototypeString(); + String cname = ((org.jf.dexlib2.iface.reference.MethodReference)((Instruction3rc)inst).getReference()).getDefiningClass(); + String mname = ((org.jf.dexlib2.iface.reference.MethodReference)((Instruction3rc)inst).getReference()).getName(); + String pname = DexUtil.getSignature((org.jf.dexlib2.iface.reference.MethodReference)((Instruction3rc)inst).getReference()); if (cname.endsWith(";")) cname = cname.substring(0,cname.length()-1); instructions.add(new Invoke.InvokeInterface(instLoc, - cname, mname, pname, args, inst.opcode, this)); + cname, mname, pname, args, inst.getOpcode(), this)); break; } case NEG_INT: instructions.add(new UnaryOperation(instLoc, - OpID.NEGINT, ((Instruction12x)inst).getRegisterA(), ((Instruction12x)inst).getRegisterB(), inst.opcode, this)); + OpID.NEGINT, ((Instruction12x)inst).getRegisterA(), ((Instruction12x)inst).getRegisterB(), inst.getOpcode(), this)); break; case NOT_INT: instructions.add(new UnaryOperation(instLoc, - OpID.NOTINT, ((Instruction12x)inst).getRegisterA(), ((Instruction12x)inst).getRegisterB(), inst.opcode, this)); + OpID.NOTINT, ((Instruction12x)inst).getRegisterA(), ((Instruction12x)inst).getRegisterB(), inst.getOpcode(), this)); break; case NEG_LONG: instructions.add(new UnaryOperation(instLoc, - OpID.NEGLONG, ((Instruction12x)inst).getRegisterA(), ((Instruction12x)inst).getRegisterB(), inst.opcode, this)); + OpID.NEGLONG, ((Instruction12x)inst).getRegisterA(), ((Instruction12x)inst).getRegisterB(), inst.getOpcode(), this)); break; case NOT_LONG: instructions.add(new UnaryOperation(instLoc, - OpID.NOTLONG, ((Instruction12x)inst).getRegisterA(), ((Instruction12x)inst).getRegisterB(), inst.opcode, this)); + OpID.NOTLONG, ((Instruction12x)inst).getRegisterA(), ((Instruction12x)inst).getRegisterB(), inst.getOpcode(), this)); break; case NEG_FLOAT: instructions.add(new UnaryOperation(instLoc, - OpID.NEGFLOAT, ((Instruction12x)inst).getRegisterA(), ((Instruction12x)inst).getRegisterB(), inst.opcode, this)); + OpID.NEGFLOAT, ((Instruction12x)inst).getRegisterA(), ((Instruction12x)inst).getRegisterB(), inst.getOpcode(), this)); break; case NEG_DOUBLE: instructions.add(new UnaryOperation(instLoc, - OpID.NEGDOUBLE, ((Instruction12x)inst).getRegisterA(), ((Instruction12x)inst).getRegisterB(), inst.opcode, this)); + OpID.NEGDOUBLE, ((Instruction12x)inst).getRegisterA(), ((Instruction12x)inst).getRegisterB(), inst.getOpcode(), this)); break; case INT_TO_LONG: instructions.add(new UnaryOperation(instLoc, - OpID.INTTOLONG, ((Instruction12x)inst).getRegisterA(), ((Instruction12x)inst).getRegisterB(), inst.opcode, this)); + OpID.INTTOLONG, ((Instruction12x)inst).getRegisterA(), ((Instruction12x)inst).getRegisterB(), inst.getOpcode(), this)); break; case INT_TO_FLOAT: instructions.add(new UnaryOperation(instLoc, - OpID.INTTOFLOAT, ((Instruction12x)inst).getRegisterA(), ((Instruction12x)inst).getRegisterB(), inst.opcode, this)); + OpID.INTTOFLOAT, ((Instruction12x)inst).getRegisterA(), ((Instruction12x)inst).getRegisterB(), inst.getOpcode(), this)); break; case INT_TO_DOUBLE: instructions.add(new UnaryOperation(instLoc, - OpID.INTTODOUBLE, ((Instruction12x)inst).getRegisterA(), ((Instruction12x)inst).getRegisterB(), inst.opcode, this)); + OpID.INTTODOUBLE, ((Instruction12x)inst).getRegisterA(), ((Instruction12x)inst).getRegisterB(), inst.getOpcode(), this)); break; case LONG_TO_INT: instructions.add(new UnaryOperation(instLoc, - OpID.LONGTOINT, ((Instruction12x)inst).getRegisterA(), ((Instruction12x)inst).getRegisterB(), inst.opcode, this)); + OpID.LONGTOINT, ((Instruction12x)inst).getRegisterA(), ((Instruction12x)inst).getRegisterB(), inst.getOpcode(), this)); break; case LONG_TO_FLOAT: instructions.add(new UnaryOperation(instLoc, - OpID.LONGTOFLOAT, ((Instruction12x)inst).getRegisterA(), ((Instruction12x)inst).getRegisterB(), inst.opcode, this)); + OpID.LONGTOFLOAT, ((Instruction12x)inst).getRegisterA(), ((Instruction12x)inst).getRegisterB(), inst.getOpcode(), this)); break; case LONG_TO_DOUBLE: instructions.add(new UnaryOperation(instLoc, - OpID.LONGTODOUBLE, ((Instruction12x)inst).getRegisterA(), ((Instruction12x)inst).getRegisterB(), inst.opcode, this)); + OpID.LONGTODOUBLE, ((Instruction12x)inst).getRegisterA(), ((Instruction12x)inst).getRegisterB(), inst.getOpcode(), this)); break; case FLOAT_TO_INT: instructions.add(new UnaryOperation(instLoc, - OpID.FLOATTOINT, ((Instruction12x)inst).getRegisterA(), ((Instruction12x)inst).getRegisterB(), inst.opcode, this)); + OpID.FLOATTOINT, ((Instruction12x)inst).getRegisterA(), ((Instruction12x)inst).getRegisterB(), inst.getOpcode(), this)); break; case FLOAT_TO_LONG: instructions.add(new UnaryOperation(instLoc, - OpID.FLOATTOLONG, ((Instruction12x)inst).getRegisterA(), ((Instruction12x)inst).getRegisterB(), inst.opcode, this)); + OpID.FLOATTOLONG, ((Instruction12x)inst).getRegisterA(), ((Instruction12x)inst).getRegisterB(), inst.getOpcode(), this)); break; case FLOAT_TO_DOUBLE: instructions.add(new UnaryOperation(instLoc, - OpID.FLOATTODOUBLE, ((Instruction12x)inst).getRegisterA(), ((Instruction12x)inst).getRegisterB(), inst.opcode, this)); + OpID.FLOATTODOUBLE, ((Instruction12x)inst).getRegisterA(), ((Instruction12x)inst).getRegisterB(), inst.getOpcode(), this)); break; case DOUBLE_TO_INT: instructions.add(new UnaryOperation(instLoc, - OpID.DOUBLETOINT, ((Instruction12x)inst).getRegisterA(), ((Instruction12x)inst).getRegisterB(), inst.opcode, this)); + OpID.DOUBLETOINT, ((Instruction12x)inst).getRegisterA(), ((Instruction12x)inst).getRegisterB(), inst.getOpcode(), this)); break; case DOUBLE_TO_LONG: instructions.add(new UnaryOperation(instLoc, - OpID.DOUBLETOLONG, ((Instruction12x)inst).getRegisterA(), ((Instruction12x)inst).getRegisterB(), inst.opcode, this)); + OpID.DOUBLETOLONG, ((Instruction12x)inst).getRegisterA(), ((Instruction12x)inst).getRegisterB(), inst.getOpcode(), this)); break; case DOUBLE_TO_FLOAT: instructions.add(new UnaryOperation(instLoc, - OpID.DOUBLETOFLOAT, ((Instruction12x)inst).getRegisterA(), ((Instruction12x)inst).getRegisterB(), inst.opcode, this)); + OpID.DOUBLETOFLOAT, ((Instruction12x)inst).getRegisterA(), ((Instruction12x)inst).getRegisterB(), inst.getOpcode(), this)); break; case INT_TO_BYTE: instructions.add(new UnaryOperation(instLoc, - OpID.INTTOBYTE, ((Instruction12x)inst).getRegisterA(), ((Instruction12x)inst).getRegisterB(), inst.opcode, this)); + OpID.INTTOBYTE, ((Instruction12x)inst).getRegisterA(), ((Instruction12x)inst).getRegisterB(), inst.getOpcode(), this)); break; case INT_TO_CHAR: instructions.add(new UnaryOperation(instLoc, - OpID.INTTOCHAR, ((Instruction12x)inst).getRegisterA(), ((Instruction12x)inst).getRegisterB(), inst.opcode, this)); + OpID.INTTOCHAR, ((Instruction12x)inst).getRegisterA(), ((Instruction12x)inst).getRegisterB(), inst.getOpcode(), this)); break; case INT_TO_SHORT: instructions.add(new UnaryOperation(instLoc, - OpID.INTTOSHORT, ((Instruction12x)inst).getRegisterA(), ((Instruction12x)inst).getRegisterB(), inst.opcode, this)); + OpID.INTTOSHORT, ((Instruction12x)inst).getRegisterA(), ((Instruction12x)inst).getRegisterB(), inst.getOpcode(), this)); break; case ADD_INT: instructions.add(new BinaryOperation(instLoc, BinaryOperation.OpID.ADD_INT, ((Instruction23x)inst).getRegisterA(), - ((Instruction23x)inst).getRegisterB(),((Instruction23x)inst).getRegisterC(), inst.opcode, this)); + ((Instruction23x)inst).getRegisterB(),((Instruction23x)inst).getRegisterC(), inst.getOpcode(), this)); break; case SUB_INT: instructions.add(new BinaryOperation(instLoc, BinaryOperation.OpID.SUB_INT, ((Instruction23x)inst).getRegisterA(), - ((Instruction23x)inst).getRegisterB(),((Instruction23x)inst).getRegisterC(), inst.opcode, this)); + ((Instruction23x)inst).getRegisterB(),((Instruction23x)inst).getRegisterC(), inst.getOpcode(), this)); break; case MUL_INT: instructions.add(new BinaryOperation(instLoc, BinaryOperation.OpID.MUL_INT, ((Instruction23x)inst).getRegisterA(), - ((Instruction23x)inst).getRegisterB(),((Instruction23x)inst).getRegisterC(), inst.opcode, this)); + ((Instruction23x)inst).getRegisterB(),((Instruction23x)inst).getRegisterC(), inst.getOpcode(), this)); break; case DIV_INT: instructions.add(new BinaryOperation(instLoc, BinaryOperation.OpID.DIV_INT, ((Instruction23x)inst).getRegisterA(), - ((Instruction23x)inst).getRegisterB(),((Instruction23x)inst).getRegisterC(), inst.opcode, this)); + ((Instruction23x)inst).getRegisterB(),((Instruction23x)inst).getRegisterC(), inst.getOpcode(), this)); break; case REM_INT: instructions.add(new BinaryOperation(instLoc, BinaryOperation.OpID.REM_INT, ((Instruction23x)inst).getRegisterA(), - ((Instruction23x)inst).getRegisterB(),((Instruction23x)inst).getRegisterC(), inst.opcode, this)); + ((Instruction23x)inst).getRegisterB(),((Instruction23x)inst).getRegisterC(), inst.getOpcode(), this)); break; case AND_INT: instructions.add(new BinaryOperation(instLoc, BinaryOperation.OpID.AND_INT, ((Instruction23x)inst).getRegisterA(), - ((Instruction23x)inst).getRegisterB(),((Instruction23x)inst).getRegisterC(), inst.opcode, this)); + ((Instruction23x)inst).getRegisterB(),((Instruction23x)inst).getRegisterC(), inst.getOpcode(), this)); break; case OR_INT: instructions.add(new BinaryOperation(instLoc, BinaryOperation.OpID.OR_INT, ((Instruction23x)inst).getRegisterA(), - ((Instruction23x)inst).getRegisterB(),((Instruction23x)inst).getRegisterC(), inst.opcode, this)); + ((Instruction23x)inst).getRegisterB(),((Instruction23x)inst).getRegisterC(), inst.getOpcode(), this)); break; case XOR_INT: instructions.add(new BinaryOperation(instLoc, BinaryOperation.OpID.XOR_INT, ((Instruction23x)inst).getRegisterA(), - ((Instruction23x)inst).getRegisterB(),((Instruction23x)inst).getRegisterC(), inst.opcode, this)); + ((Instruction23x)inst).getRegisterB(),((Instruction23x)inst).getRegisterC(), inst.getOpcode(), this)); break; case SHL_INT: instructions.add(new BinaryOperation(instLoc, BinaryOperation.OpID.SHL_INT, ((Instruction23x)inst).getRegisterA(), - ((Instruction23x)inst).getRegisterB(),((Instruction23x)inst).getRegisterC(), inst.opcode, this)); + ((Instruction23x)inst).getRegisterB(),((Instruction23x)inst).getRegisterC(), inst.getOpcode(), this)); break; case SHR_INT: instructions.add(new BinaryOperation(instLoc, BinaryOperation.OpID.SHR_INT, ((Instruction23x)inst).getRegisterA(), - ((Instruction23x)inst).getRegisterB(),((Instruction23x)inst).getRegisterC(), inst.opcode, this)); + ((Instruction23x)inst).getRegisterB(),((Instruction23x)inst).getRegisterC(), inst.getOpcode(), this)); break; case USHR_INT: instructions.add(new BinaryOperation(instLoc, BinaryOperation.OpID.USHR_INT, ((Instruction23x)inst).getRegisterA(), - ((Instruction23x)inst).getRegisterB(),((Instruction23x)inst).getRegisterC(), inst.opcode, this)); + ((Instruction23x)inst).getRegisterB(),((Instruction23x)inst).getRegisterC(), inst.getOpcode(), this)); break; case ADD_LONG: instructions.add(new BinaryOperation(instLoc, BinaryOperation.OpID.ADD_LONG, ((Instruction23x)inst).getRegisterA(), - ((Instruction23x)inst).getRegisterB(),((Instruction23x)inst).getRegisterC(), inst.opcode, this)); + ((Instruction23x)inst).getRegisterB(),((Instruction23x)inst).getRegisterC(), inst.getOpcode(), this)); break; case SUB_LONG: instructions.add(new BinaryOperation(instLoc, BinaryOperation.OpID.SUB_LONG, ((Instruction23x)inst).getRegisterA(), - ((Instruction23x)inst).getRegisterB(),((Instruction23x)inst).getRegisterC(), inst.opcode, this)); + ((Instruction23x)inst).getRegisterB(),((Instruction23x)inst).getRegisterC(), inst.getOpcode(), this)); break; case MUL_LONG: instructions.add(new BinaryOperation(instLoc, BinaryOperation.OpID.MUL_LONG, ((Instruction23x)inst).getRegisterA(), - ((Instruction23x)inst).getRegisterB(),((Instruction23x)inst).getRegisterC(), inst.opcode, this)); + ((Instruction23x)inst).getRegisterB(),((Instruction23x)inst).getRegisterC(), inst.getOpcode(), this)); break; case DIV_LONG: instructions.add(new BinaryOperation(instLoc, BinaryOperation.OpID.DIV_LONG, ((Instruction23x)inst).getRegisterA(), - ((Instruction23x)inst).getRegisterB(),((Instruction23x)inst).getRegisterC(), inst.opcode, this)); + ((Instruction23x)inst).getRegisterB(),((Instruction23x)inst).getRegisterC(), inst.getOpcode(), this)); break; case REM_LONG: instructions.add(new BinaryOperation(instLoc, BinaryOperation.OpID.REM_LONG, ((Instruction23x)inst).getRegisterA(), - ((Instruction23x)inst).getRegisterB(),((Instruction23x)inst).getRegisterC(), inst.opcode, this)); + ((Instruction23x)inst).getRegisterB(),((Instruction23x)inst).getRegisterC(), inst.getOpcode(), this)); break; case AND_LONG: instructions.add(new BinaryOperation(instLoc, BinaryOperation.OpID.AND_LONG, ((Instruction23x)inst).getRegisterA(), - ((Instruction23x)inst).getRegisterB(),((Instruction23x)inst).getRegisterC(), inst.opcode, this)); + ((Instruction23x)inst).getRegisterB(),((Instruction23x)inst).getRegisterC(), inst.getOpcode(), this)); break; case OR_LONG: instructions.add(new BinaryOperation(instLoc, BinaryOperation.OpID.OR_LONG, ((Instruction23x)inst).getRegisterA(), - ((Instruction23x)inst).getRegisterB(),((Instruction23x)inst).getRegisterC(), inst.opcode, this)); + ((Instruction23x)inst).getRegisterB(),((Instruction23x)inst).getRegisterC(), inst.getOpcode(), this)); break; case XOR_LONG: instructions.add(new BinaryOperation(instLoc, BinaryOperation.OpID.XOR_LONG, ((Instruction23x)inst).getRegisterA(), - ((Instruction23x)inst).getRegisterB(),((Instruction23x)inst).getRegisterC(), inst.opcode, this)); + ((Instruction23x)inst).getRegisterB(),((Instruction23x)inst).getRegisterC(), inst.getOpcode(), this)); break; case SHL_LONG: instructions.add(new BinaryOperation(instLoc, BinaryOperation.OpID.SHL_LONG, ((Instruction23x)inst).getRegisterA(), - ((Instruction23x)inst).getRegisterB(),((Instruction23x)inst).getRegisterC(), inst.opcode, this)); + ((Instruction23x)inst).getRegisterB(),((Instruction23x)inst).getRegisterC(), inst.getOpcode(), this)); break; case SHR_LONG: instructions.add(new BinaryOperation(instLoc, BinaryOperation.OpID.SHR_LONG, ((Instruction23x)inst).getRegisterA(), - ((Instruction23x)inst).getRegisterB(),((Instruction23x)inst).getRegisterC(), inst.opcode, this)); + ((Instruction23x)inst).getRegisterB(),((Instruction23x)inst).getRegisterC(), inst.getOpcode(), this)); break; case USHR_LONG: instructions.add(new BinaryOperation(instLoc, BinaryOperation.OpID.USHR_LONG, ((Instruction23x)inst).getRegisterA(), - ((Instruction23x)inst).getRegisterB(),((Instruction23x)inst).getRegisterC(), inst.opcode, this)); + ((Instruction23x)inst).getRegisterB(),((Instruction23x)inst).getRegisterC(), inst.getOpcode(), this)); break; case ADD_FLOAT: instructions.add(new BinaryOperation(instLoc, BinaryOperation.OpID.ADD_FLOAT, ((Instruction23x)inst).getRegisterA(), - ((Instruction23x)inst).getRegisterB(),((Instruction23x)inst).getRegisterC(), inst.opcode, this)); + ((Instruction23x)inst).getRegisterB(),((Instruction23x)inst).getRegisterC(), inst.getOpcode(), this)); break; case SUB_FLOAT: instructions.add(new BinaryOperation(instLoc, BinaryOperation.OpID.SUB_FLOAT, ((Instruction23x)inst).getRegisterA(), - ((Instruction23x)inst).getRegisterB(),((Instruction23x)inst).getRegisterC(), inst.opcode, this)); + ((Instruction23x)inst).getRegisterB(),((Instruction23x)inst).getRegisterC(), inst.getOpcode(), this)); break; case MUL_FLOAT: instructions.add(new BinaryOperation(instLoc, BinaryOperation.OpID.MUL_FLOAT, ((Instruction23x)inst).getRegisterA(), - ((Instruction23x)inst).getRegisterB(),((Instruction23x)inst).getRegisterC(), inst.opcode, this)); + ((Instruction23x)inst).getRegisterB(),((Instruction23x)inst).getRegisterC(), inst.getOpcode(), this)); break; case DIV_FLOAT: instructions.add(new BinaryOperation(instLoc, BinaryOperation.OpID.DIV_FLOAT, ((Instruction23x)inst).getRegisterA(), - ((Instruction23x)inst).getRegisterB(),((Instruction23x)inst).getRegisterC(), inst.opcode, this)); + ((Instruction23x)inst).getRegisterB(),((Instruction23x)inst).getRegisterC(), inst.getOpcode(), this)); break; case REM_FLOAT: instructions.add(new BinaryOperation(instLoc, BinaryOperation.OpID.REM_FLOAT, ((Instruction23x)inst).getRegisterA(), - ((Instruction23x)inst).getRegisterB(),((Instruction23x)inst).getRegisterC(), inst.opcode, this)); + ((Instruction23x)inst).getRegisterB(),((Instruction23x)inst).getRegisterC(), inst.getOpcode(), this)); break; case ADD_DOUBLE: instructions.add(new BinaryOperation(instLoc, BinaryOperation.OpID.ADD_DOUBLE, ((Instruction23x)inst).getRegisterA(), - ((Instruction23x)inst).getRegisterB(),((Instruction23x)inst).getRegisterC(), inst.opcode, this)); + ((Instruction23x)inst).getRegisterB(),((Instruction23x)inst).getRegisterC(), inst.getOpcode(), this)); break; case SUB_DOUBLE: instructions.add(new BinaryOperation(instLoc, BinaryOperation.OpID.SUB_DOUBLE, ((Instruction23x)inst).getRegisterA(), - ((Instruction23x)inst).getRegisterB(),((Instruction23x)inst).getRegisterC(), inst.opcode, this)); + ((Instruction23x)inst).getRegisterB(),((Instruction23x)inst).getRegisterC(), inst.getOpcode(), this)); break; case MUL_DOUBLE: instructions.add(new BinaryOperation(instLoc, BinaryOperation.OpID.MUL_DOUBLE, ((Instruction23x)inst).getRegisterA(), - ((Instruction23x)inst).getRegisterB(),((Instruction23x)inst).getRegisterC(), inst.opcode, this)); + ((Instruction23x)inst).getRegisterB(),((Instruction23x)inst).getRegisterC(), inst.getOpcode(), this)); break; case DIV_DOUBLE: instructions.add(new BinaryOperation(instLoc, BinaryOperation.OpID.DIV_DOUBLE, ((Instruction23x)inst).getRegisterA(), - ((Instruction23x)inst).getRegisterB(),((Instruction23x)inst).getRegisterC(), inst.opcode, this)); + ((Instruction23x)inst).getRegisterB(),((Instruction23x)inst).getRegisterC(), inst.getOpcode(), this)); break; case REM_DOUBLE: instructions.add(new BinaryOperation(instLoc, BinaryOperation.OpID.REM_DOUBLE, ((Instruction23x)inst).getRegisterA(), - ((Instruction23x)inst).getRegisterB(),((Instruction23x)inst).getRegisterC(), inst.opcode, this)); + ((Instruction23x)inst).getRegisterB(),((Instruction23x)inst).getRegisterC(), inst.getOpcode(), this)); break; case ADD_INT_2ADDR: instructions.add(new BinaryOperation(instLoc, BinaryOperation.OpID.ADD_INT, ((Instruction12x)inst).getRegisterA(), - ((Instruction12x)inst).getRegisterA(), ((Instruction12x)inst).getRegisterB(), inst.opcode, this)); + ((Instruction12x)inst).getRegisterA(), ((Instruction12x)inst).getRegisterB(), inst.getOpcode(), this)); break; case SUB_INT_2ADDR: instructions.add(new BinaryOperation(instLoc, BinaryOperation.OpID.SUB_INT, ((Instruction12x)inst).getRegisterA(), - ((Instruction12x)inst).getRegisterA(), ((Instruction12x)inst).getRegisterB(), inst.opcode, this)); + ((Instruction12x)inst).getRegisterA(), ((Instruction12x)inst).getRegisterB(), inst.getOpcode(), this)); break; case MUL_INT_2ADDR: instructions.add(new BinaryOperation(instLoc, BinaryOperation.OpID.MUL_INT, ((Instruction12x)inst).getRegisterA(), - ((Instruction12x)inst).getRegisterA(), ((Instruction12x)inst).getRegisterB(), inst.opcode, this)); + ((Instruction12x)inst).getRegisterA(), ((Instruction12x)inst).getRegisterB(), inst.getOpcode(), this)); break; case DIV_INT_2ADDR: instructions.add(new BinaryOperation(instLoc, BinaryOperation.OpID.DIV_INT, ((Instruction12x)inst).getRegisterA(), - ((Instruction12x)inst).getRegisterA(), ((Instruction12x)inst).getRegisterB(), inst.opcode, this)); + ((Instruction12x)inst).getRegisterA(), ((Instruction12x)inst).getRegisterB(), inst.getOpcode(), this)); break; case REM_INT_2ADDR: instructions.add(new BinaryOperation(instLoc, BinaryOperation.OpID.REM_INT, ((Instruction12x)inst).getRegisterA(), - ((Instruction12x)inst).getRegisterA(), ((Instruction12x)inst).getRegisterB(), inst.opcode, this)); + ((Instruction12x)inst).getRegisterA(), ((Instruction12x)inst).getRegisterB(), inst.getOpcode(), this)); break; case AND_INT_2ADDR: instructions.add(new BinaryOperation(instLoc, BinaryOperation.OpID.AND_INT, ((Instruction12x)inst).getRegisterA(), - ((Instruction12x)inst).getRegisterA(), ((Instruction12x)inst).getRegisterB(), inst.opcode, this)); + ((Instruction12x)inst).getRegisterA(), ((Instruction12x)inst).getRegisterB(), inst.getOpcode(), this)); break; case OR_INT_2ADDR: instructions.add(new BinaryOperation(instLoc, BinaryOperation.OpID.OR_INT, ((Instruction12x)inst).getRegisterA(), - ((Instruction12x)inst).getRegisterA(), ((Instruction12x)inst).getRegisterB(), inst.opcode, this)); + ((Instruction12x)inst).getRegisterA(), ((Instruction12x)inst).getRegisterB(), inst.getOpcode(), this)); break; case XOR_INT_2ADDR: instructions.add(new BinaryOperation(instLoc, BinaryOperation.OpID.XOR_INT, ((Instruction12x)inst).getRegisterA(), - ((Instruction12x)inst).getRegisterA(), ((Instruction12x)inst).getRegisterB(), inst.opcode, this)); + ((Instruction12x)inst).getRegisterA(), ((Instruction12x)inst).getRegisterB(), inst.getOpcode(), this)); break; case SHL_INT_2ADDR: instructions.add(new BinaryOperation(instLoc, BinaryOperation.OpID.SHL_INT, ((Instruction12x)inst).getRegisterA(), - ((Instruction12x)inst).getRegisterA(), ((Instruction12x)inst).getRegisterB(), inst.opcode, this)); + ((Instruction12x)inst).getRegisterA(), ((Instruction12x)inst).getRegisterB(), inst.getOpcode(), this)); break; case SHR_INT_2ADDR: instructions.add(new BinaryOperation(instLoc, BinaryOperation.OpID.SHR_INT, ((Instruction12x)inst).getRegisterA(), - ((Instruction12x)inst).getRegisterA(), ((Instruction12x)inst).getRegisterB(), inst.opcode, this)); + ((Instruction12x)inst).getRegisterA(), ((Instruction12x)inst).getRegisterB(), inst.getOpcode(), this)); break; case USHR_INT_2ADDR: instructions.add(new BinaryOperation(instLoc, BinaryOperation.OpID.USHR_INT, ((Instruction12x)inst).getRegisterA(), - ((Instruction12x)inst).getRegisterA(), ((Instruction12x)inst).getRegisterB(), inst.opcode, this)); + ((Instruction12x)inst).getRegisterA(), ((Instruction12x)inst).getRegisterB(), inst.getOpcode(), this)); break; case ADD_LONG_2ADDR: instructions.add(new BinaryOperation(instLoc, BinaryOperation.OpID.ADD_LONG, ((Instruction12x)inst).getRegisterA(), - ((Instruction12x)inst).getRegisterA(), ((Instruction12x)inst).getRegisterB(), inst.opcode, this)); + ((Instruction12x)inst).getRegisterA(), ((Instruction12x)inst).getRegisterB(), inst.getOpcode(), this)); break; case SUB_LONG_2ADDR: instructions.add(new BinaryOperation(instLoc, BinaryOperation.OpID.SUB_LONG, ((Instruction12x)inst).getRegisterA(), - ((Instruction12x)inst).getRegisterA(), ((Instruction12x)inst).getRegisterB(), inst.opcode, this)); + ((Instruction12x)inst).getRegisterA(), ((Instruction12x)inst).getRegisterB(), inst.getOpcode(), this)); break; case MUL_LONG_2ADDR: instructions.add(new BinaryOperation(instLoc, BinaryOperation.OpID.MUL_LONG, ((Instruction12x)inst).getRegisterA(), - ((Instruction12x)inst).getRegisterA(), ((Instruction12x)inst).getRegisterB(), inst.opcode, this)); + ((Instruction12x)inst).getRegisterA(), ((Instruction12x)inst).getRegisterB(), inst.getOpcode(), this)); break; case DIV_LONG_2ADDR: instructions.add(new BinaryOperation(instLoc, BinaryOperation.OpID.DIV_LONG, ((Instruction12x)inst).getRegisterA(), - ((Instruction12x)inst).getRegisterA(), ((Instruction12x)inst).getRegisterB(), inst.opcode, this)); + ((Instruction12x)inst).getRegisterA(), ((Instruction12x)inst).getRegisterB(), inst.getOpcode(), this)); break; case REM_LONG_2ADDR: instructions.add(new BinaryOperation(instLoc, BinaryOperation.OpID.REM_LONG, ((Instruction12x)inst).getRegisterA(), - ((Instruction12x)inst).getRegisterA(), ((Instruction12x)inst).getRegisterB(), inst.opcode, this)); + ((Instruction12x)inst).getRegisterA(), ((Instruction12x)inst).getRegisterB(), inst.getOpcode(), this)); break; case AND_LONG_2ADDR: instructions.add(new BinaryOperation(instLoc, BinaryOperation.OpID.AND_LONG, ((Instruction12x)inst).getRegisterA(), - ((Instruction12x)inst).getRegisterA(), ((Instruction12x)inst).getRegisterB(), inst.opcode, this)); + ((Instruction12x)inst).getRegisterA(), ((Instruction12x)inst).getRegisterB(), inst.getOpcode(), this)); break; case OR_LONG_2ADDR: instructions.add(new BinaryOperation(instLoc, BinaryOperation.OpID.OR_LONG, ((Instruction12x)inst).getRegisterA(), - ((Instruction12x)inst).getRegisterA(), ((Instruction12x)inst).getRegisterB(), inst.opcode, this)); + ((Instruction12x)inst).getRegisterA(), ((Instruction12x)inst).getRegisterB(), inst.getOpcode(), this)); break; case XOR_LONG_2ADDR: instructions.add(new BinaryOperation(instLoc, BinaryOperation.OpID.XOR_LONG, ((Instruction12x)inst).getRegisterA(), - ((Instruction12x)inst).getRegisterA(), ((Instruction12x)inst).getRegisterB(), inst.opcode, this)); + ((Instruction12x)inst).getRegisterA(), ((Instruction12x)inst).getRegisterB(), inst.getOpcode(), this)); break; case SHL_LONG_2ADDR: instructions.add(new BinaryOperation(instLoc, BinaryOperation.OpID.SHL_LONG, ((Instruction12x)inst).getRegisterA(), - ((Instruction12x)inst).getRegisterA(), ((Instruction12x)inst).getRegisterB(), inst.opcode, this)); + ((Instruction12x)inst).getRegisterA(), ((Instruction12x)inst).getRegisterB(), inst.getOpcode(), this)); break; case SHR_LONG_2ADDR: instructions.add(new BinaryOperation(instLoc, BinaryOperation.OpID.SHR_LONG, ((Instruction12x)inst).getRegisterA(), - ((Instruction12x)inst).getRegisterA(), ((Instruction12x)inst).getRegisterB(), inst.opcode, this)); + ((Instruction12x)inst).getRegisterA(), ((Instruction12x)inst).getRegisterB(), inst.getOpcode(), this)); break; case USHR_LONG_2ADDR: instructions.add(new BinaryOperation(instLoc, BinaryOperation.OpID.USHR_LONG, ((Instruction12x)inst).getRegisterA(), - ((Instruction12x)inst).getRegisterA(), ((Instruction12x)inst).getRegisterB(), inst.opcode, this)); + ((Instruction12x)inst).getRegisterA(), ((Instruction12x)inst).getRegisterB(), inst.getOpcode(), this)); break; case ADD_FLOAT_2ADDR: instructions.add(new BinaryOperation(instLoc, BinaryOperation.OpID.ADD_FLOAT, ((Instruction12x)inst).getRegisterA(), - ((Instruction12x)inst).getRegisterA(), ((Instruction12x)inst).getRegisterB(), inst.opcode, this)); + ((Instruction12x)inst).getRegisterA(), ((Instruction12x)inst).getRegisterB(), inst.getOpcode(), this)); break; case SUB_FLOAT_2ADDR: instructions.add(new BinaryOperation(instLoc, BinaryOperation.OpID.SUB_FLOAT, ((Instruction12x)inst).getRegisterA(), - ((Instruction12x)inst).getRegisterA(), ((Instruction12x)inst).getRegisterB(), inst.opcode, this)); + ((Instruction12x)inst).getRegisterA(), ((Instruction12x)inst).getRegisterB(), inst.getOpcode(), this)); break; case MUL_FLOAT_2ADDR: instructions.add(new BinaryOperation(instLoc, BinaryOperation.OpID.MUL_FLOAT, ((Instruction12x)inst).getRegisterA(), - ((Instruction12x)inst).getRegisterA(), ((Instruction12x)inst).getRegisterB(), inst.opcode, this)); + ((Instruction12x)inst).getRegisterA(), ((Instruction12x)inst).getRegisterB(), inst.getOpcode(), this)); break; case DIV_FLOAT_2ADDR: instructions.add(new BinaryOperation(instLoc, BinaryOperation.OpID.DIV_FLOAT, ((Instruction12x)inst).getRegisterA(), - ((Instruction12x)inst).getRegisterA(), ((Instruction12x)inst).getRegisterB(), inst.opcode, this)); + ((Instruction12x)inst).getRegisterA(), ((Instruction12x)inst).getRegisterB(), inst.getOpcode(), this)); break; case REM_FLOAT_2ADDR: instructions.add(new BinaryOperation(instLoc, BinaryOperation.OpID.REM_FLOAT, ((Instruction12x)inst).getRegisterA(), - ((Instruction12x)inst).getRegisterA(), ((Instruction12x)inst).getRegisterB(), inst.opcode, this)); + ((Instruction12x)inst).getRegisterA(), ((Instruction12x)inst).getRegisterB(), inst.getOpcode(), this)); break; case ADD_DOUBLE_2ADDR: instructions.add(new BinaryOperation(instLoc, BinaryOperation.OpID.ADD_DOUBLE, ((Instruction12x)inst).getRegisterA(), - ((Instruction12x)inst).getRegisterA(), ((Instruction12x)inst).getRegisterB(), inst.opcode, this)); + ((Instruction12x)inst).getRegisterA(), ((Instruction12x)inst).getRegisterB(), inst.getOpcode(), this)); break; case SUB_DOUBLE_2ADDR: instructions.add(new BinaryOperation(instLoc, BinaryOperation.OpID.SUB_DOUBLE, ((Instruction12x)inst).getRegisterA(), - ((Instruction12x)inst).getRegisterA(), ((Instruction12x)inst).getRegisterB(), inst.opcode, this)); + ((Instruction12x)inst).getRegisterA(), ((Instruction12x)inst).getRegisterB(), inst.getOpcode(), this)); break; case MUL_DOUBLE_2ADDR: instructions.add(new BinaryOperation(instLoc, BinaryOperation.OpID.MUL_DOUBLE, ((Instruction12x)inst).getRegisterA(), - ((Instruction12x)inst).getRegisterA(), ((Instruction12x)inst).getRegisterB(), inst.opcode, this)); + ((Instruction12x)inst).getRegisterA(), ((Instruction12x)inst).getRegisterB(), inst.getOpcode(), this)); break; case DIV_DOUBLE_2ADDR: instructions.add(new BinaryOperation(instLoc, BinaryOperation.OpID.DIV_DOUBLE, ((Instruction12x)inst).getRegisterA(), - ((Instruction12x)inst).getRegisterA(), ((Instruction12x)inst).getRegisterB(), inst.opcode, this)); + ((Instruction12x)inst).getRegisterA(), ((Instruction12x)inst).getRegisterB(), inst.getOpcode(), this)); break; case REM_DOUBLE_2ADDR: instructions.add(new BinaryOperation(instLoc, BinaryOperation.OpID.REM_DOUBLE, ((Instruction12x)inst).getRegisterA(), - ((Instruction12x)inst).getRegisterA(), ((Instruction12x)inst).getRegisterB(), inst.opcode, this)); + ((Instruction12x)inst).getRegisterA(), ((Instruction12x)inst).getRegisterB(), inst.getOpcode(), this)); break; case ADD_INT_LIT16: { - Literal lit = new Literal.LongLiteral(((Instruction22s)inst).getLiteral()); + Literal lit = new Literal.LongLiteral(((Instruction22s)inst).getWideLiteral()); instructions.add(new BinaryLiteralOperation(instLoc, BinaryLiteralOperation.OpID.ADD_INT, - ((Instruction22s)inst).getRegisterA(), ((Instruction22s)inst).getRegisterB(), lit, inst.opcode, this)); + ((Instruction22s)inst).getRegisterA(), ((Instruction22s)inst).getRegisterB(), lit, inst.getOpcode(), this)); break; } case RSUB_INT: { - Literal lit = new Literal.LongLiteral(((Instruction22s)inst).getLiteral()); + Literal lit = new Literal.LongLiteral(((Instruction22s)inst).getWideLiteral()); instructions.add(new BinaryLiteralOperation(instLoc, BinaryLiteralOperation.OpID.RSUB_INT, - ((Instruction22s)inst).getRegisterA(), ((Instruction22s)inst).getRegisterB(), lit, inst.opcode, this)); + ((Instruction22s)inst).getRegisterA(), ((Instruction22s)inst).getRegisterB(), lit, inst.getOpcode(), this)); break; } case MUL_INT_LIT16: { - Literal lit = new Literal.LongLiteral(((Instruction22s)inst).getLiteral()); + Literal lit = new Literal.LongLiteral(((Instruction22s)inst).getWideLiteral()); instructions.add(new BinaryLiteralOperation(instLoc, BinaryLiteralOperation.OpID.MUL_INT, - ((Instruction22s)inst).getRegisterA(), ((Instruction22s)inst).getRegisterB(), lit, inst.opcode, this)); + ((Instruction22s)inst).getRegisterA(), ((Instruction22s)inst).getRegisterB(), lit, inst.getOpcode(), this)); break; } case DIV_INT_LIT16: { - Literal lit = new Literal.LongLiteral(((Instruction22s)inst).getLiteral()); + Literal lit = new Literal.LongLiteral(((Instruction22s)inst).getWideLiteral()); instructions.add(new BinaryLiteralOperation(instLoc, BinaryLiteralOperation.OpID.DIV_INT, - ((Instruction22s)inst).getRegisterA(), ((Instruction22s)inst).getRegisterB(), lit, inst.opcode, this)); + ((Instruction22s)inst).getRegisterA(), ((Instruction22s)inst).getRegisterB(), lit, inst.getOpcode(), this)); break; } case REM_INT_LIT16: { - Literal lit = new Literal.LongLiteral(((Instruction22s)inst).getLiteral()); + Literal lit = new Literal.LongLiteral(((Instruction22s)inst).getWideLiteral()); instructions.add(new BinaryLiteralOperation(instLoc, BinaryLiteralOperation.OpID.REM_INT, - ((Instruction22s)inst).getRegisterA(), ((Instruction22s)inst).getRegisterB(), lit, inst.opcode, this)); + ((Instruction22s)inst).getRegisterA(), ((Instruction22s)inst).getRegisterB(), lit, inst.getOpcode(), this)); break; } case AND_INT_LIT16: { - Literal lit = new Literal.LongLiteral(((Instruction22s)inst).getLiteral()); + Literal lit = new Literal.LongLiteral(((Instruction22s)inst).getWideLiteral()); instructions.add(new BinaryLiteralOperation(instLoc, BinaryLiteralOperation.OpID.AND_INT, - ((Instruction22s)inst).getRegisterA(), ((Instruction22s)inst).getRegisterB(), lit, inst.opcode, this)); + ((Instruction22s)inst).getRegisterA(), ((Instruction22s)inst).getRegisterB(), lit, inst.getOpcode(), this)); break; } case OR_INT_LIT16: { - Literal lit = new Literal.LongLiteral(((Instruction22s)inst).getLiteral()); + Literal lit = new Literal.LongLiteral(((Instruction22s)inst).getWideLiteral()); instructions.add(new BinaryLiteralOperation(instLoc, BinaryLiteralOperation.OpID.OR_INT, - ((Instruction22s)inst).getRegisterA(), ((Instruction22s)inst).getRegisterB(), lit, inst.opcode, this)); + ((Instruction22s)inst).getRegisterA(), ((Instruction22s)inst).getRegisterB(), lit, inst.getOpcode(), this)); break; } case XOR_INT_LIT16: { - Literal lit = new Literal.LongLiteral(((Instruction22s)inst).getLiteral()); + Literal lit = new Literal.LongLiteral(((Instruction22s)inst).getWideLiteral()); instructions.add(new BinaryLiteralOperation(instLoc, BinaryLiteralOperation.OpID.XOR_INT, - ((Instruction22s)inst).getRegisterA(), ((Instruction22s)inst).getRegisterB(), lit, inst.opcode, this)); + ((Instruction22s)inst).getRegisterA(), ((Instruction22s)inst).getRegisterB(), lit, inst.getOpcode(), this)); break; } case ADD_INT_LIT8: { - Literal lit = new Literal.LongLiteral(((Instruction22b)inst).getLiteral()); + Literal lit = new Literal.LongLiteral(((Instruction22b)inst).getWideLiteral()); instructions.add(new BinaryLiteralOperation(instLoc, BinaryLiteralOperation.OpID.ADD_INT, - ((Instruction22b)inst).getRegisterA(), ((Instruction22b)inst).getRegisterB(), lit, inst.opcode, this)); + ((Instruction22b)inst).getRegisterA(), ((Instruction22b)inst).getRegisterB(), lit, inst.getOpcode(), this)); break; } case RSUB_INT_LIT8: { - Literal lit = new Literal.LongLiteral(((Instruction22b)inst).getLiteral()); + Literal lit = new Literal.LongLiteral(((Instruction22b)inst).getWideLiteral()); instructions.add(new BinaryLiteralOperation(instLoc, BinaryLiteralOperation.OpID.RSUB_INT, - ((Instruction22b)inst).getRegisterA(), ((Instruction22b)inst).getRegisterB(), lit, inst.opcode, this)); + ((Instruction22b)inst).getRegisterA(), ((Instruction22b)inst).getRegisterB(), lit, inst.getOpcode(), this)); break; } case MUL_INT_LIT8: { - Literal lit = new Literal.LongLiteral(((Instruction22b)inst).getLiteral()); + Literal lit = new Literal.LongLiteral(((Instruction22b)inst).getWideLiteral()); instructions.add(new BinaryLiteralOperation(instLoc, BinaryLiteralOperation.OpID.MUL_INT, - ((Instruction22b)inst).getRegisterA(), ((Instruction22b)inst).getRegisterB(), lit, inst.opcode, this)); + ((Instruction22b)inst).getRegisterA(), ((Instruction22b)inst).getRegisterB(), lit, inst.getOpcode(), this)); break; } case DIV_INT_LIT8: { - Literal lit = new Literal.LongLiteral(((Instruction22b)inst).getLiteral()); + Literal lit = new Literal.LongLiteral(((Instruction22b)inst).getWideLiteral()); instructions.add(new BinaryLiteralOperation(instLoc, BinaryLiteralOperation.OpID.DIV_INT, - ((Instruction22b)inst).getRegisterA(), ((Instruction22b)inst).getRegisterB(), lit, inst.opcode, this)); + ((Instruction22b)inst).getRegisterA(), ((Instruction22b)inst).getRegisterB(), lit, inst.getOpcode(), this)); break; } case REM_INT_LIT8: { - Literal lit = new Literal.LongLiteral(((Instruction22b)inst).getLiteral()); + Literal lit = new Literal.LongLiteral(((Instruction22b)inst).getWideLiteral()); instructions.add(new BinaryLiteralOperation(instLoc, BinaryLiteralOperation.OpID.REM_INT, - ((Instruction22b)inst).getRegisterA(), ((Instruction22b)inst).getRegisterB(), lit, inst.opcode, this)); + ((Instruction22b)inst).getRegisterA(), ((Instruction22b)inst).getRegisterB(), lit, inst.getOpcode(), this)); break; } case AND_INT_LIT8: { - Literal lit = new Literal.LongLiteral(((Instruction22b)inst).getLiteral()); + Literal lit = new Literal.LongLiteral(((Instruction22b)inst).getWideLiteral()); instructions.add(new BinaryLiteralOperation(instLoc, BinaryLiteralOperation.OpID.AND_INT, - ((Instruction22b)inst).getRegisterA(), ((Instruction22b)inst).getRegisterB(), lit, inst.opcode, this)); + ((Instruction22b)inst).getRegisterA(), ((Instruction22b)inst).getRegisterB(), lit, inst.getOpcode(), this)); break; } case OR_INT_LIT8: { - Literal lit = new Literal.LongLiteral(((Instruction22b)inst).getLiteral()); + Literal lit = new Literal.LongLiteral(((Instruction22b)inst).getWideLiteral()); instructions.add(new BinaryLiteralOperation(instLoc, BinaryLiteralOperation.OpID.OR_INT, - ((Instruction22b)inst).getRegisterA(), ((Instruction22b)inst).getRegisterB(), lit, inst.opcode, this)); + ((Instruction22b)inst).getRegisterA(), ((Instruction22b)inst).getRegisterB(), lit, inst.getOpcode(), this)); break; } case XOR_INT_LIT8: { - Literal lit = new Literal.LongLiteral(((Instruction22b)inst).getLiteral()); + Literal lit = new Literal.LongLiteral(((Instruction22b)inst).getWideLiteral()); instructions.add(new BinaryLiteralOperation(instLoc, BinaryLiteralOperation.OpID.XOR_INT, - ((Instruction22b)inst).getRegisterA(), ((Instruction22b)inst).getRegisterB(), lit, inst.opcode, this)); + ((Instruction22b)inst).getRegisterA(), ((Instruction22b)inst).getRegisterB(), lit, inst.getOpcode(), this)); break; } case SHL_INT_LIT8: { - Literal lit = new Literal.LongLiteral(((Instruction22b)inst).getLiteral()); + Literal lit = new Literal.LongLiteral(((Instruction22b)inst).getWideLiteral()); instructions.add(new BinaryLiteralOperation(instLoc, BinaryLiteralOperation.OpID.SHL_INT, - ((Instruction22b)inst).getRegisterA(), ((Instruction22b)inst).getRegisterB(), lit, inst.opcode, this)); + ((Instruction22b)inst).getRegisterA(), ((Instruction22b)inst).getRegisterB(), lit, inst.getOpcode(), this)); break; } case SHR_INT_LIT8: { - Literal lit = new Literal.LongLiteral(((Instruction22b)inst).getLiteral()); + Literal lit = new Literal.LongLiteral(((Instruction22b)inst).getWideLiteral()); instructions.add(new BinaryLiteralOperation(instLoc, BinaryLiteralOperation.OpID.SHR_INT, - ((Instruction22b)inst).getRegisterA(), ((Instruction22b)inst).getRegisterB(), lit, inst.opcode, this)); + ((Instruction22b)inst).getRegisterA(), ((Instruction22b)inst).getRegisterB(), lit, inst.getOpcode(), this)); break; } case USHR_INT_LIT8: { - Literal lit = new Literal.LongLiteral(((Instruction22b)inst).getLiteral()); + Literal lit = new Literal.LongLiteral(((Instruction22b)inst).getWideLiteral()); instructions.add(new BinaryLiteralOperation(instLoc, BinaryLiteralOperation.OpID.USHR_INT, - ((Instruction22b)inst).getRegisterA(), ((Instruction22b)inst).getRegisterB(), lit, inst.opcode, this)); + ((Instruction22b)inst).getRegisterA(), ((Instruction22b)inst).getRegisterB(), lit, inst.getOpcode(), this)); break; } default: throw new RuntimeException("not implemented instruction: 0x" - + inst.opcode.toString()); + + inst.getOpcode().toString()); } - currentCodeAddress += inst.getSize(currentCodeAddress); + currentCodeAddress += inst.getCodeUnits(); } //// comment out start @@ -2343,7 +2335,7 @@ public class DexIMethod implements IBytecodeMethod { // // Instruction10t dInst = (Instruction10t)instruction; // - // int offset = dInst.getTargetAddressOffset(); + // int offset = dInst.getCodeOffset(); // instructions.add(new Goto(i,offset)); // // break; @@ -2905,7 +2897,7 @@ public class DexIMethod implements IBytecodeMethod { // // Instruction20t dInst = (Instruction20t)instruction; // - // int offset = dInst.getTargetAddressOffset(); + // int offset = dInst.getCodeOffset(); // instructions.add(new Goto(i,offset)); // break; // } @@ -2914,7 +2906,7 @@ public class DexIMethod implements IBytecodeMethod { // // Instruction30t dInst = (Instruction30t)instruction; // - // int offset = dInst.getTargetAddressOffset(); + // int offset = dInst.getCodeOffset(); // instructions.add(new Goto(i,offset)); // break; // } @@ -3015,7 +3007,7 @@ public class DexIMethod implements IBytecodeMethod { // Instruction21t dInst = (Instruction21t)instruction; // // Register oper1 = regBank.get(dInst.getRegisterA()); - // int offset = dInst.getTargetAddressOffset(); + // int offset = dInst.getCodeOffset(); // // switch(dInst.opcode) { // case IF_EQZ: @@ -3137,27 +3129,27 @@ public class DexIMethod implements IBytecodeMethod { } private static TypeReference findOutArrayElementType( - org.jf.dexlib.Code.Instruction[] instrucs, Instruction[] walaInstructions, int instCounter) { - if (instCounter < 0 || instrucs[instCounter].opcode != Opcode.FILL_ARRAY_DATA) { + org.jf.dexlib2.iface.instruction.Instruction inst, Instruction[] walaInstructions, int instCounter) { + if (instCounter < 0) { throw new IllegalArgumentException(); } else if (instCounter == 0) { throw new UnsupportedOperationException("fill-array-data as first instruction is not supported!"); } - Instruction31t arrayFill = (Instruction31t)instrucs[instCounter]; + + Instruction31t arrayFill = (Instruction31t)inst; int interestingRegister = arrayFill.getRegisterA(); int curCounter = instCounter - 1; while (curCounter >= 0) { - org.jf.dexlib.Code.Instruction curInst = instrucs[curCounter]; + Instruction curInst = walaInstructions[curCounter]; // do we have a 'new-array'-instruction, where the destination register coincides with the current interesting register? // then we return the element type of that array - if (curInst.opcode == Opcode.NEW_ARRAY) { - Instruction22c newArrayInst = (Instruction22c) curInst; - if (newArrayInst.getRegisterA() == interestingRegister) { - NewArray newArray = (NewArray) walaInstructions[curCounter]; + if (curInst.getOpcode() == Opcode.NEW_ARRAY) { + NewArray newArray = (NewArray) walaInstructions[curCounter]; + if (newArray.destination == interestingRegister) { return newArray.newSiteRef.getDeclaredType().getArrayElementType(); } - } else if (curInst.opcode == Opcode.MOVE_OBJECT || curInst.opcode == Opcode.MOVE_OBJECT_16 || curInst.opcode == Opcode.MOVE_OBJECT_FROM16) { + } else if (curInst.getOpcode() == Opcode.MOVE_OBJECT || curInst.getOpcode() == Opcode.MOVE_OBJECT_16 || curInst.getOpcode() == Opcode.MOVE_OBJECT_FROM16) { TwoRegisterInstruction tri = (TwoRegisterInstruction) curInst; int regA = tri.getRegisterA(); int regB = tri.getRegisterB(); @@ -3292,21 +3284,21 @@ public class DexIMethod implements IBytecodeMethod { @Override public Collection getAnnotations() { - return DexUtil.getAnnotations(myClass.getAnnotations(eMethod.method, null), myClass.getClassLoader().getReference()); + return myClass.getAnnotations(eMethod, null); } @Override public Collection getAnnotations(boolean runtimeInvisible) { - return DexUtil.getAnnotations(myClass.getAnnotations(eMethod.method, DexIClass.getTypes(runtimeInvisible)), myClass.getClassLoader().getReference()); + return myClass.getAnnotations(eMethod, DexIClass.getTypes(runtimeInvisible)); } @Override public Collection[] getParameterAnnotations() { - Map> raw = myClass.getParameterAnnotations(eMethod.method); + Map> raw = myClass.getParameterAnnotations(eMethod); @SuppressWarnings("unchecked") Collection[] result = new Collection[ getReference().getNumberOfParameters() ]; - for(Map.Entry> x : raw.entrySet()) { - result[x.getKey()] = DexUtil.getAnnotations(x.getValue(), myClass.getClassLoader().getReference()); + for(Map.Entry> x : raw.entrySet()) { + result[x.getKey()] = x.getValue(); } return result; } diff --git a/com.ibm.wala.dalvik/src/com/ibm/wala/dalvik/classLoader/DexModuleEntry.java b/com.ibm.wala.dalvik/src/com/ibm/wala/dalvik/classLoader/DexModuleEntry.java index a88300c32..1c97115af 100644 --- a/com.ibm.wala.dalvik/src/com/ibm/wala/dalvik/classLoader/DexModuleEntry.java +++ b/com.ibm.wala.dalvik/src/com/ibm/wala/dalvik/classLoader/DexModuleEntry.java @@ -50,19 +50,19 @@ package com.ibm.wala.dalvik.classLoader; import java.io.InputStream; -import org.jf.dexlib.ClassDefItem; +import org.jf.dexlib2.iface.ClassDef; import com.ibm.wala.classLoader.Module; import com.ibm.wala.classLoader.ModuleEntry; public class DexModuleEntry implements ModuleEntry { - private final ClassDefItem classDefItem; + private final ClassDef classDefItem; private final String className; - public DexModuleEntry(ClassDefItem cdefitems) { + public DexModuleEntry(ClassDef cdefitems) { classDefItem = cdefitems; - String temp =cdefitems.getClassType().getTypeDescriptor(); + String temp =cdefitems.getType(); // className = temp; if (temp.endsWith(";")) className = temp.substring(0,temp.length()-1); //remove last ';' @@ -71,7 +71,7 @@ public class DexModuleEntry implements ModuleEntry { // System.out.println(className); } - public ClassDefItem getClassDefItem(){ + public ClassDef getClassDefItem(){ return classDefItem; } diff --git a/com.ibm.wala.dalvik/src/com/ibm/wala/dalvik/classLoader/DexUtil.java b/com.ibm.wala.dalvik/src/com/ibm/wala/dalvik/classLoader/DexUtil.java index 197cab0a2..aecc67b1c 100644 --- a/com.ibm.wala.dalvik/src/com/ibm/wala/dalvik/classLoader/DexUtil.java +++ b/com.ibm.wala.dalvik/src/com/ibm/wala/dalvik/classLoader/DexUtil.java @@ -1,29 +1,43 @@ package com.ibm.wala.dalvik.classLoader; +import static org.jf.dexlib2.ValueType.ANNOTATION; +import static org.jf.dexlib2.ValueType.ARRAY; +import static org.jf.dexlib2.ValueType.BOOLEAN; +import static org.jf.dexlib2.ValueType.BYTE; +import static org.jf.dexlib2.ValueType.CHAR; +import static org.jf.dexlib2.ValueType.DOUBLE; +import static org.jf.dexlib2.ValueType.ENUM; +import static org.jf.dexlib2.ValueType.FIELD; +import static org.jf.dexlib2.ValueType.FLOAT; +import static org.jf.dexlib2.ValueType.INT; +import static org.jf.dexlib2.ValueType.LONG; +import static org.jf.dexlib2.ValueType.METHOD; +import static org.jf.dexlib2.ValueType.NULL; +import static org.jf.dexlib2.ValueType.SHORT; +import static org.jf.dexlib2.ValueType.STRING; +import static org.jf.dexlib2.ValueType.TYPE; + import java.util.Collection; +import java.util.List; import java.util.Map; -import org.jf.dexlib.AnnotationItem; -import org.jf.dexlib.FieldIdItem; -import org.jf.dexlib.MethodIdItem; -import org.jf.dexlib.TypeIdItem; -import org.jf.dexlib.EncodedValue.AnnotationEncodedSubValue; -import org.jf.dexlib.EncodedValue.ArrayEncodedValue; -import org.jf.dexlib.EncodedValue.BooleanEncodedValue; -import org.jf.dexlib.EncodedValue.ByteEncodedValue; -import org.jf.dexlib.EncodedValue.CharEncodedValue; -import org.jf.dexlib.EncodedValue.DoubleEncodedValue; -import org.jf.dexlib.EncodedValue.EncodedValue; -import org.jf.dexlib.EncodedValue.EnumEncodedValue; -import org.jf.dexlib.EncodedValue.FieldEncodedValue; -import org.jf.dexlib.EncodedValue.FloatEncodedValue; -import org.jf.dexlib.EncodedValue.IntEncodedValue; -import org.jf.dexlib.EncodedValue.LongEncodedValue; -import org.jf.dexlib.EncodedValue.MethodEncodedValue; -import org.jf.dexlib.EncodedValue.ShortEncodedValue; -import org.jf.dexlib.EncodedValue.StringEncodedValue; -import org.jf.dexlib.EncodedValue.TypeEncodedValue; -import org.jf.dexlib.EncodedValue.ValueType; +import org.jf.dexlib2.iface.AnnotationElement; +import org.jf.dexlib2.iface.value.AnnotationEncodedValue; +import org.jf.dexlib2.iface.value.ArrayEncodedValue; +import org.jf.dexlib2.iface.value.BooleanEncodedValue; +import org.jf.dexlib2.iface.value.ByteEncodedValue; +import org.jf.dexlib2.iface.value.CharEncodedValue; +import org.jf.dexlib2.iface.value.DoubleEncodedValue; +import org.jf.dexlib2.iface.value.EncodedValue; +import org.jf.dexlib2.iface.value.EnumEncodedValue; +import org.jf.dexlib2.iface.value.FieldEncodedValue; +import org.jf.dexlib2.iface.value.FloatEncodedValue; +import org.jf.dexlib2.iface.value.IntEncodedValue; +import org.jf.dexlib2.iface.value.LongEncodedValue; +import org.jf.dexlib2.iface.value.MethodEncodedValue; +import org.jf.dexlib2.iface.value.ShortEncodedValue; +import org.jf.dexlib2.iface.value.StringEncodedValue; +import org.jf.dexlib2.iface.value.TypeEncodedValue; import com.ibm.wala.shrikeCT.AnnotationsReader.AnnotationAttribute; import com.ibm.wala.shrikeCT.AnnotationsReader.ArrayElementValue; @@ -44,25 +58,21 @@ import com.ibm.wala.util.strings.ImmutableByteArray; public class DexUtil { - static Collection getAnnotations(Collection as, ClassLoaderReference clr) { + static Collection getAnnotations(Collection as, ClassLoaderReference clr) { Collection result = HashSetFactory.make(); - for(AnnotationItem a : as) { + for(org.jf.dexlib2.iface.Annotation a : as) { result.add(getAnnotation(a, clr)); } return result; } - - static Annotation getAnnotation(AnnotationItem a, ClassLoaderReference clr) { - return getAnnotation(a.getEncodedAnnotation(), clr); - } - - static Annotation getAnnotation(AnnotationEncodedSubValue ea, ClassLoaderReference clr) { + + static Annotation getAnnotation(org.jf.dexlib2.iface.Annotation ea, ClassLoaderReference clr) { Map values = HashMapFactory.make(); - TypeReference at = getTypeRef(ea.annotationType, clr); - - for(int i = 0; i < ea.names.length; i++) { - String name = ea.names[i].getStringValue(); - EncodedValue v = ea.values[i]; + TypeReference at = getTypeRef(ea.getType(), clr); + + for(AnnotationElement elt : ea.getElements()) { + String name = elt.getName(); + EncodedValue v = elt.getValue(); ElementValue value = getValue(clr, v); values.put(name, value); } @@ -72,77 +82,89 @@ public class DexUtil { static ElementValue getValue(ClassLoaderReference clr, EncodedValue v) { switch (v.getValueType()) { - case VALUE_ANNOTATION: - Annotation a = getAnnotation((AnnotationEncodedSubValue)v, clr); - return new AnnotationAttribute(a.getType().getName().toString() +";", a.getNamedArguments()); + case ANNOTATION: { + Map values = HashMapFactory.make(); + String at = ((AnnotationEncodedValue)v).getType(); - case VALUE_ARRAY: - EncodedValue[] vs = ((ArrayEncodedValue)v).values; - ElementValue rs[] = new ElementValue[ vs.length ]; - for(int idx = 0; idx < vs.length; idx++) { - rs[idx] = getValue(clr, vs[idx]); + for(AnnotationElement elt : ((AnnotationEncodedValue)v).getElements()) { + String name = elt.getName(); + EncodedValue ev = elt.getValue(); + ElementValue value = getValue(clr, ev); + values.put(name, value); + } + + return new AnnotationAttribute(at, values); + } + + case ARRAY: { + List vs = ((ArrayEncodedValue)v).getValue(); + ElementValue[] rs = new ElementValue[ vs.size() ]; + int idx = 0; + for(EncodedValue ev : vs) { + rs[idx++] = getValue(clr, ev); } return new ArrayElementValue(rs); - - case VALUE_BOOLEAN: - Boolean bl = ((BooleanEncodedValue)v).value; + } + + case BOOLEAN: + Boolean bl = ((BooleanEncodedValue)v).getValue(); return new ConstantElementValue(bl); - case VALUE_BYTE: - Byte bt = ((ByteEncodedValue)v).value; + case BYTE: + Byte bt = ((ByteEncodedValue)v).getValue(); return new ConstantElementValue(bt); - case VALUE_CHAR: - Character c = ((CharEncodedValue)v).value; + case CHAR: + Character c = ((CharEncodedValue)v).getValue(); return new ConstantElementValue(c); - case VALUE_DOUBLE: - Double d = ((DoubleEncodedValue)v).value; + case DOUBLE: + Double d = ((DoubleEncodedValue)v).getValue(); return new ConstantElementValue(d); - case VALUE_ENUM: - FieldIdItem o = ((EnumEncodedValue)v).value; - return new EnumElementValue(o.getFieldType().getTypeDescriptor(), o.getFieldName().getStringValue()); + case ENUM: + org.jf.dexlib2.iface.reference.FieldReference o = ((EnumEncodedValue)v).getValue(); + return new EnumElementValue(o.getType(), o.getName()); - case VALUE_FIELD: - o = v.getValueType()==ValueType.VALUE_ENUM? ((EnumEncodedValue)v).value: ((FieldEncodedValue)v).value; - String fieldName = o.getFieldName().getStringValue(); - TypeReference ft = getTypeRef(o.getFieldType(), clr); - TypeReference ct = getTypeRef(o.getContainingClass(), clr); + case FIELD: + o = v.getValueType()==ENUM? ((EnumEncodedValue)v).getValue(): ((FieldEncodedValue)v).getValue(); + String fieldName = o.getName(); + TypeReference ft = getTypeRef(o.getType(), clr); + TypeReference ct = getTypeRef(o.getDefiningClass(), clr); return new ConstantElementValue(FieldReference.findOrCreate(ct, Atom.findOrCreateUnicodeAtom(fieldName), ft)); - case VALUE_FLOAT: - Float f = ((FloatEncodedValue)v).value; + case FLOAT: + Float f = ((FloatEncodedValue)v).getValue(); return new ConstantElementValue(f); - case VALUE_INT: - Integer iv = ((IntEncodedValue)v).value; + case INT: + Integer iv = ((IntEncodedValue)v).getValue(); return new ConstantElementValue(iv); - case VALUE_LONG: - Long l = ((LongEncodedValue)v).value; + case LONG: + Long l = ((LongEncodedValue)v).getValue(); return new ConstantElementValue(l); - case VALUE_METHOD: - MethodIdItem m = ((MethodEncodedValue)v).value; - ct = getTypeRef(m.getContainingClass(), clr); - String methodName = m.getMethodName().getStringValue(); - String methodSig = m.getPrototype().getPrototypeString(); + case METHOD: + org.jf.dexlib2.iface.reference.MethodReference m = ((MethodEncodedValue)v).getValue(); + ct = getTypeRef(m.getDefiningClass(), clr); + String methodName = m.getName(); + String methodSig = getSignature(m); return new ConstantElementValue(MethodReference.findOrCreate(ct, Atom.findOrCreateUnicodeAtom(methodName), Descriptor.findOrCreateUTF8(methodSig))); - case VALUE_NULL: + case NULL: return new ConstantElementValue(null); - case VALUE_SHORT: - Short s = ((ShortEncodedValue)v).value; + case SHORT: + Short s = ((ShortEncodedValue)v).getValue(); return new ConstantElementValue(s); - case VALUE_STRING: - String str = ((StringEncodedValue)v).value.getStringValue(); + case STRING: + String str = ((StringEncodedValue)v).getValue(); return new ConstantElementValue(str); - case VALUE_TYPE: - TypeIdItem t = ((TypeEncodedValue)v).value; + case TYPE: + String t = ((TypeEncodedValue)v).getValue(); return new ConstantElementValue(getTypeName(t) + ";"); default: @@ -151,12 +173,21 @@ public class DexUtil { } } - static TypeReference getTypeRef(TypeIdItem type, ClassLoaderReference clr) { + static String getSignature(org.jf.dexlib2.iface.reference.MethodReference ref) { + StringBuilder sig = new StringBuilder("("); + for(CharSequence p : ref.getParameterTypes()) { + sig = sig.append(p); + } + sig.append(')').append(ref.getReturnType()); + return sig.toString(); + } + + static TypeReference getTypeRef(String type, ClassLoaderReference clr) { return TypeReference.findOrCreate(clr, getTypeName(type)); } - static TypeName getTypeName(TypeIdItem fieldType) { - ImmutableByteArray fieldTypeArray = ImmutableByteArray.make(fieldType.getTypeDescriptor()); + static TypeName getTypeName(String fieldType) { + ImmutableByteArray fieldTypeArray = ImmutableByteArray.make(fieldType); TypeName T = null; if (fieldTypeArray.get(fieldTypeArray.length() - 1) == ';') { T = TypeName.findOrCreate(fieldTypeArray, 0, fieldTypeArray.length() - 1); diff --git a/com.ibm.wala.dalvik/src/com/ibm/wala/dalvik/dex/instructions/ArrayFill.java b/com.ibm.wala.dalvik/src/com/ibm/wala/dalvik/dex/instructions/ArrayFill.java index 3ebe648cd..6f8bfc269 100644 --- a/com.ibm.wala.dalvik/src/com/ibm/wala/dalvik/dex/instructions/ArrayFill.java +++ b/com.ibm.wala.dalvik/src/com/ibm/wala/dalvik/dex/instructions/ArrayFill.java @@ -51,8 +51,8 @@ */ package com.ibm.wala.dalvik.dex.instructions; -import org.jf.dexlib.Code.Opcode; -import org.jf.dexlib.Code.Format.ArrayDataPseudoInstruction; +import org.jf.dexlib2.Opcode; +import org.jf.dexlib2.iface.instruction.formats.ArrayPayload; import com.ibm.wala.dalvik.classLoader.DexIMethod; import com.ibm.wala.types.TypeReference; @@ -63,7 +63,7 @@ public class ArrayFill extends Instruction { public final int array; public final int tableAddressOffset; public int registerIndex; - private ArrayDataPseudoInstruction table; + private ArrayPayload table; public final TypeReference type; @@ -85,16 +85,16 @@ public class ArrayFill extends Instruction { } - public void setArrayDataTable(ArrayDataPseudoInstruction table) { - this.table = table; + public void setArrayDataTable(ArrayPayload inst) { + this.table = inst; } - public ArrayDataPseudoInstruction getTable() { + public ArrayPayload getTable() { return table; } public int getElementCount() { - return table.getElementCount(); + return table.getArrayElements().size(); } public TypeReference getType() { diff --git a/com.ibm.wala.dalvik/src/com/ibm/wala/dalvik/dex/instructions/ArrayGet.java b/com.ibm.wala.dalvik/src/com/ibm/wala/dalvik/dex/instructions/ArrayGet.java index 5857671cd..a31545584 100644 --- a/com.ibm.wala.dalvik/src/com/ibm/wala/dalvik/dex/instructions/ArrayGet.java +++ b/com.ibm.wala.dalvik/src/com/ibm/wala/dalvik/dex/instructions/ArrayGet.java @@ -48,7 +48,7 @@ package com.ibm.wala.dalvik.dex.instructions; -import org.jf.dexlib.Code.Opcode; +import org.jf.dexlib2.Opcode; import com.ibm.wala.dalvik.classLoader.DexIMethod; import com.ibm.wala.types.TypeReference; diff --git a/com.ibm.wala.dalvik/src/com/ibm/wala/dalvik/dex/instructions/ArrayLength.java b/com.ibm.wala.dalvik/src/com/ibm/wala/dalvik/dex/instructions/ArrayLength.java index fc5f83e56..f083ca18a 100644 --- a/com.ibm.wala.dalvik/src/com/ibm/wala/dalvik/dex/instructions/ArrayLength.java +++ b/com.ibm.wala.dalvik/src/com/ibm/wala/dalvik/dex/instructions/ArrayLength.java @@ -48,7 +48,7 @@ package com.ibm.wala.dalvik.dex.instructions; -import org.jf.dexlib.Code.Opcode; +import org.jf.dexlib2.Opcode; import com.ibm.wala.dalvik.classLoader.DexIMethod; diff --git a/com.ibm.wala.dalvik/src/com/ibm/wala/dalvik/dex/instructions/ArrayPut.java b/com.ibm.wala.dalvik/src/com/ibm/wala/dalvik/dex/instructions/ArrayPut.java index 21f52fd79..248fdae05 100644 --- a/com.ibm.wala.dalvik/src/com/ibm/wala/dalvik/dex/instructions/ArrayPut.java +++ b/com.ibm.wala.dalvik/src/com/ibm/wala/dalvik/dex/instructions/ArrayPut.java @@ -48,7 +48,7 @@ package com.ibm.wala.dalvik.dex.instructions; -import org.jf.dexlib.Code.Opcode; +import org.jf.dexlib2.Opcode; import com.ibm.wala.dalvik.classLoader.DexIMethod; import com.ibm.wala.dalvik.dex.instructions.ArrayGet.Type; diff --git a/com.ibm.wala.dalvik/src/com/ibm/wala/dalvik/dex/instructions/BinaryLiteralOperation.java b/com.ibm.wala.dalvik/src/com/ibm/wala/dalvik/dex/instructions/BinaryLiteralOperation.java index 9d8fbbd97..0175f5660 100644 --- a/com.ibm.wala.dalvik/src/com/ibm/wala/dalvik/dex/instructions/BinaryLiteralOperation.java +++ b/com.ibm.wala.dalvik/src/com/ibm/wala/dalvik/dex/instructions/BinaryLiteralOperation.java @@ -48,7 +48,7 @@ package com.ibm.wala.dalvik.dex.instructions; -import org.jf.dexlib.Code.Opcode; +import org.jf.dexlib2.Opcode; import com.ibm.wala.cast.ir.ssa.CAstBinaryOp; import com.ibm.wala.dalvik.classLoader.DexIMethod; diff --git a/com.ibm.wala.dalvik/src/com/ibm/wala/dalvik/dex/instructions/BinaryOperation.java b/com.ibm.wala.dalvik/src/com/ibm/wala/dalvik/dex/instructions/BinaryOperation.java index 39841a004..4bd4682f8 100644 --- a/com.ibm.wala.dalvik/src/com/ibm/wala/dalvik/dex/instructions/BinaryOperation.java +++ b/com.ibm.wala.dalvik/src/com/ibm/wala/dalvik/dex/instructions/BinaryOperation.java @@ -48,7 +48,7 @@ package com.ibm.wala.dalvik.dex.instructions; -import org.jf.dexlib.Code.Opcode; +import org.jf.dexlib2.Opcode; import com.ibm.wala.cast.ir.ssa.CAstBinaryOp; import com.ibm.wala.dalvik.classLoader.DexIMethod; @@ -84,10 +84,8 @@ public class BinaryOperation extends Instruction { visitor.visitBinaryOperation(this); } - public IBinaryOpInstruction.IOperator getOperator() - { - switch(op) - { + public IBinaryOpInstruction.IOperator getOperator() { + switch(op) { case CMPL_FLOAT: return CAstBinaryOp.LT; case CMPG_FLOAT: @@ -196,28 +194,20 @@ public class BinaryOperation extends Instruction { } public boolean isUnsigned() { - - /** - * At the moment, WALA asserts that false is returned here. Maybe WALA will support unsigned - * arithmetic in its IR some time in the future - then the commented code will make sense. - */ - return false; -// switch(op) -// { -// case AND_INT: -// case OR_INT: -// case XOR_INT: -// case SHL_INT: -// case USHR_INT: -// case AND_LONG: -// case OR_LONG: -// case XOR_LONG: -// case SHL_LONG: -// case USHR_LONG: -// return true; -// default: -// return false; -// } + switch(op) { + case AND_INT: + case OR_INT: + case XOR_INT: + case SHL_INT: + case USHR_INT: + case AND_LONG: + case OR_LONG: + case XOR_LONG: + case SHL_LONG: + case USHR_LONG: + return true; + default: + return false; + } } - } diff --git a/com.ibm.wala.dalvik/src/com/ibm/wala/dalvik/dex/instructions/Branch.java b/com.ibm.wala.dalvik/src/com/ibm/wala/dalvik/dex/instructions/Branch.java index a8bac5e45..fb5b4e440 100644 --- a/com.ibm.wala.dalvik/src/com/ibm/wala/dalvik/dex/instructions/Branch.java +++ b/com.ibm.wala.dalvik/src/com/ibm/wala/dalvik/dex/instructions/Branch.java @@ -48,7 +48,7 @@ package com.ibm.wala.dalvik.dex.instructions; -import org.jf.dexlib.Code.Opcode; +import org.jf.dexlib2.Opcode; import com.ibm.wala.dalvik.classLoader.DexIMethod; import com.ibm.wala.shrikeBT.IConditionalBranchInstruction; diff --git a/com.ibm.wala.dalvik/src/com/ibm/wala/dalvik/dex/instructions/CheckCast.java b/com.ibm.wala.dalvik/src/com/ibm/wala/dalvik/dex/instructions/CheckCast.java index 3046b95dd..c51fb5abe 100644 --- a/com.ibm.wala.dalvik/src/com/ibm/wala/dalvik/dex/instructions/CheckCast.java +++ b/com.ibm.wala.dalvik/src/com/ibm/wala/dalvik/dex/instructions/CheckCast.java @@ -48,7 +48,7 @@ package com.ibm.wala.dalvik.dex.instructions; -import org.jf.dexlib.Code.Opcode; +import org.jf.dexlib2.Opcode; import com.ibm.wala.dalvik.classLoader.DexIMethod; import com.ibm.wala.types.TypeReference; diff --git a/com.ibm.wala.dalvik/src/com/ibm/wala/dalvik/dex/instructions/Constant.java b/com.ibm.wala.dalvik/src/com/ibm/wala/dalvik/dex/instructions/Constant.java index 9c56682a9..a9761f8bd 100644 --- a/com.ibm.wala.dalvik/src/com/ibm/wala/dalvik/dex/instructions/Constant.java +++ b/com.ibm.wala.dalvik/src/com/ibm/wala/dalvik/dex/instructions/Constant.java @@ -48,7 +48,7 @@ package com.ibm.wala.dalvik.dex.instructions; -import org.jf.dexlib.Code.Opcode; +import org.jf.dexlib2.Opcode; import com.ibm.wala.dalvik.classLoader.DexIMethod; import com.ibm.wala.types.TypeReference; diff --git a/com.ibm.wala.dalvik/src/com/ibm/wala/dalvik/dex/instructions/GetField.java b/com.ibm.wala.dalvik/src/com/ibm/wala/dalvik/dex/instructions/GetField.java index 89a54e8e3..80f811693 100644 --- a/com.ibm.wala.dalvik/src/com/ibm/wala/dalvik/dex/instructions/GetField.java +++ b/com.ibm.wala.dalvik/src/com/ibm/wala/dalvik/dex/instructions/GetField.java @@ -48,7 +48,7 @@ package com.ibm.wala.dalvik.dex.instructions; -import org.jf.dexlib.Code.Opcode; +import org.jf.dexlib2.Opcode; import com.ibm.wala.dalvik.classLoader.DexIMethod; diff --git a/com.ibm.wala.dalvik/src/com/ibm/wala/dalvik/dex/instructions/Goto.java b/com.ibm.wala.dalvik/src/com/ibm/wala/dalvik/dex/instructions/Goto.java index ee181ff53..cf1b55794 100644 --- a/com.ibm.wala.dalvik/src/com/ibm/wala/dalvik/dex/instructions/Goto.java +++ b/com.ibm.wala.dalvik/src/com/ibm/wala/dalvik/dex/instructions/Goto.java @@ -48,7 +48,7 @@ package com.ibm.wala.dalvik.dex.instructions; -import org.jf.dexlib.Code.Opcode; +import org.jf.dexlib2.Opcode; import com.ibm.wala.dalvik.classLoader.DexIMethod; diff --git a/com.ibm.wala.dalvik/src/com/ibm/wala/dalvik/dex/instructions/InstanceOf.java b/com.ibm.wala.dalvik/src/com/ibm/wala/dalvik/dex/instructions/InstanceOf.java index b83115bfb..fb03a6161 100644 --- a/com.ibm.wala.dalvik/src/com/ibm/wala/dalvik/dex/instructions/InstanceOf.java +++ b/com.ibm.wala.dalvik/src/com/ibm/wala/dalvik/dex/instructions/InstanceOf.java @@ -48,7 +48,7 @@ package com.ibm.wala.dalvik.dex.instructions; -import org.jf.dexlib.Code.Opcode; +import org.jf.dexlib2.Opcode; import com.ibm.wala.dalvik.classLoader.DexIMethod; import com.ibm.wala.types.TypeReference; diff --git a/com.ibm.wala.dalvik/src/com/ibm/wala/dalvik/dex/instructions/Instruction.java b/com.ibm.wala.dalvik/src/com/ibm/wala/dalvik/dex/instructions/Instruction.java index fb9c387ac..d2f0fab42 100644 --- a/com.ibm.wala.dalvik/src/com/ibm/wala/dalvik/dex/instructions/Instruction.java +++ b/com.ibm.wala.dalvik/src/com/ibm/wala/dalvik/dex/instructions/Instruction.java @@ -48,7 +48,7 @@ package com.ibm.wala.dalvik.dex.instructions; -import org.jf.dexlib.Code.Opcode; +import org.jf.dexlib2.Opcode; import com.ibm.wala.dalvik.classLoader.DexIMethod; @@ -146,7 +146,7 @@ public abstract class Instruction { * True if the instruction can continue. * @see com.ibm.wala.shrikeBT.IInstruction#isFallThrough() */ - public boolean isFallThrough() { + public boolean isFallThrough() { return opcode.canContinue(); } @@ -154,7 +154,7 @@ public abstract class Instruction { * True if the instruction can throw an exception * @see com.ibm.wala.shrikeBT.IInstruction#isPEI() */ - public boolean isPEI() { + public boolean isPEI() { return opcode.canThrow(); } @@ -172,12 +172,10 @@ public abstract class Instruction { return opcode; } - public int[] getBranchTargets() { + public int[] getBranchTargets() { return noInstructions; } - - public abstract void visit(Visitor visitor); } diff --git a/com.ibm.wala.dalvik/src/com/ibm/wala/dalvik/dex/instructions/Invoke.java b/com.ibm.wala.dalvik/src/com/ibm/wala/dalvik/dex/instructions/Invoke.java index d7d3a26d6..d9c9ff22c 100644 --- a/com.ibm.wala.dalvik/src/com/ibm/wala/dalvik/dex/instructions/Invoke.java +++ b/com.ibm.wala.dalvik/src/com/ibm/wala/dalvik/dex/instructions/Invoke.java @@ -48,11 +48,12 @@ package com.ibm.wala.dalvik.dex.instructions; -import org.jf.dexlib.Code.Opcode; +import org.jf.dexlib2.Opcode; import com.ibm.wala.dalvik.classLoader.DexIMethod; import com.ibm.wala.shrikeBT.IInvokeInstruction; import com.ibm.wala.shrikeBT.IInvokeInstruction.IDispatch; +import com.ibm.wala.types.Descriptor; public abstract class Invoke extends Instruction { @@ -68,6 +69,8 @@ public abstract class Invoke extends Instruction { this.methodName = methodName; this.descriptor = descriptor; this.args = args; + + assert Descriptor.findOrCreateUTF8(descriptor) != null; } public static class InvokeVirtual extends Invoke diff --git a/com.ibm.wala.dalvik/src/com/ibm/wala/dalvik/dex/instructions/Monitor.java b/com.ibm.wala.dalvik/src/com/ibm/wala/dalvik/dex/instructions/Monitor.java index 2cea2fa64..115678627 100644 --- a/com.ibm.wala.dalvik/src/com/ibm/wala/dalvik/dex/instructions/Monitor.java +++ b/com.ibm.wala.dalvik/src/com/ibm/wala/dalvik/dex/instructions/Monitor.java @@ -48,7 +48,7 @@ package com.ibm.wala.dalvik.dex.instructions; -import org.jf.dexlib.Code.Opcode; +import org.jf.dexlib2.Opcode; import com.ibm.wala.dalvik.classLoader.DexIMethod; diff --git a/com.ibm.wala.dalvik/src/com/ibm/wala/dalvik/dex/instructions/New.java b/com.ibm.wala.dalvik/src/com/ibm/wala/dalvik/dex/instructions/New.java index d43d0fa94..06356bea4 100644 --- a/com.ibm.wala.dalvik/src/com/ibm/wala/dalvik/dex/instructions/New.java +++ b/com.ibm.wala.dalvik/src/com/ibm/wala/dalvik/dex/instructions/New.java @@ -48,7 +48,7 @@ package com.ibm.wala.dalvik.dex.instructions; -import org.jf.dexlib.Code.Opcode; +import org.jf.dexlib2.Opcode; import com.ibm.wala.classLoader.NewSiteReference; import com.ibm.wala.dalvik.classLoader.DexIMethod; diff --git a/com.ibm.wala.dalvik/src/com/ibm/wala/dalvik/dex/instructions/NewArray.java b/com.ibm.wala.dalvik/src/com/ibm/wala/dalvik/dex/instructions/NewArray.java index 0ca641d01..5fd0f323b 100644 --- a/com.ibm.wala.dalvik/src/com/ibm/wala/dalvik/dex/instructions/NewArray.java +++ b/com.ibm.wala.dalvik/src/com/ibm/wala/dalvik/dex/instructions/NewArray.java @@ -48,7 +48,7 @@ package com.ibm.wala.dalvik.dex.instructions; -import org.jf.dexlib.Code.Opcode; +import org.jf.dexlib2.Opcode; import com.ibm.wala.classLoader.NewSiteReference; import com.ibm.wala.dalvik.classLoader.DexIMethod; diff --git a/com.ibm.wala.dalvik/src/com/ibm/wala/dalvik/dex/instructions/NewArrayFilled.java b/com.ibm.wala.dalvik/src/com/ibm/wala/dalvik/dex/instructions/NewArrayFilled.java index 91429fb3c..bcaa3af0f 100644 --- a/com.ibm.wala.dalvik/src/com/ibm/wala/dalvik/dex/instructions/NewArrayFilled.java +++ b/com.ibm.wala.dalvik/src/com/ibm/wala/dalvik/dex/instructions/NewArrayFilled.java @@ -48,7 +48,7 @@ package com.ibm.wala.dalvik.dex.instructions; -import org.jf.dexlib.Code.Opcode; +import org.jf.dexlib2.Opcode; import com.ibm.wala.classLoader.NewSiteReference; import com.ibm.wala.dalvik.classLoader.DexIMethod; diff --git a/com.ibm.wala.dalvik/src/com/ibm/wala/dalvik/dex/instructions/PackedSwitchPad.java b/com.ibm.wala.dalvik/src/com/ibm/wala/dalvik/dex/instructions/PackedSwitchPad.java index 610c3d7e8..876264de0 100644 --- a/com.ibm.wala.dalvik/src/com/ibm/wala/dalvik/dex/instructions/PackedSwitchPad.java +++ b/com.ibm.wala.dalvik/src/com/ibm/wala/dalvik/dex/instructions/PackedSwitchPad.java @@ -48,19 +48,26 @@ package com.ibm.wala.dalvik.dex.instructions; -import org.jf.dexlib.Code.Format.PackedSwitchDataPseudoInstruction; +import org.jf.dexlib2.iface.instruction.SwitchElement; +import org.jf.dexlib2.iface.instruction.SwitchPayload; public class PackedSwitchPad implements SwitchPad { - public final int firstValue; + public int firstValue; public final int[] offsets; public final int defaultOffset; private int [] labelsAndOffsets; private int[] values; - public PackedSwitchPad(PackedSwitchDataPseudoInstruction s, int defaultOffset) { - this.firstValue = s.getFirstKey(); - this.offsets = s.getTargets(); + public PackedSwitchPad(SwitchPayload inst, int defaultOffset) { + int i = 0; + this.offsets = new int[inst.getSwitchElements().size()]; + for(SwitchElement elt : inst.getSwitchElements()) { + if (i == 0) { + firstValue = elt.getKey(); + } + offsets[i++] = elt.getOffset(); + } this.defaultOffset = defaultOffset; } diff --git a/com.ibm.wala.dalvik/src/com/ibm/wala/dalvik/dex/instructions/PutField.java b/com.ibm.wala.dalvik/src/com/ibm/wala/dalvik/dex/instructions/PutField.java index 1aa72a3e1..3b94da71c 100644 --- a/com.ibm.wala.dalvik/src/com/ibm/wala/dalvik/dex/instructions/PutField.java +++ b/com.ibm.wala.dalvik/src/com/ibm/wala/dalvik/dex/instructions/PutField.java @@ -48,7 +48,7 @@ package com.ibm.wala.dalvik.dex.instructions; -import org.jf.dexlib.Code.Opcode; +import org.jf.dexlib2.Opcode; import com.ibm.wala.dalvik.classLoader.DexIMethod; diff --git a/com.ibm.wala.dalvik/src/com/ibm/wala/dalvik/dex/instructions/Return.java b/com.ibm.wala.dalvik/src/com/ibm/wala/dalvik/dex/instructions/Return.java index 830b30bbd..286c2c5d1 100644 --- a/com.ibm.wala.dalvik/src/com/ibm/wala/dalvik/dex/instructions/Return.java +++ b/com.ibm.wala.dalvik/src/com/ibm/wala/dalvik/dex/instructions/Return.java @@ -48,7 +48,7 @@ package com.ibm.wala.dalvik.dex.instructions; -import org.jf.dexlib.Code.Opcode; +import org.jf.dexlib2.Opcode; import com.ibm.wala.dalvik.classLoader.DexIMethod; diff --git a/com.ibm.wala.dalvik/src/com/ibm/wala/dalvik/dex/instructions/SparseSwitchPad.java b/com.ibm.wala.dalvik/src/com/ibm/wala/dalvik/dex/instructions/SparseSwitchPad.java index b1a3579bc..aa53bf7ef 100644 --- a/com.ibm.wala.dalvik/src/com/ibm/wala/dalvik/dex/instructions/SparseSwitchPad.java +++ b/com.ibm.wala.dalvik/src/com/ibm/wala/dalvik/dex/instructions/SparseSwitchPad.java @@ -48,7 +48,8 @@ package com.ibm.wala.dalvik.dex.instructions; -import org.jf.dexlib.Code.Format.SparseSwitchDataPseudoInstruction; +import org.jf.dexlib2.iface.instruction.SwitchElement; +import org.jf.dexlib2.iface.instruction.SwitchPayload; public class SparseSwitchPad implements SwitchPad { @@ -57,10 +58,15 @@ public class SparseSwitchPad implements SwitchPad { public final int defaultOffset; private int [] labelsAndOffsets; - public SparseSwitchPad(SparseSwitchDataPseudoInstruction s, int defaultOffset) + public SparseSwitchPad(SwitchPayload inst, int defaultOffset) { - this.values = s.getKeys(); - this.offsets = s.getTargets(); + int i = 0; + this.values = new int[ inst.getSwitchElements().size() ]; + this.offsets = new int[ inst.getSwitchElements().size() ]; + for(SwitchElement elt : inst.getSwitchElements()) { + values[i] = elt.getKey(); + offsets[i++] = elt.getOffset(); + } this.defaultOffset = defaultOffset; } diff --git a/com.ibm.wala.dalvik/src/com/ibm/wala/dalvik/dex/instructions/Switch.java b/com.ibm.wala.dalvik/src/com/ibm/wala/dalvik/dex/instructions/Switch.java index fbc6c12ea..dee35b02a 100644 --- a/com.ibm.wala.dalvik/src/com/ibm/wala/dalvik/dex/instructions/Switch.java +++ b/com.ibm.wala.dalvik/src/com/ibm/wala/dalvik/dex/instructions/Switch.java @@ -48,7 +48,7 @@ package com.ibm.wala.dalvik.dex.instructions; -import org.jf.dexlib.Code.Opcode; +import org.jf.dexlib2.Opcode; import com.ibm.wala.dalvik.classLoader.DexIMethod; diff --git a/com.ibm.wala.dalvik/src/com/ibm/wala/dalvik/dex/instructions/Throw.java b/com.ibm.wala.dalvik/src/com/ibm/wala/dalvik/dex/instructions/Throw.java index bb91b6464..2bce7eca9 100644 --- a/com.ibm.wala.dalvik/src/com/ibm/wala/dalvik/dex/instructions/Throw.java +++ b/com.ibm.wala.dalvik/src/com/ibm/wala/dalvik/dex/instructions/Throw.java @@ -48,7 +48,7 @@ package com.ibm.wala.dalvik.dex.instructions; -import org.jf.dexlib.Code.Opcode; +import org.jf.dexlib2.Opcode; import com.ibm.wala.dalvik.classLoader.DexIMethod; diff --git a/com.ibm.wala.dalvik/src/com/ibm/wala/dalvik/dex/instructions/UnaryOperation.java b/com.ibm.wala.dalvik/src/com/ibm/wala/dalvik/dex/instructions/UnaryOperation.java index d6319b7cd..84f29573a 100644 --- a/com.ibm.wala.dalvik/src/com/ibm/wala/dalvik/dex/instructions/UnaryOperation.java +++ b/com.ibm.wala.dalvik/src/com/ibm/wala/dalvik/dex/instructions/UnaryOperation.java @@ -48,7 +48,7 @@ package com.ibm.wala.dalvik.dex.instructions; -import org.jf.dexlib.Code.Opcode; +import org.jf.dexlib2.Opcode; import com.ibm.wala.cast.ir.ssa.CAstUnaryOp; import com.ibm.wala.dalvik.classLoader.DexIMethod; diff --git a/com.ibm.wala.dalvik/src/com/ibm/wala/dalvik/ssa/DexSSABuilder.java b/com.ibm.wala.dalvik/src/com/ibm/wala/dalvik/ssa/DexSSABuilder.java index e9837da22..c1b839cb6 100644 --- a/com.ibm.wala.dalvik/src/com/ibm/wala/dalvik/ssa/DexSSABuilder.java +++ b/com.ibm.wala.dalvik/src/com/ibm/wala/dalvik/ssa/DexSSABuilder.java @@ -11,11 +11,8 @@ *******************************************************************************/ package com.ibm.wala.dalvik.ssa; -import java.nio.ByteBuffer; import java.util.Iterator; -import org.jf.dexlib.Code.Format.ArrayDataPseudoInstruction.ArrayElement; - import com.ibm.wala.cfg.IBasicBlock; import com.ibm.wala.classLoader.CallSiteReference; import com.ibm.wala.classLoader.Language; @@ -480,46 +477,38 @@ public class DexSSABuilder extends AbstractIntRegisterMachine { @Override public void visitArrayFill(ArrayFill instruction) { - - Iterator iae = instruction.getTable().getElements(); + int ElementWidth = instruction.getTable().getElementWidth(); + Iterator iae = instruction.getTable().getArrayElements().iterator(); int i = 0; while (iae.hasNext()) { - ArrayElement ae = iae.next(); - int ElementWidth = ae.elementWidth; - + Number ae = iae.next(); int index = symbolTable.getConstant(i); int arrayRef = workingState.getLocal(instruction.array); TypeReference t = instruction.getType(); // System.out.println(t.getName().toString()); int value; - - //fetch the byte[] array for the element - byte[] temp_byte = new byte[ElementWidth]; - for (int j = 0; j < ElementWidth; j++) - temp_byte[j] = ae.buffer[ae.bufferIndex+(ElementWidth-1)-j]; - ByteBuffer byte_buffer = ByteBuffer.wrap(temp_byte); // // System.out.println("Index: " + ae.bufferIndex + ", Width: " + ae.elementWidth + ", Value: " + byte_buffer.getSomethingDependingonType ); //okay to call the getConstant(String) for a char? if (t.equals(TypeReference.Char)) - value = symbolTable.getConstant(Character.toString(byte_buffer.getChar())); + value = symbolTable.getConstant((char) ae.intValue()); else if (t.equals(TypeReference.Byte)) - value = symbolTable.getConstant(byte_buffer.get()); + value = symbolTable.getConstant(ae.byteValue()); else if (t.equals(TypeReference.Short)) - value = symbolTable.getConstant(byte_buffer.getShort()); + value = symbolTable.getConstant(ae.shortValue()); else if (t.equals(TypeReference.Int)) - value = symbolTable.getConstant(byte_buffer.getInt()); + value = symbolTable.getConstant(ae.intValue()); else if (t.equals(TypeReference.Long)) - value = symbolTable.getConstant(byte_buffer.getLong()); + value = symbolTable.getConstant(ae.longValue()); else if (t.equals(TypeReference.Float)) - value = symbolTable.getConstant(byte_buffer.getFloat()); + value = symbolTable.getConstant(ae.floatValue()); else if (t.equals(TypeReference.Double)) - value = symbolTable.getConstant(byte_buffer.getDouble()); + value = symbolTable.getConstant(ae.doubleValue()); else if (t.equals(TypeReference.Boolean)) - value = symbolTable.getConstant((byte_buffer.get() == 1)?true:false); + value = symbolTable.getConstant(ae.intValue() != 0); else { diff --git a/com.ibm.wala.util/src/com/ibm/wala/util/collections/AbstractMultiMap.java b/com.ibm.wala.util/src/com/ibm/wala/util/collections/AbstractMultiMap.java index ec483e96c..f696ae6cb 100644 --- a/com.ibm.wala.util/src/com/ibm/wala/util/collections/AbstractMultiMap.java +++ b/com.ibm.wala.util/src/com/ibm/wala/util/collections/AbstractMultiMap.java @@ -37,13 +37,14 @@ */ package com.ibm.wala.util.collections; +import java.io.Serializable; import java.util.Collection; import java.util.Collections; import java.util.Map; import java.util.Set; -abstract class AbstractMultiMap implements MultiMap { +abstract class AbstractMultiMap implements Serializable, MultiMap { protected final Map> map = HashMapFactory.make(); diff --git a/com.ibm.wala.util/src/com/ibm/wala/util/graph/labeled/SparseNumberedLabeledEdgeManager.java b/com.ibm.wala.util/src/com/ibm/wala/util/graph/labeled/SparseNumberedLabeledEdgeManager.java index 4d094da81..039c0f506 100644 --- a/com.ibm.wala.util/src/com/ibm/wala/util/graph/labeled/SparseNumberedLabeledEdgeManager.java +++ b/com.ibm.wala.util/src/com/ibm/wala/util/graph/labeled/SparseNumberedLabeledEdgeManager.java @@ -48,6 +48,7 @@ */ package com.ibm.wala.util.graph.labeled; +import java.io.Serializable; import java.util.Collection; import java.util.Iterator; import java.util.Map; @@ -64,7 +65,7 @@ import com.ibm.wala.util.intset.IntSet; /** */ -public class SparseNumberedLabeledEdgeManager implements NumberedLabeledEdgeManager { +public class SparseNumberedLabeledEdgeManager implements Serializable, NumberedLabeledEdgeManager { /** * the label to be attached to an edge when no label is specified diff --git a/pom.xml b/pom.xml index bea1eab19..5d2e289d9 100644 --- a/pom.xml +++ b/pom.xml @@ -249,11 +249,11 @@ - aggregate + javadoc - aggregate + javadoc - generate-sources + generate-resources diff --git a/targets/pom.xml b/targets/pom.xml index 8d3281364..3e15ec6d1 100644 --- a/targets/pom.xml +++ b/targets/pom.xml @@ -12,6 +12,6 @@ pom - e44 + e47