RFR: 8354556: Expand value-based class warnings to java.lang.ref API [v4]
Yudi Zheng
yzheng at openjdk.org
Mon May 5 09:42:47 UTC 2025
On Fri, 2 May 2025 19:44:31 GMT, Vicente Romero <vromero at openjdk.org> wrote:
>> This PR is defining a new internal annotation, `@jdk.internal.RequiresIdentity`, with target types PARAMETER and TYPE_PARAMETER. The @RequiresIdentity annotation expresses the expectation that an argument to a given method or constructor parameter will be an object with a unique identity, not an instance of a value-based class; or that the type argument to a given type parameter will not be a value-based class type.
>>
>> For more details please refer to the complete description in the corresponding JIRA entry [1]
>>
>> TIA
>>
>> [1] https://bugs.openjdk.org/browse/JDK-8354556
>
> Vicente Romero has updated the pull request incrementally with one additional commit since the last revision:
>
> changes to test
src/jdk.compiler/share/classes/com/sun/tools/javac/code/Type.java line 669:
> 667:
> 668: public boolean isValueBased() {
> 669: return (tsym.flags_field & VALUE_BASED) != 0;
We have encountered a NPE in javac:
java.lang.NullPointerException: Cannot read field "flags_field" because "this.tsym" is null
at jdk.compiler/com.sun.tools.javac.code.Type.isValueBased(Type.java:669)
at jdk.compiler/com.sun.tools.javac.comp.Check.checkRequiresIdentity(Check.java:5739)
at jdk.compiler/com.sun.tools.javac.comp.Attr.visitNewClass(Attr.java:2918)
at jdk.compiler/com.sun.tools.javac.tree.JCTree$JCNewClass.accept(JCTree.java:1915)
...
It looks like `tsym` can be null https://github.com/openjdk/jdk/blob/60f1f53b18d065f110936e71b7430d7e365881d4/src/jdk.compiler/share/classes/com/sun/tools/javac/code/Type.java#L517-L519
-------------
PR Review Comment: https://git.openjdk.org/jdk/pull/24746#discussion_r2073144717
More information about the core-libs-dev
mailing list