Bug 25265 - linking BC-compiled classes with incompatible changes
Summary: linking BC-compiled classes with incompatible changes
Status: RESOLVED FIXED
Alias: None
Product: gcc
Classification: Unclassified
Component: libgcj (show other bugs)
Version: 4.2.0
: P3 normal
Target Milestone: ---
Assignee: Andrew Haley
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2005-12-05 14:00 UTC by Robert Schuster
Modified: 2006-05-25 09:56 UTC (History)
2 users (show)

See Also:
Host:
Target:
Build:
Known to work:
Known to fail:
Last reconfirmed: 2006-03-05 03:03:05


Attachments
test setup (2.53 KB, application/octet-stream)
2005-12-05 14:03 UTC, Robert Schuster
Details
test setup (2.53 KB, application/octet-stream)
2005-12-05 14:37 UTC, Robert Schuster
Details

Note You need to log in before you can comment on or make changes to this bug.
Description Robert Schuster 2005-12-05 14:00:18 UTC
Imagine the following situation:

class T {
  void test(){
       M.staticMethod(); // a
       new M().method(); // b
       M.staticField = "FOO"; // c
       new M().field = "FOO"; // d
  }
}

class M{
   static void staticMethod(){}
   void method(){}
   static String staticField;
   String field;
}

Compile this and then replace the class file of M with the compiled code of this class: class M{}

The JDK has no problems loading the T class and when running each the statement *on its own* it would throw a NoSuchMethodError (case a & b) or a NoSuchFieldError (case c & d).

GIJ should do the same.
Comment 1 Robert Schuster 2005-12-05 14:03:58 UTC
Created attachment 10408 [details]
test setup

A test setup for the above mentioned 4 cases. There are three scripts which runs different interpreters:

nf-run.sh: Runs java - usually an proprietary runtime.
gij-run.sh: Runs gij in interpreted mode
bc-run.sh: Run gij with BC compiled classes.

The output describes what was done and what was expected.
Comment 2 Robert Schuster 2005-12-05 14:37:49 UTC
Created attachment 10409 [details]
test setup

Same as above but fixed the messages about expected and unexpected Throwables.
Comment 3 Robert Schuster 2005-12-05 21:53:30 UTC
The version of gcj in SVN cannot handle loading classes of case d ( = accessing a nonstatic field which is removed) when BC-compiled classes are used (interpreted mode is fine in all cases).
Comment 4 Andrew Haley 2005-12-08 14:40:52 UTC
Subject: Bug 25265

Author: aph
Date: Thu Dec  8 14:40:48 2005
New Revision: 108232

URL: http://gcc.gnu.org/viewcvs?root=gcc&view=rev&rev=108232
Log:
2005-12-08  Andrew Haley  <aph@redhat.com>

        PR libgcj/25265
        * java-tree.h (enum java_tree_index): Add JTI_SOFT_NOSUCHFIELD_NODE.
        (soft_abstractmethod_node): New.
        * expr.c (build_field_ref): Add in-line check for missing field.
        * decl.c (java_init_decl_processing): Add soft_nosuchfield_node.


Modified:
    branches/gcc-4_1-branch/gcc/java/ChangeLog
    branches/gcc-4_1-branch/gcc/java/decl.c
    branches/gcc-4_1-branch/gcc/java/expr.c
    branches/gcc-4_1-branch/gcc/java/java-tree.h

Comment 5 Andrew Haley 2005-12-08 14:44:33 UTC
Subject: Bug 25265

Author: aph
Date: Thu Dec  8 14:44:29 2005
New Revision: 108233

URL: http://gcc.gnu.org/viewcvs?root=gcc&view=rev&rev=108233
Log:
2005-12-08  Andrew Haley  <aph@redhat.com>

        PR libgcj/25265
        * java/lang/Object.h (throwNoSuchMethodError): New method.
        * java/lang/Object.java (throwNoSuchMethodError): New method.
        * include/jvm.h (_Jv_ThrowNoSuchFieldError): Declare.
        * link.cc (_Jv_ThrowNoSuchFieldError): New.
        (link_symbol_table): Don't throw a NoSuchFieldError if a field is
        missing.  Instead, set the otable entry to zero.
        (link_symbol_table): If we don't find a nonstatic method, insert
        the vtable offset of Object.throwNoSuchMethodError() into the
        otable.


Modified:
    branches/gcc-4_1-branch/libjava/ChangeLog

Comment 6 Andrew Haley 2005-12-08 15:32:49 UTC
Subject: Bug 25265

Author: aph
Date: Thu Dec  8 15:32:44 2005
New Revision: 108235

URL: http://gcc.gnu.org/viewcvs?root=gcc&view=rev&rev=108235
Log:
2005-12-08  Andrew Haley  <aph@redhat.com>

        PR libgcj/25265
        * java-tree.h (enum java_tree_index): Add JTI_SOFT_NOSUCHFIELD_NODE.
        (soft_abstractmethod_node): New.
        * expr.c (build_field_ref): Add in-line check for missing field.
        * decl.c (java_init_decl_processing): Add soft_nosuchfield_node.

2005-12-08  Andrew Haley  <aph@redhat.com>

        PR libgcj/25265
        * java/lang/Object.h (throwNoSuchMethodError): New method.
        * java/lang/Object.java (throwNoSuchMethodError): New method.
        * include/jvm.h (_Jv_ThrowNoSuchFieldError): Declare.
        * link.cc (_Jv_ThrowNoSuchFieldError): New.
        (link_symbol_table): Don't throw a NoSuchFieldError if a field is
        missing.  Instead, set the otable entry to zero.
        (link_symbol_table): If we don't find a nonstatic method, insert
        the vtable offset of Object.throwNoSuchMethodError() into the
        otable.


Modified:
    trunk/gcc/java/ChangeLog
    trunk/libjava/ChangeLog

Comment 7 Andrew Haley 2006-05-25 09:56:00 UTC
.