Examples of toClass()


Examples of javassist.CtClass.toClass()

                    try {

                        CtClass ctClass = ServiceFramwork.classPool.makeClass(classFile);
                        TraceEnhancer.enhanceMethod(ctClass);
                        try {
                            ctClasses.add(ctClass.toClass());
                        } catch (Exception e) {
                            String name = ctClass.getName();
                            Class me = Class.forName(name);
                            if (!ctClasses.contains(me)) {
                                ctClasses.add(me);
View Full Code Here

Examples of javassist.CtClass.toClass()

            CtClass ctClass = ServiceFramwork.classPool.get("net.csdn.bootstrap.Bootstrap");
            if (checkClassLoaded(ctClass.getName())) {
                return;
            }
            //加载Guice容器
            Method method = ctClass.toClass().getDeclaredMethod("configureSystem");
            method.setAccessible(true);
            method.invoke(null);
            injector = ServiceFramwork.injector;
        } catch (Exception e) {
            e.printStackTrace();
View Full Code Here

Examples of javassist.CtClass.toClass()

    private Class<?> createArtificialApplicationResourcesClass() {
        try {
            ClassPool classPool = ClassPool.getDefault();
            CtClass applicationResourcesCtClass = classPool.makeClass(APP_FUSE_RESOURCE_FILE_NAME);
            return applicationResourcesCtClass.toClass();
        } catch (CannotCompileException e) {
            throw new RuntimeException("Unable to instantiate Wicket application", e);
        }
    }
View Full Code Here

Examples of javassist.CtClass.toClass()

      CtMethod theMethod = new CtMethod(
          classPool.get("java.lang.String"), "interfaceMethod",
          new CtClass[0], theClass);
      theMethod.setBody("return \"Hello, World!\";");
      theClass.addMethod(theMethod);
      Class clazz = theClass.toClass();
      return ( BeanInterface )clazz.newInstance();
    } catch (Exception e) {
      throw new ApplicationRuntimeException("Cannot construct instance.",
          e);
    }
View Full Code Here

Examples of javassist.CtClass.toClass()

      // 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

Examples of javassist.CtClass.toClass()

               "            ((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

Examples of javassist.CtClass.toClass()

      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

Examples of javassist.CtClass.toClass()

               "   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

Examples of javassist.CtClass.toClass()

      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

Examples of javassist.CtClass.toClass()

               "} 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.