changeset 244:a2d5f52d6175

8133540: api/jdk/dio/DevicePermission test fails Summary: Move verefing and odering actions to DevicePermission; Override construcrots and getActions method in classes where additinaly actions are added Reviewed-by: snazarki Contributed-by: olga.milovskaya@oracle.com
author snazarki
date Wed, 19 Aug 2015 18:42:19 +0300
parents 0820986e0688
children 1eeb2952871d
files src/share/classes/jdk/dio/DevicePermission.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/UARTPermission.java src/share/classes/jdk/dio/watchdog/WatchdogTimerPermission.java
diffstat 13 files changed, 72 insertions(+), 15 deletions(-) [+]
line wrap: on
line diff
--- a/src/share/classes/jdk/dio/DevicePermission.java	Tue Aug 18 17:55:46 2015 +0300
+++ b/src/share/classes/jdk/dio/DevicePermission.java	Wed Aug 19 18:42:19 2015 +0300
@@ -189,7 +189,7 @@
         String[] ret = Utils.parseDevicePermissionName(name);
         thisDevice  = ret[0];
         thisChannel = ret[1];
-        myActions = actions;
+        myActions = Utils.verifyAndOrderDeviceActions(actions);
     }
 
     /**
@@ -254,7 +254,7 @@
      */
     @Override
     public int hashCode() {
-        return (getName() + myActions).hashCode();
+        return (getName() + getActions()).hashCode();
     }
 
     /**
@@ -283,7 +283,7 @@
             return false;
         }
 
-        if (!Utils.implies(myActions, permission.getActions())) {
+        if (!Utils.implies(getActions(), permission.getActions())) {
             return false;
         }
 
--- a/src/share/classes/jdk/dio/adc/ADCPermission.java	Tue Aug 18 17:55:46 2015 +0300
+++ b/src/share/classes/jdk/dio/adc/ADCPermission.java	Wed Aug 19 18:42:19 2015 +0300
@@ -99,7 +99,7 @@
      * @see #getName getName
      */
     public ADCPermission(String name, String actions) {
-        super(name, Utils.verifyAndOrderDeviceActions(actions));
+        super(name, actions);
         Utils.checkDevicePermissionChannelFormat(name, Utils.DECIMAL_DIGITS);
     }
 
--- a/src/share/classes/jdk/dio/atcmd/ATPermission.java	Tue Aug 18 17:55:46 2015 +0300
+++ b/src/share/classes/jdk/dio/atcmd/ATPermission.java	Wed Aug 19 18:42:19 2015 +0300
@@ -24,6 +24,7 @@
  */
 package jdk.dio.atcmd;
 
+import com.oracle.dio.utils.ExceptionMessage;
 import jdk.dio.DeviceManager;
 import jdk.dio.DevicePermission;
 import java.security.Permission;
@@ -69,6 +70,12 @@
      */
     public static final String DATA = "data";
 
+     /**
+     * Coma-separated action list
+     *
+     */
+    private String myActions;
+
     /**
      * Constructs a new {@code ATPermission} with the specified target name and implicit {@code open} action.
      * The target name is normalized so that leading and trailing spaces are removed
@@ -110,7 +117,19 @@
      *             </ul>
      */
     public ATPermission(String name, String actions) {
-        super(name, Utils.verifyAndOrderActions(actions, DevicePermission.OPEN + "," + DATA + "," + DevicePermission.POWER_MANAGE));
+        super(name);
+        myActions = Utils.verifyAndOrderActions(actions, DevicePermission.OPEN + "," + DATA + "," + DevicePermission.POWER_MANAGE);
         Utils.checkDevicePermissionChannelFormat(name, Utils.DECIMAL_DIGITS);
     }
+
+    /**
+     * Returns the list of possible actions in the following order: {@code open}
+     * or {@code powermanage} (additional actions may be defined by subclasses).
+     *
+     * @return comma-separated list of possible actions.
+     */
+    @Override
+    public String getActions() {
+        return myActions;
+    }
 }
