Merge
authorprr
Wed, 08 Nov 2017 12:27:40 -0800
changeset 47719 3d660bb6b67d
parent 47718 080c3ab73c8d (current diff)
parent 47715 5645dc537135 (diff)
child 47720 79efc2c3d832
Merge
src/jdk.scripting.nashorn/share/classes/jdk/nashorn/internal/runtime/PropertyListeners.java
--- a/make/common/MakeBase.gmk	Tue Nov 07 14:36:52 2017 -0800
+++ b/make/common/MakeBase.gmk	Wed Nov 08 12:27:40 2017 -0800
@@ -529,7 +529,7 @@
 	$(call MakeDir, $(@D))
 	$(RM) '$(call DecodeSpace, $@)'
 	$(CP) -fRP '$(call DecodeSpace, $<)' '$(call DecodeSpace, $@)'
-	if [ -n "`$(XATTR) -l '$(call DecodeSpace, $@)'`" ]; then $(XATTR) -c '$(call DecodeSpace, $@)'; fi
+	if [ -n "`$(XATTR) -ls '$(call DecodeSpace, $@)'`" ]; then $(XATTR) -cs '$(call DecodeSpace, $@)'; fi
   endef
 else
   define install-file
--- a/make/mapfiles/libjava/mapfile-vers	Tue Nov 07 14:36:52 2017 -0800
+++ b/make/mapfiles/libjava/mapfile-vers	Wed Nov 08 12:27:40 2017 -0800
@@ -130,8 +130,8 @@
 		Java_java_lang_ClassLoader_defineClass2;
 		Java_java_lang_ClassLoader_findBuiltinLib;
 		Java_java_lang_ClassLoader_findLoadedClass0;
-		Java_java_lang_ClassLoader_00024NativeLibrary_find;
-		Java_java_lang_ClassLoader_00024NativeLibrary_load;
+		Java_java_lang_ClassLoader_00024NativeLibrary_findEntry;
+		Java_java_lang_ClassLoader_00024NativeLibrary_load0;
 		Java_java_lang_ClassLoader_00024NativeLibrary_unload;
 		Java_java_lang_ClassLoader_registerNatives;
 		Java_java_lang_Double_longBitsToDouble;
--- a/make/mapfiles/libjava/reorder-sparc	Tue Nov 07 14:36:52 2017 -0800
+++ b/make/mapfiles/libjava/reorder-sparc	Wed Nov 08 12:27:40 2017 -0800
@@ -48,8 +48,8 @@
 text: .text%Java_java_io_FileInputStream_close0;
 text: .text%Java_java_lang_System_mapLibraryName;
 text: .text%Java_java_io_UnixFileSystem_getBooleanAttributes0;
-text: .text%Java_java_lang_ClassLoader_00024NativeLibrary_load;
-text: .text%Java_java_lang_ClassLoader_00024NativeLibrary_find;
+text: .text%Java_java_lang_ClassLoader_00024NativeLibrary_load0;
+text: .text%Java_java_lang_ClassLoader_00024NativeLibrary_findEntry;
 text: .text%Java_java_security_AccessController_doPrivileged__Ljava_security_PrivilegedExceptionAction_2;
 text: .text%Java_java_io_UnixFileSystem_list;
 text: .text%JNU_ClassString;
--- a/make/mapfiles/libjava/reorder-sparcv9	Tue Nov 07 14:36:52 2017 -0800
+++ b/make/mapfiles/libjava/reorder-sparcv9	Wed Nov 08 12:27:40 2017 -0800
@@ -57,8 +57,8 @@
 text: .text%Java_java_io_UnixFileSystem_getBooleanAttributes0;
 text: .text%Java_java_security_AccessController_doPrivileged__Ljava_security_PrivilegedExceptionAction_2Ljava_security_AccessControlContext_2;
 text: .text%Java_java_lang_System_mapLibraryName;
-text: .text%Java_java_lang_ClassLoader_00024NativeLibrary_load;
-text: .text%Java_java_lang_ClassLoader_00024NativeLibrary_find;
+text: .text%Java_java_lang_ClassLoader_00024NativeLibrary_load0;
+text: .text%Java_java_lang_ClassLoader_00024NativeLibrary_findEntry;
 text: .text%Java_java_io_UnixFileSystem_getLength;
 text: .text%Java_java_lang_Object_getClass;
 text: .text%Java_java_lang_ClassLoader_defineClass0;
--- a/make/mapfiles/libjava/reorder-x86	Tue Nov 07 14:36:52 2017 -0800
+++ b/make/mapfiles/libjava/reorder-x86	Wed Nov 08 12:27:40 2017 -0800
@@ -50,8 +50,8 @@
 text: .text%Java_java_security_AccessController_doPrivileged__Ljava_security_PrivilegedExceptionAction_2Ljava_security_AccessControlContext_2;
 text: .text%Java_java_lang_System_mapLibraryName;
 text: .text%cpchars: OUTPUTDIR/System.o;
-text: .text%Java_java_lang_ClassLoader_00024NativeLibrary_load;
-text: .text%Java_java_lang_ClassLoader_00024NativeLibrary_find;
+text: .text%Java_java_lang_ClassLoader_00024NativeLibrary_load0;
+text: .text%Java_java_lang_ClassLoader_00024NativeLibrary_findEntry;
 text: .text%Java_java_lang_Float_floatToRawIntBits;
 text: .text%Java_java_lang_Double_doubleToRawLongBits;
 text: .text%Java_java_io_FileInputStream_open0;
--- a/make/test/JtregNativeJdk.gmk	Tue Nov 07 14:36:52 2017 -0800
+++ b/make/test/JtregNativeJdk.gmk	Wed Nov 08 12:27:40 2017 -0800
@@ -44,6 +44,7 @@
 # Add more directories here when needed.
 BUILD_JDK_JTREG_NATIVE_SRC += \
     $(TOPDIR)/test/jdk/native_sanity \
+    $(TOPDIR)/test/jdk/java/lang/ClassLoader/nativeLibrary \
     $(TOPDIR)/test/jdk/java/lang/String/nativeEncoding \
     #
 
--- a/src/java.base/share/classes/java/lang/ClassLoader.java	Tue Nov 07 14:36:52 2017 -0800
+++ b/src/java.base/share/classes/java/lang/ClassLoader.java	Wed Nov 08 12:27:40 2017 -0800
@@ -37,17 +37,20 @@
 import java.security.PrivilegedAction;
 import java.security.ProtectionDomain;
 import java.security.cert.Certificate;
+import java.util.Arrays;
 import java.util.Collections;
+import java.util.Deque;
 import java.util.Enumeration;
 import java.util.HashMap;
+import java.util.HashSet;
 import java.util.Hashtable;
+import java.util.LinkedList;
 import java.util.Map;
 import java.util.NoSuchElementException;
 import java.util.Objects;
 import java.util.Set;
 import java.util.Spliterator;
 import java.util.Spliterators;
-import java.util.Stack;
 import java.util.Vector;
 import java.util.WeakHashMap;
 import java.util.concurrent.ConcurrentHashMap;
@@ -58,9 +61,9 @@
 import jdk.internal.perf.PerfCounter;
 import jdk.internal.loader.BootLoader;
 import jdk.internal.loader.ClassLoaders;
-import jdk.internal.misc.SharedSecrets;
 import jdk.internal.misc.Unsafe;
 import jdk.internal.misc.VM;
+import jdk.internal.ref.CleanerFactory;
 import jdk.internal.reflect.CallerSensitive;
 import jdk.internal.reflect.Reflection;
 import sun.reflect.misc.ReflectUtil;
