Seeing "Instrumented method length exceeds the limit allowed by the JVM specification" error in APM log.

Document ID : KB000032543
Last Modified Date : 14/02/2018
Show Technical Document Details

Question:

I am getting the below error in the APM log file. Am I hitting a threshold which is causing these errors?

Error in log:  Instrumented method length exceeds the limit allowed by the JVM specification

10/06/15 12:45:06 AM PDT [ERROR] [IntroscopeAgent.Agent] A problem occurred while attempting to Introscope-enable jsp_servlet/_shop/__shop_iru_home: Instrumented method length exceeds the limit allowed by the JVM specification

Answer:

The Java class file format imposes an upper limit on the size of the byte-code for an individual method. The limit is usually 64K per JSP (depending on version and details). With a very large JSP, the 64 K limit can be approached and additionally, Wily's instrumentation could potentially push the size past the JVM limit. 

What is probably happening is that the un-instrumented method is just barely shy of 64 K, so the additional byte-code from the Introscope instrumentation pushes over the limit.

 

The error says that after the servlets method are instrumented, the total byte code for the method length exceeds the limit allowed in a JVM specification. Basically, without instrumentation, the method length is already very close to the limit, and adding instrumentation places it over the limit. 

With this error, AutoProbe just passes the original byte-code to the JVM without instrumentation and can fill up the logs.

 

Additional suggestions are:

1. Ignore the error as it's harmless. It basically says AutoProbe cannot instrument it and will just pass the bytecode as is to the JVM. 

2. Skip the JSP class in question to avoid the error. 

3. Ask the developers to refactor the JSP in question - Refactor/break the method in JSP code to smaller chunks so it meets the JVM specs after instrumentation. 

4. Log an enhancement/idea via the apm communities communities.ca.com.