JDK-6974016 : Bogus error on superclass of nested class with imported member
  • Type: Bug
  • Component: tools
  • Sub-Component: javac
  • Affected Version: 7
  • Priority: P4
  • Status: Closed
  • Resolution: Duplicate
  • OS: linux
  • CPU: x86
  • Submitted: 2010-08-03
  • Updated: 2012-03-20
  • Resolved: 2010-12-01
Related Reports
Duplicate :  
Description
FULL PRODUCT VERSION :
java version "1.6.0_18"
OpenJDK Runtime Environment (IcedTea6 1.8) (fedora-41.b18.fc13-x86_64)
OpenJDK 64-Bit Server VM (build 14.0-b16, mixed mode)

ADDITIONAL OS VERSION INFORMATION :
Linux mattlaptop2.local 2.6.33.6-147.2.4.fc13.x86_64 #1 SMP Fri Jul 23 17:14:44 UTC 2010 x86_64 x86_64 x86_64 GNU/Linux

A DESCRIPTION OF THE PROBLEM :
Consider a nested class whose superclass is in another package and is referenced via an import statement.  If a member of the nested class is imported before the superclass is imported, javac issues a bogus compile error that the superclass cannot be found.  Eclipse compiles the code successfully.

STEPS TO FOLLOW TO REPRODUCE THE PROBLEM :
Compile the test case.

EXPECTED VERSUS ACTUAL BEHAVIOR :
EXPECTED -
Successful compilation.

ERROR MESSAGES/STACK TRACES THAT OCCUR :
ImportNotRecognized.java:7: cannot find symbol
symbol  : class BitSet
location: class test.ImportNotRecognized
  static class Nested extends BitSet {
                              ^

REPRODUCIBILITY :
This bug can be reproduced always.

---------- BEGIN SOURCE ----------
package test;

import static test.ImportNotRecognized.Nested.answer;
import java.util.BitSet;

class ImportNotRecognized {
  static class Nested extends BitSet {
    static final int answer = 42;
  }
  static final int answer2 = answer + 1;
}
---------- END SOURCE ----------

CUSTOMER SUBMITTED WORKAROUND :
Use the fully qualified name of the superclass.

Comments
WORK AROUND invert the order of the import statements
01-12-2010