SlideShare a Scribd company logo
1 of 46
Download to read offline
© 2013 IBM Corporation
Ryan	
  A.	
  Sciampacone	
  –	
  Managed	
  Run4me	
  Architect	
  
25	
  September	
  2013	
  
Effec4ve	
  Foreign	
  Func4on	
  Interfaces:	
  
From	
  JNI	
  to	
  JNR	
  
© 2013 IBM Corporation
Important	
  Disclaimers	
  
THE	
  INFORMATION	
  CONTAINED	
  IN	
  THIS	
  PRESENTATION	
  IS	
  PROVIDED	
  FOR	
  INFORMATIONAL	
  PURPOSES	
  ONLY.	
  	
  
WHILST	
  EFFORTS	
  WERE	
  MADE	
  TO	
  VERIFY	
  THE	
  COMPLETENESS	
  AND	
  ACCURACY	
  OF	
  THE	
  INFORMATION	
  CONTAINED	
  IN	
  THIS	
  
PRESENTATION,	
  IT	
  IS	
  PROVIDED	
  “AS	
  IS”,	
  WITHOUT	
  WARRANTY	
  OF	
  ANY	
  KIND,	
  EXPRESS	
  OR	
  IMPLIED.	
  	
  
ALL	
  PERFORMANCE	
  DATA	
  INCLUDED	
  IN	
  THIS	
  PRESENTATION	
  HAVE	
  BEEN	
  GATHERED	
  IN	
  A	
  CONTROLLED	
  ENVIRONMENT.	
  	
  YOUR	
  OWN	
  
TEST	
  RESULTS	
  MAY	
  VARY	
  BASED	
  ON	
  HARDWARE,	
  SOFTWARE	
  OR	
  INFRASTRUCTURE	
  DIFFERENCES.	
  
ALL	
  DATA	
  INCLUDED	
  IN	
  THIS	
  PRESENTATION	
  ARE	
  MEANT	
  TO	
  BE	
  USED	
  ONLY	
  AS	
  A	
  GUIDE.	
  
IN	
  ADDITION,	
  THE	
  INFORMATION	
  CONTAINED	
  IN	
  THIS	
  PRESENTATION	
  IS	
  BASED	
  ON	
  IBM’S	
  CURRENT	
  PRODUCT	
  PLANS	
  AND	
  STRATEGY,	
  
WHICH	
  ARE	
  SUBJECT	
  TO	
  CHANGE	
  BY	
  IBM,	
  WITHOUT	
  NOTICE.	
  	
  
IBM	
  AND	
  ITS	
  AFFILIATED	
  COMPANIES	
  SHALL	
  NOT	
  BE	
  RESPONSIBLE	
  FOR	
  ANY	
  DAMAGES	
  ARISING	
  OUT	
  OF	
  THE	
  USE	
  OF,	
  OR	
  OTHERWISE	
  
RELATED	
  TO,	
  THIS	
  PRESENTATION	
  OR	
  ANY	
  OTHER	
  DOCUMENTATION.	
  	
  
NOTHING	
  CONTAINED	
  IN	
  THIS	
  PRESENTATION	
  IS	
  INTENDED	
  TO,	
  OR	
  SHALL	
  HAVE	
  THE	
  EFFECT	
  OF:	
  	
  
-­‐	
  CREATING	
  ANY	
  WARRANT	
  OR	
  REPRESENTATION	
  FROM	
  IBM,	
  ITS	
  AFFILIATED	
  COMPANIES	
  OR	
  ITS	
  OR	
  THEIR	
  SUPPLIERS	
  AND/OR	
  
LICENSORS	
  
2
© 2013 IBM Corporation
Your	
  Speaker:	
  Ryan	
  A.	
  Sciampacone	
  
• Run4me	
  Architect	
  @	
  IBM	
  (JTC)	
  
•  Interpreters	
  
•  Garbage	
  Collec4on	
  
•  Plaborm	
  interfacing	
  /	
  op4miza4on	
  
•  Hardware	
  exploita4on	
  
(E)	
  ryan_sciampacone@ca.ibm.com	
  
(T)	
  @rsciampacone	
  
3
© 2013 IBM Corporation
What	
  should	
  you	
  get	
  from	
  this?	
  
• Why	
  a	
  foreign	
  func4on	
  interface	
  (FFI)	
  is	
  important	
  
• Performance	
  4ps	
  /	
  common	
  piballs	
  when	
  using	
  JNI	
  
• Next	
  steps	
  in	
  the	
  evolu4on	
  of	
  the	
  FFI	
  for	
  Java	
  
• At	
  the	
  very	
  least,	
  45	
  minutes	
  or	
  so	
  of	
  entertainment	
  
4
© 2013 IBM Corporation
WHY	
  IS	
  AN	
  FFI	
  IMPORTANT?	
  
What	
  the	
  Java	
  Na4ve	
  Interface	
  (JNI)	
  does	
  for	
  you…	
  
5
© 2013 IBM Corporation
Why	
  have	
  a	
  FFI?	
  
• Plaborm	
  interfacing	
  
• Legacy	
  System	
  Support	
  
• Cross	
  Language	
  Interop	
  
• Speed	
  
6
© 2013 IBM Corporation
Mo4va4ng	
  Example:	
  Missed	
  some	
  API	
  
• New	
  things	
  come	
  up	
  /	
  Some	
  things	
  missed	
  
7
© 2013 IBM Corporation
JNI	
  Call	
  Example	
  
Java:	
  
8
C:	
  
© 2013 IBM Corporation
Benefits	
  of	
  the	
  JNI	
  implementa4on	
  
• API	
  based	
  
• GC	
  Safety	
  
• Java	
  /	
  JVM	
  based	
  ac4vity	
  not	
  blocked	
  
• Plaborm	
  agnos4c	
  
• Clear	
  lines	
  between	
  Java	
  /	
  plaborm	
  
• Founda4on	
  for	
  JVM	
  Tooling	
  (JVMTI)	
  
9
© 2013 IBM Corporation
JNI	
  API	
  Building	
  Blocks	
  
10
© 2013 IBM Corporation
JNIEnv	
  is	
  your	
  lifeline	
  
• JNIEnv	
  is	
  the	
  connec4on	
  back	
  to	
  the	
  “Java	
  world”	
  
• Calls	
  through	
  the	
  JNIEnv	
  are	
  effec4vely	
  round	
  trip	
  
• Performance	
  is	
  dependent	
  on	
  keeping	
  round	
  trips	
  down	
  
11
© 2013 IBM Corporation
PERFORMANCE	
  PITFALLS	
  
But	
  it’s	
  already	
  slow,	
  what’s	
  a	
  few	
  more	
  instruc4ons?	
  
12
© 2013 IBM Corporation
Caching	
  Classes,	
  Method	
  IDs	
  and	
  Field	
  IDs	
  
• Core	
  elements	
  when	
  interac4ng	
  with	
  objects	
  
• Effec4vely	
  your	
  na4ve	
  “resolve”	
  point	
  
• Not	
  as	
  cheap	
  to	
  acquire	
  
• So	
  cache	
  them!	
  
13
© 2013 IBM Corporation
Basic	
  ID	
  use	
  
14
© 2013 IBM Corporation
Caching	
  Classes,	
  Method	
  IDs	
  and	
  Field	
  IDs	
  
15
© 2013 IBM Corporation
Caching	
  Classes,	
  Method	
  IDs	
  and	
  Field	
  IDs	
  
