@Override public void visitINVOKESTATIC(INVOKESTATIC ins) { // Find calls to System.exit(), since this effectively terminates the // basic block. String className = ins.getClassName(constPoolGen); String methodName = ins.getName(constPoolGen); String methodSig = ins.getSignature(constPoolGen); if ("java.lang.System".equals(className) && "exit".equals(methodName) && "(I)V".equals(methodSig)) { isExit = true; } }
private boolean isSleep(INVOKESTATIC ins, ConstantPoolGen cpg) { String className = ins.getClassName(cpg); if (!"java.lang.Thread".equals(className)) { return false; } String methodName = ins.getMethodName(cpg); String signature = ins.getSignature(cpg); return "sleep".equals(methodName) && ("(J)V".equals(signature) || "(JI)V".equals(signature)); }
@Override public void visitINVOKESTATIC(INVOKESTATIC obj) { String methodName = obj.getMethodName(cpg); String signature = obj.getSignature(cpg); String className = obj.getClassName(cpg); if ("asList".equals(methodName) && "java.util.Arrays".equals(className) && "([Ljava/lang/Object;)Ljava/util/List;".equals(signature)) { consumeStack(obj); Type returnType = Type.getType("Ljava/util/Arrays$ArrayList;"); pushValue(returnType); return; } visitInvokeInstructionCommon(obj); }
/** * Get the InnerClassAccess for access method called by given INVOKESTATIC. * * @param inv * the INVOKESTATIC instruction * @param cpg * the ConstantPoolGen for the method * @return the InnerClassAccess, or null if the instruction is not an * inner-class access */ public static InnerClassAccess getInnerClassAccess(INVOKESTATIC inv, ConstantPoolGen cpg) throws ClassNotFoundException { String className = inv.getClassName(cpg); String methodName = inv.getName(cpg); String methodSig = inv.getSignature(cpg); InnerClassAccess access = AnalysisContext.currentAnalysisContext().getInnerClassAccessMap() .getInnerClassAccess(className, methodName); return (access != null && access.getMethodSignature().equals(methodSig)) ? access : null; }
String targetClassName = obj.getClassName(cpg); String methodName = obj.getName(cpg); String methodSig = obj.getSignature(cpg);
INVOKESTATIC inv = (INVOKESTATIC) ins; InnerClassAccess access = icam.getInnerClassAccess(inv, cpg); if (access != null && access.getMethodSignature().equals(inv.getSignature(cpg))) { xfield = access.getField(); isWrite = !access.isLoad();
INVOKESTATIC is = (INVOKESTATIC) i; String name = is.getMethodName(cpg); String signature = is.getSignature(cpg); if (name.startsWith("access$")) { XMethod invoked = XFactory.createXMethod(is, cpg);
private boolean isSleep(INVOKESTATIC ins, ConstantPoolGen cpg) { String className = ins.getClassName(cpg); if (!"java.lang.Thread".equals(className)) { return false; } String methodName = ins.getMethodName(cpg); String signature = ins.getSignature(cpg); return "sleep".equals(methodName) && ("(J)V".equals(signature) || "(JI)V".equals(signature)); }
@Override public void visitINVOKESTATIC(INVOKESTATIC ins) { // Find calls to System.exit(), since this effectively terminates the // basic block. String className = ins.getClassName(constPoolGen); String methodName = ins.getName(constPoolGen); String methodSig = ins.getSignature(constPoolGen); if ("java.lang.System".equals(className) && "exit".equals(methodName) && "(I)V".equals(methodSig)) { isExit = true; } }
@Override public void visitINVOKESTATIC(INVOKESTATIC obj) { String methodName = obj.getMethodName(cpg); String signature = obj.getSignature(cpg); String className = obj.getClassName(cpg); if ("asList".equals(methodName) && "java.util.Arrays".equals(className) && "([Ljava/lang/Object;)Ljava/util/List;".equals(signature)) { consumeStack(obj); Type returnType = Type.getType("Ljava/util/Arrays$ArrayList;"); pushValue(returnType); return; } visitInvokeInstructionCommon(obj); }
public static String getCallSignature(Instruction ins, ConstantPoolGen cp) { if (ins instanceof INVOKESTATIC) { INVOKESTATIC invst = (INVOKESTATIC) ins; return invst.getSignature(cp); } else if (ins instanceof INVOKEVIRTUAL) { INVOKEVIRTUAL invst = (INVOKEVIRTUAL) ins; return invst.getSignature(cp); } else if (ins instanceof INVOKEINTERFACE) { INVOKEINTERFACE invst = (INVOKEINTERFACE) ins; return invst.getSignature(cp); } else if (ins instanceof INVOKESPECIAL) { INVOKESPECIAL invst = (INVOKESPECIAL) ins; return invst.getSignature(cp); } else { return null; } }
/** * Get the InnerClassAccess for access method called by given INVOKESTATIC. * * @param inv * the INVOKESTATIC instruction * @param cpg * the ConstantPoolGen for the method * @return the InnerClassAccess, or null if the instruction is not an * inner-class access */ public static InnerClassAccess getInnerClassAccess(INVOKESTATIC inv, ConstantPoolGen cpg) throws ClassNotFoundException { String className = inv.getClassName(cpg); String methodName = inv.getName(cpg); String methodSig = inv.getSignature(cpg); InnerClassAccess access = AnalysisContext.currentAnalysisContext().getInnerClassAccessMap() .getInnerClassAccess(className, methodName); return (access != null && access.getMethodSignature().equals(methodSig)) ? access : null; }
String targetClassName = obj.getClassName(cpg); String methodName = obj.getName(cpg); String methodSig = obj.getSignature(cpg);
/** Checks if the constraints of operands of the said instruction(s) are satisfied. */ @Override public void visitINVOKESTATIC(final INVOKESTATIC o) { try { // INVOKESTATIC is a LoadClass; the Class where the referenced method is declared in, // is therefore resolved/verified. // INVOKESTATIC is an InvokeInstruction, the argument and return types are resolved/verified, // too. So are the allowed method names. final String classname = o.getClassName(cpg); final JavaClass jc = Repository.lookupClass(classname); final Method m = getMethodRecursive(jc, o); if (m == null) { constraintViolated(o, "Referenced method '"+o.getMethodName(cpg)+"' with expected signature '"+ o.getSignature(cpg) +"' not found in class '"+jc.getClassName()+"'."); } else if (! (m.isStatic())) { // implies it's not abstract, verified in pass 2. constraintViolated(o, "Referenced method '"+o.getMethodName(cpg)+"' has ACC_STATIC unset."); } } catch (final ClassNotFoundException e) { // FIXME: maybe not the best way to handle this throw new AssertionViolatedException("Missing class: " + e, e); } }
INVOKESTATIC inv = (INVOKESTATIC) ins; InnerClassAccess access = icam.getInnerClassAccess(inv, cpg); if (access != null && access.getMethodSignature().equals(inv.getSignature(cpg))) { xfield = access.getField(); isWrite = !access.isLoad();
INVOKESTATIC is = (INVOKESTATIC) i; String name = is.getMethodName(cpg); String signature = is.getSignature(cpg); if (name.startsWith("access$")) { XMethod invoked = XFactory.createXMethod(is, cpg);