jdk/test/com/sun/jdi/RedefineClasses.sh
author jjg
Thu, 22 May 2008 15:51:41 -0700
changeset 655 1ebc7ce89018
parent 2 90ce3da70b43
child 5506 202f599c92aa
permissions -rw-r--r--
6705945: com.sun.tools.javac.zip files do not have valid copyright Reviewed-by: mcimadamore
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
     1
#!/bin/sh
90ce3da70b43 Initial load
duke
parents:
diff changeset
     2
90ce3da70b43 Initial load
duke
parents:
diff changeset
     3
#
90ce3da70b43 Initial load
duke
parents:
diff changeset
     4
# Copyright 2002-2007 Sun Microsystems, Inc.  All Rights Reserved.
90ce3da70b43 Initial load
duke
parents:
diff changeset
     5
# DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
90ce3da70b43 Initial load
duke
parents:
diff changeset
     6
#
90ce3da70b43 Initial load
duke
parents:
diff changeset
     7
# This code is free software; you can redistribute it and/or modify it
90ce3da70b43 Initial load
duke
parents:
diff changeset
     8
# under the terms of the GNU General Public License version 2 only, as
90ce3da70b43 Initial load
duke
parents:
diff changeset
     9
# published by the Free Software Foundation.
90ce3da70b43 Initial load
duke
parents:
diff changeset
    10
#
90ce3da70b43 Initial load
duke
parents:
diff changeset
    11
# This code is distributed in the hope that it will be useful, but WITHOUT
90ce3da70b43 Initial load
duke
parents:
diff changeset
    12
# ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
90ce3da70b43 Initial load
duke
parents:
diff changeset
    13
# FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
90ce3da70b43 Initial load
duke
parents:
diff changeset
    14
# version 2 for more details (a copy is included in the LICENSE file that
90ce3da70b43 Initial load
duke
parents:
diff changeset
    15
# accompanied this code).
90ce3da70b43 Initial load
duke
parents:
diff changeset
    16
#
90ce3da70b43 Initial load
duke
parents:
diff changeset
    17
# You should have received a copy of the GNU General Public License version
90ce3da70b43 Initial load
duke
parents:
diff changeset
    18
# 2 along with this work; if not, write to the Free Software Foundation,
90ce3da70b43 Initial load
duke
parents:
diff changeset
    19
# Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
90ce3da70b43 Initial load
duke
parents:
diff changeset
    20
#
90ce3da70b43 Initial load
duke
parents:
diff changeset
    21
# Please contact Sun Microsystems, Inc., 4150 Network Circle, Santa Clara,
90ce3da70b43 Initial load
duke
parents:
diff changeset
    22
# CA 95054 USA or visit www.sun.com if you need additional information or
90ce3da70b43 Initial load
duke
parents:
diff changeset
    23
# have any questions.
90ce3da70b43 Initial load
duke
parents:
diff changeset
    24
#
90ce3da70b43 Initial load
duke
parents:
diff changeset
    25
90ce3da70b43 Initial load
duke
parents:
diff changeset
    26
#  @test
90ce3da70b43 Initial load
duke
parents:
diff changeset
    27
#  @bug 4628760
90ce3da70b43 Initial load
duke
parents:
diff changeset
    28
#  @summary RedefineClasses gets assertion: "Should be a method entry in cpcache!"
90ce3da70b43 Initial load
duke
parents:
diff changeset
    29
#  @author jjh
90ce3da70b43 Initial load
duke
parents:
diff changeset
    30
#
90ce3da70b43 Initial load
duke
parents:
diff changeset
    31
#  @run shell/timeout=180 RedefineClasses.sh
90ce3da70b43 Initial load
duke
parents:
diff changeset
    32
90ce3da70b43 Initial load
duke
parents:
diff changeset
    33
# On windows, with b90, this gets this:
90ce3da70b43 Initial load
duke
parents:
diff changeset
    34
# assert(u2_at_bcp >= 0 && u2_at_bcp < old_cache->length(), "Bad cpcache index!")
90ce3da70b43 Initial load
duke
parents:
diff changeset
    35
#
90ce3da70b43 Initial load
duke
parents:
diff changeset
    36
# Error happened during: VM_RedefineClasses
90ce3da70b43 Initial load
duke
parents:
diff changeset
    37
#
90ce3da70b43 Initial load
duke
parents:
diff changeset
    38
# Error ID: D:/jdk1.4/hotspot\src\share\vm\prims\jvmdi_hotswap.cpp, 331
90ce3da70b43 Initial load
duke
parents:
diff changeset
    39
90ce3da70b43 Initial load
duke
parents:
diff changeset
    40
# On solaris, and on windows with 4559100 fixed, this test fails with:
90ce3da70b43 Initial load
duke
parents:
diff changeset
    41
#
90ce3da70b43 Initial load
duke
parents:
diff changeset
    42
# HotSpot Virtual Machine Error, assertion failure
90ce3da70b43 Initial load
duke
parents:
diff changeset
    43
