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
State-Changed-From-To: open->analyzed State-Changed-Why: Still a bug
Very much related to bug 13493.
I am looking into fixing this one.
The problem is that the DECL_INITIAL of the final static has been nulled.
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.
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.