[ https://issues.apache.org/jira/browse/GROOVY-7518?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ]
Pascal Schumacher closed GROOVY-7518. ------------------------------------- > hashCode() throws NPE when using @CompileStatic with @EqualsAndHashCode > ----------------------------------------------------------------------- > > Key: GROOVY-7518 > URL: https://issues.apache.org/jira/browse/GROOVY-7518 > Project: Groovy > Issue Type: Bug > Affects Versions: 2.4.4 > Reporter: Thomas > Assignee: Paul King > Fix For: 2.4.5, 2.5.0-beta-1 > > > Given the following class > {code:title=Person.groovy} > import groovy.transform.CompileStatic > import groovy.transform.EqualsAndHashCode > @EqualsAndHashCode > @CompileStatic > class Person { > Long someLong > } > {code} > and the test > {code:title=PersonTest.groovy} > import static org.junit.Assert.* > import org.junit.Test > class PersonTest { > @Test > void hashcodeWithoutLongValue() { > def person = new Person() > assert person.hashCode() > } > } > {code} > and the gradle configuration: > {code:title=build.gradle} > buildscript { > repositories { > mavenCentral() > } > } > apply plugin: 'groovy' > apply plugin: 'eclipse' > jar { > baseName = 'HashCodeNPE' > version = '0.0.1-SNAPSHOT' > } > sourceCompatibility = 1.8 > targetCompatibility = 1.8 > repositories { > mavenCentral() > } > dependencies { > compile("org.codehaus.groovy:groovy:2.4.4") > testCompile("junit:junit:4.12") > } > eclipse { > classpath { > containers.remove('org.eclipse.jdt.launching.JRE_CONTAINER') > containers > 'org.eclipse.jdt.launching.JRE_CONTAINER/org.eclipse.jdt.internal.debug.ui.launcher.StandardVMType/JavaSE-1.8' > } > } > task wrapper(type: Wrapper) { > gradleVersion = '2.4' > } > {code} > when I run {code}gradle clean build{code} > then the test fails with the following message. > {code} > PersonTest > hashcodeWithoutLongValue FAILED > java.lang.NullPointerException at PersonTest.groovy:10 > 1 test completed, 1 failed > :test FAILED > {code} > With Groovy 2.4.3 the test passes. -- This message was sent by Atlassian JIRA (v6.3.4#6332)