private void createCode(Element code) throws IllegalXMLVMException { List<Element> instructions = code.getChildren(); for (Element inst : instructions) { String name = inst.getName(); String opcMethodName = "createInstruction" + name.substring(0, 1).toUpperCase() + name.substring(1); Class appClazz; Method opcMeth; Class[] paramTypes = {Element.class}; Object[] params = {inst}; appClazz = this.getClass(); Object newInstr = null; try { opcMeth = appClazz.getMethod(opcMethodName, paramTypes); newInstr = opcMeth.invoke(this, params); } catch (NoSuchMethodException ex) { throw new IllegalXMLVMException( "Illegal instruction 1, unable to find method " + opcMethodName + " for '" + name + "'"); } catch (InvocationTargetException ex) { ex.printStackTrace(); throw new IllegalXMLVMException("Illegal instruction 2 '" + name + "'"); } catch (IllegalAccessException ex) { throw new IllegalXMLVMException("Illegal instruction 3 '" + name + "'"); } if (newInstr != null) { InstructionHandle ih = null; if (newInstr instanceof BranchInstruction) ih = il.append((BranchInstruction) newInstr); else if (newInstr instanceof CompoundInstruction) ih = il.append((CompoundInstruction) newInstr); else if (newInstr instanceof Instruction) ih = il.append((Instruction) newInstr); instructionHandlerManager.registerInstructionHandle(ih); } } }