Skip to content

Commit 3f83e1c

Browse files
authored
Merge pull request #19034 from JasonFengJ9/jdk22warningmsgs-v0.44
(v0.44.0-release) JDK22+ print deprecation warning messages
2 parents 850fad6 + a19c6ba commit 3f83e1c

File tree

4 files changed

+101
-7
lines changed

4 files changed

+101
-7
lines changed

runtime/nls/j9vm/j9vm.nls

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2385,3 +2385,12 @@ J9NLS_VM_MODULARITY_PACKAGE_NOT_FOUND.explanation=The specified package was not
23852385
J9NLS_VM_MODULARITY_PACKAGE_NOT_FOUND.system_action=The JVM will fail to start.
23862386
J9NLS_VM_MODULARITY_PACKAGE_NOT_FOUND.user_response=Contact your service representative.
23872387
# END NON-TRANSLATABLE
2388+
2389+
J9NLS_VM_DEPRECATED_OPTION=%s warning: Option %s was deprecated in JDK 22 and will likely be removed in a future release.
2390+
# START NON-TRANSLATABLE
2391+
J9NLS_VM_DEPRECATED_OPTION.sample_input_1=Eclipse OpenJ9 VM
2392+
J9NLS_VM_DEPRECATED_OPTION.sample_input_2=-Xdebug
2393+
J9NLS_VM_DEPRECATED_OPTION.explanation=The command line option is deprecated.
2394+
J9NLS_VM_DEPRECATED_OPTION.system_action=The JVM will print a deprecation warning.
2395+
J9NLS_VM_DEPRECATED_OPTION.user_response=Remove the command line option from the command line.
2396+
# END NON-TRANSLATABLE

runtime/vm/jvminit.c

Lines changed: 18 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -4442,17 +4442,17 @@ unloadDLL(void* dllLoadInfo, void* userDataTemp)
44424442
Also walks the ignoredOptionTable and if it sees any of those options in the vm_args and marks them as ignored */
44434443

