←Older revision |
Revision as of 20:23, 17 February 2009 |
Line 118: |
Line 118: |
| <source lang="java" snippet="design.composition.arith.runtime"/> | | <source lang="java" snippet="design.composition.arith.runtime"/> |
| | | |
- | By doing this inspection the code the requires '''Arithmetica''' behaviour in | + | By doing this inspection the '''Arithmetica''' class can find out what actual version and thus behaviour the code calling into the [[API]] really requires. If the dependency is on anything older than version 2.0 the code will see the old behaviour. Callers compiled against the newer, improved |
- | version older than 2.0 will get it, while those aware of the new, improved | + | |
| '''sumRange''' implementation will benefit from the performance boost. Moreover | | '''sumRange''' implementation will benefit from the performance boost. Moreover |
| there is just one version of the '''Arithmetica''' class in the whole system, | | there is just one version of the '''Arithmetica''' class in the whole system, |
| so there are no problems with multiple ''ghost'' types. | | so there are no problems with multiple ''ghost'' types. |
| + | |
| + | :''The above example assumes that there is 1:1 mapping between a module'' |
| + | :''and a classloader and as such it is easy to iterate the stack and find'' |
| + | :''the dependency information from it. This is the simplest case, good for'' |
| + | :''demonstration purposes. Everything else would just complicate the principle.'' |
| | | |
| This style of providing [[AlternativeBehaviour]]s is not really common in [[Java]] | | This style of providing [[AlternativeBehaviour]]s is not really common in [[Java]] |