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

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

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

Type.getElementType介绍

[英]Returns the type of the elements of this array type. This method should only be used for an array type.
[中]返回此数组类型的元素类型。此方法只能用于数组类型。

代码示例

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

public void visitInsn(int opcode) {
    if ((opcode >= IRETURN && opcode <= RETURN)) {
      Type tp = returnType;
      if (tp.getSort() == Type.ARRAY && tp.getElementType().getSort() == Type.BYTE) {
        mv.visitInsn(Opcodes.DUP);
        mv.visitVarInsn(Opcodes.ALOAD, 1);// stat
        mv.visitMethodInsn(Opcodes.INVOKESTATIC, TRACEMAIN, START_METHOD, START_SIGNATURE, false);
      }
    }
    mv.visitInsn(opcode);
  }
}

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

public void visitInsn(int opcode) {
    if ((opcode >= IRETURN && opcode <= RETURN)) {
      Type tp = returnType;
      if (tp.getSort() == Type.ARRAY && tp.getElementType().getSort() == Type.BYTE) {
        mv.visitInsn(Opcodes.DUP);
        mv.visitVarInsn(ALOAD, 0);
        mv.visitFieldInsn(GETFIELD, this.className, KEY_ELEMENT_FIELD, "Ljava/lang/Object;");
        mv.visitMethodInsn(Opcodes.INVOKESTATIC, TRACEMAIN, START_METHOD, START_SIGNATURE, false);
      }
    }
    mv.visitInsn(opcode);
  }
}

代码示例来源: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: pmd/pmd

private void addType(Type t) {
  switch (t.getSort()) {
  case Type.ARRAY:
    addType(t.getElementType());
    break;
  case Type.OBJECT:
    parseClassName(t.getClassName().replace('.', '/'));
    break;
  default:
    // Do nothing
    break;
  }
}

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

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

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

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

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

switch (returnType.getSort()) {
  case Type.ARRAY:
    if(returnType.getElementType().getSort() == Type.INT) {
      lvPosReturn = newLocal(returnType);
      mv.visitVarInsn(Opcodes.ASTORE, lvPosReturn);

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

switch (returnType.getSort()) {
  case Type.ARRAY:
    if(returnType.getElementType().getSort() == Type.INT) {

代码示例来源: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: com.google.gwt/gwt-servlet

processType(sourceType, type.getElementType());
return toReturn;

代码示例来源: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: 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: com.yahoo.vespa/bundle-plugin

static Optional<String> getClassName(Type aType) {
  switch (aType.getSort()) {
  case Type.ARRAY:
    return getClassName(aType.getElementType());
  case Type.OBJECT:
    return Optional.of(aType.getClassName());
  default:
    return Optional.empty();
  }
}

代码示例来源:origin: com.github.nullstress/DependencyAnalysisPlugin

private void addType(final Type t) {
  switch (t.getSort()) {
    case Type.ARRAY:
      addType( t.getElementType() );
      break;
    case Type.OBJECT:
      addName( t.getClassName().replace( '.', '/' ) );
      break;
  }
}

代码示例来源:origin: EvoSuite/evosuite

private String getReturnTypeDesc(Type t) {
  if(t.getSort() == Type.OBJECT) {
    return "Ljava/lang/Object;";
  } else if(t.getSort() == Type.ARRAY) {
    return "["+getReturnTypeDesc(t.getElementType());
  } else
    return t.getDescriptor();
}

代码示例来源:origin: org.apache.twill/twill-core

private void addType(Type type) {
 if (type.getSort() == Type.ARRAY) {
  type = type.getElementType();
 }
 if (type.getSort() == Type.OBJECT) {
  addClass(type.getInternalName());
 }
}

代码示例来源:origin: org.eclipse.virgo.bundlor/org.eclipse.virgo.bundlor

public static String getFullyQualifiedTypeName(Type type) {
  if (type.getSort() == Type.OBJECT) {
    return type.getClassName();
  } else if (type.getSort() == Type.ARRAY) {
    return getFullyQualifiedTypeName(type.getElementType());
  } else {
    return null;
  }
}

代码示例来源:origin: com.springsource.bundlor/com.springsource.bundlor

public static String getFullyQualifiedTypeName(Type type) {
  if (type.getSort() == Type.OBJECT) {
    return type.getClassName();
  } else if (type.getSort() == Type.ARRAY) {
    return getFullyQualifiedTypeName(type.getElementType());
  } else {
    return null;
  }
}

代码示例来源:origin: au.net.zeus.jgdms.tools/classdep

private void addType(Type t) {
  switch (t.getSort()) {
    case Type.ARRAY:
      addType(t.getElementType());
      break;
    case Type.OBJECT:
      addNameInternal(t.getClassName(), false);
      break;
  }
}

代码示例来源:origin: md-5/SpecialSource

private void visitType(Type type) {
  // FIXME: Scan arrays too!
  if (type.getSort() == Type.OBJECT) {
    String name = type.getInternalName();
    if (jar.containsClass(name)) {
      classes.add(name);
    }
  }
  if (type.getSort() == Type.ARRAY) {
    visitType(type.getElementType());
  }
}

相关文章