Path: blob/aarch64-shenandoah-jdk8u272-b10/jdk/test/com/sun/jdi/ArrayLengthDumpTest.sh
38855 views
#!/bin/sh12#3# Copyright (c) 2002, Oracle and/or its affiliates. All rights reserved.4# DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.5#6# This code is free software; you can redistribute it and/or modify it7# under the terms of the GNU General Public License version 2 only, as8# published by the Free Software Foundation.9#10# This code is distributed in the hope that it will be useful, but WITHOUT11# ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or12# FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License13# version 2 for more details (a copy is included in the LICENSE file that14# accompanied this code).15#16# You should have received a copy of the GNU General Public License version17# 2 along with this work; if not, write to the Free Software Foundation,18# Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.19#20# Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA21# or visit www.oracle.com if you need additional information or have any22# questions.23#2425#26# @test27# @bug 4422141 469533828# @summary TTY: .length field for arrays in print statements in jdb not recognized29# TTY: dump <ArrayReference> command not implemented.30# @author Tim Bell31#32# @run shell ArrayLengthDumpTest.sh33#34classname=ArrayLengthDumpTarg3536createJavaFile()37{38cat <<EOF > $classname.java.139class $classname {40static final int [] i = {0,1,2,3,4,5,6};41String [] s = {"zero", "one", "two", "three", "four"};42String [][] t = {s, s, s, s, s, s, s, s, s, s, s};43int length = 5;4445public void bar() {46}4748public void foo() {49ArrayLengthDumpTarg u[] = { new ArrayLengthDumpTarg(),50new ArrayLengthDumpTarg(),51new ArrayLengthDumpTarg(),52new ArrayLengthDumpTarg(),53new ArrayLengthDumpTarg(),54new ArrayLengthDumpTarg() };55int k = u.length;56System.out.println(" u.length is: " + k);57k = this.s.length;58System.out.println(" this.s.length is: " + k);59k = this.t.length;60System.out.println(" this.t.length is: " + k);61k = this.t[1].length;62System.out.println("this.t[1].length is: " + k);63k = i.length;64System.out.println(" i.length is: " + k);65bar(); // @1 breakpoint66}6768public static void main(String[] args) {69ArrayLengthDumpTarg my = new ArrayLengthDumpTarg();70my.foo();71}72}73EOF74}7576# This is called to feed cmds to jdb.77dojdbCmds()78{79setBkpts @180runToBkpt @181cmd dump this82cmd dump this.s.length83cmd dump this.s84cmd dump this.t.length85cmd dump this.t[1].length86cmd dump ArrayLengthDumpTarg.i.length87cmd dump this.length88cmd cont89}9091mysetup()92{93if [ -z "$TESTSRC" ] ; then94TESTSRC=.95fi9697for ii in . $TESTSRC $TESTSRC/.. ; do98if [ -r "$ii/ShellScaffold.sh" ] ; then99. $ii/ShellScaffold.sh100break101fi102done103}104105106# You could replace this next line with the contents107# of ShellScaffold.sh and this script will run just the same.108mysetup109110runit111#112# Test the fix for 4690242:113#114jdbFailIfPresent "No instance field or method with the name length in" 50115jdbFailIfPresent "No static field or method with the name length" 50116#117# Test the fix for 4695338:118#119jdbFailIfNotPresent "\"zero\", \"one\", \"two\", \"three\", \"four\"" 50120pass121122123