16
© 2013 IBM Corporation
Caching	
  Classes,	
  Method	
  IDs	
  and	
  Field	
  IDs	
  
24x!	
  	
  
17
NoCache Cache
Field ID Caching
© 2013 IBM Corporation
Triggering	
  Array	
  Copies	
  
• Remember:	
  No	
  direct	
  manipula4on	
  of	
  Java	
  Objects	
  
• Basically	
  3	
  categories	
  of	
  API:	
  
•  Some4mes	
  copying	
  the	
  en4re	
  array	
  (Get*ArrayElements)	
  
•  Always	
  copy	
  a	
  por4on	
  of	
  the	
  array	
  (Get*ArrayRegion)	
  
•  (Usually)	
  Direct	
  on-­‐heap	
  access	
  (GetPrimi4veArrayCri4cal)	
  
• Be	
  aware	
  of	
  the	
  cost	
  of	
  copying!	
  
18
© 2013 IBM Corporation
Triggering	
  Array	
  Copies	
  
19
© 2013 IBM Corporation
Triggering	
  Array	
  Copies	
  
20
© 2013 IBM Corporation
Triggering	
  Array	
  Copies	
  
21
Elements Region
GetElements vs. GetRegion
8.5x!	
  	
  
© 2013 IBM Corporation
Reaching	
  Back	
  for	
  Parameters	
  
• We	
  all	
  hate	
  huge	
  func4on	
  prototypes	
  
• Basic	
  teaching	
  is	
  pass	
  the	
  object	
  go	
  from	
  there	
  
• Think	
  –	
  what	
  is	
  the	
  cost	
  of	
  accessing	
  fields	
  in	
  JNI?	
  
• Pass	
  what	
  you	
  need	
  as	
  arguments	
  
22
© 2013 IBM Corporation
Reaching	
  Back	
  for	
  Parameters	
  
23
© 2013 IBM Corporation
Reaching	
  Back	
  for	
  Parameters	
  
24
© 2013 IBM Corporation
Reaching	
  Back	
  for	
  Parameters	
  
25
Fetch Parameter
Fetching vs. Parameters
6x!	
  	
  
© 2013 IBM Corporation
Local	
  Reference	
  Abuse	
  
• Local	
  references	
  are	
  beau4ful	
  for	
  hiding	
  JVM-­‐isms	
  
• And	
  they	
  get	
  blissfully	
  ignored	
  by	
  a	
  lot	
  of	
  na4ve	
  code	
  
26
© 2013 IBM Corporation
Local	
  Reference	
  Abuse	
  
27
© 2013 IBM Corporation
Local	
  Reference	
  Abuse	
  
28
© 2013 IBM Corporation
CORRECTNESS	
  PITFALLS	
  
Hey	
  it	
  ran	
  didn’t	
  it?	
  
29
© 2013 IBM Corporation
Using	
  Array	
  API	
  Correctly	
  
• Recap:	
  Basically	
  3	
  categories	
  of	
  API	
  
•  Some4mes	
  copying	
  the	
  en4re	
  array	
  (Get*ArrayElements)	
  
•  Always	
  copy	
  a	
  por4on	
  of	
  the	
  array	
  (Get*ArrayRegion)	
  
•  (Usually)	
  Direct	
  on-­‐heap	
  access	
  (GetPrimi4veArrayCri4cal)	
  
• You	
  need	
  to	
  be	
  certain	
  that	
  you	
  are	
  geqng	
  a	
  copy!	
  
• Affected	
  by	
  VM	
  vendor,	
  GC	
  technology,	
  and	
  version	
  of	
  JDK	
  
30
© 2013 IBM Corporation
Using	
  Array	
  API	
  Correctly	
  
31
© 2013 IBM Corporation
Using	
  Array	
  API	
  Correctly	
  
32
© 2013 IBM Corporation
Respec4ng	
  “Cri4cal”	
  Sec4ons	
  
• Cri4cal	
  API:	
  Get/Release	
  for	
  (almost)	
  assured	
  direct	
  access	
  
• Idea:	
  Direct	
  on-­‐heap	
  access	
  which	
  locks	
  out	
  certain	
  JVM	
  events	
  
• General	
  advice:	
  Do	
  not	
  use	
  JNI	
  API	
  between	
  Get	
  and	
  Release	
  
33
© 2013 IBM Corporation
Respec4ng	
  “Cri4cal”	
  Sec4ons	
  
34
© 2013 IBM Corporation
Check	
  your	
  excep4ons!	
  
• Java	
  code	
  and	
  IDEs	
  really	
  help	
  you	
  with	
  excep4ons	
  
• Na4ve	
  code	
  doesn’t	
  give	
  you	
  this	
  feedback	
  
• JNI	
  API	
  can	
  raise	
  excep4ons	
  -­‐	
  Check	
  and	
  act	
  accordingly	
  
• You	
  are	
  the	
  try/catch	
  block	
  now!	
  
35
© 2013 IBM Corporation
Check	
  your	
  excep4ons!	
  
36
© 2013 IBM Corporation
Check	
  your	
  excep4ons!	
  
37
© 2013 IBM Corporation
Check	
  your	
  return	
  values!	
  
38
© 2013 IBM Corporation
Maintain	
  your	
  Global	
  References	
  
• Global	
  references	
  aren’t	
  cleaned	
  up	
  like	
  Local	
  references	
  
• Great	
  for	
  caching,	
  but	
  watch	
  out	
  for	
  leaks	
  
39
© 2013 IBM Corporation
Use	
  the	
  correct	
  JNIEnv	
  
• JNIEnv	
  are	
  unique	
  to	
  your	
  thread	
  
• Using	
  the	
  wrong	
  one	
  can	
  cause	
  subtle	
  problems	
  
• GetEnv	
  /	
  GetJavaVM	
  exist	
  from	
  the	
  invoca4on	
  API	
  
• For	
  callbacks,	
  make	
  sure	
  you	
  have	
  the	
  correct	
  one	
  available	
  
40
© 2013 IBM Corporation
EVOLUTION	
  
If	
  it	
  is	
  broken	
  you	
  should	
  probably	
  fix	
  it	
  
41
© 2013 IBM Corporation
JNI	
  is	
  good,	
  but	
  some4mes	
  its	
  in	
  the	
  way	
  
• Direct	
  func4on	
  calls	
  
• Speed	
  
• Marshalling	
  data	
  is	
  expensive	
  
• Unsigned	
  types?	
  
• Op4mizing	
  the	
  JNI	
  interface	
  can	
  be	
  tricky	
  
42
© 2013 IBM Corporation
Packed	
  Objects	
  
• A	
  solu4on	
  to	
  accessing	
  na4ve	
  data	
  
•  Session:	
  An	
  Introduc4on	
  to	
  Packed	
  Objects	
  (CON5758)	
  
43
int	
  
int	
  
Java	
   Na4ve	
  
…
int[]	
  d	
  
anObject	
  
int	
  
int	
  
int	
  
…
Object	
  header	
  
Object	
  field	
  /	
  data	
  
© 2013 IBM Corporation
References	
  
• Introduc4on	
  to	
  Packed	
  Objects	
  (CON5758)	
  
• JVMLS	
  2013:	
  Packed	
  Objects	
  (Sciampacone)	
  hup://goo.gl/jWv2Jx	
  
