Merge
authorpsadhukhan
Wed, 27 Feb 2019 14:48:22 +0530
changeset 54229 6673d2b7e084
parent 54228 a17f46493e0b (current diff)
parent 53940 f8b2179a55d0 (diff)
child 54230 d9d9655bb077
Merge
src/java.smartcardio/unix/native/libj2pcsc/MUSCLE/COPYING
src/jdk.jlink/share/classes/jdk/tools/jlink/internal/plugins/StripDebugPlugin.java
test/jdk/tools/jlink/plugins/StripDebugPluginTest.java
--- a/make/data/cldr/common/main/my.xml	Tue Feb 26 18:12:06 2019 +0000
+++ b/make/data/cldr/common/main/my.xml	Wed Feb 27 14:48:22 2019 +0530
@@ -1446,17 +1446,14 @@
 							<pattern>z HH:mm:ss</pattern>
 						</timeFormat>
 					</timeFormatLength>
-					<!--Pattern for medium and short replaced with CLDR 29's patterns 
-					    as character 'B' is currently not supported in SimpleDateFormat and java.time.DateTimeFormatter 
-					    classes. This is a restriction until JDK-8209175 is resolved.-->
 					<timeFormatLength type="medium">
 						<timeFormat>
-							<pattern>HH:mm:ss</pattern>
+							<pattern>B HH:mm:ss</pattern>
 						</timeFormat>
 					</timeFormatLength>
 					<timeFormatLength type="short">
 						<timeFormat>
-							<pattern>H:mm</pattern>
+							<pattern>B H:mm</pattern>
 						</timeFormat>
 					</timeFormatLength>
 				</timeFormats>
--- a/make/jdk/src/classes/build/tools/cldrconverter/Bundle.java	Tue Feb 26 18:12:06 2019 +0000
+++ b/make/jdk/src/classes/build/tools/cldrconverter/Bundle.java	Wed Feb 27 14:48:22 2019 +0530
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2012, 2018, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2012, 2019, 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
@@ -523,36 +523,46 @@
         for (String k : patternKeys) {
             if (myMap.containsKey(calendarPrefix + k)) {
                 int len = patternKeys.length;
-                List<String> rawPatterns = new ArrayList<>(len);
-                List<String> patterns = new ArrayList<>(len);
+                List<String> dateTimePatterns = new ArrayList<>(len);
+                List<String> sdfPatterns = new ArrayList<>(len);
                 for (int i = 0; i < len; i++) {
                     String key = calendarPrefix + patternKeys[i];
                     String pattern = (String) myMap.remove(key);
                     if (pattern == null) {
                         pattern = (String) parentsMap.remove(key);
                     }
-                    rawPatterns.add(i, pattern);
                     if (pattern != null) {
-                        patterns.add(i, translateDateFormatLetters(calendarType, pattern));
+                        // Perform date-time format pattern conversion which is
+                        // applicable to both SimpleDateFormat and j.t.f.DateTimeFormatter.
+                        // For example, character 'B' is mapped with 'a', as 'B' is not
+                        // supported in either SimpleDateFormat or j.t.f.DateTimeFormatter
+                        String transPattern = translateDateFormatLetters(calendarType, pattern, this::convertDateTimePatternLetter);
+                        dateTimePatterns.add(i, transPattern);
+                        // Additionally, perform SDF specific date-time format pattern conversion
+                        sdfPatterns.add(i, translateDateFormatLetters(calendarType, transPattern, this::convertSDFLetter));
                     } else {
-                        patterns.add(i, null);
+                        dateTimePatterns.add(i, null);
+                        sdfPatterns.add(i, null);
                     }
                 }
-                // If patterns is empty or has any nulls, discard patterns.
-                if (patterns.isEmpty()) {
+                // If empty, discard patterns
+                if (sdfPatterns.isEmpty()) {
                     return;
                 }
                 String key = calendarPrefix + name;
-                if (!rawPatterns.equals(patterns)) {
-                    myMap.put("java.time." + key, rawPatterns.toArray(new String[len]));
+
+                // If additional changes are made in the SDF specific conversion,
+                // keep the commonly converted patterns as java.time patterns
+                if (!dateTimePatterns.equals(sdfPatterns)) {
+                    myMap.put("java.time." + key, dateTimePatterns.toArray(String[]::new));
                 }
-                myMap.put(key, patterns.toArray(new String[len]));
+                myMap.put(key, sdfPatterns.toArray(new String[len]));
                 break;
             }
         }
     }
 
-    private String translateDateFormatLetters(CalendarType calendarType, String cldrFormat) {
+    private String translateDateFormatLetters(CalendarType calendarType, String cldrFormat, ConvertDateTimeLetters converter) {
         String pattern = cldrFormat;
         int length = pattern.length();
         boolean inQuote = false;
@@ -571,7 +581,7 @@
                     if (nextc == '\'') {
                         i++;
                         if (count != 0) {
-                            convert(calendarType, lastLetter, count, jrePattern);
+                            converter.convert(calendarType, lastLetter, count, jrePattern);
                             lastLetter = 0;
                             count = 0;
                         }
@@ -581,7 +591,7 @@
                 }
                 if (!inQuote) {
                     if (count != 0) {
-                        convert(calendarType, lastLetter, count, jrePattern);
+                        converter.convert(calendarType, lastLetter, count, jrePattern);
                         lastLetter = 0;
                         count = 0;
                     }
@@ -598,7 +608,7 @@
             }
             if (!(c >= 'a' && c <= 'z' || c >= 'A' && c <= 'Z')) {
                 if (count != 0) {
-                    convert(calendarType, lastLetter, count, jrePattern);
+                    converter.convert(calendarType, lastLetter, count, jrePattern);
                     lastLetter = 0;
                     count = 0;
                 }
@@ -611,7 +621,7 @@
                 count++;
                 continue;
             }
-            convert(calendarType, lastLetter, count, jrePattern);
+            converter.convert(calendarType, lastLetter, count, jrePattern);
             lastLetter = c;
             count = 1;
         }
@@ -621,7 +631,7 @@
         }
 
         if (count != 0) {
-            convert(calendarType, lastLetter, count, jrePattern);
+            converter.convert(calendarType, lastLetter, count, jrePattern);
         }
         if (cldrFormat.contentEquals(jrePattern)) {
             return cldrFormat;
@@ -676,71 +686,91 @@
         }
     }
 
-    private void convert(CalendarType calendarType, char cldrLetter, int count, StringBuilder sb) {
+    /**
+     * Perform a generic conversion of CLDR date-time format pattern letter based
+     * on the support given by the SimpleDateFormat and the j.t.f.DateTimeFormatter
+     * for date-time formatting.
+     */
+    private void convertDateTimePatternLetter(CalendarType calendarType, char cldrLetter, int count, StringBuilder sb) {
         switch (cldrLetter) {
-        case 'G':
-            if (calendarType != CalendarType.GREGORIAN) {
-                // Adjust the number of 'G's for JRE SimpleDateFormat
-                if (count == 5) {
-                    // CLDR narrow -> JRE short
-                    count = 1;
-                } else if (count == 1) {
-                    // CLDR abbr -> JRE long
-                    count = 4;
-                }
-            }
-            appendN(cldrLetter, count, sb);
-            break;
-
-        // TODO: support 'c' and 'e' in JRE SimpleDateFormat
-        // Use 'u' and 'E' for now.
-        case 'c':
-        case 'e':
-            switch (count) {
-            case 1:
-                sb.append('u');
+            case 'u':
+                // Change cldr letter 'u' to 'y', as 'u' is interpreted as
+                // "Extended year (numeric)" in CLDR/LDML,
+                // which is not supported in SimpleDateFormat and
+                // j.t.f.DateTimeFormatter, so it is replaced with 'y'
+                // as the best approximation
+                appendN('y', count, sb);
                 break;
-            case 3:
-            case 4:
-                appendN('E', count, sb);
+            case 'B':
+                // 'B' character (day period) is not supported by
+                // SimpleDateFormat and j.t.f.DateTimeFormatter,
+                // this is a workaround in which 'B' character
+                // appearing in CLDR date-time pattern is replaced
+                // with 'a' character and hence resolved with am/pm strings.
+                // This workaround is based on the the fallback mechanism
+                // specified in LDML spec for 'B' character, when a locale
+                // does not have data for day period ('B')
+                appendN('a', count, sb);
                 break;
-            case 5:
-                appendN('E', 3, sb);
+            default:
+                appendN(cldrLetter, count, sb);
                 break;
-            }
-            break;
 
-        case 'l':
-            // 'l' is deprecated as a pattern character. Should be ignored.
-            break;
+        }
+    }
 
-        case 'u':
-            // Use 'y' for now.
-            appendN('y', count, sb);
-            break;
-
-        case 'v':
-        case 'V':
-            appendN('z', count, sb);
-            break;
+    /**
+     * Perform a conversion of CLDR date-time format pattern letter which is
+     * specific to the SimpleDateFormat.
+     */
+    private void convertSDFLetter(CalendarType calendarType, char cldrLetter, int count, StringBuilder sb) {
+        switch (cldrLetter) {
+            case 'G':
+                if (calendarType != CalendarType.GREGORIAN) {
+                    // Adjust the number of 'G's for JRE SimpleDateFormat
+                    if (count == 5) {
+                        // CLDR narrow -> JRE short
+                        count = 1;
+                    } else if (count == 1) {
+                        // CLDR abbr -> JRE long
+                        count = 4;
+                    }
+                }
+                appendN(cldrLetter, count, sb);
+                break;
 
-        case 'Z':
-            if (count == 4 || count == 5) {
-                sb.append("XXX");
-            }
-            break;
+            // TODO: support 'c' and 'e' in JRE SimpleDateFormat
+            // Use 'u' and 'E' for now.
+            case 'c':
+            case 'e':
+                switch (count) {
+                    case 1:
+                        sb.append('u');
+                        break;
+                    case 3:
+                    case 4:
+                        appendN('E', count, sb);
+                        break;
+                    case 5:
+                        appendN('E', 3, sb);
+                        break;
+                }
+                break;
 
-        case 'U':
-        case 'q':
-        case 'Q':
-        case 'g':
-        case 'j':
-        case 'A':
-            throw new InternalError(String.format("Unsupported letter: '%c', count=%d, id=%s%n",
-                                                  cldrLetter, count, id));
-        default:
-            appendN(cldrLetter, count, sb);
-            break;
+            case 'v':
+            case 'V':
+                appendN('z', count, sb);
+                break;
+
+            case 'Z':
+                if (count == 4 || count == 5) {
+                    sb.append("XXX");
+                }
+                break;
+
+            default:
+                appendN(cldrLetter, count, sb);
+                break;
         }
     }
 
@@ -758,4 +788,9 @@
         }
         return false;
     }
+
+    @FunctionalInterface
+    private interface ConvertDateTimeLetters {
+        void convert(CalendarType calendarType, char cldrLetter, int count, StringBuilder sb);
+    }
 }
--- a/src/hotspot/cpu/aarch64/templateTable_aarch64.cpp	Tue Feb 26 18:12:06 2019 +0000
+++ b/src/hotspot/cpu/aarch64/templateTable_aarch64.cpp	Wed Feb 27 14:48:22 2019 +0530
@@ -2981,7 +2981,7 @@
   {
     Label notVolatile;
     __ tbz(r3, ConstantPoolCacheEntry::is_volatile_shift, notVolatile);
-    __ membar(MacroAssembler::StoreStore);
+    __ membar(MacroAssembler::StoreStore | MacroAssembler::LoadStore);
     __ bind(notVolatile);
   }
 
--- a/src/hotspot/os/windows/os_windows.cpp	Tue Feb 26 18:12:06 2019 +0000
+++ b/src/hotspot/os/windows/os_windows.cpp	Wed Feb 27 14:48:22 2019 +0530
@@ -602,7 +602,7 @@
   HANDLE interrupt_event = CreateEvent(NULL, true, false, NULL);
   if (interrupt_event == NULL) {
     delete osthread;
-    return NULL;
+    return false;
   }
   osthread->set_interrupt_event(interrupt_event);
   osthread->set_interrupted(false);
@@ -676,7 +676,7 @@
     CloseHandle(osthread->interrupt_event());
     thread->set_osthread(NULL);
     delete osthread;
-    return NULL;
+    return false;
   }
 
   Atomic::inc(&os::win32::_os_thread_count);
--- a/src/hotspot/share/classfile/javaClasses.cpp	Tue Feb 26 18:12:06 2019 +0000
+++ b/src/hotspot/share/classfile/javaClasses.cpp	Wed Feb 27 14:48:22 2019 +0530
@@ -3635,7 +3635,7 @@
     // distinct loaders) to ensure the metadata is kept alive.
     // This mirror may be different than the one in clazz field.
     new_resolved_method->obj_field_put(_vmholder_offset, m->method_holder()->java_mirror());
-    resolved_method = ResolvedMethodTable::add_method(Handle(THREAD, new_resolved_method));
+    resolved_method = ResolvedMethodTable::add_method(m, Handle(THREAD, new_resolved_method));
   }
   return resolved_method;
 }
--- a/src/hotspot/share/code/nmethod.cpp	Tue Feb 26 18:12:06 2019 +0000
+++ b/src/hotspot/share/code/nmethod.cpp	Wed Feb 27 14:48:22 2019 +0530
@@ -1370,6 +1370,8 @@
   assert(_speculation_log == NULL, "should have been nulled out when transitioned to zombie");
 #endif
 
+  Universe::heap()->flush_nmethod(this);
+
   CodeBlob::flush();
   CodeCache::free(this);
 }
--- a/src/hotspot/share/gc/shared/collectedHeap.hpp	Tue Feb 26 18:12:06 2019 +0000
+++ b/src/hotspot/share/gc/shared/collectedHeap.hpp	Wed Feb 27 14:48:22 2019 +0530
@@ -521,6 +521,7 @@
   // Override with specific mechanism for each specialized heap type.
   virtual void register_nmethod(nmethod* nm) {}
   virtual void unregister_nmethod(nmethod* nm) {}
+  virtual void flush_nmethod(nmethod* nm) {}
   virtual void verify_nmethod(nmethod* nmethod) {}
 
   void trace_heap_before_gc(const GCTracer* gc_tracer);
--- a/src/hotspot/share/gc/z/zCollectedHeap.cpp	Tue Feb 26 18:12:06 2019 +0000
+++ b/src/hotspot/share/gc/z/zCollectedHeap.cpp	Wed Feb 27 14:48:22 2019 +0530
@@ -262,6 +262,10 @@
   ZNMethod::unregister_nmethod(nm);
 }
 
+void ZCollectedHeap::flush_nmethod(nmethod* nm) {
+  ZNMethod::flush_nmethod(nm);
+}
+
 void ZCollectedHeap::verify_nmethod(nmethod* nm) {
   // Does nothing
 }
--- a/src/hotspot/share/gc/z/zCollectedHeap.hpp	Tue Feb 26 18:12:06 2019 +0000
+++ b/src/hotspot/share/gc/z/zCollectedHeap.hpp	Wed Feb 27 14:48:22 2019 +0530
@@ -105,6 +105,7 @@
 
   virtual void register_nmethod(nmethod* nm);
   virtual void unregister_nmethod(nmethod* nm);
+  virtual void flush_nmethod(nmethod* nm);
   virtual void verify_nmethod(nmethod* nmethod);
 
   virtual WorkGang* get_safepoint_workers();
--- a/src/hotspot/share/gc/z/zNMethod.cpp	Tue Feb 26 18:12:06 2019 +0000
+++ b/src/hotspot/share/gc/z/zNMethod.cpp	Wed Feb 27 14:48:22 2019 +0530
@@ -82,7 +82,7 @@
   // Attach GC data to nmethod
   ZNMethodData* data = gc_data(nm);
   if (data == NULL) {
-    data = ZNMethodData::create(nm);
+    data = new ZNMethodData();
     set_gc_data(nm, data);
   }
 
@@ -92,18 +92,8 @@
   ZNMethodDataOops::destroy(old_oops);
 }
 
-void ZNMethod::detach_gc_data(nmethod* nm) {
-  // Destroy GC data
-  ZNMethodData::destroy(gc_data(nm));
-  set_gc_data(nm, NULL);
-}
-
 ZReentrantLock* ZNMethod::lock_for_nmethod(nmethod* nm) {
-  ZNMethodData* const data = gc_data(nm);
-  if (data == NULL) {
-    return NULL;
-  }
-  return data->lock();
+  return gc_data(nm)->lock();
 }
 
 void ZNMethod::log_register(const nmethod* nm) {
@@ -190,9 +180,11 @@
   log_unregister(nm);
 
   ZNMethodTable::unregister_nmethod(nm);
+}
 
-  // Destroy and detach gc data
-  detach_gc_data(nm);
+void ZNMethod::flush_nmethod(nmethod* nm) {
+  // Destroy GC data
+  delete gc_data(nm);
 }
 
 void ZNMethod::disarm_nmethod(nmethod* nm) {
--- a/src/hotspot/share/gc/z/zNMethod.hpp	Tue Feb 26 18:12:06 2019 +0000
+++ b/src/hotspot/share/gc/z/zNMethod.hpp	Wed Feb 27 14:48:22 2019 +0530
@@ -34,7 +34,6 @@
 class ZNMethod : public AllStatic {
 private:
   static void attach_gc_data(nmethod* nm);
-  static void detach_gc_data(nmethod* nm);
 
   static void log_register(const nmethod* nm);
   static void log_unregister(const nmethod* nm);
@@ -42,6 +41,7 @@
 public:
   static void register_nmethod(nmethod* nm);
   static void unregister_nmethod(nmethod* nm);
+  static void flush_nmethod(nmethod* nm);
 
   static void disarm_nmethod(nmethod* nm);
 
--- a/src/hotspot/share/gc/z/zNMethodData.cpp	Tue Feb 26 18:12:06 2019 +0000
+++ b/src/hotspot/share/gc/z/zNMethodData.cpp	Wed Feb 27 14:48:22 2019 +0530
@@ -23,7 +23,6 @@
 
 #include "precompiled.hpp"
 #include "gc/z/zLock.inline.hpp"
-#include "gc/z/zNMethodAllocator.hpp"
 #include "gc/z/zNMethodData.hpp"
 #include "memory/allocation.hpp"
 #include "runtime/atomic.hpp"
@@ -42,12 +41,12 @@
   // Allocate memory for the ZNMethodDataOops object
   // plus the immediate oop* array that follows right after.
   const size_t size = ZNMethodDataOops::header_size() + (sizeof(oop*) * immediates.length());
-  void* const mem = ZNMethodAllocator::allocate(size);
+  void* const mem = NEW_C_HEAP_ARRAY(uint8_t, size, mtGC);
   return ::new (mem) ZNMethodDataOops(immediates, has_non_immediates);
 }
 
 void ZNMethodDataOops::destroy(ZNMethodDataOops* oops) {
-  ZNMethodAllocator::free(oops);
+  FREE_C_HEAP_ARRAY(uint8_t, oops);
 }
 
 ZNMethodDataOops::ZNMethodDataOops(const GrowableArray<oop*>& immediates, bool has_non_immediates) :
@@ -76,20 +75,14 @@
   return _has_non_immediates;
 }
 
