From f89063af066d1e9e1fd36229645a565145c8fb5f Mon Sep 17 00:00:00 2001 From: chiba Date: Thu, 16 Feb 2006 14:42:22 +0000 Subject: [PATCH] reformatting. git-svn-id: http://anonsvn.jboss.org/repos/javassist/trunk@248 30ef5769-5b8d-40dd-aea6-55b5d6557bb3 --- src/main/javassist/CtClassType.java | 5 ++++- src/main/javassist/expr/NewExpr.java | 5 ++--- src/main/javassist/util/proxy/ProxyFactory.java | 16 ++++++++++++++++ 3 files changed, 22 insertions(+), 4 deletions(-) diff --git a/src/main/javassist/CtClassType.java b/src/main/javassist/CtClassType.java index 3902a3bd..d4830676 100644 --- a/src/main/javassist/CtClassType.java +++ b/src/main/javassist/CtClassType.java @@ -422,7 +422,9 @@ class CtClassType extends CtClass { } static Object[][] toAnnotationType(ClassPool cp, ParameterAnnotationsAttribute a1, - ParameterAnnotationsAttribute a2) throws ClassNotFoundException { + ParameterAnnotationsAttribute a2) + throws ClassNotFoundException + { int numParameters = 0; if (a1 != null) numParameters = a1.numParameters(); @@ -454,6 +456,7 @@ class CtClassType extends CtClass { anno2 = a2.getAnnotations()[i]; size2 = anno2.length; } + result[i] = new Object[size1 + size2]; for (int j = 0; j < size1; ++j) result[i][j] = anno1[j].toAnnotationType(cl, cp); diff --git a/src/main/javassist/expr/NewExpr.java b/src/main/javassist/expr/NewExpr.java index 835485f5..19018d3d 100644 --- a/src/main/javassist/expr/NewExpr.java +++ b/src/main/javassist/expr/NewExpr.java @@ -95,8 +95,7 @@ public class NewExpr extends Expr { * * @return the signature */ - public String getSignature() - { + public String getSignature() { ConstPool constPool = getConstPool(); int methodIndex = iterator.u16bitAt(currentPos + 1); // constructor return constPool.getMethodrefType(methodIndex); @@ -146,7 +145,7 @@ public class NewExpr extends Expr { throw new CannotCompileException( "sorry, cannot edit NEW followed by no DUP"); } - + /** * Replaces the new expression with the bytecode derived from * the given source text. diff --git a/src/main/javassist/util/proxy/ProxyFactory.java b/src/main/javassist/util/proxy/ProxyFactory.java index 89cb98cd..9d56dc7f 100644 --- a/src/main/javassist/util/proxy/ProxyFactory.java +++ b/src/main/javassist/util/proxy/ProxyFactory.java @@ -16,6 +16,7 @@ package javassist.util.proxy; import java.lang.reflect.Field; +import java.lang.reflect.InvocationTargetException; import java.lang.reflect.Method; import java.lang.reflect.Constructor; import java.lang.reflect.Member; @@ -185,6 +186,21 @@ public class ProxyFactory { // return Thread.currentThread().getContextClassLoader(); } + /** + * Creates a proxy class and returns an instance of that class. + * + * @param paramTypes parameter types for a constructor. + * @param args arguments passed to a constructor. + */ + public Object create(Class[] paramTypes, Object[] args) + throws NoSuchMethodException, IllegalArgumentException, + InstantiationException, IllegalAccessException, InvocationTargetException + { + Class c = createClass(); + Constructor cons = c.getConstructor(paramTypes); + return cons.newInstance(args); + } + /** * Sets the default invocation handler. This invocation handler is shared * among all the instances of a proxy class unless another is explicitly -- 2.39.5