本文整理匯總了Java中org.objectweb.asm.Type.METHOD屬性的典型用法代碼示例。如果您正苦於以下問題:Java Type.METHOD屬性的具體用法?Java Type.METHOD怎麽用?Java Type.METHOD使用的例子?那麽, 這裏精選的屬性代碼示例或許可以為您提供幫助。您也可以進一步了解該屬性所在類org.objectweb.asm.Type
的用法示例。
在下文中一共展示了Type.METHOD屬性的12個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。
示例1: mapType
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;
}
示例2: visit
@Override
public void visit(final String name, final Object value) {
checkEnd();
checkName(name);
if (!(value instanceof Byte || value instanceof Boolean
|| value instanceof Character || value instanceof Short
|| value instanceof Integer || value instanceof Long
|| value instanceof Float || value instanceof Double
|| value instanceof String || value instanceof Type
|| value instanceof byte[] || value instanceof boolean[]
|| value instanceof char[] || value instanceof short[]
|| value instanceof int[] || value instanceof long[]
|| value instanceof float[] || value instanceof double[])) {
throw new IllegalArgumentException("Invalid annotation value");
}
if (value instanceof Type) {
int sort = ((Type) value).getSort();
if (sort == Type.METHOD) {
throw new IllegalArgumentException("Invalid annotation value");
}
}
if (av != null) {
av.visit(name, value);
}
}
示例3: yieldAnnotationValuesReferences
protected void yieldAnnotationValuesReferences(Reference.Visitor visitor, List<Object> list) throws Reference.Visitor.Stop {
for (int i = 0, s = list.size(); i < s; i++) {
Object item = list.get(i);
if (item instanceof Type) {
Type typ = (Type) item;
switch (typ.getSort()) {
case Type.OBJECT:case Type.ARRAY:
acceptNullable(visitor, new AsmAnnotDefTypeListReference(this, list, i, true));
break;
case Type.METHOD:
new AsmAnnotDefTypeListDescriptor(this, list, i, true).parseAndAccept(visitor);
break;
}
} else if (item instanceof AnnotationNode) {
visitor.visit(new AsmAnnotationReference(this, (AnnotationNode) item, true));
} else if (item instanceof List) {
//noinspection unchecked
yieldAnnotationValuesReferences(visitor, (List<Object>) item);
}
}
}
示例4: checkLDCConstant
void checkLDCConstant(final Object cst) {
if (cst instanceof Type) {
int s = ((Type) cst).getSort();
if (s != Type.OBJECT && s != Type.ARRAY && s != Type.METHOD) {
throw new IllegalArgumentException("Illegal LDC constant value");
}
if (s != Type.METHOD && (version & 0xFFFF) < Opcodes.V1_5) {
throw new IllegalArgumentException(
"ldc of a constant class requires at least version 1.5");
}
if (s == Type.METHOD && (version & 0xFFFF) < Opcodes.V1_7) {
throw new IllegalArgumentException(
"ldc of a method type requires at least version 1.7");
}
} else if (cst instanceof Handle) {
if ((version & 0xFFFF) < Opcodes.V1_7) {
throw new IllegalArgumentException(
"ldc of a handle requires at least version 1.7");
}
int tag = ((Handle) cst).getTag();
if (tag < Opcodes.H_GETFIELD || tag > Opcodes.H_INVOKEINTERFACE) {
throw new IllegalArgumentException("invalid handle tag " + tag);
}
} else {
checkConstant(cst);
}
}
示例5: decodeBootstrapArgument
private DexValue decodeBootstrapArgument(Object value) {
if (value instanceof Integer) {
return DexValue.DexValueInt.create((Integer) value);
} else if (value instanceof Long) {
return DexValue.DexValueLong.create((Long) value);
} else if (value instanceof Float) {
return DexValue.DexValueFloat.create((Float) value);
} else if (value instanceof Double) {
return DexValue.DexValueDouble.create((Double) value);
} else if (value instanceof String) {
return new DexValue.DexValueString(application.getString((String) value));
} else if (value instanceof Type) {
Type type = (Type) value;
switch (type.getSort()) {
case Type.OBJECT:
return new DexValue.DexValueType(
application.getTypeFromDescriptor(((Type) value).getDescriptor()));
case Type.METHOD:
return new DexValue.DexValueMethodType(
application.getProto(((Type) value).getDescriptor()));
}
throw new Unreachable("Type sort is not supported: " + type.getSort());
} else if (value instanceof Handle) {
return new DexValue.DexValueMethodHandle(getMethodHandle(application, (Handle) value));
} else {
throw new Unreachable(
"Unsupported bootstrap static argument of type " + value.getClass().getSimpleName());
}
}
示例6: getShortyDescriptor
private static String getShortyDescriptor(Type type) {
switch (type.getSort()) {
case Type.METHOD:
throw new InternalCompilerError("Cannot produce a shorty decriptor for methods");
case Type.ARRAY:
case Type.OBJECT:
return "L";
default:
return type.getDescriptor();
}
}
示例7: checkCastReturn
final protected void checkCastReturn(Type returnType) {
final int sort = returnType.getSort();
switch (sort) {
case Type.VOID: {
pop();
mv.visitInsn(Opcodes.RETURN);
break;
}
case Type.BOOLEAN:
case Type.CHAR:
case Type.BYTE:
case Type.SHORT:
case Type.INT: {
unbox(returnType);
returnValue();
break;
}
case Type.FLOAT: {
unbox(returnType);
mv.visitInsn(Opcodes.FRETURN);
break;
}
case Type.LONG: {
unbox(returnType);
mv.visitInsn(Opcodes.LRETURN);
break;
}
case Type.DOUBLE: {
unbox(returnType);
mv.visitInsn(Opcodes.DRETURN);
break;
}
case Type.ARRAY:
case Type.OBJECT:
case Type.METHOD:
default: {
// checkCast(returnType);
unbox(returnType);
mv.visitInsn(ARETURN);
break;
}
}
}
示例8: visitLdcInsn
@Override
public void visitLdcInsn(final Object cst) {
if (mv != null) {
mv.visitLdcInsn(cst);
}
if (this.locals == null) {
labels = null;
return;
}
if (cst instanceof Integer) {
push(Opcodes.INTEGER);
} else if (cst instanceof Long) {
push(Opcodes.LONG);
push(Opcodes.TOP);
} else if (cst instanceof Float) {
push(Opcodes.FLOAT);
} else if (cst instanceof Double) {
push(Opcodes.DOUBLE);
push(Opcodes.TOP);
} else if (cst instanceof String) {
push("java/lang/String");
} else if (cst instanceof Type) {
int sort = ((Type) cst).getSort();
if (sort == Type.OBJECT || sort == Type.ARRAY) {
push("java/lang/Class");
} else if (sort == Type.METHOD) {
push("java/lang/invoke/MethodType");
} else {
throw new IllegalArgumentException();
}
} else if (cst instanceof Handle) {
push("java/lang/invoke/MethodHandle");
} else {
throw new IllegalArgumentException();
}
labels = null;
}
示例9: newOperation
@Override
public BasicValue newOperation(final AbstractInsnNode insn)
throws AnalyzerException {
switch (insn.getOpcode()) {
case ACONST_NULL:
return newValue(Type.getObjectType("null"));
case ICONST_M1:
case ICONST_0:
case ICONST_1:
case ICONST_2:
case ICONST_3:
case ICONST_4:
case ICONST_5:
return BasicValue.INT_VALUE;
case LCONST_0:
case LCONST_1:
return BasicValue.LONG_VALUE;
case FCONST_0:
case FCONST_1:
case FCONST_2:
return BasicValue.FLOAT_VALUE;
case DCONST_0:
case DCONST_1:
return BasicValue.DOUBLE_VALUE;
case BIPUSH:
case SIPUSH:
return BasicValue.INT_VALUE;
case LDC:
Object cst = ((LdcInsnNode) insn).cst;
if (cst instanceof Integer) {
return BasicValue.INT_VALUE;
} else if (cst instanceof Float) {
return BasicValue.FLOAT_VALUE;
} else if (cst instanceof Long) {
return BasicValue.LONG_VALUE;
} else if (cst instanceof Double) {
return BasicValue.DOUBLE_VALUE;
} else if (cst instanceof String) {
return newValue(Type.getObjectType("java/lang/String"));
} else if (cst instanceof Type) {
int sort = ((Type) cst).getSort();
if (sort == Type.OBJECT || sort == Type.ARRAY) {
return newValue(Type.getObjectType("java/lang/Class"));
} else if (sort == Type.METHOD) {
return newValue(Type
.getObjectType("java/lang/invoke/MethodType"));
} else {
throw new IllegalArgumentException("Illegal LDC constant "
+ cst);
}
} else if (cst instanceof Handle) {
return newValue(Type
.getObjectType("java/lang/invoke/MethodHandle"));
} else {
throw new IllegalArgumentException("Illegal LDC constant "
+ cst);
}
case JSR:
return BasicValue.RETURNADDRESS_VALUE;
case GETSTATIC:
return newValue(Type.getType(((FieldInsnNode) insn).desc));
case NEW:
return newValue(Type.getObjectType(((TypeInsnNode) insn).desc));
default:
throw new Error("Internal error.");
}
}
示例10: visitInvokeDynamicInsn
@Override
public void visitInvokeDynamicInsn(String name, String desc, Handle bsm,
Object... bsmArgs) {
buf.setLength(0);
buf.append(tab2).append("INVOKEDYNAMIC").append(' ');
buf.append(name);
appendDescriptor(METHOD_DESCRIPTOR, desc);
buf.append(" [");
buf.append('\n');
buf.append(tab3);
appendHandle(bsm);
buf.append('\n');
buf.append(tab3).append("// arguments:");
if (bsmArgs.length == 0) {
buf.append(" none");
} else {
buf.append('\n');
for (int i = 0; i < bsmArgs.length; i++) {
buf.append(tab3);
Object cst = bsmArgs[i];
if (cst instanceof String) {
Printer.appendString(buf, (String) cst);
} else if (cst instanceof Type) {
Type type = (Type) cst;
if(type.getSort() == Type.METHOD){
appendDescriptor(METHOD_DESCRIPTOR, type.getDescriptor());
} else {
buf.append(type.getDescriptor()).append(".class");
}
} else if (cst instanceof Handle) {
appendHandle((Handle) cst);
} else {
buf.append(cst);
}
buf.append(", \n");
}
buf.setLength(buf.length() - 3);
}
buf.append('\n');
buf.append(tab2).append("]\n");
text.add(buf.toString());
}
示例11: getDesc
@Override
protected String getDesc() {
Type typ = getTypeRef();
return typ != null && typ.getSort() == Type.METHOD ? typ.getDescriptor() : null;
}
示例12: setDesc
@Override
protected void setDesc(String desc) {
Type typ = getTypeRef();
if (typ != null && typ.getSort() == Type.METHOD)
setTypeRef(typ);
}