Hi,
I've just upgraded from 1.5R4 to 1.7R1 and some scripts that used to
compile now no longer compile.
My code is pretty much as follows:
context.setGeneratingDebug( true );
context.setOptimizationLevel( 0 );
this.script = context.compileReader( reader, fileName, 1, null );
Then I call a function multiple times on the same script, throwing the
scope away after each execution:
Scriptable scope = new ImporterTopLevel();
this.script.exec( context, scope );
Object functionObject = scope.get( functionName, scope );
if ( functionObject instanceof Function )
{
Function function = (Function)functionObject;
function.call( context, scope, null, args );
}
The first question is whether this usage is acceptable. I want to
reuse the compiled code to save perm gen space and compilation time.
I need to throw away the scope between executions to save heap space
between function calls.
Some of my scripts don't compile properly any more. The error I get
is when I call compileReader:
java.lang.VerifyError: (class: org/mozilla/javascript/gen/c3, method:
_c1 signature: (Lorg/mozilla/javascript/gen/c3;Lorg/mozilla/javascript/
Context;Lorg/mozilla/javascript/Scriptable;Lorg/mozilla/javascript/
Scriptable;[Ljava/lang/Object;)Ljava/lang/Object;) Accessing value
from uninitialized register 9
at java.lang.Class.getDeclaredConstructors0(Native Method)
at java.lang.Class.privateGetDeclaredConstructors(Class.java:2389)
at java.lang.Class.getConstructor0(Class.java:2699)
at java.lang.Class.newInstance0(Class.java:326)
at java.lang.Class.newInstance(Class.java:308)
at
org.mozilla.javascript.optimizer.Codegen.createScriptObject(Codegen.java:
106)
at org.mozilla.javascript.Context.compileImpl(Context.java:2293)
at org.mozilla.javascript.Context.compileReader(Context.java:1202)
at org.mozilla.javascript.Context.compileReader(Context.java:1174)
I've isolated the part of the script that causes the error (below).
If I remove one of the inner-most try-catch errors, the error
disappears. If I remove the finally section, the error also
disappears. I don't see anything obviously wrong with the code, so is
this a bug?
Thanks,
Nathan
/**
* Checks whether the business exists in the system
*/
function isBuyerBusinessRegistered(p_communityMemberCode, p_buyerFlag,
p_communityCode)
{
//
// Return values from SP
//
var v_id_business;
var v_fl_exists;
var v_NO_error;
if ( g_testMode == "true" )
{
return 1;
}
g_log.logInfo( "Checking if business registered with parameters
p_communityCode '" + p_communityCode + "' and p_communityMemberCode '"
+ p_communityMemberCode + "' and p_buyerFlag '" + p_buyerFlag +
"'" );
try
{
try
{
//
// Get the connection that we will be working with in this
scope
//
g_conn =
DBConnectionManagerFactory.getDBConnectionManager().getConnection();
g_sql = "{ call " + g_spBusExists +
"( ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ? ) }";
g_stmt = g_conn.prepareCall( g_sql );
//
// Call the Stored Procedure
//
//1 (p_CD_community IN community.CD_community
%TYPE,
//2 p_CD_business IN
community_member.CD_buyer_business%TYPE,
//3 p_FL_buyer_business IN NUMBER DEFAULT 1,
//4 p_NO_error OUT NUMBER,
//5 p_ID_business OUT business.ID_business
%TYPE,
//6 p_NM_business OUT business.NM_business
%TYPE,
//7 p_TX_EMAIL OUT business.TX_email%TYPE,
//8 p_ID_ADDRESS OUT business.ID_address%TYPE,
//9 p_ID_ADDRESS_DELIVERY OUT
business.ID_address_delivery%TYPE,
//10 p_TX_PHONE OUT business.TX_phone%TYPE,
//11 p_TX_FAX OUT business.TX_fax%TYPE,
//12 p_CD_INVOICE_TEMPLATE OUT
business.CD_invoice_template%TYPE,
//13 p_NM_CONTACT OUT business.NM_contact
%TYPE,
//14 p_TX_COMMENT OUT business.TX_comment
%TYPE,
//15 p_FL_ENABLED OUT business.FL_enabled
%TYPE,
//16 p_AM_CREDIT_LIMIT OUT business.AM_credit_limit
%TYPE,
//17 p_CD_DIVISION OUT business.CD_division
%TYPE) AS
g_stmt.setString( 1, p_communityCode );
g_stmt.setString( 2, p_communityMemberCode );
g_stmt.setString( 3, p_buyerFlag );
g_stmt.registerOutParameter( 4 , java.sql.Types.INTEGER );
g_stmt.registerOutParameter( 5 , java.sql.Types.VARCHAR );
g_stmt.registerOutParameter( 6 , java.sql.Types.VARCHAR );
g_stmt.registerOutParameter( 7 , java.sql.Types.VARCHAR );
g_stmt.registerOutParameter( 8 , java.sql.Types.VARCHAR );
g_stmt.registerOutParameter( 9 , java.sql.Types.VARCHAR );
g_stmt.registerOutParameter( 10 , java.sql.Types.VARCHAR );
g_stmt.registerOutParameter( 11 , java.sql.Types.VARCHAR );
g_stmt.registerOutParameter( 12 , java.sql.Types.VARCHAR );
g_stmt.registerOutParameter( 13 , java.sql.Types.VARCHAR );
g_stmt.registerOutParameter( 14 , java.sql.Types.VARCHAR );
g_stmt.registerOutParameter( 15 , java.sql.Types.INTEGER );
g_stmt.registerOutParameter( 16 , java.sql.Types.VARCHAR );
g_stmt.registerOutParameter( 17 , java.sql.Types.VARCHAR );
g_stmt.execute();
}
catch( ex )
{
iCISScriptExceptionUtil.handleException( "Could not lookup
community member '" + p_communityMemberCode + "' using stored
procedure.", ex );
}
try
{
//
// Get the result
//
v_id_business = g_stmt.getInt( 5 );
v_NO_error = g_stmt.getInt( 4 );
v_fl_enabled = g_stmt.getInt( 15 );
g_defaultEmail = g_stmt.getString( 7 );
//g_log.logInfo( "Method returned: v_id_business '" +
v_id_business + "'\n" +
// " v_NO_error '" + v_NO_error
+ "'\n" +
// " v_fl_enabled '" +
v_fl_enabled + "'"
// );
g_buyerBusinessId = v_id_business;
//return v_fl_exists;
if ( v_fl_enabled == 1 && v_NO_error == 0 )
return 1;
else
return 0;
}
catch( ex )
{
iCISScriptExceptionUtil.handleException( "Could not retrieve
return parameters from stored procedure for community member '" +
p_communityMemberCode + "'.", ex );
}
}
catch( ex )
{
// dont do anything on an error, just return null for the business
number
// and it will go out in the BAM
iCISScriptExceptionUtil.handleException( "Failed to find business,
exception encountered", ex);
//return null;
}
finally
{
try
{
g_stmt.close();
}
catch ( ignored ) { }
try
{
g_conn.close();
}
catch ( ignored ) { }
}
}
_______________________________________________
dev-tech-js-engine-rhino mailing list
[email protected]
https://lists.mozilla.org/listinfo/dev-tech-js-engine-rhino