org.objectweb.asm.Type.getDimensions()方法的使用及代码示例

x33g5p2x  于2022-01-29 转载在 其他  
字(8.6k)|赞(0)|评价(0)|浏览(85)

本文整理了Java中org.objectweb.asm.Type.getDimensions()方法的一些代码示例,展示了Type.getDimensions()的具体用法。这些代码示例主要来源于Github/Stackoverflow/Maven等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。Type.getDimensions()方法的具体详情如下:
包路径:org.objectweb.asm.Type
类名称:Type
方法名:getDimensions

Type.getDimensions介绍

[英]Returns the number of dimensions of this array type. This method should only be used for an array type.
[中]

代码示例

代码示例来源:origin: org.ow2.asm/asm

/**
 * Returns the type of the elements of this array type. This method should only be used for an
 * array type.
 *
 * @return Returns the type of the elements of this array type.
 */
public Type getElementType() {
 final int numDimensions = getDimensions();
 return getTypeInternal(valueBuffer, valueBegin + numDimensions, valueEnd);
}

代码示例来源:origin: scouter-project/scouter

public static void main(String[] args) {
  Type type = Type.getReturnType("(Z)[I");
  System.out.println("type = " + type.getSort());
  System.out.println("dim = " + type.getDimensions());
  System.out.println("element = " + type.getElementType());
}

代码示例来源:origin: org.ow2.asm/asm

