build identifier: birt runtime 2.5.1 (don't know where build id is accessible)

we are getting an issue with mozilla rhino classes not getting
initialized properly with birt. if birt is started before any
other code accesses rhino classes then the problem occurs. if code other
than birt accesses rhino classes first, then the problem does not occur.

the context class is not fully resolved. accessing static members that should have values return null. osgilauncher.java has a workaround for classpath issues in weblogic. this workaround is contributing to the issue, but doesn't appear to   be the cause. if the workaround is removed or changed to initialize the classes in addition to loading them, then the issue doesn't occur.

jvm: java(tm) se runtime environment (build 1.6.0_14-b08) server / client

i'll attach a newsgroup conversation with jason weathersby that has additional information.

this can be worked around by initializing the three rhino classes that birt loads in osgilauncher before birt is started by the webapp.



reproducible: always

steps to reproduce:
1. start birt via org.eclipse.birt.core.framework.platform.startup(config);
2. system.out.println("context.emptyargs -> " + org.mozilla.javascript.context.emptyargs); 
3. expected to print an object array, instead it prints null for "emtptyargs"
created an attachment (id=156001)
newsgroup conversation
i can't reproduce this bug in 2.5.1 and 2.6.0.

what i did was to deploy birt runtime in tomcat and wrote following statement in a jsp file:
<%
platformconfig platformconfig = new platformconfig();
org.eclipse.birt.core.framework.platform.startup(platformconfig);
%>
context.emptyargs -><%=org.mozilla.javascript.context.emptyargs%>

and the result was like follows:
context.emptyargs ->[ljava.lang.object;@1338d3d.

russ, how did you run the code, in a servlet? can you tell us more detailed information about the whole process?
i was running it from a webapp on jetty 6.1.8. 

other info:
jdk 1.6.0_14
linux 2.6.31-20-generic-pae #58-ubuntu smp fri mar 12 06:25:51 utc 2010 i686 gnu/linux


i'll see if i can create a simple test case to reproduce the issue.
created an attachment (id=165429)
test case
created an attachment (id=165430)
test case
created an attachment (id=165431)
test case
created an attachment (id=165432)
test case zip
i was able to create a simple test case. the key to reproducing was to generate some reports after starting the platform and before accessing the rhino context.

our birt helper util, runs a sample report for all the possible supported output formats to determine what output formats are available at runtime right after calling org.eclipse.birt.core.framework.platform.startup(...).

steps to reproduce:

* start birt platform
* run report(s)
* access org.mozilla.javascript.context.emptyargs

see the attached test case for a working example. 

dependencies of test case:

* birt 2.5.1 runtime libraries (birt_home/reportengine/lib/*jar)
* outputformat_check.rptdesign (included in zip file)

arguments of test case:
 -server
 -dbirt_home=/${some_path}/birt-runtime-2_5_1/reportengine


i ran this on eclipse 3.5 with jdk 1.6.0_14.
1. it occurs if org.mozilla.javascript.scriptruntime.contextclass is accessed before org.mozilla.javascript.context. following simple code can reproduce this bug:
	system.out.println( scriptruntime.contextclass );
	system.out.println( context.emptyargs );

check the definition of the 2 classes we can figure out how could this happens:
scriptruntime defines as follows:
    a) public final static class
        contextclass
            = kit.classornull("org.mozilla.javascript.context"),
    b) public static final object[] emptyargs = new object[0];
context defines empltyargs as follows:
    c) public static final object[] emptyargs = scriptruntime.emptyargs;

so, if scriptruntime.contextclass is accessed first, the sequence of above 3 statements will be a/c/b. therefore the context.emptyargs is initialized as null in statement c because b is not executed yet.

2. model registers functions into scriptruntime without invoke context.enter() in org.eclipse.birt.report.model.simpleapi.reportdesign, line 369. to fix this bug, the statement should be like follows:
	contextfactory.getglobal( ).entercontext( );
	try
	{
          	this.definefunctionproperties( tmparray, this.getclass( ), dontenum );
	}
	finally
	{
		context.exit( );
	}
fix the class load issue according to ouyang's comment.
verified.
platform.startup->run report->platform.shutdown->
system.out.println("context.emptyargs:"+context.emptyargs);

return like '[ljava.lang.object;@1c3432a' instead of null,close it