changeset 24065:6009b66f2fa1

Merge
author asaha
date Tue, 16 Aug 2016 13:31:51 -0700
parents fff265b31090 (current diff) 14919ca8db45 (diff)
children 3e2b407e18c3
files .hgtags
diffstat 6 files changed, 53 insertions(+), 13 deletions(-) [+]
line wrap: on
line diff
--- a/.hgtags	Thu Aug 11 12:17:39 2016 +0300
+++ b/.hgtags	Tue Aug 16 13:31:51 2016 -0700
@@ -904,6 +904,7 @@
 019b22dd8128840ecdcd1bfebcf4447e28e45068 jdk8u111-b06
 3f337aaf090769653ee0a746fbe661d09055a883 jdk8u111-b07
 e180e364a40364a059a20c74b97ab4e928e2b676 jdk8u111-b08
+c48b303692bb86c42e928da6dec815e901a24c5b jdk8u111-b09
 b09a69142dd3bf78ca66bb0c99046ca7cccbdda9 jdk8u112-b00
 cf1faa9100dd8c8df6e1a604aaf613d037f51ebf jdk8u112-b01
 f22b5be95347c669a1463d9e05ec3bf11420208e jdk8u112-b02
@@ -912,4 +913,5 @@
 4b7af794466ba22461ed043a1394df43e4993c4f jdk8u112-b06
 55ed9b0a35e4ad4bb5ca3f393f6749e81ad9fef0 jdk8u112-b07
 670f8169b83c6af14339fe37b2a2b8384dc2149b jdk8u112-b08
+1ccd27199595fedefcd1ca4a335e049887c63107 jdk8u112-b09
 3b0e5f01891f5ebbf67797b1aae786196f1bb4f6 jdk8u121-b00
--- a/src/share/vm/oops/method.cpp	Thu Aug 11 12:17:39 2016 +0300
+++ b/src/share/vm/oops/method.cpp	Tue Aug 16 13:31:51 2016 -0700
@@ -111,6 +111,7 @@
 // Release Method*.  The nmethod will be gone when we get here because
 // we've walked the code cache.
 void Method::deallocate_contents(ClassLoaderData* loader_data) {
+  clear_jmethod_id(loader_data);
   MetadataFactory::free_metadata(loader_data, constMethod());
   set_constMethod(NULL);
   MetadataFactory::free_metadata(loader_data, method_data());
@@ -1800,6 +1801,17 @@
 #endif // ASSERT
     *m = _free_method;
   }
+  void clear_method(Method* m) {
+    for (JNIMethodBlock* b = this; b != NULL; b = b->_next) {
+      for (int i = 0; i < number_of_methods; i++) {
+        if (b->_methods[i] == m) {
+          b->_methods[i] = NULL;
+          return;
+        }
+      }
+    }
+    // not found
+  }
 
   // During class unloading the methods are cleared, which is different
   // than freed.
@@ -1872,7 +1884,9 @@
 
 bool Method::is_method_id(jmethodID mid) {
   Method* m = resolve_jmethod_id(mid);
-  assert(m != NULL, "should be called with non-null method");
+  if (m == NULL) {
+    return false;
+  }
   InstanceKlass* ik = m->method_holder();
   if (ik == NULL) {
     return false;
@@ -1905,6 +1919,10 @@
   }
 }
 
