@Test public void testGenerateEmptyClass() { final CtClass emptyClass = JavassistUtils.generateEmptyClass(); final CtClass anotherEmptyClass = JavassistUtils.generateEmptyClass(); Assert.assertFalse(emptyClass.equals(anotherEmptyClass)); final CtMethod method = addNewMethod(emptyClass, "a"); annotateMethod(method, "abc", 7); final CtField field = addNewField(emptyClass, "d"); annotateField(field, "def", 9); Assert.assertEquals( 7, ((IntegerMemberValue) ((AnnotationsAttribute) method.getMethodInfo().getAttribute( AnnotationsAttribute.visibleTag)).getAnnotation("java.lang.Integer").getMemberValue( "abc")).getValue()); Assert.assertEquals( 9, ((IntegerMemberValue) ((AnnotationsAttribute) field.getFieldInfo().getAttribute( AnnotationsAttribute.visibleTag)).getAnnotation("java.lang.Integer").getMemberValue( "def")).getValue()); }
public static CtClass generateEmptyClass() { final ClassPool pool = ClassPool.getDefault(); return pool.makeClass(getNextUniqueClassName()); }
JavassistUtils { public static CtClass generateEmptyClass() { final ClassPool pool = ClassPool.getDefault(); return pool.makeClass(getNextUniqueClassName()); } }
JavassistUtils { public static CtClass generateEmptyClass() { final ClassPool pool = ClassPool.getDefault(); return pool.makeClass(getNextUniqueClassName()); } private  JavassistUtils(); }
JavassistUtils { public static CtClass generateEmptyClass() { final ClassPool pool = ClassPool.getDefault(); return pool.makeClass(getNextUniqueClassName()); } private  JavassistUtils(); static AnnotationsAttribute cloneAnnotationsAttribute(
      final ConstPool constPool,
      final AnnotationsAttribute attr,
      final ElementType validElementType); static CtMethod findMethod(final CtClass clz, final Method m); static void copyClassAnnotations(final CtClass oldClass, final CtClass newClass); static void copyMethodAnnotationsToField(final CtMethod method, final CtField field); static String getNextUniqueClassName(); static String getNextUniqueFieldName(); static CtClass generateEmptyClass(); }
JavassistUtils { public static CtClass generateEmptyClass() { final ClassPool pool = ClassPool.getDefault(); return pool.makeClass(getNextUniqueClassName()); } private  JavassistUtils(); static AnnotationsAttribute cloneAnnotationsAttribute(
      final ConstPool constPool,
      final AnnotationsAttribute attr,
      final ElementType validElementType); static CtMethod findMethod(final CtClass clz, final Method m); static void copyClassAnnotations(final CtClass oldClass, final CtClass newClass); static void copyMethodAnnotationsToField(final CtMethod method, final CtField field); static String getNextUniqueClassName(); static String getNextUniqueFieldName(); static CtClass generateEmptyClass(); static final String PREFIX_PACKAGE; }