【问题标题】:Ceylon version 1.2 Format CommandCeylon 1.2 版格式命令
【发布时间】:2015-10-31 08:01:10
【问题描述】:

我该如何解决这个问题:

命令:

$ ceylon format source/com/example/helloworld/*

例外:

Exception in thread "main" java.lang.NoSuchMethodError: ceylon.language.runtime_.getMaxArraySize()Lceylon/language/Integer;
        at ceylon.collection.Hashtable.<init>(Hashtable.ceylon:35)
        at ceylon.collection.Hashtable.<init>(Hashtable.ceylon)
        at ceylon.collection.HashMap.$default$hashtable(HashMap.ceylon:31)
        at ceylon.formatter.options.Spaces$cache_.<init>(IndentMode.ceylon:62)
        at ceylon.formatter.options.Spaces$cache_.<init>(IndentMode.ceylon)
        at ceylon.formatter.options.Spaces.<init>(IndentMode.ceylon:59)
        at ceylon.formatter.options.FormattingOptions.$default$indentMode(FormattingOptions_generated.ceylon:355)
        at ceylon.formatter.options.FormattingOptions.<init>(FormattingOptions_generated.ceylon)
        at ceylon.formatter.options.loadProfile_.loadProfile(profiles.ceylon:79)
        at ceylon.formatter.options.loadProfile_.loadProfile(profiles.ceylon)
        at ceylon.formatter.options.commandLineOptions_.commandLineOptions(formattingOptions.ceylon:125)
        at ceylon.formatter.options.commandLineOptions_.commandLineOptions(formattingOptions.ceylon)
            at ceylon.formatter.run_.run(run.ceylon:285)
   ...

我想我必须重新安装格式化程序。但是哪个版本?

以下命令无缘无故起作用:

ceylon run ceylon.formatter source/com/example/helloworld/*.ceylon

差异在哪里,我该如何解决。

【问题讨论】:

    标签: ceylon


    【解决方案1】:

    ceylon.language.runtime 曾经是implemented in hand-written Java code。在这段代码中,getMaxArraySize() 在本应返回 long 时意外地出现了 returned ceylon.language.Integer。这行得通,但并不完全正确。

    然后,在 Ceylon 1.2 中的原生支持下,runtime(以及其他一些对象)作为原生 Ceylon 代码使用 rewritten。由于 Ceylon 编译器将其转换为 Java,该方法现在获得正确的返回类型,long。新编译的模块现在将调用此方法,但针对旧 ceylon.language 编译的代码仍会尝试调用返回 ceylon.language.Integer 的方法,这会导致您的 NoSuchMethodError

    这里发生的情况似乎是 ceylon format 运行 ceylon.formatter/1.1.0,它是针对 ceylon.language/1.1.0 编译的,现在无法使用 ceylon.language/1.2.0 运行。 ceylon run ceylon.formatter 可能出于某种原因运行 ceylon.formatter/1.2.0,这有效。

    我不确定你需要做什么来解决这个问题。我更改了ceylon format 插件recently 的工作方式,因此您可能需要删除旧的ceylon format 脚本(我相信ceylon-formatceylon-format.bat 文件位于.ceylon/bin 的某处)。希望新的已经在那里,准备好接管了。

    【讨论】:

      【解决方案2】:

      试试ceylon plugin uninstall format 看看能不能解决问题。

      第二种选择是说ceylon plugin install ceylon.formatter/1.2.0

      ceylon format 不起作用但ceylon run 起作用的原因是因为您安装的ceylon format 将寻找不再兼容的硬编码版本1.1ceylon run 将寻找任何与您正在使用的当前 Ceylon 版本兼容的版本。 (所以它会同时找到 1.1.0 和 1.2.0 但它会丢弃 1.1.0,因为它不兼容,因此会自动选择 1.2.0)

      【讨论】:

        猜你喜欢
        • 1970-01-01
        • 1970-01-01
        • 2016-07-24
        • 1970-01-01
        • 1970-01-01
        • 2021-08-19
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        相关资源
        最近更新 更多