Upgrade to Pro
— share decks privately, control downloads, hide ads and more …
Speaker Deck
Features
Speaker Deck
PRO
Sign in
Sign up for free
Search
Search
Java Interoperating with Golang V2
Search
swt02026
May 28, 2019
Programming
0
26
Java Interoperating with Golang V2
GraalVM
JNI
JDK 13 Panama( new!!!)
swt02026
May 28, 2019
Tweet
Share
More Decks by swt02026
See All by swt02026
Interoperating Golang with Swift
swt02026
0
27
Java Interoperating with Golang
swt02026
0
40
Other Decks in Programming
See All in Programming
入門プロパティベーステスト/learning-property-based-testing
kiway
6
1k
Navigating Generative AI: A Developer's Guide
alperhankendi
0
160
ウォンテッドリーでのKMPワークフロー / KMP workflow at Wantedly
kubode
0
120
来週から実践できる! LayerXのバクラク事業部で行われている Go 関連の読書会のご紹介 / Bakuraku Go Reading Group
upamune
5
250
CQRS+ES解体新書 / CQRS ES Disassembly Book
nrslib
7
710
JS RPCを理解する
yusukebe
5
390
HonoのRPCで真の型安全が欲しかった
kosei28
1
210
Module Harmony について
yosuke_furukawa
PRO
3
670
BQで天気基盤をつくって、役立つ情報を可視化してみた!
wakamatsu_takumu
4
640
Containerization Tips and Tricks for PHP apps
dunglas
2
3.4k
[RubyKaigi 2024] Ruby Mixology 101: adding shots of PHP, Elixir, and more
palkan
1
390
Community-driven RBS repository
pocke
2
390
Featured
See All Featured
Practical Orchestrator
shlominoach
183
9.8k
Robots, Beer and Maslow
schacon
PRO
155
8k
Distributed Sagas: A Protocol for Coordinating Microservices
caitiem20
323
20k
The Language of Interfaces
destraynor
151
23k
Building Adaptive Systems
keathley
32
1.9k
Imperfection Machines: The Place of Print at Facebook
scottboms
261
12k
How to train your dragon (web standard)
notwaldorf
76
5.3k
BBQ
matthewcrist
80
8.8k
The World Runs on Bad Software
bkeepers
PRO
61
6.8k
Designing on Purpose - Digital PM Summit 2013
jponch
111
6.5k
Optimizing for Happiness
mojombo
372
69k
StorybookのUI Testing Handbookを読んだ
zakiyama
13
4.7k
Transcript
在 Java 使用 Go 函式Ver.2 使用JDK 13 Panama Colab: http://bit.ly/2Ex4clY
簡報: http://bit.ly/2HXFYST
已知的解決方案 • Java Native Interface • GraalVM Native-Image • GraalVM
sulong + llgo • JDK 13 Panama
Java Native Interface Java Go C Header X 2 Library
jar Library 2
Java Native Interface 原理 • 撰寫 C 程式,將 JNI 與
cgo 產生 Library 包裝 優點 • 相關教學資源多 • Android 也適用 缺點 • 需要寫 C 、Java、Go • 產生的中介檔多
GraalVM Native-Image Java Go Header Library ELF or Mach-O .class
GraalVM Native-Image 原理 • 把 Java 程式編譯成 Native Binary,與 cgo
Library 進行 Linkage 缺點 • 編譯時間長,產生的執行檔很肥 • JVM 的功能無法完全取代 • Java 程式需要提供編譯器相關資訊 • 目前只提供 Java 8 的語法 • Android 尚未支援 優點 • 不用 JVM 就能執行 • 只需要寫 Java 、Go
GraalVM sulong + llgo Java Go LLVM bitCode jar
GraalVM sulong + llgo 原理 • 用 llgo 將 Go
程式編譯成 LLVM bitcode • 使用 GraalVM sulong 執行 LLVM bitcode 缺點 • llgo 已經五年沒維護,沒安裝成功.... • 可能會遇到 bitcode 版本相容問題 • Java 程式中要處理 bitcode Lifecycle • 編譯時期 Go 與 Java 產生檔案沒有直接相依,不易偵錯
JDK 13 Panama Java Go Library Header jar
JDK 13 Panama 原理 • 使用 jextract 工具,將 Header 與
Library 相關資訊包裝成 Java Package 優點 • Java 程式只需 Import Package 就可以使用 • 未來會取代 Java Native Interface,Android 不確定 缺點 • 目前文件很少 • 產生的 Java Package 資訊不透明,decompile 才能了解如何使用
None
我們都用GO直接重寫,沒在跨語言der
參考資料 https://hg.openjdk.java.net/panama/dev/raw-file/c359a9e944de/doc/panama_forei gn.html https://jdk.java.net/panama/