New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

@NotNull annotations should introduce a null check #344

Closed
lombokissues opened this Issue Jul 14, 2015 · 7 comments

Comments

Projects
None yet
1 participant
@lombokissues
Collaborator

lombokissues commented Jul 14, 2015

Migrated from Google Code (issue 271)

@lombokissues

This comment has been minimized.

Show comment
Hide comment
@lombokissues

lombokissues Jul 14, 2015

Collaborator

👤 anthony@whitford.com   🕗 Sep 05, 2011 at 17:28 UTC

Consider the attached code.
It has a @ NotNull annotation on a field member, and the documentation says that delombok will add null checks -- but it does not.

Also note that lombok.NonNull will add the null checks, but the lombok.NonNull annotation is not being removed.

@ java.lang.SuppressWarnings("all")
public void setDataOne(@ NonNull final String dataOne) {
    if (dataOne == null) throw new java.lang.NullPointerException("dataOne");
    this.dataOne = dataOne;
}

@ java.lang.SuppressWarnings("all")
public void setDataTwo(final String dataTwo) {
    this.dataTwo = dataTwo;
}

I am using Java 6 and have witnessed this on Windows and Mac.
I am using Lombok 0.10.0.

Collaborator

lombokissues commented Jul 14, 2015

👤 anthony@whitford.com   🕗 Sep 05, 2011 at 17:28 UTC

Consider the attached code.
It has a @ NotNull annotation on a field member, and the documentation says that delombok will add null checks -- but it does not.

Also note that lombok.NonNull will add the null checks, but the lombok.NonNull annotation is not being removed.

@ java.lang.SuppressWarnings("all")
public void setDataOne(@ NonNull final String dataOne) {
    if (dataOne == null) throw new java.lang.NullPointerException("dataOne");
    this.dataOne = dataOne;
}

@ java.lang.SuppressWarnings("all")
public void setDataTwo(final String dataTwo) {
    this.dataTwo = dataTwo;
}

I am using Java 6 and have witnessed this on Windows and Mac.
I am using Lombok 0.10.0.

@lombokissues

This comment has been minimized.

Show comment
Hide comment
@lombokissues

lombokissues Jul 14, 2015

Collaborator

👤 anthony@whitford.com   🕗 Sep 05, 2011 at 17:28 UTC

🔗 NullDataExample.java View file

Collaborator

lombokissues commented Jul 14, 2015

👤 anthony@whitford.com   🕗 Sep 05, 2011 at 17:28 UTC

🔗 NullDataExample.java View file

@lombokissues

This comment has been minimized.

Show comment
Hide comment
@lombokissues

lombokissues Jul 14, 2015

Collaborator

👤 pe.fips   🕗 Sep 05, 2011 at 17:30 UTC

Issue #343 has been merged into this issue.

Collaborator

lombokissues commented Jul 14, 2015

👤 pe.fips   🕗 Sep 05, 2011 at 17:30 UTC

Issue #343 has been merged into this issue.

@lombokissues

This comment has been minimized.

Show comment
Hide comment
@lombokissues

lombokissues Jul 14, 2015

Collaborator

👤 anthony@whitford.com   🕗 Sep 05, 2011 at 17:32 UTC

BTW... I made a comment about the lombok.NonNull annotation not being removed here:
issue #219
Once 271 is solved, perhaps 146 is solved too.

Collaborator

lombokissues commented Jul 14, 2015

👤 anthony@whitford.com   🕗 Sep 05, 2011 at 17:32 UTC

BTW... I made a comment about the lombok.NonNull annotation not being removed here:
issue #219
Once 271 is solved, perhaps 146 is solved too.

@lombokissues

This comment has been minimized.

Show comment
Hide comment
@lombokissues

lombokissues Jul 14, 2015

Collaborator

👤 pe.fips   🕗 Sep 05, 2011 at 17:52 UTC

This issue will only cover the support of @ NotNull.
You can follow the progress of delombok part in ﹟146.

Furthermore we should fix a small inconsistency in the documentation:

"@ Data" states that @ NonNull and @ NotNull will create null checks, while "@ Getter and @ Setter" only states @ NonNull.

Collaborator

lombokissues commented Jul 14, 2015

👤 pe.fips   🕗 Sep 05, 2011 at 17:52 UTC

This issue will only cover the support of @ NotNull.
You can follow the progress of delombok part in ﹟146.

Furthermore we should fix a small inconsistency in the documentation:

"@ Data" states that @ NonNull and @ NotNull will create null checks, while "@ Getter and @ Setter" only states @ NonNull.

@lombokissues

This comment has been minimized.

Show comment
Hide comment
@lombokissues

lombokissues Jul 14, 2015

Collaborator

👤 pe.fips   🕗 Sep 05, 2011 at 19:59 UTC

fixed with commit:
236c88f

Collaborator

lombokissues commented Jul 14, 2015

👤 pe.fips   🕗 Sep 05, 2011 at 19:59 UTC

fixed with commit:
236c88f

@lombokissues

This comment has been minimized.

Show comment
Hide comment
@lombokissues

lombokissues Jul 14, 2015

Collaborator

End of migration

Collaborator

lombokissues commented Jul 14, 2015

End of migration

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment