Path: blob/master/test/hotspot/jtreg/compiler/jvmci/common/testcases/MultipleAbstractImplementer.java
41161 views
/*1* Copyright (c) 2015, 2016, 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*/2223package compiler.jvmci.common.testcases;2425import java.util.HashMap;26import java.util.Map;2728public abstract class MultipleAbstractImplementer29implements MultipleImplementersInterface {3031// Different access levels on the fields of this class are used on purpose.32// It is needed to verify jdk.vm.ci.CompilerToVM constant pool related33// methods, e.g. resolveFieldInPool.3435private static int intStaticField = INT_CONSTANT;36final static long longStaticField = LONG_CONSTANT;37volatile static float floatStaticField = FLOAT_CONSTANT;38static double doubleStaticField = DOUBLE_CONSTANT;39public static String stringStaticField = STRING_CONSTANT;40protected static Object objectStaticField = OBJECT_CONSTANT;4142public int intField = INT_CONSTANT;43private long longField = LONG_CONSTANT;44protected float floatField = FLOAT_CONSTANT;45transient double doubleField = DOUBLE_CONSTANT;46volatile String stringField = STRING_CONSTANT;47String stringFieldEmpty = "";48final Object objectField;4950public MultipleAbstractImplementer() {51intField = Integer.MAX_VALUE;52longField = Long.MAX_VALUE;53floatField = Float.MAX_VALUE;54doubleField = Double.MAX_VALUE;55stringField = "Message";56objectField = new Object();57}5859public abstract void abstractMethod();6061@Override62public void finalize() throws Throwable {63super.finalize();64}6566public void lambdaUsingMethod2() {67Thread t = new Thread(this::testMethod);68t.start();69}7071/**72* This method is needed to have "getstatic" and "getfield" instructions73* in the class. These instructions are needed to test74* resolveFieldInPool method, because it needs a bytecode as one of its arguments.75*/76public void printFileds() {77System.out.println(intStaticField);78System.out.println(longStaticField);79System.out.println(floatStaticField);80System.out.println(doubleStaticField);81System.out.println(stringStaticField);82System.out.println(objectStaticField);83System.out.println(intField);84System.out.println(longField);85System.out.println(floatField);86System.out.println(doubleField);87System.out.println(stringField);88System.out.println(stringFieldEmpty);89System.out.println(objectField);90}9192public static void staticMethod() {93System.getProperties(); // calling some static method94Map map = new HashMap(); // calling some constructor95map.put(OBJECT_CONSTANT, OBJECT_CONSTANT); // calling some interface method96map.remove(OBJECT_CONSTANT); // calling some default interface method97}9899@Override100public void instanceMethod() {101toString(); // calling some virtual method102super.toString(); // calling some special method103}104105@Override106public void anonClassMethod() {107new Runnable() {108@Override109public void run() {110System.out.println("Running");111}112}.run();113}114}115116117