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
35
Dependency Management for Java - Portland - 2025-11-04
sullis
0
21
Dependency management for Java applications 2025-09-11
sullis
0
31
S3 NYC Iceberg meetup 2025-07-10
sullis
0
53
Amazon S3 Chicago 2025-06-04
sullis
0
130
Amazon S3 Boston 2025-05-07
sullis
0
98
Netty ConFoo Montreal 2025-02-27
sullis
0
140
GitHub Actions ConFoo Montreal 2025-02-26
sullis
0
99
Netty Portland Java User Group 2025-02-18
sullis
0
35
Other Decks in Programming
See All in Programming
エンジニアの「手元の自動化」を加速するn8n 2026.02.27
symy2co
0
150
CSC307 Lecture 14
javiergs
PRO
0
470
モジュラモノリスにおける境界をGoのinternalパッケージで守る
magavel
0
3.5k
野球解説AI Agentを開発してみた - 2026/02/27 LayerX社内LT会資料
shinyorke
PRO
0
280
The Past, Present, and Future of Enterprise Java
ivargrimstad
0
330
AIコードレビューの導入・運用と AI駆動開発における「AI4QA」の取り組みについて
hagevvashi
0
450
20260313 - Grafana & Friends Taipei #1 - Kubernetes v1.36 的開發雜記:那些困在 Alpha 加護病房太久的 Metrics
tico88612
0
180
どんと来い、データベース信頼性エンジニアリング / Introduction to DBRE
nnaka2992
1
280
grapheme_strrev関数が採択されました(あと雑感)
youkidearitai
PRO
1
220
nilとは何か 〜interfaceの構造とnil!=nilから理解する〜
kuro_kurorrr
3
1.9k
How to stabilize UI tests using XCTest
akkeylab
0
120
S3ストレージクラスの「見える」「ある」「使える」は全部違う ─ 体験から見た、仕様の深淵を覗く
ya_ma23
0
450
Featured
See All Featured
Believing is Seeing
oripsolob
1
82
Max Prin - Stacking Signals: How International SEO Comes Together (And Falls Apart)
techseoconnect
PRO
0
120
SEO Brein meetup: CTRL+C is not how to scale international SEO
lindahogenes
1
2.4k
Documentation Writing (for coders)
carmenintech
77
5.3k
Visual Storytelling: How to be a Superhuman Communicator
reverentgeek
2
470
[RailsConf 2023 Opening Keynote] The Magic of Rails
eileencodes
31
10k
The Power of CSS Pseudo Elements
geoffreycrofte
82
6.2k
So, you think you're a good person
axbom
PRO
2
2k
Winning Ecommerce Organic Search in an AI Era - #searchnstuff2025
aleyda
1
1.9k
KATA
mclloyd
PRO
35
15k
The State of eCommerce SEO: How to Win in Today's Products SERPs - #SEOweek
aleyda
2
9.9k
SEO for Brand Visibility & Recognition
aleyda
0
4.4k
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