+void Method::clear_jmethod_id(ClassLoaderData* loader_data) {
+  loader_data->jmethod_ids()->clear_method(this);
+}
+
 // Called when the class loader is unloaded to make all methods weak.
 void Method::clear_jmethod_ids(ClassLoaderData* loader_data) {
   loader_data->jmethod_ids()->clear_all_methods();
--- a/src/share/vm/oops/method.hpp	Thu Aug 11 12:17:39 2016 +0300
+++ b/src/share/vm/oops/method.hpp	Tue Aug 16 13:31:51 2016 -0700
@@ -768,6 +768,8 @@
 
   // Helper routines for intrinsic_id() and vmIntrinsics::method().
   void init_intrinsic_id();     // updates from _none if a match
+  void clear_jmethod_id(ClassLoaderData* loader_data);
+
   static vmSymbols::SID klass_id_for_intrinsics(Klass* holder);
 
   bool     jfr_towrite()                { return _jfr_towrite;              }
--- a/src/share/vm/prims/jvm.cpp	Thu Aug 11 12:17:39 2016 +0300
+++ b/src/share/vm/prims/jvm.cpp	Tue Aug 16 13:31:51 2016 -0700
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 1997, 2014, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 1997, 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
@@ -2872,7 +2872,18 @@
 int jio_vsnprintf(char *str, size_t count, const char *fmt, va_list args) {
   // see bug 4399518, 4417214
   if ((intptr_t)count <= 0) return -1;
-  return vsnprintf(str, count, fmt, args);
+
+  int result = vsnprintf(str, count, fmt, args);
+  // Note: on truncation vsnprintf(3) on Unix returns number of
+  // characters which would have been written had the buffer been large
+  // enough; on Windows, it returns -1. We handle both cases here and
+  // always return -1, and perform null termination.
+  if ((result > 0 && (size_t)result >= count) || result == -1) {
+    str[count - 1] = '\0';
+    result = -1;
+  }
+
+  return result;
 }
 
 ATTRIBUTE_PRINTF(3, 0)
--- a/src/share/vm/runtime/deoptimization.cpp	Thu Aug 11 12:17:39 2016 +0300
+++ b/src/share/vm/runtime/deoptimization.cpp	Tue Aug 16 13:31:51 2016 -0700
@@ -1881,8 +1881,6 @@
                        trap_reason_name(reason),
                        recomp_flag ? " recompiled" : "");
   }
-  if (len >= buflen)
-    buf[buflen-1] = '\0';
   return buf;
 }
 
@@ -1952,8 +1950,6 @@
     len = jio_snprintf(buf, buflen, "reason='%s' action='%s' index='%d'",
                        reason, action, unloaded_class_index);
   }
-  if (len >= buflen)
-    buf[buflen-1] = '\0';
   return buf;
 }
 
--- a/src/share/vm/runtime/java.cpp	Thu Aug 11 12:17:39 2016 +0300
+++ b/src/share/vm/runtime/java.cpp	Tue Aug 16 13:31:51 2016 -0700
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 1997, 2014, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 1997, 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
@@ -773,25 +773,36 @@
 }
 
 void JDK_Version::to_string(char* buffer, size_t buflen) const {
+  assert(buffer && buflen > 0, "call with useful buffer");
   size_t index = 0;
   if (!is_valid()) {
     jio_snprintf(buffer, buflen, "%s", "(uninitialized)");
   } else if (is_partially_initialized()) {
     jio_snprintf(buffer, buflen, "%s", "(uninitialized) pre-1.6.0");
   } else {
-    index += jio_snprintf(
+    int rc = jio_snprintf(
         &buffer[index], buflen - index, "%d.%d", _major, _minor);
+    if (rc == -1) return;
+    index += rc;
     if (_micro > 0) {
-      index += jio_snprintf(&buffer[index], buflen - index, ".%d", _micro);
+      rc = jio_snprintf(&buffer[index], buflen - index, ".%d", _micro);
+      if (rc == -1) return;
+      index += rc;
     }
     if (_update > 0) {
-      index += jio_snprintf(&buffer[index], buflen - index, "_%02d", _update);
+      rc = jio_snprintf(&buffer[index], buflen - index, "_%02d", _update);
+      if (rc == -1) return;
+      index += rc;
     }
     if (_special > 0) {
-      index += jio_snprintf(&buffer[index], buflen - index, "%c", _special);
+      rc = jio_snprintf(&buffer[index], buflen - index, "%c", _special);
+      if (rc == -1) return;
+      index += rc;
     }
     if (_build > 0) {
-      index += jio_snprintf(&buffer[index], buflen - index, "-b%02d", _build);
+      rc = jio_snprintf(&buffer[index], buflen - index, "-b%02d", _build);
+      if (rc == -1) return;
+      index += rc;
     }
   }
 }