diff --git a/substratevm/mx.substratevm/suite.py b/substratevm/mx.substratevm/suite.py index b67ec406fa82..5cdb7dccf095 100644 --- a/substratevm/mx.substratevm/suite.py +++ b/substratevm/mx.substratevm/suite.py @@ -229,6 +229,7 @@ "java.compiler", ], "requiresConcealed" : { + "jdk.internal.vm.ci": ["jdk.vm.ci.meta"], "java.base" : [ "jdk.internal.module", "jdk.internal.reflect", diff --git a/substratevm/src/com.oracle.svm.core.jdk11/src/com/oracle/svm/core/code/SourceReferenceSupplier.java b/substratevm/src/com.oracle.svm.core.jdk11/src/com/oracle/svm/core/code/SourceReferenceSupplier.java new file mode 100644 index 000000000000..50726827ba85 --- /dev/null +++ b/substratevm/src/com.oracle.svm.core.jdk11/src/com/oracle/svm/core/code/SourceReferenceSupplier.java @@ -0,0 +1,47 @@ +/* + * Copyright (c) 2021, 2021, Oracle and/or its affiliates. All rights reserved. + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * This code is free software; you can redistribute it and/or modify it + * under the terms of the GNU General Public License version 2 only, as + * published by the Free Software Foundation. Oracle designates this + * particular file as subject to the "Classpath" exception as provided + * by Oracle in the LICENSE file that accompanied this code. + * + * This code is distributed in the hope that it will be useful, but WITHOUT + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License + * version 2 for more details (a copy is included in the LICENSE file that + * accompanied this code). + * + * You should have received a copy of the GNU General Public License version + * 2 along with this work; if not, write to the Free Software Foundation, + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. + * + * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA + * or visit www.oracle.com if you need additional information or have any + * questions. + */ +package com.oracle.svm.core.code; + +import com.oracle.svm.core.hub.DynamicHub; + +import java.lang.module.ModuleDescriptor; +import java.util.Optional; + +final class SourceReferenceSupplier { + + public static StackTraceElement createReference(Class sourceClass, String sourceMethodName, int sourceLineNumber) { + if (sourceClass == null) { + return new StackTraceElement("", sourceMethodName, null, sourceLineNumber); + } + + final String classLoaderName = sourceClass.getClassLoader() != null ? sourceClass.getClassLoader().getName() : null; + final String moduleName = sourceClass.getModule().getName(); + Optional moduleVersion = sourceClass.getModule().getDescriptor().version(); + final String version = moduleVersion.map(ModuleDescriptor.Version::toString).orElse(null); + final String className = sourceClass.getName(); + final String sourceFileName = DynamicHub.fromClass(sourceClass).getSourceFileName(); + return new StackTraceElement(classLoaderName, moduleName, version, className, sourceMethodName, sourceFileName, sourceLineNumber); + } +} diff --git a/substratevm/src/com.oracle.svm.core/src/com/oracle/svm/core/code/FrameInfoQueryResult.java b/substratevm/src/com.oracle.svm.core/src/com/oracle/svm/core/code/FrameInfoQueryResult.java index 9d9a0a1fd920..b5f82b1f4268 100644 --- a/substratevm/src/com.oracle.svm.core/src/com/oracle/svm/core/code/FrameInfoQueryResult.java +++ b/substratevm/src/com.oracle.svm.core/src/com/oracle/svm/core/code/FrameInfoQueryResult.java @@ -328,13 +328,7 @@ public int getSourceLineNumber() { * Returns the name and source code location of the method, for debugging purposes only. */ 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); + return SourceReferenceSupplier.createReference(sourceClass, sourceMethodName, sourceLineNumber); } public boolean isNativeMethod() { diff --git a/substratevm/src/com.oracle.svm.core/src/com/oracle/svm/core/code/SourceReferenceSupplier.java b/substratevm/src/com.oracle.svm.core/src/com/oracle/svm/core/code/SourceReferenceSupplier.java new file mode 100644 index 000000000000..1fc9cd551b67 --- /dev/null +++ b/substratevm/src/com.oracle.svm.core/src/com/oracle/svm/core/code/SourceReferenceSupplier.java @@ -0,0 +1,40 @@ +/* + * Copyright (c) 2021, 2021, Oracle and/or its affiliates. All rights reserved. + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * This code is free software; you can redistribute it and/or modify it + * under the terms of the GNU General Public License version 2 only, as + * published by the Free Software Foundation. Oracle designates this + * particular file as subject to the "Classpath" exception as provided + * by Oracle in the LICENSE file that accompanied this code. + * + * This code is distributed in the hope that it will be useful, but WITHOUT + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License + * version 2 for more details (a copy is included in the LICENSE file that + * accompanied this code). + * + * You should have received a copy of the GNU General Public License version + * 2 along with this work; if not, write to the Free Software Foundation, + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. + * + * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA + * or visit www.oracle.com if you need additional information or have any + * questions. + */ +package com.oracle.svm.core.code; + +import com.oracle.svm.core.hub.DynamicHub; + +final class SourceReferenceSupplier { + + public static StackTraceElement createReference(Class sourceClass, String sourceMethodName, int sourceLineNumber) { + /* + * 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); + } +}