本文整理汇总了Java中jdk.internal.org.objectweb.asm.Opcodes.ACC_STATIC属性的典型用法代码示例。如果您正苦于以下问题:Java Opcodes.ACC_STATIC属性的具体用法?Java Opcodes.ACC_STATIC怎么用?Java Opcodes.ACC_STATIC使用的例子?那么, 这里精选的属性代码示例或许可以为您提供帮助。您也可以进一步了解该属性所在类jdk.internal.org.objectweb.asm.Opcodes
的用法示例。
在下文中一共展示了Opcodes.ACC_STATIC属性的12个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: visitMethod
@Override
public MethodVisitor visitMethod(final int access, final String name,
final String desc, final String signature, final String[] exceptions) {
MethodVisitor mv;
if ("<clinit>".equals(name)) {
int a = Opcodes.ACC_PRIVATE + Opcodes.ACC_STATIC;
String n = prefix + counter++;
mv = cv.visitMethod(a, n, desc, signature, exceptions);
if (clinit == null) {
clinit = cv.visitMethod(a, name, desc, null, null);
}
clinit.visitMethodInsn(Opcodes.INVOKESTATIC, this.name, n, desc,
false);
} else {
mv = cv.visitMethod(access, name, desc, signature, exceptions);
}
return mv;
}
示例2: loadThis
/**
* Generates the instruction to load 'this' on the stack.
*/
public void loadThis() {
if ((access & Opcodes.ACC_STATIC) != 0) {
throw new IllegalStateException(
"no 'this' pointer within static method");
}
mv.visitVarInsn(Opcodes.ALOAD, 0);
}
示例3: addSVUID
protected void addSVUID(long svuid) {
FieldVisitor fv = super.visitField(Opcodes.ACC_FINAL
+ Opcodes.ACC_STATIC, "serialVersionUID", "J", null, svuid);
if (fv != null) {
fv.visitEnd();
}
}
示例4: asAccessFlags
private static int asAccessFlags(Symbol s) {
int attr = 0;
attr |= s.isPublic() ? Opcodes.ACC_PUBLIC : 0;
attr |= s.isPrivate() ? Opcodes.ACC_PRIVATE : 0;
attr |= s.isProtected() ? Opcodes.ACC_PROTECTED : 0;
attr |= s.isStatic() ? Opcodes.ACC_STATIC : 0;
attr |= s.isFinal() ? Opcodes.ACC_FINAL : 0;
return attr;
}
示例5: validate
private static void validate(ConstantPool constantPoolCTVM,
ConstantTypes cpType,
DummyClasses dummyClass,
int cpi) {
TestedCPEntry entry = cpType.getTestedCPEntry(dummyClass, cpi);
if (entry == null) {
return;
}
int index = cpi;
String cached = "";
int cpci = dummyClass.getCPCacheIndex(cpi);
if (cpci != ConstantPoolTestsHelper.NO_CP_CACHE_PRESENT) {
index = cpci;
cached = "cached ";
}
for (int j = 0; j < entry.opcodes.length; j++) {
int[] info = new int[3];
HotSpotResolvedObjectType fieldToVerify
= CompilerToVMHelper.resolveFieldInPool(constantPoolCTVM,
index,
entry.methods == null ? null : entry.methods[j],
entry.opcodes[j],
info);
String msg = String.format("Object returned by resolveFieldInPool method"
+ " for %sindex %d should not be null",
cached,
index);
Asserts.assertNotNull(fieldToVerify, msg);
String classNameToRefer = entry.klass;
String fieldToVerifyKlassToString = fieldToVerify.klass().toValueString();
if (!fieldToVerifyKlassToString.contains(classNameToRefer)) {
msg = String.format("String representation \"%s\" of the object"
+ " returned by resolveFieldInPool method"
+ " for index %d does not contain a field's class name,"
+ " should contain %s",
fieldToVerifyKlassToString,
index,
classNameToRefer);
throw new AssertionError(msg);
}
msg = String.format("Access flags returned by resolveFieldInPool"
+ " method are wrong for the field %s.%s"
+ " at %sindex %d",
entry.klass,
entry.name,
cached,
index);
Asserts.assertEQ(info[0], entry.accFlags, msg);
if (cpci == -1) {
return;
}
Class classOfTheField = null;
Field fieldToRefer = null;
try {
classOfTheField = Class.forName(classNameToRefer.replaceAll("/", "\\."));
fieldToRefer = classOfTheField.getDeclaredField(entry.name);
fieldToRefer.setAccessible(true);
} catch (Exception ex) {
throw new Error("Unexpected exception", ex);
}
int offsetToRefer;
if ((entry.accFlags & Opcodes.ACC_STATIC) != 0) {
offsetToRefer = (int) UNSAFE.staticFieldOffset(fieldToRefer);
} else {
offsetToRefer = (int) UNSAFE.objectFieldOffset(fieldToRefer);
}
msg = String.format("Field offset returned by resolveFieldInPool"
+ " method is wrong for the field %s.%s"
+ " at %sindex %d",
entry.klass,
entry.name,
cached,
index);
Asserts.assertEQ(info[1], offsetToRefer, msg);
}
}
示例6: AnalyzerAdapter
/**
* Creates a new {@link AnalyzerAdapter}.
*
* @param api
* the ASM API version implemented by this visitor. Must be one
* of {@link Opcodes#ASM4} or {@link Opcodes#ASM5}.
* @param owner
* the owner's class name.
* @param access
* the method's access flags (see {@link Opcodes}).
* @param name
* the method's name.
* @param desc
* the method's descriptor (see {@link Type Type}).
* @param mv
* the method visitor to which this adapter delegates calls. May
* be <tt>null</tt>.
*/
protected AnalyzerAdapter(final int api, final String owner,
final int access, final String name, final String desc,
final MethodVisitor mv) {
super(api, mv);
this.owner = owner;
locals = new ArrayList<Object>();
stack = new ArrayList<Object>();
uninitializedTypes = new HashMap<Object, Object>();
if ((access & Opcodes.ACC_STATIC) == 0) {
if ("<init>".equals(name)) {
locals.add(Opcodes.UNINITIALIZED_THIS);
} else {
locals.add(owner);
}
}
Type[] types = Type.getArgumentTypes(desc);
for (int i = 0; i < types.length; ++i) {
Type type = types[i];
switch (type.getSort()) {
case Type.BOOLEAN:
case Type.CHAR:
case Type.BYTE:
case Type.SHORT:
case Type.INT:
locals.add(Opcodes.INTEGER);
break;
case Type.FLOAT:
locals.add(Opcodes.FLOAT);
break;
case Type.LONG:
locals.add(Opcodes.LONG);
locals.add(Opcodes.TOP);
break;
case Type.DOUBLE:
locals.add(Opcodes.DOUBLE);
locals.add(Opcodes.TOP);
break;
case Type.ARRAY:
locals.add(types[i].getDescriptor());
break;
// case Type.OBJECT:
default:
locals.add(types[i].getInternalName());
}
}
maxLocals = locals.size();
}
示例7: visitMethod
@Override
public Textifier visitMethod(final int access, final String name,
final String desc, final String signature, final String[] exceptions) {
buf.setLength(0);
buf.append('\n');
if ((access & Opcodes.ACC_DEPRECATED) != 0) {
buf.append(tab).append("// DEPRECATED\n");
}
buf.append(tab).append("// access flags 0x")
.append(Integer.toHexString(access).toUpperCase()).append('\n');
if (signature != null) {
buf.append(tab);
appendDescriptor(METHOD_SIGNATURE, signature);
TraceSignatureVisitor v = new TraceSignatureVisitor(0);
SignatureReader r = new SignatureReader(signature);
r.accept(v);
String genericDecl = v.getDeclaration();
String genericReturn = v.getReturnType();
String genericExceptions = v.getExceptions();
buf.append(tab).append("// declaration: ").append(genericReturn)
.append(' ').append(name).append(genericDecl);
if (genericExceptions != null) {
buf.append(" throws ").append(genericExceptions);
}
buf.append('\n');
}
buf.append(tab);
appendAccess(access & ~Opcodes.ACC_VOLATILE);
if ((access & Opcodes.ACC_NATIVE) != 0) {
buf.append("native ");
}
if ((access & Opcodes.ACC_VARARGS) != 0) {
buf.append("varargs ");
}
if ((access & Opcodes.ACC_BRIDGE) != 0) {
buf.append("bridge ");
}
if ((this.access & Opcodes.ACC_INTERFACE) != 0
&& (access & Opcodes.ACC_ABSTRACT) == 0
&& (access & Opcodes.ACC_STATIC) == 0) {
buf.append("default ");
}
buf.append(name);
appendDescriptor(METHOD_DESCRIPTOR, desc);
if (exceptions != null && exceptions.length > 0) {
buf.append(" throws ");
for (int i = 0; i < exceptions.length; ++i) {
appendDescriptor(INTERNAL_NAME, exceptions[i]);
buf.append(' ');
}
}
buf.append('\n');
text.add(buf.toString());
Textifier t = createTextifier();
text.add(t.getText());
return t;
}
示例8: appendAccess
/**
* Appends a string representation of the given access modifiers to
* {@link #buf buf}.
*
* @param access
* some access modifiers.
*/
private void appendAccess(final int access) {
if ((access & Opcodes.ACC_PUBLIC) != 0) {
buf.append("public ");
}
if ((access & Opcodes.ACC_PRIVATE) != 0) {
buf.append("private ");
}
if ((access & Opcodes.ACC_PROTECTED) != 0) {
buf.append("protected ");
}
if ((access & Opcodes.ACC_FINAL) != 0) {
buf.append("final ");
}
if ((access & Opcodes.ACC_STATIC) != 0) {
buf.append("static ");
}
if ((access & Opcodes.ACC_SYNCHRONIZED) != 0) {
buf.append("synchronized ");
}
if ((access & Opcodes.ACC_VOLATILE) != 0) {
buf.append("volatile ");
}
if ((access & Opcodes.ACC_TRANSIENT) != 0) {
buf.append("transient ");
}
if ((access & Opcodes.ACC_ABSTRACT) != 0) {
buf.append("abstract ");
}
if ((access & Opcodes.ACC_STRICT) != 0) {
buf.append("strictfp ");
}
if ((access & Opcodes.ACC_SYNTHETIC) != 0) {
buf.append("synthetic ");
}
if ((access & Opcodes.ACC_MANDATED) != 0) {
buf.append("mandated ");
}
if ((access & Opcodes.ACC_ENUM) != 0) {
buf.append("enum ");
}
}
示例9: appendAccess
private static void appendAccess(final StringBuilder sb, final int access) {
if ((access & Opcodes.ACC_PUBLIC) != 0) {
sb.append("public ");
}
if ((access & Opcodes.ACC_PRIVATE) != 0) {
sb.append("private ");
}
if ((access & Opcodes.ACC_PROTECTED) != 0) {
sb.append("protected ");
}
if ((access & Opcodes.ACC_FINAL) != 0) {
sb.append("final ");
}
if ((access & Opcodes.ACC_STATIC) != 0) {
sb.append("static ");
}
if ((access & Opcodes.ACC_SYNCHRONIZED) != 0) {
sb.append("synchronized ");
}
if ((access & Opcodes.ACC_VOLATILE) != 0) {
sb.append("volatile ");
}
if ((access & Opcodes.ACC_TRANSIENT) != 0) {
sb.append("transient ");
}
if ((access & Opcodes.ACC_ABSTRACT) != 0) {
sb.append("abstract ");
}
if ((access & Opcodes.ACC_STRICT) != 0) {
sb.append("strictfp ");
}
if ((access & Opcodes.ACC_SYNTHETIC) != 0) {
sb.append("synthetic ");
}
if ((access & Opcodes.ACC_MANDATED) != 0) {
sb.append("mandated ");
}
if ((access & Opcodes.ACC_ENUM) != 0) {
sb.append("enum ");
}
}
示例10: visitField
@Override
public FieldVisitor visitField(final int fieldAccess, final String fieldName, final String fieldDesc, final String signature, final Object value) {
final FieldVisitor delegateFV = super.visitField(fieldAccess, fieldName, fieldDesc, signature, value);
return new FieldVisitor(Main.ASM_VERSION, delegateFV) {
@Override
public AnnotationVisitor visitAnnotation(final String descriptor, final boolean visible) {
final AnnotationVisitor delegateAV = super.visitAnnotation(descriptor, visible);
if (ScriptClassInfo.PROPERTY_ANNO_DESC.equals(descriptor)) {
final MemberInfo memInfo = new MemberInfo();
memInfo.setKind(Kind.PROPERTY);
memInfo.setJavaName(fieldName);
memInfo.setJavaDesc(fieldDesc);
memInfo.setJavaAccess(fieldAccess);
if ((fieldAccess & Opcodes.ACC_STATIC) != 0) {
memInfo.setValue(value);
}
addScriptMember(memInfo);
return new AnnotationVisitor(Main.ASM_VERSION, delegateAV) {
// These could be "null" if values are not supplied,
// in which case we have to use the default values.
private String name;
private Integer attributes;
private String clazz = "";
private Where where;
@Override
public void visit(final String annotationName, final Object annotationValue) {
switch (annotationName) {
case "name":
this.name = (String) annotationValue;
break;
case "attributes":
this.attributes = (Integer) annotationValue;
break;
case "clazz":
this.clazz = (annotationValue == null) ? "" : annotationValue.toString();
break;
default:
break;
}
super.visit(annotationName, annotationValue);
}
@Override
public void visitEnum(final String enumName, final String desc, final String enumValue) {
if ("where".equals(enumName) && WHERE_ENUM_DESC.equals(desc)) {
this.where = Where.valueOf(enumValue);
}
super.visitEnum(enumName, desc, enumValue);
}
@Override
public void visitEnd() {
super.visitEnd();
memInfo.setName(name == null ? fieldName : name);
memInfo.setAttributes(attributes == null
? MemberInfo.DEFAULT_ATTRIBUTES : attributes);
clazz = clazz.replace('.', '/');
memInfo.setInitClass(clazz);
memInfo.setWhere(where == null? Where.INSTANCE : where);
}
};
}
return delegateAV;
}
};
}
示例11: LocalVariablesSorter
/**
* Creates a new {@link LocalVariablesSorter}.
*
* @param api
* the ASM API version implemented by this visitor. Must be one
* of {@link Opcodes#ASM4} or {@link Opcodes#ASM5}.
* @param access
* access flags of the adapted method.
* @param desc
* the method's descriptor (see {@link Type Type}).
* @param mv
* the method visitor to which this adapter delegates calls.
*/
protected LocalVariablesSorter(final int api, final int access,
final String desc, final MethodVisitor mv) {
super(api, mv);
Type[] args = Type.getArgumentTypes(desc);
nextLocal = (Opcodes.ACC_STATIC & access) == 0 ? 1 : 0;
for (int i = 0; i < args.length; i++) {
nextLocal += args[i].getSize();
}
firstLocal = nextLocal;
}
示例12: getArgIndex
/**
* Returns the index of the given method argument in the frame's local
* variables array.
*
* @param arg
* the index of a method argument.
* @return the index of the given method argument in the frame's local
* variables array.
*/
private int getArgIndex(final int arg) {
int index = (access & Opcodes.ACC_STATIC) == 0 ? 1 : 0;
for (int i = 0; i < arg; i++) {
index += argumentTypes[i].getSize();
}
return index;
}