Here you can find the source of loadClass(ClassLoader classLoader, String className)
className
over given classLoader
and suppress ClassNotFoundException .
public static Class<?> loadClass(ClassLoader classLoader, String className)
//package com.java2s; /******************************************************************************* * Copyright (c) 2011 Google, Inc.// www . j a v a 2 s.c o m * All rights reserved. This program and the accompanying materials * are made available under the terms of the Eclipse Public License v1.0 * which accompanies this distribution, and is available at * http://www.eclipse.org/legal/epl-v10.html * * Contributors: * Google, Inc. - initial API and implementation *******************************************************************************/ public class Main { /** * Load class with given <code>className</code> over given <code>classLoader</code> and suppress * {@link ClassNotFoundException}. */ public static Class<?> loadClass(ClassLoader classLoader, String className) { try { return load(classLoader, className); } catch (ClassNotFoundException e) { return null; } } /** * Load class with given <code>className</code> over given <code>classLoader</code>. Support load * inner classes over Java class name (auto replace last "." to "$"). */ public static Class<?> load(ClassLoader classLoader, String className) throws ClassNotFoundException { try { return classLoader.loadClass(className); } catch (ClassNotFoundException e) { int index = className.lastIndexOf('.'); if (index > 0) { try { return classLoader .loadClass(className.substring(0, index) + "$" + className.substring(index + 1)); } catch (Throwable t) { } } throw e; } } }