Path: blob/master/test/hotspot/jtreg/vmTestbase/vm/mlvm/meth/share/Argument.java
41162 views
/*1* Copyright (c) 2011, 2018, 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 vm.mlvm.meth.share;2425import nsk.share.test.TestUtils;2627public class Argument {2829private final Class<?> type;30private final Object value;31private boolean isPreserved;32private String tag;3334public Argument(Class<?> type, Object value) {35this(type, value, false, "");36}3738public Argument(Class<?> type, Object value, boolean isPreserved, String tag) {39this.type = type;40this.value = value;41this.isPreserved = isPreserved;42this.tag = tag;43}4445public Class<?> getType() {46return this.type;47}4849public Object getValue() {50return this.value;51}5253public void setPreserved(boolean newValue) {54this.isPreserved = newValue;55}5657public boolean isPreserved() {58return this.isPreserved;59}6061public String getTag() {62return this.tag;63}6465public void setTag(String newTag) {66this.tag = newTag;67}6869public static Argument fromValue(Object value) {70return new Argument(value.getClass(), value);71}7273public static Argument fromPrimitiveValue(Object boxedValue) {74TestUtils.assertInCollection(TestTypes.UNBOX_MAP.keySet(), boxedValue.getClass());75return new Argument(TestTypes.UNBOX_MAP.get(boxedValue.getClass()), boxedValue);76}7778public static Argument fromArray(Object[] a) {79boolean isProtected = false;80if ( a.length > 2 && a[2].getClass().equals(Boolean.class) )81isProtected = (Boolean) a[2];8283return new Argument((Class<?>) a[0], a[1], isProtected, "");84}8586@Override87public String toString() {88return getType().getName().replaceFirst("^java.lang.", "") + "="89+ (getType().equals(String.class) ? "{" + getValue() + "}" : getValue() == null ? "null" : getValue() )90+ ((! getTag().isEmpty() || isPreserved()) ? ("[" + (isPreserved() ? "!" : "") + getTag() + "]") : "");91}9293@Override94public Argument clone() {95return new Argument(getType(), getValue(), isPreserved(), getTag());96}97}9899100