4

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).

1
  • To debug a DLL you have to specify a host application (as the message suggests). You can do that via the menu: "Start" - "Parameter". Commented Nov 8, 2009 at 16:04

3 Answers 3

4

I believe the answer for this question would be the same as for Stack Overflow question How to debug a DLL file in Delphi.

In fact, since you debug the Delphi's DLL file within a Delphi environment, it does not matter who is in the higher of the call stack.

Sign up to request clarification or add additional context in comments.

Comments

0

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

Comments

-2

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.

4 Comments

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: 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! :)
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: 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 c2.com/cgi/wiki?UnitTestIsolation

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.