gcj/194: gcj does not look in superclass scope for inner classes

mdejong@cygnus.com mdejong@cygnus.com
Sat Apr 8 23:30:00 GMT 2000


>Number:         194
>Category:       gcj
>Synopsis:       gcj does not look in superclass scope for inner classes
>Confidential:   no
>Severity:       serious
>Priority:       medium
>Responsible:    apbianco
>State:          open
>Class:          sw-bug
>Submitter-Id:   net
>Arrival-Date:   Sat Apr 08 23:30:01 PDT 2000
>Closed-Date:
>Last-Modified:
>Originator:     Mo
>Release:        egcs CVS as of Sat Apr 8 2000
>Organization:
>Environment:
I was running this on a Red Hat 5.2 box (Intel). I compile
egcs and libjava from the CVS today (Sat Apr 8 2000).
>Description:
I tried to compile the following two classes.

// File InnerClass.java

public class InnerClass {
    public class MyInner {}
}

// File InnerClass_Test.java

public class InnerClass_Test extends InnerClass {
    void foo() {
	MyInner mi = new MyInner();	
    }
}


I can compile them just fine with javac and jikes,
but gcj does not seem to know that it should look
inside the scope of it's superclass for class names.

% javac InnerClass.java InnerClass_Test.java 

% jikes InnerClass.java InnerClass_Test.java

% rm *.class

% gcj -c InnerClass.java InnerClass_Test.java
InnerClass_Test.java:5: Type `MyInner' not found in the declaration of the local variable `mi'.
        MyInner mi = new MyInner();

Now here is where it gets a little strange.
If you do the following, you get a different error.

% gcj -C InnerClass.java

% ls *.class
InnerClass$MyInner.class  InnerClass.class

% gcj -C InnerClass_Test.java
InnerClass_Test.java: In class `InnerClass_Test':
InnerClass_Test.java: In method `foo()':
InnerClass_Test.java:5: No enclosing instance for inner class `InnerClass$MyInner' is in scope; an explicit one must be provided when creating this inner class.
        MyInner mi = new MyInner();
                         ^
1 error



Either way, gcj is broken. It should look in the super
class to find the class in the first case, and it should
not give the second error if a .class file for the
super class is found.
>How-To-Repeat:
See above.
>Fix:

>Release-Note:
>Audit-Trail:
>Unformatted:
----gnatsweb-attachment----
Content-Type: application/octet-stream; name="InnerClass.java"
Content-Transfer-Encoding: base64
Content-Disposition: attachment; filename="InnerClass.java"

Ly8gRmlsZSBJbm5lckNsYXNzLmphdmEKCnB1YmxpYyBjbGFzcyBJbm5lckNsYXNzIHsKICAgIHB1
YmxpYyBjbGFzcyBNeUlubmVyIHt9Cn0K


More information about the Java-prs mailing list