You use a static compiler such as Oracle’s javac.exe to create platform-independent, binary, JVM (Java Virtual Machine) byte code. Then you can either:
Compiler classifications | ||
---|---|---|
Code Letter | Meaning | Advantages and Disadvantages |
I | Interpreter | Interpreters are easy to write. Thus they appear on any new platform first. They start execution instantly. The code is compact. However, they are usually the slowest to execute. The lines between software interpreter, firmware interpreter and microchip that runs byte codes directly is blurry. The more hardware assist you have, the faster the execution and the smaller the package you can squeeze everything into. With sufficient hardware assist, this is the fastest approach. |
N | AOT (Ahead Of Time) Static Native code, complied to machine code at the developer site from byte codes. Sometimes called AOT AOT compilers. | Native code compilers do all their work long before the execution starts. They take a long time to study the code. They figure out what can be precalculated, what tests were not really necessary, which objects can be safely stack allocated for speed. They inline aggressively. They study the program as whole globally optimising, not just method by method. They unravel in ways no assembler programmer would have the patience for. The result is a standard platform-dependent executable. These now rival C++ in speed and are getting better daily. The catch is you need to buy a different compiler for every native platform. And you have to distribute a different executable for every platform and sometimes a fat runtime library as well. Happily, you can use these tools even when you don’t have the source. They work with the class or jar files as input. This means you as customer can use them to speed up programs you buy. The author of the program need not ever know you used them. Their main weakness is dealing with any sort of on-the-fly newly created or imported classes that were not present at compile time. Either such classes have to be disallowed or not optimised. The other main disadvantage is high cost. Native code, especially highly optimised native code, is considerably more difficult to reverse engineer than Java byte codes, even obfuscated ones. So you might consider using a native compiler for protecting the secrets of your source code. |
J | JIT compiles every time needed at the client site. | Good for executing platform-independent byte codes freshly downloaded off the web, e.g. An Applet. Does a rough and ready quick compilation and gets on with execution quickly. The code is not particularly fast to execute though. |
H | Hotspot (starts off interpreting and gradually compiles the hotspots). | This is good primarily for servlets. The disadvantage is the several minutes the servlet womb takes to warm up. The advantage is the system responds to real life bottlenecks, not to theoretical ones. The optimiser has more information about how the code is actually used than on that did all its work before execution started. It can deal with code changing on the fly or being generated on the fly as in JSP (Java Server Pages). Static native code optimisers cannot. For example it can presume all non-overridden methods are final and do inlining, then change its mind later and undo that if a dynamic class load overrides one of those methods. It leaves rarely used code in compact byte code form. |
W | Wrapper | This technique looks superficially like native code, but what actually is happening is the class files are bundled with a little kickoff program. The actually running may be by interpretation or by a JIT. Microsoft’s Jexegen was the originator of this technique. |
Real World Compilers | |||
---|---|---|---|
Vendor | Compiler Name | How Run | Notes |
IBM | AS400 | N | 128-bit address space. |
IBM | Eclipse | I | Incremental compiler keeps compiling as you edit. Windows, others? |
JSmooth | JSmooth | W | Wraps Jar in a standard windows executable. |
IBM | Java 2 | ? | 64-bit, Itanium under Linux |
IBM | Java 2 | ? | 64-bit, Itanium under Linux |
NaturalBridge | BulletTrain | N | defunct |
webGAIN | Café | JW | IDE (Integrated Development Environment) that comes in Pro and database editions. Includes source code level debugger that lets you evaluate arbitrary expressions that can include method calls. Formerly by Symantec, now called webGAIN Studio. Defunct. |
Metroworks | CodeWarrior | N | Runs on Linux, Macintosh, Solaris, Windows 95/98/NT. |
Wind River Systems | Diab FastJ | N | For embedded Systems. |
Microsoft | J++ | IW | Works with Microsoft’s variant of the Java language that does not have RMI (Remote Method Invocation), JNI (Java Native Interface) etc and has some extra keywords. May be useful for writing Windows-only applications. |
Oracle/Sun/JavaSoft | javac | I or J or H | Comes with various JDKs (Java Development Kits). |
GNU | gcj | I or N | Compiler that accepts either java or class files and emits either class or native object files. |
Inprise (née Borland) | Jbuilder | J | IDE. |
Excelsior | JET (Just Enough Time) | N | Just an optimser and native code generator. Needs somebody else’s compiler to produce the byte codes. Very simple to use! Just give it a jar file or some class files and it hands back an equivalent tiny self-contained EXE that runs so fast it will make your head spin. Free evaluation download. The install is very unfriendly, making your machine completely unusable for an hour or so. On my old clunker it took about 18 hours! Do it just before you go to sleep. To deploy you must install both the precise matching JRE (Java Runtime Environment) and some DLLs (Dynamic Link Libraries) on the client machine. For non-GUIs, you don’t even need that. |
IBM (International Business Machines) Alphaworks | Jikes | I. Use Oracle’s or other’s runtime | very fast compilation, good error messages, works very well with the SmartJ front end. SmartJ is a convenient front end to the compiler and runtime that makes them much smarter and forgiving. |
Instantiations | Jove | N | highly optimised. Very expensive. Unfortunately, no longer available. |
KOPI | KJC | I | written in pure Java. GNU (Gnu’ Not Unix!) opensource. |
Microsoft | MSIL | ? | Java Language to IL compiler: The Java language converter is the Java equivalent of a C++ language compiler for .NET. It will take Java source files and create the .NET assemblies containing the IL and metadata that can run on the .NET runtime. |
Dobysoft | NativeJ | W |
standard edition, professional edition, Not a compiler. Wraps class files to look like a standard windows executable, even a service. |
Pizza | Pizza | ? | opensource |
Tower Technology | TowerJ | N | heavy duty optimisation. Generates native code for Solaris, HP/UX, Windows, Linux, Tru64, DG/UX, AIX (Advanced Interactive eXecutive) and SGI (Silicon Graphics Inc), including Itanium. Defunct. |
IBM | VAJ (Visual Age for Java) | I and N | SCID that offers very good code browsing and source code debugging of multithread apps. Terrible help files. Runs under AIX, OS/2, OS/390, Windows 98 and Windows NT. |
Going the other way from C to Java is also difficult. There is a program C2J that can do an approximate translation of simple C programs to Java. Many of the low-level things you can do in C, such as unions, have no equivalent in Java.
This page is posted |
http://mindprod.com/jgloss/compiler.html | |
Optional Replicator mirror
|
J:\mindprod\jgloss\compiler.html | |
Please read the feedback from other visitors,
or send your own feedback about the site. Contact Roedy. Please feel free to link to this page without explicit permission. | ||
Canadian
Mind
Products
IP:[65.110.21.43] Your face IP:[18.97.14.89] |
| |
Feedback |
You are visitor number | |