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
Sponsored
·
SiteGround - Reliable hosting with speed, security, and support you can count on.
→
sullis
April 19, 2016
Programming
370
0
Share
Java-Scala interoperability - April 2016
Java-Scala interoperability
Portland Java User Group
April 19, 2016
sullis
April 19, 2016
More Decks by sullis
See All by sullis
Dependency Management for Java - Code Remix Summit 2026-05-12
sullis
0
12
AI Assisted Software Development - Portland Java User Group - 2026-04-14
sullis
0
47
Dependency Management for Java - Seattle 2025-11-18
sullis
0
45
Dependency Management for Java - Portland - 2025-11-04
sullis
0
29
Dependency management for Java applications 2025-09-11
sullis
0
47
S3 NYC Iceberg meetup 2025-07-10
sullis
0
56
Amazon S3 Chicago 2025-06-04
sullis
0
130
Amazon S3 Boston 2025-05-07
sullis
0
100
Netty ConFoo Montreal 2025-02-27
sullis
0
160
Other Decks in Programming
See All in Programming
サプライチェーン攻撃対策「層を重ねて落ちない壁」を10日間で組み上げた話 #TechLeadConf2026
kashewnuts
1
210
WebAssembly を読み込むベストプラクティス 2026年春版 / Best Practices for Loading WebAssembly (Spring 2026)
petamoriken
5
1.1k
Road to RubyKaigi: Play Hard(ware)
makicamel
1
550
Oxlintとeslint-plugin-react-hooks 明日から始められそう?
t6adev
0
320
when storing skills in S3 file
watany
3
1.3k
継続的な負荷検証を目指して
pyama86
0
290
tRPCの概要と少しだけパフォーマンス
misoton665
2
260
エラー処理の温故知新 / history of error handling technic
ryotanakaya
7
1.8k
Kingdom of the Machine
yui_knk
2
1.4k
HTML-Aware ERB: The Path to Reactive Rendering @ RubyKaigi 2026, Hakodate, Japan
marcoroth
0
640
「話せることがない」を乗り越える 〜日常業務から登壇テーマをつくる思考法〜
shoheimitani
4
970
(Re)make Regexp in Ruby: Democratizing internals for the JIT
makenowjust
3
1k
Featured
See All Featured
Lessons Learnt from Crawling 1000+ Websites
charlesmeaden
PRO
1
1.2k
Between Models and Reality
mayunak
3
280
Building an army of robots
kneath
306
46k
How Fast Is Fast Enough? [PerfNow 2025]
tammyeverts
3
560
State of Search Keynote: SEO is Dead Long Live SEO
ryanjones
0
190
Refactoring Trust on Your Teams (GOTO; Chicago 2020)
rmw
35
3.4k
Utilizing Notion as your number one productivity tool
mfonobong
4
300
Deep Space Network (abreviated)
tonyrice
0
130
Ecommerce SEO: The Keys for Success Now & Beyond - #SERPConf2024
aleyda
1
2k
Have SEOs Ruined the Internet? - User Awareness of SEO in 2025
akashhashmi
0
340
Optimising Largest Contentful Paint
csswizardry
37
3.7k
Improving Core Web Vitals using Speculation Rules API
sergeychernyshev
21
1.5k
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