Release date: 2019-10-26.
Number of major changes : 8
The entire SARL project was tested against the versions 8 and 11 of Java. The version 8 must still be used for running the SARL DSL Environment in order to create SARL libraries that could be used on a JRE 1.8.
For application developers who are using SARL, they could use either Java 8 or Java 11 for running the SARL Development environment, or the SARL applications that are the result of the SARL compilation.
The try-with-resources statement is a try statement that declares one or more resources.
A resource is an object that must be closed after the program is finished with it.
The try-with-resources statement ensures that each resource is closed at the end of the statement.
Any object that implements AutoCloseable
, which includes all objects which implement Closeable
, can be used as a resource.
The following example reads the first line from a file. It uses an instance of BufferedReader
to read data from the file.
BufferedReader
is a resource that must be closed after the program is finished with it:
def readFirstLineFromFile(path : String) : String {
try (var br = new BufferedReader(new FileReader(path))) {
return br.readLine
}
}
In this example, the resource declared in the try-with-resources statement is a BufferedReader
.
The declaration statement appears within parentheses immediately after the try
keyword.
The class BufferedReader
, inherited from Java libraries, implements the interface AutoCloseable
.
Because the BufferedReader
instance is declared in a try-with-resource statement, it will be closed regardless of
whether the try
statement completes normally or abruptly.
When a lambda (also known as closure) has multiple parameters, and no name is provided by the SARL developer, the SARL compiler in its previous version generates an error because it was able to consider only it
as an implicitly declared variable, i.e. there was too many implicit parameter to declare by the compiler and it cannot do that.
In its version 0.10, the SARL compiler is able to a generate default name for each of the formal parameters of a lambda, even if there are multiple unnamed parameters.
The implicit name for the first parameter becomes $0
, $1
for the second, $2
for the third, etc.
The example below shows the definition of an interface, a class that is calling an instance of the previous interface, and a piece of code that is invoking the class. It is interesting to note that the arguments’ values of the lambda expressions are accessed with their implicit names.
interface MyInterface {
def a(a : int, b : char, c : String)
}
class MyClass {
def b(lambda : MyInterface) {
lambda.a(1, '2', "3")
}
}
var i = new Myclass
i.b [
println($0)
println($1)
println($2)
]
The events ParticipantJoined
and ParticipantLeft
are introduced.
The first is fired when an agent has joined a space that has participants, e.g. an event space.
The second is fired when an agent has left a space.
The uses of mutual exclusion locks were replaced by similar uses of read-write locks.
A read-write lock maintains a pair of associated locks, one for read-only operations and one for writing.
The read lock may be held simultaneously by multiple reader threads, so long as there are no writers.
The write lock is exclusive.
The read-write lock implementation guarantees that the memory synchronization effects of writeLock
operations also hold with respect to the associated readLock
.
That is, a thread successfully acquiring the read lock will see all updates made upon previous release of the write lock.
A read-write lock allows for a greater level of concurrency in accessing shared data than that permitted by a mutual exclusion lock. It exploits the fact that while only a single thread at a time (a writer thread) can modify the shared data, in many cases any number of threads can concurrently read the data (hence reader threads). In theory, the increase in concurrency permitted by the use of a read-write lock will lead to performance improvements over the use of a mutual exclusion lock.
Sarldoc is a documentation generator for the SARL language for generating API documentation in HTML format from SARL source code. The HTML format is used for adding the convenience of being able to hyperlink related documents together. To pass source code to sarldoc, you have to provide the names of the folders in which the SARL code files are located. Then, the sarldoc tool generates a set of HTML files that contains the API documentation of your program.
The SARL compiler was reviewed in order to remove several memory leaks that cause low performances when compiling large number of SARL files. Even if this task is always active, several improvements have been obtained in this version of SARL.
Boids is an artificial life program, developed by Craig Reynolds in 1986, which simulates the flocking behaviour of birds. The name “boid” corresponds to a shortened version of “bird-oid object”, which refers to a bird-like object. As with most artificial life simulations, Boids is an example of emergent behavior; that is, the complexity of Boids arises from the interaction of individual agents (the boids, in this case) adhering to a set of simple rules. The rules applied in the simplest Boids world are as follows:
The SARL development environment provides an implementation of the Reynold’s Boids within the set of available “examples.” This version of the Boids is implemented with the Java AWT graphical library.
$0
, $1
for the second, $2
for the third, etc. (details).throw
becomes a statement that has side effect (details).occurrence
is used within complex expressions (details).occurrence
(details). The meaning of previous error message was not enough clear to the SARL developers. The message is refactored in order to be more explicit and clear.release()
function in the GenerationContext
type in order to limit memory leaks (details).0.1
and 0.10
.ParticipantJoined
and ParticipantLeft
, and the associated supported into the SRE (details).getOrCreateSpaceWithSpec
in order to indicate that the default space is ignored (details).Capacity
in order to specify the default skill to create into an agent, if one skill is not explicitly provided.SarlAccessorsProcessor
annotation, which is provessing the @Accessors
annoations into the SARL core library (details). Indeed, for being used by the compiler, the SarlAccessorsProcessor
annotation must be in the classpath of the project, i.e. the core library.AgentTrait
(details) in order to enable access to these read-only information.getService
function into the Bootstrap (details). This function enables the access to SRE services from any point in the code.getKernelLogger
function into the Bootstrap (details). This function enables the access to the SRE kernel logger from any point in the code.isRunning
function into the Bootstrap (details) in order to determine any instance of the SRE is running.startAgentWithID
function into the Bootstrap (details).io.sarl.javafx
from the SDK (details). The features that are provided by this module are not supposed to be used by all the SARL applications. Moreover, the dependency to JavaFX libraries (in JDK or not) should be managed by the SARL developer, not by the SARL SDK itself. The module is transformed into a maven library (see below).Collections3
(details).SpaceCreated
, SpaceDestroy
into the template that is used by the new-agent wizard (details).AbstractUIPlugin.imageDescriptorFromPlugin()
(details).on
statements were removed.plugin.xml
file is normalized (details). The example-creation wizard searches for the file based on the specified location (named <loc>
below):
1) file with path <loc>
exists;
2) file with path <project-name>/<loc>
exists;
3) file with path <project-name>/src/main/sarl/<loc>
exists.ParticipantJoined
and ParticipantLeft
(details).getOrCreateSpaceWithSpec
function (details).StandardBuiltinCapacitiesProvider
to the invokers of this provider (details).io.sarl.javafx
module (details).sarldoc
command-line tools for creation the API documentation from the CLI (1, 2, 3, 4, 5, 6, 7, 8, 9)build.properties
, MANIFEST.MF
files and specific Java classes to contains the JDK and JRE version numbers that is provided in the general pom file (details).io.sarl.javafx
module able to use the JavaFX’s dependency for JDK8 or JDK11 (details).Accessors
annotation (details).Files.toString()
(details).DefaultActionPrototypeProvider
is an eager singleton in order to limit memory leaks (details).