Details
-
Bug
-
Resolution: Unresolved
-
P4
-
7u51
Description
I've gotten a number of BadClassFile exceptions in the past, in the form of:
com.sun.tools.javac.jvm.ClassReader$BadClassFile: bad class file: javax.swing.JSlider$1SmartHashtable$LabelUIResource
class file contains wrong class: javax.swing.JSlider
Please remove or make sure it appears in the correct subdirectory of the classpath.
at com.sun.tools.javac.jvm.ClassReader.badClassFile(ClassReader.java:325)
at com.sun.tools.javac.jvm.ClassReader.readClass(ClassReader.java:1909)
at com.sun.tools.javac.jvm.ClassReader.readClassFile(ClassReader.java:2020)
at com.sun.tools.javac.jvm.ClassReader.fillIn(ClassReader.java:2208)
at com.sun.tools.javac.jvm.ClassReader.complete(ClassReader.java:2139)
Web searches turn up a number of other people scratching their head about this one.
The exception is caused by a JavaFileObject returning an empty stream from the call JavaFileObject.getInputStream().
If you look at com.sun.tools.javac.jvm.ClassReader, around line 2463:
buf = readInputStream(buf, classfile.openInputStream());
readClassFile(c);
You'll find that 'buf' is not emptied out first, so if JavaFileObject.openInputStream() returns an empty stream, Javac is still reading from the previous class file, and throws the mysterious and misleading exception above. Possible fix would be to empty 'buf' and check for empty 'buf' and either throw an exception with the real cause (empty class file) or give a proper error.
com.sun.tools.javac.jvm.ClassReader$BadClassFile: bad class file: javax.swing.JSlider$1SmartHashtable$LabelUIResource
class file contains wrong class: javax.swing.JSlider
Please remove or make sure it appears in the correct subdirectory of the classpath.
at com.sun.tools.javac.jvm.ClassReader.badClassFile(ClassReader.java:325)
at com.sun.tools.javac.jvm.ClassReader.readClass(ClassReader.java:1909)
at com.sun.tools.javac.jvm.ClassReader.readClassFile(ClassReader.java:2020)
at com.sun.tools.javac.jvm.ClassReader.fillIn(ClassReader.java:2208)
at com.sun.tools.javac.jvm.ClassReader.complete(ClassReader.java:2139)
Web searches turn up a number of other people scratching their head about this one.
The exception is caused by a JavaFileObject returning an empty stream from the call JavaFileObject.getInputStream().
If you look at com.sun.tools.javac.jvm.ClassReader, around line 2463:
buf = readInputStream(buf, classfile.openInputStream());
readClassFile(c);
You'll find that 'buf' is not emptied out first, so if JavaFileObject.openInputStream() returns an empty stream, Javac is still reading from the previous class file, and throws the mysterious and misleading exception above. Possible fix would be to empty 'buf' and check for empty 'buf' and either throw an exception with the real cause (empty class file) or give a proper error.