GNU Compiler for Java: Difference between revisions

Content deleted Content added
Trevie (talk | contribs)
 
(98 intermediate revisions by 67 users not shown)
Line 1:
{{Short description|Java compiler}}
{{multiple issues|
{{essay-like|date=August 2012}}
{{primary sources|date=August 2012}}
}}
 
{{Infobox software
| name = GNU Compiler for Java
| logo = [[Image:Gcj2.png|70px]]
| logo size = 70px
| screenshot =
| caption =
| developer = [[GNU|The GNU Project]]
| released = {{Start date and age|1998|09|06}}<ref>{{cite web|url=https://gcc.gnu.org/news/gcj-announce.txt|author=Anthony Green, Cygnus Solutions|title=GCJ announcement}}</ref>
| discontinued = yes
| latest release version = {{wikidata|property|preferred|references|edit|Q1007042|P348|P548=Q2804309}}
| latest release date = {{wikidata|qualifier|preferred|single|Q1007042|P348|P548=Q2804309|P577}}
| latest preview version = {{wikidata|property|preferred|references|edit|Q1007042|P348|P548=Q51930650}}
| latest preview date = {{wikidata|qualifier|preferred|single|Q1007042|P348|P548=Q51930650|P577}}
| operating system = [[Unix-like]]
| programming language =
| genre = [[Compiler]]
| license = [[GNU General Public License|GNU GPL]]
| website = http{{URL|https://gcc.gnu.org/java}}
}}
The '''GNU Compiler for Java''' ('''GCJ''') is a discontinued [[freewareFree software|free]] [[compiler]] [[software]] for the [[Java (programming language)|Java programming language]]. and aIt was part of the [[GNU Compiler Collection]].<ref>{{cite web |url=https://gcc.gnu.org/java/ |title=GCJ: The GNU Compiler for Java - GNU Project - Free Software Foundation (FSF) |access-date=2010-04-22 |url-status=dead |archive-url=https://web.archive.org/web/20070509055923/http://gcc.gnu.org/java/ |archive-date=2007-05-09 }}</ref><ref>{{cite book |last=Campbell |first=Bill |date=2013 |title=Introduction to Compiler Construction in a Java World |url=https://books.google.com/books?id=-b8WjLY2eKEC&pg=PA277 |publisher=CRC Press Taylor & Francis Group |isbn=978-1-4398-6088-5 |access-date=2014-02-06}}</ref>
 
GCJ can compilecompiles Java [[source code]] to [[Java Virtualvirtual Machinemachine]] (JVM) [[bytecode]] or to a [[machine code]] for a number of [[CPU architecture]]s. It cancould also compile [[Class (file format)|class files]] and whole [[JAR (file format)|JARs]] that contain bytecode into machine code.<ref>{{Cite web|url=https://www.linuxjournal.com/article/4860|title = Compiling Java with GCJ &#124; Linux Journal}}</ref><ref>{{Cite web|url=http://freecode.com/projects/gcj|title = GNU Compiler for Java}}</ref>
 
==History==
The GCJ runtime-libraries original source is from [[GNU Classpath]] project, but there is a code difference between the <code> libgcj </code> libraries. GCJ 4.3 {{clarify-span|integrates with ecj|date=August 2012}},uses the [[Eclipse (software)|Eclipse]] Compiler for Java as a front-end.<ref>
{{cite web | title = gcj to use Eclipse compiler as a front end | url = httphttps://gcc.gnu.org/java/ | date = 2007-01-08 | accessdateaccess-date = 2007-05-20 | url-status = dead | archive-url = https://web.archive.org/web/20070509055923/http://gcc.gnu.org/java/ | archive-date = 2007-05-09 }}
{{
cite web | title = gcj to use Eclipse compiler as a front end | url = http://gcc.gnu.org/java/ | date= 2007-01-08 | accessdate = 2007-05-20
}}
</ref>
 
In 2007, a lot of work was done to implement support for Java's two graphical [[application programming interface|API]]s in [[GNU Classpath]]: [[Abstract Window Toolkit|AWT]] and [[Swing (Java)|Swing]]. Software support for [[Abstract Window Toolkit|AWT]] is still in development.<!--Note, "Optional SWT support" also available for micro-libgcj (that is a subset - not maintained, not sure if this SWT support also applies to GCJ)--> "Once AWT support is working then Swing support can be considered. There is at least one free-software partial implementations of [[Swing Application Framework|Swing]] that may be usable.".<ref>[https://gcc.gnu.org/java/faq.html#2_4 The GCJ FAQ]</ref> The GNU CLASSPATH was never completed to even Java 1.2 status and now appears to have been abandoned completely.
 
<!--Not sure if this non-development for years contradicts above "AWT is still in development" as that is not a compiler (but would appear in "News"?)-->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]].<ref>[https://www.phoronix.com/scan.php?page=news_item&px=MTUwOTA GCC Looks To Turn Off Java, Replace With Go Or ADA]</ref> GCJ was removed from the GCC [[Trunk (software)|trunk]] on September 30, 2016.<ref>{{cite web|url=https://gcc.gnu.org/viewcvs/gcc?view=revision&revision=240661|title=[gcc] Revision 240661|date=September 30, 2016|author=Andrew Haley}}</ref><ref>{{Cite web|url=https://tromey.com/blog/?p=911|title=The Deletion of gcj|last=Tromey|first=Tom|date=October 2, 2016|website=The Cliffs of Inanity|access-date=October 3, 2016}}</ref> Announcement of its removal was made with the release of the GCC 7.1, which does not contain it.<ref>{{cite web|url=https://gcc.gnu.org/gcc-7/changes.html|title=GCC 7 Release Series: Changes, New Features, and Fixes|access-date=May 9, 2017}}</ref> GCJ remains part of GCC 6.
As of 2013 there have been no new developments announced from GCJ<ref>[http://gcc.gnu.org/java GCJ: News]</ref> and the product is currently in [[maintenance mode]].
 
== Performance ==
Software support for [[Abstract Window Toolkit|AWT]] is still in development. The next planned support feature after AWT support is a software support for [[Swing Application Framework|Swing]].<ref>[http://gcc.gnu.org/java/faq.html#2_4 The GCJ FAQ - GNU Project - Free Software Foundation (FSF)]</ref>
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.<ref>[{{Cite web |url=http://www.hpl.hp.com/personal/Hans_Boehm/misc_slides/gcj2.pdf |title=GCJ: The GNU Static Java Compiler] |access-date=2009-08-02 |archive-url=https://web.archive.org/web/20110607102558/http://www.hpl.hp.com/personal/Hans_Boehm/misc_slides/gcj2.pdf |archive-date=2011-06-07 |url-status=dead }}</ref>
 
== CNI (Compiled Native Interface (CNI) ==
== Performance ==
The CNI ('''Compiled Native Interface''' ('''CNI'''), previously named '"Cygnus Native Interface')", is a [[software framework]] for the [[GCJ]] that allows Java code to [[Call site|call]], and be [[Call site|called]], by, native applications (programs specific to a hardware and operating-system platform) and libraries written in [[C++]].
The compilation function in GCJ should have faster start-up time than the equivalent bytecode launched in a JVM when compiling Java code into machine code.<ref>[http://www.hpl.hp.com/personal/Hans_Boehm/misc_slides/gcj2.pdf GCJ: The GNU Static Java Compiler]</ref>
GCJ does not execute{{Clarify|date=August 2013}} faster than bytecode executed by a modern [[Just-in-time compilation|JIT]]-enabled JVM.<ref>[http://zigabyte.com/blog/GCJ_vs_Java_JIT_Performance_Comparison.doc GCJ vs Java JIT Performance Comparison]</ref>
 
== CNI (Compiled Native Interface) ==
The CNI ('''Compiled Native Interface''', previously named 'Cygnus Native Interface') is a [[software framework]] for the [[GCJ]] that allows Java code to [[Call site|call]], and be [[Call site|called]], by native applications (programs specific to a hardware and operating-system platform) and libraries written in [[C++]].
 
CNI closely resembles the [[Java Native Interface|JNI]] (Java Native Interface) framework which comes as a standard with various [[Java virtual machine]]s.
 
=== Comparison of language use ===
theThe authors of CNI claim for various advantages over JNI:<ref>[httphttps://gcc.gnu.org/java/faq.html#2_3 The GCJ FAQ - GNU Project - Free Software Foundation (FSF)<!-- Bot generated title -->]</ref>
 
{{cquote|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,<ref>The example comes from: https://gcc.gnu.org/onlinedocs/gcj/Objects-and-Classes.html#Objects-and-Classes {{Webarchive|url=https://web.archive.org/web/20161020222612/https://gcc.gnu.org/onlinedocs/gcj/Objects-and-Classes.html#Objects-and-Classes |date=2016-10-20 }}</ref>
The example comes from: http://gcc.gnu.org/onlinedocs/gcj/Objects-and-Classes.html#Objects-and-Classes</ref>
given a Java class,
 
<sourcesyntaxhighlight lang="java">
public class IntMyInteger {
{
public private int i;
 
public Int(int i) { this.i = i; }
public static Int(int zeroi) ={ new Int(0);
public Int(int i) { this.i = i; }
}
 
public int get() {
return i;
}
 
public void set(int j) {
i = j;
}
 
public static final Int ZERO = new Int(0);
}
</syntaxhighlight>
</source>
 
one can use the class thus:
 
<sourcesyntaxhighlight lang="cpp">
#include <gcj/cni.h>
#include <IntMyInteger>
 
Int MyInteger* mult(IntMyInteger& *p, int k) {
if (k == 0) {
{
return IntMyInteger::zeroZERO; // Static member access.
if (k == 0)
}
return Int::zero; // Static member access.
return new Int(p->i * k);
}
</source>
 
return new IntMyInteger(p->i.get() * k);
== See also ==
}}
</syntaxhighlight>
 
== See also ==
{{Portal|Free and open-source software|JavaComputer programming}}
 
* [[GNU Interpreter for Java]] (GIJ)
* [[Excelsior JET]] (Excelsior Java native code compiler)
* [[IcedTea]]
Line 84 ⟶ 94:
* [[Apache Harmony]]
* [[Jikes]]
* [[GraalVM]] - GraalVM's Native Image functionality is an ahead-of-time compilation technology that produces executable binaries of class files.
* [[C to Java Virtual Machine compilers]]
* [[Java virtual machine]]
* [[Free Java implementations]]
* [[Kotlin (programming language)|Kotlin]] - Kotlin/Native is a technology for compiling Kotlin to native binaries that run without any JVM. It comprises a [[LLVM]]-based backend for the Kotlin compiler and a native implementation of the Kotlin runtime library.
* [http://javacompiler.sf.net/ JavaNativeCompiler] (seemingly abandoned)
 
==References==
Line 92 ⟶ 103:
 
==External links==
* {{cite web |url= http://gcc.gnu.org/java/ |title= Official website |publisher= GNU |work= GCC |date= Mar 30, 2007 |url-status= dead |archive-date= May 9, 2007 |archive-url= https://web.archive.org/web/20070509055923/http://gcc.gnu.org/java/ }}
* [http://gcc.gnu.org/java/ GCJ Homepage]
* [{{cite web |url= http://gcc.gnu.org/onlinedocs/gcj/ |title= GCJ Manual] |url-status= dead |archive-date= August 22, 2016 |archive-url= https://web.archive.org/web/20160822153028/http://gcc.gnu.org/onlinedocs/gcj/ }}
* [{{cite web |url= http://gcc.gnu.org/onlinedocs/gcj/About-CNI.html |title= About CNI section of|work= GCJ Manual] |url-status= dead |archive-date= July 28, 2016 |archive-url= https://web.archive.org/web/20160728215116/http://gcc.gnu.org/onlinedocs/gcj/About-CNI.html }}
* [http{{cite web |url= https://lwn.net/Articles/130796/ |publisher= LWN: |title= GCJ - past, present, and future] |first= Mark |last= Wielaard |date= Apr 6, 2005 |url-status= thelive article|archive-date= discussAugust some2, history2019 of|archive-url= GCJhttps://web.archive.org/web/20190802072307/https://lwn.net/Articles/130796/ }}
 
{{Java Virtual Machine}}
{{Java (Sunsoftware platform)}}
 
{{DEFAULTSORT:Gnu Compiler For Java}}
[[Category:Free and open source compilers]]
[[Category:GNU Project software|Java]]
[[Category:Java development toolscompilers]]
[[Category:FreeDiscontinued compilersJava andvirtual interpretersmachines]]
[[Category:Java platform]]