Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
25 commits
Select commit Hold shift + click to select a range
88823aa
feat: Use Java 25 in Besu docker image
usmansaleem Oct 27, 2025
9c45613
chore: Comment
usmansaleem Oct 27, 2025
13e6ba4
Fix docker test scripts.
usmansaleem Oct 28, 2025
ece66fa
Merge remote-tracking branch 'upstream/main' into jdk25_multistage_do…
usmansaleem Oct 28, 2025
85adc5a
spotless fix
usmansaleem Oct 28, 2025
3c0b1ac
cleanup goss tests - remove static file test as it is not supported a…
usmansaleem Oct 28, 2025
d081a82
spotless fix
usmansaleem Oct 28, 2025
7aa05f0
externalize jvm opts
usmansaleem Oct 28, 2025
09ec6b5
unixStartupScript with placeholder
usmansaleem Oct 28, 2025
c25e8d2
tweakStartScript to replace jvm 25 opts placeholder
usmansaleem Oct 28, 2025
9f98f4f
tweakStartScript to replace jvm 25 opts placeholder for windows
usmansaleem Oct 28, 2025
dd4d9de
fix serialize of java 25 opts
usmansaleem Oct 28, 2025
fd8a473
exclude quotes from windows batch script java25 opts
usmansaleem Oct 28, 2025
7a75ba7
Merge remote-tracking branch 'upstream/main' into jdk25_multistage_do…
usmansaleem Oct 28, 2025
0869c7a
spotless fix
usmansaleem Oct 28, 2025
b3d162d
Merge remote-tracking branch 'upstream/main' into jdk25_multistage_do…
usmansaleem Oct 29, 2025
24fc95e
revert gitignore
usmansaleem Oct 29, 2025
48a448b
revert gitignore
usmansaleem Oct 29, 2025
3ff68bf
Merge upstream changes
usmansaleem Nov 14, 2025
d0eadd2
Revert "Merge upstream changes"
usmansaleem Nov 14, 2025
62855d0
Merge remote-tracking branch 'upstream/main' into jdk25_multistage_do…
usmansaleem Nov 14, 2025
fdfab23
Merge remote-tracking branch 'upstream/main' into jdk25_multistage_do…
usmansaleem Nov 17, 2025
e7b56c6
Update JVM options
usmansaleem Nov 17, 2025
546bef2
Fix Java detection in windows start script template
usmansaleem Nov 17, 2025
4029f15
Merge branch 'main' into jdk25_multistage_docker
usmansaleem Nov 17, 2025
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
20 changes: 17 additions & 3 deletions app/src/main/scripts/unixStartScript.txt
Original file line number Diff line number Diff line change
Expand Up @@ -43,9 +43,6 @@ cd "\$SAVED" >/dev/null
APP_NAME="${applicationName}"
APP_BASE_NAME=`basename "\$0"`

# Add default JVM options here. You can also use JAVA_OPTS and ${optsEnvironmentVar} to pass JVM options to this script.
DEFAULT_JVM_OPTS=${defaultJvmOpts}

# Use the maximum available, or set MAX_FD != -1 to use that value.
MAX_FD="maximum"

Expand Down Expand Up @@ -105,6 +102,23 @@ Please set the JAVA_HOME variable in your environment to match the
location of your Java installation."
fi

# Detect Java version
JAVA_VERSION=\$("\$JAVACMD" -version 2>&1 | awk -F '"' '/version/ {print \$2}' | sed 's/^1\\.//' | cut -d'.' -f1)

# Validate it's a number
if ! [ "\$JAVA_VERSION" -eq "\$JAVA_VERSION" ] 2>/dev/null; then
die "Unable to determine Java version"
fi

# Add default JVM options here. You can also use JAVA_OPTS and ${optsEnvironmentVar} to pass JVM options to this script.
if [ "\$JAVA_VERSION" -ge 25 ]; then
DEFAULT_JVM_OPTS=@DEFAULT_JVM_OPTS_25@
Copy link

Copilot AI Oct 28, 2025

Choose a reason for hiding this comment

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

The placeholder @DEFAULT_JVM_OPTS_25@ uses a different format than ${defaultJvmOpts}. This inconsistency in placeholder syntax could indicate a template processing issue or incomplete implementation. Verify that both placeholders are correctly replaced during the build process.

Suggested change
DEFAULT_JVM_OPTS=@DEFAULT_JVM_OPTS_25@
DEFAULT_JVM_OPTS=${defaultJvmOpts25}

Copilot uses AI. Check for mistakes.
elif [ "\$JAVA_VERSION" -ge 21 ]; then
DEFAULT_JVM_OPTS=${defaultJvmOpts}
else
die "Java version must be at least 21 (detected: \$JAVA_VERSION)"
fi

