changeset 20204:d22136881b85

Merge
author robm
date Thu, 17 Jul 2014 18:03:26 +0100
parents 4ca77b815015 (current diff) a7a22f7d9396 (diff)
children e248acd6cfcf
files .hgtags make/hotspot_version src/os/bsd/vm/os_bsd.cpp src/os/linux/vm/os_linux.cpp src/os/solaris/vm/os_solaris.cpp src/os/windows/vm/os_windows.cpp src/share/vm/classfile/verifier.cpp src/share/vm/utilities/vmError.cpp
diffstat 14 files changed, 141 insertions(+), 57 deletions(-) [+]
line wrap: on
line diff
--- a/.hgtags	Wed Jul 16 16:45:17 2014 -0700
+++ b/.hgtags	Thu Jul 17 18:03:26 2014 +0100
@@ -428,6 +428,7 @@
 e5561d89fe8bfc79cd6c8fcc36d270cc6a49ec6e jdk8u5-b02
 2f9eb9fcab6c42c8c84ddb44170ea33235116d84 jdk8u5-b03
 5ac720d47ab83f8eb2f5fe3641667823a0298f41 jdk8u5-b04
+b90de55aca30678ab0fec05d6a61bb3468b783d2 jdk8u11-b00
 b90de55aca30678ab0fec05d6a61bb3468b783d2 jdk8u5-b05
 956c0e048ef29ee9a8026fb05858abe64b4e0ceb jdk8u5-b06
 46fa2940e6861df18a107b6b83a2df85239e5ec7 jdk8u5-b07
@@ -437,6 +438,20 @@
 17a75e692af397532e2b296b24f6b9b6c239c633 jdk8u5-b11
 9b289963cb9a14636fbe8faaa2dd6d3678464a7b jdk8u5-b12
 8a67179106085689906732013a282efeeb9bd5f4 jdk8u5-b13
+5c7ef8e396835b82c0460b73f23cac86ba34846f jdk8u5-b31
+f0d759a6a2309a1c149d530b29db24eda885f267 jdk8u11-b01
+3c079aebb516765784dd8097887daadda5a76ac1 jdk8u11-b02
+0037e964ce486c009984171f004259263628079f jdk8u11-b03
+4c40343ecdb33fe046833fe4b8970fd29859c4ad jdk8u11-b04
+a4d44dfb7d30eea54bc172e4429a655454ae0bbf jdk8u11-b05
+b73ee2b9027c4183e520b2c0884d785ef9e539cf jdk8u11-b06
+561045d225990b8423af11fd80d2d704954c89c2 jdk8u11-b07
+af747c288b0f379448bebf56e2982f50caac6972 jdk8u11-b08
+34de1e8eeabbcc6e690f92766fd619beb9f3f049 jdk8u11-b09
+7e4ae023277bef5b82361fd985262f4009eb2fe8 jdk8u11-b10
+e6b7384074325d5a4ede728d6928ecb7f1cc1326 jdk8u11-b11
+78df957d46ebd98ba5bb68f4d9654c8bea3f1587 jdk8u11-b12
+13f04650aa09df696d62a1912febe25fe4a64082 jdk8u11-b31
 412d3b5fe90e54c0ff9d9ac7374b98607c561d5a hs25.20-b01
 4638c4d7ff106db0f29ef7f18b128dd7e69bc470 hs25.20-b02
 e56d11f8cc2158d4280f80e56d196193349c150a hs25.20-b03
@@ -477,5 +492,10 @@
 b15553cde967dfd7781a4a5c669e4cb7db734317 jdk8u20-b19
 4f18dea0312d601d0515976bc0c643ea7acc829d hs25.20-b20
 9e4d27da4ac04c6e19291087f7c68a5c5803c7ca jdk8u20-b20
+4828415ebbf11e205dcc08e97ad5ae7dd03522f9 jdk8u20-b21
+e4a6e7f1b90b85270aee1c54edaca3ef737082f1 hs25.20-b21
+f7429096a202cab5c36a0f20dea33c554026010f jdk8u20-b22
+7c56530b11496459e66cb9ea933035002311672c hs25.20-b22
+f09d1f6a401e25a54dad44bb7bea482e47558af5 jdk8u20-b23
 4828415ebbf11e205dcc08e97ad5ae7dd03522f9 jdk8u40-b00
 d952af8cf67dd1e7ab5fec9a299c6c6dafd1863e hs25.40-b01
