db-derby-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From ma...@apache.org
Subject svn commit: r538325 - in /db/derby/code/trunk/java/engine/org/apache/derby: iapi/sql/compile/ impl/sql/compile/
Date Tue, 15 May 2007 21:27:17 GMT
Author: mamta
Date: Tue May 15 14:27:16 2007
New Revision: 538325

URL: http://svn.apache.org/viewvc?view=rev&rev=538325
Log:
DERBY-2335
Made changes such that rather than having a new method in BaseTypeCompiler to push the DVD
on the stack at code generation time, we use the
existing method that accomplishes the same task in ExpressionClassBuilder. The junit tests
have run fine with these changes and the stack
trace experienced by Army in DERBY-2335 has been fixed by this fix. The reason for stack trace
was that the lifetime of a BaseTypeCompiler
is longer than a single class generation and I was trying to hold a reference to a declared
method from MethodBuilder.describeMethod across
the generated classes. This discussion can be found at 
http://www.nabble.com/DERBY-1478-subtask-DERBY-2583---need-help-in-debugging-stack-trace-thrown-during-code-generation-p10611184.html

Modified:
    db/derby/code/trunk/java/engine/org/apache/derby/iapi/sql/compile/TypeCompiler.java
    db/derby/code/trunk/java/engine/org/apache/derby/impl/sql/compile/BaseTypeCompiler.java
    db/derby/code/trunk/java/engine/org/apache/derby/impl/sql/compile/CLOBTypeCompiler.java
    db/derby/code/trunk/java/engine/org/apache/derby/impl/sql/compile/CharTypeCompiler.java
    db/derby/code/trunk/java/engine/org/apache/derby/impl/sql/compile/ExpressionClassBuilder.java
    db/derby/code/trunk/java/engine/org/apache/derby/impl/sql/compile/NumericTypeCompiler.java
    db/derby/code/trunk/java/engine/org/apache/derby/impl/sql/compile/UserDefinedTypeCompiler.java

Modified: db/derby/code/trunk/java/engine/org/apache/derby/iapi/sql/compile/TypeCompiler.java
URL: http://svn.apache.org/viewvc/db/derby/code/trunk/java/engine/org/apache/derby/iapi/sql/compile/TypeCompiler.java?view=diff&rev=538325&r1=538324&r2=538325
==============================================================================
--- db/derby/code/trunk/java/engine/org/apache/derby/iapi/sql/compile/TypeCompiler.java (original)
+++ db/derby/code/trunk/java/engine/org/apache/derby/iapi/sql/compile/TypeCompiler.java Tue
May 15 14:27:16 2007
@@ -25,6 +25,7 @@
 
 import org.apache.derby.iapi.services.compiler.MethodBuilder;
 import org.apache.derby.iapi.services.compiler.LocalField;
+import org.apache.derby.impl.sql.compile.ExpressionClassBuilder;
 
 import org.apache.derby.iapi.types.DataTypeDescriptor;
 import org.apache.derby.iapi.types.TypeId;
@@ -178,6 +179,7 @@
 	 * type. The stack must contain a DataValueFactory and a null or a value
 	 * of the correct type (interfaceName()).
 	 *
+	 * @param eb The ExpressionClassBuilder for the class we're generating
 	 * @param mb	The method to put the expression in
 	 * @param collationType For character DVDs, this will be used to determine
 	 *   what Collator should be associated with the DVD which in turn will 
@@ -185,7 +187,8 @@
 	 * @param className name of the base class of the activation's hierarchy
 	 */
 
-	void generateNull(MethodBuilder mb, int collationType, String className);
+	void generateNull(ExpressionClassBuilder eb,
+			MethodBuilder mb, int collationType, String className);
 
 
 	/**
@@ -200,7 +203,8 @@
 	 * 
 	 * The stack must contain data value factory value.
 	 * 
-	 * @param eb	The method to put the expression in
+	 * @param eb The ExpressionClassBuilder for the class we're generating
+	 * @param mb	The method to put the expression in
 	 * @param collationType For character DVDs, this will be used to determine
 	 *   what Collator should be associated with the DVD which in turn will 
 	 *   decide whether to generate CollatorSQLcharDVDs or SQLcharDVDs. For 
@@ -208,7 +212,9 @@
 	 * @param className name of the base class of the activation's hierarchy
 	 * @param field LocalField
 	 */
