changeset 174:4acc8eae476b

8129121: ADCChannel.setScaleFactor(valid) doesn't set current sampling interval to minimal (recent fix in the spec) Summary: Redesign of ADCChannelConfig value verfication, ActionFactory renamed to Utils Reviewed-by: alkonsta
author snazarki
date Thu, 18 Jun 2015 16:40:53 +0300
parents 03997bac2a18
children 4328bfd8a8f5
files src/se/classes/com/oracle/dio/impl/Platform.java src/share/classes/com/oracle/dio/utils/ActionFactory.java src/share/classes/com/oracle/dio/utils/Utils.java src/share/classes/jdk/dio/DeviceMgmtPermission.java src/share/classes/jdk/dio/DevicePermission.java src/share/classes/jdk/dio/adc/ADCChannelConfig.java src/share/classes/jdk/dio/adc/ADCPermission.java src/share/classes/jdk/dio/atcmd/ATPermission.java src/share/classes/jdk/dio/counter/CounterPermission.java src/share/classes/jdk/dio/dac/DACPermission.java src/share/classes/jdk/dio/generic/GenericPermission.java src/share/classes/jdk/dio/gpio/GPIOPinPermission.java src/share/classes/jdk/dio/gpio/GPIOPortPermission.java src/share/classes/jdk/dio/i2cbus/I2CPermission.java src/share/classes/jdk/dio/pwm/PWMPermission.java src/share/classes/jdk/dio/spibus/SPIPermission.java src/share/classes/jdk/dio/uart/UARTConfig.java src/share/classes/jdk/dio/uart/UARTPermission.java src/share/classes/jdk/dio/watchdog/WatchdogTimerPermission.java
diffstat 19 files changed, 255 insertions(+), 215 deletions(-) [+]
line wrap: on
line diff
--- a/src/se/classes/com/oracle/dio/impl/Platform.java	Thu Jun 18 14:46:23 2015 +0300
+++ b/src/se/classes/com/oracle/dio/impl/Platform.java	Thu Jun 18 16:40:53 2015 +0300
@@ -79,8 +79,13 @@
      * @param obj object to be cloned.
      * @return a clone of object.
      */
-    public static Object clone(Object obj) throws IOException {
-        return deserialize(serialize(obj));
+    public static Object clone(Object obj)  {
+        try {
+            return deserialize(serialize(obj));
+        } catch (IOException e) {
+            Logging.reportWarning(ExceptionMessage.format(ExceptionMessage.CLONE_ERROR));
+            return instance;
+        }
     }
 
     /**
--- a/src/share/classes/com/oracle/dio/utils/ActionFactory.java	Thu Jun 18 14:46:23 2015 +0300
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,162 +0,0 @@
-/*
- * Copyright (c) 2014, Oracle and/or its affiliates. All rights reserved.
- * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
- *
- * This code is free software; you can redistribute it and/or modify it
- * under the terms of the GNU General Public License version 2 only, as
- * published by the Free Software Foundation.  Oracle designates this
- * particular file as subject to the "Classpath" exception as provided
- * by Oracle in the LICENSE file that accompanied this code.
- *
- * This code is distributed in the hope that it will be useful, but WITHOUT
- * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
- * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
- * version 2 for more details (a copy is included in the LICENSE file that
- * accompanied this code).
- *
- * You should have received a copy of the GNU General Public License version
- * 2 along with this work; if not, write to the Free Software Foundation,
- * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
- *
- * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
- * or visit www.oracle.com if you need additional information or have any
- * questions.
- */
-
-package com.oracle.dio.utils;
-
-import java.util.StringTokenizer;
-import jdk.dio.DevicePermission;
-
-/**
- * Utility class for device permission class
- */
-public class ActionFactory {
-    /**
-     * Checks if <code>actions1</code> list "implies"
-     * <code>actions2</code> list
-     *
-     * @param actions1 comma-separated list of verified and valid
-     *                 actions
-     * @param actions1 comma-separated list of verified and valid
-     *                 actions
-     *
-     * @return true <code>actions2</code> list is implied by
-     *         <code>actions1</code> list
-     */
-    public static boolean implies(String actions1, String actions2) {
-        int index = actions2.indexOf(",");
-        if (index == -1) {
-            return isIncluded(actions2, actions1);
-        } else {
-            return implies(actions1, actions2.substring(0, index)) &&
-                   implies(actions1, actions2.substring(index+1));
-        }
-    }
-
-    /**
-     * Checks if given <code>what</code> is included to
-     * <code>where</code> list
-     *
-     * @param what   string to compare
-     * @param where  coma-separated string list to search at
-     *
-     * @return <code>true</code> if <code>what</code> contains in
-     *         the list
-     */
-    private static boolean isIncluded(String what, String where) {
-        StringTokenizer tokens = new StringTokenizer(where, ",");
-        while (tokens.hasMoreElements()) {
-            if (tokens.nextToken().equals(what)) {
-                return true;
-            }
-        }
-        return false;
-    }
-
-    /**
-     * Return true for permission specified actions
-     *
-     * @param action for validation
-     * @param normalizedList allowed actions list
-     *
-     * @return true for valid
-     */
-    private static boolean isValidAction(String actions, String normalizedList) {
-        StringTokenizer tokez = new StringTokenizer(actions, ",", true);
-        // detect first empty token
-        boolean lastTokenIsComma = true;
-        while (tokez.hasMoreElements()) {
-            String action = tokez.nextToken();
-            // special case for empty actions that are not returned by StringTokenizer.nextToken() by default
-            if (action.equals(",")) {
-                if (lastTokenIsComma) {
-                    return false;
-                } else {
-                    lastTokenIsComma = true;
-                    continue;
-                }
-            } else {
-                lastTokenIsComma = false;
-            }
-            if (!isIncluded(action, normalizedList)) {
-                return false;
-            }
-        }
-        // detects last empty token as well
-        return !lastTokenIsComma;
-    }
-
-    /**
-     * Returns action list in spec required order
-     *
-     * @param actions unordered and unverified list
-     * @param normalizedList allowed actions list in normalized form
-     *
-     * @return ordered list
-     */
-    public static String verifyAndOrderActions(String actions, String normalizedList) {
-        if(actions == null){
-            throw new IllegalArgumentException(
-                ExceptionMessage.format(ExceptionMessage.DEVICE_NULL_ACTIONS)
-            );
-        }
-        if(actions.length() == 0){
-            throw new IllegalArgumentException(
-                ExceptionMessage.format(ExceptionMessage.DEVICE_EMPTY_ACTIONS)
-            );
-        }
-
-        if (!isValidAction(actions, normalizedList)) {
-            throw new IllegalArgumentException(actions);
-        }
-
-        boolean comma = false;
-        StringBuilder sb = new StringBuilder(30);
-        StringTokenizer tokez = new StringTokenizer(normalizedList, ",");
-        while (tokez.hasMoreElements()) {
-            String validAction = tokez.nextToken();
-            if (isIncluded(validAction, actions)) {
-                if (comma) {
-                    sb.append(',');
-                }
-                sb.append(validAction);
-                comma = true;
-            }
-        }
-
-        return sb.toString();
-    }
-
-    /**
-     * Verifies and order given <code>actions</code> against
-     * DevicePermission actions list
-     *
-     * @param actions unordered and unverified list
-     *
-     * @return ordered and verified list
-     */
-    public static String verifyAndOrderDeviceActions(String actions) {
-        return verifyAndOrderActions(actions, DevicePermission.OPEN + "," + DevicePermission.POWER_MANAGE);
-    }
-}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/src/share/classes/com/oracle/dio/utils/Utils.java	Thu Jun 18 16:40:53 2015 +0300
@@ -0,0 +1,194 @@
+/*
+ * Copyright (c) 2014, Oracle and/or its affiliates. All rights reserved.
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * This code is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License version 2 only, as
+ * published by the Free Software Foundation.  Oracle designates this
+ * particular file as subject to the "Classpath" exception as provided
+ * by Oracle in the LICENSE file that accompanied this code.
+ *
+ * This code is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
+ * version 2 for more details (a copy is included in the LICENSE file that
+ * accompanied this code).
+ *
+ * You should have received a copy of the GNU General Public License version
+ * 2 along with this work; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
+ *
+ * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
+ * or visit www.oracle.com if you need additional information or have any
+ * questions.
+ */
+
+package com.oracle.dio.utils;
+
+import java.util.StringTokenizer;
+
+import jdk.dio.DeviceConfig;
+import jdk.dio.DevicePermission;
+
+/**
+ * Utility class for device permission class
+ */
+public final class Utils {
+    /**
+     * Checks if <code>actions1</code> list "implies"
+     * <code>actions2</code> list
+     *
+     * @param actions1 comma-separated list of verified and valid
+     *                 actions
+     * @param actions1 comma-separated list of verified and valid
+     *                 actions
+     *
+     * @return true <code>actions2</code> list is implied by
+     *         <code>actions1</code> list
+     */
+    public static boolean implies(String actions1, String actions2) {
+        int index = actions2.indexOf(",");
+        if (index == -1) {
+            return isIncluded(actions2, actions1);
+        } else {
+            return implies(actions1, actions2.substring(0, index)) &&
+                   implies(actions1, actions2.substring(index+1));
+        }
+    }
+
+    /**
+     * Checks if given <code>what</code> is included to
+     * <code>where</code> list
+     *
+     * @param what   string to compare
+     * @param where  coma-separated string list to search at
+     *
+     * @return <code>true</code> if <code>what</code> contains in
+     *         the list
+     */
+    private static boolean isIncluded(String what, String where) {
+        StringTokenizer tokens = new StringTokenizer(where, ",");
+        while (tokens.hasMoreElements()) {
+            if (tokens.nextToken().equals(what)) {
+                return true;
+            }
+        }
+        return false;
+    }
+
+    /**
+     * Return true for permission specified actions
+     *
+     * @param action for validation
+     * @param normalizedList allowed actions list
+     *
+     * @return true for valid
+     */
+    private static boolean isValidAction(String actions, String normalizedList) {
+        StringTokenizer tokez = new StringTokenizer(actions, ",", true);
+        // detect first empty token
+        boolean lastTokenIsComma = true;
+        while (tokez.hasMoreElements()) {
+            String action = tokez.nextToken();
+            // special case for empty actions that are not returned by StringTokenizer.nextToken() by default
+            if (action.equals(",")) {
+                if (lastTokenIsComma) {
+                    return false;
+                } else {
+                    lastTokenIsComma = true;
+                    continue;
+                }
+            } else {
+                lastTokenIsComma = false;
+            }
+            if (!isIncluded(action, normalizedList)) {
+                return false;
+            }
+        }
+        // detects last empty token as well
+        return !lastTokenIsComma;
+    }
+
+    /**
+     * Returns action list in spec required order
+     *
+     * @param actions unordered and unverified list
+     * @param normalizedList allowed actions list in normalized form
+     *
+     * @return ordered list
+     */
+    public static String verifyAndOrderActions(String actions, String normalizedList) {
+        if(actions == null){
+            throw new IllegalArgumentException(
+                ExceptionMessage.format(ExceptionMessage.DEVICE_NULL_ACTIONS)
+            );
+        }
+        if(actions.length() == 0){
+            throw new IllegalArgumentException(
+                ExceptionMessage.format(ExceptionMessage.DEVICE_EMPTY_ACTIONS)
+            );
+        }
+
+        if (!isValidAction(actions, normalizedList)) {
+            throw new IllegalArgumentException(actions);
+        }
+
+        boolean comma = false;
+        StringBuilder sb = new StringBuilder(30);
+        StringTokenizer tokez = new StringTokenizer(normalizedList, ",");
+        while (tokez.hasMoreElements()) {
+            String validAction = tokez.nextToken();
+            if (isIncluded(validAction, actions)) {
+                if (comma) {
+                    sb.append(',');
+                }
+                sb.append(validAction);
+                comma = true;
+            }
+        }
+
+        return sb.toString();
+    }
+
+    /**
+     * Verifies and order given <code>actions</code> against
+     * DevicePermission actions list
+     *
+     * @param actions unordered and unverified list
+     *
+     * @return ordered and verified list
+     */
+    public static String verifyAndOrderDeviceActions(String actions) {
+        return verifyAndOrderActions(actions, DevicePermission.OPEN + "," + DevicePermission.POWER_MANAGE);
+    }
+
+
+    /**
+     * Checks if given value is UNASSIGNED or zero or positive
+     *
+     */
+    public static void checkIntValue(final int val) {
+        if (DeviceConfig.UNASSIGNED > val) {
+            throw new IllegalArgumentException(Integer.toString(val));
+        }
+    }
+
+    /**
+     * Checks if given value is greater than one
+     *
+     */
+    public static void checkGreaterThanOne(final int val) {
+        if (1> val) {
+            throw new IllegalArgumentException(Integer.toString(val));
+        }
+    }
+
+    /**
+     * Checks if no NaN and positive value
+     */
+    public static void checkDoubleGreaterThanOne(double val) {
+        if (val  < 1.0 || Double.NaN == val) {
+            throw new IllegalArgumentException(Double.toString(val));
+        }
+    }
+}
--- a/src/share/classes/jdk/dio/DeviceMgmtPermission.java	Thu Jun 18 14:46:23 2015 +0300
+++ b/src/share/classes/jdk/dio/DeviceMgmtPermission.java	Thu Jun 18 16:40:53 2015 +0300
@@ -29,8 +29,8 @@
 import java.util.Objects;
 import java.util.Vector;
 
-import com.oracle.dio.utils.ActionFactory;
-import com.oracle.dio.utils.ActionFactory;
+import com.oracle.dio.utils.Utils;
+import com.oracle.dio.utils.Utils;
 import com.oracle.dio.utils.ExceptionMessage;
 
 /**
@@ -149,7 +149,7 @@
             );
         }
         checkTargetNameFormat(name);
-        myActions = ActionFactory.verifyAndOrderActions(actions, REGISTER+","+UNREGISTER+","+OPEN);
+        myActions = Utils.verifyAndOrderActions(actions, REGISTER+","+UNREGISTER+","+OPEN);
     }
 
     private void checkTargetNameFormat(String name) {
@@ -281,7 +281,7 @@
         if ((permission == null) || (permission.getClass() != getClass()))
             return false;
 
-        if (!ActionFactory.implies(myActions, permission.getActions())) return false;
+        if (!Utils.implies(myActions, permission.getActions())) return false;
 
         String thatName = ((DeviceMgmtPermission)permission).thisName;
 
--- a/src/share/classes/jdk/dio/DevicePermission.java	Thu Jun 18 14:46:23 2015 +0300
+++ b/src/share/classes/jdk/dio/DevicePermission.java	Thu Jun 18 16:40:53 2015 +0300
@@ -29,7 +29,7 @@
 import java.util.Enumeration;
 import java.util.Vector;
 import com.oracle.dio.utils.ExceptionMessage;
-import com.oracle.dio.utils.ActionFactory;
+import com.oracle.dio.utils.Utils;
 import romizer.Local;
 
 /**
@@ -264,7 +264,7 @@
         if ((permission == null) || (permission.getClass() != getClass()))
             return false;
 
-        if (!ActionFactory.implies(myActions, permission.getActions())) return false;
+        if (!Utils.implies(myActions, permission.getActions())) return false;
 
         int idx = -1;
         String name = permission.getName();
--- a/src/share/classes/jdk/dio/adc/ADCChannelConfig.java	Thu Jun 18 14:46:23 2015 +0300
+++ b/src/share/classes/jdk/dio/adc/ADCChannelConfig.java	Thu Jun 18 16:40:53 2015 +0300
@@ -31,6 +31,7 @@
 import java.util.Objects;
 
 import com.oracle.dio.impl.Platform;
+import com.oracle.dio.utils.Utils;
 
 import jdk.dio.DeviceConfig;
 import jdk.dio.DeviceManager;
@@ -115,8 +116,7 @@
          * @return a new initialized {@code ADCChannelConfig} instance.
          */
         public ADCChannelConfig build() {
-            instance.checkValues();
-            return instance;
+            return (ADCChannelConfig)Platform.clone(instance);
         }
 
         /**
@@ -127,6 +127,8 @@
          * @return this {@code Builder} instance.
          */
         public Builder setControllerName(String controllerName) {
+            // null check
+            controllerName.length();
             instance.controllerName = controllerName;
             return this;
         }
@@ -141,6 +143,7 @@
          * the defined range.
          */
         public Builder setChannelNumber(int channelNumber) {
+            Utils.checkIntValue(channelNumber);
             instance.channelNumber = channelNumber;
             return this;
         }
@@ -155,6 +158,7 @@
          * in the defined range.
          */
         public Builder setControllerNumber(int controllerNumber) {
+            Utils.checkIntValue(controllerNumber);
             instance.controllerNumber = controllerNumber;
             return this;
         }
@@ -169,6 +173,7 @@
          * defined range.
          */
         public Builder setResolution(int resolution) {
+            Utils.checkGreaterThanOne(resolution);
             instance.resolution = resolution;
             return this;
         }
@@ -187,6 +192,7 @@
          * @see #setScaleFactor
          */
         public Builder setSamplingInterval(int samplingInterval) {
+            Utils.checkGreaterThanOne(samplingInterval);
             instance.samplingInterval = samplingInterval;
             return this;
         }
@@ -204,6 +210,7 @@
          * @see #setScaleFactor
          */
         public Builder setSamplingTime(int samplingTime) {
+            Utils.checkGreaterThanOne(samplingTime);
             instance.samplingTime = samplingTime;
             return this;
         }
@@ -219,6 +226,7 @@
          * defined range.
          */
         public Builder setScaleFactor(double scaleFactor) {
+            Utils.checkDoubleGreaterThanOne(scaleFactor);
             instance.scaleFactor = Double.doubleToLongBits(scaleFactor);
             return this;
         }
@@ -234,6 +242,7 @@
          * the defined range.
          */
         public Builder setInputBufferSize(int inputBufferSize) {
+            Utils.checkIntValue(inputBufferSize);
             instance.inputBufferSize = inputBufferSize;
             return this;
         }
@@ -336,7 +345,7 @@
      * @since 1.1
      */
     public static ADCChannelConfig deserialize(InputStream in) throws IOException {
-        throw new IOException("Unsupported Operation");
+        return (ADCChannelConfig)Platform.deserialize(in);
     }
 
     /**
@@ -352,7 +361,7 @@
      */
     @Override
     public int serialize(OutputStream out) throws IOException {
-        throw new IOException("Unsupported Operation");
+        return Platform.serialize(this, out);
     }
 
     /**
@@ -474,14 +483,14 @@
         return Platform.equals(this, obj);
     }
 
+
     private void checkValues() throws IllegalArgumentException {
-        if ((null == controllerName && DEFAULT > controllerNumber) ||
-            DEFAULT > channelNumber ||
-            DEFAULT > resolution || 0 == resolution ||
-            DEFAULT > samplingInterval || 0 == samplingInterval ||
-            DEFAULT > samplingTime || 0 == samplingTime ||
-            getScaleFactor() < 0.0) {
-            throw new IllegalArgumentException();
-        }
+        Utils.checkIntValue(controllerNumber);
+        Utils.checkIntValue(channelNumber);
+        Utils.checkIntValue(inputBufferSize);
+        Utils.checkGreaterThanOne(resolution);
+        Utils.checkGreaterThanOne(samplingInterval);
+        Utils.checkGreaterThanOne(samplingTime);
     }
 }
+
--- a/src/share/classes/jdk/dio/adc/ADCPermission.java	Thu Jun 18 14:46:23 2015 +0300
+++ b/src/share/classes/jdk/dio/adc/ADCPermission.java	Thu Jun 18 16:40:53 2015 +0300
@@ -28,7 +28,7 @@
 import jdk.dio.DevicePermission;
 import java.security.Permission;
 import java.security.PermissionCollection;
-import com.oracle.dio.utils.ActionFactory;
+import com.oracle.dio.utils.Utils;
 
 /**
  * The {@code ADCPermission} class defines permissions for ADC channel access.
@@ -95,6 +95,6 @@
      * @see #getName getName
      */
     public ADCPermission(String name, String actions) {
-        super(name, ActionFactory.verifyAndOrderDeviceActions(actions));
+        super(name, Utils.verifyAndOrderDeviceActions(actions));
     }
 }
