I found a strange problem when I redefine println() in top level, then
call it from a function bellow, it only work for the first time. Then
it will invoke the original one.

/*
 * Redefine println error pattern
 */
util = JavaImporter(com.devx.util);

with(util) {
        function println(str){
                Logger.log(str);
        }
}

jface = JavaImporter(
        org.eclipse.swt,
        org.eclipse.swt.widgets,
        org.eclipse.jface.dialogs.MessageDialog);

with(jface) {
        function inform(msg){
                println('inform: ' + msg);
                Display.getDefault().syncExec(new java.lang.Runnable({
                        run: function () {
                                MessageDialog.openInformation(null, 
'Information', msg);
                        }
                }));
        }
}

inform('Hi~');
inform('Hello!');
inform('Bye~ :p');

Note:
1. If I mark the Display.getDefault().syncExec(...) part of the code.
It will work fine.
2. If I chose not redefined println(). Define the function as log, it
just work fine.

Don't know if this issue is related to Rhino/Java threading model or
Eclipse osgi.
_______________________________________________
dev-tech-js-engine-rhino mailing list
[email protected]
https://lists.mozilla.org/listinfo/dev-tech-js-engine-rhino

Reply via email to