GNU Compiler for Java

From Wikipedia, the free encyclopedia

(Redirected from GCJ)
Jump to: navigation, search
GNU Compiler for Java
Developer: The GNU Project
Latest release: 4.2.1 / July 21, 2007
OS: Unix-like
Genre: Compiler
License: GPL
Website: http://gcc.gnu.org/java

The GNU Compiler for Java (GCJ) is a free software compiler for the Java programming language that is part of the GNU Compiler Collection. It can compile Java source code to either Java Virtual Machine bytecode, or directly to machine code for any of a number of CPU architectures. It can also compile class files containing bytecode or entire JARs containing such files into machine code. Almost all of the runtime libraries used by GCJ come from the GNU Classpath project. Since gcj 4.3 (currently alpha), it is integrated with ecj, the Eclipse Compiler for Java.[1]

Currently a lot of work has gone in to getting GNU Classpath to support Java's two graphical APIs: AWT and Swing. Full support for both AWT and Swing is close and it is likely that soon it will no longer be necessary to use the runtime provided by Sun Microsystems in order to run AWT/Swing applications.[citation needed]

Contents

The Cygnus Native Interface (CNI) is a software framework for the GCJ which 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++.

It is similar to the Java Native Interface (JNI) framework which comes as standard with various Java virtual machines. However the CNI authors claim various advantages over JNI: [1]

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.)

The basic idea behind CNI is that Java classes appear as C++ classes. For example[2], 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, like so:

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

Advanced Search
Included Web Search Engines


Safe Search

close

Top Matching Results

Occasionally Search.com will highlight specialized results that are based on the context of your query. Examples of specialized results include specific links to news, images, or video.

Top Matching Results may highlight information from other Search.com pages, content from the CNET Network of sites, or third party content. The listings are based purely on relevance. Search.com does not receive payment for listings in this section but our partners that provide this data may get paid for listing these products.

Sponsored Links

This section contains paid listings which have been purchased by companies that want to have their sites appear for specific search terms and related content. These listings are administered, sorted and maintained by a third party and are not endorsed by Search.com.

Search Results

Search.com sends your search query to several search engines at one time and integrates the results into one list which has been sorted by relevance using Search.com's proprietary algorithm. You can customize the list of search engines included in your metasearch from the preferences.

The search engines that are used in your metasearch may allow companies to pay to have their Web sites included within the results. To view the Paid Inclusion policy for a specific search engine, please visit their Web site. Search.com does not accept payment or share revenue with any search engine partner for listings in this section.