• John	
  Duïmovich	
  (IBM	
  Java	
  CTO)	
  hup://goo.gl/OGeDix	
  
• JNI	
  Best	
  Prac4ces	
  (Dawson,Johnson,Low)	
  hup://goo.gl/hvyGDY	
  
44
© 2013 IBM Corporation
?	
  45
© 2013 IBM Corporation
Copyright	
  and	
  Trademarks	
  
©	
  IBM	
  Corpora4on	
  2013.	
  All	
  Rights	
  Reserved.	
  	
  
	
  
IBM,	
  the	
  IBM	
  logo,	
  and	
  ibm.com	
  are	
  trademarks	
  or	
  registered	
  trademarks	
  of	
  
Interna4onal	
  Business	
  Machines	
  Corp.,	
  and	
  registered	
  in	
  many	
  jurisdic4ons	
  
worldwide.	
  	
  
	
  
Other	
  product	
  and	
  service	
  names	
  might	
  be	
  trademarks	
  of	
  IBM	
  or	
  other	
  companies.	
  	
  
	
  
A	
  current	
  list	
  of	
  IBM	
  trademarks	
  is	
  available	
  on	
  the	
  Web	
  –	
  see	
  the	
  IBM	
  “Copyright	
  and	
  
trademark	
  informa4on”	
  page	
  at	
  URL:	
  	
  www.ibm.com/legal/copytrade.shtml	
  
46

More Related Content

What's hot

Windows Debugging Tools - JavaOne 2013
Windows Debugging Tools - JavaOne 2013Windows Debugging Tools - JavaOne 2013
Windows Debugging Tools - JavaOne 2013MattKilner
 
JavaOne2013: Securing Java in the Server Room - Tim Ellison
JavaOne2013: Securing Java in the Server Room - Tim EllisonJavaOne2013: Securing Java in the Server Room - Tim Ellison
JavaOne2013: Securing Java in the Server Room - Tim EllisonChris Bailey
 
QCon Shanghai: Trends in Application Development
QCon Shanghai: Trends in Application DevelopmentQCon Shanghai: Trends in Application Development
QCon Shanghai: Trends in Application DevelopmentChris Bailey
 
Virtualization aware Java VM
Virtualization aware Java VMVirtualization aware Java VM
Virtualization aware Java VMTim Ellison
 
JavaOne2013: Secure Engineering Practices for Java
JavaOne2013: Secure Engineering Practices for JavaJavaOne2013: Secure Engineering Practices for Java
JavaOne2013: Secure Engineering Practices for JavaChris Bailey
 
JavaOne2013: Build Your Own Runtime Monitoring for the IBM JDK with the Healt...
JavaOne2013: Build Your Own Runtime Monitoring for the IBM JDK with the Healt...JavaOne2013: Build Your Own Runtime Monitoring for the IBM JDK with the Healt...
JavaOne2013: Build Your Own Runtime Monitoring for the IBM JDK with the Healt...Chris Bailey
 
WebSocket in Enterprise Applications 2015
WebSocket in Enterprise Applications 2015WebSocket in Enterprise Applications 2015
WebSocket in Enterprise Applications 2015Pavel Bucek
 
Batch Applications for Java Platform 1.0: Java EE 7 and GlassFish
Batch Applications for Java Platform 1.0: Java EE 7 and GlassFishBatch Applications for Java Platform 1.0: Java EE 7 and GlassFish
Batch Applications for Java Platform 1.0: Java EE 7 and GlassFishArun Gupta
 
What's New in IBM Java 8 SE?
What's New in IBM Java 8 SE?What's New in IBM Java 8 SE?
What's New in IBM Java 8 SE?Tim Ellison
 
CON5898 What Servlet 4.0 Means To You
CON5898 What Servlet 4.0 Means To YouCON5898 What Servlet 4.0 Means To You
CON5898 What Servlet 4.0 Means To YouEdward Burns
 
Apache Harmony: An Open Innovation
Apache Harmony: An Open InnovationApache Harmony: An Open Innovation
Apache Harmony: An Open InnovationTim Ellison
 
Five cool ways the JVM can run Apache Spark faster
Five cool ways the JVM can run Apache Spark fasterFive cool ways the JVM can run Apache Spark faster
Five cool ways the JVM can run Apache Spark fasterTim Ellison
 
Java API for WebSocket 1.0: Java EE 7 and GlassFish
Java API for WebSocket 1.0: Java EE 7 and GlassFishJava API for WebSocket 1.0: Java EE 7 and GlassFish
Java API for WebSocket 1.0: Java EE 7 and GlassFishArun Gupta
 
WebSockets in Enterprise Applications
WebSockets in Enterprise ApplicationsWebSockets in Enterprise Applications
WebSockets in Enterprise ApplicationsPavel Bucek
 
How to Thrive on REST/WebSocket-Based Microservices
How to Thrive on REST/WebSocket-Based MicroservicesHow to Thrive on REST/WebSocket-Based Microservices
How to Thrive on REST/WebSocket-Based MicroservicesPavel Bucek
 
Node.js and Oracle Database: New Development Techniques
Node.js and Oracle Database: New Development TechniquesNode.js and Oracle Database: New Development Techniques
Node.js and Oracle Database: New Development TechniquesChristopher Jones
 
Yatin's Updated Resume
Yatin's Updated ResumeYatin's Updated Resume
Yatin's Updated ResumeYatin Popli
 
The Complete Spring Tutorial
The Complete Spring TutorialThe Complete Spring Tutorial
The Complete Spring Tutorialcribes
 
Whats Next for JCA?
Whats Next for JCA?Whats Next for JCA?
Whats Next for JCA?Fred Rowe
 

What's hot (20)

Windows Debugging Tools - JavaOne 2013
Windows Debugging Tools - JavaOne 2013Windows Debugging Tools - JavaOne 2013
Windows Debugging Tools - JavaOne 2013
 
JavaOne2013: Securing Java in the Server Room - Tim Ellison
JavaOne2013: Securing Java in the Server Room - Tim EllisonJavaOne2013: Securing Java in the Server Room - Tim Ellison
JavaOne2013: Securing Java in the Server Room - Tim Ellison
 
QCon Shanghai: Trends in Application Development
QCon Shanghai: Trends in Application DevelopmentQCon Shanghai: Trends in Application Development
QCon Shanghai: Trends in Application Development
 
Virtualization aware Java VM
Virtualization aware Java VMVirtualization aware Java VM
Virtualization aware Java VM
 
JavaOne2013: Secure Engineering Practices for Java
JavaOne2013: Secure Engineering Practices for JavaJavaOne2013: Secure Engineering Practices for Java
JavaOne2013: Secure Engineering Practices for Java
 
Cloud Economics
Cloud EconomicsCloud Economics
Cloud Economics
 
JavaOne2013: Build Your Own Runtime Monitoring for the IBM JDK with the Healt...
JavaOne2013: Build Your Own Runtime Monitoring for the IBM JDK with the Healt...JavaOne2013: Build Your Own Runtime Monitoring for the IBM JDK with the Healt...
JavaOne2013: Build Your Own Runtime Monitoring for the IBM JDK with the Healt...
 
WebSocket in Enterprise Applications 2015
WebSocket in Enterprise Applications 2015WebSocket in Enterprise Applications 2015
WebSocket in Enterprise Applications 2015
 
