[groovy-user] VerifyError when using DelegatingMetaClass

10 views
Skip to first unread message

seven

unread,
Oct 18, 2007, 5:34:23 AM10/18/07
to us...@groovy.codehaus.org

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

Regards,
Horia Muntean
--
View this message in context: http://www.nabble.com/VerifyError-when-using-DelegatingMetaClass-tf4645827.html#a13271029
Sent from the groovy - user mailing list archive at Nabble.com.


---------------------------------------------------------------------
To unsubscribe from this list please visit:

http://xircles.codehaus.org/manage_email

Guillaume Laforge

unread,
Oct 22, 2007, 4:45:08 AM10/22/07
to us...@groovy.codehaus.org
Hi,

Could you please create a JIRA issue?


--
Guillaume Laforge
Groovy Project Manager
G2One, Inc. Vice-President Technology
http://www.g2one.com

seven

unread,
Oct 22, 2007, 4:54:08 AM10/22/07
to us...@groovy.codehaus.org

Guillaume Laforge

unread,
Oct 22, 2007, 5:01:54 AM10/22/07
to us...@groovy.codehaus.org
Thanks a lot.

seven

unread,
Oct 22, 2007, 5:09:01 AM10/22/07
to us...@groovy.codehaus.org

BTW, I made a comment for another bug (
http://jira.codehaus.org/browse/GROOVY-1918 ) including code to reproduce
the problem. Not sure if I should've opened another issue.

Could you please look over it?

Regards,
Horia Muntean

--
View this message in context: http://www.nabble.com/VerifyError-when-using-DelegatingMetaClass-tf4645827.html#a13339354

Reply all
Reply to author
Forward
0 new messages