Constance Eustace
Constance Eustace

Reputation: 427

Groovy java.lang.VerifyError - Expecting to find integer on stack

I resolved this myself, but the compilation error provided no feedback so I'm dropping the fix here.

The code was something like

def aMethod(String param1, String param2)
{
  Sql gsql = Sql.newInstance(<init code>)
  int hashCode = null

  ... more code
}

I assumed that Groovy was wrapping the int variable in an object, but apparently not fully. When I removed the int hashcode = null, everything ran fine.

May be related to some of the static compilation/optimization stuff that is going into Groovy these days

Upvotes: 3

Views: 1986

Answers (1)

blackdrag
blackdrag

Reputation: 6508

Firstly thanks to Peter for filing https://issues.apache.org/jira/browse/GROOVY-6419

int x = null is not valid in Groovy anymore since Groovy 1.8. Back then we made quite big change called "primitive optimizations", which allows Groovy to run some programs with a near Java speed, if the program is mostly based on Java primitives. Sadly this required Groovy to handle int really as int when it comes to null. Otherwise we would be unable to use the operations the JVM offers for this and thus loss the speed advantage again.

Upvotes: 3

Related Questions