jdk/src/share/classes/com/sun/demo/jvmti/hprof/Tracker.java
changeset 20823 ddd111318407
parent 5506 202f599c92aa
child 23010 6dadb192ad81
equal deleted inserted replaced
20822:2552851d9562 20823:ddd111318407
    51 
    51 
    52     private static native void nativeObjectInit(Object thr, Object obj);
    52     private static native void nativeObjectInit(Object thr, Object obj);
    53 
    53 
    54     public static void ObjectInit(Object obj)
    54     public static void ObjectInit(Object obj)
    55     {
    55     {
    56         if ( engaged != 0 ) {
    56         if ( engaged != 0) {
       
    57             if (obj == null) {
       
    58                 throw new IllegalArgumentException("Null object.");
       
    59             }
    57             nativeObjectInit(Thread.currentThread(), obj);
    60             nativeObjectInit(Thread.currentThread(), obj);
    58         }
    61         }
    59     }
    62     }
    60 
    63 
    61     /* Immediately following any of the newarray bytecodes, a call to
    64     /* Immediately following any of the newarray bytecodes, a call to
    64 
    67 
    65     private static native void nativeNewArray(Object thr, Object obj);
    68     private static native void nativeNewArray(Object thr, Object obj);
    66 
    69 
    67     public static void NewArray(Object obj)
    70     public static void NewArray(Object obj)
    68     {
    71     {
    69         if ( engaged != 0 ) {
    72         if ( engaged != 0) {
       
    73             if (obj == null) {
       
    74                 throw new IllegalArgumentException("Null object.");
       
    75             }
    70             nativeNewArray(Thread.currentThread(), obj);
    76             nativeNewArray(Thread.currentThread(), obj);
    71         }
    77         }
    72     }
    78     }
    73 
    79 
    74     /* For cpu time spent in methods, we need to inject for every method. */
    80     /* For cpu time spent in methods, we need to inject for every method. */
    80     private static native void nativeCallSite(Object thr, int cnum, int mnum);
    86     private static native void nativeCallSite(Object thr, int cnum, int mnum);
    81 
    87 
    82     public static void CallSite(int cnum, int mnum)
    88     public static void CallSite(int cnum, int mnum)
    83     {
    89     {
    84         if ( engaged != 0 ) {
    90         if ( engaged != 0 ) {
       
    91             if (cnum < 0) {
       
    92                 throw new IllegalArgumentException("Negative class index");
       
    93             }
       
    94 
       
    95             if (mnum < 0) {
       
    96                 throw new IllegalArgumentException("Negative method index");
       
    97             }
       
    98 
    85             nativeCallSite(Thread.currentThread(), cnum, mnum);
    99             nativeCallSite(Thread.currentThread(), cnum, mnum);
    86         }
   100         }
    87     }
   101     }
    88 
   102 
    89     /* Before any of the return bytecodes, a call to
   103     /* Before any of the return bytecodes, a call to
    93     private static native void nativeReturnSite(Object thr, int cnum, int mnum);
   107     private static native void nativeReturnSite(Object thr, int cnum, int mnum);
    94 
   108 
    95     public static void ReturnSite(int cnum, int mnum)
   109     public static void ReturnSite(int cnum, int mnum)
    96     {
   110     {
    97         if ( engaged != 0 ) {
   111         if ( engaged != 0 ) {
       
   112             if (cnum < 0) {
       
   113                 throw new IllegalArgumentException("Negative class index");
       
   114             }
       
   115 
       
   116             if (mnum < 0) {
       
   117                 throw new IllegalArgumentException("Negative method index");
       
   118             }
       
   119 
    98             nativeReturnSite(Thread.currentThread(), cnum, mnum);
   120             nativeReturnSite(Thread.currentThread(), cnum, mnum);
    99         }
   121         }
   100     }
   122     }
   101 
   123 
   102 }
   124 }