groovy-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Jochen Theodorou <blackd...@gmx.org>
Subject Re: @CompileStatic null iteration
Date Fri, 15 Dec 2017 15:34:41 GMT

Am 15.12.2017 um 14:35 schrieb Winnebeck, Jason:
> It’s been like this for as long as I’ve been using compile static in 
> Groovy. I assumed that was expected behavior and I make sure to point it 
> out to all new developers in our project as one of the Groovy gotchas. 
> Is it not supposed to be that way?

Afaik it is supposed to be this way for technical reasons

Not failing invocation on null means to not be able to use direct method 
calls in static compiled code. And while they do not have to be as 
dynamic as in standard Groovy, you would have to make them at least with 
invokedynamic. And that is because if I tell the JVM to invoke 
String#length(), it does not like to get NullObject instead of a String.

in summary:
If we want to keep static Groovy near Java as much as possible, we pay 
this for example with the NPE here.

bye Jochen

Mime
View raw message