Skip to content

Commit

Permalink
Merge pull request #1912 from SAP/pr-jdk-24+35
Browse files Browse the repository at this point in the history
Merge to tag jdk-24+35
  • Loading branch information
RealCLanger authored Feb 5, 2025
2 parents afebe4a + 5f5ed96 commit 28db524
Show file tree
Hide file tree
Showing 27 changed files with 631 additions and 3,199 deletions.
4 changes: 2 additions & 2 deletions make/common/Modules.gmk
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
#
# Copyright (c) 2014, 2023, Oracle and/or its affiliates. All rights reserved.
# Copyright (c) 2014, 2025, Oracle and/or its affiliates. All rights reserved.
# DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
#
# This code is free software; you can redistribute it and/or modify it
Expand Down Expand Up @@ -92,7 +92,7 @@ SRC_SUBDIRS += share/classes

SPEC_SUBDIRS += share/specs

MAN_SUBDIRS += share/man
MAN_SUBDIRS += share/man windows/man

# Find all module-info.java files for the current build target platform and
# configuration.
Expand Down
5 changes: 5 additions & 0 deletions src/hotspot/share/cds/cdsConfig.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -420,6 +420,11 @@ void CDSConfig::check_flag_aliases() {
bool CDSConfig::check_vm_args_consistency(bool patch_mod_javabase, bool mode_flag_cmd_line) {
check_flag_aliases();

if (!FLAG_IS_DEFAULT(AOTMode)) {
// Using any form of the new AOTMode switch enables enhanced optimizations.
FLAG_SET_ERGO_IF_DEFAULT(AOTClassLinking, true);
}

if (AOTClassLinking) {
// If AOTClassLinking is specified, enable all AOT optimizations by default.
FLAG_SET_ERGO_IF_DEFAULT(AOTInvokeDynamicLinking, true);
Expand Down
7 changes: 7 additions & 0 deletions src/hotspot/share/cds/filemap.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2511,6 +2511,13 @@ bool FileMapInfo::validate_aot_class_linking() {
log_error(cds)("CDS archive has aot-linked classes. It cannot be used with -Djava.security.manager=%s.", prop);
return false;
}

#if INCLUDE_JVMTI
if (Arguments::has_jdwp_agent()) {
log_error(cds)("CDS archive has aot-linked classes. It cannot be used with JDWP agent");
return false;
}
#endif
}

return true;
Expand Down
7 changes: 7 additions & 0 deletions src/hotspot/share/classfile/systemDictionaryShared.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -327,6 +327,13 @@ bool SystemDictionaryShared::check_for_exclusion_impl(InstanceKlass* k) {
if (!k->is_linked()) {
if (has_class_failed_verification(k)) {
return warn_excluded(k, "Failed verification");
} else if (CDSConfig::is_dumping_aot_linked_classes()) {
// Most loaded classes should have been speculatively linked by MetaspaceShared::link_class_for_cds().
// However, we do not speculatively link old classes, as they are not recorded by
// SystemDictionaryShared::record_linking_constraint(). As a result, such an unlinked
// class may fail to verify in AOTLinkedClassBulkLoader::init_required_classes_for_loader(),
// causing the JVM to fail at bootstrap.
return warn_excluded(k, "Unlinked class not supported by AOTClassLinking");
}
} else {
if (!k->can_be_verified_at_dumptime()) {
Expand Down
7 changes: 6 additions & 1 deletion src/hotspot/share/runtime/arguments.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -103,6 +103,7 @@ bool Arguments::_ClipInlining = ClipInlining;
size_t Arguments::_default_SharedBaseAddress = SharedBaseAddress;

bool Arguments::_enable_preview = false;
bool Arguments::_has_jdwp_agent = false;

LegacyGCLogging Arguments::_legacyGCLogging = { nullptr, 0 };

Expand Down Expand Up @@ -2021,7 +2022,7 @@ jint Arguments::parse_vm_init_args(const JavaVMInitArgs *vm_options_args,
return JNI_OK;
}

#if !INCLUDE_JVMTI
#if !INCLUDE_JVMTI || INCLUDE_CDS
// Checks if name in command-line argument -agent{lib,path}:name[=options]
// represents a valid JDWP agent. is_path==true denotes that we
// are dealing with -agentpath (case where name is a path), otherwise with
Expand Down Expand Up @@ -2319,6 +2320,10 @@ jint Arguments::parse_each_vm_init_arg(const JavaVMInitArgs* args, JVMFlagOrigin
"Debugging agents are not supported in this VM\n");
return JNI_ERR;
}
#elif INCLUDE_CDS
if (valid_jdwp_agent(name, is_absolute_path)) {
_has_jdwp_agent = true;
}
#endif // !INCLUDE_JVMTI
JvmtiAgentList::add(name, options, is_absolute_path);
os::free(name);
Expand Down
8 changes: 7 additions & 1 deletion src/hotspot/share/runtime/arguments.hpp
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
* Copyright (c) 1997, 2024, Oracle and/or its affiliates. All rights reserved.
* Copyright (c) 1997, 2025, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
Expand Down Expand Up @@ -254,6 +254,9 @@ class Arguments : AllStatic {
// preview features
static bool _enable_preview;

// jdwp
static bool _has_jdwp_agent;

// Used to save default settings
static bool _AlwaysCompileLoopMethods;
static bool _UseOnStackReplacement;
Expand Down Expand Up @@ -506,6 +509,9 @@ class Arguments : AllStatic {
static void set_enable_preview() { _enable_preview = true; }
static bool enable_preview() { return _enable_preview; }

// jdwp
static bool has_jdwp_agent() { return _has_jdwp_agent; }

// Utility: copies src into buf, replacing "%%" with "%" and "%p" with pid.
static bool copy_expand_pid(const char* src, size_t srclen, char* buf, size_t buflen);

Expand Down
6 changes: 3 additions & 3 deletions src/java.base/share/classes/java/util/Formatter.java
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
* Copyright (c) 2003, 2024, Oracle and/or its affiliates. All rights reserved.
* Copyright (c) 2003, 2025, Oracle and/or its affiliates. All rights reserved.
* Copyright (c) 2023, Alibaba Group Holding Limited. All Rights Reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
Expand Down Expand Up @@ -432,7 +432,7 @@
* prefix {@code 'T'} forces this output to upper case.
*
* <tr><th scope="row" style="vertical-align:top">{@code 'z'}
* <td> <a href="http://www.ietf.org/rfc/rfc0822.txt">RFC&nbsp;822</a>
* <td> <a href="https://www.ietf.org/rfc/rfc822.txt">RFC&nbsp;822</a>
* style numeric time zone offset from GMT, e.g. {@code -0800}. This
* value will be adjusted as necessary for Daylight Saving Time. For
* {@code long}, {@link Long}, and {@link Date} the time zone used is
Expand Down Expand Up @@ -1720,7 +1720,7 @@
*
* <tr><th scope="row" style="vertical-align:top">{@code 'z'}
* <td style="vertical-align:top"> <code>'&#92;u007a'</code>
* <td> <a href="http://www.ietf.org/rfc/rfc0822.txt">RFC&nbsp;822</a>
* <td> <a href="https://www.ietf.org/rfc/rfc822.txt">RFC&nbsp;822</a>
* style numeric time zone offset from GMT, e.g. {@code -0800}. This
* value will be adjusted as necessary for Daylight Saving Time. For
* {@code long}, {@link Long}, and {@link Date} the time zone used is
Expand Down
113 changes: 111 additions & 2 deletions src/java.base/share/man/java.md
Original file line number Diff line number Diff line change
Expand Up @@ -4011,12 +4011,12 @@ The values for these options (if specified), should be identical when creating a
CDS archive. Otherwise, if there is a mismatch of any of these options, the CDS archive may be
partially or completely disabled, leading to lower performance.

- If the -XX:+AOTClassLinking options *was* used during CDS archive creation, the CDS archive
- If the `AOTClassLinking` option (see below) *was* enabled during CDS archive creation, the CDS archive
cannot be used, and the following error message is printed:

`CDS archive has aot-linked classes. It cannot be used when archived full module graph is not used`

- If the -XX:+AOTClassLinking options *was not* used during CDS archive creation, the CDS archive
- If the `AOTClassLinking` option *was not* enabled during CDS archive creation, the CDS archive
can be used, but the "archived module graph" feature will be disabled. This can lead to increased
start-up time.

Expand All @@ -4037,6 +4037,115 @@ JVM will execute without loading any CDS archives. In addition, if
you try to create a CDS archive with any of these 3 options specified,
the JVM will report an error.

## Ahead-of-Time Cache

The JDK supports ahead-of-time (AOT) optimizations that can be performed before an
application is executed. One example is Class Data Sharing (CDS), as described above,
that parses classes ahead of time. AOT optimizations can improve the start-up and
warm-up performance of Java applications.

The Ahead-of-Time Cache (AOT cache) is a container introduced in JDK 24 for
storing artifacts produced by AOT optimizations. The AOT cache currently contains
Java classes and heap objects. In future JDK releases, the AOT cache may contain additional
artifacts, such as execution profiles and compiled methods.

An AOT cache is specific to a combination of the following:

- A particular application (as expressed by `-classpath`, `-jar`, or `--module-path`.)
- A particular JDK release.
- A particular OS and CPU architecture.

If any of the above changes, you must recreate the AOT cache.

The deployment of the AOT cache is divided into three phases:

- **Training:** We execute the application with a representative work-load
to gather statistical data that tell us what artifacts should be included
into the AOT cache. The data are saved in an *AOT Configuration* file.

- **Assembly:** We use the AOT Configuration file to produce an AOT cache.

- **Production:** We execute the application with the AOT cache for better
start-up and warm-up performance.

The AOT cache can be used with the following command-line options:

`-XX:AOTCache:=`*cachefile*
: Specifies the location of the AOT cache. The standard extension for *cachefile* is `.aot`.
If `-XX:AOTCache` is specified but `-XX:AOTMode` is not specified,
then `AOTMode` will be given the value of `auto`.

`-XX:AOTConfiguration:=`*configfile*
: Specifies the AOT Configuration file for the JVM to write to or read from.
This option can be used only with `-XX:AOTMode=record` and `-XX:AOTMode=create`.
The standard extension for *configfile* is `.aotconfig`.

`-XX:+AOTMode:=`*mode*
: *mode* must be one of the following: `off`, `record`, `create`, `auto`, or `on`.

- `off`: no AOT cache is used.

- `record`: Execute the application in the Training phase.
`-XX:AOTConfiguration=`*configfile* must be specified. The JVM gathers
statistical data and stores them into *configfile*.

- `create`: Perform the Assembly phase. `-XX:AOTConfiguration=`*configfile*
and `-XX:AOTCache=`*cachefile* must be specified. The JVM reads the statistical
data from *configfile* and writes the optimization artifacts into *cachefile*.
Note that the application itself is not executed in this phase.

- `auto` or `on`: These modes should be used in the Production phase.
If `-XX:AOTCache=`*cachefile* is specified, the JVM tries to
load *cachefile* as the AOT cache. Otherwise, the JVM tries to load
a *default CDS archive* from the JDK installation directory as the AOT cache.

The loading of an AOT cache can fail for a number of reasons:

- You are trying to use the AOT cache with an incompatible application, JDK release,
or OS/CPU.

- The specified *cachefile* does not exist or is not accessible.

- Incompatible JVM options are used (for example, certain JVMTI options).

Since the AOT cache is an optimization feature, there's no guarantee that it will be
compatible with all possible JVM options. See [JEP 483](https://openjdk.org/jeps/483),
section **Consistency of training and subsequent runs** for a representative
list of scenarios that may be incompatible with the AOT cache for JDK 24.

These scenarios usually involve arbitrary modification of classes for diagnostic
purposes and are typically not relevant for production environments.

When the AOT cache fails to load:

- If `AOTMode` is `auto`, the JVM will continue execution without using the
AOT cache. This is the recommended mode for production environments, especially
when you may not have complete control of the command-line (e.g., your
application's launch script may allow users to inject options to the command-line).
This allows your application to function correctly, although sometimes it may not
benefit from the AOT cache.

- If `AOTMode` is `on`, the JVM will print an error message and exit immediately. This
mode should be used only as a "fail-fast" debugging aid to check if your command-line
options are compatible with the AOT cache. An alternative is to run your application with
`-XX:AOTMode=auto -Xlog:cds` to see if the AOT cache can be used or not.

`-XX:+AOTClassLinking`
: If this option is enabled, the JVM will perform more advanced optimizations (such
as ahead-of-time resolution of invokedynamic instructions)
when creating the AOT cache. As a result, the application will see further improvements
in start-up and warm-up performance. However, an AOT cache created with this option
cannot be used when certain command-line parameters are specified in
the Production phase. Please see [JEP 483](https://openjdk.org/jeps/483) for a
detailed discussion of `-XX:+AOTClassLinking` and its restrictions.

When `-XX:AOTMode` *is used* in the command-line, `AOTClassLinking` is automatically
enabled. To disable it, you must explicitly pass the `-XX:-AOTClassLinking` option.

When `-XX:AOTMode` *is not used* in the command-line, `AOTClassLinking` is disabled by
default to provide full compatibility with traditional CDS options such as `-Xshare:dump.


## Performance Tuning Examples

You can use the Java advanced runtime options to optimize the performance of
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@
* <ul>
* <li>
* Paged results, as defined in
* <a href="http://www.ietf.org/rfc/rfc2696.txt">RFC 2696</a>.
* <a href="https://www.ietf.org/rfc/rfc2696.txt">RFC 2696</a>.
* <li>
* Server-side sorting, as defined in
* <a href="http://www.ietf.org/rfc/rfc2891.txt">RFC 2891</a>.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -92,7 +92,7 @@
* } </pre>
* <p>
* This class implements the LDAPv3 Control for paged-results as defined in
* <a href="http://www.ietf.org/rfc/rfc2696.txt">RFC 2696</a>.
* <a href="https://www.ietf.org/rfc/rfc2696.txt">RFC 2696</a>.
*
* The control's value has the following ASN.1 definition:
* <pre>{@code
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
* Copyright (c) 2003, 2020, Oracle and/or its affiliates. All rights reserved.
* Copyright (c) 2003, 2025, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
Expand Down Expand Up @@ -40,7 +40,7 @@
* <p>
* This class implements the LDAPv3 Response Control for
* paged-results as defined in
* <a href="http://www.ietf.org/rfc/rfc2696">RFC 2696</a>.
* <a href="https://www.ietf.org/rfc/rfc2696.txt">RFC 2696</a>.
*
* The control's value has the following ASN.1 definition:
* <pre>
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
* Copyright (c) 2003, 2021, Oracle and/or its affiliates. All rights reserved.
* Copyright (c) 2003, 2025, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
Expand Down Expand Up @@ -64,7 +64,7 @@
* but may involve techniques such as the <i>positive
* acknowledgment with retransmission</i> technique used in
* protocols such as the Transmission Control Protocol (TCP)
* (see <a href="http://www.ietf.org/rfc/rfc0793.txt"> RFC 793
* (see <a href="https://www.ietf.org/rfc/rfc793.txt"> RFC 793
* </a>).
*
* <p> A transport service can be used to initiate a connection
Expand Down
7 changes: 3 additions & 4 deletions test/docs/jdk/javadoc/doccheck/ExtLinksJdk.txt
Original file line number Diff line number Diff line change
Expand Up @@ -43,8 +43,8 @@ http://www.iana.org/assignments/character-sets/character-sets.xhtml
http://www.iana.org/assignments/media-types/
http://www.iana.org/assignments/uri-schemes.html
http://www.ietf.org/
http://www.ietf.org/rfc/rfc0793.txt
http://www.ietf.org/rfc/rfc0822.txt
https://www.ietf.org/rfc/rfc793.txt
https://www.ietf.org/rfc/rfc822.txt
http://www.ietf.org/rfc/rfc1122.txt
http://www.ietf.org/rfc/rfc1123.txt
http://www.ietf.org/rfc/rfc1323.txt
Expand Down Expand Up @@ -83,8 +83,7 @@ http://www.ietf.org/rfc/rfc2440.txt
http://www.ietf.org/rfc/rfc2474.txt
http://www.ietf.org/rfc/rfc2609.txt
http://www.ietf.org/rfc/rfc2616.txt
http://www.ietf.org/rfc/rfc2696
http://www.ietf.org/rfc/rfc2696.txt
https://www.ietf.org/rfc/rfc2696.txt
http://www.ietf.org/rfc/rfc2710.txt
http://www.ietf.org/rfc/rfc2732.txt
http://www.ietf.org/rfc/rfc2743.txt
Expand Down
16 changes: 15 additions & 1 deletion test/hotspot/jtreg/TEST.groups
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
#
# Copyright (c) 2013, 2024, Oracle and/or its affiliates. All rights reserved.
# Copyright (c) 2013, 2025, Oracle and/or its affiliates. All rights reserved.
# DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
#
# This code is free software; you can redistribute it and/or modify it
Expand Down Expand Up @@ -534,14 +534,21 @@ hotspot_aot_classlinking = \
-runtime/cds/appcds/cacheObject/ArchivedIntegerCacheTest.java \
-runtime/cds/appcds/cacheObject/ArchivedModuleCompareTest.java \
-runtime/cds/appcds/CDSandJFR.java \
-runtime/cds/appcds/customLoader/CustomClassListDump.java \
-runtime/cds/appcds/customLoader/HelloCustom_JFR.java \
-runtime/cds/appcds/customLoader/OldClassAndInf.java \
-runtime/cds/appcds/customLoader/ParallelTestMultiFP.java \
-runtime/cds/appcds/customLoader/ParallelTestSingleFP.java \
-runtime/cds/appcds/customLoader/SameNameInTwoLoadersTest.java \
-runtime/cds/appcds/DumpClassListWithLF.java \
-runtime/cds/appcds/dynamicArchive/ModulePath.java \
-runtime/cds/appcds/dynamicArchive/LambdaCustomLoader.java \
-runtime/cds/appcds/dynamicArchive/LambdaForOldInfInBaseArchive.java \
-runtime/cds/appcds/dynamicArchive/LambdaInBaseArchive.java \
-runtime/cds/appcds/dynamicArchive/LambdasInTwoArchives.java \
-runtime/cds/appcds/dynamicArchive/OldClassAndInf.java \
-runtime/cds/appcds/dynamicArchive/OldClassInBaseArchive.java \
-runtime/cds/appcds/dynamicArchive/OldClassVerifierTrouble.java \
-runtime/cds/appcds/HelloExtTest.java \
-runtime/cds/appcds/javaldr/AnonVmClassesDuringDump.java \
-runtime/cds/appcds/javaldr/GCDuringDump.java \
Expand All @@ -562,6 +569,13 @@ hotspot_aot_classlinking = \
-runtime/cds/appcds/jvmti \
-runtime/cds/appcds/LambdaProxyClasslist.java \
-runtime/cds/appcds/loaderConstraints/LoaderConstraintsTest.java \
-runtime/cds/appcds/NestHostOldInf.java \
-runtime/cds/appcds/OldClassTest.java \
-runtime/cds/appcds/OldClassWithjsr.java \
-runtime/cds/appcds/OldInfExtendsInfDefMeth.java \
-runtime/cds/appcds/OldSuperClass.java \
-runtime/cds/appcds/OldSuperInfIndirect.java \
-runtime/cds/appcds/OldSuperInf.java \
-runtime/cds/appcds/redefineClass \
-runtime/cds/appcds/resolvedConstants/AOTLinkedLambdas.java \
-runtime/cds/appcds/resolvedConstants/AOTLinkedVarHandles.java \
Expand Down
Loading

0 comments on commit 28db524

Please sign in to comment.