Skip to content

fix: upgrade required Java version in start scripts #2846

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 2 commits into
base: master
Choose a base branch
from

Conversation

hexuxu110
Copy link

fix the bug in JDK version comparison

fix the bug in JDK version comparison
@dosubot dosubot bot added size:XS This PR changes 0-9 lines, ignoring generated files. bug Something isn't working labels Jul 31, 2025
@VGalaxies VGalaxies requested a review from Copilot July 31, 2025 14:58
Copy link
Contributor

@Copilot Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copilot wasn't able to review any files in this pull request.

if [[ $? -eq 0 && $JAVA_VERSION > "1.9" ]]; then
DEFAULT_JAVA_OPTIONS="--add-exports=java.base/jdk.internal.reflect=ALL-UNNAMED"

# 提取主版本号进行数值比较
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

please translate them into English~

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

ok

Comment on lines 52 to 59
if [[ $JAVA_VERSION == 1.* ]]; then
MAJOR_VERSION=$(echo $JAVA_VERSION | cut -d'.' -f2)
else
MAJOR_VERSION=$(echo $JAVA_VERSION | cut -d'.' -f1)
fi

if [[ $? -eq 0 && $MAJOR_VERSION -ge 9 ]]; then
DEFAULT_JAVA_OPTIONS="--add-exports=java.base/jdk.internal.reflect=ALL-UNNAMED"
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

这里的逻辑需要更新了, 现在是必须要求 Java 版本 == 11, 而不只是 Java9 之后了

所以麻烦修改一下这里的逻辑, 如果不符合请直接清晰的告诉用户需要使用 Java xx (这个抽取为一个变量, 方便后续升级 Java17/21 的时候直接调整即可, 避免硬编码了)

另外同时也看看 pd/store 的启动脚本里是否有版本检查, 一并可以同步一下, THX

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

好的

@imbajin imbajin changed the title fix the bug in JDK version comparison fix: upgrade required Java version in start scripts Aug 1, 2025
fix the bug in JDK version comparison
Comment on lines 81 to 92
JAVA_VERSION=$($JAVA -version 2>&1 | awk 'NR==1{gsub(/"/,""); print $3}' | awk -F'_' '{print $1}')
if [[ $? -ne 0 || $JAVA_VERSION < $EXPECT_JDK_VERSION ]]; then

if [[ $JAVA_VERSION == 1.* ]]; then
MAJOR_VERSION=$(echo $JAVA_VERSION | cut -d'.' -f2)
else
MAJOR_VERSION=$(echo $JAVA_VERSION | cut -d'.' -f1)
fi


if [[ $? -ne 0 || $MAJOR_VERSION -lt $EXPECT_JDK_VERSION ]]; then
echo "Please make sure that the JDK is installed and the version >= $EXPECT_JDK_VERSION" >> ${OUTPUT}
exit 1
Copy link
Member

@imbajin imbajin Aug 5, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The logic need to refactor like

#!/bin/bash
# Expected JDK version
EXPECT_JDK_VERSION=11

# Extract and check Java version
JAVA_VERSION=$(java -version 2>&1 | head -n1 | sed -n 's/.*version "\([0-9]*\)\..*/\1/p')

if [[ "$JAVA_VERSION" != "$EXPECT_JDK_VERSION" ]]; then
    echo "Expected Java ${EXPECT_JDK_VERSION}, but found Java ${JAVA_VERSION}" >> ${OUTPUT}
fi

And test it
image

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working size:XS This PR changes 0-9 lines, ignoring generated files.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants