com.agimatec.commons.util.ClassUtils Maven / Gradle / Ivy
package com.agimatec.commons.util;
/**
* Title: Agimatec GmbH
* Description: Reflection util for class access.
* Copyright (c) 2007
* Company: Agimatec GmbH
*
* @author Roman Stumm
*/
public class ClassUtils {
/**
* @return contextclassloader or the caller classLoader
*/
public static ClassLoader getClassLoader() {
final ClassLoader cl = Thread.currentThread().getContextClassLoader();
// if Reflection.getCallerClass(3) is not the correct stuff, just drop it.
// return cl == null ? Reflection.getCallerClass(3).getClassLoader() : cl;
return cl == null ? ClassUtils.class.getClassLoader() : cl;
}
/**
* @param className
* @return a Class
* @throws ClassNotFoundException
* @see Class#forName(String)
*/
public static Class forName(String className) throws ClassNotFoundException {
return Class.forName(className, true, getClassLoader());
}
}
© 2015 - 2025 Weber Informatics LLC | Privacy Policy