Blog

Branch target offset too large for short null in ColdFusion

January 3, 2017

When working with complex logic functions in ColdFusion (i.e. lots of code) I’ve encountered this error numerous times

Branch target offset too large for short null

This error essentially means your method length exceeds what the JVM allows.

To correct the error break the logic up into multiple smaller functions.

2 Comments

Graham Pearson
Graham PearsonJanuary 1, 2018 at 10:15:05 am

In a FW/1 Application what would the recommended way to break up a controller cfc into smaller functions. Any Suggestions?

Jason Holden
Jason HoldenJanuary 1, 2018 at 11:23:46 am

@Graham I'm not very familiar with the FW/1 framework. However, just taking a quick look it appears that it should be no different than any other CFC. Typically what I do is name my smaller functions based on the "main" function I'm attempting to break up.

So something like:
<cffunction name="smallerfunction1_mainfunction" access="private"></cffunction>

Then your main function would look like:

<cffunction name="mainfunction" access="public">
<cfset smallerfunction1_mainfunction(arg1,arg2,...)>
<cfset smallerfunction2_mainfunction(arg1,arg2,...)>
</cffunction>

If you need to pass values around to each smaller function the best way I've found is to return the variable from your smaller function to your main function where it can then be manipulated and/or passed on to the next smaller function.

All that said if the logic is getting this complicated in a page controller you may want to consider moving the logic completely out of the controller and into it's own class or classes.

I'm happy to look at your code if you want to PM me.

Leave Your Comment

Your email address will not be published. Required fields are marked *


about me

An information technology professional with twenty four years experience in systems administration, computer programming, requirements gathering, customer service, and technical support.