This is an automated email from the ASF dual-hosted git repository.

fanningpj pushed a commit to branch graal
in repository https://gitbox.apache.org/repos/asf/incubator-pekko-samples.git

commit bbac48cbbf9036817a3f38d391c15e0d84456d5c
Author: Arnout Engelen <[email protected]>
AuthorDate: Fri Jun 21 09:35:33 2019 +0200

    Demo graal-akka-actor
---
 akka-sample-main-scala/build.sbt                   | 16 ++++++++++++-
 akka-sample-main-scala/graal/reflect-config.json   | 10 ++++++++
 akka-sample-main-scala/project/plugins.sbt         |  2 ++
 .../src/main/java/AkkaSubstitutions.java           | 23 ++++++++++++++++++
 .../src/main/scala/sample/hello/HelloWorld.scala   |  2 +-
 .../src/main/scala/sample/hello/Main.scala         |  3 +--
 .../src/main/scala/sample/hello/Main2.scala        | 27 ----------------------
 7 files changed, 52 insertions(+), 31 deletions(-)

diff --git a/akka-sample-main-scala/build.sbt b/akka-sample-main-scala/build.sbt
index 242e169..3a00de1 100644
--- a/akka-sample-main-scala/build.sbt
+++ b/akka-sample-main-scala/build.sbt
@@ -1,9 +1,23 @@
 organization := "com.typesafe.akka.samples"
 name := "akka-sample-main-scala"
 
+enablePlugins(GraalVMNativeImagePlugin)
+
+mainClass := Some("sample.hello.Main")
+
+// Build it with `sbt graalvm-native-image:packageBin`
+graalVMNativeImageOptions := Seq(
+  s"-H:ConfigurationFileDirectories=${baseDirectory.value}/graal",
+  "--initialize-at-build-time",
+  "--no-fallback",
+)
+
+unmanagedJars in Compile += file(sys.env("GRAAL_HOME") + 
"/jre/lib/svm/builder/svm.jar")
+
 scalaVersion := "2.12.8"
 libraryDependencies ++= Seq(
-  "com.typesafe.akka" %% "akka-actor" % "2.5.22"
+  "com.typesafe.akka" %% "akka-actor" % "2.5.23",
+  "com.github.vmencik" %% "graal-akka-actor" % "0.1.2-SNAPSHOT" % "provided",
 )
 
 licenses := Seq(("CC0", 
url("http://creativecommons.org/publicdomain/zero/1.0";)))
diff --git a/akka-sample-main-scala/graal/reflect-config.json 
b/akka-sample-main-scala/graal/reflect-config.json
new file mode 100644
index 0000000..7256f50
--- /dev/null
+++ b/akka-sample-main-scala/graal/reflect-config.json
@@ -0,0 +1,10 @@
+[
+  {
+    "name": "sample.hello.HelloWorld",
+    "allDeclaredConstructors":true,
+    "fields" : [
+      { "name" : "context", "allowWrite" : true },
+      { "name" : "self", "allowWrite" : true }
+    ]
+  }
+]
diff --git a/akka-sample-main-scala/project/plugins.sbt 
b/akka-sample-main-scala/project/plugins.sbt
index a7f83b3..66d4c2a 100644
--- a/akka-sample-main-scala/project/plugins.sbt
+++ b/akka-sample-main-scala/project/plugins.sbt
@@ -1 +1,3 @@
 addSbtPlugin("com.dwijnand" % "sbt-dynver" % "3.0.0")
+
+addSbtPlugin("com.typesafe.sbt" % "sbt-native-packager" % "1.3.22")
diff --git a/akka-sample-main-scala/src/main/java/AkkaSubstitutions.java 
b/akka-sample-main-scala/src/main/java/AkkaSubstitutions.java
new file mode 100644
index 0000000..c7be7c3
--- /dev/null
+++ b/akka-sample-main-scala/src/main/java/AkkaSubstitutions.java
@@ -0,0 +1,23 @@
+/*
+ * Copyright (C) 2017-2018 Lightbend Inc. <https://www.lightbend.com>
+ */
+
+package com.github.vmencik.akkanative;
+
+import com.oracle.svm.core.annotate.Alias;
+import com.oracle.svm.core.annotate.RecomputeFieldValue;
+import com.oracle.svm.core.annotate.TargetClass;
+
+// see 
https://medium.com/graalvm/instant-netty-startup-using-graalvm-native-image-generation-ed6f14ff7692
+
+// should no longer be needed, but 
https://github.com/vmencik/akka-graal-config/issues/4
+
+@TargetClass(className = "akka.actor.LightArrayRevolverScheduler$")
+final class Target_akka_actor_LightArrayRevolverScheduler$ {
+    @Alias
+    @RecomputeFieldValue(kind = RecomputeFieldValue.Kind.FieldOffset, 
declClassName = "akka.actor.LightArrayRevolverScheduler$TaskHolder", name = 
"task")
+    public long akka$actor$LightArrayRevolverScheduler$$taskOffset;
+}
+
+public class AkkaSubstitutions {
+}
diff --git 
a/akka-sample-main-scala/src/main/scala/sample/hello/HelloWorld.scala 
b/akka-sample-main-scala/src/main/scala/sample/hello/HelloWorld.scala
index e52619b..e343f87 100644
--- a/akka-sample-main-scala/src/main/scala/sample/hello/HelloWorld.scala
+++ b/akka-sample-main-scala/src/main/scala/sample/hello/HelloWorld.scala
@@ -7,7 +7,7 @@ class HelloWorld extends Actor {
 
   override def preStart(): Unit = {
     // create the greeter actor
-    val greeter = context.actorOf(Props[Greeter], "greeter")
+    val greeter = context.actorOf(Props(new Greeter), "greeter")
     // tell it to perform the greeting
     greeter ! Greeter.Greet
   }
diff --git a/akka-sample-main-scala/src/main/scala/sample/hello/Main.scala 
b/akka-sample-main-scala/src/main/scala/sample/hello/Main.scala
index 7f11453..ce8db69 100644
--- a/akka-sample-main-scala/src/main/scala/sample/hello/Main.scala
+++ b/akka-sample-main-scala/src/main/scala/sample/hello/Main.scala
@@ -5,5 +5,4 @@ object Main {
   def main(args: Array[String]): Unit = {
     akka.Main.main(Array(classOf[HelloWorld].getName))
   }
-
-}
\ No newline at end of file
+}
diff --git a/akka-sample-main-scala/src/main/scala/sample/hello/Main2.scala 
b/akka-sample-main-scala/src/main/scala/sample/hello/Main2.scala
deleted file mode 100644
index 1d79c65..0000000
--- a/akka-sample-main-scala/src/main/scala/sample/hello/Main2.scala
+++ /dev/null
@@ -1,27 +0,0 @@
-package sample.hello
-
-import akka.actor.ActorSystem
-import akka.actor.Props
-import akka.actor.ActorRef
-import akka.actor.Actor
-import akka.actor.ActorLogging
-import akka.actor.Terminated
-
-object Main2 {
-
-  def main(args: Array[String]): Unit = {
-    val system = ActorSystem("Hello")
-    val a = system.actorOf(Props[HelloWorld], "helloWorld")
-    system.actorOf(Props(classOf[Terminator], a), "terminator")
-  }
-
-  class Terminator(ref: ActorRef) extends Actor with ActorLogging {
-    context watch ref
-    def receive = {
-      case Terminated(_) =>
-        log.info("{} has terminated, shutting down system", ref.path)
-        context.system.terminate()
-    }
-  }
-
-}
\ No newline at end of file


---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to