ObjectGraphBuilder - JVM error when running ObjectGraphBuilder and overriding relationNameResolver (JDK 1.6.0_20, IntelliJ 9.0.1, Groovy 1.7.2)

I'm trying to override the classNameResolver in objectgraphbuilder.  When I do that, and try to run my script *in debug mode*, I get a JVM exception:




Here's the script I run:

// start of script
import org.codehaus.groovy.runtime.InvokerHelper
import groovy.util.ObjectGraphBuilder.RelationNameResolver

class CustomResolver implements RelationNameResolver {
// * Handles the common English regular plurals with the following rules.<br />
// * <ul>
// * <li>If childName ends in {consonant}y, replace 'y' with "ies". For example, allergy to allergies.</li>
// * <li>Otherwise, append 's'. For example, monkey to monkeys; employee to employees.</li>
// * </ul>
// * If the property does not exist then it will return childName unchanged.
// *
// * @see English_plural
//
  public String resolveChildRelationName(String parentName, Object parent, String childName,
                                         Object child) {
    boolean matchesIESRule = pluralIESPattern.matcher(childName).matches();
    String childNamePlural = matchesIESRule ? childName.substring(0, childName.length() - 1) + "ies" : childName + "s";

    MetaProperty metaProperty = InvokerHelper.getMetaClass(parent)
            .hasProperty(parent, childNamePlural);

    return metaProperty != null ? childNamePlural : childName;
  }

// * Follow the most conventional pattern, returns the parentName
// * unchanged.
//
  public String resolveParentRelationName(String parentName, Object parent,
                                          String childName, Object child) {
    return parentName;
  }
  
}

builder = new ObjectGraphBuilder();
builder.classNameResolver = "com.mypackagename";

builder.relationNameResolver = new CustomResolver();
print "hello"

// end of script

Some environment info:
I'm running on Windows 2003
IntelliJ 9.0.1
JDK 1.6.0_20
Groovy 1.7.2

Please note: I'm able to run the script in IntelliJ without any problems.  It's when I try to debug that I run into issues.  I've been able to debug groovy scripts with an ObjectGraphBuilder that has an overrided childPropertySetter, newInstanceResolver without any issues.  It's when I try to override relationNameResolver that I get this weird VM error.

Anyone have any ideas what's going on?

Omair

1 comment

Unfortunately I can't reproduce the failure (and I don't have exactly
the same environment). Could you post a complete console output when you
debug your script?

0

Please sign in to leave a comment.