Uploaded image for project: 'JDK'
  1. JDK
  2. JDK-7093328

JVMTI: jvmtiPrimitiveFieldCallback always report 0's for static primitives

    Details

    • Subcomponent:
    • Introduced In Build:
      b06
    • Introduced In Version:
    • Resolved In Build:
      b01
    • CPU:
      x86
    • OS:
      windows_7
    • Verification:
      Verified

      Backports

        Description

        FULL PRODUCT VERSION :
        java version "1.7.0"
        Java(TM) SE Runtime Environment (build 1.7.0-b147)
        Java HotSpot(TM) 64-Bit Server VM (build 21.0-b17, mixed mode)

        ADDITIONAL OS VERSION INFORMATION :
        Microsoft Windows [Version 6.1.7601]

        A DESCRIPTION OF THE PROBLEM :
        It seems that with jdk7, the jvmtiPrimitiveFieldCallback used with IterateThroughHeap() always reports 0's for static primitive fields. Non-static primitive fields seem to be reported correctly.

        REGRESSION. Last worked in version 6u26

        STEPS TO FOLLOW TO REPRODUCE THE PROBLEM :
        java-sample:

        class Test {
          private float pi = 3.1415927f;
          private static float pipi = 3.1415927f;
          private static String aString = “hello”;
        }

        Write an agent that does an IterateThroughHeap(), the jvmtiPrimitiveFieldCallback always reports 3.415927 for the non-static field "pi" of an instance of this class and 0 for the static field "pipi". This was working in Java6.

        EXPECTED VERSUS ACTUAL BEHAVIOR :
        EXPECTED -
        I'd exepcted that (as for java6) jvmtiPrimitiveFieldCallback returns 3.1415927 for "pipi" in the example above
        ACTUAL -
        0 instead of 3.1415927 for "pipi" in the example above

        REPRODUCIBILITY :
        This bug can be reproduced always.

        ---------- BEGIN SOURCE ----------
        import java.io.IOException;

        public class Test {
        private static String aString = "hello";
        private float pi = 3.1415927f;
        private static float pipi = 3.1415927f;

        public static void main(String[] args) throws Exception {
        Test test = new Test();
        waitForEnter();
        }

        public Test() {
        }

        private static void waitForEnter() throws IOException {
        System.out.println("waiting for ENTER, pipi="+pipi);
        System.in.skip(System.in.available());
        System.in.read();
        }
        }

        ---------- END SOURCE ----------

        CUSTOMER SUBMITTED WORKAROUND :
        none found
        1) To run the reproducer, use runStaticFields.cmd.

        C:\devtools\jdk1.7.0_x64\bin\java -agentpath:".\win64\lib\dtdagent.dll" StaticFields
        rem C:\devtools\jdk1.6.0_31_x64\bin\java -agentpath:".\win64\lib\dtdagent.dll" StaticFields

        You have to adapt JRE locations in this script first.

        2) relevant agent-source is in Agent.cpp, please note that this is a highly stripped-down version of our agent and error-checking is not done.

        3) when run with a JDK1.6.x_64, you will get something similar to waiting for ENTER, pipi=2.1415927 doDump invoked found instance of TestClass found primitiveField of TestClass (instance)
                float-value:3.141593
        found primitiveField of TestClass (static)
                float-value:2.141593 ( <===== )
        VMDeath

        4) when running with JDK1.7.0_64, you will get something similar to the following, please note that the float-value of the static-field is 0.00 although it is 2.1415 from java and when running with jdk1.6 waiting for ENTER, pipi=2.1415927 doDump invoked found primitiveField of TestClass (static)
                float-value:0.000000 ( <===== )
        found instance of TestClass
        found primitiveField of TestClass (instance)
                float-value:3.141593
        VMDeath

          Attachments

            Issue Links

              Activity

                People

                • Assignee:
                  rbackman Rickard Backman
                  Reporter:
                  webbuggrp Webbug Group
                • Votes:
                  0 Vote for this issue
                  Watchers:
                  3 Start watching this issue

                  Dates

                  • Created:
                    Updated:
                    Resolved:
                    Imported:
                    Indexed: