Hello, I've encountered an error while trying to make a method in a class file.
Exception in thread "main" javassist.CannotCompileException: [source error] ) is missing at javassist.CtNewMethod.make(CtNewMethod.java:78) at javassist.CtNewMethod.make(CtNewMethod.java:44) at Modify.main(Modify.java:33) Caused by: compile error: ) is missing at javassist.compiler.Parser.parseArgumentList(Parser.java:1337) at javassist.compiler.Parser.parseMethodCall(Parser.java:1177) at javassist.compiler.Parser.parsePostfix(Parser.java:1034) at javassist.compiler.Parser.parseUnaryExpr(Parser.java:887) at javassist.compiler.Parser.parseBinaryExpr(Parser.java:774) at javassist.compiler.Parser.parseConditionalExpr(Parser.java:718) at javassist.compiler.Parser.parseExpression(Parser.java:698) at javassist.compiler.Parser.parseDeclarationOrExpression(Parser.java:59 0) at javassist.compiler.Parser.parseStatement(Parser.java:276) at javassist.compiler.Parser.parseBlock(Parser.java:288) at javassist.compiler.Parser.parseMethod2(Parser.java:151) at javassist.compiler.Javac.compileMethod(Javac.java:138) at javassist.compiler.Javac.compile(Javac.java:93) at javassist.CtNewMethod.make(CtNewMethod.java:73) ... 2 more
CtMethod CM = CtNewMethod.make("public void setTray() { final SystemTray tray = SystemTray.getDefaultSystemTray(); ImageIcon i = new ImageIcon(System.getProperty("user.dir") + "/progicon.gif"); final TrayIcon ti = new TrayIcon(i, "Trayed"); ti.setIconAutoSize(true); ti.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent e) { window.setVisible(true); tray.removeTrayIcon(ti); } }); window.setVisible(false); tray.addTrayIcon(ti); }", CC);
Print out the string with all substitutions being passed to CtNewMethod.make to debug its syntax as this inline construct is simply unreadable.