From: Peter C. M. <Pet...@na...> - 2008-09-11 16:56:20
|
it doesn't have to be a static field. Your listeners are created outside of JPF, so you can pass whatever shared object you want into their constructors: .. Config conf = JPF.createConfig(..) SharedData shared = ... Listener1 l1 = new Listener1(conf,..shared..); Listener2 l2 = new Listener2(conf,..shared..); JPF jpf = new JPF(conf); jpf.addListener(l1); jpf.addListener(l2); jpf.run(); .. A generic per-run object in the JPF instance wouldn't work because Listeners shouldn't be forced to know about each other, and could therefore easily compete for this field. So even if you need to share data between a native peer (static methods) and a listener, this requires a per-run registry, and we already have one - Config. You can stick whatever object you want in there, it's just a Hashtable. Just make sure it doesn't contain a conflicting key before you do so. -- Peter On Sep 11, 2008, at 6:02 AM, Michal Kebrt wrote: > I don't like the idea of a static field very much and will explain > why. Suppose I have a JPFJUnit class which is a wrapper above JPF > +JUnit and runs JUnit under pathfinder through the JPF class. > JPFJUnit will be used from different kinds of applications to embed > the test framework - e.g. from Eclipse plugin or Ant task. > > What happens when a JPFJUnit's static field is used for > communication with JUnit's listener peer and is launched twice (e.g. > on different test cases in Eclipse plugin) at the _same moment_. > Then both peer instances will forward information to the same static > field. I don't like this. > > I would like to have so called JPFJUnitListener that will receive > information from both JPF and JUnit listeners. It could be used from > a plugin in the following way: > > JPFJUnit jpfjunit = new JPFJUnit(); > // do some config on jpfjunit > jpfjunit.addListener(new MyJPFJUnitListener()); > jpfjunit.run() { > jpf = new JPF(); > // do some config on jpf > jpf.setTag(listeners); > jpf.run(); > } > > Michal > > Peter C. Mehlitz wrote: >> Since this object would only be processed by your own listeners/ >> native peers, why don't you pass it directly between them (e.g. by >> using a static field)? >> -- Peter |