use of org.eclipse.persistence.internal.libraries.asm.Label in project eclipselink by eclipse-ee4j.
the class CollectionProxyClassWriter method writeClass.
/**
* public class Proxy extends SuperType implements CollectionProxy {
* private List<LinkV2> links;
*
* public CollectionProxy(Collection c) {
* super();
* this.addAll(c);
* }
*
* @Override
* public List<LinkV2> getLinks() {
* return links;
* }
*
* @Override
* public void setLinks(List<LinkV2> links) {
* this.links = links;
* }
* }
*/
@Override
public byte[] writeClass(DynamicClassLoader loader, String className) {
final EclipseLinkASMClassWriter cw = new EclipseLinkASMClassWriter(0);
MethodVisitor mv;
// public class Proxy extends SuperType implements CollectionProxy
cw.visit(ACC_PUBLIC + ACC_SUPER, getASMClassName(), null, getASMParentClassName(), new String[] { INTERFACE });
// private List<LinkV2> links;
final FieldVisitor fv = cw.visitField(ACC_PRIVATE, "links", "Ljava/util/List;", "Ljava/util/List<Lorg/eclipse/persistence/internal/jpa/rs/metadata/model/LinkV2;>;", null);
fv.visitEnd();
// public CollectionProxy(Collection c) {
// super();
// this.addAll(c);
// }
{
mv = cw.visitMethod(ACC_PUBLIC, "<init>", "(Ljava/util/Collection;)V", null, null);
mv.visitCode();
Label l0 = new Label();
mv.visitLabel(l0);
mv.visitLineNumber(15, l0);
mv.visitVarInsn(ALOAD, 0);
mv.visitMethodInsn(INVOKESPECIAL, getASMParentClassName(), "<init>", "()V", false);
Label l1 = new Label();
mv.visitLabel(l1);
mv.visitLineNumber(16, l1);
mv.visitVarInsn(ALOAD, 0);
mv.visitVarInsn(ALOAD, 1);
mv.visitMethodInsn(INVOKEVIRTUAL, getASMClassName(), "addAll", "(Ljava/util/Collection;)Z", false);
mv.visitInsn(POP);
Label l2 = new Label();
mv.visitLabel(l2);
mv.visitLineNumber(17, l2);
mv.visitInsn(RETURN);
Label l3 = new Label();
mv.visitLabel(l3);
mv.visitLocalVariable("this", "L" + getASMClassName() + ";", null, l0, l3, 0);
mv.visitLocalVariable("c", "Ljava/util/Collection;", null, l0, l3, 1);
mv.visitMaxs(2, 2);
mv.visitEnd();
}
// @Override
// public List<LinkV2> getLinks() {
// return links;
// }
{
mv = cw.visitMethod(ACC_PUBLIC, "getLinks", "()Ljava/util/List;", "()Ljava/util/List<Lorg/eclipse/persistence/internal/jpa/rs/metadata/model/LinkV2;>;", null);
mv.visitCode();
Label l0 = new Label();
mv.visitLabel(l0);
mv.visitLineNumber(21, l0);
mv.visitVarInsn(ALOAD, 0);
mv.visitFieldInsn(GETFIELD, getASMClassName(), "links", "Ljava/util/List;");
mv.visitInsn(ARETURN);
Label l1 = new Label();
mv.visitLabel(l1);
mv.visitLocalVariable("this", "L" + getASMClassName() + ";", null, l0, l1, 0);
mv.visitMaxs(1, 1);
mv.visitEnd();
}
// @Override
// public void setLinks(List<LinkV2> links) {
// this.links = links;
// }
{
mv = cw.visitMethod(ACC_PUBLIC, "setLinks", "(Ljava/util/List;)V", "(Ljava/util/List<Lorg/eclipse/persistence/internal/jpa/rs/metadata/model/LinkV2;>;)V", null);
mv.visitCode();
Label l0 = new Label();
mv.visitLabel(l0);
mv.visitLineNumber(26, l0);
mv.visitVarInsn(ALOAD, 0);
mv.visitVarInsn(ALOAD, 1);
mv.visitFieldInsn(PUTFIELD, getASMClassName(), "links", "Ljava/util/List;");
Label l1 = new Label();
mv.visitLabel(l1);
mv.visitLineNumber(27, l1);
mv.visitInsn(RETURN);
Label l2 = new Label();
mv.visitLabel(l2);
mv.visitLocalVariable("this", "L" + getASMClassName() + ";", null, l0, l2, 0);
mv.visitLocalVariable("links", "Ljava/util/List;", "Ljava/util/List<Lorg/eclipse/persistence/internal/jpa/rs/metadata/model/LinkV2;>;", l0, l2, 1);
mv.visitMaxs(2, 2);
mv.visitEnd();
}
return cw.toByteArray();
}
Aggregations