Bug 1259 - string constants not handled properly
string constants not handled properly
Status: RESOLVED FIXED
Product: gcc
Classification: Unclassified
Component: java
3.0
: P3 normal
: 4.3.0
Assigned To: Not yet assigned to anyone
: wrong-code
Depends on: 13493 28067
Blocks: 21722
  Show dependency treegraph
 
Reported: 2000-12-20 12:18 UTC by Tom Tromey
Modified: 2007-01-09 20:43 UTC (History)
6 users (show)

See Also:
Host:
Target:
Build:
Known to work:
Known to fail:
Last reconfirmed: 2006-01-29 17:53:59


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Tom Tromey 2000-12-20 12:18:23 UTC
According to section 12.4.1 of the JVM, a class or
interface shouldn't be initialized if a field is
passively referenced; this includes references to
"static final" (or equiv.) fields whose value is a
compile-time constant expression.  The latter is
defined (section 15.27) to include Strings.

We don't seem to handle this at all.

I checked in the "stringconst.java" test which demonstrates
the bug.  However, that is just one instance; I suspect
there are others.

Release:
unknown
Comment 1 Tom Tromey 2003-05-03 02:44:46 UTC
State-Changed-From-To: open->analyzed
State-Changed-Why: Still a bug
Comment 2 Andrew Pinski 2004-01-07 19:48:44 UTC
Very much related to bug 13493.
Comment 3 Andrew Pinski 2004-11-07 23:27:00 UTC
I am looking into fixing this one.
Comment 4 Andrew Pinski 2004-11-07 23:42:41 UTC
The problem is that the DECL_INITIAL of the final static has been nulled.
Comment 5 Tom Tromey 2005-06-01 21:12:24 UTC
One example of a failure is the test case in PR 21722.
In this PR we generate this bytecode in A.class:

  0: ldc #9=<String "foo">
  2: astore_1
  3: getstatic #15=<Field b.B.FOO java.lang.String>
  6: aload_1
  7: invokevirtual #21=<Method java.lang.String.equals (java.lang.Object)boolean>

However, as B.FOO is a compile-time constant, we should not have
a 'getstatic' here.
Comment 6 Tom Tromey 2007-01-09 20:43:15 UTC
All gcj front end bugs have been fixed by the gcj-eclipse branch merge.
I'm mass-closing the affected PRs.
If you believe one of these was closed in error, please reopen it
with a note explaining why.
Thanks.