From 0675784032d6606adb5849a4787366e193568b54 Mon Sep 17 00:00:00 2001 From: Kyle Wood Date: Fri, 26 Nov 2021 00:33:08 -0600 Subject: [PATCH] Fix stacktrace deobf when running as a bundler jar --- ...tacktraces-in-log-messages-crash-report.patch | 16 +++++++++++++--- 1 file changed, 13 insertions(+), 3 deletions(-) diff --git a/patches/server/0417-Deobfuscate-stacktraces-in-log-messages-crash-report.patch b/patches/server/0417-Deobfuscate-stacktraces-in-log-messages-crash-report.patch index 49a98d2406..9a2dabdac6 100644 --- a/patches/server/0417-Deobfuscate-stacktraces-in-log-messages-crash-report.patch +++ b/patches/server/0417-Deobfuscate-stacktraces-in-log-messages-crash-report.patch @@ -316,16 +316,17 @@ index 0000000000000000000000000000000000000000..b8b17d046f836c8652ab094db00ab1af +} diff --git a/src/main/java/io/papermc/paper/util/StacktraceDeobfuscator.java b/src/main/java/io/papermc/paper/util/StacktraceDeobfuscator.java new file mode 100644 -index 0000000000000000000000000000000000000000..5019d22fa2ab8d72fac5ffcf5dc2a3715ae63760 +index 0000000000000000000000000000000000000000..3c3051c2917548faf7e72276fb642202b33d1794 --- /dev/null +++ b/src/main/java/io/papermc/paper/util/StacktraceDeobfuscator.java -@@ -0,0 +1,153 @@ +@@ -0,0 +1,163 @@ +package io.papermc.paper.util; + +import com.destroystokyo.paper.PaperConfig; +import it.unimi.dsi.fastutil.ints.IntArrayList; +import it.unimi.dsi.fastutil.ints.IntList; +import java.io.IOException; ++import java.io.InputStream; +import java.util.Collections; +import java.util.HashMap; +import java.util.LinkedHashMap; @@ -465,7 +466,16 @@ index 0000000000000000000000000000000000000000..5019d22fa2ab8d72fac5ffcf5dc2a371 + } + }; + try { -+ final ClassReader reader = new ClassReader(key.getName()); ++ final @Nullable InputStream inputStream = StacktraceDeobfuscator.class.getClassLoader() ++ .getResourceAsStream(key.getName().replace('.', '/') + ".class"); ++ if (inputStream == null) { ++ throw new IllegalStateException("Could not find class file: " + key.getName()); ++ } ++ final byte[] classData; ++ try (inputStream) { ++ classData = inputStream.readAllBytes(); ++ } ++ final ClassReader reader = new ClassReader(classData); + reader.accept(classVisitor, 0); + } catch (final IOException ex) { + throw new RuntimeException(ex);