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
Dependency management for Java applications 2025-09-11
sullis
0
7
S3 NYC Iceberg meetup 2025-07-10
sullis
0
40
Amazon S3 Chicago 2025-06-04
sullis
0
100
Amazon S3 Boston 2025-05-07
sullis
0
55
Netty ConFoo Montreal 2025-02-27
sullis
0
100
GitHub Actions ConFoo Montreal 2025-02-26
sullis
0
62
Netty Portland Java User Group 2025-02-18
sullis
0
12
Amazon S3 NYJavaSIG 2024-12-12
sullis
0
190
Amazon S3 - Portland Java User Group 2024-09-17
sullis
0
110
Other Decks in Programming
See All in Programming
The Past, Present, and Future of Enterprise Java with ASF in the Middle
ivargrimstad
0
110
Android 16 × Jetpack Composeで縦書きテキストエディタを作ろう / Vertical Text Editor with Compose on Android 16
cc4966
1
220
Performance for Conversion! 分散トレーシングでボトルネックを 特定せよ
inetand
0
160
🔨 小さなビルドシステムを作る
momeemt
4
680
概念モデル→論理モデルで気をつけていること
sunnyone
2
160
go test -json そして testing.T.Attr / Kyoto.go #63
utgwkk
3
300
プロポーザル駆動学習 / Proposal-Driven Learning
mackey0225
2
1.3k
Ruby Parser progress report 2025
yui_knk
1
440
250830 IaCの選定~AWS SAMのLambdaをECSに乗り換えたときの備忘録~
east_takumi
0
390
Azure SRE Agentで運用は楽になるのか?
kkamegawa
0
2.2k
旅行プランAIエージェント開発の裏側
ippo012
2
910
AIを活用し、今後に備えるための技術知識 / Basic Knowledge to Utilize AI
kishida
22
5.8k
Featured
See All Featured
Templates, Plugins, & Blocks: Oh My! Creating the theme that thinks of everything
marktimemedia
31
2.5k
Making the Leap to Tech Lead
cromwellryan
135
9.5k
What's in a price? How to price your products and services
michaelherold
246
12k
Site-Speed That Sticks
csswizardry
10
810
It's Worth the Effort
3n
187
28k
Bash Introduction
62gerente
615
210k
VelocityConf: Rendering Performance Case Studies
addyosmani
332
24k
Fantastic passwords and where to find them - at NoRuKo
philnash
52
3.4k
Optimizing for Happiness
mojombo
379
70k
[RailsConf 2023 Opening Keynote] The Magic of Rails
eileencodes
30
9.7k
Understanding Cognitive Biases in Performance Measurement
bluesmoon
29
1.9k
BBQ
matthewcrist
89
9.8k
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