RFR: 8301578: Perform output outside synchronization in Module.class [v4]

Alan Bateman alanb at openjdk.org
Fri Feb 10 08:56:48 UTC 2023


On Thu, 9 Feb 2023 16:27:34 GMT, Per Minborg <pminborg at openjdk.org> wrote:

>> src/java.base/share/classes/java/lang/Module.java line 120:
>> 
>>> 118:     // memory semantics that preserves ordering and visibility across threads.
>>> 119:     //
>>> 120:     // Used reflectively via Unsafe
>> 
>> I assume L119-120 can be removed.
>
> The reson for the L119-120 comments is to make it easier to understand why we are declaring a variable that does not appear to be used. But maybe there is a better way to do that?

The comment at L117-118 already explains that it's accessed with Unsafe so I don't think we need any more than that. The IDE may suggest the field is unused but if anyone removes it then it will break the JDK build/startup. Same thing many other areas where Unsafe or VarHandles are used. So I don't think we should be too concerned about and the comments at L116-118 are more than enough.

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

PR: https://git.openjdk.org/jdk/pull/12193


More information about the core-libs-dev mailing list