[ https://issues.apache.org/jira/browse/GROOVY-8912?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=16740995#comment-16740995 ]
Paul King edited comment on GROOVY-8912 at 1/12/19 4:49 AM: ------------------------------------------------------------ I created a related issue, GROOVY-8955, when trying to create a standalone reproducer for this issue. I don't know yet whether a fix to that issue will fix both cases. It's from a few lines up from the relevant line here as I was setting up the context for this one. was (Author: paulk): I created a related issue, GROOVY-8955, when trying to create a standalone reproducer for this issue. I don't know yet whether a fix to that issue will fix both cases. > Cannot cast object ... with class 'java.lang.Class' to class > 'groovy.lang.GroovyObject' > ----------------------------------------------------------------------------------------- > > Key: GROOVY-8912 > URL: https://issues.apache.org/jira/browse/GROOVY-8912 > Project: Groovy > Issue Type: Bug > Affects Versions: 2.5.4 > Reporter: Sergio del Amo > Priority: Major > > This code > {{MetaProperty idProp = > getJavaClass().getMetaClass().getMetaProperty(GormProperties.IDENTITY)}} > > throws the next error: > {{org.codehaus.groovy.runtime.typehandling.GroovyCastException: Cannot cast > object 'class grails.gorm.tests.path.domain.Person' with class > 'java.lang.Class' to class 'groovy.lang.GroovyObject' at > org.grails.datastore.gorm.neo4j.GraphPersistentEntity.initialize(GraphPersistentEntity.groovy:89) > at > org.grails.datastore.mapping.model.AbstractMappingContext.initializePersistentEntity(AbstractMappingContext.java:352) > at > org.grails.datastore.mapping.model.AbstractMappingContext.addPersistentEntities(AbstractMappingContext.java:283) > at > org.grails.datastore.gorm.neo4j.Neo4jMappingContext.<init>(Neo4jMappingContext.java:108) > at > org.grails.datastore.gorm.neo4j.Neo4jDatastore.createMappingContext(Neo4jDatastore.java:385) > at > org.grails.datastore.gorm.neo4j.Neo4jDatastore.<init>(Neo4jDatastore.java:163) > at > org.grails.datastore.gorm.neo4j.Neo4jDatastore.<init>(Neo4jDatastore.java:250) > at > org.grails.datastore.gorm.neo4j.Neo4jDatastore.<init>(Neo4jDatastore.java:272) > at > org.grails.datastore.gorm.neo4j.Neo4jDatastore.<init>(Neo4jDatastore.java:282) > at > org.grails.datastore.gorm.neo4j.Neo4jDatastore.<init>(Neo4jDatastore.java:320) > at > grails.gorm.tests.path.PathSpec.$spock_initializeSharedFields(PathSpec.groovy:16)}} > > But this is ok: > {{Class clazz = getJavaClass()}} > {{MetaClass metaClass = clazz.getMetaClass()}} > {{MetaProperty idProp = metaClass.getMetaProperty(GormProperties.IDENTITY)}} > > {{GormProperties.IDENTITY}} is String defined in an interface in a .java file. > > *Steps to reproduce:.* > You can find a link to the commit here: > [https://github.com/grails/gorm-neo4j/commit/70a6321b902377303b762cc2cdb9e3f2c9a4b794] > > Cloning the repo, reverting that commit and execute: > > ./gradlew --stacktrace grails-datastore-gorm-neo4j:test --tests > grails.gorm.tests.path.PathSpec > > and compilation fails -- This message was sent by Atlassian JIRA (v7.6.3#76005)