RFR: 8317356: Test ClassFile API if it deals with nulls correctly across the whole API [v3]

Chen Liang liach at openjdk.org
Fri Sep 6 13:42:53 UTC 2024


On Fri, 6 Sep 2024 12:40:15 GMT, Nizar Benalla <nbenalla at openjdk.org> wrote:

>> src/java.base/share/classes/java/lang/classfile/AnnotationValue.java line 681:
>> 
>>> 679:      */
>>> 680:     static AnnotationValue of(Object value) {
>>> 681:         requireNonNull(value);
>> 
>> Below is a null test throwing IAE.
>
> The test fails if the method does not throw an exception or throws anything other than a NPE. That's why I added `requireNonNull` here.
> 
> What exceptions would be considered ok when nulls are provided?

I think we should prefer NPE instead of IAE for null inputs.

I think we should just remove this method - the format for composite list/array or annotation is not well-defined. We might replace this with a `ofResolvedConstant` to accept primitives and String.

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

PR Review Comment: https://git.openjdk.org/jdk/pull/20556#discussion_r1747146758


More information about the compiler-dev mailing list