Uploaded image for project: 'Groovy'
  1. Groovy
  2. GROOVY-5925

Casting map as Random results in java.lang.VerifyError

    XMLWordPrintableJSON

Details

    • Bug
    • Status: Closed
    • Major
    • Resolution: Fixed
    • 2.0.0, 2.0.1, 2.0.2, 2.0.4, 2.0.5, 2.0.6, 2.1.0-rc-1
    • 2.1.0-rc-2, 2.1.0, 2.0.7
    • None
    • None
    • Mac OSX 10.8.2, Java 1.7.0_08-ea

    Description

      When trying to cast a map as Random such as:

      Random random = [nextInt: { x -> return 0 }] as Random
      

      the following exception is thrown:

      WARNING: Sanitizing stacktrace:
      java.lang.VerifyError: (class: Random1_groovyProxy, method: <init> signature: (JLjava/util/Map;)V) Register 2 contains wrong type
      	at java.lang.Class.getDeclaredConstructors0(Native Method)
      	at java.lang.Class.privateGetDeclaredConstructors(Class.java:2404)
      	at java.lang.Class.getConstructor0(Class.java:2714)
      	at java.lang.Class.getConstructor(Class.java:1674)
      	at org.codehaus.groovy.runtime.ProxyGeneratorAdapter.<init>(ProxyGeneratorAdapter.java:167)
      	at groovy.util.ProxyGenerator.instantiateAggregate(ProxyGenerator.java:161)
      	at groovy.util.ProxyGenerator.instantiateAggregateFromBaseClass(ProxyGenerator.java:117)
      	at groovy.util.ProxyGenerator.instantiateAggregateFromBaseClass(ProxyGenerator.java:103)
      	at org.codehaus.groovy.runtime.DefaultGroovyMethods.asType(DefaultGroovyMethods.java:7511)
      	at org.codehaus.groovy.runtime.dgm$48.doMethodInvoke(Unknown Source)
      	at groovy.lang.MetaClassImpl.invokeMethod(MetaClassImpl.java:1076)
      	at groovy.lang.MetaClassImpl.invokeMethod(MetaClassImpl.java:906)
      	at org.codehaus.groovy.runtime.InvokerHelper.invokePojoMethod(InvokerHelper.java:836)
      	at org.codehaus.groovy.runtime.InvokerHelper.invokeMethod(InvokerHelper.java:827)
      	at org.codehaus.groovy.runtime.ScriptBytecodeAdapter.invokeMethodN(ScriptBytecodeAdapter.java:164)
      	at org.codehaus.groovy.runtime.ScriptBytecodeAdapter.asType(ScriptBytecodeAdapter.java:587)
      	at ConsoleScript2.run(ConsoleScript2:1)
      	at groovy.lang.GroovyShell.runScriptOrMainOrTestOrRunnable(GroovyShell.java:257)
      	at groovy.lang.GroovyShell.run(GroovyShell.java:481)
      	at groovy.lang.GroovyShell.run(GroovyShell.java:163)
      	at groovy.lang.GroovyShell$run.call(Unknown Source)
      	at org.codehaus.groovy.runtime.callsite.CallSiteArray.defaultCall(CallSiteArray.java:45)
      	at org.codehaus.groovy.runtime.callsite.AbstractCallSite.call(AbstractCallSite.java:108)
      	at org.codehaus.groovy.runtime.callsite.AbstractCallSite.call(AbstractCallSite.java:124)
      	at groovy.ui.Console$_runScriptImpl_closure17.doCall(Console.groovy:951)
      	at groovy.ui.Console$_runScriptImpl_closure17.doCall(Console.groovy)
      	at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
      	at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:57)
      	at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
      	at java.lang.reflect.Method.invoke(Method.java:601)
      	at org.codehaus.groovy.reflection.CachedMethod.invoke(CachedMethod.java:90)
      	at groovy.lang.MetaMethod.doMethodInvoke(MetaMethod.java:233)
      	at org.codehaus.groovy.runtime.metaclass.ClosureMetaClass.invokeMethod(ClosureMetaClass.java:272)
      	at groovy.lang.MetaClassImpl.invokeMethod(MetaClassImpl.java:906)
      	at groovy.lang.Closure.call(Closure.java:412)
      	at groovy.lang.Closure.call(Closure.java:406)
      	at groovy.lang.Closure.run(Closure.java:490)
      	at java.lang.Thread.run(Thread.java:722)
      

      This worked in versions earlier than groovy 2.0.0

      Attachments

        Activity

          People

            paulk Paul King
            mecameron Michael Cameron
            Votes:
            0 Vote for this issue
            Watchers:
            3 Start watching this issue

            Dates

              Created:
              Updated:
              Resolved: