Ugrás a tartalomhoz

GNU Compiler for Java

A Wikipédiából, a szabad enciklopédiából
A lap korábbi változatát látod, amilyen Zafir (vitalap | szerkesztései) 2012. március 6., 10:43-kor történt szerkesztése után volt. Ez a változat jelentősen eltérhet az aktuális változattól. (Története)
GNU Compiler for Java

FejlesztőThe GNU Projekt
Legfrissebb stabil kiadás6.5 (stabil verzió, 2018. október 26.)[1]
Operációs rendszerUnix-szerű
PlatformJava virtuális gép
Kategóriafordítóprogram
LicencGNU GPL
A GNU Compiler for Java weboldala

A GNU Compiler for Java (GCJ vagy gcj) egy szabad szoftver fordítóprogram a Java programozási nyelvhez és része a GNU fordító gyűjteménynek.

A GCJ képes a Java kódot lefordítani JVM bájtkódra, vagy direkt módon a számos CPU architektúra bármelyikének gépi kódjára. Képes továbbá lefordítani bájt kódot tartalmazó class fájlokat vagy teljes JAR fájlokat gépi kódra.

Története

Csaknem minden futtató környezeti könyvtár ()runtime library), amit a gcj használ a GNU Classpath projektből jön, (de különböznek a libgcj könyvtáraitól). A gcj a 4.3 verziótól, össze lett integrálva az ecj-vel, ami az Eclipse java fordítója.[2]

A 2007-es állapot szerint rengeteg munkát öltek bele abba, hogy a GNU Classpath támogassa a Java két grafikus API-jét: AWT-t és Swing-et. Work on supporting AWT is ongoing, after which support for Swing will follow.[3]

Sablon:As of there have been no new developments announced from gcj.[4] The product is currently in maintenance mode.

Teljesítmény

Java code compiled into machine code by GCJ should have faster start-up time than the equivalent bytecode launched in a JVM.[5]

However, after start-up, Java code compiled by GCJ does not necessarily execute any faster than bytecode executed by a modern JIT-enabled JVM. This is true even when GCJ is invoked with advanced optimization options such as -fno-bounds-check -O3 -mfpmath=sse -msse2 -ffast-math -march=native; in this case, the compiled program may or may not surpass JVM performance, depending on the operations performed by the code in question.[6]

CNI - lefordított natív interfész

A CNI (Compiled Native Interface, korábban Cygnus Native Interface), egy szoftver keretrendszer a gcj-hez, mely lehetővé teszi a Java kódnak, hogy hívjon natív alkalmazásokat (azaz olyan programokat, melyek hardver és operációs rendszer platform specifikusak), C++-ban írt könyvtárakat ill. ezekből is hívható legyen.

CNI closely resembles the Java Native Interface (JNI) framework which comes as standard with various Java virtual machines. However the CNI authors claim various advantages over JNI:[7]

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. Például,[8] 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);
}

Lásd még

Jegyzetek

Külső hivatkozások