Bug 7073 - bytecode interpreter gives wrong answer for interface getSuperclass()
Summary: bytecode interpreter gives wrong answer for interface getSuperclass()
Status: RESOLVED FIXED
Alias: None
Product: gcc
Classification: Unclassified
Component: libgcj (show other bugs)
Version: 3.1
: P3 normal
Target Milestone: ---
Assignee: Tom Tromey
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2002-06-18 14:06 UTC by Jeff Sturm
Modified: 2003-07-25 17:33 UTC (History)
4 users (show)

See Also:
Host:
Target:
Build:
Known to work:
Known to fail:
Last reconfirmed:


Attachments
B.java (114 bytes, application/octet-stream)
2003-05-21 15:17 UTC, Jeff Sturm
Details

Note You need to log in before you can comment on or make changes to this bug.
Description Jeff Sturm 2002-06-18 14:06:00 UTC
For an interface class instance, getSuperclass() returns java.lang.Object instead of null.  This is inconsistent with the behavior of compiled classes and the public documentation on java.sun.com.

Release:
3.1

Environment:
i686-pc-linux-gnu

How-To-Repeat:
Run the attached example under the bytecode interpreter:

[jsturm@suzy jsturm]$ gcj -C B.java
[jsturm@suzy jsturm]$ gij B
class java.lang.Object
Comment 1 Tom Tromey 2002-06-18 16:33:32 UTC
From: Tom Tromey <tromey@redhat.com>
To: jsturm@one-point.com
Cc: gcc-gnats@gcc.gnu.org
Subject: Re: libgcj/7073: bytecode interpreter gives wrong answer for interface getSuperclass()
Date: 18 Jun 2002 16:33:32 -0600

 Jeff> For an interface class instance, getSuperclass() returns
 Jeff> java.lang.Object instead of null.  This is inconsistent with the
 Jeff> behavior of compiled classes and the public documentation on
 Jeff> java.sun.com.
 
 Thanks, I added a Mauve tests for this, plus a related bug I found
 when looking at your test case.  (Try void.class.getSuperClass())
 I also got a failure when compiling from bytecode.
 
 The void thing is definitely a compiler bug.  I think it must be a
 regression, but I haven't looked.  `void.class' has to be rewritten to
 look up the `Void.TYPE' field.
 
 Tom

Comment 2 Tom Tromey 2002-06-20 15:10:54 UTC
From: tromey@gcc.gnu.org
To: gcc-gnats@gcc.gnu.org
Cc:  
Subject: libgcj/7073
Date: 20 Jun 2002 15:10:54 -0000

 CVSROOT:	/cvs/gcc
 Module name:	gcc
 Changes by:	tromey@gcc.gnu.org	2002-06-20 08:10:52
 
 Modified files:
 	libjava        : ChangeLog defineclass.cc resolve.cc 
 
 Log message:
 	For PR libgcj/7073:
 	* resolve.cc (_Jv_PrepareClass): Only resolve superclass if it
 	exists.
 	* defineclass.cc (handleClassBegin): Superclass for interface is
 	`null'.
 
 Patches:
 http://gcc.gnu.org/cgi-bin/cvsweb.cgi/gcc/libjava/ChangeLog.diff?cvsroot=gcc&r1=1.1363&r2=1.1364
 http://gcc.gnu.org/cgi-bin/cvsweb.cgi/gcc/libjava/defineclass.cc.diff?cvsroot=gcc&r1=1.27&r2=1.28
 http://gcc.gnu.org/cgi-bin/cvsweb.cgi/gcc/libjava/resolve.cc.diff?cvsroot=gcc&r1=1.28&r2=1.29
 
Comment 3 Tom Tromey 2002-07-01 19:54:26 UTC
Responsible-Changed-From-To: unassigned->tromey
Responsible-Changed-Why: I'm handling this.
Comment 4 Tom Tromey 2002-07-01 19:54:26 UTC
State-Changed-From-To: open->closed
State-Changed-Why: I checked in the libgcj part of the fix a while ago.
    I just checked in the gcj part.
    So I think this is fixed.
Comment 5 Tom Tromey 2002-07-02 02:56:13 UTC
From: tromey@gcc.gnu.org
To: gcc-gnats@gcc.gnu.org
Cc:  
Subject: libgcj/7073
Date: 2 Jul 2002 02:56:13 -0000

 CVSROOT:	/cvs/gcc
 Module name:	gcc
 Changes by:	tromey@gcc.gnu.org	2002-07-01 19:56:13
 
 Modified files:
 	gcc/java       : ChangeLog parse.y 
 
 Log message:
 	For PR libgcj/7073:
 	* parse.y (patch_incomplete_class_ref): Handle VOID_TYPE
 	specially.
 
 Patches:
 http://gcc.gnu.org/cgi-bin/cvsweb.cgi/gcc/gcc/java/ChangeLog.diff?cvsroot=gcc&r1=1.1026&r2=1.1027
 http://gcc.gnu.org/cgi-bin/cvsweb.cgi/gcc/gcc/java/parse.y.diff?cvsroot=gcc&r1=1.389&r2=1.390
 

