Bug 8433 - Static initializers must be able to complete normally
Summary: Static initializers must be able to complete normally
Status: RESOLVED FIXED
Alias: None
Product: gcc
Classification: Unclassified
Component: java (show other bugs)
Version: 3.2
: P3 normal
Target Milestone: 4.3.0
Assignee: Not yet assigned to anyone
URL:
Keywords: accepts-invalid, diagnostic
Depends on: 28067
Blocks:
  Show dependency treegraph
 
Reported: 2002-11-02 17:46 UTC by ebb9
Modified: 2007-01-09 20:44 UTC (History)
4 users (show)

See Also:
Host:
Target:
Build:
Known to work:
Known to fail:
Last reconfirmed: 2005-09-30 13:35:37


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description ebb9 2002-11-02 17:46:00 UTC
Java forbids static initializers from not being able to complete normally. These two classes should both cause a compile-time error, but gcj accepts them:

class Foo
{
  static
  {
    throw new NullPointerException("nope");
  }
}
class Other
{
  static
  {
    while (true);
  }
}

Release:
gcj (GCC) 3.2 20020818 (prerelease)

Environment:
Configured with: /netrel/src/gcc-3.2-1/configure --enable-languages=c,c++,f77,ja
va --enable-libgcj --enable-threads=posix --with-system-zlib --enable-nls --with
out-included-gettext --enable-interpreter --disable-sjlj-exceptions --disable-ve
rsion-specific-runtime-libs --enable-shared --build=i686-pc-linux --host=i686-pc
-cygwin --target=i686-pc-cygwin --enable-haifa --prefix=/usr --exec-prefix=/usr
--sysconfdir=/etc --libdir=/usr/lib --includedir=/nonexistent/include --libexecd
ir=/usr/sbin
Thread model: posix
gcc version 3.2 20020818 (prerelease)

How-To-Repeat:
Compile the two example classes. It should give two compile errors.
Comment 1 Tom Tromey 2003-01-29 12:56:56 UTC
State-Changed-From-To: feedback-open
State-Changed-Why: "Completes normally" is a technical term defined in the Java Language
Specification.  See section 15.6 in the JSL 2nd Ed.
We already have a fair amount of machinery for this.  However, when
I looked, it appeared difficult to fix this PR.
Comment 2 Andrew Haley 2003-01-29 20:01:55 UTC
State-Changed-From-To: open->feedback
State-Changed-Why: I don't understand how gcj is expected to do this.
    Determining whether a static initializer will complete normally is equivalent to the halting problem, and is therefore not computable.
Comment 3 Andrew Pinski 2003-05-25 22:51:54 UTC
Confirmed on mainline (20030525).
Comment 4 Tom Tromey 2007-01-09 20:44:09 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.