Details
-
Bug
-
Status: Closed
-
Major
-
Resolution: Fixed
-
2.1.6
-
None
Description
Using the @CompileStatic annotation with @Canonical, and having an integer property creates a null pointer opportunity in the generated hashCode method -
it decompiles to this:
public int hashCode()
{
int _result = HashCodeHelper.initHash();
int _tmp = _result;
if(!DefaultGroovyMethods.is(getName(), this))
if(!DefaultGroovyMethods.is(getSomeNum(), this))
{ int j = HashCodeHelper.updateHash(_result, getSomeNum().intValue()); _result = j; int _tmp2 = j; } return _result;
}
Note the intValue being called without checking to see if the getter returns null.