Guest User

Untitled

a guest
Jul 19th, 2018
72
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.49 KB | None | 0 0
  1. void addLogMethod(CtClass ctClass) {
  2. String body = "System.out.println(\"Added later\");";
  3. CtConstructor[] constructors = ctClass.getConstructors();
  4. if (constructors == null) return;
  5. for (CtConstructor constructor : constructors) {
  6. addCodeIfNeeded(constructor, body);
  7. }
  8. }
  9.  
  10. void addCode(CtConstructor constructor, String body) {
  11. try {
  12. constructor.insertBeforeBody(body);
  13. } catch (CannotCompileException e) {
  14. System.err.println(e.getMessage());
  15. }
  16. }
Add Comment
Please, Sign In to add comment