Table of Contents for Programming Languages: a survey

"Most people talk about Java the language, and this may sound odd coming from me, but I could hardly care less. At the core of the Java ecosystem is the JVM." -- James Gosling, Creator of the Java Programming Language(2011, TheServerSide?)

JVM bytecode


9 primitive types: int, long, short, byte, char, float, double, bool, reference

invokedynamic Dynalink (Dynamic Linker Framework)


JVM bytecode verification • JVM bytecode is statically verified before execution - An instruction must work on stack operands and variables of the right type - A method must use no more local variables and no more local stack positions than it claims to - For every point in the bytecode, the local stack has the same depth every time it is reached - A method must not throw more exceptions than it admits - A method must end with a return value or throw instruction - Method must not use one half of a two word value

Additional JVM runtime checks • Array bounds check • Array assignment type checks • Null reference checks • Checked casts • Bottom line: - A JVM program cannot read or overwrite arbitrary memory - Better debugging, better security - No buffer overflow attacks, worms, etc as in C/C++

" -- Rasmus Ejlers Møgelberg,

In JVM instructions, local variables are referred to by one- or two-byte index numbers ((some or all?) functions using local variables have a 'wide' form which indicates that the index will be two bytes long.). E.g. [1], [2].



(note that the POP and SWAP instructions don't specify a type, but they can only operate on certain types; see the spec). The allowed types are ones which always occupy only a single location in the stack (eg 'float'); other types which sometimes or always occupy multiple consecutive locations in the stack (eg 'double') cannot have eg SWAP applied to them.


issues with the JSR/RET instructions

Instructions Appendix A, page 16 provides a categorization of JVM instructions into 13 categories: load store stackop cond iinc get put new monitor invoke return throw other ('other' is just wide,breakpoint, impdep1, impdep2)

Dynamic profiling of the most common bytecodes may be found in Table 5, pdf page 5 of [4].


with constants: (a
dfi)(loadstore) (a=references, d=doubles, f=float, i=integer)
bcdfils)(aloadastore) anewarray arraylength getfield getstatic multianewarray new newarray putfield putstatic
fil): add sub mul div neg rem
l) and or xor shl shr ushr
dfil)return athrow goto goto_w invokedynamic invokeinterface invokespecial invokestatic invokevirtual jsr jsr_w lookupswitch ret tableswitch
il) f2(dil) i2(bcdfls) l2(dfi)



on Android

Android has a non-canonical JVM compiler that called 'Dalvik' that compiles to another Dalvik-specific VM.

It doesn't support invokedynamic. (?)


Squawk and Java Card

"As for size, there's a lot of stuff in class files that you can remove if you don't require too much debug info. .suite and .cap files (Squawk en Java Card) are much, much smaller than .class for instance." -- inopia

Suitability for languages other than Java

" But I hear a lot of complaints from those people about how much of the Java language is baked into the JVM. For example, it makes it really difficult to do tail-call optimization, call-with-current-continuation, or fully-dynamic method calls, and integers are not objects. " -- Kragen Sitaker (in 2008, so may be very out of date by now)

early non-Java JVM languages: "The first alternatives were targeting the scripting domain: Jython, a Python implementation for the JVM, as well as Rhino and JavaScript? engines for the JVM, appeared in 1997, followed by BeanShell? in 2000 and JRuby in 2001." [5]