From 28a48351fae0351f0a2154c1124dabc326235cf1 Mon Sep 17 00:00:00 2001 From: samskivert Date: Tue, 9 Feb 2010 21:16:12 +0000 Subject: [PATCH] Introduce some finality. git-svn-id: https://samskivert.googlecode.com/svn/trunk@2726 6335cc39-0255-0410-8fd6-9bcaacd3b74c --- src/java/com/samskivert/Log.java | 2 +- src/java/com/samskivert/jdbc/JDBCUtil.java | 2 +- src/java/com/samskivert/jdbc/jora/Table.java | 27 ++++++++++---------- src/java/com/samskivert/net/MACUtil.java | 6 ++--- 4 files changed, 19 insertions(+), 18 deletions(-) diff --git a/src/java/com/samskivert/Log.java b/src/java/com/samskivert/Log.java index 8b301a70..fc0397d6 100644 --- a/src/java/com/samskivert/Log.java +++ b/src/java/com/samskivert/Log.java @@ -28,5 +28,5 @@ import com.samskivert.util.Logger; public class Log { /** We dispatch our log messages through this logger. */ - public static Logger log = Logger.getLogger("com.samskivert"); + public static final Logger log = Logger.getLogger("com.samskivert"); } diff --git a/src/java/com/samskivert/jdbc/JDBCUtil.java b/src/java/com/samskivert/jdbc/JDBCUtil.java index c06cd478..5d49eebd 100644 --- a/src/java/com/samskivert/jdbc/JDBCUtil.java +++ b/src/java/com/samskivert/jdbc/JDBCUtil.java @@ -649,5 +649,5 @@ public class JDBCUtil } /** Used by {@link #makeCollectingConnection}. */ - protected static Class[] PROXY_IFACES = { Connection.class }; + protected static final Class[] PROXY_IFACES = { Connection.class }; } diff --git a/src/java/com/samskivert/jdbc/jora/Table.java b/src/java/com/samskivert/jdbc/jora/Table.java index 5017d3a5..a2f26d3c 100644 --- a/src/java/com/samskivert/jdbc/jora/Table.java +++ b/src/java/com/samskivert/jdbc/jora/Table.java @@ -429,7 +429,7 @@ public class Table * components "x" and "y", then database table should have columns * "location_x" and "location_y" (if '_' is used as separator). */ - public static String fieldSeparator = "_"; + public static final String fieldSeparator = "_"; protected final void init (Class clazz, String tableName, String[] keys, boolean mixedCaseConvert) @@ -877,6 +877,17 @@ public class Table return column; } + protected static Method getSetBypass () + { + try { + Class c = Class.forName("java.lang.reflect.AccessibleObject"); + return c.getMethod("setAccessible", new Class[] { Boolean.TYPE }); + } catch (Exception ex) { + System.err.println("Unable to reflect AccessibleObject.setAccessible: " + ex); + return null; + } + } + protected String name; protected String listOfFields; protected String qualifiedListOfFields; @@ -895,22 +906,12 @@ public class Table protected int primaryKeyIndices[]; protected Constructor constructor; - protected static Method setBypass; - protected static Class serializableClass; + protected static final Method setBypass = getSetBypass(); + protected static final Class serializableClass = Serializable.class; protected static final Object[] bypassFlag = { Boolean.TRUE }; protected static final Object[] constructorArgs = {}; // used to identify byte[] fields protected static final byte[] BYTE_PROTO = new byte[0]; - - static { - try { - serializableClass = Serializable.class; - Class c = Class.forName("java.lang.reflect.AccessibleObject"); - setBypass = c.getMethod("setAccessible", new Class[] { Boolean.TYPE }); - } catch (Exception ex) { - System.err.println("Unable to reflect AccessibleObject.setAccessible: " + ex); - } - } } diff --git a/src/java/com/samskivert/net/MACUtil.java b/src/java/com/samskivert/net/MACUtil.java index ff8af020..e2e73128 100644 --- a/src/java/com/samskivert/net/MACUtil.java +++ b/src/java/com/samskivert/net/MACUtil.java @@ -161,11 +161,11 @@ public class MACUtil /** Look for 2 hex values in a row followed by a ':' or '-' repeated 5 times, followed by 2 hex * values. */ - protected static Pattern MACRegex = + protected static final Pattern MACRegex = Pattern.compile("((?:\\p{XDigit}{2}+[:\\-]){5}+\\p{XDigit}{2}+)", Pattern.CASE_INSENSITIVE); // TODO maybe we should obfuscate these with rot13 or something so // that people can't run 'strings' on us and instantly see what we try - protected static String[] WINDOWS_CMDS = {"ipconfig /all"}; - protected static String[] UNIX_CMDS = {"/sbin/ifconfig", "/etc/ifconfig"}; + protected static final String[] WINDOWS_CMDS = {"ipconfig /all"}; + protected static final String[] UNIX_CMDS = {"/sbin/ifconfig", "/etc/ifconfig"}; }