Path: blob/aarch64-shenandoah-jdk8u272-b10/jdk/test/demo/jvmti/hprof/HelloWorld.java
38840 views
/*1* Copyright (c) 2004, 2009, Oracle and/or its affiliates. All rights reserved.2* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.3*4* This code is free software; you can redistribute it and/or modify it5* under the terms of the GNU General Public License version 2 only, as6* published by the Free Software Foundation.7*8* This code is distributed in the hope that it will be useful, but WITHOUT9* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or10* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License11* version 2 for more details (a copy is included in the LICENSE file that12* accompanied this code).13*14* You should have received a copy of the GNU General Public License version15* 2 along with this work; if not, write to the Free Software Foundation,16* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.17*18* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA19* or visit www.oracle.com if you need additional information or have any20* questions.21*/222324/* HelloWorld:25*26* Sample target application for HPROF tests27*28*/2930/* Just some classes that create a variety of references */3132class AAAA {33public int AAAA_i;34public static int AAAA_si;35public Object AAAA_j;36public static Object AAAA_sj;37public long AAAA_k;38public static long AAAA_sk;39}4041interface IIII {42Object o = new Object();43}4445class BBBB extends AAAA implements IIII {46public byte BBBB_ii;47public static byte BBBB_sii;48public Object BBBB_jj;49public static Object BBBB_sjj;50public short BBBB_kk;51public static short BBBB_skk;52}5354class REFS {55private static String s1 = new String("REFS_string1");56private String is2 = new String("REFS_string2");57private static String s3 = new String("REFS_string3");58private static String s4 = new String("REFS_string4");59private String is5 = new String("REFS_string5");6061private AAAA aaaa;62private BBBB bbbb;6364public void test() {65aaaa = new AAAA();66bbbb = new BBBB();6768aaaa.AAAA_i = 1;69AAAA.AAAA_si = 2;70aaaa.AAAA_j = s1;71AAAA.AAAA_sj = is2;72aaaa.AAAA_k = 5;73AAAA.AAAA_sk = 6;7475bbbb.BBBB_ii = 11;76BBBB.BBBB_sii = 22;77bbbb.BBBB_jj = s3;78BBBB.BBBB_sjj = s4;79bbbb.BBBB_kk = 55;80BBBB.BBBB_skk = 66;8182bbbb.AAAA_i = 111;83bbbb.AAAA_j = is5;84bbbb.AAAA_k = 555;85}86}8788/* Fairly simple hello world program that does some exercises first. */8990public class HelloWorld {91public static void main(String args[]) {9293/* References exercise. */94REFS r = new REFS();95r.test();9697/* Use a generic type exercise. */98java.util.List<String> l = new java.util.ArrayList<String>();99String.format("%s", "");100101/* Create a class that has lots of different bytecodes exercise. */102/* (Don't run it!) */103UseAllBytecodes x = new UseAllBytecodes(1,2);104105/* Just some code with branches exercise. */106try {107if ( args.length == 0 ) {108System.out.println("No arguments passed in (doesn't matter)");109} else {110System.out.println("Arguments passed in (doesn't matter)");111}112} catch ( Throwable e ) {113System.out.println("ERROR: System.out.println() did a throw");114} finally {115System.out.println("Hello, world!");116}117}118}119120121