@@ -2375,75 +2378,161 @@
      * @since    1.2
      */
     static class NativeLibrary {
+        // the class from which the library is loaded, also indicates
+        // the loader this native library belongs.
+        final Class<?> fromClass;
+        // the canonicalized name of the native library.
+        // or static library name
+        final String name;
+        // Indicates if the native library is linked into the VM
+        final boolean isBuiltin;
+
         // opaque handle to native library, used in native code.
         long handle;
         // the version of JNI environment the native library requires.
-        private int jniVersion;
-        // the class from which the library is loaded, also indicates
-        // the loader this native library belongs.
-        private Class<?> fromClass;
-        // the canonicalized name of the native library.
-        // or static library name
-        String name;
-        // Indicates if the native library is linked into the VM
-        boolean isBuiltin;
-        // Indicates if the native library is loaded
-        boolean loaded;
-        native void load(String name, boolean isBuiltin);
+        int jniVersion;
+
+        native boolean load0(String name, boolean isBuiltin);
 
-        native long find(String name);
-        native void unload(String name, boolean isBuiltin);
+        native long findEntry(String name);
 
-        public NativeLibrary(Class<?> fromClass, String name, boolean isBuiltin) {
+        NativeLibrary(Class<?> fromClass, String name, boolean isBuiltin) {
             this.name = name;
             this.fromClass = fromClass;
             this.isBuiltin = isBuiltin;
         }
 
-        @SuppressWarnings("deprecation")
-        protected void finalize() {
-            synchronized (loadedLibraryNames) {
-                if (fromClass.getClassLoader() != null && loaded) {
-                    this.fromClass = null;   // no context when unloaded
+        /*
+         * Loads the native library and registers for cleanup when its
+         * associated class loader is unloaded
+         */
+        boolean load() {
+            if (handle != 0) {
+                throw new InternalError("Native library " + name + " has been loaded");
+            }
+
+            if (!load0(name, isBuiltin)) return false;
+
+            // register the class loader for cleanup when unloaded
+            // built class loaders are never unloaded
+            ClassLoader loader = fromClass.getClassLoader();
+            if (loader != null &&
+                loader != getBuiltinPlatformClassLoader() &&
+                loader != getBuiltinAppClassLoader()) {
+                CleanerFactory.cleaner().register(loader,
+                        new Unloader(name, handle, isBuiltin));
+            }
+            return true;
+        }
+
+        static boolean loadLibrary(Class<?> fromClass, String name, boolean isBuiltin) {
+            ClassLoader loader =
+                fromClass == null ? null : fromClass.getClassLoader();
 
-                    /* remove the native library name */
-                    int size = loadedLibraryNames.size();
-                    for (int i = 0; i < size; i++) {
-                        if (name.equals(loadedLibraryNames.elementAt(i))) {
-                            loadedLibraryNames.removeElementAt(i);
-                            break;
+            synchronized (loadedLibraryNames) {
+                Map<String, NativeLibrary> libs =
+                    loader != null ? loader.nativeLibraries() : systemNativeLibraries();
+                if (libs.containsKey(name)) {
+                    return true;
+                }
+
+                if (loadedLibraryNames.contains(name)) {
+                    throw new UnsatisfiedLinkError("Native Library " + name +
+                        " already loaded in another classloader");
+                }
+
+                /*
+                 * When a library is being loaded, JNI_OnLoad function can cause
+                 * another loadLibrary invocation that should succeed.
+                 *
+                 * We use a static stack to hold the list of libraries we are
+                 * loading because this can happen only when called by the
+                 * same thread because Runtime.load and Runtime.loadLibrary
+                 * are synchronous.
+                 *
+                 * If there is a pending load operation for the library, we
+                 * immediately return success; otherwise, we raise
+                 * UnsatisfiedLinkError.
+                 */
+                for (NativeLibrary lib : nativeLibraryContext) {
+                    if (name.equals(lib.name)) {
+                        if (loader == lib.fromClass.getClassLoader()) {
+                            return true;
+                        } else {
+                            throw new UnsatisfiedLinkError("Native Library " +
+                                name + " is being loaded in another classloader");
                         }
                     }
-                    /* unload the library. */
-                    ClassLoader.nativeLibraryContext.push(this);
+                }
+                NativeLibrary lib = new NativeLibrary(fromClass, name, isBuiltin);
+                // load the native library
+                nativeLibraryContext.push(lib);
+                try {
+                    if (!lib.load()) return false;
+                } finally {
+                    nativeLibraryContext.pop();
+                }
+                // register the loaded native library
+                loadedLibraryNames.add(name);
+                libs.put(name, lib);
+            }
+            return true;
+        }
+
+        // Invoked in the VM to determine the context class in JNI_OnLoad
+        // and JNI_OnUnload
+        static Class<?> getFromClass() {
+            return nativeLibraryContext.peek().fromClass;
+        }
+
+        // native libraries being loaded
+        static Deque<NativeLibrary> nativeLibraryContext = new LinkedList<>();
+
+        /*
+         * The run() method will be invoked when this class loader becomes
+         * phantom reachable to unload the native library.
+         */
+        static class Unloader implements Runnable {
+            // This represents the context when a native library is unloaded
+            // and getFromClass() will return null,
+            static final NativeLibrary UNLOADER =
+                new NativeLibrary(null, "dummy", false);
+            final String name;
+            final long handle;
+            final boolean isBuiltin;
+
+            Unloader(String name, long handle, boolean isBuiltin) {
+                if (handle == 0) {
+                    throw new IllegalArgumentException(
+                        "Invalid handle for native library " + name);
+                }
+
+                this.name = name;
+                this.handle = handle;
+                this.isBuiltin = isBuiltin;
+            }
+
+            @Override
+            public void run() {
+                synchronized (loadedLibraryNames) {
+                    /* remove the native library name */
+                    loadedLibraryNames.remove(name);
+                    nativeLibraryContext.push(UNLOADER);
                     try {
-                        unload(name, isBuiltin);
+                        unload(name, isBuiltin, handle);
                     } finally {
-                        ClassLoader.nativeLibraryContext.pop();
+                        nativeLibraryContext.pop();
                     }
+
                 }
             }
         }
-        // Invoked in the VM to determine the context class in
-        // JNI_Load/JNI_Unload
-        static Class<?> getFromClass() {
-            return ClassLoader.nativeLibraryContext.peek().fromClass;
-        }
+
+        // JNI FindClass expects the caller class if invoked from JNI_OnLoad
+        // and JNI_OnUnload is NativeLibrary class
+        static native void unload(String name, boolean isBuiltin, long handle);
     }
 
-    // All native library names we've loaded.
-    private static Vector<String> loadedLibraryNames = new Vector<>();
-
-    // Native libraries belonging to system classes.
-    private static Vector<NativeLibrary> systemNativeLibraries
-        = new Vector<>();
-
-    // Native libraries associated with the class loader.
-    private Vector<NativeLibrary> nativeLibraries = new Vector<>();
-
-    // native libraries being loaded/unloaded.
-    private static Stack<NativeLibrary> nativeLibraryContext = new Stack<>();
-
     // The paths searched for libraries
     private static String usr_paths[];
     private static String sys_paths[];
@@ -2455,7 +2544,7 @@
         int psCount = 0;
 
         if (ClassLoaderHelper.allowsQuotedPathElements &&
-                ldPath.indexOf('\"') >= 0) {
+            ldPath.indexOf('\"') >= 0) {
             // First, remove quotes put around quoted parts of paths.
             // Second, use a quotation mark as a new path separator.
             // This will preserve any quoted old path separators.
@@ -2465,7 +2554,7 @@
                 char ch = ldPath.charAt(i);
                 if (ch == '\"') {
                     while (++i < ldLen &&
-                            (ch = ldPath.charAt(i)) != '\"') {
+                        (ch = ldPath.charAt(i)) != '\"') {
                         buf[bufLen++] = ch;
                     }
                 } else {
@@ -2481,7 +2570,7 @@
             ps = '\"';
         } else {
             for (int i = ldPath.indexOf(ps); i >= 0;
-                    i = ldPath.indexOf(ps, i + 1)) {
+                 i = ldPath.indexOf(ps, i + 1)) {
                 psCount++;
             }
         }
@@ -2491,11 +2580,11 @@
         for (int j = 0; j < psCount; ++j) {
             int pathEnd = ldPath.indexOf(ps, pathStart);
             paths[j] = (pathStart < pathEnd) ?
-                    ldPath.substring(pathStart, pathEnd) : ".";
+                ldPath.substring(pathStart, pathEnd) : ".";
             pathStart = pathEnd + 1;
         }
         paths[psCount] = (pathStart < ldLen) ?
-                ldPath.substring(pathStart, ldLen) : ".";
+            ldPath.substring(pathStart, ldLen) : ".";
         return paths;
     }
 
@@ -2520,7 +2609,7 @@
                 File libfile = new File(libfilename);
                 if (!libfile.isAbsolute()) {
                     throw new UnsatisfiedLinkError(
-    "ClassLoader.findLibrary failed to return an absolute path: " + libfilename);
+                        "ClassLoader.findLibrary failed to return an absolute path: " + libfilename);
                 }
                 if (loadLibrary0(fromClass, libfile)) {
                     return;
@@ -2551,10 +2640,11 @@
             }
         }
         // Oops, it failed
-        throw new UnsatisfiedLinkError("no " + name + " in java.library.path");
+        throw new UnsatisfiedLinkError("no " + name +
+            " in java.library.path: " + Arrays.toString(usr_paths));
     }
 
-    static native String findBuiltinLib(String name);
+    private static native String findBuiltinLib(String name);
 
     private static boolean loadLibrary0(Class<?> fromClass, final File file) {
         // Check to see if we're attempting to access a static library
@@ -2575,85 +2665,72 @@
                 return false;
             }
         }
-        ClassLoader loader =
-            (fromClass == null) ? null : fromClass.getClassLoader();
-        Vector<NativeLibrary> libs =
-            loader != null ? loader.nativeLibraries : systemNativeLibraries;
-        synchronized (libs) {
-            int size = libs.size();
-            for (int i = 0; i < size; i++) {
-                NativeLibrary lib = libs.elementAt(i);
-                if (name.equals(lib.name)) {
-                    return true;
-                }
-            }
-
-            synchronized (loadedLibraryNames) {
-                if (loadedLibraryNames.contains(name)) {
-                    throw new UnsatisfiedLinkError
-                        ("Native Library " +
-                         name +
-                         " already loaded in another classloader");
-                }
-                /* If the library is being loaded (must be by the same thread,
-                 * because Runtime.load and Runtime.loadLibrary are
-                 * synchronous). The reason is can occur is that the JNI_OnLoad
-                 * function can cause another loadLibrary invocation.
-                 *
-                 * Thus we can use a static stack to hold the list of libraries
-                 * we are loading.
-                 *
-                 * If there is a pending load operation for the library, we
-                 * immediately return success; otherwise, we raise
-                 * UnsatisfiedLinkError.
-                 */
-                int n = nativeLibraryContext.size();
-                for (int i = 0; i < n; i++) {
-                    NativeLibrary lib = nativeLibraryContext.elementAt(i);
-                    if (name.equals(lib.name)) {
-                        if (loader == lib.fromClass.getClassLoader()) {
-                            return true;
-                        } else {
-                            throw new UnsatisfiedLinkError
-                                ("Native Library " +
-                                 name +
-                                 " is being loaded in another classloader");
-                        }
-                    }
-                }
-                NativeLibrary lib = new NativeLibrary(fromClass, name, isBuiltin);
-                nativeLibraryContext.push(lib);
-                try {
-                    lib.load(name, isBuiltin);
-                } finally {
-                    nativeLibraryContext.pop();
-                }
-                if (lib.loaded) {
-                    loadedLibraryNames.addElement(name);
-                    libs.addElement(lib);
-                    return true;
-                }
-                return false;
-            }
-        }
+        return NativeLibrary.loadLibrary(fromClass, name, isBuiltin);
     }
 
-    // Invoked in the VM class linking code.
-    static long findNative(ClassLoader loader, String name) {
-        Vector<NativeLibrary> libs =
-            loader != null ? loader.nativeLibraries : systemNativeLibraries;
-        synchronized (libs) {
-            int size = libs.size();
-            for (int i = 0; i < size; i++) {
-                NativeLibrary lib = libs.elementAt(i);
-                long entry = lib.find(name);
-                if (entry != 0)
-                    return entry;
-            }
+    /*
+     * Invoked in the VM class linking code.
+     */
+    private static long findNative(ClassLoader loader, String entryName) {
+        Map<String, NativeLibrary> libs =
+            loader != null ? loader.nativeLibraries() : systemNativeLibraries();
+        if (libs.isEmpty())
+            return 0;
+
+        // the native libraries map may be updated in another thread
+        // when a native library is being loaded.  No symbol will be
+        // searched from it yet.
+        for (NativeLibrary lib : libs.values()) {
+            long entry = lib.findEntry(entryName);
+            if (entry != 0) return entry;
         }
         return 0;
     }
 
+    // All native library names we've loaded.
+    // This also serves as the lock to obtain nativeLibraries
+    // and write to nativeLibraryContext.
+    private static final Set<String> loadedLibraryNames = new HashSet<>();
+
+    // Native libraries belonging to system classes.
+    private static volatile Map<String, NativeLibrary> systemNativeLibraries;
+
+    // Native libraries associated with the class loader.
+    private volatile Map<String, NativeLibrary> nativeLibraries;
+
+    /*
+     * Returns the native libraries map associated with bootstrap class loader
+     * This method will create the map at the first time when called.
+     */
+    private static Map<String, NativeLibrary> systemNativeLibraries() {
+        Map<String, NativeLibrary> libs = systemNativeLibraries;
+        if (libs == null) {
+            synchronized (loadedLibraryNames) {
+                libs = systemNativeLibraries;
+                if (libs == null) {
+                    libs = systemNativeLibraries = new ConcurrentHashMap<>();
+                }
+            }
+        }
+        return libs;
+    }
+
+    /*
+     * Returns the native libraries map associated with this class loader
+     * This method will create the map at the first time when called.
+     */
+    private Map<String, NativeLibrary> nativeLibraries() {
+        Map<String, NativeLibrary> libs = nativeLibraries;
+        if (libs == null) {
+            synchronized (loadedLibraryNames) {
+                libs = nativeLibraries;
+                if (libs == null) {
+                    libs = nativeLibraries = new ConcurrentHashMap<>();
+                }
+            }
+        }
+        return libs;
+    }
 
     // -- Assertion management --
 
--- a/src/java.base/share/classes/java/lang/Runtime.java	Tue Nov 07 14:36:52 2017 -0800
+++ b/src/java.base/share/classes/java/lang/Runtime.java	Wed Nov 08 12:27:40 2017 -0800
@@ -765,7 +765,9 @@
      * with the VM, then the JNI_OnLoad_L function exported by the library
      * is invoked rather than attempting to load a dynamic library.
      * A filename matching the argument does not have to exist in the file
-     * system. See the JNI Specification for more details.
+     * system.
+     * See the <a href="{@docRoot}/../specs/jni/index.html"> JNI Specification</a>
+     * for more details.
      *
      * Otherwise, the filename argument is mapped to a native library image in
      * an implementation-dependent manner.
@@ -818,7 +820,8 @@
      * specific prefix, file extension or path. If a native library
      * called {@code libname} is statically linked with the VM, then the
      * JNI_OnLoad_{@code libname} function exported by the library is invoked.
-     * See the JNI Specification for more details.
+     * See the <a href="{@docRoot}/../specs/jni/index.html"> JNI Specification</a>
+     * for more details.
      *
      * Otherwise, the libname argument is loaded from a system library
      * location and mapped to a native library image in an implementation-
--- a/src/java.base/share/classes/java/lang/System.java	Tue Nov 07 14:36:52 2017 -0800
+++ b/src/java.base/share/classes/java/lang/System.java	Wed Nov 08 12:27:40 2017 -0800
@@ -1799,7 +1799,8 @@
      * is invoked rather than attempting to load a dynamic library.
      * A filename matching the argument does not have to exist in the
      * file system.
-     * See the JNI Specification for more details.
+     * See the <a href="{@docRoot}/../specs/jni/index.html"> JNI Specification</a>
+     * for more details.
      *
      * Otherwise, the filename argument is mapped to a native library image in
      * an implementation-dependent manner.
@@ -1835,7 +1836,8 @@
      * specific prefix, file extension or path. If a native library
      * called <code>libname</code> is statically linked with the VM, then the
      * JNI_OnLoad_<code>libname</code> function exported by the library is invoked.
-     * See the JNI Specification for more details.
+     * See the <a href="{@docRoot}/../specs/jni/index.html"> JNI Specification</a>
+     * for more details.
      *
      * Otherwise, the libname argument is loaded from a system library
      * location and mapped to a native library image in an implementation-
--- a/src/java.base/share/classes/jdk/internal/misc/InnocuousThread.java	Tue Nov 07 14:36:52 2017 -0800
+++ b/src/java.base/share/classes/jdk/internal/misc/InnocuousThread.java	Wed Nov 08 12:27:40 2017 -0800
@@ -62,10 +62,16 @@
      * set to the system class loader.
      */
     public static Thread newThread(String name, Runnable target) {
-        return new InnocuousThread(INNOCUOUSTHREADGROUP,
-                                   target,
-                                   name,
-                                   ClassLoader.getSystemClassLoader());
+        return AccessController.doPrivileged(
+                new PrivilegedAction<Thread>() {
+                    @Override
+                    public Thread run() {
+                        return new InnocuousThread(INNOCUOUSTHREADGROUP,
+                                                   target,
+                                                   name,
+                                                   ClassLoader.getSystemClassLoader());
+                    }
+                });
     }
 
     /**
@@ -80,8 +86,14 @@
      * Returns a new InnocuousThread with null context class loader.
      */
     public static Thread newSystemThread(String name, Runnable target) {
-        return new InnocuousThread(INNOCUOUSTHREADGROUP,
-                                   target, name, null);
+        return AccessController.doPrivileged(
+                new PrivilegedAction<Thread>() {
+                    @Override
+                    public Thread run() {
+                        return new InnocuousThread(INNOCUOUSTHREADGROUP,
+                                                   target, name, null);
+                    }
+                });
     }
 
     private InnocuousThread(ThreadGroup group, Runnable target, String name, ClassLoader tccl) {
--- a/src/java.base/share/native/libjava/ClassLoader.c	Tue Nov 07 14:36:52 2017 -0800
+++ b/src/java.base/share/native/libjava/ClassLoader.c	Wed Nov 08 12:27:40 2017 -0800
@@ -260,7 +260,6 @@
 
 static jfieldID handleID;
 static jfieldID jniVersionID;
-static jfieldID loadedID;
 static void *procHandle;
 
 static jboolean initIDs(JNIEnv *env)
@@ -276,9 +275,6 @@
         jniVersionID = (*env)->GetFieldID(env, this, "jniVersion", "I");
         if (jniVersionID == 0)
             return JNI_FALSE;
-        loadedID = (*env)->GetFieldID(env, this, "loaded", "Z");
-        if (loadedID == 0)
-             return JNI_FALSE;
         procHandle = getProcessHandle();
     }
     return JNI_TRUE;
@@ -335,30 +331,31 @@
 
 /*
  * Class:     java_lang_ClassLoader_NativeLibrary
- * Method:    load
- * Signature: (Ljava/lang/String;Z)V
+ * Method:    load0
+ * Signature: (Ljava/lang/String;Z)Z
  */
-JNIEXPORT void JNICALL
-Java_java_lang_ClassLoader_00024NativeLibrary_load
+JNIEXPORT jboolean JNICALL
+Java_java_lang_ClassLoader_00024NativeLibrary_load0
   (JNIEnv *env, jobject this, jstring name, jboolean isBuiltin)
 {
     const char *cname;
     jint jniVersion;
     jthrowable cause;
     void * handle;
+    jboolean loaded = JNI_FALSE;
 
     if (!initIDs(env))
-        return;
+        return JNI_FALSE;
 
     cname = JNU_GetStringPlatformChars(env, name, 0);
     if (cname == 0)
-        return;
+        return JNI_FALSE;
     handle = isBuiltin ? procHandle : JVM_LoadLibrary(cname);
     if (handle) {
         JNI_OnLoad_t JNI_OnLoad;
         JNI_OnLoad = (JNI_OnLoad_t)findJniFunction(env, handle,
-                                               isBuiltin ? cname : NULL,
-                                               JNI_TRUE);
+                                                   isBuiltin ? cname : NULL,
+                                                   JNI_TRUE);
         if (JNI_OnLoad) {
             JavaVM *jvm;
             (*env)->GetJavaVM(env, &jvm);
@@ -400,20 +397,21 @@
         goto done;
     }
     (*env)->SetLongField(env, this, handleID, ptr_to_jlong(handle));
-    (*env)->SetBooleanField(env, this, loadedID, JNI_TRUE);
+    loaded = JNI_TRUE;
 
  done:
     JNU_ReleaseStringPlatformChars(env, name, cname);
+    return loaded;
 }
 
 /*
  * Class:     java_lang_ClassLoader_NativeLibrary
  * Method:    unload
- * Signature: (Z)V
+ * Signature: (Ljava/lang/String;ZJ)V
  */
 JNIEXPORT void JNICALL
 Java_java_lang_ClassLoader_00024NativeLibrary_unload
-(JNIEnv *env, jobject this, jstring name, jboolean isBuiltin)
+(JNIEnv *env, jclass cls, jstring name, jboolean isBuiltin, jlong address)
 {
     const char *onUnloadSymbols[] = JNI_ONUNLOAD_SYMBOLS;
     void *handle;
@@ -426,10 +424,10 @@
     if (cname == NULL) {
         return;
     }
-    handle = jlong_to_ptr((*env)->GetLongField(env, this, handleID));
+    handle = jlong_to_ptr(address);
     JNI_OnUnload = (JNI_OnUnload_t )findJniFunction(env, handle,
-                                                isBuiltin ? cname : NULL,
-                                                JNI_FALSE);
+                                                    isBuiltin ? cname : NULL,
+                                                    JNI_FALSE);
     if (JNI_OnUnload) {
         JavaVM *jvm;
         (*env)->GetJavaVM(env, &jvm);
@@ -443,11 +441,11 @@
 
 /*
  * Class:     java_lang_ClassLoader_NativeLibrary
- * Method:    find
+ * Method:    findEntry
  * Signature: (Ljava/lang/String;)J
  */
 JNIEXPORT jlong JNICALL
-Java_java_lang_ClassLoader_00024NativeLibrary_find
+Java_java_lang_ClassLoader_00024NativeLibrary_findEntry
   (JNIEnv *env, jobject this, jstring name)
 {
     jlong handle;
--- a/src/java.xml/share/classes/com/sun/java_cup/internal/runtime/lr_parser.java	Tue Nov 07 14:36:52 2017 -0800
+++ b/src/java.xml/share/classes/com/sun/java_cup/internal/runtime/lr_parser.java	Wed Nov 08 12:27:40 2017 -0800
@@ -946,7 +946,7 @@
           if (debug)
             debug_message("# Pop stack by one, state was # " +
                           (stack.peek()).parse_state);
-          left_pos = ((Symbol)stack.pop()).left;
+          left_pos = stack.pop().left;
           tos--;
 
           /* if we have hit bottom, we fail */
--- a/src/java.xml/share/classes/com/sun/org/apache/xalan/internal/lib/ExsltDatetime.java	Tue Nov 07 14:36:52 2017 -0800
+++ b/src/java.xml/share/classes/com/sun/org/apache/xalan/internal/lib/ExsltDatetime.java	Wed Nov 08 12:27:40 2017 -0800
@@ -1,6 +1,6 @@
 /*
- * reserved comment block
- * DO NOT REMOVE OR ALTER!
+ * Copyright (c) 2017, Oracle and/or its affiliates. All rights reserved.
+ * @LastModified: Nov 2017
  */
 /*
  * Licensed to the Apache Software Foundation (ASF) under one or more
@@ -616,7 +616,7 @@
     public static boolean leapYear()
     {
       Calendar cal = Calendar.getInstance();
-      int yr = (int)cal.get(Calendar.YEAR);
+      int yr = cal.get(Calendar.YEAR);
       return (yr % 400 == 0 || (yr % 100 != 0 && yr % 4 == 0));
     }
 
--- a/src/java.xml/share/classes/com/sun/org/apache/xalan/internal/xsltc/compiler/AttributeSet.java	Tue Nov 07 14:36:52 2017 -0800
+++ b/src/java.xml/share/classes/com/sun/org/apache/xalan/internal/xsltc/compiler/AttributeSet.java	Wed Nov 08 12:27:40 2017 -0800
@@ -1,6 +1,6 @@
 /*
  * Copyright (c) 2015, 2017, Oracle and/or its affiliates. All rights reserved.
- * @LastModified: Oct 2017
+ * @LastModified: Nov 2017
  */
 /*
  * Licensed to the Apache Software Foundation (ASF) under one or more
@@ -115,7 +115,7 @@
         final List<SyntaxTreeNode> contents = getContents();
         final int count = contents.size();
         for (int i=0; i<count; i++) {
-            SyntaxTreeNode child = (SyntaxTreeNode)contents.get(i);
+            SyntaxTreeNode child = contents.get(i);
             if (child instanceof XslAttribute) {
                 parser.getSymbolTable().setCurrentNode(child);
                 child.parseContents(parser);
@@ -184,7 +184,7 @@
         // Translate all local attributes
         final Iterator<SyntaxTreeNode> attributes = elements();
         while (attributes.hasNext()) {
-            SyntaxTreeNode element = (SyntaxTreeNode)attributes.next();
+            SyntaxTreeNode element = attributes.next();
             if (element instanceof XslAttribute) {
                 final XslAttribute attribute = (XslAttribute)element;
                 attribute.translate(classGen, methodGen);
--- a/src/java.xml/share/classes/com/sun/org/apache/xalan/internal/xsltc/compiler/BinOpExpr.java	Tue Nov 07 14:36:52 2017 -0800
+++ b/src/java.xml/share/classes/com/sun/org/apache/xalan/internal/xsltc/compiler/BinOpExpr.java	Wed Nov 08 12:27:40 2017 -0800
@@ -1,6 +1,6 @@
 /*
  * Copyright (c) 2017, Oracle and/or its affiliates. All rights reserved.
- * @LastModified: Oct 2017
+ * @LastModified: Nov 2017
  */
 /*
  * Licensed to the Apache Software Foundation (ASF) under one or more
@@ -83,11 +83,11 @@
                                               new MethodType(Type.Void,
                                                              tleft, tright));
         if (ptype != null) {
-            final Type arg1 = (Type) ptype.argsType().get(0);
+            final Type arg1 = ptype.argsType().get(0);
             if (!arg1.identicalTo(tleft)) {
                 _left = new CastExpr(_left, arg1);
             }
-            final Type arg2 = (Type) ptype.argsType().get(1);
+            final Type arg2 = ptype.argsType().get(1);
             if (!arg2.identicalTo(tright)) {
                 _right = new CastExpr(_right, arg1);
             }
--- a/src/java.xml/share/classes/com/sun/org/apache/xalan/internal/xsltc/compiler/FilterExpr.java	Tue Nov 07 14:36:52 2017 -0800
+++ b/src/java.xml/share/classes/com/sun/org/apache/xalan/internal/xsltc/compiler/FilterExpr.java	Wed Nov 08 12:27:40 2017 -0800
@@ -1,6 +1,6 @@
 /*
  * Copyright (c) 2017, Oracle and/or its affiliates. All rights reserved.
- * @LastModified: Oct 2017
+ * @LastModified: Nov 2017
  */
 /*
  * Licensed to the Apache Software Foundation (ASF) under one or more
@@ -75,7 +75,7 @@
         if (_predicates != null) {
             final int n = _predicates.size();
             for (int i = 0; i < n; i++) {
-                final Expression exp = (Expression)_predicates.get(i);
+                final Expression exp = _predicates.get(i);
                 exp.setParser(parser);
                 exp.setParent(this);
             }
--- a/src/java.xml/share/classes/com/sun/org/apache/xalan/internal/xsltc/compiler/FunctionAvailableCall.java	Tue Nov 07 14:36:52 2017 -0800
+++ b/src/java.xml/share/classes/com/sun/org/apache/xalan/internal/xsltc/compiler/FunctionAvailableCall.java	Wed Nov 08 12:27:40 2017 -0800
@@ -1,6 +1,6 @@
 /*
  * Copyright (c) 2017, Oracle and/or its affiliates. All rights reserved.
- * @LastModified: Oct 2017
+ * @LastModified: Nov 2017
  */
 /*
  * Licensed to the Apache Software Foundation (ASF) under one or more
@@ -53,7 +53,7 @@
      */
     public FunctionAvailableCall(QName fname, List<Expression> arguments) {
         super(fname, arguments);
-        _arg = (Expression)arguments.get(0);
+        _arg = arguments.get(0);
         _type = null;
 
         if (_arg instanceof LiteralExpr) {
--- a/src/java.xml/share/classes/com/sun/org/apache/xalan/internal/xsltc/compiler/FunctionCall.java	Tue Nov 07 14:36:52 2017 -0800
+++ b/src/java.xml/share/classes/com/sun/org/apache/xalan/internal/xsltc/compiler/FunctionCall.java	Wed Nov 08 12:27:40 2017 -0800
@@ -1,6 +1,6 @@
 /*
  * Copyright (c) 2015, 2017, Oracle and/or its affiliates. All rights reserved.
- * @LastModified: Oct 2017
+ * @LastModified: Nov 2017
  */
 /*
  * Licensed to the Apache Software Foundation (ASF) under one or more
@@ -443,7 +443,7 @@
 
         if (ptype != null) {
             for (int i = 0; i < n; i++) {
-                final Type argType = (Type) ptype.argsType().get(i);
+                final Type argType = ptype.argsType().get(i);
                 final Expression exp = _arguments.get(i);
                 if (!argType.identicalTo(exp.getType())) {
                     try {
@@ -557,7 +557,7 @@
                     hasThisArgument = true;
 
                 Expression firstArg = _arguments.get(0);
-                Type firstArgType = (Type)firstArg.typeCheck(stable);
+                Type firstArgType = firstArg.typeCheck(stable);
 
                 if (_namespace_format == NAMESPACE_FORMAT_CLASS
                     && firstArgType instanceof ObjectType
@@ -608,7 +608,7 @@
         _type = null;                       // reset internal type
         for (int j, i = 0; i < nMethods; i++) {
             // Check if all paramteters to this method can be converted
-            final Method method = (Method)methods.get(i);
+            final Method method = methods.get(i);
             final Class<?>[] paramTypes = method.getParameterTypes();
 
             int currMethodDistance = 0;
--- a/src/java.xml/share/classes/com/sun/org/apache/xalan/internal/xsltc/compiler/LogicalExpr.java	Tue Nov 07 14:36:52 2017 -0800
+++ b/src/java.xml/share/classes/com/sun/org/apache/xalan/internal/xsltc/compiler/LogicalExpr.java	Wed Nov 08 12:27:40 2017 -0800
@@ -1,6 +1,6 @@
 /*
  * Copyright (c) 2017, Oracle and/or its affiliates. All rights reserved.
- * @LastModified: Oct 2017
+ * @LastModified: Nov 2017
  */
 /*
  * Licensed to the Apache Software Foundation (ASF) under one or more
@@ -137,11 +137,11 @@
         // Yes, the operation is supported
         if (haveType != null) {
             // Check if left-hand side operand must be type casted
-            Type arg1 = (Type)haveType.argsType().get(0);
+            Type arg1 = haveType.argsType().get(0);
             if (!arg1.identicalTo(tleft))
                 _left = new CastExpr(_left, arg1);
             // Check if right-hand side operand must be type casted
-            Type arg2 = (Type) haveType.argsType().get(1);
+            Type arg2 = haveType.argsType().get(1);
             if (!arg2.identicalTo(tright))
                 _right = new CastExpr(_right, arg1);
             // Return the result type for the operator we will use
--- a/src/java.xml/share/classes/com/sun/org/apache/xalan/internal/xsltc/compiler/Message.java	Tue Nov 07 14:36:52 2017 -0800
+++ b/src/java.xml/share/classes/com/sun/org/apache/xalan/internal/xsltc/compiler/Message.java	Wed Nov 08 12:27:40 2017 -0800
@@ -1,6 +1,6 @@
 /*
  * Copyright (c) 2017, Oracle and/or its affiliates. All rights reserved.
- * @LastModified: Oct 2017
+ * @LastModified: Nov 2017
  */
 /*
  * Licensed to the Apache Software Foundation (ASF) under one or more
@@ -67,7 +67,7 @@
                 il.append(new PUSH(cpg, ""));
             break;
             case 1:
-                SyntaxTreeNode child = (SyntaxTreeNode) elementAt(0);
+                SyntaxTreeNode child = elementAt(0);
                 if (child instanceof Text) {
                     il.append(new PUSH(cpg, ((Text) child).getText()));
                     break;
--- a/src/java.xml/share/classes/com/sun/org/apache/xalan/internal/xsltc/compiler/Mode.java	Tue Nov 07 14:36:52 2017 -0800
+++ b/src/java.xml/share/classes/com/sun/org/apache/xalan/internal/xsltc/compiler/Mode.java	Wed Nov 08 12:27:40 2017 -0800
@@ -1,6 +1,6 @@
 /*
  * Copyright (c) 2015, 2017, Oracle and/or its affiliates. All rights reserved.
- * @LastModified: Oct 2017
+ * @LastModified: Nov 2017
  */
 /*
  * Licensed to the Apache Software Foundation (ASF) under one or more
@@ -229,12 +229,12 @@
     }
 
     private int partition(List<Template> templates, int p, int r) {
-        final Template x = (Template)templates.get(p);
+        final Template x = templates.get(p);
         int i = p - 1;
         int j = r + 1;
         while (true) {
-            while (x.compareTo((Template)templates.get(--j)) > 0);
-            while (x.compareTo((Template)templates.get(++i)) < 0);
+            while (x.compareTo(templates.get(--j)) > 0);
+            while (x.compareTo(templates.get(++i)) < 0);
             if (i < j) {
                 templates.set(j, templates.set(i, templates.get(j)));
             }
@@ -366,7 +366,7 @@
             boolean inserted = false;
             for (int i = 0; i < patterns.size(); i++) {
                 final LocationPathPattern lppToCompare =
-                    (LocationPathPattern)patterns.get(i);
+                    patterns.get(i);
 
                 if (pattern.noSmallerThan(lppToCompare)) {
                     inserted = true;
@@ -1136,7 +1136,7 @@
         final boolean[] isAttribute = new boolean[types.length];
         final boolean[] isNamespace = new boolean[types.length];
         for (int i = 0; i < names.size(); i++) {
-            final String name = (String)names.get(i);
+            final String name = names.get(i);
             isAttribute[i+DTM.NTYPES] = isAttributeName(name);
             isNamespace[i+DTM.NTYPES] = isNamespaceName(name);
         }
--- a/src/java.xml/share/classes/com/sun/org/apache/xalan/internal/xsltc/compiler/Number.java	Tue Nov 07 14:36:52 2017 -0800
+++ b/src/java.xml/share/classes/com/sun/org/apache/xalan/internal/xsltc/compiler/Number.java	Wed Nov 08 12:27:40 2017 -0800
@@ -1,6 +1,6 @@
 /*
  * Copyright (c) 2017, Oracle and/or its affiliates. All rights reserved.
- * @LastModified: Oct 2017
+ * @LastModified: Nov 2017
  */
 /*
  * Licensed to the Apache Software Foundation (ASF) under one or more
@@ -481,7 +481,7 @@
 
         // Initialize closure variables
         for (int i = 0; i < closureLen; i++) {
-            final VariableRefBase varRef = (VariableRefBase) _closureVars.get(i);
+            final VariableRefBase varRef = _closureVars.get(i);
             final VariableBase var = varRef.getVariable();
             final Type varType = var.getType();
 
--- a/src/java.xml/share/classes/com/sun/org/apache/xalan/internal/xsltc/compiler/Parser.java	Tue Nov 07 14:36:52 2017 -0800
+++ b/src/java.xml/share/classes/com/sun/org/apache/xalan/internal/xsltc/compiler/Parser.java	Wed Nov 08 12:27:40 2017 -0800
@@ -1,6 +1,6 @@
 /*
  * Copyright (c) 2015, 2017, Oracle and/or its affiliates. All rights reserved.
- * @LastModified: Sep 2017
+ * @LastModified: Nov 2017
  */
 /*
  * Licensed to the Apache Software Foundation (ASF) under one or more
@@ -433,7 +433,7 @@
             reader.setContentHandler(this);
             reader.parse(input);
             // Find the start of the stylesheet within the tree
-            return (SyntaxTreeNode)getStylesheet(_root);
+            return getStylesheet(_root);
         }
         catch (IOException e) {
             if (_xsltc.debug()) e.printStackTrace();
@@ -668,7 +668,7 @@
         else
             source = new InputSource(location);
 
-        SyntaxTreeNode external = (SyntaxTreeNode)parse(source);
+        SyntaxTreeNode external = parse(source);
         return(external);
     }
 
--- a/src/java.xml/share/classes/com/sun/org/apache/xalan/internal/xsltc/compiler/Sort.java	Tue Nov 07 14:36:52 2017 -0800
+++ b/src/java.xml/share/classes/com/sun/org/apache/xalan/internal/xsltc/compiler/Sort.java	Wed Nov 08 12:27:40 2017 -0800
@@ -1,6 +1,6 @@
 /*
  * Copyright (c) 2016, 2017, Oracle and/or its affiliates. All rights reserved.
- * @LastModified: Oct 2017
+ * @LastModified: Nov 2017
  */
 /*
  * Licensed to the Apache Software Foundation (ASF) under one or more
@@ -419,7 +419,7 @@
         final List<VariableRefBase> dups = new ArrayList<>();
 
         for (int j = 0; j < nsorts; j++) {
-            final Sort sort = (Sort) sortObjects.get(j);
+            final Sort sort = sortObjects.get(j);
             final int length = (sort._closureVars == null) ? 0 :
                 sort._closureVars.size();
 
@@ -553,7 +553,7 @@
         // Initialize closure in record class
         final int ndups = dups.size();
         for (int i = 0; i < ndups; i++) {
-            final VariableRefBase varRef = (VariableRefBase) dups.get(i);
+            final VariableRefBase varRef = dups.get(i);
             final VariableBase var = varRef.getVariable();
             final Type varType = var.getType();
 
@@ -617,7 +617,7 @@
             final int length = (sort._closureVars == null) ? 0 :
                 sort._closureVars.size();
             for (int i = 0; i < length; i++) {
-                final VariableRefBase varRef = (VariableRefBase) sort._closureVars.get(i);
+                final VariableRefBase varRef = sort._closureVars.get(i);
 
                 // Discard duplicate variable references
                 if (dups.contains(varRef)) continue;
--- a/src/java.xml/share/classes/com/sun/org/apache/xalan/internal/xsltc/compiler/SyntaxTreeNode.java	Tue Nov 07 14:36:52 2017 -0800
+++ b/src/java.xml/share/classes/com/sun/org/apache/xalan/internal/xsltc/compiler/SyntaxTreeNode.java	Wed Nov 08 12:27:40 2017 -0800
@@ -1,5 +1,6 @@
 /*
- * Copyright (c) 2006, 2016, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2006, 2017, Oracle and/or its affiliates. All rights reserved.
+ * @LastModified: Nov 2017
  */
 /*
  * Licensed to the Apache Software Foundation (ASF) under one or more
@@ -856,7 +857,7 @@
      */
     protected final SyntaxTreeNode lastChild() {
         if (_contents.isEmpty()) return null;
-        return (SyntaxTreeNode)_contents.get(_contents.size() - 1);
+        return _contents.get(_contents.size() - 1);
     }
 
     /**
--- a/src/java.xml/share/classes/com/sun/org/apache/xalan/internal/xsltc/compiler/TestSeq.java	Tue Nov 07 14:36:52 2017 -0800
+++ b/src/java.xml/share/classes/com/sun/org/apache/xalan/internal/xsltc/compiler/TestSeq.java	Wed Nov 08 12:27:40 2017 -0800
@@ -1,6 +1,6 @@
 /*
  * Copyright (c) 2015, 2017, Oracle and/or its affiliates. All rights reserved.
- * @LastModified: Oct 2017
+ * @LastModified: Nov 2017
  */
 /*
  * Licensed to the Apache Software Foundation (ASF) under one or more
@@ -191,7 +191,7 @@
      * (e.g. match="A/B | A/C").
      */
     private InstructionHandle getTemplateHandle(Template template) {
-        return (InstructionHandle)_mode.getTemplateInstructionHandle(template);
+        return _mode.getTemplateInstructionHandle(template);
     }
 
     /**
--- a/src/java.xml/share/classes/com/sun/org/apache/xalan/internal/xsltc/compiler/UnionPathExpr.java	Tue Nov 07 14:36:52 2017 -0800
+++ b/src/java.xml/share/classes/com/sun/org/apache/xalan/internal/xsltc/compiler/UnionPathExpr.java	Wed Nov 08 12:27:40 2017 -0800
@@ -1,6 +1,6 @@
 /*
  * Copyright (c) 2017, Oracle and/or its affiliates. All rights reserved.
- * @LastModified: Oct 2017
+ * @LastModified: Nov 2017
  */
 /*
  * Licensed to the Apache Software Foundation (ASF) under one or more
@@ -60,7 +60,7 @@
         final List<Expression> components = new ArrayList<>();
         flatten(components);
         final int size = components.size();
-        _components = (Expression[])components.toArray(new Expression[size]);
+        _components = components.toArray(new Expression[size]);
         for (int i = 0; i < size; i++) {
             _components[i].setParser(parser);
             _components[i].setParent(this);
--- a/src/java.xml/share/classes/com/sun/org/apache/xalan/internal/xsltc/compiler/XPathParser.java	Tue Nov 07 14:36:52 2017 -0800
+++ b/src/java.xml/share/classes/com/sun/org/apache/xalan/internal/xsltc/compiler/XPathParser.java	Wed Nov 08 12:27:40 2017 -0800
@@ -1311,7 +1311,7 @@
               QName RESULT = null;
                 int qnameleft = (parser_stack.get(parser_top-0)).left;
                 int qnameright = (parser_stack.get(parser_top-0)).right;
-                String qname = (String)((Symbol) parser_stack.get(parser_top-0)).value;
+                String qname = (String)(parser_stack.get(parser_top-0)).value;
                  RESULT = parser.getQNameIgnoreDefaultNs(qname);
               parser_result = new Symbol(37/*QName*/, (parser_stack.get(parser_top-0)).left, (parser_stack.get(parser_top-0)).right, RESULT);
             }
@@ -1323,7 +1323,7 @@
               Object RESULT = null;
                 int qnleft = (parser_stack.get(parser_top-0)).left;
                 int qnright = (parser_stack.get(parser_top-0)).right;
-                QName qn = (QName)((Symbol) parser_stack.get(parser_top-0)).value;
+                QName qn = (QName)(parser_stack.get(parser_top-0)).value;
                  RESULT = qn;
               parser_result = new Symbol(26/*NameTest*/, (parser_stack.get(parser_top-0)).left, (parser_stack.get(parser_top-0)).right, RESULT);
             }
@@ -1353,7 +1353,7 @@
               Object RESULT = null;
                 int lleft = (parser_stack.get(parser_top-1)).left;
                 int lright = (parser_stack.get(parser_top-1)).right;
-                String l = (String)((Symbol) parser_stack.get(parser_top-1)).value;
+                String l = (String)(parser_stack.get(parser_top-1)).value;
 
            QName name = parser.getQNameIgnoreDefaultNs("name");
            Expression exp = new EqualityExpr(Operators.EQ,
@@ -1400,7 +1400,7 @@
               Object RESULT = null;
                 int ntleft = (parser_stack.get(parser_top-0)).left;
                 int ntright = (parser_stack.get(parser_top-0)).right;
-                Object nt = (Object)((Symbol) parser_stack.get(parser_top-0)).value;
+                Object nt = parser_stack.get(parser_top-0).value;
                  RESULT = nt;
               parser_result = new Symbol(25/*NodeTest*/, (parser_stack.get(parser_top-0)).left, (parser_stack.get(parser_top-0)).right, RESULT);
             }
@@ -1412,7 +1412,7 @@
               Expression RESULT = null;
                 int exleft = (parser_stack.get(parser_top-0)).left;
                 int exright = (parser_stack.get(parser_top-0)).right;
-                Expression ex = (Expression)((Symbol) parser_stack.get(parser_top-0)).value;
+                Expression ex = (Expression)(parser_stack.get(parser_top-0)).value;
                  RESULT = ex;
               parser_result = new Symbol(3/*Argument*/, (parser_stack.get(parser_top-0)).left, (parser_stack.get(parser_top-0)).right, RESULT);
             }
@@ -1424,7 +1424,7 @@
               QName RESULT = null;
                 int vnameleft = (parser_stack.get(parser_top-0)).left;
                 int vnameright = (parser_stack.get(parser_top-0)).right;
-                QName vname = (QName)((Symbol) parser_stack.get(parser_top-0)).value;
+                QName vname = (QName)(parser_stack.get(parser_top-0)).value;
 
             RESULT = vname;
 
@@ -1438,7 +1438,7 @@
               QName RESULT = null;
                 int fnameleft = (parser_stack.get(parser_top-0)).left;
                 int fnameright = (parser_stack.get(parser_top-0)).right;
-                QName fname = (QName)((Symbol) parser_stack.get(parser_top-0)).value;
+                QName fname = (QName)(parser_stack.get(parser_top-0)).value;
 
             RESULT = fname;
 
@@ -1452,11 +1452,11 @@
                 List<Expression> RESULT = null;
                 int argleft = (parser_stack.get(parser_top-2)).left;
                 int argright = (parser_stack.get(parser_top-2)).right;
-                Expression arg = (Expression)((Symbol) parser_stack.get(parser_top-2)).value;
+                Expression arg = (Expression)(parser_stack.get(parser_top-2)).value;
                 int arglleft = (parser_stack.get(parser_top-0)).left;
                 int arglright = (parser_stack.get(parser_top-0)).right;
                 @SuppressWarnings("unchecked")
-                List<Expression> argl = (ArrayList<Expression>)((Symbol) parser_stack.get(parser_top-0)).value;
+                List<Expression> argl = (ArrayList<Expression>)(parser_stack.get(parser_top-0)).value;
                 argl.add(0, arg);
                 RESULT = argl;
               parser_result = new Symbol(36/*NonemptyArgumentList*/, (parser_stack.get(parser_top-2)).left, (parser_stack.get(parser_top-0)).right, RESULT);
@@ -1469,7 +1469,7 @@
               List<Expression> RESULT = null;
                 int argleft = (parser_stack.get(parser_top-0)).left;
                 int argright = (parser_stack.get(parser_top-0)).right;
-                Expression arg = (Expression)((Symbol) parser_stack.get(parser_top-0)).value;
+                Expression arg = (Expression)(parser_stack.get(parser_top-0)).value;
 
             List<Expression> temp = new ArrayList<>();
             temp.add(arg);
@@ -1485,11 +1485,11 @@
                 Expression RESULT = null;
                 int fnameleft = (parser_stack.get(parser_top-3)).left;
                 int fnameright = (parser_stack.get(parser_top-3)).right;
-                QName fname = (QName)((Symbol) parser_stack.get(parser_top-3)).value;
+                QName fname = (QName)(parser_stack.get(parser_top-3)).value;
                 int arglleft = (parser_stack.get(parser_top-1)).left;
                 int arglright = (parser_stack.get(parser_top-1)).right;
                 @SuppressWarnings("unchecked")
-                List<Expression> argl = (ArrayList<Expression>)((Symbol) parser_stack.get(parser_top-1)).value;
+                List<Expression> argl = (ArrayList<Expression>)(parser_stack.get(parser_top-1)).value;
 
           if (fname == parser.getQNameIgnoreDefaultNs("concat")) {
             RESULT = new ConcatCall(fname, argl);
@@ -1584,7 +1584,7 @@
               Expression RESULT = null;
                 int fnameleft = (parser_stack.get(parser_top-2)).left;
                 int fnameright = (parser_stack.get(parser_top-2)).right;
-                QName fname = (QName)((Symbol) parser_stack.get(parser_top-2)).value;
+                QName fname = (QName)(parser_stack.get(parser_top-2)).value;
 
 
           if (fname == parser.getQNameIgnoreDefaultNs("current")) {
@@ -1640,7 +1640,7 @@
               Expression RESULT = null;
                 int varNameleft = (parser_stack.get(parser_top-0)).left;
                 int varNameright = (parser_stack.get(parser_top-0)).right;
-                QName varName = (QName)((Symbol) parser_stack.get(parser_top-0)).value;
+                QName varName = (QName)(parser_stack.get(parser_top-0)).value;
 
             // An empty qname prefix for a variable or parameter reference
             // should map to the null namespace and not the default URI.
@@ -1672,7 +1672,7 @@
               Expression RESULT = null;
                 int fcleft = (parser_stack.get(parser_top-0)).left;
                 int fcright = (parser_stack.get(parser_top-0)).right;
-                Expression fc = (Expression)((Symbol) parser_stack.get(parser_top-0)).value;
+                Expression fc = (Expression)(parser_stack.get(parser_top-0)).value;
                  RESULT = fc;
               parser_result = new Symbol(17/*PrimaryExpr*/, (parser_stack.get(parser_top-0)).left, (parser_stack.get(parser_top-0)).right, RESULT);
             }
@@ -1684,7 +1684,7 @@
               Expression RESULT = null;
                 int numleft = (parser_stack.get(parser_top-0)).left;
                 int numright = (parser_stack.get(parser_top-0)).right;
-                Double num = (Double)((Symbol) parser_stack.get(parser_top-0)).value;
+                Double num = (Double)(parser_stack.get(parser_top-0)).value;
                  RESULT = new RealExpr(num.doubleValue());
               parser_result = new Symbol(17/*PrimaryExpr*/, (parser_stack.get(parser_top-0)).left, (parser_stack.get(parser_top-0)).right, RESULT);
             }
@@ -1696,7 +1696,7 @@
               Expression RESULT = null;
                 int numleft = (parser_stack.get(parser_top-0)).left;
                 int numright = (parser_stack.get(parser_top-0)).right;
-                Long num = (Long)((Symbol) parser_stack.get(parser_top-0)).value;
+                Long num = (Long)(parser_stack.get(parser_top-0)).value;
 
            long value = num.longValue();
            if (value < Integer.MIN_VALUE || value > Integer.MAX_VALUE) {
@@ -1723,7 +1723,7 @@
               Expression RESULT = null;
                 int stringleft = (parser_stack.get(parser_top-0)).left;
                 int stringright = (parser_stack.get(parser_top-0)).right;
-                String string = (String)((Symbol) parser_stack.get(parser_top-0)).value;
+                String string = (String)(parser_stack.get(parser_top-0)).value;
 
         /*
         * If the string appears to have the syntax of a QName, store
@@ -1751,7 +1751,7 @@
               Expression RESULT = null;
                 int exleft = (parser_stack.get(parser_top-1)).left;
                 int exright = (parser_stack.get(parser_top-1)).right;
-                Expression ex = (Expression)((Symbol) parser_stack.get(parser_top-1)).value;
+                Expression ex = (Expression)(parser_stack.get(parser_top-1)).value;
                  RESULT = ex;
               parser_result = new Symbol(17/*PrimaryExpr*/, (parser_stack.get(parser_top-2)).left, (parser_stack.get(parser_top-0)).right, RESULT);
             }
@@ -1763,7 +1763,7 @@
               Expression RESULT = null;
                 int vrleft = (parser_stack.get(parser_top-0)).left;
                 int vrright = (parser_stack.get(parser_top-0)).right;
-                Expression vr = (Expression)((Symbol) parser_stack.get(parser_top-0)).value;
+                Expression vr = (Expression)(parser_stack.get(parser_top-0)).value;
                  RESULT = vr;
               parser_result = new Symbol(17/*PrimaryExpr*/, (parser_stack.get(parser_top-0)).left, (parser_stack.get(parser_top-0)).right, RESULT);
             }
@@ -1775,11 +1775,11 @@
               Expression RESULT = null;
                 int primaryleft = (parser_stack.get(parser_top-1)).left;
                 int primaryright = (parser_stack.get(parser_top-1)).right;
-                Expression primary = (Expression)((Symbol) parser_stack.get(parser_top-1)).value;
+                Expression primary = (Expression)(parser_stack.get(parser_top-1)).value;
                 int ppleft = (parser_stack.get(parser_top-0)).left;
                 int ppright = (parser_stack.get(parser_top-0)).right;
                 @SuppressWarnings("unchecked")
-                List<Expression> pp = (ArrayList<Expression>)((Symbol) parser_stack.get(parser_top-0)).value;
+                List<Expression> pp = (ArrayList<Expression>)(parser_stack.get(parser_top-0)).value;
                  RESULT = new FilterExpr(primary, pp);
               parser_result = new Symbol(6/*FilterExpr*/, (parser_stack.get(parser_top-1)).left, (parser_stack.get(parser_top-0)).right, RESULT);
             }
@@ -1791,7 +1791,7 @@
               Expression RESULT = null;
                 int primaryleft = (parser_stack.get(parser_top-0)).left;
                 int primaryright = (parser_stack.get(parser_top-0)).right;
-                Expression primary = (Expression)((Symbol) parser_stack.get(parser_top-0)).value;
+                Expression primary = (Expression)(parser_stack.get(parser_top-0)).value;
                  RESULT = primary;
               parser_result = new Symbol(6/*FilterExpr*/, (parser_stack.get(parser_top-0)).left, (parser_stack.get(parser_top-0)).right, RESULT);
             }
