eclipse-jdt / eclipse-jdt/eclipse.jdt.core
[feat] Add support for polymorphic external null annotations
- Dominant language
- Java
- Stars
- 237
- Forks
- 195
- Avg merge
- 1d 12h
- Merged PRs (30d)
- 47
Description
This is a follow-up issue to https://bugs.eclipse.org/bugs/show_bug.cgi?id=575822
I am looking for a way to declare the nullability of a return value depending on nullability of one (or possibly more) input values. This is an example from commons-lang3 StringUtils:
```java
public static String join(final boolean[] array, final char delimiter) {
if (array == null) {
return null;
}
return join(array, delimiter, 0, array.length);
}
```
As suggested in https://bugs.eclipse.org/bugs/show_bug.cgi?id=575822, it would be great to make it work by being able to specify something like:
```java
join
([ZC)Ljava/lang/String;
([0ZC)L0java/lang/String;
([1ZC)L1java/lang/String;
```
---
This would also be great for the **java.util.Optional** class:
```java
Optional opt = ...
@Nullable String result1 = opt.orElse(null);
@NonNull String result2 = opt.orElse("else");
```
when one could specify these EEAs:
```java
orElse
(TT;)TT;
(T0T;)T0T;
(T1T;)T1T;
```
Contributor guide
Assessment
This issue has not been assessed yet.