Code Review BAEL-4302

This commit is contained in:
root 2020-07-14 18:59:16 +00:00
parent b2a0fcd76b
commit c5c128033d
4 changed files with 5 additions and 11 deletions

View File

@ -1,6 +0,0 @@
package com.baeldung.loadedclasslisting;
public enum ClassLoaderType {
SYSTEM, EXTENSION, BOOTSTRAP, CUSTOM
}

View File

@ -3,6 +3,7 @@ package com.baeldung.loadedclasslisting;
import java.lang.reflect.Method;
import java.util.Arrays;
import com.baeldung.loadedclasslisting.ListLoadedClassesAgent.ClassLoaderType;
import com.baeldung.loadedclasslisting.customLoader.ClassLoaderInfo;
import com.baeldung.loadedclasslisting.customLoader.CustomClassLoader;
@ -11,13 +12,9 @@ public class Launcher {
private static ClassLoader customClassLoader;
public static void main(String[] args) {
printClassesLoadedBy(ClassLoaderType.BOOTSTRAP);
printClassesLoadedBy(ClassLoaderType.SYSTEM);
printClassesLoadedBy(ClassLoaderType.EXTENSION);
printClassesLoadedBy(ClassLoaderType.CUSTOM);
}

View File

@ -4,6 +4,10 @@ import java.lang.instrument.Instrumentation;
public class ListLoadedClassesAgent {
public enum ClassLoaderType {
SYSTEM, EXTENSION, BOOTSTRAP, CUSTOM , PLATFORM
}
private static Instrumentation instrumentation;
public static void premain(String agentArgs, Instrumentation instrumentation) {

View File

@ -5,7 +5,6 @@ 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());
}