简体   繁体   中英

Maven can't find sun.jvm.hotspot when compiling

I'm trying to use sum.jvm tools in my Java program. It allows me to program using sun.jvm.* but it when i try to compile it (clean, install) i get this:

error: package sun.jvm.hotspot.memory does not exist

Basically a ton of these errors for wherever i used a sun.jvm reference.

I've looked around a lot and i can't see to find anyone else with this problem so far... Does anyone know a fix to this?

I'm trying to create a Tools subclass that scans the JVM for certain strings, i found out i need to use sun.jvm, but now it wont work.

This is my method:

@Override
public void run() {
    SystemDictionary dict = VM.getVM().getSystemDictionary();
    InstanceKlass stringKlass = (InstanceKlass) dict.find("java/lang/String", null, null);
    OopField valueField = (OopField) stringKlass.findField("value", "[C");

    long[] stats = new long[2];
    VM.getVM().getStringTable().stringsDo(s -> {
        s.printValueOn(System.out);
        System.out.println();
        stats[0]++;
        stats[1] += s.getObjectSize() + valueField.getValue(s).getObjectSize();
    });
}

That i'm using to test in the Tools subclass. Anywhere in my project that i reference sun.jvm it gives that error when i try to do a clean install with Maven. It builds with IntelliJ's built in compiler, but not Maven.

I've also tried to re-import Maven, and even re-install IntelliJ and compile it with a fresh install.

It happens with all sun.jvm.hotspot.* paths.

Thanks, Erouax

$JAVA_HOME/lib/sa-jdi.jar到CLASSPATH。

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM