Slide 1

Slide 1 text

Spring Fu on GraalVM 2018-06-27 Taro Nagasawa

Slide 2

Slide 2 text

Taro - たろう ● @ngsw_taro ● Organizer of Japan Kotlin User Group

Slide 3

Slide 3 text

Redesign Medical Care

Slide 4

Slide 4 text

GraalVM ● Platform developed by Oracle ● Polyglot VM ○ JVM-based languages (Java, Scala, Kotlin! …) ○ JavaScript, Python, Ruby, R ○ LLVM-based languages (C, C++, ...) ● AOT Compiler ○ Java code is compiled to native code ● Community Edition / Enterprise Edition

Slide 5

Slide 5 text

$ docker run --rm findepi/graalvm java -version openjdk version "1.8.0_171" OpenJDK Runtime Environment (build 1.8.0_171-11) GraalVM 1.0.0-rc2 (build25.71-b01-internal-jvmci -0.43, mixed mode)

Slide 6

Slide 6 text

Familiar Spring Boot application @SpringBootApplication class DemoApplication fun main(args: Array) { runApplication(*args) } @Service class HelloService { fun hello(): String = "Hello, world!" } @RestController class HelloController(val helloService: HelloService) { @GetMapping("") fun hello(): String = helloService.hello() }

Slide 7

Slide 7 text

$ ./gradlew bootRun $ curl http://localhost:8080 Hello, world! Spring app written in Kotlin runs on GraalVM

Slide 8

Slide 8 text

$ ./gradlew assemble $ native-image -jar\ build/libs/demo-0.0.1-SNAPSHOT.jar Native

Slide 9

Slide 9 text

$ ./gradlew assemble $ native-image -jar\ build/libs/demo-0.0.1-SNAPSHOT.jar Error: com.oracle.graal.pointsto.constraints.Un supportedFeatureException: Unsupported field jav a.net.URL.handlers is reachable Native

Slide 10

Slide 10 text

Spring Fu ● Micro-framework for Kotlin ● Like Spring 5 functional registration

Slide 11

Slide 11 text

Hello, Spring Fu class HelloService { fun hello(): String = "Hello, world!" } class HelloController(val helloService: HelloService) { fun hello(request: ServerRequest): Mono { val hello = helloService.hello() return ServerResponse.ok().syncBody(hello) } }

Slide 12

Slide 12 text

Hello, Spring Fu fun main(args: Array) = application { bean() bean() webflux { server(netty(8080)) { routes { this.context = [email protected] val helloController = ref() GET("/", helloController::hello) } } } }.run(await = true)

Slide 13

Slide 13 text

Hello, Spring Fu fun main(args: Array) = application { bean() bean() webflux { server(netty(8080)) { routes { this.context = [email protected] val helloController = ref() GET("/", helloController::hello) } } } }.run(await = true)

Slide 14

Slide 14 text

$ ./gradlew bootRun $ curl http://localhost:8080 Hello, world! Spring Fu app runs on GraalVM

Slide 15

Slide 15 text

$ ./gradlew assemble $ native-image -jar build/libs/app.jar Native!

Slide 16

Slide 16 text

$ ./gradlew assemble $ native-image -jar build/libs/app.jar Error: com.oracle.graal.pointsto.constraints.Un supportedFeatureException: Unsupported field jav a.net.URL.handlers is reachable Native!

Slide 17

Slide 17 text

Spring Fu does not support GraalVM AOT compiler

Slide 18

Slide 18 text

No content

Slide 19

Slide 19 text

One more thing...

Slide 20

Slide 20 text

Kotlin Fest 2018 Tokyo Aug. 25th More information coming soon.

Slide 21

Slide 21 text

Thank you! Enjoy Kotlin!