Skip to content
Closed
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
1 change: 1 addition & 0 deletions substratevm/mx.substratevm/suite.py
Original file line number Diff line number Diff line change
Expand Up @@ -229,6 +229,7 @@
"java.compiler",
],
"requiresConcealed" : {
"jdk.internal.vm.ci": ["jdk.vm.ci.meta"],
"java.base" : [
"jdk.internal.module",
"jdk.internal.reflect",
Expand Down
Original file line number Diff line number Diff line change
@@ -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<ModuleDescriptor.Version> 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);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -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() {
Expand Down
Original file line number Diff line number Diff line change
@@ -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);
}
}