Java Code Examples for jdk.internal.org.objectweb.asm.FieldVisitor#visitEnd()

The following examples show how to use jdk.internal.org.objectweb.asm.FieldVisitor#visitEnd() . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: ByteCodeVisitor.java    From openjdk-jdk9 with GNU General Public License v2.0 6 votes vote down vote up
@Override
public byte[] visit(VariableDeclaration node) {
    VariableInfo vi = node.getVariableInfo();
    String ownerName = vi.getOwner().getName();
    ContextDependedClassWriter cw = classWriters.get(ownerName);
    String typeName = new String(vi.type.accept(this));
    if (vi.isLocal()) {
        locals.addLocal(vi);
    } else {
        FieldVisitor fv = cw.visitField(asAccessFlags(vi),
                vi.name,
                typeName,
                null /* Generic */,
                null /* Constant value */);
        fv.visitEnd(); // doesn't need visitAnnotation and visitAttribute
    }
    return EMPTY_BYTE_ARRAY;
}
 
Example 2
Source File: SerialVersionUIDAdder.java    From openjdk-jdk8u-backup with GNU General Public License v2.0 5 votes vote down vote up
protected void addSVUID(long svuid) {
    FieldVisitor fv = super.visitField(Opcodes.ACC_FINAL
            + Opcodes.ACC_STATIC, "serialVersionUID", "J", null, svuid);
    if (fv != null) {
        fv.visitEnd();
    }
}
 
Example 3
Source File: SerialVersionUIDAdder.java    From jdk8u-jdk with GNU General Public License v2.0 5 votes vote down vote up
protected void addSVUID(long svuid) {
    FieldVisitor fv = super.visitField(Opcodes.ACC_FINAL
            + Opcodes.ACC_STATIC, "serialVersionUID", "J", null, svuid);
    if (fv != null) {
        fv.visitEnd();
    }
}
 
Example 4
Source File: ClassGenerator.java    From openjdk-jdk9 with GNU General Public License v2.0 5 votes vote down vote up
static void addMapField(final ClassVisitor cv) {
    // add a PropertyMap static field
    final FieldVisitor fv = cv.visitField(ACC_PRIVATE | ACC_STATIC | ACC_FINAL,
        PROPERTYMAP_FIELD_NAME, PROPERTYMAP_DESC, null, null);
    if (fv != null) {
        fv.visitEnd();
    }
}
 
Example 5
Source File: SerialVersionUIDAdder.java    From openjdk-jdk9 with GNU General Public License v2.0 5 votes vote down vote up
protected void addSVUID(long svuid) {
    FieldVisitor fv = super.visitField(Opcodes.ACC_FINAL
            + Opcodes.ACC_STATIC, "serialVersionUID", "J", null, svuid);
    if (fv != null) {
        fv.visitEnd();
    }
}
 
Example 6
Source File: ByteCodeVisitor.java    From openjdk-jdk9 with GNU General Public License v2.0 5 votes vote down vote up
@Override
public byte[] visit(Initialization node) {
    VariableInfo vi = node.getVariableInfo();
    if (vi.isLocal()) {
        return visitLocalVar(node);
    }
    String ownerName = vi.getOwner().getName();
    ContextDependedClassWriter cw = classWriters.get(ownerName);
    String typeName = new String(vi.type.accept(this));
    // constant value used only for final static fields
    FieldVisitor fw = cw.visitField(asAccessFlags(vi), vi.name,
            typeName,
            null /* Generic */,
            null /* Constant value */);
    fw.visitEnd(); // doesn't need visitAnnotation and visitAttribute
    if (vi.isStatic()) {
        node.getChild(0).accept(this); // put value to stack
        emitDup(vi.type);
        currentMV.visitFieldInsn(Opcodes.PUTSTATIC,
                asInternalName(vi.getOwner().getName()),
                vi.name,
                new String(vi.type.accept(this)));
    } else {
        // TODO : can it be another object?
        currentMV.visitVarInsn(Opcodes.ALOAD, 0); // put this to stack
        node.getChild(0).accept(this); // put value to stack
        emitDupX1(vi.type);
        currentMV.visitFieldInsn(Opcodes.PUTFIELD,
                asInternalName(vi.getOwner().getName()),
                vi.name,
                new String(vi.type.accept(this)));
    }
    return EMPTY_BYTE_ARRAY;
}
 
Example 7
Source File: SerialVersionUIDAdder.java    From Bytecoder with Apache License 2.0 5 votes vote down vote up
/**
  * Adds a final static serialVersionUID field to the class, with the given value.
  *
  * @param svuid the serialVersionUID field value.
  */
// DontCheck(AbbreviationAsWordInName): can't be renamed (for backward binary compatibility).
protected void addSVUID(final long svuid) {
    FieldVisitor fieldVisitor =
            super.visitField(
                    Opcodes.ACC_FINAL + Opcodes.ACC_STATIC, "serialVersionUID", "J", null, svuid);
    if (fieldVisitor != null) {
        fieldVisitor.visitEnd();
    }
}
 
Example 8
Source File: ClassGenerator.java    From openjdk-jdk8u-backup with GNU General Public License v2.0 5 votes vote down vote up
static void addMapField(final ClassVisitor cv) {
    // add a PropertyMap static field
    final FieldVisitor fv = cv.visitField(ACC_PRIVATE | ACC_STATIC | ACC_FINAL,
        PROPERTYMAP_FIELD_NAME, PROPERTYMAP_DESC, null, null);
    if (fv != null) {
        fv.visitEnd();
    }
}
 
