I am using JNI (created with Swig) to convert from my internal format to DWG.
When I read a particular file I get the following error:

-----output cut above------
Conversion to DB finished

write database to file

============== OdError Caught =============
Description: Was open for write object: (1B3B)

=============== WHERE START ===============
symname: OdStringArray_indexOf
overname:
wrapname: Java_com_opendesign_core_GlobalsJNI_OdStringArray_ 1indexOf
decl: OdArray< OdString,OdObjectsAllocator< OdString > >::indexOf(OdString const &) const
fulldecl: int OdArray< OdString,OdObjectsAllocator< OdString > >::indexOf(OdString const &) const
=============== WHERE END ===============

Exception in thread "ModalContext" com.opendesign.core.OdError
at com.opendesign.td.TD_DbJNI.OdDbDatabase_writeFile_ _SWIG_4(Native Method)
at com.opendesign.td.OdDbDatabase.writeFile(OdDbDatab ase.java:382)
at com.performanceplanningsystem.dataformats.DWG.Teig haWrite.writeDWG(TeighaWrite.java:144)
at com.performanceplanningsystem.site.Site$LoadSave$2 .save(Site.java:17678)
at com.performanceplanningsystem.site.Site$LoadSave.l oadSave(Site.java:17927)
at com.performanceplanningsystem.site.Site$LoadSave.s ave(Site.java:18028)
at com.performanceplanningsystem.site.Site$LoadSaveSi te.run(Site.java:18164)
at org.eclipse.jface.operation.ModalContext$ModalCont extThread.run(ModalContext.java:121)
Which seems like some sort of programming error on my part. To figure out where object 1B3B was created, I added some java diagnostics and got the following line (plus a bunch of other diagnostics above it:

-----output cut above------
TeighaWrite.putNextElement LINE objId 1B3A
Conversion to DB finished
-----same error message cut below------
Obviously the program is not giving me enough info so I added the following at line 5461 of TeighaWrite.java
 PPS.diagnose("putNextElement " + type + " points " + pointList.size());

Then the conversion worked correctly with no errors!!!!

So I commented out the line
 // PPS.diagnose("putNextElement " + type + " points " + pointList.size());

and got the same error (above). I've frequently encountered pointer errors (like this) in C, but not in Java.

Any suggestions about how I can diagnose/fix this?