--- a/src/share/classes/jdk/dio/counter/CounterPermission.java	Tue Aug 18 17:55:46 2015 +0300
+++ b/src/share/classes/jdk/dio/counter/CounterPermission.java	Wed Aug 19 18:42:19 2015 +0300
@@ -100,7 +100,7 @@
      * @see #getName getName
      */
     public CounterPermission(String name, String actions) {
-        super(name, Utils.verifyAndOrderDeviceActions(actions));
+        super(name, actions);
         Utils.checkDevicePermissionChannelFormat(name, Utils.DECIMAL_DIGITS);
     }
 }
--- a/src/share/classes/jdk/dio/dac/DACPermission.java	Tue Aug 18 17:55:46 2015 +0300
+++ b/src/share/classes/jdk/dio/dac/DACPermission.java	Wed Aug 19 18:42:19 2015 +0300
@@ -100,7 +100,7 @@
      * @see #getName getName
      */
     public DACPermission(String name, String actions) {
-        super(name, Utils.verifyAndOrderDeviceActions(actions));
+        super(name, actions);
         Utils.checkDevicePermissionChannelFormat(name, Utils.DECIMAL_DIGITS);
     }
 }
--- a/src/share/classes/jdk/dio/generic/GenericPermission.java	Tue Aug 18 17:55:46 2015 +0300
+++ b/src/share/classes/jdk/dio/generic/GenericPermission.java	Wed Aug 19 18:42:19 2015 +0300
@@ -98,7 +98,7 @@
      * @see #getName getName
      */
     public GenericPermission(String name, String actions) {
-        super(name, Utils.verifyAndOrderDeviceActions(actions));
+        super(name, actions);
         Utils.checkDevicePermissionChannelFormat(name, Utils.DECIMAL_DIGITS);
     }
 }
--- a/src/share/classes/jdk/dio/gpio/GPIOPinPermission.java	Tue Aug 18 17:55:46 2015 +0300
+++ b/src/share/classes/jdk/dio/gpio/GPIOPinPermission.java	Wed Aug 19 18:42:19 2015 +0300
@@ -24,6 +24,7 @@
  */
 package jdk.dio.gpio;
 
+import com.oracle.dio.utils.ExceptionMessage;
 import jdk.dio.DeviceManager;
 import jdk.dio.DevicePermission;
 import java.security.Permission;
@@ -69,6 +70,12 @@
     public static final String SET_DIRECTION = "setdirection";
 
     /**
+     * Coma-separated action list
+     *
+     */
+    private String myActions;
+
+    /**
      * Constructs a new {@code GPIOPinPermission} with the specified target name and the implicit
      * {@code open} action.
      * The target name is normalized so that leading and trailing spaces are removed
@@ -111,7 +118,19 @@
      * @see #getName getName
      */
     public GPIOPinPermission(String name, String actions) {
-        super(name, Utils.verifyAndOrderActions(actions, DevicePermission.OPEN + "," + DevicePermission.POWER_MANAGE + "," + SET_DIRECTION));
+        super(name);
+        myActions = Utils.verifyAndOrderActions(actions, DevicePermission.OPEN + "," + DevicePermission.POWER_MANAGE + "," + SET_DIRECTION);
         Utils.checkDevicePermissionChannelFormat(name, Utils.DECIMAL_DIGITS);
     }
+
+    /**
+     * Returns the list of possible actions in the following order: {@code open}
+     * or {@code powermanage} (additional actions may be defined by subclasses).
+     *
+     * @return comma-separated list of possible actions.
+     */
+    @Override
+    public String getActions() {
+        return myActions;
+    }
 }
--- a/src/share/classes/jdk/dio/gpio/GPIOPortPermission.java	Tue Aug 18 17:55:46 2015 +0300
+++ b/src/share/classes/jdk/dio/gpio/GPIOPortPermission.java	Wed Aug 19 18:42:19 2015 +0300
@@ -24,6 +24,7 @@
  */
 package jdk.dio.gpio;
 
+import com.oracle.dio.utils.ExceptionMessage;
 import jdk.dio.DeviceManager;
 import jdk.dio.DevicePermission;
 import java.security.Permission;
@@ -66,6 +67,12 @@
      */
     public static final String SET_DIRECTION = "setdirection";
 