Example 9
Source File: SerialVersionUIDAdder.java    From dragonwell8_jdk with GNU General Public License v2.0 5 votes vote down vote up
protected void addSVUID(long svuid) {
    FieldVisitor fv = super.visitField(Opcodes.ACC_FINAL
            + Opcodes.ACC_STATIC, "serialVersionUID", "J", null, svuid);
    if (fv != null) {
        fv.visitEnd();
    }
}
 
Example 10
Source File: ClassGenerator.java    From openjdk-jdk8u with GNU General Public License v2.0 5 votes vote down vote up
static void addMapField(final ClassVisitor cv) {
    // add a PropertyMap static field
    final FieldVisitor fv = cv.visitField(ACC_PRIVATE | ACC_STATIC | ACC_FINAL,
        PROPERTYMAP_FIELD_NAME, PROPERTYMAP_DESC, null, null);
    if (fv != null) {
        fv.visitEnd();
    }
}
 
Example 11
Source File: SerialVersionUIDAdder.java    From openjdk-jdk8u with GNU General Public License v2.0 5 votes vote down vote up
protected void addSVUID(long svuid) {
    FieldVisitor fv = super.visitField(Opcodes.ACC_FINAL
            + Opcodes.ACC_STATIC, "serialVersionUID", "J", null, svuid);
    if (fv != null) {
        fv.visitEnd();
    }
}
 
Example 12
Source File: ClassGenerator.java    From jdk8u60 with GNU General Public License v2.0 5 votes vote down vote up
static void addMapField(final ClassVisitor cv) {
    // add a PropertyMap static field
    final FieldVisitor fv = cv.visitField(ACC_PRIVATE | ACC_STATIC | ACC_FINAL,
        PROPERTYMAP_FIELD_NAME, PROPERTYMAP_DESC, null, null);
    if (fv != null) {
        fv.visitEnd();
    }
}
 
Example 13
Source File: SerialVersionUIDAdder.java    From jdk8u60 with GNU General Public License v2.0 5 votes vote down vote up
protected void addSVUID(long svuid) {
    FieldVisitor fv = super.visitField(Opcodes.ACC_FINAL
            + Opcodes.ACC_STATIC, "serialVersionUID", "J", null, svuid);
    if (fv != null) {
        fv.visitEnd();
    }
}
 
Example 14
Source File: ClassGenerator.java    From TencentKona-8 with GNU General Public License v2.0 5 votes vote down vote up
static void addMapField(final ClassVisitor cv) {
    // add a PropertyMap static field
    final FieldVisitor fv = cv.visitField(ACC_PRIVATE | ACC_STATIC | ACC_FINAL,
        PROPERTYMAP_FIELD_NAME, PROPERTYMAP_DESC, null, null);
    if (fv != null) {
        fv.visitEnd();
    }
}
 
Example 15
Source File: SerialVersionUIDAdder.java    From TencentKona-8 with GNU General Public License v2.0 5 votes vote down vote up
protected void addSVUID(long svuid) {
    FieldVisitor fv = super.visitField(Opcodes.ACC_FINAL
            + Opcodes.ACC_STATIC, "serialVersionUID", "J", null, svuid);
    if (fv != null) {
        fv.visitEnd();
    }
}
 
Example 16
Source File: ClassGenerator.java    From openjdk-jdk8u with GNU General Public License v2.0 4 votes vote down vote up
static void addField(final ClassVisitor cv, final String name, final String desc) {
    final FieldVisitor fv = cv.visitField(ACC_PRIVATE, name, desc, null, null);
    if (fv != null) {
        fv.visitEnd();
    }
}
 
Example 17
Source File: ClassGenerator.java    From openjdk-jdk8u-backup with GNU General Public License v2.0 4 votes vote down vote up
static void addField(final ClassVisitor cv, final String name, final String desc) {
    final FieldVisitor fv = cv.visitField(ACC_PRIVATE, name, desc, null, null);
    if (fv != null) {
        fv.visitEnd();
    }
}
 
Example 18
Source File: ClassGenerator.java    From jdk8u60 with GNU General Public License v2.0 4 votes vote down vote up
static void addField(final ClassVisitor cv, final String name, final String desc) {
    final FieldVisitor fv = cv.visitField(ACC_PRIVATE, name, desc, null, null);
    if (fv != null) {
        fv.visitEnd();
    }
}
 
Example 19
Source File: ClassGenerator.java    From TencentKona-8 with GNU General Public License v2.0 4 votes vote down vote up
static void addField(final ClassVisitor cv, final String name, final String desc) {
    final FieldVisitor fv = cv.visitField(ACC_PRIVATE, name, desc, null, null);
    if (fv != null) {
        fv.visitEnd();
    }
}
 
Example 20
Source File: ClassGenerator.java    From openjdk-jdk9 with GNU General Public License v2.0 4 votes vote down vote up
static void addField(final ClassVisitor cv, final String name, final String desc) {
    final FieldVisitor fv = cv.visitField(ACC_PRIVATE, name, desc, null, null);
    if (fv != null) {
        fv.visitEnd();
    }
}