Accessing Objects from Different Interpreters

Using BBjNamespace, or the static modifier within custom Java classes, the developer can access an object via more than one interpreter at the same time. This creates a multi-threaded environment, in which two (or more) interpreter threads are capable of manipulating an object at the same time. However, manipulating objects in this manner is not safe for all Java objects. Avoid modifying an object from two different threads at the same time, commonly known as concurrent modification.

Additionally, since it is impossible to know the timing of two threads running without coordination between one another, it is possible that the object can change in between two sequential lines of code within any given interpreter. This can causes logical errors in your program. To avoid this, use a locking strategy. The BBjNamespace provides such a mechanism.

For example, to perform an update on a shared object, follow these steps:

1.   Get a lock on the BBjNamespace entry via the setLock method.

2.   Get the object from the BBjNamespace via the getValue method.

3.   Change the object via some modifying method.

4.   Update the object in the BBjNamespace via the setValue method.

5.   Remove the lock via the removeLock method.

6.   Null out any reference to the object or the object's children to prevent accidental, unsynchronized access.

A foreign interpreter is an interpreter who does not own the object it is trying to access. Typically, the owner of an object is the interpreter who created the object via a call to the BBjAPI().

Objects created via the BBjAPI() throw an !ERROR 208 Multi Thread when methods are invoked by a foreign interpreter.

Exceptions to this rule are the BBjSysGui and objects created via the BBjSysGui.

If a foreign interpreter retrieves a SysGui object foo! from a BBjNamespace, and a call on foo! creates an object bar, ie: bar! = foo!.createObject(); then the interpreter that owns bar! also owns foo!

A foreign interpreter is prohibited from calling the following methods:

BBjSysGui.createPopupMenu(int resHandle, int popupMenuID)

BBjSysGui.createTopLevelWindow(int resHandle, int windowID)


BBjControl.clearCallback(int eventType)

BBjControl.setCallback(int eventType, string subRoutineName)

RecordSetBindable.bindRecordSet(BBjRecordSet recordset, string fieldname)


RecordSetFillable.fillFromRecordSet(BBjRecordSet recordSet, string fieldname)

BBjStandardGrid.convertToDataAware(int channel, string template)

BBjDataAwareGrid.setDataChannel(int channel, string template)

A foreign interpreter can not call any method of a BBjTemplatedString.

An object whose owner does not match the owner of the parameter object is prohibited from calling on the following methods:

BBjControl.setPopupMenu(BBjPopupMenu popupMenu!)

BBjTabCtrl.addTab(string title, BBjControl control!)

BBjTabCtrl.addTab(string title, int imgIndex, BBjControl control!)

BBjTabCtrl.insertTab(int index, string title, BBjControl control!)

BBjTabCtrl.insertTab(int index, string title, int imgIndex, BBjControl control!)

BBjTabCtrl.setControlAt(int index, BBjControl control!)

BBjStandardGrid.setCellListControl(int row, int column, BBj ComboBoxlist)

BBjStandardGrid.setColumnListControl(int column, BBj ComboBoxlist)

BBjSplitter.setFirstControl(BBjControl control)

BBjSplitter.setFirstControlID(int id)

BBjSplitter.setSecondControl(BBjControl control)

BBjSplitter.setSecondControlID(int id)