--- a/src/os/bsd/vm/os_bsd.cpp	Wed Jul 16 16:45:17 2014 -0700
+++ b/src/os/bsd/vm/os_bsd.cpp	Thu Jul 17 18:03:26 2014 +0100
@@ -1169,10 +1169,6 @@
   ::abort();
 }
 
-// unused on bsd for now.
-void os::set_error_file(const char *logfile) {}
-
-
 // This method is a copy of JDK's sysGetLastErrorString
 // from src/solaris/hpi/src/system_md.c
 
@@ -1827,6 +1823,7 @@
         // determine if this is a legacy image or modules image
         // modules image doesn't have "jre" subdirectory
         len = strlen(buf);
+        assert(len < buflen, "Ran out of buffer space");
         jrelib_p = buf + len;
 
         // Add the appropriate library subdir
@@ -1860,7 +1857,7 @@
     }
   }
 
-  strcpy(saved_jvm_path, buf);
+  strncpy(saved_jvm_path, buf, MAXPATHLEN);
 }
 
 void os::print_jni_name_prefix_on(outputStream* st, int args_size) {
--- a/src/os/linux/vm/os_linux.cpp	Wed Jul 16 16:45:17 2014 -0700
+++ b/src/os/linux/vm/os_linux.cpp	Thu Jul 17 18:03:26 2014 +0100
@@ -1551,9 +1551,6 @@
   ::abort();
 }
 
-// unused on linux for now.
-void os::set_error_file(const char *logfile) {}
-
 
 // This method is a copy of JDK's sysGetLastErrorString
 // from src/solaris/hpi/src/system_md.c
@@ -2342,6 +2339,7 @@
         // determine if this is a legacy image or modules image
         // modules image doesn't have "jre" subdirectory
         len = strlen(buf);
+        assert(len < buflen, "Ran out of buffer room");
         jrelib_p = buf + len;
         snprintf(jrelib_p, buflen-len, "/jre/lib/%s", cpu_arch);
         if (0 != access(buf, F_OK)) {
@@ -2362,7 +2360,7 @@
     }
   }
 
-  strcpy(saved_jvm_path, buf);
+  strncpy(saved_jvm_path, buf, MAXPATHLEN);
 }
 
 void os::print_jni_name_prefix_on(outputStream* st, int args_size) {
--- a/src/os/solaris/vm/os_solaris.cpp	Wed Jul 16 16:45:17 2014 -0700
+++ b/src/os/solaris/vm/os_solaris.cpp	Thu Jul 17 18:03:26 2014 +0100
@@ -1711,9 +1711,6 @@
   ::abort(); // dump core (for debugging)
 }
 
-// unused
-void os::set_error_file(const char *logfile) {}
-
 // DLL functions
 
 const char* os::dll_file_extension() { return ".so"; }
@@ -2357,6 +2354,7 @@
         // determine if this is a legacy image or modules image
         // modules image doesn't have "jre" subdirectory
         len = strlen(buf);
+        assert(len < buflen, "Ran out of buffer space");
         jrelib_p = buf + len;
         snprintf(jrelib_p, buflen-len, "/jre/lib/%s", cpu_arch);
         if (0 != access(buf, F_OK)) {
@@ -2375,7 +2373,7 @@
     }
   }
 
-  strcpy(saved_jvm_path, buf);
+  strncpy(saved_jvm_path, buf, MAXPATHLEN);
 }
 
 
--- a/src/os/windows/vm/os_windows.cpp	Wed Jul 16 16:45:17 2014 -0700
+++ b/src/os/windows/vm/os_windows.cpp	Thu Jul 17 18:03:26 2014 +0100
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 1997, 2013, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 1997, 2014, 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
@@ -1820,7 +1820,8 @@
      // libjvm.so is installed there (append a fake suffix
      // hotspot/libjvm.so).
      char* java_home_var = ::getenv("JAVA_HOME");
-     if (java_home_var != NULL && java_home_var[0] != 0) {
+     if (java_home_var != NULL && java_home_var[0] != 0 &&
+         strlen(java_home_var) < (size_t)buflen) {
 
         strncpy(buf, java_home_var, buflen);
 
@@ -1838,9 +1839,9 @@
   }
 
   if(buf[0] == '\0') {
-  GetModuleFileName(vm_lib_handle, buf, buflen);
-  }
-  strcpy(saved_jvm_path, buf);
+    GetModuleFileName(vm_lib_handle, buf, buflen);
+  }
+  strncpy(saved_jvm_path, buf, MAX_PATH);
 }
 
 
@@ -2291,19 +2292,8 @@
       }
 
 */
