db-derby-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From rhille...@apache.org
Subject svn commit: r658822 - in /db/derby/code/trunk/java: engine/org/apache/derby/iapi/services/loader/ClassInspector.java testing/org/apache/derbyTesting/functionTests/tests/lang/AnsiSignatures.java
Date Wed, 21 May 2008 19:28:01 GMT
Author: rhillegas
Date: Wed May 21 12:28:00 2008
New Revision: 658822

URL: http://svn.apache.org/viewvc?rev=658822&view=rev
Log:
DERBY-3652: Stop widening Strings to Objects when matching SQL routine signatures to Java
method signatures.

Modified:
    db/derby/code/trunk/java/engine/org/apache/derby/iapi/services/loader/ClassInspector.java
    db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/tests/lang/AnsiSignatures.java

Modified: db/derby/code/trunk/java/engine/org/apache/derby/iapi/services/loader/ClassInspector.java
URL: http://svn.apache.org/viewvc/db/derby/code/trunk/java/engine/org/apache/derby/iapi/services/loader/ClassInspector.java?rev=658822&r1=658821&r2=658822&view=diff
==============================================================================
--- db/derby/code/trunk/java/engine/org/apache/derby/iapi/services/loader/ClassInspector.java
(original)
+++ db/derby/code/trunk/java/engine/org/apache/derby/iapi/services/loader/ClassInspector.java
Wed May 21 12:28:00 2008
@@ -53,6 +53,9 @@
 		 "java.lang.Short", "java.lang.Integer", "java.lang.Long",
 		 "java.lang.Float", "java.lang.Double"};
 
+    private static final String OBJECT_TYPE_NAME = "java.lang.Object";
+    private static final String STRING_TYPE_NAME = "java.lang.String";
+
 	private final ClassFactory cf;
 
 	/**
@@ -945,7 +948,27 @@
 	 **/
 	protected boolean classConvertableFromTo(Class fromClass, Class toClass, boolean mixTypes)
{
 
-		if (toClass.isAssignableFrom(fromClass)) {
+        //
+        // Don't allow widening of String to Object. Otherwise, the SQL
+        // signature
+        //
+        //    f( a varchar( 10 ) ) returns varchar( 10 )
+        //
+        // will incorrectly match the Java signature
+        //
+        //   public static String f( Object a )
+        //
+        // For a description of the ANSI signature matching rules, see
+        // DERBY-3652.
+        //
+		if (
+            !(
+              STRING_TYPE_NAME.equals( fromClass.getName() ) &&
+              OBJECT_TYPE_NAME.equals( toClass.getName() )
+              ) &&
+            toClass.isAssignableFrom(fromClass)
+            )
+        {            
 			return true;
 		}
 

Modified: db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/tests/lang/AnsiSignatures.java
URL: http://svn.apache.org/viewvc/db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/tests/lang/AnsiSignatures.java?rev=658822&r1=658821&r2=658822&view=diff
==============================================================================
--- db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/tests/lang/AnsiSignatures.java
(original)
+++ db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/tests/lang/AnsiSignatures.java
Wed May 21 12:28:00 2008
@@ -546,6 +546,6 @@
     public  static  String   varchar_String_String( Long a ) { return "-1"; }
     public  static  String   varchar_String_String( Float a ) { return "-1"; }
     public  static  String   varchar_String_String( Double a ) { return "-1"; }
-    //    public  static  String   varchar_String_String( Object a ) { return "-1"; }
+    public  static  String   varchar_String_String( Object a ) { return "-1"; }
     
 }



Mime
View raw message