--- a/src/share/classes/jdk/dio/atcmd/ATPermission.java	Thu Jun 18 14:46:23 2015 +0300
+++ b/src/share/classes/jdk/dio/atcmd/ATPermission.java	Thu Jun 18 16:40:53 2015 +0300
@@ -28,7 +28,7 @@
 import jdk.dio.DevicePermission;
 import java.security.Permission;
 import java.security.PermissionCollection;
-import com.oracle.dio.utils.ActionFactory;
+import com.oracle.dio.utils.Utils;
 
 /**
  * The {@code ATPermission} class defines permissions for AT device access.
@@ -104,6 +104,6 @@
      *             </ul>
      */
     public ATPermission(String name, String actions) {
-        super(name, ActionFactory.verifyAndOrderActions(actions, DevicePermission.OPEN + "," + DATA + "," + DevicePermission.POWER_MANAGE));
+        super(name, Utils.verifyAndOrderActions(actions, DevicePermission.OPEN + "," + DATA + "," + DevicePermission.POWER_MANAGE));
     }
 }
--- a/src/share/classes/jdk/dio/counter/CounterPermission.java	Thu Jun 18 14:46:23 2015 +0300
+++ b/src/share/classes/jdk/dio/counter/CounterPermission.java	Thu Jun 18 16:40:53 2015 +0300
@@ -28,7 +28,7 @@
 import jdk.dio.DevicePermission;
 import java.security.Permission;
 import java.security.PermissionCollection;
