|
1 | 1 | /*
|
2 |
| - * Copyright (c) 2015, 2019, Oracle and/or its affiliates. All rights reserved. |
| 2 | + * Copyright (c) 2015, 2025, Oracle and/or its affiliates. All rights reserved. |
3 | 3 | * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
|
4 | 4 | *
|
5 | 5 | * This code is free software; you can redistribute it and/or modify it
|
|
65 | 65 | import jdk.graal.compiler.options.OptionType;
|
66 | 66 | import jdk.graal.compiler.word.Word;
|
67 | 67 |
|
68 |
| -import java.text.SimpleDateFormat; |
69 |
| - |
70 | 68 | public class RuntimeCodeCache {
|
71 | 69 |
|
72 | 70 | public static class Options {
|
@@ -174,11 +172,18 @@ private static RawFileOperationSupport getFileSupport() {
|
174 | 172 | }
|
175 | 173 |
|
176 | 174 | private static void dumpMethod(CodeInfo info) {
|
177 |
| - String methodName = CodeInfoAccess.getName(info); |
178 |
| - int tier = CodeInfoAccess.getTier(info); |
179 |
| - String date = new SimpleDateFormat("yyyy.MM.dd.HH.mm.ss").format(new java.util.Date()); |
180 | 175 | String tmpDirPath = getFileSupport().getTempDirectory();
|
181 |
| - String filePath = tmpDirPath + "/" + date + "_" + methodName + "_" + tier + ".bin"; |
| 176 | + String prefix = System.nanoTime() + "_"; |
| 177 | + String methodName = SubstrateUtil.sanitizeForFileName(CodeInfoAccess.getName(info)); |
| 178 | + String suffix = "_" + CodeInfoAccess.getTier(info) + ".bin"; |
| 179 | + |
| 180 | + // Check that the file name size does not exceed the 255 chars |
| 181 | + int maxMethodNameSize = 255 - prefix.length() - suffix.length(); |
| 182 | + if (methodName.length() > maxMethodNameSize) { |
| 183 | + methodName = methodName.substring(maxMethodNameSize); |
| 184 | + } |
| 185 | + |
| 186 | + String filePath = tmpDirPath + "/" + prefix + methodName + suffix; |
182 | 187 |
|
183 | 188 | RawFileOperationSupport.RawFileDescriptor fd = getFileSupport().create(filePath, CREATE_OR_REPLACE, WRITE);
|
184 | 189 | if (!getFileSupport().isValid(fd)) {
|
|
0 commit comments