Safe for Any Thread

Annotating a method with @OnlyRunBy(@ThreadDesc(name=".*")) works to override all other, more narrow annotations and allow all threads to run, as expected. It looks pretty cumbersome, though, and doesn’t allow me to generate adequate warnings.

I think I should introduce a @OnlyRunBy(@ThreadDesc(anyThread=true)) annotation. If such an annotation is found, then the entire @OnlyRunBy can be removed, but warnings should be emited that a superclass annotation overrides subclass annotations: It’s a just another subtyping violation.

Actually… I guess it’s the same as having no annotation at all. So in principle I could just not annotate these methods. It may still be easier to annotate an entire class as @OnlyRunBy(@ThreadDesc(eventThread=true)) and then have @OnlyRunBy(@ThreadDesc(anyThread=true)) annotations for a few methods.

I need to think about this for a while…

Share

About Mathias

Software development engineer. Principal developer of DrJava. Recent Ph.D. graduate from the Department of Computer Science at Rice University.
This entry was posted in Concurrent Unit Testing. Bookmark the permalink.

Leave a Reply