RFR: 7904028: jcstress: Address s.m.Unsafe use warnings which fail build on JDK 23+ [v2]

Pavel Rappo prappo at openjdk.org
Thu Jun 19 09:37:36 UTC 2025


On Thu, 19 Jun 2025 09:20:01 GMT, Aleksey Shipilev <shade at openjdk.org> wrote:

> It is not very clear why sometimes we do `@SuppressWarnings` on the class, and sometimes on the fields/methods. I think doing all annotations on class-level is clean enough. Your call, though.

IIRC, `@SuppressWarnings` can be applied only in certain contexts. Sometimes the least broad context if the class.

For example, these are declarations to which the annotation is applicable:

 *     @SuppressWarnings("removal")
       public static final long ARRAY_BASE_OFFSET = UNSAFE.arrayBaseOffset(byte[].class);

 *     @Actor
       public void actor2(BBBB_Result r) {
           @SuppressWarnings("removal")
           int t = UNSAFE.getInt(bytes, offset);

 *     @SuppressWarnings("removal")
       @Actor
       public void actor1() {
 
This is a declaration to which it is __NOT__ applicable:

 *     static {
           try {
               offset = UNSAFE.objectFieldOffset(UnsafeBusyLoopTest.class.getDeclaredField("isStopped"));
           } catch (NoSuchFieldException e) {
               throw new IllegalStateException(e);
           }
       }

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

PR Comment: https://git.openjdk.org/jcstress/pull/165#issuecomment-2987413183


More information about the jcstress-dev mailing list