+     /**
+     * Coma-separated action list
+     *
+     */
+    private String myActions;
+
     /**
      * Constructs a new {@code GPIOPortPermission} with the specified target name and the implicit
      * {@code open} action.
@@ -109,7 +116,19 @@
      * @see #getName getName
      */
     public GPIOPortPermission(String name, String actions) {
-        super(name, Utils.verifyAndOrderActions(actions, DevicePermission.OPEN + "," + DevicePermission.POWER_MANAGE + "," + SET_DIRECTION));
+        super(name);
+        myActions = Utils.verifyAndOrderActions(actions, DevicePermission.OPEN + "," + DevicePermission.POWER_MANAGE + "," + SET_DIRECTION);
         Utils.checkDevicePermissionChannelFormat(name, Utils.EMPTY);
     }
+
+    /**
+     * Returns the list of possible actions in the following order: {@code open}
+     * or {@code powermanage} (additional actions may be defined by subclasses).
+     *
+     * @return comma-separated list of possible actions.
+     */
+    @Override
+    public String getActions() {
+        return myActions;
+    }
 }
--- a/src/share/classes/jdk/dio/i2cbus/I2CPermission.java	Tue Aug 18 17:55:46 2015 +0300
+++ b/src/share/classes/jdk/dio/i2cbus/I2CPermission.java	Wed Aug 19 18:42:19 2015 +0300
@@ -100,7 +100,7 @@
      * @see #getName getName
      */
     public I2CPermission(String name, String actions) {
-        super(name, Utils.verifyAndOrderDeviceActions(actions));
+        super(name, actions);
         Utils.checkDevicePermissionChannelFormat(name, Utils.HEXADECIMAL_DIGITS);
     }
 }
--- a/src/share/classes/jdk/dio/pwm/PWMPermission.java	Tue Aug 18 17:55:46 2015 +0300
+++ b/src/share/classes/jdk/dio/pwm/PWMPermission.java	Wed Aug 19 18:42:19 2015 +0300
@@ -101,7 +101,7 @@
      * @see #getName getName
      */
     public PWMPermission(String name, String actions) {
-        super(name, Utils.verifyAndOrderDeviceActions(actions));
+        super(name, actions);
         Utils.checkDevicePermissionChannelFormat(name, Utils.DECIMAL_DIGITS);
     }
 }
--- a/src/share/classes/jdk/dio/spibus/SPIPermission.java	Tue Aug 18 17:55:46 2015 +0300
+++ b/src/share/classes/jdk/dio/spibus/SPIPermission.java	Wed Aug 19 18:42:19 2015 +0300
@@ -101,7 +101,7 @@
      * @see #getName getName
      */
     public SPIPermission(String name, String actions) {
-        super(name, Utils.verifyAndOrderDeviceActions(actions));
+        super(name, actions);
        Utils.checkDevicePermissionChannelFormat(name, Utils.HEXADECIMAL_DIGITS);
     }
 }
--- a/src/share/classes/jdk/dio/uart/UARTPermission.java	Tue Aug 18 17:55:46 2015 +0300
+++ b/src/share/classes/jdk/dio/uart/UARTPermission.java	Wed Aug 19 18:42:19 2015 +0300
@@ -102,7 +102,7 @@
      * @see #getName getName
      */
     public UARTPermission(String name, String actions) {
-        super(name, Utils.verifyAndOrderDeviceActions(actions));
+        super(name, actions);
         Utils.checkDevicePermissionChannelFormat(name, Utils.DECIMAL_DIGITS);
     }
 }
--- a/src/share/classes/jdk/dio/watchdog/WatchdogTimerPermission.java	Tue Aug 18 17:55:46 2015 +0300
+++ b/src/share/classes/jdk/dio/watchdog/WatchdogTimerPermission.java	Wed Aug 19 18:42:19 2015 +0300
@@ -101,7 +101,7 @@
      * @see #getName getName
      */
     public WatchdogTimerPermission(String name, String actions) {
-        super(name, Utils.verifyAndOrderDeviceActions(actions));
+        super(name, actions);
         Utils.checkDevicePermissionChannelFormat(name, Utils.DECIMAL_DIGITS);
     }
 }