8169232: SA: TestCpoolForInvokeDynamic.java fails with sun.jvm.hotspot.debugger.DebuggerException: binary search bug: should have found entry 1

Avoid potential data loss by avoiding the long-to-int cast of the return value of minus()

Reviewed-by: dsamersoff, sspitsyn
This commit is contained in:
Jini George 2016-11-23 12:08:37 +05:30 committed by Vyom Tewari
parent 358f09e305
commit 95a418feb0
3 changed files with 4 additions and 5 deletions

View File

@ -975,7 +975,7 @@ public class InstanceKlass extends Klass {
while (l <= h) {
int mid = (l + h) >> 1;
Method m = methods.at(mid);
int res = m.getName().fastCompare(name);
long res = m.getName().fastCompare(name);
if (res == 0) {
// found matching name; do linear search to find matching signature
// first, quick check for common case

View File

@ -1,5 +1,5 @@
/*
* Copyright (c) 2000, 2011, Oracle and/or its affiliates. All rights reserved.
* Copyright (c) 2000, 2016, 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
@ -139,8 +139,8 @@ public class Symbol extends VMObject {
time-invariant order Since Symbol* are in C_HEAP, their
relative order in memory never changes, so use address
comparison for speed. */
public int fastCompare(Symbol other) {
return (int) addr.minus(other.addr);
public long fastCompare(Symbol other) {
return addr.minus(other.addr);
}
private static String readModifiedUTF8(byte[] buf) throws IOException {

View File

@ -51,7 +51,6 @@ import jdk.test.lib.Asserts;
* jdk.hotspot.agent/sun.jvm.hotspot.oops
* jdk.hotspot.agent/sun.jvm.hotspot.debugger
* jdk.hotspot.agent/sun.jvm.hotspot.ui.classbrowser
* @ignore 8169232
* @run main/othervm TestCpoolForInvokeDynamic
*/