public inbox for gcc-prs@sourceware.org
help / color / mirror / Atom feed
* java/1304: GCJ fails to compile inner classes which extend another inner class
@ 2000-12-20 12:24 idstewart
  0 siblings, 0 replies; only message in thread
From: idstewart @ 2000-12-20 12:24 UTC (permalink / raw)
  To: java-gnats

>Number:         1304
>Category:       java
>Synopsis:       GCJ fails to compile inner classes which extend another inner class
>Confidential:   no
>Severity:       serious
>Priority:       medium
>Responsible:    apbianco
>State:          closed
>Class:          sw-bug
>Submitter-Id:   net
>Arrival-Date:   Wed Dec 20 12:18:51 PST 2000
>Closed-Date:    Tue Nov 21 21:25:51 PST 2000
>Last-Modified:  Tue Nov 21 21:30:00 PST 2000
>Originator:     idstewart@softhome.net
>Release:        unknown-1.0
>Organization:
>Environment:

>Description:
public class OuterA {
  public class InnerA {
  }
}

public class OuterB {
  public class InnerB extends OuterA.InnerA {
  }
}

OuterA.java compiles just fine.  Compiling OuterB.java dies with "Superclass
'OuterA.InnerA' of class 'OuterB$InnerB' not found".

I believe this has to do with how GCJ resolves packages/classes/fields/methods
( e.g., GCJ is looking for OuterA/InnerA.class instead of OuterA$InnerA.class)
>How-To-Repeat:

>Fix:

>Release-Note:

>Audit-Trail:

Formerly PR gcj/283


From: Mark Wielaard <mark@klomp.org>
To: idstewart@softhome.net
Cc: java-gnats@sourceware.cygnus.com
Subject: Re: gcj/283: GCJ fails to compile inner classes which extend another inner class
Date: Fri, 14 Jul 2000 14:11:31 +0200

 Hi,
 
 You might want to try the patch attached to gcj/256
 < http://sources.redhat.com/cgi-bin/gnatsweb.pl?cmd=view&pr=256&database=java >
 That solves the problem for me.
 
 Note that in your example you try to extend InnerB from a non static
 innerclass InnerA which is not legal. Making InnerA a public static class
 would be a valid example.
 
 Mark

From: Bryce McKinlay <bryce@albatross.co.nz>
To: java-gnats@sourceware.cygnus.com
Cc:  
Subject: Re: gcj/283: GCJ fails to compile inner classes which extend another 
 inner class
Date: Sat, 15 Jul 2000 18:22:39 +1200

 Mark Wielaard wrote:
 
 >  You might want to try the patch attached to gcj/256
 >  < http://sources.redhat.com/cgi-bin/gnatsweb.pl?cmd=view&pr=256&database=java >
 >  That solves the problem for me.
 >
 >  Note that in your example you try to extend InnerB from a non static
 >  innerclass InnerA which is not legal. Making InnerA a public static class
 >  would be a valid example.
 
 I agree. With the PR256 patch applied, I get the correct error trying to
 compile this test:
 
 $ gcj -c *.java
 OuterB.java: In class `OuterB$InnerB':
 OuterB.java: In method `<init>(OuterB)':
 OuterB.java:4: No enclosing instance for inner class `OuterA$InnerA' is
 in scope; an
 explicit one must be provided when creating this inner class.
                    }
                    ^
 1 error
 
 However, throw some .class files into the mix and it all goes wrong:
 
 $ javac OuterA.java
 
 $ ls -l *.class
 -rw-rw-r--    1 bryce    bryce         320 Jul 15 18:14
 OuterA$InnerA.class
 -rw-rw-r--    1 bryce    bryce         245 Jul 15 18:14 OuterA.class
 
 $ gcj -c *.java
 OuterB.java:2: Superclass `OuterA.InnerA' of class `OuterB$InnerB' not
 found.
                    public class InnerB extends OuterA.InnerA {
                                                ^
 gcj: Internal error: Segmentation fault (program jc1)
 Please submit a full bug report.
 See <URL: http://www.gnu.org/software/gcc/bugs.html > for instructions.
 
 regards
 
   [ bryce ]

From: Mark Wielaard <mark@klomp.org>
To: idstewart@softhome.net
Cc: java-gnats@sourceware.cygnus.com
Subject: Re: gcj/283: GCJ fails to compile inner classes which extend another inner class
Date: Sat, 15 Jul 2000 12:51:51 +0200

 Hi,
 
 > > Note that in your example you try to extend InnerB from a non static
 > > innerclass InnerA which is not legal. Making InnerA a public static class
 > > would be a valid example.
 > 
 > That, unfortunately, is not an option.  I'm working on a clean-room 
 > implementation of Swing.  Each of the core classes implement the Accessible 
 > interface by returning an inner class which extends 
 > JComponent.AccessibleJComponent, a protected abstract inner class.
 
 I see what you are trying to do. You found (another) bug which is different
 from gjc/256 (but which can only be shown when the gcj/256 patch is applied).
 
 So to show this bug you have to not only extend the InnerA from InnerB
 but also OuterB from OuterA:
 
 public class OuterA {
     public class InnerA {
     }
 }
 
 public class OuterB extends OuterA {
     public class InnerB extends OuterA.InnerA {
     }
 }
 
 Now gcj will give the following error:
 
 OuterB.java: In class `OuterB$InnerB':
 OuterB.java: In method `<init>(OuterB)':
 OuterB.java:4: No enclosing instance for inner class `OuterA$InnerA' is in scope; an explicit one must be provided when creating this inner class.
 }
 ^
 1 error
 
 Which is wrong since OuterB is in scope and is an instance of OuterA.
 
 Note that as Bryce noted you want to make sure that you don't have
 any class files around since that gives yet another obscure error message.
 
 Thanks,
 
 Mark
 
 P.S. Please CC java-gnats so your comments will make it into the bug database.
 P.P.S. Where can I find this Swing clean room implementation?
 Are you going to merge it with Classpath/libgcj?

From: idstewart@softhome.net
To: mark@klomp.org (Mark Wielaard)
Cc: java-gnats@sourceware.cygnus.com
Subject: Re: gcj/283: GCJ fails to compile inner classes which extend another inner class
Date: Sat, 15 Jul 2000 12:48:29 -0400 (EDT)

 On Sat Jul 15 06:51:51 2000 Mark Wielaard wrote:
 > 
 > Hi,
 > 
 > > > Note that in your example you try to extend InnerB from a non static
 > > > innerclass InnerA which is not legal. Making InnerA a public static class
 > > > would be a valid example.
 > > 
 > > That, unfortunately, is not an option.  I'm working on a clean-room 
 > > implementation of Swing.  Each of the core classes implement the Accessible 
 > > interface by returning an inner class which extends 
 > > JComponent.AccessibleJComponent, a protected abstract inner class.
 > 
 > I see what you are trying to do. You found (another) bug which is different
 > from gjc/256 (but which can only be shown when the gcj/256 patch is applied).
 > 
 > So to show this bug you have to not only extend the InnerA from InnerB
 > but also OuterB from OuterA:
 > 
 > public class OuterA {
 >     public class InnerA {
 >     }
 > }
 > 
 > public class OuterB extends OuterA {
 >     public class InnerB extends OuterA.InnerA {
 >     }
 > }
 > 
 > Now gcj will give the following error:
 > 
 > OuterB.java: In class `OuterB$InnerB':
 > OuterB.java: In method `<init>(OuterB)':
 > OuterB.java:4: No enclosing instance for inner class `OuterA$InnerA' is in scope; an explicit one must be provided when creating this inner class.
 > }
 > ^
 > 1 error
 > 
 > Which is wrong since OuterB is in scope and is an instance of OuterA.
 > 
 > Note that as Bryce noted you want to make sure that you don't have
 > any class files around since that gives yet another obscure error message.
 
 I'm compiling in the parent directory of javax, and sending the resulting 
 .class files to a seperate directory.
 
 example: gcj -C -I/usr/local/japhar/share/classpath -d /usr/local/japhar/share\
 /classpath javax/swing/JLayeredPane.java
 
 Is that what you mean?
 
 > P.S. Please CC java-gnats so your comments will make it into the bug database.
 
 Done.
 
 > P.P.S. Where can I find this Swing clean room implementation?
 > Are you going to merge it with Classpath/libgcj?
 
 Well, currently it resides only on my hard-drive.  I just accepted a position
 with the Maxim Group (I start July 31).  At somepoint after that I'll get the
 paperwork for FSF into RMS, and then add my source to the libgcj repository.
 
 I was kinda holding off, waiting for the Classpath implementation, but after 3
 months with no activity, figured it was time to put up or shutup... ;)
 
 
 Ian
 
 

From: Alexandre Petit-Bianco <apbianco@cygnus.com>
To: Mark Wielaard <mark@klomp.org>, idstewart@softhome.net
Cc: java-gnats@sourceware.cygnus.com
Subject: Re: gcj/283: GCJ fails to compile inner classes which extend another inner class
Date: Tue, 24 Oct 2000 10:09:24 -0700 (PDT)

 Mark Wielaard writes:
 
 >  Which is wrong since OuterB is in scope and is an instance of OuterA.
 
 Yes. Here's a patch.
 
 >  Note that as Bryce noted you want to make sure that you don't have
 >  any class files around since that gives yet another obscure error
 >  message.
 
 It might have been a temporary glitch. I wasn't able to reproduce the
 problem.
 
 ./A
 
 2000-10-24  Alexandre Petit-Bianco  <apbianco@cygnus.com>
 
 	* parse.h (INNER_ENCLOSING_SCOPE_CHECK): Check inherited type in
 	scope. Fixes gcj/283.
 
 Index: parse.h
 ===================================================================
 RCS file: /cvs/gcc/egcs/gcc/java/parse.h,v
 retrieving revision 1.61
 diff -u -p -r1.61 parse.h
 --- parse.h	2000/10/21 15:10:38	1.61
 +++ parse.h	2000/10/24 16:53:10
 @@ -861,6 +861,11 @@ struct parser_ctxt {
  			     TREE_TYPE (DECL_CONTEXT (TYPE_NAME (T))))	      \
          && !common_enclosing_context_p (TREE_TYPE (TREE_TYPE (current_this)), \
  					(T)))				      \
 +        && INNER_CLASS_TYPE_P (TREE_TYPE (TREE_TYPE (current_this)))	      \
 +        && !inherits_from_p 						      \
 +              (TREE_TYPE (DECL_CONTEXT 					      \
 +			  (TYPE_NAME (TREE_TYPE (TREE_TYPE (current_this))))),\
 +	       TREE_TYPE (DECL_CONTEXT (TYPE_NAME (T))))		      \
         /* We don't have a this. */					      \
         || !current_this))
  
State-Changed-From-To: open->feedback
State-Changed-By: apbianco
State-Changed-When: Tue Oct 24 10:20:15 2000
State-Changed-Why:
    Here's a patch:
      http://sources.redhat.com/ml/java-prs/2000-q4/msg00069.html

From: apbianco@cygnus.com
To: apbianco@cygnus.com, idstewart@softhome.net,
  java-gnats@sourceware.cygnus.com
Cc:  
Subject: Re: gcj/283
Date: 24 Oct 2000 17:20:16 -0000

 Synopsis: GCJ fails to compile inner classes which extend another inner class
 
 State-Changed-From-To: open->feedback
 State-Changed-By: apbianco
 State-Changed-When: Tue Oct 24 10:20:15 2000
 State-Changed-Why:
     Here's a patch:
       http://sources.redhat.com/ml/java-prs/2000-q4/msg00069.html
 
 http://sources.redhat.com/cgi-bin/gnatsweb.pl?cmd=view&pr=283&database=java

