private Method isSelfCall ( InvokeInstruction inv ) { ConstantPoolGen cpg = classContext . getConstantPoolGen ( ) ; JavaClass jclass = classContext . getJavaClass ( ) ; String calledClassName = inv . getClassName ( cpg ) ; // FIXME: is it possible we would see a superclass name here? // Not a big deal for now, as we are mostly just interested in calls // to private methods, for which we will definitely see the right // called class name. if ( ! calledClassName . equals ( jclass . getClassName ( ) ) ) { return null ; } String calledMethodName = inv . getMethodName ( cpg ) ; String calledMethodSignature = inv . getSignature ( cpg ) ; boolean isStaticCall = ( inv instanceof INVOKESTATIC ) ; // Scan methods for one that matches. Method [ ] methods = jclass . getMethods ( ) ; for ( Method method : methods ) { String methodName = method . getName ( ) ; String signature = method . getSignature ( ) ; boolean isStatic = method . isStatic ( ) ; if ( methodName . equals ( calledMethodName ) && signature . equals ( calledMethodSignature ) && isStatic == isStaticCall ) { // This method looks like a match. return wantCallsFor ( method ) ? method : null ; } } // Hmm...no matching method found. // This is almost certainly because the named method // was inherited from a superclass. LOG . debug ( "No method found for {}.{} : {}" , calledClassName , calledMethodName , calledMethodSignature ) ; return null ; }
Is the given instruction a self - call?