-import com.oracle.dio.utils.ActionFactory;
+import com.oracle.dio.utils.Utils;
 
 /**
  * The {@code CounterPermission} class defines permissions for pulse counter access.
@@ -95,7 +95,7 @@
      * @see #getName getName
      */
     public CounterPermission(String name, String actions) {
-        super(name, ActionFactory.verifyAndOrderDeviceActions(actions));
+        super(name, Utils.verifyAndOrderDeviceActions(actions));
     }
 }
 
--- a/src/share/classes/jdk/dio/dac/DACPermission.java	Thu Jun 18 14:46:23 2015 +0300
+++ b/src/share/classes/jdk/dio/dac/DACPermission.java	Thu Jun 18 16:40:53 2015 +0300
@@ -29,7 +29,7 @@
 import jdk.dio.DevicePermission;
 import java.security.Permission;
 import java.security.PermissionCollection;
-import com.oracle.dio.utils.ActionFactory;
+import com.oracle.dio.utils.Utils;
 
 /**
  * The {@code DACPermission} class defines permissions for DAC channel access.
@@ -94,6 +94,6 @@
      * @see #getName getName
      */
     public DACPermission(String name, String actions) {
-        super(name, ActionFactory.verifyAndOrderDeviceActions(actions));
+        super(name, Utils.verifyAndOrderDeviceActions(actions));
     }
 }
