Merge JDK-8200758-branch
authorherrick
Wed, 27 Feb 2019 20:45:51 -0500
branchJDK-8200758-branch
changeset 57220 6a80fd1912ef
parent 57219 bfa094e6ce15 (current diff)
parent 53947 8e069f7b4fab (diff)
child 57241 e11f3bf34083
Merge
src/java.base/macosx/native/libjli/java_md_macosx.m
src/java.smartcardio/unix/native/libj2pcsc/MUSCLE/COPYING
--- a/src/hotspot/cpu/aarch64/templateTable_aarch64.cpp	Wed Feb 27 20:04:03 2019 -0500
+++ b/src/hotspot/cpu/aarch64/templateTable_aarch64.cpp	Wed Feb 27 20:45:51 2019 -0500
@@ -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/cpu/aarch64/vm_version_aarch64.cpp	Wed Feb 27 20:04:03 2019 -0500
+++ b/src/hotspot/cpu/aarch64/vm_version_aarch64.cpp	Wed Feb 27 20:45:51 2019 -0500
@@ -258,8 +258,10 @@
   if (FLAG_IS_DEFAULT(UseCRC32)) {
     UseCRC32 = (auxv & HWCAP_CRC32) != 0;
   }
+
   if (UseCRC32 && (auxv & HWCAP_CRC32) == 0) {
     warning("UseCRC32 specified, but not supported on this CPU");
+    FLAG_SET_DEFAULT(UseCRC32, false);
   }
 
   if (FLAG_IS_DEFAULT(UseAdler32Intrinsics)) {
@@ -277,6 +279,7 @@
   } else {
     if (UseLSE) {
       warning("UseLSE specified, but not supported on this CPU");
+      FLAG_SET_DEFAULT(UseLSE, false);
     }
   }
 
@@ -291,9 +294,11 @@
   } else {
     if (UseAES) {
       warning("UseAES specified, but not supported on this CPU");
+      FLAG_SET_DEFAULT(UseAES, false);
     }
     if (UseAESIntrinsics) {
       warning("UseAESIntrinsics specified, but not supported on this CPU");
+      FLAG_SET_DEFAULT(UseAESIntrinsics, false);
     }
   }
 
--- a/src/hotspot/share/utilities/debug.cpp	Wed Feb 27 20:04:03 2019 -0500
+++ b/src/hotspot/share/utilities/debug.cpp	Wed Feb 27 20:45:51 2019 -0500
@@ -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	Wed Feb 27 20:04:03 2019 -0500
+++ b/src/hotspot/share/utilities/ostream.cpp	Wed Feb 27 20:45:51 2019 -0500
@@ -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	Wed Feb 27 20:04:03 2019 -0500
+++ b/src/hotspot/share/utilities/ostream.hpp	Wed Feb 27 20:45:51 2019 -0500
@@ -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/macosx/native/libjli/java_md_macosx.m	Wed Feb 27 20:04:03 2019 -0500
+++ b/src/java.base/macosx/native/libjli/java_md_macosx.m	Wed Feb 27 20:45:51 2019 -0500
@@ -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
@@ -717,10 +717,17 @@
 }
 
 /*
- * Block current thread and continue execution in a new thread
+ * Signature adapter for pthread_create().
+ */
+static void* ThreadJavaMain(void* args) {
+    return (void*)(intptr_t)JavaMain(args);
+}
+
+/*
+ * Block current thread and continue execution in a new thread.
  */
 int
