Semantics : JavaExtensionDefinition
The Java extension mechanism allows Java classes to be extended and/or interfaces implemented in
JudoScript. The extends java :: clause can have one Java class (must be the first) and any number
of Java interfaces.
The content of a Java extension class is not the same as regular JudoScript classes. These are the points:
- A Java extension class is defined with the extends> java :: clause,
which can take zero or one Java class and any number of Java interfaces, all separated
by comma. The resultant class is a Java class with that name without any package names.
- Methods are declared with Java return type and Java-typed parameters just like Java
methods; fields are declared with Java types like Java. No access control can be
specified as they are always public; they can never be static. Methods are never
declared with exceptions.
- Method bodies are implemented in JudoScript code. The parent class's methods, public or
protected, can be invoked by the super decorator. You can also invoke own
methods, and access this and parent's data fields, public or protected.
- When abstract methods from the parent class/interfaces are not explicitly implemented,
they are given empty bodies, so the resultant Java class can be instantiated.
- Data fields can be initialized only in the constructor.
- There can be up to one constructor in a Java extension class. This constructor may
take untyped, JudoScript parameters. Within the constructor, there must be one and only one
invocation of
super()
, which is one of the parent class's constructors.
This call must precede data member initializations and invocations of any other
methods.