GNU Compiler for Java

Last updated
GNU Compiler for Java
Developer(s) The GNU Project
Initial releaseSeptember 6, 1998;24 years ago (1998-09-06) [1]
Final release
6.5 [2]   OOjs UI icon edit-ltr-progressive.svg / 26 October 2018
Operating system Unix-like
Type Compiler
License GNU GPL
Website gcc.gnu.org

The GNU Compiler for Java (GCJ) is a free compiler for the Java programming language. It was part of the GNU Compiler Collection for over ten years but as of 2017 it is no longer maintained and will not be part of future releases. [3] [4]

Contents

GCJ compiles Java source code to Java virtual machine (JVM) bytecode or to machine code for a number of CPU architectures. It could also compile class files and whole JARs that contain bytecode into machine code. [5] [6]

History

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. [7]

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.". [8] The GNU CLASSPATH was never completed to even Java 1.2 status and now appears to have been abandoned completely.

As of 2015, there were no new developments announced from GCJ and the product was in maintenance mode, with open-source Java toolchain development mostly happening within OpenJDK. [9] GCJ was removed from the GCC trunk on September 30, 2016. [10] [11] Announcement of its removal was made with the release of the GCC 7.1, which does not contain it. [12] GCJ remains part of GCC 6.

Performance

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. [13]

Compiled Native Interface (CNI)

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

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

We use CNI because we think it is a better solution, especially for a Java implementation that is based on the idea that Java is just another programming language that can be implemented using standard compilation techniques. Given that, and the idea that languages implemented using Gcc should be compatible where it makes sense, it follows that the Java calling convention should be as similar as practical to that used for other languages, especially C++, since we can think of Java as a subset of C++. CNI is just a set of helper functions and conventions built on the idea that C++ and Java have the *same* calling convention and object layout; they are binary compatible. (This is a simplification, but close enough.)

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

publicclassInt{publicinti;publicInt(inti){this.i=i;}publicstaticIntzero=newInt(0);}

one can use the class thus:

#include<gcj/cni.h>#include<Int>Int*mult(Int*p,intk){if(k==0)returnInt::zero;// Static member access.returnnewInt(p->i*k);}

See also

Related Research Articles

<span class="mw-page-title-main">GNU Compiler Collection</span> Free and open-source compiler for various programming languages

The GNU Compiler Collection (GCC) is an optimizing compiler produced by the GNU Project supporting various programming languages, hardware architectures and operating systems. The Free Software Foundation (FSF) distributes GCC as free software under the GNU General Public License. GCC is a key component of the GNU toolchain and the standard compiler for most projects related to GNU and the Linux kernel. With roughly 15 million lines of code in 2019, GCC is one of the biggest free programs in existence. It has played an important role in the growth of free software, as both a tool and an example.

<span class="mw-page-title-main">Java (programming language)</span> Object-oriented programming language

Java is a high-level, class-based, object-oriented programming language that is designed to have as few implementation dependencies as possible. It is a general-purpose programming language intended to let programmers write once, run anywhere (WORA), meaning that compiled Java code can run on all platforms that support Java without the need to recompile. Java applications are typically compiled to bytecode that can run on any Java virtual machine (JVM) regardless of the underlying computer architecture. The syntax of Java is similar to C and C++, but has fewer low-level facilities than either of them. The Java runtime provides dynamic capabilities that are typically not available in traditional compiled languages. As of 2019, Java was one of the most popular programming languages in use according to GitHub, particularly for client–server web applications, with a reported 9 million developers.

<span class="mw-page-title-main">Java virtual machine</span> Virtual machine

A Java virtual machine (JVM) is a virtual machine that enables a computer to run Java programs as well as programs written in other languages that are also compiled to Java bytecode. The JVM is detailed by a specification that formally describes what is required in a JVM implementation. Having a specification ensures interoperability of Java programs across different implementations so that program authors using the Java Development Kit (JDK) need not worry about idiosyncrasies of the underlying hardware platform.

<span class="mw-page-title-main">GNAT</span>

GNAT is a free-software compiler for the Ada programming language which forms part of the GNU Compiler Collection (GCC). It supports all versions of the language, i.e. Ada 2012, Ada 2005, Ada 95 and Ada 83. Originally its name was an acronym that stood for GNU NYU Ada Translator, but that name no longer applies. The front-end and run-time are written in Ada.

In software design, the Java Native Interface (JNI) is a foreign function interface programming framework that enables Java code running in a Java virtual machine (JVM) to call and be called by native applications and libraries written in other languages such as C, C++ and assembly.

SableVM was a clean room implementation of Java bytecode interpreter implementing the Java virtual machine (VM) specification, second edition. SableVM was designed to be a robust, extremely portable, efficient, and fully specifications-compliant Java Virtual Machine that would be easy to maintain and to extend. It is now no longer being maintained.

<span class="mw-page-title-main">GNU Classpath</span> Implementation of standard class library of Java

GNU Classpath is a free software implementation of the standard class library for the Java programming language. Most classes from J2SE 1.4 and 5.0 are implemented. Classpath can thus be used to run Java-based applications. GNU Classpath is a part of the GNU Project. It was originally developed in parallel with libgcj due to license incompatibilities, but later the two projects merged.

