RFR: 8349944: [JMH] sun.misc.UnsafeOps cannot access class jdk.internal.misc.Unsafe [v2]
Chen Liang
liach at openjdk.org
Thu Feb 27 04:36:52 UTC 2025
On Wed, 26 Feb 2025 12:13:59 GMT, Liam Miller-Cushon <cushon at openjdk.org> wrote:
>> Nicole Xu has updated the pull request incrementally with two additional commits since the last revision:
>>
>> - 8349944: [JMH] sun.misc.UnsafeOps cannot access class jdk.internal.misc.Unsafe
>>
>> The UnsafeOps JMH benchmark fails with the following error:
>>
>> ```
>> java.lang.IllegalAccessError: class org.openjdk.bench.sun.misc.UnsafeOps (in unnamed module @0x520a3426) cannot access class jdk.internal.misc.Unsafe (in module java.base) because module java.base does not export jdk.internal.misc to unnamed module @0x520a3426
>> ```
>>
>> Since this micro-benchmark is created for `sun.misc.Unsafe` rather than
>> `jdk.internal.misc.Unsafe`, we change it back as before JDK-8332744.
>>
>> Note that even it will raise "proprietary API" warnings after this
>> patch, it is acceptable because the relevant APIs are bound for removal
>> for the integrity of the platform.
>>
>> Change-Id: Ia7c57c2ca09af4b2b3c6cc10ef4ae5a9f3c38a4c
>> - Revert "8349944: [JMH] sun.misc.UnsafeOps cannot access class jdk.internal.misc.Unsafe"
>>
>> This reverts commit ebc32ae2c6e448075fedbdbb2b4879c43829c44b.
>
> Would it be possible to configure the build of the microbenchmarks to not pass `-Werror`, so they don't break when sunapi diagnostics are emitted?
>
>> Note that even it will raise "proprietary API" warnings after this patch, it is acceptable because the relevant APIs are bound for removal for the integrity of the platform.
>
> It will not raise those diagnostics today, because they don't work for this compilation due to [JDK-8349846](https://bugs.openjdk.org/browse/JDK-8349846). If that issue is fixed again it would break the build of these benchmarks, e.g. with 1ab1c1d53b86228be85aac96fa5d69db39ac6317 backed out and with this change it would fail with:
>
>
> test/micro/org/openjdk/bench/sun/misc/UnsafeOps.java:27: warning: Unsafe is internal proprietary API and may be removed in a future release
> import sun.misc.Unsafe;
> ^
> ...
> error: warnings found and -Werror specified
Hi @cushon, I believe disabling `JAVA_WARNINGS_ARE_ERRORS` should be done as part of those javac patches instead of part of this patch. We cannot verify such an addition in this patch, and it will just cause meaningless extra review and update cycles.
This flag is defined at https://github.com/openjdk/jdk/blob/964dd18fd2ba998e5c1efed48e15e516b0c22b19/make/common/JavaCompilation.gmk#L268. Unfortunately I don't know about make well enough to say what's the best way to disable this for micro build.
-------------
PR Comment: https://git.openjdk.org/jdk/pull/23686#issuecomment-2686877434
More information about the core-libs-dev
mailing list