Example usage for org.objectweb.asm Opcodes ACC_STATIC

List of usage examples for org.objectweb.asm Opcodes ACC_STATIC

Introduction

In this page you can find the example usage for org.objectweb.asm Opcodes ACC_STATIC.

Prototype

int ACC_STATIC

To view the source code for org.objectweb.asm Opcodes ACC_STATIC.

Click Source Link

Usage

From source file:com.google.gwt.dev.shell.rewrite.WriteJsoImpl.java

License:Apache License

/**
 * Records the original name and resets access opcodes.
 *//*from  w  ww . ja  va 2  s  . co  m*/
@Override
public void visit(int version, int access, String name, String signature, String superName,
        String[] interfaces) {
    originalName = name;
    super.visit(version, Opcodes.ACC_PUBLIC | Opcodes.ACC_STATIC | Opcodes.ACC_SYNTHETIC, name + '$', signature,
            superName, interfaces);
}

From source file:com.google.gwt.dev.shell.rewrite.WriteJsoImpl.java

License:Apache License

/**
 * Mangle all instance methods declared in JavaScriptObject types.
 *//* w w w  .ja v  a2s .c  o m*/
@Override
public MethodVisitor visitMethod(int access, String name, String desc, String signature, String[] exceptions) {
    boolean isCtor = isCtor(name);
    if (!isCtor && !isStatic(access) && !isObjectMethod(name + desc)) {
        access |= Opcodes.ACC_STATIC;
        desc = HostedModeClassRewriter.addSyntheticThisParam(getOriginalName(), desc);
        name = name + "$";
    }
    return super.visitMethod(access, name, desc, signature, exceptions);
}

From source file:com.google.gwt.dev.shell.rewrite.WriteJsoImpl.java

License:Apache License

protected boolean isStatic(int access) {
    return (access & Opcodes.ACC_STATIC) != 0;
}

From source file:com.google.gwt.jvm.asm.ClassDollarVistor.java

License:Apache License

@Override
public MethodVisitor visitMethod(int access, String name, String desc, String signature, String[] exceptions) {
    MethodVisitor visitor;/*from   w  ww.j a  v  a 2  s. c  o  m*/
    if (!isStatic(access) && (!isConstructor(name))) {
        int staticMethodAccess = access | Opcodes.ACC_STATIC;
        String staticDesc = new Descriptor(desc).toDescPrefix(originalClassName);
        // System.out.println("Creating: " + originalClassName + "$." + name +
        // staticDesc);
        visitor = delegate.visitMethod(staticMethodAccess, name, staticDesc, signature, exceptions);
        visitor = new RewriteInvokeSpecial2InvokeVirtualForSuper(visitor, overlayTypePredicate);
    } else if (isConstructor(name)) {
        visitor = new ConstructorDollarMethodVistor(
                delegate.visitMethod(access, name, desc, signature, exceptions), overlayTypePredicate);
    } else {
        visitor = delegate.visitMethod(access, name, desc, signature, exceptions);
    }
    return new RewriteOverlayMethodDispatch(visitor, overlayTypePredicate);
}

From source file:com.google.gwt.jvm.asm.GwtClassMunger.java

License:Apache License

public static boolean isStatic(int access) {
    return isOpcode(access, Opcodes.ACC_STATIC);
}

From source file:com.google.gwt.jvm.asm.NativeMethodDispatchVisitor.java

License:Apache License

@Override
public MethodVisitor visitMethod(int access, String name, String desc, String signature, String[] exceptions) {
    int nonNativeAccess = access & ~Opcodes.ACC_NATIVE;
    MethodVisitor visitMethod = delegate.visitMethod(nonNativeAccess, name, desc, signature, exceptions);
    if (isOpcode(access, Opcodes.ACC_NATIVE)) {
        boolean isStatic = isOpcode(access, Opcodes.ACC_STATIC);
        return new NativeMethodDelegatingVisitor(visitMethod, className, name, new Descriptor(desc), isStatic);
    } else {//from www  . jav a 2s . c om
        //System.out.println(className + "." + name + "(" + desc + ")");
        return new RewriteOverlayMethodDispatch(visitMethod, overlayTypePredicate);
    }
}

From source file:com.google.gwt.jvm.asm.RewriteOverlayMethodDispatch.java

License:Apache License

@Override
public void visitMethodInsn(int opcode, String owner, String name, String desc) {
    if (overlayTypePredicate.isOverlayDesc(owner)) {
        //System.out.println(owner + "." + name);
        if (isConstructor(name)) {
            super.visitMethodInsn(opcode, owner + "$", name, desc);
        } else {/*w  w w .  j a v a  2 s  .c o m*/
            boolean isStatic = isOpcode(opcode, Opcodes.ACC_STATIC);

            String newDescriptor = desc;
            if (!isStatic) {
                String overlayClass = overlayTypePredicate.getImplementingClass(owner, name, desc);
                newDescriptor = new Descriptor(desc).toDescPrefix(overlayClass);
            }
            super.visitMethodInsn(Opcodes.INVOKESTATIC, owner + "$", name, newDescriptor);
        }
    } else {
        super.visitMethodInsn(opcode, owner, name, desc);
    }
}

From source file:com.google.singletondetector.visitors.SingletonClassVisitor.java

License:Apache License

@Override
public FieldVisitor visitField(int access, String name, String desc, String signature, Object value) {
    if ((access & Opcodes.ACC_STATIC) == Opcodes.ACC_STATIC) {
        if ((access & Opcodes.ACC_PUBLIC) == Opcodes.ACC_PUBLIC) {
            sd.visitStaticField(name, desc);
        }//from w  w  w  . j a  v  a  2 s  .  c o  m

        if ((access & Opcodes.ACC_PRIVATE) == Opcodes.ACC_PRIVATE
                && (access & Opcodes.ACC_FINAL) != Opcodes.ACC_FINAL) {
            sd.addStaticField(name, desc);
        }
    }
    return null;
}

From source file:com.google.singletondetector.visitors.SingletonClassVisitor.java

License:Apache License

@Override
public MethodVisitor visitMethod(int access, String name, String desc, String signature, String[] exceptions) {
    if (((access & Opcodes.ACC_STATIC) == Opcodes.ACC_STATIC
            && (access & Opcodes.ACC_PUBLIC) == Opcodes.ACC_PUBLIC)) {
        sd.visitStaticMethod(name, desc);
    }/* w  w  w.  ja  v a 2  s.  c  om*/

    return super.visitMethod(access, name, desc, signature, exceptions);
}

From source file:com.google.template.soy.jbcsrc.FieldRef.java

License:Apache License

static FieldRef staticFieldReference(java.lang.reflect.Field field) {
    if (!Modifier.isStatic(field.getModifiers())) {
        throw new IllegalStateException("Field: " + field + " is not static");
    }/*from  w  w  w.  ja va 2s . co m*/
    return new AutoValue_FieldRef(TypeInfo.create(field.getDeclaringClass()), field.getName(),
            Type.getType(field.getType()), Opcodes.ACC_STATIC,
            false /** Assume all static field refs are non-null. */
    );
}