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-Scala interoperability - April 2016
Search
sullis
April 19, 2016
Programming
0
360
Java-Scala interoperability - April 2016
Java-Scala interoperability
Portland Java User Group
April 19, 2016
sullis
April 19, 2016
Tweet
Share
More Decks by sullis
See All by sullis
Amazon S3 Chicago 2025-06-04
sullis
0
86
Amazon S3 Boston 2025-05-07
sullis
0
40
Netty ConFoo Montreal 2025-02-27
sullis
0
71
GitHub Actions ConFoo Montreal 2025-02-26
sullis
0
41
Netty Portland Java User Group 2025-02-18
sullis
0
8
Amazon S3 NYJavaSIG 2024-12-12
sullis
0
170
Amazon S3 - Portland Java User Group 2024-09-17
sullis
0
95
Netty - Montreal Java User Group 2024-05-21
sullis
0
170
Netty Chicago Java User Group 2024-04-17
sullis
0
1.1k
Other Decks in Programming
See All in Programming
GitHub Copilot and GitHub Codespaces Hands-on
ymd65536
1
120
F#で自在につくる静的ブログサイト - 関数型まつり2025
pizzacat83
1
310
Team topologies and the microservice architecture: a synergistic relationship
cer
PRO
0
1k
#kanrk08 / 公開版 PicoRubyとマイコンでの自作トレーニング計測装置を用いたワークアウトの理想と現実
bash0c7
1
340
Is Xcode slowly dying out in 2025?
uetyo
1
190
Railsアプリケーションと パフォーマンスチューニング ー 秒間5万リクエストの モバイルオーダーシステムを支える事例 ー Rubyセミナー 大阪
falcon8823
4
930
VS Code Update for GitHub Copilot
74th
1
320
0626 Findy Product Manager LT Night_高田スライド_speaker deck用
mana_takada
0
100
Result型で“失敗”を型にするPHPコードの書き方
kajitack
4
310
GraphRAGの仕組みまるわかり
tosuri13
7
480
関数型まつり2025登壇資料「関数プログラミングと再帰」
taisontsukada
2
850
「ElixirでIoT!!」のこれまでとこれから
takasehideki
0
370
Featured
See All Featured
RailsConf & Balkan Ruby 2019: The Past, Present, and Future of Rails at GitHub
eileencodes
138
34k
Large-scale JavaScript Application Architecture
addyosmani
512
110k
Building an army of robots
kneath
306
45k
We Have a Design System, Now What?
morganepeng
53
7.7k
VelocityConf: Rendering Performance Case Studies
addyosmani
330
24k
The Cult of Friendly URLs
andyhume
79
6.5k
Distributed Sagas: A Protocol for Coordinating Microservices
caitiem20
331
22k
Six Lessons from altMBA
skipperchong
28
3.8k
[RailsConf 2023 Opening Keynote] The Magic of Rails
eileencodes
29
9.5k
ReactJS: Keep Simple. Everything can be a component!
pedronauck
667
120k
Why Our Code Smells
bkeepers
PRO
337
57k
GitHub's CSS Performance
jonrohan
1031
460k
Transcript
Java-Scala interoperability Sean Sullivan April 19, 2016 Portland Java User
Group
• software engineer • 20 years Java • 5 years
at Gilt • back office systems @ Gilt About me
• Scala @ Gilt.com • Scala on the Java VM
• code examples Agenda
www.gilt.com
https://www.gilt.com/checkout
None
“The Scala 2.11.x series targets Java 6" http://www.scala-lang.org/news/2.11.0/
http://scala-lang.org/news/2.12-roadmap/ “The official Scala 2.12 distribution will be built for
Java 8 (and thus require it)”
Scala case classes and JSP’s
case class Thing( name: String, color: String)
thing.jsp <%@ taglib uri="http://java.sun.com/jsp/jstl/core" prefix="c" %> <html> <body> <c:out value=“${myThing.name}”/>
</body> </html>
JSP expression language expects a JavaBean with “getter” methods
import scala.reflect.BeanProperty case class Thing( @BeanProperty name: String, @BeanProperty color:
String) @BeanProperty annotation
Collections
None
• convert java.util.List to Scala collection • convert java.util.Set to
Scala collection • convert java.util.Map to Scala collection • convert Scala List to java.util.List Common scenarios
import scala.collection.JavaConverters._
import java.util.{ArrayList => JArrayList} import scala.collection.JavaConverters._ val jArrayList =
new JArrayList[String] jArrayList.add("a") jArrayList.add("b") jArrayList.add("c") val scalaList = jArrayList.asScala scalaList should be (List("a", "b", "c"))
Google Guava library
• com.google.common.base.Optional • com.google.common.util.concurrent.ListenableFuture
Guava @ Gilt
Guava Optional -> Scala Option Scala Option -> Guava Optional
import com.gilt.gfc.guava.GuavaConverters._
Guava Future -> Scala Future Scala Future -> Guava Future
import com.gilt.gfc.guava.future.FutureConverters._
Java 8
https://github.com/scala/scala-java8-compat
import scala.compat.java8.FutureConverters._ Java 8 Future to Scala Future
import scala.compat.java8.OptionConverters._ java.util.Optional to scala.Option
https://github.com/sullis/java-scala-interop-examples
The end
None