Deobfuscate stacktraces in log messages, crash reports, and etc.

This commit is contained in:
Jason Penilla
2021-06-20 18:19:09 -07:00
parent b0d7c2e971
commit 34407fe880
13 changed files with 466 additions and 17 deletions

View File

@@ -0,0 +1,34 @@
package io.papermc.paper.util;
import java.util.HashMap;
import java.util.Map;
import java.util.function.Function;
import org.checkerframework.checker.nullness.qual.NonNull;
import org.checkerframework.framework.qual.DefaultQualifier;
/**
* De-duplicates {@link String} instances without using {@link String#intern()}.
*
* <p>Interning may not be desired as we may want to use the heap for our pool,
* so it can be garbage collected as normal, etc.</p>
*
* <p>Additionally, interning can be slow due to the potentially large size of the
* pool (as it is shared for the entire JVM), and because most JVMs implement
* it using JNI.</p>
*/
@DefaultQualifier(NonNull.class)
public final class StringPool {
private final Map<String, String> pool;
public StringPool() {
this(new HashMap<>());
}
public StringPool(final Map<String, String> map) {
this.pool = map;
}
public String string(final String string) {
return this.pool.computeIfAbsent(string, Function.identity());
}
}