[Jsr308-statements] use cases for the annotations on code blocks
and statements
Eugene Kuleshov
eu at javatx.org
Sun Feb 4 00:24:59 EST 2007
Hi,
I would like to start collecting possible use cases for the
annotations on code blocks and statements.
Doug Lea gave great example for parallel execution [1]. In short the
idea is to allow to transform the following code to improve execution
characteristics:
@ParallelAccumulator int sum = 0;
@Parallelizable for(Student s : students) sum += s.credit;
Decisions on those transformations can be delayed till execution and
transformation could take into the account characteristics of the actual
environment. In some cases runtime may allow to execute certain methods
in parallel:
@Parallelizable {
methodA();
....
methodX();
}
Further exploiting this idea to the distributed computing, if
"students" collection in the above example is partitioned across several
nodes, it is useful to transfer loop code block to the nodes holding
particular subsets of collection and at the end return result back to
the caller for aggregation. And things like that can be also done by the
code transformations, unloading source code complexity from the developer.
Another example is continuations. There are at least two continuation
engines for Java that allow to suspend and resume method execution in
the middle of method (RIFE [2] and Javaflow [3]) that allows very
compact and readable code for defining execution floe. They both are
using special method naming convention to control transformations for
the execution flow. It would be better to use annotations for that purpose.
Thoughts, comments and other use cases and examples are really
appreciated.
regards,
Eugene
[1] https://lists.csail.mit.edu/pipermail/jsr308/2007-February/000152.html
[2] http://rifers.org/wiki/display/RIFECNT/Home
[3] http://jakarta.apache.org/commons/sandbox/javaflow/
More information about the Jsr308-statements
mailing list