hi all,
does anyone know much about the FESI interpreter ??? i am getting an error while using this third party product (GTX) which is written in java and i cant work out whats wrong. FESI is built into this product which i am using so i dont know the details of how it interprets the script which i write.

error that gets thrown is :


[8/07/09 10:36:23:755 NZST] 133e76d ExceptionUtil E CNTR0020E: Non-application exception occurred while processing method "onInput" on bean "BeanId(GTX_Test#GTXEJB.jar#GTProcessEngineEJB , 1225754b587)". Exception data: java.lang.StackOverflowError
at com.gtnet.pk.ecmas.extensions.GTDecimalPrototype.g etDefaultValue(GTDecimalPrototype.java:287)
at FESI.Data.ESObject.getDefaultValue(ESObject.java:4 99)
at FESI.Data.ESObject.toESPrimitive(ESObject.java:667 )
at FESI.Interpreter.EcmaScriptEvaluateVisitor.equal(E cmaScriptEvaluateVisitor.java:310)
at FESI.Interpreter.EcmaScriptEvaluateVisitor.equal(E cmaScriptEvaluateVisitor.java:310)


this error gets thrown when i try and reference a field from a user defined object e.g if( dbObject.ID == 0) but it works fine when :

var tmpID = dbObject.ID [B]+ 0[/B] ;

if(tmpID == 0) ......

any help to understand how/why the above works would be much appreciated.

ta.

Recommended Answers

All 6 Replies

I'm not sure of your level of experience so I'll post this just in case you don't know stack issues, which you may:

http://en.wikipedia.org/wiki/Stack_overflow

hey thanks for the reply. I know about the logic behind stackoverflow error but what i cant understand is why does it throw this error on that particular line of code ?? its not even in a loop of any sort so i dont see a large stack of memory being built.

and why does it work if i declare a local variable and assign it the same value as before ??

once again thanks for your reply.

...and why does it work if i declare a local variable and assign it the same value as before ??

Hi

When you assign a local variable the value of the object and ask for a comparison to 0 whit the operator == the two values are compared.
When you ask for the same thing to be done whit the object, and uses the operator [B]==[/B] what you compare is not the value of the object but the objects referents (address) compared to 0.
If you want the value in the object to be compared to 0 then you have to use the method equals() instead of the == operator.

Hope this will give some help.
Good luck =)

Hi

When you assign a local variable the value of the object and ask for a comparison to 0 whit the operator == the two values are compared.
When you ask for the same thing to be done whit the object, and uses the operator == what you compare is not the value of the object but the objects referents (address) compared to 0.
If you want the value in the object to be compared to 0 then you have to use the method equals() instead of the == operator.

Hope this will give some help.
Good luck =)

hi,
this makes sense but (theres always a but :) ) why would it compare address of the object when i have used the dot operator to reference the attribute of the object i.e ID ??

so the object is 'dbObject' which holds an "attribute" named 'ID'. if i want to get the value of ID it is common in java to use the dot operator like dbObject.ID which gives you the value of the ID rather than the address.

Please correct me if i am wrong.

however its all happy when i declare a local variable and assign this variable the same value as above with a '+ 0' i.e

var tmpID = dbObject.ID + 0;

Even if it was comparing address of the object why would it cause stack overflow error ?

i cant make sense of this so need you good people to help.

>any help to understand how/why the above works would be much
>appreciated.

The problem you are facing could be very well because of a broken library implementation.

From what I can make out of the stacktrace, the implementation blows up when trying to convert the value of your object field i.e. ID to a primitive. Also given that it *works* when you add a zero to the ID field, I guess that there is some kind of implicit coercion taking place which makes the entire comparison *work* somehow.

Again, this is all guesswork and would be best answered on the forum for that given third party library. You can try printing out the value of "tmpID" in the second case; what does it give? NaN? Does printing out the value "dbObject.ID" cause the same stackoverflow issue?

>any help to understand how/why the above works would be much
>appreciated.

The problem you are facing could be very well because of a broken library implementation.

From what I can make out of the stacktrace, the implementation blows up when trying to convert the value of your object field i.e. ID to a primitive. Also given that it *works* when you add a zero to the ID field, I guess that there is some kind of implicit coercion taking place which makes the entire comparison *work* somehow.

Again, this is all guesswork and would be best answered on the forum for that given third party library. You can try printing out the value of "tmpID" in the second case; what does it give? NaN? Does printing out the value "dbObject.ID" cause the same stackoverflow issue?

thanks for the reply. Printing the value of 'dbObject.ID' causes stackoverflow error as well. unfortunately going back to the 3rd party would mean paying them lots and lots of $$$.

Anyway i think you are right that there is some casting error behind the scenes in the libraries which is causing this error. Just cant figure out where.

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.