Search in sources :

Example 86 with GroovyObject

use of groovy.lang.GroovyObject in project groovy-core by groovy.

the class ProxyGeneratorAdapter method visit.

@Override
public void visit(final int version, final int access, final String name, final String signature, final String superName, final String[] interfaces) {
    Set<String> interfacesSet = new LinkedHashSet<String>();
    if (interfaces != null)
        Collections.addAll(interfacesSet, interfaces);
    for (Class extraInterface : classList) {
        if (extraInterface.isInterface())
            interfacesSet.add(BytecodeHelper.getClassInternalName(extraInterface));
    }
    final boolean addGroovyObjectSupport = !GroovyObject.class.isAssignableFrom(superClass);
    if (addGroovyObjectSupport)
        interfacesSet.add("groovy/lang/GroovyObject");
    if (generateDelegateField) {
        classList.add(GeneratedGroovyProxy.class);
        interfacesSet.add("groovy/lang/GeneratedGroovyProxy");
    }
    super.visit(V1_5, ACC_PUBLIC, proxyName, signature, BytecodeHelper.getClassInternalName(superClass), interfacesSet.toArray(new String[interfacesSet.size()]));
    visitMethod(ACC_PUBLIC, "<init>", "()V", null, null);
    addDelegateFields();
    if (addGroovyObjectSupport) {
        createGroovyObjectSupport();
    }
    for (Class clazz : classList) {
        visitClass(clazz);
    }
}
Also used : LinkedHashSet(java.util.LinkedHashSet) GroovyClass(org.codehaus.groovy.tools.GroovyClass) GroovyObject(groovy.lang.GroovyObject)

Example 87 with GroovyObject

use of groovy.lang.GroovyObject in project groovy-core by groovy.

the class MethodFailureTest method testMethodWhichCallsTheFailingMethodInsideAClosure.

public void testMethodWhichCallsTheFailingMethodInsideAClosure() {
    MockGroovyObject object = new MockGroovyObject();
    try {
        object.invokeMethod("callClosure", new Closure(this) {

            protected Object doCall(GroovyObject object) {
                return object.invokeMethod("nonExistentMethod", "hello");
            }
        });
        fail("Should have thrown an exception");
    } catch (GroovyRuntimeException e) {
        System.out.println(e);
    //e.printStackTrace();
    }
}
Also used : Closure(groovy.lang.Closure) GroovyRuntimeException(groovy.lang.GroovyRuntimeException) GroovyObject(groovy.lang.GroovyObject) GroovyObject(groovy.lang.GroovyObject)

Example 88 with GroovyObject

use of groovy.lang.GroovyObject in project groovy-core by groovy.

the class RunClosureTest method testBytecode2Bug.

public void testBytecode2Bug() throws Exception {
    GroovyObject object = compile("src/test/groovy/bugs/Bytecode2Bug.groovy");
    object.invokeMethod("testTedsBytecodeBug", null);
}
Also used : GroovyObject(groovy.lang.GroovyObject)

Example 89 with GroovyObject

use of groovy.lang.GroovyObject in project groovy-core by groovy.

the class RunClosureTest method testZoharsBug.

public void testZoharsBug() throws Exception {
    GroovyObject object = compile("src/test/groovy/bugs/ZoharsBug.groovy");
    object.invokeMethod("testBug", null);
}
Also used : GroovyObject(groovy.lang.GroovyObject)

Example 90 with GroovyObject

use of groovy.lang.GroovyObject in project groovy-core by groovy.

the class RunClosureTest method testBytecodeBug.

public void testBytecodeBug() throws Exception {
    GroovyObject object = compile("src/test/groovy/bugs/BytecodeBug.groovy");
    object.invokeMethod("testTedsBytecodeBug", null);
}
Also used : GroovyObject(groovy.lang.GroovyObject)

Aggregations

GroovyObject (groovy.lang.GroovyObject)142 GroovyClassLoader (groovy.lang.GroovyClassLoader)15 Closure (groovy.lang.Closure)11 File (java.io.File)8 Map (java.util.Map)8 Decorator (com.opensymphony.module.sitemesh.Decorator)7 GroovyRuntimeException (groovy.lang.GroovyRuntimeException)7 MetaClass (groovy.lang.MetaClass)7 HashMap (java.util.HashMap)7 GrailsWebRequest (org.grails.web.servlet.mvc.GrailsWebRequest)7 Page (com.opensymphony.module.sitemesh.Page)5 HTMLPageParser (com.opensymphony.module.sitemesh.parser.HTMLPageParser)5 Config (grails.config.Config)5 InvocationTargetException (java.lang.reflect.InvocationTargetException)5 ServletContext (javax.servlet.ServletContext)5 PropertySourcesConfig (org.grails.config.PropertySourcesConfig)5 MockApplicationContext (org.grails.support.MockApplicationContext)5 MockHttpServletRequest (org.springframework.mock.web.MockHttpServletRequest)5 MockServletConfig (org.springframework.mock.web.MockServletConfig)5 ArrayList (java.util.ArrayList)4