java/1276: Cannot cast to inner class

mark@klomp.org mark@klomp.org
Wed Dec 20 12:23:00 GMT 2000


>Number:         1276
>Category:       java
>Synopsis:       Cannot cast to 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:36 PST 2000
>Closed-Date:    Fri Jul 21 17:51:39 PDT 2000
>Last-Modified:  Thu Jul 27 04:30:01 PDT 2000
>Originator:     mark@klomp.org
>Release:        gcc version 2.96 20000602 (experimental)
>Organization:
>Environment:

>Description:
The following legal java code does not compile:

public class A {
    public static void main(String args[]) {
        B.C bc = (B.C) new B.C();
    }
}

class B {
    static class C {
    }
}

compiling with 'gcj --main=A A.java' gives:

A.java: In class `A':
A.java: In method `main(java.lang.String[])':
A.java:3: Class `B.C' not found in type declaration.
        B.C bc = (B.C) new B.C();
                  ^
1 error
>How-To-Repeat:

>Fix:

>Release-Note:

>Audit-Trail:

Formerly PR gcj/257


From: Mark Wielaard <mark@klomp.org>
To: java-gnats@sourceware.cygnus.com
Cc:  
Subject: Re: gcj/257 (workaround)
Date: Fri, 14 Jul 2000 14:37:51 +0200

 http://sources.redhat.com/cgi-bin/gnatsweb.pl?cmd=view&pr=257&database=java
 
 As a workaround you can cast to (B$C) which is accepted by gcj.
 (But not by jikes and it seems wrong that gcj accepts it.)
State-Changed-From-To: open->feedback
State-Changed-By: apbianco
State-Changed-When: Thu Jul 20 01:32:11 2000
State-Changed-Why:
    Thanks. I attached a patch. The `$' isn't allowed in type
    names (but it is in identifiers.)

From: apbianco@cygnus.com
To: apbianco@cygnus.com, java-gnats@sourceware.cygnus.com, mark@klomp.org
Cc:  
Subject: Re: gcj/257
Date: 20 Jul 2000 08:32:11 -0000

 Synopsis: Cannot cast to inner class
 
 State-Changed-From-To: open->feedback
 State-Changed-By: apbianco
 State-Changed-When: Thu Jul 20 01:32:11 2000
 State-Changed-Why:
     Thanks. I attached a patch. The `$' isn't allowed in type
     names (but it is in identifiers.)
 
 http://sources.redhat.com/cgi-bin/gnatsweb.pl?cmd=view&pr=257&database=java

From: Mark Wielaard <mark@klomp.org>
To: apbianco@cygnus.com
Cc: java-gnats@sourceware.cygnus.com
Subject: Re: gcj/257
Date: Thu, 20 Jul 2000 10:57:53 +0200

 >     Thanks. I attached a patch. The `$' isn't allowed in type
 >     names (but it is in identifiers.)
 
 Great! This patch finally makes it possible to compile java.util.jar
 and part of the Collection classes from Classpath. Thanks.
 
 Note that although gcj/288 seems similar the patch doesn't solve that bug.

From: Alexandre Petit-Bianco <apbianco@cygnus.com>
To: java-gnats@sourceware.cygnus.com
Cc:  
Subject: Re: gcj/257
Date: Thu, 20 Jul 2000 10:06:39 -0700 (PDT)

 Bryce McKinlay writes:
 
 >  Note that although gcj/288 seems similar the patch doesn't solve
 >  that bug.
 
 I yet have to address this bug.
 
 ./A
State-Changed-From-To: feedback->closed
State-Changed-By: apbianco
State-Changed-When: Fri Jul 21 17:51:39 2000
State-Changed-Why:
    Bryce hinted that he liked the fix. I checked the patch in and I'm also
    closing this PR:
    
      http://gcc.gnu.org/ml/gcc-patches/2000-07/msg00869.html

From: apbianco@cygnus.com
To: apbianco@cygnus.com, java-gnats@sourceware.cygnus.com, mark@klomp.org
Cc:  
Subject: Re: gcj/257
Date: 22 Jul 2000 00:51:39 -0000

 Synopsis: Cannot cast to inner class
 
 State-Changed-From-To: feedback->closed
 State-Changed-By: apbianco
 State-Changed-When: Fri Jul 21 17:51:39 2000
 State-Changed-Why:
     Bryce hinted that he liked the fix. I checked the patch in and I'm also
     closing this PR:
     
       http://gcc.gnu.org/ml/gcc-patches/2000-07/msg00869.html
 
 http://sources.redhat.com/cgi-bin/gnatsweb.pl?cmd=view&pr=257&database=java

From: Alexandre Petit-Bianco <apbianco@cygnus.com>
To: java-gnats@sourceware.cygnus.com
Cc:  
Subject: Re: gcj/257
Date: Fri, 21 Jul 2000 22:38:17 -0700 (PDT)

 apbianco@cygnus.com writes:
 >      Thanks. I attached a patch. The `$' isn't allowed in type
 >      names (but it is in identifiers.)
 
 Hm. Per Bothner pointed out that I was wrong. I'm preparing an other
 patch.
 
 ./A

From: Alexandre Petit-Bianco <apbianco@cygnus.com>
To: java-gnats@sourceware.cygnus.com
Cc:  
Subject: Re: gcj/257 (workaround)
Date: Fri, 21 Jul 2000 22:44:40 -0700 (PDT)

 Mark Wielaard writes:
 
 >  As a workaround you can cast to (B$C) which is accepted by gcj.
 >  (But not by jikes and it seems wrong that gcj accepts it.)
 
 It is, because `$' isn't a qualified expression separator. Jikes is
 right to reject it and most likely accepts something like:
 
   class A$B {}
   class C { A$B x = null;}
 
 Compilers of some versions of the JDK accept it interesting ways:
 jdk117 accepts the following:
 
   class a$b {}
   class z {
     Z$C x = null;
     a$b y = null;
   }
 
   class Z {class C {}}
 
 I.e. will accept a class called a$b and will take the liberty to
 interpret Z$C as a qualified expression to point at inner class C.
 
 In the light of these facts, I'm going to amend my patch to 257.
 
 ./A

From: Alexandre Petit-Bianco <apbianco@cygnus.com>
To: java-gnats@sourceware.cygnus.com
Cc:  
Subject: Re: gcj/257 (workaround)
Date: Thu, 27 Jul 2000 04:21:02 -0700 (PDT)

 Alexandre Petit-Bianco writes:
 
 >  In the light of these facts, I'm going to amend my patch to 257.
 
 And I just did. See http://gcc.gnu.org/ml/gcc-patches/2000-07/msg01109.html
 
 ./A
>Unformatted:
----gnatsweb-attachment----
Content-Type: application/octet-stream; name="patch"
Content-Transfer-Encoding: base64
Content-Disposition: attachment; filename="patch"

MjAwMC0wNy0xOSAgQWxleGFuZHJlIFBldGl0LUJpYW5jbyAgPGFwYmlhbmNvQGN5Z251cy5jb20+
CgogICAgICAgICogcGFyc2UueSAoc2ltcGxlX25hbWU6KTogUmVqZWN0IGAkJyBpbiB0eXBlIG5h
bWVzLgoJKHJlc29sdmVfdHlwZV9kdXJpbmdfcGF0Y2gpOiBVc2UgYHR5cGUnIGFzIGEgc2Vjb25k
Cglhcmd1bWVudCB0byByZXNvbHZlX25vX2xheW91dC4gRml4ZXMgZ2NqLzI1Ny4KCkluZGV4OiBw
YXJzZS55Cj09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09
PT09PT09PT09PT09PT09PT0KZGlmZiAtdSAtcCBwYXJzZS55Ci0tLSBvbGQtcGFyc2UueQlXZWQg
SnVsIDE5IDIwOjQ4OjM1IDIwMDAKKysrIHBhcnNlLnkJVGh1IEp1bCAyMCAwMDo1MjoyMiAyMDAw
CkBAIC02NDIsNiArNjQyLDExIEBAIG5hbWU6CiAKIHNpbXBsZV9uYW1lOgogCWlkZW50aWZpZXIJ
CS8qIERlZmF1bHQgcnVsZSAqLworCXsKKwkgIGlmIChzdHJjaHIgKElERU5USUZJRVJfUE9JTlRF
UiAoRVhQUl9XRkxfTk9ERSAoJCQpKSwgJyQnKSkKKwkgICAgcGFyc2VfZXJyb3JfY29udGV4dCAo
JCQsICJJbnZhbGlkZSBuYW1lIGAlcyciLAorCQkJCSBJREVOVElGSUVSX1BPSU5URVIgKEVYUFJf
V0ZMX05PREUgKCQkKSkpOworCX0KIDsKIAogcXVhbGlmaWVkX25hbWU6CkBAIC0xMzI2OCw3ICsx
MzMyOSw3IEBAIHJlc29sdmVfdHlwZV9kdXJpbmdfcGF0Y2ggKHR5cGUpCiB7CiAgIGlmICh1bnJl
c29sdmVkX3R5cGVfcCAodHlwZSwgTlVMTCkpCiAgICAgewotICAgICAgdHJlZSB0eXBlX2RlY2wg
PSByZXNvbHZlX25vX2xheW91dCAoRVhQUl9XRkxfTk9ERSAodHlwZSksIE5VTExfVFJFRSk7Cisg
ICAgICB0cmVlIHR5cGVfZGVjbCA9IHJlc29sdmVfbm9fbGF5b3V0IChFWFBSX1dGTF9OT0RFICh0
eXBlKSwgdHlwZSk7CiAgICAgICBpZiAoIXR5cGVfZGVjbCkKIAl7CiAJICBwYXJzZV9lcnJvcl9j
b250ZXh0ICh0eXBlLCAK




More information about the Gcc-prs mailing list