0N/A/*
2362N/A * Copyright (c) 1996, 2005, Oracle and/or its affiliates. All rights reserved.
0N/A * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
0N/A *
0N/A * This code is free software; you can redistribute it and/or modify it
0N/A * under the terms of the GNU General Public License version 2 only, as
0N/A * published by the Free Software Foundation.
0N/A *
0N/A * This code is distributed in the hope that it will be useful, but WITHOUT
0N/A * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
0N/A * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
0N/A * version 2 for more details (a copy is included in the LICENSE file that
0N/A * accompanied this code).
0N/A *
0N/A * You should have received a copy of the GNU General Public License version
0N/A * 2 along with this work; if not, write to the Free Software Foundation,
0N/A * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
0N/A *
2362N/A * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
2362N/A * or visit www.oracle.com if you need additional information or have any
2362N/A * questions.
0N/A */
0N/A/*
0N/A A simple Java class definition that helps self-test the runtime
0N/A interpreter. Used for getfield/putfield, invoke* opcodes and
0N/A their _quick variants.
0N/A
0N/A See src/share/java/runtime/selftest.c for details of the test
0N/A environment.
0N/A*/
0N/A
0N/A/* Used to be sun/misc/SelfTest.java */
0N/A
0N/Ainterface UseAllBytecodesInterface
0N/A{
0N/A public void test_an_interface(int p1);
0N/A}
0N/A
0N/Apublic class UseAllBytecodes implements UseAllBytecodesInterface
0N/A{
0N/A public int i1, i2;
0N/A public float f1, f2;
0N/A public double d1, d2;
0N/A public long l1, l2;
0N/A
0N/A public static int si1, si2;
0N/A public static float sf1, sf2;
0N/A public static double sd1, sd2;
0N/A public static long sl1, sl2;
0N/A
0N/A public UseAllBytecodesInterface interfaceObject;
0N/A
0N/A public int multi[][][];
0N/A
0N/A public UseAllBytecodes()
0N/A {
0N/A /* This constructor is not intended to ever be run. It is here
0N/A to force CONSTANT_Methodref constants into the CP */
0N/A set_i1(11);
0N/A set_i2(22);
0N/A set_f1(1.1f);
0N/A set_f2(2.2f);
0N/A set_d1(1.0);
0N/A set_d2(2.0);
0N/A set_l1(3);
0N/A set_l2(4);
0N/A
0N/A set_si1(33);
0N/A set_si2(44);
0N/A set_sf1(3.3f);
0N/A set_sf2(4.4f);
0N/A set_sd1(3.0);
0N/A set_sd2(4.0);
0N/A set_sl1(5);
0N/A set_sl2(6);
0N/A
0N/A test_areturn();
0N/A test_athrow1();
0N/A test_athrow2();
0N/A test_athrow3();
0N/A test_athrow4();
0N/A
0N/A /* This puts a CONSTANT_InterfaceMethodref into the CP */
0N/A interfaceObject.test_an_interface(1234);
0N/A
0N/A /* This creates an array and puts it into the CP */
0N/A multi = new int[2][3][4];
0N/A }
0N/A
0N/A public UseAllBytecodes(int p1)
0N/A {
0N/A i1 = p1;
0N/A i2 = 12345678; /* This puts a CONSTANT_Integer into the CP */
0N/A d1 = (double) p1;
0N/A d2 = 1.2e234; /* This puts a CONSTANT_Double into the CP */
0N/A }
0N/A
0N/A public UseAllBytecodes(int p1, int p2)
0N/A {
0N/A i1 = p1;
0N/A i2 = p2;
0N/A }
0N/A
0N/A /* These methods should return something other than their
0N/A arguments, so the self test can easily determine that
0N/A the correct value was returned. */
0N/A public int set_i1(int p1)
0N/A {
0N/A i1 = p1;
0N/A return i1 + 1;
0N/A }
0N/A
0N/A public int set_i2(int p2)
0N/A {
0N/A i2 = p2;
0N/A return i2 + 1;
0N/A }
0N/A
0N/A public float set_f1(float p1)
0N/A {
0N/A f1 = p1;
0N/A return f1 + 1.0e34f;
0N/A }
0N/A
0N/A public float set_f2(float p2)
0N/A {
0N/A f2 = p2;
0N/A return f2 + 1.0e34f;
0N/A }
0N/A
0N/A public double set_d1(double p1)
0N/A {
0N/A d1 = p1;
0N/A return d1 + 1.0e234;
0N/A }
0N/A
0N/A public double set_d2(double p2)
0N/A {
0N/A d2 = p2;
0N/A return d2 + 1.0e234;
0N/A }
0N/A
0N/A public long set_l1(long p1)
0N/A {
0N/A l1 = p1;
0N/A return l1 + 1;
0N/A }
0N/A
0N/A public long set_l2(long p2)
0N/A {
0N/A l2 = p2;
0N/A return l2 + 1;
0N/A }
0N/A
0N/A public static void set_si1(int p1)
0N/A {
0N/A si1 = p1;
0N/A }
0N/A
0N/A public static void set_si2(int p2)
0N/A {
0N/A si2 = p2;
0N/A }
0N/A
0N/A public static void set_sf1(float p1)
0N/A {
0N/A sf1 = p1;
0N/A }
0N/A
0N/A public static void set_sf2(float p2)
0N/A {
0N/A sf2 = p2;
0N/A }
0N/A
0N/A public static void set_sd1(double p1)
0N/A {
0N/A sd1 = p1;
0N/A }
0N/A
0N/A public static void set_sd2(double p2)
0N/A {
0N/A sd2 = p2;
0N/A }
0N/A
0N/A public static void set_sl1(long p1)
0N/A {
0N/A sl1 = p1;
0N/A }
0N/A
0N/A public static void set_sl2(long p2)
0N/A {
0N/A sl2 = p2;
0N/A }
0N/A
0N/A public UseAllBytecodes test_areturn()
0N/A {
0N/A return this;
0N/A }
0N/A
0N/A /* This method does the same thing as set_i1.
0N/A It is here to test the invokeinterface opcode. */
0N/A public void test_an_interface(int p1)
0N/A {
0N/A i1 = p1;
0N/A }
0N/A
0N/A /* The following 10 methods test various permutations of
0N/A try-and-catch. */
0N/A public static void test_athrow1() throws NullPointerException
0N/A {
0N/A try
0N/A {
0N/A si1 = -1;
0N/A throw new NullPointerException();
0N/A }
0N/A catch (Exception e)
0N/A {
0N/A si1 = 1;
0N/A }
0N/A }
0N/A
0N/A public static void test_athrow2()
0N/A {
0N/A int i = 1;
0N/A try
0N/A {
0N/A si1 = -1;
0N/A test_athrow1();
0N/A }
0N/A catch (Exception e)
0N/A {
0N/A // This should *not* catch the exception;
0N/A // should be caught in test_athrow1.
0N/A si1 = i + 1;
0N/A }
0N/A }
0N/A
0N/A public static void test_athrow3()
0N/A {
0N/A int i = 1;
0N/A try
0N/A {
0N/A // Ultimately throws NullPointerException
0N/A si1 = -1;
0N/A si2 = -1;
0N/A test_athrow5();
0N/A }
0N/A catch (NullPointerException np)
0N/A {
0N/A si1 = i + 1;
0N/A }
0N/A catch (NoSuchMethodException e)
0N/A {
0N/A si2 = i + 1;
0N/A }
0N/A si1++; // total is 3
0N/A }
0N/A
0N/A public static void test_athrow4()
0N/A {
0N/A int i = 2;
0N/A try
0N/A {
0N/A // Ultimately throws NoSuchMethodException
0N/A si1 = -1;
0N/A si2 = -1;
0N/A test_athrow7();
0N/A }
0N/A catch (NullPointerException e)
0N/A {
0N/A si1 = i + 1;
0N/A }
0N/A catch (NoSuchMethodException nsm)
0N/A {
0N/A si2 = i + 1;
0N/A }
0N/A si2++; // total is 4
0N/A }
0N/A
0N/A public static void test_throw_nosuchmethod() throws NoSuchMethodException
0N/A {
0N/A throw new NoSuchMethodException();
0N/A }
0N/A
0N/A public static void test_throw_nullpointer() throws NullPointerException
0N/A {
0N/A throw new NullPointerException();
0N/A }
0N/A
0N/A public static void test_athrow5() throws NullPointerException, NoSuchMethodException
0N/A {
0N/A test_athrow6();
0N/A }
0N/A
0N/A public static void test_athrow6() throws NullPointerException, NoSuchMethodException
0N/A {
0N/A test_throw_nullpointer();
0N/A }
0N/A
0N/A public static void test_athrow7() throws NullPointerException, NoSuchMethodException
0N/A {
0N/A test_athrow8();
0N/A }
0N/A
0N/A public static void test_athrow8() throws NullPointerException, NoSuchMethodException
0N/A {
0N/A test_throw_nosuchmethod();
0N/A }
0N/A}