jcf-write.c (generate_bytecode_insns): Use qualifying type for non-static method...
authorTom Tromey <tromey@redhat.com>
Thu, 16 Mar 2006 00:08:12 +0000 (00:08 +0000)
committerTom Tromey <tromey@gcc.gnu.org>
Thu, 16 Mar 2006 00:08:12 +0000 (00:08 +0000)
gcc/java
* jcf-write.c (generate_bytecode_insns): Use qualifying type for
non-static method calls.
libjava
* testsuite/libjava.jacks/jacks.xfail: Removed
13.1-runtime-method-5.

From-SVN: r112102

gcc/java/ChangeLog
gcc/java/jcf-write.c
libjava/ChangeLog
libjava/testsuite/libjava.jacks/jacks.xfail

index 9e40d60d9408f8d7191bd6b48dd880ea9073afec..5f840751fb426741e9f7bd372a5a1a8dc9539dbd 100644 (file)
@@ -1,3 +1,8 @@
+2006-03-15  Tom Tromey  <tromey@redhat.com>
+
+       * jcf-write.c (generate_bytecode_insns): Use qualifying type for
+       non-static method calls.
+
 2006-03-15  David Daney  <ddaney@avtrex.com>
 
        * java-tree.h : Moved comment for TYPE_DOT_CLASS adjacent to its
index 534336190918a883d0f49fe3486f85ee6daba6b4..aa4d33b141f82fd24d4474677019e818f7bd0faa 100644 (file)
@@ -1,5 +1,5 @@
 /* Write out a Java(TM) class file.
-   Copyright (C) 1998, 1999, 2000, 2001, 2002, 2003, 2004, 2005
+   Copyright (C) 1998, 1999, 2000, 2001, 2002, 2003, 2004, 2005, 2006
    Free Software Foundation, Inc.
 
 This file is part of GCC.
@@ -2610,26 +2610,36 @@ generate_bytecode_insns (tree exp, int target, struct jcf_partial *state)
            tree context = DECL_CONTEXT (f);
            int index, interface = 0;
            RESERVE (5);
+
+           /* If the method is not static, use the qualifying type.
+              However, don't use the qualifying type if the method
+              was declared in Object.  */
+           if (! METHOD_STATIC (f)
+               && ! DECL_CONSTRUCTOR_P (f)
+               && ! METHOD_PRIVATE (f)
+               && DECL_CONTEXT (f) != object_type_node)
+             {
+               tree arg1 = TREE_VALUE (TREE_OPERAND (exp, 1));
+               context = TREE_TYPE (TREE_TYPE (arg1));
+             }
+
            if (METHOD_STATIC (f))
              OP1 (OPCODE_invokestatic);
            else if (DECL_CONSTRUCTOR_P (f) || CALL_USING_SUPER (exp)
-               || METHOD_PRIVATE (f))
+                    || METHOD_PRIVATE (f))
              OP1 (OPCODE_invokespecial);
            else
              {
                if (CLASS_INTERFACE (TYPE_NAME (context)))
-                 {
-                   tree arg1 = TREE_VALUE (TREE_OPERAND (exp, 1));
-                   context = TREE_TYPE (TREE_TYPE (arg1));
-                   if (CLASS_INTERFACE (TYPE_NAME (context)))
-                     interface = 1;
-                 }
+                 interface = 1;
                if (interface)
                  OP1 (OPCODE_invokeinterface);
                else
                  OP1 (OPCODE_invokevirtual);
              }
-           index = find_methodref_with_class_index (&state->cpool, f, context);
+
+           index = find_methodref_with_class_index (&state->cpool, f,
+                                                    context);
            OP2 (index);
            if (interface)
              {
index cbcb506ba92024a9f568fa3da63b7d6b0b0b41d3..f3ff2d68a7924b57808d9b2e7f0a3d049fa8cf20 100644 (file)
@@ -1,3 +1,8 @@
+2006-03-15  Tom Tromey  <tromey@redhat.com>
+
+       * testsuite/libjava.jacks/jacks.xfail: Removed
+       13.1-runtime-method-5.
+
 2006-03-15  Tom Tromey  <tromey@redhat.com>
 
        PR java/26638:
index 0ecb62b28b332e2a28093180a6254cda5c73ff72..081e8ac233a1318897460a7295b528781666a4ce 100644 (file)
@@ -5,7 +5,6 @@
 13.1-runtime-constant-1
 13.1-runtime-constant-3
 13.1-runtime-field-1
-13.1-runtime-method-5
 13.1-runtime-method-6
 13.4.8-constant-runtime-1
 13.4.8-constant-runtime-2