Package javassist

Examples of javassist.CtClass.addConstructor()


/*     */
/*  87 */     result.addInterface(pool.get(JavassistMethod.class.getName()));
/*     */
/*  89 */     CtConstructor constructor = new CtConstructor(null, result);
/*  90 */     constructor.setBody("super();");
/*  91 */     result.addConstructor(constructor);
/*     */
/*  93 */     CtClass object = pool.get(Object.class.getName());
/*     */
/*  95 */     JBossStringBuilder buffer = new JBossStringBuilder();
/*     */
View Full Code Here


      CtClass clazz = pool.makeClass(fullName);

      // add a default constructor
      CtConstructor constructor = new CtConstructor(null, clazz);
      constructor.setBody("{super();}");
      clazz.addConstructor(constructor);

      // add the method implementation
      CtMethod m = CtNewMethod.make(methodDef.toString(), clazz);
      clazz.addMethod(m);
View Full Code Here

/* 148 */     f.setModifiers(2);
/* 149 */     proxy.addField(f, CtField.Initializer.byParameter(1));
/*     */
/* 151 */     proxy.addMethod(CtNewMethod.getter("_getObjectId", f));
/*     */
/* 153 */     proxy.addConstructor(CtNewConstructor.defaultConstructor(proxy));
/* 154 */     CtConstructor cons = CtNewConstructor.skeleton(this.proxyConstructorParamTypes, null, proxy);
/*     */
/* 157 */     proxy.addConstructor(cons);
/*     */     try
/*     */     {
View Full Code Here

/* 151 */     proxy.addMethod(CtNewMethod.getter("_getObjectId", f));
/*     */
/* 153 */     proxy.addConstructor(CtNewConstructor.defaultConstructor(proxy));
/* 154 */     CtConstructor cons = CtNewConstructor.skeleton(this.proxyConstructorParamTypes, null, proxy);
/*     */
/* 157 */     proxy.addConstructor(cons);
/*     */     try
/*     */     {
/* 160 */       addMethods(proxy, orgRtClass.getMethods());
/* 161 */       return proxy;
/*     */     } catch (SecurityException e) {
View Full Code Here

/*     */       {
/* 245 */         superclazz.getDeclaredConstructor(null);
/*     */       }
/*     */       catch (NotFoundException e)
/*     */       {
/* 251 */         superclazz.addConstructor(CtNewConstructor.defaultConstructor(superclazz));
/*     */       }
/*     */     }
/*     */   }
/*     */ }

View Full Code Here

          break;
        }
      }
      if (!hasDefaultConstructor && !ctClass.isInterface()) {
        CtConstructor defaultConstructor = CtNewConstructor.make("private " + ctClass.getSimpleName() + "() {}", ctClass);
        ctClass.addConstructor(defaultConstructor);
      }
    } catch (Throwable t) {
      Logger.error(t, "Error in EbeanEnhancer");
      throw new UnexpectedException("Error in EbeanEnhancer", t);
    }
View Full Code Here

    aClass.addField(aAllTriplesField, CtField.Initializer.byExpr("new com.complexible.common.openrdf.model.SetGraph();"));
   
    CtField aInstanceTriplesField = new CtField(aPool.get(Graph.class.getName()), "mInstanceTriples", aClass);
    aClass.addField(aInstanceTriplesField, CtField.Initializer.byExpr("new com.complexible.common.openrdf.model.SetGraph();"));
   
    aClass.addConstructor(CtNewConstructor.defaultConstructor(aClass));
   
    generateMethods(theInterface, aPool, aClass);
    generateMethodsForSuperInterfaces(theInterface, aPool, aClass);

    CtField aIdField = new CtField(aPool.get(SupportsRdfId.class.getName()), "supportsId", aClass);
View Full Code Here

                        pool.get(Class.class.getName()),
                        pool.get(String.class.getName()) },
                    subClass);
                constructor
                    .setBody("{ super($1); this.scenarioName = $2; }");
                subClass.addConstructor(constructor);
                proxyClass = subClass.toClass();

              }
            }
          }
View Full Code Here

                        + " is not set; please set serialVersionUID to allow Warp work correctly");
            }
            for (CtConstructor constructor : output.getConstructors()) {
                output.removeConstructor(constructor);
            }
            output.addConstructor(CtNewConstructor.defaultConstructor(output));

            return output;
        } catch (Exception e) {
            throw new InspectionTransformationException("Unable to transform inspection " + originalClass.getName() + ":\n" + e.getMessage(), e);
        }
View Full Code Here

            } catch (ClassNotFoundException e) {
                ClassPool pool = ClassGenerator.getClassPool(clazz.getClassLoader());
                CtClass ctClass = pool.makeClass(parameterClassName);
                ClassFile classFile = ctClass.getClassFile();
                classFile.setVersionToJava5();
                ctClass.addConstructor(CtNewConstructor.defaultConstructor(pool.getCtClass(parameterClassName)));
                // parameter fields
                Class<?>[] parameterTypes = method.getParameterTypes();
                Annotation[][] parameterAnnotations = method.getParameterAnnotations();
                for (int i = 0; i < parameterTypes.length; i ++) {
                    Class<?> type = parameterTypes[i];
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.