方法代码在Groovy& Grails的? [英] Method code too large in Groovy & Grails?

查看:737
本文介绍了方法代码在Groovy& Grails的?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

  2014-06-17 11:22:18,622 [线程11] ERROR compiler.GrailsProjectWatcher  - 编译错误:启动失败:
在类生成期间的一般错误:方法代码太大了!

解决方案是什么?只有4-5行代码隐藏并重新启动才能完全运行成功,bootStrap文件大小为149k。当我注释或删除4-5行代码时,它将会运行而不会出现错误! 解决方案

Java虚拟机有一个限制表示方法不能大于64k (65536字节)。这篇文章详细描述了这个限制。

克服的最好方法这个问题只是将你的大方法分解成更小的方法,这通常是一个很好的习惯。
还要注意,JVM JIT编译器不会编译大于8K的方法。但是,您可以使用 -XX:-DontCompileHugeMethods 选项更改此行为。


2014-06-17 11:22:18,622 [Thread-11] ERROR compiler.GrailsProjectWatcher  - Compilation Error: startup failed:
General error during class generation: Method code too large!

What is the solution? Only 4-5 line code hide and restart then fully run in successfully, the bootStrap file size is 149k. When I comment or delete 4-5 line code, it will be run without no error!

解决方案

The Java Virtual Machine has a limitation that methods cannot be larger than 64k (65536 bytes). This post describes this limitation in details.
The best way to overcome this issue is simply splitting your large method into smaller ones, which is generally a good practice.

Also notice that the JVM JIT compiler will not compile methods larger than 8K. You can however change this behavior using the -XX:-DontCompileHugeMethods option.

这篇关于方法代码在Groovy& Grails的?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