public static Class getCallerClass() {
		String className = null;
		StackTraceElement[] stackTraceElements = new Throwable().getStackTrace();

		for (StackTraceElement stackTraceElement : stackTraceElements) {
			className = stackTraceElement.getClassName();
			String methodName = stackTraceElement.getMethodName();

			if (methodName.equals("loadClass")) {
				if (className.contains(ClassLoaderStrategy.class.getSimpleName())) {
					continue;
				}
				if (className.equals(ClassLoaderUtil.class.getName())) {
					continue;
				}
			} else if (methodName.equals("getCallerClass")) {
				continue;
			}
			break;
		}

		try {
			return Thread.currentThread().getContextClassLoader().loadClass(className);
		} catch (ClassNotFoundException cnfex) {
			throw new UnsupportedOperationException(className + " not found.");
		}
	}
public static Class getCallerClass ( ) { String className = null ; StackTraceElement [ ] stackTraceElements = new Throwable ( ) . getStackTrace ( ) ; for ( StackTraceElement stackTraceElement : stackTraceElements ) { className = stackTraceElement . getClassName ( ) ; String methodName = stackTraceElement . getMethodName ( ) ; if ( methodName . equals ( "loadClass" ) ) { if ( className . contains ( ClassLoaderStrategy . class . getSimpleName ( ) ) ) { continue ; } if ( className . equals ( ClassLoaderUtil . class . getName ( ) ) ) { continue ; } } else if ( methodName . equals ( "getCallerClass" ) ) { continue ; } break ; } try { return Thread . currentThread ( ) . getContextClassLoader ( ) . loadClass ( className ) ; } catch ( ClassNotFoundException cnfex ) { throw new UnsupportedOperationException ( className + " not found." ) ; } }
Smart variant of {@link #getCallerClass(int)} that skips all relevant Jodd calls.
However, this one does not use the security manager.