• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 import java.io.File;
2 import java.io.PrintWriter;
3 
4 public class ClassGen {
5 
main(String... args)6     public static void main(String... args) {
7 
8 	int start = 1;
9         int end =   8024;
10 	int fields =   4;
11         int methods =   6;
12 	if (args.length > 0) {
13 	    start = Integer.parseInt(args[0]);
14         }
15 	if (args.length > 1) {
16 	    end = Integer.parseInt(args[1]);
17         }
18 	if (args.length > 2) {
19 	    fields = Integer.parseInt(args[2]);
20         }
21 	if (args.length > 3) {
22 	    methods = Integer.parseInt(args[3]);
23         }
24 
25 	for (int file = start; file <= end; file++) {
26             try {
27 	        File f = new File("src/Clazz" + file + ".java");
28 	        PrintWriter pw = new PrintWriter(f);
29 		pw.println("class Clazz" + file + " {");
30 		for (int field = 1; field <= fields; field++) {
31 		    pw.println("    public static int f" + field + ";");
32 		}
33 		for (int method = 1; method <= methods; method++) {
34 		    pw.println("    boolean m" + method + "_" + (file%(end/2)) + "() {"
35 );
36 		    pw.println("      int max = Thread.MAX_PRIORITY;");
37 		    pw.println("      for (int i = 0; i < max; i++) {");
38 		    pw.println("        System.out.println(\"Hello from: \" + Clazz"
39                             + file + ".class + \".method" + method
40                             + "() \" + Clazz" + (end-file+1) + ".f1);");
41 		    pw.println("        Thread.dumpStack();");
42 		    pw.println("      }");
43 		    pw.println("      return Thread.holdsLock(this);");
44 		    pw.println("    }");
45 		}
46 		pw.println("}");
47                 pw.close();
48             } catch(Exception ex) {
49 		System.out.println("Ups");
50             }
51         }
52     }
53 }
54