public static void main ( String [ ] argv ) throws Exception { if ( argv . length != 1 ) { System . err . println ( "Usage: " + BetterCFGBuilder2 . class . getName ( ) + " <class file>" ) ; System . exit ( 1 ) ; } String methodName = SystemProperties . getProperty ( "cfgbuilder.method" ) ; JavaClass jclass = new ClassParser ( argv [ 0 ] ) . parse ( ) ; ClassGen classGen = new ClassGen ( jclass ) ; Method [ ] methodList = jclass . getMethods ( ) ; for ( Method method : methodList ) { if ( method . isAbstract ( ) || method . isNative ( ) ) { continue ; } if ( methodName != null && ! method . getName ( ) . equals ( methodName ) ) { continue ; } MethodDescriptor descriptor = DescriptorFactory . instance ( ) . getMethodDescriptor ( jclass , method ) ; MethodGen methodGen = new MethodGen ( method , jclass . getClassName ( ) , classGen . getConstantPool ( ) ) ; CFGBuilder cfgBuilder = new BetterCFGBuilder2 ( descriptor , methodGen ) ; cfgBuilder . build ( ) ; CFG cfg = cfgBuilder . getCFG ( ) ; CFGPrinter cfgPrinter = new CFGPrinter ( cfg ) ; System . out . println ( "---------------------------------------------------------------------" ) ; System . out . println ( "Method: " + SignatureConverter . convertMethodSignature ( methodGen ) ) ; System . out . println ( "---------------------------------------------------------------------" ) ; cfgPrinter . print ( System . out ) ; } }
Test driver .