--- a/src/share/classes/jdk/dio/generic/GenericPermission.java	Thu Jun 18 14:46:23 2015 +0300
+++ b/src/share/classes/jdk/dio/generic/GenericPermission.java	Thu Jun 18 16:40:53 2015 +0300
@@ -28,7 +28,7 @@
 import jdk.dio.DevicePermission;
 import java.security.Permission;
 import java.security.PermissionCollection;
-import com.oracle.dio.utils.ActionFactory;
+import com.oracle.dio.utils.Utils;
 
 /**
  * The {@code GenericPermission} class defines permissions for g device access.
@@ -93,7 +93,7 @@
      * @see #getName getName
      */
     public GenericPermission(String name, String actions) {
-        super(name, ActionFactory.verifyAndOrderDeviceActions(actions));
+        super(name, Utils.verifyAndOrderDeviceActions(actions));
     }
 }
 
--- a/src/share/classes/jdk/dio/gpio/GPIOPinPermission.java	Thu Jun 18 14:46:23 2015 +0300
+++ b/src/share/classes/jdk/dio/gpio/GPIOPinPermission.java	Thu Jun 18 16:40:53 2015 +0300
@@ -28,7 +28,7 @@
 import jdk.dio.DevicePermission;
 import java.security.Permission;
 import java.security.PermissionCollection;
