幾天做項目,生成一堆注解的實體,當實體數超過86個時,jvm報錯:
#
# A fatal error has been detected by the Java Runtime Environment:
#
# Internal Error (c1_Optimizer.cpp:271), pid=5104, tid=6488
# guarantee(x_compare_res != Constant::not_comparable) failed: incomparable constants in IfOp
#
# JRE version: 6.0_35-b10
# Java VM: Java HotSpot(TM) Client VM (20.10-b01 mixed mode, sharing windows-x86 )
# An error report file with more information is saved as:
# D:\開發工具\eclipse_up\hs_err_pid5104.log
20121130|13:44:09 [INFO ] [localhost-startStop-1] [AnnotationSessionFactoryBean:777] Building new Hibernate SessionFactory
#
# If you would like to submit a bug report, please visit:
# http://java.sun.com/webapps/bugreport/crash.jsp
#
查詢得知是windows版jdk 1.6bug(經測試,linux下無此問題),問題的原因就在於,JIT在做編譯優化的時候處理 某個方法時出錯。 錯誤是這個方法
org.hibernate.cfg.annotations.SimpleValueBinder.setType
解決辦法:讓jvm跳過該方法的編譯優化
在jvm啟動參數中添加啟動參數
加入jvm啟動參數:-XX:CompileCommand=exclude,org/hibernate/cfg/annotations/SimpleValueBinder.setType
或:換成jdk1.5 jdk7
如果是直接通過startup 啟動tomcat,則需要修改以下文件
Windows下,在文件/bin/catalina.bat,Unix下,在文件/bin/catalina.sh
找到
set JAVA_OPTS=%JAVA_OPTS% %LOGGING_CONFIG%
修改為
set JAVA_OPTS=%JAVA_OPTS% -XX:CompileCommand=exclude,org/hibernate/cfg/annotations/SimpleValueBinder,setType %LOGGING_CONFIG%
