public static Class getCallingClass ( int matchLevel , Collection < String > extraIgnoredPackages ) { Class [ ] classContext = HELPER . getClassContext ( ) ; int depth = 0 ; try { Class c ; // this super class stuff is for Java 1.4 support only // it isn't needed on a 5.0 VM Class sc ; do { do { c = classContext [ depth ++ ] ; if ( c != null ) { sc = c . getSuperclass ( ) ; } else { sc = null ; } } while ( classShouldBeIgnored ( c , extraIgnoredPackages ) || superClassShouldBeIgnored ( sc ) ) ; } while ( c != null && matchLevel -- > 0 && depth < classContext . length ) ; return c ; } catch ( Throwable t ) { return null ; } }
Get the called that is matchLevel stack frames before the call ignoring MOP frames and desired exclude packages .