/** * public boolean bdbIsPriKeyFieldNullOrZero() { return theField == null; // or zero or false, as * appropriate // or if no primary key but has superclass: return * super.bdbIsPriKeyFieldNullOrZero(); } */ private void genBdbIsPriKeyFieldNullOrZero() { MethodVisitor mv = cv.visitMethod(ACC_PUBLIC, "bdbIsPriKeyFieldNullOrZero", "()Z", null, null); mv.visitCode(); if (priKeyField != null) { mv.visitVarInsn(ALOAD, 0); mv.visitFieldInsn(GETFIELD, className, priKeyField.name, priKeyField.type.getDescriptor()); Label l0 = new Label(); if (isRefType(priKeyField.type)) { mv.visitJumpInsn(IFNONNULL, l0); } else { genBeforeCompareToZero(mv, priKeyField.type); mv.visitJumpInsn(IFNE, l0); } mv.visitInsn(ICONST_1); Label l1 = new Label(); mv.visitJumpInsn(GOTO, l1); mv.visitLabel(l0); mv.visitInsn(ICONST_0); mv.visitLabel(l1); } else if (hasPersistentSuperclass) { mv.visitVarInsn(ALOAD, 0); mv.visitMethodInsn(INVOKESPECIAL, superclassName, "bdbIsPriKeyFieldNullOrZero", "()Z"); } else { mv.visitInsn(ICONST_0); } mv.visitInsn(IRETURN); mv.visitMaxs(1, 1); mv.visitEnd(); }
/** * public void bdbSetField(Object o, int field, int superLevel, boolean isSecField, Object value) * { if (superLevel > 0) { // if has superclass: super.bdbSetField (o, field, superLevel - 1, * isSecField, value); } else if (isSecField) { switch (field) { case 0: f2 = ((Integer) * value).intValue(); case 1: f3 = (String) value; case 2: f4 = (String) value; } } else { switch * (field) { case 0: f5 = ((Integer) value).intValue(); case 1: f6 = (String) value; case 2: f7 = * (String) value; } } } */ private void genBdbSetField() { MethodVisitor mv = cv.visitMethod( ACC_PUBLIC, "bdbSetField", "(Ljava/lang/Object;IIZLjava/lang/Object;)V", null, null); mv.visitCode(); mv.visitVarInsn(ILOAD, 3); Label l0 = new Label(); mv.visitJumpInsn(IFLE, l0); if (hasPersistentSuperclass) { mv.visitVarInsn(ALOAD, 0); mv.visitVarInsn(ALOAD, 1); mv.visitVarInsn(ILOAD, 2); mv.visitVarInsn(ILOAD, 3); mv.visitInsn(ICONST_1); mv.visitInsn(ISUB); mv.visitVarInsn(ILOAD, 4); mv.visitVarInsn(ALOAD, 5); mv.visitMethodInsn( INVOKESPECIAL, className, "bdbSetField", "(Ljava/lang/Object;IIZLjava/lang/Object;)V"); } mv.visitInsn(RETURN); mv.visitLabel(l0); mv.visitVarInsn(ILOAD, 4); Label l2 = new Label(); mv.visitJumpInsn(IFEQ, l2); Label l1 = new Label(); genSetFieldSwitch(mv, secKeyFields, l1); mv.visitLabel(l2); genSetFieldSwitch(mv, nonKeyFields, l1); mv.visitLabel(l1); mv.visitInsn(RETURN); mv.visitMaxs(2, 6); mv.visitEnd(); }
/** * public void bdbReadXxxKeyFields(EntityInput input, int startField, int endField, int * superLevel) { // ... if (superLevel <= 0) { switch (startField) { case 0: keyField1 = * input.readInt(); if (endField == 0) break; case 1: keyField2 = (String) input.readObject(); if * (endField == 1) break; case 2: keyField3 = input.readInt(); } } */ private void genReadFieldSwitch(MethodVisitor mv, List<FieldInfo> fields) { int nFields = fields.size(); if (nFields > 0) { mv.visitVarInsn(ILOAD, 4); Label pastSwitch = new Label(); mv.visitJumpInsn(IFGT, pastSwitch); Label[] labels = new Label[nFields]; for (int i = 0; i < nFields; i += 1) { labels[i] = new Label(); } mv.visitVarInsn(ILOAD, 2); mv.visitTableSwitchInsn(0, nFields - 1, pastSwitch, labels); for (int i = 0; i < nFields; i += 1) { FieldInfo field = fields.get(i); mv.visitLabel(labels[i]); genReadField(mv, field); if (i < nFields - 1) { Label nextCase = labels[i + 1]; mv.visitVarInsn(ILOAD, 3); if (i == 0) { mv.visitJumpInsn(IFNE, nextCase); } else { switch (i) { case 1: mv.visitInsn(ICONST_1); break; case 2: mv.visitInsn(ICONST_2); break; case 3: mv.visitInsn(ICONST_3); break; case 4: mv.visitInsn(ICONST_4); break; case 5: mv.visitInsn(ICONST_5); break; default: mv.visitIntInsn(BIPUSH, i); } mv.visitJumpInsn(IF_ICMPNE, nextCase); } mv.visitJumpInsn(GOTO, pastSwitch); } } mv.visitLabel(pastSwitch); } }
/** * public void bdbWriteNonKeyFields(EntityOutput output) { super.bdbWriteNonKeyFields(output); // * if has super output.writeInt(nonKeyField1); output.writeObject(nonKeyField2, null); // etc } */ private void genBdbWriteNonKeyFields() { MethodVisitor mv = cv.visitMethod( ACC_PUBLIC, "bdbWriteNonKeyFields", "(Lcom/sleepycat/persist/impl/EntityOutput;)V", null, null); mv.visitCode(); if (hasPersistentSuperclass) { mv.visitVarInsn(ALOAD, 0); mv.visitVarInsn(ALOAD, 1); mv.visitMethodInsn( INVOKESPECIAL, superclassName, "bdbWriteNonKeyFields", "(Lcom/sleepycat/persist/impl/EntityOutput;)V"); } if (isCompositeKey) { for (FieldInfo field : nonKeyFields) { genWriteSimpleKeyField(mv, field); /* Ignore non-simple (illegal) types for composite key. */ } } else { for (FieldInfo field : nonKeyFields) { genWriteField(mv, field); } } mv.visitInsn(RETURN); mv.visitMaxs(2, 2); mv.visitEnd(); }
/** * public void bdbWriteSecKeyFields(EntityOutput output) { * output.registerPriKeyObject(priKeyField); // if an object * super.bdbWriteSecKeyFields(EntityOutput output); // if has super output.writeInt(secKeyField1); * output.writeObject(secKeyField2, null); // etc } */ private void genBdbWriteSecKeyFields() { MethodVisitor mv = cv.visitMethod( ACC_PUBLIC, "bdbWriteSecKeyFields", "(Lcom/sleepycat/persist/impl/EntityOutput;)V", null, null); mv.visitCode(); if (priKeyField != null && isRefType(priKeyField.type)) { genRegisterPrimaryKey(mv, false); } if (hasPersistentSuperclass) { mv.visitVarInsn(ALOAD, 0); mv.visitVarInsn(ALOAD, 1); mv.visitMethodInsn( INVOKESPECIAL, superclassName, "bdbWriteSecKeyFields", "(Lcom/sleepycat/persist/impl/EntityOutput;)V"); } for (FieldInfo field : secKeyFields) { genWriteField(mv, field); } mv.visitInsn(RETURN); mv.visitMaxs(2, 2); mv.visitEnd(); }
/** * mv.visitVarInsn(ILOAD, 2); Label l0 = new Label(); Label l1 = new Label(); Label l2 = new * Label(); mv.visitTableSwitchInsn(0, 2, TheDefLabel, new Label[] { l0, l1, l2 }); * mv.visitLabel(l0); mv.visitVarInsn(ALOAD, 0); mv.visitVarInsn(ALOAD, 5); * mv.visitTypeInsn(CHECKCAST, "java/lang/Integer"); mv.visitMethodInsn(INVOKEVIRTUAL, * "java/lang/Integer", "intValue", "()I"); mv.visitFieldInsn(PUTFIELD, TheClassName, "f2", "I"); * mv.visitLabel(l1); mv.visitVarInsn(ALOAD, 0); mv.visitVarInsn(ALOAD, 5); * mv.visitTypeInsn(CHECKCAST, "java/lang/String"); mv.visitFieldInsn(PUTFIELD, TheClassName, * "f3", "Ljava/lang/String;"); mv.visitLabel(l2); mv.visitVarInsn(ALOAD, 0); * mv.visitVarInsn(ALOAD, 5); mv.visitTypeInsn(CHECKCAST, "java/lang/String"); * mv.visitFieldInsn(PUTFIELD, TheClassName, "f4", "Ljava/lang/String;"); */ private void genSetFieldSwitch(MethodVisitor mv, List<FieldInfo> fields, Label defaultLabel) { int nFields = fields.size(); if (nFields == 0) { mv.visitJumpInsn(GOTO, defaultLabel); return; } Label[] labels = new Label[nFields]; for (int i = 0; i < nFields; i += 1) { labels[i] = new Label(); } mv.visitVarInsn(ILOAD, 2); mv.visitTableSwitchInsn(0, nFields - 1, defaultLabel, labels); for (int i = 0; i < nFields; i += 1) { FieldInfo field = fields.get(i); mv.visitLabel(labels[i]); mv.visitVarInsn(ALOAD, 0); mv.visitVarInsn(ALOAD, 5); if (isRefType(field.type)) { mv.visitTypeInsn(CHECKCAST, getTypeInstName(field.type)); } else { int sort = field.type.getSort(); mv.visitTypeInsn(CHECKCAST, getPrimitiveWrapperClass(sort).replace('.', '/')); genUnwrapPrimitive(mv, sort); } mv.visitFieldInsn(PUTFIELD, className, field.name, field.type.getDescriptor()); mv.visitInsn(RETURN); } }
/** * public Object bdbNewArray(int len) { return new TheClass[len]; // or if abstract: return null; * } */ private void genBdbNewArray() { MethodVisitor mv = cv.visitMethod(ACC_PUBLIC, "bdbNewArray", "(I)Ljava/lang/Object;", null, null); mv.visitCode(); if (isAbstract) { mv.visitInsn(ACONST_NULL); mv.visitInsn(ARETURN); mv.visitMaxs(1, 2); } else { mv.visitVarInsn(ILOAD, 1); mv.visitTypeInsn(ANEWARRAY, className); mv.visitInsn(ARETURN); mv.visitMaxs(1, 2); mv.visitEnd(); } }
/** public Object bdbNewInstance() { return new TheClass(); // or if abstract: return null; } */ private void genBdbNewInstance() { MethodVisitor mv = cv.visitMethod(ACC_PUBLIC, "bdbNewInstance", "()Ljava/lang/Object;", null, null); mv.visitCode(); if (isAbstract) { mv.visitInsn(ACONST_NULL); mv.visitInsn(ARETURN); mv.visitMaxs(1, 1); } else { mv.visitTypeInsn(NEW, className); mv.visitInsn(DUP); mv.visitMethodInsn(INVOKESPECIAL, className, "<init>", "()V"); mv.visitInsn(ARETURN); mv.visitMaxs(2, 1); } mv.visitEnd(); }
/** // if has super: if (superLevel != 0) { super.bdbReadXxxKeyFields(..., superLevel - 1); } */ private void genReadSuperKeyFields(MethodVisitor mv, boolean areSecKeyFields) { if (hasPersistentSuperclass) { Label next = new Label(); mv.visitVarInsn(ILOAD, 4); mv.visitJumpInsn(IFEQ, next); mv.visitVarInsn(ALOAD, 0); mv.visitVarInsn(ALOAD, 1); mv.visitVarInsn(ILOAD, 2); mv.visitVarInsn(ILOAD, 3); mv.visitVarInsn(ILOAD, 4); mv.visitInsn(ICONST_1); mv.visitInsn(ISUB); String name = areSecKeyFields ? "bdbReadSecKeyFields" : "bdbReadNonKeyFields"; mv.visitMethodInsn( INVOKESPECIAL, superclassName, name, "(Lcom/sleepycat/persist/impl/EntityInput;III)V"); mv.visitLabel(next); } }
/** * Outputs code in a static block to register the prototype instance: * * <p>static { EnhancedAccessor.registerClass(TheClassName, new TheClass()); // or for an abstract * class: EnhancedAccessor.registerClass(TheClassName, null); } */ private void genStaticBlock() { MethodVisitor mv = cv.visitMethod(ACC_STATIC, "<clinit>", "()V", null, null); mv.visitCode(); if (staticBlockMethod != null) { mv.visitMethodInsn(INVOKESTATIC, className, staticBlockMethod, "()V"); } mv.visitLdcInsn(className.replace('/', '.')); if (isAbstract) { mv.visitInsn(ACONST_NULL); } else { mv.visitTypeInsn(NEW, className); mv.visitInsn(DUP); mv.visitMethodInsn(INVOKESPECIAL, className, "<init>", "()V"); } mv.visitMethodInsn( INVOKESTATIC, "com/sleepycat/persist/impl/EnhancedAccessor", "registerClass", "(Ljava/lang/String;Lcom/sleepycat/persist/impl/Enhanced;)V"); mv.visitInsn(RETURN); mv.visitMaxs(3, 0); mv.visitEnd(); }
/** * Generates writing of a simple type key field, or returns false if the key field is not a simple * type (i.e., it is a composite key type). * * <p>output.writeInt(theField); // and other primitives // or * output.writeInt(theField.intValue()); // and other simple types // or returns false */ private boolean genWriteSimpleKeyField(MethodVisitor mv, FieldInfo field) { if (genWritePrimitiveField(mv, field)) { return true; } String fieldClassName = field.type.getClassName(); if (!isSimpleRefType(fieldClassName)) { return false; } mv.visitVarInsn(ALOAD, 1); mv.visitVarInsn(ALOAD, 0); mv.visitFieldInsn(GETFIELD, className, field.name, field.type.getDescriptor()); Integer sort = PRIMITIVE_WRAPPERS.get(fieldClassName); if (sort != null) { genUnwrapPrimitive(mv, sort); genWritePrimitive(mv, sort); } else if (fieldClassName.equals(Date.class.getName())) { mv.visitMethodInsn(INVOKEVIRTUAL, "java/util/Date", "getTime", "()J"); genWritePrimitive(mv, Type.LONG); } else if (fieldClassName.equals(String.class.getName())) { mv.visitMethodInsn( INVOKEINTERFACE, "com/sleepycat/persist/impl/EntityOutput", "writeString", "(Ljava/lang/String;)Lcom/sleepycat/bind/tuple/TupleOutput;"); mv.visitInsn(POP); } else if (fieldClassName.equals(BigInteger.class.getName())) { mv.visitMethodInsn( INVOKEINTERFACE, "com/sleepycat/persist/impl/EntityOutput", "writeBigInteger", "(Ljava/math/BigInteger;)Lcom/sleepycat/bind/tuple/TupleOutput;"); mv.visitInsn(POP); } else { throw new IllegalStateException(fieldClassName); } return true; }
/** output.writeInt(field); // and other primitives // or output.writeObject(field, null); */ private void genWriteField(MethodVisitor mv, FieldInfo field) { mv.visitVarInsn(ALOAD, 1); mv.visitVarInsn(ALOAD, 0); mv.visitFieldInsn(GETFIELD, className, field.name, field.type.getDescriptor()); int sort = field.type.getSort(); if (sort == Type.OBJECT || sort == Type.ARRAY) { mv.visitInsn(ACONST_NULL); mv.visitMethodInsn( INVOKEINTERFACE, "com/sleepycat/persist/impl/EntityOutput", "writeObject", "(Ljava/lang/Object;Lcom/sleepycat/persist/impl/Format;)V"); } else { genWritePrimitive(mv, sort); } }
/** * public void bdbReadSecKeyFields(EntityInput input, int startField, int endField, int * superLevel) { input.registerPriKeyObject(priKeyField); // if an object // if has super: if * (superLevel != 0) { super.bdbReadSecKeyFields(..., superLevel - 1); } if (superLevel <= 0) { * switch (startField) { case 0: secKeyField1 = input.readInt(); if (endField == 0) break; case 1: * secKeyField2 = (String) input.readObject(); if (endField == 1) break; case 2: secKeyField3 = * input.readInt(); } } } */ private void genBdbReadSecKeyFields() { MethodVisitor mv = cv.visitMethod( ACC_PUBLIC, "bdbReadSecKeyFields", "(Lcom/sleepycat/persist/impl/EntityInput;III)V", null, null); mv.visitCode(); if (priKeyField != null && isRefType(priKeyField.type)) { genRegisterPrimaryKey(mv, true); } genReadSuperKeyFields(mv, true); genReadFieldSwitch(mv, secKeyFields); mv.visitInsn(RETURN); mv.visitMaxs(5, 5); mv.visitEnd(); }
/** * Generates reading of a simple type key field, or returns false if the key field is not a simple * type (i.e., it is a composite key type). * * <p>field = input.readInt(); // and other primitives // or field = * Integer.valueOf(input.readInt()); // and other simple types // or returns false */ private boolean genReadSimpleKeyField(MethodVisitor mv, FieldInfo field) { if (genReadPrimitiveField(mv, field)) { return true; } String fieldClassName = field.type.getClassName(); if (!isSimpleRefType(fieldClassName)) { return false; } Integer sort = PRIMITIVE_WRAPPERS.get(fieldClassName); if (sort != null) { mv.visitVarInsn(ALOAD, 0); mv.visitVarInsn(ALOAD, 1); genReadPrimitive(mv, sort); genWrapPrimitive(mv, sort); } else if (fieldClassName.equals(Date.class.getName())) { /* Date is a special case because we use NEW instead of valueOf. */ mv.visitVarInsn(ALOAD, 0); mv.visitTypeInsn(NEW, "java/util/Date"); mv.visitInsn(DUP); mv.visitVarInsn(ALOAD, 1); genReadPrimitive(mv, Type.LONG); mv.visitMethodInsn(INVOKESPECIAL, "java/util/Date", "<init>", "(J)V"); } else if (fieldClassName.equals(String.class.getName())) { mv.visitVarInsn(ALOAD, 0); mv.visitVarInsn(ALOAD, 1); mv.visitMethodInsn( INVOKEINTERFACE, "com/sleepycat/persist/impl/EntityInput", "readString", "()Ljava/lang/String;"); } else if (fieldClassName.equals(BigInteger.class.getName())) { mv.visitVarInsn(ALOAD, 0); mv.visitVarInsn(ALOAD, 1); mv.visitMethodInsn( INVOKEINTERFACE, "com/sleepycat/persist/impl/EntityInput", "readBigInteger", "()Ljava/math/BigInteger;"); } else { throw new IllegalStateException(fieldClassName); } mv.visitFieldInsn(PUTFIELD, className, field.name, field.type.getDescriptor()); return true; }
/** * Call this method before comparing a non-reference operand to zero as an int, for example, with * IFNE, IFEQ, IFLT, etc. If the operand is a long, float or double, this method will compare it * to zero and leave the result as an int operand. */ private static void genBeforeCompareToZero(MethodVisitor mv, Type type) { switch (type.getSort()) { case Type.LONG: mv.visitInsn(LCONST_0); mv.visitInsn(LCMP); break; case Type.FLOAT: mv.visitInsn(FCONST_0); mv.visitInsn(FCMPL); break; case Type.DOUBLE: mv.visitInsn(DCONST_0); mv.visitInsn(DCMPL); break; } }
/** * public void bdbReadNonKeyFields(EntityInput input, int startField, int endField, int * superLevel) { // if has super: if (superLevel != 0) { super.bdbReadNonKeyFields(..., superLevel * - 1); } nonKeyField1 = input.readInt(); nonKeyField2 = (String) input.readObject(); // etc // * or like bdbReadSecKeyFields if not a composite key class } */ private void genBdbReadNonKeyFields() { MethodVisitor mv = cv.visitMethod( ACC_PUBLIC, "bdbReadNonKeyFields", "(Lcom/sleepycat/persist/impl/EntityInput;III)V", null, null); mv.visitCode(); if (isCompositeKey) { for (FieldInfo field : nonKeyFields) { genReadSimpleKeyField(mv, field); /* Ignore non-simple (illegal) types for composite key. */ } } else { genReadSuperKeyFields(mv, false); genReadFieldSwitch(mv, nonKeyFields); } mv.visitInsn(RETURN); mv.visitMaxs(5, 5); mv.visitEnd(); }
/** * mv.visitVarInsn(ILOAD, 2); Label l0 = new Label(); Label l1 = new Label(); Label l2 = new * Label(); mv.visitTableSwitchInsn(0, 2, TheDefLabel, new Label[] { l0, l1, l2 }); * mv.visitLabel(l0); mv.visitVarInsn(ALOAD, 0); mv.visitFieldInsn(GETFIELD, TheClassName, "f2", * "I"); mv.visitMethodInsn(INVOKESTATIC, "java/lang/Integer", "valueOf", * "(I)Ljava/lang/Integer;"); mv.visitInsn(ARETURN); mv.visitLabel(l1); mv.visitVarInsn(ALOAD, 0); * mv.visitFieldInsn(GETFIELD, TheClassName, "f3", "Ljava/lang/String;"); mv.visitInsn(ARETURN); * mv.visitLabel(l2); mv.visitVarInsn(ALOAD, 0); mv.visitFieldInsn(GETFIELD, TheClassName, "f4", * "Ljava/lang/String;"); mv.visitInsn(ARETURN); */ private void genGetFieldSwitch(MethodVisitor mv, List<FieldInfo> fields, Label defaultLabel) { int nFields = fields.size(); if (nFields == 0) { mv.visitJumpInsn(GOTO, defaultLabel); return; } Label[] labels = new Label[nFields]; for (int i = 0; i < nFields; i += 1) { labels[i] = new Label(); } mv.visitVarInsn(ILOAD, 2); mv.visitTableSwitchInsn(0, nFields - 1, defaultLabel, labels); for (int i = 0; i < nFields; i += 1) { FieldInfo field = fields.get(i); mv.visitLabel(labels[i]); mv.visitVarInsn(ALOAD, 0); mv.visitFieldInsn(GETFIELD, className, field.name, field.type.getDescriptor()); if (!isRefType(field.type)) { genWrapPrimitive(mv, field.type.getSort()); } mv.visitInsn(ARETURN); } }
/** * public void bdbReadPriKeyField(EntityInput input, Format format) { theField = (TheFieldClass) * input.readKeyObject(format); // or theField = input.readInt(); // and other simple types // or * if no primary key but has superclass: super.bdbReadPriKeyField(input, format); } */ private void genBdbReadPriKeyField() { MethodVisitor mv = cv.visitMethod( ACC_PUBLIC, "bdbReadPriKeyField", "(Lcom/sleepycat/persist/impl/EntityInput;" + "Lcom/sleepycat/persist/impl/Format;)V", null, null); mv.visitCode(); if (priKeyField != null) { if (!genReadSimpleKeyField(mv, priKeyField)) { /* For a non-simple type, call EntityInput.readKeyObject. */ mv.visitVarInsn(ALOAD, 0); mv.visitVarInsn(ALOAD, 1); mv.visitVarInsn(ALOAD, 2); mv.visitMethodInsn( INVOKEINTERFACE, "com/sleepycat/persist/impl/EntityInput", "readKeyObject", "(Lcom/sleepycat/persist/impl/Format;)" + "Ljava/lang/Object;"); mv.visitTypeInsn(CHECKCAST, getTypeInstName(priKeyField.type)); mv.visitFieldInsn(PUTFIELD, className, priKeyField.name, priKeyField.type.getDescriptor()); } } else if (hasPersistentSuperclass) { mv.visitVarInsn(ALOAD, 0); mv.visitVarInsn(ALOAD, 1); mv.visitVarInsn(ALOAD, 2); mv.visitMethodInsn( INVOKESPECIAL, superclassName, "bdbReadPriKeyField", "(Lcom/sleepycat/persist/impl/EntityInput;" + "Lcom/sleepycat/persist/impl/Format;)V"); } mv.visitInsn(RETURN); mv.visitMaxs(3, 3); mv.visitEnd(); }
private void genWritePrimitive(MethodVisitor mv, int sort) { switch (sort) { case Type.BOOLEAN: mv.visitMethodInsn( INVOKEINTERFACE, "com/sleepycat/persist/impl/EntityOutput", "writeBoolean", "(Z)Lcom/sleepycat/bind/tuple/TupleOutput;"); break; case Type.CHAR: mv.visitMethodInsn( INVOKEINTERFACE, "com/sleepycat/persist/impl/EntityOutput", "writeChar", "(I)Lcom/sleepycat/bind/tuple/TupleOutput;"); break; case Type.BYTE: mv.visitMethodInsn( INVOKEINTERFACE, "com/sleepycat/persist/impl/EntityOutput", "writeByte", "(I)Lcom/sleepycat/bind/tuple/TupleOutput;"); break; case Type.SHORT: mv.visitMethodInsn( INVOKEINTERFACE, "com/sleepycat/persist/impl/EntityOutput", "writeShort", "(I)Lcom/sleepycat/bind/tuple/TupleOutput;"); break; case Type.INT: mv.visitMethodInsn( INVOKEINTERFACE, "com/sleepycat/persist/impl/EntityOutput", "writeInt", "(I)Lcom/sleepycat/bind/tuple/TupleOutput;"); break; case Type.LONG: mv.visitMethodInsn( INVOKEINTERFACE, "com/sleepycat/persist/impl/EntityOutput", "writeLong", "(J)Lcom/sleepycat/bind/tuple/TupleOutput;"); break; case Type.FLOAT: mv.visitMethodInsn( INVOKEINTERFACE, "com/sleepycat/persist/impl/EntityOutput", "writeSortedFloat", "(F)Lcom/sleepycat/bind/tuple/TupleOutput;"); break; case Type.DOUBLE: mv.visitMethodInsn( INVOKEINTERFACE, "com/sleepycat/persist/impl/EntityOutput", "writeSortedDouble", "(D)Lcom/sleepycat/bind/tuple/TupleOutput;"); break; default: throw new IllegalStateException(String.valueOf(sort)); } /* The write methods always return 'this' and we always discard it. */ mv.visitInsn(POP); }