@@ -1947,7 +1947,7 @@
               Integer RESULT = null;
                 int anleft = (parser_stack.get(parser_top-1)).left;
                 int anright = (parser_stack.get(parser_top-1)).right;
-                Integer an = (Integer)((Symbol) parser_stack.get(parser_top-1)).value;
+                Integer an = (Integer)(parser_stack.get(parser_top-1)).value;
                  RESULT = an;
               parser_result = new Symbol(41/*AxisSpecifier*/, (parser_stack.get(parser_top-1)).left, (parser_stack.get(parser_top-0)).right, RESULT);
             }
@@ -1959,7 +1959,7 @@
               Expression RESULT = null;
                 int abbrevleft = (parser_stack.get(parser_top-0)).left;
                 int abbrevright = (parser_stack.get(parser_top-0)).right;
-                Expression abbrev = (Expression)((Symbol) parser_stack.get(parser_top-0)).value;
+                Expression abbrev = (Expression)(parser_stack.get(parser_top-0)).value;
                  RESULT = abbrev;
               parser_result = new Symbol(7/*Step*/, (parser_stack.get(parser_top-0)).left, (parser_stack.get(parser_top-0)).right, RESULT);
             }
@@ -1971,10 +1971,10 @@
               Expression RESULT = null;
                 int axisleft = (parser_stack.get(parser_top-1)).left;
                 int axisright = (parser_stack.get(parser_top-1)).right;
-                Integer axis = (Integer)((Symbol) parser_stack.get(parser_top-1)).value;
+                Integer axis = (Integer)(parser_stack.get(parser_top-1)).value;
                 int ntestleft = (parser_stack.get(parser_top-0)).left;
                 int ntestright = (parser_stack.get(parser_top-0)).right;
-                Object ntest = (Object)((Symbol) parser_stack.get(parser_top-0)).value;
+                Object ntest = parser_stack.get(parser_top-0).value;
                  RESULT = new Step(axis.intValue(),
                              parser.findNodeType(axis.intValue(), ntest),
                              null);
@@ -1989,14 +1989,14 @@
               Expression RESULT = null;
                 int axisleft = (parser_stack.get(parser_top-2)).left;
                 int axisright = (parser_stack.get(parser_top-2)).right;
-                Integer axis = (Integer)((Symbol) parser_stack.get(parser_top-2)).value;
+                Integer axis = (Integer)(parser_stack.get(parser_top-2)).value;
                 int ntestleft = (parser_stack.get(parser_top-1)).left;
                 int ntestright = (parser_stack.get(parser_top-1)).right;
-                Object ntest = (Object)((Symbol) parser_stack.get(parser_top-1)).value;
+                Object ntest = parser_stack.get(parser_top-1).value;
                 int ppleft = (parser_stack.get(parser_top-0)).left;
                 int ppright = (parser_stack.get(parser_top-0)).right;
                 @SuppressWarnings("unchecked")
-                List<Predicate> pp = (ArrayList<Predicate>)((Symbol) parser_stack.get(parser_top-0)).value;
+                List<Predicate> pp = (ArrayList<Predicate>)(parser_stack.get(parser_top-0)).value;
                  RESULT = new Step(axis.intValue(),
                              parser.findNodeType(axis.intValue(), ntest),
                              pp);
@@ -2011,11 +2011,11 @@
               Expression RESULT = null;
                 int ntestleft = (parser_stack.get(parser_top-1)).left;
                 int ntestright = (parser_stack.get(parser_top-1)).right;
-                Object ntest = (Object)((Symbol) parser_stack.get(parser_top-1)).value;
+                Object ntest = parser_stack.get(parser_top-1).value;
                 int ppleft = (parser_stack.get(parser_top-0)).left;
                 int ppright = (parser_stack.get(parser_top-0)).right;
                 @SuppressWarnings("unchecked")
-                List<Predicate> pp = (ArrayList<Predicate>)((Symbol) parser_stack.get(parser_top-0)).value;
+                List<Predicate> pp = (ArrayList<Predicate>)(parser_stack.get(parser_top-0)).value;
 
             if (ntest instanceof Step) {
                 Step step = (Step)ntest;
@@ -2037,7 +2037,7 @@
               Expression RESULT = null;
                 int ntestleft = (parser_stack.get(parser_top-0)).left;
                 int ntestright = (parser_stack.get(parser_top-0)).right;
-                Object ntest = (Object)((Symbol) parser_stack.get(parser_top-0)).value;
+                Object ntest = parser_stack.get(parser_top-0).value;
 
             if (ntest instanceof Step) {
                 RESULT = (Step)ntest;
@@ -2058,7 +2058,7 @@
               Expression RESULT = null;
                 int rlpleft = (parser_stack.get(parser_top-0)).left;
                 int rlpright = (parser_stack.get(parser_top-0)).right;
-                Expression rlp = (Expression)((Symbol) parser_stack.get(parser_top-0)).value;
+                Expression rlp = (Expression)(parser_stack.get(parser_top-0)).value;
 
            //
            // Expand '//' into '/descendant-or-self::node()/' or
@@ -2084,10 +2084,10 @@
               Expression RESULT = null;
                 int rlpleft = (parser_stack.get(parser_top-2)).left;
                 int rlpright = (parser_stack.get(parser_top-2)).right;
-                Expression rlp = (Expression)((Symbol) parser_stack.get(parser_top-2)).value;
+                Expression rlp = (Expression)(parser_stack.get(parser_top-2)).value;
                 int stepleft = (parser_stack.get(parser_top-0)).left;
                 int stepright = (parser_stack.get(parser_top-0)).right;
-                Expression step = (Expression)((Symbol) parser_stack.get(parser_top-0)).value;
+                Expression step = (Expression)(parser_stack.get(parser_top-0)).value;
 
            final Step right  = (Step)step;
            final int  axis   = right.getAxis();
@@ -2151,7 +2151,7 @@
               Expression RESULT = null;
                 int aalpleft = (parser_stack.get(parser_top-0)).left;
                 int aalpright = (parser_stack.get(parser_top-0)).right;
-                Expression aalp = (Expression)((Symbol) parser_stack.get(parser_top-0)).value;
+                Expression aalp = (Expression)(parser_stack.get(parser_top-0)).value;
                  RESULT = aalp;
               parser_result = new Symbol(23/*AbsoluteLocationPath*/, (parser_stack.get(parser_top-0)).left, (parser_stack.get(parser_top-0)).right, RESULT);
             }
@@ -2163,7 +2163,7 @@
               Expression RESULT = null;
                 int rlpleft = (parser_stack.get(parser_top-0)).left;
                 int rlpright = (parser_stack.get(parser_top-0)).right;
-                Expression rlp = (Expression)((Symbol) parser_stack.get(parser_top-0)).value;
+                Expression rlp = (Expression)(parser_stack.get(parser_top-0)).value;
                  RESULT = new AbsoluteLocationPath(rlp);
               parser_result = new Symbol(23/*AbsoluteLocationPath*/, (parser_stack.get(parser_top-1)).left, (parser_stack.get(parser_top-0)).right, RESULT);
             }
@@ -2184,7 +2184,7 @@
               Expression RESULT = null;
                 int arlpleft = (parser_stack.get(parser_top-0)).left;
                 int arlpright = (parser_stack.get(parser_top-0)).right;
-                Expression arlp = (Expression)((Symbol) parser_stack.get(parser_top-0)).value;
+                Expression arlp = (Expression)(parser_stack.get(parser_top-0)).value;
                  RESULT = arlp;
               parser_result = new Symbol(21/*RelativeLocationPath*/, (parser_stack.get(parser_top-0)).left, (parser_stack.get(parser_top-0)).right, RESULT);
             }
@@ -2196,10 +2196,10 @@
               Expression RESULT = null;
                 int rlpleft = (parser_stack.get(parser_top-2)).left;
                 int rlpright = (parser_stack.get(parser_top-2)).right;
-                Expression rlp = (Expression)((Symbol) parser_stack.get(parser_top-2)).value;
+                Expression rlp = (Expression)(parser_stack.get(parser_top-2)).value;
                 int stepleft = (parser_stack.get(parser_top-0)).left;
                 int stepright = (parser_stack.get(parser_top-0)).right;
-                Expression step = (Expression)((Symbol) parser_stack.get(parser_top-0)).value;
+                Expression step = (Expression)(parser_stack.get(parser_top-0)).value;
 
         if (rlp instanceof Step && ((Step) rlp).isAbbreviatedDot()) {
               RESULT = step;       // Remove './' from the middle
@@ -2222,7 +2222,7 @@
               Expression RESULT = null;
                 int stepleft = (parser_stack.get(parser_top-0)).left;
                 int stepright = (parser_stack.get(parser_top-0)).right;
-                Expression step = (Expression)((Symbol) parser_stack.get(parser_top-0)).value;
+                Expression step = (Expression)(parser_stack.get(parser_top-0)).value;
                  RESULT = step;
               parser_result = new Symbol(21/*RelativeLocationPath*/, (parser_stack.get(parser_top-0)).left, (parser_stack.get(parser_top-0)).right, RESULT);
             }
@@ -2234,7 +2234,7 @@
               Expression RESULT = null;
                 int alpleft = (parser_stack.get(parser_top-0)).left;
                 int alpright = (parser_stack.get(parser_top-0)).right;
-                Expression alp = (Expression)((Symbol) parser_stack.get(parser_top-0)).value;
+                Expression alp = (Expression)(parser_stack.get(parser_top-0)).value;
                  RESULT = alp;
               parser_result = new Symbol(4/*LocationPath*/, (parser_stack.get(parser_top-0)).left, (parser_stack.get(parser_top-0)).right, RESULT);
             }
@@ -2246,7 +2246,7 @@
               Expression RESULT = null;
                 int rlpleft = (parser_stack.get(parser_top-0)).left;
                 int rlpright = (parser_stack.get(parser_top-0)).right;
-                Expression rlp = (Expression)((Symbol) parser_stack.get(parser_top-0)).value;
+                Expression rlp = (Expression)(parser_stack.get(parser_top-0)).value;
                  RESULT = rlp;
               parser_result = new Symbol(4/*LocationPath*/, (parser_stack.get(parser_top-0)).left, (parser_stack.get(parser_top-0)).right, RESULT);
             }
@@ -2258,10 +2258,10 @@
               Expression RESULT = null;
                 int fexpleft = (parser_stack.get(parser_top-2)).left;
                 int fexpright = (parser_stack.get(parser_top-2)).right;
-                Expression fexp = (Expression)((Symbol) parser_stack.get(parser_top-2)).value;
+                Expression fexp = (Expression)(parser_stack.get(parser_top-2)).value;
                 int rlpleft = (parser_stack.get(parser_top-0)).left;
                 int rlpright = (parser_stack.get(parser_top-0)).right;
-                Expression rlp = (Expression)((Symbol) parser_stack.get(parser_top-0)).value;
+                Expression rlp = (Expression)(parser_stack.get(parser_top-0)).value;
 
            //
            // Expand '//' into '/descendant-or-self::node()/' or
@@ -2291,10 +2291,10 @@
               Expression RESULT = null;
                 int fexpleft = (parser_stack.get(parser_top-2)).left;
                 int fexpright = (parser_stack.get(parser_top-2)).right;
-                Expression fexp = (Expression)((Symbol) parser_stack.get(parser_top-2)).value;
+                Expression fexp = (Expression)(parser_stack.get(parser_top-2)).value;
                 int rlpleft = (parser_stack.get(parser_top-0)).left;
                 int rlpright = (parser_stack.get(parser_top-0)).right;
-                Expression rlp = (Expression)((Symbol) parser_stack.get(parser_top-0)).value;
+                Expression rlp = (Expression)(parser_stack.get(parser_top-0)).value;
                  RESULT = new FilterParentPath(fexp, rlp);
               parser_result = new Symbol(19/*PathExpr*/, (parser_stack.get(parser_top-2)).left, (parser_stack.get(parser_top-0)).right, RESULT);
             }
@@ -2306,7 +2306,7 @@
               Expression RESULT = null;
                 int fexpleft = (parser_stack.get(parser_top-0)).left;
                 int fexpright = (parser_stack.get(parser_top-0)).right;
-                Expression fexp = (Expression)((Symbol) parser_stack.get(parser_top-0)).value;
+                Expression fexp = (Expression)(parser_stack.get(parser_top-0)).value;
                  RESULT = fexp;
               parser_result = new Symbol(19/*PathExpr*/, (parser_stack.get(parser_top-0)).left, (parser_stack.get(parser_top-0)).right, RESULT);
             }
@@ -2318,7 +2318,7 @@
               Expression RESULT = null;
                 int lpleft = (parser_stack.get(parser_top-0)).left;
                 int lpright = (parser_stack.get(parser_top-0)).right;
-                Expression lp = (Expression)((Symbol) parser_stack.get(parser_top-0)).value;
+                Expression lp = (Expression)(parser_stack.get(parser_top-0)).value;
                  RESULT = lp;
               parser_result = new Symbol(19/*PathExpr*/, (parser_stack.get(parser_top-0)).left, (parser_stack.get(parser_top-0)).right, RESULT);
             }
@@ -2330,10 +2330,10 @@
               Expression RESULT = null;
                 int peleft = (parser_stack.get(parser_top-2)).left;
                 int peright = (parser_stack.get(parser_top-2)).right;
-                Expression pe = (Expression)((Symbol) parser_stack.get(parser_top-2)).value;
+                Expression pe = (Expression)(parser_stack.get(parser_top-2)).value;
                 int restleft = (parser_stack.get(parser_top-0)).left;
                 int restright = (parser_stack.get(parser_top-0)).right;
-                Expression rest = (Expression)((Symbol) parser_stack.get(parser_top-0)).value;
+                Expression rest = (Expression)(parser_stack.get(parser_top-0)).value;
                  RESULT = new UnionPathExpr(pe, rest);
               parser_result = new Symbol(18/*UnionExpr*/, (parser_stack.get(parser_top-2)).left, (parser_stack.get(parser_top-0)).right, RESULT);
             }
@@ -2345,7 +2345,7 @@
               Expression RESULT = null;
                 int peleft = (parser_stack.get(parser_top-0)).left;
                 int peright = (parser_stack.get(parser_top-0)).right;
-                Expression pe = (Expression)((Symbol) parser_stack.get(parser_top-0)).value;
+                Expression pe = (Expression)(parser_stack.get(parser_top-0)).value;
                  RESULT = pe;
               parser_result = new Symbol(18/*UnionExpr*/, (parser_stack.get(parser_top-0)).left, (parser_stack.get(parser_top-0)).right, RESULT);
             }
@@ -2357,7 +2357,7 @@
               Expression RESULT = null;
                 int ueleft = (parser_stack.get(parser_top-0)).left;
                 int ueright = (parser_stack.get(parser_top-0)).right;
-                Expression ue = (Expression)((Symbol) parser_stack.get(parser_top-0)).value;
+                Expression ue = (Expression)(parser_stack.get(parser_top-0)).value;
                  RESULT = new UnaryOpExpr(ue);
               parser_result = new Symbol(14/*UnaryExpr*/, (parser_stack.get(parser_top-1)).left, (parser_stack.get(parser_top-0)).right, RESULT);
             }
@@ -2369,7 +2369,7 @@
               Expression RESULT = null;
                 int ueleft = (parser_stack.get(parser_top-0)).left;
                 int ueright = (parser_stack.get(parser_top-0)).right;
-                Expression ue = (Expression)((Symbol) parser_stack.get(parser_top-0)).value;
+                Expression ue = (Expression)(parser_stack.get(parser_top-0)).value;
                  RESULT = ue;
               parser_result = new Symbol(14/*UnaryExpr*/, (parser_stack.get(parser_top-0)).left, (parser_stack.get(parser_top-0)).right, RESULT);
             }
@@ -2381,10 +2381,10 @@
               Expression RESULT = null;
                 int meleft = (parser_stack.get(parser_top-2)).left;
                 int meright = (parser_stack.get(parser_top-2)).right;
-                Expression me = (Expression)((Symbol) parser_stack.get(parser_top-2)).value;
+                Expression me = (Expression)(parser_stack.get(parser_top-2)).value;
                 int ueleft = (parser_stack.get(parser_top-0)).left;
                 int ueright = (parser_stack.get(parser_top-0)).right;
-                Expression ue = (Expression)((Symbol) parser_stack.get(parser_top-0)).value;
+                Expression ue = (Expression)(parser_stack.get(parser_top-0)).value;
                  RESULT = new BinOpExpr(BinOpExpr.MOD, me, ue);
               parser_result = new Symbol(13/*MultiplicativeExpr*/, (parser_stack.get(parser_top-2)).left, (parser_stack.get(parser_top-0)).right, RESULT);
             }
@@ -2396,10 +2396,10 @@
               Expression RESULT = null;
                 int meleft = (parser_stack.get(parser_top-2)).left;
                 int meright = (parser_stack.get(parser_top-2)).right;
-                Expression me = (Expression)((Symbol) parser_stack.get(parser_top-2)).value;
+                Expression me = (Expression)(parser_stack.get(parser_top-2)).value;
                 int ueleft = (parser_stack.get(parser_top-0)).left;
                 int ueright = (parser_stack.get(parser_top-0)).right;
-                Expression ue = (Expression)((Symbol) parser_stack.get(parser_top-0)).value;
+                Expression ue = (Expression)(parser_stack.get(parser_top-0)).value;
                  RESULT = new BinOpExpr(BinOpExpr.DIV, me, ue);
               parser_result = new Symbol(13/*MultiplicativeExpr*/, (parser_stack.get(parser_top-2)).left, (parser_stack.get(parser_top-0)).right, RESULT);
             }
@@ -2411,10 +2411,10 @@
               Expression RESULT = null;
                 int meleft = (parser_stack.get(parser_top-2)).left;
                 int meright = (parser_stack.get(parser_top-2)).right;
-                Expression me = (Expression)((Symbol) parser_stack.get(parser_top-2)).value;
+                Expression me = (Expression)(parser_stack.get(parser_top-2)).value;
                 int ueleft = (parser_stack.get(parser_top-0)).left;
                 int ueright = (parser_stack.get(parser_top-0)).right;
-                Expression ue = (Expression)((Symbol) parser_stack.get(parser_top-0)).value;
+                Expression ue = (Expression)(parser_stack.get(parser_top-0)).value;
                  RESULT = new BinOpExpr(BinOpExpr.TIMES, me, ue);
               parser_result = new Symbol(13/*MultiplicativeExpr*/, (parser_stack.get(parser_top-2)).left, (parser_stack.get(parser_top-0)).right, RESULT);
             }
@@ -2426,7 +2426,7 @@
               Expression RESULT = null;
                 int ueleft = (parser_stack.get(parser_top-0)).left;
                 int ueright = (parser_stack.get(parser_top-0)).right;
-                Expression ue = (Expression)((Symbol) parser_stack.get(parser_top-0)).value;
+                Expression ue = (Expression)(parser_stack.get(parser_top-0)).value;
                  RESULT = ue;
               parser_result = new Symbol(13/*MultiplicativeExpr*/, (parser_stack.get(parser_top-0)).left, (parser_stack.get(parser_top-0)).right, RESULT);
             }
@@ -2438,10 +2438,10 @@
               Expression RESULT = null;
                 int aeleft = (parser_stack.get(parser_top-2)).left;
                 int aeright = (parser_stack.get(parser_top-2)).right;
-                Expression ae = (Expression)((Symbol) parser_stack.get(parser_top-2)).value;
+                Expression ae = (Expression)(parser_stack.get(parser_top-2)).value;
                 int meleft = (parser_stack.get(parser_top-0)).left;
                 int meright = (parser_stack.get(parser_top-0)).right;
-                Expression me = (Expression)((Symbol) parser_stack.get(parser_top-0)).value;
+                Expression me = (Expression)(parser_stack.get(parser_top-0)).value;
                  RESULT = new BinOpExpr(BinOpExpr.MINUS, ae, me);
               parser_result = new Symbol(12/*AdditiveExpr*/, (parser_stack.get(parser_top-2)).left, (parser_stack.get(parser_top-0)).right, RESULT);
             }
@@ -2453,10 +2453,10 @@
               Expression RESULT = null;
                 int aeleft = (parser_stack.get(parser_top-2)).left;
                 int aeright = (parser_stack.get(parser_top-2)).right;
-                Expression ae = (Expression)((Symbol) parser_stack.get(parser_top-2)).value;
+                Expression ae = (Expression)(parser_stack.get(parser_top-2)).value;
                 int meleft = (parser_stack.get(parser_top-0)).left;
                 int meright = (parser_stack.get(parser_top-0)).right;
-                Expression me = (Expression)((Symbol) parser_stack.get(parser_top-0)).value;
+                Expression me = (Expression)(parser_stack.get(parser_top-0)).value;
                  RESULT = new BinOpExpr(BinOpExpr.PLUS, ae, me);
               parser_result = new Symbol(12/*AdditiveExpr*/, (parser_stack.get(parser_top-2)).left, (parser_stack.get(parser_top-0)).right, RESULT);
             }
@@ -2468,7 +2468,7 @@
               Expression RESULT = null;
                 int meleft = (parser_stack.get(parser_top-0)).left;
                 int meright = (parser_stack.get(parser_top-0)).right;
-                Expression me = (Expression)((Symbol) parser_stack.get(parser_top-0)).value;
+                Expression me = (Expression)(parser_stack.get(parser_top-0)).value;
                  RESULT = me;
               parser_result = new Symbol(12/*AdditiveExpr*/, (parser_stack.get(parser_top-0)).left, (parser_stack.get(parser_top-0)).right, RESULT);
             }
@@ -2480,10 +2480,10 @@
               Expression RESULT = null;
                 int releft = (parser_stack.get(parser_top-2)).left;
                 int reright = (parser_stack.get(parser_top-2)).right;
-                Expression re = (Expression)((Symbol) parser_stack.get(parser_top-2)).value;
+                Expression re = (Expression)(parser_stack.get(parser_top-2)).value;
                 int aeleft = (parser_stack.get(parser_top-0)).left;
                 int aeright = (parser_stack.get(parser_top-0)).right;
-                Expression ae = (Expression)((Symbol) parser_stack.get(parser_top-0)).value;
+                Expression ae = (Expression)(parser_stack.get(parser_top-0)).value;
                  RESULT = new RelationalExpr(Operators.GE, re, ae);
               parser_result = new Symbol(11/*RelationalExpr*/, (parser_stack.get(parser_top-2)).left, (parser_stack.get(parser_top-0)).right, RESULT);
             }
@@ -2495,10 +2495,10 @@
               Expression RESULT = null;
                 int releft = (parser_stack.get(parser_top-2)).left;
                 int reright = (parser_stack.get(parser_top-2)).right;
-                Expression re = (Expression)((Symbol) parser_stack.get(parser_top-2)).value;
+                Expression re = (Expression)(parser_stack.get(parser_top-2)).value;
                 int aeleft = (parser_stack.get(parser_top-0)).left;
                 int aeright = (parser_stack.get(parser_top-0)).right;
-                Expression ae = (Expression)((Symbol) parser_stack.get(parser_top-0)).value;
+                Expression ae = (Expression)(parser_stack.get(parser_top-0)).value;
                  RESULT = new RelationalExpr(Operators.LE, re, ae);
               parser_result = new Symbol(11/*RelationalExpr*/, (parser_stack.get(parser_top-2)).left, (parser_stack.get(parser_top-0)).right, RESULT);
             }
@@ -2510,10 +2510,10 @@
               Expression RESULT = null;
                 int releft = (parser_stack.get(parser_top-2)).left;
                 int reright = (parser_stack.get(parser_top-2)).right;
-                Expression re = (Expression)((Symbol) parser_stack.get(parser_top-2)).value;
+                Expression re = (Expression)(parser_stack.get(parser_top-2)).value;
                 int aeleft = (parser_stack.get(parser_top-0)).left;
                 int aeright = (parser_stack.get(parser_top-0)).right;
-                Expression ae = (Expression)((Symbol) parser_stack.get(parser_top-0)).value;
+                Expression ae = (Expression)(parser_stack.get(parser_top-0)).value;
                  RESULT = new RelationalExpr(Operators.GT, re, ae);
               parser_result = new Symbol(11/*RelationalExpr*/, (parser_stack.get(parser_top-2)).left, (parser_stack.get(parser_top-0)).right, RESULT);
             }
@@ -2525,10 +2525,10 @@
               Expression RESULT = null;
                 int releft = (parser_stack.get(parser_top-2)).left;
                 int reright = (parser_stack.get(parser_top-2)).right;
-                Expression re = (Expression)((Symbol) parser_stack.get(parser_top-2)).value;
+                Expression re = (Expression)(parser_stack.get(parser_top-2)).value;
                 int aeleft = (parser_stack.get(parser_top-0)).left;
                 int aeright = (parser_stack.get(parser_top-0)).right;
-                Expression ae = (Expression)((Symbol) parser_stack.get(parser_top-0)).value;
+                Expression ae = (Expression)(parser_stack.get(parser_top-0)).value;
                  RESULT = new RelationalExpr(Operators.LT, re, ae);
               parser_result = new Symbol(11/*RelationalExpr*/, (parser_stack.get(parser_top-2)).left, (parser_stack.get(parser_top-0)).right, RESULT);
             }
@@ -2540,7 +2540,7 @@
               Expression RESULT = null;
                 int aeleft = (parser_stack.get(parser_top-0)).left;
                 int aeright = (parser_stack.get(parser_top-0)).right;
-                Expression ae = (Expression)((Symbol) parser_stack.get(parser_top-0)).value;
+                Expression ae = (Expression)(parser_stack.get(parser_top-0)).value;
                  RESULT = ae;
               parser_result = new Symbol(11/*RelationalExpr*/, (parser_stack.get(parser_top-0)).left, (parser_stack.get(parser_top-0)).right, RESULT);
             }
@@ -2552,10 +2552,10 @@
               Expression RESULT = null;
                 int eeleft = (parser_stack.get(parser_top-2)).left;
                 int eeright = (parser_stack.get(parser_top-2)).right;
-                Expression ee = (Expression)((Symbol) parser_stack.get(parser_top-2)).value;
+                Expression ee = (Expression)(parser_stack.get(parser_top-2)).value;
                 int releft = (parser_stack.get(parser_top-0)).left;
                 int reright = (parser_stack.get(parser_top-0)).right;
-                Expression re = (Expression)((Symbol) parser_stack.get(parser_top-0)).value;
+                Expression re = (Expression)(parser_stack.get(parser_top-0)).value;
                  RESULT = new EqualityExpr(Operators.NE, ee, re);
               parser_result = new Symbol(10/*EqualityExpr*/, (parser_stack.get(parser_top-2)).left, (parser_stack.get(parser_top-0)).right, RESULT);
             }
@@ -2567,10 +2567,10 @@
               Expression RESULT = null;
                 int eeleft = (parser_stack.get(parser_top-2)).left;
                 int eeright = (parser_stack.get(parser_top-2)).right;
-                Expression ee = (Expression)((Symbol) parser_stack.get(parser_top-2)).value;
+                Expression ee = (Expression)(parser_stack.get(parser_top-2)).value;
                 int releft = (parser_stack.get(parser_top-0)).left;
                 int reright = (parser_stack.get(parser_top-0)).right;
-                Expression re = (Expression)((Symbol) parser_stack.get(parser_top-0)).value;
+                Expression re = (Expression)(parser_stack.get(parser_top-0)).value;
                  RESULT = new EqualityExpr(Operators.EQ, ee, re);
               parser_result = new Symbol(10/*EqualityExpr*/, (parser_stack.get(parser_top-2)).left, (parser_stack.get(parser_top-0)).right, RESULT);
             }
@@ -2582,7 +2582,7 @@
               Expression RESULT = null;
                 int releft = (parser_stack.get(parser_top-0)).left;
                 int reright = (parser_stack.get(parser_top-0)).right;
-                Expression re = (Expression)((Symbol) parser_stack.get(parser_top-0)).value;
+                Expression re = (Expression)(parser_stack.get(parser_top-0)).value;
                  RESULT = re;
               parser_result = new Symbol(10/*EqualityExpr*/, (parser_stack.get(parser_top-0)).left, (parser_stack.get(parser_top-0)).right, RESULT);
             }
@@ -2594,10 +2594,10 @@
               Expression RESULT = null;
                 int aeleft = (parser_stack.get(parser_top-2)).left;
                 int aeright = (parser_stack.get(parser_top-2)).right;
-                Expression ae = (Expression)((Symbol) parser_stack.get(parser_top-2)).value;
+                Expression ae = (Expression)(parser_stack.get(parser_top-2)).value;
                 int eeleft = (parser_stack.get(parser_top-0)).left;
                 int eeright = (parser_stack.get(parser_top-0)).right;
-                Expression ee = (Expression)((Symbol) parser_stack.get(parser_top-0)).value;
+                Expression ee = (Expression)(parser_stack.get(parser_top-0)).value;
                  RESULT = new LogicalExpr(LogicalExpr.AND, ae, ee);
               parser_result = new Symbol(9/*AndExpr*/, (parser_stack.get(parser_top-2)).left, (parser_stack.get(parser_top-0)).right, RESULT);
             }
@@ -2609,7 +2609,7 @@
               Expression RESULT = null;
                 int eleft = (parser_stack.get(parser_top-0)).left;
                 int eright = (parser_stack.get(parser_top-0)).right;
-                Expression e = (Expression)((Symbol) parser_stack.get(parser_top-0)).value;
+                Expression e = (Expression)(parser_stack.get(parser_top-0)).value;
                  RESULT = e;
               parser_result = new Symbol(9/*AndExpr*/, (parser_stack.get(parser_top-0)).left, (parser_stack.get(parser_top-0)).right, RESULT);
             }
@@ -2621,10 +2621,10 @@
               Expression RESULT = null;
                 int oeleft = (parser_stack.get(parser_top-2)).left;
                 int oeright = (parser_stack.get(parser_top-2)).right;
-                Expression oe = (Expression)((Symbol) parser_stack.get(parser_top-2)).value;
+                Expression oe = (Expression)(parser_stack.get(parser_top-2)).value;
                 int aeleft = (parser_stack.get(parser_top-0)).left;
                 int aeright = (parser_stack.get(parser_top-0)).right;
-                Expression ae = (Expression)((Symbol) parser_stack.get(parser_top-0)).value;
+                Expression ae = (Expression)(parser_stack.get(parser_top-0)).value;
                  RESULT = new LogicalExpr(LogicalExpr.OR, oe, ae);
               parser_result = new Symbol(8/*OrExpr*/, (parser_stack.get(parser_top-2)).left, (parser_stack.get(parser_top-0)).right, RESULT);
             }
