Here you can find the source of loadClass(String className)
Parameter | Description |
---|---|
className | class name |
public static Class<?> loadClass(String className) throws ClassNotFoundException
//package com.java2s; //License from project: Apache License public class Main { private static ClassLoader currentClassLoader; /**/*w w w . j a va2s.c o m*/ * Load class from the previously set class loader. If not set, use * default class loader * * @param className class name * @return the loaded class */ public static Class<?> loadClass(String className) throws ClassNotFoundException { ClassLoader loader = currentClassLoader; if (loader == null) { loader = Thread.currentThread().getContextClassLoader(); } try { return Class.forName(className, false, loader); } catch (ClassNotFoundException e) { ClassLoader contextLoader = Thread.currentThread().getContextClassLoader(); if (contextLoader != loader) { return Class.forName(className, false, contextLoader); } throw e; } } }