From: Mark Wielaard <mark@klomp.org>
To: apbianco@redhat.com
Cc: idstewart@softhome.net, java-gnats@sourceware.cygnus.com
Subject: Re: gcj/283: GCJ fails to compile inner classes which extend another inner class
Date: Tue, 24 Oct 2000 23:00:10 +0200

 Hi,
 
 On Tue, Oct 24, 2000 at 10:09:24AM -0700, Alexandre Petit-Bianco wrote:
 > 
 > Mark Wielaard writes:
 > 
 > >  Which is wrong since OuterB is in scope and is an instance of OuterA.
 > 
 > Yes. Here's a patch.
 
 That patch makes it possible to compile the classes.
 
 But I could not test everything since it seems that using this in an
 inner class goes wrong. e.g when compiling and running the following
 it should print Test$Inner@xxxxx but it print Test@xxxxx
 
 public class Test {
     public static void main(String[] args) {
         new Test().getInner().m();
     }
 
     public Inner getInner() {
         return new Inner();
     }
 
     public class Inner {
         public void m() {
             System.out.println(this.toString());
         }
     }
 }
 
 I will add this to the bug database if it is not already there.
 
 > >  Note that as Bryce noted you want to make sure that you don't have
 > >  any class files around since that gives yet another obscure error
 > >  message.
 > 
 > It might have been a temporary glitch. I wasn't able to reproduce the
 > problem.
 
 I also cannot reproduce this with a recent compiler.
 
 Thanks,
 
 Mark

From: Alexandre Petit-Bianco <apbianco@cygnus.com>
To: java-gnats@sourceware.cygnus.com
Cc:  
Subject: Re: gcj/283: GCJ fails to compile inner classes which extend another inner class
Date: Tue, 24 Oct 2000 16:27:33 -0700 (PDT)

 Alexandre Petit-Bianco writes:
 
 >  Yes. Here's a patch.
 
 That patch was bogus. Better use this one.
 
 ./A
 
 2000-10-24  Alexandre Petit-Bianco  <apbianco@cygnus.com>
 
 	* parse.h (INNER_ENCLOSING_SCOPE_CHECK): Check inherited type in
 	scope.
 
 Index: parse.h
 ===================================================================
 RCS file: /cvs/gcc/egcs/gcc/java/parse.h,v
 retrieving revision 1.61
 diff -u -p -r1.61 parse.h
 --- parse.h	2000/10/21 15:10:38	1.61
 +++ parse.h	2000/10/24 23:18:58
 @@ -860,7 +860,12 @@ struct parser_ctxt {
  	&& !inherits_from_p (TREE_TYPE (TREE_TYPE (current_this)),	      \
  			     TREE_TYPE (DECL_CONTEXT (TYPE_NAME (T))))	      \
          && !common_enclosing_context_p (TREE_TYPE (TREE_TYPE (current_this)), \
 -					(T)))				      \
 +					(T))				      \
 +        && INNER_CLASS_TYPE_P (TREE_TYPE (TREE_TYPE (current_this)))	      \
 +        && !inherits_from_p 						      \
 +              (TREE_TYPE (DECL_CONTEXT 					      \
 +			  (TYPE_NAME (TREE_TYPE (TREE_TYPE (current_this))))),\
 +	       TREE_TYPE (DECL_CONTEXT (TYPE_NAME (T)))))		      \
         /* We don't have a this. */					      \
         || !current_this))
  

From: Ian D. Stewart <idstewart@softhome.net>
To: apbianco@redhat.com,
 Mark Wielaard <mark@klomp.org>
Cc: java-gnats@sourceware.cygnus.com
Subject: Re: gcj/283: GCJ fails to compile inner classes which extend another inner class
Date: Tue, 24 Oct 2000 18:53:35 -0400

 On Tue, 24 Oct 2000, Alexandre Petit-Bianco wrote:
 > Mark Wielaard writes:
 > 
 > >  Which is wrong since OuterB is in scope and is an instance of OuterA.
 > 
 > Yes. Here's a patch.
 
 Wahoo!  Alexandre, you da man!!
 
 
 Ian

From: Mark Wielaard <mark@klomp.org>
To: java-gnats@sourceware.cygnus.com, idstewart@softhome.net,
	apbianco@cygnus.com
Cc:  
Subject: Re: gcj/283
Date: Wed, 25 Oct 2000 22:18:10 +0200

 Alexandre Petit-Bianco writes:
  
 > That patch was bogus. Better use this one.
 
 Oops. My comments were based on the first patch.
 Also note that I filed a few bug reports gcj/361, gcj/362 and gcj/363
 with that patch applied. I don't have time to check this new patch now.
 But I will rerun my tests this weekend. 
 
 Cheers,
 
 Mark
 
 http://sources.redhat.com/cgi-bin/gnatsweb.pl?cmd=view&pr=283&database=java

From: Alexandre Petit-Bianco <apbianco@cygnus.com>
To: Mark Wielaard <mark@klomp.org>
Cc: java-gnats@sourceware.cygnus.com, idstewart@softhome.net
Subject: Re: gcj/283
Date: Wed, 25 Oct 2000 13:21:52 -0700 (PDT)

 Mark Wielaard writes:
 
 > Also note that I filed a few bug reports gcj/361
 
 I have a patch for this I'll submit shortly.
 
 ./A

From: Mark Wielaard <mark@klomp.org>
To: apbianco@cygnus.com
Cc: java-prs@sourceware.cygnus.com
Subject: Re: gcj/283
Date: Fri, 27 Oct 2000 01:02:23 +0200

 Hi,
 
 On Wed, Oct 25, 2000 at 08:20:01PM -0000, Mark Wielaard wrote:
 >  Alexandre Petit-Bianco writes:
 >   
 >  > That patch was bogus. Better use this one.
 >  
 >  Oops. My comments were based on the first patch.
 
 OK I rechecked with a current compiler gcc version 2.97 20001026
 (experimental) with the second patch (plus the patch to gcj/361)
 applied and that fixes it.
 
 Thanks,
 
 Mark

From: Alexandre Petit-Bianco <apbianco@cygnus.com>
To: java-gnats@sourceware.cygnus.com
Cc:  
Subject: Re: gcj/283
Date: Thu, 26 Oct 2000 16:10:19 -0700 (PDT)

 Mark Wielaard writes:
 
 > OK I rechecked with a current compiler gcc version 2.97 20001026
 > (experimental) with the second patch (plus the patch to gcj/361)
 > applied and that fixes it.
 
 Cool. I'll check the fix in shortly.
 
 ./A
State-Changed-From-To: feedback->closed
State-Changed-By: apbianco
State-Changed-When: Tue Nov 21 21:25:51 2000
State-Changed-Why:
    I checked in the following patch:
      http://gcc.gnu.org/ml/gcc-patches/2000-11/msg01217.html

From: apbianco@cygnus.com
To: apbianco@cygnus.com, idstewart@softhome.net,
  java-gnats@sourceware.cygnus.com
Cc:  
Subject: Re: gcj/283
Date: 22 Nov 2000 05:25:51 -0000

 Synopsis: GCJ fails to compile inner classes which extend another inner class
 
 State-Changed-From-To: feedback->closed
 State-Changed-By: apbianco
 State-Changed-When: Tue Nov 21 21:25:51 2000
 State-Changed-Why:
     I checked in the following patch:
       http://gcc.gnu.org/ml/gcc-patches/2000-11/msg01217.html
 
 http://sources.redhat.com/cgi-bin/gnatsweb.pl?cmd=view&pr=283&database=java
>Unformatted:



^ permalink raw reply	[flat|nested] only message in thread

only message in thread, other threads:[~2000-12-20 12:24 UTC | newest]

Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2000-12-20 12:24 java/1304: GCJ fails to compile inner classes which extend another inner class idstewart

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).