| << §9 Value Dependent Classes | ↑ Table of Contents ↑ | §B Changes between versions >> |
The following grammar rules extend the Java grammar given in the
Java Language Specification.
We adopt the conventions of printing non-terminal symbols in italic font
(e.g., ClassDeclaration),
and terminal symbols in roman font (e.g., class).
Names printed in black refer to definitions from the original Java grammar.
Object Teams additions are printed in blue boldface.
For those rules that simply add a new option to an existing rule,
the original options are indicated by an ellipse (...).
The keywords introduced by OT/J have different scopes, which means outside their given scope these keywords can be used for regular identifiers. Only these names are keywords unconditionally:
readonly, team, within
The following names are keywords in OT/J only if they appear within a team or role class, ie., after the keyword team has been recognized:
as, base, callin, playedBy, precedence, tsuper, with, when
These names are keywords only in the context of a callin or callout binding respectively (§A.3):
after, before, replace, get, set
While regular Java classes may use the scoped keywords (§A.0.1) of OT/J freely, it is an error if a role class inherits a feature whose name is a scoped keyword.
Compiler and runtime environment generate internal methods and fields which start with
the prefix _OT$. It is illegal to use any of these methods and fields within client code.
Class definitions add two new keywords team and
playedBy. Classes which use these keywords are called
teams and bound roles, respectively.
Any class that inherits from a bound role class (either by an
extends clause or by implicit inheritance, cf.
§1.3.1.(c)) is again a bound role class.
| § A.1.1 | ClassDeclaration [Modifiers] [team] class Identifier [extends Type] [implements TypeList] [playedBy Type] [Guard] ClassBody |
playedBy clause (a bound
role class) may not be declared static and
must be directly contained in a class that has the
team modifier (a team class).
team modifier, too.
The rule for method modifiers adds one keyword: callin:
| § A.2.1 | Modifier ... callin |
callin modifier
may not be declared static and must be directly contained in a team class.
callin modifier may not
appear in an explicit method call (rule Apply in JLS).
The rule of items declarable in a class body is augmented by method bindings:
| § A.3.1 | ClassBodyDeclaration ... CalloutBinding CallinBinding |
| § A.3.2 | CalloutBinding MethodSpec CalloutKind MethodSpec CalloutParameterMappings MethodSpec CalloutKind CalloutModifier FieldSpec |
| § A.3.3 | Callin binding [ Identifier : ] MethodSpec <- CallinModifier MethodSpecs [Guard] CallinParameterMappings |
| § A.3.4 | MethodSpec Identifier ResultType MethodDeclarator |
| § A.3.5 | MethodSpecs MethodSpec [, MethodSpecs] |
| § A.3.6 | CalloutKind -> => |
| § A.3.7 | CallinModifier before after replace |
| § A.3.8 | CalloutModifier get set |
| § A.3.9 | FieldSpec [Type] Identifier |
CalloutBindings and CallinBindings
may occur only in bound role classes.
CalloutBinding or CallinBinding
may not mix identifiers and full signatures (MethodDeclarationHead)
for its method specifiers (MethodSpec).
FieldSpec
to include the Type.
CallinBinding which has the replace modifier
must refer to a method that has the callin modifier.
| § A.4.1 | CalloutParameterMappings with { CalloutParameterMappingList [,] } ; |
| § A.4.2 | CallinParameterMappings with { CallinParameterMappingList [,] } ; |
| § A.4.3 | CalloutParameterMappingList CalloutParameterMapping [, CalloutParameterMappingList] |
| § A.4.4 | CallinParameterMappingList CallinParameterMapping [, CallinParameterMappingList] |
| § A.4.5 | CalloutParameterMapping Expression -> Identifier result <- Expression |
| § A.4.6 | CallinParameterMapping Identifier <- Expression Expression -> result |
| § A.5.1 | Statement ... Within BaseCall TSuperCall |
| § A.5.2 | Within within ( Expression ) Statement |
| § A.5.3 | BaseCall base . Identifier ( Argumentsopt ) base ( Argumentsopt ) |
| § A.5.4 | TSuperCall tsuper . Identifier ( Argumentsopt ) tsuper ( Argumentsopt ) |
Within must evaluate
to an instance of a team class.
BaseCall may occur only
in the body of a method that has the callin modifier.
The identifier must be the name of the enclosing method.
BaseCall may occur only in a constructor of a
bound role class.
TSuperCall may occur only in a method of
a role class.
TSuperCall may occur only in a constructor of a
role class.
| § A.6.1 | Type ... LiftingType AnchoredType |
| § A.6.2 | LiftingType Type as Type |
| § A.6.3 | AnchoredType Path.Type |
| § A.6.4 | Path Identifier Path.Identifier |
LiftingType may only occur in the parameter list
of a method of a team class.
LiftingType
must be a class directly contained in the enclosing team class
(the class may be acquired by implicit inheritance (§1.3.1.(c))).
AnchoredType must refer to an instance of a team class.
Each identifier in the path must be declared with the final modifier.
| § A.7.1 | Guard [base] when ( Expression ) |
| § A.7.2 | MethodDeclaration ... MethodHeader [Guard] MethodBody |
Other rules referring to Guard:
ClassDeclaration (§A.1.1),
CallinBinding (§A.3.3)
Expression in a guard must have type boolean.
| § A.8.1 | PrecedenceDeclaration precedence CallinNameList ; |
| § A.8.2 | CallinNameList Name [, CallinNameList] |
| § A.9.1 | TypeParameter TypeVariable [TypeBound] ReferenceType Name |
See JLS 3 §4.4
| § A.9.2 | ActualTypeArgument ReferenceType Wildcard @Name |
See JLS 3 §4.5.1
ActualTypeArgument of the form @Name may only occur
as a parameter of a simple name type reference.
| § A.10.1 | PackageDeclaration ... team QualifiedName ; |
| § A.10.2 | Import ... import base QualifiedName ; |
| << §9 Value Dependent Classes | ↑ Table of Contents ↑ | §B Changes between versions >> |