50

What language is Sun's JVM written in?

John Woo
  • 258,903
  • 69
  • 498
  • 492
Ethan
  • 57,819
  • 63
  • 187
  • 237
  • 1
    possible duplicate of [In which language are the Java compiler, JVM and Java written?](http://stackoverflow.com/questions/1220914/in-which-language-are-the-java-compiler-jvm-and-java-written). This is older, but it is a subset and has less votes. – Ciro Santilli OurBigBook.com Mar 05 '15 at 13:08

4 Answers4

42

Sun actually has multiple JVMs. The HotSpot JVM is written largely in C++, because HotSpot is heavily based on the Animorphic Smalltalk VM which is written in C++.

More interesting than HotSpot is IMHO the Maxine Research VM, which is written (almost) completely in Java.

Jörg W Mittag
  • 363,080
  • 75
  • 446
  • 653
25

Strictly speaking, C++ (the JVM code does make use of C++ OO facilities).

Neil Coffey
  • 21,615
  • 7
  • 62
  • 83
9

You can find out for yourself at: http://www.sun.com/software/opensource/java/.

5

C.

Sun's not a Java shop; it's a C shop. That's what Solaris is written in.

duffymo
  • 305,152
  • 44
  • 369
  • 561
  • 2
    It should be noted that nearly all the Java standard libraries however are written in Java. – cletus Jan 04 '09 at 02:51
  • 1
    Absolutely correct, of course, but the question was about the JVM itself. – duffymo Jan 04 '09 at 02:52
  • At a guess, the C source includes some ASM - conditionally compiled on certain mainstream architectures. – slim Jan 04 '09 at 02:54
  • Also: Sun's a big company. Parts of it will be a 'C shop', other parts will be writing in Java, or in shell, or Perl, or whatever. Solaris is written in C largely because when they got SysV from AT&T it was in C. – slim Jan 04 '09 at 03:05
  • Still, a large part of the JVM is written in C. (Or, was when I last looked at it.) – Jonathan Leffler Jan 04 '09 at 03:13
  • slim: The interpreters are written in an assembly language-like way in C++ (the C++ generates machine code). – Tom Hawtin - tackline Jan 04 '09 at 13:38
  • Some of the libraries are written in C, some date back to before Java. Most of the libraries are Java. HotSpot is low-church C++, not C. – Tom Hawtin - tackline Jan 04 '09 at 13:39
  • 2
    Silly response. They were supposed to jump in the time machine and suggest Java for implementing Unix in 1970? They were supposed to rewrite their Solaris in Java? There have been a few Java OS's written, none targeting servers like Solaris does. – John M Jan 09 '09 at 20:21