Skip to content

Instantly share code, notes, and snippets.

@nipunthathsara
Created April 10, 2020 19:11
Show Gist options
  • Save nipunthathsara/5786f1933c43d68fae4b3361e79fb5cf to your computer and use it in GitHub Desktop.
Save nipunthathsara/5786f1933c43d68fae4b3361e79fb5cf to your computer and use it in GitHub Desktop.
URLClassLoader.java - Loading *.class files
...
protected Class<?> findClass(final String name)
throws ClassNotFoundException
{
final Class<?> result;
try {
result = AccessController.doPrivileged(
new PrivilegedExceptionAction<>() {
public Class<?> run() throws ClassNotFoundException {
String path = name.replace('.', '/').concat(".class");
Resource res = ucp.getResource(path, false);
if (res != null) {
try {
return defineClass(name, res);
} catch (IOException e) {
throw new ClassNotFoundException(name, e);
}
...
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment