[jboss-cvs] JBossAS SVN: r60105 - in projects/aop/trunk/aop/src/main/org/jboss/aop: util and 1 other directory.
jboss-cvs-commits at lists.jboss.org
jboss-cvs-commits at lists.jboss.org
Mon Jan 29 12:52:10 EST 2007
Author: flavia.rainone at jboss.com
Date: 2007-01-29 12:52:09 -0500 (Mon, 29 Jan 2007)
New Revision: 60105
Modified:
projects/aop/trunk/aop/src/main/org/jboss/aop/instrument/ConByConJoinPointGenerator.java
projects/aop/trunk/aop/src/main/org/jboss/aop/instrument/ConByMethodJoinPointGenerator.java
projects/aop/trunk/aop/src/main/org/jboss/aop/instrument/ConstructionJoinPointGenerator.java
projects/aop/trunk/aop/src/main/org/jboss/aop/instrument/ConstructorJoinPointGenerator.java
projects/aop/trunk/aop/src/main/org/jboss/aop/instrument/FieldJoinPointGenerator.java
projects/aop/trunk/aop/src/main/org/jboss/aop/instrument/MethodByConJoinPointGenerator.java
projects/aop/trunk/aop/src/main/org/jboss/aop/instrument/MethodByMethodJoinPointGenerator.java
projects/aop/trunk/aop/src/main/org/jboss/aop/instrument/MethodJoinPointGenerator.java
projects/aop/trunk/aop/src/main/org/jboss/aop/instrument/OptimizedBehaviourInvocations.java
projects/aop/trunk/aop/src/main/org/jboss/aop/instrument/OptimizedCallerInvocations.java
projects/aop/trunk/aop/src/main/org/jboss/aop/instrument/OptimizedConstructionInvocations.java
projects/aop/trunk/aop/src/main/org/jboss/aop/instrument/OptimizedConstructorInvocations.java
projects/aop/trunk/aop/src/main/org/jboss/aop/instrument/OptimizedFieldInvocations.java
projects/aop/trunk/aop/src/main/org/jboss/aop/instrument/OptimizedMethodInvocations.java
projects/aop/trunk/aop/src/main/org/jboss/aop/util/JavassistToReflect.java
Log:
[JBAOP-352] Code refactoring plus addition of control to arguments/typed arg fields inconsistency.
Totally functional on optimized caller invocations.
Modified: projects/aop/trunk/aop/src/main/org/jboss/aop/instrument/ConByConJoinPointGenerator.java
===================================================================
--- projects/aop/trunk/aop/src/main/org/jboss/aop/instrument/ConByConJoinPointGenerator.java 2007-01-29 17:24:22 UTC (rev 60104)
+++ projects/aop/trunk/aop/src/main/org/jboss/aop/instrument/ConByConJoinPointGenerator.java 2007-01-29 17:52:09 UTC (rev 60105)
@@ -228,7 +228,8 @@
protected CtClass generate() throws CannotCompileException, NotFoundException
{
jp = setupClass();
- addArgumentsFieldsAndAccessors();
+ OptimizedBehaviourInvocations.addArgumentFieldsAndAccessors(
+ instrumentor.getClassPool(), jp, params, false);
addInvokeJoinpointMethod();
addMethodInfoField();
addPublicConstructor();
@@ -250,13 +251,6 @@
return jp;
}
- private void addArgumentsFieldsAndAccessors() throws NotFoundException, CannotCompileException
- {
- OptimizedBehaviourInvocations.addArgumentFieldsToInvocation(jp, params);
- OptimizedBehaviourInvocations.addSetArguments(instrumentor.getClassPool(), jp, params);
- OptimizedBehaviourInvocations.addGetArguments(instrumentor.getClassPool(), jp, params);
- }
-
/**
* This constructor is used by the advisor when we have regenerated the joinpoint.
* This just creates a generic JoinPoint instance with no data specific to the
Modified: projects/aop/trunk/aop/src/main/org/jboss/aop/instrument/ConByMethodJoinPointGenerator.java
===================================================================
--- projects/aop/trunk/aop/src/main/org/jboss/aop/instrument/ConByMethodJoinPointGenerator.java 2007-01-29 17:24:22 UTC (rev 60104)
+++ projects/aop/trunk/aop/src/main/org/jboss/aop/instrument/ConByMethodJoinPointGenerator.java 2007-01-29 17:52:09 UTC (rev 60105)
@@ -240,7 +240,8 @@
protected CtClass generate() throws CannotCompileException, NotFoundException
{
jp = setupClass();
- addArgumentsFieldsAndAccessors();
+ OptimizedBehaviourInvocations.addArgumentFieldsAndAccessors(
+ instrumentor.getClassPool(), jp, params, false);
addInvokeJoinpointMethod();
addMethodInfoField();
addPublicConstructor();
@@ -262,13 +263,6 @@
return jp;
}
- private void addArgumentsFieldsAndAccessors() throws NotFoundException, CannotCompileException
- {
- OptimizedBehaviourInvocations.addArgumentFieldsToInvocation(jp, params);
- OptimizedBehaviourInvocations.addSetArguments(instrumentor.getClassPool(), jp, params);
- OptimizedBehaviourInvocations.addGetArguments(instrumentor.getClassPool(), jp, params);
- }
-
/**
* This constructor is used by the advisor when we have regenerated the joinpoint.
* This just creates a generic JoinPoint instance with no data specific to the
Modified: projects/aop/trunk/aop/src/main/org/jboss/aop/instrument/ConstructionJoinPointGenerator.java
===================================================================
--- projects/aop/trunk/aop/src/main/org/jboss/aop/instrument/ConstructionJoinPointGenerator.java 2007-01-29 17:24:22 UTC (rev 60104)
+++ projects/aop/trunk/aop/src/main/org/jboss/aop/instrument/ConstructionJoinPointGenerator.java 2007-01-29 17:52:09 UTC (rev 60105)
@@ -204,7 +204,8 @@
protected CtClass generate() throws CannotCompileException, NotFoundException
{
jp = setupClass();
- addArgumentsFieldsAndAccessors();
+ OptimizedBehaviourInvocations.addArgumentFieldsAndAccessors(
+ instrumentor.getClassPool(), jp, originalParams, false);
addTypedTargetField();
addInvokeJoinpointMethod();
addConstructionInfoField();
@@ -234,14 +235,6 @@
targetField.setModifiers(Modifier.PROTECTED);
}
-
- private void addArgumentsFieldsAndAccessors() throws NotFoundException, CannotCompileException
- {
- OptimizedBehaviourInvocations.addArgumentFieldsToInvocation(jp, originalParams);
- OptimizedBehaviourInvocations.addSetArguments(instrumentor.getClassPool(), jp, originalParams);
- OptimizedBehaviourInvocations.addGetArguments(instrumentor.getClassPool(), jp, originalParams);
- }
-
/**
* This constructor is used by the advisor when we have regenerated the joinpoint.
* This just creates a generic JoinPoint instance with no data specific to the
Modified: projects/aop/trunk/aop/src/main/org/jboss/aop/instrument/ConstructorJoinPointGenerator.java
===================================================================
--- projects/aop/trunk/aop/src/main/org/jboss/aop/instrument/ConstructorJoinPointGenerator.java 2007-01-29 17:24:22 UTC (rev 60104)
+++ projects/aop/trunk/aop/src/main/org/jboss/aop/instrument/ConstructorJoinPointGenerator.java 2007-01-29 17:52:09 UTC (rev 60105)
@@ -187,7 +187,8 @@
protected CtClass generate() throws CannotCompileException, NotFoundException
{
jp = setupClass();
- addArgumentsFieldsAndAccessors();
+ OptimizedBehaviourInvocations.addArgumentFieldsAndAccessors(
+ instrumentor.getClassPool(), jp, params, false);
addInvokeJoinpointMethod();
addMethodInfoField();
addPublicConstructor();
@@ -209,13 +210,6 @@
return jp;
}
- private void addArgumentsFieldsAndAccessors() throws NotFoundException, CannotCompileException
- {
- OptimizedBehaviourInvocations.addArgumentFieldsToInvocation(jp, params);
- OptimizedBehaviourInvocations.addSetArguments(instrumentor.getClassPool(), jp, params);
- OptimizedBehaviourInvocations.addGetArguments(instrumentor.getClassPool(), jp, params);
- }
-
/**
* This constructor is used by the advisor when we have regenerated the joinpoint.
* This just creates a generic JoinPoint instance with no data specific to the
Modified: projects/aop/trunk/aop/src/main/org/jboss/aop/instrument/FieldJoinPointGenerator.java
===================================================================
--- projects/aop/trunk/aop/src/main/org/jboss/aop/instrument/FieldJoinPointGenerator.java 2007-01-29 17:24:22 UTC (rev 60104)
+++ projects/aop/trunk/aop/src/main/org/jboss/aop/instrument/FieldJoinPointGenerator.java 2007-01-29 17:52:09 UTC (rev 60105)
@@ -614,7 +614,7 @@
protected String createInvokeNextDispatchMethodBody() throws NotFoundException
{
CtClass type = advisedField.getType();
- String value = JavassistToReflect.castInvocationValueToTypeString(type);
+ String value = JavassistToReflect.castInvocationValueToTypeString(type) + ";";
return
"{" +
Modified: projects/aop/trunk/aop/src/main/org/jboss/aop/instrument/MethodByConJoinPointGenerator.java
===================================================================
--- projects/aop/trunk/aop/src/main/org/jboss/aop/instrument/MethodByConJoinPointGenerator.java 2007-01-29 17:24:22 UTC (rev 60104)
+++ projects/aop/trunk/aop/src/main/org/jboss/aop/instrument/MethodByConJoinPointGenerator.java 2007-01-29 17:52:09 UTC (rev 60105)
@@ -222,7 +222,8 @@
protected CtClass generate() throws CannotCompileException, NotFoundException
{
jp = setupClass();
- addArgumentsFieldsAndAccessors();
+ OptimizedBehaviourInvocations.addArgumentFieldsAndAccessors(
+ instrumentor.getClassPool(), jp, params, false);
if (hasTargetObject)
{
addTypedTargetField();
@@ -253,13 +254,6 @@
return jp;
}
- private void addArgumentsFieldsAndAccessors() throws NotFoundException, CannotCompileException
- {
- OptimizedBehaviourInvocations.addArgumentFieldsToInvocation(jp, params);
- OptimizedBehaviourInvocations.addSetArguments(instrumentor.getClassPool(), jp, params);
- OptimizedBehaviourInvocations.addGetArguments(instrumentor.getClassPool(), jp, params);
- }
-
private void addTypedTargetField()throws CannotCompileException
{
CtField targetField = new CtField(targetClass, TARGET_FIELD, jp);
Modified: projects/aop/trunk/aop/src/main/org/jboss/aop/instrument/MethodByMethodJoinPointGenerator.java
===================================================================
--- projects/aop/trunk/aop/src/main/org/jboss/aop/instrument/MethodByMethodJoinPointGenerator.java 2007-01-29 17:24:22 UTC (rev 60104)
+++ projects/aop/trunk/aop/src/main/org/jboss/aop/instrument/MethodByMethodJoinPointGenerator.java 2007-01-29 17:52:09 UTC (rev 60105)
@@ -233,7 +233,8 @@
protected CtClass generate() throws CannotCompileException, NotFoundException
{
jp = setupClass();
- addArgumentsFieldsAndAccessors();
+ OptimizedBehaviourInvocations.addArgumentFieldsAndAccessors(
+ instrumentor.getClassPool(), jp, params, false);
if (hasTargetObject)
{
addTypedTargetField();
@@ -264,13 +265,6 @@
return jp;
}
- private void addArgumentsFieldsAndAccessors() throws NotFoundException, CannotCompileException
- {
- OptimizedBehaviourInvocations.addArgumentFieldsToInvocation(jp, params);
- OptimizedBehaviourInvocations.addSetArguments(instrumentor.getClassPool(), jp, params);
- OptimizedBehaviourInvocations.addGetArguments(instrumentor.getClassPool(), jp, params);
- }
-
private void addTypedTargetField()throws CannotCompileException
{
CtField targetField = new CtField(targetClass, TARGET_FIELD, jp);
Modified: projects/aop/trunk/aop/src/main/org/jboss/aop/instrument/MethodJoinPointGenerator.java
===================================================================
--- projects/aop/trunk/aop/src/main/org/jboss/aop/instrument/MethodJoinPointGenerator.java 2007-01-29 17:24:22 UTC (rev 60104)
+++ projects/aop/trunk/aop/src/main/org/jboss/aop/instrument/MethodJoinPointGenerator.java 2007-01-29 17:52:09 UTC (rev 60105)
@@ -206,7 +206,9 @@
protected CtClass generate() throws CannotCompileException, NotFoundException
{
jp = setupClass();
- addArgumentsFieldsAndAccessors();
+ // We might be marshalled so add special get arguments code
+ OptimizedBehaviourInvocations.addArgumentFieldsAndAccessors(
+ instrumentor.getClassPool(), jp, originalParams, true);
if (hasTargetObject)
{
addTypedTargetField();
@@ -238,14 +240,6 @@
return jp;
}
-
- private void addArgumentsFieldsAndAccessors() throws NotFoundException, CannotCompileException
- {
- OptimizedBehaviourInvocations.addArgumentFieldsToInvocation(jp, originalParams);
- OptimizedBehaviourInvocations.addSetArguments(instrumentor.getClassPool(), jp, originalParams);
- //We might be marshalled so add special get arguments code
- OptimizedBehaviourInvocations.addGetArguments(instrumentor.getClassPool(), jp, originalParams, true);
- }
private void addTypedTargetField()throws CannotCompileException
{
Modified: projects/aop/trunk/aop/src/main/org/jboss/aop/instrument/OptimizedBehaviourInvocations.java
===================================================================
--- projects/aop/trunk/aop/src/main/org/jboss/aop/instrument/OptimizedBehaviourInvocations.java 2007-01-29 17:24:22 UTC (rev 60104)
+++ projects/aop/trunk/aop/src/main/org/jboss/aop/instrument/OptimizedBehaviourInvocations.java 2007-01-29 17:52:09 UTC (rev 60105)
@@ -31,6 +31,8 @@
import javassist.Modifier;
import javassist.NotFoundException;
+import org.jboss.aop.util.JavassistToReflect;
+
/**
* Comment
*
@@ -39,42 +41,155 @@
*/
public abstract class OptimizedBehaviourInvocations extends OptimizedInvocations
{
- protected static void addSetArguments(ClassPool pool, CtClass invocation, CtClass[] params)throws NotFoundException, CannotCompileException
+ /**
+ * Returns a piece of code that sets all typed argument fields to the
+ * parameter values of current behaviour (i.e., arg0 = $1; arg1 = $2...).
+ *
+ * @param length number of arguments
+ * @return the code that sets all argument fields to the values of current
+ * behaviour parameters
+ */
+ protected static String setArguments(int length)
{
+ return setArguments("invocation", length, 0);
+ }
+
+ /**
+ * Adds typed argument fields to <code>invocation</code> and overwrites its
+ * arguments accessor methods accordingly.
+ *
+ * @param pool the class pool that contains <code>invocation
+ * <code>
+ * @param invocation the invocation class to which fields and methods
+ * will be added
+ * @param params the list of the parameter types
+ * @param hasMarshalledArguments indicates whether this invocation class has a
+ * marshalled arguments field
+ */
+ protected static void addArgumentFieldsAndAccessors(ClassPool pool,
+ CtClass invocation, CtClass[] params, boolean hasMarshalledArguments)
+ throws NotFoundException, CannotCompileException
+ {
+ addArgumentFieldsToInvocation(invocation, params);
+ addGetArguments(pool, invocation, params, hasMarshalledArguments);
+ addSetArguments(pool, invocation, params);
+ }
+
+ protected static void addInvokeTarget(CtClass invocation, String dispatchLine,
+ CtClass[] params, String beforeDispatch, String afterDispatch)
+ throws NotFoundException, CannotCompileException
+ {
+ StringBuffer sb = new StringBuffer("{");
+ sb.append(beforeDispatch);
+ if (params.length == 0)
+ {
+ sb.append(dispatchLine);
+ sb.append("();");
+ }
+ else
+ {
+ sb.append(" if (inconsistentArgs){");
+ sb.append(dispatchLine);
+ sb.append('(');
+ sb.append(JavassistToReflect.castInvocationValueToTypeString(params[0], "arguments[0]"));
+ for (int i = 1; i < params.length; i++)
+ {
+ sb.append(", ");
+ sb.append(JavassistToReflect.castInvocationValueToTypeString(params[i],
+ "arguments[" + i + "]"));
+ }
+ sb.append(");} else {");
+ sb.append(dispatchLine);
+ sb.append("(arg0");
+ for (int i = 1; i < params.length; i++)
+ {
+ sb.append(", ");
+ sb.append("arg");
+ sb.append(i);
+ }
+ sb.append(");} ");
+ }
+ sb.append(afterDispatch);
+ sb.append("}");
+ System.out.println("CODE: " + sb.toString());
+ CtMethod invokeTarget = null;
+ CtMethod in = invocation.getSuperclass().getDeclaredMethod("invokeTarget");
+ try
+ {
+ invokeTarget = CtNewMethod.make(in.getReturnType(), "invokeTarget",
+ in.getParameterTypes(), in.getExceptionTypes(), sb.toString(),
+ invocation);
+ }
+ catch (CannotCompileException e)
+ {
+ System.out.println(sb.toString());
+ throw e;
+ }
+ invokeTarget.setModifiers(in.getModifiers());
+ invocation.addMethod(invokeTarget);
+ }
+
+ private static String setArguments(String inv, int length, int offset)
+ {
+ StringBuffer sb = new StringBuffer("");
+ for (int i = 0 ; i < length ; i++)
+ {
+ sb.append(inv + ".arg" + (i) + " = $" + (i + 1 + offset) + "; ");
+ }
+ return sb.toString();
+ }
+
+
+ private static void addSetArguments(ClassPool pool, CtClass invocation, CtClass[] params)throws NotFoundException, CannotCompileException
+ {
if (params == null || params.length == 0) return;
CtClass methodInvocation = pool.get("org.jboss.aop.joinpoint.MethodInvocation");
CtMethod template = methodInvocation.getDeclaredMethod("setArguments");
- String code =
- "public void setArguments(java.lang.Object[] args)" +
- "{ ";
- code += " arguments = args; ";
+ StringBuffer code = new StringBuffer(
+ "public void setArguments(java.lang.Object[] args){");
+ code.append(" inconsistentArgs = false;");
+ code.append(" arguments = args; ");
for (int i = 0; i < params.length; i++)
{
if (params[i].isPrimitive())
{
CtPrimitiveType primitive = (CtPrimitiveType) params[i];
- code += " arg" + i + " = ((" + primitive.getWrapperName() + ")args[" + i + "])." + primitive.getGetMethodName() + "(); ";
+ code.append(" arg");
+ code.append(i);
+ code.append(" = ((");
+ code.append(primitive.getWrapperName());
+ code.append(")args[");
+ code.append(i);
+ code.append("]).");
+ code.append(primitive.getGetMethodName());
+ code.append("(); ");
}
else
{
- code += " Object warg" + i + " = args[" + i + "]; ";
- code += " arg" + i + " = (" + params[i].getName() + ")warg" + i + "; ";
+ code.append(" Object warg");
+ code.append(i);
+ code.append(" = args[");
+ code.append(i);
+ code.append("]; ");
+ code.append(" arg");
+ code.append(i);
+ code.append(" = (");
+ code.append(params[i].getName());
+ code.append(")warg");
+ code.append(i);
+ code.append("; ");
}
}
- code += "}";
- CtMethod setArguments = CtNewMethod.make(code, invocation);
+ code.append(" inconsistentArgs = false;");
+ code.append("}");
+ CtMethod setArguments = CtNewMethod.make(code.toString(), invocation);
setArguments.setModifiers(template.getModifiers());
invocation.addMethod(setArguments);
}
- public static void addGetArguments(ClassPool pool, CtClass invocation, CtClass[] params) throws CannotCompileException
+ private static void addGetArguments(ClassPool pool, CtClass invocation, CtClass[] params, boolean hasMarshalledArguments) throws CannotCompileException
{
- addGetArguments(pool, invocation, params, false);
- }
-
- public static void addGetArguments(ClassPool pool, CtClass invocation, CtClass[] params, boolean hasMarshalledArguments) throws CannotCompileException
- {
if (params == null || params.length == 0) return;
try {
CtClass superInvocation = invocation.getSuperclass();
@@ -83,7 +198,7 @@
StringBuffer code = new StringBuffer();
code.append("public Object[] getArguments()");
code.append("{ ");
-
+ code.append(" inconsistentArgs = true;");
if (hasMarshalledArguments)
{
code.append(" if (super.marshalledArguments != null)");
@@ -110,29 +225,18 @@
}
}
- protected static String setArguments(int length)
- {
- return setArguments("invocation", length, 0);
- }
-
- protected static String setArguments(String inv, int length, int offset)
- {
- StringBuffer sb = new StringBuffer("");
- for (int i = 0 ; i < length ; i++)
- {
- sb.append(inv + ".arg" + (i) + " = $" + (i + 1 + offset) + "; ");
- }
- return sb.toString();
- }
-
/** Adds fields arg0, arg1 etc. to the invocation class for storing the parameters for a method
*
* @param invocation The invocation we want to add
* @param params Array of the types of the parameters
* @throws CannotCompileException
*/
- public static void addArgumentFieldsToInvocation(CtClass invocation, CtClass[] params)throws CannotCompileException
+ private static void addArgumentFieldsToInvocation(CtClass invocation, CtClass[] params)throws CannotCompileException
{
+ CtField inconsistentArgs = new CtField(CtClass.booleanType, "inconsistentArgs",
+ invocation);
+ invocation.addField(inconsistentArgs, CtField.Initializer.byExpr("false"));
+
for (int i = 0 ; i < params.length ; i++)
{
CtField field = new CtField(params[i], "arg" + i, invocation);
@@ -140,4 +244,4 @@
invocation.addField(field);
}
}
-}
+}
\ No newline at end of file
Modified: projects/aop/trunk/aop/src/main/org/jboss/aop/instrument/OptimizedCallerInvocations.java
===================================================================
--- projects/aop/trunk/aop/src/main/org/jboss/aop/instrument/OptimizedCallerInvocations.java 2007-01-29 17:24:22 UTC (rev 60104)
+++ projects/aop/trunk/aop/src/main/org/jboss/aop/instrument/OptimizedCallerInvocations.java 2007-01-29 17:52:09 UTC (rev 60105)
@@ -50,121 +50,24 @@
int callingIndex,
long calledHash) throws NotFoundException, CannotCompileException
{
- AOPClassPool pool = (AOPClassPool) instrumentor.getClassPool();
- CtClass methodInvocation = pool.get("org.jboss.aop.joinpoint.MethodCalledByConstructorInvocation");
+ return createOptimizedMethodCalledInvocationClass(
+ instrumentor, className, callingClass, method,
+ "org.jboss.aop.joinpoint.MethodCalledByConstructorInvocation",
+ "this.calling, ");
+ }
- ////////////////
- //Create the class
- boolean makeInnerClass = Modifier.isPrivate(method.getModifiers());
- CtClass invocation = makeInvocationClass(pool, makeInnerClass, callingClass, className, methodInvocation);
-
- CtClass[] params = method.getParameterTypes();
- addArgumentFieldsToInvocation(invocation, params);
-
- /////////
- //Create invokeTarget() body
- boolean isStatic = javassist.Modifier.isStatic(method.getModifiers());
- if (!isStatic)
- {
- CtField target = new CtField(method.getDeclaringClass(), "typedTargetObject", invocation);
- target.setModifiers(Modifier.PUBLIC);
- invocation.addField(target);
- }
-
-
- CtMethod in = methodInvocation.getDeclaredMethod("invokeTarget");
-
- String code = "{";
-
- String returnStr = (method.getReturnType().equals(CtClass.voidType)) ? "" : "return ($w)";
- if (isStatic)
- {
- code +=
- " " + returnStr + " " + method.getDeclaringClass().getName() + ".";
- }
- else
- {
- code +=
- " " + returnStr + " typedTargetObject.";
- }
- code += method.getName() + "(";
- for (int i = 0; i < params.length; i++)
- {
- if (i > 0) code += ", ";
- code += "arg" + i;
- }
- code += "); ";
- if (method.getReturnType().equals(CtClass.voidType))
- {
- code += " return null; ";
- }
- code += "}";
- CtMethod invokeTarget = null;
- try
- {
- invokeTarget = CtNewMethod.make(in.getReturnType(), "invokeTarget", in.getParameterTypes(), in.getExceptionTypes(), code, invocation);
- }
- catch (CannotCompileException e)
- {
- System.out.println(code);
- throw e;
- }
- invokeTarget.setModifiers(in.getModifiers());
- invocation.addMethod(invokeTarget);
- addGetArguments(pool, invocation, method.getParameterTypes());
- addSetArguments(pool, invocation, method.getParameterTypes());
-
-
- ////////////
- //Create copy() method
- CtMethod copyTemplate = methodInvocation.getDeclaredMethod("copy");
-
- String copyCode = "{ "
- + " "
- + invocation.getName()
- + " wrapper = new "
- + invocation.getName()
- + "(this.advisor, this.calling, this.method, this.callingObject, this.targetObject, this.arguments, this.interceptors);"
- + " wrapper.metadata = this.metadata; "
- + " wrapper.currentInterceptor = this.currentInterceptor; "
- + " wrapper.instanceResolver = this.instanceResolver; "
- + " wrapper.targetObject = this.targetObject; "
- + " wrapper.responseContextInfo = this.responseContextInfo; ";
-
- if (!isStatic)
- {
- copyCode += "wrapper.typedTargetObject = typedTargetObject;";
- }
-
- for (int i = 0; i < params.length; i++)
- {
- copyCode += " wrapper.arg" + i + " = this.arg" + i + "; ";
- }
- copyCode += " return wrapper; }";
-
- CtMethod copy = null;
- try
- {
- copy = CtNewMethod.make(
- copyTemplate.getReturnType(),
- "copy",
- copyTemplate.getParameterTypes(),
- copyTemplate.getExceptionTypes(),
- copyCode,
- invocation);
- }
- catch (CannotCompileException e)
- {
- System.out.println(copyCode);
- throw e;
- }
- copy.setModifiers(copyTemplate.getModifiers());
- invocation.addMethod(copy);
-
- TransformerCommon.compileOrLoadClass(callingClass, invocation);
-
- //Return fully qualified name of class (may be an inner class)
- return invocation.getName();
+ protected static String createOptimizedMethodCalledByMethodInvocationClass(
+ Instrumentor instrumentor,
+ String className,
+ CtClass callingClass,
+ CtMethod method,
+ long callingHash,
+ long calledHash) throws NotFoundException, CannotCompileException
+ {
+ return createOptimizedMethodCalledInvocationClass(
+ instrumentor, className, callingClass, method,
+ "org.jboss.aop.joinpoint.MethodCalledByMethodInvocation",
+ "this.callingClass, this.callingMethod, ");
}
protected static String createOptimizedConCalledByConInvocationClass(
@@ -175,307 +78,153 @@
int callingIndex,
long calledHash) throws NotFoundException, CannotCompileException
{
- //TODO: Merge this method with createOptimizedConCalledByMethodInvocationClass()
+ return createOptimizedConCalledInvocationClass(
+ instrumentor, className, callingClass, con,
+ "org.jboss.aop.joinpoint.ConstructorCalledByConstructorInvocation",
+ "this.calling, ");
+ }
+
+ protected static String createOptimizedConCalledByMethodInvocationClass(
+ Instrumentor instrumentor,
+ String className,
+ CtClass callingClass,
+ CtConstructor con,
+ long callingHash,
+ long calledHash) throws NotFoundException, CannotCompileException
+ {
+ return createOptimizedConCalledInvocationClass(
+ instrumentor, className, callingClass, con,
+ "org.jboss.aop.joinpoint.ConstructorCalledByMethodInvocation",
+ "this.callingClass, this.callingMethod, ");
+ }
+
+ private static String createOptimizedMethodCalledInvocationClass(
+ Instrumentor instrumentor, String className, CtClass callingClass,
+ CtMethod method, String invocationClassName, String callerDescription)
+ throws NotFoundException, CannotCompileException
+ {
AOPClassPool pool = (AOPClassPool) instrumentor.getClassPool();
- CtClass conInvocation = pool.get("org.jboss.aop.joinpoint.ConstructorCalledByConstructorInvocation");
+ CtClass methodInvocation = pool.get(invocationClassName);
////////////////
//Create the class
- //String className = getOptimizedConCalledByConInvocationClassName(callingIndex, callingClass.getName(), calledHash);
- boolean makeInnerClass = Modifier.isPrivate(con.getModifiers());
- CtClass invocation = makeInvocationClass(pool, makeInnerClass, callingClass, className, conInvocation);
+ CtClass invocation = makeInvocationClass(pool,
+ Modifier.isPrivate(method.getModifiers()), callingClass, className,
+ methodInvocation);
- CtClass[] params = con.getParameterTypes();
- addArgumentFieldsToInvocation(invocation, params);
-
- /////////
- //Create invokeTarget() body
- CtMethod in = conInvocation.getDeclaredMethod("invokeTarget");
-
- String code = "{";
-
- code += "setTargetObject(new " + con.getDeclaringClass().getName() + "(";
- for (int i = 0; i < params.length; i++)
+ ////////////////
+ //Add typed fields
+ CtClass[] params = method.getParameterTypes();
+ addArgumentFieldsAndAccessors(pool, invocation, params, false);
+ boolean isStatic = javassist.Modifier.isStatic(method.getModifiers());
+ if (!isStatic)
{
- if (i > 0) code += ", ";
- code += "arg" + i;
+ CtField target = new CtField(
+ method.getDeclaringClass(), "typedTargetObject", invocation);
+ target.setModifiers(Modifier.PUBLIC);
+ invocation.addField(target);
}
- code += ")); ";
- code += "return getTargetObject();";
- code += "}";
- CtMethod invokeTarget = null;
- try
+ /////////
+ //Create invokeTarget() body
+ StringBuffer dispatchLine = new StringBuffer();
+ boolean isVoid = method.getReturnType().equals(CtClass.voidType);
+ if (!isVoid)
{
- invokeTarget = CtNewMethod.make(
- in.getReturnType(),
- "invokeTarget",
- in.getParameterTypes(),
- in.getExceptionTypes(),
- code,
- invocation);
+ dispatchLine.append("return ($w)");
}
- catch (Exception e)
- {
- throw new RuntimeException("code: " + code, e);
- }
- invokeTarget.setModifiers(in.getModifiers());
- invocation.addMethod(invokeTarget);
- addGetArguments(pool, invocation, con.getParameterTypes());
- addSetArguments(pool, invocation, con.getParameterTypes());
+ dispatchLine.append((isStatic? (method.getDeclaringClass().getName()):
+ " typedTargetObject") + '.' + method.getName());
+ addInvokeTarget(invocation, dispatchLine.toString(),
+ method.getParameterTypes(), "", isVoid?" return null;": "");
- ////////////
+ ////////////////
//Create copy() method
- CtMethod copyTemplate = conInvocation.getDeclaredMethod("copy");
-
- String copyCode = "{ "
- + " "
- + invocation.getName()
- + " wrapper = new "
- + invocation.getName()
- + "(this.advisor, this.calling, this.constructor, this.wrappingMethod, this.callingObject, this.arguments, this.interceptors);"
- + " wrapper.metadata = super.metadata; "
- + " wrapper.currentInterceptor = super.currentInterceptor; "
- + " wrapper.instanceResolver = super.instanceResolver; "
- + " wrapper.interceptors = super.interceptors; "
- + " wrapper.responseContextInfo = super.responseContextInfo; "
- + " wrapper.targetObject = super.targetObject; ";
-
- for (int i = 0; i < params.length; i++)
+ String copy = "";
+ if (!Modifier.isStatic(method.getModifiers()))
{
- copyCode += " wrapper.arg" + i + " = this.arg" + i + "; ";
+ copy = "wrapper.typedTargetObject = typedTargetObject;";
}
- copyCode += " return wrapper; }";
-
- CtMethod copy = null;
- try
- {
- copy = CtNewMethod.make(
- copyTemplate.getReturnType(),
- "copy",
- copyTemplate.getParameterTypes(),
- copyTemplate.getExceptionTypes(),
- copyCode,
- invocation);
- }
- catch (Exception e)
- {
- throw new RuntimeException("code: " + code, e);
- }
- copy.setModifiers(copyTemplate.getModifiers());
- invocation.addMethod(copy);
-
+ addCopyMethod(invocation, callerDescription,
+ "this.method, this.callingObject, this.targetObject, ", copy,
+ params.length);
+
+ /////////
+ //Compile/Load
TransformerCommon.compileOrLoadClass(callingClass, invocation);
-
+
//Return fully qualified name of class (may be an inner class)
return invocation.getName();
}
-
- protected static String createOptimizedConCalledByMethodInvocationClass(
- Instrumentor instrumentor,
- String className,
- CtClass callingClass,
- CtConstructor con,
- long callingHash,
- long calledHash) throws NotFoundException, CannotCompileException
+
+ private static String createOptimizedConCalledInvocationClass(
+ Instrumentor instrumentor, String className, CtClass callingClass,
+ CtConstructor con, String invocationClassName, String callerDescription)
+ throws NotFoundException, CannotCompileException
{
AOPClassPool pool = (AOPClassPool) instrumentor.getClassPool();
- CtClass conInvocation = pool.get("org.jboss.aop.joinpoint.ConstructorCalledByMethodInvocation");
+ CtClass conInvocation = pool.get(invocationClassName);
////////////////
//Create the class
- boolean makeInnerClass = Modifier.isPrivate(con.getModifiers());
- CtClass invocation = makeInvocationClass(pool, makeInnerClass, callingClass, className, conInvocation);
+ CtClass invocation = makeInvocationClass(pool,
+ Modifier.isPrivate(con.getModifiers()), callingClass, className,
+ conInvocation);
+ ////////////////
+ //Add typed fields
CtClass[] params = con.getParameterTypes();
- addArgumentFieldsToInvocation(invocation, params);
-
+ addArgumentFieldsAndAccessors(pool, invocation, params, false);
+
/////////
//Create invokeTarget() body
- CtMethod in = conInvocation.getDeclaredMethod("invokeTarget");
+ StringBuffer dispatchLine = new StringBuffer(" result = new ");
+ dispatchLine.append(con.getDeclaringClass().getName());
+ OptimizedBehaviourInvocations.addInvokeTarget(invocation,
+ dispatchLine.toString(), con.getParameterTypes(),
+ "Object result = null;", " setTargetObject(result); return result;");
- String code = "{";
- code += "setTargetObject(new " + con.getDeclaringClass().getName() + "(";
- for (int i = 0; i < params.length; i++)
- {
- if (i > 0) code += ", ";
- code += "arg" + i;
- }
- code += ")); ";
- code += "return getTargetObject();";
- code += "}";
-
- CtMethod invokeTarget = null;
- try
- {
- invokeTarget = CtNewMethod.make(
- in.getReturnType(),
- "invokeTarget",
- in.getParameterTypes(),
- in.getExceptionTypes(),
- code,
- invocation);
- }
- catch (CannotCompileException e)
- {
- System.out.println(code);
- throw e;
- }
+ ////////////////
+ //Create copy() method
+ addCopyMethod(invocation, callerDescription,
+ "this.constructor, this.wrappingMethod, this.callingObject, ", "",
+ params.length);
- invokeTarget.setModifiers(in.getModifiers());
+ ////////////////
+ //Compile/Load
+ TransformerCommon.compileOrLoadClass(callingClass, invocation);
+
+ //Return fully qualified name of class (may be an inner class)
+ return invocation.getName();
+ }
- invocation.addMethod(invokeTarget);
- addGetArguments(pool, invocation, con.getParameterTypes());
- addSetArguments(pool, invocation, con.getParameterTypes());
-
- ////////////
- //Create copy() method
- CtMethod copyTemplate = conInvocation.getDeclaredMethod("copy");
+ private static void addCopyMethod(CtClass invocation, String callerDescription,
+ String calledDescription, String copyText, int paramsLength)
+ throws NotFoundException, CannotCompileException
+ {
+ CtMethod copyTemplate = invocation.getSuperclass().getDeclaredMethod("copy");
+
String copyCode = "{ "
+ " "
+ invocation.getName()
+ " wrapper = new "
+ invocation.getName()
- + "(this.advisor, this.callingClass, this.callingMethod, this.constructor, this.wrappingMethod, this.callingObject, this.arguments, this.interceptors);"
+ + "(this.advisor, " + callerDescription + calledDescription + "this.arguments, this.interceptors);"
+ + " wrapper.interceptors = super.interceptors; "
+ " wrapper.metadata = this.metadata; "
+ " wrapper.currentInterceptor = this.currentInterceptor; "
+ " wrapper.instanceResolver = this.instanceResolver; "
+ " wrapper.targetObject = this.targetObject; "
- + " wrapper.responseContextInfo = this.responseContextInfo; ";
+ + " wrapper.responseContextInfo = this.responseContextInfo; "
+ + copyText;
- for (int i = 0; i < params.length; i++)
+ for (int i = 0; i < paramsLength; i++)
{
copyCode += " wrapper.arg" + i + " = this.arg" + i + "; ";
}
copyCode += " return wrapper; }";
-
- CtMethod copy = null;
- try
- {
- copy = CtNewMethod.make(
- copyTemplate.getReturnType(),
- "copy",
- copyTemplate.getParameterTypes(),
- copyTemplate.getExceptionTypes(),
- copyCode,
- invocation);
- }
- catch (CannotCompileException e)
- {
- System.out.println(copyCode);
- throw e;
- }
- copy.setModifiers(copyTemplate.getModifiers());
-
- invocation.addMethod(copy);
-
- TransformerCommon.compileOrLoadClass(callingClass, invocation);
- //Return fully qualified name of class (may be an inner class)
- return invocation.getName();
- }
-
- protected static String createOptimizedMethodCalledByMethodInvocationClass(
- Instrumentor instrumentor,
- String className,
- CtClass callingClass,
- CtMethod method,
- long callingHash,
- long calledHash) throws NotFoundException, CannotCompileException
- {
- AOPClassPool pool = (AOPClassPool) instrumentor.getClassPool();
- CtClass methodInvocation = pool.get("org.jboss.aop.joinpoint.MethodCalledByMethodInvocation");
-
- ////////////////
- //Create the class
- boolean makeInnerClass = Modifier.isPrivate(method.getModifiers());
- CtClass invocation = makeInvocationClass(pool, makeInnerClass, callingClass, className, methodInvocation);
-
- CtClass[] params = method.getParameterTypes();
- addArgumentFieldsToInvocation(invocation, params);
-
- /////////
- //Create invokeTarget() body
- boolean isStatic = javassist.Modifier.isStatic(method.getModifiers());
- if (!isStatic)
- {
- CtField target = new CtField(method.getDeclaringClass(), "typedTargetObject", invocation);
- target.setModifiers(Modifier.PUBLIC);
- invocation.addField(target);
- }
-
-
- CtMethod in = methodInvocation.getDeclaredMethod("invokeTarget");
-
- String code = "{";
-
- String returnStr = (method.getReturnType().equals(CtClass.voidType)) ? "" : "return ($w)";
- if (isStatic)
- {
- code +=
- " " + returnStr + " " + method.getDeclaringClass().getName() + ".";
- }
- else
- {
- code +=
- " " + returnStr + " typedTargetObject.";
- }
- code += method.getName() + "(";
- for (int i = 0; i < params.length; i++)
- {
- if (i > 0) code += ", ";
- code += "arg" + i;
- }
- code += "); ";
- if (method.getReturnType().equals(CtClass.voidType))
- {
- code += " return null; ";
- }
- code += "}";
-
- CtMethod invokeTarget = null;
- try
- {
- invokeTarget = CtNewMethod.make(in.getReturnType(), "invokeTarget", in.getParameterTypes(), in.getExceptionTypes(), code, invocation);
- }
- catch (CannotCompileException e)
- {
- System.out.println(code);
- throw e;
- }
- invokeTarget.setModifiers(in.getModifiers());
- invocation.addMethod(invokeTarget);
- addGetArguments(pool, invocation, method.getParameterTypes());
- addSetArguments(pool, invocation, method.getParameterTypes());
-
- ////////////
- //Create copy() method
- CtMethod copyTemplate = methodInvocation.getDeclaredMethod("copy");
-
- String copyCode = "{ "
- + " "
- + invocation.getName()
- + " wrapper = new "
- + invocation.getName()
- + "(this.advisor, this.callingClass, this.callingMethod, this.method, this.callingObject, this.targetObject, this.arguments, this.interceptors);"
- + " wrapper.metadata = this.metadata; "
- + " wrapper.currentInterceptor = this.currentInterceptor; "
- + " wrapper.instanceResolver = this.instanceResolver; "
- + " wrapper.targetObject = this.targetObject; "
- + " wrapper.responseContextInfo = this.responseContextInfo; ";
-
- if (!isStatic)
- {
- copyCode += "wrapper.typedTargetObject = typedTargetObject;";
- }
-
- for (int i = 0; i < params.length; i++)
- {
- copyCode += " wrapper.arg" + i + " = this.arg" + i + "; ";
- }
- copyCode += " return wrapper; }";
-
CtMethod copy = null;
try
{
@@ -494,11 +243,5 @@
}
copy.setModifiers(copyTemplate.getModifiers());
invocation.addMethod(copy);
-
- TransformerCommon.compileOrLoadClass(callingClass, invocation);
-
- //Return fully qualified name of class (may be an inner class)
- return invocation.getName();
}
-
-}
+}
\ No newline at end of file
Modified: projects/aop/trunk/aop/src/main/org/jboss/aop/instrument/OptimizedConstructionInvocations.java
===================================================================
--- projects/aop/trunk/aop/src/main/org/jboss/aop/instrument/OptimizedConstructionInvocations.java 2007-01-29 17:24:22 UTC (rev 60104)
+++ projects/aop/trunk/aop/src/main/org/jboss/aop/instrument/OptimizedConstructionInvocations.java 2007-01-29 17:52:09 UTC (rev 60105)
@@ -22,17 +22,16 @@
package org.jboss.aop.instrument;
-import org.jboss.aop.classpool.AOPClassPool;
-
import javassist.ClassPool;
import javassist.CtClass;
import javassist.CtConstructor;
-import javassist.CtField;
import javassist.CtMethod;
import javassist.CtNewConstructor;
import javassist.CtNewMethod;
import javassist.Modifier;
+import org.jboss.aop.classpool.AOPClassPool;
+
/**
* Comment
*
@@ -81,8 +80,7 @@
{
AOPClassPool pool = (AOPClassPool) instrumentor.getClassPool();
CtClass conInvocation = pool.get("org.jboss.aop.joinpoint.ConstructionInvocation");
- CtClass untransformable = pool.get("org.jboss.aop.instrument.Untransformable");
-
+
String className = getOptimizedInvocationClassName(clazz, index);
boolean makeInnerClass = !Modifier.isPublic(con.getModifiers());
@@ -101,15 +99,7 @@
CtConstructor icon = CtNewConstructor.make(template.getParameterTypes(), template.getExceptionTypes(), invocation);
invocation.addConstructor(icon);
- CtClass[] params = con.getParameterTypes();
- for (int i = 0; i < params.length; i++)
- {
- CtField field = new CtField(params[i], "arg" + i, invocation);
- field.setModifiers(Modifier.PUBLIC);
- invocation.addField(field);
- }
-
- addGetArguments(pool, invocation, con.getParameterTypes());
+ addArgumentFieldsAndAccessors(pool, invocation, con.getParameterTypes(), false);
addCopy(pool, invocation, con.getParameterTypes());
// If compile time
TransformerCommon.compileOrLoadClass(con.getDeclaringClass(), invocation);
Modified: projects/aop/trunk/aop/src/main/org/jboss/aop/instrument/OptimizedConstructorInvocations.java
===================================================================
--- projects/aop/trunk/aop/src/main/org/jboss/aop/instrument/OptimizedConstructorInvocations.java 2007-01-29 17:24:22 UTC (rev 60104)
+++ projects/aop/trunk/aop/src/main/org/jboss/aop/instrument/OptimizedConstructorInvocations.java 2007-01-29 17:52:09 UTC (rev 60105)
@@ -21,25 +21,18 @@
*/
package org.jboss.aop.instrument;
-import java.io.File;
-import java.io.FileOutputStream;
-import java.net.URI;
-import java.net.URL;
-
-import org.jboss.aop.classpool.AOPClassPool;
-import org.jboss.aop.standalone.Compiler;
-
import javassist.CannotCompileException;
import javassist.ClassPool;
import javassist.CtClass;
import javassist.CtConstructor;
-import javassist.CtField;
import javassist.CtMethod;
import javassist.CtNewConstructor;
import javassist.CtNewMethod;
import javassist.Modifier;
import javassist.NotFoundException;
+import org.jboss.aop.classpool.AOPClassPool;
+
/**
* Comment
*
@@ -64,7 +57,6 @@
{
AOPClassPool pool = (AOPClassPool) instrumentor.getClassPool();
CtClass conInvocation = pool.get("org.jboss.aop.joinpoint.ConstructorInvocation");
- CtClass untransformable = pool.get("org.jboss.aop.instrument.Untransformable");
String className = getOptimizedInvocationClassName(clazz, index);
boolean makeInnerClass = !Modifier.isPublic(con.getModifiers());
@@ -76,13 +68,9 @@
invocation.addConstructor(icon);
CtClass[] params = con.getParameterTypes();
- for (int i = 0; i < params.length; i++)
- {
- CtField field = new CtField(params[i], "arg" + i, invocation);
- field.setModifiers(Modifier.PUBLIC);
- invocation.addField(field);
- }
-
+ addArgumentFieldsAndAccessors(pool, invocation, params, false);
+
+
CtMethod in = conInvocation.getDeclaredMethod("invokeTarget");
StringBuffer code = new StringBuffer("{") ;
@@ -110,7 +98,6 @@
}
invocation.addMethod(invokeTarget);
invokeTarget.setModifiers(in.getModifiers());
- addGetArguments(pool, invocation, con.getParameterTypes());
addCopy(pool, invocation, con.getParameterTypes());
TransformerCommon.compileOrLoadClass(clazz, invocation);
Modified: projects/aop/trunk/aop/src/main/org/jboss/aop/instrument/OptimizedFieldInvocations.java
===================================================================
--- projects/aop/trunk/aop/src/main/org/jboss/aop/instrument/OptimizedFieldInvocations.java 2007-01-29 17:24:22 UTC (rev 60104)
+++ projects/aop/trunk/aop/src/main/org/jboss/aop/instrument/OptimizedFieldInvocations.java 2007-01-29 17:52:09 UTC (rev 60105)
@@ -176,7 +176,7 @@
{
//TODO: Must be a better way to do the cast of the value that what is done by castInvocationValueToTypeString()?
CtClass type = field.getType();
- code += ref + field.getName() + " = " + JavassistToReflect.castInvocationValueToTypeString(type) + " return null;";
+ code += ref + field.getName() + " = " + JavassistToReflect.castInvocationValueToTypeString(type) + "; return null;";
}
code += "}";
Modified: projects/aop/trunk/aop/src/main/org/jboss/aop/instrument/OptimizedMethodInvocations.java
===================================================================
--- projects/aop/trunk/aop/src/main/org/jboss/aop/instrument/OptimizedMethodInvocations.java 2007-01-29 17:24:22 UTC (rev 60104)
+++ projects/aop/trunk/aop/src/main/org/jboss/aop/instrument/OptimizedMethodInvocations.java 2007-01-29 17:52:09 UTC (rev 60105)
@@ -77,7 +77,7 @@
CtClass invocation = makeInvocationClass(pool, makeInnerClass, clazz, className, methodInvocation);
CtClass[] params = method.getParameterTypes();
- addArgumentFieldsToInvocation(invocation, params);
+ addArgumentFieldsAndAccessors(pool, invocation, params, true);
boolean isStatic = javassist.Modifier.isStatic(method.getModifiers());
if (!isStatic)
@@ -127,8 +127,8 @@
}
invokeTarget.setModifiers(in.getModifiers());
invocation.addMethod(invokeTarget);
- addSetArguments(pool, invocation, method.getParameterTypes());
- addGetArguments(pool, invocation, method.getParameterTypes(), true);
+
+
addCopy(pool, invocation, method.getParameterTypes(), isStatic);
TransformerCommon.compileOrLoadClass(method.getDeclaringClass(), invocation);
Modified: projects/aop/trunk/aop/src/main/org/jboss/aop/util/JavassistToReflect.java
===================================================================
--- projects/aop/trunk/aop/src/main/org/jboss/aop/util/JavassistToReflect.java 2007-01-29 17:24:22 UTC (rev 60104)
+++ projects/aop/trunk/aop/src/main/org/jboss/aop/util/JavassistToReflect.java 2007-01-29 17:52:09 UTC (rev 60105)
@@ -141,44 +141,44 @@
{
if (type.equals(CtClass.booleanType))
{
- cast = "((Boolean)" + valueName +").booleanValue();";
+ cast = "((Boolean)" + valueName +").booleanValue()";
}
else if (type.equals(CtClass.byteType))
{
- cast = "((Byte)" + valueName +").byteValue();";
+ cast = "((Byte)" + valueName +").byteValue()";
}
else if (type.equals(CtClass.charType))
{
- cast = "((Character)" + valueName +").charValue();";
+ cast = "((Character)" + valueName +").charValue()";
}
else if (type.equals(CtClass.doubleType))
{
- cast = "((Double)" + valueName +").doubleValue();";
+ cast = "((Double)" + valueName +").doubleValue()";
}
else if (type.equals(CtClass.floatType))
{
- cast = "((Float)" + valueName +").floatValue();";
+ cast = "((Float)" + valueName +").floatValue()";
}
else if (type.equals(CtClass.intType))
{
- cast = "((Integer)" + valueName +").intValue();";
+ cast = "((Integer)" + valueName +").intValue()";
}
else if (type.equals(CtClass.longType))
{
- cast = "((Long)" + valueName +").longValue();";
+ cast = "((Long)" + valueName +").longValue()";
}
else if (type.equals(CtClass.shortType))
{
- cast = "((Short)" + valueName +").shortValue();";
+ cast = "((Short)" + valueName +").shortValue()";
}
}
else if (type.isArray())
{
- cast = "(" + type.getName() + ")" + valueName +";";
+ cast = "(" + type.getName() + ")" + valueName;
}
else
{
- cast = "(" + type.getName() + ")" + valueName +";";
+ cast = "(" + type.getName() + ")" + valueName;
}
return cast;
More information about the jboss-cvs-commits
mailing list