Package javassist

Examples of javassist.CtClass.toClass()


       
        overrideInterceptedMethods(subClass);
       
        // now let's get the real class from it
        @SuppressWarnings("unchecked")
        Class<T> interceptedClass = subClass.toClass();
       
        return interceptedClass;
    }

View Full Code Here


         CtMethod m = new CtMethod(CtClass.voidType, methodName, new CtClass[0], newClazz);
         methodList.add(methodName);
         m.setBody("launchTest(\"" + StringEscapeUtils.escapeJava(fileAbsolutePath) + "\");");
         newClazz.addMethod(m);
      }
      generatedClazz = newClazz.toClass(getClass().getClassLoader(), null);
      for (String methodName : methodList) {
         Method m = generatedClazz.getMethod(methodName);
         testMethods.add(m);
      }
   }
View Full Code Here

         CtMethod get = CtMethod.make("public void get(" + AsyncCallback.class.getName()
                  + " callback) { callback.onSuccess(provider.get()); }", c);
         c.addMethod(get);

         return c.toClass();
      } catch (CannotCompileException e) {
         throw new GwtTestGinException("Error while creating AsyncProvider subclass [" + className
                  + "]", e);
      }
View Full Code Here

                cc.addMethod(generateGetter(cc, entry.getKey(), entry.getValue()));

                // add setter
                cc.addMethod(generateSetter(cc, entry.getKey(), entry.getValue()));
            }
            return cc.toClass();
        } catch (Exception e) {
            throw new RuntimeException(e);
        }
    }
View Full Code Here

      // Insert a classpath so that Maven does not complain about not finding the class
      pool.insertClassPath(new ClassClassPath(Car.class));
      CtClass carCt = pool.get(CAR);
      try {
         carCt.addField(CtField.make("public int year;", carCt));
         Class carClass = carCt.toClass();
         if (isNewExternalizer) {
            CtClass carExtCt = pool.get(CAR_EXT);
            CtMethod writeObjMeth = carExtCt.getMethod("writeObject",
                  "(Ljava/io/ObjectOutput;Ljava/lang/Object;)V");
            writeObjMeth.setBody("{\n" +
View Full Code Here

               "            ((0xFF & b3) << 8) | (0xFF & b4);\n" +
               "}\n" +
               "return o;\n" +
            "}\n"
            );
            carExtCt.toClass(); // Convert to class so that it gets loaded!!!
         }

         Object oldCarFromWire = unmarshall(oldCarbytes, method);

         Field plateField = carClass.getDeclaredField("plateNumber");
View Full Code Here

      Thread.currentThread().setContextClassLoader(cherryPickCl);
      ClassPool pool = ClassPool.getDefault();
      CtClass ct = pool.get(PERSON);
      try {
         ct.addField(CtField.make("public String name;", ct));
         Class clazz = ct.toClass();
         if (isNewExternalizer) {
            CtClass extCt = pool.get(PERSON_EXT);
            CtMethod writeObjMeth = extCt.getMethod("writeObject", "(Ljava/io/ObjectOutput;Ljava/lang/Object;)V");
            writeObjMeth.setBody("{\n" +
               "$1.writeInt(((" + PERSON + ") $2).age);\n" +
View Full Code Here

               "   o.name = (String) $1.readObject();\n" +
               "} catch(java.io.OptionalDataException e) {}\n" +
               "return o;\n" +
            "}\n"
            );
            extCt.toClass(); // Convert to class so that it gets loaded!!!
         }

         Object oldFromWire = unmarshall(bytes, method);

         Field age = clazz.getDeclaredField("age");
View Full Code Here

      Thread.currentThread().setContextClassLoader(cherryPickCl);
      ClassPool pool = ClassPool.getDefault();
      CtClass ct = pool.get(HOUSE);
      try {
         ct.removeField(ct.getField("number"));
         Class clazz = ct.toClass();
         if (isNewExternalizer) {
            CtClass extCt = pool.get(HOUSE_EXT);
            CtMethod writeObjMeth = extCt.getMethod("writeObject", "(Ljava/io/ObjectOutput;Ljava/lang/Object;)V");
            writeObjMeth.setBody("{\n" +
               "$1.writeInt(0);\n" + // Safe the spot to avoid incompatibility
View Full Code Here

               "} catch(java.io.OptionalDataException e) {}\n" +
               "o.street = (String) $1.readObject();\n" +
               "return o;\n" +
            "}\n"
            );
            extCt.toClass(); // Convert to class so that it gets loaded!!!
         }

         Object oldFromWire = unmarshall(bytes, method);

         Field street = clazz.getDeclaredField("street");
View Full Code Here

TOP
Copyright © 2018 www.massapi.com. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.