db-derby-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From kahat...@apache.org
Subject svn commit: r1485676 - in /db/derby/code/trunk/java/engine/org/apache/derby: iapi/services/io/ iapi/sql/dictionary/ impl/jdbc/ impl/sql/ impl/sql/execute/ impl/sql/execute/rts/
Date Thu, 23 May 2013 12:56:46 GMT
Author: kahatlen
Date: Thu May 23 12:56:45 2013
New Revision: 1485676

URL: http://svn.apache.org/r1485676
Log:
DERBY-5840: Clean up compiler warnings introduced by using Java 5 language features

- Make ArrayUtil.asReadOnlyList() use checked conversions and remove
  SuppressWarnings annotation

- Generify the signature of ArrayUtil.copy(Object[]), remove the now
  redundant copy(String[]) overload, and remove the now redundant
  casts in many of the call sites

Modified:
    db/derby/code/trunk/java/engine/org/apache/derby/iapi/services/io/ArrayUtil.java
    db/derby/code/trunk/java/engine/org/apache/derby/iapi/sql/dictionary/IndexLister.java
    db/derby/code/trunk/java/engine/org/apache/derby/iapi/sql/dictionary/SPSDescriptor.java
    db/derby/code/trunk/java/engine/org/apache/derby/impl/jdbc/EmbedResultSetMetaData.java
    db/derby/code/trunk/java/engine/org/apache/derby/impl/sql/GenericPreparedStatement.java
    db/derby/code/trunk/java/engine/org/apache/derby/impl/sql/GenericResultDescription.java
    db/derby/code/trunk/java/engine/org/apache/derby/impl/sql/execute/ColumnInfo.java
    db/derby/code/trunk/java/engine/org/apache/derby/impl/sql/execute/FKInfo.java
    db/derby/code/trunk/java/engine/org/apache/derby/impl/sql/execute/rts/RealDeleteCascadeResultSetStatistics.java
    db/derby/code/trunk/java/engine/org/apache/derby/impl/sql/execute/rts/RealHashTableStatistics.java
    db/derby/code/trunk/java/engine/org/apache/derby/impl/sql/execute/rts/RealProjectRestrictStatistics.java
    db/derby/code/trunk/java/engine/org/apache/derby/impl/sql/execute/rts/RunTimeStatisticsImpl.java

