List of usage examples for org.objectweb.asm Opcodes RETURN
int RETURN
To view the source code for org.objectweb.asm Opcodes RETURN.
Click Source Link
From source file:com.triage.bytecodemaster.GroovyShardTransformer.java
protected boolean isReturnOpCode(int opCode) { return opCode == Opcodes.ARETURN || opCode == Opcodes.LRETURN || opCode == Opcodes.IRETURN || opCode == Opcodes.DRETURN || opCode == Opcodes.FRETURN || opCode == Opcodes.RETURN; }
From source file:com.triage.bytecodemaster.TestObjectReferenceSwitches.java
@Test public void testInjectingIntoMethodWithLotsOfParameters() throws Exception { final String FIELDPROXYWORKED = "FIELDPROXYWORKED"; //set up the proxy object. this is the object that will receive //the proxied calls TestSubClass tcc = new TestSubClass(); tcc.setBaseString(FIELDPROXYWORKED); TestBaseClassHolder.setTestBase(tcc); //get the dynamic source that has the donor body in it ClassNode donorSource = loadGroovyTestClassAsBytecode(GROOVY_CLASS_FIELDREF2); MethodNode donorMethod = findMethod(donorSource, "before_whatDoIThinkAbout"); System.out.println("Donor Method Before Modifications:"); printMethodNode(donorMethod);//from w w w . ja va 2 s .c o m String TARGETCLASSNAME = "com.triage.bytecodemaster.fortesting.Concatenator"; ClassNode targetSource = loadLocalClass(TARGETCLASSNAME); ClassNode exampleSource = loadLocalClass("com.triage.bytecodemaster.fortesting.JustLikeGroovyClass"); MethodNode exampleMethod = findMethod(exampleSource, "before_whatDoIThinkAbout"); System.out.println("Example Method-- Should be just like the Donor Source"); printMethodNode(exampleMethod); MethodNode targetMethod = findMethod(targetSource, "concat"); System.out.println("Target Method <Before Mods>"); printMethodNode(targetMethod); //alright here's the strategy: (1) inject a new local variable that points // to our remote instance, // (2) inject code that sets this local to the value of a method call, // (3) change references to 'this' ( ALOAD0 or ALOAD 0 ) to ALOAD1 InsnList instructionsToInject = donorMethod.instructions; InsnList targetInstructions = targetMethod.instructions; //make a new local variable in the donor method. //this variable needs to have a slot high enough that it doesnt //conflict with either the target or the source method //it will hold references to the objects we replace with 'this' LabelNode begin = new LabelNode(); LabelNode end = new LabelNode(); targetInstructions.insertBefore(targetInstructions.getFirst(), begin); targetInstructions.add(end); Type type = Type.getObjectType("com/triage/bytecodemaster/fortesting/TestBaseClass"); int variableIndex = targetMethod.maxLocals; targetMethod.maxLocals += type.getSize(); targetMethod.visitLocalVariable("proxy", type.getDescriptor(), null, begin.getLabel(), end.getLabel(), variableIndex); //set the value of the local variable with a new instruction at the top //fetch a reference to our proxy object MethodInsnNode getTestBase = new MethodInsnNode(Opcodes.INVOKESTATIC, "com/triage/bytecodemaster/fortesting/TestBaseClassHolder", "getTestBase", "()Lcom/triage/bytecodemaster/fortesting/TestBaseClass;"); //insert after begin label targetInstructions.insert(begin, getTestBase); //store reference VarInsnNode setRef = new VarInsnNode(Opcodes.ASTORE, variableIndex); //insert store after fetch targetInstructions.insert(getTestBase, setRef); //replace all references to 'this' in the DONOR method with the new variable //in the TARGET code for (int currentIndex = 0; currentIndex < instructionsToInject.size(); currentIndex++) { AbstractInsnNode node = instructionsToInject.get(currentIndex); if (node.getOpcode() == Opcodes.ALOAD) { VarInsnNode vin = (VarInsnNode) node; //'this' is var index 0. ours is var index varindex if (vin.var == 0) { vin.var = variableIndex; } } //remove return methods. this will prevent a return. it should cause the donor //method to have parameters that overlap with the target, which has more parameters if (node.getOpcode() == Opcodes.RETURN || node.getOpcode() == Opcodes.ARETURN) { instructionsToInject.remove(node); } } System.out.println(">>>>>>>>>Finished Modifying Donor Method <<<<<<<<"); printMethodNode(donorMethod); String NEWCLASSNAME = "ScriptTestClass"; //stash instructions at the beginning of the original method, //but after populating the new variable targetInstructions.insert(setRef, instructionsToInject); System.out.println("Modified Target:"); printMethodNode(targetMethod); //write a class Class c = createClassFromClassNode(targetSource, TARGETCLASSNAME); Object o = c.newInstance(); Method m = o.getClass().getDeclaredMethod("concat", String.class, String.class, String.class, String.class); //should return HAHAHA not baseStringValue String result = (String) m.invoke(o, new Object[] { "A", "B", "C", "D" }); System.out.println("Concatenator.concat Result: " + result); assertTrue(result.equals("ABCD")); }
From source file:com.trigersoft.jaque.expression.ExpressionClassVisitor.java
License:Apache License
@Override public MethodVisitor visitMethod(int access, String name, String desc, String signature, String[] exceptions) { // if ((access & Opcodes.ACC_SYNTHETIC) != 0) // return null; if (!_method.equals(name) || !_methodDesc.equals(desc)) return null; Type ret = Type.getReturnType(desc); if (ret.getSort() == Type.VOID) throw ExpressionMethodVisitor.notLambda(Opcodes.RETURN); _type = getClass(ret);/*from ww w .j a v a2 s . c o m*/ Type[] args = Type.getArgumentTypes(desc); Class<?>[] argTypes = new Class<?>[args.length]; for (int i = 0; i < args.length; i++) argTypes[i] = getClass(args[i]); _argTypes = argTypes; return new ExpressionMethodVisitor(this, (access & Opcodes.ACC_STATIC) == 0 ? _me : null, argTypes); }
From source file:com.trigersoft.jaque.expression.ExpressionMethodVisitor.java
License:Apache License
@Override public void visitInsn(int opcode) { Expression e;/* w w w .ja v a 2 s .co m*/ Expression first; Expression second; switch (opcode) { case Opcodes.ARRAYLENGTH: e = Expression.arrayLength(_exprStack.pop()); break; case Opcodes.ACONST_NULL: e = Expression.constant(null, Object.class); break; case Opcodes.IALOAD: case Opcodes.LALOAD: case Opcodes.FALOAD: case Opcodes.DALOAD: case Opcodes.AALOAD: case Opcodes.BALOAD: case Opcodes.CALOAD: case Opcodes.SALOAD: first = _exprStack.pop(); second = _exprStack.pop(); e = Expression.arrayIndex(second, first); break; case Opcodes.DCONST_0: e = Expression.constant(0d, Double.TYPE); break; case Opcodes.DCONST_1: e = Expression.constant(1d, Double.TYPE); break; case Opcodes.FCMPG: case Opcodes.FCMPL: case Opcodes.DCMPG: case Opcodes.DCMPL: case Opcodes.LCMP: first = _exprStack.pop(); second = _exprStack.pop(); e = Expression.subtract(second, first); break; case Opcodes.FCONST_0: e = Expression.constant(0f, Float.TYPE); break; case Opcodes.FCONST_1: e = Expression.constant(1f, Float.TYPE); break; case Opcodes.FCONST_2: e = Expression.constant(2f, Float.TYPE); break; case Opcodes.ICONST_M1: e = Expression.constant(-1, Integer.TYPE); break; case Opcodes.ICONST_0: e = Expression.constant(0, Integer.TYPE); break; case Opcodes.ICONST_1: e = Expression.constant(1, Integer.TYPE); break; case Opcodes.ICONST_2: e = Expression.constant(2, Integer.TYPE); break; case Opcodes.ICONST_3: e = Expression.constant(3, Integer.TYPE); break; case Opcodes.ICONST_4: e = Expression.constant(4, Integer.TYPE); break; case Opcodes.ICONST_5: e = Expression.constant(5, Integer.TYPE); break; case Opcodes.LCONST_0: e = Expression.constant(0l, Long.TYPE); break; case Opcodes.LCONST_1: e = Expression.constant(1l, Long.TYPE); break; case Opcodes.IADD: case Opcodes.LADD: case Opcodes.FADD: case Opcodes.DADD: first = _exprStack.pop(); second = _exprStack.pop(); e = Expression.add(second, first); break; case Opcodes.ISUB: case Opcodes.LSUB: case Opcodes.FSUB: case Opcodes.DSUB: first = _exprStack.pop(); second = _exprStack.pop(); e = Expression.subtract(second, first); break; case Opcodes.IMUL: case Opcodes.LMUL: case Opcodes.FMUL: case Opcodes.DMUL: first = _exprStack.pop(); second = _exprStack.pop(); e = Expression.multiply(second, first); break; case Opcodes.IDIV: case Opcodes.LDIV: case Opcodes.FDIV: case Opcodes.DDIV: first = _exprStack.pop(); second = _exprStack.pop(); e = Expression.divide(second, first); break; case Opcodes.IREM: case Opcodes.LREM: case Opcodes.FREM: case Opcodes.DREM: first = _exprStack.pop(); second = _exprStack.pop(); e = Expression.modulo(second, first); break; case Opcodes.INEG: case Opcodes.LNEG: case Opcodes.FNEG: case Opcodes.DNEG: first = _exprStack.pop(); e = Expression.negate(first); break; case Opcodes.ISHL: case Opcodes.LSHL: first = _exprStack.pop(); second = _exprStack.pop(); e = Expression.leftShift(second, first); break; case Opcodes.ISHR: case Opcodes.LSHR: first = _exprStack.pop(); second = _exprStack.pop(); e = Expression.rightShift(second, first); break; case Opcodes.IUSHR: case Opcodes.LUSHR: first = _exprStack.pop(); second = _exprStack.pop(); e = Expression.rightShift(second, first); break; case Opcodes.IAND: case Opcodes.LAND: first = _exprStack.pop(); second = _exprStack.pop(); e = Expression.bitwiseAnd(second, first); break; case Opcodes.IOR: case Opcodes.LOR: first = _exprStack.pop(); second = _exprStack.pop(); e = Expression.bitwiseOr(second, first); break; case Opcodes.IXOR: case Opcodes.LXOR: first = _exprStack.pop(); second = _exprStack.pop(); e = Expression.exclusiveOr(second, first); break; case Opcodes.I2B: case Opcodes.I2C: case Opcodes.I2S: first = _exprStack.pop(); e = Expression.convert(first, NumericTypeLookup2[opcode - Opcodes.I2B]); break; case Opcodes.I2L: case Opcodes.I2F: case Opcodes.I2D: first = _exprStack.pop(); e = Expression.convert(first, NumericTypeLookup[opcode - Opcodes.I2L + 1]); break; case Opcodes.L2I: case Opcodes.L2F: case Opcodes.L2D: int l2l = opcode > Opcodes.L2I ? 1 : 0; first = _exprStack.pop(); e = Expression.convert(first, NumericTypeLookup[opcode - Opcodes.L2I + l2l]); break; case Opcodes.F2I: case Opcodes.F2L: case Opcodes.F2D: int f2f = opcode == Opcodes.F2D ? 1 : 0; first = _exprStack.pop(); e = Expression.convert(first, NumericTypeLookup[opcode - Opcodes.F2I + f2f]); break; case Opcodes.D2I: case Opcodes.D2L: case Opcodes.D2F: first = _exprStack.pop(); e = Expression.convert(first, NumericTypeLookup[opcode - Opcodes.D2I]); break; case Opcodes.IRETURN: case Opcodes.LRETURN: case Opcodes.FRETURN: case Opcodes.DRETURN: case Opcodes.ARETURN: go(null); return; case Opcodes.SWAP: first = _exprStack.pop(); second = _exprStack.pop(); _exprStack.push(first); _exprStack.push(second); case Opcodes.DUP: case Opcodes.DUP_X1: case Opcodes.DUP_X2: case Opcodes.DUP2: case Opcodes.DUP2_X1: case Opcodes.DUP2_X2: // our stack is not divided to words int base = (opcode - Opcodes.DUP) % 3; base++; dup(_exprStack, base, base - 1); return; case Opcodes.NOP: return; case Opcodes.RETURN: default: throw notLambda(opcode); } _exprStack.push(e); }
From source file:com.yahoo.yqlplus.engine.internal.bytecode.ClassAdapterGenerator.java
private void generatePutProperty(TypeWidget targetType, final PropertyAdapter propertyAdapter) { MethodGenerator method = createStaticMethod("putProperty"); final BytecodeExpression targetExpr = method.addArgument("target", targetType).read(); final BytecodeExpression propertyName = method.addArgument("property", BaseTypeAdapter.STRING).read(); final BytecodeExpression valueExpr = method.addArgument("value", AnyTypeWidget.getInstance()).read(); method.add(new BytecodeSequence() { @Override// w ww . ja v a 2 s . co m public void generate(CodeEmitter code) { Map<String, Label> labelMap = Maps.newLinkedHashMap(); Label done = new Label(); for (PropertyAdapter.Property property : propertyAdapter.getProperties()) { labelMap.put(property.name, new Label()); } propertyName.generate(code); code.emitStringSwitch(labelMap, done, true); MethodVisitor mv = code.getMethodVisitor(); for (PropertyAdapter.Property property : propertyAdapter.getProperties()) { mv.visitLabel(labelMap.get(property.name)); AssignableValue av = propertyAdapter.property(targetExpr, property.name); try { code.exec(av.write(new BytecodeCastExpression(property.type, valueExpr))); } catch (UnsupportedOperationException ignored) { // can't write what isn't writable } mv.visitJumpInsn(Opcodes.GOTO, done); } mv.visitLabel(done); mv.visitInsn(Opcodes.RETURN); } }); }
From source file:com.yahoo.yqlplus.engine.internal.bytecode.DynamicBootstrapUnit.java
public void init() { ProgramValueTypeAdapter types = environment.getValueTypeAdapter(); BytecodeExpression classSource = types.constant(getEnvironment()); TypeWidget dynamicLinker = types.adaptInternal(DynamicLinker.class); FieldDefinition field = createField(dynamicLinker, "bootstrap"); field.addModifier(Opcodes.ACC_STATIC | Opcodes.ACC_FINAL); MethodGenerator sl = createMethod("<clinit>"); sl.setModifier(Opcodes.ACC_STATIC);//from w w w.j a v a2 s . c om sl.add(classSource); sl.add(new BytecodeSequence() { @Override public void generate(CodeEmitter code) { final MethodVisitor mv = code.getMethodVisitor(); mv.visitMethodInsn(Opcodes.INVOKESTATIC, Type.getInternalName(Dynamic.class), "createDynamicLinker", MethodType.methodType(DynamicLinker.class, ASMClassSource.class).toMethodDescriptorString(), false); mv.visitFieldInsn(Opcodes.PUTSTATIC, Dynamic.DYNAMIC_INTERNAL_NAME, "bootstrap", Type.getDescriptor(DynamicLinker.class)); mv.visitInsn(Opcodes.RETURN); } }); MethodGenerator mgen = createStaticMethod(Dynamic.DYNAMIC_BOOTSTRAP_METHOD); TypeWidget callSite = types.adaptInternal(CallSite.class); TypeWidget lookup = types.adaptInternal(MethodHandles.Lookup.class); TypeWidget methodType = types.adaptInternal(MethodType.class); mgen.setReturnType(callSite); AssignableValue lu = mgen.addArgument("lookup", lookup); AssignableValue name = mgen.addArgument("name", BaseTypeAdapter.STRING); AssignableValue sig = mgen.addArgument("sig", methodType); final String desc = MethodType.methodType(CallSite.class, // ...that will return a CallSite object, ... MethodHandles.Lookup.class, // ... when given a lookup object, ... String.class, // ... the operation name, ... MethodType.class, // ... and the signature at the call site. DynamicLinker.class).toMethodDescriptorString(); mgen.add(lu.read()); mgen.add(name.read()); mgen.add(sig.read()); mgen.add(new BytecodeSequence() { @Override public void generate(CodeEmitter code) { final MethodVisitor mv = code.getMethodVisitor(); mv.visitFieldInsn(Opcodes.GETSTATIC, Dynamic.DYNAMIC_INTERNAL_NAME, "bootstrap", Type.getDescriptor(DynamicLinker.class)); mv.visitMethodInsn(Opcodes.INVOKESTATIC, Type.getInternalName(Dynamic.class), "link", desc, false); mv.visitInsn(Opcodes.ARETURN); } }); }
From source file:com.yahoo.yqlplus.engine.internal.bytecode.ReturnCode.java
public ReturnCode() { this.op = Opcodes.RETURN; }
From source file:com.yahoo.yqlplus.engine.internal.compiler.TaskGenerator.java
public TaskGenerator(ProgramGenerator program, GambitScope scope) { builder = scope.createObject();//from w ww. j av a2 s. c o m builder.implement(Runnable.class); builder.addParameter("$program", program.getType()); programGenerator = program; this.run = builder.method("run"); GambitCreator.CatchBuilder catcher = run.tryCatchFinally(); ScopedBuilder body = catcher.body(); runBody = body.block(); body.exec(new ReturnCode()); ScopedBuilder handler = catcher.on("$e", Throwable.class); handler.exec(new BytecodeSequence() { @Override public void generate(CodeEmitter code) { code.exec(code.getLocal("$program")); code.exec(code.getLocal("$e")); code.getMethodVisitor().visitMethodInsn(Opcodes.INVOKEVIRTUAL, Type.getInternalName(ProgramInvocation.class), "fail", Type.getMethodDescriptor(Type.VOID_TYPE, Type.getType(Throwable.class)), false); code.getMethodVisitor().visitInsn(Opcodes.RETURN); } }); run.exec(catcher.build()); }
From source file:com.yahoo.yqlplus.engine.internal.generate.StructGenerator.java
private void generatePutMethod() { final MethodGenerator setGenerator = createMethod("set"); final BytecodeExpression propertyNameExpr = setGenerator.addArgument("propertyName", BaseTypeAdapter.STRING) .read();//w w w . j a va 2 s . c o m final BytecodeExpression valueExpr = setGenerator.addArgument("value", AnyTypeWidget.getInstance()).read(); setGenerator.add(new BytecodeSequence() { @Override public void generate(CodeEmitter code) { Map<String, Label> labelMap = Maps.newLinkedHashMap(); Label done = new Label(); for (Map.Entry<String, FieldProperty> field : fields.entrySet()) { labelMap.put(field.getKey(), new Label()); } propertyNameExpr.generate(code); code.emitStringSwitch(labelMap, done, true); MethodVisitor mv = code.getMethodVisitor(); for (Map.Entry<String, FieldProperty> field : fields.entrySet()) { mv.visitLabel(labelMap.get(field.getKey())); BytecodeExpression castValue = new BytecodeCastExpression(field.getValue().property.type, valueExpr); field.getValue().property(setGenerator.getLocal("this").read()).write(castValue).generate(code); mv.visitJumpInsn(Opcodes.GOTO, done); } mv.visitLabel(done); mv.visitInsn(Opcodes.RETURN); } }); }
From source file:de.codesourcery.asm.controlflow.ControlFlowAnalyzer.java
License:Apache License
@SuppressWarnings("unchecked") public ControlFlowGraph analyze(String owner, final MethodNode mn) throws AnalyzerException { // line numbers with associated block // initially we'll create one block per line and merge adjacent ones later if control flow permits it final Map<Integer, IBlock> blocks = new HashMap<>(); final ListIterator<AbstractInsnNode> it = mn.instructions.iterator(); IBlock currentLine = null;/*from w w w .j a v a2 s . co m*/ Object previousMetadata = null; IBlock previous = null; final IBlock methodExit = new MethodExit(); for (int instrCounter = 0; it.hasNext(); instrCounter++) { final AbstractInsnNode instruction = it.next(); currentLine = getBlockForInstruction(instrCounter, blocks); if (previous != null) { previous.addSuccessor(currentLine, EdgeType.REGULAR, previousMetadata); currentLine.addRegularPredecessor(previous); previousMetadata = null; } IBlock nextPrevious = currentLine; switch (instruction.getType()) { case AbstractInsnNode.LOOKUPSWITCH_INSN: LookupSwitchInsnNode lookup = (LookupSwitchInsnNode) instruction; // add edge for default handler if (lookup.dflt != null) { final IBlock target = getBlockForInstruction(lookup.dflt, mn, blocks); target.addRegularPredecessor(currentLine); currentLine.addRegularSuccessor(target); } @SuppressWarnings("cast") final Iterator<Integer> keys = (Iterator<Integer>) lookup.keys.iterator(); for (LabelNode ln : (List<LabelNode>) lookup.labels) { final IBlock target = getBlockForInstruction(ln, mn, blocks); final Integer key = keys.next(); target.addPredecessor(currentLine, EdgeType.LOOKUP_SWITCH, key); currentLine.addSuccessor(target, EdgeType.LOOKUP_SWITCH, key); } nextPrevious = null; break; case AbstractInsnNode.TABLESWITCH_INSN: TableSwitchInsnNode tblSwitch = (TableSwitchInsnNode) instruction; // add edge for default handler if (tblSwitch.dflt != null) { final IBlock target = getBlockForInstruction(tblSwitch.dflt, mn, blocks); target.addRegularPredecessor(currentLine); currentLine.addRegularSuccessor(target); } int currentKey = tblSwitch.min; for (LabelNode ln : (List<LabelNode>) tblSwitch.labels) { final IBlock target = getBlockForInstruction(ln, mn, blocks); target.addPredecessor(currentLine, EdgeType.TABLE_SWITCH, currentKey); currentLine.addSuccessor(target, EdgeType.TABLE_SWITCH, currentKey); currentKey++; } nextPrevious = null; break; case AbstractInsnNode.INSN: if (instruction.getOpcode() == Opcodes.RETURN || instruction.getOpcode() == Opcodes.IRETURN) /* method exit */ { currentLine.addRegularSuccessor(methodExit); methodExit.addRegularPredecessor(currentLine); nextPrevious = null; } else if (instruction.getOpcode() == Opcodes.ATHROW || instruction.getOpcode() == Opcodes.RET) { nextPrevious = null; } break; case AbstractInsnNode.JUMP_INSN: /* jump */ final JumpInsnNode jmp = (JumpInsnNode) instruction; final LabelNode label = jmp.label; final int target = mn.instructions.indexOf(label); final boolean isConditional = ASMUtil.isConditionalJump(instruction); if (isConditional) { // label edges of conditional jump instructions with "true" and "false previousMetadata = "false"; } final IBlock targetBlock = getBlockForInstruction(target, blocks); targetBlock.addRegularPredecessor(currentLine); // create edge from current block to jump target currentLine.addSuccessor(targetBlock, EdgeType.REGULAR, isConditional ? "true" : null); if (instruction.getOpcode() == Opcodes.GOTO) { nextPrevious = null; } break; } // link last instruction with method_exit block if (!it.hasNext()) { currentLine.addRegularSuccessor(methodExit); methodExit.addRegularPredecessor(currentLine); } previous = nextPrevious; } // try/catch blocks need special treatment because // they are not represented as opcodes for (TryCatchBlockNode node : (List<TryCatchBlockNode>) mn.tryCatchBlocks) { final LabelNode startLabel = node.start; final int startTarget = mn.instructions.indexOf(startLabel); final LabelNode endLabel = node.end; final int endTarget = mn.instructions.indexOf(endLabel); final int handlerTarget = mn.instructions.indexOf(node.handler); IBlock handler = getBlockForInstruction(node.handler, mn, blocks); for (int i = startTarget; i <= endTarget; i++) { if (i != handlerTarget) { getBlockForInstruction(i, blocks).addExceptionHandler(handler, node.type); } } } // merge adjacent instructions final Set<Integer> linesBeforeMerge = new HashSet<>(); for (IBlock block : blocks.values()) { linesBeforeMerge.addAll(block.getInstructionNums()); } final List<IBlock> result = mergeBlocks(blocks, mn); if (debug) { System.out.println("################ Control-blocks merged ################"); } // sanity check final Set<Integer> linesAfterMerge = new HashSet<>(); for (IBlock block : result) { linesAfterMerge.addAll(block.getInstructionNums()); if (debug) { System.out.println("-----"); System.out.println(block + " has " + block.getByteCodeInstructionCount(mn) + " instructions."); System.out.println(block.disassemble(mn, false, true)); } for (Edge e : block.getEdges()) { if (!result.contains(e.src) && e.src != methodExit) { throw new RuntimeException(e + " has src that is not in result list?"); } if (!result.contains(e.dst) && e.dst != methodExit) { throw new RuntimeException(e + " has destination that is not in result list?"); } } } if (!linesBeforeMerge.equals(linesAfterMerge)) { throw new RuntimeException("Internal error, line count mismatch before/after control block merge: \n\n" + linesBeforeMerge + "\n\n" + linesAfterMerge); } // add starting block and link it with block that contains the lowest instruction number MethodEntry methodEntry = new MethodEntry(); int lowest = Integer.MAX_VALUE; for (Integer i : blocks.keySet()) { if (i < lowest) { lowest = i; } } final IBlock firstBlock = blocks.get(lowest); if (firstBlock.hasRegularPredecessor()) { throw new IllegalStateException(firstBlock + " that constrains first instruction has a predecessor?"); } methodEntry.addRegularSuccessor(firstBlock); firstBlock.addRegularPredecessor(methodEntry); result.add(0, methodEntry); // add end block to results result.add(methodExit);//owner+"#"+ ControlFlowGraph cfg = new ControlFlowGraph(mn, result); System.out.println("CFGMAP:" + formatname(owner) + "#" + cfg.getMethod().name); graphmap.put(formatname(owner) + "#" + cfg.getMethod().name, cfg); return cfg; }