Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

The code of method ... is exceeding the 65535 bytes limit

Inside a jsp I have a small header :

<%@ page import="java.util.*"%>

<% HttpSession CurrentSession =
 request.getSession();
 ...
%>

...and a big html

<html>
...
</html>

If I try to read it as is I get an error of "...is exceeding the 65535 bytes limit".I have to break it up.Since I am new to java I cannot figure it out how to do it.Could you please indicate me the way?

like image 531
user2334908 Avatar asked Apr 30 '13 07:04

user2334908


People also ask

Is exceeding the 65535 bytes limit Java?

If a subjob is too big, the size of the final generated code will exceed 65536 bytes. According to Java specifications, the amount of code for this non-native, non-abstract method is limited to a size of 65536 bytes, so the generated code of a subjob cannot be greater than this limit.

Is exceeding the 65535 bytes limit Stacktrace?

It is possible that after an upgrade you may encounter this error on some of the more complex pages of Asset Bank, such as the Asset Detail page. If you see a stack trace on the screen the same as the one below then you can add a configuration setting to Tomcat to stop it.

How many characters is 65 535 bytes?

A text column can be up to 65,535 bytes. An utf-8 character can be up to 3 bytes. So... your actual limit can be 21,844 characters.

Why does the Code of method main(string[]) exceed the 65535 byte limit?

The code of method main(String[]) is exceeding the 65535 bytes limit. This is because there is an arbitrary hard-coded limit in Java of 64Kb for method sizes. (And actually many other things are limited to 64K, such as method names, the number of constants, etc. See the Java 8 specs or the Java 7 specs for more details.)

What is the 65536 byte limit for a class?

The 65536 byte limit is per method, not per class. So, you may have to split up the larger methods into sub-routines. The 65536 byte limit is per method, not per class.

What is the limit of code of method in Talend?

[resolved] Talend: The code of method exceeding the 65535 bytes limit... Design and Development — jayesh423 (Customer) asked a question. [resolved] Talend: The code of method exceeding the 65535 bytes limit... I am loading data from Salesforce to SQL. I've done it for few objects successfully.

Why Jira code size limit is 65535?

it's only due to generated code that cannot exceed 65535 bytes. * The amount of code per non-native, non-abstract method is limited to 65536 bytes .... It is known issue in talend. Please refer to related jira bug , , .


2 Answers

The JSP is converted into a normal Servlet java source, and some generated method is too large, as there is a 64 KB limit (on the byte code) on method lengths.

If possible change static includes (really embedding an other JSP source) with dynamic includes.

The solution (and probably good style) is too introduce a couple of methods into which pieces of the general code is moved. For instance to generate a HTML table row with <tr>:

<%@

    void tableRow(String... cellValues) {
        %><tr><%
           for (String cellValue : cellValues) {
               %>  <td><%= cellValue %></td>
  <%
           }
        %></tr>
  <%
    }
%>

...

<%
    tableRow("one", "unu", "un");
    tableRow("two", "du", "deux");
    tableRow("three", "tri", "trois");
%>

P.S. The above method is too small scale to save much, taking a large piece and create a method like createResultsTable is more effective.

like image 98
Joop Eggen Avatar answered Oct 16 '22 01:10

Joop Eggen


JSPs get compiled into servlet code, which are then compiled into actual java .class files. JSP code will be put into one big doGet() method, and if your JSP file is really big, it will hit the method size limit of 65535. The limit is coming from JVM specification ("The value of the code_length item must be less than 65536").

You should split the file into several files. I wouldn't split it into different methods as proposed in this thread, since it can make the code logic even more complex in this case, but do a jsp:include for the HTML part(s) like proposed by McDowell.

like image 38
eis Avatar answered Oct 16 '22 00:10

eis