3. Program Agenda
• JVM to Multi-language VM
• Invoke bytecodes
• InvokeDynamic
• JSR-292 API
• Examples
3
4. Program Agenda
• JVM to Multi-language VM
• Invoke bytecodes
• InvokeDynamic
• JSR-292 API
• Examples
4
5. JVM to Multi-Language VM
Many languages are already available on JVM
• Programming languages for Java Virtual Machine
• http://www.is-research.de/info/vmlanguages/category/jvm-language/
BeanShell, Clojure, Groovy, JRuby, Mirah,
JavaFX, Rhino, Nashorn, Kawa, Smalltalk,
Jython, Scala, Ceylon, Kotlin,...
•
5
6. JVM to Multi-Language VM
The Da Vinci Machine Project
• a multi-language renaissance for the JVM
• http://openjdk.java.net/projects/mlvm/
• mailing list http://mail.openjdk.java.net/mailman/listinfo/mlvm-dev
• sub-projects
Dynamic Invocation Lightweight method objects
Lightweight bytecode loading Interface Injection
Continuations and stack introspection Tail calls and tail recursion
Tuples and value-oriented types Immediate wrapper types
Runtime support for closures Runtime support for multimethods
Faster interface invocation Faster reflection
Symbolic freedom
6
7. JVM to Multi-Language VM
JSR-292
• Dynamic Invocation
• invokedynamic
VM
bootstrap
• Lightweight method objects
• MethodHandle
invokedynamic bootstrap CallSite
MethodHandle function pointer
7
8. JVM to Multi-Language VM
JVM Language Summit
•
VM
• http://openjdk.java.net/projects/mlvm/jvmlangsummit/
• Wiki page invokedynamic
• http://www.wiki.jvmlangsummit.com/Main_Page
• 2011
• http://medianetwork.oracle.com/media/show/16998 - 17017
• 17014 Method Handles and Beyond / John Rose
• 17008 JSR 292 Cookbook / Rémi Forax
• 17016 Adding invokedynamic Support to JRuby / Charles Nutter
8
9. JVM to Multi-Language VM
Other resources
• JSR-292 Cookbook
• http://code.google.com/p/jsr292-cookbook/
• JSR-292 API
• https://github.com/headius/invokebinder
• MethodHandle
•
• https://github.com/ytoshima/indy-samples
• git clone https://github.com/ytoshima/indy-samples.git
9
10. JVM to Multi-Language VM
Other resources
• JRuby
• invokedynamic
git clone http://github.com/jruby/jruby.git
export JAVA_HOME=<path to jdk7>
See
cd jruby
InvokeDynamicSupport.java
ant
for bootstrap method
bin/jruby --bytecode test/fib.rb
implementation
:
ALOAD 1
INVOKEDYNAMIC getFixnum (Lorg/jruby/runtime/ThreadContext;)Lorg/jruby/RubyFixnum;
[org/jruby/runtime/invokedynamic/InvokeDynamicSupport.getFixnumBootstrap(Ljava/lang/
invoke/MethodHandles$Lookup;Ljava/lang/String;Ljava/lang/invoke/MethodType;J)Ljava/
lang/invoke/CallSite; (6), 0]
10
11. Program Agenda
• JVM to Multi-language VM
• Invoke bytecodes
• InvokeDynamic
• JSR-292 API
• Examples
11