I experienced this problem in CF8 some time ago as well. There is no general "2000 lines limit" but a maximum value in the JVM for the address offset in order to jump within a subroutine. The offset must not exceed 2 Bytes (WORD), otherwise you will face this exception. To avoid large address offsets within a subroutine (function), you need to minimize large blocks of conditional jumps (if/else/switch). You can do this by using multiple subroutines instead (these calls may take the full register up to 4/8 Bytes).
For example: Redesign...
function A (x, y) {
if (...) {
switch (...) {
case ...:
switch (...) {
...
}
...
}
} else {
switch (...) {
...
}
}
}
To something like...
function A (x, y) {
if (...) {
call B(x, y);
} else {
call C(x, y);
}
}
function B (x, y) {
switch (...) {
case ...:
call B1(x, y);
...
}
}
function B1 (x, y) {
switch (...) {
....
}
}
function C (x, y) {
switch (...) {
....
}
}
...you get the idea. This will usually also improve readability and maintainability.