Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
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
35 changes: 20 additions & 15 deletions bin/jmeter
Original file line number Diff line number Diff line change
Expand Up @@ -115,18 +115,19 @@ if [ -z "$JAVA_HOME" ]; then
JAVA_HOME="$JRE_HOME"
fi

#--add-opens if JAVA 9
JAVA9_OPTS=
# Module access for modern Java versions (required for JMeter components)
JAVA_OPTS="--add-opens java.desktop/sun.awt=ALL-UNNAMED --add-opens java.desktop/sun.swing=ALL-UNNAMED --add-opens java.desktop/javax.swing.text.html=ALL-UNNAMED --add-opens java.desktop/java.awt=ALL-UNNAMED --add-opens java.desktop/java.awt.font=ALL-UNNAMED --add-opens=java.base/java.lang=ALL-UNNAMED --add-opens=java.base/java.lang.invoke=ALL-UNNAMED --add-opens=java.base/java.lang.reflect=ALL-UNNAMED --add-opens=java.base/java.util=ALL-UNNAMED --add-opens=java.base/java.text=ALL-UNNAMED --add-opens=java.desktop/sun.awt.X11=ALL-UNNAMED --add-opens=java.desktop/sun.awt.shell=ALL-UNNAMED"

# Minimal version to run JMeter
MINIMAL_VERSION=8
MINIMAL_VERSION=17

# Check if version is from OpenJDK or Oracle Hotspot JVM prior to 9 containing 1.${version}.x
# Check if version meets the minimal requirement
CURRENT_VERSION=`"${JAVA_HOME}/bin/java" -version 2>&1 | awk -F'"' '/version/ {gsub("^1[.]", "", $2); gsub("[^0-9].*$", "", $2); print $2}'`

# Check if Java is present and the minimal version requirement
if [ "$CURRENT_VERSION" -gt "$MINIMAL_VERSION" ]; then
JAVA9_OPTS="--add-opens java.desktop/sun.awt=ALL-UNNAMED --add-opens java.desktop/sun.swing=ALL-UNNAMED --add-opens java.desktop/javax.swing.text.html=ALL-UNNAMED --add-opens java.desktop/java.awt=ALL-UNNAMED --add-opens java.desktop/java.awt.font=ALL-UNNAMED --add-opens=java.base/java.lang=ALL-UNNAMED --add-opens=java.base/java.lang.invoke=ALL-UNNAMED --add-opens=java.base/java.lang.reflect=ALL-UNNAMED --add-opens=java.base/java.util=ALL-UNNAMED --add-opens=java.base/java.text=ALL-UNNAMED --add-opens=java.desktop/sun.awt.X11=ALL-UNNAMED --add-opens=java.desktop/sun.awt.shell=ALL-UNNAMED"
# Check if Java is present and meets the minimal version requirement
if [ "$CURRENT_VERSION" -lt "$MINIMAL_VERSION" ]; then
echo "ERROR: Java version $CURRENT_VERSION is too low. JMeter requires Java $MINIMAL_VERSION or higher."
exit 1
fi

: "${JMETER_OPTS:=""}"
Expand Down Expand Up @@ -169,15 +170,19 @@ esac
# Default to en_EN
: "${JMETER_LANGUAGE:="-Duser.language=en -Duser.region=EN"}"

# Uncomment this to generate GC verbose file with Java prior to 9
# VERBOSE_GC="-verbose:gc -Xloggc:gc_jmeter_%p.log -XX:+PrintGCDetails -XX:+PrintGCCause -XX:+PrintTenuringDistribution -XX:+PrintHeapAtGC -XX:+PrintGCApplicationConcurrentTime -XX:+PrintAdaptiveSizePolicy -XX:+PrintGCApplicationStoppedTime -XX:+PrintGCDateStamps"
# Legacy GC verbose options removed (Java 8/9 support discontinued)

# Optimized GC logging for Java 17 with structured output and performance analysis
# Uncomment to enable comprehensive GC logging with rotation and detailed metrics
# VERBOSE_GC="-Xlog:gc,gc+heap,gc+regions,gc+refine,gc+phases:gc_jmeter_%p_%t.log:time,level,tags:filecount=5,filesize=50M"

