Bug 525512 - [null] @NonNullByDefault meta annotation
Summary: [null] @NonNullByDefault meta annotation
Status: NEW
Alias: None
Product: JDT
Classification: Eclipse Project
Component: Core (show other bugs)
Version: 4.8   Edit
Hardware: PC Linux
: P3 enhancement (vote)
Target Milestone: ---   Edit
Assignee: JDT-Core-Inbox CLA
QA Contact:
URL:
Whiteboard:
Keywords:
Depends on:
Blocks:
 
Reported: 2017-10-03 10:32 EDT by Michael Vorburger CLA
Modified: 2020-06-04 11:16 EDT (History)
0 users

See Also:


Attachments
FullNonNullByDefault.java example to illustrate the idea proposed here (1.42 KB, text/x-java)
2017-10-03 10:32 EDT, Michael Vorburger CLA
no flags Details

Note You need to log in before you can comment on or make changes to this bug.
Description Michael Vorburger CLA 2017-10-03 10:32:14 EDT
Created attachment 270805 [details]
FullNonNullByDefault.java example to illustrate the idea proposed here

This is a (certainly low priority) enhancement suggestion, not a bug:

In an ideal world, once more pressing things are taken care of, it would be nice if @NonNullByDefault would support "meta annotations".  

A "meta annotation" is not a core Java language feature, but a convention which has gained widespread use, e.g. in the popular Spring Framework and others or in something like http://immutables.org; see their documentation about this here: http://immutables.github.io/style.html#custom-immutable-annotation

Attached is an FullNonNullByDefault.java example for how I would imagine something like this would look like, which one could us instead of having to repeat the long list of all DefaultLocation (because TYPE_PARAMETER & ARRAY_CONTENTS are not includd by default) in every bloody package-info.java:

// Add TYPE_PARAMETER & ARRAY_CONTENTS to NonNullByDefault value() default:
@NonNullByDefault({ PARAMETER, RETURN_TYPE, FIELD, TYPE_PARAMETER, TYPE_BOUND, TYPE_ARGUMENT, ARRAY_CONTENTS })
public @interface FullNonNullByDefault {
    // nothing here, the point of this is above
}
Comment 1 Till Brychcy CLA 2017-10-03 14:43:48 EDT
Bug 518839 sounds a bit related. In case one of them is implemented, the other one shouldn't be too hard.
Comment 2 Till Brychcy CLA 2018-02-26 15:34:51 EST
I think this is not needed, you can simply define secondary NonNullByDefault-annotations with different default values.