-#endif //_WIN64
-
-
-// Fatal error reporting is single threaded so we can make this a
-// static and preallocated.  If it's more than MAX_PATH silently ignore
-// it.
-static char saved_error_file[MAX_PATH] = {0};
-
-void os::set_error_file(const char *logfile) {
-  if (strlen(logfile) <= MAX_PATH) {
-    strncpy(saved_error_file, logfile, MAX_PATH);
-  }
-}
+#endif // _WIN64
+
 
 static inline void report_error(Thread* t, DWORD exception_code,
                                 address addr, void* siginfo, void* context) {
--- a/src/share/vm/classfile/classFileParser.cpp	Wed Jul 16 16:45:17 2014 -0700
+++ b/src/share/vm/classfile/classFileParser.cpp	Thu Jul 17 18:03:26 2014 +0100
@@ -931,7 +931,7 @@
             "Wrong size %u for field's Signature attribute in class file %s",
             attribute_length, CHECK);
         }
-        generic_signature_index = cfs->get_u2(CHECK);
+        generic_signature_index = parse_generic_signature_attribute(CHECK);
       } else if (attribute_name == vmSymbols::tag_runtime_visible_annotations()) {
         runtime_visible_annotations_length = attribute_length;
         runtime_visible_annotations = cfs->get_u1_buffer();
@@ -2305,8 +2305,7 @@
             "Invalid Signature attribute length %u in class file %s",
             method_attribute_length, CHECK_(nullHandle));
         }
-        cfs->guarantee_more(2, CHECK_(nullHandle));  // generic_signature_index
-        generic_signature_index = cfs->get_u2_fast();
+        generic_signature_index = parse_generic_signature_attribute(CHECK_(nullHandle));
       } else if (method_attribute_name == vmSymbols::tag_runtime_visible_annotations()) {
         runtime_visible_annotations_length = method_attribute_length;
         runtime_visible_annotations = cfs->get_u1_buffer();
@@ -2616,6 +2615,17 @@
   return method_ordering;
 }
 
