Yesterday, I made the first version of the Thread Checker available on the Concutest website. It is just one jar file,
tcrt.jar, that contains both the classes for the annotations and the classes for rewriting class files (on-the-fly and offline) to check the invariants. I think in the future, I will separate this into two archives in order to keep the jar file with the annotations, the one that will have to be linked with user programs, as small as possible.
I also didn’t post any instructions yet. There are many examples available in this blog (e.g. here, here, here, here, here, and here), but no description on how to invoke the Thread Checker for on-the-fly instrumentation or how to rewrite the class files offline. I still have to do that.
I also realized that I need to check how the features of making backups, saving the instrumented version of a class, and writing auto-generated class files for
@Combine-style annotations behave when the source class file is in a jar file. I think for the first two, backups and writing to disk, I will simply not perform these tasks if the class came from a jar file. I don’t want to rewrite the entire jar file; if caching or backups are important, then the jar file should be instrumented offline.
The auto-generated class files are more difficult to handle: I think I will have to stipulate that there needs to be at least one directory on the class path, and auto-generated class files will be placed there unless some other directory is specified. Another, perhaps better, possibility would be to try to load the automatically generated class files immediately from a byte array instead of first writing it to disk. That would allow classpaths that do not have any directories in them, but of course, it also disables caching.
I also need to continue the work on the reflection-based predicate Thread Checker. My intuition tells me that it will in general be slower than the thread checks done by rewriting bytecode, but the delay of auto-generating the class files may go away. I definitely need to have this as a comparison.