tags:

views:

265

answers:

4

How much of the Java SE api is actually written in Java itself?

+3  A: 

The easiest way to find out is just to look at the source code (that's from Sun's J2SE website; there's also the OpenJDK source for 6 and 7). It's pretty much as you'd expect - things which absolutely have to be written in native code, e.g. "open a socket or a file" are native, but almost everything else is written in Java (in Sun's implementation, anyway).

Jon Skeet
Wow Jon! You know Java as well!?I have just bought "C# In Depth". It's really good. Congrats!
Pablo Santa Cruz
Java is my day job - C# is my passion :) Glad you're enjoying the book - please let me know what you'd like to see in the 2nd edition: http://msmvps.com/jon.skeet
Jon Skeet
Skeeted by 32 seconds. *sigh*
Michael Myers
+2  A: 

Download OpenJDK and find out!

Most of it is Java, but there are some low-level things that must be native code (graphics and file operations come to mind).

Michael Myers
A: 

I don't have numbers, but it should be easy to compute.

If you want to take into consideration the total number of methods of the API to calculate a %, you could just count the total number and the ones with the native keyword on their definitions.

You can perform this calculation by parsing SUN's open source implementation source code.

Pablo Santa Cruz
+1  A: 

Download Apache Harmony and find out!

Around 85% of Sun's JRE is written in Java. In fact very little has to be written in native code. IBM's Jikes RVM (formerly Jalapeño) and Sun's Maxine are JVMs almost entirely written in Java. Most of the native code in Sun's JRE is native for legacy reasons. Some because it's convenient. A very small amount is native because it is (or was) fractionally faster.

Tom Hawtin - tackline