RFR: 8236987: Remove call to System.out.println from ImageIcon.loadImage [v14]

Prasanta Sadhukhan psadhukhan at openjdk.java.net
Fri Apr 8 11:22:39 UTC 2022


On Fri, 8 Apr 2022 10:10:09 GMT, Alexey Ivanov <aivanov at openjdk.org> wrote:

>> test/jdk/javax/swing/ImageIcon/LoadInterruptTest.java line 61:
>> 
>>> 59:         prevSysOut = System.out;
>>> 60:         testOut = new ByteArrayOutputStream();
>>> 61:         System.setOut(new PrintStream(testOut, true, StandardCharsets.UTF_8));
>> 
>> The spec says "First, if there is a security manager, its checkPermission method is called with a RuntimePermission("setIO") permission to see if it's ok to reassign the "standard" output stream."
>> 
>> Since security manager is removed, I guess either this doc needs updation or we still need to follow this checkPermission step...
>
> What are you referring to?
> 
> The javadoc to [`System.setOut`](https://docs.oracle.com/en/java/javase/17/docs/api/java.base/java/lang/System.html#setOut(java.io.PrintStream)) does indeed state this. [The implementation](https://github.com/openjdk/jdk/blob/4dbebb62aa264adda8d96a06f608ef9d13155a26/src/java.base/share/classes/java/lang/System.java#L244) does exactly what it says: it calls `checkIO` method which verifies whether `"setIO"` permission is granted if `SecurityManager` is installed.
> 
> I can't see what we should do about it. `SecurityManager` hasn't been removed yet.

Yeah, right..I was thinking something else..

-------------

PR: https://git.openjdk.java.net/jdk/pull/7754



More information about the client-libs-dev mailing list