-	void generateDataValue(MethodBuilder eb, int collationType, 
+	void generateDataValue(
+			ExpressionClassBuilder eb,
+			MethodBuilder mb, int collationType, 
 			String className, LocalField field);
 
 	/**

Modified: db/derby/code/trunk/java/engine/org/apache/derby/impl/sql/compile/BaseTypeCompiler.java
URL: http://svn.apache.org/viewvc/db/derby/code/trunk/java/engine/org/apache/derby/impl/sql/compile/BaseTypeCompiler.java?view=diff&rev=538325&r1=538324&r2=538325
==============================================================================
--- db/derby/code/trunk/java/engine/org/apache/derby/impl/sql/compile/BaseTypeCompiler.java
(original)
+++ db/derby/code/trunk/java/engine/org/apache/derby/impl/sql/compile/BaseTypeCompiler.java
Tue May 15 14:27:16 2007
@@ -93,8 +93,9 @@
 										);
 	}
 
-	/** @see TypeCompiler#generateNull(MethodBuilder, int, String) */
-	public void generateNull(MethodBuilder mb, int collationType, 
+	/** @see TypeCompiler#generateNull(ExpressionClassBuilder, MethodBuilder, int, String)*/
+	public void generateNull(ExpressionClassBuilder e,
+			MethodBuilder mb, int collationType, 
 			String className)
 	{
 		mb.callMethod(VMOpcode.INVOKEINTERFACE, (String) null,
@@ -103,8 +104,9 @@
 									1);
 	}
 
-	/** @see TypeCompiler#generateDataValue(MethodBuilder, int, String, LocalField) */
-	public void generateDataValue(MethodBuilder mb, int collationType,
+	/** @see TypeCompiler#generateDataValue(ExpressionClassBuilder, MethodBuilder, int, String,
LocalField) */
+	public void generateDataValue(ExpressionClassBuilder eb,
+			MethodBuilder mb, int collationType,
 			String className, LocalField field)
 	{
 		String				interfaceName = interfaceName();
@@ -153,7 +155,8 @@
 	 * because those are the only type compilers who generate DVDs which are 
 	 * impacted by the collation. Rest of the TypeCompilers generate DVDs which
 	 * are collation in-sensitive.
-	 * 
+	 *
+	 * @param eb The ExpressionClassBuilder for the class we're generating
 	 * @param mb The method to put the expression in
 	 * @param collationType For character DVDs, this will be used to determine
 	 *   what Collator should be associated with the DVD which in turn will 
@@ -161,7 +164,9 @@
 	 *   other types of DVDs, this parameter will be ignored.
 	 * @param className name of the base class of the activation's hierarchy
 	 */
-	protected void generateCollationSensitiveDataValue(MethodBuilder mb, 
+	protected void generateCollationSensitiveDataValue(
+			ExpressionClassBuilder eb,
+			MethodBuilder mb, 
 			int collationType, String className){		
 		if (collationType == StringDataValue.COLLATION_TYPE_UCS_BASIC)
 			return; 
@@ -169,38 +174,11 @@
 		//generate DVDs with territory based RuleBasedCollator and hence we 
 		//need to generate CollatorSQLChar/CollatorSQLVarchar/
 		//CollatorSQLLongvarchar/CollatorSQLClob 
-		pushDataValueFactory(mb, className);
+		eb.pushDataValueFactory(mb);
 		mb.push(collationType);
 		mb.callMethod(VMOpcode.INVOKEINTERFACE, null, "getCharacterCollator",
 				"java.text.RuleBasedCollator", 1);
 		mb.callMethod(VMOpcode.INVOKEINTERFACE, null, "getValue", interfaceName(), 1);
-	}
-	
-	private Object getDVF;
-	/**
-	 * This method will push a DVF on the stack. This DVF is required to get
-	 * the territory based collator using the collation type. In other words,
-	 * this DVF will be used to generate something like following
-	 * DVF.getCharacterCollator(collationType)
-	 * 
-	 * @param mb The method to put the expression in
-	 * @param className name of the base class of the activation's hierarchy
-	 */
-	private void pushDataValueFactory(MethodBuilder mb, String className)
-	{
-		// generates:
-		//	   getDataValueFactory()
-		//
-
-		if (getDVF == null) {
-			getDVF = mb.describeMethod(VMOpcode.INVOKEVIRTUAL,
-										className,
-										"getDataValueFactory",
-										ClassName.DataValueFactory);
-		}
-
-		mb.pushThis();
-		mb.callMethod(getDVF);
 	}
 
 	protected abstract String nullMethodName();

Modified: db/derby/code/trunk/java/engine/org/apache/derby/impl/sql/compile/CLOBTypeCompiler.java
URL: http://svn.apache.org/viewvc/db/derby/code/trunk/java/engine/org/apache/derby/impl/sql/compile/CLOBTypeCompiler.java?view=diff&rev=538325&r1=538324&r2=538325
==============================================================================
--- db/derby/code/trunk/java/engine/org/apache/derby/impl/sql/compile/CLOBTypeCompiler.java
(original)
+++ db/derby/code/trunk/java/engine/org/apache/derby/impl/sql/compile/CLOBTypeCompiler.java
Tue May 15 14:27:16 2007
@@ -140,19 +140,23 @@
                 }
         }
 
-    	/** @see TypeCompiler#generateDataValue(MethodBuilder, int, String, LocalField) */
-    	public void generateDataValue(MethodBuilder mb, int collationType,
+    	/** @see TypeCompiler#generateDataValue(ExpressionClassBuilder, MethodBuilder, int,
String, LocalField) */
+    	public void generateDataValue(
+    			ExpressionClassBuilder eb,
+				MethodBuilder mb, int collationType,
     			String className, LocalField field)
     	{
-    		super.generateDataValue(mb, collationType, className, field);
-    		generateCollationSensitiveDataValue(mb, collationType, className);
+    		super.generateDataValue(eb, mb, collationType, className, field);
+    		generateCollationSensitiveDataValue(eb, mb, collationType, className);
     	}
 
-    	/** @see TypeCompiler#generateNull(MethodBuilder, int, String) */
-    	public void generateNull(MethodBuilder mb, int collationType, 
+    	/** @see TypeCompiler#generateNull(ExpressionClassBuilder, MethodBuilder, int, String)*/
+    	public void generateNull(
+    			ExpressionClassBuilder eb,
+				MethodBuilder mb, int collationType, 
     			String className)
     	{
-    		super.generateNull(mb, collationType, className);
-    		generateCollationSensitiveDataValue(mb, collationType, className);
+    		super.generateNull(eb, mb, collationType, className);
+    		generateCollationSensitiveDataValue(eb, mb, collationType, className);
     	}
 }

Modified: db/derby/code/trunk/java/engine/org/apache/derby/impl/sql/compile/CharTypeCompiler.java
URL: http://svn.apache.org/viewvc/db/derby/code/trunk/java/engine/org/apache/derby/impl/sql/compile/CharTypeCompiler.java?view=diff&rev=538325&r1=538324&r2=538325
==============================================================================
--- db/derby/code/trunk/java/engine/org/apache/derby/impl/sql/compile/CharTypeCompiler.java
(original)
+++ db/derby/code/trunk/java/engine/org/apache/derby/impl/sql/compile/CharTypeCompiler.java
Tue May 15 14:27:16 2007
@@ -192,20 +192,24 @@
                 }
         }
 
-    	/** @see TypeCompiler#generateDataValue(MethodBuilder, int, String, LocalField) */
-    	public void generateDataValue(MethodBuilder mb, int collationType,
+    	/** @see TypeCompiler#generateDataValue(ExpressionClassBuilder, MethodBuilder, int,
String, LocalField) */
+    	public void generateDataValue(
+    			ExpressionClassBuilder eb,
+				MethodBuilder mb, int collationType,
     			String className, LocalField field)
     	{
-    		super.generateDataValue(mb, collationType, className, field);
-    		generateCollationSensitiveDataValue(mb, collationType, className);
+    		super.generateDataValue(eb, mb, collationType, className, field);
+    		generateCollationSensitiveDataValue(eb, mb, collationType, className);
     	}
 
-    	/** @see TypeCompiler#generateNull(MethodBuilder, int, String) */
-    	public void generateNull(MethodBuilder mb, int collationType, 
+    	/** @see TypeCompiler#generateNull(ExpressionClassBuilder, MethodBuilder, int, String)*/
+    	public void generateNull(
+    			ExpressionClassBuilder eb,
+				MethodBuilder mb, int collationType, 
     			String className)
     	{
-    		super.generateNull(mb, collationType, className);
-    		generateCollationSensitiveDataValue(mb, collationType, className);
+    		super.generateNull(eb, mb, collationType, className);
+    		generateCollationSensitiveDataValue(eb, mb, collationType, className);
     	}
 
         protected String dataValueMethodName()

Modified: db/derby/code/trunk/java/engine/org/apache/derby/impl/sql/compile/ExpressionClassBuilder.java
URL: http://svn.apache.org/viewvc/db/derby/code/trunk/java/engine/org/apache/derby/impl/sql/compile/ExpressionClassBuilder.java?view=diff&rev=538325&r1=538324&r2=538325
==============================================================================
--- db/derby/code/trunk/java/engine/org/apache/derby/impl/sql/compile/ExpressionClassBuilder.java
(original)
+++ db/derby/code/trunk/java/engine/org/apache/derby/impl/sql/compile/ExpressionClassBuilder.java
Tue May 15 14:27:16 2007
@@ -80,7 +80,7 @@
  * FilterClassBuilder. See the documentation on ActivationClassBuilder.
  *
  */
-abstract	class ExpressionClassBuilder implements ExpressionClassBuilderInterface
+public abstract	class ExpressionClassBuilder implements ExpressionClassBuilderInterface
 {
 	///////////////////////////////////////////////////////////////////////
 	//
@@ -870,7 +870,7 @@
 	void generateNull(MethodBuilder mb, TypeCompiler tc, int collationType) {
 		pushDataValueFactory(mb);
 		mb.pushNull(tc.interfaceName());
-		tc.generateNull(mb, collationType, getBaseClassName());
+		tc.generateNull(this, mb, collationType, getBaseClassName());
 	}
 
 	/**
@@ -883,7 +883,7 @@
 		pushDataValueFactory(mb);
 		mb.swap(); // need the dvf as the instance
 		mb.cast(tc.interfaceName());
-		tc.generateNull(mb, collationType, getBaseClassName());
+		tc.generateNull(this, mb, collationType, getBaseClassName());
 	}
 
 	/**
@@ -896,7 +896,7 @@
 			int collationType, LocalField field) {
 		pushDataValueFactory(mb);
 		mb.swap(); // need the dvf as the instance
-		tc.generateDataValue(mb, collationType, getBaseClassName(), field);
+		tc.generateDataValue(this, mb, collationType, getBaseClassName(), field);
 	}
 
 	

Modified: db/derby/code/trunk/java/engine/org/apache/derby/impl/sql/compile/NumericTypeCompiler.java
URL: http://svn.apache.org/viewvc/db/derby/code/trunk/java/engine/org/apache/derby/impl/sql/compile/NumericTypeCompiler.java?view=diff&rev=538325&r1=538324&r2=538325
==============================================================================
--- db/derby/code/trunk/java/engine/org/apache/derby/impl/sql/compile/NumericTypeCompiler.java
(original)
+++ db/derby/code/trunk/java/engine/org/apache/derby/impl/sql/compile/NumericTypeCompiler.java
Tue May 15 14:27:16 2007
@@ -530,7 +530,9 @@
 	}
 
 
-	public void generateDataValue(MethodBuilder mb, int collationType,
+	/** @see TypeCompiler#generateDataValue(ExpressionClassBuilder, MethodBuilder, int, String,
LocalField) */
+	public void generateDataValue(ExpressionClassBuilder eb,
+			MethodBuilder mb, int collationType,
 			String className, LocalField field)
 	{
 		if (!JVMInfo.J2ME && getTypeId().isDecimalTypeId())
@@ -542,7 +544,7 @@
 			mb.upCast("java.lang.Number");
 		}
 
-		super.generateDataValue(mb, collationType, className, field);
+		super.generateDataValue(eb, mb, collationType, className, field);
 	}
 
 }

Modified: db/derby/code/trunk/java/engine/org/apache/derby/impl/sql/compile/UserDefinedTypeCompiler.java
URL: http://svn.apache.org/viewvc/db/derby/code/trunk/java/engine/org/apache/derby/impl/sql/compile/UserDefinedTypeCompiler.java?view=diff&rev=538325&r1=538324&r2=538325
==============================================================================
--- db/derby/code/trunk/java/engine/org/apache/derby/impl/sql/compile/UserDefinedTypeCompiler.java
(original)
+++ db/derby/code/trunk/java/engine/org/apache/derby/impl/sql/compile/UserDefinedTypeCompiler.java
Tue May 15 14:27:16 2007
@@ -118,13 +118,14 @@
 		return "getNullObject";
 	}
 
-	public void generateDataValue(MethodBuilder mb, int collationType,
+	/** @see TypeCompiler#generateDataValue(ExpressionClassBuilder, MethodBuilder, int, String,
LocalField) */
+	public void generateDataValue(ExpressionClassBuilder eb, MethodBuilder mb, int collationType,
 			String className, LocalField field)
 	{
 		// cast the value to an object for method resolution
 		mb.upCast("java.lang.Object");
 
-		super.generateDataValue(mb, collationType, className, field);
+		super.generateDataValue(eb, mb, collationType, className, field);
 	}
 
 		



Mime
View raw message