@@ -2636,7 +2636,7 @@
               Expression RESULT = null;
                 int aeleft = (parser_stack.get(parser_top-0)).left;
                 int aeright = (parser_stack.get(parser_top-0)).right;
-                Expression ae = (Expression)((Symbol) parser_stack.get(parser_top-0)).value;
+                Expression ae = (Expression)(parser_stack.get(parser_top-0)).value;
                  RESULT = ae;
               parser_result = new Symbol(8/*OrExpr*/, (parser_stack.get(parser_top-0)).left, (parser_stack.get(parser_top-0)).right, RESULT);
             }
@@ -2648,7 +2648,7 @@
               Expression RESULT = null;
                 int exleft = (parser_stack.get(parser_top-0)).left;
                 int exright = (parser_stack.get(parser_top-0)).right;
-                Expression ex = (Expression)((Symbol) parser_stack.get(parser_top-0)).value;
+                Expression ex = (Expression)(parser_stack.get(parser_top-0)).value;
                  RESULT = ex;
               parser_result = new Symbol(2/*Expr*/, (parser_stack.get(parser_top-0)).left, (parser_stack.get(parser_top-0)).right, RESULT);
             }
@@ -2660,7 +2660,7 @@
               Expression RESULT = null;
                 int eleft = (parser_stack.get(parser_top-1)).left;
                 int eright = (parser_stack.get(parser_top-1)).right;
-                Expression e = (Expression)((Symbol) parser_stack.get(parser_top-1)).value;
+                Expression e = (Expression)(parser_stack.get(parser_top-1)).value;
 
                 RESULT = new Predicate(e);
 
@@ -2674,11 +2674,11 @@
                 List<Expression> RESULT = null;
                 int pleft = (parser_stack.get(parser_top-1)).left;
                 int pright = (parser_stack.get(parser_top-1)).right;
-                Expression p = (Expression)((Symbol) parser_stack.get(parser_top-1)).value;
+                Expression p = (Expression)(parser_stack.get(parser_top-1)).value;
                 int ppleft = (parser_stack.get(parser_top-0)).left;
                 int ppright = (parser_stack.get(parser_top-0)).right;
                 @SuppressWarnings("unchecked")
-                List<Expression> pp = (ArrayList<Expression>)((Symbol) parser_stack.get(parser_top-0)).value;
+                List<Expression> pp = (ArrayList<Expression>)(parser_stack.get(parser_top-0)).value;
                 pp.add(0, p); RESULT = pp;
               parser_result = new Symbol(35/*Predicates*/, (parser_stack.get(parser_top-1)).left, (parser_stack.get(parser_top-0)).right, RESULT);
             }
@@ -2690,7 +2690,7 @@
                 List<Expression> RESULT = null;
                 int pleft = (parser_stack.get(parser_top-0)).left;
                 int pright = (parser_stack.get(parser_top-0)).right;
-                Expression p = (Expression)((Symbol) parser_stack.get(parser_top-0)).value;
+                Expression p = (Expression)(parser_stack.get(parser_top-0)).value;
 
                 List<Expression> temp = new ArrayList<>();
                 temp.add(p);
@@ -2733,7 +2733,7 @@
               Object RESULT = null;
                 int qnleft = (parser_stack.get(parser_top-0)).left;
                 int qnright = (parser_stack.get(parser_top-0)).right;
-                QName qn = (QName)((Symbol) parser_stack.get(parser_top-0)).value;
+                QName qn = (QName)(parser_stack.get(parser_top-0)).value;
                  RESULT = qn;
               parser_result = new Symbol(34/*NameTestPattern*/, (parser_stack.get(parser_top-0)).left, (parser_stack.get(parser_top-0)).right, RESULT);
             }
@@ -2790,7 +2790,7 @@
               Object RESULT = null;
                 int ntleft = (parser_stack.get(parser_top-0)).left;
                 int ntright = (parser_stack.get(parser_top-0)).right;
-                Object nt = (Object)((Symbol) parser_stack.get(parser_top-0)).value;
+                Object nt = parser_stack.get(parser_top-0).value;
                  RESULT = nt;
               parser_result = new Symbol(33/*NodeTestPattern*/, (parser_stack.get(parser_top-0)).left, (parser_stack.get(parser_top-0)).right, RESULT);
             }
@@ -2802,14 +2802,14 @@
               StepPattern RESULT = null;
                 int axisleft = (parser_stack.get(parser_top-2)).left;
                 int axisright = (parser_stack.get(parser_top-2)).right;
-                Integer axis = (Integer)((Symbol) parser_stack.get(parser_top-2)).value;
+                Integer axis = (Integer)(parser_stack.get(parser_top-2)).value;
                 int pipleft = (parser_stack.get(parser_top-1)).left;
                 int pipright = (parser_stack.get(parser_top-1)).right;
-                StepPattern pip = (StepPattern)((Symbol) parser_stack.get(parser_top-1)).value;
+                StepPattern pip = (StepPattern)(parser_stack.get(parser_top-1)).value;
                 int ppleft = (parser_stack.get(parser_top-0)).left;
                 int ppright = (parser_stack.get(parser_top-0)).right;
                 @SuppressWarnings("unchecked")
-                List<Predicate> pp = (ArrayList<Predicate>)((Symbol) parser_stack.get(parser_top-0)).value;
+                List<Predicate> pp = (ArrayList<Predicate>)(parser_stack.get(parser_top-0)).value;
 
                // TODO: report error if axis is attribute
                RESULT = (ProcessingInstructionPattern)pip.setPredicates(pp);
@@ -2824,10 +2824,10 @@
               StepPattern RESULT = null;
                 int axisleft = (parser_stack.get(parser_top-1)).left;
                 int axisright = (parser_stack.get(parser_top-1)).right;
-                Integer axis = (Integer)((Symbol) parser_stack.get(parser_top-1)).value;
+                Integer axis = (Integer)(parser_stack.get(parser_top-1)).value;
                 int pipleft = (parser_stack.get(parser_top-0)).left;
                 int pipright = (parser_stack.get(parser_top-0)).right;
-                StepPattern pip = (StepPattern)((Symbol) parser_stack.get(parser_top-0)).value;
+                StepPattern pip = (StepPattern)(parser_stack.get(parser_top-0)).value;
 
                RESULT = pip;    // TODO: report error if axis is attribute
 
@@ -2841,14 +2841,14 @@
               StepPattern RESULT = null;
                 int axisleft = (parser_stack.get(parser_top-2)).left;
                 int axisright = (parser_stack.get(parser_top-2)).right;
-                Integer axis = (Integer)((Symbol) parser_stack.get(parser_top-2)).value;
+                Integer axis = (Integer)(parser_stack.get(parser_top-2)).value;
                 int ntleft = (parser_stack.get(parser_top-1)).left;
                 int ntright = (parser_stack.get(parser_top-1)).right;
-                Object nt = (Object)((Symbol) parser_stack.get(parser_top-1)).value;
+                Object nt = parser_stack.get(parser_top-1).value;
                 int ppleft = (parser_stack.get(parser_top-0)).left;
                 int ppright = (parser_stack.get(parser_top-0)).right;
                 @SuppressWarnings("unchecked")
-               List<Predicate>pp = (ArrayList<Predicate>)((Symbol) parser_stack.get(parser_top-0)).value;
+               List<Predicate>pp = (ArrayList<Predicate>)(parser_stack.get(parser_top-0)).value;
 
                RESULT = parser.createStepPattern(axis.intValue(), nt, pp);
 
@@ -2862,10 +2862,10 @@
               StepPattern RESULT = null;
                 int axisleft = (parser_stack.get(parser_top-1)).left;
                 int axisright = (parser_stack.get(parser_top-1)).right;
-                Integer axis = (Integer)((Symbol) parser_stack.get(parser_top-1)).value;
+                Integer axis = (Integer)(parser_stack.get(parser_top-1)).value;
                 int ntleft = (parser_stack.get(parser_top-0)).left;
                 int ntright = (parser_stack.get(parser_top-0)).right;
-                Object nt = (Object)((Symbol) parser_stack.get(parser_top-0)).value;
+                Object nt = parser_stack.get(parser_top-0).value;
 
                RESULT = parser.createStepPattern(axis.intValue(), nt, null);
 
@@ -2879,11 +2879,11 @@
               StepPattern RESULT = null;
                 int pipleft = (parser_stack.get(parser_top-1)).left;
                 int pipright = (parser_stack.get(parser_top-1)).right;
-                StepPattern pip = (StepPattern)((Symbol) parser_stack.get(parser_top-1)).value;
+                StepPattern pip = (StepPattern)(parser_stack.get(parser_top-1)).value;
                 int ppleft = (parser_stack.get(parser_top-0)).left;
                 int ppright = (parser_stack.get(parser_top-0)).right;
                 @SuppressWarnings("unchecked")
-                List<Predicate> pp = (ArrayList<Predicate>)((Symbol) parser_stack.get(parser_top-0)).value;
+                List<Predicate> pp = (ArrayList<Predicate>)(parser_stack.get(parser_top-0)).value;
                  RESULT = (ProcessingInstructionPattern)pip.setPredicates(pp);
               parser_result = new Symbol(32/*StepPattern*/, (parser_stack.get(parser_top-1)).left, (parser_stack.get(parser_top-0)).right, RESULT);
             }
@@ -2895,7 +2895,7 @@
               StepPattern RESULT = null;
                 int pipleft = (parser_stack.get(parser_top-0)).left;
                 int pipright = (parser_stack.get(parser_top-0)).right;
-                StepPattern pip = (StepPattern)((Symbol) parser_stack.get(parser_top-0)).value;
+                StepPattern pip = (StepPattern)(parser_stack.get(parser_top-0)).value;
                  RESULT = pip;
               parser_result = new Symbol(32/*StepPattern*/, (parser_stack.get(parser_top-0)).left, (parser_stack.get(parser_top-0)).right, RESULT);
             }
@@ -2907,11 +2907,11 @@
               StepPattern RESULT = null;
                 int ntleft = (parser_stack.get(parser_top-1)).left;
                 int ntright = (parser_stack.get(parser_top-1)).right;
-                Object nt = (Object)((Symbol) parser_stack.get(parser_top-1)).value;
+                Object nt = parser_stack.get(parser_top-1).value;
                 int ppleft = (parser_stack.get(parser_top-0)).left;
                 int ppright = (parser_stack.get(parser_top-0)).right;
                 @SuppressWarnings("unchecked")
-                List<Predicate> pp = (ArrayList<Predicate>)((Symbol) parser_stack.get(parser_top-0)).value;
+                List<Predicate> pp = (ArrayList<Predicate>)(parser_stack.get(parser_top-0)).value;
 
                 RESULT = parser.createStepPattern(Axis.CHILD, nt, pp);
 
@@ -2925,7 +2925,7 @@
               StepPattern RESULT = null;
                 int ntleft = (parser_stack.get(parser_top-0)).left;
                 int ntright = (parser_stack.get(parser_top-0)).right;
-                Object nt = (Object)((Symbol) parser_stack.get(parser_top-0)).value;
+                Object nt = parser_stack.get(parser_top-0).value;
 
                 RESULT = parser.createStepPattern(Axis.CHILD, nt, null);
 
@@ -2939,10 +2939,10 @@
               RelativePathPattern RESULT = null;
                 int spleft = (parser_stack.get(parser_top-2)).left;
                 int spright = (parser_stack.get(parser_top-2)).right;
-                StepPattern sp = (StepPattern)((Symbol) parser_stack.get(parser_top-2)).value;
+                StepPattern sp = (StepPattern)(parser_stack.get(parser_top-2)).value;
                 int rppleft = (parser_stack.get(parser_top-0)).left;
                 int rppright = (parser_stack.get(parser_top-0)).right;
-                RelativePathPattern rpp = (RelativePathPattern)((Symbol) parser_stack.get(parser_top-0)).value;
+                RelativePathPattern rpp = (RelativePathPattern)(parser_stack.get(parser_top-0)).value;
                  RESULT = new AncestorPattern(sp, rpp);
               parser_result = new Symbol(31/*RelativePathPattern*/, (parser_stack.get(parser_top-2)).left, (parser_stack.get(parser_top-0)).right, RESULT);
             }
@@ -2954,10 +2954,10 @@
               RelativePathPattern RESULT = null;
                 int spleft = (parser_stack.get(parser_top-2)).left;
                 int spright = (parser_stack.get(parser_top-2)).right;
-                StepPattern sp = (StepPattern)((Symbol) parser_stack.get(parser_top-2)).value;
+                StepPattern sp = (StepPattern)(parser_stack.get(parser_top-2)).value;
                 int rppleft = (parser_stack.get(parser_top-0)).left;
                 int rppright = (parser_stack.get(parser_top-0)).right;
-                RelativePathPattern rpp = (RelativePathPattern)((Symbol) parser_stack.get(parser_top-0)).value;
+                RelativePathPattern rpp = (RelativePathPattern)(parser_stack.get(parser_top-0)).value;
                  RESULT = new ParentPattern(sp, rpp);
               parser_result = new Symbol(31/*RelativePathPattern*/, (parser_stack.get(parser_top-2)).left, (parser_stack.get(parser_top-0)).right, RESULT);
             }
@@ -2969,7 +2969,7 @@
               RelativePathPattern RESULT = null;
                 int spleft = (parser_stack.get(parser_top-0)).left;
                 int spright = (parser_stack.get(parser_top-0)).right;
-                StepPattern sp = (StepPattern)((Symbol) parser_stack.get(parser_top-0)).value;
+                StepPattern sp = (StepPattern)(parser_stack.get(parser_top-0)).value;
                  RESULT = sp;
               parser_result = new Symbol(31/*RelativePathPattern*/, (parser_stack.get(parser_top-0)).left, (parser_stack.get(parser_top-0)).right, RESULT);
             }
@@ -2981,7 +2981,7 @@
               StepPattern RESULT = null;
                 int lleft = (parser_stack.get(parser_top-1)).left;
                 int lright = (parser_stack.get(parser_top-1)).right;
-                String l = (String)((Symbol) parser_stack.get(parser_top-1)).value;
+                String l = (String)(parser_stack.get(parser_top-1)).value;
                  RESULT = new ProcessingInstructionPattern(l);
               parser_result = new Symbol(30/*ProcessingInstructionPattern*/, (parser_stack.get(parser_top-3)).left, (parser_stack.get(parser_top-0)).right, RESULT);
             }
@@ -2993,10 +2993,10 @@
               IdKeyPattern RESULT = null;
                 int l1left = (parser_stack.get(parser_top-3)).left;
                 int l1right = (parser_stack.get(parser_top-3)).right;
-                String l1 = (String)((Symbol) parser_stack.get(parser_top-3)).value;
+                String l1 = (String)(parser_stack.get(parser_top-3)).value;
                 int l2left = (parser_stack.get(parser_top-1)).left;
                 int l2right = (parser_stack.get(parser_top-1)).right;
-                String l2 = (String)((Symbol) parser_stack.get(parser_top-1)).value;
+                String l2 = (String)(parser_stack.get(parser_top-1)).value;
                  RESULT = new KeyPattern(l1, l2);
               parser_result = new Symbol(27/*IdKeyPattern*/, (parser_stack.get(parser_top-5)).left, (parser_stack.get(parser_top-0)).right, RESULT);
             }
@@ -3008,7 +3008,7 @@
               IdKeyPattern RESULT = null;
                 int lleft = (parser_stack.get(parser_top-1)).left;
                 int lright = (parser_stack.get(parser_top-1)).right;
-                String l = (String)((Symbol) parser_stack.get(parser_top-1)).value;
+                String l = (String)(parser_stack.get(parser_top-1)).value;
                  RESULT = new IdPattern(l);
                parser.setHasIdCall(true);
 
@@ -3022,7 +3022,7 @@
               Pattern RESULT = null;
                 int rppleft = (parser_stack.get(parser_top-0)).left;
                 int rppright = (parser_stack.get(parser_top-0)).right;
-                RelativePathPattern rpp = (RelativePathPattern)((Symbol) parser_stack.get(parser_top-0)).value;
+                RelativePathPattern rpp = (RelativePathPattern)(parser_stack.get(parser_top-0)).value;
                  RESULT = rpp;
               parser_result = new Symbol(29/*LocationPathPattern*/, (parser_stack.get(parser_top-0)).left, (parser_stack.get(parser_top-0)).right, RESULT);
             }
@@ -3034,7 +3034,7 @@
               Pattern RESULT = null;
                 int rppleft = (parser_stack.get(parser_top-0)).left;
                 int rppright = (parser_stack.get(parser_top-0)).right;
-                RelativePathPattern rpp = (RelativePathPattern)((Symbol) parser_stack.get(parser_top-0)).value;
+                RelativePathPattern rpp = (RelativePathPattern)(parser_stack.get(parser_top-0)).value;
                  RESULT = new AncestorPattern(rpp);
               parser_result = new Symbol(29/*LocationPathPattern*/, (parser_stack.get(parser_top-1)).left, (parser_stack.get(parser_top-0)).right, RESULT);
             }
@@ -3046,10 +3046,10 @@
               Pattern RESULT = null;
                 int ikpleft = (parser_stack.get(parser_top-2)).left;
                 int ikpright = (parser_stack.get(parser_top-2)).right;
-                IdKeyPattern ikp = (IdKeyPattern)((Symbol) parser_stack.get(parser_top-2)).value;
+                IdKeyPattern ikp = (IdKeyPattern)(parser_stack.get(parser_top-2)).value;
                 int rppleft = (parser_stack.get(parser_top-0)).left;
                 int rppright = (parser_stack.get(parser_top-0)).right;
-                RelativePathPattern rpp = (RelativePathPattern)((Symbol) parser_stack.get(parser_top-0)).value;
+                RelativePathPattern rpp = (RelativePathPattern)(parser_stack.get(parser_top-0)).value;
                  RESULT = new AncestorPattern(ikp, rpp);
               parser_result = new Symbol(29/*LocationPathPattern*/, (parser_stack.get(parser_top-2)).left, (parser_stack.get(parser_top-0)).right, RESULT);
             }
@@ -3061,10 +3061,10 @@
               Pattern RESULT = null;
                 int ikpleft = (parser_stack.get(parser_top-2)).left;
                 int ikpright = (parser_stack.get(parser_top-2)).right;
-                IdKeyPattern ikp = (IdKeyPattern)((Symbol) parser_stack.get(parser_top-2)).value;
+                IdKeyPattern ikp = (IdKeyPattern)(parser_stack.get(parser_top-2)).value;
                 int rppleft = (parser_stack.get(parser_top-0)).left;
                 int rppright = (parser_stack.get(parser_top-0)).right;
-                RelativePathPattern rpp = (RelativePathPattern)((Symbol) parser_stack.get(parser_top-0)).value;
+                RelativePathPattern rpp = (RelativePathPattern)(parser_stack.get(parser_top-0)).value;
                  RESULT = new ParentPattern(ikp, rpp);
               parser_result = new Symbol(29/*LocationPathPattern*/, (parser_stack.get(parser_top-2)).left, (parser_stack.get(parser_top-0)).right, RESULT);
             }
@@ -3076,7 +3076,7 @@
               Pattern RESULT = null;
                 int ikpleft = (parser_stack.get(parser_top-0)).left;
                 int ikpright = (parser_stack.get(parser_top-0)).right;
-                IdKeyPattern ikp = (IdKeyPattern)((Symbol) parser_stack.get(parser_top-0)).value;
+                IdKeyPattern ikp = (IdKeyPattern)(parser_stack.get(parser_top-0)).value;
                  RESULT = ikp;
               parser_result = new Symbol(29/*LocationPathPattern*/, (parser_stack.get(parser_top-0)).left, (parser_stack.get(parser_top-0)).right, RESULT);
             }
@@ -3088,7 +3088,7 @@
               Pattern RESULT = null;
                 int rppleft = (parser_stack.get(parser_top-0)).left;
                 int rppright = (parser_stack.get(parser_top-0)).right;
-                RelativePathPattern rpp = (RelativePathPattern)((Symbol) parser_stack.get(parser_top-0)).value;
+                RelativePathPattern rpp = (RelativePathPattern)(parser_stack.get(parser_top-0)).value;
                  RESULT = new AbsolutePathPattern(rpp);
               parser_result = new Symbol(29/*LocationPathPattern*/, (parser_stack.get(parser_top-1)).left, (parser_stack.get(parser_top-0)).right, RESULT);
             }
@@ -3109,10 +3109,10 @@
               Pattern RESULT = null;
                 int lppleft = (parser_stack.get(parser_top-2)).left;
                 int lppright = (parser_stack.get(parser_top-2)).right;
-                Pattern lpp = (Pattern)((Symbol) parser_stack.get(parser_top-2)).value;
+                Pattern lpp = (Pattern)(parser_stack.get(parser_top-2)).value;
                 int pleft = (parser_stack.get(parser_top-0)).left;
                 int pright = (parser_stack.get(parser_top-0)).right;
-                Pattern p = (Pattern)((Symbol) parser_stack.get(parser_top-0)).value;
+                Pattern p = (Pattern)(parser_stack.get(parser_top-0)).value;
                  RESULT = new AlternativePattern(lpp, p);
               parser_result = new Symbol(28/*Pattern*/, (parser_stack.get(parser_top-2)).left, (parser_stack.get(parser_top-0)).right, RESULT);
             }
@@ -3124,7 +3124,7 @@
               Pattern RESULT = null;
                 int lppleft = (parser_stack.get(parser_top-0)).left;
                 int lppright = (parser_stack.get(parser_top-0)).right;
-                Pattern lpp = (Pattern)((Symbol) parser_stack.get(parser_top-0)).value;
+                Pattern lpp = (Pattern)(parser_stack.get(parser_top-0)).value;
                  RESULT = lpp;
               parser_result = new Symbol(28/*Pattern*/, (parser_stack.get(parser_top-0)).left, (parser_stack.get(parser_top-0)).right, RESULT);
             }
@@ -3136,7 +3136,7 @@
               SyntaxTreeNode RESULT = null;
                 int exprleft = (parser_stack.get(parser_top-0)).left;
                 int exprright = (parser_stack.get(parser_top-0)).right;
-                Expression expr = (Expression)((Symbol) parser_stack.get(parser_top-0)).value;
+                Expression expr = (Expression)(parser_stack.get(parser_top-0)).value;
                  RESULT = expr;
               parser_result = new Symbol(1/*TopLevel*/, (parser_stack.get(parser_top-1)).left, (parser_stack.get(parser_top-0)).right, RESULT);
             }
@@ -3148,7 +3148,7 @@
               SyntaxTreeNode RESULT = null;
                 int patternleft = (parser_stack.get(parser_top-0)).left;
                 int patternright = (parser_stack.get(parser_top-0)).right;
-                Pattern pattern = (Pattern)((Symbol) parser_stack.get(parser_top-0)).value;
+                Pattern pattern = (Pattern)(parser_stack.get(parser_top-0)).value;
                  RESULT = pattern;
               parser_result = new Symbol(1/*TopLevel*/, (parser_stack.get(parser_top-1)).left, (parser_stack.get(parser_top-0)).right, RESULT);
             }
@@ -3160,7 +3160,7 @@
               Object RESULT = null;
                 int start_valleft = (parser_stack.get(parser_top-1)).left;
                 int start_valright = (parser_stack.get(parser_top-1)).right;
-                SyntaxTreeNode start_val = (SyntaxTreeNode)((Symbol) parser_stack.get(parser_top-1)).value;
+                SyntaxTreeNode start_val = (SyntaxTreeNode)(parser_stack.get(parser_top-1)).value;
                 RESULT = start_val;
               parser_result = new Symbol(0/*$START*/, (parser_stack.get(parser_top-1)).left, (parser_stack.get(parser_top-0)).right, RESULT);
             }
--- a/src/java.xml/share/classes/com/sun/org/apache/xalan/internal/xsltc/compiler/util/MethodGenerator.java	Tue Nov 07 14:36:52 2017 -0800
+++ b/src/java.xml/share/classes/com/sun/org/apache/xalan/internal/xsltc/compiler/util/MethodGenerator.java	Wed Nov 08 12:27:40 2017 -0800
@@ -1,6 +1,6 @@
 /*
  * Copyright (c) 2015, 2017, Oracle and/or its affiliates. All rights reserved.
- * @LastModified: Oct 2017
+ * @LastModified: Nov 2017
  */
 /*
  * Licensed to the Apache Software Foundation (ASF) under one or more
@@ -864,7 +864,7 @@
             // iteration after it reaches the end of the InstructionList, with
             // currentHandle set to null.
             currentHandle = instructions.hasNext()
-                                    ? (InstructionHandle) instructions.next()
+                                    ? instructions.next()
                                     : null;
             Instruction inst =
                     (currentHandle != null) ? currentHandle.getInstruction()
@@ -904,14 +904,13 @@
                 // are better candidates for outlining than the current chunk.
                 if (!openChunkAtCurrLevel) {
                     nestedSubChunks = currLevelChunks;
-                    currLevelChunks = (List<InstructionHandle>)subChunkStack.pop();
+                    currLevelChunks = subChunkStack.pop();
                 }
 
                 // Get the handle for the start of this chunk (the last entry
                 // in currLevelChunks)
                 InstructionHandle chunkStart =
-                        (InstructionHandle) currLevelChunks.get(
-                                                      currLevelChunks.size()-1);
+                        currLevelChunks.get(currLevelChunks.size()-1);
 
                 int chunkEndPosition =
                         (currentHandle != null) ? currentHandle.getPosition()
@@ -940,12 +939,8 @@
 
                             // Gather all the child chunks of the current chunk
                             for (int i = 0; i < childChunkCount; i++) {
-                                InstructionHandle start =
-                                    (InstructionHandle) nestedSubChunks
-                                                            .get(i*2);
-                                InstructionHandle end =
-                                    (InstructionHandle) nestedSubChunks
-                                                            .get(i*2+1);
+                                InstructionHandle start = nestedSubChunks.get(i*2);
+                                InstructionHandle end = nestedSubChunks.get(i*2+1);
 
                                 childChunks[i] = new Chunk(start, end);
                             }
@@ -1168,7 +1163,7 @@
             for (int i = candidateChunks.size()-1;
                  i >= 0 && currentMethodSize > TARGET_METHOD_SIZE;
                  i--) {
-                Chunk chunkToOutline = (Chunk)candidateChunks.get(i);
+                Chunk chunkToOutline = candidateChunks.get(i);
 
                 methodsOutlined.add(outline(chunkToOutline.getChunkStart(),
                                             chunkToOutline.getChunkEnd(),
--- a/src/java.xml/share/classes/com/sun/org/apache/xalan/internal/xsltc/trax/SAX2DOM.java	Tue Nov 07 14:36:52 2017 -0800
+++ b/src/java.xml/share/classes/com/sun/org/apache/xalan/internal/xsltc/trax/SAX2DOM.java	Wed Nov 08 12:27:40 2017 -0800
@@ -1,6 +1,6 @@
 /*
  * Copyright (c) 2017, Oracle and/or its affiliates. All rights reserved.
- * @LastModified: Oct 2017
+ * @LastModified: Nov 2017
  */
 /*
  * Licensed to the Apache Software Foundation (ASF) under one or more
@@ -151,7 +151,7 @@
             needToSetDocumentInfo = false;
         }
 
-        final Element tmp = (Element)_document.createElementNS(namespace, qName);
+        final Element tmp = _document.createElementNS(namespace, qName);
 
         // Add namespace declarations first
         if (_namespaceDecls != null) {
--- a/src/java.xml/share/classes/com/sun/org/apache/xalan/internal/xsltc/trax/SAX2StAXEventWriter.java	Tue Nov 07 14:36:52 2017 -0800
+++ b/src/java.xml/share/classes/com/sun/org/apache/xalan/internal/xsltc/trax/SAX2StAXEventWriter.java	Wed Nov 08 12:27:40 2017 -0800
@@ -1,6 +1,5 @@
 /*
  * Copyright (c) 2005, 2017, Oracle and/or its affiliates. All rights reserved.
- * @LastModified: Oct 2017
  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
  *
  * This code is free software; you can redistribute it and/or modify it
@@ -337,8 +336,8 @@
         if (namespaces != null) {
             final int nDecls = namespaces.size();
             for (int i = 0; i < nDecls; i++) {
-                final String prefix = (String) namespaces.get(i++);
-                String uri = (String) namespaces.get(i);
+                final String prefix = namespaces.get(i++);
+                String uri = namespaces.get(i);
                 Namespace ns = createNamespace(prefix, uri);
                 if (nsMap == null) {
                     nsMap = new HashMap<>();
--- a/src/java.xml/share/classes/com/sun/org/apache/xalan/internal/xsltc/trax/TemplatesImpl.java	Tue Nov 07 14:36:52 2017 -0800
+++ b/src/java.xml/share/classes/com/sun/org/apache/xalan/internal/xsltc/trax/TemplatesImpl.java	Wed Nov 08 12:27:40 2017 -0800
@@ -1,6 +1,6 @@
 /*
  * Copyright (c) 2007, 2017, Oracle and/or its affiliates. All rights reserved.
- * @LastModified: Oct 2017
+ * @LastModified: Nov 2017
  */
 /*
  * Licensed to the Apache Software Foundation (ASF) under one or more
@@ -613,7 +613,7 @@
      * Return the thread local copy of the stylesheet DOM.
      */
     public DOM getStylesheetDOM() {
-        return (DOM)_sdom.get();
+        return _sdom.get();
     }
 
     /**
--- a/src/java.xml/share/classes/com/sun/org/apache/xalan/internal/xsltc/trax/TransformerFactoryImpl.java	Tue Nov 07 14:36:52 2017 -0800
+++ b/src/java.xml/share/classes/com/sun/org/apache/xalan/internal/xsltc/trax/TransformerFactoryImpl.java	Wed Nov 08 12:27:40 2017 -0800
@@ -1,6 +1,6 @@
 /*
  * Copyright (c) 2007, 2017, Oracle and/or its affiliates. All rights reserved.
- * @LastModified: Oct 2017
+ * @LastModified: Nov 2017
  */
 /*
  * Licensed to the Apache Software Foundation (ASF) under one or more
@@ -1518,7 +1518,7 @@
         if ( count > 0) {
             final byte[][] result = new byte[count][1];
             for (int i = 0; i < count; i++) {
-                result[i] = (byte[])bytecodes.get(i);
+                result[i] = bytecodes.get(i);
             }
 
             return result;
@@ -1612,7 +1612,7 @@
         if (count > 0) {
             final byte[][] result = new byte[count][1];
             for (int i = 0; i < count; i++) {
-                result[i] = (byte[])bytecodes.get(i);
+                result[i] = bytecodes.get(i);
             }
 
             return result;
--- a/src/java.xml/share/classes/com/sun/org/apache/xalan/internal/xsltc/trax/TransformerImpl.java	Tue Nov 07 14:36:52 2017 -0800
+++ b/src/java.xml/share/classes/com/sun/org/apache/xalan/internal/xsltc/trax/TransformerImpl.java	Wed Nov 08 12:27:40 2017 -0800
@@ -1,6 +1,6 @@
 /*
  * Copyright (c) 2007, 2017, Oracle and/or its affiliates. All rights reserved.
- * @LastModified: Oct 2017
+ * @LastModified: Nov 2017
  */
 /*
  * Licensed to the Apache Software Foundation (ASF) under one or more
@@ -407,7 +407,7 @@
         _method = (String) _properties.get(OutputKeys.METHOD);
 
         // Get encoding using getProperty() to use defaults
-        _encoding = (String) _properties.getProperty(OutputKeys.ENCODING);
+        _encoding = _properties.getProperty(OutputKeys.ENCODING);
 
         _tohFactory = TransletOutputHandlerFactory.newInstance(_useServicesMechanism);
         _tohFactory.setEncoding(_encoding);
--- a/src/java.xml/share/classes/com/sun/org/apache/xalan/internal/xsltc/trax/XSLTCSource.java	Tue Nov 07 14:36:52 2017 -0800
+++ b/src/java.xml/share/classes/com/sun/org/apache/xalan/internal/xsltc/trax/XSLTCSource.java	Wed Nov 08 12:27:40 2017 -0800
@@ -1,6 +1,6 @@
 /*
  * Copyright (c) 2017, Oracle and/or its affiliates. All rights reserved.
- * @LastModified: Oct 2017
+ * @LastModified: Nov 2017
  */
 /*
  * Licensed to the Apache Software Foundation (ASF) under one or more
@@ -94,7 +94,7 @@
     protected DOM getDOM(XSLTCDTMManager dtmManager, AbstractTranslet translet)
         throws SAXException
     {
-        SAXImpl idom = (SAXImpl)_dom.get();
+        SAXImpl idom = _dom.get();
 
         if (idom != null) {
             if (dtmManager != null) {
--- a/src/java.xml/share/classes/com/sun/org/apache/xerces/internal/dom/CoreDocumentImpl.java	Tue Nov 07 14:36:52 2017 -0800
+++ b/src/java.xml/share/classes/com/sun/org/apache/xerces/internal/dom/CoreDocumentImpl.java	Wed Nov 08 12:27:40 2017 -0800
@@ -1,6 +1,6 @@
 /*
  * Copyright (c) 2009, 2017, Oracle and/or its affiliates. All rights reserved.
- * @LastModified: Sep 2017
+ * @LastModified: Nov 2017
  */
 /*
  * Licensed to the Apache Software Foundation (ASF) under one or more
@@ -1476,7 +1476,7 @@
             num = --nodeCounter;
             nodeTable.put(node, num);
         } else {
-            Integer n = (Integer) nodeTable.get(node);
+            Integer n = nodeTable.get(node);
             if (n == null) {
                 num = --nodeCounter;
                 nodeTable.put(node, num);
--- a/src/java.xml/share/classes/com/sun/org/apache/xerces/internal/dom/DOMNormalizer.java	Tue Nov 07 14:36:52 2017 -0800
+++ b/src/java.xml/share/classes/com/sun/org/apache/xerces/internal/dom/DOMNormalizer.java	Wed Nov 08 12:27:40 2017 -0800
@@ -1,6 +1,6 @@
 /*
  * Copyright (c) 2017, Oracle and/or its affiliates. All rights reserved.
- * @LastModified: Oct 2017
+ * @LastModified: Nov 2017
  */
 /*
  * Licensed to the Apache Software Foundation (ASF) under one or more
@@ -1647,7 +1647,7 @@
         }
 
         public Augmentations getAugmentations (int attributeIndex){
-            return(Augmentations)fAugmentations.elementAt(attributeIndex);
+            return fAugmentations.elementAt(attributeIndex);
         }
 
         public Augmentations getAugmentations (String uri, String localPart){
--- a/src/java.xml/share/classes/com/sun/org/apache/xerces/internal/dom/DOMStringListImpl.java	Tue Nov 07 14:36:52 2017 -0800
+++ b/src/java.xml/share/classes/com/sun/org/apache/xerces/internal/dom/DOMStringListImpl.java	Wed Nov 08 12:27:40 2017 -0800
@@ -1,6 +1,6 @@
 /*
  * Copyright (c) 2017, Oracle and/or its affiliates. All rights reserved.
- * @LastModified: Oct 2017
+ * @LastModified: Nov 2017
  */
 /*
  * Licensed to the Apache Software Foundation (ASF) under one or more
@@ -59,7 +59,7 @@
     public String item(int index) {
         final int length = getLength();
         if (index >= 0 && index < length) {
-            return (String) fStrings.get(index);
+            return fStrings.get(index);
         }
         return null;
     }
--- a/src/java.xml/share/classes/com/sun/org/apache/xerces/internal/dom/DocumentImpl.java	Tue Nov 07 14:36:52 2017 -0800
+++ b/src/java.xml/share/classes/com/sun/org/apache/xerces/internal/dom/DocumentImpl.java	Wed Nov 08 12:27:40 2017 -0800
@@ -1,6 +1,6 @@
 /*
  * Copyright (c) 2015, 2017, Oracle and/or its affiliates. All rights reserved.
- * @LastModified: Oct 2017
+ * @LastModified: Nov 2017
  */
 /*
  * Licensed to the Apache Software Foundation (ASF) under one or more
@@ -773,7 +773,7 @@
                 // call listeners in the order in which they got registered
                 int nlsize = nl.size();
                 for (int i = 0; i < nlsize; i++) {
-                    LEntry le = (LEntry) nl.get(i);
+                    LEntry le = nl.get(i);
                     if (!le.useCapture && le.type.equals(evt.type) &&
                         nodeListeners.contains(le)) {
                         try {
--- a/src/java.xml/share/classes/com/sun/org/apache/xerces/internal/impl/XMLDTDScannerImpl.java	Tue Nov 07 14:36:52 2017 -0800
+++ b/src/java.xml/share/classes/com/sun/org/apache/xerces/internal/impl/XMLDTDScannerImpl.java	Wed Nov 08 12:27:40 2017 -0800
@@ -1,7 +1,7 @@
 /*
- * Copyright (c) 2003, 2016, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2003, 2017, Oracle and/or its affiliates. All rights reserved.
+ * @LastModified: Nov 2017
  */
