Fixing bugs: 1) Arrays.asList generates finaled List (need to feed it into an ArrayLi...
authorrtrimana <rtrimana@uci.edu>
Thu, 1 Dec 2016 18:42:21 +0000 (10:42 -0800)
committerrtrimana <rtrimana@uci.edu>
Thu, 1 Dec 2016 18:42:21 +0000 (10:42 -0800)
iotjava/iotpolicy/IoTCompiler.java

index 9d9ecdd948f576618dd68f7f71783950f2026c2c..c28aeea465250de7e4f752012483f173119a4db4 100644 (file)
@@ -447,7 +447,7 @@ public class IoTCompiler {
                for (Map.Entry<String,Set<String>> intMeth : mapNewIntMethods.entrySet()) {
                        String newIntface = intMeth.getKey();
                        int newObjectId = getNewIntfaceObjectId(newIntface);
-                       println("set" + newObjectId + "Allowed = Arrays.asList(object" + newObjectId +"Permission);");
+                       println("set" + newObjectId + "Allowed = new ArrayList<Integer>(Arrays.asList(object" + newObjectId +"Permission));");
                }
        }
 
@@ -3148,15 +3148,17 @@ public class IoTCompiler {
        /**
         * HELPER: writeCplusInitCallbackPermission() writes the permission for callback
         */
-       private void writeCplusInitCallbackPermission(String intface, InterfaceDecl intDecl) {
+       private void writeCplusInitCallbackPermission(String intface, InterfaceDecl intDecl, boolean callbackExist) {
 
-               String method = "___initCallBack()";
-               int methodNumId = intDecl.getHelperMethodNumId(method);
-               Map<String,Set<String>> mapNewIntMethods = mapInt2NewInts.get(intface);
-               for (Map.Entry<String,Set<String>> intMeth : mapNewIntMethods.entrySet()) {
-                       String newIntface = intMeth.getKey();
-                       int newObjectId = getNewIntfaceObjectId(newIntface);
-                       println("set" + newObjectId + "Allowed.insert(" + methodNumId + ");");
+               if (callbackExist) {
+                       String method = "___initCallBack()";
+                       int methodNumId = intDecl.getHelperMethodNumId(method);
+                       Map<String,Set<String>> mapNewIntMethods = mapInt2NewInts.get(intface);
+                       for (Map.Entry<String,Set<String>> intMeth : mapNewIntMethods.entrySet()) {
+                               String newIntface = intMeth.getKey();
+                               int newObjectId = getNewIntfaceObjectId(newIntface);
+                               println("set" + newObjectId + "Allowed.insert(" + methodNumId + ");");
+                       }
                }
        }
 
@@ -3429,7 +3431,7 @@ public class IoTCompiler {
                println("bool _bResult = false;");
                println("mainObj = _mainObj;");
                println("rmiObj = new IoTRMIObject(_port, &_bResult);");
-               writeCplusInitCallbackPermission(intface, intDecl);
+               writeCplusInitCallbackPermission(intface, intDecl, callbackExist);
                writeStructPermissionCplusSkeleton(methods, intDecl, intface);
                println("___waitRequestInvokeMethod();");
                println("}\n");