@@ -258,21 +258,27 @@ public boolean isAnonymousOrLocal(ClassEntry classEntry) {
258
258
* @param parameter the parameter to validate
259
259
* @return whether the index is valid
260
260
*/
261
+ @ SuppressWarnings ("DataFlowIssue" )
261
262
public boolean validateParameterIndex (LocalVariableEntry parameter ) {
262
263
MethodEntry parent = parameter .getParent ();
263
264
EntryIndex index = this .jarIndex .getIndex (EntryIndex .class );
264
265
265
266
if (index .hasMethod (parent )) {
266
267
AtomicInteger maxLocals = new AtomicInteger (-1 );
267
- ClassEntry parentClass = parent != null ? parent .getParent () : null ;
268
+ ClassEntry parentClass = parent .getParent ();
268
269
269
270
// find max_locals for method, representing the number of parameters it receives (JVMS§4.7.3)
270
271
// note: parent class cannot be null, warning suppressed
271
272
ClassNode classNode = this .getClassProvider ().get (parentClass .getFullName ());
272
273
if (classNode != null ) {
273
274
classNode .methods .stream ()
274
275
.filter (node -> node .name .equals (parent .getName ()) && node .desc .equals (parent .getDesc ().toString ()))
275
- .findFirst ().ifPresent (node -> maxLocals .set (node .maxLocals ));
276
+ .findFirst ().ifPresent (node -> {
277
+ // occasionally it's possible to run into a method that has parameters, yet whose max locals is 0. java is stupid. we ignore those cases
278
+ if (node .parameters .size () <= node .maxLocals ) {
279
+ maxLocals .set (node .maxLocals );
280
+ }
281
+ });
276
282
}
277
283
278
284
// if maxLocals is -1 it's not found for the method and should be ignored
0 commit comments