10f36c0
diff --git openjdk.orig/jdk/make/CompileLaunchers.gmk openjdk/jdk/make/CompileLaunchers.gmk
10f36c0
--- openjdk.orig/jdk/make/CompileLaunchers.gmk
10f36c0
+++ openjdk/jdk/make/CompileLaunchers.gmk
10f36c0
@@ -255,6 +255,33 @@
10f36c0
   endif
10f36c0
 endif
48e4f20
 
10f36c0
+# -Wno-error=cpp is present to allow commented warning in ifdef part of main.c
48e4f20
+$(eval $(call SetupLauncher,alt-java, \
00f1f31
+    -DEXPAND_CLASSPATH_WILDCARDS -DREDHAT_ALT_JAVA -Wno-error=cpp,,,user32.lib comctl32.lib, \
48e4f20
+    $(JDK_OUTPUTDIR)/objs/jli_static.lib, $(JAVA_RC_FLAGS), \
48e4f20
+    $(JDK_TOPDIR)/src/windows/resource/java.rc, $(JDK_OUTPUTDIR)/objs/java_objs,true))
48e4f20
+
48e4f20
+$(JDK_OUTPUTDIR)/bin$(OUTPUT_SUBDIR)/alt-java$(EXE_SUFFIX): $(BUILD_LAUNCHER_alt-java)
48e4f20
+	$(MKDIR) -p $(@D)
48e4f20
+	$(RM) $@
48e4f20
+	$(CP) $(JDK_OUTPUTDIR)/objs/java_objs$(OUTPUT_SUBDIR)/alt-java$(EXE_SUFFIX) $@
48e4f20
+
10f36c0
+$(JDK_OUTPUTDIR)/bin$(OUTPUT_SUBDIR)/alt-java$(DEBUGINFO_EXT): $(BUILD_LAUNCHER_alt-java)
10f36c0
+	$(MKDIR) -p $(@D)
10f36c0
+	$(RM) $@
10f36c0
+	$(CP) $(JDK_OUTPUTDIR)/objs/java_objs$(OUTPUT_SUBDIR)/alt-java$(DEBUGINFO_EXT) $@
10f36c0
+
48e4f20
+ifeq ($(OPENJDK_TARGET_OS), linux)
48e4f20
+  BUILD_LAUNCHERS += $(JDK_OUTPUTDIR)/bin$(OUTPUT_SUBDIR)/alt-java$(EXE_SUFFIX)
10f36c0
+  ifeq ($(ENABLE_DEBUG_SYMBOLS), true)
10f36c0
+    ifneq ($(POST_STRIP_CMD), )
10f36c0
+      ifneq ($(STRIP_POLICY), no_strip)
10f36c0
+        BUILD_LAUNCHERS += $(JDK_OUTPUTDIR)/bin$(OUTPUT_SUBDIR)/alt-java$(DEBUGINFO_EXT)
10f36c0
+      endif
10f36c0
+    endif
10f36c0
+  endif
48e4f20
+endif
48e4f20
+
48e4f20
 ifeq ($(OPENJDK_TARGET_OS), windows)
