Fix protobuf code generation for Timestamp
We forgot to push the field value onto the stack, so we couldn't
invoke getTime() on the timestamp object. This resulted in a class
verification error.
We also failed to denote the constructor as taking a primitive long,
causing a class verification error when a long was found where an
uninitialized object was expected.
Change-Id: I4c60fac33f2c1c8dea02d97ac6ad4522ffacf3b6
Signed-off-by: Shawn O. Pearce <sop@google.com>
diff --git a/src/main/java/com/google/gwtorm/protobuf/CodecGen.java b/src/main/java/com/google/gwtorm/protobuf/CodecGen.java
index 05e5d6d..eb26460 100644
--- a/src/main/java/com/google/gwtorm/protobuf/CodecGen.java
+++ b/src/main/java/com/google/gwtorm/protobuf/CodecGen.java
@@ -272,6 +272,7 @@
|| f.getPrimitiveType() == java.util.Date.class
|| f.getPrimitiveType() == java.sql.Date.class) {
cgs.push(f.getColumnID());
+ cgs.pushFieldValue();
String tsType = Type.getType(f.getPrimitiveType()).getInternalName();
mv.visitMethodInsn(INVOKEVIRTUAL, tsType, "getTime", Type
.getMethodDescriptor(Type.LONG_TYPE, new Type[] {}));
@@ -649,8 +650,9 @@
mv.visitTypeInsn(NEW, tsType);
mv.visitInsn(DUP);
cgs.call("readFixed64", Type.LONG_TYPE);
- mv.visitMethodInsn(INVOKESPECIAL, tsType, "<init>", Type
- .getMethodDescriptor(Type.VOID_TYPE, new Type[] {}));
+ mv.visitMethodInsn(INVOKESPECIAL, tsType, "<init>", //
+ Type.getMethodDescriptor(Type.VOID_TYPE,
+ new Type[] {Type.LONG_TYPE}));
} else {
throw new OrmException("Type " + f.getPrimitiveType()