public String type(Class<?> clz) {
    if (!sourcePkgLevelAccessible(clz)) {
      clz = Object.class;
    }
    if (clz.isArray()) {
      return getArrayType(clz);
    }
    String type = ReflectionUtils.getLiteralName(clz);
    if (type.startsWith("java.lang")) {
      if (!type.substring("java.lang.".length()).contains(".")) {
        String simpleName = clz.getSimpleName();
        boolean hasPackage = StringUtils.isNotBlank(pkg);
        Map<String, Boolean> packageMap =
            nameConflicts.computeIfAbsent(hasPackage ? pkg : "", p -> new ConcurrentHashMap<>());
        Class<?> c = clz;
        Boolean conflictRes =
            packageMap.computeIfAbsent(
                simpleName,
                sn -> {
                  try {
                    ClassLoader beanClassClassLoader =
                        c.getClassLoader() == null
                            ? Thread.currentThread().getContextClassLoader()
                            : c.getClassLoader();
                    if (beanClassClassLoader == null) {
                      beanClassClassLoader = Fury.class.getClassLoader();
                    }
                    beanClassClassLoader.loadClass(hasPackage ? pkg + "." + sn : sn);
                    return Boolean.TRUE;
                  } catch (ClassNotFoundException e) {
                    return Boolean.FALSE;
                  }
                });
        return conflictRes ? clz.getName() : simpleName;
      }
    }
    if (imports.contains(type)) {
      return clz.getSimpleName();
    } else {
      int index = type.lastIndexOf(".");
      if (index > 0) {
        // This might be package name or qualified name of outer class
        String pkgOrClassName = type.substring(0, index);
        if (imports.contains(pkgOrClassName + ".*")) {
          return clz.getSimpleName();
        }
      }
      return type;
    }
  }
@Test
  public void type() {
    TypeRef<List<List<String>>> typeRef = new TypeRef<List<List<String>>>() {};
    {
      CodegenContext ctx = new CodegenContext();
      ctx.addImport(List.class);
      Assert.assertEquals("List", ctx.type(List.class));
    }
    CodegenContext ctx = new CodegenContext();
    String type = ctx.type(typeRef);
    Assert.assertEquals("java.util.List", type);
    Assert.assertEquals("int[][]", ctx.type(int[][].class));
  }