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
@@ -0,0 +1,49 @@
/*
* Copyright (c) 2020, 2020, 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;

import org.graalvm.nativeimage.ImageInfo;
import org.graalvm.nativeimage.hosted.Feature;

import com.oracle.svm.core.annotate.Alias;
import com.oracle.svm.core.annotate.AutomaticFeature;
import com.oracle.svm.core.annotate.TargetClass;
import com.oracle.svm.core.jdk.RuntimeSupport;

@AutomaticFeature
public class SubstrateExitHandlerFeature implements Feature {
@Override
public void beforeAnalysis(BeforeAnalysisAccess access) {
if (SubstrateOptions.InstallExitHandlers.getValue() && ImageInfo.isExecutable()) {
RuntimeSupport.getRuntimeSupport().addStartupHook(Target_java_lang_Terminator::setup);
}
}
}

@TargetClass(className = "java.lang.Terminator")
final class Target_java_lang_Terminator {
@Alias
static native void setup();
}
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@
*/
package com.oracle.svm.core;

import static org.graalvm.compiler.core.common.GraalOptions.TrackNodeSourcePosition;
import static org.graalvm.compiler.core.common.SpeculativeExecutionAttacksMitigations.None;
import static org.graalvm.compiler.core.common.SpeculativeExecutionAttacksMitigations.Options.MitigateSpeculativeExecutionAttacks;
import static org.graalvm.compiler.options.OptionType.User;
Expand Down Expand Up @@ -52,8 +53,6 @@
import com.oracle.svm.core.option.RuntimeOptionKey;
import com.oracle.svm.core.option.XOptions;

import static org.graalvm.compiler.core.common.GraalOptions.TrackNodeSourcePosition;

public class SubstrateOptions {

@Option(help = "Class containing the default entry point method. Optional if --shared is used.", type = OptionType.User)//
Expand Down Expand Up @@ -425,6 +424,10 @@ public static Predicate<String> makeFilter(String[] definedFilters) {
@Option(help = "Show native-toolchain information and image-build settings", type = User)//
public static final HostedOptionKey<Boolean> DumpTargetInfo = new HostedOptionKey<>(false);

@APIOption(name = "install-exit-handlers")//
@Option(help = "Provide java.lang.Terminator exit handlers for executable images", type = User)//
public static final HostedOptionKey<Boolean> InstallExitHandlers = new HostedOptionKey<>(false);

@Option(help = "file:doc-files/UseMuslCHelp.txt", type = OptionType.Expert)//
public static final HostedOptionKey<String> UseMuslC = new HostedOptionKey<>(null);

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,7 @@ public void registerGraphBuilderPlugins(Providers providers, Plugins plugins, bo
public void duringSetup(DuringSetupAccess a) {
ImageSingletons.add(JNIRegistrationSupport.class, new JNIRegistrationSupport());

rerunClassInit(a, "java.io.RandomAccessFile", "java.lang.ProcessEnvironment", "java.io.File$TempDirectory");
rerunClassInit(a, "java.io.RandomAccessFile", "java.lang.ProcessEnvironment", "java.io.File$TempDirectory", "java.lang.Terminator");
if (JavaVersionUtil.JAVA_SPEC <= 8) {
if (isPosix()) {
rerunClassInit(a, "java.lang.UNIXProcess");
Expand Down