8152329: jvm should treat the "Multi-Release" jar manifest attribute name as case insensitive
authorccheung
Wed, 06 Apr 2016 11:40:45 -0700
changeset 37418 ebb041956080
parent 37416 9f905b8b3718
child 37419 bac980e1e730
8152329: jvm should treat the "Multi-Release" jar manifest attribute name as case insensitive Reviewed-by: iklam, jiangli, mseledtsov
hotspot/src/share/vm/classfile/classLoader.cpp
hotspot/src/share/vm/classfile/classLoader.hpp
--- a/hotspot/src/share/vm/classfile/classLoader.cpp	Wed Apr 06 16:03:02 2016 +0200
+++ b/hotspot/src/share/vm/classfile/classLoader.cpp	Wed Apr 06 11:40:45 2016 -0700
@@ -233,6 +233,7 @@
   strcpy(copy, zip_name);
   _zip_name = copy;
   _is_boot_append = is_boot_append;
+  _multi_versioned = _unknown;
 }
 
 ClassPathZipEntry::~ClassPathZipEntry() {
@@ -330,13 +331,20 @@
 
 bool ClassPathZipEntry::is_multiple_versioned(TRAPS) {
   assert(DumpSharedSpaces, "called only at dump time");
+  if (_multi_versioned != _unknown) {
+    return (_multi_versioned == _yes) ? true : false;
+  }
   jint size;
-  char* buffer = (char*)open_entry("META-INF/MANIFEST.MF", &size, false, CHECK_false);
+  char* buffer = (char*)open_entry("META-INF/MANIFEST.MF", &size, true, CHECK_false);
   if (buffer != NULL) {
-    if (strstr(buffer, "Multi-Release: true") != NULL) {
+    char* p = buffer;
+    for ( ; *p; ++p) *p = tolower(*p);
+    if (strstr(buffer, "multi-release: true") != NULL) {
+      _multi_versioned = _yes;
       return true;
     }
   }
+  _multi_versioned = _no;
   return false;
 }
 #endif // INCLUDE_CDS
--- a/hotspot/src/share/vm/classfile/classLoader.hpp	Wed Apr 06 16:03:02 2016 +0200
+++ b/hotspot/src/share/vm/classfile/classLoader.hpp	Wed Apr 06 11:40:45 2016 -0700
@@ -101,10 +101,17 @@
 
 
 class ClassPathZipEntry: public ClassPathEntry {
+ enum {
+   _unknown = 0,
+   _yes     = 1,
+   _no      = 2
+ };
  private:
   jzfile* _zip;              // The zip archive
   const char*   _zip_name;   // Name of zip archive
   bool _is_boot_append;      // entry coming from -Xbootclasspath/a
+  u1 _multi_versioned;       // indicates if the jar file has multi-versioned entries.
+                             // It can have value of "_unknown", "_yes", or "_no"
  public:
   bool is_jrt()            { return false; }
   bool is_jar_file() const { return true;  }