Comment 6 Jakub Jelinek 2002-10-16 21:26:49 UTC
From: jakub@gcc.gnu.org
To: gcc-gnats@gcc.gnu.org
Cc:  
Subject: libgcj/7073
Date: 16 Oct 2002 21:26:49 -0000

 CVSROOT:	/cvs/gcc
 Module name:	egcs
 Branch: 	gcc-3_2-rhl8-branch
 Changes by:	jakub@gcc.gnu.org	2002-10-16 14:26:48
 
 Modified files:
 	gcc            : ChangeLog expr.c langhooks-def.h langhooks.h 
 	                 langhooks.c fold-const.c Makefile.in 
 	gcc/java       : ChangeLog parse.y lang.c lex.c jcf-write.c 
 	                 expr.c except.c verify.c jcf-dump.c 
 	libjava/testsuite/libjava.lang: Array_3.java 
 	libjava/testsuite: ChangeLog 
 Added files:
 	libjava/testsuite/libjava.compile: narrow_case.java zeroexp.java 
 	libjava/testsuite/libjava.lang: EvaluationOrder.java 
 	                                EvaluationOrder.out 
 	                                utf8concat.java 
 
 Log message:
 	gcc/
 	2002-10-16  Jakub Jelinek  <jakub@redhat.com>
 	
 	* fold-const.c: Include langhooks.h.
 	* Makefile.in (fold-const.o): Depend on langhooks.h.
 	
 	2002-08-21  Tom Tromey  <tromey@redhat.com>
 	
 	For PR java/6005 and PR java/7611:
 	* fold-const.c (fold_truthop): Use can_use_bit_fields_p.
 	(fold): Likewise.
 	* langhooks.c (lhd_can_use_bit_fields_p): New function.
 	* langhooks-def.h (lhd_can_use_bit_fields_p): Declare.
 	(LANG_HOOKS_CAN_USE_BIT_FIELDS_P): New define.
 	(LANG_HOOKS_INITIALIZER): Use it.
 	* langhooks.h (struct lang_hooks) [can_use_bit_fields_p]: New
 	field.
 	
 	2002-07-24  Richard Henderson  <rth@redhat.com>
 	
 	* expr.c (expand_expr) [TRY_FINALLY_EXPR]: Use GOTO_SUBROUTINE_EXPR
 	form when not optimizing.
 	
 	2002-07-21  Richard Henderson  <rth@redhat.com>
 	
 	* expr.c (expand_expr) [TRY_FINALLY_EXPR]: Don't use
 	GOTO_SUBROUTINE_EXPR when finally_block can be re-expanded.
 	
 	gcc/java/
 	2002-10-15  Andrew Haley  <aph@redhat.com>
 	
 	* parse.y (patch_invoke): Call force_evaluation_order on a static
 	arg list.
 	(resolve_qualified_expression_name): Call force_evaluation_order
 	on a arg list that is part of a Qualified Expression Name.
 	
 	2002-10-09  Kaveh R. Ghazi  <ghazi@caip.rutgers.edu>
 	
 	* parse.y (merge_string_cste): Add parentheses around & within |.
 	
 	2002-10-08  Tom Tromey  <tromey@redhat.com>
 	
 	* parse.y (variable_declarator_id): Simplify error path for
 	array declarator error.  For PR java/8003.
 	
 	2002-10-07  Anthony Green  <green@redhat.com>
 	
 	* parse.y (merge_string_cste): Fix bug in string concatenation.
 	
 	2002-10-01  Nathan Sidwell  <nathan@codesourcery.com>
 	
 	* jcf-dump.c (print_constant, case CONSTANT_float): Don't fall
 	foul of type-based aliasing.
 	
 	2002-09-26  Andrew Haley  <aph@redhat.com>
 	
 	* expr.c (build_java_array_length_access): Check for null pointer.
 	* expr.c (expand_java_arrayload): Likewise.
 	
 	2002-09-17  Tom Tromey  <tromey@redhat.com>
 	
 	* lex.c (java_read_unicode_collapsing_terminators): Handle case
 	where \r appears at EOF.  Fixes PR java/7950.
 	
 	2002-09-11  Per Bothner  <per@bothner.com>
 	
 	* parse.y (fold_constant_for_init):  If a VAR_DECL, convert numerical
 	constant to the type of the field.
 	(java_complete_tree):  Remove now-redundant code.
 	
 	* parse.y (fold_constant_for_init):  'null' is not a constant expr.
 	
 	2002-09-03  Jesse Rosenstock  <jmr@ugcs.caltech.edu>
 	
 	For PR java/5794:
 	* verify.c (verify_jvm_instructions) [OPCODE_jsr]: Only push the
 	return label if a ret instruction for the jsr has been reached.
 	
 	2002-08-28  Andrew Haley  <aph@redhat.com>
 	
 	* verify.c (verify_jvm_instructions): Allow exception handler
 	inside code that is being protected, but generate a warning.
 	* except.c (link_handler): Initialize `expanded' in new eh_range.
 	(binding_depth, is_class_level, current_pc): Declare extern.
 	
 	2002-08-26  Tom Tromey  <tromey@redhat.com>
 	
 	* parse.y (try_builtin_assignconv): Allow narrowing primitive
 	conversion if RHS_TYPE is byte, short, or char.
 	
 	2002-08-21  Tom Tromey  <tromey@redhat.com>
 	
 	For PR java/6005 and PR java/7611:
 	* lang.c (LANG_HOOKS_CAN_USE_BITFIELDS_P): New define.
 	(java_can_use_bit_fields_p): New function.
 	
 	2002-08-08  Bryce McKinlay  <bryce@waitaki.otago.ac.nz>
 	
 	* jcf-write.c (get_access_flags): Return correct access flags for
 	private and protected inner classes.
 	
 	2002-07-22  Tom Tromey  <tromey@redhat.com>
 	
 	* lex.c (java_lex): Check for `e' or `E' after 0.
 	
 	2002-07-21  Richard Henderson  <rth@redhat.com>
 	
 	* lang.c (java_unsafe_for_reeval): New.
 	(LANG_HOOKS_UNSAFE_FOR_REEVAL): New.
 	
 	2002-07-01  Tom Tromey  <tromey@redhat.com>
 	
 	For PR libgcj/7073:
 	* parse.y (patch_incomplete_class_ref): Handle VOID_TYPE
 	specially.
 	
 	libjava/testsuite/
 	2002-10-15  Andrew Haley  <aph@redhat.com>
 	
 	* libjava.lang/EvaluationOrder.java (EvaluationOrder): New.
 	* libjava.lang/EvaluationOrder.out (EvaluationOrder): New.
 	
 	2002-10-03  Andrew Haley  <aph@redhat.com>
 	
 	* libjava.lang/Array_3.java (baz): New.
 	(main): Call baz.
 	
 	2002-09-29  Anthony Green  <green@redhat.com>
 	
 	* libjava.lang/utf8concat.java: New file.
 	* libjava.lang/utf8concat.out: Ditto.
 	
 	2002-08-26  Tom Tromey  <tromey@redhat.com>
 	
 	* libjava.compile/narrow_case.java: New file.
 	
 	2002-07-22  Tom Tromey  <tromey@redhat.com>
 	
 	* libjava.compile/zeroexp.java: New file.
 
 Patches:
 http://gcc.gnu.org/cgi-bin/cvsweb.cgi/egcs/gcc/ChangeLog.diff?cvsroot=gcc&only_with_tag=gcc-3_2-rhl8-branch&r1=1.13152.2.657.2.27.2.21&r2=1.13152.2.657.2.27.2.22
 http://gcc.gnu.org/cgi-bin/cvsweb.cgi/egcs/gcc/expr.c.diff?cvsroot=gcc&only_with_tag=gcc-3_2-rhl8-branch&r1=1.423.2.19.4.1.2.3&r2=1.423.2.19.4.1.2.4
 http://gcc.gnu.org/cgi-bin/cvsweb.cgi/egcs/gcc/langhooks-def.h.diff?cvsroot=gcc&only_with_tag=gcc-3_2-rhl8-branch&r1=1.8.10.2.2.1.2.2&r2=1.8.10.2.2.1.2.3
 http://gcc.gnu.org/cgi-bin/cvsweb.cgi/egcs/gcc/langhooks.h.diff?cvsroot=gcc&only_with_tag=gcc-3_2-rhl8-branch&r1=1.15.8.2.2.1.2.2&r2=1.15.8.2.2.1.2.3
 http://gcc.gnu.org/cgi-bin/cvsweb.cgi/egcs/gcc/langhooks.c.diff?cvsroot=gcc&only_with_tag=gcc-3_2-rhl8-branch&r1=1.16.2.2.4.1.2.2&r2=1.16.2.2.4.1.2.3
 http://gcc.gnu.org/cgi-bin/cvsweb.cgi/egcs/gcc/fold-const.c.diff?cvsroot=gcc&only_with_tag=gcc-3_2-rhl8-branch&r1=1.185.2.4.4.1&r2=1.185.2.4.4.2
 http://gcc.gnu.org/cgi-bin/cvsweb.cgi/egcs/gcc/Makefile.in.diff?cvsroot=gcc&only_with_tag=gcc-3_2-rhl8-branch&r1=1.830.2.15.4.3&r2=1.830.2.15.4.4
 http://gcc.gnu.org/cgi-bin/cvsweb.cgi/egcs/gcc/java/ChangeLog.diff?cvsroot=gcc&only_with_tag=gcc-3_2-rhl8-branch&r1=1.925.2.59.2.2.2.2&r2=1.925.2.59.2.2.2.3
 http://gcc.gnu.org/cgi-bin/cvsweb.cgi/egcs/gcc/java/parse.y.diff?cvsroot=gcc&only_with_tag=gcc-3_2-rhl8-branch&r1=1.353.2.19&r2=1.353.2.19.4.1
 http://gcc.gnu.org/cgi-bin/cvsweb.cgi/egcs/gcc/java/lang.c.diff?cvsroot=gcc&only_with_tag=gcc-3_2-rhl8-branch&r1=1.85.2.4.4.2&r2=1.85.2.4.4.3
 http://gcc.gnu.org/cgi-bin/cvsweb.cgi/egcs/gcc/java/lex.c.diff?cvsroot=gcc&only_with_tag=gcc-3_2-rhl8-branch&r1=1.80.8.4&r2=1.80.8.4.8.1
 http://gcc.gnu.org/cgi-bin/cvsweb.cgi/egcs/gcc/java/jcf-write.c.diff?cvsroot=gcc&only_with_tag=gcc-3_2-rhl8-branch&r1=1.99.2.4&r2=1.99.2.4.4.1
 http://gcc.gnu.org/cgi-bin/cvsweb.cgi/egcs/gcc/java/expr.c.diff?cvsroot=gcc&only_with_tag=gcc-3_2-rhl8-branch&r1=1.132.2.10&r2=1.132.2.10.4.1
 http://gcc.gnu.org/cgi-bin/cvsweb.cgi/egcs/gcc/java/except.c.diff?cvsroot=gcc&only_with_tag=gcc-3_2-rhl8-branch&r1=1.26.20.1&r2=1.26.20.1.8.1
 http://gcc.gnu.org/cgi-bin/cvsweb.cgi/egcs/gcc/java/verify.c.diff?cvsroot=gcc&only_with_tag=gcc-3_2-rhl8-branch&r1=1.47&r2=1.47.14.1
 http://gcc.gnu.org/cgi-bin/cvsweb.cgi/egcs/gcc/java/jcf-dump.c.diff?cvsroot=gcc&only_with_tag=gcc-3_2-rhl8-branch&r1=1.42.2.2&r2=1.42.2.2.8.1
 http://gcc.gnu.org/cgi-bin/cvsweb.cgi/egcs/libjava/testsuite/libjava.compile/narrow_case.java.diff?cvsroot=gcc&only_with_tag=gcc-3_2-rhl8-branch&r1=NONE&r2=1.1.16.1
 http://gcc.gnu.org/cgi-bin/cvsweb.cgi/egcs/libjava/testsuite/libjava.compile/zeroexp.java.diff?cvsroot=gcc&only_with_tag=gcc-3_2-rhl8-branch&r1=NONE&r2=1.1.18.1
 http://gcc.gnu.org/cgi-bin/cvsweb.cgi/egcs/libjava/testsuite/libjava.lang/EvaluationOrder.java.diff?cvsroot=gcc&only_with_tag=gcc-3_2-rhl8-branch&r1=NONE&r2=1.1.2.1
 http://gcc.gnu.org/cgi-bin/cvsweb.cgi/egcs/libjava/testsuite/libjava.lang/EvaluationOrder.out.diff?cvsroot=gcc&only_with_tag=gcc-3_2-rhl8-branch&r1=NONE&r2=1.1.2.1
 http://gcc.gnu.org/cgi-bin/cvsweb.cgi/egcs/libjava/testsuite/libjava.lang/utf8concat.java.diff?cvsroot=gcc&only_with_tag=gcc-3_2-rhl8-branch&r1=NONE&r2=1.1.10.1
 http://gcc.gnu.org/cgi-bin/cvsweb.cgi/egcs/libjava/testsuite/libjava.lang/Array_3.java.diff?cvsroot=gcc&only_with_tag=gcc-3_2-rhl8-branch&r1=1.1&r2=1.1.26.1
 http://gcc.gnu.org/cgi-bin/cvsweb.cgi/egcs/libjava/testsuite/ChangeLog.diff?cvsroot=gcc&only_with_tag=gcc-3_2-rhl8-branch&r1=1.177.2.24.2.2&r2=1.177.2.24.2.2.2.1