Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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

Tags:

java

jvm

maven

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

like image 470
Erouax Avatar asked Mar 07 '17 15:03

Erouax


1 Answers

Add $JAVA_HOME/lib/sa-jdi.jar to CLASSPATH.

like image 183
apangin Avatar answered Sep 23 '22 20:09

apangin