/* * Copyright (c) 2013, 2017, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it * under the terms of the GNU General Public License version 2 only, as * published by the Free Software Foundation. * * This code is distributed in the hope that it will be useful, but WITHOUT * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License * version 2 for more details (a copy is included in the LICENSE file that * accompanied this code). * * You should have received a copy of the GNU General Public License version * 2 along with this work; if not, write to the Free Software Foundation, * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. * * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA * or visit www.oracle.com if you need additional information or have any * questions.
*/
// THIS TEST IS LINE NUMBER SENSITIVE
/** * @test * @bug 4386002 4429245 * @summary Test fix for: Incorrect values reported for some locals of type long * @author Tim Bell * * @run build TestScaffold VMConnection TargetListener TargetAdapter * @run compile -g FetchLocals.java * @run driver FetchLocals
*/ import com.sun.jdi.*; import com.sun.jdi.event.*; import java.util.*;
class FetchLocalsDebugee { publiclong testMethod() { short s = 12345; int i = 8675309; boolean pt = true; long w = 973230999L; byte b = 0x3b; long x = w * 1000L; char c = '\u005A'; // 005A = "Z" long y = 22; float f = 6.66f; double d = 7.77;
System.out.print("pt is: ");
System.out.println(pt);
System.out.print("b is: ");
System.out.println(b);
System.out.print("c is: ");
System.out.println(c);
System.out.print("s is: ");
System.out.println(s);
System.out.print("i is: ");
System.out.println(i);
System.out.print("w is: ");
System.out.print(w);
System.out.print(" (0x");
System.out.print(Long.toHexString(w));
System.out.println(")");
System.out.print("x is: ");
System.out.print(x);
System.out.print(" (0x");
System.out.print(Long.toHexString(x));
System.out.println(")");
System.out.print("y is: ");
System.out.print(y);
System.out.print(" (0x");
System.out.print(Long.toHexString(y));
System.out.println(")");
System.out.print("f is: ");
System.out.println(f);
System.out.print("d is: ");
System.out.println(d);
System.out.println(); // This is FetchLocals::LINE if (w == 0xde00ad00be00ef00L) {
System.out.print ("The debugger was here. w modified to: 0x");
System.out.println(Long.toHexString(w));
} else {
System.out.print ("w contains : 0x");
System.out.println(Long.toHexString(w));
}
System.out.println(); return x;
} publicstaticvoid main(String[] args) {
System.out.print ("FetchLocalsDebugee");
System.out.println(" Starting up...");
FetchLocalsDebugee my = new FetchLocalsDebugee (); long result = my.testMethod();
System.out.print ("testMethod() returned: ");
System.out.print (result);
System.out.print (" (0x");
System.out.print (Long.toHexString(result));
System.out.println(")");
protectedvoid testLocalVariables (StackFrame sf) throws Exception
{ /* * Test values in the local method testMethod (): * 1) Read current data * 2) Test against the expected value * 3) Set to a new value * 4) Read again * 5) Test against the expected value
*/
LocalVariable lv = sf.visibleVariableByName("pt");
BooleanValue booleanV = (BooleanValue) sf.getValue(lv);
test("pt", booleanV, true);
booleanV = vm().mirrorOf(false);
sf.setValue(lv, booleanV);
booleanV = (BooleanValue) sf.getValue(lv);
test("pt", booleanV, false);
protectedvoid runTests() throws Exception
{
startToMain("FetchLocalsDebugee"); /* * Get to the bottom of testMethod():
*/ try {
BreakpointEvent bpe = resumeTo("FetchLocalsDebugee", LINE); /* * Fetch values from fields; what did we get?
*/
StackFrame sf = bpe.thread().frame(0);
testLocalVariables (sf);
} catch(Exception ex) {
ex.printStackTrace();
testFailed = true;
} finally { // Allow application to complete and shut down
resumeToVMDisconnect();
} if (!testFailed) {
System.out.println("FetchLocals: passed");
} else { thrownew Exception("FetchLocals: failed");
}
}
}
Messung V0.5
¤ Dauer der Verarbeitung: 0.13 Sekunden
(vorverarbeitet)
¤
Die Informationen auf dieser Webseite wurden
nach bestem Wissen sorgfältig zusammengestellt. Es wird jedoch weder Vollständigkeit, noch Richtigkeit,
noch Qualität der bereit gestellten Informationen zugesichert.
Bemerkung:
Die farbliche Syntaxdarstellung und die Messung sind noch experimentell.