From 2f9cb1a32393b6bb2607133836d16c1da73ec497 Mon Sep 17 00:00:00 2001
Date: Tue, 3 Sep 2019 09:52:13 +0000
Subject: [PATCH] Add with-company-name option

Summary: <openjdk_dev>: <Add with-company-name option to support customize the output of java -version>
LLT:
Bug url: AdoptOpenJDK
---
 common/autoconf/generated-configure.sh             | 22 ++++++++++++++--------
 common/autoconf/jdk-options.m4                     | 12 ++++++++++++
 jdk/make/gensrc/GensrcMisc.gmk                     |  6 ++++++
 .../share/classes/sun/misc/Version.java.template   |  9 ++++++---
 4 files changed, 38 insertions(+), 11 deletions(-)

diff --git a/common/autoconf/generated-configure.sh b/common/autoconf/generated-configure.sh
index 19efd8be38..32dc7779d5 100644
--- a/common/autoconf/generated-configure.sh
+++ b/common/autoconf/generated-configure.sh
@@ -1062,6 +1062,7 @@ with_milestone
 with_update_version
 with_user_release_suffix
 with_build_number
+with_company_name
 with_vendor_name
 with_vendor_url
 with_vendor_bug_url
@@ -1910,6 +1911,7 @@ Optional Packages:
                           Add a custom string to the version string if build
                           number isn't set.[username_builddateb00]
   --with-build-number     Set build number value for build [b00]
+  --with-company-name     Set company name.
   --with-vendor-name      Set vendor name. Among others, used to set the
                           'java.vendor' and 'java.vm.vendor' system
                           properties. [not specified]
@@ -19886,16 +19888,20 @@ fi
   # Now set the JDK version, milestone, build number etc.
 
 
+ # The company name, if any
 
+# Check whether --with-company-name was given.
+if test "${with_company_name+set}" = set; then :
+  withval=$with_company_name;
+fi
 
-
-
-
-
-
-
-
-
+  if test "x$with_company_name" = xyes; then
+    as_fn_error $? "--with-company-name must have a value" "$LINENO" 5
+  elif  ! [[ $with_company_name =~ ^[[:print:]]*$ ]] ; then
+    as_fn_error $? "--with-company-name contains non-printing characters: $with_company_name" "$LINENO" 5
+  elif test "x$with_company_name" != x; then
+    COMPANY_NAME="$with_company_name"
+  fi
 
 
   # The vendor name, if any
diff --git a/common/autoconf/jdk-options.m4 b/common/autoconf/jdk-options.m4
index 9d75dc7bd4..e7657a14fe 100644
--- a/common/autoconf/jdk-options.m4
+++ b/common/autoconf/jdk-options.m4
@@ -509,6 +509,18 @@ AC_DEFUN_ONCE([JDKOPT_SETUP_JDK_VERSION_NUMBERS],
   AC_SUBST(MACOSX_BUNDLE_NAME_BASE)
   AC_SUBST(MACOSX_BUNDLE_ID_BASE)
 
+  # The company name, if any
+  AC_ARG_WITH(company-name, [AS_HELP_STRING([--with-company-name],
+      [Set company name.])])
+  if test "x$with_company_name" = xyes; then
+    AC_MSG_ERROR([--with-company-name must have a value])
+  elif [ ! [[ $with_company_name =~ ^[[:print:]]*$ ]] ]; then
+    AC_MSG_ERROR([--with-company-name contains non-printing characters: $with_company_name])
+  elif test "x$with_company_name" != x; then
+    COMPANY_NAME="$with_company_name"
+  fi
+  AC_SUBST(COMPANY_NAME)
+
   # The vendor name, if any
   AC_ARG_WITH(vendor-name, [AS_HELP_STRING([--with-vendor-name],
       [Set vendor name. Among others, used to set the 'java.vendor'
diff --git a/jdk/make/gensrc/GensrcMisc.gmk b/jdk/make/gensrc/GensrcMisc.gmk
index df886e88f4..c0c7b7bdb3 100644
--- a/jdk/make/gensrc/GensrcMisc.gmk
+++ b/jdk/make/gensrc/GensrcMisc.gmk
@@ -30,6 +30,11 @@ include ProfileNames.gmk
 # string and the runtime name into the Version.java file.
 # To be printed by java -version
 
+company_name =
+ifneq ($(COMPANY_NAME),N/A)
+  company_name=($(COMPANY_NAME))
+endif
+
 $(JDK_OUTPUTDIR)/gensrc/sun/misc/Version.java \
 $(PROFILE_VERSION_JAVA_TARGETS): \
     $(JDK_TOPDIR)/src/share/classes/sun/misc/Version.java.template
@@ -41,6 +46,7 @@ $(PROFILE_VERSION_JAVA_TARGETS): \
 	    -e 's/@@java_runtime_version@@/$(FULL_VERSION)/g' \
 	    -e 's/@@java_runtime_name@@/$(RUNTIME_NAME)/g' \
 	    -e 's/@@java_profile_name@@/$(call profile_version_name, $@)/g' \
+            -e 's/@@company_name@@/$(company_name)/g' \
 	    $< > $@.tmp
 	$(MV) $@.tmp $@
 
diff --git a/jdk/src/share/classes/sun/misc/Version.java.template b/jdk/src/share/classes/sun/misc/Version.java.template
index 32e2586e79..022c142810 100644
--- a/jdk/src/share/classes/sun/misc/Version.java.template
+++ b/jdk/src/share/classes/sun/misc/Version.java.template
@@ -44,6 +44,9 @@ public class Version {
     private static final String java_runtime_version =
         "@@java_runtime_version@@";
 
+    private static final String company_name =
+        "@@company_name@@";
+
     static {
         init();
     }
@@ -103,7 +106,7 @@ public class Version {
 
         /* Second line: runtime version (ie, libraries). */
 
-        ps.print(java_runtime_name + " (build " + java_runtime_version);
+        ps.print(java_runtime_name + " " + company_name + "(build " + java_runtime_version);
 
         if (java_profile_name.length() > 0) {
             // profile name
@@ -120,8 +123,8 @@ public class Version {
         String java_vm_name    = System.getProperty("java.vm.name");
         String java_vm_version = System.getProperty("java.vm.version");
         String java_vm_info    = System.getProperty("java.vm.info");
-        ps.println(java_vm_name + " (build " + java_vm_version + ", " +
-                   java_vm_info + ")");
+        ps.println(java_vm_name + " " + company_name + "(build " + java_vm_version + ", " +
+                    java_vm_info + ")");
     }
 
 
-- 
2.12.3

