[ https://issues.apache.org/jira/browse/GROOVY-8485?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=16413172#comment-16413172 ]
Jochen Theodorou commented on GROOVY-8485: ------------------------------------------ I think you do not have it 100%. The transformLoader sits on top of the loader for the compiler itself as well as the classes used for compilation. The only reason the transform loader exists is to allow a separation of transform runtime and facet as well as actual compile time implementation. > PropertyHandler support producing errors when supplied class loader is not in > loader chain of PropertyLoder.class > ----------------------------------------------------------------------------------------------------------------- > > Key: GROOVY-8485 > URL: https://issues.apache.org/jira/browse/GROOVY-8485 > Project: Groovy > Issue Type: Bug > Reporter: Eric Milles > Priority: Major > > I'm having a little trouble with the new PropertyHandler stuff that supports > @Immutable. The error "The propertyHandler class > 'groovy.transform.options.ImmutablePropertyHandler' on @MapConstructor is > not a propertyHandler" is showing anywhere @Immutable is applied. I think > the ClassLoader used to load PropertyHandler was different from the one > passed as "loader" to the method below. And so the isAssignableFrom check > fails. When I edit (see below) to use the same class loader used for > PropertyHandler, the check and typecast succeed. > > {code:java} > public static PropertyHandler > createPropertyHandler(AbstractASTTransformation xform, GroovyClassLoader > loader, ClassNode cNode) { > List<AnnotationNode> annotations = > cNode.getAnnotations(PROPERTY_OPTIONS_TYPE); > AnnotationNode anno = annotations.isEmpty() ? null : > annotations.get(0); > if (anno == null) return new > groovy.transform.options.DefaultPropertyHandler(); > > ClassNode handlerClass = xform.getMemberClassValue(anno, > "propertyHandler", > ClassHelper.make(groovy.transform.options.DefaultPropertyHandler.class)); > > if (handlerClass == null) { > xform.addError("Couldn't determine propertyHandler class", anno); > return null; > } > > String className = handlerClass.getName(); > try { > // GRECLIPSE edit > //Object instance = loader.loadClass(className).newInstance(); > Object instance = > PropertyHandler.class.getClassLoader().loadClass(className).newInstance(); > // GRECLIPSE end > if (instance == null) { > xform.addError("Can't load propertyHandler '" + className + > "'", anno); > return null; > } > if (!PropertyHandler.class.isAssignableFrom(instance.getClass())) > { > xform.addError("The propertyHandler class '" + > handlerClass.getName() + "' on " + xform.getAnnotationName() + " is not a > propertyHandler", anno); > return null; > } > > return (PropertyHandler) instance; > } catch (Exception e) { > xform.addError("Can't load propertyHandler '" + className + "' " > + e, anno); > return null; > } > } > {code} > Please note this is from within Eclipse IDE support. So the > GroovyClassLoader has a different origin than the command-line tools provide. -- This message was sent by Atlassian JIRA (v7.6.3#76005)