Batch Applications for Java Platform 1.0: Java EE 7 and GlassFish
Batch Applications for Java Platform 1.0: Java EE 7 and GlassFishBatch Applications for Java Platform 1.0: Java EE 7 and GlassFish
Batch Applications for Java Platform 1.0: Java EE 7 and GlassFish
 
What's New in IBM Java 8 SE?
What's New in IBM Java 8 SE?What's New in IBM Java 8 SE?
What's New in IBM Java 8 SE?
 
CON5898 What Servlet 4.0 Means To You
CON5898 What Servlet 4.0 Means To YouCON5898 What Servlet 4.0 Means To You
CON5898 What Servlet 4.0 Means To You
 
Apache Harmony: An Open Innovation
Apache Harmony: An Open InnovationApache Harmony: An Open Innovation
Apache Harmony: An Open Innovation
 
Five cool ways the JVM can run Apache Spark faster
Five cool ways the JVM can run Apache Spark fasterFive cool ways the JVM can run Apache Spark faster
Five cool ways the JVM can run Apache Spark faster
 
Java API for WebSocket 1.0: Java EE 7 and GlassFish
Java API for WebSocket 1.0: Java EE 7 and GlassFishJava API for WebSocket 1.0: Java EE 7 and GlassFish
Java API for WebSocket 1.0: Java EE 7 and GlassFish
 
WebSockets in Enterprise Applications
WebSockets in Enterprise ApplicationsWebSockets in Enterprise Applications
WebSockets in Enterprise Applications
 
How to Thrive on REST/WebSocket-Based Microservices
How to Thrive on REST/WebSocket-Based MicroservicesHow to Thrive on REST/WebSocket-Based Microservices
How to Thrive on REST/WebSocket-Based Microservices
 
Node.js and Oracle Database: New Development Techniques
Node.js and Oracle Database: New Development TechniquesNode.js and Oracle Database: New Development Techniques
Node.js and Oracle Database: New Development Techniques
 
Yatin's Updated Resume
Yatin's Updated ResumeYatin's Updated Resume
Yatin's Updated Resume
 
The Complete Spring Tutorial
The Complete Spring TutorialThe Complete Spring Tutorial
The Complete Spring Tutorial
 
Whats Next for JCA?
Whats Next for JCA?Whats Next for JCA?
Whats Next for JCA?
 

Viewers also liked

Lukasz Kaiser at AI Frontiers: How Deep Learning Quietly Revolutionized NLP
Lukasz Kaiser at AI Frontiers: How Deep Learning Quietly Revolutionized NLPLukasz Kaiser at AI Frontiers: How Deep Learning Quietly Revolutionized NLP
Lukasz Kaiser at AI Frontiers: How Deep Learning Quietly Revolutionized NLPAI Frontiers
 
JNR: Java Native Runtime
JNR: Java Native RuntimeJNR: Java Native Runtime
JNR: Java Native RuntimeYuichi Sakuraba
 
Nikko Ström at AI Frontiers: Deep Learning in Alexa
Nikko Ström at AI Frontiers: Deep Learning in AlexaNikko Ström at AI Frontiers: Deep Learning in Alexa
Nikko Ström at AI Frontiers: Deep Learning in AlexaAI Frontiers
 
Jeff Dean at AI Frontiers: Trends and Developments in Deep Learning Research
Jeff Dean at AI Frontiers: Trends and Developments in Deep Learning ResearchJeff Dean at AI Frontiers: Trends and Developments in Deep Learning Research
Jeff Dean at AI Frontiers: Trends and Developments in Deep Learning ResearchAI Frontiers
 
Deep Learning for Data Scientists - Data Science ATL Meetup Presentation, 201...
Deep Learning for Data Scientists - Data Science ATL Meetup Presentation, 201...Deep Learning for Data Scientists - Data Science ATL Meetup Presentation, 201...
Deep Learning for Data Scientists - Data Science ATL Meetup Presentation, 201...Andrew Gardner
 
Scaling Deep Learning with MXNet
Scaling Deep Learning with MXNetScaling Deep Learning with MXNet
Scaling Deep Learning with MXNetAI Frontiers
 
Intelligent Chatbot on WeChat
Intelligent Chatbot on WeChatIntelligent Chatbot on WeChat
Intelligent Chatbot on WeChatAI Frontiers
 

Viewers also liked (7)

Lukasz Kaiser at AI Frontiers: How Deep Learning Quietly Revolutionized NLP
Lukasz Kaiser at AI Frontiers: How Deep Learning Quietly Revolutionized NLPLukasz Kaiser at AI Frontiers: How Deep Learning Quietly Revolutionized NLP
Lukasz Kaiser at AI Frontiers: How Deep Learning Quietly Revolutionized NLP
 
JNR: Java Native Runtime
JNR: Java Native RuntimeJNR: Java Native Runtime
JNR: Java Native Runtime
 
Nikko Ström at AI Frontiers: Deep Learning in Alexa
Nikko Ström at AI Frontiers: Deep Learning in AlexaNikko Ström at AI Frontiers: Deep Learning in Alexa
Nikko Ström at AI Frontiers: Deep Learning in Alexa
 
Jeff Dean at AI Frontiers: Trends and Developments in Deep Learning Research
Jeff Dean at AI Frontiers: Trends and Developments in Deep Learning ResearchJeff Dean at AI Frontiers: Trends and Developments in Deep Learning Research
Jeff Dean at AI Frontiers: Trends and Developments in Deep Learning Research
 
Deep Learning for Data Scientists - Data Science ATL Meetup Presentation, 201...
Deep Learning for Data Scientists - Data Science ATL Meetup Presentation, 201...Deep Learning for Data Scientists - Data Science ATL Meetup Presentation, 201...
Deep Learning for Data Scientists - Data Science ATL Meetup Presentation, 201...
 
Scaling Deep Learning with MXNet
Scaling Deep Learning with MXNetScaling Deep Learning with MXNet
Scaling Deep Learning with MXNet
 
Intelligent Chatbot on WeChat
Intelligent Chatbot on WeChatIntelligent Chatbot on WeChat
Intelligent Chatbot on WeChat
 

Similar to JavaOne 2013: Effective Foreign Function Interfaces: From JNI to JNR

