dumpclass icon indicating copy to clipboard operation
dumpclass copied to clipboard

jdk 11下面出错

Open hengyunabc opened this issue 4 years ago • 1 comments

因为即使加了各种的 --add-exports,在 jdk.hotspot.agent 里,是在 sun.jvm.hotspot.tools.jcore.ClassDump.run() 里 ,用Class.forName 来加载filter类的。用户自定义的类加载不到。

    public void run() {
        // Ready to go with the database...
        try {
            if (classFilter == null) {
                // If not already set, the name of the filter comes from a System property.
                // If we have a pkgList, pass it, otherwise let the filter read
                // its own System property for the list of classes.
                String filterClassName = System.getProperty("sun.jvm.hotspot.tools.jcore.filter",
                                                            "sun.jvm.hotspot.tools.jcore.PackageNameFilter");
                try {
                    Class filterClass = Class.forName(filterClassName);
                    if (pkgList == null) {
                        classFilter = (ClassFilter) filterClass.newInstance();
                    } else {
                        Constructor con = filterClass.getConstructor(String.class);
                        classFilter = (ClassFilter) con.newInstance(pkgList);
                    }
                } catch(Exception exp) {
                    System.err.println("Warning: Can not create class filter!");
                }
            }

/Library/Java/JavaVirtualMachines/jdk-11.0.4.jdk/Contents/Home/bin/java --add-modules ALL-SYSTEM --add-exports=jdk.hotspot.agent/sun.jvm.hotspot=ALL-UNNAMED --add-exports=jdk.hotspot.agent/sun.jvm.hotspot.runtime=ALL-UNNAMED --add-exports=jdk.hotspot.agent/sun.jvm.hotspot.memory=ALL-UNNAMED --add-exports=jdk.hotspot.agent/sun.jvm.hotspot.oops=ALL-UNNAMED --add-exports=jdk.hotspot.agent/sun.jvm.hotspot.utilities=ALL-UNNAMED --add-exports=jdk.hotspot.agent/sun.jvm.hotspot.tools.jcore=ALL-UNNAMED sun.jvm.hotspot.tools.jcore.ClassDump

http://hengyunabc.github.io/dumpclass/

hengyunabc avatar Apr 07 '20 18:04 hengyunabc

/Library/Java/JavaVirtualMachines/jdk-11.0.4.jdk/Contents/Home/bin/jhsdb hsdb

hengyunabc avatar Apr 07 '20 18:04 hengyunabc