[jboss-cvs] JBossAS SVN: r74279 - in projects/ejb3/trunk/proxy/src: test/java/org/jboss/ejb3/test/proxy/lang and 1 other directories.
jboss-cvs-commits at lists.jboss.org
jboss-cvs-commits at lists.jboss.org
Sat Jun 7 01:51:27 EDT 2008
Author: ALRubinger
Date: 2008-06-07 01:51:27 -0400 (Sat, 07 Jun 2008)
New Revision: 74279
Modified:
projects/ejb3/trunk/proxy/src/main/java/org/jboss/ejb3/proxy/lang/SerializableMethod.java
projects/ejb3/trunk/proxy/src/test/java/org/jboss/ejb3/test/proxy/lang/MyClass.java
projects/ejb3/trunk/proxy/src/test/java/org/jboss/ejb3/test/proxy/lang/unit/SerializableMethodTestCase.java
Log:
[EJBTHREE-1407] Bug Fixes for SerializableMethod
Modified: projects/ejb3/trunk/proxy/src/main/java/org/jboss/ejb3/proxy/lang/SerializableMethod.java
===================================================================
--- projects/ejb3/trunk/proxy/src/main/java/org/jboss/ejb3/proxy/lang/SerializableMethod.java 2008-06-07 05:22:53 UTC (rev 74278)
+++ projects/ejb3/trunk/proxy/src/main/java/org/jboss/ejb3/proxy/lang/SerializableMethod.java 2008-06-07 05:51:27 UTC (rev 74279)
@@ -185,16 +185,7 @@
List<Object> argTypesList = new ArrayList<Object>();
for (String argTypeName : this.getArgumentTypes())
{
- Class<?> argType = null;
- try
- {
- argType = cl.loadClass(argTypeName);
- }
- catch (ClassNotFoundException cnfe)
- {
- throw new RuntimeException("Could not load class defined as the invoking class, " + argTypeName + ", by "
- + cl, cnfe);
- }
+ Class<?> argType = this.getClassFromName(argTypeName, cl);
argTypesList.add(argType);
}
Class<?>[] argTypes = argTypesList.toArray(new Class<?>[]
@@ -236,24 +227,79 @@
*/
public Class<?> getClassType(ClassLoader cl)
{
+ // Obtain
+ Class<?> clazz = this.getClassFromName(this.getClassName(), cl);
+
+ // Return
+ return clazz;
+ }
+
+ /**
+ * Returns the class associated with the given name
+ *
+ * @param name
+ * @param cl
+ * @return
+ */
+ protected Class<?> getClassFromName(String name, ClassLoader cl)
+ {
// Perform assertions
assert cl != null : ClassLoader.class.getSimpleName() + "must be defined.";
+ /*
+ * Handle Primitives
+ */
+ if (name.equals(void.class.getName()))
+ {
+ return void.class;
+ }
+ if (name.equals(byte.class.getName()))
+ {
+ return byte.class;
+ }
+ if (name.equals(short.class.getName()))
+ {
+ return short.class;
+ }
+ if (name.equals(int.class.getName()))
+ {
+ return int.class;
+ }
+ if (name.equals(long.class.getName()))
+ {
+ return long.class;
+ }
+ if (name.equals(char.class.getName()))
+ {
+ return char.class;
+ }
+ if (name.equals(boolean.class.getName()))
+ {
+ return boolean.class;
+ }
+ if (name.equals(float.class.getName()))
+ {
+ return float.class;
+ }
+ if (name.equals(double.class.getName()))
+ {
+ return double.class;
+ }
+
// Load the Class described by the Method
- String invokingClassName = this.getClassName();
- Class<?> invokingClass = null;
+ Class<?> clazz = null;
+
try
{
- invokingClass = cl.loadClass(invokingClassName);
+ clazz = cl.loadClass(name);
}
catch (ClassNotFoundException cnfe)
{
- throw new RuntimeException("Specified calling class, " + invokingClassName + " could not be found for " + cl,
- cnfe);
+ throw new RuntimeException("Specified calling class, " + name + " could not be found for " + cl, cnfe);
}
// Return
- return invokingClass;
+ return clazz;
}
// ------------------------------------------------------------------------------||
Modified: projects/ejb3/trunk/proxy/src/test/java/org/jboss/ejb3/test/proxy/lang/MyClass.java
===================================================================
--- projects/ejb3/trunk/proxy/src/test/java/org/jboss/ejb3/test/proxy/lang/MyClass.java 2008-06-07 05:22:53 UTC (rev 74278)
+++ projects/ejb3/trunk/proxy/src/test/java/org/jboss/ejb3/test/proxy/lang/MyClass.java 2008-06-07 05:51:27 UTC (rev 74279)
@@ -12,6 +12,7 @@
* {@link SerializableMethod}
*
* @author Jaikiran Pai
+ * @author <a href="mailto:andrew.rubinger at jboss.org">ALR</a>
* @version $Revision: $
* @see {@link SerializableMethodTestCase}
*/
@@ -55,6 +56,21 @@
/**
*
+ * @param b
+ * @param s
+ * @param i
+ * @param l
+ * @param c
+ * @param f
+ * @param d
+ * @param b
+ */
+ public void methodWithPrimitiveParamsAndReturningVoid(byte b, short s, int i, long l, char c, float f, double d, boolean bo){
+ // Do Nothing
+ }
+
+ /**
+ *
* @param obj
*/
public void methodWithParamAndReturningVoid(Object obj)
Modified: projects/ejb3/trunk/proxy/src/test/java/org/jboss/ejb3/test/proxy/lang/unit/SerializableMethodTestCase.java
===================================================================
--- projects/ejb3/trunk/proxy/src/test/java/org/jboss/ejb3/test/proxy/lang/unit/SerializableMethodTestCase.java 2008-06-07 05:22:53 UTC (rev 74278)
+++ projects/ejb3/trunk/proxy/src/test/java/org/jboss/ejb3/test/proxy/lang/unit/SerializableMethodTestCase.java 2008-06-07 05:51:27 UTC (rev 74279)
@@ -51,7 +51,7 @@
// Intention of this test is to ensure that the methods accepting no parameter are handled correctly.
Method methodWithNoParamAndReturningVoid = myClass.getClass()
- .getMethod("methodWithNoParamAndReturningVoid", null);
+ .getMethod("methodWithNoParamAndReturningVoid", (Class<?>[])null);
SerializableMethod serializableMethod = new SerializableMethod(methodWithNoParamAndReturningVoid);
SerializableMethod anotherSerializableMethod = new SerializableMethod(methodWithNoParamAndReturningVoid);
@@ -190,8 +190,8 @@
// Test that the SerializableMethod instances created
// for a method with same name, param and return type, but belonging to different classes are NOT equal
- Method toStringMethodOfMyClass = myClass.getClass().getDeclaredMethod("toString", null);
- Method toStringMethodOfObject = Object.class.getDeclaredMethod("toString", null);
+ Method toStringMethodOfMyClass = myClass.getClass().getDeclaredMethod("toString", (Class<?>[]) null);
+ Method toStringMethodOfObject = Object.class.getDeclaredMethod("toString", (Class<?>[]) null);
SerializableMethod serializableMethod_toStringForMyClass = new SerializableMethod(toStringMethodOfMyClass);
SerializableMethod serializableMethod_toStringForThisTestCase = new SerializableMethod(toStringMethodOfObject);
@@ -268,8 +268,8 @@
// Note that this testcase should NOT override the toString method, to ensure that the getMethod() returns
// the 'Method' of Object.class
- Method toStringMethodOfThisClass = this.getClass().getMethod("toString", null);
- Method toStringMethodOfObject = Object.class.getMethod("toString", null);
+ Method toStringMethodOfThisClass = this.getClass().getMethod("toString", (Class<?>[]) null);
+ Method toStringMethodOfObject = Object.class.getMethod("toString", (Class<?>[]) null);
SerializableMethod serializableMethod_toStringOfThisClass = new SerializableMethod(toStringMethodOfThisClass);
SerializableMethod serializableMethod_toStringOfObjectClass = new SerializableMethod(toStringMethodOfObject);
@@ -414,8 +414,10 @@
logger.info("Testing the toMethod(), for methods accepting primitives");
- Method method = myClass.getClass().getMethod("methodWithParamAndReturningVoid", new Class[]
- {int.class});
+ Method method = myClass.getClass().getMethod(
+ "methodWithPrimitiveParamsAndReturningVoid",
+ new Class[]
+ {byte.class, short.class, int.class, long.class, char.class, float.class, double.class, boolean.class});
SerializableMethod serializableMethod = new SerializableMethod(method);
// invoke the toMethod()
Method copyOfMethod = serializableMethod.toMethod();
More information about the jboss-cvs-commits
mailing list