[JVMLS 12] Kotlin / Java Interop
Upcoming SlideShare
Loading in...5
×
 

[JVMLS 12] Kotlin / Java Interop

on

  • 945 views

 

Statistics

Views

Total Views
945
Views on SlideShare
944
Embed Views
1

Actions

Likes
0
Downloads
8
Comments
0

1 Embed 1

http://www.slideee.com 1

Accessibility

Upload Details

Uploaded via as Adobe PDF

Usage Rights

© All Rights Reserved

Report content

Flagged as inappropriate Flag as inappropriate
Flag as inappropriate

Select your reason for flagging this presentation as inappropriate.

Cancel
  • Full Name Full Name Comment goes here.
    Are you sure you want to
    Your message goes here
    Processing…
Post Comment
Edit your comment

[JVMLS 12] Kotlin / Java Interop [JVMLS 12] Kotlin / Java Interop Presentation Transcript

  • A Friend In Need Is a Friend Indeed Kotlin / Java Interop Andrey BreslavWednesday, August 1, 12 1
  • Kotlin Modern Language for Industry • Smart compiler • Static typing ➡ Less boilerplate • Readability • Flexible abstractions • Tool support ➡ Powerful libraries • Interoperability 2Wednesday, August 1, 12 2
  • Stuff • Apache 2 • IDE • Target ➡ IntelliJ ➡ JVM (1.6) ➡ Web Demo ➡ JavaScript * • Build ➡ Ant ➡ Maven 3 * PlannedWednesday, August 1, 12 3
  • Outline 4Wednesday, August 1, 12 4
  • Outline • Enhancing Existing APIs ➡ Extensions ➡ Splitting Collections Interfaces 4Wednesday, August 1, 12 4
  • Outline • Enhancing Existing APIs ➡ Extensions ➡ Splitting Collections Interfaces • Fighting for Safety ➡ Nullable types ➡ Interaction with generics 4Wednesday, August 1, 12 4
  • Outline • Enhancing Existing APIs ➡ Extensions ➡ Splitting Collections Interfaces • Fighting for Safety ➡ Nullable types ➡ Interaction with generics • Statics ➡ Packages ➡ Class objects 4Wednesday, August 1, 12 4
  • Making Existing Things Nicer Extensions Variance TricksWednesday, August 1, 12 5
  • Extensions • Demo 6Wednesday, August 1, 12 6
  • Collections & Variance Java: Kotlin: 7Wednesday, August 1, 12 7
  • Declaration-Site Variance 8Wednesday, August 1, 12 8
  • Translation Ø java.util.List 9Wednesday, August 1, 12 9
  • Translation: Inheritance 10Wednesday, August 1, 12 10
  • Translation: Variance 11Wednesday, August 1, 12 11
  • Calling Java From Kotlin 12Wednesday, August 1, 12 12
  • Summary • Use JDK collections in Kotlin • Extend them with useful operations • Make them variant for Kotlin • At the expense of some unsoundness around the edges 13Wednesday, August 1, 12 13
  • Fighting NPEs Nullable Types Annotating Java CodeWednesday, August 1, 12 14
  • Nullable Types • Demo 15Wednesday, August 1, 12 15
  • Nullable Types Summary • null is a legitimate value, not a sin • No overhead (as opposed to Option) • Proper subtyping: ➡ List<String> is a List<String?> • At the expense of: file.getParent()!!.getName()!! 16Wednesday, August 1, 12 16
  • Annotations to The Rescue String String? JSR 305: Annotations for Software Defect Detection 17Wednesday, August 1, 12 17
  • Generics?! @NotNull doesnt help 18Wednesday, August 1, 12 18
  • More Use-Cases of @Kotlin 19Wednesday, August 1, 12 19
  • External Annotations 20Wednesday, August 1, 12 20
  • It Is Not So Bad • IDE aids annotating with quick fixes • Some annotations can be inferred automatically • Alternative: have a special kind of types for Java things 21Wednesday, August 1, 12 21
  • Statics Packages Class ObjectsWednesday, August 1, 12 22
  • Package-Level Code file1.kt foo/namespace.class file2.kt 23Wednesday, August 1, 12 23
  • Package-Level Code file1.kt foo/namespace.class Compiled From: file1.kt file2.kt 23Wednesday, August 1, 12 23
  • Package-Level Code file1.kt foo/namespace.class foo/namespace$file1.class from: file1.kt foo/namespace$file2.class file2.kt from: file2.kt 24Wednesday, August 1, 12 24
  • Package-Level Code file1.kt foo/namespace.class foo/namespace$file1.class from: Initialization Order?! file1.kt foo/namespace$file2.class file2.kt from: file2.kt 24Wednesday, August 1, 12 24
  • Kotlin Classes Have No StaticsWednesday, August 1, 12 25
  • Class Object Translation 26Wednesday, August 1, 12 26
  • Class Object Translation Only fields! 26Wednesday, August 1, 12 26
  • Resources • Docs: http://kotlin.jetbrains.org • Demo: http://kotlin-demo.jetbrains.com • Code: http://github.com/jetbrains/kotlin • Twitter: ➡ @project_kotlin ➡ @abreslav 27Wednesday, August 1, 12 27