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

Alexey Ivanov aivanov at openjdk.java.net
Fri Apr 8 10:13:51 UTC 2022


On Fri, 8 Apr 2022 09:00:53 GMT, Prasanta Sadhukhan <psadhukhan at openjdk.org> wrote:

>> Tejesh R has updated the pull request incrementally with one additional commit since the last revision:
>> 
>>   Updated based on Review Comments
>
> 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.

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

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



More information about the client-libs-dev mailing list