기술지원 문의

[답변]code too large for try statement 문의
권용찬 / 2007-03-11 19:16

음...원인을 잘 알고 계시니 간단하게 설명 드리겠습니다. ^^

 

JAVA에서  컴파일러 스펙상의 제한입니다.

이 부분은 JAVA  Spec이기 대문에 WAS에서는 해당 Spec을 준수하여 Exception처리하는 것이 정상(?) 이라고 할 수 있겠습니다.

 

 JAVA Spec상에 1개의 Method는 내용이 64kbyte를 넘으면 커파일러 자체가 처리를 거부합니다.

또한 Try catch 사이의 내용이 이러한 경우에도 마찮가지 입니다.

JSP는 1차 JAVA Code로 변환과정을 거치고 이때 컴파일러가 JSP문을 try-catch문으로 엮어서 처리하는데 jsp내용이 큰 경우 제한에 걸리는 것입니다.

 

해결방법은 JSP 일부 코드 영역을 리펙토링 하셔야 하겠습니다.

1만줄이나 되는 JSP가 당연하게 그러해야 한다고 하신다면.... -.-;; 방법이 없습니다만..

 

코드를 bean형태로 뜯어내셔서 JSP의 크기를 줄여서 사용하셔야만 이 문제를 해결 가능합니다.

 

해당 내용에 관련된 resolution을 첨부해 드립니다.

 

Problem
How do you avoid a code too large for try statement error message while compiling JavaServer Pages?(JSP??

 

Solution
The Java?specification states that there is a 64 K limit on the size of methods in Java.

The JVM?does not execute methods that exceed this limit.

 

It is possible to compile methods larger than 64 K, but the JVM will not run these methods. Consequently, the error occurs during runtime, while attempting to execute Java methods that are greater than 64 K.

A code too large for try statement error can still be issued while compiling a JSP. The compiler limitation does not allow try/catch blocks to have a start or end location greater than 64 K into the method code. Therefore, compiler limitations are usually caught when a try/catch block overlaps the 64 K boundary.

 

The workaround is to refactor the code into smaller methods or try/catch blocks.