From c1a9c42194d7945b8c5162de41d6c92410437247 Mon Sep 17 00:00:00 2001 From: root Date: Sat, 25 Jul 2020 18:23:39 +0000 Subject: [PATCH] Review - II Kevin Gilmore --- .../customLoader/ClassLoaderInfo.java | 11 ------- .../customLoader/CustomClassLoader.java | 32 ------------------- 2 files changed, 43 deletions(-) delete mode 100644 core-java-modules/core-java-jvm-2/src/main/java/com/baeldung/loadedclasslisting/customLoader/ClassLoaderInfo.java delete mode 100644 core-java-modules/core-java-jvm-2/src/main/java/com/baeldung/loadedclasslisting/customLoader/CustomClassLoader.java diff --git a/core-java-modules/core-java-jvm-2/src/main/java/com/baeldung/loadedclasslisting/customLoader/ClassLoaderInfo.java b/core-java-modules/core-java-jvm-2/src/main/java/com/baeldung/loadedclasslisting/customLoader/ClassLoaderInfo.java deleted file mode 100644 index 2574394c13..0000000000 --- a/core-java-modules/core-java-jvm-2/src/main/java/com/baeldung/loadedclasslisting/customLoader/ClassLoaderInfo.java +++ /dev/null @@ -1,11 +0,0 @@ -package com.baeldung.loadedclasslisting.customLoader; - -import java.util.ArrayList; - -public class ClassLoaderInfo { - - public void printClassLoaders() throws ClassNotFoundException { - System.out.println("Classloader of this class:" + ClassLoaderInfo.class.getClassLoader()); - System.out.println("Classloader of ArrayList:" + ArrayList.class.getClassLoader()); - } -} diff --git a/core-java-modules/core-java-jvm-2/src/main/java/com/baeldung/loadedclasslisting/customLoader/CustomClassLoader.java b/core-java-modules/core-java-jvm-2/src/main/java/com/baeldung/loadedclasslisting/customLoader/CustomClassLoader.java deleted file mode 100644 index a5f293f605..0000000000 --- a/core-java-modules/core-java-jvm-2/src/main/java/com/baeldung/loadedclasslisting/customLoader/CustomClassLoader.java +++ /dev/null @@ -1,32 +0,0 @@ -package com.baeldung.loadedclasslisting.customLoader; - -import java.io.ByteArrayOutputStream; -import java.io.File; -import java.io.IOException; -import java.io.InputStream; - -public class CustomClassLoader extends ClassLoader { - - @Override - public Class findClass(String name) throws ClassNotFoundException { - byte[] b = loadClassFromFile(name); - return defineClass(name, b, 0, b.length); - } - - private byte[] loadClassFromFile(String fileName) { - InputStream inputStream = getClass().getClassLoader() - .getResourceAsStream(fileName.replace('.', File.separatorChar) + ".class"); - byte[] buffer; - ByteArrayOutputStream byteStream = new ByteArrayOutputStream(); - int nextValue = 0; - try { - while ((nextValue = inputStream.read()) != -1) { - byteStream.write(nextValue); - } - } catch (IOException e) { - e.printStackTrace(); - } - buffer = byteStream.toByteArray(); - return buffer; - } -}