Modified: db/derby/code/trunk/java/engine/org/apache/derby/iapi/services/io/ArrayUtil.java
URL: http://svn.apache.org/viewvc/db/derby/code/trunk/java/engine/org/apache/derby/iapi/services/io/ArrayUtil.java?rev=1485676&r1=1485675&r2=1485676&view=diff
==============================================================================
--- db/derby/code/trunk/java/engine/org/apache/derby/iapi/services/io/ArrayUtil.java (original)
+++ db/derby/code/trunk/java/engine/org/apache/derby/iapi/services/io/ArrayUtil.java Thu May
23 12:56:45 2013
@@ -38,21 +38,16 @@ public abstract class ArrayUtil
 {
 	///////////////////////////////////////////////////////////////////
 	//
-	// Methods to copy arrays. We'd like to use java.util.copyOf(), but
-    // we have to run on Java 5.
+	// Methods to copy arrays.
 	//
 	///////////////////////////////////////////////////////////////////
 
     /** Copy an array of objects; the original array could be null */
-    public  static  Object[]    copy( Object[] original )
+    public  static <T> T[] copy( T[] original )
     {
-        return (original == null) ? null : (Object[]) original.clone();
-    }
-
-    /** Copy a (possibly null) array of strings */
-    public  static  String[]    copy( String[] original )
-    {
-        return (original == null) ? null : (String[]) original.clone();
+        return (original == null) ?
+                null :
+                Arrays.copyOf(original, original.length);
     }
 
     /** Copy a (possibly null) array of booleans */
@@ -97,14 +92,12 @@ public abstract class ArrayUtil
      * Make the contents of an array available as a read-only list. If the
      * array is null, an empty list will be returned.
      */
-    @SuppressWarnings("unchecked")
-    public static List<Object> asReadOnlyList(Object[] array) {
-        return (List<Object>)
-            (
-             array == null ?
-             Collections.EMPTY_LIST :
-             Collections.unmodifiableList(Arrays.asList(array))
-             );
+    public static <T> List<T> asReadOnlyList(T... array) {
+        if (array == null) {
+            return Collections.emptyList();
+        } else {
+            return Collections.unmodifiableList(Arrays.asList(array));
+        }
     }
 
 	///////////////////////////////////////////////////////////////////

Modified: db/derby/code/trunk/java/engine/org/apache/derby/iapi/sql/dictionary/IndexLister.java
URL: http://svn.apache.org/viewvc/db/derby/code/trunk/java/engine/org/apache/derby/iapi/sql/dictionary/IndexLister.java?rev=1485676&r1=1485675&r2=1485676&view=diff
==============================================================================
--- db/derby/code/trunk/java/engine/org/apache/derby/iapi/sql/dictionary/IndexLister.java
(original)
+++ db/derby/code/trunk/java/engine/org/apache/derby/iapi/sql/dictionary/IndexLister.java
Thu May 23 12:56:45 2013
@@ -87,7 +87,7 @@ public class IndexLister
 					throws StandardException
 	{
 		if ( indexRowGenerators == null ) { getAllIndexes(); }
-		return	(IndexRowGenerator[]) ArrayUtil.copy( indexRowGenerators );
+        return ArrayUtil.copy(indexRowGenerators);
 	}
 
     /**
@@ -129,7 +129,7 @@ public class IndexLister
 					throws StandardException
 	{
 		if ( distinctIndexRowGenerators == null ) { getAllIndexes(); }
-		return	(IndexRowGenerator[]) ArrayUtil.copy( distinctIndexRowGenerators );
+        return ArrayUtil.copy(distinctIndexRowGenerators);
 	}
 
     /**

Modified: db/derby/code/trunk/java/engine/org/apache/derby/iapi/sql/dictionary/SPSDescriptor.java
URL: http://svn.apache.org/viewvc/db/derby/code/trunk/java/engine/org/apache/derby/iapi/sql/dictionary/SPSDescriptor.java?rev=1485676&r1=1485675&r2=1485676&view=diff
==============================================================================
--- db/derby/code/trunk/java/engine/org/apache/derby/iapi/sql/dictionary/SPSDescriptor.java
(original)
+++ db/derby/code/trunk/java/engine/org/apache/derby/iapi/sql/dictionary/SPSDescriptor.java
Thu May 23 12:56:45 2013
@@ -596,7 +596,7 @@ public class SPSDescriptor extends Uniqu
             lookedUpParams = true;
         }
 
-		return (DataTypeDescriptor[]) ArrayUtil.copy( params );
+        return ArrayUtil.copy(params);
 	}
 
 	/**
@@ -606,7 +606,7 @@ public class SPSDescriptor extends Uniqu
 	 */
 	public final synchronized void setParams(DataTypeDescriptor params[])
 	{
-		this.params = (DataTypeDescriptor[]) ArrayUtil.copy( params );
+        this.params = ArrayUtil.copy(params);
 	}
 
 	/**

Modified: db/derby/code/trunk/java/engine/org/apache/derby/impl/jdbc/EmbedResultSetMetaData.java
URL: http://svn.apache.org/viewvc/db/derby/code/trunk/java/engine/org/apache/derby/impl/jdbc/EmbedResultSetMetaData.java?rev=1485676&r1=1485675&r2=1485676&view=diff
==============================================================================
--- db/derby/code/trunk/java/engine/org/apache/derby/impl/jdbc/EmbedResultSetMetaData.java
(original)
+++ db/derby/code/trunk/java/engine/org/apache/derby/impl/jdbc/EmbedResultSetMetaData.java
Thu May 23 12:56:45 2013
@@ -66,7 +66,7 @@ public abstract class EmbedResultSetMeta
 	// constructor
 	//
 	public EmbedResultSetMetaData(ResultColumnDescriptor[] columnInfo) {
-		this.columnInfo = (ResultColumnDescriptor[]) ArrayUtil.copy( columnInfo );
+        this.columnInfo = ArrayUtil.copy(columnInfo);
 	}
 
 	//

Modified: db/derby/code/trunk/java/engine/org/apache/derby/impl/sql/GenericPreparedStatement.java
URL: http://svn.apache.org/viewvc/db/derby/code/trunk/java/engine/org/apache/derby/impl/sql/GenericPreparedStatement.java?rev=1485676&r1=1485675&r2=1485676&view=diff
==============================================================================
--- db/derby/code/trunk/java/engine/org/apache/derby/impl/sql/GenericPreparedStatement.java
(original)
+++ db/derby/code/trunk/java/engine/org/apache/derby/impl/sql/GenericPreparedStatement.java
Thu May 23 12:56:45 2013
@@ -490,7 +490,7 @@ recompileOutOfDatePlan:
 	}
 
 	public DataTypeDescriptor[]	getParameterTypes()	{
-		return (DataTypeDescriptor[]) ArrayUtil.copy( paramTypeDescriptors );
+        return ArrayUtil.copy(paramTypeDescriptors);
 	}
 
     /** Return the type of the parameter (0-based indexing) */

Modified: db/derby/code/trunk/java/engine/org/apache/derby/impl/sql/GenericResultDescription.java
URL: http://svn.apache.org/viewvc/db/derby/code/trunk/java/engine/org/apache/derby/impl/sql/GenericResultDescription.java?rev=1485676&r1=1485675&r2=1485676&view=diff
==============================================================================
--- db/derby/code/trunk/java/engine/org/apache/derby/impl/sql/GenericResultDescription.java
(original)
+++ db/derby/code/trunk/java/engine/org/apache/derby/impl/sql/GenericResultDescription.java
Thu May 23 12:56:45 2013
@@ -98,7 +98,7 @@ public final class GenericResultDescript
 	public GenericResultDescription(ResultColumnDescriptor[] columns, 
 					String statementType) 
 	{
-		this.columns = (ResultColumnDescriptor[]) ArrayUtil.copy( columns );
+        this.columns = ArrayUtil.copy(columns);
 		this.statementType = statementType;
 	}
 
@@ -146,7 +146,7 @@ public final class GenericResultDescript
 	}
 
 	public ResultColumnDescriptor[] getColumnInfo() {
-		return (ResultColumnDescriptor[]) ArrayUtil.copy( columns );
+        return ArrayUtil.copy(columns);
 	}
 
     public  ResultColumnDescriptor  getColumnInfo( int idx ) { return columns[ idx ]; }

Modified: db/derby/code/trunk/java/engine/org/apache/derby/impl/sql/execute/ColumnInfo.java
URL: http://svn.apache.org/viewvc/db/derby/code/trunk/java/engine/org/apache/derby/impl/sql/execute/ColumnInfo.java?rev=1485676&r1=1485675&r2=1485676&view=diff
==============================================================================
--- db/derby/code/trunk/java/engine/org/apache/derby/impl/sql/execute/ColumnInfo.java (original)
+++ db/derby/code/trunk/java/engine/org/apache/derby/impl/sql/execute/ColumnInfo.java Thu
May 23 12:56:45 2013
@@ -132,7 +132,7 @@ public class ColumnInfo implements Forma
 		this.dataType = dataType;
 		this.defaultValue = defaultValue;
 		this.defaultInfo = defaultInfo;
-        this.providers = (ProviderInfo[]) ArrayUtil.copy(providers);
+        this.providers = ArrayUtil.copy(providers);
 		this.newDefaultUUID = newDefaultUUID;
 		this.oldDefaultUUID = oldDefaultUUID;
 		this.action = action;

Modified: db/derby/code/trunk/java/engine/org/apache/derby/impl/sql/execute/FKInfo.java
URL: http://svn.apache.org/viewvc/db/derby/code/trunk/java/engine/org/apache/derby/impl/sql/execute/FKInfo.java?rev=1485676&r1=1485675&r2=1485676&view=diff
==============================================================================
--- db/derby/code/trunk/java/engine/org/apache/derby/impl/sql/execute/FKInfo.java (original)
+++ db/derby/code/trunk/java/engine/org/apache/derby/impl/sql/execute/FKInfo.java Thu May
23 12:56:45 2013
@@ -138,7 +138,7 @@ public class FKInfo implements Formatabl
 		this.type = type;
 		this.refUUID = refUUID;
 		this.refConglomNumber = refConglomNumber;
-        this.fkUUIDs = (UUID[]) ArrayUtil.copy(fkUUIDs);
+        this.fkUUIDs = ArrayUtil.copy(fkUUIDs);
         this.fkConglomNumbers = ArrayUtil.copy(fkConglomNumbers);
         this.fkIsSelfReferencing = ArrayUtil.copy(fkIsSelfReferencing);
         this.colArray = ArrayUtil.copy(colArray);

Modified: db/derby/code/trunk/java/engine/org/apache/derby/impl/sql/execute/rts/RealDeleteCascadeResultSetStatistics.java
URL: http://svn.apache.org/viewvc/db/derby/code/trunk/java/engine/org/apache/derby/impl/sql/execute/rts/RealDeleteCascadeResultSetStatistics.java?rev=1485676&r1=1485675&r2=1485676&view=diff
==============================================================================
--- db/derby/code/trunk/java/engine/org/apache/derby/impl/sql/execute/rts/RealDeleteCascadeResultSetStatistics.java
(original)
+++ db/derby/code/trunk/java/engine/org/apache/derby/impl/sql/execute/rts/RealDeleteCascadeResultSetStatistics.java
Thu May 23 12:56:45 2013
@@ -56,7 +56,7 @@ public class RealDeleteCascadeResultSetS
 								)
 	{
 		super(rowCount, deferred, indexesUpdated, tableLock, executeTime, sourceResultSetStatistics);
-		this.dependentTrackingArray = (ResultSetStatistics[]) ArrayUtil.copy( dependentTrackingArray
);
+        this.dependentTrackingArray = ArrayUtil.copy(dependentTrackingArray);
 	}
 
 