48e4f20
   $(eval $(call SetupLauncher,javaw, \
48e4f20
       -DJAVAW -DEXPAND_CLASSPATH_WILDCARDS,,,user32.lib comctl32.lib, \
10f36c0
diff --git openjdk.orig/jdk/src/share/bin/alt_main.h openjdk/jdk/src/share/bin/alt_main.h
10f36c0
new file mode 100644
10f36c0
--- /dev/null
10f36c0
+++ openjdk/jdk/src/share/bin/alt_main.h
48e4f20
@@ -0,0 +1,73 @@
48e4f20
+/*
48e4f20
+ * Copyright (c) 2019, Red Hat, Inc. All rights reserved.
48e4f20
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
48e4f20
+ *
48e4f20
+ * This code is free software; you can redistribute it and/or modify it
48e4f20
+ * under the terms of the GNU General Public License version 2 only, as
48e4f20
+ * published by the Free Software Foundation.  Oracle designates this
48e4f20
+ * particular file as subject to the "Classpath" exception as provided
48e4f20
+ * by Oracle in the LICENSE file that accompanied this code.
48e4f20
+ *
48e4f20
+ * This code is distributed in the hope that it will be useful, but WITHOUT
48e4f20
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
48e4f20
+ * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
48e4f20
+ * version 2 for more details (a copy is included in the LICENSE file that
48e4f20
+ * accompanied this code).
48e4f20
+ *
48e4f20
+ * You should have received a copy of the GNU General Public License version
48e4f20
+ * 2 along with this work; if not, write to the Free Software Foundation,
48e4f20
+ * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
48e4f20
+ *
48e4f20
+ * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
48e4f20
+ * or visit www.oracle.com if you need additional information or have any
48e4f20
+ * questions.
48e4f20
+ */
48e4f20
+
48e4f20
+#ifdef REDHAT_ALT_JAVA
48e4f20
+
48e4f20
+#include <sys/prctl.h>
48e4f20
+
48e4f20
+
48e4f20
+/* Per task speculation control */
48e4f20
+#ifndef PR_GET_SPECULATION_CTRL
48e4f20
+# define PR_GET_SPECULATION_CTRL    52
48e4f20
+#endif
48e4f20
+#ifndef PR_SET_SPECULATION_CTRL
48e4f20
+# define PR_SET_SPECULATION_CTRL    53
48e4f20
+#endif
48e4f20
+/* Speculation control variants */
48e4f20
+#ifndef PR_SPEC_STORE_BYPASS
48e4f20
+# define PR_SPEC_STORE_BYPASS          0
48e4f20
+#endif
48e4f20
+/* Return and control values for PR_SET/GET_SPECULATION_CTRL */
48e4f20
+
48e4f20
+#ifndef PR_SPEC_NOT_AFFECTED
48e4f20
+# define PR_SPEC_NOT_AFFECTED          0
48e4f20
+#endif
48e4f20
+#ifndef PR_SPEC_PRCTL
48e4f20
+# define PR_SPEC_PRCTL                 (1UL << 0)
48e4f20
+#endif
48e4f20
+#ifndef PR_SPEC_ENABLE
48e4f20
+# define PR_SPEC_ENABLE                (1UL << 1)
48e4f20
+#endif
48e4f20
+#ifndef PR_SPEC_DISABLE
48e4f20
+# define PR_SPEC_DISABLE               (1UL << 2)
48e4f20
+#endif
48e4f20
+#ifndef PR_SPEC_FORCE_DISABLE
48e4f20
+# define PR_SPEC_FORCE_DISABLE         (1UL << 3)
48e4f20
+#endif
48e4f20
+#ifndef PR_SPEC_DISABLE_NOEXEC
48e4f20
+# define PR_SPEC_DISABLE_NOEXEC        (1UL << 4)
48e4f20
+#endif
48e4f20
+
48e4f20
+static void set_speculation() __attribute__((constructor));
48e4f20
+static void set_speculation() {
48e4f20
+  if ( prctl(PR_SET_SPECULATION_CTRL,
48e4f20
+             PR_SPEC_STORE_BYPASS,
48e4f20
+             PR_SPEC_DISABLE_NOEXEC, 0, 0) == 0 ) {
48e4f20
+    return;
48e4f20
+  }
48e4f20
+  prctl(PR_SET_SPECULATION_CTRL, PR_SPEC_STORE_BYPASS, PR_SPEC_DISABLE, 0, 0);
48e4f20
+}
48e4f20
+
48e4f20
+#endif // REDHAT_ALT_JAVA
10f36c0
diff --git openjdk.orig/jdk/src/share/bin/main.c openjdk/jdk/src/share/bin/main.c
10f36c0
--- openjdk.orig/jdk/src/share/bin/main.c
10f36c0
+++ openjdk/jdk/src/share/bin/main.c
00f1f31
@@ -32,6 +32,14 @@
48e4f20
 
48e4f20
 #include "defines.h"
48e4f20
 
00f1f31
+#ifdef REDHAT_ALT_JAVA
0b99caa
+#if defined(__linux__) && defined(__x86_64__)
48e4f20
+#include "alt_main.h"
00f1f31
+#else
00f1f31
+#warning alt-java requested but SSB mitigation not available on this platform.
00f1f31
+#endif
48e4f20
+#endif
48e4f20
+
48e4f20
 #ifdef _MSC_VER
48e4f20
 #if _MSC_VER > 1400 && _MSC_VER < 1600
48e4f20