db-derby-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From kahat...@apache.org
Subject svn commit: r789684 - in /db/derby/code/trunk/java: client/org/apache/derby/client/am/ client/org/apache/derby/jdbc/ engine/org/apache/derby/iapi/types/ engine/org/apache/derby/impl/sql/compile/
Date Tue, 30 Jun 2009 11:22:48 GMT
Author: kahatlen
Date: Tue Jun 30 11:22:48 2009
New Revision: 789684

URL: http://svn.apache.org/viewvc?rev=789684&view=rev
Log:
DERBY-4293: Mutable public static variables

Made more static variables final and/or private, and created accessor
method to prevent direct access to public static array.

Patch contributed by Sebb <sebb@apache.org>.

Modified:
    db/derby/code/trunk/java/client/org/apache/derby/client/am/BatchUpdateException.java
    db/derby/code/trunk/java/client/org/apache/derby/client/am/Configuration.java
    db/derby/code/trunk/java/client/org/apache/derby/client/am/Decimal.java
    db/derby/code/trunk/java/client/org/apache/derby/client/am/EncryptionManager.java
    db/derby/code/trunk/java/client/org/apache/derby/client/am/Version.java
    db/derby/code/trunk/java/client/org/apache/derby/jdbc/ClientBaseDataSource.java
    db/derby/code/trunk/java/engine/org/apache/derby/iapi/types/JSQLType.java
    db/derby/code/trunk/java/engine/org/apache/derby/impl/sql/compile/JavaValueNode.java
    db/derby/code/trunk/java/engine/org/apache/derby/impl/sql/compile/MethodCallNode.java

Modified: db/derby/code/trunk/java/client/org/apache/derby/client/am/BatchUpdateException.java
URL: http://svn.apache.org/viewvc/db/derby/code/trunk/java/client/org/apache/derby/client/am/BatchUpdateException.java?rev=789684&r1=789683&r2=789684&view=diff
==============================================================================
--- db/derby/code/trunk/java/client/org/apache/derby/client/am/BatchUpdateException.java (original)
+++ db/derby/code/trunk/java/client/org/apache/derby/client/am/BatchUpdateException.java Tue
Jun 30 11:22:48 2009
@@ -32,7 +32,7 @@
      *  it knows to look there if the message isn't found in the
      *  shared message bundle.
      */