-ZNMethodData* ZNMethodData::create(nmethod* nm) {
-  void* const mem = ZNMethodAllocator::allocate(sizeof(ZNMethodData));
-  return ::new (mem) ZNMethodData(nm);
-}
-
-void ZNMethodData::destroy(ZNMethodData* data) {
-  ZNMethodAllocator::free(data->oops());
-  ZNMethodAllocator::free(data);
-}
-
-ZNMethodData::ZNMethodData(nmethod* nm) :
+ZNMethodData::ZNMethodData() :
     _lock(),
     _oops(NULL) {}
 
+ZNMethodData::~ZNMethodData() {
+  ZNMethodDataOops::destroy(_oops);
+}
+
 ZReentrantLock* ZNMethodData::lock() {
   return &_lock;
 }
@@ -99,5 +92,8 @@
 }
 
 ZNMethodDataOops* ZNMethodData::swap_oops(ZNMethodDataOops* new_oops) {
-  return Atomic::xchg(new_oops, &_oops);
+  ZLocker<ZReentrantLock> locker(&_lock);
+  ZNMethodDataOops* const old_oops = _oops;
+  _oops = new_oops;
+  return old_oops;
 }
--- a/src/hotspot/share/gc/z/zNMethodData.hpp	Tue Feb 26 18:12:06 2019 +0000
+++ b/src/hotspot/share/gc/z/zNMethodData.hpp	Wed Feb 27 14:48:22 2019 +0530
@@ -22,6 +22,7 @@
  */
 
 #include "gc/z/zLock.hpp"
+#include "memory/allocation.hpp"
 #include "oops/oopsHierarchy.hpp"
 #include "utilities/globalDefinitions.hpp"
 
@@ -51,16 +52,14 @@
   bool has_non_immediates() const;
 };
 
-class ZNMethodData {
+class ZNMethodData : public CHeapObj<mtGC> {
 private:
   ZReentrantLock             _lock;
   ZNMethodDataOops* volatile _oops;
 
-  ZNMethodData(nmethod* nm);
-
 public:
-  static ZNMethodData* create(nmethod* nm);
-  static void destroy(ZNMethodData* data);
+  ZNMethodData();
+  ~ZNMethodData();
 
   ZReentrantLock* lock();
 
--- a/src/hotspot/share/gc/z/zUnload.cpp	Tue Feb 26 18:12:06 2019 +0000
+++ b/src/hotspot/share/gc/z/zUnload.cpp	Wed Feb 27 14:48:22 2019 +0530
@@ -65,23 +65,14 @@
 };
 
 class ZIsUnloadingBehaviour : public IsUnloadingBehaviour {
-private:
-  bool is_unloading(nmethod* nm) const {
-    ZIsUnloadingOopClosure cl;
-    nm->oops_do(&cl, true /* allow_zombie */);
-    return cl.is_unloading();
-  }
-
 public:
   virtual bool is_unloading(CompiledMethod* method) const {
     nmethod* const nm = method->as_nmethod();
     ZReentrantLock* const lock = ZNMethod::lock_for_nmethod(nm);
-    if (lock == NULL) {
-      return is_unloading(nm);
-    } else {
-      ZLocker<ZReentrantLock> locker(lock);
-      return is_unloading(nm);
-    }
+    ZLocker<ZReentrantLock> locker(lock);
+    ZIsUnloadingOopClosure cl;
+    nm->oops_do(&cl, true /* allow_zombie */);
+    return cl.is_unloading();
   }
 };
 
@@ -90,18 +81,14 @@
   virtual bool lock(CompiledMethod* method) {
     nmethod* const nm = method->as_nmethod();
     ZReentrantLock* const lock = ZNMethod::lock_for_nmethod(nm);
-    if (lock != NULL) {
-      lock->lock();
-    }
+    lock->lock();
     return true;
   }
 
   virtual void unlock(CompiledMethod* method) {
     nmethod* const nm = method->as_nmethod();
     ZReentrantLock* const lock = ZNMethod::lock_for_nmethod(nm);
-    if (lock != NULL) {
-      lock->unlock();
-    }
+    lock->unlock();
   }
 
   virtual bool is_safe(CompiledMethod* method) {
@@ -111,7 +98,7 @@
 
     nmethod* const nm = method->as_nmethod();
     ZReentrantLock* const lock = ZNMethod::lock_for_nmethod(nm);
-    return lock == NULL || lock->is_owned();
+    return lock->is_owned();
   }
 };
 
--- a/src/hotspot/share/memory/universe.cpp	Tue Feb 26 18:12:06 2019 +0000
+++ b/src/hotspot/share/memory/universe.cpp	Wed Feb 27 14:48:22 2019 +0530
@@ -107,6 +107,7 @@
 LatestMethodCache* Universe::_finalizer_register_cache = NULL;
 LatestMethodCache* Universe::_loader_addClass_cache    = NULL;
 LatestMethodCache* Universe::_throw_illegal_access_error_cache = NULL;
+LatestMethodCache* Universe::_throw_no_such_method_error_cache = NULL;
 LatestMethodCache* Universe::_do_stack_walk_cache     = NULL;
 oop Universe::_out_of_memory_error_java_heap          = NULL;
 oop Universe::_out_of_memory_error_metaspace          = NULL;
@@ -230,6 +231,7 @@
   _finalizer_register_cache->metaspace_pointers_do(it);
   _loader_addClass_cache->metaspace_pointers_do(it);
   _throw_illegal_access_error_cache->metaspace_pointers_do(it);
+  _throw_no_such_method_error_cache->metaspace_pointers_do(it);
   _do_stack_walk_cache->metaspace_pointers_do(it);
 }
 
@@ -271,6 +273,7 @@
   _finalizer_register_cache->serialize(f);
   _loader_addClass_cache->serialize(f);
   _throw_illegal_access_error_cache->serialize(f);
+  _throw_no_such_method_error_cache->serialize(f);
   _do_stack_walk_cache->serialize(f);
 }
 
@@ -689,6 +692,7 @@
   Universe::_finalizer_register_cache = new LatestMethodCache();
   Universe::_loader_addClass_cache    = new LatestMethodCache();
   Universe::_throw_illegal_access_error_cache = new LatestMethodCache();
+  Universe::_throw_no_such_method_error_cache = new LatestMethodCache();
   Universe::_do_stack_walk_cache = new LatestMethodCache();
 
 #if INCLUDE_CDS
@@ -935,6 +939,11 @@
                           "throwIllegalAccessError",
                           vmSymbols::void_method_signature(), true, CHECK);
 
+  initialize_known_method(_throw_no_such_method_error_cache,
+                          SystemDictionary::internal_Unsafe_klass(),
+                          "throwNoSuchMethodError",
+                          vmSymbols::void_method_signature(), true, CHECK);
+
   // Set up method for registering loaded classes in class loader vector
   initialize_known_method(_loader_addClass_cache,
                           SystemDictionary::ClassLoader_klass(),
--- a/src/hotspot/share/memory/universe.hpp	Tue Feb 26 18:12:06 2019 +0000
+++ b/src/hotspot/share/memory/universe.hpp	Wed Feb 27 14:48:22 2019 +0530
@@ -138,6 +138,7 @@
   static LatestMethodCache* _finalizer_register_cache; // static method for registering finalizable objects
   static LatestMethodCache* _loader_addClass_cache;    // method for registering loaded classes in class loader vector
   static LatestMethodCache* _throw_illegal_access_error_cache; // Unsafe.throwIllegalAccessError() method
+  static LatestMethodCache* _throw_no_such_method_error_cache; // Unsafe.throwNoSuchMethodError() method
   static LatestMethodCache* _do_stack_walk_cache;      // method for stack walker callback
 
   // preallocated error objects (no backtrace)
@@ -322,6 +323,7 @@
   static Method*      loader_addClass_method()        { return _loader_addClass_cache->get_method(); }
 
   static Method*      throw_illegal_access_error()    { return _throw_illegal_access_error_cache->get_method(); }
+  static Method*      throw_no_such_method_error()    { return _throw_no_such_method_error_cache->get_method(); }
 
   static Method*      do_stack_walk_method()          { return _do_stack_walk_cache->get_method(); }
 
--- a/src/hotspot/share/oops/method.cpp	Tue Feb 26 18:12:06 2019 +0000
+++ b/src/hotspot/share/oops/method.cpp	Wed Feb 27 14:48:22 2019 +0530
@@ -2120,7 +2120,8 @@
   // Can't assert the method_holder is the same because the new method has the
   // scratch method holder.
   assert(resolve_jmethod_id(jmid)->method_holder()->class_loader()
-           == new_method->method_holder()->class_loader(),
+           == new_method->method_holder()->class_loader() ||
+           new_method->method_holder()->class_loader() == NULL, // allow Unsafe substitution
          "changing to a different class loader");
   // Just change the method in place, jmethodID pointer doesn't change.
   *((Method**)jmid) = new_method;
--- a/src/hotspot/share/prims/jvmtiRedefineClasses.cpp	Tue Feb 26 18:12:06 2019 +0000
+++ b/src/hotspot/share/prims/jvmtiRedefineClasses.cpp	Wed Feb 27 14:48:22 2019 +0530
@@ -3525,6 +3525,15 @@
              "should be replaced");
     }
   }
+  // Update deleted jmethodID
+  for (int j = 0; j < _deleted_methods_length; ++j) {
+    Method* old_method = _deleted_methods[j];
+    jmethodID jmid = old_method->find_jmethod_id_or_null();
+    if (jmid != NULL) {
+      // Change the jmethodID to point to NSME.
+      Method::change_method_associated_with_jmethod_id(jmid, Universe::throw_no_such_method_error());
+    }
+  }
 }
 
 int VM_RedefineClasses::check_methods_and_mark_as_obsolete() {
--- a/src/hotspot/share/prims/resolvedMethodTable.cpp	Tue Feb 26 18:12:06 2019 +0000
+++ b/src/hotspot/share/prims/resolvedMethodTable.cpp	Wed Feb 27 14:48:22 2019 +0530
@@ -120,18 +120,21 @@
   return entry;
 }
 
