/*
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* under the terms of the GNU General Public License version 2 only, as
* published by the Free Software Foundation.
*
* This code is distributed in the hope that it will be useful, but WITHOUT
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
* version 2 for more details (a copy is included in the LICENSE file that
* accompanied this code).
*
* You should have received a copy of the GNU General Public License version
* 2 along with this work; if not, write to the Free Software Foundation,
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
*
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
* or visit www.oracle.com if you need additional information or have any
* questions.
*/
/*
* A utility used to invoke and test the apt tool.
* Tests should subclass Tester, and invoke run().
*
* @author Scott Seligman
*/
public abstract class Tester {
/**
* The declaration corresponding to this tester's class. Set by
* TestProcessorFactory after the constructor completes, and
* before init() is invoked.
*/
/**
* The environment for this apt run. Set by TestProcessorFactory
* after the constructor completes, and before init() is invoked.
*/
// TestProcessorFactory looks here to find the tester that's running
// when it's invoked.
"-nocompile",
"-XPrintAptRounds",
"-XListDeclarations",
};
// Force processor and factory to be compiled
// apt command-line args
static {
// Enable assertions in the unnamed package.
}
}
}
/**
* Run apt.
*/
protected void run() {
activeTester = this;
throw new Error("apt errors encountered.");
}
}
/**
* Called after thisClassDecl and env have been set, but before any
* tests are run, to allow the tester subclass to perform any
* needed initialization.
*/
protected void init() {
}
/**
* Returns the declaration of a named method in this class. If this
* method name is overloaded, one method is chosen arbitrarily.
* Returns null if no method is found.
*/
return m;
}
}
return null;
}
/**
* Returns the declaration of a named field in this class.
* Returns null if no field is found.
*/
return f;
}
}
return null;
}
/**
* Returns the annotation mirror of a given type on a named method
* in this class. If this method name is overloaded, one method is
* chosen arbitrarily. Returns null if no appropriate annotation
* is found.
*/
if (m != null) {
for (AnnotationMirror a : m.getAnnotationMirrors()) {
return a;
}
}
}
return null;
}
}