[jboss-cvs] JBossAS SVN: r102910 - in projects/jboss-reflect/trunk/src: main/java/org/jboss/reflect/plugins/javassist/bytecode and 5 other directories.
jboss-cvs-commits at lists.jboss.org
jboss-cvs-commits at lists.jboss.org
Wed Mar 24 12:48:30 EDT 2010
Author: kabir.khan at jboss.com
Date: 2010-03-24 12:48:26 -0400 (Wed, 24 Mar 2010)
New Revision: 102910
Added:
projects/jboss-reflect/trunk/src/main/java/org/jboss/reflect/plugins/javassist/bytecode/
projects/jboss-reflect/trunk/src/main/java/org/jboss/reflect/plugins/javassist/bytecode/JavassistBehaviorFactory.java
projects/jboss-reflect/trunk/src/main/java/org/jboss/reflect/plugins/javassist/bytecode/JavassistConstructorFactory.java
projects/jboss-reflect/trunk/src/main/java/org/jboss/reflect/plugins/javassist/bytecode/JavassistFieldFactory.java
projects/jboss-reflect/trunk/src/main/java/org/jboss/reflect/plugins/javassist/bytecode/JavassistMemberFactory.java
projects/jboss-reflect/trunk/src/main/java/org/jboss/reflect/plugins/javassist/bytecode/JavassistMethodFactory.java
projects/jboss-reflect/trunk/src/main/java/org/jboss/reflect/plugins/javassist/bytecode/SecurityActions.java
projects/jboss-reflect/trunk/src/test/java/org/jboss/test/plugins/javassist/bytecode/
projects/jboss-reflect/trunk/src/test/java/org/jboss/test/plugins/javassist/bytecode/support/
projects/jboss-reflect/trunk/src/test/java/org/jboss/test/plugins/javassist/bytecode/support/BeanInterface.java
projects/jboss-reflect/trunk/src/test/java/org/jboss/test/plugins/javassist/bytecode/support/PackageProtectedBoxedBean.java
projects/jboss-reflect/trunk/src/test/java/org/jboss/test/plugins/javassist/bytecode/support/PackageProtectedPrimitiveBean.java
projects/jboss-reflect/trunk/src/test/java/org/jboss/test/plugins/javassist/bytecode/support/PackageProtectedStaticBoxedBean.java
projects/jboss-reflect/trunk/src/test/java/org/jboss/test/plugins/javassist/bytecode/support/PackageProtectedStaticPrimitiveBean.java
projects/jboss-reflect/trunk/src/test/java/org/jboss/test/plugins/javassist/bytecode/support/PrivateBoxedBean.java
projects/jboss-reflect/trunk/src/test/java/org/jboss/test/plugins/javassist/bytecode/support/PrivatePrimitiveBean.java
projects/jboss-reflect/trunk/src/test/java/org/jboss/test/plugins/javassist/bytecode/support/PrivateStaticBoxedBean.java
projects/jboss-reflect/trunk/src/test/java/org/jboss/test/plugins/javassist/bytecode/support/PrivateStaticPrimitiveBean.java
projects/jboss-reflect/trunk/src/test/java/org/jboss/test/plugins/javassist/bytecode/support/ProtectedBoxedBean.java
projects/jboss-reflect/trunk/src/test/java/org/jboss/test/plugins/javassist/bytecode/support/ProtectedPrimitiveBean.java
projects/jboss-reflect/trunk/src/test/java/org/jboss/test/plugins/javassist/bytecode/support/ProtectedStaticBoxedBean.java
projects/jboss-reflect/trunk/src/test/java/org/jboss/test/plugins/javassist/bytecode/support/ProtectedStaticPrimitiveBean.java
projects/jboss-reflect/trunk/src/test/java/org/jboss/test/plugins/javassist/bytecode/support/PublicBoxedBean.java
projects/jboss-reflect/trunk/src/test/java/org/jboss/test/plugins/javassist/bytecode/support/PublicPrimitiveBean.java
projects/jboss-reflect/trunk/src/test/java/org/jboss/test/plugins/javassist/bytecode/support/PublicStaticBoxedBean.java
projects/jboss-reflect/trunk/src/test/java/org/jboss/test/plugins/javassist/bytecode/support/PublicStaticPrimitiveBean.java
projects/jboss-reflect/trunk/src/test/java/org/jboss/test/plugins/javassist/bytecode/test/
projects/jboss-reflect/trunk/src/test/java/org/jboss/test/plugins/javassist/bytecode/test/AbstractJavassistMemberAndConstructorFactoryTest.java
projects/jboss-reflect/trunk/src/test/java/org/jboss/test/plugins/javassist/bytecode/test/AbstractJavassistMemberFactoryTest.java
projects/jboss-reflect/trunk/src/test/java/org/jboss/test/plugins/javassist/bytecode/test/JavassistMemberFactoryPackageProtectedBoxedUnitTestCase.java
projects/jboss-reflect/trunk/src/test/java/org/jboss/test/plugins/javassist/bytecode/test/JavassistMemberFactoryPackageProtectedPrimitiveUnitTestCase.java
projects/jboss-reflect/trunk/src/test/java/org/jboss/test/plugins/javassist/bytecode/test/JavassistMemberFactoryPackageProtectedStaticBoxedUnitTestCase.java
projects/jboss-reflect/trunk/src/test/java/org/jboss/test/plugins/javassist/bytecode/test/JavassistMemberFactoryPackageProtectedStaticPrimitiveUnitTestCase.java
projects/jboss-reflect/trunk/src/test/java/org/jboss/test/plugins/javassist/bytecode/test/JavassistMemberFactoryPrivateBoxedUnitTestCase.java
projects/jboss-reflect/trunk/src/test/java/org/jboss/test/plugins/javassist/bytecode/test/JavassistMemberFactoryPrivatePrimitiveUnitTestCase.java
projects/jboss-reflect/trunk/src/test/java/org/jboss/test/plugins/javassist/bytecode/test/JavassistMemberFactoryPrivateStaticBoxedUnitTestCase.java
projects/jboss-reflect/trunk/src/test/java/org/jboss/test/plugins/javassist/bytecode/test/JavassistMemberFactoryPrivateStaticPrimitiveUnitTestCase.java
projects/jboss-reflect/trunk/src/test/java/org/jboss/test/plugins/javassist/bytecode/test/JavassistMemberFactoryProtectedBoxedUnitTestCase.java
projects/jboss-reflect/trunk/src/test/java/org/jboss/test/plugins/javassist/bytecode/test/JavassistMemberFactoryProtectedPrimitiveUnitTestCase.java
projects/jboss-reflect/trunk/src/test/java/org/jboss/test/plugins/javassist/bytecode/test/JavassistMemberFactoryProtectedStaticBoxedUnitTestCase.java
projects/jboss-reflect/trunk/src/test/java/org/jboss/test/plugins/javassist/bytecode/test/JavassistMemberFactoryProtectedStaticPrimitiveUnitTestCase.java
projects/jboss-reflect/trunk/src/test/java/org/jboss/test/plugins/javassist/bytecode/test/JavassistMemberFactoryPublicBoxedUnitTestCase.java
projects/jboss-reflect/trunk/src/test/java/org/jboss/test/plugins/javassist/bytecode/test/JavassistMemberFactoryPublicPrimitiveUnitTestCase.java
projects/jboss-reflect/trunk/src/test/java/org/jboss/test/plugins/javassist/bytecode/test/JavassistMemberFactoryPublicStaticBoxedUnitTestCase.java
projects/jboss-reflect/trunk/src/test/java/org/jboss/test/plugins/javassist/bytecode/test/JavassistMemberFactoryPublicStaticPrimitiveUnitTestCase.java
projects/jboss-reflect/trunk/src/test/java/org/jboss/test/plugins/javassist/bytecode/test/JavassistMemberFactoryTestSuite.java
Modified:
projects/jboss-reflect/trunk/src/main/java/org/jboss/reflect/plugins/javassist/JavassistConstructor.java
projects/jboss-reflect/trunk/src/main/java/org/jboss/reflect/plugins/javassist/JavassistField.java
projects/jboss-reflect/trunk/src/main/java/org/jboss/reflect/plugins/javassist/JavassistMethod.java
projects/jboss-reflect/trunk/src/main/java/org/jboss/reflect/plugins/javassist/JavassistReflectionFactory.java
projects/jboss-reflect/trunk/src/main/java/org/jboss/reflect/plugins/javassist/SecurityActions.java
projects/jboss-reflect/trunk/src/test/java/org/jboss/test/plugins/javassist/test/JavassistTestSuite.java
Log:
[JBREFLECT-6] Implement the javassist reflection objects by generating the bytecode directly
Modified: projects/jboss-reflect/trunk/src/main/java/org/jboss/reflect/plugins/javassist/JavassistConstructor.java
===================================================================
--- projects/jboss-reflect/trunk/src/main/java/org/jboss/reflect/plugins/javassist/JavassistConstructor.java 2010-03-24 16:46:18 UTC (rev 102909)
+++ projects/jboss-reflect/trunk/src/main/java/org/jboss/reflect/plugins/javassist/JavassistConstructor.java 2010-03-24 16:48:26 UTC (rev 102910)
@@ -24,6 +24,8 @@
/**
* JavassistConstructor.
*
+ * <p>Will typically be implemented by a generated class to call particular target constructor</p>
+ *
* @author <a href="adrian at jboss.com">Adrian Brock</a>
* @version $Revision$
*/
Modified: projects/jboss-reflect/trunk/src/main/java/org/jboss/reflect/plugins/javassist/JavassistField.java
===================================================================
--- projects/jboss-reflect/trunk/src/main/java/org/jboss/reflect/plugins/javassist/JavassistField.java 2010-03-24 16:46:18 UTC (rev 102909)
+++ projects/jboss-reflect/trunk/src/main/java/org/jboss/reflect/plugins/javassist/JavassistField.java 2010-03-24 16:48:26 UTC (rev 102910)
@@ -22,8 +22,10 @@
package org.jboss.reflect.plugins.javassist;
/**
- * JavassistField.
+ * <p>JavassistField</p>
*
+ * <p>Will typically be implemented by a generated class to read/write a particular target field</p>
+ *
* @author <a href="adrian at jboss.com">Adrian Brock</a>
* @version $Revision$
*/
Modified: projects/jboss-reflect/trunk/src/main/java/org/jboss/reflect/plugins/javassist/JavassistMethod.java
===================================================================
--- projects/jboss-reflect/trunk/src/main/java/org/jboss/reflect/plugins/javassist/JavassistMethod.java 2010-03-24 16:46:18 UTC (rev 102909)
+++ projects/jboss-reflect/trunk/src/main/java/org/jboss/reflect/plugins/javassist/JavassistMethod.java 2010-03-24 16:48:26 UTC (rev 102910)
@@ -22,8 +22,10 @@
package org.jboss.reflect.plugins.javassist;
/**
- * JavassistMethod.
+ * <p>JavassistMethod</p>
*
+ * <p>Will typically be implemented by a generated class to make calls to a particular target method</p>
+ *
* @author <a href="adrian at jboss.com">Adrian Brock</a>
* @version $Revision$
*/
Modified: projects/jboss-reflect/trunk/src/main/java/org/jboss/reflect/plugins/javassist/JavassistReflectionFactory.java
===================================================================
--- projects/jboss-reflect/trunk/src/main/java/org/jboss/reflect/plugins/javassist/JavassistReflectionFactory.java 2010-03-24 16:46:18 UTC (rev 102909)
+++ projects/jboss-reflect/trunk/src/main/java/org/jboss/reflect/plugins/javassist/JavassistReflectionFactory.java 2010-03-24 16:48:26 UTC (rev 102910)
@@ -21,22 +21,12 @@
*/
package org.jboss.reflect.plugins.javassist;
-import java.security.AccessController;
-import java.security.PrivilegedActionException;
-import java.security.PrivilegedExceptionAction;
-import java.util.concurrent.atomic.AtomicInteger;
-
-import javassist.ClassPool;
-import javassist.CtClass;
import javassist.CtConstructor;
import javassist.CtField;
-import javassist.CtMember;
import javassist.CtMethod;
-import javassist.CtNewMethod;
-import javassist.Modifier;
-import org.jboss.util.JBossStringBuilder;
-import org.jboss.util.UnreachableStatementException;
+import org.jboss.reflect.plugins.javassist.bytecode.JavassistMemberFactory;
+
/**
* JavassistReflectionFactory.
* Creates instances of {@link JavassistMethod}, {@link JavassistConstructor} and
@@ -44,19 +34,32 @@
* the use of reflection.
*
* TODO JBREFLECT-3 proper classpool with pruning
- * TODO JBREFLECT-6 non compiler based implementation
* @author <a href="adrian at jboss.com">Adrian Brock</a>
* @author <a href="ales.justin at jboss.com">Ales Justin</a>
+ * @author <a href="kabir.khan at jboss.com">Kabir Khan</a>
* @version $Revision$
*/
public class JavassistReflectionFactory
{
- /** The method class counter */
- private static final AtomicInteger counter = new AtomicInteger(0);
-
/** Whether to check arguments */
private final boolean check;
+ /** Whether to output generated classes to disk */
+ private final boolean debug;
+
+ protected static final Class<?> MAGIC_ACCESSOR_IMPL;
+ static
+ {
+ try
+ {
+ MAGIC_ACCESSOR_IMPL = Class.forName("sun.reflect.MagicAccessorImpl");
+ }
+ catch (ClassNotFoundException e)
+ {
+ throw new RuntimeException(e);
+ }
+ }
+
/**
* Create a new JavassistReflectionFactory.
*
@@ -64,72 +67,22 @@
*/
public JavassistReflectionFactory(boolean check)
{
- this.check = check;
+ this(check, false);
}
/**
- * Get class pool.
- *
- * @param member the member
- * @return member's class pool
- * @throws Throwable for anby error
+ * Create a new JavassistReflectionFactory.
+ *
+ * @param check whether to check arguments
+ * @param debug whether to output generated classes to disk
*/
- protected ClassPool getClassPool(CtMember member) throws Throwable
+ public JavassistReflectionFactory(boolean check, boolean debug)
{
- if (member == null)
- throw new IllegalArgumentException("Null member");
-
- CtClass ctClass = member.getDeclaringClass();
- return ctClass.getClassPool();
+ this.check = check;
+ this.debug = debug;
}
/**
- * Apply super class.
- *
- * @param result the current ct class
- * @param pool the class pool
- */
- protected void applySuperClass(CtClass result, ClassPool pool)
- {
- // TODO JBREFLECT-2 figure out how to do this on all JDKs
- try
- {
- CtClass magic = pool.get("sun.reflect.MagicAccessorImpl");
- result.setSuperclass(magic);
- }
- catch (Exception ignored)
- {
- }
- }
-
- /**
- * Create instance.
- *
- * @param result the current ct class
- * @param expectedType expected type
- * @return new instance
- * @throws Throwable for any error
- */
- protected <T> T createInstance(final CtClass result, final Class<T> expectedType) throws Throwable
- {
- try
- {
- return AccessController.doPrivileged(new PrivilegedExceptionAction<T>()
- {
- public T run() throws Exception
- {
- Class<?> clazz = result.toClass();
- return expectedType.cast(clazz.newInstance());
- }
- });
- }
- catch (PrivilegedActionException e)
- {
- throw e.getCause();
- }
- }
-
- /**
* Creates a javassist method.
*
* This method generates an implementation of {@code JavassistMethod}, loads
@@ -141,154 +94,7 @@
*/
public JavassistMethod createMethod(CtMethod ctMethod) throws Throwable
{
- ClassPool pool = getClassPool(ctMethod);
- final CtClass result = pool.makeClass(JavassistMethod.class.getName() + counter.incrementAndGet());
- applySuperClass(result, pool);
- result.addInterface(pool.get(JavassistMethod.class.getName()));
-
- CtConstructor constructor = new CtConstructor(null, result);
- constructor.setBody("super();");
- result.addConstructor(constructor);
-
- CtClass object = pool.get(Object.class.getName());
-
- JBossStringBuilder buffer = new JBossStringBuilder();
-
- // Signature
- buffer.append("public Object invoke(Object target, Object[] args) throws Throwable {");
-
- boolean isInstanceMethod = Modifier.isStatic(ctMethod.getModifiers()) == false;
-
- // Check for null target
- if (check && isInstanceMethod)
- {
- buffer.append("if (target == null) throw new IllegalArgumentException(\"Null target for ");
- buffer.append(ctMethod.getName()).append(ctMethod.getSignature()).append("\");");
- }
-
- // Check the target
- CtClass declaring = ctMethod.getDeclaringClass();
- boolean needsCast = isInstanceMethod && object.equals(declaring) == false;
- if (check && needsCast)
- {
- buffer.append("if (target instanceof ").append(declaring.getName()).append(" == false) ");
- buffer.append("throw new IllegalArgumentException(\"Target \" + target + \"");
- buffer.append(" is not an instance of ").append(declaring.getName());
- buffer.append(" for ").append(ctMethod.getName()).append(ctMethod.getSignature()).append("\");");
- }
-
- // Check the parameters
- CtClass[] params = ctMethod.getParameterTypes();
- if (check)
- {
- // Wrong number of args?
- if (params.length != 0)
- {
- buffer.append("if (args == null || args.length != ").append(params.length).append(") ");
- buffer.append("throw new IllegalArgumentException(\"Expected ").append(params.length).append(" parameter(s)");
- buffer.append(" for ").append(ctMethod.getName()).append(ctMethod.getSignature()).append("\");");
- }
- else
- {
- // Didn't expect args
- buffer.append("if (args != null && args.length != 0)");
- buffer.append("throw new IllegalArgumentException(\"Expected no parameters");
- buffer.append(" for ").append(ctMethod.getName()).append(ctMethod.getSignature()).append("\");");
- }
- for (int i = 0; i < params.length; ++i)
- {
- if (object.equals(params[i]) == false)
- {
- String paramType = getBoxedType(params[i]);
- // Primitives can't be null
- if (params[i].isPrimitive())
- {
- buffer.append("if (args[").append(i).append("] == null) ");
- buffer.append("throw new IllegalArgumentException(\"Parameter ").append(i);
- buffer.append(" cannot be null for ").append(params[i].getName());
- buffer.append(" for ").append(ctMethod.getName()).append(ctMethod.getSignature()).append("\");");
- }
- // Check the parameter types
- buffer.append("if (args[").append(i).append("] != null && ");
- buffer.append("args[").append(i).append("] instanceof ").append(paramType).append(" == false) ");
- buffer.append("throw new IllegalArgumentException(\"Parameter ").append(i).append(" \" + args[").append(i).append("] + \"");
- buffer.append(" is not an instance of ").append(paramType);
- buffer.append(" for ").append(ctMethod.getName()).append(ctMethod.getSignature()).append("\");");
- }
- }
- }
-
- // Add a return and box the return type if necessary
- CtClass returnType = ctMethod.getReturnType();
- boolean isVoid = CtClass.voidType.equals(returnType);
- boolean isPrimitive = returnType.isPrimitive();
- if (isVoid == false)
- {
- buffer.append("return ");
- if (isPrimitive)
- buffer.append("new ").append(getBoxedType(returnType)).append('(');
- }
-
- // Instance method
- if (isInstanceMethod)
- {
- buffer.append('(');
- if (needsCast)
- buffer.append("(").append(declaring.getName()).append(')');
-
- buffer.append("target).");
- }
- else
- {
- // Static method
- buffer.append(declaring.getName()).append('.');
- }
-
- // Add the method name
- buffer.append(ctMethod.getName()).append('(');
-
- // Add the parameters
- for (int i = 0; i < params.length; ++i)
- {
- buffer.append('(');
- // Cast the parameters
- if (object.equals(params[i]) == false)
- buffer.append("(").append(getBoxedType(params[i])).append(')');
- buffer.append("args[").append(i).append("])");
- // Unbox primitive parameters
- if (params[i].isPrimitive())
- unbox(buffer, params[i]);
-
- if (i < params.length - 1)
- buffer.append(", ");
- }
- buffer.append(')');
-
- // Complete the boxing of the return value
- if (isVoid == false && isPrimitive)
- buffer.append(')');
-
- buffer.append(';');
-
- // Add a return null if there is no return value
- if (isVoid)
- buffer.append("return null;");
- buffer.append('}');
-
- // Compile it
- String code = buffer.toString();
- try
- {
- CtMethod invoke = CtNewMethod.make(code, result);
- result.addMethod(invoke);
- }
- catch (Exception e)
- {
- throw new RuntimeException("Cannot compile " + code, e);
- }
-
- // Create it
- return createInstance(result, JavassistMethod.class);
+ return JavassistMemberFactory.createJavassistMethod(MAGIC_ACCESSOR_IMPL, ctMethod, check, debug);
}
/**
@@ -300,99 +106,7 @@
*/
public JavassistConstructor createConstructor(CtConstructor ctConstructor) throws Throwable
{
- ClassPool pool = getClassPool(ctConstructor);
- final CtClass result = pool.makeClass(JavassistConstructor.class.getName() + counter.incrementAndGet());
- applySuperClass(result, pool);
- result.addInterface(pool.get(JavassistConstructor.class.getName()));
-
- CtConstructor constructor = new CtConstructor(null, result);
- constructor.setBody("super();");
- result.addConstructor(constructor);
-
- CtClass object = pool.get(Object.class.getName());
-
- JBossStringBuilder buffer = new JBossStringBuilder();
-
- // Signature
- buffer.append("public Object newInstance(Object[] args) throws Throwable {");
-
- String declaring = ctConstructor.getDeclaringClass().getName();
-
- // Check the parameters
- CtClass[] params = ctConstructor.getParameterTypes();
- if (check)
- {
- // Wrong number of args?
- if (params.length != 0)
- {
- buffer.append("if (args == null || args.length != ").append(params.length).append(") ");
- buffer.append("throw new IllegalArgumentException(\"Expected ").append(params.length).append(" parameter(s)");
- buffer.append(" for ").append("new ").append(declaring).append(ctConstructor.getSignature()).append("\");");
- }
- else
- {
- // Didn't expect args
- buffer.append("if (args != null && args.length != 0)");
- buffer.append("throw new IllegalArgumentException(\"Expected no parameters");
- buffer.append(" for ").append("new ").append(declaring).append(ctConstructor.getSignature()).append("\");");
- }
- for (int i = 0; i < params.length; ++i)
- {
- if (object.equals(params[i]) == false)
- {
- String paramType = getBoxedType(params[i]);
- // Primitives can't be null
- if (params[i].isPrimitive())
- {
- buffer.append("if (args[").append(i).append("] == null) ");
- buffer.append("throw new IllegalArgumentException(\"Parameter ").append(i);
- buffer.append(" cannot be null for ").append(params[i].getName());
- buffer.append(" for ").append("new ").append(declaring).append(ctConstructor.getSignature()).append("\");");
- }
- // Check the parameter types
- buffer.append("if (args[").append(i).append("] != null && ");
- buffer.append("args[").append(i).append("] instanceof ").append(paramType).append(" == false) ");
- buffer.append("throw new IllegalArgumentException(\"Parameter ").append(i).append(" \" + args[").append(i).append("] + \"");
- buffer.append(" is not an instance of ").append(paramType);
- buffer.append(" for ").append("new ").append(declaring).append(ctConstructor.getSignature()).append("\");");
- }
- }
- }
-
- // Add the return new
- buffer.append("return new ").append(declaring).append('(');
-
- // Add the parameters
- for (int i = 0; i < params.length; ++i)
- {
- buffer.append('(');
- // Cast the parameters
- if (object.equals(params[i]) == false)
- buffer.append("(").append(getBoxedType(params[i])).append(')');
- buffer.append("args[").append(i).append("])");
- // Unbox primitive parameters
- if (params[i].isPrimitive())
- unbox(buffer, params[i]);
-
- if (i < params.length - 1)
- buffer.append(", ");
- }
- buffer.append(");}");
-
- // Compile it
- String code = buffer.toString();
- try
- {
- CtMethod newInstance = CtNewMethod.make(code, result);
- result.addMethod(newInstance);
- }
- catch (Exception e)
- {
- throw new RuntimeException("Cannot compile " + code, e);
- }
-
- // Create it
- return createInstance(result, JavassistConstructor.class);
+ return JavassistMemberFactory.createJavassistConstructor(MAGIC_ACCESSOR_IMPL, ctConstructor, check, debug);
}
/**
@@ -404,236 +118,7 @@
*/
public JavassistField createField(CtField ctField) throws Throwable
{
- ClassPool pool = getClassPool(ctField);
- final CtClass result = pool.makeClass(JavassistField.class.getName() + counter.incrementAndGet());
- applySuperClass(result, pool);
- result.addInterface(pool.get(JavassistField.class.getName()));
-
- CtConstructor constructor = new CtConstructor(null, result);
- constructor.setBody("super();");
- result.addConstructor(constructor);
-
- CtClass object = pool.get(Object.class.getName());
-
- // GET
- JBossStringBuilder buffer = new JBossStringBuilder();
-
- // Signature
- buffer.append("public Object get(Object target) throws Throwable {");
-
- boolean isInstanceField= Modifier.isStatic(ctField.getModifiers()) == false;
-
- // Check for null target
- if (check && isInstanceField)
- {
- buffer.append("if (target == null) throw new IllegalArgumentException(\"Null target");
- buffer.append(" for ").append(ctField.getName()).append("\");");
- }
-
- // Check the target
- CtClass declaring = ctField.getDeclaringClass();
- boolean needsCast = isInstanceField && object.equals(declaring) == false;
- if (check && needsCast)
- {
- buffer.append("if (target instanceof ").append(declaring.getName()).append(" == false) ");
- buffer.append("throw new IllegalArgumentException(\"Target \" + target + \"");
- buffer.append(" is not an instance of ").append(declaring.getName());
- buffer.append(" for ").append(ctField.getName()).append("\");");
- }
-
- // Add a return and box the return type if necessary
- CtClass type = ctField.getType();
- boolean isPrimitive = type.isPrimitive();
- buffer.append("return ");
- if (isPrimitive)
- buffer.append("new ").append(getBoxedType(type)).append('(');
-
- // Instance field
- if (isInstanceField)
- {
- buffer.append('(');
- if (needsCast)
- buffer.append("(").append(declaring.getName()).append(')');
-
- buffer.append("target).");
- }
- else
- {
- // Static field
- buffer.append(declaring.getName()).append('.');
- }
-
- // Add the field name
- buffer.append(ctField.getName());
-
- // Complete the boxing of the return value
- if (isPrimitive)
- buffer.append(')');
-
- buffer.append(";}");
-
- // Compile it
- String code = buffer.toString();
- CtMethod get = CtNewMethod.make(code, result);
- try
- {
- result.addMethod(get);
- }
- catch (Exception e)
- {
- throw new RuntimeException("Cannot compile " + code, e);
- }
-
- // SET
- buffer = new JBossStringBuilder();
-
- // Signature
- buffer.append("public void set(Object target, Object value) throws Throwable {");
-
- // Check for null target
- if (check && isInstanceField)
- {
- buffer.append("if (target == null) throw new IllegalArgumentException(\"Null target");
- buffer.append(" for ").append(ctField.getName()).append("\");");
- }
-
- // Check the target
- if (check && needsCast)
- {
- buffer.append("if (target instanceof ").append(declaring.getName()).append(" == false) ");
- buffer.append("throw new IllegalArgumentException(\"Target \" + target + \"");
- buffer.append(" is not an instance of ").append(declaring.getName());
- buffer.append(" for ").append(ctField.getName()).append("\");");
- }
-
- // Check the parameter
- if (check)
- {
- if (object.equals(type) == false)
- {
- String paramType = getBoxedType(type);
- // Primitives can't be null
- if (type.isPrimitive())
- {
- buffer.append("if (value == null) ");
- buffer.append("throw new IllegalArgumentException(\"Value ");
- buffer.append(" cannot be null for ").append(type.getName());
- buffer.append(" for ").append(ctField.getName()).append("\");");
- }
- // Check the parameter types
- buffer.append("if (value != null && ");
- buffer.append("value instanceof ").append(paramType).append(" == false) ");
- buffer.append("throw new IllegalArgumentException(\"Value \" + value + \"");
- buffer.append(" is not an instance of ").append(paramType);
- buffer.append(" for ").append(ctField.getName()).append("\");");
- }
- }
-
- // Instance Field
- if (isInstanceField)
- {
- buffer.append('(');
- if (needsCast)
- buffer.append("(").append(declaring.getName()).append(')');
-
- buffer.append("target).");
- }
- else
- {
- // Static field
- buffer.append(declaring.getName()).append('.');
- }
-
- // Add the field name
- buffer.append(ctField.getName()).append("=");
-
- // Add the value
- buffer.append('(');
- // Cast the value
- if (object.equals(type) == false)
- buffer.append("(").append(getBoxedType(type)).append(')');
- buffer.append("value)");
- // Unbox primitive parameters
- if (type.isPrimitive())
- unbox(buffer, type);
-
- buffer.append(";}");
-
- // Compile it
- code = buffer.toString();
- try
- {
- CtMethod set = CtNewMethod.make(code, result);
- result.addMethod(set);
- }
- catch (Exception e)
- {
- throw new RuntimeException("Cannot compile " + code, e);
- }
-
- // Create it
- return createInstance(result, JavassistField.class);
+ return JavassistMemberFactory.createJavassistField(MAGIC_ACCESSOR_IMPL, ctField, check, debug);
}
- /**
- * Unbox a primitive
- *
- * @param buffer the buffer
- * @param primitive the primitive
- */
- protected void unbox(JBossStringBuilder buffer, CtClass primitive)
- {
- if (CtClass.booleanType.equals(primitive))
- buffer.append(".booleanValue()");
- else if (CtClass.byteType.equals(primitive))
- buffer.append(".byteValue()");
- else if (CtClass.charType.equals(primitive))
- buffer.append(".charValue()");
- else if (CtClass.doubleType.equals(primitive))
- buffer.append(".doubleValue()");
- else if (CtClass.floatType.equals(primitive))
- buffer.append(".floatValue()");
- else if (CtClass.intType.equals(primitive))
- buffer.append(".intValue()");
- else if (CtClass.longType.equals(primitive))
- buffer.append(".longValue()");
- else if (CtClass.shortType.equals(primitive))
- buffer.append(".shortValue()");
- else
- {
- throw new UnreachableStatementException();
- }
- }
-
- /**
- * Get the boxed type
- *
- * TODO JBMICROCONT-119 integer progression?
- * @param type the type to box
- * @return the boxed type name
- */
- protected String getBoxedType(CtClass type)
- {
- if (type.isPrimitive())
- {
- if (CtClass.booleanType.equals(type))
- return Boolean.class.getName();
- else if (CtClass.byteType.equals(type))
- return Byte.class.getName();
- else if (CtClass.charType.equals(type))
- return Character.class.getName();
- else if (CtClass.doubleType.equals(type))
- return Double.class.getName();
- else if (CtClass.floatType.equals(type))
- return Float.class.getName();
- else if (CtClass.intType.equals(type))
- return Integer.class.getName();
- else if (CtClass.longType.equals(type))
- return Long.class.getName();
- else if (CtClass.shortType.equals(type))
- return Short.class.getName();
- throw new UnreachableStatementException();
- }
- return type.getName();
- }
}
Modified: projects/jboss-reflect/trunk/src/main/java/org/jboss/reflect/plugins/javassist/SecurityActions.java
===================================================================
--- projects/jboss-reflect/trunk/src/main/java/org/jboss/reflect/plugins/javassist/SecurityActions.java 2010-03-24 16:46:18 UTC (rev 102909)
+++ projects/jboss-reflect/trunk/src/main/java/org/jboss/reflect/plugins/javassist/SecurityActions.java 2010-03-24 16:48:26 UTC (rev 102910)
@@ -18,9 +18,11 @@
* License along with this software; if not, write to the Free
* Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
* 02110-1301 USA, or see the FSF site: http://www.fsf.org.
-*/
+*/
package org.jboss.reflect.plugins.javassist;
+import java.lang.reflect.Constructor;
+import java.lang.reflect.Method;
import java.security.AccessController;
import java.security.PrivilegedAction;
@@ -38,15 +40,47 @@
else
return AccessController.doPrivileged(GetContextClassLoaderAction.INSTANCE);
}
-
+
static class GetContextClassLoaderAction implements PrivilegedAction<ClassLoader>
{
- final static GetContextClassLoaderAction INSTANCE = new GetContextClassLoaderAction();
-
+ final static GetContextClassLoaderAction INSTANCE = new GetContextClassLoaderAction();
+
public ClassLoader run()
{
return Thread.currentThread().getContextClassLoader();
}
-
+
}
+
+ static Constructor<?>[] getDeclaredConstructors(final Class<?> clazz)
+ {
+ if (System.getSecurityManager() == null)
+ return clazz.getDeclaredConstructors();
+ else
+ {
+ return AccessController.doPrivileged(new PrivilegedAction<Constructor<?>[]>()
+ {
+ public Constructor<?>[] run()
+ {
+ return clazz.getDeclaredConstructors();
+ }
+ });
+ }
+ }
+
+ static Method[] getDeclaredMethods(final Class<?> clazz)
+ {
+ if (System.getSecurityManager() == null)
+ return clazz.getDeclaredMethods();
+ else
+ {
+ return AccessController.doPrivileged(new PrivilegedAction<Method[]>()
+ {
+ public Method[] run()
+ {
+ return clazz.getDeclaredMethods();
+ }
+ });
+ }
+ }
}
Added: projects/jboss-reflect/trunk/src/main/java/org/jboss/reflect/plugins/javassist/bytecode/JavassistBehaviorFactory.java
===================================================================
--- projects/jboss-reflect/trunk/src/main/java/org/jboss/reflect/plugins/javassist/bytecode/JavassistBehaviorFactory.java (rev 0)
+++ projects/jboss-reflect/trunk/src/main/java/org/jboss/reflect/plugins/javassist/bytecode/JavassistBehaviorFactory.java 2010-03-24 16:48:26 UTC (rev 102910)
@@ -0,0 +1,209 @@
+/*
+* JBoss, Home of Professional Open Source.
+* Copyright 2006, Red Hat Middleware LLC, and individual contributors
+* as indicated by the @author tags. See the copyright.txt file in the
+* distribution for a full listing of individual contributors.
+*
+* This is free software; you can redistribute it and/or modify it
+* under the terms of the GNU Lesser General Public License as
+* published by the Free Software Foundation; either version 2.1 of
+* the License, or (at your option) any later version.
+*
+* This software is distributed in the hope that it will be useful,
+* but WITHOUT ANY WARRANTY; without even the implied warranty of
+* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+* Lesser General Public License for more details.
+*
+* You should have received a copy of the GNU Lesser General Public
+* License along with this software; if not, write to the Free
+* Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+* 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+*/
+package org.jboss.reflect.plugins.javassist.bytecode;
+
+import javassist.CtBehavior;
+import javassist.CtClass;
+import javassist.NotFoundException;
+import javassist.bytecode.Bytecode;
+import javassist.bytecode.Opcode;
+
+import org.jboss.reflect.plugins.javassist.JavassistConstructor;
+import org.jboss.reflect.plugins.javassist.JavassistMethod;
+
+/**
+ * <p>Abstract class to create implementations of the {@link JavassistMethod} and {@link JavassistConstructor}
+ * interfaces.</p>
+ * <p>This implementation generates raw bytecode to avoid the overhead of compilation via javassist. If
+ * <code>sun.reflect.MagicAccessorImpl</code> is used as the <code>superClass</code> field the implementation
+ * classes can access private and protected members of the target class.</p>
+ *
+ * @author <a href="kabir.khan at jboss.com">Kabir Khan</a>
+ * @version $Revision: 1.1 $
+ */
+public abstract class JavassistBehaviorFactory extends JavassistMemberFactory
+{
+ /** The constructor or method being targeted */
+ CtBehavior ctBehavior;
+
+ /**
+ * Constructor
+ *
+ * @param superClass the super class to use for the implementation
+ * @param ctBehavior the method or constructor we are generating a {@link JavassistMethod} or {@link JavassistConstructor} for
+ * @param check whether the methods implemented from the interfaces should check the parameters
+ * @param debug true to cause the class bytes to be output to the file system so they can be inspected with a decompiler/javap
+ */
+ JavassistBehaviorFactory(Class<?> superClass, CtBehavior ctBehavior, boolean check, boolean debug)
+ {
+ super(superClass, check, debug);
+ this.ctBehavior = ctBehavior;
+ }
+
+ /**
+ * Gets the parameter types of the method or constructor we are generating a {@link JavassistMethod} or {@link JavassistConstructor} for.
+ *
+ * @return the parameter types
+ */
+ CtClass[] getParameterTypes()
+ {
+ try
+ {
+ return ctBehavior.getParameterTypes();
+ }
+ catch (NotFoundException e)
+ {
+ throw new RuntimeException(e);
+ }
+ }
+
+ @Override
+ String initAccessedMember()
+ {
+ return ctBehavior.getDeclaringClass().getName() + "." + ctBehavior.getName() + ctBehavior.getSignature();
+ }
+
+ /**
+ * Adds the byte code to push the parameters for a method/constructor
+ * on to the stack
+ *
+ * @param code the byte code of the method we are generating
+ * @param params the target parameter types
+ */
+ void addParameters(Bytecode code, CtClass[] params, int parameterIndex)
+ {
+ for (int i = 0 ; i < params.length ; i++)
+ {
+ code.addAload(parameterIndex);
+ code.addIconst(i);
+ code.addOpcode(Opcode.AALOAD);
+ if (!params[i].getName().equals(OBJECT_NAME))
+ {
+ castAndUnbox(code, params[i]);
+ }
+ }
+ }
+
+
+ /**
+ * Adds byte code instructions to the <code>code</code> parameter to validate the parameters in the
+ * method we are generating.
+ *
+ * @param The parameter index, with 1 being the first, 2 the second and so on
+ * @param code the byte code of the method we are generating
+ * @param isStatic true if the target member is static
+ */
+ void checkParameters(Bytecode code, int parameterIndex)
+ {
+ if (check)
+ {
+ CtClass[] parameterTypes = getParameterTypes();
+ if (parameterTypes.length > 0)
+ {
+ //if (args == null || args.length != 10) throw new IllegalArgumentException("Wrong number of parameters");
+ code.addAload(parameterIndex);
+ code.addOpcode(Opcode.IFNULL);
+ int pc1 = code.currentPc();
+ code.addIndex(0);
+ code.addAload(parameterIndex);
+ code.addOpcode(Opcode.ARRAYLENGTH);
+ code.addIconst(parameterTypes.length);
+ code.addOpcode(Opcode.IF_ICMPEQ);
+ int pc2 = code.currentPc();
+ code.addIndex(0);
+ code.write16bit(pc1, code.currentPc() - pc1 + 1);
+ code.addNew(ILLEGAL_ARGUMENT_EXCEPTION_NAME);
+ code.addOpcode(Opcode.DUP);
+ code.addLdc("Expected " + parameterTypes.length + " parameter(s) for " + getAccessedMember());
+ code.addInvokespecial(ILLEGAL_ARGUMENT_EXCEPTION_NAME, "<init>", ILLEGAL_ARGUMENT_EXCEPTION_CONSTRUCTOR_DESCRIPTOR);
+ code.addOpcode(Opcode.ATHROW);
+ code.write16bit(pc2, code.currentPc() - pc2 + 1);
+ }
+ else
+ {
+ //if (args != null && args.length > 0) throw new IllegalArgumentException("No parameters expected");
+ code.addAload(parameterIndex);
+ code.addOpcode(Opcode.IFNULL);
+ int pc1 = code.currentPc();
+ code.addIndex(0);
+ code.addAload(parameterIndex);
+ code.addOpcode(Opcode.ARRAYLENGTH);
+ code.addOpcode(Opcode.IFLE);
+ int pc2 = code.currentPc();
+ code.addIndex(0);
+ code.addNew(ILLEGAL_ARGUMENT_EXCEPTION_NAME);
+ code.addOpcode(Opcode.DUP);
+ code.addLdc("Expected no parameters for " + getAccessedMember());
+ code.addInvokespecial(ILLEGAL_ARGUMENT_EXCEPTION_NAME, "<init>", ILLEGAL_ARGUMENT_EXCEPTION_CONSTRUCTOR_DESCRIPTOR);
+ code.addOpcode(Opcode.ATHROW);
+ code.write16bit(pc1, code.currentPc() - pc1 + 1);
+ code.write16bit(pc2, code.currentPc() - pc2 + 1);
+ }
+
+ for (int i = 0 ; i < parameterTypes.length ; i++)
+ {
+ if (!parameterTypes[i].getName().equals(OBJECT_NAME))
+ {
+ String param = getBoxedType(parameterTypes[i]);
+ if (parameterTypes[i].isPrimitive())
+ {
+ //if (args[1] == null) throw new IllegalArgumentException("Parameter 1 cannot be null for TestBean.test()");
+ code.addAload(parameterIndex);
+ code.addIconst(i);
+ code.addOpcode(Opcode.AALOAD);
+ code.addOpcode(Opcode.IFNONNULL);
+ int pc1 = code.currentPc();
+ code.addIndex(0);
+ code.addNew(ILLEGAL_ARGUMENT_EXCEPTION_NAME);
+ code.addOpcode(Opcode.DUP);
+ code.addLdc("Parameter[" + i + "] can not be null for " + getAccessedMember());
+ code.addInvokespecial(ILLEGAL_ARGUMENT_EXCEPTION_NAME, "<init>", ILLEGAL_ARGUMENT_EXCEPTION_CONSTRUCTOR_DESCRIPTOR);
+ code.addOpcode(Opcode.ATHROW);
+ code.write16bit(pc1, code.currentPc() - pc1 + 1);
+ }
+
+ //if (args[1] != null && args[1] instanceof String == false) throw new IllegalArgumentException("Parameter 1 is not an instance of String for TestBean.test()");
+ code.addAload(parameterIndex);
+ code.addIconst(i);
+ code.addOpcode(Opcode.AALOAD);
+ code.addOpcode(Opcode.IFNULL);
+ int pc1 = code.currentPc();
+ code.addIndex(0);
+ code.addAload(parameterIndex);
+ code.addIconst(i);
+ code.addOpcode(Opcode.AALOAD);
+ code.addInstanceof(param);
+ code.addOpcode(Opcode.IFNE);
+ int pc2 = code.currentPc();
+ code.addIndex(0);
+ code.addNew(ILLEGAL_ARGUMENT_EXCEPTION_NAME);
+ code.addOpcode(Opcode.DUP);
+ code.addLdc("Parameter[" + i + "] is not an instance of " + param + " for " + getAccessedMember());
+ code.addInvokespecial(ILLEGAL_ARGUMENT_EXCEPTION_NAME, "<init>", ILLEGAL_ARGUMENT_EXCEPTION_CONSTRUCTOR_DESCRIPTOR);
+ code.addOpcode(Opcode.ATHROW);
+ code.write16bit(pc1, code.currentPc() - pc1 + 1);
+ code.write16bit(pc2, code.currentPc() - pc2 + 1);
+ }
+ }
+ }
+ }
+}
Added: projects/jboss-reflect/trunk/src/main/java/org/jboss/reflect/plugins/javassist/bytecode/JavassistConstructorFactory.java
===================================================================
--- projects/jboss-reflect/trunk/src/main/java/org/jboss/reflect/plugins/javassist/bytecode/JavassistConstructorFactory.java (rev 0)
+++ projects/jboss-reflect/trunk/src/main/java/org/jboss/reflect/plugins/javassist/bytecode/JavassistConstructorFactory.java 2010-03-24 16:48:26 UTC (rev 102910)
@@ -0,0 +1,137 @@
+/*
+* JBoss, Home of Professional Open Source.
+* Copyright 2006, Red Hat Middleware LLC, and individual contributors
+* as indicated by the @author tags. See the copyright.txt file in the
+* distribution for a full listing of individual contributors.
+*
+* This is free software; you can redistribute it and/or modify it
+* under the terms of the GNU Lesser General Public License as
+* published by the Free Software Foundation; either version 2.1 of
+* the License, or (at your option) any later version.
+*
+* This software is distributed in the hope that it will be useful,
+* but WITHOUT ANY WARRANTY; without even the implied warranty of
+* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+* Lesser General Public License for more details.
+*
+* You should have received a copy of the GNU Lesser General Public
+* License along with this software; if not, write to the Free
+* Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+* 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+*/
+package org.jboss.reflect.plugins.javassist.bytecode;
+
+import java.lang.reflect.Method;
+
+import javassist.CtConstructor;
+import javassist.Modifier;
+import javassist.bytecode.Bytecode;
+import javassist.bytecode.CodeAttribute;
+import javassist.bytecode.ConstPool;
+import javassist.bytecode.MethodInfo;
+import javassist.bytecode.Opcode;
+import javassist.bytecode.StackMapTable;
+import javassist.util.proxy.RuntimeSupport;
+
+import org.jboss.reflect.plugins.javassist.JavassistConstructor;
+
+/**
+ * <p>Class to create implementations of the {{@link JavassistConstructor} interface.</p>
+ *
+ * <p>This implementation generates raw bytecode to avoid the overhead of compilation via javassist. If
+ * <code>sun.reflect.MagicAccessorImpl</code> is used as the <code>superClass</code> field the implementation
+ * classes can access private and protected members of the target class.</p>
+ *
+ * @author <a href="kabir.khan at jboss.com">Kabir Khan</a>
+ * @version $Revision: 1.1 $
+ */
+public class JavassistConstructorFactory extends JavassistBehaviorFactory
+{
+ /** The names of the interfaces we are implementing */
+ private static final String[] interfaceNames = new String[] {JavassistConstructor.class.getName()};
+
+ /** The methods from the interface that are being implemented */
+ private static final Method[] methods;
+
+ static
+ {
+ methods = new Method[1];
+ try
+ {
+ methods[0] = SecurityActions.getDeclaredMethod(JavassistConstructor.class, "newInstance", Object[].class);
+ }
+ catch (NoSuchMethodException e)
+ {
+ throw new RuntimeException(e);
+ }
+ }
+
+ /** The constructor we are targeting */
+ private final CtConstructor ctConstructor;
+
+ /** The name of the class being generated */
+ private final String className = JavassistConstructor.class.getName() + counter.incrementAndGet();
+
+ /**
+ * Constructor
+ *
+ * @param superClass the super class to use for the implementation
+ * @param ctConstructor the constructor we are generating a {@link JavassistConstructor} for
+ * @param check whether the methods implemented from the interfaces should check the parameters
+ * @param debug true to cause the class bytes to be output to the file system so they can be inspected with a decompiler/javap
+ */
+ JavassistConstructorFactory(Class<?> superClass, CtConstructor ctConstructor, boolean check, boolean debug)
+ {
+ super(superClass, ctConstructor, check, debug);
+ this.ctConstructor = ctConstructor;
+ }
+
+ String getGeneratedClassName()
+ {
+ return className;
+ }
+
+
+ String[] getInterfaceNames()
+ {
+ return interfaceNames;
+ }
+
+ @Override
+ MethodInfo implementMethod(int index, ConstPool cp)
+ {
+ if (index >= methods.length)
+ return null;
+
+ Method method = methods[index];
+
+ String desc = RuntimeSupport.makeDescriptor(method);
+ MethodInfo minfo = new MethodInfo(cp, method.getName(), desc);
+ minfo.setAccessFlags(Modifier.PUBLIC);
+ setThrows(minfo, cp, method.getExceptionTypes());
+ Bytecode code = new Bytecode(cp, 0, 0);
+
+ int pc = code.currentPc();
+
+ int s = countParameterStackSize(1, getParameterTypes());
+
+ checkParameters(code, 1);
+
+ code.addNew(ctConstructor.getDeclaringClass().getName());
+ code.addOpcode(Opcode.DUP);
+
+ addParameters(code, getParameterTypes(), 1);
+
+ code.addInvokespecial(ctConstructor.getDeclaringClass(), "<init>", ctConstructor.getSignature());
+ code.addOpcode(Opcode.ARETURN);
+
+ code.setMaxLocals(s + 1);
+ CodeAttribute ca = code.toCodeAttribute();
+ minfo.setCodeAttribute(ca);
+
+ StackMapTable.Writer writer = new StackMapTable.Writer(32);
+ writer.sameFrame(pc);
+ ca.setAttribute(writer.toStackMapTable(cp));
+ return minfo;
+ }
+}
\ No newline at end of file
Added: projects/jboss-reflect/trunk/src/main/java/org/jboss/reflect/plugins/javassist/bytecode/JavassistFieldFactory.java
===================================================================
--- projects/jboss-reflect/trunk/src/main/java/org/jboss/reflect/plugins/javassist/bytecode/JavassistFieldFactory.java (rev 0)
+++ projects/jboss-reflect/trunk/src/main/java/org/jboss/reflect/plugins/javassist/bytecode/JavassistFieldFactory.java 2010-03-24 16:48:26 UTC (rev 102910)
@@ -0,0 +1,210 @@
+/*
+* JBoss, Home of Professional Open Source.
+* Copyright 2006, Red Hat Middleware LLC, and individual contributors
+* as indicated by the @author tags. See the copyright.txt file in the
+* distribution for a full listing of individual contributors.
+*
+* This is free software; you can redistribute it and/or modify it
+* under the terms of the GNU Lesser General Public License as
+* published by the Free Software Foundation; either version 2.1 of
+* the License, or (at your option) any later version.
+*
+* This software is distributed in the hope that it will be useful,
+* but WITHOUT ANY WARRANTY; without even the implied warranty of
+* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+* Lesser General Public License for more details.
+*
+* You should have received a copy of the GNU Lesser General Public
+* License along with this software; if not, write to the Free
+* Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+* 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+*/
+package org.jboss.reflect.plugins.javassist.bytecode;
+
+import java.lang.reflect.Method;
+
+import javassist.CtClass;
+import javassist.CtField;
+import javassist.Modifier;
+import javassist.NotFoundException;
+import javassist.bytecode.Bytecode;
+import javassist.bytecode.CodeAttribute;
+import javassist.bytecode.ConstPool;
+import javassist.bytecode.MethodInfo;
+import javassist.bytecode.Opcode;
+import javassist.bytecode.StackMapTable;
+import javassist.util.proxy.RuntimeSupport;
+
+import org.jboss.reflect.plugins.javassist.JavassistField;
+
+/**
+ * <p>Class to create implementations of the {{@link JavassistField} interface.</p>
+ *
+ * <p>This implementation generates raw bytecode to avoid the overhead of compilation via javassist. If
+ * <code>sun.reflect.MagicAccessorImpl</code> is used as the <code>superClass</code> field the implementation
+ * classes can access private and protected members of the target class.</p>
+ *
+ * @author <a href="kabir.khan at jboss.com">Kabir Khan</a>
+ * @version $Revision: 1.1 $
+ */
+public class JavassistFieldFactory extends JavassistMemberFactory
+{
+ /** The names of the interfaces we are implementing */
+ protected static final String[] interfaceNames;
+
+ /** The methods from the interface that are being implemented */
+ protected static final Method[] methods;
+
+ static
+ {
+ interfaceNames = new String[] {JavassistField.class.getName()};
+ methods = new Method[2];
+ try
+ {
+ methods[0] = SecurityActions.getDeclaredMethod(JavassistField.class, "get", Object.class);
+ methods[1] = SecurityActions.getDeclaredMethod(JavassistField.class, "set", Object.class, Object.class);
+ }
+ catch (NoSuchMethodException e)
+ {
+ throw new RuntimeException(e);
+ }
+ }
+
+ /** The field we are targeting */
+ final CtField ctField;
+
+ /** The name of the class being generated */
+ final String className = JavassistField.class.getName() + counter.incrementAndGet();
+
+ /**
+ * Constructor
+ *
+ * @param superClass the super class to use for the implementation
+ * @param ctField the field we are generating a {@link JavassistField} for
+ * @param check whether the methods implemented from the interfaces should check the parameters
+ * @param debug true to cause the class bytes to be output to the file system so they can be inspected with a decompiler/javap
+ */
+ JavassistFieldFactory(Class<?> superClass, CtField ctField, boolean check, boolean debug)
+ {
+ super(superClass, check, debug);
+ this.ctField = ctField;
+ }
+
+ @Override
+ String getGeneratedClassName()
+ {
+ return className;
+ }
+
+ @Override
+ String[] getInterfaceNames()
+ {
+ return interfaceNames;
+ }
+
+ /**
+ * Gets the type of the field
+ *
+ * @return the field type
+ */
+ private CtClass getFieldType()
+ {
+ try
+ {
+ return ctField.getType();
+ }
+ catch (NotFoundException e)
+ {
+ // AutoGenerated
+ throw new RuntimeException(e);
+ }
+ }
+
+ @Override
+ String getAccessedMember()
+ {
+ return ctField.getDeclaringClass().getName() + "." + ctField.getName() + ctField.getSignature();
+ }
+
+ @Override
+ String initAccessedMember()
+ {
+ return null;
+ }
+
+ @Override
+ MethodInfo implementMethod(int index, ConstPool cp)
+ {
+ if (index >= methods.length)
+ return null;
+
+ String desc = RuntimeSupport.makeDescriptor(methods[index]);
+ MethodInfo minfo = new MethodInfo(cp, methods[index].getName(), desc);
+ minfo.setAccessFlags(Modifier.PUBLIC);
+ setThrows(minfo, cp, methods[index].getExceptionTypes());
+ Bytecode code = new Bytecode(cp, 0, 0);
+
+ int pc = code.currentPc();
+ int s = countParameterStackSize(1, getFieldType());
+ boolean isStatic = Modifier.isStatic(ctField.getModifiers());
+
+ checkTargetParameter(code, ctField.getDeclaringClass().getName(), isStatic);
+
+ if (index == 0)
+ makeGetMethod(code, methods[index], cp, isStatic);
+ else
+ makeSetMethod(code, methods[index], cp, isStatic);
+
+ code.setMaxLocals(s + 1);
+ CodeAttribute ca = code.toCodeAttribute();
+ minfo.setCodeAttribute(ca);
+
+ StackMapTable.Writer writer = new StackMapTable.Writer(32);
+ writer.sameFrame(pc);
+ ca.setAttribute(writer.toStackMapTable(cp));
+ return minfo;
+ }
+
+ private void makeGetMethod(Bytecode code, Method method, ConstPool cp, boolean isStatic)
+ {
+ if (isStatic)
+ {
+ code.addGetstatic(ctField.getDeclaringClass().getName(), ctField.getName(), ctField.getSignature());
+ }
+ else
+ {
+ //push and cast the target object
+ code.addAload(1);
+ code.addCheckcast(ctField.getDeclaringClass());
+ code.addGetfield(ctField.getDeclaringClass(), ctField.getName(), ctField.getSignature());
+ }
+ boxReturnValue(code, getFieldType());
+ code.addOpcode(Opcode.ARETURN);
+
+ }
+
+ private void makeSetMethod(Bytecode code, Method method, ConstPool cp, boolean isStatic)
+ {
+ if (!isStatic)
+ {
+ //push and cast the target object
+ code.addAload(1);
+ code.addCheckcast(ctField.getDeclaringClass());
+ }
+
+ //push and cast the value
+ code.addAload(2);
+ castAndUnbox(code, getFieldType());
+
+ if (isStatic)
+ {
+ code.addPutstatic(ctField.getDeclaringClass().getName(), ctField.getName(), ctField.getSignature());
+ }
+ else
+ {
+ code.addPutfield(ctField.getDeclaringClass(), ctField.getName(), ctField.getSignature());
+ }
+
+ code.addOpcode(Opcode.RETURN);
+ }
+}
\ No newline at end of file
Added: projects/jboss-reflect/trunk/src/main/java/org/jboss/reflect/plugins/javassist/bytecode/JavassistMemberFactory.java
===================================================================
--- projects/jboss-reflect/trunk/src/main/java/org/jboss/reflect/plugins/javassist/bytecode/JavassistMemberFactory.java (rev 0)
+++ projects/jboss-reflect/trunk/src/main/java/org/jboss/reflect/plugins/javassist/bytecode/JavassistMemberFactory.java 2010-03-24 16:48:26 UTC (rev 102910)
@@ -0,0 +1,708 @@
+/*
+* JBoss, Home of Professional Open Source.
+* Copyright 2006, Red Hat Middleware LLC, and individual contributors
+* as indicated by the @author tags. See the copyright.txt file in the
+* distribution for a full listing of individual contributors.
+*
+* This is free software; you can redistribute it and/or modify it
+* under the terms of the GNU Lesser General Public License as
+* published by the Free Software Foundation; either version 2.1 of
+* the License, or (at your option) any later version.
+*
+* This software is distributed in the hope that it will be useful,
+* but WITHOUT ANY WARRANTY; without even the implied warranty of
+* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+* Lesser General Public License for more details.
+*
+* You should have received a copy of the GNU Lesser General Public
+* License along with this software; if not, write to the Free
+* Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+* 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+*/
+package org.jboss.reflect.plugins.javassist.bytecode;
+
+import java.io.DataOutputStream;
+import java.io.FileOutputStream;
+import java.io.IOException;
+import java.lang.reflect.Constructor;
+import java.util.concurrent.atomic.AtomicInteger;
+
+import javassist.CannotCompileException;
+import javassist.CtClass;
+import javassist.CtConstructor;
+import javassist.CtField;
+import javassist.CtMethod;
+import javassist.Modifier;
+import javassist.bytecode.AccessFlag;
+import javassist.bytecode.Bytecode;
+import javassist.bytecode.ClassFile;
+import javassist.bytecode.CodeAttribute;
+import javassist.bytecode.ConstPool;
+import javassist.bytecode.DuplicateMemberException;
+import javassist.bytecode.ExceptionsAttribute;
+import javassist.bytecode.MethodInfo;
+import javassist.bytecode.Opcode;
+import javassist.bytecode.StackMapTable;
+import javassist.util.proxy.FactoryHelper;
+import javassist.util.proxy.RuntimeSupport;
+
+import org.jboss.reflect.plugins.javassist.JavassistConstructor;
+import org.jboss.reflect.plugins.javassist.JavassistField;
+import org.jboss.reflect.plugins.javassist.JavassistMethod;
+import org.jboss.util.UnreachableStatementException;
+
+/**
+ * <p>Abstract base class to create implementations of the {@link JavassistMethod}, {@link JavassistConstructor}
+ * and {@link JavassistField} interfaces.</p>
+ * <p>This implementation generates raw bytecode to avoid the overhead of compilation via javassist. If
+ * <code>sun.reflect.MagicAccessorImpl</code> is used as the <code>superClass</code> field the implementation
+ * classes can access private and protected members of the target class.</p>
+ *
+ *
+ * @author <a href="kabir.khan at jboss.com">Kabir Khan</a>
+ * @version $Revision: 1.1 $
+ */
+public abstract class JavassistMemberFactory
+{
+ protected static final String OBJECT_NAME = Object.class.getName();
+
+ private static final String STRINGBUILDER_NAME = StringBuilder.class.getName();
+
+ protected static final String ILLEGAL_ARGUMENT_EXCEPTION_NAME = IllegalArgumentException.class.getName();
+
+ private static final String SHORT_NAME = Short.class.getName();
+
+ private static final String LONG_NAME = Long.class.getName();
+
+ private static final String INTEGER_NAME = Integer.class.getName();
+
+ private static final String FLOAT_NAME = Float.class.getName();
+
+ private static final String DOUBLE_NAME = Double.class.getName();
+
+ private static final String CHARACTER_NAME = Character.class.getName();
+
+ protected static final String BYTE_NAME = Byte.class.getName();
+
+ protected static final String BOOLEAN_NAME = Boolean.class.getName();
+
+ /** Descriptor for new IllegalArgumentException(String) */
+ protected static final String ILLEGAL_ARGUMENT_EXCEPTION_CONSTRUCTOR_DESCRIPTOR = RuntimeSupport.makeDescriptor(new Class<?>[] {String.class}, Void.TYPE);
+
+ /** Descriptor for StringBuilder.toString() */
+ protected static final String STRINGBUILDER_TOSTRING_DESCRIPTOR = RuntimeSupport.makeDescriptor(new Class<?>[0], String.class);
+
+ /** Descriptor for StringBuilder.append(Object) */
+ protected static final String STRINGBUILDER_APPEND_DESCRIPTOR = RuntimeSupport.makeDescriptor(new Class<?>[] {Object.class}, StringBuilder.class);
+
+ /** Descriptor for new StringBuilder(String) */
+ protected static final String STRINGBUILDER_CONSTRUCTOR_DESCRIPTOR = RuntimeSupport.makeDescriptor(new Class[]{String.class}, Void.TYPE);
+
+ /** Descriptor for Boolean.booleanValue() */
+ private final static String BOOLEAN_VALUE_DESCRIPTOR = RuntimeSupport.makeDescriptor(new Class[0], Boolean.TYPE);
+
+ /** Descriptor for Byte.byteValue() */
+ private final static String BYTE_VALUE_DESCRIPTOR = RuntimeSupport.makeDescriptor(new Class[0], Byte.TYPE);
+
+ /** Descriptor for Character.charValue() */
+ private final static String CHAR_VALUE_DESCRIPTOR = RuntimeSupport.makeDescriptor(new Class[0], Character.TYPE);
+
+ /** Descriptor for Double.doubleValue() */
+ private final static String DOUBLE_VALUE_DESCRIPTOR = RuntimeSupport.makeDescriptor(new Class[0], Double.TYPE);
+
+ /** Descriptor for Float.floatValue() */
+ private final static String FLOAT_VALUE_DESCRIPTOR = RuntimeSupport.makeDescriptor(new Class[0], Float.TYPE);
+
+ /** Descriptor for Integer.intValue() */
+ private final static String INTEGER_VALUE_DESCRIPTOR = RuntimeSupport.makeDescriptor(new Class[0], Integer.TYPE);
+
+ /** Descriptor for Long.longValue() */
+ private final static String LONG_VALUE_DESCRIPTOR = RuntimeSupport.makeDescriptor(new Class[0], Long.TYPE);
+
+ /** Descriptor for Short.shortValue() */
+ private final static String SHORT_VALUE_DESCRIPTOR = RuntimeSupport.makeDescriptor(new Class[0], Short.TYPE);
+
+ /** Descriptor for Boolean.valueOf */
+ private final static String BOOLEAN_VALUE_OF_DESCRIPTOR = RuntimeSupport.makeDescriptor(new Class[] {Boolean.TYPE}, Boolean.class);
+
+ /** Descriptor for Byte.valueOf */
+ private final static String BYTE_VALUE_OF_DESCRIPTOR = RuntimeSupport.makeDescriptor(new Class[] {Byte.TYPE}, Byte.class);
+
+ /** Descriptor for Character.valueOf */
+ private final static String CHARACTER_VALUE_OF_DESCRIPTOR = RuntimeSupport.makeDescriptor(new Class[] {Character.TYPE}, Character.class);
+
+ /** Descriptor for Double.valueOf */
+ private final static String DOUBLE_VALUE_OF_DESCRIPTOR = RuntimeSupport.makeDescriptor(new Class[] {Double.TYPE}, Double.class);
+
+ /** Descriptor for Float.valueOf */
+ private final static String FLOAT_VALUE_OF_DESCRIPTOR = RuntimeSupport.makeDescriptor(new Class[] {Float.TYPE}, Float.class);
+
+ /** Descriptor for Integer.valueOf */
+ private final static String INTEGER_VALUE_OF_DESCRIPTOR = RuntimeSupport.makeDescriptor(new Class[] {Integer.TYPE}, Integer.class);
+
+ /** Descriptor for Long.valueOf */
+ private final static String LONG_VALUE_OF_DESCRIPTOR = RuntimeSupport.makeDescriptor(new Class[] {Long.TYPE}, Long.class);
+
+ /** Descriptor for Short.valueOf */
+ private final static String SHORT_VALUE_OF_DESCRIPTOR = RuntimeSupport.makeDescriptor(new Class[] {Short.TYPE}, Short.class);
+
+
+ /** The method class counter */
+ protected static final AtomicInteger counter = new AtomicInteger(0);
+
+ /** The super class to use for the implementation */
+ private final Class<?> superClass;
+
+ /** Whether the methods implemented from the interfaces should check the parameters */
+ protected final boolean check;
+
+ /** If true the class bytes are output to the file system so they can be inspected with a decompiler/javap */
+ private final boolean debug;
+
+ /** Cached string representation of the signature of the accessed member */
+ private String accessedMember;
+
+ /**
+ * Constructor
+ *
+ * @param superClass the super class to use for the implementation
+ * @param check whether the methods implemented from the interfaces should check the parameters
+ * @param debug true to cause the class bytes to be output to the file system so they can be inspected with a decompiler/javap
+ */
+ JavassistMemberFactory(Class<?> superClass, boolean check, boolean debug)
+ {
+ this.superClass = superClass;
+ this.check = check;
+ this.debug = debug;
+ }
+
+ /**
+ * Creates a new {@link JavassistMethod} implementation for a given method
+ *
+ * @param superClass the super class of the JavassistMethod implementation
+ * @param ctMethod the CtMethod for which we want to create a JavassistMethod implementation
+ * @param check true if the JavassistMethod implementation should check the parameters when its invoke method is called
+ * @param debug true if the bytecode should be output to file
+ * @return the generated class
+ * @throws RuntimeException if an error ocurred
+ */
+ public static JavassistMethod createJavassistMethod(Class<?> superClass, CtMethod ctMethod, boolean check, boolean debug)
+ {
+ JavassistMemberFactory factory = new JavassistMethodFactory(superClass, ctMethod, check, debug);
+ Class<JavassistMethod> member = factory.makeClass(JavassistMethod.class, ctMethod.getDeclaringClass());
+ return factory.instantiate(member);
+ }
+
+ /**
+ * Creates a new {@link JavassistConstructor} implementation for a given constructor
+ *
+ * @param superClass the super class of the JavassistConstructor implementation
+ * @param ctConstructor the CtConstructor for which we want to create a JavassistConstructor implementation
+ * @param check true if the JavassistConstructor implementation should check the parameters when its invoke method is called
+ * @param debug true if the bytecode should be output to file
+ * @return the generated class
+ * @throws RuntimeException if an error ocurred
+ */
+ public static JavassistConstructor createJavassistConstructor(Class<?> superClass, CtConstructor ctConstructor, boolean check, boolean debug)
+ {
+ JavassistMemberFactory factory = new JavassistConstructorFactory(superClass, ctConstructor, check, debug);
+ Class<JavassistConstructor> member = factory.makeClass(JavassistConstructor.class, ctConstructor.getDeclaringClass());
+ return factory.instantiate(member);
+ }
+
+ /**
+ * Creates a new {@link JavassistField} implementation for a given field
+ *
+ * @param superClass the super class of the JavassistField implementation
+ * @param ctField the CtField for which we want to create a JavassistField implementation
+ * @param check true if the JavassistField implementation should check the parameters when its get/set methods are called
+ * @param debug true if the bytecode should be output to file
+ * @return the generated class
+ * @throws RuntimeException if an error ocurred
+ */
+ public static JavassistField createJavassistField(Class<?> superClass, CtField ctField, boolean check, boolean debug)
+ {
+ JavassistMemberFactory factory = new JavassistFieldFactory(superClass, ctField, check, debug);
+ Class<JavassistField> member = factory.makeClass(JavassistField.class, ctField.getDeclaringClass());
+ return factory.instantiate(member);
+ }
+
+ /**
+ * Instantiates the class
+ *
+ * @param clazz the class
+ * @return the instance
+ * @throws RuntimeException if an error ocurred
+ */
+ protected <T> T instantiate(Class<T> clazz)
+ {
+ try
+ {
+ return clazz.newInstance();
+ }
+ catch (Exception e)
+ {
+ // AutoGenerated
+ throw new RuntimeException(e);
+ }
+ }
+
+
+ /**
+ * Creates a JavassistMethod/-Field/-Constructor implementation
+ *
+ * @return the generated class
+ */
+ protected <T> Class<T> makeClass(Class<T> expected, CtClass target)
+ {
+ try
+ {
+ //Create a new public class
+ ClassFile cf = new ClassFile(false, getGeneratedClassName(), superClass.getName());
+ cf.setAccessFlags(AccessFlag.PUBLIC);
+ cf.setInterfaces(getInterfaceNames());
+
+ //Add the constructors from the super class
+ makeConstructors(cf);
+
+ //implement the methods from the interfaces
+ implementMethods(cf);
+
+ if (debug)
+ debugWriteFile(cf);
+
+
+ ClassLoader cl = target.getClassPool().getClassLoader();
+ return FactoryHelper.toClass(cf, cl);
+ }
+ catch (Exception e)
+ {
+ throw new RuntimeException(e);
+ }
+ }
+
+ /**
+ * Implements the methods of the interface
+ *
+ * @param cf the class file of the class we are creating
+ */
+ void implementMethods(ClassFile cf) throws DuplicateMemberException
+ {
+ int i = 0;
+ while (true)
+ {
+ MethodInfo minfo = implementMethod(i++, cf.getConstPool());
+ if (minfo == null)
+ break;
+ cf.addMethod(minfo);
+ }
+ }
+
+ /**
+ * Returns the signature string of the accessed member
+ *
+ * @return the signature
+ */
+ String getAccessedMember()
+ {
+ if (accessedMember == null)
+ {
+ accessedMember = initAccessedMember();
+ }
+ return accessedMember;
+ }
+
+ /**
+ * Create the method
+ *
+ * @param index the current index (starting at 0)
+ * @param cp the constant pool
+ * @return the created method, or null if there was no method with that index
+ */
+ abstract MethodInfo implementMethod(int index, ConstPool cp);
+
+ /**
+ * Get the names of the interfaces to implement
+ */
+ abstract String[] getInterfaceNames();
+
+ /**
+ * Get the name of the class we are creating
+ *
+ * @return the class name
+ */
+ abstract String getGeneratedClassName();
+
+ /**
+ * Initialize the signature string of the accessed member
+ *
+ * @return the signature
+ */
+ abstract String initAccessedMember();
+
+ /**
+ * Counts the maximum stack size of the methods being implemented
+ *
+ * @param offset the offset
+ * @param params an array containing the parameters being implemented
+ * @return the max stack size
+ */
+ int countParameterStackSize(int offset, CtClass...params)
+ {
+ int stacksize = offset;
+ int n = params.length;
+ for (int i = 0; i < n; ++i)
+ {
+ stacksize++;
+ if (params[i].equals(CtClass.longType) || params[i].equals(CtClass.doubleType))
+ stacksize++;
+ }
+
+ return stacksize;
+ }
+
+ /**
+ * Adds the constructors from the super class to the and delegates to them
+ * via super calls
+ *
+ * @param cf the class file of the class we are creating
+ * @throws CannotCompileException if any of the constructors could not be added
+ */
+ private void makeConstructors(ClassFile cf) throws CannotCompileException
+ {
+ Constructor<?>[] cons = SecurityActions.getDeclaredConstructors(superClass);
+ for (int i = 0; i < cons.length; i++)
+ {
+ Constructor<?> c = cons[i];
+ int mod = c.getModifiers();
+ if (!Modifier.isFinal(mod) && !Modifier.isPrivate(mod))
+ {
+ MethodInfo m = makeConstructor(c, cf.getConstPool());
+ cf.addMethod(m);
+ }
+ }
+ }
+
+ /**
+ * Add a particular constructor from the super class and delegate to it via a
+ * super call
+ *
+ * @param cons the constructor we are implementing
+ * @param cp the constant pool of the class we are generating
+ * @return the method info for the created constructor
+ */
+ private MethodInfo makeConstructor(Constructor<?> cons, ConstPool cp)
+ {
+ String desc = RuntimeSupport.makeDescriptor(cons.getParameterTypes(), Void.TYPE);
+ MethodInfo minfo = new MethodInfo(cp, "<init>", desc);
+ minfo.setAccessFlags(Modifier.PUBLIC);
+ setThrows(minfo, cp, cons.getExceptionTypes());
+ Bytecode code = new Bytecode(cp, 0, 0);
+
+ int pc = code.currentPc();
+
+ code.addAload(0);
+ int s = addLoadParameters(code, cons.getParameterTypes(), 1);
+ code.addInvokespecial(superClass.getName(), "<init>", desc);
+ code.addOpcode(Opcode.RETURN);
+ code.setMaxLocals(s + 1);
+ CodeAttribute ca = code.toCodeAttribute();
+ minfo.setCodeAttribute(ca);
+
+ StackMapTable.Writer writer = new StackMapTable.Writer(32);
+ writer.sameFrame(pc);
+ ca.setAttribute(writer.toStackMapTable(cp));
+ return minfo;
+ }
+
+ /**
+ * Adds a throws clause to a method info
+ *
+ * @param minfo the method info being created
+ * @param cp the constant pool of the class file the minfo will be added to
+ * @param exceptions the exceptions to be added to the throws clause
+ */
+ void setThrows(MethodInfo minfo, ConstPool cp, Class<?>[] exceptions)
+ {
+ if (exceptions.length == 0)
+ return;
+
+ String[] list = new String[exceptions.length];
+ for (int i = 0; i < exceptions.length; i++)
+ list[i] = exceptions[i].getName();
+
+ ExceptionsAttribute ea = new ExceptionsAttribute(cp);
+ ea.setExceptions(list);
+ minfo.setExceptionsAttribute(ea);
+ }
+
+ /**
+ * Writes the class file bytes to the local file system so they can be inspected
+ * with javap or another decompiler.
+ *
+ * @param cf the class file
+ * @throws IOException if an error occurred writing the file
+ */
+ void debugWriteFile(ClassFile cf) throws IOException
+ {
+ FileOutputStream fout = new FileOutputStream(cf.getName() + ".class");
+ DataOutputStream out = new DataOutputStream(fout);
+ try
+ {
+ cf.write(out);
+ }
+ finally {
+ out.close();
+ }
+ }
+
+ /**
+ * Adds instructions to load all the parameters for a method/constructor
+ *
+ * @param code the byte code of the method/constructor being constructed
+ * @param params the types of the parameters of the method/constructor
+ * @param offset the offset
+ * @return the stack size
+ */
+ int addLoadParameters(Bytecode code, Class<?>[] params, int offset)
+ {
+ int stacksize = 0;
+ int n = params.length;
+ for (int i = 0; i < n; ++i)
+ stacksize += addLoad(code, stacksize + offset, params[i]);
+
+ return stacksize;
+ }
+
+ /**
+ * Adds the instruction to load a particular parameter for a method constructor
+ *
+ * @param code the byte code of the method/constructor being constructed
+ * @param index the index of the parameter
+ * @param type the type of the parameter
+ * @return the stack size required for loading the parameter
+ */
+ int addLoad(Bytecode code, int index, Class<?> type)
+ {
+ if (type.isPrimitive())
+ {
+ if (type == Long.TYPE)
+ {
+ code.addLload(index);
+ return 2;
+ }
+ else if (type == Float.TYPE)
+ code.addFload(index);
+ else if (type == Double.TYPE)
+ {
+ code.addDload(index);
+ return 2;
+ }
+ else
+ code.addIload(index);
+ }
+ else
+ code.addAload(index);
+
+ return 1;
+ }
+
+ /**
+ * Get the boxed type
+ *
+ * TODO JBMICROCONT-119 integer progression?
+ * @param type the type to box
+ * @return the boxed type name
+ */
+ String getBoxedType(CtClass type)
+ {
+ if (type.isPrimitive())
+ {
+ if (CtClass.booleanType.equals(type))
+ return BOOLEAN_NAME;
+ else if (CtClass.byteType.equals(type))
+ return BYTE_NAME;
+ else if (CtClass.charType.equals(type))
+ return CHARACTER_NAME;
+ else if (CtClass.doubleType.equals(type))
+ return DOUBLE_NAME;
+ else if (CtClass.floatType.equals(type))
+ return FLOAT_NAME;
+ else if (CtClass.intType.equals(type))
+ return INTEGER_NAME;
+ else if (CtClass.longType.equals(type))
+ return LONG_NAME;
+ else if (CtClass.shortType.equals(type))
+ return SHORT_NAME;
+ throw new UnreachableStatementException();
+ }
+ return type.getName();
+ }
+
+ /**
+ * Casts the value currently on the stack to the target type, and if a primitive
+ * unboxes it. The byte code instructions to do this are added to the
+ * <code>code</code> parameter.
+ *
+ * @param code the byte code of the method/constructor we are creating
+ * @param type the target type we want to cast to
+ */
+ void castAndUnbox(Bytecode code, CtClass type)
+ {
+ if (type.getName().equals(OBJECT_NAME))
+ return;
+
+ code.addCheckcast(getBoxedType(type));
+ if (type.isPrimitive())
+ {
+ if (CtClass.booleanType.equals(type))
+ {
+ code.addInvokevirtual(BOOLEAN_NAME, "booleanValue", BOOLEAN_VALUE_DESCRIPTOR);
+ return;
+ }
+ else if (CtClass.byteType.equals(type))
+ {
+ code.addInvokevirtual(BYTE_NAME, "byteValue", BYTE_VALUE_DESCRIPTOR);
+ return;
+ }
+ else if (CtClass.charType.equals(type))
+ {
+ code.addInvokevirtual(CHARACTER_NAME, "charValue", CHAR_VALUE_DESCRIPTOR);
+ return;
+ }
+ else if (CtClass.doubleType.equals(type))
+ {
+ code.addInvokevirtual(DOUBLE_NAME, "doubleValue", DOUBLE_VALUE_DESCRIPTOR);
+ return;
+ }
+ else if (CtClass.floatType.equals(type))
+ {
+ code.addInvokevirtual(FLOAT_NAME, "floatValue", FLOAT_VALUE_DESCRIPTOR);
+ return;
+ }
+ else if (CtClass.intType.equals(type))
+ {
+ code.addInvokevirtual(INTEGER_NAME, "intValue", INTEGER_VALUE_DESCRIPTOR);
+ return;
+ }
+ else if (CtClass.longType.equals(type))
+ {
+ code.addInvokevirtual(LONG_NAME, "longValue", LONG_VALUE_DESCRIPTOR);
+ return;
+ }
+ else if (CtClass.shortType.equals(type))
+ {
+ code.addInvokevirtual(SHORT_NAME, "shortValue", SHORT_VALUE_DESCRIPTOR);
+ return;
+ }
+ throw new UnreachableStatementException();
+ }
+
+ }
+
+ /**
+ * Adds the byte code instructions to the <code>code</code> paramter to box the value currently on the stack to the target type.
+ *
+ * @param code the byte code of the method/constructor we are currently creating
+ * @param type the type we want to cast to
+ */
+ void boxReturnValue(Bytecode code, CtClass type)
+ {
+ if (type.isPrimitive())
+ {
+ if (CtClass.booleanType.equals(type))
+ {
+ code.addInvokestatic(BOOLEAN_NAME, "valueOf", BOOLEAN_VALUE_OF_DESCRIPTOR);
+ return;
+ }
+ else if (CtClass.byteType.equals(type))
+ {
+ code.addInvokestatic(BYTE_NAME, "valueOf", BYTE_VALUE_OF_DESCRIPTOR);
+ return;
+ }
+ else if (CtClass.charType.equals(type))
+ {
+ code.addInvokestatic(CHARACTER_NAME, "valueOf", CHARACTER_VALUE_OF_DESCRIPTOR);
+ return;
+ }
+ else if (CtClass.doubleType.equals(type))
+ {
+ code.addInvokestatic(DOUBLE_NAME, "valueOf", DOUBLE_VALUE_OF_DESCRIPTOR);
+ return;
+ }
+ else if (CtClass.floatType.equals(type))
+ {
+ code.addInvokestatic(FLOAT_NAME, "valueOf", FLOAT_VALUE_OF_DESCRIPTOR);
+ return;
+ }
+ else if (CtClass.intType.equals(type))
+ {
+ code.addInvokestatic(INTEGER_NAME, "valueOf", INTEGER_VALUE_OF_DESCRIPTOR);
+ return;
+ }
+ else if (CtClass.longType.equals(type))
+ {
+ code.addInvokestatic(LONG_NAME, "valueOf", LONG_VALUE_OF_DESCRIPTOR);
+ return;
+ }
+ else if (CtClass.shortType.equals(type))
+ {
+ code.addInvokestatic(SHORT_NAME, "valueOf", SHORT_VALUE_OF_DESCRIPTOR);
+ return;
+ }
+ throw new UnreachableStatementException();
+ }
+ }
+
+ /**
+ * Adds byte code instructions to the <code>code</code> parameter to check if
+ * the first parameter to the method/constructor being constructed is of a particular
+ * type
+ *
+ * @param code the byte code of the method/constructor we are currently creating
+ * @param targetType the type we want to make sure we have
+ * @param isStatic true if the method being created is static?
+ */
+ void checkTargetParameter(Bytecode code, String targetType, boolean isStatic)
+ {
+ if (!isStatic)
+ {
+ //if ($1 == null) throw new IllegalArgumentException("Null target");
+ if (check)
+ {
+ code.addAload(1);
+ code.addOpcode(Opcode.IFNONNULL);
+ int pc1 = code.currentPc();
+ code.addIndex(0);
+ code.addNew(ILLEGAL_ARGUMENT_EXCEPTION_NAME);
+ code.addOpcode(Opcode.DUP);
+ code.addLdc("Null target for " + getAccessedMember());
+ code.addInvokespecial(ILLEGAL_ARGUMENT_EXCEPTION_NAME, "<init>", ILLEGAL_ARGUMENT_EXCEPTION_CONSTRUCTOR_DESCRIPTOR);
+ code.addOpcode(Opcode.ATHROW);
+ code.write16bit(pc1, code.currentPc() - pc1 + 1);
+ }
+
+ //if ($1 instanceof TargetType == false) throw new IllegalArgumentException("$1 is not an instance of TargetType");
+ code.addAload(1);
+ code.addInstanceof(targetType); //TODO take parameter
+ code.addOpcode(Opcode.IFNE);
+ int pc1 = code.currentPc();
+ code.addIndex(0);
+ code.addNew(ILLEGAL_ARGUMENT_EXCEPTION_NAME);
+ code.addOpcode(Opcode.DUP);
+ code.addNew(STRINGBUILDER_NAME);
+ code.addOpcode(Opcode.DUP);
+ code.addLdc("Target: ");
+ code.addInvokespecial(STRINGBUILDER_NAME, "<init>", STRINGBUILDER_CONSTRUCTOR_DESCRIPTOR);
+ code.addAload(1);
+ code.addInvokevirtual(STRINGBUILDER_NAME, "append", STRINGBUILDER_APPEND_DESCRIPTOR);
+ code.addLdc(" is not an instance of " + targetType);
+ code.addInvokevirtual(STRINGBUILDER_NAME, "append", STRINGBUILDER_APPEND_DESCRIPTOR);
+ code.addInvokevirtual(STRINGBUILDER_NAME, "toString", STRINGBUILDER_TOSTRING_DESCRIPTOR);
+ code.addInvokespecial(ILLEGAL_ARGUMENT_EXCEPTION_NAME, "<init>", ILLEGAL_ARGUMENT_EXCEPTION_CONSTRUCTOR_DESCRIPTOR);
+ code.addOpcode(Opcode.ATHROW);
+ code.write16bit(pc1, code.currentPc() - pc1 + 1);
+ }
+ }
+
+}
\ No newline at end of file
Added: projects/jboss-reflect/trunk/src/main/java/org/jboss/reflect/plugins/javassist/bytecode/JavassistMethodFactory.java
===================================================================
--- projects/jboss-reflect/trunk/src/main/java/org/jboss/reflect/plugins/javassist/bytecode/JavassistMethodFactory.java (rev 0)
+++ projects/jboss-reflect/trunk/src/main/java/org/jboss/reflect/plugins/javassist/bytecode/JavassistMethodFactory.java 2010-03-24 16:48:26 UTC (rev 102910)
@@ -0,0 +1,196 @@
+/*
+* JBoss, Home of Professional Open Source.
+* Copyright 2006, Red Hat Middleware LLC, and individual contributors
+* as indicated by the @author tags. See the copyright.txt file in the
+* distribution for a full listing of individual contributors.
+*
+* This is free software; you can redistribute it and/or modify it
+* under the terms of the GNU Lesser General Public License as
+* published by the Free Software Foundation; either version 2.1 of
+* the License, or (at your option) any later version.
+*
+* This software is distributed in the hope that it will be useful,
+* but WITHOUT ANY WARRANTY; without even the implied warranty of
+* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+* Lesser General Public License for more details.
+*
+* You should have received a copy of the GNU Lesser General Public
+* License along with this software; if not, write to the Free
+* Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+* 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+*/
+package org.jboss.reflect.plugins.javassist.bytecode;
+
+import java.lang.reflect.Method;
+
+import javassist.CtClass;
+import javassist.CtMethod;
+import javassist.Modifier;
+import javassist.NotFoundException;
+import javassist.bytecode.Bytecode;
+import javassist.bytecode.CodeAttribute;
+import javassist.bytecode.ConstPool;
+import javassist.bytecode.MethodInfo;
+import javassist.bytecode.Opcode;
+import javassist.bytecode.StackMapTable;
+import javassist.util.proxy.RuntimeSupport;
+
+import org.jboss.reflect.plugins.javassist.JavassistMethod;
+
+/**
+ * <p>Class to create implementations of the {@link JavassistMethod} interface.</p>
+ *
+ * <p>This implementation generates raw bytecode to avoid the overhead of compilation via javassist. If
+ * <code>sun.reflect.MagicAccessorImpl</code> is used as the <code>superClass</code> field the implementation
+ * classes can access private and protected members of the target class.</p>
+ *
+ * @author <a href="kabir.khan at jboss.com">Kabir Khan</a>
+ * @version $Revision: 1.1 $
+ */
+public class JavassistMethodFactory extends JavassistBehaviorFactory
+{
+ /** The names of the interfaces we are implementing */
+ private static final String[] interfaceNames;
+
+ /** The methods from the interface that are being implemented */
+ private static final Method[] methods;
+
+ static
+ {
+ interfaceNames = new String[] {JavassistMethod.class.getName()};
+ methods = new Method[1];
+ try
+ {
+ methods[0] = SecurityActions.getDeclaredMethod(JavassistMethod.class, "invoke", Object.class, Object[].class);
+ }
+ catch (NoSuchMethodException e)
+ {
+ throw new RuntimeException(e);
+ }
+ }
+
+ /** The method we are targeting */
+ private final CtMethod ctMethod;
+
+ /** The name of the class being generated */
+ private final String className = JavassistMethod.class.getName() + counter.incrementAndGet();
+
+
+ /**
+ * Constructor
+ *
+ * @param superClass the super class to use for the implementation
+ * @param ctMethod the constructor we are generating a {@link JavassistMethod} for
+ * @param check whether the methods implemented from the interfaces should check the parameters
+ * @param debug true to cause the class bytes to be output to the file system so they can be inspected with a decompiler/javap
+ */
+ JavassistMethodFactory(Class<?> superClass, CtMethod ctMethod, boolean check, boolean debug)
+ {
+ super(superClass, ctMethod, check, debug);
+ this.ctMethod = ctMethod;
+ }
+
+ String getGeneratedClassName()
+ {
+ return className;
+ }
+
+
+ String[] getInterfaceNames()
+ {
+ return interfaceNames;
+ }
+
+ /**
+ * The return type of the method we are targeting
+ *
+ * @return the target type
+ */
+ private CtClass getReturnType()
+ {
+ try
+ {
+ return ctMethod.getReturnType();
+ }
+ catch (NotFoundException e)
+ {
+ throw new RuntimeException(e);
+ }
+ }
+
+ @Override
+ MethodInfo implementMethod(int index, ConstPool cp)
+ {
+ if (index >= methods.length)
+ return null;
+
+ Method method = methods[index];
+
+ String desc = RuntimeSupport.makeDescriptor(method);
+ MethodInfo minfo = new MethodInfo(cp, method.getName(), desc);
+ minfo.setAccessFlags(Modifier.PUBLIC);
+ setThrows(minfo, cp, method.getExceptionTypes());
+ Bytecode code = new Bytecode(cp, 0, 0);
+
+ int pc = code.currentPc();
+
+
+ boolean isStatic = Modifier.isStatic(ctBehavior.getModifiers());
+ checkTargetParameter(code, ctBehavior.getDeclaringClass().getName(), isStatic);
+ checkParameters(code, 2);
+
+ if (!isStatic)
+ {
+ //push and cast the target object
+ code.addAload(1);
+ code.addCheckcast(ctMethod.getDeclaringClass());
+ }
+
+ addParameters(code, getParameterTypes(), 2);
+
+ if (isStatic)
+ code.addInvokestatic(ctMethod.getDeclaringClass(), ctMethod.getName(), ctMethod.getSignature());
+ else if (ctMethod.getDeclaringClass().isInterface())
+ code.addInvokeinterface(ctMethod.getDeclaringClass(), ctMethod.getName(), ctMethod.getSignature(), countParameterStackSize(0, getParameterTypes()));
+ else
+ code.addInvokevirtual(ctMethod.getDeclaringClass(), ctMethod.getName(), ctMethod.getSignature());
+
+ if (getReturnType() == CtClass.voidType)
+ {
+ //return null;
+ code.addOpcode(Opcode.ACONST_NULL);
+ code.addOpcode(Opcode.ARETURN);
+ }
+ else
+ {
+ boxReturnValue(code, getReturnType());
+ code.addOpcode(Opcode.ARETURN);
+ }
+
+ code.setMaxLocals(determineMaxStackSize());
+
+ CodeAttribute ca = code.toCodeAttribute();
+ minfo.setCodeAttribute(ca);
+
+ StackMapTable.Writer writer = new StackMapTable.Writer(32);
+ writer.sameFrame(pc);
+ ca.setAttribute(writer.toStackMapTable(cp));
+ return minfo;
+ }
+
+ private int determineMaxStackSize()
+ {
+ //Not 100% sure what is going on here :-)
+
+ //This is the original code which yields a too small stack size if the target parameter size is 0
+ //int stackSize = countParameterStackSize(1, getParameterTypes());
+ //code.setMaxLocals(stackSize + 1);
+
+ //Try adding the parameters to the method being implemented AND the parameters for the target method
+ //This might be too big, but hopefully that won't hurt
+ int offset = 1; //TODO 0 if the target is static?
+ int stackSize = countParameterStackSize(offset, getParameterTypes());
+ stackSize += 2; //size of parameters to the invoke(Object target, Object[] args)
+ return stackSize + 1;
+ }
+}
\ No newline at end of file
Added: projects/jboss-reflect/trunk/src/main/java/org/jboss/reflect/plugins/javassist/bytecode/SecurityActions.java
===================================================================
--- projects/jboss-reflect/trunk/src/main/java/org/jboss/reflect/plugins/javassist/bytecode/SecurityActions.java (rev 0)
+++ projects/jboss-reflect/trunk/src/main/java/org/jboss/reflect/plugins/javassist/bytecode/SecurityActions.java 2010-03-24 16:48:26 UTC (rev 102910)
@@ -0,0 +1,114 @@
+/*
+* JBoss, Home of Professional Open Source.
+* Copyright 2006, Red Hat Middleware LLC, and individual contributors
+* as indicated by the @author tags. See the copyright.txt file in the
+* distribution for a full listing of individual contributors.
+*
+* This is free software; you can redistribute it and/or modify it
+* under the terms of the GNU Lesser General Public License as
+* published by the Free Software Foundation; either version 2.1 of
+* the License, or (at your option) any later version.
+*
+* This software is distributed in the hope that it will be useful,
+* but WITHOUT ANY WARRANTY; without even the implied warranty of
+* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+* Lesser General Public License for more details.
+*
+* You should have received a copy of the GNU Lesser General Public
+* License along with this software; if not, write to the Free
+* Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+* 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+*/
+package org.jboss.reflect.plugins.javassist.bytecode;
+
+import java.lang.reflect.Constructor;
+import java.lang.reflect.Method;
+import java.security.AccessController;
+import java.security.PrivilegedAction;
+import java.security.PrivilegedActionException;
+import java.security.PrivilegedExceptionAction;
+
+/**
+ *
+ * @author <a href="kabir.khan at jboss.com">Kabir Khan</a>
+ * @version $Revision: 1.1 $
+ */
+class SecurityActions
+{
+ static ClassLoader getContextClassLoader()
+ {
+ if (System.getSecurityManager() == null)
+ return Thread.currentThread().getContextClassLoader();
+ else
+ return AccessController.doPrivileged(GetContextClassLoaderAction.INSTANCE);
+ }
+
+ static class GetContextClassLoaderAction implements PrivilegedAction<ClassLoader>
+ {
+ final static GetContextClassLoaderAction INSTANCE = new GetContextClassLoaderAction();
+
+ public ClassLoader run()
+ {
+ return Thread.currentThread().getContextClassLoader();
+ }
+
+ }
+
+ static Constructor<?>[] getDeclaredConstructors(final Class<?> clazz)
+ {
+ if (System.getSecurityManager() == null)
+ return clazz.getDeclaredConstructors();
+ else
+ {
+ return AccessController.doPrivileged(new PrivilegedAction<Constructor<?>[]>()
+ {
+ public Constructor<?>[] run()
+ {
+ return clazz.getDeclaredConstructors();
+ }
+ });
+ }
+ }
+
+ static Method[] getDeclaredMethods(final Class<?> clazz)
+ {
+ if (System.getSecurityManager() == null)
+ return clazz.getDeclaredMethods();
+ else
+ {
+ return AccessController.doPrivileged(new PrivilegedAction<Method[]>()
+ {
+ public Method[] run()
+ {
+ return clazz.getDeclaredMethods();
+ }
+ });
+ }
+ }
+
+ static Method getDeclaredMethod(final Class<?> clazz, final String methodName, final Class<?>...classes) throws NoSuchMethodException
+ {
+ if (System.getSecurityManager() == null)
+ return clazz.getDeclaredMethod(methodName, classes);
+ else
+ {
+ try
+ {
+ return AccessController.doPrivileged(new PrivilegedExceptionAction<Method>()
+ {
+ public Method run() throws Exception
+ {
+ return clazz.getDeclaredMethod(methodName, classes);
+ }
+ });
+ }
+ catch (PrivilegedActionException e)
+ {
+ Exception ex = e.getException();
+ if (ex instanceof NoSuchMethodException)
+ throw (NoSuchMethodException)ex;
+ throw new RuntimeException(e);
+ }
+ }
+ }
+}
Added: projects/jboss-reflect/trunk/src/test/java/org/jboss/test/plugins/javassist/bytecode/support/BeanInterface.java
===================================================================
--- projects/jboss-reflect/trunk/src/test/java/org/jboss/test/plugins/javassist/bytecode/support/BeanInterface.java (rev 0)
+++ projects/jboss-reflect/trunk/src/test/java/org/jboss/test/plugins/javassist/bytecode/support/BeanInterface.java 2010-03-24 16:48:26 UTC (rev 102910)
@@ -0,0 +1,48 @@
+/*
+* JBoss, Home of Professional Open Source.
+* Copyright 2006, Red Hat Middleware LLC, and individual contributors
+* as indicated by the @author tags. See the copyright.txt file in the
+* distribution for a full listing of individual contributors.
+*
+* This is free software; you can redistribute it and/or modify it
+* under the terms of the GNU Lesser General Public License as
+* published by the Free Software Foundation; either version 2.1 of
+* the License, or (at your option) any later version.
+*
+* This software is distributed in the hope that it will be useful,
+* but WITHOUT ANY WARRANTY; without even the implied warranty of
+* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+* Lesser General Public License for more details.
+*
+* You should have received a copy of the GNU Lesser General Public
+* License along with this software; if not, write to the Free
+* Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+* 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+*/
+package org.jboss.test.plugins.javassist.bytecode.support;
+
+/**
+ *
+ * @author <a href="kabir.khan at jboss.com">Kabir Khan</a>
+ * @version $Revision: 1.1 $
+ */
+public interface BeanInterface
+{
+ Object getObject();
+
+ Boolean getBooleanField();
+
+ Byte getByteField();
+
+ Character getCharField();
+
+ Double getDoubleField();
+
+ Float getFloatField();
+
+ Integer getIntField();
+
+ Long getLongField();
+
+ Short getShortField();
+}
Added: projects/jboss-reflect/trunk/src/test/java/org/jboss/test/plugins/javassist/bytecode/support/PackageProtectedBoxedBean.java
===================================================================
--- projects/jboss-reflect/trunk/src/test/java/org/jboss/test/plugins/javassist/bytecode/support/PackageProtectedBoxedBean.java (rev 0)
+++ projects/jboss-reflect/trunk/src/test/java/org/jboss/test/plugins/javassist/bytecode/support/PackageProtectedBoxedBean.java 2010-03-24 16:48:26 UTC (rev 102910)
@@ -0,0 +1,220 @@
+/*
+* JBoss, Home of Professional Open Source.
+* Copyright 2006, Red Hat Middleware LLC, and individual contributors
+* as indicated by the @author tags. See the copyright.txt file in the
+* distribution for a full listing of individual contributors.
+*
+* This is free software; you can redistribute it and/or modify it
+* under the terms of the GNU Lesser General Public License as
+* published by the Free Software Foundation; either version 2.1 of
+* the License, or (at your option) any later version.
+*
+* This software is distributed in the hope that it will be useful,
+* but WITHOUT ANY WARRANTY; without even the implied warranty of
+* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+* Lesser General Public License for more details.
+*
+* You should have received a copy of the GNU Lesser General Public
+* License along with this software; if not, write to the Free
+* Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+* 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+*/
+package org.jboss.test.plugins.javassist.bytecode.support;
+
+/**
+ *
+ * @author <a href="kabir.khan at jboss.com">Kabir Khan</a>
+ * @version $Revision: 1.1 $
+ */
+public class PackageProtectedBoxedBean implements BeanInterface
+{
+ Object object;
+
+ Boolean booleanField;
+
+ Byte byteField;
+
+ Character charField;
+
+ Double doubleField;
+
+ Float floatField;
+
+ Integer intField;
+
+ Long longField;
+
+ Short shortField;
+
+ public static PackageProtectedBoxedBean getInstance()
+ {
+ return new PackageProtectedBoxedBean();
+ }
+
+ PackageProtectedBoxedBean()
+ {
+ }
+
+ PackageProtectedBoxedBean(Boolean booleanField)
+ {
+ this.booleanField = booleanField;
+ }
+
+ PackageProtectedBoxedBean(Byte byteField)
+ {
+ this.byteField = byteField;
+ }
+
+ PackageProtectedBoxedBean(Character charField)
+ {
+ this.charField = charField;
+ }
+
+ PackageProtectedBoxedBean(Double doubleField)
+ {
+ this.doubleField = doubleField;
+ }
+
+ PackageProtectedBoxedBean(Object object)
+ {
+ this.object = object;
+ }
+
+ PackageProtectedBoxedBean(Float floatField)
+ {
+ this.floatField = floatField;
+ }
+
+ PackageProtectedBoxedBean(Integer intField)
+ {
+ this.intField = intField;
+ }
+
+ PackageProtectedBoxedBean(Long longField)
+ {
+ this.longField = longField;
+ }
+
+ PackageProtectedBoxedBean(Short shortField)
+ {
+ this.shortField = shortField;
+ }
+
+ PackageProtectedBoxedBean(String object, Boolean booleanField, Byte byteField, Character charField)
+ {
+ this.object = object;
+ this.booleanField = booleanField;
+ this.byteField = byteField;
+ this.charField = charField;
+ }
+
+ void noReturnNoParams()
+ {
+
+ }
+
+ String bigMethod(String s, Boolean booleanField, Byte byteField, Character charField)
+ {
+ return s;
+ }
+
+ Object objectMethod(Object object)
+ {
+ this.object = object;
+ return this.object;
+ }
+
+ Boolean booleanMethod(Boolean param)
+ {
+ this.booleanField = param;
+ return param;
+ }
+
+ Byte byteMethod(Byte param)
+ {
+ this.byteField = param;
+ return param;
+ }
+
+ Character charMethod(Character param)
+ {
+ this.charField = param;
+ return param;
+ }
+
+ Double doubleMethod(Double param)
+ {
+ this.doubleField = param;
+ return param;
+ }
+
+ Float floatMethod(Float param)
+ {
+ this.floatField = param;
+ return param;
+ }
+
+ Integer intMethod(Integer param)
+ {
+ this.intField = param;
+ return param;
+ }
+
+ Long longMethod(Long param)
+ {
+ this.longField = param;
+ return param;
+ }
+
+ Short shortMethod(Short param)
+ {
+ this.shortField = param;
+ return param;
+ }
+
+ //Getters only needed for the constructor tests
+ public Object getObject()
+ {
+ return object;
+ }
+
+ public Boolean getBooleanField()
+ {
+ return booleanField;
+ }
+
+ public Byte getByteField()
+ {
+ return byteField;
+ }
+
+ public Character getCharField()
+ {
+ return charField;
+ }
+
+ public Double getDoubleField()
+ {
+ return doubleField;
+ }
+
+ public Float getFloatField()
+ {
+ return floatField;
+ }
+
+ public Integer getIntField()
+ {
+ return intField;
+ }
+
+ public Long getLongField()
+ {
+ return longField;
+ }
+
+ public Short getShortField()
+ {
+ return shortField;
+ }
+}
Added: projects/jboss-reflect/trunk/src/test/java/org/jboss/test/plugins/javassist/bytecode/support/PackageProtectedPrimitiveBean.java
===================================================================
--- projects/jboss-reflect/trunk/src/test/java/org/jboss/test/plugins/javassist/bytecode/support/PackageProtectedPrimitiveBean.java (rev 0)
+++ projects/jboss-reflect/trunk/src/test/java/org/jboss/test/plugins/javassist/bytecode/support/PackageProtectedPrimitiveBean.java 2010-03-24 16:48:26 UTC (rev 102910)
@@ -0,0 +1,220 @@
+/*
+* JBoss, Home of Professional Open Source.
+* Copyright 2006, Red Hat Middleware LLC, and individual contributors
+* as indicated by the @author tags. See the copyright.txt file in the
+* distribution for a full listing of individual contributors.
+*
+* This is free software; you can redistribute it and/or modify it
+* under the terms of the GNU Lesser General Public License as
+* published by the Free Software Foundation; either version 2.1 of
+* the License, or (at your option) any later version.
+*
+* This software is distributed in the hope that it will be useful,
+* but WITHOUT ANY WARRANTY; without even the implied warranty of
+* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+* Lesser General Public License for more details.
+*
+* You should have received a copy of the GNU Lesser General Public
+* License along with this software; if not, write to the Free
+* Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+* 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+*/
+package org.jboss.test.plugins.javassist.bytecode.support;
+
+/**
+ *
+ * @author <a href="kabir.khan at jboss.com">Kabir Khan</a>
+ * @version $Revision: 1.1 $
+ */
+public class PackageProtectedPrimitiveBean implements BeanInterface
+{
+ Object object;
+
+ boolean booleanField;
+
+ byte byteField;
+
+ char charField;
+
+ double doubleField;
+
+ float floatField;
+
+ int intField;
+
+ long longField;
+
+ short shortField;
+
+ public static PackageProtectedPrimitiveBean getInstance()
+ {
+ return new PackageProtectedPrimitiveBean();
+ }
+
+ PackageProtectedPrimitiveBean()
+ {
+ }
+
+ PackageProtectedPrimitiveBean(boolean booleanField)
+ {
+ this.booleanField = booleanField;
+ }
+
+ PackageProtectedPrimitiveBean(byte byteField)
+ {
+ this.byteField = byteField;
+ }
+
+ PackageProtectedPrimitiveBean(char charField)
+ {
+ this.charField = charField;
+ }
+
+ PackageProtectedPrimitiveBean(double doubleField)
+ {
+ this.doubleField = doubleField;
+ }
+
+ PackageProtectedPrimitiveBean(Object object)
+ {
+ this.object = object;
+ }
+
+ PackageProtectedPrimitiveBean(float floatField)
+ {
+ this.floatField = floatField;
+ }
+
+ PackageProtectedPrimitiveBean(int intField)
+ {
+ this.intField = intField;
+ }
+
+ PackageProtectedPrimitiveBean(long longField)
+ {
+ this.longField = longField;
+ }
+
+ PackageProtectedPrimitiveBean(short shortField)
+ {
+ this.shortField = shortField;
+ }
+
+ PackageProtectedPrimitiveBean(String object, boolean booleanField, byte byteField, char charField)
+ {
+ this.object = object;
+ this.booleanField = booleanField;
+ this.byteField = byteField;
+ this.charField = charField;
+ }
+
+ void noReturnNoParams()
+ {
+
+ }
+
+ String bigMethod(String s, boolean booleanField, byte byteField, char charField)
+ {
+ return s;
+ }
+
+ Object objectMethod(Object object)
+ {
+ this.object = object;
+ return this.object;
+ }
+
+ boolean booleanMethod(boolean param)
+ {
+ this.booleanField = param;
+ return param;
+ }
+
+ byte byteMethod(byte param)
+ {
+ this.byteField = param;
+ return param;
+ }
+
+ char charMethod(char param)
+ {
+ this.charField = param;
+ return param;
+ }
+
+ double doubleMethod(double param)
+ {
+ this.doubleField = param;
+ return param;
+ }
+
+ float floatMethod(float param)
+ {
+ this.floatField = param;
+ return param;
+ }
+
+ int intMethod(int param)
+ {
+ this.intField = param;
+ return param;
+ }
+
+ long longMethod(long param)
+ {
+ this.longField = param;
+ return param;
+ }
+
+ short shortMethod(short param)
+ {
+ this.shortField = param;
+ return param;
+ }
+
+ //Getters only needed for the constructor tests
+ public Object getObject()
+ {
+ return object;
+ }
+
+ public Boolean getBooleanField()
+ {
+ return booleanField;
+ }
+
+ public Byte getByteField()
+ {
+ return byteField;
+ }
+
+ public Character getCharField()
+ {
+ return charField;
+ }
+
+ public Double getDoubleField()
+ {
+ return doubleField;
+ }
+
+ public Float getFloatField()
+ {
+ return floatField;
+ }
+
+ public Integer getIntField()
+ {
+ return intField;
+ }
+
+ public Long getLongField()
+ {
+ return longField;
+ }
+
+ public Short getShortField()
+ {
+ return shortField;
+ }
+}
Added: projects/jboss-reflect/trunk/src/test/java/org/jboss/test/plugins/javassist/bytecode/support/PackageProtectedStaticBoxedBean.java
===================================================================
--- projects/jboss-reflect/trunk/src/test/java/org/jboss/test/plugins/javassist/bytecode/support/PackageProtectedStaticBoxedBean.java (rev 0)
+++ projects/jboss-reflect/trunk/src/test/java/org/jboss/test/plugins/javassist/bytecode/support/PackageProtectedStaticBoxedBean.java 2010-03-24 16:48:26 UTC (rev 102910)
@@ -0,0 +1,113 @@
+/*
+* JBoss, Home of Professional Open Source.
+* Copyright 2006, Red Hat Middleware LLC, and individual contributors
+* as indicated by the @author tags. See the copyright.txt file in the
+* distribution for a full listing of individual contributors.
+*
+* This is free software; you can redistribute it and/or modify it
+* under the terms of the GNU Lesser General Public License as
+* published by the Free Software Foundation; either version 2.1 of
+* the License, or (at your option) any later version.
+*
+* This software is distributed in the hope that it will be useful,
+* but WITHOUT ANY WARRANTY; without even the implied warranty of
+* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+* Lesser General Public License for more details.
+*
+* You should have received a copy of the GNU Lesser General Public
+* License along with this software; if not, write to the Free
+* Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+* 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+*/
+package org.jboss.test.plugins.javassist.bytecode.support;
+
+/**
+ *
+ * @author <a href="kabir.khan at jboss.com">Kabir Khan</a>
+ * @version $Revision: 1.1 $
+ */
+public class PackageProtectedStaticBoxedBean
+{
+ static Object object;
+
+ static Boolean booleanField;
+
+ static Byte byteField;
+
+ static Character charField;
+
+ static Double doubleField;
+
+ static Float floatField;
+
+ static Integer intField;
+
+ static Long longField;
+
+ static Short shortField;
+
+ static void noReturnNoParams()
+ {
+
+ }
+
+ static String bigMethod(String s, Boolean booleanField, Byte byteField, Character charField)
+ {
+ return s;
+ }
+
+ static Object objectMethod(Object object)
+ {
+ PackageProtectedStaticBoxedBean.object = object;
+ return PackageProtectedStaticBoxedBean.object;
+ }
+
+ static Boolean booleanMethod(Boolean param)
+ {
+ PackageProtectedStaticBoxedBean.booleanField = param;
+ return param;
+ }
+
+ static Byte byteMethod(Byte param)
+ {
+ PackageProtectedStaticBoxedBean.byteField = param;
+ return param;
+ }
+
+ static Character charMethod(Character param)
+ {
+ PackageProtectedStaticBoxedBean.charField = param;
+ return param;
+ }
+
+ static Double doubleMethod(Double param)
+ {
+ PackageProtectedStaticBoxedBean.doubleField = param;
+ return param;
+ }
+
+ static Float floatMethod(Float param)
+ {
+ PackageProtectedStaticBoxedBean.floatField = param;
+ return param;
+ }
+
+ static Integer intMethod(Integer param)
+ {
+ PackageProtectedStaticBoxedBean.intField = param;
+ return param;
+ }
+
+ static Long longMethod(Long param)
+ {
+ PackageProtectedStaticBoxedBean.longField = param;
+ return param;
+ }
+
+ static Short shortMethod(Short param)
+ {
+ PackageProtectedStaticBoxedBean.shortField = param;
+ return param;
+ }
+
+}
Added: projects/jboss-reflect/trunk/src/test/java/org/jboss/test/plugins/javassist/bytecode/support/PackageProtectedStaticPrimitiveBean.java
===================================================================
--- projects/jboss-reflect/trunk/src/test/java/org/jboss/test/plugins/javassist/bytecode/support/PackageProtectedStaticPrimitiveBean.java (rev 0)
+++ projects/jboss-reflect/trunk/src/test/java/org/jboss/test/plugins/javassist/bytecode/support/PackageProtectedStaticPrimitiveBean.java 2010-03-24 16:48:26 UTC (rev 102910)
@@ -0,0 +1,113 @@
+/*
+* JBoss, Home of Professional Open Source.
+* Copyright 2006, Red Hat Middleware LLC, and individual contributors
+* as indicated by the @author tags. See the copyright.txt file in the
+* distribution for a full listing of individual contributors.
+*
+* This is free software; you can redistribute it and/or modify it
+* under the terms of the GNU Lesser General Public License as
+* published by the Free Software Foundation; either version 2.1 of
+* the License, or (at your option) any later version.
+*
+* This software is distributed in the hope that it will be useful,
+* but WITHOUT ANY WARRANTY; without even the implied warranty of
+* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+* Lesser General Public License for more details.
+*
+* You should have received a copy of the GNU Lesser General Public
+* License along with this software; if not, write to the Free
+* Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+* 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+*/
+package org.jboss.test.plugins.javassist.bytecode.support;
+
+/**
+ *
+ * @author <a href="kabir.khan at jboss.com">Kabir Khan</a>
+ * @version $Revision: 1.1 $
+ */
+public class PackageProtectedStaticPrimitiveBean
+{
+ static Object object;
+
+ static boolean booleanField;
+
+ static byte byteField;
+
+ static char charField;
+
+ static double doubleField;
+
+ static float floatField;
+
+ static int intField;
+
+ static long longField;
+
+ static short shortField;
+
+ static void noReturnNoParams()
+ {
+
+ }
+
+ static String bigMethod(String s, boolean booleanField, byte byteField, char charField)
+ {
+ return s;
+ }
+
+ static Object objectMethod(Object object)
+ {
+ PackageProtectedStaticPrimitiveBean.object = object;
+ return PackageProtectedStaticPrimitiveBean.object;
+ }
+
+ static boolean booleanMethod(boolean param)
+ {
+ PackageProtectedStaticPrimitiveBean.booleanField = param;
+ return param;
+ }
+
+ static byte byteMethod(byte param)
+ {
+ PackageProtectedStaticPrimitiveBean.byteField = param;
+ return param;
+ }
+
+ static char charMethod(char param)
+ {
+ PackageProtectedStaticPrimitiveBean.charField = param;
+ return param;
+ }
+
+ static double doubleMethod(double param)
+ {
+ PackageProtectedStaticPrimitiveBean.doubleField = param;
+ return param;
+ }
+
+ static float floatMethod(float param)
+ {
+ PackageProtectedStaticPrimitiveBean.floatField = param;
+ return param;
+ }
+
+ static int intMethod(int param)
+ {
+ PackageProtectedStaticPrimitiveBean.intField = param;
+ return param;
+ }
+
+ static long longMethod(long param)
+ {
+ PackageProtectedStaticPrimitiveBean.longField = param;
+ return param;
+ }
+
+ static short shortMethod(short param)
+ {
+ PackageProtectedStaticPrimitiveBean.shortField = param;
+ return param;
+ }
+
+}
Added: projects/jboss-reflect/trunk/src/test/java/org/jboss/test/plugins/javassist/bytecode/support/PrivateBoxedBean.java
===================================================================
--- projects/jboss-reflect/trunk/src/test/java/org/jboss/test/plugins/javassist/bytecode/support/PrivateBoxedBean.java (rev 0)
+++ projects/jboss-reflect/trunk/src/test/java/org/jboss/test/plugins/javassist/bytecode/support/PrivateBoxedBean.java 2010-03-24 16:48:26 UTC (rev 102910)
@@ -0,0 +1,221 @@
+/*
+* JBoss, Home of Professional Open Source.
+* Copyright 2006, Red Hat Middleware LLC, and individual contributors
+* as indicated by the @author tags. See the copyright.txt file in the
+* distribution for a full listing of individual contributors.
+*
+* This is free software; you can redistribute it and/or modify it
+* under the terms of the GNU Lesser General Public License as
+* published by the Free Software Foundation; either version 2.1 of
+* the License, or (at your option) any later version.
+*
+* This software is distributed in the hope that it will be useful,
+* but WITHOUT ANY WARRANTY; without even the implied warranty of
+* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+* Lesser General Public License for more details.
+*
+* You should have received a copy of the GNU Lesser General Public
+* License along with this software; if not, write to the Free
+* Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+* 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+*/
+package org.jboss.test.plugins.javassist.bytecode.support;
+
+/**
+ *
+ * @author <a href="kabir.khan at jboss.com">Kabir Khan</a>
+ * @version $Revision: 1.1 $
+ */
+ at SuppressWarnings("unused")
+public class PrivateBoxedBean implements BeanInterface
+{
+ private Object object;
+
+ private Boolean booleanField;
+
+ private Byte byteField;
+
+ private Character charField;
+
+ private Double doubleField;
+
+ private Float floatField;
+
+ private Integer intField;
+
+ private Long longField;
+
+ private Short shortField;
+
+ public static PrivateBoxedBean getInstance()
+ {
+ return new PrivateBoxedBean();
+ }
+
+ private PrivateBoxedBean()
+ {
+ }
+
+ private PrivateBoxedBean(Boolean booleanField)
+ {
+ this.booleanField = booleanField;
+ }
+
+ private PrivateBoxedBean(Byte byteField)
+ {
+ this.byteField = byteField;
+ }
+
+ private PrivateBoxedBean(Character charField)
+ {
+ this.charField = charField;
+ }
+
+ private PrivateBoxedBean(Double doubleField)
+ {
+ this.doubleField = doubleField;
+ }
+
+ private PrivateBoxedBean(Object object)
+ {
+ this.object = object;
+ }
+
+ private PrivateBoxedBean(Float floatField)
+ {
+ this.floatField = floatField;
+ }
+
+ private PrivateBoxedBean(Integer intField)
+ {
+ this.intField = intField;
+ }
+
+ private PrivateBoxedBean(Long longField)
+ {
+ this.longField = longField;
+ }
+
+ private PrivateBoxedBean(Short shortField)
+ {
+ this.shortField = shortField;
+ }
+
+ private PrivateBoxedBean(String object, Boolean booleanField, Byte byteField, Character charField)
+ {
+ this.object = object;
+ this.booleanField = booleanField;
+ this.byteField = byteField;
+ this.charField = charField;
+ }
+
+ private void noReturnNoParams()
+ {
+
+ }
+
+ private String bigMethod(String s, Boolean booleanField, Byte byteField, Character charField)
+ {
+ return s;
+ }
+
+ private Object objectMethod(Object object)
+ {
+ this.object = object;
+ return this.object;
+ }
+
+ private Boolean booleanMethod(Boolean param)
+ {
+ this.booleanField = param;
+ return param;
+ }
+
+ private Byte byteMethod(Byte param)
+ {
+ this.byteField = param;
+ return param;
+ }
+
+ private Character charMethod(Character param)
+ {
+ this.charField = param;
+ return param;
+ }
+
+ private Double doubleMethod(Double param)
+ {
+ this.doubleField = param;
+ return param;
+ }
+
+ private Float floatMethod(Float param)
+ {
+ this.floatField = param;
+ return param;
+ }
+
+ private Integer intMethod(Integer param)
+ {
+ this.intField = param;
+ return param;
+ }
+
+ private Long longMethod(Long param)
+ {
+ this.longField = param;
+ return param;
+ }
+
+ private Short shortMethod(Short param)
+ {
+ this.shortField = param;
+ return param;
+ }
+
+ //Getters only needed for the constructor tests
+ public Object getObject()
+ {
+ return object;
+ }
+
+ public Boolean getBooleanField()
+ {
+ return booleanField;
+ }
+
+ public Byte getByteField()
+ {
+ return byteField;
+ }
+
+ public Character getCharField()
+ {
+ return charField;
+ }
+
+ public Double getDoubleField()
+ {
+ return doubleField;
+ }
+
+ public Float getFloatField()
+ {
+ return floatField;
+ }
+
+ public Integer getIntField()
+ {
+ return intField;
+ }
+
+ public Long getLongField()
+ {
+ return longField;
+ }
+
+ public Short getShortField()
+ {
+ return shortField;
+ }
+}
Added: projects/jboss-reflect/trunk/src/test/java/org/jboss/test/plugins/javassist/bytecode/support/PrivatePrimitiveBean.java
===================================================================
--- projects/jboss-reflect/trunk/src/test/java/org/jboss/test/plugins/javassist/bytecode/support/PrivatePrimitiveBean.java (rev 0)
+++ projects/jboss-reflect/trunk/src/test/java/org/jboss/test/plugins/javassist/bytecode/support/PrivatePrimitiveBean.java 2010-03-24 16:48:26 UTC (rev 102910)
@@ -0,0 +1,221 @@
+/*
+* JBoss, Home of Professional Open Source.
+* Copyright 2006, Red Hat Middleware LLC, and individual contributors
+* as indicated by the @author tags. See the copyright.txt file in the
+* distribution for a full listing of individual contributors.
+*
+* This is free software; you can redistribute it and/or modify it
+* under the terms of the GNU Lesser General Public License as
+* published by the Free Software Foundation; either version 2.1 of
+* the License, or (at your option) any later version.
+*
+* This software is distributed in the hope that it will be useful,
+* but WITHOUT ANY WARRANTY; without even the implied warranty of
+* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+* Lesser General Public License for more details.
+*
+* You should have received a copy of the GNU Lesser General Public
+* License along with this software; if not, write to the Free
+* Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+* 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+*/
+package org.jboss.test.plugins.javassist.bytecode.support;
+
+/**
+ *
+ * @author <a href="kabir.khan at jboss.com">Kabir Khan</a>
+ * @version $Revision: 1.1 $
+ */
+ at SuppressWarnings("unused")
+public class PrivatePrimitiveBean implements BeanInterface
+{
+ private Object object;
+
+ private boolean booleanField;
+
+ private byte byteField;
+
+ private char charField;
+
+ private double doubleField;
+
+ private float floatField;
+
+ private int intField;
+
+ private long longField;
+
+ private short shortField;
+
+ public static PrivatePrimitiveBean getInstance()
+ {
+ return new PrivatePrimitiveBean();
+ }
+
+ private PrivatePrimitiveBean()
+ {
+ }
+
+ private PrivatePrimitiveBean(boolean booleanField)
+ {
+ this.booleanField = booleanField;
+ }
+
+ private PrivatePrimitiveBean(byte byteField)
+ {
+ this.byteField = byteField;
+ }
+
+ private PrivatePrimitiveBean(char charField)
+ {
+ this.charField = charField;
+ }
+
+ private PrivatePrimitiveBean(double doubleField)
+ {
+ this.doubleField = doubleField;
+ }
+
+ private PrivatePrimitiveBean(Object object)
+ {
+ this.object = object;
+ }
+
+ private PrivatePrimitiveBean(float floatField)
+ {
+ this.floatField = floatField;
+ }
+
+ private PrivatePrimitiveBean(int intField)
+ {
+ this.intField = intField;
+ }
+
+ private PrivatePrimitiveBean(long longField)
+ {
+ this.longField = longField;
+ }
+
+ private PrivatePrimitiveBean(short shortField)
+ {
+ this.shortField = shortField;
+ }
+
+ private PrivatePrimitiveBean(String object, boolean booleanField, byte byteField, char charField)
+ {
+ this.object = object;
+ this.booleanField = booleanField;
+ this.byteField = byteField;
+ this.charField = charField;
+ }
+
+ private void noReturnNoParams()
+ {
+
+ }
+
+ private String bigMethod(String s, boolean booleanField, byte byteField, char charField)
+ {
+ return s;
+ }
+
+ private Object objectMethod(Object object)
+ {
+ this.object = object;
+ return this.object;
+ }
+
+ private boolean booleanMethod(boolean param)
+ {
+ this.booleanField = param;
+ return param;
+ }
+
+ private byte byteMethod(byte param)
+ {
+ this.byteField = param;
+ return param;
+ }
+
+ private char charMethod(char param)
+ {
+ this.charField = param;
+ return param;
+ }
+
+ private double doubleMethod(double param)
+ {
+ this.doubleField = param;
+ return param;
+ }
+
+ private float floatMethod(float param)
+ {
+ this.floatField = param;
+ return param;
+ }
+
+ private int intMethod(int param)
+ {
+ this.intField = param;
+ return param;
+ }
+
+ private long longMethod(long param)
+ {
+ this.longField = param;
+ return param;
+ }
+
+ private short shortMethod(short param)
+ {
+ this.shortField = param;
+ return param;
+ }
+
+ //Getters only needed for the constructor tests
+ public Object getObject()
+ {
+ return object;
+ }
+
+ public Boolean getBooleanField()
+ {
+ return booleanField;
+ }
+
+ public Byte getByteField()
+ {
+ return byteField;
+ }
+
+ public Character getCharField()
+ {
+ return charField;
+ }
+
+ public Double getDoubleField()
+ {
+ return doubleField;
+ }
+
+ public Float getFloatField()
+ {
+ return floatField;
+ }
+
+ public Integer getIntField()
+ {
+ return intField;
+ }
+
+ public Long getLongField()
+ {
+ return longField;
+ }
+
+ public Short getShortField()
+ {
+ return shortField;
+ }
+}
Added: projects/jboss-reflect/trunk/src/test/java/org/jboss/test/plugins/javassist/bytecode/support/PrivateStaticBoxedBean.java
===================================================================
--- projects/jboss-reflect/trunk/src/test/java/org/jboss/test/plugins/javassist/bytecode/support/PrivateStaticBoxedBean.java (rev 0)
+++ projects/jboss-reflect/trunk/src/test/java/org/jboss/test/plugins/javassist/bytecode/support/PrivateStaticBoxedBean.java 2010-03-24 16:48:26 UTC (rev 102910)
@@ -0,0 +1,114 @@
+/*
+* JBoss, Home of Professional Open Source.
+* Copyright 2006, Red Hat Middleware LLC, and individual contributors
+* as indicated by the @author tags. See the copyright.txt file in the
+* distribution for a full listing of individual contributors.
+*
+* This is free software; you can redistribute it and/or modify it
+* under the terms of the GNU Lesser General Public License as
+* published by the Free Software Foundation; either version 2.1 of
+* the License, or (at your option) any later version.
+*
+* This software is distributed in the hope that it will be useful,
+* but WITHOUT ANY WARRANTY; without even the implied warranty of
+* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+* Lesser General Public License for more details.
+*
+* You should have received a copy of the GNU Lesser General Public
+* License along with this software; if not, write to the Free
+* Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+* 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+*/
+package org.jboss.test.plugins.javassist.bytecode.support;
+
+/**
+ *
+ * @author <a href="kabir.khan at jboss.com">Kabir Khan</a>
+ * @version $Revision: 1.1 $
+ */
+ at SuppressWarnings("unused")
+public class PrivateStaticBoxedBean
+{
+ private static Object object;
+
+ private static Boolean booleanField;
+
+ private static Byte byteField;
+
+ private static Character charField;
+
+ private static Double doubleField;
+
+ private static Float floatField;
+
+ private static Integer intField;
+
+ private static Long longField;
+
+ private static Short shortField;
+
+ private static void noReturnNoParams()
+ {
+
+ }
+
+ private static String bigMethod(String s, Boolean booleanField, Byte byteField, Character charField)
+ {
+ return s;
+ }
+
+ private static Object objectMethod(Object object)
+ {
+ PrivateStaticBoxedBean.object = object;
+ return PrivateStaticBoxedBean.object;
+ }
+
+ private static Boolean booleanMethod(Boolean param)
+ {
+ PrivateStaticBoxedBean.booleanField = param;
+ return param;
+ }
+
+ private static Byte byteMethod(Byte param)
+ {
+ PrivateStaticBoxedBean.byteField = param;
+ return param;
+ }
+
+ private static Character charMethod(Character param)
+ {
+ PrivateStaticBoxedBean.charField = param;
+ return param;
+ }
+
+ private static Double doubleMethod(Double param)
+ {
+ PrivateStaticBoxedBean.doubleField = param;
+ return param;
+ }
+
+ private static Float floatMethod(Float param)
+ {
+ PrivateStaticBoxedBean.floatField = param;
+ return param;
+ }
+
+ private static Integer intMethod(Integer param)
+ {
+ PrivateStaticBoxedBean.intField = param;
+ return param;
+ }
+
+ private static Long longMethod(Long param)
+ {
+ PrivateStaticBoxedBean.longField = param;
+ return param;
+ }
+
+ private static Short shortMethod(Short param)
+ {
+ PrivateStaticBoxedBean.shortField = param;
+ return param;
+ }
+
+}
Added: projects/jboss-reflect/trunk/src/test/java/org/jboss/test/plugins/javassist/bytecode/support/PrivateStaticPrimitiveBean.java
===================================================================
--- projects/jboss-reflect/trunk/src/test/java/org/jboss/test/plugins/javassist/bytecode/support/PrivateStaticPrimitiveBean.java (rev 0)
+++ projects/jboss-reflect/trunk/src/test/java/org/jboss/test/plugins/javassist/bytecode/support/PrivateStaticPrimitiveBean.java 2010-03-24 16:48:26 UTC (rev 102910)
@@ -0,0 +1,114 @@
+/*
+* JBoss, Home of Professional Open Source.
+* Copyright 2006, Red Hat Middleware LLC, and individual contributors
+* as indicated by the @author tags. See the copyright.txt file in the
+* distribution for a full listing of individual contributors.
+*
+* This is free software; you can redistribute it and/or modify it
+* under the terms of the GNU Lesser General Public License as
+* published by the Free Software Foundation; either version 2.1 of
+* the License, or (at your option) any later version.
+*
+* This software is distributed in the hope that it will be useful,
+* but WITHOUT ANY WARRANTY; without even the implied warranty of
+* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+* Lesser General Public License for more details.
+*
+* You should have received a copy of the GNU Lesser General Public
+* License along with this software; if not, write to the Free
+* Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+* 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+*/
+package org.jboss.test.plugins.javassist.bytecode.support;
+
+/**
+ *
+ * @author <a href="kabir.khan at jboss.com">Kabir Khan</a>
+ * @version $Revision: 1.1 $
+ */
+ at SuppressWarnings("unused")
+public class PrivateStaticPrimitiveBean
+{
+ private static Object object;
+
+ private static boolean booleanField;
+
+ private static byte byteField;
+
+ private static char charField;
+
+ private static double doubleField;
+
+ private static float floatField;
+
+ private static int intField;
+
+ private static long longField;
+
+ private static short shortField;
+
+ private static void noReturnNoParams()
+ {
+
+ }
+
+ private static String bigMethod(String s, boolean booleanField, byte byteField, char charField)
+ {
+ return s;
+ }
+
+ private static Object objectMethod(Object object)
+ {
+ PrivateStaticPrimitiveBean.object = object;
+ return PrivateStaticPrimitiveBean.object;
+ }
+
+ private static boolean booleanMethod(boolean param)
+ {
+ PrivateStaticPrimitiveBean.booleanField = param;
+ return param;
+ }
+
+ private static byte byteMethod(byte param)
+ {
+ PrivateStaticPrimitiveBean.byteField = param;
+ return param;
+ }
+
+ private static char charMethod(char param)
+ {
+ PrivateStaticPrimitiveBean.charField = param;
+ return param;
+ }
+
+ private static double doubleMethod(double param)
+ {
+ PrivateStaticPrimitiveBean.doubleField = param;
+ return param;
+ }
+
+ private static float floatMethod(float param)
+ {
+ PrivateStaticPrimitiveBean.floatField = param;
+ return param;
+ }
+
+ private static int intMethod(int param)
+ {
+ PrivateStaticPrimitiveBean.intField = param;
+ return param;
+ }
+
+ private static long longMethod(long param)
+ {
+ PrivateStaticPrimitiveBean.longField = param;
+ return param;
+ }
+
+ private static short shortMethod(short param)
+ {
+ PrivateStaticPrimitiveBean.shortField = param;
+ return param;
+ }
+
+}
Added: projects/jboss-reflect/trunk/src/test/java/org/jboss/test/plugins/javassist/bytecode/support/ProtectedBoxedBean.java
===================================================================
--- projects/jboss-reflect/trunk/src/test/java/org/jboss/test/plugins/javassist/bytecode/support/ProtectedBoxedBean.java (rev 0)
+++ projects/jboss-reflect/trunk/src/test/java/org/jboss/test/plugins/javassist/bytecode/support/ProtectedBoxedBean.java 2010-03-24 16:48:26 UTC (rev 102910)
@@ -0,0 +1,220 @@
+/*
+* JBoss, Home of Professional Open Source.
+* Copyright 2006, Red Hat Middleware LLC, and individual contributors
+* as indicated by the @author tags. See the copyright.txt file in the
+* distribution for a full listing of individual contributors.
+*
+* This is free software; you can redistribute it and/or modify it
+* under the terms of the GNU Lesser General Public License as
+* published by the Free Software Foundation; either version 2.1 of
+* the License, or (at your option) any later version.
+*
+* This software is distributed in the hope that it will be useful,
+* but WITHOUT ANY WARRANTY; without even the implied warranty of
+* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+* Lesser General Public License for more details.
+*
+* You should have received a copy of the GNU Lesser General Public
+* License along with this software; if not, write to the Free
+* Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+* 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+*/
+package org.jboss.test.plugins.javassist.bytecode.support;
+
+/**
+ *
+ * @author <a href="kabir.khan at jboss.com">Kabir Khan</a>
+ * @version $Revision: 1.1 $
+ */
+public class ProtectedBoxedBean implements BeanInterface
+{
+ protected Object object;
+
+ protected Boolean booleanField;
+
+ protected Byte byteField;
+
+ protected Character charField;
+
+ protected Double doubleField;
+
+ protected Float floatField;
+
+ protected Integer intField;
+
+ protected Long longField;
+
+ protected Short shortField;
+
+ public static ProtectedBoxedBean getInstance()
+ {
+ return new ProtectedBoxedBean();
+ }
+
+ protected ProtectedBoxedBean()
+ {
+ }
+
+ protected ProtectedBoxedBean(Boolean booleanField)
+ {
+ this.booleanField = booleanField;
+ }
+
+ protected ProtectedBoxedBean(Byte byteField)
+ {
+ this.byteField = byteField;
+ }
+
+ protected ProtectedBoxedBean(Character charField)
+ {
+ this.charField = charField;
+ }
+
+ protected ProtectedBoxedBean(Double doubleField)
+ {
+ this.doubleField = doubleField;
+ }
+
+ protected ProtectedBoxedBean(Object object)
+ {
+ this.object = object;
+ }
+
+ protected ProtectedBoxedBean(Float floatField)
+ {
+ this.floatField = floatField;
+ }
+
+ protected ProtectedBoxedBean(Integer intField)
+ {
+ this.intField = intField;
+ }
+
+ protected ProtectedBoxedBean(Long longField)
+ {
+ this.longField = longField;
+ }
+
+ protected ProtectedBoxedBean(Short shortField)
+ {
+ this.shortField = shortField;
+ }
+
+ protected ProtectedBoxedBean(String object, Boolean booleanField, Byte byteField, Character charField)
+ {
+ this.object = object;
+ this.booleanField = booleanField;
+ this.byteField = byteField;
+ this.charField = charField;
+ }
+
+ protected void noReturnNoParams()
+ {
+
+ }
+
+ protected String bigMethod(String s, Boolean booleanField, Byte byteField, Character charField)
+ {
+ return s;
+ }
+
+ protected Object objectMethod(Object object)
+ {
+ this.object = object;
+ return this.object;
+ }
+
+ protected Boolean booleanMethod(Boolean param)
+ {
+ this.booleanField = param;
+ return param;
+ }
+
+ protected Byte byteMethod(Byte param)
+ {
+ this.byteField = param;
+ return param;
+ }
+
+ protected Character charMethod(Character param)
+ {
+ this.charField = param;
+ return param;
+ }
+
+ protected Double doubleMethod(Double param)
+ {
+ this.doubleField = param;
+ return param;
+ }
+
+ protected Float floatMethod(Float param)
+ {
+ this.floatField = param;
+ return param;
+ }
+
+ protected Integer intMethod(Integer param)
+ {
+ this.intField = param;
+ return param;
+ }
+
+ protected Long longMethod(Long param)
+ {
+ this.longField = param;
+ return param;
+ }
+
+ protected Short shortMethod(Short param)
+ {
+ this.shortField = param;
+ return param;
+ }
+
+ //Getters only needed for the constructor tests
+ public Object getObject()
+ {
+ return object;
+ }
+
+ public Boolean getBooleanField()
+ {
+ return booleanField;
+ }
+
+ public Byte getByteField()
+ {
+ return byteField;
+ }
+
+ public Character getCharField()
+ {
+ return charField;
+ }
+
+ public Double getDoubleField()
+ {
+ return doubleField;
+ }
+
+ public Float getFloatField()
+ {
+ return floatField;
+ }
+
+ public Integer getIntField()
+ {
+ return intField;
+ }
+
+ public Long getLongField()
+ {
+ return longField;
+ }
+
+ public Short getShortField()
+ {
+ return shortField;
+ }
+}
Added: projects/jboss-reflect/trunk/src/test/java/org/jboss/test/plugins/javassist/bytecode/support/ProtectedPrimitiveBean.java
===================================================================
--- projects/jboss-reflect/trunk/src/test/java/org/jboss/test/plugins/javassist/bytecode/support/ProtectedPrimitiveBean.java (rev 0)
+++ projects/jboss-reflect/trunk/src/test/java/org/jboss/test/plugins/javassist/bytecode/support/ProtectedPrimitiveBean.java 2010-03-24 16:48:26 UTC (rev 102910)
@@ -0,0 +1,220 @@
+/*
+* JBoss, Home of Professional Open Source.
+* Copyright 2006, Red Hat Middleware LLC, and individual contributors
+* as indicated by the @author tags. See the copyright.txt file in the
+* distribution for a full listing of individual contributors.
+*
+* This is free software; you can redistribute it and/or modify it
+* under the terms of the GNU Lesser General Public License as
+* published by the Free Software Foundation; either version 2.1 of
+* the License, or (at your option) any later version.
+*
+* This software is distributed in the hope that it will be useful,
+* but WITHOUT ANY WARRANTY; without even the implied warranty of
+* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+* Lesser General Public License for more details.
+*
+* You should have received a copy of the GNU Lesser General Public
+* License along with this software; if not, write to the Free
+* Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+* 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+*/
+package org.jboss.test.plugins.javassist.bytecode.support;
+
+/**
+ *
+ * @author <a href="kabir.khan at jboss.com">Kabir Khan</a>
+ * @version $Revision: 1.1 $
+ */
+public class ProtectedPrimitiveBean implements BeanInterface
+{
+ protected Object object;
+
+ protected boolean booleanField;
+
+ protected byte byteField;
+
+ protected char charField;
+
+ protected double doubleField;
+
+ protected float floatField;
+
+ protected int intField;
+
+ protected long longField;
+
+ protected short shortField;
+
+ public static ProtectedPrimitiveBean getInstance()
+ {
+ return new ProtectedPrimitiveBean();
+ }
+
+ protected ProtectedPrimitiveBean()
+ {
+ }
+
+ protected ProtectedPrimitiveBean(boolean booleanField)
+ {
+ this.booleanField = booleanField;
+ }
+
+ protected ProtectedPrimitiveBean(byte byteField)
+ {
+ this.byteField = byteField;
+ }
+
+ protected ProtectedPrimitiveBean(char charField)
+ {
+ this.charField = charField;
+ }
+
+ protected ProtectedPrimitiveBean(double doubleField)
+ {
+ this.doubleField = doubleField;
+ }
+
+ protected ProtectedPrimitiveBean(Object object)
+ {
+ this.object = object;
+ }
+
+ protected ProtectedPrimitiveBean(float floatField)
+ {
+ this.floatField = floatField;
+ }
+
+ protected ProtectedPrimitiveBean(int intField)
+ {
+ this.intField = intField;
+ }
+
+ protected ProtectedPrimitiveBean(long longField)
+ {
+ this.longField = longField;
+ }
+
+ protected ProtectedPrimitiveBean(short shortField)
+ {
+ this.shortField = shortField;
+ }
+
+ protected ProtectedPrimitiveBean(String object, boolean booleanField, byte byteField, char charField)
+ {
+ this.object = object;
+ this.booleanField = booleanField;
+ this.byteField = byteField;
+ this.charField = charField;
+ }
+
+ protected void noReturnNoParams()
+ {
+
+ }
+
+ protected String bigMethod(String s, boolean booleanField, byte byteField, char charField)
+ {
+ return s;
+ }
+
+ protected Object objectMethod(Object object)
+ {
+ this.object = object;
+ return this.object;
+ }
+
+ protected boolean booleanMethod(boolean param)
+ {
+ this.booleanField = param;
+ return param;
+ }
+
+ protected byte byteMethod(byte param)
+ {
+ this.byteField = param;
+ return param;
+ }
+
+ protected char charMethod(char param)
+ {
+ this.charField = param;
+ return param;
+ }
+
+ protected double doubleMethod(double param)
+ {
+ this.doubleField = param;
+ return param;
+ }
+
+ protected float floatMethod(float param)
+ {
+ this.floatField = param;
+ return param;
+ }
+
+ protected int intMethod(int param)
+ {
+ this.intField = param;
+ return param;
+ }
+
+ protected long longMethod(long param)
+ {
+ this.longField = param;
+ return param;
+ }
+
+ protected short shortMethod(short param)
+ {
+ this.shortField = param;
+ return param;
+ }
+
+ //Getters only needed for the constructor tests
+ public Object getObject()
+ {
+ return object;
+ }
+
+ public Boolean getBooleanField()
+ {
+ return booleanField;
+ }
+
+ public Byte getByteField()
+ {
+ return byteField;
+ }
+
+ public Character getCharField()
+ {
+ return charField;
+ }
+
+ public Double getDoubleField()
+ {
+ return doubleField;
+ }
+
+ public Float getFloatField()
+ {
+ return floatField;
+ }
+
+ public Integer getIntField()
+ {
+ return intField;
+ }
+
+ public Long getLongField()
+ {
+ return longField;
+ }
+
+ public Short getShortField()
+ {
+ return shortField;
+ }
+}
Added: projects/jboss-reflect/trunk/src/test/java/org/jboss/test/plugins/javassist/bytecode/support/ProtectedStaticBoxedBean.java
===================================================================
--- projects/jboss-reflect/trunk/src/test/java/org/jboss/test/plugins/javassist/bytecode/support/ProtectedStaticBoxedBean.java (rev 0)
+++ projects/jboss-reflect/trunk/src/test/java/org/jboss/test/plugins/javassist/bytecode/support/ProtectedStaticBoxedBean.java 2010-03-24 16:48:26 UTC (rev 102910)
@@ -0,0 +1,113 @@
+/*
+* JBoss, Home of Professional Open Source.
+* Copyright 2006, Red Hat Middleware LLC, and individual contributors
+* as indicated by the @author tags. See the copyright.txt file in the
+* distribution for a full listing of individual contributors.
+*
+* This is free software; you can redistribute it and/or modify it
+* under the terms of the GNU Lesser General Public License as
+* published by the Free Software Foundation; either version 2.1 of
+* the License, or (at your option) any later version.
+*
+* This software is distributed in the hope that it will be useful,
+* but WITHOUT ANY WARRANTY; without even the implied warranty of
+* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+* Lesser General Public License for more details.
+*
+* You should have received a copy of the GNU Lesser General Public
+* License along with this software; if not, write to the Free
+* Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+* 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+*/
+package org.jboss.test.plugins.javassist.bytecode.support;
+
+/**
+ *
+ * @author <a href="kabir.khan at jboss.com">Kabir Khan</a>
+ * @version $Revision: 1.1 $
+ */
+public class ProtectedStaticBoxedBean
+{
+ protected static Object object;
+
+ protected static Boolean booleanField;
+
+ protected static Byte byteField;
+
+ protected static Character charField;
+
+ protected static Double doubleField;
+
+ protected static Float floatField;
+
+ protected static Integer intField;
+
+ protected static Long longField;
+
+ protected static Short shortField;
+
+ protected static void noReturnNoParams()
+ {
+
+ }
+
+ protected static String bigMethod(String s, Boolean booleanField, Byte byteField, Character charField)
+ {
+ return s;
+ }
+
+ protected static Object objectMethod(Object object)
+ {
+ ProtectedStaticBoxedBean.object = object;
+ return ProtectedStaticBoxedBean.object;
+ }
+
+ protected static Boolean booleanMethod(Boolean param)
+ {
+ ProtectedStaticBoxedBean.booleanField = param;
+ return param;
+ }
+
+ protected static Byte byteMethod(Byte param)
+ {
+ ProtectedStaticBoxedBean.byteField = param;
+ return param;
+ }
+
+ protected static Character charMethod(Character param)
+ {
+ ProtectedStaticBoxedBean.charField = param;
+ return param;
+ }
+
+ protected static Double doubleMethod(Double param)
+ {
+ ProtectedStaticBoxedBean.doubleField = param;
+ return param;
+ }
+
+ protected static Float floatMethod(Float param)
+ {
+ ProtectedStaticBoxedBean.floatField = param;
+ return param;
+ }
+
+ protected static Integer intMethod(Integer param)
+ {
+ ProtectedStaticBoxedBean.intField = param;
+ return param;
+ }
+
+ protected static Long longMethod(Long param)
+ {
+ ProtectedStaticBoxedBean.longField = param;
+ return param;
+ }
+
+ protected static Short shortMethod(Short param)
+ {
+ ProtectedStaticBoxedBean.shortField = param;
+ return param;
+ }
+
+}
Added: projects/jboss-reflect/trunk/src/test/java/org/jboss/test/plugins/javassist/bytecode/support/ProtectedStaticPrimitiveBean.java
===================================================================
--- projects/jboss-reflect/trunk/src/test/java/org/jboss/test/plugins/javassist/bytecode/support/ProtectedStaticPrimitiveBean.java (rev 0)
+++ projects/jboss-reflect/trunk/src/test/java/org/jboss/test/plugins/javassist/bytecode/support/ProtectedStaticPrimitiveBean.java 2010-03-24 16:48:26 UTC (rev 102910)
@@ -0,0 +1,113 @@
+/*
+* JBoss, Home of Professional Open Source.
+* Copyright 2006, Red Hat Middleware LLC, and individual contributors
+* as indicated by the @author tags. See the copyright.txt file in the
+* distribution for a full listing of individual contributors.
+*
+* This is free software; you can redistribute it and/or modify it
+* under the terms of the GNU Lesser General Public License as
+* published by the Free Software Foundation; either version 2.1 of
+* the License, or (at your option) any later version.
+*
+* This software is distributed in the hope that it will be useful,
+* but WITHOUT ANY WARRANTY; without even the implied warranty of
+* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+* Lesser General Public License for more details.
+*
+* You should have received a copy of the GNU Lesser General Public
+* License along with this software; if not, write to the Free
+* Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+* 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+*/
+package org.jboss.test.plugins.javassist.bytecode.support;
+
+/**
+ *
+ * @author <a href="kabir.khan at jboss.com">Kabir Khan</a>
+ * @version $Revision: 1.1 $
+ */
+public class ProtectedStaticPrimitiveBean
+{
+ protected static Object object;
+
+ protected static boolean booleanField;
+
+ protected static byte byteField;
+
+ protected static char charField;
+
+ protected static double doubleField;
+
+ protected static float floatField;
+
+ protected static int intField;
+
+ protected static long longField;
+
+ protected static short shortField;
+
+ protected static void noReturnNoParams()
+ {
+
+ }
+
+ protected static String bigMethod(String s, boolean booleanField, byte byteField, char charField)
+ {
+ return s;
+ }
+
+ protected static Object objectMethod(Object object)
+ {
+ ProtectedStaticPrimitiveBean.object = object;
+ return ProtectedStaticPrimitiveBean.object;
+ }
+
+ protected static boolean booleanMethod(boolean param)
+ {
+ ProtectedStaticPrimitiveBean.booleanField = param;
+ return param;
+ }
+
+ protected static byte byteMethod(byte param)
+ {
+ ProtectedStaticPrimitiveBean.byteField = param;
+ return param;
+ }
+
+ protected static char charMethod(char param)
+ {
+ ProtectedStaticPrimitiveBean.charField = param;
+ return param;
+ }
+
+ protected static double doubleMethod(double param)
+ {
+ ProtectedStaticPrimitiveBean.doubleField = param;
+ return param;
+ }
+
+ protected static float floatMethod(float param)
+ {
+ ProtectedStaticPrimitiveBean.floatField = param;
+ return param;
+ }
+
+ protected static int intMethod(int param)
+ {
+ ProtectedStaticPrimitiveBean.intField = param;
+ return param;
+ }
+
+ protected static long longMethod(long param)
+ {
+ ProtectedStaticPrimitiveBean.longField = param;
+ return param;
+ }
+
+ protected static short shortMethod(short param)
+ {
+ ProtectedStaticPrimitiveBean.shortField = param;
+ return param;
+ }
+
+}
Added: projects/jboss-reflect/trunk/src/test/java/org/jboss/test/plugins/javassist/bytecode/support/PublicBoxedBean.java
===================================================================
--- projects/jboss-reflect/trunk/src/test/java/org/jboss/test/plugins/javassist/bytecode/support/PublicBoxedBean.java (rev 0)
+++ projects/jboss-reflect/trunk/src/test/java/org/jboss/test/plugins/javassist/bytecode/support/PublicBoxedBean.java 2010-03-24 16:48:26 UTC (rev 102910)
@@ -0,0 +1,215 @@
+/*
+* JBoss, Home of Professional Open Source.
+* Copyright 2006, Red Hat Middleware LLC, and individual contributors
+* as indicated by the @author tags. See the copyright.txt file in the
+* distribution for a full listing of individual contributors.
+*
+* This is free software; you can redistribute it and/or modify it
+* under the terms of the GNU Lesser General Public License as
+* published by the Free Software Foundation; either version 2.1 of
+* the License, or (at your option) any later version.
+*
+* This software is distributed in the hope that it will be useful,
+* but WITHOUT ANY WARRANTY; without even the implied warranty of
+* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+* Lesser General Public License for more details.
+*
+* You should have received a copy of the GNU Lesser General Public
+* License along with this software; if not, write to the Free
+* Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+* 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+*/
+package org.jboss.test.plugins.javassist.bytecode.support;
+
+/**
+ *
+ * @author <a href="kabir.khan at jboss.com">Kabir Khan</a>
+ * @version $Revision: 1.1 $
+ */
+public class PublicBoxedBean implements BeanInterface
+{
+ public Object object;
+
+ public Boolean booleanField;
+
+ public Byte byteField;
+
+ public Character charField;
+
+ public Double doubleField;
+
+ public Float floatField;
+
+ public Integer intField;
+
+ public Long longField;
+
+ public Short shortField;
+
+ public PublicBoxedBean()
+ {
+ }
+
+ public PublicBoxedBean(Boolean booleanField)
+ {
+ this.booleanField = booleanField;
+ }
+
+ public PublicBoxedBean(Byte byteField)
+ {
+ this.byteField = byteField;
+ }
+
+ public PublicBoxedBean(Character charField)
+ {
+ this.charField = charField;
+ }
+
+ public PublicBoxedBean(Double doubleField)
+ {
+ this.doubleField = doubleField;
+ }
+
+ public PublicBoxedBean(Object object)
+ {
+ this.object = object;
+ }
+
+ public PublicBoxedBean(Float floatField)
+ {
+ this.floatField = floatField;
+ }
+
+ public PublicBoxedBean(Integer intField)
+ {
+ this.intField = intField;
+ }
+
+ public PublicBoxedBean(Long longField)
+ {
+ this.longField = longField;
+ }
+
+ public PublicBoxedBean(Short shortField)
+ {
+ this.shortField = shortField;
+ }
+
+ public PublicBoxedBean(String object, Boolean booleanField, Byte byteField, Character charField)
+ {
+ this.object = object;
+ this.booleanField = booleanField;
+ this.byteField = byteField;
+ this.charField = charField;
+ }
+
+ public void noReturnNoParams()
+ {
+
+ }
+
+ public String bigMethod(String s, Boolean booleanField, Byte byteField, Character charField)
+ {
+ return s;
+ }
+
+ public Object objectMethod(Object object)
+ {
+ this.object = object;
+ return this.object;
+ }
+
+ public Boolean booleanMethod(Boolean param)
+ {
+ this.booleanField = param;
+ return param;
+ }
+
+ public Byte byteMethod(Byte param)
+ {
+ this.byteField = param;
+ return param;
+ }
+
+ public Character charMethod(Character param)
+ {
+ this.charField = param;
+ return param;
+ }
+
+ public Double doubleMethod(Double param)
+ {
+ this.doubleField = param;
+ return param;
+ }
+
+ public Float floatMethod(Float param)
+ {
+ this.floatField = param;
+ return param;
+ }
+
+ public Integer intMethod(Integer param)
+ {
+ this.intField = param;
+ return param;
+ }
+
+ public Long longMethod(Long param)
+ {
+ this.longField = param;
+ return param;
+ }
+
+ public Short shortMethod(Short param)
+ {
+ this.shortField = param;
+ return param;
+ }
+
+ //Getters only needed for the constructor tests
+ public Object getObject()
+ {
+ return object;
+ }
+
+ public Boolean getBooleanField()
+ {
+ return booleanField;
+ }
+
+ public Byte getByteField()
+ {
+ return byteField;
+ }
+
+ public Character getCharField()
+ {
+ return charField;
+ }
+
+ public Double getDoubleField()
+ {
+ return doubleField;
+ }
+
+ public Float getFloatField()
+ {
+ return floatField;
+ }
+
+ public Integer getIntField()
+ {
+ return intField;
+ }
+
+ public Long getLongField()
+ {
+ return longField;
+ }
+
+ public Short getShortField()
+ {
+ return shortField;
+ }
+}
Added: projects/jboss-reflect/trunk/src/test/java/org/jboss/test/plugins/javassist/bytecode/support/PublicPrimitiveBean.java
===================================================================
--- projects/jboss-reflect/trunk/src/test/java/org/jboss/test/plugins/javassist/bytecode/support/PublicPrimitiveBean.java (rev 0)
+++ projects/jboss-reflect/trunk/src/test/java/org/jboss/test/plugins/javassist/bytecode/support/PublicPrimitiveBean.java 2010-03-24 16:48:26 UTC (rev 102910)
@@ -0,0 +1,215 @@
+/*
+* JBoss, Home of Professional Open Source.
+* Copyright 2006, Red Hat Middleware LLC, and individual contributors
+* as indicated by the @author tags. See the copyright.txt file in the
+* distribution for a full listing of individual contributors.
+*
+* This is free software; you can redistribute it and/or modify it
+* under the terms of the GNU Lesser General Public License as
+* published by the Free Software Foundation; either version 2.1 of
+* the License, or (at your option) any later version.
+*
+* This software is distributed in the hope that it will be useful,
+* but WITHOUT ANY WARRANTY; without even the implied warranty of
+* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+* Lesser General Public License for more details.
+*
+* You should have received a copy of the GNU Lesser General Public
+* License along with this software; if not, write to the Free
+* Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+* 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+*/
+package org.jboss.test.plugins.javassist.bytecode.support;
+
+/**
+ *
+ * @author <a href="kabir.khan at jboss.com">Kabir Khan</a>
+ * @version $Revision: 1.1 $
+ */
+public class PublicPrimitiveBean implements BeanInterface
+{
+ public Object object;
+
+ public boolean booleanField;
+
+ public byte byteField;
+
+ public char charField;
+
+ public double doubleField;
+
+ public float floatField;
+
+ public int intField;
+
+ public long longField;
+
+ public short shortField;
+
+ public PublicPrimitiveBean()
+ {
+ }
+
+ public PublicPrimitiveBean(boolean booleanField)
+ {
+ this.booleanField = booleanField;
+ }
+
+ public PublicPrimitiveBean(byte byteField)
+ {
+ this.byteField = byteField;
+ }
+
+ public PublicPrimitiveBean(char charField)
+ {
+ this.charField = charField;
+ }
+
+ public PublicPrimitiveBean(double doubleField)
+ {
+ this.doubleField = doubleField;
+ }
+
+ public PublicPrimitiveBean(Object object)
+ {
+ this.object = object;
+ }
+
+ public PublicPrimitiveBean(float floatField)
+ {
+ this.floatField = floatField;
+ }
+
+ public PublicPrimitiveBean(int intField)
+ {
+ this.intField = intField;
+ }
+
+ public PublicPrimitiveBean(long longField)
+ {
+ this.longField = longField;
+ }
+
+ public PublicPrimitiveBean(short shortField)
+ {
+ this.shortField = shortField;
+ }
+
+ public PublicPrimitiveBean(String object, boolean booleanField, byte byteField, char charField)
+ {
+ this.object = object;
+ this.booleanField = booleanField;
+ this.byteField = byteField;
+ this.charField = charField;
+ }
+
+ public void noReturnNoParams()
+ {
+
+ }
+
+ public String bigMethod(String s, boolean booleanField, byte byteField, char charField)
+ {
+ return s;
+ }
+
+ public Object objectMethod(Object object)
+ {
+ this.object = object;
+ return this.object;
+ }
+
+ public boolean booleanMethod(boolean param)
+ {
+ this.booleanField = param;
+ return param;
+ }
+
+ public byte byteMethod(byte param)
+ {
+ this.byteField = param;
+ return param;
+ }
+
+ public char charMethod(char param)
+ {
+ this.charField = param;
+ return param;
+ }
+
+ public double doubleMethod(double param)
+ {
+ this.doubleField = param;
+ return param;
+ }
+
+ public float floatMethod(float param)
+ {
+ this.floatField = param;
+ return param;
+ }
+
+ public int intMethod(int param)
+ {
+ this.intField = param;
+ return param;
+ }
+
+ public long longMethod(long param)
+ {
+ this.longField = param;
+ return param;
+ }
+
+ public short shortMethod(short param)
+ {
+ this.shortField = param;
+ return param;
+ }
+
+ //Getters only needed for the constructor tests
+ public Object getObject()
+ {
+ return object;
+ }
+
+ public Boolean getBooleanField()
+ {
+ return booleanField;
+ }
+
+ public Byte getByteField()
+ {
+ return byteField;
+ }
+
+ public Character getCharField()
+ {
+ return charField;
+ }
+
+ public Double getDoubleField()
+ {
+ return doubleField;
+ }
+
+ public Float getFloatField()
+ {
+ return floatField;
+ }
+
+ public Integer getIntField()
+ {
+ return intField;
+ }
+
+ public Long getLongField()
+ {
+ return longField;
+ }
+
+ public Short getShortField()
+ {
+ return shortField;
+ }
+}
Added: projects/jboss-reflect/trunk/src/test/java/org/jboss/test/plugins/javassist/bytecode/support/PublicStaticBoxedBean.java
===================================================================
--- projects/jboss-reflect/trunk/src/test/java/org/jboss/test/plugins/javassist/bytecode/support/PublicStaticBoxedBean.java (rev 0)
+++ projects/jboss-reflect/trunk/src/test/java/org/jboss/test/plugins/javassist/bytecode/support/PublicStaticBoxedBean.java 2010-03-24 16:48:26 UTC (rev 102910)
@@ -0,0 +1,113 @@
+/*
+* JBoss, Home of Professional Open Source.
+* Copyright 2006, Red Hat Middleware LLC, and individual contributors
+* as indicated by the @author tags. See the copyright.txt file in the
+* distribution for a full listing of individual contributors.
+*
+* This is free software; you can redistribute it and/or modify it
+* under the terms of the GNU Lesser General Public License as
+* published by the Free Software Foundation; either version 2.1 of
+* the License, or (at your option) any later version.
+*
+* This software is distributed in the hope that it will be useful,
+* but WITHOUT ANY WARRANTY; without even the implied warranty of
+* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+* Lesser General Public License for more details.
+*
+* You should have received a copy of the GNU Lesser General Public
+* License along with this software; if not, write to the Free
+* Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+* 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+*/
+package org.jboss.test.plugins.javassist.bytecode.support;
+
+/**
+ *
+ * @author <a href="kabir.khan at jboss.com">Kabir Khan</a>
+ * @version $Revision: 1.1 $
+ */
+public class PublicStaticBoxedBean
+{
+ public static Object object;
+
+ public static Boolean booleanField;
+
+ public static Byte byteField;
+
+ public static Character charField;
+
+ public static Double doubleField;
+
+ public static Float floatField;
+
+ public static Integer intField;
+
+ public static Long longField;
+
+ public static Short shortField;
+
+ public static void noReturnNoParams()
+ {
+
+ }
+
+ public static String bigMethod(String s, Boolean booleanField, Byte byteField, Character charField)
+ {
+ return s;
+ }
+
+ public static Object objectMethod(Object object)
+ {
+ PublicStaticBoxedBean.object = object;
+ return PublicStaticBoxedBean.object;
+ }
+
+ public static Boolean booleanMethod(Boolean param)
+ {
+ PublicStaticBoxedBean.booleanField = param;
+ return param;
+ }
+
+ public static Byte byteMethod(Byte param)
+ {
+ PublicStaticBoxedBean.byteField = param;
+ return param;
+ }
+
+ public static Character charMethod(Character param)
+ {
+ PublicStaticBoxedBean.charField = param;
+ return param;
+ }
+
+ public static Double doubleMethod(Double param)
+ {
+ PublicStaticBoxedBean.doubleField = param;
+ return param;
+ }
+
+ public static Float floatMethod(Float param)
+ {
+ PublicStaticBoxedBean.floatField = param;
+ return param;
+ }
+
+ public static Integer intMethod(Integer param)
+ {
+ PublicStaticBoxedBean.intField = param;
+ return param;
+ }
+
+ public static Long longMethod(Long param)
+ {
+ PublicStaticBoxedBean.longField = param;
+ return param;
+ }
+
+ public static Short shortMethod(Short param)
+ {
+ PublicStaticBoxedBean.shortField = param;
+ return param;
+ }
+
+}
Added: projects/jboss-reflect/trunk/src/test/java/org/jboss/test/plugins/javassist/bytecode/support/PublicStaticPrimitiveBean.java
===================================================================
--- projects/jboss-reflect/trunk/src/test/java/org/jboss/test/plugins/javassist/bytecode/support/PublicStaticPrimitiveBean.java (rev 0)
+++ projects/jboss-reflect/trunk/src/test/java/org/jboss/test/plugins/javassist/bytecode/support/PublicStaticPrimitiveBean.java 2010-03-24 16:48:26 UTC (rev 102910)
@@ -0,0 +1,113 @@
+/*
+* JBoss, Home of Professional Open Source.
+* Copyright 2006, Red Hat Middleware LLC, and individual contributors
+* as indicated by the @author tags. See the copyright.txt file in the
+* distribution for a full listing of individual contributors.
+*
+* This is free software; you can redistribute it and/or modify it
+* under the terms of the GNU Lesser General Public License as
+* published by the Free Software Foundation; either version 2.1 of
+* the License, or (at your option) any later version.
+*
+* This software is distributed in the hope that it will be useful,
+* but WITHOUT ANY WARRANTY; without even the implied warranty of
+* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+* Lesser General Public License for more details.
+*
+* You should have received a copy of the GNU Lesser General Public
+* License along with this software; if not, write to the Free
+* Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+* 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+*/
+package org.jboss.test.plugins.javassist.bytecode.support;
+
+/**
+ *
+ * @author <a href="kabir.khan at jboss.com">Kabir Khan</a>
+ * @version $Revision: 1.1 $
+ */
+public class PublicStaticPrimitiveBean
+{
+ public static Object object;
+
+ public static boolean booleanField;
+
+ public static byte byteField;
+
+ public static char charField;
+
+ public static double doubleField;
+
+ public static float floatField;
+
+ public static int intField;
+
+ public static long longField;
+
+ public static short shortField;
+
+ public static void noReturnNoParams()
+ {
+
+ }
+
+ public static String bigMethod(String s, boolean booleanField, byte byteField, char charField)
+ {
+ return s;
+ }
+
+ public static Object objectMethod(Object object)
+ {
+ PublicStaticPrimitiveBean.object = object;
+ return PublicStaticPrimitiveBean.object;
+ }
+
+ public static boolean booleanMethod(boolean param)
+ {
+ PublicStaticPrimitiveBean.booleanField = param;
+ return param;
+ }
+
+ public static byte byteMethod(byte param)
+ {
+ PublicStaticPrimitiveBean.byteField = param;
+ return param;
+ }
+
+ public static char charMethod(char param)
+ {
+ PublicStaticPrimitiveBean.charField = param;
+ return param;
+ }
+
+ public static double doubleMethod(double param)
+ {
+ PublicStaticPrimitiveBean.doubleField = param;
+ return param;
+ }
+
+ public static float floatMethod(float param)
+ {
+ PublicStaticPrimitiveBean.floatField = param;
+ return param;
+ }
+
+ public static int intMethod(int param)
+ {
+ PublicStaticPrimitiveBean.intField = param;
+ return param;
+ }
+
+ public static long longMethod(long param)
+ {
+ PublicStaticPrimitiveBean.longField = param;
+ return param;
+ }
+
+ public static short shortMethod(short param)
+ {
+ PublicStaticPrimitiveBean.shortField = param;
+ return param;
+ }
+
+}
Added: projects/jboss-reflect/trunk/src/test/java/org/jboss/test/plugins/javassist/bytecode/test/AbstractJavassistMemberAndConstructorFactoryTest.java
===================================================================
--- projects/jboss-reflect/trunk/src/test/java/org/jboss/test/plugins/javassist/bytecode/test/AbstractJavassistMemberAndConstructorFactoryTest.java (rev 0)
+++ projects/jboss-reflect/trunk/src/test/java/org/jboss/test/plugins/javassist/bytecode/test/AbstractJavassistMemberAndConstructorFactoryTest.java 2010-03-24 16:48:26 UTC (rev 102910)
@@ -0,0 +1,201 @@
+/*
+* JBoss, Home of Professional Open Source.
+* Copyright 2006, Red Hat Middleware LLC, and individual contributors
+* as indicated by the @author tags. See the copyright.txt file in the
+* distribution for a full listing of individual contributors.
+*
+* This is free software; you can redistribute it and/or modify it
+* under the terms of the GNU Lesser General Public License as
+* published by the Free Software Foundation; either version 2.1 of
+* the License, or (at your option) any later version.
+*
+* This software is distributed in the hope that it will be useful,
+* but WITHOUT ANY WARRANTY; without even the implied warranty of
+* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+* Lesser General Public License for more details.
+*
+* You should have received a copy of the GNU Lesser General Public
+* License along with this software; if not, write to the Free
+* Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+* 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+*/
+package org.jboss.test.plugins.javassist.bytecode.test;
+
+import org.jboss.reflect.plugins.javassist.JavassistConstructor;
+import org.jboss.test.plugins.javassist.bytecode.support.BeanInterface;
+
+/**
+ * Abstract base class for testing JavassistConstructor. JavassistMethod and JavassistField
+ * get tested in the super class.
+ *
+ * @author <a href="kabir.khan at jboss.com">Kabir Khan</a>
+ * @version $Revision: 1.1 $
+ */
+public abstract class AbstractJavassistMemberAndConstructorFactoryTest extends AbstractJavassistMemberFactoryTest
+{
+ public AbstractJavassistMemberAndConstructorFactoryTest(String name, boolean isPrimitive)
+ {
+ super(name, isPrimitive);
+ }
+
+ public void testDefaultConstructor() throws Throwable
+ {
+ JavassistConstructor ctor = createConstructor(getClazz());
+ Object o = ctor.newInstance(null);
+ assertNotNull(o);
+ assertInstanceOf(o, getClazz());
+ }
+
+ public void testDefaultConstructorWithEmptyParameters() throws Throwable
+ {
+ JavassistConstructor ctor = createConstructor(getClazz());
+ Object o = ctor.newInstance(new Object[0]);
+ assertNotNull(o);
+ assertInstanceOf(o, getClazz());
+ }
+
+ public void testDefaultConstructorWithTooManyParametersError() throws Throwable
+ {
+ JavassistConstructor ctor = createConstructor(getClazz());
+ checkWrongParameters(ctor, new Object[] {new Object()});
+ }
+
+ public void testObjectConstructor() throws Throwable
+ {
+ JavassistConstructor ctor = createConstructor(getClazz(), Object.class);
+ Object p1 = new Object();
+ Object o = ctor.newInstance(new Object[] {p1});
+ assertNotNull(o);
+ assertInstanceOf(o, getClazz());
+ BeanInterface bean = assertInstanceOf(o, BeanInterface.class);
+ assertSame(p1, bean.getObject());
+ }
+
+ public void testObjectConstructorWithNullParameters() throws Throwable
+ {
+ JavassistConstructor ctor = createConstructor(getClazz(), Object.class);
+ checkWrongParameters(ctor, null);
+ }
+
+ public void testObjectConstructorWithEmptyParameters() throws Throwable
+ {
+ JavassistConstructor ctor = createConstructor(getClazz(), Object.class);
+ checkWrongParameters(ctor, new Object[0]);
+ }
+
+ public void testObjectConstructorWithTooManyParameters() throws Throwable
+ {
+ JavassistConstructor ctor = createConstructor(getClazz(), Object.class);
+ checkWrongParameters(ctor, new Object[] {new Object(), new Object()});
+ }
+
+ public void testSimpleBooleanConstructor() throws Throwable
+ {
+ JavassistConstructor ctor = createConstructor(getClazz(), Boolean.class);
+ Boolean value = Boolean.TRUE;
+ BeanInterface bean = testSimplePrimitiveConstructor(ctor, value);
+ assertSame(value, bean.getBooleanField());
+ }
+
+ public void testSimpleByteConstructor() throws Throwable
+ {
+ JavassistConstructor ctor = createConstructor(getClazz(), Byte.class);
+ Byte value = Byte.valueOf((byte)1);
+ BeanInterface bean = testSimplePrimitiveConstructor(ctor, value);
+ assertSame(value, bean.getByteField());
+ }
+
+ public void testSimpleCharConstructor() throws Throwable
+ {
+ JavassistConstructor ctor = createConstructor(getClazz(), Character.class);
+ Character value = Character.valueOf('a');
+ BeanInterface bean = testSimplePrimitiveConstructor(ctor, value);
+ assertSame(value, bean.getCharField());
+ }
+
+ public void testSimpleDoubleConstructor() throws Throwable
+ {
+ JavassistConstructor ctor = createConstructor(getClazz(), Double.class);
+ Double value = Double.valueOf(3);
+ BeanInterface bean = testSimplePrimitiveConstructor(ctor, value);
+ assertEquals(value, bean.getDoubleField());
+ }
+
+ public void testSimpleFloatConstructor() throws Throwable
+ {
+ JavassistConstructor ctor = createConstructor(getClazz(), Float.class);
+ Float value = Float.valueOf(4);
+ BeanInterface bean = testSimplePrimitiveConstructor(ctor, value);
+ assertEquals(value, bean.getFloatField());
+ }
+
+ public void testSimpleIntConstructor() throws Throwable
+ {
+ JavassistConstructor ctor = createConstructor(getClazz(), Integer.class);
+ Integer value = Integer.valueOf(5);
+ BeanInterface bean = testSimplePrimitiveConstructor(ctor, value);
+ assertSame(value, bean.getIntField());
+ }
+
+ public void testSimpleLongConstructor() throws Throwable
+ {
+ JavassistConstructor ctor = createConstructor(getClazz(), Long.class);
+ Long value = Long.valueOf(6);
+ BeanInterface bean = testSimplePrimitiveConstructor(ctor, value);
+ assertSame(value, bean.getLongField());
+ }
+
+ public void testSimpleShortConstructor() throws Throwable
+ {
+ JavassistConstructor ctor = createConstructor(getClazz(), Short.class);
+ Short value = Short.valueOf((short)7);
+ BeanInterface bean = testSimplePrimitiveConstructor(ctor, value);
+ assertSame(value, bean.getShortField());
+ }
+
+ public void testBigConstructor() throws Throwable
+ {
+ JavassistConstructor ctor = createConstructor(getClazz(), new Class[] {String.class, Boolean.class, Byte.class, Character.class});
+ checkWrongParameters(ctor, new Object[] {Integer.valueOf(1)});
+ checkWrongParameters(ctor, new Object[] {"Test"});
+ checkWrongParameters(ctor, new Object[] {"Test", Boolean.TRUE});
+ checkWrongParameters(ctor, new Object[] {"Test", Boolean.TRUE, Byte.valueOf((byte)1)});
+ checkWrongParameters(ctor, new Object[] {"Test", Boolean.TRUE, Byte.valueOf((byte)1), Integer.valueOf(5)});
+ checkWrongParameters(ctor, new Object[] {"Test", Boolean.TRUE, Byte.valueOf((byte)1), Character.valueOf('a'), null});
+
+ Object o = ctor.newInstance(new Object[] {"Test", Boolean.TRUE, Byte.valueOf((byte)1), Character.valueOf('a')});
+ assertNotNull(o);
+ BeanInterface bean = assertInstanceOf(o, BeanInterface.class);
+ assertEquals("Test", bean.getObject());
+ assertSame(Boolean.TRUE, bean.getBooleanField());
+ assertSame(Byte.valueOf((byte)1), bean.getByteField());
+ assertSame(Character.valueOf('a'), bean.getCharField());
+ }
+ protected BeanInterface testSimplePrimitiveConstructor(JavassistConstructor ctor, Object goodParam) throws Throwable
+ {
+ checkWrongParameters(ctor, new Object[] {"Not a primitive"});
+ checkWrongParameters(ctor, new Object[] {goodParam, goodParam});
+ checkWrongParameters(ctor, null);
+ checkWrongParameters(ctor, new Object[0]);
+ if (isPrimitive)
+ checkWrongParameters(ctor, new Object[] {null});
+ else
+ assertNotNull(ctor.newInstance(new Object[] {null}));
+
+ Object o = ctor.newInstance(new Object[] {goodParam});
+ return assertInstanceOf(o, BeanInterface.class);
+ }
+
+ protected void checkWrongParameters(JavassistConstructor ctor, Object[] params) throws Throwable
+ {
+ try
+ {
+ ctor.newInstance(params);
+ fail("Should have picked up wrong parameters");
+ }
+ catch (Exception expected)
+ {
+ }
+ }
+
+}
Added: projects/jboss-reflect/trunk/src/test/java/org/jboss/test/plugins/javassist/bytecode/test/AbstractJavassistMemberFactoryTest.java
===================================================================
--- projects/jboss-reflect/trunk/src/test/java/org/jboss/test/plugins/javassist/bytecode/test/AbstractJavassistMemberFactoryTest.java (rev 0)
+++ projects/jboss-reflect/trunk/src/test/java/org/jboss/test/plugins/javassist/bytecode/test/AbstractJavassistMemberFactoryTest.java 2010-03-24 16:48:26 UTC (rev 102910)
@@ -0,0 +1,362 @@
+/*
+* JBoss, Home of Professional Open Source.
+* Copyright 2006, Red Hat Middleware LLC, and individual contributors
+* as indicated by the @author tags. See the copyright.txt file in the
+* distribution for a full listing of individual contributors.
+*
+* This is free software; you can redistribute it and/or modify it
+* under the terms of the GNU Lesser General Public License as
+* published by the Free Software Foundation; either version 2.1 of
+* the License, or (at your option) any later version.
+*
+* This software is distributed in the hope that it will be useful,
+* but WITHOUT ANY WARRANTY; without even the implied warranty of
+* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+* Lesser General Public License for more details.
+*
+* You should have received a copy of the GNU Lesser General Public
+* License along with this software; if not, write to the Free
+* Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+* 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+*/
+package org.jboss.test.plugins.javassist.bytecode.test;
+
+import java.util.Arrays;
+
+import javassist.ClassPool;
+import javassist.CtClass;
+import javassist.CtConstructor;
+import javassist.CtField;
+import javassist.CtMethod;
+
+import org.jboss.reflect.plugins.javassist.JavassistConstructor;
+import org.jboss.reflect.plugins.javassist.JavassistField;
+import org.jboss.reflect.plugins.javassist.JavassistMethod;
+import org.jboss.reflect.plugins.javassist.bytecode.JavassistMemberFactory;
+import org.jboss.test.ContainerTest;
+
+/**
+ * Abstract base class for testing JavassistMethod and JavassistField
+ *
+ * @author <a href="kabir.khan at jboss.com">Kabir Khan</a>
+ * @version $Revision: 1.1 $
+ */
+public abstract class AbstractJavassistMemberFactoryTest extends ContainerTest
+{
+ protected static final boolean CHECK = true;
+
+ protected static final boolean DEBUG = false;
+
+ protected static final Class<?> MAGIC_ACCESSOR_IMPL;
+ static
+ {
+ try
+ {
+ MAGIC_ACCESSOR_IMPL = Class.forName("sun.reflect.MagicAccessorImpl");
+ }
+ catch (ClassNotFoundException e)
+ {
+ throw new RuntimeException(e);
+ }
+ }
+
+ protected final boolean isPrimitive;
+
+ public AbstractJavassistMemberFactoryTest(String name, boolean isPrimitive)
+ {
+ super(name);
+ this.isPrimitive = isPrimitive;
+ }
+
+ //Test methods
+
+ public void testNoParamsNoReturnMethod() throws Throwable
+ {
+ JavassistMethod m = createMethod(getClazz(), "noReturnNoParams");
+ m.invoke(createInstance(), null);
+ }
+
+ public void testNoParamsNoReturnMethodEmptyParameters() throws Throwable
+ {
+ JavassistMethod m = createMethod(getClazz(), "noReturnNoParams");
+ m.invoke(createInstance(), new Object[0]);
+ }
+
+ public void testNoParamsNoReturnMethodWithTooManyParametersError() throws Throwable
+ {
+ JavassistMethod m = createMethod(getClazz(), "noReturnNoParams");
+ checkWrongParameters(m, createInstance(), new Object[] {new Object()});
+ }
+
+ public void testObjectMethod() throws Throwable
+ {
+ JavassistMethod m = createMethod(getClazz(), "objectMethod", Object.class);
+ Object p1 = new Object();
+ Object ret = m.invoke(createInstance(), new Object[] {p1});
+ assertSame(ret, p1);
+ }
+
+ public void testObjectMethodWithNullParameters() throws Throwable
+ {
+ JavassistMethod m = createMethod(getClazz(), "noReturnNoParams");
+ checkWrongParameters(m, createInstance(), null);
+ }
+
+ public void testObjectMethodWithEmptyParameters() throws Throwable
+ {
+ JavassistMethod m = createMethod(getClazz(), "noReturnNoParams");
+ checkWrongParameters(m, createInstance(), new Object[0]);
+ }
+
+ public void testObjectMethodWithTooManyParameters() throws Throwable
+ {
+ JavassistMethod m = createMethod(getClazz(), "noReturnNoParams");
+ checkWrongParameters(m, createInstance(), new Object[] {new Object(), new Object()});
+ }
+
+ public void testSimpleBooleanMethod() throws Throwable
+ {
+ testSimplePrimitiveMethod(createMethod(getClazz(), "booleanMethod", Boolean.class), Boolean.TRUE);
+ }
+
+ public void testSimpleByteMethod() throws Throwable
+ {
+ testSimplePrimitiveMethod(createMethod(getClazz(), "byteMethod", Byte.class), Byte.valueOf((byte)1));
+ }
+
+ public void testSimpleCharMethod() throws Throwable
+ {
+ testSimplePrimitiveMethod(createMethod(getClazz(), "charMethod", Character.class), Character.valueOf('a'));
+ }
+
+ public void testSimpleDoubleMethod() throws Throwable
+ {
+ testSimplePrimitiveMethod(createMethod(getClazz(), "doubleMethod", Double.class), Double.valueOf(2));
+ }
+
+ public void testSimpleFloatMethod() throws Throwable
+ {
+ testSimplePrimitiveMethod(createMethod(getClazz(), "floatMethod", Float.class), Float.valueOf(3));
+ }
+
+ public void testSimpleIntMethod() throws Throwable
+ {
+ testSimplePrimitiveMethod(createMethod(getClazz(), "intMethod", Integer.class), Integer.valueOf(4));
+ }
+
+ public void testSimpleLongMethod() throws Throwable
+ {
+ testSimplePrimitiveMethod(createMethod(getClazz(), "longMethod", Long.class), Long.valueOf(4));
+ }
+
+ public void testSimpleShortMethod() throws Throwable
+ {
+ testSimplePrimitiveMethod(createMethod(getClazz(), "shortMethod", Short.class), Short.valueOf((short)4));
+ }
+
+ protected void testSimplePrimitiveMethod(JavassistMethod method, Object goodParam) throws Throwable
+ {
+ Object target = createInstance();
+ checkWrongParameters(method, target, new Object[] {"Not a primitive"});
+ checkWrongParameters(method, target, new Object[] {null});
+ checkWrongParameters(method, target, new Object[0]);
+ checkWrongParameters(method, target, new Object[] {goodParam, goodParam});
+ if (isPrimitive)
+ checkWrongParameters(method, target, new Object[] {null});
+ else
+ assertNull(method.invoke(target, new Object[] {null}));
+
+ assertEquals(goodParam, method.invoke(target, new Object[] {goodParam}));
+ }
+
+ public void testBigMethod() throws Throwable
+ {
+ Object target = createInstance();
+ JavassistMethod method = createMethod(getClazz(), "bigMethod", new Class[] {String.class, Boolean.class, Byte.class, Character.class});
+ checkWrongParameters(method, target, new Object[] {Integer.valueOf(1)});
+ checkWrongParameters(method, target, new Object[] {"Test"});
+ checkWrongParameters(method, target, new Object[] {"Test", Boolean.TRUE});
+ checkWrongParameters(method, target, new Object[] {"Test", Boolean.TRUE, Byte.valueOf((byte)1)});
+ checkWrongParameters(method, target, new Object[] {"Test", Boolean.TRUE, Byte.valueOf((byte)1), Integer.valueOf(5)});
+ assertEquals("Test", method.invoke(target, new Object[] {"Test", Boolean.TRUE, Byte.valueOf((byte)1), Character.valueOf('a')}));
+ checkWrongParameters(method, target, new Object[] {"Test", Boolean.TRUE, Byte.valueOf((byte)1), Character.valueOf('a'), null});
+ }
+
+ //Test fields
+
+ public void testObjectField() throws Throwable
+ {
+ JavassistField f = createField(getClazz(), "object");
+ Object val = new Object();
+ Object tgt = createInstance();
+ f.set(tgt, val);
+ assertSame(val, f.get(tgt));
+ }
+
+ public void testObjectFieldNull() throws Throwable
+ {
+ JavassistField f = createField(getClazz(), "object");
+ Object val = null;
+ Object tgt = createInstance();
+ f.set(tgt, val);
+ assertNull(f.get(tgt));
+ }
+
+ public void testBooleanField() throws Throwable
+ {
+ testSimplePrimitiveField(createField(getClazz(), "booleanField"), Boolean.TRUE);
+ }
+
+ public void testByteField() throws Throwable
+ {
+ testSimplePrimitiveField(createField(getClazz(), "byteField"), Byte.valueOf((byte)1));
+ }
+
+ public void testCharField() throws Throwable
+ {
+ testSimplePrimitiveField(createField(getClazz(), "charField"), Character.valueOf('a'));
+ }
+
+ public void testDoubleField() throws Throwable
+ {
+ testSimplePrimitiveField(createField(getClazz(), "doubleField"), Double.valueOf(2));
+ }
+
+ public void testFloatField() throws Throwable
+ {
+ testSimplePrimitiveField(createField(getClazz(), "floatField"), Float.valueOf(3));
+ }
+
+ public void testIntField() throws Throwable
+ {
+ testSimplePrimitiveField(createField(getClazz(), "intField"), Integer.valueOf(4));
+ }
+
+ public void testShortField() throws Throwable
+ {
+ testSimplePrimitiveField(createField(getClazz(), "shortField"), Short.valueOf((short)5));
+ }
+
+ protected void testSimplePrimitiveField(JavassistField field, Object goodParam) throws Throwable
+ {
+ Object target = createInstance();
+ if (isPrimitive)
+ checkWrongParameter(field, target, null);
+ else
+ {
+ field.set(target, null);
+ assertNull(field.get(target));
+ }
+ checkWrongParameter(field, target, "Not a primitive");
+
+ field.set(target, goodParam);
+ if (goodParam instanceof Double || goodParam instanceof Float)
+ assertEquals(goodParam, field.get(target));
+ else
+ assertSame(goodParam, field.get(target));
+ }
+
+ public void checkWrongParameters(JavassistMethod m, Object bean, Object[] params) throws Throwable
+ {
+ try
+ {
+ m.invoke(bean, new Object[] {new Object()});
+ fail("Should have picked up too many parameters");
+ }
+ catch (Exception expected)
+ {
+ }
+ }
+
+ public void checkWrongParameter(JavassistField f, Object bean, Object param) throws Throwable
+ {
+ try
+ {
+ f.set(bean, param);
+ fail("Should have picked up too many parameters");
+ }
+ catch (Exception expected)
+ {
+ }
+ }
+
+ protected CtClass getCtClass(Class<?> clazz) throws Exception
+ {
+ if (isPrimitive)
+ {
+ if (clazz == Boolean.class)
+ clazz = Boolean.TYPE;
+ else if (clazz == Byte.class)
+ clazz = Byte.TYPE;
+ else if (clazz == Character.class)
+ clazz = Character.TYPE;
+ else if (clazz == Double.class)
+ clazz = Double.TYPE;
+ else if (clazz == Float.class)
+ clazz = Float.TYPE;
+ else if (clazz == Integer.class)
+ clazz = Integer.TYPE;
+ else if (clazz == Long.class)
+ clazz = Long.TYPE;
+ else if (clazz == Short.class)
+ clazz = Short.TYPE;
+ }
+ return ClassPool.getDefault().getCtClass(clazz.getName());
+ }
+
+ protected CtClass[] getCtClasses(Class<?>...classes) throws Exception
+ {
+ CtClass[] ctClasses = new CtClass[classes.length];
+
+ for (int i = 0 ; i < classes.length ; i++)
+ {
+ ctClasses[i] = getCtClass(classes[i]);
+ }
+ return ctClasses;
+ }
+
+ protected CtConstructor getCtConstructor(Class<?> clazz, Class<?>...params) throws Exception
+ {
+ CtClass ct = getCtClass(clazz);
+ CtClass[] ctParams = getCtClasses(params);
+ for (CtConstructor ctor : ct.getConstructors())
+ {
+ if (Arrays.equals(ctParams, ctor.getParameterTypes()))
+ return ctor;
+ }
+ fail("No constructor found");
+ return null;
+ }
+
+ protected CtMethod getCtMethod(Class<?> clazz, String name, Class<?>...params) throws Exception
+ {
+ CtClass ct = getCtClass(clazz);
+ CtClass[] ctParams = getCtClasses(params);
+ return ct.getDeclaredMethod(name, ctParams);
+ }
+
+ protected CtField getCtField(Class<?> clazz, String name) throws Exception
+ {
+ CtClass ct = getCtClass(clazz);
+ return ct.getDeclaredField(name);
+ }
+
+ protected JavassistConstructor createConstructor(Class<?> clazz, Class<?>...params) throws Exception
+ {
+ return JavassistMemberFactory.createJavassistConstructor(MAGIC_ACCESSOR_IMPL, getCtConstructor(clazz, params), CHECK, DEBUG);
+ }
+
+ protected JavassistMethod createMethod(Class<?> clazz, String name, Class<?>...params) throws Exception
+ {
+ return JavassistMemberFactory.createJavassistMethod(MAGIC_ACCESSOR_IMPL, getCtMethod(clazz, name, params), CHECK, DEBUG);
+ }
+
+ protected JavassistField createField(Class<?> clazz, String name) throws Exception
+ {
+ return JavassistMemberFactory.createJavassistField(MAGIC_ACCESSOR_IMPL, getCtField(clazz, name), CHECK, DEBUG);
+ }
+
+ protected abstract Class<?> getClazz();
+
+ protected abstract Object createInstance();
+}
Added: projects/jboss-reflect/trunk/src/test/java/org/jboss/test/plugins/javassist/bytecode/test/JavassistMemberFactoryPackageProtectedBoxedUnitTestCase.java
===================================================================
--- projects/jboss-reflect/trunk/src/test/java/org/jboss/test/plugins/javassist/bytecode/test/JavassistMemberFactoryPackageProtectedBoxedUnitTestCase.java (rev 0)
+++ projects/jboss-reflect/trunk/src/test/java/org/jboss/test/plugins/javassist/bytecode/test/JavassistMemberFactoryPackageProtectedBoxedUnitTestCase.java 2010-03-24 16:48:26 UTC (rev 102910)
@@ -0,0 +1,60 @@
+/*
+* JBoss, Home of Professional Open Source.
+* Copyright 2006, Red Hat Middleware LLC, and individual contributors
+* as indicated by the @author tags. See the copyright.txt file in the
+* distribution for a full listing of individual contributors.
+*
+* This is free software; you can redistribute it and/or modify it
+* under the terms of the GNU Lesser General Public License as
+* published by the Free Software Foundation; either version 2.1 of
+* the License, or (at your option) any later version.
+*
+* This software is distributed in the hope that it will be useful,
+* but WITHOUT ANY WARRANTY; without even the implied warranty of
+* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+* Lesser General Public License for more details.
+*
+* You should have received a copy of the GNU Lesser General Public
+* License along with this software; if not, write to the Free
+* Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+* 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+*/
+package org.jboss.test.plugins.javassist.bytecode.test;
+
+import junit.framework.Test;
+
+import org.jboss.test.plugins.javassist.bytecode.support.ProtectedBoxedBean;
+
+
+
+/**
+ *
+ * @author <a href="kabir.khan at jboss.com">Kabir Khan</a>
+ * @version $Revision: 1.1 $
+ */
+public class JavassistMemberFactoryPackageProtectedBoxedUnitTestCase extends AbstractJavassistMemberAndConstructorFactoryTest
+{
+ public static Test suite()
+ {
+ return suite(JavassistMemberFactoryPackageProtectedBoxedUnitTestCase.class);
+ }
+
+ public JavassistMemberFactoryPackageProtectedBoxedUnitTestCase(String name)
+ {
+ super(name, false);
+ }
+
+ @Override
+ protected Object createInstance()
+ {
+ return ProtectedBoxedBean.getInstance();
+ }
+
+ @Override
+ protected Class<?> getClazz()
+ {
+ return ProtectedBoxedBean.class;
+ }
+
+
+}
Added: projects/jboss-reflect/trunk/src/test/java/org/jboss/test/plugins/javassist/bytecode/test/JavassistMemberFactoryPackageProtectedPrimitiveUnitTestCase.java
===================================================================
--- projects/jboss-reflect/trunk/src/test/java/org/jboss/test/plugins/javassist/bytecode/test/JavassistMemberFactoryPackageProtectedPrimitiveUnitTestCase.java (rev 0)
+++ projects/jboss-reflect/trunk/src/test/java/org/jboss/test/plugins/javassist/bytecode/test/JavassistMemberFactoryPackageProtectedPrimitiveUnitTestCase.java 2010-03-24 16:48:26 UTC (rev 102910)
@@ -0,0 +1,60 @@
+/*
+* JBoss, Home of Professional Open Source.
+* Copyright 2006, Red Hat Middleware LLC, and individual contributors
+* as indicated by the @author tags. See the copyright.txt file in the
+* distribution for a full listing of individual contributors.
+*
+* This is free software; you can redistribute it and/or modify it
+* under the terms of the GNU Lesser General Public License as
+* published by the Free Software Foundation; either version 2.1 of
+* the License, or (at your option) any later version.
+*
+* This software is distributed in the hope that it will be useful,
+* but WITHOUT ANY WARRANTY; without even the implied warranty of
+* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+* Lesser General Public License for more details.
+*
+* You should have received a copy of the GNU Lesser General Public
+* License along with this software; if not, write to the Free
+* Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+* 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+*/
+package org.jboss.test.plugins.javassist.bytecode.test;
+
+import junit.framework.Test;
+
+import org.jboss.test.plugins.javassist.bytecode.support.PackageProtectedPrimitiveBean;
+
+
+
+/**
+ *
+ * @author <a href="kabir.khan at jboss.com">Kabir Khan</a>
+ * @version $Revision: 1.1 $
+ */
+public class JavassistMemberFactoryPackageProtectedPrimitiveUnitTestCase extends AbstractJavassistMemberAndConstructorFactoryTest
+{
+ public static Test suite()
+ {
+ return suite(JavassistMemberFactoryPackageProtectedPrimitiveUnitTestCase.class);
+ }
+
+ public JavassistMemberFactoryPackageProtectedPrimitiveUnitTestCase(String name)
+ {
+ super(name, true);
+ }
+
+ @Override
+ protected Object createInstance()
+ {
+ return PackageProtectedPrimitiveBean.getInstance();
+ }
+
+ @Override
+ protected Class<?> getClazz()
+ {
+ return PackageProtectedPrimitiveBean.class;
+ }
+
+
+}
Added: projects/jboss-reflect/trunk/src/test/java/org/jboss/test/plugins/javassist/bytecode/test/JavassistMemberFactoryPackageProtectedStaticBoxedUnitTestCase.java
===================================================================
--- projects/jboss-reflect/trunk/src/test/java/org/jboss/test/plugins/javassist/bytecode/test/JavassistMemberFactoryPackageProtectedStaticBoxedUnitTestCase.java (rev 0)
+++ projects/jboss-reflect/trunk/src/test/java/org/jboss/test/plugins/javassist/bytecode/test/JavassistMemberFactoryPackageProtectedStaticBoxedUnitTestCase.java 2010-03-24 16:48:26 UTC (rev 102910)
@@ -0,0 +1,60 @@
+/*
+* JBoss, Home of Professional Open Source.
+* Copyright 2006, Red Hat Middleware LLC, and individual contributors
+* as indicated by the @author tags. See the copyright.txt file in the
+* distribution for a full listing of individual contributors.
+*
+* This is free software; you can redistribute it and/or modify it
+* under the terms of the GNU Lesser General Public License as
+* published by the Free Software Foundation; either version 2.1 of
+* the License, or (at your option) any later version.
+*
+* This software is distributed in the hope that it will be useful,
+* but WITHOUT ANY WARRANTY; without even the implied warranty of
+* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+* Lesser General Public License for more details.
+*
+* You should have received a copy of the GNU Lesser General Public
+* License along with this software; if not, write to the Free
+* Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+* 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+*/
+package org.jboss.test.plugins.javassist.bytecode.test;
+
+import junit.framework.Test;
+
+import org.jboss.test.plugins.javassist.bytecode.support.PackageProtectedStaticBoxedBean;
+
+
+
+/**
+ *
+ * @author <a href="kabir.khan at jboss.com">Kabir Khan</a>
+ * @version $Revision: 1.1 $
+ */
+public class JavassistMemberFactoryPackageProtectedStaticBoxedUnitTestCase extends AbstractJavassistMemberFactoryTest
+{
+ public static Test suite()
+ {
+ return suite(JavassistMemberFactoryPackageProtectedStaticBoxedUnitTestCase.class);
+ }
+
+ public JavassistMemberFactoryPackageProtectedStaticBoxedUnitTestCase(String name)
+ {
+ super(name, false);
+ }
+
+ @Override
+ protected Class<?> getClazz()
+ {
+ return PackageProtectedStaticBoxedBean.class;
+ }
+
+ @Override
+ protected Object createInstance()
+ {
+ return new PackageProtectedStaticBoxedBean();
+ }
+
+
+}
Added: projects/jboss-reflect/trunk/src/test/java/org/jboss/test/plugins/javassist/bytecode/test/JavassistMemberFactoryPackageProtectedStaticPrimitiveUnitTestCase.java
===================================================================
--- projects/jboss-reflect/trunk/src/test/java/org/jboss/test/plugins/javassist/bytecode/test/JavassistMemberFactoryPackageProtectedStaticPrimitiveUnitTestCase.java (rev 0)
+++ projects/jboss-reflect/trunk/src/test/java/org/jboss/test/plugins/javassist/bytecode/test/JavassistMemberFactoryPackageProtectedStaticPrimitiveUnitTestCase.java 2010-03-24 16:48:26 UTC (rev 102910)
@@ -0,0 +1,60 @@
+/*
+* JBoss, Home of Professional Open Source.
+* Copyright 2006, Red Hat Middleware LLC, and individual contributors
+* as indicated by the @author tags. See the copyright.txt file in the
+* distribution for a full listing of individual contributors.
+*
+* This is free software; you can redistribute it and/or modify it
+* under the terms of the GNU Lesser General Public License as
+* published by the Free Software Foundation; either version 2.1 of
+* the License, or (at your option) any later version.
+*
+* This software is distributed in the hope that it will be useful,
+* but WITHOUT ANY WARRANTY; without even the implied warranty of
+* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+* Lesser General Public License for more details.
+*
+* You should have received a copy of the GNU Lesser General Public
+* License along with this software; if not, write to the Free
+* Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+* 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+*/
+package org.jboss.test.plugins.javassist.bytecode.test;
+
+import junit.framework.Test;
+
+import org.jboss.test.plugins.javassist.bytecode.support.PackageProtectedStaticPrimitiveBean;
+
+
+
+/**
+ *
+ * @author <a href="kabir.khan at jboss.com">Kabir Khan</a>
+ * @version $Revision: 1.1 $
+ */
+public class JavassistMemberFactoryPackageProtectedStaticPrimitiveUnitTestCase extends AbstractJavassistMemberFactoryTest
+{
+ public static Test suite()
+ {
+ return suite(JavassistMemberFactoryPackageProtectedStaticPrimitiveUnitTestCase.class);
+ }
+
+ public JavassistMemberFactoryPackageProtectedStaticPrimitiveUnitTestCase(String name)
+ {
+ super(name, true);
+ }
+
+ @Override
+ protected Class<?> getClazz()
+ {
+ return PackageProtectedStaticPrimitiveBean.class;
+ }
+
+ @Override
+ protected Object createInstance()
+ {
+ return new PackageProtectedStaticPrimitiveBean();
+ }
+
+
+}
Added: projects/jboss-reflect/trunk/src/test/java/org/jboss/test/plugins/javassist/bytecode/test/JavassistMemberFactoryPrivateBoxedUnitTestCase.java
===================================================================
--- projects/jboss-reflect/trunk/src/test/java/org/jboss/test/plugins/javassist/bytecode/test/JavassistMemberFactoryPrivateBoxedUnitTestCase.java (rev 0)
+++ projects/jboss-reflect/trunk/src/test/java/org/jboss/test/plugins/javassist/bytecode/test/JavassistMemberFactoryPrivateBoxedUnitTestCase.java 2010-03-24 16:48:26 UTC (rev 102910)
@@ -0,0 +1,60 @@
+/*
+* JBoss, Home of Professional Open Source.
+* Copyright 2006, Red Hat Middleware LLC, and individual contributors
+* as indicated by the @author tags. See the copyright.txt file in the
+* distribution for a full listing of individual contributors.
+*
+* This is free software; you can redistribute it and/or modify it
+* under the terms of the GNU Lesser General Public License as
+* published by the Free Software Foundation; either version 2.1 of
+* the License, or (at your option) any later version.
+*
+* This software is distributed in the hope that it will be useful,
+* but WITHOUT ANY WARRANTY; without even the implied warranty of
+* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+* Lesser General Public License for more details.
+*
+* You should have received a copy of the GNU Lesser General Public
+* License along with this software; if not, write to the Free
+* Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+* 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+*/
+package org.jboss.test.plugins.javassist.bytecode.test;
+
+import junit.framework.Test;
+
+import org.jboss.test.plugins.javassist.bytecode.support.ProtectedBoxedBean;
+
+
+
+/**
+ *
+ * @author <a href="kabir.khan at jboss.com">Kabir Khan</a>
+ * @version $Revision: 1.1 $
+ */
+public class JavassistMemberFactoryPrivateBoxedUnitTestCase extends AbstractJavassistMemberAndConstructorFactoryTest
+{
+ public static Test suite()
+ {
+ return suite(JavassistMemberFactoryPrivateBoxedUnitTestCase.class);
+ }
+
+ public JavassistMemberFactoryPrivateBoxedUnitTestCase(String name)
+ {
+ super(name, false);
+ }
+
+ @Override
+ protected Object createInstance()
+ {
+ return ProtectedBoxedBean.getInstance();
+ }
+
+ @Override
+ protected Class<?> getClazz()
+ {
+ return ProtectedBoxedBean.class;
+ }
+
+
+}
Added: projects/jboss-reflect/trunk/src/test/java/org/jboss/test/plugins/javassist/bytecode/test/JavassistMemberFactoryPrivatePrimitiveUnitTestCase.java
===================================================================
--- projects/jboss-reflect/trunk/src/test/java/org/jboss/test/plugins/javassist/bytecode/test/JavassistMemberFactoryPrivatePrimitiveUnitTestCase.java (rev 0)
+++ projects/jboss-reflect/trunk/src/test/java/org/jboss/test/plugins/javassist/bytecode/test/JavassistMemberFactoryPrivatePrimitiveUnitTestCase.java 2010-03-24 16:48:26 UTC (rev 102910)
@@ -0,0 +1,60 @@
+/*
+* JBoss, Home of Professional Open Source.
+* Copyright 2006, Red Hat Middleware LLC, and individual contributors
+* as indicated by the @author tags. See the copyright.txt file in the
+* distribution for a full listing of individual contributors.
+*
+* This is free software; you can redistribute it and/or modify it
+* under the terms of the GNU Lesser General Public License as
+* published by the Free Software Foundation; either version 2.1 of
+* the License, or (at your option) any later version.
+*
+* This software is distributed in the hope that it will be useful,
+* but WITHOUT ANY WARRANTY; without even the implied warranty of
+* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+* Lesser General Public License for more details.
+*
+* You should have received a copy of the GNU Lesser General Public
+* License along with this software; if not, write to the Free
+* Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+* 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+*/
+package org.jboss.test.plugins.javassist.bytecode.test;
+
+import junit.framework.Test;
+
+import org.jboss.test.plugins.javassist.bytecode.support.ProtectedPrimitiveBean;
+
+
+
+/**
+ *
+ * @author <a href="kabir.khan at jboss.com">Kabir Khan</a>
+ * @version $Revision: 1.1 $
+ */
+public class JavassistMemberFactoryPrivatePrimitiveUnitTestCase extends AbstractJavassistMemberAndConstructorFactoryTest
+{
+ public static Test suite()
+ {
+ return suite(JavassistMemberFactoryPrivatePrimitiveUnitTestCase.class);
+ }
+
+ public JavassistMemberFactoryPrivatePrimitiveUnitTestCase(String name)
+ {
+ super(name, true);
+ }
+
+ @Override
+ protected Object createInstance()
+ {
+ return ProtectedPrimitiveBean.getInstance();
+ }
+
+ @Override
+ protected Class<?> getClazz()
+ {
+ return ProtectedPrimitiveBean.class;
+ }
+
+
+}
Added: projects/jboss-reflect/trunk/src/test/java/org/jboss/test/plugins/javassist/bytecode/test/JavassistMemberFactoryPrivateStaticBoxedUnitTestCase.java
===================================================================
--- projects/jboss-reflect/trunk/src/test/java/org/jboss/test/plugins/javassist/bytecode/test/JavassistMemberFactoryPrivateStaticBoxedUnitTestCase.java (rev 0)
+++ projects/jboss-reflect/trunk/src/test/java/org/jboss/test/plugins/javassist/bytecode/test/JavassistMemberFactoryPrivateStaticBoxedUnitTestCase.java 2010-03-24 16:48:26 UTC (rev 102910)
@@ -0,0 +1,60 @@
+/*
+* JBoss, Home of Professional Open Source.
+* Copyright 2006, Red Hat Middleware LLC, and individual contributors
+* as indicated by the @author tags. See the copyright.txt file in the
+* distribution for a full listing of individual contributors.
+*
+* This is free software; you can redistribute it and/or modify it
+* under the terms of the GNU Lesser General Public License as
+* published by the Free Software Foundation; either version 2.1 of
+* the License, or (at your option) any later version.
+*
+* This software is distributed in the hope that it will be useful,
+* but WITHOUT ANY WARRANTY; without even the implied warranty of
+* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+* Lesser General Public License for more details.
+*
+* You should have received a copy of the GNU Lesser General Public
+* License along with this software; if not, write to the Free
+* Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+* 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+*/
+package org.jboss.test.plugins.javassist.bytecode.test;
+
+import junit.framework.Test;
+
+import org.jboss.test.plugins.javassist.bytecode.support.ProtectedStaticBoxedBean;
+
+
+
+/**
+ *
+ * @author <a href="kabir.khan at jboss.com">Kabir Khan</a>
+ * @version $Revision: 1.1 $
+ */
+public class JavassistMemberFactoryPrivateStaticBoxedUnitTestCase extends AbstractJavassistMemberFactoryTest
+{
+ public static Test suite()
+ {
+ return suite(JavassistMemberFactoryPrivateStaticBoxedUnitTestCase.class);
+ }
+
+ public JavassistMemberFactoryPrivateStaticBoxedUnitTestCase(String name)
+ {
+ super(name, false);
+ }
+
+ @Override
+ protected Class<?> getClazz()
+ {
+ return ProtectedStaticBoxedBean.class;
+ }
+
+ @Override
+ protected Object createInstance()
+ {
+ return new ProtectedStaticBoxedBean();
+ }
+
+
+}
Added: projects/jboss-reflect/trunk/src/test/java/org/jboss/test/plugins/javassist/bytecode/test/JavassistMemberFactoryPrivateStaticPrimitiveUnitTestCase.java
===================================================================
--- projects/jboss-reflect/trunk/src/test/java/org/jboss/test/plugins/javassist/bytecode/test/JavassistMemberFactoryPrivateStaticPrimitiveUnitTestCase.java (rev 0)
+++ projects/jboss-reflect/trunk/src/test/java/org/jboss/test/plugins/javassist/bytecode/test/JavassistMemberFactoryPrivateStaticPrimitiveUnitTestCase.java 2010-03-24 16:48:26 UTC (rev 102910)
@@ -0,0 +1,60 @@
+/*
+* JBoss, Home of Professional Open Source.
+* Copyright 2006, Red Hat Middleware LLC, and individual contributors
+* as indicated by the @author tags. See the copyright.txt file in the
+* distribution for a full listing of individual contributors.
+*
+* This is free software; you can redistribute it and/or modify it
+* under the terms of the GNU Lesser General Public License as
+* published by the Free Software Foundation; either version 2.1 of
+* the License, or (at your option) any later version.
+*
+* This software is distributed in the hope that it will be useful,
+* but WITHOUT ANY WARRANTY; without even the implied warranty of
+* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+* Lesser General Public License for more details.
+*
+* You should have received a copy of the GNU Lesser General Public
+* License along with this software; if not, write to the Free
+* Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+* 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+*/
+package org.jboss.test.plugins.javassist.bytecode.test;
+
+import junit.framework.Test;
+
+import org.jboss.test.plugins.javassist.bytecode.support.ProtectedStaticPrimitiveBean;
+
+
+
+/**
+ *
+ * @author <a href="kabir.khan at jboss.com">Kabir Khan</a>
+ * @version $Revision: 1.1 $
+ */
+public class JavassistMemberFactoryPrivateStaticPrimitiveUnitTestCase extends AbstractJavassistMemberFactoryTest
+{
+ public static Test suite()
+ {
+ return suite(JavassistMemberFactoryPrivateStaticPrimitiveUnitTestCase.class);
+ }
+
+ public JavassistMemberFactoryPrivateStaticPrimitiveUnitTestCase(String name)
+ {
+ super(name, true);
+ }
+
+ @Override
+ protected Class<?> getClazz()
+ {
+ return ProtectedStaticPrimitiveBean.class;
+ }
+
+ @Override
+ protected Object createInstance()
+ {
+ return new ProtectedStaticPrimitiveBean();
+ }
+
+
+}
Added: projects/jboss-reflect/trunk/src/test/java/org/jboss/test/plugins/javassist/bytecode/test/JavassistMemberFactoryProtectedBoxedUnitTestCase.java
===================================================================
--- projects/jboss-reflect/trunk/src/test/java/org/jboss/test/plugins/javassist/bytecode/test/JavassistMemberFactoryProtectedBoxedUnitTestCase.java (rev 0)
+++ projects/jboss-reflect/trunk/src/test/java/org/jboss/test/plugins/javassist/bytecode/test/JavassistMemberFactoryProtectedBoxedUnitTestCase.java 2010-03-24 16:48:26 UTC (rev 102910)
@@ -0,0 +1,60 @@
+/*
+* JBoss, Home of Professional Open Source.
+* Copyright 2006, Red Hat Middleware LLC, and individual contributors
+* as indicated by the @author tags. See the copyright.txt file in the
+* distribution for a full listing of individual contributors.
+*
+* This is free software; you can redistribute it and/or modify it
+* under the terms of the GNU Lesser General Public License as
+* published by the Free Software Foundation; either version 2.1 of
+* the License, or (at your option) any later version.
+*
+* This software is distributed in the hope that it will be useful,
+* but WITHOUT ANY WARRANTY; without even the implied warranty of
+* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+* Lesser General Public License for more details.
+*
+* You should have received a copy of the GNU Lesser General Public
+* License along with this software; if not, write to the Free
+* Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+* 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+*/
+package org.jboss.test.plugins.javassist.bytecode.test;
+
+import junit.framework.Test;
+
+import org.jboss.test.plugins.javassist.bytecode.support.ProtectedBoxedBean;
+
+
+
+/**
+ *
+ * @author <a href="kabir.khan at jboss.com">Kabir Khan</a>
+ * @version $Revision: 1.1 $
+ */
+public class JavassistMemberFactoryProtectedBoxedUnitTestCase extends AbstractJavassistMemberAndConstructorFactoryTest
+{
+ public static Test suite()
+ {
+ return suite(JavassistMemberFactoryProtectedBoxedUnitTestCase.class);
+ }
+
+ public JavassistMemberFactoryProtectedBoxedUnitTestCase(String name)
+ {
+ super(name, false);
+ }
+
+ @Override
+ protected Object createInstance()
+ {
+ return ProtectedBoxedBean.getInstance();
+ }
+
+ @Override
+ protected Class<?> getClazz()
+ {
+ return ProtectedBoxedBean.class;
+ }
+
+
+}
Added: projects/jboss-reflect/trunk/src/test/java/org/jboss/test/plugins/javassist/bytecode/test/JavassistMemberFactoryProtectedPrimitiveUnitTestCase.java
===================================================================
--- projects/jboss-reflect/trunk/src/test/java/org/jboss/test/plugins/javassist/bytecode/test/JavassistMemberFactoryProtectedPrimitiveUnitTestCase.java (rev 0)
+++ projects/jboss-reflect/trunk/src/test/java/org/jboss/test/plugins/javassist/bytecode/test/JavassistMemberFactoryProtectedPrimitiveUnitTestCase.java 2010-03-24 16:48:26 UTC (rev 102910)
@@ -0,0 +1,60 @@
+/*
+* JBoss, Home of Professional Open Source.
+* Copyright 2006, Red Hat Middleware LLC, and individual contributors
+* as indicated by the @author tags. See the copyright.txt file in the
+* distribution for a full listing of individual contributors.
+*
+* This is free software; you can redistribute it and/or modify it
+* under the terms of the GNU Lesser General Public License as
+* published by the Free Software Foundation; either version 2.1 of
+* the License, or (at your option) any later version.
+*
+* This software is distributed in the hope that it will be useful,
+* but WITHOUT ANY WARRANTY; without even the implied warranty of
+* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+* Lesser General Public License for more details.
+*
+* You should have received a copy of the GNU Lesser General Public
+* License along with this software; if not, write to the Free
+* Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+* 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+*/
+package org.jboss.test.plugins.javassist.bytecode.test;
+
+import junit.framework.Test;
+
+import org.jboss.test.plugins.javassist.bytecode.support.ProtectedPrimitiveBean;
+
+
+
+/**
+ *
+ * @author <a href="kabir.khan at jboss.com">Kabir Khan</a>
+ * @version $Revision: 1.1 $
+ */
+public class JavassistMemberFactoryProtectedPrimitiveUnitTestCase extends AbstractJavassistMemberAndConstructorFactoryTest
+{
+ public static Test suite()
+ {
+ return suite(JavassistMemberFactoryProtectedPrimitiveUnitTestCase.class);
+ }
+
+ public JavassistMemberFactoryProtectedPrimitiveUnitTestCase(String name)
+ {
+ super(name, true);
+ }
+
+ @Override
+ protected Object createInstance()
+ {
+ return ProtectedPrimitiveBean.getInstance();
+ }
+
+ @Override
+ protected Class<?> getClazz()
+ {
+ return ProtectedPrimitiveBean.class;
+ }
+
+
+}
Added: projects/jboss-reflect/trunk/src/test/java/org/jboss/test/plugins/javassist/bytecode/test/JavassistMemberFactoryProtectedStaticBoxedUnitTestCase.java
===================================================================
--- projects/jboss-reflect/trunk/src/test/java/org/jboss/test/plugins/javassist/bytecode/test/JavassistMemberFactoryProtectedStaticBoxedUnitTestCase.java (rev 0)
+++ projects/jboss-reflect/trunk/src/test/java/org/jboss/test/plugins/javassist/bytecode/test/JavassistMemberFactoryProtectedStaticBoxedUnitTestCase.java 2010-03-24 16:48:26 UTC (rev 102910)
@@ -0,0 +1,60 @@
+/*
+* JBoss, Home of Professional Open Source.
+* Copyright 2006, Red Hat Middleware LLC, and individual contributors
+* as indicated by the @author tags. See the copyright.txt file in the
+* distribution for a full listing of individual contributors.
+*
+* This is free software; you can redistribute it and/or modify it
+* under the terms of the GNU Lesser General Public License as
+* published by the Free Software Foundation; either version 2.1 of
+* the License, or (at your option) any later version.
+*
+* This software is distributed in the hope that it will be useful,
+* but WITHOUT ANY WARRANTY; without even the implied warranty of
+* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+* Lesser General Public License for more details.
+*
+* You should have received a copy of the GNU Lesser General Public
+* License along with this software; if not, write to the Free
+* Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+* 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+*/
+package org.jboss.test.plugins.javassist.bytecode.test;
+
+import junit.framework.Test;
+
+import org.jboss.test.plugins.javassist.bytecode.support.ProtectedStaticBoxedBean;
+
+
+
+/**
+ *
+ * @author <a href="kabir.khan at jboss.com">Kabir Khan</a>
+ * @version $Revision: 1.1 $
+ */
+public class JavassistMemberFactoryProtectedStaticBoxedUnitTestCase extends AbstractJavassistMemberFactoryTest
+{
+ public static Test suite()
+ {
+ return suite(JavassistMemberFactoryProtectedStaticBoxedUnitTestCase.class);
+ }
+
+ public JavassistMemberFactoryProtectedStaticBoxedUnitTestCase(String name)
+ {
+ super(name, false);
+ }
+
+ @Override
+ protected Class<?> getClazz()
+ {
+ return ProtectedStaticBoxedBean.class;
+ }
+
+ @Override
+ protected Object createInstance()
+ {
+ return new ProtectedStaticBoxedBean();
+ }
+
+
+}
Added: projects/jboss-reflect/trunk/src/test/java/org/jboss/test/plugins/javassist/bytecode/test/JavassistMemberFactoryProtectedStaticPrimitiveUnitTestCase.java
===================================================================
--- projects/jboss-reflect/trunk/src/test/java/org/jboss/test/plugins/javassist/bytecode/test/JavassistMemberFactoryProtectedStaticPrimitiveUnitTestCase.java (rev 0)
+++ projects/jboss-reflect/trunk/src/test/java/org/jboss/test/plugins/javassist/bytecode/test/JavassistMemberFactoryProtectedStaticPrimitiveUnitTestCase.java 2010-03-24 16:48:26 UTC (rev 102910)
@@ -0,0 +1,60 @@
+/*
+* JBoss, Home of Professional Open Source.
+* Copyright 2006, Red Hat Middleware LLC, and individual contributors
+* as indicated by the @author tags. See the copyright.txt file in the
+* distribution for a full listing of individual contributors.
+*
+* This is free software; you can redistribute it and/or modify it
+* under the terms of the GNU Lesser General Public License as
+* published by the Free Software Foundation; either version 2.1 of
+* the License, or (at your option) any later version.
+*
+* This software is distributed in the hope that it will be useful,
+* but WITHOUT ANY WARRANTY; without even the implied warranty of
+* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+* Lesser General Public License for more details.
+*
+* You should have received a copy of the GNU Lesser General Public
+* License along with this software; if not, write to the Free
+* Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+* 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+*/
+package org.jboss.test.plugins.javassist.bytecode.test;
+
+import junit.framework.Test;
+
+import org.jboss.test.plugins.javassist.bytecode.support.ProtectedStaticPrimitiveBean;
+
+
+
+/**
+ *
+ * @author <a href="kabir.khan at jboss.com">Kabir Khan</a>
+ * @version $Revision: 1.1 $
+ */
+public class JavassistMemberFactoryProtectedStaticPrimitiveUnitTestCase extends AbstractJavassistMemberFactoryTest
+{
+ public static Test suite()
+ {
+ return suite(JavassistMemberFactoryProtectedStaticPrimitiveUnitTestCase.class);
+ }
+
+ public JavassistMemberFactoryProtectedStaticPrimitiveUnitTestCase(String name)
+ {
+ super(name, true);
+ }
+
+ @Override
+ protected Class<?> getClazz()
+ {
+ return ProtectedStaticPrimitiveBean.class;
+ }
+
+ @Override
+ protected Object createInstance()
+ {
+ return new ProtectedStaticPrimitiveBean();
+ }
+
+
+}
Added: projects/jboss-reflect/trunk/src/test/java/org/jboss/test/plugins/javassist/bytecode/test/JavassistMemberFactoryPublicBoxedUnitTestCase.java
===================================================================
--- projects/jboss-reflect/trunk/src/test/java/org/jboss/test/plugins/javassist/bytecode/test/JavassistMemberFactoryPublicBoxedUnitTestCase.java (rev 0)
+++ projects/jboss-reflect/trunk/src/test/java/org/jboss/test/plugins/javassist/bytecode/test/JavassistMemberFactoryPublicBoxedUnitTestCase.java 2010-03-24 16:48:26 UTC (rev 102910)
@@ -0,0 +1,60 @@
+/*
+* JBoss, Home of Professional Open Source.
+* Copyright 2006, Red Hat Middleware LLC, and individual contributors
+* as indicated by the @author tags. See the copyright.txt file in the
+* distribution for a full listing of individual contributors.
+*
+* This is free software; you can redistribute it and/or modify it
+* under the terms of the GNU Lesser General Public License as
+* published by the Free Software Foundation; either version 2.1 of
+* the License, or (at your option) any later version.
+*
+* This software is distributed in the hope that it will be useful,
+* but WITHOUT ANY WARRANTY; without even the implied warranty of
+* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+* Lesser General Public License for more details.
+*
+* You should have received a copy of the GNU Lesser General Public
+* License along with this software; if not, write to the Free
+* Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+* 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+*/
+package org.jboss.test.plugins.javassist.bytecode.test;
+
+import junit.framework.Test;
+
+import org.jboss.test.plugins.javassist.bytecode.support.PublicBoxedBean;
+
+
+
+/**
+ *
+ * @author <a href="kabir.khan at jboss.com">Kabir Khan</a>
+ * @version $Revision: 1.1 $
+ */
+public class JavassistMemberFactoryPublicBoxedUnitTestCase extends AbstractJavassistMemberAndConstructorFactoryTest
+{
+ public static Test suite()
+ {
+ return suite(JavassistMemberFactoryPublicBoxedUnitTestCase.class);
+ }
+
+ public JavassistMemberFactoryPublicBoxedUnitTestCase(String name)
+ {
+ super(name, false);
+ }
+
+ @Override
+ protected Object createInstance()
+ {
+ return new PublicBoxedBean();
+ }
+
+ @Override
+ protected Class<?> getClazz()
+ {
+ return PublicBoxedBean.class;
+ }
+
+
+}
Added: projects/jboss-reflect/trunk/src/test/java/org/jboss/test/plugins/javassist/bytecode/test/JavassistMemberFactoryPublicPrimitiveUnitTestCase.java
===================================================================
--- projects/jboss-reflect/trunk/src/test/java/org/jboss/test/plugins/javassist/bytecode/test/JavassistMemberFactoryPublicPrimitiveUnitTestCase.java (rev 0)
+++ projects/jboss-reflect/trunk/src/test/java/org/jboss/test/plugins/javassist/bytecode/test/JavassistMemberFactoryPublicPrimitiveUnitTestCase.java 2010-03-24 16:48:26 UTC (rev 102910)
@@ -0,0 +1,60 @@
+/*
+* JBoss, Home of Professional Open Source.
+* Copyright 2006, Red Hat Middleware LLC, and individual contributors
+* as indicated by the @author tags. See the copyright.txt file in the
+* distribution for a full listing of individual contributors.
+*
+* This is free software; you can redistribute it and/or modify it
+* under the terms of the GNU Lesser General Public License as
+* published by the Free Software Foundation; either version 2.1 of
+* the License, or (at your option) any later version.
+*
+* This software is distributed in the hope that it will be useful,
+* but WITHOUT ANY WARRANTY; without even the implied warranty of
+* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+* Lesser General Public License for more details.
+*
+* You should have received a copy of the GNU Lesser General Public
+* License along with this software; if not, write to the Free
+* Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+* 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+*/
+package org.jboss.test.plugins.javassist.bytecode.test;
+
+import junit.framework.Test;
+
+import org.jboss.test.plugins.javassist.bytecode.support.PublicPrimitiveBean;
+
+
+
+/**
+ *
+ * @author <a href="kabir.khan at jboss.com">Kabir Khan</a>
+ * @version $Revision: 1.1 $
+ */
+public class JavassistMemberFactoryPublicPrimitiveUnitTestCase extends AbstractJavassistMemberAndConstructorFactoryTest
+{
+ public static Test suite()
+ {
+ return suite(JavassistMemberFactoryPublicPrimitiveUnitTestCase.class);
+ }
+
+ public JavassistMemberFactoryPublicPrimitiveUnitTestCase(String name)
+ {
+ super(name, true);
+ }
+
+ @Override
+ protected Object createInstance()
+ {
+ return new PublicPrimitiveBean();
+ }
+
+ @Override
+ protected Class<?> getClazz()
+ {
+ return PublicPrimitiveBean.class;
+ }
+
+
+}
Added: projects/jboss-reflect/trunk/src/test/java/org/jboss/test/plugins/javassist/bytecode/test/JavassistMemberFactoryPublicStaticBoxedUnitTestCase.java
===================================================================
--- projects/jboss-reflect/trunk/src/test/java/org/jboss/test/plugins/javassist/bytecode/test/JavassistMemberFactoryPublicStaticBoxedUnitTestCase.java (rev 0)
+++ projects/jboss-reflect/trunk/src/test/java/org/jboss/test/plugins/javassist/bytecode/test/JavassistMemberFactoryPublicStaticBoxedUnitTestCase.java 2010-03-24 16:48:26 UTC (rev 102910)
@@ -0,0 +1,60 @@
+/*
+* JBoss, Home of Professional Open Source.
+* Copyright 2006, Red Hat Middleware LLC, and individual contributors
+* as indicated by the @author tags. See the copyright.txt file in the
+* distribution for a full listing of individual contributors.
+*
+* This is free software; you can redistribute it and/or modify it
+* under the terms of the GNU Lesser General Public License as
+* published by the Free Software Foundation; either version 2.1 of
+* the License, or (at your option) any later version.
+*
+* This software is distributed in the hope that it will be useful,
+* but WITHOUT ANY WARRANTY; without even the implied warranty of
+* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+* Lesser General Public License for more details.
+*
+* You should have received a copy of the GNU Lesser General Public
+* License along with this software; if not, write to the Free
+* Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+* 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+*/
+package org.jboss.test.plugins.javassist.bytecode.test;
+
+import junit.framework.Test;
+
+import org.jboss.test.plugins.javassist.bytecode.support.PublicStaticBoxedBean;
+
+
+
+/**
+ *
+ * @author <a href="kabir.khan at jboss.com">Kabir Khan</a>
+ * @version $Revision: 1.1 $
+ */
+public class JavassistMemberFactoryPublicStaticBoxedUnitTestCase extends AbstractJavassistMemberFactoryTest
+{
+ public static Test suite()
+ {
+ return suite(JavassistMemberFactoryPublicStaticBoxedUnitTestCase.class);
+ }
+
+ public JavassistMemberFactoryPublicStaticBoxedUnitTestCase(String name)
+ {
+ super(name, false);
+ }
+
+ @Override
+ protected Object createInstance()
+ {
+ return new PublicStaticBoxedBean();
+ }
+
+ @Override
+ protected Class<?> getClazz()
+ {
+ return PublicStaticBoxedBean.class;
+ }
+
+
+}
Added: projects/jboss-reflect/trunk/src/test/java/org/jboss/test/plugins/javassist/bytecode/test/JavassistMemberFactoryPublicStaticPrimitiveUnitTestCase.java
===================================================================
--- projects/jboss-reflect/trunk/src/test/java/org/jboss/test/plugins/javassist/bytecode/test/JavassistMemberFactoryPublicStaticPrimitiveUnitTestCase.java (rev 0)
+++ projects/jboss-reflect/trunk/src/test/java/org/jboss/test/plugins/javassist/bytecode/test/JavassistMemberFactoryPublicStaticPrimitiveUnitTestCase.java 2010-03-24 16:48:26 UTC (rev 102910)
@@ -0,0 +1,60 @@
+/*
+* JBoss, Home of Professional Open Source.
+* Copyright 2006, Red Hat Middleware LLC, and individual contributors
+* as indicated by the @author tags. See the copyright.txt file in the
+* distribution for a full listing of individual contributors.
+*
+* This is free software; you can redistribute it and/or modify it
+* under the terms of the GNU Lesser General Public License as
+* published by the Free Software Foundation; either version 2.1 of
+* the License, or (at your option) any later version.
+*
+* This software is distributed in the hope that it will be useful,
+* but WITHOUT ANY WARRANTY; without even the implied warranty of
+* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+* Lesser General Public License for more details.
+*
+* You should have received a copy of the GNU Lesser General Public
+* License along with this software; if not, write to the Free
+* Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+* 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+*/
+package org.jboss.test.plugins.javassist.bytecode.test;
+
+import junit.framework.Test;
+
+import org.jboss.test.plugins.javassist.bytecode.support.PublicStaticPrimitiveBean;
+
+
+
+/**
+ *
+ * @author <a href="kabir.khan at jboss.com">Kabir Khan</a>
+ * @version $Revision: 1.1 $
+ */
+public class JavassistMemberFactoryPublicStaticPrimitiveUnitTestCase extends AbstractJavassistMemberFactoryTest
+{
+ public static Test suite()
+ {
+ return suite(JavassistMemberFactoryPublicStaticPrimitiveUnitTestCase.class);
+ }
+
+ public JavassistMemberFactoryPublicStaticPrimitiveUnitTestCase(String name)
+ {
+ super(name, true);
+ }
+
+ @Override
+ protected Object createInstance()
+ {
+ return new PublicStaticPrimitiveBean();
+ }
+
+ @Override
+ protected Class<?> getClazz()
+ {
+ return PublicStaticPrimitiveBean.class;
+ }
+
+
+}
Added: projects/jboss-reflect/trunk/src/test/java/org/jboss/test/plugins/javassist/bytecode/test/JavassistMemberFactoryTestSuite.java
===================================================================
--- projects/jboss-reflect/trunk/src/test/java/org/jboss/test/plugins/javassist/bytecode/test/JavassistMemberFactoryTestSuite.java (rev 0)
+++ projects/jboss-reflect/trunk/src/test/java/org/jboss/test/plugins/javassist/bytecode/test/JavassistMemberFactoryTestSuite.java 2010-03-24 16:48:26 UTC (rev 102910)
@@ -0,0 +1,67 @@
+/*
+* JBoss, Home of Professional Open Source.
+* Copyright 2006, Red Hat Middleware LLC, and individual contributors
+* as indicated by the @author tags. See the copyright.txt file in the
+* distribution for a full listing of individual contributors.
+*
+* This is free software; you can redistribute it and/or modify it
+* under the terms of the GNU Lesser General Public License as
+* published by the Free Software Foundation; either version 2.1 of
+* the License, or (at your option) any later version.
+*
+* This software is distributed in the hope that it will be useful,
+* but WITHOUT ANY WARRANTY; without even the implied warranty of
+* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+* Lesser General Public License for more details.
+*
+* You should have received a copy of the GNU Lesser General Public
+* License along with this software; if not, write to the Free
+* Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+* 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+*/
+package org.jboss.test.plugins.javassist.bytecode.test;
+
+import junit.framework.Test;
+import junit.framework.TestSuite;
+import junit.textui.TestRunner;
+
+/**
+ *
+ * @author <a href="kabir.khan at jboss.com">Kabir Khan</a>
+ * @version $Revision: 1.1 $
+ */
+public class JavassistMemberFactoryTestSuite extends TestSuite
+{
+ public static void main(String[] args)
+ {
+ TestRunner.run(suite());
+ }
+
+ public static Test suite()
+ {
+ TestSuite suite = new TestSuite("Javassist Member Factory Tests");
+
+ suite.addTest(JavassistMemberFactoryPublicBoxedUnitTestCase.suite());
+ suite.addTest(JavassistMemberFactoryPublicPrimitiveUnitTestCase.suite());
+ suite.addTest(JavassistMemberFactoryPublicStaticBoxedUnitTestCase.suite());
+ suite.addTest(JavassistMemberFactoryPublicStaticPrimitiveUnitTestCase.suite());
+
+ suite.addTest(JavassistMemberFactoryProtectedBoxedUnitTestCase.suite());
+ suite.addTest(JavassistMemberFactoryProtectedPrimitiveUnitTestCase.suite());
+ suite.addTest(JavassistMemberFactoryProtectedStaticBoxedUnitTestCase.suite());
+ suite.addTest(JavassistMemberFactoryProtectedStaticPrimitiveUnitTestCase.suite());
+
+ suite.addTest(JavassistMemberFactoryPackageProtectedBoxedUnitTestCase.suite());
+ suite.addTest(JavassistMemberFactoryPackageProtectedPrimitiveUnitTestCase.suite());
+ suite.addTest(JavassistMemberFactoryPackageProtectedStaticBoxedUnitTestCase.suite());
+ suite.addTest(JavassistMemberFactoryPackageProtectedStaticPrimitiveUnitTestCase.suite());
+
+ suite.addTest(JavassistMemberFactoryPrivateBoxedUnitTestCase.suite());
+ suite.addTest(JavassistMemberFactoryPrivatePrimitiveUnitTestCase.suite());
+ suite.addTest(JavassistMemberFactoryPrivateStaticBoxedUnitTestCase.suite());
+ suite.addTest(JavassistMemberFactoryPrivateStaticPrimitiveUnitTestCase.suite());
+
+ return suite;
+ }
+
+}
Modified: projects/jboss-reflect/trunk/src/test/java/org/jboss/test/plugins/javassist/test/JavassistTestSuite.java
===================================================================
--- projects/jboss-reflect/trunk/src/test/java/org/jboss/test/plugins/javassist/test/JavassistTestSuite.java 2010-03-24 16:46:18 UTC (rev 102909)
+++ projects/jboss-reflect/trunk/src/test/java/org/jboss/test/plugins/javassist/test/JavassistTestSuite.java 2010-03-24 16:48:26 UTC (rev 102910)
@@ -24,6 +24,8 @@
import junit.framework.Test;
import junit.framework.TestSuite;
+import org.jboss.test.plugins.javassist.bytecode.test.JavassistMemberFactoryTestSuite;
+
/**
*
* @author <a href="kabir.khan at jboss.com">Kabir Khan</a>
@@ -43,6 +45,7 @@
suite.addTest(JavassistMutableTypeInfoTestCase.suite());
suite.addTest(JavassistUtilTestCase.suite());
suite.addTest(ModifierInfoTestCase.suite());
+ suite.addTest(JavassistMemberFactoryTestSuite.suite());
return suite;
}
More information about the jboss-cvs-commits
mailing list