2

I am looking for a tool or api which allows deterministic execution of Java threads for testing purposes. Thus, allowing context switches in java code at certain locations in byte code. For instance, I want a thread t1 to preempt for another thread t2 at say line N in the bytecode/sourcecode and so on. To make the case simpler lets ignore the synchronization or locks. Is there any tool, if possible open source customized JVM available. I am aware of a few tools like dejavu, LEAP but I would like to know about recommended open source tools from some one who has experience with such tools.

Cheers, Pulkit

pto
  • 31
  • 6
  • 2
    Interesting. I usually just set up a bunch of breakpoints and then start and stop threads at-will. But it's tedious, error-prone and definitely not automatable. – Adam Batkin Mar 16 '11 at 05:53
  • check out [Can a multi-threaded program ever be deterministic?](http://stackoverflow.com/questions/3830347/can-a-multi-threaded-program-ever-be-deterministic) – Janus Troelsen Feb 08 '15 at 14:09

2 Answers2

1

I'm not aware of any tools that do exactly what you want, and in general that's going to be tough, simply because JITs etc.. will blur what a "line" means. So you'll either get lousy code that meets your goals, or the real code that won't. Either way bugs could slip through. I'd suggest you look at ConTest for a good perspective on how testing in this general area can be done.

Trent Gray-Donald
  • 2,286
  • 14
  • 17
  • Thanks Trent, Adam. By line I mean, a byte code instruction. Say, I want the thread T1 to pause its execution at say byte code instruction X, and let the another thread T2 to resume the execution from where ever it paused, or beginning if it is supposed to start. I remember reading about ConTest, but I don't think its opensource. – pto Mar 18 '11 at 14:52
  • The JIT certainly will change what it means to be on "bytecode instruction X". And yes, ConTest isn't open source, but I've not seen anything closer to what you want than that, sorry... – Trent Gray-Donald Mar 24 '11 at 13:42
0

Here's a comparison of different solutions: http://sites.fct.unl.pt/sites/default/files/synergy-vm/files/2013-middleware-silva.pdf

Janus Troelsen
  • 20,267
  • 14
  • 135
  • 196