Skip to content

Commit 2621518

Browse files
[GR-51948] Merge in tag jdk-22+35
PullRequest: labsjdk-ce-22/12
2 parents 9fe84e1 + eec04bf commit 2621518

File tree

81 files changed

+537
-238
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

81 files changed

+537
-238
lines changed

make/conf/version-numbers.conf

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -39,4 +39,4 @@ DEFAULT_VERSION_CLASSFILE_MINOR=0
3939
DEFAULT_VERSION_DOCS_API_SINCE=11
4040
DEFAULT_ACCEPTABLE_BOOT_VERSIONS="21 22"
4141
DEFAULT_JDK_SOURCE_TARGET_VERSION=22
42-
DEFAULT_PROMOTED_VERSION_PRE=ea
42+
DEFAULT_PROMOTED_VERSION_PRE=

src/hotspot/share/classfile/systemDictionary.cpp

Lines changed: 5 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1111,14 +1111,13 @@ InstanceKlass* SystemDictionary::load_shared_lambda_proxy_class(InstanceKlass* i
11111111
if (loaded_ik != nullptr) {
11121112
assert(shared_nest_host->is_same_class_package(ik),
11131113
"lambda proxy class and its nest host must be in the same package");
1114+
// The lambda proxy class and its nest host have the same class loader and class loader data,
1115+
// as verified in SystemDictionaryShared::add_lambda_proxy_class()
1116+
assert(shared_nest_host->class_loader() == class_loader(), "mismatched class loader");
1117+
assert(shared_nest_host->class_loader_data() == class_loader_data(class_loader), "mismatched class loader data");
1118+
ik->set_nest_host(shared_nest_host);
11141119
}
11151120

1116-
// The lambda proxy class and its nest host have the same class loader and class loader data,
1117-
// as verified in SystemDictionaryShared::add_lambda_proxy_class()
1118-
assert(shared_nest_host->class_loader() == class_loader(), "mismatched class loader");
1119-
assert(shared_nest_host->class_loader_data() == class_loader_data(class_loader), "mismatched class loader data");
1120-
ik->set_nest_host(shared_nest_host);
1121-
11221121
return loaded_ik;
11231122
}
11241123

