aboutsummaryrefslogtreecommitdiff
path: root/spark-common
diff options
context:
space:
mode:
authorLuck <git@lucko.me>2020-03-06 17:30:37 +0000
committerLuck <git@lucko.me>2020-03-06 17:30:37 +0000
commitf13b8b917a910885f39bf5c0c131b7a4ee3824c9 (patch)
tree0ec47fb081e41ffdd575169992736f4ba7721e5b /spark-common
parent4eff32f040d023e225937c1a59583f1e89b2cac2 (diff)
downloadspark-f13b8b917a910885f39bf5c0c131b7a4ee3824c9.tar.gz
spark-f13b8b917a910885f39bf5c0c131b7a4ee3824c9.tar.bz2
spark-f13b8b917a910885f39bf5c0c131b7a4ee3824c9.zip
Use ASMs type descriptor utility instead of our own
Diffstat (limited to 'spark-common')
-rw-r--r--spark-common/src/main/java/me/lucko/spark/common/heapdump/HeapDumpSummary.java4
-rw-r--r--spark-common/src/main/java/me/lucko/spark/common/util/TypeDescriptors.java82
2 files changed, 2 insertions, 84 deletions
diff --git a/spark-common/src/main/java/me/lucko/spark/common/heapdump/HeapDumpSummary.java b/spark-common/src/main/java/me/lucko/spark/common/heapdump/HeapDumpSummary.java
index 137a4fe..002ff72 100644
--- a/spark-common/src/main/java/me/lucko/spark/common/heapdump/HeapDumpSummary.java
+++ b/spark-common/src/main/java/me/lucko/spark/common/heapdump/HeapDumpSummary.java
@@ -21,10 +21,10 @@
package me.lucko.spark.common.heapdump;
import me.lucko.spark.common.command.sender.CommandSender;
-import me.lucko.spark.common.util.TypeDescriptors;
import me.lucko.spark.proto.SparkProtos;
import me.lucko.spark.proto.SparkProtos.HeapData;
import me.lucko.spark.proto.SparkProtos.HeapEntry;
+import org.objectweb.asm.Type;
import java.io.ByteArrayOutputStream;
import java.io.IOException;
@@ -95,7 +95,7 @@ public final class HeapDumpSummary {
Integer.parseInt(matcher.group(1)),
Integer.parseInt(matcher.group(2)),
Long.parseLong(matcher.group(3)),
- TypeDescriptors.getJavaType(matcher.group(4))
+ Type.getType(matcher.group(4)).getClassName()
);
} catch (Exception e) {
new IllegalArgumentException("Exception parsing line: " + line, e).printStackTrace();
diff --git a/spark-common/src/main/java/me/lucko/spark/common/util/TypeDescriptors.java b/spark-common/src/main/java/me/lucko/spark/common/util/TypeDescriptors.java
deleted file mode 100644
index c827c69..0000000
--- a/spark-common/src/main/java/me/lucko/spark/common/util/TypeDescriptors.java
+++ /dev/null
@@ -1,82 +0,0 @@
-/*
- * This file is part of spark.
- *
- * Copyright (c) lucko (Luck) <luck@lucko.me>
- * Copyright (c) contributors
- *
- * This program is free software: you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation, either version 3 of the License, or
- * (at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program. If not, see <http://www.gnu.org/licenses/>.
- */
-
-package me.lucko.spark.common.util;
-
-/**
- * Utilities for working with Java type descriptors.
- */
-public enum TypeDescriptors {
- ;
-
- /**
- * Returns the Java type corresponding to the given type descriptor.
- *
- * @param typeDescriptor a type descriptor.
- * @return the Java type corresponding to the given type descriptor.
- */
- public static String getJavaType(String typeDescriptor) {
- return getJavaType(typeDescriptor.toCharArray(), 0);
- }
-
- private static String getJavaType(char[] buf, int offset) {
- int len;
- switch (buf[offset]) {
- case 'V':
- return "void";
- case 'Z':
- return "boolean";
- case 'C':
- return "char";
- case 'B':
- return "byte";
- case 'S':
- return "short";
- case 'I':
- return "int";
- case 'F':
- return "float";
- case 'J':
- return "long";
- case 'D':
- return "double";
- case '[': // array
- len = 1;
- while (buf[offset + len] == '[') {
- len++;
- }
-
- StringBuilder sb = new StringBuilder(getJavaType(buf, offset + len));
- for (int i = len; i > 0; --i) {
- sb.append("[]");
- }
- return sb.toString();
- case 'L': // object
- len = 1;
- while (buf[offset + len] != ';') {
- len++;
- }
- return new String(buf, offset + 1, len - 1);
- default:
- return new String(buf, offset, buf.length - offset);
- }
- }
-
-}