db-derby-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From kmars...@apache.org
Subject svn commit: r1177468 - in /db/derby/code/branches/10.8/java: engine/org/apache/derby/iapi/services/info/JVMInfo.java tools/org/apache/derby/impl/tools/ij/xaHelper.java tools/org/apache/derby/impl/tools/sysinfo/Main.java
Date Fri, 30 Sep 2011 00:24:03 GMT
Author: kmarsden
Date: Fri Sep 30 00:24:03 2011
New Revision: 1177468

URL: http://svn.apache.org/viewvc?rev=1177468&view=rev
Log:
DERBY-1046 JVMInfo is duplicated in derbyclient.jar
DERBY-5431 If 10.7 or greater derbyclient.jar is in the classpath before an older release's
server jars, derby fails to boot with NoSuchFieldError for JVMInfo.JAVA_SQL_TYPES_BOOLEAN

Remove references to JVMInfo in xaHelper and sysinfo to get it out of 
derbytools.jar and derbyclient.jar 


Modified:
    db/derby/code/branches/10.8/java/engine/org/apache/derby/iapi/services/info/JVMInfo.java
    db/derby/code/branches/10.8/java/tools/org/apache/derby/impl/tools/ij/xaHelper.java
    db/derby/code/branches/10.8/java/tools/org/apache/derby/impl/tools/sysinfo/Main.java

Modified: db/derby/code/branches/10.8/java/engine/org/apache/derby/iapi/services/info/JVMInfo.java
URL: http://svn.apache.org/viewvc/db/derby/code/branches/10.8/java/engine/org/apache/derby/iapi/services/info/JVMInfo.java?rev=1177468&r1=1177467&r2=1177468&view=diff
==============================================================================
--- db/derby/code/branches/10.8/java/engine/org/apache/derby/iapi/services/info/JVMInfo.java
(original)
+++ db/derby/code/branches/10.8/java/engine/org/apache/derby/iapi/services/info/JVMInfo.java
Fri Sep 30 00:24:03 2011
@@ -56,6 +56,7 @@ public abstract class JVMInfo
 	public static final int J2SE_142 = 5;
 	public static final int J2SE_15 = 6; // aka J2SE 5.0
 	public static final int J2SE_16 = 7; // Java SE 6, not J2SE
+	public static final int J2SE_17 = 8;
 
 	public static final boolean J2ME;
 
@@ -131,6 +132,10 @@ public abstract class JVMInfo
 			{
 				id = J2SE_16;
 			}
+			else if (javaVersion.equals("1.7")) 
+			{
+			    id = J2SE_17;
+			}
 			else
 			{
 				// aussme our lowest support unless the java spec
@@ -161,6 +166,8 @@ public abstract class JVMInfo
 
 	/**
 		Return Derby's understanding of the virtual machine's environment.
+		Any changes here must also be made in sysinfo.Main() derbyVMLevel
+		due to the fix for DERBY-1046.
 	*/
 	public static String derbyVMLevel()
 	{
@@ -170,6 +177,7 @@ public abstract class JVMInfo
 		case J2SE_142: return "J2SE 1.4.2 - JDBC 3.0";
 		case J2SE_15: return "J2SE 5.0 - JDBC 3.0";
 		case J2SE_16: return "Java SE 6 - JDBC 4.0";
+		case J2SE_17: return "Java SE 7 - JDBC 4.0";
 		default: return "?-?";
 		}
 	}

Modified: db/derby/code/branches/10.8/java/tools/org/apache/derby/impl/tools/ij/xaHelper.java
URL: http://svn.apache.org/viewvc/db/derby/code/branches/10.8/java/tools/org/apache/derby/impl/tools/ij/xaHelper.java?rev=1177468&r1=1177467&r2=1177468&view=diff
==============================================================================
--- db/derby/code/branches/10.8/java/tools/org/apache/derby/impl/tools/ij/xaHelper.java (original)
+++ db/derby/code/branches/10.8/java/tools/org/apache/derby/impl/tools/ij/xaHelper.java Fri
Sep 30 00:24:03 2011
@@ -510,45 +510,49 @@ class xaHelper implements xaAbstractHelp
 		// if we new it directly, then it will the tools.jar file to bloat.
 		try
 		{
-			if (isJCC)
-				return (XADataSource) 
-					(Class.forName("com.ibm.db2.jcc.DB2XADataSource").newInstance());
-			else if (isNetClient){
-                            if (JVMInfo.JDK_ID >= JVMInfo.J2SE_16) {
-                                //running under jdk1.6 or higher 
-                                // try instantiating EmbeddedXADataSource40
-                                try {
-                                    return (XADataSource)(Class.forName(
-                                        "org.apache.derby.jdbc." +
-                                        "ClientXADataSource40").newInstance());         
                              
-                                }
-                                catch (ClassNotFoundException e) {
-                                    //probably it was not compiled with jdbc4.0
-                                    //support go ahead with EmbeddedXADataSource
-                                }
-                            }
-                            return (XADataSource) (Class.forName(
-                                    "org.apache.derby.jdbc.ClientXADataSource"
-                                    ).newInstance());
-                        }
-			else {
-                            if (JVMInfo.JDK_ID >= JVMInfo.J2SE_16) {
-                                //running under jdk1.6 or higher 
-                                // try instantiating EmbeddedXADataSource40
-                                try {
-                                    return (XADataSource)(Class.forName(
-                                        "org.apache.derby.jdbc." +
-                                        "EmbeddedXADataSource40").newInstance());       
                                
-                                }
-                                catch (ClassNotFoundException e) {
-                                    //probably it was not compiled with jdbc4.0
-                                    //support go ahead with EmbeddedXADataSource
-                                }
-                            }
-                            return (XADataSource)(Class.forName("org.apache.derby.jdbc.EmbeddedXADataSource").newInstance());
-                        }
-		}
-		catch(ClassNotFoundException cnfe) {
+		    
+            if (isJCC)
+               return (XADataSource) 
+                (Class.forName("com.ibm.db2.jcc.DB2XADataSource").newInstance());
+            else if (isNetClient){
+                //running under jdk1.6 or higher 
+                // try instantiating EmbeddedXADataSource40
+                try {
+                    return (XADataSource)(Class.forName(
+                            "org.apache.derby.jdbc." +
+                    "ClientXADataSource40").newInstance());                             
          
+                }
+                catch (ClassNotFoundException e) {
+                    //probably it was not compiled with jdbc4.0
+                    //support go ahead with ClientXADataSource
+                }
+                catch (UnsupportedClassVersionError ue) { 
+                    // ClientXADataSource
+                }
+                return (XADataSource) (Class.forName(
+                        "org.apache.derby.jdbc.ClientXADataSource"
+                ).newInstance());
+            }
+            else {
+                //running under jdk1.6 or higher 
+                // try instantiating EmbeddedXADataSource40
+                try {
+                    return (XADataSource)(Class.forName(
+                            "org.apache.derby.jdbc." +
+                    "EmbeddedXADataSource40").newInstance());                           
            
+                }
+                catch (ClassNotFoundException e) {
+                    //probably it was not compiled with jdbc4.0
+                    //support go ahead with EmbeddedXADataSource
+                }
+                catch (UnsupportedClassVersionError ue) {
+                    // not jdk 16 or higher. Go ahead with
+                    // EmbeddedXADataSource
+                }
+                return (XADataSource)(Class.forName("org.apache.derby.jdbc.EmbeddedXADataSource").newInstance());
+            }
+        }
+        catch(ClassNotFoundException cnfe) {
 			throw new ijException(LocalizedResource.getMessage("IJ_XAClass"));
 		}
 		catch (InstantiationException e) { }