-ContinueInNewThread0(int (JNICALL *continuation)(void *), jlong stack_size, void * args) {
+CallJavaMainInNewThread(jlong stack_size, void* args) {
     int rslt;
     pthread_t tid;
     pthread_attr_t attr;
@@ -728,22 +735,22 @@
     pthread_attr_setdetachstate(&attr, PTHREAD_CREATE_JOINABLE);
 
     if (stack_size > 0) {
-      pthread_attr_setstacksize(&attr, stack_size);
+        pthread_attr_setstacksize(&attr, stack_size);
     }
     pthread_attr_setguardsize(&attr, 0); // no pthread guard page on java threads
 
-    if (pthread_create(&tid, &attr, (void *(*)(void*))continuation, (void*)args) == 0) {
-      void * tmp;
-      pthread_join(tid, &tmp);
-      rslt = (int)(intptr_t)tmp;
+    if (pthread_create(&tid, &attr, ThreadJavaMain, args) == 0) {
+        void* tmp;
+        pthread_join(tid, &tmp);
+        rslt = (int)(intptr_t)tmp;
     } else {
-     /*
-      * Continue execution in current thread if for some reason (e.g. out of
-      * memory/LWP)  a new thread can't be created. This will likely fail
-      * later in continuation as JNI_CreateJavaVM needs to create quite a
-      * few new threads, anyway, just give it a try..
-      */
-      rslt = continuation(args);
+       /*
+        * Continue execution in current thread if for some reason (e.g. out of
+        * memory/LWP)  a new thread can't be created. This will likely fail
+        * later in JavaMain as JNI_CreateJavaVM needs to create quite a
+        * few new threads, anyway, just give it a try..
+        */
+        rslt = JavaMain(args);
     }
 
     pthread_attr_destroy(&attr);
--- a/src/java.base/share/classes/java/lang/Throwable.java	Wed Feb 27 20:04:03 2019 -0500
+++ b/src/java.base/share/classes/java/lang/Throwable.java	Wed Feb 27 20:45:51 2019 -0500
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 1994, 2016, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 1994, 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
@@ -616,7 +616,7 @@
      *          ... 1 more
      * </pre>
      * Note that the "... n more" notation is used on suppressed exceptions
-     * just at it is used on causes. Unlike causes, suppressed exceptions are
+     * just as it is used on causes. Unlike causes, suppressed exceptions are
      * indented beyond their "containing exceptions."
      *
      * <p>An exception can have both a cause and one or more suppressed
--- a/src/java.base/share/classes/java/util/spi/ToolProvider.java	Wed Feb 27 20:04:03 2019 -0500
+++ b/src/java.base/share/classes/java/util/spi/ToolProvider.java	Wed Feb 27 20:45:51 2019 -0500
@@ -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/reflect/ReflectionFactory.java	Wed Feb 27 20:04:03 2019 -0500
+++ b/src/java.base/share/classes/jdk/internal/reflect/ReflectionFactory.java	Wed Feb 27 20:45:51 2019 -0500
@@ -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.base/share/native/libjli/java.c	Wed Feb 27 20:04:03 2019 -0500
+++ b/src/java.base/share/native/libjli/java.c	Wed Feb 27 20:45:51 2019 -0500
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 1995, 2018, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 1995, 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
@@ -388,8 +388,8 @@
     } while (JNI_FALSE)
 
 
-int JNICALL
-JavaMain(void * _args)
+int
+JavaMain(void* _args)
 {
     JavaMainArgs *args = (JavaMainArgs *)_args;
     int argc = args->argc;
@@ -2348,7 +2348,7 @@
       args.what = what;
       args.ifn = *ifn;
 
-      rslt = ContinueInNewThread0(JavaMain, threadStackSize, (void*)&args);
+      rslt = CallJavaMainInNewThread(threadStackSize, (void*)&args);
       /* If the caller has deemed there is an error we
        * simply return that, otherwise we return the value of
        * the callee
--- a/src/java.base/share/native/libjli/java.h	Wed Feb 27 20:04:03 2019 -0500
+++ b/src/java.base/share/native/libjli/java.h	Wed Feb 27 20:45:51 2019 -0500
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 1998, 2018, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 1998, 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
@@ -156,10 +156,9 @@
 void PrintMachineDependentOptions();
 
 /*
- * Block current thread and continue execution in new thread
+ * Block current thread and continue execution in new thread.
  */
-int ContinueInNewThread0(int (JNICALL *continuation)(void *),
-                        jlong stack_size, void * args);
+int CallJavaMainInNewThread(jlong stack_size, void* args);
 
 /* sun.java.launcher.* platform properties. */
 void SetJavaLauncherPlatformProps(void);
@@ -224,7 +223,10 @@
 jobjectArray NewPlatformStringArray(JNIEnv *env, char **strv, int strc);
 jclass GetLauncherHelperClass(JNIEnv *env);
 
-int JNICALL JavaMain(void * args); /* entry point                  */
+/*
+ * Entry point.
+ */
+int JavaMain(void* args);
 
 enum LaunchMode {               // cf. sun.launcher.LauncherHelper
     LM_UNKNOWN = 0,
--- a/src/java.base/unix/native/libjli/java_md_solinux.c	Wed Feb 27 20:04:03 2019 -0500
+++ b/src/java.base/unix/native/libjli/java_md_solinux.c	Wed Feb 27 20:45:51 2019 -0500
@@ -718,10 +718,17 @@
 }
 
 /*
- * Block current thread and continue execution in a new thread
+ * Signature adapter for pthread_create() or thr_create().
+ */
+static void* ThreadJavaMain(void* args) {
+    return (void*)(intptr_t)JavaMain(args);
+}
+
+/*
+ * Block current thread and continue execution in a new thread.
  */
 int
-ContinueInNewThread0(int (JNICALL *continuation)(void *), jlong stack_size, void * args) {
+CallJavaMainInNewThread(jlong stack_size, void* args) {
     int rslt;
 #ifndef __solaris__
     pthread_t tid;
@@ -730,35 +737,35 @@
     pthread_attr_setdetachstate(&attr, PTHREAD_CREATE_JOINABLE);
 
     if (stack_size > 0) {
-      pthread_attr_setstacksize(&attr, stack_size);
+        pthread_attr_setstacksize(&attr, stack_size);
     }
     pthread_attr_setguardsize(&attr, 0); // no pthread guard page on java threads
 
-    if (pthread_create(&tid, &attr, (void *(*)(void*))continuation, (void*)args) == 0) {
-      void * tmp;
-      pthread_join(tid, &tmp);
-      rslt = (int)(intptr_t)tmp;
+    if (pthread_create(&tid, &attr, ThreadJavaMain, args) == 0) {
+        void* tmp;
+        pthread_join(tid, &tmp);
+        rslt = (int)(intptr_t)tmp;
     } else {
-     /*
-      * Continue execution in current thread if for some reason (e.g. out of
-      * memory/LWP)  a new thread can't be created. This will likely fail
-      * later in continuation as JNI_CreateJavaVM needs to create quite a
-      * few new threads, anyway, just give it a try..
-      */
-      rslt = continuation(args);
+       /*
+        * Continue execution in current thread if for some reason (e.g. out of
+        * memory/LWP)  a new thread can't be created. This will likely fail
+        * later in JavaMain as JNI_CreateJavaVM needs to create quite a
+        * few new threads, anyway, just give it a try..
+        */
+        rslt = JavaMain(args);
     }
 
     pthread_attr_destroy(&attr);
 #else /* __solaris__ */
     thread_t tid;
     long flags = 0;
-    if (thr_create(NULL, stack_size, (void *(*)(void *))continuation, args, flags, &tid) == 0) {
-      void * tmp;
-      thr_join(tid, NULL, &tmp);
-      rslt = (int)(intptr_t)tmp;
+    if (thr_create(NULL, stack_size, ThreadJavaMain, args, flags, &tid) == 0) {
+        void* tmp;
+        thr_join(tid, NULL, &tmp);
+        rslt = (int)(intptr_t)tmp;
     } else {
-      /* See above. Continue in current thread if thr_create() failed */
-      rslt = continuation(args);
+        /* See above. Continue in current thread if thr_create() failed */
+        rslt = JavaMain(args);
     }
 #endif /* !__solaris__ */
     return rslt;
--- a/src/java.base/windows/native/libjli/java_md.c	Wed Feb 27 20:04:03 2019 -0500
+++ b/src/java.base/windows/native/libjli/java_md.c	Wed Feb 27 20:45:51 2019 -0500
@@ -704,10 +704,17 @@
 }
 
 /*
- * Block current thread and continue execution in a new thread
+ * Signature adapter for _beginthreadex().
+ */
+static unsigned __stdcall ThreadJavaMain(void* args) {
+    return (unsigned)JavaMain(args);
+}
+
+/*
+ * Block current thread and continue execution in a new thread.
  */
 int
-ContinueInNewThread0(int (JNICALL *continuation)(void *), jlong stack_size, void * args) {
+CallJavaMainInNewThread(jlong stack_size, void* args) {
     int rslt = 0;
     unsigned thread_id;
 
@@ -722,20 +729,20 @@
      * source (os_win32.cpp) for details.
      */
     HANDLE thread_handle =
-      (HANDLE)_beginthreadex(NULL,
-                             (unsigned)stack_size,
-                             continuation,
-                             args,
-                             STACK_SIZE_PARAM_IS_A_RESERVATION,
-                             &thread_id);
+        (HANDLE)_beginthreadex(NULL,
+                               (unsigned)stack_size,
+                               ThreadJavaMain,
+                               args,
+                               STACK_SIZE_PARAM_IS_A_RESERVATION,
+                               &thread_id);
     if (thread_handle == NULL) {
-      thread_handle =
-      (HANDLE)_beginthreadex(NULL,
-                             (unsigned)stack_size,
-                             continuation,
-                             args,
-                             0,
-                             &thread_id);
+        thread_handle =
+        (HANDLE)_beginthreadex(NULL,
+                               (unsigned)stack_size,
+                               ThreadJavaMain,
+                               args,
+                               0,
+                               &thread_id);
     }
 
     /* AWT preloading (AFTER main thread start) */
@@ -772,11 +779,11 @@
 #endif /* ENABLE_AWT_PRELOAD */
 
     if (thread_handle) {
-      WaitForSingleObject(thread_handle, INFINITE);
-      GetExitCodeThread(thread_handle, &rslt);
-      CloseHandle(thread_handle);
+        WaitForSingleObject(thread_handle, INFINITE);
+        GetExitCodeThread(thread_handle, &rslt);
+        CloseHandle(thread_handle);
     } else {
-      rslt = continuation(args);
+        rslt = JavaMain(args);
     }
 
 #ifdef ENABLE_AWT_PRELOAD
--- a/src/java.compiler/share/classes/javax/lang/model/element/package-info.java	Wed Feb 27 20:04:03 2019 -0500
+++ b/src/java.compiler/share/classes/javax/lang/model/element/package-info.java	Wed Feb 27 20:45:51 2019 -0500
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2005, 2017, 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
@@ -107,6 +107,7 @@
  * @author Joseph D. Darcy
  * @author Scott Seligman
  * @author Peter von der Ah&eacute;
+ * @see javax.lang.model.util.Elements
  * @since 1.6
  */
 package javax.lang.model.element;
--- a/src/java.compiler/share/classes/javax/lang/model/type/package-info.java	Wed Feb 27 20:04:03 2019 -0500
+++ b/src/java.compiler/share/classes/javax/lang/model/type/package-info.java	Wed Feb 27 20:45:51 2019 -0500
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2005, 2006, 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
@@ -36,6 +36,7 @@
  * @author Joseph D. Darcy
  * @author Scott Seligman
  * @author Peter von der Ah&eacute;
+ * @see javax.lang.model.util.Types
  * @since 1.6
  */
 package javax.lang.model.type;
--- a/src/java.desktop/macosx/native/libawt_lwawt/awt/AWTWindow.h	Wed Feb 27 20:04:03 2019 -0500
+++ b/src/java.desktop/macosx/native/libawt_lwawt/awt/AWTWindow.h	Wed Feb 27 20:45:51 2019 -0500
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2011, 2015, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2011, 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
@@ -47,6 +47,7 @@
     jint preFullScreenLevel;
     NSRect standardFrame;
     BOOL isMinimizing;
+    BOOL keyNotificationRecd;
 }
 
 // An instance of either AWTWindow_Normal or AWTWindow_Panel
@@ -62,6 +63,7 @@
 @property (nonatomic) jint preFullScreenLevel;
 @property (nonatomic) NSRect standardFrame;
 @property (nonatomic) BOOL isMinimizing;
+@property (nonatomic) BOOL keyNotificationRecd;
 
 - (id) initWithPlatformWindow:(JNFWeakJObjectWrapper *)javaPlatformWindow
                   ownerWindow:owner
--- a/src/java.desktop/macosx/native/libawt_lwawt/awt/AWTWindow.m	Wed Feb 27 20:04:03 2019 -0500
+++ b/src/java.desktop/macosx/native/libawt_lwawt/awt/AWTWindow.m	Wed Feb 27 20:45:51 2019 -0500
@@ -186,6 +186,7 @@
 @synthesize preFullScreenLevel;
 @synthesize standardFrame;
 @synthesize isMinimizing;
+@synthesize keyNotificationRecd;
 
 - (void) updateMinMaxSize:(BOOL)resizable {
     if (resizable) {
@@ -319,6 +320,7 @@
     if (self.nsWindow == nil) return nil; // no hope either
     [self.nsWindow release]; // the property retains the object already
 
+    self.keyNotificationRecd = NO;
     self.isEnabled = YES;
     self.isMinimizing = NO;
     self.javaPlatformWindow = platformWindow;
@@ -747,9 +749,16 @@
 AWT_ASSERT_APPKIT_THREAD;
     [AWTToolkit eventCountPlusPlus];
 #ifdef DEBUG
-    NSLog(@"became main: %d %@ %@", [self.nsWindow isKeyWindow], [self.nsWindow title], [self menuBarForWindow]);
+    NSLog(@"became main: %d %@ %@ %d", [self.nsWindow isKeyWindow], [self.nsWindow title], [self menuBarForWindow], self.keyNotificationRecd);
 #endif
 
+    // if for some reason, no KEY notification is received but this main window is also a key window
+    // then we need to execute the KEY notification functionality.
+    if(self.keyNotificationRecd != YES && [self.nsWindow isKeyWindow]) {
+        [self doWindowDidBecomeKey];
+    }
+    self.keyNotificationRecd = NO;
+
     if (![self.nsWindow isKeyWindow]) {
         [self activateWindowMenuBar];
     }
@@ -769,6 +778,12 @@
 #ifdef DEBUG
     NSLog(@"became key: %d %@ %@", [self.nsWindow isMainWindow], [self.nsWindow title], [self menuBarForWindow]);
 #endif
+    [self doWindowDidBecomeKey];
+    self.keyNotificationRecd = YES;
+}
+
+- (void) doWindowDidBecomeKey {
+AWT_ASSERT_APPKIT_THREAD;
     AWTWindow *opposite = [AWTWindow lastKeyWindow];
 
     if (![self.nsWindow isMainWindow]) {
--- a/src/java.desktop/share/classes/javax/swing/text/html/CSS.java	Wed Feb 27 20:04:03 2019 -0500
+++ b/src/java.desktop/share/classes/javax/swing/text/html/CSS.java	Wed Feb 27 20:45:51 2019 -0500
@@ -1362,6 +1362,19 @@
         } else {
             digits = value;
         }
+        // Some webpage passes 3 digit color code as in #fff which is
+        // decoded as #000FFF resulting in blue background.
+        // As per https://www.w3.org/TR/CSS1/#color-units,
+        // The three-digit RGB notation (#rgb) is converted into six-digit form
+        // (#rrggbb) by replicating digits, not by adding zeros.
+        // This makes sure that white (#ffffff) can be specified with the short notation
+        // (#fff) and removes any dependencies on the color depth of the display.
+        if (digits.length() == 3) {
+            final String r = digits.substring(0, 1);
+            final String g = digits.substring(1, 2);
+            final String b = digits.substring(2, 3);
+            digits = String.format("%s%s%s%s%s%s", r, r, g, g, b, b);
+        }
         String hstr = "0x" + digits;
         Color c;
         try {
--- a/src/java.desktop/share/classes/javax/swing/text/rtf/RTFReader.java	Wed Feb 27 20:04:03 2019 -0500
+++ b/src/java.desktop/share/classes/javax/swing/text/rtf/RTFReader.java	Wed Feb 27 20:45:51 2019 -0500
@@ -1185,6 +1185,10 @@
             parserState.put(keyword, Integer.valueOf(parameter));
             return true;
         }
+        if (keyword.equals("cb")) {
+            parserState.put(keyword, Integer.valueOf(parameter));
+            return true;
+        }
 
         {
             RTFAttribute attr = straightforwardAttributes.get(keyword);
--- a/src/java.desktop/windows/classes/sun/print/PrintServiceLookupProvider.java	Wed Feb 27 20:04:03 2019 -0500
+++ b/src/java.desktop/windows/classes/sun/print/PrintServiceLookupProvider.java	Wed Feb 27 20:45:51 2019 -0500
@@ -403,18 +403,36 @@
        list.
     */
     class RemotePrinterChangeListener implements Runnable {
-        private String[] prevRemotePrinters;
+        private String[] prevRemotePrinters = null;
 
         RemotePrinterChangeListener() {
             prevRemotePrinters = getRemotePrintersNames();
         }
 
         boolean doCompare(String[] str1, String[] str2) {
+            if (str1 == null && str2 == null) {
+                return false;
+            } else if (str1 == null || str2 == null) {
+                return true;
+            }
+
             if (str1.length != str2.length) {
                 return true;
             } else {
                 for (int i = 0;i < str1.length;i++) {
                     for (int j = 0;j < str2.length;j++) {
+                        // skip if both are nulls
+                        if (str1[i] == null && str2[j] == null) {
+                            continue;
+                        }
+
+                        // return true if there is a 'difference' but
+                        // no need to access the individual string
+                        if (str1[i] == null || str2[j] == null) {
+                            return true;
+                        }
+
+                        // do comparison only if they are non-nulls
                         if (!str1[i].equals(str2[j])) {
                             return true;
                         }
@@ -428,15 +446,19 @@
         @Override
         public void run() {
             while (true) {
-                String[] currentRemotePrinters = getRemotePrintersNames();
-                if (doCompare(prevRemotePrinters, currentRemotePrinters)) {
+                if (prevRemotePrinters != null && prevRemotePrinters.length > 0) {
+                    String[] currentRemotePrinters = getRemotePrintersNames();
+                    if (doCompare(prevRemotePrinters, currentRemotePrinters)) {
 
-                    // updated the printers data
-                    // printers list now contains both local and network printer data
-                    refreshServices();
+                        // updated the printers data
+                        // printers list now contains both local and network printer data
+                        refreshServices();
 
-                    // store the current data for next comparison
-                    prevRemotePrinters = currentRemotePrinters;
+                        // store the current data for next comparison
+                        prevRemotePrinters = currentRemotePrinters;
+                    }
+                } else {
+                    prevRemotePrinters = getRemotePrintersNames();
                 }
 
                 try {
--- a/src/java.desktop/windows/native/libawt/windows/WPrinterJob.cpp	Wed Feb 27 20:04:03 2019 -0500
+++ b/src/java.desktop/windows/native/libawt/windows/WPrinterJob.cpp	Wed Feb 27 20:45:51 2019 -0500
@@ -249,7 +249,7 @@
     if (clazz == NULL) {
         return NULL;
     }
-    jobjectArray nameArray;
+    jobjectArray nameArray = NULL;
 
     try {
         ::EnumPrinters(PRINTER_ENUM_LOCAL | PRINTER_ENUM_CONNECTIONS,
@@ -270,13 +270,14 @@
                 }
             }
 
-            // Allocate space only for the network type printers
-            nameArray = env->NewObjectArray(remotePrintersCount, clazz, NULL);
-            if (nameArray == NULL) {
-                throw std::bad_alloc();
+            // return remote printers only if the list contains it.
+            if (remotePrintersCount > 0) {
+                // Allocate space only for the network type printers
+                nameArray = env->NewObjectArray(remotePrintersCount, clazz, NULL);
+                if (nameArray == NULL) {
+                    throw std::bad_alloc();
+                }
             }
-        } else {
-            nameArray = NULL;
         }
 
         // Loop thro' network printers list only
@@ -298,7 +299,12 @@
 
     delete [] pPrinterEnum;
     delete [] pNetworkPrinterLoc;
-    return nameArray;
+
+    if (nameArray != NULL) {
+      return nameArray;
+    } else {
+      return env->NewObjectArray(0, clazz, NULL);
+    }
 
     CATCH_BAD_ALLOC_RET(NULL);
 }
--- a/src/java.smartcardio/share/native/libj2pcsc/pcsc.c	Wed Feb 27 20:04:03 2019 -0500
+++ b/src/java.smartcardio/share/native/libj2pcsc/pcsc.c	Wed Feb 27 20:45:51 2019 -0500
@@ -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	Wed Feb 27 20:04:03 2019 -0500
+++ /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	Wed Feb 27 20:04:03 2019 -0500
+++ b/src/java.smartcardio/unix/native/libj2pcsc/MUSCLE/pcsclite.h	Wed Feb 27 20:45:51 2019 -0500
@@ -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	Wed Feb 27 20:04:03 2019 -0500
+++ b/src/java.smartcardio/unix/native/libj2pcsc/MUSCLE/winscard.h	Wed Feb 27 20:45:51 2019 -0500
@@ -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 20:45:51 2019 -0500
@@ -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	Wed Feb 27 20:04:03 2019 -0500
+++ b/src/java.smartcardio/unix/native/libj2pcsc/pcsc_md.h	Wed Feb 27 20:45:51 2019 -0500
@@ -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.accessibility/windows/native/jaccessinspector/jaccessinspectorWindow.rc	Wed Feb 27 20:04:03 2019 -0500
+++ b/src/jdk.accessibility/windows/native/jaccessinspector/jaccessinspectorWindow.rc	Wed Feb 27 20:45:51 2019 -0500
@@ -202,7 +202,7 @@
             VALUE "CompanyName",      XSTR(JDK_COMPANY)       "\0"
             VALUE "FileDescription",  XSTR(JDK_COMPONENT)     "\0"
             VALUE "FileVersion",      XSTR(JDK_VER)           "\0"
-            VALUE "Full Version",     XSTR(JDK_BUILD_ID)      "\0"
+            VALUE "Full Version",     XSTR(JDK_VERSION_STRING) "\0"
             VALUE "InternalName",     XSTR(JDK_INTERNAL_NAME) "\0"
             VALUE "LegalCopyright",   XSTR(JDK_COPYRIGHT)     "\0"
             VALUE "OriginalFilename", XSTR(JDK_FNAME)         "\0"
--- a/src/jdk.accessibility/windows/native/jaccesswalker/jaccesswalkerWindow.rc	Wed Feb 27 20:04:03 2019 -0500
+++ b/src/jdk.accessibility/windows/native/jaccesswalker/jaccesswalkerWindow.rc	Wed Feb 27 20:45:51 2019 -0500
@@ -167,7 +167,7 @@
             VALUE "CompanyName",      XSTR(JDK_COMPANY)       "\0"
             VALUE "FileDescription",  XSTR(JDK_COMPONENT)     "\0"
             VALUE "FileVersion",      XSTR(JDK_VER)           "\0"
-            VALUE "Full Version",     XSTR(JDK_BUILD_ID)      "\0"
+            VALUE "Full Version",     XSTR(JDK_VERSION_STRING) "\0"
             VALUE "InternalName",     XSTR(JDK_INTERNAL_NAME) "\0"
             VALUE "LegalCopyright",   XSTR(JDK_COPYRIGHT)     "\0"
             VALUE "OriginalFilename", XSTR(JDK_FNAME)         "\0"
--- a/src/jdk.crypto.cryptoki/share/classes/sun/security/pkcs11/P11KeyGenerator.java	Wed Feb 27 20:04:03 2019 -0500
+++ b/src/jdk.crypto.cryptoki/share/classes/sun/security/pkcs11/P11KeyGenerator.java	Wed Feb 27 20:45:51 2019 -0500
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2003, 2008, 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
@@ -119,11 +119,13 @@
                 // RC4 which is in bits. However, some PKCS#11 impls still use
                 // bytes for all mechs, e.g. NSS. We try to detect this
                 // inconsistency if the minKeySize seems unreasonably small.
-                int minKeySize = (int)info.ulMinKeySize;
-                int maxKeySize = (int)info.ulMaxKeySize;
+                int minKeySize = info.iMinKeySize;
+                int maxKeySize = info.iMaxKeySize;
                 if (keyGenMech != CKM_RC4_KEY_GEN || minKeySize < 8) {
-                    minKeySize = (int)info.ulMinKeySize << 3;
-                    maxKeySize = (int)info.ulMaxKeySize << 3;
+                    minKeySize = Math.multiplyExact(minKeySize, 8);
+                    if (maxKeySize != Integer.MAX_VALUE) {
+                        maxKeySize = Math.multiplyExact(maxKeySize, 8);
+                    }
                 }
                 // Explicitly disallow keys shorter than 40-bits for security
                 if (minKeySize < 40) minKeySize = 40;
--- a/src/jdk.crypto.cryptoki/share/classes/sun/security/pkcs11/P11KeyPairGenerator.java	Wed Feb 27 20:04:03 2019 -0500
+++ b/src/jdk.crypto.cryptoki/share/classes/sun/security/pkcs11/P11KeyPairGenerator.java	Wed Feb 27 20:45:51 2019 -0500
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2003, 2017, 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
@@ -73,7 +73,7 @@
     private BigInteger rsaPublicExponent = RSAKeyGenParameterSpec.F4;
 
     // the supported keysize range of the native PKCS11 library
-    // if the value cannot be retrieved or unspecified, -1 is used.
+    // if mechanism info is unavailable, 0/Integer.MAX_VALUE is used
     private final int minKeySize;
     private final int maxKeySize;
 
@@ -83,13 +83,13 @@
     P11KeyPairGenerator(Token token, String algorithm, long mechanism)
             throws PKCS11Exception {
         super();
-        int minKeyLen = -1;
-        int maxKeyLen = -1;
+        int minKeyLen = 0;
+        int maxKeyLen = Integer.MAX_VALUE;
         try {
             CK_MECHANISM_INFO mechInfo = token.getMechanismInfo(mechanism);
             if (mechInfo != null) {
-                minKeyLen = (int) mechInfo.ulMinKeySize;
-                maxKeyLen = (int) mechInfo.ulMaxKeySize;
+                minKeyLen = mechInfo.iMinKeySize;
+                maxKeyLen = mechInfo.iMaxKeySize;
             }
         } catch (PKCS11Exception p11e) {
             // Should never happen
@@ -101,10 +101,10 @@
         // override upper limit to deter DOS attack
         if (algorithm.equals("EC")) {
             keySize = DEF_EC_KEY_SIZE;
-            if ((minKeyLen == -1) || (minKeyLen < 112)) {
+            if (minKeyLen < 112) {
                 minKeyLen = 112;
             }
-            if ((maxKeyLen == -1) || (maxKeyLen > 2048)) {
+            if (maxKeyLen > 2048) {
                 maxKeyLen = 2048;
             }
         } else {
@@ -112,24 +112,22 @@
                 keySize = DEF_DSA_KEY_SIZE;
             } else if (algorithm.equals("RSA")) {
                 keySize = DEF_RSA_KEY_SIZE;
+                if (maxKeyLen > 64 * 1024) {
+                    maxKeyLen = 64 * 1024;
+                }
             } else {
                 keySize = DEF_DH_KEY_SIZE;
             }
-            if ((minKeyLen == -1) || (minKeyLen < 512)) {
+            if (minKeyLen < 512) {
                 minKeyLen = 512;
             }
-            if (algorithm.equals("RSA")) {
-                if ((maxKeyLen == -1) || (maxKeyLen > 64 * 1024)) {
-                    maxKeyLen = 64 * 1024;
-                }
-            }
         }
 
         // auto-adjust default keysize in case it's out-of-range
-        if ((minKeyLen != -1) && (keySize < minKeyLen)) {
+        if (keySize < minKeyLen) {
             keySize = minKeyLen;
         }
-        if ((maxKeyLen != -1) && (keySize > maxKeyLen)) {
+        if (keySize > maxKeyLen) {
             keySize = maxKeyLen;
         }
         this.token = token;
@@ -233,13 +231,17 @@
 
     private void checkKeySize(int keySize, AlgorithmParameterSpec params)
         throws InvalidAlgorithmParameterException {
+        if (keySize <= 0) {
+            throw new InvalidAlgorithmParameterException
+                    ("key size must be positive, got " + keySize);
+        }
         // check native range first
-        if ((minKeySize != -1) && (keySize < minKeySize)) {
+        if (keySize < minKeySize) {
             throw new InvalidAlgorithmParameterException(algorithm +
                 " key must be at least " + minKeySize + " bits. " +
                 "The specific key size " + keySize + " is not supported");
         }
-        if ((maxKeySize != -1) && (keySize > maxKeySize)) {
+        if (keySize > maxKeySize) {
             throw new InvalidAlgorithmParameterException(algorithm +
                 " key must be at most " + maxKeySize + " bits. " +
                 "The specific key size " + keySize + " is not supported");
@@ -272,12 +274,8 @@
                         ((RSAKeyGenParameterSpec)params).getPublicExponent();
                 }
                 try {
-                    // Reuse the checking in SunRsaSign provider.
-                    // If maxKeySize is -1, then replace it with
-                    // Integer.MAX_VALUE to indicate no limit.
                     RSAKeyFactory.checkKeyLengths(keySize, tmpExponent,
-                        minKeySize,
-                        (maxKeySize==-1? Integer.MAX_VALUE:maxKeySize));
+                        minKeySize, maxKeySize);
                 } catch (InvalidKeyException e) {
                     throw new InvalidAlgorithmParameterException(e);
                 }
--- a/src/jdk.crypto.cryptoki/share/classes/sun/security/pkcs11/P11Signature.java	Wed Feb 27 20:04:03 2019 -0500
+++ b/src/jdk.crypto.cryptoki/share/classes/sun/security/pkcs11/P11Signature.java	Wed Feb 27 20:45:51 2019 -0500
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2003, 2018, 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
@@ -394,8 +394,9 @@
             // skip the check if no native info available
             return;
         }
-        int minKeySize = (int) mechInfo.ulMinKeySize;
-        int maxKeySize = (int) mechInfo.ulMaxKeySize;
+        int minKeySize = mechInfo.iMinKeySize;
+        int maxKeySize = mechInfo.iMaxKeySize;
+
         // need to override the MAX keysize for SHA1withDSA
         if (md != null && mechanism == CKM_DSA && maxKeySize > 1024) {
                maxKeySize = 1024;
@@ -419,11 +420,11 @@
                     " key must be the right type", cce);
             }
         }
-        if ((minKeySize != -1) && (keySize < minKeySize)) {
+        if (keySize < minKeySize) {
             throw new InvalidKeyException(keyAlgo +
                 " key must be at least " + minKeySize + " bits");
         }
-        if ((maxKeySize != -1) && (keySize > maxKeySize)) {
+        if (keySize > maxKeySize) {
             throw new InvalidKeyException(keyAlgo +
                 " key must be at most " + maxKeySize + " bits");
         }
--- a/src/jdk.crypto.cryptoki/share/classes/sun/security/pkcs11/wrapper/CK_MECHANISM_INFO.java	Wed Feb 27 20:04:03 2019 -0500
+++ b/src/jdk.crypto.cryptoki/share/classes/sun/security/pkcs11/wrapper/CK_MECHANISM_INFO.java	Wed Feb 27 20:45:51 2019 -0500
@@ -1,3 +1,27 @@
+/*
+ * 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.  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.
+ */
 /*
  * reserved comment block
  * DO NOT REMOVE OR ALTER!
@@ -47,7 +71,7 @@
 
 package sun.security.pkcs11.wrapper;
 
-
+import java.security.ProviderException;
 
 /**
  * class CK_MECHANISM_INFO provides information about a particular mechanism.
@@ -74,6 +98,10 @@
      */
     public long ulMinKeySize;
 
+    // the integer version of ulMinKeySize for doing the actual range
+    // check in SunPKCS11 provider, defaults to 0
+    public final int iMinKeySize;
+
     /**
      * <B>PKCS#11:</B>
      * <PRE>
@@ -82,6 +110,10 @@
      */
     public long ulMaxKeySize;
 
+    // the integer version of ulMaxKeySize for doing the actual range
+    // check in SunPKCS11 provider, defaults to Integer.MAX_VALUE
+    public final int iMaxKeySize;
+
     /**
      * <B>PKCS#11:</B>
      * <PRE>
@@ -94,6 +126,10 @@
                              long flags) {
         this.ulMinKeySize = minKeySize;
         this.ulMaxKeySize = maxKeySize;
+        this.iMinKeySize = ((minKeySize < Integer.MAX_VALUE && minKeySize > 0)?
+                (int)minKeySize : 0);
+        this.iMaxKeySize = ((maxKeySize < Integer.MAX_VALUE && maxKeySize > 0)?
+                (int)maxKeySize : Integer.MAX_VALUE);
         this.flags = flags;
     }
 
--- a/test/jdk/ProblemList.txt	Wed Feb 27 20:04:03 2019 -0500
+++ b/test/jdk/ProblemList.txt	Wed Feb 27 20:45:51 2019 -0500
@@ -556,6 +556,8 @@
 
 java/net/MulticastSocket/Test.java                              7145658 macosx-all
 
+java/net/MulticastSocket/SetGetNetworkInterfaceTest.java        8219083 windows-all
+
 java/net/DatagramSocket/SendDatagramToBadAddress.java           7143960 macosx-all
 
 java/net/ServerSocket/AcceptInheritHandle.java                  8211854 aix-ppc64
--- a/test/jdk/com/sun/jdi/OptionTest.java	Wed Feb 27 20:04:03 2019 -0500
+++ b/test/jdk/com/sun/jdi/OptionTest.java	Wed Feb 27 20:45:51 2019 -0500
@@ -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	Wed Feb 27 20:04:03 2019 -0500
+++ b/test/jdk/com/sun/jdi/RunToExit.java	Wed Feb 27 20:45:51 2019 -0500
@@ -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/awt/print/RemotePrinterStatusRefresh/RemotePrinterStatusRefresh.java	Wed Feb 27 20:04:03 2019 -0500
+++ b/test/jdk/java/awt/print/RemotePrinterStatusRefresh/RemotePrinterStatusRefresh.java	Wed Feb 27 20:45:51 2019 -0500
@@ -23,7 +23,7 @@
 
 /**
  * @test
- * @bug 8153732
+ * @bug 8153732 8212202
  * @requires (os.family == "Windows")
  * @summary Windows remote printer changes do not reflect in lookupPrintServices()
  * @ignore Requires a new network printer installation\removal
--- a/test/jdk/java/util/spi/ToolProviderTest.java	Wed Feb 27 20:04:03 2019 -0500
+++ b/test/jdk/java/util/spi/ToolProviderTest.java	Wed Feb 27 20:45:51 2019 -0500
@@ -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"));
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/test/jdk/javax/swing/JEditorPane/TestBrowserBGColor.java	Wed Feb 27 20:45:51 2019 -0500
@@ -0,0 +1,116 @@
+/*
+ * 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
+ * @key headful
+ * @bug 8213781
+ * @summary Verify webpage background color renders correctly in JEditorPane
+ */
+
+import java.awt.Toolkit;
+import java.awt.event.WindowAdapter;
+import java.awt.event.WindowEvent;
+import java.io.IOException;
+import java.net.MalformedURLException;
+import javax.swing.JDialog;
+import javax.swing.JEditorPane;
+import javax.swing.JFrame;
+import javax.swing.JScrollPane;
+import javax.swing.SwingUtilities;
+import javax.swing.event.HyperlinkEvent;
+import javax.swing.event.HyperlinkListener;
+import javax.swing.text.html.HTMLFrameHyperlinkEvent;
+import javax.swing.text.html.HTMLDocument;
+import java.awt.Color;
+import java.awt.Insets;
+import java.awt.Point;
+import java.awt.Robot;
+
+public class TestBrowserBGColor extends JFrame implements HyperlinkListener {
+
+    private static TestBrowserBGColor b;
+    private static JEditorPane browser;
+
+    public static void main(final String[] args) throws Exception {
+        Robot r = new Robot();
+        SwingUtilities.invokeAndWait(() -> {
+            try {
+                b = new TestBrowserBGColor();
+            } catch (Exception e) {
+                throw new RuntimeException(e);
+            }
+            b.setSize(Toolkit.getDefaultToolkit().getScreenSize());
+            b.setVisible(true);
+            b.setDefaultCloseOperation(JFrame.DO_NOTHING_ON_CLOSE);
+            b.addWindowListener(new WindowAdapter() {
+                public void windowClosing(WindowEvent e) {
+                    b.dispose();
+                    b = null;
+                }
+            });
+        });
+
+        r.waitForIdle();
+        r.delay(500);
+
+        SwingUtilities.invokeAndWait(() -> {
+            Insets insets = browser.getInsets();
+            Point loc = browser.getLocationOnScreen();
+            Color c = r.getPixelColor( loc.x + insets.left+100,
+                                  loc.y + insets.top + 100);
+            b.dispose();
+            if (!c.equals(Color.WHITE)) {
+                throw new RuntimeException("webpage background color wrong");
+            }
+        });
+    }
+
+
+    String htmlDoc = " <!DOCTYPE html> <html><style> body { background: #FFF; } </style> <head> <title>Title</title> </head> <body> </body> </html>";
+
+    public TestBrowserBGColor() throws IOException, MalformedURLException {
+        browser = new JEditorPane("text/html", htmlDoc);
+        browser.setEditable(false);
+        browser.addHyperlinkListener(this);
+        JScrollPane scroll = new JScrollPane(browser);
+        getContentPane().add(scroll);
+    }
+
+    public void hyperlinkUpdate(final HyperlinkEvent e) {
+        if (e.getEventType() == HyperlinkEvent.EventType.ACTIVATED) {
+            JEditorPane pane = (JEditorPane) e.getSource();
+            if (e instanceof HTMLFrameHyperlinkEvent) {
+                HTMLFrameHyperlinkEvent evt = (HTMLFrameHyperlinkEvent) e;
+                HTMLDocument doc = (HTMLDocument) pane.getDocument();
+                doc.processHTMLFrameHyperlinkEvent(evt);
+            } else {
+                try {
+                    pane.setPage(e.getURL());
+                } catch (Throwable t) {
+                    t.printStackTrace();
+                }
+            }
+        }
+    }
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/test/jdk/javax/swing/text/rtf/RTFReadBGColorTest.java	Wed Feb 27 20:45:51 2019 -0500
@@ -0,0 +1,100 @@
+/*
+ * 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
+ * @key headful
+ * @bug 8219156
+ * @summary Verify RTFEditorKit does not read background color
+ */
+
+import java.awt.Color;
+import java.awt.image.BufferedImage;
+import java.io.InputStream;
+import java.io.OutputStream;
+import java.nio.file.Files;
+import java.nio.file.Paths;
+import java.util.Enumeration;
+
+import javax.swing.JTextPane;
+import javax.swing.SwingUtilities;
+import javax.swing.JFrame;
+import javax.swing.text.MutableAttributeSet;
+import javax.swing.text.StyleConstants;
+import javax.swing.text.SimpleAttributeSet;
+import javax.swing.text.StyledDocument;
+import javax.swing.text.AttributeSet;
+import javax.swing.text.rtf.RTFEditorKit;
+
+public class RTFReadBGColorTest {
+    static JTextPane text;
+    static String BGTEXT = "yellow_background\n";
+
+    public static void main(String[] a) throws Exception {
+        SwingUtilities.invokeAndWait(() -> {
+            JFrame f = new JFrame();
+            f.setBounds(200, 600, 400, 300);
+            f.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
+            text = new JTextPane();
+            text.setEditorKit(new RTFEditorKit());
+
+            MutableAttributeSet attrBackground = new SimpleAttributeSet();
+            StyleConstants.setBackground(attrBackground, Color.YELLOW);
+
+            try {
+                text.getDocument().insertString(0, BGTEXT, attrBackground);
+            } catch (Exception e) {
+                throw new RuntimeException(e);
+            }
+            write();
+            read();
+
+            f.getContentPane().add(text);
+            f.setVisible(true);
+            text.setCaretPosition(BGTEXT.length()+6);
+            StyledDocument style = text.getStyledDocument();
+            AttributeSet oldSet = style.getCharacterElement(BGTEXT.length()+6).getAttributes();
+            f.dispose();
+            if (!style.getBackground(oldSet).equals(Color.YELLOW)) {
+                throw new RuntimeException("RTFEditorKit does not read background color");
+            }
+        });
+    }
+
+    static void write() {
+        try (OutputStream o = Files.newOutputStream(Paths.get("test.rtf"))) {
+            text.getEditorKit().write(o, text.getDocument(), 0, 0);
+        } catch (Exception e2) {
+            throw new RuntimeException(e2);
+        }
+    }
+
+    static void read() {
+        try (InputStream in = Files.newInputStream(Paths.get("test.rtf"))) {
+            text.getEditorKit().read(in, text.getDocument(), 0);
+        } catch (Exception e2) {
+            throw new RuntimeException(e2);
+        }
+    }
+}
+