Package javassist

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


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

                                        "( methods[" + i + "], target, $args ) );\n }";
                    method.setBody( body );
                    proxyClass.addMethod( method );

                }
                return proxyClass.toClass( classLoader );
            }
            catch( CannotCompileException e )
            {
                throw new ProxyFactoryException( "Could not compile class.", e );
            }
View Full Code Here

                                        method.getName() + "($$); }";
                    ctMethod.setBody( body );
                    proxyClass.addMethod( ctMethod );

                }
                return proxyClass.toClass( classLoader );
            }
            catch( CannotCompileException e )
            {
                throw new ProxyFactoryException( "Could not compile class.", e );
            }
View Full Code Here

        }
        proceedBody.append( "}" );
        final String body = proceedBody.toString();
        proceedMethod.setBody( body );
        ctClass.addMethod( proceedMethod );
        invocationClass = ctClass.toClass( classLoader );
        return invocationClass;
    }

    private static Map getClassCache( ClassLoader classLoader )
    {
View Full Code Here

                    final String body = "{\n\t return ( $r ) invoker.invoke( this, methods[" + i +
                                        "], $args );\n }";
                    method.setBody( body );
                    proxyClass.addMethod( method );
                }
                return proxyClass.toClass( classLoader );
            }
            catch( CannotCompileException e )
            {
                throw new ProxyFactoryException( "Could not compile class.", e );
            }
View Full Code Here

         else if ("getProxyResultSet".equals(methodName)) {
            method.setBody("{return new " + packageName + ".ResultSetJavassistProxy($$);}");
         }
      }

      proxyCt.toClass(classPool.getClassLoader(), getClass().getProtectionDomain());
   }

   /**
    *  Generate Javassist Proxy Classes
    */
 
View Full Code Here

            CtConstructor constructorCt = new CtConstructor(null, targetCt);
            constructorCt.setModifiers(Modifier.PUBLIC);
            constructorCt.setBody("{ throw new RuntimeException(\"HikariCP Codahale shim says: Codahale metrics library is required but was not found in the classpath\"); }");
            targetCt.addConstructor(constructorCt);

            targetCt.toClass(classPool.getClassLoader(), getClass().getProtectionDomain());
         }
         catch (CannotCompileException cce) {
            LOGGER.error("Cannot generate CodaHale metrics shim", cce);
            throw new RuntimeException(cce);
         }
View Full Code Here

            method.setBody("{return new " + packageName + ".ResultSetJavassistProxy($$);}");
            break;
         }
      }

      proxyCt.toClass(classPool.getClassLoader(), getClass().getProtectionDomain());
   }

   /**
    *  Generate Javassist Proxy Classes
    */
 
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

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.