CtConstructor[] constructors = clazz.getDeclaredConstructors(); Arrays.sort(constructors, new Comparator() { public int compare(Object o1, Object o2) {
CtConstructor[] constructors = clazz.getDeclaredConstructors(); Arrays.sort(constructors, new Comparator<CtConstructor>() { @Override
cs = superclazz.getDeclaredConstructors();
@Override public void scan(Object cls) { try { CtClass ctClass = getClassPool().get(getMetadataAdapter().getClassName(cls)); for (CtBehavior member : ctClass.getDeclaredConstructors()) { scanMember(member); } for (CtBehavior member : ctClass.getDeclaredMethods()) { scanMember(member); } ctClass.detach(); } catch (Exception e) { throw new ReflectionsException("Could not scan method usage for " + getMetadataAdapter().getClassName(cls), e); } }
@Override public void scan(Object cls) { try { CtClass ctClass = getClassPool().get(getMetadataAdapter().getClassName(cls)); for (CtBehavior member : ctClass.getDeclaredConstructors()) { scanMember(member); } for (CtBehavior member : ctClass.getDeclaredMethods()) { scanMember(member); } ctClass.detach(); } catch (Exception e) { throw new ReflectionsException("Could not scan method usage for " + getMetadataAdapter().getClassName(cls), e); } }
private void ensureNullaryCtor(CtClass cc) throws NotFoundException, CannotCompileException { // Build a null-ary constructor if needed String clzname = cc.getSimpleName(); if( !hasExisting(clzname,"()V",cc.getDeclaredConstructors()) ) { String body = "public "+clzname+"() { }"; cc.addConstructor(CtNewConstructor.make(body,cc)); } else { CtConstructor ctor = cc.getConstructor("()V"); ctor.setModifiers(javassist.Modifier.setPublic(ctor.getModifiers())); } }
cs = superclazz.getDeclaredConstructors();
public List<CtConstructor> getConstructors(CtClass clazz) { List<CtConstructor> list = new ArrayList<CtConstructor>(); CtConstructor[] constructors = clazz.getDeclaredConstructors(); for (int i = 0; i < constructors.length; i++) { list.add(constructors[i]); } Collections.sort(list, CtConstructorComparator.INSTANCE); return list; }
private boolean hasDefaultConstructor(CtClass ctClass) throws NotFoundException { for (CtConstructor constructor : ctClass.getDeclaredConstructors()) { if (constructor.getParameterTypes().length == 0) { return true; } } return false; }
private void updateConstructors(CtClass klass, Node node) { CtConstructor[] constructors = klass.getDeclaredConstructors(); for (int i = 0; i < constructors.length; i++) { try { constructors[i].setBody(emptyBodyCode(CtClass.voidType)); } catch (CannotCompileException ce) { throw new RuntimeException(klass.getName(), ce); } } }
private void addConstructorNotification(final CtClass clazz) throws CannotCompileException { final String notificationCode = GlobalNotificationBuildSupport.class.getName() + ".testInstanceCreated(this);"; final boolean asFinally = !hasSuperClass(clazz); for (final CtConstructor constr : clazz.getDeclaredConstructors()) { constr.insertAfter( notificationCode, asFinally/* unless there is a super-class, because of this * problem: https://community.jboss.org/thread/94194*/); } }
private List<CtConstructor> extractExistingConstructors(final InsertableConstructor insertableConstructor) throws NotFoundException, AfterBurnerImpossibleException { List<CtConstructor> constructors = new ArrayList<CtConstructor>(); CtConstructor[] declaredConstructors = insertableConstructor .getClassToInsertInto().getDeclaredConstructors(); for (CtConstructor constructor : declaredConstructors) { CtClass[] paramClasses = constructor.getParameterTypes(); if (insertableConstructor.acceptParameters(paramClasses)) { constructors.add(constructor); } } return constructors; }
private List<CtConstructor> extractExistingConstructors(final InsertableConstructor insertableConstructor) throws NotFoundException, AfterBurnerImpossibleException { List<CtConstructor> constructors = new ArrayList<CtConstructor>(); CtConstructor[] declaredConstructors = insertableConstructor .getClassToInsertInto().getDeclaredConstructors(); for (CtConstructor constructor : declaredConstructors) { CtClass[] paramClasses = constructor.getParameterTypes(); if (insertableConstructor.acceptParameters(paramClasses)) { constructors.add(constructor); } } return constructors; }
Configuration conf = (Configuration) entry.getValue(); String clazz = conf.getClazz(); try { CtClass ctClass = ClassPool.getDefault().get(clazz); String appendCode = "{com.broada.bsp.gene.config.management.ConfigurationManager.manager.inject(this);\n}"; CtConstructor constructor[] = ctClass.getDeclaredConstructors(); for (CtConstructor ctConstructor : constructor) { ctConstructor.insertAfter(appendCode); } ctClass.toClass();
private Map<String, CtConstructor> createConstructorMap(Optional<CtClass> ctClass) { Map<String, CtConstructor> methods = new HashMap<>(); if (ctClass.isPresent()) { for (CtConstructor ctConstructor : ctClass.get().getDeclaredConstructors()) { if (options.getFilters().includeBehavior(ctConstructor)) { methods.put(ctConstructor.getLongName(), ctConstructor); } } } return methods; }
private Map<String, CtConstructor> createConstructorMap(Optional<CtClass> ctClass) { Map<String, CtConstructor> methods = new HashMap<>(); if (ctClass.isPresent()) { for (CtConstructor ctConstructor : ctClass.get().getDeclaredConstructors()) { if (options.getFilters().includeBehavior(ctConstructor)) { methods.put(ctConstructor.getLongName(), ctConstructor); } } } return methods; }
private boolean hasInheritableConstructor(CtClass cls) throws NotFoundException { CtConstructor[] constructors = cls.getDeclaredConstructors(); if (constructors.length == 0) { return true; } for (CtConstructor ctConstructor : constructors) { int modifiers = ctConstructor.getModifiers(); if (!Modifier.isPackage(modifiers) && !Modifier.isPrivate(modifiers)) { return true; } } return false; }
private boolean compare(CtClass clazz, ClassInfo info) { if(clazz.getDeclaredMethods().length == info.getDeclaredMethods().length && clazz.getDeclaredConstructors().length == info.getDeclaredConstructors().length && clazz.getDeclaredFields().length == info.getDeclaredFields().length) return true; else return false; }
private boolean compare(CtClass clazz, ClassInfo info) { if(clazz.getDeclaredMethods().length == info.getDeclaredMethods().length && clazz.getDeclaredConstructors().length == info.getDeclaredConstructors().length && clazz.getDeclaredFields().length == info.getDeclaredFields().length) return true; else return false; }
@Override public void scan(Object cls) { try { CtClass ctClass = getClassPool().get(getMetadataAdapter().getClassName(cls)); for (CtBehavior member : ctClass.getDeclaredConstructors()) { scanMember(member); } for (CtBehavior member : ctClass.getDeclaredMethods()) { scanMember(member); } ctClass.detach(); } catch (Exception e) { throw new ReflectionsException("Could not scan method usage for " + getMetadataAdapter().getClassName(cls), e); } }