Modify

Opened 15 years ago

Last modified 15 years ago

#230 new defect

GJ has problems with inner classes

Reported by: Thorsten Meinl Owned by: moschny
Priority: normal Milestone:
Component: gjc Version: 1.00
Severity: normal Keywords:
Cc:

Description

Members of nested static (=inner) classes don't hide members of their surrounding class.

A.java:

public class A {
        public Object test;
}

B.java:

public class B {
        public Object test;

        public static class C extends A {

                public void method() {
                        System.out.println(test);
                }
        }
}

GJ prints the following error message:

B.java:7: variable test is inherited from class A and hides a variable 
of the same name in class B. An explicit `this' qualifier must be used 
to select the desired instance
                        System.out.println(test);

This is obviously wrong as the inner class C is static and therefore has no access to the member B.test. Suns javac and the Eclipse compiler do it right.

Attachments (0)

Change History (3)

comment:1 Changed 15 years ago by hauma

  • Summary changed from GJ has problems with inner classes to GJ uses wrong visibility rules for inner classes

comment:2 Changed 15 years ago by moschny

  • Summary changed from GJ uses wrong visibility rules for inner classes to GJ has problems with inner classes

There seem to be more bugs than just visibility rules.

comment:3 Changed 15 years ago by hauma

There seem to be more bugs than just visibility rules.

Of cause, but the ticket name should be as specific as possible. From the problem description, this seems to be a visibility problem. There are other tickets dealing with "problems with inner classes", e.g. ticket:234.

Add Comment

Modify Ticket

Change Properties
Set your email in Preferences
Action
as new The owner will remain moschny.
as The resolution will be set. Next status will be 'closed'.
to The owner will be changed from moschny to the specified user. Next status will be 'new'.
The owner will be changed from moschny to anonymous. Next status will be 'assigned'.
Author


E-mail address and user name can be saved in the Preferences.

 
Note: See TracTickets for help on using tickets.