Problem with static fields and indirect-dispatch
Casey Marshall
csm@gnu.org
Wed May 10 21:37:00 GMT 2006
On IRC Bryce mentioned -fno-indirect-classes, and if I compile this
test case with that flag, it works.
Why do I need that flag? It seems like it's equivalent to `-fmake-it-
work-really' or something.
On May 10, 2006, at 2:32 PM, Casey Marshall wrote:
> Hi, I'm seeing a problem with a 4.2.0 snapshot. The following
> program fails to run; without the patch mentioned, it still fails,
> but in `java.lang.Class.initializeClass,' not in `testbc.<clinit>'.
> Without the patch, it fails at line 1663 of link.cc, which is the
> `if' in:
>
> jstring *strp = (jstring *) f->u.addr;
> if (*strp)
> *strp = _Jv_NewStringUTF8Const ((_Jv_Utf8Const *) *strp);
>
> Running this interpreted, or compiled directly works; compiling it
> with -findirect-dispatch and launching it with `gij' fails.
>
> Thanks.
>
> ----
>
> /*
> * Steps to reproduce:
> * 1. gcj -C testbc.java
> * 2. jar cf testbc.jar testbc.class
> * 3. gcj -shared -g -O2 -findirect-dispatch -o testbc.jar.so
> testbc.jar
> * 4. gcj-dbtool -n testbc.gcjdb 32
> * 5. gcj-dbtool -a testbc.gcjdb testbc.jar testbc.jar.so
> * 6. gij -cp testbc.jar -Dgnu.gcj.precompiled.db.path=testbc.gcjdb
> testbc
> *
> * Expected output:
> * {}
> * Actual output:
> * Exception in thread "main" java.lang.ExceptionInInitializerError
> * at java.lang.Class.initializeClass (natClass.cc:758)
> * at java.lang.Class.forName (Class.h:641)
> * at gnu.java.lang.MainThread.run (MainThread.java:95)
> * Caused by: java.lang.NullPointerException
> * at testbc.<clinit> (testbc.java:5)
> * at java.lang.Class.initializeClass (natClass.cc:750)
> * ...2 more
> *
> * Version info:
> * gcj (GCC) 4.2.0 20060506 (experimental)
> * Copyright (C) 2006 Free Software Foundation, Inc.
> * This is free software; see the source for copying conditions.
> There is NO
> * warranty; not even for MERCHANTABILITY or FITNESS FOR A
> PARTICULAR PURPOSE.
> *
> * This patch was applied to the sources:
> * http://gcc.gnu.org/ml/java-patches/2006-q2/msg00127.html
> *
> * Host triplet (build and target): i686-pc-linux-gnu.
> */
>
> import java.util.Hashtable;
>
> public class testbc
> {
> protected static Hashtable cache = new Hashtable();
>
> public static void main (String[] s) throws Throwable
> {
> System.out.println (cache);
> }
> }
-------------- next part --------------
A non-text attachment was scrubbed...
Name: PGP.sig
Type: application/pgp-signature
Size: 478 bytes
Desc: This is a digitally signed message part
URL: <http://gcc.gnu.org/pipermail/java/attachments/20060510/fd4564d2/attachment.sig>
More information about the Java
mailing list