Example usage for java.lang Class getName

List of usage examples for java.lang Class getName

Introduction

In this page you can find the example usage for java.lang Class getName.

Prototype

public String getName() 

Source Link

Document

Returns the name of the entity (class, interface, array class, primitive type, or void) represented by this Class object, as a String .

Usage

From source file:Main.java

/**
 * Use instrumentation to get the class loader for a given class.
 *
 * @param name/*www  .ja  v a 2s . co m*/
 *            the fully qualified classname
 * @return the classloader
 */
static public ClassLoader getClassLoaderByName(String name) {

    Class<?>[] allLoadedClasses = instrumentation.getAllLoadedClasses();

    ClassLoader cl = null;
    for (Class<?> c : allLoadedClasses) {
        if (c.getName().equals(name)) {
            cl = c.getClassLoader();
            break;
        }
    }

    return cl;
}

From source file:Main.java

private static void getClassModifier(Class clazz) {
    int modifier = clazz.getModifiers();

    if (Modifier.isFinal(modifier)) {
        System.out.println(clazz.getName() + " class modifier is final");
    }//w  w  w . jav a  2  s  . co  m
}

From source file:Main.java

private static void getClassModifier(Class clazz) {
    int modifier = clazz.getModifiers();

    if (Modifier.isPublic(modifier)) {
        System.out.println(clazz.getName() + " class modifier is public");
    }/*  w  w w  .  j a  v a2 s .c om*/
}

From source file:Main.java

private static void getClassModifier(Class clazz) {
    int modifier = clazz.getModifiers();

    if (Modifier.isStatic(modifier)) {
        System.out.println(clazz.getName() + " class modifier is static");
    }//w w w.  j  a  va  2s  .c  o m

}

From source file:Main.java

/**
 * Check whether the specified class is a CGLIB-generated class.
 *
 * @param clazz the class to check/*  ww  w.  jav  a2  s . c  om*/
 */
public static boolean isCglibProxyClass(Class<?> clazz) {
    return (clazz != null && isCglibProxyClassName(clazz.getName()));
}

From source file:Main.java

private static void getClassModifier(Class clazz) {
    int modifier = clazz.getModifiers();

    if (Modifier.isAbstract(modifier)) {
        System.out.println(clazz.getName() + " class modifier is abstract");
    }// w  w  w.  j a  va  2 s.  co  m
}

From source file:Main.java

/**
 * Compute the root directory of this maven project. This will result in the
 * same directory no matter if executed from Eclipse, this maven project root or
 * any parent maven pom directory. //from ww  w .  jav  a2s.c  o  m
 * 
 * @param anyTestClass Any test class *local* to the maven project, i.e that 
 * only exist in this maven project.
 * 
 * @param child The file that should be 
 * @return The root directory of this maven project.
 */
public static File computeMavenProjectRoot(Class<?> anyTestClass) {
    final String clsUri = anyTestClass.getName().replace('.', '/') + ".class";
    final URL url = anyTestClass.getClassLoader().getResource(clsUri);
    final String clsPath = url.getPath();
    // located in ./target/test-classes or ./eclipse-out/target
    final File target_test_classes = new File(clsPath.substring(0, clsPath.length() - clsUri.length()));
    // get parent's parent
    return target_test_classes.getParentFile().getParentFile();
}

From source file:Main.java

private static void getClassModifier(Class clazz) {
    int modifier = clazz.getModifiers();

    if (Modifier.isPrivate(modifier)) {
        System.out.println(clazz.getName() + " class modifier is private");
    }/*from  w w w  .j a v a  2 s .  c o  m*/

}

From source file:br.mdarte.exemplo.academico.SistemaacademicoLogger.java

public static synchronized void info(Object mensagem, Class classe, Throwable arg3) {
    log.info("[" + classe.getName() + "]" + mensagem, arg3);
}

From source file:br.mdarte.exemplo.academico.SistemaacademicoLogger.java

public static synchronized void warn(Object mensagem, Class classe, Throwable arg3) {
    log.warn("[" + classe.getName() + "]" + mensagem, arg3);
}