44444444
static void
4445-
registerIgnoredOptions(J9PortLibrary *portLibrary, J9VMInitArgs* j9vm_args)
4445+
registerIgnoredOptions(J9PortLibrary *portLibrary, J9VMInitArgs *j9vm_args)
44464446
{
4447-
UDATA i;
4448-
char* option;
4447+
UDATA i = 0;
4448+
const char *option = NULL;
44494449
const struct J9VMIgnoredOption *ignoredOptionTablePtr = (const struct J9VMIgnoredOption *)GLOBAL_TABLE(ignoredOptionTable);
44504450

44514451
PORT_ACCESS_FROM_PORT(portLibrary);
44524452

4453-
for (i=0; i<j9vm_args->nOptions; i++) {
4453+
for (i = 0; i < j9vm_args->nOptions; i++) {
44544454
option = getOptionString(j9vm_args, i); /* may return mapped value */
4455-
if ((strlen(option)>2) && option[0]=='-') {
4455+
if ((strlen(option) > 2) && ('-' == option[0])) {
44564456
switch (option[1]) {
44574457
/* Mark all -D options as non-consumable */
44584458
case 'D' :
@@ -4463,8 +4463,19 @@ registerIgnoredOptions(J9PortLibrary *portLibrary, J9VMInitArgs* j9vm_args)
44634463
}
44644464

44654465
/* Mark all ignored options as consumed */
4466-
for (i=0; i<ignoredOptionTableSize; i++) {
4467-
findArgInVMArgs( PORTLIB, j9vm_args, ignoredOptionTablePtr[i].match, ignoredOptionTablePtr[i].optionName, NULL, TRUE);
4466+
for (i = 0; i < ignoredOptionTableSize; i++) {
4467+
const char *optionName = ignoredOptionTablePtr[i].optionName;
4468+
#if JAVA_SPEC_VERSION >= 22
4469+
IDATA index =
4470+
#endif /* JAVA_SPEC_VERSION >= 22 */
4471+
findArgInVMArgs( PORTLIB, j9vm_args, ignoredOptionTablePtr[i].match, optionName, NULL, TRUE);
4472+
#if JAVA_SPEC_VERSION >= 22
4473+
if ((index >= 0)
4474+
&& ((0 == strcmp(VMOPT_XDEBUG, optionName)) || (0 == strcmp(VMOPT_XNOAGENT, optionName)))
4475+
) {
4476+
j9nls_printf(PORTLIB, J9NLS_WARNING, J9NLS_VM_DEPRECATED_OPTION, JAVA_VM_NAME, optionName);
4477+
}
4478+
#endif /* JAVA_SPEC_VERSION >= 22 */
44684479
}
44694480
}
44704481

Lines changed: 53 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,53 @@
1+
<?xml version="1.0" encoding="UTF-8" standalone="no" ?>
2+
3+
<!--
4+
Copyright IBM Corp. and others 2024
5+
6+
This program and the accompanying materials are made available under
7+
the terms of the Eclipse Public License 2.0 which accompanies this
8+
distribution and is available at https://www.eclipse.org/legal/epl-2.0/
9+
or the Apache License, Version 2.0 which accompanies this distribution and
10+
is available at https://www.apache.org/licenses/LICENSE-2.0.
11+
12+
This Source Code may also be made available under the following
13+
Secondary Licenses when the conditions for such availability set
14+
forth in the Eclipse Public License, v. 2.0 are satisfied: GNU
15+
General Public License, version 2 with the GNU Classpath
16+
Exception [1] and GNU General Public License, version 2 with the
17+
OpenJDK Assembly Exception [2].
18+
19+
[1] https://www.gnu.org/software/classpath/license.html
20+
[2] https://openjdk.org/legal/assembly-exception.html
21+
22+
SPDX-License-Identifier: EPL-2.0 OR Apache-2.0 OR GPL-2.0-only WITH Classpath-exception-2.0 OR GPL-2.0-only WITH OpenJDK-assembly-exception-1.0
23+
-->
24+
25+
<!DOCTYPE suite SYSTEM "cmdlinetester.dtd">
26+
27+
<suite id="DeprecatedVMOptions Command-Line Option Tests" timeout="2400">
28+
29+
<variable name="XDEBUG" value="-Xdebug" />
30+
<variable name="XNOAGENT" value="-Xnoagent" />
31+
32+
<test id="test -Xdebug">
33+
<command>$EXE$ $XDEBUG$ -version</command>
34+
<output type="success" caseSensitive="no" regex="yes" javaUtilPattern="yes">(java|openjdk|semeru) version</output>
35+
<output type="required" caseSensitive="no" regex="yes" javaUtilPattern="yes">JVMJ9VM246W(.)*-Xdebug</output>
36+
<output type="failure" caseSensitive="no" regex="no">Command-line option unrecognised</output>
37+
</test>
38+
39+
<test id="test -Xnoagent">
40+
<command>$EXE$ $XNOAGENT$ -version</command>
41+
<output type="success" caseSensitive="no" regex="yes" javaUtilPattern="yes">(java|openjdk|semeru) version</output>
42+
<output type="required" caseSensitive="no" regex="yes" javaUtilPattern="yes">JVMJ9VM246W(.)*-Xnoagent</output>
43+
<output type="failure" caseSensitive="no" regex="no">Command-line option unrecognised</output>
44+
</test>
45+
46+
<test id="test -Xdebug -Xnoagent">
47+
<command>$EXE$ $XDEBUG$ $XNOAGENT$ -version</command>
48+
<output type="success" caseSensitive="no" regex="yes" javaUtilPattern="yes">(java|openjdk|semeru) version</output>
49+
<output type="required" caseSensitive="no" regex="yes" javaUtilPattern="yes">JVMJ9VM246W(.)*-Xdebug</output>
50+
<output type="required" caseSensitive="no" regex="yes" javaUtilPattern="yes">JVMJ9VM246W(.)*-Xnoagent</output>
51+
<output type="failure" caseSensitive="no" regex="no">Command-line option unrecognised</output>
52+
</test>
53+
</suite>

test/functional/cmdLineTests/ignoreUnrecognizedVMOptions/playlist.xml

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -58,4 +58,25 @@
5858
<impl>openj9</impl>
5959
</impls>
6060
</test>
61+
<test>
62+
<testCaseName>cmdLineTester_deprecatedvmoptions</testCaseName>
63+
<variations>
64+
<variation>NoOptions</variation>
65+
</variations>
66+
<command>$(JAVA_COMMAND) $(CMDLINETESTER_JVM_OPTIONS) -DTESTDIR=$(Q)$(TEST_RESROOT)$(Q) -DRESJAR=$(CMDLINETESTER_RESJAR) -DEXE=$(SQ)$(JAVA_COMMAND)$(SQ) -jar $(CMDLINETESTER_JAR) -config $(Q)$(TEST_RESROOT)$(D)deprecatedvmoptions.xml$(Q) -explainExcludes -nonZeroExitWhenError; \
67+
$(TEST_STATUS)</command>
68+
<levels>
69+
<level>extended</level>
70+
</levels>
71+
<groups>
72+
<group>functional</group>
73+
</groups>
74+
<impls>
75+
<impl>ibm</impl>
76+
<impl>openj9</impl>
77+
</impls>
78+
<versions>
79+
<version>22+</version>
80+
</versions>
81+
</test>
6182
</playlist>

0 commit comments

Comments
 (0)