You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@servicecomb.apache.org by GitBox <gi...@apache.org> on 2018/05/11 07:01:40 UTC

[GitHub] liubao68 closed pull request #696: [SCB-533] JavassistUtils create class from CtClass

liubao68 closed pull request #696: [SCB-533] JavassistUtils create class from CtClass
URL: https://github.com/apache/incubator-servicecomb-java-chassis/pull/696
 
 
   

This is a PR merged from a forked repository.
As GitHub hides the original diff on merge, it is displayed below for
the sake of provenance:

As this is a foreign pull request (from a fork), the diff is supplied
below (as it won't show otherwise due to GitHub magic):

diff --git a/common/common-javassist/src/main/java/org/apache/servicecomb/common/javassist/ClassConfig.java b/common/common-javassist/src/main/java/org/apache/servicecomb/common/javassist/ClassConfig.java
index 9471d7a93..bc070ba1f 100644
--- a/common/common-javassist/src/main/java/org/apache/servicecomb/common/javassist/ClassConfig.java
+++ b/common/common-javassist/src/main/java/org/apache/servicecomb/common/javassist/ClassConfig.java
@@ -73,9 +73,13 @@ public FieldConfig addField(String name, Type genericType) {
   }
 
   public FieldConfig addField(String name, JavaType javaType) {
+    return addField(name, new CtType(javaType));
+  }
+
+  public FieldConfig addField(String name, CtType ctType) {
     FieldConfig field = new FieldConfig();
     field.setName(name);
-    field.setType(javaType);
+    field.setType(ctType);
 
     fieldList.add(field);
 
diff --git a/common/common-javassist/src/main/java/org/apache/servicecomb/common/javassist/CtType.java b/common/common-javassist/src/main/java/org/apache/servicecomb/common/javassist/CtType.java
new file mode 100644
index 000000000..d0da1e010
--- /dev/null
+++ b/common/common-javassist/src/main/java/org/apache/servicecomb/common/javassist/CtType.java
@@ -0,0 +1,86 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.servicecomb.common.javassist;
+
+import com.fasterxml.jackson.databind.JavaType;
+
+import javassist.ClassPool;
+import javassist.CtClass;
+import javassist.CtPrimitiveType;
+import javassist.NotFoundException;
+
+public class CtType {
+  private static final ClassPool PRIMITIVE_CLASSPOOL = JavassistUtils.getOrCreateClassPool(int.class.getClassLoader());
+
+  private CtClass ctClass;
+
+  private boolean hasGenericTypes;
+
+  private String genericSignature;
+
+  public CtType(CtClass ctClass, boolean hasGenericTypes, String genericSignature) {
+    init(ctClass, hasGenericTypes, genericSignature);
+  }
+
+  public CtType(JavaType javaType) {
+    ClassLoader classLoader = javaType.getRawClass().getClassLoader();
+    try {
+      ClassPool classPool = JavassistUtils.getOrCreateClassPool(classLoader);
+      init(classPool.get(javaType.getRawClass().getCanonicalName()), javaType.hasGenericTypes(),
+          javaType.getGenericSignature()
+      );
+    } catch (NotFoundException e) {
+      throw new IllegalStateException(
+          String.format("Failed to get CtClass for %s in classloader %s.",
+              javaType.getRawClass().getName(),
+              classLoader),
+          e);
+    }
+  }
+
+  private void init(CtClass ctClass, boolean hasGenericTypes, String genericSignature) {
+    if (ctClass.isPrimitive()) {
+      try {
+        ctClass = PRIMITIVE_CLASSPOOL.get(((CtPrimitiveType) ctClass).getWrapperName());
+      } catch (NotFoundException e) {
+        throw new IllegalStateException("Impossible exception.", e);
+      }
+    }
+
+    this.ctClass = ctClass;
+    // no problem:
+    //   Ljava/util/List<Ljava/lang/String;>;
+    // cause problem:
+    //   Ljava/util/List<[B;>;
+    //   it should be Ljava/util/List<[B>;
+    // jackson generate genericSignature to be "Ljava/util/List<[B;>;" of List<byte[]>, we should convert it
+    this.genericSignature = genericSignature.replace("[B;>", "[B>");
+    this.hasGenericTypes = hasGenericTypes;
+  }
+
+  public CtClass getCtClass() {
+    return ctClass;
+  }
+
+  public boolean hasGenericTypes() {
+    return this.hasGenericTypes;
+  }
+
+  public String getGenericSignature() {
+    return genericSignature;
+  }
+}
diff --git a/common/common-javassist/src/main/java/org/apache/servicecomb/common/javassist/FieldConfig.java b/common/common-javassist/src/main/java/org/apache/servicecomb/common/javassist/FieldConfig.java
index c630b73b1..8975690bd 100644
--- a/common/common-javassist/src/main/java/org/apache/servicecomb/common/javassist/FieldConfig.java
+++ b/common/common-javassist/src/main/java/org/apache/servicecomb/common/javassist/FieldConfig.java
@@ -17,17 +17,12 @@
 
 package org.apache.servicecomb.common.javassist;
 
-import org.springframework.util.ClassUtils;
-
 import com.fasterxml.jackson.databind.JavaType;
 
 public class FieldConfig {
   private String name;
 
-  // javassist的成员不支持int这样的类型,必须是Integer才行
-  private Class<?> rawType;
-
-  private JavaType type;
+  private CtType type;
 
   private boolean genGetter;
 
@@ -41,17 +36,16 @@ public void setName(String name) {
     this.name = name;
   }
 
-  public Class<?> getRawType() {
-    return rawType;
+  public CtType getType() {
+    return type;
   }
 
-  public JavaType getType() {
-    return type;
+  public void setType(JavaType javaType) {
+    this.type = new CtType(javaType);
   }
 
-  public void setType(JavaType type) {
-    this.rawType = ClassUtils.resolvePrimitiveIfNecessary(type.getRawClass());
-    this.type = type;
+  public void setType(CtType ctType) {
+    this.type = ctType;
   }
 
   public boolean isGenGetter() {
@@ -69,12 +63,4 @@ public boolean isGenSetter() {
   public void setGenSetter(boolean genSetter) {
     this.genSetter = genSetter;
   }
-
-  public String getGenericSignature() {
-    if (type.hasGenericTypes()) {
-      return type.getGenericSignature();
-    }
-
-    return null;
-  }
 }
diff --git a/common/common-javassist/src/main/java/org/apache/servicecomb/common/javassist/JavassistUtils.java b/common/common-javassist/src/main/java/org/apache/servicecomb/common/javassist/JavassistUtils.java
index e3691744f..025ea9474 100644
--- a/common/common-javassist/src/main/java/org/apache/servicecomb/common/javassist/JavassistUtils.java
+++ b/common/common-javassist/src/main/java/org/apache/servicecomb/common/javassist/JavassistUtils.java
@@ -22,15 +22,11 @@
 import java.lang.reflect.Modifier;
 import java.nio.charset.StandardCharsets;
 import java.util.Arrays;
-import java.util.IdentityHashMap;
 import java.util.List;
-import java.util.Map;
 
 import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
-import org.springframework.util.ClassUtils;
 
-import com.fasterxml.jackson.databind.JavaType;
 import com.google.common.hash.Hashing;
 
 import javassist.CannotCompileException;
@@ -39,36 +35,21 @@
 import javassist.CtConstructor;
 import javassist.CtField;
 import javassist.CtMethod;
-import javassist.LoaderClassPath;
-import javassist.NotFoundException;
+import javassist.scopedpool.ScopedClassPoolRepositoryImpl;
 
 public final class JavassistUtils {
   private static final Logger LOGGER = LoggerFactory.getLogger(JavassistUtils.class);
 
-  private static final Map<ClassLoader, ClassPool> CLASSPOOLS = new IdentityHashMap<>();
-
-  private static final Object LOCK = new Object();
-
-  private static ClassPool getOrCreateClassPool(ClassLoader classLoader) {
-    ClassPool classPool = CLASSPOOLS.get(classLoader);
-    if (classPool == null) {
-      synchronized (LOCK) {
-        classPool = CLASSPOOLS.get(classLoader);
-        if (classPool == null) {
-          classPool = new ClassPool(null);
-          classPool.appendSystemPath();
-          classPool.appendClassPath(new LoaderClassPath(classLoader));
-
-          CLASSPOOLS.put(classLoader, classPool);
-        }
-      }
-    }
+  static {
+    ScopedClassPoolRepositoryImpl.getInstance().setClassPoolFactory(new StdScopedClassPoolFactory());
+  }
 
-    return classPool;
+  public static ClassPool getOrCreateClassPool(ClassLoader classLoader) {
+    return ScopedClassPoolRepositoryImpl.getInstance().registerClassLoader(classLoader);
   }
 
   public static void clearByClassLoader(ClassLoader classLoader) {
-    CLASSPOOLS.remove(classLoader);
+    ScopedClassPoolRepositoryImpl.getInstance().unregisterClassLoader(classLoader);
   }
 
   private JavassistUtils() {
@@ -179,7 +160,7 @@ private static void addEnumValuesMethod(CtClass ctClass, List<String> values) th
       }
 
       for (FieldConfig fieldConfig : config.getFieldList()) {
-        CtField field = createCtField(classPool, ctClass, fieldConfig);
+        CtField field = createCtField(ctClass, fieldConfig);
         ctClass.addField(field);
 
         if (fieldConfig.isGenGetter()) {
@@ -221,9 +202,9 @@ public static String capitalize(String name) {
   private static void addFieldGetter(ClassConfig config, FieldConfig fieldConfig) {
     MethodConfig methodConfig = new MethodConfig();
 
-    Class<?> cls = fieldConfig.getRawType();
     String prefix = "get";
-    if (cls.equals(Boolean.class) || cls.equals(boolean.class)) {
+    if (boolean.class.getName().equals(fieldConfig.getType().getCtClass().getName())
+        || Boolean.class.getName().equals(fieldConfig.getType().getCtClass().getName())) {
       prefix = "is";
     }
     methodConfig.setName(prefix + capitalize(fieldConfig.getName()));
@@ -270,7 +251,7 @@ public static void genSingleWrapperInterface(ClassConfig config) {
     }
   }
 
-  private static String genReadFieldsMethodSource(List<FieldConfig> fieldList) throws Exception {
+  private static String genReadFieldsMethodSource(List<FieldConfig> fieldList) {
     StringBuilder sb = new StringBuilder();
     sb.append("public Object[] readFields(){");
     sb.append(String.format("Object values[] = new Object[%d];", fieldList.size()));
@@ -289,17 +270,16 @@ private static String genReadFieldsMethodSource(List<FieldConfig> fieldList) thr
     return sb.toString();
   }
 
-  private static String genWriteFieldsMethodSource(List<FieldConfig> fieldList) throws Exception {
+  private static String genWriteFieldsMethodSource(List<FieldConfig> fieldList) {
     StringBuilder sb = new StringBuilder();
     sb.append("public void writeFields(Object[] values){");
     for (int idx = 0; idx < fieldList.size(); idx++) {
       FieldConfig fieldConfig = fieldList.get(idx);
 
       String fieldName = fieldConfig.getName();
-      Class<?> type = fieldConfig.getRawType();
       String code = String.format("    %s = (%s)values[%d];",
           fieldName,
-          type.getTypeName(),
+          fieldConfig.getType().getCtClass().getName(),
           idx);
 
       sb.append(code);
@@ -309,7 +289,7 @@ private static String genWriteFieldsMethodSource(List<FieldConfig> fieldList) th
     return sb.toString();
   }
 
-  private static String genReadFieldMethodSource(List<FieldConfig> fieldList) throws Exception {
+  private static String genReadFieldMethodSource(List<FieldConfig> fieldList) {
     StringBuilder sb = new StringBuilder();
     sb.append("public Object readField(){");
 
@@ -324,7 +304,7 @@ private static String genReadFieldMethodSource(List<FieldConfig> fieldList) thro
     return sb.toString();
   }
 
-  private static String genWriteFieldMethodSource(List<FieldConfig> fieldList) throws Exception {
+  private static String genWriteFieldMethodSource(List<FieldConfig> fieldList) {
     StringBuilder sb = new StringBuilder();
     sb.append("public void writeField(Object value){");
 
@@ -333,7 +313,7 @@ private static String genWriteFieldMethodSource(List<FieldConfig> fieldList) thr
       sb.append(
           String.format("    %s=(%s)value;",
               fieldConfig.getName(),
-              fieldConfig.getRawType().getTypeName()));
+              fieldConfig.getType().getCtClass().getName()));
     }
 
     sb.append("}");
@@ -341,37 +321,12 @@ private static String genWriteFieldMethodSource(List<FieldConfig> fieldList) thr
     return sb.toString();
   }
 
-  private static CtField createCtField(ClassPool pool, CtClass ctClass, FieldConfig field) throws Exception {
-    Class<?> fieldType = field.getRawType();
-
-    CtField ctField = new CtField(pool.getCtClass(fieldType.getName()), field.getName(), ctClass);
-    if (field.getGenericSignature() != null) {
-      ctField.setGenericSignature(field.getGenericSignature());
+  private static CtField createCtField(CtClass ctClass, FieldConfig field) throws CannotCompileException {
+    CtField ctField = new CtField(field.getType().getCtClass(), field.getName(), ctClass);
+    if (field.getType().hasGenericTypes()) {
+      ctField.setGenericSignature(field.getType().getGenericSignature());
     }
     ctField.setModifiers(Modifier.PUBLIC);
     return ctField;
   }
-
-  public static String getNameForGenerateCode(JavaType javaType) {
-    if (byte[].class.equals(javaType.getRawClass())) {
-      return "byte[]";
-    }
-
-    if (!javaType.isArrayType()) {
-      Class<?> rawClass = ClassUtils.resolvePrimitiveIfNecessary(javaType.getRawClass());
-      return rawClass.getTypeName();
-    }
-
-    return javaType.getContentType().getRawClass().getName() + "[]";
-  }
-
-  // for test
-  public static void detach(String clsName) {
-    try {
-      ClassPool classPool = getOrCreateClassPool(Thread.currentThread().getContextClassLoader());
-      classPool.getCtClass(clsName).detach();
-    } catch (NotFoundException e) {
-      // do nothing.
-    }
-  }
 }
diff --git a/common/common-javassist/src/main/java/org/apache/servicecomb/common/javassist/MethodConfig.java b/common/common-javassist/src/main/java/org/apache/servicecomb/common/javassist/MethodConfig.java
index aa0b77313..437c308c3 100644
--- a/common/common-javassist/src/main/java/org/apache/servicecomb/common/javassist/MethodConfig.java
+++ b/common/common-javassist/src/main/java/org/apache/servicecomb/common/javassist/MethodConfig.java
@@ -25,7 +25,7 @@
 public class MethodConfig {
   private String name;
 
-  private JavaType result;
+  private CtType result;
 
   private List<ParameterConfig> parameterList = new ArrayList<>();
 
@@ -60,14 +60,22 @@ public void setName(String name) {
     this.name = name;
   }
 
-  public void setResult(JavaType result) {
+  public void setResult(JavaType javaType) {
+    this.result = new CtType(javaType);
+  }
+
+  public void setResult(CtType result) {
     this.result = result;
   }
 
-  public void addParameter(String name, JavaType type) {
+  public void addParameter(String name, JavaType javaType) {
+    addParameter(name, new CtType(javaType));
+  }
+
+  public void addParameter(String name, CtType ctType) {
     ParameterConfig parameterConfig = new ParameterConfig();
     parameterConfig.setName(name);
-    parameterConfig.setType(type);
+    parameterConfig.setType(ctType);
     parameterList.add(parameterConfig);
   }
 
@@ -84,17 +92,17 @@ void init() {
     StringBuilder sbMethodGenericSignature = new StringBuilder();
 
     sbMethod.append("public ");
-    sbMethod.append(result == null ? "void" : JavassistUtils.getNameForGenerateCode(result));
+    sbMethod.append(result == null ? "void" : result.getCtClass().getName());
     sbMethod.append(" ")
         .append(name)
         .append("(");
     sbMethodGenericSignature.append("(");
 
-    boolean hasGenericSignature = result == null ? false : result.hasGenericTypes();
+    boolean hasGenericSignature = result != null && result.hasGenericTypes();
     for (ParameterConfig parameter : parameterList) {
       hasGenericSignature = hasGenericSignature || parameter.getType().hasGenericTypes();
 
-      String paramTypeName = JavassistUtils.getNameForGenerateCode(parameter.getType());
+      String paramTypeName = parameter.getType().getCtClass().getName();
       String code = String.format("%s %s,", paramTypeName, parameter.getName());
       sbMethod.append(code);
       sbMethodGenericSignature.append(parameter.getType().getGenericSignature());
diff --git a/common/common-javassist/src/main/java/org/apache/servicecomb/common/javassist/ParameterConfig.java b/common/common-javassist/src/main/java/org/apache/servicecomb/common/javassist/ParameterConfig.java
index d7281e68c..3234ccb65 100644
--- a/common/common-javassist/src/main/java/org/apache/servicecomb/common/javassist/ParameterConfig.java
+++ b/common/common-javassist/src/main/java/org/apache/servicecomb/common/javassist/ParameterConfig.java
@@ -16,12 +16,10 @@
  */
 package org.apache.servicecomb.common.javassist;
 
-import com.fasterxml.jackson.databind.JavaType;
-
 public class ParameterConfig {
   private String name;
 
-  private JavaType type;
+  private CtType type;
 
   public String getName() {
     return name;
@@ -31,11 +29,11 @@ public void setName(String name) {
     this.name = name;
   }
 
-  public JavaType getType() {
+  public CtType getType() {
     return type;
   }
 
-  public void setType(JavaType type) {
+  public void setType(CtType type) {
     this.type = type;
   }
 }
diff --git a/common/common-javassist/src/main/java/org/apache/servicecomb/common/javassist/StdScopedClassPool.java b/common/common-javassist/src/main/java/org/apache/servicecomb/common/javassist/StdScopedClassPool.java
new file mode 100644
index 000000000..6f54754e1
--- /dev/null
+++ b/common/common-javassist/src/main/java/org/apache/servicecomb/common/javassist/StdScopedClassPool.java
@@ -0,0 +1,40 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.servicecomb.common.javassist;
+
+import javassist.ClassPool;
+import javassist.CtClass;
+import javassist.scopedpool.ScopedClassPool;
+import javassist.scopedpool.ScopedClassPoolRepository;
+
+/**
+ * getCached of ScopedClassPool, not only search self and parent
+ * but also search other ScopedClassPool in repository
+ *
+ * this is not what we want, so change getCached behavior
+ */
+public class StdScopedClassPool extends ScopedClassPool {
+  protected StdScopedClassPool(ClassLoader cl, ClassPool src,
+      ScopedClassPoolRepository repository, boolean isTemp) {
+    super(cl, src, repository, isTemp);
+  }
+
+  @Override
+  protected CtClass getCached(String classname) {
+    return getCachedLocally(classname);
+  }
+}
diff --git a/common/common-javassist/src/main/java/org/apache/servicecomb/common/javassist/StdScopedClassPoolFactory.java b/common/common-javassist/src/main/java/org/apache/servicecomb/common/javassist/StdScopedClassPoolFactory.java
new file mode 100644
index 000000000..411da775d
--- /dev/null
+++ b/common/common-javassist/src/main/java/org/apache/servicecomb/common/javassist/StdScopedClassPoolFactory.java
@@ -0,0 +1,40 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.servicecomb.common.javassist;
+
+import javassist.ClassPool;
+import javassist.scopedpool.ScopedClassPool;
+import javassist.scopedpool.ScopedClassPoolFactory;
+import javassist.scopedpool.ScopedClassPoolRepository;
+
+public class StdScopedClassPoolFactory implements ScopedClassPoolFactory {
+  /**
+   * Makes an instance.
+   */
+  public ScopedClassPool create(ClassLoader cl, ClassPool src,
+      ScopedClassPoolRepository repository) {
+    return new StdScopedClassPool(cl, src, repository, false);
+  }
+
+  /**
+   * Makes an instance.
+   */
+  public ScopedClassPool create(ClassPool src,
+      ScopedClassPoolRepository repository) {
+    return new StdScopedClassPool(null, src, repository, true);
+  }
+}
\ No newline at end of file
diff --git a/common/common-javassist/src/test/java/org/apache/servicecomb/common/javassist/TestCtType.java b/common/common-javassist/src/test/java/org/apache/servicecomb/common/javassist/TestCtType.java
new file mode 100644
index 000000000..40ecd7b3a
--- /dev/null
+++ b/common/common-javassist/src/test/java/org/apache/servicecomb/common/javassist/TestCtType.java
@@ -0,0 +1,90 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.servicecomb.common.javassist;
+
+import java.util.List;
+
+import org.junit.Assert;
+import org.junit.Test;
+import org.mockito.Mockito;
+
+import com.fasterxml.jackson.databind.JavaType;
+import com.fasterxml.jackson.databind.type.TypeFactory;
+
+import javassist.CtClass;
+import javassist.NotFoundException;
+
+public class TestCtType {
+  CtType ctType;
+
+  @Test
+  public void fromCtClass() {
+    CtClass ctClass = Mockito.mock(CtClass.class);
+    ctType = new CtType(ctClass, true, "Ljava/util/List<[B;>;");
+
+    Assert.assertSame(ctClass, ctType.getCtClass());
+    Assert.assertTrue(ctType.hasGenericTypes());
+    Assert.assertEquals("Ljava/util/List<[B>;", ctType.getGenericSignature());
+  }
+
+  @Test
+  public void fromJavaType() throws NotFoundException {
+    Class<?> cls = String.class;
+    JavaType javaType = TypeFactory.defaultInstance().constructType(cls);
+    ctType = new CtType(javaType);
+
+    Assert.assertSame(JavassistUtils.getOrCreateClassPool(cls.getClassLoader())
+        .get(cls.getCanonicalName()), ctType.getCtClass());
+    Assert.assertFalse(ctType.hasGenericTypes());
+    Assert.assertEquals("Ljava/lang/String;", ctType.getGenericSignature());
+  }
+
+  @Test
+  public void fromJavaType_primitive() throws NotFoundException {
+    Class<?> cls = int.class;
+    JavaType javaType = TypeFactory.defaultInstance().constructType(cls);
+    ctType = new CtType(javaType);
+
+    Assert.assertSame(JavassistUtils.getOrCreateClassPool(Integer.class.getClassLoader())
+        .get(Integer.class.getCanonicalName()), ctType.getCtClass());
+    Assert.assertFalse(ctType.hasGenericTypes());
+    Assert.assertEquals("I;", ctType.getGenericSignature());
+  }
+
+  @Test
+  public void fromJavaType_bytes() throws NotFoundException {
+    Class<?> cls = byte[].class;
+    JavaType javaType = TypeFactory.defaultInstance().constructType(cls);
+    ctType = new CtType(javaType);
+
+    Assert.assertSame(JavassistUtils.getOrCreateClassPool(cls.getClassLoader())
+        .get(cls.getCanonicalName()), ctType.getCtClass());
+    Assert.assertFalse(ctType.hasGenericTypes());
+    Assert.assertEquals("[B;", ctType.getGenericSignature());
+  }
+
+  @Test
+  public void fromJavaType_listBytes() throws NotFoundException {
+    JavaType javaType = TypeFactory.defaultInstance().constructCollectionType(List.class, byte[].class);
+    ctType = new CtType(javaType);
+
+    Assert.assertSame(JavassistUtils.getOrCreateClassPool(List.class.getClassLoader())
+        .get(List.class.getCanonicalName()), ctType.getCtClass());
+    Assert.assertTrue(ctType.hasGenericTypes());
+    Assert.assertEquals("Ljava/util/List<[B>;", ctType.getGenericSignature());
+  }
+}
diff --git a/common/common-javassist/src/test/java/org/apache/servicecomb/common/javassist/TestJavassistUtils.java b/common/common-javassist/src/test/java/org/apache/servicecomb/common/javassist/TestJavassistUtils.java
index a69eb0fd7..6869bf2a4 100644
--- a/common/common-javassist/src/test/java/org/apache/servicecomb/common/javassist/TestJavassistUtils.java
+++ b/common/common-javassist/src/test/java/org/apache/servicecomb/common/javassist/TestJavassistUtils.java
@@ -33,11 +33,11 @@
 import org.junit.Assert;
 import org.junit.Test;
 
-import com.fasterxml.jackson.databind.JavaType;
 import com.fasterxml.jackson.databind.type.TypeFactory;
 import com.google.common.hash.Hashing;
 
 import javassist.ClassPool;
+import javassist.scopedpool.ScopedClassPoolRepositoryImpl;
 import mockit.Deencapsulation;
 
 public class TestJavassistUtils {
@@ -54,11 +54,17 @@ public void testField() throws Exception {
     fieldConfig.setGenGetter(true);
     fieldConfig.setGenSetter(true);
 
-    fieldConfig = classConfig.addField("listStringField",
-        TypeFactory.defaultInstance().constructCollectionType(List.class, String.class));
+    fieldConfig = classConfig
+        .addField("listStringField", TypeFactory.defaultInstance().constructCollectionType(List.class, String.class));
     fieldConfig.setGenGetter(true);
     fieldConfig.setGenSetter(true);
 
+    fieldConfig = classConfig.addField("bool", TypeFactory.defaultInstance().constructType(boolean.class));
+    fieldConfig.setGenGetter(true);
+
+    fieldConfig = classConfig.addField("wrapperBool", TypeFactory.defaultInstance().constructType(Boolean.class));
+    fieldConfig.setGenGetter(true);
+
     Class<?> cls = JavassistUtils.createClass(classConfig);
 
     Field field = cls.getField("intField");
@@ -78,6 +84,12 @@ public void testField() throws Exception {
 
     method = cls.getMethod("getListStringField");
     Assert.assertEquals("java.util.List<java.lang.String>", method.getGenericReturnType().getTypeName());
+
+    method = cls.getMethod("isBool");
+    Assert.assertEquals(Boolean.class, method.getReturnType());
+
+    method = cls.getMethod("isWrapperBool");
+    Assert.assertEquals(Boolean.class, method.getReturnType());
   }
 
   @Test
@@ -90,10 +102,9 @@ public void testAddParameter() {
     MethodConfig methodConfig = new MethodConfig();
     methodConfig.setName("method");
     methodConfig.setResult(TypeFactory.defaultInstance().constructCollectionType(List.class, String.class));
-    methodConfig.addParameter("map",
-        TypeFactory.defaultInstance().constructMapType(Map.class, String.class, String.class));
-    methodConfig.addParameter("set",
-        TypeFactory.defaultInstance().constructCollectionType(Set.class, String.class));
+    methodConfig
+        .addParameter("map", TypeFactory.defaultInstance().constructMapType(Map.class, String.class, String.class));
+    methodConfig.addParameter("set", TypeFactory.defaultInstance().constructCollectionType(Set.class, String.class));
     classConfig.addMethod(methodConfig);
 
     Class<?> intf = JavassistUtils.createClass(classConfig);
@@ -109,7 +120,7 @@ public void testAddParameter() {
   }
 
   @Test
-  public void testInterface() throws Exception {
+  public void testInterface() {
     ClassConfig classConfig = new ClassConfig();
     classConfig.setIntf(true);
     String intfName = "cse.ut.TestInterface";
@@ -213,7 +224,6 @@ public void getOrCreateEnumWithPackageName()
             .getOrCreateEnumWithPackageName(Thread.currentThread().getContextClassLoader(),
                 packageName,
                 Arrays.asList("a", "b")));
-
   }
 
   @Test
@@ -238,21 +248,6 @@ protected void checkEnum(String expectName, Class<? extends Enum> cls)
     Assert.assertEquals(1, values[1].ordinal());
   }
 
-  @Test
-  public void testGetNameForGenerateCode() {
-    JavaType jt = TypeFactory.defaultInstance().constructType(byte[].class);
-    String name = JavassistUtils.getNameForGenerateCode(jt);
-    Assert.assertEquals("byte[]", name);
-
-    jt = TypeFactory.defaultInstance().constructType(Byte[].class);
-    name = JavassistUtils.getNameForGenerateCode(jt);
-    Assert.assertEquals("java.lang.Byte[]", name);
-
-    jt = TypeFactory.defaultInstance().constructType(Object[].class);
-    name = JavassistUtils.getNameForGenerateCode(jt);
-    Assert.assertEquals("java.lang.Object[]", name);
-  }
-
   @Test
   public void managerClassPool() {
     ClassLoader classLoader1 = new ClassLoader() {
@@ -264,8 +259,10 @@ public void managerClassPool() {
     ClassPool p2 = Deencapsulation.invoke(JavassistUtils.class, "getOrCreateClassPool", classLoader2);
     Assert.assertNotSame(p1, p2);
 
-    Map<ClassLoader, ClassPool> CLASSPOOLS = Deencapsulation.getField(JavassistUtils.class, "CLASSPOOLS");
     JavassistUtils.clearByClassLoader(classLoader1);
-    Assert.assertNull(CLASSPOOLS.get(classLoader1));
+    Assert.assertFalse(ScopedClassPoolRepositoryImpl.getInstance().getRegisteredCLs().containsKey(classLoader1));
+
+    JavassistUtils.clearByClassLoader(classLoader2);
+    Assert.assertFalse(ScopedClassPoolRepositoryImpl.getInstance().getRegisteredCLs().containsKey(classLoader2));
   }
 }
diff --git a/common/common-protobuf/src/main/java/org/apache/servicecomb/codec/protobuf/definition/OperationProtobuf.java b/common/common-protobuf/src/main/java/org/apache/servicecomb/codec/protobuf/definition/OperationProtobuf.java
index fe97a7aba..428af56c8 100644
--- a/common/common-protobuf/src/main/java/org/apache/servicecomb/codec/protobuf/definition/OperationProtobuf.java
+++ b/common/common-protobuf/src/main/java/org/apache/servicecomb/codec/protobuf/definition/OperationProtobuf.java
@@ -33,8 +33,7 @@
 
   private WrapSchema responseSchema;
 
-  public OperationProtobuf(OperationMeta operationMeta)
-      throws Exception {
+  public OperationProtobuf(OperationMeta operationMeta) {
     this.operationMeta = operationMeta;
 
     requestSchema = ProtobufSchemaUtils.getOrCreateArgsSchema(operationMeta);
diff --git a/common/common-protobuf/src/main/java/org/apache/servicecomb/codec/protobuf/utils/ProtobufSchemaUtils.java b/common/common-protobuf/src/main/java/org/apache/servicecomb/codec/protobuf/utils/ProtobufSchemaUtils.java
index 8fd1e89dd..52fd03872 100644
--- a/common/common-protobuf/src/main/java/org/apache/servicecomb/codec/protobuf/utils/ProtobufSchemaUtils.java
+++ b/common/common-protobuf/src/main/java/org/apache/servicecomb/codec/protobuf/utils/ProtobufSchemaUtils.java
@@ -72,7 +72,7 @@ public void writeTo(Output output, int number, Object value, boolean repeated) t
       }
 
       @Override
-      public void transfer(Pipe pipe, Input input, Output output, int number, boolean repeated) throws IOException {
+      public void transfer(Pipe pipe, Input input, Output output, int number, boolean repeated) {
         throw new IllegalStateException("not support.");
       }
 
@@ -134,7 +134,7 @@ private static boolean isNeedWrap(Class<?> cls) {
   }
 
   // 为了支持method args的场景,全部实现ProtobufMessageWrapper接口,有的场景有点浪费,不过无关紧要
-  private static WrapSchema createWrapSchema(WrapClassConfig config) throws Exception {
+  private static WrapSchema createWrapSchema(WrapClassConfig config) {
     Class<?> cls = JavassistUtils.createClass(config);
     Schema<?> schema = RuntimeSchema.createFrom(cls);
     return WrapSchemaFactory.createSchema(schema, config.getType());
diff --git a/common/common-protobuf/src/test/java/org/apache/servicecomb/codec/protobuf/utils/TestProtobufSchemaUtils.java b/common/common-protobuf/src/test/java/org/apache/servicecomb/codec/protobuf/utils/TestProtobufSchemaUtils.java
index 883edb07d..bfc0dc9b2 100644
--- a/common/common-protobuf/src/test/java/org/apache/servicecomb/codec/protobuf/utils/TestProtobufSchemaUtils.java
+++ b/common/common-protobuf/src/test/java/org/apache/servicecomb/codec/protobuf/utils/TestProtobufSchemaUtils.java
@@ -55,7 +55,7 @@ public void testMap() throws Exception {
   public void wrapPrimitive() throws Exception {
     Assert.assertNotNull(WrapType.ARGS_WRAP);
     Assert.assertNotNull(WrapType.NORMAL_WRAP);
-    testSchema((int) 1);
+    testSchema(1);
     testSchema("test");
     testSchema(WrapType.ARGS_WRAP);
     Assert.assertTrue(true);
@@ -77,7 +77,7 @@ public void notWrap() throws Exception {
     FieldConfig expect = new FieldConfig();
     expect.setName("test");
 
-    FieldConfig result = (FieldConfig) writeThenRead(expect);
+    FieldConfig result = writeThenRead(expect);
     Assert.assertEquals(expect.getName(), result.getName());
   }
 
diff --git a/swagger/swagger-generator/generator-core/src/main/java/org/apache/servicecomb/swagger/converter/ConverterMgr.java b/swagger/swagger-generator/generator-core/src/main/java/org/apache/servicecomb/swagger/converter/ConverterMgr.java
index a70907e5f..05177dbad 100644
--- a/swagger/swagger-generator/generator-core/src/main/java/org/apache/servicecomb/swagger/converter/ConverterMgr.java
+++ b/swagger/swagger-generator/generator-core/src/main/java/org/apache/servicecomb/swagger/converter/ConverterMgr.java
@@ -40,7 +40,6 @@
 import org.apache.servicecomb.swagger.extend.property.ShortProperty;
 
 import com.fasterxml.jackson.databind.JavaType;
-import com.fasterxml.jackson.databind.type.SimpleType;
 import com.fasterxml.jackson.databind.type.TypeFactory;
 
 import io.swagger.models.ArrayModel;
@@ -108,28 +107,28 @@ private static void initTypeFormatMap() {
   }
 
   private static void initPropertyMap() {
-    PROPERTY_MAP.put(BooleanProperty.class, SimpleType.constructUnsafe(Boolean.class));
+    PROPERTY_MAP.put(BooleanProperty.class, TypeFactory.defaultInstance().constructType(Boolean.class));
 
-    PROPERTY_MAP.put(FloatProperty.class, SimpleType.constructUnsafe(Float.class));
-    PROPERTY_MAP.put(DoubleProperty.class, SimpleType.constructUnsafe(Double.class));
-    PROPERTY_MAP.put(DecimalProperty.class, SimpleType.constructUnsafe(BigDecimal.class));
+    PROPERTY_MAP.put(FloatProperty.class, TypeFactory.defaultInstance().constructType(Float.class));
+    PROPERTY_MAP.put(DoubleProperty.class, TypeFactory.defaultInstance().constructType(Double.class));
+    PROPERTY_MAP.put(DecimalProperty.class, TypeFactory.defaultInstance().constructType(BigDecimal.class));
 
-    PROPERTY_MAP.put(ByteProperty.class, SimpleType.constructUnsafe(Byte.class));
-    PROPERTY_MAP.put(ShortProperty.class, SimpleType.constructUnsafe(Short.class));
-    PROPERTY_MAP.put(IntegerProperty.class, SimpleType.constructUnsafe(Integer.class));
-    PROPERTY_MAP.put(BaseIntegerProperty.class, SimpleType.constructUnsafe(Integer.class));
-    PROPERTY_MAP.put(LongProperty.class, SimpleType.constructUnsafe(Long.class));
+    PROPERTY_MAP.put(ByteProperty.class, TypeFactory.defaultInstance().constructType(Byte.class));
+    PROPERTY_MAP.put(ShortProperty.class, TypeFactory.defaultInstance().constructType(Short.class));
+    PROPERTY_MAP.put(IntegerProperty.class, TypeFactory.defaultInstance().constructType(Integer.class));
+    PROPERTY_MAP.put(BaseIntegerProperty.class, TypeFactory.defaultInstance().constructType(Integer.class));
+    PROPERTY_MAP.put(LongProperty.class, TypeFactory.defaultInstance().constructType(Long.class));
 
     // stringProperty包含了enum的场景,并不一定是转化为string
     // 但是,如果统一走StringPropertyConverter则可以处理enum的场景
-    PROPERTY_MAP.put(StringProperty.class, SimpleType.constructUnsafe(String.class));
+    PROPERTY_MAP.put(StringProperty.class, TypeFactory.defaultInstance().constructType(String.class));
 
-    PROPERTY_MAP.put(DateProperty.class, SimpleType.constructUnsafe(LocalDate.class));
-    PROPERTY_MAP.put(DateTimeProperty.class, SimpleType.constructUnsafe(Date.class));
+    PROPERTY_MAP.put(DateProperty.class, TypeFactory.defaultInstance().constructType(LocalDate.class));
+    PROPERTY_MAP.put(DateTimeProperty.class, TypeFactory.defaultInstance().constructType(Date.class));
 
-    PROPERTY_MAP.put(ByteArrayProperty.class, SimpleType.constructUnsafe(byte[].class));
+    PROPERTY_MAP.put(ByteArrayProperty.class, TypeFactory.defaultInstance().constructType(byte[].class));
 
-    PROPERTY_MAP.put(FileProperty.class, SimpleType.constructUnsafe(Part.class));
+    PROPERTY_MAP.put(FileProperty.class, TypeFactory.defaultInstance().constructType(Part.class));
   }
 
   private static void initConverters() {
diff --git a/swagger/swagger-generator/generator-core/src/main/java/org/apache/servicecomb/swagger/generator/core/unittest/UnitTestSwaggerUtils.java b/swagger/swagger-generator/generator-core/src/main/java/org/apache/servicecomb/swagger/generator/core/unittest/UnitTestSwaggerUtils.java
index 2829a6442..346f8294d 100644
--- a/swagger/swagger-generator/generator-core/src/main/java/org/apache/servicecomb/swagger/generator/core/unittest/UnitTestSwaggerUtils.java
+++ b/swagger/swagger-generator/generator-core/src/main/java/org/apache/servicecomb/swagger/generator/core/unittest/UnitTestSwaggerUtils.java
@@ -83,11 +83,11 @@ public static Swagger parse(String content) {
     }
   }
 
-  public static SwaggerGenerator testSwagger(String resPath, SwaggerGeneratorContext context, Class<?> cls,
+  public static SwaggerGenerator testSwagger(ClassLoader classLoader, String resPath, SwaggerGeneratorContext context,
+      Class<?> cls,
       String... methods) {
     SwaggerGeneratorForTest generator = new SwaggerGeneratorForTest(context, cls);
-    generator.setClassLoader(new ClassLoader() {
-    });
+    generator.setClassLoader(classLoader);
     generator.replaceMethods(methods);
 
     Swagger swagger = generator.generate();
diff --git a/swagger/swagger-generator/generator-core/src/test/java/org/apache/servicecomb/swagger/converter/TestConverterMgr.java b/swagger/swagger-generator/generator-core/src/test/java/org/apache/servicecomb/swagger/converter/TestConverterMgr.java
new file mode 100644
index 000000000..d3b793c53
--- /dev/null
+++ b/swagger/swagger-generator/generator-core/src/test/java/org/apache/servicecomb/swagger/converter/TestConverterMgr.java
@@ -0,0 +1,65 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.servicecomb.swagger.converter;
+
+import java.util.Map;
+
+import org.apache.commons.lang3.reflect.FieldUtils;
+import org.apache.servicecomb.swagger.extend.property.ByteProperty;
+import org.apache.servicecomb.swagger.extend.property.ShortProperty;
+import org.junit.Assert;
+import org.junit.Test;
+
+import com.fasterxml.jackson.databind.JavaType;
+
+import io.swagger.models.properties.BaseIntegerProperty;
+import io.swagger.models.properties.BooleanProperty;
+import io.swagger.models.properties.ByteArrayProperty;
+import io.swagger.models.properties.DateProperty;
+import io.swagger.models.properties.DateTimeProperty;
+import io.swagger.models.properties.DecimalProperty;
+import io.swagger.models.properties.DoubleProperty;
+import io.swagger.models.properties.FileProperty;
+import io.swagger.models.properties.FloatProperty;
+import io.swagger.models.properties.IntegerProperty;
+import io.swagger.models.properties.LongProperty;
+import io.swagger.models.properties.Property;
+import io.swagger.models.properties.StringProperty;
+
+public class TestConverterMgr {
+  @Test
+  public void propertyMapGenericSignature() throws IllegalAccessException {
+    @SuppressWarnings("unchecked")
+    Map<Class<? extends Property>, JavaType> propertyMap = (Map<Class<? extends Property>, JavaType>) FieldUtils
+        .readStaticField(ConverterMgr.class, "PROPERTY_MAP", true);
+
+    Assert.assertEquals("Ljava/lang/Boolean;", propertyMap.get(BooleanProperty.class).getGenericSignature());
+    Assert.assertEquals("Ljava/lang/Float;", propertyMap.get(FloatProperty.class).getGenericSignature());
+    Assert.assertEquals("Ljava/lang/Double;", propertyMap.get(DoubleProperty.class).getGenericSignature());
+    Assert.assertEquals("Ljava/math/BigDecimal;", propertyMap.get(DecimalProperty.class).getGenericSignature());
+    Assert.assertEquals("Ljava/lang/Byte;", propertyMap.get(ByteProperty.class).getGenericSignature());
+    Assert.assertEquals("Ljava/lang/Short;", propertyMap.get(ShortProperty.class).getGenericSignature());
+    Assert.assertEquals("Ljava/lang/Integer;", propertyMap.get(IntegerProperty.class).getGenericSignature());
+    Assert.assertEquals("Ljava/lang/Integer;", propertyMap.get(BaseIntegerProperty.class).getGenericSignature());
+    Assert.assertEquals("Ljava/lang/Long;", propertyMap.get(LongProperty.class).getGenericSignature());
+    Assert.assertEquals("Ljava/lang/String;", propertyMap.get(StringProperty.class).getGenericSignature());
+    Assert.assertEquals("Ljava/time/LocalDate;", propertyMap.get(DateProperty.class).getGenericSignature());
+    Assert.assertEquals("Ljava/util/Date;", propertyMap.get(DateTimeProperty.class).getGenericSignature());
+    Assert.assertEquals("[B;", propertyMap.get(ByteArrayProperty.class).getGenericSignature());
+    Assert.assertEquals("Ljavax/servlet/http/Part;", propertyMap.get(FileProperty.class).getGenericSignature());
+  }
+}
diff --git a/swagger/swagger-generator/generator-core/src/test/java/org/apache/servicecomb/swagger/converter/model/TestModelImplConverter.java b/swagger/swagger-generator/generator-core/src/test/java/org/apache/servicecomb/swagger/converter/model/TestModelImplConverter.java
index c0ced849f..6e0e178b9 100644
--- a/swagger/swagger-generator/generator-core/src/test/java/org/apache/servicecomb/swagger/converter/model/TestModelImplConverter.java
+++ b/swagger/swagger-generator/generator-core/src/test/java/org/apache/servicecomb/swagger/converter/model/TestModelImplConverter.java
@@ -18,9 +18,11 @@
 
 import java.util.Map;
 
+import org.apache.servicecomb.common.javassist.JavassistUtils;
 import org.apache.servicecomb.swagger.converter.SwaggerToClassGenerator;
 import org.apache.servicecomb.swagger.generator.core.SwaggerConst;
 import org.apache.servicecomb.swagger.generator.core.utils.ParamUtils;
+import org.junit.After;
 import org.junit.Assert;
 import org.junit.Rule;
 import org.junit.Test;
@@ -46,6 +48,11 @@
 
   SwaggerToClassGenerator swaggerToClassGenerator = new SwaggerToClassGenerator(classLoader, swagger, "pkg");
 
+  @After
+  public void teardown() {
+    JavassistUtils.clearByClassLoader(classLoader);
+  }
+
   @Test
   public void convert_simple() {
     ModelImpl model = new ModelImpl();
diff --git a/swagger/swagger-generator/generator-core/src/test/java/org/apache/servicecomb/swagger/generator/core/TestArrayType.java b/swagger/swagger-generator/generator-core/src/test/java/org/apache/servicecomb/swagger/generator/core/TestArrayType.java
index da8a1aa4e..695bf3c88 100644
--- a/swagger/swagger-generator/generator-core/src/test/java/org/apache/servicecomb/swagger/generator/core/TestArrayType.java
+++ b/swagger/swagger-generator/generator-core/src/test/java/org/apache/servicecomb/swagger/generator/core/TestArrayType.java
@@ -18,9 +18,11 @@
 
 import java.lang.reflect.Method;
 
+import org.apache.servicecomb.common.javassist.JavassistUtils;
 import org.apache.servicecomb.foundation.common.utils.ReflectUtils;
 import org.apache.servicecomb.swagger.generator.core.schema.ArrayType;
 import org.apache.servicecomb.swagger.generator.core.unittest.UnitTestSwaggerUtils;
+import org.junit.After;
 import org.junit.Assert;
 import org.junit.Test;
 
@@ -28,9 +30,17 @@
 import javassist.CtMethod;
 
 public class TestArrayType {
+  ClassLoader classLoader = new ClassLoader() {
+  };
+
+  @After
+  public void tearDown() {
+    JavassistUtils.clearByClassLoader(classLoader);
+  }
+
   @Test
   public void test() throws Exception {
-    SwaggerGenerator generator = UnitTestSwaggerUtils.generateSwagger(ArrayType.class);
+    SwaggerGenerator generator = UnitTestSwaggerUtils.generateSwagger(classLoader, ArrayType.class);
     Class<?> cls = ClassUtilsForTest.getOrCreateInterface(generator);
     Method method = ReflectUtils.findMethod(cls, "testBytes");
 
diff --git a/swagger/swagger-generator/generator-core/src/test/java/org/apache/servicecomb/swagger/generator/core/TestSwaggerUtils.java b/swagger/swagger-generator/generator-core/src/test/java/org/apache/servicecomb/swagger/generator/core/TestSwaggerUtils.java
index b2f76a773..b5c127c29 100644
--- a/swagger/swagger-generator/generator-core/src/test/java/org/apache/servicecomb/swagger/generator/core/TestSwaggerUtils.java
+++ b/swagger/swagger-generator/generator-core/src/test/java/org/apache/servicecomb/swagger/generator/core/TestSwaggerUtils.java
@@ -29,19 +29,28 @@
 import org.apache.servicecomb.swagger.generator.core.schema.Schema;
 import org.apache.servicecomb.swagger.generator.core.unittest.UnitTestSwaggerUtils;
 import org.apache.servicecomb.swagger.generator.pojo.PojoSwaggerGeneratorContext;
+import org.junit.After;
 import org.junit.Assert;
 import org.junit.Test;
 
 public class TestSwaggerUtils {
+  ClassLoader classLoader = new ClassLoader() {
+  };
+
   SwaggerGeneratorContext context = new PojoSwaggerGeneratorContext();
 
   private SwaggerGenerator testSchemaMethod(String resultName, String... methodNames) {
-    return UnitTestSwaggerUtils.testSwagger("schemas/" + resultName + ".yaml",
+    return UnitTestSwaggerUtils.testSwagger(classLoader, "schemas/" + resultName + ".yaml",
         context,
         Schema.class,
         methodNames);
   }
 
+  @After
+  public void tearDown() {
+    JavassistUtils.clearByClassLoader(classLoader);
+  }
+
   @Test
   public void testBoolean() {
     testSchemaMethod("boolean", "testboolean");
@@ -87,7 +96,6 @@ public void testDouble() {
   @Test
   public void testEnum() {
     SwaggerGenerator generator = testSchemaMethod("enum", "testEnum");
-    JavassistUtils.detach("gen.cse.ms.ut.SchemaIntf");
     Class<?> intf = ClassUtilsForTest.getOrCreateInterface(generator);
 
     Method method = ReflectUtils.findMethod(intf, "testEnum");
@@ -182,7 +190,6 @@ public void testCompletableFuture() {
   @Test
   public void testDate() {
     SwaggerGenerator generator = testSchemaMethod("date", "testDate");
-    JavassistUtils.detach("gen.cse.ms.ut.SchemaIntf");
     Class<?> intf = ClassUtilsForTest.getOrCreateInterface(generator);
 
     Method method = ReflectUtils.findMethod(intf, "testDate");
diff --git a/swagger/swagger-generator/generator-jaxrs/src/test/java/org/apache/servicecomb/swagger/generator/jaxrs/TestJaxrs.java b/swagger/swagger-generator/generator-jaxrs/src/test/java/org/apache/servicecomb/swagger/generator/jaxrs/TestJaxrs.java
index e5a731b08..09ee931e7 100644
--- a/swagger/swagger-generator/generator-jaxrs/src/test/java/org/apache/servicecomb/swagger/generator/jaxrs/TestJaxrs.java
+++ b/swagger/swagger-generator/generator-jaxrs/src/test/java/org/apache/servicecomb/swagger/generator/jaxrs/TestJaxrs.java
@@ -17,15 +17,25 @@
 
 package org.apache.servicecomb.swagger.generator.jaxrs;
 
+import org.apache.servicecomb.common.javassist.JavassistUtils;
 import org.apache.servicecomb.swagger.generator.core.CompositeSwaggerGeneratorContext;
 import org.apache.servicecomb.swagger.generator.core.SwaggerGeneratorContext;
 import org.apache.servicecomb.swagger.generator.core.unittest.UnitTestSwaggerUtils;
+import org.junit.After;
 import org.junit.Assert;
 import org.junit.Test;
 
 public class TestJaxrs {
+  ClassLoader classLoader = new ClassLoader() {
+  };
+
   SwaggerGeneratorContext context = new JaxrsSwaggerGeneratorContext();
 
+  @After
+  public void tearDown() {
+    JavassistUtils.clearByClassLoader(classLoader);
+  }
+
   @Test
   public void testMultiDefaultPath() {
     UnitTestSwaggerUtils.testException(
@@ -35,12 +45,12 @@ public void testMultiDefaultPath() {
   }
 
   @Test
-  public void testResponse() throws Exception {
-    UnitTestSwaggerUtils.testSwagger("schemas/response.yaml", context, Echo.class, "response");
+  public void testResponse() {
+    UnitTestSwaggerUtils.testSwagger(classLoader, "schemas/response.yaml", context, Echo.class, "response");
   }
 
   @Test
-  public void testInvalidResponse() throws Exception {
+  public void testInvalidResponse() {
     UnitTestSwaggerUtils.testException(
         "generate operation swagger failed, org.apache.servicecomb.swagger.generator.jaxrs.Echo:invalidResponse",
         "Use ApiOperation or ApiResponses to declare response type",
@@ -50,22 +60,22 @@ public void testInvalidResponse() throws Exception {
   }
 
   @Test
-  public void testEcho() throws Exception {
-    UnitTestSwaggerUtils.testSwagger("schemas/echo.yaml", context, Echo.class, "echo");
+  public void testEcho() {
+    UnitTestSwaggerUtils.testSwagger(classLoader, "schemas/echo.yaml", context, Echo.class, "echo");
   }
 
   @Test
-  public void testForm() throws Exception {
-    UnitTestSwaggerUtils.testSwagger("schemas/form.yaml", context, Echo.class, "form");
+  public void testForm() {
+    UnitTestSwaggerUtils.testSwagger(classLoader, "schemas/form.yaml", context, Echo.class, "form");
   }
 
   @Test
-  public void testQuery() throws Exception {
-    UnitTestSwaggerUtils.testSwagger("schemas/query.yaml", context, Echo.class, "query");
+  public void testQuery() {
+    UnitTestSwaggerUtils.testSwagger(classLoader, "schemas/query.yaml", context, Echo.class, "query");
   }
 
   @Test
-  public void testQueryComplex() throws Exception {
+  public void testQueryComplex() {
     UnitTestSwaggerUtils.testException(
         "generate operation swagger failed, org.apache.servicecomb.swagger.generator.jaxrs.Echo:queryComplex",
         "not allow complex type for query parameter, method=org.apache.servicecomb.swagger.generator.jaxrs.Echo:queryComplex, paramIdx=0, type=java.util.List<org.apache.servicecomb.swagger.generator.jaxrs.User>",
@@ -75,22 +85,23 @@ public void testQueryComplex() throws Exception {
   }
 
   @Test
-  public void testCookie() throws Exception {
-    UnitTestSwaggerUtils.testSwagger("schemas/cookie.yaml", context, Echo.class, "cookie");
+  public void testCookie() {
+    UnitTestSwaggerUtils.testSwagger(classLoader, "schemas/cookie.yaml", context, Echo.class, "cookie");
   }
 
   @Test
-  public void testEmptyPath() throws Exception {
-    UnitTestSwaggerUtils.testSwagger("schemas/emptyPath.yaml", context, Echo.class, "emptyPath");
+  public void testEmptyPath() {
+    UnitTestSwaggerUtils.testSwagger(classLoader, "schemas/emptyPath.yaml", context, Echo.class, "emptyPath");
   }
 
   @Test
-  public void testNonRestful() throws Exception {
-    UnitTestSwaggerUtils.testSwagger("schemas/emptyContract.yaml", context, Echo.class, "ignoredNonRestful");
+  public void testNonRestful() {
+    UnitTestSwaggerUtils
+        .testSwagger(classLoader, "schemas/emptyContract.yaml", context, Echo.class, "ignoredNonRestful");
   }
 
   @Test
-  public void testClassMethodNoPath() throws Exception {
+  public void testClassMethodNoPath() {
     UnitTestSwaggerUtils.testException(
         "generate operation swagger failed, org.apache.servicecomb.swagger.generator.jaxrs.ClassMethodNoPath:p1",
         "Path must not both be empty in class and method",
@@ -107,7 +118,8 @@ public void testComposite() {
   }
 
   @Test
-  public void testRawJsonStringMethod() throws Exception {
-    UnitTestSwaggerUtils.testSwagger("schemas/rawJsonStringMethod.yaml", context, Echo.class, "rawJsonStringMethod");
+  public void testRawJsonStringMethod() {
+    UnitTestSwaggerUtils
+        .testSwagger(classLoader, "schemas/rawJsonStringMethod.yaml", context, Echo.class, "rawJsonStringMethod");
   }
 }
diff --git a/swagger/swagger-generator/generator-springmvc/src/test/java/org/apache/servicecomb/swagger/generator/springmvc/TestSpringmvc.java b/swagger/swagger-generator/generator-springmvc/src/test/java/org/apache/servicecomb/swagger/generator/springmvc/TestSpringmvc.java
index 48b8cb693..e8b97138a 100644
--- a/swagger/swagger-generator/generator-springmvc/src/test/java/org/apache/servicecomb/swagger/generator/springmvc/TestSpringmvc.java
+++ b/swagger/swagger-generator/generator-springmvc/src/test/java/org/apache/servicecomb/swagger/generator/springmvc/TestSpringmvc.java
@@ -17,15 +17,25 @@
 
 package org.apache.servicecomb.swagger.generator.springmvc;
 
+import org.apache.servicecomb.common.javassist.JavassistUtils;
 import org.apache.servicecomb.swagger.generator.core.CompositeSwaggerGeneratorContext;
 import org.apache.servicecomb.swagger.generator.core.SwaggerGeneratorContext;
 import org.apache.servicecomb.swagger.generator.core.unittest.UnitTestSwaggerUtils;
+import org.junit.After;
 import org.junit.Assert;
 import org.junit.Test;
 
 public class TestSpringmvc {
+  ClassLoader classLoader = new ClassLoader() {
+  };
+
   SwaggerGeneratorContext context = new SpringmvcSwaggerGeneratorContext();
 
+  @After
+  public void tearDown() {
+    JavassistUtils.clearByClassLoader(classLoader);
+  }
+
   @Test
   public void testMultiDefaultPath() {
     UnitTestSwaggerUtils.testException(
@@ -35,40 +45,44 @@ public void testMultiDefaultPath() {
   }
 
   @Test
-  public void testResponseEntity() throws Exception {
-    UnitTestSwaggerUtils.testSwagger("schemas/responseEntity.yaml", context, MethodResponseEntity.class);
+  public void testResponseEntity() {
+    UnitTestSwaggerUtils.testSwagger(classLoader, "schemas/responseEntity.yaml", context, MethodResponseEntity.class);
   }
 
   @Test
-  public void testEmptyPath() throws Exception {
-    UnitTestSwaggerUtils.testSwagger("schemas/emptyPath.yaml", context, Echo.class, "emptyPath");
-    UnitTestSwaggerUtils.testSwagger("schemas/MethodEmptyPath.yaml",
+  public void testEmptyPath() {
+    UnitTestSwaggerUtils.testSwagger(classLoader, "schemas/emptyPath.yaml", context, Echo.class, "emptyPath");
+    UnitTestSwaggerUtils.testSwagger(classLoader, "schemas/MethodEmptyPath.yaml",
         context,
         MethodEmptyPath.class);
   }
 
   @Test
-  public void testMixupAnnotations() throws Exception {
-    UnitTestSwaggerUtils.testSwagger("schemas/mixupAnnotations.yaml", context, MethodMixupAnnotations.class);
+  public void testMixupAnnotations() {
+    UnitTestSwaggerUtils
+        .testSwagger(classLoader, "schemas/mixupAnnotations.yaml", context, MethodMixupAnnotations.class);
   }
 
   @Test
-  public void testDefaultParameter() throws Exception {
-    UnitTestSwaggerUtils.testSwagger("schemas/defaultParameter.yaml", context, MethodDefaultParameter.class);
+  public void testDefaultParameter() {
+    UnitTestSwaggerUtils
+        .testSwagger(classLoader, "schemas/defaultParameter.yaml", context, MethodDefaultParameter.class);
   }
 
   @Test
-  public void testInheritHttpMethod() throws Exception {
-    UnitTestSwaggerUtils.testSwagger("schemas/inheritHttpMethod.yaml", context, Echo.class, "inheritHttpMethod");
+  public void testInheritHttpMethod() {
+    UnitTestSwaggerUtils
+        .testSwagger(classLoader, "schemas/inheritHttpMethod.yaml", context, Echo.class, "inheritHttpMethod");
   }
 
   @Test
-  public void testRawJsonStringMethod() throws Exception {
-    UnitTestSwaggerUtils.testSwagger("schemas/rawJsonStringMethod.yaml", context, Echo.class, "rawJsonStringMethod");
+  public void testRawJsonStringMethod() {
+    UnitTestSwaggerUtils
+        .testSwagger(classLoader, "schemas/rawJsonStringMethod.yaml", context, Echo.class, "rawJsonStringMethod");
   }
 
   @Test
-  public void testClassMethodNoPath() throws Exception {
+  public void testClassMethodNoPath() {
     UnitTestSwaggerUtils.testException(
         "generate operation swagger failed, org.apache.servicecomb.swagger.generator.springmvc.ClassMethodNoPath:noPath",
         "Path must not both be empty in class and method",
@@ -78,7 +92,7 @@ public void testClassMethodNoPath() throws Exception {
   }
 
   @Test
-  public void testClassMethodNoHttpMetod() throws Exception {
+  public void testClassMethodNoHttpMetod() {
     UnitTestSwaggerUtils.testException(
         "generate operation swagger failed, org.apache.servicecomb.swagger.generator.springmvc.ClassMethodNoHttpMethod:noHttpMethod",
         "HttpMethod must not both be empty in class and method",
@@ -87,7 +101,7 @@ public void testClassMethodNoHttpMetod() throws Exception {
   }
 
   @Test
-  public void testMethodMultiHttpMethod() throws Exception {
+  public void testMethodMultiHttpMethod() {
     UnitTestSwaggerUtils.testException(
         "generate operation swagger failed, org.apache.servicecomb.swagger.generator.springmvc.Echo:multiHttpMethod",
         "not allowed multi http method for org.apache.servicecomb.swagger.generator.springmvc.Echo:multiHttpMethod",
@@ -97,7 +111,7 @@ public void testMethodMultiHttpMethod() throws Exception {
   }
 
   @Test
-  public void testClassMultiHttpMethod() throws Exception {
+  public void testClassMultiHttpMethod() {
     UnitTestSwaggerUtils.testException(
         "not allowed multi http method for org.apache.servicecomb.swagger.generator.springmvc.ClassMultiHttpMethod",
         context,
@@ -165,7 +179,7 @@ public void testMethodMultiPathUsingDeleteMapping() {
   }
 
   @Test
-  public void testClassMultiPath() throws Exception {
+  public void testClassMultiPath() {
     UnitTestSwaggerUtils.testException(
         "not support multi path for org.apache.servicecomb.swagger.generator.springmvc.ClassMultiPath",
         context,
diff --git a/swagger/swagger-invocation/invocation-core/src/test/java/org/apache/servicecomb/engine/SwaggerEnvironmentForTest.java b/swagger/swagger-invocation/invocation-core/src/test/java/org/apache/servicecomb/engine/SwaggerEnvironmentForTest.java
index bc5759004..72eb40db4 100644
--- a/swagger/swagger-invocation/invocation-core/src/test/java/org/apache/servicecomb/engine/SwaggerEnvironmentForTest.java
+++ b/swagger/swagger-invocation/invocation-core/src/test/java/org/apache/servicecomb/engine/SwaggerEnvironmentForTest.java
@@ -45,8 +45,8 @@ public SwaggerProducer createProducer(Object producerInstance) {
     SwaggerGenerator producerGenerator = UnitTestSwaggerUtils.generateSwagger(classLoader, producerCls);
     Swagger swagger = producerGenerator.getSwagger();
 
-    SwaggerToClassGenerator swaggerToClassGenerator = new SwaggerToClassGenerator(new ClassLoader() {
-    }, swagger, null);
+    SwaggerToClassGenerator swaggerToClassGenerator = new SwaggerToClassGenerator(classLoader, swagger,
+        producerInstance.getClass().getPackage().getName());
     return swaggerEnvironment.createProducer(producerInstance, swaggerToClassGenerator.convert());
   }
 }
diff --git a/swagger/swagger-invocation/invocation-core/src/test/java/org/apache/servicecomb/engine/TestSwaggerEnvironment.java b/swagger/swagger-invocation/invocation-core/src/test/java/org/apache/servicecomb/engine/TestSwaggerEnvironment.java
index c256775e4..5aa6c99cc 100644
--- a/swagger/swagger-invocation/invocation-core/src/test/java/org/apache/servicecomb/engine/TestSwaggerEnvironment.java
+++ b/swagger/swagger-invocation/invocation-core/src/test/java/org/apache/servicecomb/engine/TestSwaggerEnvironment.java
@@ -22,8 +22,10 @@
 import static org.hamcrest.core.IsNull.nullValue;
 import static org.junit.Assert.assertThat;
 
+import org.apache.servicecomb.common.javassist.JavassistUtils;
 import org.apache.servicecomb.swagger.engine.SwaggerProducer;
 import org.apache.servicecomb.swagger.invocation.models.ProducerImpl;
+import org.junit.AfterClass;
 import org.junit.BeforeClass;
 import org.junit.Test;
 
@@ -37,6 +39,11 @@ public static void init() {
     producer = env.createProducer(new ProducerImpl());
   }
 
+  @AfterClass
+  public static void tearDown() {
+    JavassistUtils.clearByClassLoader(env.getClassLoader());
+  }
+
   @Test
   public void ableToFindVisibleMethod() {
     assertThat(producer.findOperation("visibleMethod"), is(notNullValue()));
diff --git a/swagger/swagger-invocation/invocation-core/src/test/java/org/apache/servicecomb/swagger/invocation/arguments/TestPojoConsumerEqualProducer.java b/swagger/swagger-invocation/invocation-core/src/test/java/org/apache/servicecomb/swagger/invocation/arguments/TestPojoConsumerEqualProducer.java
index 04d2b30c5..ec2ce3f03 100644
--- a/swagger/swagger-invocation/invocation-core/src/test/java/org/apache/servicecomb/swagger/invocation/arguments/TestPojoConsumerEqualProducer.java
+++ b/swagger/swagger-invocation/invocation-core/src/test/java/org/apache/servicecomb/swagger/invocation/arguments/TestPojoConsumerEqualProducer.java
@@ -21,6 +21,7 @@
 import java.util.List;
 import java.util.concurrent.CompletableFuture;
 
+import org.apache.servicecomb.common.javassist.JavassistUtils;
 import org.apache.servicecomb.engine.SwaggerEnvironmentForTest;
 import org.apache.servicecomb.swagger.engine.SwaggerConsumer;
 import org.apache.servicecomb.swagger.engine.SwaggerProducer;
@@ -31,6 +32,7 @@
 import org.apache.servicecomb.swagger.invocation.models.Person;
 import org.apache.servicecomb.swagger.invocation.models.PojoConsumerIntf;
 import org.apache.servicecomb.swagger.invocation.models.PojoImpl;
+import org.junit.AfterClass;
 import org.junit.Assert;
 import org.junit.BeforeClass;
 import org.junit.Test;
@@ -54,8 +56,13 @@ public static void init() {
     proxy = invoker.getProxy();
   }
 
+  @AfterClass
+  public static void tearDown() {
+    JavassistUtils.clearByClassLoader(env.getClassLoader());
+  }
+
   @Test
-  public void testSimple() throws Exception {
+  public void testSimple() {
     int result = proxy.testSimple(1, 2, 3);
 
     Object body = invoker.getSwaggerArgument(0);
@@ -67,7 +74,7 @@ public void testSimple() throws Exception {
   }
 
   @Test
-  public void testObject() throws Exception {
+  public void testObject() {
     Person person = new Person();
     person.setName("abc");
 
@@ -94,7 +101,7 @@ public void testObjectAsync() throws Exception {
   }
 
   @Test
-  public void testSimpleAndObject() throws Exception {
+  public void testSimpleAndObject() {
     Person person = new Person();
     person.setName("abc");
 
@@ -108,7 +115,7 @@ public void testSimpleAndObject() throws Exception {
   }
 
   @Test
-  public void testContext() throws Exception {
+  public void testContext() {
     InvocationContext threadContext = new InvocationContext();
     threadContext.addContext("ta", "tvalue");
     ContextUtils.setInvocationContext(threadContext);
@@ -129,7 +136,7 @@ public void testContext() throws Exception {
   }
 
   @Test
-  public void testBytes() throws Exception {
+  public void testBytes() {
     byte[] bytes = new byte[] {1, 2};
 
     byte[] result = proxy.testBytes(bytes);
@@ -137,11 +144,23 @@ public void testBytes() throws Exception {
     Object body = invoker.getSwaggerArgument(0);
     Assert.assertEquals(bytes, Utils.getFieldValue(body, "bytes"));
 
-    Assert.assertArrayEquals(bytes, (byte[]) result);
+    Assert.assertArrayEquals(bytes, result);
   }
 
   @Test
-  public void testArrayArray() throws Exception {
+  public void testListBytes() {
+    List<byte[]> bytes = Arrays.asList(new byte[] {1, 2});
+
+    List<byte[]> result = proxy.testListBytes(bytes);
+
+    Object body = invoker.getSwaggerArgument(0);
+    Assert.assertEquals(bytes, Utils.getFieldValue(body, "bytes"));
+
+    Assert.assertEquals(bytes, result);
+  }
+
+  @Test
+  public void testArrayArray() {
     String[] array = new String[] {"a", "b"};
     List<String> list = Arrays.asList(array);
 
@@ -150,11 +169,11 @@ public void testArrayArray() throws Exception {
     Object body = invoker.getSwaggerArgument(0);
     Assert.assertEquals(list, Utils.getFieldValue(body, "s"));
 
-    Assert.assertArrayEquals(array, (String[]) result);
+    Assert.assertArrayEquals(array, result);
   }
 
   @Test
-  public void testArrayList() throws Exception {
+  public void testArrayList() {
     String[] array = new String[] {"a", "b"};
     List<String> list = Arrays.asList(array);
     List<String> result = proxy.testArrayList(array);
@@ -166,7 +185,7 @@ public void testArrayList() throws Exception {
   }
 
   @Test
-  public void testListArray() throws Exception {
+  public void testListArray() {
     String[] array = new String[] {"a", "b"};
     List<String> list = Arrays.asList(array);
 
@@ -179,7 +198,7 @@ public void testListArray() throws Exception {
   }
 
   @Test
-  public void testListList() throws Exception {
+  public void testListList() {
     List<String> list = Arrays.asList("a", "b");
 
     List<String> result = proxy.testListList(list);
diff --git a/swagger/swagger-invocation/invocation-core/src/test/java/org/apache/servicecomb/swagger/invocation/arguments/TestPojoConsumerEqualSwagger.java b/swagger/swagger-invocation/invocation-core/src/test/java/org/apache/servicecomb/swagger/invocation/arguments/TestPojoConsumerEqualSwagger.java
index 7a1f4d558..0c553c612 100644
--- a/swagger/swagger-invocation/invocation-core/src/test/java/org/apache/servicecomb/swagger/invocation/arguments/TestPojoConsumerEqualSwagger.java
+++ b/swagger/swagger-invocation/invocation-core/src/test/java/org/apache/servicecomb/swagger/invocation/arguments/TestPojoConsumerEqualSwagger.java
@@ -20,6 +20,7 @@
 import java.util.Arrays;
 import java.util.List;
 
+import org.apache.servicecomb.common.javassist.JavassistUtils;
 import org.apache.servicecomb.engine.SwaggerEnvironmentForTest;
 import org.apache.servicecomb.swagger.engine.SwaggerConsumer;
 import org.apache.servicecomb.swagger.engine.SwaggerProducer;
@@ -29,6 +30,7 @@
 import org.apache.servicecomb.swagger.invocation.models.JaxrsImpl;
 import org.apache.servicecomb.swagger.invocation.models.Person;
 import org.apache.servicecomb.swagger.invocation.models.PojoConsumerIntf;
+import org.junit.AfterClass;
 import org.junit.Assert;
 import org.junit.BeforeClass;
 import org.junit.Test;
@@ -52,8 +54,13 @@ public static void init() {
     proxy = invoker.getProxy();
   }
 
+  @AfterClass
+  public static void tearDown() {
+    JavassistUtils.clearByClassLoader(env.getClassLoader());
+  }
+
   @Test
-  public void testSimple() throws Exception {
+  public void testSimple() {
     int result = proxy.testSimple(1, 2, 3);
 
     Assert.assertEquals(1, (int) invoker.getSwaggerArgument(0));
@@ -64,7 +71,7 @@ public void testSimple() throws Exception {
   }
 
   @Test
-  public void testObject() throws Exception {
+  public void testObject() {
     Person person = new Person();
     person.setName("abc");
 
@@ -77,7 +84,7 @@ public void testObject() throws Exception {
   }
 
   @Test
-  public void testSimpleAndObject() throws Exception {
+  public void testSimpleAndObject() {
     Person person = new Person();
     person.setName("abc");
 
@@ -90,7 +97,7 @@ public void testSimpleAndObject() throws Exception {
   }
 
   @Test
-  public void testContext() throws Exception {
+  public void testContext() {
     InvocationContext threadContext = new InvocationContext();
     threadContext.addContext("ta", "tvalue");
     ContextUtils.setInvocationContext(threadContext);
@@ -110,7 +117,7 @@ public void testContext() throws Exception {
   }
 
   @Test
-  public void testBytes() throws Exception {
+  public void testBytes() {
     byte[] bytes = new byte[] {1, 2};
 
     byte[] result = proxy.testBytes(bytes);
@@ -121,19 +128,29 @@ public void testBytes() throws Exception {
   }
 
   @Test
-  public void testArrayArray() throws Exception {
+  public void testListBytes() {
+    List<byte[]> bytes = Arrays.asList(new byte[] {1, 2});
+
+    List<byte[]> result = proxy.testListBytes(bytes);
+
+    Assert.assertEquals(bytes, invoker.getSwaggerArgument(0));
+    Assert.assertEquals(bytes, result);
+  }
+
+  @Test
+  public void testArrayArray() {
     String[] array = new String[] {"a", "b"};
     List<String> list = Arrays.asList(array);
 
     String[] result = proxy.testArrayArray(array);
 
-    Assert.assertEquals(list, (List<?>) invoker.getSwaggerArgument(0));
+    Assert.assertEquals(list, invoker.getSwaggerArgument(0));
 
-    Assert.assertArrayEquals(array, (String[]) result);
+    Assert.assertArrayEquals(array, result);
   }
 
   @Test
-  public void testArrayList() throws Exception {
+  public void testArrayList() {
     String[] array = new String[] {"a", "b"};
     List<String> list = Arrays.asList(array);
     List<String> result = proxy.testArrayList(array);
@@ -144,7 +161,7 @@ public void testArrayList() throws Exception {
   }
 
   @Test
-  public void testListArray() throws Exception {
+  public void testListArray() {
     String[] array = new String[] {"a", "b"};
     List<String> list = Arrays.asList(array);
 
@@ -156,7 +173,7 @@ public void testListArray() throws Exception {
   }
 
   @Test
-  public void testListList() throws Exception {
+  public void testListList() {
     List<String> list = Arrays.asList("a", "b");
 
     List<String> result = proxy.testListList(list);
@@ -167,19 +184,19 @@ public void testListList() throws Exception {
   }
 
   @Test
-  public void testObjectArrayArray() throws Exception {
+  public void testObjectArrayArray() {
     Person[] array = new Person[] {new Person("a"), new Person("b")};
     List<Person> list = Arrays.asList(array);
 
     Person[] result = proxy.testObjectArrayArray(array);
 
-    Assert.assertEquals(list, (List<?>) invoker.getSwaggerArgument(0));
+    Assert.assertEquals(list, invoker.getSwaggerArgument(0));
 
-    Assert.assertArrayEquals(array, (Person[]) result);
+    Assert.assertArrayEquals(array, result);
   }
 
   @Test
-  public void testObjectArrayList() throws Exception {
+  public void testObjectArrayList() {
     Person[] array = new Person[] {new Person("a"), new Person("b")};
     List<Person> list = Arrays.asList(array);
     List<Person> result = proxy.testObjectArrayList(array);
@@ -190,7 +207,7 @@ public void testObjectArrayList() throws Exception {
   }
 
   @Test
-  public void testObjectListArray() throws Exception {
+  public void testObjectListArray() {
     Person[] array = new Person[] {new Person("a"), new Person("b")};
     List<Person> list = Arrays.asList(array);
 
@@ -203,7 +220,7 @@ public void testObjectListArray() throws Exception {
   }
 
   @Test
-  public void testObjectListList() throws Exception {
+  public void testObjectListList() {
     Person[] array = new Person[] {new Person("a"), new Person("b")};
     List<Person> list = Arrays.asList(array);
 
diff --git a/swagger/swagger-invocation/invocation-core/src/test/java/org/apache/servicecomb/swagger/invocation/models/JaxrsImpl.java b/swagger/swagger-invocation/invocation-core/src/test/java/org/apache/servicecomb/swagger/invocation/models/JaxrsImpl.java
index 4750ba491..fe02aa2d8 100644
--- a/swagger/swagger-invocation/invocation-core/src/test/java/org/apache/servicecomb/swagger/invocation/models/JaxrsImpl.java
+++ b/swagger/swagger-invocation/invocation-core/src/test/java/org/apache/servicecomb/swagger/invocation/models/JaxrsImpl.java
@@ -68,6 +68,12 @@ public String testContext(InvocationContext context, @FormParam("form") String n
     return input;
   }
 
+  @Path("/listBytes")
+  @POST
+  public List<byte[]> testListBytes(List<byte[]> bytes) {
+    return bytes;
+  }
+
   @Path("/testArrayArray")
   @POST
   public String[] testArrayArray(String[] s) {
diff --git a/swagger/swagger-invocation/invocation-core/src/test/java/org/apache/servicecomb/swagger/invocation/models/PojoConsumerIntf.java b/swagger/swagger-invocation/invocation-core/src/test/java/org/apache/servicecomb/swagger/invocation/models/PojoConsumerIntf.java
index a851e56c7..be2dc07ae 100644
--- a/swagger/swagger-invocation/invocation-core/src/test/java/org/apache/servicecomb/swagger/invocation/models/PojoConsumerIntf.java
+++ b/swagger/swagger-invocation/invocation-core/src/test/java/org/apache/servicecomb/swagger/invocation/models/PojoConsumerIntf.java
@@ -36,6 +36,8 @@
 
   String testContext(InvocationContext context, String name);
 
+  List<byte[]> testListBytes(List<byte[]> bytes);
+
   byte[] testBytes(byte[] bytes);
 
   String[] testArrayArray(String[] s);
diff --git a/swagger/swagger-invocation/invocation-core/src/test/java/org/apache/servicecomb/swagger/invocation/models/PojoImpl.java b/swagger/swagger-invocation/invocation-core/src/test/java/org/apache/servicecomb/swagger/invocation/models/PojoImpl.java
index bcb510569..611a5c770 100644
--- a/swagger/swagger-invocation/invocation-core/src/test/java/org/apache/servicecomb/swagger/invocation/models/PojoImpl.java
+++ b/swagger/swagger-invocation/invocation-core/src/test/java/org/apache/servicecomb/swagger/invocation/models/PojoImpl.java
@@ -47,6 +47,10 @@ public String testContext(InvocationContext context, String name) {
     return name + " sayhi";
   }
 
+  public List<byte[]> testListBytes(List<byte[]> bytes) {
+    return bytes;
+  }
+
   public byte[] testBytes(byte[] bytes) {
     return bytes;
   }


 

----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on GitHub and use the
URL above to go to the specific comment.
 
For queries about this service, please contact Infrastructure at:
users@infra.apache.org


With regards,
Apache Git Services