@@ -154,9 +154,9 @@ abstract class ForLoadedExecutable<T> extends AbstractBase<ParameterDescription.
154
154
protected final ParameterDescription .ForLoadedParameter .ParameterAnnotationSource parameterAnnotationSource ;
155
155
156
156
/**
157
- * The number of parameters of this executable, or -1, if the size was not yet computed. This avoids recomputation
158
- * what can lead to an unreasonable performance impact if placed on a hot execution path. This field is not
159
- * volatile as the result is stable and can be recomputed from different threads.
157
+ * The number of parameters of this executable, 0 if the size was not yet computed, or -1 if the list is empty.
158
+ * This avoids recomputation what can lead to an unreasonable performance impact if placed on a hot execution
159
+ * path. This field is not volatile as the result is stable and can be recomputed from different threads.
160
160
*/
161
161
private int size ;
162
162
@@ -169,7 +169,6 @@ abstract class ForLoadedExecutable<T> extends AbstractBase<ParameterDescription.
169
169
protected ForLoadedExecutable (T executable , ParameterDescription .ForLoadedParameter .ParameterAnnotationSource parameterAnnotationSource ) {
170
170
this .executable = executable ;
171
171
this .parameterAnnotationSource = parameterAnnotationSource ;
172
- size = -1 ;
173
172
}
174
173
175
174
/**
@@ -236,10 +235,11 @@ public static ParameterList<ParameterDescription.InDefinedShape> of(Method metho
236
235
* {@inheritDoc}
237
236
*/
238
237
public int size () {
239
- if (size == -1 ) {
240
- size = EXECUTABLE .getParameterCount (executable );
238
+ if (size == 0 ) {
239
+ int size = EXECUTABLE .getParameterCount (executable );
240
+ this .size = size == 0 ? -1 : size ;
241
241
}
242
- return size ;
242
+ return size == - 1 ? 0 : size ;
243
243
}
244
244
245
245
/**
@@ -584,9 +584,9 @@ class TypeSubstituting extends AbstractBase<ParameterDescription.InGenericShape>
584
584
private final TypeDescription .Generic .Visitor <? extends TypeDescription .Generic > visitor ;
585
585
586
586
/**
587
- * The number of parameters of this executable, or -1, if the size was not yet computed. This avoids recomputation
588
- * what can lead to an unreasonable performance impact if placed on a hot execution path. This field is not
589
- * volatile as the result is stable and can be recomputed from different threads.
587
+ * The number of parameters of this executable, 0 if the size was not yet computed, or -1 if the list is empty.
588
+ * This avoids recomputation what can lead to an unreasonable performance impact if placed on a hot execution
589
+ * path. This field is not volatile as the result is stable and can be recomputed from different threads.
590
590
*/
591
591
private int size ;
592
592
@@ -603,7 +603,6 @@ public TypeSubstituting(MethodDescription.InGenericShape declaringMethod,
603
603
this .declaringMethod = declaringMethod ;
604
604
this .parameterDescriptions = parameterDescriptions ;
605
605
this .visitor = visitor ;
606
- size = -1 ;
607
606
}
608
607
609
608
/**
@@ -617,10 +616,11 @@ public ParameterDescription.InGenericShape get(int index) {
617
616
* {@inheritDoc}
618
617
*/
619
618
public int size () {
620
- if (size == -1 ) {
621
- size = parameterDescriptions .size ();
619
+ if (size == 0 ) {
620
+ int size = parameterDescriptions .size ();
621
+ this .size = size == 0 ? -1 : size ;
622
622
}
623
- return size ;
623
+ return size == - 1 ? 0 : size ;
624
624
}
625
625
}
626
626
0 commit comments