public static int insertPopsForAllParameters ( MethodVisitor mv , String desc ) { String descSequence = Utils . getParamSequence ( desc ) ; if ( descSequence == null ) { return 0 ; // nothing to do, there are no parameters } int count = descSequence . length ( ) ; for ( int dpos = count - 1 ; dpos >= 0 ; dpos -- ) { char ch = descSequence . charAt ( dpos ) ; switch ( ch ) { case ' ' : case ' ' : case ' ' : case ' ' : case ' ' : case ' ' : case ' ' : mv . visitInsn ( POP ) ; break ; case ' ' : // long - double slot case ' ' : // double - double slot mv . visitInsn ( POP2 ) ; break ; default : throw new IllegalStateException ( "Unexpected character: " + ch + " from " + desc + ":" + dpos ) ; } } return count ; }
Looks at the supplied descriptor and inserts enough pops to remove all parameters . Should be used when about to avoid a method call .