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:
Could you please create a JIRA issue?
--
Guillaume Laforge
Groovy Project Manager
G2One, Inc. Vice-President Technology
http://www.g2one.com
--
View this message in context: http://www.nabble.com/VerifyError-when-using-DelegatingMetaClass-tf4645827.html#a13339112
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