Skip to content

Commit

Permalink
Use simpler logic to compare the Java version numerically
Browse files Browse the repository at this point in the history
  • Loading branch information
merks committed Dec 6, 2024
1 parent cdeb962 commit bec1c33
Showing 1 changed file with 6 additions and 5 deletions.
11 changes: 6 additions & 5 deletions releng/org.eclipse.justj.releng/build-jre.sh
Original file line number Diff line number Diff line change
Expand Up @@ -268,11 +268,12 @@ $eclipse_executable --launcher.suppressErrors -application org.eclipse.ant.core.
# Determine the Java version from the system properties.
java_version=$(grep "^java.version=" all.properties | sed 's/^.*=//;s/\r//')
echo "Java Version '$java_version'"
java_major_version=${java_version%%.*}



# Not all vendors support --generate-cds-archive
# Also only Java version 22 or higher support it.
# Also only Java version 21 or higher support it.
generate_cds_archive=""

# Compute the name prefix depending on the vendor and VM.
Expand All @@ -286,7 +287,7 @@ if grep "^java.vendor.version=" all.properties | grep -q "Temurin"; then
vendor_label="Adoptium OpenJDK Hotspot"
vendor_prefix="openjdk.hotspot"

if [[ $java_version =~ ^[2-9][0-9]+(.[0-9]+(.[0-9]+)?)?$ ]]; then
if (($java_major_version >= 21)); then
generate_cds_archive="--generate-cds-archive"
fi
fi
Expand All @@ -295,9 +296,9 @@ else
vendor_label="OpenJDK Hotspot"
vendor_prefix="openjdk.hotspot"

if [[ $java_version =~ ^[2-9][0-9]+(.[0-9]+(.[0-9]+)?)?$ ]]; then
generate_cds_archive="--generate-cds-archive"
fi
if (($java_major_version >= 21)); then
generate_cds_archive="--generate-cds-archive"
fi

This comment has been minimized.

Copy link
@chirontt

chirontt Dec 6, 2024

Contributor

This else code block, starting at line 294, for JDKs other than Temurin's, should take care of the OpenJ9 JVM too, as evidently the OpenJ9 JVM doesn't support CDS-archive option at all. So this else code block should be:

else
  # Assume other JDKs are derived from OpenJDK
  vendor_url="https://jdk.java.net/"
  if grep "OpenJ9" all.properties; then
    vendor_label="OpenJDK J9"
    vendor_prefix="openjdk.j9"
  else
    vendor_label="OpenJDK Hotspot"
    vendor_prefix="openjdk.hotspot"

    if (($java_version >= 21)); then
      generate_cds_archive="--generate-cds-archive"
    fi
  fi
fi
fi

echo "Vendor prefix: $vendor_prefix-$java_version-$jre_suffix"
Expand Down

0 comments on commit bec1c33

Please sign in to comment.