From: Gerald Pfeifer <gerald@pfeifer.com>
To: gcc-patches@gcc.gnu.org
Cc: java-patches@gcc.gnu.org
Subject: [wwwdocs] Remove reference to GCJ FAQ
Date: Thu, 29 Dec 2016 21:09:00 -0000 [thread overview]
Message-ID: <alpine.LSU.2.20.1612291705160.2994@anthias.pfeifer.com> (raw)
...from our main FAQ, plus the GCJ FAQ to begin with.
Applied.
Gerald
Index: java/faq.html
===================================================================
RCS file: java/faq.html
diff -N java/faq.html
--- java/faq.html 29 Jun 2014 19:39:16 -0000 1.74
+++ /dev/null 1 Jan 1970 00:00:00 -0000
@@ -1,443 +0,0 @@
-<html>
-<head>
-<title>The GCJ FAQ</title>
-</head>
-
-<body>
-
- <h1>The GCJ FAQ</h1>
-
- <ol>
- <li><a href="#1_0">General Questions</a>
- <ol>
- <li><a href="#1_1">What license is used for libgcj?</a></li>
- <li><a href="#1_6">How can I debug my Java program?</a></li>
- <li><a href="#1_7">Can I interface byte-compiled and native java code?</a></li>
- </ol>
- </li>
- <li><a href="#2_0">Java Feature Support</a>
- <ol>
- <li><a href="#2_1">What Java API's are supported? How complete is
- the support? </a></li>
- <li><a href="#2_2">Does GCJ support using straight C native methods
- ala JNI? </a></li>
- <li><a href="#2_3">Why does GCJ use CNI? </a></li>
- <li><a href="#2_4">What is the state of AWT support?</a></li>
- <li><a href="#2_5">How about support for Swing ?</a></li>
- <li><a href="#2_6">What support is there for RMI ?</a></li>
- <li><a href="#2_7">Can I use any code from other projects
- to supplement libgcj's current features?</a></li>
- <li><a href="#2_8">What features of the Java language are/arn't supported</a></li>
- </ol>
- </li>
- <li><a href="#4_0">Gcj Compile/Link Questions</a>
- <ol>
- <li><a href="#4_1">Why do I get <tt>undefined reference to `main'</tt>
- errors?</a></li>
- <li><a href="#4_2">Can GCJ only handle source code? </a></li>
- <li><a href="#4_3">"gcj -C" Doesn't seem to work like javac/jikes.
- Whats going on? </a></li>
- <li><a href="#4_4">Where does GCJ look for files? </a></li>
- <li><a href="#4_5">How does gcj resolve wether to compile .class or
- .java files? </a></li>
- </ol>
- </li>
- <li><a href="#5_0">Runtime Questions</a>
- <ol>
- <li><a href="#5_1">My program is dumping core! What's going on?</a></li>
- <li><a href="#5_2">When I run the debugger I get a SEGV in the GC!
- What's going on?</a></li>
- <li><a href="#5_3">I have just compiled and benchmarked my Java application
- and it seems to be running slower than than XXX JIT JVM. Is there
- anything I can do to make it go faster?</a></li>
- <li><a href="#5_4">Can I profile Garbage Collection? </a></li>
- <li><a href="#5_5">How do I increase the runtime's initial and maximum
- heap sizes?</a></li>
- <li><a href="#5_6">How can I profile my application?</a></li>
- </ol>
- </li>
- <li><a href="#6_0">Programming Issues</a>
- <ol>
- <li><a href="#6_1">Are there any examples of how to use CNI?</a></li>
- <li><a href="#6_2">Is it possible to invoke GCJ compiled Java code from a C++ application?</a></li>
- </ol>
- </li>
- </ol>
-
- <h2><a name="1_0">General Questions</a></h2>
-
- <h3><a name="1_1">1.1 What license is used for libgcj?</a></h3>
- <dl>
- <dd>
- libgcj is distributed under the GPL, with the 'libgcc exception'.
- This means that linking with libgcj does not by itself cause
- your program to fall under the GPL. See LIBGCJ_LICENSE in
- the source tree for more details.
- </dd>
- </dl>
-
- <hr />
- <h3><a name="1_6">1.6 How can I debug my Java program?</a></h3>
- <dl>
- <dd>
- <a href="ftp://ftp.gnu.org/pub/gnu/gdb/">gdb 5.0</a>
- includes support for debugging gcj-compiled Java programs. For more
- information please read <a href="gdb.html">Java Debugging with gdb</a>.
- </dd>
- </dl>
-
- <hr />
- <h3><a name="1_7">1.7 Can I interface byte-compiled and native java code</a></h3>
- <dl>
- <dd>
- <p>libgcj has a bytecode interpreter that allows you to mix .class files with
- compiled code. It works pretty transparently: if a compiled version of a class is
- not found in the application binary or linked shared libraries, the class loader
- will search for a bytecode version in your classpath, much like a VM would. Be
- sure to build libgcj with the --enable-interpreter option to enable this
- functionality.</p>
-
- <p>The program "gij" provides a front end to the interpreter that behaves
- much like a traditional virtual machine. You can even use "gij" to run a shared library
- which is compiled from java code and contains a main method:</p>
- <pre>
-$ gcj -shared -o lib-HelloWorld.so HelloWorld.java
-$ gij HelloWorld
- </pre>
- This works because gij uses Class.forName, which knows how to load shared objects.
- </dd>
- </dl>
-
- <h2><a name="2_0">Java Feature Support</a></h2>
-
- <h3><a name="2_1">2.1 What Java API's are supported?</a> How complete is
- the support?</h3>
- <dl>
- <dd>
- <a href="mailto:mdw@cs.berkeley.edu">Matt Welsh</a> writes:
- <blockquote>
- <p>Just look in the 'libjava' directory of libgcj and see what classes
- are there. Most GUI stuff isn't there yet, that's true, but many of
- the other classes are easy to add if they don't yet exist. </p>
-
- <p>I think it's important to stress that there is a big difference
- between Java and the many libraries which Java supports. Unfortunately,
- Sun's promise of "write once, run everywhere" assumes much
- more than a JVM: you also need the full set of JDK libraries. Considering
- that new Java APIs come out every week, it's going to be impossible
- to track everything. </p>
-
- <p>To make things worse, you can't simply run Sun's JDK classes on
- any old JVM -- they assume that a bunch of native methods are also
- defined. Since this native method requirement isn't defined by the
- JDK specs, you're effectively constrained to using Sun's JVMs if you
- want to use Sun's JDK libraries. Oh yes -- you could also reimplement
- all of those native methods yourself, and make sure they behave exactly
- as Sun's do. Note that they're undocumented! </p>
- </blockquote>
- </dd>
- </dl>
-
- <hr />
- <h3><a name="2_2">2.2 </a>Does GCJ support using straight C native methods
- ala JNI? </h3>
- <dl>
- <dd>
- Yes. libgcj now has experimental support for JNI, in addition to
- its native Compiled Native Interface (CNI). gcjh will generate JNI
- stubs and headers using the "-jni" option. However, we do
- prefer CNI: it is more efficient, easier to write, and (at least
- potentially) easier to debug.
- </dd>
- </dl>
-
- <hr />
- <h3><a name="2_3">2.3 </a>Why does GCJ use CNI? </h3>
- <dl>
- <dd>
- <a href="mailto:per@bothner.com">Per Bothner</a> explains:
- <blockquote>
- <p>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.)</p>
- </blockquote>
- </dd>
- </dl>
-
- <hr />
- <h3><a name="2_4">2.4 What is the state of AWT support</a>?</h3>
- <dl>
- <dd>
- Work is in progress to implement AWT and Java2D. We
- intend to support both GTK and xlib peers written using CNI. Some
- components are already working atop the
- <a href="http://www.ii.uib.no/~rolfwr/jcnix/">xlib peers</a>.
- </dd>
- </dl>
-
- <hr />
- <h3><a name="2_5">2.5 How about support for Swing</a>?</h3>
- <dl>
- <dd>
- 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.
- </dd>
- </dl>
-
- <hr />
- <h3><a name="2_6">2.6 </a>What support is there for RMI?</h3>
- <dl>
- <dd> RMI code exists on the CVS trunk (aka gcc 3.1), but it
- has not been heavily tested. This code was donated by
- Transvirtual Technologies.
- </dd>
- </dl>
-
- <hr />
- <h3><a name="2_7">2.7 Can I use any code from other
- projects to supplement libgcj's current features?</a></h3>
- <dl>
- <dd>
- <p>Certainly, provided the licenses are compatible.
- However, in many cases, if you wanted to contribute the
- code back into the official libgcj distribution, we would require that the
- original author(s) assign copyright to the Free Software Foundation. </p>
- <p> As of March 6, 2000, libgcj has been relicenced, and copyright has
- been assigned to the <a href="http://www.gnu.org/">FSF</a>. This allows
- us to share and merge much of the libgcj codebase with the
- <a href="http://www.gnu.org/software/classpath/">Classpath</a> project.
- Our eventual goal is for Classpath to be an upstream source provider for libgcj,
- however it will be some time before this becomes reality: libgcj and Classpath
- have different implementations of
- many core java classes. In order to merge them, we need to select the
- best (most efficient, cleanest) implementation of each method/class/package,
- resolve any conflicts created by the merge, and test the final result.
- Needless to say, this is a lot of work. If you can help out, please
- <a href="mailto:java@gcc.gnu.org">let us know</a>!</p>
- </dd>
- </dl>
-
- <hr />
- <h3><a name="2_8">2.8 What features of the Java language are/aren't supported.</a></h3>
- <dl>
- <dd>
- GCJ supports all Java language constructs as per the
- <a href="http://docs.oracle.com/javase/specs/">Java language specification</a>.
- </dd>
- </dl>
-
-
- <h2><a name="4_0">Gcj Compile/Link Questions</a></h2>
-
- <h3><a name="4_1">4.1 Why do I get <tt>undefined reference to `main'</tt>
- errors?</a></h3>
- <dl>
- <dd>
- When using <tt>gcj</tt> to link a Java program, you must use the <tt>--main=</tt>
- option to indicate the class that has the desired <tt>main</tt> method.
- This is because every Java class can have a <tt>main</tt> method, thus
- you have to tell gcj which one to use.
- </dd>
- </dl>
-
- <hr />
- <h3><a name="4_2">4.2 Can GCJ only handle source code?</a></h3>
- <dl>
- <dd>
- <p>GCJ will compile both source <code>(.java)</code> and bytecode
- <code>(.class)</code> files. However, in many cases the native code produced
- by compiling from source is better optimized than that compiled from .class
- files.</p>
-
- <p><a href="mailto:per@bothner.com">Per Bothner</a> explains: </p>
- <blockquote>
- <p>The reason is that when you compile to bytecode you lose a lot
- of information about program structure etc. That information helps
- in generating better code. We can in theory recover the information
- we need by analysing the structure of the bytecodes, but it is sometimes
- difficult - or sometimes it just that no-one has gotten around to
- it.</p>
- <p>Specific examples include loop structure (gcc generates better
- code with explicit loops rather than with the equivalent spaghetti
- code), array initializers, and the JDK 1.1 `CLASS.class' syntax,
- all of which are represented using more low-level constructs in
- bytecode.</p>
- </blockquote>
- </dd>
- </dl>
-
- <hr />
- <h3><a name="4_3">4.3 "gcj -C"</a> Doesn't seem to work like javac/jikes.
- Whats going on?</h3>
- <dl>
- <dd>
- <p>The behavior of "gcj -C" is not at all like javac or jikes, which
- will compile (not just scan) all .java's which are out of date with
- regard to their .class's.</p>
- </dd>
- </dl>
-
- <hr />
- <h3><a name="4_4">4.4 Where does GCJ look for files?</a></h3>
- <dl>
- <dd>
- <p>GCJ looks for classes to compile based on the CLASSPATH environment
- variable. <code>libgcj.jar</code> and other files are found relative to the
- path of the compiler itself, so it is safe to move the entire compiler tree
- to a different path, and there is no need to include <code>libgcj.jar</code>
- in your CLASSPATH. </p>
- </dd>
- </dl>
-
- <hr />
- <h3><a name="4_5">4.5 How does gcj resolve whether to compile .class
- or .java files?</a></h3>
- <dl>
- <dd>
- <p>GCJ compiles only the files presented to it on the command line. However,
- it also needs to scan other files in order to determine the layout of other
- classes and check for errors in your code. For these dependencies, GCJ will
- favour .class files if they are available because it is faster to parse a
- class file than source code.</p>
- </dd>
- </dl>
-
-
- <h2><a name="5_0">Runtime Questions</a></h2>
-
- <h3><a name="5_1">5.1 My program is dumping core! What's going on?</a></h3>
- <dl>
- <dd>
- It could be any number of things. One common mistake is
- having your <tt>CLASSPATH</tt> environment variable pointing
- at a third party's java.lang and friends. Either unset
- <tt>CLASSPATH</tt>, or make sure it does not refer to core
- libraries other than those found in
- <tt>libgcj.jar</tt>.Note that newwer versions of
- GCJ will reject the core class library if it wasn't
- <a href="https://gcc.gnu.org/ml/java/2001-03/msg00383.html">generated</a>
- by GCJ itself.
- </dd>
- </dl>
-
- <hr />
- <h3><a name="5_2">5.2 When I run the debugger I get a SEGV in the GC!
- What's going on?</a></h3>
- <dl>
- <dd>
- This is "normal"; the Garbage Collector (GC) uses it to determine
- stack boundaries. It is ordinarily caught and handled by the GC -- you
- can see this in the debugger by using <tt>cont</tt> to continue to the
- "real" segv.
- </dd>
- </dl>
-
- <hr />
- <h3><a name="5_3">5.3 I have just compiled and benchmarked my Java application
- and it seems to be running slower than than XXX JIT JVM. Is there
- anything I can do to make it go faster?</a></h3>
- <dl>
- <dd>A few things:
- <ul>
- <li>If your programs allocate many small, short lived objects, the
- heap could be filling and triggering GC too regularly. Try increasing
- the initial and maximum heap sizes as per <i>5.5 How do I increase
- the runtime's initial and maximum heap size?</i></li>
- <li>RE - array accesses. We have sub-optimal runtime checking code,
- and the compiler is still not so smart about automatically removing
- array checks. If your code is ready, and it doesn't rely on them,
- try compiling with --no-bounds-check. </li>
- <li>Try static linking. On many platforms, dynamic (PIC) function
- calls are more expensive than static ones. In particular, the
- interaction with boehm-gc seems to incur extra overhead when shared
- libraries are used. </li>
- <li>If your Java application doesn't need threads, try building libgcj
- using --enable-threads=none. Portions of the libgcj runtime are
- still more efficient when single-threaded.</li>
- </ul>
- </dd>
- </dl>
-
- <hr />
- <h3><a name="5_4">5.4 Can I profile Garbage Collection?</a></h3>
- <dl>
- <dd>
- <p>It is possible to turn on verbose GC output by suppressing the -DSILENT
- flag during build. One way to do this is to comment out the line with
- #define SILENT 1 from boehm-gc/configure before configuring libgcj. </p>
- <p>The GC will print collection statistics to stdout. (Rebuilding boehm-gc
- alone without this flag doesn't seem to work.)</p>
- </dd>
- </dl>
-
- <hr />
- <h3><a name="5_5">5.5 How do I increase the runtime's initial and maximum
- heap sizes?</a></h3>
- <dl>
- <dd>
- <p>Some programs that allocate many small, short-lived objects can cause
- the default-sized heap to fill quickly and GC often. With the 2.95.1
- release there is no means to adjust the heap at runtime. Recent snapshots
- provide the -ms and -mx arguments to gij to specify the initial and
- maximum heap sizes, respectively.</p>
- </dd>
- </dl>
-
- <hr />
- <h3><a name="5_6">5.6 How can I profile my application?</a></h3>
- <dl>
- <dd>
- <p>Currently, only single threaded Java code may be used by the profiler
- (gprof). POSIX threads seem to be incompatible with the gmon stuff.</p>
-
- <p>A couple of other tools that have been mentioned on the GCJ mailing list are
- sprof and cprof. The former is part of GNU libc.</p>
- </dd>
- </dl>
-
- <h2><a name="6_0"></a>Programming Issues</h2>
-
- <h3><a name="6_1"></a>6.1 Are there any examples of how to use CNI?</h3>
- <dl>
- <dd>
- <p>Glenn Chambers has created a couple
- of trivial examples for
- <a href="cni-1.txt">version 2.95</a>
- and <a href="cni-2.txt">version 3.0</a>.
- As a comparison, <a href="jni-kaffe.txt">here</a>
- is the same example as a JNI application using
- <a href="http://www.kaffe.org">Kaffe</a>. The same code will
- work with GCJ, as shown <a href="jni-comp.txt">here</a>.</p>
-
- <p>Note that for version 2.95, you must compile the C++ files
- used for CNI with the -fno-rtti option.
- This constraint does not apply in version 3.0 and later.</p>
-
- <p>The primary source of documentation for CNI is
- <a href="papers/cni/t1.html">this paper</a>.</p>
- </dd>
- </dl>
-
- <hr />
- <h3><a name="6_2">6.2 Is it possible to invoke GCJ compiled Java code from a C++ application?</a></h3>
- <dl>
- <dd>
- <p>Yes, GCJ 3.1 supports a CNI-based invocation interface as well as
- the traditional JNI invocation API.
-
- See the <a href="https://gcc.gnu.org/onlinedocs/gcj/Invocation.html">GCJ Manual</a>
- for more details on how to use the CNI interface. </p>
- </dd>
- </dl>
-
-</body>
-</html>
Index: faq.html
===================================================================
RCS file: /cvs/gcc/wwwdocs/htdocs/faq.html,v
retrieving revision 1.222
diff -u -r1.222 faq.html
--- faq.html 26 Sep 2016 10:23:16 -0000 1.222
+++ faq.html 29 Dec 2016 21:04:45 -0000
@@ -17,8 +17,7 @@
<p>Other GCC-related FAQs:
<a href="https://gcc.gnu.org/onlinedocs/libstdc++/faq.html">
- libstdc++-v3</a>, and
- <a href="java/faq.html">GCJ</a>.</p>
+ libstdc++-v3</a>.</p>
<hr />
<h1>Questions</h1>
reply other threads:[~2016-12-29 21:09 UTC|newest]
Thread overview: [no followups] expand[flat|nested] mbox.gz Atom feed
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=alpine.LSU.2.20.1612291705160.2994@anthias.pfeifer.com \
--to=gerald@pfeifer.com \
--cc=gcc-patches@gcc.gnu.org \
--cc=java-patches@gcc.gnu.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).