groovy

VerifyError when using DelegatingMetaClass

Details

  • Type: Bug Bug
  • Status: Closed Closed
  • Priority: Major Major
  • Resolution: Fixed
  • Affects Version/s: 1.1-rc-1
  • Fix Version/s: 1.1-rc-2
  • Component/s: None
  • Labels:
    None
  • Environment:
    Environment WinXP SP2
    The eclipse plugin is V 1.0.1 installed on Eclipse 3.3.0
    When trying to run the script standalone I use Groovy Version: 1.1-rc-1 JVM: 1.6.0_03-b05
  • Number of attachments :
    0

Description

Hi, I have a problem with DelegatingMetaClass. I am trying to extend groovy.sql.Sql class with a static method similar to newInstance but that takes only one parameter ( a file name that contains all the connection parameters )

So I have used DelegatingMetaClass conventions and here is my SqlMetaClass.groovy:
------------------------
package groovy.runtime.metaclass.groovy.sql

import groovy.sql.Sql

class SqlMetaClass extends groovy.lang.DelegatingMetaClass
{
SqlMetaClass(MetaClassRegistry a_registry, final Class a_class)

{ super(a_class); }

public Object invokeStaticMethod(Object a_object, String a_methodName, Object[] a_arguments)
{
if(a_methodName == 'newInstance'){
if(a_arguments.length == 1) { //interpret the first argument as a file name Properties props = new Properties() props.load(new FileInputStream(a_arguments[0])) return Sql.newInstance(props['db.url'],props['db.user'], props['db.password'], props['db.drivername']) }
}
return super.invokeStaticMethod(a_object, a_methodName, a_arguments)
}
}
------------------------

Afterwards calling Sql.newInstance('hsql.properties') in some script worked as expected.
My problem is that it works only from eclipse, the moment I try to use it standalone I get some errors:

1. Calling the script as groovy -cp ../bin-groovy bug.groovy ( using the compiled class generated by the eclipse plug-in ) I get:

Caught: java.lang.VerifyError: (class: groovy/runtime/metaclass/groovy/sql/SqlMetaClass, method: super$2$invokeMethod signature: (Ljava/lang/Class;Ljava/lang/Object;Ljava/lang/String;[Ljava/lang/Object;ZZ)Ljava/lang/Object Illegal use of nonvirtual function call
at bug.run(bug.groovy:4)
at bug.main(bug.groovy)

2. Calling the script as groovy -cp ../clazzez bug.groovy gives me :
Caught: java.lang.VerifyError: (class: groovy/runtime/metaclass/groovy/sql/SqlMetaClass, method: super$2$setUseReflection signature: (Z)V) Illegal use of nonvirtual function call
at bug.run(bug.groovy:4)
at bug.main(bug.groovy)

where clazzez is the directory where I compiled the SqlMetaClass.groovy file using groovyc

<?xml version="1.0"?>

<project name="Compile a groovy class" default="compile" basedir=".">
<target name="compile">
<taskdef name="groovyc" classname="org.codehaus.groovy.ant.Groovyc" />

<groovyc srcdir="scripts/groovy" destdir="clazzez">

</groovyc>

</target>
</project>

Environment WinXP SP2
The eclipse plugin is V 1.0.1 installed on Eclipse 3.3.0
When trying to run the script standalone I use Groovy Version: 1.1-rc-1 JVM: 1.6.0_03-b05

Activity

Hide
blackdrag blackdrag added a comment -

1.1 is not binary compatible with the groovy version of your plugin. This is causing these problems in case 1. For case 2... setUseReflection is not in 1.1, so I guess you compiled using the wrong compiler again.... did you try to execute bug.groovy without compiling the groovy parts? if it works in that case, then it confirms that you used the wrong compiler..maybe a second Groovy.jar in the classpath for example

Show
blackdrag blackdrag added a comment - 1.1 is not binary compatible with the groovy version of your plugin. This is causing these problems in case 1. For case 2... setUseReflection is not in 1.1, so I guess you compiled using the wrong compiler again.... did you try to execute bug.groovy without compiling the groovy parts? if it works in that case, then it confirms that you used the wrong compiler..maybe a second Groovy.jar in the classpath for example
Hide
blackdrag blackdrag added a comment -

fixed

Show
blackdrag blackdrag added a comment - fixed

People

Vote (0)
Watch (0)

Dates

  • Created:
    Updated:
    Resolved: