FULL PRODUCT VERSION :
java version "1.8.0_25"
Java(TM) SE Runtime Environment (build 1.8.0_25-b17)
Java HotSpot(TM) 64-Bit Server VM (build 25.25-b02, mixed mode)
ADDITIONAL OS VERSION INFORMATION :
Darwin Brians-iMac.local 14.0.0 Darwin Kernel Version 14.0.0: Fri Sep 19 00:26:44 PDT 2014; root:xnu-2782.1.97~2/RELEASE_X86_64 x86_64
A DESCRIPTION OF THE PROBLEM :
I have a class that imports and implements java.io.Externalizable in a public static inner class. Unless the import for the java.io.Externalizable is BEFORE imports for other inner classes in the same file, javac fails too compile with a "cannot find symbol" error.
I put example code to reproduce this in the "Source code" section below.
EXPECTED VERSUS ACTUAL BEHAVIOR :
EXPECTED -
Successful compilation
ACTUAL -
com/inversoft/MyClass.java:19: error: cannot find symbol
public static class MyInnerClass implements Externalizable {
^
symbol: class Externalizable
location: class MyClass
com/inversoft/MyClass.java:20: error: method does not override or implement a method from a supertype
@Override
^
com/inversoft/MyClass.java:25: error: method does not override or implement a method from a supertype
@Override
^
3 errors
REPRODUCIBILITY :
This bug can be reproduced always.
---------- BEGIN SOURCE ----------
Here's a small test case class that always fails:
package com.inversoft;
import com.inversoft.MyClass.MyInnerClass.MyOtherClass;
import java.io.Externalizable;
import java.io.IOException;
import java.io.ObjectInput;
import java.io.ObjectOutput;
import java.time.ZonedDateTime;
import java.util.HashMap;
import java.util.Map;
import java.util.UUID;
public class MyClass {
public MyClass(MyOtherClass c) {
c.go();
}
public static class MyInnerClass implements Externalizable {
@Override
public void readExternal(ObjectInput in) throws IOException, ClassNotFoundException {
}
@Override
public void writeExternal(ObjectOutput out) throws IOException {
}
public static class MyOtherClass {
public void go() {
System.out.println("Here");
}
}
}
}
Here's the same class that compiles successfully:
package com.inversoft;
import java.io.Externalizable;
import java.io.IOException;
import java.io.ObjectInput;
import java.io.ObjectOutput;
import java.time.ZonedDateTime;
import java.util.HashMap;
import java.util.Map;
import java.util.UUID;
import com.inversoft.MyClass.MyInnerClass.MyOtherClass;
public class MyClass {
public MyClass(MyOtherClass c) {
c.go();
}
public static class MyInnerClass implements Externalizable {
@Override
public void readExternal(ObjectInput in) throws IOException, ClassNotFoundException {
}
@Override
public void writeExternal(ObjectOutput out) throws IOException {
}
public static class MyOtherClass {
public void go() {
System.out.println("Here");
}
}
}
}
---------- END SOURCE ----------
CUSTOMER SUBMITTED WORKAROUND :
Re-organize the imports and this works fine.