1 /* 2 * Copyright (c) 2004, 2018, Oracle and/or its affiliates. All rights reserved. 3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. 4 * 5 * This code is free software; you can redistribute it and/or modify it 6 * under the terms of the GNU General Public License version 2 only, as 7 * published by the Free Software Foundation. 8 * 9 * This code is distributed in the hope that it will be useful, but WITHOUT 10 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or 11 * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License 12 * version 2 for more details (a copy is included in the LICENSE file that 13 * accompanied this code). 14 * 15 * You should have received a copy of the GNU General Public License version 16 * 2 along with this work; if not, write to the Free Software Foundation, 17 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. 18 * 19 * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA 20 * or visit www.oracle.com if you need additional information or have any 21 * questions. 22 */ 23 24 package nsk.jvmti.scenarios.allocation.AP05; 25 26 import java.io.*; 27 import java.lang.reflect.*; 28 29 import nsk.share.*; 30 import nsk.share.jvmti.*; 31 32 public class ap05t001 extends DebugeeClass { main(String[] argv)33 public static void main(String[] argv) { 34 argv = nsk.share.jvmti.JVMTITest.commonInit(argv); 35 36 // produce JCK-like exit status 37 System.exit(run(argv, System.out) + Consts.JCK_STATUS_BASE); 38 } 39 run(String argv[], PrintStream out)40 public static int run(String argv[], PrintStream out) { 41 return new ap05t001().runThis(argv, out); 42 } 43 setTag(Object target, long tag)44 public static native void setTag(Object target, long tag); setReferrer(Object referrer)45 public static native void setReferrer(Object referrer); 46 47 /* scaffold objects */ 48 static ArgumentHandler argHandler = null; 49 static Log log = null; 50 static long timeout = 0; 51 int status = Consts.TEST_PASSED; 52 53 ap05t001Subclass referrer; 54 public static final long CLS_TAG = 1l, REFERRER_TAG = 2l, REFERREE_TAG = 10l; 55 runThis(String argv[], PrintStream out)56 private int runThis(String argv[], PrintStream out) { 57 argHandler = new ArgumentHandler(argv); 58 log = new Log(out, argHandler); 59 timeout = argHandler.getWaitTime() * 60 * 1000; // milliseconds 60 61 referrer = new ap05t001Subclass(); 62 setTag(ap05t001Subclass.class, CLS_TAG); 63 setTag(referrer, REFERRER_TAG); 64 65 setTag(ap05t001Interface.referree01, REFERREE_TAG); 66 67 referrer.setFields(ap05t001Interface.referree01); 68 referrer.setSubFields(ap05t001Interface.referree01); 69 70 setReferrer(referrer); 71 72 status = checkStatus(status); 73 return status; 74 } 75 } 76 77 class ap05t001Superclass { 78 static private Object referree11; 79 static private Object referree12; 80 static protected Object referree13; 81 static protected Object referree14; 82 static public Object referree15; 83 static public Object referree16; 84 static Object referree17; 85 static Object referree18; 86 87 private Object referree21; 88 private Object referree22; 89 protected Object referree23; 90 protected Object referree24; 91 public Object referree25; 92 public Object referree26; 93 Object referree27; 94 Object referree28; 95 setFields(Object value)96 void setFields(Object value) { 97 referree11 = value; 98 referree12 = value; 99 referree13 = value; 100 referree14 = value; 101 referree15 = value; 102 referree16 = value; 103 referree17 = value; 104 referree18 = value; 105 106 referree21 = value; 107 referree22 = value; 108 referree23 = value; 109 referree24 = value; 110 referree25 = value; 111 referree26 = value; 112 referree27 = value; 113 referree28 = value; 114 } 115 } 116 117 interface ap05t001Interface { 118 static public Object referree01 = new Object(); 119 static public Object referree02 = referree01; 120 } 121 122 class ap05t001Subclass extends ap05t001Superclass implements ap05t001Interface { 123 124 static private Object referree31; 125 static private Object referree32; 126 static protected Object referree33; 127 static protected Object referree34; 128 static public Object referree35; 129 static public Object referree36; 130 static Object referree37; 131 static Object referree38; 132 133 private Object referree41; 134 private Object referree42; 135 protected Object referree43; 136 protected Object referree44; 137 public Object referree45; 138 public Object referree46; 139 Object referree47; 140 Object referree48; 141 setSubFields(Object value)142 void setSubFields(Object value) { 143 referree31 = value; 144 referree32 = value; 145 referree33 = value; 146 referree34 = value; 147 referree35 = value; 148 referree36 = value; 149 referree37 = value; 150 referree38 = value; 151 152 referree41 = value; 153 referree42 = value; 154 referree43 = value; 155 referree44 = value; 156 referree45 = value; 157 referree46 = value; 158 referree47 = value; 159 referree48 = value; 160 } 161 } 162