scala jrebel 超类更改
我将 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 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
正在变化的数字是指函数参数的数量。
AbstractFunction1
是一个单参数函数,而AbstractFunction2
是一个双参数函数。解决这个问题的一种方法是柯里化或元组你的函数,以便它们始终是单参数函数。是的,匿名函数会按照您的建议自动命名。如果在现有匿名单参数函数之前插入新的匿名双参数函数,则看起来好像原始函数的类型已更改。
The numbers that are changing refer to the number of function arguments. An
AbstractFunction1
is a one-argument function, whileAbstractFunction2
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.