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
370
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
Dependency Management for Java - Seattle 2025-11-18
sullis
0
22
Dependency Management for Java - Portland - 2025-11-04
sullis
0
17
Dependency management for Java applications 2025-09-11
sullis
0
25
S3 NYC Iceberg meetup 2025-07-10
sullis
0
50
Amazon S3 Chicago 2025-06-04
sullis
0
120
Amazon S3 Boston 2025-05-07
sullis
0
93
Netty ConFoo Montreal 2025-02-27
sullis
0
130
GitHub Actions ConFoo Montreal 2025-02-26
sullis
0
93
Netty Portland Java User Group 2025-02-18
sullis
0
31
Other Decks in Programming
See All in Programming
Kotlin Multiplatform Meetup - Compose Multiplatform 외부 의존성 아키텍처 설계부터 운영까지
wisemuji
0
190
CSC307 Lecture 04
javiergs
PRO
0
660
20260127_試行錯誤の結晶を1冊に。著者が解説 先輩データサイエンティストからの指南書 / author's_commentary_ds_instructions_guide
nash_efp
0
910
Smart Handoff/Pickup ガイド - Claude Code セッション管理
yukiigarashi
0
130
Fragmented Architectures
denyspoltorak
0
150
フルサイクルエンジニアリングをAI Agentで全自動化したい 〜構想と現在地〜
kamina_zzz
0
400
MUSUBIXとは
nahisaho
0
130
AWS re:Invent 2025参加 直前 Seattle-Tacoma Airport(SEA)におけるハードウェア紛失インシデントLT
tetutetu214
2
100
組織で育むオブザーバビリティ
ryota_hnk
0
170
CSC307 Lecture 06
javiergs
PRO
0
680
CSC307 Lecture 07
javiergs
PRO
0
550
今こそ知るべき耐量子計算機暗号(PQC)入門 / PQC: What You Need to Know Now
mackey0225
3
370
Featured
See All Featured
Dominate Local Search Results - an insider guide to GBP, reviews, and Local SEO
greggifford
PRO
0
77
How to Think Like a Performance Engineer
csswizardry
28
2.4k
HU Berlin: Industrial-Strength Natural Language Processing with spaCy and Prodigy
inesmontani
PRO
0
200
Reality Check: Gamification 10 Years Later
codingconduct
0
2k
Navigating Algorithm Shifts & AI Overviews - #SMXNext
aleyda
0
1.1k
I Don’t Have Time: Getting Over the Fear to Launch Your Podcast
jcasabona
34
2.6k
Music & Morning Musume
bryan
47
7.1k
Embracing the Ebb and Flow
colly
88
5k
16th Malabo Montpellier Forum Presentation
akademiya2063
PRO
0
47
Git: the NoSQL Database
bkeepers
PRO
432
66k
Thoughts on Productivity
jonyablonski
74
5k
Navigating the Design Leadership Dip - Product Design Week Design Leaders+ Conference 2024
apolaine
0
170
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