diff --git a/core-java/src/main/java/com/baeldung/classloader/CustomClassLoader.java b/core-java/src/main/java/com/baeldung/classloader/CustomClassLoader.java index c44e863776..532adce1ab 100644 --- a/core-java/src/main/java/com/baeldung/classloader/CustomClassLoader.java +++ b/core-java/src/main/java/com/baeldung/classloader/CustomClassLoader.java @@ -1,11 +1,14 @@ package com.baeldung.classloader; -import java.io.*; +import java.io.ByteArrayOutputStream; +import java.io.File; +import java.io.IOException; +import java.io.InputStream; public class CustomClassLoader extends ClassLoader { - - public Class getClass(String name) throws ClassNotFoundException { + @Override + public Class findClass(String name) throws ClassNotFoundException { byte[] b = loadClassFromFile(name); return defineClass(name, b, 0, b.length); } diff --git a/core-java/src/test/java/com/baeldung/classloader/CustomClassLoaderUnitTest.java b/core-java/src/test/java/com/baeldung/classloader/CustomClassLoaderUnitTest.java index ec35885b84..cabf9f7bdb 100644 --- a/core-java/src/test/java/com/baeldung/classloader/CustomClassLoaderUnitTest.java +++ b/core-java/src/test/java/com/baeldung/classloader/CustomClassLoaderUnitTest.java @@ -11,7 +11,7 @@ public class CustomClassLoaderUnitTest { public void customLoader() throws ClassNotFoundException, IllegalAccessException, InstantiationException, NoSuchMethodException, InvocationTargetException { CustomClassLoader customClassLoader = new CustomClassLoader(); - Class c = customClassLoader.getClass(PrintClassLoader.class.getName()); + Class c = customClassLoader.findClass(PrintClassLoader.class.getName()); Object ob = c.newInstance();