GNU Compiler for Java
GNU Compiler for Java | |
![]() | |
![]() | |
Fejlesztő | The GNU Projekt |
Legfrissebb stabil kiadás | 6.5 (stabil verzió, 2018. október 26.)[1] |
Operációs rendszer | Unix-szerű |
Platform | Java virtuális gép |
Kategória | fordítóprogram |
Licenc | GNU GPL |
A GNU Compiler for Java weboldala |
Ez a szócikk/szakasz most épül, még dolgoznak az első verzión! |
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. Jelenleg az AWT-s támogatásához a munka folyamatban van, majd miután ezzel megvannak fog folytatódni a Swing-es támogatási projekt.[3]
2009-es állapot szerint nem jelentettek be újabb fejlesztéseket a gcj-től.[4] A termék jelenleg csak karbantartási üzemmódban van.
Teljesítmény
A GCJ-vel gépi kódra lefordított Java kódnak elvileg gyorsabban kéne elindulnia, mint vele ekvivalens a JVM által elindított bájtkódnak.[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
- GNU Interpreter for Java (GIJ)
- IcedTea
- Kaffe
- SableVM
- JamVM
- Apache Harmony
- Jikes
- C to Java Virtual Machine compilers
- Szabad java implementációk
Jegyzetek
- ↑ Jakub Jelinek: GCC 6.5 Released, 2018. október 26.
- ↑ gcj to use Eclipse compiler as a front end, 2007. január 8. (Hozzáférés: 2007. május 20.)
- ↑ The GCJ FAQ - GNU Project - Free Software Foundation (FSF)
- ↑ GCJ: News
- ↑ GCJ: The GNU Static Java Compiler
- ↑ GCJ vs Java JIT Performance Comparison
- ↑ The GCJ FAQ - GNU Project - Free Software Foundation (FSF)
- ↑ The example comes from: http://gcc.gnu.org/onlinedocs/gcj/Objects-and-Classes.html#Objects-and-Classes
Külső hivatkozások
- GCJ Honlapja
- GCJ kézikönyv
- About CNI section of GCJ Manual
- LWN: GCJ - past, present, and future - the article discuss some history of GCJ.