The ant extension task throws the stackoverflowerror exception. When the inherited task performs the extension task, it uses the LOG method in the project instance of the parent class. At the same time, it uses other output stream instances to output information to the command line, in this case, stackoverflowerror occurs.
Java. Lang. stackoverflowerror
Java source code, which defines an ant task. Pay attention to the application of the project instance.
/*** Custom ant task * @ author wangyancheng * @ version 2011-10-20 */public class simpletask extends task {private project; private list filelistarr = new arraylist (); @ override public void execute () throws buildexception {string message = project. getproperty ("ant. project. name "); Project. log ("here is project" + message + ". ", project. msg_err); Project. log ("My location is" + getlocation (); For (iterator = filelistarr. iterator (); iterator. hasnext ();) {// project. log (iterator. next (). path, project. msg_info); system. out. println (iterator. next (). path) ;}} public void setproject (Project proj) {This. project = proj;} public filelist createfilelist () {filelist = new filelist (); filelistarr. add (filelist); Return filelist;}/*** nested object * @ author wangyancheng * @ version 2011-10-20 */public class filelist {string path; Public filelist () {} Public String getpath () {return path;} public void setpath (string path) {This. path = path ;}}}
Ant source code, which describes ant tasks
<?xml version="1.0" encoding="UTF-8"?>
Exception Information
Buildfile: D:\work\workspace\mywork\leanant\SimpleTask.xmljar: [jar] Building jar: D:\work\workspace\mywork\leanant\SimpleTask.jarmain:Here is project SimpleTask.My location is D:\work\workspace\mywork\leanant\SimpleTask.xml:9: ABCABCABCABCABCABCABCABCABCABCABCABCBUILD FAILEDD:\work\workspace\mywork\leanant\SimpleTask.xml:9: java.lang.StackOverflowErrorTotal time: 922 milliseconds