-import com.oracle.dio.utils.ActionFactory;
+import com.oracle.dio.utils.Utils;
 
 /**
  * The {@code GPIOPinPermission} class defines permissions for GPIO pin access.
@@ -104,6 +104,6 @@
      * @see #getName getName
      */
     public GPIOPinPermission(String name, String actions) {
-        super(name, ActionFactory.verifyAndOrderActions(actions, DevicePermission.OPEN + "," + DevicePermission.POWER_MANAGE + "," + SET_DIRECTION));
+        super(name, Utils.verifyAndOrderActions(actions, DevicePermission.OPEN + "," + DevicePermission.POWER_MANAGE + "," + SET_DIRECTION));
     }
 }
--- a/src/share/classes/jdk/dio/gpio/GPIOPortPermission.java	Thu Jun 18 14:46:23 2015 +0300
+++ b/src/share/classes/jdk/dio/gpio/GPIOPortPermission.java	Thu Jun 18 16:40:53 2015 +0300
@@ -28,7 +28,7 @@
 import jdk.dio.DevicePermission;
 import java.security.Permission;
 import java.security.PermissionCollection;
-import com.oracle.dio.utils.ActionFactory;
+import com.oracle.dio.utils.Utils;
 
 /**
  * The {@code GPIOPortPermission} class defines permissions for GPIO port access.
@@ -102,6 +102,6 @@
      * @see #getName getName
      */
     public GPIOPortPermission(String name, String actions) {
-        super(name, ActionFactory.verifyAndOrderActions(actions, DevicePermission.OPEN + "," + DevicePermission.POWER_MANAGE + "," + SET_DIRECTION));
+        super(name, Utils.verifyAndOrderActions(actions, DevicePermission.OPEN + "," + DevicePermission.POWER_MANAGE + "," + SET_DIRECTION));
     }
 }