Modified: db/derby/code/trunk/java/engine/org/apache/derby/impl/sql/execute/rts/RealHashTableStatistics.java
URL: http://svn.apache.org/viewvc/db/derby/code/trunk/java/engine/org/apache/derby/impl/sql/execute/rts/RealHashTableStatistics.java?rev=1485676&r1=1485675&r2=1485676&view=diff
==============================================================================
--- db/derby/code/trunk/java/engine/org/apache/derby/impl/sql/execute/rts/RealHashTableStatistics.java
(original)
+++ db/derby/code/trunk/java/engine/org/apache/derby/impl/sql/execute/rts/RealHashTableStatistics.java
Thu May 23 12:56:45 2013
@@ -110,7 +110,7 @@ public class RealHashTableStatistics
 				this.scanProperties.put(key, scanProperties.get(key));
 			}
 		}
-		this.subqueryTrackingArray = (ResultSetStatistics[]) ArrayUtil.copy( subqueryTrackingArray
);
+        this.subqueryTrackingArray = ArrayUtil.copy(subqueryTrackingArray);
 		this.childResultSetStatistics = childResultSetStatistics;
 	}
 

Modified: db/derby/code/trunk/java/engine/org/apache/derby/impl/sql/execute/rts/RealProjectRestrictStatistics.java
URL: http://svn.apache.org/viewvc/db/derby/code/trunk/java/engine/org/apache/derby/impl/sql/execute/rts/RealProjectRestrictStatistics.java?rev=1485676&r1=1485675&r2=1485676&view=diff
==============================================================================
--- db/derby/code/trunk/java/engine/org/apache/derby/impl/sql/execute/rts/RealProjectRestrictStatistics.java
(original)
+++ db/derby/code/trunk/java/engine/org/apache/derby/impl/sql/execute/rts/RealProjectRestrictStatistics.java
Thu May 23 12:56:45 2013
@@ -97,7 +97,7 @@ public class RealProjectRestrictStatisti
 		this.doesProjection = doesProjection;
 		this.restrictionTime = restrictionTime;
 		this.projectionTime = projectionTime;