# Please report this error at
90ce3da70b43 Initial load
duke
parents:
diff changeset
    44
# http://java.sun.com/cgi-bin/bugreport.cgi
90ce3da70b43 Initial load
duke
parents:
diff changeset
    45
#
90ce3da70b43 Initial load
duke
parents:
diff changeset
    46
# Java VM: Java HotSpot(TM) Client VM (1.4-internal-debug mixed mode)
90ce3da70b43 Initial load
duke
parents:
diff changeset
    47
#
90ce3da70b43 Initial load
duke
parents:
diff changeset
    48
# assert(old_cache->entry_at(u2_at_bcp)->is_method_entry(), "Should be a method entry in cpcache!")
90ce3da70b43 Initial load
duke
parents:
diff changeset
    49
#
90ce3da70b43 Initial load
duke
parents:
diff changeset
    50
# Error happened during: VM_RedefineClasses
90ce3da70b43 Initial load
duke
parents:
diff changeset
    51
#
90ce3da70b43 Initial load
duke
parents:
diff changeset
    52
# Error ID: M:\ws\m\b2\service_hs_baseline\src\share\vm\prims\jvmdi_hotswap.cpp, 335
90ce3da70b43 Initial load
duke
parents:
diff changeset
    53
90ce3da70b43 Initial load
duke
parents:
diff changeset
    54
90ce3da70b43 Initial load
duke
parents:
diff changeset
    55
# With -Xcomp on solaris this passes, but takes 2 minutes, thus the /timeout above.
90ce3da70b43 Initial load
duke
parents:
diff changeset
    56
90ce3da70b43 Initial load
duke
parents:
diff changeset
    57
# These are variables that can be set to control execution
90ce3da70b43 Initial load
duke
parents:
diff changeset
    58
90ce3da70b43 Initial load
duke
parents:
diff changeset
    59
java=java
90ce3da70b43 Initial load
duke
parents:
diff changeset
    60
90ce3da70b43 Initial load
duke
parents:
diff changeset
    61
createJavaFile()
90ce3da70b43 Initial load
duke
parents:
diff changeset
    62
{
90ce3da70b43 Initial load
duke
parents:
diff changeset
    63
    cat <<EOF > $1.java.1
90ce3da70b43 Initial load
duke
parents:
diff changeset
    64
90ce3da70b43 Initial load
duke
parents:
diff changeset
    65
90ce3da70b43 Initial load
duke
parents:
diff changeset
    66
import java.lang.Thread;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    67
import java.util.HashMap;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    68
import javax.swing.*;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    69
import java.util.*;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    70
90ce3da70b43 Initial load
duke
parents:
diff changeset
    71
90ce3da70b43 Initial load
duke
parents:
diff changeset
    72
public class $1 {
90ce3da70b43 Initial load
duke
parents:
diff changeset
    73
  int xxx = 20;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    74
  //ThreadGroup k = new ThreadGroup("group");
90ce3da70b43 Initial load
duke
parents:
diff changeset
    75
  int i;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    76
90ce3da70b43 Initial load
duke
parents:
diff changeset
    77
  public $1() {
90ce3da70b43 Initial load
duke
parents:
diff changeset
    78
  }
90ce3da70b43 Initial load
duke
parents:
diff changeset
    79
90ce3da70b43 Initial load
duke
parents:
diff changeset
    80
  public void a1() {
90ce3da70b43 Initial load
duke
parents:
diff changeset
    81
      a2();
90ce3da70b43 Initial load
duke
parents:
diff changeset
    82
  }
90ce3da70b43 Initial load
duke
parents:
diff changeset
    83
90ce3da70b43 Initial load
duke
parents:
diff changeset
    84
  public void a2() {
90ce3da70b43 Initial load
duke
parents:
diff changeset
    85
    a3();
90ce3da70b43 Initial load
duke
parents:
diff changeset
    86
  }
90ce3da70b43 Initial load
duke
parents:
diff changeset
    87
90ce3da70b43 Initial load
duke
parents:
diff changeset
    88
  public void a3() {
90ce3da70b43 Initial load
duke
parents:
diff changeset
    89
     System.out.println("out from a3");   // @1 breakpoint
90ce3da70b43 Initial load
duke
parents:
diff changeset
    90
     //System.out.println("hello world"); // @ 1 delete this isn't even necesary
90ce3da70b43 Initial load
duke
parents:
diff changeset
    91
  }
90ce3da70b43 Initial load
duke
parents:
diff changeset
    92
  public void a4() {
90ce3da70b43 Initial load
duke
parents:
diff changeset
    93
    System.out.println("in a4");
90ce3da70b43 Initial load
duke
parents:
diff changeset
    94
    int i = 2;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    95
    int j = 3333;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    96
    System.out.println("i + j = " + (i + j));
90ce3da70b43 Initial load
duke
parents:
diff changeset
    97
    System.out.println("out from a4");
90ce3da70b43 Initial load
duke
parents:
diff changeset
    98
    System.out.println("def");
90ce3da70b43 Initial load
duke
parents:
diff changeset
    99
    a1();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   100
  }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   101
90ce3da70b43 Initial load
duke
parents:
diff changeset
   102
  public void aa() {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   103
    a4();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   104
    System.out.println("out from aa");
90ce3da70b43 Initial load
duke
parents:
diff changeset
   105
  }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   106
90ce3da70b43 Initial load
duke
parents:
diff changeset
   107
90ce3da70b43 Initial load
duke
parents:
diff changeset
   108
  public static void main(String[] args) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   109
    byte xyz[] = new byte[] { 'a', 'b', 'c' };
90ce3da70b43 Initial load
duke
parents:
diff changeset
   110
90ce3da70b43 Initial load
duke
parents:
diff changeset
   111
    int x1 = 100;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   112
    x1 = 101;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   113
    x1 = 102;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   114
    x1 = 103;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   115
    String m1 = "def";
90ce3da70b43 Initial load
duke
parents:
diff changeset
   116
    String m2 = "abc";
90ce3da70b43 Initial load
duke
parents:
diff changeset
   117
    String m3 = "def";
90ce3da70b43 Initial load
duke
parents:
diff changeset
   118
90ce3da70b43 Initial load
duke
parents:
diff changeset
   119
    int[] m = new int[] { 100, 200, 300 };
90ce3da70b43 Initial load
duke
parents:
diff changeset
   120
90ce3da70b43 Initial load
duke
parents:
diff changeset
   121
    $1 untitled31 = new $1();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   122
    untitled31.aa();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   123
  }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   124
}
90ce3da70b43 Initial load
duke
parents:
diff changeset
   125