+// Parse generic_signature attribute for methods and fields
+u2 ClassFileParser::parse_generic_signature_attribute(TRAPS) {
+  ClassFileStream* cfs = stream();
+  cfs->guarantee_more(2, CHECK_0);  // generic_signature_index
+  u2 generic_signature_index = cfs->get_u2_fast();
+  check_property(
+    valid_symbol_at(generic_signature_index),
+    "Invalid Signature attribute at constant pool index %u in class file %s",
+    generic_signature_index, CHECK_0);
+  return generic_signature_index;
+}
 
 void ClassFileParser::parse_classfile_sourcefile_attribute(TRAPS) {
   ClassFileStream* cfs = stream();
@@ -2770,7 +2780,13 @@
   ClassFileStream* cfs = stream();
   u1* current_start = cfs->current();
 
-  cfs->guarantee_more(2, CHECK);  // length
+  guarantee_property(attribute_byte_length > sizeof(u2),
+                     "Invalid BootstrapMethods attribute length %u in class file %s",
+                     attribute_byte_length,
+                     CHECK);
+
+  cfs->guarantee_more(attribute_byte_length, CHECK);
+
   int attribute_array_length = cfs->get_u2_fast();
 
   guarantee_property(_max_bootstrap_specifier_index < attribute_array_length,
--- a/src/share/vm/classfile/classFileParser.hpp	Wed Jul 16 16:45:17 2014 -0700
+++ b/src/share/vm/classfile/classFileParser.hpp	Thu Jul 17 18:03:26 2014 +0100
@@ -266,6 +266,7 @@
   u1* parse_stackmap_table(u4 code_attribute_length, TRAPS);
 
   // Classfile attribute parsing
+  u2 parse_generic_signature_attribute(TRAPS);
   void parse_classfile_sourcefile_attribute(TRAPS);
   void parse_classfile_source_debug_extension_attribute(int length, TRAPS);
   u2   parse_classfile_inner_classes_attribute(u1* inner_classes_attribute_start,
--- a/src/share/vm/classfile/stackMapTable.cpp	Wed Jul 16 16:45:17 2014 -0700
+++ b/src/share/vm/classfile/stackMapTable.cpp	Thu Jul 17 18:03:26 2014 +0100
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2003, 2012, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2003, 2014, 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
@@ -134,6 +134,7 @@
   }
   // check if uninitialized objects exist on backward branches
   check_new_object(frame, target, CHECK_VERIFY(frame->verifier()));
+  frame->verifier()->update_furthest_jump(target);
 }
 
 void StackMapTable::check_new_object(
--- a/src/share/vm/classfile/verifier.cpp	Wed Jul 16 16:45:17 2014 -0700
+++ b/src/share/vm/classfile/verifier.cpp	Thu Jul 17 18:03:26 2014 +0100
@@ -633,6 +633,9 @@
   bool no_control_flow = false; // Set to true when there is no direct control
                                 // flow from current instruction to the next
                                 // instruction in sequence
+
+  set_furthest_jump(0);
+
   Bytecodes::Code opcode;
   while (!bcs.is_last_bytecode()) {
     // Check for recursive re-verification before each bytecode.
@@ -2248,6 +2251,29 @@
           "Bad <init> method call");
       return;
     }
+
+    // Make sure that this call is not jumped over.
+    if (bci < furthest_jump()) {
+      verify_error(ErrorContext::bad_code(bci),
+                   "Bad <init> method call from inside of a branch");
+      return;
+    }
+
+    // Make sure that this call is not done from within a TRY block because
+    // that can result in returning an incomplete object.  Simply checking
+    // (bci >= start_pc) also ensures that this call is not done after a TRY
+    // block.  That is also illegal because this call must be the first Java
+    // statement in the constructor.
+    ExceptionTable exhandlers(_method());
+    int exlength = exhandlers.length();
+    for(int i = 0; i < exlength; i++) {
+      if (bci >= exhandlers.start_pc(i)) {
+        verify_error(ErrorContext::bad_code(bci),
+                     "Bad <init> method call from after the start of a try block");
+        return;
+      }
+    }
+
     current_frame->initialize_object(type, current_type());
     *this_uninit = true;
   } else if (type.is_uninitialized()) {
@@ -2283,18 +2309,20 @@
         ref_class_type.name(), CHECK_VERIFY(this));
       Method* m = InstanceKlass::cast(ref_klass)->uncached_lookup_method(
         vmSymbols::object_initializer_name(),
-        cp->signature_ref_at(bcs->get_index_u2()),
-        Klass::normal);
-      instanceKlassHandle mh(THREAD, m->method_holder());
-      if (m->is_protected() && !mh->is_same_class_package(_klass())) {
-        bool assignable = current_type().is_assignable_from(
-          objectref_type, this, CHECK_VERIFY(this));
-        if (!assignable) {
-          verify_error(ErrorContext::bad_type(bci,
-              TypeOrigin::cp(new_class_index, objectref_type),
-              TypeOrigin::implicit(current_type())),
-              "Bad access to protected <init> method");
-          return;
+        cp->signature_ref_at(bcs->get_index_u2()), Klass::normal);
+      // Do nothing if method is not found.  Let resolution detect the error.
+      if (m != NULL) {
+        instanceKlassHandle mh(THREAD, m->method_holder());
+        if (m->is_protected() && !mh->is_same_class_package(_klass())) {
+          bool assignable = current_type().is_assignable_from(
+            objectref_type, this, CHECK_VERIFY(this));
+          if (!assignable) {
+            verify_error(ErrorContext::bad_type(bci,
+                TypeOrigin::cp(new_class_index, objectref_type),
+                TypeOrigin::implicit(current_type())),
+                "Bad access to protected <init> method");
+            return;
+          }
         }
       }
     }
--- a/src/share/vm/classfile/verifier.hpp	Wed Jul 16 16:45:17 2014 -0700
+++ b/src/share/vm/classfile/verifier.hpp	Thu Jul 17 18:03:26 2014 +0100
@@ -258,6 +258,9 @@
 
   ErrorContext _error_context;  // contains information about an error
 
