@Override public void visit(Code obj) { classCodeSize += obj.getCode().length; }
public Set<String> getSurroundingCaughtExceptions(int pc, int maxTryBlockSize) { HashSet<String> result = new HashSet<>(); if (code == null) { throw new IllegalStateException("Not visiting Code"); } int size = maxTryBlockSize; if (code.getExceptionTable() == null) { return result; } for (CodeException catchBlock : code.getExceptionTable()) { int startPC = catchBlock.getStartPC(); int endPC = catchBlock.getEndPC(); if (pc >= startPC && pc <= endPC) { int thisSize = endPC - startPC; if (size > thisSize) { result.clear(); size = thisSize; result.add("C" + catchBlock.getCatchType()); } else if (size == thisSize) { result.add("C" + catchBlock.getCatchType()); } } } return result; }
public InstructionHandleMap(MethodGen methodGen) { map = new Object[methodGen.getMethod().getCode().getLength()]; }
@Override public void visitCode(Code obj) { code = obj; super.visitCode(obj); CodeException[] exceptions = obj.getExceptionTable(); for (CodeException exception : exceptions) { exception.accept(this); } Attribute[] attributes = obj.getAttributes(); for (Attribute attribute : attributes) { attribute.accept(this); } visitAfter(obj); code = null; }
int tightStartPC = 0; int tightEndPC = Integer.MAX_VALUE; if (code.getExceptionTable() == null) { return size; for (CodeException catchBlock : code.getExceptionTable()) { if (vmNameOfExceptionClass != null) { Constant catchType = constantPool.getConstant(catchBlock.getCatchType()); LineNumberTable lineNumberTable = code.getLineNumberTable(); if (lineNumberTable == null) { return size;
/** * Initialize from another object. Note that both objects use the same * references (shallow copy). Use copy() for a physical copy. */ public Code(final Code c) { this(c.getNameIndex(), c.getLength(), c.getMaxStack(), c.getMaxLocals(), c.getCode(), c .getExceptionTable(), c.getAttributes(), c.getConstantPool()); }
int codeLength = code.getCode().length; LineNumberTable lnt = code.getLineNumberTable(); if (lnt != null){ LineNumber[] lineNumbers = lnt.getLineNumberTable(); if (instructionPositions[j] == offset){ if (offsets.contains(offset)){ addMessage("LineNumberTable attribute '"+code.getLineNumberTable()+"' refers to the same code offset ('"+offset+"') more than once which is violating the semantics [but is sometimes produced by IBM's 'jikes' compiler]."); throw new ClassConstraintException("Code attribute '"+code+"' has a LineNumberTable attribute '"+code.getLineNumberTable()+"' referring to a code offset ('"+lineNumbers[i].getStartPC()+"') that does not exist."); Attribute[] atts = code.getAttributes(); for (int a=0; a<atts.length; a++){ if (atts[a] instanceof LocalVariableTable){ throw new ClassConstraintException("Code attribute '"+code+"' has a LocalVariableTable attribute '"+code.getLocalVariableTable()+"' referring to a code offset ('"+startpc+"') that does not exist."); throw new ClassConstraintException("Code attribute '"+code+"' has a LocalVariableTable attribute '"+code.getLocalVariableTable()+"' referring to a code offset start_pc+length ('"+(startpc+length)+"') that does not exist."); CodeException[] exceptionTable = code.getExceptionTable(); for (int i=0; i<exceptionTable.length; i++){ int startpc = exceptionTable[i].getStartPC();
? new InstructionList(m.getCode().getCode()) : null, cp); final Attribute[] attributes = m.getAttributes(); if (a instanceof Code) { final Code c = (Code) a; setMaxStack(c.getMaxStack()); setMaxLocals(c.getMaxLocals()); final CodeException[] ces = c.getExceptionTable(); if (ces != null) { for (final CodeException ce : ces) { final int length = m.getCode().getCode().length; InstructionHandle end; if (length == end_pc) { // May happen, because end_pc is exclusive final Attribute[] c_attributes = c.getAttributes(); for (final Attribute c_attribute : c_attributes) { a = c_attribute;
checkIndex(obj, obj.getNameIndex(), CONST_Utf8); String name = ((ConstantUtf8) cp.getConstant(obj.getNameIndex())).getBytes(); if (! name.equals("Code")){ throw new ClassConstraintException("The Code attribute '"+tostring(obj)+"' is not correctly named 'Code' but '"+name+"'."); if (obj.getCode().length == 0){ throw new ClassConstraintException("Code array of Code attribute '"+tostring(obj)+"' (method '"+m+"') must not be empty."); CodeException[] exc_table = obj.getExceptionTable(); for (int i=0; i<exc_table.length; i++){ int exc_index = exc_table[i].getCatchType(); throw new AssertionViolatedException("Could not find a known BCEL Method object in the corresponding BCEL JavaClass object."); localVariablesInfos[method_number] = new LocalVariablesInfo(obj.getMaxLocals()); Attribute[] atts = obj.getAttributes(); for (int a=0; a<atts.length; a++){ if ((! (atts[a] instanceof LineNumberTable)) && if ( ( (t==Type.LONG || t==Type.DOUBLE)? localindex+1:localindex) >= code.getMaxLocals()){ throw new ClassConstraintException("LocalVariableTable attribute '"+tostring(lvt)+"' references a LocalVariable '"+tostring(localvariables[i])+"' with an index that exceeds the surrounding Code attribute's max_locals value of '"+code.getMaxLocals()+"'."); if (num_of_lvt_attribs > obj.getMaxLocals()){ throw new ClassConstraintException("Number of LocalVariableTable attributes of Code attribute '"+tostring(obj)+"' (method '"+tostring(m)+"') exceeds number of local variable slots '"+obj.getMaxLocals()+"' ('There may be no more than one LocalVariableTable attribute per local variable in the Code attribute.').");
@Override public void visit(Code obj) { uselessVoidCandidate = !classInit && !constructor && !getXMethod().isSynthetic() && Type.getReturnType(getMethodSig()) == Type.VOID; byte[] code = obj.getCode(); if(code.length == 4 && (code[0] & 0xFF) == Const.GETSTATIC && (code[3] & 0xFF) == Const.ARETURN) { getStaticMethods.add(getMethodDescriptor()); for(CodeException ex : getCode().getExceptionTable()) { if(ex.getCatchType() == 0) { finallyTargets.add(ex.getHandlerPC());
public void visit(Code obj) { CodeException[] exp = obj.getExceptionTable(); LineNumberTable lineNumbers = obj.getLineNumberTable(); if (exp == null) { return; byte[] code = obj.getCode();
@Override public void visit(Code obj) { lastRegStore = -1; lineNumbers = obj.getLineNumberTable(); super.visit(obj); }
public void visitCode(Code code) { stack.push(code); code.accept(visitor); CodeException[] table = code.getExceptionTable(); for(int i=0; i < table.length; i++) table[i].accept(this); Attribute[] attributes = code.getAttributes(); for(int i=0; i < attributes.length; i++) attributes[i].accept(this); stack.pop(); }
file.print("<UL><LI>Maximum stack size = " + c.getMaxStack() + "</LI>\n<LI>Number of local variables = " + c.getMaxLocals() + "</LI>\n<LI><A HREF=\"" + class_name + "_code.html#method" + method_number + "\" TARGET=Code>Byte code</A></LI></UL>\n"); CodeException[] ce = c.getExceptionTable(); int len = ce.length;
codeBytes = obj.getCode(); DataInputStream byteStream = new DataInputStream(new ByteArrayInputStream(codeBytes)); lineNumberTable = obj.getLineNumberTable();
LocalVariableTable t = obj.getLocalVariableTable();
rootScopeBlock = new ScopeBlock(0, obj.getLength()); tryBlocks.clear(); catchHandlers.clear(); CodeException[] exceptions = obj.getExceptionTable(); if (exceptions != null) { for (CodeException ex : exceptions) {
static @CheckForNull StackMap getStackMapTable(Code code) { for(Attribute a : code.getAttributes()) { if (a instanceof StackMap) { return (StackMap) a; } } return null; }
Dataflow<BitSet, LiveLocalStoreAnalysis> llsaDataflow = classContext.getLiveLocalStoreDataflow(method); int numLocals = method.getCode().getMaxLocals(); int[] localStoreCount = new int[numLocals]; int[] localLoadCount = new int[numLocals]; continue; if (method.getCode().getLocalVariableTable() != null) { continue;
/** * @return String representation of code chunk. */ @Override public final String toString() { return toString(true); }