Increased Developer Productivity for IoT with Java and Reactive Blocks (Oracl...
Increased Developer Productivity for IoT with Java and Reactive Blocks (Oracl...Increased Developer Productivity for IoT with Java and Reactive Blocks (Oracl...
Increased Developer Productivity for IoT with Java and Reactive Blocks (Oracl...Bart Jonkers
 
The OMR GC talk - Ruby Kaigi 2015
The OMR GC talk - Ruby Kaigi 2015The OMR GC talk - Ruby Kaigi 2015
The OMR GC talk - Ruby Kaigi 2015craig lehmann
 
Java and Serverless - A Match Made In Heaven, Part 1
Java and Serverless - A Match Made In Heaven, Part 1Java and Serverless - A Match Made In Heaven, Part 1
Java and Serverless - A Match Made In Heaven, Part 1Curity
 
What's new in AVR 12.0 and VS 2013
What's new in AVR 12.0 and VS 2013What's new in AVR 12.0 and VS 2013
What's new in AVR 12.0 and VS 2013Roger Pence
 
EJB 3.2/JPA 2.1 Best Practices with Real-Life Examples - CON7535
EJB 3.2/JPA 2.1 Best Practices with Real-Life Examples - CON7535EJB 3.2/JPA 2.1 Best Practices with Real-Life Examples - CON7535
EJB 3.2/JPA 2.1 Best Practices with Real-Life Examples - CON7535Ahmad Gohar
 
BGOUG 2014 Decrease Your MySQL Attack Surface
BGOUG 2014 Decrease Your MySQL Attack SurfaceBGOUG 2014 Decrease Your MySQL Attack Surface
BGOUG 2014 Decrease Your MySQL Attack SurfaceGeorgi Kodinov
 
Everything You Wanted to Know About JIT Compilation but Were Afraid to Ask [J...
Everything You Wanted to Know About JIT Compilation but Were Afraid to Ask [J...Everything You Wanted to Know About JIT Compilation but Were Afraid to Ask [J...
Everything You Wanted to Know About JIT Compilation but Were Afraid to Ask [J...David Buck
 
JavaOne 2014: Java Debugging
JavaOne 2014: Java DebuggingJavaOne 2014: Java Debugging
JavaOne 2014: Java DebuggingChris Bailey
 
FOSDEM2016 - Ruby and OMR
FOSDEM2016 - Ruby and OMRFOSDEM2016 - Ruby and OMR
FOSDEM2016 - Ruby and OMRCharlie Gracie
 
Cloud Native Java GraalVM 이상과 현실
Cloud Native Java GraalVM 이상과 현실Cloud Native Java GraalVM 이상과 현실
Cloud Native Java GraalVM 이상과 현실Taewan Kim
 
Why is Infrastructure-as-Code essential in the Cloud Age?
Why is Infrastructure-as-Code essential in the Cloud Age?Why is Infrastructure-as-Code essential in the Cloud Age?
Why is Infrastructure-as-Code essential in the Cloud Age?Andrew Ferrier
 
Serverless Patterns by Jesse Butler
Serverless Patterns by Jesse ButlerServerless Patterns by Jesse Butler
Serverless Patterns by Jesse ButlerOracle Developers
 
20191119 Cloud Native Java : GraalVM
20191119 Cloud Native Java : GraalVM20191119 Cloud Native Java : GraalVM
20191119 Cloud Native Java : GraalVMTaewan Kim
 
Autonomous Drone Development with Java and IoT
Autonomous Drone Development with Java and IoTAutonomous Drone Development with Java and IoT
Autonomous Drone Development with Java and IoTjavafxpert
 
MacRuby for Fun and Profit
MacRuby for Fun and ProfitMacRuby for Fun and Profit
MacRuby for Fun and ProfitJoshua Ballanco
 
Inception: A reverse-engineer horror History
Inception: A reverse-engineer horror HistoryInception: A reverse-engineer horror History
Inception: A reverse-engineer horror HistoryNelson Brito
 
New Repository in AEM 6 by Michael Marth
New Repository in AEM 6 by Michael MarthNew Repository in AEM 6 by Michael Marth
New Repository in AEM 6 by Michael MarthAEM HUB
 
Better Practices when Using Terraform to Manage Oracle Cloud Infrastructure
Better Practices when Using Terraform to Manage Oracle Cloud InfrastructureBetter Practices when Using Terraform to Manage Oracle Cloud Infrastructure
Better Practices when Using Terraform to Manage Oracle Cloud InfrastructureSimon Haslam
 

Similar to JavaOne 2013: Effective Foreign Function Interfaces: From JNI to JNR (20)

Increased Developer Productivity for IoT with Java and Reactive Blocks (Oracl...
Increased Developer Productivity for IoT with Java and Reactive Blocks (Oracl...Increased Developer Productivity for IoT with Java and Reactive Blocks (Oracl...
Increased Developer Productivity for IoT with Java and Reactive Blocks (Oracl...
 
The OMR GC talk - Ruby Kaigi 2015
The OMR GC talk - Ruby Kaigi 2015The OMR GC talk - Ruby Kaigi 2015
The OMR GC talk - Ruby Kaigi 2015
 
Java and Serverless - A Match Made In Heaven, Part 1
Java and Serverless - A Match Made In Heaven, Part 1Java and Serverless - A Match Made In Heaven, Part 1
Java and Serverless - A Match Made In Heaven, Part 1
 
What's new in AVR 12.0 and VS 2013
What's new in AVR 12.0 and VS 2013What's new in AVR 12.0 and VS 2013
What's new in AVR 12.0 and VS 2013
 
EJB 3.2/JPA 2.1 Best Practices with Real-Life Examples - CON7535
EJB 3.2/JPA 2.1 Best Practices with Real-Life Examples - CON7535EJB 3.2/JPA 2.1 Best Practices with Real-Life Examples - CON7535
EJB 3.2/JPA 2.1 Best Practices with Real-Life Examples - CON7535
 
BGOUG 2014 Decrease Your MySQL Attack Surface
BGOUG 2014 Decrease Your MySQL Attack SurfaceBGOUG 2014 Decrease Your MySQL Attack Surface
BGOUG 2014 Decrease Your MySQL Attack Surface
 
Everything You Wanted to Know About JIT Compilation but Were Afraid to Ask [J...
Everything You Wanted to Know About JIT Compilation but Were Afraid to Ask [J...Everything You Wanted to Know About JIT Compilation but Were Afraid to Ask [J...
Everything You Wanted to Know About JIT Compilation but Were Afraid to Ask [J...
 
JavaOne 2014: Java Debugging
JavaOne 2014: Java DebuggingJavaOne 2014: Java Debugging
JavaOne 2014: Java Debugging
 
FOSDEM2016 - Ruby and OMR
FOSDEM2016 - Ruby and OMRFOSDEM2016 - Ruby and OMR
FOSDEM2016 - Ruby and OMR
 
S109 cics-java
S109 cics-javaS109 cics-java
S109 cics-java
 
Cloud Native Java GraalVM 이상과 현실
Cloud Native Java GraalVM 이상과 현실Cloud Native Java GraalVM 이상과 현실
Cloud Native Java GraalVM 이상과 현실
 
Why is Infrastructure-as-Code essential in the Cloud Age?
Why is Infrastructure-as-Code essential in the Cloud Age?Why is Infrastructure-as-Code essential in the Cloud Age?
Why is Infrastructure-as-Code essential in the Cloud Age?
 
Java one2016
Java one2016Java one2016
Java one2016
 
Serverless Patterns by Jesse Butler
Serverless Patterns by Jesse ButlerServerless Patterns by Jesse Butler
Serverless Patterns by Jesse Butler
 
20191119 Cloud Native Java : GraalVM
20191119 Cloud Native Java : GraalVM20191119 Cloud Native Java : GraalVM
20191119 Cloud Native Java : GraalVM
 
Autonomous Drone Development with Java and IoT
Autonomous Drone Development with Java and IoTAutonomous Drone Development with Java and IoT
Autonomous Drone Development with Java and IoT
 
MacRuby for Fun and Profit
MacRuby for Fun and ProfitMacRuby for Fun and Profit
MacRuby for Fun and Profit
 
Inception: A reverse-engineer horror History
Inception: A reverse-engineer horror HistoryInception: A reverse-engineer horror History
Inception: A reverse-engineer horror History
 
New Repository in AEM 6 by Michael Marth
New Repository in AEM 6 by Michael MarthNew Repository in AEM 6 by Michael Marth
New Repository in AEM 6 by Michael Marth
 
Better Practices when Using Terraform to Manage Oracle Cloud Infrastructure
Better Practices when Using Terraform to Manage Oracle Cloud InfrastructureBetter Practices when Using Terraform to Manage Oracle Cloud Infrastructure
Better Practices when Using Terraform to Manage Oracle Cloud Infrastructure
 

Recently uploaded

A Call to Action for Generative AI in 2024
A Call to Action for Generative AI in 2024A Call to Action for Generative AI in 2024
A Call to Action for Generative AI in 2024Results
 
Real Time Object Detection Using Open CV
Real Time Object Detection Using Open CVReal Time Object Detection Using Open CV
Real Time Object Detection Using Open CVKhem
 
Automating Google Workspace (GWS) & more with Apps Script
Automating Google Workspace (GWS) & more with Apps ScriptAutomating Google Workspace (GWS) & more with Apps Script
Automating Google Workspace (GWS) & more with Apps Scriptwesley chun
 
Bajaj Allianz Life Insurance Company - Insurer Innovation Award 2024
Bajaj Allianz Life Insurance Company - Insurer Innovation Award 2024Bajaj Allianz Life Insurance Company - Insurer Innovation Award 2024
Bajaj Allianz Life Insurance Company - Insurer Innovation Award 2024The Digital Insurer
 
Boost PC performance: How more available memory can improve productivity
Boost PC performance: How more available memory can improve productivityBoost PC performance: How more available memory can improve productivity
Boost PC performance: How more available memory can improve productivityPrincipled Technologies
 
From Event to Action: Accelerate Your Decision Making with Real-Time Automation
From Event to Action: Accelerate Your Decision Making with Real-Time AutomationFrom Event to Action: Accelerate Your Decision Making with Real-Time Automation
From Event to Action: Accelerate Your Decision Making with Real-Time AutomationSafe Software
 
A Domino Admins Adventures (Engage 2024)
A Domino Admins Adventures (Engage 2024)A Domino Admins Adventures (Engage 2024)
A Domino Admins Adventures (Engage 2024)Gabriella Davis
 
08448380779 Call Girls In Civil Lines Women Seeking Men
08448380779 Call Girls In Civil Lines Women Seeking Men08448380779 Call Girls In Civil Lines Women Seeking Men
08448380779 Call Girls In Civil Lines Women Seeking MenDelhi Call girls
 
08448380779 Call Girls In Friends Colony Women Seeking Men
08448380779 Call Girls In Friends Colony Women Seeking Men08448380779 Call Girls In Friends Colony Women Seeking Men
08448380779 Call Girls In Friends Colony Women Seeking MenDelhi Call girls
 
Apidays Singapore 2024 - Building Digital Trust in a Digital Economy by Veron...
Apidays Singapore 2024 - Building Digital Trust in a Digital Economy by Veron...Apidays Singapore 2024 - Building Digital Trust in a Digital Economy by Veron...
Apidays Singapore 2024 - Building Digital Trust in a Digital Economy by Veron...apidays
 
GenCyber Cyber Security Day Presentation
GenCyber Cyber Security Day PresentationGenCyber Cyber Security Day Presentation
GenCyber Cyber Security Day PresentationMichael W. Hawkins
 
Finology Group – Insurtech Innovation Award 2024
Finology Group – Insurtech Innovation Award 2024Finology Group – Insurtech Innovation Award 2024
Finology Group – Insurtech Innovation Award 2024The Digital Insurer
 
Workshop - Best of Both Worlds_ Combine KG and Vector search for enhanced R...
Workshop - Best of Both Worlds_ Combine  KG and Vector search for  enhanced R...Workshop - Best of Both Worlds_ Combine  KG and Vector search for  enhanced R...
Workshop - Best of Both Worlds_ Combine KG and Vector search for enhanced R...Neo4j
 
Axa Assurance Maroc - Insurer Innovation Award 2024
Axa Assurance Maroc - Insurer Innovation Award 2024Axa Assurance Maroc - Insurer Innovation Award 2024
Axa Assurance Maroc - Insurer Innovation Award 2024The Digital Insurer
 
How to Troubleshoot Apps for the Modern Connected Worker
How to Troubleshoot Apps for the Modern Connected WorkerHow to Troubleshoot Apps for the Modern Connected Worker
How to Troubleshoot Apps for the Modern Connected WorkerThousandEyes
 
[2024]Digital Global Overview Report 2024 Meltwater.pdf
[2024]Digital Global Overview Report 2024 Meltwater.pdf[2024]Digital Global Overview Report 2024 Meltwater.pdf
[2024]Digital Global Overview Report 2024 Meltwater.pdfhans926745
 
EIS-Webinar-Prompt-Knowledge-Eng-2024-04-08.pptx
EIS-Webinar-Prompt-Knowledge-Eng-2024-04-08.pptxEIS-Webinar-Prompt-Knowledge-Eng-2024-04-08.pptx
EIS-Webinar-Prompt-Knowledge-Eng-2024-04-08.pptxEarley Information Science
 
Understanding Discord NSFW Servers A Guide for Responsible Users.pdf
Understanding Discord NSFW Servers A Guide for Responsible Users.pdfUnderstanding Discord NSFW Servers A Guide for Responsible Users.pdf
Understanding Discord NSFW Servers A Guide for Responsible Users.pdfUK Journal
 
Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...
Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...
Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...Miguel Araújo
 
IAC 2024 - IA Fast Track to Search Focused AI Solutions
IAC 2024 - IA Fast Track to Search Focused AI SolutionsIAC 2024 - IA Fast Track to Search Focused AI Solutions
IAC 2024 - IA Fast Track to Search Focused AI SolutionsEnterprise Knowledge
 

Recently uploaded (20)

A Call to Action for Generative AI in 2024
A Call to Action for Generative AI in 2024A Call to Action for Generative AI in 2024
A Call to Action for Generative AI in 2024
 
Real Time Object Detection Using Open CV
Real Time Object Detection Using Open CVReal Time Object Detection Using Open CV
Real Time Object Detection Using Open CV
 
Automating Google Workspace (GWS) & more with Apps Script
Automating Google Workspace (GWS) & more with Apps ScriptAutomating Google Workspace (GWS) & more with Apps Script
Automating Google Workspace (GWS) & more with Apps Script
 
Bajaj Allianz Life Insurance Company - Insurer Innovation Award 2024
Bajaj Allianz Life Insurance Company - Insurer Innovation Award 2024Bajaj Allianz Life Insurance Company - Insurer Innovation Award 2024
Bajaj Allianz Life Insurance Company - Insurer Innovation Award 2024
 
Boost PC performance: How more available memory can improve productivity
Boost PC performance: How more available memory can improve productivityBoost PC performance: How more available memory can improve productivity
Boost PC performance: How more available memory can improve productivity
 
From Event to Action: Accelerate Your Decision Making with Real-Time Automation
From Event to Action: Accelerate Your Decision Making with Real-Time AutomationFrom Event to Action: Accelerate Your Decision Making with Real-Time Automation
From Event to Action: Accelerate Your Decision Making with Real-Time Automation
 
A Domino Admins Adventures (Engage 2024)
A Domino Admins Adventures (Engage 2024)A Domino Admins Adventures (Engage 2024)
A Domino Admins Adventures (Engage 2024)
 
08448380779 Call Girls In Civil Lines Women Seeking Men
08448380779 Call Girls In Civil Lines Women Seeking Men08448380779 Call Girls In Civil Lines Women Seeking Men
08448380779 Call Girls In Civil Lines Women Seeking Men
 
08448380779 Call Girls In Friends Colony Women Seeking Men
08448380779 Call Girls In Friends Colony Women Seeking Men08448380779 Call Girls In Friends Colony Women Seeking Men
08448380779 Call Girls In Friends Colony Women Seeking Men
 
Apidays Singapore 2024 - Building Digital Trust in a Digital Economy by Veron...
Apidays Singapore 2024 - Building Digital Trust in a Digital Economy by Veron...Apidays Singapore 2024 - Building Digital Trust in a Digital Economy by Veron...
Apidays Singapore 2024 - Building Digital Trust in a Digital Economy by Veron...
 
GenCyber Cyber Security Day Presentation
GenCyber Cyber Security Day PresentationGenCyber Cyber Security Day Presentation
GenCyber Cyber Security Day Presentation
 
Finology Group – Insurtech Innovation Award 2024
Finology Group – Insurtech Innovation Award 2024Finology Group – Insurtech Innovation Award 2024
Finology Group – Insurtech Innovation Award 2024
 
Workshop - Best of Both Worlds_ Combine KG and Vector search for enhanced R...
Workshop - Best of Both Worlds_ Combine  KG and Vector search for  enhanced R...Workshop - Best of Both Worlds_ Combine  KG and Vector search for  enhanced R...
Workshop - Best of Both Worlds_ Combine KG and Vector search for enhanced R...
 
Axa Assurance Maroc - Insurer Innovation Award 2024
Axa Assurance Maroc - Insurer Innovation Award 2024Axa Assurance Maroc - Insurer Innovation Award 2024
Axa Assurance Maroc - Insurer Innovation Award 2024
 
How to Troubleshoot Apps for the Modern Connected Worker
How to Troubleshoot Apps for the Modern Connected WorkerHow to Troubleshoot Apps for the Modern Connected Worker
How to Troubleshoot Apps for the Modern Connected Worker
 
[2024]Digital Global Overview Report 2024 Meltwater.pdf
[2024]Digital Global Overview Report 2024 Meltwater.pdf[2024]Digital Global Overview Report 2024 Meltwater.pdf
[2024]Digital Global Overview Report 2024 Meltwater.pdf
 
EIS-Webinar-Prompt-Knowledge-Eng-2024-04-08.pptx
EIS-Webinar-Prompt-Knowledge-Eng-2024-04-08.pptxEIS-Webinar-Prompt-Knowledge-Eng-2024-04-08.pptx
EIS-Webinar-Prompt-Knowledge-Eng-2024-04-08.pptx
 
Understanding Discord NSFW Servers A Guide for Responsible Users.pdf
Understanding Discord NSFW Servers A Guide for Responsible Users.pdfUnderstanding Discord NSFW Servers A Guide for Responsible Users.pdf
Understanding Discord NSFW Servers A Guide for Responsible Users.pdf
 
Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...
Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...
Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...
 
IAC 2024 - IA Fast Track to Search Focused AI Solutions
IAC 2024 - IA Fast Track to Search Focused AI SolutionsIAC 2024 - IA Fast Track to Search Focused AI Solutions
IAC 2024 - IA Fast Track to Search Focused AI Solutions
 

JavaOne 2013: Effective Foreign Function Interfaces: From JNI to JNR

  • 1. © 2013 IBM Corporation Ryan  A.  Sciampacone  –  Managed  Run4me  Architect   25  September  2013   Effec4ve  Foreign  Func4on  Interfaces:   From  JNI  to  JNR  
  • 2. © 2013 IBM Corporation Important  Disclaimers   THE  INFORMATION  CONTAINED  IN  THIS  PRESENTATION  IS  PROVIDED  FOR  INFORMATIONAL  PURPOSES  ONLY.     WHILST  EFFORTS  WERE  MADE  TO  VERIFY  THE  COMPLETENESS  AND  ACCURACY  OF  THE  INFORMATION  CONTAINED  IN  THIS   PRESENTATION,  IT  IS  PROVIDED  “AS  IS”,  WITHOUT  WARRANTY  OF  ANY  KIND,  EXPRESS  OR  IMPLIED.     ALL  PERFORMANCE  DATA  INCLUDED  IN  THIS  PRESENTATION  HAVE  BEEN  GATHERED  IN  A  CONTROLLED  ENVIRONMENT.    YOUR  OWN   TEST  RESULTS  MAY  VARY  BASED  ON  HARDWARE,  SOFTWARE  OR  INFRASTRUCTURE  DIFFERENCES.   ALL  DATA  INCLUDED  IN  THIS  PRESENTATION  ARE  MEANT  TO  BE  USED  ONLY  AS  A  GUIDE.   IN  ADDITION,  THE  INFORMATION  CONTAINED  IN  THIS  PRESENTATION  IS  BASED  ON  IBM’S  CURRENT  PRODUCT  PLANS  AND  STRATEGY,   WHICH  ARE  SUBJECT  TO  CHANGE  BY  IBM,  WITHOUT  NOTICE.     IBM  AND  ITS  AFFILIATED  COMPANIES  SHALL  NOT  BE  RESPONSIBLE  FOR  ANY  DAMAGES  ARISING  OUT  OF  THE  USE  OF,  OR  OTHERWISE   RELATED  TO,  THIS  PRESENTATION  OR  ANY  OTHER  DOCUMENTATION.     NOTHING  CONTAINED  IN  THIS  PRESENTATION  IS  INTENDED  TO,  OR  SHALL  HAVE  THE  EFFECT  OF:     -­‐  CREATING  ANY  WARRANT  OR  REPRESENTATION  FROM  IBM,  ITS  AFFILIATED  COMPANIES  OR  ITS  OR  THEIR  SUPPLIERS  AND/OR   LICENSORS   2
  • 3. © 2013 IBM Corporation Your  Speaker:  Ryan  A.  Sciampacone   • Run4me  Architect  @  IBM  (JTC)   •  Interpreters   •  Garbage  Collec4on   •  Plaborm  interfacing  /  op4miza4on   •  Hardware  exploita4on   (E)  ryan_sciampacone@ca.ibm.com   (T)  @rsciampacone   3
  • 4. © 2013 IBM Corporation What  should  you  get  from  this?   • Why  a  foreign  func4on  interface  (FFI)  is  important   • Performance  4ps  /  common  piballs  when  using  JNI   • Next  steps  in  the  evolu4on  of  the  FFI  for  Java   • At  the  very  least,  45  minutes  or  so  of  entertainment   4
  • 5. © 2013 IBM Corporation WHY  IS  AN  FFI  IMPORTANT?   What  the  Java  Na4ve  Interface  (JNI)  does  for  you…   5
  • 6. © 2013 IBM Corporation Why  have  a  FFI?   • Plaborm  interfacing   • Legacy  System  Support   • Cross  Language  Interop   • Speed   6
  • 7. © 2013 IBM Corporation Mo4va4ng  Example:  Missed  some  API   • New  things  come  up  /  Some  things  missed   7
  • 8. © 2013 IBM Corporation JNI  Call  Example   Java:   8 C:  
  • 9. © 2013 IBM Corporation Benefits  of  the  JNI  implementa4on   • API  based   • GC  Safety   • Java  /  JVM  based  ac4vity  not  blocked   • Plaborm  agnos4c   • Clear  lines  between  Java  /  plaborm   • Founda4on  for  JVM  Tooling  (JVMTI)   9
  • 10. © 2013 IBM Corporation JNI  API  Building  Blocks   10
  • 11. © 2013 IBM Corporation JNIEnv  is  your  lifeline   • JNIEnv  is  the  connec4on  back  to  the  “Java  world”   • Calls  through  the  JNIEnv  are  effec4vely  round  trip   • Performance  is  dependent  on  keeping  round  trips  down   11
  • 12. © 2013 IBM Corporation PERFORMANCE  PITFALLS   But  it’s  already  slow,  what’s  a  few  more  instruc4ons?   12
  • 13. © 2013 IBM Corporation Caching  Classes,  Method  IDs  and  Field  IDs   • Core  elements  when  interac4ng  with  objects   • Effec4vely  your  na4ve  “resolve”  point   • Not  as  cheap  to  acquire   • So  cache  them!   13
  • 14. © 2013 IBM Corporation Basic  ID  use   14
  • 15. © 2013 IBM Corporation Caching  Classes,  Method  IDs  and  Field  IDs   15
  • 16. © 2013 IBM Corporation Caching  Classes,  Method  IDs  and  Field  IDs   16
  • 17. © 2013 IBM Corporation Caching  Classes,  Method  IDs  and  Field  IDs   24x!     17 NoCache Cache Field ID Caching
  • 18. © 2013 IBM Corporation Triggering  Array  Copies   • Remember:  No  direct  manipula4on  of  Java  Objects   • Basically  3  categories  of  API:   •  Some4mes  copying  the  en4re  array  (Get*ArrayElements)   •  Always  copy  a  por4on  of  the  array  (Get*ArrayRegion)   •  (Usually)  Direct  on-­‐heap  access  (GetPrimi4veArrayCri4cal)   • Be  aware  of  the  cost  of  copying!   18
  • 19. © 2013 IBM Corporation Triggering  Array  Copies   19
  • 20. © 2013 IBM Corporation Triggering  Array  Copies   20
  • 21. © 2013 IBM Corporation Triggering  Array  Copies   21 Elements Region GetElements vs. GetRegion 8.5x!    
  • 22. © 2013 IBM Corporation Reaching  Back  for  Parameters   • We  all  hate  huge  func4on  prototypes   • Basic  teaching  is  pass  the  object  go  from  there   • Think  –  what  is  the  cost  of  accessing  fields  in  JNI?   • Pass  what  you  need  as  arguments   22
  • 23. © 2013 IBM Corporation Reaching  Back  for  Parameters   23
  • 24. © 2013 IBM Corporation Reaching  Back  for  Parameters   24
  • 25. © 2013 IBM Corporation Reaching  Back  for  Parameters   25 Fetch Parameter Fetching vs. Parameters 6x!    
  • 26. © 2013 IBM Corporation Local  Reference  Abuse   • Local  references  are  beau4ful  for  hiding  JVM-­‐isms   • And  they  get  blissfully  ignored  by  a  lot  of  na4ve  code   26
  • 27. © 2013 IBM Corporation Local  Reference  Abuse   27
  • 28. © 2013 IBM Corporation Local  Reference  Abuse   28
  • 29. © 2013 IBM Corporation CORRECTNESS  PITFALLS   Hey  it  ran  didn’t  it?   29
  • 30. © 2013 IBM Corporation Using  Array  API  Correctly   • Recap:  Basically  3  categories  of  API   •  Some4mes  copying  the  en4re  array  (Get*ArrayElements)   •  Always  copy  a  por4on  of  the  array  (Get*ArrayRegion)   •  (Usually)  Direct  on-­‐heap  access  (GetPrimi4veArrayCri4cal)   • You  need  to  be  certain  that  you  are  geqng  a  copy!   • Affected  by  VM  vendor,  GC  technology,  and  version  of  JDK   30
  • 31. © 2013 IBM Corporation Using  Array  API  Correctly   31
  • 32. © 2013 IBM Corporation Using  Array  API  Correctly   32
  • 33. © 2013 IBM Corporation Respec4ng  “Cri4cal”  Sec4ons   • Cri4cal  API:  Get/Release  for  (almost)  assured  direct  access   • Idea:  Direct  on-­‐heap  access  which  locks  out  certain  JVM  events   • General  advice:  Do  not  use  JNI  API  between  Get  and  Release   33
  • 34. © 2013 IBM Corporation Respec4ng  “Cri4cal”  Sec4ons   34
  • 35. © 2013 IBM Corporation Check  your  excep4ons!   • Java  code  and  IDEs  really  help  you  with  excep4ons   • Na4ve  code  doesn’t  give  you  this  feedback   • JNI  API  can  raise  excep4ons  -­‐  Check  and  act  accordingly   • You  are  the  try/catch  block  now!   35
  • 36. © 2013 IBM Corporation Check  your  excep4ons!   36
  • 37. © 2013 IBM Corporation Check  your  excep4ons!   37
  • 38. © 2013 IBM Corporation Check  your  return  values!   38
  • 39. © 2013 IBM Corporation Maintain  your  Global  References   • Global  references  aren’t  cleaned  up  like  Local  references   • Great  for  caching,  but  watch  out  for  leaks   39
  • 40. © 2013 IBM Corporation Use  the  correct  JNIEnv   • JNIEnv  are  unique  to  your  thread   • Using  the  wrong  one  can  cause  subtle  problems   • GetEnv  /  GetJavaVM  exist  from  the  invoca4on  API   • For  callbacks,  make  sure  you  have  the  correct  one  available   40
  • 41. © 2013 IBM Corporation EVOLUTION   If  it  is  broken  you  should  probably  fix  it   41
  • 42. © 2013 IBM Corporation JNI  is  good,  but  some4mes  its  in  the  way   • Direct  func4on  calls   • Speed   • Marshalling  data  is  expensive   • Unsigned  types?   • Op4mizing  the  JNI  interface  can  be  tricky   42
  • 43. © 2013 IBM Corporation Packed  Objects   • A  solu4on  to  accessing  na4ve  data   •  Session:  An  Introduc4on  to  Packed  Objects  (CON5758)   43 int   int   Java   Na4ve   … int[]  d   anObject   int   int   int   … Object  header   Object  field  /  data  
  • 44. © 2013 IBM Corporation References   • Introduc4on  to  Packed  Objects  (CON5758)   • JVMLS  2013:  Packed  Objects  (Sciampacone)  hup://goo.gl/jWv2Jx   • John  Duïmovich  (IBM  Java  CTO)  hup://goo.gl/OGeDix   • JNI  Best  Prac4ces  (Dawson,Johnson,Low)  hup://goo.gl/hvyGDY   44
  • 45. © 2013 IBM Corporation ?  45
  • 46. © 2013 IBM Corporation Copyright  and  Trademarks   ©  IBM  Corpora4on  2013.  All  Rights  Reserved.       IBM,  the  IBM  logo,  and  ibm.com  are  trademarks  or  registered  trademarks  of   Interna4onal  Business  Machines  Corp.,  and  registered  in  many  jurisdic4ons   worldwide.       Other  product  and  service  names  might  be  trademarks  of  IBM  or  other  companies.       A  current  list  of  IBM  trademarks  is  available  on  the  Web  –  see  the  IBM  “Copyright  and   trademark  informa4on”  page  at  URL:    www.ibm.com/legal/copytrade.shtml   46