-oop ResolvedMethodTable::add_method(Handle resolved_method_name) {
+oop ResolvedMethodTable::add_method(const methodHandle& m, Handle resolved_method_name) {
   MutexLocker ml(ResolvedMethodTable_lock);
   DEBUG_ONLY(NoSafepointVerifier nsv);
 
+  Method* method = m();
   // Check if method has been redefined while taking out ResolvedMethodTable_lock, if so
-  // use new method.
-  Method* method = (Method*)java_lang_invoke_ResolvedMethodName::vmtarget(resolved_method_name());
-  assert(method->is_method(), "must be method");
+  // use new method.  The old method won't be deallocated because it's passed in as a Handle.
   if (method->is_old()) {
     // Replace method with redefined version
     InstanceKlass* holder = method->method_holder();
     method = holder->method_with_idnum(method->method_idnum());
+    if (method == NULL) {
+      // Replace deleted method with NSME.
+      method = Universe::throw_no_such_method_error();
+    }
     java_lang_invoke_ResolvedMethodName::set_vmtarget(resolved_method_name(), method);
   }
   // Set flag in class to indicate this InstanceKlass has entries in the table
@@ -226,13 +229,9 @@
 
       if (old_method->is_old()) {
 
-        if (old_method->is_deleted()) {
-          // leave deleted method in ResolvedMethod for now (this is a bug that we don't mark
-          // these on_stack)
-          continue;
-        }
-
-        Method* new_method = old_method->get_new_method();
+        Method* new_method = (old_method->is_deleted()) ?
+                              Universe::throw_no_such_method_error() :
+                              old_method->get_new_method();
         java_lang_invoke_ResolvedMethodName::set_vmtarget(mem_name, new_method);
 
         ResourceMark rm;
--- a/src/hotspot/share/prims/resolvedMethodTable.hpp	Tue Feb 26 18:12:06 2019 +0000
+++ b/src/hotspot/share/prims/resolvedMethodTable.hpp	Wed Feb 27 14:48:22 2019 +0530
@@ -89,7 +89,7 @@
 
   // Called from java_lang_invoke_ResolvedMethodName
   static oop find_method(Method* method);
-  static oop add_method(Handle rmethod_name);
+  static oop add_method(const methodHandle& method, Handle rmethod_name);
 
   static bool has_work() { return _dead_entries; }
   static void trigger_cleanup();
--- a/src/hotspot/share/utilities/debug.cpp	Tue Feb 26 18:12:06 2019 +0000
+++ b/src/hotspot/share/utilities/debug.cpp	Wed Feb 27 14:48:22 2019 +0530
@@ -643,6 +643,7 @@
   tty->print_cr("                   pns($sp, $rbp, $pc) on Linux/amd64 and Solaris/amd64 or");
   tty->print_cr("                   pns($sp, $ebp, $pc) on Linux/x86 or");
   tty->print_cr("                   pns($sp, 0, $pc)    on Linux/ppc64 or");
+  tty->print_cr("                   pns($sp, $s8, $pc)  on Linux/mips or");
   tty->print_cr("                   pns($sp + 0x7ff, 0, $pc) on Solaris/SPARC");
   tty->print_cr("                 - in gdb do 'set overload-resolution off' before calling pns()");
   tty->print_cr("                 - in dbx do 'frame 1' before calling pns()");
--- a/src/hotspot/share/utilities/ostream.cpp	Tue Feb 26 18:12:06 2019 +0000
+++ b/src/hotspot/share/utilities/ostream.cpp	Wed Feb 27 14:48:22 2019 +0530
@@ -559,13 +559,6 @@
   fflush(_file);
 }
 
-fdStream::~fdStream() {
-  if (_fd != -1) {
-    if (_need_close) close(_fd);
-    _fd = -1;
-  }
-}
-
 void fdStream::write(const char* s, size_t len) {
   if (_fd != -1) {
     // Make an unused local variable to avoid warning from gcc 4.x compiler.
--- a/src/hotspot/share/utilities/ostream.hpp	Tue Feb 26 18:12:06 2019 +0000
+++ b/src/hotspot/share/utilities/ostream.hpp	Wed Feb 27 14:48:22 2019 +0530
@@ -216,7 +216,6 @@
   fileStream(FILE* file, bool need_close = false) { _file = file; _need_close = need_close; }
   ~fileStream();
   bool is_open() const { return _file != NULL; }
-  void set_need_close(bool b) { _need_close = b;}
   virtual void write(const char* c, size_t len);
   size_t read(void *data, size_t size, size_t count) { return ::fread(data, size, count, _file); }
   char* readln(char *data, int count);
@@ -235,13 +234,10 @@
 class fdStream : public outputStream {
  protected:
   int  _fd;
-  bool _need_close;
  public:
-  fdStream(const char* file_name);
-  fdStream(int fd = -1) { _fd = fd; _need_close = false; }
-  ~fdStream();
+  fdStream(int fd = -1) : _fd(fd) { }
   bool is_open() const { return _fd != -1; }
-  void set_fd(int fd) { _fd = fd; _need_close = false; }
+  void set_fd(int fd) { _fd = fd; }
   int fd() const { return _fd; }
   virtual void write(const char* c, size_t len);
   void flush() {};
--- a/src/java.base/share/classes/java/util/spi/ToolProvider.java	Tue Feb 26 18:12:06 2019 +0000
+++ b/src/java.base/share/classes/java/util/spi/ToolProvider.java	Wed Feb 27 14:48:22 2019 +0530
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2016, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2016, 2019, 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
@@ -126,8 +126,9 @@
     default int run(PrintStream out, PrintStream err, String... args) {
         Objects.requireNonNull(out);
         Objects.requireNonNull(err);
+        Objects.requireNonNull(args);
         for (String arg : args) {
-            Objects.requireNonNull(args);
+            Objects.requireNonNull(arg);
         }
 
         PrintWriter outWriter = new PrintWriter(out);
--- a/src/java.base/share/classes/jdk/internal/misc/Unsafe.java	Tue Feb 26 18:12:06 2019 +0000
+++ b/src/java.base/share/classes/jdk/internal/misc/Unsafe.java	Wed Feb 27 14:48:22 2019 +0530
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2000, 2018, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2000, 2019, 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
@@ -3114,7 +3114,7 @@
      * @param offset field/element offset
      * @param mask the mask value
      * @return the previous value
-     * @since 1.9
+     * @since 9
      */
     @ForceInline
     public final int getAndBitwiseAndInt(Object o, long offset, int mask) {
@@ -3343,6 +3343,14 @@
     }
 
     /**
+     * Throws NoSuchMethodError; for use by the VM for redefinition support.
+     * @since 13
+     */
+    private static void throwNoSuchMethodError() {
+        throw new NoSuchMethodError();
+    }
+
+    /**
      * @return Returns true if the native byte ordering of this
      * platform is big-endian, false if it is little-endian.
      */
--- a/src/java.base/share/classes/jdk/internal/reflect/ReflectionFactory.java	Tue Feb 26 18:12:06 2019 +0000
+++ b/src/java.base/share/classes/jdk/internal/reflect/ReflectionFactory.java	Wed Feb 27 14:48:22 2019 +0530
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2001, 2018, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2001, 2019, 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
@@ -175,7 +175,7 @@
     public FieldAccessor newFieldAccessor(Field field, boolean override) {
         checkInitted();
 
-        Field root = langReflectAccess.getRoot(field);
+        Field root = langReflectAccess().getRoot(field);
         if (root != null) {
             // FieldAccessor will use the root unless the modifiers have
             // been overrridden
@@ -197,7 +197,7 @@
         }
 
         // use the root Method that will not cache caller class
-        Method root = langReflectAccess.getRoot(method);
+        Method root = langReflectAccess().getRoot(method);
         if (root != null) {
             method = root;
         }
@@ -233,7 +233,7 @@
         }
 
         // use the root Constructor that will not cache caller class
-        Constructor<?> root = langReflectAccess.getRoot(c);
+        Constructor<?> root = langReflectAccess().getRoot(c);
         if (root != null) {
             c = root;
         }
--- a/src/java.smartcardio/share/native/libj2pcsc/pcsc.c	Tue Feb 26 18:12:06 2019 +0000
+++ b/src/java.smartcardio/share/native/libj2pcsc/pcsc.c	Wed Feb 27 14:48:22 2019 +0530
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2005, 2018, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2005, 2019, 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
@@ -181,7 +181,7 @@
 {
     SCARDCONTEXT context = (SCARDCONTEXT)jContext;
     LONG rv;
-    LPTSTR mszReaders = NULL;
+    LPSTR mszReaders = NULL;
     DWORD size = 0;
     jobjectArray result;
 
@@ -220,7 +220,7 @@
 {
     SCARDCONTEXT context = (SCARDCONTEXT)jContext;
     LONG rv;
-    LPCTSTR readerName;
+    LPCSTR readerName;
     SCARDHANDLE card = 0;
     DWORD proto = 0;
 
--- a/src/java.smartcardio/unix/native/libj2pcsc/MUSCLE/COPYING	Tue Feb 26 18:12:06 2019 +0000
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,28 +0,0 @@
-Copyright (c) 1999-2003 David Corcoran <corcoran@linuxnet.com>
-All rights reserved.
-
-Redistribution and use in source and binary forms, with or without
-modification, are permitted provided that the following conditions
-are met:
-
-1. Redistributions of source code must retain the above copyright
-   notice, this list of conditions and the following disclaimer.
-2. Redistributions in binary form must reproduce the above copyright
-   notice, this list of conditions and the following disclaimer in the
-   documentation and/or other materials provided with the distribution.
-3. The name of the author may not be used to endorse or promote products
-   derived from this software without specific prior written permission.
-
-Changes to this license can be made only by the copyright author with 
-explicit written consent.
-
-THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
-IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
-OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
-IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
-INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
-NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
-DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
-THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
-(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
-THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
--- a/src/java.smartcardio/unix/native/libj2pcsc/MUSCLE/pcsclite.h	Tue Feb 26 18:12:06 2019 +0000
+++ b/src/java.smartcardio/unix/native/libj2pcsc/MUSCLE/pcsclite.h	Wed Feb 27 14:48:22 2019 +0530
@@ -1,374 +1,306 @@
 /*
- * This keeps a list of defines for pcsc-lite.
- *
- * MUSCLE SmartCard Development ( http://www.linuxnet.com )
+ * MUSCLE SmartCard Development ( https://pcsclite.apdu.fr/ )
  *
  * Copyright (C) 1999-2004
- *  David Corcoran <corcoran@linuxnet.com>
+ *  David Corcoran <corcoran@musclecard.com>
+ * Copyright (C) 2002-2011
  *  Ludovic Rousseau <ludovic.rousseau@free.fr>
+ * Copyright (C) 2005
+ *  Martin Paljak <martin@paljak.pri.ee>
  *
- * $Id: pcsclite.h.in,v 1.47 2004/08/24 21:46:57 rousseau Exp $
+Redistribution and use in source and binary forms, with or without
+modification, are permitted provided that the following conditions
+are met:
+
+1. Redistributions of source code must retain the above copyright
+   notice, this list of conditions and the following disclaimer.
+2. Redistributions in binary form must reproduce the above copyright
+   notice, this list of conditions and the following disclaimer in the
+   documentation and/or other materials provided with the distribution.
+3. The name of the author may not be used to endorse or promote products
+   derived from this software without specific prior written permission.
+
+THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
+IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
+OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
+IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
+INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
+NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
+THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+/**
+ * @file
+ * @brief This keeps a list of defines for pcsc-lite.
+ *
+ * Error codes from http://msdn.microsoft.com/en-us/library/aa924526.aspx
  */
 
 #ifndef __pcsclite_h__
 #define __pcsclite_h__
 
-#ifndef __sun_jdk
 #include <wintypes.h>
-#else
-#include <sys/types.h>
-#include <inttypes.h>
-#ifdef BYTE
-#error BYTE is already defined
-#else
-  typedef unsigned char BYTE;
-#endif /* End BYTE */
-
-        typedef unsigned char UCHAR;
-        typedef unsigned char *PUCHAR;
-        typedef unsigned short USHORT;
-        typedef unsigned long ULONG;
-        typedef void *LPVOID;
-        typedef short BOOL;
-        typedef unsigned long *PULONG;
-        typedef const void *LPCVOID;
-        typedef unsigned long DWORD;
-        typedef unsigned long *PDWORD;
-        typedef unsigned short WORD;
-        typedef long LONG;
-        typedef long RESPONSECODE;
-        typedef const char *LPCTSTR;
-        typedef const BYTE *LPCBYTE;
-        typedef BYTE *LPBYTE;
-        typedef DWORD *LPDWORD;
-        typedef char *LPTSTR;
-
-#endif
 
 #ifdef __cplusplus
 extern "C"
 {
 #endif
 
-#ifdef WIN32
-#include <winscard.h>
-#else
-typedef long SCARDCONTEXT;
+typedef LONG SCARDCONTEXT; /**< \p hContext returned by SCardEstablishContext() */
 typedef SCARDCONTEXT *PSCARDCONTEXT;
 typedef SCARDCONTEXT *LPSCARDCONTEXT;
-typedef long SCARDHANDLE;
+typedef LONG SCARDHANDLE; /**< \p hCard returned by SCardConnect() */
 typedef SCARDHANDLE *PSCARDHANDLE;
 typedef SCARDHANDLE *LPSCARDHANDLE;
 
-#define MAX_ATR_SIZE                    33      /* Maximum ATR size */
+#define MAX_ATR_SIZE                  33      /**< Maximum ATR size */
 
-#ifndef __APPLE__
+/* Set structure elements aligment on bytes
+ * http://gcc.gnu.org/onlinedocs/gcc/Structure_002dPacking-Pragmas.html */
+#ifdef __APPLE__
+#pragma pack(1)
+#endif
 
 typedef struct
 {
-        const char *szReader;
-        void *pvUserData;
-        unsigned long dwCurrentState;
-        unsigned long dwEventState;
-        unsigned long cbAtr;
-        unsigned char rgbAtr[MAX_ATR_SIZE];
+      const char *szReader;
+      void *pvUserData;
+      DWORD dwCurrentState;
+      DWORD dwEventState;
+      DWORD cbAtr;
+      unsigned char rgbAtr[MAX_ATR_SIZE];
 }
-SCARD_READERSTATE_A;
+SCARD_READERSTATE, *LPSCARD_READERSTATE;
 
-typedef struct _SCARD_IO_REQUEST
-{
-        unsigned long dwProtocol;       /* Protocol identifier */
-        unsigned long cbPciLength;      /* Protocol Control Inf Length */
-}
-SCARD_IO_REQUEST, *PSCARD_IO_REQUEST, *LPSCARD_IO_REQUEST;
-
-#else // __APPLE__
-
-#pragma pack(1)
+/** Protocol Control Information (PCI) */
 typedef struct
 {
-        const char *szReader;
-        void *pvUserData;
-        uint32_t dwCurrentState;
-        uint32_t dwEventState;
-        uint32_t cbAtr;
-        unsigned char rgbAtr[MAX_ATR_SIZE];
-}
-SCARD_READERSTATE_A;
-
-typedef struct _SCARD_IO_REQUEST
-{
-        uint32_t dwProtocol;            /* Protocol identifier */
-        uint32_t cbPciLength;           /* Protocol Control Inf Length */
+      unsigned long dwProtocol;      /**< Protocol identifier */
+      unsigned long cbPciLength;      /**< Protocol Control Inf Length */
 }
 SCARD_IO_REQUEST, *PSCARD_IO_REQUEST, *LPSCARD_IO_REQUEST;
-#pragma pack()
-
-#endif // __APPLE__
-
-typedef SCARD_READERSTATE_A SCARD_READERSTATE, *PSCARD_READERSTATE_A,
-        *LPSCARD_READERSTATE_A;
 
 typedef const SCARD_IO_REQUEST *LPCSCARD_IO_REQUEST;
 
-extern SCARD_IO_REQUEST g_rgSCardT0Pci, g_rgSCardT1Pci,
-        g_rgSCardRawPci;
-
-#define SCARD_PCI_T0    (&g_rgSCardT0Pci)
-#define SCARD_PCI_T1    (&g_rgSCardT1Pci)
-#define SCARD_PCI_RAW   (&g_rgSCardRawPci)
-
-#define SCARD_S_SUCCESS                 0x00000000
-#define SCARD_E_CANCELLED               0x80100002
-#define SCARD_E_CANT_DISPOSE            0x8010000E
-#define SCARD_E_INSUFFICIENT_BUFFER     0x80100008
-#define SCARD_E_INVALID_ATR             0x80100015
-#define SCARD_E_INVALID_HANDLE          0x80100003
-#define SCARD_E_INVALID_PARAMETER       0x80100004
-#define SCARD_E_INVALID_TARGET          0x80100005
-#define SCARD_E_INVALID_VALUE           0x80100011
-#define SCARD_E_NO_MEMORY               0x80100006
-#define SCARD_F_COMM_ERROR              0x80100013
-#define SCARD_F_INTERNAL_ERROR          0x80100001
-#define SCARD_F_UNKNOWN_ERROR           0x80100014
-#define SCARD_F_WAITED_TOO_LONG         0x80100007
-#define SCARD_E_UNKNOWN_READER          0x80100009
-#define SCARD_E_TIMEOUT                 0x8010000A
-#define SCARD_E_SHARING_VIOLATION       0x8010000B
-#define SCARD_E_NO_SMARTCARD            0x8010000C
-#define SCARD_E_UNKNOWN_CARD            0x8010000D
-#define SCARD_E_PROTO_MISMATCH          0x8010000F
-#define SCARD_E_NOT_READY               0x80100010
-#define SCARD_E_SYSTEM_CANCELLED        0x80100012
-#define SCARD_E_NOT_TRANSACTED          0x80100016
-#define SCARD_E_READER_UNAVAILABLE      0x80100017
-
-#define SCARD_W_UNSUPPORTED_CARD        0x80100065
-#define SCARD_W_UNRESPONSIVE_CARD       0x80100066
-#define SCARD_W_UNPOWERED_CARD          0x80100067
-#define SCARD_W_RESET_CARD              0x80100068
-#define SCARD_W_REMOVED_CARD            0x80100069
-
-#define SCARD_E_PCI_TOO_SMALL           0x80100019
-#define SCARD_E_READER_UNSUPPORTED      0x8010001A
-#define SCARD_E_DUPLICATE_READER        0x8010001B
-#define SCARD_E_CARD_UNSUPPORTED        0x8010001C
-#define SCARD_E_NO_SERVICE              0x8010001D
-#define SCARD_E_SERVICE_STOPPED         0x8010001E
-
-#define SCARD_SCOPE_USER                0x0000  /* Scope in user space */
-#define SCARD_SCOPE_TERMINAL            0x0001  /* Scope in terminal */
-#define SCARD_SCOPE_SYSTEM              0x0002  /* Scope in system */
-
-#define SCARD_PROTOCOL_UNSET            0x0000  /* protocol not set */
-#define SCARD_PROTOCOL_T0               0x0001  /* T=0 active protocol. */
-#define SCARD_PROTOCOL_T1               0x0002  /* T=1 active protocol. */
-#define SCARD_PROTOCOL_RAW              0x0004  /* Raw active protocol. */
-#define SCARD_PROTOCOL_T15              0x0008  /* T=15 protocol. */
-
-#define SCARD_PROTOCOL_ANY              (SCARD_PROTOCOL_T0|SCARD_PROTOCOL_T1)   /* IFD determines prot. */
-
-#define SCARD_SHARE_EXCLUSIVE           0x0001  /* Exclusive mode only */
-#define SCARD_SHARE_SHARED              0x0002  /* Shared mode only */
-#define SCARD_SHARE_DIRECT              0x0003  /* Raw mode only */
-
-#define SCARD_LEAVE_CARD                0x0000  /* Do nothing on close */
-#define SCARD_RESET_CARD                0x0001  /* Reset on close */
-#define SCARD_UNPOWER_CARD              0x0002  /* Power down on close */
-#define SCARD_EJECT_CARD                0x0003  /* Eject on close */
-
-#define SCARD_UNKNOWN                   0x0001  /* Unknown state */
-#define SCARD_ABSENT                    0x0002  /* Card is absent */
-#define SCARD_PRESENT                   0x0004  /* Card is present */
-#define SCARD_SWALLOWED                 0x0008  /* Card not powered */
-#define SCARD_POWERED                   0x0010  /* Card is powered */
-#define SCARD_NEGOTIABLE                0x0020  /* Ready for PTS */
-#define SCARD_SPECIFIC                  0x0040  /* PTS has been set */
+extern const SCARD_IO_REQUEST g_rgSCardT0Pci, g_rgSCardT1Pci, g_rgSCardRawPci;
 
-#define SCARD_STATE_UNAWARE             0x0000  /* App wants status */
-#define SCARD_STATE_IGNORE              0x0001  /* Ignore this reader */
-#define SCARD_STATE_CHANGED             0x0002  /* State has changed */
-#define SCARD_STATE_UNKNOWN             0x0004  /* Reader unknown */
-#define SCARD_STATE_UNAVAILABLE         0x0008  /* Status unavailable */
-#define SCARD_STATE_EMPTY               0x0010  /* Card removed */
-#define SCARD_STATE_PRESENT             0x0020  /* Card inserted */
-#define SCARD_STATE_ATRMATCH            0x0040  /* ATR matches card */
-#define SCARD_STATE_EXCLUSIVE           0x0080  /* Exclusive Mode */
-#define SCARD_STATE_INUSE               0x0100  /* Shared Mode */
-#define SCARD_STATE_MUTE                0x0200  /* Unresponsive card */
-#define SCARD_STATE_UNPOWERED           0x0400  /* Unpowered card */
-
-/*
- * Tags for requesting card and reader attributes
- */
-
-#define SCARD_ATTR_VALUE(Class, Tag) ((((ULONG)(Class)) << 16) | ((ULONG)(Tag)))
-
-#define SCARD_CLASS_VENDOR_INFO     1   /* Vendor information definitions */
-#define SCARD_CLASS_COMMUNICATIONS  2   /* Communication definitions */
-#define SCARD_CLASS_PROTOCOL        3   /* Protocol definitions */
-#define SCARD_CLASS_POWER_MGMT      4   /* Power Management definitions */
-#define SCARD_CLASS_SECURITY        5   /* Security Assurance definitions */
-#define SCARD_CLASS_MECHANICAL      6   /* Mechanical characteristic definitions */
-#define SCARD_CLASS_VENDOR_DEFINED  7   /* Vendor specific definitions */
-#define SCARD_CLASS_IFD_PROTOCOL    8   /* Interface Device Protocol options */
-#define SCARD_CLASS_ICC_STATE       9   /* ICC State specific definitions */
-#define SCARD_CLASS_SYSTEM     0x7fff   /* System-specific definitions */
-
-#define SCARD_ATTR_VENDOR_NAME SCARD_ATTR_VALUE(SCARD_CLASS_VENDOR_INFO, 0x0100)
-#define SCARD_ATTR_VENDOR_IFD_TYPE SCARD_ATTR_VALUE(SCARD_CLASS_VENDOR_INFO, 0x0101)
-#define SCARD_ATTR_VENDOR_IFD_VERSION SCARD_ATTR_VALUE(SCARD_CLASS_VENDOR_INFO, 0x0102)
-#define SCARD_ATTR_VENDOR_IFD_SERIAL_NO SCARD_ATTR_VALUE(SCARD_CLASS_VENDOR_INFO, 0x0103)
-#define SCARD_ATTR_CHANNEL_ID SCARD_ATTR_VALUE(SCARD_CLASS_COMMUNICATIONS, 0x0110)
-#define SCARD_ATTR_ASYNC_PROTOCOL_TYPES SCARD_ATTR_VALUE(SCARD_CLASS_PROTOCOL, 0x0120)
-#define SCARD_ATTR_DEFAULT_CLK SCARD_ATTR_VALUE(SCARD_CLASS_PROTOCOL, 0x0121)
-#define SCARD_ATTR_MAX_CLK SCARD_ATTR_VALUE(SCARD_CLASS_PROTOCOL, 0x0122)
-#define SCARD_ATTR_DEFAULT_DATA_RATE SCARD_ATTR_VALUE(SCARD_CLASS_PROTOCOL, 0x0123)
-#define SCARD_ATTR_MAX_DATA_RATE SCARD_ATTR_VALUE(SCARD_CLASS_PROTOCOL, 0x0124)
-#define SCARD_ATTR_MAX_IFSD SCARD_ATTR_VALUE(SCARD_CLASS_PROTOCOL, 0x0125)
-#define SCARD_ATTR_SYNC_PROTOCOL_TYPES SCARD_ATTR_VALUE(SCARD_CLASS_PROTOCOL, 0x0126)
-#define SCARD_ATTR_POWER_MGMT_SUPPORT SCARD_ATTR_VALUE(SCARD_CLASS_POWER_MGMT, 0x0131)
-#define SCARD_ATTR_USER_TO_CARD_AUTH_DEVICE SCARD_ATTR_VALUE(SCARD_CLASS_SECURITY, 0x0140)
-#define SCARD_ATTR_USER_AUTH_INPUT_DEVICE SCARD_ATTR_VALUE(SCARD_CLASS_SECURITY, 0x0142)
-#define SCARD_ATTR_CHARACTERISTICS SCARD_ATTR_VALUE(SCARD_CLASS_MECHANICAL, 0x0150)
-
-#define SCARD_ATTR_CURRENT_PROTOCOL_TYPE SCARD_ATTR_VALUE(SCARD_CLASS_IFD_PROTOCOL, 0x0201)
-#define SCARD_ATTR_CURRENT_CLK SCARD_ATTR_VALUE(SCARD_CLASS_IFD_PROTOCOL, 0x0202)
-#define SCARD_ATTR_CURRENT_F SCARD_ATTR_VALUE(SCARD_CLASS_IFD_PROTOCOL, 0x0203)
-#define SCARD_ATTR_CURRENT_D SCARD_ATTR_VALUE(SCARD_CLASS_IFD_PROTOCOL, 0x0204)
-#define SCARD_ATTR_CURRENT_N SCARD_ATTR_VALUE(SCARD_CLASS_IFD_PROTOCOL, 0x0205)
-#define SCARD_ATTR_CURRENT_W SCARD_ATTR_VALUE(SCARD_CLASS_IFD_PROTOCOL, 0x0206)
-#define SCARD_ATTR_CURRENT_IFSC SCARD_ATTR_VALUE(SCARD_CLASS_IFD_PROTOCOL, 0x0207)
-#define SCARD_ATTR_CURRENT_IFSD SCARD_ATTR_VALUE(SCARD_CLASS_IFD_PROTOCOL, 0x0208)
-#define SCARD_ATTR_CURRENT_BWT SCARD_ATTR_VALUE(SCARD_CLASS_IFD_PROTOCOL, 0x0209)
-#define SCARD_ATTR_CURRENT_CWT SCARD_ATTR_VALUE(SCARD_CLASS_IFD_PROTOCOL, 0x020a)
-#define SCARD_ATTR_CURRENT_EBC_ENCODING SCARD_ATTR_VALUE(SCARD_CLASS_IFD_PROTOCOL, 0x020b)
-#define SCARD_ATTR_EXTENDED_BWT SCARD_ATTR_VALUE(SCARD_CLASS_IFD_PROTOCOL, 0x020c)
-
-#define SCARD_ATTR_ICC_PRESENCE SCARD_ATTR_VALUE(SCARD_CLASS_ICC_STATE, 0x0300)
-#define SCARD_ATTR_ICC_INTERFACE_STATUS SCARD_ATTR_VALUE(SCARD_CLASS_ICC_STATE, 0x0301)
-#define SCARD_ATTR_CURRENT_IO_STATE SCARD_ATTR_VALUE(SCARD_CLASS_ICC_STATE, 0x0302)
-#define SCARD_ATTR_ATR_STRING SCARD_ATTR_VALUE(SCARD_CLASS_ICC_STATE, 0x0303)
-#define SCARD_ATTR_ICC_TYPE_PER_ATR SCARD_ATTR_VALUE(SCARD_CLASS_ICC_STATE, 0x0304)
-
-#define SCARD_ATTR_ESC_RESET SCARD_ATTR_VALUE(SCARD_CLASS_VENDOR_DEFINED, 0xA000)
-#define SCARD_ATTR_ESC_CANCEL SCARD_ATTR_VALUE(SCARD_CLASS_VENDOR_DEFINED, 0xA003)
-#define SCARD_ATTR_ESC_AUTHREQUEST SCARD_ATTR_VALUE(SCARD_CLASS_VENDOR_DEFINED, 0xA005)
-#define SCARD_ATTR_MAXINPUT SCARD_ATTR_VALUE(SCARD_CLASS_VENDOR_DEFINED, 0xA007)
-
-#define SCARD_ATTR_DEVICE_UNIT SCARD_ATTR_VALUE(SCARD_CLASS_SYSTEM, 0x0001)
-#define SCARD_ATTR_DEVICE_IN_USE SCARD_ATTR_VALUE(SCARD_CLASS_SYSTEM, 0x0002)
-#define SCARD_ATTR_DEVICE_FRIENDLY_NAME_A SCARD_ATTR_VALUE(SCARD_CLASS_SYSTEM, 0x0003)
-#define SCARD_ATTR_DEVICE_SYSTEM_NAME_A SCARD_ATTR_VALUE(SCARD_CLASS_SYSTEM, 0x0004)
-#define SCARD_ATTR_DEVICE_FRIENDLY_NAME_W SCARD_ATTR_VALUE(SCARD_CLASS_SYSTEM, 0x0005)
-#define SCARD_ATTR_DEVICE_SYSTEM_NAME_W SCARD_ATTR_VALUE(SCARD_CLASS_SYSTEM, 0x0006)
-#define SCARD_ATTR_SUPRESS_T1_IFS_REQUEST SCARD_ATTR_VALUE(SCARD_CLASS_SYSTEM, 0x0007)
-
-#ifdef UNICODE
-#define SCARD_ATTR_DEVICE_FRIENDLY_NAME SCARD_ATTR_DEVICE_FRIENDLY_NAME_W
-#define SCARD_ATTR_DEVICE_SYSTEM_NAME SCARD_ATTR_DEVICE_SYSTEM_NAME_W
-#else
-#define SCARD_ATTR_DEVICE_FRIENDLY_NAME SCARD_ATTR_DEVICE_FRIENDLY_NAME_A
-#define SCARD_ATTR_DEVICE_SYSTEM_NAME SCARD_ATTR_DEVICE_SYSTEM_NAME_A
+/* restore default structure elements alignment */
+#ifdef __APPLE__
+#pragma pack()
 #endif
 
-#endif
-
-/* PC/SC Lite specific extensions */
-#define SCARD_W_INSERTED_CARD           0x8010006A
-#define SCARD_E_UNSUPPORTED_FEATURE     0x8010001F
-
-#define SCARD_SCOPE_GLOBAL              0x0003  /* Scope is global */
-
-#define SCARD_RESET                     0x0001  /* Card was reset */
-#define SCARD_INSERTED                  0x0002  /* Card was inserted */
-#define SCARD_REMOVED                   0x0004  /* Card was removed */
+#define SCARD_PCI_T0      (&g_rgSCardT0Pci) /**< protocol control information (PCI) for T=0 */
+#define SCARD_PCI_T1      (&g_rgSCardT1Pci) /**< protocol control information (PCI) for T=1 */
+#define SCARD_PCI_RAW      (&g_rgSCardRawPci) /**< protocol control information (PCI) for RAW protocol */
 
-#define BLOCK_STATUS_RESUME             0x00FF  /* Normal resume */
-#define BLOCK_STATUS_BLOCKING           0x00FA  /* Function is blocking */
-
-#define PCSCLITE_CONFIG_DIR             "/etc"
+/**
+ * @defgroup ErrorCodes ErrorCodes
+ * @brief Error code documentation
+ *
+ * The error codes descriptions are from
+ * http://msdn.microsoft.com/en-us/library/aa924526.aspx
+ */
+/** @ingroup ErrorCodes */
+#define SCARD_S_SUCCESS                  ((LONG)0x00000000) /**< No error was encountered. */
+/** @ingroup ErrorCodes */
+#define SCARD_F_INTERNAL_ERROR            ((LONG)0x80100001) /**< An internal consistency check failed. */
+/** @ingroup ErrorCodes */
+#define SCARD_E_CANCELLED            ((LONG)0x80100002) /**< The action was cancelled by an SCardCancel request. */
+/** @ingroup ErrorCodes */
+#define SCARD_E_INVALID_HANDLE            ((LONG)0x80100003) /**< The supplied handle was invalid. */
+/** @ingroup ErrorCodes */
+#define SCARD_E_INVALID_PARAMETER      ((LONG)0x80100004) /**< One or more of the supplied parameters could not be properly interpreted. */
+/** @ingroup ErrorCodes */
+#define SCARD_E_INVALID_TARGET            ((LONG)0x80100005) /**< Registry startup information is missing or invalid. */
+/** @ingroup ErrorCodes */
+#define SCARD_E_NO_MEMORY            ((LONG)0x80100006) /**< Not enough memory available to complete this command. */
+/** @ingroup ErrorCodes */
+#define SCARD_F_WAITED_TOO_LONG            ((LONG)0x80100007) /**< An internal consistency timer has expired. */
+/** @ingroup ErrorCodes */
+#define SCARD_E_INSUFFICIENT_BUFFER      ((LONG)0x80100008) /**< The data buffer to receive returned data is too small for the returned data. */
+/** @ingroup ErrorCodes */
+#define SCARD_E_UNKNOWN_READER            ((LONG)0x80100009) /**< The specified reader name is not recognized. */
+/** @ingroup ErrorCodes */
+#define SCARD_E_TIMEOUT                  ((LONG)0x8010000A) /**< The user-specified timeout value has expired. */
+/** @ingroup ErrorCodes */
+#define SCARD_E_SHARING_VIOLATION      ((LONG)0x8010000B) /**< The smart card cannot be accessed because of other connections outstanding. */
+/** @ingroup ErrorCodes */
+#define SCARD_E_NO_SMARTCARD            ((LONG)0x8010000C) /**< The operation requires a Smart Card, but no Smart Card is currently in the device. */
+/** @ingroup ErrorCodes */
+#define SCARD_E_UNKNOWN_CARD            ((LONG)0x8010000D) /**< The specified smart card name is not recognized. */
+/** @ingroup ErrorCodes */
+#define SCARD_E_CANT_DISPOSE            ((LONG)0x8010000E) /**< The system could not dispose of the media in the requested manner. */
+/** @ingroup ErrorCodes */
+#define SCARD_E_PROTO_MISMATCH            ((LONG)0x8010000F) /**< The requested protocols are incompatible with the protocol currently in use with the smart card. */
+/** @ingroup ErrorCodes */
+#define SCARD_E_NOT_READY            ((LONG)0x80100010) /**< The reader or smart card is not ready to accept commands. */
+/** @ingroup ErrorCodes */
+#define SCARD_E_INVALID_VALUE            ((LONG)0x80100011) /**< One or more of the supplied parameters values could not be properly interpreted. */
+/** @ingroup ErrorCodes */
+#define SCARD_E_SYSTEM_CANCELLED      ((LONG)0x80100012) /**< The action was cancelled by the system, presumably to log off or shut down. */
+/** @ingroup ErrorCodes */
+#define SCARD_F_COMM_ERROR            ((LONG)0x80100013) /**< An internal communications error has been detected. */
+/** @ingroup ErrorCodes */
+#define SCARD_F_UNKNOWN_ERROR            ((LONG)0x80100014) /**< An internal error has been detected, but the source is unknown. */
+/** @ingroup ErrorCodes */
+#define SCARD_E_INVALID_ATR            ((LONG)0x80100015) /**< An ATR obtained from the registry is not a valid ATR string. */
+/** @ingroup ErrorCodes */
+#define SCARD_E_NOT_TRANSACTED            ((LONG)0x80100016) /**< An attempt was made to end a non-existent transaction. */
+/** @ingroup ErrorCodes */
+#define SCARD_E_READER_UNAVAILABLE      ((LONG)0x80100017) /**< The specified reader is not currently available for use. */
+/** @ingroup ErrorCodes */
+#define SCARD_P_SHUTDOWN            ((LONG)0x80100018) /**< The operation has been aborted to allow the server application to exit. */
+/** @ingroup ErrorCodes */
+#define SCARD_E_PCI_TOO_SMALL            ((LONG)0x80100019) /**< The PCI Receive buffer was too small. */
+/** @ingroup ErrorCodes */
+#define SCARD_E_READER_UNSUPPORTED      ((LONG)0x8010001A) /**< The reader driver does not meet minimal requirements for support. */
+/** @ingroup ErrorCodes */
+#define SCARD_E_DUPLICATE_READER      ((LONG)0x8010001B) /**< The reader driver did not produce a unique reader name. */
+/** @ingroup ErrorCodes */
+#define SCARD_E_CARD_UNSUPPORTED      ((LONG)0x8010001C) /**< The smart card does not meet minimal requirements for support. */
+/** @ingroup ErrorCodes */
+#define SCARD_E_NO_SERVICE            ((LONG)0x8010001D) /**< The Smart card resource manager is not running. */
+/** @ingroup ErrorCodes */
+#define SCARD_E_SERVICE_STOPPED            ((LONG)0x8010001E) /**< The Smart card resource manager has shut down. */
+/** @ingroup ErrorCodes */
+#define SCARD_E_UNEXPECTED            ((LONG)0x8010001F) /**< An unexpected card error has occurred. */
+/** @ingroup ErrorCodes */
+#define SCARD_E_UNSUPPORTED_FEATURE      ((LONG)0x8010001F) /**< This smart card does not support the requested feature. */
+/** @ingroup ErrorCodes */
+#define SCARD_E_ICC_INSTALLATION      ((LONG)0x80100020) /**< No primary provider can be found for the smart card. */
+/** @ingroup ErrorCodes */
+#define SCARD_E_ICC_CREATEORDER            ((LONG)0x80100021) /**< The requested order of object creation is not supported. */
+/** @ingroup ErrorCodes */
+/* #define SCARD_E_UNSUPPORTED_FEATURE      ((LONG)0x80100022) / **< This smart card does not support the requested feature. */
+/** @ingroup ErrorCodes */
+#define SCARD_E_DIR_NOT_FOUND            ((LONG)0x80100023) /**< The identified directory does not exist in the smart card. */
+/** @ingroup ErrorCodes */
+#define SCARD_E_FILE_NOT_FOUND            ((LONG)0x80100024) /**< The identified file does not exist in the smart card. */
+/** @ingroup ErrorCodes */
+#define SCARD_E_NO_DIR                  ((LONG)0x80100025) /**< The supplied path does not represent a smart card directory. */
+/** @ingroup ErrorCodes */
+#define SCARD_E_NO_FILE                  ((LONG)0x80100026) /**< The supplied path does not represent a smart card file. */
+/** @ingroup ErrorCodes */
+#define SCARD_E_NO_ACCESS            ((LONG)0x80100027) /**< Access is denied to this file. */
+/** @ingroup ErrorCodes */
+#define SCARD_E_WRITE_TOO_MANY            ((LONG)0x80100028) /**< The smart card does not have enough memory to store the information. */
+/** @ingroup ErrorCodes */
+#define SCARD_E_BAD_SEEK            ((LONG)0x80100029) /**< There was an error trying to set the smart card file object pointer. */
+/** @ingroup ErrorCodes */
+#define SCARD_E_INVALID_CHV            ((LONG)0x8010002A) /**< The supplied PIN is incorrect. */
+/** @ingroup ErrorCodes */
+#define SCARD_E_UNKNOWN_RES_MNG            ((LONG)0x8010002B) /**< An unrecognized error code was returned from a layered component. */
+/** @ingroup ErrorCodes */
+#define SCARD_E_NO_SUCH_CERTIFICATE      ((LONG)0x8010002C) /**< The requested certificate does not exist. */
+/** @ingroup ErrorCodes */
+#define SCARD_E_CERTIFICATE_UNAVAILABLE      ((LONG)0x8010002D) /**< The requested certificate could not be obtained. */
+/** @ingroup ErrorCodes */
+#define SCARD_E_NO_READERS_AVAILABLE    ((LONG)0x8010002E) /**< Cannot find a smart card reader. */
+/** @ingroup ErrorCodes */
+#define SCARD_E_COMM_DATA_LOST            ((LONG)0x8010002F) /**< A communications error with the smart card has been detected. Retry the operation. */
+/** @ingroup ErrorCodes */
+#define SCARD_E_NO_KEY_CONTAINER      ((LONG)0x80100030) /**< The requested key container does not exist on the smart card. */
+/** @ingroup ErrorCodes */
+#define SCARD_E_SERVER_TOO_BUSY            ((LONG)0x80100031) /**< The Smart Card Resource Manager is too busy to complete this operation. */
 
-#ifndef USE_IPCDIR
-#define PCSCLITE_IPC_DIR                "/var/run"
-#else
-#define PCSCLITE_IPC_DIR                USE_IPCDIR
-#endif
+/** @ingroup ErrorCodes */
+#define SCARD_W_UNSUPPORTED_CARD      ((LONG)0x80100065) /**< The reader cannot communicate with the card, due to ATR string configuration conflicts. */
+/** @ingroup ErrorCodes */
+#define SCARD_W_UNRESPONSIVE_CARD      ((LONG)0x80100066) /**< The smart card is not responding to a reset. */
+/** @ingroup ErrorCodes */
+#define SCARD_W_UNPOWERED_CARD            ((LONG)0x80100067) /**< Power has been removed from the smart card, so that further communication is not possible. */
+/** @ingroup ErrorCodes */
+#define SCARD_W_RESET_CARD            ((LONG)0x80100068) /**< The smart card has been reset, so any shared state information is invalid. */
+/** @ingroup ErrorCodes */
+#define SCARD_W_REMOVED_CARD            ((LONG)0x80100069) /**< The smart card has been removed, so further communication is not possible. */
+
+/** @ingroup ErrorCodes */
+#define SCARD_W_SECURITY_VIOLATION      ((LONG)0x8010006A) /**< Access was denied because of a security violation. */
+/** @ingroup ErrorCodes */
+#define SCARD_W_WRONG_CHV            ((LONG)0x8010006B) /**< The card cannot be accessed because the wrong PIN was presented. */
+/** @ingroup ErrorCodes */
+#define SCARD_W_CHV_BLOCKED            ((LONG)0x8010006C) /**< The card cannot be accessed because the maximum number of PIN entry attempts has been reached. */
+/** @ingroup ErrorCodes */
+#define SCARD_W_EOF                  ((LONG)0x8010006D) /**< The end of the smart card file has been reached. */
+/** @ingroup ErrorCodes */
+#define SCARD_W_CANCELLED_BY_USER      ((LONG)0x8010006E) /**< The user pressed "Cancel" on a Smart Card Selection Dialog. */
+/** @ingroup ErrorCodes */
+#define SCARD_W_CARD_NOT_AUTHENTICATED      ((LONG)0x8010006F) /**< No PIN was presented to the smart card. */
+
+#define SCARD_AUTOALLOCATE (DWORD)(-1)      /**< see SCardFreeMemory() */
+#define SCARD_SCOPE_USER            0x0000      /**< Scope in user space */
+#define SCARD_SCOPE_TERMINAL            0x0001      /**< Scope in terminal */
+#define SCARD_SCOPE_SYSTEM            0x0002      /**< Scope in system */
+#define SCARD_SCOPE_GLOBAL            0x0003      /**< Scope is global */
 
-#define PCSCLITE_READER_CONFIG          PCSCLITE_CONFIG_DIR "/reader.conf"
-#define PCSCLITE_PUBSHM_FILE            PCSCLITE_IPC_DIR "/pcscd.pub"
-#define PCSCLITE_CSOCK_NAME             PCSCLITE_IPC_DIR "/pcscd.comm"
+#define SCARD_PROTOCOL_UNDEFINED      0x0000      /**< protocol not set */
+#define SCARD_PROTOCOL_UNSET SCARD_PROTOCOL_UNDEFINED      /* backward compat */
+#define SCARD_PROTOCOL_T0            0x0001      /**< T=0 active protocol. */
+#define SCARD_PROTOCOL_T1            0x0002      /**< T=1 active protocol. */
+#define SCARD_PROTOCOL_RAW            0x0004      /**< Raw active protocol. */
+#define SCARD_PROTOCOL_T15            0x0008      /**< T=15 protocol. */
+
+#define SCARD_PROTOCOL_ANY            (SCARD_PROTOCOL_T0|SCARD_PROTOCOL_T1)      /**< IFD determines prot. */
+
+#define SCARD_SHARE_EXCLUSIVE            0x0001      /**< Exclusive mode only */
+#define SCARD_SHARE_SHARED            0x0002      /**< Shared mode only */
+#define SCARD_SHARE_DIRECT            0x0003      /**< Raw mode only */
+
+#define SCARD_LEAVE_CARD            0x0000      /**< Do nothing on close */
+#define SCARD_RESET_CARD            0x0001      /**< Reset on close */
+#define SCARD_UNPOWER_CARD            0x0002      /**< Power down on close */
+#define SCARD_EJECT_CARD            0x0003      /**< Eject on close */
 
-#define PCSCLITE_SVC_IDENTITY           0x01030000      /* Service ID */
+#define SCARD_UNKNOWN                  0x0001      /**< Unknown state */
+#define SCARD_ABSENT                  0x0002      /**< Card is absent */
+#define SCARD_PRESENT                  0x0004      /**< Card is present */
+#define SCARD_SWALLOWED                  0x0008      /**< Card not powered */
+#define SCARD_POWERED                  0x0010      /**< Card is powered */
+#define SCARD_NEGOTIABLE            0x0020      /**< Ready for PTS */
+#define SCARD_SPECIFIC                  0x0040      /**< PTS has been set */
+
+#define SCARD_STATE_UNAWARE            0x0000      /**< App wants status */
+#define SCARD_STATE_IGNORE            0x0001      /**< Ignore this reader */
+#define SCARD_STATE_CHANGED            0x0002      /**< State has changed */
+#define SCARD_STATE_UNKNOWN            0x0004      /**< Reader unknown */
+#define SCARD_STATE_UNAVAILABLE            0x0008      /**< Status unavailable */
+#define SCARD_STATE_EMPTY            0x0010      /**< Card removed */
+#define SCARD_STATE_PRESENT            0x0020      /**< Card inserted */
+#define SCARD_STATE_ATRMATCH            0x0040      /**< ATR matches card */
+#define SCARD_STATE_EXCLUSIVE            0x0080      /**< Exclusive Mode */
+#define SCARD_STATE_INUSE            0x0100      /**< Shared Mode */
+#define SCARD_STATE_MUTE            0x0200      /**< Unresponsive card */
+#define SCARD_STATE_UNPOWERED            0x0400      /**< Unpowered card */
 
 #ifndef INFINITE
-#define INFINITE                        0xFFFFFFFF      /* Infinite timeout */
+#define INFINITE                  0xFFFFFFFF      /**< Infinite timeout */
 #endif
-#define PCSCLITE_INFINITE_TIMEOUT       4320000         /* 50 day infinite t/o */
-
-#define PCSCLITE_VERSION_NUMBER         "1.2.9-beta7"   /* Current version */
-#define PCSCLITE_CLIENT_ATTEMPTS        120             /* Attempts to reach sv */
-#define PCSCLITE_MCLIENT_ATTEMPTS       20              /* Attempts to reach sv */
-#define PCSCLITE_STATUS_POLL_RATE       400000          /* Status polling rate */
-#define PCSCLITE_MSG_KEY_LEN            16              /* App ID key length */
-#define PCSCLITE_RW_ATTEMPTS            100             /* Attempts to rd/wrt */
 
-/* Maximum applications */
-#define PCSCLITE_MAX_APPLICATIONS                       16
-/* Maximum contexts by application */
-#define PCSCLITE_MAX_APPLICATION_CONTEXTS               16
-/* Maximum of applications contexts that pcscd can accept */
-#define PCSCLITE_MAX_APPLICATIONS_CONTEXTS \
-        PCSCLITE_MAX_APPLICATIONS * PCSCLITE_MAX_APPLICATION_CONTEXTS
-/* Maximum channels on a reader context */
-#define PCSCLITE_MAX_READER_CONTEXT_CHANNELS            16
-/* Maximum channels on an application context */
-#define PCSCLITE_MAX_APPLICATION_CONTEXT_CHANNELS       16
-/* Maximum readers context (a slot is count as a reader) */
-#define PCSCLITE_MAX_READERS_CONTEXTS                   16
+#define PCSCLITE_VERSION_NUMBER            "1.8.24"      /**< Current version */
+/** Maximum readers context (a slot is count as a reader) */
+#define PCSCLITE_MAX_READERS_CONTEXTS                  16
 
-/* PCSCLITE_MAX_READERS is deprecated
- * use PCSCLITE_MAX_READERS_CONTEXTS instead */
-/* extern int PCSCLITE_MAX_READERS __attribute__ ((deprecated)); */
-
-#define PCSCLITE_MAX_THREADS            16      /* Stat change threads */
-#define PCSCLITE_STATUS_WAIT            200000  /* Status Change Sleep */
-#define PCSCLITE_TRANSACTION_TIMEOUT    40      /* Transaction timeout */
-#define MAX_READERNAME                  52
-#define MAX_LIBNAME                     100
-#define MAX_DEVICENAME          255
+#define MAX_READERNAME                  128
 
 #ifndef SCARD_ATR_LENGTH
-#define SCARD_ATR_LENGTH                MAX_ATR_SIZE    /* Maximum ATR size */
+#define SCARD_ATR_LENGTH            MAX_ATR_SIZE      /**< Maximum ATR size */
 #endif
 
 /*
- * Enhanced messaging has been added to accommodate newer devices which have
- * more advanced capabilities, such as dedicated secure co-processors which
- * can stream and encrypt data over USB. In order to used enhanced messaging
- * you must define PCSCLITE_ENHANCED_MESSAGING in the framework(library),
- * the daemon, and your application
- */
-#undef PCSCLITE_ENHANCED_MESSAGING
-#ifndef PCSCLITE_ENHANCED_MESSAGING
-#define PCSCLITE_MAX_MESSAGE_SIZE       2048    /* Transport msg len */
-#define MAX_BUFFER_SIZE                 264     /* Maximum Tx/Rx Buffer */
-#define PCSCLITE_SERVER_ATTEMPTS        5       /* Attempts to reach cl */
-#else
-/*
  * The message and buffer sizes must be multiples of 16.
  * The max message size must be at least large enough
- * to accommodate the transmit_struct
+ * to accomodate the transmit_struct
  */
-#define PCSCLITE_MAX_MESSAGE_SIZE       (1<<17) /* enhanced (128K) msg len */
-#define MAX_BUFFER_SIZE                 (1<<15) /* enhanced (32K) Tx/Rx Buffer */
-#define PCSCLITE_SERVER_ATTEMPTS        200     /* To allow larger data reads/writes */
-#endif
+#define MAX_BUFFER_SIZE                  264      /**< Maximum Tx/Rx Buffer for short APDU */
+#define MAX_BUFFER_SIZE_EXTENDED      (4 + 3 + (1<<16) + 3 + 2)      /**< enhanced (64K + APDU + Lc + Le + SW) Tx/Rx Buffer */
 
 /*
  * Gets a stringified error response
  */
-char *pcsc_stringify_error(long);
+const char *pcsc_stringify_error(const LONG);
 
 #ifdef __cplusplus
 }
--- a/src/java.smartcardio/unix/native/libj2pcsc/MUSCLE/winscard.h	Tue Feb 26 18:12:06 2019 +0000
+++ b/src/java.smartcardio/unix/native/libj2pcsc/MUSCLE/winscard.h	Wed Feb 27 14:48:22 2019 +0530
@@ -1,13 +1,38 @@
 /*
- * This handles smartcard reader communications.
- *
- * MUSCLE SmartCard Development ( http://www.linuxnet.com )
+ * MUSCLE SmartCard Development ( https://pcsclite.apdu.fr/ )
  *
  * Copyright (C) 1999-2003
- *  David Corcoran <corcoran@linuxnet.com>
+ *  David Corcoran <corcoran@musclecard.com>
+ * Copyright (C) 2002-2009
  *  Ludovic Rousseau <ludovic.rousseau@free.fr>
  *
- * $Id: winscard.h,v 1.13 2004/08/06 12:12:19 rousseau Exp $
+Redistribution and use in source and binary forms, with or without
+modification, are permitted provided that the following conditions
+are met:
+
+1. Redistributions of source code must retain the above copyright
+   notice, this list of conditions and the following disclaimer.
+2. Redistributions in binary form must reproduce the above copyright
+   notice, this list of conditions and the following disclaimer in the
+   documentation and/or other materials provided with the distribution.
+3. The name of the author may not be used to endorse or promote products
+   derived from this software without specific prior written permission.
+
+THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
+IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
+OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
+IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
+INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
+NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
+THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+/**
+ * @file
+ * @brief This handles smart card reader communications.
  */
 
 #ifndef __winscard_h__
@@ -20,71 +45,79 @@
 {
 #endif
 
-        LONG SCardEstablishContext(DWORD dwScope,
-                LPCVOID pvReserved1, LPCVOID pvReserved2, LPSCARDCONTEXT phContext);
-
-        LONG SCardReleaseContext(SCARDCONTEXT hContext);
+#ifndef PCSC_API
+#define PCSC_API
+#endif
 
-        LONG SCardSetTimeout(SCARDCONTEXT hContext, DWORD dwTimeout);
+      PCSC_API LONG SCardEstablishContext(DWORD dwScope,
+            /*@null@*/ LPCVOID pvReserved1, /*@null@*/ LPCVOID pvReserved2,
+            /*@out@*/ LPSCARDCONTEXT phContext);
 
-        LONG SCardConnect(SCARDCONTEXT hContext,
-                LPCTSTR szReader,
-                DWORD dwShareMode,
-                DWORD dwPreferredProtocols,
-                LPSCARDHANDLE phCard, LPDWORD pdwActiveProtocol);
+      PCSC_API LONG SCardReleaseContext(SCARDCONTEXT hContext);
+
+      PCSC_API LONG SCardIsValidContext(SCARDCONTEXT hContext);
 
-        LONG SCardReconnect(SCARDHANDLE hCard,
-                DWORD dwShareMode,
-                DWORD dwPreferredProtocols,
-                DWORD dwInitialization, LPDWORD pdwActiveProtocol);
+      PCSC_API LONG SCardConnect(SCARDCONTEXT hContext,
+            LPCSTR szReader,
+            DWORD dwShareMode,
+            DWORD dwPreferredProtocols,
+            /*@out@*/ LPSCARDHANDLE phCard, /*@out@*/ LPDWORD pdwActiveProtocol);
 
-        LONG SCardDisconnect(SCARDHANDLE hCard, DWORD dwDisposition);
-
-        LONG SCardBeginTransaction(SCARDHANDLE hCard);
+      PCSC_API LONG SCardReconnect(SCARDHANDLE hCard,
+            DWORD dwShareMode,
+            DWORD dwPreferredProtocols,
+            DWORD dwInitialization, /*@out@*/ LPDWORD pdwActiveProtocol);
 
-        LONG SCardEndTransaction(SCARDHANDLE hCard, DWORD dwDisposition);
+      PCSC_API LONG SCardDisconnect(SCARDHANDLE hCard, DWORD dwDisposition);
 
-        LONG SCardCancelTransaction(SCARDHANDLE hCard);
+      PCSC_API LONG SCardBeginTransaction(SCARDHANDLE hCard);
+
+      PCSC_API LONG SCardEndTransaction(SCARDHANDLE hCard, DWORD dwDisposition);
 
-        LONG SCardStatus(SCARDHANDLE hCard,
-                LPTSTR mszReaderNames, LPDWORD pcchReaderLen,
-                LPDWORD pdwState,
-                LPDWORD pdwProtocol,
-                LPBYTE pbAtr, LPDWORD pcbAtrLen);
+      PCSC_API LONG SCardStatus(SCARDHANDLE hCard,
+            /*@null@*/ /*@out@*/ LPSTR mszReaderName,
+            /*@null@*/ /*@out@*/ LPDWORD pcchReaderLen,
+            /*@null@*/ /*@out@*/ LPDWORD pdwState,
+            /*@null@*/ /*@out@*/ LPDWORD pdwProtocol,
+            /*@null@*/ /*@out@*/ LPBYTE pbAtr,
+            /*@null@*/ /*@out@*/ LPDWORD pcbAtrLen);
 
-        LONG SCardGetStatusChange(SCARDCONTEXT hContext,
-                DWORD dwTimeout,
-                LPSCARD_READERSTATE_A rgReaderStates, DWORD cReaders);
+      PCSC_API LONG SCardGetStatusChange(SCARDCONTEXT hContext,
+            DWORD dwTimeout,
+            SCARD_READERSTATE *rgReaderStates, DWORD cReaders);
 
-        LONG SCardControl(SCARDHANDLE hCard, DWORD dwControlCode,
-                LPCVOID pbSendBuffer, DWORD cbSendLength,
-                LPVOID pbRecvBuffer, DWORD cbRecvLength, LPDWORD lpBytesReturned);
+      PCSC_API LONG SCardControl(SCARDHANDLE hCard, DWORD dwControlCode,
+            LPCVOID pbSendBuffer, DWORD cbSendLength,
+            /*@out@*/ LPVOID pbRecvBuffer, DWORD cbRecvLength,
+            LPDWORD lpBytesReturned);
 
-        LONG SCardTransmit(SCARDHANDLE hCard,
-                LPCSCARD_IO_REQUEST pioSendPci,
-                LPCBYTE pbSendBuffer, DWORD cbSendLength,
-                LPSCARD_IO_REQUEST pioRecvPci,
-                LPBYTE pbRecvBuffer, LPDWORD pcbRecvLength);
+      PCSC_API LONG SCardTransmit(SCARDHANDLE hCard,
+            const SCARD_IO_REQUEST *pioSendPci,
+            LPCBYTE pbSendBuffer, DWORD cbSendLength,
+            /*@out@*/ SCARD_IO_REQUEST *pioRecvPci,
+            /*@out@*/ LPBYTE pbRecvBuffer, LPDWORD pcbRecvLength);
 
-        LONG SCardListReaderGroups(SCARDCONTEXT hContext,
-                LPTSTR mszGroups, LPDWORD pcchGroups);
+      PCSC_API LONG SCardListReaderGroups(SCARDCONTEXT hContext,
+            /*@out@*/ LPSTR mszGroups, LPDWORD pcchGroups);
 
-        LONG SCardListReaders(SCARDCONTEXT hContext,
-                LPCTSTR mszGroups,
-                LPTSTR mszReaders, LPDWORD pcchReaders);
+      PCSC_API LONG SCardListReaders(SCARDCONTEXT hContext,
+            /*@null@*/ /*@out@*/ LPCSTR mszGroups,
+            /*@null@*/ /*@out@*/ LPSTR mszReaders,
+            /*@out@*/ LPDWORD pcchReaders);
 
-        LONG SCardCancel(SCARDCONTEXT hContext);
+      PCSC_API LONG SCardFreeMemory(SCARDCONTEXT hContext, LPCVOID pvMem);
 
-        LONG SCardGetAttrib(SCARDHANDLE hCard, DWORD dwAttrId, LPBYTE pbAttr,
-                        LPDWORD pcbAttrLen);
+      PCSC_API LONG SCardCancel(SCARDCONTEXT hContext);
 
-        LONG SCardSetAttrib(SCARDHANDLE hCard, DWORD dwAttrId, LPCBYTE pbAttr,
-                        DWORD cbAttrLen);
+      PCSC_API LONG SCardGetAttrib(SCARDHANDLE hCard, DWORD dwAttrId,
+            /*@out@*/ LPBYTE pbAttr, LPDWORD pcbAttrLen);
 
-        void SCardUnload(void);
+      PCSC_API LONG SCardSetAttrib(SCARDHANDLE hCard, DWORD dwAttrId,
+            LPCBYTE pbAttr, DWORD cbAttrLen);
 
 #ifdef __cplusplus
 }
 #endif
 
 #endif
+
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/src/java.smartcardio/unix/native/libj2pcsc/MUSCLE/wintypes.h	Wed Feb 27 14:48:22 2019 +0530
@@ -0,0 +1,115 @@
+/*
+ * MUSCLE SmartCard Development ( https://pcsclite.apdu.fr/ )
+ *
+ * Copyright (C) 1999
+ *  David Corcoran <corcoran@musclecard.com>
+ * Copyright (C) 2002-2011
+ *  Ludovic Rousseau <ludovic.rousseau@free.fr>
+ *
+Redistribution and use in source and binary forms, with or without
+modification, are permitted provided that the following conditions
+are met:
+
+1. Redistributions of source code must retain the above copyright
+   notice, this list of conditions and the following disclaimer.
+2. Redistributions in binary form must reproduce the above copyright
+   notice, this list of conditions and the following disclaimer in the
+   documentation and/or other materials provided with the distribution.
+3. The name of the author may not be used to endorse or promote products
+   derived from this software without specific prior written permission.
+
+THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
+IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
+OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
+IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
+INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
+NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
+THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+/**
+ * @file
+ * @brief This keeps a list of Windows(R) types.
+ */
+
+#ifndef __wintypes_h__
+#define __wintypes_h__
+
+#ifdef __cplusplus
+extern "C"
+{
+#endif
+
+#ifdef __APPLE__
+
+#include <stdint.h>
+
+#ifndef BYTE
+    typedef uint8_t BYTE;
+#endif
+    typedef uint8_t UCHAR;
+    typedef UCHAR *PUCHAR;
+    typedef uint16_t USHORT;
+
+#ifndef __COREFOUNDATION_CFPLUGINCOM__
+    typedef uint32_t ULONG;
+    typedef void *LPVOID;
+    typedef int16_t BOOL;
+#endif
+
+    typedef ULONG *PULONG;
+    typedef const void *LPCVOID;
+    typedef uint32_t DWORD;
+    typedef DWORD *PDWORD;
+    typedef uint16_t WORD;
+    typedef int32_t LONG;
+    typedef const char *LPCSTR;
+    typedef const BYTE *LPCBYTE;
+    typedef BYTE *LPBYTE;
+    typedef DWORD *LPDWORD;
+    typedef char *LPSTR;
+
+#else
+
+#ifndef BYTE
+    typedef unsigned char BYTE;
+#endif
+    typedef unsigned char UCHAR;
+    typedef UCHAR *PUCHAR;
+    typedef unsigned short USHORT;
+
+#ifndef __COREFOUNDATION_CFPLUGINCOM__
+    typedef unsigned long ULONG;
+    typedef void *LPVOID;
+#endif
+
+    typedef const void *LPCVOID;
+    typedef unsigned long DWORD;
+    typedef DWORD *PDWORD;
+    typedef long LONG;
+    typedef const char *LPCSTR;
+    typedef const BYTE *LPCBYTE;
+    typedef BYTE *LPBYTE;
+    typedef DWORD *LPDWORD;
+    typedef char *LPSTR;
+
+    /* these types were deprecated but still used by old drivers and
+     * applications. So just declare and use them. */
+    typedef LPSTR LPTSTR;
+    typedef LPCSTR LPCTSTR;
+
+    /* types unused by pcsc-lite */
+    typedef short BOOL;
+    typedef unsigned short WORD;
+    typedef ULONG *PULONG;
+
+#endif
+
+#ifdef __cplusplus
+}
+#endif
+
+#endif
--- a/src/java.smartcardio/unix/native/libj2pcsc/pcsc_md.h	Tue Feb 26 18:12:06 2019 +0000
+++ b/src/java.smartcardio/unix/native/libj2pcsc/pcsc_md.h	Wed Feb 27 14:48:22 2019 +0530
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2005, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2005, 2019, 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
@@ -23,48 +23,49 @@
  * questions.
  */
 
-typedef LONG (*FPTR_SCardEstablishContext)(ULONG dwScope,
-                const void *pvReserved1,
-                const void *pvReserved2,
-                LONG *phContext);
+typedef LONG (*FPTR_SCardEstablishContext)(DWORD dwScope,
+                LPCVOID pvReserved1,
+                LPCVOID pvReserved2,
+                LPSCARDCONTEXT phContext);
 
-typedef LONG (*FPTR_SCardConnect)(LONG hContext,
-                const char *szReader,
-                ULONG dwShareMode,
-                ULONG dwPreferredProtocols,
-                LONG *phCard, ULONG *pdwActiveProtocol);
+typedef LONG (*FPTR_SCardConnect)(SCARDCONTEXT hContext,
+                LPCSTR szReader,
+                DWORD dwShareMode,
+                DWORD dwPreferredProtocols,
+                LPSCARDHANDLE phCard, LPDWORD pdwActiveProtocol);
 
-typedef LONG (*FPTR_SCardDisconnect)(LONG hCard, ULONG dwDisposition);
+typedef LONG (*FPTR_SCardDisconnect)(SCARDHANDLE hCard, DWORD dwDisposition);
 
-typedef LONG (*FPTR_SCardStatus)(LONG hCard,
-                char *mszReaderNames,
-                ULONG *pcchReaderLen,
-                ULONG *pdwState,
-                ULONG *pdwProtocol,
-                unsigned char *pbAtr, ULONG *pcbAtrLen);
+typedef LONG (*FPTR_SCardStatus)(SCARDHANDLE hCard,
+                LPSTR mszReaderNames,
+                LPDWORD pcchReaderLen,
+                LPDWORD pdwState,
+                LPDWORD pdwProtocol,
+                LPBYTE pbAtr, LPDWORD pcbAtrLen);
 
-typedef LONG (*FPTR_SCardGetStatusChange)(LONG hContext,
-                ULONG dwTimeout,
-                LPSCARD_READERSTATE_A rgReaderStates, ULONG cReaders);
+typedef LONG (*FPTR_SCardGetStatusChange)(SCARDCONTEXT hContext,
+                DWORD dwTimeout,
+                SCARD_READERSTATE *rgReaderStates, DWORD cReaders);
 
-typedef LONG (*FPTR_SCardTransmit)(LONG hCard,
-                LPCSCARD_IO_REQUEST pioSendPci,
-                const unsigned char *pbSendBuffer,
-                ULONG cbSendLength,
-                LPSCARD_IO_REQUEST pioRecvPci,
-                unsigned char *pbRecvBuffer, ULONG *pcbRecvLength);
+typedef LONG (*FPTR_SCardTransmit)(SCARDHANDLE hCard,
+                const SCARD_IO_REQUEST *pioSendPci,
+                LPCBYTE pbSendBuffer,
+                DWORD cbSendLength,
+                SCARD_IO_REQUEST *pioRecvPci,
+                LPBYTE pbRecvBuffer, LPDWORD pcbRecvLength);
 
-typedef LONG (*FPTR_SCardListReaders)(LONG hContext,
-                const char *mszGroups,
-                char *mszReaders, ULONG *pcchReaders);
+typedef LONG (*FPTR_SCardListReaders)(SCARDCONTEXT hContext,
+                LPCSTR mszGroups,
+                LPSTR mszReaders, LPDWORD pcchReaders);
 
-typedef LONG (*FPTR_SCardBeginTransaction)(LONG hCard);
+typedef LONG (*FPTR_SCardBeginTransaction)(SCARDHANDLE hCard);
 
-typedef LONG (*FPTR_SCardEndTransaction)(LONG hCard, ULONG dwDisposition);
+typedef LONG (*FPTR_SCardEndTransaction)(SCARDHANDLE hCard,
+                DWORD dwDisposition);
 
-typedef LONG (*FPTR_SCardControl)(LONG hCard, ULONG dwControlCode,
-    const void* pbSendBuffer, ULONG cbSendLength, const void* pbRecvBuffer,
-    ULONG pcbRecvLength, ULONG *lpBytesReturned);
+typedef LONG (*FPTR_SCardControl)(SCARDHANDLE hCard, DWORD dwControlCode,
+                LPCVOID pbSendBuffer, DWORD cbSendLength, LPVOID pbRecvBuffer,
+                DWORD pcbRecvLength, LPDWORD lpBytesReturned);
 
 #define CALL_SCardEstablishContext(dwScope, pvReserved1, pvReserved2, phContext) \
     ((scardEstablishContext)(dwScope, pvReserved1, pvReserved2, phContext))
--- a/src/jdk.jlink/share/classes/jdk/tools/jlink/internal/TaskHelper.java	Tue Feb 26 18:12:06 2019 +0000
+++ b/src/jdk.jlink/share/classes/jdk/tools/jlink/internal/TaskHelper.java	Wed Feb 27 14:48:22 2019 +0530
@@ -49,9 +49,9 @@
 import jdk.tools.jlink.builder.ImageBuilder;
 import jdk.tools.jlink.internal.Jlink.PluginsConfiguration;
 import jdk.tools.jlink.internal.plugins.DefaultCompressPlugin;
+import jdk.tools.jlink.internal.plugins.DefaultStripDebugPlugin;
 import jdk.tools.jlink.internal.plugins.ExcludeJmodSectionPlugin;
 import jdk.tools.jlink.internal.plugins.PluginsResourceBundle;
-import jdk.tools.jlink.internal.plugins.StripDebugPlugin;
 import jdk.tools.jlink.plugin.Plugin;
 import jdk.tools.jlink.plugin.Plugin.Category;
 import jdk.tools.jlink.plugin.PluginException;
@@ -375,7 +375,7 @@
                                 m.put(DefaultCompressPlugin.NAME, DefaultCompressPlugin.LEVEL_2);
                             }, false, "--compress", "-c");
                     mainOptions.add(plugOption);
-                } else if (plugin instanceof StripDebugPlugin) {
+                } else if (plugin instanceof DefaultStripDebugPlugin) {
                     plugOption
                         = new PluginOption(false,
                             (task, opt, arg) -> {
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/src/jdk.jlink/share/classes/jdk/tools/jlink/internal/plugins/DefaultStripDebugPlugin.java	Wed Feb 27 14:48:22 2019 +0530
@@ -0,0 +1,58 @@
+/*
+ * Copyright (c) 2019, Red Hat, Inc.
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * This code is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License version 2 only, as
+ * published by the Free Software Foundation.  Oracle designates this
+ * particular file as subject to the "Classpath" exception as provided
+ * by Oracle in the LICENSE file that accompanied this code.
+ *
+ * This code is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
+ * version 2 for more details (a copy is included in the LICENSE file that
+ * accompanied this code).
+ *
+ * You should have received a copy of the GNU General Public License version
+ * 2 along with this work; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
+ *
+ * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
+ * or visit www.oracle.com if you need additional information or have any
+ * questions.
+ */
+
+package jdk.tools.jlink.internal.plugins;
+
+import jdk.tools.jlink.plugin.Plugin;
+import jdk.tools.jlink.plugin.ResourcePool;
+import jdk.tools.jlink.plugin.ResourcePoolBuilder;
+
+/**
+ * Combined debug stripping plugin: Java debug attributes and native debug
+ * symbols.
+ *
+ */
+public final class DefaultStripDebugPlugin implements Plugin {
+
+    public static final String NAME = "strip-debug";
+
+    private final Plugin javaStripPlugin = new StripJavaDebugAttributesPlugin();
+
+    @Override
+    public String getName() {
+        return NAME;
+    }
+
+    @Override
+    public String getDescription() {
+        return PluginsResourceBundle.getDescription(NAME);
+    }
+
+    @Override
+    public ResourcePool transform(ResourcePool in, ResourcePoolBuilder out) {
+        return javaStripPlugin.transform(in, out);
+    }
+
+}
--- a/src/jdk.jlink/share/classes/jdk/tools/jlink/internal/plugins/StripDebugPlugin.java	Tue Feb 26 18:12:06 2019 +0000
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,87 +0,0 @@
-/*
- * Copyright (c) 2015, 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
- * under the terms of the GNU General Public License version 2 only, as
- * published by the Free Software Foundation.  Oracle designates this
- * particular file as subject to the "Classpath" exception as provided
- * by Oracle in the LICENSE file that accompanied this code.
- *
- * This code is distributed in the hope that it will be useful, but WITHOUT
- * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
- * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
- * version 2 for more details (a copy is included in the LICENSE file that
- * accompanied this code).
- *
- * You should have received a copy of the GNU General Public License version
- * 2 along with this work; if not, write to the Free Software Foundation,
- * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
- *
- * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
- * or visit www.oracle.com if you need additional information or have any
- * questions.
- */
-package jdk.tools.jlink.internal.plugins;
-
-import java.util.function.Predicate;
-import jdk.internal.org.objectweb.asm.ClassReader;
-import jdk.internal.org.objectweb.asm.ClassWriter;
-import jdk.tools.jlink.plugin.ResourcePool;
-import jdk.tools.jlink.plugin.ResourcePoolBuilder;
-import jdk.tools.jlink.plugin.ResourcePoolEntry;
-import jdk.tools.jlink.plugin.Plugin;
-
-/**
- *
- * Strip debug attributes plugin
- */
-public final class StripDebugPlugin implements Plugin {
-    public static final String NAME = "strip-debug";
-    private final Predicate<String> predicate;
-
-    public StripDebugPlugin() {
-        this((path) -> false);
-    }
-
-    StripDebugPlugin(Predicate<String> predicate) {
-        this.predicate = predicate;
-    }
-
-    @Override
-    public String getName() {
-        return NAME;
-    }
-
-    @Override
-    public String getDescription() {
-        return PluginsResourceBundle.getDescription(NAME);
-    }
-
-    @Override
-    public ResourcePool transform(ResourcePool in, ResourcePoolBuilder out) {
-        //remove *.diz files as well as debug attributes.
-        in.transformAndCopy((resource) -> {
-            ResourcePoolEntry res = resource;
-            if (resource.type().equals(ResourcePoolEntry.Type.CLASS_OR_RESOURCE)) {
-                String path = resource.path();
-                if (path.endsWith(".class")) {
-                    if (path.endsWith("module-info.class")) {
-                        // XXX. Do we have debug info? Is Asm ready for module-info?
-                    } else {
-                        ClassReader reader = new ClassReader(resource.contentBytes());
-                        ClassWriter writer = new ClassWriter(ClassWriter.COMPUTE_MAXS);
-                        reader.accept(writer, ClassReader.SKIP_DEBUG);
-                        byte[] content = writer.toByteArray();
-                        res = resource.copyWithContent(content);
-                    }
-                }
-            } else if (predicate.test(res.path())) {
-                res = null;
-            }
-            return res;
-        }, out);
-
-        return out.build();
-    }
-}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/src/jdk.jlink/share/classes/jdk/tools/jlink/internal/plugins/StripJavaDebugAttributesPlugin.java	Wed Feb 27 14:48:22 2019 +0530
@@ -0,0 +1,88 @@
+/*
+ * Copyright (c) 2015, 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
+ * under the terms of the GNU General Public License version 2 only, as
+ * published by the Free Software Foundation.  Oracle designates this
+ * particular file as subject to the "Classpath" exception as provided
+ * by Oracle in the LICENSE file that accompanied this code.
+ *
+ * This code is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
+ * version 2 for more details (a copy is included in the LICENSE file that
+ * accompanied this code).
+ *
+ * You should have received a copy of the GNU General Public License version
+ * 2 along with this work; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
+ *
+ * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
+ * or visit www.oracle.com if you need additional information or have any
+ * questions.
+ */
+package jdk.tools.jlink.internal.plugins;
+
+import java.util.function.Predicate;
+
+import jdk.internal.org.objectweb.asm.ClassReader;
+import jdk.internal.org.objectweb.asm.ClassWriter;
+import jdk.tools.jlink.plugin.Plugin;
+import jdk.tools.jlink.plugin.ResourcePool;
+import jdk.tools.jlink.plugin.ResourcePoolBuilder;
+import jdk.tools.jlink.plugin.ResourcePoolEntry;
+
+/**
+ *
+ * Strip java debug attributes plugin
+ */
+public final class StripJavaDebugAttributesPlugin implements Plugin {
+    public static final String NAME = "strip-java-debug-attributes";
+    private final Predicate<String> predicate;
+
+    public StripJavaDebugAttributesPlugin() {
+        this((path) -> false);
+    }
+
+    StripJavaDebugAttributesPlugin(Predicate<String> predicate) {
+        this.predicate = predicate;
+    }
+
+    @Override
+    public String getName() {
+        return NAME;
+    }
+
+    @Override
+    public String getDescription() {
+        return PluginsResourceBundle.getDescription(NAME);
+    }
+
+    @Override
+    public ResourcePool transform(ResourcePool in, ResourcePoolBuilder out) {
+        //remove *.diz files as well as debug attributes.
+        in.transformAndCopy((resource) -> {
+            ResourcePoolEntry res = resource;
+            if (resource.type().equals(ResourcePoolEntry.Type.CLASS_OR_RESOURCE)) {
+                String path = resource.path();
+                if (path.endsWith(".class")) {
+                    if (path.endsWith("module-info.class")) {
+                        // XXX. Do we have debug info? Is Asm ready for module-info?
+                    } else {
+                        ClassReader reader = new ClassReader(resource.contentBytes());
+                        ClassWriter writer = new ClassWriter(ClassWriter.COMPUTE_MAXS);
+                        reader.accept(writer, ClassReader.SKIP_DEBUG);
+                        byte[] content = writer.toByteArray();
+                        res = resource.copyWithContent(content);
+                    }
+                }
+            } else if (predicate.test(res.path())) {
+                res = null;
+            }
+            return res;
+        }, out);
+
+        return out.build();
+    }
+}
--- a/src/jdk.jlink/share/classes/jdk/tools/jlink/resources/plugins.properties	Tue Feb 26 18:12:06 2019 +0000
+++ b/src/jdk.jlink/share/classes/jdk/tools/jlink/resources/plugins.properties	Wed Feb 27 14:48:22 2019 +0530
@@ -99,6 +99,9 @@
 strip-debug.description=\
 Strip debug information from the output image
 
+strip-java-debug-attributes.description=\
+Strip Java debug attributes from classes in the output image
+
 strip-native-commands.description=\
 Exclude native commands (such as java/java.exe) from the image
 
--- a/src/jdk.jlink/share/classes/module-info.java	Tue Feb 26 18:12:06 2019 +0000
+++ b/src/jdk.jlink/share/classes/module-info.java	Wed Feb 27 14:48:22 2019 +0530
@@ -63,7 +63,8 @@
         jdk.tools.jlink.internal.Main.JlinkToolProvider;
 
     provides jdk.tools.jlink.plugin.Plugin with
-        jdk.tools.jlink.internal.plugins.StripDebugPlugin,
+        jdk.tools.jlink.internal.plugins.DefaultStripDebugPlugin,
+        jdk.tools.jlink.internal.plugins.StripJavaDebugAttributesPlugin,
         jdk.tools.jlink.internal.plugins.ExcludePlugin,
         jdk.tools.jlink.internal.plugins.ExcludeFilesPlugin,
         jdk.tools.jlink.internal.plugins.ExcludeJmodSectionPlugin,
--- a/src/utils/LogCompilation/src/main/java/com/sun/hotspot/tools/compiler/LogParser.java	Tue Feb 26 18:12:06 2019 +0000
+++ b/src/utils/LogCompilation/src/main/java/com/sun/hotspot/tools/compiler/LogParser.java	Wed Feb 27 14:48:22 2019 +0530
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2009, 2018, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2009, 2019, 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
@@ -1279,6 +1279,7 @@
                 types.clear();
                 methods.clear();
                 site = null;
+                lateInlining = false;
             }
         } catch (Exception e) {
             reportInternalError("exception while processing end element", e);
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/test/hotspot/jtreg/runtime/RedefineTests/RedefineDeleteJmethod.java	Wed Feb 27 14:48:22 2019 +0530
@@ -0,0 +1,94 @@
+/*
+ * Copyright (c) 2019, 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
+ * under the terms of the GNU General Public License version 2 only, as
+ * published by the Free Software Foundation.
+ *
+ * This code is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
+ * version 2 for more details (a copy is included in the LICENSE file that
+ * accompanied this code).
+ *
+ * You should have received a copy of the GNU General Public License version
+ * 2 along with this work; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
+ *
+ * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
+ * or visit www.oracle.com if you need additional information or have any
+ * questions.
+ */
+
+/*
+ * @test
+ * @bug 8181171
+ * @summary Test deleting static method pointing to by a jmethod
+ * @library /test/lib
+ * @modules java.base/jdk.internal.misc
+ * @modules java.compiler
+ *          java.instrument
+ *          jdk.jartool/sun.tools.jar
+ * @run main RedefineClassHelper
+ * @run main/native/othervm -javaagent:redefineagent.jar -Xlog:redefine+class*=trace RedefineDeleteJmethod
+ */
+
+class B {
+    private static int deleteMe() { System.out.println("deleteMe called"); return 5; }
+    public static int callDeleteMe() { return deleteMe(); }
+}
+
+public class RedefineDeleteJmethod {
+
+    public static String newB =
+        "class B {" +
+            "public static int callDeleteMe() { return 6; }" +
+        "}";
+
+    public static String newerB =
+        "class B {" +
+            "private static int deleteMe() { System.out.println(\"deleteMe (2) called\"); return 7; }" +
+            "public static int callDeleteMe() { return deleteMe(); }" +
+        "}";
+
+
+    static {
+        System.loadLibrary("RedefineDeleteJmethod");
+    }
+
+    static native int jniCallDeleteMe();
+
+    static void test(int expected, boolean nsme_expected) throws Exception {
+        // Call through static method
+        int res = B.callDeleteMe();
+        System.out.println("Result = " + res);
+        if (res != expected) {
+            throw new Error("returned " + res + " expected " + expected);
+        }
+
+        // Call through jmethodID, saved from first call.
+        try {
+            res = jniCallDeleteMe();
+            if (nsme_expected) {
+                throw new RuntimeException("Failed, NoSuchMethodError expected");
+            }
+            if (res != expected) {
+                throw new Error("returned " + res + " expected " + expected);
+            }
+        } catch (NoSuchMethodError ex) {
+            if (!nsme_expected) {
+                throw new RuntimeException("Failed, NoSuchMethodError not expected");
+            }
+            System.out.println("Passed, NoSuchMethodError expected");
+        }
+    }
+
+    public static void main(String[] args) throws Exception {
+        test(5, false);
+        RedefineClassHelper.redefineClass(B.class, newB);
+        test(6, true);
+        RedefineClassHelper.redefineClass(B.class, newerB);
+        test(7, true);
+    }
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/test/hotspot/jtreg/runtime/RedefineTests/libRedefineDeleteJmethod.c	Wed Feb 27 14:48:22 2019 +0530
@@ -0,0 +1,47 @@
+/*
+ * Copyright (c) 2019, 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
+ * under the terms of the GNU General Public License version 2 only, as
+ * published by the Free Software Foundation.
+ *
+ * This code is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
+ * version 2 for more details (a copy is included in the LICENSE file that
+ * accompanied this code).
+ *
+ * You should have received a copy of the GNU General Public License version
+ * 2 along with this work; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
+ *
+ * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
+ * or visit www.oracle.com if you need additional information or have any
+ * questions.
+ */
+
+#include <jni.h>
+
+jmethodID mid;
+jclass cls;
+static int count = 0;
+
+JNIEXPORT jint JNICALL
+Java_RedefineDeleteJmethod_jniCallDeleteMe(JNIEnv* env, jobject obj) {
+
+    if (count == 0) {
+      count++;
+      cls = (*env)->FindClass(env, "B");
+      if (NULL == cls) {
+          (*env)->FatalError(env, "could not find class");
+      }
+
+      mid = (*env)->GetStaticMethodID(env, cls, "deleteMe", "()I");
+      if (NULL == mid) {
+          (*env)->FatalError(env, "could not find method");
+      }
+    }
+
+    return (*env)->CallStaticIntMethod(env, cls, mid);
+}
--- a/test/jdk/com/sun/jdi/OptionTest.java	Tue Feb 26 18:12:06 2019 +0000
+++ b/test/jdk/com/sun/jdi/OptionTest.java	Wed Feb 27 14:48:22 2019 +0530
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2004, 2015, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2004, 2019, 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
@@ -33,8 +33,6 @@
  * @run driver OptionTest
  */
 
-import java.net.ServerSocket;
-import java.util.regex.Matcher;
 import java.util.regex.Pattern;
 
 public class OptionTest extends Object {
@@ -127,18 +125,12 @@
     }
 
     public static void main(String[] args) throws Exception {
-        // find a free port
-        ServerSocket ss = new ServerSocket(0);
-        int port = ss.getLocalPort();
-        ss.close();
-        String address = String.valueOf(port);
-
         String javaExe = System.getProperty("java.home") +
             java.io.File.separator + "bin" +
             java.io.File.separator + "java";
         String targetClass = "HelloWorld";
         String baseOptions = "transport=dt_socket" +
-                              ",address=" + address +
+                              ",address=0" +
                               ",server=y" +
                               ",suspend=n";
 
--- a/test/jdk/com/sun/jdi/RunToExit.java	Tue Feb 26 18:12:06 2019 +0000
+++ b/test/jdk/com/sun/jdi/RunToExit.java	Wed Feb 27 14:48:22 2019 +0530
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2004, 2018, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2004, 2019, 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
@@ -30,7 +30,6 @@
  * @build VMConnection RunToExit Exit0
  * @run driver RunToExit
  */
-import java.net.ServerSocket;
 import com.sun.jdi.Bootstrap;
 import com.sun.jdi.VirtualMachine;
 import com.sun.jdi.event.*;
@@ -41,6 +40,8 @@
 import java.util.List;
 import java.util.Iterator;
 import java.util.concurrent.TimeUnit;
+import java.util.regex.Matcher;
+import java.util.regex.Pattern;
 import java.util.stream.Collectors;
 import jdk.test.lib.process.ProcessTools;
 
@@ -50,6 +51,9 @@
     static volatile int error_seen = 0;
     static volatile boolean ready = false;
 
+    /* port the debuggee is listening on */
+    private static String address;
+
     /*
      * Find a connector by name
      */
@@ -66,12 +70,11 @@
     }
 
     /*
-     * Launch a server debuggee with the given address
+     * Launch a server debuggee, detect debuggee listening port
      */
-    private static Process launch(String address, String class_name) throws Exception {
+    private static Process launch(String class_name) throws Exception {
         String args[] = new String[]{
-            "-agentlib:jdwp=transport=dt_socket,server=y,suspend=y,address="
-                + address,
+            "-agentlib:jdwp=transport=dt_socket,server=y,suspend=y,address=0",
             class_name
         };
         args = VMConnection.insertDebuggeeVMOptions(args);
@@ -92,8 +95,17 @@
         return p;
     }
 
+    /* warm-up predicate for debuggee */
+    private static Pattern listenRegexp = Pattern.compile("Listening for transport \\b(.+)\\b at address: \\b(.+)\\b");
+
     private static boolean isTransportListening(String line) {
-        return line.startsWith("Listening for transport dt_socket");
+        Matcher m = listenRegexp.matcher(line);
+        if (!m.matches()) {
+            return false;
+        }
+        // address is 2nd group
+        address = m.group(2);
+        return true;
     }
 
     private static void checkForError(String line) {
@@ -103,28 +115,21 @@
     }
 
     /*
-     * - pick a TCP port
-     * - Launch a server debuggee: server=y,suspend=y,address=${port}
+     * - Launch a server debuggee: server=y,suspend=y,address=0
+     * - detect the port debuggee is listening on
      * - run it to VM death
      * - verify we saw no error
      */
     public static void main(String args[]) throws Exception {
-        // find a free port
-        ServerSocket ss = new ServerSocket(0);
-        int port = ss.getLocalPort();
-        ss.close();
-
-        String address = String.valueOf(port);
-
         // launch the server debuggee
-        Process process = launch(address, "Exit0");
+        Process process = launch("Exit0");
 
         // attach to server debuggee and resume it so it can exit
         AttachingConnector conn = (AttachingConnector)findConnector("com.sun.jdi.SocketAttach");
         Map conn_args = conn.defaultArguments();
         Connector.IntegerArgument port_arg =
             (Connector.IntegerArgument)conn_args.get("port");
-        port_arg.setValue(port);
+        port_arg.setValue(address);
 
         System.out.println("Connection arguments: " + conn_args);
 
--- a/test/jdk/java/lang/instrument/NamedBuffer.java	Tue Feb 26 18:12:06 2019 +0000
+++ b/test/jdk/java/lang/instrument/NamedBuffer.java	Wed Feb 27 14:48:22 2019 +0530
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2003, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2003, 2019, 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
@@ -64,7 +64,7 @@
     public static byte[]
     loadBufferFromStream(InputStream stream)
         throws IOException
-        {
+    {
         // hack for now, just assume the stream will fit in our reasonable size buffer.
         // if not, panic
         int bufferLimit = 200 * 1024;
@@ -83,5 +83,60 @@
                             0,
                             actualSize);
         return resultBuffer;
+    }
+
+    static final String DEST = System.getProperty("test.classes");
+    static final boolean VERBOSE = false;
+
+    static boolean checkMatch(byte[] buf, byte[] name, int begIdx) {
+        if (buf.length < name.length + begIdx) {
+            return false;
         }
+        for (int i = 0; i < name.length; i++) {
+            if (buf[i + begIdx] != name[i]) {
+                return false;
+            }
+        }
+        return true;
+    }
+
+    // This function reads a class file from disk and replaces the first character of
+    // the name with the one passed as "replace".  Then goes through the bytecodes to
+    // replace all instances of the name of the class with the new name.  The
+    // redefinition tests use this to redefine Host$ classes with precompiled class files
+    // Xost.java, Yost.java and Zost.java.
+    static byte[]
+    bytesForHostClass(char replace, String className) throws Throwable {
+        String tail = className.substring(1);
+        String origClassName = "" + replace + tail;
+        File clsfile = new File(DEST + "/" + origClassName + ".class");
+
+        if (VERBOSE) {
+            System.out.println("   Reading bytes from " + clsfile);
+        }
+        byte[] buf = null;
+        try (FileInputStream str = new FileInputStream(clsfile)) {
+            buf = loadBufferFromStream(str);
+        }
+
+        boolean found = false;
+        int dollarSignIdx = className.indexOf('$');
+        int ptrnLen = (dollarSignIdx == -1) ? className.length() : dollarSignIdx;
+        byte[] ptrnBytes = origClassName.substring(0, ptrnLen).getBytes();
+        byte firstByte = className.getBytes()[0];
+
+        for (int i = 0; i < buf.length - ptrnLen; i++) {
+            if (checkMatch(buf, ptrnBytes, i)) {
+                if (VERBOSE) {
+                    System.out.println("Appear to have found " + origClassName + " starting at " + i);
+                }
+                buf[i] = firstByte;
+                found = true;
+            }
+        }
+        if (!found) {
+            throw new Error("Could not locate '" + ptrnBytes + "' name in byte array");
+        }
+        return buf;
+    }
 }
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/test/jdk/java/lang/instrument/RedefineAddDeleteMethod/DeleteMethodHandle/MethodHandleDeletedMethod.java	Wed Feb 27 14:48:22 2019 +0530
@@ -0,0 +1,97 @@
+/*
+ * Copyright (c) 2019, 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
+ * under the terms of the GNU General Public License version 2 only, as
+ * published by the Free Software Foundation.
+ *
+ * This code is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
+ * version 2 for more details (a copy is included in the LICENSE file that
+ * accompanied this code).
+ *
+ * You should have received a copy of the GNU General Public License version
+ * 2 along with this work; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
+ *
+ * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
+ * or visit www.oracle.com if you need additional information or have any
+ * questions.
+ */
+
+/*
+ * @test
+ * @bug 8181171
+ * @summary Break ResolvedMethodTable with redefined nest class.
+ * @library /test/lib
+ * @modules java.base/jdk.internal.misc
+ * @modules java.compiler
+ *          java.instrument
+ *          jdk.jartool/sun.tools.jar
+ * @compile ../../NamedBuffer.java
+ * @compile redef/Xost.java
+ * @run main RedefineClassHelper
+ * @run main/othervm -javaagent:redefineagent.jar -Xlog:redefine+class+update*=debug,membername+table=debug MethodHandleDeletedMethod
+ */
+
+import java.io.File;
+import java.io.FileInputStream;
+import java.lang.invoke.*;
+
+class Host {
+    static MethodHandle fooMH;
+
+    static class A {
+        private static void foo() { System.out.println("OLD foo called"); }
+    }
+    static void bar() throws NoSuchMethodError {
+        A.foo();
+    }
+    static void barMH() throws Throwable {
+        fooMH.invokeExact();
+    }
+
+    public static void reresolve() throws Throwable {
+        fooMH = MethodHandles.lookup().findStatic(A.class, "foo", MethodType.methodType(void.class));
+    }
+
+    static {
+        try {
+          fooMH = MethodHandles.lookup().findStatic(A.class, "foo", MethodType.methodType(void.class));
+        } catch (ReflectiveOperationException ex) {
+        }
+    }
+}
+
+public class MethodHandleDeletedMethod {
+
+    static final String DEST = System.getProperty("test.classes");
+    static final boolean VERBOSE = false;
+
+    private static byte[] bytesForHostClass(char replace) throws Throwable {
+        return NamedBuffer.bytesForHostClass(replace, "Host$A");
+    }
+
+    public static void main(java.lang.String[] unused) throws Throwable {
+        Host h = new Host();
+        h.bar();
+        h.barMH();
+        byte[] buf = bytesForHostClass('X');
+        RedefineClassHelper.redefineClass(Host.A.class, buf);
+        try {
+            h.bar();    // call deleted Method directly
+            throw new RuntimeException("Failed, expected NSME");
+        } catch (NoSuchMethodError nsme) {
+            System.out.println("Received expected NSME");
+        }
+        try {
+            h.barMH();  // call through MethodHandle for deleted Method
+            throw new RuntimeException("Failed, expected NSME");
+        } catch (NoSuchMethodError nsme) {
+            System.out.println("Received expected NSME");
+        }
+        System.out.println("Passed.");
+    }
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/test/jdk/java/lang/instrument/RedefineAddDeleteMethod/DeleteMethodHandle/redef/Xost.java	Wed Feb 27 14:48:22 2019 +0530
@@ -0,0 +1,29 @@
+/*
+ * Copyright (c) 2019, 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
+ * under the terms of the GNU General Public License version 2 only, as
+ * published by the Free Software Foundation.
+ *
+ * This code is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
+ * version 2 for more details (a copy is included in the LICENSE file that
+ * accompanied this code).
+ *
+ * You should have received a copy of the GNU General Public License version
+ * 2 along with this work; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
+ *
+ * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
+ * or visit www.oracle.com if you need additional information or have any
+ * questions.
+ */
+
+public class Xost {
+    // Remove static private methods, in A in redefinition.
+    static class A { }
+    // Removed public method to get this to compile, but we don't
+    // try to redefine Host.
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/test/jdk/java/text/Format/DateFormat/TestDayPeriodWithSDF.java	Wed Feb 27 14:48:22 2019 +0530
@@ -0,0 +1,71 @@
+/*
+ * Copyright (c) 2019, 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
+ * under the terms of the GNU General Public License version 2 only, as
+ * published by the Free Software Foundation.
+ *
+ * This code is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
+ * version 2 for more details (a copy is included in the LICENSE file that
+ * accompanied this code).
+ *
+ * You should have received a copy of the GNU General Public License version
+ * 2 along with this work; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
+ *
+ * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
+ * or visit www.oracle.com if you need additional information or have any
+ * questions.
+ */
+/*
+ * @test
+ * @bug 8209175
+ * @summary Checks the 'B' character added in the CLDR date-time patterns is
+ *          getting resolved with 'a' character (am/pm strings) for burmese locale.
+ *          This test case assumes that the 'B' character is added in CLDRv33 update
+ *          for burmese locale in the time patterns. Since it is not supported by
+ *          SimpleDateFormat it is replaced with the 'a' while CLDR resource
+ *          conversion.
+ * @modules jdk.localedata
+ * @run testng/othervm TestDayPeriodWithSDF
+ */
+
+import org.testng.annotations.DataProvider;
+import org.testng.annotations.Test;
+import static org.testng.Assert.*;
+
+import java.text.DateFormat;
+import java.util.Calendar;
+import java.util.Date;
+import java.util.GregorianCalendar;
+import java.util.Locale;
+
+public class TestDayPeriodWithSDF {
+
+    private static final Locale BURMESE = new Locale("my");
+    private static final DateFormat FORMAT_SHORT_BURMESE = DateFormat.getTimeInstance(DateFormat.SHORT, BURMESE);
+    private static final DateFormat FORMAT_MEDIUM_BURMESE = DateFormat.getTimeInstance(DateFormat.MEDIUM, BURMESE);
+
+    private static final Date DATE_AM = new GregorianCalendar(2019, Calendar.FEBRUARY, 14, 10, 10, 10).getTime();
+    private static final Date DATE_PM = new GregorianCalendar(2019, Calendar.FEBRUARY, 14, 12, 12, 12).getTime();
+
+    @DataProvider(name = "timePatternData")
+    Object[][] timePatternData() {
+        return new Object[][] {
+                {FORMAT_SHORT_BURMESE, DATE_AM, "\u1014\u1036\u1014\u1000\u103A \u1041\u1040:\u1041\u1040"},
+                {FORMAT_SHORT_BURMESE, DATE_PM, "\u100A\u1014\u1031 \u1041\u1042:\u1041\u1042"},
+                {FORMAT_MEDIUM_BURMESE, DATE_AM, "\u1014\u1036\u1014\u1000\u103A \u1041\u1040:\u1041\u1040:\u1041\u1040"},
+                {FORMAT_MEDIUM_BURMESE, DATE_PM, "\u100A\u1014\u1031 \u1041\u1042:\u1041\u1042:\u1041\u1042"},
+        };
+    }
+
+    @Test(dataProvider = "timePatternData")
+    public void testTimePattern(DateFormat format, Date date, String expected) {
+        String actual = format.format(date);
+        assertEquals(actual, expected);
+    }
+
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/test/jdk/java/time/test/java/time/format/TestDayPeriodWithDTF.java	Wed Feb 27 14:48:22 2019 +0530
@@ -0,0 +1,72 @@
+/*
+ * Copyright (c) 2019, 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
+ * under the terms of the GNU General Public License version 2 only, as
+ * published by the Free Software Foundation.
+ *
+ * This code is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
+ * version 2 for more details (a copy is included in the LICENSE file that
+ * accompanied this code).
+ *
+ * You should have received a copy of the GNU General Public License version
+ * 2 along with this work; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
+ *
+ * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
+ * or visit www.oracle.com if you need additional information or have any
+ * questions.
+ */
+/*
+ * @test
+ * @bug 8209175
+ * @summary Checks the 'B' character added in the CLDR date-time patterns is
+ *          getting resolved with 'a' character (am/pm strings) for burmese locale.
+ *          This test case assumes that the 'B' character is added in CLDRv33 update
+ *          for burmese locale in the time patterns. Since it is not supported by
+ *          DateTimeFormatter it is replaced with the 'a' while CLDR resource
+ *          conversion.
+ * @modules jdk.localedata
+ */
+package test.java.time.format;
+
+import org.testng.annotations.DataProvider;
+import org.testng.annotations.Test;
+import static org.testng.Assert.*;
+
+import java.time.LocalTime;
+import java.time.format.DateTimeFormatter;
+import java.time.format.FormatStyle;
+import java.util.Locale;
+
+@Test
+public class TestDayPeriodWithDTF {
+
+    private static final Locale BURMESE = new Locale("my");
+
+    private static final DateTimeFormatter FORMAT_SHORT_BURMESE = DateTimeFormatter.ofLocalizedTime(FormatStyle.SHORT).withLocale(BURMESE);
+    private static final DateTimeFormatter FORMAT_MEDIUM_BURMESE = DateTimeFormatter.ofLocalizedTime(FormatStyle.MEDIUM).withLocale(BURMESE);
+
+    private static final LocalTime LOCAL_TIME_AM = LocalTime.of(10, 10, 10);
+    private static final LocalTime LOCAL_TIME_PM = LocalTime.of(12, 12, 12);
+
+    @DataProvider(name = "timePatternData")
+    Object[][] timePatternData() {
+        return new Object[][] {
+                {FORMAT_SHORT_BURMESE, LOCAL_TIME_AM, "\u1014\u1036\u1014\u1000\u103A 10:10"},
+                {FORMAT_SHORT_BURMESE, LOCAL_TIME_PM, "\u100A\u1014\u1031 12:12"},
+                {FORMAT_MEDIUM_BURMESE, LOCAL_TIME_AM, "\u1014\u1036\u1014\u1000\u103A 10:10:10"},
+                {FORMAT_MEDIUM_BURMESE, LOCAL_TIME_PM, "\u100A\u1014\u1031 12:12:12"},
+        };
+    }
+
+    @Test(dataProvider = "timePatternData")
+    public void testTimePattern(DateTimeFormatter formatter, LocalTime time, String expected) {
+        String actual = formatter.format(time);
+        assertEquals(actual, expected);
+    }
+
+}
--- a/test/jdk/java/util/spi/ToolProviderTest.java	Tue Feb 26 18:12:06 2019 +0000
+++ b/test/jdk/java/util/spi/ToolProviderTest.java	Wed Feb 27 14:48:22 2019 +0530
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2016, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2016, 2019, 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
@@ -28,7 +28,6 @@
  * @run main/othervm ToolProviderTest
  */
 
-import java.io.File;
 import java.io.IOException;
 import java.io.PrintWriter;
 import java.nio.file.Files;
@@ -46,6 +45,10 @@
     void run() throws Exception {
         initServices();
 
+        System.out.println("Validate an NPE is thrown with null arguments");
+
+        testNullArgs();
+
         System.out.println("test without security manager present:");
         test();
 
@@ -63,6 +66,33 @@
         }
     }
 
+    private void testNullArgs() {
+        ToolProvider testProvider = ToolProvider.findFirst("test").get();
+
+        // out null check
+        expectNullPointerException(() -> testProvider.run(null, System.err));
+
+        // err null check
+        expectNullPointerException(() -> testProvider.run(System.out, null));
+
+        // args array null check
+        expectNullPointerException(() ->
+                testProvider.run(System.out, System.err, (String[]) null));
+
+        // args array elements null check
+        expectNullPointerException(() ->
+                testProvider.run(System.out, System.err, (String) null));
+    }
+
+    private static void expectNullPointerException(Runnable test) {
+        try {
+            test.run();
+            throw new Error("NullPointerException not thrown");
+        } catch (NullPointerException e) {
+            // expected
+        }
+    }
+
     private void initServices() throws IOException {
         Path testClasses = Paths.get(System.getProperty("test.classes"));
         Path services = testClasses.resolve(Paths.get("META-INF", "services"));
--- a/test/jdk/tools/jlink/IntegrationTest.java	Tue Feb 26 18:12:06 2019 +0000
+++ b/test/jdk/tools/jlink/IntegrationTest.java	Wed Feb 27 14:48:22 2019 +0530
@@ -49,7 +49,7 @@
 import jdk.tools.jlink.internal.Jlink.PluginsConfiguration;
 import jdk.tools.jlink.internal.PostProcessor;
 import jdk.tools.jlink.internal.plugins.DefaultCompressPlugin;
-import jdk.tools.jlink.internal.plugins.StripDebugPlugin;
+import jdk.tools.jlink.internal.plugins.DefaultStripDebugPlugin;
 
 import tests.Helper;
 import tests.JImageGenerator;
@@ -168,7 +168,7 @@
         //Strip debug
         {
             Map<String, String> config1 = new HashMap<>();
-            config1.put(StripDebugPlugin.NAME, "");
+            config1.put(DefaultStripDebugPlugin.NAME, "");
             Plugin strip = Jlink.newPlugin("strip-debug", config1, null);
             lst.add(strip);
         }
--- a/test/jdk/tools/jlink/plugins/StripDebugPluginTest.java	Tue Feb 26 18:12:06 2019 +0000
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,162 +0,0 @@
-/*
- * Copyright (c) 2015, 2018, 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
- * under the terms of the GNU General Public License version 2 only, as
- * published by the Free Software Foundation.
- *
- * This code is distributed in the hope that it will be useful, but WITHOUT
- * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
- * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
- * version 2 for more details (a copy is included in the LICENSE file that
- * accompanied this code).
- *
- * You should have received a copy of the GNU General Public License version
- * 2 along with this work; if not, write to the Free Software Foundation,
- * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
- *
- * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
- * or visit www.oracle.com if you need additional information or have any
- * questions.
- */
-
-/*
- * @test
- * @summary Test StripDebugPlugin
- * @author Jean-Francois Denise
- * @library ../../lib
- * @build tests.*
- * @modules java.base/jdk.internal.jimage
- *          jdk.jlink/jdk.tools.jlink.internal
- *          jdk.jlink/jdk.tools.jlink.internal.plugins
- *          jdk.jlink/jdk.tools.jlink.plugin
- *          jdk.jlink/jdk.tools.jimage
- *          jdk.jlink/jdk.tools.jmod
- *          jdk.jdeps/com.sun.tools.classfile
- *          jdk.compiler
- * @run main StripDebugPluginTest
- */
-
-import java.io.ByteArrayInputStream;
-import java.io.IOException;
-import java.nio.file.Files;
-import java.nio.file.Path;
-import java.util.ArrayList;
-import java.util.Arrays;
-import java.util.Iterator;
-import java.util.List;
-import java.util.stream.Stream;
-
-import com.sun.tools.classfile.Attribute;
-import com.sun.tools.classfile.ClassFile;
-import com.sun.tools.classfile.Code_attribute;
-import com.sun.tools.classfile.ConstantPoolException;
-import com.sun.tools.classfile.Method;
-import java.util.HashMap;
-import java.util.Map;
-import jdk.tools.jlink.internal.ResourcePoolManager;
-import jdk.tools.jlink.internal.plugins.StripDebugPlugin;
-import jdk.tools.jlink.plugin.ResourcePoolEntry;
-import jdk.tools.jlink.plugin.ResourcePool;
-import jdk.tools.jlink.plugin.Plugin;
-import tests.Helper;
-
-public class StripDebugPluginTest {
-    public static void main(String[] args) throws Exception {
-        new StripDebugPluginTest().test();
-    }
-
-    public void test() throws Exception {
-        Helper helper = Helper.newHelper();
-        if (helper == null) {
-            // Skip test if the jmods directory is missing (e.g. exploded image)
-            System.err.println("Test not run, NO jmods directory");
-            return;
-        }
-
-        List<String> classes = Arrays.asList("toto.Main", "toto.com.foo.bar.X");
-        Path moduleFile = helper.generateModuleCompiledClasses(
-                helper.getJmodSrcDir(), helper.getJmodClassesDir(), "leaf1", classes);
-        Path moduleInfo = moduleFile.resolve("module-info.class");
-
-        // Classes have been compiled in debug.
-        List<Path> covered = new ArrayList<>();
-        byte[] infoContent = Files.readAllBytes(moduleInfo);
-        try (Stream<Path> stream = Files.walk(moduleFile)) {
-            for (Iterator<Path> iterator = stream.iterator(); iterator.hasNext(); ) {
-                Path p = iterator.next();
-                if (Files.isRegularFile(p) && p.toString().endsWith(".class")) {
-                    byte[] content = Files.readAllBytes(p);
-                    String path = "/" + helper.getJmodClassesDir().relativize(p).toString();
-                    String moduleInfoPath = path + "/module-info.class";
-                    check(path, content, moduleInfoPath, infoContent);
-                    covered.add(p);
-                }
-            }
-        }
-        if (covered.isEmpty()) {
-            throw new AssertionError("No class to compress");
-        } else {
-            System.err.println("removed debug attributes from "
-                    + covered.size() + " classes");
-        }
-    }
-
-    private void check(String path, byte[] content, String infoPath, byte[] moduleInfo) throws Exception {
-        path = path.replace('\\', '/');
-        StripDebugPlugin debug = new StripDebugPlugin();
-        debug.configure(new HashMap<>());
-        ResourcePoolEntry result1 = stripDebug(debug, ResourcePoolEntry.create(path,content), path, infoPath, moduleInfo);
-
-        if (!path.endsWith("module-info.class")) {
-            if (result1.contentLength() >= content.length) {
-                throw new AssertionError("Class size not reduced, debug info not "
-                        + "removed for " + path);
-            }
-            checkDebugAttributes(result1.contentBytes());
-        }
-
-        ResourcePoolEntry result2 = stripDebug(debug, result1, path, infoPath, moduleInfo);
-        if (result1.contentLength() != result2.contentLength()) {
-            throw new AssertionError("removing debug info twice reduces class size of "
-                    + path);
-        }
-        checkDebugAttributes(result1.contentBytes());
-    }
-
-    private ResourcePoolEntry stripDebug(Plugin debug, ResourcePoolEntry classResource,
-            String path, String infoPath, byte[] moduleInfo) throws Exception {
-        ResourcePoolManager resources = new ResourcePoolManager();
-        resources.add(classResource);
-        if (!path.endsWith("module-info.class")) {
-            ResourcePoolEntry res2 = ResourcePoolEntry.create(infoPath, moduleInfo);
-            resources.add(res2);
-        }
-        ResourcePoolManager results = new ResourcePoolManager();
-        ResourcePool resPool = debug.transform(resources.resourcePool(),
-                results.resourcePoolBuilder());
-        System.out.println(classResource.path());
-
-        return resPool.findEntry(classResource.path()).get();
-    }
-
-    private void checkDebugAttributes(byte[] strippedClassFile) throws IOException, ConstantPoolException {
-        ClassFile classFile = ClassFile.read(new ByteArrayInputStream(strippedClassFile));
-        String[] debugAttributes = new String[]{
-                Attribute.LineNumberTable,
-                Attribute.LocalVariableTable,
-                Attribute.LocalVariableTypeTable
-        };
-        for (Method method : classFile.methods) {
-            String methodName = method.getName(classFile.constant_pool);
-            Code_attribute code = (Code_attribute) method.attributes.get(Attribute.Code);
-            for (String attr : debugAttributes) {
-                if (code.attributes.get(attr) != null) {
-                    throw new AssertionError("Debug attribute was not removed: " + attr +
-                            " from method " + classFile.getName() + "#" + methodName);
-                }
-            }
-        }
-    }
-}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/test/jdk/tools/jlink/plugins/StripJavaDebugAttributesPluginTest.java	Wed Feb 27 14:48:22 2019 +0530
@@ -0,0 +1,162 @@
+/*
+ * Copyright (c) 2015, 2018, 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
+ * under the terms of the GNU General Public License version 2 only, as
+ * published by the Free Software Foundation.
+ *
+ * This code is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
+ * version 2 for more details (a copy is included in the LICENSE file that
+ * accompanied this code).
+ *
+ * You should have received a copy of the GNU General Public License version
+ * 2 along with this work; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
+ *
+ * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
+ * or visit www.oracle.com if you need additional information or have any
+ * questions.
+ */
+
+/*
+ * @test
+ * @summary Test StripJavaDebugAttributesPlugin
+ * @author Jean-Francois Denise
+ * @library ../../lib
+ * @build tests.*
+ * @modules java.base/jdk.internal.jimage
+ *          jdk.jlink/jdk.tools.jlink.internal
+ *          jdk.jlink/jdk.tools.jlink.internal.plugins
+ *          jdk.jlink/jdk.tools.jlink.plugin
+ *          jdk.jlink/jdk.tools.jimage
+ *          jdk.jlink/jdk.tools.jmod
+ *          jdk.jdeps/com.sun.tools.classfile
+ *          jdk.compiler
+ * @run main StripJavaDebugAttributesPluginTest
+ */
+
+import java.io.ByteArrayInputStream;
+import java.io.IOException;
+import java.nio.file.Files;
+import java.nio.file.Path;
+import java.util.ArrayList;
+import java.util.Arrays;
+import java.util.HashMap;
+import java.util.Iterator;
+import java.util.List;
+import java.util.stream.Stream;
+
+import com.sun.tools.classfile.Attribute;
+import com.sun.tools.classfile.ClassFile;
+import com.sun.tools.classfile.Code_attribute;
+import com.sun.tools.classfile.ConstantPoolException;
+import com.sun.tools.classfile.Method;
+
+import jdk.tools.jlink.internal.ResourcePoolManager;
+import jdk.tools.jlink.internal.plugins.StripJavaDebugAttributesPlugin;
+import jdk.tools.jlink.plugin.Plugin;
+import jdk.tools.jlink.plugin.ResourcePool;
+import jdk.tools.jlink.plugin.ResourcePoolEntry;
+import tests.Helper;
+
+public class StripJavaDebugAttributesPluginTest {
+    public static void main(String[] args) throws Exception {
+        new StripJavaDebugAttributesPluginTest().test();
+    }
+
+    public void test() throws Exception {
+        Helper helper = Helper.newHelper();
+        if (helper == null) {
+            // Skip test if the jmods directory is missing (e.g. exploded image)
+            System.err.println("Test not run, NO jmods directory");
+            return;
+        }
+
+        List<String> classes = Arrays.asList("toto.Main", "toto.com.foo.bar.X");
+        Path moduleFile = helper.generateModuleCompiledClasses(
+                helper.getJmodSrcDir(), helper.getJmodClassesDir(), "leaf1", classes);
+        Path moduleInfo = moduleFile.resolve("module-info.class");
+
+        // Classes have been compiled in debug.
+        List<Path> covered = new ArrayList<>();
+        byte[] infoContent = Files.readAllBytes(moduleInfo);
+        try (Stream<Path> stream = Files.walk(moduleFile)) {
+            for (Iterator<Path> iterator = stream.iterator(); iterator.hasNext(); ) {
+                Path p = iterator.next();
+                if (Files.isRegularFile(p) && p.toString().endsWith(".class")) {
+                    byte[] content = Files.readAllBytes(p);
+                    String path = "/" + helper.getJmodClassesDir().relativize(p).toString();
+                    String moduleInfoPath = path + "/module-info.class";
+                    check(path, content, moduleInfoPath, infoContent);
+                    covered.add(p);
+                }
+            }
+        }
+        if (covered.isEmpty()) {
+            throw new AssertionError("No class to compress");
+        } else {
+            System.err.println("removed debug attributes from "
+                    + covered.size() + " classes");
+        }
+    }
+
+    private void check(String path, byte[] content, String infoPath, byte[] moduleInfo) throws Exception {
+        path = path.replace('\\', '/');
+        StripJavaDebugAttributesPlugin debug = new StripJavaDebugAttributesPlugin();
+        debug.configure(new HashMap<>());
+        ResourcePoolEntry result1 = stripDebug(debug, ResourcePoolEntry.create(path,content), path, infoPath, moduleInfo);
+
+        if (!path.endsWith("module-info.class")) {
+            if (result1.contentLength() >= content.length) {
+                throw new AssertionError("Class size not reduced, debug info not "
+                        + "removed for " + path);
+            }
+            checkDebugAttributes(result1.contentBytes());
+        }
+
+        ResourcePoolEntry result2 = stripDebug(debug, result1, path, infoPath, moduleInfo);
+        if (result1.contentLength() != result2.contentLength()) {
+            throw new AssertionError("removing debug info twice reduces class size of "
+                    + path);
+        }
+        checkDebugAttributes(result1.contentBytes());
+    }
+
+    private ResourcePoolEntry stripDebug(Plugin debug, ResourcePoolEntry classResource,
+            String path, String infoPath, byte[] moduleInfo) throws Exception {
+        ResourcePoolManager resources = new ResourcePoolManager();
+        resources.add(classResource);
+        if (!path.endsWith("module-info.class")) {
+            ResourcePoolEntry res2 = ResourcePoolEntry.create(infoPath, moduleInfo);
+            resources.add(res2);
+        }
+        ResourcePoolManager results = new ResourcePoolManager();
+        ResourcePool resPool = debug.transform(resources.resourcePool(),
+                results.resourcePoolBuilder());
+        System.out.println(classResource.path());
+
+        return resPool.findEntry(classResource.path()).get();
+    }
+
+    private void checkDebugAttributes(byte[] strippedClassFile) throws IOException, ConstantPoolException {
+        ClassFile classFile = ClassFile.read(new ByteArrayInputStream(strippedClassFile));
+        String[] debugAttributes = new String[]{
+                Attribute.LineNumberTable,
+                Attribute.LocalVariableTable,
+                Attribute.LocalVariableTypeTable
+        };
+        for (Method method : classFile.methods) {
+            String methodName = method.getName(classFile.constant_pool);
+            Code_attribute code = (Code_attribute) method.attributes.get(Attribute.Code);
+            for (String attr : debugAttributes) {
+                if (code.attributes.get(attr) != null) {
+                    throw new AssertionError("Debug attribute was not removed: " + attr +
+                            " from method " + classFile.getName() + "#" + methodName);
+                }
+            }
+        }
+    }
+}