Question

recently I am doing an experiment on JVM and bytecode.

I use these code snippets to test.

import java.util.*;

public class Simple {

    private String a = "abcdefghijklmnopaqrstuvwaxyazaaabcdefghijklmnopaqrstuvwaxyazaabcdefghijklmnopaqrstuvwaxyazaabcdefghijklmnopaqrstuvwaxyaz";

    public int test()
    {
        String bb = "abcdefghijklmnopaqrstuvwaxyazaaabcdefghijklmnopaqrstuvwaxyazaabcdefghijklmnopaqrstuvwaxyazaabcdefghijklmnopaqrstuvwaxyaz";

        int a = 0;
        int b = a;
        int c = a + b;
        return c;
    }

    public static void main(String[] args) 
    {
        String cc = "abcdefghijklmnopaqrstuvwaxyazaaabcdefghijklmnopaqrstuvwaxyazaabcdefghijklmnopaqrstuvwaxyazaabcdefghijklmnopaqrstuvwaxyaz";

        Simple simple = new Simple();
        simple.test();

        Scanner input=new Scanner(System.in);
        System.out.println("how much money do you need?");
        double  number=input.nextDouble();
    }
} 

FIrstly I use HotSpot to conduct the experiment. On Windows, I trun off the

-Djava.compiler=NONE

and use HeapMemView to view the HotSpot's heap memory. I can find a sequence of "6162 6364.."(whichs match my private String variant) and find my code snippet's bytecode sequence.

But I cannot find the bytecode sequence of Java Standard library.. like

Java.Lang.Obeject
Java.Lang.Math

What's wrong..? In my understanding, I think I should find their bytecode sequence in the JVM's heap..

Then I use JRocket to do it again.. use

   -Djava.compiler=NONE

to turn of the complier mode... but this time I cannot even find my String variant on the heap....

I am trapped here for two days.. Could anybody can me some help...? I really really appreciate it...

Thank you!

Was it helpful?

Solution

I am trapped here for two days.. Could anybody can me some help...? I really really appreciate it...

I would focus on the problem you are trying to solve first. Perhaps you could make it clearer as to why you are doing this in the question.

On Windows, I trun off the -Djava.compiler=NONE

This only changes how the code is compiled to native code. This will not change the heap in any way.

But I cannot find the bytecode sequence of Java Standard library.. like

The byte code and class definitions are not in the heap, they are in the perm gen.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top