geode-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From kl...@apache.org
Subject incubator-geode git commit: Fix arg ctor
Date Tue, 17 May 2016 20:26:06 GMT
Repository: incubator-geode
Updated Branches:
  refs/heads/feature/GEODE-1392 868db81ac -> 67d5e8de6


Fix arg ctor


Project: http://git-wip-us.apache.org/repos/asf/incubator-geode/repo
Commit: http://git-wip-us.apache.org/repos/asf/incubator-geode/commit/67d5e8de
Tree: http://git-wip-us.apache.org/repos/asf/incubator-geode/tree/67d5e8de
Diff: http://git-wip-us.apache.org/repos/asf/incubator-geode/diff/67d5e8de

Branch: refs/heads/feature/GEODE-1392
Commit: 67d5e8de64b4a41c635d139045ce3b9b760522c9
Parents: 868db81
Author: Kirk Lund <klund@apache.org>
Authored: Tue May 17 13:26:08 2016 -0700
Committer: Kirk Lund <klund@apache.org>
Committed: Tue May 17 13:26:08 2016 -0700

----------------------------------------------------------------------
 ...bHelperWithThreadContextClassLoaderTest.java | 57 +++++++++++---------
 1 file changed, 33 insertions(+), 24 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/incubator-geode/blob/67d5e8de/geode-core/src/test/java/com/gemstone/gemfire/internal/util/BlobHelperWithThreadContextClassLoaderTest.java
----------------------------------------------------------------------
diff --git a/geode-core/src/test/java/com/gemstone/gemfire/internal/util/BlobHelperWithThreadContextClassLoaderTest.java
b/geode-core/src/test/java/com/gemstone/gemfire/internal/util/BlobHelperWithThreadContextClassLoaderTest.java
index 56b23b1..6dfcadd 100644
--- a/geode-core/src/test/java/com/gemstone/gemfire/internal/util/BlobHelperWithThreadContextClassLoaderTest.java
+++ b/geode-core/src/test/java/com/gemstone/gemfire/internal/util/BlobHelperWithThreadContextClassLoaderTest.java
@@ -16,7 +16,7 @@
  */
 package com.gemstone.gemfire.internal.util;
 
-import static org.assertj.core.api.Assertions.assertThat;
+import static org.assertj.core.api.Assertions.*;
 
 import java.io.IOException;
 import java.io.Serializable;
