7035615: Address lint warnings for javax.sql.rowset & com.sun.rowset
Reviewed-by: alanb, darcy
--- a/jdk/src/share/classes/com/sun/rowset/CachedRowSetImpl.java Tue Apr 12 08:27:00 2011 -0700
+++ b/jdk/src/share/classes/com/sun/rowset/CachedRowSetImpl.java Tue Apr 12 12:25:15 2011 -0400
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 2003, 2010, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2003, 2011, 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
@@ -111,13 +111,13 @@
*/
private String tableName;
-
/**
* A <code>Vector</code> object containing the <code>Row</code>
* objects that comprise this <code>CachedRowSetImpl</code> object.
* @serial
*/
- private Vector rvh;
+ private Vector<Object> rvh;
+
/**
* The current postion of the cursor in this <code>CachedRowSetImpl</code>
* object.
@@ -293,12 +293,12 @@
/**
* The Vector holding the Match Columns
*/
- private Vector iMatchColumns;
+ private Vector<Integer> iMatchColumns;
/**
* The Vector that will hold the Match Column names.
*/
- private Vector strMatchColumns;
+ private Vector<String> strMatchColumns;
/**
* Trigger that indicates whether the active SyncProvider is exposes the
@@ -484,7 +484,7 @@
*/
private void initContainer() {
- rvh = new Vector(100);
+ rvh = new Vector<Object>(100);
cursorPos = 0;
absolutePos = 0;
numRows = 0;
@@ -523,12 +523,12 @@
//Instantiating the vector for MatchColumns
- iMatchColumns = new Vector(10);
+ iMatchColumns = new Vector<Integer>(10);
for(int i = 0; i < 10 ; i++) {
iMatchColumns.add(i,Integer.valueOf(-1));
}
- strMatchColumns = new Vector(10);
+ strMatchColumns = new Vector<String>(10);
for(int j = 0; j < 10; j++) {
strMatchColumns.add(j,null);
}
@@ -622,7 +622,7 @@
Row currentRow;
int numCols;
int i;
- Map map = getTypeMap();
+ Map<String, Class<?>> map = getTypeMap();
Object obj;
int mRows;
@@ -939,14 +939,9 @@
*/
public void acceptChanges(Connection con) throws SyncProviderException{
- try{
- setConnection(con);
- acceptChanges();
- } catch (SyncProviderException spe) {
- throw spe;
- } catch(SQLException sqle){
- throw new SyncProviderException(sqle.getMessage());
- }
+ setConnection(con);
+ acceptChanges();
+
}
/**
@@ -1289,14 +1284,7 @@
*/
public Collection<?> toCollection() throws SQLException {
- TreeMap tMap;
- int count = 0;
- Row origRow;
- Vector newRow;
-
- int colCount = ((RowSetMetaDataImpl)this.getMetaData()).getColumnCount();
-
- tMap = new TreeMap();
+ TreeMap<Integer, Object> tMap = new TreeMap<>();
for (int i = 0; i<numRows; i++) {
tMap.put(Integer.valueOf(i), rvh.get(i));
@@ -1325,10 +1313,8 @@
*/
public Collection<?> toCollection(int column) throws SQLException {
- Vector vec;
- Row origRow;
int nRows = numRows;
- vec = new Vector(nRows);
+ Vector<Object> vec = new Vector<>(nRows);
// create a copy
CachedRowSetImpl crsTemp;
@@ -2953,7 +2939,7 @@
*/
public Object getObject(int columnIndex) throws SQLException {
Object value;
- java.util.Map map;
+ Map<String, Class<?>> map;
// sanity check.
checkIndex(columnIndex);
@@ -7257,7 +7243,7 @@
Row currentRow;
int numCols;
int i;
- Map map = getTypeMap();
+ Map<String, Class<?>> map = getTypeMap();
Object obj;
int mRows;
@@ -7304,11 +7290,11 @@
resultSet.absolute(start -1);
}
if( pageSize == 0) {
- rvh = new Vector(getMaxRows());
+ rvh = new Vector<Object>(getMaxRows());
}
else{
- rvh = new Vector(getPageSize());
+ rvh = new Vector<Object>(getPageSize());
}
if (data == null) {
--- a/jdk/src/share/classes/com/sun/rowset/JdbcRowSetImpl.java Tue Apr 12 08:27:00 2011 -0700
+++ b/jdk/src/share/classes/com/sun/rowset/JdbcRowSetImpl.java Tue Apr 12 12:25:15 2011 -0400
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 2003, 2010, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2003, 2011, 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
@@ -93,12 +93,12 @@
/**
* The Vector holding the Match Columns
*/
- private Vector iMatchColumns;
+ private Vector<Integer> iMatchColumns;
/**
* The Vector that will hold the Match Column names.
*/
- private Vector strMatchColumns;
+ private Vector<String> strMatchColumns;
protected transient JdbcRowSetResourceBundle resBundle;
@@ -213,12 +213,12 @@
//Instantiating the vector for MatchColumns
- iMatchColumns = new Vector(10);
+ iMatchColumns = new Vector<Integer>(10);
for(int i = 0; i < 10 ; i++) {
iMatchColumns.add(i,Integer.valueOf(-1));
}
- strMatchColumns = new Vector(10);
+ strMatchColumns = new Vector<String>(10);
for(int j = 0; j < 10; j++) {
strMatchColumns.add(j,null);
}
@@ -286,12 +286,12 @@
//Instantiating the vector for MatchColumns
- iMatchColumns = new Vector(10);
+ iMatchColumns = new Vector<Integer>(10);
for(int i = 0; i < 10 ; i++) {
iMatchColumns.add(i,Integer.valueOf(-1));
}
- strMatchColumns = new Vector(10);
+ strMatchColumns = new Vector<String>(10);
for(int j = 0; j < 10; j++) {
strMatchColumns.add(j,null);
}
@@ -373,12 +373,12 @@
//Instantiating the vector for MatchColumns
- iMatchColumns = new Vector(10);
+ iMatchColumns = new Vector<Integer>(10);
for(int i = 0; i < 10 ; i++) {
iMatchColumns.add(i,Integer.valueOf(-1));
}
- strMatchColumns = new Vector(10);
+ strMatchColumns = new Vector<String>(10);
for(int j = 0; j < 10; j++) {
strMatchColumns.add(j,null);
}
@@ -463,12 +463,12 @@
//Instantiating the vector for MatchColumns
- iMatchColumns = new Vector(10);
+ iMatchColumns = new Vector<Integer>(10);
for(int i = 0; i < 10 ; i++) {
iMatchColumns.add(i,Integer.valueOf(-1));
}
- strMatchColumns = new Vector(10);
+ strMatchColumns = new Vector<String>(10);
for(int j = 0; j < 10; j++) {
strMatchColumns.add(j,null);
}
@@ -675,7 +675,7 @@
try {
- Map aMap = getTypeMap();
+ Map<String, Class<?>> aMap = getTypeMap();
if( aMap != null) {
conn.setTypeMap(aMap);
}
--- a/jdk/src/share/classes/com/sun/rowset/JoinRowSetImpl.java Tue Apr 12 08:27:00 2011 -0700
+++ b/jdk/src/share/classes/com/sun/rowset/JoinRowSetImpl.java Tue Apr 12 12:25:15 2011 -0400
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 2003, 2010, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2003, 2011, 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
@@ -59,8 +59,8 @@
/**
* A <code>Vector</code> object that contains the <code>RowSet</code> objects
* that have been added to this <code>JoinRowSet</code> object.
- */
- private Vector vecRowSetsInJOIN;
+ */
+ private Vector<CachedRowSetImpl> vecRowSetsInJOIN;
/**
* The <code>CachedRowSet</code> object that encapsulates this
@@ -78,13 +78,13 @@
* for this <code>JoinRowSet</code> object.
* The last join type set forms the basis of succeeding joins.
*/
- private Vector vecJoinType;
+ private Vector<Integer> vecJoinType;
/**
* A <code>Vector</code> object containing the names of all the tables entering
* the join.
*/
- private Vector vecTableNames;
+ private Vector<String> vecTableNames;
/**
* An <code>int</code> that indicates the column index of the match column.
@@ -121,10 +121,10 @@
*/
public JoinRowSetImpl() throws SQLException {
- vecRowSetsInJOIN = new Vector();
+ vecRowSetsInJOIN = new Vector<CachedRowSetImpl>();
crsInternal = new CachedRowSetImpl();
- vecJoinType = new Vector();
- vecTableNames = new Vector();
+ vecJoinType = new Vector<Integer>();
+ vecTableNames = new Vector<String>();
iMatchKey = -1;
strMatchKey = null;
supportedJOINs =
@@ -222,7 +222,7 @@
// either of the setter methods have been set.
if(boolColId){
//
- ArrayList indices = new ArrayList();
+ ArrayList<Integer> indices = new ArrayList<>();
for(int i=0;i<cRowset.getMatchColumnNames().length;i++) {
if( (strMatchKey = (cRowset.getMatchColumnNames())[i]) != null) {
iMatchKey = cRowset.findColumn(strMatchKey);
--- a/jdk/src/share/classes/javax/sql/rowset/BaseRowSet.java Tue Apr 12 08:27:00 2011 -0700
+++ b/jdk/src/share/classes/javax/sql/rowset/BaseRowSet.java Tue Apr 12 12:25:15 2011 -0400
@@ -296,32 +296,32 @@
public abstract class BaseRowSet implements Serializable, Cloneable {
-/**
- * A constant indicating to a <code>RowSetReaderImpl</code> object
- * that a given parameter is a Unicode stream. This
- * <code>RowSetReaderImpl</code> object is provided as an extension of the
- * <code>SyncProvider</code> abstract class defined in the
- * <code>SyncFactory</code> static factory SPI mechanism.
- */
-public static final int UNICODE_STREAM_PARAM = 0;
-
-/**
- * A constant indicating to a <code>RowSetReaderImpl</code> object
- * that a given parameter is a binary stream. A
- * <code>RowSetReaderImpl</code> object is provided as an extension of the
- * <code>SyncProvider</code> abstract class defined in the
- * <code>SyncFactory</code> static factory SPI mechanism.
- */
-public static final int BINARY_STREAM_PARAM = 1;
-
-/**
- * A constant indicating to a <code>RowSetReaderImpl</code> object
- * that a given parameter is an ASCII stream. A
- * <code>RowSetReaderImpl</code> object is provided as an extension of the
- * <code>SyncProvider</code> abstract class defined in the
- * <code>SyncFactory</code> static factory SPI mechanism.
- */
-public static final int ASCII_STREAM_PARAM = 2;
+ /**
+ * A constant indicating to a <code>RowSetReaderImpl</code> object
+ * that a given parameter is a Unicode stream. This
+ * <code>RowSetReaderImpl</code> object is provided as an extension of the
+ * <code>SyncProvider</code> abstract class defined in the
+ * <code>SyncFactory</code> static factory SPI mechanism.
+ */
+ public static final int UNICODE_STREAM_PARAM = 0;
+
+ /**
+ * A constant indicating to a <code>RowSetReaderImpl</code> object
+ * that a given parameter is a binary stream. A
+ * <code>RowSetReaderImpl</code> object is provided as an extension of the
+ * <code>SyncProvider</code> abstract class defined in the
+ * <code>SyncFactory</code> static factory SPI mechanism.
+ */
+ public static final int BINARY_STREAM_PARAM = 1;
+
+ /**
+ * A constant indicating to a <code>RowSetReaderImpl</code> object
+ * that a given parameter is an ASCII stream. A
+ * <code>RowSetReaderImpl</code> object is provided as an extension of the
+ * <code>SyncProvider</code> abstract class defined in the
+ * <code>SyncFactory</code> static factory SPI mechanism.
+ */
+ public static final int ASCII_STREAM_PARAM = 2;
/**
* The <code>InputStream</code> object that will be
@@ -505,21 +505,21 @@
* custom mapping of user-defined types.
* @serial
*/
- private Map map;
+ private Map<String, Class<?>> map;
/**
* A <code>Vector</code> object that holds the list of listeners
* that have registered with this <code>RowSet</code> object.
* @serial
*/
- private Vector listeners;
+ private Vector<RowSetListener> listeners;
/**
* A <code>Vector</code> object that holds the parameters set
* for this <code>RowSet</code> object's current command.
* @serial
*/
- private Hashtable params; // could be transient?
+ private Hashtable<Integer, Object> params; // could be transient?
/**
* Constructs a new <code>BaseRowSet</code> object initialized with
@@ -529,7 +529,7 @@
*/
public BaseRowSet() {
// allocate the listeners collection
- listeners = new Vector();
+ listeners = new Vector<RowSetListener>();
}
/**
@@ -542,7 +542,7 @@
* a <code>RowSet</code> implementation extending this class.
*/
protected void initParams() {
- params = new Hashtable();
+ params = new Hashtable<Integer, Object>();
}
//--------------------------------------------------------------------
--- a/jdk/src/share/classes/javax/sql/rowset/RowSetMetaDataImpl.java Tue Apr 12 08:27:00 2011 -0700
+++ b/jdk/src/share/classes/javax/sql/rowset/RowSetMetaDataImpl.java Tue Apr 12 12:25:15 2011 -0400
@@ -912,7 +912,12 @@
* @since 1.6
*/
public <T> T unwrap(java.lang.Class<T> iface) throws java.sql.SQLException {
- return (T)this;
+
+ if(isWrapperFor(iface)) {
+ return iface.cast(this);
+ } else {
+ throw new SQLException("unwrap failed for:"+ iface);
+ }
}
/**
@@ -929,8 +934,9 @@
* @throws java.sql.SQLException if an error occurs while determining whether this is a wrapper
* for an object with the given interface.
* @since 1.6
- */ public boolean isWrapperFor(Class<?> interfaces) throws SQLException {
- return false;
+ */
+ public boolean isWrapperFor(Class<?> interfaces) throws SQLException {
+ return interfaces.isInstance(this);
}
static final long serialVersionUID = 6893806403181801867L;
--- a/jdk/src/share/classes/javax/sql/rowset/RowSetProvider.java Tue Apr 12 08:27:00 2011 -0700
+++ b/jdk/src/share/classes/javax/sql/rowset/RowSetProvider.java Tue Apr 12 12:25:15 2011 -0400
@@ -204,9 +204,9 @@
*
*/
static private ClassLoader getContextClassLoader() throws SecurityException {
- return (ClassLoader) AccessController.doPrivileged(new PrivilegedAction() {
+ return AccessController.doPrivileged(new PrivilegedAction<ClassLoader>() {
- public Object run() {
+ public ClassLoader run() {
ClassLoader cl = null;
cl = Thread.currentThread().getContextClassLoader();
@@ -284,9 +284,9 @@
static private String getSystemProperty(final String propName) {
String property = null;
try {
- property = (String) AccessController.doPrivileged(new PrivilegedAction() {
+ property = AccessController.doPrivileged(new PrivilegedAction<String>() {
- public Object run() {
+ public String run() {
return System.getProperty(propName);
}
});