# Alternative: Minimal GC logging for production (uncomment if needed)
# VERBOSE_GC="-Xlog:gc:gc_jmeter_%p.log:time"

# Uncomment this to generate GC verbose file with Java 9 and above
# VERBOSE_GC="-Xlog:gc*,gc+age=trace,gc+heap=debug:file=gc_jmeter_%p.log"
# Docker support for Java 17+
# Modern container memory detection is automatic in Java 17+
# RUN_IN_DOCKER="-XX:+UseContainerSupport"

# Uncomment this if you run JMeter in DOCKER (need Java SE 8u131 or JDK 9)
# see https://blogs.oracle.com/java-platform-group/java-se-support-for-docker-cpu-and-memory-limits
# RUN_IN_DOCKER="-XX:+UnlockExperimentalVMOptions -XX:+UseCGroupMemoryLimitForHeap"

# Finally, some tracing to help in case things go astray:
# You may want to add those settings:
Expand All @@ -191,7 +196,7 @@ SYSTEM_PROPS="-Djava.security.egd=file:/dev/urandom"
SERVER="-server"

if [ -z "${JMETER_COMPLETE_ARGS}" ]; then
ARGS="$JAVA9_OPTS $SERVER $DUMP $HEAP $VERBOSE_GC $GC_ALGO $SYSTEM_PROPS $JMETER_LANGUAGE $RUN_IN_DOCKER"
ARGS="$JAVA_OPTS $SERVER $DUMP $HEAP $VERBOSE_GC $GC_ALGO $SYSTEM_PROPS $JMETER_LANGUAGE $RUN_IN_DOCKER"
else
ARGS=""
fi
Expand Down
61 changes: 25 additions & 36 deletions bin/jmeter.bat
Original file line number Diff line number Diff line change
Expand Up @@ -78,12 +78,19 @@ if not defined JMETER_LANGUAGE (
)

rem Minimal version to run JMeter
set MINIMAL_VERSION=1.8.0
set MINIMAL_VERSION=17.0.0


rem --add-opens if JAVA 9
set JAVA9_OPTS=
rem Optimized GC logging for Java 17 with structured output and performance analysis
rem Uncomment to enable comprehensive GC logging with rotation and detailed metrics
rem set VERBOSE_GC=-Xlog:gc,gc+heap,gc+regions,gc+refine,gc+phases:gc_jmeter_%%p_%%t.log:time,level,tags:filecount=5,filesize=50M

rem Alternative: Minimal GC logging for production (uncomment if needed)
rem set VERBOSE_GC=-Xlog:gc:gc_jmeter_%%p.log:time


rem Module access for modern Java versions (required for JMeter components)
set JAVA_OPTS=--add-opens java.desktop/sun.awt=ALL-UNNAMED --add-opens java.desktop/sun.swing=ALL-UNNAMED --add-opens java.desktop/javax.swing.text.html=ALL-UNNAMED --add-opens java.desktop/java.awt=ALL-UNNAMED --add-opens java.desktop/java.awt.font=ALL-UNNAMED --add-opens=java.base/java.lang=ALL-UNNAMED --add-opens=java.base/java.lang.invoke=ALL-UNNAMED --add-opens=java.base/java.lang.reflect=ALL-UNNAMED --add-opens=java.base/java.util=ALL-UNNAMED --add-opens=java.base/java.text=ALL-UNNAMED --add-opens=java.desktop/sun.awt.shell=ALL-UNNAMED
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

I assume you just moved the code, however, it would be nice to reduce the list of those options one day

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Me too


