本文整理汇总了Java中org.objectweb.asm.Opcodes.V1_5属性的典型用法代码示例。如果您正苦于以下问题:Java Opcodes.V1_5属性的具体用法?Java Opcodes.V1_5怎么用?Java Opcodes.V1_5使用的例子?那么, 这里精选的属性代码示例或许可以为您提供帮助。您也可以进一步了解该属性所在类org.objectweb.asm.Opcodes
的用法示例。
在下文中一共展示了Opcodes.V1_5属性的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: 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);
}
}
示例2: checkUnqualifiedName
/**
* Checks that the given string is a valid unqualified name.
*
* @param version
* the class version.
* @param name
* the string to be checked.
* @param msg
* a message to be used in case of error.
*/
static void checkUnqualifiedName(int version, final String name,
final String msg) {
if ((version & 0xFFFF) < Opcodes.V1_5) {
checkIdentifier(name, msg);
} else {
for (int i = 0; i < name.length(); ++i) {
if (".;[/".indexOf(name.charAt(i)) != -1) {
throw new IllegalArgumentException("Invalid " + msg
+ " (must be a valid unqualified name): " + name);
}
}
}
}
示例3: checkMethodIdentifier
/**
* Checks that the given string is a valid Java identifier.
*
* @param version
* the class version.
* @param name
* the string to be checked.
* @param msg
* a message to be used in case of error.
*/
static void checkMethodIdentifier(int version, final String name,
final String msg) {
if (name == null || name.length() == 0) {
throw new IllegalArgumentException("Invalid " + msg
+ " (must not be null or empty)");
}
if ((version & 0xFFFF) >= Opcodes.V1_5) {
for (int i = 0; i < name.length(); ++i) {
if (".;[/<>".indexOf(name.charAt(i)) != -1) {
throw new IllegalArgumentException("Invalid " + msg
+ " (must be a valid unqualified name): " + name);
}
}
return;
}
if (!Character.isJavaIdentifierStart(name.charAt(0))) {
throw new IllegalArgumentException(
"Invalid "
+ msg
+ " (must be a '<init>', '<clinit>' or a valid Java identifier): "
+ name);
}
for (int i = 1; i < name.length(); ++i) {
if (!Character.isJavaIdentifierPart(name.charAt(i))) {
throw new IllegalArgumentException(
"Invalid "
+ msg
+ " (must be '<init>' or '<clinit>' or a valid Java identifier): "
+ name);
}
}
}
示例4: getClassConstantReference
static InsnList getClassConstantReference(Type type, int majorVersion) {
InsnList il = new InsnList();
if (majorVersion >= Opcodes.V1_5) {
il.add(new LdcInsnNode(type));
} else {
String fullyQualifiedName = type.getInternalName().replaceAll("/", ".");
il.add(new LdcInsnNode(fullyQualifiedName));
il.add(new MethodInsnNode(Opcodes.INVOKESTATIC,
"java/lang/Class", "forName",
"(Ljava/lang/String;)Ljava/lang/Class;", false));
}
return il;
}
示例5: visit
@Override
public void visit(final int version, final int access, final String name,
final String signature, final String superName,
final String[] interfaces) {
String simpleName;
int n = name.lastIndexOf('/');
if (n == -1) {
simpleName = name;
} else {
text.add("package asm." + name.substring(0, n).replace('/', '.')
+ ";\n");
simpleName = name.substring(n + 1);
}
text.add("import java.util.*;\n");
text.add("import org.objectweb.asm.*;\n");
text.add("public class " + simpleName + "Dump implements Opcodes {\n\n");
text.add("public static byte[] dump () throws Exception {\n\n");
text.add("ClassWriter cw = new ClassWriter(0);\n");
text.add("FieldVisitor fv;\n");
text.add("MethodVisitor mv;\n");
text.add("AnnotationVisitor av0;\n\n");
buf.setLength(0);
buf.append("cw.visit(");
switch (version) {
case Opcodes.V1_1:
buf.append("V1_1");
break;
case Opcodes.V1_2:
buf.append("V1_2");
break;
case Opcodes.V1_3:
buf.append("V1_3");
break;
case Opcodes.V1_4:
buf.append("V1_4");
break;
case Opcodes.V1_5:
buf.append("V1_5");
break;
case Opcodes.V1_6:
buf.append("V1_6");
break;
case Opcodes.V1_7:
buf.append("V1_7");
break;
default:
buf.append(version);
break;
}
buf.append(", ");
appendAccess(access | ACCESS_CLASS);
buf.append(", ");
appendConstant(name);
buf.append(", ");
appendConstant(signature);
buf.append(", ");
appendConstant(superName);
buf.append(", ");
if (interfaces != null && interfaces.length > 0) {
buf.append("new String[] {");
for (int i = 0; i < interfaces.length; ++i) {
buf.append(i == 0 ? " " : ", ");
appendConstant(interfaces[i]);
}
buf.append(" }");
} else {
buf.append("null");
}
buf.append(");\n\n");
text.add(buf.toString());
}