Fixing problem with array/list of callbacks; Java static variables persist across...
authorrtrimana <rtrimana@uci.edu>
Mon, 5 Dec 2016 23:20:13 +0000 (15:20 -0800)
committerrtrimana <rtrimana@uci.edu>
Mon, 5 Dec 2016 23:20:13 +0000 (15:20 -0800)
iotjava/iotpolicy/IoTCompiler.java
iotjava/iotrmi/C++/basics/TestClass_Stub.cpp
iotjava/iotrmi/Java/basics/TestClass_Stub.java

index e461706..d056fe4 100644 (file)
@@ -1119,7 +1119,7 @@ public class IoTCompiler {
                println("private String address;");
                println("private int[] ports;\n");
                // Get the object Id
-               println("private static int objectId = 0;");
+               println("private int objectId = 0;");
                if (callbackExist) {
                // We assume that each class only has one callback interface for now
                        Iterator it = callbackClasses.iterator();
@@ -2172,7 +2172,7 @@ public class IoTCompiler {
 
                println("private " + intface + " mainObj;");
                // For callback skeletons, this is its own object Id
-               println("private static int objectId = 0;");
+               println("private int objectId = 0;");
                // Callback
                if (callbackExist) {
                        println("private static int objIdCnt = 0;");
index 207eb8b..d3c4e1d 100644 (file)
@@ -142,9 +142,9 @@ int main(int argc, char *argv[])
        cb.push_back(cb3);
        tcStub->registerCallbackArray(cb);
        cout << "Return value from callback: " << tcStub->callBack() << endl;
-       CallBackInterface *cb4 = new CallBack(23);
-       CallBackInterface *cb5 = new CallBack(33);
-       CallBackInterface *cb6 = new CallBack(43);
+       CallBackInterface *cb4 = new CallBack(53);
+       CallBackInterface *cb5 = new CallBack(63);
+       CallBackInterface *cb6 = new CallBack(73);
        vector<CallBackInterface*> cblist;
        cblist.push_back(cb4);
        cblist.push_back(cb5);
index d82c905..7a6b277 100644 (file)
@@ -106,16 +106,16 @@ public class TestClass_Stub {
                //CallBackInterface cbSingle2 = new CallBack(2355);
                //tcstub.registerCallback(cbSingle2);
                //System.out.println("Return value from callback: " + tcstub.callBack());
-               /*CallBackInterface cb1 = new CallBack(23);
+               CallBackInterface cb1 = new CallBack(23);
                CallBackInterface cb2 = new CallBack(33);
                CallBackInterface cb3 = new CallBack(43);
                CallBackInterface[] cb = { cb1, cb2, cb3 };
                tcstub.registerCallbackArray(cb);
-               System.out.println("Return value from callback: " + tcstub.callBack());*/
+               System.out.println("Return value from callback: " + tcstub.callBack());
                List<CallBackInterface> cblist = new ArrayList<CallBackInterface>();
-               CallBackInterface cb1 = new CallBack(23); cblist.add(cb1);
-               CallBackInterface cb2 = new CallBack(33); cblist.add(cb2);
-               CallBackInterface cb3 = new CallBack(43); cblist.add(cb3);
+               CallBackInterface cb4 = new CallBack(53); cblist.add(cb4);
+               CallBackInterface cb5 = new CallBack(63); cblist.add(cb5);
+               CallBackInterface cb6 = new CallBack(73); cblist.add(cb6);
                tcstub.registerCallbackList(cblist);
                System.out.println("Return value from callback: " + tcstub.callBack());
 
@@ -124,5 +124,7 @@ public class TestClass_Stub {
                System.out.println("Return value: " + tcstub.setAndGetA(123));
                System.out.println("Return value: " + tcstub.setACAndGetA("string", 123));
                System.out.println("Return value: " + tcstub.sumArray(new String[] { "123", "456", "987" }));
+
+
        }
 }