Subj : Re: "Code of a method longer than 65535 bytes" To : Cameron McCormack From : Igor Bukanov Date : Wed Mar 31 2004 10:55 am Cameron McCormack wrote: > Hi everyone. > > I'm getting the message in the Subject line when trying to use some > script in Batik[1]. From reading up a few old messages in here it seems > that this message comes about because Rhino is trying to compile my > script into a Java class but is reaching a JVM limit of 64KB for a method. > > The file I'm trying to load is here[2]. The web server returns Not Found for [2] > The file is actually only 55KB, > so why is the compiled version greater than 64KB? The reason for the compiled classes been bigger then the source is that JVM byte code is very inefficient for initializing data structures. > Now there's nothing I > can really remove from the file, as I need those big tables. Is there > anything I can do to get this working? The simplest solution would be to split your arrays into few smaller data structures defined in different JS functions so each of them would fit the limit. Another solution is to put your data array as CDATA of some DOM node and then use a small JS driver to extract and parse them. It probably would produce fastest to load and execute scripts as well. > I thought I remembered seeing > something about making Rhino just interpret files rather than try to > compile them into Java, but I'd like to avoid putting this burden on the > users of my code. Rhino always uses interpreted mode for scripts inside eval so if you load somehow your script source into JS string and then call eval on it it should allow to exceed 64K limit. Regards, Igor .