2
|
1 |
/*
|
|
2 |
* Copyright 2004-2005 Sun Microsystems, Inc. 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 Sun Microsystems, Inc., 4150 Network Circle, Santa Clara,
|
|
20 |
* CA 95054 USA or visit www.sun.com if you need additional information or
|
|
21 |
* have any questions.
|
|
22 |
*/
|
|
23 |
|
|
24 |
|
|
25 |
/* HelloWorld:
|
|
26 |
*
|
|
27 |
* Sample target appluication for HPROF tests
|
|
28 |
*
|
|
29 |
*/
|
|
30 |
|
|
31 |
/* Just some classes that create a variety of references */
|
|
32 |
|
|
33 |
class AAAA {
|
|
34 |
public int AAAA_i;
|
|
35 |
public static int AAAA_si;
|
|
36 |
public Object AAAA_j;
|
|
37 |
public static Object AAAA_sj;
|
|
38 |
public long AAAA_k;
|
|
39 |
public static long AAAA_sk;
|
|
40 |
}
|
|
41 |
|
|
42 |
interface IIII {
|
|
43 |
Object o = new Object();
|
|
44 |
}
|
|
45 |
|
|
46 |
class BBBB extends AAAA implements IIII {
|
|
47 |
public byte BBBB_ii;
|
|
48 |
public static byte BBBB_sii;
|
|
49 |
public Object BBBB_jj;
|
|
50 |
public static Object BBBB_sjj;
|
|
51 |
public short BBBB_kk;
|
|
52 |
public static short BBBB_skk;
|
|
53 |
}
|
|
54 |
|
|
55 |
class REFS {
|
|
56 |
private static String s1 = new String("REFS_string1");
|
|
57 |
private String is2 = new String("REFS_string2");
|
|
58 |
private static String s3 = new String("REFS_string3");
|
|
59 |
private static String s4 = new String("REFS_string4");
|
|
60 |
private String is5 = new String("REFS_string5");
|
|
61 |
|
|
62 |
private AAAA aaaa;
|
|
63 |
private BBBB bbbb;
|
|
64 |
|
|
65 |
public void test() {
|
|
66 |
aaaa = new AAAA();
|
|
67 |
bbbb = new BBBB();
|
|
68 |
|
|
69 |
aaaa.AAAA_i = 1;
|
|
70 |
AAAA.AAAA_si = 2;
|
|
71 |
aaaa.AAAA_j = s1;
|
|
72 |
AAAA.AAAA_sj = is2;
|
|
73 |
aaaa.AAAA_k = 5;
|
|
74 |
AAAA.AAAA_sk = 6;
|
|
75 |
|
|
76 |
bbbb.BBBB_ii = 11;
|
|
77 |
BBBB.BBBB_sii = 22;
|
|
78 |
bbbb.BBBB_jj = s3;
|
|
79 |
BBBB.BBBB_sjj = s4;
|
|
80 |
bbbb.BBBB_kk = 55;
|
|
81 |
BBBB.BBBB_skk = 66;
|
|
82 |
|
|
83 |
bbbb.AAAA_i = 111;
|
|
84 |
bbbb.AAAA_j = is5;
|
|
85 |
bbbb.AAAA_k = 555;
|
|
86 |
}
|
|
87 |
}
|
|
88 |
|
|
89 |
/* Fairly simple hello world program that does some exercises first. */
|
|
90 |
|
|
91 |
public class HelloWorld {
|
|
92 |
public static void main(String args[]) {
|
|
93 |
|
|
94 |
/* References exercise. */
|
|
95 |
REFS r = new REFS();
|
|
96 |
r.test();
|
|
97 |
|
|
98 |
/* Use a generic type exercise. */
|
|
99 |
java.util.List<String> l = new java.util.ArrayList<String>();
|
|
100 |
String.format("%s", "");
|
|
101 |
|
|
102 |
/* Create a class that has lots of different bytecodes exercise. */
|
|
103 |
/* (Don't run it!) */
|
|
104 |
UseAllBytecodes x = new UseAllBytecodes(1,2);
|
|
105 |
|
|
106 |
/* Just some code with branches exercise. */
|
|
107 |
try {
|
|
108 |
if ( args.length == 0 ) {
|
|
109 |
System.out.println("No arguments passed in (doesn't matter)");
|
|
110 |
} else {
|
|
111 |
System.out.println("Arguments passed in (doesn't matter)");
|
|
112 |
}
|
|
113 |
} catch ( Throwable e ) {
|
|
114 |
System.out.println("ERROR: System.out.println() did a throw");
|
|
115 |
} finally {
|
|
116 |
System.out.println("Hello, world!");
|
|
117 |
}
|
|
118 |
}
|
|
119 |
}
|