views:

232

answers:

3

With Delphi I wrote a DLL which can be called from Java via JNA (Java Native Access). Methods in this DLL are just simple operations, but for future use and more complex invocations I would like to know how I can use the Delphi debugger, if the DLL is called from Java directly (or from the Java IDE).

+3  A: 

I believe the answer for this question would be the same as for this one. In fact, since you debug the Delphi's dll within a Delphi env. it does not matter who is in the higher of the call stack

Tzury Bar Yochay
I have read them before posting but found that they are to vague, see my additional information above. I will also try with Delphi 2009.
mjustin
A: 

It works if I define the host application (Java) and set the correct arguments:

  • Host Application: C:\Programme\Java\jdk1.6.0_14\jre\bin\java.exe
  • Parameter: -cp "/path/to/test.jar" junit.textui.TestRunner AppTest

The JUnit text TestRunner command line arguments are explained here: http://junit.sourceforge.net/junit3.8.1/javadoc/junit/textui/TestRunner.html

mjustin
A: 

Why not debug the DLL in Delphi first? There's a unit testing framework for Delphi called DUnit. You'll still want to write integration tests for the full system, but you could mock out the external dependency in your JUnit unit tests.

TrueWill
The old proverb says 'the proof of the pudding is in the eating' - by calling the DLL from Java it is possible to analyze errors, for example with wrong data types, pointers and so on. DUnit tests can be used as an additional safety net of course. JUnit tests will cover the integration of the DLL and the related operations on the Java side, and if this integration test fails there is a need to analyze the data flow.
mjustin
@mjustin: I completely agree that you'll want integration tests. All I'm suggesting is testing the classes in isolation (unit tests) in addition to that. You can have your cake and eat it too! :)
TrueWill
If you're mocking out the external dependency (the DLL), then it's not a very good integration test anymore. You've essentially answered the question of how to debug a DLL called by Java by suggesting debugging a DLL *not* called by Java.
Rob Kennedy
@Rob: As I have said twice, this is **in addition** to integration tests. The OP asked about debugging a DLL. Unit tests are a great way to reduce bugs in code. A core principle of unit testing is to test classes (and by extension, DLLs) in isolation. I want my integration tests to just work - because I've already eliminated any bugs via unit testing. See http://c2.com/cgi/wiki?UnitTestIsolation
TrueWill