# Increase the maximum file descriptors if we can.
if [ "\$cygwin" = "false" -a "\$darwin" = "false" -a "\$nonstop" = "false" ] ; then
MAX_FD_LIMIT=`ulimit -H -n`
Expand Down
50 changes: 43 additions & 7 deletions app/src/main/scripts/windowsStartScript.txt
Original file line number Diff line number Diff line change
Expand Up @@ -33,15 +33,12 @@ set APP_HOME=%DIRNAME%${appHomeRelativePath}
@rem Resolve any "." and ".." in APP_HOME to make it shorter.
for %%i in ("%APP_HOME%") do set APP_HOME=%%~fi

@rem Add default JVM options here. You can also use JAVA_OPTS and ${optsEnvironmentVar} to pass JVM options to this script.
set DEFAULT_JVM_OPTS=${defaultJvmOpts}

@rem Find java.exe
if defined JAVA_HOME goto findJavaFromJavaHome

set JAVA_EXE=java.exe
%JAVA_EXE% -version >NUL 2>&1
if "%ERRORLEVEL%" == "0" goto execute
if "%ERRORLEVEL%" == "0" goto detectJavaVersion

echo.
echo ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH.
Expand All @@ -53,9 +50,9 @@ goto fail

:findJavaFromJavaHome
set JAVA_HOME=%JAVA_HOME:"=%
set JAVA_EXE=%JAVA_HOME%/bin/java.exe
set JAVA_EXE=%JAVA_HOME%\\bin\\java.exe

if exist "%JAVA_EXE%" goto execute
if exist "%JAVA_EXE%" goto detectJavaVersion

echo.
echo ERROR: JAVA_HOME is set to an invalid directory: %JAVA_HOME%
Expand All @@ -65,9 +62,48 @@ echo location of your Java installation.

goto fail

:detectJavaVersion
@rem Detect Java version - parse first line of java -version output
for /f "tokens=3" %%g in ('"%JAVA_EXE%" -version 2^>^&1') do (
set JAVA_VERSION_STRING=%%g
goto extractVersion
)

:extractVersion
@rem Remove quotes
set JAVA_VERSION_STRING=%JAVA_VERSION_STRING:"=%

@rem Extract major version (handle both 1.8 and 11+ format)
for /f "delims=. tokens=1-2" %%v in ("%JAVA_VERSION_STRING%") do (
if "%%v"=="1" (
set JAVA_VERSION=%%w
) else (
set JAVA_VERSION=%%v
)
)

@rem Validate Java version
if not defined JAVA_VERSION (
echo Unable to determine Java version
goto fail
)

@rem Add default JVM options here. You can also use JAVA_OPTS and ${optsEnvironmentVar} to pass JVM options to this script.
if %JAVA_VERSION% GEQ 25 goto setJvmOpts25
if %JAVA_VERSION% GEQ 21 goto setJvmOpts21
echo Java version must be at least 21 (detected: %JAVA_VERSION%)
goto fail

:setJvmOpts25
set DEFAULT_JVM_OPTS=@DEFAULT_JVM_OPTS_25@
goto execute

:setJvmOpts21
set DEFAULT_JVM_OPTS=${defaultJvmOpts}
goto execute

:execute
@rem Setup the command line

set CLASSPATH=$classpath
<% if ( mainClassName.startsWith('--module ') ) { %>set MODULE_PATH=$modulePath<% } %>

Expand Down
53 changes: 38 additions & 15 deletions build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -718,11 +718,42 @@ run {
}
}

def tweakStartScript(createScriptTask) {
def defaultJvmOpts21 = application.applicationDefaultJvmArgs + [
"-XX:MaxHeapFreeRatio=30",
"-XX:MinHeapFreeRatio=10",
"-XX:MaxGCPauseMillis=100",
"-XX:StartFlightRecording,settings=default.jfc",
"-Xlog:jfr*=off"
]

def defaultJvmOpts25 = defaultJvmOpts21 + [
"-XX:+UseCompactObjectHeaders"
]

def untunedJvmOpts = application.applicationDefaultJvmArgs

def evmToolJvmOpts = [
"-Dsecp256k1.randomize=false"
]

def serializeDefaultJvmOpts(opts) {
return "'" + opts.collect{ '"' + it.replaceAll(/"/, '\\"').replaceAll(/\$/, '\\$') + '"' }.join(' ') + "'"
}

def tweakStartScript(createScriptTask, jvmOptsForJava25) {
def shortenWindowsClasspath = { line ->
line.replaceAll(/^set CLASSPATH=.*$/, "set CLASSPATH=%APP_HOME%/lib/*")
}

// Replace Java 25 opts placeholder - must be before BESU_HOME replacement
createScriptTask.unixScript.text = createScriptTask.unixScript.text
.replace('@DEFAULT_JVM_OPTS_25@', jvmOptsForJava25)

// For Windows, remove the outer single quotes
def windowsJvmOpts = jvmOptsForJava25.replaceAll(/^'|'$/, '')
createScriptTask.windowsScript.text = createScriptTask.windowsScript.text
.replace('@DEFAULT_JVM_OPTS_25@', windowsJvmOpts)

createScriptTask.unixScript.text = createScriptTask.unixScript.text.replace('BESU_HOME', '\$APP_HOME')
createScriptTask.windowsScript.text = createScriptTask.windowsScript.text.replace('BESU_HOME', '%~dp0..')

Expand All @@ -735,40 +766,32 @@ def tweakStartScript(createScriptTask) {
}

startScripts {
defaultJvmOpts = application.applicationDefaultJvmArgs + [
"-XX:G1ConcRefinementThreads=2",
"-XX:G1HeapWastePercent=15",
"-XX:MaxGCPauseMillis=100",
"-XX:StartFlightRecording,settings=default.jfc",
"-Xlog:jfr*=off"
]
defaultJvmOpts = defaultJvmOpts21
unixStartScriptGenerator.template = resources.text.fromFile("${projectDir}/app/src/main/scripts/unixStartScript.txt")
windowsStartScriptGenerator.template = resources.text.fromFile("${projectDir}/app/src/main/scripts/windowsStartScript.txt")
doLast { tweakStartScript(startScripts) }
doLast { tweakStartScript(startScripts, serializeDefaultJvmOpts(defaultJvmOpts25)) }
}

task untunedStartScripts(type: CreateStartScripts) {
mainClass = 'org.hyperledger.besu.Besu'
classpath = startScripts.classpath
outputDir = startScripts.outputDir
applicationName = 'besu-untuned'
defaultJvmOpts = application.applicationDefaultJvmArgs
defaultJvmOpts = untunedJvmOpts
unixStartScriptGenerator.template = resources.text.fromFile("${projectDir}/app/src/main/scripts/unixStartScript.txt")
windowsStartScriptGenerator.template = resources.text.fromFile("${projectDir}/app/src/main/scripts/windowsStartScript.txt")
doLast { tweakStartScript(untunedStartScripts) }
doLast { tweakStartScript(untunedStartScripts, serializeDefaultJvmOpts(untunedJvmOpts)) }
}

task evmToolStartScripts(type: CreateStartScripts) {
mainClass = 'org.hyperledger.besu.evmtool.EvmTool'
classpath = startScripts.classpath
outputDir = startScripts.outputDir
applicationName = 'evmtool'
defaultJvmOpts = [
"-Dsecp256k1.randomize=false"
]
defaultJvmOpts = evmToolJvmOpts
unixStartScriptGenerator.template = resources.text.fromFile("${projectDir}/app/src/main/scripts/unixStartScript.txt")
windowsStartScriptGenerator.template = resources.text.fromFile("${projectDir}/app/src/main/scripts/windowsStartScript.txt")
doLast { tweakStartScript(evmToolStartScripts) }
doLast { tweakStartScript(evmToolStartScripts, serializeDefaultJvmOpts(evmToolJvmOpts)) }
}

task autocomplete(type: JavaExec) {
Expand Down
3 changes: 1 addition & 2 deletions docker/Dockerfile
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
# syntax=docker/dockerfile:1

# Stage: Use Eclipse Temurin JRE
FROM eclipse-temurin:21-jre AS java-base
FROM eclipse-temurin:25-jre AS java-base

# Stage: Final Besu image
FROM ubuntu:24.04
Expand Down Expand Up @@ -30,7 +30,6 @@ ARG BESU_USER=besu
USER ${BESU_USER}
WORKDIR /opt/besu


COPY --chown=besu:besu besu /opt/besu/
# support for pyroscope
ADD --chown=besu:besu https://github.com/grafana/pyroscope-java/releases/download/v2.1.2/pyroscope.jar /opt/besu/pyroscope/pyroscope.jar
Expand Down
2 changes: 1 addition & 1 deletion ethereum/evmtool/src/main/docker/Dockerfile
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
# syntax=docker/dockerfile:1

# Stage: Use Eclipse Temurin JRE
FROM eclipse-temurin:21-jre AS java-base
FROM eclipse-temurin:25-jre AS java-base

# Stage: Final Besu EVMTool image
FROM ubuntu:24.04
Expand Down