-
 /*
  * Licensed to the Apache Software Foundation (ASF) under one or more
  * contributor license agreements.  See the NOTICE file distributed with
@@ -333,7 +333,7 @@
         //xxx:stax getText() is supposed to return only DTD internal subset
         //shouldn't we record position here before we go ahead ??
 
-        fEntityScanner = (XMLEntityScanner)fEntityManager.getEntityScanner();
+        fEntityScanner = fEntityManager.getEntityScanner();
         fEntityManager.setEntityHandler(this);
         fStandalone = standalone;
         //System.out.println("state"+fScannerState);
@@ -443,7 +443,7 @@
      * are recognized by this component.
      */
     public String[] getRecognizedFeatures() {
-        return (String[])(RECOGNIZED_FEATURES.clone());
+        return RECOGNIZED_FEATURES.clone();
     } // getRecognizedFeatures():String[]
 
     /**
@@ -452,7 +452,7 @@
      * are recognized by this component.
      */
     public String[] getRecognizedProperties() {
-        return (String[])(RECOGNIZED_PROPERTIES.clone());
+        return RECOGNIZED_PROPERTIES.clone();
     } // getRecognizedProperties():String[]
 
     /**
--- a/src/java.xml/share/classes/com/sun/org/apache/xerces/internal/impl/XMLErrorReporter.java	Tue Nov 07 14:36:52 2017 -0800
+++ b/src/java.xml/share/classes/com/sun/org/apache/xerces/internal/impl/XMLErrorReporter.java	Wed Nov 08 12:27:40 2017 -0800
@@ -1,5 +1,6 @@
 /*
- * Copyright (c) 2015, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2015, 2017, Oracle and/or its affiliates. All rights reserved.
+ * @LastModified: Nov 2017
  */
 /*
  * Licensed to the Apache Software Foundation (ASF) under one or more
@@ -442,7 +443,7 @@
      * are recognized by this component.
      */
     public String[] getRecognizedFeatures() {
-        return (String[])(RECOGNIZED_FEATURES.clone());
+        return RECOGNIZED_FEATURES.clone();
     } // getRecognizedFeatures():String[]
 
     /**
@@ -514,7 +515,7 @@
      * are recognized by this component.
      */
     public String[] getRecognizedProperties() {
-        return (String[])(RECOGNIZED_PROPERTIES.clone());
+        return RECOGNIZED_PROPERTIES.clone();
     } // getRecognizedProperties():String[]
 
     /**
--- a/src/java.xml/share/classes/com/sun/org/apache/xerces/internal/impl/XMLNamespaceBinder.java	Tue Nov 07 14:36:52 2017 -0800
+++ b/src/java.xml/share/classes/com/sun/org/apache/xerces/internal/impl/XMLNamespaceBinder.java	Wed Nov 08 12:27:40 2017 -0800
@@ -1,6 +1,6 @@
 /*
- * reserved comment block
- * DO NOT REMOVE OR ALTER!
+ * Copyright (c) 2003, 2017, Oracle and/or its affiliates. All rights reserved.
+ * @LastModified: Nov 2017
  */
 /*
  * Licensed to the Apache Software Foundation (ASF) under one or more
@@ -216,7 +216,7 @@
      * are recognized by this component.
      */
     public String[] getRecognizedFeatures() {
-        return (String[])(RECOGNIZED_FEATURES.clone());
+        return RECOGNIZED_FEATURES.clone();
     } // getRecognizedFeatures():String[]
 
     /**
@@ -244,7 +244,7 @@
      * are recognized by this component.
      */
     public String[] getRecognizedProperties() {
-        return (String[])(RECOGNIZED_PROPERTIES.clone());
+        return RECOGNIZED_PROPERTIES.clone();
     } // getRecognizedProperties():String[]
 
     /**
--- a/src/java.xml/share/classes/com/sun/org/apache/xerces/internal/impl/XMLScanner.java	Tue Nov 07 14:36:52 2017 -0800
+++ b/src/java.xml/share/classes/com/sun/org/apache/xerces/internal/impl/XMLScanner.java	Wed Nov 08 12:27:40 2017 -0800
@@ -1,7 +1,7 @@
 /*
- * Copyright (c) 2003, 2016, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2003, 2017, Oracle and/or its affiliates. All rights reserved.
+ * @LastModified: Nov 2017
  */
-
 /*
  * Licensed to the Apache Software Foundation (ASF) under one or more
  * contributor license agreements.  See the NOTICE file distributed with
@@ -389,7 +389,7 @@
 
         fEntityManager = (XMLEntityManager)propertyManager.getProperty(ENTITY_MANAGER);
         fEntityStore = fEntityManager.getEntityStore() ;
-        fEntityScanner = (XMLEntityScanner)fEntityManager.getEntityScanner() ;
+        fEntityScanner = fEntityManager.getEntityScanner() ;
         fSecurityManager = (XMLSecurityManager)propertyManager.getProperty(SECURITY_MANAGER);
 
         //fEntityManager.reset();
--- a/src/java.xml/share/classes/com/sun/org/apache/xerces/internal/impl/dtd/XMLDTDLoader.java	Tue Nov 07 14:36:52 2017 -0800
+++ b/src/java.xml/share/classes/com/sun/org/apache/xerces/internal/impl/dtd/XMLDTDLoader.java	Wed Nov 08 12:27:40 2017 -0800
@@ -1,6 +1,6 @@
 /*
- * reserved comment block
- * DO NOT REMOVE OR ALTER!
+ * Copyright (c) 2017, Oracle and/or its affiliates. All rights reserved.
+ * @LastModified: Nov 2017
  */
 /*
  * Licensed to the Apache Software Foundation (ASF) under one or more
@@ -195,7 +195,7 @@
      * are recognized by this component.
      */
     public String[] getRecognizedFeatures() {
-        return (String[])(LOADER_RECOGNIZED_FEATURES.clone());
+        return LOADER_RECOGNIZED_FEATURES.clone();
     } // getRecognizedFeatures():String[]
 
     /**
@@ -244,7 +244,7 @@
      * are recognized by this component.
      */
     public String[] getRecognizedProperties() {
-        return (String[])(LOADER_RECOGNIZED_PROPERTIES.clone());
+        return LOADER_RECOGNIZED_PROPERTIES.clone();
     } // getRecognizedProperties():String[]
 
     /**
--- a/src/java.xml/share/classes/com/sun/org/apache/xerces/internal/impl/dtd/XMLDTDProcessor.java	Tue Nov 07 14:36:52 2017 -0800
+++ b/src/java.xml/share/classes/com/sun/org/apache/xerces/internal/impl/dtd/XMLDTDProcessor.java	Wed Nov 08 12:27:40 2017 -0800
@@ -1,6 +1,6 @@
 /*
  * Copyright (c) 2017, Oracle and/or its affiliates. All rights reserved.
- * @LastModified: Oct 2017
+ * @LastModified: Nov 2017
  */
 /*
  * Licensed to the Apache Software Foundation (ASF) under one or more
@@ -365,7 +365,7 @@
      * are recognized by this component.
      */
     public String[] getRecognizedFeatures() {
-        return (String[])(RECOGNIZED_FEATURES.clone());
+        return RECOGNIZED_FEATURES.clone();
     } // getRecognizedFeatures():String[]
 
     /**
@@ -393,7 +393,7 @@
      * are recognized by this component.
      */
     public String[] getRecognizedProperties() {
-        return (String[])(RECOGNIZED_PROPERTIES.clone());
+        return RECOGNIZED_PROPERTIES.clone();
     } // getRecognizedProperties():String[]
 
     /**
--- a/src/java.xml/share/classes/com/sun/org/apache/xerces/internal/impl/dtd/XMLDTDValidator.java	Tue Nov 07 14:36:52 2017 -0800
+++ b/src/java.xml/share/classes/com/sun/org/apache/xerces/internal/impl/dtd/XMLDTDValidator.java	Wed Nov 08 12:27:40 2017 -0800
@@ -1,6 +1,6 @@
 /*
  * Copyright (c) 2017, Oracle and/or its affiliates. All rights reserved.
- * @LastModified: Oct 2017
+ * @LastModified: Nov 2017
  */
 /*
  * Licensed to the Apache Software Foundation (ASF) under one or more
@@ -480,7 +480,7 @@
      * are recognized by this component.
      */
     public String[] getRecognizedFeatures() {
-        return (String[])(RECOGNIZED_FEATURES.clone());
+        return RECOGNIZED_FEATURES.clone();
     } // getRecognizedFeatures():String[]
 
     /**
@@ -508,7 +508,7 @@
      * are recognized by this component.
      */
     public String[] getRecognizedProperties() {
-        return (String[])(RECOGNIZED_PROPERTIES.clone());
+        return RECOGNIZED_PROPERTIES.clone();
     } // getRecognizedProperties():String[]
 
     /**
--- a/src/java.xml/share/classes/com/sun/org/apache/xerces/internal/impl/dv/util/Base64.java	Tue Nov 07 14:36:52 2017 -0800
+++ b/src/java.xml/share/classes/com/sun/org/apache/xerces/internal/impl/dv/util/Base64.java	Wed Nov 08 12:27:40 2017 -0800
@@ -1,6 +1,6 @@
 /*
- * reserved comment block
- * DO NOT REMOVE OR ALTER!
+ * Copyright (c) 2017, Oracle and/or its affiliates. All rights reserved.
+ * @LastModified: Nov 2017
  */
 /*
  * Licensed to the Apache Software Foundation (ASF) under one or more
@@ -80,8 +80,8 @@
 
         for (int i = 52,  j = 0; i<=61; i++, j++)
             lookUpBase64Alphabet[i] = (char)('0' + j);
-        lookUpBase64Alphabet[62] = (char)'+';
-        lookUpBase64Alphabet[63] = (char)'/';
+        lookUpBase64Alphabet[62] = '+';
+        lookUpBase64Alphabet[63] = '/';
 
     }
 
--- a/src/java.xml/share/classes/com/sun/org/apache/xerces/internal/impl/dv/xs/BaseDVFactory.java	Tue Nov 07 14:36:52 2017 -0800
+++ b/src/java.xml/share/classes/com/sun/org/apache/xerces/internal/impl/dv/xs/BaseDVFactory.java	Wed Nov 08 12:27:40 2017 -0800
@@ -1,6 +1,6 @@
 /*
- * reserved comment block
- * DO NOT REMOVE OR ALTER!
+ * Copyright (c) 2017, Oracle and/or its affiliates. All rights reserved.
+ * @LastModified: Nov 2017
  */
 /*
  * Licensed to the Apache Software Foundation (ASF) under one or more
@@ -69,7 +69,7 @@
      * @return      a hashtable which contains all built-in simple types
      */
     public SymbolHash getBuiltInTypes() {
-        return (SymbolHash)fBaseTypes.makeClone();
+        return fBaseTypes.makeClone();
     }
 
     /**
--- a/src/java.xml/share/classes/com/sun/org/apache/xerces/internal/impl/dv/xs/ExtendedSchemaDVFactoryImpl.java	Tue Nov 07 14:36:52 2017 -0800
+++ b/src/java.xml/share/classes/com/sun/org/apache/xerces/internal/impl/dv/xs/ExtendedSchemaDVFactoryImpl.java	Wed Nov 08 12:27:40 2017 -0800
@@ -1,6 +1,6 @@
 /*
- * reserved comment block
- * DO NOT REMOVE OR ALTER!
+ * Copyright (c) 2017, Oracle and/or its affiliates. All rights reserved.
+ * @LastModified: Nov 2017
  */
 /*
  * Licensed to the Apache Software Foundation (ASF) under one or more
@@ -80,6 +80,6 @@
      * @return      a hashtable which contains all built-in simple types
      */
     public SymbolHash getBuiltInTypes() {
-        return (SymbolHash)fBuiltInTypes.makeClone();
+        return fBuiltInTypes.makeClone();
     }
 }
--- a/src/java.xml/share/classes/com/sun/org/apache/xerces/internal/impl/dv/xs/FullDVFactory.java	Tue Nov 07 14:36:52 2017 -0800
+++ b/src/java.xml/share/classes/com/sun/org/apache/xerces/internal/impl/dv/xs/FullDVFactory.java	Wed Nov 08 12:27:40 2017 -0800
@@ -1,6 +1,6 @@
 /*
- * reserved comment block
- * DO NOT REMOVE OR ALTER!
+ * Copyright (c) 2017, Oracle and/or its affiliates. All rights reserved.
+ * @LastModified: Nov 2017
  */
 /*
  * Licensed to the Apache Software Foundation (ASF) under one or more
@@ -67,7 +67,7 @@
      * @return      a hashtable which contains all built-in simple types
      */
     public SymbolHash getBuiltInTypes() {
-        return (SymbolHash)fFullTypes.makeClone();
+        return fFullTypes.makeClone();
     }
 
     // create all built-in types
--- a/src/java.xml/share/classes/com/sun/org/apache/xerces/internal/impl/dv/xs/SchemaDVFactoryImpl.java	Tue Nov 07 14:36:52 2017 -0800
+++ b/src/java.xml/share/classes/com/sun/org/apache/xerces/internal/impl/dv/xs/SchemaDVFactoryImpl.java	Wed Nov 08 12:27:40 2017 -0800
@@ -1,6 +1,6 @@
 /*
- * reserved comment block
- * DO NOT REMOVE OR ALTER!
+ * Copyright (c) 2017, Oracle and/or its affiliates. All rights reserved.
+ * @LastModified: Nov 2017
  */
 /*
  * Licensed to the Apache Software Foundation (ASF) under one or more
@@ -71,7 +71,7 @@
      * @return      a hashtable which contains all built-in simple types
      */
     public SymbolHash getBuiltInTypes() {
-        return (SymbolHash)fBuiltInTypes.makeClone();
+        return fBuiltInTypes.makeClone();
     }
 
 }//SchemaDVFactoryImpl
