GNU Compiler for Java

From Wikipedia, the free encyclopedia
  (Redirected from Gcj)
Jump to: navigation, search
GNU Compiler for Java
Gcj2.png
Developer(s) The GNU Project
Stable release 6.1[1] / April 27, 2016; 2 months ago (2016-04-27)
Preview release 7.0 / May 22, 2016; 2 months ago (2016-05-22)
Operating system Unix-like
Type Compiler
License GNU GPL
Website gcc.gnu.org/java

The GNU Compiler for Java (GCJ) was a free compiler for the Java programming language and a part of the GNU Compiler Collection.[2][3]

GCJ can compile Java source code to Java Virtual Machine bytecode or to machine code for a number of CPU architectures. It can also compile class files and whole JARs that contain bytecode into machine code.[4][5]

History[edit]

The GCJ runtime-libraries original source is from GNU Classpath project, but there is a code difference between the libgcj libraries. GCJ 4.3 uses the Eclipse Compiler for Java as a front-end.[6]

In 2007, a lot of work was done to implement support for Java's two graphical APIs in GNU Classpath: AWT and Swing. Software support for AWT is still in development. "Once AWT support is working then Swing support can be considered. There is at least one free-software partial implementations of Swing that may be usable.".[7] The GNU CLASSPATH was never completed to even Java 1.2 status and now appears to have been abandoned completely.

As of 2015, there have been no new developments announced from GCJ[8] and the product is currently in deep maintenance mode.[9]

Performance[edit]

The compilation function in GCJ should have a faster start-up time than the equivalent bytecode launched in a JVM when compiling Java code into machine code.[10]

Compiled Native Interface (CNI)[edit]

The Compiled Native Interface (CNI), previously named "Cygnus Native Interface", is a software framework for the GCJ that allows Java code to call, and be called, by native applications (programs specific to a hardware and operating-system platform) and libraries written in C++.

CNI closely resembles the JNI (Java Native Interface) framework which comes as a standard with various Java virtual machines.

Comparison of language use[edit]

The authors of CNI claim for various advantages over JNI:[11]

CNI depends on Java classes appearing as C++ classes. For example,[12] given a Java class,

public class Int
{
   public int i;
   public Int(int i) { this.i = i; }
   public static Int zero = new Int(0);
}

one can use the class thus:

#include <gcj/cni.h>
#include <Int>

Int *mult(Int *p, int k)
{
  if (k == 0)
    return Int::zero;  // Static member access.
  return new Int(p->i * k);
}

See also[edit]

References[edit]

External links[edit]