1 /*
2 * Copyright (c) 2015, 2018, Oracle and/or its affiliates. All rights reserved.
3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
4 *
5 * This code is free software; you can redistribute it and/or modify it
6 * under the terms of the GNU General Public License version 2 only, as
7 * published by the Free Software Foundation.
8 *
9 * This code is distributed in the hope that it will be useful, but WITHOUT
10 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
11 * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
12 * version 2 for more details (a copy is included in the LICENSE file that
13 * accompanied this code).
14 *
15 * You should have received a copy of the GNU General Public License version
16 * 2 along with this work; if not, write to the Free Software Foundation,
17 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
18 *
19 * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
20 * or visit www.oracle.com if you need additional information or have any
21 * questions.
22 */
23
24 package gc.g1.unloading.bytecode;
25
26 import java.io.BufferedWriter;
27 import java.io.File;
28 import java.io.FileWriter;
29 import java.io.IOException;
30 import java.util.ArrayList;
31 import java.util.List;
32
33 /*
34 * This class is compiled and invoke due the build to produce
35 * HumongousTemplateClass.java. The size of generated file is
36 * too large to store it in the repository.
37 */
38
39 public class HumongousTemplateClassGen {
40
41 private static final String CLASS_NAME = "HumongousTemplateClass";
42 private static final String PKG_NAME = "gc.g1.unloading.bytecode";
43 private static final String PKG_DIR_NAME = PKG_NAME.replace(".",
44 File.separator);
45 private static final int ITERATIONS = 1075;
46 private static final double MG = (Math.pow(1024, 2));
47 private static final int RECORD_COUNT = 16 * ITERATIONS + 10;
48
49 public static void addFileTop(List<String> records) {
50 records.add("package " + PKG_NAME + ";\n");
51 records.add("\n");
52 records.add("import java.util.*;\n");
53 records.add("\n");
54 records.add("public class " + CLASS_NAME + " {\n");
55 records.add(" public static void main() {\n");
56 records.add(" System.out.println(\"In humongous class \");\n");
57 records.add(" }");
58 records.add("\n");
59 }
60
61 public static void addIteration(int itNum, List<String> records) {
62 records.add(" public static Object public_static_object_" + itNum
63 + " = new Object();\n");
64 records.add(" protected static Object protected_static_object_" + itNum
65 + " = new Object();\n");
66 records.add(" private static Object private_static_Object_" + itNum
67 + " = new Object();\n");
68 records.add("\n");
69 records.add(" public static long public_static_long_" + itNum + ";\n");
70 records.add(" protected static long protected_static_long_" + itNum
71 + " = new Random().nextLong();\n");
72 records.add(" private static long private_static_long_" + itNum
73 + " = 42;\n");
74 records.add("\n");
75 records.add(" public Object public_object_" + itNum
76 + " = new Object();\n");
77 records.add(" protected Object protected_object_" + itNum
78 + " = new Object();\n");
79 records.add(" private Object private_Object_" + itNum
80 + " = new Object();\n");
81 records.add("\n");
82 records.add(" public long public_long_" + itNum + " = 43;\n");
83 records.add(" protected long protected_long_" + itNum + " = 44;\n");
84 records.add(" private long private_long_" + itNum
85 + " = new Random().nextLong();\n");
86 }
87 public static void main(String[] args) throws Exception {
88 if (args.length < 1) {
89 System.out.println("Usage: HumongousTemplateClassGen "
90 + "<vm-testbase_src_folder>");
91 return;
92 }
93
94 List<String> records = new ArrayList<String>(RECORD_COUNT);
95 addFileTop(records);
96 for (int i = 1; i < ITERATIONS; i++) {
97 addIteration(i, records);
98 }
99 records.add("}");
100 writeBuffered(records, (int) (MG * 1), args[0]);
101 }
102
103 private static void writeBuffered(List<String> records, int bufSize,
104 String srcDir) throws IOException {
105 String path = srcDir + File.separator + PKG_DIR_NAME + File.separator
|
1 /*
2 * Copyright (c) 2015, 2020, Oracle and/or its affiliates. All rights reserved.
3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
4 *
5 * This code is free software; you can redistribute it and/or modify it
6 * under the terms of the GNU General Public License version 2 only, as
7 * published by the Free Software Foundation.
8 *
9 * This code is distributed in the hope that it will be useful, but WITHOUT
10 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
11 * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
12 * version 2 for more details (a copy is included in the LICENSE file that
13 * accompanied this code).
14 *
15 * You should have received a copy of the GNU General Public License version
16 * 2 along with this work; if not, write to the Free Software Foundation,
17 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
18 *
19 * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
20 * or visit www.oracle.com if you need additional information or have any
21 * questions.
22 */
23
24 package gc.g1.unloading.bytecode;
25
26 import java.io.BufferedWriter;
27 import java.io.File;
28 import java.io.FileWriter;
29 import java.io.IOException;
30 import java.util.ArrayList;
31 import java.util.List;
32 import java.util.Random;
33 import jdk.test.lib.Utils;
34
35 /*
36 * This class is compiled and invoke due the build to produce
37 * HumongousTemplateClass.java. The size of generated file is
38 * too large to store it in the repository.
39 */
40
41 public class HumongousTemplateClassGen {
42
43 private static final String CLASS_NAME = "HumongousTemplateClass";
44 private static final String PKG_NAME = "gc.g1.unloading.bytecode";
45 private static final String PKG_DIR_NAME = PKG_NAME.replace(".",
46 File.separator);
47 private static final int ITERATIONS = 1075;
48 private static final double MG = (Math.pow(1024, 2));
49 private static final int RECORD_COUNT = 16 * ITERATIONS + 10;
50
51 public static void addFileTop(List<String> records) {
52 records.add("package " + PKG_NAME + ";\n");
53 records.add("\n");
54 records.add("import java.util.*;\n");
55 records.add("\n");
56 records.add("public class " + CLASS_NAME + " {\n");
57 records.add(" public static void main() {\n");
58 records.add(" System.out.println(\"In humongous class \");\n");
59 records.add(" }");
60 records.add("\n");
61 }
62
63 public static void addIteration(int itNum, List<String> records) {
64 Random rng = Utils.getRandomInstance();
65 records.add(" public static Object public_static_object_" + itNum
66 + " = new Object();\n");
67 records.add(" protected static Object protected_static_object_" + itNum
68 + " = new Object();\n");
69 records.add(" private static Object private_static_Object_" + itNum
70 + " = new Object();\n");
71 records.add("\n");
72 records.add(" public static long public_static_long_" + itNum + ";\n");
73 records.add(" protected static long protected_static_long_" + itNum
74 + " = " + rng.nextLong() + "L;\n");
75 records.add(" private static long private_static_long_" + itNum
76 + " = 42;\n");
77 records.add("\n");
78 records.add(" public Object public_object_" + itNum
79 + " = new Object();\n");
80 records.add(" protected Object protected_object_" + itNum
81 + " = new Object();\n");
82 records.add(" private Object private_Object_" + itNum
83 + " = new Object();\n");
84 records.add("\n");
85 records.add(" public long public_long_" + itNum + " = 43;\n");
86 records.add(" protected long protected_long_" + itNum + " = 44;\n");
87 records.add(" private long private_long_" + itNum
88 + " = " + rng.nextLong() + "L;\n");
89 }
90 public static void main(String[] args) throws Exception {
91 if (args.length < 1) {
92 System.out.println("Usage: HumongousTemplateClassGen "
93 + "<vm-testbase_src_folder>");
94 return;
95 }
96
97 List<String> records = new ArrayList<String>(RECORD_COUNT);
98 addFileTop(records);
99 for (int i = 1; i < ITERATIONS; i++) {
100 addIteration(i, records);
101 }
102 records.add("}");
103 writeBuffered(records, (int) (MG * 1), args[0]);
104 }
105
106 private static void writeBuffered(List<String> records, int bufSize,
107 String srcDir) throws IOException {
108 String path = srcDir + File.separator + PKG_DIR_NAME + File.separator
|