Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- void addLogMethod(CtClass ctClass) {
- String body = "System.out.println(\"Added later\");";
- CtConstructor[] constructors = ctClass.getConstructors();
- if (constructors == null) return;
- for (CtConstructor constructor : constructors) {
- addCodeIfNeeded(constructor, body);
- }
- }
- void addCode(CtConstructor constructor, String body) {
- try {
- constructor.insertBeforeBody(body);
- } catch (CannotCompileException e) {
- System.err.println(e.getMessage());
- }
- }
Add Comment
Please, Sign In to add comment