changeset 160:aa7d1593f97f

8079602: Reduce code size by refactoring of DeviceConfig.equals() method Summary: Introduced Platfroms.equals method that has to instances comparison Reviewed-by: alkonsta
author snazarki
date Thu, 07 May 2015 15:09:42 +0300
parents 5d161bfcaf7a
children 1b2e8cfd44d1
files src/se/classes/com/oracle/dio/impl/Platform.java src/share/classes/jdk/dio/adc/ADCChannelConfig.java src/share/classes/jdk/dio/counter/PulseCounterConfig.java src/share/classes/jdk/dio/dac/DACChannelConfig.java src/share/classes/jdk/dio/generic/GenericDeviceConfig.java src/share/classes/jdk/dio/gpio/GPIOPinConfig.java src/share/classes/jdk/dio/gpio/GPIOPortConfig.java src/share/classes/jdk/dio/i2cbus/I2CDeviceConfig.java src/share/classes/jdk/dio/pwm/PWMChannelConfig.java src/share/classes/jdk/dio/spibus/SPIDeviceConfig.java src/share/classes/jdk/dio/uart/UARTConfig.java
diffstat 11 files changed, 82 insertions(+), 291 deletions(-) [+]
line wrap: on
line diff
--- a/src/se/classes/com/oracle/dio/impl/Platform.java	Tue May 05 13:56:51 2015 +0300
+++ b/src/se/classes/com/oracle/dio/impl/Platform.java	Thu May 07 15:09:42 2015 +0300
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2013, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2013, 2015, 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
@@ -26,6 +26,7 @@
 
 import java.security.AccessController;
 import java.security.PrivilegedAction;
+import java.util.Objects;
 
 public final class Platform {
     /** Don't let anyone instantiate this class */
@@ -43,4 +44,25 @@
                 }
             });
     }
+
+    /**
+     * Compare two objects by recursive inspection of their fields.
+     *
+     * @param obj1 first object to compare
+     * @param obj2 second object to compare
+     *
+     * @return true if objects classes are the same and all objects
+     *         members are equals.
+     *
+     * @note unimplemented
+     */
+    public static boolean equals(Object obj1, Object obj2) {
+        if (null == obj1 || null == obj2) {
+            return false;
+        }
+        if (obj1.getClass() != obj2.getClass()) {
+            return false;
+        }
+        return Objects.equals(obj1, obj2);
+    }
 }
--- a/src/share/classes/jdk/dio/adc/ADCChannelConfig.java	Tue May 05 13:56:51 2015 +0300
+++ b/src/share/classes/jdk/dio/adc/ADCChannelConfig.java	Thu May 07 15:09:42 2015 +0300
@@ -24,11 +24,14 @@
  */
 package jdk.dio.adc;
 
+import java.io.ByteArrayOutputStream;
 import java.io.IOException;
 import java.io.InputStream;
 import java.io.OutputStream;
 import java.util.Objects;
 
+import com.oracle.dio.impl.Platform;
+
 import jdk.dio.DeviceConfig;
 import jdk.dio.DeviceManager;
 import jdk.dio.InvalidDeviceConfigException;
@@ -70,7 +73,7 @@
     private int resolution = UNASSIGNED;
     private int samplingInterval = UNASSIGNED;
     private int samplingTime = UNASSIGNED;
-    private double scaleFactor = 1.0;
+    private Double scaleFactor = 1.0;
     private int inputBufferSize = UNASSIGNED;
 
     /**
@@ -268,6 +271,7 @@
      * </ul>
      * @deprecated As of 1.1, use {@link Builder} instead.
      */