90ce3da70b43 Initial load
duke
parents:
diff changeset
   126
EOF
90ce3da70b43 Initial load
duke
parents:
diff changeset
   127
}
90ce3da70b43 Initial load
duke
parents:
diff changeset
   128
90ce3da70b43 Initial load
duke
parents:
diff changeset
   129
# This is called to feed cmds to jdb.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   130
dojdbCmds()
90ce3da70b43 Initial load
duke
parents:
diff changeset
   131
{
90ce3da70b43 Initial load
duke
parents:
diff changeset
   132
    setBkpts @1
90ce3da70b43 Initial load
duke
parents:
diff changeset
   133
    runToBkpt
90ce3da70b43 Initial load
duke
parents:
diff changeset
   134
    cmd redefine $classname $tmpFileDir/$classname.class
90ce3da70b43 Initial load
duke
parents:
diff changeset
   135
    cmd redefine $classname $tmpFileDir/$classname.class
90ce3da70b43 Initial load
duke
parents:
diff changeset
   136
    cmd redefine $classname $tmpFileDir/$classname.class
90ce3da70b43 Initial load
duke
parents:
diff changeset
   137
    cmd quit
90ce3da70b43 Initial load
duke
parents:
diff changeset
   138
}
90ce3da70b43 Initial load
duke
parents:
diff changeset
   139
90ce3da70b43 Initial load
duke
parents:
diff changeset
   140
90ce3da70b43 Initial load
duke
parents:
diff changeset
   141
mysetup()
90ce3da70b43 Initial load
duke
parents:
diff changeset
   142
{
90ce3da70b43 Initial load
duke
parents:
diff changeset
   143
    if [ -z "$TESTSRC" ] ; then
90ce3da70b43 Initial load
duke
parents:
diff changeset
   144
        TESTSRC=.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   145
    fi
90ce3da70b43 Initial load
duke
parents:
diff changeset
   146
90ce3da70b43 Initial load
duke
parents:
diff changeset
   147
    for ii in . $TESTSRC $TESTSRC/.. ; do
90ce3da70b43 Initial load
duke
parents:
diff changeset
   148
        if [ -r "$ii/ShellScaffold.sh" ] ; then
90ce3da70b43 Initial load
duke
parents:
diff changeset
   149
            . $ii/ShellScaffold.sh 
90ce3da70b43 Initial load
duke
parents:
diff changeset
   150
            break
90ce3da70b43 Initial load
duke
parents:
diff changeset
   151
        fi
90ce3da70b43 Initial load
duke
parents:
diff changeset
   152
    done
90ce3da70b43 Initial load
duke
parents:
diff changeset
   153
}
90ce3da70b43 Initial load
duke
parents:
diff changeset
   154
90ce3da70b43 Initial load
duke
parents:
diff changeset
   155
# You could replace this next line with the contents
90ce3da70b43 Initial load
duke
parents:
diff changeset
   156
# of ShellScaffold.sh and this script will run just the same.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   157
mysetup
90ce3da70b43 Initial load
duke
parents:
diff changeset
   158
90ce3da70b43 Initial load
duke
parents:
diff changeset
   159
runit
90ce3da70b43 Initial load
duke
parents:
diff changeset
   160
pass