scala jrebel 超类更改

发布于 2024-10-09 04:40:51 字数 351 浏览 0 评论 0原文

我将 JRebel 与 Scala 一起使用,并且经常遇到需要重新启动服务器的情况,因为如果超类发生更改,JRebel 无法加载类。这主要是在我更改匿名函数时完成的,因为我可以从 JRebel 错误描述中推断出:
Class 'mypackage.NewBook$$anonfun$2' 超类已从 'scala.runtime.AbstractFunction1' 更改为 'scala.runtime.AbstractFunction1' 。 Runtime.AbstractFunction2'并且无法重新加载
有什么办法,我如何设计我的代码来避免这种情况? scala 编译器是否会获取这些函数,并按照它们在源代码中出现的方式对它们进行编号?

I'm using JRebel with Scala and I'm quite frequently experiencing the need for restart of server due to the fact that JRebel is unable to load a class if the superclass was changed. This is done mainly when I change anonymous functions as I can deduce from the JRebel error desription:
Class 'mypackage.NewBook$$anonfun$2' superclass was changed from 'scala.runtime.AbstractFunction1' to 'scala.runtime.AbstractFunction2' and could not be reloaded.
Is there any way, how can I design my code to avoid this? Does scala compiler take the functions, numbers them from one as they appear in source code?

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

万人眼中万个我 2024-10-16 04:40:51

正在变化的数字是指函数参数的数量。 AbstractFunction1 是一个单参数函数,而 AbstractFunction2 是一个双参数函数。解决这个问题的一种方法是柯里化或元组你的函数,以便它们始终是单参数函数。

是的,匿名函数会按照您的建议自动命名。如果在现有匿名单参数函数之前插入新的匿名双参数函数,则看起来好像原始函数的类型已更改。

The numbers that are changing refer to the number of function arguments. An AbstractFunction1 is a one-argument function, while AbstractFunction2 is a two-argument function. One way to work around this would be to curry or tuple your functions so that they're always one-argument functions.

And, yes, anonymous functions are automatically named as you suggested. If you insert a new anonymous two-arg function before an existing anonymous one-arg function, it will appear as if the type of the original function changed.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文