java-decompiler: fixes and cleanups
- console decompiler: resource closing, lookup instead of scan, error reporting - logger interface reworked - saver interface renamed - bytecode provider returns byte array (to reduce stream leakage) - extra level of context unit avoided - unneeded exceptions, dead code, formatting
This commit is contained in:
@@ -15,7 +15,7 @@
|
||||
*/
|
||||
package org.jetbrains.java.decompiler.struct;
|
||||
|
||||
import org.jetbrains.java.decompiler.main.extern.IDecompilatSaver;
|
||||
import org.jetbrains.java.decompiler.main.extern.IResultSaver;
|
||||
import org.jetbrains.java.decompiler.struct.lazy.LazyLoader;
|
||||
import org.jetbrains.java.decompiler.struct.lazy.LazyLoader.Link;
|
||||
import org.jetbrains.java.decompiler.util.DataInputFullStream;
|
||||
@@ -23,6 +23,7 @@ import org.jetbrains.java.decompiler.util.DataInputFullStream;
|
||||
import java.io.IOException;
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
import java.util.jar.JarFile;
|
||||
import java.util.jar.Manifest;
|
||||
|
||||
public class ContextUnit {
|
||||
@@ -31,168 +32,125 @@ public class ContextUnit {
|
||||
public static final int TYPE_JAR = 1;
|
||||
public static final int TYPE_ZIP = 2;
|
||||
|
||||
private static final String MANIFEST_ENTRY = "META-INF/MANIFEST.MF";
|
||||
private final int type;
|
||||
private final boolean own;
|
||||
|
||||
// *****************************************************************************
|
||||
// private fields
|
||||
// *****************************************************************************
|
||||
private final String archivePath; // relative path to jar/zip
|
||||
private final String filename; // folder: relative path, archive: file name
|
||||
private final IResultSaver resultSaver;
|
||||
private final IDecompiledData decompiledData;
|
||||
|
||||
private int type;
|
||||
|
||||
// relative path to jar/zip
|
||||
private String archivepath;
|
||||
|
||||
// folder: relative path
|
||||
// archive: file name
|
||||
private String filename;
|
||||
private final List<String> classEntries = new ArrayList<String>(); // class file or jar/zip entry
|
||||
private final List<String> dirEntries = new ArrayList<String>();
|
||||
private final List<String[]> otherEntries = new ArrayList<String[]>();
|
||||
|
||||
private List<StructClass> classes = new ArrayList<StructClass>();
|
||||
|
||||
// class file or jar/zip entry. Should, but doesn't have to be the same as qualifiedName of the class
|
||||
private List<String> classentries = new ArrayList<String>();
|
||||
|
||||
private List<String> direntries = new ArrayList<String>();
|
||||
|
||||
private List<String[]> otherentries = new ArrayList<String[]>();
|
||||
|
||||
private Manifest manifest;
|
||||
|
||||
private IDecompilatSaver decompilatSaver;
|
||||
|
||||
private IDecompiledData decompiledData;
|
||||
|
||||
private boolean own = true;
|
||||
|
||||
// *****************************************************************************
|
||||
// constructors
|
||||
// *****************************************************************************
|
||||
|
||||
public ContextUnit(int type, String archivepath, String filename, boolean own,
|
||||
IDecompilatSaver decompilatSaver, IDecompiledData decompiledData) {
|
||||
public ContextUnit(int type, String archivePath, String filename, boolean own, IResultSaver resultSaver, IDecompiledData decompiledData) {
|
||||
this.type = type;
|
||||
this.own = own;
|
||||
this.archivepath = archivepath;
|
||||
this.archivePath = archivePath;
|
||||
this.filename = filename;
|
||||
this.decompilatSaver = decompilatSaver;
|
||||
this.resultSaver = resultSaver;
|
||||
this.decompiledData = decompiledData;
|
||||
}
|
||||
|
||||
// *****************************************************************************
|
||||
// public methods
|
||||
// *****************************************************************************
|
||||
|
||||
public void addClass(StructClass cl, String entryname) {
|
||||
public void addClass(StructClass cl, String entryName) {
|
||||
classes.add(cl);
|
||||
classentries.add(entryname);
|
||||
classEntries.add(entryName);
|
||||
}
|
||||
|
||||
public void addDirEntry(String entry) {
|
||||
direntries.add(entry);
|
||||
dirEntries.add(entry);
|
||||
}
|
||||
|
||||
public void addOtherEntry(String fullpath, String entry) {
|
||||
otherentries.add(new String[]{fullpath, entry});
|
||||
public void addOtherEntry(String fullPath, String entry) {
|
||||
otherEntries.add(new String[]{fullPath, entry});
|
||||
}
|
||||
|
||||
public void reload(LazyLoader loader) throws IOException {
|
||||
|
||||
List<StructClass> lstClasses = new ArrayList<StructClass>();
|
||||
for (StructClass cl : classes) {
|
||||
String oldname = cl.qualifiedName;
|
||||
|
||||
StructClass newcl;
|
||||
DataInputFullStream in = loader.getClassStream(oldname);
|
||||
for (StructClass cl : classes) {
|
||||
String oldName = cl.qualifiedName;
|
||||
|
||||
StructClass newCl;
|
||||
DataInputFullStream in = loader.getClassStream(oldName);
|
||||
try {
|
||||
newcl = new StructClass(in, cl.isOwn(), loader);
|
||||
newCl = new StructClass(in, cl.isOwn(), loader);
|
||||
}
|
||||
finally {
|
||||
in.close();
|
||||
}
|
||||
|
||||
lstClasses.add(newcl);
|
||||
lstClasses.add(newCl);
|
||||
|
||||
Link lnk = loader.getClassLink(oldname);
|
||||
loader.removeClassLink(oldname);
|
||||
loader.addClassLink(newcl.qualifiedName, lnk);
|
||||
Link lnk = loader.getClassLink(oldName);
|
||||
loader.removeClassLink(oldName);
|
||||
loader.addClassLink(newCl.qualifiedName, lnk);
|
||||
}
|
||||
|
||||
classes = lstClasses;
|
||||
}
|
||||
|
||||
public void save() {
|
||||
|
||||
switch (type) {
|
||||
case TYPE_FOLDER:
|
||||
|
||||
// create folder
|
||||
decompilatSaver.saveFolder(filename);
|
||||
resultSaver.saveFolder(filename);
|
||||
|
||||
// non-class files
|
||||
for (String[] arr : otherentries) {
|
||||
decompilatSaver.copyFile(arr[0], filename, arr[0]);
|
||||
for (String[] pair : otherEntries) {
|
||||
resultSaver.copyFile(pair[0], filename, pair[1]);
|
||||
}
|
||||
|
||||
// classes
|
||||
for (int i = 0; i < classes.size(); i++) {
|
||||
|
||||
StructClass cl = classes.get(i);
|
||||
String entryname = classentries.get(i);
|
||||
|
||||
entryname = decompiledData.getClassEntryName(cl, entryname);
|
||||
if (entryname != null) {
|
||||
String entryName = decompiledData.getClassEntryName(cl, classEntries.get(i));
|
||||
if (entryName != null) {
|
||||
String content = decompiledData.getClassContent(cl);
|
||||
if (content != null) {
|
||||
decompilatSaver.saveClassFile(filename, cl.qualifiedName, entryname, content);
|
||||
resultSaver.saveClassFile(filename, cl.qualifiedName, entryName, content);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
break;
|
||||
|
||||
case TYPE_JAR:
|
||||
case TYPE_ZIP:
|
||||
|
||||
// create archive file
|
||||
decompilatSaver.saveFolder(archivepath);
|
||||
decompilatSaver.createArchive(archivepath, filename, manifest);
|
||||
resultSaver.saveFolder(archivePath);
|
||||
resultSaver.createArchive(archivePath, filename, manifest);
|
||||
|
||||
// directory entries
|
||||
for (String direntry : direntries) {
|
||||
decompilatSaver.saveEntry(archivepath, filename, direntry, null);
|
||||
for (String dirEntry : dirEntries) {
|
||||
resultSaver.saveDirEntry(archivePath, filename, dirEntry);
|
||||
}
|
||||
|
||||
// non-class entries
|
||||
for (String[] arr : otherentries) {
|
||||
// manifest was defined by constructor invocation
|
||||
if (type != TYPE_JAR || !MANIFEST_ENTRY.equalsIgnoreCase(arr[1])) {
|
||||
decompilatSaver.copyEntry(arr[0], archivepath, filename, arr[1]);
|
||||
for (String[] pair : otherEntries) {
|
||||
if (type != TYPE_JAR || !JarFile.MANIFEST_NAME.equalsIgnoreCase(pair[1])) {
|
||||
resultSaver.copyEntry(pair[0], archivePath, filename, pair[1]);
|
||||
}
|
||||
}
|
||||
|
||||
// classes
|
||||
for (int i = 0; i < classes.size(); i++) {
|
||||
|
||||
StructClass cl = classes.get(i);
|
||||
String entryname = classentries.get(i);
|
||||
|
||||
entryname = decompiledData.getClassEntryName(cl, entryname);
|
||||
if (entryname != null) {
|
||||
String entryName = decompiledData.getClassEntryName(cl, classEntries.get(i));
|
||||
if (entryName != null) {
|
||||
String content = decompiledData.getClassContent(cl);
|
||||
decompilatSaver.saveClassEntry(archivepath, filename, cl.qualifiedName, entryname, content);
|
||||
resultSaver.saveClassEntry(archivePath, filename, cl.qualifiedName, entryName, content);
|
||||
}
|
||||
}
|
||||
|
||||
decompilatSaver.closeArchive(archivepath, filename);
|
||||
resultSaver.closeArchive(archivePath, filename);
|
||||
}
|
||||
}
|
||||
|
||||
// *****************************************************************************
|
||||
// private methods
|
||||
// *****************************************************************************
|
||||
|
||||
// *****************************************************************************
|
||||
// getter and setter methods
|
||||
// *****************************************************************************
|
||||
|
||||
public void setManifest(Manifest manifest) {
|
||||
this.manifest = manifest;
|
||||
}
|
||||
@@ -204,16 +162,4 @@ public class ContextUnit {
|
||||
public List<StructClass> getClasses() {
|
||||
return classes;
|
||||
}
|
||||
|
||||
public int getType() {
|
||||
return type;
|
||||
}
|
||||
|
||||
public void setDecompilatSaver(IDecompilatSaver decompilatSaver) {
|
||||
this.decompilatSaver = decompilatSaver;
|
||||
}
|
||||
|
||||
public void setDecompiledData(IDecompiledData decompiledData) {
|
||||
this.decompiledData = decompiledData;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -24,7 +24,6 @@ import org.jetbrains.java.decompiler.util.InterpreterUtil;
|
||||
import org.jetbrains.java.decompiler.util.VBStyleCollection;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.io.InputStream;
|
||||
|
||||
/*
|
||||
class_file {
|
||||
@@ -62,8 +61,8 @@ public class StructClass extends StructMember {
|
||||
|
||||
private ConstantPool pool;
|
||||
|
||||
public StructClass(InputStream inStream, boolean own, LazyLoader loader) throws IOException {
|
||||
this(new DataInputFullStream(inStream), own, loader);
|
||||
public StructClass(byte[] bytes, boolean own, LazyLoader loader) throws IOException {
|
||||
this(new DataInputFullStream(bytes), own, loader);
|
||||
}
|
||||
|
||||
public StructClass(DataInputFullStream in, boolean own, LazyLoader loader) throws IOException {
|
||||
|
||||
@@ -16,65 +16,50 @@
|
||||
package org.jetbrains.java.decompiler.struct;
|
||||
|
||||
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.main.extern.IResultSaver;
|
||||
import org.jetbrains.java.decompiler.struct.lazy.LazyLoader;
|
||||
import org.jetbrains.java.decompiler.util.DataInputFullStream;
|
||||
import org.jetbrains.java.decompiler.util.InterpreterUtil;
|
||||
|
||||
import java.io.File;
|
||||
import java.io.IOException;
|
||||
import java.util.Enumeration;
|
||||
import java.util.HashMap;
|
||||
import java.util.Map;
|
||||
import java.util.jar.JarFile;
|
||||
import java.util.zip.ZipEntry;
|
||||
import java.util.zip.ZipFile;
|
||||
|
||||
|
||||
public class StructContext {
|
||||
|
||||
// *****************************************************************************
|
||||
// private fields
|
||||
// *****************************************************************************
|
||||
|
||||
private LazyLoader loader;
|
||||
|
||||
private HashMap<String, StructClass> classes = new HashMap<String, StructClass>();
|
||||
|
||||
private HashMap<String, ContextUnit> units = new HashMap<String, ContextUnit>();
|
||||
|
||||
private IDecompilatSaver saver;
|
||||
|
||||
private IDecompiledData decdata;
|
||||
|
||||
public StructContext(IDecompilatSaver saver, IDecompiledData decdata, LazyLoader loader) {
|
||||
private final IResultSaver saver;
|
||||
private final IDecompiledData decompiledData;
|
||||
private final LazyLoader loader;
|
||||
private final Map<String, ContextUnit> units = new HashMap<String, ContextUnit>();
|
||||
private final Map<String, StructClass> classes = new HashMap<String, StructClass>();
|
||||
|
||||
public StructContext(IResultSaver saver, IDecompiledData decompiledData, LazyLoader loader) {
|
||||
this.saver = saver;
|
||||
this.decdata = decdata;
|
||||
this.decompiledData = decompiledData;
|
||||
this.loader = loader;
|
||||
|
||||
ContextUnit defaultUnit = new ContextUnit(ContextUnit.TYPE_FOLDER, null, "", true, saver, decdata);
|
||||
ContextUnit defaultUnit = new ContextUnit(ContextUnit.TYPE_FOLDER, null, "", true, saver, decompiledData);
|
||||
units.put("", defaultUnit);
|
||||
}
|
||||
|
||||
// *****************************************************************************
|
||||
// public methods
|
||||
// *****************************************************************************
|
||||
|
||||
public StructClass getClass(String name) {
|
||||
return classes.get(name);
|
||||
}
|
||||
|
||||
public void reloadContext() throws IOException {
|
||||
|
||||
for (ContextUnit unit : units.values()) {
|
||||
|
||||
for (StructClass cl : unit.getClasses()) {
|
||||
classes.remove(cl.qualifiedName);
|
||||
}
|
||||
|
||||
unit.reload(loader);
|
||||
|
||||
// adjust lobal class collection
|
||||
// adjust global class collection
|
||||
for (StructClass cl : unit.getClasses()) {
|
||||
classes.put(cl.qualifiedName, cl);
|
||||
}
|
||||
@@ -82,7 +67,6 @@ public class StructContext {
|
||||
}
|
||||
|
||||
public void saveContext() {
|
||||
|
||||
for (ContextUnit unit : units.values()) {
|
||||
if (unit.isOwn()) {
|
||||
unit.save();
|
||||
@@ -90,134 +74,116 @@ public class StructContext {
|
||||
}
|
||||
}
|
||||
|
||||
public void addSpace(File file, boolean isOwn) throws IOException {
|
||||
addSpace("", file, isOwn);
|
||||
public void addSpace(File file, boolean isOwn) {
|
||||
addSpace("", file, isOwn, 0);
|
||||
}
|
||||
|
||||
private void addSpace(String path, File file, boolean isOwn) throws IOException {
|
||||
|
||||
private void addSpace(String path, File file, boolean isOwn, int level) {
|
||||
if (file.isDirectory()) {
|
||||
if (level == 1) path += file.getName();
|
||||
else if (level > 1) path += "/" + file.getName();
|
||||
|
||||
File[] files = file.listFiles();
|
||||
path += "/" + (path.length() == 0 ? "" : file.getName());
|
||||
|
||||
for (int i = files.length - 1; i >= 0; i--) {
|
||||
addSpace(path, files[i], isOwn);
|
||||
if (files != null) {
|
||||
for (int i = files.length - 1; i >= 0; i--) {
|
||||
addSpace(path, files[i], isOwn, level + 1);
|
||||
}
|
||||
}
|
||||
}
|
||||
else {
|
||||
|
||||
String filename = file.getName();
|
||||
|
||||
boolean isArchive = false;
|
||||
|
||||
try {
|
||||
if (filename.endsWith(".jar")) {
|
||||
addArchive(path, file, ContextUnit.TYPE_JAR, isOwn);
|
||||
isArchive = true;
|
||||
addArchive(path, file, ContextUnit.TYPE_JAR, isOwn);
|
||||
}
|
||||
else if (filename.endsWith(".zip")) {
|
||||
addArchive(path, file, ContextUnit.TYPE_ZIP, isOwn);
|
||||
isArchive = true;
|
||||
addArchive(path, file, ContextUnit.TYPE_ZIP, isOwn);
|
||||
}
|
||||
}
|
||||
catch (IOException ex) {
|
||||
DecompilerContext.getLogger()
|
||||
.writeMessage("Invalid archive file: " + (path.length() > 0 ? path + "/" : "") + filename, IFernflowerLogger.ERROR);
|
||||
String message = "Corrupted archive file: " + file;
|
||||
DecompilerContext.getLogger().writeMessage(message, ex);
|
||||
}
|
||||
if (isArchive) {
|
||||
return;
|
||||
}
|
||||
|
||||
if (!isArchive) {
|
||||
ContextUnit unit = units.get(path);
|
||||
if (unit == null) {
|
||||
unit = new ContextUnit(ContextUnit.TYPE_FOLDER, null, path, isOwn, saver, decdata);
|
||||
units.put(path, unit);
|
||||
}
|
||||
ContextUnit unit = units.get(path);
|
||||
if (unit == null) {
|
||||
unit = new ContextUnit(ContextUnit.TYPE_FOLDER, null, path, isOwn, saver, decompiledData);
|
||||
units.put(path, unit);
|
||||
}
|
||||
|
||||
boolean isClass = false;
|
||||
|
||||
if (filename.endsWith(".class")) {
|
||||
if (filename.endsWith(".class")) {
|
||||
try {
|
||||
DataInputFullStream in = loader.getClassStream(file.getAbsolutePath(), null);
|
||||
try {
|
||||
StructClass cl;
|
||||
|
||||
DataInputFullStream in = loader.getClassStream(file.getAbsolutePath(), null);
|
||||
try {
|
||||
cl = new StructClass(in, isOwn, loader);
|
||||
}
|
||||
finally {
|
||||
in.close();
|
||||
}
|
||||
|
||||
StructClass cl = new StructClass(in, isOwn, loader);
|
||||
classes.put(cl.qualifiedName, cl);
|
||||
unit.addClass(cl, filename);
|
||||
loader.addClassLink(cl.qualifiedName, new LazyLoader.Link(LazyLoader.Link.CLASS, file.getAbsolutePath(), null));
|
||||
|
||||
isClass = true;
|
||||
}
|
||||
catch (IOException ex) {
|
||||
DecompilerContext.getLogger().writeMessage("Invalid class file: " + (path.length() > 0 ? path + "/" : "") + filename,
|
||||
IFernflowerLogger.ERROR);
|
||||
finally {
|
||||
in.close();
|
||||
}
|
||||
}
|
||||
|
||||
if (!isClass) {
|
||||
unit.addOtherEntry(file.getAbsolutePath(), filename);
|
||||
catch (IOException ex) {
|
||||
String message = "Corrupted class file: " + file;
|
||||
DecompilerContext.getLogger().writeMessage(message, ex);
|
||||
}
|
||||
}
|
||||
else {
|
||||
unit.addOtherEntry(file.getAbsolutePath(), filename);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
private void addArchive(String path, File file, int type, boolean isOwn) throws IOException {
|
||||
@SuppressWarnings("IOResourceOpenedButNotSafelyClosed")
|
||||
ZipFile archive = type == ContextUnit.TYPE_JAR ? new JarFile(file) : new ZipFile(file);
|
||||
|
||||
ZipFile archive;
|
||||
try {
|
||||
Enumeration<? extends ZipEntry> entries = archive.entries();
|
||||
while (entries.hasMoreElements()) {
|
||||
ZipEntry entry = entries.nextElement();
|
||||
|
||||
if (type == ContextUnit.TYPE_JAR) { // jar
|
||||
archive = new JarFile(file);
|
||||
}
|
||||
else { // zip
|
||||
archive = new ZipFile(file);
|
||||
}
|
||||
|
||||
Enumeration<? extends ZipEntry> en = archive.entries();
|
||||
while (en.hasMoreElements()) {
|
||||
ZipEntry entr = en.nextElement();
|
||||
|
||||
ContextUnit unit = units.get(path + "/" + file.getName());
|
||||
if (unit == null) {
|
||||
unit = new ContextUnit(type, path, file.getName(), isOwn, saver, decdata);
|
||||
if (type == ContextUnit.TYPE_JAR) {
|
||||
unit.setManifest(((JarFile)archive).getManifest());
|
||||
ContextUnit unit = units.get(path + "/" + file.getName());
|
||||
if (unit == null) {
|
||||
unit = new ContextUnit(type, path, file.getName(), isOwn, saver, decompiledData);
|
||||
if (type == ContextUnit.TYPE_JAR) {
|
||||
unit.setManifest(((JarFile)archive).getManifest());
|
||||
}
|
||||
units.put(path + "/" + file.getName(), unit);
|
||||
}
|
||||
units.put(path + "/" + file.getName(), unit);
|
||||
}
|
||||
|
||||
String name = entr.getName();
|
||||
if (!entr.isDirectory()) {
|
||||
if (name.endsWith(".class")) {
|
||||
StructClass cl = new StructClass(archive.getInputStream(entr), isOwn, loader);
|
||||
classes.put(cl.qualifiedName, cl);
|
||||
|
||||
unit.addClass(cl, name);
|
||||
|
||||
if (loader != null) {
|
||||
String name = entry.getName();
|
||||
if (!entry.isDirectory()) {
|
||||
if (name.endsWith(".class")) {
|
||||
byte[] bytes = InterpreterUtil.getBytes(archive, entry);
|
||||
StructClass cl = new StructClass(bytes, isOwn, loader);
|
||||
classes.put(cl.qualifiedName, cl);
|
||||
unit.addClass(cl, name);
|
||||
loader.addClassLink(cl.qualifiedName, new LazyLoader.Link(LazyLoader.Link.ENTRY, file.getAbsolutePath(), name));
|
||||
}
|
||||
else {
|
||||
unit.addOtherEntry(file.getAbsolutePath(), name);
|
||||
}
|
||||
}
|
||||
else {
|
||||
unit.addOtherEntry(file.getAbsolutePath(), name);
|
||||
unit.addDirEntry(name);
|
||||
}
|
||||
}
|
||||
else if (entr.isDirectory()) {
|
||||
unit.addDirEntry(name);
|
||||
}
|
||||
}
|
||||
finally {
|
||||
archive.close();
|
||||
}
|
||||
}
|
||||
|
||||
// *****************************************************************************
|
||||
// getter and setter methods
|
||||
// *****************************************************************************
|
||||
|
||||
public HashMap<String, StructClass> getClasses() {
|
||||
public Map<String, StructClass> getClasses() {
|
||||
return classes;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -21,7 +21,6 @@ import org.jetbrains.java.decompiler.struct.consts.ConstantPool;
|
||||
import org.jetbrains.java.decompiler.util.DataInputFullStream;
|
||||
import org.jetbrains.java.decompiler.util.VBStyleCollection;
|
||||
|
||||
import java.io.ByteArrayInputStream;
|
||||
import java.io.IOException;
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
@@ -106,7 +105,7 @@ public class StructMethod extends StructMember {
|
||||
public void expandData() throws IOException {
|
||||
if (containsCode && !expanded) {
|
||||
byte[] code = classStruct.getLoader().loadBytecode(this, codeFullLength);
|
||||
seq = parseBytecode(new DataInputFullStream(new ByteArrayInputStream(code)), codeLength, classStruct.getPool());
|
||||
seq = parseBytecode(new DataInputFullStream(code), codeLength, classStruct.getPool());
|
||||
expanded = true;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -18,7 +18,6 @@ package org.jetbrains.java.decompiler.struct.attr;
|
||||
import org.jetbrains.java.decompiler.struct.consts.ConstantPool;
|
||||
import org.jetbrains.java.decompiler.util.DataInputFullStream;
|
||||
|
||||
import java.io.ByteArrayInputStream;
|
||||
import java.io.IOException;
|
||||
|
||||
/*
|
||||
@@ -104,7 +103,7 @@ public class StructGeneralAttribute {
|
||||
}
|
||||
|
||||
protected DataInputFullStream stream() {
|
||||
return new DataInputFullStream(new ByteArrayInputStream(info));
|
||||
return new DataInputFullStream(info);
|
||||
}
|
||||
|
||||
public void initContent(ConstantPool pool) throws IOException { }
|
||||
|
||||
@@ -22,14 +22,13 @@ import org.jetbrains.java.decompiler.struct.consts.ConstantPool;
|
||||
import org.jetbrains.java.decompiler.util.DataInputFullStream;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.io.InputStream;
|
||||
import java.util.HashMap;
|
||||
import java.util.Map;
|
||||
|
||||
public class LazyLoader {
|
||||
|
||||
private Map<String, Link> mapClassLinks = new HashMap<String, Link>();
|
||||
private IBytecodeProvider provider;
|
||||
private final Map<String, Link> mapClassLinks = new HashMap<String, Link>();
|
||||
private final IBytecodeProvider provider;
|
||||
|
||||
public LazyLoader(IBytecodeProvider provider) {
|
||||
this.provider = provider;
|
||||
@@ -138,10 +137,9 @@ public class LazyLoader {
|
||||
}
|
||||
}
|
||||
|
||||
@SuppressWarnings("IOResourceOpenedButNotSafelyClosed")
|
||||
public DataInputFullStream getClassStream(String externalPath, String internalPath) throws IOException {
|
||||
InputStream stream = provider.getBytecodeStream(externalPath, internalPath);
|
||||
return stream == null ? null : new DataInputFullStream(stream);
|
||||
byte[] bytes = provider.getBytecode(externalPath, internalPath);
|
||||
return new DataInputFullStream(bytes);
|
||||
}
|
||||
|
||||
public DataInputFullStream getClassStream(String qualifiedClassName) throws IOException {
|
||||
|
||||
Reference in New Issue
Block a user