--- a/src/java.xml/share/classes/com/sun/org/apache/xerces/internal/impl/dv/xs/XSSimpleTypeDecl.java	Tue Nov 07 14:36:52 2017 -0800
+++ b/src/java.xml/share/classes/com/sun/org/apache/xerces/internal/impl/dv/xs/XSSimpleTypeDecl.java	Wed Nov 08 12:27:40 2017 -0800
@@ -1,6 +1,6 @@
 /*
  * Copyright (c) 2017, Oracle and/or its affiliates. All rights reserved.
- * @LastModified: Oct 2017
+ * @LastModified: Nov 2017
  */
 /*
  * Licensed to the Apache Software Foundation (ASF) under one or more
@@ -235,7 +235,7 @@
     };
 
     protected static TypeValidator[] getGDVs() {
-        return (TypeValidator[])gDVs.clone();
+        return gDVs.clone();
     }
     private TypeValidator[] fDVs = gDVs;
     protected void setDVs(TypeValidator[] dvs) {
@@ -434,7 +434,7 @@
         fAnnotations = annotations;
 
         fVariety = VARIETY_LIST;
-        fItemType = (XSSimpleTypeDecl)itemType;
+        fItemType = itemType;
         fValidationDV = DV_LIST;
         fFacetsDefined = FACET_WHITESPACE;
         fFixedFacet = FACET_WHITESPACE;
@@ -544,7 +544,7 @@
         fAnnotations = annotations;
 
         fVariety = VARIETY_LIST;
-        fItemType = (XSSimpleTypeDecl)itemType;
+        fItemType = itemType;
         fValidationDV = DV_LIST;
         fFacetsDefined = FACET_WHITESPACE;
         fFixedFacet = FACET_WHITESPACE;
@@ -883,9 +883,9 @@
                 fEnumerationSize = 0;
                 for (int i = 0; i < size; i++) {
                     if (enumNSDecls != null)
-                        ctx.setNSContext((NamespaceContext)enumNSDecls.get(i));
+                        ctx.setNSContext(enumNSDecls.get(i));
                     try {
-                        ValidatedInfo info = getActualEnumValue((String)enumVals.get(i), ctx, null);
+                        ValidatedInfo info = getActualEnumValue(enumVals.get(i), ctx, null);
                         // check 4.3.5.c0 must: enumeration values from the value space of base
                         fEnumeration[fEnumerationSize++] = info;
                     } catch (InvalidDatatypeValueException ide) {
@@ -2604,7 +2604,7 @@
                 ((ancestorNS == null && type.getNamespace() == null) ||
                         (ancestorNS != null && ancestorNS.equals(type.getNamespace())))) &&   // compare with ancestor
                         type != fAnySimpleType) {  // reached anySimpleType
-            type = (XSTypeDefinition)type.getBaseType();
+            type = type.getBaseType();
         }
 
         return type != fAnySimpleType;
--- a/src/java.xml/share/classes/com/sun/org/apache/xerces/internal/impl/xs/AttributePSVImpl.java	Tue Nov 07 14:36:52 2017 -0800
+++ b/src/java.xml/share/classes/com/sun/org/apache/xerces/internal/impl/xs/AttributePSVImpl.java	Wed Nov 08 12:27:40 2017 -0800
@@ -1,5 +1,6 @@
 /*
  * Copyright (c) 2017, Oracle and/or its affiliates. All rights reserved.
+ * @LastModified: Nov 2017
  */
 /*
  * Licensed to the Apache Software Foundation (ASF) under one or more
@@ -81,8 +82,7 @@
         fValidity = attrPSVI.getValidity();
         if (attrPSVI instanceof AttributePSVImpl) {
             final AttributePSVImpl attrPSVIImpl = (AttributePSVImpl) attrPSVI;
-            fErrors = (attrPSVIImpl.fErrors != null) ?
-                    (String[]) attrPSVIImpl.fErrors.clone() : null;
+            fErrors = (attrPSVIImpl.fErrors != null) ? attrPSVIImpl.fErrors.clone() : null;
         }
         else {
             final StringList errorCodes = attrPSVI.getErrorCodes();
--- a/src/java.xml/share/classes/com/sun/org/apache/xerces/internal/impl/xs/ElementPSVImpl.java	Tue Nov 07 14:36:52 2017 -0800
+++ b/src/java.xml/share/classes/com/sun/org/apache/xerces/internal/impl/xs/ElementPSVImpl.java	Wed Nov 08 12:27:40 2017 -0800
@@ -1,5 +1,6 @@
 /*
  * Copyright (c) 2017, Oracle and/or its affiliates. All rights reserved.
+ * @LastModified: Nov 2017
  */
 /*
  * Licensed to the Apache Software Foundation (ASF) under one or more
@@ -105,8 +106,7 @@
         fValidationContext = elementPSVI.getValidationContext();
         if (elementPSVI instanceof ElementPSVImpl) {
             final ElementPSVImpl elementPSVIImpl = (ElementPSVImpl) elementPSVI;
-            fErrors = (elementPSVIImpl.fErrors != null) ?
-                    (String[]) elementPSVIImpl.fErrors.clone() : null;
+            fErrors = (elementPSVIImpl.fErrors != null) ? elementPSVIImpl.fErrors.clone() : null;
             elementPSVIImpl.copySchemaInformationTo(this);
         }
         else {
--- a/src/java.xml/share/classes/com/sun/org/apache/xerces/internal/impl/xs/SubstitutionGroupHandler.java	Tue Nov 07 14:36:52 2017 -0800
+++ b/src/java.xml/share/classes/com/sun/org/apache/xerces/internal/impl/xs/SubstitutionGroupHandler.java	Wed Nov 08 12:27:40 2017 -0800
@@ -1,6 +1,6 @@
 /*
  * Copyright (c) 2015, 2017, Oracle and/or its affiliates. All rights reserved.
- * @LastModified: Oct 2017
+ * @LastModified: Nov 2017
  */
 /*
  * Licensed to the Apache Software Foundation (ASF) under one or more
@@ -284,7 +284,7 @@
         short dMethod, bMethod, dSubMethod, bSubMethod;
         for (int i = group.size()-1, j; i >= 0; i--) {
             // Check whether this element is blocked. If so, ignore it.
-            XSElementDecl sub = (XSElementDecl)group.get(i);
+            XSElementDecl sub = group.get(i);
             if (!getDBMethods(sub.fType, element.fType, methods))
                 continue;
             // Remember derivation methods and blocks from the types
@@ -307,7 +307,7 @@
         // Convert to an array
         OneSubGroup[] ret = new OneSubGroup[newGroup.size()];
         for (int i = newGroup.size()-1; i >= 0; i--) {
-            ret[i] = (OneSubGroup)newGroup.get(i);
+            ret[i] = newGroup.get(i);
         }
         // Store the potential sub group
         fSubGroupsB.put(element, ret);
--- a/src/java.xml/share/classes/com/sun/org/apache/xerces/internal/impl/xs/XMLSchemaValidator.java	Tue Nov 07 14:36:52 2017 -0800
+++ b/src/java.xml/share/classes/com/sun/org/apache/xerces/internal/impl/xs/XMLSchemaValidator.java	Wed Nov 08 12:27:40 2017 -0800
@@ -1,6 +1,6 @@
 /*
  * Copyright (c) 2006, 2017, Oracle and/or its affiliates. All rights reserved.
- * @LastModified: Oct 2017
+ * @LastModified: Nov 2017
  */
 /*
  * Licensed to the Apache Software Foundation (ASF) under one or more
@@ -572,7 +572,7 @@
      * are recognized by this component.
      */
     public String[] getRecognizedFeatures() {
-        return (String[]) (RECOGNIZED_FEATURES.clone());
+        return RECOGNIZED_FEATURES.clone();
     } // getRecognizedFeatures():String[]
 
     /**
@@ -599,7 +599,7 @@
      * are recognized by this component.
      */
     public String[] getRecognizedProperties() {
-        return (String[]) (RECOGNIZED_PROPERTIES.clone());
+        return RECOGNIZED_PROPERTIES.clone();
     } // getRecognizedProperties():String[]
 
     /**
@@ -3037,7 +3037,7 @@
                     // 5 Let [Definition:]  the wild IDs be the set of all attribute information item to which clause 3.2 applied and whose validation resulted in a context-determined declaration of mustFind or no context-determined declaration at all, and whose [local name] and [namespace name] resolve (as defined by QName resolution (Instance) (3.15.4)) to an attribute declaration whose {type definition} is or is derived from ID. Then all of the following must be true:
                     // 5.1 There must be no more than one item in wild IDs.
                     if (currDecl.fType.getTypeCategory() == XSTypeDefinition.SIMPLE_TYPE
-                        && ((XSSimpleType) currDecl.fType).isIDType()) {
+                        && (currDecl.fType).isIDType()) {
                         if (wildcardIDName != null) {
                             reportSchemaError(
                                 "cvc-complex-type.5.1",
@@ -4120,7 +4120,7 @@
 
         private ShortList getItemValueTypeAt(int index) {
             if (fUseItemValueTypeVector) {
-                return (ShortList) fItemValueTypes.get(index);
+                return fItemValueTypes.get(index);
             }
             return fItemValueType;
         }
@@ -4245,8 +4245,7 @@
 
             // verify references
             // get the key store corresponding (if it exists):
-            fKeyValueStore =
-                (ValueStoreBase) fValueStoreCache.fGlobalIDConstraintMap.get(
+            fKeyValueStore = fValueStoreCache.fGlobalIDConstraintMap.get(
                     ((KeyRef) fIdentityConstraint).getKey());
 
             if (fKeyValueStore == null) {
--- a/src/java.xml/share/classes/com/sun/org/apache/xerces/internal/impl/xs/XSComplexTypeDecl.java	Tue Nov 07 14:36:52 2017 -0800
+++ b/src/java.xml/share/classes/com/sun/org/apache/xerces/internal/impl/xs/XSComplexTypeDecl.java	Wed Nov 08 12:27:40 2017 -0800
@@ -1,6 +1,6 @@
 /*
- * reserved comment block
- * DO NOT REMOVE OR ALTER!
+ * Copyright (c) 2017, Oracle and/or its affiliates. All rights reserved.
+ * @LastModified: Nov 2017
  */
 /*
  * Licensed to the Apache Software Foundation (ASF) under one or more
@@ -260,7 +260,7 @@
                   (ancestorNS != null && ancestorNS.equals(type.getNamespace())))) &&   // compare with ancestor
                type != SchemaGrammar.fAnySimpleType &&  // reached anySimpleType
                type != SchemaGrammar.fAnyType) {        // reached anyType
-            type = (XSTypeDefinition)type.getBaseType();
+            type = type.getBaseType();
         }
 
         return type != SchemaGrammar.fAnySimpleType &&
--- a/src/java.xml/share/classes/com/sun/org/apache/xerces/internal/impl/xs/XSConstraints.java	Tue Nov 07 14:36:52 2017 -0800
+++ b/src/java.xml/share/classes/com/sun/org/apache/xerces/internal/impl/xs/XSConstraints.java	Wed Nov 08 12:27:40 2017 -0800
@@ -1,6 +1,6 @@
 /*
  * Copyright (c) 2017, Oracle and/or its affiliates. All rights reserved.
- * @LastModified: Oct 2017
+ * @LastModified: Nov 2017
  */
 /*
  * Licensed to the Apache Software Foundation (ASF) under one or more
@@ -165,8 +165,7 @@
             else
                 return false;
         }
-        return checkSimpleDerivation((XSSimpleType)derived,
-                (XSSimpleType)base, block);
+        return checkSimpleDerivation(derived, (XSSimpleType)base, block);
     }
 
     /**
@@ -177,7 +176,7 @@
         // if derived is anyType, then it's valid only if base is anyType too
         if (derived == SchemaGrammar.fAnyType)
             return derived == base;
-        return checkComplexDerivation((XSComplexTypeDecl)derived, base, block);
+        return checkComplexDerivation(derived, base, block);
     }
 
     /**
@@ -1237,7 +1236,7 @@
         int count = children.size();
         try {
             for (int i = 0; i < count; i++) {
-                XSParticleDecl particle1 = (XSParticleDecl)children.get(i);
+                XSParticleDecl particle1 = children.get(i);
                 particleValidRestriction(particle1, dSGHandler, wildcard, null, false);
 
             }
@@ -1271,9 +1270,9 @@
         int current = 0;
         label: for (int i = 0; i<count1; i++) {
 
-            XSParticleDecl particle1 = (XSParticleDecl)dChildren.get(i);
+            XSParticleDecl particle1 = dChildren.get(i);
             for (int j = current; j<count2; j++) {
-                XSParticleDecl particle2 = (XSParticleDecl)bChildren.get(j);
+                XSParticleDecl particle2 = bChildren.get(j);
                 current +=1;
                 try {
                     particleValidRestriction(particle1, dSGHandler, particle2, bSGHandler);
@@ -1289,7 +1288,7 @@
 
         // Now, see if there are some elements in the base we didn't match up
         for (int j=current; j < count2; j++) {
-            XSParticleDecl particle2 = (XSParticleDecl)bChildren.get(j);
+            XSParticleDecl particle2 = bChildren.get(j);
             if (!particle2.emptiable()) {
                 throw new XMLSchemaException("rcase-Recurse.2", null);
             }
@@ -1319,10 +1318,10 @@
         boolean foundIt[] = new boolean[count2];
 
         label: for (int i = 0; i<count1; i++) {
-            XSParticleDecl particle1 = (XSParticleDecl)dChildren.get(i);
+            XSParticleDecl particle1 = dChildren.get(i);
 
             for (int j = 0; j<count2; j++) {
-                XSParticleDecl particle2 = (XSParticleDecl)bChildren.get(j);
+                XSParticleDecl particle2 = bChildren.get(j);
                 try {
                     particleValidRestriction(particle1, dSGHandler, particle2, bSGHandler);
                     if (foundIt[j])
@@ -1341,7 +1340,7 @@
 
         // Now, see if there are some elements in the base we didn't match up
         for (int j=0; j < count2; j++) {
-            XSParticleDecl particle2 = (XSParticleDecl)bChildren.get(j);
+            XSParticleDecl particle2 = bChildren.get(j);
             if (!foundIt[j] && !particle2.emptiable()) {
                 throw new XMLSchemaException("rcase-RecurseUnordered.2", null);
             }
@@ -1370,9 +1369,9 @@
         int current = 0;
         label: for (int i = 0; i<count1; i++) {
 
-            XSParticleDecl particle1 = (XSParticleDecl)dChildren.get(i);
+            XSParticleDecl particle1 = dChildren.get(i);
             for (int j = current; j<count2; j++) {
-                XSParticleDecl particle2 = (XSParticleDecl)bChildren.get(j);
+                XSParticleDecl particle2 = bChildren.get(j);
                 current +=1;
                 try {
                     // IHR: go back one element on b list because the next element may match
@@ -1425,9 +1424,9 @@
 
         label: for (int i = 0; i<count1; i++) {
 
-            XSParticleDecl particle1 = (XSParticleDecl)dChildren.get(i);
+            XSParticleDecl particle1 = dChildren.get(i);
             for (int j = 0; j<count2; j++) {
-                XSParticleDecl particle2 = (XSParticleDecl)bChildren.get(j);
+                XSParticleDecl particle2 = bChildren.get(j);
                 try {
                     particleValidRestriction(particle1, dSGHandler, particle2, bSGHandler);
                     continue label;
--- a/src/java.xml/share/classes/com/sun/org/apache/xerces/internal/impl/xs/XSGrammarBucket.java	Tue Nov 07 14:36:52 2017 -0800
+++ b/src/java.xml/share/classes/com/sun/org/apache/xerces/internal/impl/xs/XSGrammarBucket.java	Wed Nov 08 12:27:40 2017 -0800
@@ -1,6 +1,6 @@
 /*
  * Copyright (c) 2015, 2017, Oracle and/or its affiliates. All rights reserved.
- * @LastModified: Oct 2017
+ * @LastModified: Nov 2017
  */
 /*
  * Licensed to the Apache Software Foundation (ASF) under one or more
@@ -52,7 +52,7 @@
     public SchemaGrammar getGrammar(String namespace) {
         if (namespace == null)
             return fNoNSGrammar;
-        return (SchemaGrammar)fGrammarRegistry.get(namespace);
+        return fGrammarRegistry.get(namespace);
     }
 
     /**
@@ -191,7 +191,7 @@
                 // we add them to the vector
                 if(gs == null) continue;
                 for (int j = gs.size() - 1; j >= 0; j--) {
-                    sg2 = (SchemaGrammar)gs.get(j);
+                    sg2 = gs.get(j);
                     if (!grammars.contains(sg2))
                         grammars.add(sg2);
                 }
--- a/src/java.xml/share/classes/com/sun/org/apache/xerces/internal/impl/xs/models/CMBuilder.java	Tue Nov 07 14:36:52 2017 -0800
+++ b/src/java.xml/share/classes/com/sun/org/apache/xerces/internal/impl/xs/models/CMBuilder.java	Wed Nov 08 12:27:40 2017 -0800
@@ -1,5 +1,6 @@
 /*
- * Copyright (c) 2006, 2009, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2006, 2017, Oracle and/or its affiliates. All rights reserved.
+ * @LastModified: Nov 2017
  */
 /*
  * Licensed to the Apache Software Foundation (ASF) under one or more
@@ -457,7 +458,7 @@
             XSModelGroupImpl group = (XSModelGroupImpl) particle.fValue;
             if (minOccurs != 1 || maxOccurs != 1) {
                 if (group.fParticleCount == 1) {
-                    XSParticleDecl particle2 = (XSParticleDecl) group.fParticles[0];
+                    XSParticleDecl particle2 = group.fParticles[0];
                     short type2 = particle2.fType;
                     return ((type2 == XSParticleDecl.PARTICLE_ELEMENT ||
                             type2 == XSParticleDecl.PARTICLE_WILDCARD) &&
--- a/src/java.xml/share/classes/com/sun/org/apache/xerces/internal/impl/xs/traversers/XSAttributeChecker.java	Tue Nov 07 14:36:52 2017 -0800
+++ b/src/java.xml/share/classes/com/sun/org/apache/xerces/internal/impl/xs/traversers/XSAttributeChecker.java	Wed Nov 08 12:27:40 2017 -0800
@@ -1,6 +1,6 @@
 /*
  * Copyright (c) 2016, 2017, Oracle and/or its affiliates. All rights reserved.
- * @LastModified: Oct 2017
+ * @LastModified: Nov 2017
  */
 /*
  * Licensed to the Apache Software Foundation (ASF) under one or more
@@ -1607,7 +1607,7 @@
             // for each of the values
             int count = values.size();
             for (int i = 1; i < count; i += 2) {
-                elName = (String)values.get(i);
+                elName = values.get(i);
                 try {
                     // and validate it using the XSSimpleType
                     // REVISIT: what would be the proper validation context?
@@ -1824,7 +1824,7 @@
         values[pos++] = value;
     }
     OneAttr get(String key) {
-        OneAttr ret = (OneAttr)items.get(key);
+        OneAttr ret = items.get(key);
         return ret;
     }
 }
--- a/src/java.xml/share/classes/com/sun/org/apache/xerces/internal/impl/xs/traversers/XSDHandler.java	Tue Nov 07 14:36:52 2017 -0800
+++ b/src/java.xml/share/classes/com/sun/org/apache/xerces/internal/impl/xs/traversers/XSDHandler.java	Wed Nov 08 12:27:40 2017 -0800
@@ -1,6 +1,6 @@
 /*
  * Copyright (c) 2007, 2017, Oracle and/or its affiliates. All rights reserved.
- * @LastModified: Oct 2017
+ * @LastModified: Nov 2017
  */
 /*
  * Licensed to the Apache Software Foundation (ASF) under one or more
@@ -2581,7 +2581,7 @@
         List<SchemaGrammar> gs;
         for (int i = 0; i < currGrammars.size(); i++) {
             // get the grammar
-            sg1 = (SchemaGrammar)currGrammars.get(i);
+            sg1 = currGrammars.get(i);
             // we need to add grammars imported by sg1 too
             gs = sg1.getImportedGrammars();
             // for all grammars imported by sg2, but not in the vector
@@ -2591,7 +2591,7 @@
             }
 
             for (int j = gs.size() - 1; j >= 0; j--) {
-                sg2 = (SchemaGrammar)gs.get(j);
+                sg2 = gs.get(j);
                 if (!currGrammars.contains(sg2)) {
                     currGrammars.add(sg2);
                 }
@@ -2606,7 +2606,7 @@
         final XSDDescription desc = new XSDDescription();
 
         for (int i=0; i < length; i++) {
-            final SchemaGrammar sg1 = (SchemaGrammar)grammars.get(i);
+            final SchemaGrammar sg1 = grammars.get(i);
             desc.setNamespace(sg1.getTargetNamespace());
 
             final SchemaGrammar sg2 = findGrammar(desc, false);
@@ -2622,7 +2622,7 @@
         final int size = components.size();
         final XSDDescription desc = new XSDDescription();
         for (int i=0; i<size; i++) {
-            XSObject component = (XSObject) components.get(i);
+            XSObject component = components.get(i);
             if (!canAddComponent(component, desc)) {
                 return false;
             }
@@ -2763,7 +2763,7 @@
         final int size = importedSrc.size();
 
         for (int i=0; i<size; i++) {
-            final SchemaGrammar sg = (SchemaGrammar) importedSrc.get(i);
+            final SchemaGrammar sg =  importedSrc.get(i);
             if (!containedImportedGrammar(importedDst, sg)) {
                 importedDst.add(sg);
             }
@@ -3361,7 +3361,7 @@
         SchemaGrammar sg;
 
         for (int i=0; i<size; i++) {
-            sg = (SchemaGrammar) importedGrammar.get(i);
+            sg =  importedGrammar.get(i);
             if (null2EmptyString(sg.getTargetNamespace()).equals(null2EmptyString(grammar.getTargetNamespace()))) {
                 return true;
             }
@@ -3766,7 +3766,7 @@
         }
         else {
             Element collidingElem = (Element)objElem;
-            XSDocumentInfo collidingElemSchema = (XSDocumentInfo)registry_sub.get(qName);
+            XSDocumentInfo collidingElemSchema = registry_sub.get(qName);
             if (collidingElem == currComp) return;
             Element elemParent = null;
             XSDocumentInfo redefinedSchema = null;
--- a/src/java.xml/share/classes/com/sun/org/apache/xerces/internal/impl/xs/traversers/XSDSimpleTypeTraverser.java	Tue Nov 07 14:36:52 2017 -0800
+++ b/src/java.xml/share/classes/com/sun/org/apache/xerces/internal/impl/xs/traversers/XSDSimpleTypeTraverser.java	Wed Nov 08 12:27:40 2017 -0800
@@ -1,6 +1,6 @@
 /*
  * Copyright (c) 2017, Oracle and/or its affiliates. All rights reserved.
- * @LastModified: Oct 2017
+ * @LastModified: Nov 2017
  */
 /*
  * Licensed to the Apache Software Foundation (ASF) under one or more
@@ -296,7 +296,7 @@
             // for each qname in the list
             for (int i = 0; i < size; i++) {
                 // get the type decl
-                dv = findDTValidator(child, name, (QName)memberTypes.get(i),
+                dv = findDTValidator(child, name, memberTypes.get(i),
                         XSConstants.DERIVATION_UNION, schemaDoc);
                 if (dv != null) {
                     // if it's a union, expand it
@@ -389,7 +389,7 @@
                     annotations == null? null : new XSObjectListImpl(annotations, annotations.length));
         }
         else if (union) {
-            XSSimpleType[] memberDecls = (XSSimpleType[]) dTValidators.toArray(new XSSimpleType[dTValidators.size()]);
+            XSSimpleType[] memberDecls = dTValidators.toArray(new XSSimpleType[dTValidators.size()]);
             newDecl = fSchemaHandler.fDVFactory.createTypeUnion(name, schemaDoc.fTargetNamespace, (short)finalProperty, memberDecls,
                     annotations == null? null : new XSObjectListImpl(annotations, annotations.length));
         }
--- a/src/java.xml/share/classes/com/sun/org/apache/xerces/internal/impl/xs/traversers/XSDUniqueOrKeyTraverser.java	Tue Nov 07 14:36:52 2017 -0800
+++ b/src/java.xml/share/classes/com/sun/org/apache/xerces/internal/impl/xs/traversers/XSDUniqueOrKeyTraverser.java	Wed Nov 08 12:27:40 2017 -0800
@@ -1,6 +1,6 @@
 /*
- * reserved comment block
- * DO NOT REMOVE OR ALTER!
+ * Copyright (c) 2017, Oracle and/or its affiliates. All rights reserved.
+ * @LastModified: Nov 2017
  */
 /*
  * Licensed to the Apache Software Foundation (ASF) under one or more
@@ -61,7 +61,7 @@
             return;
         }
 
-        UniqueOrKey uniqueOrKey = null;
+        UniqueOrKey uniqueOrKey;
         if(DOMUtil.getLocalName(uElem).equals(SchemaSymbols.ELT_UNIQUE)) {
             uniqueOrKey = new UniqueOrKey(schemaDoc.fTargetNamespace, uName, element.fName, IdentityConstraint.IC_UNIQUE);
         } else {
@@ -89,7 +89,7 @@
             if (fSchemaHandler.fTolerateDuplicates) {
                 if (idc != null) {
                     if (idc instanceof UniqueOrKey) {
-                        uniqueOrKey = (UniqueOrKey) uniqueOrKey;
+                        uniqueOrKey = (UniqueOrKey)idc;
                     }
                 }
                 fSchemaHandler.addIDConstraintDecl(uniqueOrKey);
--- a/src/java.xml/share/classes/com/sun/org/apache/xerces/internal/impl/xs/util/XSGrammarPool.java	Tue Nov 07 14:36:52 2017 -0800
+++ b/src/java.xml/share/classes/com/sun/org/apache/xerces/internal/impl/xs/util/XSGrammarPool.java	Wed Nov 08 12:27:40 2017 -0800
@@ -1,6 +1,6 @@
 /*
  * Copyright (c) 2017, Oracle and/or its affiliates. All rights reserved.
- * @LastModified: Oct 2017
+ * @LastModified: Nov 2017
  */
 /*
  * Licensed to the Apache Software Foundation (ASF) under one or more
@@ -64,7 +64,7 @@
         if (size == 0) {
             return toXSModel(new SchemaGrammar[0], schemaVersion);
         }
-        SchemaGrammar[] gs = (SchemaGrammar[])list.toArray(new SchemaGrammar[size]);
+        SchemaGrammar[] gs = list.toArray(new SchemaGrammar[size]);
         return toXSModel(gs, schemaVersion);
     }
 
--- a/src/java.xml/share/classes/com/sun/org/apache/xerces/internal/jaxp/validation/SimpleXMLSchema.java	Tue Nov 07 14:36:52 2017 -0800
+++ b/src/java.xml/share/classes/com/sun/org/apache/xerces/internal/jaxp/validation/SimpleXMLSchema.java	Wed Nov 08 12:27:40 2017 -0800
@@ -1,6 +1,6 @@
 /*
- * reserved comment block
- * DO NOT REMOVE OR ALTER!
+ * Copyright (c) 2017, Oracle and/or its affiliates. All rights reserved.
+ * @LastModified: Nov 2017
  */
 /*
  * Licensed to the Apache Software Foundation (ASF) under one or more
@@ -52,7 +52,7 @@
 
     public Grammar[] retrieveInitialGrammarSet(String grammarType) {
         return XMLGrammarDescription.XML_SCHEMA.equals(grammarType) ?
-                (Grammar[]) fGrammars.clone() : ZERO_LENGTH_GRAMMAR_ARRAY;
+                fGrammars.clone() : ZERO_LENGTH_GRAMMAR_ARRAY;
     }
 
     public void cacheGrammars(String grammarType, Grammar[] grammars) {}
--- a/src/java.xml/share/classes/com/sun/org/apache/xerces/internal/jaxp/validation/SoftReferenceGrammarPool.java	Tue Nov 07 14:36:52 2017 -0800
+++ b/src/java.xml/share/classes/com/sun/org/apache/xerces/internal/jaxp/validation/SoftReferenceGrammarPool.java	Wed Nov 08 12:27:40 2017 -0800
@@ -1,6 +1,6 @@
 /*
  * Copyright (c) 2017, Oracle and/or its affiliates. All rights reserved.
- * @LastModified: Oct 2017
+ * @LastModified: Nov 2017
  */
 /*
  * Licensed to the Apache Software Foundation (ASF) under one or more
@@ -191,7 +191,7 @@
             int hash = hashCode(desc);
             int index = (hash & 0x7FFFFFFF) % fGrammars.length;
             for (Entry entry = fGrammars[index]; entry != null; entry = entry.next) {
-                Grammar tempGrammar = (Grammar) entry.grammar.get();
+                Grammar tempGrammar = entry.grammar.get();
                 /** If the soft reference has been cleared, remove this entry from the pool. */
                 if (tempGrammar == null) {
                     removeEntry(entry);
@@ -241,7 +241,7 @@
             int hash = hashCode(desc);
             int index = (hash & 0x7FFFFFFF) % fGrammars.length;
             for (Entry entry = fGrammars[index]; entry != null ; entry = entry.next) {
-                Grammar tempGrammar = (Grammar) entry.grammar.get();
+                Grammar tempGrammar = entry.grammar.get();
                 /** If the soft reference has been cleared, remove this entry from the pool. */
                 if (tempGrammar == null) {
                     removeEntry(entry);
@@ -363,7 +363,7 @@
         }
         --fGrammarCount;
         entry.grammar.entry = null;
-        return (Grammar) entry.grammar.get();
+        return entry.grammar.get();
     }
 
     /**
--- a/src/java.xml/share/classes/com/sun/org/apache/xerces/internal/parsers/AbstractDOMParser.java	Tue Nov 07 14:36:52 2017 -0800
+++ b/src/java.xml/share/classes/com/sun/org/apache/xerces/internal/parsers/AbstractDOMParser.java	Wed Nov 08 12:27:40 2017 -0800
@@ -1,6 +1,6 @@
 /*
  * Copyright (c) 2017, Oracle and/or its affiliates. All rights reserved.
- * @LastModified: Oct 2017
+ * @LastModified: Nov 2017
  */
 /*
  * Licensed to the Apache Software Foundation (ASF) under one or more
@@ -1931,7 +1931,7 @@
         if (DEBUG_EVENTS) {
             System.out.println ("==>internalEntityDecl: "+name);
             if (DEBUG_BASEURI) {
-                System.out.println ("   baseURI:"+ (String)fBaseURIStack.peek ());
+                System.out.println ("   baseURI:"+ fBaseURIStack.peek ());
             }
         }
         // internal subset string
@@ -1966,7 +1966,7 @@
             EntityImpl entity = (EntityImpl)entities.getNamedItem (name);
             if (entity == null) {
                 entity = (EntityImpl)fDocumentImpl.createEntity (name);
-                entity.setBaseURI ((String)fBaseURIStack.peek ());
+                entity.setBaseURI (fBaseURIStack.peek ());
                 entities.setNamedItem (entity);
             }
         }
@@ -1988,7 +1988,7 @@
             }
             if (!found) {
                 int entityIndex =
-                fDeferredDocumentImpl.createDeferredEntity (name, null, null, null, (String)fBaseURIStack.peek ());
+                fDeferredDocumentImpl.createDeferredEntity (name, null, null, null, fBaseURIStack.peek ());
                 fDeferredDocumentImpl.appendChild (fDocumentTypeIndex, entityIndex);
             }
         }
--- a/src/java.xml/share/classes/com/sun/org/apache/xerces/internal/util/DOMEntityResolverWrapper.java	Tue Nov 07 14:36:52 2017 -0800
+++ b/src/java.xml/share/classes/com/sun/org/apache/xerces/internal/util/DOMEntityResolverWrapper.java	Wed Nov 08 12:27:40 2017 -0800
@@ -1,6 +1,6 @@
 /*
- * reserved comment block
- * DO NOT REMOVE OR ALTER!
+ * Copyright (c) 2017, Oracle and/or its affiliates. All rights reserved.
+ * @LastModified: Nov 2017
  */
 /*
  * Licensed to the Apache Software Foundation (ASF) under one or more
@@ -142,7 +142,7 @@
                     xmlInputSource.setCharacterStream(charStream);
                 }
                 else if (byteStream != null) {
-                    xmlInputSource.setByteStream((InputStream) byteStream);
+                    xmlInputSource.setByteStream(byteStream);
                 }
                 else if (data != null && data.length() != 0) {
                     xmlInputSource.setCharacterStream(new StringReader(data));
--- a/src/java.xml/share/classes/com/sun/org/apache/xerces/internal/util/SymbolHash.java	Tue Nov 07 14:36:52 2017 -0800
+++ b/src/java.xml/share/classes/com/sun/org/apache/xerces/internal/util/SymbolHash.java	Wed Nov 08 12:27:40 2017 -0800
@@ -1,6 +1,6 @@
 /*
- * reserved comment block
- * DO NOT REMOVE OR ALTER!
+ * Copyright (c) 2017, Oracle and/or its affiliates. All rights reserved.
+ * @LastModified: Nov 2017
  */
 /*
  * Licensed to the Apache Software Foundation (ASF) under one or more
@@ -191,7 +191,7 @@
     public SymbolHash makeClone() {
         SymbolHash newTable = new SymbolHash(fTableSize);
         newTable.fNum = fNum;
-        newTable.fHashMultipliers = fHashMultipliers != null ? (int[]) fHashMultipliers.clone() : null;
+        newTable.fHashMultipliers = fHashMultipliers != null ? fHashMultipliers.clone() : null;
         for (int i = 0; i < fTableSize; i++) {
             if (fBuckets[i] != null) {
                 newTable.fBuckets[i] = fBuckets[i].makeClone();
--- a/src/java.xml/share/classes/com/sun/org/apache/xerces/internal/xinclude/XIncludeHandler.java	Tue Nov 07 14:36:52 2017 -0800
+++ b/src/java.xml/share/classes/com/sun/org/apache/xerces/internal/xinclude/XIncludeHandler.java	Wed Nov 08 12:27:40 2017 -0800
@@ -1,8 +1,6 @@
 /*
  * Copyright (c) 2006, 2017, Oracle and/or its affiliates. All rights reserved.
- * @LastModified: Oct 2017
- * @modifiedBy: Oracle Inc.
- * @modifiedOn: Nov 2015, Sept 2017
+ * @LastModified: Nov 2017
  */
 /*
  * Licensed to the Apache Software Foundation (ASF) under one or more
@@ -621,7 +619,7 @@
      */
     @Override
     public String[] getRecognizedFeatures() {
-        return (String[])(RECOGNIZED_FEATURES.clone());
+        return RECOGNIZED_FEATURES.clone();
     } // getRecognizedFeatures():String[]
 
     /**
@@ -658,7 +656,7 @@
      */
     @Override
     public String[] getRecognizedProperties() {
-        return (String[])(RECOGNIZED_PROPERTIES.clone());
+        return RECOGNIZED_PROPERTIES.clone();
     } // getRecognizedProperties():String[]
 
     /**
@@ -1772,7 +1770,7 @@
 
                 // Parse the XPointer expression
                 try {
-                    ((XPointerProcessor)fXPtrProcessor).parseXPointer(xpointer);
+                    fXPtrProcessor.parseXPointer(xpointer);
 
                 } catch (XNIException ex) {
                     // report the XPointer error as a resource error
@@ -1803,7 +1801,7 @@
                 // If the xpointer attribute is present
                 if (xpointer != null ) {
                         // and it was not resolved
-                        if (!((XPointerProcessor)fXPtrProcessor).isXPointerResolved()) {
+                        if (!fXPtrProcessor.isXPointerResolved()) {
                         Locale locale = (fErrorReporter != null) ? fErrorReporter.getLocale() : null;
                         String reason = fXIncludeMessageFormatter.formatMessage(locale, "XPointerResolutionUnsuccessful", null);
                         reportResourceError("XMLResourceError", new Object[] {href, reason});
@@ -2841,9 +2839,9 @@
         fLiteralSystemID.pop();
         fExpandedSystemID.pop();
         fBaseURIScope.pop();
-        fCurrentBaseURI.setBaseSystemId((String)fBaseURI.peek());
-        fCurrentBaseURI.setLiteralSystemId((String)fLiteralSystemID.peek());
-        fCurrentBaseURI.setExpandedSystemId((String)fExpandedSystemID.peek());
+        fCurrentBaseURI.setBaseSystemId(fBaseURI.peek());
+        fCurrentBaseURI.setLiteralSystemId(fLiteralSystemID.peek());
+        fCurrentBaseURI.setExpandedSystemId(fExpandedSystemID.peek());
     }
 
     // The following methods are used for language processing
@@ -2864,7 +2862,7 @@
     public String restoreLanguage() {
         fLanguageStack.pop();
         fLanguageScope.pop();
-        return (String) fLanguageStack.peek();
+        return fLanguageStack.peek();
     }
 
     /**
--- a/src/java.xml/share/classes/com/sun/org/apache/xml/internal/dtm/ref/DTMManagerDefault.java	Tue Nov 07 14:36:52 2017 -0800
+++ b/src/java.xml/share/classes/com/sun/org/apache/xml/internal/dtm/ref/DTMManagerDefault.java	Wed Nov 08 12:27:40 2017 -0800
@@ -1,6 +1,6 @@
 /*
- * reserved comment block
- * DO NOT REMOVE OR ALTER!
+ * Copyright (c) 2017, Oracle and/or its affiliates. All rights reserved.
+ * @LastModified: Nov 2017
  */
 /*
  * Licensed to the Apache Software Foundation (ASF) under one or more
@@ -571,7 +571,7 @@
                                 handle=dtm.getAttributeNode(handle,node.getNamespaceURI(),node.getLocalName());
       }
       else
-                                handle = ((DOM2DTM)dtm).getHandleOfNode(node);
+                                handle = dtm.getHandleOfNode(node);
 
       if(DTM.NULL == handle)
         throw new RuntimeException(XMLMessages.createXMLMessage(XMLErrorResources.ER_COULD_NOT_RESOLVE_NODE, null)); //"Could not resolve the node to a handle!");
--- a/src/java.xml/share/classes/com/sun/org/apache/xml/internal/dtm/ref/DTMNodeList.java	Tue Nov 07 14:36:52 2017 -0800
+++ b/src/java.xml/share/classes/com/sun/org/apache/xml/internal/dtm/ref/DTMNodeList.java	Wed Nov 08 12:27:40 2017 -0800
@@ -1,6 +1,6 @@
 /*
- * reserved comment block
- * DO NOT REMOVE OR ALTER!
+ * Copyright (c) 2017, Oracle and/or its affiliates. All rights reserved.
+ * @LastModified: Nov 2017
  */
 /*
  * Licensed to the Apache Software Foundation (ASF) under one or more
@@ -74,7 +74,7 @@
         if (dtmIterator != null) {
             int pos = dtmIterator.getCurrentPos();
             try {
-                m_iter=(DTMIterator)dtmIterator.cloneWithReset();
+                m_iter = dtmIterator.cloneWithReset();
             } catch(CloneNotSupportedException cnse) {
                 m_iter = dtmIterator;
             }
--- a/src/java.xml/share/classes/com/sun/org/apache/xml/internal/dtm/ref/DTMNodeProxy.java	Tue Nov 07 14:36:52 2017 -0800
+++ b/src/java.xml/share/classes/com/sun/org/apache/xml/internal/dtm/ref/DTMNodeProxy.java	Wed Nov 08 12:27:40 2017 -0800
@@ -1,6 +1,6 @@
 /*
  * Copyright (c) 2017, Oracle and/or its affiliates. All rights reserved.
- * @LastModified: Oct 2017
+ * @LastModified: Nov 2017
  */
 /*
  * Licensed to the Apache Software Foundation (ASF) under one or more
@@ -335,7 +335,7 @@
   @Override
   public final short getNodeType()
   {
-    return (short) dtm.getNodeType(node);
+    return dtm.getNodeType(node);
   }
 
   /**
--- a/src/java.xml/share/classes/com/sun/org/apache/xml/internal/serialize/BaseMarkupSerializer.java	Tue Nov 07 14:36:52 2017 -0800
+++ b/src/java.xml/share/classes/com/sun/org/apache/xml/internal/serialize/BaseMarkupSerializer.java	Wed Nov 08 12:27:40 2017 -0800
@@ -1,6 +1,6 @@
 /*
  * Copyright (c) 2015, 2017, Oracle and/or its affiliates. All rights reserved.
- * @LastModified: Oct 2017
+ * @LastModified: Nov 2017
  */
 /*
  * Licensed to the Apache Software Foundation (ASF) under one or more
@@ -1902,7 +1902,7 @@
         }
         for ( int i = _elementStateCount ; i > 0 ; --i ) {
             if ( _elementStates[ i ].prefixes != null ) {
-                prefix = (String) _elementStates[ i ].prefixes.get( namespaceURI );
+                prefix = _elementStates[ i ].prefixes.get( namespaceURI );
                 if ( prefix != null )
                     return prefix;
             }
--- a/src/java.xml/share/classes/com/sun/org/apache/xml/internal/serializer/NamespaceMappings.java	Tue Nov 07 14:36:52 2017 -0800
+++ b/src/java.xml/share/classes/com/sun/org/apache/xml/internal/serializer/NamespaceMappings.java	Wed Nov 08 12:27:40 2017 -0800
@@ -1,6 +1,6 @@
 /*
  * Copyright (c) 2017, Oracle and/or its affiliates. All rights reserved.
- * @LastModified: Oct 2017
+ * @LastModified: Nov 2017
  */
 /*
  * Licensed to the Apache Software Foundation (ASF) under one or more
@@ -250,7 +250,7 @@
         {
             if (m_nodeStack.isEmpty())
                 return;
-            MappingRecord map = (MappingRecord)(m_nodeStack.peek());
+            MappingRecord map = m_nodeStack.peek();
             int depth = map.m_declarationDepth;
             if (depth < elemDepth)
                 return;
@@ -258,7 +258,7 @@
              * so get rid of it
              */
 
-            map = (MappingRecord) m_nodeStack.pop();
+            map = m_nodeStack.pop();
             final String prefix = map.m_prefix;
             popNamespace(prefix);
             if (saxHandler != null)
--- a/src/java.xml/share/classes/com/sun/org/apache/xml/internal/serializer/ToStream.java	Tue Nov 07 14:36:52 2017 -0800
+++ b/src/java.xml/share/classes/com/sun/org/apache/xml/internal/serializer/ToStream.java	Wed Nov 08 12:27:40 2017 -0800
@@ -1,6 +1,6 @@
 /*
  * Copyright (c) 2006, 2017, Oracle and/or its affiliates. All rights reserved.
- * @LastModified: Oct 2017
+ * @LastModified: Nov 2017
  */
 /*
  * Licensed to the Apache Software Foundation (ASF) under one or more
@@ -1667,7 +1667,7 @@
             startClean =
                 accumDefaultEscape(
                     m_writer,
-                    (char)ch,
+                    ch,
                     i,
                     chars,
                     end,
@@ -2739,9 +2739,8 @@
                     // whitspace separated "{uri1}local1 {uri2}local2 ..."
                     if (i != 0)
                         sb.append(' ');
-                    final String uri = (String) URI_and_localNames.get(i);
-                    final String localName =
-                        (String) URI_and_localNames.get(i + 1);
+                    final String uri = URI_and_localNames.get(i);
+                    final String localName = URI_and_localNames.get(i + 1);
                     if (uri != null) {
                         // If there is no URI don't put this in, just the localName then.
                         sb.append('{');
--- a/src/java.xml/share/classes/com/sun/org/apache/xpath/internal/NodeSet.java	Tue Nov 07 14:36:52 2017 -0800
+++ b/src/java.xml/share/classes/com/sun/org/apache/xpath/internal/NodeSet.java	Wed Nov 08 12:27:40 2017 -0800
@@ -1,6 +1,6 @@
 /*
- * reserved comment block
- * DO NOT REMOVE OR ALTER!
+ * Copyright (c) 2017, Oracle and/or its affiliates. All rights reserved.
+ * @LastModified: Nov 2017
  */
 /*
  * Licensed to the Apache Software Foundation (ASF) under one or more
@@ -350,7 +350,7 @@
 
     runTo(index);
 
-    return (Node) this.elementAt(index);
+    return this.elementAt(index);
   }
 
   /**
@@ -582,7 +582,7 @@
 
     for (i = end; i >= start; i--)
     {
-      Node child = (Node) elementAt(i);
+      Node child = elementAt(i);
 
       if (child == node)
       {
@@ -648,7 +648,7 @@
 
       for (i = size - 1; i >= 0; i--)
       {
-        Node child = (Node) elementAt(i);
+        Node child = elementAt(i);
 
         if (child == node)
         {
--- a/src/java.xml/share/classes/com/sun/org/apache/xpath/internal/VariableStack.java	Tue Nov 07 14:36:52 2017 -0800
+++ b/src/java.xml/share/classes/com/sun/org/apache/xpath/internal/VariableStack.java	Wed Nov 08 12:27:40 2017 -0800
@@ -1,6 +1,6 @@
 /*
- * reserved comment block
- * DO NOT REMOVE OR ALTER!
+ * Copyright (c) 2017, Oracle and/or its affiliates. All rights reserved.
+ * @LastModified: Nov 2017
  */
 /*
  * Licensed to the Apache Software Foundation (ASF) under one or more
@@ -63,8 +63,8 @@
     VariableStack vs = (VariableStack) super.clone();
 
     // I *think* I can get away with a shallow clone here?
-    vs._stackFrames = (XObject[]) _stackFrames.clone();
-    vs._links = (int[]) _links.clone();
+    vs._stackFrames = _stackFrames.clone();
+    vs._links = _links.clone();
 
     return vs;
   }
--- a/src/java.xml/share/classes/com/sun/org/apache/xpath/internal/axes/LocPathIterator.java	Tue Nov 07 14:36:52 2017 -0800
+++ b/src/java.xml/share/classes/com/sun/org/apache/xpath/internal/axes/LocPathIterator.java	Wed Nov 08 12:27:40 2017 -0800
@@ -1,6 +1,6 @@
 /*
- * reserved comment block
- * DO NOT REMOVE OR ALTER!
+ * Copyright (c) 2017, Oracle and/or its affiliates. All rights reserved.
+ * @LastModified: Nov 2017
  */
 /*
  * Licensed to the Apache Software Foundation (ASF) under one or more
@@ -294,7 +294,7 @@
   public int asNode(XPathContext xctxt)
     throws javax.xml.transform.TransformerException
   {
-    DTMIterator iter = (DTMIterator)m_clones.getInstance();
+    DTMIterator iter = m_clones.getInstance();
 
     int current = xctxt.getCurrentNode();
 
--- a/src/java.xml/share/classes/com/sun/org/apache/xpath/internal/compiler/Lexer.java	Tue Nov 07 14:36:52 2017 -0800
+++ b/src/java.xml/share/classes/com/sun/org/apache/xpath/internal/compiler/Lexer.java	Wed Nov 08 12:27:40 2017 -0800
@@ -1,6 +1,6 @@
 /*
  * Copyright (c) 2017, Oracle and/or its affiliates. All rights reserved.
- * @LastModified: Oct 2017
+ * @LastModified: Nov 2017
  */
 /*
  * Licensed to the Apache Software Foundation (ASF) under one or more
@@ -470,7 +470,7 @@
 
     try
     {
-      Integer itok = (Integer) Keywords.getKeyWord(key);
+      Integer itok = Keywords.getKeyWord(key);
 
       tok = (null != itok) ? itok.intValue() : 0;
     }
@@ -587,8 +587,7 @@
       try
       {
         if (prefix.length() > 0)
-          uName = ((PrefixResolver) m_namespaceContext).getNamespaceForPrefix(
-            prefix);
+          uName = m_namespaceContext.getNamespaceForPrefix(prefix);
         else
         {
 
@@ -608,9 +607,7 @@
           }
           else
           {
-            uName =
-              ((PrefixResolver) m_namespaceContext).getNamespaceForPrefix(
-                prefix);
+            uName = m_namespaceContext.getNamespaceForPrefix(prefix);
           }
         }
       }
--- a/src/java.xml/share/classes/com/sun/org/apache/xpath/internal/compiler/OpMap.java	Tue Nov 07 14:36:52 2017 -0800
+++ b/src/java.xml/share/classes/com/sun/org/apache/xpath/internal/compiler/OpMap.java	Wed Nov 08 12:27:40 2017 -0800
@@ -1,6 +1,6 @@
 /*
- * reserved comment block
- * DO NOT REMOVE OR ALTER!
+ * Copyright (c) 2017, Oracle and/or its affiliates. All rights reserved.
+ * @LastModified: Nov 2017
  */
 /*
  * Licensed to the Apache Software Foundation (ASF) under one or more
@@ -446,7 +446,7 @@
     // int index = (argLenOfStep == 3) ? m_opMap[opPosOfStep+5]
     //                                  : ((argLenOfStep == 1) ? -3 : -2);
     if (index >= 0)
-      return (String) m_tokenQueue.elementAt(index).toString();
+      return m_tokenQueue.elementAt(index).toString();
     else if (OpCodes.ELEMWILDCARD == index)
       return NodeTest.WILD;
     else
--- a/src/java.xml/share/classes/com/sun/org/apache/xpath/internal/jaxp/JAXPExtensionsProvider.java	Tue Nov 07 14:36:52 2017 -0800
+++ b/src/java.xml/share/classes/com/sun/org/apache/xpath/internal/jaxp/JAXPExtensionsProvider.java	Wed Nov 08 12:27:40 2017 -0800
@@ -1,6 +1,6 @@
 /*
  * Copyright (c) 2013, 2017, Oracle and/or its affiliates. All rights reserved.
- * @LastModified: Oct 2017
+ * @LastModified: Nov 2017
  */
 /*
  * Licensed to the Apache Software Foundation (ASF) under one or more
@@ -137,7 +137,7 @@
                 if ( argument instanceof XNodeSet ) {
                     argList.add ( i, ((XNodeSet)argument).nodelist() );
                 } else if ( argument instanceof XObject ) {
-                    Object passedArgument = ((XObject)argument).object();
+                    Object passedArgument = argument.object();
                     argList.add ( i, passedArgument );
                 } else {
                     argList.add ( i, argument );
@@ -188,7 +188,7 @@
                 if ( argument instanceof XNodeSet ) {
                     argList.add ( i, ((XNodeSet)argument).nodelist() );
                 } else if ( argument instanceof XObject ) {
-                    Object passedArgument = ((XObject)argument).object();
+                    Object passedArgument = argument.object();
                     argList.add ( i, passedArgument );
                 } else {
                     argList.add ( i, argument );
--- a/src/java.xml/share/classes/javax/xml/xpath/XPathException.java	Tue Nov 07 14:36:52 2017 -0800
+++ b/src/java.xml/share/classes/javax/xml/xpath/XPathException.java	Wed Nov 08 12:27:40 2017 -0800
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2003, 2013, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2003, 2017, 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
@@ -110,7 +110,7 @@
             throws IOException
     {
         ObjectOutputStream.PutField fields = out.putFields();
-        fields.put("cause", (Throwable) super.getCause());
+        fields.put("cause", super.getCause());
         out.writeFields();
     }
 
--- a/src/java.xml/share/classes/org/w3c/dom/bootstrap/DOMImplementationRegistry.java	Tue Nov 07 14:36:52 2017 -0800
+++ b/src/java.xml/share/classes/org/w3c/dom/bootstrap/DOMImplementationRegistry.java	Wed Nov 08 12:27:40 2017 -0800
@@ -213,8 +213,7 @@
         int size = sources.size();
         String name = null;
         for (int i = 0; i < size; i++) {
-            DOMImplementationSource source =
-                (DOMImplementationSource) sources.get(i);
+            DOMImplementationSource source = sources.get(i);
             DOMImplementation impl = source.getDOMImplementation(features);
             if (impl != null) {
                 return impl;
@@ -238,8 +237,7 @@
         final List<DOMImplementation> implementations = new ArrayList<>();
         int size = sources.size();
         for (int i = 0; i < size; i++) {
-            DOMImplementationSource source =
-                (DOMImplementationSource) sources.get(i);
+            DOMImplementationSource source = sources.get(i);
             DOMImplementationList impls =
                 source.getDOMImplementationList(features);
             for (int j = 0; j < impls.getLength(); j++) {
@@ -251,8 +249,7 @@
                 public DOMImplementation item(final int index) {
                     if (index >= 0 && index < implementations.size()) {
                         try {
-                            return (DOMImplementation)
-                                implementations.get(index);
+                            return implementations.get(index);
                         } catch (IndexOutOfBoundsException e) {
                             return null;
                         }
--- a/src/java.xml/share/classes/org/xml/sax/helpers/NamespaceSupport.java	Tue Nov 07 14:36:52 2017 -0800
+++ b/src/java.xml/share/classes/org/xml/sax/helpers/NamespaceSupport.java	Wed Nov 08 12:27:40 2017 -0800
@@ -666,7 +666,7 @@
             // Start by looking in the cache, and
             // return immediately if the name
             // is already known in this content
-            name = (String[])table.get(qName);
+            name = table.get(qName);
             if (name != null) {
                 return name;
             }
@@ -703,7 +703,7 @@
                 if ("".equals(prefix)) {
                     uri = defaultNS;
                 } else {
-                    uri = (String)prefixTable.get(prefix);
+                    uri = prefixTable.get(prefix);
                 }
                 if (uri == null
                         || (!isAttribute && "xmlns".equals (prefix))) {
@@ -735,7 +735,7 @@
             } else if (prefixTable == null) {
                 return null;
             } else {
-                return (String)prefixTable.get(prefix);
+                return prefixTable.get(prefix);
             }
         }
 
@@ -755,7 +755,7 @@
             if (uriTable == null) {
                 return null;
             } else {
-                return (String)uriTable.get(uri);
+                return uriTable.get(uri);
             }
         }
 
--- a/src/jdk.scripting.nashorn/share/classes/jdk/nashorn/internal/objects/NativeDebug.java	Tue Nov 07 14:36:52 2017 -0800
+++ b/src/jdk.scripting.nashorn/share/classes/jdk/nashorn/internal/objects/NativeDebug.java	Wed Nov 08 12:27:40 2017 -0800
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2010, 2016, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2010, 2017, 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,7 +36,7 @@
 import jdk.nashorn.internal.objects.annotations.Where;
 import jdk.nashorn.internal.runtime.Context;
 import jdk.nashorn.internal.runtime.JSType;
-import jdk.nashorn.internal.runtime.PropertyListeners;
+import jdk.nashorn.internal.runtime.PropertySwitchPoints;
 import jdk.nashorn.internal.runtime.PropertyMap;
 import jdk.nashorn.internal.runtime.Scope;
 import jdk.nashorn.internal.runtime.ScriptFunction;
@@ -244,7 +244,7 @@
      */
     @Function(attributes = Attribute.NOT_ENUMERABLE, where = Where.CONSTRUCTOR)
     public static int getListenerCount(final Object self, final Object obj) {
-        return (obj instanceof ScriptObject) ? PropertyListeners.getListenerCount((ScriptObject) obj) : 0;
+        return (obj instanceof ScriptObject) ? PropertySwitchPoints.getSwitchPointCount((ScriptObject) obj) : 0;
     }
 
     /**
@@ -260,8 +260,8 @@
 
         out.println("ScriptObject count " + ScriptObject.getCount());
         out.println("Scope count " + Scope.getScopeCount());
-        out.println("ScriptObject listeners added " + PropertyListeners.getListenersAdded());
-        out.println("ScriptObject listeners removed " + PropertyListeners.getListenersRemoved());
+        out.println("Property SwitchPoints added " + PropertySwitchPoints.getSwitchPointsAdded());
+        out.println("Property SwitchPoints invalidated " + PropertySwitchPoints.getSwitchPointsInvalidated());
         out.println("ScriptFunction constructor calls " + ScriptFunction.getConstructorCount());
         out.println("ScriptFunction invokes " + ScriptFunction.getInvokes());
         out.println("ScriptFunction allocations " + ScriptFunction.getAllocations());
--- a/src/jdk.scripting.nashorn/share/classes/jdk/nashorn/internal/objects/NativeFunction.java	Tue Nov 07 14:36:52 2017 -0800
+++ b/src/jdk.scripting.nashorn/share/classes/jdk/nashorn/internal/objects/NativeFunction.java	Wed Nov 08 12:27:40 2017 -0800
@@ -35,6 +35,7 @@
 import java.util.List;
 import jdk.dynalink.linker.support.Lookup;
 import jdk.nashorn.api.scripting.JSObject;
+import jdk.nashorn.api.scripting.ScriptObjectMirror;
 import jdk.nashorn.internal.objects.annotations.Attribute;
 import jdk.nashorn.internal.objects.annotations.Constructor;
 import jdk.nashorn.internal.objects.annotations.Function;
@@ -101,8 +102,13 @@
 
         if (self instanceof ScriptFunction) {
             return ScriptRuntime.apply((ScriptFunction)self, thiz, args);
+        } else if (self instanceof ScriptObjectMirror) {
+            return ((JSObject)self).call(thiz, args);
         } else if (self instanceof JSObject) {
-            return ((JSObject)self).call(thiz, args);
+            final Global global = Global.instance();
+            final Object result = ((JSObject) self).call(ScriptObjectMirror.wrap(thiz, global),
+                    ScriptObjectMirror.wrapArray(args, global));
+            return ScriptObjectMirror.unwrap(result, global);
         }
         throw new AssertionError("Should not reach here");
     }
--- a/src/jdk.scripting.nashorn/share/classes/jdk/nashorn/internal/runtime/PropertyListeners.java	Tue Nov 07 14:36:52 2017 -0800
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,260 +0,0 @@
-/*
- * Copyright (c) 2010, 2014, Oracle and/or its affiliates. All rights reserved.
- * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
- *
- * This code is free software; you can redistribute it and/or modify it
- * under the terms of the GNU General Public License version 2 only, as
- * published by the Free Software Foundation.  Oracle designates this
- * particular file as subject to the "Classpath" exception as provided
- * by Oracle in the LICENSE file that accompanied this code.
- *
- * This code is distributed in the hope that it will be useful, but WITHOUT
- * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
- * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
- * version 2 for more details (a copy is included in the LICENSE file that
- * accompanied this code).
- *
- * You should have received a copy of the GNU General Public License version
- * 2 along with this work; if not, write to the Free Software Foundation,
- * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
- *
- * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
- * or visit www.oracle.com if you need additional information or have any
- * questions.
- */
-
-package jdk.nashorn.internal.runtime;
-
-import java.util.Map;
-import java.util.Set;
-import java.util.WeakHashMap;
-import java.util.concurrent.atomic.LongAdder;
-
-/**
- * Helper class to manage property listeners and notification.
- */
-public class PropertyListeners {
-
-    private Map<Object, WeakPropertyMapSet> listeners;
-
-    // These counters are updated in debug mode
-    private static LongAdder listenersAdded;
-    private static LongAdder listenersRemoved;
-
-    static {
-        if (Context.DEBUG) {
-            listenersAdded = new LongAdder();
-            listenersRemoved = new LongAdder();
-        }
-    }
-
-    /**
-     * Copy constructor
-     * @param listener listener to copy
-     */
-    PropertyListeners(final PropertyListeners listener) {
-        if (listener != null && listener.listeners != null) {
-            this.listeners = new WeakHashMap<>();
-            // We need to copy the nested weak sets in order to avoid concurrent modification issues, see JDK-8146274
-            synchronized (listener) {
-                for (final Map.Entry<Object, WeakPropertyMapSet> entry : listener.listeners.entrySet()) {
-                    this.listeners.put(entry.getKey(), new WeakPropertyMapSet(entry.getValue()));
-                }
-            }
-        }
-    }
-
-    /**
-     * Return aggregate listeners added to all PropertyListenerManagers
-     * @return the listenersAdded
-     */
-    public static long getListenersAdded() {
-        return listenersAdded.longValue();
-    }
-
-    /**
-     * Return aggregate listeners removed from all PropertyListenerManagers
-     * @return the listenersRemoved
-     */
-    public static long getListenersRemoved() {
-        return listenersRemoved.longValue();
-    }
-
-    /**
-     * Return number of listeners added to a ScriptObject.
-     * @param obj the object
-     * @return the listener count
-     */
-    public static int getListenerCount(final ScriptObject obj) {
-        return obj.getMap().getListenerCount();
-    }
-
-    /**
-     * Return the number of listeners added to this PropertyListeners instance.
-     * @return the listener count;
-     */
-    public int getListenerCount() {
-        return listeners == null ? 0 : listeners.size();
-    }
-
-    // Property listener management methods
-
-    /**
-     * Add {@code propertyMap} as property listener to {@code listeners} using key {@code key} by
-     * creating and returning a new {@code PropertyListeners} instance.
-     *
-     * @param listeners the original property listeners instance, may be null
-     * @param key the property key
-     * @param propertyMap the property map
-     * @return the new property map
-     */
-    public static PropertyListeners addListener(final PropertyListeners listeners, final String key, final PropertyMap propertyMap) {
-        final PropertyListeners newListeners;
-        if (listeners == null || !listeners.containsListener(key, propertyMap)) {
-            newListeners = new PropertyListeners(listeners);
-            newListeners.addListener(key, propertyMap);
-            return newListeners;
-        }
-        return listeners;
-    }
-
-    /**
-     * Checks whether {@code propertyMap} is registered as listener with {@code key}.
-     *
-     * @param key the property key
-     * @param propertyMap the property map
-     * @return true if property map is registered with property key
-     */
-    synchronized boolean containsListener(final String key, final PropertyMap propertyMap) {
-        if (listeners == null) {
-            return false;
-        }
-        final WeakPropertyMapSet set = listeners.get(key);
-        return set != null && set.contains(propertyMap);
-    }
-
-    /**
-     * Add a property listener to this object.
-     *
-     * @param propertyMap The property listener that is added.
-     */
-    synchronized final void addListener(final String key, final PropertyMap propertyMap) {
-        if (Context.DEBUG) {
-            listenersAdded.increment();
-        }
-        if (listeners == null) {
-            listeners = new WeakHashMap<>();
-        }
-
-        WeakPropertyMapSet set = listeners.get(key);
-        if (set == null) {
-            set = new WeakPropertyMapSet();
-            listeners.put(key, set);
-        }
-        if (!set.contains(propertyMap)) {
-            set.add(propertyMap);
-        }
-    }
-
-    /**
-     * A new property is being added.
-     *
-     * @param prop The new Property added.
-     */
-    public synchronized void propertyAdded(final Property prop) {
-        if (listeners != null) {
-            final WeakPropertyMapSet set = listeners.get(prop.getKey());
-            if (set != null) {
-                for (final PropertyMap propertyMap : set.elements()) {
-                    propertyMap.propertyAdded(prop, false);
-                }
-                listeners.remove(prop.getKey());
-                if (Context.DEBUG) {
-                    listenersRemoved.increment();
-                }
-            }
-        }
-    }
-
-    /**
-     * An existing property is being deleted.
-     *
-     * @param prop The property being deleted.
-     */
-    public synchronized void propertyDeleted(final Property prop) {
-        if (listeners != null) {
-            final WeakPropertyMapSet set = listeners.get(prop.getKey());
-            if (set != null) {
-                for (final PropertyMap propertyMap : set.elements()) {
-                    propertyMap.propertyDeleted(prop, false);
-                }
-                listeners.remove(prop.getKey());
-                if (Context.DEBUG) {
-                    listenersRemoved.increment();
-                }
-            }
-        }
-    }
-
-    /**
-     * An existing Property is being replaced with a new Property.
-     *
-     * @param oldProp The old property that is being replaced.
-     * @param newProp The new property that replaces the old property.
-     *
-     */
-    public synchronized void propertyModified(final Property oldProp, final Property newProp) {
-        if (listeners != null) {
-            final WeakPropertyMapSet set = listeners.get(oldProp.getKey());
-            if (set != null) {
-                for (final PropertyMap propertyMap : set.elements()) {
-                    propertyMap.propertyModified(oldProp, newProp, false);
-                }
-                listeners.remove(oldProp.getKey());
-                if (Context.DEBUG) {
-                    listenersRemoved.increment();
-                }
-            }
-        }
-    }
-
-    /**
-     * Callback for when a proto is changed
-     */
-    public synchronized void protoChanged() {
-        if (listeners != null) {
-            for (final WeakPropertyMapSet set : listeners.values()) {
-                for (final PropertyMap propertyMap : set.elements()) {
-                    propertyMap.protoChanged(false);
-                }
-            }
-            listeners.clear();
-        }
-    }
-
-    private static class WeakPropertyMapSet {
-
-        private final WeakHashMap<PropertyMap, Boolean> map;
-
-        WeakPropertyMapSet() {
-            this.map = new WeakHashMap<>();
-        }
-
-        WeakPropertyMapSet(final WeakPropertyMapSet set) {
-            this.map = new WeakHashMap<>(set.map);
-        }
-
-        void add(final PropertyMap propertyMap) {
-            map.put(propertyMap, Boolean.TRUE);
-        }
-
-        boolean contains(final PropertyMap propertyMap) {
-            return map.containsKey(propertyMap);
-        }
-
-        Set<PropertyMap> elements() {
-            return map.keySet();
-        }
-
-    }
-}
--- a/src/jdk.scripting.nashorn/share/classes/jdk/nashorn/internal/runtime/PropertyMap.java	Tue Nov 07 14:36:52 2017 -0800
+++ b/src/jdk.scripting.nashorn/share/classes/jdk/nashorn/internal/runtime/PropertyMap.java	Wed Nov 08 12:27:40 2017 -0800
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2010, 2016, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2010, 2017, 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
@@ -40,9 +40,9 @@
 import java.util.Arrays;
 import java.util.BitSet;
 import java.util.Collection;
-import java.util.HashMap;
 import java.util.Iterator;
 import java.util.NoSuchElementException;
+import java.util.Set;
 import java.util.WeakHashMap;
 import java.util.concurrent.atomic.LongAdder;
 import jdk.nashorn.internal.runtime.options.Options;
@@ -95,17 +95,14 @@
      * property map should only be used if it the same as the actual prototype map. */
     private transient SharedPropertyMap sharedProtoMap;
 
-    /** {@link SwitchPoint}s for gets on inherited properties. */
-    private transient HashMap<Object, SwitchPoint> protoSwitches;
-
     /** History of maps, used to limit map duplication. */
     private transient WeakHashMap<Property, Reference<PropertyMap>> history;
 
     /** History of prototypes, used to limit map duplication. */
     private transient WeakHashMap<ScriptObject, SoftReference<PropertyMap>> protoHistory;
 
-    /** property listeners */
-    private transient PropertyListeners listeners;
+    /** SwitchPoints for properties inherited form this map */
+    private transient PropertySwitchPoints propertySwitchPoints;
 
     private transient BitSet freeSlots;
 
@@ -147,8 +144,8 @@
         this.fieldCount   = fieldCount;
         this.fieldMaximum = propertyMap.fieldMaximum;
         this.className    = propertyMap.className;
-        // We inherit the parent property listeners instance. It will be cloned when a new listener is added.
-        this.listeners    = propertyMap.listeners;
+        // We inherit the parent property propertySwitchPoints instance. It will be cloned when a new listener is added.
+        this.propertySwitchPoints = propertyMap.propertySwitchPoints;
         this.freeSlots    = propertyMap.freeSlots;
         this.sharedProtoMap = propertyMap.sharedProtoMap;
         this.softReferenceDerivationLimit = softReferenceDerivationLimit;
@@ -245,142 +242,70 @@
     }
 
     /**
-     * Get the number of listeners of this map
+     * Get the number of property SwitchPoints of this map
      *
-     * @return the number of listeners
+     * @return the number of property SwitchPoints
      */
