[英]How to get all the classes my application load in JAVA
How to get all the classes loaded by my application running in integrated weblogic server . 如何让我的应用程序在集成的weblogic服务器中运行时加载所有类。 I used java -verbose:class and created a javaagent that returns .getAllLoadedClasses() using Instrumentation package . 我使用java-verbose:class并创建了一个使用Instrumentation包返回.getAllLoadedClasses()的javaagent。 Both returns a large set of results mainly from packages java.* and sun.* but no class from my app was present in the output. 两者都主要从包java。*和sun。*返回大量结果,但是输出中不存在我的应用程序中的类。 How to get the classes loaded by my app. 如何获取我的应用加载的类。 I am a beginner. 我是初学者。 Please help. 请帮忙。
You can try something with following 您可以尝试以下操作
Reflections reflections = new Reflections(ClasspathHelper
.forClass(Object.class),new SubTypesScanner(false));
Set<String> classList =reflections.
getStore().getSubTypesOf(Object.class.getName())
FYI: Reflections 仅供参考: 思考
You might try to experiment with java.lang.ClassLoader
. 您可以尝试使用java.lang.ClassLoader
进行试验。 This class has an internal attribute classes
of type Vector
. 此类具有类型为Vector
的内部属性classes
。 If you use reflection then you can access the loaded classes of its classloader-instance only. 如果使用反射,则只能访问其classloader-instance的已加载类。 And of course you can also go up the ClassLoader-hierarchy to ask the parents of application classloader. 当然,您也可以向上ClassLoader层次结构询问应用程序类加载器的父级。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.