-
Notifications
You must be signed in to change notification settings - Fork 177
Description
In the class org.antlr.tool.CompositeGrammar, in the method getIndirectDelegates, there is a call to java.util.ArrayList.removeAll with an argument that might be null.
In Java 7, this can sometimes be okay: ArrayList.removeAll(null) is a no-op if the list you are removing from is empty. But starting with Java 8, it's never okay: ArrayList.removeAll(null) will always throw NullPointerException. When I upgraded my build to use Java 8, it started failing with this NPE.
I suggest that a check should be added to getIndirectDelegates so that the call to removeAll (line 226, in the source I'm seeing) only happens if direct is not null. And, for that matter, if delegates is also not null.
I get this in antlr versions 3.2 and 3.5.1.
Here's a partial stack trace:
java.lang.NullPointerException
at java.util.Objects.requireNonNull(Objects.java:203)
at java.util.ArrayList.removeAll(ArrayList.java:674)
at org.antlr.tool.CompositeGrammar.getIndirectDelegates(CompositeGrammar.java:226)
at org.antlr.tool.Grammar.getIndirectDelegates(Grammar.java:2722)