You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@groovy.apache.org by su...@apache.org on 2018/02/06 09:10:31 UTC
[6/6] groovy git commit: Minor refactoring: remove the duplicated
code further
Minor refactoring: remove the duplicated code further
(cherry picked from commit 6b208c1)
Project: http://git-wip-us.apache.org/repos/asf/groovy/repo
Commit: http://git-wip-us.apache.org/repos/asf/groovy/commit/0d9733be
Tree: http://git-wip-us.apache.org/repos/asf/groovy/tree/0d9733be
Diff: http://git-wip-us.apache.org/repos/asf/groovy/diff/0d9733be
Branch: refs/heads/GROOVY_2_6_X
Commit: 0d9733bed475fe1fb2bb2ec1cad511878472dbbe
Parents: c46f9fc
Author: sunlan <su...@apache.org>
Authored: Tue Feb 6 16:37:16 2018 +0800
Committer: sunlan <su...@apache.org>
Committed: Tue Feb 6 17:09:50 2018 +0800
----------------------------------------------------------------------
.../groovy/classgen/asm/BytecodeHelper.java | 29 ++++++--------------
1 file changed, 9 insertions(+), 20 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/groovy/blob/0d9733be/src/main/java/org/codehaus/groovy/classgen/asm/BytecodeHelper.java
----------------------------------------------------------------------
diff --git a/src/main/java/org/codehaus/groovy/classgen/asm/BytecodeHelper.java b/src/main/java/org/codehaus/groovy/classgen/asm/BytecodeHelper.java
index a983af4..25fa258 100644
--- a/src/main/java/org/codehaus/groovy/classgen/asm/BytecodeHelper.java
+++ b/src/main/java/org/codehaus/groovy/classgen/asm/BytecodeHelper.java
@@ -124,24 +124,15 @@ public class BytecodeHelper implements Opcodes {
* @return the ASM type description for class loading
*/
public static String getClassLoadingTypeDescription(ClassNode c) {
- StringBuilder buf = new StringBuilder();
- boolean array = false;
- while (true) {
- if (c.isArray()) {
- buf.append('[');
- c = c.getComponentType();
- array = true;
- } else {
- if (ClassHelper.isPrimitiveType(c)) {
- buf.append(getTypeDescription(c));
- } else {
- if (array) buf.append('L');
- buf.append(c.getName());
- if (array) buf.append(';');
- }
- return buf.toString();
+ String desc = TypeDescriptionUtil.getDescriptionByType(c);
+
+ if (!c.isArray()) {
+ if (desc.startsWith("L") && desc.endsWith(";")) {
+ desc = desc.substring(1, desc.length() - 1); // remove "L" and ";"
}
}
+
+ return desc.replace('/', '.');
}
/**
@@ -170,10 +161,8 @@ public class BytecodeHelper implements Opcodes {
String desc = TypeDescriptionUtil.getDescriptionByType(d);
- if (!end) {
- if (desc.endsWith(";")) {
- desc = desc.substring(0, desc.length() - 1);
- }
+ if (!end && desc.endsWith(";")) {
+ desc = desc.substring(0, desc.length() - 1);
}
return desc;