Merge pull request #374 from ThexXTURBOXx/master

Fix closed stream for Procyon
This commit is contained in:
Konloch 2021-11-18 12:39:09 -08:00 committed by GitHub
commit bf1faa949d
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

View file

@ -68,10 +68,9 @@ import static the.bytecode.club.bytecodeviewer.translation.TranslatedStrings.PRO
* @author Konloch * @author Konloch
* @author DeathMarine * @author DeathMarine
*/ */
public class ProcyonDecompiler extends InternalDecompiler public class ProcyonDecompiler extends InternalDecompiler {
{
public DecompilerSettings getDecompilerSettings() public DecompilerSettings getDecompilerSettings() {
{
DecompilerSettings settings = new DecompilerSettings(); DecompilerSettings settings = new DecompilerSettings();
settings.setAlwaysGenerateExceptionVariableForCatchBlocks(BytecodeViewer.viewer.alwaysGenerateExceptionVars.isSelected()); settings.setAlwaysGenerateExceptionVariableForCatchBlocks(BytecodeViewer.viewer.alwaysGenerateExceptionVars.isSelected());
settings.setExcludeNestedTypes(BytecodeViewer.viewer.excludeNestedTypes.isSelected()); settings.setExcludeNestedTypes(BytecodeViewer.viewer.excludeNestedTypes.isSelected());
@ -118,7 +117,7 @@ public class ProcyonDecompiler extends InternalDecompiler
TypeDefinition resolvedType; TypeDefinition resolvedType;
if (type == null || ((resolvedType = type.resolve()) == null)) if (type == null || ((resolvedType = type.resolve()) == null))
throw new Exception("Unable to resolve type."); throw new Exception("Unable to resolve type.");
StringWriter stringwriter = new StringWriter(); StringWriter stringwriter = new StringWriter();
settings.getLanguage().decompileType(resolvedType, new PlainTextOutput(stringwriter), decompilationOptions); settings.getLanguage().decompileType(resolvedType, new PlainTextOutput(stringwriter), decompilationOptions);
@ -130,7 +129,7 @@ public class ProcyonDecompiler extends InternalDecompiler
exception = ExceptionUI.SEND_STACKTRACE_TO_NL + sw; exception = ExceptionUI.SEND_STACKTRACE_TO_NL + sw;
} }
return PROCYON + " " + ERROR + "! " + ExceptionUI.SEND_STACKTRACE_TO + return PROCYON + " " + ERROR + "! " + ExceptionUI.SEND_STACKTRACE_TO +
nl + nl + TranslatedStrings.SUGGESTED_FIX_DECOMPILER_ERROR + nl + nl + TranslatedStrings.SUGGESTED_FIX_DECOMPILER_ERROR +
nl + nl + exception; nl + nl + exception;
@ -184,12 +183,11 @@ public class ProcyonDecompiler extends InternalDecompiler
|| ((resolvedType = type.resolve()) == null)) { || ((resolvedType = type.resolve()) == null)) {
throw new Exception("Unable to resolve type."); throw new Exception("Unable to resolve type.");
} }
try (Writer writer = new OutputStreamWriter(out)) { Writer writer = new OutputStreamWriter(out);
settings.getLanguage().decompileType(resolvedType, settings.getLanguage().decompileType(resolvedType,
new PlainTextOutput(writer), new PlainTextOutput(writer),
decompilationOptions); decompilationOptions);
writer.flush(); writer.flush();
}
} finally { } finally {
out.closeEntry(); out.closeEntry();
} }
@ -212,8 +210,7 @@ public class ProcyonDecompiler extends InternalDecompiler
out.closeEntry(); out.closeEntry();
} }
} catch (ZipException ze) { } catch (ZipException ze) {
// some jar-s contain duplicate pom.xml entries: ignore // some jars contain duplicate pom.xml entries: ignore it
// it
if (!ze.getMessage().contains("duplicate")) { if (!ze.getMessage().contains("duplicate")) {
throw ze; throw ze;
} }
@ -227,6 +224,7 @@ public class ProcyonDecompiler extends InternalDecompiler
* @author DeathMarine * @author DeathMarine
*/ */
public static final class LuytenTypeLoader implements ITypeLoader { public static final class LuytenTypeLoader implements ITypeLoader {
private final List<ITypeLoader> _typeLoaders; private final List<ITypeLoader> _typeLoaders;
public LuytenTypeLoader() { public LuytenTypeLoader() {
@ -251,5 +249,7 @@ public class ProcyonDecompiler extends InternalDecompiler
return false; return false;
} }
} }
} }