hi,
I need to create a class and execute it n times, and i get this error "duplicate
class definition: linkage Error", and really i don't know that is wrong.
| public static ArrayList MacTestScript(String inputTextScript, Mensaje inMsg)
throws NotFoundException, IOException, CannotCompileException{
| String nameScript = "testConsole";
| ArrayList msg2 = null;
| try{
| ClassPool pool;
|
| pool = ClassPool.getDefault();
|
| pool.appendClassPath(classPath);
| CtClass newClass=null;
|
| try{
| newClass = pool.get( packageName + nameScript +
suffixClass);
| newClass.defrost();
| newClass.detach();
| newClass = null;
|
| }
| catch(NotFoundException e){
| System.out.println("no esta creada la clase aun");
| newClass = pool.makeClass( packageName + nameScript +
suffixClass );
| newClass.stopPruning(true);
|
| }
|
| System.out.println("buscando super" + packageName +
suffixClass);
| CtClass superClass = null;
| superClass = pool.get( packageName + suffixClass );
| System.out.println("super encontrada");
|
|
| newClass.setSuperclass(superClass);
| System.out.println("seteando super");
|
|
newClass.addConstructor(CtNewConstructor.defaultConstructor(newClass));
| String executeBody = "";
|
| java.util.List list = new java.util.ArrayList();
| executeBody = executeBody + "public java.util.ArrayList
execute(){";
| executeBody = executeBody + "java.util.ArrayList list = new
java.util.ArrayList();";
| executeBody = executeBody + inputTextScript ;
| executeBody = executeBody + "return list;";
| executeBody = executeBody + "}";
|
| newClass.addMethod(CtNewMethod.make(executeBody, newClass));
|
| System.out.println("Clase creada");
|
| Class testObject = newClass.toClass();
| System.out.println("Nombre Clase: " + testObject.getName());
|
| Method m[] = testObject.getDeclaredMethods();
| System.out.println("Metodos =" + m.length);
| for (int i = 0; i < m.length; i++)
| System.out.println("Metodos =<" + m.toString() + ">");
|
| Constructor c[] = testObject.getDeclaredConstructors();
| for (int i = 0; i < c.length; i++)
| System.out.println("Constructor =<" + c.toString() +
">");
|
| //Object testConstructed = con.newInstance(arguments);
| System.out.println("Constr...");
| Object testConstructed = testObject.newInstance();
| System.out.println("Cast");
| Script testInstance = (Script) testConstructed;
| System.out.println("setMessage");
| testInstance.setMsg(inMsg);
| System.out.println("Execute");
| msg2 = testInstance.execute();
|
| newClass.detach();
|
|
| }
| catch (NotFoundException e ){
| throw e;
|
| }
| catch (CannotCompileException e ){
| throw e;
| }
| catch (InstantiationException e) {
| // TODO Auto-generated catch block
| e.printStackTrace();
| } catch (IllegalAccessException e) {
| // TODO Auto-generated catch block
| e.printStackTrace();
| }
| return msg2;
| }
Thanks
marÃa de los Angeles
View the original post :
http://www.jboss.org/index.html?module=bb&op=viewtopic&p=3852843#3852843
Reply to the post :
http://www.jboss.org/index.html?module=bb&op=posting&mode=reply&p=3852843
-------------------------------------------------------
This SF.Net email is sponsored by:
Sybase ASE Linux Express Edition - download now for FREE
LinuxWorld Reader's Choice Award Winner for best database on Linux.
http://ads.osdn.com/?ad_idU88&alloc_id065&op=click
_______________________________________________
JBoss-user mailing list
[EMAIL PROTECTED]
https://lists.sourceforge.net/lists/listinfo/jboss-user