@@ -70,7 +70,7 @@ public class PosixJfrEmergencyDumpSupport implements com.oracle.svm.core.jfr.Jfr
7070 @ BasedOnJDKFile ("https://github.com/openjdk/jdk/blob/jdk-26+2/src/hotspot/os/posix/include/jvm_md.h#L57" ) //
7171 private static final int JVM_MAXPATHLEN = 4096 ;
7272 @ BasedOnJDKFile ("https://github.com/openjdk/jdk/blob/jdk-26+2/src/hotspot/share/jfr/recorder/repository/jfrEmergencyDump.cpp#L47" ) //
73- private static int ISO8601_LEN = 19 ;
73+ private static final int ISO_8601_LEN = 19 ;
7474 private static final byte FILE_SEPARATOR = "/" .getBytes (StandardCharsets .UTF_8 )[0 ];
7575 private static final byte DOT = "." .getBytes (StandardCharsets .UTF_8 )[0 ];
7676 // It does not really matter what the name is.
@@ -88,37 +88,46 @@ public class PosixJfrEmergencyDumpSupport implements com.oracle.svm.core.jfr.Jfr
8888 public PosixJfrEmergencyDumpSupport () {
8989 }
9090
91+ @ Override
9192 public void initialize () {
9293 pidBytes = String .valueOf (ProcessHandle .current ().pid ()).getBytes (StandardCharsets .UTF_8 );
9394 pathBuffer = NativeMemory .calloc (JVM_MAXPATHLEN , NmtCategory .JFR );
9495 directory = WordFactory .nullPointer ();
9596 }
9697
98+ @ Override
9799 public void setRepositoryLocation (String dirText ) {
98100 repositoryLocationBytes = dirText .getBytes (StandardCharsets .UTF_8 );
99101 }
100102
103+ @ Override
101104 public void setDumpPath (String dumpPathText ) {
102105 dumpPathBytes = dumpPathText .getBytes (StandardCharsets .UTF_8 );
103106 }
104107
108+ @ Override
105109 public String getDumpPath () {
106110 if (dumpPathBytes != null ) {
107111 return new String (dumpPathBytes , StandardCharsets .UTF_8 );
108112 }
109113 return "" ;
110114 }
111115
112- // Either use create and use the dumpfile itself, or create a new file in the repository
113- // location.
116+ /*
117+ * Either use create and use the dumpfile itself, or create a new file in the repository
118+ * location.
119+ */
120+ @ Override
114121 @ BasedOnJDKFile ("https://github.com/openjdk/jdk/blob/jdk-26+3/src/hotspot/share/jfr/recorder/repository/jfrEmergencyDump.cpp#L433-L445" )
115122 public RawFileDescriptor chunkPath () {
116123 if (repositoryLocationBytes == null ) {
117124 if (!openEmergencyDumpFile ()) {
118125 return WordFactory .nullPointer ();
119126 }
120- // We can directly use the emergency dump file name as the new chunk since there are no
121- // other chunk files.
127+ /*
128+ * We can directly use the emergency dump file name as the new chunk since there are no
129+ * other chunk files.
130+ */
122131 return emergencyFd ;
123132 }
124133 Log .log ().string ("Creating a new emergency chunk file in the JFR disk repository" ).newline ();
@@ -141,6 +150,7 @@ private RawFileDescriptor createEmergencyChunkPath() {
141150 return getFileSupport ().create (getPathBuffer (), FileCreationMode .CREATE , FileAccessMode .READ_WRITE );
142151 }
143152
153+ @ Override
144154 @ BasedOnJDKFile ("https://github.com/openjdk/jdk/blob/jdk-26+2/src/hotspot/share/jfr/recorder/repository/jfrEmergencyDump.cpp#L409-L416" )
145155 public void onVmError () {
146156 Log .log ().string ("Attempting JFR Emergency Dump" ).newline ();
@@ -213,12 +223,6 @@ private GrowableWordArray iterateRepository(GrowableWordArray gwa) {
213223 if (count > 0 ) {
214224 GrowableWordArrayAccess .qsort (gwa , 0 , count - 1 , PosixJfrEmergencyDumpSupport ::compare );
215225 }
216- // for (int i=0; i < count; i ++){ // todo remove
217- // String name =
218- // org.graalvm.nativeimage.c.type.CTypeConversion.toJavaString(GrowableWordArrayAccess.read(gwa,
219- // i));
220- // System.out.println("chunk file: "+ name);
221- // }
222226 }
223227 return WordFactory .nullPointer ();
224228 }
@@ -227,7 +231,7 @@ private GrowableWordArray iterateRepository(GrowableWordArray gwa) {
227231 static int compare (Word a , Word b ) {
228232 CCharPointer filenameA = (CCharPointer ) a ;
229233 CCharPointer filenameB = (CCharPointer ) b ;
230- int cmp = LibC .strncmp (filenameA , filenameB , WordFactory .unsigned (ISO8601_LEN ));
234+ int cmp = LibC .strncmp (filenameA , filenameB , WordFactory .unsigned (ISO_8601_LEN ));
231235 if (cmp == 0 ) {
232236 CCharPointer aDot = SubstrateUtil .strchr (filenameA , DOT );
233237 CCharPointer bDot = SubstrateUtil .strchr (filenameB , DOT );
@@ -306,8 +310,8 @@ private CCharPointer getRepositoryLocation() {
306310 }
307311
308312 /**
309- * See
310- * {@link com.oracle.svm.core.posix.jvmstat.PosixPerfMemoryProvider#restartableOpen(CCharPointer, int, int)}
313+ * See com.oracle.svm.core.posix.jvmstat.PosixPerfMemoryProvider#restartableOpen(CCharPointer,
314+ * int, int).
311315 */
312316 @ Uninterruptible (reason = "LibC.errno() must not be overwritten accidentally." )
313317 private static int restartableOpen (CCharPointer directory , int flags , int mode ) {
@@ -363,8 +367,6 @@ private CCharPointer fullyQualified(CCharPointer fn) {
363367
364368 clearPathBuffer ();
365369
366- // TODO HS uses _path_buffer_file_name_offset to avoid building this part of th path each
367- // time.
368370 // Cached in RepositoryIterator::RepositoryIterator and used in fully_qualified
369371 idx = writeToPathBuffer (repositoryLocationBytes , idx );
370372
@@ -386,7 +388,8 @@ private void clearPathBuffer() {
386388 LibC .memset (getPathBuffer (), Word .signed (0 ), Word .unsigned (JVM_MAXPATHLEN ));
387389 }
388390
389- private int writeToPathBuffer (byte [] bytes , int idx ) {
391+ private int writeToPathBuffer (byte [] bytes , int start ) {
392+ int idx = start ;
390393 for (int i = 0 ; i < bytes .length ; i ++) {
391394 getPathBuffer ().write (idx ++, bytes [i ]);
392395 }
@@ -412,6 +415,7 @@ private void closeDirectory() {
412415 }
413416 }
414417
418+ @ Override
415419 public void teardown () {
416420 closeEmergencyDumpFile ();
417421 closeDirectory ();
0 commit comments