Skip to content

Instantly share code, notes, and snippets.

@hohonuuli
Created October 28, 2017 18:22
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save hohonuuli/a58d97fd98f8c25e303a15f32bd993e5 to your computer and use it in GitHub Desktop.
Save hohonuuli/a58d97fd98f8c25e303a15f32bd993e5 to your computer and use it in GitHub Desktop.
class Sample1 {
// --- Native methods
@native def intMethod(n: Int): Int
@native def booleanMethod(b: Boolean): Boolean
@native def stringMethod(s: String): String
@native def intArrayMethod(a: Array[Int]): Int
}
object Sample1 {
// --- Main method to test our native library
def main(args: Array[String]): Unit = {
System.loadLibrary("Sample1")
val sample = new Sample1
val square = sample.intMethod(5)
val bool = sample.booleanMethod(true)
val text = sample.stringMethod("java")
val sum = sample.intArrayMethod(Array(1, 1, 2, 3, 5, 8, 13))
println(s"intMethod: $square")
println(s"booleanMethod: $bool")
println(s"stringMethod: $text")
println(s"intArrayMethod: $sum")
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment