head	1.34;
access;
symbols;
locks; strict;
comment	@# @;


1.34
date	2000.12.18.23.20.51;	author warrenl;	state Exp;
branches;
next	1.33;

1.33
date	2000.12.13.05.46.05;	author apbianco;	state Exp;
branches;
next	1.32;

1.32
date	2000.11.30.04.26.41;	author bryce;	state Exp;
branches;
next	1.31;

1.31
date	2000.11.03.02.48.44;	author tromey;	state Exp;
branches;
next	1.30;

1.30
date	2000.10.17.21.36.34;	author mark;	state Exp;
branches;
next	1.29;

1.29
date	2000.10.17.19.42.06;	author mark;	state Exp;
branches;
next	1.28;

1.28
date	2000.07.08.18.27.35;	author green;	state Exp;
branches;
next	1.27;

1.27
date	2000.07.05.06.07.11;	author kingdon;	state Exp;
branches;
next	1.26;

1.26
date	2000.06.28.04.54.21;	author apbianco;	state Exp;
branches;
next	1.25;

1.25
date	2000.06.21.21.05.38;	author tromey;	state Exp;
branches;
next	1.24;

1.24
date	2000.06.07.08.37.32;	author bryce;	state Exp;
branches;
next	1.23;

1.23
date	2000.06.06.02.23.46;	author bryce;	state Exp;
branches;
next	1.22;

1.22
date	2000.04.23.05.00.31;	author green;	state Exp;
branches;
next	1.21;

1.21
date	2000.03.29.21.02.15;	author tromey;	state Exp;
branches;
next	1.20;

1.20
date	2000.03.27.20.23.21;	author tromey;	state Exp;
branches;
next	1.19;

1.19
date	2000.03.15.05.16.52;	author bryce;	state Exp;
branches;
next	1.18;

1.18
date	2000.03.13.17.23.06;	author tromey;	state Exp;
branches;
next	1.17;

1.17
date	2000.03.09.20.10.41;	author warrenl;	state Exp;
branches;
next	1.16;

1.16
date	2000.03.09.11.54.27;	author warrenl;	state Exp;
branches;
next	1.15;

1.15
date	2000.03.03.05.12.26;	author bryce;	state Exp;
branches;
next	1.14;

1.14
date	2000.03.03.04.56.29;	author bryce;	state Exp;
branches;
next	1.13;

1.13
date	2000.02.18.18.31.16;	author tromey;	state Exp;
branches;
next	1.12;

1.12
date	2000.02.17.07.57.12;	author green;	state Exp;
branches;
next	1.11;

1.11
date	2000.02.09.01.03.58;	author apbianco;	state Exp;
branches;
next	1.10;

1.10
date	2000.01.16.02.08.50;	author tromey;	state Exp;
branches;
next	1.9;

1.9
date	2000.01.06.03.27.14;	author green;	state Exp;
branches;
next	1.8;

1.8
date	99.12.22.17.36.43;	author green;	state Exp;
branches;
next	1.7;

1.7
date	99.12.20.01.05.31;	author brads;	state Exp;
branches;
next	1.6;

1.6
date	99.10.25.07.30.12;	author warrenl;	state Exp;
branches;
next	1.5;

1.5
date	99.10.14.08.12.30;	author warrenl;	state Exp;
branches;
next	1.4;

1.4
date	99.10.13.23.43.16;	author warrenl;	state Exp;
branches;
next	1.3;

1.3
date	99.10.13.01.24.26;	author warrenl;	state Exp;
branches;
next	1.2;

1.2
date	99.09.28.08.41.40;	author warrenl;	state Exp;
branches;
next	1.1;

1.1
date	99.09.07.00.34.01;	author green;	state Exp;
branches;
next	;


desc
@@


1.34
log
@	* build-snapshot.html: Mention more specifics on activating libgcj
	regarding noconfigdirs in the toplevel configure.in.
	* index.html: Added a Build link.
	* about.html: Ditto.
	* contrib.html: Ditto.
	* docs.html: Ditto.
	* done.html: Ditto.
	* download.html: Ditto.
	* faq-portugese.html: Ditto.
	* faq.html: Ditto.
	* mail.html: Ditto.
	* projects.html: Ditto.
	* support.html: Ditto.
	* thanks.html: Ditto.
	* tm.html: Ditto.
@
text
@<html>
<head>
<title>The GCJ FAQ</title>
</head>
<!--#include virtual="/include/header-subpages.html"-->
<body bgcolor="#FFFFFF">
<table border=0>
  <tr>
    <td valign="top"> 
      <table border=0>
        <tr>
          <td> <img src="gcj.jpg" alt="gcj logo" width=136 height=98> </td>
        </tr>
        <tr> 
          <td> <br>
            <table border=0>
              <tr>
                <td width="10"></td>
                <td> <a href="index.html">Home</a><br>
                  <a href="faq.html">FAQ</a><br>
                  <a href="mail.html">Mailing Lists</a><br>
                  <a href="docs.html">Documentation</a><br>
                  <a href="download.html">Download</a><br>
		  <a href="build-snapshot.html">Build</a><br>
                  <a href="contrib.html">Contributing</a><br>
		  <a href="done.html">Done with Gcj</A><br>
                  <a href="http://sourceware.cygnus.com/cgi-bin/gnatsweb.pl?user=guest&password=guest&database=java&cmd=login">Bugs</a><br>
                  <a href="thanks.html">Thanks</a><br>
                  <!-- <a href="support.html">Support</a><br> --> <br>
                  <br>
                  <br>
                  <a href="http://gcc.gnu.org">GCC</a><br>
                  <a href="http://sourceware.cygnus.com/mauve">The Mauve Project</a><br>
                  <a href="http://sourceware.cygnus.com">Sourceware</a><br>
                  <a href="http://www.gnu.org">The GNU Project</a><br>
                  <a href="http://www.redhat.com">Red Hat</a><br>
                </td>
              </tr>
            </table>
          </td>
        </tr>
      </table>
    </td>
    <td width=2 bgcolor="black"> i </td>
    <td width=6> </td>
    <td> <br>
      <br>
      <h1>The GCJ FAQ</h1>
      <p>The latest version of this document is always available at <a href="faq.html">http://sourceware.cygnus.com/java/faq.html</a>.</p>
      <p>This FAQ is also available in <a href="faq-portugese.html">Brazilian Portugese</a>.</p>
      <ol>
        <li><a href="#1_0">General Questions</a> 
          <ol>
            <li><a href="#1_1">What license is used for libgcj?</a> 
            <li><a href="#1_2">How can I report a bug in libgcj?</a> 
            <li><a href="#1_3">How can I contribute to libgcj?</a> 
            <li><a href="#1_4">Is libgcj part of GCC?</a> 
            <li><a href="#1_5">Will gcj and libgcj work on my machine?</a> 
            <li><a href="#1_6">How can I debug my Java program?</a> 
            <li><a href="#1_7">Can I interface byte-compiled and native java code?</a>
          </ol>
        <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 OpenSource 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><a href="#3_0">Build Issues</a> 
          <ol>
            <li><a href="#3_1">I need something more recent than the last release; how
                  should I build it?</a>
            <li><a href="#3_2">Linker bug on Solaris</a> 
            <li><a href="#3_3">Can I configure/build in the source tree?</a> 
	    <li><a href="#3_4">My libgcj build fails with "invalid use of undefined type struct sigcontext_struct"</a>
          </ol>
        <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><a href="#4_2">Can GCJ only handle source code? </a> 
            <li><a href="#4_3">&quot;gcj -C" Doesnt seem to work like javac/jikes. 
              Whats going on? </a> 
            <li><a href="#4_4">Where does GCJ look for files? </a> 
            <li><a href="#4_5">How does gcj resolve wether to compile .class or 
              .java files? </a> 
            <li><a href="#4_6">I'm getting link errors!</a> 
          </ol>
        <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><a href="#5_2">When I run the debugger I get a SEGV in the GC! 
              What's going on?</a> 
            <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><a href="#5_4">Can I profile Garbage Collection? </a> 
            <li><a href="#5_5">How do I increase the runtime's initial and maximum 
              heap sizes?</a> 
            <li><a href="#5_6">How can I profile my application?</a> 
	    <li><a href="#5_7">I'm getting 'undefined symbol: __dso_handle'</a>
	    <li><a href="#5_8">My program seems to hang and doesn't produce any output</a>
          </ol>
        <li><a href="#6_0">Programing Issues</a> 
          <ol>
            <li><a href="#6_1">Are there any examples of how to use CNI?</a></li>
          </ol>
        </li>
      </ol>
      <table border="0" cellpadding="4" width="95%">
        <tr bgcolor="#b0d0ff"> 
          <th align="left"> 
            <h2><a name="1_0">General Questions</a></h2>
          </th>
        </tr>
      </table>
      <br>
      <dl> 
        <dt> 
          <h3><a name="1_1">1.1 What license is used for libgcj?</a></h3>
        </dt>
        <p> 
        <dd>
          libgcj is distributed under the GPL, with the 'libgcc exception'.
          This means that if 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>
        <p></p>
        <dt> 
          <hr>
          <h3><a name="1_2">1.2 How can I report a bug in libgcj?</a></h3>
        </dt>
        <p> 
        <dd>libgcj has a corresponding <a
      href="http://sourceware.cygnus.com/cgi-bin/gnatsweb.pl?user=guest&password=guest&database=java&cmd=login">Gnats 
          bug database</a> which you can browse. You can also submit new bug reports 
          from the Gnats page.</dd>
        <p></p>
        <dt> 
          <hr>
          <h3><a name="1_3">1.3 How can I contribute to libgcj?</a></h3>
        </dt>
        <p> 
        <dd>You can send simple bug fixes in as patches. Please follow the <a href="http://gcc.gnu.org/contribute.html">GCC 
          guidelines for submitting patches</a>. For more complex changes, you 
          must sign copyright over to the Free Software Foundation. See the <a href="contrib.html">contribution</a> 
          page for details.</dd>
        <p></p>
        <dt> 
          <hr>
          <h3><a name="1_4">1.4 Is libgcj part of GCC?</a></h3>
        </dt>
        <p> 
        <dd>Yes, libgcj is now part of GCC. It can be downloaded,
        configured and built as one single tree.</dd>
        <p></p>
        <dt> 
          <hr>
          <h3><a name="1_5">1.5 Will gcj and libgcj work on my machine?</a></h3>
        </dt>
        <p> 
        <dd>Gcj and libgcj are known to work more or less with IA-32 and 
          Sparc Solaris, as well as IA-32, Alpha, and PowerPC Linux. 
	  They might work on other systems, but we don't know. 
          Generally speaking, porting to a new system should not be hard. This 
          would be a good way to volunteer.</dd>
        <p></p>
        <dt> 
          <hr>
          <h3><a name="1_6">1.6 How can I debug my Java program?</a></h3>
        </dt>
        <p> 
        <dd><a href="ftp://ftp.gnu.org/pub/gnu/gdb/gdb-4.18.tar.gz">gdb 4.18</a> 
          includes support for debugging gcj-compiled Java programs. For linux, 
          you will need to use a recent development snapshot of gdb from 
	  <a href="ftp://sourceware.cygnus.com/pub/gdb/snapshots/">ftp://sourceware.cygnus.com/pub/gdb/snapshots/</a> 
	  , or the gdb included with Redhat 6.1 and newwer. 
	  The standard 4.18 does not have support for linux threads. 
	  For more information please read 
	  <a href="gdb.html">Java Debugging with gdb</a>.</dd>
        <dt>&nbsp; </dt>

        <dt> 
          <hr>
          <h3><a name="1_7">1.7 Can I interface byte-compiled and native java code</a></h3>
        </dt>
        <p> 
        <dd>
	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. Currently this only works on x86 linux. 
        <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:
<pre>
$ gcj -shared -o HelloWorld.so HelloWorld.java
$ gij HelloWorld
</pre>
          This works because gij uses Class.forName, which now knows how to load shared objects.
        </dd>
        <dt>&nbsp; </dt>	
      </dl>
      <table border="0" cellpadding="4" width="95%">
        <tr bgcolor="#B0D0FF"> 
          <th align="left"> 
            <h2><a name="2_0">Java Feature Support</a></h2>
          </th>
        </tr>
      </table>
      <dl> 
      </dl>
      <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:</dd>
        <dl> 
          <dd>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. </dd>
          <dt>&nbsp;</dt>
          <dd>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 &quot;write once, run everywhere&quot; 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. </dd>
          <dt>&nbsp;</dt>
          <dd>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! </dd>
        </dl>
        <dt>&nbsp;</dt>
       </dl>
        </dl>
        <hr>
        <h3><a name="2_2">2.2 </a>Does GCJ support using straight C native methods 
          ala JNI? </h3>
        <blockquote> 
	  <p>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.
        </blockquote>
        <hr>
        <h3><a name="2_3">2.3 </a>Why does GCJ use CNI? </h3>
        <blockquote> 
          <p><a href="mailto:per@@bothner.com">Per Bothner</a> explains </p>
          <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>
        </blockquote>
        <hr>
      </dl>
      <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>.
      </dl>
      <hr>
      <h3><a name="2_5">2.5 How about support for Swing</a>?</h3>
      <dl> 
        <dl> 
          <dt>Considering that AWT support isnt here yet there is no chance of 
            getting Swing running. Once we have AWT support the Swing 1.1.1 may 
            be useable and even redistributable, but JFC will be another issue, 
            as <a href="mailto:moroz@@metahood.ru">Oleg Moroz</a> summarises: 
            <blockquote> 
              <p>1) Swing 1.1.1 for JDK 1.1.x with license that allows to redistribute 
                it as part of the value-added applet or application. This needs 
                some research, however I feel that the term "value-added application" 
                might include e.g. gcj-based development system; if it is not 
                by itself, a simple Swing-based application might be added to 
                the distribution). This version depends on AWT 1.1 only (well, 
                1.1.x, x >=7) and it seems that the Sun's version could be used 
                for most purposes people would like to use it. </p>
            </blockquote>
          </dt>
          <blockquote> 
            <p>2) Swing (JFC) that is part of Java2. This is AFAIK not available 
              as separate product and is covered by more restrictive (in this 
              case at least) JDK license; it is also dependent on AWT 1.2 features. 
              We'd want to develop a replacement only when we move to the 1.2 
              codebase and then we'll also need to develop AWT 1.2 replacement 
              w/o regard to Swing.</p>
          </blockquote>
        </dl>
        <dl> 
          <dt><a href="mailto:per@@bothner.com">Per Bothner</a> expands:</dt>
          <dd>&nbsp;</dd>
          <dd>One possibility worth considering is developing Swing components 
            in conjunction with AWT. We can implement JTextArea and TextArea at 
            the same time. We could also implement both on top of (say) some Gtk 
            widget; we don't necessarily *have* to go the "peerless" route. Instead, 
            we can base the "plugable look-and-feel" on the "themebility" of (say) 
            Gtk. </dd>
          <dt>&nbsp;</dt>
          <dd>A bigger potential issue is Swing's separation between &quot;model&quot; 
            (e.g. Document) and &quot;view&quot; (e.g. JTextPane). It may be difficult 
            to make use of the functionality of an existing toolkit such as Gtk 
            unless we can use Gtk widgets with separate &quot;model&quot; objects.</dd>
        </dl>
        <dt>&nbsp; </dt>
        <hr>
      </dl>
      <h3><a name="2_6">2.6 </a>What support is there for RMI?</h3>
      <dl> 
        <dd> There is no RMI support at the moment. <a href="mailto:mdw@@cs.berkeley.edu">Matt 
          Welsh</a> elaborates:</dd>
        <dt> 
          <dl> 
            <dd>I was working on this, but it's on the back-burner right now. 
              So, if anyone would like to help out I would appreciate it. I have 
              a free implementation of RMI (&quot;NinjaRMI&quot;) that is quite 
              similar to Sun's RMI. You can download it from <a href="http://www.cs.berkeley.edu/%7Emdw/proj/ninja">http://www.cs.berkeley.edu/~mdw/proj/ninja</a></dd>
          </dl>
        </dt>
        <dd><a href="http://www.cs.berkeley.edu/%7Emdw/proj/ninja"></a></dd>
      </dl>
      <blockquote> 
        <blockquote> 
          <p>Note that this is NOT Java RMI per se; it is just very similar in 
            functionality and design. You might want to steal some classes out 
            of it to get RMI support in libgcj. However, it does require some 
            classes in java.* and sun.* which are not part of libgcj.</p>
        </blockquote>
        <p>It may be possible to use the JavaParty's <a href="http://wwwipd.ira.uka.de/%7Ehauma/EfficientRMI/">RMI 
          implementation</a>, but the licensing is much more restrictive than 
          that of NinjaRMI. Details below:</p>
        <blockquote> 
          <p>The much faster drop-in RMI and the appropriate efficient serialization 
            is designed and implemented completely in Java without any native 
            code. Moreover, the re-designed RMI supports non-TCP/IP communication 
            networks, even with heterogeneous transport protocols. As a by-product, 
            there is a benchmark collection for RMI. </p>
        </blockquote>
      </blockquote>
      <p></p>
      <dl> 
        <dt>&nbsp; </dt>
        <hr>
      </dl>
      <dl> 
        <dt> 
          <h3><a name="2_7">2.7 Can I use any code from other OpenSource
            projects to supplement libgcj's current features?</a></h3>
        </dt>
	<dd>
	<p> Certainly. 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) 
	<A HREF="http://www.gnu.org/software/gcc/fsf-forms/assignment-instructions.html">
	assign copyright</A> to the Free Software Foundation.  
	<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.classpath.org">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-discuss@@sourceware.cygnus.com">let us know</A>!
      </dl>

      <hr>

      <dl> 
        <dt> 
          <h3><a name="2_8">2.8 What features of the Java language are/aren't supported.</a></h3>
        </dt>
        <dd>GCJ supports all Java language constructs as per the 
          <a href="http://java.sun.com/docs/books/jls/">Java language Specification 
          v1.0</a>. Recent GCJ snapshots have added support for most JDK1.1 
	  language features, including inner classes.
      </dl>
      <dl> 
        <p></p>
      </dl>
      <table border="0" cellpadding="4" width="95%">
        <tr bgcolor="#b0d0ff"> 
          <th align="left"> 
            <h2><a name="3_0">Build Issues</a></h2>
          </th>
        </tr>
      </table>

      <dl> 
        <dt> 
          <h3><a name="3_1">3.1 I need something more recent than the last release; how should I build it?</a></h3>
        </dt>
        <p> 
        <dd>Please read <a href="build-snapshot.html">here</a>.
        </dd>
        <p></p>
      </dl>

      <hr>

      <dl> 
        <dt> 
          <h3><a name="3_2">3.2 Linker bug on Solaris</a></h3>
        </dt>
        <p> 
        <dd>There is a known problem with the <a href="http://gcc.gnu.org/ml/gcc-bugs/1999-10/msg00159.html"> 
          native Solaris linker</a> when using gcc/gcj. A good indication you've 
          run into this problem is if you get an error that looks like the following 
          when building libgcj: 
          <pre>
ld: warning: option -o appears more than once, first setting taken
ld: fatal: file libfoo.so: cannot open file: No such file or directory
ld: fatal: File processing errors. No output written to .libs/libfoo.so
collect2: ld returned 1 exit status
	</pre>
          A known workaround for this and other reported link problems on the 
          various releases of Solaris is to build gcc/gcj with the <a href="ftp://sourceware.cygnus.com/pub/binutils/snapshots"> 
          latest GNU binutils</a> instead of the native Solaris <tt>ld</tt>. The 
          most straightforward way to do this is to build and install binutils, 
          and then reference it in the configure for gcc via <tt>--with-ld=/path_to_binutils_install/bin/ld</tt> 
          (<tt>--with-as</tt> may also be similarly specified but is not believed 
          to be required). 
          <p> Please note, gcc/gcj must be built using GNU ld prior to doing a 
            clean build of libgcj! 
        </dd>
        <p></p>
      </dl>

      <hr>

      <dl> 
        <dt> 
          <h3><a name="3_3">3.3 Can I configure/build in the source tree?</a></h3>
        </dt>
        <p> 
        <dd>No.  You cannot configure/build in the source tree.  If you try,
	you'll see something like:
	<pre>
$ ./configure [...]
Configuring for a i686-pc-linux-gnu host.
*** Cannot currently configure in source tree.
	</pre>
	Instead, you must build in another directory.  E.g.:
	<pre>
$ mkdir build
$ cd build
$ ../configure [...]
	</pre>
        </dd>
        <p></p>
      </dl>
      
      <hr>

      <dl> 
        <dt> 
          <h3><a name="3_4">3.4 My libgcj build fails with "invalid use of undefined type struct sigcontext_struct"</a></h3>
        </dt>
        <p> 
	<dd>If you're using Linux, this probibly means you need to upgrade to
	a newwer, glibc (libc6) based Linux distribution. libgcj does not 
	support the older linux libc5.
	<p>It might be possible to get a working libgcj by changing occurances
	of "sigcontext_struct" to "sigcontext", however this has not been tested.
	Even if it works, it is likely that there are other issues with older
	libc versions that would prevent libgcj from working correctly (threads
	bugs, for example).
        </dd>
      </dl>


      <table border="0" cellpadding="4" width="95%">
        <tr bgcolor="#b0d0ff"> 
          <th align="left"> 
            <h2><a name="4_0">Gcj Compile/Link Questions</a></h2>
          </th>
        </tr>
      </table>
      <dl> 
        <dt> 
          <h3><a name="4_1">4.1 Why do I get <tt>undefined reference to `main'</tt> 
            errors?</a></h3>
        </dt>
      </dl>
      <p> 
      <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>
        <dt>&nbsp;</dt>
        <hr>
      </dl>
      <dl> 
        <dt> 
          <h3><a name="4_2">4.2 Can GCJ only handle source code?</a></h3>
        </dt>
      </dl>
      <p> 
      <dl> 
        <dd>The GCJ compiler will compile both java source and bytecode .class 
          files. For the moment support for compiling bytecodes will support more 
          applications than compiling from source, as the source code compiler 
          has some bugs in its support for inner classes, which are used heavily 
	  in programs written for the JDK 1.1 (AWT in particular). 
          <p>In many cases the native code produced by compiling from source is 
            better optimised than that compiled from .class files. Per Bothner 
            explains:</p>
        </dd>
        <dt> 
          <dl> 
            <dd>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>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>
            </dd>
          </dl>
        </dt>
        <hr>
        <dt><font color="#FF3300"></font></dt>
        <dt> 
          <h3><a name="4_3">4.3 &quot;gcj -C"</a> Doesnt seem to work like javac/jikes. 
            Whats going on?</h3>
        </dt>
        <blockquote> 
          <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>
        </blockquote>
      </dl>
      <hr>

      <dl> 
        <dt> 
          <h3><a name="4_4">4.4 Where does GCJ look for files?</a></h3>
        </dt>
        <blockquote> 
          <p>GCJ looks for classes to compile based on the CLASSPATH environment 
            variable. An important limitation presently is that gcj doesn't handle 
            compressed jar files in your classpath. </p>
        </blockquote>
      </dl>
      <hr>

      <dl> 
        <dt> 
          <h3><a name="4_5">4.5 How does gcj resolve whether to compile .class 
            or .java files?</a></h3>
        </dt>
        <blockquote> 
          <p>GCJ seems to favor .class files in the CLASSPATH, if any, otherwise 
            it will use the source (.java), also in the CLASSPATH. It also checks 
            to see if the class is newer than the .java file. If it can't find 
            either it throws an error.</p>
        </blockquote>
      </dl>
      
      <hr>
      
      <dl>
        <dt>
          <h3><a name="4_6">4.6 I'm getting link errors</a></h3>
        </dt>
        <blockquote>
        <p>If you get errors at link time that refer to
          'undefined reference to `java::lang::Object type_info function',
          verify that you have compiled any CNI C++ files with the
          -fno_rtti option.
        </blockquote>
      </dl>
      
      <dl> 
        <dt>&nbsp; </dt>
      </dl>
      <dl> 
        <p></p>
      </dl>
      <table border="0" cellpadding="4" width="95%">
        <tr bgcolor="#B0D0FF"> 
          <th align="left"> 
            <h2><a name="5_0">Runtime Questions</a></h2>
          </th>
        </tr>
      </table>
      <dl> 
        <dt> 
          <h3><a name="5_1">5.1 My program is dumping core! What's going on?</a></h3>
        </dt>
        <p> 
        <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 libgcj.zip.</dd>
	  <p> An other symptom covered by this fix is a running
          "<tt>Hello World</tt>" type program, with a lot of non printable
	  ASCII garbage before and/or after the output.
        <dd></dd>
      </dl>
      <p></p>
      <dl> 
        <dt> 
          <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>
        </dt>
      </dl>
      <p> 
      <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. 
          <p>This shouln't happen anymore, as we dont define MPROTECT_VDB in the 
            GC, at least for Linux/386.</p>
        </dd>
      </dl>
      <p></p>
      <dl> 
        <dt> 
          <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>
        </dt>
      </dl>
      <p> 
      <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. The interaction with boehm-gc seems to incur 
              extra overhead when shared libraries are used. On one program that 
              makes heavy use of the allocator I achieved over 30% runtime performance 
              gain with static linking. This shouldn't be an issue
              with the current CVS gcj, as it handles GC marking
              differently in most cases.</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>
      <p></p>
      <p> 
      <dl> 
      <hr>
        <dt> 
          <h3><a name="5_4">5.4 Can I profile Garbage Collection?</a></h3>
        </dt>
        <dd>It is possible to turn on verbose GC output by supressing 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. 
        </dd>
        <dt>&nbsp;</dt>
        <dd>The GC will print collection statistics to stdout. (Rebuilding boehm-gc 
          alone without this flag doesn't seem to work.)</dd>
        <dt>&nbsp;</dt>
        <hr>
        <dt> 
          <h3><a name="5_5">5.5 How do I increase the runtime's initial and maximum 
            heap sizes?</a></h3>
        </dt>
        <dd>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.</dd>
      </dl>
      <hr>
      <dl> 
        <dt> 
          <h3><a name="5_6">5.6 How can I profile my application?</a></h3>
        </dt>
        <dd>Support for this is currently lagging. Only single threaded Java code 
          may be used by the profiler (gprof). POSIX threads seem to be incompatible 
          with the gmon stuff.</dd>
        <dt>&nbsp;</dt>
      </dl>
      
      <hr>

      <dl>
	<dt>
          <h3><a name="5_7">5.7 I'm getting 'undefined symbol: __dso_handle'</a></h3>
	</dt>
	<dd>
	Some versions of the GNU linker have broken support for the '.hidden'
	directive, which results in problems with shared libraries built with
	recent versions of gcc.	
	<p>
	There are three solutions:
	<ul>
	  <li>downgrade to binutils that don't support .hidden at all,
	  <li>upgrade to a recent CVS binutils, or
	  <li>undef the HAVE_GAS_HIDDEN definition in gcc's auto-host.h
	  (and rebuild gcc).
	</ul>
	</dd>
      </dl>      

    <hr>  
    <dl>
	<dt>
      <h3><a name="5_8">5.8 My program seems to hang and doesn't produce any output</a></h3>
	</dt>
    <dd>
    There seems to be a bug in the current iconv support. You can work around
    it for now by setting <tt>LANG=en_US.UTF-8</tt> at runtime. Or give the
    following option during compile time
    <tt>-Dfile.encoding=UTF-8</tt>.  This problem should no longer
    occur as of November 1, 2000.
    </dd>
    </dl>

      <p> 
      <table width="100%" border="0">
        <tr bgcolor="#B0D0FF" align="left"> 
          <th> 
            <h2><a name="6_0"></a>Programing Issues </h2>
          </th>
        </tr>
      </table>
      <h3><a name="6_1"></a>6.1 Are there any examples of how to use CNI?</h3>
      <blockquote> 
        <p>Glenn Chambers has created a couple 
          of trivial examples <a href="cni-1.txt">here</a> and <a href="cni-2.txt">here</a>. 
        As a comparision, <a href="jni-kaffe.txt">here</a>
        is the same example as a JNI application.
        </p>
        <p>
        Note that you must compile the C++ files used for CNI with the
        -fno-rtti option.
        </p>
        <p>The primary source of documentation for CNI is at <a href="papers/cni/t1.html">http://sourceware.cygnus.com/java/papers/cni/t1.html</a></p>
      </blockquote>
    </td>
  </tr>
</table>
<hr>
<address> <a href="about.html">The GCJ team</a> <br>
<small> $Id: faq.html,v 1.33 2000/12/13 05:46:05 apbianco Exp $ </small></address>
<h2 align=center>&nbsp;</h2>

    <!--#include virtual="/include/footer-subpages.html"-->
@


1.33
log
@2000-12-12  Alexandre Petit-Bianco  <apbianco@@cygnus.com>

	* build-snapshot.html: Reorganized to account for the unified tree.
	* download.html: Mention unified tree. Snapshots, cvs and cvs web
	access info modified.
	* faq.html (1_4): Libgcj is part of gcc.
	(4_7): Removed
	* index.html: Fastjar replaces zip.

(http://sources.redhat.com/ml/java-patches/2000-q4/msg00242.html)
@
text
@d24 1
d784 1
a784 1
<small> $Id: faq.html,v 1.32 2000/11/30 04:26:41 bryce Exp $ </small></address>
@


1.32
log
@	* faq.html (2.4): Update AWT status.
@
text
@d56 1
a56 1
            <li><a href="#1_4">Why isn't libgcj part of GCC?</a> 
a93 1
            <li><a href="#4_7">I'm getting 'gcj: libgcj.spec: No such file or directory'</a>	    
d158 1
a158 1
          <h3><a name="1_4">1.4 Why isn't libgcj part of GCC?</a></h3>
d161 2
a162 2
        <dd>Various minor reasons. It's likely that libgcj will end up in GCC 
          at some point in the future.</dd>
a606 12
      <hr>
      
      <dl>
	<dt>
          <h3><a name="4_7">4.7 I'm getting 'gcj: libgcj.spec: No such file or directory'</a></h3>
	</dt>
	<blockquote>
	<p>Make sure you configure both libgcj and gcj with the 
	same "--prefix" directory.
	</blockquote>
      </dl>   
            
d783 1
a783 1
<small> $Id: faq.html,v 1.31 2000/11/03 02:48:44 tromey Exp $ </small></address>
@


1.31
log
@	* faq.html: Update for bitmap marking, iconv bug fixes.  Typo
	fix.
@
text
@d283 4
a286 36
        <dd> No support is currently in place for AWT. Prior Art which could be 
          used for this all require JNI. Possible starting points follow: 
          <dl> </dl>
          <p>QtAWT</p>
          <blockquote> 
            <p>QtAWT ( )provides a Qt based implementation of the peer classes 
              used by the AWT components. This consists of a set of Java classes 
              that implement the interfaces specified in java.awt.peer, and a 
              few others such as java.awt.Toolkit. The classes are implemented 
              in a mixture of Java code and native code, with the native methods 
              being called via the JNI. Because it sticks to standard APIs such 
              as the JNI QtAWT should be portable enough to work on any 1.1 JVM. 
              Once the class and library paths have been set up correctly, the 
              QtAWT can be used instead of the native peers provided with your 
              JVM by setting the awt.toolkit property to point to the QtToolkit 
              implementation. </p>
          </blockquote>
        </dd>
        <dl> 
          <dt>&nbsp;</dt>
          <dd><a href="http://developer.kde.org/language-bindings/java/qtawt/developer.html">http://developer.kde.org/language-bindings/java/qtawt/developer.html</a></dd>
          <dt>&nbsp;</dt>
          <dt>GTK AWT</dt>
          <dd>Some Mozilla / Blackdown project mambers are having a go at this 
            (free login required):</dd>
          <dd><a href="http://developer.java.sun.com/developer/restricted/java2cs/contribs/">http://developer.java.sun.com/developer/restricted/java2cs/contribs/</a></dd>
          <dt>&nbsp;</dt>
          <dd>The Classpath project is doing AWT with GTK peers, and they're looking 
            for someone who wants to make Classpath work with Kaffe ... <a href="http://www.gnu.org/software/classpath/">http://www.gnu.org/software/classpath/</a></dd>
          <dt>&nbsp;</dt>
        </dl>
        <dl> 
          <dt><a href="http://www.kaffe.org/">Kaffe</a> AWT</dt>
          <dd>Kaffe has a JNI based AWT implementation using lightweight peers. 
            Work is currently in progress to implement using GTK.</dd>
        </dl>
d796 1
a796 1
<small> $Id: faq.html,v 1.30 2000/10/17 21:36:34 mark Exp $ </small></address>
@


1.30
log
@Small HTML fixes
@
text
@d716 1
a716 1
              array checks. If you're code is ready, and it doesn't rely on them, 
d721 3
a723 2
              gain with static linking. This issue may disappear soon with a new 
              version of the GC.</li>
d796 3
a798 1
    following option during compile time <tt>-Dfile.encoding=UTF-8</tt>.
d828 1
a828 1
<small> $Id: faq.html,v 1.29 2000/10/17 19:42:06 mark Exp $ </small></address>
@


1.29
log
@    * build-snapshot.html: Add --enable-libstdcxx-v3
    * faq.html: Mention the iconv bug and workaround
@
text
@d772 2
a773 2
	<blockquote>
	<p>Some versions of the GNU linker have broken support for the '.hidden'
d783 2
a784 2
	</sl>
	</blockquote>
d825 1
a825 1
<small> $Id: faq.html,v 1.28 2000/07/08 18:27:35 green Exp $ </small></address>
@


1.28
log
@Revert Jim Kingdon's changes
@
text
@d109 1
d786 13
a798 1
      
d825 1
a825 1
<small> $Id: faq.html,v 1.26 2000/06/28 04:54:21 apbianco Exp $ </small></address>
@


1.27
log
@sourceware.cygnus.com->sources.redhat.com
@
text
@d2 5
a6 6
<title>GCJ - FAQ</title>
<body bgcolor="white">

<table border=0>
<tr><td valign="top">

d8 463
a470 140
<tr><td>
<img src="gcj.jpg" alt="gcj logo" width=136 height=98>
</td></tr>
<tr>
<td>
<br>
<table border=0><tr><td width="10"></td><td>
<a href="index.html">Home</a><br>
<a href="faq.html">FAQ</a><br>
<a href="mail.html">Mailing Lists</a><br>
<a href="docs.html">Documentation</a><br>
<a href="download.html">Download</a><br>
<a href="contrib.html">Contributing</a><br>
<a href="/cgi-bin/gnatsweb.pl?user=guest&password=guest&database=java&cmd=login">Bugs</a><br>
<a href="thanks.html">Thanks</a><br>
<!-- <a href="support.html">Support</a><br> -->
<br><br><br>
<a href="http://gcc.gnu.org/">GCC</a><br>
<a href="/mauve">The Mauve Project</a><br>
<a href="/">Sources.redhat.com</a><br>
<a href="http://www.gnu.org">The GNU Project</a><br>
<a href="http://www.redhat.com">Red Hat</a><br>
</td></tr></table>
</td></tr></table>

</td>

<td width=2 bgcolor="black">
i
</td>
<td width=6>
</td>

<td>

<br><br>
<h1>The GCJ FAQ</h1>

<P>The latest version of this document is always available at
<A HREF="faq.html">http://sources.redhat.com/java/faq.html</A>.</P>

<OL>
   <LI><A HREF="#1_0">General Questions</A>
   <OL>
      <LI><A HREF="#1_1">What license is used for libgcj?</A>
      <LI><A HREF="#1_2">How can I report a bug in libgcj?</A>
      <LI><A HREF="#1_3">How can I contribute to libgcj?</A>
      <LI><A HREF="#1_4">Why isn't libgcj part of GCC?</A>
      <LI><A HREF="#1_5">Will gcj and libgcj work on my machine?</A>
      <LI><A HREF="#1_6">How can I debug my Java program?</A>
   </OL>
   <LI><A HREF="#2_0">Build Issues</A>
   <OL>
      <LI><A HREF="#2_1">Linker bug on Solaris</A>
   </OL>
   <LI><A HREF="#3_0">Gcj Compile/Link Questions</A>
   <OL>
      <LI><A HREF="#3_1">Why do I get <tt>undefined reference to `main'</tt> errors?</A>
   </OL>
   <LI><A HREF="#4_0">Runtime Questions</A>
   <OL>
      <LI><A HREF="#4_1">My program is dumping core!  What's going on?</A>
      <LI><A HREF="#4_2">When I run the debugger I get a SEGV in the GC!  What's going on?</A>
   </OL>
</OL>

<table border="0" cellpadding="4" width="95%">
<tr bgcolor="#b0d0ff">
 <th align="left">
 <A NAME="1_0"><h2>General Questions</h2></A>
 </th>
</tr>
</table>
<br>

    <dl>
      <dt><h3><a name="1_1">1.1 What license is used for libgcj?</a></h3></dt>
      <p>
      <dd>libgcj is distributed under the Library GPL.</dd>
      </p>

      <dt><hr><h3><a name="1_2">1.2 How can I report a bug in libgcj?</a></h3></dt>
      <p>
      <dd>libgcj has a corresponding
	<a
      href="/cgi-bin/gnatsweb.pl?user=guest&password=guest&database=java&cmd=login">Gnats
	  bug database</a> which you can browse.  You can also submit new
	bug reports from the Gnats page.</dd>
      </p>

      <dt><hr><h3><a name="1_3">1.3 How can I contribute to libgcj?</a></h3></dt>
      <p>
      <dd>You can send simple bug fixes in as patches.  Please follow
	the <a href="http://egcs.cygnus.com/contribute.html">GCC guidelines
	for submitting patches</a>.
	For more complex changes, you must sign copyright over to
	Cygnus.  See the <a href="contrib.html">contribution</a> page
	for details.</dd>
      </p>

      <dt><hr><h3><a name="1_4">1.4 Why isn't libgcj part of GCC?</a></h3></dt>
      <p>
      <dd>Various minor reasons.  It's likely that libgcj will end up
	in GCC at some point in the future.</dd>
      </p>

      <dt><hr><h3><a name="1_5">1.5 Will gcj and libgcj work on my machine?</a></h3></dt>
      <p>
      <dd>So far gcj and libgcj have only really been tried on Sparc
	Solaris and x86 Linux.  They might work on other systems, but
	we don't know.  Generally speaking, porting to a new system
	should not be hard.  This would be a good way to volunteer.</dd>
      </p>

      <dt><hr><h3><a name="1_6">1.6 How can I debug my Java program?</a></h3></dt>
      <p>
      <dd><a href="ftp://ftp.gnu.org/pub/gnu/gdb/gdb-4.18.tar.gz">gdb
	4.18</a> includes support for debugging gcj-compiled Java
	programs.</dd>
      </p>

    </dl>

<table border="0" cellpadding="4" width="95%">
<tr bgcolor="#b0d0ff">
 <th align="left">
 <A NAME="2_0"><h2>Build Issues</h2></A>
 </th>
</tr>
</table>
    <dl>

      <dt><h3><a name="2_1">2.1 Linker bug on Solaris</a></h3></dt>
      <p>
      <dd>There is a known problem with the 
        <a href="http://egcs.cygnus.com/ml/gcc-bugs/1999-10/msg00159.html">
        native Solaris linker</a> when using gcc/gcj.
	A good indication you've run into this problem is if you get
	an error that looks like the following when building libgcj:
	<pre>
d476 299
a774 10
	A known workaround
	for this and other reported link problems on the various releases
	of Solaris is to build gcc/gcj with the 
        <a href="ftp://sources.redhat.com/pub/binutils/snapshots">
	latest GNU binutils</a> instead of the native Solaris <tt>ld</tt>.
	The most straightforward way to do this is to build and install
	binutils, and then reference it in the configure for gcc
	via <tt>--with-ld=/path_to_binutils_install/bin/ld</tt>
	(<tt>--with-as</tt> may also be similarly
	specified but is not believed to be required).
d776 33
a808 12
	Please note, gcc/gcj must be built using GNU ld prior to doing
	a clean build of libgcj!
	</dd>
      </p>
    </dl>

<table border="0" cellpadding="4" width="95%">
<tr bgcolor="#b0d0ff">
 <th align="left">
 <A NAME="3_0"><h2>Gcj Compile/Link Questions</h2></A>
 </th>
</tr>
a809 43
    <dl>

      <dt><h3><a name="3_1">3.1 Why do I get <tt>undefined reference to `main'</tt> errors?</a></h3></dt>
      <p>
      <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>
      </p>
    </dl>

<table border="0" cellpadding="4" width="95%">
<tr bgcolor="#b0d0ff">
 <th align="left">
 <A NAME="4_0"><h2>Runtime Questions</h2></A>
 </th>
</tr>
</table>
    <dl>

      <dt><h3><a name="4_1">4.1 My program is dumping core!  What's going on?</a></h3></dt>
      <p>
      <dd>I 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 libgcj.zip.</dd>
      </p>

      <dt><hr><h3><a name="4_2">4.2 When I run the debugger I get a SEGV in the GC! What's going on?</a></h3></dt>
      <p>
      <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>
      </p>
    </dl>

<br>
</td></tr>
</table>

d811 3
d815 1
a815 10
<address>
<a href="about.html">The GCJ team</a>
<br>
<small>
$Id: faq.html,v 1.6 1999/10/25 07:30:12 warrenl Exp $
</small>
</address>

</body>
</html>
@


1.26
log
@2000-06-27  Alexandre Petit-Bianco  <apbianco@@cygnus.com>

        * done.html: New file.
        * about.html: Added link to the `Done with Gcj' page.
        * contrib.html: Likewise.
        * docs.html: Likewise.
        * download.html: Likewise.
        * faq-portugese.html: Likewise.
        * faq.html: Likewise.
        * index.html: Likewise. Added new `GCJ News' item.
        * mail.html: Added link to the `Done with Gcj' page.
        * projects.html: Likewise.
        * support.html: Likewise.
        * thanks.html: Likewise.
        * tm.html: Likewise.

(Add a `Done with gcj' section.)
@
text
@d2 6
a7 5
<head>
<title>The GCJ FAQ</title>
</head>
<!--#include virtual="/include/header-subpages.html"-->
<body bgcolor="#FFFFFF">
d9 140
a148 463
  <tr>
    <td valign="top"> 
      <table border=0>
        <tr>
          <td> <img src="gcj.jpg" alt="gcj logo" width=136 height=98> </td>
        </tr>
        <tr> 
          <td> <br>
            <table border=0>
              <tr>
                <td width="10"></td>
                <td> <a href="index.html">Home</a><br>
                  <a href="faq.html">FAQ</a><br>
                  <a href="mail.html">Mailing Lists</a><br>
                  <a href="docs.html">Documentation</a><br>
                  <a href="download.html">Download</a><br>
                  <a href="contrib.html">Contributing</a><br>
		  <a href="done.html">Done with Gcj</A><br>
                  <a href="http://sourceware.cygnus.com/cgi-bin/gnatsweb.pl?user=guest&password=guest&database=java&cmd=login">Bugs</a><br>
                  <a href="thanks.html">Thanks</a><br>
                  <!-- <a href="support.html">Support</a><br> --> <br>
                  <br>
                  <br>
                  <a href="http://gcc.gnu.org">GCC</a><br>
                  <a href="http://sourceware.cygnus.com/mauve">The Mauve Project</a><br>
                  <a href="http://sourceware.cygnus.com">Sourceware</a><br>
                  <a href="http://www.gnu.org">The GNU Project</a><br>
                  <a href="http://www.redhat.com">Red Hat</a><br>
                </td>
              </tr>
            </table>
          </td>
        </tr>
      </table>
    </td>
    <td width=2 bgcolor="black"> i </td>
    <td width=6> </td>
    <td> <br>
      <br>
      <h1>The GCJ FAQ</h1>
      <p>The latest version of this document is always available at <a href="faq.html">http://sourceware.cygnus.com/java/faq.html</a>.</p>
      <p>This FAQ is also available in <a href="faq-portugese.html">Brazilian Portugese</a>.</p>
      <ol>
        <li><a href="#1_0">General Questions</a> 
          <ol>
            <li><a href="#1_1">What license is used for libgcj?</a> 
            <li><a href="#1_2">How can I report a bug in libgcj?</a> 
            <li><a href="#1_3">How can I contribute to libgcj?</a> 
            <li><a href="#1_4">Why isn't libgcj part of GCC?</a> 
            <li><a href="#1_5">Will gcj and libgcj work on my machine?</a> 
            <li><a href="#1_6">How can I debug my Java program?</a> 
            <li><a href="#1_7">Can I interface byte-compiled and native java code?</a>
          </ol>
        <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 OpenSource 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><a href="#3_0">Build Issues</a> 
          <ol>
            <li><a href="#3_1">I need something more recent than the last release; how
                  should I build it?</a>
            <li><a href="#3_2">Linker bug on Solaris</a> 
            <li><a href="#3_3">Can I configure/build in the source tree?</a> 
	    <li><a href="#3_4">My libgcj build fails with "invalid use of undefined type struct sigcontext_struct"</a>
          </ol>
        <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><a href="#4_2">Can GCJ only handle source code? </a> 
            <li><a href="#4_3">&quot;gcj -C" Doesnt seem to work like javac/jikes. 
              Whats going on? </a> 
            <li><a href="#4_4">Where does GCJ look for files? </a> 
            <li><a href="#4_5">How does gcj resolve wether to compile .class or 
              .java files? </a> 
            <li><a href="#4_6">I'm getting link errors!</a> 
            <li><a href="#4_7">I'm getting 'gcj: libgcj.spec: No such file or directory'</a>	    
          </ol>
        <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><a href="#5_2">When I run the debugger I get a SEGV in the GC! 
              What's going on?</a> 
            <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><a href="#5_4">Can I profile Garbage Collection? </a> 
            <li><a href="#5_5">How do I increase the runtime's initial and maximum 
              heap sizes?</a> 
            <li><a href="#5_6">How can I profile my application?</a> 
	    <li><a href="#5_7">I'm getting 'undefined symbol: __dso_handle'</a>
          </ol>
        <li><a href="#6_0">Programing Issues</a> 
          <ol>
            <li><a href="#6_1">Are there any examples of how to use CNI?</a></li>
          </ol>
        </li>
      </ol>
      <table border="0" cellpadding="4" width="95%">
        <tr bgcolor="#b0d0ff"> 
          <th align="left"> 
            <h2><a name="1_0">General Questions</a></h2>
          </th>
        </tr>
      </table>
      <br>
      <dl> 
        <dt> 
          <h3><a name="1_1">1.1 What license is used for libgcj?</a></h3>
        </dt>
        <p> 
        <dd>
          libgcj is distributed under the GPL, with the 'libgcc exception'.
          This means that if 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>
        <p></p>
        <dt> 
          <hr>
          <h3><a name="1_2">1.2 How can I report a bug in libgcj?</a></h3>
        </dt>
        <p> 
        <dd>libgcj has a corresponding <a
      href="http://sourceware.cygnus.com/cgi-bin/gnatsweb.pl?user=guest&password=guest&database=java&cmd=login">Gnats 
          bug database</a> which you can browse. You can also submit new bug reports 
          from the Gnats page.</dd>
        <p></p>
        <dt> 
          <hr>
          <h3><a name="1_3">1.3 How can I contribute to libgcj?</a></h3>
        </dt>
        <p> 
        <dd>You can send simple bug fixes in as patches. Please follow the <a href="http://gcc.gnu.org/contribute.html">GCC 
          guidelines for submitting patches</a>. For more complex changes, you 
          must sign copyright over to the Free Software Foundation. See the <a href="contrib.html">contribution</a> 
          page for details.</dd>
        <p></p>
        <dt> 
          <hr>
          <h3><a name="1_4">1.4 Why isn't libgcj part of GCC?</a></h3>
        </dt>
        <p> 
        <dd>Various minor reasons. It's likely that libgcj will end up in GCC 
          at some point in the future.</dd>
        <p></p>
        <dt> 
          <hr>
          <h3><a name="1_5">1.5 Will gcj and libgcj work on my machine?</a></h3>
        </dt>
        <p> 
        <dd>Gcj and libgcj are known to work more or less with IA-32 and 
          Sparc Solaris, as well as IA-32, Alpha, and PowerPC Linux. 
	  They might work on other systems, but we don't know. 
          Generally speaking, porting to a new system should not be hard. This 
          would be a good way to volunteer.</dd>
        <p></p>
        <dt> 
          <hr>
          <h3><a name="1_6">1.6 How can I debug my Java program?</a></h3>
        </dt>
        <p> 
        <dd><a href="ftp://ftp.gnu.org/pub/gnu/gdb/gdb-4.18.tar.gz">gdb 4.18</a> 
          includes support for debugging gcj-compiled Java programs. For linux, 
          you will need to use a recent development snapshot of gdb from 
	  <a href="ftp://sourceware.cygnus.com/pub/gdb/snapshots/">ftp://sourceware.cygnus.com/pub/gdb/snapshots/</a> 
	  , or the gdb included with Redhat 6.1 and newwer. 
	  The standard 4.18 does not have support for linux threads. 
	  For more information please read 
	  <a href="gdb.html">Java Debugging with gdb</a>.</dd>
        <dt>&nbsp; </dt>

        <dt> 
          <hr>
          <h3><a name="1_7">1.7 Can I interface byte-compiled and native java code</a></h3>
        </dt>
        <p> 
        <dd>
	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. Currently this only works on x86 linux. 
        <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:
<pre>
$ gcj -shared -o HelloWorld.so HelloWorld.java
$ gij HelloWorld
</pre>
          This works because gij uses Class.forName, which now knows how to load shared objects.
        </dd>
        <dt>&nbsp; </dt>	
      </dl>
      <table border="0" cellpadding="4" width="95%">
        <tr bgcolor="#B0D0FF"> 
          <th align="left"> 
            <h2><a name="2_0">Java Feature Support</a></h2>
          </th>
        </tr>
      </table>
      <dl> 
      </dl>
      <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:</dd>
        <dl> 
          <dd>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. </dd>
          <dt>&nbsp;</dt>
          <dd>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 &quot;write once, run everywhere&quot; 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. </dd>
          <dt>&nbsp;</dt>
          <dd>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! </dd>
        </dl>
        <dt>&nbsp;</dt>
       </dl>
        </dl>
        <hr>
        <h3><a name="2_2">2.2 </a>Does GCJ support using straight C native methods 
          ala JNI? </h3>
        <blockquote> 
	  <p>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.
        </blockquote>
        <hr>
        <h3><a name="2_3">2.3 </a>Why does GCJ use CNI? </h3>
        <blockquote> 
          <p><a href="mailto:per@@bothner.com">Per Bothner</a> explains </p>
          <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>
        </blockquote>
        <hr>
      </dl>
      <h3><a name="2_4">2.4 What is the state of AWT support</a>?</h3>
      <dl> 
        <dd> No support is currently in place for AWT. Prior Art which could be 
          used for this all require JNI. Possible starting points follow: 
          <dl> </dl>
          <p>QtAWT</p>
          <blockquote> 
            <p>QtAWT ( )provides a Qt based implementation of the peer classes 
              used by the AWT components. This consists of a set of Java classes 
              that implement the interfaces specified in java.awt.peer, and a 
              few others such as java.awt.Toolkit. The classes are implemented 
              in a mixture of Java code and native code, with the native methods 
              being called via the JNI. Because it sticks to standard APIs such 
              as the JNI QtAWT should be portable enough to work on any 1.1 JVM. 
              Once the class and library paths have been set up correctly, the 
              QtAWT can be used instead of the native peers provided with your 
              JVM by setting the awt.toolkit property to point to the QtToolkit 
              implementation. </p>
          </blockquote>
        </dd>
        <dl> 
          <dt>&nbsp;</dt>
          <dd><a href="http://developer.kde.org/language-bindings/java/qtawt/developer.html">http://developer.kde.org/language-bindings/java/qtawt/developer.html</a></dd>
          <dt>&nbsp;</dt>
          <dt>GTK AWT</dt>
          <dd>Some Mozilla / Blackdown project mambers are having a go at this 
            (free login required):</dd>
          <dd><a href="http://developer.java.sun.com/developer/restricted/java2cs/contribs/">http://developer.java.sun.com/developer/restricted/java2cs/contribs/</a></dd>
          <dt>&nbsp;</dt>
          <dd>The Classpath project is doing AWT with GTK peers, and they're looking 
            for someone who wants to make Classpath work with Kaffe ... <a href="http://www.gnu.org/software/classpath/">http://www.gnu.org/software/classpath/</a></dd>
          <dt>&nbsp;</dt>
        </dl>
        <dl> 
          <dt><a href="http://www.kaffe.org/">Kaffe</a> AWT</dt>
          <dd>Kaffe has a JNI based AWT implementation using lightweight peers. 
            Work is currently in progress to implement using GTK.</dd>
        </dl>
      </dl>
      <hr>
      <h3><a name="2_5">2.5 How about support for Swing</a>?</h3>
      <dl> 
        <dl> 
          <dt>Considering that AWT support isnt here yet there is no chance of 
            getting Swing running. Once we have AWT support the Swing 1.1.1 may 
            be useable and even redistributable, but JFC will be another issue, 
            as <a href="mailto:moroz@@metahood.ru">Oleg Moroz</a> summarises: 
            <blockquote> 
              <p>1) Swing 1.1.1 for JDK 1.1.x with license that allows to redistribute 
                it as part of the value-added applet or application. This needs 
                some research, however I feel that the term "value-added application" 
                might include e.g. gcj-based development system; if it is not 
                by itself, a simple Swing-based application might be added to 
                the distribution). This version depends on AWT 1.1 only (well, 
                1.1.x, x >=7) and it seems that the Sun's version could be used 
                for most purposes people would like to use it. </p>
            </blockquote>
          </dt>
          <blockquote> 
            <p>2) Swing (JFC) that is part of Java2. This is AFAIK not available 
              as separate product and is covered by more restrictive (in this 
              case at least) JDK license; it is also dependent on AWT 1.2 features. 
              We'd want to develop a replacement only when we move to the 1.2 
              codebase and then we'll also need to develop AWT 1.2 replacement 
              w/o regard to Swing.</p>
          </blockquote>
        </dl>
        <dl> 
          <dt><a href="mailto:per@@bothner.com">Per Bothner</a> expands:</dt>
          <dd>&nbsp;</dd>
          <dd>One possibility worth considering is developing Swing components 
            in conjunction with AWT. We can implement JTextArea and TextArea at 
            the same time. We could also implement both on top of (say) some Gtk 
            widget; we don't necessarily *have* to go the "peerless" route. Instead, 
            we can base the "plugable look-and-feel" on the "themebility" of (say) 
            Gtk. </dd>
          <dt>&nbsp;</dt>
          <dd>A bigger potential issue is Swing's separation between &quot;model&quot; 
            (e.g. Document) and &quot;view&quot; (e.g. JTextPane). It may be difficult 
            to make use of the functionality of an existing toolkit such as Gtk 
            unless we can use Gtk widgets with separate &quot;model&quot; objects.</dd>
        </dl>
        <dt>&nbsp; </dt>
        <hr>
      </dl>
      <h3><a name="2_6">2.6 </a>What support is there for RMI?</h3>
      <dl> 
        <dd> There is no RMI support at the moment. <a href="mailto:mdw@@cs.berkeley.edu">Matt 
          Welsh</a> elaborates:</dd>
        <dt> 
          <dl> 
            <dd>I was working on this, but it's on the back-burner right now. 
              So, if anyone would like to help out I would appreciate it. I have 
              a free implementation of RMI (&quot;NinjaRMI&quot;) that is quite 
              similar to Sun's RMI. You can download it from <a href="http://www.cs.berkeley.edu/%7Emdw/proj/ninja">http://www.cs.berkeley.edu/~mdw/proj/ninja</a></dd>
          </dl>
        </dt>
        <dd><a href="http://www.cs.berkeley.edu/%7Emdw/proj/ninja"></a></dd>
      </dl>
      <blockquote> 
        <blockquote> 
          <p>Note that this is NOT Java RMI per se; it is just very similar in 
            functionality and design. You might want to steal some classes out 
            of it to get RMI support in libgcj. However, it does require some 
            classes in java.* and sun.* which are not part of libgcj.</p>
        </blockquote>
        <p>It may be possible to use the JavaParty's <a href="http://wwwipd.ira.uka.de/%7Ehauma/EfficientRMI/">RMI 
          implementation</a>, but the licensing is much more restrictive than 
          that of NinjaRMI. Details below:</p>
        <blockquote> 
          <p>The much faster drop-in RMI and the appropriate efficient serialization 
            is designed and implemented completely in Java without any native 
            code. Moreover, the re-designed RMI supports non-TCP/IP communication 
            networks, even with heterogeneous transport protocols. As a by-product, 
            there is a benchmark collection for RMI. </p>
        </blockquote>
      </blockquote>
      <p></p>
      <dl> 
        <dt>&nbsp; </dt>
        <hr>
      </dl>
      <dl> 
        <dt> 
          <h3><a name="2_7">2.7 Can I use any code from other OpenSource
            projects to supplement libgcj's current features?</a></h3>
        </dt>
	<dd>
	<p> Certainly. 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) 
	<A HREF="http://www.gnu.org/software/gcc/fsf-forms/assignment-instructions.html">
	assign copyright</A> to the Free Software Foundation.  
	<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.classpath.org">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-discuss@@sourceware.cygnus.com">let us know</A>!
      </dl>

      <hr>

      <dl> 
        <dt> 
          <h3><a name="2_8">2.8 What features of the Java language are/aren't supported.</a></h3>
        </dt>
        <dd>GCJ supports all Java language constructs as per the 
          <a href="http://java.sun.com/docs/books/jls/">Java language Specification 
          v1.0</a>. Recent GCJ snapshots have added support for most JDK1.1 
	  language features, including inner classes.
      </dl>
      <dl> 
        <p></p>
      </dl>
      <table border="0" cellpadding="4" width="95%">
        <tr bgcolor="#b0d0ff"> 
          <th align="left"> 
            <h2><a name="3_0">Build Issues</a></h2>
          </th>
        </tr>
      </table>

      <dl> 
        <dt> 
          <h3><a name="3_1">3.1 I need something more recent than the last release; how should I build it?</a></h3>
        </dt>
        <p> 
        <dd>Please read <a href="build-snapshot.html">here</a>.
        </dd>
        <p></p>
      </dl>

      <hr>

      <dl> 
        <dt> 
          <h3><a name="3_2">3.2 Linker bug on Solaris</a></h3>
        </dt>
        <p> 
        <dd>There is a known problem with the <a href="http://gcc.gnu.org/ml/gcc-bugs/1999-10/msg00159.html"> 
          native Solaris linker</a> when using gcc/gcj. A good indication you've 
          run into this problem is if you get an error that looks like the following 
          when building libgcj: 
          <pre>
d154 10
a163 299
          A known workaround for this and other reported link problems on the 
          various releases of Solaris is to build gcc/gcj with the <a href="ftp://sourceware.cygnus.com/pub/binutils/snapshots"> 
          latest GNU binutils</a> instead of the native Solaris <tt>ld</tt>. The 
          most straightforward way to do this is to build and install binutils, 
          and then reference it in the configure for gcc via <tt>--with-ld=/path_to_binutils_install/bin/ld</tt> 
          (<tt>--with-as</tt> may also be similarly specified but is not believed 
          to be required). 
          <p> Please note, gcc/gcj must be built using GNU ld prior to doing a 
            clean build of libgcj! 
        </dd>
        <p></p>
      </dl>

      <hr>

      <dl> 
        <dt> 
          <h3><a name="3_3">3.3 Can I configure/build in the source tree?</a></h3>
        </dt>
        <p> 
        <dd>No.  You cannot configure/build in the source tree.  If you try,
	you'll see something like:
	<pre>
$ ./configure [...]
Configuring for a i686-pc-linux-gnu host.
*** Cannot currently configure in source tree.
	</pre>
	Instead, you must build in another directory.  E.g.:
	<pre>
$ mkdir build
$ cd build
$ ../configure [...]
	</pre>
        </dd>
        <p></p>
      </dl>
      
      <hr>

      <dl> 
        <dt> 
          <h3><a name="3_4">3.4 My libgcj build fails with "invalid use of undefined type struct sigcontext_struct"</a></h3>
        </dt>
        <p> 
	<dd>If you're using Linux, this probibly means you need to upgrade to
	a newwer, glibc (libc6) based Linux distribution. libgcj does not 
	support the older linux libc5.
	<p>It might be possible to get a working libgcj by changing occurances
	of "sigcontext_struct" to "sigcontext", however this has not been tested.
	Even if it works, it is likely that there are other issues with older
	libc versions that would prevent libgcj from working correctly (threads
	bugs, for example).
        </dd>
      </dl>


      <table border="0" cellpadding="4" width="95%">
        <tr bgcolor="#b0d0ff"> 
          <th align="left"> 
            <h2><a name="4_0">Gcj Compile/Link Questions</a></h2>
          </th>
        </tr>
      </table>
      <dl> 
        <dt> 
          <h3><a name="4_1">4.1 Why do I get <tt>undefined reference to `main'</tt> 
            errors?</a></h3>
        </dt>
      </dl>
      <p> 
      <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>
        <dt>&nbsp;</dt>
        <hr>
      </dl>
      <dl> 
        <dt> 
          <h3><a name="4_2">4.2 Can GCJ only handle source code?</a></h3>
        </dt>
      </dl>
      <p> 
      <dl> 
        <dd>The GCJ compiler will compile both java source and bytecode .class 
          files. For the moment support for compiling bytecodes will support more 
          applications than compiling from source, as the source code compiler 
          has some bugs in its support for inner classes, which are used heavily 
	  in programs written for the JDK 1.1 (AWT in particular). 
          <p>In many cases the native code produced by compiling from source is 
            better optimised than that compiled from .class files. Per Bothner 
            explains:</p>
        </dd>
        <dt> 
          <dl> 
            <dd>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>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>
            </dd>
          </dl>
        </dt>
        <hr>
        <dt><font color="#FF3300"></font></dt>
        <dt> 
          <h3><a name="4_3">4.3 &quot;gcj -C"</a> Doesnt seem to work like javac/jikes. 
            Whats going on?</h3>
        </dt>
        <blockquote> 
          <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>
        </blockquote>
      </dl>
      <hr>

      <dl> 
        <dt> 
          <h3><a name="4_4">4.4 Where does GCJ look for files?</a></h3>
        </dt>
        <blockquote> 
          <p>GCJ looks for classes to compile based on the CLASSPATH environment 
            variable. An important limitation presently is that gcj doesn't handle 
            compressed jar files in your classpath. </p>
        </blockquote>
      </dl>
      <hr>

      <dl> 
        <dt> 
          <h3><a name="4_5">4.5 How does gcj resolve whether to compile .class 
            or .java files?</a></h3>
        </dt>
        <blockquote> 
          <p>GCJ seems to favor .class files in the CLASSPATH, if any, otherwise 
            it will use the source (.java), also in the CLASSPATH. It also checks 
            to see if the class is newer than the .java file. If it can't find 
            either it throws an error.</p>
        </blockquote>
      </dl>
      
      <hr>
      
      <dl>
        <dt>
          <h3><a name="4_6">4.6 I'm getting link errors</a></h3>
        </dt>
        <blockquote>
        <p>If you get errors at link time that refer to
          'undefined reference to `java::lang::Object type_info function',
          verify that you have compiled any CNI C++ files with the
          -fno_rtti option.
        </blockquote>
      </dl>
      
      <hr>
      
      <dl>
	<dt>
          <h3><a name="4_7">4.7 I'm getting 'gcj: libgcj.spec: No such file or directory'</a></h3>
	</dt>
	<blockquote>
	<p>Make sure you configure both libgcj and gcj with the 
	same "--prefix" directory.
	</blockquote>
      </dl>   
            
      <dl> 
        <dt>&nbsp; </dt>
      </dl>
      <dl> 
        <p></p>
      </dl>
      <table border="0" cellpadding="4" width="95%">
        <tr bgcolor="#B0D0FF"> 
          <th align="left"> 
            <h2><a name="5_0">Runtime Questions</a></h2>
          </th>
        </tr>
      </table>
      <dl> 
        <dt> 
          <h3><a name="5_1">5.1 My program is dumping core! What's going on?</a></h3>
        </dt>
        <p> 
        <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 libgcj.zip.</dd>
	  <p> An other symptom covered by this fix is a running
          "<tt>Hello World</tt>" type program, with a lot of non printable
	  ASCII garbage before and/or after the output.
        <dd></dd>
      </dl>
      <p></p>
      <dl> 
        <dt> 
          <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>
        </dt>
      </dl>
      <p> 
      <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. 
          <p>This shouln't happen anymore, as we dont define MPROTECT_VDB in the 
            GC, at least for Linux/386.</p>
        </dd>
      </dl>
      <p></p>
      <dl> 
        <dt> 
          <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>
        </dt>
      </dl>
      <p> 
      <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 you're code is ready, and it doesn't rely on them, 
              try compiling with --no-bounds-check. </li>
            <li>Try static linking. The interaction with boehm-gc seems to incur 
              extra overhead when shared libraries are used. On one program that 
              makes heavy use of the allocator I achieved over 30% runtime performance 
              gain with static linking. This issue may disappear soon with a new 
              version of the GC.</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>
      <p></p>
      <p> 
      <dl> 
      <hr>
        <dt> 
          <h3><a name="5_4">5.4 Can I profile Garbage Collection?</a></h3>
        </dt>
        <dd>It is possible to turn on verbose GC output by supressing 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. 
        </dd>
        <dt>&nbsp;</dt>
        <dd>The GC will print collection statistics to stdout. (Rebuilding boehm-gc 
          alone without this flag doesn't seem to work.)</dd>
        <dt>&nbsp;</dt>
        <hr>
        <dt> 
          <h3><a name="5_5">5.5 How do I increase the runtime's initial and maximum 
            heap sizes?</a></h3>
        </dt>
        <dd>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.</dd>
      </dl>
      <hr>
      <dl> 
        <dt> 
          <h3><a name="5_6">5.6 How can I profile my application?</a></h3>
        </dt>
        <dd>Support for this is currently lagging. Only single threaded Java code 
          may be used by the profiler (gprof). POSIX threads seem to be incompatible 
          with the gmon stuff.</dd>
        <dt>&nbsp;</dt>
      </dl>
      
      <hr>

      <dl>
	<dt>
          <h3><a name="5_7">5.7 I'm getting 'undefined symbol: __dso_handle'</a></h3>
	</dt>
	<blockquote>
	<p>Some versions of the GNU linker have broken support for the '.hidden'
	directive, which results in problems with shared libraries built with
	recent versions of gcc.	
d165 12
a176 33
	There are three solutions:
	<ul>
	  <li>downgrade to binutils that don't support .hidden at all,
	  <li>upgrade to a recent CVS binutils, or
	  <li>undef the HAVE_GAS_HIDDEN definition in gcc's auto-host.h
	  (and rebuild gcc).
	</sl>
	</blockquote>
      </dl>      
      
      <p> 
      <table width="100%" border="0">
        <tr bgcolor="#B0D0FF" align="left"> 
          <th> 
            <h2><a name="6_0"></a>Programing Issues </h2>
          </th>
        </tr>
      </table>
      <h3><a name="6_1"></a>6.1 Are there any examples of how to use CNI?</h3>
      <blockquote> 
        <p>Glenn Chambers has created a couple 
          of trivial examples <a href="cni-1.txt">here</a> and <a href="cni-2.txt">here</a>. 
        As a comparision, <a href="jni-kaffe.txt">here</a>
        is the same example as a JNI application.
        </p>
        <p>
        Note that you must compile the C++ files used for CNI with the
        -fno-rtti option.
        </p>
        <p>The primary source of documentation for CNI is at <a href="papers/cni/t1.html">http://sourceware.cygnus.com/java/papers/cni/t1.html</a></p>
      </blockquote>
    </td>
  </tr>
d178 43
a221 3
<address> <a href="about.html">The GCJ team</a> <br>
<small> $Id: faq.html,v 1.25 2000/06/21 21:05:38 tromey Exp $ </small></address>
<h2 align=center>&nbsp;</h2>
d223 10
a232 1
    <!--#include virtual="/include/footer-subpages.html"-->
@


1.25
log
@	* faq.html: Typo.
@
text
@d25 1
d812 1
a812 1
<small> $Id: faq.html,v 1.24 2000/06/07 08:37:32 bryce Exp $ </small></address>
@


1.24
log
@2000-06-07  Bryce McKinlay  <bryce@@albatross.co.nz>

	* faq.html (3.4): New Answer.
	(2.7): Updated.
	(4.2): Clarify inner class support.
@
text
@d668 1
a668 1
        <dd>I could be any number of things. One common mistake is having your 
d811 1
a811 1
<small> $Id: faq.html,v 1.23 2000/06/06 02:23:46 bryce Exp $ </small></address>
@


1.23
log
@2000-06-06  Bryce McKinlay  <bryce@@albatross.co.nz>

	* faq.html (5.7: I'm getting 'undefined symbol: __dso_handle'):
	New answer.
@
text
@d80 1
d93 1
a93 1
            <li><a href="#4_7">I'm getting 'gcj: libgcj.spec: No such file or directory'</a> 
d406 18
a423 8
        <dd> <font color="#FF6600">Can someone point me to some difinitive words 
          on this issue</font> </dd>
      </dl>
      <blockquote> 
        <blockquote>&nbsp;</blockquote>
      </blockquote>
      <dl> 
        <hr>
d425 3
d511 19
d563 2
a564 2
          lacks support for inner classes, which are used heavily in programs 
          written for the JDK 1.1 (AWT in particular). 
d811 1
a811 1
<small> $Id: faq.html,v 1.22 2000/04/23 05:00:31 green Exp $ </small></address>
@


1.22
log
@Mention Red Hat.  Add projects page.
@
text
@d106 1
d616 1
d730 22
d778 1
a778 1
<small> $Id: faq.html,v 1.21 2000/03/29 21:02:15 tromey Exp $ </small></address>
@


1.21
log
@2000-03-29	Glenn Chambers <gchambers@@provsol.com>

	* faq.html: Update license text for new GPL+libgcc-exception
	fix spello.
@
text
@d34 1
a34 1
                  <a href="http://www.cygnus.com">Cygnus Solutions</a><br>
d150 1
a150 1
          must sign copyright over to Cygnus. See the <a href="contrib.html">contribution</a> 
d754 1
a754 1
<small> $Id: faq.html,v 1.20 2000/03/27 20:23:21 tromey Exp $ </small></address>
@


1.20
log
@2000-03-27  Glenn Chambers <gchambers@@provsol.com>

	* faq.html: Remove bogus '-c' from gij shared library
	example
@
text
@d126 6
a131 1
        <dd>libgcj is distributed under the Library GPL.</dd>
d328 1
a328 1
                might inlcude e.g. gcj-based development system; if it is not 
d754 1
a754 1
<small> $Id: faq.html,v 1.19 2000/03/15 05:16:52 bryce Exp $ </small></address>
@


1.19
log
@FAQ Update.
@
text
@d199 1
a199 1
$ gcj -shared -c -o HelloWorld.so HelloWorld.java
d749 1
a749 1
<small> $Id: faq.html,v 1.18 2000/03/13 17:23:06 tromey Exp $ </small></address>
@


1.18
log
@	* Many files: Updated gcc URL.
@
text
@d58 1
d92 1
d181 24
d379 1
a379 1
          implementation</a>, but the lisencing is much more restrictive than 
d412 1
a412 1
        <dd>At the moment GCJ supports all Java language constructs as per the 
d414 2
a415 3
          v1.0</a>. The JDK1.1 added support for Inner Classes, which aren't yet 
          supported when compiling from source code, but can be used when compiling 
          from bytecode. see <i>4.2 Can GCJ only handle source code?</i> </dd>
d598 12
d749 1
a749 1
<small> $Id: faq.html,v 1.17 2000/03/09 20:10:41 warrenl Exp $ </small></address>
@


1.17
log
@	* faq.html (3_3 Can I configure/build in the source tree?): Cleaned
	up typos and used clearer wording.
@
text
@d30 1
a30 1
                  <a href="http://egcs.cygnus.com">GCC</a><br>
d141 1
a141 1
        <dd>You can send simple bug fixes in as patches. Please follow the <a href="http://egcs.cygnus.com/contribute.html">GCC 
d420 1
a420 1
        <dd>There is a known problem with the <a href="http://egcs.cygnus.com/ml/gcc-bugs/1999-10/msg00159.html"> 
d712 1
a712 1
<small> $Id: faq.html,v 1.16 2000/03/09 11:54:27 warrenl Exp $ </small></address>
@


1.16
log
@	* faq.html (3_3 Can I configure/build in the source tree?): Added.
@
text
@d453 1
a453 1
$ ./configure
d457 1
a457 1
	Instead, must do something like:
d459 3
a461 3
mkdir build
cd build
../configure --enable-threads=posix --enable-java-gc=boehm [...]
d712 1
a712 1
<small> $Id: faq.html,v 1.15 2000/03/03 05:12:26 bryce Exp $ </small></address>
@


1.15
log
@2000-03-03  Bryce McKinlay  <bryce@@albatross.co.nz>

        * faq.html: Fix some formatting issues.
@
text
@d78 1
d442 25
d712 1
a712 1
<small> $Id: faq.html,v 1.14 2000/03/03 04:56:29 bryce Exp $ </small></address>
@


1.14
log
@2000-03-03  Bryce McKinlay  <bryce@@albatross.co.nz>

        * faq.html: Update JNI information. Link to gdb.html.
        * FAQ.html: Remove obsolete FAQ, meta-refresh to faq.html.
        * gdb.html: Add <html>,<body>,<title> tags, etc. Mention that
        .gdbinit' can be in $HOME.
        * doc.html: Add link to gdb.html.
@
text
@a186 1
        <dd>&nbsp; </dd>
a309 1
            <p>&nbsp;</p>
d327 1
d412 2
a448 1
        <dt>&nbsp; </dt>
a463 1
        <dt>&nbsp; </dt>
a492 1
            <dt>&nbsp;</dt>
a495 1
        <dt>&nbsp;</dt>
d508 1
a508 3
      <dl> 
        <dt>&nbsp; </dt>
      </dl>
d520 1
a520 3
      <dl> 
        <dt>&nbsp; </dt>
      </dl>
d533 3
a535 3
      <dl>
        <dt>&nbsp; </dt>
      </dl>
a590 1
        <dt>&nbsp;</dt>
d627 1
a627 5
        <dd>&nbsp;</dd>
      </dl>
      <dl> 
        <hr>
        <dt>&nbsp;</dt>
a639 1
        <dt>&nbsp;</dt>
d686 1
a686 1
<small> $Id: faq.html,v 1.13 2000/02/18 18:31:16 tromey Exp $ </small></address>
@


1.13
log
@	* faq.html: Typos.
@
text
@d64 1
a64 1
              ala JNI? CNI looks kind of hard to use.</a></li>
d171 6
a176 2
          you will need to use a recent development snapshot of gdb from <a href="ftp://sourceware.cygnus.com/pub/gdb/snapshots/">ftp://sourceware.cygnus.com/pub/gdb/snapshots/</a> because 
          the standard 4.18 does not have support for linux threads.</dd>
d218 1
a218 1
          ala JNI? CNI looks kind of hard to use.</h3>
d220 5
a224 4
          <p>Currently gcj does not support JNI, but this may change in the future. 
          </p>
          <p><a href="mailto:per@@bothner.com">Per Bothner</a> explains the future 
            of these native interfaces:</p>
a225 24
        <dl> 
          <blockquote> 
            <blockquote> 
              <p>(1) It is a goal that Gcj should support JNI as well as CNI. 
                Doing so is not in principle difficult, especially dealing with 
                JNI-using libraries that are known at link-time (since you can 
                just generate CNI wrapper functions that call the corresponding 
                JNI methods). However, there is still a for bit of tedious work 
                needed for JNI. </p>
              <p>(2) We do prefer CNI, as it is more efficient, easier to write, 
                and (at least potentially) easier to debug. </p>
              <p>(3) You could in principle write C++ code that implements both 
                a CNI and JNI interface, using the magic of pre-processing. The 
                question is whether we can do it in a way such that it would not 
                be simpler and cleaner to just maintain two copies of the code. 
                We don't know yet. </p>
            </blockquote>
          </blockquote>
          <dt> 
            <dl> 
              <dd></dd>
            </dl>
          </dt>
        </dl>
d521 1
a521 1
            compressed jar files in your classpath </p>
d692 1
a692 1
        <p>The primary source of documentation for CNI is at <a href="http://sourceware.cygnus.com/java/papers/cni/t1.html">http://sourceware.cygnus.com/java/papers/cni/t1.html</a></p>
d699 1
a699 1
<small> $Id: faq.html,v 1.12 2000/02/17 07:57:12 green Exp $ </small></address>
@


1.12
log
@minor tweaks
@
text
@d595 1
a595 1
	  <p> An other symtom covered by this fix is a running
d597 1
a597 1
	  ASCII garbage before and/or after the output. YMMW.
d718 1
a718 1
<small> $Id: faq.html,v 1.11 2000/02/09 01:03:58 apbianco Exp $ </small></address>
@


1.11
log
@Tue Feb  8 17:00:56 2000  Alexandre Petit-Bianco  <apbianco@@cygnus.com>

	* faq.html: Added symptom to the section 5.1
@
text
@d48 1
d718 1
a718 1
<small> $Id: faq.html,v 1.10 2000/01/16 02:08:50 tromey Exp $ </small></address>
@


1.10
log
@2000-01-06  Glenn Chambers <gchambers@@provsol.com>

	* faq.html: Add text about -fno-rtti.
	Fix bogus close-tag left behind in my last edit.
@
text
@d594 3
d717 1
a717 1
<small> $Id: faq.html,v 1.9 2000/01/06 03:27:14 green Exp $ </small></address>
@


1.9
log
@2000-01-05  Anthony Green  <green@@cygnus.com>

	* faq.html: Add pointer to gdb snapshots.
	Reflection is supported.

2000-01-05  Joerg Brunsmann  <joerg.brusmann@@FernUni-Hagen.de>

	* build-snapshot.html: New file.
	* faq.html: Many cleanups.

Wed Dec 22 13:12:06 1999  Glenn Chambers  (gchambers@@provsol.com)

        * faq.html: Renumber section 5; fix minor typos; correct
	attribution of CNI examples; add JNI example reference.
	* cni-2.txt: Fix typo: this example is for version 2.96.
@
text
@d88 1
d558 14
d698 1
a698 1
        <p>Glenn Chambers</a> has created a couple 
d703 4
d714 1
a714 1
<small> $Id: faq.html,v 1.8 1999/12/22 17:36:43 green Exp $ </small></address>
@


1.8
log
@Bother->Bothner
@
text
@d64 5
a68 5
            <li><a href="#3_3">Why does GCJ use CNI? </a></li>
            <li><a href="#2_3">What is the state of AWT support?</a></li>
            <li><a href="#2_4">How about support for Swing ?</a></li>
            <li><a href="#2_5">What support is there for RMI ?</a></li>
            <li><a href="#2_6">Can I use any code from other OpenSource projects 
d70 1
a70 1
            <li><a href="#2_7">What features of the Java language are/arn't supported</a></li>
d72 1
a72 1
        <li><a href="#2_0">Build Issues</a> 
d74 2
d82 1
a82 1
            <li><a href="#4_2">4.2 Can GCJ only handle source code? </a> 
d86 1
a86 1
            <li><a href="#4_4">How does gcj resolve wether to compile .class or 
a87 2
            <li><a href="#4_5">How do I increase the runtime's initial and maximum 
              heap sizes? </a> 
d94 5
a98 2
            <li><a href="#5_3">Can I profile Garbage Collection? </a> 
            <li><a href="#5_4">How do I increase the runtime's initial and maximum 
d100 1
a100 1
            <li><a href="#5_5">How can I profile my application?</a> 
d156 3
a158 2
        <dd>So far gcj and libgcj have only really been tried on Sparc Solaris 
          and x86 Linux. They might work on other systems, but we don't know. 
d169 1
a169 1
          you will need to use a recent development snapshot (link) of gdb, because 
a175 1
            <h2>&nbsp;</h2>
a206 4
        <dl> 
          <dt>&nbsp;</dt>
          <dd>&nbsp;</dd>
        </dl>
d208 1
a208 15
        <dd>To date Reflection is not supported, although all the required metadata 
          is included in Class.h.</dd>
        <dl> 
          <dd> 
            <dl> 
              <dt>&nbsp; </dt>
            </dl>
          </dd>
        </dl>
        <dl> 
          <dt> 
            <dl> 
              <dd></dd>
            </dl>
          </dt>
d244 1
a244 1
        <h3><a name="2_2">2.3 </a>Why does GCJ use CNI? </h3>
d263 1
a263 1
      <h3><a name="4_4">2.4 What is the state of AWT support</a>?</h3>
d387 1
a387 1
          <h3><a name="2_7">2.7 Can I contribute code from other Free Software 
d401 1
a401 1
          <h3><a name="2_8">2.8 What features of the Java language are/arn't supported.</a></h3>
d405 1
a405 1
          v1.0</a>. The JDK1.1 added support for Inner Classes, which arent yet 
d419 1
d422 11
a432 1
          <h3><a name="3_1">3.1 Linker bug on Solaris</a></h3>
d518 1
a518 1
          <h3><a name="4_4">4.3 &quot;gcj -C"</a> Doesnt seem to work like javac/jikes. 
d547 1
a547 1
          <h3><a name="4_5">4.5 How does gcj resolve wether to compile .class 
d615 1
a615 1
              the initial and maximum heap sizes as per <i>5.3 How do I increase 
d641 1
a641 1
          <h3><a name="5_3">5.3 Can I profile Garbage Collection?</a></h3>
d654 1
a654 1
          <h3><a name="5_3">5.4 How do I increase the runtime's initial and maximum 
d666 1
a666 1
          <h3><a name="5_3">5.5 How can I profile my application?</a></h3>
d683 4
a686 5
        <p><a href="mailto:tromey@@cygnus.com">Tom Tromey</a> has created a couple 
          of simple ezamples <a href="cni-1.txt">here</a> and <a href="cni-2.txt">here</a>. 
        </p>
        <p>Another CNI example may be found here (thanks to Glenn Chambers!): 
          <a href="http://sourceware.cygnus.com/ml/java-discuss/1999-q3/msg00534.html">http://sourceware.cygnus.com/ml/java-discuss/1999-q3/msg00534.html</a> 
d695 1
a695 1
<small> $Id: faq.html,v 1.7 1999/12/20 01:05:31 brads Exp $ </small></address>
@


1.7
log
@added many new faq entries
@
text
@d1 703
a703 703
<html>
<head>
<title>The GCJ FAQ</title>
</head>
<!--#include virtual="/include/header-subpages.html"-->
<body bgcolor="#FFFFFF">
<table border=0>
  <tr>
    <td valign="top"> 
      <table border=0>
        <tr>
          <td> <img src="gcj.jpg" alt="gcj logo" width=136 height=98> </td>
        </tr>
        <tr> 
          <td> <br>
            <table border=0>
              <tr>
                <td width="10"></td>
                <td> <a href="index.html">Home</a><br>
                  <a href="faq.html">FAQ</a><br>
                  <a href="mail.html">Mailing Lists</a><br>
                  <a href="docs.html">Documentation</a><br>
                  <a href="download.html">Download</a><br>
                  <a href="contrib.html">Contributing</a><br>
                  <a href="http://sourceware.cygnus.com/cgi-bin/gnatsweb.pl?user=guest&password=guest&database=java&cmd=login">Bugs</a><br>
                  <a href="thanks.html">Thanks</a><br>
                  <!-- <a href="support.html">Support</a><br> --> <br>
                  <br>
                  <br>
                  <a href="http://egcs.cygnus.com">GCC</a><br>
                  <a href="http://sourceware.cygnus.com/mauve">The Mauve Project</a><br>
                  <a href="http://sourceware.cygnus.com">Sourceware</a><br>
                  <a href="http://www.gnu.org">The GNU Project</a><br>
                  <a href="http://www.cygnus.com">Cygnus Solutions</a><br>
                </td>
              </tr>
            </table>
          </td>
        </tr>
      </table>
    </td>
    <td width=2 bgcolor="black"> i </td>
    <td width=6> </td>
    <td> <br>
      <br>
      <h1>The GCJ FAQ</h1>
      <p>The latest version of this document is always available at <a href="faq.html">http://sourceware.cygnus.com/java/faq.html</a>.</p>
      <ol>
        <li><a href="#1_0">General Questions</a> 
          <ol>
            <li><a href="#1_1">What license is used for libgcj?</a> 
            <li><a href="#1_2">How can I report a bug in libgcj?</a> 
            <li><a href="#1_3">How can I contribute to libgcj?</a> 
            <li><a href="#1_4">Why isn't libgcj part of GCC?</a> 
            <li><a href="#1_5">Will gcj and libgcj work on my machine?</a> 
            <li><a href="#1_6">How can I debug my Java program?</a> 
          </ol>
        <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? CNI looks kind of hard to use.</a></li>
            <li><a href="#3_3">Why does GCJ use CNI? </a></li>
            <li><a href="#2_3">What is the state of AWT support?</a></li>
            <li><a href="#2_4">How about support for Swing ?</a></li>
            <li><a href="#2_5">What support is there for RMI ?</a></li>
            <li><a href="#2_6">Can I use any code from other OpenSource projects 
              to supplement libgcj's current features ?</a></li>
            <li><a href="#2_7">What features of the Java language are/arn't supported</a></li>
          </ol>
        <li><a href="#2_0">Build Issues</a> 
          <ol>
            <li><a href="#3_2">Linker bug on Solaris</a> 
          </ol>
        <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><a href="#4_2">4.2 Can GCJ only handle source code? </a> 
            <li><a href="#4_3">&quot;gcj -C" Doesnt seem to work like javac/jikes. 
              Whats going on? </a> 
            <li><a href="#4_4">Where does GCJ look for files? </a> 
            <li><a href="#4_4">How does gcj resolve wether to compile .class or 
              .java files? </a> 
            <li><a href="#4_5">How do I increase the runtime's initial and maximum 
              heap sizes? </a> 
          </ol>
        <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><a href="#5_2">When I run the debugger I get a SEGV in the GC! 
              What's going on?</a> 
            <li><a href="#5_3">Can I profile Garbage Collection? </a> 
            <li><a href="#5_4">How do I increase the runtime's initial and maximum 
              heap sizes?</a> 
            <li><a href="#5_5">How can I profile my application?</a> 
          </ol>
        <li><a href="#6_0">Programing Issues</a> 
          <ol>
            <li><a href="#6_1">Are there any examples of how to use CNI?</a></li>
          </ol>
        </li>
      </ol>
      <table border="0" cellpadding="4" width="95%">
        <tr bgcolor="#b0d0ff"> 
          <th align="left"> 
            <h2><a name="1_0">General Questions</a></h2>
          </th>
        </tr>
      </table>
      <br>
      <dl> 
        <dt> 
          <h3><a name="1_1">1.1 What license is used for libgcj?</a></h3>
        </dt>
        <p> 
        <dd>libgcj is distributed under the Library GPL.</dd>
        <p></p>
        <dt> 
          <hr>
          <h3><a name="1_2">1.2 How can I report a bug in libgcj?</a></h3>
        </dt>
        <p> 
        <dd>libgcj has a corresponding <a
      href="http://sourceware.cygnus.com/cgi-bin/gnatsweb.pl?user=guest&password=guest&database=java&cmd=login">Gnats 
          bug database</a> which you can browse. You can also submit new bug reports 
          from the Gnats page.</dd>
        <p></p>
        <dt> 
          <hr>
          <h3><a name="1_3">1.3 How can I contribute to libgcj?</a></h3>
        </dt>
        <p> 
        <dd>You can send simple bug fixes in as patches. Please follow the <a href="http://egcs.cygnus.com/contribute.html">GCC 
          guidelines for submitting patches</a>. For more complex changes, you 
          must sign copyright over to Cygnus. See the <a href="contrib.html">contribution</a> 
          page for details.</dd>
        <p></p>
        <dt> 
          <hr>
          <h3><a name="1_4">1.4 Why isn't libgcj part of GCC?</a></h3>
        </dt>
        <p> 
        <dd>Various minor reasons. It's likely that libgcj will end up in GCC 
          at some point in the future.</dd>
        <p></p>
        <dt> 
          <hr>
          <h3><a name="1_5">1.5 Will gcj and libgcj work on my machine?</a></h3>
        </dt>
        <p> 
        <dd>So far gcj and libgcj have only really been tried on Sparc Solaris 
          and x86 Linux. They might work on other systems, but we don't know. 
          Generally speaking, porting to a new system should not be hard. This 
          would be a good way to volunteer.</dd>
        <p></p>
        <dt> 
          <hr>
          <h3><a name="1_6">1.6 How can I debug my Java program?</a></h3>
        </dt>
        <p> 
        <dd><a href="ftp://ftp.gnu.org/pub/gnu/gdb/gdb-4.18.tar.gz">gdb 4.18</a> 
          includes support for debugging gcj-compiled Java programs. For linux, 
          you will need to use a recent development snapshot (link) of gdb, because 
          the standard 4.18 does not have support for linux threads.</dd>
        <dt>&nbsp; </dt>
      </dl>
      <table border="0" cellpadding="4" width="95%">
        <tr bgcolor="#B0D0FF"> 
          <th align="left"> 
            <h2>&nbsp;</h2>
            <h2><a name="2_0">Java Feature Support</a></h2>
          </th>
        </tr>
      </table>
      <dl> 
        <dd>&nbsp; </dd>
      </dl>
      <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:</dd>
        <dl> 
          <dd>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. </dd>
          <dt>&nbsp;</dt>
          <dd>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 &quot;write once, run everywhere&quot; 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. </dd>
          <dt>&nbsp;</dt>
          <dd>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! </dd>
        </dl>
        <dl> 
          <dt>&nbsp;</dt>
          <dd>&nbsp;</dd>
        </dl>
        <dt>&nbsp;</dt>
        <dd>To date Reflection is not supported, although all the required metadata 
          is included in Class.h.</dd>
        <dl> 
          <dd> 
            <dl> 
              <dt>&nbsp; </dt>
            </dl>
          </dd>
        </dl>
        <dl> 
          <dt> 
            <dl> 
              <dd></dd>
            </dl>
          </dt>
        </dl>
        <hr>
        <h3><a name="2_2">2.2 </a>Does GCJ support using straight C native methods 
          ala JNI? CNI looks kind of hard to use.</h3>
        <blockquote> 
          <p>Currently gcj does not support JNI, but this may change in the future. 
          </p>
          <p><a href="mailto:per@@bothner.com">Per Bother</a> explains the future 
            of these native interfaces:</p>
        </blockquote>
        <dl> 
          <blockquote> 
            <blockquote> 
              <p>(1) It is a goal that Gcj should support JNI as well as CNI. 
                Doing so is not in principle difficult, especially dealing with 
                JNI-using libraries that are known at link-time (since you can 
                just generate CNI wrapper functions that call the corresponding 
                JNI methods). However, there is still a for bit of tedious work 
                needed for JNI. </p>
              <p>(2) We do prefer CNI, as it is more efficient, easier to write, 
                and (at least potentially) easier to debug. </p>
              <p>(3) You could in principle write C++ code that implements both 
                a CNI and JNI interface, using the magic of pre-processing. The 
                question is whether we can do it in a way such that it would not 
                be simpler and cleaner to just maintain two copies of the code. 
                We don't know yet. </p>
            </blockquote>
          </blockquote>
          <dt> 
            <dl> 
              <dd></dd>
            </dl>
          </dt>
        </dl>
        <hr>
        <h3><a name="2_2">2.3 </a>Why does GCJ use CNI? </h3>
        <blockquote> 
          <p><a href="mailto:per@@bothner.com">Per Bother</a> explains </p>
          <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>
        </blockquote>
        <hr>
      </dl>
      <h3><a name="4_4">2.4 What is the state of AWT support</a>?</h3>
      <dl> 
        <dd> No support is currently in place for AWT. Prior Art which could be 
          used for this all require JNI. Possible starting points follow: 
          <dl> </dl>
          <p>QtAWT</p>
          <blockquote> 
            <p>QtAWT ( )provides a Qt based implementation of the peer classes 
              used by the AWT components. This consists of a set of Java classes 
              that implement the interfaces specified in java.awt.peer, and a 
              few others such as java.awt.Toolkit. The classes are implemented 
              in a mixture of Java code and native code, with the native methods 
              being called via the JNI. Because it sticks to standard APIs such 
              as the JNI QtAWT should be portable enough to work on any 1.1 JVM. 
              Once the class and library paths have been set up correctly, the 
              QtAWT can be used instead of the native peers provided with your 
              JVM by setting the awt.toolkit property to point to the QtToolkit 
              implementation. </p>
          </blockquote>
        </dd>
        <dl> 
          <dt>&nbsp;</dt>
          <dd><a href="http://developer.kde.org/language-bindings/java/qtawt/developer.html">http://developer.kde.org/language-bindings/java/qtawt/developer.html</a></dd>
          <dt>&nbsp;</dt>
          <dt>GTK AWT</dt>
          <dd>Some Mozilla / Blackdown project mambers are having a go at this 
            (free login required):</dd>
          <dd><a href="http://developer.java.sun.com/developer/restricted/java2cs/contribs/">http://developer.java.sun.com/developer/restricted/java2cs/contribs/</a></dd>
          <dt>&nbsp;</dt>
          <dd>The Classpath project is doing AWT with GTK peers, and they're looking 
            for someone who wants to make Classpath work with Kaffe ... <a href="http://www.gnu.org/software/classpath/">http://www.gnu.org/software/classpath/</a></dd>
          <dt>&nbsp;</dt>
        </dl>
        <dl> 
          <dt><a href="http://www.kaffe.org/">Kaffe</a> AWT</dt>
          <dd>Kaffe has a JNI based AWT implementation using lightweight peers. 
            Work is currently in progress to implement using GTK.</dd>
        </dl>
      </dl>
      <hr>
      <h3><a name="2_5">2.5 How about support for Swing</a>?</h3>
      <dl> 
        <dl> 
          <dt>Considering that AWT support isnt here yet there is no chance of 
            getting Swing running. Once we have AWT support the Swing 1.1.1 may 
            be useable and even redistributable, but JFC will be another issue, 
            as <a href="mailto:moroz@@metahood.ru">Oleg Moroz</a> summarises: 
            <blockquote> 
              <p>1) Swing 1.1.1 for JDK 1.1.x with license that allows to redistribute 
                it as part of the value-added applet or application. This needs 
                some research, however I feel that the term "value-added application" 
                might inlcude e.g. gcj-based development system; if it is not 
                by itself, a simple Swing-based application might be added to 
                the distribution). This version depends on AWT 1.1 only (well, 
                1.1.x, x >=7) and it seems that the Sun's version could be used 
                for most purposes people would like to use it. </p>
            </blockquote>
          </dt>
          <blockquote> 
            <p>2) Swing (JFC) that is part of Java2. This is AFAIK not available 
              as separate product and is covered by more restrictive (in this 
              case at least) JDK license; it is also dependent on AWT 1.2 features. 
              We'd want to develop a replacement only when we move to the 1.2 
              codebase and then we'll also need to develop AWT 1.2 replacement 
              w/o regard to Swing.</p>
            <p>&nbsp;</p>
          </blockquote>
        </dl>
        <dl> 
          <dt><a href="mailto:per@@bothner.com">Per Bother</a> expands:</dt>
          <dd>&nbsp;</dd>
          <dd>One possibility worth considering is developing Swing components 
            in conjunction with AWT. We can implement JTextArea and TextArea at 
            the same time. We could also implement both on top of (say) some Gtk 
            widget; we don't necessarily *have* to go the "peerless" route. Instead, 
            we can base the "plugable look-and-feel" on the "themebility" of (say) 
            Gtk. </dd>
          <dt>&nbsp;</dt>
          <dd>A bigger potential issue is Swing's separation between &quot;model&quot; 
            (e.g. Document) and &quot;view&quot; (e.g. JTextPane). It may be difficult 
            to make use of the functionality of an existing toolkit such as Gtk 
            unless we can use Gtk widgets with separate &quot;model&quot; objects.</dd>
        </dl>
        <hr>
      </dl>
      <h3><a name="2_6">2.6 </a>What support is there for RMI?</h3>
      <dl> 
        <dd> There is no RMI support at the moment. <a href="mailto:mdw@@cs.berkeley.edu">Matt 
          Welsh</a> elaborates:</dd>
        <dt> 
          <dl> 
            <dd>I was working on this, but it's on the back-burner right now. 
              So, if anyone would like to help out I would appreciate it. I have 
              a free implementation of RMI (&quot;NinjaRMI&quot;) that is quite 
              similar to Sun's RMI. You can download it from <a href="http://www.cs.berkeley.edu/%7Emdw/proj/ninja">http://www.cs.berkeley.edu/~mdw/proj/ninja</a></dd>
          </dl>
        </dt>
        <dd><a href="http://www.cs.berkeley.edu/%7Emdw/proj/ninja"></a></dd>
      </dl>
      <blockquote> 
        <blockquote> 
          <p>Note that this is NOT Java RMI per se; it is just very similar in 
            functionality and design. You might want to steal some classes out 
            of it to get RMI support in libgcj. However, it does require some 
            classes in java.* and sun.* which are not part of libgcj.</p>
        </blockquote>
        <p>It may be possible to use the JavaParty's <a href="http://wwwipd.ira.uka.de/%7Ehauma/EfficientRMI/">RMI 
          implementation</a>, but the lisencing is much more restrictive than 
          that of NinjaRMI. Details below:</p>
        <blockquote> 
          <p>The much faster drop-in RMI and the appropriate efficient serialization 
            is designed and implemented completely in Java without any native 
            code. Moreover, the re-designed RMI supports non-TCP/IP communication 
            networks, even with heterogeneous transport protocols. As a by-product, 
            there is a benchmark collection for RMI. </p>
        </blockquote>
      </blockquote>
      <p></p>
      <dl> 
        <dt>&nbsp; </dt>
        <hr>
      </dl>
      <dl> 
        <dt> 
          <h3><a name="2_7">2.7 Can I contribute code from other Free Software 
            projects to supplement libgcj's current features?</a></h3>
        </dt>
        <dd> <font color="#FF6600">Can someone point me to some difinitive words 
          on this issue</font> </dd>
      </dl>
      <blockquote> 
        <blockquote>&nbsp;</blockquote>
      </blockquote>
      <dl> 
        <hr>
      </dl>
      <dl> 
        <dt> 
          <h3><a name="2_8">2.8 What features of the Java language are/arn't supported.</a></h3>
        </dt>
        <dd>At the moment GCJ supports all Java language constructs as per the 
          <a href="http://java.sun.com/docs/books/jls/">Java language Specification 
          v1.0</a>. The JDK1.1 added support for Inner Classes, which arent yet 
          supported when compiling from source code, but can be used when compiling 
          from bytecode. see <i>4.2 Can GCJ only handle source code?</i> </dd>
      </dl>
      <dl> 
        <p></p>
      </dl>
      <table border="0" cellpadding="4" width="95%">
        <tr bgcolor="#b0d0ff"> 
          <th align="left"> 
            <h2><a name="3_0">Build Issues</a></h2>
          </th>
        </tr>
      </table>
      <dl> 
        <dt> 
          <h3><a name="3_1">3.1 Linker bug on Solaris</a></h3>
        </dt>
        <p> 
        <dd>There is a known problem with the <a href="http://egcs.cygnus.com/ml/gcc-bugs/1999-10/msg00159.html"> 
          native Solaris linker</a> when using gcc/gcj. A good indication you've 
          run into this problem is if you get an error that looks like the following 
          when building libgcj: 
          <pre>
ld: warning: option -o appears more than once, first setting taken
ld: fatal: file libfoo.so: cannot open file: No such file or directory
ld: fatal: File processing errors. No output written to .libs/libfoo.so
collect2: ld returned 1 exit status
	</pre>
          A known workaround for this and other reported link problems on the 
          various releases of Solaris is to build gcc/gcj with the <a href="ftp://sourceware.cygnus.com/pub/binutils/snapshots"> 
          latest GNU binutils</a> instead of the native Solaris <tt>ld</tt>. The 
          most straightforward way to do this is to build and install binutils, 
          and then reference it in the configure for gcc via <tt>--with-ld=/path_to_binutils_install/bin/ld</tt> 
          (<tt>--with-as</tt> may also be similarly specified but is not believed 
          to be required). 
          <p> Please note, gcc/gcj must be built using GNU ld prior to doing a 
            clean build of libgcj! 
        </dd>
        <p></p>
      </dl>
      <table border="0" cellpadding="4" width="95%">
        <tr bgcolor="#b0d0ff"> 
          <th align="left"> 
            <h2><a name="4_0">Gcj Compile/Link Questions</a></h2>
          </th>
        </tr>
      </table>
      <dl> 
        <dt>&nbsp; </dt>
        <dt> 
          <h3><a name="4_1">4.1 Why do I get <tt>undefined reference to `main'</tt> 
            errors?</a></h3>
        </dt>
      </dl>
      <p> 
      <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>
        <dt>&nbsp;</dt>
        <hr>
      </dl>
      <dl> 
        <dt>&nbsp; </dt>
        <dt> 
          <h3><a name="4_2">4.2 Can GCJ only handle source code?</a></h3>
        </dt>
      </dl>
      <p> 
      <dl> 
        <dd>The GCJ compiler will compile both java source and bytecode .class 
          files. For the moment support for compiling bytecodes will support more 
          applications than compiling from source, as the source code compiler 
          lacks support for inner classes, which are used heavily in programs 
          written for the JDK 1.1 (AWT in particular). 
          <p>In many cases the native code produced by compiling from source is 
            better optimised than that compiled from .class files. Per Bother 
            explains:</p>
        </dd>
        <dt> 
          <dl> 
            <dd>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>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>
            </dd>
            <dt>&nbsp;</dt>
          </dl>
        </dt>
        <hr>
        <dt>&nbsp;</dt>
        <dt><font color="#FF3300"></font></dt>
        <dt> 
          <h3><a name="4_4">4.3 &quot;gcj -C"</a> Doesnt seem to work like javac/jikes. 
            Whats going on?</h3>
        </dt>
        <blockquote> 
          <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>
        </blockquote>
      </dl>
      <hr>
      <dl> 
        <dt>&nbsp; </dt>
      </dl>
      <dl> 
        <dt> 
          <h3><a name="4_4">4.4 Where does GCJ look for files?</a></h3>
        </dt>
        <blockquote> 
          <p>GCJ looks for classes to compile based on the CLASSPATH environment 
            variable. An important limitation presently is that gcj doesn't handle 
            compressed jar files in your classpath </p>
        </blockquote>
      </dl>
      <hr>
      <dl> 
        <dt>&nbsp; </dt>
      </dl>
      <dl> 
        <dt> 
          <h3><a name="4_5">4.5 How does gcj resolve wether to compile .class 
            or .java files?</a></h3>
        </dt>
        <blockquote> 
          <p>GCJ seems to favor .class files in the CLASSPATH, if any, otherwise 
            it will use the source (.java), also in the CLASSPATH. It also checks 
            to see if the class is newer than the .java file. If it can't find 
            either it throws an error.</p>
        </blockquote>
      </dl>
      <dl> 
        <dt>&nbsp; </dt>
      </dl>
      <dl> 
        <p></p>
      </dl>
      <table border="0" cellpadding="4" width="95%">
        <tr bgcolor="#B0D0FF"> 
          <th align="left"> 
            <h2><a name="5_0">Runtime Questions</a></h2>
          </th>
        </tr>
      </table>
      <dl> 
        <dt> 
          <h3><a name="5_1">5.1 My program is dumping core! What's going on?</a></h3>
        </dt>
        <p> 
        <dd>I 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 libgcj.zip.</dd>
        <dd></dd>
      </dl>
      <p></p>
      <dl> 
        <dt> 
          <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>
        </dt>
      </dl>
      <p> 
      <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. 
          <p>This shouln't happen anymore, as we dont define MPROTECT_VDB in the 
            GC, at least for Linux/386.</p>
        </dd>
        <dt>&nbsp;</dt>
      </dl>
      <p></p>
      <dl> 
        <dt> 
          <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>
        </dt>
      </dl>
      <p> 
      <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.3 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 you're code is ready, and it doesn't rely on them, 
              try compiling with --no-bounds-check. </li>
            <li>Try static linking. The interaction with boehm-gc seems to incur 
              extra overhead when shared libraries are used. On one program that 
              makes heavy use of the allocator I achieved over 30% runtime performance 
              gain with static linking. This issue may disappear soon with a new 
              version of the GC.</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>
      <p></p>
      <p> 
      <dl> 
        <dd>&nbsp;</dd>
      </dl>
      <dl> 
        <hr>
        <dt>&nbsp;</dt>
        <dt> 
          <h3><a name="5_3">5.3 Can I profile Garbage Collection?</a></h3>
        </dt>
        <dd>It is possible to turn on verbose GC output by supressing 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. 
        </dd>
        <dt>&nbsp;</dt>
        <dd>The GC will print collection statistics to stdout. (Rebuilding boehm-gc 
          alone without this flag doesn't seem to work.)</dd>
        <dt>&nbsp;</dt>
        <hr>
        <dt>&nbsp;</dt>
        <dt> 
          <h3><a name="5_3">5.4 How do I increase the runtime's initial and maximum 
            heap sizes?</a></h3>
        </dt>
        <dd>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.</dd>
      </dl>
      <hr>
      <dl> 
        <dt> 
          <h3><a name="5_3">5.5 How can I profile my application?</a></h3>
        </dt>
        <dd>Support for this is currently lagging. Only single threaded Java code 
          may be used by the profiler (gprof). POSIX threads seem to be incompatible 
          with the gmon stuff.</dd>
        <dt>&nbsp;</dt>
      </dl>
      <p> 
      <table width="100%" border="0">
        <tr bgcolor="#B0D0FF" align="left"> 
          <th> 
            <h2><a name="6_0"></a>Programing Issues </h2>
          </th>
        </tr>
      </table>
      <h3><a name="6_1"></a>6.1 Are there any examples of how to use CNI?</h3>
      <blockquote> 
        <p><a href="mailto:tromey@@cygnus.com">Tom Tromey</a> has created a couple 
          of simple ezamples <a href="cni-1.txt">here</a> and <a href="cni-2.txt">here</a>. 
        </p>
        <p>Another CNI example may be found here (thanks to Glenn Chambers!): 
          <a href="http://sourceware.cygnus.com/ml/java-discuss/1999-q3/msg00534.html">http://sourceware.cygnus.com/ml/java-discuss/1999-q3/msg00534.html</a> 
        </p>
        <p>The primary source of documentation for CNI is at <a href="http://sourceware.cygnus.com/java/papers/cni/t1.html">http://sourceware.cygnus.com/java/papers/cni/t1.html</a></p>
      </blockquote>
    </td>
  </tr>
</table>
<hr>
<address> <a href="about.html">The GCJ team</a> <br>
<small> $Id: faq.html,v 1.6 1999/10/25 07:30:12 warrenl Exp $ </small></address>
<h2 align=center>&nbsp;</h2>

    <!--#include virtual="/include/footer-subpages.html"-->
@


1.6
log
@	* faq.html (2_1 Linker bug on Solaris): Use --with-ld.
@
text
@d1 703
a703 232
<html>
<title>GCJ - FAQ</title>
<body bgcolor="white">

<table border=0>
<tr><td valign="top">

<table border=0>
<tr><td>
<img src="gcj.jpg" alt="gcj logo" width=136 height=98>
</td></tr>
<tr>
<td>
<br>
<table border=0><tr><td width="10"></td><td>
<a href="index.html">Home</a><br>
<a href="faq.html">FAQ</a><br>
<a href="mail.html">Mailing Lists</a><br>
<a href="docs.html">Documentation</a><br>
<a href="download.html">Download</a><br>
<a href="contrib.html">Contributing</a><br>
<a href="http://sourceware.cygnus.com/cgi-bin/gnatsweb.pl?user=guest&password=guest&database=java&cmd=login">Bugs</a><br>
<a href="thanks.html">Thanks</a><br>
<!-- <a href="support.html">Support</a><br> -->
<br><br><br>
<a href="http://egcs.cygnus.com">GCC</a><br>
<a href="http://sourceware.cygnus.com/mauve">The Mauve Project</a><br>
<a href="http://sourceware.cygnus.com">Sourceware</a><br>
<a href="http://www.gnu.org">The GNU Project</a><br>
<a href="http://www.cygnus.com">Cygnus Solutions</a><br>
</td></tr></table>
</td></tr></table>

</td>

<td width=2 bgcolor="black">
i
</td>
<td width=6>
</td>

<td>

<br><br>
<h1>The GCJ FAQ</h1>

<P>The latest version of this document is always available at
<A HREF="faq.html">http://sourceware.cygnus.com/java/faq.html</A>.</P>

<OL>
   <LI><A HREF="#1_0">General Questions</A>
   <OL>
      <LI><A HREF="#1_1">What license is used for libgcj?</A>
      <LI><A HREF="#1_2">How can I report a bug in libgcj?</A>
      <LI><A HREF="#1_3">How can I contribute to libgcj?</A>
      <LI><A HREF="#1_4">Why isn't libgcj part of GCC?</A>
      <LI><A HREF="#1_5">Will gcj and libgcj work on my machine?</A>
      <LI><A HREF="#1_6">How can I debug my Java program?</A>
   </OL>
   <LI><A HREF="#2_0">Build Issues</A>
   <OL>
      <LI><A HREF="#2_1">Linker bug on Solaris</A>
   </OL>
   <LI><A HREF="#3_0">Gcj Compile/Link Questions</A>
   <OL>
      <LI><A HREF="#3_1">Why do I get <tt>undefined reference to `main'</tt> errors?</A>
   </OL>
   <LI><A HREF="#4_0">Runtime Questions</A>
   <OL>
      <LI><A HREF="#4_1">My program is dumping core!  What's going on?</A>
      <LI><A HREF="#4_2">When I run the debugger I get a SEGV in the GC!  What's going on?</A>
   </OL>
</OL>

<table border="0" cellpadding="4" width="95%">
<tr bgcolor="#b0d0ff">
 <th align="left">
 <A NAME="1_0"><h2>General Questions</h2></A>
 </th>
</tr>
</table>
<br>

    <dl>
      <dt><h3><a name="1_1">1.1 What license is used for libgcj?</a></h3></dt>
      <p>
      <dd>libgcj is distributed under the Library GPL.</dd>
      </p>

      <dt><hr><h3><a name="1_2">1.2 How can I report a bug in libgcj?</a></h3></dt>
      <p>
      <dd>libgcj has a corresponding
	<a
      href="http://sourceware.cygnus.com/cgi-bin/gnatsweb.pl?user=guest&password=guest&database=java&cmd=login">Gnats
	  bug database</a> which you can browse.  You can also submit new
	bug reports from the Gnats page.</dd>
      </p>

      <dt><hr><h3><a name="1_3">1.3 How can I contribute to libgcj?</a></h3></dt>
      <p>
      <dd>You can send simple bug fixes in as patches.  Please follow
	the <a href="http://egcs.cygnus.com/contribute.html">GCC guidelines
	for submitting patches</a>.
	For more complex changes, you must sign copyright over to
	Cygnus.  See the <a href="contrib.html">contribution</a> page
	for details.</dd>
      </p>

      <dt><hr><h3><a name="1_4">1.4 Why isn't libgcj part of GCC?</a></h3></dt>
      <p>
      <dd>Various minor reasons.  It's likely that libgcj will end up
	in GCC at some point in the future.</dd>
      </p>

      <dt><hr><h3><a name="1_5">1.5 Will gcj and libgcj work on my machine?</a></h3></dt>
      <p>
      <dd>So far gcj and libgcj have only really been tried on Sparc
	Solaris and x86 Linux.  They might work on other systems, but
	we don't know.  Generally speaking, porting to a new system
	should not be hard.  This would be a good way to volunteer.</dd>
      </p>

      <dt><hr><h3><a name="1_6">1.6 How can I debug my Java program?</a></h3></dt>
      <p>
      <dd><a href="ftp://ftp.gnu.org/pub/gnu/gdb/gdb-4.18.tar.gz">gdb
	4.18</a> includes support for debugging gcj-compiled Java
	programs.</dd>
      </p>

    </dl>

<table border="0" cellpadding="4" width="95%">
<tr bgcolor="#b0d0ff">
 <th align="left">
 <A NAME="2_0"><h2>Build Issues</h2></A>
 </th>
</tr>
</table>
    <dl>

      <dt><h3><a name="2_1">2.1 Linker bug on Solaris</a></h3></dt>
      <p>
      <dd>There is a known problem with the 
        <a href="http://egcs.cygnus.com/ml/gcc-bugs/1999-10/msg00159.html">
        native Solaris linker</a> when using gcc/gcj.
	A good indication you've run into this problem is if you get
	an error that looks like the following when building libgcj:
	<pre>
ld: warning: option -o appears more than once, first setting taken
ld: fatal: file libfoo.so: cannot open file: No such file or directory
ld: fatal: File processing errors. No output written to .libs/libfoo.so
collect2: ld returned 1 exit status
	</pre>
	A known workaround
	for this and other reported link problems on the various releases
	of Solaris is to build gcc/gcj with the 
        <a href="ftp://sourceware.cygnus.com/pub/binutils/snapshots">
	latest GNU binutils</a> instead of the native Solaris <tt>ld</tt>.
	The most straightforward way to do this is to build and install
	binutils, and then reference it in the configure for gcc
	via <tt>--with-ld=/path_to_binutils_install/bin/ld</tt>
	(<tt>--with-as</tt> may also be similarly
	specified but is not believed to be required).
	<p>
	Please note, gcc/gcj must be built using GNU ld prior to doing
	a clean build of libgcj!
	</dd>
      </p>
    </dl>

<table border="0" cellpadding="4" width="95%">
<tr bgcolor="#b0d0ff">
 <th align="left">
 <A NAME="3_0"><h2>Gcj Compile/Link Questions</h2></A>
 </th>
</tr>
</table>
    <dl>

      <dt><h3><a name="3_1">3.1 Why do I get <tt>undefined reference to `main'</tt> errors?</a></h3></dt>
      <p>
      <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>
      </p>
    </dl>

<table border="0" cellpadding="4" width="95%">
<tr bgcolor="#b0d0ff">
 <th align="left">
 <A NAME="4_0"><h2>Runtime Questions</h2></A>
 </th>
</tr>
</table>
    <dl>

      <dt><h3><a name="4_1">4.1 My program is dumping core!  What's going on?</a></h3></dt>
      <p>
      <dd>I 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 libgcj.zip.</dd>
      </p>

      <dt><hr><h3><a name="4_2">4.2 When I run the debugger I get a SEGV in the GC! What's going on?</a></h3></dt>
      <p>
      <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>
      </p>
    </dl>

<br>
</td></tr>
</table>

<hr>

<address>
<a href="about.html">The GCJ team</a>
<br>
<small>
$Id: faq.html,v 1.5 1999/10/14 08:12:30 warrenl Exp $
</small>
</address>

</body>
</html>
@


1.5
log
@	* faq.html (2_1 Linker bug on Solaris): Added text of error msg.
@
text
@d160 4
a163 5
	binutils, and then reference it in the configure for gcc and gcj
	via <tt>--with-gnu-ld</tt> (<tt>--with-gnu-as</tt> may also be
	specified but is not believed to be required).  Alternatively, 
	a non-installed GNU ld can be used by instead passing
	<tt>--with-ld=/path_to_your_binutils/bin/ld</tt> to configure.
d227 1
a227 1
$Id: faq.html,v 1.4 1999/10/13 23:43:16 warrenl Exp $
@


1.4
log
@	* faq.html: Updated link for faq to be relative instead of absolute.
	* gcj2.html: Updated links for libgcj info from dead pages.
@
text
@d145 10
a154 1
        native Solaris linker</a> when using gcc/gcj.  A known workaround
d228 1
a228 1
$Id: faq.html,v 1.3 1999/10/13 01:24:26 warrenl Exp $
@


1.3
log
@	* faq.html (2_0 Build Issues): Added Q&A for infamous Solaris ld bug.
@
text
@d48 1
a48 2
<A HREF="http://sourceware.cygnus.com/java/faq.html">
http://sourceware.cygnus.com/java/faq.html</A>.</P>
d219 1
a219 1
$Id: faq.html,v 1.2 1999/09/28 08:41:40 warrenl Exp $
@


1.2
log
@	* faq.html: Added sections, links and some new questions.
@
text
@d61 1
a61 1
   <LI><A HREF="#2_0">Build Questions</A>
d63 1
d136 1
a136 1
 <A NAME="2_0"><h2>Build Questions</h2></A>
d141 21
d177 3
a179 1
	desired <tt>main</tt> method.</dd>
d220 1
a220 1
$Id: faq.html,v 1.1 1999/09/07 00:34:01 green Exp $
@


1.1
log
@Move new files into main area.
@
text
@d47 28
d78 1
a78 1
 General FAQ
d85 2
a86 1
      <dt>What license is used for libgcj?</dt>
d88 1
d90 2
a91 1
      <dt>How can I report a bug in libgcj?</dt>
d97 1
d99 2
a100 1
      <dt>How can I contribute to libgcj?</dt>
d107 1
d109 2
a110 6
      <dt>How can I debug my Java program?</dt>
      <dd><a href="ftp://ftp.gnu.org/pub/gnu/gdb/gdb-4.18.tar.gz">gdb
	4.18</a> includes support for debugging gcj-compiled Java
	programs.</dd>

      <dt>Why isn't libgcj part of GCC?</dt>
d113 1
d115 2
a116 1
      <dt>Will gcj and libgcj work on my machine?</dt>
d121 20
d142 28
a169 1
      <dt>My program is dumping core!  What's going on?</dt>
d175 1
d177 7
d186 1
d196 1
a196 1
$Id: faq.html,v 1.5 1999/09/07 00:18:38 green Exp $
d201 1
a201 1
</html>@

