mvel/mvel — pull request #35 by mariofusco (2011-10-21 10:14:06+00:00)
Title: Avoid RuntimeException when evaluating an expression with an unused import

When evaluating an expression llike:

import java.util.*; name == "Mario";

a RuntimeException is thrown. That's because MVEL correctly recognizes that there isn't any import actually required (the flag importInjectionRequired in the CompiledExpression is set to false) and then uses an ImmutableDefaultFactory. The problem is that, when the import token is parsed, it tries to call setNextFactory on that Immutable one, resulting in the RuntimeException mentioned above.

Note indeed that both the following expressions are evaluated correctly;

import java.util.*; new ArrayList(); name == "Mario";
import java.util.ArrayList; name == "Mario";