org.codehaus.groovy.runtime.typehandling.GroovyCastException Java Examples

The following examples show how to use org.codehaus.groovy.runtime.typehandling.GroovyCastException. You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: ProxyGenerator.java    From groovy with Apache License 2.0 5 votes vote down vote up
@SuppressWarnings("unchecked")
public GroovyObject instantiateAggregate(Map closureMap, List<Class> interfaces, Class clazz, Object[] constructorArgs) {
    if (clazz != null && Modifier.isFinal(clazz.getModifiers())) {
        throw new GroovyCastException("Cannot coerce a map to class " + clazz.getName() + " because it is a final class");
    }
    Map<Object,Object> map = closureMap != null ? closureMap : EMPTY_CLOSURE_MAP;
    ProxyGeneratorAdapter adapter = createAdapter(map, interfaces, null, clazz);

    return adapter.proxy(map, constructorArgs);
}
 
Example #2
Source File: GroovyEvaluatorExceptionTest.java    From beakerx with Apache License 2.0 4 votes vote down vote up
@Test(expected = GroovyCastException.class)
public void parseCastWrongClassScript_throwGroovyCastException() {
  //when
  parseClassFromScript("def plot = new Plot() \n" + "Line line = (Line) Plot ");
}