+  // Used to detect illegal jumps over calls to super() nd this() in ctors.
+  int32_t _furthest_jump;
+
   void verify_method(methodHandle method, TRAPS);
   char* generate_code_data(methodHandle m, u4 code_length, TRAPS);
   void verify_exception_handler_table(u4 code_length, char* code_data,
@@ -403,6 +406,20 @@
   Symbol* create_temporary_symbol(const char *s, int length, TRAPS);
 
   TypeOrigin ref_ctx(const char* str, TRAPS);
+
+  // Keep track of the furthest branch done in a method to make sure that
+  // there are no branches over calls to super() or this() from inside of
+  // a constructor.
+  int32_t furthest_jump() { return _furthest_jump; }
+
+  void set_furthest_jump(int32_t target) {
+    _furthest_jump = target;
+  }
+
+  void update_furthest_jump(int32_t target) {
+    if (target > _furthest_jump) _furthest_jump = target;
+  }
+
 };
 
 inline int ClassVerifier::change_sig_to_verificationType(
--- a/src/share/vm/compiler/compileBroker.cpp	Wed Jul 16 16:45:17 2014 -0700
+++ b/src/share/vm/compiler/compileBroker.cpp	Thu Jul 17 18:03:26 2014 +0100
@@ -2089,6 +2089,7 @@
   ResourceMark rm;
   char* method_name = method->name()->as_C_string();
   strncpy(_last_method_compiled, method_name, CompileBroker::name_buffer_length);
+  _last_method_compiled[CompileBroker::name_buffer_length - 1] = '\0'; // ensure null terminated
   char current_method[CompilerCounters::cmname_buffer_length];
   size_t maxLen = CompilerCounters::cmname_buffer_length;
 
--- a/src/share/vm/oops/klassVtable.cpp	Wed Jul 16 16:45:17 2014 -0700
+++ b/src/share/vm/oops/klassVtable.cpp	Thu Jul 17 18:03:26 2014 +0100
@@ -251,6 +251,17 @@
 // For bytecodes not produced by javac together it is possible that a method does not override
 // the superclass's method, but might indirectly override a super-super class's vtable entry
 // If none found, return a null superk, else return the superk of the method this does override
+// For public and protected methods: if they override a superclass, they will
+// also be overridden themselves appropriately.
+// Private methods do not override and are not overridden.
+// Package Private methods are trickier:
+// e.g. P1.A, pub m
+// P2.B extends A, package private m
+// P1.C extends B, public m
+// P1.C.m needs to override P1.A.m and can not override P2.B.m
+// Therefore: all package private methods need their own vtable entries for
+// them to be the root of an inheritance overriding decision
+// Package private methods may also override other vtable entries
 InstanceKlass* klassVtable::find_transitive_override(InstanceKlass* initialsuper, methodHandle target_method,
                             int vtable_index, Handle target_loader, Symbol* target_classname, Thread * THREAD) {
   InstanceKlass* superk = initialsuper;
@@ -398,8 +409,11 @@
                              target_classname, THREAD))
                              != (InstanceKlass*)NULL))))
         {
-        // overriding, so no new entry
-        allocate_new = false;
+        // Package private methods always need a new entry to root their own
+        // overriding. They may also override other methods.
+        if (!target_method()->is_package_private()) {
+          allocate_new = false;
+        }
 
         if (checkconstraints) {
         // Override vtable entry if passes loader constraint check
@@ -543,8 +557,9 @@
                                          AccessFlags class_flags,
                                          TRAPS) {
   if (class_flags.is_interface()) {
-    // Interfaces do not use vtables, so there is no point to assigning
-    // a vtable index to any of their methods.  If we refrain from doing this,
+    // Interfaces do not use vtables, except for java.lang.Object methods,
+    // so there is no point to assigning
+    // a vtable index to any of their local methods.  If we refrain from doing this,
     // we can use Method::_vtable_index to hold the itable index
     return false;
   }
@@ -582,6 +597,12 @@
     return true;
   }
 
+  // Package private methods always need a new entry to root their own
+  // overriding. This allows transitive overriding to work.
+  if (target_method()->is_package_private()) {
+    return true;
+  }
+
   // search through the super class hierarchy to see if we need
   // a new entry
   ResourceMark rm;
--- a/src/share/vm/runtime/os.hpp	Wed Jul 16 16:45:17 2014 -0700
+++ b/src/share/vm/runtime/os.hpp	Thu Jul 17 18:03:26 2014 +0100
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 1997, 2013, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 1997, 2014, 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
@@ -480,9 +480,6 @@
   // run cmd in a separate process and return its exit code; or -1 on failures
   static int fork_and_exec(char *cmd);
 
-  // Set file to send error reports.
-  static void set_error_file(const char *logfile);
-
   // os::exit() is merged with vm_exit()
   // static void exit(int num);
 
--- a/src/share/vm/utilities/vmError.cpp	Wed Jul 16 16:45:17 2014 -0700
+++ b/src/share/vm/utilities/vmError.cpp	Thu Jul 17 18:03:26 2014 +0100
@@ -988,7 +988,6 @@
       if (fd != -1) {
         out.print_raw("# An error report file with more information is saved as:\n# ");
         out.print_raw_cr(buffer);
-        os::set_error_file(buffer);
 
         log.set_fd(fd);
       } else {