case ARRAY:
 StringBuilder stringBuilder = new StringBuilder(getElementType().getClassName());
 for (int i = getDimensions(); i > 0; --i) {
  stringBuilder.append("[]");

代码示例来源:origin: konsoletyper/teavm

case Type.ARRAY: {
  StringBuilder sb = new StringBuilder(printType(type.getElementType()));
  for (int i = 0; i < type.getDimensions(); ++i) {
    sb.append("[]");

代码示例来源:origin: glowroot/glowroot

private static void loadArrayType(MethodVisitor mv, Type type, Type ownerType) {
  loadType(mv, type.getElementType(), ownerType);
  mv.visitLdcInsn(type.getDimensions());
  mv.visitMethodInsn(INVOKESTATIC, bytecodeUtilType.getInternalName(),
      "getArrayClass", "(Ljava/lang/Class;I)Ljava/lang/Class;", false);
}

代码示例来源:origin: glowroot/glowroot

private static Class<?> getType(Type type) throws ClassNotFoundException {
  switch (type.getSort()) {
    case Type.VOID:
      return void.class;
    case Type.BOOLEAN:
      return boolean.class;
    case Type.CHAR:
      return char.class;
    case Type.BYTE:
      return byte.class;
    case Type.SHORT:
      return short.class;
    case Type.INT:
      return int.class;
    case Type.FLOAT:
      return float.class;
    case Type.LONG:
      return long.class;
    case Type.DOUBLE:
      return double.class;
    case Type.ARRAY:
      return Util.getArrayClass(getType(type.getElementType()),
          type.getDimensions());
    default:
      return Class.forName(type.getClassName(), false, null);
  }
}

代码示例来源:origin: com.bladejava/blade-asm

/**
 * Returns the type of the elements of this array type. This method should only be used for an
 * array type.
 *
 * @return Returns the type of the elements of this array type.
 */
public Type getElementType() {
 final int numDimensions = getDimensions();
 return getType(valueBuffer, valueBegin + numDimensions, valueEnd);
}

代码示例来源:origin: org.ow2.asm/asm-debug-all

/**
 * Returns the type of the elements of this array type. This method should
 * only be used for an array type.
 * 
 * @return Returns the type of the elements of this array type.
 */
public Type getElementType() {
  return getType(buf, off + getDimensions());
}

代码示例来源:origin: com.bladejava/blade-core

/**
 * Returns the type of the elements of this array type. This method should
 * only be used for an array type.
 * 
 * @return Returns the type of the elements of this array type.
 */
public Type getElementType() {
  return getType(buf, off + getDimensions());
}

代码示例来源:origin: org.apache.aries.spifly/org.apache.aries.spifly.dynamic.framework.extension

/**
 * Returns the type of the elements of this array type. This method should only be used for an
 * array type.
 *
 * @return Returns the type of the elements of this array type.
 */
public Type getElementType() {
 final int numDimensions = getDimensions();
 return getTypeInternal(valueBuffer, valueBegin + numDimensions, valueEnd);
}

代码示例来源:origin: org.apache.aries.spifly/org.apache.aries.spifly.dynamic.bundle

/**
 * Returns the type of the elements of this array type. This method should only be used for an
 * array type.
 *
 * @return Returns the type of the elements of this array type.
 */
public Type getElementType() {
 final int numDimensions = getDimensions();
 return getTypeInternal(valueBuffer, valueBegin + numDimensions, valueEnd);
}

代码示例来源:origin: copper-engine/copper-engine

private static Type getArrayElementType(Type arrayType) {
  int dim = arrayType.getDimensions();
  if(dim < 1) throw new IllegalArgumentException("Not an array type: " + arrayType);
  if(dim > 1) {
    String descr = arrayType.getDescriptor();
    return Type.getType(descr.substring(1));
  }
  return arrayType.getElementType();
}

代码示例来源:origin: anba/es6draft

private String getDescriptor(Type type) {
  if (type.getSort() == Type.OBJECT) {
    String name = type.getInternalName();
    int index = name.lastIndexOf('/');
    return name.substring(index + 1);
  }
  if (type.getSort() == Type.ARRAY) {
    StringBuilder sb = new StringBuilder(getDescriptor(type.getElementType()));
    for (int dim = type.getDimensions(); dim > 0; --dim) {
      sb.append("[]");
    }
    return sb.toString();
  }
  return type.getClassName();
}

代码示例来源:origin: org.ow2.asm/asm-debug-all

public String mapDesc(String desc) {
  Type t = Type.getType(desc);
  switch (t.getSort()) {
  case Type.ARRAY:
    String s = mapDesc(t.getElementType().getDescriptor());
    for (int i = 0; i < t.getDimensions(); ++i) {
      s = '[' + s;
    }
    return s;
  case Type.OBJECT:
    String newType = map(t.getInternalName());
    if (newType != null) {
      return 'L' + newType + ';';
    }
  }
  return desc;
}

代码示例来源:origin: MinecraftForge/Installer

public String mapDesc(String desc) {
  Type t = Type.getType(desc);
  switch (t.getSort()) {
  case Type.ARRAY:
    String s = mapDesc(t.getElementType().getDescriptor());
    for (int i = 0; i < t.getDimensions(); ++i) {
      s = '[' + s;
    }
    return s;
  case Type.OBJECT:
    String newType = map(t.getInternalName());
    if (newType != null) {
      return 'L' + newType + ';';
    }
  }
  return desc;
}

代码示例来源:origin: net.sourceforge.retroweaver/retroweaver

private Type getMirrorType(final Type type) {
  int numDimensions = 0;
  final Type basicType;
  if (type.getSort() == Type.ARRAY) {
    numDimensions = type.getDimensions();
    basicType = type.getElementType();
  } else {
    basicType = type;
  }
  if (basicType.getSort() != Type.OBJECT) {
    return type;
  }
  final Mirror mirror = getMirror(basicType.getInternalName());
  if (mirror.isClassMirror()) {
    final StringBuilder name = new StringBuilder();
    for (int i = 0; i < numDimensions; ++i) {
      name.append('[');
    }
    name.append('L').append(mirror.getTranslatedName()).append(';');
    return Type.getType(name.toString());
  }
  return type;
}

代码示例来源:origin: org.apache.aries.spifly/org.apache.aries.spifly.dynamic.bundle

/**
 * Returns the given {@link Type}, remapped with {@link #map(String)} or {@link
 * #mapMethodDesc(String)}.
 *
 * @param type a type, which can be a method type.
 * @return the given type, with its [array element type] internal name remapped with {@link
 *     #map(String)} (if the type is an array or object type, otherwise the type is returned as
 *     is) or, of the type is a method type, with its descriptor remapped with {@link
 *     #mapMethodDesc(String)}.
 */
private Type mapType(final Type type) {
 switch (type.getSort()) {
  case Type.ARRAY:
   StringBuilder remappedDescriptor = new StringBuilder();
   for (int i = 0; i < type.getDimensions(); ++i) {
    remappedDescriptor.append('[');
   }
   remappedDescriptor.append(mapType(type.getElementType()).getDescriptor());
   return Type.getType(remappedDescriptor.toString());
  case Type.OBJECT:
   String remappedInternalName = map(type.getInternalName());
   return remappedInternalName != null ? Type.getObjectType(remappedInternalName) : type;
  case Type.METHOD:
   return Type.getMethodType(mapMethodDesc(type.getDescriptor()));
  default:
   return type;
 }
}

代码示例来源:origin: org.ow2.asm/asm-commons

/**
 * Returns the given {@link Type}, remapped with {@link #map(String)} or {@link
 * #mapMethodDesc(String)}.
 *
 * @param type a type, which can be a method type.
 * @return the given type, with its [array element type] internal name remapped with {@link
 *     #map(String)} (if the type is an array or object type, otherwise the type is returned as
 *     is) or, of the type is a method type, with its descriptor remapped with {@link
 *     #mapMethodDesc(String)}.
 */
private Type mapType(final Type type) {
 switch (type.getSort()) {
  case Type.ARRAY:
   StringBuilder remappedDescriptor = new StringBuilder();
   for (int i = 0; i < type.getDimensions(); ++i) {
    remappedDescriptor.append('[');
   }
   remappedDescriptor.append(mapType(type.getElementType()).getDescriptor());
   return Type.getType(remappedDescriptor.toString());
  case Type.OBJECT:
   String remappedInternalName = map(type.getInternalName());
   return remappedInternalName != null ? Type.getObjectType(remappedInternalName) : type;
  case Type.METHOD:
   return Type.getMethodType(mapMethodDesc(type.getDescriptor()));
  default:
   return type;
 }
}

代码示例来源:origin: MinecraftForge/Installer

private Type mapType(Type t) {
  switch (t.getSort()) {
  case Type.ARRAY:
    String s = mapDesc(t.getElementType().getDescriptor());
    for (int i = 0; i < t.getDimensions(); ++i) {
      s = '[' + s;
    }
    return Type.getType(s);
  case Type.OBJECT:
    s = map(t.getInternalName());
    return s != null ? Type.getObjectType(s) : t;
  case Type.METHOD:
    return Type.getMethodType(mapMethodDesc(t.getDescriptor()));
  }
  return t;
}

代码示例来源:origin: org.ow2.asm/asm-debug-all

private Type mapType(Type t) {
  switch (t.getSort()) {
  case Type.ARRAY:
    String s = mapDesc(t.getElementType().getDescriptor());
    for (int i = 0; i < t.getDimensions(); ++i) {
      s = '[' + s;
    }
    return Type.getType(s);
  case Type.OBJECT:
    s = map(t.getInternalName());
    return s != null ? Type.getObjectType(s) : t;
  case Type.METHOD:
    return Type.getMethodType(mapMethodDesc(t.getDescriptor()));
  }
  return t;
}

相关文章