Bug 1299 - full hiearchy of interfaces not checked?
Summary: full hiearchy of interfaces not checked?
Status: RESOLVED FIXED
Alias: None
Product: gcc
Classification: Unclassified
Component: java (show other bugs)
Version: unknown
: P3 normal
Target Milestone: ---
Assignee: Alexandre Petit-Bianco
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2000-12-20 12:18 UTC by osk
Modified: 2003-07-25 17:33 UTC (History)
3 users (show)

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


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Bryce McKinlay 2000-07-03 22:47:35 UTC
From: Bryce McKinlay <bryce@albatross.co.nz>
To: osk@hem.passagen.se
Cc: java-gnats@sourceware.cygnus.com
Subject: Re: gcj/278: full hiearchy of interfaces not checked?
Date: Mon, 03 Jul 2000 22:47:35 +1200

 This is a multi-part message in MIME format.
 --------------9BAB4FC556DE4E9507B0F7D1
 Content-Type: text/plain; charset=us-ascii
 Content-Transfer-Encoding: 7bit
 
 osk@hem.passagen.se wrote:
 
 > If BorderLayout only extends LayoutManager and not LayoutManager2, everything
 > is fine. So it seems that the class hierarchy of interfaces are not checked
 > in arguments.
 
 This seems to be a case of gcj behaving differently depending on whethere the classes referenced exist as
 .class files or .java files. When the LayoutManager interfaces exist as class files, interface_of_p will
 return false (when it should return true), but if they exist as java files it works okay.
 
 Here is a proposed patch.
 
 regards
 
   [ bryce ]
 
 
 
 --------------9BAB4FC556DE4E9507B0F7D1
 Content-Type: text/plain; charset=us-ascii;
  name="gcj-PR278.patch"
 Content-Transfer-Encoding: 7bit
 Content-Disposition: inline;
  filename="gcj-PR278.patch"
 
 2000-07-03  Bryce McKinlay  <bryce@albatross.co.nz>
 
 	* class.c (interface_of_p): Call load_class on arguments if they're
 	not loaded.
 
 Index: class.c
 ===================================================================
 RCS file: /cvs/gcc/egcs/gcc/java/class.c,v
 retrieving revision 1.70
 diff -u -r1.70 class.c
 --- class.c	2000/06/27 04:30:18	1.70
 +++ class.c	2000/07/03 10:40:51
 @@ -432,6 +432,11 @@
    int n, i;
    tree basetype_vec;
  
 +  if (! CLASS_LOADED_P (type1))
 +    load_class (type1, 1);
 +  if (! CLASS_LOADED_P (type2))
 +    load_class (type2, 1);
 +
    if (!(basetype_vec = TYPE_BINFO_BASETYPES (type2)))
      return 0;
    n = TREE_VEC_LENGTH (basetype_vec);
 
 --------------9BAB4FC556DE4E9507B0F7D1--
 

Comment 1 Bryce McKinlay 2000-07-03 23:38:47 UTC
From: Bryce McKinlay <bryce@albatross.co.nz>
To: Oskar Liljeblad <osk@hem.passagen.se>, java-gnats@sourceware.cygnus.com
Cc:  
Subject: Re: gcj/278: full hiearchy of interfaces not checked?
Date: Mon, 03 Jul 2000 23:38:47 +1200

 This is a multi-part message in MIME format.
 --------------7D4C2CD1C698A6C846153641
 Content-Type: text/plain; charset=us-ascii
 Content-Transfer-Encoding: 7bit
 
 Oskar Liljeblad wrote:
 
 > I applied your patch, recompiled and installed. Now Dialog.java compiles
 > but LayoutManager2.java doesn't. I get this error:
 >
 > $ gcj -C bava/awt/*.java
 > ./bava/awt/LayoutManager2.java:2: Interface `bava.awt.LayoutManager2' already defined in bava/awt/LayoutManager2.java:2.
 > public interface LayoutManager2 extends LayoutManager { }
 >                  ^
 > 1 error
 >
 > Oskar Liljeblad (osk@hem.passagen.se)
 
 Doh.
 
 Try this one. I'm not really sure if the patch is correct - I get the feeling I'm just fixing the symptom here and not the
 real problem... ;-(
 
 regards
 
   [ bryce ]
 
 
 
 --------------7D4C2CD1C698A6C846153641
 Content-Type: text/plain; charset=us-ascii;
  name="gcj-PR278-2.patch"
 Content-Transfer-Encoding: 7bit
 Content-Disposition: inline;
  filename="gcj-PR278-2.patch"
 
 2000-07-03  Bryce McKinlay  <bryce@albatross.co.nz>
 
 	* class.c (interface_of_p): Call load_class on arguments if they're
 	not loaded and not being compiled from source.
 
 Index: class.c
 ===================================================================
 RCS file: /cvs/gcc/egcs/gcc/java/class.c,v
 retrieving revision 1.70
 diff -u -r1.70 class.c
 --- class.c	2000/06/27 04:30:18	1.70
 +++ class.c	2000/07/03 11:34:46
 @@ -432,6 +432,11 @@
    int n, i;
    tree basetype_vec;
  
 +  if (!CLASS_LOADED_P (type1) && !CLASS_FROM_SOURCE_P (type1))
 +    load_class (type1, 1);
 +  if (!CLASS_LOADED_P (type2) && !CLASS_FROM_SOURCE_P (type2))
 +    load_class (type2, 1);
 +
    if (!(basetype_vec = TYPE_BINFO_BASETYPES (type2)))
      return 0;
    n = TREE_VEC_LENGTH (basetype_vec);
 
 --------------7D4C2CD1C698A6C846153641--
 
Comment 2 osk 2000-12-20 12:18:50 UTC
Run the script below to generate the java code, then compile it.

 $ sh the_script
 $ gcj -C bava/awt/*.java
 bava/awt/Dialog.java: In class `bava.awt.Dialog':
 bava/awt/Dialog.java: In method `bava.awt.Dialog()':
 bava/awt/Dialog.java:4: Can't find method `setLayout(Lbava/awt/BorderLayout;)' in type `bava.awt.Dialog'.
                setLayout(new BorderLayout());

If BorderLayout only extends LayoutManager and not LayoutManager2, everything
is fine. So it seems that the class hierarchy of interfaces are not checked
in arguments.

Oskar Liljeblad (osk@hem.passagen.se)

----------------------------------------------------------------------
mkdir bava bava/awt
cd bava/awt

echo  >BorderLayout.java "package bava.awt;"
echo >>BorderLayout.java "public class BorderLayout implements LayoutManager2 { }"
echo  >LayoutManager2.java "package bava.awt;"
echo >>LayoutManager2.java "public interface LayoutManager2 extends LayoutManager { }"
echo  >LayoutManager.java "package bava.awt;"
echo >>LayoutManager.java "public interface LayoutManager { }"

cat  >Dialog.java <<__END__
package bava.awt;
public class Dialog {
	public Dialog() {
		setLayout(new BorderLayout());
	}
	public void setLayout(LayoutManager layout_manager) { }	
}
__END__
----------------------------------------------------------------------

Release:
unknown

Environment:
Debian GNU/Linux
egcs 2.96 2000-06-26
libgcj 2000-07-02
Comment 3 Bryce McKinlay 2001-03-02 17:22:27 UTC
State-Changed-From-To: open->closed
State-Changed-Why: Confirmed as fixed in gcc 3.0 branch.
Comment 4 Bryce McKinlay 2001-03-03 01:22:27 UTC
From: bryce@gcc.gnu.org
To: apbianco@gcc.gnu.org, gcc-gnats@gcc.gnu.org, osk@hem.passagen.se
Cc:  
Subject: Re: java/1299
Date: 3 Mar 2001 01:22:27 -0000

 Synopsis: full hiearchy of interfaces not checked?
 
 State-Changed-From-To: open->closed
 State-Changed-By: bryce
 State-Changed-When: Fri Mar  2 17:22:27 2001
 State-Changed-Why:
     Confirmed as fixed in gcc 3.0 branch.
 
 http://gcc.gnu.org/cgi-bin/gnatsweb.pl?cmd=view&pr=1299&database=gcc