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 - Seattle 2025-11-18
sullis
0
41
Dependency Management for Java - Portland - 2025-11-04
sullis
0
24
Dependency management for Java applications 2025-09-11
sullis
0
33
S3 NYC Iceberg meetup 2025-07-10
sullis
0
54
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
GitHub Actions ConFoo Montreal 2025-02-26
sullis
0
100
Netty Portland Java User Group 2025-02-18
sullis
0
39
Other Decks in Programming
See All in Programming
Redox OS でのネームスペース管理と chroot の実現
isanethen
0
510
The Past, Present, and Future of Enterprise Java
ivargrimstad
0
1.3k
Strategy for Finding a Problem for OSS: With Real Examples
kibitan
0
130
CS教育のDX AIによる育成の効率化
niftycorp
PRO
0
180
一度始めたらやめられない開発効率向上術 / Findy あなたのdotfilesを教えて!
k0kubun
3
2.7k
へんな働き方
yusukebe
6
2.9k
Tamach-sre-3_ANDPAD-shimaison93
mane12yurks38
0
240
事業会社でのセキュリティ長期インターンについて
masachikaura
0
210
[PHPerKaigi 2026]PHPerKaigi2025の企画CodeGolfが最高すぎて社内で内製して半年運営して得た内製と運営の知見
ikezoemakoto
0
320
PHP 7.4でもOpenTelemetryゼロコード計装がしたい! / PHPerKaigi 2026
arthur1
1
470
我々はなぜ「層」を分けるのか〜「関心の分離」と「抽象化」で手に入れる変更に強いシンプルな設計〜 #phperkaigi / PHPerKaigi 2026
shogogg
2
760
モダンOBSプラグイン開発
umireon
0
190
Featured
See All Featured
Game over? The fight for quality and originality in the time of robots
wayneb77
1
150
Documentation Writing (for coders)
carmenintech
77
5.3k
Writing Fast Ruby
sferik
630
63k
Navigating Team Friction
lara
192
16k
SEO for Brand Visibility & Recognition
aleyda
0
4.4k
A brief & incomplete history of UX Design for the World Wide Web: 1989–2019
jct
1
340
Lightning talk: Run Django tests with GitHub Actions
sabderemane
0
160
Abbi's Birthday
coloredviolet
2
6.2k
Product Roadmaps are Hard
iamctodd
PRO
55
12k
コードの90%をAIが書く世界で何が待っているのか / What awaits us in a world where 90% of the code is written by AI
rkaga
61
43k
Mozcon NYC 2025: Stop Losing SEO Traffic
samtorres
0
190
Groundhog Day: Seeking Process in Gaming for Health
codingconduct
0
140
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