Here's what I'm trying to do. I have a program which runs tests on lots of historical price data. The big
testing program is in one package, and a second package contains one class per test (each class defines the rules of a separate test). The program runs and writes the test results for the specified test class to a text file; in the file are various sorts of quantitative results of the the test. The text results file also contains the name of the class tested (which I obtain via reflection) and the values of parameters used for testing, etc. Typically the user than modifies the test class a little and runs the test again, and repeats this process many times. I thought it would be nice for each test results file to have the complete code of the testing algorithm printed at the bottom so there would be a very clear permanant record of exactly which test the results represent. I looked in the java reflection package but could only find ways of outputting method names and signatures but not the actual method code. I see what you mean, Ernest - the .class files don't contain source code, so how can one expect the program to output the source code?
There's a limit to how many hoops I'm willing to jump through to get this to work. For example I know there are programs that reverse engineer compiled code to produce source code, but I don't think I'd want to go there. As it is I keep the source files, and the text files with the test results provide reference to those source files (because they output the name of the class) so they can be looked up. It seems the user will have to rename each test class each time, though, in order to keep a discrete record of each test unless the source code can be stored elsewhere, e.g. in the results file. If anyone has a fairly simple solution, great; otherwise I'll have to make due.
Thanks for your consideration.
Jonathan