Java Class Load loadClass(ClassLoader loader, String className)

Here you can find the source of loadClass(ClassLoader loader, String className)

Description

load Class

License

Apache License

Declaration

public static Class<?> loadClass(ClassLoader loader, String className) throws ClassNotFoundException 

Method Source Code

//package com.java2s;
//License from project: Apache License 

public class Main {
    public static Class<?> loadClass(ClassLoader loader, String className) throws ClassNotFoundException {
        try {//from w ww  .j a  v a  2s.  c  o m
            return loader.loadClass(className);
        } catch (ClassNotFoundException e) {
            return loadClass(className);
        }
    }

    public static Class<?> loadClass(String className) throws ClassNotFoundException {
        if (className.equals("boolean"))
            return boolean.class;
        if (className.equals("byte"))
            return byte.class;
        if (className.equals("short"))
            return short.class;
        if (className.equals("int"))
            return int.class;
        if (className.equals("long"))
            return long.class;
        if (className.equals("char"))
            return char.class;
        if (className.equals("float"))
            return float.class;
        if (className.equals("double"))
            return double.class;
        if (className.equals("void"))
            return void.class;
        return Class.forName(className);
    }
}

Related

  1. loadClass(Class contextClass, String className)
  2. loadClass(ClassLoader classLoader, Class clazz, String postfix)
  3. loadClass(ClassLoader classLoader, String className)
  4. loadClass(ClassLoader classLoader, String className)
  5. loadClass(ClassLoader classLoader, String fullyQualifiedClassName)
  6. loadClass(ClassLoader loader, String className, String errorMessage)
  7. loadClass(final ClassLoader cl, final String cname)
  8. loadClass(final ClassLoader classLoader, final String classname)
  9. loadClass(final String className)