-		this.subqueryTrackingArray = (ResultSetStatistics[]) ArrayUtil.copy( subqueryTrackingArray
);
+        this.subqueryTrackingArray = ArrayUtil.copy(subqueryTrackingArray);
 		this.childResultSetStatistics = childResultSetStatistics;
 	}
 

Modified: db/derby/code/trunk/java/engine/org/apache/derby/impl/sql/execute/rts/RunTimeStatisticsImpl.java
URL: http://svn.apache.org/viewvc/db/derby/code/trunk/java/engine/org/apache/derby/impl/sql/execute/rts/RunTimeStatisticsImpl.java?rev=1485676&r1=1485675&r2=1485676&view=diff
==============================================================================
--- db/derby/code/trunk/java/engine/org/apache/derby/impl/sql/execute/rts/RunTimeStatisticsImpl.java
(original)
+++ db/derby/code/trunk/java/engine/org/apache/derby/impl/sql/execute/rts/RunTimeStatisticsImpl.java
Thu May 23 12:56:45 2013
@@ -103,7 +103,7 @@ public final class RunTimeStatisticsImpl
 		this.endCompilationTimestamp = DataTypeUtilities.clone( endCompilationTimestamp );
 		this.beginExecutionTimestamp = DataTypeUtilities.clone( beginExecutionTimestamp );
 		this.endExecutionTimestamp = DataTypeUtilities.clone( endExecutionTimestamp );
-		this.subqueryTrackingArray = (ResultSetStatistics[]) ArrayUtil.copy( subqueryTrackingArray
);
+        this.subqueryTrackingArray = ArrayUtil.copy(subqueryTrackingArray);
 		this.topResultSetStatistics = topResultSetStatistics;
 	}
 



Mime
View raw message