Beispiel #1
0
 /** return all executables of this class */
 public static Collection<CtExecutableReference<?>> getAllExecutables(
     Class<?> clazz, Factory factory) {
   Collection<CtExecutableReference<?>> l = new ArrayList<CtExecutableReference<?>>();
   for (Method m : clazz.getDeclaredMethods()) {
     l.add(factory.Method().createReference(m));
   }
   for (Constructor<?> c : clazz.getDeclaredConstructors()) {
     l.add(factory.Constructor().createReference(c));
   }
   return l;
 }
Beispiel #2
0
 @Test
 public void testAddSameMethodsTwoTimes() throws Exception {
   final Factory factory = createFactory();
   final CtClass<Object> tacos = factory.Class().create("Tacos");
   final CtMethod<Void> method =
       factory.Method()
           .create(
               tacos,
               new HashSet<>(),
               factory.Type().voidType(),
               "m",
               new ArrayList<>(),
               new HashSet<>());
   try {
     tacos.addMethod(method.clone());
   } catch (ConcurrentModificationException e) {
     fail();
   }
 }