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

Overflow in java.lang.instrument.Instrumentation.getObjectSize() method

    Details

      Backports

        Description

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

        ADDITIONAL OS VERSION INFORMATION :
        Windows 7 64-bit

        A DESCRIPTION OF THE PROBLEM :
        Overflow in method long getObjectSize(Object objectToSize) from java.lang.instrument.Instrumentation

        instrumentation.getObjectSize(new int[600_000_000]) returns -1894967280 (negative value)

        STEPS TO FOLLOW TO REPRODUCE THE PROBLEM :
        java.exe -Xmx4000m -javaagent:object_size_test.jar -jar object_size_test.jar

        EXPECTED VERSUS ACTUAL BEHAVIOR :
        EXPECTED -
        2400000016
        ACTUAL -
        -1894967280

        REPRODUCIBILITY :
        This bug can be reproduced always.

        ---------- BEGIN SOURCE ----------
        import java.lang.instrument.Instrumentation;

        public class ObjectSizeTest {

        private static Instrumentation instrumentation;

        public static void premain(String options, Instrumentation instrumentation) {
        ObjectSizeTest.instrumentation = instrumentation;
        }

        public static void main(String[] args) {
        int[] a = new int[1000_000_000];
        System.out.println(instrumentation.getObjectSize(a));
        }
        }
        ---------- END SOURCE ----------

          Attachments

            Issue Links

              Activity

                People

                • Assignee:
                  allwin Peter Allwin (Inactive)
                  Reporter:
                  mcastegr Mattis Castegren (Inactive)
                • Votes:
                  0 Vote for this issue
                  Watchers:
                  6 Start watching this issue

                  Dates

                  • Created:
                    Updated:
                    Resolved: