|
From: niceguy <ni...@ab...> - 2000-12-08 14:28:10
|
Yes, I am trying to combine all the items in the subject in a single project. :) I've bumped into a very specific problem, which may or may not be Mingw related, and I'd like to bounce it off of the various experienced Mingw users here in hopes of finding a solution. I'm a programmer by hobby, not by trade, so the more specific the advice the better. Some background: I have a third party application developed with MFC. Specifically it is a CAD application for mechanical design (my actual profession). This application exposes portions of its API via COM. My primary area of programming experience is Java, so I have been working on porting the entire CAD application COM API to a more OO, simpler, Java API using JNI to act as a bridge from Java to COM. To use the COM interfaces, the CAD application requires that the code be contained in a DLL which is then loaded into the CAD application's process, in a fashion similar to Add-Ins for Word, Excel, etc. To meet this restriction, I simply created a C++ DLL which adds some menu items ot the CAD application. These menu items can be used to start the Java Virtual Machine via JNI, and run various Java applications which can call back into the COM API. The current situation: The API porting and add-in DLL issues are resolved, and I am left with the task of testing my Java API for correctness and stability. Since I'm dealing with 100 classes with several thousand methods in total, I went looking for a testing tool that could automate some of this. There is a unit testing package called JUnit which fits my needs quite nicely, providing a GUI to run various tests and assess the output. It was a trivial task to have my JNI DLL provide a menu item in the CAD application which could be used to start the JUnit application. The problem: When I start the JUnit application and attempt to run tests, I get a spectacular crash from the MS C++ runtime. After much fiddling and debugging, I have determined that the crash only happens when a thread other than the the main thread of the Java application makes a call to the COM interface of the CAD application. If I start the JUnit program and pass in the name of a test to run, the test completes successfully. If I select the test from a list in the GUI and try to run it, the crash occurs, because the code is running in the Java event dispatch thread. If I create a new thread from inside the main thread and run tests, the crash occurs. So it is definitely thread-related. This problem essentially means that no Java application with a GUI can be used to interact with the CAD application, which is a restriction I would rather not have, for obvious reasons. The question: Are there any specific issues related to COM and threads in the context of a DLL compiled with Mingw? Is there anything special I should be doing when compiling and/or linking? Any/All assistance appreciated, Jim S. |