-    public int getListenerCount() {
-        return listeners == null ? 0 : listeners.getListenerCount();
-    }
-
-    /**
-     * Add {@code listenerMap} as a listener to this property map for the given {@code key}.
-     *
-     * @param key the property name
-     * @param listenerMap the listener map
-     */
-    public void addListener(final String key, final PropertyMap listenerMap) {
-        if (listenerMap != this) {
-            // We need to clone listener instance when adding a new listener since we share
-            // the listeners instance with our parent maps that don't need to see the new listener.
-            listeners = PropertyListeners.addListener(listeners, key, listenerMap);
-        }
+    public int getSwitchPointCount() {
+        return propertySwitchPoints == null ? 0 : propertySwitchPoints.getSwitchPointCount();
     }
 
     /**
-     * A new property is being added.
+     * Add a property switchpoint to this property map for the given {@code key}.
      *
-     * @param property The new Property added.
-     * @param isSelf was the property added to this map?
+     * @param key the property name
+     * @param switchPoint the switchpoint
      */
-    public void propertyAdded(final Property property, final boolean isSelf) {
-        if (!isSelf) {
-            invalidateProtoSwitchPoint(property.getKey());
-        }
-        if (listeners != null) {
-            listeners.propertyAdded(property);
-        }
+    public void addSwitchPoint(final String key, final SwitchPoint switchPoint) {
+        // We need to clone listener instance when adding a new listener since we share
+        // the propertySwitchPoints instance with our parent maps that don't need to see the new listener.
+        propertySwitchPoints = PropertySwitchPoints.addSwitchPoint(propertySwitchPoints, key, switchPoint);
     }
 
     /**
-     * An existing property is being deleted.
+     * Method called when a property of an object using this property map is being created,
+     * modified, or deleted. If a switchpoint for the property exists it will be invalidated.
      *
-     * @param property The property being deleted.
-     * @param isSelf was the property deleted from this map?
+     * @param property The changed property.
      */
-    public void propertyDeleted(final Property property, final boolean isSelf) {
-        if (!isSelf) {
-            invalidateProtoSwitchPoint(property.getKey());
-        }
-        if (listeners != null) {
-            listeners.propertyDeleted(property);
+    public void propertyChanged(final Property property) {
+        if (propertySwitchPoints != null) {
+            propertySwitchPoints.invalidateProperty(property);
         }
     }
 
     /**
-     * An existing property is being redefined.
-     *
-     * @param oldProperty The old property
-     * @param newProperty The new property
-     * @param isSelf was the property modified on this map?
+     * Method called when the prototype of an object using this property map is changed.
      */
-    public void propertyModified(final Property oldProperty, final Property newProperty, final boolean isSelf) {
-        if (!isSelf) {
-            invalidateProtoSwitchPoint(oldProperty.getKey());
-        }
-        if (listeners != null) {
-            listeners.propertyModified(oldProperty, newProperty);
-        }
-    }
-
-    /**
-     * The prototype of an object associated with this {@link PropertyMap} is changed.
-     *
-     * @param isSelf was the prototype changed on the object using this map?
-     */
-    public void protoChanged(final boolean isSelf) {
-        if (!isSelf) {
-            invalidateAllProtoSwitchPoints();
-        } else if (sharedProtoMap != null) {
+    void protoChanged() {
+        if (sharedProtoMap != null) {
             sharedProtoMap.invalidateSwitchPoint();
         }
-        if (listeners != null) {
-            listeners.protoChanged();
+        if (propertySwitchPoints != null) {
+            propertySwitchPoints.invalidateInheritedProperties(this);
         }
     }
 
     /**
-     * Return a SwitchPoint used to track changes of a property in a prototype.
+     * Returns a SwitchPoint for use with a property inherited from this or a parent map.
+     * If such a switchpoint exists, it will be invalidated when the property is modified
+     * in an object using this map. This method returns {@code null} if no swichpoint exists
+     * for the property.
      *
      * @param key Property key.
-     * @return A shared {@link SwitchPoint} for the property.
+     * @return A {@link SwitchPoint} for the property, or null.
      */
     public synchronized SwitchPoint getSwitchPoint(final String key) {
-        if (protoSwitches == null) {
-            protoSwitches = new HashMap<>();
-        }
-
-        SwitchPoint switchPoint = protoSwitches.get(key);
-        if (switchPoint == null) {
-            switchPoint = new SwitchPoint();
-            protoSwitches.put(key, switchPoint);
+        if (propertySwitchPoints != null) {
+            final Set<SwitchPoint> existingSwitchPoints = propertySwitchPoints.getSwitchPoints(key);
+            for (final SwitchPoint switchPoint : existingSwitchPoints) {
+                if (switchPoint != null && !switchPoint.hasBeenInvalidated()) {
+                    return switchPoint;
+                }
+            }
         }
 
-        return switchPoint;
-    }
-
-    /**
-     * Indicate that a prototype property has changed.
-     *
-     * @param key {@link Property} key to invalidate.
-     */
-    synchronized void invalidateProtoSwitchPoint(final Object key) {
-        if (protoSwitches != null) {
-            final SwitchPoint sp = protoSwitches.get(key);
-            if (sp != null) {
-                protoSwitches.remove(key);
-                if (Context.DEBUG) {
-                    protoInvalidations.increment();
-                }
-                SwitchPoint.invalidateAll(new SwitchPoint[]{sp});
-            }
-        }
-    }
-
-    /**
-     * Indicate that proto itself has changed in hierarchy somewhere.
-     */
-    synchronized void invalidateAllProtoSwitchPoints() {
-        if (protoSwitches != null) {
-            final int size = protoSwitches.size();
-            if (size > 0) {
-                if (Context.DEBUG) {
-                    protoInvalidations.add(size);
-                }
-                SwitchPoint.invalidateAll(protoSwitches.values().toArray(new SwitchPoint[0]));
-                protoSwitches.clear();
-            }
-        }
+        return null;
     }
 
     /**
@@ -452,7 +377,7 @@
      * @return New {@link PropertyMap} with {@link Property} added.
      */
     public final PropertyMap addPropertyNoHistory(final Property property) {
-        propertyAdded(property, true);
+        propertyChanged(property);
         return addPropertyInternal(property);
     }
 
@@ -464,7 +389,7 @@
      * @return New {@link PropertyMap} with {@link Property} added.
      */
     public final synchronized PropertyMap addProperty(final Property property) {
-        propertyAdded(property, true);
+        propertyChanged(property);
         PropertyMap newMap = checkHistory(property);
 
         if (newMap == null) {
@@ -494,7 +419,7 @@
      * @return New {@link PropertyMap} with {@link Property} removed or {@code null} if not found.
      */
     public final synchronized PropertyMap deleteProperty(final Property property) {
-        propertyDeleted(property, true);
+        propertyChanged(property);
         PropertyMap newMap = checkHistory(property);
         final Object key = property.getKey();
 
@@ -529,7 +454,7 @@
      * @return New {@link PropertyMap} with {@link Property} replaced.
      */
     public final PropertyMap replaceProperty(final Property oldProperty, final Property newProperty) {
-        propertyModified(oldProperty, newProperty, true);
+        propertyChanged(oldProperty);
         /*
          * See ScriptObject.modifyProperty and ScriptObject.setUserAccessors methods.
          *
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/src/jdk.scripting.nashorn/share/classes/jdk/nashorn/internal/runtime/PropertySwitchPoints.java	Wed Nov 08 12:27:40 2017 -0800
@@ -0,0 +1,226 @@
+/*
+ * Copyright (c) 2010, 2017, Oracle and/or its affiliates. All rights reserved.
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * This code is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License version 2 only, as
+ * published by the Free Software Foundation.  Oracle designates this
+ * particular file as subject to the "Classpath" exception as provided
+ * by Oracle in the LICENSE file that accompanied this code.
+ *
+ * This code is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
+ * version 2 for more details (a copy is included in the LICENSE file that
+ * accompanied this code).
+ *
+ * You should have received a copy of the GNU General Public License version
+ * 2 along with this work; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
+ *
+ * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
+ * or visit www.oracle.com if you need additional information or have any
+ * questions.
+ */
+
+package jdk.nashorn.internal.runtime;
+
+import java.lang.invoke.SwitchPoint;
+import java.util.Collections;
+import java.util.HashMap;
+import java.util.Map;
+import java.util.Set;
+import java.util.WeakHashMap;
+import java.util.concurrent.atomic.LongAdder;
+
+/**
+ * Helper class for tracking and invalidation of switchpoints for inherited properties.
+ */
+public class PropertySwitchPoints {
+
+    private final Map<Object, WeakSwitchPointSet> switchPointMap = new HashMap<>();
+
+    private final static SwitchPoint[] EMPTY_SWITCHPOINT_ARRAY = new SwitchPoint[0];
+
+    // These counters are updated in debug mode
+    private static LongAdder switchPointsAdded;
+    private static LongAdder switchPointsInvalidated;
+
+    static {
+        if (Context.DEBUG) {
+            switchPointsAdded = new LongAdder();
+            switchPointsInvalidated = new LongAdder();
+        }
+    }
+
+    /**
+     * Copy constructor
+     *
+     * @param switchPoints Proto switchpoints to copy
+     */
+    private PropertySwitchPoints(final PropertySwitchPoints switchPoints) {
+        if (switchPoints != null) {
+            // We need to copy the nested weak sets in order to avoid concurrent modification issues, see JDK-8146274
+            synchronized (switchPoints) {
+                for (final Map.Entry<Object, WeakSwitchPointSet> entry : switchPoints.switchPointMap.entrySet()) {
+                    this.switchPointMap.put(entry.getKey(), new WeakSwitchPointSet(entry.getValue()));
+                }
+            }
+        }
+    }
+
+    /**
+     * Return aggregate switchpoints added to all ProtoSwitchPoints
+     * @return the number of switchpoints added
+     */
+    public static long getSwitchPointsAdded() {
+        return switchPointsAdded.longValue();
+    }
+
+    /**
+     * Return aggregate switchPointMap invalidated in all ProtoSwitchPoints
+     * @return the number of switchpoints invalidated
+     */
+    public static long getSwitchPointsInvalidated() {
+        return switchPointsInvalidated.longValue();
+    }
+
+    /**
+     * Return number of property switchPoints added to a ScriptObject.
+     * @param obj the object
+     * @return the switchpoint count
+     */
+    public static int getSwitchPointCount(final ScriptObject obj) {
+        return obj.getMap().getSwitchPointCount();
+    }
+
+    /**
+     * Return the number of switchpoints added to this ProtoSwitchPoints instance.
+     * @return the switchpoint count;
+     */
+    int getSwitchPointCount() {
+        return switchPointMap.size();
+    }
+
+    /**
+     * Add {@code switchPoint} to the switchpoints for for property {@code key}, creating
+     * and returning a new {@code ProtoSwitchPoints} instance if the switchpoint was not already contained
+     *
+     * @param oldSwitchPoints the original PropertySwitchPoints instance. May be null
+     * @param key the property key
+     * @param switchPoint the switchpoint to be added
+     * @return the new PropertySwitchPoints instance, or this instance if switchpoint was already contained
+     */
+    static PropertySwitchPoints addSwitchPoint(final PropertySwitchPoints oldSwitchPoints, final String key, final SwitchPoint switchPoint) {
+        if (oldSwitchPoints == null || !oldSwitchPoints.contains(key, switchPoint)) {
+            final PropertySwitchPoints newSwitchPoints = new PropertySwitchPoints(oldSwitchPoints);
+            newSwitchPoints.add(key, switchPoint);
+            return newSwitchPoints;
+        }
+        return oldSwitchPoints;
+    }
+
+    /**
+     * Checks whether {@code switchPoint} is contained in {@code key}'s set.
+     *
+     * @param key the property key
+     * @param switchPoint the switchPoint
+     * @return true if switchpoint is already contained for key
+     */
+    private synchronized boolean contains(final String key, final SwitchPoint switchPoint) {
+        final WeakSwitchPointSet set = this.switchPointMap.get(key);
+        return set != null && set.contains(switchPoint);
+    }
+
+    private synchronized void add(final String key, final SwitchPoint switchPoint) {
+        if (Context.DEBUG) {
+            switchPointsAdded.increment();
+        }
+
+        WeakSwitchPointSet set = this.switchPointMap.get(key);
+        if (set == null) {
+            set = new WeakSwitchPointSet();
+            this.switchPointMap.put(key, set);
+        }
+
+        set.add(switchPoint);
+    }
+
+    Set<SwitchPoint> getSwitchPoints(final Object key) {
+        WeakSwitchPointSet switchPointSet = switchPointMap.get(key);
+        if (switchPointSet != null) {
+            return switchPointSet.elements();
+        }
+
+        return Collections.emptySet();
+    }
+
+    /**
+     * Invalidate all switchpoints for the given property. This is called when that
+     * property is created, deleted, or modified in a script object.
+     *
+     * @param prop The property to invalidate.
+     */
+    synchronized void invalidateProperty(final Property prop) {
+        final WeakSwitchPointSet set = switchPointMap.get(prop.getKey());
+        if (set != null) {
+            if (Context.DEBUG) {
+                switchPointsInvalidated.add(set.size());
+            }
+            final SwitchPoint[] switchPoints = set.elements().toArray(EMPTY_SWITCHPOINT_ARRAY);
+            SwitchPoint.invalidateAll(switchPoints);
+            this.switchPointMap.remove(prop.getKey());
+        }
+    }
+
+
+    /**
+     * Invalidate all switchpoints except those defined in {@code map}. This is called
+     * when the prototype of a script object is changed.
+     *
+     * @param map map of properties to exclude from invalidation
+     */
+    synchronized void invalidateInheritedProperties(final PropertyMap map) {
+        for (final Map.Entry<Object, WeakSwitchPointSet> entry : switchPointMap.entrySet()) {
+            if (map.findProperty(entry.getKey()) != null) {
+                continue;
+            }
+            if (Context.DEBUG) {
+                switchPointsInvalidated.add(entry.getValue().size());
+            }
+            final SwitchPoint[] switchPoints = entry.getValue().elements().toArray(EMPTY_SWITCHPOINT_ARRAY);
+            SwitchPoint.invalidateAll(switchPoints);
+        }
+        switchPointMap.clear();
+    }
+
+    private static class WeakSwitchPointSet {
+
+        private final WeakHashMap<SwitchPoint, Void> map;
+
+        WeakSwitchPointSet() {
+            map = new WeakHashMap<>();
+        }
+
+        WeakSwitchPointSet(final WeakSwitchPointSet set) {
+            map = new WeakHashMap<>(set.map);
+        }
+
+        void add(final SwitchPoint switchPoint) {
+            map.put(switchPoint, null);
+        }
+
+        boolean contains(final SwitchPoint switchPoint) {
+            return map.containsKey(switchPoint);
+        }
+
+        Set<SwitchPoint> elements() {
+            return map.keySet();
+        }
+
+        int size() {
+            return map.size();
+        }
+
+    }
+}
--- a/src/jdk.scripting.nashorn/share/classes/jdk/nashorn/internal/runtime/ScriptObject.java	Tue Nov 07 14:36:52 2017 -0800
+++ b/src/jdk.scripting.nashorn/share/classes/jdk/nashorn/internal/runtime/ScriptObject.java	Wed Nov 08 12:27:40 2017 -0800
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2010, 2016, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2010, 2017, 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
@@ -1248,7 +1248,7 @@
             proto = newProto;
 
             // Let current listeners know that the prototype has changed
-            getMap().protoChanged(true);
+            getMap().protoChanged();
             // Replace our current allocator map with one that is associated with the new prototype.
             setMap(getMap().changeProto(newProto));
         }
@@ -2107,30 +2107,38 @@
     }
 
     /**
-     * Get a switch point for a property with the given {@code name} that will be invalidated when
-     * the property definition is changed in this object's prototype chain. Returns {@code null} if
-     * the property is defined in this object itself.
+     * Get an array of switch points for a property with the given {@code name} that will be
+     * invalidated when the property definition is changed in this object's prototype chain.
+     * Returns {@code null} if the property is defined in this object itself.
      *
      * @param name the property name
      * @param owner the property owner, null if property is not defined
-     * @return a SwitchPoint or null
+     * @return an array of SwitchPoints or null
      */
     public final SwitchPoint[] getProtoSwitchPoints(final String name, final ScriptObject owner) {
         if (owner == this || getProto() == null) {
             return null;
         }
 
-        final List<SwitchPoint> switchPoints = new ArrayList<>();
-        for (ScriptObject obj = this; obj != owner && obj.getProto() != null; obj = obj.getProto()) {
-            final ScriptObject parent = obj.getProto();
-            parent.getMap().addListener(name, obj.getMap());
-            final SwitchPoint sp = parent.getMap().getSharedProtoSwitchPoint();
-            if (sp != null && !sp.hasBeenInvalidated()) {
-                switchPoints.add(sp);
+        final Set<SwitchPoint> switchPoints = new HashSet<>();
+        SwitchPoint switchPoint = getProto().getMap().getSwitchPoint(name);
+
+        if (switchPoint == null) {
+            switchPoint = new SwitchPoint();
+            for (ScriptObject obj = this; obj != owner && obj.getProto() != null; obj = obj.getProto()) {
+                obj.getProto().getMap().addSwitchPoint(name, switchPoint);
             }
         }
 
-        switchPoints.add(getMap().getSwitchPoint(name));
+        switchPoints.add(switchPoint);
+
+        for (ScriptObject obj = this; obj != owner && obj.getProto() != null; obj = obj.getProto()) {
+            final SwitchPoint sharedProtoSwitchPoint = obj.getProto().getMap().getSharedProtoSwitchPoint();
+            if (sharedProtoSwitchPoint != null && !sharedProtoSwitchPoint.hasBeenInvalidated()) {
+                switchPoints.add(sharedProtoSwitchPoint);
+            }
+        }
+
         return switchPoints.toArray(new SwitchPoint[0]);
     }
 
@@ -2141,12 +2149,16 @@
             return null;
         }
 
-        for (ScriptObject obj = this; obj.getProto() != null; obj = obj.getProto()) {
-            final ScriptObject parent = obj.getProto();
-            parent.getMap().addListener(name, obj.getMap());
+        SwitchPoint switchPoint = getProto().getMap().getSwitchPoint(name);
+
+        if (switchPoint == null) {
+            switchPoint = new SwitchPoint();
+            for (ScriptObject obj = this; obj.getProto() != null; obj = obj.getProto()) {
+                obj.getProto().getMap().addSwitchPoint(name, switchPoint);
+            }
         }
 
-        return getMap().getSwitchPoint(name);
+        return switchPoint;
     }
 
     private void checkSharedProtoMap() {
--- a/src/jdk.scripting.nashorn/share/classes/jdk/nashorn/internal/runtime/SetMethodCreator.java	Tue Nov 07 14:36:52 2017 -0800
+++ b/src/jdk.scripting.nashorn/share/classes/jdk/nashorn/internal/runtime/SetMethodCreator.java	Wed Nov 08 12:27:40 2017 -0800
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2010, 2013, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2010, 2017, 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
@@ -185,7 +185,7 @@
 
     private SetMethod createNewPropertySetter(final SwitchPoint builtinSwitchPoint) {
         final SetMethod sm = map.getFreeFieldSlot() > -1 ? createNewFieldSetter(builtinSwitchPoint) : createNewSpillPropertySetter(builtinSwitchPoint);
-        map.propertyAdded(sm.property, true);
+        map.propertyChanged(sm.property);
         return sm;
     }
 
--- a/src/jdk.scripting.nashorn/share/classes/jdk/nashorn/internal/runtime/SharedPropertyMap.java	Tue Nov 07 14:36:52 2017 -0800
+++ b/src/jdk.scripting.nashorn/share/classes/jdk/nashorn/internal/runtime/SharedPropertyMap.java	Wed Nov 08 12:27:40 2017 -0800
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2015, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2015, 2017, 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
@@ -48,33 +48,15 @@
      * Create a new shared property map from the given {@code map}.
      * @param map property map to copy
      */
-    public SharedPropertyMap(final PropertyMap map) {
+    SharedPropertyMap(final PropertyMap map) {
         super(map);
         this.switchPoint = new SwitchPoint();
     }
 
     @Override
-    public void propertyAdded(final Property property, final boolean isSelf) {
-        if (isSelf) {
-            invalidateSwitchPoint();
-        }
-        super.propertyAdded(property, isSelf);
-    }
-
-    @Override
-    public void propertyDeleted(final Property property, final boolean isSelf) {
-        if (isSelf) {
-            invalidateSwitchPoint();
-        }
-        super.propertyDeleted(property, isSelf);
-    }
-
-    @Override
-    public void propertyModified(final Property oldProperty, final Property newProperty, final boolean isSelf) {
-        if (isSelf) {
-            invalidateSwitchPoint();
-        }
-        super.propertyModified(oldProperty, newProperty, isSelf);
+    public void propertyChanged(final Property property) {
+        invalidateSwitchPoint();
+        super.propertyChanged(property);
     }
 
     @Override
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/test/jdk/java/lang/ClassLoader/nativeLibrary/NativeLibraryTest.java	Wed Nov 08 12:27:40 2017 -0800
@@ -0,0 +1,129 @@
+/*
+ * Copyright (c) 2017, Oracle and/or its affiliates. All rights reserved.
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * This code is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License version 2 only, as
+ * published by the Free Software Foundation.
+ *
+ * This code is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
+ * version 2 for more details (a copy is included in the LICENSE file that
+ * accompanied this code).
+ *
+ * You should have received a copy of the GNU General Public License version
+ * 2 along with this work; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
+ *
+ * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
+ * or visit www.oracle.com if you need additional information or have any
+ * questions.
+ */
+
+/*
+ * @test
+ * @bug 8164512
+ * @summary verify if the native library is unloaded when the class loader is GC'ed
+ * @build p.Test
+ * @run main/othervm/native -Xcheck:jni NativeLibraryTest
+ */
+
+import java.io.IOException;
+import java.net.MalformedURLException;
+import java.net.URL;
+import java.net.URLClassLoader;
+import java.nio.file.Files;
+import java.nio.file.Path;
+import java.nio.file.Paths;
+
+public class NativeLibraryTest {
+    static final Path CLASSES = Paths.get("classes");
+    static int unloadedCount = 0;
+
+    /*
+     * Called by JNI_OnUnload when the native library is unloaded
+     */
+    static void nativeLibraryUnloaded() {
+        unloadedCount++;
+    }
+
+    public static void main(String... args) throws Exception {
+        setup();
+
+        for (int count=1; count <= 5; count++) {
+            // create a class loader and load a native library
+            runTest();
+            // unloading the class loader and native library
+            System.gc();
+            // give Cleaner thread a chance to unload the native library
+            Thread.sleep(100);
+
+            // unloadedCount is incremented when the native library is unloaded
+            if (count != unloadedCount) {
+                throw new RuntimeException("Expected unloaded=" + count +
+                    " but got=" + unloadedCount);
+            }
+        }
+    }
+
+    /*
+     * Loads p.Test class with a new class loader and its static initializer
+     * will load a native library.
+     *
+     * The class loader becomes unreachable when this method returns and
+     * the native library should be unloaded at some point after the class
+     * loader is garbage collected.
+     */
+    static void runTest() throws Exception {
+        // invoke p.Test.run() that loads the native library
+        Runnable r = newTestRunnable();
+        r.run();
+
+        // reload the native library by the same class loader
+        r.run();
+
+        // load the native library by another class loader
+        Runnable r1 = newTestRunnable();
+        try {
+            r1.run();
+            throw new RuntimeException("should fail to load the native library" +
+                    " by another class loader");
+        } catch (UnsatisfiedLinkError e) {}
+    }
+
+    /*
+     * Loads p.Test class with a new class loader and returns
+     * a Runnable instance.
+     */
+    static Runnable newTestRunnable() throws Exception {
+        TestLoader loader = new TestLoader();
+        Class<?> c = Class.forName("p.Test", true, loader);
+        return (Runnable) c.newInstance();
+    }
+
+    static class TestLoader extends URLClassLoader {
+        static URL[] toURLs() {
+            try {
+                return new URL[] { CLASSES.toUri().toURL() };
+            } catch (MalformedURLException e) {
+                throw new Error(e);
+            }
+        }
+
+        TestLoader() {
+            super("testloader", toURLs(), ClassLoader.getSystemClassLoader());
+        }
+    }
+
+    /*
+     * move p/Test.class out from classpath to the scratch directory
+     */
+    static void setup() throws IOException {
+        String dir = System.getProperty("test.classes", ".");
+        Path file = Paths.get("p", "Test.class");
+        Files.createDirectories(CLASSES.resolve("p"));
+        Files.move(Paths.get(dir).resolve(file),
+                   CLASSES.resolve("p").resolve("Test.class"));
+    }
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/test/jdk/java/lang/ClassLoader/nativeLibrary/libnativeLibraryTest.c	Wed Nov 08 12:27:40 2017 -0800
@@ -0,0 +1,74 @@
+/*
+ * Copyright (c) 2017, Oracle and/or its affiliates. All rights reserved.
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * This code is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License version 2 only, as
+ * published by the Free Software Foundation.
+ *
+ * This code is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
+ * version 2 for more details (a copy is included in the LICENSE file that
+ * accompanied this code).
+ *
+ * You should have received a copy of the GNU General Public License version
+ * 2 along with this work; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
+ *
+ * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
+ * or visit www.oracle.com if you need additional information or have any
+ * questions.
+ */
+
+#include <stdio.h>
+#include <stdlib.h>
+
+#include "jni.h"
+#include "jni_util.h"
+
+static jint count = 0;
+static jclass test_class;
+static jint current_jni_version = JNI_VERSION_10;
+
+JNIEXPORT jint JNICALL
+JNI_OnLoad(JavaVM *vm, void *reserved) {
+    JNIEnv *env;
+    jclass cl;
+
+    (*vm)->GetEnv(vm, (void **) &env, current_jni_version);
+
+    cl = (*env)->FindClass(env, "NativeLibraryTest");
+    test_class = (*env)->NewGlobalRef(env, cl);
+
+    // increment the count when JNI_OnLoad is called
+    count++;
+
+    return current_jni_version;
+}
+
+JNIEXPORT void JNICALL
+JNI_OnUnload(JavaVM *vm, void *reserved) {
+    JNIEnv *env;
+    jmethodID mid;
+    jclass cl;
+
+    (*vm)->GetEnv(vm, (void **) &env, current_jni_version);
+    mid = (*env)->GetStaticMethodID(env, test_class, "nativeLibraryUnloaded", "()V");
+    (*env)->CallStaticVoidMethod(env, test_class, mid);
+    if ((*env)->ExceptionCheck(env)) {
+        (*env)->ExceptionDescribe(env);
+        (*env)->FatalError(env, "Exception thrown");
+    }
+
+    cl = (*env)->FindClass(env, "p/Test");
+    if (cl != NULL) {
+        (*env)->FatalError(env, "p/Test class should not be found");
+    }
+}
+
+JNIEXPORT jint JNICALL
+Java_p_Test_count
+(JNIEnv *env, jclass cls) {
+    return count;
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/test/jdk/java/lang/ClassLoader/nativeLibrary/p/Test.java	Wed Nov 08 12:27:40 2017 -0800
@@ -0,0 +1,37 @@
+/*
+ * Copyright (c) 2017, 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.
+ */
+package p;
+
+public class Test implements Runnable {
+    public static native int count();
+
+    /**
+     * Tests if the native library is loaded.
+     */
+    public void run() {
+        System.loadLibrary("nativeLibraryTest");
+        if (count() != 1) {
+            throw new RuntimeException("Expected count = 1 but got " + count());
+        }
+    }
+}
--- a/test/jdk/java/lang/ProcessHandle/OnExitTest.java	Tue Nov 07 14:36:52 2017 -0800
+++ b/test/jdk/java/lang/ProcessHandle/OnExitTest.java	Wed Nov 08 12:27:40 2017 -0800
@@ -40,7 +40,6 @@
 
 /*
  * @test
- * @key intermittent
  * @library /test/lib
  * @build jdk.test.lib.Utils
  * @run testng OnExitTest
--- a/test/jdk/java/lang/Runtime/exec/LotsOfOutput.java	Tue Nov 07 14:36:52 2017 -0800
+++ b/test/jdk/java/lang/Runtime/exec/LotsOfOutput.java	Wed Nov 08 12:27:40 2017 -0800
@@ -23,7 +23,8 @@
 
 /**
  * @test
- * @bug 4369826 8078582
+ * @bug 4369826 8078582 8190884
+ * @run main/othervm LotsOfOutput
  * @summary Process with lots of output should not crash VM
  * @author kladko
  */
--- a/test/jdk/java/util/Currency/PropertiesTest.sh	Tue Nov 07 14:36:52 2017 -0800
+++ b/test/jdk/java/util/Currency/PropertiesTest.sh	Wed Nov 08 12:27:40 2017 -0800
@@ -104,7 +104,7 @@
 WRITABLEJDK=.${FS}testjava
 cp -H -R $TESTJAVA $WRITABLEJDK || exit 1
 PROPLOCATION=${WRITABLEJDK}${FS}lib
-chmod -R a+rx $WRITABLEJDK || exit 1
+chmod -R u+w $WRITABLEJDK || exit 1
 cp ${PROPS} $PROPLOCATION || exit 1
 echo "Properties location: ${PROPLOCATION}"
 
--- a/test/jdk/javax/imageio/stream/NullStreamCheckTest.java	Tue Nov 07 14:36:52 2017 -0800
+++ b/test/jdk/javax/imageio/stream/NullStreamCheckTest.java	Wed Nov 08 12:27:40 2017 -0800
@@ -58,17 +58,6 @@
     static BufferedImage inputImage = new BufferedImage(width, height,
             BufferedImage.TYPE_INT_ARGB);
 
-    // creates test file needed for read and write in local directory.
-    private static File createTestFile(String name) throws IOException {
-        String sep = System.getProperty("file.separator");
-        String dir = System.getProperty("test.src", ".");
-        String filePath = dir+sep;
-        File directory = new File(filePath);
-        File tmpTestFile = File.createTempFile(name, ".png", directory);
-        directory.delete();
-        return tmpTestFile;
-    }
-
     /* if we catch expected IOException message return
      * false otherwise return true.
      */
@@ -86,7 +75,7 @@
     }
 
     private static void verifyFileWrite() throws IOException {
-        File outputTestFile = createTestFile("outputTestFile");
+        File outputTestFile = File.createTempFile("outputTestFile", ".png");
         try {
             ImageIO.write(inputImage, "png", outputTestFile);
         } catch (IOException ex) {
@@ -113,7 +102,7 @@
     }
 
     private static void verifyFileRead() throws IOException {
-        File inputTestFile = createTestFile("inputTestFile");
+        File inputTestFile = File.createTempFile("inputTestFile", ".png");
         try {
             ImageIO.read(inputTestFile);
         } catch (IOException ex) {
@@ -141,7 +130,7 @@
 
     private static void verifyUrlRead() throws IOException {
         URL url;
-        File inputTestUrlFile = createTestFile("inputTestFile");
+        File inputTestUrlFile = File.createTempFile("inputTestFile", ".png");
         try {
             try {
                 url = inputTestUrlFile.toURI().toURL();
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/test/nashorn/src/jdk/nashorn/internal/runtime/test/JDK_8186807_Test.java	Wed Nov 08 12:27:40 2017 -0800
@@ -0,0 +1,76 @@
+/*
+ * Copyright (c) 2017, Oracle and/or its affiliates. All rights reserved.
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * This code is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License version 2 only, as
+ * published by the Free Software Foundation.  Oracle designates this
+ * particular file as subject to the "Classpath" exception as provided
+ * by Oracle in the LICENSE file that accompanied this code.
+ *
+ * This code is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
+ * version 2 for more details (a copy is included in the LICENSE file that
+ * accompanied this code).
+ *
+ * You should have received a copy of the GNU General Public License version
+ * 2 along with this work; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
+ *
+ * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
+ * or visit www.oracle.com if you need additional information or have any
+ * questions.
+ */
+
+package jdk.nashorn.internal.runtime.test;
+
+import jdk.nashorn.api.scripting.AbstractJSObject;
+import jdk.nashorn.api.scripting.NashornScriptEngine;
+import jdk.nashorn.api.scripting.NashornScriptEngineFactory;
+import jdk.nashorn.api.scripting.ScriptObjectMirror;
+import static org.testng.Assert.assertEquals;
+import org.testng.annotations.Test;
+import javax.script.ScriptException;
+
+
+/**
+ * @test
+ * @bug 8186807
+ * @summary JSObject gets ScriptFunction when ScriptObjectMirror is expected
+ * @modules jdk.scripting.nashorn/jdk.nashorn.internal.runtime
+ * @run testng/othervm -Dnashorn.unstable.relink.threshold=1 jdk.nashorn.internal.runtime.test.JDK_8186807_Test
+ */
+
+public class JDK_8186807_Test {
+
+    @Test
+    public void testScript() throws ScriptException {
+        NashornScriptEngine engine = (NashornScriptEngine) new NashornScriptEngineFactory().getScriptEngine();
+        engine.put("a", new Func());
+        engine.eval("var Assert = Java.type('org.testng.Assert')\n" +
+                "var fn=function() {return 2;}\n" +
+                "var arr = [ a, fn, a ];\n" +
+                "var result;\n" +
+                "for (i in arr) {\n" +
+                "    result = Function.prototype.apply.apply(arr[i],[null,[fn]]);\n" +
+                "    if(i==0 || i==2)\n" +
+                "        Assert.assertTrue(result==1);\n" +
+                "    if(i==1)\n" +
+                "        Assert.assertTrue(result==2);\n" +
+                "}");
+    }
+
+    static class Func extends AbstractJSObject {
+        @Override
+        public boolean isFunction() {
+            return true;
+        }
+
+        @Override
+        public Object call(Object thiz, Object... args) {
+            assertEquals(args[0].getClass(), ScriptObjectMirror.class);
+            return 1;
+        }
+    }
+}