From 89c412cda16bbaf370699f747ad167f3a5fd9fec Mon Sep 17 00:00:00 2001 From: Gravit Date: Wed, 23 Oct 2019 03:09:47 +0700 Subject: [PATCH] =?UTF-8?q?[FIX]=20=D0=9D=D0=B5=20=D0=BF=D0=BE=D0=B7=D0=B2?= =?UTF-8?q?=D0=BE=D0=BB=D1=8F=D0=B5=D0=BC=20=D0=BB=D0=B0=D1=83=D0=BD=D1=87?= =?UTF-8?q?=D0=B5=D1=80=D1=83=20=D1=80=D0=B0=D0=B7=D0=B6=D0=B8=D1=80=D0=B0?= =?UTF-8?q?=D1=82=D1=8C=D1=81=D1=8F=20=D1=81=D0=BB=D0=B8=D1=88=D0=BA=D0=BE?= =?UTF-8?q?=D0=BC=20=D1=81=D0=B8=D0=BB=D1=8C=D0=BD=D0=BE?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../launchserver/asm/SafeClassWriter.java | 1 + .../tasks/AdditionalFixesApplyTask.java | 19 ++++++++----------- .../launcher/ClientLauncherWrapper.java | 1 + 3 files changed, 10 insertions(+), 11 deletions(-) diff --git a/LaunchServer/src/main/java/pro/gravit/launchserver/asm/SafeClassWriter.java b/LaunchServer/src/main/java/pro/gravit/launchserver/asm/SafeClassWriter.java index 05b340e0..54fe3e4c 100644 --- a/LaunchServer/src/main/java/pro/gravit/launchserver/asm/SafeClassWriter.java +++ b/LaunchServer/src/main/java/pro/gravit/launchserver/asm/SafeClassWriter.java @@ -18,6 +18,7 @@ public SafeClassWriter(ClassMetadataReader classMetadataReader, int flags) { this.classMetadataReader = classMetadataReader; } + public SafeClassWriter(ClassReader classReader, ClassMetadataReader classMetadataReader, int flags) { super(classReader, flags); this.classMetadataReader = classMetadataReader; diff --git a/LaunchServer/src/main/java/pro/gravit/launchserver/binary/tasks/AdditionalFixesApplyTask.java b/LaunchServer/src/main/java/pro/gravit/launchserver/binary/tasks/AdditionalFixesApplyTask.java index f486e965..57f2c311 100644 --- a/LaunchServer/src/main/java/pro/gravit/launchserver/binary/tasks/AdditionalFixesApplyTask.java +++ b/LaunchServer/src/main/java/pro/gravit/launchserver/binary/tasks/AdditionalFixesApplyTask.java @@ -11,6 +11,7 @@ import java.io.ByteArrayOutputStream; import java.io.IOException; +import java.io.InputStream; import java.nio.file.Path; import java.util.List; import java.util.function.Predicate; @@ -69,16 +70,12 @@ public static void apply(Path inputFile, Path addFile, ZipOutputStream output, L output.putNextEntry(IOHelper.newZipEntry(e)); if (filename.endsWith(".class")) { byte[] bytes; - try (ByteArrayOutputStream outputStream = new ByteArrayOutputStream(2048)) { - IOHelper.transfer(input, outputStream); - bytes = outputStream.toByteArray(); + if(needFixes) { + bytes = classFix(input, reader, srv.config.launcher.stripLineNumbers); + output.write(bytes); } - try { - if(needFixes) bytes = classFix(bytes, reader, srv.config.launcher.stripLineNumbers); - } catch (Throwable t) { - LogHelper.error(t); - } - output.write(bytes); + else + IOHelper.transfer(input, output); } else IOHelper.transfer(input, output); e = input.getNextEntry(); @@ -87,8 +84,8 @@ public static void apply(Path inputFile, Path addFile, ZipOutputStream output, L } } - private static byte[] classFix(byte[] bytes, ClassMetadataReader reader, boolean stripNumbers) { - ClassReader cr = new ClassReader(bytes); + private static byte[] classFix(InputStream input, ClassMetadataReader reader, boolean stripNumbers) throws IOException { + ClassReader cr = new ClassReader(input); ClassNode cn = new ClassNode(); cr.accept(cn, stripNumbers ? (ClassReader.SKIP_DEBUG | ClassReader.SKIP_FRAMES) : ClassReader.SKIP_FRAMES); ClassWriter cw = new SafeClassWriter(reader, ClassWriter.COMPUTE_FRAMES | ClassWriter.COMPUTE_MAXS); diff --git a/Launcher/src/main/java/pro/gravit/launcher/ClientLauncherWrapper.java b/Launcher/src/main/java/pro/gravit/launcher/ClientLauncherWrapper.java index 9838ffe5..a7aafb6a 100644 --- a/Launcher/src/main/java/pro/gravit/launcher/ClientLauncherWrapper.java +++ b/Launcher/src/main/java/pro/gravit/launcher/ClientLauncherWrapper.java @@ -81,6 +81,7 @@ public static void main(String[] arguments) throws IOException, InterruptedExcep } Collections.addAll(args, MAGIC_ARG); Collections.addAll(args, "-XX:+DisableAttachMechanism"); + Collections.addAll(args, "-Xmx256M"); Collections.addAll(args, "-javaagent:".concat(pathLauncher)); Collections.addAll(args, "-cp"); Collections.addAll(args, pathLauncher);