Refine search
for (Attribute ca : ((Code) a).getAttributes()) { if (ca.getTag() == org.apache.bcel.Const.ATTR_LOCAL_VARIABLE_TABLE) { for (LocalVariable l : ((LocalVariableTable) ca).getLocalVariableTable()) { printLocal(out, fout, l, v, defs, refs); out.write(TAB); fout.write(TAB); aflgs = Utility.accessToString(m.getAccessFlags()); if (aflgs != null && aflgs.length() > 0) { out.write(aflgs); fout.write(SPACE); sig = m.getSignature(); msig=Utility.methodSignatureReturnType(sig, false); out.write(msig); out.write(SPACE); fout.write(SPACE); ltdef=tagDef(t = m.getName()); out.write(ltdef); fout.write(ltdef); for (Attribute ca : ((Code) a).getAttributes()) { if (ca.getTag() == org.apache.bcel.Const.ATTR_LOCAL_VARIABLE_TABLE) { locals.add(((LocalVariableTable) ca).getLocalVariableTable());
private void analyzeMethod(ClassContext classContext, Method method) throws CheckedAnalysisException { LocalVariableTable lvt = method.getLocalVariableTable(); UselessValuesContext context = new UselessValuesContext(classContext, method); context.initObservedValues(); if(++iteration > MAX_ITERATIONS) { AnalysisContext.logError("FindUselessObjects: " + classContext.getClassDescriptor().getDottedClassName() + "." + method.getName() + method.getSignature() + ": cannot converge after " + MAX_ITERATIONS + " iterations; method is skipped"); return; if(vi.var == null && vi.origValue == vn.getNumber()) { int index = ((StoreInstruction)inst).getIndex(); LocalVariable lv = lvt == null ? null : lvt.getLocalVariable(index, location.getHandle().getNext().getPosition()); vi.var = lv == null ? "var$"+index : lv.getName(); vi.hasObjectOnlyCall = false;
/** * returns the local variable at an index int the scope of PC * * @param lvt * the local variable table * @param index * the variable index * @param pc * the PC where the variable is used */ public static LocalVariable getLocalVariableAtPC(@Nonnull LocalVariableTable lvt, int index, int pc) { int length = lvt.getTableLength(); LocalVariable[] lvs = lvt.getLocalVariableTable(); for (int i = 0; i < length; i++) { if (lvs[i].getIndex() == index) { int startPC = lvs[i].getStartPC(); if ((pc >= startPC) && (pc < (startPC + lvs[i].getLength()))) { return lvs[i]; } } } return null; } }
private boolean isIDEGeneratedMethodWithCode(Method m) { if (!m.isPublic()) { return false; String name = m.getName(); if (Values.CONSTRUCTOR.equals(name) || Values.STATIC_INITIALIZER.equals(name)) { return false; LocalVariableTable lvt = m.getLocalVariableTable(); if (lvt == null) { return false; LocalVariable lv = lvt.getLocalVariable(offset + i, 0); if ((lv == null) || (lv.getName() == null)) { return false;
if (Values.STATIC_INITIALIZER.equals(obj.getName())) { return; Type[] argTypes = obj.getArgumentTypes(); for (Type t : argTypes) { addType(t); Type resultType = obj.getReturnType(); addType(resultType); LocalVariableTable lvt = obj.getLocalVariableTable(); if (lvt != null) { LocalVariable[] lvs = lvt.getLocalVariableTable(); if (lvs != null) { for (LocalVariable lv : lvs) {
this(m.getAccessFlags(), Type.getReturnType(m.getSignature()), Type.getArgumentTypes(m.getSignature()), null /* may be overridden anyway */, m.getName(), class_name, ((m.getAccessFlags() & (Constants.ACC_ABSTRACT | Constants.ACC_NATIVE)) == 0)? LocalVariable[] lv = ((LocalVariableTable)a).getLocalVariableTable();
if (iteratorBug != null) { if (isRegisterStore()) { LocalVariableTable lvt = getMethod().getLocalVariableTable(); if (lvt != null) { LocalVariable localVariable = lvt.getLocalVariable(getRegisterOperand(), getNextPC()); if(localVariable == null || localVariable.getName().endsWith("$")) {
@Override public void visit(Code obj) { if (!getMethod().isPublic() && !getMethod().isProtected()) { return; int index = getMethod().isStatic() ? 0 : 1; int parameterNumber = 0; for (Iterator<String> i = p.parameterSignatureIterator(); i.hasNext();) { String s = i.next(); LocalVariable localVariable = t.getLocalVariable(index, 0); if (localVariable != null) { String name = localVariable.getName();
@Override public void visitLocalVariableTable(LocalVariableTable obj) { super.visitLocalVariableTable(obj); LocalVariable[] local_variable_table = obj.getLocalVariableTable(); for (LocalVariable aLocal_variable_table : local_variable_table) { aLocal_variable_table.accept(this); } }
public static LocalVariableAnnotation getLocalVariableAnnotation(Method method, int local, int position1, int position2) { LocalVariableTable localVariableTable = method.getLocalVariableTable(); String localName = UNKNOWN_NAME; if (localVariableTable != null) { LocalVariable lv1 = localVariableTable.getLocalVariable(local, position1); if (lv1 == null) { lv1 = localVariableTable.getLocalVariable(local, position2); position1 = position2; } if (lv1 != null) { localName = lv1.getName(); } } LineNumberTable lineNumbers = method.getLineNumberTable(); if (lineNumbers == null) { return new LocalVariableAnnotation(localName, local, position1); } int line = lineNumbers.getSourceLine(position1); return new LocalVariableAnnotation(localName, local, position1, line); }
public static LocalVariableAnnotation getLocalVariableAnnotation(Method method, int local, int position1, int position2) { LocalVariableTable localVariableTable = method.getLocalVariableTable(); String localName = "?"; if (localVariableTable != null) { LocalVariable lv1 = localVariableTable.getLocalVariable(local, position1); if (lv1 == null) { lv1 = localVariableTable.getLocalVariable(local, position2); position1 = position2; localName = lv1.getName(); } else { for (LocalVariable lv : localVariableTable.getLocalVariableTable()) { if (lv.getIndex() == local) { if (!"?".equals(localName) && !localName.equals(lv.getName())) { LineNumberTable lineNumbers = method.getLineNumberTable(); if (lineNumbers == null) { return new LocalVariableAnnotation(localName, local, position1);
public static String getLocalVariableName(Method method, int slot, int pc) { if (method.getLocalVariableTable() != null) { LocalVariable[] table= method.getLocalVariableTable().getLocalVariableTable(); LocalVariable lvar= null; for (int i= 0; i < table.length; i++) { lvar= table[i]; if (lvar.getIndex() == slot && lvar.getStartPC() <= pc && pc <= lvar.getStartPC() + lvar.getLength()) { String name2= lvar.getName(); if (name2.equals("in")) name2= "in_"; if (isSuperpositionDetected(table, lvar)) throw new UnhandledCompilerProblemException(); return name2; } } } return "l" + slot; }
LocalVariable lv = lvTable == null ? null : lvTable.getLocalVariable(index, ih.getPosition()); String name, signature; if(lv == null) {
private void buildVariableEndScopeMap() { LocalVariableTable lvt = getMethod().getLocalVariableTable(); if ((lvt == null) || (lvt.getLength() == 0)) { endOfScopes = Collections.emptyMap(); } else { int len = lvt.getLength(); endOfScopes = new HashMap<>((int) (len * 1.6)); for (int i = 0; i < len; i++) { @SuppressWarnings("deprecation") LocalVariable lv = lvt.getLocalVariable(i); if (lv != null) { Integer endPC = Integer.valueOf(lv.getStartPC() + lv.getLength()); BitSet vars = endOfScopes.get(endPC); if (vars == null) { vars = new BitSet(); endOfScopes.put(endPC, vars); } vars.set(lv.getIndex()); } } } }
/** * Initialize from another object. Note that both objects use the same * references (shallow copy). Use copy() for a physical copy. */ public LocalVariableTable(final LocalVariableTable c) { this(c.getNameIndex(), c.getLength(), c.getLocalVariableTable(), c.getConstantPool()); }
checkIndex(lvt, lvt.getNameIndex(), CONST_Utf8); final String lvtname = ((ConstantUtf8) cp.getConstant(lvt.getNameIndex())).getBytes(); if (! lvtname.equals("LocalVariableTable")) { throw new ClassConstraintException("The LocalVariableTable attribute '"+tostring(lvt)+ final LocalVariable[] localvariables = lvt.getLocalVariableTable(); if (!m.isStatic() && 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()+
@Override public void visitLocalVariableTable(final LocalVariableTable table) { stack.push(table); table.accept(visitor); final LocalVariable[] vars = table.getLocalVariableTable(); for (final LocalVariable var : vars) { var.accept(this); } stack.pop(); }
checkIndex(lvt, lvt.getNameIndex(), CONST_Utf8); String lvtname = ((ConstantUtf8) cp.getConstant(lvt.getNameIndex())).getBytes(); if (! lvtname.equals("LocalVariableTable")){ throw new ClassConstraintException("The LocalVariableTable attribute '"+tostring(lvt)+"' is not correctly named 'LocalVariableTable' but '"+lvtname+"'."); LocalVariable[] localvariables = lvt.getLocalVariableTable();
/** * BCEL-79: */ public void testB79() throws ClassNotFoundException { final JavaClass clazz = getTestClass(PACKAGE_BASE_NAME+".data.PLSETestClass"); final ClassGen gen = new ClassGen(clazz); final ConstantPoolGen pool = gen.getConstantPool(); final Method m = gen.getMethodAt(2); final LocalVariableTable lvt = m.getLocalVariableTable(); //System.out.println(lvt); //System.out.println(lvt.getTableLength()); final MethodGen mg = new MethodGen(m, gen.getClassName(), pool); final LocalVariableTable new_lvt = mg.getLocalVariableTable(mg.getConstantPool()); //System.out.println(new_lvt); assertEquals("number of locals", lvt.getTableLength(), new_lvt.getTableLength()); }
/** * @return `LocalVariableTable' attribute of all the local variables of this method. */ public LocalVariableTable getLocalVariableTable(ConstantPoolGen cp) { LocalVariableGen[] lg = getLocalVariables(); int size = lg.length; LocalVariable[] lv = new LocalVariable[size]; for(int i=0; i < size; i++) lv[i] = lg[i].getLocalVariable(cp); return new LocalVariableTable(cp.addUtf8("LocalVariableTable"), 2 + lv.length * 10, lv, cp.getConstantPool()); }