eclipsebirt

Eclipse BIRT - Java bytecode compilation done at compile time or runtime?


Does the JavaScript to Java bytecode compilation happen at runtime? It seems to be so.

Because when I build the project with gradlew build, I do not see any errors or warnings related to Eclipse BIRT.

I only got the following error when I called a REST endpoint to generate a report:

-----
A BIRT exception occurred. See next exception for more information.
Encountered code generation error while compiling function "39": generated bytecode for method exceeds 64K limit.
org.eclipse.birt.data.engine.core.DataException: Fail to execute script in function __bm_FETCH(). Source:
------

Is it possible to know beforehand which scripts are exceeding the 64K limit? Because there are quite a lot of scripts (20+) to manually test for


Solution

  • BIRT reports are just XML files. The Javascript is stored as text inside them (or in separate *.js files). At runtime, the Rhino Javascript engine (a Javascript implementation written in Java) compiles the scripts to Java bytecode. Note that you can store utility code which you need in several reports in *.js files (see the ressources property tab for the report properties).

    BTW because BIRT only supports (most of) the old ECMAScript 5 standard, and because JS itself is not well-suited for complex code (in comparison to e.g. Typescript), I'd recommend to avoid large scripts if possible.

    Manually testing if 20-30 script in reports are working shouldn't take long. Creating a test programs that tries to check this automatically is much more work. I'd recommend automating this only if you expect to switch BIRT and Java releases on a regular base. But OTOH you can just create a test script that runs all these reports and tests if they work as expected.