--- a/src/share/classes/jdk/dio/i2cbus/I2CPermission.java	Thu Jun 18 14:46:23 2015 +0300
+++ b/src/share/classes/jdk/dio/i2cbus/I2CPermission.java	Thu Jun 18 16:40:53 2015 +0300
@@ -28,7 +28,7 @@
 import jdk.dio.DevicePermission;
 import java.security.Permission;
 import java.security.PermissionCollection;
-import com.oracle.dio.utils.ActionFactory;
+import com.oracle.dio.utils.Utils;
 
 /**
  * The {@code I2CPermission} class defines permissions for I2C slave device access.
@@ -95,6 +95,6 @@
      * @see #getName getName
      */
     public I2CPermission(String name, String actions) {
-        super(name, ActionFactory.verifyAndOrderDeviceActions(actions));
+        super(name, Utils.verifyAndOrderDeviceActions(actions));
     }
 }
--- a/src/share/classes/jdk/dio/pwm/PWMPermission.java	Thu Jun 18 14:46:23 2015 +0300
+++ b/src/share/classes/jdk/dio/pwm/PWMPermission.java	Thu Jun 18 16:40:53 2015 +0300
@@ -28,7 +28,7 @@
 import jdk.dio.DevicePermission;
 import java.security.Permission;
 import java.security.PermissionCollection;
-import com.oracle.dio.utils.ActionFactory;
+import com.oracle.dio.utils.Utils;
 
 /**
  * The {@code PWMPermission} class defines permissions for PWM channel access.
@@ -96,7 +96,7 @@
      * @see #getName getName
      */
     public PWMPermission(String name, String actions) {
-        super(name, ActionFactory.verifyAndOrderDeviceActions(actions));
+        super(name, Utils.verifyAndOrderDeviceActions(actions));
     }
 }
 
