Skip to content

Commit db1e44c

Browse files
rjernstChrisHegarty
authored andcommitted
8290353: ModuleReader::list specification should suggest closing the returned stream
Reviewed-by: chegar, mchung, mr, jpai
1 parent 2c73a1f commit db1e44c

File tree

1 file changed

+9
-1
lines changed

1 file changed

+9
-1
lines changed

src/java.base/share/classes/java/lang/module/ModuleReader.java

+9-1
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright (c) 2015, 2020, Oracle and/or its affiliates. All rights reserved.
2+
* Copyright (c) 2015, 2022, Oracle and/or its affiliates. All rights reserved.
33
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
44
*
55
* This code is free software; you can redistribute it and/or modify it
@@ -213,9 +213,17 @@ default void release(ByteBuffer bb) {
213213
* when using the stream to list the module contents and access is denied
214214
* by the security manager. </p>
215215
*
216+
* <p> The returned stream may contain references to one or more open directories
217+
* in the module. The directories are closed by closing the stream. </p>
218+
*
216219
* <p> The behavior of the stream when used after the module reader is
217220
* closed is implementation specific and therefore not specified. </p>
218221
*
222+
* @apiNote
223+
* This method should be used within a try-with-resources statement or similar
224+
* control structure to ensure that any open directories referenced by the
225+
* stream are closed promptly after the stream's operations have completed.
226+
*
219227
* @return A stream of elements that are the names of all resources
220228
* in the module
221229
*

0 commit comments

Comments
 (0)