You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
We should be able to leverage inheritance when writing models for librarys. E.g., Collections.toArray(T[]) is specified to throw an NPE whenever the parameter is null. Right now, we need to add a model for Collections.toArray, ArrayDeque.toArray, LinkedList.toArray, etc. to get full safety. It'd be nice to just add a model for Collections.toArray and then catch this for any overriding method. Would need to be careful about performance when implementing this.
@msridhar we are seeing the word performance thrown around a lot during many tickets failed against nullaway, but we dont seem to have a concrete way to measure this. Can we setup a profiling sample using jmh in this repo that can we run as part of travis and give us numbers on what the performance change looks like on PRs? or atleast a way for us to run manually?
Parameter models (nonNullParameters, explicitlyNullableParameters, failIfNullParameters, nullImpliesTrueParameters, nullImpliesFalseParameters, castToNonNullMethods) still match only the exact method, so the Collection.toArray(T[]) example from the description still needs the separate ArrayDeque.toArray(T[]) model added in Add models for java.util.Deque methods #86.
With JSpecify mode and the JSpecify JDK models (JSpecifyJDKModels, on by default with JSpecifyExperimental), linkedList.toArray(nullArray) is reported, because those models annotate the parameter on LinkedList and ArrayList themselves. Without them, it is not reported.
Should this issue stay open for the parameter models, or is the JSpecify JDK models coverage enough to close it? If it stays open, the question for the parameter models is the same one #445 settled for return models: whether an inherited model may apply to an overriding method that is annotated.
Flags: -XepOpt:NullAway:AnnotatedPackages=com.uber (standard mode). The same source is not reported with -XepOpt:NullAway:JSpecifyMode=true -XDaddTypeAnnotationsToSymbol=true -XepOpt:NullAway:JSpecifyExperimental=true -XepOpt:NullAway:JSpecifyJDKModels=false, and is reported when JSpecifyJDKModels is left on.
The same call through Collection<String> or ArrayDeque<String> is reported, because both have exact models. l.toArray(null) does not compile on JDK 11 and later (ambiguous with toArray(IntFunction)), hence the local.
Activity
Add models for java.util.Deque methods (#86)
kageiit commentedon Dec 18, 2017
@msridhar we are seeing the word performance thrown around a lot during many tickets failed against nullaway, but we dont seem to have a concrete way to measure this. Can we setup a profiling sample using jmh in this repo that can we run as part of travis and give us numbers on what the performance change looks like on PRs? or atleast a way for us to run manually?
msridhar commentedon Dec 18, 2017
@kageiit opened #87 on benchmarking / profiling. Not sure we can trust numbers from Travis, but at least for running locally it should be useful.
vlsi commentedon Oct 22, 2026
Triage update on current master (5023d67): this is still open for parameter models, and done for other kinds of models.
nonNullReturns,nullableReturns) already apply to overriding methods when the overriding method is unannotated; for an annotated one, the exact signature is required (Nullness of Throwable.getMessage() cannot be overridden in subclasses #445).nullImpliesNullParametersmodels apply to overriding methods since Inherit null-implies-null models across overrides #1758 (released in 0.14.1).nonNullParameters,explicitlyNullableParameters,failIfNullParameters,nullImpliesTrueParameters,nullImpliesFalseParameters,castToNonNullMethods) still match only the exact method, so theCollection.toArray(T[])example from the description still needs the separateArrayDeque.toArray(T[])model added in Add models for java.util.Deque methods #86.With JSpecify mode and the JSpecify JDK models (
JSpecifyJDKModels, on by default withJSpecifyExperimental),linkedList.toArray(nullArray)is reported, because those models annotate the parameter onLinkedListandArrayListthemselves. Without them, it is not reported.Should this issue stay open for the parameter models, or is the JSpecify JDK models coverage enough to close it? If it stays open, the question for the parameter models is the same one #445 settled for return models: whether an inherited model may apply to an overriding method that is annotated.
Reproducer (NullAway 5023d67, JDK 21)
Flags:
-XepOpt:NullAway:AnnotatedPackages=com.uber(standard mode). The same source is not reported with-XepOpt:NullAway:JSpecifyMode=true -XDaddTypeAnnotationsToSymbol=true -XepOpt:NullAway:JSpecifyExperimental=true -XepOpt:NullAway:JSpecifyJDKModels=false, and is reported whenJSpecifyJDKModelsis left on.The same call through
Collection<String>orArrayDeque<String>is reported, because both have exact models.l.toArray(null)does not compile on JDK 11 and later (ambiguous withtoArray(IntFunction)), hence the local.