--- a/src/share/classes/jdk/dio/spibus/SPIPermission.java	Thu Jun 18 14:46:23 2015 +0300
+++ b/src/share/classes/jdk/dio/spibus/SPIPermission.java	Thu Jun 18 16:40:53 2015 +0300
@@ -28,7 +28,7 @@
 import jdk.dio.DevicePermission;
 import java.security.Permission;
 import java.security.PermissionCollection;
-import com.oracle.dio.utils.ActionFactory;
+import com.oracle.dio.utils.Utils;
 
 /**
  * The {@code SPIPermission} class defines permissions for SPI slave device access.
@@ -96,7 +96,7 @@
      * @see #getName getName
      */
     public SPIPermission(String name, String actions) {
-        super(name, ActionFactory.verifyAndOrderDeviceActions(actions));
+        super(name, Utils.verifyAndOrderDeviceActions(actions));
     }
 }
 
--- a/src/share/classes/jdk/dio/uart/UARTConfig.java	Thu Jun 18 14:46:23 2015 +0300
+++ b/src/share/classes/jdk/dio/uart/UARTConfig.java	Thu Jun 18 16:40:53 2015 +0300
@@ -196,13 +196,7 @@
          * @return a new initialized {@code UARTConfig} instance.
          */
         public UARTConfig build() {
-            instance.checkParameters();
-            try {
-                return (UARTConfig)Platform.clone(instance);
-            } catch (IOException e) {
-                Logging.reportWarning(ExceptionMessage.format(ExceptionMessage.CLONE_ERROR));
-                return instance;
-            }
+            return (UARTConfig)Platform.clone(instance);
         }
 
         /**
@@ -608,7 +602,7 @@
      * @since 1.1
      */
     public static UARTConfig deserialize(InputStream in) throws IOException {
-      throw new IOException("Unsupported Operation");
+        return (UARTConfig) Platform.deserialize(in);
     }
 
     /**
@@ -623,7 +617,7 @@
      */
     @Override
     public int serialize(OutputStream out) throws IOException {
-      throw new IOException("Unsupported Operation");
+      return Platform.serialize(this, out);
     }
 
     /**
--- a/src/share/classes/jdk/dio/uart/UARTPermission.java	Thu Jun 18 14:46:23 2015 +0300
+++ b/src/share/classes/jdk/dio/uart/UARTPermission.java	Thu Jun 18 16:40:53 2015 +0300
@@ -28,7 +28,7 @@
 import jdk.dio.DevicePermission;
 import java.security.Permission;
 import java.security.PermissionCollection;
-import com.oracle.dio.utils.ActionFactory;
+import com.oracle.dio.utils.Utils;
 
 
 /**
@@ -97,7 +97,7 @@
      * @see #getName getName
      */
     public UARTPermission(String name, String actions) {
-        super(name, ActionFactory.verifyAndOrderDeviceActions(actions));
+        super(name, Utils.verifyAndOrderDeviceActions(actions));
     }
 }
 
--- a/src/share/classes/jdk/dio/watchdog/WatchdogTimerPermission.java	Thu Jun 18 14:46:23 2015 +0300
+++ b/src/share/classes/jdk/dio/watchdog/WatchdogTimerPermission.java	Thu Jun 18 16:40:53 2015 +0300
@@ -28,7 +28,7 @@
 import jdk.dio.DevicePermission;
 import java.security.Permission;
 import java.security.PermissionCollection;
-import com.oracle.dio.utils.ActionFactory;
+import com.oracle.dio.utils.Utils;
 
 /**
  * The {@code WatchdogTimerPermission} class defines permissions for watchdog timer access.
@@ -97,7 +97,7 @@
      * @see #getName getName
      */
     public WatchdogTimerPermission(String name, String actions) {
-        super(name, ActionFactory.verifyAndOrderDeviceActions(actions));
+        super(name, Utils.verifyAndOrderDeviceActions(actions));
     }
 }