-    private static MessageUtil msgutil_ = 
+    private static final MessageUtil msgutil_ =
         SqlException.getMessageUtil();
 
     public BatchUpdateException(LogWriter logWriter, ClientMessageId msgid,

Modified: db/derby/code/trunk/java/client/org/apache/derby/client/am/Configuration.java
URL: http://svn.apache.org/viewvc/db/derby/code/trunk/java/client/org/apache/derby/client/am/Configuration.java?rev=789684&r1=789683&r2=789684&view=diff
==============================================================================
--- db/derby/code/trunk/java/client/org/apache/derby/client/am/Configuration.java (original)
+++ db/derby/code/trunk/java/client/org/apache/derby/client/am/Configuration.java Tue Jun
30 11:22:48 2009
@@ -42,9 +42,9 @@
     public static String traceDirectory__ = null;
 
     public static boolean traceFileAppend__ = false;
-    public static String jreLevel = "1.3.0"; // default level if unable to read
-    public static int jreLevelMajor = 1;
-    public static int jreLevelMinor = 3;
+    public static final String jreLevel;// = "1.3.0"; // default level if unable to read
+    public static final int jreLevelMajor;// = 1;
+    public static final int jreLevelMinor;// = 3;
 
     private Configuration() {
     }
@@ -56,7 +56,7 @@
 
     // -------------------------- versioning -------------------------------------
 
-    public static ProductVersionHolder dncProductVersionHolder__;
+    private static ProductVersionHolder dncProductVersionHolder__;
 
     public static ProductVersionHolder getProductVersionHolder() {
         return dncProductVersionHolder__;
@@ -73,9 +73,9 @@
     public final static byte[] dncPackageConsistencyToken =
             {0x53, 0x59, 0x53, 0x4c, 0x56, 0x4c, 0x30, 0x31};
 
-    // We will not set packagge VERSION in the initial release.
+    // We will not set package VERSION in the initial release.
     // If we have to change the package version in the future then we can.
-    public static String dncPackageVersion = null;
+    public static final String dncPackageVersion = null;
 
     // for Driver.jdbcCompliant()
     public final static boolean jdbcCompliant = true;
@@ -130,7 +130,7 @@
 
     // -----------------------Load resource bundles for the driver asap-----------
 
-    private static final String packageNameForDNC = "org.apache.derby.client";
+    private static final String packageNameForDNC = "org.apache.derby.client"; // NOTUSED
 
     public static SqlException exceptionsOnLoadResources = null; // used by ClientDriver
to accumulate load exceptions
 
@@ -140,12 +140,17 @@
         } catch (SqlException e) {
             exceptionsOnLoadResources = e;
         }
+        String _jreLevel;
         try {
-            jreLevel = System.getProperty("java.version");
+            _jreLevel = System.getProperty("java.version");
         } catch (SecurityException e) {
+            _jreLevel = "1.3.0";
         } // ignore it, assume 1.3.0
+        jreLevel = _jreLevel;
         java.util.StringTokenizer st = new java.util.StringTokenizer(jreLevel, ".");
         int jreState = 0;
+        int _jreLevelMajor = 1;
+        int _jreLevelMinor = 3;
         while (st.hasMoreTokens()) {
             int i;
             try {
@@ -155,15 +160,17 @@
             }
             switch (jreState++) {
             case 0:
-                jreLevelMajor = i; // state 0, this is the major version
+                _jreLevelMajor = i; // state 0, this is the major version
                 break;
             case 1:
-                jreLevelMinor = i; // state 1, this is the minor version
+                _jreLevelMinor = i; // state 1, this is the minor version
                 break;
             default:
                 break; // state >1, ignore
             }
         }
+        jreLevelMajor = _jreLevelMajor;
+        jreLevelMinor = _jreLevelMinor;
     }
 
     /**

Modified: db/derby/code/trunk/java/client/org/apache/derby/client/am/Decimal.java
URL: http://svn.apache.org/viewvc/db/derby/code/trunk/java/client/org/apache/derby/client/am/Decimal.java?rev=789684&r1=789683&r2=789684&view=diff
==============================================================================
--- db/derby/code/trunk/java/client/org/apache/derby/client/am/Decimal.java (original)
+++ db/derby/code/trunk/java/client/org/apache/derby/client/am/Decimal.java Tue Jun 30 11:22:48
2009
@@ -33,7 +33,7 @@
      */
     public final static int PACKED_DECIMAL = 0x30;
     
-    private static MessageUtil msgutil = SqlException.getMessageUtil();
+    private static final MessageUtil msgutil = SqlException.getMessageUtil();
 
     //--------------------------private constants---------------------------------
 

Modified: db/derby/code/trunk/java/client/org/apache/derby/client/am/EncryptionManager.java
URL: http://svn.apache.org/viewvc/db/derby/code/trunk/java/client/org/apache/derby/client/am/EncryptionManager.java?rev=789684&r1=789683&r2=789684&view=diff
==============================================================================
--- db/derby/code/trunk/java/client/org/apache/derby/client/am/EncryptionManager.java (original)
+++ db/derby/code/trunk/java/client/org/apache/derby/client/am/EncryptionManager.java Tue
Jun 30 11:22:48 2009
@@ -618,7 +618,7 @@
      * package when the capability is put back in (StringUtil.java).     *
      *********************************************************************/
 