Modified: db/derby/code/branches/10.8/java/tools/org/apache/derby/impl/tools/sysinfo/Main.java
URL: http://svn.apache.org/viewvc/db/derby/code/branches/10.8/java/tools/org/apache/derby/impl/tools/sysinfo/Main.java?rev=1177468&r1=1177467&r2=1177468&view=diff
==============================================================================
--- db/derby/code/branches/10.8/java/tools/org/apache/derby/impl/tools/sysinfo/Main.java (original)
+++ db/derby/code/branches/10.8/java/tools/org/apache/derby/impl/tools/sysinfo/Main.java Fri
Sep 30 00:24:03 2011
@@ -220,7 +220,7 @@ public static void getMainInfo (java.io.
 
   private static void reportDerby (java.io.PrintWriter localAW) {
 
-	  localAW.println("JRE - JDBC: " + org.apache.derby.iapi.services.info.JVMInfo.derbyVMLevel());
+	  localAW.println("JRE - JDBC: " + derbyVMLevel());
 
 	  String classpath = null;
 
@@ -260,8 +260,8 @@ public static void getMainInfo (java.io.
 
 
   } // end of reportDerby
-
-  /**
+  
+/**
     Writes out the relevant info about the Java environment to
     the specified AppStreamWriter.
 
@@ -1253,5 +1253,62 @@ public static void getMainInfo (java.io.
         return result;
     }
 
+    /**
+     * Return VM and JDBC version for sysinfo This has to be in this class and
+     * NOT use org.apache.derby.iapi.services.info. ! Some code is repeated here
+     * to avoid JVMInfo being in multiple jars DERBY-1046 DERBY-5431. For now
+     * changes made here probably also be made in JVMInfo.
+     * 
+     * @return Derby's understanding of the virtual machine's environment.
+     */
+    private static String derbyVMLevel() {
+
+        // For sysinfo assuming java.specification.version is set because it
+        // was mandatory as of 1.4.2. This method is not as extensive as the
+        // initialization in JVMInfo and makes such assumptions. If any
+        // exception
+        // occurs we skip this line of sysinfo.
+        try {
+            String javaVersion =
+                System.getProperty("java.specification.version", "1.4");
+            String javaSpec =
+                System.getProperty("java.specification.name", "-");
+
+            boolean isJ2ME = javaSpec.startsWith("J2ME") || // recognize IBM
+            // WCTME
+            javaSpec.startsWith("CDC") || // Oracle Java ME Embedded
+            // Client
+            (
+                    (javaSpec.indexOf("Profile") > -1) && // recognize phoneME
+                    (javaSpec.indexOf("Specification") > -1)
+            );
+            
+            if (isJ2ME) {
+                return "J2ME - JDBC for CDC/FP 1.1";
+            }
+            else if (javaVersion.equals("1.4")) {
+                // 1.4.2 is the minimum we support so assume that
+                // if it is not J2ME it is 1.4.2
+                return "J2SE 1.4.2 - JDBC 3.0";
+            }
+            else if (javaVersion.equals("1.5")) {
+                return "J2SE 5.0 - JDBC 3.0";
+            }
+            else if (javaVersion.equals("1.6")) {
+                return "Java SE 6 - JDBC 4.0";
+            }
+            else if (javaVersion.equals("1.7")) {
+                // We don't have full JDBC 4.1 support yet, so still print JDBC
+                // 4.0
+                return "Java SE 7 - JDBC 4.0";
+            }
+            else
+                return "?-?";
+        } catch (Exception e) {
+            return "?-?: " + e.getMessage();
+        }
+    }
+
+
 } // end of class Main
 



Mime
View raw message