src/jdk.jfr/share/classes/jdk/jfr/internal/JVM.java
changeset 59226 a0f39cc47387
parent 58863 c16ac7a2eba4
child 59259 127ca611f19b
equal deleted inserted replaced
59225:80e1201f6c9a 59226:a0f39cc47387
    41     // JVM signals file changes by doing Object#notifu on this object
    41     // JVM signals file changes by doing Object#notifu on this object
    42     static final Object FILE_DELTA_CHANGE = new Object();
    42     static final Object FILE_DELTA_CHANGE = new Object();
    43 
    43 
    44     static final long RESERVED_CLASS_ID_LIMIT = 400;
    44     static final long RESERVED_CLASS_ID_LIMIT = 400;
    45 
    45 
    46     private volatile boolean recording;
       
    47     private volatile boolean nativeOK;
    46     private volatile boolean nativeOK;
    48 
    47 
    49     private static native void registerNatives();
    48     private static native void registerNatives();
    50 
    49 
    51     static {
    50     static {
    67 
    66 
    68     private JVM() {
    67     private JVM() {
    69     }
    68     }
    70 
    69 
    71     /**
    70     /**
       
    71      * Marks current chunk as final
       
    72      * <p>
       
    73      * This allows streaming clients to read the chunk header and
       
    74      * close the stream when no more data will be written into
       
    75      * the current repository.
       
    76      */
       
    77     public native void markChunkFinal();
       
    78 
       
    79     /**
    72      * Begin recording events
    80      * Begin recording events
    73      *
    81      *
    74      * Requires that JFR has been started with {@link #createNativeJFR()}
    82      * Requires that JFR has been started with {@link #createNativeJFR()}
    75      */
    83      */
    76     public native void beginRecording();
    84     public native void beginRecording();
       
    85 
       
    86     /**
       
    87      * Return true if the JVM is recording
       
    88      */
       
    89     public native boolean isRecording();
       
    90 
       
    91     /**
       
    92      * End recording events, which includes flushing data in thread buffers
       
    93      *
       
    94      * Requires that JFR has been started with {@link #createNativeJFR()}
       
    95      *
       
    96      */
       
    97     public native void endRecording();
    77 
    98 
    78     /**
    99     /**
    79      * Return ticks
   100      * Return ticks
    80      *
   101      *
    81      * @return the time, in ticks
   102      * @return the time, in ticks
    95      *
   116      *
    96      * @return true if the event was committed
   117      * @return true if the event was committed
    97      */
   118      */
    98     public native boolean emitEvent(long eventTypeId, long timestamp, long when);
   119     public native boolean emitEvent(long eventTypeId, long timestamp, long when);
    99 
   120 
   100     /**
   121 
   101      * End recording events, which includes flushing data in thread buffers
       
   102      *
       
   103      * Requires that JFR has been started with {@link #createNativeJFR()}
       
   104      *
       
   105      */
       
   106     public native void endRecording();
       
   107 
   122 
   108     /**
   123     /**
   109      * Return a list of all classes deriving from {@link jdk.internal.event.Event}
   124      * Return a list of all classes deriving from {@link jdk.internal.event.Event}
   110      *
   125      *
   111      * @return list of event classes.
   126      * @return list of event classes.
   352      *
   367      *
   353      * @param binary representation of descriptor
   368      * @param binary representation of descriptor
   354      */
   369      */
   355     public native void storeMetadataDescriptor(byte[] bytes);
   370     public native void storeMetadataDescriptor(byte[] bytes);
   356 
   371 
   357     public void endRecording_() {
       
   358         endRecording();
       
   359         recording = false;
       
   360     }
       
   361 
       
   362     public void beginRecording_() {
       
   363         beginRecording();
       
   364         recording = true;
       
   365     }
       
   366 
       
   367     public boolean isRecording() {
       
   368         return recording;
       
   369     }
       
   370 
       
   371     /**
   372     /**
   372      * If the JVM supports JVM TI and retransformation has not been disabled this
   373      * If the JVM supports JVM TI and retransformation has not been disabled this
   373      * method will return true. This flag can not change during the lifetime of
   374      * method will return true. This flag can not change during the lifetime of
   374      * the JVM.
   375      * the JVM.
   375      *
   376      *
   556      * Get the start time in nanos from the header of the current chunk
   557      * Get the start time in nanos from the header of the current chunk
   557      *
   558      *
   558      *@return start time of the recording in nanos, -1 in case of in-memory
   559      *@return start time of the recording in nanos, -1 in case of in-memory
   559      */
   560      */
   560     public native long getChunkStartNanos();
   561     public native long getChunkStartNanos();
       
   562 
   561 }
   563 }