-    private static char[] hex_table = {
+    private static final char[] hex_table = {
                 '0', '1', '2', '3', '4', '5', '6', '7', '8', '9', 
                 'a', 'b', 'c', 'd', 'e', 'f'
             };

Modified: db/derby/code/trunk/java/client/org/apache/derby/client/am/Version.java
URL: http://svn.apache.org/viewvc/db/derby/code/trunk/java/client/org/apache/derby/client/am/Version.java?rev=789684&r1=789683&r2=789684&view=diff
==============================================================================
--- db/derby/code/trunk/java/client/org/apache/derby/client/am/Version.java (original)
+++ db/derby/code/trunk/java/client/org/apache/derby/client/am/Version.java Tue Jun 30 11:22:48
2009
@@ -27,7 +27,7 @@
 
 
 public abstract class Version {
-    static MessageUtil msgutil = SqlException.getMessageUtil();
+    static final MessageUtil msgutil = SqlException.getMessageUtil();
     
     // Same as java.sql.DatabaseMetaData.getDriverName()
     public static String getDriverName() {
@@ -36,7 +36,7 @@
 
     // for DatabaseMetaData.getDriverVersion()
     public static String getDriverVersion() {
-        return Configuration.dncProductVersionHolder__.getVersionBuildString(true);
+        return Configuration.getProductVersionHolder().getVersionBuildString(true);
     }
 
 
@@ -68,7 +68,7 @@
     // Not an external, just a helper method
     private static String getDriverNameAndVersion() {
         return Configuration.dncDriverName + " " +
-                Configuration.dncProductVersionHolder__.getVersionBuildString(true);
+                Configuration.getProductVersionHolder().getVersionBuildString(true);
     }
 
     // -------------------------- configuration print stream ---------------------

Modified: db/derby/code/trunk/java/client/org/apache/derby/jdbc/ClientBaseDataSource.java
URL: http://svn.apache.org/viewvc/db/derby/code/trunk/java/client/org/apache/derby/jdbc/ClientBaseDataSource.java?rev=789684&r1=789683&r2=789684&view=diff
==============================================================================
--- db/derby/code/trunk/java/client/org/apache/derby/jdbc/ClientBaseDataSource.java (original)
+++ db/derby/code/trunk/java/client/org/apache/derby/jdbc/ClientBaseDataSource.java Tue Jun
30 11:22:48 2009
@@ -25,7 +25,6 @@
 import java.io.PrintWriter;
 import java.io.File;
 import java.security.AccessController;
-import java.security.PrivilegedActionException;
 import java.util.Properties;
 import java.util.StringTokenizer;
 import java.util.NoSuchElementException;
@@ -66,10 +65,11 @@
     // this information is needed to decide if security mechanism 
     // can be upgraded to EUSRIDPWD or not
     // See getUpgradedSecurityMechanism()
-    static boolean SUPPORTS_EUSRIDPWD = false;
+    static final boolean SUPPORTS_EUSRIDPWD;
     
     static
     {
+        boolean supports_eusridpwd = false;
         try
         {
             // The EncryptionManager class will instantiate objects of the required 
@@ -78,14 +78,15 @@
             // in the JCE implementation in the JVM in which the client
             // is loaded.
             new org.apache.derby.client.am.EncryptionManager(null);
-            SUPPORTS_EUSRIDPWD = true;
+            supports_eusridpwd = true;
         }catch(Exception e)
         {
             // if an exception is thrown, ignore exception.
             // set SUPPORTS_EUSRIDPWD to false indicating that the client 
             // does not support EUSRIDPWD security mechanism
-            SUPPORTS_EUSRIDPWD = false;
+            supports_eusridpwd = false;
         }
+        SUPPORTS_EUSRIDPWD = supports_eusridpwd;
     }
     
     // The loginTimeout jdbc 2 data source property is not supported as a jdbc 1 connection
property,

Modified: db/derby/code/trunk/java/engine/org/apache/derby/iapi/types/JSQLType.java
URL: http://svn.apache.org/viewvc/db/derby/code/trunk/java/engine/org/apache/derby/iapi/types/JSQLType.java?rev=789684&r1=789683&r2=789684&view=diff
==============================================================================
--- db/derby/code/trunk/java/engine/org/apache/derby/iapi/types/JSQLType.java (original)
+++ db/derby/code/trunk/java/engine/org/apache/derby/iapi/types/JSQLType.java Tue Jun 30 11:22:48
2009
@@ -72,7 +72,7 @@
 		"java.lang.Double"
 	};
 
-	static	public	final	String[]	primitiveNames =
+	static	private	final	String[]	primitiveNames =
 	{
 		"boolean",
 		"char",
@@ -196,6 +196,11 @@
 		return sqlType;
 	}
 
+    // Give read-only access to array of strings
+	public static String getPrimitiveName(byte index){
+	    return primitiveNames[index];
+	}
+
 	///////////////////////////////////////////////////////////////////////
 	//
 	//	Formatable BEHAVIOR

Modified: db/derby/code/trunk/java/engine/org/apache/derby/impl/sql/compile/JavaValueNode.java
URL: http://svn.apache.org/viewvc/db/derby/code/trunk/java/engine/org/apache/derby/impl/sql/compile/JavaValueNode.java?rev=789684&r1=789683&r2=789684&view=diff
==============================================================================
--- db/derby/code/trunk/java/engine/org/apache/derby/impl/sql/compile/JavaValueNode.java (original)
+++ db/derby/code/trunk/java/engine/org/apache/derby/impl/sql/compile/JavaValueNode.java Tue
Jun 30 11:22:48 2009
@@ -95,7 +95,7 @@
 		{
 		    case JSQLType.JAVA_CLASS: return myType.getJavaClassName();
 
-		    case JSQLType.JAVA_PRIMITIVE: return JSQLType.primitiveNames[ myType.getPrimitiveKind()
];
+		    case JSQLType.JAVA_PRIMITIVE: return JSQLType.getPrimitiveName( myType.getPrimitiveKind()
);
 
 		    default:
 
@@ -120,7 +120,7 @@
 
 		switch( myType.getCategory() )
 		{
-		    case JSQLType.JAVA_PRIMITIVE: return JSQLType.primitiveNames[ myType.getPrimitiveKind()
];
+		    case JSQLType.JAVA_PRIMITIVE: return JSQLType.getPrimitiveName( myType.getPrimitiveKind()
);
 
 		    default:
 

Modified: db/derby/code/trunk/java/engine/org/apache/derby/impl/sql/compile/MethodCallNode.java
URL: http://svn.apache.org/viewvc/db/derby/code/trunk/java/engine/org/apache/derby/impl/sql/compile/MethodCallNode.java?rev=789684&r1=789683&r2=789684&view=diff
==============================================================================
--- db/derby/code/trunk/java/engine/org/apache/derby/impl/sql/compile/MethodCallNode.java
(original)
+++ db/derby/code/trunk/java/engine/org/apache/derby/impl/sql/compile/MethodCallNode.java
Tue Jun 30 11:22:48 2009
@@ -1095,7 +1095,7 @@
 
 		        case JSQLType.JAVA_CLASS: return jsqlType.getJavaClassName();
 
-		        case JSQLType.JAVA_PRIMITIVE: return JSQLType.primitiveNames[ jsqlType.getPrimitiveKind()
];
+		        case JSQLType.JAVA_PRIMITIVE: return JSQLType.getPrimitiveName( jsqlType.getPrimitiveKind()
);
 
 		        default:
 
@@ -1155,7 +1155,7 @@
 
 		            case JSQLType.JAVA_PRIMITIVE:
 
-						primParmTypeNames[i] = JSQLType.primitiveNames[ jsqlType.getPrimitiveKind() ];
+						primParmTypeNames[i] = JSQLType.getPrimitiveName( jsqlType.getPrimitiveKind() );
 						if ( castToPrimitiveAsNecessary) { methodParms[i].castToPrimitive(true); }
 						break;
 



Mime
View raw message