diff options
author | Tom Tromey <tromey@redhat.com> | 2006-03-16 00:08:12 +0000 |
---|---|---|
committer | Tom Tromey <tromey@gcc.gnu.org> | 2006-03-16 00:08:12 +0000 |
commit | b32d6f93f89dbfd30e0190fa6201839ad0d1d172 (patch) | |
tree | f5f9e86f993986a9fdff0fe28fccaa0e8e0821de /gcc/java/jcf-write.c | |
parent | 34a9f549fd2e5f15666cb384a507ef7b2d39e1f3 (diff) | |
download | gcc-b32d6f93f89dbfd30e0190fa6201839ad0d1d172.zip gcc-b32d6f93f89dbfd30e0190fa6201839ad0d1d172.tar.gz gcc-b32d6f93f89dbfd30e0190fa6201839ad0d1d172.tar.bz2 |
jcf-write.c (generate_bytecode_insns): Use qualifying type for non-static method calls.
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
Diffstat (limited to 'gcc/java/jcf-write.c')
-rw-r--r-- | gcc/java/jcf-write.c | 28 |
1 files changed, 19 insertions, 9 deletions
diff --git a/gcc/java/jcf-write.c b/gcc/java/jcf-write.c index 5343361..aa4d33b 100644 --- a/gcc/java/jcf-write.c +++ b/gcc/java/jcf-write.c @@ -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) { |