Reputation: 579
I've googled around on internet, but haven't found a problem exactly matching mine. So, I decided to post here.
Recently, our ANT building is throwing the following exception intermittently. And it's becoming more and more frequent.
The issue looks like related to:
However, the test case runs pretty OK on our JVM (IBM Java 7.1). So, the bug mentioned above shouldn't be the cause anymore.
I looked into the source code of the compiler, though I'm not quite good at it.
ZipFileIndex.class
public class ZipFileIndex
{
.......
private SoftReference<Inflater> inflaterRef;
......
private int inflate(byte[] paramArrayOfByte1, byte[] paramArrayOfByte2)
{
Inflater localInflater = this.inflaterRef == null ? null : (Inflater)this.inflaterRef.get();
if (localInflater == null) {
this.inflaterRef = new SoftReference(localInflater = new Inflater(true));
}
localInflater.reset();
localInflater.setInput(paramArrayOfByte1);
try {
return localInflater.inflate(paramArrayOfByte2); } catch (DataFormatException localDataFormatException) {
}
return -1;
}
......
}
Inflater.class
......
public void reset() {
synchronized (zsRef) {
ensureOpen();
reset(zsRef.address());
buf = defaultBuf;
finished = false;
needDict = false;
off = len = 0;
}
}
......
public void end() {
synchronized (zsRef) {
long addr = zsRef.address();
zsRef.clear();
if (addr != 0) {
end(addr);
buf = null;
}
}
}
/**
* Closes the decompressor when garbage is collected.
*/
protected void finalize() {
end();
}
private void ensureOpen () {
assert Thread.holdsLock(zsRef);
if (zsRef.address() == 0)
throw new NullPointerException("Inflater has been closed");
}
......
The "SoftReference" is very suspicous. Our ANT building can easily reach above 1024m, and I can still see the exception when setting MAX HeapSize to 1024m. (now I've changed it to 2048m, fingers crossed).
If this.inflaterRef is being collected right after initialization:
Here are my questions:
Here is the stack trace*
An exception has occurred in the compiler (1.7.0-internal). Please file a bug at the Java Developer Connection (http://java.sun.com/webapps/bugreport) after checking the Bug Parade for duplicates. Include your program and the following diagnostic in your report. Thank you. java.lang.NullPointerException: Inflater has been closed at java.util.zip.Inflater.ensureOpen(Inflater.java:413) at java.util.zip.Inflater.reset(Inflater.java:375) at com.sun.tools.javac.file.ZipFileIndex.inflate(ZipFileIndex.java:467) at com.sun.tools.javac.file.ZipFileIndex.readBytes(ZipFileIndex.java:403) at com.sun.tools.javac.file.ZipFileIndex.read(ZipFileIndex.java:372) at com.sun.tools.javac.file.ZipFileIndex.read(ZipFileIndex.java:372) at com.sun.tools.javac.file.ZipFileIndexArchive$ZipFileIndexFileObject.openInputStream(ZipFileIndexArchive.java:163) at com.sun.tools.javac.jvm.ClassReader.fillIn(ClassReader.java:2219) at com.sun.tools.javac.jvm.ClassReader.complete(ClassReader.java:2151) at com.sun.tools.javac.code.Symbol.complete(Symbol.java:433) at com.sun.tools.javac.code.Symbol$ClassSymbol.complete(Symbol.java:833) at com.sun.tools.javac.jvm.ClassReader.loadClass(ClassReader.java:2332) at com.sun.tools.javac.comp.Resolve.loadClass(Resolve.java:1074) at com.sun.tools.javac.comp.Resolve.findIdentInPackage(Resolve.java:1239) at com.sun.tools.javac.comp.Attr.selectSym(Attr.java:2404) at com.sun.tools.javac.comp.Attr.visitSelect(Attr.java:2295) at com.sun.tools.javac.tree.JCTree$JCFieldAccess.accept(JCTree.java:1689)
Upvotes: 2
Views: 2223
Reputation: 579
In the past week, with ANT_OPTS setting to -Xms512m -Xmx2048m, the problem hasn't happened again.
BTW, it doesn't work when setting JAVA_OPTS to -Xms512m -Xmx2048m for ANT.
Upvotes: 0