3
0
Mirror von https://github.com/PaperMC/Paper.git synchronisiert 2024-12-15 11:00:06 +01:00

Fix timings task name generation for extreme cases - Fixes #3499

I'm going make a class, and in that class i'm going to
make a method. And in that method, I'm going to make a local class.

And then in that local class, I'm going to make another inner class.

I heard you like complex class trees.
Dieser Commit ist enthalten in:
Aikar 2020-06-08 12:22:40 -04:00
Ursprung 5e3bacbced
Commit 34e5942bf0
Es konnte kein GPG-Schlüssel zu dieser Signatur gefunden werden
GPG-Schlüssel-ID: 401ADFC9891FAAFE

Datei anzeigen

@ -6,7 +6,7 @@ Subject: [PATCH] Timings v2
diff --git a/src/main/java/co/aikar/timings/MinecraftTimings.java b/src/main/java/co/aikar/timings/MinecraftTimings.java diff --git a/src/main/java/co/aikar/timings/MinecraftTimings.java b/src/main/java/co/aikar/timings/MinecraftTimings.java
new file mode 100644 new file mode 100644
index 0000000000000000000000000000000000000000..33342139a042ebec5fb4e8566028f8f7e3149937 index 0000000000000000000000000000000000000000..11c5f8e033689f483a64486d2f8c206ca26ff9da
--- /dev/null --- /dev/null
+++ b/src/main/java/co/aikar/timings/MinecraftTimings.java +++ b/src/main/java/co/aikar/timings/MinecraftTimings.java
@@ -0,0 +1,145 @@ @@ -0,0 +1,145 @@
@ -81,13 +81,13 @@ index 0000000000000000000000000000000000000000..33342139a042ebec5fb4e8566028f8f7
+ +
+ final String taskname = taskNameCache.computeIfAbsent(taskClass, clazz -> { + final String taskname = taskNameCache.computeIfAbsent(taskClass, clazz -> {
+ try { + try {
+ String clsName = clazz.isAnonymousClass() || clazz.isLocalClass() + String clsName = !clazz.isMemberClass()
+ ? clazz.getName() + ? clazz.getName()
+ : clazz.getCanonicalName(); + : clazz.getCanonicalName();
+ if (clsName.contains("$Lambda$")) { + if (clsName != null && clsName.contains("$Lambda$")) {
+ clsName = clsName.replaceAll("(Lambda\\$.*?)/.*", "$1"); + clsName = clsName.replaceAll("(Lambda\\$.*?)/.*", "$1");
+ } + }
+ return clsName; + return clsName != null ? clsName : "UnknownTask";
+ } catch (Throwable ex) { + } catch (Throwable ex) {
+ new Exception("Error occurred detecting class name", ex).printStackTrace(); + new Exception("Error occurred detecting class name", ex).printStackTrace();
+ return "MangledClassFile"; + return "MangledClassFile";