Bug 30742 - ResourceBundle regression
Summary: ResourceBundle regression
Status: RESOLVED FIXED
Alias: None
Product: gcc
Classification: Unclassified
Component: libgcj (show other bugs)
Version: 4.3.0
: P3 normal
Target Milestone: 4.3.0
Assignee: Andrew Haley
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2007-02-09 03:58 UTC by Tom Tromey
Modified: 2007-02-16 21:51 UTC (History)
4 users (show)

See Also:
Host:
Target:
Build:
Known to work:
Known to fail:
Last reconfirmed: 2007-02-10 11:01:57


Attachments
bug tar (2.43 KB, application/x-gzip)
2007-02-09 03:58 UTC, Tom Tromey
Details
first patch (363 bytes, patch)
2007-02-09 22:28 UTC, Tom Tromey
Details | Diff
It's a patch! (788 bytes, patch)
2007-02-10 11:50 UTC, Andrew Haley
Details | Diff

Note You need to log in before you can comment on or make changes to this bug.
Description Tom Tromey 2007-02-09 03:58:14 UTC
ResourceBundle on svn head has a regression.
It doesn't find the correct class loader from the stack.
I'll attach a test case.  To see the bug:

cd Fail
gij -cp main.jar F
Comment 1 Tom Tromey 2007-02-09 03:58:53 UTC
Created attachment 13024 [details]
bug tar
Comment 2 Andrew Haley 2007-02-09 17:05:39 UTC
I can't reproduce this with trunk or any of the Red Hat test builds.

zebedee:/tmp/Fail $ gij -cp main.jar F
class Z
java.util.PropertyResourceBundle@3169d8b5
zebedee:/tmp/Fail $ gij --version
java version "1.5.0"
gij (GNU libgcj) version 4.1.1 20070202 (Red Hat 4.1.1-55)
zebedee:/tmp/Fail $ ~/gcc/trunk/install/bin/gij -cp main.jar F
class Z
java.util.PropertyResourceBundle@319b98f5
zebedee:/tmp/Fail $ ~/gcc/trunk/install/bin/gij --version     
java version "1.5.0"
gij (GNU libgcj) version 4.3.0 20070208 (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.
Comment 3 Tom Tromey 2007-02-09 20:49:42 UTC
Definitely fails with trunk on x86.
Comment 4 Tom Tromey 2007-02-09 21:59:25 UTC
So far the bug seems to be that we reach the
"CALLER_OF_CALLER" state in stackwalker_trace_fn
with ResourceBundle as the class.
There seems to be one more frame on the stack
than this code expects.
Comment 5 Tom Tromey 2007-02-09 22:28:38 UTC
Created attachment 13028 [details]
first patch

This patch fixes the problem for me.
In my run, the GetStackWalkerCallingClass call in
getCallingClass returns ResourceBundle -- but what we
want it ResourceBundle's caller.

This is pretty awful though.  I think perhaps we need a new
API in _Jv_StackTrace for this case.

Also I think there must be something here I am missing,
since I don't see how this code could work on any platform.
Comment 6 Andrew Haley 2007-02-10 11:01:56 UTC
Definitely a 32-bit only issue:

zorro:/tmp/Fail $ ~/gcc/trunk/obj-x86_64-unknown-linux-gnu/x86_64-unknown-linux-gnu/libjava/gij -cp main.jar F
class Z
java.util.PropertyResourceBundle@317b08f5
zorro:/tmp/Fail $ ~/gcc/trunk/obj-x86_64-unknown-linux-gnu/x86_64-unknown-linux-gnu/32/libjava/gij -cp main.jar F
class Z
Exception in thread "main" java.lang.ExceptionInInitializerError
   at java.lang.Class.initializeClass(natClass.cc:767)
   at java.lang.Class.newInstance(Class.h:733)
   at F.main(F.java:9)
Caused by: java.util.MissingResourceException: Bundle org/test not found for locale en_US by classloader gnu.gcj.runtime.SystemClassLoader{urls=[file:main.jar], parent=gnu.gcj.runtime.ExtensionClassLoader{urls=[], parent=null}}
   at java.util.ResourceBundle.getBundle(ResourceBundle.java:410)
   at java.util.ResourceBundle.getBundle(ResourceBundle.java:231)
   at Z.<clinit>(Z.java:6)
   at java.lang.Class.initializeClass(natClass.cc:755)
   ...2 more
Comment 7 Andrew Haley 2007-02-10 11:50:00 UTC
Created attachment 13029 [details]
It's a patch!

This is the correct patch.  The key here is that it is never correct for one
VMStackWalker method to call another, becasue that introduces another level of
nesting.
Comment 8 Andrew Haley 2007-02-10 14:23:15 UTC
Subject: Bug 30742

Author: aph
Date: Sat Feb 10 14:22:54 2007
New Revision: 121798

URL: http://gcc.gnu.org/viewcvs?root=gcc&view=rev&rev=121798
Log:
2007-02-10  Andrew Haley  <aph@redhat.com>

	PR java/30742
	* gnu/classpath/natVMStackWalker.cc (GET_CALLING_CLASS): New.
	(getCallingClass): Call GET_CALLING_CLASS.
	(getCallingClassLoader): Likewise.


Modified:
    trunk/libjava/ChangeLog
    trunk/libjava/gnu/classpath/natVMStackWalker.cc

Comment 9 Andrew Haley 2007-02-10 14:36:42 UTC
Subject: Bug 30742

Author: aph
Date: Sat Feb 10 14:36:28 2007
New Revision: 121799

URL: http://gcc.gnu.org/viewcvs?root=gcc&view=rev&rev=121799
Log:
2007-02-10  Andrew Haley  <aph@redhat.com>

        PR java/30742
        * gnu/classpath/natVMStackWalker.cc (GET_CALLING_CLASS): New.
        (getCallingClass): Call GET_CALLING_CLASS.
        (getCallingClassLoader): Likewise.


Modified:
    branches/redhat/gcc-4_1-branch-java-merge-20070117/libjava/ChangeLog
    branches/redhat/gcc-4_1-branch-java-merge-20070117/libjava/gnu/classpath/natVMStackWalker.cc

Comment 10 Tom Tromey 2007-02-16 21:51:25 UTC
Fix checked in.