From 5ac7cbd1b35d8f6e01104c1d62c02f333f156ef8 Mon Sep 17 00:00:00 2001
From: valentino-aguiar-gsa
 <138504252+valentino-aguiar-gsa@users.noreply.github.com>
Date: Fri, 12 Jan 2024 12:31:59 +0000
Subject: [PATCH] Bugfix java 17 support per atlassian upstream

See https://jira.atlassian.com/browse/JRASERVER-76224 for details on this. This snippet was taken directly from the setenv.sh script from JIRA 9.11.1.
---
 templates/setenv.sh.epp | 8 ++++++++
 1 file changed, 8 insertions(+)

diff --git a/templates/setenv.sh.epp b/templates/setenv.sh.epp
index 271be6c2..c212c01a 100755
--- a/templates/setenv.sh.epp
+++ b/templates/setenv.sh.epp
@@ -89,6 +89,14 @@ fi
 
 JAVA_OPTS="-Xms${JVM_MINIMUM_MEMORY} -Xmx${JVM_MAXIMUM_MEMORY} ${JVM_CODE_CACHE_ARGS} ${JAVA_OPTS} ${JVM_REQUIRED_ARGS} ${DISABLE_NOTIFICATIONS} ${JVM_SUPPORT_RECOMMENDED_ARGS} ${JVM_EXTRA_ARGS} ${JIRA_HOME_MINUSD} ${START_JIRA_JAVA_OPTS}"
 
+j_ver=`echo "$($JAVA_HOME/bin/java -version 2>&1)" | grep "version" | awk '{ print substr($3, 2, length($3)-2); }'`
+IFS='.' read -a j_ver_parts <<< "$j_ver"
+
+if [[ ${j_ver_parts[0]} = 17 ]]; then
+  JVM_OPENS=$(cat $PRGDIR/java-opens.txt)
+  JAVA_OPTS="$JVM_OPENS $JAVA_OPTS"
+fi
+
 export JAVA_OPTS
 
 # DO NOT remove the following line