Skip to content

Commit 932061d

Browse files
committed
Core: fix dumping debug class/source files
Previously, the given name was used to construct the dump file path. The given name may be delimited using `.` or `/`, which leads to a strange situation where some debug files are dumped into a directory hierarchy (`com/example/foo/bar/MyClass.class`), while other debug files are dumped into the root directory (`com.example.foo.bar.MyClass.class`). With this commit, we no longer use the deprecated `getName()` method to construct the dump file paths. Instead, we always use the `internalName()` method, which returns a `/`-delimited name, so that all files are dumped into a directory hierarchy. For log messages, on the other hand, we always use the `binaryName()` method, which returns a `.`-delimited name, so that logging uses classic Java class names.
1 parent fb5b21c commit 932061d

File tree

1 file changed

+7
-7
lines changed

1 file changed

+7
-7
lines changed

core/deployment/src/main/java/io/quarkus/runner/bootstrap/StartupActionImpl.java

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -445,45 +445,45 @@ private static Map<String, byte[]> extractTransformedClasses(BuildResult buildRe
445445

446446
private static Map<String, byte[]> extractGeneratedResources(BuildResult buildResult, boolean applicationClasses) {
447447
Map<String, byte[]> data = new HashMap<>();
448+
String debugClassesDir = BootstrapDebug.debugClassesDir();
449+
String debugSourcesDir = BootstrapDebug.debugSourcesDir();
448450
for (GeneratedClassBuildItem i : buildResult.consumeMulti(GeneratedClassBuildItem.class)) {
449451
if (i.isApplicationClass() == applicationClasses) {
450452
data.put(fromClassNameToResourceName(i.getName()), i.getClassData());
451-
var debugClassesDir = BootstrapDebug.debugClassesDir();
452453
if (debugClassesDir != null) {
453454
try {
454455
File debugPath = new File(debugClassesDir);
455456
if (!debugPath.exists()) {
456457
debugPath.mkdir();
457458
}
458-
File classFile = new File(debugPath, i.getName() + ".class");
459+
File classFile = new File(debugPath, i.internalName() + ".class");
459460
classFile.getParentFile().mkdirs();
460461
try (FileOutputStream classWriter = new FileOutputStream(classFile)) {
461462
classWriter.write(i.getClassData());
462463
}
463464
log.infof("Wrote %s", classFile.getAbsolutePath());
464465
} catch (Exception t) {
465-
log.errorf(t, "Failed to write debug class files %s", i.getName());
466+
log.errorf(t, "Failed to write debug class file for %s", i.binaryName());
466467
}
467468
}
468469

469-
String debugSourcesDir = BootstrapDebug.debugSourcesDir();
470470
if (debugSourcesDir != null) {
471471
try {
472472
if (i.getSource() != null) {
473473
File debugPath = new File(debugSourcesDir);
474474
if (!debugPath.exists()) {
475475
debugPath.mkdir();
476476
}
477-
File sourceFile = new File(debugPath, i.getName() + ".zig");
477+
File sourceFile = new File(debugPath, i.internalName() + ".zig");
478478
sourceFile.getParentFile().mkdirs();
479479
Files.write(sourceFile.toPath(), i.getSource().getBytes(StandardCharsets.UTF_8),
480480
StandardOpenOption.CREATE);
481481
log.infof("Wrote source %s", sourceFile.getAbsolutePath());
482482
} else {
483-
log.infof("Source not available: %s", i.getName());
483+
log.infof("Source not available: %s", i.binaryName());
484484
}
485485
} catch (Exception t) {
486-
log.errorf(t, "Failed to write debug source file %s", i.getName());
486+
log.errorf(t, "Failed to write debug source file for %s", i.binaryName());
487487
}
488488
}
489489
}

0 commit comments

Comments
 (0)