Bug 24321 - instanceof erroneously causes class initialization
Summary: instanceof erroneously causes class initialization
Status: RESOLVED FIXED
Alias: None
Product: gcc
Classification: Unclassified
Component: libgcj (show other bugs)
Version: 4.1.0
: P2 normal
Target Milestone: 4.2.0
Assignee: Tom Tromey
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2005-10-11 21:59 UTC by Tom Tromey
Modified: 2006-03-01 16:29 UTC (History)
2 users (show)

See Also:
Host:
Target:
Build:
Known to work:
Known to fail:
Last reconfirmed: 2006-02-28 20:53:13


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Tom Tromey 2005-10-11 21:59:06 UTC
Consider this program:

public class iof {
  static class Z {
    static {
      System.out.println("init");
    }
  }

  public static Object x () { return new Object(); }

  public static void main(String[] args)
  {
    System.out.println(x() instanceof Z);
  }
}


With gcj this prints "init".
With the JDK it does not.
Comment 1 Andrew Pinski 2005-10-11 22:03:16 UTC
Confirmed.
Comment 2 Andrew Pinski 2005-10-11 22:05:05 UTC
Hmm, when compiled to native it works but not when using gij.
Comment 3 Andrew Pinski 2005-10-16 00:40:29 UTC
Note -noverify does not help with this case unlike PR 17021.
Comment 4 Tom Tromey 2006-02-28 20:53:13 UTC
Testing a patch.
Comment 5 Tom Tromey 2006-03-01 16:01:44 UTC
Subject: Bug 24321

Author: tromey
Date: Wed Mar  1 16:01:34 2006
New Revision: 111603

URL: http://gcc.gnu.org/viewcvs?root=gcc&view=rev&rev=111603
Log:
	PR java/24321:
	* testsuite/libjava.lang/pr24321.java: New file.
	* testsuite/libjava.lang/pr24321.out: New file.
	* java/lang/natClass.cc (isInstance): Don't initialize class.
	(isAssignableFrom): Likewise.

Added:
    trunk/libjava/testsuite/libjava.lang/pr24321.java
    trunk/libjava/testsuite/libjava.lang/pr24321.out
Modified:
    trunk/libjava/ChangeLog
    trunk/libjava/java/lang/natClass.cc

Comment 6 Tom Tromey 2006-03-01 16:29:40 UTC
Fix checked in to trunk.
This may be a good 4.1.1 candidate.