Free Java implementations are software projects that implement Oracle's Java technologies and are distributed under free software licences, making them free software. Sun released most of its Java source code as free software in May 2007, so it can now almost be considered a free Java implementation. Java implementations include compilers, runtimes, class libraries, etc. Advocates of free and open source software refer to free or open source Java virtual machine software as free runtimes or free Java runtimes.

A Java compiler is a compiler for the programming language Java. The most common form of output from a Java compiler is Java class files containing platform-neutral Java bytecode, but there are also compilers that output optimized native machine code for a particular hardware/operating system combination, most notably the now discontinued GNU Compiler for Java.

javac is the primary Java compiler included in the Java Development Kit (JDK) from Oracle Corporation. Martin Odersky implemented the GJ compiler, and his implementation became the basis for javac.

Apache Harmony is a retired open source, free Java implementation, developed by the Apache Software Foundation. It was announced in early May 2005 and on October 25, 2006, the Board of Directors voted to make Apache Harmony a top-level project. The Harmony project achieved 99% completeness for J2SE 5.0, and 97% for Java SE 6. The Android operating system has historically been a major user of Harmony, although since Android Nougat it increasingly relies on OpenJDK libraries.

JamVM is an open-source Java Virtual Machine (JVM) developed to be extremely small compared with other virtual machines (VMs) while conforming to the Java virtual machine specification version 2.

Jikes Research Virtual Machine is a mature virtual machine that runs programs written for the Java platform. Unlike most other Java virtual machines (JVMs), it is written in the programming language Java, in a style of implementation termed meta-circular. It is free and open source software released under an Eclipse Public License.

<span class="mw-page-title-main">Java (software platform)</span> Set of computer software and specifications

Java is a set of computer software and specifications developed by James Gosling at Sun Microsystems, which was later acquired by the Oracle Corporation, that provides a system for developing application software and deploying it in a cross-platform computing environment. Java is used in a wide variety of computing platforms from embedded devices and mobile phones to enterprise servers and supercomputers. Java applets, which are less common than standalone Java applications, were commonly run in secure, sandboxed environments to provide many features of native applications through being embedded in HTML pages.

The Java Class Library (JCL) is a set of dynamically loadable libraries that Java Virtual Machine (JVM) languages can call at run time. Because the Java Platform is not dependent on a specific operating system, applications cannot rely on any of the platform-native libraries. Instead, the Java Platform provides a comprehensive set of standard class libraries, containing the functions common to modern operating systems.

The Java Development Kit (JDK) is a distribution of Java Technology by Oracle Corporation. It implements the Java Language Specification (JLS) and the Java Virtual Machine Specification (JVMS) and provides the Standard Edition (SE) of the Java Application Programming Interface (API). It is derivative of the community driven OpenJDK which Oracle steward. It provides software for working with Java applications. Examples of included software are the virtual machine, a compiler, performance monitoring tools, a debugger, and other utilities that Oracle considers useful for a Java programmer.

In computing, Java bytecode is the bytecode-structured instruction set of the Java virtual machine (JVM), a virtual machine that enables a computer to run programs written in the Java programming language and several other programming languages, see List of JVM languages.

GraalVM is a Java VM and JDK based on HotSpot/OpenJDK, implemented in Java. It supports additional programming languages and execution modes, like ahead-of-time compilation of Java applications for fast startup and low memory footprint. The first production-ready version, GraalVM 19.0, was released in May 2019. The most recent version is GraalVM 22.1.0, made available in April 2022.

References

  1. Anthony Green, Cygnus Solutions. "GCJ announcement".
  2. "GCC Releases - GNU Project".
  3. "GCJ: The GNU Compiler for Java - GNU Project - Free Software Foundation (FSF)". Archived from the original on 2007-05-09. Retrieved 2010-04-22.
  4. Campbell, Bill (2013). Introduction to Compiler Construction in a Java World. CRC Press Taylor & Francis Group. ISBN   978-1-4398-6088-5 . Retrieved 2014-02-06.
  5. "Compiling Java with GCJ | Linux Journal".
  6. "GNU Compiler for Java".
  7. "gcj to use Eclipse compiler as a front end". 2007-01-08. Archived from the original on 2007-05-09. Retrieved 2007-05-20.
  8. The GCJ FAQ
  9. GCC Looks To Turn Off Java, Replace With Go Or ADA
  10. Andrew Haley (September 30, 2016). "[gcc] Revision 240661".
  11. Tromey, Tom (October 2, 2016). "The Deletion of gcj". The Cliffs of Inanity. Retrieved October 3, 2016.
  12. "GCC 7 Release Series: Changes, New Features, and Fixes" . Retrieved May 9, 2017.
  13. "GCJ: The GNU Static Java Compiler" (PDF). Archived from the original (PDF) on 2011-06-07. Retrieved 2009-08-02.
  14. The GCJ FAQ – GNU Project – Free Software Foundation (FSF)
  15. The example comes from: https://gcc.gnu.org/onlinedocs/gcj/Objects-and-Classes.html#Objects-and-Classes Archived 2016-10-20 at the Wayback Machine