[stringtemplate-interest] [ST4-Beta2] NullPointerException in Interpreter.storeArgs

Udo Borkowski ub at abego-software.de
Mon Jan 24 03:29:26 PST 2011


A NPE may occur in void storeArgs(ST self, Map<String,Object> attrs, ST st).

formalArguments in

if ( !st.impl.formalArguments.containsKey(argName) ) {
	errMgr.runTimeError(self,
				current_ip,
				ErrorType.NO_SUCH_ATTRIBUTE,
				argName);
	continue;
}

may be null, thus generating the NPE.



Possible fix:

if ( st.impl.formalArguments == null || !st.impl.formalArguments.containsKey(argName) ) {
	errMgr.runTimeError(self,
				current_ip,
				ErrorType.NO_SUCH_ATTRIBUTE,
				argName);
	continue;
}


Udo

P.S.: This (invalid) definition will generate the NPE:

main(p) ::= <<
<f(x="abc")>
>>

f(x) ::= <<
<x
>>

-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://www.antlr.org/pipermail/stringtemplate-interest/attachments/20110124/5e25130e/attachment.html 


More information about the stringtemplate-interest mailing list