@Test public void testInstanceOfNarrowingAfterMove_art() throws IOException { MethodImplementationBuilder builder = new MethodImplementationBuilder(3); builder.addInstruction(new BuilderInstruction12x(Opcode.MOVE_OBJECT, 1, 2)); builder.addInstruction(new BuilderInstruction22c(Opcode.INSTANCE_OF, 0, 1, new ImmutableTypeReference("Lmain;"))); builder.addInstruction(new BuilderInstruction21t(Opcode.IF_EQZ, 0, builder.getLabel("not_instance_of"))); builder.addInstruction(new BuilderInstruction10x(Opcode.RETURN_VOID)); builder.addLabel("not_instance_of"); builder.addInstruction(new BuilderInstruction10x(Opcode.RETURN_VOID)); MethodImplementation methodImplementation = builder.getMethodImplementation(); Method method = new ImmutableMethod("Lmain;", "narrowing", Collections.singletonList(new ImmutableMethodParameter("Ljava/lang/Object;", null, null)), "V", AccessFlags.PUBLIC.getValue(), null, methodImplementation); ClassDef classDef = new ImmutableClassDef("Lmain;", AccessFlags.PUBLIC.getValue(), "Ljava/lang/Object;", null, null, null, null, Collections.singletonList(method)); DexFile dexFile = new ImmutableDexFile(forArtVersion(56), Collections.singletonList(classDef)); ClassPath classPath = new ClassPath(Lists.newArrayList(new DexClassProvider(dexFile)), true, 56); MethodAnalyzer methodAnalyzer = new MethodAnalyzer(classPath, method, null, false); List<AnalyzedInstruction> analyzedInstructions = methodAnalyzer.getAnalyzedInstructions(); Assert.assertEquals("Lmain;", analyzedInstructions.get(3).getPreInstructionRegisterType(1).type.getType()); Assert.assertEquals("Lmain;", analyzedInstructions.get(3).getPreInstructionRegisterType(2).type.getType()); Assert.assertEquals("Ljava/lang/Object;", analyzedInstructions.get(4).getPreInstructionRegisterType(1).type.getType()); Assert.assertEquals("Ljava/lang/Object;", analyzedInstructions.get(4).getPreInstructionRegisterType(2).type.getType()); }
public List<AnalyzedInstruction> getAnalyzedInstructions() { return analyzedInstructions.getValues(); }
MethodAnalyzer { public List<AnalyzedInstruction> getAnalyzedInstructions() { return analyzedInstructions.getValues(); } }
MethodAnalyzer { public List<AnalyzedInstruction> getAnalyzedInstructions() { return analyzedInstructions.getValues(); } MethodAnalyzer(@Nonnull ClassPath classPath, @Nonnull Method method,
                          @Nullable InlineMethodResolver inlineResolver, boolean normalizeVirtualMethods); }
MethodAnalyzer { public List<AnalyzedInstruction> getAnalyzedInstructions() { return analyzedInstructions.getValues(); } MethodAnalyzer(@Nonnull ClassPath classPath, @Nonnull Method method,
                          @Nullable InlineMethodResolver inlineResolver, boolean normalizeVirtualMethods); @Nonnull ClassPath getClassPath(); List<AnalyzedInstruction> getAnalyzedInstructions(); List<Instruction> getInstructions(); @Nullable AnalysisException getAnalysisException(); int getParamRegisterCount(); int getInstructionAddress(@Nonnull AnalyzedInstruction instruction); }
MethodAnalyzer { public List<AnalyzedInstruction> getAnalyzedInstructions() { return analyzedInstructions.getValues(); } MethodAnalyzer(@Nonnull ClassPath classPath, @Nonnull Method method,
                          @Nullable InlineMethodResolver inlineResolver, boolean normalizeVirtualMethods); @Nonnull ClassPath getClassPath(); List<AnalyzedInstruction> getAnalyzedInstructions(); List<Instruction> getInstructions(); @Nullable AnalysisException getAnalysisException(); int getParamRegisterCount(); int getInstructionAddress(@Nonnull AnalyzedInstruction instruction);  }