aboutsummaryrefslogtreecommitdiff
path: root/spark-common/src/main/java/me/lucko/spark/common/util
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/src/main/java/me/lucko/spark/common/util
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/src/main/java/me/lucko/spark/common/util')
-rw-r--r--spark-common/src/main/java/me/lucko/spark/common/util/TypeDescriptors.java82
1 files changed, 0 insertions, 82 deletions
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);
- }
- }
-
-}