This chapter discusses the distribution of the Java source code. It also covers platform-specific issues that affect the porting of Java. You will look at the validity and issues of platform benchmarks. When you finish this chapter, you will have a better understanding of Sun's role in the evolution of Java, as well as what is involved in porting Java.
If you are coming from a purely DOS/Windows background, the concept of releasing the source code for a product might seem a little ridiculous. If you are coming from a UNIX background, this idea is completely native to you. Why is the concept of releasing source so alien to the DOS/Windows world, and so native to the UNIX world? The reason stems from the homogeneous nature of the IBM pc and the heterogeneous platforms of the UNIX world. Therein lies Sun's motivation to release Java source to the masses.
In the IBM pc world, the 80x86 processor reigned supreme. All executables compiled for this architecture would run on any IBM pc. Life in the UNIX world was nowhere near as easy. Programs were released with full source code so that they could be compiled onto the specific platform. Sun, coming from a UNIX background, is used to cross-platform issues. This is the reason for the distribution of the Java source code. However, Sun is also in the business to make money, so the distribution of the source code has some hitches.
Sun provides two different licensing options: one is free and the other one will cost you. The free option is for noncommercial purposes such as education. For more information, contact http://www.javasoft.com/source.html.
The commercial distribution license provides Sun a mechanism for revenue as well as control over the technology. For more information, contact http://www.javasoft.com/comm_license.html.
If you have detailed questions about either option, these sites should lead you into the right direction.
If Java were simply a native code compiler, the process of porting to different platforms would not be that difficult. Unfortunately, for porting purposes, the Java Developer's Kit (JDK) is compiled into Java virtual machine (JVM) executable programs. Unless the Java executable is being run on a native JVM, the executable needs to be interpreted into the instructions supported by the current platform. Porting the Java compiler onto other machines does not require nearly the effort of porting the Java runtime interpreter.
From the Java compiler's perspective, the platform on which it is being executed does not really matter. The Java compiler actually does not need to know anything specific about the current platform, which minimizes the cross-platform differences.
The Java runtime library, on the other hand, is a completely different story. The entire point of having a runtime interpreter is to convert JVM operations into machine-specific code. In many cases this is not simply a one-to-one translation. A number of platform-specific issues constitute drastic platform differences in the Java interpreter: byte order, multithreading capabilities, graphics capabilities, network mechanisms, and memory allocation, to name just a few.
The JDK was designed for cross-platform execution. However, to attain this goal, the Java runtime interpreter must be ported to the target platform. The amount of porting effort required is directly proportional to the difference between the target platform and the JVM.
As mentioned earlier, the interpretation between JVM-executable and platform-specific code is not always easy. In almost all cases the translation is not a direct one-to-one mapping. Some machines might require less or more instructions than others to do the same translation. Platform benchmarks may be able to test the compatibility of the native machine and the JVM, but currently there is not a standardized benchmark.
The JDK was released for the Windows 95/NT platforms in May 1995. Because the majority of pcs were still running the 16-bit Windows 3.1, the choice to release the JDK for the Win32 platform was a commitment to Java's future.
Unlike the 16-bit Window operating system, the Win32 platform offers Java what it needs to port the Java runtime interpreter. Win32 supports a multithreaded model as well as a standardized WinSock (that is, the Windows DLL version of Berkeley Sockets). Windows does not directly support either of these, which made implementation of the JVM on Windows 3.1 infeasible.
This chapter covers issues related to the distribution of the Java source code and the porting of Java to the Win32 platform. The following chapter describes the operation of the Java virtual machine.