@@ -243,46 +243,54 @@ public class BlobHelperWithThreadContextClassLoaderTest {
       ConstantPoolGen cp = cg.getConstantPool();
       InstructionFactory fac = new InstructionFactory(cg, cp);
 
-      // constructor
-      cg.addEmptyConstructor(Constants.ACC_PUBLIC);
-
       // field
       FieldGen fg = new FieldGen(Constants.ACC_PRIVATE, Type.OBJECT, VALUE, cp);
       Field field = fg.getField();
       cg.addField(field);
 
-      // setter
-      //   0: aload_0
-      //   1: aload_1
-      //   2: putfield #2; //Field value:Ljava/lang/Object;
-      //   5: return
-      InstructionList setter = new InstructionList();
-      MethodGen setterMethod = new MethodGen(Constants.ACC_PUBLIC, Type.VOID, new Type[]
{Type.OBJECT}, new String[] {field.getName()}, SET_VALUE, CLASS_NAME_SERIALIZABLE_IMPL_WITH_VALUE,
setter, cp);
-      setterMethod.setMaxStack(2);
+      // empty constructor
+      cg.addEmptyConstructor(Constants.ACC_PUBLIC);
 
-      InstructionHandle setter_ih_0 = setter.append(fac.createLoad(Type.OBJECT, 0)); // 0:
aload_0 this
-      InstructionHandle setter_ih_1 = setter.append(fac.createLoad(Type.OBJECT, 1)); // 1:
aload_1 value
-      InstructionHandle setter_ih_2 = setter.append(fac.createPutField(cg.getClassName(),
field.getName(), Type.getType(field.getSignature()))); // 2: putfield #2 stack to field
-      InstructionHandle setter_ih_0_ih_5 = setter.append(fac.createReturn(Type.VOID)); //
5: return void
+      // constructor with arg
+      InstructionList ctor = new InstructionList();
+      MethodGen ctorMethod = new MethodGen(Constants.ACC_PUBLIC, Type.VOID, new Type[] {
Type.OBJECT }, new String[] { "arg0" }, "<init>", "com.gemstone.gemfire.internal.util.bcel.SerializableImplWithValue",
ctor, cp);
+      ctorMethod.setMaxStack(2);
 
-      cg.addMethod(setterMethod.getMethod());
-      setter.dispose();
+      InstructionHandle ctor_ih_0 = ctor.append(fac.createLoad(Type.OBJECT, 0));
+      ctor.append(fac.createInvoke(CLASS_NAME_SERIALIZABLE_IMPL, "<init>", Type.VOID,
Type.NO_ARGS, Constants.INVOKESPECIAL));
+      InstructionHandle ctor_ih_4 = ctor.append(fac.createLoad(Type.OBJECT, 0));
+      ctor.append(fac.createLoad(Type.OBJECT, 1));
+      ctor.append(fac.createFieldAccess(CLASS_NAME_SERIALIZABLE_IMPL_WITH_VALUE, "value",
Type.OBJECT, Constants.PUTFIELD));
+      InstructionHandle ctor_ih_9 = ctor.append(fac.createReturn(Type.VOID));
+
+      cg.addMethod(ctorMethod.getMethod());
+      ctor.dispose();
 
       // getter
-      //   0: aload_0
-      //   1: getfield #2; //Field value:Ljava/lang/Object;
-      //   4: areturn
       InstructionList getter = new InstructionList();
       MethodGen getterMethod = new MethodGen(Constants.ACC_PUBLIC, Type.OBJECT, null, null,
GET_VALUE, CLASS_NAME_SERIALIZABLE_IMPL_WITH_VALUE, getter, cp);
       getterMethod.setMaxStack(1);
 
-      InstructionHandle getter_ih_0 = getter.append(fac.createLoad(Type.OBJECT, 0)); // 0:
aload_0 this
-      InstructionHandle getter_ih_1 = getter.append(fac.createGetField(cg.getClassName(),
field.getName(), Type.getType(field.getSignature()))); // 1: getfield #2 field to stack
-      InstructionHandle getter_ih_4 = getter.append(fac.createReturn(Type.OBJECT)); // 4:
areturn Object
+      InstructionHandle getter_ih_0 = getter.append(fac.createLoad(Type.OBJECT, 0));
+      InstructionHandle getter_ih_1 = getter.append(fac.createGetField(cg.getClassName(),
field.getName(), Type.getType(field.getSignature())));
+      InstructionHandle getter_ih_4 = getter.append(fac.createReturn(Type.OBJECT));
 
       cg.addMethod(getterMethod.getMethod());
       getter.dispose();
 
+      // setter
+      InstructionList setter = new InstructionList();
+      MethodGen setterMethod = new MethodGen(Constants.ACC_PUBLIC, Type.VOID, new Type[]
{Type.OBJECT}, new String[] {field.getName()}, SET_VALUE, CLASS_NAME_SERIALIZABLE_IMPL_WITH_VALUE,
setter, cp);
+      setterMethod.setMaxStack(2);
+
+      InstructionHandle setter_ih_0 = setter.append(fac.createLoad(Type.OBJECT, 0));
+      InstructionHandle setter_ih_1 = setter.append(fac.createLoad(Type.OBJECT, 1));
+      InstructionHandle setter_ih_2 = setter.append(fac.createPutField(cg.getClassName(),
field.getName(), Type.getType(field.getSignature())));
+      InstructionHandle setter_ih_0_ih_5 = setter.append(fac.createReturn(Type.VOID));
+
+      cg.addMethod(setterMethod.getMethod());
+      setter.dispose();
+
       JavaClass jClazz = cg.getJavaClass();
       byte[] bytes = jClazz.getBytes();
       return defineClass(jClazz.getClassName(), bytes, 0, bytes.length);
@@ -295,3 +303,4 @@ public class BlobHelperWithThreadContextClassLoaderTest {
     }
   }
 }
+


Mime
View raw message