JDK-6707323 : javac fails to compile inner class when secondary inner class is involved: "cannot find symbol"
  • Type: Bug
  • Component: tools
  • Sub-Component: javac
  • Affected Version: 6,6u18
  • Priority: P3
  • Status: Closed
  • Resolution: Duplicate
  • OS: solaris,solaris_10
  • CPU: sparc
  • Submitted: 2008-05-27
  • Updated: 2013-06-04
  • Resolved: 2013-06-04
The Version table provides details related to the release that this issue/RFE will be addressed.

Unresolved : Release in which this issue/RFE will be addressed.
Resolved: Release in which this issue/RFE has been resolved.
Fixed : Release in which this issue/RFE has been fixed. The release containing this fix may be available for download as an Early Access Release or a General Availability Release.

To download the current JDK release, click here.
JDK 8
8Resolved
Related Reports
Duplicate :  
Description
Javac fails to compile inner class, when a secondary inner class (inner class of the inner class)
is imported first. It appears that importing a secondary inner class hides symbols in inner class.

The problem can be cured by changing the sequence of import statements.

The problem is easily reproducible.

1. Testcase
-----------
 The testcase consists of two files:
     abc/TestClass.java
     def/BaseClass.java

% more abc/TestClass.java
package abc;

// Compile error with JavaSE 6, but not with JavaSE 1.4.2:

import abc.TestClass.TTT.CCC;
import def.BaseClass;

public class TestClass
{
        CCC ccc;

        public class TTT extends BaseClass {
                public class CCC {
                        public CCC() {}
                }
        }
}

% more def/BaseClass.java
package def;

public class BaseClass
{
        public BaseClass() {}
}


2. Compile w/ 6u6
-----------------
% /jdk1.6.0_06/bin/javac def/BaseClass.java abc/TestClass.java 
abc/TestClass.java:12: cannot find symbol
symbol  : class BaseClass
location: class abc.TestClass
        public class TTT extends BaseClass {
                                 ^
1 error
%

3. Change source - works fine
-----------------------------
 Change the sequence of import statements in abc/TestClass.java
 from
    import abc.TestClass.TTT.CCC;
    import def.BaseClass;
 to
    import def.BaseClass;
    import abc.TestClass.TTT.CCC;
 and compile again:

% /jdk1.6.0_06/bin/javac def/BaseClass.java abc/TestClass.java 
%


4. Problem reproducible w/ JDK 1.5.0
------------------------------------
% /jdk1.5.0_17/bin/javac def/BaseClass.java abc/TestClass.java 
abc/TestClass.java:12: cannot find symbol
symbol  : class BaseClass
location: class abc.TestClass
        public class TTT extends BaseClass {
                                 ^
1 error
%


5. Problem not reproducible w/ J2SDK 1.4.2
------------------------------------------
% /j2sdk1.4.2_17/bin/javac def/BaseClass.java abc/TestClass.java 
%

Comments
WORK AROUND change sequence of import statements
27-05-2008