8169232: SA: TestCpoolForInvokeDynamic.java fails with sun.jvm.hotspot.debugger.DebuggerException: binary search bug: should have found entry 1
Summary: Avoid potential data loss by avoiding the long-to-int cast of the return value of minus()
Reviewed-by: dsamersoff, sspitsyn
Contributed-by: jini.george@oracle.com
--- a/hotspot/src/jdk.hotspot.agent/share/classes/sun/jvm/hotspot/oops/InstanceKlass.java Tue Nov 22 20:50:31 2016 -0500
+++ b/hotspot/src/jdk.hotspot.agent/share/classes/sun/jvm/hotspot/oops/InstanceKlass.java Wed Nov 23 12:08:37 2016 +0530
@@ -975,7 +975,7 @@
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
--- a/hotspot/src/jdk.hotspot.agent/share/classes/sun/jvm/hotspot/oops/Symbol.java Tue Nov 22 20:50:31 2016 -0500
+++ b/hotspot/src/jdk.hotspot.agent/share/classes/sun/jvm/hotspot/oops/Symbol.java Wed Nov 23 12:08:37 2016 +0530
@@ -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 @@
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 {
--- a/hotspot/test/serviceability/sa/TestCpoolForInvokeDynamic.java Tue Nov 22 20:50:31 2016 -0500
+++ b/hotspot/test/serviceability/sa/TestCpoolForInvokeDynamic.java Wed Nov 23 12:08:37 2016 +0530
@@ -51,7 +51,6 @@
* 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
*/