Here you can find the source of loadClass(final String className, final ClassLoader classLoader)
Parameter | Description |
---|---|
className | is the class to instantiate |
classLoader | the class loader to use; may be null if the current class loader is to be used |
Parameter | Description |
---|---|
ClassNotFoundException | an exception |
private static final Class<?> loadClass(final String className, final ClassLoader classLoader) throws ClassNotFoundException
//package com.java2s; /*//from w w w . jav a2s .c o m * JBoss, Home of Professional Open Source. * * See the LEGAL.txt file distributed with this work for information regarding copyright ownership and licensing. * * See the AUTHORS.txt file distributed with this work for a full listing of individual contributors. */ public class Main { /** * Helper method to load a class. * @param className is the class to instantiate * @param classLoader the class loader to use; may be null if the current * class loader is to be used * @return Class is the instance of the class * @throws ClassNotFoundException */ private static final Class<?> loadClass(final String className, final ClassLoader classLoader) throws ClassNotFoundException { Class<?> cls = null; if (classLoader == null) { cls = Class.forName(className.trim()); } else { cls = Class.forName(className.trim(), true, classLoader); } return cls; } }