Issue Details (XML | Word | Printable)

Key: GROOVY-2232
Type: Bug Bug
Status: Closed Closed
Resolution: Fixed
Priority: Major Major
Assignee: Jochen Theodorou
Reporter: Horia Muntean
Votes: 0
Watchers: 0
Operations

If you were logged in you would be able to see more operations.
groovy

VerifyError when using DelegatingMetaClass

Created: 22/Oct/07 03:53 AM   Updated: 26/Oct/07 10:02 AM
Component/s: None
Affects Version/s: 1.1-rc-1
Fix Version/s: 1.1-rc-2

Time Tracking:
Not Specified

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


 Description  « Hide
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



 All   Comments   Work Log   Change History      Sort Order: Ascending order - Click to sort in descending order
Jochen Theodorou added a comment - 26/Oct/07 09:34 AM
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

Jochen Theodorou added a comment - 26/Oct/07 10:02 AM
fixed