for /f "tokens=3" %%g in ('java -version 2^>^&1 ^| findstr /i "version"') do (
rem @echo Debug Output: %%g
Expand All @@ -95,36 +102,24 @@ if not defined JAVAVER (
goto pause
)



rem Check if version is from OpenJDK or Oracle Hotspot JVM prior to 9 containing 1.${version}.x
rem JAVAVER will be equal to "9.0.4" (quotes are part of the value) for Oracle Java 9
rem JAVAVER will be equal to "1.8.0_161" (quotes are part of the value) for Oracle Java 8
rem so we extract 2 chars starting from index 1
IF "%JAVAVER:~1,2%"=="1." (
set JAVAVER=%JAVAVER:"=%
for /f "delims=. tokens=1-3" %%v in ("%JAVAVER%") do (
set current_minor=%%w
rem Extract major version number from Java version string
for /f "delims=. tokens=1" %%v in ("%JAVAVER:~1,-1%") do (
set current_major=%%v
)
) else (
rem Java 9 at least
set current_minor=9
set JAVA9_OPTS=--add-opens java.desktop/sun.awt=ALL-UNNAMED --add-opens java.desktop/sun.swing=ALL-UNNAMED --add-opens java.desktop/javax.swing.text.html=ALL-UNNAMED --add-opens java.desktop/java.awt=ALL-UNNAMED --add-opens java.desktop/java.awt.font=ALL-UNNAMED --add-opens=java.base/java.lang=ALL-UNNAMED --add-opens=java.base/java.lang.invoke=ALL-UNNAMED --add-opens=java.base/java.lang.reflect=ALL-UNNAMED --add-opens=java.base/java.util=ALL-UNNAMED --add-opens=java.base/java.text=ALL-UNNAMED --add-opens=java.desktop/sun.awt.shell=ALL-UNNAMED
)


for /f "delims=. tokens=1-3" %%v in ("%MINIMAL_VERSION%") do (
set minimal_minor=%%w
rem Extract minimal major version
for /f "delims=. tokens=1" %%v in ("%MINIMAL_VERSION%") do (
set minimal_major=%%v
)

if not defined current_minor (
if not defined current_major (
@echo Not able to find Java executable or version. Please check your Java installation.
set ERRORLEVEL=2
goto pause
)
rem @echo Debug: CURRENT=%current_minor% - MINIMAL=%minimal_minor%
if %current_minor% LSS %minimal_minor% (
@echo Error: Java version -- %JAVAVER% -- is too low to run JMeter. Needs a Java version greater than or equal to %MINIMAL_VERSION%

if %current_major% LSS %minimal_major% (
@echo Error: Java version -- %JAVAVER% -- is too low to run JMeter. Needs Java %MINIMAL_VERSION% or higher.
set ERRORLEVEL=3
goto pause
)
Expand All @@ -151,13 +146,7 @@ if not defined HEAP (
set HEAP=-Xms1g -Xmx1g -XX:MaxMetaspaceSize=256m
)

rem Uncomment this to generate GC verbose file with Java prior to 9
rem set VERBOSE_GC=-verbose:gc -Xloggc:gc_jmeter_%%p.log -XX:+PrintGCDetails -XX:+PrintGCCause -XX:+PrintTenuringDistribution -XX:+PrintHeapAtGC -XX:+PrintGCApplicationConcurrentTime -XX:+PrintGCApplicationStoppedTime -XX:+PrintGCDateStamps -XX:+PrintAdaptiveSizePolicy

rem Uncomment this to generate GC verbose file with Java 9 and above
rem set VERBOSE_GC=-Xlog:gc*,gc+age=trace,gc+heap=debug:file=gc_jmeter_%%p.log
rem You may want to add those settings
rem -XX:+ParallelRefProcEnabled -XX:+PerfDisableSharedMem
rem Legacy GC verbose options removed (Java 8/9 support discontinued)
if not defined GC_ALGO (
set GC_ALGO=-XX:+UseG1GC -XX:MaxGCPauseMillis=100 -XX:G1ReservePercent=20
)
Expand All @@ -167,9 +156,9 @@ set SYSTEM_PROPS=-Djava.security.egd=file:/dev/urandom
rem Always dump on OOM (does not cost anything unless triggered)
set DUMP=-XX:+HeapDumpOnOutOfMemoryError

rem Uncomment this if you run JMeter in DOCKER (need Java SE 8u131 or JDK 9)
rem see https://blogs.oracle.com/java-platform-group/java-se-support-for-docker-cpu-and-memory-limits
rem set RUN_IN_DOCKER=-XX:+UnlockExperimentalVMOptions -XX:+UseCGroupMemoryLimitForHeap
rem Docker support for Java 17+
rem Modern container memory detection is automatic in Java 17+
rem set RUN_IN_DOCKER=-XX:+UseContainerSupport

rem Additional settings that might help improve GUI performance on some platforms
rem See: http://www.oracle.com/technetwork/java/perf-graphics-135933.html
Expand All @@ -188,7 +177,7 @@ if not defined DDRAW (

rem Collect the settings defined above
if not defined JMETER_COMPLETE_ARGS (
set ARGS=%JAVA9_OPTS% %DUMP% %HEAP% %VERBOSE_GC% %GC_ALGO% %DDRAW% %SYSTEM_PROPS% %JMETER_LANGUAGE% %RUN_IN_DOCKER%
set ARGS=%JAVA_OPTS% %DUMP% %HEAP% %VERBOSE_GC% %GC_ALGO% %DDRAW% %SYSTEM_PROPS% %JMETER_LANGUAGE% %RUN_IN_DOCKER%
) else (
set ARGS=
)
Expand Down
7 changes: 5 additions & 2 deletions bin/jmeter.sh
Original file line number Diff line number Diff line change
Expand Up @@ -90,14 +90,17 @@ fi
JAVA9_OPTS=

# Minimal version to run JMeter
MINIMAL_VERSION=8
MINIMAL_VERSION=17

# Check if version is from OpenJDK or Oracle Hotspot JVM prior to 9 containing 1.${version}.x
CURRENT_VERSION=`"${JAVA_HOME}/bin/java" -version 2>&1 | awk -F'"' '/version/ {gsub("^1[.]", "", $2); gsub("[^0-9].*$", "", $2); print $2}'`

# Check if Java is present and the minimal version requirement
if [ "$CURRENT_VERSION" -gt "$MINIMAL_VERSION" ]; then
if [ "$CURRENT_VERSION" -ge "$MINIMAL_VERSION" ]; then
JAVA9_OPTS="--add-opens java.desktop/sun.awt=ALL-UNNAMED --add-opens java.desktop/sun.swing=ALL-UNNAMED --add-opens java.desktop/javax.swing.text.html=ALL-UNNAMED --add-opens java.desktop/java.awt=ALL-UNNAMED --add-opens java.desktop/java.awt.font=ALL-UNNAMED --add-opens=java.base/java.lang=ALL-UNNAMED --add-opens=java.base/java.lang.invoke=ALL-UNNAMED --add-opens=java.base/java.lang.reflect=ALL-UNNAMED --add-opens=java.base/java.util=ALL-UNNAMED --add-opens=java.base/java.text=ALL-UNNAMED --add-opens=java.desktop/sun.awt.X11=ALL-UNNAMED --add-opens=java.desktop/sun.awt.shell=ALL-UNNAMED"
else
echo "JMeter requires Java $MINIMAL_VERSION or later. Current Java version is $CURRENT_VERSION"
exit 1
fi

# Don't add additional arguments to the JVM start, except those needed for Java 9
Expand Down
10 changes: 3 additions & 7 deletions build-logic/jvm/src/main/kotlin/build-logic.java.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -121,18 +121,14 @@ tasks.configureEach<Javadoc> {
docTitle = "Apache JMeter ${project.name} API"
windowTitle = "Apache JMeter ${project.name} API"
header = "<b>Apache JMeter</b>"
addStringOption("source", "8")
addStringOption("source", "17")
addStringOption("Xmaxwarns", "10")
addBooleanOption("Xdoclint:all,-missing", true)
val lastEditYear: String by rootProject.extra
bottom =
"Copyright &copy; 1998-$lastEditYear Apache Software Foundation. All Rights Reserved."
if (buildParameters.buildJdkVersion > 8) {
addBooleanOption("html5", true)
links("https://docs.oracle.com/en/java/javase/11/docs/api/")
} else {
links("https://docs.oracle.com/javase/8/docs/api/")
}
addBooleanOption("html5", true)
links("https://docs.oracle.com/en/java/javase/17/docs/api/")
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -35,17 +35,86 @@ public class SizeAssertion extends AbstractScopedAssertion implements Serializab

private static final long serialVersionUID = 241L;

// Static int to signify the type of logical comparator to assert
/**
* Comparison operators for size assertions
*/
public enum ComparisonOperator {
EQUAL(1, "size_assertion_comparator_error_equal"),
NOTEQUAL(2, "size_assertion_comparator_error_notequal"),
GREATERTHAN(3, "size_assertion_comparator_error_greater"),
LESSTHAN(4, "size_assertion_comparator_error_less"),
GREATERTHANEQUAL(5, "size_assertion_comparator_error_greaterequal"),
LESSTHANEQUAL(6, "size_assertion_comparator_error_lessequal");

private static final ComparisonOperator[] VALUES = values();

private final int value;
private final String errorMessageKey;

ComparisonOperator(int value, String errorMessageKey) {
this.value = value;
this.errorMessageKey = errorMessageKey;
}

public int getValue() {
return value;
}

public String getErrorMessageKey() {
return errorMessageKey;
}

public static ComparisonOperator fromValue(int value) {
for (ComparisonOperator op : VALUES) {
if (op.value == value) {
return op;
}
}
return null;
}

public boolean evaluate(long actual, long expected) {
switch (this) {
case EQUAL:
return actual == expected;
case NOTEQUAL:
return actual != expected;
case GREATERTHAN:
return actual > expected;
case LESSTHAN:
return actual < expected;
case GREATERTHANEQUAL:
return actual >= expected;
case LESSTHANEQUAL:
return actual <= expected;
}
throw new IllegalStateException("Unexpected value: " + this);
}
}

// Backward compatibility constants - deprecated
/** @deprecated Use {@link ComparisonOperator#EQUAL} instead */
@Deprecated
public static final int EQUAL = 1;

/** @deprecated Use {@link ComparisonOperator#NOTEQUAL} instead */
@Deprecated
public static final int NOTEQUAL = 2;

/** @deprecated Use {@link ComparisonOperator#GREATERTHAN} instead */
@Deprecated
public static final int GREATERTHAN = 3;

/** @deprecated Use {@link ComparisonOperator#LESSTHAN} instead */
@Deprecated
public static final int LESSTHAN = 4;

/** @deprecated Use {@link ComparisonOperator#GREATERTHANEQUAL} instead */
@Deprecated
public static final int GREATERTHANEQUAL = 5;

/** @deprecated Use {@link ComparisonOperator#LESSTHANEQUAL} instead */
@Deprecated
public static final int LESSTHANEQUAL = 6;

/** Key for storing assertion-information in the jmx-file. */
Expand Down Expand Up @@ -175,41 +244,17 @@ public void setAllowedSize(long size) {
*
*/
private String compareSize(long resultSize) {
String comparatorErrorMessage;
long allowedSize = Long.parseLong(getAllowedSize());
boolean result;
int comp = getCompOper();
switch (comp) {
case EQUAL:
result = resultSize == allowedSize;
comparatorErrorMessage = JMeterUtils.getResString("size_assertion_comparator_error_equal"); //$NON-NLS-1$
break;
case NOTEQUAL:
result = resultSize != allowedSize;
comparatorErrorMessage = JMeterUtils.getResString("size_assertion_comparator_error_notequal"); //$NON-NLS-1$
break;
case GREATERTHAN:
result = resultSize > allowedSize;
comparatorErrorMessage = JMeterUtils.getResString("size_assertion_comparator_error_greater"); //$NON-NLS-1$
break;
case LESSTHAN:
result = resultSize < allowedSize;
comparatorErrorMessage = JMeterUtils.getResString("size_assertion_comparator_error_less"); //$NON-NLS-1$
break;
case GREATERTHANEQUAL:
result = resultSize >= allowedSize;
comparatorErrorMessage = JMeterUtils.getResString("size_assertion_comparator_error_greaterequal"); //$NON-NLS-1$
break;
case LESSTHANEQUAL:
result = resultSize <= allowedSize;
comparatorErrorMessage = JMeterUtils.getResString("size_assertion_comparator_error_lessequal"); //$NON-NLS-1$
break;
default:
result = false;
comparatorErrorMessage = "ERROR - invalid condition";
break;
ComparisonOperator operator = ComparisonOperator.fromValue(getCompOper());
if (operator == null) {
return "ERROR - invalid condition";
}

if (operator.evaluate(resultSize, allowedSize)) {
return "";
} else {
return JMeterUtils.getResString(operator.getErrorMessageKey());
}
return result ? "" : comparatorErrorMessage;
}

private void setTestField(String testField) {
Expand Down
Loading
Loading