Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@
*/
package com.oracle.svm.core.code;

import jdk.internal.loader.BuiltinClassLoader;
import org.graalvm.nativeimage.c.function.CodePointer;

import com.oracle.svm.core.CalleeSavedRegisters;
Expand All @@ -39,6 +40,9 @@
import jdk.vm.ci.meta.JavaConstant;
import jdk.vm.ci.meta.JavaKind;

import java.lang.module.ModuleDescriptor;
import java.util.Optional;

public class FrameInfoQueryResult {

public enum ValueType {
Expand Down Expand Up @@ -328,13 +332,24 @@ public int getSourceLineNumber() {
* Returns the name and source code location of the method.
*/
public StackTraceElement getSourceReference() {
/*
* According to StackTraceElement undefined className is denoted by "", undefined fileName
* is denoted by null
*/
final String className = sourceClass != null ? sourceClass.getName() : "";
String sourceFileName = sourceClass != null ? DynamicHub.fromClass(sourceClass).getSourceFileName() : null;
return new StackTraceElement(className, sourceMethodName, sourceFileName, sourceLineNumber);
if (sourceClass == null) {
return new StackTraceElement("", sourceMethodName, null, sourceLineNumber);
}

ClassLoader classLoader = sourceClass.getClassLoader();
String classLoaderName = null;
if (classLoader != null && !(classLoader instanceof BuiltinClassLoader)) {
classLoaderName = classLoader.getName();
}
Module module = sourceClass.getModule();
String moduleName = module.getName();
String moduleVersion = Optional.ofNullable(module.getDescriptor())
.flatMap(ModuleDescriptor::version)
.map(ModuleDescriptor.Version::toString)
.orElse(null);
String className = sourceClass.getName();
String sourceFileName = DynamicHub.fromClass(sourceClass).getSourceFileName();
return new StackTraceElement(classLoaderName, moduleName, moduleVersion, className, sourceMethodName, sourceFileName, sourceLineNumber);
}

public boolean isNativeMethod() {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -306,6 +306,7 @@ public final class DynamicHub implements JavaKind.FormatWithToString, AnnotatedE

@Platforms(Platform.HOSTED_ONLY.class)
public void setModule(Module module) {
assert module != null;
this.module = module;
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,6 @@
import org.graalvm.compiler.phases.OptimisticOptimizations;
import org.graalvm.compiler.phases.common.BoxNodeIdentityPhase;
import org.graalvm.compiler.phases.common.CanonicalizerPhase;
import org.graalvm.compiler.serviceprovider.JavaVersionUtil;
import org.graalvm.compiler.virtual.phases.ea.PartialEscapePhase;
import org.graalvm.nativeimage.Platform;
import org.graalvm.nativeimage.Platforms;
Expand Down Expand Up @@ -391,9 +390,7 @@ private DynamicHub createHub(AnalysisType type) {
isLocalClass(javaClass), isAnonymousClass(javaClass), superHub, componentHub, sourceFileName,
modifiers, hubClassLoader, isHidden, isRecord, nestHost, assertionStatus, type.hasDefaultMethods(),
type.declaresDefaultMethods(), isSealed);
if (JavaVersionUtil.JAVA_SPEC > 8) {
ModuleAccess.extractAndSetModule(dynamicHub, javaClass);
}
ModuleAccess.extractAndSetModule(dynamicHub, javaClass);
return dynamicHub;
}

Expand Down