|
24 | 24 | */ |
25 | 25 | package com.oracle.svm.core.code; |
26 | 26 |
|
| 27 | +import jdk.internal.loader.BuiltinClassLoader; |
27 | 28 | import org.graalvm.nativeimage.c.function.CodePointer; |
28 | 29 |
|
29 | 30 | import com.oracle.svm.core.CalleeSavedRegisters; |
|
39 | 40 | import jdk.vm.ci.meta.JavaConstant; |
40 | 41 | import jdk.vm.ci.meta.JavaKind; |
41 | 42 |
|
| 43 | +import java.lang.module.ModuleDescriptor; |
| 44 | +import java.util.Optional; |
| 45 | + |
42 | 46 | public class FrameInfoQueryResult { |
43 | 47 |
|
44 | 48 | public enum ValueType { |
@@ -328,13 +332,24 @@ public int getSourceLineNumber() { |
328 | 332 | * Returns the name and source code location of the method. |
329 | 333 | */ |
330 | 334 | public StackTraceElement getSourceReference() { |
331 | | - /* |
332 | | - * According to StackTraceElement undefined className is denoted by "", undefined fileName |
333 | | - * is denoted by null |
334 | | - */ |
335 | | - final String className = sourceClass != null ? sourceClass.getName() : ""; |
336 | | - String sourceFileName = sourceClass != null ? DynamicHub.fromClass(sourceClass).getSourceFileName() : null; |
337 | | - return new StackTraceElement(className, sourceMethodName, sourceFileName, sourceLineNumber); |
| 335 | + if (sourceClass == null) { |
| 336 | + return new StackTraceElement("", sourceMethodName, null, sourceLineNumber); |
| 337 | + } |
| 338 | + |
| 339 | + ClassLoader classLoader = sourceClass.getClassLoader(); |
| 340 | + String classLoaderName = null; |
| 341 | + if (classLoader != null && !(classLoader instanceof BuiltinClassLoader)) { |
| 342 | + classLoaderName = classLoader.getName(); |
| 343 | + } |
| 344 | + Module module = sourceClass.getModule(); |
| 345 | + String moduleName = module.getName(); |
| 346 | + String moduleVersion = Optional.ofNullable(module.getDescriptor()) |
| 347 | + .flatMap(ModuleDescriptor::version) |
| 348 | + .map(ModuleDescriptor.Version::toString) |
| 349 | + .orElse(null); |
| 350 | + String className = sourceClass.getName(); |
| 351 | + String sourceFileName = DynamicHub.fromClass(sourceClass).getSourceFileName(); |
| 352 | + return new StackTraceElement(classLoaderName, moduleName, moduleVersion, className, sourceMethodName, sourceFileName, sourceLineNumber); |
338 | 353 | } |
339 | 354 |
|
340 | 355 | public boolean isNativeMethod() { |
|
0 commit comments