linux.core: Intern SystemCall name string
authorMatthew Khouzam <matthew.khouzam@ericsson.com>
Wed, 18 May 2016 00:44:05 +0000 (20:44 -0400)
committerMatthew Khouzam <matthew.khouzam@ericsson.com>
Wed, 25 May 2016 20:47:57 +0000 (16:47 -0400)
commit4eec2dc5012a554724f98237ddc8a1d0bc7adb0e
tree44f5fc708ec397062e1d6147f0e8580c045ede6e
parent22216a03b77620fdf6a3603a9c30bd889363a043
linux.core: Intern SystemCall name string

This patch makes SystemCall mutable.

This is a tricky situation. This object is serializable.
In order to internalize the string (name) the object needs
to have a custom readObject().

This means we need to either make the name field mutable or
use reflexion to make the field modifyable. If we are using
reflexion, the point of making an object immutable is moot.

Here are the main reasons for an immutable object:

* immutable objects are simpler to construct, test, and use
* truly immutable objects are always thread-safe
* they help to avoid temporal coupling
* their usage is side-effect free (no defensive copies)
* identity mutability problem is avoided
* they always have failure atomicity
* they are much easier to cache
* they prevent NULL references, which are bad

As SystemCall has no setters, and the class is now final,
its fields are in practice immutable.

This begs the question though, would having no "final" keyword
on a field affect performance. Unfortunately no. Final classes
can be inlined, but final fields yield no advantage other than
code clarity.

We should still strive to have final fields whenever it is
possible, but this should not cause ideological objections,
as it breaks clean serialization.

This partially addresses bug 489217

Change-Id: I80a99128dffebe1fb3c0561ab76beabea2cc7775
Signed-off-by: Matthew Khouzam <matthew.khouzam@ericsson.com>
Reviewed-on: https://git.eclipse.org/r/72995
Reviewed-by: Hudson CI
analysis/org.eclipse.tracecompass.analysis.os.linux.core/src/org/eclipse/tracecompass/internal/analysis/os/linux/core/latency/SystemCall.java
This page took 0.024726 seconds and 5 git commands to generate.