Path: blob/master/test/hotspot/jtreg/compiler/jvmci/common/testcases/MultipleImplementer2.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 class MultipleImplementer2 implements MultipleImplementersInterface {2930// Different access levels on the fields of this class are used on purpose.31// It is needed to verify jdk.vm.ci.CompilerToVM constant pool related32// methods, e.g. resolveFieldInPool.3334private static int intStaticField = INT_CONSTANT;35final static long longStaticField = LONG_CONSTANT;36volatile static float floatStaticField = FLOAT_CONSTANT;37static double doubleStaticField = DOUBLE_CONSTANT;38public static String stringStaticField = STRING_CONSTANT;39protected static Object objectStaticField = OBJECT_CONSTANT;4041public int intField = INT_CONSTANT;42private long longField = LONG_CONSTANT;43protected float floatField = FLOAT_CONSTANT;44transient double doubleField = DOUBLE_CONSTANT;45volatile String stringField = STRING_CONSTANT;46String stringFieldEmpty = "";47final Object objectField;4849public MultipleImplementer2() {50intField = Integer.MAX_VALUE;51longField = Long.MAX_VALUE;52floatField = Float.MAX_VALUE;53doubleField = Double.MAX_VALUE;54stringField = "Message";55objectField = new Object();56}5758@Override59public void testMethod() {60// empty61}6263@Override64public void finalize() throws Throwable {65super.finalize();66}6768public void lambdaUsingMethod2() {69Thread t = new Thread(this::testMethod);70t.start();71}7273/**74* This method is needed to have "getstatic" and "getfield" instructions75* in the class. These instructions are needed to test76* resolveFieldInPool method, because it needs a bytecode as one of its arguments.77*/78public void printFileds() {79System.out.println(intStaticField);80System.out.println(longStaticField);81System.out.println(floatStaticField);82System.out.println(doubleStaticField);83System.out.println(stringStaticField);84System.out.println(objectStaticField);85System.out.println(intField);86System.out.println(longField);87System.out.println(floatField);88System.out.println(doubleField);89System.out.println(stringField);90System.out.println(stringFieldEmpty);91System.out.println(objectField);92}9394public static void staticMethod() {95System.getProperties(); // calling some static method96Map map = new HashMap(); // calling some constructor97map.put(OBJECT_CONSTANT, OBJECT_CONSTANT); // calling some interface method98map.remove(OBJECT_CONSTANT); // calling some default interface method99}100101@Override102public void instanceMethod() {103toString(); // calling some virtual method104super.toString(); // calling some special method105}106107@Override108public void anonClassMethod() {109new Runnable() {110@Override111public void run() {112System.out.println("Running");113}114}.run();115}116}117118119