+    @Deprecated
     public ADCChannelConfig(int controllerNumber, int channelNumber, int resolution, int samplingInterval, int samplingTime) {
         this.controllerNumber = controllerNumber;
         this.channelNumber = channelNumber;
@@ -306,6 +310,7 @@
      * @throws NullPointerException if {@code controllerName} is {@code null}.
      * @deprecated As of 1.1, use {@link Builder} instead.
      */
+    @Deprecated
     public ADCChannelConfig(String controllerName, int channelNumber, int resolution, int samplingInterval, int samplingTime) {
         this.controllerName = controllerName;
         this.channelNumber = channelNumber;
@@ -474,35 +479,7 @@
      */
     @Override
     public boolean equals(Object obj) {
-        if (obj == null) {
-            return false;
-        }
-        if (getClass() != obj.getClass()) {
-            return false;
-        }
-        final ADCChannelConfig other = (ADCChannelConfig) obj;
-        if (!Objects.equals(this.controllerName, other.controllerName)) {
-            return false;
-        }
-        if (this.channelNumber != other.channelNumber) {
-            return false;
-        }
-        if (this.controllerNumber != other.controllerNumber) {
-            return false;
-        }
-        if (this.resolution != other.resolution) {
-            return false;
-        }
-        if (this.samplingInterval != other.samplingInterval) {
-            return false;
-        }
-        if (this.samplingTime != other.samplingTime) {
-            return false;
-        }
-        if (Double.doubleToLongBits(this.scaleFactor) != Double.doubleToLongBits(other.scaleFactor)) {
-            return false;
-        }
-        return this.inputBufferSize == other.inputBufferSize;
+        return Platform.equals(this, obj);
     }
 
     private void checkValues() throws IllegalArgumentException {
--- a/src/share/classes/jdk/dio/counter/PulseCounterConfig.java	Tue May 05 13:56:51 2015 +0300
+++ b/src/share/classes/jdk/dio/counter/PulseCounterConfig.java	Thu May 07 15:09:42 2015 +0300
@@ -29,6 +29,7 @@
 import java.io.OutputStream;
 import java.util.Objects;
 
+import com.oracle.dio.impl.Platform;
 import com.oracle.dio.utils.ExceptionMessage;
 
 import jdk.dio.DeviceConfig;
@@ -258,6 +259,7 @@
      *
      * @deprecated As of 1.1, use {@link Builder} instead.
      */
+    @Deprecated
     public PulseCounterConfig(int controllerNumber, int channelNumber, int type) {
         this.controllerNumber = controllerNumber;
         this.channelNumber = channelNumber;
@@ -295,6 +297,7 @@
      *
      * @deprecated As of 1.1, use {@link Builder} instead.
      */
+    @Deprecated
     public PulseCounterConfig(int controllerNumber, int channelNumber, int type, GPIOPinConfig source) {
         this.controllerNumber = controllerNumber;
         this.channelNumber = channelNumber;
@@ -328,6 +331,7 @@
      *
      * @deprecated As of 1.1, use {@link Builder} instead.
      */
+    @Deprecated
     public PulseCounterConfig(String controllerName, int channelNumber, int type) {
         // checks for null
         controllerName.length();
@@ -366,6 +370,7 @@
      *
      * @deprecated As of 1.1, use {@link Builder} instead.
      */
+    @Deprecated
     public PulseCounterConfig(String controllerName, int channelNumber, int type, GPIOPinConfig source) {
         // checks for null
         controllerName.length();
@@ -451,6 +456,7 @@
      *
      * @deprecated As of 1.1, replaced by {@link PulseCounter#getSource PulseCounter.getSource}.
      */
+    @Deprecated
     public GPIOPin getSource() {
         return null;
     }
@@ -504,26 +510,7 @@
      */
     @Override
     public boolean equals(Object obj) {
-        if (obj == null) {
-            return false;
-        }
-        if (getClass() != obj.getClass()) {
-            return false;
-        }
-        final PulseCounterConfig other = (PulseCounterConfig) obj;
-        if (!Objects.equals(this.controllerName, other.controllerName)) {
-            return false;
-        }
-        if (this.controllerNumber != other.controllerNumber) {
-            return false;
-        }
-        if (this.channelNumber != other.channelNumber) {
-            return false;
-        }
-        if (!Objects.equals(this.sourceConfig, other.sourceConfig)) {
-            return false;
-        }
-        return this.type == other.type;
+        return Platform.equals(this, obj);
     }
 
     private void checkValues() throws IllegalArgumentException {
--- a/src/share/classes/jdk/dio/dac/DACChannelConfig.java	Tue May 05 13:56:51 2015 +0300
+++ b/src/share/classes/jdk/dio/dac/DACChannelConfig.java	Thu May 07 15:09:42 2015 +0300
@@ -30,6 +30,8 @@
 import java.io.OutputStream;
 import java.util.Objects;
 
+import com.oracle.dio.impl.Platform;
+
 import jdk.dio.DeviceConfig;
 import jdk.dio.DeviceManager;
 import jdk.dio.InvalidDeviceConfigException;
@@ -246,6 +248,7 @@
      *
      * @deprecated As of 1.1, use {@link Builder} instead.
      */
+    @Deprecated
     public DACChannelConfig(int controllerNumber, int channelNumber, int resolution, int samplingInterval) {
         this.controllerNumber = controllerNumber;
         this.channelNumber = channelNumber;
@@ -281,6 +284,7 @@
      *
      * @deprecated As of 1.1, use {@link Builder} instead.
      */
+    @Deprecated
     public DACChannelConfig(String controllerName, int channelNumber, int resolution, int samplingInterval) {
         this.controllerName = controllerName;
         this.channelNumber = channelNumber;
@@ -430,32 +434,7 @@
      */
     @Override
     public boolean equals(Object obj) {
-        if (obj == null) {
-            return false;
-        }
-        if (getClass() != obj.getClass()) {
-            return false;
-        }
-        final DACChannelConfig other = (DACChannelConfig) obj;
-        if (!Objects.equals(this.controllerName, other.controllerName)) {
-            return false;
-        }
-        if (this.channelNumber != other.channelNumber) {
-            return false;
-        }
-        if (this.controllerNumber != other.controllerNumber) {
-            return false;
-        }
-        if (this.resolution != other.resolution) {
-            return false;
-        }
-        if (this.samplingInterval != other.samplingInterval) {
-            return false;
-        }
-        if (Double.doubleToLongBits(this.scaleFactor) != Double.doubleToLongBits(other.scaleFactor)) {
-            return false;
-        }
-        return this.outputBufferSize == other.outputBufferSize;
+        return Platform.equals(this, obj);
     }
 
     private void checkValues() {
--- a/src/share/classes/jdk/dio/generic/GenericDeviceConfig.java	Tue May 05 13:56:51 2015 +0300
+++ b/src/share/classes/jdk/dio/generic/GenericDeviceConfig.java	Thu May 07 15:09:42 2015 +0300
@@ -29,6 +29,8 @@
 import java.io.OutputStream;
 import java.util.Objects;
 
+import com.oracle.dio.impl.Platform;
+
 import jdk.dio.DeviceConfig;
 import jdk.dio.DeviceManager;
 import jdk.dio.InvalidDeviceConfigException;
@@ -107,7 +109,7 @@
          */
         public GenericDeviceConfig build() {
             return instance;
-       }
+        }
 
         /**
          * Sets the controller name (default value is {@code null} if not set).
@@ -184,16 +186,6 @@
         }
     }
 
-    private GenericDeviceConfig(GenericDeviceConfig prototype) {
-        if (prototype != null) {
-            this.controllerName = prototype.controllerName;
-            this.channelNumber = prototype.channelNumber;
-            this.controllerNumber = prototype.controllerNumber;
-            this.inputBufferSize = prototype.inputBufferSize;
-            this.outputBufferSize = prototype.outputBufferSize;
-        }
-    }
-
     // hidden constructor for serializer
     @DontRenameMethod
     GenericDeviceConfig(){}
@@ -215,6 +207,7 @@
      *
      * @deprecated As of 1.1, use {@link Builder} instead.
      */
+    @Deprecated
     public GenericDeviceConfig(int controllerNumber, int channelNumber) {
         if (controllerNumber< DEFAULT || channelNumber < DEFAULT) {
             throw new IllegalArgumentException();
@@ -237,6 +230,7 @@
      *
      * @deprecated As of 1.1, use {@link Builder} instead.
      */
+    @Deprecated
     public GenericDeviceConfig(String controllerName, int channelNumber) {
         this.controllerName = controllerName;
         this.channelNumber = channelNumber;
@@ -361,19 +355,6 @@
      */
     @Override
     public boolean equals(Object obj) {
-        if (obj == null) {
-            return false;
-        }
-        if (getClass() != obj.getClass()) {
-            return false;
-        }
-        final GenericDeviceConfig other = (GenericDeviceConfig) obj;
-        if (!Objects.equals(this.controllerName, other.controllerName)) {
-            return false;
-        }
-        if (this.channelNumber != other.channelNumber) {
-            return false;
-        }
-        return this.controllerNumber == other.controllerNumber;
+        return Platform.equals(this, obj);
     }
 }
--- a/src/share/classes/jdk/dio/gpio/GPIOPinConfig.java	Tue May 05 13:56:51 2015 +0300
+++ b/src/share/classes/jdk/dio/gpio/GPIOPinConfig.java	Thu May 07 15:09:42 2015 +0300
@@ -29,6 +29,7 @@
 import java.io.OutputStream;
 import java.util.Objects;
 
+import com.oracle.dio.impl.Platform;
 import com.oracle.dio.utils.ExceptionMessage;
 
 import jdk.dio.DeviceConfig;
@@ -356,6 +357,7 @@
      *
      * @deprecated As of 1.1, use {@link Builder} instead.
      */
+    @Deprecated
     public GPIOPinConfig(int controllerNumber, int pinNumber, int direction, int mode, int trigger, boolean initValue) {
         this.controllerNumber = controllerNumber;
         this.pinNumber = pinNumber;
@@ -412,6 +414,7 @@
      *
      * @deprecated As of 1.1, use {@link Builder} instead.
      */
+    @Deprecated
     public GPIOPinConfig(String controllerName, int pinNumber, int direction, int mode, int trigger, boolean initValue) {
         this.controllerName = controllerName;
         this.pinNumber = pinNumber;
@@ -558,32 +561,7 @@
      */
     @Override
     public boolean equals(Object obj) {
-        if (obj == null) {
-            return false;
-        }
-        if (getClass() != obj.getClass()) {
-            return false;
-        }
-        final GPIOPinConfig other = (GPIOPinConfig) obj;
-        if (!Objects.equals(this.controllerName, other.controllerName)) {
-            return false;
-        }
-        if (this.direction != other.direction) {
-            return false;
-        }
-        if (this.initValue != other.initValue) {
-            return false;
-        }
-        if (this.mode != other.mode) {
-            return false;
-        }
-        if (this.pinNumber != other.pinNumber) {
-            return false;
-        }
-        if (this.controllerNumber != other.controllerNumber) {
-            return false;
-        }
-        return this.trigger == other.trigger;
+        return Platform.equals(this, obj);
     }
 
     private void checkValues() {
--- a/src/share/classes/jdk/dio/gpio/GPIOPortConfig.java	Tue May 05 13:56:51 2015 +0300
+++ b/src/share/classes/jdk/dio/gpio/GPIOPortConfig.java	Thu May 07 15:09:42 2015 +0300
@@ -30,6 +30,7 @@
 import java.util.Arrays;
 import java.util.Objects;
 
+import com.oracle.dio.impl.Platform;
 import com.oracle.dio.utils.ExceptionMessage;
 
 import jdk.dio.DeviceConfig;
@@ -233,6 +234,7 @@
      *
      * @deprecated As of 1.1, replaced by {@link GPIOPort#getPins GPIOPort.getPins}.
      */
+    @Deprecated
     public GPIOPin[] getPins() {
         return null;
     }
@@ -263,20 +265,7 @@
      */
     @Override
     public boolean equals(Object obj) {
-        if (obj == null) {
-            return false;
-        }
-        if (getClass() != obj.getClass()) {
-            return false;
-        }
-        final GPIOPortConfig other = (GPIOPortConfig) obj;
-        if (this.direction != other.direction) {
-            return false;
-        }
-        if (this.initValue != other.initValue) {
-            return false;
-        }
-        return Arrays.equals(this.pinConfigs, other.pinConfigs);
+        return Platform.equals(this, obj);
     }
 
 }
--- a/src/share/classes/jdk/dio/i2cbus/I2CDeviceConfig.java	Tue May 05 13:56:51 2015 +0300
+++ b/src/share/classes/jdk/dio/i2cbus/I2CDeviceConfig.java	Thu May 07 15:09:42 2015 +0300
@@ -29,6 +29,8 @@
 import java.io.OutputStream;
 import java.util.Objects;
 
+import com.oracle.dio.impl.Platform;
+
 import jdk.dio.DeviceConfig;
 import jdk.dio.DeviceManager;
 import jdk.dio.InvalidDeviceConfigException;
@@ -251,6 +253,7 @@
      *
      * @deprecated As of 1.1, use {@link Builder} instead.
      */
+    @Deprecated
     public I2CDeviceConfig(int controllerNumber, int address, int addressSize, int clockFrequency) {
         this.controllerNumber = controllerNumber;
         this.address = address;
@@ -285,6 +288,7 @@
      *
      * @deprecated As of 1.1, use {@link Builder} instead.
      */
+    @Deprecated
     public I2CDeviceConfig(String controllerName, int address, int addressSize, int clockFrequency) {
         this.controllerName = controllerName;
         this.address = address;
@@ -432,26 +436,7 @@
      */
     @Override
     public boolean equals(Object obj) {
-        if (obj == null) {
-            return false;
-        }
-        if (getClass() != obj.getClass()) {
-            return false;
-        }
-        final I2CDeviceConfig other = (I2CDeviceConfig) obj;
-        if (!Objects.equals(this.controllerName, other.controllerName)) {
-            return false;
-        }
-        if (this.address != other.address) {
-            return false;
-        }
-        if (this.addressSize != other.addressSize) {
-            return false;
-        }
-        if (this.controllerNumber != other.controllerNumber) {
-            return false;
-        }
-        return this.clockFrequency == other.clockFrequency;
+        return Platform.equals(this, obj);
     }
 
     private void checkValues() {
--- a/src/share/classes/jdk/dio/pwm/PWMChannelConfig.java	Tue May 05 13:56:51 2015 +0300
+++ b/src/share/classes/jdk/dio/pwm/PWMChannelConfig.java	Thu May 07 15:09:42 2015 +0300
@@ -29,6 +29,7 @@
 import java.io.OutputStream;
 import java.util.Objects;
 
+import com.oracle.dio.impl.Platform;
 import com.oracle.dio.utils.ExceptionMessage;
 
 import jdk.dio.DeviceConfig;
@@ -302,6 +303,7 @@
      *
      * @deprecated As of 1.1, use {@link Builder} instead.
      */
+    @Deprecated
     public PWMChannelConfig(int controllerNumber, int channelNumber, int idleState, int pulsePeriod, int pulseAlignment) {
         this.controllerNumber = controllerNumber;
         this.channelNumber = channelNumber;
@@ -351,6 +353,7 @@
      *
      * @deprecated As of 1.1, use {@link Builder} instead.
      */
+    @Deprecated
     public PWMChannelConfig(int controllerNumber, int channelNumber, int idleState, int pulsePeriod,
             int pulseAlignment, GPIOPinConfig output) {
         // checks for null as well
@@ -400,6 +403,7 @@
      *
      * @deprecated As of 1.1, use {@link Builder} instead.
      */
+    @Deprecated
     public PWMChannelConfig(String controllerName, int channelNumber, int idleState, int pulsePeriod, int pulseAlignment) {
         this(DEFAULT, channelNumber, idleState, pulsePeriod, pulseAlignment);
         // null check
@@ -446,6 +450,7 @@
      *
      * @deprecated As of 1.1, use {@link Builder} instead.
      */
+    @Deprecated
     public PWMChannelConfig(String controllerName, int channelNumber, int idleState, int pulsePeriod,
             int pulseAlignment, GPIOPinConfig output) {
        this(DEFAULT, channelNumber, idleState, pulsePeriod, pulseAlignment, output);
@@ -560,6 +565,7 @@
      *
      * @deprecated As of 1.1, replaced by {@link PWMChannel#getOutput PWMChannel.getOutput}.
      */
+    @Deprecated
     public GPIOPin getOutput() {
         return null;
     }
@@ -634,37 +640,6 @@
      */
     @Override
     public boolean equals(Object obj) {
-        if (obj == null) {
-            return false;
-        }
-        if (getClass() != obj.getClass()) {
-            return false;
-        }
-        final PWMChannelConfig other = (PWMChannelConfig) obj;
-        if (!Objects.equals(this.controllerName, other.controllerName)) {
-            return false;
-        }
-        if (this.channelNumber != other.channelNumber) {
-            return false;
-        }
-        if (this.controllerNumber != other.controllerNumber) {
-            return false;
-        }
-        if (!Objects.equals(this.outputConfig, other.outputConfig)) {
-            return false;
-        }
-        if (this.idleState != other.idleState) {
-            return false;
-        }
-        if (this.pulsePeriod != other.pulsePeriod) {
-            return false;
-        }
-        if (Double.doubleToLongBits(this.scaleFactor) != Double.doubleToLongBits(other.scaleFactor)) {
-            return false;
-        }
-        if (this.pulseAlignment != other.pulseAlignment) {
-            return false;
-        }
-        return this.outputBufferSize == other.outputBufferSize;
+        return Platform.equals(this, obj);
     }
 }
--- a/src/share/classes/jdk/dio/spibus/SPIDeviceConfig.java	Tue May 05 13:56:51 2015 +0300
+++ b/src/share/classes/jdk/dio/spibus/SPIDeviceConfig.java	Thu May 07 15:09:42 2015 +0300
@@ -29,6 +29,8 @@
 import java.io.OutputStream;
 import java.util.Objects;
 
+import com.oracle.dio.impl.Platform;
+
 import jdk.dio.DeviceConfig;
 import jdk.dio.DeviceManager;
 import jdk.dio.InvalidDeviceConfigException;
@@ -321,21 +323,6 @@
         }
     }
 
-    private SPIDeviceConfig(SPIDeviceConfig prototype) {
-        if (prototype != null) {
-            this.controllerName = prototype.controllerName;
-            this.address = prototype.address;
-            this.controllerNumber = prototype.controllerNumber;
-            this.csActive = prototype.csActive;
-            this.clockFrequency = prototype.clockFrequency;
-            this.clockMode = prototype.clockMode;
-            this.bitOrdering = prototype.bitOrdering;
-            this.wordLength = prototype.wordLength;
-            this.inputBufferSize = prototype.inputBufferSize;
-            this.outputBufferSize = prototype.outputBufferSize;
-        }
-    }
-
     // hidden constructor for serializer
     @DontRenameMethod
     SPIDeviceConfig(){}
@@ -372,6 +359,7 @@
      *
      * @deprecated As of 1.1, use {@link Builder} instead.
      */
+    @Deprecated
     public SPIDeviceConfig(int controllerNumber, int address, int clockFrequency, int clockMode, int wordLength,
             int bitOrdering) {
         this(controllerNumber, address, DEFAULT, clockFrequency, clockMode, wordLength, bitOrdering);
@@ -412,6 +400,7 @@
      *
      * @deprecated As of 1.1, use {@link Builder} instead.
      */
+    @Deprecated
     public SPIDeviceConfig(int controllerNumber, int address, int csActive, int clockFrequency, int clockMode, int wordLength,
             int bitOrdering) {
         this.controllerNumber = controllerNumber;
@@ -456,6 +445,7 @@
      *
      * @deprecated As of 1.1, use {@link Builder} instead.
      */
+    @Deprecated
     public SPIDeviceConfig(String controllerName, int address, int clockFrequency, int clockMode, int wordLength,
             int bitOrdering) {
         this(controllerName, address, DEFAULT, clockFrequency, clockMode, wordLength, bitOrdering);
@@ -496,6 +486,7 @@
      *
      * @deprecated As of 1.1, use {@link Builder} instead.
      */
+    @Deprecated
     public SPIDeviceConfig(String controllerName, int address, int csActive, int clockFrequency, int clockMode, int wordLength,
             int bitOrdering) {
         // checks for null
@@ -679,35 +670,7 @@
      */
     @Override
     public boolean equals(Object obj) {
-        if (obj == null) {
-            return false;
-        }
-        if (getClass() != obj.getClass()) {
-            return false;
-        }
-        final SPIDeviceConfig other = (SPIDeviceConfig) obj;
-        if (!Objects.equals(this.controllerName, other.controllerName)) {
-            return false;
-        }
-        if (this.address != other.address) {
-            return false;
-        }
-        if (this.controllerNumber != other.controllerNumber) {
-            return false;
-        }
-        if (this.bitOrdering != other.bitOrdering) {
-            return false;
-        }
-        if (this.clockFrequency != other.clockFrequency) {
-            return false;
-        }
-        if (this.clockMode != other.clockMode) {
-            return false;
-        }
-        if (this.csActive != other.csActive) {
-            return false;
-        }
-        return this.wordLength == other.wordLength;
+        return Platform.equals(this, obj);
     }
 
     private void checkParameters(){
--- a/src/share/classes/jdk/dio/uart/UARTConfig.java	Tue May 05 13:56:51 2015 +0300
+++ b/src/share/classes/jdk/dio/uart/UARTConfig.java	Thu May 07 15:09:42 2015 +0300
@@ -29,6 +29,8 @@
 import java.io.OutputStream;
 import java.util.Objects;
 
+import com.oracle.dio.impl.Platform;
+
 import jdk.dio.DeviceConfig;
 import jdk.dio.DeviceManager;
 import jdk.dio.InvalidDeviceConfigException;
@@ -146,7 +148,7 @@
     private int channelNumber = UNASSIGNED;
     private int controllerNumber = UNASSIGNED;
     private int baudRate = 9600;
-    private int dataBits = DATABITS_9;
+    private int dataBits = DATABITS_8;
     private int flowcontrol; // none
     private int inputBufferSize = UNASSIGNED;
     private int outputBufferSize = UNASSIGNED;
@@ -345,23 +347,6 @@
         }
     }
 
-    private UARTConfig(UARTConfig prototype) {
-        if (prototype != null) {
-            this.controllerName = prototype.controllerName;
-            this.channelNumber = prototype.channelNumber;
-            this.controllerNumber = prototype.controllerNumber;
-            this.baudRate = prototype.baudRate;
-            this.dataBits = prototype.dataBits;
-            this.stopBits = prototype.stopBits;
-            this.parity = prototype.parity;
-            this.flowcontrol = prototype.flowcontrol;
-            this.inputBufferSize = prototype.inputBufferSize;
-            this.outputBufferSize = prototype.outputBufferSize;
-        }
-    }
-
-
-
     // hidden constructor for serializer
     @DontRenameMethod
     UARTConfig() {}
@@ -403,6 +388,7 @@
      *
      * @deprecated As of 1.1, use {@link Builder} instead.
      */
+    @Deprecated
     public UARTConfig(int controllerNumber, int channelNumber, int baudRate, int dataBits, int parity, int stopBits, int flowcontrol) {
         this(controllerNumber, channelNumber, baudRate, dataBits, parity, stopBits, flowcontrol, DEFAULT, DEFAULT);
     }
@@ -451,6 +437,7 @@
      *
      * @deprecated As of 1.1, use {@link Builder} instead.
      */
+    @Deprecated
     public UARTConfig(int controllerNumber, int channelNumber, int baudRate, int dataBits, int parity, int stopBits, int flowcontrol,
             int inputBufferSize, int outputBufferSize) {
         this.controllerNumber = controllerNumber;
@@ -503,6 +490,7 @@
      *
      * @deprecated As of 1.1, use {@link Builder} instead.
      */
+    @Deprecated
     public UARTConfig(String controllerName, int channelNumber, int baudRate, int dataBits, int parity, int stopBits, int flowcontrol) {
         this(controllerName, channelNumber, baudRate, dataBits, parity, stopBits, flowcontrol, DEFAULT, DEFAULT);
     }
@@ -552,6 +540,7 @@
      *
      * @deprecated As of 1.1, use {@link Builder} instead.
      */
+    @Deprecated
     public UARTConfig(String controllerName, int channelNumber, int baudRate, int dataBits, int parity, int stopBits, int flowcontrol,
             int inputBufferSize, int outputBufferSize) {
         this.controllerName = controllerName;
@@ -752,40 +741,6 @@
      */
     @Override
     public boolean equals(Object obj) {
-        if (obj == null) {
-            return false;
-        }
-        if (getClass() != obj.getClass()) {
-            return false;
-        }
-        final UARTConfig other = (UARTConfig) obj;
-        if (!Objects.equals(this.controllerName, other.controllerName)) {
-            return false;
-        }
-        if (this.channelNumber != other.channelNumber) {
-            return false;
-        }
-        if (this.controllerNumber != other.controllerNumber) {
-            return false;
-        }
-        if (this.baudRate != other.baudRate) {
-            return false;
-        }
-        if (this.dataBits != other.dataBits) {
-            return false;
-        }
-        if (this.flowcontrol != other.flowcontrol) {
-            return false;
-        }
-        if (this.inputBufferSize != other.inputBufferSize) {
-            return false;
-        }
-        if (this.outputBufferSize != other.outputBufferSize) {
-            return false;
-        }
-        if (this.parity != other.parity) {
-            return false;
-        }
-        return this.stopBits == other.stopBits;
+        return Platform.equals(this, obj);
     }
 }