src/hotspot/share/compiler/compileBroker.cpp

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -841,8 +841,15 @@ void DeoptimizeObjectsALotThread::deoptimize_objects_alot_loop_all() {
841841

842842

843843
JavaThread* CompileBroker::make_thread(ThreadType type, jobject thread_handle, CompileQueue* queue, AbstractCompiler* comp, JavaThread* THREAD) {
844-
JavaThread* new_thread = nullptr;
844+
Handle thread_oop(THREAD, JNIHandles::resolve_non_null(thread_handle));
845845

846+
if (java_lang_Thread::thread(thread_oop()) != nullptr) {
847+
assert(type == compiler_t, "should only happen with reused compiler threads");
848+
// The compiler thread hasn't actually exited yet so don't try to reuse it
849+
return nullptr;
850+
}
851+
852+
JavaThread* new_thread = nullptr;
846853
switch (type) {
847854
case compiler_t:
848855
assert(comp != nullptr, "Compiler instance missing.");
@@ -871,7 +878,6 @@ JavaThread* CompileBroker::make_thread(ThreadType type, jobject thread_handle, C
871878
// JavaThread due to lack of resources. We will handle that failure below.
872879
// Also check new_thread so that static analysis is happy.
873880
if (new_thread != nullptr && new_thread->osthread() != nullptr) {
874-
Handle thread_oop(THREAD, JNIHandles::resolve_non_null(thread_handle));
875881

876882
if (type == compiler_t) {
877883
CompilerThread::cast(new_thread)->set_compiler(comp);

src/hotspot/share/runtime/javaThread.cpp

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -745,6 +745,7 @@ static void ensure_join(JavaThread* thread) {
745745
// Clear the native thread instance - this makes isAlive return false and allows the join()
746746
// to complete once we've done the notify_all below. Needs a release() to obey Java Memory Model
747747
// requirements.
748+
assert(java_lang_Thread::thread(threadObj()) == thread, "must be alive");
748749
java_lang_Thread::release_set_thread(threadObj(), nullptr);
749750
lock.notify_all(thread);
750751
// Ignore pending exception, since we are exiting anyway
@@ -2155,6 +2156,8 @@ void JavaThread::start_internal_daemon(JavaThread* current, JavaThread* target,
21552156
// on a ThreadsList. We don't want to wait for the release when the
21562157
// Theads_lock is dropped when the 'mu' destructor is run since the
21572158
// JavaThread* is already visible to JVM/TI via the ThreadsList.
2159+
2160+
assert(java_lang_Thread::thread(thread_oop()) == nullptr, "must not be alive");
21582161
java_lang_Thread::release_set_thread(thread_oop(), target); // isAlive == true now
21592162
Thread::start(target);
21602163
}

src/java.base/share/classes/java/lang/foreign/Arena.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -258,7 +258,7 @@ static Arena ofConfined() {
258258
}
259259

260260
/**
261-
* {@return a new shared arena} Segments allocated with the global arena can be
261+
* {@return a new shared arena} Segments allocated with the shared arena can be
262262
* {@linkplain MemorySegment#isAccessibleBy(Thread) accessed} by any thread.
263263
* <p>
264264
* Memory segments {@linkplain #allocate(long, long) allocated} by the returned arena

src/java.base/share/man/java.1

Lines changed: 59 additions & 37 deletions
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,7 @@
3636
. ftr VB CB
3737
. ftr VBI CBI
3838
.\}
39-
.TH "JAVA" "1" "2024" "JDK 22-ea" "JDK Commands"
39+
.TH "JAVA" "1" "2024" "JDK 22" "JDK Commands"
4040
.hy
4141
.SH NAME
4242
.PP
@@ -63,7 +63,7 @@ or
6363
\f[V]java\f[R] [\f[I]options\f[R]] \f[V]--module\f[R]
6464
\f[I]module\f[R][\f[V]/\f[R]\f[I]mainclass\f[R]] [\f[I]args\f[R] ...]
6565
.PP
66-
To launch a single source-file program:
66+
To launch a source-file program:
6767
.PP
6868
\f[V]java\f[R] [\f[I]options\f[R]] \f[I]source-file\f[R] [\f[I]args\f[R]
6969
\&...]
@@ -100,11 +100,10 @@ See \f[B]Standard Options for Java\f[R].
100100
.RE
101101
.TP
102102
\f[I]source-file\f[R]
103-
Only used to launch a single source-file program.
103+
Only used to launch a source-file program.
104104
Specifies the source file that contains the main class when using
105105
source-file mode.
106-
See \f[B]Using Source-File Mode to Launch Single-File Source-Code
107-
Programs\f[R]
106+
See \f[B]Using Source-File Mode to Launch Source-Code Programs\f[R]
108107
.TP
109108
\f[I]args\f[R] ...
110109
Optional: Arguments following \f[I]mainclass\f[R],
@@ -128,8 +127,8 @@ The method declaration has the following form:
128127
.PP
129128
In source-file mode, the \f[V]java\f[R] command can launch a class
130129
declared in a source file.
131-
See \f[B]Using Source-File Mode to Launch Single-File Source-Code
132-
Programs\f[R] for a description of using the source-file mode.
130+
See \f[B]Using Source-File Mode to Launch Source-Code Programs\f[R] for
131+
a description of using the source-file mode.
133132
.RS
134133
.PP
135134
\f[B]Note:\f[R] You can use the \f[V]JDK_JAVA_OPTIONS\f[R] launcher
@@ -157,7 +156,7 @@ Use \f[V]javaw\f[R] when you don\[aq]t want a command prompt window to
157156
appear.
158157
The \f[V]javaw\f[R] launcher will, however, display a dialog box with
159158
error information if a launch fails.
160-
.SH USING SOURCE-FILE MODE TO LAUNCH SINGLE-FILE SOURCE-CODE PROGRAMS
159+
.SH USING SOURCE-FILE MODE TO LAUNCH SOURCE-CODE PROGRAMS
161160
.PP
162161
To launch a class declared in a source file, run the \f[V]java\f[R]
163162
launcher in source-file mode.
@@ -205,26 +204,25 @@ Any arguments placed after the name of the source file in the original
205204
command line are passed to the compiled class when it is executed.
206205
.PP
207206
For example, if a file were named \f[V]HelloWorld.java\f[R] and
208-
contained a class named \f[V]hello.World\f[R], then the source-file mode
207+
contained a class named \f[V]HelloWorld\f[R], then the source-file mode
209208
command to launch the class would be:
210209
.RS
211210
.PP
212211
\f[V]java HelloWorld.java\f[R]
213212
.RE
214213
.PP
215-
The example illustrates that the class can be in a named package, and
216-
does not need to be in the unnamed package.
217214
This use of source-file mode is informally equivalent to using the
218-
following two commands where \f[V]hello.World\f[R] is the name of the
219-
class in the package:
215+
following two commands:
220216
.IP
221217
.nf
222218
\f[CB]
223-
javac -d <memory> HelloWorld.java
224-
java -cp <memory> hello.World
219+
javac -d <memory> --source-path <source-root> HelloWorld.java
220+
java --class-path <memory> HelloWorld
225221
\f[R]
226222
.fi
227223
.PP
224+
where \f[V]<source-root>\f[R] is computed
225+
.PP
228226
\f[B]In source-file mode, any additional command-line options are
229227
processed as follows:\f[R]
230228
.IP \[bu] 2
@@ -253,9 +251,24 @@ filename with an \f[V]\[at]\f[R] character.
253251
.IP \[bu] 2
254252
Any command-line options that are relevant to the compilation
255253
environment are taken into account.
256-
.IP \[bu] 2
257-
No other source files are found and compiled, as if the source path is
258-
set to an empty value.
254+
These include:
255+
\f[V]--class-path\f[R]/\f[V]-classpath\f[R]/\f[V]-cp\f[R],
256+
\f[V]--module-path\f[R]/\f[V]-p\f[R], \f[V]--add-exports\f[R],
257+
\f[V]--add-modules\f[R], \f[V]--limit-modules\f[R],
258+
\f[V]--patch-module\f[R], \f[V]--upgrade-module-path\f[R],
259+
\f[V]--enable-preview\f[R].
260+
.IP \[bu] 2
261+
The root of the source tree, \f[V]<source-root>\f[R] is computed from
262+
the package of the class being launched.
263+
For example, if \f[V]HelloWorld.java\f[R] declared its classes to be in
264+
the \f[V]hello\f[R] package, then the file \f[V]HelloWorld.java\f[R] is
265+
expected to reside in the directory \f[V]somedir/hello/\f[R].
266+
In this case, \f[V]somedir\f[R] is computed to be the root of the source
267+
tree.
268+
.IP \[bu] 2
269+
The root of the source tree serves as the source-path for compilation,
270+
so that other source files found in that tree and are needed by
271+
\f[V]HelloWorld\f[R] could be compiled.
259272
.IP \[bu] 2
260273
Annotation processing is disabled, as if \f[V]-proc:none\f[R] is in
261274
effect.
@@ -266,45 +279,54 @@ the compilation.
266279
This sets both the source version accepted by compiler and the system
267280
API that may be used by the code in the source file.
268281
.IP \[bu] 2
269-
The source file is compiled in the context of an unnamed module.
282+
If a \f[V]module-info.java\f[R] file exists in the
283+
\f[V]<source-root>\f[R] directory, its module declaration is used to
284+
define a named module that will contain all the classes compiled from
285+
\f[V].java\f[R] files in the source tree.
286+
If \f[V]module-info.java\f[R] does not exist, all the classes compiled
287+
from source files will be compiled in the context of the unnamed module.
270288
.IP \[bu] 2
271-
The source file should contain one or more top-level classes, the first
272-
of which is taken as the class to be executed.
289+
The source file that is launched should contain one or more top-level
290+
classes, the first of which is taken as the class to be executed.
273291
.IP \[bu] 2
274-
The compiler does not enforce the optional restriction defined at the
275-
end of JLS 7.6, that a type in a named package should exist in a file
276-
whose name is composed from the type name followed by the
277-
\f[V].java\f[R] extension.
292+
For the source file that is launched, the compiler does not enforce the
293+
optional restriction defined at the end of JLS 7.6, that a type in a
294+
named package should exist in a file whose name is composed from the
295+
type name followed by the \f[V].java\f[R] extension.
278296
.IP \[bu] 2
279-
If the source file contains errors, appropriate error messages are
280-
written to the standard error stream, and the launcher exits with a
281-
non-zero exit code.
297+
If a source file contains errors, appropriate error messages are written
298+
to the standard error stream, and the launcher exits with a non-zero
299+
exit code.
282300
.PP
283301
\f[B]In source-file mode, execution proceeds as follows:\f[R]
284302
.IP \[bu] 2
285303
The class to be executed is the first top-level class found in the
286304
source file.
287-
It must contain a declaration of the standard
288-
\f[V]public static void main(String[])\f[R] method.
305+
It must contain a declaration of an entry \f[V]main\f[R] method.
289306
.IP \[bu] 2
290307
The compiled classes are loaded by a custom class loader, that delegates
291308
to the application class loader.
292309
This implies that classes appearing on the application class path cannot
293-
refer to any classes declared in the source file.
294-
.IP \[bu] 2
295-
The compiled classes are executed in the context of an unnamed module,
296-
as though \f[V]--add-modules=ALL-DEFAULT\f[R] is in effect.
310+
refer to any classes declared in source files.
311+
.IP \[bu] 2
312+
If a \f[V]module-info.java\f[R] file exists in the
313+
\f[V]<source-root>\f[R] directory, then all the classes compiled from
314+
\f[V].java\f[R] files in the source tree will be in that module, which
315+
will serve as the root module for the execution of the program.
316+
If \f[V]module-info.java\f[R] does not exist, the compiled classes are
317+
executed in the context of an unnamed module, as though
318+
\f[V]--add-modules=ALL-DEFAULT\f[R] is in effect.
297319
This is in addition to any other \f[V]--add-module\f[R] options that may
298320
be have been specified on the command line.
299321
.IP \[bu] 2
300322
Any arguments appearing after the name of the file on the command line
301-
are passed to the standard main method in the obvious way.
323+
are passed to the main method in the obvious way.
302324
.IP \[bu] 2
303325
It is an error if there is a class on the application class path whose
304326
name is the same as that of the class to be executed.
305327
.PP
306-
See \f[B]JEP 330: Launch Single-File Source-Code Programs\f[R]
307-
[https://openjdk.org/jeps/330] for complete details.
328+
See \f[B]JEP 458: Launch Multi-File Source-Code Programs\f[R]
329+
[https://openjdk.org/jeps/458] for complete details.
308330
.SH USING THE JDK_JAVA_OPTIONS LAUNCHER ENVIRONMENT VARIABLE
309331
.PP
310332
\f[V]JDK_JAVA_OPTIONS\f[R] prepends its content to the options parsed

src/java.base/share/man/keytool.1

Lines changed: 44 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,7 @@
3636
. ftr VB CB
3737
. ftr VBI CBI
3838
.\}
39-
.TH "KEYTOOL" "1" "2024" "JDK 22-ea" "JDK Commands"
39+
.TH "KEYTOOL" "1" "2024" "JDK 22" "JDK Commands"
4040
.hy
4141
.SH NAME
4242
.PP
@@ -452,17 +452,32 @@ The certificate chain and private key are stored in a new keystore entry
452452
that is identified by its alias.
453453
.PP
454454
The \f[V]-keyalg\f[R] value specifies the algorithm to be used to
455-
generate the key pair, and the \f[V]-keysize\f[R] value specifies the
456-
size of each key to be generated.
457-
The \f[V]-sigalg\f[R] value specifies the algorithm that should be used
458-
to sign the certificate.
459-
This algorithm must be compatible with the \f[V]-keyalg\f[R] value.
460-
.PP
455+
generate the key pair.
456+
The \f[V]-keysize\f[R] value specifies the size of each key to be
457+
generated.
461458
The \f[V]-groupname\f[R] value specifies the named group (for example,
462459
the standard or predefined name of an Elliptic Curve) of the key to be
463460
generated.
461+
.PP
462+
When a \f[V]-keysize\f[R] value is provided, it will be used to
463+
initialize a \f[V]KeyPairGenerator\f[R] object using the
464+
\f[V]initialize(int keysize)\f[R] method.
465+
When a \f[V]-groupname\f[R] value is provided, it will be used to
466+
initialize a \f[V]KeyPairGenerator\f[R] object using the
467+
\f[V]initialize(AlgorithmParameterSpec params)\f[R] method where
468+
\f[V]params\f[R] is \f[V]new NamedParameterSpec(groupname)\f[R].
469+
.PP
464470
Only one of \f[V]-groupname\f[R] and \f[V]-keysize\f[R] can be
465471
specified.
472+
If an algorithm has multiple named groups that have the same key size,
473+
the \f[V]-groupname\f[R] option should usually be used.
474+
In this case, if \f[V]-keysize\f[R] is specified, it\[aq]s up to the
475+
security provider to determine which named group is chosen when
476+
generating a key pair.
477+
.PP
478+
The \f[V]-sigalg\f[R] value specifies the algorithm that should be used
479+
to sign the certificate.
480+
This algorithm must be compatible with the \f[V]-keyalg\f[R] value.
466481
.PP
467482
The \f[V]-signer\f[R] value specifies the alias of a
468483
\f[V]PrivateKeyEntry\f[R] for the signer that already exists in the
@@ -1570,10 +1585,13 @@ The following examples show the defaults for various option values:
15701585
2048 (when using -genkeypair and -keyalg is \[dq]DSA\[dq])
15711586
3072 (when using -genkeypair and -keyalg is \[dq]RSA\[dq], \[dq]RSASSA-PSS\[dq], or \[dq]DH\[dq])
15721587
384 (when using -genkeypair and -keyalg is \[dq]EC\[dq])
1573-
255 (when using -genkeypair and -keyalg is \[dq]EdDSA\[dq], or \[dq]XDH)
15741588
56 (when using -genseckey and -keyalg is \[dq]DES\[dq])
15751589
168 (when using -genseckey and -keyalg is \[dq]DESede\[dq])
15761590

1591+
-groupname
1592+
ed25519 (when using -genkeypair and -keyalg is \[dq]EdDSA\[dq], key size is 255)
1593+
x25519 (when using -genkeypair and -keyalg is \[dq]XDH\[dq], key size is 255)
1594+
15771595
-validity 90
15781596

15791597
-keystore <the file named .keystore in the user\[aq]s home directory>
@@ -1604,7 +1622,7 @@ l l l.
16041622
T{
16051623
keyalg
16061624
T}@T{
1607-
keysize
1625+
key size
16081626
T}@T{
16091627
default sigalg
16101628
T}
@@ -1621,7 +1639,7 @@ RSA
16211639
T}@T{
16221640
< 624
16231641
T}@T{
1624-
SHA256withRSA (keysize is too small for using SHA-384)
1642+
SHA256withRSA (key size is too small for using SHA-384)
16251643
T}
16261644
T{
16271645
T}@T{
@@ -1653,7 +1671,7 @@ RSASSA-PSS
16531671
T}@T{
16541672
< 624
16551673
T}@T{
1656-
RSASSA-PSS (with SHA-256, keysize is too small for
1674+
RSASSA-PSS (with SHA-256, key size is too small for
16571675
T}
16581676
T{
16591677
T}@T{
@@ -1701,28 +1719,29 @@ Ed448
17011719
T}
17021720
.TE
17031721
.IP \[bu] 2
1722+
The key size, measured in bits, corresponds to the size of the private
1723+
key.
1724+
This size is determined by the value of the \f[V]-keysize\f[R] or
1725+
\f[V]-groupname\f[R] options or the value derived from a default
1726+
setting.
1727+
.IP \[bu] 2
17041728
An RSASSA-PSS signature algorithm uses a \f[V]MessageDigest\f[R]
17051729
algorithm as its hash and MGF1 algorithms.
17061730
.IP \[bu] 2
1707-
EdDSA supports 2 key sizes: Ed25519 and Ed448.
1708-
When generating an EdDSA key pair using \f[V]-keyalg EdDSA\f[R], a user
1709-
can specify \f[V]-keysize 255\f[R] or \f[V]-keysize 448\f[R] to generate
1710-
Ed25519 or Ed448 key pairs.
1711-
When no \f[V]-keysize\f[R] is specified, an Ed25519 key pair is
1712-
generated.
1713-
A user can also directly specify \f[V]-keyalg Ed25519\f[R] or
1714-
\f[V]-keyalg Ed448\f[R] to generate a key pair with the expected key
1715-
size.
1731+
If neither a default \f[V]-keysize\f[R] or \f[V]-groupname\f[R] is
1732+
defined for an algorithm, the security provider will choose a default
1733+
setting.
17161734
.PP
17171735
\f[B]Note:\f[R]
17181736
.PP
1719-
To improve out of the box security, default key size and signature
1720-
algorithm names are periodically updated to stronger values with each
1721-
release of the JDK.
1737+
To improve out of the box security, default keysize, groupname, and
1738+
signature algorithm names are periodically updated to stronger values
1739+
with each release of the JDK.
17221740
If interoperability with older releases of the JDK is important, make
17231741
sure that the defaults are supported by those releases.
1724-
Alternatively, you can use the \f[V]-keysize\f[R] or \f[V]-sigalg\f[R]
1725-
options to override the default values at your own risk.
1742+
Alternatively, you can use the \f[V]-keysize\f[R], \f[V]-groupname\f[R],
1743+
or \f[V]-sigalg\f[R] options to override the default values at your own
1744+
risk.
17261745
.SH SUPPORTED NAMED EXTENSIONS
17271746
.PP
17281747
The \f[V]keytool\f[R] command supports these named extensions.

0 commit comments

Comments
 (0)