1

我该如何解决:

命令:

$ 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

区别在哪里,我该如何解决。

4

2 回答 2

4

ceylon.language.runtime过去是用手写的 Java 代码实现的。在这段代码中,当它应该返回时getMaxArraySize()意外返回ceylon.language.Integerlong。这有效,但并不完全正确。

然后,在 Ceylon 1.2 的原生支持下,runtime(连同其他一些对象)被重写为原生 Ceylon 代码。由于 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.0ceylon run ceylon.formatter可能ceylon.formatter/1.2.0出于某种原因运行,这有效。

我不确定你需要做什么来解决这个问题。我最近改变了ceylon format插件的工作方式,所以你可能需要删除旧脚本(我相信某个地方的一个或文件)。希望新的已经在那里,准备接管。ceylon formatceylon-formatceylon-format.bat.ceylon/bin

于 2015-10-29T19:38:07.523 回答
4

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

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

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

于 2015-10-29T22:12:43.583 回答