【问题标题】:Grails / Groovy Transform ExceptionGrails / Groovy 转换异常
【发布时间】:2011-10-19 23:42:42
【问题描述】:

当我尝试使用最新的 grails 快照编译附加的 groovy 类时,出现以下异常。我今天离开了构建服务器。异常中的关键注释是:如果这不是您自己做的,请将此错误报告给转换的作者。

例外:

/u01/workspace/grails/grails-spring-social-core/grails-app/domain/grails/plugins/springsocial/UserConnection.groovy:-1: 转换使用包含 ClassNode grails.plugins.springsocial.UserConnection 的泛型作为 方法 public static grails.plugins.springsocial.UserConnection create() { ... }
直接地。你不应该这样做。请新建一个 ClassNode 引用旧的 ClassNode 并改用新的 ClassNode 旧的。否则编译器将创建错误的描述符和 OpenJDK 中的 TypeResolver 中潜在的 NullPointerException。如果这是 不是您自己做的,请将此错误报告给转换的作者。

所以这看起来像几个报告的 grails 错误,但它们在插件中被视为错误。这是 grails 问题还是 groovy 问题?

关于这个的讨论可能是一个 groovy 错误……但这超出了我的想象。

http://comments.gmane.org/gmane.comp.lang.groovy.devel/26130

造成这种情况的根本原因是什么?这又是 grails 转换的问题,还是一个 groovy 编译器异常?以下类是我要编译的:

package grails.plugins.springsocial

import groovy.transform.EqualsAndHashCode

@EqualsAndHashCode(includeFields=true)
class UserConnection implements Serializable {

    String userId
    String providerId
    String providerUserId
    String displayName
    String profileUrl
    String imageUrl
    String accessToken
    String secret
    String refreshToken
    Long rank
    Long expireTime

    static constraints = {
        userId nullable: false
        providerId nullable: false
        providerUserId nullable: false
        displayName nullable: true
        profileUrl nullable: true
        imageUrl nullable: true
        accessToken nullable: false
        secret nullable: true
        refreshToken nullable: true
        rank nullable: false
        expireTime nullable: true
    }

    static mapping = {
        table "UserConnection"
        version false

        id composite:['userId', 'providerId', 'providerUserId']

        userId column:'userId',length:64
        providerId column:'providerId',length:128
        providerUserId column:'providerUserId',length:128
        displayName column:'displayName'
        profileUrl column:'profileUrl'
        imageUrl column:'imageUrl'
        accessToken column:'accessToken'
        secret column:'secret'
        refreshToken column:'refreshToken'
        rank column:'rank'
        expireTime column:'expireTime'
    }
}

感谢您的帮助!

【问题讨论】:

  • 什么版本的 Grails? EqualsAndHashCode 是从 Groovy 1.8.0 开始出现的,Grails 1.3.7 在 Groovy 1.7 上不是吗?
  • 构建服务器的最新 2.0 快照。这是一个 1.8.3 的 groovy 问题。我降级到 1.8.2 来解决这个问题。

标签: grails groovy


【解决方案1】:

这最终成为一个 Groovy 1.8.3 问题。我降级到 1.8.2 后就没有问题了。

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2021-06-26
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2014-08-02
    • 2013-03-06
    相关资源
    最近更新 更多