The java wrapper which provides access to the gem5 ops is implemented
using JNI in a .so file which needs to be loaded before the class can be
used. Rather than expecting the caller to do that, we can use a static
block in the class definition. We know that will be called at the right
time, and it's one less detail (arguably an implementation detail) that
the caller won't have to worry about.
Change-Id: I2b4b18ebb12030ea6f4e6463c6cd512afed74cfd
Reviewed-on: https://gem5-review.googlesource.com/c/public/gem5/+/28177
Reviewed-by: Gabe Black <gabe.black@gmail.com>
Maintainer: Gabe Black <gabe.black@gmail.com>
Tested-by: kokoro <noreply+kokoro@google.com>
# Java jar
-To use the gem5 java jar, you will need to load the corresponding .so.
-
-```shell
-System.loadLibrary("gem5Ops");
-```
-
In your java source, import the gem5Op class which will have methods for
-calling each of the gem5 operations.
+calling each of the gem5 operations. The .so library will be loaded
+automatically.
```shell
import gem5.Ops
*/
public class Ops {
+ static {
+ System.loadLibrary("gem5Ops");
+ }
+
public native void arm(long address);
public native void quiesce();
public native void quiesce_ns(long ns);