java-decompiler: fixes and cleanups

- unified attribute loading code
- common methods for checking member flags
- verifying skip()
- correct resource closing
- typos
This commit is contained in:
Roman Shevchenko
2014-09-02 20:56:03 +04:00
parent c0c83126a6
commit 2df49d32a7
31 changed files with 586 additions and 1012 deletions

View File

@@ -19,6 +19,7 @@ import org.jetbrains.java.decompiler.main.DecompilerContext;
import org.jetbrains.java.decompiler.main.extern.IDecompilatSaver;
import org.jetbrains.java.decompiler.main.extern.IFernflowerLogger;
import org.jetbrains.java.decompiler.struct.lazy.LazyLoader;
import org.jetbrains.java.decompiler.util.DataInputFullStream;
import java.io.File;
import java.io.IOException;
@@ -136,7 +137,15 @@ public class StructContext {
if (filename.endsWith(".class")) {
try {
StructClass cl = new StructClass(loader.getClassStream(file.getAbsolutePath(), null), isOwn, loader);
StructClass cl;
DataInputFullStream in = loader.getClassStream(file.getAbsolutePath(), null);
try {
cl = new StructClass(in, isOwn, loader);
}
finally {
in.close();
}
classes.put(cl.qualifiedName, cl);
unit.addClass(cl, filename);
@@ -145,8 +154,8 @@ public class StructContext {
isClass = true;
}
catch (IOException ex) {
DecompilerContext.getLogger()
.writeMessage("Invalid class file: " + (path.length() > 0 ? path + "/" : "") + filename, IFernflowerLogger.ERROR);
DecompilerContext.getLogger().writeMessage("Invalid class file: " + (path.length() > 0 ? path + "/" : "") + filename,
IFernflowerLogger.ERROR);
}
}