2362N/A# Copyright (c) 2002, 2003, Oracle and/or its affiliates. All rights reserved. 0N/A# DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. 0N/A# This code is free software; you can redistribute it and/or modify it 0N/A# under the terms of the GNU General Public License version 2 only, as 0N/A# published by the Free Software Foundation. 0N/A# This code is distributed in the hope that it will be useful, but WITHOUT 0N/A# ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or 0N/A# FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License 0N/A# version 2 for more details (a copy is included in the LICENSE file that 0N/A# accompanied this code). 0N/A# You should have received a copy of the GNU General Public License version 0N/A# 2 along with this work; if not, write to the Free Software Foundation, 0N/A# Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. 2362N/A# Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA 0N/A# The failure occurs when a method is active and 0N/A# a method that it calls multiple times is redefined 0N/A // The first time thru the loop in start, 0N/A // "Before update..." should be printed. 0N/A // After the first redefine, "After update..." should be printed 0N/A // After the 2nd redefine, "abcde..." should be printed. 0N/A // The bug is that "After update..." is printed instead because 0N/A // stat() calls version 2 of doSomething() instead of 0N/A private void doSomething() { 0N/A System.out.println("Before update..."); // @1 commentout 0N/A // @1 uncomment System.out.println("After update..."); // @2 commentout 0N/A // @2 uncomment System.out.println("abcde..."); 0N/A public void start() { 0N/A for (int i=0; i < 3; i++) { 0N/A doSomething(); // @1 breakpoint here line 16 0N/A System.out.println("field1 = " + field1); 0N/A System.out.println("field2 = " + field2); 0N/A // Redefinex myx = new Redefinex(); 0N/A // for (int i = 0; i < 5; i++) { 0N/A // myx.methodx1(); // line 22 0N/A // System.out.println("fieldx1 = " + myx.fieldx1); 0N/A // System.out.println("fieldx2 = " + myx.fieldx2); 0N/A public static void main(String[] args) { 0N/A xxx.field1 = "field1"; 0N/A xxx.field2 = "field2"; 0N/A public String fieldx1; 0N/A public String fieldx2; 0N/A fieldx1 = "fieldx1"; 0N/A fieldx2 = "fieldx2"; 0N/A public void methodx1() { 0N/A System.out.println("redefinex 1"); 0N/A //System.out.println("redefinex 2"); 0N/A //System.out.println("redefinex 3"); 0N/ASteps to reproduce this problem: 0N/A a. add line breakpoint in start() 0N/A c. when breakpoint is hit, type continue. You should see output 0N/A d. change "Before update" to "After update" 0N/A e. redefine, and set line breakpoint (see step a) 0N/A f. type continue. You should see output "After update" 0N/A g. change "After update" to "abcde" 0N/A h. redefine, and set line breakpoint (see step a) 0N/A i. type continue. The output is shown as "After update" 0N/A j. to see "abcde" output, users will have to pop the stack, and 0N/Are-execute method start(). 0N/A# This is called to feed cmds to jdb. 0N/A# You could replace this next line with the contents