Merge
authorlana
Thu, 19 May 2016 19:46:20 +0000
changeset 38433 6c0c995231c6
parent 38319 739e70ea7187 (current diff)
parent 38431 ed73e79a0eb4 (diff)
child 38434 a38df2210d1f
Merge
jdk/src/java.desktop/share/native/libmlib_image/mlib_ImageColorTrue2Index.c
jdk/src/java.desktop/share/native/libmlib_image/mlib_ImageColormap.h
jdk/src/java.desktop/share/native/libmlib_image/mlib_ImageConv2x2_f.c
jdk/src/java.desktop/share/native/libmlib_image/mlib_c_ImageAffineIndex_BC.c
jdk/src/java.desktop/share/native/libmlib_image/mlib_c_ImageAffineIndex_BL.c
jdk/src/java.desktop/share/native/libmlib_image/mlib_c_ImageBlendTable.c
jdk/src/java.desktop/share/native/libmlib_image/mlib_c_ImageBlendTable.h
jdk/src/java.desktop/share/native/libmlib_image/mlib_c_ImageThresh1.h
jdk/src/java.desktop/share/native/libmlib_image/mlib_c_ImageThresh1_U8.c
jdk/src/java.desktop/share/native/libmlib_image/mlib_image_blend_proto.h
jdk/src/java.desktop/unix/native/libawt/awt/medialib/mlib_v_ImageCopy.c
jdk/src/java.desktop/unix/native/libawt/awt/medialib/mlib_v_ImageCopy_blk.s
jdk/src/java.desktop/unix/native/libawt/awt/medialib/vis_asi.h
jdk/src/java.desktop/unix/native/libmlib_image/mlib_v_ImageAffineIndex_BC.c
jdk/src/java.desktop/unix/native/libmlib_image/mlib_v_ImageChannelExtract.c
jdk/src/java.desktop/unix/native/libmlib_image/mlib_v_ImageChannelExtract_f.c
jdk/src/java.desktop/unix/native/libmlib_image/mlib_v_ImageChannelInsert.c
jdk/src/java.desktop/unix/native/libmlib_image/mlib_v_ImageChannelInsert_34.c
jdk/src/java.desktop/unix/native/libmlib_image/mlib_v_ImageConvIndex3_8_16nw.c
jdk/src/java.desktop/unix/native/libmlib_image/mlib_v_ImageConvIndex3_8_8nw.c
jdk/src/java.httpclient/share/classes/java/net/http/HttpHeaders1.java
jdk/src/jdk.jcmd/share/classes/jdk/internal/vm/agent/spi/ToolProvider.java
jdk/src/jdk.jcmd/share/classes/jdk/internal/vm/agent/spi/ToolProviderFinder.java
jdk/src/jdk.jlink/share/classes/jdk/tools/jlink/internal/PluginContextImpl.java
jdk/src/jdk.jlink/share/classes/jdk/tools/jlink/internal/PoolImpl.java
jdk/src/jdk.jlink/share/classes/jdk/tools/jlink/plugin/PluginContext.java
jdk/src/jdk.jlink/share/classes/jdk/tools/jlink/plugin/Pool.java
jdk/src/jdk.unsupported/share/classes/sun/misc/SoftCache.java
jdk/src/jdk.unsupported/unix/classes/sun/misc/GThreadHelper.java
jdk/test/java/awt/dnd/Button2DragTest/Button2DragTest.html
jdk/test/java/awt/print/Dialog/RestoreActiveWindowTest/RestoreActiveWindowTest.html
jdk/test/javax/sound/sampled/spi/AudioFileReader/RecognizeHugeWaveFloatFiles.java
jdk/test/javax/xml/bind/xjc/8032884/compile-schema.sh
jdk/test/jdk/modules/scenarios/overlappingpackages/src/misc/sun/misc/Unsafe.java
jdk/test/sun/tools/jinfo/JInfoHelper.java
jdk/test/sun/tools/jinfo/JInfoLauncherTest.java
jdk/test/sun/tools/jinfo/JInfoRunningProcessFlagTest.java
jdk/test/sun/tools/jinfo/JInfoRunningProcessTest.java
jdk/test/sun/tools/jinfo/JInfoSanityTest.java
jdk/test/sun/tools/jmap/heapconfig/JMapHeapConfigTest.java
jdk/test/sun/tools/jmap/heapconfig/TmtoolTestScenario.java
jdk/test/tools/launcher/modules/patch/PatchTest.java
jdk/test/tools/launcher/modules/patch/src/test/jdk/test/Main.java
jdk/test/tools/launcher/modules/patch/src/test/module-info.java
jdk/test/tools/launcher/modules/patch/src1/java.base/java/text/Annotation.java
jdk/test/tools/launcher/modules/patch/src1/java.base/java/text/AnnotationBuddy.java
jdk/test/tools/launcher/modules/patch/src1/jdk.compiler/com/sun/tools/javac/Main.java
jdk/test/tools/launcher/modules/patch/src1/jdk.compiler/com/sun/tools/javac/MainBuddy.java
jdk/test/tools/launcher/modules/patch/src1/jdk.naming.dns/com/sun/jndi/dns/DnsClient.java
jdk/test/tools/launcher/modules/patch/src1/jdk.naming.dns/com/sun/jndi/dns/DnsClientBuddy.java
jdk/test/tools/launcher/modules/patch/src2/java.base/java/lang2/Object.java
jdk/test/tools/launcher/modules/patch/src2/jdk.compiler/com/sun/tools/javac2/Main.java
jdk/test/tools/launcher/modules/patch/src2/jdk.naming.dns/com/sun/jndi/dns2/Zone.java
--- a/jdk/make/Import.gmk	Thu May 19 17:48:02 2016 +0000
+++ b/jdk/make/Import.gmk	Thu May 19 19:46:20 2016 +0000
@@ -112,7 +112,7 @@
 	$(LN) -s ../$(@F) $@
 
 ifeq ($(OPENJDK_TARGET_OS), macosx)
-  $(BASE_INSTALL_LIBRARIES_HERE)/server/%.dSYM : $(BASE_INSTALL_LIBRARIES_HERE)/%.dSYM
+  $(BASE_INSTALL_LIBRARIES_HERE)/server/%.dSYM:
 	$(MKDIR) -p $(@D)
 	$(RM) $@
 	$(LN) -s ../$(@F) $@
--- a/jdk/make/lib/Awt2dLibraries.gmk	Thu May 19 17:48:02 2016 +0000
+++ b/jdk/make/lib/Awt2dLibraries.gmk	Thu May 19 19:46:20 2016 +0000
@@ -96,10 +96,7 @@
       mlib_c_ImageAffine_BL.c \
       mlib_c_ImageAffine_BL_S16.c \
       mlib_c_ImageAffine_BL_U16.c \
-      mlib_c_ImageAffineIndex_BC.c \
-      mlib_c_ImageAffineIndex_BL.c \
       mlib_c_ImageAffine_NN.c \
-      mlib_c_ImageBlendTable.c \
       mlib_c_ImageConvClearEdge.c \
       mlib_c_ImageConvCopyEdge.c \
       mlib_c_ImageConv_f.c \
@@ -107,14 +104,6 @@
       mlib_c_ImageCopy.c \
       mlib_c_ImageLookUp.c \
       mlib_c_ImageLookUp_f.c \
-      mlib_v_ImageChannelExtract.c \
-      mlib_v_ImageChannelExtract_f.c \
-      mlib_v_ImageChannelInsert_34.c \
-      mlib_v_ImageChannelInsert.c \
-      mlib_v_ImageConvIndex3_8_16nw.c \
-      mlib_v_ImageConvIndex3_8_8nw.c \
-      mlib_v_ImageCopy.c \
-      mlib_v_ImageCopy_blk.s \
       #
 
   LIBMLIB_IMAGE_V_CFLAGS += $(filter-out -DMLIB_NO_LIBSUNMATH, $(BUILD_LIBMLIB_CFLAGS))
--- a/jdk/src/demo/share/jvmti/index.html	Thu May 19 17:48:02 2016 +0000
+++ b/jdk/src/demo/share/jvmti/index.html	Thu May 19 19:46:20 2016 +0000
@@ -415,7 +415,7 @@
 Various technical articles are also available through this website.
 And don't forget the 
 Java Tutorials at 
-<A HREF="http://java.sun.com/docs/books/tutorial">http://java.sun.com/docs/books/tutorial</A>
+<A HREF="http://docs.oracle.com/javase/tutorial">http://docs.oracle.com/javase/tutorial</A>
 for getting a quick start on all the various interfaces.
 
 <h2>Comments and Feedback</h2>
--- a/jdk/src/java.base/share/classes/com/sun/java/util/jar/pack/Constants.java	Thu May 19 17:48:02 2016 +0000
+++ b/jdk/src/java.base/share/classes/com/sun/java/util/jar/pack/Constants.java	Thu May 19 19:46:20 2016 +0000
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2001, 2013, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2001, 2016, 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
@@ -43,9 +43,10 @@
         1.0 to 1.3.X 45,3
         1.4 to 1.4.X 46,0
         1.5 to 1.5.X 49,0
-        1.6 to 1.5.x 50,0
-        1.7 to 1.6.x 51,0
-        1.8 to 1.7.x 52,0
+        1.6 to 1.6.X 50,0
+        1.7 to 1.7.X 51,0
+        1.8 to 1.8.X 52,0
+        1.9 to 1.9.X 53,0
     */
 
     public static final Package.Version JAVA_MIN_CLASS_VERSION =
@@ -63,6 +64,9 @@
     public static final Package.Version JAVA8_MAX_CLASS_VERSION =
             Package.Version.of(52, 00);
 
+    public static final Package.Version JAVA9_MAX_CLASS_VERSION =
+            Package.Version.of(53, 00);
+
     public static final int JAVA_PACKAGE_MAGIC = 0xCAFED00D;
 
     public static final Package.Version JAVA5_PACKAGE_VERSION =
@@ -79,7 +83,7 @@
 
     // upper limit, should point to the latest class version
     public static final Package.Version JAVA_MAX_CLASS_VERSION =
-            JAVA8_MAX_CLASS_VERSION;
+            JAVA9_MAX_CLASS_VERSION;
 
     // upper limit should point to the latest package version, for version info!.
     public static final Package.Version MAX_PACKAGE_VERSION =
--- a/jdk/src/java.base/share/classes/java/io/BufferedWriter.java	Thu May 19 17:48:02 2016 +0000
+++ b/jdk/src/java.base/share/classes/java/io/BufferedWriter.java	Thu May 19 19:46:20 2016 +0000
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 1996, 2015, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 1996, 2016, 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
@@ -153,13 +153,18 @@
      * needed.  If the requested length is at least as large as the buffer,
      * however, then this method will flush the buffer and write the characters
      * directly to the underlying stream.  Thus redundant
-     * <code>BufferedWriter</code>s will not copy data unnecessarily.
+     * {@code BufferedWriter}s will not copy data unnecessarily.
      *
      * @param  cbuf  A character array
      * @param  off   Offset from which to start reading characters
      * @param  len   Number of characters to write
      *
-     * @exception  IOException  If an I/O error occurs
+     * @throws  IndexOutOfBoundsException
+     *          If {@code off} is negative, or {@code len} is negative,
+     *          or {@code off + len} is negative or greater than the length
+     *          of the given array
+     *
+     * @throws  IOException  If an I/O error occurs
      */
     public void write(char cbuf[], int off, int len) throws IOException {
         synchronized (lock) {
@@ -195,17 +200,24 @@
     /**
      * Writes a portion of a String.
      *
-     * <p> If the value of the {@code len} parameter is negative then no
-     * characters are written.  This is contrary to the specification of this
-     * method in the {@linkplain java.io.Writer#write(java.lang.String,int,int)
-     * superclass}, which requires that an {@link IndexOutOfBoundsException} be
-     * thrown.
+     * @implSpec
+     * While the specification of this method in the
+     * {@linkplain java.io.Writer#write(java.lang.String,int,int) superclass}
+     * recommends that an {@link IndexOutOfBoundsException} be thrown
+     * if {@code len} is negative or {@code off + len} is negative,
+     * the implementation in this class does not throw such an exception in
+     * these cases but instead simply writes no characters.
      *
      * @param  s     String to be written
      * @param  off   Offset from which to start reading characters
      * @param  len   Number of characters to be written
      *
-     * @exception  IOException  If an I/O error occurs
+     * @throws  IndexOutOfBoundsException
+     *          If {@code off} is negative,
+     *          or {@code off + len} is greater than the length
+     *          of the given string
+     *
+     * @throws  IOException  If an I/O error occurs
      */
     public void write(String s, int off, int len) throws IOException {
         synchronized (lock) {
--- a/jdk/src/java.base/share/classes/java/io/CharArrayWriter.java	Thu May 19 17:48:02 2016 +0000
+++ b/jdk/src/java.base/share/classes/java/io/CharArrayWriter.java	Thu May 19 19:46:20 2016 +0000
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 1996, 2005, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 1996, 2016, 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
@@ -91,6 +91,11 @@
      * @param c the data to be written
      * @param off       the start offset in the data
      * @param len       the number of chars that are written
+     *
+     * @throws  IndexOutOfBoundsException
+     *          If {@code off} is negative, or {@code len} is negative,
+     *          or {@code off + len} is negative or greater than the length
+     *          of the given array
      */
     public void write(char c[], int off, int len) {
         if ((off < 0) || (off > c.length) || (len < 0) ||
@@ -114,6 +119,11 @@
      * @param  str  String to be written from
      * @param  off  Offset from which to start reading characters
      * @param  len  Number of characters to be written
+     *
+     * @throws  IndexOutOfBoundsException
+     *          If {@code off} is negative, or {@code len} is negative,
+     *          or {@code off + len} is negative or greater than the length
+     *          of the given string
      */
     public void write(String str, int off, int len) {
         synchronized (lock) {
--- a/jdk/src/java.base/share/classes/java/io/FilterWriter.java	Thu May 19 17:48:02 2016 +0000
+++ b/jdk/src/java.base/share/classes/java/io/FilterWriter.java	Thu May 19 19:46:20 2016 +0000
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 1996, 2005, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 1996, 2016, 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
@@ -72,7 +72,12 @@
      * @param  off   Offset from which to start reading characters
      * @param  len   Number of characters to be written
      *
-     * @exception  IOException  If an I/O error occurs
+     * @throws  IndexOutOfBoundsException
+     *          If the values of the {@code off} and {@code len} parameters
+     *          cause the corresponding method of the underlying {@code Writer}
+     *          to throw an {@code IndexOutOfBoundsException}
+     *
+     * @throws  IOException  If an I/O error occurs
      */
     public void write(char cbuf[], int off, int len) throws IOException {
         out.write(cbuf, off, len);
@@ -85,7 +90,12 @@
      * @param  off  Offset from which to start reading characters
      * @param  len  Number of characters to be written
      *
-     * @exception  IOException  If an I/O error occurs
+     * @throws  IndexOutOfBoundsException
+     *          If the values of the {@code off} and {@code len} parameters
+     *          cause the corresponding method of the underlying {@code Writer}
+     *          to throw an {@code IndexOutOfBoundsException}
+     *
+     * @throws  IOException  If an I/O error occurs
      */
     public void write(String str, int off, int len) throws IOException {
         out.write(str, off, len);
--- a/jdk/src/java.base/share/classes/java/io/OutputStreamWriter.java	Thu May 19 17:48:02 2016 +0000
+++ b/jdk/src/java.base/share/classes/java/io/OutputStreamWriter.java	Thu May 19 19:46:20 2016 +0000
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 1996, 2013, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 1996, 2016, 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
@@ -202,7 +202,12 @@
      * @param  off   Offset from which to start writing characters
      * @param  len   Number of characters to write
      *
-     * @exception  IOException  If an I/O error occurs
+     * @throws  IndexOutOfBoundsException
+     *          If {@code off} is negative, or {@code len} is negative,
+     *          or {@code off + len} is negative or greater than the length
+     *          of the given array
+     *
+     * @throws  IOException  If an I/O error occurs
      */
     public void write(char cbuf[], int off, int len) throws IOException {
         se.write(cbuf, off, len);
@@ -215,7 +220,12 @@
      * @param  off  Offset from which to start writing characters
      * @param  len  Number of characters to write
      *
-     * @exception  IOException  If an I/O error occurs
+     * @throws  IndexOutOfBoundsException
+     *          If {@code off} is negative, or {@code len} is negative,
+     *          or {@code off + len} is negative or greater than the length
+     *          of the given string
+     *
+     * @throws  IOException  If an I/O error occurs
      */
     public void write(String str, int off, int len) throws IOException {
         se.write(str, off, len);
--- a/jdk/src/java.base/share/classes/java/io/PipedWriter.java	Thu May 19 17:48:02 2016 +0000
+++ b/jdk/src/java.base/share/classes/java/io/PipedWriter.java	Thu May 19 19:46:20 2016 +0000
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 1996, 2006, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 1996, 2016, 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
@@ -125,19 +125,25 @@
     }
 
     /**
-     * Writes <code>len</code> characters from the specified character array
-     * starting at offset <code>off</code> to this piped output stream.
+     * Writes {@code len} characters from the specified character array
+     * starting at offset {@code off} to this piped output stream.
      * This method blocks until all the characters are written to the output
      * stream.
      * If a thread was reading data characters from the connected piped input
      * stream, but the thread is no longer alive, then an
-     * <code>IOException</code> is thrown.
+     * {@code IOException} is thrown.
      *
      * @param      cbuf  the data.
      * @param      off   the start offset in the data.
      * @param      len   the number of characters to write.
-     * @exception  IOException  if the pipe is
-     *          <a href=PipedOutputStream.html#BROKEN> <code>broken</code></a>,
+     *
+     * @throws  IndexOutOfBoundsException
+     *          If {@code off} is negative, or {@code len} is negative,
+     *          or {@code off + len} is negative or greater than the length
+     *          of the given array
+     *
+     * @throws  IOException  if the pipe is
+     *          <a href=PipedOutputStream.html#BROKEN><code>broken</code></a>,
      *          {@link #connect(java.io.PipedReader) unconnected}, closed
      *          or an I/O error occurs.
      */
--- a/jdk/src/java.base/share/classes/java/io/PrintWriter.java	Thu May 19 17:48:02 2016 +0000
+++ b/jdk/src/java.base/share/classes/java/io/PrintWriter.java	Thu May 19 19:46:20 2016 +0000
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 1996, 2015, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 1996, 2016, 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
@@ -410,6 +410,11 @@
      * @param buf Array of characters
      * @param off Offset from which to start writing characters
      * @param len Number of characters to write
+     *
+     * @throws  IndexOutOfBoundsException
+     *          If the values of the {@code off} and {@code len} parameters
+     *          cause the corresponding method of the underlying {@code Writer}
+     *          to throw an {@code IndexOutOfBoundsException}
      */
     public void write(char buf[], int off, int len) {
         try {
@@ -440,6 +445,11 @@
      * @param s A String
      * @param off Offset from which to start writing characters
      * @param len Number of characters to write
+     *
+     * @throws  IndexOutOfBoundsException
+     *          If the values of the {@code off} and {@code len} parameters
+     *          cause the corresponding method of the underlying {@code Writer}
+     *          to throw an {@code IndexOutOfBoundsException}
      */
     public void write(String s, int off, int len) {
         try {
--- a/jdk/src/java.base/share/classes/java/io/StringWriter.java	Thu May 19 17:48:02 2016 +0000
+++ b/jdk/src/java.base/share/classes/java/io/StringWriter.java	Thu May 19 19:46:20 2016 +0000
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 1996, 2004, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 1996, 2016, 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
@@ -83,6 +83,11 @@
      * @param  cbuf  Array of characters
      * @param  off   Offset from which to start writing characters
      * @param  len   Number of characters to write
+     *
+     * @throws  IndexOutOfBoundsException
+     *          If {@code off} is negative, or {@code len} is negative,
+     *          or {@code off + len} is negative or greater than the length
+     *          of the given array
      */
     public void write(char cbuf[], int off, int len) {
         if ((off < 0) || (off > cbuf.length) || (len < 0) ||
@@ -107,6 +112,11 @@
      * @param  str  String to be written
      * @param  off  Offset from which to start writing characters
      * @param  len  Number of characters to write
+     *
+     * @throws  IndexOutOfBoundsException
+     *          If {@code off} is negative, or {@code len} is negative,
+     *          or {@code off + len} is negative or greater than the length
+     *          of the given string
      */
     public void write(String str, int off, int len)  {
         buf.append(str, off, off + len);
--- a/jdk/src/java.base/share/classes/java/io/Writer.java	Thu May 19 17:48:02 2016 +0000
+++ b/jdk/src/java.base/share/classes/java/io/Writer.java	Thu May 19 19:46:20 2016 +0000
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 1996, 2011, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 1996, 2016, 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
@@ -32,12 +32,11 @@
  * Most subclasses, however, will override some of the methods defined here in
  * order to provide higher efficiency, additional functionality, or both.
  *
- * @see Writer
  * @see   BufferedWriter
  * @see   CharArrayWriter
  * @see   FilterWriter
  * @see   OutputStreamWriter
- * @see     FileWriter
+ * @see   FileWriter
  * @see   PipedWriter
  * @see   PrintWriter
  * @see   StringWriter
@@ -139,6 +138,12 @@
      * @param  len
      *         Number of characters to write
      *
+     * @throws  IndexOutOfBoundsException
+     *          Implementations should throw this exception
+     *          if {@code off} is negative, or {@code len} is negative,
+     *          or {@code off + len} is negative or greater than the length
+     *          of the given array
+     *
      * @throws  IOException
      *          If an I/O error occurs
      */
@@ -160,6 +165,11 @@
     /**
      * Writes a portion of a string.
      *
+     * @implSpec
+     * The implementation in this class throws an
+     * {@code IndexOutOfBoundsException} for the indicated conditions;
+     * overriding methods may choose to do otherwise.
+     *
      * @param  str
      *         A String
      *
@@ -170,8 +180,9 @@
      *         Number of characters to write
      *
      * @throws  IndexOutOfBoundsException
-     *          If {@code off} is negative, or {@code len} is negative,
-     *          or {@code off+len} is negative or greater than the length
+     *          Implementations should throw this exception
+     *          if {@code off} is negative, or {@code len} is negative,
+     *          or {@code off + len} is negative or greater than the length
      *          of the given string
      *
      * @throws  IOException
--- a/jdk/src/java.base/share/classes/java/lang/Thread.java	Thu May 19 17:48:02 2016 +0000
+++ b/jdk/src/java.base/share/classes/java/lang/Thread.java	Thu May 19 19:46:20 2016 +0000
@@ -341,6 +341,45 @@
     }
 
     /**
+     * Indicates that the caller is momentarily unable to progress, until the
+     * occurrence of one or more actions on the part of other activities. By
+     * invoking this method within each iteration of a spin-wait loop construct,
+     * the calling thread indicates to the runtime that it is busy-waiting.
+     * The runtime may take action to improve the performance of invoking
+     * spin-wait loop constructions.
+     * <p>
+     * @apiNote
+     * As an example consider a method in a class that spins in a loop until
+     * some flag is set outside of that method. A call to the {@code onSpinWait}
+     * method should be placed inside the spin loop.
+     * <pre>{@code
+     *     class EventHandler {
+     *         volatile boolean eventNotificationNotReceived;
+     *         void waitForEventAndHandleIt() {
+     *             while ( eventNotificationNotReceived ) {
+     *                 java.lang.Thread.onSpinWait();
+     *             }
+     *             readAndProcessEvent();
+     *         }
+     *
+     *         void readAndProcessEvent() {
+     *             // Read event from some source and process it
+     *              . . .
+     *         }
+     *     }
+     * }</pre>
+     * <p>
+     * The code above would remain correct even if the {@code onSpinWait}
+     * method was not called at all. However on some architectures the Java
+     * Virtual Machine may issue the processor instructions to address such
+     * code patterns in a more beneficial way.
+     * <p>
+     * @since 9
+     */
+    @HotSpotIntrinsicCandidate
+    public static void onSpinWait() {}
+
+    /**
      * Initializes a Thread with the current AccessControlContext.
      * @see #init(ThreadGroup,Runnable,String,long,AccessControlContext,boolean)
      */
--- a/jdk/src/java.base/share/classes/java/lang/invoke/InvokerBytecodeGenerator.java	Thu May 19 17:48:02 2016 +0000
+++ b/jdk/src/java.base/share/classes/java/lang/invoke/InvokerBytecodeGenerator.java	Thu May 19 19:46:20 2016 +0000
@@ -706,6 +706,9 @@
                 case ARRAY_STORE:
                     emitArrayStore(name);
                     continue;
+                case ARRAY_LENGTH:
+                    emitArrayLength(name);
+                    continue;
                 case IDENTITY:
                     assert(name.arguments.length == 1);
                     emitPushArguments(name);
@@ -740,15 +743,16 @@
         return classFile;
     }
 
-    void emitArrayLoad(Name name)  { emitArrayOp(name, Opcodes.AALOAD);  }
-    void emitArrayStore(Name name) { emitArrayOp(name, Opcodes.AASTORE); }
+    void emitArrayLoad(Name name)   { emitArrayOp(name, Opcodes.AALOAD);      }
+    void emitArrayStore(Name name)  { emitArrayOp(name, Opcodes.AASTORE);     }
+    void emitArrayLength(Name name) { emitArrayOp(name, Opcodes.ARRAYLENGTH); }
 
     void emitArrayOp(Name name, int arrayOpcode) {
-        assert arrayOpcode == Opcodes.AALOAD || arrayOpcode == Opcodes.AASTORE;
+        assert arrayOpcode == Opcodes.AALOAD || arrayOpcode == Opcodes.AASTORE || arrayOpcode == Opcodes.ARRAYLENGTH;
         Class<?> elementType = name.function.methodType().parameterType(0).getComponentType();
         assert elementType != null;
         emitPushArguments(name);
-        if (elementType.isPrimitive()) {
+        if (arrayOpcode != Opcodes.ARRAYLENGTH && elementType.isPrimitive()) {
             Wrapper w = Wrapper.forPrimitiveType(elementType);
             arrayOpcode = arrayInsnOpcode(arrayTypeCode(w), arrayOpcode);
         }
--- a/jdk/src/java.base/share/classes/java/lang/invoke/Invokers.java	Thu May 19 17:48:02 2016 +0000
+++ b/jdk/src/java.base/share/classes/java/lang/invoke/Invokers.java	Thu May 19 19:46:20 2016 +0000
@@ -95,12 +95,12 @@
 
     /*non-public*/ MethodHandle varHandleMethodInvoker(VarHandle.AccessMode ak) {
         // TODO cache invoker
-        return makeVarHandleMethodInvoker(ak);
+        return makeVarHandleMethodInvoker(ak, false);
     }
 
     /*non-public*/ MethodHandle varHandleMethodExactInvoker(VarHandle.AccessMode ak) {
         // TODO cache invoker
-        return makeVarHandleMethodExactInvoker(ak);
+        return makeVarHandleMethodInvoker(ak, true);
     }
 
     private MethodHandle cachedInvoker(int idx) {
@@ -127,26 +127,11 @@
         return invoker;
     }
 
-    private MethodHandle makeVarHandleMethodInvoker(VarHandle.AccessMode ak) {
+    private MethodHandle makeVarHandleMethodInvoker(VarHandle.AccessMode ak, boolean isExact) {
         MethodType mtype = targetType;
         MethodType invokerType = mtype.insertParameterTypes(0, VarHandle.class);
 
-        LambdaForm lform = varHandleMethodGenericInvokerHandleForm(ak.methodName(), mtype);
-        VarHandle.AccessDescriptor ad = new VarHandle.AccessDescriptor(mtype, ak.at.ordinal(), ak.ordinal());
-        MethodHandle invoker = BoundMethodHandle.bindSingle(invokerType, lform, ad);
-
-        invoker = invoker.withInternalMemberName(MemberName.makeVarHandleMethodInvoke(ak.methodName(), mtype), false);
-        assert(checkVarHandleInvoker(invoker));
-
-        maybeCompileToBytecode(invoker);
-        return invoker;
-    }
-
-    private MethodHandle makeVarHandleMethodExactInvoker(VarHandle.AccessMode ak) {
-        MethodType mtype = targetType;
-        MethodType invokerType = mtype.insertParameterTypes(0, VarHandle.class);
-
-        LambdaForm lform = varHandleMethodExactInvokerHandleForm(ak.methodName(), mtype);
+        LambdaForm lform = varHandleMethodInvokerHandleForm(ak.methodName(), mtype, isExact);
         VarHandle.AccessDescriptor ad = new VarHandle.AccessDescriptor(mtype, ak.at.ordinal(), ak.ordinal());
         MethodHandle invoker = BoundMethodHandle.bindSingle(invokerType, lform, ad);
 
@@ -400,59 +385,7 @@
         return lform;
     }
 
-    private static LambdaForm varHandleMethodExactInvokerHandleForm(String name, MethodType mtype) {
-        // TODO Cache form?
-
-        final int THIS_MH      = 0;
-        final int CALL_VH      = THIS_MH + 1;
-        final int ARG_BASE     = CALL_VH + 1;
-        final int ARG_LIMIT = ARG_BASE + mtype.parameterCount();
-        int nameCursor = ARG_LIMIT;
-        final int VAD_ARG      = nameCursor++;
-        final int CHECK_TYPE   = nameCursor++;
-        final int GET_MEMBER   = nameCursor++;
-        final int LINKER_CALL  = nameCursor++;
-
-        MethodType invokerFormType = mtype.insertParameterTypes(0, VarHandle.class)
-                .basicType()
-                .appendParameterTypes(MemberName.class);
-
-        MemberName linker = new MemberName(MethodHandle.class, "linkToStatic", invokerFormType, REF_invokeStatic);
-        try {
-            linker = MemberName.getFactory().resolveOrFail(REF_invokeStatic, linker, null, NoSuchMethodException.class);
-        } catch (ReflectiveOperationException ex) {
-            throw newInternalError(ex);
-        }
-
-        Name[] names = new Name[LINKER_CALL + 1];
-        names[THIS_MH] = argument(THIS_MH, BasicType.basicType(Object.class));
-        names[CALL_VH] = argument(CALL_VH, BasicType.basicType(Object.class));
-        for (int i = 0; i < mtype.parameterCount(); i++) {
-            names[ARG_BASE + i] = argument(ARG_BASE + i, BasicType.basicType(mtype.parameterType(i)));
-        }
-
-        BoundMethodHandle.SpeciesData speciesData = BoundMethodHandle.speciesData_L();
-        names[THIS_MH] = names[THIS_MH].withConstraint(speciesData);
-
-        NamedFunction getter = speciesData.getterFunction(0);
-        names[VAD_ARG] = new Name(getter, names[THIS_MH]);
-
-        Object[] outArgs = Arrays.copyOfRange(names, CALL_VH, ARG_LIMIT + 1, Object[].class);
-
-        names[CHECK_TYPE] = new Name(NF_checkVarHandleExactType, names[CALL_VH], names[VAD_ARG]);
-
-        names[GET_MEMBER] = new Name(NF_getVarHandleMemberName, names[CALL_VH], names[VAD_ARG]);
-        outArgs[outArgs.length - 1] = names[GET_MEMBER];
-
-        names[LINKER_CALL] = new Name(linker, outArgs);
-        LambdaForm lform = new LambdaForm(name + ":VarHandle_exactInvoker" + shortenSignature(basicTypeSignature(mtype)),
-                                          ARG_LIMIT, names);
-
-        lform.compileToBytecode();
-        return lform;
-    }
-
-    private static LambdaForm varHandleMethodGenericInvokerHandleForm(String name, MethodType mtype) {
+    private static LambdaForm varHandleMethodInvokerHandleForm(String name, MethodType mtype, boolean isExact) {
         // TODO Cache form?
 
         final int THIS_MH      = 0;
@@ -477,8 +410,11 @@
         NamedFunction getter = speciesData.getterFunction(0);
         names[VAD_ARG] = new Name(getter, names[THIS_MH]);
 
-        names[CHECK_TYPE] = new Name(NF_checkVarHandleGenericType, names[CALL_VH], names[VAD_ARG]);
-
+        if (isExact) {
+            names[CHECK_TYPE] = new Name(NF_checkVarHandleExactType, names[CALL_VH], names[VAD_ARG]);
+        } else {
+            names[CHECK_TYPE] = new Name(NF_checkVarHandleGenericType, names[CALL_VH], names[VAD_ARG]);
+        }
         Object[] outArgs = new Object[ARG_LIMIT];
         outArgs[0] = names[CHECK_TYPE];
         for (int i = 1; i < ARG_LIMIT; i++) {
@@ -488,7 +424,8 @@
         MethodType outCallType = mtype.insertParameterTypes(0, VarHandle.class)
                 .basicType();
         names[LINKER_CALL] = new Name(outCallType, outArgs);
-        LambdaForm lform = new LambdaForm(name + ":VarHandle_invoker" + shortenSignature(basicTypeSignature(mtype)),
+        String debugName = isExact ? ":VarHandle_exactInvoker" : ":VarHandle_invoker";
+        LambdaForm lform = new LambdaForm(name + debugName + shortenSignature(basicTypeSignature(mtype)),
                                           ARG_LIMIT, names);
 
         lform.prepare();
@@ -511,21 +448,13 @@
 
     /*non-public*/ static
     @ForceInline
-    void checkVarHandleExactType(VarHandle handle, VarHandle.AccessDescriptor ad) {
-        MethodType erasedTarget = handle.vform.methodType_table[ad.type];
-        MethodType erasedSymbolic = ad.symbolicMethodTypeErased;
-        if (erasedTarget != erasedSymbolic)
-            throw newWrongMethodTypeException(erasedTarget, erasedSymbolic);
-    }
-
-    /*non-public*/ static
-    @ForceInline
-    MemberName getVarHandleMemberName(VarHandle handle, VarHandle.AccessDescriptor ad) {
-        MemberName mn = handle.vform.memberName_table[ad.mode];
-        if (mn == null) {
-            throw handle.unsupported();
+    MethodHandle checkVarHandleExactType(VarHandle handle, VarHandle.AccessDescriptor ad) {
+        MethodHandle mh = handle.getMethodHandle(ad.mode);
+        MethodType mt = mh.type();
+        if (mt != ad.symbolicMethodTypeInvoker) {
+            throw newWrongMethodTypeException(mt, ad.symbolicMethodTypeInvoker);
         }
-        return mn;
+        return mh;
     }
 
     /*non-public*/ static
@@ -649,8 +578,7 @@
         NF_getCallSiteTarget,
         NF_checkCustomized,
         NF_checkVarHandleGenericType,
-        NF_checkVarHandleExactType,
-        NF_getVarHandleMemberName;
+        NF_checkVarHandleExactType;
     static {
         try {
             NamedFunction nfs[] = {
@@ -666,8 +594,6 @@
                         .getDeclaredMethod("checkVarHandleGenericType", VarHandle.class, VarHandle.AccessDescriptor.class)),
                 NF_checkVarHandleExactType = new NamedFunction(Invokers.class
                         .getDeclaredMethod("checkVarHandleExactType", VarHandle.class, VarHandle.AccessDescriptor.class)),
-                NF_getVarHandleMemberName = new NamedFunction(Invokers.class
-                        .getDeclaredMethod("getVarHandleMemberName", VarHandle.class, VarHandle.AccessDescriptor.class))
             };
             // Each nf must be statically invocable or we get tied up in our bootstraps.
             assert(InvokerBytecodeGenerator.isStaticallyInvocable(nfs));
--- a/jdk/src/java.base/share/classes/java/lang/invoke/MethodHandleImpl.java	Thu May 19 17:48:02 2016 +0000
+++ b/jdk/src/java.base/share/classes/java/lang/invoke/MethodHandleImpl.java	Thu May 19 19:46:20 2016 +0000
@@ -41,9 +41,15 @@
 import sun.invoke.util.ValueConversions;
 import sun.invoke.util.VerifyType;
 import sun.invoke.util.Wrapper;
+
+import jdk.internal.org.objectweb.asm.AnnotationVisitor;
+import jdk.internal.org.objectweb.asm.ClassWriter;
+import jdk.internal.org.objectweb.asm.MethodVisitor;
+
 import static java.lang.invoke.LambdaForm.*;
 import static java.lang.invoke.MethodHandleStatics.*;
 import static java.lang.invoke.MethodHandles.Lookup.IMPL_LOOKUP;
+import static jdk.internal.org.objectweb.asm.Opcodes.*;
 
 /**
  * Trusted implementation code for MethodHandle.
@@ -66,25 +72,28 @@
 
     /// Factory methods to create method handles:
 
-    static MethodHandle makeArrayElementAccessor(Class<?> arrayClass, boolean isSetter) {
-        if (arrayClass == Object[].class)
-            return (isSetter ? ArrayAccessor.OBJECT_ARRAY_SETTER : ArrayAccessor.OBJECT_ARRAY_GETTER);
+    static MethodHandle makeArrayElementAccessor(Class<?> arrayClass, ArrayAccess access) {
+        if (arrayClass == Object[].class) {
+            return ArrayAccess.objectAccessor(access);
+        }
         if (!arrayClass.isArray())
             throw newIllegalArgumentException("not an array: "+arrayClass);
         MethodHandle[] cache = ArrayAccessor.TYPED_ACCESSORS.get(arrayClass);
-        int cacheIndex = (isSetter ? ArrayAccessor.SETTER_INDEX : ArrayAccessor.GETTER_INDEX);
+        int cacheIndex = ArrayAccess.cacheIndex(access);
         MethodHandle mh = cache[cacheIndex];
         if (mh != null)  return mh;
-        mh = ArrayAccessor.getAccessor(arrayClass, isSetter);
-        MethodType correctType = ArrayAccessor.correctType(arrayClass, isSetter);
+        mh = ArrayAccessor.getAccessor(arrayClass, access);
+        MethodType correctType = ArrayAccessor.correctType(arrayClass, access);
         if (mh.type() != correctType) {
             assert(mh.type().parameterType(0) == Object[].class);
-            assert((isSetter ? mh.type().parameterType(2) : mh.type().returnType()) == Object.class);
-            assert(isSetter || correctType.parameterType(0).getComponentType() == correctType.returnType());
+            /* if access == SET */ assert(access != ArrayAccess.SET || mh.type().parameterType(2) == Object.class);
+            /* if access == GET */ assert(access != ArrayAccess.GET ||
+                    (mh.type().returnType() == Object.class &&
+                     correctType.parameterType(0).getComponentType() == correctType.returnType()));
             // safe to view non-strictly, because element type follows from array type
             mh = mh.viewAsType(correctType, false);
         }
-        mh = makeIntrinsic(mh, (isSetter ? Intrinsic.ARRAY_STORE : Intrinsic.ARRAY_LOAD));
+        mh = makeIntrinsic(mh, ArrayAccess.intrinsic(access));
         // Atomically update accessor cache.
         synchronized(cache) {
             if (cache[cacheIndex] == null) {
@@ -97,9 +106,52 @@
         return mh;
     }
 
+    enum ArrayAccess {
+        GET, SET, LENGTH;
+
+        // As ArrayAccess and ArrayAccessor have a circular dependency, the ArrayAccess properties cannot be stored in
+        // final fields.
+
+        static String opName(ArrayAccess a) {
+            switch (a) {
+                case GET: return "getElement";
+                case SET: return "setElement";
+                case LENGTH: return "length";
+            }
+            throw new AssertionError();
+        }
+
+        static MethodHandle objectAccessor(ArrayAccess a) {
+            switch (a) {
+                case GET: return ArrayAccessor.OBJECT_ARRAY_GETTER;
+                case SET: return ArrayAccessor.OBJECT_ARRAY_SETTER;
+                case LENGTH: return ArrayAccessor.OBJECT_ARRAY_LENGTH;
+            }
+            throw new AssertionError();
+        }
+
+        static int cacheIndex(ArrayAccess a) {
+            switch (a) {
+                case GET: return ArrayAccessor.GETTER_INDEX;
+                case SET: return ArrayAccessor.SETTER_INDEX;
+                case LENGTH: return ArrayAccessor.LENGTH_INDEX;
+            }
+            throw new AssertionError();
+        }
+
+        static Intrinsic intrinsic(ArrayAccess a) {
+            switch (a) {
+                case GET: return Intrinsic.ARRAY_LOAD;
+                case SET: return Intrinsic.ARRAY_STORE;
+                case LENGTH: return Intrinsic.ARRAY_LENGTH;
+            }
+            throw new AssertionError();
+        }
+    }
+
     static final class ArrayAccessor {
-        /// Support for array element access
-        static final int GETTER_INDEX = 0, SETTER_INDEX = 1, INDEX_LIMIT = 2;
+        /// Support for array element and length access
+        static final int GETTER_INDEX = 0, SETTER_INDEX = 1, LENGTH_INDEX = 2, INDEX_LIMIT = 3;
         static final ClassValue<MethodHandle[]> TYPED_ACCESSORS
                 = new ClassValue<MethodHandle[]>() {
                     @Override
@@ -107,14 +159,16 @@
                         return new MethodHandle[INDEX_LIMIT];
                     }
                 };
-        static final MethodHandle OBJECT_ARRAY_GETTER, OBJECT_ARRAY_SETTER;
+        static final MethodHandle OBJECT_ARRAY_GETTER, OBJECT_ARRAY_SETTER, OBJECT_ARRAY_LENGTH;
         static {
             MethodHandle[] cache = TYPED_ACCESSORS.get(Object[].class);
-            cache[GETTER_INDEX] = OBJECT_ARRAY_GETTER = makeIntrinsic(getAccessor(Object[].class, false), Intrinsic.ARRAY_LOAD);
-            cache[SETTER_INDEX] = OBJECT_ARRAY_SETTER = makeIntrinsic(getAccessor(Object[].class, true),  Intrinsic.ARRAY_STORE);
+            cache[GETTER_INDEX] = OBJECT_ARRAY_GETTER = makeIntrinsic(getAccessor(Object[].class, ArrayAccess.GET),    Intrinsic.ARRAY_LOAD);
+            cache[SETTER_INDEX] = OBJECT_ARRAY_SETTER = makeIntrinsic(getAccessor(Object[].class, ArrayAccess.SET),    Intrinsic.ARRAY_STORE);
+            cache[LENGTH_INDEX] = OBJECT_ARRAY_LENGTH = makeIntrinsic(getAccessor(Object[].class, ArrayAccess.LENGTH), Intrinsic.ARRAY_LENGTH);
 
             assert(InvokerBytecodeGenerator.isStaticallyInvocable(ArrayAccessor.OBJECT_ARRAY_GETTER.internalMemberName()));
             assert(InvokerBytecodeGenerator.isStaticallyInvocable(ArrayAccessor.OBJECT_ARRAY_SETTER.internalMemberName()));
+            assert(InvokerBytecodeGenerator.isStaticallyInvocable(ArrayAccessor.OBJECT_ARRAY_LENGTH.internalMemberName()));
         }
 
         static int     getElementI(int[]     a, int i)            { return              a[i]; }
@@ -137,31 +191,47 @@
         static void    setElementC(char[]    a, int i, char    x) {              a[i] = x; }
         static void    setElementL(Object[]  a, int i, Object  x) {              a[i] = x; }
 
-        static String name(Class<?> arrayClass, boolean isSetter) {
+        static int     lengthI(int[]     a)                       { return a.length; }
+        static int     lengthJ(long[]    a)                       { return a.length; }
+        static int     lengthF(float[]   a)                       { return a.length; }
+        static int     lengthD(double[]  a)                       { return a.length; }
+        static int     lengthZ(boolean[] a)                       { return a.length; }
+        static int     lengthB(byte[]    a)                       { return a.length; }
+        static int     lengthS(short[]   a)                       { return a.length; }
+        static int     lengthC(char[]    a)                       { return a.length; }
+        static int     lengthL(Object[]  a)                       { return a.length; }
+
+        static String name(Class<?> arrayClass, ArrayAccess access) {
             Class<?> elemClass = arrayClass.getComponentType();
             if (elemClass == null)  throw newIllegalArgumentException("not an array", arrayClass);
-            return (!isSetter ? "getElement" : "setElement") + Wrapper.basicTypeChar(elemClass);
+            return ArrayAccess.opName(access) + Wrapper.basicTypeChar(elemClass);
         }
-        static MethodType type(Class<?> arrayClass, boolean isSetter) {
+        static MethodType type(Class<?> arrayClass, ArrayAccess access) {
             Class<?> elemClass = arrayClass.getComponentType();
             Class<?> arrayArgClass = arrayClass;
             if (!elemClass.isPrimitive()) {
                 arrayArgClass = Object[].class;
                 elemClass = Object.class;
             }
-            return !isSetter ?
-                    MethodType.methodType(elemClass,  arrayArgClass, int.class) :
-                    MethodType.methodType(void.class, arrayArgClass, int.class, elemClass);
+            switch (access) {
+                case GET:    return MethodType.methodType(elemClass,  arrayArgClass, int.class);
+                case SET:    return MethodType.methodType(void.class, arrayArgClass, int.class, elemClass);
+                case LENGTH: return MethodType.methodType(int.class,  arrayArgClass);
+            }
+            throw new IllegalStateException("should not reach here");
         }
-        static MethodType correctType(Class<?> arrayClass, boolean isSetter) {
+        static MethodType correctType(Class<?> arrayClass, ArrayAccess access) {
             Class<?> elemClass = arrayClass.getComponentType();
-            return !isSetter ?
-                    MethodType.methodType(elemClass,  arrayClass, int.class) :
-                    MethodType.methodType(void.class, arrayClass, int.class, elemClass);
+            switch (access) {
+                case GET:    return MethodType.methodType(elemClass,  arrayClass, int.class);
+                case SET:    return MethodType.methodType(void.class, arrayClass, int.class, elemClass);
+                case LENGTH: return MethodType.methodType(int.class,  arrayClass);
+            }
+            throw new IllegalStateException("should not reach here");
         }
-        static MethodHandle getAccessor(Class<?> arrayClass, boolean isSetter) {
-            String     name = name(arrayClass, isSetter);
-            MethodType type = type(arrayClass, isSetter);
+        static MethodHandle getAccessor(Class<?> arrayClass, ArrayAccess access) {
+            String     name = name(arrayClass, access);
+            MethodType type = type(arrayClass, access);
             try {
                 return IMPL_LOOKUP.findStatic(ArrayAccessor.class, name, type);
             } catch (ReflectiveOperationException ex) {
@@ -1091,6 +1161,8 @@
     // Put the whole mess into its own nested class.
     // That way we can lazily load the code and set up the constants.
     private static class BindCaller {
+        private static MethodType INVOKER_MT = MethodType.methodType(Object.class, MethodHandle.class, Object[].class);
+
         static
         MethodHandle bindCaller(MethodHandle mh, Class<?> hostClass) {
             // Do not use this function to inject calls into system classes.
@@ -1109,38 +1181,15 @@
         }
 
         private static MethodHandle makeInjectedInvoker(Class<?> hostClass) {
-            Class<?> bcc = UNSAFE.defineAnonymousClass(hostClass, T_BYTES, null);
-            if (hostClass.getClassLoader() != bcc.getClassLoader())
-                throw new InternalError(hostClass.getName()+" (CL)");
             try {
-                if (hostClass.getProtectionDomain() != bcc.getProtectionDomain())
-                    throw new InternalError(hostClass.getName()+" (PD)");
-            } catch (SecurityException ex) {
-                // Self-check was blocked by security manager.  This is OK.
-                // In fact the whole try body could be turned into an assertion.
-            }
-            try {
-                MethodHandle init = IMPL_LOOKUP.findStatic(bcc, "init", MethodType.methodType(void.class));
-                init.invokeExact();  // force initialization of the class
-            } catch (Throwable ex) {
-                throw uncaughtException(ex);
-            }
-            MethodHandle bccInvoker;
-            try {
-                MethodType invokerMT = MethodType.methodType(Object.class, MethodHandle.class, Object[].class);
-                bccInvoker = IMPL_LOOKUP.findStatic(bcc, "invoke_V", invokerMT);
+                Class<?> invokerClass = UNSAFE.defineAnonymousClass(hostClass, INJECTED_INVOKER_TEMPLATE, null);
+                assert checkInjectedInvoker(hostClass, invokerClass);
+                return IMPL_LOOKUP.findStatic(invokerClass, "invoke_V", INVOKER_MT);
             } catch (ReflectiveOperationException ex) {
                 throw uncaughtException(ex);
             }
-            // Test the invoker, to ensure that it really injects into the right place.
-            try {
-                MethodHandle vamh = prepareForInvoker(MH_checkCallerClass);
-                Object ok = bccInvoker.invokeExact(vamh, new Object[]{hostClass, bcc});
-            } catch (Throwable ex) {
-                throw new InternalError(ex);
-            }
-            return bccInvoker;
         }
+
         private static ClassValue<MethodHandle> CV_makeInjectedInvoker = new ClassValue<MethodHandle>() {
             @Override protected MethodHandle computeValue(Class<?> hostClass) {
                 return makeInjectedInvoker(hostClass);
@@ -1171,62 +1220,82 @@
             return mh;
         }
 
+        private static boolean checkInjectedInvoker(Class<?> hostClass, Class<?> invokerClass) {
+            assert (hostClass.getClassLoader() == invokerClass.getClassLoader()) : hostClass.getName()+" (CL)";
+            try {
+                assert (hostClass.getProtectionDomain() == invokerClass.getProtectionDomain()) : hostClass.getName()+" (PD)";
+            } catch (SecurityException ex) {
+                // Self-check was blocked by security manager. This is OK.
+            }
+            try {
+                // Test the invoker to ensure that it really injects into the right place.
+                MethodHandle invoker = IMPL_LOOKUP.findStatic(invokerClass, "invoke_V", INVOKER_MT);
+                MethodHandle vamh = prepareForInvoker(MH_checkCallerClass);
+                return (boolean)invoker.invoke(vamh, new Object[]{ invokerClass });
+            } catch (Throwable ex) {
+                throw new InternalError(ex);
+            }
+        }
+
         private static final MethodHandle MH_checkCallerClass;
         static {
             final Class<?> THIS_CLASS = BindCaller.class;
-            assert(checkCallerClass(THIS_CLASS, THIS_CLASS));
+            assert(checkCallerClass(THIS_CLASS));
             try {
                 MH_checkCallerClass = IMPL_LOOKUP
                     .findStatic(THIS_CLASS, "checkCallerClass",
-                                MethodType.methodType(boolean.class, Class.class, Class.class));
-                assert((boolean) MH_checkCallerClass.invokeExact(THIS_CLASS, THIS_CLASS));
+                                MethodType.methodType(boolean.class, Class.class));
+                assert((boolean) MH_checkCallerClass.invokeExact(THIS_CLASS));
             } catch (Throwable ex) {
                 throw new InternalError(ex);
             }
         }
 
         @CallerSensitive
-        private static boolean checkCallerClass(Class<?> expected, Class<?> expected2) {
-            // This method is called via MH_checkCallerClass and so it's
-            // correct to ask for the immediate caller here.
+        private static boolean checkCallerClass(Class<?> expected) {
+            // This method is called via MH_checkCallerClass and so it's correct to ask for the immediate caller here.
             Class<?> actual = Reflection.getCallerClass();
-            if (actual != expected && actual != expected2)
-                throw new InternalError("found "+actual.getName()+", expected "+expected.getName()
-                                        +(expected == expected2 ? "" : ", or else "+expected2.getName()));
+            if (actual != expected)
+                throw new InternalError("found " + actual.getName() + ", expected " + expected.getName());
             return true;
         }
 
-        private static final byte[] T_BYTES;
-        static {
-            final Object[] values = {null};
-            AccessController.doPrivileged(new PrivilegedAction<>() {
-                    public Void run() {
-                        try {
-                            Class<T> tClass = T.class;
-                            String tName = tClass.getName();
-                            String tResource = tName.substring(tName.lastIndexOf('.')+1)+".class";
-                            try (java.io.InputStream in = tClass.getResourceAsStream(tResource)) {
-                                values[0] = in.readAllBytes();
-                            }
-                        } catch (java.io.IOException ex) {
-                            throw new InternalError(ex);
-                        }
-                        return null;
-                    }
-                });
-            T_BYTES = (byte[]) values[0];
-        }
+        private static final byte[] INJECTED_INVOKER_TEMPLATE = generateInvokerTemplate();
+
+        /** Produces byte code for a class that is used as an injected invoker. */
+        private static byte[] generateInvokerTemplate() {
+            ClassWriter cw = new ClassWriter(0);
+
+            // private static class InjectedInvoker {
+            //     @Hidden
+            //     static Object invoke_V(MethodHandle vamh, Object[] args) throws Throwable {
+            //        return vamh.invokeExact(args);
+            //     }
+            // }
+            cw.visit(52, ACC_PRIVATE | ACC_SUPER, "InjectedInvoker", null, "java/lang/Object", null);
 
-        // The following class is used as a template for Unsafe.defineAnonymousClass:
-        private static class T {
-            static void init() { }  // side effect: initializes this class
-            static Object invoke_V(MethodHandle vamh, Object[] args) throws Throwable {
-                return vamh.invokeExact(args);
-            }
+            MethodVisitor mv = cw.visitMethod(ACC_STATIC, "invoke_V",
+                          "(Ljava/lang/invoke/MethodHandle;[Ljava/lang/Object;)Ljava/lang/Object;",
+                          null, null);
+
+            // Suppress invoker method in stack traces.
+            AnnotationVisitor av0 = mv.visitAnnotation("Ljava/lang/invoke/LambdaForm$Hidden;", true);
+            av0.visitEnd();
+
+            mv.visitCode();
+            mv.visitVarInsn(ALOAD, 0);
+            mv.visitVarInsn(ALOAD, 1);
+            mv.visitMethodInsn(INVOKEVIRTUAL, "java/lang/invoke/MethodHandle", "invokeExact",
+                               "([Ljava/lang/Object;)Ljava/lang/Object;", false);
+            mv.visitInsn(ARETURN);
+            mv.visitMaxs(2, 2);
+            mv.visitEnd();
+
+            cw.visitEnd();
+            return cw.toByteArray();
         }
     }
 
-
     /** This subclass allows a wrapped method handle to be re-associated with an arbitrary member name. */
     private static final class WrappedMember extends DelegatingMethodHandle {
         private final MethodHandle target;
@@ -1282,6 +1351,7 @@
         NEW_ARRAY,
         ARRAY_LOAD,
         ARRAY_STORE,
+        ARRAY_LENGTH,
         IDENTITY,
         ZERO,
         NONE // no intrinsic associated
--- a/jdk/src/java.base/share/classes/java/lang/invoke/MethodHandles.java	Thu May 19 17:48:02 2016 +0000
+++ b/jdk/src/java.base/share/classes/java/lang/invoke/MethodHandles.java	Thu May 19 19:46:20 2016 +0000
@@ -2245,6 +2245,20 @@
     }
 
     /**
+     * Produces a method handle returning the length of an array.
+     * The type of the method handle will have {@code int} as return type,
+     * and its sole argument will be the array type.
+     * @param arrayClass an array type
+     * @return a method handle which can retrieve the length of an array of the given array type
+     * @throws NullPointerException if the argument is {@code null}
+     * @throws IllegalArgumentException if arrayClass is not an array type
+     */
+    public static
+    MethodHandle arrayLength(Class<?> arrayClass) throws IllegalArgumentException {
+        return MethodHandleImpl.makeArrayElementAccessor(arrayClass, MethodHandleImpl.ArrayAccess.LENGTH);
+    }
+
+    /**
      * Produces a method handle giving read access to elements of an array.
      * The type of the method handle will have a return type of the array's
      * element type.  Its first argument will be the array type,
@@ -2256,7 +2270,7 @@
      */
     public static
     MethodHandle arrayElementGetter(Class<?> arrayClass) throws IllegalArgumentException {
-        return MethodHandleImpl.makeArrayElementAccessor(arrayClass, false);
+        return MethodHandleImpl.makeArrayElementAccessor(arrayClass, MethodHandleImpl.ArrayAccess.GET);
     }
 
     /**
@@ -2271,7 +2285,7 @@
      */
     public static
     MethodHandle arrayElementSetter(Class<?> arrayClass) throws IllegalArgumentException {
-        return MethodHandleImpl.makeArrayElementAccessor(arrayClass, true);
+        return MethodHandleImpl.makeArrayElementAccessor(arrayClass, MethodHandleImpl.ArrayAccess.SET);
     }
 
     /**
--- a/jdk/src/java.base/share/classes/java/lang/invoke/StringConcatFactory.java	Thu May 19 17:48:02 2016 +0000
+++ b/jdk/src/java.base/share/classes/java/lang/invoke/StringConcatFactory.java	Thu May 19 19:46:20 2016 +0000
@@ -128,7 +128,7 @@
     /**
      * Default strategy to use for concatenation.
      */
-    private static final Strategy DEFAULT_STRATEGY = Strategy.BC_SB;
+    private static final Strategy DEFAULT_STRATEGY = Strategy.MH_INLINE_SIZED_EXACT;
 
     private enum Strategy {
         /**
--- a/jdk/src/java.base/share/classes/java/lang/invoke/VarHandle.java	Thu May 19 17:48:02 2016 +0000
+++ b/jdk/src/java.base/share/classes/java/lang/invoke/VarHandle.java	Thu May 19 19:46:20 2016 +0000
@@ -26,6 +26,7 @@
 package java.lang.invoke;
 
 import jdk.internal.HotSpotIntrinsicCandidate;
+import jdk.internal.util.Preconditions;
 import jdk.internal.vm.annotation.ForceInline;
 import jdk.internal.vm.annotation.Stable;
 
@@ -33,7 +34,6 @@
 import java.util.HashMap;
 import java.util.List;
 import java.util.Map;
-import java.util.Objects;
 import java.util.function.BiFunction;
 import java.util.function.Function;
 
@@ -1475,11 +1475,11 @@
         TypesAndInvokers tis = getTypesAndInvokers();
         MethodHandle mh = tis.methodHandle_table[mode];
         if (mh == null) {
-            mh = tis.methodHandle_table[mode] = getMethodHandleUncached(tis, mode);
+            mh = tis.methodHandle_table[mode] = getMethodHandleUncached(mode);
         }
         return mh;
     }
-    private final MethodHandle getMethodHandleUncached(TypesAndInvokers tis, int mode) {
+    private final MethodHandle getMethodHandleUncached(int mode) {
         MethodType mt = accessModeType(AccessMode.values()[mode]).
                 insertParameterTypes(0, VarHandle.class);
         MemberName mn = vform.getMemberName(mode);
@@ -1501,7 +1501,7 @@
     }
 
     static final BiFunction<String, List<Integer>, ArrayIndexOutOfBoundsException>
-            AIOOBE_SUPPLIER = Objects.outOfBoundsExceptionFormatter(
+            AIOOBE_SUPPLIER = Preconditions.outOfBoundsExceptionFormatter(
             new Function<String, ArrayIndexOutOfBoundsException>() {
                 @Override
                 public ArrayIndexOutOfBoundsException apply(String s) {
--- a/jdk/src/java.base/share/classes/java/lang/invoke/X-VarHandle.java.template	Thu May 19 17:48:02 2016 +0000
+++ b/jdk/src/java.base/share/classes/java/lang/invoke/X-VarHandle.java.template	Thu May 19 19:46:20 2016 +0000
@@ -24,8 +24,10 @@
  */
 package java.lang.invoke;
 
+import jdk.internal.util.Preconditions;
+import jdk.internal.vm.annotation.ForceInline;
+
 import java.util.Objects;
-import jdk.internal.vm.annotation.ForceInline;
 
 import static java.lang.invoke.MethodHandleStatics.UNSAFE;
 
@@ -163,8 +165,7 @@
 
         @ForceInline
         static boolean weakCompareAndSetVolatile(FieldInstanceReadWrite handle, Object holder, $type$ expected, $type$ value) {
-            // TODO defer to strong form until new Unsafe method is added
-            return UNSAFE.compareAndSwap$Type$(Objects.requireNonNull(handle.receiverType.cast(holder)),
+            return UNSAFE.weakCompareAndSwap$Type$Volatile(Objects.requireNonNull(handle.receiverType.cast(holder)),
                                                handle.fieldOffset,
                                                {#if[Object]?handle.fieldType.cast(expected):expected},
                                                {#if[Object]?handle.fieldType.cast(value):value});
@@ -345,8 +346,7 @@
 
         @ForceInline
         static boolean weakCompareAndSetVolatile(FieldStaticReadWrite handle, $type$ expected, $type$ value) {
-            // TODO defer to strong form until new Unsafe method is added
-            return UNSAFE.compareAndSwap$Type$(handle.base,
+            return UNSAFE.weakCompareAndSwap$Type$Volatile(handle.base,
                                                handle.fieldOffset,
                                                {#if[Object]?handle.fieldType.cast(expected):expected},
                                                {#if[Object]?handle.fieldType.cast(value):value});
@@ -447,7 +447,7 @@
             $type$[] array = ($type$[]) oarray;
 #end[Object]
             return UNSAFE.get$Type$Volatile(array,
-                    (((long) Objects.checkIndex(index, array.length, AIOOBE_SUPPLIER)) << handle.ashift) + handle.abase);
+                    (((long) Preconditions.checkIndex(index, array.length, AIOOBE_SUPPLIER)) << handle.ashift) + handle.abase);
         }
 
         @ForceInline
@@ -458,7 +458,7 @@
             $type$[] array = ($type$[]) oarray;
 #end[Object]
             UNSAFE.put$Type$Volatile(array,
-                    (((long) Objects.checkIndex(index, array.length, AIOOBE_SUPPLIER)) << handle.ashift) + handle.abase,
+                    (((long) Preconditions.checkIndex(index, array.length, AIOOBE_SUPPLIER)) << handle.ashift) + handle.abase,
                     {#if[Object]?handle.componentType.cast(value):value});
         }
 
@@ -470,7 +470,7 @@
             $type$[] array = ($type$[]) oarray;
 #end[Object]
             return UNSAFE.get$Type$Opaque(array,
-                    (((long) Objects.checkIndex(index, array.length, AIOOBE_SUPPLIER)) << handle.ashift) + handle.abase);
+                    (((long) Preconditions.checkIndex(index, array.length, AIOOBE_SUPPLIER)) << handle.ashift) + handle.abase);
         }
 
         @ForceInline
@@ -481,7 +481,7 @@
             $type$[] array = ($type$[]) oarray;
 #end[Object]
             UNSAFE.put$Type$Opaque(array,
-                    (((long) Objects.checkIndex(index, array.length, AIOOBE_SUPPLIER)) << handle.ashift) + handle.abase,
+                    (((long) Preconditions.checkIndex(index, array.length, AIOOBE_SUPPLIER)) << handle.ashift) + handle.abase,
                     {#if[Object]?handle.componentType.cast(value):value});
         }
 
@@ -493,7 +493,7 @@
             $type$[] array = ($type$[]) oarray;
 #end[Object]
             return UNSAFE.get$Type$Acquire(array,
-                    (((long) Objects.checkIndex(index, array.length, AIOOBE_SUPPLIER)) << handle.ashift) + handle.abase);
+                    (((long) Preconditions.checkIndex(index, array.length, AIOOBE_SUPPLIER)) << handle.ashift) + handle.abase);
         }
 
         @ForceInline
@@ -504,7 +504,7 @@
             $type$[] array = ($type$[]) oarray;
 #end[Object]
             UNSAFE.put$Type$Release(array,
-                    (((long) Objects.checkIndex(index, array.length, AIOOBE_SUPPLIER)) << handle.ashift) + handle.abase,
+                    (((long) Preconditions.checkIndex(index, array.length, AIOOBE_SUPPLIER)) << handle.ashift) + handle.abase,
                     {#if[Object]?handle.componentType.cast(value):value});
         }
 #if[CAS]
@@ -517,7 +517,7 @@
             $type$[] array = ($type$[]) oarray;
 #end[Object]
             return UNSAFE.compareAndSwap$Type$(array,
-                    (((long) Objects.checkIndex(index, array.length, AIOOBE_SUPPLIER)) << handle.ashift) + handle.abase,
+                    (((long) Preconditions.checkIndex(index, array.length, AIOOBE_SUPPLIER)) << handle.ashift) + handle.abase,
                     {#if[Object]?handle.componentType.cast(expected):expected},
                     {#if[Object]?handle.componentType.cast(value):value});
         }
@@ -530,7 +530,7 @@
             $type$[] array = ($type$[]) oarray;
 #end[Object]
             return UNSAFE.compareAndExchange$Type$Volatile(array,
-                    (((long) Objects.checkIndex(index, array.length, AIOOBE_SUPPLIER)) << handle.ashift) + handle.abase,
+                    (((long) Preconditions.checkIndex(index, array.length, AIOOBE_SUPPLIER)) << handle.ashift) + handle.abase,
                     {#if[Object]?handle.componentType.cast(expected):expected},
                     {#if[Object]?handle.componentType.cast(value):value});
         }
@@ -543,7 +543,7 @@
             $type$[] array = ($type$[]) oarray;
 #end[Object]
             return UNSAFE.compareAndExchange$Type$Acquire(array,
-                    (((long) Objects.checkIndex(index, array.length, AIOOBE_SUPPLIER)) << handle.ashift) + handle.abase,
+                    (((long) Preconditions.checkIndex(index, array.length, AIOOBE_SUPPLIER)) << handle.ashift) + handle.abase,
                     {#if[Object]?handle.componentType.cast(expected):expected},
                     {#if[Object]?handle.componentType.cast(value):value});
         }
@@ -556,7 +556,7 @@
             $type$[] array = ($type$[]) oarray;
 #end[Object]
             return UNSAFE.compareAndExchange$Type$Release(array,
-                    (((long) Objects.checkIndex(index, array.length, AIOOBE_SUPPLIER)) << handle.ashift) + handle.abase,
+                    (((long) Preconditions.checkIndex(index, array.length, AIOOBE_SUPPLIER)) << handle.ashift) + handle.abase,
                     {#if[Object]?handle.componentType.cast(expected):expected},
                     {#if[Object]?handle.componentType.cast(value):value});
         }
@@ -569,7 +569,7 @@
             $type$[] array = ($type$[]) oarray;
 #end[Object]
             return UNSAFE.weakCompareAndSwap$Type$(array,
-                    (((long) Objects.checkIndex(index, array.length, AIOOBE_SUPPLIER)) << handle.ashift) + handle.abase,
+                    (((long) Preconditions.checkIndex(index, array.length, AIOOBE_SUPPLIER)) << handle.ashift) + handle.abase,
                     {#if[Object]?handle.componentType.cast(expected):expected},
                     {#if[Object]?handle.componentType.cast(value):value});
         }
@@ -581,9 +581,8 @@
 #else[Object]
             $type$[] array = ($type$[]) oarray;
 #end[Object]
-            // TODO defer to strong form until new Unsafe method is added
-            return UNSAFE.compareAndSwap$Type$(array,
-                    (((long) Objects.checkIndex(index, array.length, AIOOBE_SUPPLIER)) << handle.ashift) + handle.abase,
+            return UNSAFE.weakCompareAndSwap$Type$Volatile(array,
+                    (((long) Preconditions.checkIndex(index, array.length, AIOOBE_SUPPLIER)) << handle.ashift) + handle.abase,
                     {#if[Object]?handle.componentType.cast(expected):expected},
                     {#if[Object]?handle.componentType.cast(value):value});
         }
@@ -596,7 +595,7 @@
             $type$[] array = ($type$[]) oarray;
 #end[Object]
             return UNSAFE.weakCompareAndSwap$Type$Acquire(array,
-                    (((long) Objects.checkIndex(index, array.length, AIOOBE_SUPPLIER)) << handle.ashift) + handle.abase,
+                    (((long) Preconditions.checkIndex(index, array.length, AIOOBE_SUPPLIER)) << handle.ashift) + handle.abase,
                     {#if[Object]?handle.componentType.cast(expected):expected},
                     {#if[Object]?handle.componentType.cast(value):value});
         }
@@ -609,7 +608,7 @@
             $type$[] array = ($type$[]) oarray;
 #end[Object]
             return UNSAFE.weakCompareAndSwap$Type$Release(array,
-                    (((long) Objects.checkIndex(index, array.length, AIOOBE_SUPPLIER)) << handle.ashift) + handle.abase,
+                    (((long) Preconditions.checkIndex(index, array.length, AIOOBE_SUPPLIER)) << handle.ashift) + handle.abase,
                     {#if[Object]?handle.componentType.cast(expected):expected},
                     {#if[Object]?handle.componentType.cast(value):value});
         }
@@ -622,7 +621,7 @@
             $type$[] array = ($type$[]) oarray;
 #end[Object]
             return UNSAFE.getAndSet$Type$(array,
-                    (((long) Objects.checkIndex(index, array.length, AIOOBE_SUPPLIER)) << handle.ashift) + handle.abase,
+                    (((long) Preconditions.checkIndex(index, array.length, AIOOBE_SUPPLIER)) << handle.ashift) + handle.abase,
                     {#if[Object]?handle.componentType.cast(value):value});
         }
 #end[CAS]
@@ -636,7 +635,7 @@
             $type$[] array = ($type$[]) oarray;
 #end[Object]
             return UNSAFE.getAndAdd$Type$(array,
-                    (((long) Objects.checkIndex(index, array.length, AIOOBE_SUPPLIER)) << handle.ashift) + handle.abase,
+                    (((long) Preconditions.checkIndex(index, array.length, AIOOBE_SUPPLIER)) << handle.ashift) + handle.abase,
                     value);
         }
 
@@ -648,7 +647,7 @@
             $type$[] array = ($type$[]) oarray;
 #end[Object]
             return UNSAFE.getAndAdd$Type$(array,
-                    (((long) Objects.checkIndex(index, array.length, AIOOBE_SUPPLIER)) << handle.ashift) + handle.abase,
+                    (((long) Preconditions.checkIndex(index, array.length, AIOOBE_SUPPLIER)) << handle.ashift) + handle.abase,
                     value) + value;
         }
 #end[AtomicAdd]
--- a/jdk/src/java.base/share/classes/java/lang/invoke/X-VarHandleByteArrayView.java.template	Thu May 19 17:48:02 2016 +0000
+++ b/jdk/src/java.base/share/classes/java/lang/invoke/X-VarHandleByteArrayView.java.template	Thu May 19 19:46:20 2016 +0000
@@ -25,6 +25,7 @@
 package java.lang.invoke;
 
 import jdk.internal.misc.Unsafe;
+import jdk.internal.util.Preconditions;
 import jdk.internal.vm.annotation.ForceInline;
 
 import java.nio.ByteBuffer;
@@ -81,7 +82,7 @@
 
         @ForceInline
         static int index(byte[] ba, int index) {
-            return Objects.checkIndex(index, ba.length - ALIGN, null);
+            return Preconditions.checkIndex(index, ba.length - ALIGN, null);
         }
 
         @ForceInline
@@ -233,8 +234,7 @@
         @ForceInline
         static boolean weakCompareAndSetVolatile(ArrayHandle handle, Object oba, int index, $type$ expected, $type$ value) {
             byte[] ba = (byte[]) oba;
-            // TODO defer to strong form until new Unsafe method is added
-            return UNSAFE.compareAndSwap$RawType$(
+            return UNSAFE.weakCompareAndSwap$RawType$Volatile(
                     ba,
                     address(ba, index(ba, index)),
                     convEndian(handle.be, expected), convEndian(handle.be, value));
@@ -271,22 +271,33 @@
 #if[AtomicAdd]
 
         @ForceInline
-        static $type$ getAndAdd(ArrayHandle handle, Object oba, int index, $type$ value) {
+        static $type$ getAndAdd(ArrayHandle handle, Object oba, int index, $type$ delta) {
             byte[] ba = (byte[]) oba;
-            return convEndian(handle.be,
-                              UNSAFE.getAndAdd$RawType$(
-                                      ba,
-                                      address(ba, index(ba, index)),
-                                      convEndian(handle.be, value)));
+            if (handle.be == BE) {
+                return UNSAFE.getAndAdd$RawType$(
+                        ba,
+                        address(ba, index(ba, index)),
+                        delta);
+            } else {
+                return getAndAddConvEndianWithCAS(ba, index, delta);
+            }
         }
 
         @ForceInline
-        static $type$ addAndGet(ArrayHandle handle, Object oba, int index, $type$ value) {
-            byte[] ba = (byte[]) oba;
-            return convEndian(handle.be, UNSAFE.getAndAdd$RawType$(
-                    ba,
-                    address(ba, index(ba, index)),
-                    convEndian(handle.be, value))) + value;
+        static $type$ getAndAddConvEndianWithCAS(byte[] ba, int index, $type$ delta) {
+            $type$ nativeExpectedValue, expectedValue;
+            long offset = address(ba, index(ba, index));
+            do {
+                nativeExpectedValue = UNSAFE.get$RawType$Volatile(ba, offset);
+                expectedValue = $RawBoxType$.reverseBytes(nativeExpectedValue);
+            } while (!UNSAFE.weakCompareAndSwap$RawType$Volatile(ba, offset,
+                    nativeExpectedValue, $RawBoxType$.reverseBytes(expectedValue + delta)));
+            return expectedValue;
+        }
+
+        @ForceInline
+        static $type$ addAndGet(ArrayHandle handle, Object oba, int index, $type$ delta) {
+            return getAndAdd(handle, oba, index, delta) + delta;
         }
 #end[AtomicAdd]
 
@@ -307,14 +318,14 @@
 
         @ForceInline
         static int index(ByteBuffer bb, int index) {
-            return Objects.checkIndex(index, UNSAFE.getInt(bb, BUFFER_LIMIT) - ALIGN, null);
+            return Preconditions.checkIndex(index, UNSAFE.getInt(bb, BUFFER_LIMIT) - ALIGN, null);
         }
 
         @ForceInline
         static int indexRO(ByteBuffer bb, int index) {
             if (UNSAFE.getBoolean(bb, BYTE_BUFFER_IS_READ_ONLY))
                 throw new ReadOnlyBufferException();
-            return Objects.checkIndex(index, UNSAFE.getInt(bb, BUFFER_LIMIT) - ALIGN, null);
+            return Preconditions.checkIndex(index, UNSAFE.getInt(bb, BUFFER_LIMIT) - ALIGN, null);
         }
 
         @ForceInline
@@ -466,8 +477,7 @@
         @ForceInline
         static boolean weakCompareAndSetVolatile(ByteBufferHandle handle, Object obb, int index, $type$ expected, $type$ value) {
             ByteBuffer bb = (ByteBuffer) obb;
-            // TODO defer to strong form until new Unsafe method is added
-            return UNSAFE.compareAndSwap$RawType$(
+            return UNSAFE.weakCompareAndSwap$RawType$Volatile(
                     UNSAFE.getObject(bb, BYTE_BUFFER_HB),
                     address(bb, indexRO(bb, index)),
                     convEndian(handle.be, expected), convEndian(handle.be, value));
@@ -504,23 +514,34 @@
 #if[AtomicAdd]
 
         @ForceInline
-        static $type$ getAndAdd(ByteBufferHandle handle, Object obb, int index, $type$ value) {
+        static $type$ getAndAdd(ByteBufferHandle handle, Object obb, int index, $type$ delta) {
             ByteBuffer bb = (ByteBuffer) obb;
-            return convEndian(handle.be,
-                              UNSAFE.getAndAdd$RawType$(
-                                      UNSAFE.getObject(bb, BYTE_BUFFER_HB),
-                                      address(bb, indexRO(bb, index)),
-                                      convEndian(handle.be, value)));
+            if (handle.be == BE) {
+                return UNSAFE.getAndAdd$RawType$(
+                        UNSAFE.getObject(bb, BYTE_BUFFER_HB),
+                        address(bb, indexRO(bb, index)),
+                        delta);
+            } else {
+                return getAndAddConvEndianWithCAS(bb, index, delta);
+            }
         }
 
         @ForceInline
-        static $type$ addAndGet(ByteBufferHandle handle, Object obb, int index, $type$ value) {
-            ByteBuffer bb = (ByteBuffer) obb;
-            return convEndian(handle.be,
-                              UNSAFE.getAndAdd$RawType$(
-                                      UNSAFE.getObject(bb, BYTE_BUFFER_HB),
-                                      address(bb, indexRO(bb, index)),
-                                      convEndian(handle.be, value))) + value;
+        static $type$ getAndAddConvEndianWithCAS(ByteBuffer bb, int index, $type$ delta) {
+            $type$ nativeExpectedValue, expectedValue;
+            Object base = UNSAFE.getObject(bb, BYTE_BUFFER_HB);
+            long offset = address(bb, indexRO(bb, index));
+            do {
+                nativeExpectedValue = UNSAFE.get$RawType$Volatile(base, offset);
+                expectedValue = $RawBoxType$.reverseBytes(nativeExpectedValue);
+            } while (!UNSAFE.weakCompareAndSwap$RawType$Volatile(base, offset,
+                    nativeExpectedValue, $RawBoxType$.reverseBytes(expectedValue + delta)));
+            return expectedValue;
+        }
+
+        @ForceInline
+        static $type$ addAndGet(ByteBufferHandle handle, Object obb, int index, $type$ delta) {
+            return getAndAdd(handle, obb, index, delta) + delta;
         }
 #end[AtomicAdd]
 
--- a/jdk/src/java.base/share/classes/java/lang/module/ModuleInfo.java	Thu May 19 17:48:02 2016 +0000
+++ b/jdk/src/java.base/share/classes/java/lang/module/ModuleInfo.java	Thu May 19 19:46:20 2016 +0000
@@ -154,7 +154,7 @@
         int minor_version = in.readUnsignedShort();
         int major_version = in.readUnsignedShort();
         if (major_version < 53) {
-            // throw invalidModuleDescriptor"Must be >= 53.0");
+            throw invalidModuleDescriptor("Must be >= 53.0");
         }
 
         ConstantPool cpool = new ConstantPool(in);
--- a/jdk/src/java.base/share/classes/java/lang/module/SystemModuleFinder.java	Thu May 19 17:48:02 2016 +0000
+++ b/jdk/src/java.base/share/classes/java/lang/module/SystemModuleFinder.java	Thu May 19 19:46:20 2016 +0000
@@ -45,6 +45,7 @@
 import jdk.internal.jimage.ImageReader;
 import jdk.internal.jimage.ImageReaderFactory;
 import jdk.internal.module.ModuleHashes;
+import jdk.internal.module.ModuleHashes.HashSupplier;
 import jdk.internal.module.SystemModules;
 import jdk.internal.module.ModulePatcher;
 import jdk.internal.perf.PerfCounter;
@@ -84,57 +85,23 @@
         long t0 = System.nanoTime();
         imageReader = ImageReaderFactory.getImageReader();
 
-        String[] moduleNames = SystemModules.MODULE_NAMES;
-        ModuleDescriptor[] descriptors = null;
+        String[] names = moduleNames();
+        ModuleDescriptor[] descriptors = descriptors(names);
 
-        boolean fastLoad = System.getProperty("jdk.installed.modules.disable") == null;
-        if (fastLoad) {
-            // fast loading of ModuleDescriptor of installed modules
-            descriptors = SystemModules.modules();
-        }
-
-        int n = moduleNames.length;
+        int n = names.length;
         moduleCount.add(n);
 
         Set<ModuleReference> mods = new HashSet<>(n);
         Map<String, ModuleReference> map = new HashMap<>(n);
 
         for (int i = 0; i < n; i++) {
-            String mn = moduleNames[i];
-            ModuleDescriptor md;
-            String hash;
-            if (fastLoad) {
-                md = descriptors[i];
-                hash = SystemModules.MODULES_TO_HASH[i];
-            } else {
-                // fallback to read module-info.class
-                // if fast loading of ModuleDescriptors is disabled
-                ImageLocation location = imageReader.findLocation(mn, "module-info.class");
-                md = ModuleDescriptor.read(imageReader.getResourceBuffer(location));
-                hash = null;
-            }
-            if (!md.name().equals(mn))
-                throw new InternalError();
+            ModuleDescriptor md = descriptors[i];
 
             // create the ModuleReference
-
-            URI uri = URI.create("jrt:/" + mn);
-
-            Supplier<ModuleReader> readerSupplier = new Supplier<>() {
-                @Override
-                public ModuleReader get() {
-                    return new ImageModuleReader(mn, uri);
-                }
-            };
-
-            ModuleReference mref =
-                new ModuleReference(md, uri, readerSupplier, hashSupplier(hash));
-
-            // may need a reference to a patched module if -Xpatch specified
-            mref = ModulePatcher.interposeIfNeeded(mref);
+            ModuleReference mref = toModuleReference(md, hashSupplier(i, names[i]));
 
             mods.add(mref);
-            map.put(mn, mref);
+            map.put(names[i], mref);
 
             // counters
             packageCount.add(md.packages().size());
@@ -147,16 +114,114 @@
         initTime.addElapsedTimeFrom(t0);
     }
 
-    private static ModuleHashes.HashSupplier hashSupplier(String hash) {
-        if (hash == null)
-            return null;
+    /*
+     * Returns an array of ModuleDescriptor of the given module names.
+     *
+     * This obtains ModuleDescriptors from SystemModules class that is generated
+     * from the jlink system-modules plugin.  ModuleDescriptors have already
+     * been validated at link time.
+     *
+     * If java.base is patched, or fastpath is disabled for troubleshooting
+     * purpose, it will fall back to find system modules via jrt file system.
+     */
+    private static ModuleDescriptor[] descriptors(String[] names) {
+        // fastpath is enabled by default.
+        // It can be disabled for troubleshooting purpose.
+        boolean disabled =
+            System.getProperty("jdk.system.module.finder.disabledFastPath") != null;
+
+        // fast loading of ModuleDescriptor of system modules
+        if (isFastPathSupported() && !disabled)
+            return SystemModules.modules();
+
+        // if fast loading of ModuleDescriptors is disabled
+        // fallback to read module-info.class
+        ModuleDescriptor[] descriptors = new ModuleDescriptor[names.length];
+        for (int i = 0; i < names.length; i++) {
+            String mn = names[i];
+            ImageLocation loc = imageReader.findLocation(mn, "module-info.class");
+            descriptors[i] = ModuleDescriptor.read(imageReader.getResourceBuffer(loc));
 
-        return new ModuleHashes.HashSupplier() {
+            // add the recorded hashes of tied modules
+            Hashes.add(descriptors[i]);
+        }
+        return descriptors;
+    }
+
+    private static boolean isFastPathSupported() {
+       return SystemModules.MODULE_NAMES.length > 0;
+    }
+
+    private static String[] moduleNames() {
+        if (isFastPathSupported())
+            // module names recorded at link time
+            return SystemModules.MODULE_NAMES;
+
+        // this happens when java.base is patched with java.base
+        // from an exploded image
+        return imageReader.getModuleNames();
+    }
+
+    private static ModuleReference toModuleReference(ModuleDescriptor md,
+                                                     HashSupplier hash)
+    {
+        String mn = md.name();
+        URI uri = URI.create("jrt:/" + mn);
+
+        Supplier<ModuleReader> readerSupplier = new Supplier<>() {
             @Override
-            public String generate(String algorithm) {
-                return hash;
+            public ModuleReader get() {
+                return new ImageModuleReader(mn, uri);
             }
         };
+
+        ModuleReference mref =
+            new ModuleReference(md, uri, readerSupplier, hash);
+
+        // may need a reference to a patched module if -Xpatch specified
+        mref = ModulePatcher.interposeIfNeeded(mref);
+
+        return mref;
+    }
+
+    private static HashSupplier hashSupplier(int index, String name) {
+        if (isFastPathSupported()) {
+            return new HashSupplier() {
+                @Override
+                public String generate(String algorithm) {
+                    return SystemModules.MODULES_TO_HASH[index];
+                }
+            };
+        } else {
+            return Hashes.hashFor(name);
+        }
+    }
+
+    /*
+     * This helper class is only used when SystemModules is patched.
+     * It will get the recorded hashes from module-info.class.
+     */
+    private static class Hashes {
+        static Map<String, String> hashes = new HashMap<>();
+
+        static void add(ModuleDescriptor descriptor) {
+            Optional<ModuleHashes> ohashes = descriptor.hashes();
+            if (ohashes.isPresent()) {
+                hashes.putAll(ohashes.get().hashes());
+            }
+        }
+
+        static HashSupplier hashFor(String name) {
+            if (!hashes.containsKey(name))
+                return null;
+
+            return new HashSupplier() {
+                @Override
+                public String generate(String algorithm) {
+                    return hashes.get(name);
+                }
+            };
+        }
     }
 
     SystemModuleFinder() { }
--- a/jdk/src/java.base/share/classes/java/nio/Buffer.java	Thu May 19 17:48:02 2016 +0000
+++ b/jdk/src/java.base/share/classes/java/nio/Buffer.java	Thu May 19 19:46:20 2016 +0000
@@ -111,7 +111,7 @@
  * to zero.
  *
  *
- * <h2> Clearing, flipping, and rewinding </h2>
+ * <h2> Additional operations </h2>
  *
  * <p> In addition to methods for accessing the position, limit, and capacity
  * values and for marking and resetting, this class also defines the following
@@ -131,6 +131,12 @@
  *   it already contains: It leaves the limit unchanged and sets the position
  *   to zero.  </p></li>
  *
+ *   <li><p> {@link #slice} creates a subsequence of a buffer: It leaves the
+ *   limit and the position unchanged. </p></li>
+ *
+ *   <li><p> {@link #duplicate} creates a shallow copy of a buffer: It leaves
+ *   the limit and the position unchanged. </p></li>
+ *
  * </ul>
  *
  *
@@ -567,6 +573,46 @@
      */
     public abstract boolean isDirect();
 
+    /**
+     * Creates a new buffer whose content is a shared subsequence of
+     * this buffer's content.
+     *
+     * <p> The content of the new buffer will start at this buffer's current
+     * position.  Changes to this buffer's content will be visible in the new
+     * buffer, and vice versa; the two buffers' position, limit, and mark
+     * values will be independent.
+     *
+     * <p> The new buffer's position will be zero, its capacity and its limit
+     * will be the number of elements remaining in this buffer, its mark will be
+     * undefined. The new buffer will be direct if, and only if, this buffer is
+     * direct, and it will be read-only if, and only if, this buffer is
+     * read-only.  </p>
+     *
+     * @return  The new buffer
+     *
+     * @since 9
+     */
+    public abstract Buffer slice();
+
+    /**
+     * Creates a new buffer that shares this buffer's content.
+     *
+     * <p> The content of the new buffer will be that of this buffer.  Changes
+     * to this buffer's content will be visible in the new buffer, and vice
+     * versa; the two buffers' position, limit, and mark values will be
+     * independent.
+     *
+     * <p> The new buffer's capacity, limit, position and mark values will be
+     * identical to those of this buffer. The new buffer will be direct if, and
+     * only if, this buffer is direct, and it will be read-only if, and only if,
+     * this buffer is read-only.  </p>
+     *
+     * @return  The new buffer
+     *
+     * @since 9
+     */
+    public abstract Buffer duplicate();
+
 
     // -- Package-private methods for bounds checking, etc. --
 
--- a/jdk/src/java.base/share/classes/java/nio/X-Buffer.java.template	Thu May 19 17:48:02 2016 +0000
+++ b/jdk/src/java.base/share/classes/java/nio/X-Buffer.java.template	Thu May 19 19:46:20 2016 +0000
@@ -70,8 +70,7 @@
  *
 #end[byte]
  *
- *   <li><p> Methods for {@link #compact compacting}, {@link
- *   #duplicate duplicating}, and {@link #slice slicing}
+ *   <li><p> A method for {@link #compact compacting}
  *   $a$ $type$ buffer.  </p></li>
  *
  * </ul>
@@ -535,6 +534,7 @@
      * @see #alignedSlice(int)
 #end[byte]
      */
+    @Override
     public abstract $Type$Buffer slice();
 
     /**
@@ -557,6 +557,7 @@
      *
      * @return  The new $type$ buffer
      */
+    @Override
     public abstract $Type$Buffer duplicate();
 
     /**
--- a/jdk/src/java.base/share/classes/java/util/Objects.java	Thu May 19 17:48:02 2016 +0000
+++ b/jdk/src/java.base/share/classes/java/util/Objects.java	Thu May 19 19:46:20 2016 +0000
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2009, 2015, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2009, 2016, 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
@@ -25,10 +25,9 @@
 
 package java.util;
 
-import jdk.internal.HotSpotIntrinsicCandidate;
+import jdk.internal.util.Preconditions;
+import jdk.internal.vm.annotation.ForceInline;
 
-import java.util.function.BiFunction;
-import java.util.function.Function;
 import java.util.function.Supplier;
 
 /**
@@ -349,172 +348,6 @@
     }
 
     /**
-     * Maps out-of-bounds values to a runtime exception.
-     *
-     * @param checkKind the kind of bounds check, whose name may correspond
-     *        to the name of one of the range check methods, checkIndex,
-     *        checkFromToIndex, checkFromIndexSize
-     * @param args the out-of-bounds arguments that failed the range check.
-     *        If the checkKind corresponds a the name of a range check method
-     *        then the bounds arguments are those that can be passed in order
-     *        to the method.
-     * @param oobef the exception formatter that when applied with a checkKind
-     *        and a list out-of-bounds arguments returns a runtime exception.
-     *        If {@code null} then, it is as if an exception formatter was
-     *        supplied that returns {@link IndexOutOfBoundsException} for any
-     *        given arguments.
-     * @return the runtime exception
-     */
-    private static RuntimeException outOfBounds(
-            BiFunction<String, List<Integer>, ? extends RuntimeException> oobef,
-            String checkKind,
-            Integer... args) {
-        List<Integer> largs = List.of(args);
-        RuntimeException e = oobef == null
-                             ? null : oobef.apply(checkKind, largs);
-        return e == null
-               ? new IndexOutOfBoundsException(outOfBoundsMessage(checkKind, largs)) : e;
-    }
-
-    // Specific out-of-bounds exception producing methods that avoid
-    // the varargs-based code in the critical methods there by reducing their
-    // the byte code size, and therefore less likely to peturb inlining
-
-    private static RuntimeException outOfBoundsCheckIndex(
-            BiFunction<String, List<Integer>, ? extends RuntimeException> oobe,
-            int index, int length) {
-        return outOfBounds(oobe, "checkIndex", index, length);
-    }
-
-    private static RuntimeException outOfBoundsCheckFromToIndex(
-            BiFunction<String, List<Integer>, ? extends RuntimeException> oobe,
-            int fromIndex, int toIndex, int length) {
-        return outOfBounds(oobe, "checkFromToIndex", fromIndex, toIndex, length);
-    }
-
-    private static RuntimeException outOfBoundsCheckFromIndexSize(
-            BiFunction<String, List<Integer>, ? extends RuntimeException> oobe,
-            int fromIndex, int size, int length) {
-        return outOfBounds(oobe, "checkFromIndexSize", fromIndex, size, length);
-    }
-
-    /**
-     * Returns an out-of-bounds exception formatter from an given exception
-     * factory.  The exception formatter is a function that formats an
-     * out-of-bounds message from its arguments and applies that message to the
-     * given exception factory to produce and relay an exception.
-     *
-     * <p>The exception formatter accepts two arguments: a {@code String}
-     * describing the out-of-bounds range check that failed, referred to as the
-     * <em>check kind</em>; and a {@code List<Integer>} containing the
-     * out-of-bound integer values that failed the check.  The list of
-     * out-of-bound values is not modified.
-     *
-     * <p>Three check kinds are supported {@code checkIndex},
-     * {@code checkFromToIndex} and {@code checkFromIndexSize} corresponding
-     * respectively to the specified application of an exception formatter as an
-     * argument to the out-of-bounds range check methods
-     * {@link #checkIndex(int, int, BiFunction) checkIndex},
-     * {@link #checkFromToIndex(int, int, int, BiFunction) checkFromToIndex}, and
-     * {@link #checkFromIndexSize(int, int, int, BiFunction) checkFromIndexSize}.
-     * Thus a supported check kind corresponds to a method name and the
-     * out-of-bound integer values correspond to method argument values, in
-     * order, preceding the exception formatter argument (similar in many
-     * respects to the form of arguments required for a reflective invocation of
-     * such a range check method).
-     *
-     * <p>Formatter arguments conforming to such supported check kinds will
-     * produce specific exception messages describing failed out-of-bounds
-     * checks.  Otherwise, more generic exception messages will be produced in
-     * any of the following cases: the check kind is supported but fewer
-     * or more out-of-bounds values are supplied, the check kind is not
-     * supported, the check kind is {@code null}, or the list of out-of-bound
-     * values is {@code null}.
-     *
-     * @apiNote
-     * This method produces an out-of-bounds exception formatter that can be
-     * passed as an argument to any of the supported out-of-bounds range check
-     * methods declared by {@code Objects}.  For example, a formatter producing
-     * an {@code ArrayIndexOutOfBoundsException} may be produced and stored on a
-     * {@code static final} field as follows:
-     * <pre>{@code
-     * static final
-     * BiFunction<String, List<Integer>, ArrayIndexOutOfBoundsException> AIOOBEF =
-     *     outOfBoundsExceptionFormatter(ArrayIndexOutOfBoundsException::new);
-     * }</pre>
-     * The formatter instance {@code AIOOBEF} may be passed as an argument to an
-     * out-of-bounds range check method, such as checking if an {@code index}
-     * is within the bounds of a {@code limit}:
-     * <pre>{@code
-     * checkIndex(index, limit, AIOOBEF);
-     * }</pre>
-     * If the bounds check fails then the range check method will throw an
-     * {@code ArrayIndexOutOfBoundsException} with an appropriate exception
-     * message that is a produced from {@code AIOOBEF} as follows:
-     * <pre>{@code
-     * AIOOBEF.apply("checkIndex", List.of(index, limit));
-     * }</pre>
-     *
-     * @param f the exception factory, that produces an exception from a message
-     *        where the message is produced and formatted by the returned
-     *        exception formatter.  If this factory is stateless and side-effect
-     *        free then so is the returned formatter.
-     *        Exceptions thrown by the factory are relayed to the caller
-     *        of the returned formatter.
-     * @param <X> the type of runtime exception to be returned by the given
-     *        exception factory and relayed by the exception formatter
-     * @return the out-of-bounds exception formatter
-     */
-    public static <X extends RuntimeException>
-    BiFunction<String, List<Integer>, X> outOfBoundsExceptionFormatter(Function<String, X> f) {
-        // Use anonymous class to avoid bootstrap issues if this method is
-        // used early in startup
-        return new BiFunction<String, List<Integer>, X>() {
-            @Override
-            public X apply(String checkKind, List<Integer> args) {
-                return f.apply(outOfBoundsMessage(checkKind, args));
-            }
-        };
-    }
-
-    private static String outOfBoundsMessage(String checkKind, List<Integer> args) {
-        if (checkKind == null && args == null) {
-            return String.format("Range check failed");
-        } else if (checkKind == null) {
-            return String.format("Range check failed: %s", args);
-        } else if (args == null) {
-            return String.format("Range check failed: %s", checkKind);
-        }
-
-        int argSize = 0;
-        switch (checkKind) {
-            case "checkIndex":
-                argSize = 2;
-                break;
-            case "checkFromToIndex":
-            case "checkFromIndexSize":
-                argSize = 3;
-                break;
-            default:
-        }
-
-        // Switch to default if fewer or more arguments than required are supplied
-        switch ((args.size() != argSize) ? "" : checkKind) {
-            case "checkIndex":
-                return String.format("Index %d out-of-bounds for length %d",
-                                     args.get(0), args.get(1));
-            case "checkFromToIndex":
-                return String.format("Range [%d, %d) out-of-bounds for length %d",
-                                     args.get(0), args.get(1), args.get(2));
-            case "checkFromIndexSize":
-                return String.format("Range [%d, %<d + %d) out-of-bounds for length %d",
-                                     args.get(0), args.get(1), args.get(2));
-            default:
-                return String.format("Range check failed: %s %s", checkKind, args);
-        }
-    }
-
-    /**
      * Checks if the {@code index} is within the bounds of the range from
      * {@code 0} (inclusive) to {@code length} (exclusive).
      *
@@ -526,72 +359,16 @@
      *  <li>{@code length < 0}, which is implied from the former inequalities</li>
      * </ul>
      *
-     * <p>This method behaves as if {@link #checkIndex(int, int, BiFunction)}
-     * was called with same out-of-bounds arguments and an exception formatter
-     * argument produced from an invocation of
-     * {@code outOfBoundsExceptionFormatter(IndexOutOfBounds::new)} (though it may
-     * be more efficient).
-     *
      * @param index the index
      * @param length the upper-bound (exclusive) of the range
      * @return {@code index} if it is within bounds of the range
      * @throws IndexOutOfBoundsException if the {@code index} is out-of-bounds
      * @since 9
      */
+    @ForceInline
     public static
     int checkIndex(int index, int length) {
-        return checkIndex(index, length, null);
-    }
-
-    /**
-     * Checks if the {@code index} is within the bounds of the range from
-     * {@code 0} (inclusive) to {@code length} (exclusive).
-     *
-     * <p>The {@code index} is defined to be out-of-bounds if any of the
-     * following inequalities is true:
-     * <ul>
-     *  <li>{@code index < 0}</li>
-     *  <li>{@code index >= length}</li>
-     *  <li>{@code length < 0}, which is implied from the former inequalities</li>
-     * </ul>
-     *
-     * <p>If the {@code index} is out-of-bounds, then a runtime exception is
-     * thrown that is the result of applying the following arguments to the
-     * exception formatter: the name of this method, {@code checkIndex};
-     * and an unmodifiable list integers whose values are, in order, the
-     * out-of-bounds arguments {@code index} and {@code length}.
-     *
-     * @param <X> the type of runtime exception to throw if the arguments are
-     *        out-of-bounds
-     * @param index the index
-     * @param length the upper-bound (exclusive) of the range
-     * @param oobef the exception formatter that when applied with this
-     *        method name and out-of-bounds arguments returns a runtime
-     *        exception.  If {@code null} or returns {@code null} then, it is as
-     *        if an exception formatter produced from an invocation of
-     *        {@code outOfBoundsExceptionFormatter(IndexOutOfBounds::new)} is used
-     *        instead (though it may be more efficient).
-     *        Exceptions thrown by the formatter are relayed to the caller.
-     * @return {@code index} if it is within bounds of the range
-     * @throws X if the {@code index} is out-of-bounds and the exception
-     *         formatter is non-{@code null}
-     * @throws IndexOutOfBoundsException if the {@code index} is out-of-bounds
-     *         and the exception formatter is {@code null}
-     * @since 9
-     *
-     * @implNote
-     * This method is made intrinsic in optimizing compilers to guide them to
-     * perform unsigned comparisons of the index and length when it is known the
-     * length is a non-negative value (such as that of an array length or from
-     * the upper bound of a loop)
-    */
-    @HotSpotIntrinsicCandidate
-    public static <X extends RuntimeException>
-    int checkIndex(int index, int length,
-                   BiFunction<String, List<Integer>, X> oobef) {
-        if (index < 0 || index >= length)
-            throw outOfBoundsCheckIndex(oobef, index, length);
-        return index;
+        return Preconditions.checkIndex(index, length, null);
     }
 
     /**
@@ -608,12 +385,6 @@
      *  <li>{@code length < 0}, which is implied from the former inequalities</li>
      * </ul>
      *
-     * <p>This method behaves as if {@link #checkFromToIndex(int, int, int, BiFunction)}
-     * was called with same out-of-bounds arguments and an exception formatter
-     * argument produced from an invocation of
-     * {@code outOfBoundsExceptionFormatter(IndexOutOfBounds::new)} (though it may
-     * be more efficient).
-     *
      * @param fromIndex the lower-bound (inclusive) of the sub-range
      * @param toIndex the upper-bound (exclusive) of the sub-range
      * @param length the upper-bound (exclusive) the range
@@ -623,54 +394,7 @@
      */
     public static
     int checkFromToIndex(int fromIndex, int toIndex, int length) {
-        return checkFromToIndex(fromIndex, toIndex, length, null);
-    }
-
-    /**
-     * Checks if the sub-range from {@code fromIndex} (inclusive) to
-     * {@code toIndex} (exclusive) is within the bounds of range from {@code 0}
-     * (inclusive) to {@code length} (exclusive).
-     *
-     * <p>The sub-range is defined to be out-of-bounds if any of the following
-     * inequalities is true:
-     * <ul>
-     *  <li>{@code fromIndex < 0}</li>
-     *  <li>{@code fromIndex > toIndex}</li>
-     *  <li>{@code toIndex > length}</li>
-     *  <li>{@code length < 0}, which is implied from the former inequalities</li>
-     * </ul>
-     *
-     * <p>If the sub-range  is out-of-bounds, then a runtime exception is
-     * thrown that is the result of applying the following arguments to the
-     * exception formatter: the name of this method, {@code checkFromToIndex};
-     * and an unmodifiable list integers whose values are, in order, the
-     * out-of-bounds arguments {@code fromIndex}, {@code toIndex}, and {@code length}.
-     *
-     * @param <X> the type of runtime exception to throw if the arguments are
-     *        out-of-bounds
-     * @param fromIndex the lower-bound (inclusive) of the sub-range
-     * @param toIndex the upper-bound (exclusive) of the sub-range
-     * @param length the upper-bound (exclusive) the range
-     * @param oobef the exception formatter that when applied with this
-     *        method name and out-of-bounds arguments returns a runtime
-     *        exception.  If {@code null} or returns {@code null} then, it is as
-     *        if an exception formatter produced from an invocation of
-     *        {@code outOfBoundsExceptionFormatter(IndexOutOfBounds::new)} is used
-     *        instead (though it may be more efficient).
-     *        Exceptions thrown by the formatter are relayed to the caller.
-     * @return {@code fromIndex} if the sub-range within bounds of the range
-     * @throws X if the sub-range is out-of-bounds and the exception factory
-     *         function is non-{@code null}
-     * @throws IndexOutOfBoundsException if the sub-range is out-of-bounds and
-     *         the exception factory function is {@code null}
-     * @since 9
-     */
-    public static <X extends RuntimeException>
-    int checkFromToIndex(int fromIndex, int toIndex, int length,
-                         BiFunction<String, List<Integer>, X> oobef) {
-        if (fromIndex < 0 || fromIndex > toIndex || toIndex > length)
-            throw outOfBoundsCheckFromToIndex(oobef, fromIndex, toIndex, length);
-        return fromIndex;
+        return Preconditions.checkFromToIndex(fromIndex, toIndex, length, null);
     }
 
     /**
@@ -687,12 +411,6 @@
      *  <li>{@code length < 0}, which is implied from the former inequalities</li>
      * </ul>
      *
-     * <p>This method behaves as if {@link #checkFromIndexSize(int, int, int, BiFunction)}
-     * was called with same out-of-bounds arguments and an exception formatter
-     * argument produced from an invocation of
-     * {@code outOfBoundsExceptionFormatter(IndexOutOfBounds::new)} (though it may
-     * be more efficient).
-     *
      * @param fromIndex the lower-bound (inclusive) of the sub-interval
      * @param size the size of the sub-range
      * @param length the upper-bound (exclusive) of the range
@@ -702,54 +420,7 @@
      */
     public static
     int checkFromIndexSize(int fromIndex, int size, int length) {
-        return checkFromIndexSize(fromIndex, size, length, null);
+        return Preconditions.checkFromIndexSize(fromIndex, size, length, null);
     }
 
-    /**
-     * Checks if the sub-range from {@code fromIndex} (inclusive) to
-     * {@code fromIndex + size} (exclusive) is within the bounds of range from
-     * {@code 0} (inclusive) to {@code length} (exclusive).
-     *
-     * <p>The sub-range is defined to be out-of-bounds if any of the following
-     * inequalities is true:
-     * <ul>
-     *  <li>{@code fromIndex < 0}</li>
-     *  <li>{@code size < 0}</li>
-     *  <li>{@code fromIndex + size > length}, taking into account integer overflow</li>
-     *  <li>{@code length < 0}, which is implied from the former inequalities</li>
-     * </ul>
-     *
-     * <p>If the sub-range  is out-of-bounds, then a runtime exception is
-     * thrown that is the result of applying the following arguments to the
-     * exception formatter: the name of this method, {@code checkFromIndexSize};
-     * and an unmodifiable list integers whose values are, in order, the
-     * out-of-bounds arguments {@code fromIndex}, {@code size}, and
-     * {@code length}.
-     *
-     * @param <X> the type of runtime exception to throw if the arguments are
-     *        out-of-bounds
-     * @param fromIndex the lower-bound (inclusive) of the sub-interval
-     * @param size the size of the sub-range
-     * @param length the upper-bound (exclusive) of the range
-     * @param oobef the exception formatter that when applied with this
-     *        method name and out-of-bounds arguments returns a runtime
-     *        exception.  If {@code null} or returns {@code null} then, it is as
-     *        if an exception formatter produced from an invocation of
-     *        {@code outOfBoundsExceptionFormatter(IndexOutOfBounds::new)} is used
-     *        instead (though it may be more efficient).
-     *        Exceptions thrown by the formatter are relayed to the caller.
-     * @return {@code fromIndex} if the sub-range within bounds of the range
-     * @throws X if the sub-range is out-of-bounds and the exception factory
-     *         function is non-{@code null}
-     * @throws IndexOutOfBoundsException if the sub-range is out-of-bounds and
-     *         the exception factory function is {@code null}
-     * @since 9
-     */
-    public static <X extends RuntimeException>
-    int checkFromIndexSize(int fromIndex, int size, int length,
-                           BiFunction<String, List<Integer>, X> oobef) {
-        if ((length | fromIndex | size) < 0 || size > length - fromIndex)
-            throw outOfBoundsCheckFromIndexSize(oobef, fromIndex, size, length);
-        return fromIndex;
-    }
 }
--- a/jdk/src/java.base/share/classes/java/util/zip/ZipFile.java	Thu May 19 17:48:02 2016 +0000
+++ b/jdk/src/java.base/share/classes/java/util/zip/ZipFile.java	Thu May 19 19:46:20 2016 +0000
@@ -462,9 +462,13 @@
 
     private class ZipEntryIterator implements Enumeration<ZipEntry>, Iterator<ZipEntry> {
         private int i = 0;
+        private final int entryCount;
 
         public ZipEntryIterator() {
-            ensureOpen();
+            synchronized (ZipFile.this) {
+                ensureOpen();
+                this.entryCount = zsrc.total;
+            }
         }
 
         public boolean hasMoreElements() {
@@ -472,10 +476,7 @@
         }
 
         public boolean hasNext() {
-            synchronized (ZipFile.this) {
-                ensureOpen();
-                return i < zsrc.total;
-            }
+            return i < entryCount;
         }
 
         public ZipEntry nextElement() {
@@ -485,7 +486,7 @@
         public ZipEntry next() {
             synchronized (ZipFile.this) {
                 ensureOpen();
-                if (i >= zsrc.total) {
+                if (!hasNext()) {
                     throw new NoSuchElementException();
                 }
                 // each "entry" has 3 ints in table entries
@@ -526,34 +527,34 @@
     /* Checks ensureOpen() before invoke this method */
     private ZipEntry getZipEntry(String name, int pos) {
         byte[] cen = zsrc.cen;
-        ZipEntry e = new ZipEntry();
         int nlen = CENNAM(cen, pos);
         int elen = CENEXT(cen, pos);
         int clen = CENCOM(cen, pos);
-        e.flag = CENFLG(cen, pos);  // get the flag first
-        if (name != null) {
-            e.name = name;
-        } else {
-            if (!zc.isUTF8() && (e.flag & EFS) != 0) {
-                e.name = zc.toStringUTF8(cen, pos + CENHDR, nlen);
+        int flag = CENFLG(cen, pos);
+        if (name == null) {
+            if (!zc.isUTF8() && (flag & EFS) != 0) {
+                name = zc.toStringUTF8(cen, pos + CENHDR, nlen);
             } else {
-                e.name = zc.toString(cen, pos + CENHDR, nlen);
+                name = zc.toString(cen, pos + CENHDR, nlen);
             }
         }
+        ZipEntry e = new ZipEntry(name);
+        e.flag = flag;
         e.xdostime = CENTIM(cen, pos);
         e.crc = CENCRC(cen, pos);
         e.size = CENLEN(cen, pos);
         e.csize = CENSIZ(cen, pos);
         e.method = CENHOW(cen, pos);
         if (elen != 0) {
-            e.setExtra0(Arrays.copyOfRange(cen, pos + CENHDR + nlen,
-                                           pos + CENHDR + nlen + elen), true);
+            int start = pos + CENHDR + nlen;
+            e.setExtra0(Arrays.copyOfRange(cen, start, start + elen), true);
         }
         if (clen != 0) {
-            if (!zc.isUTF8() && (e.flag & EFS) != 0) {
-                e.comment = zc.toStringUTF8(cen, pos + CENHDR + nlen + elen, clen);
+            int start = pos + CENHDR + nlen + elen;
+            if (!zc.isUTF8() && (flag & EFS) != 0) {
+                e.comment = zc.toStringUTF8(cen, start, clen);
             } else {
-                e.comment = zc.toString(cen, pos + CENHDR + nlen + elen, clen);
+                e.comment = zc.toString(cen, start, clen);
             }
         }
         return e;
@@ -817,7 +818,7 @@
         );
     }
 
-    /*
+    /**
      * Returns an array of strings representing the names of all entries
      * that begin with "META-INF/" (case ignored). This method is used
      * in JarFile, via SharedSecrets, as an optimization when looking up
@@ -827,14 +828,14 @@
     private String[] getMetaInfEntryNames() {
         synchronized (this) {
             ensureOpen();
-            if (zsrc.metanames.size() == 0) {
+            if (zsrc.metanames == null) {
                 return null;
             }
-            String[] names = new String[zsrc.metanames.size()];
+            String[] names = new String[zsrc.metanames.length];
             byte[] cen = zsrc.cen;
             for (int i = 0; i < names.length; i++) {
-                int pos = zsrc.metanames.get(i);
-                names[i] = new String(cen, pos + CENHDR,  CENNAM(cen, pos),
+                int pos = zsrc.metanames[i];
+                names[i] = new String(cen, pos + CENHDR, CENNAM(cen, pos),
                                       StandardCharsets.UTF_8);
             }
             return names;
@@ -850,7 +851,7 @@
         private long locpos;                 // position of first LOC header (usually 0)
         private byte[] comment;              // zip file comment
                                              // list of meta entries in META-INF dir
-        private ArrayList<Integer> metanames = new ArrayList<>();
+        private int[] metanames;
         private final boolean startsWithLoc; // true, if zip file starts with LOCSIG (usually true)
 
         // A Hashmap for all entries.
@@ -1159,7 +1160,7 @@
             int next = -1;
 
             // list for all meta entries
-            metanames = new ArrayList<>();
+            ArrayList<Integer> metanamesList = null;
 
             // Iterate through the entries in the central directory
             int i = 0;
@@ -1194,13 +1195,21 @@
                 idx = addEntry(idx, hash, next, pos);
                 // Adds name to metanames.
                 if (isMetaName(cen, pos + CENHDR, nlen)) {
-                    metanames.add(pos);
+                    if (metanamesList == null)
+                        metanamesList = new ArrayList<>(4);
+                    metanamesList.add(pos);
                 }
                 // skip ext and comment
                 pos += (CENHDR + nlen + elen + clen);
                 i++;
             }
             total = i;
+            if (metanamesList != null) {
+                metanames = new int[metanamesList.size()];
+                for (int j = 0, len = metanames.length; j < len; j++) {
+                    metanames[j] = metanamesList.get(j);
+                }
+            }
             if (pos + ENDHDR != cen.length) {
                 zerror("invalid CEN header (bad header size)");
             }
@@ -1265,30 +1274,23 @@
             }
         }
 
-        private static byte[] metainf = new byte[] {
-            'M', 'E', 'T', 'A', '-', 'I' , 'N', 'F', '/',
-        };
-
-        /*
-         * Returns true if the specified entry's name begins with the string
-         * "META-INF/" irrespective of case.
+        /**
+         * Returns true if the bytes represent a non-directory name
+         * beginning with "META-INF/", disregarding ASCII case.
          */
-        private static boolean isMetaName(byte[] name,  int off, int len) {
-            if (len < 9 || (name[off] != 'M' && name[off] != 'm')) {  //  sizeof("META-INF/") - 1
-                return false;
-            }
-            off++;
-            for (int i = 1; i < metainf.length; i++) {
-                byte c = name[off++];
-                // Avoid toupper; it's locale-dependent
-                if (c >= 'a' && c <= 'z') {
-                    c += 'A' - 'a';
-                }
-                if (metainf[i] != c) {
-                    return false;
-                }
-            }
-            return true;
+        private static boolean isMetaName(byte[] name, int off, int len) {
+            // Use the "oldest ASCII trick in the book"
+            return len > 9                     // "META-INF/".length()
+                && name[off + len - 1] != '/'  // non-directory
+                && (name[off++] | 0x20) == 'm'
+                && (name[off++] | 0x20) == 'e'
+                && (name[off++] | 0x20) == 't'
+                && (name[off++] | 0x20) == 'a'
+                && (name[off++]       ) == '-'
+                && (name[off++] | 0x20) == 'i'
+                && (name[off++] | 0x20) == 'n'
+                && (name[off++] | 0x20) == 'f'
+                && (name[off]         ) == '/';
         }
 
         /*
--- a/jdk/src/java.base/share/classes/jdk/internal/jimage/ImageReader.java	Thu May 19 17:48:02 2016 +0000
+++ b/jdk/src/java.base/share/classes/jdk/internal/jimage/ImageReader.java	Thu May 19 19:46:20 2016 +0000
@@ -149,6 +149,17 @@
         return reader.getEntryNames();
     }
 
+    public String[] getModuleNames() {
+        Objects.requireNonNull(reader, "image file closed");
+        int off = "/modules/".length();
+        return reader.findNode("/modules")
+                     .getChildren()
+                     .stream()
+                     .map(Node::getNameString)
+                     .map(s -> s.substring(off, s.length()))
+                     .toArray(String[]::new);
+    }
+
     public long[] getAttributes(int offset) {
         Objects.requireNonNull(reader, "image file closed");
         return reader.getAttributes(offset);
--- a/jdk/src/java.base/share/classes/jdk/internal/loader/ClassLoaders.java	Thu May 19 17:48:02 2016 +0000
+++ b/jdk/src/java.base/share/classes/jdk/internal/loader/ClassLoaders.java	Thu May 19 19:46:20 2016 +0000
@@ -68,13 +68,14 @@
         if (s != null && s.length() > 0)
             bcp = toURLClassPath(s);
 
-        // we have a class path if -cp is specified or -m is not specified
+        // we have a class path if -cp is specified or -m is not specified.
+        // If neither is specified then default to -cp <working directory>.
         URLClassPath ucp = null;
         String mainMid = System.getProperty("jdk.module.main");
         String cp = System.getProperty("java.class.path");
-        if (mainMid == null && (cp == null || cp.length() == 0))
-            cp = ".";
-        if (cp != null && cp.length() > 0)
+        if (mainMid == null && cp == null)
+            cp = "";
+        if (cp != null)
             ucp = toURLClassPath(cp);
 
 
@@ -197,7 +198,7 @@
          * @see java.lang.instrument.Instrumentation#appendToSystemClassLoaderSearch
          */
         void appendToClassPathForInstrumentation(String path) {
-            appendToUCP(path, ucp);
+            addClassPathToUCP(path, ucp);
         }
 
         /**
@@ -224,7 +225,7 @@
      */
     private static URLClassPath toURLClassPath(String cp) {
         URLClassPath ucp = new URLClassPath(new URL[0]);
-        appendToUCP(cp, ucp);
+        addClassPathToUCP(cp, ucp);
         return ucp;
     }
 
@@ -232,20 +233,28 @@
      * Converts the elements in the given class path to file URLs and adds
      * them to the given URLClassPath.
      */
-    private static void appendToUCP(String cp, URLClassPath ucp) {
-        String[] elements = cp.split(File.pathSeparator);
-        if (elements.length == 0) {
-            // contains path separator(s) only, default to current directory
-            // to be compatible with long standing behavior
-            elements = new String[] { "" };
+    private static void addClassPathToUCP(String cp, URLClassPath ucp) {
+        int off = 0;
+        int next;
+        while ((next = cp.indexOf(File.pathSeparator, off)) != -1) {
+            addURLToUCP(cp.substring(off, next), ucp);
+            off = next + 1;
         }
-        for (String s: elements) {
-            try {
-                URL url = Paths.get(s).toRealPath().toUri().toURL();
-                ucp.addURL(url);
-            } catch (InvalidPathException | IOException ignore) {
-                // malformed path string or class path element does not exist
-            }
+
+        // remaining
+        addURLToUCP(cp.substring(off), ucp);
+    }
+
+    /**
+     * Attempts to convert to the given string to a file URL and adds it
+     * to the given URLClassPath.
+     */
+    private static void addURLToUCP(String s, URLClassPath ucp) {
+        try {
+            URL url = Paths.get(s).toRealPath().toUri().toURL();
+            ucp.addURL(url);
+        } catch (InvalidPathException | IOException ignore) {
+            // malformed path string or class path element does not exist
         }
     }
 
--- a/jdk/src/java.base/share/classes/jdk/internal/misc/Unsafe.java	Thu May 19 17:48:02 2016 +0000
+++ b/jdk/src/java.base/share/classes/jdk/internal/misc/Unsafe.java	Thu May 19 19:46:20 2016 +0000
@@ -33,6 +33,7 @@
 import jdk.internal.misc.VM;
 
 import jdk.internal.HotSpotIntrinsicCandidate;
+import jdk.internal.vm.annotation.ForceInline;
 
 
 /**
@@ -209,46 +210,103 @@
     /** @see #getInt(Object, long) */
     @HotSpotIntrinsicCandidate
     public native boolean getBoolean(Object o, long offset);
+
     /** @see #putInt(Object, long, int) */
     @HotSpotIntrinsicCandidate
     public native void    putBoolean(Object o, long offset, boolean x);
+
     /** @see #getInt(Object, long) */
     @HotSpotIntrinsicCandidate
     public native byte    getByte(Object o, long offset);
+
     /** @see #putInt(Object, long, int) */
     @HotSpotIntrinsicCandidate
     public native void    putByte(Object o, long offset, byte x);
+
     /** @see #getInt(Object, long) */
     @HotSpotIntrinsicCandidate
     public native short   getShort(Object o, long offset);
+
     /** @see #putInt(Object, long, int) */
     @HotSpotIntrinsicCandidate
     public native void    putShort(Object o, long offset, short x);
+
     /** @see #getInt(Object, long) */
     @HotSpotIntrinsicCandidate
     public native char    getChar(Object o, long offset);
+
     /** @see #putInt(Object, long, int) */
     @HotSpotIntrinsicCandidate
     public native void    putChar(Object o, long offset, char x);
+
     /** @see #getInt(Object, long) */
     @HotSpotIntrinsicCandidate
     public native long    getLong(Object o, long offset);
+
     /** @see #putInt(Object, long, int) */
     @HotSpotIntrinsicCandidate
     public native void    putLong(Object o, long offset, long x);
+
     /** @see #getInt(Object, long) */
     @HotSpotIntrinsicCandidate
     public native float   getFloat(Object o, long offset);
+
     /** @see #putInt(Object, long, int) */
     @HotSpotIntrinsicCandidate
     public native void    putFloat(Object o, long offset, float x);
+
     /** @see #getInt(Object, long) */
     @HotSpotIntrinsicCandidate
     public native double  getDouble(Object o, long offset);
+
     /** @see #putInt(Object, long, int) */
     @HotSpotIntrinsicCandidate
     public native void    putDouble(Object o, long offset, double x);
 
+    /**
+     * Fetches a native pointer from a given memory address.  If the address is
+     * zero, or does not point into a block obtained from {@link
+     * #allocateMemory}, the results are undefined.
+     *
+     * <p>If the native pointer is less than 64 bits wide, it is extended as
+     * an unsigned number to a Java long.  The pointer may be indexed by any
+     * given byte offset, simply by adding that offset (as a simple integer) to
+     * the long representing the pointer.  The number of bytes actually read
+     * from the target address may be determined by consulting {@link
+     * #addressSize}.
+     *
+     * @see #allocateMemory
+     * @see #getInt(Object, long)
+     */
+    @ForceInline
+    public long getAddress(Object o, long offset) {
+        if (ADDRESS_SIZE == 4) {
+            return Integer.toUnsignedLong(getInt(o, offset));
+        } else {
+            return getLong(o, offset);
+        }
+    }
+
+    /**
+     * Stores a native pointer into a given memory address.  If the address is
+     * zero, or does not point into a block obtained from {@link
+     * #allocateMemory}, the results are undefined.
+     *
+     * <p>The number of bytes actually written at the target address may be
+     * determined by consulting {@link #addressSize}.
+     *
+     * @see #allocateMemory
+     * @see #putInt(Object, long, int)
+     */
+    @ForceInline
+    public void putAddress(Object o, long offset, long x) {
+        if (ADDRESS_SIZE == 4) {
+            putInt(o, offset, (int)x);
+        } else {
+            putLong(o, offset, x);
+        }
+    }
+
     // These read VM internal data.
 
     /**
@@ -287,8 +345,10 @@
      *
      * @see #allocateMemory
      */
-    @HotSpotIntrinsicCandidate
-    public native byte    getByte(long address);
+    @ForceInline
+    public byte getByte(long address) {
+        return getByte(null, address);
+    }
 
     /**
      * Stores a value into a given memory address.  If the address is zero, or
@@ -297,75 +357,94 @@
      *
      * @see #getByte(long)
      */
-    @HotSpotIntrinsicCandidate
-    public native void    putByte(long address, byte x);
+    @ForceInline
+    public void putByte(long address, byte x) {
+        putByte(null, address, x);
+    }
+
+    /** @see #getByte(long) */
+    @ForceInline
+    public short getShort(long address) {
+        return getShort(null, address);
+    }
+
+    /** @see #putByte(long, byte) */
+    @ForceInline
+    public void putShort(long address, short x) {
+        putShort(null, address, x);
+    }
+
+    /** @see #getByte(long) */
+    @ForceInline
+    public char getChar(long address) {
+        return getChar(null, address);
+    }
+
+    /** @see #putByte(long, byte) */
+    @ForceInline
+    public void putChar(long address, char x) {
+        putChar(null, address, x);
+    }
+
+    /** @see #getByte(long) */
+    @ForceInline
+    public int getInt(long address) {
+        return getInt(null, address);
+    }
+
+    /** @see #putByte(long, byte) */
+    @ForceInline
+    public void putInt(long address, int x) {
+        putInt(null, address, x);
+    }
 
     /** @see #getByte(long) */
-    @HotSpotIntrinsicCandidate
-    public native short   getShort(long address);
-    /** @see #putByte(long, byte) */
-    @HotSpotIntrinsicCandidate
-    public native void    putShort(long address, short x);
-    /** @see #getByte(long) */
-    @HotSpotIntrinsicCandidate
-    public native char    getChar(long address);
-    /** @see #putByte(long, byte) */
-    @HotSpotIntrinsicCandidate
-    public native void    putChar(long address, char x);
-    /** @see #getByte(long) */
-    @HotSpotIntrinsicCandidate
-    public native int     getInt(long address);
+    @ForceInline
+    public long getLong(long address) {
+        return getLong(null, address);
+    }
+
     /** @see #putByte(long, byte) */
-    @HotSpotIntrinsicCandidate
-    public native void    putInt(long address, int x);
-    /** @see #getByte(long) */
-    @HotSpotIntrinsicCandidate
-    public native long    getLong(long address);
-    /** @see #putByte(long, byte) */
-    @HotSpotIntrinsicCandidate
-    public native void    putLong(long address, long x);
+    @ForceInline
+    public void putLong(long address, long x) {
+        putLong(null, address, x);
+    }
+
     /** @see #getByte(long) */
-    @HotSpotIntrinsicCandidate
-    public native float   getFloat(long address);
-    /** @see #putByte(long, byte) */
-    @HotSpotIntrinsicCandidate
-    public native void    putFloat(long address, float x);
-    /** @see #getByte(long) */
-    @HotSpotIntrinsicCandidate
-    public native double  getDouble(long address);
+    @ForceInline
+    public float getFloat(long address) {
+        return getFloat(null, address);
+    }
+
     /** @see #putByte(long, byte) */
-    @HotSpotIntrinsicCandidate
-    public native void    putDouble(long address, double x);
+    @ForceInline
+    public void putFloat(long address, float x) {
+        putFloat(null, address, x);
+    }
+
+    /** @see #getByte(long) */
+    @ForceInline
+    public double getDouble(long address) {
+        return getDouble(null, address);
+    }
 
-    /**
-     * Fetches a native pointer from a given memory address.  If the address is
-     * zero, or does not point into a block obtained from {@link
-     * #allocateMemory}, the results are undefined.
-     *
-     * <p>If the native pointer is less than 64 bits wide, it is extended as
-     * an unsigned number to a Java long.  The pointer may be indexed by any
-     * given byte offset, simply by adding that offset (as a simple integer) to
-     * the long representing the pointer.  The number of bytes actually read
-     * from the target address may be determined by consulting {@link
-     * #addressSize}.
-     *
-     * @see #allocateMemory
-     */
-    @HotSpotIntrinsicCandidate
-    public native long getAddress(long address);
+    /** @see #putByte(long, byte) */
+    @ForceInline
+    public void putDouble(long address, double x) {
+        putDouble(null, address, x);
+    }
 
-    /**
-     * Stores a native pointer into a given memory address.  If the address is
-     * zero, or does not point into a block obtained from {@link
-     * #allocateMemory}, the results are undefined.
-     *
-     * <p>The number of bytes actually written at the target address may be
-     * determined by consulting {@link #addressSize}.
-     *
-     * @see #getAddress(long)
-     */
-    @HotSpotIntrinsicCandidate
-    public native void putAddress(long address, long x);
+    /** @see #getAddress(Object, long) */
+    @ForceInline
+    public long getAddress(long address) {
+        return getAddress(null, address);
+    }
+
+    /** @see #putAddress(Object, long, long) */
+    @ForceInline
+    public void putAddress(long address, long x) {
+        putAddress(null, address, x);
+    }
 
 
 
@@ -1271,6 +1350,13 @@
         return compareAndSwapObject(o, offset, expected, x);
     }
 
+    @HotSpotIntrinsicCandidate
+    public final boolean weakCompareAndSwapObjectVolatile(Object o, long offset,
+                                                                Object expected,
+                                                                Object x) {
+        return compareAndSwapObject(o, offset, expected, x);
+    }
+
     /**
      * Atomically updates Java variable to {@code x} if it is currently
      * holding {@code expected}.
@@ -1325,6 +1411,13 @@
         return compareAndSwapInt(o, offset, expected, x);
     }
 
+    @HotSpotIntrinsicCandidate
+    public final boolean weakCompareAndSwapIntVolatile(Object o, long offset,
+                                                             int expected,
+                                                             int x) {
+        return compareAndSwapInt(o, offset, expected, x);
+    }
+
     /**
      * Atomically updates Java variable to {@code x} if it is currently
      * holding {@code expected}.
@@ -1379,6 +1472,13 @@
         return compareAndSwapLong(o, offset, expected, x);
     }
 
+    @HotSpotIntrinsicCandidate
+    public final boolean weakCompareAndSwapLongVolatile(Object o, long offset,
+                                                              long expected,
+                                                              long x) {
+        return compareAndSwapLong(o, offset, expected, x);
+    }
+
     /**
      * Fetches a reference value from a given Java variable, with volatile
      * load semantics. Otherwise identical to {@link #getObject(Object, long)}
--- a/jdk/src/java.base/share/classes/jdk/internal/module/ModuleInfoWriter.java	Thu May 19 17:48:02 2016 +0000
+++ b/jdk/src/java.base/share/classes/jdk/internal/module/ModuleInfoWriter.java	Thu May 19 19:46:20 2016 +0000
@@ -54,7 +54,7 @@
         ClassWriter cw = new ClassWriter(0);
 
         String name = md.name().replace('.', '/') + "/module-info";
-        cw.visit(Opcodes.V1_8, ACC_MODULE, name, null, null, null);
+        cw.visit(Opcodes.V1_9, ACC_MODULE, name, null, null, null);
 
         cw.visitAttribute(new ModuleAttribute(md));
         cw.visitAttribute(new ConcealedPackagesAttribute(md.conceals()));
--- a/jdk/src/java.base/share/classes/jdk/internal/module/SystemModules.java	Thu May 19 17:48:02 2016 +0000
+++ b/jdk/src/java.base/share/classes/jdk/internal/module/SystemModules.java	Thu May 19 19:46:20 2016 +0000
@@ -46,12 +46,12 @@
      * and read module-info.class from the run-time image instead of
      * the fastpath.
      */
-    public static final String[] MODULE_NAMES = new String[1];
+    public static final String[] MODULE_NAMES = new String[0];
 
     /**
      * Hash of system modules.
      */
-    public static String[] MODULES_TO_HASH = new String[1];
+    public static String[] MODULES_TO_HASH = new String[0];
 
     /**
      * Number of packages in the boot layer from the installed modules.
@@ -67,7 +67,7 @@
      * When running an exploded image it returns an empty array.
      */
     public static ModuleDescriptor[] modules() {
-        return new ModuleDescriptor[0];
+        throw new InternalError("should not reach here");
     }
 
 }
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/jdk/src/java.base/share/classes/jdk/internal/util/Preconditions.java	Thu May 19 19:46:20 2016 +0000
@@ -0,0 +1,346 @@
+/*
+ * Copyright (c) 2016, 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.internal.util;
+
+import jdk.internal.HotSpotIntrinsicCandidate;
+
+import java.util.List;
+import java.util.function.BiFunction;
+import java.util.function.Function;
+
+/**
+ * Utility methods to check if state or arguments are correct.
+ *
+ */
+public class Preconditions {
+
+    /**
+     * Maps out-of-bounds values to a runtime exception.
+     *
+     * @param checkKind the kind of bounds check, whose name may correspond
+     *        to the name of one of the range check methods, checkIndex,
+     *        checkFromToIndex, checkFromIndexSize
+     * @param args the out-of-bounds arguments that failed the range check.
+     *        If the checkKind corresponds a the name of a range check method
+     *        then the bounds arguments are those that can be passed in order
+     *        to the method.
+     * @param oobef the exception formatter that when applied with a checkKind
+     *        and a list out-of-bounds arguments returns a runtime exception.
+     *        If {@code null} then, it is as if an exception formatter was
+     *        supplied that returns {@link IndexOutOfBoundsException} for any
+     *        given arguments.
+     * @return the runtime exception
+     */
+    private static RuntimeException outOfBounds(
+            BiFunction<String, List<Integer>, ? extends RuntimeException> oobef,
+            String checkKind,
+            Integer... args) {
+        List<Integer> largs = List.of(args);
+        RuntimeException e = oobef == null
+                             ? null : oobef.apply(checkKind, largs);
+        return e == null
+               ? new IndexOutOfBoundsException(outOfBoundsMessage(checkKind, largs)) : e;
+    }
+
+    private static RuntimeException outOfBoundsCheckIndex(
+            BiFunction<String, List<Integer>, ? extends RuntimeException> oobe,
+            int index, int length) {
+        return outOfBounds(oobe, "checkIndex", index, length);
+    }
+
+    private static RuntimeException outOfBoundsCheckFromToIndex(
+            BiFunction<String, List<Integer>, ? extends RuntimeException> oobe,
+            int fromIndex, int toIndex, int length) {
+        return outOfBounds(oobe, "checkFromToIndex", fromIndex, toIndex, length);
+    }
+
+    private static RuntimeException outOfBoundsCheckFromIndexSize(
+            BiFunction<String, List<Integer>, ? extends RuntimeException> oobe,
+            int fromIndex, int size, int length) {
+        return outOfBounds(oobe, "checkFromIndexSize", fromIndex, size, length);
+    }
+
+    /**
+     * Returns an out-of-bounds exception formatter from an given exception
+     * factory.  The exception formatter is a function that formats an
+     * out-of-bounds message from its arguments and applies that message to the
+     * given exception factory to produce and relay an exception.
+     *
+     * <p>The exception formatter accepts two arguments: a {@code String}
+     * describing the out-of-bounds range check that failed, referred to as the
+     * <em>check kind</em>; and a {@code List<Integer>} containing the
+     * out-of-bound integer values that failed the check.  The list of
+     * out-of-bound values is not modified.
+     *
+     * <p>Three check kinds are supported {@code checkIndex},
+     * {@code checkFromToIndex} and {@code checkFromIndexSize} corresponding
+     * respectively to the specified application of an exception formatter as an
+     * argument to the out-of-bounds range check methods
+     * {@link #checkIndex(int, int, BiFunction) checkIndex},
+     * {@link #checkFromToIndex(int, int, int, BiFunction) checkFromToIndex}, and
+     * {@link #checkFromIndexSize(int, int, int, BiFunction) checkFromIndexSize}.
+     * Thus a supported check kind corresponds to a method name and the
+     * out-of-bound integer values correspond to method argument values, in
+     * order, preceding the exception formatter argument (similar in many
+     * respects to the form of arguments required for a reflective invocation of
+     * such a range check method).
+     *
+     * <p>Formatter arguments conforming to such supported check kinds will
+     * produce specific exception messages describing failed out-of-bounds
+     * checks.  Otherwise, more generic exception messages will be produced in
+     * any of the following cases: the check kind is supported but fewer
+     * or more out-of-bounds values are supplied, the check kind is not
+     * supported, the check kind is {@code null}, or the list of out-of-bound
+     * values is {@code null}.
+     *
+     * @apiNote
+     * This method produces an out-of-bounds exception formatter that can be
+     * passed as an argument to any of the supported out-of-bounds range check
+     * methods declared by {@code Objects}.  For example, a formatter producing
+     * an {@code ArrayIndexOutOfBoundsException} may be produced and stored on a
+     * {@code static final} field as follows:
+     * <pre>{@code
+     * static final
+     * BiFunction<String, List<Integer>, ArrayIndexOutOfBoundsException> AIOOBEF =
+     *     outOfBoundsExceptionFormatter(ArrayIndexOutOfBoundsException::new);
+     * }</pre>
+     * The formatter instance {@code AIOOBEF} may be passed as an argument to an
+     * out-of-bounds range check method, such as checking if an {@code index}
+     * is within the bounds of a {@code limit}:
+     * <pre>{@code
+     * checkIndex(index, limit, AIOOBEF);
+     * }</pre>
+     * If the bounds check fails then the range check method will throw an
+     * {@code ArrayIndexOutOfBoundsException} with an appropriate exception
+     * message that is a produced from {@code AIOOBEF} as follows:
+     * <pre>{@code
+     * AIOOBEF.apply("checkIndex", List.of(index, limit));
+     * }</pre>
+     *
+     * @param f the exception factory, that produces an exception from a message
+     *        where the message is produced and formatted by the returned
+     *        exception formatter.  If this factory is stateless and side-effect
+     *        free then so is the returned formatter.
+     *        Exceptions thrown by the factory are relayed to the caller
+     *        of the returned formatter.
+     * @param <X> the type of runtime exception to be returned by the given
+     *        exception factory and relayed by the exception formatter
+     * @return the out-of-bounds exception formatter
+     */
+    public static <X extends RuntimeException>
+    BiFunction<String, List<Integer>, X> outOfBoundsExceptionFormatter(Function<String, X> f) {
+        // Use anonymous class to avoid bootstrap issues if this method is
+        // used early in startup
+        return new BiFunction<String, List<Integer>, X>() {
+            @Override
+            public X apply(String checkKind, List<Integer> args) {
+                return f.apply(outOfBoundsMessage(checkKind, args));
+            }
+        };
+    }
+
+    private static String outOfBoundsMessage(String checkKind, List<Integer> args) {
+        if (checkKind == null && args == null) {
+            return String.format("Range check failed");
+        } else if (checkKind == null) {
+            return String.format("Range check failed: %s", args);
+        } else if (args == null) {
+            return String.format("Range check failed: %s", checkKind);
+        }
+
+        int argSize = 0;
+        switch (checkKind) {
+            case "checkIndex":
+                argSize = 2;
+                break;
+            case "checkFromToIndex":
+            case "checkFromIndexSize":
+                argSize = 3;
+                break;
+            default:
+        }
+
+        // Switch to default if fewer or more arguments than required are supplied
+        switch ((args.size() != argSize) ? "" : checkKind) {
+            case "checkIndex":
+                return String.format("Index %d out-of-bounds for length %d",
+                                     args.get(0), args.get(1));
+            case "checkFromToIndex":
+                return String.format("Range [%d, %d) out-of-bounds for length %d",
+                                     args.get(0), args.get(1), args.get(2));
+            case "checkFromIndexSize":
+                return String.format("Range [%d, %<d + %d) out-of-bounds for length %d",
+                                     args.get(0), args.get(1), args.get(2));
+            default:
+                return String.format("Range check failed: %s %s", checkKind, args);
+        }
+    }
+
+    /**
+     * Checks if the {@code index} is within the bounds of the range from
+     * {@code 0} (inclusive) to {@code length} (exclusive).
+     *
+     * <p>The {@code index} is defined to be out-of-bounds if any of the
+     * following inequalities is true:
+     * <ul>
+     *  <li>{@code index < 0}</li>
+     *  <li>{@code index >= length}</li>
+     *  <li>{@code length < 0}, which is implied from the former inequalities</li>
+     * </ul>
+     *
+     * <p>If the {@code index} is out-of-bounds, then a runtime exception is
+     * thrown that is the result of applying the following arguments to the
+     * exception formatter: the name of this method, {@code checkIndex};
+     * and an unmodifiable list integers whose values are, in order, the
+     * out-of-bounds arguments {@code index} and {@code length}.
+     *
+     * @param <X> the type of runtime exception to throw if the arguments are
+     *        out-of-bounds
+     * @param index the index
+     * @param length the upper-bound (exclusive) of the range
+     * @param oobef the exception formatter that when applied with this
+     *        method name and out-of-bounds arguments returns a runtime
+     *        exception.  If {@code null} or returns {@code null} then, it is as
+     *        if an exception formatter produced from an invocation of
+     *        {@code outOfBoundsExceptionFormatter(IndexOutOfBounds::new)} is used
+     *        instead (though it may be more efficient).
+     *        Exceptions thrown by the formatter are relayed to the caller.
+     * @return {@code index} if it is within bounds of the range
+     * @throws X if the {@code index} is out-of-bounds and the exception
+     *         formatter is non-{@code null}
+     * @throws IndexOutOfBoundsException if the {@code index} is out-of-bounds
+     *         and the exception formatter is {@code null}
+     * @since 9
+     *
+     * @implNote
+     * This method is made intrinsic in optimizing compilers to guide them to
+     * perform unsigned comparisons of the index and length when it is known the
+     * length is a non-negative value (such as that of an array length or from
+     * the upper bound of a loop)
+    */
+    @HotSpotIntrinsicCandidate
+    public static <X extends RuntimeException>
+    int checkIndex(int index, int length,
+                   BiFunction<String, List<Integer>, X> oobef) {
+        if (index < 0 || index >= length)
+            throw outOfBoundsCheckIndex(oobef, index, length);
+        return index;
+    }
+
+    /**
+     * Checks if the sub-range from {@code fromIndex} (inclusive) to
+     * {@code toIndex} (exclusive) is within the bounds of range from {@code 0}
+     * (inclusive) to {@code length} (exclusive).
+     *
+     * <p>The sub-range is defined to be out-of-bounds if any of the following
+     * inequalities is true:
+     * <ul>
+     *  <li>{@code fromIndex < 0}</li>
+     *  <li>{@code fromIndex > toIndex}</li>
+     *  <li>{@code toIndex > length}</li>
+     *  <li>{@code length < 0}, which is implied from the former inequalities</li>
+     * </ul>
+     *
+     * <p>If the sub-range  is out-of-bounds, then a runtime exception is
+     * thrown that is the result of applying the following arguments to the
+     * exception formatter: the name of this method, {@code checkFromToIndex};
+     * and an unmodifiable list integers whose values are, in order, the
+     * out-of-bounds arguments {@code fromIndex}, {@code toIndex}, and {@code length}.
+     *
+     * @param <X> the type of runtime exception to throw if the arguments are
+     *        out-of-bounds
+     * @param fromIndex the lower-bound (inclusive) of the sub-range
+     * @param toIndex the upper-bound (exclusive) of the sub-range
+     * @param length the upper-bound (exclusive) the range
+     * @param oobef the exception formatter that when applied with this
+     *        method name and out-of-bounds arguments returns a runtime
+     *        exception.  If {@code null} or returns {@code null} then, it is as
+     *        if an exception formatter produced from an invocation of
+     *        {@code outOfBoundsExceptionFormatter(IndexOutOfBounds::new)} is used
+     *        instead (though it may be more efficient).
+     *        Exceptions thrown by the formatter are relayed to the caller.
+     * @return {@code fromIndex} if the sub-range within bounds of the range
+     * @throws X if the sub-range is out-of-bounds and the exception factory
+     *         function is non-{@code null}
+     * @throws IndexOutOfBoundsException if the sub-range is out-of-bounds and
+     *         the exception factory function is {@code null}
+     * @since 9
+     */
+    public static <X extends RuntimeException>
+    int checkFromToIndex(int fromIndex, int toIndex, int length,
+                         BiFunction<String, List<Integer>, X> oobef) {
+        if (fromIndex < 0 || fromIndex > toIndex || toIndex > length)
+            throw outOfBoundsCheckFromToIndex(oobef, fromIndex, toIndex, length);
+        return fromIndex;
+    }
+
+    /**
+     * Checks if the sub-range from {@code fromIndex} (inclusive) to
+     * {@code fromIndex + size} (exclusive) is within the bounds of range from
+     * {@code 0} (inclusive) to {@code length} (exclusive).
+     *
+     * <p>The sub-range is defined to be out-of-bounds if any of the following
+     * inequalities is true:
+     * <ul>
+     *  <li>{@code fromIndex < 0}</li>
+     *  <li>{@code size < 0}</li>
+     *  <li>{@code fromIndex + size > length}, taking into account integer overflow</li>
+     *  <li>{@code length < 0}, which is implied from the former inequalities</li>
+     * </ul>
+     *
+     * <p>If the sub-range  is out-of-bounds, then a runtime exception is
+     * thrown that is the result of applying the following arguments to the
+     * exception formatter: the name of this method, {@code checkFromIndexSize};
+     * and an unmodifiable list integers whose values are, in order, the
+     * out-of-bounds arguments {@code fromIndex}, {@code size}, and
+     * {@code length}.
+     *
+     * @param <X> the type of runtime exception to throw if the arguments are
+     *        out-of-bounds
+     * @param fromIndex the lower-bound (inclusive) of the sub-interval
+     * @param size the size of the sub-range
+     * @param length the upper-bound (exclusive) of the range
+     * @param oobef the exception formatter that when applied with this
+     *        method name and out-of-bounds arguments returns a runtime
+     *        exception.  If {@code null} or returns {@code null} then, it is as
+     *        if an exception formatter produced from an invocation of
+     *        {@code outOfBoundsExceptionFormatter(IndexOutOfBounds::new)} is used
+     *        instead (though it may be more efficient).
+     *        Exceptions thrown by the formatter are relayed to the caller.
+     * @return {@code fromIndex} if the sub-range within bounds of the range
+     * @throws X if the sub-range is out-of-bounds and the exception factory
+     *         function is non-{@code null}
+     * @throws IndexOutOfBoundsException if the sub-range is out-of-bounds and
+     *         the exception factory function is {@code null}
+     * @since 9
+     */
+    public static <X extends RuntimeException>
+    int checkFromIndexSize(int fromIndex, int size, int length,
+                           BiFunction<String, List<Integer>, X> oobef) {
+        if ((length | fromIndex | size) < 0 || size > length - fromIndex)
+            throw outOfBoundsCheckFromIndexSize(oobef, fromIndex, size, length);
+        return fromIndex;
+    }
+}
--- a/jdk/src/java.base/share/classes/sun/launcher/resources/launcher.properties	Thu May 19 17:48:02 2016 +0000
+++ b/jdk/src/java.base/share/classes/sun/launcher/resources/launcher.properties	Thu May 19 19:46:20 2016 +0000
@@ -100,7 +100,6 @@
 \    -Xdiag            show additional diagnostic messages\n\
 \    -Xdiag:resolver   show resolver diagnostic messages\n\
 \    -Xnoclassgc       disable class garbage collection\n\
-\    -Xincgc           enable incremental garbage collection\n\
 \    -Xloggc:<file>    log GC status to a file with time stamps\n\
 \    -Xbatch           disable background compilation\n\
 \    -Xms<size>        set initial Java heap size\n\
--- a/jdk/src/java.base/share/classes/sun/security/provider/PolicyFile.java	Thu May 19 17:48:02 2016 +0000
+++ b/jdk/src/java.base/share/classes/sun/security/provider/PolicyFile.java	Thu May 19 19:46:20 2016 +0000
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 1997, 2015, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 1997, 2016, 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
@@ -259,14 +259,10 @@
 
     private static final Debug debug = Debug.getInstance("policy");
 
-    private static final String NONE = "NONE";
-    private static final String P11KEYSTORE = "PKCS11";
-
     private static final String SELF = "${{self}}";
     private static final String X500PRINCIPAL =
                         "javax.security.auth.x500.X500Principal";
     private static final String POLICY = "java.security.policy";
-    private static final String SECURITY_MANAGER = "java.security.manager";
     private static final String POLICY_URL = "policy.url.";
     private static final String AUTH_POLICY = "java.security.auth.policy";
     private static final String AUTH_POLICY_URL = "auth.policy.url.";
@@ -288,6 +284,17 @@
     private static final Class<?>[] PARAMS2 = { String.class, String.class };
 
     /**
+     * When a policy file has a syntax error, the exception code may generate
+     * another permission check and this can cause the policy file to be parsed
+     * repeatedly, leading to a StackOverflowError or ClassCircularityError.
+     * To avoid this, this set is populated with policy files that have been
+     * previously parsed and have syntax errors, so that they can be
+     * subsequently ignored.
+     */
+    private static AtomicReference<Set<URL>> badPolicyURLs =
+        new AtomicReference<>(new HashSet<>());
+
+    /**
      * Initializes the Policy object and reads the default policy
      * configuration file(s) into the Policy object.
      */
@@ -580,6 +587,16 @@
      * @param policyFile the policy Reader object.
      */
     private boolean init(URL policy, PolicyInfo newInfo) {
+
+        // skip parsing policy file if it has been previously parsed and
+        // has syntax errors
+        if (badPolicyURLs.get().contains(policy)) {
+            if (debug != null) {
+                debug.println("skipping bad policy file: " + policy);
+            }
+            return false;
+        }
+
         boolean success = false;
         PolicyParser pp = new PolicyParser(expandProperties);
         InputStreamReader isr = null;
@@ -622,13 +639,18 @@
                 addGrantEntry(ge, keyStore, newInfo);
             }
         } catch (PolicyParser.ParsingException pe) {
+            // record bad policy file to avoid later reparsing it
+            badPolicyURLs.updateAndGet(k -> {
+                k.add(policy);
+                return k;
+            });
             MessageFormat form = new MessageFormat(ResourcesMgr.getString
                 (POLICY + ".error.parsing.policy.message"));
             Object[] source = {policy, pe.getLocalizedMessage()};
             System.err.println(form.format(source));
-            if (debug != null)
+            if (debug != null) {
                 pe.printStackTrace();
-
+            }
         } catch (Exception e) {
             if (debug != null) {
                 debug.println("error parsing "+policy);
--- a/jdk/src/java.base/share/classes/sun/security/provider/PolicyParser.java	Thu May 19 17:48:02 2016 +0000
+++ b/jdk/src/java.base/share/classes/sun/security/provider/PolicyParser.java	Thu May 19 19:46:20 2016 +0000
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 1997, 2014, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 1997, 2016, 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
@@ -213,7 +213,9 @@
                             new MessageFormat(ResourcesMgr.getString(
                                 "duplicate.keystore.domain.name"));
                         Object[] source = {domainName};
-                        throw new ParsingException(form.format(source));
+                        String msg = "duplicate keystore domain name: " +
+                                     domainName;
+                        throw new ParsingException(msg, form, source);
                     }
                 }
             } else {
@@ -743,7 +745,8 @@
                     ResourcesMgr.getString
                             ("expected.expect.read.end.of.file."));
             Object[] source = {expect};
-            throw new ParsingException(form.format(source));
+            String msg = "expected [" + expect + "], read [end of file]";
+            throw new ParsingException(msg, form, source);
         case StreamTokenizer.TT_WORD:
             if (expect.equalsIgnoreCase(st.sval)) {
                 lookahead = st.nextToken();
@@ -1244,7 +1247,8 @@
                 MessageFormat form = new MessageFormat(ResourcesMgr.getString(
                     "duplicate.keystore.name"));
                 Object[] source = {keystoreName};
-                throw new ParsingException(form.format(source));
+                String msg = "duplicate keystore name: " + keystoreName;
+                throw new ParsingException(msg, form, source);
             }
         }
 
@@ -1316,6 +1320,8 @@
         private static final long serialVersionUID = -4330692689482574072L;
 
         private String i18nMessage;
+        private MessageFormat form;
+        private Object[] source;
 
         /**
          * Constructs a ParsingException with the specified
@@ -1330,26 +1336,34 @@
             i18nMessage = msg;
         }
 
+        public ParsingException(String msg, MessageFormat form,
+                                Object[] source) {
+            super(msg);
+            this.form = form;
+            this.source = source;
+        }
+
         public ParsingException(int line, String msg) {
             super("line " + line + ": " + msg);
-            MessageFormat form = new MessageFormat
-                (ResourcesMgr.getString("line.number.msg"));
-            Object[] source = {line, msg};
-            i18nMessage = form.format(source);
+            // don't call form.format unless getLocalizedMessage is called
+            // to avoid unnecessary permission checks
+            form = new MessageFormat(ResourcesMgr.getString("line.number.msg"));
+            source = new Object[] {line, msg};
         }
 
         public ParsingException(int line, String expect, String actual) {
             super("line " + line + ": expected [" + expect +
                 "], found [" + actual + "]");
-            MessageFormat form = new MessageFormat(ResourcesMgr.getString
+            // don't call form.format unless getLocalizedMessage is called
+            // to avoid unnecessary permission checks
+            form = new MessageFormat(ResourcesMgr.getString
                 ("line.number.expected.expect.found.actual."));
-            Object[] source = {line, expect, actual};
-            i18nMessage = form.format(source);
+            source = new Object[] {line, expect, actual};
         }
 
         @Override
         public String getLocalizedMessage() {
-            return i18nMessage;
+            return i18nMessage != null ? i18nMessage : form.format(source);
         }
     }
 
--- a/jdk/src/java.base/share/classes/sun/security/util/SignatureFileVerifier.java	Thu May 19 17:48:02 2016 +0000
+++ b/jdk/src/java.base/share/classes/sun/security/util/SignatureFileVerifier.java	Thu May 19 19:46:20 2016 +0000
@@ -145,11 +145,10 @@
      */
     public static boolean isBlockOrSF(String s) {
         // we currently only support DSA and RSA PKCS7 blocks
-        if (s.endsWith(".SF") || s.endsWith(".DSA") ||
-                s.endsWith(".RSA") || s.endsWith(".EC")) {
-            return true;
-        }
-        return false;
+        return s.endsWith(".SF")
+            || s.endsWith(".DSA")
+            || s.endsWith(".RSA")
+            || s.endsWith(".EC");
     }
 
     /**
--- a/jdk/src/java.base/share/conf/security/java.policy	Thu May 19 17:48:02 2016 +0000
+++ b/jdk/src/java.base/share/conf/security/java.policy	Thu May 19 19:46:20 2016 +0000
@@ -80,6 +80,10 @@
         permission java.security.AllPermission;
 };
 
+grant codeBase "jrt:/java.scripting" {
+        permission java.security.AllPermission;
+};
+
 grant codeBase "jrt:/jdk.scripting.nashorn" {
         permission java.security.AllPermission;
 };
--- a/jdk/src/java.base/share/conf/security/java.security	Thu May 19 17:48:02 2016 +0000
+++ b/jdk/src/java.base/share/conf/security/java.security	Thu May 19 19:46:20 2016 +0000
@@ -713,6 +713,12 @@
 # See SSL/TLS specifications and "Java Cryptography Architecture Standard
 # Algorithm Name Documentation" for information about the algorithm names.
 #
+# Note: If a legacy algorithm is also restricted through the
+# jdk.tls.disabledAlgorithms property or the
+# java.security.AlgorithmConstraints API (See
+# javax.net.ssl.SSLParameters.setAlgorithmConstraints()),
+# then the algorithm is completely disabled and will not be negotiated.
+#
 # Note: This property is currently used by Oracle's JSSE implementation.
 # It is not guaranteed to be examined and used by other implementations.
 # There is no guarantee the property will continue to exist or be of the
--- a/jdk/src/java.base/share/native/include/jvmti.h	Thu May 19 17:48:02 2016 +0000
+++ b/jdk/src/java.base/share/native/include/jvmti.h	Thu May 19 19:46:20 2016 +0000
@@ -704,7 +704,8 @@
     unsigned int can_generate_resource_exhaustion_heap_events : 1;
     unsigned int can_generate_resource_exhaustion_threads_events : 1;
     unsigned int can_generate_early_vmstart : 1;
-    unsigned int : 6;
+    unsigned int can_generate_early_class_hook_events : 1;
+    unsigned int : 5;
     unsigned int : 16;
     unsigned int : 16;
     unsigned int : 16;
--- a/jdk/src/java.desktop/macosx/classes/com/apple/laf/AquaFileChooserUI.java	Thu May 19 17:48:02 2016 +0000
+++ b/jdk/src/java.desktop/macosx/classes/com/apple/laf/AquaFileChooserUI.java	Thu May 19 19:46:20 2016 +0000
@@ -112,7 +112,7 @@
     private AncestorListener ancestorListener = null;
     private DropTarget dragAndDropTarget = null;
 
-    private final AcceptAllFileFilter acceptAllFileFilter = new AcceptAllFileFilter();
+    private static final AcceptAllFileFilter acceptAllFileFilter = new AcceptAllFileFilter();
 
     private AquaFileSystemModel model;
 
@@ -997,7 +997,7 @@
     // *****************************************
     // ***** default AcceptAll file filter *****
     // *****************************************
-    protected class AcceptAllFileFilter extends FileFilter {
+    private static class AcceptAllFileFilter extends FileFilter {
         public AcceptAllFileFilter() {
         }
 
@@ -1305,6 +1305,8 @@
     protected class FilterComboBoxModel extends AbstractListModel<FileFilter> implements ComboBoxModel<FileFilter>,
             PropertyChangeListener {
         protected FileFilter[] filters;
+        Object oldFileFilter = getFileChooser().getFileFilter();
+
         protected FilterComboBoxModel() {
             super();
             filters = getFileChooser().getChoosableFileFilters();
@@ -1321,12 +1323,17 @@
         }
 
         public void setSelectedItem(Object filter) {
-            if (filter != null && !containsFileFilter(filter)) {
+            if (filter != null && !isSelectedFileFilterInModel(filter)) {
+                oldFileFilter = filter;
                 getFileChooser().setFileFilter((FileFilter) filter);
                 fireContentsChanged(this, -1, -1);
             }
         }
 
+        private boolean isSelectedFileFilterInModel(Object filter) {
+            return Objects.equals(filter, oldFileFilter);
+        }
+
         public Object getSelectedItem() {
             // Ensure that the current filter is in the list.
             // NOTE: we shouldnt' have to do this, since JFileChooser adds
--- a/jdk/src/java.desktop/macosx/native/libawt_lwawt/awt/AWTEvent.m	Thu May 19 17:48:02 2016 +0000
+++ b/jdk/src/java.desktop/macosx/native/libawt_lwawt/awt/AWTEvent.m	Thu May 19 19:46:20 2016 +0000
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2011, 2015, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2011, 2016, 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
@@ -282,12 +282,20 @@
         //kCGSFlagsMaskAppleLeftAlternateKey,
         //kCGSFlagsMaskAppleRightAlternateKey,
         58,
-        61,
+        0,
         java_awt_event_InputEvent_ALT_DOWN_MASK,
         java_awt_event_InputEvent_ALT_MASK,
         java_awt_event_KeyEvent_VK_ALT
     },
     {
+        NSAlternateKeyMask,
+        0,
+        61,
+        java_awt_event_InputEvent_ALT_DOWN_MASK | java_awt_event_InputEvent_ALT_GRAPH_DOWN_MASK,
+        java_awt_event_InputEvent_ALT_MASK | java_awt_event_InputEvent_ALT_GRAPH_MASK,
+        java_awt_event_KeyEvent_VK_ALT
+    },
+    {
         NSCommandKeyMask,
         //kCGSFlagsMaskAppleLeftCommandKey,
         //kCGSFlagsMaskAppleRightCommandKey,
@@ -310,6 +318,8 @@
     {0, 0, 0, 0, 0, 0}
 };
 
+static BOOL leftAltKeyPressed;
+
 /*
  * Almost all unicode characters just go from NS to Java with no translation.
  *  For the few exceptions, we handle it here with this small table.
@@ -523,13 +533,17 @@
             //    *javaKeyLocation = java_awt_event_KeyEvent_KEY_LOCATION_RIGHT;
             //}
             if (eventKeyCode == cur->leftKeyCode) {
+                leftAltKeyPressed = YES;
                 *javaKeyLocation = java_awt_event_KeyEvent_KEY_LOCATION_LEFT;
             } else if (eventKeyCode == cur->rightKeyCode) {
                 *javaKeyLocation = java_awt_event_KeyEvent_KEY_LOCATION_RIGHT;
+            } else if (cur->nsMask == NSAlternateKeyMask) {
+                leftAltKeyPressed = NO;
+                continue;
             }
             *javaKeyType = (cur->nsMask & nsFlags) ?
-                java_awt_event_KeyEvent_KEY_PRESSED :
-                java_awt_event_KeyEvent_KEY_RELEASED;
+            java_awt_event_KeyEvent_KEY_PRESSED :
+            java_awt_event_KeyEvent_KEY_RELEASED;
             break;
         }
     }
@@ -545,7 +559,11 @@
 
     for (cur = nsKeyToJavaModifierTable; cur->nsMask != 0; ++cur) {
         if ((cur->nsMask & nsFlags) != 0) {
-            javaModifiers |= isExtMods? cur->javaExtMask : cur->javaMask;
+            javaModifiers |= isExtMods ? cur->javaExtMask : cur->javaMask;
+            if (cur->nsMask == NSAlternateKeyMask && leftAltKeyPressed == NO) {
+                continue;
+            }
+            break;
         }
     }
 
--- a/jdk/src/java.desktop/macosx/native/libawt_lwawt/awt/CMenuItem.m	Thu May 19 17:48:02 2016 +0000
+++ b/jdk/src/java.desktop/macosx/native/libawt_lwawt/awt/CMenuItem.m	Thu May 19 19:46:20 2016 +0000
@@ -25,7 +25,6 @@
 
 #import <JavaNativeFoundation/JavaNativeFoundation.h>
 #include <Carbon/Carbon.h>
-
 #import "CMenuItem.h"
 #import "CMenu.h"
 #import "AWTEvent.h"
@@ -64,42 +63,6 @@
 - (BOOL) worksWhenModal {
     return YES;
 }
-// This is a method written using Carbon framework methods to remove
-// All modifiers including "Shift" modifier.
-// Example 1: Shortcut set is "Command Shift m" returns "m"
-// Example 2: Shortcut set is "Command m" returns "m"
-// Example 3: Shortcut set is "Alt Shift ," returns ","
-
-CFStringRef createStringForKey(CGKeyCode keyCode)
-{
-    TISInputSourceRef currentKeyboard = TISCopyCurrentKeyboardInputSource();
-//  currentKeyboard now contains the current input source
-    CFDataRef layoutData =
-    TISGetInputSourceProperty(currentKeyboard,
-                              kTISPropertyUnicodeKeyLayoutData);
-//  the UNICODE keyLayout is fetched from currentKeyboard in layoutData
-    const UCKeyboardLayout *keyboardLayout =
-    (const UCKeyboardLayout *)CFDataGetBytePtr(layoutData);
-//  A read-only data pointer is fetched from layoutData
-    UInt32 keysDown = 0;
-    UniChar chars[4];
-    UniCharCount realLength;
-    
-    UCKeyTranslate(keyboardLayout,
-                   keyCode,
-                   kUCKeyActionDisplay,
-                   0,
-                   LMGetKbdType(),
-                   kUCKeyTranslateNoDeadKeysBit,
-                   &keysDown,
-                   sizeof(chars) / sizeof(chars[0]),
-                   &realLength,
-                   chars);
-    CFRelease(currentKeyboard);
-//  Converts keyCode, modifier and dead-key state into UNICODE characters
-    return CFStringCreateWithCharacters(kCFAllocatorDefault, chars, 1);
-}
-
 // Events
 - (void)handleAction:(NSMenuItem *)sender {
     AWT_ASSERT_APPKIT_THREAD;
@@ -116,35 +79,6 @@
     // from this "frameless" menu, because there are no active windows. This
     // means we have to handle it here.
     NSEvent *currEvent = [[NSApplication sharedApplication] currentEvent];
-    if ([currEvent type] == NSKeyDown) {
-        NSString *menuKey = [sender keyEquivalent];
-//      If shortcut is "Command Shift ," the menuKey gets the value ","
-//      But [currEvent charactersIgnoringModifiers]; returns "<" and not ","
-//      because the charactersIgnoreingModifiers does not ignore "Shift"
-//      So a shortcut like "Command Shift m" will return "M" where as the
-//      MenuKey will have the value "m". To remove this issue the below
-//      createStringForKey is used.
-        NSString *eventKey = createStringForKey([currEvent keyCode]);
-        
-//      Apple uses characters from private Unicode range for some of the
-//      keys, so we need to do the same translation here that we do
-//      for the regular key down events
-                if ([eventKey length] == 1) {
-                    unichar origChar = [eventKey characterAtIndex:0];
-                    unichar newChar =  NsCharToJavaChar(origChar, 0);
-                    if (newChar == java_awt_event_KeyEvent_CHAR_UNDEFINED) {
-                        newChar = origChar;
-                    }
-        
-                    eventKey = [NSString stringWithCharacters: &newChar length: 1];
-                }
-        
-        NSWindow *keyWindow = [NSApp keyWindow];
-        if ([menuKey isEqualToString:eventKey] && keyWindow != nil) {
-            return;
-        }
-    }
-    
     if (fIsCheckbox) {
         static JNF_CLASS_CACHE(jc_CCheckboxMenuItem, "sun/lwawt/macosx/CCheckboxMenuItem");
         static JNF_MEMBER_CACHE(jm_ckHandleAction, jc_CCheckboxMenuItem, "handleAction", "(Z)V");
@@ -154,16 +88,47 @@
         NSInteger state = [sender state];
         jboolean newState = (state == NSOnState ? JNI_FALSE : JNI_TRUE);
         JNFCallVoidMethod(env, fPeer, jm_ckHandleAction, newState);
-    } else {
-        static JNF_CLASS_CACHE(jc_CMenuItem, "sun/lwawt/macosx/CMenuItem");
-        static JNF_MEMBER_CACHE(jm_handleAction, jc_CMenuItem, "handleAction", "(JI)V"); // AWT_THREADING Safe (event)
-        
-        NSUInteger modifiers = [currEvent modifierFlags];
-        jint javaModifiers = NsKeyModifiersToJavaModifiers(modifiers, NO);
-        
-        JNFCallVoidMethod(env, fPeer, jm_handleAction, UTC(currEvent), javaModifiers); // AWT_THREADING Safe (event)
+    }
+    else {
+        if ([currEvent type] == NSKeyDown) {
+            
+            // Event available through sender variable hence NSApplication
+            // not needed for checking the keyboard input sans the modifier keys
+            // Also, the method used to fetch eventKey earlier would be locale dependent
+            // With earlier implementation, if MenuKey: e EventKey: ा ; if input method
+            // is not U.S. (Devanagari in this case)
+            // With current implementation, EventKey = MenuKey = e irrespective of
+            // input method
+            
+            NSString *eventKey = [sender keyEquivalent];
+            // Apple uses characters from private Unicode range for some of the
+            // keys, so we need to do the same translation here that we do
+            // for the regular key down events
+            if ([eventKey length] == 1) {
+                unichar origChar = [eventKey characterAtIndex:0];
+                unichar newChar =  NsCharToJavaChar(origChar, 0);
+                if (newChar == java_awt_event_KeyEvent_CHAR_UNDEFINED) {
+                    newChar = origChar;
+                }
+                eventKey = [NSString stringWithCharacters: &newChar length: 1];
+            }
+            NSWindow *keyWindow = [NSApp keyWindow];
+            if (keyWindow != nil) {
+                return;
+            }
+            else {
+                static JNF_CLASS_CACHE(jc_CMenuItem, "sun/lwawt/macosx/CMenuItem");
+                static JNF_MEMBER_CACHE(jm_handleAction, jc_CMenuItem, "handleAction", "(JI)V"); // AWT_THREADING Safe (event)
+                
+                NSUInteger modifiers = [currEvent modifierFlags];
+                jint javaModifiers = NsKeyModifiersToJavaModifiers(modifiers, NO);
+                
+                JNFCallVoidMethod(env, fPeer, jm_handleAction, UTC(currEvent), javaModifiers); // AWT_THREADING Safe (event)
+            }
+        }
     }
     JNF_COCOA_EXIT(env);
+    
 }
 
 - (void) setJavaLabel:(NSString *)theLabel shortcut:(NSString *)theKeyEquivalent modifierMask:(jint)modifiers {
--- a/jdk/src/java.desktop/macosx/native/libawt_lwawt/awt/JavaComponentAccessibility.m	Thu May 19 17:48:02 2016 +0000
+++ b/jdk/src/java.desktop/macosx/native/libawt_lwawt/awt/JavaComponentAccessibility.m	Thu May 19 19:46:20 2016 +0000
@@ -25,7 +25,7 @@
 
 // External Java Accessibility links:
 //
-// <http://java.sun.com/j2se/1.4.2/docs/guide/access/index.html>
+// <https://docs.oracle.com/javase/8/docs/technotes/guides/access/index.html>
 // <http://www-106.ibm.com/developerworks/library/j-access/?n-j-10172>
 // <http://archives.java.sun.com/archives/java-access.html> (Sun's mailing list for Java accessibility)
 
@@ -1030,7 +1030,7 @@
 // Element's value (id)
 // note that the appKit meaning of "accessibilityValue" is different from the java
 // meaning of "accessibleValue", which is specific to numerical values
-// (http://java.sun.com/j2se/1.3/docs/api/javax/accessibility/AccessibleValue.html#setCurrentAccessibleValue(java.lang.Number))
+// (https://docs.oracle.com/javase/8/docs/api/javax/accessibility/AccessibleValue.html#setCurrentAccessibleValue-java.lang.Number-)
 - (id)accessibilityValueAttribute
 {
     static JNF_STATIC_MEMBER_CACHE(jm_getCurrentAccessibleValue, sjc_CAccessibility, "getCurrentAccessibleValue", "(Ljavax/accessibility/AccessibleValue;Ljava/awt/Component;)Ljava/lang/Number;");
--- a/jdk/src/java.desktop/share/classes/com/sun/imageio/plugins/common/SimpleCMYKColorSpace.java	Thu May 19 17:48:02 2016 +0000
+++ b/jdk/src/java.desktop/share/classes/com/sun/imageio/plugins/common/SimpleCMYKColorSpace.java	Thu May 19 19:46:20 2016 +0000
@@ -31,7 +31,7 @@
  * color space.
  */
 public final class SimpleCMYKColorSpace extends ColorSpace {
-    private static final long serialVersionUID = 666L; // XXX Revise UID value
+    private static final long serialVersionUID = 5387117338644522424L;
 
     private static ColorSpace theInstance = null;
     private ColorSpace csRGB;
--- a/jdk/src/java.desktop/share/classes/com/sun/media/sound/AiffFileFormat.java	Thu May 19 17:48:02 2016 +0000
+++ b/jdk/src/java.desktop/share/classes/com/sun/media/sound/AiffFileFormat.java	Thu May 19 19:46:20 2016 +0000
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 1999, 2013, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 1999, 2016, 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
@@ -25,17 +25,14 @@
 
 package com.sun.media.sound;
 
-import javax.sound.sampled.AudioFileFormat;
 import javax.sound.sampled.AudioFormat;
 
-
 /**
  * AIFF file format.
  *
  * @author Jan Borgersen
  */
-
-final class AiffFileFormat extends AudioFileFormat {
+final class AiffFileFormat extends StandardFileFormat {
 
     static final int AIFF_MAGIC         = 1179603533;
 
@@ -70,11 +67,8 @@
     /** FVER chunk size in bytes, inclusive magic and length field */
     private final int fverChunkSize=0;
 
-    AiffFileFormat( AudioFileFormat aff ) {
-        this( aff.getType(), aff.getByteLength(), aff.getFormat(), aff.getFrameLength() );
-    }
-
-    AiffFileFormat(Type type, int byteLength, AudioFormat format, int frameLength) {
+    AiffFileFormat(final Type type, final long byteLength,
+                   final AudioFormat format, final long frameLength) {
         super(type, byteLength, format, frameLength);
     }
 
--- a/jdk/src/java.desktop/share/classes/com/sun/media/sound/AiffFileReader.java	Thu May 19 17:48:02 2016 +0000
+++ b/jdk/src/java.desktop/share/classes/com/sun/media/sound/AiffFileReader.java	Thu May 19 19:46:20 2016 +0000
@@ -45,7 +45,7 @@
 public final class AiffFileReader extends SunFileReader {
 
     @Override
-    AudioFileFormat getAudioFileFormatImpl(final InputStream stream)
+    StandardFileFormat getAudioFileFormatImpl(final InputStream stream)
             throws UnsupportedAudioFileException, IOException {
         DataInputStream dis = new DataInputStream(stream);
 
@@ -60,11 +60,11 @@
             throw new UnsupportedAudioFileException("not an AIFF file");
         }
 
-        int frameLength = 0;
+        long /* unsigned 32bit */ frameLength = 0;
         int length = dis.readInt();
         int iffType = dis.readInt();
 
-        int totallength;
+        final long totallength;
         if(length <= 0 ) {
             length = AudioSystem.NOT_SPECIFIED;
             totallength = AudioSystem.NOT_SPECIFIED;
@@ -106,12 +106,7 @@
                 if (channels <= 0) {
                     throw new UnsupportedAudioFileException("Invalid number of channels");
                 }
-                frameLength = dis.readInt(); // numSampleFrames
-                if (frameLength < 0) {
-                    // AiffFileFormat uses int, unlike AIS which uses long
-                    //TODO this (negative) value should be passed as long to AIS
-                    frameLength = AudioSystem.NOT_SPECIFIED;
-                }
+                frameLength = dis.readInt() & 0xffffffffL; // numSampleFrames
 
                 int sampleSizeInBits = dis.readUnsignedShort();
                 if (sampleSizeInBits < 1 || sampleSizeInBits > 32) {
--- a/jdk/src/java.desktop/share/classes/com/sun/media/sound/AuFileFormat.java	Thu May 19 17:48:02 2016 +0000
+++ b/jdk/src/java.desktop/share/classes/com/sun/media/sound/AuFileFormat.java	Thu May 19 19:46:20 2016 +0000
@@ -33,7 +33,7 @@
  *
  * @author Jan Borgersen
  */
-final class AuFileFormat extends AudioFileFormat {
+final class AuFileFormat extends StandardFileFormat {
 
     // magic numbers
     static final int AU_SUN_MAGIC = 0x2e736e64; // ".snd"
@@ -55,11 +55,18 @@
 
     static final int AU_HEADERSIZE       = 24;
 
+    /**
+     * According the specification of AU file format this is the value for
+     * length field if length is not known. This is a maximum possible value for
+     * the unsigned int.
+     */
+    static final long /*unsigned int */ UNKNOWN_SIZE = 0xffffffffL;
+
     private int auType;
 
-    AuFileFormat(AudioFileFormat.Type type, int lengthInBytes, AudioFormat format, int lengthInFrames) {
-
-        super(type,lengthInBytes,format,lengthInFrames);
+    AuFileFormat(final AudioFileFormat.Type type, final long byteLength,
+                 final AudioFormat format, final long frameLength) {
+        super(type, byteLength, format, frameLength);
 
         AudioFormat.Encoding encoding = format.getEncoding();
 
--- a/jdk/src/java.desktop/share/classes/com/sun/media/sound/AuFileReader.java	Thu May 19 17:48:02 2016 +0000
+++ b/jdk/src/java.desktop/share/classes/com/sun/media/sound/AuFileReader.java	Thu May 19 19:46:20 2016 +0000
@@ -29,7 +29,6 @@
 import java.io.IOException;
 import java.io.InputStream;
 
-import javax.sound.sampled.AudioFileFormat;
 import javax.sound.sampled.AudioFileFormat.Type;
 import javax.sound.sampled.AudioFormat;
 import javax.sound.sampled.AudioSystem;
@@ -45,7 +44,7 @@
 public final class AuFileReader extends SunFileReader {
 
     @Override
-    public AudioFileFormat getAudioFileFormatImpl(final InputStream stream)
+    public StandardFileFormat getAudioFileFormatImpl(final InputStream stream)
             throws UnsupportedAudioFileException, IOException {
         final DataInputStream dis = new DataInputStream(stream);
         final int magic = dis.readInt();
@@ -56,7 +55,7 @@
         }
 
         final int headerSize = dis.readInt();
-        final int dataSize = dis.readInt();
+        final long /* unsigned int */ dataSize = dis.readInt() & 0xffffffffL;
         final int auType = dis.readInt();
         final int sampleRate = dis.readInt();
         final int channels = dis.readInt();
@@ -120,21 +119,21 @@
                 // unsupported filetype, throw exception
                 throw new UnsupportedAudioFileException("not a valid AU file");
         }
+        // now seek past the header
+        dis.skipBytes(headerSize - AuFileFormat.AU_HEADERSIZE);
 
         final int frameSize = calculatePCMFrameSize(sampleSizeInBits, channels);
         //$$fb 2002-11-02: fix for 4629669: AU file reader: problems with empty files
-        final int length;
-        if (dataSize < 0) {
-            length = AudioSystem.NOT_SPECIFIED;
-        } else {
-            //$$fb 2003-10-20: fix for 4940459: AudioInputStream.getFrameLength() returns 0 instead of NOT_SPECIFIED
-            length = dataSize / frameSize;
+        //$$fb 2003-10-20: fix for 4940459: AudioInputStream.getFrameLength() returns 0 instead of NOT_SPECIFIED
+        long frameLength = AudioSystem.NOT_SPECIFIED;
+        long byteLength = AudioSystem.NOT_SPECIFIED;
+        if (dataSize != AuFileFormat.UNKNOWN_SIZE) {
+            frameLength = dataSize / frameSize;
+            byteLength = dataSize + headerSize;
         }
-        // now seek past the header
-        dis.skipBytes(headerSize - AuFileFormat.AU_HEADERSIZE);
         final AudioFormat format = new AudioFormat(encoding, sampleRate,
                                                    sampleSizeInBits, channels,
                                                    frameSize, sampleRate, true);
-        return new AuFileFormat(Type.AU, dataSize + headerSize, format, length);
+        return new AuFileFormat(Type.AU, byteLength, format, frameLength);
     }
 }
--- a/jdk/src/java.desktop/share/classes/com/sun/media/sound/SoftMidiAudioFileReader.java	Thu May 19 17:48:02 2016 +0000
+++ b/jdk/src/java.desktop/share/classes/com/sun/media/sound/SoftMidiAudioFileReader.java	Thu May 19 19:46:20 2016 +0000
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2007, 2015, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2007, 2016, 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
@@ -38,7 +38,6 @@
 import javax.sound.midi.Receiver;
 import javax.sound.midi.Sequence;
 import javax.sound.midi.Track;
-import javax.sound.sampled.AudioFileFormat;
 import javax.sound.sampled.AudioFileFormat.Type;
 import javax.sound.sampled.AudioFormat;
 import javax.sound.sampled.AudioInputStream;
@@ -56,10 +55,10 @@
     private static final AudioFormat format = new AudioFormat(44100, 16, 2,
                                                               true, false);
 
-    private static AudioFileFormat getAudioFileFormat(final Sequence seq) {
+    private static StandardFileFormat getAudioFileFormat(final Sequence seq) {
         long totallen = seq.getMicrosecondLength() / 1000000;
         long len = (long) (format.getFrameRate() * (totallen + 4));
-        return new AudioFileFormat(MIDI, format, (int) len);
+        return new StandardFileFormat(MIDI, format, len);
     }
 
     private AudioInputStream getAudioInputStream(final Sequence seq)
@@ -140,7 +139,7 @@
     }
 
     @Override
-    AudioFileFormat getAudioFileFormatImpl(final InputStream stream)
+    StandardFileFormat getAudioFileFormatImpl(final InputStream stream)
             throws UnsupportedAudioFileException, IOException {
         try {
             return getAudioFileFormat(MidiSystem.getSequence(stream));
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/jdk/src/java.desktop/share/classes/com/sun/media/sound/StandardFileFormat.java	Thu May 19 19:46:20 2016 +0000
@@ -0,0 +1,114 @@
+/*
+ * Copyright (c) 2016, 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 com.sun.media.sound;
+
+import javax.sound.sampled.AudioFileFormat;
+import javax.sound.sampled.AudioFormat;
+import javax.sound.sampled.AudioSystem;
+
+/**
+ * An instance of the {@code StandardFileFormat} describes the file's length in
+ * bytes and the length in sample frames as longs. This will provide an
+ * additional precision unlike the {@code AudioFileFormat}.
+ */
+class StandardFileFormat extends AudioFileFormat {
+
+    /**
+     * File length in bytes stored as long.
+     */
+    private final long byteLength;
+
+    /**
+     * Audio data length in sample frames stored as long.
+     */
+    private final long frameLength;
+
+    /**
+     * Constructs {@code StandardFileFormat} object.
+     *
+     * @param  type the type of the audio file
+     * @param  format the format of the audio data contained in the file
+     * @param  frameLength the audio data length in sample frames, or
+     *         {@code AudioSystem.NOT_SPECIFIED}
+     */
+    StandardFileFormat(final Type type, final AudioFormat format,
+                       final long frameLength) {
+        this(type, AudioSystem.NOT_SPECIFIED, format, frameLength);
+    }
+
+    /**
+     * Constructs {@code StandardFileFormat} object.
+     *
+     * @param  type the type of the audio file
+     * @param  byteLength the length of the file in bytes, or
+     *         {@code AudioSystem.NOT_SPECIFIED}
+     * @param  format the format of the audio data contained in the file
+     * @param  frameLength the audio data length in sample frames, or
+     *         {@code AudioSystem.NOT_SPECIFIED}
+     */
+    StandardFileFormat(final Type type, final long byteLength,
+                       final AudioFormat format, final long frameLength) {
+        super(type, clip(byteLength), format, clip(frameLength));
+        this.byteLength = byteLength;
+        this.frameLength = frameLength;
+    }
+
+    /**
+     * Replaces the passed value to {@code AudioSystem.NOT_SPECIFIED} if the
+     * value is greater than {@code Integer.MAX_VALUE}.
+     *
+     * @param  value which should be clipped
+     * @return the clipped value
+     */
+    private static int clip(final long value) {
+        if (value > Integer.MAX_VALUE) {
+            return AudioSystem.NOT_SPECIFIED;
+        }
+        return (int) value;
+    }
+
+    /**
+     * Obtains the length of the audio data contained in the file, expressed in
+     * sample frames. The long precision is used.
+     *
+     * @return the number of sample frames of audio data in the file
+     * @see AudioSystem#NOT_SPECIFIED
+     */
+    public final long getLongFrameLength() {
+        return frameLength;
+    }
+
+    /**
+     * Obtains the size in bytes of the entire audio file (not just its audio
+     * data). The long precision is used.
+     *
+     * @return the audio file length in bytes
+     * @see AudioSystem#NOT_SPECIFIED
+     */
+    public final long getLongByteLength() {
+        return byteLength;
+    }
+}
--- a/jdk/src/java.desktop/share/classes/com/sun/media/sound/SunFileReader.java	Thu May 19 17:48:02 2016 +0000
+++ b/jdk/src/java.desktop/share/classes/com/sun/media/sound/SunFileReader.java	Thu May 19 19:46:20 2016 +0000
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 1999, 2015, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 1999, 2016, Oracle and/or its affiliates. All rights reserved.
  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
  *
  * This code is free software; you can redistribute it and/or modify it
@@ -47,7 +47,7 @@
 abstract class SunFileReader extends AudioFileReader {
 
     @Override
-    public final AudioFileFormat getAudioFileFormat(final InputStream stream)
+    public final StandardFileFormat getAudioFileFormat(final InputStream stream)
             throws UnsupportedAudioFileException, IOException {
         stream.mark(200); // The biggest value which was historically used
         try {
@@ -87,11 +87,11 @@
             throws UnsupportedAudioFileException, IOException {
         stream.mark(200); // The biggest value which was historically used
         try {
-            final AudioFileFormat fileFormat = getAudioFileFormatImpl(stream);
+            final StandardFileFormat format = getAudioFileFormatImpl(stream);
             // we've got everything, the stream is supported and it is at the
             // beginning of the audio data, so return an AudioInputStream
-            return new AudioInputStream(stream, fileFormat.getFormat(),
-                                        fileFormat.getFrameLength());
+            return new AudioInputStream(stream, format.getFormat(),
+                                        format.getLongFrameLength());
         } catch (UnsupportedAudioFileException | EOFException ignored) {
             // stream is unsupported or the header is less than was expected
             stream.reset();
@@ -140,7 +140,7 @@
      *         UnsupportedAudioFileException if the header is less than was
      *         expected
      */
-    abstract AudioFileFormat getAudioFileFormatImpl(InputStream stream)
+    abstract StandardFileFormat getAudioFileFormatImpl(InputStream stream)
             throws UnsupportedAudioFileException, IOException;
 
     // HELPER METHODS
--- a/jdk/src/java.desktop/share/classes/com/sun/media/sound/WaveExtensibleFileReader.java	Thu May 19 17:48:02 2016 +0000
+++ b/jdk/src/java.desktop/share/classes/com/sun/media/sound/WaveExtensibleFileReader.java	Thu May 19 19:46:20 2016 +0000
@@ -34,7 +34,6 @@
 import javax.sound.sampled.AudioFormat;
 import javax.sound.sampled.AudioFormat.Encoding;
 import javax.sound.sampled.AudioInputStream;
-import javax.sound.sampled.AudioSystem;
 import javax.sound.sampled.UnsupportedAudioFileException;
 
 /**
@@ -167,7 +166,7 @@
     }
 
     @Override
-    AudioFileFormat getAudioFileFormatImpl(final InputStream stream)
+    StandardFileFormat getAudioFileFormatImpl(final InputStream stream)
             throws UnsupportedAudioFileException, IOException {
 
         RIFFReader riffiterator = new RIFFReader(stream);
@@ -249,19 +248,17 @@
         } else {
             throw new UnsupportedAudioFileException();
         }
-        long frameLength = dataSize / audioformat.getFrameSize();
-        if (frameLength > Integer.MAX_VALUE) {
-            frameLength = AudioSystem.NOT_SPECIFIED;
-        }
-        return new AudioFileFormat(AudioFileFormat.Type.WAVE, audioformat,
-                                   (int) frameLength);
+        return new StandardFileFormat(AudioFileFormat.Type.WAVE, audioformat,
+                                      dataSize / audioformat.getFrameSize());
     }
 
     @Override
     public AudioInputStream getAudioInputStream(final InputStream stream)
             throws UnsupportedAudioFileException, IOException {
 
-        final AudioFileFormat format = getAudioFileFormat(stream);
+        final StandardFileFormat format = getAudioFileFormat(stream);
+        final AudioFormat af = format.getFormat();
+        final long length = format.getLongFrameLength();
         // we've got everything, the stream is supported and it is at the
         // beginning of the header, so find the data chunk again and return an
         // AudioInputStream
@@ -269,8 +266,6 @@
         while (riffiterator.hasNextChunk()) {
             RIFFReader chunk = riffiterator.nextChunk();
             if (chunk.getFormat().equals("data")) {
-                final AudioFormat af = format.getFormat();
-                final long length = chunk.getSize() / af.getFrameSize();
                 return new AudioInputStream(chunk, af, length);
             }
         }
--- a/jdk/src/java.desktop/share/classes/com/sun/media/sound/WaveFileFormat.java	Thu May 19 17:48:02 2016 +0000
+++ b/jdk/src/java.desktop/share/classes/com/sun/media/sound/WaveFileFormat.java	Thu May 19 19:46:20 2016 +0000
@@ -33,7 +33,7 @@
  *
  * @author Jan Borgersen
  */
-final class WaveFileFormat extends AudioFileFormat {
+final class WaveFileFormat extends StandardFileFormat {
 
     /**
      * Wave format type.
@@ -73,9 +73,9 @@
     static final int WAVE_FORMAT_SX7383    = 0x1C07;
     static final int WAVE_FORMAT_EXTENSIBLE= 0xFFFE;
 
-    WaveFileFormat(AudioFileFormat.Type type, int lengthInBytes, AudioFormat format, int lengthInFrames) {
-
-        super(type,lengthInBytes,format,lengthInFrames);
+    WaveFileFormat(final AudioFileFormat.Type type, final long byteLength,
+                   final AudioFormat format, final long frameLength) {
+        super(type, byteLength, format, frameLength);
 
         AudioFormat.Encoding encoding = format.getEncoding();
 
--- a/jdk/src/java.desktop/share/classes/com/sun/media/sound/WaveFileReader.java	Thu May 19 17:48:02 2016 +0000
+++ b/jdk/src/java.desktop/share/classes/com/sun/media/sound/WaveFileReader.java	Thu May 19 19:46:20 2016 +0000
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 1999, 2015, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 1999, 2016, 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
@@ -45,7 +45,7 @@
 public final class WaveFileReader extends SunFileReader {
 
     @Override
-    AudioFileFormat getAudioFileFormatImpl(final InputStream stream)
+    StandardFileFormat getAudioFileFormatImpl(final InputStream stream)
             throws UnsupportedAudioFileException, IOException {
 
         // assumes sream is rewound
@@ -64,9 +64,9 @@
         DataInputStream dis = new DataInputStream( stream );
 
         int magic = dis.readInt();
-        int fileLength = rllong(dis);
+        long /* unsigned int */ fileLength = rllong(dis) & 0xffffffffL;
         int waveMagic = dis.readInt();
-        int totallength;
+        long totallength;
         if (fileLength <= 0) {
             fileLength = AudioSystem.NOT_SPECIFIED;
             totallength = AudioSystem.NOT_SPECIFIED;
@@ -186,19 +186,18 @@
             }
         }
         // this is the length of the data chunk
-        int dataLength = rllong(dis); nread += 4;
+        long /* unsigned int */ dataLength = rllong(dis) & 0xffffffffL; nread += 4;
 
         // now build the new AudioFileFormat and return
-
+        final int frameSize = calculatePCMFrameSize(sampleSizeInBits, channels);
         AudioFormat format = new AudioFormat(encoding,
                                              (float)sampleRate,
                                              sampleSizeInBits, channels,
-                                             calculatePCMFrameSize(sampleSizeInBits, channels),
+                                             frameSize,
                                              (float)sampleRate, false);
 
-        return new WaveFileFormat(AudioFileFormat.Type.WAVE,
-                                  totallength,
-                                  format,
-                                  dataLength / format.getFrameSize());
+        long frameLength = dataLength / format.getFrameSize();
+        return new WaveFileFormat(AudioFileFormat.Type.WAVE, totallength,
+                                  format, frameLength);
     }
 }
--- a/jdk/src/java.desktop/share/classes/com/sun/media/sound/WaveFloatFileReader.java	Thu May 19 17:48:02 2016 +0000
+++ b/jdk/src/java.desktop/share/classes/com/sun/media/sound/WaveFloatFileReader.java	Thu May 19 19:46:20 2016 +0000
@@ -32,7 +32,6 @@
 import javax.sound.sampled.AudioFormat;
 import javax.sound.sampled.AudioFormat.Encoding;
 import javax.sound.sampled.AudioInputStream;
-import javax.sound.sampled.AudioSystem;
 import javax.sound.sampled.UnsupportedAudioFileException;
 
 /**
@@ -43,7 +42,7 @@
 public final class WaveFloatFileReader extends SunFileReader {
 
     @Override
-    AudioFileFormat getAudioFileFormatImpl(final InputStream stream)
+    StandardFileFormat getAudioFileFormatImpl(final InputStream stream)
             throws UnsupportedAudioFileException, IOException {
 
         RIFFReader riffiterator = new RIFFReader(stream);
@@ -88,20 +87,17 @@
         AudioFormat audioformat = new AudioFormat(
                 Encoding.PCM_FLOAT, samplerate, bits, channels,
                 framesize, samplerate, false);
-        long frameLength = dataSize / audioformat.getFrameSize();
-        if (frameLength > Integer.MAX_VALUE) {
-            frameLength = AudioSystem.NOT_SPECIFIED;
-        }
-
-        return new AudioFileFormat(AudioFileFormat.Type.WAVE, audioformat,
-                                   (int) frameLength);
+        return new StandardFileFormat(AudioFileFormat.Type.WAVE, audioformat,
+                                      dataSize / audioformat.getFrameSize());
     }
 
     @Override
     public AudioInputStream getAudioInputStream(final InputStream stream)
             throws UnsupportedAudioFileException, IOException {
 
-        final AudioFileFormat format = getAudioFileFormat(stream);
+        final StandardFileFormat format = getAudioFileFormat(stream);
+        final AudioFormat af = format.getFormat();
+        final long length = format.getLongFrameLength();
         // we've got everything, the stream is supported and it is at the
         // beginning of the header, so find the data chunk again and return an
         // AudioInputStream
@@ -109,8 +105,6 @@
         while (riffiterator.hasNextChunk()) {
             RIFFReader chunk = riffiterator.nextChunk();
             if (chunk.getFormat().equals("data")) {
-                final AudioFormat af = format.getFormat();
-                final long length = chunk.getSize() / af.getFrameSize();
                 return new AudioInputStream(chunk, af, length);
             }
         }
--- a/jdk/src/java.desktop/share/classes/java/awt/Component.java	Thu May 19 17:48:02 2016 +0000
+++ b/jdk/src/java.desktop/share/classes/java/awt/Component.java	Thu May 19 19:46:20 2016 +0000
@@ -9739,19 +9739,24 @@
      */
     int getAccessibleIndexInParent() {
         synchronized (getTreeLock()) {
-            int index = -1;
-            Container parent = this.getParent();
-            if (parent != null && parent instanceof Accessible) {
-                Component ca[] = parent.getComponents();
-                for (int i = 0; i < ca.length; i++) {
-                    if (ca[i] instanceof Accessible) {
-                        index++;
-                    }
-                    if (this.equals(ca[i])) {
-                        return index;
-                    }
+
+            AccessibleContext accContext = getAccessibleContext();
+            if (accContext == null) {
+                return -1;
+            }
+
+            Accessible parent = accContext.getAccessibleParent();
+            if (parent == null) {
+                return -1;
+            }
+
+            accContext = parent.getAccessibleContext();
+            for (int i = 0; i < accContext.getAccessibleChildrenCount(); i++) {
+                if (this.equals(accContext.getAccessibleChild(i))) {
+                    return i;
                 }
             }
+
             return -1;
         }
     }
--- a/jdk/src/java.desktop/share/classes/java/awt/Toolkit.java	Thu May 19 17:48:02 2016 +0000
+++ b/jdk/src/java.desktop/share/classes/java/awt/Toolkit.java	Thu May 19 19:46:20 2016 +0000
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 1995, 2015, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 1995, 2016, 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
@@ -89,7 +89,7 @@
  * <br>For more information, see
  * <a href="http://docs.oracle.com/javase/tutorial/uiswing/misc/focus.html#transferTiming">Timing
  * Focus Transfers</a>, a section in
- * <a href="http://java.sun.com/docs/books/tutorial/uiswing/">The Swing
+ * <a href="http://docs.oracle.com/javase/tutorial/uiswing/">The Swing
  * Tutorial</a>.
  *
  * <li>Making a top-level container visible.
@@ -207,30 +207,34 @@
     }
 
     /**
-     * Returns whether dynamic layout of Containers on resize is
-     * currently active (both set in program
-     *( {@code isDynamicLayoutSet()} )
-     *, and supported
-     * by the underlying operating system and/or window manager).
-     * If dynamic layout is currently inactive then Containers
-     * re-layout their components when resizing is completed. As a result
-     * the {@code Component.validate()} method will be invoked only
-     * once per resize.
-     * If dynamic layout is currently active then Containers
-     * re-layout their components on every native resize event and
-     * the {@code validate()} method will be invoked each time.
-     * The OS/WM support can be queried using
-     * the getDesktopProperty("awt.dynamicLayoutSupported") method.
+     * Returns whether dynamic layout of Containers on resize is currently
+     * enabled on the underlying operating system and/or window manager). If the
+     * platform supports it, {@code setDynamicLayout(boolean)} may be used to
+     * programmatically enable or disable platform dynamic layout. Regardless of
+     * whether that toggling is supported, or whether {@code true} or {@code
+     * false} is specified as an argument, or has never been called at all, this
+     * method will return the active current platform behavior and which will be
+     * followed by the JDK in determining layout policy during resizing.
+     * <p>
+     * If dynamic layout is currently inactive then Containers re-layout their
+     * components when resizing is completed. As a result the
+     * {@code Component.validate()} method will be invoked only once per resize.
+     * If dynamic layout is currently active then Containers re-layout their
+     * components on every native resize event and the {@code validate()} method
+     * will be invoked each time. The OS/WM support can be queried using the
+     * getDesktopProperty("awt.dynamicLayoutSupported") method. This property
+     * will reflect the platform capability but is not sufficient to tell if it
+     * is presently enabled.
      *
-     * @return    true if dynamic layout of Containers on resize is
-     *            currently active, false otherwise.
-     * @exception HeadlessException if the GraphicsEnvironment.isHeadless()
-     *            method returns true
-     * @see       #setDynamicLayout(boolean dynamic)
-     * @see       #isDynamicLayoutSet()
-     * @see       #getDesktopProperty(String propertyName)
-     * @see       java.awt.GraphicsEnvironment#isHeadless
-     * @since     1.4
+     * @return true if dynamic layout of Containers on resize is currently
+     *         active, false otherwise.
+     * @throws HeadlessException if the GraphicsEnvironment.isHeadless() method
+     *         returns true
+     * @see #setDynamicLayout(boolean dynamic)
+     * @see #isDynamicLayoutSet()
+     * @see #getDesktopProperty(String propertyName)
+     * @see java.awt.GraphicsEnvironment#isHeadless
+     * @since 1.4
      */
     public boolean isDynamicLayoutActive()
         throws HeadlessException {
--- a/jdk/src/java.desktop/share/classes/java/beans/XMLDecoder.java	Thu May 19 17:48:02 2016 +0000
+++ b/jdk/src/java.desktop/share/classes/java/beans/XMLDecoder.java	Thu May 19 19:46:20 2016 +0000
@@ -53,8 +53,8 @@
  *
  *<p>
  * For more information you might also want to check out
- * <a
- href="http://java.sun.com/products/jfc/tsc/articles/persistence3">Long Term Persistence of JavaBeans Components: XML Schema</a>,
+ * <a href="http://www.oracle.com/technetwork/java/persistence3-139471.html">
+ * Long Term Persistence of JavaBeans Components: XML Schema</a>,
  * an article in <em>The Swing Connection.</em>
  * @see XMLEncoder
  * @see java.io.ObjectInputStream
@@ -284,7 +284,8 @@
      * The {@code null} value may cause illegal parsing in such case.
      * The same problem may occur, if the {@code owner} class
      * does not contain expected method to call. See details <a
-     * href="http://java.sun.com/products/jfc/tsc/articles/persistence3/">here</a>.
+     * href="http://www.oracle.com/technetwork/java/persistence3-139471.html">
+     * here</a>.
      *
      * @param owner  the owner of the default handler
      *               that can be used as a value of &lt;java&gt; element
--- a/jdk/src/java.desktop/share/classes/java/beans/XMLEncoder.java	Thu May 19 17:48:02 2016 +0000
+++ b/jdk/src/java.desktop/share/classes/java/beans/XMLEncoder.java	Thu May 19 19:46:20 2016 +0000
@@ -193,8 +193,8 @@
  *
  *<p>
  * For more information you might also want to check out
- * <a
- href="http://java.sun.com/products/jfc/tsc/articles/persistence4">Using XMLEncoder</a>,
+ * <a href="http://www.oracle.com/technetwork/java/persistence4-140124.html">
+ * Using XMLEncoder</a>,
  * an article in <em>The Swing Connection.</em>
  * @see XMLDecoder
  * @see java.io.ObjectOutputStream
@@ -438,7 +438,8 @@
      * <P>
      * For more information about using resource bundles with the
      * XMLEncoder, see
-     * http://java.sun.com/products/jfc/tsc/articles/persistence4/#i18n
+     * <a href="http://www.oracle.com/technetwork/java/persistence4-140124.html#i18n">
+     * Creating Internationalized Applications</a>,
      *
      * @param oldExp The expression that will be written
      *               to the stream.
--- a/jdk/src/java.desktop/share/classes/javax/imageio/plugins/tiff/GeoTIFFTagSet.java	Thu May 19 17:48:02 2016 +0000
+++ b/jdk/src/java.desktop/share/classes/javax/imageio/plugins/tiff/GeoTIFFTagSet.java	Thu May 19 19:46:20 2016 +0000
@@ -87,9 +87,9 @@
         }
     }
 
-    static class ModelTiePoint extends TIFFTag {
-        public ModelTiePoint() {
-            super("ModelTiePointTag",
+    static class ModelTiepoint extends TIFFTag {
+        public ModelTiepoint() {
+            super("ModelTiepointTag",
                   TAG_MODEL_TIE_POINT,
                   1 << TIFFTag.TIFF_DOUBLE);
         }
@@ -126,7 +126,7 @@
 
         tags.add(new GeoTIFFTagSet.ModelPixelScale());
         tags.add(new GeoTIFFTagSet.ModelTransformation());
-        tags.add(new GeoTIFFTagSet.ModelTiePoint());
+        tags.add(new GeoTIFFTagSet.ModelTiepoint());
         tags.add(new GeoTIFFTagSet.GeoKeyDirectory());
         tags.add(new GeoTIFFTagSet.GeoDoubleParams());
         tags.add(new GeoTIFFTagSet.GeoAsciiParams());
--- a/jdk/src/java.desktop/share/classes/javax/imageio/plugins/tiff/TIFFField.java	Thu May 19 17:48:02 2016 +0000
+++ b/jdk/src/java.desktop/share/classes/javax/imageio/plugins/tiff/TIFFField.java	Thu May 19 19:46:20 2016 +0000
@@ -412,7 +412,7 @@
 
     /**
      * Creates a {@code TIFFField} from a TIFF native image
-     * metadata node. If the value of the <tt>"tagNumber"</tt> attribute
+     * metadata node. If the value of the <tt>"number"</tt> attribute
      * of the node is not found in {@code tagSet} then a new
      * {@code TIFFTag} with name {@code TIFFTag.UNKNOWN_TAG_NAME}
      * will be created and assigned to the field.
@@ -424,6 +424,10 @@
      * {@code null}.
      * @throws IllegalArgumentException if the name of the node is not
      * {@code "TIFFField"}.
+     * @throws NullPointerException if the node does not contain any data.
+     * @throws IllegalArgumentException if the combination of node attributes
+     * and data is not legal per the {@link #TIFFField(TIFFTag,int,int,Object)}
+     * constructor specification.
      * @return A new {@code TIFFField}.
      */
     public static TIFFField createFromMetadataNode(TIFFTagSet tagSet,
@@ -1089,6 +1093,15 @@
      * {@code TIFF_SBYTE} data will be returned in the range
      * [-128, 127].
      *
+     * <p> Data in {@code TIFF_FLOAT} and {@code TIFF_DOUBLE} are
+     * simply cast to {@code long} and may suffer from truncation.
+     *
+     * <p> Data in {@code TIFF_SRATIONAL} or
+     * {@code TIFF_RATIONAL} format are evaluated by dividing the
+     * numerator into the denominator using double-precision
+     * arithmetic and then casting to {@code long}.  Loss of
+     * precision and truncation may occur.
+     *
      * <p> Data in {@code TIFF_ASCII} format will be parsed as by
      * the {@code Double.parseDouble} method, with the result
      * cast to {@code long}.
@@ -1112,6 +1125,10 @@
         case TIFFTag.TIFF_LONG:
         case TIFFTag.TIFF_IFD_POINTER:
             return ((long[])data)[index];
+        case TIFFTag.TIFF_FLOAT:
+            return (long)((float[])data)[index];
+        case TIFFTag.TIFF_DOUBLE:
+            return (long)((double[])data)[index];
         case TIFFTag.TIFF_SRATIONAL:
             int[] ivalue = getAsSRational(index);
             return (long)((double)ivalue[0]/ivalue[1]);
@@ -1286,7 +1303,11 @@
      * version of the data item.  Data of type
      * {@code TIFFTag.TIFF_RATIONAL} or {@code TIFF_SRATIONAL} are
      * represented as a pair of integers separated by a
-     * {@code '/'} character.
+     * {@code '/'} character.  If the numerator of a
+     * {@code TIFFTag.TIFF_RATIONAL} or {@code TIFF_SRATIONAL} is an integral
+     * multiple of the denominator, then the value is represented as
+     * {@code "q/1"} where {@code q} is the quotient of the numerator and
+     * denominator.
      *
      * @param index The index of the data.
      * @return The data at the given index as a {@code String}.
--- a/jdk/src/java.desktop/share/classes/javax/swing/JRootPane.java	Thu May 19 17:48:02 2016 +0000
+++ b/jdk/src/java.desktop/share/classes/javax/swing/JRootPane.java	Thu May 19 19:46:20 2016 +0000
@@ -194,7 +194,7 @@
  * @see JComponent
  * @see BoxLayout
  *
- * @see <a href="http://java.sun.com/products/jfc/tsc/articles/mixing/">
+ * @see <a href="http://www.oracle.com/technetwork/articles/java/mixing-components-433992.html">
  * Mixing Heavy and Light Components</a>
  *
  * @author David Kloba
--- a/jdk/src/java.desktop/share/classes/javax/swing/colorchooser/package.html	Thu May 19 17:48:02 2016 +0000
+++ b/jdk/src/java.desktop/share/classes/javax/swing/colorchooser/package.html	Thu May 19 19:46:20 2016 +0000
@@ -37,10 +37,10 @@
 Most of the Swing API is <em>not</em> thread safe.
 For details, see
 <a
-href="http://java.sun.com/docs/books/tutorial/uiswing/overview/threads.html"
-target="_top">Threads and Swing</a>,
+href="http://docs.oracle.com/javase/tutorial/uiswing/concurrency/index.html"
+target="_top">Concurrency in Swing</a>,
 a section in
-<em><a href="http://java.sun.com/docs/books/tutorial/"
+<em><a href="http://docs.oracle.com/javase/tutorial/"
 target="_top">The Java Tutorial</a></em>.
 
 
@@ -49,7 +49,7 @@
 This document forms the complete API specification.  For overviews, tutorials, 
 examples, guides, and tool documentation, please see:
 <ul>
-  <li><a href="http://java.sun.com/docs/books/tutorial/uiswing/components/colorchooser.html" target="_top">How to Use Color Choosers</a>, 
+  <li><a href="http://docs.oracle.com/javase/tutorial/uiswing/components/colorchooser.html" target="_top">How to Use Color Choosers</a>,
       a section in <em>The Java Tutorial</em>
 
   <li><a href="../../../../technotes/guides/intl/index.html"
--- a/jdk/src/java.desktop/share/classes/javax/swing/event/package.html	Thu May 19 17:48:02 2016 +0000
+++ b/jdk/src/java.desktop/share/classes/javax/swing/event/package.html	Thu May 19 19:46:20 2016 +0000
@@ -39,17 +39,17 @@
 Most of the Swing API is <em>not</em> thread safe.
 For details, see
 <a
-href="http://java.sun.com/docs/books/tutorial/uiswing/overview/threads.html"
-target="_top">Threads and Swing</a>,
+href="http://docs.oracle.com/javase/tutorial/uiswing/concurrency/index.html"
+target="_top">Concurrency in Swing</a>,
 a section in
-<em><a href="http://java.sun.com/docs/books/tutorial/"
+<em><a href="http://docs.oracle.com/javase/tutorial/"
 target="_top">The Java Tutorial</a></em>.
 
 <h2>Related Documentation</h2>
 
 For overviews, tutorials, examples, guides, and tool documentation, please see:
 <ul>
-  <li><a href="http://java.sun.com/docs/books/tutorial/uiswing/events/"
+  <li><a href="http://docs.oracle.com/javase/tutorial/uiswing/events/index.html"
       target="_top">Writing Event Listeners</a>,
       a section in <em>The Java Tutorial</em>
 </ul>
--- a/jdk/src/java.desktop/share/classes/javax/swing/filechooser/package.html	Thu May 19 17:48:02 2016 +0000
+++ b/jdk/src/java.desktop/share/classes/javax/swing/filechooser/package.html	Thu May 19 19:46:20 2016 +0000
@@ -37,10 +37,10 @@
 Most of the Swing API is <em>not</em> thread safe.
 For details, see
 <a
-href="http://java.sun.com/docs/books/tutorial/uiswing/overview/threads.html"
-target="_top">Threads and Swing</a>,
+href="http://docs.oracle.com/javase/tutorial/uiswing/concurrency/index.html"
+target="_top">Concurrency in Swing</a>,
 a section in
-<em><a href="http://java.sun.com/docs/books/tutorial/"
+<em><a href="http://docs.oracle.com/javase/tutorial/"
 target="_top">The Java Tutorial</a></em>.
 
 
@@ -49,7 +49,7 @@
 This document forms the complete API specification.  For overviews, tutorials,
 examples, guides, and tool documentation, please see:
 <ul>
-  <li><a href="http://java.sun.com/docs/books/tutorial/uiswing/components/filechooser.html" target="_top">How to Use File Choosers</a>,
+  <li><a href="http://docs.oracle.com/javase/tutorial/uiswing/components/filechooser.html" target="_top">How to Use File Choosers</a>,
       a section in <em>The Java Tutorial</em>
   <li><a href="../../../../technotes/guides/intl/index.html"
       target="_top">Internationalization Documentation</a>
--- a/jdk/src/java.desktop/share/classes/javax/swing/package.html	Thu May 19 17:48:02 2016 +0000
+++ b/jdk/src/java.desktop/share/classes/javax/swing/package.html	Thu May 19 19:46:20 2016 +0000
@@ -38,7 +38,7 @@
 (all-Java language) components that,
 to the maximum degree possible, work the same on all platforms.
 For a programmer's guide to using these components, see
-<a href="http://java.sun.com/docs/books/tutorial/uiswing/index.html" 
+<a href="http://docs.oracle.com/javase/tutorial/uiswing/index.html"
 target="_top">Creating
 a GUI with JFC/Swing</a>, a trail in <em>The Java Tutorial</em>.
 For other resources, see 
@@ -123,9 +123,9 @@
 processing when working with Swing.
 <p>
 More information on this topic can be found in the
-<a href="http://download.oracle.com/javase/tutorial/uiswing/">Swing tutorial</a>,
+<a href="http://docs.oracle.com/javase/tutorial/uiswing/">Swing tutorial</a>,
 in particular the section on
-<a href="http://download.oracle.com/javase/tutorial/uiswing/concurrency/index.html">Concurrency in Swing</a>.
+<a href="http://docs.oracle.com/javase/tutorial/uiswing/concurrency/index.html">Concurrency in Swing</a>.
 
 
 <H2>
@@ -134,13 +134,13 @@
 <P>For overviews, tutorials, examples, guides, and other documentation, please see:
 
 <UL>
-   <LI><A HREF="http://java.sun.com/products/jfc/tsc/" 
+   <LI><A HREF="http://www.oracle.com/technetwork/java/javase/tech/articles-jsp-139072.html"
    target="_top">The Swing Connection</A>
-   <LI><A HREF="http://java.sun.com/docs/books/tutorial/" 
+   <LI><A HREF="http://docs.oracle.com/javase/tutorial/"
    target="_top">The Java Tutorial</A>
-   <LI><A HREF="http://java.sun.com/developer/onlineTraining/" 
+   <LI><A HREF="http://www.oracle.com/technetwork/java/javase/training/index.html"
    target="_top">Online Training</A> at the Java Developer Connection<font size=-2><sup>SM</sup></font>
-   <LI><A HREF="http://java.sun.com/products/jfc/" 
+   <LI><A HREF="http://www.oracle.com/technetwork/java/javase/tech/index-jsp-142216.html"
    target="_top">Java Foundation Classes (JFC)</A> home page
 </UL>
 
--- a/jdk/src/java.desktop/share/classes/javax/swing/plaf/basic/BasicSpinnerUI.java	Thu May 19 17:48:02 2016 +0000
+++ b/jdk/src/java.desktop/share/classes/javax/swing/plaf/basic/BasicSpinnerUI.java	Thu May 19 19:46:20 2016 +0000
@@ -210,6 +210,16 @@
         LookAndFeel.installBorder(spinner, "Spinner.border");
         LookAndFeel.installColorsAndFont(spinner, "Spinner.background", "Spinner.foreground", "Spinner.font");
         LookAndFeel.installProperty(spinner, "opaque", Boolean.TRUE);
+
+        JComponent editor = spinner.getEditor();
+        if (editor instanceof JSpinner.DefaultEditor) {
+            JTextField tf = ((JSpinner.DefaultEditor) editor).getTextField();
+            if (tf != null) {
+                if (tf.getFont() instanceof UIResource) {
+                    tf.setFont(new FontUIResource(spinner.getFont()));
+                }
+            }
+        }
     }
 
 
--- a/jdk/src/java.desktop/share/classes/javax/swing/plaf/basic/package.html	Thu May 19 17:48:02 2016 +0000
+++ b/jdk/src/java.desktop/share/classes/javax/swing/plaf/basic/package.html	Thu May 19 19:46:20 2016 +0000
@@ -55,10 +55,10 @@
 Most of the Swing API is <em>not</em> thread safe.
 For details, see
 <a
-href="http://java.sun.com/docs/books/tutorial/uiswing/overview/threads.html"
-target="_top">Threads and Swing</a>,
+href="http://docs.oracle.com/javase/tutorial/uiswing/concurrency/index.html"
+target="_top">Concurrency in Swing</a>,
 a section in
-<em><a href="http://java.sun.com/docs/books/tutorial/"
+<em><a href="http://docs.oracle.com/javase/tutorial/"
 target="_top">The Java Tutorial</a></em>.
 
 @since 1.2
--- a/jdk/src/java.desktop/share/classes/javax/swing/plaf/metal/package.html	Thu May 19 17:48:02 2016 +0000
+++ b/jdk/src/java.desktop/share/classes/javax/swing/plaf/metal/package.html	Thu May 19 19:46:20 2016 +0000
@@ -51,10 +51,10 @@
 Most of the Swing API is <em>not</em> thread safe.
 For details, see
 <a
-href="http://java.sun.com/docs/books/tutorial/uiswing/overview/threads.html"
-target="_top">Threads and Swing</a>,
+href="http://docs.oracle.com/javase/tutorial/uiswing/concurrency/index.html"
+target="_top">Concurrency in Swing</a>,
 a section in
-<em><a href="http://java.sun.com/docs/books/tutorial/"
+<em><a href="http://docs.oracle.com/javase/tutorial/"
 target="_top">The Java Tutorial</a></em>.
 
 @since 1.2
--- a/jdk/src/java.desktop/share/classes/javax/swing/plaf/multi/doc-files/multi_tsc.html	Thu May 19 17:48:02 2016 +0000
+++ b/jdk/src/java.desktop/share/classes/javax/swing/plaf/multi/doc-files/multi_tsc.html	Thu May 19 19:46:20 2016 +0000
@@ -18,7 +18,7 @@
 <i>
 This document is based on an article
 originally published in
-<a href="http://java.sun.com/products/jfc/tsc/" target="_top"><em>The Swing
+<a href="http://www.oracle.com/technetwork/java/javase/tech/articles-jsp-139072.html" target="_top"><em>The Swing
 Connection</em></a>.
 </i>
 </p>
@@ -65,12 +65,12 @@
 Before reading further, you should be familiar 
 with the concept of pluggable look and feels.
 For basic information, see
-<a href="http://java.sun.com/docs/books/tutorial/uiswing/lookandfeel/plaf.html">How to Set the Look and Feel</a>,
+<a href="https://docs.oracle.com/javase/tutorial/uiswing/lookandfeel/plaf.html">How to Set the Look and Feel</a>,
 a section in 
 <em>The Java Tutorial</em>.
 For architectural details, you can read
 <a
-href="http://java.sun.com/products/jfc/tsc/articles/architecture/#pluggable">Pluggable look-and-feel architecture</a>, a section within
+href="http://www.oracle.com/technetwork/java/architecture-142923.html#pluggable">Pluggable look-and-feel architecture</a>, a section within
 a <em>Swing Connection</em> article.
 </p>
 
--- a/jdk/src/java.desktop/share/classes/javax/swing/plaf/multi/package.html	Thu May 19 17:48:02 2016 +0000
+++ b/jdk/src/java.desktop/share/classes/javax/swing/plaf/multi/package.html	Thu May 19 19:46:20 2016 +0000
@@ -53,10 +53,10 @@
 Most of the Swing API is <em>not</em> thread safe.
 For details, see
 <a
-href="http://java.sun.com/docs/books/tutorial/uiswing/overview/threads.html"
-target="_top">Threads and Swing</a>,
+href="http://docs.oracle.com/javase/tutorial/uiswing/concurrency/index.html"
+target="_top">Concurrency in Swing</a>,
 a section in
-<em><a href="http://java.sun.com/docs/books/tutorial/"
+<em><a href="http://docs.oracle.com/javase/tutorial/"
 target="_top">The Java Tutorial</a></em>.
 
 @since 1.2
--- a/jdk/src/java.desktop/share/classes/javax/swing/plaf/nimbus/package.html	Thu May 19 17:48:02 2016 +0000
+++ b/jdk/src/java.desktop/share/classes/javax/swing/plaf/nimbus/package.html	Thu May 19 19:46:20 2016 +0000
@@ -88,10 +88,10 @@
 <p><strong>Note:</strong>
 Most of the Swing API is <em>not</em> thread safe.
 For details, see
-<a href="http://java.sun.com/docs/books/tutorial/uiswing/concurrency/index.html"
+<a href="http://docs.oracle.com/javase/tutorial/uiswing/concurrency/index.html"
    target="_top">Concurrency in Swing</a>,
 a section in
-<em><a href="http://java.sun.com/docs/books/tutorial/"
+<em><a href="http://docs.oracle.com/javase/tutorial/"
        target="_top">The Java Tutorial</a></em>.
 
 @since 1.7
--- a/jdk/src/java.desktop/share/classes/javax/swing/plaf/package.html	Thu May 19 17:48:02 2016 +0000
+++ b/jdk/src/java.desktop/share/classes/javax/swing/plaf/package.html	Thu May 19 19:46:20 2016 +0000
@@ -44,10 +44,10 @@
 Most of the Swing API is <em>not</em> thread safe.
 For details, see
 <a
-href="http://java.sun.com/docs/books/tutorial/uiswing/overview/threads.html"
-target="_top">Threads and Swing</a>,
+href="http://docs.oracle.com/javase/tutorial/uiswing/concurrency/index.html"
+target="_top">Concurrency in Swing</a>,
 a section in
-<em><a href="http://java.sun.com/docs/books/tutorial/"
+<em><a href="http://docs.oracle.com/javase/tutorial/"
 target="_top">The Java Tutorial</a></em>.
 
 @since 1.2
--- a/jdk/src/java.desktop/share/classes/javax/swing/plaf/synth/doc-files/synthFileFormat.html	Thu May 19 17:48:02 2016 +0000
+++ b/jdk/src/java.desktop/share/classes/javax/swing/plaf/synth/doc-files/synthFileFormat.html	Thu May 19 19:46:20 2016 +0000
@@ -950,7 +950,7 @@
       Beans persistance can be used to embed any Object. This is
       typically used for embedding your own Painters, but can be used
       for other arbritrary objects as well. Refer to <a
-							href="http://java.sun.com/products/jfc/tsc/articles/persistence3/">http://java.sun.com/products/jfc/tsc/articles/persistence3/</a> for details on beans persistance.
+							href="http://www.oracle.com/technetwork/java/persistence3-139471.html">http://www.oracle.com/technetwork/java/persistence3-139471.html</a> for details on beans persistance.
 
 
     <h3>Backing Style</h3>
--- a/jdk/src/java.desktop/share/classes/javax/swing/table/package.html	Thu May 19 17:48:02 2016 +0000
+++ b/jdk/src/java.desktop/share/classes/javax/swing/table/package.html	Thu May 19 19:46:20 2016 +0000
@@ -43,10 +43,10 @@
 Most of the Swing API is <em>not</em> thread safe.
 For details, see
 <a
-href="http://java.sun.com/docs/books/tutorial/uiswing/overview/threads.html"
-target="_top">Threads and Swing</a>,
+href="http://docs.oracle.com/javase/tutorial/uiswing/concurrency/index.html"
+target="_top">Concurrency in Swing</a>,
 a section in
-<em><a href="http://java.sun.com/docs/books/tutorial/"
+<em><a href="http://docs.oracle.com/javase/tutorial/"
 target="_top">The Java Tutorial</a></em>.
 
 
@@ -54,7 +54,7 @@
 
 For overviews, tutorials, examples, guides, and tool documentation, please see:
 <ul>
-  <li><a href="http://java.sun.com/docs/books/tutorial/uiswing/components/table.html" target="_top">How to Use Tables</a>,
+  <li><a href="http://docs.oracle.com/javase/tutorial/uiswing/components/table.html" target="_top">How to Use Tables</a>,
       a section in <em>The Java Tutorial</em>
 </ul>
 
--- a/jdk/src/java.desktop/share/classes/javax/swing/text/Document.java	Thu May 19 17:48:02 2016 +0000
+++ b/jdk/src/java.desktop/share/classes/javax/swing/text/Document.java	Thu May 19 19:46:20 2016 +0000
@@ -166,7 +166,7 @@
  * </ul>
  *
  * <p>For more information on the <code>Document</code> class, see
- * <a href="http://java.sun.com/products/jfc/tsc">The Swing Connection</a>
+ * <a href="http://www.oracle.com/technetwork/java/javase/tech/articles-jsp-139072.html">The Swing Connection</a>
  * and most particularly the article,
  * <a href="http://java.sun.com/products/jfc/tsc/articles/text/element_interface">
  * The Element Interface</a>.
--- a/jdk/src/java.desktop/share/classes/javax/swing/text/html/package.html	Thu May 19 17:48:02 2016 +0000
+++ b/jdk/src/java.desktop/share/classes/javax/swing/text/html/package.html	Thu May 19 19:46:20 2016 +0000
@@ -37,10 +37,10 @@
 Most of the Swing API is <em>not</em> thread safe.
 For details, see
 <a
-href="http://java.sun.com/docs/books/tutorial/uiswing/overview/threads.html"
-target="_top">Threads and Swing</a>,
+href="http://docs.oracle.com/javase/tutorial/uiswing/concurrency/index.html"
+target="_top">Concurrency in Swing</a>,
 a section in
-<em><a href="http://java.sun.com/docs/books/tutorial/"
+<em><a href="http://docs.oracle.com/javase/tutorial/"
 target="_top">The Java Tutorial</a></em>.
 
 <h2>Package Specification</h2>
--- a/jdk/src/java.desktop/share/classes/javax/swing/text/html/parser/package.html	Thu May 19 17:48:02 2016 +0000
+++ b/jdk/src/java.desktop/share/classes/javax/swing/text/html/parser/package.html	Thu May 19 19:46:20 2016 +0000
@@ -40,10 +40,10 @@
 Most of the Swing API is <em>not</em> thread safe.
 For details, see
 <a
-href="http://java.sun.com/docs/books/tutorial/uiswing/overview/threads.html"
-target="_top">Threads and Swing</a>,
+href="http://docs.oracle.com/javase/tutorial/uiswing/concurrency/index.html"
+target="_top">Concurrency in Swing</a>,
 a section in
-<em><a href="http://java.sun.com/docs/books/tutorial/"
+<em><a href="http://docs.oracle.com/javase/tutorial/"
 target="_top">The Java Tutorial</a></em>.
 
 @see javax.swing.text.html.HTMLEditorKit.ParserCallback
--- a/jdk/src/java.desktop/share/classes/javax/swing/text/package.html	Thu May 19 17:48:02 2016 +0000
+++ b/jdk/src/java.desktop/share/classes/javax/swing/text/package.html	Thu May 19 19:46:20 2016 +0000
@@ -41,17 +41,17 @@
 Most of the Swing API is <em>not</em> thread safe.
 For details, see
 <a
-href="http://java.sun.com/docs/books/tutorial/uiswing/overview/threads.html"
-target="_top">Threads and Swing</a>,
+href="http://docs.oracle.com/javase/tutorial/uiswing/concurrency/index.html"
+target="_top">Concurrency in Swing</a>,
 a section in
-<em><a href="http://java.sun.com/docs/books/tutorial/"
+<em><a href="http://docs.oracle.com/javase/tutorial/"
 target="_top">The Java Tutorial</a></em>.
 
 <h2>Related Documentation</h2>
 
 For overviews, tutorials, examples, guides, and tool documentation, please see:
 <ul>
-  <li><a href="http://java.sun.com/docs/books/tutorial/uiswing/components/text.html" target="_top">Using Text Components</a>,
+  <li><a href="http://docs.oracle.com/javase/tutorial/uiswing/components/text.html" target="_top">Using Text Components</a>,
       a section in <em>The Java Tutorial</em>
 </ul>
 
--- a/jdk/src/java.desktop/share/classes/javax/swing/text/rtf/package.html	Thu May 19 17:48:02 2016 +0000
+++ b/jdk/src/java.desktop/share/classes/javax/swing/text/rtf/package.html	Thu May 19 19:46:20 2016 +0000
@@ -38,10 +38,10 @@
 Most of the Swing API is <em>not</em> thread safe.
 For details, see
 <a
-href="http://java.sun.com/docs/books/tutorial/uiswing/overview/threads.html"
-target="_top">Threads and Swing</a>,
+href="http://docs.oracle.com/javase/tutorial/uiswing/concurrency/index.html"
+target="_top">Concurrency in Swing</a>,
 a section in
-<em><a href="http://java.sun.com/docs/books/tutorial/"
+<em><a href="http://docs.oracle.com/javase/tutorial/"
 target="_top">The Java Tutorial</a></em>.
 
 @since 1.2
--- a/jdk/src/java.desktop/share/classes/javax/swing/tree/package.html	Thu May 19 17:48:02 2016 +0000
+++ b/jdk/src/java.desktop/share/classes/javax/swing/tree/package.html	Thu May 19 19:46:20 2016 +0000
@@ -39,10 +39,10 @@
 Most of the Swing API is <em>not</em> thread safe.
 For details, see
 <a
-href="http://java.sun.com/docs/books/tutorial/uiswing/overview/threads.html"
-target="_top">Threads and Swing</a>,
+href="http://docs.oracle.com/javase/tutorial/uiswing/concurrency/index.html"
+target="_top">Concurrency in Swing</a>,
 a section in
-<em><a href="http://java.sun.com/docs/books/tutorial/"
+<em><a href="http://docs.oracle.com/javase/tutorial/"
 target="_top">The Java Tutorial</a></em>.
 
 
@@ -50,7 +50,7 @@
 
 For overviews, tutorials, examples, guides, and tool documentation, please see:
 <ul>
-  <li><a href="http://java.sun.com/docs/books/tutorial/uiswing/components/tree.html" target="_top">How to Use Trees</a>,
+  <li><a href="http://docs.oracle.com/javase/tutorial/uiswing/components/tree.html" target="_top">How to Use Trees</a>,
       a section in <em>The Java Tutorial</em>
 </ul>
 
--- a/jdk/src/java.desktop/share/classes/javax/swing/undo/package.html	Thu May 19 17:48:02 2016 +0000
+++ b/jdk/src/java.desktop/share/classes/javax/swing/undo/package.html	Thu May 19 19:46:20 2016 +0000
@@ -37,17 +37,17 @@
 Most of the Swing API is <em>not</em> thread safe.
 For details, see
 <a
-href="http://java.sun.com/docs/books/tutorial/uiswing/overview/threads.html"
-target="_top">Threads and Swing</a>,
+href="http://docs.oracle.com/javase/tutorial/uiswing/concurrency/index.html"
+target="_top">Concurrency in Swing</a>,
 a section in
-<em><a href="http://java.sun.com/docs/books/tutorial/"
+<em><a href="http://docs.oracle.com/javase/tutorial/"
 target="_top">The Java Tutorial</a></em>.
 
 <h2>Related Documentation</h2>
 
 For overviews, tutorials, examples, guides, and tool documentation, please see:
 <ul>
-  <li><a href="http://java.sun.com/docs/books/tutorial/uiswing/components/generaltext.html#undo" target="_top">Implementing Undo and Redo</a>,
+  <li><a href="http://docs.oracle.com/javase/tutorial/uiswing/components/generaltext.html#undo" target="_top">Implementing Undo and Redo</a>,
       a section in <em>The Java Tutorial</em>
 </ul>
 
--- a/jdk/src/java.desktop/share/classes/module-info.java	Thu May 19 17:48:02 2016 +0000
+++ b/jdk/src/java.desktop/share/classes/module-info.java	Thu May 19 19:46:20 2016 +0000
@@ -27,8 +27,6 @@
     requires public java.datatransfer;
     requires public java.xml;
     requires java.prefs;
-    // 8147544
-    requires jdk.unsupported;
 
     exports java.applet;
     exports java.awt;
--- a/jdk/src/java.desktop/share/classes/sun/applet/Main.java	Thu May 19 17:48:02 2016 +0000
+++ b/jdk/src/java.desktop/share/classes/sun/applet/Main.java	Thu May 19 19:46:20 2016 +0000
@@ -104,7 +104,8 @@
     private int run(String [] args) {
         // DECODE ARGS
         try {
-            System.out.println(lookup("deprecated"));
+            System.err.println(lookup("deprecated"));
+            System.err.flush();
             if (args.length == 0) {
                 usage();
                 return 0;
--- a/jdk/src/java.desktop/share/classes/sun/applet/resources/MsgAppletViewer.java	Thu May 19 17:48:02 2016 +0000
+++ b/jdk/src/java.desktop/share/classes/sun/applet/resources/MsgAppletViewer.java	Thu May 19 19:46:20 2016 +0000
@@ -73,7 +73,7 @@
             {"appletviewer.parse.warning.embed.requiresheight", "Warning: <embed> tag requires height attribute."},
             {"appletviewer.parse.warning.embed.requireswidth", "Warning: <embed> tag requires width attribute."},
             {"appletviewer.parse.warning.appnotLongersupported", "Warning: <app> tag no longer supported, use <applet> instead:"},
-            {"appletviewer.deprecated", "AppletViewer is deprecated."},
+            {"appletviewer.deprecated", "Warning: Applet API and AppletViewer are deprecated."},
             {"appletviewer.usage", "Usage: appletviewer <options> url(s)\n\nwhere <options> include:\n  -encoding <encoding>    Specify character encoding used by HTML files\n  -J<runtime flag>        Pass argument to the java interpreter\n\nThe -J option is non-standard and subject to change without notice."},
             {"appletviewer.main.err.unsupportedopt", "Unsupported option: {0}"},
             {"appletviewer.main.err.unrecognizedarg", "Unrecognized argument: {0}"},
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/jdk/src/java.desktop/share/classes/sun/awt/SoftCache.java	Thu May 19 19:46:20 2016 +0000
@@ -0,0 +1,462 @@
+/*
+ * Copyright (c) 1998, 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 sun.awt;
+
+import java.lang.ref.SoftReference;
+import java.lang.ref.ReferenceQueue;
+
+import java.util.Iterator;
+import java.util.Map;
+import java.util.AbstractMap;
+import java.util.HashMap;
+import java.util.Set;
+import java.util.AbstractSet;
+import java.util.NoSuchElementException;
+
+
+/**
+ * A memory-sensitive implementation of the <code>Map</code> interface.
+ *
+ * <p> A <code>SoftCache</code> object uses {@link java.lang.ref.SoftReference
+ * soft references} to implement a memory-sensitive hash map.  If the garbage
+ * collector determines at a certain point in time that a value object in a
+ * <code>SoftCache</code> entry is no longer strongly reachable, then it may
+ * remove that entry in order to release the memory occupied by the value
+ * object.  All <code>SoftCache</code> objects are guaranteed to be completely
+ * cleared before the virtual machine will throw an
+ * <code>OutOfMemoryError</code>.  Because of this automatic clearing feature,
+ * the behavior of this class is somewhat different from that of other
+ * <code>Map</code> implementations.
+ *
+ * <p> Both null values and the null key are supported.  This class has the
+ * same performance characteristics as the <code>HashMap</code> class, and has
+ * the same efficiency parameters of <em>initial capacity</em> and <em>load
+ * factor</em>.
+ *
+ * <p> Like most collection classes, this class is not synchronized.  A
+ * synchronized <code>SoftCache</code> may be constructed using the
+ * <code>Collections.synchronizedMap</code> method.
+ *
+ * <p> In typical usage this class will be subclassed and the <code>fill</code>
+ * method will be overridden.  When the <code>get</code> method is invoked on a
+ * key for which there is no mapping in the cache, it will in turn invoke the
+ * <code>fill</code> method on that key in an attempt to construct a
+ * corresponding value.  If the <code>fill</code> method returns such a value
+ * then the cache will be updated and the new value will be returned.  Thus,
+ * for example, a simple URL-content cache can be constructed as follows:
+ *
+ * <pre>
+ *     public class URLCache extends SoftCache {
+ *         protected Object fill(Object key) {
+ *             return ((URL)key).getContent();
+ *         }
+ *     }
+ * </pre>
+ *
+ * <p> The behavior of the <code>SoftCache</code> class depends in part upon
+ * the actions of the garbage collector, so several familiar (though not
+ * required) <code>Map</code> invariants do not hold for this class.  <p>
+ * Because entries are removed from a <code>SoftCache</code> in response to
+ * dynamic advice from the garbage collector, a <code>SoftCache</code> may
+ * behave as though an unknown thread is silently removing entries.  In
+ * particular, even if you synchronize on a <code>SoftCache</code> instance and
+ * invoke none of its mutator methods, it is possible for the <code>size</code>
+ * method to return smaller values over time, for the <code>isEmpty</code>
+ * method to return <code>false</code> and then <code>true</code>, for the
+ * <code>containsKey</code> method to return <code>true</code> and later
+ * <code>false</code> for a given key, for the <code>get</code> method to
+ * return a value for a given key but later return <code>null</code>, for the
+ * <code>put</code> method to return <code>null</code> and the
+ * <code>remove</code> method to return <code>false</code> for a key that
+ * previously appeared to be in the map, and for successive examinations of the
+ * key set, the value set, and the entry set to yield successively smaller
+ * numbers of elements.
+ *
+ * @author      Mark Reinhold
+ * @since       1.2
+ * @see         java.util.HashMap
+ * @see         java.lang.ref.SoftReference
+ * @deprecated No direct replacement; {@link java.util.WeakHashMap}
+ * addresses a related by different use-case.
+ */
+
+@Deprecated
+public class SoftCache extends AbstractMap<Object, Object> implements Map<Object, Object> {
+
+    /* The basic idea of this implementation is to maintain an internal HashMap
+       that maps keys to soft references whose referents are the keys' values;
+       the various accessor methods dereference these soft references before
+       returning values.  Because we don't have access to the innards of the
+       HashMap, each soft reference must contain the key that maps to it so
+       that the processQueue method can remove keys whose values have been
+       discarded.  Thus the HashMap actually maps keys to instances of the
+       ValueCell class, which is a simple extension of the SoftReference class.
+     */
+
+
+    private static class ValueCell extends SoftReference<Object> {
+        private static Object INVALID_KEY = new Object();
+        private static int dropped = 0;
+        private Object key;
+
+        private ValueCell(Object key, Object value, ReferenceQueue<Object> queue) {
+            super(value, queue);
+            this.key = key;
+        }
+
+        private static ValueCell create(Object key, Object value,
+                                        ReferenceQueue<Object> queue)
+        {
+            if (value == null) return null;
+            return new ValueCell(key, value, queue);
+        }
+
+        private static Object strip(Object val, boolean drop) {
+            if (val == null) return null;
+            ValueCell vc = (ValueCell)val;
+            Object o = vc.get();
+            if (drop) vc.drop();
+            return o;
+        }
+
+        private boolean isValid() {
+            return (key != INVALID_KEY);
+        }
+
+        private void drop() {
+            super.clear();
+            key = INVALID_KEY;
+            dropped++;
+        }
+
+    }
+
+
+    /* Hash table mapping keys to ValueCells */
+    private Map<Object, Object> hash;
+
+    /* Reference queue for cleared ValueCells */
+    private ReferenceQueue<Object> queue = new ReferenceQueue<>();
+
+
+    /* Process any ValueCells that have been cleared and enqueued by the
+       garbage collector.  This method should be invoked once by each public
+       mutator in this class.  We don't invoke this method in public accessors
+       because that can lead to surprising ConcurrentModificationExceptions.
+     */
+    private void processQueue() {
+        ValueCell vc;
+        while ((vc = (ValueCell)queue.poll()) != null) {
+            if (vc.isValid()) hash.remove(vc.key);
+            else ValueCell.dropped--;
+        }
+    }
+
+
+    /* -- Constructors -- */
+
+    /**
+     * Construct a new, empty <code>SoftCache</code> with the given
+     * initial capacity and the given load factor.
+     *
+     * @param  initialCapacity  The initial capacity of the cache
+     *
+     * @param  loadFactor       A number between 0.0 and 1.0
+     *
+     * @throws IllegalArgumentException  If the initial capacity is less than
+     *                                   or equal to zero, or if the load
+     *                                   factor is less than zero
+     */
+    public SoftCache(int initialCapacity, float loadFactor) {
+        hash = new HashMap<>(initialCapacity, loadFactor);
+    }
+
+    /**
+     * Construct a new, empty <code>SoftCache</code> with the given
+     * initial capacity and the default load factor.
+     *
+     * @param  initialCapacity  The initial capacity of the cache
+     *
+     * @throws IllegalArgumentException  If the initial capacity is less than
+     *                                   or equal to zero
+     */
+    public SoftCache(int initialCapacity) {
+        hash = new HashMap<>(initialCapacity);
+    }
+
+    /**
+     * Construct a new, empty <code>SoftCache</code> with the default
+     * capacity and the default load factor.
+     */
+    public SoftCache() {
+        hash = new HashMap<>();
+    }
+
+
+    /* -- Simple queries -- */
+
+    /**
+     * Return the number of key-value mappings in this cache.  The time
+     * required by this operation is linear in the size of the map.
+     */
+    public int size() {
+        return entrySet().size();
+    }
+
+    /**
+     * Return <code>true</code> if this cache contains no key-value mappings.
+     */
+    public boolean isEmpty() {
+        return entrySet().isEmpty();
+    }
+
+    /**
+     * Return <code>true</code> if this cache contains a mapping for the
+     * specified key.  If there is no mapping for the key, this method will not
+     * attempt to construct one by invoking the <code>fill</code> method.
+     *
+     * @param   key   The key whose presence in the cache is to be tested
+     */
+    public boolean containsKey(Object key) {
+        return ValueCell.strip(hash.get(key), false) != null;
+    }
+
+
+    /* -- Lookup and modification operations -- */
+
+    /**
+     * Create a value object for the given <code>key</code>.  This method is
+     * invoked by the <code>get</code> method when there is no entry for
+     * <code>key</code>.  If this method returns a non-<code>null</code> value,
+     * then the cache will be updated to map <code>key</code> to that value,
+     * and that value will be returned by the <code>get</code> method.
+     *
+     * <p> The default implementation of this method simply returns
+     * <code>null</code> for every <code>key</code> value.  A subclass may
+     * override this method to provide more useful behavior.
+     *
+     * @param  key  The key for which a value is to be computed
+     *
+     * @return      A value for <code>key</code>, or <code>null</code> if one
+     *              could not be computed
+     * @see #get
+     */
+    protected Object fill(Object key) {
+        return null;
+    }
+
+    /**
+     * Return the value to which this cache maps the specified
+     * <code>key</code>.  If the cache does not presently contain a value for
+     * this key, then invoke the <code>fill</code> method in an attempt to
+     * compute such a value.  If that method returns a non-<code>null</code>
+     * value, then update the cache and return the new value.  Otherwise,
+     * return <code>null</code>.
+     *
+     * <p> Note that because this method may update the cache, it is considered
+     * a mutator and may cause <code>ConcurrentModificationException</code>s to
+     * be thrown if invoked while an iterator is in use.
+     *
+     * @param  key  The key whose associated value, if any, is to be returned
+     *
+     * @see #fill
+     */
+    public Object get(Object key) {
+        processQueue();
+        Object v = hash.get(key);
+        if (v == null) {
+            v = fill(key);
+            if (v != null) {
+                hash.put(key, ValueCell.create(key, v, queue));
+                return v;
+            }
+        }
+        return ValueCell.strip(v, false);
+    }
+
+    /**
+     * Update this cache so that the given <code>key</code> maps to the given
+     * <code>value</code>.  If the cache previously contained a mapping for
+     * <code>key</code> then that mapping is replaced and the old value is
+     * returned.
+     *
+     * @param  key    The key that is to be mapped to the given
+     *                <code>value</code>
+     * @param  value  The value to which the given <code>key</code> is to be
+     *                mapped
+     *
+     * @return  The previous value to which this key was mapped, or
+     *          <code>null</code> if there was no mapping for the key
+     */
+    public Object put(Object key, Object value) {
+        processQueue();
+        ValueCell vc = ValueCell.create(key, value, queue);
+        return ValueCell.strip(hash.put(key, vc), true);
+    }
+
+    /**
+     * Remove the mapping for the given <code>key</code> from this cache, if
+     * present.
+     *
+     * @param  key  The key whose mapping is to be removed
+     *
+     * @return  The value to which this key was mapped, or <code>null</code> if
+     *          there was no mapping for the key
+     */
+    public Object remove(Object key) {
+        processQueue();
+        return ValueCell.strip(hash.remove(key), true);
+    }
+
+    /**
+     * Remove all mappings from this cache.
+     */
+    public void clear() {
+        processQueue();
+        hash.clear();
+    }
+
+
+    /* -- Views -- */
+
+    private static boolean valEquals(Object o1, Object o2) {
+        return (o1 == null) ? (o2 == null) : o1.equals(o2);
+    }
+
+
+    /* Internal class for entries.
+       Because it uses SoftCache.this.queue, this class cannot be static.
+     */
+    private class Entry implements Map.Entry<Object, Object> {
+        private Map.Entry<Object, Object> ent;
+        private Object value;   /* Strong reference to value, to prevent the GC
+                                   from flushing the value while this Entry
+                                   exists */
+
+        Entry(Map.Entry<Object, Object> ent, Object value) {
+            this.ent = ent;
+            this.value = value;
+        }
+
+        public Object getKey() {
+            return ent.getKey();
+        }
+
+        public Object getValue() {
+            return value;
+        }
+
+        public Object setValue(Object value) {
+            return ent.setValue(ValueCell.create(ent.getKey(), value, queue));
+        }
+
+        @SuppressWarnings("unchecked")
+        public boolean equals(Object o) {
+            if (! (o instanceof Map.Entry)) return false;
+            Map.Entry<Object, Object> e = (Map.Entry<Object, Object>)o;
+            return (valEquals(ent.getKey(), e.getKey())
+                    && valEquals(value, e.getValue()));
+        }
+
+        public int hashCode() {
+            Object k;
+            return ((((k = getKey()) == null) ? 0 : k.hashCode())
+                    ^ ((value == null) ? 0 : value.hashCode()));
+        }
+
+    }
+
+
+    /* Internal class for entry sets */
+    private class EntrySet extends AbstractSet<Map.Entry<Object, Object>> {
+        Set<Map.Entry<Object, Object>> hashEntries = hash.entrySet();
+
+        public Iterator<Map.Entry<Object, Object>> iterator() {
+
+            return new Iterator<Map.Entry<Object, Object>>() {
+                Iterator<Map.Entry<Object, Object>> hashIterator = hashEntries.iterator();
+                Entry next = null;
+
+                public boolean hasNext() {
+                    while (hashIterator.hasNext()) {
+                        Map.Entry<Object, Object> ent = hashIterator.next();
+                        ValueCell vc = (ValueCell)ent.getValue();
+                        Object v = null;
+                        if ((vc != null) && ((v = vc.get()) == null)) {
+                            /* Value has been flushed by GC */
+                            continue;
+                        }
+                        next = new Entry(ent, v);
+                        return true;
+                    }
+                    return false;
+                }
+
+                public Map.Entry<Object, Object> next() {
+                    if ((next == null) && !hasNext())
+                        throw new NoSuchElementException();
+                    Entry e = next;
+                    next = null;
+                    return e;
+                }
+
+                public void remove() {
+                    hashIterator.remove();
+                }
+
+            };
+        }
+
+        public boolean isEmpty() {
+            return !(iterator().hasNext());
+        }
+
+        public int size() {
+            int j = 0;
+            for (Iterator<Map.Entry<Object, Object>> i = iterator(); i.hasNext(); i.next()) j++;
+            return j;
+        }
+
+        public boolean remove(Object o) {
+            processQueue();
+            if (o instanceof Entry) return hashEntries.remove(((Entry)o).ent);
+            else return false;
+        }
+
+    }
+
+
+    private Set<Map.Entry<Object, Object>> entrySet = null;
+
+    /**
+     * Return a <code>Set</code> view of the mappings in this cache.
+     */
+    public Set<Map.Entry<Object, Object>> entrySet() {
+        if (entrySet == null) entrySet = new EntrySet();
+        return entrySet;
+    }
+
+}
--- a/jdk/src/java.desktop/share/classes/sun/awt/SunToolkit.java	Thu May 19 17:48:02 2016 +0000
+++ b/jdk/src/java.desktop/share/classes/sun/awt/SunToolkit.java	Thu May 19 19:46:20 2016 +0000
@@ -65,7 +65,6 @@
 import sun.awt.image.ToolkitImage;
 import sun.awt.image.URLImageSource;
 import sun.font.FontDesignMetrics;
-import sun.misc.SoftCache;
 import sun.net.util.URLUtil;
 import sun.security.action.GetBooleanAction;
 import sun.security.action.GetPropertyAction;
--- a/jdk/src/java.desktop/share/classes/sun/awt/image/MultiResolutionToolkitImage.java	Thu May 19 17:48:02 2016 +0000
+++ b/jdk/src/java.desktop/share/classes/sun/awt/image/MultiResolutionToolkitImage.java	Thu May 19 19:46:20 2016 +0000
@@ -29,7 +29,7 @@
 import java.awt.image.MultiResolutionImage;
 import java.util.Arrays;
 import java.util.List;
-import sun.misc.SoftCache;
+import sun.awt.SoftCache;
 
 public class MultiResolutionToolkitImage extends ToolkitImage implements MultiResolutionImage {
 
--- a/jdk/src/java.desktop/share/native/libmlib_image/mlib_ImageAffine.c	Thu May 19 17:48:02 2016 +0000
+++ b/jdk/src/java.desktop/share/native/libmlib_image/mlib_ImageAffine.c	Thu May 19 19:46:20 2016 +0000
@@ -73,7 +73,6 @@
  */
 
 #include "mlib_ImageCheck.h"
-#include "mlib_ImageColormap.h"
 #include "mlib_ImageAffine.h"
 
 
@@ -125,18 +124,6 @@
 };
 
 /***************************************************************/
-const type_affine_i_fun mlib_AffineFunArr_bc_i[] = {
-  mlib_ImageAffineIndex_U8_U8_3CH_BC,
-  mlib_ImageAffineIndex_U8_U8_4CH_BC,
-  mlib_ImageAffineIndex_S16_U8_3CH_BC,
-  mlib_ImageAffineIndex_S16_U8_4CH_BC,
-  mlib_ImageAffineIndex_U8_S16_3CH_BC,
-  mlib_ImageAffineIndex_U8_S16_4CH_BC,
-  mlib_ImageAffineIndex_S16_S16_3CH_BC,
-  mlib_ImageAffineIndex_S16_S16_4CH_BC
-};
-
-/***************************************************************/
 #ifdef i386 /* do not perform the coping by mlib_d64 data type for x86 */
 #define MAX_T_IND  2
 #else
@@ -148,8 +135,7 @@
                                       const mlib_image *src,
                                       const mlib_d64   *mtx,
                                       mlib_filter      filter,
-                                      mlib_edge        edge,
-                                      const void       *colormap)
+                                      mlib_edge        edge)
 {
   mlib_affine_param param[1];
   mlib_status res;
@@ -213,18 +199,6 @@
   else
     return MLIB_FAILURE; /* unknown image type */
 
-  if (colormap != NULL && filter != MLIB_NEAREST) {
-    if (t_ind != 0 && t_ind != 1)
-      return MLIB_FAILURE;
-
-    if (mlib_ImageGetLutType(colormap) == MLIB_SHORT)
-      t_ind += 2;
-    t_ind = 2 * t_ind;
-
-    if (mlib_ImageGetLutChannels(colormap) == 4)
-      t_ind++;
-  }
-
   if (type == MLIB_BIT) {
     mlib_s32 s_bitoff = mlib_ImageGetBitOffset(src);
     mlib_s32 d_bitoff = mlib_ImageGetBitOffset(dst);
@@ -253,25 +227,13 @@
 
       case MLIB_BILINEAR:
 
-        if (colormap != NULL) {
-          res = mlib_AffineFunArr_bl_i[t_ind] (param, colormap);
-        }
-        else {
-          res = mlib_AffineFunArr_bl[4 * t_ind + (nchan - 1)] (param);
-        }
-
+        res = mlib_AffineFunArr_bl[4 * t_ind + (nchan - 1)] (param);
         break;
 
       case MLIB_BICUBIC:
       case MLIB_BICUBIC2:
 
-        if (colormap != NULL) {
-          res = mlib_AffineFunArr_bc_i[t_ind] (param, colormap);
-        }
-        else {
-          res = mlib_AffineFunArr_bc[4 * t_ind + (nchan - 1)] (param);
-        }
-
+        res = mlib_AffineFunArr_bc[4 * t_ind + (nchan - 1)] (param);
         break;
     }
 
@@ -303,7 +265,7 @@
 
     switch (edge) {
       case MLIB_EDGE_DST_FILL_ZERO:
-        mlib_ImageAffineEdgeZero(param, param_e, colormap);
+        mlib_ImageAffineEdgeZero(param, param_e);
         break;
 
       case MLIB_EDGE_OP_NEAREST:
@@ -313,10 +275,10 @@
       case MLIB_EDGE_SRC_EXTEND:
 
         if (filter == MLIB_BILINEAR) {
-          res = mlib_ImageAffineEdgeExtend_BL(param, param_e, colormap);
+          res = mlib_ImageAffineEdgeExtend_BL(param, param_e);
         }
         else {
-          res = mlib_ImageAffineEdgeExtend_BC(param, param_e, colormap);
+          res = mlib_ImageAffineEdgeExtend_BC(param, param_e);
         }
 
         break;
@@ -355,7 +317,7 @@
     return MLIB_FAILURE;
   }
 
-  return mlib_ImageAffine_alltypes(dst, src, mtx, filter, edge, NULL);
+  return mlib_ImageAffine_alltypes(dst, src, mtx, filter, edge);
 }
 
 /***************************************************************/
--- a/jdk/src/java.desktop/share/native/libmlib_image/mlib_ImageAffine.h	Thu May 19 17:48:02 2016 +0000
+++ b/jdk/src/java.desktop/share/native/libmlib_image/mlib_ImageAffine.h	Thu May 19 19:46:20 2016 +0000
@@ -162,99 +162,25 @@
 
 /***************************************************************/
 void mlib_ImageAffineEdgeZero(mlib_affine_param *param,
-                              mlib_affine_param *param_e,
-                              const void        *colormap);
+                              mlib_affine_param *param_e);
 
 void mlib_ImageAffineEdgeNearest(mlib_affine_param *param,
                                  mlib_affine_param *param_e);
 
 mlib_status mlib_ImageAffineEdgeExtend_BL(mlib_affine_param *param,
-                                          mlib_affine_param *param_e,
-                                          const void        *colormap);
+                                          mlib_affine_param *param_e);
 
 mlib_status mlib_ImageAffineEdgeExtend_BC(mlib_affine_param *param,
-                                          mlib_affine_param *param_e,
-                                          const void        *colormap);
-
-mlib_status mlib_ImageAffineEdgeExtend_BC2(mlib_affine_param *param,
-                                           mlib_affine_param *param_e,
-                                           const void        *colormap);
-
-/***************************************************************/
-typedef mlib_status (*type_affine_i_fun)(mlib_affine_param *param, const void *colormap);
-
-mlib_status mlib_ImageAffine_u8_u8_i_bl(mlib_affine_param *param,
-                                        const void        *colormap);
-mlib_status mlib_ImageAffine_u8_s16_i_bl(mlib_affine_param *param,
-                                         const void        *colormap);
-mlib_status mlib_ImageAffine_s16_u8_i_bl(mlib_affine_param *param,
-                                         const void        *colormap);
-mlib_status mlib_ImageAffine_s16_s16_i_bl(mlib_affine_param *param,
-                                          const void        *colormap);
-
-mlib_status mlib_ImageAffine_u8_u8_i_bc(mlib_affine_param *param,
-                                        const void        *colormap);
-mlib_status mlib_ImageAffine_u8_s16_i_bc(mlib_affine_param *param,
-                                         const void        *colormap);
-mlib_status mlib_ImageAffine_s16_u8_i_bc(mlib_affine_param *param,
-                                         const void        *colormap);
-mlib_status mlib_ImageAffine_s16_s16_i_bc(mlib_affine_param *param,
-                                          const void        *colormap);
-
-void mlib_ImageAffineEdgeZeroIndex(mlib_affine_param *param,
-                                   mlib_affine_param *param_e,
-                                   const void        *colormap);
-
-void mlib_ImageAffineEdgeExtendIndex_BL(mlib_affine_param *param,
-                                        mlib_affine_param *param_e,
-                                        const void        *colormap);
-
-void mlib_ImageAffineEdgeExtendIndex_BC(mlib_affine_param *param,
-                                        mlib_affine_param *param_e,
-                                        const void        *colormap);
-
-void mlib_ImageAffineEdgeExtendIndex_BC2(mlib_affine_param *param,
-                                         mlib_affine_param *param_e,
-                                         const void        *colormap);
-
-/***************************************************************/
-#define PROT_AFFINEINDEX_BC(ITYPE, LTYPE, NCHAN)                                                 \
-  mlib_status mlib_ImageAffineIndex_##ITYPE##_##LTYPE##_##NCHAN##CH_BC(mlib_affine_param *param, \
-                                                                       const void        *colormap)
-
-PROT_AFFINEINDEX_BC(U8, U8, 3);
-PROT_AFFINEINDEX_BC(U8, S16, 3);
-PROT_AFFINEINDEX_BC(U8, U8, 4);
-PROT_AFFINEINDEX_BC(U8, S16, 4);
-PROT_AFFINEINDEX_BC(S16, U8, 3);
-PROT_AFFINEINDEX_BC(S16, S16, 3);
-PROT_AFFINEINDEX_BC(S16, U8, 4);
-PROT_AFFINEINDEX_BC(S16, S16, 4);
-
-/***************************************************************/
-#define PROT_AFFINEINDEX_BL(ITYPE, LTYPE, NCHAN)                                                 \
-  mlib_status mlib_ImageAffineIndex_##ITYPE##_##LTYPE##_##NCHAN##CH_BL(mlib_affine_param *param, \
-                                                                       const void        *colormap)
-
-PROT_AFFINEINDEX_BL(U8, U8, 3);
-PROT_AFFINEINDEX_BL(U8, S16, 3);
-PROT_AFFINEINDEX_BL(U8, U8, 4);
-PROT_AFFINEINDEX_BL(U8, S16, 4);
-PROT_AFFINEINDEX_BL(S16, U8, 3);
-PROT_AFFINEINDEX_BL(S16, S16, 3);
-PROT_AFFINEINDEX_BL(S16, U8, 4);
-PROT_AFFINEINDEX_BL(S16, S16, 4);
+                                          mlib_affine_param *param_e);
 
 /***************************************************************/
 mlib_status mlib_ImageAffine_alltypes(mlib_image       *dst,
                                       const mlib_image *src,
                                       const mlib_d64   *mtx,
                                       mlib_filter      filter,
-                                      mlib_edge        edge,
-                                      const void       *colormap);
+                                      mlib_edge        edge);
 
 /***************************************************************/
-extern const type_affine_i_fun mlib_AffineFunArr_bl_i[];
 extern const type_affine_fun mlib_AffineFunArr_nn[];
 extern const type_affine_fun mlib_AffineFunArr_bl[];
 extern const type_affine_fun mlib_AffineFunArr_bc[];
--- a/jdk/src/java.desktop/share/native/libmlib_image/mlib_ImageAffineEdge.c	Thu May 19 17:48:02 2016 +0000
+++ b/jdk/src/java.desktop/share/native/libmlib_image/mlib_ImageAffineEdge.c	Thu May 19 19:46:20 2016 +0000
@@ -73,7 +73,6 @@
  */
 
 #include "mlib_image.h"
-#include "mlib_ImageColormap.h"
 #include "mlib_ImageAffine.h"
 
 /***************************************************************/
@@ -218,97 +217,6 @@
   }
 
 /***************************************************************/
-#define LUT(k, ind) plut[channels*sp[ind] + k]
-
-/***************************************************************/
-#define MLIB_EDGE_INDEX(ITYPE, DTYPE, size)                             \
-  for (j = 0; j < size; j++) {                                          \
-    ySrc = ((Y - 32768) >> MLIB_SHIFT);                                 \
-    xSrc = ((X - 32768) >> MLIB_SHIFT);                                 \
-                                                                        \
-    t = ((X - 32768) & MLIB_MASK) * scale;                              \
-    u = ((Y - 32768) & MLIB_MASK) * scale;                              \
-                                                                        \
-    xDelta = (((xSrc + 1 - srcWidth )) >> MLIB_SIGN_SHIFT) & 1;         \
-    yDelta = (((ySrc + 1 - srcHeight)) >> MLIB_SIGN_SHIFT) & srcStride; \
-                                                                        \
-    xFlag = (xSrc >> (MLIB_SIGN_SHIFT - MLIB_SHIFT));                   \
-    xSrc = xSrc + (1 & xFlag);                                          \
-    xDelta = xDelta &~ xFlag;                                           \
-                                                                        \
-    yFlag = (ySrc >> (MLIB_SIGN_SHIFT - MLIB_SHIFT));                   \
-    ySrc = ySrc + (1 & yFlag);                                          \
-    yDelta = yDelta &~ yFlag;                                           \
-                                                                        \
-    sp = (ITYPE*)lineAddr[ySrc] + xSrc;                                 \
-                                                                        \
-    for (k = 0; k < channels; k++) {                                    \
-      a00  = LUT(k, 0);                                                 \
-      a01  = LUT(k, xDelta);                                            \
-      a10  = LUT(k, yDelta);                                            \
-      a11  = LUT(k, yDelta + xDelta);                                   \
-      pix0 = (a00 * (1 - t) + a01 * t) * (1 - u) +                      \
-             (a10 * (1 - t) + a11 * t) * u;                             \
-                                                                        \
-      pbuff[k] = (mlib_s32)pix0;                                        \
-    }                                                                   \
-    pbuff += channels;                                                  \
-                                                                        \
-    X += dX;                                                            \
-    Y += dY;                                                            \
-  }
-
-/***************************************************************/
-#define MLIB_EDGE_INDEX_u8i(ITYPE, Left, Right) {                              \
-  mlib_u8  *pbuff = buff;                                                      \
-                                                                               \
-  size = Right - Left;                                                         \
-                                                                               \
-  MLIB_EDGE_INDEX(ITYPE, mlib_u8, size);                                       \
-                                                                               \
-  dp = (ITYPE*)data + Left;                                                    \
-                                                                               \
-  if (channels == 3) {                                                         \
-    if (sizeof(ITYPE) == 1) {                                                  \
-      mlib_ImageColorTrue2IndexLine_U8_U8_3 (buff, (void*)dp, size, colormap); \
-    } else {                                                                   \
-      mlib_ImageColorTrue2IndexLine_U8_S16_3(buff, (void*)dp, size, colormap); \
-    }                                                                          \
-  } else {                                                                     \
-    if (sizeof(ITYPE) == 1) {                                                  \
-      mlib_ImageColorTrue2IndexLine_U8_U8_4 (buff, (void*)dp, size, colormap); \
-    } else {                                                                   \
-      mlib_ImageColorTrue2IndexLine_U8_S16_4(buff, (void*)dp, size, colormap); \
-    }                                                                          \
-  }                                                                            \
-}
-
-/***************************************************************/
-#define MLIB_EDGE_INDEX_s16i(ITYPE, Left, Right) {                              \
-  mlib_s16 *pbuff = buff;                                                       \
-                                                                                \
-  size = Right - Left;                                                          \
-                                                                                \
-  MLIB_EDGE_INDEX(ITYPE, mlib_s16, size);                                       \
-                                                                                \
-  dp = (ITYPE*)data + Left;                                                     \
-                                                                                \
-  if (channels == 3) {                                                          \
-    if (sizeof(ITYPE) == 1) {                                                   \
-      mlib_ImageColorTrue2IndexLine_S16_U8_3 (buff, (void*)dp, size, colormap); \
-    } else {                                                                    \
-      mlib_ImageColorTrue2IndexLine_S16_S16_3(buff, (void*)dp, size, colormap); \
-    }                                                                           \
-  } else {                                                                      \
-    if (sizeof(ITYPE) == 1) {                                                   \
-      mlib_ImageColorTrue2IndexLine_S16_U8_4 (buff, (void*)dp, size, colormap); \
-    } else {                                                                    \
-      mlib_ImageColorTrue2IndexLine_S16_S16_4(buff, (void*)dp, size, colormap); \
-    }                                                                           \
-  }                                                                             \
-}
-
-/***************************************************************/
 #define GET_FLT_TBL(X, xf0, xf1, xf2, xf3)                      \
   filterpos = ((X - 32768) >> flt_shift) & flt_mask;            \
   fptr = (mlib_f32 *) ((mlib_u8 *)flt_tbl + filterpos);         \
@@ -424,47 +332,6 @@
   MLIB_EDGE_BC_LINE(TYPE, Left, Right, GET_FLT_BC2)
 
 /***************************************************************/
-#define MLIB_EDGE_INDEX_BC(ITYPE, DTYPE, size)                  \
-  for (j = 0; j < size; j++) {                                  \
-    GET_FLT_TBL(X, xf0, xf1, xf2, xf3);                         \
-    GET_FLT_TBL(Y, yf0, yf1, yf2, yf3);                         \
-                                                                \
-    CALC_SRC_POS(X, Y, 1, srcStride);                           \
-                                                                \
-    sp = (ITYPE*)lineAddr[ySrc] + xSrc;                         \
-                                                                \
-    for (k = 0; k < channels; k++) {                            \
-      c0 = LUT(k, yDelta0 + xDelta0) * xf0 +                    \
-           LUT(k, yDelta0          ) * xf1 +                    \
-           LUT(k, yDelta0 + xDelta1) * xf2 +                    \
-           LUT(k, yDelta0 + xDelta2) * xf3;                     \
-                                                                \
-      c1 = LUT(k, xDelta0) * xf0 +                              \
-           LUT(k, 0      ) * xf1 +                              \
-           LUT(k, xDelta1) * xf2 +                              \
-           LUT(k, xDelta2) * xf3;                               \
-                                                                \
-      c2 = LUT(k, yDelta1 + xDelta0) * xf0 +                    \
-           LUT(k, yDelta1          ) * xf1 +                    \
-           LUT(k, yDelta1 + xDelta1) * xf2 +                    \
-           LUT(k, yDelta1 + xDelta2) * xf3;                     \
-                                                                \
-      c3 = LUT(k, yDelta2 + xDelta0) * xf0 +                    \
-           LUT(k, yDelta2          ) * xf1 +                    \
-           LUT(k, yDelta2 + xDelta1) * xf2 +                    \
-           LUT(k, yDelta2 + xDelta2) * xf3;                     \
-                                                                \
-      val0 = c0*yf0 + c1*yf1 + c2*yf2 + c3*yf3;                 \
-                                                                \
-      SAT##DTYPE(pbuff[k], val0);                               \
-    }                                                           \
-    pbuff += channels;                                          \
-                                                                \
-    X += dX;                                                    \
-    Y += dY;                                                    \
-  }
-
-/***************************************************************/
 #define MLIB_PROCESS_EDGES_ZERO(TYPE) {                         \
   TYPE *dp, *dstLineEnd;                                        \
                                                                 \
@@ -586,16 +453,11 @@
 
 /***************************************************************/
 void mlib_ImageAffineEdgeZero(mlib_affine_param *param,
-                              mlib_affine_param *param_e,
-                              const void        *colormap)
+                              mlib_affine_param *param_e)
 {
   GET_EDGE_PARAMS_ZERO();
   mlib_s32 zero = 0;
 
-  if (colormap != NULL) {
-    zero = mlib_ImageGetLutOffset(colormap);
-  }
-
   switch (type) {
     case MLIB_BYTE:
       MLIB_PROCESS_EDGES_ZERO(mlib_u8);
@@ -654,8 +516,7 @@
 
 /***************************************************************/
 mlib_status mlib_ImageAffineEdgeExtend_BL(mlib_affine_param *param,
-                                          mlib_affine_param *param_e,
-                                          const void        *colormap)
+                                          mlib_affine_param *param_e)
 {
   GET_EDGE_PARAMS();
   mlib_d64 scale = 1.0 / (mlib_d64) MLIB_PREC;
@@ -663,79 +524,6 @@
   mlib_d64 t, u, pix0;
   mlib_d64 a00, a01, a10, a11;
 
-  if (colormap != NULL) {
-    mlib_s32 max_xsize = param_e->max_xsize;
-    mlib_type ltype = mlib_ImageGetLutType(colormap);
-    mlib_d64 *plut = (mlib_d64 *) mlib_ImageGetLutDoubleData(colormap);
-    void *buff;
-
-    channels = mlib_ImageGetLutChannels(colormap);
-    plut -= channels * mlib_ImageGetLutOffset(colormap);
-
-    if (max_xsize == 0) {
-      return MLIB_SUCCESS;
-    }
-
-    if (ltype == MLIB_BYTE) {
-      buff = mlib_malloc(channels * max_xsize);
-    }
-    else if (ltype == MLIB_SHORT) {
-      buff = mlib_malloc(channels * max_xsize * sizeof(mlib_s16));
-    } else {
-      /* Unsupported type of lookup table. Report a failure */
-      return MLIB_FAILURE;
-    }
-
-    if (buff == NULL)
-      return MLIB_FAILURE;
-
-    switch (ltype) {
-      case MLIB_BYTE:
-        switch (type) {
-          case MLIB_BYTE:
-            MLIB_PROCESS_EDGES(MLIB_EDGE_INDEX_u8i, mlib_u8);
-            break;
-
-          case MLIB_SHORT:
-            srcStride >>= 1;
-            MLIB_PROCESS_EDGES(MLIB_EDGE_INDEX_u8i, mlib_s16);
-            break;
-        default:
-          /* Incompatible image type. Ignore it for now. */
-          break;
-        }
-
-        break;
-
-      case MLIB_SHORT:
-        switch (type) {
-          case MLIB_BYTE:
-            MLIB_PROCESS_EDGES(MLIB_EDGE_INDEX_s16i, mlib_u8);
-            break;
-
-          case MLIB_SHORT:
-            srcStride >>= 1;
-            MLIB_PROCESS_EDGES(MLIB_EDGE_INDEX_s16i, mlib_s16);
-            break;
-        default:
-          /* Incompatible image type. Ignore it for now. */
-          break;
-        }
-
-        break;
-    default:
-      /* Unsupported type of lookup table.
-       * Can not be here due to check on line 685,
-       * so just ignore it.
-       */
-      break;
-    }
-
-    mlib_free(buff);
-
-    return MLIB_SUCCESS;
-  }
-
   switch (type) {
     case MLIB_BYTE:
       MLIB_PROCESS_EDGES(MLIB_EDGE_BL, mlib_u8);
@@ -775,12 +563,8 @@
 }
 
 /***************************************************************/
-#undef  MLIB_EDGE_INDEX
-#define MLIB_EDGE_INDEX MLIB_EDGE_INDEX_BC
-
 mlib_status mlib_ImageAffineEdgeExtend_BC(mlib_affine_param *param,
-                                          mlib_affine_param *param_e,
-                                          const void        *colormap)
+                                          mlib_affine_param *param_e)
 {
   GET_EDGE_PARAMS();
   mlib_d64 scale = 1.0 / (mlib_d64) MLIB_PREC;
@@ -789,7 +573,6 @@
   mlib_d64 xf0, xf1, xf2, xf3;
   mlib_d64 yf0, yf1, yf2, yf3;
   mlib_d64 c0, c1, c2, c3, val0;
-  mlib_type ltype;
   mlib_filter filter = param->filter;
   mlib_f32 *fptr;
   mlib_f32 const *flt_tbl;
@@ -798,9 +581,7 @@
   mlib_s32 yDelta0, yDelta1, yDelta2;
   mlib_d64 sat;
 
-  ltype = (colormap != NULL) ? mlib_ImageGetLutType(colormap) : type;
-
-  if (ltype == MLIB_BYTE) {
+  if (type == MLIB_BYTE) {
     flt_shift = FLT_SHIFT_U8;
     flt_mask = FLT_MASK_U8;
     flt_tbl = (filter == MLIB_BICUBIC) ? mlib_filters_u8f_bc : mlib_filters_u8f_bc2;
@@ -813,78 +594,6 @@
     sat = (mlib_d64) 0x7FFF8000;                           /* saturation for U16 */
   }
 
-  if (colormap != NULL) {
-    mlib_s32 max_xsize = param_e->max_xsize;
-    mlib_d64 *plut = (mlib_d64 *) mlib_ImageGetLutDoubleData(colormap);
-    void *buff;
-
-    channels = mlib_ImageGetLutChannels(colormap);
-    plut -= channels * mlib_ImageGetLutOffset(colormap);
-
-    if (max_xsize == 0) {
-      return MLIB_SUCCESS;
-    }
-
-    if (ltype == MLIB_BYTE) {
-      buff = mlib_malloc(channels * max_xsize);
-    }
-    else if (ltype == MLIB_SHORT) {
-      buff = mlib_malloc(channels * max_xsize * sizeof(mlib_s16));
-    } else {
-      /* Unsupported type of lookup table. */
-      return MLIB_FAILURE;
-    }
-
-    if (buff == NULL)
-      return MLIB_FAILURE;
-
-    switch (ltype) {
-      case MLIB_BYTE:
-        switch (type) {
-          case MLIB_BYTE:
-            MLIB_PROCESS_EDGES(MLIB_EDGE_INDEX_u8i, mlib_u8);
-            break;
-
-          case MLIB_SHORT:
-            srcStride >>= 1;
-            MLIB_PROCESS_EDGES(MLIB_EDGE_INDEX_u8i, mlib_s16);
-            break;
-        default:
-          /* Ignore incomatible image type. */
-          break;
-        }
-
-        break;
-
-      case MLIB_SHORT:
-        switch (type) {
-          case MLIB_BYTE:
-            MLIB_PROCESS_EDGES(MLIB_EDGE_INDEX_s16i, mlib_u8);
-            break;
-
-          case MLIB_SHORT:
-            srcStride >>= 1;
-            MLIB_PROCESS_EDGES(MLIB_EDGE_INDEX_s16i, mlib_s16);
-            break;
-        default:
-          /* Ignore incomatible image type. */
-          break;
-        }
-
-        break;
-
-    default:
-      /* Unsupported type of lookup table.
-       * Can not be here due to check on line 836,
-       * so just ignore it.
-       */
-      break;
-    }
-
-    mlib_free(buff);
-
-    return MLIB_SUCCESS;
-  }
 
   switch (type) {
     case MLIB_BYTE:
--- a/jdk/src/java.desktop/share/native/libmlib_image/mlib_ImageCheck.h	Thu May 19 17:48:02 2016 +0000
+++ b/jdk/src/java.desktop/share/native/libmlib_image/mlib_ImageCheck.h	Thu May 19 19:46:20 2016 +0000
@@ -82,12 +82,6 @@
     return MLIB_FAILURE;                                        \
   }
 
-#define MLIB_IMAGE_AND_COLORMAP_ARE_COMPAT(image,colormap)                 \
-  if ((mlib_ImageGetChannels(image) != mlib_ImageGetLutChannels(colormap)) \
-    || (mlib_ImageGetLutType(colormap) != mlib_ImageGetType(image))) {     \
-    return MLIB_FAILURE;                                                   \
-  }
-
 #define MLIB_IMAGE_GET_ALL_PARAMS(image, type, nchan, width, height, stride, pdata) \
   type   = mlib_ImageGetType(image);                                                \
   nchan  = mlib_ImageGetChannels(image);                                            \
--- a/jdk/src/java.desktop/share/native/libmlib_image/mlib_ImageColorTrue2Index.c	Thu May 19 17:48:02 2016 +0000
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,4256 +0,0 @@
-/*
- * Copyright (c) 2003, 2011, 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.
- */
-
-/*
- * FUNCTION
- *      mlib_ImageColorTrue2Index - convert a true color image to an indexed
- *                                  color image
- *
- * SYNOPSIS
- *      mlib_status mlib_ImageColorTrue2Index(mlib_image       *dst,
- *                                            const mlib_image *src,
- *                                            const void       *colormap)
- *
- * ARGUMENTS
- *      colormap  Internal data structure for inverse color mapping.
- *      dst       Pointer to destination image.
- *      src       Pointer to source image.
- *
- * DESCRIPTION
- *      Convert a true color image to a pseudo color image with the method
- *      of finding the nearest matched lut entry for each pixel.
- *
- *      The src can be an MLIB_BYTE or MLIB_SHORT image with 3 or 4 channels.
- *      The dst must be a 1-channel MLIB_BYTE or MLIB_SHORT image.
- *
- *      The lut might have either 3 or 4 channels. The type of the lut can be
- *      one of the following:
- *              MLIB_BYTE in, MLIB_BYTE out (i.e., BYTE-to-BYTE)
- *              MLIB_BYTE in, MLIB_SHORT out (i.e., BYTE-to-SHORT)
- *              MLIB_SHORT in, MLIB_SHORT out (i.e., SHORT-to-SHORT)
- *              MLIB_SHORT in, MLIB_BYTE out (i.e., SHORT-to-BYTE)
- *
- *      The src image and the lut must have same number of channels.
- */
-
-#include "mlib_image.h"
-#include "mlib_ImageColormap.h"
-#include "mlib_ImageCheck.h"
-
-/***************************************************************/
-
-/*#define USE_VIS_CODE*/
-
-#ifdef USE_VIS_CODE
-#include "vis_proto.h"
-#define VIS_ALIGNADDR(X, Y)  vis_alignaddr((void *)(X), (Y))
-#endif
-
-/***************************************************************/
-
-#define LUT_BYTE_COLORS_3CHANNELS  1000
-#define LUT_BYTE_COLORS_4CHANNELS  3000
-#define LUT_SHORT_COLORS_3CHANNELS 1000
-#define LUT_SHORT_COLORS_4CHANNELS 1000
-
-/***************************************************************/
-
-#define MAIN_COLORTRUE2INDEX_LOOP( FROM_TYPE, TO_TYPE, NCHANNELS )       \
-  for( y = 0; y < height; y++ )                                          \
-  {                                                                      \
-    mlib_ImageColorTrue2IndexLine_##FROM_TYPE##_##TO_TYPE##_##NCHANNELS( \
-      sdata, ddata, width, colormap );                                   \
-                                                                         \
-    sdata += sstride;                                                    \
-    ddata += dstride;                                                    \
-  }
-
-/***************************************************************/
-
-#define COLOR_CUBE_U8_3_SEARCH( TABLE_POINTER_TYPE, SHIFT, STEP ) \
-{                                                                 \
-  const mlib_u8 *c0, *c1, *c2;                                    \
-  TABLE_POINTER_TYPE *table = s->table;                           \
-  mlib_s32 bits = s->bits;                                        \
-  mlib_s32 nbits = 8 - bits;                                      \
-  mlib_s32 mask = ~( ( 1 << nbits ) - 1 );                        \
-  mlib_s32 j;                                                     \
-                                                                  \
-  c0 = src + SHIFT;                                               \
-  c1 = src + 1 + SHIFT;                                           \
-  c2 = src + 2 + SHIFT;                                           \
-                                                                  \
-  switch( bits )                                                  \
-  {                                                               \
-    case 1:                                                       \
-    case 2:                                                       \
-    {                                                             \
-      mlib_s32 bits0 = 8 - bits;                                  \
-      mlib_s32 bits1 = bits0 - bits;                              \
-      mlib_s32 bits2 = bits1 - bits;                              \
-                                                                  \
-      for( j = 0; j < length; j++ )                               \
-      {                                                           \
-        dst[ j ] = table[ ( ( *c0 & mask ) >> bits2 ) |           \
-          ( ( *c1 & mask ) >> bits1 ) |                           \
-          ( ( *c2 & mask ) >> bits0 ) ];                          \
-                                                                  \
-        c0 += STEP;                                               \
-        c1 += STEP;                                               \
-        c2 += STEP;                                               \
-      }                                                           \
-      break;                                                      \
-    }                                                             \
-    case 3:                                                       \
-    {                                                             \
-      for( j = 0; j < length; j++ )                               \
-      {                                                           \
-        dst[ j ] = table[ ( ( *c0 & mask ) << 1 ) |               \
-          ( ( *c1 & mask ) >> 2 ) |                               \
-          ( ( *c2 & mask ) >> 5 ) ];                              \
-                                                                  \
-        c0 += STEP;                                               \
-        c1 += STEP;                                               \
-        c2 += STEP;                                               \
-      }                                                           \
-      break;                                                      \
-    }                                                             \
-    case 4:                                                       \
-    {                                                             \
-      for( j = 0; j < length; j++ )                               \
-      {                                                           \
-        dst[ j ] = table[ ( ( *c0 & mask ) << 4 ) |               \
-          ( *c1 & mask ) |                                        \
-          ( ( *c2 & mask ) >> 4 ) ];                              \
-                                                                  \
-        c0 += STEP;                                               \
-        c1 += STEP;                                               \
-        c2 += STEP;                                               \
-      }                                                           \
-      break;                                                      \
-    }                                                             \
-    case 5:                                                       \
-    case 6:                                                       \
-    case 7:                                                       \
-    {                                                             \
-      mlib_s32 bits0 = 8 - bits;                                  \
-      mlib_s32 bits1 = bits * 2 - 8;                              \
-      mlib_s32 bits2 = bits1 + bits;                              \
-                                                                  \
-      for( j = 0; j < length; j++ )                               \
-      {                                                           \
-        dst[ j ] = table[ ( ( *c0 & mask ) << bits2 ) |           \
-          ( ( *c1 & mask ) << bits1 ) |                           \
-          ( ( *c2 & mask ) >> bits0 ) ];                          \
-                                                                  \
-        c0 += STEP;                                               \
-        c1 += STEP;                                               \
-        c2 += STEP;                                               \
-      }                                                           \
-      break;                                                      \
-    }                                                             \
-    case 8:                                                       \
-    {                                                             \
-      for( j = 0; j < length; j++ )                               \
-      {                                                           \
-        dst[ j ] = table[ ( ( *c0 & mask ) << 16 ) |              \
-          ( ( *c1 & mask ) << 8 ) |                               \
-          ( *c2 & mask ) ];                                       \
-                                                                  \
-        c0 += STEP;                                               \
-        c1 += STEP;                                               \
-        c2 += STEP;                                               \
-      }                                                           \
-      break;                                                      \
-    }                                                             \
-  }                                                               \
-}
-
-/***************************************************************/
-#define COLOR_CUBE_U8_4_SEARCH( TABLE_TYPE )                    \
-{                                                               \
-  const mlib_u8 *c0, *c1, *c2, *c3;                             \
-  TABLE_TYPE *table = s->table;                                 \
-  mlib_s32 bits = s->bits;                                      \
-  mlib_s32 nbits = 8 - bits;                                    \
-  mlib_s32 mask = ~( ( 1 << nbits ) - 1 );                      \
-  mlib_s32 j;                                                   \
-                                                                \
-  c0 = src;                                                     \
-  c1 = src + 1;                                                 \
-  c2 = src + 2;                                                 \
-  c3 = src + 3;                                                 \
-                                                                \
-  switch( bits )                                                \
-  {                                                             \
-    case 1:                                                     \
-    {                                                           \
-      for( j = 0; j < length; j++ )                             \
-      {                                                         \
-        dst[ j ] = table[ ( ( *c0 & mask ) >> 4 ) |             \
-          ( ( *c1 & mask ) >> 5 ) |                             \
-          ( ( *c2 & mask ) >> 6 ) |                             \
-          ( ( *c3 & mask ) >> 7 ) ];                            \
-                                                                \
-        c0 += 4;                                                \
-        c1 += 4;                                                \
-        c2 += 4;                                                \
-        c3 += 4;                                                \
-      }                                                         \
-      break;                                                    \
-    }                                                           \
-    case 2:                                                     \
-    {                                                           \
-      for( j = 0; j < length; j++ )                             \
-      {                                                         \
-        dst[ j ] = table[ ( *c0 & mask ) |                      \
-          ( ( *c1 & mask ) >> 2 ) |                             \
-          ( ( *c2 & mask ) >> 4 ) |                             \
-          ( ( *c3 & mask ) >> 6 ) ];                            \
-                                                                \
-        c0 += 4;                                                \
-        c1 += 4;                                                \
-        c2 += 4;                                                \
-        c3 += 4;                                                \
-          }                                                     \
-      break;                                                    \
-    }                                                           \
-    case 3:                                                     \
-    {                                                           \
-      for( j = 0; j < length; j++ )                             \
-      {                                                         \
-        dst[ j ] = table[ ( ( *c0 & mask ) << 4 ) |             \
-          ( ( *c1 & mask ) << 1 ) |                             \
-          ( ( *c2 & mask ) >> 2 ) |                             \
-          ( ( *c3 & mask ) >> 5 ) ];                            \
-                                                                \
-        c0 += 4;                                                \
-        c1 += 4;                                                \
-        c2 += 4;                                                \
-        c3 += 4;                                                \
-      }                                                         \
-      break;                                                    \
-    }                                                           \
-    case 4:                                                     \
-    {                                                           \
-      for( j = 0; j < length; j++ )                             \
-      {                                                         \
-        dst[ j ] = table[ ( ( *c0 & mask ) << 8 ) |             \
-          ( ( *c1 & mask ) << 4 ) |                             \
-          ( *c2 & mask ) |                                      \
-          ( ( *c3 & mask ) >> 4 ) ];                            \
-                                                                \
-        c0 += 4;                                                \
-        c1 += 4;                                                \
-        c2 += 4;                                                \
-        c3 += 4;                                                \
-      }                                                         \
-      break;                                                    \
-    }                                                           \
-    case 5:                                                     \
-    case 6:                                                     \
-    {                                                           \
-      mlib_s32 bits3 = bits * 4 - 8;                            \
-      mlib_s32 bits2 = bits3 - bits;                            \
-      mlib_s32 bits1 = bits2 - bits;                            \
-      mlib_s32 bits0 = 8 - bits;                                \
-                                                                \
-      for( j = 0; j < length; j++ )                             \
-      {                                                         \
-        dst[ j ] = table[ ( ( *c0 & mask ) << bits3 ) |         \
-          ( ( *c1 & mask ) << bits2 ) |                         \
-          ( ( *c2 & mask ) << bits1 ) |                         \
-          ( ( *c3 & mask ) >> bits0 ) ];                        \
-                                                                \
-        c0 += 4;                                                \
-        c1 += 4;                                                \
-        c2 += 4;                                                \
-        c3 += 4;                                                \
-      }                                                         \
-      break;                                                    \
-    }                                                           \
-    case 7:                                                     \
-    {                                                           \
-      for( j = 0; j < length; j++ )                             \
-      {                                                         \
-        dst[ j ] = table[ ( ( *c0 & mask ) << 20 ) |            \
-          ( ( *c1 & mask ) << 13 ) |                            \
-          ( ( *c2 & mask ) << 6 ) |                             \
-          ( ( *c3 & mask ) >> 1 ) ];                            \
-                                                                \
-        c0 += 4;                                                \
-        c1 += 4;                                                \
-        c2 += 4;                                                \
-        c3 += 4;                                                \
-      }                                                         \
-      break;                                                    \
-    }                                                           \
-    case 8: /* will never be called */                          \
-    {                                                           \
-      for( j = 0; j < length; j++ )                             \
-      {                                                         \
-        dst[ j ] = table[ ( ( *c0 & mask ) << 24 ) |            \
-          ( ( *c1 & mask ) << 16 ) |                            \
-          ( ( *c2 & mask ) << 8 ) |                             \
-          ( *c3 & mask ) ];                                     \
-                                                                \
-        c0 += 4;                                                \
-        c1 += 4;                                                \
-        c2 += 4;                                                \
-        c3 += 4;                                                \
-      }                                                         \
-      break;                                                    \
-    }                                                           \
-  }                                                             \
-}
-
-/***************************************************************/
-#define COLOR_CUBE_S16_3_SEARCH( TABLE_TYPE, SHIFT, STEP )                 \
-{                                                                          \
-  const mlib_s16 *c0, *c1, *c2;                                            \
-  mlib_s32 bits = s->bits;                                                 \
-  mlib_s32 nbits = 16 - bits;                                              \
-  mlib_s32 mask = ~( ( 1 << nbits ) - 1 );                                 \
-  TABLE_TYPE *table = s->table;                                            \
-  mlib_s32 j;                                                              \
-                                                                           \
-  c0 = src + SHIFT;                                                        \
-  c1 = src + 1 + SHIFT;                                                    \
-  c2 = src + 2 + SHIFT;                                                    \
-                                                                           \
-  switch( bits )                                                           \
-  {                                                                        \
-    case 1:                                                                \
-    case 2:                                                                \
-    case 3:                                                                \
-    case 4:                                                                \
-    case 5:                                                                \
-    {                                                                      \
-      mlib_s32 bits0 = 16 - bits;                                          \
-      mlib_s32 bits1 = bits0 - bits;                                       \
-      mlib_s32 bits2 = bits1 - bits;                                       \
-                                                                           \
-      for( j = 0; j < length; j++ )                                        \
-      {                                                                    \
-        dst[ j ] = table[ ( ( ( *c0 - MLIB_S16_MIN ) & mask ) >> bits2 ) | \
-          ( ( ( *c1 - MLIB_S16_MIN ) & mask ) >> bits1 ) |                 \
-          ( ( ( *c2 - MLIB_S16_MIN ) & mask ) >> bits0 ) ];                \
-                                                                           \
-        c0 += STEP;                                                        \
-        c1 += STEP;                                                        \
-        c2 += STEP;                                                        \
-      }                                                                    \
-      break;                                                               \
-    }                                                                      \
-    case 6:                                                                \
-    case 7:                                                                \
-    {                                                                      \
-      mlib_s32 bits0 = 16 - bits;                                          \
-      mlib_s32 bits1 = bits0 - bits;                                       \
-      mlib_s32 bits2 = bits * 3 - 16;                                      \
-                                                                           \
-      for( j = 0; j < length; j++ )                                        \
-      {                                                                    \
-        dst[ j ] = table[ ( ( ( *c0 - MLIB_S16_MIN ) & mask ) << bits2 ) | \
-          ( ( ( *c1 - MLIB_S16_MIN ) & mask ) >> bits1 ) |                 \
-          ( ( ( *c2 - MLIB_S16_MIN ) & mask ) >> bits0 ) ];                \
-                                                                           \
-        c0 += STEP;                                                        \
-        c1 += STEP;                                                        \
-        c2 += STEP;                                                        \
-      }                                                                    \
-      break;                                                               \
-    }                                                                      \
-    case 8:                                                                \
-    {                                                                      \
-      for( j = 0; j < length; j++ )                                        \
-      {                                                                    \
-        dst[ j ] = table[ ( ( ( *c0 - MLIB_S16_MIN ) & mask ) << 8 ) |     \
-          ( ( *c1 - MLIB_S16_MIN ) & mask ) |                              \
-          ( ( ( *c2 - MLIB_S16_MIN ) & mask ) >> 8 ) ];                    \
-                                                                           \
-        c0 += STEP;                                                        \
-        c1 += STEP;                                                        \
-        c2 += STEP;                                                        \
-      }                                                                    \
-      break;                                                               \
-    }                                                                      \
-    case 9:                                                                \
-    case 10:                                                               \
-    {                                                                      \
-      mlib_s32 bits0 = 16 - bits;                                          \
-      mlib_s32 bits1 = 2 * bits - 16;                                      \
-      mlib_s32 bits2 = bits1 + bits;                                       \
-                                                                           \
-      for( j = 0; j < length; j++ )                                        \
-      {                                                                    \
-        dst[ j ] = table[ ( ( ( *c0 - MLIB_S16_MIN ) & mask ) << bits2 ) | \
-          ( ( ( *c1 - MLIB_S16_MIN ) & mask ) << bits1 ) |                 \
-          ( ( ( *c2 - MLIB_S16_MIN ) & mask ) >> bits0 ) ];                \
-                                                                           \
-        c0 += STEP;                                                        \
-        c1 += STEP;                                                        \
-        c2 += STEP;                                                        \
-      }                                                                    \
-      break;                                                               \
-    }                                                                      \
-    /* Other cases may not be considered as the table size will be more    \
-       than 2^32 */                                                        \
-  }                                                                        \
-}
-
-/***************************************************************/
-#define COLOR_CUBE_S16_4_SEARCH( TABLE_TYPE )                              \
-{                                                                          \
-  const mlib_s16 *c0, *c1, *c2, *c3;                                       \
-  TABLE_TYPE *table = s->table;                                            \
-  mlib_s32 bits = s->bits;                                                 \
-  mlib_s32 nbits = 16 - bits;                                              \
-  mlib_s32 mask = ~( ( 1 << nbits ) - 1 );                                 \
-  mlib_s32 j;                                                              \
-                                                                           \
-  c0 = src;                                                                \
-  c1 = src + 1;                                                            \
-  c2 = src + 2;                                                            \
-  c3 = src + 3;                                                            \
-                                                                           \
-  switch( bits )                                                           \
-  {                                                                        \
-    case 1:                                                                \
-    case 2:                                                                \
-    case 3:                                                                \
-    {                                                                      \
-      mlib_s32 bits0 = 16 - bits;                                          \
-      mlib_s32 bits1 = bits0 - bits;                                       \
-      mlib_s32 bits2 = bits1 - bits;                                       \
-      mlib_s32 bits3 = bits2 - bits;                                       \
-                                                                           \
-      for( j = 0; j < length; j++ )                                        \
-      {                                                                    \
-        dst[ j ] = table[ ( ( ( *c0 - MLIB_S16_MIN ) & mask ) >> bits3 ) | \
-          ( ( ( *c1 - MLIB_S16_MIN ) & mask ) >> bits2 ) |                 \
-          ( ( ( *c2 - MLIB_S16_MIN ) & mask ) >> bits1 ) |                 \
-          ( ( ( *c3 - MLIB_S16_MIN ) & mask ) >> bits0 ) ];                \
-                                                                           \
-        c0 += 4;                                                           \
-        c1 += 4;                                                           \
-        c2 += 4;                                                           \
-        c3 += 4;                                                           \
-      }                                                                    \
-      break;                                                               \
-    }                                                                      \
-    case 4:                                                                \
-    {                                                                      \
-      for( j = 0; j < length; j++ )                                        \
-      {                                                                    \
-        dst[ j ] = table[ ( ( *c0 - MLIB_S16_MIN ) & mask ) |              \
-          ( ( ( *c1 - MLIB_S16_MIN ) & mask ) >> 4 ) |                     \
-          ( ( ( *c2 - MLIB_S16_MIN ) & mask ) >> 8 ) |                     \
-          ( ( ( *c3 - MLIB_S16_MIN ) & mask ) >> 12 ) ];                   \
-                                                                           \
-        c0 += 4;                                                           \
-        c1 += 4;                                                           \
-        c2 += 4;                                                           \
-        c3 += 4;                                                           \
-      }                                                                    \
-      break;                                                               \
-    }                                                                      \
-    case 5:                                                                \
-    {                                                                      \
-      for( j = 0; j < length; j++ )                                        \
-      {                                                                    \
-        dst[ j ] = table[ ( ( ( *c0 - MLIB_S16_MIN ) & mask ) << 4 ) |     \
-          ( ( ( *c1 - MLIB_S16_MIN ) & mask ) >> 1 ) |                     \
-          ( ( ( *c2 - MLIB_S16_MIN ) & mask ) >> 6 ) |                     \
-          ( ( ( *c3 - MLIB_S16_MIN ) & mask ) >> 11 ) ];                   \
-                                                                           \
-        c0 += 4;                                                           \
-        c1 += 4;                                                           \
-        c2 += 4;                                                           \
-        c3 += 4;                                                           \
-      }                                                                    \
-      break;                                                               \
-    }                                                                      \
-    case 6:                                                                \
-    case 7:                                                                \
-    {                                                                      \
-      mlib_s32 bits0 = 16 - bits;                                          \
-      mlib_s32 bits1 = bits0 - bits;                                       \
-      mlib_s32 bits3 = bits * 4 - 16;                                      \
-      mlib_s32 bits2 = bits3 - bits;                                       \
-                                                                           \
-      for( j = 0; j < length; j++ )                                        \
-      {                                                                    \
-        dst[ j ] = table[ ( ( ( *c0 - MLIB_S16_MIN ) & mask ) << bits3 ) | \
-          ( ( ( *c1 - MLIB_S16_MIN ) & mask ) << bits2 ) |                 \
-          ( ( ( *c2 - MLIB_S16_MIN ) & mask ) >> bits1 ) |                 \
-          ( ( ( *c3 - MLIB_S16_MIN ) & mask ) >> bits0 ) ];                \
-                                                                           \
-        c0 += 4;                                                           \
-        c1 += 4;                                                           \
-        c2 += 4;                                                           \
-        c3 += 4;                                                           \
-      }                                                                    \
-      break;                                                               \
-    }                                                                      \
-    case 8:                                                                \
-    {                                                                      \
-      for( j = 0; j < length; j++ )                                        \
-      {                                                                    \
-        dst[ j ] = table[ ( ( ( *c0 - MLIB_S16_MIN ) & mask ) << 16 ) |    \
-          ( ( ( *c1 - MLIB_S16_MIN ) & mask ) << 8 ) |                     \
-          ( ( *c2 - MLIB_S16_MIN ) & mask ) |                              \
-          ( ( ( *c3 - MLIB_S16_MIN ) & mask ) >> 8 ) ];                    \
-                                                                           \
-        c0 += 4;                                                           \
-        c1 += 4;                                                           \
-        c2 += 4;                                                           \
-        c3 += 4;                                                           \
-      }                                                                    \
-      break;                                                               \
-    }                                                                      \
-    /* Other cases may not be considered as the table size will be more    \
-       than 2^32 */                                                        \
-  }                                                                        \
-}
-
-/***************************************************************/
-#define BINARY_TREE_SEARCH_RIGHT( POSITION, COLOR_MAX, SHIFT )  \
-{                                                               \
-  if( ( distance >= ( ( ( position[ POSITION ] + current_size - \
-    c[ POSITION ] ) * ( position[ POSITION ] + current_size -   \
-    c[ POSITION ] ) ) >> SHIFT ) ) &&                           \
-    ( position[ POSITION ] + current_size != COLOR_MAX ) )      \
-    continue_up = 1;                                            \
-}
-
-/***************************************************************/
-#define BINARY_TREE_EXPLORE_RIGHT_3( POSITION, COLOR_MAX, IMAGE_TYPE,    \
-  FIRST_NEIBOUR, SECOND_NEIBOUR, SUBSTRACTION, SHIFT )                   \
-{                                                                        \
-  if( distance >= ( ( ( position[ POSITION ] + current_size -            \
-    c[ POSITION ] ) * ( position[ POSITION ] +                           \
-      current_size - c[ POSITION ] ) ) >> SHIFT ) )                      \
-  {                                                                      \
-    if( distance < ( ( ( COLOR_MAX - c[ POSITION ] ) *                   \
-      ( COLOR_MAX - c[ POSITION ] ) ) >> SHIFT ) )                       \
-    {                                                                    \
-      if( distance < ( ( ( position[ POSITION ] +                        \
-        current_size * 2 - c[ POSITION ] ) *                             \
-        ( position[ POSITION ] + current_size * 2 -                      \
-          c[ POSITION ] ) ) >> SHIFT ) )                                 \
-      {                                                                  \
-        /* Check only a part of quadrant */                              \
-        mlib_s32 qq = q ^ ( 1 << POSITION );                             \
-                                                                         \
-        check_neibours[ FIRST_NEIBOUR ] += 1;                            \
-        check_neibours[ SECOND_NEIBOUR ] += 1;                           \
-        check_corner += 1;                                               \
-        if( node->tag & ( 1 << qq ) )                                    \
-        {                                                                \
-          /* Here is another color cell.                                 \
-             Check the distance */                                       \
-          mlib_s32 new_found_color =                                     \
-            node->contents.index[ qq ];                                  \
-          mlib_u32 newdistance = FIND_DISTANCE_3( c[ 0 ],                \
-            p[ 0 ][ new_found_color ] - SUBSTRACTION, c[ 1 ],            \
-            p[ 1 ][ new_found_color ] - SUBSTRACTION, c[ 2 ],            \
-            p[ 2 ][ new_found_color ] - SUBSTRACTION, SHIFT );           \
-                                                                         \
-          if( newdistance < distance )                                   \
-          {                                                              \
-            found_color = new_found_color;                               \
-            distance = newdistance;                                      \
-          }                                                              \
-        }                                                                \
-        else if( node->contents.quadrants[ qq ] )                        \
-          /* Only a part of quadrant needs checking */                   \
-          distance =                                                     \
-            mlib_search_quadrant_part_to_left_##IMAGE_TYPE##_3(          \
-              node->contents.quadrants[ qq ],                            \
-              distance, &found_color, c, p,                              \
-              position[ POSITION ] + current_size, pass - 1, POSITION ); \
-      }                                                                  \
-      else /* Check whole quadrant */                                    \
-      {                                                                  \
-        mlib_s32 qq = q ^ ( 1 << POSITION );                             \
-                                                                         \
-        check_neibours[ FIRST_NEIBOUR ] += 2;                            \
-        check_neibours[ SECOND_NEIBOUR ] += 2;                           \
-        check_corner += 2;                                               \
-        continue_up = 1;                                                 \
-        if( node->tag & ( 1 << qq ) )                                    \
-        {                                                                \
-          /* Here is another color cell.                                 \
-             Check the distance */                                       \
-          mlib_s32 new_found_color =                                     \
-            node->contents.index[ qq ];                                  \
-          mlib_u32 newdistance = FIND_DISTANCE_3( c[ 0 ],                \
-            p[ 0 ][ new_found_color ] - SUBSTRACTION, c[ 1 ],            \
-            p[ 1 ][ new_found_color ] - SUBSTRACTION, c[ 2 ],            \
-            p[ 2 ][ new_found_color ] - SUBSTRACTION, SHIFT );           \
-                                                                         \
-          if( newdistance < distance )                                   \
-          {                                                              \
-            found_color = new_found_color;                               \
-            distance = newdistance;                                      \
-          }                                                              \
-        }                                                                \
-        else if( node->contents.quadrants[ qq ] )                        \
-          /* Here is a full node. Just explore it */                     \
-          distance = mlib_search_quadrant_##IMAGE_TYPE##_3(              \
-            node->contents.quadrants[ qq ],                              \
-            distance, &found_color, c[ 0 ], c[ 1 ], c[ 2 ], p );         \
-      }                                                                  \
-    }                                                                    \
-    else /* Cell is on the edge of the space */                          \
-    {                                                                    \
-      if( position[ POSITION ] + current_size * 2 ==                     \
-        COLOR_MAX )                                                      \
-      {                                                                  \
-        /* Check only a part of quadrant */                              \
-        mlib_s32 qq = q ^ ( 1 << POSITION );                             \
-                                                                         \
-        check_neibours[ FIRST_NEIBOUR ] += 1;                            \
-        check_neibours[ SECOND_NEIBOUR ] += 1;                           \
-        check_corner += 1;                                               \
-        if( node->tag & ( 1 << qq ) )                                    \
-        {                                                                \
-          /* Here is another color cell.                                 \
-             Check the distance */                                       \
-          mlib_s32 new_found_color =                                     \
-            node->contents.index[ qq ];                                  \
-          mlib_u32 newdistance = FIND_DISTANCE_3( c[ 0 ],                \
-            p[ 0 ][ new_found_color ] - SUBSTRACTION, c[ 1 ],            \
-            p[ 1 ][ new_found_color ] - SUBSTRACTION, c[ 2 ],            \
-            p[ 2 ][ new_found_color ] - SUBSTRACTION, SHIFT );           \
-                                                                         \
-          if( newdistance < distance )                                   \
-          {                                                              \
-            found_color = new_found_color;                               \
-            distance = newdistance;                                      \
-          }                                                              \
-        }                                                                \
-        else if( node->contents.quadrants[ qq ] )                        \
-          /* Only a part of quadrant needs checking */                   \
-          distance =                                                     \
-            mlib_search_quadrant_part_to_left_##IMAGE_TYPE##_3(          \
-              node->contents.quadrants[ qq ],                            \
-              distance, &found_color, c, p,                              \
-              position[ POSITION ] + current_size,                       \
-              pass - 1, POSITION );                                      \
-      }                                                                  \
-      else /* Check whole quadrant */                                    \
-      {                                                                  \
-        mlib_s32 qq = q ^ ( 1 << POSITION );                             \
-                                                                         \
-        check_neibours[ FIRST_NEIBOUR ] += 2;                            \
-        check_neibours[ SECOND_NEIBOUR ] += 2;                           \
-        check_corner += 2;                                               \
-        continue_up = 1;                                                 \
-        if( node->tag & ( 1 << qq ) )                                    \
-        {                                                                \
-          /* Here is another color cell.                                 \
-             Check the distance */                                       \
-          mlib_s32 new_found_color =                                     \
-            node->contents.index[ qq ];                                  \
-          mlib_u32 newdistance = FIND_DISTANCE_3( c[ 0 ],                \
-            p[ 0 ][ new_found_color ] - SUBSTRACTION, c[ 1 ],            \
-            p[ 1 ][ new_found_color ] - SUBSTRACTION, c[ 2 ],            \
-            p[ 2 ][ new_found_color ] - SUBSTRACTION, SHIFT );           \
-                                                                         \
-          if( newdistance < distance )                                   \
-          {                                                              \
-            found_color = new_found_color;                               \
-            distance = newdistance;                                      \
-          }                                                              \
-        }                                                                \
-        else if( node->contents.quadrants[ qq ] )                        \
-          /* Here is a full node. Just explore it */                     \
-          distance = mlib_search_quadrant_##IMAGE_TYPE##_3(              \
-            node->contents.quadrants[ qq ],                              \
-            distance, &found_color, c[ 0 ], c[ 1 ], c[ 2 ], p );         \
-      }                                                                  \
-    }                                                                    \
-  }                                                                      \
-}
-
-/***************************************************************/
-#define BINARY_TREE_EXPLORE_RIGHT_4( POSITION, COLOR_MAX, IMAGE_TYPE,    \
-  FIRST_NEIBOUR, SECOND_NEIBOUR, THIRD_NEIBOUR, SUBSTRACTION, SHIFT )    \
-{                                                                        \
-  if( distance >= ( ( ( position[ POSITION ] + current_size -            \
-    c[ POSITION ] ) * ( position[ POSITION ] +                           \
-      current_size - c[ POSITION ] ) ) >> SHIFT ) )                      \
-  {                                                                      \
-    if( distance < ( ( ( COLOR_MAX - c[ POSITION ] ) *                   \
-      ( COLOR_MAX - c[ POSITION ] ) ) >> SHIFT ) )                       \
-    {                                                                    \
-      if( distance < ( ( ( position[ POSITION ] +                        \
-        current_size * 2 - c[ POSITION ] ) *                             \
-        ( position[ POSITION ] + current_size * 2 -                      \
-          c[ POSITION ] ) ) >> SHIFT ) )                                 \
-      {                                                                  \
-        /* Check only a part of quadrant */                              \
-        mlib_s32 qq = q ^ ( 1 << POSITION );                             \
-                                                                         \
-        check_neibours[ FIRST_NEIBOUR ] += 1;                            \
-        check_neibours[ SECOND_NEIBOUR ] += 1;                           \
-        check_neibours[ THIRD_NEIBOUR ] += 1;                            \
-        if( node->tag & ( 1 << qq ) )                                    \
-        {                                                                \
-          /* Here is another color cell.                                 \
-             Check the distance */                                       \
-          mlib_s32 new_found_color =                                     \
-            node->contents.index[ qq ];                                  \
-          mlib_u32 newdistance = FIND_DISTANCE_4( c[ 0 ],                \
-            p[ 0 ][ new_found_color ] - SUBSTRACTION, c[ 1 ],            \
-            p[ 1 ][ new_found_color ] - SUBSTRACTION, c[ 2 ],            \
-            p[ 2 ][ new_found_color ] - SUBSTRACTION, c[ 3 ],            \
-            p[ 3 ][ new_found_color ] - SUBSTRACTION, SHIFT );           \
-                                                                         \
-          if( newdistance < distance )                                   \
-          {                                                              \
-            found_color = new_found_color;                               \
-            distance = newdistance;                                      \
-          }                                                              \
-        }                                                                \
-        else if( node->contents.quadrants[ qq ] )                        \
-          /* Only a part of quadrant needs checking */                   \
-          distance =                                                     \
-            mlib_search_quadrant_part_to_left_##IMAGE_TYPE##_4(          \
-              node->contents.quadrants[ qq ],                            \
-              distance, &found_color, c, p,                              \
-              position[ POSITION ] + current_size, pass - 1, POSITION ); \
-      }                                                                  \
-      else /* Check whole quadrant */                                    \
-      {                                                                  \
-        mlib_s32 qq = q ^ ( 1 << POSITION );                             \
-                                                                         \
-        check_neibours[ FIRST_NEIBOUR ] += 2;                            \
-        check_neibours[ SECOND_NEIBOUR ] += 2;                           \
-        check_neibours[ THIRD_NEIBOUR ] += 2;                            \
-        continue_up = 1;                                                 \
-        if( node->tag & ( 1 << qq ) )                                    \
-        {                                                                \
-          /* Here is another color cell.                                 \
-             Check the distance */                                       \
-          mlib_s32 new_found_color =                                     \
-            node->contents.index[ qq ];                                  \
-          mlib_u32 newdistance = FIND_DISTANCE_4( c[ 0 ],                \
-            p[ 0 ][ new_found_color ] - SUBSTRACTION, c[ 1 ],            \
-            p[ 1 ][ new_found_color ] - SUBSTRACTION, c[ 2 ],            \
-            p[ 2 ][ new_found_color ] - SUBSTRACTION, c[ 3 ],            \
-            p[ 3 ][ new_found_color ] - SUBSTRACTION, SHIFT );           \
-                                                                         \
-          if( newdistance < distance )                                   \
-          {                                                              \
-            found_color = new_found_color;                               \
-            distance = newdistance;                                      \
-          }                                                              \
-        }                                                                \
-        else if( node->contents.quadrants[ qq ] )                        \
-          /* Here is a full node. Just explore it */                     \
-          distance = mlib_search_quadrant_##IMAGE_TYPE##_4(              \
-            node->contents.quadrants[ qq ],                              \
-            distance, &found_color, c[ 0 ], c[ 1 ], c[ 2 ], c[ 3 ], p ); \
-      }                                                                  \
-    }                                                                    \
-    else /* Cell is on the edge of the space */                          \
-    {                                                                    \
-      if( position[ POSITION ] + current_size * 2 ==                     \
-        COLOR_MAX )                                                      \
-      {                                                                  \
-        /* Check only a part of quadrant */                              \
-        mlib_s32 qq = q ^ ( 1 << POSITION );                             \
-                                                                         \
-        check_neibours[ FIRST_NEIBOUR ] += 1;                            \
-        check_neibours[ SECOND_NEIBOUR ] += 1;                           \
-        check_neibours[ THIRD_NEIBOUR ] += 1;                            \
-        if( node->tag & ( 1 << qq ) )                                    \
-        {                                                                \
-          /* Here is another color cell.                                 \
-             Check the distance */                                       \
-          mlib_s32 new_found_color =                                     \
-            node->contents.index[ qq ];                                  \
-          mlib_u32 newdistance = FIND_DISTANCE_4( c[ 0 ],                \
-            p[ 0 ][ new_found_color ] - SUBSTRACTION, c[ 1 ],            \
-            p[ 1 ][ new_found_color ] - SUBSTRACTION, c[ 2 ],            \
-            p[ 2 ][ new_found_color ] - SUBSTRACTION, c[ 3 ],            \
-            p[ 3 ][ new_found_color ] - SUBSTRACTION, SHIFT );           \
-                                                                         \
-          if( newdistance < distance )                                   \
-          {                                                              \
-            found_color = new_found_color;                               \
-            distance = newdistance;                                      \
-          }                                                              \
-        }                                                                \
-        else if( node->contents.quadrants[ qq ] )                        \
-          /* Only a part of quadrant needs checking */                   \
-          distance =                                                     \
-            mlib_search_quadrant_part_to_left_##IMAGE_TYPE##_4(          \
-              node->contents.quadrants[ qq ],                            \
-              distance, &found_color, c, p,                              \
-              position[ POSITION ] + current_size,                       \
-              pass - 1, POSITION );                                      \
-      }                                                                  \
-      else /* Check whole quadrant */                                    \
-      {                                                                  \
-        mlib_s32 qq = q ^ ( 1 << POSITION );                             \
-                                                                         \
-        check_neibours[ FIRST_NEIBOUR ] += 2;                            \
-        check_neibours[ SECOND_NEIBOUR ] += 2;                           \
-        check_neibours[ THIRD_NEIBOUR ] += 2;                            \
-        continue_up = 1;                                                 \
-        if( node->tag & ( 1 << qq ) )                                    \
-        {                                                                \
-          /* Here is another color cell.                                 \
-             Check the distance */                                       \
-          mlib_s32 new_found_color =                                     \
-            node->contents.index[ qq ];                                  \
-          mlib_u32 newdistance = FIND_DISTANCE_4( c[ 0 ],                \
-            p[ 0 ][ new_found_color ] - SUBSTRACTION, c[ 1 ],            \
-            p[ 1 ][ new_found_color ] - SUBSTRACTION, c[ 2 ],            \
-            p[ 2 ][ new_found_color ] - SUBSTRACTION, c[ 3 ],            \
-            p[ 3 ][ new_found_color ] - SUBSTRACTION, SHIFT );           \
-                                                                         \
-          if( newdistance < distance )                                   \
-          {                                                              \
-            found_color = new_found_color;                               \
-            distance = newdistance;                                      \
-          }                                                              \
-        }                                                                \
-        else if( node->contents.quadrants[ qq ] )                        \
-          /* Here is a full node. Just explore it */                     \
-          distance = mlib_search_quadrant_##IMAGE_TYPE##_4(              \
-            node->contents.quadrants[ qq ],                              \
-            distance, &found_color, c[ 0 ], c[ 1 ], c[ 2 ], c[ 3 ], p ); \
-      }                                                                  \
-    }                                                                    \
-  }                                                                      \
-}
-
-/***************************************************************/
-#define BINARY_TREE_SEARCH_LEFT( POSITION, SHIFT )                \
-{                                                                 \
-  if( ( distance > ( ( ( position[ POSITION ] - c[ POSITION ] ) * \
-    ( position[ POSITION ] - c[ POSITION ] ) ) >> SHIFT ) )  &&   \
-    position[ POSITION ] )                                        \
-    continue_up = 1;                                              \
-}
-
-/***************************************************************/
-#define BINARY_TREE_EXPLORE_LEFT_3( POSITION, IMAGE_TYPE,                \
-  FIRST_NEIBOUR, SECOND_NEIBOUR, SUBSTRACTION, SHIFT )                   \
-{                                                                        \
-  if( distance >                                                         \
-    ( ( ( c[ POSITION ] - position[ POSITION ] ) *                       \
-    ( c[ POSITION ] - position[ POSITION ] ) ) >> SHIFT ) )              \
-  {                                                                      \
-    if( distance <= ( ( c[ POSITION ] * c[ POSITION ] ) >> SHIFT ) )     \
-    {                                                                    \
-      if( distance <= ( ( ( c[ POSITION ] + current_size -               \
-        position[ POSITION ] ) *                                         \
-        ( c[ POSITION ] + current_size -                                 \
-          position[ POSITION ] ) ) >> SHIFT ) )                          \
-      {                                                                  \
-        mlib_s32 qq = q ^ ( 1 << POSITION );                             \
-                                                                         \
-        check_neibours[ FIRST_NEIBOUR ] += 1;                            \
-        check_neibours[ SECOND_NEIBOUR ] += 1;                           \
-        check_corner += 1;                                               \
-        if( node->tag & ( 1 << qq ) )                                    \
-        {                                                                \
-          /* Here is another color cell.                                 \
-             Check the distance */                                       \
-          mlib_s32 new_found_color =                                     \
-            node->contents.index[ qq ];                                  \
-          mlib_u32 newdistance = FIND_DISTANCE_3( c[ 0 ],                \
-            p[ 0 ][ new_found_color ] - SUBSTRACTION, c[ 1 ],            \
-            p[ 1 ][ new_found_color ] - SUBSTRACTION, c[ 2 ],            \
-            p[ 2 ][ new_found_color ] - SUBSTRACTION, SHIFT );           \
-                                                                         \
-          if( newdistance < distance )                                   \
-          {                                                              \
-            found_color = new_found_color;                               \
-            distance = newdistance;                                      \
-          }                                                              \
-        }                                                                \
-        else if( node->contents.quadrants[ qq ] )                        \
-          /* Only a part of quadrant needs checking */                   \
-          distance =                                                     \
-            mlib_search_quadrant_part_to_right_##IMAGE_TYPE##_3(         \
-              node->contents.quadrants[ qq ],                            \
-              distance, &found_color, c, p,                              \
-              position[ POSITION ] - current_size, pass - 1, POSITION ); \
-      }                                                                  \
-      else /* Check whole quadrant */                                    \
-      {                                                                  \
-        mlib_s32 qq = q ^ ( 1 << POSITION );                             \
-                                                                         \
-        check_neibours[ FIRST_NEIBOUR ] += 2;                            \
-        check_neibours[ SECOND_NEIBOUR ] += 2;                           \
-        check_corner += 2;                                               \
-        continue_up = 1;                                                 \
-        if( node->tag & ( 1 << qq ) )                                    \
-        {                                                                \
-          /* Here is another color cell.                                 \
-             Check the distance */                                       \
-          mlib_s32 new_found_color =                                     \
-            node->contents.index[ qq ];                                  \
-          mlib_u32 newdistance = FIND_DISTANCE_3( c[ 0 ],                \
-            p[ 0 ][ new_found_color ] - SUBSTRACTION, c[ 1 ],            \
-            p[ 1 ][ new_found_color ] - SUBSTRACTION, c[ 2 ],            \
-            p[ 2 ][ new_found_color ] - SUBSTRACTION, SHIFT );           \
-                                                                         \
-          if( newdistance < distance )                                   \
-          {                                                              \
-            found_color = new_found_color;                               \
-            distance = newdistance;                                      \
-          }                                                              \
-        }                                                                \
-        else if( node->contents.quadrants[ qq ] )                        \
-          /* Here is a full node. Just explore it */                     \
-          distance = mlib_search_quadrant_##IMAGE_TYPE##_3(              \
-            node->contents.quadrants[ qq ],                              \
-            distance, &found_color, c[ 0 ], c[ 1 ], c[ 2 ], p );         \
-      }                                                                  \
-    }                                                                    \
-    else                                                                 \
-    {                                                                    \
-      if( !( position[ POSITION ] - current_size ) )                     \
-      {                                                                  \
-        mlib_s32 qq = q ^ ( 1 << POSITION );                             \
-                                                                         \
-        check_neibours[ FIRST_NEIBOUR ] += 1;                            \
-        check_neibours[ SECOND_NEIBOUR ] += 1;                           \
-        check_corner += 1;                                               \
-        if( node->tag & ( 1 << qq ) )                                    \
-        {                                                                \
-          /* Here is another color cell.                                 \
-             Check the distance */                                       \
-          mlib_s32 new_found_color =                                     \
-            node->contents.index[ qq ];                                  \
-          mlib_u32 newdistance = FIND_DISTANCE_3( c[ 0 ],                \
-            p[ 0 ][ new_found_color ] - SUBSTRACTION, c[ 1 ],            \
-            p[ 1 ][ new_found_color ] - SUBSTRACTION, c[ 2 ],            \
-            p[ 2 ][ new_found_color ] - SUBSTRACTION, SHIFT );           \
-                                                                         \
-          if( newdistance < distance )                                   \
-          {                                                              \
-            found_color = new_found_color;                               \
-            distance = newdistance;                                      \
-          }                                                              \
-        }                                                                \
-        else if( node->contents.quadrants[ qq ] )                        \
-          /* Only a part of quadrant needs checking */                   \
-          distance =                                                     \
-            mlib_search_quadrant_part_to_right_##IMAGE_TYPE##_3(         \
-              node->contents.quadrants[ qq ],                            \
-              distance, &found_color, c, p,                              \
-              position[ POSITION ] - current_size, pass - 1, POSITION ); \
-      }                                                                  \
-      else                                                               \
-      {                                                                  \
-        mlib_s32 qq = q ^ ( 1 << POSITION );                             \
-                                                                         \
-        check_neibours[ FIRST_NEIBOUR ] += 2;                            \
-        check_neibours[ SECOND_NEIBOUR ] += 2;                           \
-        check_corner += 2;                                               \
-        continue_up = 1;                                                 \
-        if( node->tag & ( 1 << qq ) )                                    \
-        {                                                                \
-          /* Here is another color cell.                                 \
-             Check the distance */                                       \
-          mlib_s32 new_found_color =                                     \
-            node->contents.index[ qq ];                                  \
-          mlib_u32 newdistance = FIND_DISTANCE_3( c[ 0 ],                \
-            p[ 0 ][ new_found_color ] - SUBSTRACTION, c[ 1 ],            \
-            p[ 1 ][ new_found_color ] - SUBSTRACTION, c[ 2 ],            \
-            p[ 2 ][ new_found_color ] - SUBSTRACTION, SHIFT );           \
-                                                                         \
-          if( newdistance < distance )                                   \
-          {                                                              \
-            found_color = new_found_color;                               \
-            distance = newdistance;                                      \
-          }                                                              \
-        }                                                                \
-        else if( node->contents.quadrants[ qq ] )                        \
-          /* Here is a full node. Just explore it */                     \
-          distance = mlib_search_quadrant_##IMAGE_TYPE##_3(              \
-            node->contents.quadrants[ qq ],                              \
-            distance, &found_color, c[ 0 ], c[ 1 ], c[ 2 ], p );         \
-      }                                                                  \
-    }                                                                    \
-  }                                                                      \
-}
-
-/***************************************************************/
-#define BINARY_TREE_EXPLORE_LEFT_4( POSITION, IMAGE_TYPE,                \
-  FIRST_NEIBOUR, SECOND_NEIBOUR, THIRD_NEIBOUR, SUBSTRACTION, SHIFT )    \
-{                                                                        \
-  if( distance >                                                         \
-    ( ( ( c[ POSITION ] - position[ POSITION ] ) *                       \
-    ( c[ POSITION ] - position[ POSITION ] ) ) >> SHIFT ) )              \
-  {                                                                      \
-    if( distance <= ( ( c[ POSITION ] * c[ POSITION ] ) >> SHIFT ) )     \
-    {                                                                    \
-      if( distance <= ( ( ( c[ POSITION ] + current_size -               \
-        position[ POSITION ] ) *                                         \
-        ( c[ POSITION ] + current_size -                                 \
-          position[ POSITION ] ) ) >> SHIFT ) )                          \
-      {                                                                  \
-        mlib_s32 qq = q ^ ( 1 << POSITION );                             \
-                                                                         \
-        check_neibours[ FIRST_NEIBOUR ] += 1;                            \
-        check_neibours[ SECOND_NEIBOUR ] += 1;                           \
-        check_neibours[ THIRD_NEIBOUR ] += 1;                            \
-        if( node->tag & ( 1 << qq ) )                                    \
-        {                                                                \
-          /* Here is another color cell.                                 \
-             Check the distance */                                       \
-          mlib_s32 new_found_color =                                     \
-            node->contents.index[ qq ];                                  \
-          mlib_u32 newdistance = FIND_DISTANCE_4( c[ 0 ],                \
-            p[ 0 ][ new_found_color ] - SUBSTRACTION, c[ 1 ],            \
-            p[ 1 ][ new_found_color ] - SUBSTRACTION, c[ 2 ],            \
-            p[ 2 ][ new_found_color ] - SUBSTRACTION, c[ 3 ],            \
-            p[ 3 ][ new_found_color ] - SUBSTRACTION, SHIFT );           \
-                                                                         \
-          if( newdistance < distance )                                   \
-          {                                                              \
-            found_color = new_found_color;                               \
-            distance = newdistance;                                      \
-          }                                                              \
-        }                                                                \
-        else if( node->contents.quadrants[ qq ] )                        \
-          /* Only a part of quadrant needs checking */                   \
-          distance =                                                     \
-            mlib_search_quadrant_part_to_right_##IMAGE_TYPE##_4(         \
-              node->contents.quadrants[ qq ],                            \
-              distance, &found_color, c, p,                              \
-              position[ POSITION ] - current_size, pass - 1, POSITION ); \
-      }                                                                  \
-      else /* Check whole quadrant */                                    \
-      {                                                                  \
-        mlib_s32 qq = q ^ ( 1 << POSITION );                             \
-                                                                         \
-        check_neibours[ FIRST_NEIBOUR ] += 2;                            \
-        check_neibours[ SECOND_NEIBOUR ] += 2;                           \
-        check_neibours[ THIRD_NEIBOUR ] += 2;                            \
-        continue_up = 1;                                                 \
-        if( node->tag & ( 1 << qq ) )                                    \
-        {                                                                \
-          /* Here is another color cell.                                 \
-             Check the distance */                                       \
-          mlib_s32 new_found_color =                                     \
-            node->contents.index[ qq ];                                  \
-          mlib_u32 newdistance = FIND_DISTANCE_4( c[ 0 ],                \
-            p[ 0 ][ new_found_color ] - SUBSTRACTION, c[ 1 ],            \
-            p[ 1 ][ new_found_color ] - SUBSTRACTION, c[ 2 ],            \
-            p[ 2 ][ new_found_color ] - SUBSTRACTION, c[ 3 ],            \
-            p[ 3 ][ new_found_color ] - SUBSTRACTION, SHIFT );           \
-                                                                         \
-          if( newdistance < distance )                                   \
-          {                                                              \
-            found_color = new_found_color;                               \
-            distance = newdistance;                                      \
-          }                                                              \
-        }                                                                \
-        else if( node->contents.quadrants[ qq ] )                        \
-          /* Here is a full node. Just explore it */                     \
-          distance = mlib_search_quadrant_##IMAGE_TYPE##_4(              \
-            node->contents.quadrants[ qq ],                              \
-            distance, &found_color, c[ 0 ], c[ 1 ], c[ 2 ], c[ 3 ], p ); \
-      }                                                                  \
-    }                                                                    \
-    else                                                                 \
-    {                                                                    \
-      if( !( position[ POSITION ] - current_size ) )                     \
-      {                                                                  \
-        mlib_s32 qq = q ^ ( 1 << POSITION );                             \
-                                                                         \
-        check_neibours[ FIRST_NEIBOUR ] += 1;                            \
-        check_neibours[ SECOND_NEIBOUR ] += 1;                           \
-        check_neibours[ THIRD_NEIBOUR ] += 1;                            \
-        if( node->tag & ( 1 << qq ) )                                    \
-        {                                                                \
-          /* Here is another color cell.                                 \
-             Check the distance */                                       \
-          mlib_s32 new_found_color =                                     \
-            node->contents.index[ qq ];                                  \
-          mlib_u32 newdistance = FIND_DISTANCE_4( c[ 0 ],                \
-            p[ 0 ][ new_found_color ] - SUBSTRACTION, c[ 1 ],            \
-            p[ 1 ][ new_found_color ] - SUBSTRACTION, c[ 2 ],            \
-            p[ 2 ][ new_found_color ] - SUBSTRACTION, c[ 3 ],            \
-            p[ 3 ][ new_found_color ] - SUBSTRACTION, SHIFT );           \
-                                                                         \
-          if( newdistance < distance )                                   \
-          {                                                              \
-            found_color = new_found_color;                               \
-            distance = newdistance;                                      \
-          }                                                              \
-        }                                                                \
-        else if( node->contents.quadrants[ qq ] )                        \
-          /* Only a part of quadrant needs checking */                   \
-          distance =                                                     \
-            mlib_search_quadrant_part_to_right_##IMAGE_TYPE##_4(         \
-              node->contents.quadrants[ qq ],                            \
-              distance, &found_color, c, p,                              \
-              position[ POSITION ] - current_size, pass - 1, POSITION ); \
-      }                                                                  \
-      else                                                               \
-      {                                                                  \
-        mlib_s32 qq = q ^ ( 1 << POSITION );                             \
-                                                                         \
-        check_neibours[ FIRST_NEIBOUR ] += 2;                            \
-        check_neibours[ SECOND_NEIBOUR ] += 2;                           \
-        check_neibours[ THIRD_NEIBOUR ] += 2;                            \
-        continue_up = 1;                                                 \
-        if( node->tag & ( 1 << qq ) )                                    \
-        {                                                                \
-          /* Here is another color cell.                                 \
-             Check the distance */                                       \
-          mlib_s32 new_found_color =                                     \
-            node->contents.index[ qq ];                                  \
-          mlib_u32 newdistance = FIND_DISTANCE_4( c[ 0 ],                \
-            p[ 0 ][ new_found_color ] - SUBSTRACTION, c[ 1 ],            \
-            p[ 1 ][ new_found_color ] - SUBSTRACTION, c[ 2 ],            \
-            p[ 2 ][ new_found_color ] - SUBSTRACTION, c[ 3 ],            \
-            p[ 3 ][ new_found_color ] - SUBSTRACTION, SHIFT );           \
-                                                                         \
-          if( newdistance < distance )                                   \
-          {                                                              \
-            found_color = new_found_color;                               \
-            distance = newdistance;                                      \
-          }                                                              \
-        }                                                                \
-        else if( node->contents.quadrants[ qq ] )                        \
-          /* Here is a full node. Just explore it */                     \
-          distance = mlib_search_quadrant_##IMAGE_TYPE##_4(              \
-            node->contents.quadrants[ qq ],                              \
-            distance, &found_color, c[ 0 ], c[ 1 ], c[ 2 ], c[ 3 ], p ); \
-      }                                                                  \
-    }                                                                    \
-  }                                                                      \
-}
-
-/***************************************************************/
-#define CHECK_QUADRANT_U8_3( qq )                               \
-{                                                               \
-  if( node->tag & ( 1 << qq ) )                                 \
-  {                                                             \
-    /* Here is another color cell. Check the distance */        \
-    mlib_s32 new_found_color = node->contents.index[ qq ];      \
-    mlib_u32 newdistance = FIND_DISTANCE_3( c[ 0 ],             \
-      p[ 0 ][ new_found_color ], c[ 1 ],                        \
-      p[ 1 ][ new_found_color ], c[ 2 ],                        \
-      p[ 2 ][ new_found_color ], 0 );                           \
-                                                                \
-    if( newdistance < distance )                                \
-    {                                                           \
-      found_color = new_found_color;                            \
-      distance = newdistance;                                   \
-    }                                                           \
-  }                                                             \
-  else if( node->contents.quadrants[ qq ] )                     \
-    /* Here is a full node. Just explore it all */              \
-    distance = mlib_search_quadrant_U8_3(                       \
-      node->contents.quadrants[ qq ], distance, &found_color,   \
-      c[ 0 ], c[ 1 ], c[ 2 ], p );                              \
-/* Else there is just an empty cell */                          \
-}
-
-/***************************************************************/
-#define CHECK_QUADRANT_S16_3( qq )                              \
-{                                                               \
-  if( node->tag & ( 1 << qq ) )                                 \
-  {                                                             \
-    /* Here is another color cell. Check the distance */        \
-    mlib_s32 new_found_color = node->contents.index[ qq ];      \
-    mlib_u32 palc0, palc1, palc2, newdistance;                  \
-                                                                \
-    palc0 = p[ 0 ][ new_found_color ] - MLIB_S16_MIN;           \
-    palc1 = p[ 1 ][ new_found_color ] - MLIB_S16_MIN;           \
-    palc2 = p[ 2 ][ new_found_color ] - MLIB_S16_MIN;           \
-                                                                \
-    newdistance = FIND_DISTANCE_3( c[ 0 ], palc0,               \
-      c[ 1 ], palc1,                                            \
-      c[ 2 ], palc2, 2 );                                       \
-                                                                \
-    if( newdistance < distance )                                \
-    {                                                           \
-      found_color = new_found_color;                            \
-      distance = newdistance;                                   \
-    }                                                           \
-  }                                                             \
-  else if( node->contents.quadrants[ qq ] )                     \
-    /* Here is a full node. Just explore it all */              \
-    distance = mlib_search_quadrant_S16_3(                      \
-      node->contents.quadrants[ qq ], distance, &found_color,   \
-      c[ 0 ], c[ 1 ], c[ 2 ], p );                              \
-/* Else there is just an empty cell */                          \
-}
-
-/***************************************************************/
-#define BINARY_TREE_SEARCH_3( SOURCE_IMAGE, POINTER_TYPE, BITS,              \
-  COLOR_MAX, SUBTRACTION, POINTER_SHIFT, STEP, SHIFT )                       \
-{                                                                            \
-  const POINTER_TYPE *channels[ 3 ], *p[ 3 ];                                \
-  mlib_u32 c[ 3 ];                                                           \
-  mlib_s32 j;                                                                \
-                                                                             \
-  p[ 0 ] = s->lut[ 0 ];                                                      \
-  p[ 1 ] = s->lut[ 1 ];                                                      \
-  p[ 2 ] = s->lut[ 2 ];                                                      \
-  channels[ 0 ] = src + POINTER_SHIFT;                                       \
-  channels[ 1 ] = src + 1 + POINTER_SHIFT;                                   \
-  channels[ 2 ] = src + 2 + POINTER_SHIFT;                                   \
-                                                                             \
-  for( j = 0; j < length; j++ )                                              \
-  {                                                                          \
-    mlib_s32 pass = BITS - 1;                                                \
-    mlib_u32 position[ 3 ] = { 0, 0, 0 };                                    \
-    mlib_s32 we_found_it = 0;                                                \
-    struct lut_node_3 *node = s->table;                                      \
-    /* Stack pointer pointers to the first free element of stack. */         \
-    /* The node we are in is in the `node' */                                \
-    struct                                                                   \
-    {                                                                        \
-      struct lut_node_3 *node;                                               \
-      mlib_s32 q;                                                            \
-    } stack[ BITS ];                                                         \
-    mlib_s32 stack_pointer = 0;                                              \
-                                                                             \
-    c[ 0 ] = *channels[ 0 ] - SUBTRACTION;                                   \
-    c[ 1 ] = *channels[ 1 ] - SUBTRACTION;                                   \
-    c[ 2 ] = *channels[ 2 ] - SUBTRACTION;                                   \
-                                                                             \
-    do                                                                       \
-    {                                                                        \
-      mlib_s32 q;                                                            \
-      mlib_u32 current_size = 1 << pass;                                     \
-                                                                             \
-      q = ( ( c[ 0 ] >> pass ) & 1 ) |                                       \
-        ( ( ( c[ 1 ] << 1 ) >> pass ) & 2 ) |                                \
-        ( ( ( c[ 2 ] << 2 ) >> pass ) & 4 );                                 \
-                                                                             \
-      position[ 0 ] |= c[ 0 ] & current_size;                                \
-      position[ 1 ] |= c[ 1 ] & current_size;                                \
-      position[ 2 ] |= c[ 2 ] & current_size;                                \
-                                                                             \
-      if( node->tag & ( 1 << q ) )                                           \
-      {                                                                      \
-        /*                                                                   \
-          Here is a cell with one color. We need to be sure it's             \
-          the one that is the closest to our color                           \
-        */                                                                   \
-        mlib_s32 palindex = node->contents.index[ q ];                       \
-        mlib_u32 palc[ 3 ];                                                  \
-        mlib_s32 identical;                                                  \
-                                                                             \
-        palc[ 0 ] = p[ 0 ][ palindex ] - SUBTRACTION;                        \
-        palc[ 1 ] = p[ 1 ][ palindex ] - SUBTRACTION;                        \
-        palc[ 2 ] = p[ 2 ][ palindex ] - SUBTRACTION;                        \
-                                                                             \
-        identical = ( palc[ 0 ] - c[ 0 ] ) | ( palc[ 1 ] - c[ 1 ] ) |        \
-          ( palc[ 2 ] - c[ 2 ] );                                            \
-                                                                             \
-        if( !identical || BITS - pass == bits )                              \
-        {                                                                    \
-          /* Oh, here it is :) */                                            \
-          dst[ j ] = palindex + s->offset;                                   \
-          we_found_it = 1;                                                   \
-        }                                                                    \
-        else                                                                 \
-        {                                                                    \
-          mlib_u32 distance;                                                 \
-          /* First index is the channel, second is the number of the         \
-             side */                                                         \
-          mlib_s32 found_color;                                              \
-          mlib_s32 continue_up;                                              \
-                                                                             \
-          distance = FIND_DISTANCE_3( c[ 0 ], palc[ 0 ],                     \
-            c[ 1 ], palc[ 1 ], c[ 2 ], palc[ 2 ], SHIFT );                   \
-          found_color = palindex;                                            \
-                                                                             \
-          do                                                                 \
-          {                                                                  \
-            mlib_s32 check_corner;                                           \
-                                                                             \
-            /*                                                               \
-              Neibours are enumerated in a cicle:                            \
-              0 - between quadrants 0 and 1,                                 \
-              1 - between quadrants 1 and 2 and                              \
-              2 - between quadrants 2 and 0                                  \
-            */                                                               \
-            mlib_s32 check_neibours[ 3 ];                                    \
-                                                                             \
-            /*                                                               \
-              Others are three two neibour quadrants                         \
-                                                                             \
-              Side number is [ <number of the coordinate >][ <the bit        \
-              in the quadrant number of the corner, corresponding to         \
-              this coordinate> ], e.g. 2 is 0..010b, so the sides it has     \
-              near are:                                                      \
-              [ 0 (coordinate number) ][ 0 (bit 0 in the number) ]           \
-              [ 1 (coordinate number) ][ 1 (bit 1 in the number) ]           \
-                                                                             \
-              Now we can look in the three nearest quadrants. Do             \
-              we really need it ? Check it.                                  \
-            */                                                               \
-                                                                             \
-            check_corner = check_neibours[ 0 ] = check_neibours[ 1 ] =       \
-              check_neibours[ 2 ] = 0;                                       \
-            continue_up = 0;                                                 \
-                                                                             \
-            if( q & 1 )                                                      \
-            {                                                                \
-              BINARY_TREE_EXPLORE_LEFT_3( 0, SOURCE_IMAGE, 2, 0,             \
-                SUBTRACTION, SHIFT );                                        \
-            }                                                                \
-            else                                                             \
-            {                                                                \
-              BINARY_TREE_EXPLORE_RIGHT_3( 0, COLOR_MAX, SOURCE_IMAGE, 2, 0, \
-                SUBTRACTION, SHIFT );                                        \
-            }                                                                \
-                                                                             \
-            if( q & 2 )                                                      \
-            {                                                                \
-              BINARY_TREE_EXPLORE_LEFT_3( 1, SOURCE_IMAGE, 0, 1,             \
-                SUBTRACTION, SHIFT );                                        \
-            }                                                                \
-            else                                                             \
-            {                                                                \
-              BINARY_TREE_EXPLORE_RIGHT_3( 1, COLOR_MAX, SOURCE_IMAGE, 0, 1, \
-                SUBTRACTION, SHIFT );                                        \
-            }                                                                \
-                                                                             \
-            if( q & 4 )                                                      \
-            {                                                                \
-              BINARY_TREE_EXPLORE_LEFT_3( 2, SOURCE_IMAGE, 1, 2,             \
-                SUBTRACTION, SHIFT );                                        \
-            }                                                                \
-            else                                                             \
-            {                                                                \
-              BINARY_TREE_EXPLORE_RIGHT_3( 2, COLOR_MAX, SOURCE_IMAGE, 1, 2, \
-                SUBTRACTION, SHIFT );                                        \
-            }                                                                \
-                                                                             \
-            if( check_neibours[ 0 ] >= 2 )                                   \
-            {                                                                \
-              mlib_s32 qq = q ^ 3;                                           \
-              CHECK_QUADRANT_##SOURCE_IMAGE##_3( qq );                       \
-            }                                                                \
-                                                                             \
-            if( check_neibours[ 1 ] >= 2 )                                   \
-            {                                                                \
-              mlib_s32 qq = q ^ 6;                                           \
-              CHECK_QUADRANT_##SOURCE_IMAGE##_3( qq );                       \
-            }                                                                \
-                                                                             \
-            if( check_neibours[ 2 ] >= 2 )                                   \
-            {                                                                \
-              mlib_s32 qq = q ^ 5;                                           \
-              CHECK_QUADRANT_##SOURCE_IMAGE##_3( qq );                       \
-            }                                                                \
-                                                                             \
-            if( check_corner >= 3 )                                          \
-            {                                                                \
-              mlib_s32 qq = q ^ 7;                                           \
-              CHECK_QUADRANT_##SOURCE_IMAGE##_3( qq );                       \
-            }                                                                \
-                                                                             \
-            if( q & 1 )                                                      \
-            {                                                                \
-              BINARY_TREE_SEARCH_RIGHT( 0, COLOR_MAX, SHIFT );               \
-            }                                                                \
-            else                                                             \
-            {                                                                \
-              BINARY_TREE_SEARCH_LEFT( 0, SHIFT );                           \
-            }                                                                \
-                                                                             \
-            if( q & 2 )                                                      \
-            {                                                                \
-              BINARY_TREE_SEARCH_RIGHT( 1, COLOR_MAX, SHIFT );               \
-            }                                                                \
-            else                                                             \
-            {                                                                \
-              BINARY_TREE_SEARCH_LEFT( 1, SHIFT );                           \
-            }                                                                \
-                                                                             \
-            if( q & 4 )                                                      \
-            {                                                                \
-              BINARY_TREE_SEARCH_RIGHT( 2, COLOR_MAX, SHIFT );               \
-            }                                                                \
-            else                                                             \
-            {                                                                \
-              BINARY_TREE_SEARCH_LEFT( 2, SHIFT );                           \
-            }                                                                \
-                                                                             \
-            position[ 0 ] &= ~( c[ 0 ] & current_size );                     \
-            position[ 1 ] &= ~( c[ 1 ] & current_size );                     \
-            position[ 2 ] &= ~( c[ 2 ] & current_size );                     \
-                                                                             \
-            current_size <<= 1;                                              \
-                                                                             \
-            pass++;                                                          \
-                                                                             \
-            stack_pointer--;                                                 \
-            q = stack[ stack_pointer ].q;                                    \
-            node = stack[ stack_pointer ].node;                              \
-          } while( continue_up );                                            \
-                                                                             \
-          dst[ j ] = found_color + s->offset;                                \
-                                                                             \
-          we_found_it = 1;                                                   \
-        }                                                                    \
-      }                                                                      \
-      else if( node->contents.quadrants[ q ] )                               \
-      {                                                                      \
-        /* Descend one level */                                              \
-        stack[ stack_pointer ].node = node;                                  \
-        stack[ stack_pointer++ ].q = q;                                      \
-        node = node->contents.quadrants[ q ];                                \
-      }                                                                      \
-      else                                                                   \
-      {                                                                      \
-        /* Found the empty quadrant. Look around */                          \
-        mlib_u32 distance = MLIB_U32_MAX;                                    \
-        mlib_s32 found_color;                                                \
-        mlib_s32 continue_up;                                                \
-                                                                             \
-        /*                                                                   \
-          As we had come to this level, it is warranted that there           \
-          are other points on this level near the empty quadrant             \
-        */                                                                   \
-        do                                                                   \
-        {                                                                    \
-          mlib_s32 check_corner;                                             \
-          mlib_s32 check_neibours[ 3 ];                                      \
-                                                                             \
-          check_corner = check_neibours[ 0 ] = check_neibours[ 1 ] =         \
-            check_neibours[ 2 ] = 0;                                         \
-          continue_up = 0;                                                   \
-                                                                             \
-          if( q & 1 )                                                        \
-          {                                                                  \
-            BINARY_TREE_EXPLORE_LEFT_3( 0, SOURCE_IMAGE, 2, 0,               \
-              SUBTRACTION, SHIFT );                                          \
-          }                                                                  \
-          else                                                               \
-          {                                                                  \
-            BINARY_TREE_EXPLORE_RIGHT_3( 0, COLOR_MAX, SOURCE_IMAGE, 2, 0,   \
-              SUBTRACTION, SHIFT );                                          \
-          }                                                                  \
-                                                                             \
-          if( q & 2 )                                                        \
-          {                                                                  \
-            BINARY_TREE_EXPLORE_LEFT_3( 1, SOURCE_IMAGE, 0, 1,               \
-              SUBTRACTION, SHIFT );                                          \
-          }                                                                  \
-          else                                                               \
-          {                                                                  \
-            BINARY_TREE_EXPLORE_RIGHT_3( 1, COLOR_MAX, SOURCE_IMAGE, 0, 1,   \
-              SUBTRACTION, SHIFT );                                          \
-          }                                                                  \
-                                                                             \
-          if( q & 4 )                                                        \
-          {                                                                  \
-            BINARY_TREE_EXPLORE_LEFT_3( 2, SOURCE_IMAGE, 1, 2,               \
-              SUBTRACTION, SHIFT );                                          \
-          }                                                                  \
-          else                                                               \
-          {                                                                  \
-            BINARY_TREE_EXPLORE_RIGHT_3( 2, COLOR_MAX, SOURCE_IMAGE, 1, 2,   \
-              SUBTRACTION, SHIFT );                                          \
-          }                                                                  \
-                                                                             \
-          if( check_neibours[ 0 ] >= 2 )                                     \
-          {                                                                  \
-            mlib_s32 qq = q ^ 3;                                             \
-            CHECK_QUADRANT_##SOURCE_IMAGE##_3( qq );                         \
-          }                                                                  \
-                                                                             \
-          if( check_neibours[ 1 ] >= 2 )                                     \
-          {                                                                  \
-            mlib_s32 qq = q ^ 6;                                             \
-            CHECK_QUADRANT_##SOURCE_IMAGE##_3( qq );                         \
-          }                                                                  \
-                                                                             \
-          if( check_neibours[ 2 ] >= 2 )                                     \
-          {                                                                  \
-            mlib_s32 qq = q ^ 5;                                             \
-            CHECK_QUADRANT_##SOURCE_IMAGE##_3( qq );                         \
-          }                                                                  \
-                                                                             \
-          if( check_corner >= 3 )                                            \
-          {                                                                  \
-            mlib_s32 qq = q ^ 7;                                             \
-            CHECK_QUADRANT_##SOURCE_IMAGE##_3( qq );                         \
-          }                                                                  \
-                                                                             \
-          if( q & 1 )                                                        \
-          {                                                                  \
-            BINARY_TREE_SEARCH_RIGHT( 0, COLOR_MAX, SHIFT );                 \
-          }                                                                  \
-          else                                                               \
-          {                                                                  \
-            BINARY_TREE_SEARCH_LEFT( 0, SHIFT );                             \
-          }                                                                  \
-                                                                             \
-          if( q & 2 )                                                        \
-          {                                                                  \
-            BINARY_TREE_SEARCH_RIGHT( 1, COLOR_MAX, SHIFT );                 \
-          }                                                                  \
-          else                                                               \
-          {                                                                  \
-            BINARY_TREE_SEARCH_LEFT( 1, SHIFT );                             \
-          }                                                                  \
-                                                                             \
-          if( q & 4 )                                                        \
-          {                                                                  \
-            BINARY_TREE_SEARCH_RIGHT( 2, COLOR_MAX, SHIFT );                 \
-          }                                                                  \
-          else                                                               \
-          {                                                                  \
-            BINARY_TREE_SEARCH_LEFT( 2, SHIFT );                             \
-          }                                                                  \
-                                                                             \
-          position[ 0 ] &= ~( c[ 0 ] & current_size );                       \
-          position[ 1 ] &= ~( c[ 1 ] & current_size );                       \
-          position[ 2 ] &= ~( c[ 2 ] & current_size );                       \
-                                                                             \
-          current_size <<= 1;                                                \
-                                                                             \
-          pass++;                                                            \
-                                                                             \
-          stack_pointer--;                                                   \
-          q = stack[ stack_pointer ].q;                                      \
-          node = stack[ stack_pointer ].node;                                \
-        } while( continue_up );                                              \
-                                                                             \
-        dst[ j ] = found_color + s->offset;                                  \
-        we_found_it = 1;                                                     \
-      }                                                                      \
-                                                                             \
-      pass--;                                                                \
-                                                                             \
-    } while( !we_found_it );                                                 \
-                                                                             \
-    channels[ 0 ] += STEP;                                                   \
-    channels[ 1 ] += STEP;                                                   \
-    channels[ 2 ] += STEP;                                                   \
-  }                                                                          \
-}
-
-/***************************************************************/
-#define CHECK_QUADRANT_U8_4( qq )                               \
-{                                                               \
-  if( node->tag & ( 1 << qq ) )                                 \
-  {                                                             \
-    /* Here is another color cell. Check the distance */        \
-    mlib_s32 new_found_color = node->contents.index[ qq ];      \
-    mlib_u32 newdistance = FIND_DISTANCE_4( c[ 0 ],             \
-      p[ 0 ][ new_found_color ], c[ 1 ],                        \
-      p[ 1 ][ new_found_color ], c[ 2 ],                        \
-      p[ 2 ][ new_found_color ], c[ 3 ],                        \
-      p[ 3 ][ new_found_color ], 0 );                           \
-                                                                \
-    if( newdistance < distance )                                \
-    {                                                           \
-      found_color = new_found_color;                            \
-      distance = newdistance;                                   \
-    }                                                           \
-  }                                                             \
-  else if( node->contents.quadrants[ qq ] )                     \
-    /* Here is a full node. Just explore it all */              \
-    distance = mlib_search_quadrant_U8_4(                       \
-      node->contents.quadrants[ qq ], distance, &found_color,   \
-      c[ 0 ], c[ 1 ], c[ 2 ], c[ 3 ], p );                      \
-/* Else there is just an empty cell */                          \
-}
-
-/***************************************************************/
-#define CHECK_QUADRANT_S16_4( qq )                              \
-{                                                               \
-  if( node->tag & ( 1 << qq ) )                                 \
-  {                                                             \
-    /* Here is another color cell. Check the distance */        \
-    mlib_s32 new_found_color = node->contents.index[ qq ];      \
-    mlib_u32 palc0, palc1, palc2, palc3, newdistance;           \
-                                                                \
-    palc0 = p[ 0 ][ new_found_color ] - MLIB_S16_MIN;           \
-    palc1 = p[ 1 ][ new_found_color ] - MLIB_S16_MIN;           \
-    palc2 = p[ 2 ][ new_found_color ] - MLIB_S16_MIN;           \
-    palc3 = p[ 3 ][ new_found_color ] - MLIB_S16_MIN;           \
-                                                                \
-    newdistance = FIND_DISTANCE_4( c[ 0 ], palc0,               \
-      c[ 1 ], palc1,                                            \
-      c[ 2 ], palc2,                                            \
-      c[ 3 ], palc3, 2 );                                       \
-                                                                \
-    if( newdistance < distance )                                \
-    {                                                           \
-      found_color = new_found_color;                            \
-      distance = newdistance;                                   \
-    }                                                           \
-  }                                                             \
-  else if( node->contents.quadrants[ qq ] )                     \
-    /* Here is a full node. Just explore it all */              \
-    distance = mlib_search_quadrant_S16_4(                      \
-      node->contents.quadrants[ qq ], distance, &found_color,   \
-      c[ 0 ], c[ 1 ], c[ 2 ], c[ 3 ], p );                      \
-/* Else there is just an empty cell */                          \
-}
-
-/***************************************************************/
-#define BINARY_TREE_SEARCH_4( SOURCE_IMAGE, POINTER_TYPE, BITS,               \
-  COLOR_MAX, SUBTRACTION, SHIFT )                                             \
-{                                                                             \
-  const POINTER_TYPE *channels[ 4 ], *p[ 4 ];                                 \
-  mlib_u32 c[ 4 ];                                                            \
-  mlib_s32 j;                                                                 \
-                                                                              \
-  p[ 0 ] = s->lut[ 0 ];                                                       \
-  p[ 1 ] = s->lut[ 1 ];                                                       \
-  p[ 2 ] = s->lut[ 2 ];                                                       \
-  p[ 3 ] = s->lut[ 3 ];                                                       \
-  channels[ 0 ] = src;                                                        \
-  channels[ 1 ] = src + 1;                                                    \
-  channels[ 2 ] = src + 2;                                                    \
-  channels[ 3 ] = src + 3;                                                    \
-                                                                              \
-  for( j = 0; j < length; j++ )                                               \
-  {                                                                           \
-    mlib_s32 pass = BITS - 1;                                                 \
-    mlib_u32 position[ 4 ] = { 0, 0, 0, 0 };                                  \
-    mlib_s32 we_found_it = 0;                                                 \
-    struct lut_node_4 *node = s->table;                                       \
-    /* Stack pointer pointers to the first free element of stack. */          \
-    /* The node we are in is in the `node' */                                 \
-    struct                                                                    \
-    {                                                                         \
-      struct lut_node_4 *node;                                                \
-      mlib_s32 q;                                                             \
-    } stack[ BITS ];                                                          \
-    mlib_s32 stack_pointer = 0;                                               \
-                                                                              \
-    c[ 0 ] = *channels[ 0 ] - SUBTRACTION;                                    \
-    c[ 1 ] = *channels[ 1 ] - SUBTRACTION;                                    \
-    c[ 2 ] = *channels[ 2 ] - SUBTRACTION;                                    \
-    c[ 3 ] = *channels[ 3 ] - SUBTRACTION;                                    \
-                                                                              \
-    do                                                                        \
-    {                                                                         \
-      mlib_s32 q;                                                             \
-      mlib_u32 current_size = 1 << pass;                                      \
-                                                                              \
-      q = ( ( c[ 0 ] >> pass ) & 1 ) |                                        \
-        ( ( ( c[ 1 ] << 1 ) >> pass ) & 2 ) |                                 \
-        ( ( ( c[ 2 ] << 2 ) >> pass ) & 4 ) |                                 \
-        ( ( ( c[ 3 ] << 3 ) >> pass ) & 8 );                                  \
-                                                                              \
-      position[ 0 ] |= c[ 0 ] & current_size;                                 \
-      position[ 1 ] |= c[ 1 ] & current_size;                                 \
-      position[ 2 ] |= c[ 2 ] & current_size;                                 \
-      position[ 3 ] |= c[ 3 ] & current_size;                                 \
-                                                                              \
-      if( node->tag & ( 1 << q ) )                                            \
-      {                                                                       \
-        /*                                                                    \
-          Here is a cell with one color. We need to be sure it's              \
-          the one that is the closest to our color                            \
-        */                                                                    \
-        mlib_s32 palindex = node->contents.index[ q ];                        \
-        mlib_u32 palc[ 4 ];                                                   \
-        mlib_s32 identical;                                                   \
-                                                                              \
-        palc[ 0 ] = p[ 0 ][ palindex ] - SUBTRACTION;                         \
-        palc[ 1 ] = p[ 1 ][ palindex ] - SUBTRACTION;                         \
-        palc[ 2 ] = p[ 2 ][ palindex ] - SUBTRACTION;                         \
-        palc[ 3 ] = p[ 3 ][ palindex ] - SUBTRACTION;                         \
-                                                                              \
-        identical = ( palc[ 0 ] - c[ 0 ] ) | ( palc[ 1 ] - c[ 1 ] ) |         \
-          ( palc[ 2 ] - c[ 2 ] ) | ( palc[ 3 ] - c[ 3 ] );                    \
-                                                                              \
-        if( !identical || BITS - pass == bits )                               \
-        {                                                                     \
-          /* Oh, here it is :) */                                             \
-          dst[ j ] = palindex + s->offset;                                    \
-          we_found_it = 1;                                                    \
-        }                                                                     \
-        else                                                                  \
-        {                                                                     \
-          mlib_u32 distance;                                                  \
-          /* First index is the channel, second is the number of the          \
-             side */                                                          \
-          mlib_s32 found_color;                                               \
-          mlib_s32 continue_up;                                               \
-                                                                              \
-          distance = FIND_DISTANCE_4( c[ 0 ], palc[ 0 ],                      \
-            c[ 1 ], palc[ 1 ], c[ 2 ], palc[ 2 ], c[ 3 ], palc[ 3 ], SHIFT ); \
-          found_color = palindex;                                             \
-                                                                              \
-          do                                                                  \
-          {                                                                   \
-            mlib_s32 check_corner;                                            \
-            mlib_s32 check_neibours[ 6 ];                                     \
-            mlib_s32 check_far_neibours[ 4 ];                                 \
-                                                                              \
-            /*                                                                \
-              Check neibours: quadrants that are different by 2 bits          \
-              from the quadrant, that we are in:                              \
-              3 -  0                                                          \
-              5 -  1                                                          \
-              6 -  2                                                          \
-              9 -  3                                                          \
-              10 - 4                                                          \
-              12 - 5                                                          \
-              Far quadrants: different by 3 bits:                             \
-              7  - 0                                                          \
-              11 - 1                                                          \
-              13 - 2                                                          \
-              14 - 3                                                          \
-            */                                                                \
-                                                                              \
-            check_neibours[ 0 ] = check_neibours[ 1 ] =                       \
-              check_neibours[ 2 ] = check_neibours[ 3 ] =                     \
-              check_neibours[ 4 ] = check_neibours[ 5 ] = 0;                  \
-            continue_up = 0;                                                  \
-                                                                              \
-            if( q & 1 )                                                       \
-            {                                                                 \
-              BINARY_TREE_EXPLORE_LEFT_4( 0, SOURCE_IMAGE, 0, 1, 3,           \
-                SUBTRACTION, SHIFT );                                         \
-            }                                                                 \
-            else                                                              \
-            {                                                                 \
-              BINARY_TREE_EXPLORE_RIGHT_4( 0, COLOR_MAX, SOURCE_IMAGE,        \
-                0, 1, 3, SUBTRACTION, SHIFT );                                \
-            }                                                                 \
-                                                                              \
-            if( q & 2 )                                                       \
-            {                                                                 \
-              BINARY_TREE_EXPLORE_LEFT_4( 1, SOURCE_IMAGE, 0, 2, 4,           \
-                SUBTRACTION, SHIFT );                                         \
-            }                                                                 \
-            else                                                              \
-            {                                                                 \
-              BINARY_TREE_EXPLORE_RIGHT_4( 1, COLOR_MAX, SOURCE_IMAGE,        \
-                0, 2, 4, SUBTRACTION, SHIFT );                                \
-            }                                                                 \
-                                                                              \
-            if( q & 4 )                                                       \
-            {                                                                 \
-              BINARY_TREE_EXPLORE_LEFT_4( 2, SOURCE_IMAGE, 1, 2, 5,           \
-                SUBTRACTION, SHIFT );                                         \
-            }                                                                 \
-            else                                                              \
-            {                                                                 \
-              BINARY_TREE_EXPLORE_RIGHT_4( 2, COLOR_MAX, SOURCE_IMAGE,        \
-                1, 2, 5, SUBTRACTION, SHIFT );                                \
-            }                                                                 \
-                                                                              \
-            if( q & 8 )                                                       \
-            {                                                                 \
-              BINARY_TREE_EXPLORE_LEFT_4( 3, SOURCE_IMAGE, 3, 4, 5,           \
-                SUBTRACTION, SHIFT );                                         \
-            }                                                                 \
-            else                                                              \
-            {                                                                 \
-              BINARY_TREE_EXPLORE_RIGHT_4( 3, COLOR_MAX, SOURCE_IMAGE,        \
-                3, 4, 5, SUBTRACTION, SHIFT );                                \
-            }                                                                 \
-                                                                              \
-            check_far_neibours[ 0 ] = check_neibours[ 0 ] +                   \
-              check_neibours[ 1 ] + check_neibours[ 2 ];                      \
-            check_far_neibours[ 1 ] = check_neibours[ 0 ] +                   \
-              check_neibours[ 3 ] + check_neibours[ 4 ];                      \
-            check_far_neibours[ 2 ] = check_neibours[ 1 ] +                   \
-              check_neibours[ 3 ] + check_neibours[ 5 ];                      \
-            check_far_neibours[ 3 ] = check_neibours[ 2 ] +                   \
-              check_neibours[ 4 ] + check_neibours[ 5 ];                      \
-                                                                              \
-            check_corner = check_far_neibours[ 0 ] +                          \
-              check_far_neibours[ 1 ] +                                       \
-              check_far_neibours[ 2 ] +                                       \
-              check_far_neibours[ 3 ];                                        \
-                                                                              \
-            if( check_neibours[ 0 ] >= 2 )                                    \
-            {                                                                 \
-              mlib_s32 qq = q ^ 3;                                            \
-              CHECK_QUADRANT_##SOURCE_IMAGE##_4( qq );                        \
-            }                                                                 \
-                                                                              \
-            if( check_neibours[ 1 ] >= 2 )                                    \
-            {                                                                 \
-              mlib_s32 qq = q ^ 5;                                            \
-              CHECK_QUADRANT_##SOURCE_IMAGE##_4( qq );                        \
-            }                                                                 \
-                                                                              \
-            if( check_neibours[ 2 ] >= 2 )                                    \
-            {                                                                 \
-              mlib_s32 qq = q ^ 6;                                            \
-              CHECK_QUADRANT_##SOURCE_IMAGE##_4( qq );                        \
-            }                                                                 \
-                                                                              \
-            if( check_neibours[ 3 ] >= 2 )                                    \
-            {                                                                 \
-              mlib_s32 qq = q ^ 9;                                            \
-              CHECK_QUADRANT_##SOURCE_IMAGE##_4( qq );                        \
-            }                                                                 \
-                                                                              \
-            if( check_neibours[ 4 ] >= 2 )                                    \
-            {                                                                 \
-              mlib_s32 qq = q ^ 10;                                           \
-              CHECK_QUADRANT_##SOURCE_IMAGE##_4( qq );                        \
-            }                                                                 \
-                                                                              \
-            if( check_neibours[ 5 ] >= 2 )                                    \
-            {                                                                 \
-              mlib_s32 qq = q ^ 12;                                           \
-              CHECK_QUADRANT_##SOURCE_IMAGE##_4( qq );                        \
-            }                                                                 \
-                                                                              \
-            if( check_far_neibours[ 0 ] >= 3 )                                \
-            {                                                                 \
-              mlib_s32 qq = q ^ 7;                                            \
-              CHECK_QUADRANT_##SOURCE_IMAGE##_4( qq );                        \
-            }                                                                 \
-                                                                              \
-            if( check_far_neibours[ 1 ] >= 3 )                                \
-            {                                                                 \
-              mlib_s32 qq = q ^ 11;                                           \
-              CHECK_QUADRANT_##SOURCE_IMAGE##_4( qq );                        \
-            }                                                                 \
-                                                                              \
-            if( check_far_neibours[ 2 ] >= 3 )                                \
-            {                                                                 \
-              mlib_s32 qq = q ^ 13;                                           \
-              CHECK_QUADRANT_##SOURCE_IMAGE##_4( qq );                        \
-            }                                                                 \
-                                                                              \
-            if( check_far_neibours[ 3 ] >= 3 )                                \
-            {                                                                 \
-              mlib_s32 qq = q ^ 14;                                           \
-              CHECK_QUADRANT_##SOURCE_IMAGE##_4( qq );                        \
-            }                                                                 \
-                                                                              \
-            if( check_corner >= 4 )                                           \
-            {                                                                 \
-              mlib_s32 qq = q ^ 15;                                           \
-              CHECK_QUADRANT_##SOURCE_IMAGE##_4( qq );                        \
-            }                                                                 \
-                                                                              \
-            if( q & 1 )                                                       \
-            {                                                                 \
-              BINARY_TREE_SEARCH_RIGHT( 0, COLOR_MAX, SHIFT );                \
-            }                                                                 \
-            else                                                              \
-            {                                                                 \
-              BINARY_TREE_SEARCH_LEFT( 0, SHIFT );                            \
-            }                                                                 \
-                                                                              \
-            if( q & 2 )                                                       \
-            {                                                                 \
-              BINARY_TREE_SEARCH_RIGHT( 1, COLOR_MAX, SHIFT );                \
-            }                                                                 \
-            else                                                              \
-            {                                                                 \
-              BINARY_TREE_SEARCH_LEFT( 1, SHIFT );                            \
-            }                                                                 \
-                                                                              \
-            if( q & 4 )                                                       \
-            {                                                                 \
-              BINARY_TREE_SEARCH_RIGHT( 2, COLOR_MAX, SHIFT );                \
-            }                                                                 \
-            else                                                              \
-            {                                                                 \
-              BINARY_TREE_SEARCH_LEFT( 2, SHIFT );                            \
-            }                                                                 \
-                                                                              \
-            if( q & 8 )                                                       \
-            {                                                                 \
-              BINARY_TREE_SEARCH_RIGHT( 3, COLOR_MAX, SHIFT );                \
-            }                                                                 \
-            else                                                              \
-            {                                                                 \
-              BINARY_TREE_SEARCH_LEFT( 3, SHIFT );                            \
-            }                                                                 \
-                                                                              \
-            position[ 0 ] &= ~( c[ 0 ] & current_size );                      \
-            position[ 1 ] &= ~( c[ 1 ] & current_size );                      \
-            position[ 2 ] &= ~( c[ 2 ] & current_size );                      \
-            position[ 3 ] &= ~( c[ 3 ] & current_size );                      \
-                                                                              \
-            current_size <<= 1;                                               \
-                                                                              \
-            pass++;                                                           \
-                                                                              \
-            stack_pointer--;                                                  \
-            q = stack[ stack_pointer ].q;                                     \
-            node = stack[ stack_pointer ].node;                               \
-          } while( continue_up );                                             \
-                                                                              \
-          dst[ j ] = found_color + s->offset;                                 \
-          we_found_it = 1;                                                    \
-        }                                                                     \
-      }                                                                       \
-      else if( node->contents.quadrants[ q ] )                                \
-      {                                                                       \
-        /* Descend one level */                                               \
-        stack[ stack_pointer ].node = node;                                   \
-        stack[ stack_pointer++ ].q = q;                                       \
-        node = node->contents.quadrants[ q ];                                 \
-      }                                                                       \
-      else                                                                    \
-      {                                                                       \
-        /* Found the empty quadrant. Look around */                           \
-        mlib_u32 distance = MLIB_U32_MAX;                                     \
-        mlib_s32 found_color;                                                 \
-        mlib_s32 continue_up;                                                 \
-                                                                              \
-        /*                                                                    \
-          As we had come to this level, it is warranted that there            \
-          are other points on this level near the empty quadrant              \
-        */                                                                    \
-        do                                                                    \
-        {                                                                     \
-          mlib_s32 check_corner;                                              \
-          mlib_s32 check_neibours[ 6 ];                                       \
-          mlib_s32 check_far_neibours[ 4 ];                                   \
-                                                                              \
-          /*                                                                  \
-            Check neibours: quadrants that are different by 2 bits            \
-            from the quadrant, that we are in:                                \
-            3 -  0                                                            \
-            5 -  1                                                            \
-            6 -  2                                                            \
-            9 -  3                                                            \
-            10 - 4                                                            \
-            12 - 5                                                            \
-            Far quadrants: different by 3 bits:                               \
-            7  - 0                                                            \
-            11 - 1                                                            \
-            13 - 2                                                            \
-            14 - 3                                                            \
-          */                                                                  \
-                                                                              \
-          check_neibours[ 0 ] = check_neibours[ 1 ] =                         \
-            check_neibours[ 2 ] = check_neibours[ 3 ] =                       \
-            check_neibours[ 4 ] = check_neibours[ 5 ] = 0;                    \
-          continue_up = 0;                                                    \
-                                                                              \
-          if( q & 1 )                                                         \
-          {                                                                   \
-            BINARY_TREE_EXPLORE_LEFT_4( 0, SOURCE_IMAGE, 0, 1, 3,             \
-              SUBTRACTION, SHIFT );                                           \
-          }                                                                   \
-          else                                                                \
-          {                                                                   \
-            BINARY_TREE_EXPLORE_RIGHT_4( 0, COLOR_MAX, SOURCE_IMAGE,          \
-              0, 1, 3, SUBTRACTION, SHIFT );                                  \
-          }                                                                   \
-                                                                              \
-          if( q & 2 )                                                         \
-          {                                                                   \
-            BINARY_TREE_EXPLORE_LEFT_4( 1, SOURCE_IMAGE, 0, 2, 4,             \
-              SUBTRACTION, SHIFT );                                           \
-          }                                                                   \
-          else                                                                \
-          {                                                                   \
-            BINARY_TREE_EXPLORE_RIGHT_4( 1, COLOR_MAX, SOURCE_IMAGE,          \
-              0, 2, 4, SUBTRACTION, SHIFT );                                  \
-          }                                                                   \
-                                                                              \
-          if( q & 4 )                                                         \
-          {                                                                   \
-            BINARY_TREE_EXPLORE_LEFT_4( 2, SOURCE_IMAGE, 1, 2, 5,             \
-              SUBTRACTION, SHIFT );                                           \
-          }                                                                   \
-          else                                                                \
-          {                                                                   \
-            BINARY_TREE_EXPLORE_RIGHT_4( 2, COLOR_MAX, SOURCE_IMAGE,          \
-              1, 2, 5, SUBTRACTION, SHIFT );                                  \
-          }                                                                   \
-                                                                              \
-          if( q & 8 )                                                         \
-          {                                                                   \
-            BINARY_TREE_EXPLORE_LEFT_4( 3, SOURCE_IMAGE, 3, 4, 5,             \
-              SUBTRACTION, SHIFT );                                           \
-          }                                                                   \
-          else                                                                \
-          {                                                                   \
-            BINARY_TREE_EXPLORE_RIGHT_4( 3, COLOR_MAX, SOURCE_IMAGE,          \
-              3, 4, 5, SUBTRACTION, SHIFT );                                  \
-          }                                                                   \
-                                                                              \
-          check_far_neibours[ 0 ] = check_neibours[ 0 ] +                     \
-            check_neibours[ 1 ] + check_neibours[ 2 ];                        \
-          check_far_neibours[ 1 ] = check_neibours[ 0 ] +                     \
-            check_neibours[ 3 ] + check_neibours[ 4 ];                        \
-          check_far_neibours[ 2 ] = check_neibours[ 1 ] +                     \
-            check_neibours[ 3 ] + check_neibours[ 5 ];                        \
-          check_far_neibours[ 3 ] = check_neibours[ 2 ] +                     \
-            check_neibours[ 4 ] + check_neibours[ 5 ];                        \
-                                                                              \
-          check_corner = check_far_neibours[ 0 ] +                            \
-            check_far_neibours[ 1 ] +                                         \
-            check_far_neibours[ 2 ] +                                         \
-            check_far_neibours[ 3 ];                                          \
-                                                                              \
-          if( check_neibours[ 0 ] >= 2 )                                      \
-          {                                                                   \
-            mlib_s32 qq = q ^ 3;                                              \
-            CHECK_QUADRANT_##SOURCE_IMAGE##_4( qq );                          \
-          }                                                                   \
-                                                                              \
-          if( check_neibours[ 1 ] >= 2 )                                      \
-          {                                                                   \
-            mlib_s32 qq = q ^ 5;                                              \
-            CHECK_QUADRANT_##SOURCE_IMAGE##_4( qq );                          \
-          }                                                                   \
-                                                                              \
-          if( check_neibours[ 2 ] >= 2 )                                      \
-          {                                                                   \
-            mlib_s32 qq = q ^ 6;                                              \
-            CHECK_QUADRANT_##SOURCE_IMAGE##_4( qq );                          \
-          }                                                                   \
-                                                                              \
-          if( check_neibours[ 3 ] >= 2 )                                      \
-          {                                                                   \
-            mlib_s32 qq = q ^ 9;                                              \
-            CHECK_QUADRANT_##SOURCE_IMAGE##_4( qq );                          \
-          }                                                                   \
-                                                                              \
-          if( check_neibours[ 4 ] >= 2 )                                      \
-          {                                                                   \
-            mlib_s32 qq = q ^ 10;                                             \
-            CHECK_QUADRANT_##SOURCE_IMAGE##_4( qq );                          \
-          }                                                                   \
-                                                                              \
-          if( check_neibours[ 5 ] >= 2 )                                      \
-          {                                                                   \
-            mlib_s32 qq = q ^ 12;                                             \
-            CHECK_QUADRANT_##SOURCE_IMAGE##_4( qq );                          \
-          }                                                                   \
-                                                                              \
-          if( check_far_neibours[ 0 ] >= 3 )                                  \
-          {                                                                   \
-            mlib_s32 qq = q ^ 7;                                              \
-            CHECK_QUADRANT_##SOURCE_IMAGE##_4( qq );                          \
-          }                                                                   \
-                                                                              \
-          if( check_far_neibours[ 1 ] >= 3 )                                  \
-          {                                                                   \
-            mlib_s32 qq = q ^ 11;                                             \
-            CHECK_QUADRANT_##SOURCE_IMAGE##_4( qq );                          \
-          }                                                                   \
-                                                                              \
-          if( check_far_neibours[ 2 ] >= 3 )                                  \
-          {                                                                   \
-            mlib_s32 qq = q ^ 13;                                             \
-            CHECK_QUADRANT_##SOURCE_IMAGE##_4( qq );                          \
-          }                                                                   \
-                                                                              \
-          if( check_far_neibours[ 3 ] >= 3 )                                  \
-          {                                                                   \
-            mlib_s32 qq = q ^ 14;                                             \
-            CHECK_QUADRANT_##SOURCE_IMAGE##_4( qq );                          \
-          }                                                                   \
-                                                                              \
-          if( check_corner >= 4 )                                             \
-          {                                                                   \
-            mlib_s32 qq = q ^ 15;                                             \
-            CHECK_QUADRANT_##SOURCE_IMAGE##_4( qq );                          \
-          }                                                                   \
-                                                                              \
-          if( q & 1 )                                                         \
-          {                                                                   \
-            BINARY_TREE_SEARCH_RIGHT( 0, COLOR_MAX, SHIFT );                  \
-          }                                                                   \
-          else                                                                \
-          {                                                                   \
-            BINARY_TREE_SEARCH_LEFT( 0, SHIFT );                              \
-          }                                                                   \
-                                                                              \
-          if( q & 2 )                                                         \
-          {                                                                   \
-            BINARY_TREE_SEARCH_RIGHT( 1, COLOR_MAX, SHIFT );                  \
-          }                                                                   \
-          else                                                                \
-          {                                                                   \
-            BINARY_TREE_SEARCH_LEFT( 1, SHIFT );                              \
-          }                                                                   \
-                                                                              \
-          if( q & 4 )                                                         \
-          {                                                                   \
-            BINARY_TREE_SEARCH_RIGHT( 2, COLOR_MAX, SHIFT );                  \
-          }                                                                   \
-          else                                                                \
-          {                                                                   \
-            BINARY_TREE_SEARCH_LEFT( 2, SHIFT );                              \
-          }                                                                   \
-                                                                              \
-          if( q & 8 )                                                         \
-          {                                                                   \
-            BINARY_TREE_SEARCH_RIGHT( 3, COLOR_MAX, SHIFT );                  \
-          }                                                                   \
-          else                                                                \
-          {                                                                   \
-            BINARY_TREE_SEARCH_LEFT( 3, SHIFT );                              \
-          }                                                                   \
-                                                                              \
-          position[ 0 ] &= ~( c[ 0 ] & current_size );                        \
-          position[ 1 ] &= ~( c[ 1 ] & current_size );                        \
-          position[ 2 ] &= ~( c[ 2 ] & current_size );                        \
-          position[ 3 ] &= ~( c[ 3 ] & current_size );                        \
-                                                                              \
-          current_size <<= 1;                                                 \
-                                                                              \
-          pass++;                                                             \
-                                                                              \
-          stack_pointer--;                                                    \
-          q = stack[ stack_pointer ].q;                                       \
-          node = stack[ stack_pointer ].node;                                 \
-        } while( continue_up );                                               \
-                                                                              \
-        dst[ j ] = found_color + s->offset;                                   \
-        we_found_it = 1;                                                      \
-      }                                                                       \
-                                                                              \
-      pass--;                                                                 \
-                                                                              \
-    } while( !we_found_it );                                                  \
-                                                                              \
-    channels[ 0 ] += 4;                                                       \
-    channels[ 1 ] += 4;                                                       \
-    channels[ 2 ] += 4;                                                       \
-    channels[ 3 ] += 4;                                                       \
-  }                                                                           \
-}
-
-/***************************************************************/
-#define FIND_NEAREST_U8_3_C( SHIFT, STEP )                      \
-  mlib_s32 i, k, k_min, min_dist, diff, mask;                   \
-  mlib_s32 offset = mlib_ImageGetLutOffset( s ) - 1;            \
-  mlib_s32 entries = s -> lutlength;                            \
-  mlib_d64 *double_lut = mlib_ImageGetLutDoubleData( s );       \
-  mlib_d64 col0, col1, col2;                                    \
-  mlib_d64 dist, len0, len1, len2;                              \
-                                                                \
-  for ( i = 0; i < length; i++ ) {                              \
-    col0 = src[ STEP * i + SHIFT ];                             \
-    col1 = src[ STEP * i + 1 + SHIFT ];                         \
-    col2 = src[ STEP * i + 2 + SHIFT ];                         \
-    min_dist = MLIB_S32_MAX;                                    \
-    k_min = 1;                                                  \
-    len0 = double_lut[ 0 ] - col0;                              \
-    len1 = double_lut[ 1 ] - col1;                              \
-    len2 = double_lut[ 2 ] - col2;                              \
-                                                                \
-    for ( k = 1; k <= entries; k++ ) {                          \
-      dist = len0 * len0;                                       \
-      len0 = double_lut[ 3 * k ] - col0;                        \
-      dist += len1 * len1;                                      \
-      len1 = double_lut[ 3 * k + 1 ] - col1;                    \
-      dist += len2 * len2;                                      \
-      len2 = double_lut[ 3 * k + 2 ] - col2;                    \
-      diff = ( mlib_s32 )dist - min_dist;                       \
-      mask = diff >> 31;                                        \
-      min_dist += diff & mask;                                  \
-      k_min += ( k - k_min ) & mask;                            \
-    }                                                           \
-                                                                \
-    dst[ i ] = k_min + offset;                                  \
-  }
-
-/***************************************************************/
-#define FIND_NEAREST_U8_4_C                                     \
-  mlib_s32 i, k, k_min, min_dist, diff, mask;                   \
-  mlib_s32 offset = mlib_ImageGetLutOffset( s ) - 1;            \
-  mlib_s32 entries = s -> lutlength;                            \
-  mlib_d64 *double_lut = mlib_ImageGetLutDoubleData( s );       \
-  mlib_d64 col0, col1, col2, col3;                              \
-  mlib_d64 dist, len0, len1, len2, len3;                        \
-                                                                \
-  for ( i = 0; i < length; i++ ) {                              \
-    col0 = src[ 4 * i ];                                        \
-    col1 = src[ 4 * i + 1 ];                                    \
-    col2 = src[ 4 * i + 2 ];                                    \
-    col3 = src[ 4 * i + 3 ];                                    \
-    min_dist = MLIB_S32_MAX;                                    \
-    k_min = 1;                                                  \
-    len0 = double_lut[ 0 ] - col0;                              \
-    len1 = double_lut[ 1 ] - col1;                              \
-    len2 = double_lut[ 2 ] - col2;                              \
-    len3 = double_lut[ 3 ] - col3;                              \
-                                                                \
-    for ( k = 1; k <= entries; k++ ) {                          \
-      dist = len0 * len0;                                       \
-      len0 =  double_lut[ 4 * k ] - col0;                       \
-      dist += len1 * len1;                                      \
-      len1 = double_lut[ 4 * k + 1 ] - col1;                    \
-      dist += len2 * len2;                                      \
-      len2 =  double_lut[ 4 * k + 2 ] - col2;                   \
-      dist += len3 * len3;                                      \
-      len3 =  double_lut[ 4 * k + 3 ] - col3;                   \
-      diff = ( mlib_s32 )dist - min_dist;                       \
-      mask = diff >> 31;                                        \
-      min_dist += diff & mask;                                  \
-      k_min += ( k - k_min ) & mask;                            \
-    }                                                           \
-                                                                \
-    dst[ i ] = k_min + offset;                                  \
-  }
-
-/***************************************************************/
-#define FSQR_S16_HI(dsrc)                                                   \
-  vis_fpadd32( vis_fmuld8ulx16( vis_read_hi( dsrc ), vis_read_hi( dsrc ) ), \
-    vis_fmuld8sux16( vis_read_hi( dsrc ), vis_read_hi( dsrc ) ) )
-
-/***************************************************************/
-#define FSQR_S16_LO(dsrc)                                                  \
-  vis_fpadd32( vis_fmuld8ulx16( vis_read_lo( dsrc ), vis_read_lo( dsrc) ), \
-    vis_fmuld8sux16( vis_read_lo( dsrc ), vis_read_lo( dsrc ) ) )
-
-/***************************************************************/
-#define FIND_NEAREST_U8_3                                             \
-{                                                                     \
-  mlib_d64 *dpsrc, dsrc, dsrc1, ddist, ddist1, ddist2, ddist3;        \
-  mlib_d64 dcolor, dind, dres, dres1, dpind[1], dpmin[1];             \
-  mlib_d64 done = vis_to_double_dup( 1 ),                             \
-           dmax = vis_to_double_dup( MLIB_S32_MAX );                  \
-  mlib_f32 *lut = ( mlib_f32 * )mlib_ImageGetLutNormalTable( s );     \
-  mlib_f32 fone = vis_to_float( 0x100 );                              \
-  mlib_s32 i, k, mask;                                                \
-  mlib_s32 gsr[1];                                                    \
-  mlib_s32 offset = mlib_ImageGetLutOffset( s ) - 1;                  \
-  mlib_s32 entries = s->lutlength;                                    \
-                                                                      \
-  gsr[0] = vis_read_gsr();                                            \
-  for( i = 0; i <= ( length-2 ); i += 2 )                             \
-  {                                                                   \
-    dpsrc = VIS_ALIGNADDR( src, -1 );                                 \
-    src += 6;                                                         \
-    dsrc = dpsrc[ 0 ];                                                \
-    dsrc1 = dpsrc[ 1 ];                                               \
-    dsrc1 = vis_faligndata( dsrc, dsrc1 );                            \
-    dsrc = vis_fmul8x16al( vis_read_hi( dsrc1 ), fone );              \
-    VIS_ALIGNADDR( dpsrc, 3 );                                        \
-    dsrc1 = vis_faligndata( dsrc1, dsrc1 );                           \
-    dsrc1 = vis_fmul8x16al( vis_read_hi( dsrc1 ), fone );             \
-    dpind[ 0 ] = dind = done;                                         \
-    dpmin[ 0 ] = dmax;                                                \
-    dcolor = vis_fmul8x16al( lut[ 0 ], fone );                        \
-    for( k = 1; k <= entries; k++ )                                   \
-    {                                                                 \
-      ddist1 = vis_fpsub16( dcolor, dsrc );                           \
-      ddist = FSQR_S16_HI( ddist1 );                                  \
-      ddist1 = FSQR_S16_LO( ddist1 );                                 \
-      dres = vis_fpadd32( ddist, ddist1 );                            \
-      ddist3 = vis_fpsub16( dcolor, dsrc1 );                          \
-      ddist2 = FSQR_S16_HI( ddist3 );                                 \
-      ddist3 = FSQR_S16_LO( ddist3 );                                 \
-      dres1 = vis_fpadd32( ddist2, ddist3 );                          \
-      dcolor = vis_fmul8x16al( lut[ k ], fone );                      \
-      dres = vis_freg_pair(                                           \
-        vis_fpadd32s( vis_read_hi( dres ), vis_read_lo( dres ) ),     \
-        vis_fpadd32s( vis_read_hi( dres1 ), vis_read_lo( dres1 ) ) ); \
-      mask = vis_fcmplt32( dres, dpmin[ 0 ] );                        \
-      vis_pst_32( dind, ( void * )dpind, mask );                      \
-      dind = vis_fpadd32( dind, done );                               \
-      vis_pst_32( dres, ( void * )dpmin, mask );                      \
-    }                                                                 \
-    dst[ i ] = ( ( mlib_s32 * )dpind )[ 0 ] + offset;                 \
-    dst[ i + 1 ] = ( ( mlib_s32 * )dpind)[ 1 ] + offset;              \
-  }                                                                   \
-  if( i < length )                                                    \
-  {                                                                   \
-    dpsrc = VIS_ALIGNADDR( src, -1 );                                 \
-    dsrc = dpsrc[ 0 ];                                                \
-    dsrc1 = dpsrc[ 1 ];                                               \
-    dsrc1 = vis_faligndata( dsrc, dsrc1 );                            \
-    dsrc = vis_fmul8x16al( vis_read_hi( dsrc1 ), fone );              \
-    dpind[ 0 ] = dind = done;                                         \
-    dpmin[ 0 ] = dmax;                                                \
-    for( k = 0; k < entries; k++ )                                    \
-    {                                                                 \
-      dcolor = vis_fmul8x16al( lut[ k ], fone );                      \
-      ddist1 = vis_fpsub16( dcolor, dsrc );                           \
-      ddist = FSQR_S16_HI( ddist1 );                                  \
-      ddist1 = FSQR_S16_LO( ddist1 );                                 \
-      dres = vis_fpadd32( ddist, ddist1 );                            \
-      dres = vis_write_lo( dres,                                      \
-        vis_fpadd32s( vis_read_hi( dres ), vis_read_lo( dres ) ) );   \
-      mask = vis_fcmplt32( dres, dpmin[ 0 ] );                        \
-      vis_pst_32( dind, ( void * )dpind, mask );                      \
-      dind = vis_fpadd32( dind, done );                               \
-      vis_pst_32( dres, ( void * )dpmin, mask );                      \
-    }                                                                 \
-    dst[ i ] = ( ( mlib_s32 * )dpind)[ 1 ] + offset;                  \
-  }                                                                   \
-  vis_write_gsr(gsr[0]);                                              \
-}
-
-/***************************************************************/
-#define FIND_NEAREST_U8_3_IN4                                         \
-{                                                                     \
-  mlib_d64 *dpsrc, dsrc, dsrc1, ddist, ddist1, ddist2, ddist3;        \
-  mlib_d64 dcolor, dind, dres, dres1, dpind[1], dpmin[1];             \
-  mlib_d64 done = vis_to_double_dup( 1 ),                             \
-           dmax = vis_to_double_dup( MLIB_S32_MAX );                  \
-  mlib_f32 *lut = ( mlib_f32 * )mlib_ImageGetLutNormalTable( s );     \
-  mlib_f32 fone = vis_to_float( 0x100 );                              \
-  mlib_s32 i, k, mask, gsr[1];                                        \
-  mlib_s32 offset = mlib_ImageGetLutOffset( s ) - 1;                  \
-  mlib_s32 entries = s->lutlength;                                    \
-                                                                      \
-  gsr[0] = vis_read_gsr();                                            \
-  dpsrc = VIS_ALIGNADDR( src, 0 );                                    \
-  for( i = 0; i <= ( length-2 ); i += 2 )                             \
-  {                                                                   \
-    dsrc = dpsrc[ 0 ];                                                \
-    dsrc1 = dpsrc[ 1 ];                                               \
-    dsrc1 = vis_faligndata( dsrc, dsrc1 );                            \
-    dpsrc++;                                                          \
-    dsrc = vis_fmul8x16al( vis_read_hi( dsrc1 ), fone );              \
-    dsrc1 = vis_fmul8x16al( vis_read_lo( dsrc1 ), fone );             \
-    dpind[ 0 ] = dind = done;                                         \
-    dpmin[ 0 ] = dmax;                                                \
-    dcolor = vis_fmul8x16al( lut[ 0 ], fone );                        \
-    for( k = 1; k <= entries; k++ )                                   \
-    {                                                                 \
-      ddist1 = vis_fpsub16( dcolor, dsrc );                           \
-      ddist = FSQR_S16_HI( ddist1 );                                  \
-      ddist1 = FSQR_S16_LO( ddist1 );                                 \
-      dres = vis_fpadd32( ddist, ddist1 );                            \
-      ddist3 = vis_fpsub16( dcolor, dsrc1 );                          \
-      ddist2 = FSQR_S16_HI( ddist3 );                                 \
-      ddist3 = FSQR_S16_LO( ddist3 );                                 \
-      dres1 = vis_fpadd32( ddist2, ddist3 );                          \
-      dcolor = vis_fmul8x16al( lut[ k ], fone );                      \
-      dres = vis_freg_pair(                                           \
-        vis_fpadd32s( vis_read_hi( dres ), vis_read_lo( dres ) ),     \
-        vis_fpadd32s( vis_read_hi( dres1 ), vis_read_lo( dres1 ) ) ); \
-      mask = vis_fcmplt32( dres, dpmin[ 0 ] );                        \
-      vis_pst_32( dind, ( void * )dpind, mask );                      \
-      dind = vis_fpadd32( dind, done );                               \
-      vis_pst_32( dres, ( void * )dpmin, mask );                      \
-    }                                                                 \
-    dst[ i ] = ( ( mlib_s32 * )dpind )[ 0 ] + offset;                 \
-    dst[ i + 1 ] = ( ( mlib_s32 * )dpind)[ 1 ] + offset;              \
-  }                                                                   \
-  if( i < length )                                                    \
-  {                                                                   \
-    dsrc = dpsrc[ 0 ];                                                \
-    dsrc1 = dpsrc[ 1 ];                                               \
-    dsrc1 = vis_faligndata( dsrc, dsrc1 );                            \
-    dsrc = vis_fmul8x16al( vis_read_hi( dsrc1 ), fone );              \
-    dpind[ 0 ] = dind = done;                                         \
-    dpmin[ 0 ] = dmax;                                                \
-    for( k = 0; k < entries; k++ )                                    \
-    {                                                                 \
-      dcolor = vis_fmul8x16al( lut[ k ], fone );                      \
-      ddist1 = vis_fpsub16( dcolor, dsrc );                           \
-      ddist = FSQR_S16_HI( ddist1 );                                  \
-      ddist1 = FSQR_S16_LO( ddist1 );                                 \
-      dres = vis_fpadd32( ddist, ddist1 );                            \
-      dres = vis_write_lo( dres,                                      \
-        vis_fpadd32s( vis_read_hi( dres ), vis_read_lo( dres ) ) );   \
-      mask = vis_fcmplt32( dres, dpmin[ 0 ] );                        \
-      vis_pst_32( dind, ( void * )dpind, mask );                      \
-      dind = vis_fpadd32( dind, done );                               \
-      vis_pst_32( dres, ( void * )dpmin, mask );                      \
-    }                                                                 \
-    dst[ i ] = ( ( mlib_s32 * )dpind)[ 1 ] + offset;                  \
-  }                                                                   \
-  vis_write_gsr(gsr[0]);                                              \
-}
-
-/***************************************************************/
-#define FIND_NEAREST_U8_4                                             \
-{                                                                     \
-  mlib_d64 *dpsrc, dsrc, dsrc1, ddist, ddist1, ddist2, ddist3;        \
-  mlib_d64 dcolor, dind, dres, dres1, dpind[ 1 ], dpmin[ 1 ];         \
-  mlib_d64 done = vis_to_double_dup( 1 ),                             \
-           dmax = vis_to_double_dup( MLIB_S32_MAX );                  \
-  mlib_f32 *lut = ( mlib_f32 * )mlib_ImageGetLutNormalTable( s );     \
-  mlib_f32 fone = vis_to_float( 0x100 );                              \
-  mlib_s32 i, k, mask, gsr[1];                                        \
-  mlib_s32 offset = mlib_ImageGetLutOffset( s ) - 1;                  \
-  mlib_s32 entries = s->lutlength;                                    \
-                                                                      \
-  gsr[0] = vis_read_gsr();                                            \
-  dpsrc = VIS_ALIGNADDR( src, 0 );                                    \
-  for( i = 0; i <= ( length-2 ); i += 2 )                             \
-  {                                                                   \
-    dsrc = dpsrc[ 0 ];                                                \
-    dsrc1 = dpsrc[ 1 ];                                               \
-    dsrc1 = vis_faligndata( dsrc, dsrc1 );                            \
-    dpsrc++;                                                          \
-    dsrc = vis_fmul8x16al( vis_read_hi( dsrc1 ), fone );              \
-    dsrc1 = vis_fmul8x16al( vis_read_lo( dsrc1 ), fone );             \
-    dpind[ 0 ] = dind = done;                                         \
-    dpmin[ 0 ] = dmax;                                                \
-    dcolor = vis_fmul8x16al(lut[0], fone);                            \
-    for( k = 1; k <= entries; k++ )                                   \
-    {                                                                 \
-      ddist1 = vis_fpsub16( dcolor, dsrc );                           \
-      ddist = FSQR_S16_HI( ddist1 );                                  \
-      ddist1 = FSQR_S16_LO( ddist1 );                                 \
-      dres = vis_fpadd32( ddist, ddist1 );                            \
-      ddist3 = vis_fpsub16( dcolor, dsrc1 );                          \
-      ddist2 = FSQR_S16_HI( ddist3 );                                 \
-      ddist3 = FSQR_S16_LO( ddist3 );                                 \
-      dres1 = vis_fpadd32( ddist2, ddist3 );                          \
-      dcolor = vis_fmul8x16al( lut[ k ], fone );                      \
-      dres = vis_freg_pair(                                           \
-        vis_fpadd32s( vis_read_hi( dres ), vis_read_lo( dres ) ),     \
-        vis_fpadd32s( vis_read_hi( dres1 ), vis_read_lo( dres1 ) ) ); \
-      mask = vis_fcmplt32( dres, dpmin[ 0 ] );                        \
-      vis_pst_32( dind, ( void * )dpind, mask );                      \
-      dind = vis_fpadd32( dind, done );                               \
-      vis_pst_32( dres, ( void * )dpmin, mask );                      \
-    }                                                                 \
-    dst[ i ] = ( ( mlib_s32 * )dpind )[ 0 ] + offset;                 \
-    dst[ i + 1 ] = ( ( mlib_s32 * )dpind )[ 1 ] + offset;             \
-  }                                                                   \
-  if( i < length )                                                    \
-  {                                                                   \
-    dsrc = dpsrc[ 0 ];                                                \
-    dsrc1 = dpsrc[ 1 ];                                               \
-    dsrc1 = vis_faligndata( dsrc, dsrc1 );                            \
-    dsrc = vis_fmul8x16al( vis_read_hi( dsrc1 ), fone );              \
-    dpind[ 0 ] = dind = done;                                         \
-    dpmin[ 0 ] = dmax;                                                \
-    for( k = 0; k < entries; k++ )                                    \
-    {                                                                 \
-      dcolor = vis_fmul8x16al( lut[ k ], fone );                      \
-      ddist1 = vis_fpsub16( dcolor, dsrc );                           \
-      ddist = FSQR_S16_HI( ddist1 );                                  \
-      ddist1 = FSQR_S16_LO( ddist1 );                                 \
-      dres = vis_fpadd32( ddist, ddist1 );                            \
-      dres = vis_write_lo( dres,                                      \
-        vis_fpadd32s( vis_read_hi( dres ), vis_read_lo( dres ) ) );   \
-      mask = vis_fcmplt32( dres, dpmin[ 0 ] );                        \
-      vis_pst_32( dind, ( void * )dpind, mask );                      \
-      dind = vis_fpadd32( dind, done );                               \
-      vis_pst_32( dres, ( void * )dpmin, mask );                      \
-    }                                                                 \
-    dst[ i ] = ( ( mlib_s32 * )dpind )[ 1 ] + offset;                 \
-  }                                                                   \
-  vis_write_gsr(gsr[0]);                                              \
-}
-
-/***************************************************************/
-#define FIND_NEAREST_S16_3( SHIFT, STEP )                       \
-  mlib_s32 i, k, k_min, min_dist, diff, mask;                   \
-  mlib_s32 offset = mlib_ImageGetLutOffset( s ) - 1;            \
-  mlib_s32 entries = s->lutlength;                              \
-  mlib_d64 *double_lut = mlib_ImageGetLutDoubleData( s );       \
-  mlib_d64 col0, col1, col2;                                    \
-  mlib_d64 dist, len0, len1, len2;                              \
-                                                                \
-  for( i = 0; i < length; i++ )                                 \
-  {                                                             \
-    col0 = src[ STEP * i + SHIFT ];                             \
-    col1 = src[ STEP * i + 1 + SHIFT ];                         \
-    col2 = src[ STEP * i + 2 + SHIFT ];                         \
-    min_dist = MLIB_S32_MAX;                                    \
-    k_min = 1;                                                  \
-    len0 = double_lut[ 0 ] - col0;                              \
-    len1 = double_lut[ 1 ] - col1;                              \
-    len2 = double_lut[ 2 ] - col2;                              \
-    for( k = 1; k <= entries; k++ )                             \
-    {                                                           \
-      dist = len0 * len0;                                       \
-      len0 = double_lut[ 3 * k ] - col0;                        \
-      dist += len1 * len1;                                      \
-      len1 = double_lut[ 3 * k + 1 ] - col1;                    \
-      dist += len2 * len2;                                      \
-      len2 = double_lut[ 3 * k + 2 ] - col2;                    \
-      diff = ( mlib_s32 )( dist * 0.125 ) - min_dist;           \
-      mask = diff >> 31;                                        \
-      min_dist += diff & mask;                                  \
-      k_min += ( k - k_min ) & mask;                            \
-    }                                                           \
-    dst[ i ] = k_min + offset;                                  \
-  }
-
-/***************************************************************/
-#define FIND_NEAREST_S16_4                                      \
-  mlib_s32 i, k, k_min, min_dist, diff, mask;                   \
-  mlib_s32 offset = mlib_ImageGetLutOffset( s ) - 1;            \
-  mlib_s32 entries = s->lutlength;                              \
-  mlib_d64 *double_lut = mlib_ImageGetLutDoubleData( s );       \
-  mlib_d64 col0, col1, col2, col3;                              \
-  mlib_d64 dist, len0, len1, len2, len3;                        \
-                                                                \
-  for( i = 0; i < length; i++ )                                 \
-  {                                                             \
-    col0 = src[ 4 * i ];                                        \
-    col1 = src[ 4 * i + 1 ];                                    \
-    col2 = src[ 4 * i + 2 ];                                    \
-    col3 = src[ 4 * i + 3 ];                                    \
-    min_dist = MLIB_S32_MAX;                                    \
-    k_min = 1;                                                  \
-    len0 = double_lut[ 0 ] - col0;                              \
-    len1 = double_lut[ 1 ] - col1;                              \
-    len2 = double_lut[ 2 ] - col2;                              \
-    len3 = double_lut[ 3 ] - col3;                              \
-    for( k = 1; k <= entries; k++ )                             \
-    {                                                           \
-      dist = len0 * len0;                                       \
-      len0 =  double_lut[ 4 * k ] - col0;                       \
-      dist += len1 * len1;                                      \
-      len1 = double_lut[ 4 * k + 1 ] - col1;                    \
-      dist += len2 * len2;                                      \
-      len2 =  double_lut[ 4 * k + 2 ] - col2;                   \
-      dist += len3 * len3;                                      \
-      len3 =  double_lut[ 4 * k + 3 ] - col3;                   \
-      diff = ( mlib_s32 )( dist * 0.125 ) - min_dist;           \
-      mask = diff >> 31;                                        \
-      min_dist += diff & mask;                                  \
-      k_min += ( k - k_min ) & mask;                            \
-    }                                                           \
-    dst[ i ] = k_min + offset;                                  \
-  }
-
-/***************************************************************/
-mlib_status mlib_ImageColorTrue2Index(mlib_image       *dst,
-                                      const mlib_image *src,
-                                      const void       *colormap)
-{
-  mlib_s32 y, width, height, sstride, dstride, schann;
-  mlib_colormap *s = (mlib_colormap *)colormap;
-  mlib_s32 channels;
-  mlib_type stype, dtype;
-
-  MLIB_IMAGE_CHECK(src);
-  MLIB_IMAGE_CHECK(dst);
-  MLIB_IMAGE_SIZE_EQUAL(src, dst);
-  MLIB_IMAGE_HAVE_CHAN(dst, 1);
-
-  if (!colormap)
-    return MLIB_NULLPOINTER;
-
-  channels = s->channels;
-  stype = mlib_ImageGetType(src);
-  dtype = mlib_ImageGetType(dst);
-  width = mlib_ImageGetWidth(src);
-  height = mlib_ImageGetHeight(src);
-  sstride = mlib_ImageGetStride(src);
-  dstride = mlib_ImageGetStride(dst);
-  schann = mlib_ImageGetChannels(src);
-
-  if (stype != s->intype || dtype != s->outtype)
-    return MLIB_FAILURE;
-
-  if (channels != schann)
-    return MLIB_FAILURE;
-
-  switch (stype) {
-    case MLIB_BYTE:
-      {
-        mlib_u8 *sdata = mlib_ImageGetData(src);
-
-        switch (dtype) {
-          case MLIB_BYTE:
-            {
-              mlib_u8 *ddata = mlib_ImageGetData(dst);
-
-              switch (channels) {
-                case 3:
-                  {
-                    MAIN_COLORTRUE2INDEX_LOOP(U8, U8, 3);
-                    return MLIB_SUCCESS;
-                  }
-
-                case 4:
-                  {
-                    MAIN_COLORTRUE2INDEX_LOOP(U8, U8, 4);
-                    return MLIB_SUCCESS;
-                  }
-
-                default:
-                  return MLIB_FAILURE;
-              }
-            }
-
-          case MLIB_SHORT:
-            {
-              mlib_s16 *ddata = mlib_ImageGetData(dst);
-
-              dstride /= 2;
-              switch (channels) {
-                case 3:
-                  {
-                    MAIN_COLORTRUE2INDEX_LOOP(U8, S16, 3);
-                    return MLIB_SUCCESS;
-                  }
-
-                case 4:
-                  {
-                    MAIN_COLORTRUE2INDEX_LOOP(U8, S16, 4);
-                    return MLIB_SUCCESS;
-                  }
-
-                default:
-                  return MLIB_FAILURE;
-              }
-            }
-        default:
-          /* Unsupported type of destination image */
-          return MLIB_FAILURE;
-        }
-      }
-
-    case MLIB_SHORT:
-      {
-        mlib_s16 *sdata = mlib_ImageGetData(src);
-
-        sstride /= 2;
-        switch (dtype) {
-          case MLIB_BYTE:
-            {
-              mlib_u8 *ddata = mlib_ImageGetData(dst);
-
-              switch (channels) {
-                case 3:
-                  {
-                    MAIN_COLORTRUE2INDEX_LOOP(S16, U8, 3);
-                    return MLIB_SUCCESS;
-                  }
-
-                case 4:
-                  {
-                    MAIN_COLORTRUE2INDEX_LOOP(S16, U8, 4);
-                    return MLIB_SUCCESS;
-                  }
-
-                default:
-                  return MLIB_FAILURE;
-              }
-            }
-
-          case MLIB_SHORT:
-            {
-              mlib_s16 *ddata = mlib_ImageGetData(dst);
-
-              dstride /= 2;
-              switch (channels) {
-                case 3:
-                  {
-                    MAIN_COLORTRUE2INDEX_LOOP(S16, S16, 3);
-                    return MLIB_SUCCESS;
-                  }
-
-                case 4:
-                  {
-                    MAIN_COLORTRUE2INDEX_LOOP(S16, S16, 4);
-                    return MLIB_SUCCESS;
-                  }
-
-                default:
-                  return MLIB_FAILURE;
-              }
-            }
-        default:
-          /* Unsupported type of destination image */
-          return MLIB_FAILURE;
-        }
-      }
-
-    default:
-      return MLIB_FAILURE;
-  }
-}
-
-/***************************************************************/
-mlib_u32 mlib_search_quadrant_U8_3(struct lut_node_3 *node,
-                                   mlib_u32          distance,
-                                    mlib_s32    *found_color,
-                                   mlib_u32          c0,
-                                   mlib_u32          c1,
-                                   mlib_u32          c2,
-                                   const mlib_u8     **base)
-{
-  mlib_s32 i;
-
-  for (i = 0; i < 8; i++) {
-
-    if (node->tag & (1 << i)) {
-      /* Here is alone color cell. Check the distance */
-      mlib_s32 newindex = node->contents.index[i];
-      mlib_u32 newpalc0, newpalc1, newpalc2;
-      mlib_u32 newdistance;
-
-      newpalc0 = base[0][newindex];
-      newpalc1 = base[1][newindex];
-      newpalc2 = base[2][newindex];
-      newdistance = FIND_DISTANCE_3(c0, newpalc0, c1, newpalc1, c2, newpalc2, 0);
-
-      if (distance > newdistance) {
-        *found_color = newindex;
-        distance = newdistance;
-      }
-    }
-    else if (node->contents.quadrants[i])
-      distance =
-        mlib_search_quadrant_U8_3(node->contents.quadrants[i], distance,
-                                  found_color, c0, c1, c2, base);
-  }
-
-  return distance;
-}
-
-/***************************************************************/
-mlib_u32 mlib_search_quadrant_part_to_left_U8_3(struct lut_node_3 *node,
-                                                mlib_u32          distance,
-                                                 mlib_s32    *found_color,
-                                                const mlib_u32    *c,
-                                                const mlib_u8     **base,
-                                                mlib_u32          position,
-                                                mlib_s32          pass,
-                                                mlib_s32          dir_bit)
-{
-  mlib_u32 current_size = 1 << pass;
-  mlib_s32 i;
-  static mlib_s32 opposite_quadrants[3][4] = {
-    {0, 2, 4, 6},
-    {0, 1, 4, 5},
-    {0, 1, 2, 3}
-  };
-
-/* Search only quadrant's half untill it is necessary to check the
-  whole quadrant */
-
-  if (distance < (position + current_size - c[dir_bit]) * (position + current_size - c[dir_bit])) { /* Search half of quadrant */
-    for (i = 0; i < 4; i++) {
-      mlib_s32 qq = opposite_quadrants[dir_bit][i];
-
-      if (node->tag & (1 << qq)) {
-        /* Here is alone color cell. Check the distance */
-        mlib_s32 newindex = node->contents.index[qq];
-        mlib_u32 newpalc0, newpalc1, newpalc2;
-        mlib_u32 newdistance;
-
-        newpalc0 = base[0][newindex];
-        newpalc1 = base[1][newindex];
-        newpalc2 = base[2][newindex];
-        newdistance = FIND_DISTANCE_3(c[0], newpalc0, c[1], newpalc1, c[2], newpalc2, 0);
-
-        if (distance > newdistance) {
-          *found_color = newindex;
-          distance = newdistance;
-        }
-      }
-      else if (node->contents.quadrants[qq])
-        distance =
-          mlib_search_quadrant_part_to_left_U8_3(node->contents.quadrants[qq],
-                                                 distance, found_color, c, base,
-                                                 position, pass - 1, dir_bit);
-    }
-  }
-  else {                                    /* Search whole quadrant */
-
-    mlib_s32 mask = 1 << dir_bit;
-
-    for (i = 0; i < 8; i++) {
-
-      if (node->tag & (1 << i)) {
-        /* Here is alone color cell. Check the distance */
-        mlib_s32 newindex = node->contents.index[i];
-        mlib_u32 newpalc0, newpalc1, newpalc2;
-        mlib_u32 newdistance;
-
-        newpalc0 = base[0][newindex];
-        newpalc1 = base[1][newindex];
-        newpalc2 = base[2][newindex];
-        newdistance = FIND_DISTANCE_3(c[0], newpalc0, c[1], newpalc1, c[2], newpalc2, 0);
-
-        if (distance > newdistance) {
-          *found_color = newindex;
-          distance = newdistance;
-        }
-      }
-      else if (node->contents.quadrants[i]) {
-
-        if (i & mask)
-          /* This quadrant may require partial checking */
-          distance =
-            mlib_search_quadrant_part_to_left_U8_3(node->contents.quadrants[i],
-                                                   distance, found_color, c,
-                                                   base,
-                                                   position + current_size,
-                                                   pass - 1, dir_bit);
-        else
-          /* Here we should check all */
-          distance =
-            mlib_search_quadrant_U8_3(node->contents.quadrants[i], distance,
-                                      found_color, c[0], c[1], c[2], base);
-      }
-    }
-  }
-
-  return distance;
-}
-
-/***************************************************************/
-mlib_u32 mlib_search_quadrant_part_to_right_U8_3(struct lut_node_3 *node,
-                                                 mlib_u32          distance,
-                                                  mlib_s32    *found_color,
-                                                 const mlib_u32    *c,
-                                                 const mlib_u8     **base,
-                                                 mlib_u32          position,
-                                                 mlib_s32          pass,
-                                                 mlib_s32          dir_bit)
-{
-  mlib_u32 current_size = 1 << pass;
-  mlib_s32 i;
-  static mlib_s32 opposite_quadrants[3][4] = {
-    {1, 3, 5, 7},
-    {2, 3, 6, 7},
-    {4, 5, 6, 7}
-  };
-
-/* Search only quadrant's half untill it is necessary to check the
-  whole quadrant */
-
-  if (distance <= (c[dir_bit] - position - current_size) * (c[dir_bit] - position - current_size)) { /* Search half of quadrant */
-    for (i = 0; i < 4; i++) {
-      mlib_s32 qq = opposite_quadrants[dir_bit][i];
-
-      if (node->tag & (1 << qq)) {
-        /* Here is alone color cell. Check the distance */
-        mlib_s32 newindex = node->contents.index[qq];
-        mlib_u32 newpalc0, newpalc1, newpalc2;
-        mlib_u32 newdistance;
-
-        newpalc0 = base[0][newindex];
-        newpalc1 = base[1][newindex];
-        newpalc2 = base[2][newindex];
-        newdistance = FIND_DISTANCE_3(c[0], newpalc0, c[1], newpalc1, c[2], newpalc2, 0);
-
-        if (distance > newdistance) {
-          *found_color = newindex;
-          distance = newdistance;
-        }
-      }
-      else if (node->contents.quadrants[qq])
-        distance =
-          mlib_search_quadrant_part_to_right_U8_3(node->contents.quadrants[qq],
-                                                  distance, found_color, c,
-                                                  base, position + current_size,
-                                                  pass - 1, dir_bit);
-    }
-  }
-  else {                                    /* Search whole quadrant */
-
-    mlib_s32 mask = 1 << dir_bit;
-
-    for (i = 0; i < 8; i++) {
-
-      if (node->tag & (1 << i)) {
-        /* Here is alone color cell. Check the distance */
-        mlib_s32 newindex = node->contents.index[i];
-        mlib_u32 newpalc0, newpalc1, newpalc2;
-        mlib_u32 newdistance;
-
-        newpalc0 = base[0][newindex];
-        newpalc1 = base[1][newindex];
-        newpalc2 = base[2][newindex];
-        newdistance = FIND_DISTANCE_3(c[0], newpalc0, c[1], newpalc1, c[2], newpalc2, 0);
-
-        if (distance > newdistance) {
-          *found_color = newindex;
-          distance = newdistance;
-        }
-      }
-      else if (node->contents.quadrants[i]) {
-
-        if (i & mask)
-          /* Here we should check all */
-          distance =
-            mlib_search_quadrant_U8_3(node->contents.quadrants[i], distance,
-                                      found_color, c[0], c[1], c[2], base);
-        else
-          /* This quadrant may require partial checking */
-          distance =
-            mlib_search_quadrant_part_to_right_U8_3(node->contents.quadrants[i],
-                                                    distance, found_color, c,
-                                                    base, position, pass - 1, dir_bit);
-      }
-    }
-  }
-
-  return distance;
-}
-
-/***************************************************************/
-mlib_u32 mlib_search_quadrant_S16_3(struct lut_node_3 *node,
-                                    mlib_u32          distance,
-                                     mlib_s32    *found_color,
-                                    mlib_u32          c0,
-                                    mlib_u32          c1,
-                                    mlib_u32          c2,
-                                    const mlib_s16    **base)
-{
-  mlib_s32 i;
-
-  for (i = 0; i < 8; i++) {
-
-    if (node->tag & (1 << i)) {
-      /* Here is alone color cell. Check the distance */
-      mlib_s32 newindex = node->contents.index[i];
-      mlib_u32 newpalc0, newpalc1, newpalc2;
-      mlib_u32 newdistance;
-
-      newpalc0 = base[0][newindex] - MLIB_S16_MIN;
-      newpalc1 = base[1][newindex] - MLIB_S16_MIN;
-      newpalc2 = base[2][newindex] - MLIB_S16_MIN;
-      newdistance = FIND_DISTANCE_3(c0, newpalc0, c1, newpalc1, c2, newpalc2, 2);
-
-      if (distance > newdistance) {
-        *found_color = newindex;
-        distance = newdistance;
-      }
-    }
-    else if (node->contents.quadrants[i])
-      distance =
-        mlib_search_quadrant_S16_3(node->contents.quadrants[i], distance,
-                                   found_color, c0, c1, c2, base);
-  }
-
-  return distance;
-}
-
-/***************************************************************/
-mlib_u32 mlib_search_quadrant_part_to_left_S16_3(struct lut_node_3 *node,
-                                                 mlib_u32          distance,
-                                                  mlib_s32    *found_color,
-                                                 const mlib_u32    *c,
-                                                 const mlib_s16    **base,
-                                                 mlib_u32          position,
-                                                 mlib_s32          pass,
-                                                 mlib_s32          dir_bit)
-{
-  mlib_u32 current_size = 1 << pass;
-  mlib_s32 i;
-  static mlib_s32 opposite_quadrants[3][4] = {
-    {0, 2, 4, 6},
-    {0, 1, 4, 5},
-    {0, 1, 2, 3}
-  };
-
-/* Search only quadrant's half untill it is necessary to check the
-  whole quadrant */
-
-  if (distance < (((position + current_size - c[dir_bit]) * (position + current_size - c[dir_bit])) >> 2)) { /* Search half of quadrant */
-    for (i = 0; i < 4; i++) {
-      mlib_s32 qq = opposite_quadrants[dir_bit][i];
-
-      if (node->tag & (1 << qq)) {
-        /* Here is alone color cell. Check the distance */
-        mlib_s32 newindex = node->contents.index[qq];
-        mlib_u32 newpalc0, newpalc1, newpalc2;
-        mlib_u32 newdistance;
-
-        newpalc0 = base[0][newindex] - MLIB_S16_MIN;
-        newpalc1 = base[1][newindex] - MLIB_S16_MIN;
-        newpalc2 = base[2][newindex] - MLIB_S16_MIN;
-        newdistance = FIND_DISTANCE_3(c[0], newpalc0, c[1], newpalc1, c[2], newpalc2, 2);
-
-        if (distance > newdistance) {
-          *found_color = newindex;
-          distance = newdistance;
-        }
-      }
-      else if (node->contents.quadrants[qq])
-        distance =
-          mlib_search_quadrant_part_to_left_S16_3(node->contents.quadrants[qq],
-                                                  distance, found_color, c,
-                                                  base, position, pass - 1, dir_bit);
-    }
-  }
-  else {                                    /* Search whole quadrant */
-
-    mlib_s32 mask = 1 << dir_bit;
-
-    for (i = 0; i < 8; i++) {
-
-      if (node->tag & (1 << i)) {
-        /* Here is alone color cell. Check the distance */
-        mlib_s32 newindex = node->contents.index[i];
-        mlib_u32 newpalc0, newpalc1, newpalc2;
-        mlib_u32 newdistance;
-
-        newpalc0 = base[0][newindex] - MLIB_S16_MIN;
-        newpalc1 = base[1][newindex] - MLIB_S16_MIN;
-        newpalc2 = base[2][newindex] - MLIB_S16_MIN;
-        newdistance = FIND_DISTANCE_3(c[0], newpalc0, c[1], newpalc1, c[2], newpalc2, 2);
-
-        if (distance > newdistance) {
-          *found_color = newindex;
-          distance = newdistance;
-        }
-      }
-      else if (node->contents.quadrants[i]) {
-
-        if (i & mask)
-          /* This quadrant may require partial checking */
-          distance =
-            mlib_search_quadrant_part_to_left_S16_3(node->contents.quadrants[i],
-                                                    distance, found_color, c,
-                                                    base,
-                                                    position + current_size,
-                                                    pass - 1, dir_bit);
-        else
-          /* Here we should check all */
-          distance =
-            mlib_search_quadrant_S16_3(node->contents.quadrants[i], distance,
-                                       found_color, c[0], c[1], c[2], base);
-      }
-    }
-  }
-
-  return distance;
-}
-
-/***************************************************************/
-mlib_u32 mlib_search_quadrant_part_to_right_S16_3(struct lut_node_3 *node,
-                                                  mlib_u32          distance,
-                                                   mlib_s32    *found_color,
-                                                  const mlib_u32    *c,
-                                                  const mlib_s16    **base,
-                                                  mlib_u32          position,
-                                                  mlib_s32          pass,
-                                                  mlib_s32          dir_bit)
-{
-  mlib_u32 current_size = 1 << pass;
-  mlib_s32 i;
-  static mlib_s32 opposite_quadrants[3][4] = {
-    {1, 3, 5, 7},
-    {2, 3, 6, 7},
-    {4, 5, 6, 7}
-  };
-
-/* Search only quadrant's half untill it is necessary to check the
-  whole quadrant */
-
-  if (distance <= (((c[dir_bit] - position - current_size) * (c[dir_bit] - position - current_size)) >> 2)) { /* Search half of quadrant */
-    for (i = 0; i < 4; i++) {
-      mlib_s32 qq = opposite_quadrants[dir_bit][i];
-
-      if (node->tag & (1 << qq)) {
-        /* Here is alone color cell. Check the distance */
-        mlib_s32 newindex = node->contents.index[qq];
-        mlib_u32 newpalc0, newpalc1, newpalc2;
-        mlib_u32 newdistance;
-
-        newpalc0 = base[0][newindex] - MLIB_S16_MIN;
-        newpalc1 = base[1][newindex] - MLIB_S16_MIN;
-        newpalc2 = base[2][newindex] - MLIB_S16_MIN;
-        newdistance = FIND_DISTANCE_3(c[0], newpalc0, c[1], newpalc1, c[2], newpalc2, 2);
-
-        if (distance > newdistance) {
-          *found_color = newindex;
-          distance = newdistance;
-        }
-      }
-      else if (node->contents.quadrants[qq])
-        distance =
-          mlib_search_quadrant_part_to_right_S16_3(node->contents.quadrants[qq],
-                                                   distance, found_color, c,
-                                                   base,
-                                                   position + current_size,
-                                                   pass - 1, dir_bit);
-    }
-  }
-  else {                                    /* Search whole quadrant */
-
-    mlib_s32 mask = 1 << dir_bit;
-
-    for (i = 0; i < 8; i++) {
-
-      if (node->tag & (1 << i)) {
-        /* Here is alone color cell. Check the distance */
-        mlib_s32 newindex = node->contents.index[i];
-        mlib_u32 newpalc0, newpalc1, newpalc2;
-        mlib_u32 newdistance;
-
-        newpalc0 = base[0][newindex] - MLIB_S16_MIN;
-        newpalc1 = base[1][newindex] - MLIB_S16_MIN;
-        newpalc2 = base[2][newindex] - MLIB_S16_MIN;
-        newdistance = FIND_DISTANCE_3(c[0], newpalc0, c[1], newpalc1, c[2], newpalc2, 2);
-
-        if (distance > newdistance) {
-          *found_color = newindex;
-          distance = newdistance;
-        }
-      }
-      else if (node->contents.quadrants[i]) {
-
-        if (i & mask)
-          /* Here we should check all */
-          distance =
-            mlib_search_quadrant_S16_3(node->contents.quadrants[i], distance,
-                                       found_color, c[0], c[1], c[2], base);
-        else
-          /* This quadrant may require partial checking */
-          distance =
-            mlib_search_quadrant_part_to_right_S16_3(node->contents.
-                                                     quadrants[i], distance,
-                                                     found_color, c, base,
-                                                     position, pass - 1, dir_bit);
-      }
-    }
-  }
-
-  return distance;
-}
-
-/***************************************************************/
-mlib_u32 mlib_search_quadrant_U8_4(struct lut_node_4 *node,
-                                   mlib_u32          distance,
-                                    mlib_s32    *found_color,
-                                   mlib_u32          c0,
-                                   mlib_u32          c1,
-                                   mlib_u32          c2,
-                                   mlib_u32          c3,
-                                   const mlib_u8     **base)
-{
-  mlib_s32 i;
-
-  for (i = 0; i < 16; i++) {
-
-    if (node->tag & (1 << i)) {
-      /* Here is alone color cell. Check the distance */
-      mlib_s32 newindex = node->contents.index[i];
-      mlib_u32 newpalc0, newpalc1, newpalc2, newpalc3;
-      mlib_u32 newdistance;
-
-      newpalc0 = base[0][newindex];
-      newpalc1 = base[1][newindex];
-      newpalc2 = base[2][newindex];
-      newpalc3 = base[3][newindex];
-      newdistance = FIND_DISTANCE_4(c0, newpalc0,
-                                    c1, newpalc1, c2, newpalc2, c3, newpalc3, 0);
-
-      if (distance > newdistance) {
-        *found_color = newindex;
-        distance = newdistance;
-      }
-    }
-    else if (node->contents.quadrants[i])
-      distance =
-        mlib_search_quadrant_U8_4(node->contents.quadrants[i], distance,
-                                  found_color, c0, c1, c2, c3, base);
-  }
-
-  return distance;
-}
-
-/***************************************************************/
-mlib_u32 mlib_search_quadrant_part_to_left_U8_4(struct lut_node_4 *node,
-                                                mlib_u32          distance,
-                                                 mlib_s32    *found_color,
-                                                const mlib_u32    *c,
-                                                const mlib_u8     **base,
-                                                mlib_u32          position,
-                                                mlib_s32          pass,
-                                                mlib_s32          dir_bit)
-{
-  mlib_u32 current_size = 1 << pass;
-  mlib_s32 i;
-  static mlib_s32 opposite_quadrants[4][8] = {
-    {0, 2, 4, 6, 8, 10, 12, 14},
-    {0, 1, 4, 5, 8, 9, 12, 13},
-    {0, 1, 2, 3, 8, 9, 10, 11},
-    {0, 1, 2, 3, 4, 5, 6, 7}
-  };
-
-/* Search only quadrant's half untill it is necessary to check the
-  whole quadrant */
-
-  if (distance < (position + current_size - c[dir_bit]) * (position + current_size - c[dir_bit])) { /* Search half of quadrant */
-    for (i = 0; i < 8; i++) {
-      mlib_s32 qq = opposite_quadrants[dir_bit][i];
-
-      if (node->tag & (1 << qq)) {
-        /* Here is alone color cell. Check the distance */
-        mlib_s32 newindex = node->contents.index[qq];
-        mlib_u32 newpalc0, newpalc1, newpalc2, newpalc3;
-        mlib_u32 newdistance;
-
-        newpalc0 = base[0][newindex];
-        newpalc1 = base[1][newindex];
-        newpalc2 = base[2][newindex];
-        newpalc3 = base[3][newindex];
-        newdistance = FIND_DISTANCE_4(c[0], newpalc0,
-                                      c[1], newpalc1, c[2], newpalc2, c[3], newpalc3, 0);
-
-        if (distance > newdistance) {
-          *found_color = newindex;
-          distance = newdistance;
-        }
-      }
-      else if (node->contents.quadrants[qq])
-        distance =
-          mlib_search_quadrant_part_to_left_U8_4(node->contents.quadrants[qq],
-                                                 distance, found_color, c, base,
-                                                 position, pass - 1, dir_bit);
-    }
-  }
-  else {                                    /* Search whole quadrant */
-
-    mlib_s32 mask = 1 << dir_bit;
-
-    for (i = 0; i < 16; i++) {
-
-      if (node->tag & (1 << i)) {
-        /* Here is alone color cell. Check the distance */
-        mlib_s32 newindex = node->contents.index[i];
-        mlib_u32 newpalc0, newpalc1, newpalc2, newpalc3;
-        mlib_u32 newdistance;
-
-        newpalc0 = base[0][newindex];
-        newpalc1 = base[1][newindex];
-        newpalc2 = base[2][newindex];
-        newpalc3 = base[3][newindex];
-        newdistance = FIND_DISTANCE_4(c[0], newpalc0,
-                                      c[1], newpalc1, c[2], newpalc2, c[3], newpalc3, 0);
-
-        if (distance > newdistance) {
-          *found_color = newindex;
-          distance = newdistance;
-        }
-      }
-      else if (node->contents.quadrants[i]) {
-
-        if (i & mask)
-          /* This quadrant may require partial checking */
-          distance =
-            mlib_search_quadrant_part_to_left_U8_4(node->contents.quadrants[i],
-                                                   distance, found_color, c,
-                                                   base,
-                                                   position + current_size,
-                                                   pass - 1, dir_bit);
-        else
-          /* Here we should check all */
-          distance =
-            mlib_search_quadrant_U8_4(node->contents.quadrants[i], distance,
-                                      found_color, c[0], c[1], c[2], c[3], base);
-      }
-    }
-  }
-
-  return distance;
-}
-
-/***************************************************************/
-mlib_u32 mlib_search_quadrant_part_to_right_U8_4(struct lut_node_4 *node,
-                                                 mlib_u32          distance,
-                                                  mlib_s32    *found_color,
-                                                 const mlib_u32    *c,
-                                                 const mlib_u8     **base,
-                                                 mlib_u32          position,
-                                                 mlib_s32          pass,
-                                                 mlib_s32          dir_bit)
-{
-  mlib_u32 current_size = 1 << pass;
-  mlib_s32 i;
-  static mlib_s32 opposite_quadrants[4][8] = {
-    {1, 3, 5, 7, 9, 11, 13, 15},
-    {2, 3, 6, 7, 10, 11, 14, 15},
-    {4, 5, 6, 7, 12, 13, 14, 15},
-    {8, 9, 10, 11, 12, 13, 14, 15}
-  };
-
-/* Search only quadrant's half untill it is necessary to check the
-  whole quadrant */
-
-  if (distance <= (c[dir_bit] - position - current_size) * (c[dir_bit] - position - current_size)) { /* Search half of quadrant */
-    for (i = 0; i < 8; i++) {
-      mlib_s32 qq = opposite_quadrants[dir_bit][i];
-
-      if (node->tag & (1 << qq)) {
-        /* Here is alone color cell. Check the distance */
-        mlib_s32 newindex = node->contents.index[qq];
-        mlib_u32 newpalc0, newpalc1, newpalc2, newpalc3;
-        mlib_u32 newdistance;
-
-        newpalc0 = base[0][newindex];
-        newpalc1 = base[1][newindex];
-        newpalc2 = base[2][newindex];
-        newpalc3 = base[3][newindex];
-        newdistance = FIND_DISTANCE_4(c[0], newpalc0,
-                                      c[1], newpalc1, c[2], newpalc2, c[3], newpalc3, 0);
-
-        if (distance > newdistance) {
-          *found_color = newindex;
-          distance = newdistance;
-        }
-      }
-      else if (node->contents.quadrants[qq])
-        distance =
-          mlib_search_quadrant_part_to_right_U8_4(node->contents.quadrants[qq],
-                                                  distance, found_color, c,
-                                                  base, position + current_size,
-                                                  pass - 1, dir_bit);
-    }
-  }
-  else {                                    /* Search whole quadrant */
-
-    mlib_s32 mask = 1 << dir_bit;
-
-    for (i = 0; i < 16; i++) {
-
-      if (node->tag & (1 << i)) {
-        /* Here is alone color cell. Check the distance */
-        mlib_s32 newindex = node->contents.index[i];
-        mlib_u32 newpalc0, newpalc1, newpalc2, newpalc3;
-        mlib_u32 newdistance;
-
-        newpalc0 = base[0][newindex];
-        newpalc1 = base[1][newindex];
-        newpalc2 = base[2][newindex];
-        newpalc3 = base[3][newindex];
-        newdistance = FIND_DISTANCE_4(c[0], newpalc0,
-                                      c[1], newpalc1, c[2], newpalc2, c[3], newpalc3, 0);
-
-        if (distance > newdistance) {
-          *found_color = newindex;
-          distance = newdistance;
-        }
-      }
-      else if (node->contents.quadrants[i]) {
-
-        if (i & mask)
-          /* Here we should check all */
-          distance =
-            mlib_search_quadrant_U8_4(node->contents.quadrants[i], distance,
-                                      found_color, c[0], c[1], c[2], c[3], base);
-        else
-          /* This quadrant may require partial checking */
-          distance =
-            mlib_search_quadrant_part_to_right_U8_4(node->contents.quadrants[i],
-                                                    distance, found_color, c,
-                                                    base, position, pass - 1, dir_bit);
-      }
-    }
-  }
-
-  return distance;
-}
-
-/***************************************************************/
-mlib_u32 mlib_search_quadrant_S16_4(struct lut_node_4 *node,
-                                    mlib_u32          distance,
-                                     mlib_s32    *found_color,
-                                    mlib_u32          c0,
-                                    mlib_u32          c1,
-                                    mlib_u32          c2,
-                                    mlib_u32          c3,
-                                    const mlib_s16    **base)
-{
-  mlib_s32 i;
-
-  for (i = 0; i < 16; i++) {
-
-    if (node->tag & (1 << i)) {
-      /* Here is alone color cell. Check the distance */
-      mlib_s32 newindex = node->contents.index[i];
-      mlib_u32 newpalc0, newpalc1, newpalc2, newpalc3;
-      mlib_u32 newdistance;
-
-      newpalc0 = base[0][newindex] - MLIB_S16_MIN;
-      newpalc1 = base[1][newindex] - MLIB_S16_MIN;
-      newpalc2 = base[2][newindex] - MLIB_S16_MIN;
-      newpalc3 = base[3][newindex] - MLIB_S16_MIN;
-      newdistance = FIND_DISTANCE_4(c0, newpalc0,
-                                    c1, newpalc1, c2, newpalc2, c3, newpalc3, 2);
-
-      if (distance > newdistance) {
-        *found_color = newindex;
-        distance = newdistance;
-      }
-    }
-    else if (node->contents.quadrants[i])
-      distance =
-        mlib_search_quadrant_S16_4(node->contents.quadrants[i], distance,
-                                   found_color, c0, c1, c2, c3, base);
-  }
-
-  return distance;
-}
-
-/***************************************************************/
-mlib_u32 mlib_search_quadrant_part_to_left_S16_4(struct lut_node_4 *node,
-                                                 mlib_u32          distance,
-                                                  mlib_s32    *found_color,
-                                                 const mlib_u32    *c,
-                                                 const mlib_s16    **base,
-                                                 mlib_u32          position,
-                                                 mlib_s32          pass,
-                                                 mlib_s32          dir_bit)
-{
-  mlib_u32 current_size = 1 << pass;
-  mlib_s32 i;
-  static mlib_s32 opposite_quadrants[4][8] = {
-    {0, 2, 4, 6, 8, 10, 12, 14},
-    {0, 1, 4, 5, 8, 9, 12, 13},
-    {0, 1, 2, 3, 8, 9, 10, 11},
-    {0, 1, 2, 3, 4, 5, 6, 7}
-  };
-
-/* Search only quadrant's half untill it is necessary to check the
-  whole quadrant */
-
-  if (distance < (((position + current_size - c[dir_bit]) * (position + current_size - c[dir_bit])) >> 2)) { /* Search half of quadrant */
-    for (i = 0; i < 8; i++) {
-      mlib_s32 qq = opposite_quadrants[dir_bit][i];
-
-      if (node->tag & (1 << qq)) {
-        /* Here is alone color cell. Check the distance */
-        mlib_s32 newindex = node->contents.index[qq];
-        mlib_u32 newpalc0, newpalc1, newpalc2, newpalc3;
-        mlib_u32 newdistance;
-
-        newpalc0 = base[0][newindex] - MLIB_S16_MIN;
-        newpalc1 = base[1][newindex] - MLIB_S16_MIN;
-        newpalc2 = base[2][newindex] - MLIB_S16_MIN;
-        newpalc3 = base[3][newindex] - MLIB_S16_MIN;
-        newdistance = FIND_DISTANCE_4(c[0], newpalc0,
-                                      c[1], newpalc1, c[2], newpalc2, c[3], newpalc3, 2);
-
-        if (distance > newdistance) {
-          *found_color = newindex;
-          distance = newdistance;
-        }
-      }
-      else if (node->contents.quadrants[qq])
-        distance =
-          mlib_search_quadrant_part_to_left_S16_4(node->contents.quadrants[qq],
-                                                  distance, found_color, c,
-                                                  base, position, pass - 1, dir_bit);
-    }
-  }
-  else {                                    /* Search whole quadrant */
-
-    mlib_s32 mask = 1 << dir_bit;
-
-    for (i = 0; i < 16; i++) {
-
-      if (node->tag & (1 << i)) {
-        /* Here is alone color cell. Check the distance */
-        mlib_s32 newindex = node->contents.index[i];
-        mlib_u32 newpalc0, newpalc1, newpalc2, newpalc3;
-        mlib_u32 newdistance;
-
-        newpalc0 = base[0][newindex] - MLIB_S16_MIN;
-        newpalc1 = base[1][newindex] - MLIB_S16_MIN;
-        newpalc2 = base[2][newindex] - MLIB_S16_MIN;
-        newpalc3 = base[3][newindex] - MLIB_S16_MIN;
-        newdistance = FIND_DISTANCE_4(c[0], newpalc0,
-                                      c[1], newpalc1, c[2], newpalc2, c[3], newpalc3, 2);
-
-        if (distance > newdistance) {
-          *found_color = newindex;
-          distance = newdistance;
-        }
-      }
-      else if (node->contents.quadrants[i]) {
-
-        if (i & mask)
-          /* This quadrant may require partial checking */
-          distance =
-            mlib_search_quadrant_part_to_left_S16_4(node->contents.quadrants[i],
-                                                    distance, found_color, c,
-                                                    base,
-                                                    position + current_size,
-                                                    pass - 1, dir_bit);
-        else
-          /* Here we should check all */
-          distance =
-            mlib_search_quadrant_S16_4(node->contents.quadrants[i], distance,
-                                       found_color, c[0], c[1], c[2], c[3], base);
-      }
-    }
-  }
-
-  return distance;
-}
-
-/***************************************************************/
-mlib_u32 mlib_search_quadrant_part_to_right_S16_4(struct lut_node_4 *node,
-                                                  mlib_u32          distance,
-                                                   mlib_s32    *found_color,
-                                                  const mlib_u32    *c,
-                                                  const mlib_s16    **base,
-                                                  mlib_u32          position,
-                                                  mlib_s32          pass,
-                                                  mlib_s32          dir_bit)
-{
-  mlib_u32 current_size = 1 << pass;
-  mlib_s32 i;
-  static mlib_s32 opposite_quadrants[4][8] = {
-    {1, 3, 5, 7, 9, 11, 13, 15},
-    {2, 3, 6, 7, 10, 11, 14, 15},
-    {4, 5, 6, 7, 12, 13, 14, 15},
-    {8, 9, 10, 11, 12, 13, 14, 15}
-  };
-
-/* Search only quadrant's half untill it is necessary to check the
-  whole quadrant */
-
-  if (distance <= (((c[dir_bit] - position - current_size) * (c[dir_bit] - position - current_size)) >> 2)) { /* Search half of quadrant */
-    for (i = 0; i < 8; i++) {
-      mlib_s32 qq = opposite_quadrants[dir_bit][i];
-
-      if (node->tag & (1 << qq)) {
-        /* Here is alone color cell. Check the distance */
-        mlib_s32 newindex = node->contents.index[qq];
-        mlib_u32 newpalc0, newpalc1, newpalc2, newpalc3;
-        mlib_u32 newdistance;
-
-        newpalc0 = base[0][newindex] - MLIB_S16_MIN;
-        newpalc1 = base[1][newindex] - MLIB_S16_MIN;
-        newpalc2 = base[2][newindex] - MLIB_S16_MIN;
-        newpalc3 = base[3][newindex] - MLIB_S16_MIN;
-        newdistance = FIND_DISTANCE_4(c[0], newpalc0,
-                                      c[1], newpalc1, c[2], newpalc2, c[3], newpalc3, 2);
-
-        if (distance > newdistance) {
-          *found_color = newindex;
-          distance = newdistance;
-        }
-      }
-      else if (node->contents.quadrants[qq])
-        distance =
-          mlib_search_quadrant_part_to_right_S16_4(node->contents.quadrants[qq],
-                                                   distance, found_color, c,
-                                                   base,
-                                                   position + current_size,
-                                                   pass - 1, dir_bit);
-    }
-  }
-  else {                                    /* Search whole quadrant */
-
-    mlib_s32 mask = 1 << dir_bit;
-
-    for (i = 0; i < 16; i++) {
-
-      if (node->tag & (1 << i)) {
-        /* Here is alone color cell. Check the distance */
-        mlib_s32 newindex = node->contents.index[i];
-        mlib_u32 newpalc0, newpalc1, newpalc2, newpalc3;
-        mlib_u32 newdistance;
-
-        newpalc0 = base[0][newindex] - MLIB_S16_MIN;
-        newpalc1 = base[1][newindex] - MLIB_S16_MIN;
-        newpalc2 = base[2][newindex] - MLIB_S16_MIN;
-        newpalc3 = base[3][newindex] - MLIB_S16_MIN;
-        newdistance = FIND_DISTANCE_4(c[0], newpalc0,
-                                      c[1], newpalc1, c[2], newpalc2, c[3], newpalc3, 2);
-
-        if (distance > newdistance) {
-          *found_color = newindex;
-          distance = newdistance;
-        }
-      }
-      else if (node->contents.quadrants[i]) {
-
-        if (i & mask)
-          /* Here we should check all */
-          distance =
-            mlib_search_quadrant_S16_4(node->contents.quadrants[i], distance,
-                                       found_color, c[0], c[1], c[2], c[3], base);
-        else
-          /* This quadrant may require partial checking */
-          distance =
-            mlib_search_quadrant_part_to_right_S16_4(node->contents.
-                                                     quadrants[i], distance,
-                                                     found_color, c, base,
-                                                     position, pass - 1, dir_bit);
-      }
-    }
-  }
-
-  return distance;
-}
-
-/***************************************************************/
-
-#define TAB_SIZE_mlib_u8   256
-#define TAB_SIZE_mlib_s16 1024
-
-#define SRC_mlib_u8(i)    src[i]
-#define SRC_mlib_s16(i)   (((mlib_u16*)src)[i] >> 6)
-
-/***************************************************************/
-
-#define DIMENSIONS_SEARCH_3(STYPE, DTYPE, STEP)                 \
-{                                                               \
-  DTYPE  *tab0 = ((mlib_colormap *)state)->table;               \
-  DTYPE  *tab1 = tab0 + TAB_SIZE_##STYPE;                       \
-  DTYPE  *tab2 = tab1 + TAB_SIZE_##STYPE;                       \
-  mlib_s32 i;                                                   \
-                                                                \
-  for (i = 0; i < length; i++) {                                \
-    dst[i] = tab0[SRC_##STYPE(0)] + tab1[SRC_##STYPE(1)] +      \
-             tab2[SRC_##STYPE(2)];                              \
-    src += STEP;                                                \
-  }                                                             \
-}
-
-/***************************************************************/
-
-#define DIMENSIONS_SEARCH_4(STYPE, DTYPE)                       \
-{                                                               \
-  DTYPE  *tab0 = ((mlib_colormap *)state)->table;               \
-  DTYPE  *tab1 = tab0 + TAB_SIZE_##STYPE;                       \
-  DTYPE  *tab2 = tab1 + TAB_SIZE_##STYPE;                       \
-  DTYPE  *tab3 = tab2 + TAB_SIZE_##STYPE;                       \
-  mlib_s32 i;                                                   \
-                                                                \
-  for (i = 0; i < length; i++) {                                \
-    dst[i] = tab0[SRC_##STYPE(0)] + tab1[SRC_##STYPE(1)] +      \
-             tab2[SRC_##STYPE(2)] + tab3[SRC_##STYPE(3)];       \
-    src += 4;                                                   \
-  }                                                             \
-}
-
-/***************************************************************/
-void mlib_ImageColorTrue2IndexLine_U8_U8_3(const mlib_u8 *src,
-                                           mlib_u8       *dst,
-                                           mlib_s32      length,
-                                           const void    *state)
-{
-  mlib_colormap *s = (mlib_colormap *)state;
-
-  switch (s->method) {
-#if LUT_BYTE_COLORS_3CHANNELS <= 256
-    case LUT_BINARY_TREE_SEARCH:
-      {
-        mlib_s32 bits = s->bits;
-        BINARY_TREE_SEARCH_3(U8, mlib_u8, 8, (MLIB_U8_MAX + 1), 0, 0, 3, 0);
-      }
-      break;
-
-#endif /* LUT_BYTE_COLORS_3CHANNELS <= 256 */
-    case LUT_COLOR_CUBE_SEARCH:
-      {
-        COLOR_CUBE_U8_3_SEARCH(mlib_u8, 0, 3);
-      }
-      break;
-
-    case LUT_STUPID_SEARCH:
-      {
-#ifdef USE_VIS_CODE
-        FIND_NEAREST_U8_3;
-#else
-        FIND_NEAREST_U8_3_C(0, 3);
-#endif
-      }
-      break;
-
-    case LUT_COLOR_DIMENSIONS:
-      DIMENSIONS_SEARCH_3(mlib_u8, mlib_u8, 3)
-      break;
-  }
-}
-
-/***************************************************************/
-void mlib_ImageColorTrue2IndexLine_U8_U8_3_in_4(const mlib_u8 *src,
-                                                mlib_u8       *dst,
-                                                mlib_s32      length,
-                                                const void    *state)
-{
-  mlib_colormap *s = (mlib_colormap *)state;
-
-  switch (s->method) {
-#if LUT_BYTE_COLORS_3CHANNELS <= 256
-    case LUT_BINARY_TREE_SEARCH:
-      {
-        mlib_s32 bits = s->bits;
-        BINARY_TREE_SEARCH_3(U8, mlib_u8, 8, (MLIB_U8_MAX + 1), 0, 1, 4, 0);
-        break;
-      }
-
-#endif /* LUT_BYTE_COLORS_3CHANNELS <= 256 */
-    case LUT_COLOR_CUBE_SEARCH:
-      {
-        COLOR_CUBE_U8_3_SEARCH(mlib_u8, 1, 4);
-        break;
-      }
-
-    case LUT_STUPID_SEARCH:
-      {
-#ifdef USE_VIS_CODE
-        FIND_NEAREST_U8_3_IN4;
-#else
-        FIND_NEAREST_U8_3_C(1, 4);
-#endif
-        break;
-      }
-
-    case LUT_COLOR_DIMENSIONS:
-      src++;
-      DIMENSIONS_SEARCH_3(mlib_u8, mlib_u8, 4)
-      break;
-  }
-}
-
-/***************************************************************/
-void mlib_ImageColorTrue2IndexLine_U8_U8_4(const mlib_u8 *src,
-                                           mlib_u8       *dst,
-                                           mlib_s32      length,
-                                           const void    *state)
-{
-  mlib_colormap *s = (mlib_colormap *)state;
-
-  switch (s->method) {
-#if LUT_BYTE_COLORS_4CHANNELS <= 256
-    case LUT_BINARY_TREE_SEARCH:
-      {
-        mlib_s32 bits = s->bits;
-        BINARY_TREE_SEARCH_4(U8, mlib_u8, 8, (MLIB_U8_MAX + 1), 0, 0);
-        break;
-      }
-
-#endif /* LUT_BYTE_COLORS_4CHANNELS <= 256 */
-    case LUT_COLOR_CUBE_SEARCH:
-      {
-        COLOR_CUBE_U8_4_SEARCH(mlib_u8);
-        break;
-      }
-
-    case LUT_STUPID_SEARCH:
-      {
-#ifdef USE_VIS_CODE
-        FIND_NEAREST_U8_4;
-#else
-        FIND_NEAREST_U8_4_C;
-#endif
-        break;
-      }
-
-    case LUT_COLOR_DIMENSIONS:
-      DIMENSIONS_SEARCH_4(mlib_u8, mlib_u8)
-      break;
-  }
-}
-
-/***************************************************************/
-void mlib_ImageColorTrue2IndexLine_U8_S16_3(const mlib_u8 *src,
-                                            mlib_s16      *dst,
-                                            mlib_s32      length,
-                                            const void    *state)
-{
-  mlib_colormap *s = (mlib_colormap *)state;
-  mlib_s32 bits = s->bits;
-
-  switch (s->method) {
-    case LUT_BINARY_TREE_SEARCH:
-      {
-        BINARY_TREE_SEARCH_3(U8, mlib_u8, 8, (MLIB_U8_MAX + 1), 0, 0, 3, 0);
-        break;
-      }
-
-    case LUT_COLOR_CUBE_SEARCH:
-      {
-        switch (s->indexsize) {
-          case 1:
-            {
-              COLOR_CUBE_U8_3_SEARCH(mlib_u8, 0, 3);
-              break;
-            }
-
-          case 2:
-            {
-              COLOR_CUBE_U8_3_SEARCH(mlib_s16, 0, 3);
-              break;
-            }
-        }
-
-        break;
-      }
-
-    case LUT_STUPID_SEARCH:
-      {
-#ifdef USE_VIS_CODE
-        FIND_NEAREST_U8_3;
-#else
-        FIND_NEAREST_U8_3_C(0, 3);
-#endif
-        break;
-      }
-
-    case LUT_COLOR_DIMENSIONS:
-      DIMENSIONS_SEARCH_3(mlib_u8, mlib_s16, 3)
-      break;
-  }
-}
-
-/***************************************************************/
-void mlib_ImageColorTrue2IndexLine_U8_S16_3_in_4(const mlib_u8 *src,
-                                                 mlib_s16      *dst,
-                                                 mlib_s32      length,
-                                                 const void    *state)
-{
-  mlib_colormap *s = (mlib_colormap *)state;
-  mlib_s32 bits = s->bits;
-
-  switch (s->method) {
-    case LUT_BINARY_TREE_SEARCH:
-      {
-        BINARY_TREE_SEARCH_3(U8, mlib_u8, 8, (MLIB_U8_MAX + 1), 0, 1, 4, 0);
-        break;
-      }
-
-    case LUT_COLOR_CUBE_SEARCH:
-      {
-        switch (s->indexsize) {
-          case 1:
-            {
-              COLOR_CUBE_U8_3_SEARCH(mlib_u8, 1, 4);
-              break;
-            }
-
-          case 2:
-            {
-              COLOR_CUBE_U8_3_SEARCH(mlib_s16, 1, 4);
-              break;
-            }
-        }
-
-        break;
-      }
-
-    case LUT_STUPID_SEARCH:
-      {
-#ifdef USE_VIS_CODE
-        FIND_NEAREST_U8_3_IN4;
-#else
-        FIND_NEAREST_U8_3_C(1, 4);
-#endif
-        break;
-      }
-
-    case LUT_COLOR_DIMENSIONS:
-      src++;
-      DIMENSIONS_SEARCH_3(mlib_u8, mlib_s16, 4)
-      break;
-  }
-}
-
-/***************************************************************/
-void mlib_ImageColorTrue2IndexLine_U8_S16_4(const mlib_u8 *src,
-                                            mlib_s16      *dst,
-                                            mlib_s32      length,
-                                            const void    *state)
-{
-  mlib_colormap *s = (mlib_colormap *)state;
-  mlib_s32 bits = s->bits;
-
-  switch (s->method) {
-    case LUT_BINARY_TREE_SEARCH:
-      {
-        BINARY_TREE_SEARCH_4(U8, mlib_u8, 8, (MLIB_U8_MAX + 1), 0, 0);
-        break;
-      }
-
-    case LUT_COLOR_CUBE_SEARCH:
-      {
-        switch (s->indexsize) {
-          case 1:
-            {
-              COLOR_CUBE_U8_4_SEARCH(mlib_u8);
-              break;
-            }
-
-          case 2:
-            {
-              COLOR_CUBE_U8_4_SEARCH(mlib_s16);
-              break;
-            }
-        }
-
-        break;
-      }
-
-    case LUT_STUPID_SEARCH:
-      {
-#ifdef USE_VIS_CODE
-        FIND_NEAREST_U8_4;
-#else
-        FIND_NEAREST_U8_4_C;
-#endif
-        break;
-      }
-
-    case LUT_COLOR_DIMENSIONS:
-      DIMENSIONS_SEARCH_4(mlib_u8, mlib_s16)
-      break;
-  }
-}
-
-/***************************************************************/
-void mlib_ImageColorTrue2IndexLine_S16_S16_3(const mlib_s16 *src,
-                                             mlib_s16       *dst,
-                                             mlib_s32       length,
-                                             const void     *state)
-{
-  mlib_colormap *s = (mlib_colormap *)state;
-  mlib_s32 bits = s->bits;
-
-  switch (s->method) {
-    case LUT_BINARY_TREE_SEARCH:
-      {
-        BINARY_TREE_SEARCH_3(S16, mlib_s16, 16, ((MLIB_S16_MAX + 1) * 2),
-                             MLIB_S16_MIN, 0, 3, 2);
-        break;
-      }
-
-    case LUT_COLOR_CUBE_SEARCH:
-      {
-        switch (s->indexsize) {
-          case 1:
-            {
-              COLOR_CUBE_S16_3_SEARCH(mlib_u8, 0, 3);
-              break;
-            }
-
-          case 2:
-            {
-              COLOR_CUBE_S16_3_SEARCH(mlib_s16, 0, 3);
-              break;
-            }
-        }
-
-        break;
-      }
-
-    case LUT_STUPID_SEARCH:
-      {
-        FIND_NEAREST_S16_3(0, 3);
-        break;
-      }
-
-    case LUT_COLOR_DIMENSIONS:
-      DIMENSIONS_SEARCH_3(mlib_s16, mlib_s16, 3)
-      break;
-  }
-}
-
-/***************************************************************/
-void mlib_ImageColorTrue2IndexLine_S16_S16_3_in_4(const mlib_s16 *src,
-                                                  mlib_s16       *dst,
-                                                  mlib_s32       length,
-                                                  const void     *state)
-{
-  mlib_colormap *s = (mlib_colormap *)state;
-  mlib_s32 bits = s->bits;
-
-  switch (s->method) {
-    case LUT_BINARY_TREE_SEARCH:
-      {
-        BINARY_TREE_SEARCH_3(S16, mlib_s16, 16, ((MLIB_S16_MAX + 1) * 2),
-                             MLIB_S16_MIN, 1, 4, 2);
-        break;
-      }
-
-    case LUT_COLOR_CUBE_SEARCH:
-      {
-        switch (s->indexsize) {
-          case 1:
-            {
-              COLOR_CUBE_S16_3_SEARCH(mlib_u8, 1, 4);
-              break;
-            }
-
-          case 2:
-            {
-              COLOR_CUBE_S16_3_SEARCH(mlib_s16, 1, 4);
-              break;
-            }
-        }
-
-        break;
-      }
-
-    case LUT_STUPID_SEARCH:
-      {
-        FIND_NEAREST_S16_3(1, 4);
-        break;
-      }
-
-    case LUT_COLOR_DIMENSIONS:
-      src++;
-      DIMENSIONS_SEARCH_3(mlib_s16, mlib_s16, 4)
-      break;
-  }
-}
-
-/***************************************************************/
-void mlib_ImageColorTrue2IndexLine_S16_S16_4(const mlib_s16 *src,
-                                             mlib_s16       *dst,
-                                             mlib_s32       length,
-                                             const void     *state)
-{
-  mlib_colormap *s = (mlib_colormap *)state;
-  mlib_s32 bits = s->bits;
-
-  switch (s->method) {
-    case LUT_BINARY_TREE_SEARCH:
-      {
-        BINARY_TREE_SEARCH_4(S16, mlib_s16, 16, ((MLIB_S16_MAX + 1) * 2),
-                             MLIB_S16_MIN, 2);
-        break;
-      }
-
-    case LUT_COLOR_CUBE_SEARCH:
-      {
-        switch (s->indexsize) {
-          case 1:
-            {
-              COLOR_CUBE_S16_4_SEARCH(mlib_u8);
-              break;
-            }
-
-          case 2:
-            {
-              COLOR_CUBE_S16_4_SEARCH(mlib_s16);
-              break;
-            }
-        }
-
-        break;
-      }
-
-    case LUT_STUPID_SEARCH:
-      {
-        FIND_NEAREST_S16_4;
-        break;
-      }
-
-    case LUT_COLOR_DIMENSIONS:
-      DIMENSIONS_SEARCH_4(mlib_s16, mlib_s16)
-      break;
-  }
-}
-
-/***************************************************************/
-void mlib_ImageColorTrue2IndexLine_S16_U8_3(const mlib_s16 *src,
-                                            mlib_u8        *dst,
-                                            mlib_s32       length,
-                                            const void     *state)
-{
-  mlib_colormap *s = (mlib_colormap *)state;
-
-  switch (s->method) {
-#if LUT_SHORT_COLORS_3CHANNELS <= 256
-    case LUT_BINARY_TREE_SEARCH:
-      {
-        mlib_s32 bits = s->bits;
-        BINARY_TREE_SEARCH_3(S16, mlib_s16, 16, ((MLIB_S16_MAX + 1) * 2),
-                             MLIB_S16_MIN, 0, 3, 2);
-        break;
-      }
-
-#endif /* LUT_SHORT_COLORS_3CHANNELS <= 256 */
-    case LUT_COLOR_CUBE_SEARCH:
-      {
-        COLOR_CUBE_S16_3_SEARCH(mlib_u8, 0, 3);
-        break;
-      }
-
-    case LUT_STUPID_SEARCH:
-      {
-        FIND_NEAREST_S16_3(0, 3);
-        break;
-      }
-
-    case LUT_COLOR_DIMENSIONS:
-      DIMENSIONS_SEARCH_3(mlib_s16, mlib_u8, 3)
-      break;
-  }
-}
-
-/***************************************************************/
-void mlib_ImageColorTrue2IndexLine_S16_U8_3_in_4(const mlib_s16 *src,
-                                                 mlib_u8        *dst,
-                                                 mlib_s32       length,
-                                                 const void     *state)
-{
-  mlib_colormap *s = (mlib_colormap *)state;
-
-  switch (s->method) {
-#if LUT_SHORT_COLORS_3CHANNELS <= 256
-    case LUT_BINARY_TREE_SEARCH:
-      {
-        mlib_s32 bits = s->bits;
-        BINARY_TREE_SEARCH_3(S16, mlib_s16, 16, ((MLIB_S16_MAX + 1) * 2),
-                             MLIB_S16_MIN, 1, 4, 2);
-        break;
-      }
-
-#endif /* LUT_SHORT_COLORS_3CHANNELS <= 256 */
-    case LUT_COLOR_CUBE_SEARCH:
-      {
-        COLOR_CUBE_S16_3_SEARCH(mlib_u8, 1, 4);
-        break;
-      }
-
-    case LUT_STUPID_SEARCH:
-      {
-        FIND_NEAREST_S16_3(1, 4);
-        break;
-      }
-
-    case LUT_COLOR_DIMENSIONS:
-      src++;
-      DIMENSIONS_SEARCH_3(mlib_s16, mlib_u8, 4)
-      break;
-  }
-}
-
-/***************************************************************/
-void mlib_ImageColorTrue2IndexLine_S16_U8_4(const mlib_s16 *src,
-                                            mlib_u8        *dst,
-                                            mlib_s32       length,
-                                            const void     *state)
-{
-  mlib_colormap *s = (mlib_colormap *)state;
-
-  switch (s->method) {
-#if LUT_SHORT_COLORS_4CHANNELS <= 256
-    case LUT_BINARY_TREE_SEARCH:
-      {
-        mlib_s32 bits = s->bits;
-        BINARY_TREE_SEARCH_4(S16, mlib_s16, 16, ((MLIB_S16_MAX + 1) * 2),
-                             MLIB_S16_MIN, 2);
-        break;
-      }
-
-#endif /* LUT_SHORT_COLORS_4CHANNELS <= 256 */
-    case LUT_COLOR_CUBE_SEARCH:
-      {
-        COLOR_CUBE_S16_4_SEARCH(mlib_u8);
-        break;
-      }
-
-    case LUT_STUPID_SEARCH:
-      {
-        FIND_NEAREST_S16_4;
-        break;
-      }
-
-    case LUT_COLOR_DIMENSIONS:
-      DIMENSIONS_SEARCH_4(mlib_s16, mlib_u8)
-      break;
-  }
-}
-
-/***************************************************************/
-
-#ifndef VIS
-
-void mlib_c_ImageThresh1_U81_1B(void     *psrc,
-                                void     *pdst,
-                                mlib_s32 src_stride,
-                                mlib_s32 dst_stride,
-                                mlib_s32 width,
-                                mlib_s32 height,
-                                void     *thresh,
-                                void     *ghigh,
-                                void     *glow,
-                                mlib_s32 dbit_off);
-
-/***************************************************************/
-
-void mlib_ImageColorTrue2IndexLine_U8_BIT_1(const mlib_u8 *src,
-                                            mlib_u8       *dst,
-                                            mlib_s32      bit_offset,
-                                            mlib_s32      length,
-                                            const void    *state)
-{
-  mlib_u8  *lut = ((mlib_colormap *)state)->table;
-  mlib_s32 thresh[1];
-  mlib_s32 ghigh[1];
-  mlib_s32 glow[1];
-
-  thresh[0] = lut[2];
-
-  glow[0]  = lut[0] - lut[1];
-  ghigh[0] = lut[1] - lut[0];
-
-  mlib_c_ImageThresh1_U81_1B((void*)src, dst, 0, 0, length, 1,
-                             thresh, ghigh, glow, bit_offset);
-}
-
-#else
-
-/***************************************************************/
-
-void mlib_v_ImageThresh1B_U8_1(const mlib_u8  *src,
-                               mlib_s32       slb,
-                               mlib_u8        *dst,
-                               mlib_s32       dlb,
-                               mlib_s32       xsize,
-                               mlib_s32       ysize,
-                               mlib_s32       dbit_off,
-                               const mlib_s32 *th,
-                               mlib_s32       hc,
-                               mlib_s32       lc);
-
-/***************************************************************/
-
-void mlib_ImageColorTrue2IndexLine_U8_BIT_1(const mlib_u8 *src,
-                                            mlib_u8       *dst,
-                                            mlib_s32      bit_offset,
-                                            mlib_s32      length,
-                                            const void    *state)
-{
-  mlib_u8  *lut = ((mlib_colormap *)state)->table;
-  mlib_s32 thresh[4];
-  mlib_s32 ghigh[1];
-  mlib_s32 glow[1];
-
-  thresh[0] = thresh[1] = thresh[2] = thresh[3] = lut[2];
-
-  glow[0]  = (lut[1] < lut[0]) ? 0xFF : 0;
-  ghigh[0] = (lut[1] < lut[0]) ? 0 : 0xFF;
-
-  mlib_v_ImageThresh1B_U8_1((void*)src, 0, dst, 0, length, 1,
-                            bit_offset, thresh, ghigh[0], glow[0]);
-}
-
-/***************************************************************/
-
-#endif
--- a/jdk/src/java.desktop/share/native/libmlib_image/mlib_ImageColormap.h	Thu May 19 17:48:02 2016 +0000
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,221 +0,0 @@
-/*
- * Copyright (c) 1998, 2003, 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.
- */
-
-
-#ifndef __MLIB_IMAGECOLORMAP_H
-#define __MLIB_IMAGECOLORMAP_H
-
-#ifdef __cplusplus
-extern "C" {
-#endif /* __cplusplus */
-
-typedef struct {
-  void **lut;
-  mlib_s32 channels;
-  mlib_type intype;
-  mlib_s32 offset;
-  void *table;
-  mlib_s32 bits;
-  mlib_s32 method;
-  mlib_s32 lutlength;
-  mlib_s32 indexsize;
-  mlib_type outtype;
-  void *normal_table;
-  mlib_d64 *double_lut;
-} mlib_colormap;
-
-/***************************************************************/
-#define LUT_COLOR_CUBE_SEARCH  0
-#define LUT_BINARY_TREE_SEARCH 1
-#define LUT_STUPID_SEARCH      2
-#define LUT_COLOR_DIMENSIONS   3
-
-/***************************************************************/
-
-/* Bit set in the tag denotes that the corresponding quadrant is a
-   palette index, not node. If the bit is clear, this means that that
-   is a pointer to the down level node. If the bit is clear and the
-   corresponding quadrant is NULL, then there is no way down there and
-   this quadrant is clear. */
-
-struct lut_node_3 {
-  mlib_u8 tag;
-  union {
-    struct lut_node_3 *quadrants[8];
-    long index[8];
-  } contents;
-};
-
-struct lut_node_4 {
-  mlib_u16 tag;
-  union {
-    struct lut_node_4 *quadrants[16];
-    long index[16];
-  } contents;
-};
-
-/***************************************************************/
-
-#define mlib_ImageGetLutData(colormap)                          \
-  ((void **)((( mlib_colormap *)( colormap))->lut))
-
-/***************************************************************/
-#define mlib_ImageGetLutNormalTable(colormap)                   \
-  ((void *)((( mlib_colormap *)( colormap))->normal_table))
-
-/***************************************************************/
-#define mlib_ImageGetLutInversTable(colormap)                   \
-  ((void *)((( mlib_colormap *)( colormap))->table))
-
-/***************************************************************/
-#define mlib_ImageGetLutChannels(colormap)                      \
-  ((mlib_s32)((( mlib_colormap *)( colormap))->channels))
-
-/***************************************************************/
-#define mlib_ImageGetLutType(colormap)                          \
-  ((mlib_type)((( mlib_colormap *)( colormap))->intype))
-
-/***************************************************************/
-#define mlib_ImageGetIndexSize(colormap)                        \
-  ((mlib_s32)((( mlib_colormap *)( colormap))->indexsize))
-
-/***************************************************************/
-#define mlib_ImageGetOutType(colormap)                          \
-  ((mlib_type)((( mlib_colormap *)( colormap))->outtype))
-
-/***************************************************************/
-#define mlib_ImageGetLutOffset(colormap)                        \
-  ((mlib_s32)((( mlib_colormap *)( colormap))->offset))
-
-/***************************************************************/
-#define mlib_ImageGetBits(colormap)                             \
-  ((mlib_s32)((( mlib_colormap *)( colormap))->bits))
-
-/***************************************************************/
-#define mlib_ImageGetMethod(colormap)                           \
-  ((mlib_s32)((( mlib_colormap *)( colormap))->method))
-
-/***************************************************************/
-#define mlib_ImageGetLutDoubleData(colormap)                    \
-  ((mlib_d64 *)((( mlib_colormap *)( colormap))->double_lut))
-
-/***************************************************************/
-#define FIND_DISTANCE_3( x1, x2, y1, y2, z1, z2, SHIFT )        \
- (( ( ( ( x1 ) - ( x2 ) ) * ( ( x1 ) - ( x2 ) ) ) >> SHIFT ) +  \
-  ( ( ( ( y1 ) - ( y2 ) ) * ( ( y1 ) - ( y2 ) ) ) >> SHIFT ) +  \
-  ( ( ( ( z1 ) - ( z2 ) ) * ( ( z1 ) - ( z2 ) ) ) >> SHIFT ) )
-
-/***************************************************************/
-#define FIND_DISTANCE_4( x1, x2, y1, y2, z1, z2, w1, w2, SHIFT ) \
-  (( ( ( ( x1 ) - ( x2 ) ) * ( ( x1 ) - ( x2 ) ) ) >> SHIFT ) +  \
-   ( ( ( ( y1 ) - ( y2 ) ) * ( ( y1 ) - ( y2 ) ) ) >> SHIFT ) +  \
-   ( ( ( ( z1 ) - ( z2 ) ) * ( ( z1 ) - ( z2 ) ) ) >> SHIFT ) +  \
-   ( ( ( ( w1 ) - ( w2 ) ) * ( ( w1 ) - ( w2 ) ) ) >> SHIFT ) )
-
-/***************************************************************/
-
-void mlib_ImageColorTrue2IndexLine_U8_BIT_1(const mlib_u8 *src,
-                                            mlib_u8       *dst,
-                                            mlib_s32      bit_offset,
-                                            mlib_s32      length,
-                                            const void    *state);
-
-
-void mlib_ImageColorTrue2IndexLine_U8_U8_3(const mlib_u8 *src,
-                                           mlib_u8       *dst,
-                                           mlib_s32      length,
-                                           const void    *colormap);
-
-
-void mlib_ImageColorTrue2IndexLine_U8_U8_3_in_4(const mlib_u8 *src,
-                                                mlib_u8       *dst,
-                                                mlib_s32      length,
-                                                const void    *colormap);
-
-
-void mlib_ImageColorTrue2IndexLine_U8_U8_4(const mlib_u8 *src,
-                                           mlib_u8       *dst,
-                                           mlib_s32      length,
-                                           const void    *colormap);
-
-
-void mlib_ImageColorTrue2IndexLine_U8_S16_3(const mlib_u8 *src,
-                                            mlib_s16      *dst,
-                                            mlib_s32      length,
-                                            const void    *colormap);
-
-
-void mlib_ImageColorTrue2IndexLine_U8_S16_3_in_4(const mlib_u8 *src,
-                                                 mlib_s16      *dst,
-                                                 mlib_s32      length,
-                                                 const void    *colormap);
-
-
-void mlib_ImageColorTrue2IndexLine_U8_S16_4(const mlib_u8 *src,
-                                            mlib_s16      *dst,
-                                            mlib_s32      length,
-                                            const void    *colormap);
-
-
-void mlib_ImageColorTrue2IndexLine_S16_S16_3(const mlib_s16 *src,
-                                             mlib_s16       *dst,
-                                             mlib_s32       length,
-                                             const void     *colormap);
-
-
-void mlib_ImageColorTrue2IndexLine_S16_S16_3_in_4(const mlib_s16 *src,
-                                                  mlib_s16       *dst,
-                                                  mlib_s32       length,
-                                                  const void     *colormap);
-
-
-void mlib_ImageColorTrue2IndexLine_S16_S16_4(const mlib_s16 *src,
-                                             mlib_s16       *dst,
-                                             mlib_s32       length,
-                                             const void     *colormap);
-
-
-void mlib_ImageColorTrue2IndexLine_S16_U8_3(const mlib_s16 *src,
-                                            mlib_u8        *dst,
-                                            mlib_s32       length,
-                                            const void     *colormap);
-
-
-void mlib_ImageColorTrue2IndexLine_S16_U8_3_in_4(const mlib_s16 *src,
-                                                 mlib_u8        *dst,
-                                                 mlib_s32       length,
-                                                 const void     *colormap);
-
-
-void mlib_ImageColorTrue2IndexLine_S16_U8_4(const mlib_s16 *src,
-                                            mlib_u8        *dst,
-                                            mlib_s32       length,
-                                            const void     *colormap);
-
-
-#ifdef __cplusplus
-}
-#endif /* __cplusplus */
-#endif /* __MLIB_IMAGECOLORMAP_H */
--- a/jdk/src/java.desktop/share/native/libmlib_image/mlib_ImageConv.h	Thu May 19 17:48:02 2016 +0000
+++ b/jdk/src/java.desktop/share/native/libmlib_image/mlib_ImageConv.h	Thu May 19 19:46:20 2016 +0000
@@ -41,466 +41,6 @@
 }
 #endif /* FREE_AND_RETURN_STATUS */
 
-void mlib_ImageXor80_aa(mlib_u8  *dl,
-                        mlib_s32 wid,
-                        mlib_s32 hgt,
-                        mlib_s32 str);
-
-void mlib_ImageXor80(mlib_u8  *dl,
-                     mlib_s32 wid,
-                     mlib_s32 hgt,
-                     mlib_s32 str,
-                     mlib_s32 nchan,
-                     mlib_s32 cmask);
-
-mlib_status mlib_conv2x2ext_d64(mlib_image       *dst,
-                                const mlib_image *src,
-                                mlib_s32         dx_l,
-                                mlib_s32         dx_r,
-                                mlib_s32         dy_t,
-                                mlib_s32         dy_b,
-                                const mlib_d64   *kern,
-                                mlib_s32         cmask);
-
-mlib_status mlib_conv2x2ext_f32(mlib_image       *dst,
-                                const mlib_image *src,
-                                mlib_s32         dx_l,
-                                mlib_s32         dx_r,
-                                mlib_s32         dy_t,
-                                mlib_s32         dy_b,
-                                const mlib_d64   *kern,
-                                mlib_s32         cmask);
-
-mlib_status mlib_conv2x2ext_s16(mlib_image       *dst,
-                                const mlib_image *src,
-                                mlib_s32         dx_l,
-                                mlib_s32         dx_r,
-                                mlib_s32         dy_t,
-                                mlib_s32         dy_b,
-                                const mlib_s32   *kern,
-                                mlib_s32         scale,
-                                mlib_s32         cmask);
-
-mlib_status mlib_conv2x2ext_s32(mlib_image       *dst,
-                                const mlib_image *src,
-                                mlib_s32         dx_l,
-                                mlib_s32         dx_r,
-                                mlib_s32         dy_t,
-                                mlib_s32         dy_b,
-                                const mlib_s32   *kern,
-                                mlib_s32         scale,
-                                mlib_s32         cmask);
-
-mlib_status mlib_conv2x2ext_u16(mlib_image       *dst,
-                                const mlib_image *src,
-                                mlib_s32         dx_l,
-                                mlib_s32         dx_r,
-                                mlib_s32         dy_t,
-                                mlib_s32         dy_b,
-                                const mlib_s32   *kern,
-                                mlib_s32         scale,
-                                mlib_s32         cmask);
-
-mlib_status mlib_conv2x2ext_u8(mlib_image       *dst,
-                               const mlib_image *src,
-                               mlib_s32         dx_l,
-                               mlib_s32         dx_r,
-                               mlib_s32         dy_t,
-                               mlib_s32         dy_b,
-                               const mlib_s32   *kern,
-                               mlib_s32         scale,
-                               mlib_s32         cmask);
-
-mlib_status mlib_conv2x2nw_d64(mlib_image       *dst,
-                               const mlib_image *src,
-                               const mlib_d64   *kern,
-                               mlib_s32         cmask);
-
-mlib_status mlib_conv2x2nw_f32(mlib_image       *dst,
-                               const mlib_image *src,
-                               const mlib_d64   *kern,
-                               mlib_s32         cmask);
-
-mlib_status mlib_conv2x2nw_s16(mlib_image       *dst,
-                               const mlib_image *src,
-                               const mlib_s32   *kern,
-                               mlib_s32         scale,
-                               mlib_s32         cmask);
-
-mlib_status mlib_conv2x2nw_s32(mlib_image       *dst,
-                               const mlib_image *src,
-                               const mlib_s32   *kern,
-                               mlib_s32         scale,
-                               mlib_s32         cmask);
-
-mlib_status mlib_conv2x2nw_u16(mlib_image       *dst,
-                               const mlib_image *src,
-                               const mlib_s32   *kern,
-                               mlib_s32         scale,
-                               mlib_s32         cmask);
-
-mlib_status mlib_conv2x2nw_u8(mlib_image       *dst,
-                              const mlib_image *src,
-                              const mlib_s32   *kern,
-                              mlib_s32         scale,
-                              mlib_s32         cmask);
-
-mlib_status mlib_conv3x3ext_bit(mlib_image       *dst,
-                                const mlib_image *src,
-                                mlib_s32         dx_l,
-                                mlib_s32         dx_r,
-                                mlib_s32         dy_t,
-                                mlib_s32         dy_b,
-                                const mlib_s32   *kern,
-                                mlib_s32         scale,
-                                mlib_s32         cmask);
-
-mlib_status mlib_conv3x3ext_d64(mlib_image       *dst,
-                                const mlib_image *src,
-                                mlib_s32         dx_l,
-                                mlib_s32         dx_r,
-                                mlib_s32         dy_t,
-                                mlib_s32         dy_b,
-                                const mlib_d64   *kern,
-                                mlib_s32         cmask);
-
-mlib_status mlib_conv3x3ext_f32(mlib_image       *dst,
-                                const mlib_image *src,
-                                mlib_s32         dx_l,
-                                mlib_s32         dx_r,
-                                mlib_s32         dy_t,
-                                mlib_s32         dy_b,
-                                const mlib_d64   *kern,
-                                mlib_s32         cmask);
-
-mlib_status mlib_conv3x3ext_s16(mlib_image       *dst,
-                                const mlib_image *src,
-                                mlib_s32         dx_l,
-                                mlib_s32         dx_r,
-                                mlib_s32         dy_t,
-                                mlib_s32         dy_b,
-                                const mlib_s32   *kern,
-                                mlib_s32         scale,
-                                mlib_s32         cmask);
-
-mlib_status mlib_conv3x3ext_s32(mlib_image       *dst,
-                                const mlib_image *src,
-                                mlib_s32         dx_l,
-                                mlib_s32         dx_r,
-                                mlib_s32         dy_t,
-                                mlib_s32         dy_b,
-                                const mlib_s32   *kern,
-                                mlib_s32         scale,
-                                mlib_s32         cmask);
-
-mlib_status mlib_conv3x3ext_u16(mlib_image       *dst,
-                                const mlib_image *src,
-                                mlib_s32         dx_l,
-                                mlib_s32         dx_r,
-                                mlib_s32         dy_t,
-                                mlib_s32         dy_b,
-                                const mlib_s32   *kern,
-                                mlib_s32         scale,
-                                mlib_s32         cmask);
-
-mlib_status mlib_conv3x3ext_u8(mlib_image       *dst,
-                               const mlib_image *src,
-                               mlib_s32         dx_l,
-                               mlib_s32         dx_r,
-                               mlib_s32         dy_t,
-                               mlib_s32         dy_b,
-                               const mlib_s32   *kern,
-                               mlib_s32         scale,
-                               mlib_s32         cmask);
-
-mlib_status mlib_conv3x3nw_bit(mlib_image       *dst,
-                               const mlib_image *src,
-                               const mlib_s32   *kern,
-                               mlib_s32         scale,
-                               mlib_s32         cmask);
-
-mlib_status mlib_conv3x3nw_d64(mlib_image       *dst,
-                               const mlib_image *src,
-                               const mlib_d64   *kern,
-                               mlib_s32         cmask);
-
-mlib_status mlib_conv3x3nw_f32(mlib_image       *dst,
-                               const mlib_image *src,
-                               const mlib_d64   *kern,
-                               mlib_s32         cmask);
-
-mlib_status mlib_conv3x3nw_s16(mlib_image       *dst,
-                               const mlib_image *src,
-                               const mlib_s32   *kern,
-                               mlib_s32         scale,
-                               mlib_s32         cmask);
-
-mlib_status mlib_conv3x3nw_s32(mlib_image       *dst,
-                               const mlib_image *src,
-                               const mlib_s32   *kern,
-                               mlib_s32         scale,
-                               mlib_s32         cmask);
-
-mlib_status mlib_conv3x3nw_u16(mlib_image       *dst,
-                               const mlib_image *src,
-                               const mlib_s32   *kern,
-                               mlib_s32         scale,
-                               mlib_s32         cmask);
-
-mlib_status mlib_conv3x3nw_u8(mlib_image       *dst,
-                              const mlib_image *src,
-                              const mlib_s32   *kern,
-                              mlib_s32         scale,
-                              mlib_s32         cmask);
-
-mlib_status mlib_conv4x4ext_d64(mlib_image       *dst,
-                                const mlib_image *src,
-                                mlib_s32         dx_l,
-                                mlib_s32         dx_r,
-                                mlib_s32         dy_t,
-                                mlib_s32         dy_b,
-                                const mlib_d64   *kern,
-                                mlib_s32         cmask);
-
-mlib_status mlib_conv4x4ext_f32(mlib_image       *dst,
-                                const mlib_image *src,
-                                mlib_s32         dx_l,
-                                mlib_s32         dx_r,
-                                mlib_s32         dy_t,
-                                mlib_s32         dy_b,
-                                const mlib_d64   *kern,
-                                mlib_s32         cmask);
-
-mlib_status mlib_conv4x4ext_s16(mlib_image       *dst,
-                                const mlib_image *src,
-                                mlib_s32         dx_l,
-                                mlib_s32         dx_r,
-                                mlib_s32         dy_t,
-                                mlib_s32         dy_b,
-                                const mlib_s32   *kern,
-                                mlib_s32         scale,
-                                mlib_s32         cmask);
-
-mlib_status mlib_conv4x4ext_s32(mlib_image       *dst,
-                                const mlib_image *src,
-                                mlib_s32         dx_l,
-                                mlib_s32         dx_r,
-                                mlib_s32         dy_t,
-                                mlib_s32         dy_b,
-                                const mlib_s32   *kern,
-                                mlib_s32         scale,
-                                mlib_s32         cmask);
-
-mlib_status mlib_conv4x4ext_u16(mlib_image       *dst,
-                                const mlib_image *src,
-                                mlib_s32         dx_l,
-                                mlib_s32         dx_r,
-                                mlib_s32         dy_t,
-                                mlib_s32         dy_b,
-                                const mlib_s32   *kern,
-                                mlib_s32         scale,
-                                mlib_s32         cmask);
-
-mlib_status mlib_conv4x4ext_u8(mlib_image       *dst,
-                               const mlib_image *src,
-                               mlib_s32         dx_l,
-                               mlib_s32         dx_r,
-                               mlib_s32         dy_t,
-                               mlib_s32         dy_b,
-                               const mlib_s32   *kern,
-                               mlib_s32         scale,
-                               mlib_s32         cmask);
-
-mlib_status mlib_conv4x4nw_d64(mlib_image       *dst,
-                               const mlib_image *src,
-                               const mlib_d64   *kern,
-                               mlib_s32         cmask);
-
-mlib_status mlib_conv4x4nw_f32(mlib_image       *dst,
-                               const mlib_image *src,
-                               const mlib_d64   *kern,
-                               mlib_s32         cmask);
-
-mlib_status mlib_conv4x4nw_s16(mlib_image       *dst,
-                               const mlib_image *src,
-                               const mlib_s32   *kern,
-                               mlib_s32         scale,
-                               mlib_s32         cmask);
-
-mlib_status mlib_conv4x4nw_s32(mlib_image       *dst,
-                               const mlib_image *src,
-                               const mlib_s32   *kern,
-                               mlib_s32         scale,
-                               mlib_s32         cmask);
-
-mlib_status mlib_conv4x4nw_u16(mlib_image       *dst,
-                               const mlib_image *src,
-                               const mlib_s32   *kern,
-                               mlib_s32         scale,
-                               mlib_s32         cmask);
-
-mlib_status mlib_conv4x4nw_u8(mlib_image       *dst,
-                              const mlib_image *src,
-                              const mlib_s32   *kern,
-                              mlib_s32         scale,
-                              mlib_s32         cmask);
-
-mlib_status mlib_conv5x5ext_d64(mlib_image       *dst,
-                                const mlib_image *src,
-                                mlib_s32         dx_l,
-                                mlib_s32         dx_r,
-                                mlib_s32         dy_t,
-                                mlib_s32         dy_b,
-                                const mlib_d64   *kern,
-                                mlib_s32         cmask);
-
-mlib_status mlib_conv5x5ext_f32(mlib_image       *dst,
-                                const mlib_image *src,
-                                mlib_s32         dx_l,
-                                mlib_s32         dx_r,
-                                mlib_s32         dy_t,
-                                mlib_s32         dy_b,
-                                const mlib_d64   *kern,
-                                mlib_s32         cmask);
-
-mlib_status mlib_conv5x5ext_s16(mlib_image       *dst,
-                                const mlib_image *src,
-                                mlib_s32         dx_l,
-                                mlib_s32         dx_r,
-                                mlib_s32         dy_t,
-                                mlib_s32         dy_b,
-                                const mlib_s32   *kern,
-                                mlib_s32         scale,
-                                mlib_s32         cmask);
-
-mlib_status mlib_conv5x5ext_s32(mlib_image       *dst,
-                                const mlib_image *src,
-                                mlib_s32         dx_l,
-                                mlib_s32         dx_r,
-                                mlib_s32         dy_t,
-                                mlib_s32         dy_b,
-                                const mlib_s32   *kern,
-                                mlib_s32         scale,
-                                mlib_s32         cmask);
-
-mlib_status mlib_conv5x5ext_u16(mlib_image       *dst,
-                                const mlib_image *src,
-                                mlib_s32         dx_l,
-                                mlib_s32         dx_r,
-                                mlib_s32         dy_t,
-                                mlib_s32         dy_b,
-                                const mlib_s32   *kern,
-                                mlib_s32         scale,
-                                mlib_s32         cmask);
-
-mlib_status mlib_conv5x5ext_u8(mlib_image       *dst,
-                               const mlib_image *src,
-                               mlib_s32         dx_l,
-                               mlib_s32         dx_r,
-                               mlib_s32         dy_t,
-                               mlib_s32         dy_b,
-                               const mlib_s32   *kern,
-                               mlib_s32         scale,
-                               mlib_s32         cmask);
-
-mlib_status mlib_conv5x5nw_d64(mlib_image       *dst,
-                               const mlib_image *src,
-                               const mlib_d64   *kern,
-                               mlib_s32         cmask);
-
-mlib_status mlib_conv5x5nw_f32(mlib_image       *dst,
-                               const mlib_image *src,
-                               const mlib_d64   *kern,
-                               mlib_s32         cmask);
-
-mlib_status mlib_conv5x5nw_s16(mlib_image       *dst,
-                               const mlib_image *src,
-                               const mlib_s32   *kern,
-                               mlib_s32         scale,
-                               mlib_s32         cmask);
-
-mlib_status mlib_conv5x5nw_s32(mlib_image       *dst,
-                               const mlib_image *src,
-                               const mlib_s32   *kern,
-                               mlib_s32         scale,
-                               mlib_s32         cmask);
-
-mlib_status mlib_conv5x5nw_u16(mlib_image       *dst,
-                               const mlib_image *src,
-                               const mlib_s32   *kern,
-                               mlib_s32         scale,
-                               mlib_s32         cmask);
-
-mlib_status mlib_conv5x5nw_u8(mlib_image       *dst,
-                              const mlib_image *src,
-                              const mlib_s32   *kern,
-                              mlib_s32         scale,
-                              mlib_s32         cmask);
-
-mlib_status mlib_conv7x7ext_s16(mlib_image       *dst,
-                                const mlib_image *src,
-                                mlib_s32         dx_l,
-                                mlib_s32         dx_r,
-                                mlib_s32         dy_t,
-                                mlib_s32         dy_b,
-                                const mlib_s32   *kern,
-                                mlib_s32         scale,
-                                mlib_s32         cmask);
-
-mlib_status mlib_conv7x7ext_s32(mlib_image       *dst,
-                                const mlib_image *src,
-                                mlib_s32         dx_l,
-                                mlib_s32         dx_r,
-                                mlib_s32         dy_t,
-                                mlib_s32         dy_b,
-                                const mlib_s32   *kern,
-                                mlib_s32         scale,
-                                mlib_s32         cmask);
-
-mlib_status mlib_conv7x7ext_u16(mlib_image       *dst,
-                                const mlib_image *src,
-                                mlib_s32         dx_l,
-                                mlib_s32         dx_r,
-                                mlib_s32         dy_t,
-                                mlib_s32         dy_b,
-                                const mlib_s32   *kern,
-                                mlib_s32         scale,
-                                mlib_s32         cmask);
-
-mlib_status mlib_conv7x7ext_u8(mlib_image       *dst,
-                               const mlib_image *src,
-                               mlib_s32         dx_l,
-                               mlib_s32         dx_r,
-                               mlib_s32         dy_t,
-                               mlib_s32         dy_b,
-                               const mlib_s32   *kern,
-                               mlib_s32         scale,
-                               mlib_s32         cmask);
-
-mlib_status mlib_conv7x7nw_s16(mlib_image       *dst,
-                               const mlib_image *src,
-                               const mlib_s32   *kern,
-                               mlib_s32         scale,
-                               mlib_s32         cmask);
-
-mlib_status mlib_conv7x7nw_s32(mlib_image       *dst,
-                               const mlib_image *src,
-                               const mlib_s32   *kern,
-                               mlib_s32         scale,
-                               mlib_s32         cmask);
-
-mlib_status mlib_conv7x7nw_u16(mlib_image       *dst,
-                               const mlib_image *src,
-                               const mlib_s32   *kern,
-                               mlib_s32         scale,
-                               mlib_s32         cmask);
-
-mlib_status mlib_conv7x7nw_u8(mlib_image       *dst,
-                              const mlib_image *src,
-                              const mlib_s32   *kern,
-                              mlib_s32         scale,
-                              mlib_s32         cmask);
-
 mlib_status mlib_convMxNext_s32(mlib_image       *dst,
                                 const mlib_image *src,
                                 const mlib_s32   *kernel,
--- a/jdk/src/java.desktop/share/native/libmlib_image/mlib_ImageConv2x2_f.c	Thu May 19 17:48:02 2016 +0000
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,1118 +0,0 @@
-/*
- * Copyright (c) 2003, 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.
- */
-
-
-/*
- * FUNCTION
- *      Internal functions for mlib_ImageConv2x2 on U8/S16/U16 types
- *      and MLIB_EDGE_DST_NO_WRITE mask.
- */
-
-#include "mlib_image.h"
-#include "mlib_ImageConv.h"
-#include "mlib_c_ImageConv.h"
-
-/***************************************************************/
-#ifdef i386 /* do not copy by mlib_d64 data type for x86 */
-
-typedef struct {
-  mlib_s32 int0, int1;
-} two_int;
-
-#define TYPE_64BIT two_int
-
-#else /* i386 */
-
-#define TYPE_64BIT mlib_d64
-
-#endif /* i386 ( do not copy by mlib_d64 data type for x86 ) */
-
-/***************************************************************/
-#define LOAD_KERNEL_INTO_DOUBLE()                                        \
-  while (scalef_expon > 30) {                                            \
-    scalef /= (1 << 30);                                                 \
-    scalef_expon -= 30;                                                  \
-  }                                                                      \
-                                                                         \
-  scalef /= (1 << scalef_expon);                                         \
-                                                                         \
-  /* keep kernel in regs */                                              \
-  k0 = scalef * kern[0];  k1 = scalef * kern[1];  k2 = scalef * kern[2]; \
-  k3 = scalef * kern[3]
-
-/***************************************************************/
-#define GET_SRC_DST_PARAMETERS(type)                            \
-  hgt = mlib_ImageGetHeight(src);                               \
-  wid = mlib_ImageGetWidth(src);                                \
-  nchannel = mlib_ImageGetChannels(src);                        \
-  sll = mlib_ImageGetStride(src) / sizeof(type);                \
-  dll = mlib_ImageGetStride(dst) / sizeof(type);                \
-  adr_src = (type *)mlib_ImageGetData(src);                     \
-  adr_dst = (type *)mlib_ImageGetData(dst)
-
-/***************************************************************/
-#ifndef MLIB_USE_FTOI_CLAMPING
-
-#define CLAMP_S32(x)                                            \
-  (((x) <= MLIB_S32_MIN) ? MLIB_S32_MIN :                       \
-  (((x) >= MLIB_S32_MAX) ? MLIB_S32_MAX : (mlib_s32)(x)))
-
-#else
-
-#define CLAMP_S32(x) ((mlib_s32)(x))
-
-#endif /* MLIB_USE_FTOI_CLAMPING */
-
-/***************************************************************/
-#if defined(_LITTLE_ENDIAN) && !defined(_NO_LONGLONG)
-
-/* NB: Explicit cast to DTYPE is necessary to avoid warning from Microsoft VC compiler.
-      And we need to explicitly define cast behavior if source exceeds destination range.
-      (it is undefined according to C99 spec). We use mask here because this macro is typically
-      used to extract bit regions. */
-
-#define STORE2(res0, res1)                                      \
-  dp[0    ] = (DTYPE) ((res1) & DTYPE_MASK);                      \
-  dp[chan1] = (DTYPE) ((res0) & DTYPE_MASK)
-
-#else
-
-#define STORE2(res0, res1)                                      \
-  dp[0    ] = (DTYPE) ((res0) & DTYPE_MASK);                      \
-  dp[chan1] = (DTYPE) ((res1) & DTYPE_MASK)
-
-#endif /* defined(_LITTLE_ENDIAN) && !defined(_NO_LONGLONG) */
-
-/***************************************************************/
-#ifdef _NO_LONGLONG
-
-#define LOAD_BUFF(buff)                                         \
-  buff[i    ] = sp[0];                                          \
-  buff[i + 1] = sp[chan1]
-
-#else /* _NO_LONGLONG */
-
-#ifdef _LITTLE_ENDIAN
-
-#define LOAD_BUFF(buff)                                         \
-  *(mlib_s64*)(buff + i) = (((mlib_s64)sp[chan1]) << 32) | ((mlib_s64)sp[0] & 0xffffffff)
-
-#else /* _LITTLE_ENDIAN */
-
-#define LOAD_BUFF(buff)                                         \
-  *(mlib_s64*)(buff + i) = (((mlib_s64)sp[0]) << 32) | ((mlib_s64)sp[chan1] & 0xffffffff)
-
-#endif /* _LITTLE_ENDIAN */
-
-#endif /* _NO_LONGLONG */
-
-/***************************************************************/
-typedef union {
-  TYPE_64BIT d64;
-  struct {
-    mlib_s32 i0, i1;
-  } i32s;
-} d64_2x32;
-
-/***************************************************************/
-#define D_KER     1
-
-#define BUFF_LINE 256
-
-/***************************************************************/
-#define XOR_80(x) x ^= 0x80
-
-void mlib_ImageXor80_aa(mlib_u8  *dl,
-                        mlib_s32 wid,
-                        mlib_s32 hgt,
-                        mlib_s32 str)
-{
-  mlib_u8  *dp, *dend;
-#ifdef _NO_LONGLONG
-  mlib_u32 cadd = 0x80808080;
-#else /* _NO_LONGLONG */
-  mlib_u64 cadd = MLIB_U64_CONST(0x8080808080808080);
-#endif /* _NO_LONGLONG */
-  mlib_s32 j;
-
-  if (wid == str) {
-    wid *= hgt;
-    hgt = 1;
-  }
-
-  for (j = 0; j < hgt; j++) {
-    dend = dl + wid;
-
-    for (dp = dl; ((mlib_addr)dp & 7) && (dp < dend); dp++) XOR_80(dp[0]);
-
-#ifdef __SUNPRO_C
-#pragma pipeloop(0)
-#endif /* __SUNPRO_C */
-    for (; dp <= (dend - 8); dp += 8) {
-#ifdef _NO_LONGLONG
-      *((mlib_s32*)dp) ^= cadd;
-      *((mlib_s32*)dp+1) ^= cadd;
-#else /* _NO_LONGLONG */
-      *((mlib_u64*)dp) ^= cadd;
-#endif /* _NO_LONGLONG */
-    }
-
-    for (; (dp < dend); dp++) XOR_80(dp[0]);
-
-    dl += str;
-  }
-}
-
-/***************************************************************/
-void mlib_ImageXor80(mlib_u8  *dl,
-                     mlib_s32 wid,
-                     mlib_s32 hgt,
-                     mlib_s32 str,
-                     mlib_s32 nchan,
-                     mlib_s32 cmask)
-{
-  mlib_s32 i, j, c;
-
-  for (j = 0; j < hgt; j++) {
-    for (c = 0; c < nchan; c++) {
-      if (cmask & (1 << (nchan - 1 - c))) {
-        mlib_u8 *dp = dl + c;
-
-#ifdef __SUNPRO_C
-#pragma pipeloop(0)
-#endif /* __SUNPRO_C */
-        for (i = 0; i < wid; i++) XOR_80(dp[i*nchan]);
-      }
-    }
-
-    dl += str;
-  }
-}
-
-/***************************************************************/
-#define DTYPE mlib_s16
-#define DTYPE_MASK 0xffff
-
-mlib_status mlib_c_conv2x2nw_s16(mlib_image       *dst,
-                                 const mlib_image *src,
-                                 const mlib_s32   *kern,
-                                 mlib_s32         scalef_expon,
-                                 mlib_s32         cmask)
-{
-  mlib_d64 buff_arr[2*BUFF_LINE];
-  mlib_s32 *pbuff = (mlib_s32*)buff_arr, *buffo, *buff0, *buff1, *buff2, *buffT;
-  DTYPE    *adr_src, *sl, *sp, *sl1;
-  DTYPE    *adr_dst, *dl, *dp;
-  mlib_d64 k0, k1, k2, k3, scalef = 65536.0;
-  mlib_d64 p00, p01, p02,
-           p10, p11, p12;
-  mlib_s32 wid, hgt, sll, dll, wid1;
-  mlib_s32 nchannel, chan1, chan2;
-  mlib_s32 i, j, c;
-  LOAD_KERNEL_INTO_DOUBLE();
-  GET_SRC_DST_PARAMETERS(DTYPE);
-
-  wid1 = (wid + 1) &~ 1;
-
-  if (wid1 > BUFF_LINE) {
-    pbuff = mlib_malloc(4*sizeof(mlib_s32)*wid1);
-
-    if (pbuff == NULL) return MLIB_FAILURE;
-  }
-
-  buffo = pbuff;
-  buff0 = buffo + wid1;
-  buff1 = buff0 + wid1;
-  buff2 = buff1 + wid1;
-
-  chan1 = nchannel;
-  chan2 = chan1 + chan1;
-
-  wid -= D_KER;
-  hgt -= D_KER;
-
-  for (c = 0; c < nchannel; c++) {
-    if (!(cmask & (1 << (nchannel - 1 - c)))) continue;
-
-    sl = adr_src + c;
-    dl = adr_dst + c;
-
-    sl1 = sl + sll;
-#ifdef __SUNPRO_C
-#pragma pipeloop(0)
-#endif /* __SUNPRO_C */
-    for (i = 0; i < wid + D_KER; i++) {
-      buff0[i - 1] = (mlib_s32)sl[i*chan1];
-      buff1[i - 1] = (mlib_s32)sl1[i*chan1];
-    }
-
-    sl += (D_KER + 1)*sll;
-
-    for (j = 0; j < hgt; j++) {
-      sp = sl;
-      dp = dl;
-
-      buff2[-1] = (mlib_s32)sp[0];
-      sp += chan1;
-
-      p02 = buff0[-1];
-      p12 = buff1[-1];
-
-#ifdef __SUNPRO_C
-#pragma pipeloop(0)
-#endif /* __SUNPRO_C */
-      for (i = 0; i <= (wid - 2); i += 2) {
-#ifdef _NO_LONGLONG
-        mlib_s32 o64_1, o64_2;
-#else /* _NO_LONGLONG */
-        mlib_s64 o64;
-#endif /* _NO_LONGLONG */
-        d64_2x32 sd0, sd1, dd;
-
-        p00 = p02; p10 = p12;
-
-        sd0.d64 = *(TYPE_64BIT*)(buff0 + i);
-        sd1.d64 = *(TYPE_64BIT*)(buff1 + i);
-        p01 = (mlib_d64)sd0.i32s.i0;
-        p02 = (mlib_d64)sd0.i32s.i1;
-        p11 = (mlib_d64)sd1.i32s.i0;
-        p12 = (mlib_d64)sd1.i32s.i1;
-
-        LOAD_BUFF(buff2);
-
-        dd.i32s.i0 = CLAMP_S32(p00 * k0 + p01 * k1 + p10 * k2 + p11 * k3);
-        dd.i32s.i1 = CLAMP_S32(p01 * k0 + p02 * k1 + p11 * k2 + p12 * k3);
-        *(TYPE_64BIT*)(buffo + i) = dd.d64;
-
-#ifdef _NO_LONGLONG
-
-        o64_1 = buffo[i];
-        o64_2 = buffo[i+1];
-        STORE2(o64_1 >> 16, o64_2 >> 16);
-
-#else /* _NO_LONGLONG */
-
-        o64 = *(mlib_s64*)(buffo + i);
-        STORE2(o64 >> 48, o64 >> 16);
-
-#endif /* _NO_LONGLONG */
-
-        sp += chan2;
-        dp += chan2;
-      }
-
-      for (; i < wid; i++) {
-        p00 = buff0[i - 1]; p10 = buff1[i - 1];
-        p01 = buff0[i];     p11 = buff1[i];
-
-        buff2[i] = (mlib_s32)sp[0];
-
-        buffo[i] = CLAMP_S32(p00 * k0 + p01 * k1 + p10 * k2 + p11 * k3);
-        dp[0] = buffo[i] >> 16;
-
-        sp += chan1;
-        dp += chan1;
-      }
-
-      sl += sll;
-      dl += dll;
-
-      buffT = buff0;
-      buff0 = buff1;
-      buff1 = buff2;
-      buff2 = buffT;
-    }
-  }
-
-  if (pbuff != (mlib_s32*)buff_arr) mlib_free(pbuff);
-
-  return MLIB_SUCCESS;
-}
-
-/***************************************************************/
-mlib_status mlib_c_conv2x2ext_s16(mlib_image       *dst,
-                                  const mlib_image *src,
-                                  mlib_s32         dx_l,
-                                  mlib_s32         dx_r,
-                                  mlib_s32         dy_t,
-                                  mlib_s32         dy_b,
-                                  const mlib_s32   *kern,
-                                  mlib_s32         scalef_expon,
-                                  mlib_s32         cmask)
-{
-  mlib_d64 buff_arr[2*BUFF_LINE];
-  mlib_s32 *pbuff = (mlib_s32*)buff_arr, *buffo, *buff0, *buff1, *buff2, *buffT;
-  DTYPE    *adr_src, *sl, *sp, *sl1;
-  DTYPE    *adr_dst, *dl, *dp;
-  mlib_d64 k0, k1, k2, k3, scalef = 65536.0;
-  mlib_d64 p00, p01, p02,
-           p10, p11, p12;
-  mlib_s32 wid, hgt, sll, dll, wid1;
-  mlib_s32 nchannel, chan1, chan2;
-  mlib_s32 i, j, c, swid;
-  LOAD_KERNEL_INTO_DOUBLE();
-  GET_SRC_DST_PARAMETERS(DTYPE);
-
-  swid = wid + D_KER;
-
-  wid1 = (swid + 1) &~ 1;
-
-  if (wid1 > BUFF_LINE) {
-    pbuff = mlib_malloc(4*sizeof(mlib_s32)*wid1);
-
-    if (pbuff == NULL) return MLIB_FAILURE;
-  }
-
-  buffo = pbuff;
-  buff0 = buffo + wid1;
-  buff1 = buff0 + wid1;
-  buff2 = buff1 + wid1;
-
-  swid -= dx_r;
-
-  chan1 = nchannel;
-  chan2 = chan1 + chan1;
-
-  for (c = 0; c < nchannel; c++) {
-    if (!(cmask & (1 << (nchannel - 1 - c)))) continue;
-
-    sl = adr_src + c;
-    dl = adr_dst + c;
-
-    if ((hgt - dy_b) > 0) sl1 = sl + sll;
-    else sl1 = sl;
-
-#ifdef __SUNPRO_C
-#pragma pipeloop(0)
-#endif /* __SUNPRO_C */
-    for (i = 0; i < swid; i++) {
-      buff0[i - 1] = (mlib_s32)sl[i*chan1];
-      buff1[i - 1] = (mlib_s32)sl1[i*chan1];
-    }
-
-    if (dx_r != 0) {
-      buff0[swid - 1] = buff0[swid - 2];
-      buff1[swid - 1] = buff1[swid - 2];
-    }
-
-    if ((hgt - dy_b) > 1) sl = sl1 + sll;
-    else sl = sl1;
-
-    for (j = 0; j < hgt; j++) {
-      sp = sl;
-      dp = dl;
-
-      buff2[-1] = (mlib_s32)sp[0];
-      sp += chan1;
-
-      p02 = buff0[-1];
-      p12 = buff1[-1];
-
-#ifdef __SUNPRO_C
-#pragma pipeloop(0)
-#endif /* __SUNPRO_C */
-      for (i = 0; i <= (wid - 2); i += 2) {
-#ifdef _NO_LONGLONG
-        mlib_s32 o64_1, o64_2;
-#else /* _NO_LONGLONG */
-        mlib_s64 o64;
-#endif /* _NO_LONGLONG */
-        d64_2x32 sd0, sd1, dd;
-
-        p00 = p02; p10 = p12;
-
-        sd0.d64 = *(TYPE_64BIT*)(buff0 + i);
-        sd1.d64 = *(TYPE_64BIT*)(buff1 + i);
-        p01 = (mlib_d64)sd0.i32s.i0;
-        p02 = (mlib_d64)sd0.i32s.i1;
-        p11 = (mlib_d64)sd1.i32s.i0;
-        p12 = (mlib_d64)sd1.i32s.i1;
-
-        LOAD_BUFF(buff2);
-
-        dd.i32s.i0 = CLAMP_S32(p00 * k0 + p01 * k1 + p10 * k2 + p11 * k3);
-        dd.i32s.i1 = CLAMP_S32(p01 * k0 + p02 * k1 + p11 * k2 + p12 * k3);
-        *(TYPE_64BIT*)(buffo + i) = dd.d64;
-
-#ifdef _NO_LONGLONG
-
-        o64_1 = buffo[i];
-        o64_2 = buffo[i+1];
-        STORE2(o64_1 >> 16, o64_2 >> 16);
-
-#else /* _NO_LONGLONG */
-
-        o64 = *(mlib_s64*)(buffo + i);
-        STORE2(o64 >> 48, o64 >> 16);
-
-#endif /* _NO_LONGLONG */
-
-        sp += chan2;
-        dp += chan2;
-      }
-
-      for (; i < wid; i++) {
-        p00 = buff0[i - 1]; p10 = buff1[i - 1];
-        p01 = buff0[i];     p11 = buff1[i];
-
-        buff2[i] = (mlib_s32)sp[0];
-
-        buffo[i] = CLAMP_S32(p00 * k0 + p01 * k1 + p10 * k2 + p11 * k3);
-        dp[0] = buffo[i] >> 16;
-
-        sp += chan1;
-        dp += chan1;
-      }
-
-      if (dx_r != 0) buff2[swid - 1] = buff2[swid - 2];
-
-      if (j < hgt - dy_b - 2) sl += sll;
-      dl += dll;
-
-      buffT = buff0;
-      buff0 = buff1;
-      buff1 = buff2;
-      buff2 = buffT;
-    }
-  }
-
-  if (pbuff != (mlib_s32*)buff_arr) mlib_free(pbuff);
-
-  return MLIB_SUCCESS;
-}
-
-/***************************************************************/
-#undef  DTYPE
-#define DTYPE mlib_u16
-
-mlib_status mlib_c_conv2x2nw_u16(mlib_image       *dst,
-                                 const mlib_image *src,
-                                 const mlib_s32   *kern,
-                                 mlib_s32         scalef_expon,
-                                 mlib_s32         cmask)
-{
-  mlib_d64 buff_arr[2*BUFF_LINE];
-  mlib_s32 *pbuff = (mlib_s32*)buff_arr, *buffo, *buff0, *buff1, *buff2, *buffT;
-  DTYPE    *adr_src, *sl, *sp, *sl1;
-  DTYPE    *adr_dst, *dl, *dp;
-  mlib_d64 k0, k1, k2, k3, scalef = 65536.0;
-  mlib_d64 p00, p01, p02,
-           p10, p11, p12;
-  mlib_s32 wid, hgt, sll, dll, wid1;
-  mlib_s32 nchannel, chan1, chan2;
-  mlib_s32 i, j, c;
-  mlib_d64 doff = 0x7FFF8000;
-  LOAD_KERNEL_INTO_DOUBLE();
-  GET_SRC_DST_PARAMETERS(DTYPE);
-
-  wid1 = (wid + 1) &~ 1;
-
-  if (wid1 > BUFF_LINE) {
-    pbuff = mlib_malloc(4*sizeof(mlib_s32)*wid1);
-
-    if (pbuff == NULL) return MLIB_FAILURE;
-  }
-
-  buffo = pbuff;
-  buff0 = buffo + wid1;
-  buff1 = buff0 + wid1;
-  buff2 = buff1 + wid1;
-
-  chan1 = nchannel;
-  chan2 = chan1 + chan1;
-
-  wid -= D_KER;
-  hgt -= D_KER;
-
-  for (c = 0; c < nchannel; c++) {
-    if (!(cmask & (1 << (nchannel - 1 - c)))) continue;
-
-    sl = adr_src + c;
-    dl = adr_dst + c;
-
-    sl1 = sl + sll;
-#ifdef __SUNPRO_C
-#pragma pipeloop(0)
-#endif /* __SUNPRO_C */
-    for (i = 0; i < wid + D_KER; i++) {
-      buff0[i - 1] = (mlib_s32)sl[i*chan1];
-      buff1[i - 1] = (mlib_s32)sl1[i*chan1];
-    }
-
-    sl += (D_KER + 1)*sll;
-
-    for (j = 0; j < hgt; j++) {
-      sp = sl;
-      dp = dl;
-
-      buff2[-1] = (mlib_s32)sp[0];
-      sp += chan1;
-
-      p02 = buff0[-1];
-      p12 = buff1[-1];
-
-#ifdef __SUNPRO_C
-#pragma pipeloop(0)
-#endif /* __SUNPRO_C */
-      for (i = 0; i <= (wid - 2); i += 2) {
-#ifdef _NO_LONGLONG
-        mlib_s32 o64_1, o64_2;
-#else /* _NO_LONGLONG */
-        mlib_s64 o64;
-#endif /* _NO_LONGLONG */
-        d64_2x32 sd0, sd1, dd;
-
-        p00 = p02; p10 = p12;
-
-        sd0.d64 = *(TYPE_64BIT*)(buff0 + i);
-        sd1.d64 = *(TYPE_64BIT*)(buff1 + i);
-        p01 = (mlib_d64)sd0.i32s.i0;
-        p02 = (mlib_d64)sd0.i32s.i1;
-        p11 = (mlib_d64)sd1.i32s.i0;
-        p12 = (mlib_d64)sd1.i32s.i1;
-
-        LOAD_BUFF(buff2);
-
-        dd.i32s.i0 = CLAMP_S32(p00 * k0 + p01 * k1 + p10 * k2 + p11 * k3 - doff);
-        dd.i32s.i1 = CLAMP_S32(p01 * k0 + p02 * k1 + p11 * k2 + p12 * k3 - doff);
-        *(TYPE_64BIT*)(buffo + i) = dd.d64;
-
-#ifdef _NO_LONGLONG
-
-        o64_1 = buffo[i];
-        o64_2 = buffo[i+1];
-        o64_1 = o64_1 ^ 0x80000000U;
-        o64_2 = o64_2 ^ 0x80000000U;
-        STORE2(o64_1 >> 16, o64_2 >> 16);
-
-#else /* _NO_LONGLONG */
-
-        o64 = *(mlib_s64*)(buffo + i);
-        o64 = o64 ^ MLIB_U64_CONST(0x8000000080000000);
-        STORE2(o64 >> 48, o64 >> 16);
-
-#endif /* _NO_LONGLONG */
-
-        sp += chan2;
-        dp += chan2;
-      }
-
-      for (; i < wid; i++) {
-        p00 = buff0[i - 1]; p10 = buff1[i - 1];
-        p01 = buff0[i];     p11 = buff1[i];
-
-        buff2[i] = (mlib_s32)sp[0];
-
-        buffo[i] = CLAMP_S32(p00 * k0 + p01 * k1 + p10 * k2 + p11 * k3 - doff);
-        dp[0] = (buffo[i] >> 16) ^ 0x8000;
-
-        sp += chan1;
-        dp += chan1;
-      }
-
-      sl += sll;
-      dl += dll;
-
-      buffT = buff0;
-      buff0 = buff1;
-      buff1 = buff2;
-      buff2 = buffT;
-    }
-  }
-
-  if (pbuff != (mlib_s32*)buff_arr) mlib_free(pbuff);
-
-  return MLIB_SUCCESS;
-}
-
-/***************************************************************/
-mlib_status mlib_c_conv2x2ext_u16(mlib_image       *dst,
-                                  const mlib_image *src,
-                                  mlib_s32         dx_l,
-                                  mlib_s32         dx_r,
-                                  mlib_s32         dy_t,
-                                  mlib_s32         dy_b,
-                                  const mlib_s32   *kern,
-                                  mlib_s32         scalef_expon,
-                                  mlib_s32         cmask)
-{
-  mlib_d64 buff_arr[2*BUFF_LINE];
-  mlib_s32 *pbuff = (mlib_s32*)buff_arr, *buffo, *buff0, *buff1, *buff2, *buffT;
-  DTYPE    *adr_src, *sl, *sp, *sl1;
-  DTYPE    *adr_dst, *dl, *dp;
-  mlib_d64 k0, k1, k2, k3, scalef = 65536.0;
-  mlib_d64 p00, p01, p02,
-           p10, p11, p12;
-  mlib_s32 wid, hgt, sll, dll, wid1;
-  mlib_s32 nchannel, chan1, chan2;
-  mlib_s32 i, j, c, swid;
-  mlib_d64 doff = 0x7FFF8000;
-  LOAD_KERNEL_INTO_DOUBLE();
-  GET_SRC_DST_PARAMETERS(DTYPE);
-
-  swid = wid + D_KER;
-
-  wid1 = (swid + 1) &~ 1;
-
-  if (wid1 > BUFF_LINE) {
-    pbuff = mlib_malloc(4*sizeof(mlib_s32)*wid1);
-
-    if (pbuff == NULL) return MLIB_FAILURE;
-  }
-
-  buffo = pbuff;
-  buff0 = buffo + wid1;
-  buff1 = buff0 + wid1;
-  buff2 = buff1 + wid1;
-
-  swid -= dx_r;
-
-  chan1 = nchannel;
-  chan2 = chan1 + chan1;
-
-  for (c = 0; c < nchannel; c++) {
-    if (!(cmask & (1 << (nchannel - 1 - c)))) continue;
-
-    sl = adr_src + c;
-    dl = adr_dst + c;
-
-    if ((hgt - dy_b) > 0) sl1 = sl + sll;
-    else sl1 = sl;
-
-#ifdef __SUNPRO_C
-#pragma pipeloop(0)
-#endif /* __SUNPRO_C */
-    for (i = 0; i < swid; i++) {
-      buff0[i - 1] = (mlib_s32)sl[i*chan1];
-      buff1[i - 1] = (mlib_s32)sl1[i*chan1];
-    }
-
-    if (dx_r != 0) {
-      buff0[swid - 1] = buff0[swid - 2];
-      buff1[swid - 1] = buff1[swid - 2];
-    }
-
-    if ((hgt - dy_b) > 1) sl = sl1 + sll;
-    else sl = sl1;
-
-    for (j = 0; j < hgt; j++) {
-      sp = sl;
-      dp = dl;
-
-      buff2[-1] = (mlib_s32)sp[0];
-      sp += chan1;
-
-      p02 = buff0[-1];
-      p12 = buff1[-1];
-
-#ifdef __SUNPRO_C
-#pragma pipeloop(0)
-#endif /* __SUNPRO_C */
-      for (i = 0; i <= (wid - 2); i += 2) {
-#ifdef _NO_LONGLONG
-        mlib_s32 o64_1, o64_2;
-#else /* _NO_LONGLONG */
-        mlib_s64 o64;
-#endif /* _NO_LONGLONG */
-        d64_2x32 sd0, sd1, dd;
-
-        p00 = p02; p10 = p12;
-
-        sd0.d64 = *(TYPE_64BIT*)(buff0 + i);
-        sd1.d64 = *(TYPE_64BIT*)(buff1 + i);
-        p01 = (mlib_d64)sd0.i32s.i0;
-        p02 = (mlib_d64)sd0.i32s.i1;
-        p11 = (mlib_d64)sd1.i32s.i0;
-        p12 = (mlib_d64)sd1.i32s.i1;
-
-        LOAD_BUFF(buff2);
-
-        dd.i32s.i0 = CLAMP_S32(p00 * k0 + p01 * k1 + p10 * k2 + p11 * k3 - doff);
-        dd.i32s.i1 = CLAMP_S32(p01 * k0 + p02 * k1 + p11 * k2 + p12 * k3 - doff);
-        *(TYPE_64BIT*)(buffo + i) = dd.d64;
-
-#ifdef _NO_LONGLONG
-
-        o64_1 = buffo[i];
-        o64_2 = buffo[i+1];
-        o64_1 = o64_1 ^ 0x80000000U;
-        o64_2 = o64_2 ^ 0x80000000U;
-        STORE2(o64_1 >> 16, o64_2 >> 16);
-
-#else /* _NO_LONGLONG */
-
-        o64 = *(mlib_s64*)(buffo + i);
-        o64 = o64 ^ MLIB_U64_CONST(0x8000000080000000);
-        STORE2(o64 >> 48, o64 >> 16);
-
-#endif /* _NO_LONGLONG */
-
-        sp += chan2;
-        dp += chan2;
-      }
-
-      for (; i < wid; i++) {
-        p00 = buff0[i - 1]; p10 = buff1[i - 1];
-        p01 = buff0[i];     p11 = buff1[i];
-
-        buff2[i] = (mlib_s32)sp[0];
-
-        buffo[i] = CLAMP_S32(p00 * k0 + p01 * k1 + p10 * k2 + p11 * k3 - doff);
-        dp[0] = (buffo[i] >> 16) ^ 0x8000;
-
-        sp += chan1;
-        dp += chan1;
-      }
-
-      if (dx_r != 0) buff2[swid - 1] = buff2[swid - 2];
-
-      if (j < hgt - dy_b - 2) sl += sll;
-      dl += dll;
-
-      buffT = buff0;
-      buff0 = buff1;
-      buff1 = buff2;
-      buff2 = buffT;
-    }
-  }
-
-  if (pbuff != (mlib_s32*)buff_arr) mlib_free(pbuff);
-
-  return MLIB_SUCCESS;
-}
-
-/***************************************************************/
-#undef  DTYPE
-#define DTYPE mlib_u8
-
-mlib_status mlib_c_conv2x2nw_u8(mlib_image       *dst,
-                                const mlib_image *src,
-                                const mlib_s32   *kern,
-                                mlib_s32         scalef_expon,
-                                mlib_s32         cmask)
-{
-  mlib_d64 buff_arr[2*BUFF_LINE];
-  mlib_s32 *pbuff = (mlib_s32*)buff_arr, *buffo, *buff0, *buff1, *buff2, *buffT;
-  DTYPE    *adr_src, *sl, *sp, *sl1;
-  DTYPE    *adr_dst, *dl, *dp;
-  mlib_d64 k0, k1, k2, k3, scalef = (1 << 24);
-  mlib_d64 p00, p01, p02,
-           p10, p11, p12;
-  mlib_s32 wid, hgt, sll, dll, wid1;
-  mlib_s32 nchannel, chan1, chan2;
-  mlib_s32 i, j, c;
-  LOAD_KERNEL_INTO_DOUBLE();
-  GET_SRC_DST_PARAMETERS(DTYPE);
-
-  wid1 = (wid + 1) &~ 1;
-
-  if (wid1 > BUFF_LINE) {
-    pbuff = mlib_malloc(4*sizeof(mlib_s32)*wid1);
-
-    if (pbuff == NULL) return MLIB_FAILURE;
-  }
-
-  buffo = pbuff;
-  buff0 = buffo + wid1;
-  buff1 = buff0 + wid1;
-  buff2 = buff1 + wid1;
-
-  chan1 = nchannel;
-  chan2 = chan1 + chan1;
-
-  wid -= D_KER;
-  hgt -= D_KER;
-
-  for (c = 0; c < nchannel; c++) {
-    if (!(cmask & (1 << (nchannel - 1 - c)))) continue;
-
-    sl = adr_src + c;
-    dl = adr_dst + c;
-
-    sl1 = sl + sll;
-#ifdef __SUNPRO_C
-#pragma pipeloop(0)
-#endif /* __SUNPRO_C */
-    for (i = 0; i < wid + D_KER; i++) {
-      buff0[i - 1] = (mlib_s32)sl[i*chan1];
-      buff1[i - 1] = (mlib_s32)sl1[i*chan1];
-    }
-
-    sl += (D_KER + 1)*sll;
-
-    for (j = 0; j < hgt; j++) {
-      sp = sl;
-      dp = dl;
-
-      buff2[-1] = (mlib_s32)sp[0];
-      sp += chan1;
-
-      p02 = buff0[-1];
-      p12 = buff1[-1];
-
-#ifdef __SUNPRO_C
-#pragma pipeloop(0)
-#endif /* __SUNPRO_C */
-      for (i = 0; i <= (wid - 2); i += 2) {
-#ifdef _NO_LONGLONG
-        mlib_s32 o64_1, o64_2;
-#else /* _NO_LONGLONG */
-        mlib_s64 o64;
-#endif /* _NO_LONGLONG */
-        d64_2x32 sd0, sd1, dd;
-
-        p00 = p02; p10 = p12;
-
-        sd0.d64 = *(TYPE_64BIT*)(buff0 + i);
-        sd1.d64 = *(TYPE_64BIT*)(buff1 + i);
-        p01 = (mlib_d64)sd0.i32s.i0;
-        p02 = (mlib_d64)sd0.i32s.i1;
-        p11 = (mlib_d64)sd1.i32s.i0;
-        p12 = (mlib_d64)sd1.i32s.i1;
-
-        LOAD_BUFF(buff2);
-
-        dd.i32s.i0 = CLAMP_S32(p00 * k0 + p01 * k1 + p10 * k2 + p11 * k3 - (1u << 31));
-        dd.i32s.i1 = CLAMP_S32(p01 * k0 + p02 * k1 + p11 * k2 + p12 * k3 - (1u << 31));
-        *(TYPE_64BIT*)(buffo + i) = dd.d64;
-
-#ifdef _NO_LONGLONG
-
-        o64_1 = buffo[i];
-        o64_2 = buffo[i+1];
-        STORE2(o64_1 >> 24, o64_2 >> 24);
-
-#else /* _NO_LONGLONG */
-
-        o64 = *(mlib_s64*)(buffo + i);
-        STORE2(o64 >> 56, o64 >> 24);
-
-#endif /* _NO_LONGLONG */
-
-        sp += chan2;
-        dp += chan2;
-      }
-
-      for (; i < wid; i++) {
-        p00 = buff0[i - 1]; p10 = buff1[i - 1];
-        p01 = buff0[i];     p11 = buff1[i];
-
-        buff2[i] = (mlib_s32)sp[0];
-
-        buffo[i] = CLAMP_S32(p00 * k0 + p01 * k1 + p10 * k2 + p11 * k3 - (1u << 31));
-        dp[0] = (buffo[i] >> 24);
-
-        sp += chan1;
-        dp += chan1;
-      }
-
-      sl += sll;
-      dl += dll;
-
-      buffT = buff0;
-      buff0 = buff1;
-      buff1 = buff2;
-      buff2 = buffT;
-    }
-  }
-
-  {
-    mlib_s32 amask = (1 << nchannel) - 1;
-
-    if ((cmask & amask) != amask) {
-      mlib_ImageXor80(adr_dst, wid, hgt, dll, nchannel, cmask);
-    } else {
-      mlib_ImageXor80_aa(adr_dst, wid*nchannel, hgt, dll);
-    }
-  }
-
-  if (pbuff != (mlib_s32*)buff_arr) mlib_free(pbuff);
-
-  return MLIB_SUCCESS;
-}
-
-/***************************************************************/
-mlib_status mlib_c_conv2x2ext_u8(mlib_image       *dst,
-                                 const mlib_image *src,
-                                 mlib_s32         dx_l,
-                                 mlib_s32         dx_r,
-                                 mlib_s32         dy_t,
-                                 mlib_s32         dy_b,
-                                 const mlib_s32   *kern,
-                                 mlib_s32         scalef_expon,
-                                 mlib_s32         cmask)
-{
-  mlib_d64 buff_arr[4*BUFF_LINE];
-  mlib_s32 *pbuff = (mlib_s32*)buff_arr, *buffo, *buff0, *buff1, *buff2, *buffT;
-  DTYPE    *adr_src, *sl, *sp, *sl1;
-  DTYPE    *adr_dst, *dl, *dp;
-  mlib_d64 k0, k1, k2, k3, scalef = (1 << 24);
-  mlib_d64 p00, p01, p02,
-           p10, p11, p12;
-  mlib_s32 wid, hgt, sll, dll, wid1;
-  mlib_s32 nchannel, chan1, chan2;
-  mlib_s32 i, j, c, swid;
-  LOAD_KERNEL_INTO_DOUBLE();
-  GET_SRC_DST_PARAMETERS(DTYPE);
-
-  swid = wid + D_KER;
-
-  wid1 = (swid + 1) &~ 1;
-
-  if (wid1 > BUFF_LINE) {
-    pbuff = mlib_malloc(4*sizeof(mlib_s32)*wid1);
-
-    if (pbuff == NULL) return MLIB_FAILURE;
-  }
-
-  buffo = pbuff;
-  buff0 = buffo + wid1;
-  buff1 = buff0 + wid1;
-  buff2 = buff1 + wid1;
-
-  chan1 = nchannel;
-  chan2 = chan1 + chan1;
-
-  swid -= dx_r;
-
-  for (c = 0; c < nchannel; c++) {
-    if (!(cmask & (1 << (nchannel - 1 - c)))) continue;
-
-    sl = adr_src + c;
-    dl = adr_dst + c;
-
-    if ((hgt - dy_b) > 0) sl1 = sl + sll;
-    else sl1 = sl;
-
-#ifdef __SUNPRO_C
-#pragma pipeloop(0)
-#endif /* __SUNPRO_C */
-    for (i = 0; i < swid; i++) {
-      buff0[i - 1] = (mlib_s32)sl[i*chan1];
-      buff1[i - 1] = (mlib_s32)sl1[i*chan1];
-    }
-
-    if (dx_r != 0) {
-      buff0[swid - 1] = buff0[swid - 2];
-      buff1[swid - 1] = buff1[swid - 2];
-    }
-
-    if ((hgt - dy_b) > 1) sl = sl1 + sll;
-    else sl = sl1;
-
-    for (j = 0; j < hgt; j++) {
-      sp = sl;
-      dp = dl;
-
-      buff2[-1] = (mlib_s32)sp[0];
-      sp += chan1;
-
-      p02 = buff0[-1];
-      p12 = buff1[-1];
-
-#ifdef __SUNPRO_C
-#pragma pipeloop(0)
-#endif /* __SUNPRO_C */
-      for (i = 0; i <= (wid - 2); i += 2) {
-#ifdef _NO_LONGLONG
-        mlib_s32 o64_1, o64_2;
-#else /* _NO_LONGLONG */
-        mlib_s64 o64;
-#endif /* _NO_LONGLONG */
-        d64_2x32 sd0, sd1, dd;
-
-        p00 = p02; p10 = p12;
-
-        sd0.d64 = *(TYPE_64BIT*)(buff0 + i);
-        sd1.d64 = *(TYPE_64BIT*)(buff1 + i);
-        p01 = (mlib_d64)sd0.i32s.i0;
-        p02 = (mlib_d64)sd0.i32s.i1;
-        p11 = (mlib_d64)sd1.i32s.i0;
-        p12 = (mlib_d64)sd1.i32s.i1;
-
-        LOAD_BUFF(buff2);
-
-        dd.i32s.i0 = CLAMP_S32(p00 * k0 + p01 * k1 + p10 * k2 + p11 * k3 - (1u << 31));
-        dd.i32s.i1 = CLAMP_S32(p01 * k0 + p02 * k1 + p11 * k2 + p12 * k3 - (1u << 31));
-        *(TYPE_64BIT*)(buffo + i) = dd.d64;
-
-#ifdef _NO_LONGLONG
-
-        o64_1 = buffo[i];
-        o64_2 = buffo[i+1];
-        STORE2(o64_1 >> 24, o64_2 >> 24);
-
-#else /* _NO_LONGLONG */
-
-        o64 = *(mlib_s64*)(buffo + i);
-        STORE2(o64 >> 56, o64 >> 24);
-
-#endif /* _NO_LONGLONG */
-
-        sp += chan2;
-        dp += chan2;
-      }
-
-      for (; i < wid; i++) {
-        p00 = buff0[i - 1]; p10 = buff1[i - 1];
-        p01 = buff0[i];     p11 = buff1[i];
-
-        buff2[i] = (mlib_s32)sp[0];
-
-        buffo[i] = CLAMP_S32(p00 * k0 + p01 * k1 + p10 * k2 + p11 * k3 - (1u << 31));
-        dp[0] = (buffo[i] >> 24);
-
-        sp += chan1;
-        dp += chan1;
-      }
-
-      if (dx_r != 0) buff2[swid - 1] = buff2[swid - 2];
-
-      if (j < hgt - dy_b - 2) sl += sll;
-      dl += dll;
-
-      buffT = buff0;
-      buff0 = buff1;
-      buff1 = buff2;
-      buff2 = buffT;
-    }
-  }
-
-  {
-    mlib_s32 amask = (1 << nchannel) - 1;
-
-    if ((cmask & amask) != amask) {
-      mlib_ImageXor80(adr_dst, wid, hgt, dll, nchannel, cmask);
-    } else {
-      mlib_ImageXor80_aa(adr_dst, wid*nchannel, hgt, dll);
-    }
-  }
-
-  if (pbuff != (mlib_s32*)buff_arr) mlib_free(pbuff);
-
-  return MLIB_SUCCESS;
-}
-
-/***************************************************************/
--- a/jdk/src/java.desktop/share/native/libmlib_image/mlib_ImageConv_16ext.c	Thu May 19 17:48:02 2016 +0000
+++ b/jdk/src/java.desktop/share/native/libmlib_image/mlib_ImageConv_16ext.c	Thu May 19 19:46:20 2016 +0000
@@ -80,9 +80,6 @@
 #endif /* IMG_TYPE == 1 */
 
 /***************************************************************/
-#define KSIZE1 (KSIZE - 1)
-
-/***************************************************************/
 #define PARAM                                                   \
   mlib_image       *dst,                                        \
   const mlib_image *src,                                        \
@@ -163,9 +160,6 @@
 #endif /* _NO_LONGLONG */
 
 /***************************************************************/
-#define MLIB_D2_24 16777216.0f
-
-/***************************************************************/
 typedef union {
   mlib_d64 d64;
   struct {
@@ -175,52 +169,6 @@
 } d64_2x32;
 
 /***************************************************************/
-#define BUFF_LINE 256
-
-/***************************************************************/
-#define DEF_VARS(type)                                          \
-  type     *adr_src, *sl, *sp, *sl1;                            \
-  type     *adr_dst, *dl, *dp;                                  \
-  FTYPE    *pbuff = buff;                                       \
-  mlib_s32 *buffi, *buffo;                                      \
-  mlib_s32 wid, hgt, sll, dll;                                  \
-  mlib_s32 nchannel, chan1, chan2;                              \
-  mlib_s32 i, j, c, swid
-
-/***************************************************************/
-#define LOAD_KERNEL3()                                                   \
-  FTYPE    scalef = DSCALE;                                              \
-  FTYPE    k0, k1, k2, k3, k4, k5, k6, k7, k8;                           \
-  FTYPE    p00, p01, p02, p03,                                           \
-           p10, p11, p12, p13,                                           \
-           p20, p21, p22, p23;                                           \
-                                                                         \
-  while (scalef_expon > 30) {                                            \
-    scalef /= (1 << 30);                                                 \
-    scalef_expon -= 30;                                                  \
-  }                                                                      \
-                                                                         \
-  scalef /= (1 << scalef_expon);                                         \
-                                                                         \
-  /* keep kernel in regs */                                              \
-  k0 = scalef * kern[0];  k1 = scalef * kern[1];  k2 = scalef * kern[2]; \
-  k3 = scalef * kern[3];  k4 = scalef * kern[4];  k5 = scalef * kern[5]; \
-  k6 = scalef * kern[6];  k7 = scalef * kern[7];  k8 = scalef * kern[8]
-
-/***************************************************************/
-#define LOAD_KERNEL(SIZE)                                       \
-  FTYPE    scalef = DSCALE;                                     \
-                                                                \
-  while (scalef_expon > 30) {                                   \
-    scalef /= (1 << 30);                                        \
-    scalef_expon -= 30;                                         \
-  }                                                             \
-                                                                \
-  scalef /= (1 << scalef_expon);                                \
-                                                                \
-  for (j = 0; j < SIZE; j++) k[j] = scalef * kern[j]
-
-/***************************************************************/
 #define GET_SRC_DST_PARAMETERS(type)                            \
   hgt = mlib_ImageGetHeight(src);                               \
   wid = mlib_ImageGetWidth(src);                                \
@@ -278,1334 +226,6 @@
 #endif /* __sparc */
 
 /***************************************************************/
-#define KSIZE  3
-
-mlib_status CONV_FUNC(3x3)
-{
-  FTYPE    buff[(KSIZE + 2)*BUFF_LINE], *buff0, *buff1, *buff2, *buff3, *buffT;
-  DEF_VARS(DTYPE);
-  DTYPE *sl2;
-#ifndef __sparc
-  mlib_s32 d0, d1;
-#endif /* __sparc */
-  LOAD_KERNEL3();
-  GET_SRC_DST_PARAMETERS(DTYPE);
-
-  swid = wid + KSIZE1;
-
-  if (swid > BUFF_LINE) {
-    pbuff = mlib_malloc((KSIZE + 2)*sizeof(FTYPE   )*swid);
-
-    if (pbuff == NULL) return MLIB_FAILURE;
-  }
-
-  buff0 = pbuff;
-  buff1 = buff0 + swid;
-  buff2 = buff1 + swid;
-  buff3 = buff2 + swid;
-  buffo = (mlib_s32*)(buff3 + swid);
-  buffi = buffo + (swid &~ 1);
-
-  swid -= (dx_l + dx_r);
-
-  chan1 = nchannel;
-  chan2 = chan1 + chan1;
-
-  for (c = 0; c < nchannel; c++) {
-    if (!(cmask & (1 << (nchannel - 1 - c)))) continue;
-
-    sl = adr_src + c;
-    dl = adr_dst + c;
-
-    if ((1 > dy_t) && (1 < hgt + KSIZE1 - dy_b)) sl1 = sl + sll;
-    else sl1 = sl;
-
-    if ((hgt - dy_b) > 0) sl2 = sl1 + sll;
-    else sl2 = sl1;
-
-    for (i = 0; i < dx_l; i++) {
-      buff0[i] = (FTYPE)sl[0];
-      buff1[i] = (FTYPE)sl1[0];
-      buff2[i] = (FTYPE)sl2[0];
-    }
-
-#ifdef __SUNPRO_C
-#pragma pipeloop(0)
-#endif /* __SUNPRO_C */
-    for (i = 0; i < swid; i++) {
-      buff0[i + dx_l] = (FTYPE)sl[i*chan1];
-      buff1[i + dx_l] = (FTYPE)sl1[i*chan1];
-      buff2[i + dx_l] = (FTYPE)sl2[i*chan1];
-    }
-
-    for (i = 0; i < dx_r; i++) {
-      buff0[swid + dx_l + i] = buff0[swid + dx_l - 1];
-      buff1[swid + dx_l + i] = buff1[swid + dx_l - 1];
-      buff2[swid + dx_l + i] = buff2[swid + dx_l - 1];
-    }
-
-    if ((hgt - dy_b) > 1) sl = sl2 + sll;
-    else sl = sl2;
-
-    for (j = 0; j < hgt; j++) {
-      FTYPE    s0, s1;
-
-      p02 = buff0[0];
-      p12 = buff1[0];
-      p22 = buff2[0];
-
-      p03 = buff0[1];
-      p13 = buff1[1];
-      p23 = buff2[1];
-
-      s0 = p02 * k0 + p03 * k1 + p12 * k3 + p13 * k4 + p22 * k6 + p23 * k7;
-      s1 = p03 * k0 + p13 * k3 + p23 * k6;
-
-      sp = sl;
-      dp = dl;
-
-#ifdef __SUNPRO_C
-#pragma pipeloop(0)
-#endif /* __SUNPRO_C */
-      for (i = 0; i <= (wid - 2); i += 2) {
-#ifdef __sparc
-#ifdef _NO_LONGLONG
-        mlib_s32 o64_1, o64_2;
-#else /* _NO_LONGLONG */
-        mlib_s64 o64;
-#endif /* _NO_LONGLONG */
-#endif /* __sparc */
-        d64_2x32 dd;
-
-        p02 = buff0[i + 2]; p12 = buff1[i + 2]; p22 = buff2[i + 2];
-        p03 = buff0[i + 3]; p13 = buff1[i + 3]; p23 = buff2[i + 3];
-
-        LOAD_BUFF(buffi);
-
-        dd.d64 = *(FTYPE   *)(buffi + i);
-        buff3[i + dx_l    ] = (FTYPE)dd.i32s.i0;
-        buff3[i + dx_l + 1] = (FTYPE)dd.i32s.i1;
-
-#ifndef __sparc
-
-        d0 = D2I(s0 + p02 * k2 + p12 * k5 + p22 * k8);
-        d1 = D2I(s1 + p02 * k1 + p03 * k2 + p12 * k4 + p13 * k5 + p22 * k7 + p23 * k8);
-
-        s0 = p02 * k0 + p03 * k1 + p12 * k3 + p13 * k4 + p22 * k6 + p23 * k7;
-        s1 = p03 * k0 + p13 * k3 + p23 * k6;
-
-        dp[0    ] = FROM_S32(d0);
-        dp[chan1] = FROM_S32(d1);
-
-#else /* __sparc */
-
-        dd.i32s.i0 = D2I(s0 + p02 * k2 + p12 * k5 + p22 * k8);
-        dd.i32s.i1 = D2I(s1 + p02 * k1 + p03 * k2 + p12 * k4 + p13 * k5 + p22 * k7 + p23 * k8);
-        *(FTYPE   *)(buffo + i) = dd.d64;
-
-        s0 = p02 * k0 + p03 * k1 + p12 * k3 + p13 * k4 + p22 * k6 + p23 * k7;
-        s1 = p03 * k0 + p13 * k3 + p23 * k6;
-
-#ifdef _NO_LONGLONG
-
-        o64_1 = buffo[i];
-        o64_2 = buffo[i+1];
-#if IMG_TYPE != 1
-        STORE2(FROM_S32(o64_1), FROM_S32(o64_2));
-#else
-        STORE2(o64_1 >> 24, o64_2 >> 24);
-#endif /* IMG_TYPE != 1 */
-
-#else /* _NO_LONGLONG */
-
-        o64 = *(mlib_s64*)(buffo + i);
-#if IMG_TYPE != 1
-        STORE2(FROM_S32(o64 >> 32), FROM_S32(o64));
-#else
-        STORE2(o64 >> 56, o64 >> 24);
-#endif /* IMG_TYPE != 1 */
-#endif /* _NO_LONGLONG */
-#endif /* __sparc */
-
-        sp += chan2;
-        dp += chan2;
-      }
-
-      for (; i < wid; i++) {
-        p00 = buff0[i];     p10 = buff1[i];     p20 = buff2[i];
-        p01 = buff0[i + 1]; p11 = buff1[i + 1]; p21 = buff2[i + 1];
-        p02 = buff0[i + 2]; p12 = buff1[i + 2]; p22 = buff2[i + 2];
-
-        buffi[i] = (mlib_s32)sp[0];
-        buff3[i + dx_l] = (FTYPE)buffi[i];
-
-#ifndef __sparc
-
-        d0 = D2I(p00 * k0 + p01 * k1 + p02 * k2 + p10 * k3 + p11 * k4 +
-                 p12 * k5 + p20 * k6 + p21 * k7 + p22 * k8);
-
-        dp[0] = FROM_S32(d0);
-
-#else  /* __sparc */
-
-        buffo[i] = D2I(p00 * k0 + p01 * k1 + p02 * k2 + p10 * k3 + p11 * k4 +
-                       p12 * k5 + p20 * k6 + p21 * k7 + p22 * k8);
-#if IMG_TYPE != 1
-        dp[0] = FROM_S32(buffo[i]);
-#else
-        dp[0] = buffo[i] >> 24;
-#endif /* IMG_TYPE != 1 */
-#endif /* __sparc */
-
-        sp += chan1;
-        dp += chan1;
-      }
-
-      for (; i < swid; i++) {
-        buffi[i] = (mlib_s32)sp[0];
-        buff3[i + dx_l] = (FTYPE)buffi[i];
-        sp += chan1;
-      }
-
-      for (i = 0; i < dx_l; i++) buff3[i] = buff3[dx_l];
-      for (i = 0; i < dx_r; i++) buff3[swid + dx_l + i] = buff3[swid + dx_l - 1];
-
-      if (j < hgt - dy_b - 2) sl += sll;
-      dl += dll;
-
-      buffT = buff0;
-      buff0 = buff1;
-      buff1 = buff2;
-      buff2 = buff3;
-      buff3 = buffT;
-    }
-  }
-
-#ifdef __sparc
-#if IMG_TYPE == 1
-  {
-    mlib_s32 amask = (1 << nchannel) - 1;
-
-    if ((cmask & amask) != amask) {
-      mlib_ImageXor80(adr_dst, wid, hgt, dll, nchannel, cmask);
-    } else {
-      mlib_ImageXor80_aa(adr_dst, wid*nchannel, hgt, dll);
-    }
-  }
-
-#endif /* IMG_TYPE == 1 */
-#endif /* __sparc */
-
-  if (pbuff != buff) mlib_free(pbuff);
-
-  return MLIB_SUCCESS;
-}
-
-/***************************************************************/
-#ifndef __sparc /* for x86, using integer multiplies is faster */
-
-mlib_status CONV_FUNC_I(3x3)
-{
-  DTYPE    *adr_src, *sl, *sp0, *sp1, *sp2, *sp_1, *sp_2;
-  DTYPE    *adr_dst, *dl, *dp;
-  mlib_s32 wid, hgt, sll, dll;
-  mlib_s32 nchannel, chan1, chan2, delta_chan;
-  mlib_s32 i, j, c;
-  mlib_s32 shift1, shift2;
-  mlib_s32 k0, k1, k2, k3, k4, k5, k6, k7, k8;
-  mlib_s32 p02, p03,
-           p12, p13,
-           p22, p23;
-
-#if IMG_TYPE != 1
-  shift1 = 16;
-#else
-  shift1 = 8;
-#endif /* IMG_TYPE != 1 */
-
-  shift2 = scalef_expon - shift1;
-
-  /* keep kernel in regs */
-  k0 = kern[0] >> shift1;  k1 = kern[1] >> shift1;  k2 = kern[2] >> shift1;
-  k3 = kern[3] >> shift1;  k4 = kern[4] >> shift1;  k5 = kern[5] >> shift1;
-  k6 = kern[6] >> shift1;  k7 = kern[7] >> shift1;  k8 = kern[8] >> shift1;
-
-  GET_SRC_DST_PARAMETERS(DTYPE);
-
-  chan1 = nchannel;
-  chan2 = chan1 + chan1;
-  delta_chan = 0;
-
-  if ((1 > dx_l) && (1 < wid + KSIZE1 - dx_r)) delta_chan = chan1;
-
-  for (c = 0; c < chan1; c++) {
-    if (!(cmask & (1 << (chan1 - 1 - c)))) continue;
-
-    sl = adr_src + c;
-    dl = adr_dst + c;
-
-    sp_1 = sl;
-
-    if ((1 > dy_t) && (1 < hgt + KSIZE1 - dy_b)) sl += sll;
-    sp_2 = sl;
-
-    if ((hgt - dy_b) > 0) sl += sll;
-
-    for (j = 0; j < hgt; j++) {
-      mlib_s32 s0, s1;
-      mlib_s32 pix0, pix1;
-
-      dp  = dl;
-      sp0 = sp_1;
-      sp_1 = sp_2;
-      sp_2 = sl;
-
-      sp1 = sp_1;
-      sp2 = sp_2;
-
-      p02 = sp0[0];
-      p12 = sp1[0];
-      p22 = sp2[0];
-
-      p03 = sp0[delta_chan];
-      p13 = sp1[delta_chan];
-      p23 = sp2[delta_chan];
-
-      s0 = p02 * k0 + p03 * k1 + p12 * k3 + p13 * k4 + p22 * k6 + p23 * k7;
-      s1 = p03 * k0 + p13 * k3 + p23 * k6;
-
-      sp0 += (chan1 + delta_chan);
-      sp1 += (chan1 + delta_chan);
-      sp2 += (chan1 + delta_chan);
-
-#ifdef __SUNPRO_C
-#pragma pipeloop(0)
-#endif /* __SUNPRO_C */
-      for (i = 0; i <= (wid - dx_r - 2); i += 2) {
-        p02 = sp0[0];     p12 = sp1[0];     p22 = sp2[0];
-        p03 = sp0[chan1]; p13 = sp1[chan1]; p23 = sp2[chan1];
-
-        pix0 = (s0 + p02 * k2 + p12 * k5 + p22 * k8) >> shift2;
-        pix1 = (s1 + p02 * k1 + p03 * k2 + p12 * k4 +
-                p13 * k5 + p22 * k7 + p23 * k8) >> shift2;
-
-        CLAMP_STORE(dp[0],     pix0);
-        CLAMP_STORE(dp[chan1], pix1);
-
-        s0 = p02 * k0 + p03 * k1 + p12 * k3 + p13 * k4 + p22 * k6 + p23 * k7;
-        s1 = p03 * k0 + p13 * k3 + p23 * k6;
-
-        sp0 += chan2;
-        sp1 += chan2;
-        sp2 += chan2;
-        dp += chan2;
-      }
-
-      p02 = p03; p12 = p13; p22 = p23;
-
-      for (; i < wid - dx_r; i++) {
-        p03 = sp0[0]; p13 = sp1[0]; p23 = sp2[0];
-        pix0 = (s0 + p03 * k2 + p13 * k5 + p23 * k8) >> shift2;
-        CLAMP_STORE(dp[0], pix0);
-        s0 = p02 * k0 + p03 * k1 + p12 * k3 + p13 * k4 + p22 * k6 + p23 * k7;
-        p02 = p03; p12 = p13; p22 = p23;
-        sp0 += chan1;
-        sp1 += chan1;
-        sp2 += chan1;
-        dp += chan1;
-      }
-
-      sp0 -= chan1;
-      sp1 -= chan1;
-      sp2 -= chan1;
-
-      for (; i < wid; i++) {
-        p03 = sp0[0]; p13 = sp1[0]; p23 = sp2[0];
-        pix0 = (s0 + p03 * k2 + p13 * k5 + p23 * k8) >> shift2;
-        CLAMP_STORE(dp[0], pix0);
-        s0 = p02 * k0 + p03 * k1 + p12 * k3 + p13 * k4 + p22 * k6 + p23 * k7;
-        p02 = p03; p12 = p13; p22 = p23;
-        dp += chan1;
-      }
-
-      if (j < hgt - dy_b - 1) sl += sll;
-      dl += dll;
-    }
-  }
-
-  return MLIB_SUCCESS;
-}
-
-#endif /* __sparc ( for x86, using integer multiplies is faster ) */
-
-/***************************************************************/
-#undef  KSIZE
-#define KSIZE 4
-
-mlib_status CONV_FUNC(4x4)
-{
-  FTYPE    buff[(KSIZE + 3)*BUFF_LINE];
-  FTYPE    *buff0, *buff1, *buff2, *buff3, *buff4, *buffd, *buffT;
-  FTYPE    k[KSIZE*KSIZE];
-  mlib_s32 d0, d1;
-  FTYPE    k0, k1, k2, k3, k4, k5, k6, k7;
-  FTYPE    p00, p01, p02, p03, p04,
-           p10, p11, p12, p13, p14,
-           p20, p21, p22, p23,
-           p30, p31, p32, p33;
-  DEF_VARS(DTYPE);
-  DTYPE *sl2, *sl3;
-  LOAD_KERNEL(KSIZE*KSIZE);
-  GET_SRC_DST_PARAMETERS(DTYPE);
-
-  swid = wid + KSIZE1;
-
-  if (swid > BUFF_LINE) {
-    pbuff = mlib_malloc((KSIZE + 3)*sizeof(FTYPE   )*swid);
-
-    if (pbuff == NULL) return MLIB_FAILURE;
-  }
-
-  buff0 = pbuff;
-  buff1 = buff0 + swid;
-  buff2 = buff1 + swid;
-  buff3 = buff2 + swid;
-  buff4 = buff3 + swid;
-  buffd = buff4 + swid;
-  buffo = (mlib_s32*)(buffd + swid);
-  buffi = buffo + (swid &~ 1);
-
-  swid -= (dx_l + dx_r);
-
-  chan1 = nchannel;
-  chan2 = chan1 + chan1;
-
-  for (c = 0; c < nchannel; c++) {
-    if (!(cmask & (1 << (nchannel - 1 - c)))) continue;
-
-    sl = adr_src + c;
-    dl = adr_dst + c;
-
-    if ((1 > dy_t) && (1 < hgt + KSIZE1 - dy_b)) sl1 = sl + sll;
-    else sl1 = sl;
-
-    if ((2 > dy_t) && (2 < hgt + KSIZE1 - dy_b)) sl2 = sl1 + sll;
-    else sl2 = sl1;
-
-    if ((hgt - dy_b) > 0) sl3 = sl2 + sll;
-    else sl3 = sl2;
-
-    for (i = 0; i < dx_l; i++) {
-      buff0[i] = (FTYPE)sl[0];
-      buff1[i] = (FTYPE)sl1[0];
-      buff2[i] = (FTYPE)sl2[0];
-      buff3[i] = (FTYPE)sl3[0];
-    }
-
-#ifdef __SUNPRO_C
-#pragma pipeloop(0)
-#endif /* __SUNPRO_C */
-    for (i = 0; i < swid; i++) {
-      buff0[i + dx_l] = (FTYPE)sl[i*chan1];
-      buff1[i + dx_l] = (FTYPE)sl1[i*chan1];
-      buff2[i + dx_l] = (FTYPE)sl2[i*chan1];
-      buff3[i + dx_l] = (FTYPE)sl3[i*chan1];
-    }
-
-    for (i = 0; i < dx_r; i++) {
-      buff0[swid + dx_l + i] = buff0[swid + dx_l - 1];
-      buff1[swid + dx_l + i] = buff1[swid + dx_l - 1];
-      buff2[swid + dx_l + i] = buff2[swid + dx_l - 1];
-      buff3[swid + dx_l + i] = buff3[swid + dx_l - 1];
-    }
-
-    if ((hgt - dy_b) > 1) sl = sl3 + sll;
-    else sl = sl3;
-
-    for (j = 0; j < hgt; j++) {
-      d64_2x32 dd;
-
-      /*
-       *  First loop on two first lines of kernel
-       */
-      k0 = k[0]; k1 = k[1]; k2 = k[2]; k3 = k[3];
-      k4 = k[4]; k5 = k[5]; k6 = k[6]; k7 = k[7];
-
-      sp = sl;
-      dp = dl;
-
-      p02 = buff0[0];
-      p12 = buff1[0];
-      p03 = buff0[1];
-      p13 = buff1[1];
-      p04 = buff0[2];
-
-#ifdef __SUNPRO_C
-#pragma pipeloop(0)
-#endif /* __SUNPRO_C */
-      for (i = 0; i <= (wid - 2); i += 2) {
-        p00 = p02; p10 = p12;
-        p01 = p03; p11 = p13;
-        p02 = p04; p12 = buff1[i + 2];
-        p03 = buff0[i + 3]; p13 = buff1[i + 3];
-        p04 = buff0[i + 4]; p14 = buff1[i + 4];
-
-        LOAD_BUFF(buffi);
-
-        dd.d64 = *(FTYPE   *)(buffi + i);
-        buff4[i + dx_l    ] = (FTYPE)dd.i32s.i0;
-        buff4[i + dx_l + 1] = (FTYPE)dd.i32s.i1;
-
-        buffd[i    ] = (p00 * k0 + p01 * k1 + p02 * k2 + p03 * k3 +
-                        p10 * k4 + p11 * k5 + p12 * k6 + p13 * k7);
-        buffd[i + 1] = (p01 * k0 + p02 * k1 + p03 * k2 + p04 * k3 +
-                        p11 * k4 + p12 * k5 + p13 * k6 + p14 * k7);
-
-        sp += chan2;
-      }
-
-      /*
-       *  Second loop on two last lines of kernel
-       */
-      k0 = k[ 8]; k1 = k[ 9]; k2 = k[10]; k3 = k[11];
-      k4 = k[12]; k5 = k[13]; k6 = k[14]; k7 = k[15];
-
-      p02 = buff2[0];
-      p12 = buff3[0];
-      p03 = buff2[1];
-      p13 = buff3[1];
-      p04 = buff2[2];
-
-#ifdef __SUNPRO_C
-#pragma pipeloop(0)
-#endif /* __SUNPRO_C */
-      for (i = 0; i <= (wid - 2); i += 2) {
-        p00 = p02; p10 = p12;
-        p01 = p03; p11 = p13;
-        p02 = p04; p12 = buff3[i + 2];
-        p03 = buff2[i + 3]; p13 = buff3[i + 3];
-        p04 = buff2[i + 4]; p14 = buff3[i + 4];
-
-        d0 = D2I(p00 * k0 + p01 * k1 + p02 * k2 + p03 * k3 +
-                 p10 * k4 + p11 * k5 + p12 * k6 + p13 * k7 + buffd[i]);
-        d1 = D2I(p01 * k0 + p02 * k1 + p03 * k2 + p04 * k3 +
-                 p11 * k4 + p12 * k5 + p13 * k6 + p14 * k7 + buffd[i + 1]);
-
-        dp[0    ] = FROM_S32(d0);
-        dp[chan1] = FROM_S32(d1);
-
-        dp += chan2;
-      }
-
-      /* last pixels */
-      for (; i < wid; i++) {
-        p00 = buff0[i];     p10 = buff1[i];     p20 = buff2[i];     p30 = buff3[i];
-        p01 = buff0[i + 1]; p11 = buff1[i + 1]; p21 = buff2[i + 1]; p31 = buff3[i + 1];
-        p02 = buff0[i + 2]; p12 = buff1[i + 2]; p22 = buff2[i + 2]; p32 = buff3[i + 2];
-        p03 = buff0[i + 3]; p13 = buff1[i + 3]; p23 = buff2[i + 3]; p33 = buff3[i + 3];
-
-        buff4[i + dx_l] = (FTYPE)sp[0];
-
-        buffo[i] = D2I(p00 * k[0] + p01 * k[1] + p02 * k[2] + p03 * k[3] +
-                       p10 * k[4] + p11 * k[5] + p12 * k[6] + p13 * k[7] +
-                       p20 * k[ 8] + p21 * k[ 9] + p22 * k[10] + p23 * k[11] +
-                       p30 * k[12] + p31 * k[13] + p32 * k[14] + p33 * k[15]);
-
-        dp[0] = FROM_S32(buffo[i]);
-
-        sp += chan1;
-        dp += chan1;
-      }
-
-      for (; i < swid; i++) {
-        buff4[i + dx_l] = (FTYPE)sp[0];
-        sp += chan1;
-      }
-
-      for (i = 0; i < dx_l; i++) buff4[i] = buff4[dx_l];
-      for (i = 0; i < dx_r; i++) buff4[swid + dx_l + i] = buff4[swid + dx_l - 1];
-
-      /* next line */
-
-      if (j < hgt - dy_b - 2) sl += sll;
-      dl += dll;
-
-      buffT = buff0;
-      buff0 = buff1;
-      buff1 = buff2;
-      buff2 = buff3;
-      buff3 = buff4;
-      buff4 = buffT;
-    }
-  }
-
-  if (pbuff != buff) mlib_free(pbuff);
-
-  return MLIB_SUCCESS;
-}
-
-/***************************************************************/
-#undef  KSIZE
-#define KSIZE 5
-
-mlib_status CONV_FUNC(5x5)
-{
-  FTYPE    buff[(KSIZE + 3)*BUFF_LINE];
-  FTYPE    *buff0, *buff1, *buff2, *buff3, *buff4, *buff5, *buffd, *buffT;
-  FTYPE    k[KSIZE*KSIZE];
-  mlib_s32 d0, d1;
-  FTYPE    k0, k1, k2, k3, k4, k5, k6, k7, k8, k9;
-  FTYPE    p00, p01, p02, p03, p04, p05,
-           p10, p11, p12, p13, p14, p15,
-           p20, p21, p22, p23, p24,
-           p30, p31, p32, p33, p34,
-           p40, p41, p42, p43, p44;
-  DEF_VARS(DTYPE);
-  DTYPE *sl2, *sl3, *sl4;
-  LOAD_KERNEL(KSIZE*KSIZE);
-  GET_SRC_DST_PARAMETERS(DTYPE);
-
-  swid = wid + KSIZE1;
-
-  if (swid > BUFF_LINE) {
-    pbuff = mlib_malloc((KSIZE + 3)*sizeof(FTYPE   )*swid);
-
-    if (pbuff == NULL) return MLIB_FAILURE;
-  }
-
-  buff0 = pbuff;
-  buff1 = buff0 + swid;
-  buff2 = buff1 + swid;
-  buff3 = buff2 + swid;
-  buff4 = buff3 + swid;
-  buff5 = buff4 + swid;
-  buffd = buff5 + swid;
-  buffo = (mlib_s32*)(buffd + swid);
-  buffi = buffo + (swid &~ 1);
-
-  swid -= (dx_l + dx_r);
-
-  chan1 = nchannel;
-  chan2 = chan1 + chan1;
-
-  for (c = 0; c < nchannel; c++) {
-    if (!(cmask & (1 << (nchannel - 1 - c)))) continue;
-
-    sl = adr_src + c;
-    dl = adr_dst + c;
-
-    if ((1 > dy_t) && (1 < hgt + KSIZE1 - dy_b)) sl1 = sl + sll;
-    else sl1 = sl;
-
-    if ((2 > dy_t) && (2 < hgt + KSIZE1 - dy_b)) sl2 = sl1 + sll;
-    else sl2 = sl1;
-
-    if ((3 > dy_t) && (3 < hgt + KSIZE1 - dy_b)) sl3 = sl2 + sll;
-    else sl3 = sl2;
-
-    if ((hgt - dy_b) > 0) sl4 = sl3 + sll;
-    else sl4 = sl3;
-
-    for (i = 0; i < dx_l; i++) {
-      buff0[i] = (FTYPE)sl[0];
-      buff1[i] = (FTYPE)sl1[0];
-      buff2[i] = (FTYPE)sl2[0];
-      buff3[i] = (FTYPE)sl3[0];
-      buff4[i] = (FTYPE)sl4[0];
-    }
-
-#ifdef __SUNPRO_C
-#pragma pipeloop(0)
-#endif /* __SUNPRO_C */
-    for (i = 0; i < swid; i++) {
-      buff0[i + dx_l] = (FTYPE)sl[i*chan1];
-      buff1[i + dx_l] = (FTYPE)sl1[i*chan1];
-      buff2[i + dx_l] = (FTYPE)sl2[i*chan1];
-      buff3[i + dx_l] = (FTYPE)sl3[i*chan1];
-      buff4[i + dx_l] = (FTYPE)sl4[i*chan1];
-    }
-
-    for (i = 0; i < dx_r; i++) {
-      buff0[swid + dx_l + i] = buff0[swid + dx_l - 1];
-      buff1[swid + dx_l + i] = buff1[swid + dx_l - 1];
-      buff2[swid + dx_l + i] = buff2[swid + dx_l - 1];
-      buff3[swid + dx_l + i] = buff3[swid + dx_l - 1];
-      buff4[swid + dx_l + i] = buff4[swid + dx_l - 1];
-    }
-
-    if ((hgt - dy_b) > 1) sl = sl4 + sll;
-    else sl = sl4;
-
-    for (j = 0; j < hgt; j++) {
-      d64_2x32 dd;
-
-      /*
-       *  First loop
-       */
-      k0 = k[0]; k1 = k[1]; k2 = k[2]; k3 = k[3]; k4 = k[4];
-      k5 = k[5]; k6 = k[6]; k7 = k[7]; k8 = k[8]; k9 = k[9];
-
-      sp = sl;
-      dp = dl;
-
-      p02 = buff0[0];
-      p12 = buff1[0];
-      p03 = buff0[1];
-      p13 = buff1[1];
-      p04 = buff0[2];
-      p14 = buff1[2];
-
-#ifdef __SUNPRO_C
-#pragma pipeloop(0)
-#endif /* __SUNPRO_C */
-      for (i = 0; i <= (wid - 2); i += 2) {
-        p00 = p02; p10 = p12;
-        p01 = p03; p11 = p13;
-        p02 = p04; p12 = p14;
-
-        LOAD_BUFF(buffi);
-
-        p03 = buff0[i + 3]; p13 = buff1[i + 3];
-        p04 = buff0[i + 4]; p14 = buff1[i + 4];
-        p05 = buff0[i + 5]; p15 = buff1[i + 5];
-
-        buffd[i    ] = (p00 * k0 + p01 * k1 + p02 * k2 + p03 * k3 + p04 * k4 +
-                        p10 * k5 + p11 * k6 + p12 * k7 + p13 * k8 + p14 * k9);
-        buffd[i + 1] = (p01 * k0 + p02 * k1 + p03 * k2 + p04 * k3 + p05 * k4 +
-                        p11 * k5 + p12 * k6 + p13 * k7 + p14 * k8 + p15 * k9);
-
-        sp += chan2;
-      }
-
-      /*
-       *  Second loop
-       */
-      k0 = k[10]; k1 = k[11]; k2 = k[12]; k3 = k[13]; k4 = k[14];
-      k5 = k[15]; k6 = k[16]; k7 = k[17]; k8 = k[18]; k9 = k[19];
-
-      p02 = buff2[0];
-      p12 = buff3[0];
-      p03 = buff2[1];
-      p13 = buff3[1];
-
-#ifdef __SUNPRO_C
-#pragma pipeloop(0)
-#endif /* __SUNPRO_C */
-      for (i = 0; i <= (wid - 2); i += 2) {
-        p00 = p02; p10 = p12;
-        p01 = p03; p11 = p13;
-
-        p02 = buff2[i + 2]; p12 = buff3[i + 2];
-        p03 = buff2[i + 3]; p13 = buff3[i + 3];
-        p04 = buff2[i + 4]; p14 = buff3[i + 4];
-        p05 = buff2[i + 5]; p15 = buff3[i + 5];
-
-        dd.d64 = *(FTYPE   *)(buffi + i);
-        buff5[i + dx_l    ] = (FTYPE)dd.i32s.i0;
-        buff5[i + dx_l + 1] = (FTYPE)dd.i32s.i1;
-
-        buffd[i    ] += (p00 * k0 + p01 * k1 + p02 * k2 + p03 * k3 + p04 * k4 +
-                         p10 * k5 + p11 * k6 + p12 * k7 + p13 * k8 + p14 * k9);
-        buffd[i + 1] += (p01 * k0 + p02 * k1 + p03 * k2 + p04 * k3 + p05 * k4 +
-                         p11 * k5 + p12 * k6 + p13 * k7 + p14 * k8 + p15 * k9);
-      }
-
-      /*
-       *  3 loop
-       */
-      k0 = k[20]; k1 = k[21]; k2 = k[22]; k3 = k[23]; k4 = k[24];
-
-      p02 = buff4[0];
-      p03 = buff4[1];
-      p04 = buff4[2];
-      p05 = buff4[3];
-
-#ifdef __SUNPRO_C
-#pragma pipeloop(0)
-#endif /* __SUNPRO_C */
-      for (i = 0; i <= (wid - 2); i += 2) {
-        p00 = p02; p01 = p03; p02 = p04; p03 = p05;
-
-        p04 = buff4[i + 4]; p05 = buff4[i + 5];
-
-        d0 = D2I(p00 * k0 + p01 * k1 + p02 * k2 + p03 * k3 + p04 * k4 + buffd[i]);
-        d1 = D2I(p01 * k0 + p02 * k1 + p03 * k2 + p04 * k3 + p05 * k4 + buffd[i + 1]);
-
-        dp[0    ] = FROM_S32(d0);
-        dp[chan1] = FROM_S32(d1);
-
-        dp += chan2;
-      }
-
-      /* last pixels */
-      for (; i < wid; i++) {
-        p00 = buff0[i];     p10 = buff1[i];     p20 = buff2[i];     p30 = buff3[i];
-        p01 = buff0[i + 1]; p11 = buff1[i + 1]; p21 = buff2[i + 1]; p31 = buff3[i + 1];
-        p02 = buff0[i + 2]; p12 = buff1[i + 2]; p22 = buff2[i + 2]; p32 = buff3[i + 2];
-        p03 = buff0[i + 3]; p13 = buff1[i + 3]; p23 = buff2[i + 3]; p33 = buff3[i + 3];
-        p04 = buff0[i + 4]; p14 = buff1[i + 4]; p24 = buff2[i + 4]; p34 = buff3[i + 4];
-
-        p40 = buff4[i];     p41 = buff4[i + 1]; p42 = buff4[i + 2];
-        p43 = buff4[i + 3]; p44 = buff4[i + 4];
-
-        buff5[i + dx_l] = (FTYPE)sp[0];
-
-        buffo[i] = D2I(p00 * k[0] + p01 * k[1] + p02 * k[2] + p03 * k[3] + p04 * k[4] +
-                       p10 * k[5] + p11 * k[6] + p12 * k[7] + p13 * k[8] + p14 * k[9] +
-                       p20 * k[10] + p21 * k[11] + p22 * k[12] + p23 * k[13] + p24 * k[14] +
-                       p30 * k[15] + p31 * k[16] + p32 * k[17] + p33 * k[18] + p34 * k[19] +
-                       p40 * k[20] + p41 * k[21] + p42 * k[22] + p43 * k[23] + p44 * k[24]);
-
-        dp[0] = FROM_S32(buffo[i]);
-
-        sp += chan1;
-        dp += chan1;
-      }
-
-      for (; i < swid; i++) {
-        buff5[i + dx_l] = (FTYPE)sp[0];
-        sp += chan1;
-      }
-
-      for (i = 0; i < dx_l; i++) buff5[i] = buff5[dx_l];
-      for (i = 0; i < dx_r; i++) buff5[swid + dx_l + i] = buff5[swid + dx_l - 1];
-
-      /* next line */
-
-      if (j < hgt - dy_b - 2) sl += sll;
-      dl += dll;
-
-      buffT = buff0;
-      buff0 = buff1;
-      buff1 = buff2;
-      buff2 = buff3;
-      buff3 = buff4;
-      buff4 = buff5;
-      buff5 = buffT;
-    }
-  }
-
-  if (pbuff != buff) mlib_free(pbuff);
-
-  return MLIB_SUCCESS;
-}
-
-/***************************************************************/
-#ifndef __sparc /* for x86, using integer multiplies is faster */
-
-mlib_status CONV_FUNC_I(5x5)
-{
-  mlib_s32 buff[BUFF_LINE];
-  mlib_s32 *buffd;
-  mlib_s32 k[KSIZE*KSIZE];
-  mlib_s32 shift1, shift2;
-  mlib_s32 k0, k1, k2, k3, k4, k5, k6, k7, k8, k9;
-  mlib_s32 p00, p01, p02, p03, p04, p05,
-           p10, p11, p12, p13, p14, p15;
-  DTYPE    *adr_src, *sl, *sp0, *sp1, *sp2, *sp3, *sp4;
-  DTYPE    *sp_1, *sp_2, *sp_3, *sp_4;
-  DTYPE    *adr_dst, *dl, *dp;
-  mlib_s32 *pbuff = buff;
-  mlib_s32 wid, hgt, sll, dll;
-  mlib_s32 nchannel, chan1, chan2, chan4;
-  mlib_s32 delta_chan1, delta_chan2, delta_chan3;
-  mlib_s32 i, j, c;
-
-#if IMG_TYPE != 1
-  shift1 = 16;
-#else
-  shift1 = 8;
-#endif /* IMG_TYPE != 1 */
-
-  shift2 = scalef_expon - shift1;
-
-  for (j = 0; j < KSIZE*KSIZE; j++) k[j] = kern[j] >> shift1;
-
-  GET_SRC_DST_PARAMETERS(DTYPE);
-
-  if (wid > BUFF_LINE) {
-    pbuff = mlib_malloc(sizeof(mlib_s32)*wid);
-
-    if (pbuff == NULL) return MLIB_FAILURE;
-  }
-
-  buffd = pbuff;
-
-  chan1 = nchannel;
-  chan2 = chan1 + chan1;
-
-  if ((1 > dx_l) && (1 < wid + KSIZE1 - dx_r)) delta_chan1 = chan1;
-  else delta_chan1 = 0;
-
-  if ((2 > dx_l) && (2 < wid + KSIZE1 - dx_r)) delta_chan2 = delta_chan1 + chan1;
-  else delta_chan2 = delta_chan1;
-
-  if ((3 > dx_l) && (3 < wid + KSIZE1 - dx_r)) delta_chan3 = delta_chan2 + chan1;
-  else delta_chan3 = delta_chan2;
-
-  chan4 = chan1 + delta_chan3;
-
-  for (c = 0; c < chan1; c++) {
-    if (!(cmask & (1 << (chan1 - 1 - c)))) continue;
-
-    sl = adr_src + c;
-    dl = adr_dst + c;
-
-    sp_1 = sl;
-
-    if ((1 > dy_t) && (1 < hgt + KSIZE1 - dy_b)) sl += sll;
-    sp_2 = sl;
-
-    if ((2 > dy_t) && (2 < hgt + KSIZE1 - dy_b)) sl += sll;
-    sp_3 = sl;
-
-    if ((3 > dy_t) && (3 < hgt + KSIZE1 - dy_b)) sl += sll;
-    sp_4 = sl;
-
-    if ((hgt - dy_b) > 0) sl += sll;
-
-    for (j = 0; j < hgt; j++) {
-      mlib_s32 pix0, pix1;
-
-      dp  = dl;
-      sp0 = sp_1;
-      sp_1 = sp_2;
-      sp_2 = sp_3;
-      sp_3 = sp_4;
-      sp_4 = sl;
-
-      sp1 = sp_1;
-      sp2 = sp_2;
-      sp3 = sp_3;
-      sp4 = sp_4;
-
-      /*
-       *  First loop
-       */
-
-      k0 = k[0]; k1 = k[1]; k2 = k[2]; k3 = k[3]; k4 = k[4];
-      k5 = k[5]; k6 = k[6]; k7 = k[7]; k8 = k[8]; k9 = k[9];
-
-      p02 = sp0[0];           p12 = sp1[0];
-      p03 = sp0[delta_chan1]; p13 = sp1[delta_chan1];
-      p04 = sp0[delta_chan2]; p14 = sp1[delta_chan2];
-      p05 = sp0[delta_chan3]; p15 = sp1[delta_chan3];
-
-      sp0 += chan4;
-      sp1 += chan4;
-
-#ifdef __SUNPRO_C
-#pragma pipeloop(0)
-#endif /* __SUNPRO_C */
-      for (i = 0; i <= (wid - dx_r - 2); i += 2) {
-        p00 = p02; p10 = p12;
-        p01 = p03; p11 = p13;
-        p02 = p04; p12 = p14;
-        p03 = p05; p13 = p15;
-
-        p04 = sp0[0];     p14 = sp1[0];
-        p05 = sp0[chan1]; p15 = sp1[chan1];
-
-        buffd[i    ] = (p00 * k0 + p01 * k1 + p02 * k2 + p03 * k3 + p04 * k4 +
-                        p10 * k5 + p11 * k6 + p12 * k7 + p13 * k8 + p14 * k9);
-        buffd[i + 1] = (p01 * k0 + p02 * k1 + p03 * k2 + p04 * k3 + p05 * k4 +
-                        p11 * k5 + p12 * k6 + p13 * k7 + p14 * k8 + p15 * k9);
-
-        sp0 += chan2;
-        sp1 += chan2;
-      }
-
-      p01 = p02; p02 = p03; p03 = p04; p04 = p05;
-      p11 = p12; p12 = p13; p13 = p14; p14 = p15;
-
-      for (; i < wid - dx_r; i++) {
-        p00 = p01; p10 = p11;
-        p01 = p02; p11 = p12;
-        p02 = p03; p12 = p13;
-        p03 = p04; p13 = p14;
-
-        p04 = sp0[0];     p14 = sp1[0];
-
-        buffd[i] = (p00 * k0 + p01 * k1 + p02 * k2 + p03 * k3 + p04 * k4 +
-                    p10 * k5 + p11 * k6 + p12 * k7 + p13 * k8 + p14 * k9);
-
-        sp0 += chan1;
-        sp1 += chan1;
-      }
-
-      sp0 -= chan1;
-      sp1 -= chan1;
-
-      for (; i < wid; i++) {
-        p00 = p01; p10 = p11;
-        p01 = p02; p11 = p12;
-        p02 = p03; p12 = p13;
-        p03 = p04; p13 = p14;
-
-        p04 = sp0[0];     p14 = sp1[0];
-
-        buffd[i] = (p00 * k0 + p01 * k1 + p02 * k2 + p03 * k3 + p04 * k4 +
-                    p10 * k5 + p11 * k6 + p12 * k7 + p13 * k8 + p14 * k9);
-      }
-
-      /*
-       *  Second loop
-       */
-
-      k0 = k[10]; k1 = k[11]; k2 = k[12]; k3 = k[13]; k4 = k[14];
-      k5 = k[15]; k6 = k[16]; k7 = k[17]; k8 = k[18]; k9 = k[19];
-
-      p02 = sp2[0];           p12 = sp3[0];
-      p03 = sp2[delta_chan1]; p13 = sp3[delta_chan1];
-      p04 = sp2[delta_chan2]; p14 = sp3[delta_chan2];
-      p05 = sp2[delta_chan3]; p15 = sp3[delta_chan3];
-
-      sp2 += chan4;
-      sp3 += chan4;
-
-#ifdef __SUNPRO_C
-#pragma pipeloop(0)
-#endif /* __SUNPRO_C */
-      for (i = 0; i <= (wid - dx_r - 2); i += 2) {
-        p00 = p02; p10 = p12;
-        p01 = p03; p11 = p13;
-        p02 = p04; p12 = p14;
-        p03 = p05; p13 = p15;
-
-        p04 = sp2[0];     p14 = sp3[0];
-        p05 = sp2[chan1]; p15 = sp3[chan1];
-
-        buffd[i    ] += (p00 * k0 + p01 * k1 + p02 * k2 + p03 * k3 + p04 * k4 +
-                         p10 * k5 + p11 * k6 + p12 * k7 + p13 * k8 + p14 * k9);
-        buffd[i + 1] += (p01 * k0 + p02 * k1 + p03 * k2 + p04 * k3 + p05 * k4 +
-                         p11 * k5 + p12 * k6 + p13 * k7 + p14 * k8 + p15 * k9);
-
-        sp2 += chan2;
-        sp3 += chan2;
-      }
-
-      p01 = p02; p02 = p03; p03 = p04; p04 = p05;
-      p11 = p12; p12 = p13; p13 = p14; p14 = p15;
-
-      for (; i < wid - dx_r; i++) {
-        p00 = p01; p10 = p11;
-        p01 = p02; p11 = p12;
-        p02 = p03; p12 = p13;
-        p03 = p04; p13 = p14;
-
-        p04 = sp2[0];     p14 = sp3[0];
-
-        buffd[i] += (p00 * k0 + p01 * k1 + p02 * k2 + p03 * k3 + p04 * k4 +
-                     p10 * k5 + p11 * k6 + p12 * k7 + p13 * k8 + p14 * k9);
-
-        sp2 += chan1;
-        sp3 += chan1;
-      }
-
-      sp2 -= chan1;
-      sp3 -= chan1;
-
-      for (; i < wid; i++) {
-        p00 = p01; p10 = p11;
-        p01 = p02; p11 = p12;
-        p02 = p03; p12 = p13;
-        p03 = p04; p13 = p14;
-
-        p04 = sp2[0];     p14 = sp3[0];
-
-        buffd[i] += (p00 * k0 + p01 * k1 + p02 * k2 + p03 * k3 + p04 * k4 +
-                     p10 * k5 + p11 * k6 + p12 * k7 + p13 * k8 + p14 * k9);
-      }
-
-      /*
-       *  3 loop
-       */
-
-      k0 = k[20]; k1 = k[21]; k2 = k[22]; k3 = k[23]; k4 = k[24];
-
-      p02 = sp4[0];
-      p03 = sp4[delta_chan1];
-      p04 = sp4[delta_chan2];
-      p05 = sp4[delta_chan3];
-
-      sp4 += chan4;
-
-#ifdef __SUNPRO_C
-#pragma pipeloop(0)
-#endif /* __SUNPRO_C */
-      for (i = 0; i <= (wid - dx_r - 2); i += 2) {
-        p00 = p02; p01 = p03; p02 = p04; p03 = p05;
-
-        p04 = sp4[0]; p05 = sp4[chan1];
-
-        pix0 = (buffd[i    ] + p00 * k0 + p01 * k1 + p02 * k2 +
-                p03 * k3 + p04 * k4) >> shift2;
-        pix1 = (buffd[i + 1] + p01 * k0 + p02 * k1 + p03 * k2 +
-                p04 * k3 + p05 * k4) >> shift2;
-
-        CLAMP_STORE(dp[0],     pix0);
-        CLAMP_STORE(dp[chan1], pix1);
-
-        dp  += chan2;
-        sp4 += chan2;
-      }
-
-      p01 = p02; p02 = p03; p03 = p04; p04 = p05;
-
-      for (; i < wid - dx_r; i++) {
-        p00 = p01; p01 = p02; p02 = p03; p03 = p04;
-
-        p04 = sp4[0];
-
-        pix0 = (buffd[i    ] + p00 * k0 + p01 * k1 + p02 * k2 +
-                p03 * k3 + p04 * k4) >> shift2;
-        CLAMP_STORE(dp[0],     pix0);
-
-        dp  += chan1;
-        sp4 += chan1;
-      }
-
-      sp4 -= chan1;
-
-      for (; i < wid; i++) {
-        p00 = p01; p01 = p02; p02 = p03; p03 = p04;
-
-        p04 = sp4[0];
-
-        pix0 = (buffd[i    ] + p00 * k0 + p01 * k1 + p02 * k2 +
-                p03 * k3 + p04 * k4) >> shift2;
-        CLAMP_STORE(dp[0],     pix0);
-
-        dp  += chan1;
-      }
-
-      /* next line */
-
-      if (j < hgt - dy_b - 1) sl += sll;
-      dl += dll;
-    }
-  }
-
-  if (pbuff != buff) mlib_free(pbuff);
-
-  return MLIB_SUCCESS;
-}
-
-#endif /* __sparc ( for x86, using integer multiplies is faster ) */
-
-/***************************************************************/
-#if IMG_TYPE == 1
-
-#undef  KSIZE
-#define KSIZE 7
-
-mlib_status CONV_FUNC(7x7)
-{
-  FTYPE    buff[(KSIZE + 3)*BUFF_LINE], *buffs[2*(KSIZE + 1)], *buffd;
-  FTYPE    k[KSIZE*KSIZE];
-  mlib_s32 l, m, buff_ind;
-  mlib_s32 d0, d1;
-  FTYPE    k0, k1, k2, k3, k4, k5, k6;
-  FTYPE    p0, p1, p2, p3, p4, p5, p6, p7;
-  DTYPE *sl2, *sl3, *sl4, *sl5, *sl6;
-  DEF_VARS(DTYPE);
-  LOAD_KERNEL(KSIZE*KSIZE);
-  GET_SRC_DST_PARAMETERS(DTYPE);
-
-  swid = wid + KSIZE1;
-
-  if (wid > BUFF_LINE) {
-    pbuff = mlib_malloc((KSIZE + 3)*sizeof(FTYPE   )*wid);
-
-    if (pbuff == NULL) return MLIB_FAILURE;
-  }
-
-  for (l = 0; l < KSIZE + 1; l++) buffs[l] = pbuff + l*swid;
-  for (l = 0; l < KSIZE + 1; l++) buffs[l + (KSIZE + 1)] = buffs[l];
-  buffd = buffs[KSIZE] + swid;
-  buffo = (mlib_s32*)(buffd + swid);
-  buffi = buffo + (swid &~ 1);
-
-  swid -= (dx_l + dx_r);
-
-  chan1 = nchannel;
-  chan2 = chan1 + chan1;
-
-  for (c = 0; c < nchannel; c++) {
-    if (!(cmask & (1 << (nchannel - 1 - c)))) continue;
-
-    sl = adr_src + c;
-    dl = adr_dst + c;
-
-    if ((1 > dy_t) && (1 < hgt + KSIZE1 - dy_b)) sl1 = sl + sll;
-    else sl1 = sl;
-
-    if ((2 > dy_t) && (2 < hgt + KSIZE1 - dy_b)) sl2 = sl1 + sll;
-    else sl2 = sl1;
-
-    if ((3 > dy_t) && (3 < hgt + KSIZE1 - dy_b)) sl3 = sl2 + sll;
-    else sl3 = sl2;
-
-    if ((4 > dy_t) && (4 < hgt + KSIZE1 - dy_b)) sl4 = sl3 + sll;
-    else sl4 = sl3;
-
-    if ((5 > dy_t) && (5 < hgt + KSIZE1 - dy_b)) sl5 = sl4 + sll;
-    else sl5 = sl4;
-
-    if ((hgt - dy_b) > 0) sl6 = sl5 + sll;
-    else sl6 = sl5;
-
-    for (i = 0; i < dx_l; i++) {
-      buffs[0][i] = (FTYPE)sl[0];
-      buffs[1][i] = (FTYPE)sl1[0];
-      buffs[2][i] = (FTYPE)sl2[0];
-      buffs[3][i] = (FTYPE)sl3[0];
-      buffs[4][i] = (FTYPE)sl4[0];
-      buffs[5][i] = (FTYPE)sl5[0];
-      buffs[6][i] = (FTYPE)sl6[0];
-    }
-
-#ifdef __SUNPRO_C
-#pragma pipeloop(0)
-#endif /* __SUNPRO_C */
-    for (i = 0; i < swid; i++) {
-      buffs[0][i + dx_l] = (FTYPE)sl[i*chan1];
-      buffs[1][i + dx_l] = (FTYPE)sl1[i*chan1];
-      buffs[2][i + dx_l] = (FTYPE)sl2[i*chan1];
-      buffs[3][i + dx_l] = (FTYPE)sl3[i*chan1];
-      buffs[4][i + dx_l] = (FTYPE)sl4[i*chan1];
-      buffs[5][i + dx_l] = (FTYPE)sl5[i*chan1];
-      buffs[6][i + dx_l] = (FTYPE)sl6[i*chan1];
-    }
-
-    for (i = 0; i < dx_r; i++) {
-      buffs[0][swid + dx_l + i] = buffs[0][swid + dx_l - 1];
-      buffs[1][swid + dx_l + i] = buffs[1][swid + dx_l - 1];
-      buffs[2][swid + dx_l + i] = buffs[2][swid + dx_l - 1];
-      buffs[3][swid + dx_l + i] = buffs[3][swid + dx_l - 1];
-      buffs[4][swid + dx_l + i] = buffs[4][swid + dx_l - 1];
-      buffs[5][swid + dx_l + i] = buffs[5][swid + dx_l - 1];
-      buffs[6][swid + dx_l + i] = buffs[6][swid + dx_l - 1];
-    }
-
-    buff_ind = 0;
-
-#ifdef __SUNPRO_C
-#pragma pipeloop(0)
-#endif /* __SUNPRO_C */
-    for (i = 0; i < wid; i++) buffd[i] = 0.0;
-
-    if ((hgt - dy_b) > 1) sl = sl6 + sll;
-    else sl = sl6;
-
-    for (j = 0; j < hgt; j++) {
-      FTYPE    **buffc = buffs + buff_ind;
-      FTYPE    *buffn = buffc[KSIZE];
-      FTYPE    *pk = k;
-
-      for (l = 0; l < KSIZE; l++) {
-        FTYPE    *buff = buffc[l];
-        d64_2x32 dd;
-
-        sp = sl;
-        dp = dl;
-
-        p2 = buff[0]; p3 = buff[1]; p4 = buff[2];
-        p5 = buff[3]; p6 = buff[4]; p7 = buff[5];
-
-        k0 = *pk++; k1 = *pk++; k2 = *pk++; k3 = *pk++;
-        k4 = *pk++; k5 = *pk++; k6 = *pk++;
-
-        if (l < (KSIZE - 1)) {
-#ifdef __SUNPRO_C
-#pragma pipeloop(0)
-#endif /* __SUNPRO_C */
-          for (i = 0; i <= (wid - 2); i += 2) {
-            p0 = p2; p1 = p3; p2 = p4; p3 = p5; p4 = p6; p5 = p7;
-
-            p6 = buff[i + 6]; p7 = buff[i + 7];
-
-            buffd[i    ] += p0*k0 + p1*k1 + p2*k2 + p3*k3 + p4*k4 + p5*k5 + p6*k6;
-            buffd[i + 1] += p1*k0 + p2*k1 + p3*k2 + p4*k3 + p5*k4 + p6*k5 + p7*k6;
-          }
-
-        } else {
-#ifdef __SUNPRO_C
-#pragma pipeloop(0)
-#endif /* __SUNPRO_C */
-          for (i = 0; i <= (wid - 2); i += 2) {
-            p0 = p2; p1 = p3; p2 = p4; p3 = p5; p4 = p6; p5 = p7;
-
-            p6 = buff[i + 6]; p7 = buff[i + 7];
-
-            LOAD_BUFF(buffi);
-
-            dd.d64 = *(FTYPE   *)(buffi + i);
-            buffn[i + dx_l    ] = (FTYPE)dd.i32s.i0;
-            buffn[i + dx_l + 1] = (FTYPE)dd.i32s.i1;
-
-            d0 = D2I(p0*k0 + p1*k1 + p2*k2 + p3*k3 + p4*k4 + p5*k5 + p6*k6 + buffd[i    ]);
-            d1 = D2I(p1*k0 + p2*k1 + p3*k2 + p4*k3 + p5*k4 + p6*k5 + p7*k6 + buffd[i + 1]);
-
-            dp[0    ] = FROM_S32(d0);
-            dp[chan1] = FROM_S32(d1);
-
-            buffd[i    ] = 0.0;
-            buffd[i + 1] = 0.0;
-
-            sp += chan2;
-            dp += chan2;
-          }
-        }
-      }
-
-      /* last pixels */
-      for (; i < wid; i++) {
-        FTYPE    *pk = k, s = 0;
-        mlib_s32 d0;
-
-        for (l = 0; l < KSIZE; l++) {
-          FTYPE    *buff = buffc[l] + i;
-
-          for (m = 0; m < KSIZE; m++) s += buff[m] * (*pk++);
-        }
-
-        d0 = D2I(s);
-        dp[0] = FROM_S32(d0);
-
-        buffn[i + dx_l] = (FTYPE)sp[0];
-
-        sp += chan1;
-        dp += chan1;
-      }
-
-      for (; i < swid; i++) {
-        buffn[i + dx_l] = (FTYPE)sp[0];
-        sp += chan1;
-      }
-
-      for (i = 0; i < dx_l; i++) buffn[i] = buffn[dx_l];
-      for (i = 0; i < dx_r; i++) buffn[swid + dx_l + i] = buffn[swid + dx_l - 1];
-
-      /* next line */
-
-      if (j < hgt - dy_b - 2) sl += sll;
-      dl += dll;
-
-      buff_ind++;
-
-      if (buff_ind >= KSIZE + 1) buff_ind = 0;
-    }
-  }
-
-  if (pbuff != buff) mlib_free(pbuff);
-
-  return MLIB_SUCCESS;
-}
-
-#endif /* IMG_TYPE == 1 */
-
-/***************************************************************/
 #define MAX_KER   7
 #define MAX_N    15
 #define BUFF_SIZE   1600
--- a/jdk/src/java.desktop/share/native/libmlib_image/mlib_ImageConv_16nw.c	Thu May 19 17:48:02 2016 +0000
+++ b/jdk/src/java.desktop/share/native/libmlib_image/mlib_ImageConv_16nw.c	Thu May 19 19:46:20 2016 +0000
@@ -144,9 +144,6 @@
 } d64_2x32;
 
 /***************************************************************/
-#define BUFF_LINE 256
-
-/***************************************************************/
 #define DEF_VARS(type)                                          \
   type     *adr_src, *sl, *sp = NULL;                           \
   type     *adr_dst, *dl, *dp = NULL;                           \
@@ -156,39 +153,6 @@
   mlib_s32 i, j, c
 
 /***************************************************************/
-#define LOAD_KERNEL3()                                                   \
-  FTYPE    scalef = DSCALE;                                              \
-  FTYPE    k0, k1, k2, k3, k4, k5, k6, k7, k8;                           \
-  FTYPE    p00, p01, p02, p03,                                           \
-           p10, p11, p12, p13,                                           \
-           p20, p21, p22, p23;                                           \
-                                                                         \
-  while (scalef_expon > 30) {                                            \
-    scalef /= (1 << 30);                                                 \
-    scalef_expon -= 30;                                                  \
-  }                                                                      \
-                                                                         \
-  scalef /= (1 << scalef_expon);                                         \
-                                                                         \
-  /* keep kernel in regs */                                              \
-  k0 = scalef * kern[0];  k1 = scalef * kern[1];  k2 = scalef * kern[2]; \
-  k3 = scalef * kern[3];  k4 = scalef * kern[4];  k5 = scalef * kern[5]; \
-  k6 = scalef * kern[6];  k7 = scalef * kern[7];  k8 = scalef * kern[8]
-
-/***************************************************************/
-#define LOAD_KERNEL(SIZE)                                       \
-  FTYPE    scalef = DSCALE;                                     \
-                                                                \
-  while (scalef_expon > 30) {                                   \
-    scalef /= (1 << 30);                                        \
-    scalef_expon -= 30;                                         \
-  }                                                             \
-                                                                \
-  scalef /= (1 << scalef_expon);                                \
-                                                                \
-  for (j = 0; j < SIZE; j++) k[j] = scalef * kern[j]
-
-/***************************************************************/
 #define GET_SRC_DST_PARAMETERS(type)                            \
   hgt = mlib_ImageGetHeight(src);                               \
   wid = mlib_ImageGetWidth(src);                                \
@@ -246,1162 +210,6 @@
 #endif /* __sparc */
 
 /***************************************************************/
-#define KSIZE  3
-
-mlib_status CONV_FUNC(3x3)(mlib_image       *dst,
-                           const mlib_image *src,
-                           const mlib_s32   *kern,
-                           mlib_s32         scalef_expon,
-                           mlib_s32         cmask)
-{
-  FTYPE    buff[(KSIZE + 2)*BUFF_LINE], *buff0, *buff1, *buff2, *buff3, *buffT;
-  DEF_VARS(DTYPE);
-  DTYPE *sl1;
-  mlib_s32 chan2;
-  mlib_s32 *buffo, *buffi;
-  DTYPE *sl2;
-#ifndef __sparc
-  mlib_s32 d0, d1;
-#endif /* __sparc */
-  LOAD_KERNEL3();
-  GET_SRC_DST_PARAMETERS(DTYPE);
-
-  if (wid > BUFF_LINE) {
-    pbuff = mlib_malloc((KSIZE + 2)*sizeof(FTYPE)*wid);
-
-    if (pbuff == NULL) return MLIB_FAILURE;
-  }
-
-  buff0 = pbuff;
-  buff1 = buff0 + wid;
-  buff2 = buff1 + wid;
-  buff3 = buff2 + wid;
-  buffo = (mlib_s32*)(buff3 + wid);
-  buffi = buffo + (wid &~ 1);
-
-  chan1 = nchannel;
-  chan2 = chan1 + chan1;
-
-  wid -= (KSIZE - 1);
-  hgt -= (KSIZE - 1);
-
-  adr_dst += ((KSIZE - 1)/2)*(dll + chan1);
-
-  for (c = 0; c < nchannel; c++) {
-    if (!(cmask & (1 << (nchannel - 1 - c)))) continue;
-
-    sl = adr_src + c;
-    dl = adr_dst + c;
-
-    sl1 = sl  + sll;
-    sl2 = sl1 + sll;
-#ifdef __SUNPRO_C
-#pragma pipeloop(0)
-#endif /* __SUNPRO_C */
-    for (i = 0; i < wid + (KSIZE - 1); i++) {
-      buff0[i] = (FTYPE)sl[i*chan1];
-      buff1[i] = (FTYPE)sl1[i*chan1];
-      buff2[i] = (FTYPE)sl2[i*chan1];
-    }
-
-    sl += KSIZE*sll;
-
-    for (j = 0; j < hgt; j++) {
-      FTYPE    s0, s1;
-
-      p02 = buff0[0];
-      p12 = buff1[0];
-      p22 = buff2[0];
-
-      p03 = buff0[1];
-      p13 = buff1[1];
-      p23 = buff2[1];
-
-      s0 = p02 * k0 + p03 * k1 + p12 * k3 + p13 * k4 + p22 * k6 + p23 * k7;
-      s1 = p03 * k0 + p13 * k3 + p23 * k6;
-
-      sp = sl;
-      dp = dl;
-
-#ifdef __SUNPRO_C
-#pragma pipeloop(0)
-#endif /* __SUNPRO_C */
-      for (i = 0; i <= (wid - 2); i += 2) {
-#ifdef __sparc
-#ifdef _NO_LONGLONG
-        mlib_s32 o64_1, o64_2;
-#else /* _NO_LONGLONG */
-        mlib_s64 o64;
-#endif /* _NO_LONGLONG */
-#endif /* __sparc */
-        d64_2x32 dd;
-
-        p02 = buff0[i + 2]; p12 = buff1[i + 2]; p22 = buff2[i + 2];
-        p03 = buff0[i + 3]; p13 = buff1[i + 3]; p23 = buff2[i + 3];
-
-        LOAD_BUFF(buffi);
-
-        dd.d64 = *(FTYPE   *)(buffi + i);
-        buff3[i    ] = (FTYPE)dd.i32s.i0;
-        buff3[i + 1] = (FTYPE)dd.i32s.i1;
-
-#ifndef __sparc
-        d0 = D2I(s0 + p02 * k2 + p12 * k5 + p22 * k8);
-        d1 = D2I(s1 + p02 * k1 + p03 * k2 + p12 * k4 + p13 * k5 + p22 * k7 + p23 * k8);
-
-        s0 = p02 * k0 + p03 * k1 + p12 * k3 + p13 * k4 + p22 * k6 + p23 * k7;
-        s1 = p03 * k0 + p13 * k3 + p23 * k6;
-
-        dp[0    ] = FROM_S32(d0);
-        dp[chan1] = FROM_S32(d1);
-
-#else /* __sparc */
-
-        dd.i32s.i0 = D2I(s0 + p02 * k2 + p12 * k5 + p22 * k8);
-        dd.i32s.i1 = D2I(s1 + p02 * k1 + p03 * k2 + p12 * k4 + p13 * k5 + p22 * k7 + p23 * k8);
-        *(FTYPE   *)(buffo + i) = dd.d64;
-
-        s0 = p02 * k0 + p03 * k1 + p12 * k3 + p13 * k4 + p22 * k6 + p23 * k7;
-        s1 = p03 * k0 + p13 * k3 + p23 * k6;
-
-#ifdef _NO_LONGLONG
-
-        o64_1 = buffo[i];
-        o64_2 = buffo[i+1];
-#if IMG_TYPE != 1
-        STORE2(FROM_S32(o64_1), FROM_S32(o64_2));
-#else
-        STORE2(o64_1 >> 24, o64_2 >> 24);
-#endif /* IMG_TYPE != 1 */
-
-#else /* _NO_LONGLONG */
-
-        o64 = *(mlib_s64*)(buffo + i);
-#if IMG_TYPE != 1
-        STORE2(FROM_S32(o64 >> 32), FROM_S32(o64));
-#else
-        STORE2(o64 >> 56, o64 >> 24);
-#endif /* IMG_TYPE != 1 */
-#endif /* _NO_LONGLONG */
-#endif /* __sparc */
-
-        sp += chan2;
-        dp += chan2;
-      }
-
-      for (; i < wid; i++) {
-        p00 = buff0[i];     p10 = buff1[i];     p20 = buff2[i];
-        p01 = buff0[i + 1]; p11 = buff1[i + 1]; p21 = buff2[i + 1];
-        p02 = buff0[i + 2]; p12 = buff1[i + 2]; p22 = buff2[i + 2];
-
-        buffi[i] = (mlib_s32)sp[0];
-        buff3[i] = (FTYPE)buffi[i];
-
-#ifndef __sparc
-
-        d0 = D2I(p00 * k0 + p01 * k1 + p02 * k2 + p10 * k3 + p11 * k4 +
-                 p12 * k5 + p20 * k6 + p21 * k7 + p22 * k8);
-
-        dp[0] = FROM_S32(d0);
-
-#else  /* __sparc */
-
-        buffo[i] = D2I(p00 * k0 + p01 * k1 + p02 * k2 + p10 * k3 + p11 * k4 +
-                       p12 * k5 + p20 * k6 + p21 * k7 + p22 * k8);
-#if IMG_TYPE != 1
-        dp[0] = FROM_S32(buffo[i]);
-#else
-        dp[0] = buffo[i] >> 24;
-#endif /* IMG_TYPE != 1 */
-#endif /* __sparc */
-
-        sp += chan1;
-        dp += chan1;
-      }
-
-      buffi[wid] = (mlib_s32)sp[0];
-      buff3[wid] = (FTYPE)buffi[wid];
-      buffi[wid + 1] = (mlib_s32)sp[chan1];
-      buff3[wid + 1] = (FTYPE)buffi[wid + 1];
-
-      sl += sll;
-      dl += dll;
-
-      buffT = buff0;
-      buff0 = buff1;
-      buff1 = buff2;
-      buff2 = buff3;
-      buff3 = buffT;
-    }
-  }
-
-#ifdef __sparc
-#if IMG_TYPE == 1
-  {
-    mlib_s32 amask = (1 << nchannel) - 1;
-
-    if ((cmask & amask) != amask) {
-      mlib_ImageXor80(adr_dst, wid, hgt, dll, nchannel, cmask);
-    } else {
-      mlib_ImageXor80_aa(adr_dst, wid*nchannel, hgt, dll);
-    }
-  }
-
-#endif /* IMG_TYPE == 1 */
-#endif /* __sparc */
-
-  if (pbuff != buff) mlib_free(pbuff);
-
-  return MLIB_SUCCESS;
-}
-
-/***************************************************************/
-#ifndef __sparc /* for x86, using integer multiplies is faster */
-
-mlib_status CONV_FUNC_I(3x3)(mlib_image       *dst,
-                             const mlib_image *src,
-                             const mlib_s32   *kern,
-                             mlib_s32         scalef_expon,
-                             mlib_s32         cmask)
-{
-  DTYPE    *adr_src, *sl, *sp0, *sp1, *sp2;
-  DTYPE    *adr_dst, *dl, *dp;
-  mlib_s32 wid, hgt, sll, dll;
-  mlib_s32 nchannel, chan1, chan2;
-  mlib_s32 i, j, c;
-  mlib_s32 shift1, shift2;
-  mlib_s32 k0, k1, k2, k3, k4, k5, k6, k7, k8;
-  mlib_s32 p02, p03,
-           p12, p13,
-           p22, p23;
-
-#if IMG_TYPE != 1
-  shift1 = 16;
-#else
-  shift1 = 8;
-#endif /* IMG_TYPE != 1 */
-
-  shift2 = scalef_expon - shift1;
-
-  /* keep kernel in regs */
-  k0 = kern[0] >> shift1;  k1 = kern[1] >> shift1;  k2 = kern[2] >> shift1;
-  k3 = kern[3] >> shift1;  k4 = kern[4] >> shift1;  k5 = kern[5] >> shift1;
-  k6 = kern[6] >> shift1;  k7 = kern[7] >> shift1;  k8 = kern[8] >> shift1;
-
-  GET_SRC_DST_PARAMETERS(DTYPE);
-
-  chan1 = nchannel;
-  chan2 = chan1 + chan1;
-
-  wid -= (KSIZE - 1);
-  hgt -= (KSIZE - 1);
-
-  adr_dst += ((KSIZE - 1)/2)*(dll + chan1);
-
-  for (c = 0; c < chan1; c++) {
-    if (!(cmask & (1 << (chan1 - 1 - c)))) continue;
-
-    sl = adr_src + c;
-    dl = adr_dst + c;
-
-    for (j = 0; j < hgt; j++) {
-      mlib_s32 s0, s1;
-      mlib_s32 pix0, pix1;
-
-      dp  = dl;
-      sp0 = sl;
-      sp1 = sp0 + sll;
-      sp2 = sp1 + sll;
-
-      p02 = sp0[0];
-      p12 = sp1[0];
-      p22 = sp2[0];
-
-      p03 = sp0[chan1];
-      p13 = sp1[chan1];
-      p23 = sp2[chan1];
-
-      s0 = p02 * k0 + p03 * k1 + p12 * k3 + p13 * k4 + p22 * k6 + p23 * k7;
-      s1 = p03 * k0 + p13 * k3 + p23 * k6;
-
-      sp0 += chan2;
-      sp1 += chan2;
-      sp2 += chan2;
-
-#ifdef __SUNPRO_C
-#pragma pipeloop(0)
-#endif /* __SUNPRO_C */
-      for (i = 0; i <= (wid - 2); i += 2) {
-        p02 = sp0[0];     p12 = sp1[0];     p22 = sp2[0];
-        p03 = sp0[chan1]; p13 = sp1[chan1]; p23 = sp2[chan1];
-
-        pix0 = (s0 + p02 * k2 + p12 * k5 + p22 * k8) >> shift2;
-        pix1 = (s1 + p02 * k1 + p03 * k2 + p12 * k4 +
-                p13 * k5 + p22 * k7 + p23 * k8) >> shift2;
-
-        CLAMP_STORE(dp[0],     pix0);
-        CLAMP_STORE(dp[chan1], pix1);
-
-        s0 = p02 * k0 + p03 * k1 + p12 * k3 + p13 * k4 + p22 * k6 + p23 * k7;
-        s1 = p03 * k0 + p13 * k3 + p23 * k6;
-
-        sp0 += chan2;
-        sp1 += chan2;
-        sp2 += chan2;
-        dp += chan2;
-      }
-
-      if (wid & 1) {
-        p02 = sp0[0]; p12 = sp1[0]; p22 = sp2[0];
-        pix0 = (s0 + p02 * k2 + p12 * k5 + p22 * k8) >> shift2;
-        CLAMP_STORE(dp[0], pix0);
-      }
-
-      sl += sll;
-      dl += dll;
-    }
-  }
-
-  return MLIB_SUCCESS;
-}
-
-#endif /* __sparc ( for x86, using integer multiplies is faster ) */
-
-/***************************************************************/
-#undef  KSIZE
-#define KSIZE 4
-
-mlib_status CONV_FUNC(4x4)(mlib_image       *dst,
-                           const mlib_image *src,
-                           const mlib_s32   *kern,
-                           mlib_s32         scalef_expon,
-                           mlib_s32         cmask)
-{
-  FTYPE    buff[(KSIZE + 3)*BUFF_LINE];
-  FTYPE    *buff0, *buff1, *buff2, *buff3, *buff4, *buffd, *buffT;
-  FTYPE    k[KSIZE*KSIZE];
-  mlib_s32 d0, d1;
-  FTYPE    k0, k1, k2, k3, k4, k5, k6, k7;
-  FTYPE    p00, p01, p02, p03, p04,
-           p10, p11, p12, p13, p14,
-           p20, p21, p22, p23,
-           p30, p31, p32, p33;
-  DEF_VARS(DTYPE);
-  DTYPE *sl1;
-  mlib_s32 chan2;
-  mlib_s32 *buffo, *buffi;
-  DTYPE *sl2, *sl3;
-  LOAD_KERNEL(KSIZE*KSIZE);
-  GET_SRC_DST_PARAMETERS(DTYPE);
-
-  if (wid > BUFF_LINE) {
-    pbuff = mlib_malloc((KSIZE + 3)*sizeof(FTYPE)*wid);
-
-    if (pbuff == NULL) return MLIB_FAILURE;
-  }
-
-  buff0 = pbuff;
-  buff1 = buff0 + wid;
-  buff2 = buff1 + wid;
-  buff3 = buff2 + wid;
-  buff4 = buff3 + wid;
-  buffd = buff4 + wid;
-  buffo = (mlib_s32*)(buffd + wid);
-  buffi = buffo + (wid &~ 1);
-
-  chan1 = nchannel;
-  chan2 = chan1 + chan1;
-
-  wid -= (KSIZE - 1);
-  hgt -= (KSIZE - 1);
-
-  adr_dst += ((KSIZE - 1)/2)*(dll + chan1);
-
-  for (c = 0; c < nchannel; c++) {
-    if (!(cmask & (1 << (nchannel - 1 - c)))) continue;
-
-    sl = adr_src + c;
-    dl = adr_dst + c;
-
-    sl1 = sl  + sll;
-    sl2 = sl1 + sll;
-    sl3 = sl2 + sll;
-#ifdef __SUNPRO_C
-#pragma pipeloop(0)
-#endif /* __SUNPRO_C */
-    for (i = 0; i < wid + (KSIZE - 1); i++) {
-      buff0[i] = (FTYPE)sl[i*chan1];
-      buff1[i] = (FTYPE)sl1[i*chan1];
-      buff2[i] = (FTYPE)sl2[i*chan1];
-      buff3[i] = (FTYPE)sl3[i*chan1];
-    }
-
-    sl += KSIZE*sll;
-
-    for (j = 0; j < hgt; j++) {
-      d64_2x32 dd;
-
-      /*
-       *  First loop on two first lines of kernel
-       */
-      k0 = k[0]; k1 = k[1]; k2 = k[2]; k3 = k[3];
-      k4 = k[4]; k5 = k[5]; k6 = k[6]; k7 = k[7];
-
-      sp = sl;
-      dp = dl;
-
-      p02 = buff0[0];
-      p12 = buff1[0];
-      p03 = buff0[1];
-      p13 = buff1[1];
-      p04 = buff0[2];
-
-#ifdef __SUNPRO_C
-#pragma pipeloop(0)
-#endif /* __SUNPRO_C */
-      for (i = 0; i <= (wid - 2); i += 2) {
-        p00 = p02; p10 = p12;
-        p01 = p03; p11 = p13;
-        p02 = p04; p12 = buff1[i + 2];
-        p03 = buff0[i + 3]; p13 = buff1[i + 3];
-        p04 = buff0[i + 4]; p14 = buff1[i + 4];
-
-        LOAD_BUFF(buffi);
-
-        dd.d64 = *(FTYPE   *)(buffi + i);
-        buff4[i    ] = (FTYPE)dd.i32s.i0;
-        buff4[i + 1] = (FTYPE)dd.i32s.i1;
-
-        buffd[i    ] = (p00 * k0 + p01 * k1 + p02 * k2 + p03 * k3 +
-                        p10 * k4 + p11 * k5 + p12 * k6 + p13 * k7);
-        buffd[i + 1] = (p01 * k0 + p02 * k1 + p03 * k2 + p04 * k3 +
-                        p11 * k4 + p12 * k5 + p13 * k6 + p14 * k7);
-
-        sp += chan2;
-        dp += chan2;
-      }
-
-      /*
-       *  Second loop on two last lines of kernel
-       */
-      k0 = k[ 8]; k1 = k[ 9]; k2 = k[10]; k3 = k[11];
-      k4 = k[12]; k5 = k[13]; k6 = k[14]; k7 = k[15];
-
-      sp = sl;
-      dp = dl;
-
-      p02 = buff2[0];
-      p12 = buff3[0];
-      p03 = buff2[1];
-      p13 = buff3[1];
-      p04 = buff2[2];
-
-#ifdef __SUNPRO_C
-#pragma pipeloop(0)
-#endif /* __SUNPRO_C */
-      for (i = 0; i <= (wid - 2); i += 2) {
-        p00 = p02; p10 = p12;
-        p01 = p03; p11 = p13;
-        p02 = p04; p12 = buff3[i + 2];
-        p03 = buff2[i + 3]; p13 = buff3[i + 3];
-        p04 = buff2[i + 4]; p14 = buff3[i + 4];
-
-        d0 = D2I(p00 * k0 + p01 * k1 + p02 * k2 + p03 * k3 +
-                 p10 * k4 + p11 * k5 + p12 * k6 + p13 * k7 + buffd[i]);
-        d1 = D2I(p01 * k0 + p02 * k1 + p03 * k2 + p04 * k3 +
-                 p11 * k4 + p12 * k5 + p13 * k6 + p14 * k7 + buffd[i + 1]);
-
-        dp[0    ] = FROM_S32(d0);
-        dp[chan1] = FROM_S32(d1);
-
-        sp += chan2;
-        dp += chan2;
-      }
-
-      /* last pixels */
-      for (; i < wid; i++) {
-        p00 = buff0[i];     p10 = buff1[i];     p20 = buff2[i];     p30 = buff3[i];
-        p01 = buff0[i + 1]; p11 = buff1[i + 1]; p21 = buff2[i + 1]; p31 = buff3[i + 1];
-        p02 = buff0[i + 2]; p12 = buff1[i + 2]; p22 = buff2[i + 2]; p32 = buff3[i + 2];
-        p03 = buff0[i + 3]; p13 = buff1[i + 3]; p23 = buff2[i + 3]; p33 = buff3[i + 3];
-
-        buff4[i] = (FTYPE)sp[0];
-
-        buffo[i] = D2I(p00 * k[0] + p01 * k[1] + p02 * k[2] + p03 * k[3] +
-                       p10 * k[4] + p11 * k[5] + p12 * k[6] + p13 * k[7] +
-                       p20 * k[ 8] + p21 * k[ 9] + p22 * k[10] + p23 * k[11] +
-                       p30 * k[12] + p31 * k[13] + p32 * k[14] + p33 * k[15]);
-
-        dp[0] = FROM_S32(buffo[i]);
-
-        sp += chan1;
-        dp += chan1;
-      }
-
-      buff4[wid    ] = (FTYPE)sp[0];
-      buff4[wid + 1] = (FTYPE)sp[chan1];
-      buff4[wid + 2] = (FTYPE)sp[chan2];
-
-      /* next line */
-      sl += sll;
-      dl += dll;
-
-      buffT = buff0;
-      buff0 = buff1;
-      buff1 = buff2;
-      buff2 = buff3;
-      buff3 = buff4;
-      buff4 = buffT;
-    }
-  }
-
-  if (pbuff != buff) mlib_free(pbuff);
-
-  return MLIB_SUCCESS;
-}
-
-/***************************************************************/
-#undef  KSIZE
-#define KSIZE 5
-
-mlib_status CONV_FUNC(5x5)(mlib_image       *dst,
-                           const mlib_image *src,
-                           const mlib_s32   *kern,
-                           mlib_s32         scalef_expon,
-                           mlib_s32         cmask)
-{
-  FTYPE    buff[(KSIZE + 3)*BUFF_LINE];
-  FTYPE    *buff0, *buff1, *buff2, *buff3, *buff4, *buff5, *buffd, *buffT;
-  FTYPE    k[KSIZE*KSIZE];
-  mlib_s32 d0, d1;
-  FTYPE    k0, k1, k2, k3, k4, k5, k6, k7, k8, k9;
-  FTYPE    p00, p01, p02, p03, p04, p05,
-           p10, p11, p12, p13, p14, p15,
-           p20, p21, p22, p23, p24,
-           p30, p31, p32, p33, p34,
-           p40, p41, p42, p43, p44;
-  DEF_VARS(DTYPE);
-  DTYPE *sl1;
-  mlib_s32 chan2;
-  mlib_s32 *buffo, *buffi;
-  DTYPE *sl2, *sl3, *sl4;
-  LOAD_KERNEL(KSIZE*KSIZE);
-  GET_SRC_DST_PARAMETERS(DTYPE);
-
-  if (wid > BUFF_LINE) {
-    pbuff = mlib_malloc((KSIZE + 3)*sizeof(FTYPE)*wid);
-
-    if (pbuff == NULL) return MLIB_FAILURE;
-  }
-
-  buff0 = pbuff;
-  buff1 = buff0 + wid;
-  buff2 = buff1 + wid;
-  buff3 = buff2 + wid;
-  buff4 = buff3 + wid;
-  buff5 = buff4 + wid;
-  buffd = buff5 + wid;
-  buffo = (mlib_s32*)(buffd + wid);
-  buffi = buffo + (wid &~ 1);
-
-  chan1 = nchannel;
-  chan2 = chan1 + chan1;
-
-  wid -= (KSIZE - 1);
-  hgt -= (KSIZE - 1);
-
-  adr_dst += ((KSIZE - 1)/2)*(dll + chan1);
-
-  for (c = 0; c < nchannel; c++) {
-    if (!(cmask & (1 << (nchannel - 1 - c)))) continue;
-
-    sl = adr_src + c;
-    dl = adr_dst + c;
-
-    sl1 = sl  + sll;
-    sl2 = sl1 + sll;
-    sl3 = sl2 + sll;
-    sl4 = sl3 + sll;
-#ifdef __SUNPRO_C
-#pragma pipeloop(0)
-#endif /* __SUNPRO_C */
-    for (i = 0; i < wid + (KSIZE - 1); i++) {
-      buff0[i] = (FTYPE)sl[i*chan1];
-      buff1[i] = (FTYPE)sl1[i*chan1];
-      buff2[i] = (FTYPE)sl2[i*chan1];
-      buff3[i] = (FTYPE)sl3[i*chan1];
-      buff4[i] = (FTYPE)sl4[i*chan1];
-    }
-
-    sl += KSIZE*sll;
-
-    for (j = 0; j < hgt; j++) {
-      d64_2x32 dd;
-
-      /*
-       *  First loop
-       */
-      k0 = k[0]; k1 = k[1]; k2 = k[2]; k3 = k[3]; k4 = k[4];
-      k5 = k[5]; k6 = k[6]; k7 = k[7]; k8 = k[8]; k9 = k[9];
-
-      sp = sl;
-      dp = dl;
-
-      p02 = buff0[0];
-      p12 = buff1[0];
-      p03 = buff0[1];
-      p13 = buff1[1];
-      p04 = buff0[2];
-      p14 = buff1[2];
-
-#ifdef __SUNPRO_C
-#pragma pipeloop(0)
-#endif /* __SUNPRO_C */
-      for (i = 0; i <= (wid - 2); i += 2) {
-        p00 = p02; p10 = p12;
-        p01 = p03; p11 = p13;
-        p02 = p04; p12 = p14;
-
-        LOAD_BUFF(buffi);
-
-        p03 = buff0[i + 3]; p13 = buff1[i + 3];
-        p04 = buff0[i + 4]; p14 = buff1[i + 4];
-        p05 = buff0[i + 5]; p15 = buff1[i + 5];
-
-        buffd[i    ] = (p00 * k0 + p01 * k1 + p02 * k2 + p03 * k3 + p04 * k4 +
-                        p10 * k5 + p11 * k6 + p12 * k7 + p13 * k8 + p14 * k9);
-        buffd[i + 1] = (p01 * k0 + p02 * k1 + p03 * k2 + p04 * k3 + p05 * k4 +
-                        p11 * k5 + p12 * k6 + p13 * k7 + p14 * k8 + p15 * k9);
-
-        sp += chan2;
-        dp += chan2;
-      }
-
-      /*
-       *  Second loop
-       */
-      k0 = k[10]; k1 = k[11]; k2 = k[12]; k3 = k[13]; k4 = k[14];
-      k5 = k[15]; k6 = k[16]; k7 = k[17]; k8 = k[18]; k9 = k[19];
-
-      sp = sl;
-      dp = dl;
-
-      p02 = buff2[0];
-      p12 = buff3[0];
-      p03 = buff2[1];
-      p13 = buff3[1];
-      p04 = buff2[2];
-      p14 = buff3[2];
-
-#ifdef __SUNPRO_C
-#pragma pipeloop(0)
-#endif /* __SUNPRO_C */
-      for (i = 0; i <= (wid - 2); i += 2) {
-        p00 = p02; p10 = p12;
-        p01 = p03; p11 = p13;
-
-        p02 = buff2[i + 2]; p12 = buff3[i + 2];
-        p03 = buff2[i + 3]; p13 = buff3[i + 3];
-        p04 = buff2[i + 4]; p14 = buff3[i + 4];
-        p05 = buff2[i + 5]; p15 = buff3[i + 5];
-
-        dd.d64 = *(FTYPE   *)(buffi + i);
-        buff5[i    ] = (FTYPE)dd.i32s.i0;
-        buff5[i + 1] = (FTYPE)dd.i32s.i1;
-
-        buffd[i    ] += (p00 * k0 + p01 * k1 + p02 * k2 + p03 * k3 + p04 * k4 +
-                         p10 * k5 + p11 * k6 + p12 * k7 + p13 * k8 + p14 * k9);
-        buffd[i + 1] += (p01 * k0 + p02 * k1 + p03 * k2 + p04 * k3 + p05 * k4 +
-                         p11 * k5 + p12 * k6 + p13 * k7 + p14 * k8 + p15 * k9);
-
-        sp += chan2;
-        dp += chan2;
-      }
-
-      /*
-       *  3 loop
-       */
-      k0 = k[20]; k1 = k[21]; k2 = k[22]; k3 = k[23]; k4 = k[24];
-
-      sp = sl;
-      dp = dl;
-
-      p02 = buff4[0];
-      p03 = buff4[1];
-      p04 = buff4[2];
-      p05 = buff4[3];
-
-#ifdef __SUNPRO_C
-#pragma pipeloop(0)
-#endif /* __SUNPRO_C */
-      for (i = 0; i <= (wid - 2); i += 2) {
-        p00 = p02; p01 = p03; p02 = p04; p03 = p05;
-
-        p04 = buff4[i + 4]; p05 = buff4[i + 5];
-
-        d0 = D2I(p00 * k0 + p01 * k1 + p02 * k2 + p03 * k3 + p04 * k4 + buffd[i]);
-        d1 = D2I(p01 * k0 + p02 * k1 + p03 * k2 + p04 * k3 + p05 * k4 + buffd[i + 1]);
-
-        dp[0    ] = FROM_S32(d0);
-        dp[chan1] = FROM_S32(d1);
-
-        sp += chan2;
-        dp += chan2;
-      }
-
-      /* last pixels */
-      for (; i < wid; i++) {
-        p00 = buff0[i];     p10 = buff1[i];     p20 = buff2[i];     p30 = buff3[i];
-        p01 = buff0[i + 1]; p11 = buff1[i + 1]; p21 = buff2[i + 1]; p31 = buff3[i + 1];
-        p02 = buff0[i + 2]; p12 = buff1[i + 2]; p22 = buff2[i + 2]; p32 = buff3[i + 2];
-        p03 = buff0[i + 3]; p13 = buff1[i + 3]; p23 = buff2[i + 3]; p33 = buff3[i + 3];
-        p04 = buff0[i + 4]; p14 = buff1[i + 4]; p24 = buff2[i + 4]; p34 = buff3[i + 4];
-
-        p40 = buff4[i];     p41 = buff4[i + 1]; p42 = buff4[i + 2];
-        p43 = buff4[i + 3]; p44 = buff4[i + 4];
-
-        buff5[i] = (FTYPE)sp[0];
-
-        buffo[i] = D2I(p00 * k[0] + p01 * k[1] + p02 * k[2] + p03 * k[3] + p04 * k[4] +
-                       p10 * k[5] + p11 * k[6] + p12 * k[7] + p13 * k[8] + p14 * k[9] +
-                       p20 * k[10] + p21 * k[11] + p22 * k[12] + p23 * k[13] + p24 * k[14] +
-                       p30 * k[15] + p31 * k[16] + p32 * k[17] + p33 * k[18] + p34 * k[19] +
-                       p40 * k[20] + p41 * k[21] + p42 * k[22] + p43 * k[23] + p44 * k[24]);
-
-        dp[0] = FROM_S32(buffo[i]);
-
-        sp += chan1;
-        dp += chan1;
-      }
-
-      buff5[wid    ] = (FTYPE)sp[0];
-      buff5[wid + 1] = (FTYPE)sp[chan1];
-      buff5[wid + 2] = (FTYPE)sp[chan2];
-      buff5[wid + 3] = (FTYPE)sp[chan2 + chan1];
-
-      /* next line */
-      sl += sll;
-      dl += dll;
-
-      buffT = buff0;
-      buff0 = buff1;
-      buff1 = buff2;
-      buff2 = buff3;
-      buff3 = buff4;
-      buff4 = buff5;
-      buff5 = buffT;
-    }
-  }
-
-  if (pbuff != buff) mlib_free(pbuff);
-
-  return MLIB_SUCCESS;
-}
-
-/***************************************************************/
-#ifndef __sparc /* for x86, using integer multiplies is faster */
-
-mlib_status CONV_FUNC_I(5x5)(mlib_image       *dst,
-                             const mlib_image *src,
-                             const mlib_s32   *kern,
-                             mlib_s32         scalef_expon,
-                             mlib_s32         cmask)
-{
-  mlib_s32 buff[BUFF_LINE];
-  mlib_s32 *buffd;
-  mlib_s32 k[KSIZE*KSIZE];
-  mlib_s32 shift1, shift2;
-  mlib_s32 k0, k1, k2, k3, k4, k5, k6, k7, k8, k9;
-  mlib_s32 p00, p01, p02, p03, p04, p05,
-           p10, p11, p12, p13, p14, p15;
-  DTYPE    *adr_src, *sl, *sp0, *sp1;
-  DTYPE    *adr_dst, *dl, *dp;
-  mlib_s32 *pbuff = buff;
-  mlib_s32 wid, hgt, sll, dll;
-  mlib_s32 nchannel, chan1, chan2, chan3, chan4;
-  mlib_s32 i, j, c;
-
-#if IMG_TYPE != 1
-  shift1 = 16;
-#else
-  shift1 = 8;
-#endif /* IMG_TYPE != 1 */
-
-  shift2 = scalef_expon - shift1;
-
-  for (j = 0; j < KSIZE*KSIZE; j++) k[j] = kern[j] >> shift1;
-
-  GET_SRC_DST_PARAMETERS(DTYPE);
-
-  if (wid > BUFF_LINE) {
-    pbuff = mlib_malloc(sizeof(mlib_s32)*wid);
-
-    if (pbuff == NULL) return MLIB_FAILURE;
-  }
-
-  buffd = pbuff;
-
-  chan1 = nchannel;
-  chan2 = chan1 + chan1;
-  chan3 = chan2 + chan1;
-  chan4 = chan3 + chan1;
-
-  wid -= (KSIZE - 1);
-  hgt -= (KSIZE - 1);
-
-  adr_dst += ((KSIZE - 1)/2)*(dll + chan1);
-
-  for (c = 0; c < chan1; c++) {
-    if (!(cmask & (1 << (chan1 - 1 - c)))) continue;
-
-    sl = adr_src + c;
-    dl = adr_dst + c;
-
-    for (j = 0; j < hgt; j++) {
-      mlib_s32 pix0, pix1;
-      /*
-       *  First loop
-       */
-      sp0 = sl;
-      sp1 = sp0 + sll;
-      dp = dl;
-
-      k0 = k[0]; k1 = k[1]; k2 = k[2]; k3 = k[3]; k4 = k[4];
-      k5 = k[5]; k6 = k[6]; k7 = k[7]; k8 = k[8]; k9 = k[9];
-
-      p02 = sp0[0];     p12 = sp1[0];
-      p03 = sp0[chan1]; p13 = sp1[chan1];
-      p04 = sp0[chan2]; p14 = sp1[chan2];
-      p05 = sp0[chan3]; p15 = sp1[chan3];
-
-      sp0 += chan4;
-      sp1 += chan4;
-
-#ifdef __SUNPRO_C
-#pragma pipeloop(0)
-#endif /* __SUNPRO_C */
-      for (i = 0; i <= (wid - 2); i += 2) {
-        p00 = p02; p10 = p12;
-        p01 = p03; p11 = p13;
-        p02 = p04; p12 = p14;
-        p03 = p05; p13 = p15;
-
-        p04 = sp0[0];     p14 = sp1[0];
-        p05 = sp0[chan1]; p15 = sp1[chan1];
-
-        buffd[i    ] = (p00 * k0 + p01 * k1 + p02 * k2 + p03 * k3 + p04 * k4 +
-                        p10 * k5 + p11 * k6 + p12 * k7 + p13 * k8 + p14 * k9);
-        buffd[i + 1] = (p01 * k0 + p02 * k1 + p03 * k2 + p04 * k3 + p05 * k4 +
-                        p11 * k5 + p12 * k6 + p13 * k7 + p14 * k8 + p15 * k9);
-
-        sp0 += chan2;
-        sp1 += chan2;
-        dp += chan2;
-      }
-
-      if (wid & 1) {
-        p00 = p02; p10 = p12;
-        p01 = p03; p11 = p13;
-        p02 = p04; p12 = p14;
-        p03 = p05; p13 = p15;
-
-        p04 = sp0[0];     p14 = sp1[0];
-
-        buffd[i] = (p00 * k0 + p01 * k1 + p02 * k2 + p03 * k3 + p04 * k4 +
-                    p10 * k5 + p11 * k6 + p12 * k7 + p13 * k8 + p14 * k9);
-      }
-
-      /*
-       *  Second loop
-       */
-      sp0 = sl + 2*sll;
-      sp1 = sp0 + sll;
-      dp = dl;
-
-      k0 = k[10]; k1 = k[11]; k2 = k[12]; k3 = k[13]; k4 = k[14];
-      k5 = k[15]; k6 = k[16]; k7 = k[17]; k8 = k[18]; k9 = k[19];
-
-      p02 = sp0[0];     p12 = sp1[0];
-      p03 = sp0[chan1]; p13 = sp1[chan1];
-      p04 = sp0[chan2]; p14 = sp1[chan2];
-      p05 = sp0[chan3]; p15 = sp1[chan3];
-
-      sp0 += chan4;
-      sp1 += chan4;
-
-#ifdef __SUNPRO_C
-#pragma pipeloop(0)
-#endif /* __SUNPRO_C */
-      for (i = 0; i <= (wid - 2); i += 2) {
-        p00 = p02; p10 = p12;
-        p01 = p03; p11 = p13;
-        p02 = p04; p12 = p14;
-        p03 = p05; p13 = p15;
-
-        p04 = sp0[0];     p14 = sp1[0];
-        p05 = sp0[chan1]; p15 = sp1[chan1];
-
-        buffd[i    ] += (p00 * k0 + p01 * k1 + p02 * k2 + p03 * k3 + p04 * k4 +
-                         p10 * k5 + p11 * k6 + p12 * k7 + p13 * k8 + p14 * k9);
-        buffd[i + 1] += (p01 * k0 + p02 * k1 + p03 * k2 + p04 * k3 + p05 * k4 +
-                         p11 * k5 + p12 * k6 + p13 * k7 + p14 * k8 + p15 * k9);
-
-        sp0 += chan2;
-        sp1 += chan2;
-        dp += chan2;
-      }
-
-      if (wid & 1) {
-        p00 = p02; p10 = p12;
-        p01 = p03; p11 = p13;
-        p02 = p04; p12 = p14;
-        p03 = p05; p13 = p15;
-
-        p04 = sp0[0];     p14 = sp1[0];
-
-        buffd[i] += (p00 * k0 + p01 * k1 + p02 * k2 + p03 * k3 + p04 * k4 +
-                     p10 * k5 + p11 * k6 + p12 * k7 + p13 * k8 + p14 * k9);
-      }
-
-      /*
-       *  3 loop
-       */
-      dp = dl;
-      sp0 = sl + 4*sll;
-
-      k0 = k[20]; k1 = k[21]; k2 = k[22]; k3 = k[23]; k4 = k[24];
-
-      p02 = sp0[0];
-      p03 = sp0[chan1];
-      p04 = sp0[chan2];
-      p05 = sp0[chan3];
-
-      sp0 += chan2 + chan2;
-
-#ifdef __SUNPRO_C
-#pragma pipeloop(0)
-#endif /* __SUNPRO_C */
-      for (i = 0; i <= (wid - 2); i += 2) {
-        p00 = p02; p01 = p03; p02 = p04; p03 = p05;
-
-        p04 = sp0[0]; p05 = sp0[chan1];
-
-        pix0 = (buffd[i    ] + p00 * k0 + p01 * k1 + p02 * k2 +
-                p03 * k3 + p04 * k4) >> shift2;
-        pix1 = (buffd[i + 1] + p01 * k0 + p02 * k1 + p03 * k2 +
-                p04 * k3 + p05 * k4) >> shift2;
-
-        CLAMP_STORE(dp[0],     pix0);
-        CLAMP_STORE(dp[chan1], pix1);
-
-        dp  += chan2;
-        sp0 += chan2;
-      }
-
-      if (wid & 1) {
-        p00 = p02; p01 = p03; p02 = p04; p03 = p05;
-
-        p04 = sp0[0];
-
-        pix0 = (buffd[i    ] + p00 * k0 + p01 * k1 + p02 * k2 +
-                p03 * k3 + p04 * k4) >> shift2;
-        CLAMP_STORE(dp[0],     pix0);
-      }
-
-      /* next line */
-      sl += sll;
-      dl += dll;
-    }
-  }
-
-  if (pbuff != buff) mlib_free(pbuff);
-
-  return MLIB_SUCCESS;
-}
-
-#endif /* __sparc ( for x86, using integer multiplies is faster ) */
-
-/***************************************************************/
-#if IMG_TYPE == 1
-
-#undef  KSIZE
-#define KSIZE 7
-
-mlib_status CONV_FUNC(7x7)(mlib_image       *dst,
-                           const mlib_image *src,
-                           const mlib_s32   *kern,
-                           mlib_s32         scalef_expon,
-                           mlib_s32         cmask)
-{
-  FTYPE    buff[(KSIZE + 3)*BUFF_LINE], *buffs[2*(KSIZE + 1)], *buffd;
-  FTYPE    k[KSIZE*KSIZE];
-  mlib_s32 l, m, buff_ind;
-  mlib_s32 d0, d1;
-  FTYPE    k0, k1, k2, k3, k4, k5, k6;
-  FTYPE    p0, p1, p2, p3, p4, p5, p6, p7;
-  DTYPE *sl2, *sl3, *sl4, *sl5, *sl6;
-  DEF_VARS(DTYPE);
-  DTYPE *sl1;
-  mlib_s32 chan2;
-  mlib_s32 *buffo, *buffi;
-  LOAD_KERNEL(KSIZE*KSIZE);
-  GET_SRC_DST_PARAMETERS(DTYPE);
-
-  if (wid > BUFF_LINE) {
-    pbuff = mlib_malloc((KSIZE + 3)*sizeof(FTYPE)*wid);
-
-    if (pbuff == NULL) return MLIB_FAILURE;
-  }
-
-  for (l = 0; l < KSIZE + 1; l++) buffs[l] = pbuff + l*wid;
-  for (l = 0; l < KSIZE + 1; l++) buffs[l + (KSIZE + 1)] = buffs[l];
-  buffd = buffs[KSIZE] + wid;
-  buffo = (mlib_s32*)(buffd + wid);
-  buffi = buffo + (wid &~ 1);
-
-  chan1 = nchannel;
-  chan2 = chan1 + chan1;
-
-  wid -= (KSIZE - 1);
-  hgt -= (KSIZE - 1);
-
-  adr_dst += ((KSIZE - 1)/2)*(dll + chan1);
-
-  for (c = 0; c < nchannel; c++) {
-    if (!(cmask & (1 << (nchannel - 1 - c)))) continue;
-
-    sl = adr_src + c;
-    dl = adr_dst + c;
-
-    sl1 = sl  + sll;
-    sl2 = sl1 + sll;
-    sl3 = sl2 + sll;
-    sl4 = sl3 + sll;
-    sl5 = sl4 + sll;
-    sl6 = sl5 + sll;
-#ifdef __SUNPRO_C
-#pragma pipeloop(0)
-#endif /* __SUNPRO_C */
-    for (i = 0; i < wid + (KSIZE - 1); i++) {
-      buffs[0][i] = (FTYPE)sl[i*chan1];
-      buffs[1][i] = (FTYPE)sl1[i*chan1];
-      buffs[2][i] = (FTYPE)sl2[i*chan1];
-      buffs[3][i] = (FTYPE)sl3[i*chan1];
-      buffs[4][i] = (FTYPE)sl4[i*chan1];
-      buffs[5][i] = (FTYPE)sl5[i*chan1];
-      buffs[6][i] = (FTYPE)sl6[i*chan1];
-    }
-
-    buff_ind = 0;
-
-#ifdef __SUNPRO_C
-#pragma pipeloop(0)
-#endif /* __SUNPRO_C */
-    for (i = 0; i < wid; i++) buffd[i] = 0.0;
-
-    sl += KSIZE*sll;
-
-    for (j = 0; j < hgt; j++) {
-      FTYPE    **buffc = buffs + buff_ind;
-      FTYPE    *buffn = buffc[KSIZE];
-      FTYPE    *pk = k;
-
-      for (l = 0; l < KSIZE; l++) {
-        FTYPE    *buff = buffc[l];
-        d64_2x32 dd;
-
-        sp = sl;
-        dp = dl;
-
-        p2 = buff[0]; p3 = buff[1]; p4 = buff[2];
-        p5 = buff[3]; p6 = buff[4]; p7 = buff[5];
-
-        k0 = *pk++; k1 = *pk++; k2 = *pk++; k3 = *pk++;
-        k4 = *pk++; k5 = *pk++; k6 = *pk++;
-
-        if (l < (KSIZE - 1)) {
-#ifdef __SUNPRO_C
-#pragma pipeloop(0)
-#endif /* __SUNPRO_C */
-          for (i = 0; i <= (wid - 2); i += 2) {
-            p0 = p2; p1 = p3; p2 = p4; p3 = p5; p4 = p6; p5 = p7;
-
-            p6 = buff[i + 6]; p7 = buff[i + 7];
-
-            buffd[i    ] += p0*k0 + p1*k1 + p2*k2 + p3*k3 + p4*k4 + p5*k5 + p6*k6;
-            buffd[i + 1] += p1*k0 + p2*k1 + p3*k2 + p4*k3 + p5*k4 + p6*k5 + p7*k6;
-          }
-
-        } else {
-#ifdef __SUNPRO_C
-#pragma pipeloop(0)
-#endif /* __SUNPRO_C */
-          for (i = 0; i <= (wid - 2); i += 2) {
-            p0 = p2; p1 = p3; p2 = p4; p3 = p5; p4 = p6; p5 = p7;
-
-            p6 = buff[i + 6]; p7 = buff[i + 7];
-
-            LOAD_BUFF(buffi);
-
-            dd.d64 = *(FTYPE   *)(buffi + i);
-            buffn[i    ] = (FTYPE)dd.i32s.i0;
-            buffn[i + 1] = (FTYPE)dd.i32s.i1;
-
-            d0 = D2I(p0*k0 + p1*k1 + p2*k2 + p3*k3 + p4*k4 + p5*k5 + p6*k6 + buffd[i    ]);
-            d1 = D2I(p1*k0 + p2*k1 + p3*k2 + p4*k3 + p5*k4 + p6*k5 + p7*k6 + buffd[i + 1]);
-
-            dp[0    ] = FROM_S32(d0);
-            dp[chan1] = FROM_S32(d1);
-
-            buffd[i    ] = 0.0;
-            buffd[i + 1] = 0.0;
-
-            sp += chan2;
-            dp += chan2;
-          }
-        }
-      }
-
-      /* last pixels */
-      for (; i < wid; i++) {
-        FTYPE    *pk = k, s = 0;
-        mlib_s32 d0;
-
-        for (l = 0; l < KSIZE; l++) {
-          FTYPE    *buff = buffc[l] + i;
-
-          for (m = 0; m < KSIZE; m++) s += buff[m] * (*pk++);
-        }
-
-        d0 = D2I(s);
-        dp[0] = FROM_S32(d0);
-
-        buffn[i] = (FTYPE)sp[0];
-
-        sp += chan1;
-        dp += chan1;
-      }
-
-      for (l = 0; l < (KSIZE - 1); l++) buffn[wid + l] = sp[l*chan1];
-
-      /* next line */
-      sl += sll;
-      dl += dll;
-
-      buff_ind++;
-
-      if (buff_ind >= KSIZE + 1) buff_ind = 0;
-    }
-  }
-
-  if (pbuff != buff) mlib_free(pbuff);
-
-  return MLIB_SUCCESS;
-}
-
-#endif /* IMG_TYPE == 1 */
-
-/***************************************************************/
 #define MAX_KER   7
 #define MAX_N    15
 
--- a/jdk/src/java.desktop/share/native/libmlib_image/mlib_ImageConv_32nw.c	Thu May 19 17:48:02 2016 +0000
+++ b/jdk/src/java.desktop/share/native/libmlib_image/mlib_ImageConv_32nw.c	Thu May 19 19:46:20 2016 +0000
@@ -35,8 +35,6 @@
 #include "mlib_ImageConv.h"
 
 /***************************************************************/
-#define BUFF_LINE  256
-
 #define CACHE_SIZE (64*1024)
 
 /***************************************************************/
@@ -83,837 +81,6 @@
   mlib_s32 i, j, c
 
 /***************************************************************/
-#define CALC_SCALE()                                            \
-  scalef = 1.0;                                                 \
-  while (scalef_expon > 30) {                                   \
-    scalef /= (1 << 30);                                        \
-    scalef_expon -= 30;                                         \
-  }                                                             \
-                                                                \
-  scalef /= (1 << scalef_expon)
-
-/***************************************************************/
-#undef  KSIZE
-#define KSIZE 2
-
-mlib_status CONV_FUNC(2x2)(mlib_image       *dst,
-                           const mlib_image *src,
-                           const mlib_s32   *kern,
-                           mlib_s32         scalef_expon,
-                           mlib_s32         cmask)
-{
-  mlib_d64 buff[(KSIZE + 1)*BUFF_LINE];
-  mlib_d64 k0, k1, k2, k3;
-  mlib_d64 p00, p01, p02, p03,
-           p10, p11, p12, p13;
-  mlib_d64 d2;
-  DEF_VARS(mlib_s32);
-  mlib_s32 chan2 = chan1 + chan1;
-  mlib_s32 chan3 = chan1 + chan2;
-
-  if (wid > BUFF_LINE) {
-    pbuff = mlib_malloc((KSIZE + 1)*sizeof(mlib_d64)*wid);
-
-    if (pbuff == NULL) return MLIB_FAILURE;
-  }
-
-  buff0 = pbuff;
-  buff1 = buff0 + wid;
-  buff2 = buff1 + wid;
-
-  wid -= (KSIZE - 1);
-  hgt -= (KSIZE - 1);
-
-  /* keep kernel in regs */
-  CALC_SCALE();
-  k0 = scalef * kern[0];  k1 = scalef * kern[1];
-  k2 = scalef * kern[2];  k3 = scalef * kern[3];
-
-  for (c = 0; c < chan1; c++) {
-    if (!(cmask & (1 << (chan1 - 1 - c)))) continue;
-
-    sl = adr_src + c;
-    dl = adr_dst + c;
-
-    sl1 = sl + sll;
-#ifdef __SUNPRO_C
-#pragma pipeloop(0)
-#endif /* __SUNPRO_C */
-    for (i = 0; i < wid + (KSIZE - 1); i++) {
-      buff0[i] = (mlib_d64)sl[i*chan1];
-      buff1[i] = (mlib_d64)sl1[i*chan1];
-    }
-
-    sl += KSIZE*sll;
-
-    for (j = 0; j < hgt; j++) {
-      p03 = buff0[0];
-      p13 = buff1[0];
-
-      sp = sl;
-      dp = dl;
-
-#ifdef __SUNPRO_C
-#pragma pipeloop(0)
-#endif /* __SUNPRO_C */
-      for (i = 0; i <= (wid - 3); i += 3) {
-
-        p00 = p03; p10 = p13;
-
-        p01 = buff0[i + 1]; p11 = buff1[i + 1];
-        p02 = buff0[i + 2]; p12 = buff1[i + 2];
-        p03 = buff0[i + 3]; p13 = buff1[i + 3];
-
-        buff2[i    ] = (mlib_d64)sp[0];
-        buff2[i + 1] = (mlib_d64)sp[chan1];
-        buff2[i + 2] = (mlib_d64)sp[chan2];
-
-        d0 = p00 * k0 + p01 * k1 + p10 * k2 + p11 * k3;
-        d1 = p01 * k0 + p02 * k1 + p11 * k2 + p12 * k3;
-        d2 = p02 * k0 + p03 * k1 + p12 * k2 + p13 * k3;
-
-        CLAMP_S32(dp[0    ], d0);
-        CLAMP_S32(dp[chan1], d1);
-        CLAMP_S32(dp[chan2], d2);
-
-        sp += chan3;
-        dp += chan3;
-      }
-
-      for (; i < wid; i++) {
-        p00 = buff0[i];     p10 = buff1[i];
-        p01 = buff0[i + 1]; p11 = buff1[i + 1];
-
-        buff2[i] = (mlib_d64)sp[0];
-
-        d0 = p00 * k0 + p01 * k1 + p10 * k2 + p11 * k3;
-        CLAMP_S32(dp[0], d0);
-
-        sp += chan1;
-        dp += chan1;
-      }
-
-      buff2[wid] = (mlib_d64)sp[0];
-
-      sl += sll;
-      dl += dll;
-
-      buffT = buff0;
-      buff0 = buff1;
-      buff1 = buff2;
-      buff2 = buffT;
-    }
-  }
-
-  if (pbuff != buff) mlib_free(pbuff);
-
-  return MLIB_SUCCESS;
-}
-
-/***************************************************************/
-#undef  KSIZE
-#define KSIZE 3
-
-mlib_status CONV_FUNC(3x3)(mlib_image       *dst,
-                           const mlib_image *src,
-                           const mlib_s32   *kern,
-                           mlib_s32         scalef_expon,
-                           mlib_s32         cmask)
-{
-  mlib_d64 buff[(KSIZE + 1)*BUFF_LINE], *buff3;
-  mlib_d64 k0, k1, k2, k3, k4, k5, k6, k7, k8;
-  mlib_d64 p00, p01, p02, p03,
-           p10, p11, p12, p13,
-           p20, p21, p22, p23;
-  mlib_s32 *sl2;
-  DEF_VARS(mlib_s32);
-  mlib_s32 chan2 = chan1 + chan1;
-
-  if (wid > BUFF_LINE) {
-    pbuff = mlib_malloc((KSIZE + 1)*sizeof(mlib_d64)*wid);
-
-    if (pbuff == NULL) return MLIB_FAILURE;
-  }
-
-  buff0 = pbuff;
-  buff1 = buff0 + wid;
-  buff2 = buff1 + wid;
-  buff3 = buff2 + wid;
-
-  wid -= (KSIZE - 1);
-  hgt -= (KSIZE - 1);
-
-  adr_dst += ((KSIZE - 1)/2)*(dll + chan1);
-
-  CALC_SCALE();
-  k0 = scalef * kern[0];  k1 = scalef * kern[1];  k2 = scalef * kern[2];
-  k3 = scalef * kern[3];  k4 = scalef * kern[4];  k5 = scalef * kern[5];
-  k6 = scalef * kern[6];  k7 = scalef * kern[7];  k8 = scalef * kern[8];
-
-  for (c = 0; c < chan1; c++) {
-    if (!(cmask & (1 << (chan1 - 1 - c)))) continue;
-
-    sl = adr_src + c;
-    dl = adr_dst + c;
-
-    sl1 = sl  + sll;
-    sl2 = sl1 + sll;
-#ifdef __SUNPRO_C
-#pragma pipeloop(0)
-#endif /* __SUNPRO_C */
-    for (i = 0; i < wid + (KSIZE - 1); i++) {
-      buff0[i] = (mlib_d64)sl[i*chan1];
-      buff1[i] = (mlib_d64)sl1[i*chan1];
-      buff2[i] = (mlib_d64)sl2[i*chan1];
-    }
-
-    sl += KSIZE*sll;
-
-    for (j = 0; j < hgt; j++) {
-      mlib_d64 s0, s1;
-
-      p02 = buff0[0];
-      p12 = buff1[0];
-      p22 = buff2[0];
-
-      p03 = buff0[1];
-      p13 = buff1[1];
-      p23 = buff2[1];
-
-      sp = sl;
-      dp = dl;
-
-      s0 = p02 * k0 + p03 * k1 + p12 * k3 + p13 * k4 + p22 * k6 + p23 * k7;
-      s1 = p03 * k0 + p13 * k3 + p23 * k6;
-
-#ifdef __SUNPRO_C
-#pragma pipeloop(0)
-#endif /* __SUNPRO_C */
-      for (i = 0; i <= (wid - 2); i += 2) {
-        p02 = buff0[i + 2]; p12 = buff1[i + 2]; p22 = buff2[i + 2];
-        p03 = buff0[i + 3]; p13 = buff1[i + 3]; p23 = buff2[i + 3];
-
-        buff3[i    ] = (mlib_d64)sp[0];
-        buff3[i + 1] = (mlib_d64)sp[chan1];
-
-        d0 = s0 + p02 * k2 + p12 * k5 + p22 * k8;
-        d1 = s1 + p02 * k1 + p03 * k2 + p12 * k4 + p13 * k5 + p22 * k7 + p23 * k8;
-
-        CLAMP_S32(dp[0    ], d0);
-        CLAMP_S32(dp[chan1], d1);
-
-        s0 = p02 * k0 + p03 * k1 + p12 * k3 + p13 * k4 + p22 * k6 + p23 * k7;
-        s1 = p03 * k0 + p13 * k3 + p23 * k6;
-
-        sp += chan2;
-        dp += chan2;
-      }
-
-      for (; i < wid; i++) {
-        p00 = buff0[i];     p10 = buff1[i];     p20 = buff2[i];
-        p01 = buff0[i + 1]; p11 = buff1[i + 1]; p21 = buff2[i + 1];
-        p02 = buff0[i + 2]; p12 = buff1[i + 2]; p22 = buff2[i + 2];
-
-        buff3[i] = (mlib_d64)sp[0];
-
-        d0 = (p00 * k0 + p01 * k1 + p02 * k2 + p10 * k3 + p11 * k4 +
-              p12 * k5 + p20 * k6 + p21 * k7 + p22 * k8);
-
-        CLAMP_S32(dp[0], d0);
-
-        sp += chan1;
-        dp += chan1;
-      }
-
-      buff3[wid    ] = (mlib_d64)sp[0];
-      buff3[wid + 1] = (mlib_d64)sp[chan1];
-
-      sl += sll;
-      dl += dll;
-
-      buffT = buff0;
-      buff0 = buff1;
-      buff1 = buff2;
-      buff2 = buff3;
-      buff3 = buffT;
-    }
-  }
-
-  if (pbuff != buff) mlib_free(pbuff);
-
-  return MLIB_SUCCESS;
-}
-
-/***************************************************************/
-#undef  KSIZE
-#define KSIZE 4
-
-mlib_status CONV_FUNC(4x4)(mlib_image       *dst,
-                           const mlib_image *src,
-                           const mlib_s32   *kern,
-                           mlib_s32         scalef_expon,
-                           mlib_s32         cmask)
-{
-  mlib_d64 buff[(KSIZE + 2)*BUFF_LINE], *buff3, *buff4, *buff5;
-  mlib_d64 k[KSIZE*KSIZE];
-  mlib_d64 k0, k1, k2, k3, k4, k5, k6, k7;
-  mlib_d64 p00, p01, p02, p03, p04,
-           p10, p11, p12, p13, p14,
-           p20, p21, p22, p23,
-           p30, p31, p32, p33;
-  mlib_s32 *sl2, *sl3;
-  DEF_VARS(mlib_s32);
-  mlib_s32 chan2 = chan1 + chan1;
-
-  if (wid > BUFF_LINE) {
-    pbuff = mlib_malloc((KSIZE + 2)*sizeof(mlib_d64)*wid);
-
-    if (pbuff == NULL) return MLIB_FAILURE;
-  }
-
-  buff0 = pbuff;
-  buff1 = buff0 + wid;
-  buff2 = buff1 + wid;
-  buff3 = buff2 + wid;
-  buff4 = buff3 + wid;
-  buff5 = buff4 + wid;
-
-  wid -= (KSIZE - 1);
-  hgt -= (KSIZE - 1);
-
-  adr_dst += ((KSIZE - 1)/2)*(dll + chan1);
-
-  CALC_SCALE();
-  for (j = 0; j < 16; j++) k[j] = scalef * kern[j];
-
-  for (c = 0; c < chan1; c++) {
-    if (!(cmask & (1 << (chan1 - 1 - c)))) continue;
-
-    sl = adr_src + c;
-    dl = adr_dst + c;
-
-    sl1 = sl  + sll;
-    sl2 = sl1 + sll;
-    sl3 = sl2 + sll;
-#ifdef __SUNPRO_C
-#pragma pipeloop(0)
-#endif /* __SUNPRO_C */
-    for (i = 0; i < wid + (KSIZE - 1); i++) {
-      buff0[i] = (mlib_d64)sl[i*chan1];
-      buff1[i] = (mlib_d64)sl1[i*chan1];
-      buff2[i] = (mlib_d64)sl2[i*chan1];
-      buff3[i] = (mlib_d64)sl3[i*chan1];
-    }
-
-    sl += KSIZE*sll;
-
-    for (j = 0; j < hgt; j++) {
-      /*
-       *  First loop on two first lines of kernel
-       */
-      k0 = k[0]; k1 = k[1]; k2 = k[2]; k3 = k[3];
-      k4 = k[4]; k5 = k[5]; k6 = k[6]; k7 = k[7];
-
-      sp = sl;
-      dp = dl;
-
-      p02 = buff0[0];
-      p12 = buff1[0];
-      p03 = buff0[1];
-      p13 = buff1[1];
-      p04 = buff0[2];
-
-#ifdef __SUNPRO_C
-#pragma pipeloop(0)
-#endif /* __SUNPRO_C */
-      for (i = 0; i <= (wid - 2); i += 2) {
-        p00 = p02; p10 = p12;
-        p01 = p03; p11 = p13;
-        p02 = p04; p12 = buff1[i + 2];
-        p03 = buff0[i + 3]; p13 = buff1[i + 3];
-        p04 = buff0[i + 4]; p14 = buff1[i + 4];
-
-        buff4[i] = (mlib_d64)sp[0];
-        buff4[i + 1] = (mlib_d64)sp[chan1];
-
-        buff5[i    ] = (p00 * k0 + p01 * k1 + p02 * k2 + p03 * k3 +
-                        p10 * k4 + p11 * k5 + p12 * k6 + p13 * k7);
-        buff5[i + 1] = (p01 * k0 + p02 * k1 + p03 * k2 + p04 * k3 +
-                        p11 * k4 + p12 * k5 + p13 * k6 + p14 * k7);
-
-        sp += chan2;
-        dp += chan2;
-      }
-
-      /*
-       *  Second loop on two last lines of kernel
-       */
-      k0 = k[ 8]; k1 = k[ 9]; k2 = k[10]; k3 = k[11];
-      k4 = k[12]; k5 = k[13]; k6 = k[14]; k7 = k[15];
-
-      sp = sl;
-      dp = dl;
-
-      p02 = buff2[0];
-      p12 = buff3[0];
-      p03 = buff2[1];
-      p13 = buff3[1];
-      p04 = buff2[2];
-
-#ifdef __SUNPRO_C
-#pragma pipeloop(0)
-#endif /* __SUNPRO_C */
-      for (i = 0; i <= (wid - 2); i += 2) {
-        p00 = p02; p10 = p12;
-        p01 = p03; p11 = p13;
-        p02 = p04; p12 = buff3[i + 2];
-        p03 = buff2[i + 3]; p13 = buff3[i + 3];
-        p04 = buff2[i + 4]; p14 = buff3[i + 4];
-
-        d0 = (p00 * k0 + p01 * k1 + p02 * k2 + p03 * k3 +
-              p10 * k4 + p11 * k5 + p12 * k6 + p13 * k7 + buff5[i]);
-        d1 = (p01 * k0 + p02 * k1 + p03 * k2 + p04 * k3 +
-              p11 * k4 + p12 * k5 + p13 * k6 + p14 * k7 + buff5[i + 1]);
-
-        CLAMP_S32(dp[0    ], d0);
-        CLAMP_S32(dp[chan1], d1);
-
-        sp += chan2;
-        dp += chan2;
-      }
-
-      /* last pixels */
-      for (; i < wid; i++) {
-        p00 = buff0[i];     p10 = buff1[i];     p20 = buff2[i];     p30 = buff3[i];
-        p01 = buff0[i + 1]; p11 = buff1[i + 1]; p21 = buff2[i + 1]; p31 = buff3[i + 1];
-        p02 = buff0[i + 2]; p12 = buff1[i + 2]; p22 = buff2[i + 2]; p32 = buff3[i + 2];
-        p03 = buff0[i + 3]; p13 = buff1[i + 3]; p23 = buff2[i + 3]; p33 = buff3[i + 3];
-
-        buff4[i] = (mlib_d64)sp[0];
-
-        d0 = (p00 * k[0] + p01 * k[1] + p02 * k[2] + p03 * k[3] +
-              p10 * k[4] + p11 * k[5] + p12 * k[6] + p13 * k[7] +
-              p20 * k[ 8] + p21 * k[ 9] + p22 * k[10] + p23 * k[11] +
-              p30 * k[12] + p31 * k[13] + p32 * k[14] + p33 * k[15]);
-
-        CLAMP_S32(dp[0], d0);
-
-        sp += chan1;
-        dp += chan1;
-      }
-
-      buff4[wid    ] = (mlib_d64)sp[0];
-      buff4[wid + 1] = (mlib_d64)sp[chan1];
-      buff4[wid + 2] = (mlib_d64)sp[chan2];
-
-      /* next line */
-      sl += sll;
-      dl += dll;
-
-      buffT = buff0;
-      buff0 = buff1;
-      buff1 = buff2;
-      buff2 = buff3;
-      buff3 = buff4;
-      buff4 = buffT;
-    }
-  }
-
-  if (pbuff != buff) mlib_free(pbuff);
-
-  return MLIB_SUCCESS;
-}
-
-/***************************************************************/
-#undef  KSIZE
-#define KSIZE 5
-
-mlib_status CONV_FUNC(5x5)(mlib_image       *dst,
-                           const mlib_image *src,
-                           const mlib_s32   *kern,
-                           mlib_s32         scalef_expon,
-                           mlib_s32         cmask)
-{
-  mlib_d64 buff[(KSIZE + 2)*BUFF_LINE], *buff3, *buff4, *buff5, *buff6;
-  mlib_d64 k[KSIZE*KSIZE];
-  mlib_d64 k0, k1, k2, k3, k4, k5, k6, k7, k8, k9;
-  mlib_d64 p00, p01, p02, p03, p04, p05,
-           p10, p11, p12, p13, p14, p15,
-           p20, p21, p22, p23, p24,
-           p30, p31, p32, p33, p34,
-           p40, p41, p42, p43, p44;
-  mlib_s32 *sl2, *sl3, *sl4;
-  DEF_VARS(mlib_s32);
-  mlib_s32 chan2 = chan1 + chan1;
-  mlib_s32 chan3 = chan1 + chan2;
-
-  if (wid > BUFF_LINE) {
-    pbuff = mlib_malloc((KSIZE + 2)*sizeof(mlib_d64)*wid);
-
-    if (pbuff == NULL) return MLIB_FAILURE;
-  }
-
-  buff0 = pbuff;
-  buff1 = buff0 + wid;
-  buff2 = buff1 + wid;
-  buff3 = buff2 + wid;
-  buff4 = buff3 + wid;
-  buff5 = buff4 + wid;
-  buff6 = buff5 + wid;
-
-  wid -= (KSIZE - 1);
-  hgt -= (KSIZE - 1);
-
-  adr_dst += ((KSIZE - 1)/2)*(dll + chan1);
-
-  CALC_SCALE();
-  for (j = 0; j < 25; j++) k[j] = scalef * kern[j];
-
-  for (c = 0; c < chan1; c++) {
-    if (!(cmask & (1 << (chan1 - 1 - c)))) continue;
-
-    sl = adr_src + c;
-    dl = adr_dst + c;
-
-    sl1 = sl  + sll;
-    sl2 = sl1 + sll;
-    sl3 = sl2 + sll;
-    sl4 = sl3 + sll;
-#ifdef __SUNPRO_C
-#pragma pipeloop(0)
-#endif /* __SUNPRO_C */
-    for (i = 0; i < wid + (KSIZE - 1); i++) {
-      buff0[i] = (mlib_d64)sl[i*chan1];
-      buff1[i] = (mlib_d64)sl1[i*chan1];
-      buff2[i] = (mlib_d64)sl2[i*chan1];
-      buff3[i] = (mlib_d64)sl3[i*chan1];
-      buff4[i] = (mlib_d64)sl4[i*chan1];
-    }
-
-    sl += KSIZE*sll;
-
-    for (j = 0; j < hgt; j++) {
-      /*
-       *  First loop
-       */
-      k0 = k[0]; k1 = k[1]; k2 = k[2]; k3 = k[3]; k4 = k[4];
-      k5 = k[5]; k6 = k[6]; k7 = k[7]; k8 = k[8]; k9 = k[9];
-
-      sp = sl;
-      dp = dl;
-
-      p02 = buff0[0];
-      p12 = buff1[0];
-      p03 = buff0[1];
-      p13 = buff1[1];
-      p04 = buff0[2];
-      p14 = buff1[2];
-
-#ifdef __SUNPRO_C
-#pragma pipeloop(0)
-#endif /* __SUNPRO_C */
-      for (i = 0; i <= (wid - 2); i += 2) {
-        p00 = p02; p10 = p12;
-        p01 = p03; p11 = p13;
-        p02 = p04; p12 = p14;
-
-        p03 = buff0[i + 3]; p13 = buff1[i + 3];
-        p04 = buff0[i + 4]; p14 = buff1[i + 4];
-        p05 = buff0[i + 5]; p15 = buff1[i + 5];
-
-        buff6[i    ] = (p00 * k0 + p01 * k1 + p02 * k2 + p03 * k3 + p04 * k4 +
-                        p10 * k5 + p11 * k6 + p12 * k7 + p13 * k8 + p14 * k9);
-        buff6[i + 1] = (p01 * k0 + p02 * k1 + p03 * k2 + p04 * k3 + p05 * k4 +
-                        p11 * k5 + p12 * k6 + p13 * k7 + p14 * k8 + p15 * k9);
-
-        sp += chan2;
-        dp += chan2;
-      }
-
-      /*
-       *  Second loop
-       */
-      k0 = k[10]; k1 = k[11]; k2 = k[12]; k3 = k[13]; k4 = k[14];
-      k5 = k[15]; k6 = k[16]; k7 = k[17]; k8 = k[18]; k9 = k[19];
-
-      sp = sl;
-      dp = dl;
-
-      p02 = buff2[0];
-      p12 = buff3[0];
-      p03 = buff2[1];
-      p13 = buff3[1];
-
-#ifdef __SUNPRO_C
-#pragma pipeloop(0)
-#endif /* __SUNPRO_C */
-      for (i = 0; i <= (wid - 2); i += 2) {
-        p00 = p02; p10 = p12;
-        p01 = p03; p11 = p13;
-
-        p02 = buff2[i + 2]; p12 = buff3[i + 2];
-        p03 = buff2[i + 3]; p13 = buff3[i + 3];
-        p04 = buff2[i + 4]; p14 = buff3[i + 4];
-        p05 = buff2[i + 5]; p15 = buff3[i + 5];
-
-        buff6[i    ] += (p00 * k0 + p01 * k1 + p02 * k2 + p03 * k3 + p04 * k4 +
-                         p10 * k5 + p11 * k6 + p12 * k7 + p13 * k8 + p14 * k9);
-        buff6[i + 1] += (p01 * k0 + p02 * k1 + p03 * k2 + p04 * k3 + p05 * k4 +
-                         p11 * k5 + p12 * k6 + p13 * k7 + p14 * k8 + p15 * k9);
-
-        sp += chan2;
-        dp += chan2;
-      }
-
-      /*
-       *  3 loop
-       */
-      k0 = k[20]; k1 = k[21]; k2 = k[22]; k3 = k[23]; k4 = k[24];
-
-      sp = sl;
-      dp = dl;
-
-      p02 = buff4[0];
-      p03 = buff4[1];
-      p04 = buff4[2];
-      p05 = buff4[3];
-
-#ifdef __SUNPRO_C
-#pragma pipeloop(0)
-#endif /* __SUNPRO_C */
-      for (i = 0; i <= (wid - 2); i += 2) {
-        p00 = p02; p01 = p03; p02 = p04; p03 = p05;
-
-        p04 = buff4[i + 4]; p05 = buff4[i + 5];
-
-        buff5[i    ] = (mlib_d64)sp[0];
-        buff5[i + 1] = (mlib_d64)sp[chan1];
-
-        d0 = p00 * k0 + p01 * k1 + p02 * k2 + p03 * k3 + p04 * k4 + buff6[i];
-        d1 = p01 * k0 + p02 * k1 + p03 * k2 + p04 * k3 + p05 * k4 + buff6[i + 1];
-
-        CLAMP_S32(dp[0    ], d0);
-        CLAMP_S32(dp[chan1], d1);
-
-        sp += chan2;
-        dp += chan2;
-      }
-
-      /* last pixels */
-      for (; i < wid; i++) {
-        p00 = buff0[i];     p10 = buff1[i];     p20 = buff2[i];     p30 = buff3[i];
-        p01 = buff0[i + 1]; p11 = buff1[i + 1]; p21 = buff2[i + 1]; p31 = buff3[i + 1];
-        p02 = buff0[i + 2]; p12 = buff1[i + 2]; p22 = buff2[i + 2]; p32 = buff3[i + 2];
-        p03 = buff0[i + 3]; p13 = buff1[i + 3]; p23 = buff2[i + 3]; p33 = buff3[i + 3];
-        p04 = buff0[i + 4]; p14 = buff1[i + 4]; p24 = buff2[i + 4]; p34 = buff3[i + 4];
-
-        p40 = buff4[i];        p41 = buff4[i + 1]; p42 = buff4[i + 2];
-        p43 = buff4[i + 3]; p44 = buff4[i + 4];
-
-        buff5[i] = (mlib_d64)sp[0];
-
-        d0 = (p00 * k[0] + p01 * k[1] + p02 * k[2] + p03 * k[3] + p04 * k[4] +
-              p10 * k[5] + p11 * k[6] + p12 * k[7] + p13 * k[8] + p14 * k[9] +
-              p20 * k[10] + p21 * k[11] + p22 * k[12] + p23 * k[13] + p24 * k[14] +
-              p30 * k[15] + p31 * k[16] + p32 * k[17] + p33 * k[18] + p34 * k[19] +
-              p40 * k[20] + p41 * k[21] + p42 * k[22] + p43 * k[23] + p44 * k[24]);
-
-        CLAMP_S32(dp[0], d0);
-
-        sp += chan1;
-        dp += chan1;
-      }
-
-      buff5[wid    ] = (mlib_d64)sp[0];
-      buff5[wid + 1] = (mlib_d64)sp[chan1];
-      buff5[wid + 2] = (mlib_d64)sp[chan2];
-      buff5[wid + 3] = (mlib_d64)sp[chan3];
-
-      /* next line */
-      sl += sll;
-      dl += dll;
-
-      buffT = buff0;
-      buff0 = buff1;
-      buff1 = buff2;
-      buff2 = buff3;
-      buff3 = buff4;
-      buff4 = buff5;
-      buff5 = buffT;
-    }
-  }
-
-  if (pbuff != buff) mlib_free(pbuff);
-
-  return MLIB_SUCCESS;
-}
-
-/***************************************************************/
-#undef  KSIZE
-#define KSIZE 7
-
-mlib_status CONV_FUNC(7x7)(mlib_image       *dst,
-                           const mlib_image *src,
-                           const mlib_s32   *kern,
-                           mlib_s32         scalef_expon,
-                           mlib_s32         cmask)
-{
-  mlib_d64 buff[(KSIZE + 2)*BUFF_LINE], *buffs[2*(KSIZE + 1)], *buffd;
-  mlib_d64 k[KSIZE*KSIZE];
-  mlib_d64 k0, k1, k2, k3, k4, k5, k6;
-  mlib_d64 p0, p1, p2, p3, p4, p5, p6, p7;
-  mlib_d64 d0, d1;
-  mlib_s32 l, m, buff_ind, *sl2, *sl3, *sl4, *sl5, *sl6;
-  mlib_d64 scalef;
-  DEF_VARS_MxN(mlib_s32);
-  mlib_s32 chan2 = chan1 + chan1;
-  mlib_s32 *sl1;
-
-  if (wid > BUFF_LINE) {
-    pbuff = mlib_malloc((KSIZE + 2)*sizeof(mlib_d64)*wid);
-
-    if (pbuff == NULL) return MLIB_FAILURE;
-  }
-
-  for (l = 0; l < KSIZE + 1; l++) buffs[l] = pbuff + l*wid;
-  for (l = 0; l < KSIZE + 1; l++) buffs[l + (KSIZE + 1)] = buffs[l];
-  buffd = buffs[KSIZE] + wid;
-
-  wid -= (KSIZE - 1);
-  hgt -= (KSIZE - 1);
-
-  adr_dst += ((KSIZE - 1)/2)*(dll + chan1);
-
-  CALC_SCALE();
-  for (j = 0; j < 49; j++) k[j] = scalef * kern[j];
-
-  for (c = 0; c < chan1; c++) {
-    if (!(cmask & (1 << (chan1 - 1 - c)))) continue;
-
-    sl = adr_src + c;
-    dl = adr_dst + c;
-
-    sl1 = sl  + sll;
-    sl2 = sl1 + sll;
-    sl3 = sl2 + sll;
-    sl4 = sl3 + sll;
-    sl5 = sl4 + sll;
-    sl6 = sl5 + sll;
-#ifdef __SUNPRO_C
-#pragma pipeloop(0)
-#endif /* __SUNPRO_C */
-    for (i = 0; i < wid + (KSIZE - 1); i++) {
-      buffs[0][i] = (mlib_d64)sl[i*chan1];
-      buffs[1][i] = (mlib_d64)sl1[i*chan1];
-      buffs[2][i] = (mlib_d64)sl2[i*chan1];
-      buffs[3][i] = (mlib_d64)sl3[i*chan1];
-      buffs[4][i] = (mlib_d64)sl4[i*chan1];
-      buffs[5][i] = (mlib_d64)sl5[i*chan1];
-      buffs[6][i] = (mlib_d64)sl6[i*chan1];
-    }
-
-    buff_ind = 0;
-
-#ifdef __SUNPRO_C
-#pragma pipeloop(0)
-#endif /* __SUNPRO_C */
-    for (i = 0; i < wid; i++) buffd[i] = 0.0;
-
-    sl += KSIZE*sll;
-
-    for (j = 0; j < hgt; j++) {
-      mlib_d64 **buffc = buffs + buff_ind;
-      mlib_d64 *buffn = buffc[KSIZE];
-      mlib_d64 *pk = k;
-
-      for (l = 0; l < KSIZE; l++) {
-        mlib_d64 *buff = buffc[l];
-
-        sp = sl;
-        dp = dl;
-
-        p2 = buff[0]; p3 = buff[1]; p4 = buff[2];
-        p5 = buff[3]; p6 = buff[4]; p7 = buff[5];
-
-        k0 = *pk++; k1 = *pk++; k2 = *pk++; k3 = *pk++;
-        k4 = *pk++; k5 = *pk++; k6 = *pk++;
-
-        if (l < (KSIZE - 1)) {
-#ifdef __SUNPRO_C
-#pragma pipeloop(0)
-#endif /* __SUNPRO_C */
-          for (i = 0; i <= (wid - 2); i += 2) {
-            p0 = p2; p1 = p3; p2 = p4; p3 = p5; p4 = p6; p5 = p7;
-
-            p6 = buff[i + 6]; p7 = buff[i + 7];
-
-            buffd[i    ] += p0*k0 + p1*k1 + p2*k2 + p3*k3 + p4*k4 + p5*k5 + p6*k6;
-            buffd[i + 1] += p1*k0 + p2*k1 + p3*k2 + p4*k3 + p5*k4 + p6*k5 + p7*k6;
-          }
-
-        } else {
-#ifdef __SUNPRO_C
-#pragma pipeloop(0)
-#endif /* __SUNPRO_C */
-          for (i = 0; i <= (wid - 2); i += 2) {
-            p0 = p2; p1 = p3; p2 = p4; p3 = p5; p4 = p6; p5 = p7;
-
-            p6 = buff[i + 6]; p7 = buff[i + 7];
-
-            buffn[i    ] = (mlib_d64)sp[0];
-            buffn[i + 1] = (mlib_d64)sp[chan1];
-
-            d0 = p0*k0 + p1*k1 + p2*k2 + p3*k3 + p4*k4 + p5*k5 + p6*k6 + buffd[i    ];
-            d1 = p1*k0 + p2*k1 + p3*k2 + p4*k3 + p5*k4 + p6*k5 + p7*k6 + buffd[i + 1];
-
-            CLAMP_S32(dp[0    ], d0);
-            CLAMP_S32(dp[chan1], d1);
-
-            buffd[i    ] = 0.0;
-            buffd[i + 1] = 0.0;
-
-            sp += chan2;
-            dp += chan2;
-          }
-        }
-      }
-
-      /* last pixels */
-      for (; i < wid; i++) {
-        mlib_d64 *pk = k, s = 0;
-
-        for (l = 0; l < KSIZE; l++) {
-          mlib_d64 *buff = buffc[l] + i;
-
-          for (m = 0; m < KSIZE; m++) s += buff[m] * (*pk++);
-        }
-
-        CLAMP_S32(dp[0], s);
-
-        buffn[i] = (mlib_d64)sp[0];
-
-        sp += chan1;
-        dp += chan1;
-      }
-
-      for (l = 0; l < (KSIZE - 1); l++) buffn[wid + l] = sp[l*chan1];
-
-      /* next line */
-      sl += sll;
-      dl += dll;
-
-      buff_ind++;
-
-      if (buff_ind >= KSIZE + 1) buff_ind = 0;
-    }
-  }
-
-  if (pbuff != buff) mlib_free(pbuff);
-
-  return MLIB_SUCCESS;
-}
-
-/***************************************************************/
 #define FTYPE  mlib_d64
 #define DTYPE  mlib_s32
 
--- a/jdk/src/java.desktop/share/native/libmlib_image/mlib_ImageConv_8ext.c	Thu May 19 17:48:02 2016 +0000
+++ b/jdk/src/java.desktop/share/native/libmlib_image/mlib_ImageConv_8ext.c	Thu May 19 19:46:20 2016 +0000
@@ -80,9 +80,6 @@
 #endif /* IMG_TYPE == 1 */
 
 /***************************************************************/
-#define KSIZE1 (KSIZE - 1)
-
-/***************************************************************/
 #define PARAM                                                   \
   mlib_image       *dst,                                        \
   const mlib_image *src,                                        \
@@ -126,21 +123,6 @@
 #define D2I(x) CLAMP_S32((x) SAT_OFF)
 
 /***************************************************************/
-#ifdef _LITTLE_ENDIAN
-
-#define STORE2(res0, res1)                                      \
-  dp[0    ] = res1;                                             \
-  dp[chan1] = res0
-
-#else
-
-#define STORE2(res0, res1)                                      \
-  dp[0    ] = res0;                                             \
-  dp[chan1] = res1
-
-#endif /* _LITTLE_ENDIAN */
-
-/***************************************************************/
 #ifdef _NO_LONGLONG
 
 #define LOAD_BUFF(buff)                                         \
@@ -163,9 +145,6 @@
 #endif /* _NO_LONGLONG */
 
 /***************************************************************/
-#define MLIB_D2_24 16777216.0f
-
-/***************************************************************/
 typedef union {
   mlib_d64 d64;
   struct {
@@ -175,52 +154,6 @@
 } d64_2x32;
 
 /***************************************************************/
-#define BUFF_LINE 256
-
-/***************************************************************/
-#define DEF_VARS(type)                                          \
-  type     *adr_src, *sl, *sp, *sl1;                            \
-  type     *adr_dst, *dl, *dp;                                  \
-  FTYPE    *pbuff = buff;                                       \
-  mlib_s32 *buffi, *buffo;                                      \
-  mlib_s32 wid, hgt, sll, dll;                                  \
-  mlib_s32 nchannel, chan1, chan2;                              \
-  mlib_s32 i, j, c, swid
-
-/***************************************************************/
-#define LOAD_KERNEL3()                                                   \
-  FTYPE    scalef = DSCALE;                                              \
-  FTYPE    k0, k1, k2, k3, k4, k5, k6, k7, k8;                           \
-  FTYPE    p00, p01, p02, p03,                                           \
-           p10, p11, p12, p13,                                           \
-           p20, p21, p22, p23;                                           \
-                                                                         \
-  while (scalef_expon > 30) {                                            \
-    scalef /= (1 << 30);                                                 \
-    scalef_expon -= 30;                                                  \
-  }                                                                      \
-                                                                         \
-  scalef /= (1 << scalef_expon);                                         \
-                                                                         \
-  /* keep kernel in regs */                                              \
-  k0 = scalef * kern[0];  k1 = scalef * kern[1];  k2 = scalef * kern[2]; \
-  k3 = scalef * kern[3];  k4 = scalef * kern[4];  k5 = scalef * kern[5]; \
-  k6 = scalef * kern[6];  k7 = scalef * kern[7];  k8 = scalef * kern[8]
-
-/***************************************************************/
-#define LOAD_KERNEL(SIZE)                                       \
-  FTYPE    scalef = DSCALE;                                     \
-                                                                \
-  while (scalef_expon > 30) {                                   \
-    scalef /= (1 << 30);                                        \
-    scalef_expon -= 30;                                         \
-  }                                                             \
-                                                                \
-  scalef /= (1 << scalef_expon);                                \
-                                                                \
-  for (j = 0; j < SIZE; j++) k[j] = scalef * kern[j]
-
-/***************************************************************/
 #define GET_SRC_DST_PARAMETERS(type)                            \
   hgt = mlib_ImageGetHeight(src);                               \
   wid = mlib_ImageGetWidth(src);                                \
@@ -278,1334 +211,6 @@
 #endif /* __sparc */
 
 /***************************************************************/
-#define KSIZE  3
-
-mlib_status CONV_FUNC(3x3)
-{
-  FTYPE    buff[(KSIZE + 2)*BUFF_LINE], *buff0, *buff1, *buff2, *buff3, *buffT;
-  DEF_VARS(DTYPE);
-  DTYPE *sl2;
-#ifndef __sparc
-  mlib_s32 d0, d1;
-#endif /* __sparc */
-  LOAD_KERNEL3();
-  GET_SRC_DST_PARAMETERS(DTYPE);
-
-  swid = wid + KSIZE1;
-
-  if (swid > BUFF_LINE) {
-    pbuff = mlib_malloc((KSIZE + 2)*sizeof(FTYPE   )*swid);
-
-    if (pbuff == NULL) return MLIB_FAILURE;
-  }
-
-  buff0 = pbuff;
-  buff1 = buff0 + swid;
-  buff2 = buff1 + swid;
-  buff3 = buff2 + swid;
-  buffo = (mlib_s32*)(buff3 + swid);
-  buffi = buffo + (swid &~ 1);
-
-  swid -= (dx_l + dx_r);
-
-  chan1 = nchannel;
-  chan2 = chan1 + chan1;
-
-  for (c = 0; c < nchannel; c++) {
-    if (!(cmask & (1 << (nchannel - 1 - c)))) continue;
-
-    sl = adr_src + c;
-    dl = adr_dst + c;
-
-    if ((1 > dy_t) && (1 < hgt + KSIZE1 - dy_b)) sl1 = sl + sll;
-    else sl1 = sl;
-
-    if ((hgt - dy_b) > 0) sl2 = sl1 + sll;
-    else sl2 = sl1;
-
-    for (i = 0; i < dx_l; i++) {
-      buff0[i] = (FTYPE)sl[0];
-      buff1[i] = (FTYPE)sl1[0];
-      buff2[i] = (FTYPE)sl2[0];
-    }
-
-#ifdef __SUNPRO_C
-#pragma pipeloop(0)
-#endif /* __SUNPRO_C */
-    for (i = 0; i < swid; i++) {
-      buff0[i + dx_l] = (FTYPE)sl[i*chan1];
-      buff1[i + dx_l] = (FTYPE)sl1[i*chan1];
-      buff2[i + dx_l] = (FTYPE)sl2[i*chan1];
-    }
-
-    for (i = 0; i < dx_r; i++) {
-      buff0[swid + dx_l + i] = buff0[swid + dx_l - 1];
-      buff1[swid + dx_l + i] = buff1[swid + dx_l - 1];
-      buff2[swid + dx_l + i] = buff2[swid + dx_l - 1];
-    }
-
-    if ((hgt - dy_b) > 1) sl = sl2 + sll;
-    else sl = sl2;
-
-    for (j = 0; j < hgt; j++) {
-      FTYPE    s0, s1;
-
-      p02 = buff0[0];
-      p12 = buff1[0];
-      p22 = buff2[0];
-
-      p03 = buff0[1];
-      p13 = buff1[1];
-      p23 = buff2[1];
-
-      s0 = p02 * k0 + p03 * k1 + p12 * k3 + p13 * k4 + p22 * k6 + p23 * k7;
-      s1 = p03 * k0 + p13 * k3 + p23 * k6;
-
-      sp = sl;
-      dp = dl;
-
-#ifdef __SUNPRO_C
-#pragma pipeloop(0)
-#endif /* __SUNPRO_C */
-      for (i = 0; i <= (wid - 2); i += 2) {
-#ifdef __sparc
-#ifdef _NO_LONGLONG
-        mlib_s32 o64_1, o64_2;
-#else /* _NO_LONGLONG */
-        mlib_s64 o64;
-#endif /* _NO_LONGLONG */
-#endif /* __sparc */
-        d64_2x32 dd;
-
-        p02 = buff0[i + 2]; p12 = buff1[i + 2]; p22 = buff2[i + 2];
-        p03 = buff0[i + 3]; p13 = buff1[i + 3]; p23 = buff2[i + 3];
-
-        LOAD_BUFF(buffi);
-
-        dd.d64 = *(FTYPE   *)(buffi + i);
-        buff3[i + dx_l    ] = (FTYPE)dd.i32s.i0;
-        buff3[i + dx_l + 1] = (FTYPE)dd.i32s.i1;
-
-#ifndef __sparc
-
-        d0 = D2I(s0 + p02 * k2 + p12 * k5 + p22 * k8);
-        d1 = D2I(s1 + p02 * k1 + p03 * k2 + p12 * k4 + p13 * k5 + p22 * k7 + p23 * k8);
-
-        s0 = p02 * k0 + p03 * k1 + p12 * k3 + p13 * k4 + p22 * k6 + p23 * k7;
-        s1 = p03 * k0 + p13 * k3 + p23 * k6;
-
-        dp[0    ] = FROM_S32(d0);
-        dp[chan1] = FROM_S32(d1);
-
-#else /* __sparc */
-
-        dd.i32s.i0 = D2I(s0 + p02 * k2 + p12 * k5 + p22 * k8);
-        dd.i32s.i1 = D2I(s1 + p02 * k1 + p03 * k2 + p12 * k4 + p13 * k5 + p22 * k7 + p23 * k8);
-        *(FTYPE   *)(buffo + i) = dd.d64;
-
-        s0 = p02 * k0 + p03 * k1 + p12 * k3 + p13 * k4 + p22 * k6 + p23 * k7;
-        s1 = p03 * k0 + p13 * k3 + p23 * k6;
-
-#ifdef _NO_LONGLONG
-
-        o64_1 = buffo[i];
-        o64_2 = buffo[i+1];
-#if IMG_TYPE != 1
-        STORE2(FROM_S32(o64_1), FROM_S32(o64_2));
-#else
-        STORE2(o64_1 >> 24, o64_2 >> 24);
-#endif /* IMG_TYPE != 1 */
-
-#else /* _NO_LONGLONG */
-
-        o64 = *(mlib_s64*)(buffo + i);
-#if IMG_TYPE != 1
-        STORE2(FROM_S32(o64 >> 32), FROM_S32(o64));
-#else
-        STORE2(o64 >> 56, o64 >> 24);
-#endif /* IMG_TYPE != 1 */
-#endif /* _NO_LONGLONG */
-#endif /* __sparc */
-
-        sp += chan2;
-        dp += chan2;
-      }
-
-      for (; i < wid; i++) {
-        p00 = buff0[i];     p10 = buff1[i];     p20 = buff2[i];
-        p01 = buff0[i + 1]; p11 = buff1[i + 1]; p21 = buff2[i + 1];
-        p02 = buff0[i + 2]; p12 = buff1[i + 2]; p22 = buff2[i + 2];
-
-        buffi[i] = (mlib_s32)sp[0];
-        buff3[i + dx_l] = (FTYPE)buffi[i];
-
-#ifndef __sparc
-
-        d0 = D2I(p00 * k0 + p01 * k1 + p02 * k2 + p10 * k3 + p11 * k4 +
-                 p12 * k5 + p20 * k6 + p21 * k7 + p22 * k8);
-
-        dp[0] = FROM_S32(d0);
-
-#else  /* __sparc */
-
-        buffo[i] = D2I(p00 * k0 + p01 * k1 + p02 * k2 + p10 * k3 + p11 * k4 +
-                       p12 * k5 + p20 * k6 + p21 * k7 + p22 * k8);
-#if IMG_TYPE != 1
-        dp[0] = FROM_S32(buffo[i]);
-#else
-        dp[0] = buffo[i] >> 24;
-#endif /* IMG_TYPE != 1 */
-#endif /* __sparc */
-
-        sp += chan1;
-        dp += chan1;
-      }
-
-      for (; i < swid; i++) {
-        buffi[i] = (mlib_s32)sp[0];
-        buff3[i + dx_l] = (FTYPE)buffi[i];
-        sp += chan1;
-      }
-
-      for (i = 0; i < dx_l; i++) buff3[i] = buff3[dx_l];
-      for (i = 0; i < dx_r; i++) buff3[swid + dx_l + i] = buff3[swid + dx_l - 1];
-
-      if (j < hgt - dy_b - 2) sl += sll;
-      dl += dll;
-
-      buffT = buff0;
-      buff0 = buff1;
-      buff1 = buff2;
-      buff2 = buff3;
-      buff3 = buffT;
-    }
-  }
-
-#ifdef __sparc
-#if IMG_TYPE == 1
-  {
-    mlib_s32 amask = (1 << nchannel) - 1;
-
-    if ((cmask & amask) != amask) {
-      mlib_ImageXor80(adr_dst, wid, hgt, dll, nchannel, cmask);
-    } else {
-      mlib_ImageXor80_aa(adr_dst, wid*nchannel, hgt, dll);
-    }
-  }
-
-#endif /* IMG_TYPE == 1 */
-#endif /* __sparc */
-
-  if (pbuff != buff) mlib_free(pbuff);
-
-  return MLIB_SUCCESS;
-}
-
-/***************************************************************/
-#ifndef __sparc /* for x86, using integer multiplies is faster */
-
-mlib_status CONV_FUNC_I(3x3)
-{
-  DTYPE    *adr_src, *sl, *sp0, *sp1, *sp2, *sp_1, *sp_2;
-  DTYPE    *adr_dst, *dl, *dp;
-  mlib_s32 wid, hgt, sll, dll;
-  mlib_s32 nchannel, chan1, chan2, delta_chan;
-  mlib_s32 i, j, c;
-  mlib_s32 shift1, shift2;
-  mlib_s32 k0, k1, k2, k3, k4, k5, k6, k7, k8;
-  mlib_s32 p02, p03,
-           p12, p13,
-           p22, p23;
-
-#if IMG_TYPE != 1
-  shift1 = 16;
-#else
-  shift1 = 8;
-#endif /* IMG_TYPE != 1 */
-
-  shift2 = scalef_expon - shift1;
-
-  /* keep kernel in regs */
-  k0 = kern[0] >> shift1;  k1 = kern[1] >> shift1;  k2 = kern[2] >> shift1;
-  k3 = kern[3] >> shift1;  k4 = kern[4] >> shift1;  k5 = kern[5] >> shift1;
-  k6 = kern[6] >> shift1;  k7 = kern[7] >> shift1;  k8 = kern[8] >> shift1;
-
-  GET_SRC_DST_PARAMETERS(DTYPE);
-
-  chan1 = nchannel;
-  chan2 = chan1 + chan1;
-  delta_chan = 0;
-
-  if ((1 > dx_l) && (1 < wid + KSIZE1 - dx_r)) delta_chan = chan1;
-
-  for (c = 0; c < chan1; c++) {
-    if (!(cmask & (1 << (chan1 - 1 - c)))) continue;
-
-    sl = adr_src + c;
-    dl = adr_dst + c;
-
-    sp_1 = sl;
-
-    if ((1 > dy_t) && (1 < hgt + KSIZE1 - dy_b)) sl += sll;
-    sp_2 = sl;
-
-    if ((hgt - dy_b) > 0) sl += sll;
-
-    for (j = 0; j < hgt; j++) {
-      mlib_s32 s0, s1;
-      mlib_s32 pix0, pix1;
-
-      dp  = dl;
-      sp0 = sp_1;
-      sp_1 = sp_2;
-      sp_2 = sl;
-
-      sp1 = sp_1;
-      sp2 = sp_2;
-
-      p02 = sp0[0];
-      p12 = sp1[0];
-      p22 = sp2[0];
-
-      p03 = sp0[delta_chan];
-      p13 = sp1[delta_chan];
-      p23 = sp2[delta_chan];
-
-      s0 = p02 * k0 + p03 * k1 + p12 * k3 + p13 * k4 + p22 * k6 + p23 * k7;
-      s1 = p03 * k0 + p13 * k3 + p23 * k6;
-
-      sp0 += (chan1 + delta_chan);
-      sp1 += (chan1 + delta_chan);
-      sp2 += (chan1 + delta_chan);
-
-#ifdef __SUNPRO_C
-#pragma pipeloop(0)
-#endif /* __SUNPRO_C */
-      for (i = 0; i <= (wid - dx_r - 2); i += 2) {
-        p02 = sp0[0];     p12 = sp1[0];     p22 = sp2[0];
-        p03 = sp0[chan1]; p13 = sp1[chan1]; p23 = sp2[chan1];
-
-        pix0 = (s0 + p02 * k2 + p12 * k5 + p22 * k8) >> shift2;
-        pix1 = (s1 + p02 * k1 + p03 * k2 + p12 * k4 +
-                p13 * k5 + p22 * k7 + p23 * k8) >> shift2;
-
-        CLAMP_STORE(dp[0],     pix0)
-        CLAMP_STORE(dp[chan1], pix1)
-
-        s0 = p02 * k0 + p03 * k1 + p12 * k3 + p13 * k4 + p22 * k6 + p23 * k7;
-        s1 = p03 * k0 + p13 * k3 + p23 * k6;
-
-        sp0 += chan2;
-        sp1 += chan2;
-        sp2 += chan2;
-        dp += chan2;
-      }
-
-      p02 = p03; p12 = p13; p22 = p23;
-
-      for (; i < wid - dx_r; i++) {
-        p03 = sp0[0]; p13 = sp1[0]; p23 = sp2[0];
-        pix0 = (s0 + p03 * k2 + p13 * k5 + p23 * k8) >> shift2;
-        CLAMP_STORE(dp[0], pix0)
-        s0 = p02 * k0 + p03 * k1 + p12 * k3 + p13 * k4 + p22 * k6 + p23 * k7;
-        p02 = p03; p12 = p13; p22 = p23;
-        sp0 += chan1;
-        sp1 += chan1;
-        sp2 += chan1;
-        dp += chan1;
-      }
-
-      sp0 -= chan1;
-      sp1 -= chan1;
-      sp2 -= chan1;
-
-      for (; i < wid; i++) {
-        p03 = sp0[0]; p13 = sp1[0]; p23 = sp2[0];
-        pix0 = (s0 + p03 * k2 + p13 * k5 + p23 * k8) >> shift2;
-        CLAMP_STORE(dp[0], pix0)
-        s0 = p02 * k0 + p03 * k1 + p12 * k3 + p13 * k4 + p22 * k6 + p23 * k7;
-        p02 = p03; p12 = p13; p22 = p23;
-        dp += chan1;
-      }
-
-      if (j < hgt - dy_b - 1) sl += sll;
-      dl += dll;
-    }
-  }
-
-  return MLIB_SUCCESS;
-}
-
-#endif /* __sparc ( for x86, using integer multiplies is faster ) */
-
-/***************************************************************/
-#undef  KSIZE
-#define KSIZE 4
-
-mlib_status CONV_FUNC(4x4)
-{
-  FTYPE    buff[(KSIZE + 3)*BUFF_LINE];
-  FTYPE    *buff0, *buff1, *buff2, *buff3, *buff4, *buffd, *buffT;
-  FTYPE    k[KSIZE*KSIZE];
-  mlib_s32 d0, d1;
-  FTYPE    k0, k1, k2, k3, k4, k5, k6, k7;
-  FTYPE    p00, p01, p02, p03, p04,
-           p10, p11, p12, p13, p14,
-           p20, p21, p22, p23,
-           p30, p31, p32, p33;
-  DEF_VARS(DTYPE);
-  DTYPE *sl2, *sl3;
-  LOAD_KERNEL(KSIZE*KSIZE);
-  GET_SRC_DST_PARAMETERS(DTYPE);
-
-  swid = wid + KSIZE1;
-
-  if (swid > BUFF_LINE) {
-    pbuff = mlib_malloc((KSIZE + 3)*sizeof(FTYPE   )*swid);
-
-    if (pbuff == NULL) return MLIB_FAILURE;
-  }
-
-  buff0 = pbuff;
-  buff1 = buff0 + swid;
-  buff2 = buff1 + swid;
-  buff3 = buff2 + swid;
-  buff4 = buff3 + swid;
-  buffd = buff4 + swid;
-  buffo = (mlib_s32*)(buffd + swid);
-  buffi = buffo + (swid &~ 1);
-
-  swid -= (dx_l + dx_r);
-
-  chan1 = nchannel;
-  chan2 = chan1 + chan1;
-
-  for (c = 0; c < nchannel; c++) {
-    if (!(cmask & (1 << (nchannel - 1 - c)))) continue;
-
-    sl = adr_src + c;
-    dl = adr_dst + c;
-
-    if ((1 > dy_t) && (1 < hgt + KSIZE1 - dy_b)) sl1 = sl + sll;
-    else sl1 = sl;
-
-    if ((2 > dy_t) && (2 < hgt + KSIZE1 - dy_b)) sl2 = sl1 + sll;
-    else sl2 = sl1;
-
-    if ((hgt - dy_b) > 0) sl3 = sl2 + sll;
-    else sl3 = sl2;
-
-    for (i = 0; i < dx_l; i++) {
-      buff0[i] = (FTYPE)sl[0];
-      buff1[i] = (FTYPE)sl1[0];
-      buff2[i] = (FTYPE)sl2[0];
-      buff3[i] = (FTYPE)sl3[0];
-    }
-
-#ifdef __SUNPRO_C
-#pragma pipeloop(0)
-#endif /* __SUNPRO_C */
-    for (i = 0; i < swid; i++) {
-      buff0[i + dx_l] = (FTYPE)sl[i*chan1];
-      buff1[i + dx_l] = (FTYPE)sl1[i*chan1];
-      buff2[i + dx_l] = (FTYPE)sl2[i*chan1];
-      buff3[i + dx_l] = (FTYPE)sl3[i*chan1];
-    }
-
-    for (i = 0; i < dx_r; i++) {
-      buff0[swid + dx_l + i] = buff0[swid + dx_l - 1];
-      buff1[swid + dx_l + i] = buff1[swid + dx_l - 1];
-      buff2[swid + dx_l + i] = buff2[swid + dx_l - 1];
-      buff3[swid + dx_l + i] = buff3[swid + dx_l - 1];
-    }
-
-    if ((hgt - dy_b) > 1) sl = sl3 + sll;
-    else sl = sl3;
-
-    for (j = 0; j < hgt; j++) {
-      d64_2x32 dd;
-
-      /*
-       *  First loop on two first lines of kernel
-       */
-      k0 = k[0]; k1 = k[1]; k2 = k[2]; k3 = k[3];
-      k4 = k[4]; k5 = k[5]; k6 = k[6]; k7 = k[7];
-
-      sp = sl;
-      dp = dl;
-
-      p02 = buff0[0];
-      p12 = buff1[0];
-      p03 = buff0[1];
-      p13 = buff1[1];
-      p04 = buff0[2];
-
-#ifdef __SUNPRO_C
-#pragma pipeloop(0)
-#endif /* __SUNPRO_C */
-      for (i = 0; i <= (wid - 2); i += 2) {
-        p00 = p02; p10 = p12;
-        p01 = p03; p11 = p13;
-        p02 = p04; p12 = buff1[i + 2];
-        p03 = buff0[i + 3]; p13 = buff1[i + 3];
-        p04 = buff0[i + 4]; p14 = buff1[i + 4];
-
-        LOAD_BUFF(buffi);
-
-        dd.d64 = *(FTYPE   *)(buffi + i);
-        buff4[i + dx_l    ] = (FTYPE)dd.i32s.i0;
-        buff4[i + dx_l + 1] = (FTYPE)dd.i32s.i1;
-
-        buffd[i    ] = (p00 * k0 + p01 * k1 + p02 * k2 + p03 * k3 +
-                        p10 * k4 + p11 * k5 + p12 * k6 + p13 * k7);
-        buffd[i + 1] = (p01 * k0 + p02 * k1 + p03 * k2 + p04 * k3 +
-                        p11 * k4 + p12 * k5 + p13 * k6 + p14 * k7);
-
-        sp += chan2;
-      }
-
-      /*
-       *  Second loop on two last lines of kernel
-       */
-      k0 = k[ 8]; k1 = k[ 9]; k2 = k[10]; k3 = k[11];
-      k4 = k[12]; k5 = k[13]; k6 = k[14]; k7 = k[15];
-
-      p02 = buff2[0];
-      p12 = buff3[0];
-      p03 = buff2[1];
-      p13 = buff3[1];
-      p04 = buff2[2];
-
-#ifdef __SUNPRO_C
-#pragma pipeloop(0)
-#endif /* __SUNPRO_C */
-      for (i = 0; i <= (wid - 2); i += 2) {
-        p00 = p02; p10 = p12;
-        p01 = p03; p11 = p13;
-        p02 = p04; p12 = buff3[i + 2];
-        p03 = buff2[i + 3]; p13 = buff3[i + 3];
-        p04 = buff2[i + 4]; p14 = buff3[i + 4];
-
-        d0 = D2I(p00 * k0 + p01 * k1 + p02 * k2 + p03 * k3 +
-                 p10 * k4 + p11 * k5 + p12 * k6 + p13 * k7 + buffd[i]);
-        d1 = D2I(p01 * k0 + p02 * k1 + p03 * k2 + p04 * k3 +
-                 p11 * k4 + p12 * k5 + p13 * k6 + p14 * k7 + buffd[i + 1]);
-
-        dp[0    ] = FROM_S32(d0);
-        dp[chan1] = FROM_S32(d1);
-
-        dp += chan2;
-      }
-
-      /* last pixels */
-      for (; i < wid; i++) {
-        p00 = buff0[i];     p10 = buff1[i];     p20 = buff2[i];     p30 = buff3[i];
-        p01 = buff0[i + 1]; p11 = buff1[i + 1]; p21 = buff2[i + 1]; p31 = buff3[i + 1];
-        p02 = buff0[i + 2]; p12 = buff1[i + 2]; p22 = buff2[i + 2]; p32 = buff3[i + 2];
-        p03 = buff0[i + 3]; p13 = buff1[i + 3]; p23 = buff2[i + 3]; p33 = buff3[i + 3];
-
-        buff4[i + dx_l] = (FTYPE)sp[0];
-
-        buffo[i] = D2I(p00 * k[0] + p01 * k[1] + p02 * k[2] + p03 * k[3] +
-                       p10 * k[4] + p11 * k[5] + p12 * k[6] + p13 * k[7] +
-                       p20 * k[ 8] + p21 * k[ 9] + p22 * k[10] + p23 * k[11] +
-                       p30 * k[12] + p31 * k[13] + p32 * k[14] + p33 * k[15]);
-
-        dp[0] = FROM_S32(buffo[i]);
-
-        sp += chan1;
-        dp += chan1;
-      }
-
-      for (; i < swid; i++) {
-        buff4[i + dx_l] = (FTYPE)sp[0];
-        sp += chan1;
-      }
-
-      for (i = 0; i < dx_l; i++) buff4[i] = buff4[dx_l];
-      for (i = 0; i < dx_r; i++) buff4[swid + dx_l + i] = buff4[swid + dx_l - 1];
-
-      /* next line */
-
-      if (j < hgt - dy_b - 2) sl += sll;
-      dl += dll;
-
-      buffT = buff0;
-      buff0 = buff1;
-      buff1 = buff2;
-      buff2 = buff3;
-      buff3 = buff4;
-      buff4 = buffT;
-    }
-  }
-
-  if (pbuff != buff) mlib_free(pbuff);
-
-  return MLIB_SUCCESS;
-}
-
-/***************************************************************/
-#undef  KSIZE
-#define KSIZE 5
-
-mlib_status CONV_FUNC(5x5)
-{
-  FTYPE    buff[(KSIZE + 3)*BUFF_LINE];
-  FTYPE    *buff0, *buff1, *buff2, *buff3, *buff4, *buff5, *buffd, *buffT;
-  FTYPE    k[KSIZE*KSIZE];
-  mlib_s32 d0, d1;
-  FTYPE    k0, k1, k2, k3, k4, k5, k6, k7, k8, k9;
-  FTYPE    p00, p01, p02, p03, p04, p05,
-           p10, p11, p12, p13, p14, p15,
-           p20, p21, p22, p23, p24,
-           p30, p31, p32, p33, p34,
-           p40, p41, p42, p43, p44;
-  DEF_VARS(DTYPE);
-  DTYPE *sl2, *sl3, *sl4;
-  LOAD_KERNEL(KSIZE*KSIZE);
-  GET_SRC_DST_PARAMETERS(DTYPE);
-
-  swid = wid + KSIZE1;
-
-  if (swid > BUFF_LINE) {
-    pbuff = mlib_malloc((KSIZE + 3)*sizeof(FTYPE   )*swid);
-
-    if (pbuff == NULL) return MLIB_FAILURE;
-  }
-
-  buff0 = pbuff;
-  buff1 = buff0 + swid;
-  buff2 = buff1 + swid;
-  buff3 = buff2 + swid;
-  buff4 = buff3 + swid;
-  buff5 = buff4 + swid;
-  buffd = buff5 + swid;
-  buffo = (mlib_s32*)(buffd + swid);
-  buffi = buffo + (swid &~ 1);
-
-  swid -= (dx_l + dx_r);
-
-  chan1 = nchannel;
-  chan2 = chan1 + chan1;
-
-  for (c = 0; c < nchannel; c++) {
-    if (!(cmask & (1 << (nchannel - 1 - c)))) continue;
-
-    sl = adr_src + c;
-    dl = adr_dst + c;
-
-    if ((1 > dy_t) && (1 < hgt + KSIZE1 - dy_b)) sl1 = sl + sll;
-    else sl1 = sl;
-
-    if ((2 > dy_t) && (2 < hgt + KSIZE1 - dy_b)) sl2 = sl1 + sll;
-    else sl2 = sl1;
-
-    if ((3 > dy_t) && (3 < hgt + KSIZE1 - dy_b)) sl3 = sl2 + sll;
-    else sl3 = sl2;
-
-    if ((hgt - dy_b) > 0) sl4 = sl3 + sll;
-    else sl4 = sl3;
-
-    for (i = 0; i < dx_l; i++) {
-      buff0[i] = (FTYPE)sl[0];
-      buff1[i] = (FTYPE)sl1[0];
-      buff2[i] = (FTYPE)sl2[0];
-      buff3[i] = (FTYPE)sl3[0];
-      buff4[i] = (FTYPE)sl4[0];
-    }
-
-#ifdef __SUNPRO_C
-#pragma pipeloop(0)
-#endif /* __SUNPRO_C */
-    for (i = 0; i < swid; i++) {
-      buff0[i + dx_l] = (FTYPE)sl[i*chan1];
-      buff1[i + dx_l] = (FTYPE)sl1[i*chan1];
-      buff2[i + dx_l] = (FTYPE)sl2[i*chan1];
-      buff3[i + dx_l] = (FTYPE)sl3[i*chan1];
-      buff4[i + dx_l] = (FTYPE)sl4[i*chan1];
-    }
-
-    for (i = 0; i < dx_r; i++) {
-      buff0[swid + dx_l + i] = buff0[swid + dx_l - 1];
-      buff1[swid + dx_l + i] = buff1[swid + dx_l - 1];
-      buff2[swid + dx_l + i] = buff2[swid + dx_l - 1];
-      buff3[swid + dx_l + i] = buff3[swid + dx_l - 1];
-      buff4[swid + dx_l + i] = buff4[swid + dx_l - 1];
-    }
-
-    if ((hgt - dy_b) > 1) sl = sl4 + sll;
-    else sl = sl4;
-
-    for (j = 0; j < hgt; j++) {
-      d64_2x32 dd;
-
-      /*
-       *  First loop
-       */
-      k0 = k[0]; k1 = k[1]; k2 = k[2]; k3 = k[3]; k4 = k[4];
-      k5 = k[5]; k6 = k[6]; k7 = k[7]; k8 = k[8]; k9 = k[9];
-
-      sp = sl;
-      dp = dl;
-
-      p02 = buff0[0];
-      p12 = buff1[0];
-      p03 = buff0[1];
-      p13 = buff1[1];
-      p04 = buff0[2];
-      p14 = buff1[2];
-
-#ifdef __SUNPRO_C
-#pragma pipeloop(0)
-#endif /* __SUNPRO_C */
-      for (i = 0; i <= (wid - 2); i += 2) {
-        p00 = p02; p10 = p12;
-        p01 = p03; p11 = p13;
-        p02 = p04; p12 = p14;
-
-        LOAD_BUFF(buffi);
-
-        p03 = buff0[i + 3]; p13 = buff1[i + 3];
-        p04 = buff0[i + 4]; p14 = buff1[i + 4];
-        p05 = buff0[i + 5]; p15 = buff1[i + 5];
-
-        buffd[i    ] = (p00 * k0 + p01 * k1 + p02 * k2 + p03 * k3 + p04 * k4 +
-                        p10 * k5 + p11 * k6 + p12 * k7 + p13 * k8 + p14 * k9);
-        buffd[i + 1] = (p01 * k0 + p02 * k1 + p03 * k2 + p04 * k3 + p05 * k4 +
-                        p11 * k5 + p12 * k6 + p13 * k7 + p14 * k8 + p15 * k9);
-
-        sp += chan2;
-      }
-
-      /*
-       *  Second loop
-       */
-      k0 = k[10]; k1 = k[11]; k2 = k[12]; k3 = k[13]; k4 = k[14];
-      k5 = k[15]; k6 = k[16]; k7 = k[17]; k8 = k[18]; k9 = k[19];
-
-      p02 = buff2[0];
-      p12 = buff3[0];
-      p03 = buff2[1];
-      p13 = buff3[1];
-
-#ifdef __SUNPRO_C
-#pragma pipeloop(0)
-#endif /* __SUNPRO_C */
-      for (i = 0; i <= (wid - 2); i += 2) {
-        p00 = p02; p10 = p12;
-        p01 = p03; p11 = p13;
-
-        p02 = buff2[i + 2]; p12 = buff3[i + 2];
-        p03 = buff2[i + 3]; p13 = buff3[i + 3];
-        p04 = buff2[i + 4]; p14 = buff3[i + 4];
-        p05 = buff2[i + 5]; p15 = buff3[i + 5];
-
-        dd.d64 = *(FTYPE   *)(buffi + i);
-        buff5[i + dx_l    ] = (FTYPE)dd.i32s.i0;
-        buff5[i + dx_l + 1] = (FTYPE)dd.i32s.i1;
-
-        buffd[i    ] += (p00 * k0 + p01 * k1 + p02 * k2 + p03 * k3 + p04 * k4 +
-                         p10 * k5 + p11 * k6 + p12 * k7 + p13 * k8 + p14 * k9);
-        buffd[i + 1] += (p01 * k0 + p02 * k1 + p03 * k2 + p04 * k3 + p05 * k4 +
-                         p11 * k5 + p12 * k6 + p13 * k7 + p14 * k8 + p15 * k9);
-      }
-
-      /*
-       *  3 loop
-       */
-      k0 = k[20]; k1 = k[21]; k2 = k[22]; k3 = k[23]; k4 = k[24];
-
-      p02 = buff4[0];
-      p03 = buff4[1];
-      p04 = buff4[2];
-      p05 = buff4[3];
-
-#ifdef __SUNPRO_C
-#pragma pipeloop(0)
-#endif /* __SUNPRO_C */
-      for (i = 0; i <= (wid - 2); i += 2) {
-        p00 = p02; p01 = p03; p02 = p04; p03 = p05;
-
-        p04 = buff4[i + 4]; p05 = buff4[i + 5];
-
-        d0 = D2I(p00 * k0 + p01 * k1 + p02 * k2 + p03 * k3 + p04 * k4 + buffd[i]);
-        d1 = D2I(p01 * k0 + p02 * k1 + p03 * k2 + p04 * k3 + p05 * k4 + buffd[i + 1]);
-
-        dp[0    ] = FROM_S32(d0);
-        dp[chan1] = FROM_S32(d1);
-
-        dp += chan2;
-      }
-
-      /* last pixels */
-      for (; i < wid; i++) {
-        p00 = buff0[i];     p10 = buff1[i];     p20 = buff2[i];     p30 = buff3[i];
-        p01 = buff0[i + 1]; p11 = buff1[i + 1]; p21 = buff2[i + 1]; p31 = buff3[i + 1];
-        p02 = buff0[i + 2]; p12 = buff1[i + 2]; p22 = buff2[i + 2]; p32 = buff3[i + 2];
-        p03 = buff0[i + 3]; p13 = buff1[i + 3]; p23 = buff2[i + 3]; p33 = buff3[i + 3];
-        p04 = buff0[i + 4]; p14 = buff1[i + 4]; p24 = buff2[i + 4]; p34 = buff3[i + 4];
-
-        p40 = buff4[i];     p41 = buff4[i + 1]; p42 = buff4[i + 2];
-        p43 = buff4[i + 3]; p44 = buff4[i + 4];
-
-        buff5[i + dx_l] = (FTYPE)sp[0];
-
-        buffo[i] = D2I(p00 * k[0] + p01 * k[1] + p02 * k[2] + p03 * k[3] + p04 * k[4] +
-                       p10 * k[5] + p11 * k[6] + p12 * k[7] + p13 * k[8] + p14 * k[9] +
-                       p20 * k[10] + p21 * k[11] + p22 * k[12] + p23 * k[13] + p24 * k[14] +
-                       p30 * k[15] + p31 * k[16] + p32 * k[17] + p33 * k[18] + p34 * k[19] +
-                       p40 * k[20] + p41 * k[21] + p42 * k[22] + p43 * k[23] + p44 * k[24]);
-
-        dp[0] = FROM_S32(buffo[i]);
-
-        sp += chan1;
-        dp += chan1;
-      }
-
-      for (; i < swid; i++) {
-        buff5[i + dx_l] = (FTYPE)sp[0];
-        sp += chan1;
-      }
-
-      for (i = 0; i < dx_l; i++) buff5[i] = buff5[dx_l];
-      for (i = 0; i < dx_r; i++) buff5[swid + dx_l + i] = buff5[swid + dx_l - 1];
-
-      /* next line */
-
-      if (j < hgt - dy_b - 2) sl += sll;
-      dl += dll;
-
-      buffT = buff0;
-      buff0 = buff1;
-      buff1 = buff2;
-      buff2 = buff3;
-      buff3 = buff4;
-      buff4 = buff5;
-      buff5 = buffT;
-    }
-  }
-
-  if (pbuff != buff) mlib_free(pbuff);
-
-  return MLIB_SUCCESS;
-}
-
-/***************************************************************/
-#ifndef __sparc /* for x86, using integer multiplies is faster */
-
-mlib_status CONV_FUNC_I(5x5)
-{
-  mlib_s32 buff[BUFF_LINE];
-  mlib_s32 *buffd;
-  mlib_s32 k[KSIZE*KSIZE];
-  mlib_s32 shift1, shift2;
-  mlib_s32 k0, k1, k2, k3, k4, k5, k6, k7, k8, k9;
-  mlib_s32 p00, p01, p02, p03, p04, p05,
-           p10, p11, p12, p13, p14, p15;
-  DTYPE    *adr_src, *sl, *sp0, *sp1, *sp2, *sp3, *sp4;
-  DTYPE    *sp_1, *sp_2, *sp_3, *sp_4;
-  DTYPE    *adr_dst, *dl, *dp;
-  mlib_s32 *pbuff = buff;
-  mlib_s32 wid, hgt, sll, dll;
-  mlib_s32 nchannel, chan1, chan2, chan4;
-  mlib_s32 delta_chan1, delta_chan2, delta_chan3;
-  mlib_s32 i, j, c;
-
-#if IMG_TYPE != 1
-  shift1 = 16;
-#else
-  shift1 = 8;
-#endif /* IMG_TYPE != 1 */
-
-  shift2 = scalef_expon - shift1;
-
-  for (j = 0; j < KSIZE*KSIZE; j++) k[j] = kern[j] >> shift1;
-
-  GET_SRC_DST_PARAMETERS(DTYPE);
-
-  if (wid > BUFF_LINE) {
-    pbuff = mlib_malloc(sizeof(mlib_s32)*wid);
-
-    if (pbuff == NULL) return MLIB_FAILURE;
-  }
-
-  buffd = pbuff;
-
-  chan1 = nchannel;
-  chan2 = chan1 + chan1;
-
-  if ((1 > dx_l) && (1 < wid + KSIZE1 - dx_r)) delta_chan1 = chan1;
-  else delta_chan1 = 0;
-
-  if ((2 > dx_l) && (2 < wid + KSIZE1 - dx_r)) delta_chan2 = delta_chan1 + chan1;
-  else delta_chan2 = delta_chan1;
-
-  if ((3 > dx_l) && (3 < wid + KSIZE1 - dx_r)) delta_chan3 = delta_chan2 + chan1;
-  else delta_chan3 = delta_chan2;
-
-  chan4 = chan1 + delta_chan3;
-
-  for (c = 0; c < chan1; c++) {
-    if (!(cmask & (1 << (chan1 - 1 - c)))) continue;
-
-    sl = adr_src + c;
-    dl = adr_dst + c;
-
-    sp_1 = sl;
-
-    if ((1 > dy_t) && (1 < hgt + KSIZE1 - dy_b)) sl += sll;
-    sp_2 = sl;
-
-    if ((2 > dy_t) && (2 < hgt + KSIZE1 - dy_b)) sl += sll;
-    sp_3 = sl;
-
-    if ((3 > dy_t) && (3 < hgt + KSIZE1 - dy_b)) sl += sll;
-    sp_4 = sl;
-
-    if ((hgt - dy_b) > 0) sl += sll;
-
-    for (j = 0; j < hgt; j++) {
-      mlib_s32 pix0, pix1;
-
-      dp  = dl;
-      sp0 = sp_1;
-      sp_1 = sp_2;
-      sp_2 = sp_3;
-      sp_3 = sp_4;
-      sp_4 = sl;
-
-      sp1 = sp_1;
-      sp2 = sp_2;
-      sp3 = sp_3;
-      sp4 = sp_4;
-
-      /*
-       *  First loop
-       */
-
-      k0 = k[0]; k1 = k[1]; k2 = k[2]; k3 = k[3]; k4 = k[4];
-      k5 = k[5]; k6 = k[6]; k7 = k[7]; k8 = k[8]; k9 = k[9];
-
-      p02 = sp0[0];           p12 = sp1[0];
-      p03 = sp0[delta_chan1]; p13 = sp1[delta_chan1];
-      p04 = sp0[delta_chan2]; p14 = sp1[delta_chan2];
-      p05 = sp0[delta_chan3]; p15 = sp1[delta_chan3];
-
-      sp0 += chan4;
-      sp1 += chan4;
-
-#ifdef __SUNPRO_C
-#pragma pipeloop(0)
-#endif /* __SUNPRO_C */
-      for (i = 0; i <= (wid - dx_r - 2); i += 2) {
-        p00 = p02; p10 = p12;
-        p01 = p03; p11 = p13;
-        p02 = p04; p12 = p14;
-        p03 = p05; p13 = p15;
-
-        p04 = sp0[0];     p14 = sp1[0];
-        p05 = sp0[chan1]; p15 = sp1[chan1];
-
-        buffd[i    ] = (p00 * k0 + p01 * k1 + p02 * k2 + p03 * k3 + p04 * k4 +
-                        p10 * k5 + p11 * k6 + p12 * k7 + p13 * k8 + p14 * k9);
-        buffd[i + 1] = (p01 * k0 + p02 * k1 + p03 * k2 + p04 * k3 + p05 * k4 +
-                        p11 * k5 + p12 * k6 + p13 * k7 + p14 * k8 + p15 * k9);
-
-        sp0 += chan2;
-        sp1 += chan2;
-      }
-
-      p01 = p02; p02 = p03; p03 = p04; p04 = p05;
-      p11 = p12; p12 = p13; p13 = p14; p14 = p15;
-
-      for (; i < wid - dx_r; i++) {
-        p00 = p01; p10 = p11;
-        p01 = p02; p11 = p12;
-        p02 = p03; p12 = p13;
-        p03 = p04; p13 = p14;
-
-        p04 = sp0[0];     p14 = sp1[0];
-
-        buffd[i] = (p00 * k0 + p01 * k1 + p02 * k2 + p03 * k3 + p04 * k4 +
-                    p10 * k5 + p11 * k6 + p12 * k7 + p13 * k8 + p14 * k9);
-
-        sp0 += chan1;
-        sp1 += chan1;
-      }
-
-      sp0 -= chan1;
-      sp1 -= chan1;
-
-      for (; i < wid; i++) {
-        p00 = p01; p10 = p11;
-        p01 = p02; p11 = p12;
-        p02 = p03; p12 = p13;
-        p03 = p04; p13 = p14;
-
-        p04 = sp0[0];     p14 = sp1[0];
-
-        buffd[i] = (p00 * k0 + p01 * k1 + p02 * k2 + p03 * k3 + p04 * k4 +
-                    p10 * k5 + p11 * k6 + p12 * k7 + p13 * k8 + p14 * k9);
-      }
-
-      /*
-       *  Second loop
-       */
-
-      k0 = k[10]; k1 = k[11]; k2 = k[12]; k3 = k[13]; k4 = k[14];
-      k5 = k[15]; k6 = k[16]; k7 = k[17]; k8 = k[18]; k9 = k[19];
-
-      p02 = sp2[0];           p12 = sp3[0];
-      p03 = sp2[delta_chan1]; p13 = sp3[delta_chan1];
-      p04 = sp2[delta_chan2]; p14 = sp3[delta_chan2];
-      p05 = sp2[delta_chan3]; p15 = sp3[delta_chan3];
-
-      sp2 += chan4;
-      sp3 += chan4;
-
-#ifdef __SUNPRO_C
-#pragma pipeloop(0)
-#endif /* __SUNPRO_C */
-      for (i = 0; i <= (wid - dx_r - 2); i += 2) {
-        p00 = p02; p10 = p12;
-        p01 = p03; p11 = p13;
-        p02 = p04; p12 = p14;
-        p03 = p05; p13 = p15;
-
-        p04 = sp2[0];     p14 = sp3[0];
-        p05 = sp2[chan1]; p15 = sp3[chan1];
-
-        buffd[i    ] += (p00 * k0 + p01 * k1 + p02 * k2 + p03 * k3 + p04 * k4 +
-                         p10 * k5 + p11 * k6 + p12 * k7 + p13 * k8 + p14 * k9);
-        buffd[i + 1] += (p01 * k0 + p02 * k1 + p03 * k2 + p04 * k3 + p05 * k4 +
-                         p11 * k5 + p12 * k6 + p13 * k7 + p14 * k8 + p15 * k9);
-
-        sp2 += chan2;
-        sp3 += chan2;
-      }
-
-      p01 = p02; p02 = p03; p03 = p04; p04 = p05;
-      p11 = p12; p12 = p13; p13 = p14; p14 = p15;
-
-      for (; i < wid - dx_r; i++) {
-        p00 = p01; p10 = p11;
-        p01 = p02; p11 = p12;
-        p02 = p03; p12 = p13;
-        p03 = p04; p13 = p14;
-
-        p04 = sp2[0];     p14 = sp3[0];
-
-        buffd[i] += (p00 * k0 + p01 * k1 + p02 * k2 + p03 * k3 + p04 * k4 +
-                     p10 * k5 + p11 * k6 + p12 * k7 + p13 * k8 + p14 * k9);
-
-        sp2 += chan1;
-        sp3 += chan1;
-      }
-
-      sp2 -= chan1;
-      sp3 -= chan1;
-
-      for (; i < wid; i++) {
-        p00 = p01; p10 = p11;
-        p01 = p02; p11 = p12;
-        p02 = p03; p12 = p13;
-        p03 = p04; p13 = p14;
-
-        p04 = sp2[0];     p14 = sp3[0];
-
-        buffd[i] += (p00 * k0 + p01 * k1 + p02 * k2 + p03 * k3 + p04 * k4 +
-                     p10 * k5 + p11 * k6 + p12 * k7 + p13 * k8 + p14 * k9);
-      }
-
-      /*
-       *  3 loop
-       */
-
-      k0 = k[20]; k1 = k[21]; k2 = k[22]; k3 = k[23]; k4 = k[24];
-
-      p02 = sp4[0];
-      p03 = sp4[delta_chan1];
-      p04 = sp4[delta_chan2];
-      p05 = sp4[delta_chan3];
-
-      sp4 += chan4;
-
-#ifdef __SUNPRO_C
-#pragma pipeloop(0)
-#endif /* __SUNPRO_C */
-      for (i = 0; i <= (wid - dx_r - 2); i += 2) {
-        p00 = p02; p01 = p03; p02 = p04; p03 = p05;
-
-        p04 = sp4[0]; p05 = sp4[chan1];
-
-        pix0 = (buffd[i    ] + p00 * k0 + p01 * k1 + p02 * k2 +
-                p03 * k3 + p04 * k4) >> shift2;
-        pix1 = (buffd[i + 1] + p01 * k0 + p02 * k1 + p03 * k2 +
-                p04 * k3 + p05 * k4) >> shift2;
-
-        CLAMP_STORE(dp[0],     pix0)
-        CLAMP_STORE(dp[chan1], pix1)
-
-        dp  += chan2;
-        sp4 += chan2;
-      }
-
-      p01 = p02; p02 = p03; p03 = p04; p04 = p05;
-
-      for (; i < wid - dx_r; i++) {
-        p00 = p01; p01 = p02; p02 = p03; p03 = p04;
-
-        p04 = sp4[0];
-
-        pix0 = (buffd[i    ] + p00 * k0 + p01 * k1 + p02 * k2 +
-                p03 * k3 + p04 * k4) >> shift2;
-        CLAMP_STORE(dp[0],     pix0)
-
-        dp  += chan1;
-        sp4 += chan1;
-      }
-
-      sp4 -= chan1;
-
-      for (; i < wid; i++) {
-        p00 = p01; p01 = p02; p02 = p03; p03 = p04;
-
-        p04 = sp4[0];
-
-        pix0 = (buffd[i    ] + p00 * k0 + p01 * k1 + p02 * k2 +
-                p03 * k3 + p04 * k4) >> shift2;
-        CLAMP_STORE(dp[0],     pix0)
-
-        dp  += chan1;
-      }
-
-      /* next line */
-
-      if (j < hgt - dy_b - 1) sl += sll;
-      dl += dll;
-    }
-  }
-
-  if (pbuff != buff) mlib_free(pbuff);
-
-  return MLIB_SUCCESS;
-}
-
-#endif /* __sparc ( for x86, using integer multiplies is faster ) */
-
-/***************************************************************/
-#if IMG_TYPE == 1
-
-#undef  KSIZE
-#define KSIZE 7
-
-mlib_status CONV_FUNC(7x7)
-{
-  FTYPE    buff[(KSIZE + 3)*BUFF_LINE], *buffs[2*(KSIZE + 1)], *buffd;
-  FTYPE    k[KSIZE*KSIZE];
-  mlib_s32 l, m, buff_ind;
-  mlib_s32 d0, d1;
-  FTYPE    k0, k1, k2, k3, k4, k5, k6;
-  FTYPE    p0, p1, p2, p3, p4, p5, p6, p7;
-  DTYPE *sl2, *sl3, *sl4, *sl5, *sl6;
-  DEF_VARS(DTYPE);
-  LOAD_KERNEL(KSIZE*KSIZE);
-  GET_SRC_DST_PARAMETERS(DTYPE);
-
-  swid = wid + KSIZE1;
-
-  if (wid > BUFF_LINE) {
-    pbuff = mlib_malloc((KSIZE + 3)*sizeof(FTYPE   )*wid);
-
-    if (pbuff == NULL) return MLIB_FAILURE;
-  }
-
-  for (l = 0; l < KSIZE + 1; l++) buffs[l] = pbuff + l*swid;
-  for (l = 0; l < KSIZE + 1; l++) buffs[l + (KSIZE + 1)] = buffs[l];
-  buffd = buffs[KSIZE] + swid;
-  buffo = (mlib_s32*)(buffd + swid);
-  buffi = buffo + (swid &~ 1);
-
-  swid -= (dx_l + dx_r);
-
-  chan1 = nchannel;
-  chan2 = chan1 + chan1;
-
-  for (c = 0; c < nchannel; c++) {
-    if (!(cmask & (1 << (nchannel - 1 - c)))) continue;
-
-    sl = adr_src + c;
-    dl = adr_dst + c;
-
-    if ((1 > dy_t) && (1 < hgt + KSIZE1 - dy_b)) sl1 = sl + sll;
-    else sl1 = sl;
-
-    if ((2 > dy_t) && (2 < hgt + KSIZE1 - dy_b)) sl2 = sl1 + sll;
-    else sl2 = sl1;
-
-    if ((3 > dy_t) && (3 < hgt + KSIZE1 - dy_b)) sl3 = sl2 + sll;
-    else sl3 = sl2;
-
-    if ((4 > dy_t) && (4 < hgt + KSIZE1 - dy_b)) sl4 = sl3 + sll;
-    else sl4 = sl3;
-
-    if ((5 > dy_t) && (5 < hgt + KSIZE1 - dy_b)) sl5 = sl4 + sll;
-    else sl5 = sl4;
-
-    if ((hgt - dy_b) > 0) sl6 = sl5 + sll;
-    else sl6 = sl5;
-
-    for (i = 0; i < dx_l; i++) {
-      buffs[0][i] = (FTYPE)sl[0];
-      buffs[1][i] = (FTYPE)sl1[0];
-      buffs[2][i] = (FTYPE)sl2[0];
-      buffs[3][i] = (FTYPE)sl3[0];
-      buffs[4][i] = (FTYPE)sl4[0];
-      buffs[5][i] = (FTYPE)sl5[0];
-      buffs[6][i] = (FTYPE)sl6[0];
-    }
-
-#ifdef __SUNPRO_C
-#pragma pipeloop(0)
-#endif /* __SUNPRO_C */
-    for (i = 0; i < swid; i++) {
-      buffs[0][i + dx_l] = (FTYPE)sl[i*chan1];
-      buffs[1][i + dx_l] = (FTYPE)sl1[i*chan1];
-      buffs[2][i + dx_l] = (FTYPE)sl2[i*chan1];
-      buffs[3][i + dx_l] = (FTYPE)sl3[i*chan1];
-      buffs[4][i + dx_l] = (FTYPE)sl4[i*chan1];
-      buffs[5][i + dx_l] = (FTYPE)sl5[i*chan1];
-      buffs[6][i + dx_l] = (FTYPE)sl6[i*chan1];
-    }
-
-    for (i = 0; i < dx_r; i++) {
-      buffs[0][swid + dx_l + i] = buffs[0][swid + dx_l - 1];
-      buffs[1][swid + dx_l + i] = buffs[1][swid + dx_l - 1];
-      buffs[2][swid + dx_l + i] = buffs[2][swid + dx_l - 1];
-      buffs[3][swid + dx_l + i] = buffs[3][swid + dx_l - 1];
-      buffs[4][swid + dx_l + i] = buffs[4][swid + dx_l - 1];
-      buffs[5][swid + dx_l + i] = buffs[5][swid + dx_l - 1];
-      buffs[6][swid + dx_l + i] = buffs[6][swid + dx_l - 1];
-    }
-
-    buff_ind = 0;
-
-#ifdef __SUNPRO_C
-#pragma pipeloop(0)
-#endif /* __SUNPRO_C */
-    for (i = 0; i < wid; i++) buffd[i] = 0.0;
-
-    if ((hgt - dy_b) > 1) sl = sl6 + sll;
-    else sl = sl6;
-
-    for (j = 0; j < hgt; j++) {
-      FTYPE    **buffc = buffs + buff_ind;
-      FTYPE    *buffn = buffc[KSIZE];
-      FTYPE    *pk = k;
-
-      for (l = 0; l < KSIZE; l++) {
-        FTYPE    *buff = buffc[l];
-        d64_2x32 dd;
-
-        sp = sl;
-        dp = dl;
-
-        p2 = buff[0]; p3 = buff[1]; p4 = buff[2];
-        p5 = buff[3]; p6 = buff[4]; p7 = buff[5];
-
-        k0 = *pk++; k1 = *pk++; k2 = *pk++; k3 = *pk++;
-        k4 = *pk++; k5 = *pk++; k6 = *pk++;
-
-        if (l < (KSIZE - 1)) {
-#ifdef __SUNPRO_C
-#pragma pipeloop(0)
-#endif /* __SUNPRO_C */
-          for (i = 0; i <= (wid - 2); i += 2) {
-            p0 = p2; p1 = p3; p2 = p4; p3 = p5; p4 = p6; p5 = p7;
-
-            p6 = buff[i + 6]; p7 = buff[i + 7];
-
-            buffd[i    ] += p0*k0 + p1*k1 + p2*k2 + p3*k3 + p4*k4 + p5*k5 + p6*k6;
-            buffd[i + 1] += p1*k0 + p2*k1 + p3*k2 + p4*k3 + p5*k4 + p6*k5 + p7*k6;
-          }
-
-        } else {
-#ifdef __SUNPRO_C
-#pragma pipeloop(0)
-#endif /* __SUNPRO_C */
-          for (i = 0; i <= (wid - 2); i += 2) {
-            p0 = p2; p1 = p3; p2 = p4; p3 = p5; p4 = p6; p5 = p7;
-
-            p6 = buff[i + 6]; p7 = buff[i + 7];
-
-            LOAD_BUFF(buffi);
-
-            dd.d64 = *(FTYPE   *)(buffi + i);
-            buffn[i + dx_l    ] = (FTYPE)dd.i32s.i0;
-            buffn[i + dx_l + 1] = (FTYPE)dd.i32s.i1;
-
-            d0 = D2I(p0*k0 + p1*k1 + p2*k2 + p3*k3 + p4*k4 + p5*k5 + p6*k6 + buffd[i    ]);
-            d1 = D2I(p1*k0 + p2*k1 + p3*k2 + p4*k3 + p5*k4 + p6*k5 + p7*k6 + buffd[i + 1]);
-
-            dp[0    ] = FROM_S32(d0);
-            dp[chan1] = FROM_S32(d1);
-
-            buffd[i    ] = 0.0;
-            buffd[i + 1] = 0.0;
-
-            sp += chan2;
-            dp += chan2;
-          }
-        }
-      }
-
-      /* last pixels */
-      for (; i < wid; i++) {
-        FTYPE    *pk = k, s = 0;
-        mlib_s32 d0;
-
-        for (l = 0; l < KSIZE; l++) {
-          FTYPE    *buff = buffc[l] + i;
-
-          for (m = 0; m < KSIZE; m++) s += buff[m] * (*pk++);
-        }
-
-        d0 = D2I(s);
-        dp[0] = FROM_S32(d0);
-
-        buffn[i + dx_l] = (FTYPE)sp[0];
-
-        sp += chan1;
-        dp += chan1;
-      }
-
-      for (; i < swid; i++) {
-        buffn[i + dx_l] = (FTYPE)sp[0];
-        sp += chan1;
-      }
-
-      for (i = 0; i < dx_l; i++) buffn[i] = buffn[dx_l];
-      for (i = 0; i < dx_r; i++) buffn[swid + dx_l + i] = buffn[swid + dx_l - 1];
-
-      /* next line */
-
-      if (j < hgt - dy_b - 2) sl += sll;
-      dl += dll;
-
-      buff_ind++;
-
-      if (buff_ind >= KSIZE + 1) buff_ind = 0;
-    }
-  }
-
-  if (pbuff != buff) mlib_free(pbuff);
-
-  return MLIB_SUCCESS;
-}
-
-#endif /* IMG_TYPE == 1 */
-
-/***************************************************************/
 #define MAX_KER   7
 #define MAX_N    15
 #define BUFF_SIZE   1600
--- a/jdk/src/java.desktop/share/native/libmlib_image/mlib_ImageConv_8nw.c	Thu May 19 17:48:02 2016 +0000
+++ b/jdk/src/java.desktop/share/native/libmlib_image/mlib_ImageConv_8nw.c	Thu May 19 19:46:20 2016 +0000
@@ -145,9 +145,6 @@
 } d64_2x32;
 
 /***************************************************************/
-#define BUFF_LINE 256
-
-/***************************************************************/
 #define DEF_VARS(type)                                          \
   type     *adr_src, *sl, *sp = NULL;                           \
   type     *adr_dst, *dl, *dp = NULL;                           \
@@ -157,39 +154,6 @@
   mlib_s32 i, j, c
 
 /***************************************************************/
-#define LOAD_KERNEL3()                                                   \
-  FTYPE    scalef = DSCALE;                                              \
-  FTYPE    k0, k1, k2, k3, k4, k5, k6, k7, k8;                           \
-  FTYPE    p00, p01, p02, p03,                                           \
-           p10, p11, p12, p13,                                           \
-           p20, p21, p22, p23;                                           \
-                                                                         \
-  while (scalef_expon > 30) {                                            \
-    scalef /= (1 << 30);                                                 \
-    scalef_expon -= 30;                                                  \
-  }                                                                      \
-                                                                         \
-  scalef /= (1 << scalef_expon);                                         \
-                                                                         \
-  /* keep kernel in regs */                                              \
-  k0 = scalef * kern[0];  k1 = scalef * kern[1];  k2 = scalef * kern[2]; \
-  k3 = scalef * kern[3];  k4 = scalef * kern[4];  k5 = scalef * kern[5]; \
-  k6 = scalef * kern[6];  k7 = scalef * kern[7];  k8 = scalef * kern[8]
-
-/***************************************************************/
-#define LOAD_KERNEL(SIZE)                                       \
-  FTYPE    scalef = DSCALE;                                     \
-                                                                \
-  while (scalef_expon > 30) {                                   \
-    scalef /= (1 << 30);                                        \
-    scalef_expon -= 30;                                         \
-  }                                                             \
-                                                                \
-  scalef /= (1 << scalef_expon);                                \
-                                                                \
-  for (j = 0; j < SIZE; j++) k[j] = scalef * kern[j]
-
-/***************************************************************/
 #define GET_SRC_DST_PARAMETERS(type)                            \
   hgt = mlib_ImageGetHeight(src);                               \
   wid = mlib_ImageGetWidth(src);                                \
@@ -247,1162 +211,6 @@
 #endif /* __sparc */
 
 /***************************************************************/
-#define KSIZE  3
-
-mlib_status CONV_FUNC(3x3)(mlib_image       *dst,
-                           const mlib_image *src,
-                           const mlib_s32   *kern,
-                           mlib_s32         scalef_expon,
-                           mlib_s32         cmask)
-{
-  FTYPE    buff[(KSIZE + 2)*BUFF_LINE], *buff0, *buff1, *buff2, *buff3, *buffT;
-  DEF_VARS(DTYPE);
-  DTYPE *sl1;
-  mlib_s32 chan2;
-  mlib_s32 *buffo, *buffi;
-  DTYPE *sl2;
-#ifndef __sparc
-  mlib_s32 d0, d1;
-#endif /* __sparc */
-  LOAD_KERNEL3();
-  GET_SRC_DST_PARAMETERS(DTYPE);
-
-  if (wid > BUFF_LINE) {
-    pbuff = mlib_malloc((KSIZE + 2)*sizeof(FTYPE)*wid);
-
-    if (pbuff == NULL) return MLIB_FAILURE;
-  }
-
-  buff0 = pbuff;
-  buff1 = buff0 + wid;
-  buff2 = buff1 + wid;
-  buff3 = buff2 + wid;
-  buffo = (mlib_s32*)(buff3 + wid);
-  buffi = buffo + (wid &~ 1);
-
-  chan1 = nchannel;
-  chan2 = chan1 + chan1;
-
-  wid -= (KSIZE - 1);
-  hgt -= (KSIZE - 1);
-
-  adr_dst += ((KSIZE - 1)/2)*(dll + chan1);
-
-  for (c = 0; c < nchannel; c++) {
-    if (!(cmask & (1 << (nchannel - 1 - c)))) continue;
-
-    sl = adr_src + c;
-    dl = adr_dst + c;
-
-    sl1 = sl  + sll;
-    sl2 = sl1 + sll;
-#ifdef __SUNPRO_C
-#pragma pipeloop(0)
-#endif /* __SUNPRO_C */
-    for (i = 0; i < wid + (KSIZE - 1); i++) {
-      buff0[i] = (FTYPE)sl[i*chan1];
-      buff1[i] = (FTYPE)sl1[i*chan1];
-      buff2[i] = (FTYPE)sl2[i*chan1];
-    }
-
-    sl += KSIZE*sll;
-
-    for (j = 0; j < hgt; j++) {
-      FTYPE    s0, s1;
-
-      p02 = buff0[0];
-      p12 = buff1[0];
-      p22 = buff2[0];
-
-      p03 = buff0[1];
-      p13 = buff1[1];
-      p23 = buff2[1];
-
-      s0 = p02 * k0 + p03 * k1 + p12 * k3 + p13 * k4 + p22 * k6 + p23 * k7;
-      s1 = p03 * k0 + p13 * k3 + p23 * k6;
-
-      sp = sl;
-      dp = dl;
-
-#ifdef __SUNPRO_C
-#pragma pipeloop(0)
-#endif /* __SUNPRO_C */
-      for (i = 0; i <= (wid - 2); i += 2) {
-#ifdef __sparc
-#ifdef _NO_LONGLONG
-        mlib_s32 o64_1, o64_2;
-#else /* _NO_LONGLONG */
-        mlib_s64 o64;
-#endif /* _NO_LONGLONG */
-#endif /* __sparc */
-        d64_2x32 dd;
-
-        p02 = buff0[i + 2]; p12 = buff1[i + 2]; p22 = buff2[i + 2];
-        p03 = buff0[i + 3]; p13 = buff1[i + 3]; p23 = buff2[i + 3];
-
-        LOAD_BUFF(buffi);
-
-        dd.d64 = *(FTYPE   *)(buffi + i);
-        buff3[i    ] = (FTYPE)dd.i32s.i0;
-        buff3[i + 1] = (FTYPE)dd.i32s.i1;
-
-#ifndef __sparc
-        d0 = D2I(s0 + p02 * k2 + p12 * k5 + p22 * k8);
-        d1 = D2I(s1 + p02 * k1 + p03 * k2 + p12 * k4 + p13 * k5 + p22 * k7 + p23 * k8);
-
-        s0 = p02 * k0 + p03 * k1 + p12 * k3 + p13 * k4 + p22 * k6 + p23 * k7;
-        s1 = p03 * k0 + p13 * k3 + p23 * k6;
-
-        dp[0    ] = FROM_S32(d0);
-        dp[chan1] = FROM_S32(d1);
-
-#else /* __sparc */
-
-        dd.i32s.i0 = D2I(s0 + p02 * k2 + p12 * k5 + p22 * k8);
-        dd.i32s.i1 = D2I(s1 + p02 * k1 + p03 * k2 + p12 * k4 + p13 * k5 + p22 * k7 + p23 * k8);
-        *(FTYPE   *)(buffo + i) = dd.d64;
-
-        s0 = p02 * k0 + p03 * k1 + p12 * k3 + p13 * k4 + p22 * k6 + p23 * k7;
-        s1 = p03 * k0 + p13 * k3 + p23 * k6;
-
-#ifdef _NO_LONGLONG
-
-        o64_1 = buffo[i];
-        o64_2 = buffo[i+1];
-#if IMG_TYPE != 1
-        STORE2(FROM_S32(o64_1), FROM_S32(o64_2));
-#else
-        STORE2(o64_1 >> 24, o64_2 >> 24);
-#endif /* IMG_TYPE != 1 */
-
-#else /* _NO_LONGLONG */
-
-        o64 = *(mlib_s64*)(buffo + i);
-#if IMG_TYPE != 1
-        STORE2(FROM_S32(o64 >> 32), FROM_S32(o64));
-#else
-        STORE2(o64 >> 56, o64 >> 24);
-#endif /* IMG_TYPE != 1 */
-#endif /* _NO_LONGLONG */
-#endif /* __sparc */
-
-        sp += chan2;
-        dp += chan2;
-      }
-
-      for (; i < wid; i++) {
-        p00 = buff0[i];     p10 = buff1[i];     p20 = buff2[i];
-        p01 = buff0[i + 1]; p11 = buff1[i + 1]; p21 = buff2[i + 1];
-        p02 = buff0[i + 2]; p12 = buff1[i + 2]; p22 = buff2[i + 2];
-
-        buffi[i] = (mlib_s32)sp[0];
-        buff3[i] = (FTYPE)buffi[i];
-
-#ifndef __sparc
-
-        d0 = D2I(p00 * k0 + p01 * k1 + p02 * k2 + p10 * k3 + p11 * k4 +
-                 p12 * k5 + p20 * k6 + p21 * k7 + p22 * k8);
-
-        dp[0] = FROM_S32(d0);
-
-#else  /* __sparc */
-
-        buffo[i] = D2I(p00 * k0 + p01 * k1 + p02 * k2 + p10 * k3 + p11 * k4 +
-                       p12 * k5 + p20 * k6 + p21 * k7 + p22 * k8);
-#if IMG_TYPE != 1
-        dp[0] = FROM_S32(buffo[i]);
-#else
-        dp[0] = buffo[i] >> 24;
-#endif /* IMG_TYPE != 1 */
-#endif /* __sparc */
-
-        sp += chan1;
-        dp += chan1;
-      }
-
-      buffi[wid] = (mlib_s32)sp[0];
-      buff3[wid] = (FTYPE)buffi[wid];
-      buffi[wid + 1] = (mlib_s32)sp[chan1];
-      buff3[wid + 1] = (FTYPE)buffi[wid + 1];
-
-      sl += sll;
-      dl += dll;
-
-      buffT = buff0;
-      buff0 = buff1;
-      buff1 = buff2;
-      buff2 = buff3;
-      buff3 = buffT;
-    }
-  }
-
-#ifdef __sparc
-#if IMG_TYPE == 1
-  {
-    mlib_s32 amask = (1 << nchannel) - 1;
-
-    if ((cmask & amask) != amask) {
-      mlib_ImageXor80(adr_dst, wid, hgt, dll, nchannel, cmask);
-    } else {
-      mlib_ImageXor80_aa(adr_dst, wid*nchannel, hgt, dll);
-    }
-  }
-
-#endif /* IMG_TYPE == 1 */
-#endif /* __sparc */
-
-  if (pbuff != buff) mlib_free(pbuff);
-
-  return MLIB_SUCCESS;
-}
-
-/***************************************************************/
-#ifndef __sparc /* for x86, using integer multiplies is faster */
-
-mlib_status CONV_FUNC_I(3x3)(mlib_image       *dst,
-                             const mlib_image *src,
-                             const mlib_s32   *kern,
-                             mlib_s32         scalef_expon,
-                             mlib_s32         cmask)
-{
-  DTYPE    *adr_src, *sl, *sp0, *sp1, *sp2;
-  DTYPE    *adr_dst, *dl, *dp;
-  mlib_s32 wid, hgt, sll, dll;
-  mlib_s32 nchannel, chan1, chan2;
-  mlib_s32 i, j, c;
-  mlib_s32 shift1, shift2;
-  mlib_s32 k0, k1, k2, k3, k4, k5, k6, k7, k8;
-  mlib_s32 p02, p03,
-           p12, p13,
-           p22, p23;
-
-#if IMG_TYPE != 1
-  shift1 = 16;
-#else
-  shift1 = 8;
-#endif /* IMG_TYPE != 1 */
-
-  shift2 = scalef_expon - shift1;
-
-  /* keep kernel in regs */
-  k0 = kern[0] >> shift1;  k1 = kern[1] >> shift1;  k2 = kern[2] >> shift1;
-  k3 = kern[3] >> shift1;  k4 = kern[4] >> shift1;  k5 = kern[5] >> shift1;
-  k6 = kern[6] >> shift1;  k7 = kern[7] >> shift1;  k8 = kern[8] >> shift1;
-
-  GET_SRC_DST_PARAMETERS(DTYPE);
-
-  chan1 = nchannel;
-  chan2 = chan1 + chan1;
-
-  wid -= (KSIZE - 1);
-  hgt -= (KSIZE - 1);
-
-  adr_dst += ((KSIZE - 1)/2)*(dll + chan1);
-
-  for (c = 0; c < chan1; c++) {
-    if (!(cmask & (1 << (chan1 - 1 - c)))) continue;
-
-    sl = adr_src + c;
-    dl = adr_dst + c;
-
-    for (j = 0; j < hgt; j++) {
-      mlib_s32 s0, s1;
-      mlib_s32 pix0, pix1;
-
-      dp  = dl;
-      sp0 = sl;
-      sp1 = sp0 + sll;
-      sp2 = sp1 + sll;
-
-      p02 = sp0[0];
-      p12 = sp1[0];
-      p22 = sp2[0];
-
-      p03 = sp0[chan1];
-      p13 = sp1[chan1];
-      p23 = sp2[chan1];
-
-      s0 = p02 * k0 + p03 * k1 + p12 * k3 + p13 * k4 + p22 * k6 + p23 * k7;
-      s1 = p03 * k0 + p13 * k3 + p23 * k6;
-
-      sp0 += chan2;
-      sp1 += chan2;
-      sp2 += chan2;
-
-#ifdef __SUNPRO_C
-#pragma pipeloop(0)
-#endif /* __SUNPRO_C */
-      for (i = 0; i <= (wid - 2); i += 2) {
-        p02 = sp0[0];     p12 = sp1[0];     p22 = sp2[0];
-        p03 = sp0[chan1]; p13 = sp1[chan1]; p23 = sp2[chan1];
-
-        pix0 = (s0 + p02 * k2 + p12 * k5 + p22 * k8) >> shift2;
-        pix1 = (s1 + p02 * k1 + p03 * k2 + p12 * k4 +
-                p13 * k5 + p22 * k7 + p23 * k8) >> shift2;
-
-        CLAMP_STORE(dp[0],     pix0)
-        CLAMP_STORE(dp[chan1], pix1)
-
-        s0 = p02 * k0 + p03 * k1 + p12 * k3 + p13 * k4 + p22 * k6 + p23 * k7;
-        s1 = p03 * k0 + p13 * k3 + p23 * k6;
-
-        sp0 += chan2;
-        sp1 += chan2;
-        sp2 += chan2;
-        dp += chan2;
-      }
-
-      if (wid & 1) {
-        p02 = sp0[0]; p12 = sp1[0]; p22 = sp2[0];
-        pix0 = (s0 + p02 * k2 + p12 * k5 + p22 * k8) >> shift2;
-        CLAMP_STORE(dp[0], pix0)
-      }
-
-      sl += sll;
-      dl += dll;
-    }
-  }
-
-  return MLIB_SUCCESS;
-}
-
-#endif /* __sparc ( for x86, using integer multiplies is faster ) */
-
-/***************************************************************/
-#undef  KSIZE
-#define KSIZE 4
-
-mlib_status CONV_FUNC(4x4)(mlib_image       *dst,
-                           const mlib_image *src,
-                           const mlib_s32   *kern,
-                           mlib_s32         scalef_expon,
-                           mlib_s32         cmask)
-{
-  FTYPE    buff[(KSIZE + 3)*BUFF_LINE];
-  FTYPE    *buff0, *buff1, *buff2, *buff3, *buff4, *buffd, *buffT;
-  FTYPE    k[KSIZE*KSIZE];
-  mlib_s32 d0, d1;
-  FTYPE    k0, k1, k2, k3, k4, k5, k6, k7;
-  FTYPE    p00, p01, p02, p03, p04,
-           p10, p11, p12, p13, p14,
-           p20, p21, p22, p23,
-           p30, p31, p32, p33;
-  DEF_VARS(DTYPE);
-  DTYPE *sl1;
-  mlib_s32 chan2;
-  mlib_s32 *buffo, *buffi;
-  DTYPE *sl2, *sl3;
-  LOAD_KERNEL(KSIZE*KSIZE);
-  GET_SRC_DST_PARAMETERS(DTYPE);
-
-  if (wid > BUFF_LINE) {
-    pbuff = mlib_malloc((KSIZE + 3)*sizeof(FTYPE)*wid);
-
-    if (pbuff == NULL) return MLIB_FAILURE;
-  }
-
-  buff0 = pbuff;
-  buff1 = buff0 + wid;
-  buff2 = buff1 + wid;
-  buff3 = buff2 + wid;
-  buff4 = buff3 + wid;
-  buffd = buff4 + wid;
-  buffo = (mlib_s32*)(buffd + wid);
-  buffi = buffo + (wid &~ 1);
-
-  chan1 = nchannel;
-  chan2 = chan1 + chan1;
-
-  wid -= (KSIZE - 1);
-  hgt -= (KSIZE - 1);
-
-  adr_dst += ((KSIZE - 1)/2)*(dll + chan1);
-
-  for (c = 0; c < nchannel; c++) {
-    if (!(cmask & (1 << (nchannel - 1 - c)))) continue;
-
-    sl = adr_src + c;
-    dl = adr_dst + c;
-
-    sl1 = sl  + sll;
-    sl2 = sl1 + sll;
-    sl3 = sl2 + sll;
-#ifdef __SUNPRO_C
-#pragma pipeloop(0)
-#endif /* __SUNPRO_C */
-    for (i = 0; i < wid + (KSIZE - 1); i++) {
-      buff0[i] = (FTYPE)sl[i*chan1];
-      buff1[i] = (FTYPE)sl1[i*chan1];
-      buff2[i] = (FTYPE)sl2[i*chan1];
-      buff3[i] = (FTYPE)sl3[i*chan1];
-    }
-
-    sl += KSIZE*sll;
-
-    for (j = 0; j < hgt; j++) {
-      d64_2x32 dd;
-
-      /*
-       *  First loop on two first lines of kernel
-       */
-      k0 = k[0]; k1 = k[1]; k2 = k[2]; k3 = k[3];
-      k4 = k[4]; k5 = k[5]; k6 = k[6]; k7 = k[7];
-
-      sp = sl;
-      dp = dl;
-
-      p02 = buff0[0];
-      p12 = buff1[0];
-      p03 = buff0[1];
-      p13 = buff1[1];
-      p04 = buff0[2];
-
-#ifdef __SUNPRO_C
-#pragma pipeloop(0)
-#endif /* __SUNPRO_C */
-      for (i = 0; i <= (wid - 2); i += 2) {
-        p00 = p02; p10 = p12;
-        p01 = p03; p11 = p13;
-        p02 = p04; p12 = buff1[i + 2];
-        p03 = buff0[i + 3]; p13 = buff1[i + 3];
-        p04 = buff0[i + 4]; p14 = buff1[i + 4];
-
-        LOAD_BUFF(buffi);
-
-        dd.d64 = *(FTYPE   *)(buffi + i);
-        buff4[i    ] = (FTYPE)dd.i32s.i0;
-        buff4[i + 1] = (FTYPE)dd.i32s.i1;
-
-        buffd[i    ] = (p00 * k0 + p01 * k1 + p02 * k2 + p03 * k3 +
-                        p10 * k4 + p11 * k5 + p12 * k6 + p13 * k7);
-        buffd[i + 1] = (p01 * k0 + p02 * k1 + p03 * k2 + p04 * k3 +
-                        p11 * k4 + p12 * k5 + p13 * k6 + p14 * k7);
-
-        sp += chan2;
-        dp += chan2;
-      }
-
-      /*
-       *  Second loop on two last lines of kernel
-       */
-      k0 = k[ 8]; k1 = k[ 9]; k2 = k[10]; k3 = k[11];
-      k4 = k[12]; k5 = k[13]; k6 = k[14]; k7 = k[15];
-
-      sp = sl;
-      dp = dl;
-
-      p02 = buff2[0];
-      p12 = buff3[0];
-      p03 = buff2[1];
-      p13 = buff3[1];
-      p04 = buff2[2];
-
-#ifdef __SUNPRO_C
-#pragma pipeloop(0)
-#endif /* __SUNPRO_C */
-      for (i = 0; i <= (wid - 2); i += 2) {
-        p00 = p02; p10 = p12;
-        p01 = p03; p11 = p13;
-        p02 = p04; p12 = buff3[i + 2];
-        p03 = buff2[i + 3]; p13 = buff3[i + 3];
-        p04 = buff2[i + 4]; p14 = buff3[i + 4];
-
-        d0 = D2I(p00 * k0 + p01 * k1 + p02 * k2 + p03 * k3 +
-                 p10 * k4 + p11 * k5 + p12 * k6 + p13 * k7 + buffd[i]);
-        d1 = D2I(p01 * k0 + p02 * k1 + p03 * k2 + p04 * k3 +
-                 p11 * k4 + p12 * k5 + p13 * k6 + p14 * k7 + buffd[i + 1]);
-
-        dp[0    ] = FROM_S32(d0);
-        dp[chan1] = FROM_S32(d1);
-
-        sp += chan2;
-        dp += chan2;
-      }
-
-      /* last pixels */
-      for (; i < wid; i++) {
-        p00 = buff0[i];     p10 = buff1[i];     p20 = buff2[i];     p30 = buff3[i];
-        p01 = buff0[i + 1]; p11 = buff1[i + 1]; p21 = buff2[i + 1]; p31 = buff3[i + 1];
-        p02 = buff0[i + 2]; p12 = buff1[i + 2]; p22 = buff2[i + 2]; p32 = buff3[i + 2];
-        p03 = buff0[i + 3]; p13 = buff1[i + 3]; p23 = buff2[i + 3]; p33 = buff3[i + 3];
-
-        buff4[i] = (FTYPE)sp[0];
-
-        buffo[i] = D2I(p00 * k[0] + p01 * k[1] + p02 * k[2] + p03 * k[3] +
-                       p10 * k[4] + p11 * k[5] + p12 * k[6] + p13 * k[7] +
-                       p20 * k[ 8] + p21 * k[ 9] + p22 * k[10] + p23 * k[11] +
-                       p30 * k[12] + p31 * k[13] + p32 * k[14] + p33 * k[15]);
-
-        dp[0] = FROM_S32(buffo[i]);
-
-        sp += chan1;
-        dp += chan1;
-      }
-
-      buff4[wid    ] = (FTYPE)sp[0];
-      buff4[wid + 1] = (FTYPE)sp[chan1];
-      buff4[wid + 2] = (FTYPE)sp[chan2];
-
-      /* next line */
-      sl += sll;
-      dl += dll;
-
-      buffT = buff0;
-      buff0 = buff1;
-      buff1 = buff2;
-      buff2 = buff3;
-      buff3 = buff4;
-      buff4 = buffT;
-    }
-  }
-
-  if (pbuff != buff) mlib_free(pbuff);
-
-  return MLIB_SUCCESS;
-}
-
-/***************************************************************/
-#undef  KSIZE
-#define KSIZE 5
-
-mlib_status CONV_FUNC(5x5)(mlib_image       *dst,
-                           const mlib_image *src,
-                           const mlib_s32   *kern,
-                           mlib_s32         scalef_expon,
-                           mlib_s32         cmask)
-{
-  FTYPE    buff[(KSIZE + 3)*BUFF_LINE];
-  FTYPE    *buff0, *buff1, *buff2, *buff3, *buff4, *buff5, *buffd, *buffT;
-  FTYPE    k[KSIZE*KSIZE];
-  mlib_s32 d0, d1;
-  FTYPE    k0, k1, k2, k3, k4, k5, k6, k7, k8, k9;
-  FTYPE    p00, p01, p02, p03, p04, p05,
-           p10, p11, p12, p13, p14, p15,
-           p20, p21, p22, p23, p24,
-           p30, p31, p32, p33, p34,
-           p40, p41, p42, p43, p44;
-  DEF_VARS(DTYPE);
-  DTYPE *sl1;
-  mlib_s32 chan2;
-  mlib_s32 *buffo, *buffi;
-  DTYPE *sl2, *sl3, *sl4;
-  LOAD_KERNEL(KSIZE*KSIZE);
-  GET_SRC_DST_PARAMETERS(DTYPE);
-
-  if (wid > BUFF_LINE) {
-    pbuff = mlib_malloc((KSIZE + 3)*sizeof(FTYPE)*wid);
-
-    if (pbuff == NULL) return MLIB_FAILURE;
-  }
-
-  buff0 = pbuff;
-  buff1 = buff0 + wid;
-  buff2 = buff1 + wid;
-  buff3 = buff2 + wid;
-  buff4 = buff3 + wid;
-  buff5 = buff4 + wid;
-  buffd = buff5 + wid;
-  buffo = (mlib_s32*)(buffd + wid);
-  buffi = buffo + (wid &~ 1);
-
-  chan1 = nchannel;
-  chan2 = chan1 + chan1;
-
-  wid -= (KSIZE - 1);
-  hgt -= (KSIZE - 1);
-
-  adr_dst += ((KSIZE - 1)/2)*(dll + chan1);
-
-  for (c = 0; c < nchannel; c++) {
-    if (!(cmask & (1 << (nchannel - 1 - c)))) continue;
-
-    sl = adr_src + c;
-    dl = adr_dst + c;
-
-    sl1 = sl  + sll;
-    sl2 = sl1 + sll;
-    sl3 = sl2 + sll;
-    sl4 = sl3 + sll;
-#ifdef __SUNPRO_C
-#pragma pipeloop(0)
-#endif /* __SUNPRO_C */
-    for (i = 0; i < wid + (KSIZE - 1); i++) {
-      buff0[i] = (FTYPE)sl[i*chan1];
-      buff1[i] = (FTYPE)sl1[i*chan1];
-      buff2[i] = (FTYPE)sl2[i*chan1];
-      buff3[i] = (FTYPE)sl3[i*chan1];
-      buff4[i] = (FTYPE)sl4[i*chan1];
-    }
-
-    sl += KSIZE*sll;
-
-    for (j = 0; j < hgt; j++) {
-      d64_2x32 dd;
-
-      /*
-       *  First loop
-       */
-      k0 = k[0]; k1 = k[1]; k2 = k[2]; k3 = k[3]; k4 = k[4];
-      k5 = k[5]; k6 = k[6]; k7 = k[7]; k8 = k[8]; k9 = k[9];
-
-      sp = sl;
-      dp = dl;
-
-      p02 = buff0[0];
-      p12 = buff1[0];
-      p03 = buff0[1];
-      p13 = buff1[1];
-      p04 = buff0[2];
-      p14 = buff1[2];
-
-#ifdef __SUNPRO_C
-#pragma pipeloop(0)
-#endif /* __SUNPRO_C */
-      for (i = 0; i <= (wid - 2); i += 2) {
-        p00 = p02; p10 = p12;
-        p01 = p03; p11 = p13;
-        p02 = p04; p12 = p14;
-
-        LOAD_BUFF(buffi);
-
-        p03 = buff0[i + 3]; p13 = buff1[i + 3];
-        p04 = buff0[i + 4]; p14 = buff1[i + 4];
-        p05 = buff0[i + 5]; p15 = buff1[i + 5];
-
-        buffd[i    ] = (p00 * k0 + p01 * k1 + p02 * k2 + p03 * k3 + p04 * k4 +
-                        p10 * k5 + p11 * k6 + p12 * k7 + p13 * k8 + p14 * k9);
-        buffd[i + 1] = (p01 * k0 + p02 * k1 + p03 * k2 + p04 * k3 + p05 * k4 +
-                        p11 * k5 + p12 * k6 + p13 * k7 + p14 * k8 + p15 * k9);
-
-        sp += chan2;
-        dp += chan2;
-      }
-
-      /*
-       *  Second loop
-       */
-      k0 = k[10]; k1 = k[11]; k2 = k[12]; k3 = k[13]; k4 = k[14];
-      k5 = k[15]; k6 = k[16]; k7 = k[17]; k8 = k[18]; k9 = k[19];
-
-      sp = sl;
-      dp = dl;
-
-      p02 = buff2[0];
-      p12 = buff3[0];
-      p03 = buff2[1];
-      p13 = buff3[1];
-      p04 = buff2[2];
-      p14 = buff3[2];
-
-#ifdef __SUNPRO_C
-#pragma pipeloop(0)
-#endif /* __SUNPRO_C */
-      for (i = 0; i <= (wid - 2); i += 2) {
-        p00 = p02; p10 = p12;
-        p01 = p03; p11 = p13;
-
-        p02 = buff2[i + 2]; p12 = buff3[i + 2];
-        p03 = buff2[i + 3]; p13 = buff3[i + 3];
-        p04 = buff2[i + 4]; p14 = buff3[i + 4];
-        p05 = buff2[i + 5]; p15 = buff3[i + 5];
-
-        dd.d64 = *(FTYPE   *)(buffi + i);
-        buff5[i    ] = (FTYPE)dd.i32s.i0;
-        buff5[i + 1] = (FTYPE)dd.i32s.i1;
-
-        buffd[i    ] += (p00 * k0 + p01 * k1 + p02 * k2 + p03 * k3 + p04 * k4 +
-                         p10 * k5 + p11 * k6 + p12 * k7 + p13 * k8 + p14 * k9);
-        buffd[i + 1] += (p01 * k0 + p02 * k1 + p03 * k2 + p04 * k3 + p05 * k4 +
-                         p11 * k5 + p12 * k6 + p13 * k7 + p14 * k8 + p15 * k9);
-
-        sp += chan2;
-        dp += chan2;
-      }
-
-      /*
-       *  3 loop
-       */
-      k0 = k[20]; k1 = k[21]; k2 = k[22]; k3 = k[23]; k4 = k[24];
-
-      sp = sl;
-      dp = dl;
-
-      p02 = buff4[0];
-      p03 = buff4[1];
-      p04 = buff4[2];
-      p05 = buff4[3];
-
-#ifdef __SUNPRO_C
-#pragma pipeloop(0)
-#endif /* __SUNPRO_C */
-      for (i = 0; i <= (wid - 2); i += 2) {
-        p00 = p02; p01 = p03; p02 = p04; p03 = p05;
-
-        p04 = buff4[i + 4]; p05 = buff4[i + 5];
-
-        d0 = D2I(p00 * k0 + p01 * k1 + p02 * k2 + p03 * k3 + p04 * k4 + buffd[i]);
-        d1 = D2I(p01 * k0 + p02 * k1 + p03 * k2 + p04 * k3 + p05 * k4 + buffd[i + 1]);
-
-        dp[0    ] = FROM_S32(d0);
-        dp[chan1] = FROM_S32(d1);
-
-        sp += chan2;
-        dp += chan2;
-      }
-
-      /* last pixels */
-      for (; i < wid; i++) {
-        p00 = buff0[i];     p10 = buff1[i];     p20 = buff2[i];     p30 = buff3[i];
-        p01 = buff0[i + 1]; p11 = buff1[i + 1]; p21 = buff2[i + 1]; p31 = buff3[i + 1];
-        p02 = buff0[i + 2]; p12 = buff1[i + 2]; p22 = buff2[i + 2]; p32 = buff3[i + 2];
-        p03 = buff0[i + 3]; p13 = buff1[i + 3]; p23 = buff2[i + 3]; p33 = buff3[i + 3];
-        p04 = buff0[i + 4]; p14 = buff1[i + 4]; p24 = buff2[i + 4]; p34 = buff3[i + 4];
-
-        p40 = buff4[i];     p41 = buff4[i + 1]; p42 = buff4[i + 2];
-        p43 = buff4[i + 3]; p44 = buff4[i + 4];
-
-        buff5[i] = (FTYPE)sp[0];
-
-        buffo[i] = D2I(p00 * k[0] + p01 * k[1] + p02 * k[2] + p03 * k[3] + p04 * k[4] +
-                       p10 * k[5] + p11 * k[6] + p12 * k[7] + p13 * k[8] + p14 * k[9] +
-                       p20 * k[10] + p21 * k[11] + p22 * k[12] + p23 * k[13] + p24 * k[14] +
-                       p30 * k[15] + p31 * k[16] + p32 * k[17] + p33 * k[18] + p34 * k[19] +
-                       p40 * k[20] + p41 * k[21] + p42 * k[22] + p43 * k[23] + p44 * k[24]);
-
-        dp[0] = FROM_S32(buffo[i]);
-
-        sp += chan1;
-        dp += chan1;
-      }
-
-      buff5[wid    ] = (FTYPE)sp[0];
-      buff5[wid + 1] = (FTYPE)sp[chan1];
-      buff5[wid + 2] = (FTYPE)sp[chan2];
-      buff5[wid + 3] = (FTYPE)sp[chan2 + chan1];
-
-      /* next line */
-      sl += sll;
-      dl += dll;
-
-      buffT = buff0;
-      buff0 = buff1;
-      buff1 = buff2;
-      buff2 = buff3;
-      buff3 = buff4;
-      buff4 = buff5;
-      buff5 = buffT;
-    }
-  }
-
-  if (pbuff != buff) mlib_free(pbuff);
-
-  return MLIB_SUCCESS;
-}
-
-/***************************************************************/
-#ifndef __sparc /* for x86, using integer multiplies is faster */
-
-mlib_status CONV_FUNC_I(5x5)(mlib_image       *dst,
-                             const mlib_image *src,
-                             const mlib_s32   *kern,
-                             mlib_s32         scalef_expon,
-                             mlib_s32         cmask)
-{
-  mlib_s32 buff[BUFF_LINE];
-  mlib_s32 *buffd;
-  mlib_s32 k[KSIZE*KSIZE];
-  mlib_s32 shift1, shift2;
-  mlib_s32 k0, k1, k2, k3, k4, k5, k6, k7, k8, k9;
-  mlib_s32 p00, p01, p02, p03, p04, p05,
-           p10, p11, p12, p13, p14, p15;
-  DTYPE    *adr_src, *sl, *sp0, *sp1;
-  DTYPE    *adr_dst, *dl, *dp;
-  mlib_s32 *pbuff = buff;
-  mlib_s32 wid, hgt, sll, dll;
-  mlib_s32 nchannel, chan1, chan2, chan3, chan4;
-  mlib_s32 i, j, c;
-
-#if IMG_TYPE != 1
-  shift1 = 16;
-#else
-  shift1 = 8;
-#endif /* IMG_TYPE != 1 */
-
-  shift2 = scalef_expon - shift1;
-
-  for (j = 0; j < KSIZE*KSIZE; j++) k[j] = kern[j] >> shift1;
-
-  GET_SRC_DST_PARAMETERS(DTYPE);
-
-  if (wid > BUFF_LINE) {
-    pbuff = mlib_malloc(sizeof(mlib_s32)*wid);
-
-    if (pbuff == NULL) return MLIB_FAILURE;
-  }
-
-  buffd = pbuff;
-
-  chan1 = nchannel;
-  chan2 = chan1 + chan1;
-  chan3 = chan2 + chan1;
-  chan4 = chan3 + chan1;
-
-  wid -= (KSIZE - 1);
-  hgt -= (KSIZE - 1);
-
-  adr_dst += ((KSIZE - 1)/2)*(dll + chan1);
-
-  for (c = 0; c < chan1; c++) {
-    if (!(cmask & (1 << (chan1 - 1 - c)))) continue;
-
-    sl = adr_src + c;
-    dl = adr_dst + c;
-
-    for (j = 0; j < hgt; j++) {
-      mlib_s32 pix0, pix1;
-      /*
-       *  First loop
-       */
-      sp0 = sl;
-      sp1 = sp0 + sll;
-      dp = dl;
-
-      k0 = k[0]; k1 = k[1]; k2 = k[2]; k3 = k[3]; k4 = k[4];
-      k5 = k[5]; k6 = k[6]; k7 = k[7]; k8 = k[8]; k9 = k[9];
-
-      p02 = sp0[0];     p12 = sp1[0];
-      p03 = sp0[chan1]; p13 = sp1[chan1];
-      p04 = sp0[chan2]; p14 = sp1[chan2];
-      p05 = sp0[chan3]; p15 = sp1[chan3];
-
-      sp0 += chan4;
-      sp1 += chan4;
-
-#ifdef __SUNPRO_C
-#pragma pipeloop(0)
-#endif /* __SUNPRO_C */
-      for (i = 0; i <= (wid - 2); i += 2) {
-        p00 = p02; p10 = p12;
-        p01 = p03; p11 = p13;
-        p02 = p04; p12 = p14;
-        p03 = p05; p13 = p15;
-
-        p04 = sp0[0];     p14 = sp1[0];
-        p05 = sp0[chan1]; p15 = sp1[chan1];
-
-        buffd[i    ] = (p00 * k0 + p01 * k1 + p02 * k2 + p03 * k3 + p04 * k4 +
-                        p10 * k5 + p11 * k6 + p12 * k7 + p13 * k8 + p14 * k9);
-        buffd[i + 1] = (p01 * k0 + p02 * k1 + p03 * k2 + p04 * k3 + p05 * k4 +
-                        p11 * k5 + p12 * k6 + p13 * k7 + p14 * k8 + p15 * k9);
-
-        sp0 += chan2;
-        sp1 += chan2;
-        dp += chan2;
-      }
-
-      if (wid & 1) {
-        p00 = p02; p10 = p12;
-        p01 = p03; p11 = p13;
-        p02 = p04; p12 = p14;
-        p03 = p05; p13 = p15;
-
-        p04 = sp0[0];     p14 = sp1[0];
-
-        buffd[i] = (p00 * k0 + p01 * k1 + p02 * k2 + p03 * k3 + p04 * k4 +
-                    p10 * k5 + p11 * k6 + p12 * k7 + p13 * k8 + p14 * k9);
-      }
-
-      /*
-       *  Second loop
-       */
-      sp0 = sl + 2*sll;
-      sp1 = sp0 + sll;
-      dp = dl;
-
-      k0 = k[10]; k1 = k[11]; k2 = k[12]; k3 = k[13]; k4 = k[14];
-      k5 = k[15]; k6 = k[16]; k7 = k[17]; k8 = k[18]; k9 = k[19];
-
-      p02 = sp0[0];     p12 = sp1[0];
-      p03 = sp0[chan1]; p13 = sp1[chan1];
-      p04 = sp0[chan2]; p14 = sp1[chan2];
-      p05 = sp0[chan3]; p15 = sp1[chan3];
-
-      sp0 += chan4;
-      sp1 += chan4;
-
-#ifdef __SUNPRO_C
-#pragma pipeloop(0)
-#endif /* __SUNPRO_C */
-      for (i = 0; i <= (wid - 2); i += 2) {
-        p00 = p02; p10 = p12;
-        p01 = p03; p11 = p13;
-        p02 = p04; p12 = p14;
-        p03 = p05; p13 = p15;
-
-        p04 = sp0[0];     p14 = sp1[0];
-        p05 = sp0[chan1]; p15 = sp1[chan1];
-
-        buffd[i    ] += (p00 * k0 + p01 * k1 + p02 * k2 + p03 * k3 + p04 * k4 +
-                         p10 * k5 + p11 * k6 + p12 * k7 + p13 * k8 + p14 * k9);
-        buffd[i + 1] += (p01 * k0 + p02 * k1 + p03 * k2 + p04 * k3 + p05 * k4 +
-                         p11 * k5 + p12 * k6 + p13 * k7 + p14 * k8 + p15 * k9);
-
-        sp0 += chan2;
-        sp1 += chan2;
-        dp += chan2;
-      }
-
-      if (wid & 1) {
-        p00 = p02; p10 = p12;
-        p01 = p03; p11 = p13;
-        p02 = p04; p12 = p14;
-        p03 = p05; p13 = p15;
-
-        p04 = sp0[0];     p14 = sp1[0];
-
-        buffd[i] += (p00 * k0 + p01 * k1 + p02 * k2 + p03 * k3 + p04 * k4 +
-                     p10 * k5 + p11 * k6 + p12 * k7 + p13 * k8 + p14 * k9);
-      }
-
-      /*
-       *  3 loop
-       */
-      dp = dl;
-      sp0 = sl + 4*sll;
-
-      k0 = k[20]; k1 = k[21]; k2 = k[22]; k3 = k[23]; k4 = k[24];
-
-      p02 = sp0[0];
-      p03 = sp0[chan1];
-      p04 = sp0[chan2];
-      p05 = sp0[chan3];
-
-      sp0 += chan2 + chan2;
-
-#ifdef __SUNPRO_C
-#pragma pipeloop(0)
-#endif /* __SUNPRO_C */
-      for (i = 0; i <= (wid - 2); i += 2) {
-        p00 = p02; p01 = p03; p02 = p04; p03 = p05;
-
-        p04 = sp0[0]; p05 = sp0[chan1];
-
-        pix0 = (buffd[i    ] + p00 * k0 + p01 * k1 + p02 * k2 +
-                p03 * k3 + p04 * k4) >> shift2;
-        pix1 = (buffd[i + 1] + p01 * k0 + p02 * k1 + p03 * k2 +
-                p04 * k3 + p05 * k4) >> shift2;
-
-        CLAMP_STORE(dp[0],     pix0)
-        CLAMP_STORE(dp[chan1], pix1)
-
-        dp  += chan2;
-        sp0 += chan2;
-      }
-
-      if (wid & 1) {
-        p00 = p02; p01 = p03; p02 = p04; p03 = p05;
-
-        p04 = sp0[0];
-
-        pix0 = (buffd[i    ] + p00 * k0 + p01 * k1 + p02 * k2 +
-                p03 * k3 + p04 * k4) >> shift2;
-        CLAMP_STORE(dp[0],     pix0)
-      }
-
-      /* next line */
-      sl += sll;
-      dl += dll;
-    }
-  }
-
-  if (pbuff != buff) mlib_free(pbuff);
-
-  return MLIB_SUCCESS;
-}
-
-#endif /* __sparc ( for x86, using integer multiplies is faster ) */
-
-/***************************************************************/
-#if IMG_TYPE == 1
-
-#undef  KSIZE
-#define KSIZE 7
-
-mlib_status CONV_FUNC(7x7)(mlib_image       *dst,
-                           const mlib_image *src,
-                           const mlib_s32   *kern,
-                           mlib_s32         scalef_expon,
-                           mlib_s32         cmask)
-{
-  FTYPE    buff[(KSIZE + 3)*BUFF_LINE], *buffs[2*(KSIZE + 1)], *buffd;
-  FTYPE    k[KSIZE*KSIZE];
-  mlib_s32 l, m, buff_ind;
-  mlib_s32 d0, d1;
-  FTYPE    k0, k1, k2, k3, k4, k5, k6;
-  FTYPE    p0, p1, p2, p3, p4, p5, p6, p7;
-  DTYPE *sl2, *sl3, *sl4, *sl5, *sl6;
-  DEF_VARS(DTYPE);
-  DTYPE *sl1;
-  mlib_s32 chan2;
-  mlib_s32 *buffo, *buffi;
-  LOAD_KERNEL(KSIZE*KSIZE);
-  GET_SRC_DST_PARAMETERS(DTYPE);
-
-  if (wid > BUFF_LINE) {
-    pbuff = mlib_malloc((KSIZE + 3)*sizeof(FTYPE)*wid);
-
-    if (pbuff == NULL) return MLIB_FAILURE;
-  }
-
-  for (l = 0; l < KSIZE + 1; l++) buffs[l] = pbuff + l*wid;
-  for (l = 0; l < KSIZE + 1; l++) buffs[l + (KSIZE + 1)] = buffs[l];
-  buffd = buffs[KSIZE] + wid;
-  buffo = (mlib_s32*)(buffd + wid);
-  buffi = buffo + (wid &~ 1);
-
-  chan1 = nchannel;
-  chan2 = chan1 + chan1;
-
-  wid -= (KSIZE - 1);
-  hgt -= (KSIZE - 1);
-
-  adr_dst += ((KSIZE - 1)/2)*(dll + chan1);
-
-  for (c = 0; c < nchannel; c++) {
-    if (!(cmask & (1 << (nchannel - 1 - c)))) continue;
-
-    sl = adr_src + c;
-    dl = adr_dst + c;
-
-    sl1 = sl  + sll;
-    sl2 = sl1 + sll;
-    sl3 = sl2 + sll;
-    sl4 = sl3 + sll;
-    sl5 = sl4 + sll;
-    sl6 = sl5 + sll;
-#ifdef __SUNPRO_C
-#pragma pipeloop(0)
-#endif /* __SUNPRO_C */
-    for (i = 0; i < wid + (KSIZE - 1); i++) {
-      buffs[0][i] = (FTYPE)sl[i*chan1];
-      buffs[1][i] = (FTYPE)sl1[i*chan1];
-      buffs[2][i] = (FTYPE)sl2[i*chan1];
-      buffs[3][i] = (FTYPE)sl3[i*chan1];
-      buffs[4][i] = (FTYPE)sl4[i*chan1];
-      buffs[5][i] = (FTYPE)sl5[i*chan1];
-      buffs[6][i] = (FTYPE)sl6[i*chan1];
-    }
-
-    buff_ind = 0;
-
-#ifdef __SUNPRO_C
-#pragma pipeloop(0)
-#endif /* __SUNPRO_C */
-    for (i = 0; i < wid; i++) buffd[i] = 0.0;
-
-    sl += KSIZE*sll;
-
-    for (j = 0; j < hgt; j++) {
-      FTYPE    **buffc = buffs + buff_ind;
-      FTYPE    *buffn = buffc[KSIZE];
-      FTYPE    *pk = k;
-
-      for (l = 0; l < KSIZE; l++) {
-        FTYPE    *buff = buffc[l];
-        d64_2x32 dd;
-
-        sp = sl;
-        dp = dl;
-
-        p2 = buff[0]; p3 = buff[1]; p4 = buff[2];
-        p5 = buff[3]; p6 = buff[4]; p7 = buff[5];
-
-        k0 = *pk++; k1 = *pk++; k2 = *pk++; k3 = *pk++;
-        k4 = *pk++; k5 = *pk++; k6 = *pk++;
-
-        if (l < (KSIZE - 1)) {
-#ifdef __SUNPRO_C
-#pragma pipeloop(0)
-#endif /* __SUNPRO_C */
-          for (i = 0; i <= (wid - 2); i += 2) {
-            p0 = p2; p1 = p3; p2 = p4; p3 = p5; p4 = p6; p5 = p7;
-
-            p6 = buff[i + 6]; p7 = buff[i + 7];
-
-            buffd[i    ] += p0*k0 + p1*k1 + p2*k2 + p3*k3 + p4*k4 + p5*k5 + p6*k6;
-            buffd[i + 1] += p1*k0 + p2*k1 + p3*k2 + p4*k3 + p5*k4 + p6*k5 + p7*k6;
-          }
-
-        } else {
-#ifdef __SUNPRO_C
-#pragma pipeloop(0)
-#endif /* __SUNPRO_C */
-          for (i = 0; i <= (wid - 2); i += 2) {
-            p0 = p2; p1 = p3; p2 = p4; p3 = p5; p4 = p6; p5 = p7;
-
-            p6 = buff[i + 6]; p7 = buff[i + 7];
-
-            LOAD_BUFF(buffi);
-
-            dd.d64 = *(FTYPE   *)(buffi + i);
-            buffn[i    ] = (FTYPE)dd.i32s.i0;
-            buffn[i + 1] = (FTYPE)dd.i32s.i1;
-
-            d0 = D2I(p0*k0 + p1*k1 + p2*k2 + p3*k3 + p4*k4 + p5*k5 + p6*k6 + buffd[i    ]);
-            d1 = D2I(p1*k0 + p2*k1 + p3*k2 + p4*k3 + p5*k4 + p6*k5 + p7*k6 + buffd[i + 1]);
-
-            dp[0    ] = FROM_S32(d0);
-            dp[chan1] = FROM_S32(d1);
-
-            buffd[i    ] = 0.0;
-            buffd[i + 1] = 0.0;
-
-            sp += chan2;
-            dp += chan2;
-          }
-        }
-      }
-
-      /* last pixels */
-      for (; i < wid; i++) {
-        FTYPE    *pk = k, s = 0;
-        mlib_s32 d0;
-
-        for (l = 0; l < KSIZE; l++) {
-          FTYPE    *buff = buffc[l] + i;
-
-          for (m = 0; m < KSIZE; m++) s += buff[m] * (*pk++);
-        }
-
-        d0 = D2I(s);
-        dp[0] = FROM_S32(d0);
-
-        buffn[i] = (FTYPE)sp[0];
-
-        sp += chan1;
-        dp += chan1;
-      }
-
-      for (l = 0; l < (KSIZE - 1); l++) buffn[wid + l] = sp[l*chan1];
-
-      /* next line */
-      sl += sll;
-      dl += dll;
-
-      buff_ind++;
-
-      if (buff_ind >= KSIZE + 1) buff_ind = 0;
-    }
-  }
-
-  if (pbuff != buff) mlib_free(pbuff);
-
-  return MLIB_SUCCESS;
-}
-
-#endif /* IMG_TYPE == 1 */
-
-/***************************************************************/
 #define MAX_KER   7
 #define MAX_N    15
 
--- a/jdk/src/java.desktop/share/native/libmlib_image/mlib_ImageConv_D64nw.c	Thu May 19 17:48:02 2016 +0000
+++ b/jdk/src/java.desktop/share/native/libmlib_image/mlib_ImageConv_D64nw.c	Thu May 19 19:46:20 2016 +0000
@@ -75,495 +75,6 @@
   mlib_s32 i = 0, j, c
 
 /***************************************************************/
-#undef  KSIZE
-#define KSIZE 2
-
-mlib_status CONV_FUNC(2x2)(mlib_image       *dst,
-                           const mlib_image *src,
-                           const mlib_d64   *kern,
-                           mlib_s32         cmask)
-{
-  DEF_VARS(DTYPE);
-  DTYPE    *sp0, *sp1;
-  mlib_s32 chan2 = chan1 + chan1;
-  mlib_s32 chan3 = chan1 + chan2;
-  mlib_s32 chan4 = chan3 + chan1;
-  DTYPE k0, k1, k2, k3;
-  DTYPE p00, p01, p02, p03, p04,
-        p10, p11, p12, p13, p14;
-
-  /* keep kernel in regs */
-  k0 = (DTYPE)kern[0];  k1 = (DTYPE)kern[1];
-  k2 = (DTYPE)kern[2];  k3 = (DTYPE)kern[3];
-
-  wid -= (KSIZE - 1);
-  hgt -= (KSIZE - 1);
-
-  for (c = 0; c < chan1; c++) {
-    if (!(cmask & (1 << (chan1 - 1 - c)))) continue;
-
-    dl = adr_dst + c;
-    sl = adr_src + c;
-
-    for (j = 0; j < hgt; j++) {
-      dp  = dl;
-      sp0 = sl;
-      sp1 = sp0 + sll;
-
-      p04 = sp0[0];
-      p14 = sp1[0];
-
-      sp0 += chan1;
-      sp1 += chan1;
-
-#ifdef __SUNPRO_C
-#pragma pipeloop(0)
-#endif /* __SUNPRO_C */
-      for (i = 0; i <= (wid - 4); i += 4) {
-        p00 = p04; p10 = p14;
-
-        p01 = sp0[0];     p11 = sp1[0];
-        p02 = sp0[chan1]; p12 = sp1[chan1];
-        p03 = sp0[chan2]; p13 = sp1[chan2];
-        p04 = sp0[chan3]; p14 = sp1[chan3];
-
-        dp[0    ] = p00 * k0 + p01 * k1 + p10 * k2 + p11 * k3;
-        dp[chan1] = p01 * k0 + p02 * k1 + p11 * k2 + p12 * k3;
-        dp[chan2] = p02 * k0 + p03 * k1 + p12 * k2 + p13 * k3;
-        dp[chan3] = p03 * k0 + p04 * k1 + p13 * k2 + p14 * k3;
-
-        dp  += chan4;
-        sp0 += chan4;
-        sp1 += chan4;
-      }
-
-      if (i < wid) {
-        p00 = p04;    p10 = p14;
-        p01 = sp0[0]; p11 = sp1[0];
-        dp[0] = p00 * k0 + p01 * k1 + p10 * k2 + p11 * k3;
-
-        if ((i + 1) < wid) {
-          p02 = sp0[chan1]; p12 = sp1[chan1];
-          dp[chan1] = p01 * k0 + p02 * k1 + p11 * k2 + p12 * k3;
-
-          if ((i + 2) < wid) {
-            p03 = sp0[chan2]; p13 = sp1[chan2];
-            dp[chan2] = p02 * k0 + p03 * k1 + p12 * k2 + p13 * k3;
-          }
-        }
-      }
-
-      sl += sll;
-      dl += dll;
-    }
-  }
-
-  return MLIB_SUCCESS;
-}
-
-/***************************************************************/
-#undef  KSIZE
-#define KSIZE 3
-
-mlib_status CONV_FUNC(3x3)(mlib_image       *dst,
-                           const mlib_image *src,
-                           const mlib_d64   *kern,
-                           mlib_s32         cmask)
-{
-  DEF_VARS(DTYPE);
-  mlib_s32 chan2 = chan1 + chan1;
-  DTYPE    *sp0, *sp1;
-  DTYPE *sp2;
-  DTYPE k0, k1, k2, k3, k4, k5, k6, k7, k8;
-  DTYPE p02, p03, p12, p13, p22, p23;
-
-  /* keep kernel in regs */
-  k0 = (DTYPE)kern[0];  k1 = (DTYPE)kern[1];  k2 = (DTYPE)kern[2];
-  k3 = (DTYPE)kern[3];  k4 = (DTYPE)kern[4];  k5 = (DTYPE)kern[5];
-  k6 = (DTYPE)kern[6];  k7 = (DTYPE)kern[7];  k8 = (DTYPE)kern[8];
-
-  wid -= (KSIZE - 1);
-  hgt -= (KSIZE - 1);
-
-  adr_dst += ((KSIZE - 1)/2)*(dll + chan1);
-
-  for (c = 0; c < chan1; c++) {
-    if (!(cmask & (1 << (chan1 - 1 - c)))) continue;
-
-    sl = adr_src + c;
-    dl = adr_dst + c;
-
-    for (j = 0; j < hgt; j++) {
-      DTYPE s0, s1;
-
-      dp  = dl;
-      sp0 = sl;
-      sp1 = sp0 + sll;
-      sp2 = sp1 + sll;
-
-      p02 = sp0[0];
-      p12 = sp1[0];
-      p22 = sp2[0];
-
-      p03 = sp0[chan1];
-      p13 = sp1[chan1];
-      p23 = sp2[chan1];
-
-      s0 = p02 * k0 + p03 * k1 + p12 * k3 + p13 * k4 + p22 * k6 + p23 * k7;
-      s1 = p03 * k0 + p13 * k3 + p23 * k6;
-
-      sp0 += chan2;
-      sp1 += chan2;
-      sp2 += chan2;
-
-#ifdef __SUNPRO_C
-#pragma pipeloop(0)
-#endif /* __SUNPRO_C */
-      for (i = 0; i <= (wid - 2); i += 2) {
-        p02 = sp0[0];     p12 = sp1[0];     p22 = sp2[0];
-        p03 = sp0[chan1]; p13 = sp1[chan1]; p23 = sp2[chan1];
-
-        dp[0    ] = s0 + p02 * k2 + p12 * k5 + p22 * k8;
-        dp[chan1] = s1 + p02 * k1 + p03 * k2 + p12 * k4 + p13 * k5 + p22 * k7 + p23 * k8;
-
-        s0 = p02 * k0 + p03 * k1 + p12 * k3 + p13 * k4 + p22 * k6 + p23 * k7;
-        s1 = p03 * k0 + p13 * k3 + p23 * k6;
-
-        sp0 += chan2;
-        sp1 += chan2;
-        sp2 += chan2;
-        dp += chan2;
-      }
-
-      if (wid & 1) {
-        p02 = sp0[0]; p12 = sp1[0]; p22 = sp2[0];
-        dp[0] = s0 + p02 * k2 + p12 * k5 + p22 * k8;
-      }
-
-      sl += sll;
-      dl += dll;
-    }
-  }
-
-  return MLIB_SUCCESS;
-}
-
-/***************************************************************/
-#undef  KSIZE
-#define KSIZE 4
-
-mlib_status CONV_FUNC(4x4)(mlib_image       *dst,
-                           const mlib_image *src,
-                           const mlib_d64   *k,
-                           mlib_s32         cmask)
-{
-  DTYPE k0, k1, k2, k3, k4, k5, k6, k7;
-  DTYPE p00, p01, p02, p03, p04,
-        p10, p11, p12, p13, p14;
-  DEF_VARS(DTYPE);
-  DTYPE    *sp0, *sp1;
-  mlib_s32 chan2 = chan1 + chan1;
-  mlib_s32 chan3 = chan1 + chan2;
-
-  wid -= (KSIZE - 1);
-  hgt -= (KSIZE - 1);
-
-  adr_dst += ((KSIZE - 1)/2)*(dll + chan1);
-
-  for (c = 0; c < chan1; c++) {
-    if (!(cmask & (1 << (chan1 - 1 - c)))) continue;
-
-    sl = adr_src + c;
-    dl = adr_dst + c;
-
-    for (j = 0; j < hgt; j++) {
-      /*
-       *  First loop on two first lines of kernel
-       */
-      sp0 = sl;
-      sp1 = sp0 + sll;
-      dp = dl;
-
-      k0 = (DTYPE)k[0]; k1 = (DTYPE)k[1]; k2 = (DTYPE)k[2]; k3 = (DTYPE)k[3];
-      k4 = (DTYPE)k[4]; k5 = (DTYPE)k[5]; k6 = (DTYPE)k[6]; k7 = (DTYPE)k[7];
-
-      p02 = sp0[0];     p12 = sp1[0];
-      p03 = sp0[chan1]; p13 = sp1[chan1];
-      p04 = sp0[chan2]; p14 = sp1[chan2];
-
-      sp0 += chan3;
-      sp1 += chan3;
-
-#ifdef __SUNPRO_C
-#pragma pipeloop(0)
-#endif /* __SUNPRO_C */
-      for (i = 0; i <= (wid - 2); i += 2) {
-        p00 = p02; p10 = p12;
-        p01 = p03; p11 = p13;
-        p02 = p04; p12 = p14;
-
-        p03 = sp0[0];     p13 = sp1[0];
-        p04 = sp0[chan1]; p14 = sp1[chan1];
-
-        dp[0    ] = (p00 * k0 + p01 * k1 + p02 * k2 + p03 * k3 +
-                     p10 * k4 + p11 * k5 + p12 * k6 + p13 * k7);
-        dp[chan1] = (p01 * k0 + p02 * k1 + p03 * k2 + p04 * k3 +
-                     p11 * k4 + p12 * k5 + p13 * k6 + p14 * k7);
-
-        sp0 += chan2;
-        sp1 += chan2;
-        dp += chan2;
-      }
-
-      if (wid & 1) {
-        p00 = p02; p10 = p12;
-        p01 = p03; p11 = p13;
-        p02 = p04; p12 = p14;
-        p03 = sp0[0]; p13 = sp1[0];
-
-        dp[0] = (p00 * k0 + p01 * k1 + p02 * k2 + p03 * k3 +
-                 p10 * k4 + p11 * k5 + p12 * k6 + p13 * k7);
-      }
-
-      /*
-       *  Second loop on two last lines of kernel
-       */
-      sp0 = sl + 2*sll;
-      sp1 = sp0 + sll;
-      dp = dl;
-
-      k0 = (DTYPE)k[ 8]; k1 = (DTYPE)k[ 9]; k2 = (DTYPE)k[10]; k3 = (DTYPE)k[11];
-      k4 = (DTYPE)k[12]; k5 = (DTYPE)k[13]; k6 = (DTYPE)k[14]; k7 = (DTYPE)k[15];
-
-      p02 = sp0[0];     p12 = sp1[0];
-      p03 = sp0[chan1]; p13 = sp1[chan1];
-      p04 = sp0[chan2]; p14 = sp1[chan2];
-
-      sp0 += chan3;
-      sp1 += chan3;
-
-#ifdef __SUNPRO_C
-#pragma pipeloop(0)
-#endif /* __SUNPRO_C */
-      for (i = 0; i <= (wid - 2); i += 2) {
-        p00 = p02; p10 = p12;
-        p01 = p03; p11 = p13;
-        p02 = p04; p12 = p14;
-
-        p03 = sp0[0];     p13 = sp1[0];
-        p04 = sp0[chan1]; p14 = sp1[chan1];
-
-        dp[0    ] += (p00 * k0 + p01 * k1 + p02 * k2 + p03 * k3 +
-                      p10 * k4 + p11 * k5 + p12 * k6 + p13 * k7);
-        dp[chan1] += (p01 * k0 + p02 * k1 + p03 * k2 + p04 * k3 +
-                      p11 * k4 + p12 * k5 + p13 * k6 + p14 * k7);
-
-        sp0 += chan2;
-        sp1 += chan2;
-        dp += chan2;
-      }
-
-      if (wid & 1) {
-        p00 = p02; p10 = p12;
-        p01 = p03; p11 = p13;
-        p02 = p04; p12 = p14;
-        p03 = sp0[0]; p13 = sp1[0];
-
-        dp[0] += (p00 * k0 + p01 * k1 + p02 * k2 + p03 * k3 +
-                  p10 * k4 + p11 * k5 + p12 * k6 + p13 * k7);
-      }
-
-      /* next line */
-      sl += sll;
-      dl += dll;
-    }
-  }
-
-  return MLIB_SUCCESS;
-}
-
-/***************************************************************/
-#undef  KSIZE
-#define KSIZE 5
-
-mlib_status CONV_FUNC(5x5)(mlib_image       *dst,
-                           const mlib_image *src,
-                           const mlib_d64   *k,
-                           mlib_s32         cmask)
-{
-  DTYPE k0, k1, k2, k3, k4, k5, k6, k7, k8, k9;
-  DTYPE p00, p01, p02, p03, p04, p05,
-        p10, p11, p12, p13, p14, p15;
-  DEF_VARS(DTYPE);
-  DTYPE    *sp0, *sp1;
-  mlib_s32 chan2 = chan1 + chan1;
-  mlib_s32 chan3 = chan1 + chan2;
-  mlib_s32 chan4 = chan3 + chan1;
-
-  wid -= (KSIZE - 1);
-  hgt -= (KSIZE - 1);
-
-  adr_dst += ((KSIZE - 1)/2)*(dll + chan1);
-
-  for (c = 0; c < chan1; c++) {
-    if (!(cmask & (1 << (chan1 - 1 - c)))) continue;
-
-    sl = adr_src + c;
-    dl = adr_dst + c;
-
-    for (j = 0; j < hgt; j++) {
-      /*
-       *  First loop
-       */
-      sp0 = sl;
-      sp1 = sp0 + sll;
-      dp = dl;
-
-      k0 = (DTYPE)k[0]; k1 = (DTYPE)k[1]; k2 = (DTYPE)k[2]; k3 = (DTYPE)k[3]; k4 = (DTYPE)k[4];
-      k5 = (DTYPE)k[5]; k6 = (DTYPE)k[6]; k7 = (DTYPE)k[7]; k8 = (DTYPE)k[8]; k9 = (DTYPE)k[9];
-
-      p02 = sp0[0];     p12 = sp1[0];
-      p03 = sp0[chan1]; p13 = sp1[chan1];
-      p04 = sp0[chan2]; p14 = sp1[chan2];
-      p05 = sp0[chan3]; p15 = sp1[chan3];
-
-      sp0 += chan4;
-      sp1 += chan4;
-
-#ifdef __SUNPRO_C
-#pragma pipeloop(0)
-#endif /* __SUNPRO_C */
-      for (i = 0; i <= (wid - 2); i += 2) {
-        p00 = p02; p10 = p12;
-        p01 = p03; p11 = p13;
-        p02 = p04; p12 = p14;
-        p03 = p05; p13 = p15;
-
-        p04 = sp0[0];     p14 = sp1[0];
-        p05 = sp0[chan1]; p15 = sp1[chan1];
-
-        dp[    0] = (p00 * k0 + p01 * k1 + p02 * k2 + p03 * k3 + p04 * k4 +
-                     p10 * k5 + p11 * k6 + p12 * k7 + p13 * k8 + p14 * k9);
-        dp[chan1] = (p01 * k0 + p02 * k1 + p03 * k2 + p04 * k3 + p05 * k4 +
-                     p11 * k5 + p12 * k6 + p13 * k7 + p14 * k8 + p15 * k9);
-
-        sp0 += chan2;
-        sp1 += chan2;
-        dp += chan2;
-      }
-
-      if (wid & 1) {
-        p00 = p02; p10 = p12;
-        p01 = p03; p11 = p13;
-        p02 = p04; p12 = p14;
-        p03 = p05; p13 = p15;
-
-        p04 = sp0[0];     p14 = sp1[0];
-
-        dp[0] = (p00 * k0 + p01 * k1 + p02 * k2 + p03 * k3 + p04 * k4 +
-                 p10 * k5 + p11 * k6 + p12 * k7 + p13 * k8 + p14 * k9);
-      }
-
-      /*
-       *  Second loop
-       */
-      sp0 = sl + 2*sll;
-      sp1 = sp0 + sll;
-      dp = dl;
-
-      k0 = (DTYPE)k[10]; k1 = (DTYPE)k[11]; k2 = (DTYPE)k[12]; k3 = (DTYPE)k[13]; k4 = (DTYPE)k[14];
-      k5 = (DTYPE)k[15]; k6 = (DTYPE)k[16]; k7 = (DTYPE)k[17]; k8 = (DTYPE)k[18]; k9 = (DTYPE)k[19];
-
-      p02 = sp0[0];     p12 = sp1[0];
-      p03 = sp0[chan1]; p13 = sp1[chan1];
-      p04 = sp0[chan2]; p14 = sp1[chan2];
-      p05 = sp0[chan3]; p15 = sp1[chan3];
-
-      sp0 += chan4;
-      sp1 += chan4;
-
-#ifdef __SUNPRO_C
-#pragma pipeloop(0)
-#endif /* __SUNPRO_C */
-      for (i = 0; i <= (wid - 2); i += 2) {
-        p00 = p02; p10 = p12;
-        p01 = p03; p11 = p13;
-        p02 = p04; p12 = p14;
-        p03 = p05; p13 = p15;
-
-        p04 = sp0[0];     p14 = sp1[0];
-        p05 = sp0[chan1]; p15 = sp1[chan1];
-
-        dp[    0] += (p00 * k0 + p01 * k1 + p02 * k2 + p03 * k3 + p04 * k4 +
-                      p10 * k5 + p11 * k6 + p12 * k7 + p13 * k8 + p14 * k9);
-        dp[chan1] += (p01 * k0 + p02 * k1 + p03 * k2 + p04 * k3 + p05 * k4 +
-                      p11 * k5 + p12 * k6 + p13 * k7 + p14 * k8 + p15 * k9);
-
-        sp0 += chan2;
-        sp1 += chan2;
-        dp += chan2;
-      }
-
-      if (wid & 1) {
-        p00 = p02; p10 = p12;
-        p01 = p03; p11 = p13;
-        p02 = p04; p12 = p14;
-        p03 = p05; p13 = p15;
-
-        p04 = sp0[0];     p14 = sp1[0];
-
-        dp[0] += (p00 * k0 + p01 * k1 + p02 * k2 + p03 * k3 + p04 * k4 +
-                  p10 * k5 + p11 * k6 + p12 * k7 + p13 * k8 + p14 * k9);
-      }
-
-      /*
-       *  3 loop
-       */
-      dp = dl;
-      sp0 = sl + 4*sll;
-
-      k0 = (DTYPE)k[20]; k1 = (DTYPE)k[21]; k2 = (DTYPE)k[22]; k3 = (DTYPE)k[23]; k4 = (DTYPE)k[24];
-
-      p02 = sp0[0];
-      p03 = sp0[chan1];
-      p04 = sp0[chan2];
-      p05 = sp0[chan3];
-
-      sp0 += chan2 + chan2;
-
-#ifdef __SUNPRO_C
-#pragma pipeloop(0)
-#endif /* __SUNPRO_C */
-      for (i = 0; i <= (wid - 2); i += 2) {
-        p00 = p02; p01 = p03; p02 = p04; p03 = p05;
-
-        p04 = sp0[0]; p05 = sp0[chan1];
-
-        dp[0    ] += p00 * k0 + p01 * k1 + p02 * k2 + p03 * k3 + p04 * k4;
-        dp[chan1] += p01 * k0 + p02 * k1 + p03 * k2 + p04 * k3 + p05 * k4;
-
-        dp  += chan2;
-        sp0 += chan2;
-      }
-
-      if (wid & 1) {
-        p00 = p02; p01 = p03; p02 = p04; p03 = p05;
-
-        p04 = sp0[0];
-
-        dp[0] += p00 * k0 + p01 * k1 + p02 * k2 + p03 * k3 + p04 * k4;
-      }
-
-      /* next line */
-      sl += sll;
-      dl += dll;
-    }
-  }
-
-  return MLIB_SUCCESS;
-}
-
-/***************************************************************/
 #define BUFF_SIZE  1600
 
 #define CACHE_SIZE (64*1024)
--- a/jdk/src/java.desktop/share/native/libmlib_image/mlib_ImageConv_F32nw.c	Thu May 19 17:48:02 2016 +0000
+++ b/jdk/src/java.desktop/share/native/libmlib_image/mlib_ImageConv_F32nw.c	Thu May 19 19:46:20 2016 +0000
@@ -75,495 +75,6 @@
   mlib_s32 i, j, c
 
 /***************************************************************/
-#undef  KSIZE
-#define KSIZE 2
-
-mlib_status CONV_FUNC(2x2)(mlib_image       *dst,
-                           const mlib_image *src,
-                           const mlib_d64   *kern,
-                           mlib_s32         cmask)
-{
-  DEF_VARS(DTYPE);
-  DTYPE    *sp0, *sp1;
-  mlib_s32 chan2 = chan1 + chan1;
-  mlib_s32 chan3 = chan1 + chan2;
-  mlib_s32 chan4 = chan3 + chan1;
-  DTYPE k0, k1, k2, k3;
-  DTYPE p00, p01, p02, p03, p04,
-        p10, p11, p12, p13, p14;
-
-  /* keep kernel in regs */
-  k0 = (DTYPE)kern[0];  k1 = (DTYPE)kern[1];
-  k2 = (DTYPE)kern[2];  k3 = (DTYPE)kern[3];
-
-  wid -= (KSIZE - 1);
-  hgt -= (KSIZE - 1);
-
-  for (c = 0; c < chan1; c++) {
-    if (!(cmask & (1 << (chan1 - 1 - c)))) continue;
-
-    dl = adr_dst + c;
-    sl = adr_src + c;
-
-    for (j = 0; j < hgt; j++) {
-      dp  = dl;
-      sp0 = sl;
-      sp1 = sp0 + sll;
-
-      p04 = sp0[0];
-      p14 = sp1[0];
-
-      sp0 += chan1;
-      sp1 += chan1;
-
-#ifdef __SUNPRO_C
-#pragma pipeloop(0)
-#endif /* __SUNPRO_C */
-      for (i = 0; i <= (wid - 4); i += 4) {
-        p00 = p04; p10 = p14;
-
-        p01 = sp0[0];     p11 = sp1[0];
-        p02 = sp0[chan1]; p12 = sp1[chan1];
-        p03 = sp0[chan2]; p13 = sp1[chan2];
-        p04 = sp0[chan3]; p14 = sp1[chan3];
-
-        dp[0    ] = p00 * k0 + p01 * k1 + p10 * k2 + p11 * k3;
-        dp[chan1] = p01 * k0 + p02 * k1 + p11 * k2 + p12 * k3;
-        dp[chan2] = p02 * k0 + p03 * k1 + p12 * k2 + p13 * k3;
-        dp[chan3] = p03 * k0 + p04 * k1 + p13 * k2 + p14 * k3;
-
-        dp  += chan4;
-        sp0 += chan4;
-        sp1 += chan4;
-      }
-
-      if (i < wid) {
-        p00 = p04;    p10 = p14;
-        p01 = sp0[0]; p11 = sp1[0];
-        dp[0] = p00 * k0 + p01 * k1 + p10 * k2 + p11 * k3;
-
-        if ((i + 1) < wid) {
-          p02 = sp0[chan1]; p12 = sp1[chan1];
-          dp[chan1] = p01 * k0 + p02 * k1 + p11 * k2 + p12 * k3;
-
-          if ((i + 2) < wid) {
-            p03 = sp0[chan2]; p13 = sp1[chan2];
-            dp[chan2] = p02 * k0 + p03 * k1 + p12 * k2 + p13 * k3;
-          }
-        }
-      }
-
-      sl += sll;
-      dl += dll;
-    }
-  }
-
-  return MLIB_SUCCESS;
-}
-
-/***************************************************************/
-#undef  KSIZE
-#define KSIZE 3
-
-mlib_status CONV_FUNC(3x3)(mlib_image       *dst,
-                           const mlib_image *src,
-                           const mlib_d64   *kern,
-                           mlib_s32         cmask)
-{
-  DEF_VARS(DTYPE);
-  mlib_s32 chan2 = chan1 + chan1;
-  DTYPE    *sp0, *sp1;
-  DTYPE *sp2;
-  DTYPE k0, k1, k2, k3, k4, k5, k6, k7, k8;
-  DTYPE p02, p03, p12, p13, p22, p23;
-
-  /* keep kernel in regs */
-  k0 = (DTYPE)kern[0];  k1 = (DTYPE)kern[1];  k2 = (DTYPE)kern[2];
-  k3 = (DTYPE)kern[3];  k4 = (DTYPE)kern[4];  k5 = (DTYPE)kern[5];
-  k6 = (DTYPE)kern[6];  k7 = (DTYPE)kern[7];  k8 = (DTYPE)kern[8];
-
-  wid -= (KSIZE - 1);
-  hgt -= (KSIZE - 1);
-
-  adr_dst += ((KSIZE - 1)/2)*(dll + chan1);
-
-  for (c = 0; c < chan1; c++) {
-    if (!(cmask & (1 << (chan1 - 1 - c)))) continue;
-
-    sl = adr_src + c;
-    dl = adr_dst + c;
-
-    for (j = 0; j < hgt; j++) {
-      DTYPE s0, s1;
-
-      dp  = dl;
-      sp0 = sl;
-      sp1 = sp0 + sll;
-      sp2 = sp1 + sll;
-
-      p02 = sp0[0];
-      p12 = sp1[0];
-      p22 = sp2[0];
-
-      p03 = sp0[chan1];
-      p13 = sp1[chan1];
-      p23 = sp2[chan1];
-
-      s0 = p02 * k0 + p03 * k1 + p12 * k3 + p13 * k4 + p22 * k6 + p23 * k7;
-      s1 = p03 * k0 + p13 * k3 + p23 * k6;
-
-      sp0 += chan2;
-      sp1 += chan2;
-      sp2 += chan2;
-
-#ifdef __SUNPRO_C
-#pragma pipeloop(0)
-#endif /* __SUNPRO_C */
-      for (i = 0; i <= (wid - 2); i += 2) {
-        p02 = sp0[0];     p12 = sp1[0];     p22 = sp2[0];
-        p03 = sp0[chan1]; p13 = sp1[chan1]; p23 = sp2[chan1];
-
-        dp[0    ] = s0 + p02 * k2 + p12 * k5 + p22 * k8;
-        dp[chan1] = s1 + p02 * k1 + p03 * k2 + p12 * k4 + p13 * k5 + p22 * k7 + p23 * k8;
-
-        s0 = p02 * k0 + p03 * k1 + p12 * k3 + p13 * k4 + p22 * k6 + p23 * k7;
-        s1 = p03 * k0 + p13 * k3 + p23 * k6;
-
-        sp0 += chan2;
-        sp1 += chan2;
-        sp2 += chan2;
-        dp += chan2;
-      }
-
-      if (wid & 1) {
-        p02 = sp0[0]; p12 = sp1[0]; p22 = sp2[0];
-        dp[0] = s0 + p02 * k2 + p12 * k5 + p22 * k8;
-      }
-
-      sl += sll;
-      dl += dll;
-    }
-  }
-
-  return MLIB_SUCCESS;
-}
-
-/***************************************************************/
-#undef  KSIZE
-#define KSIZE 4
-
-mlib_status CONV_FUNC(4x4)(mlib_image       *dst,
-                           const mlib_image *src,
-                           const mlib_d64   *k,
-                           mlib_s32         cmask)
-{
-  DTYPE k0, k1, k2, k3, k4, k5, k6, k7;
-  DTYPE p00, p01, p02, p03, p04,
-        p10, p11, p12, p13, p14;
-  DEF_VARS(DTYPE);
-  DTYPE    *sp0, *sp1;
-  mlib_s32 chan2 = chan1 + chan1;
-  mlib_s32 chan3 = chan1 + chan2;
-
-  wid -= (KSIZE - 1);
-  hgt -= (KSIZE - 1);
-
-  adr_dst += ((KSIZE - 1)/2)*(dll + chan1);
-
-  for (c = 0; c < chan1; c++) {
-    if (!(cmask & (1 << (chan1 - 1 - c)))) continue;
-
-    sl = adr_src + c;
-    dl = adr_dst + c;
-
-    for (j = 0; j < hgt; j++) {
-      /*
-       *  First loop on two first lines of kernel
-       */
-      sp0 = sl;
-      sp1 = sp0 + sll;
-      dp = dl;
-
-      k0 = (DTYPE)k[0]; k1 = (DTYPE)k[1]; k2 = (DTYPE)k[2]; k3 = (DTYPE)k[3];
-      k4 = (DTYPE)k[4]; k5 = (DTYPE)k[5]; k6 = (DTYPE)k[6]; k7 = (DTYPE)k[7];
-
-      p02 = sp0[0];     p12 = sp1[0];
-      p03 = sp0[chan1]; p13 = sp1[chan1];
-      p04 = sp0[chan2]; p14 = sp1[chan2];
-
-      sp0 += chan3;
-      sp1 += chan3;
-
-#ifdef __SUNPRO_C
-#pragma pipeloop(0)
-#endif /* __SUNPRO_C */
-      for (i = 0; i <= (wid - 2); i += 2) {
-        p00 = p02; p10 = p12;
-        p01 = p03; p11 = p13;
-        p02 = p04; p12 = p14;
-
-        p03 = sp0[0];     p13 = sp1[0];
-        p04 = sp0[chan1]; p14 = sp1[chan1];
-
-        dp[0    ] = (p00 * k0 + p01 * k1 + p02 * k2 + p03 * k3 +
-                     p10 * k4 + p11 * k5 + p12 * k6 + p13 * k7);
-        dp[chan1] = (p01 * k0 + p02 * k1 + p03 * k2 + p04 * k3 +
-                     p11 * k4 + p12 * k5 + p13 * k6 + p14 * k7);
-
-        sp0 += chan2;
-        sp1 += chan2;
-        dp += chan2;
-      }
-
-      if (wid & 1) {
-        p00 = p02; p10 = p12;
-        p01 = p03; p11 = p13;
-        p02 = p04; p12 = p14;
-        p03 = sp0[0]; p13 = sp1[0];
-
-        dp[0] = (p00 * k0 + p01 * k1 + p02 * k2 + p03 * k3 +
-                 p10 * k4 + p11 * k5 + p12 * k6 + p13 * k7);
-      }
-
-      /*
-       *  Second loop on two last lines of kernel
-       */
-      sp0 = sl + 2*sll;
-      sp1 = sp0 + sll;
-      dp = dl;
-
-      k0 = (DTYPE)k[ 8]; k1 = (DTYPE)k[ 9]; k2 = (DTYPE)k[10]; k3 = (DTYPE)k[11];
-      k4 = (DTYPE)k[12]; k5 = (DTYPE)k[13]; k6 = (DTYPE)k[14]; k7 = (DTYPE)k[15];
-
-      p02 = sp0[0];     p12 = sp1[0];
-      p03 = sp0[chan1]; p13 = sp1[chan1];
-      p04 = sp0[chan2]; p14 = sp1[chan2];
-
-      sp0 += chan3;
-      sp1 += chan3;
-
-#ifdef __SUNPRO_C
-#pragma pipeloop(0)
-#endif /* __SUNPRO_C */
-      for (i = 0; i <= (wid - 2); i += 2) {
-        p00 = p02; p10 = p12;
-        p01 = p03; p11 = p13;
-        p02 = p04; p12 = p14;
-
-        p03 = sp0[0];     p13 = sp1[0];
-        p04 = sp0[chan1]; p14 = sp1[chan1];
-
-        dp[0    ] += (p00 * k0 + p01 * k1 + p02 * k2 + p03 * k3 +
-                      p10 * k4 + p11 * k5 + p12 * k6 + p13 * k7);
-        dp[chan1] += (p01 * k0 + p02 * k1 + p03 * k2 + p04 * k3 +
-                      p11 * k4 + p12 * k5 + p13 * k6 + p14 * k7);
-
-        sp0 += chan2;
-        sp1 += chan2;
-        dp += chan2;
-      }
-
-      if (wid & 1) {
-        p00 = p02; p10 = p12;
-        p01 = p03; p11 = p13;
-        p02 = p04; p12 = p14;
-        p03 = sp0[0]; p13 = sp1[0];
-
-        dp[0] += (p00 * k0 + p01 * k1 + p02 * k2 + p03 * k3 +
-                  p10 * k4 + p11 * k5 + p12 * k6 + p13 * k7);
-      }
-
-      /* next line */
-      sl += sll;
-      dl += dll;
-    }
-  }
-
-  return MLIB_SUCCESS;
-}
-
-/***************************************************************/
-#undef  KSIZE
-#define KSIZE 5
-
-mlib_status CONV_FUNC(5x5)(mlib_image       *dst,
-                           const mlib_image *src,
-                           const mlib_d64   *k,
-                           mlib_s32         cmask)
-{
-  DTYPE k0, k1, k2, k3, k4, k5, k6, k7, k8, k9;
-  DTYPE p00, p01, p02, p03, p04, p05,
-        p10, p11, p12, p13, p14, p15;
-  DEF_VARS(DTYPE);
-  DTYPE    *sp0, *sp1;
-  mlib_s32 chan2 = chan1 + chan1;
-  mlib_s32 chan3 = chan1 + chan2;
-  mlib_s32 chan4 = chan3 + chan1;
-
-  wid -= (KSIZE - 1);
-  hgt -= (KSIZE - 1);
-
-  adr_dst += ((KSIZE - 1)/2)*(dll + chan1);
-
-  for (c = 0; c < chan1; c++) {
-    if (!(cmask & (1 << (chan1 - 1 - c)))) continue;
-
-    sl = adr_src + c;
-    dl = adr_dst + c;
-
-    for (j = 0; j < hgt; j++) {
-      /*
-       *  First loop
-       */
-      sp0 = sl;
-      sp1 = sp0 + sll;
-      dp = dl;
-
-      k0 = (DTYPE)k[0]; k1 = (DTYPE)k[1]; k2 = (DTYPE)k[2]; k3 = (DTYPE)k[3]; k4 = (DTYPE)k[4];
-      k5 = (DTYPE)k[5]; k6 = (DTYPE)k[6]; k7 = (DTYPE)k[7]; k8 = (DTYPE)k[8]; k9 = (DTYPE)k[9];
-
-      p02 = sp0[0];     p12 = sp1[0];
-      p03 = sp0[chan1]; p13 = sp1[chan1];
-      p04 = sp0[chan2]; p14 = sp1[chan2];
-      p05 = sp0[chan3]; p15 = sp1[chan3];
-
-      sp0 += chan4;
-      sp1 += chan4;
-
-#ifdef __SUNPRO_C
-#pragma pipeloop(0)
-#endif /* __SUNPRO_C */
-      for (i = 0; i <= (wid - 2); i += 2) {
-        p00 = p02; p10 = p12;
-        p01 = p03; p11 = p13;
-        p02 = p04; p12 = p14;
-        p03 = p05; p13 = p15;
-
-        p04 = sp0[0];     p14 = sp1[0];
-        p05 = sp0[chan1]; p15 = sp1[chan1];
-
-        dp[    0] = (p00 * k0 + p01 * k1 + p02 * k2 + p03 * k3 + p04 * k4 +
-                     p10 * k5 + p11 * k6 + p12 * k7 + p13 * k8 + p14 * k9);
-        dp[chan1] = (p01 * k0 + p02 * k1 + p03 * k2 + p04 * k3 + p05 * k4 +
-                     p11 * k5 + p12 * k6 + p13 * k7 + p14 * k8 + p15 * k9);
-
-        sp0 += chan2;
-        sp1 += chan2;
-        dp += chan2;
-      }
-
-      if (wid & 1) {
-        p00 = p02; p10 = p12;
-        p01 = p03; p11 = p13;
-        p02 = p04; p12 = p14;
-        p03 = p05; p13 = p15;
-
-        p04 = sp0[0];     p14 = sp1[0];
-
-        dp[0] = (p00 * k0 + p01 * k1 + p02 * k2 + p03 * k3 + p04 * k4 +
-                 p10 * k5 + p11 * k6 + p12 * k7 + p13 * k8 + p14 * k9);
-      }
-
-      /*
-       *  Second loop
-       */
-      sp0 = sl + 2*sll;
-      sp1 = sp0 + sll;
-      dp = dl;
-
-      k0 = (DTYPE)k[10]; k1 = (DTYPE)k[11]; k2 = (DTYPE)k[12]; k3 = (DTYPE)k[13]; k4 = (DTYPE)k[14];
-      k5 = (DTYPE)k[15]; k6 = (DTYPE)k[16]; k7 = (DTYPE)k[17]; k8 = (DTYPE)k[18]; k9 = (DTYPE)k[19];
-
-      p02 = sp0[0];     p12 = sp1[0];
-      p03 = sp0[chan1]; p13 = sp1[chan1];
-      p04 = sp0[chan2]; p14 = sp1[chan2];
-      p05 = sp0[chan3]; p15 = sp1[chan3];
-
-      sp0 += chan4;
-      sp1 += chan4;
-
-#ifdef __SUNPRO_C
-#pragma pipeloop(0)
-#endif /* __SUNPRO_C */
-      for (i = 0; i <= (wid - 2); i += 2) {
-        p00 = p02; p10 = p12;
-        p01 = p03; p11 = p13;
-        p02 = p04; p12 = p14;
-        p03 = p05; p13 = p15;
-
-        p04 = sp0[0];     p14 = sp1[0];
-        p05 = sp0[chan1]; p15 = sp1[chan1];
-
-        dp[    0] += (p00 * k0 + p01 * k1 + p02 * k2 + p03 * k3 + p04 * k4 +
-                      p10 * k5 + p11 * k6 + p12 * k7 + p13 * k8 + p14 * k9);
-        dp[chan1] += (p01 * k0 + p02 * k1 + p03 * k2 + p04 * k3 + p05 * k4 +
-                      p11 * k5 + p12 * k6 + p13 * k7 + p14 * k8 + p15 * k9);
-
-        sp0 += chan2;
-        sp1 += chan2;
-        dp += chan2;
-      }
-
-      if (wid & 1) {
-        p00 = p02; p10 = p12;
-        p01 = p03; p11 = p13;
-        p02 = p04; p12 = p14;
-        p03 = p05; p13 = p15;
-
-        p04 = sp0[0];     p14 = sp1[0];
-
-        dp[0] += (p00 * k0 + p01 * k1 + p02 * k2 + p03 * k3 + p04 * k4 +
-                  p10 * k5 + p11 * k6 + p12 * k7 + p13 * k8 + p14 * k9);
-      }
-
-      /*
-       *  3 loop
-       */
-      dp = dl;
-      sp0 = sl + 4*sll;
-
-      k0 = (DTYPE)k[20]; k1 = (DTYPE)k[21]; k2 = (DTYPE)k[22]; k3 = (DTYPE)k[23]; k4 = (DTYPE)k[24];
-
-      p02 = sp0[0];
-      p03 = sp0[chan1];
-      p04 = sp0[chan2];
-      p05 = sp0[chan3];
-
-      sp0 += chan2 + chan2;
-
-#ifdef __SUNPRO_C
-#pragma pipeloop(0)
-#endif /* __SUNPRO_C */
-      for (i = 0; i <= (wid - 2); i += 2) {
-        p00 = p02; p01 = p03; p02 = p04; p03 = p05;
-
-        p04 = sp0[0]; p05 = sp0[chan1];
-
-        dp[0    ] += p00 * k0 + p01 * k1 + p02 * k2 + p03 * k3 + p04 * k4;
-        dp[chan1] += p01 * k0 + p02 * k1 + p03 * k2 + p04 * k3 + p05 * k4;
-
-        dp  += chan2;
-        sp0 += chan2;
-      }
-
-      if (wid & 1) {
-        p00 = p02; p01 = p03; p02 = p04; p03 = p05;
-
-        p04 = sp0[0];
-
-        dp[0] += p00 * k0 + p01 * k1 + p02 * k2 + p03 * k3 + p04 * k4;
-      }
-
-      /* next line */
-      sl += sll;
-      dl += dll;
-    }
-  }
-
-  return MLIB_SUCCESS;
-}
-
-/***************************************************************/
 #define BUFF_SIZE  1600
 
 #define CACHE_SIZE (64*1024)
--- a/jdk/src/java.desktop/share/native/libmlib_image/mlib_ImageConv_u16ext.c	Thu May 19 17:48:02 2016 +0000
+++ b/jdk/src/java.desktop/share/native/libmlib_image/mlib_ImageConv_u16ext.c	Thu May 19 19:46:20 2016 +0000
@@ -80,9 +80,6 @@
 #endif /* IMG_TYPE == 1 */
 
 /***************************************************************/
-#define KSIZE1 (KSIZE - 1)
-
-/***************************************************************/
 #define PARAM                                                   \
   mlib_image       *dst,                                        \
   const mlib_image *src,                                        \
@@ -163,9 +160,6 @@
 #endif /* _NO_LONGLONG */
 
 /***************************************************************/
-#define MLIB_D2_24 16777216.0f
-
-/***************************************************************/
 typedef union {
   mlib_d64 d64;
   struct {
@@ -175,9 +169,6 @@
 } d64_2x32;
 
 /***************************************************************/
-#define BUFF_LINE 256
-
-/***************************************************************/
 #define DEF_VARS(type)                                          \
   type     *adr_src, *sl, *sp, *sl1;                            \
   type     *adr_dst, *dl, *dp;                                  \
@@ -188,39 +179,6 @@
   mlib_s32 i, j, c, swid
 
 /***************************************************************/
-#define LOAD_KERNEL3()                                                   \
-  FTYPE    scalef = DSCALE;                                              \
-  FTYPE    k0, k1, k2, k3, k4, k5, k6, k7, k8;                           \
-  FTYPE    p00, p01, p02, p03,                                           \
-           p10, p11, p12, p13,                                           \
-           p20, p21, p22, p23;                                           \
-                                                                         \
-  while (scalef_expon > 30) {                                            \
-    scalef /= (1 << 30);                                                 \
-    scalef_expon -= 30;                                                  \
-  }                                                                      \
-                                                                         \
-  scalef /= (1 << scalef_expon);                                         \
-                                                                         \
-  /* keep kernel in regs */                                              \
-  k0 = scalef * kern[0];  k1 = scalef * kern[1];  k2 = scalef * kern[2]; \
-  k3 = scalef * kern[3];  k4 = scalef * kern[4];  k5 = scalef * kern[5]; \
-  k6 = scalef * kern[6];  k7 = scalef * kern[7];  k8 = scalef * kern[8]
-
-/***************************************************************/
-#define LOAD_KERNEL(SIZE)                                       \
-  FTYPE    scalef = DSCALE;                                     \
-                                                                \
-  while (scalef_expon > 30) {                                   \
-    scalef /= (1 << 30);                                        \
-    scalef_expon -= 30;                                         \
-  }                                                             \
-                                                                \
-  scalef /= (1 << scalef_expon);                                \
-                                                                \
-  for (j = 0; j < SIZE; j++) k[j] = scalef * kern[j]
-
-/***************************************************************/
 #define GET_SRC_DST_PARAMETERS(type)                            \
   hgt = mlib_ImageGetHeight(src);                               \
   wid = mlib_ImageGetWidth(src);                                \
@@ -278,1334 +236,6 @@
 #endif /* __sparc */
 
 /***************************************************************/
-#define KSIZE  3
-
-mlib_status CONV_FUNC(3x3)
-{
-  FTYPE    buff[(KSIZE + 2)*BUFF_LINE], *buff0, *buff1, *buff2, *buff3, *buffT;
-  DEF_VARS(DTYPE);
-  DTYPE *sl2;
-#ifndef __sparc
-  mlib_s32 d0, d1;
-#endif /* __sparc */
-  LOAD_KERNEL3();
-  GET_SRC_DST_PARAMETERS(DTYPE);
-
-  swid = wid + KSIZE1;
-
-  if (swid > BUFF_LINE) {
-    pbuff = mlib_malloc((KSIZE + 2)*sizeof(FTYPE   )*swid);
-
-    if (pbuff == NULL) return MLIB_FAILURE;
-  }
-
-  buff0 = pbuff;
-  buff1 = buff0 + swid;
-  buff2 = buff1 + swid;
-  buff3 = buff2 + swid;
-  buffo = (mlib_s32*)(buff3 + swid);
-  buffi = buffo + (swid &~ 1);
-
-  swid -= (dx_l + dx_r);
-
-  chan1 = nchannel;
-  chan2 = chan1 + chan1;
-
-  for (c = 0; c < nchannel; c++) {
-    if (!(cmask & (1 << (nchannel - 1 - c)))) continue;
-
-    sl = adr_src + c;
-    dl = adr_dst + c;
-
-    if ((1 > dy_t) && (1 < hgt + KSIZE1 - dy_b)) sl1 = sl + sll;
-    else sl1 = sl;
-
-    if ((hgt - dy_b) > 0) sl2 = sl1 + sll;
-    else sl2 = sl1;
-
-    for (i = 0; i < dx_l; i++) {
-      buff0[i] = (FTYPE)sl[0];
-      buff1[i] = (FTYPE)sl1[0];
-      buff2[i] = (FTYPE)sl2[0];
-    }
-
-#ifdef __SUNPRO_C
-#pragma pipeloop(0)
-#endif /* __SUNPRO_C */
-    for (i = 0; i < swid; i++) {
-      buff0[i + dx_l] = (FTYPE)sl[i*chan1];
-      buff1[i + dx_l] = (FTYPE)sl1[i*chan1];
-      buff2[i + dx_l] = (FTYPE)sl2[i*chan1];
-    }
-
-    for (i = 0; i < dx_r; i++) {
-      buff0[swid + dx_l + i] = buff0[swid + dx_l - 1];
-      buff1[swid + dx_l + i] = buff1[swid + dx_l - 1];
-      buff2[swid + dx_l + i] = buff2[swid + dx_l - 1];
-    }
-
-    if ((hgt - dy_b) > 1) sl = sl2 + sll;
-    else sl = sl2;
-
-    for (j = 0; j < hgt; j++) {
-      FTYPE    s0, s1;
-
-      p02 = buff0[0];
-      p12 = buff1[0];
-      p22 = buff2[0];
-
-      p03 = buff0[1];
-      p13 = buff1[1];
-      p23 = buff2[1];
-
-      s0 = p02 * k0 + p03 * k1 + p12 * k3 + p13 * k4 + p22 * k6 + p23 * k7;
-      s1 = p03 * k0 + p13 * k3 + p23 * k6;
-
-      sp = sl;
-      dp = dl;
-
-#ifdef __SUNPRO_C
-#pragma pipeloop(0)
-#endif /* __SUNPRO_C */
-      for (i = 0; i <= (wid - 2); i += 2) {
-#ifdef __sparc
-#ifdef _NO_LONGLONG
-        mlib_s32 o64_1, o64_2;
-#else /* _NO_LONGLONG */
-        mlib_s64 o64;
-#endif /* _NO_LONGLONG */
-#endif /* __sparc */
-        d64_2x32 dd;
-
-        p02 = buff0[i + 2]; p12 = buff1[i + 2]; p22 = buff2[i + 2];
-        p03 = buff0[i + 3]; p13 = buff1[i + 3]; p23 = buff2[i + 3];
-
-        LOAD_BUFF(buffi);
-
-        dd.d64 = *(FTYPE   *)(buffi + i);
-        buff3[i + dx_l    ] = (FTYPE)dd.i32s.i0;
-        buff3[i + dx_l + 1] = (FTYPE)dd.i32s.i1;
-
-#ifndef __sparc
-
-        d0 = D2I(s0 + p02 * k2 + p12 * k5 + p22 * k8);
-        d1 = D2I(s1 + p02 * k1 + p03 * k2 + p12 * k4 + p13 * k5 + p22 * k7 + p23 * k8);
-
-        s0 = p02 * k0 + p03 * k1 + p12 * k3 + p13 * k4 + p22 * k6 + p23 * k7;
-        s1 = p03 * k0 + p13 * k3 + p23 * k6;
-
-        dp[0    ] = FROM_S32(d0);
-        dp[chan1] = FROM_S32(d1);
-
-#else /* __sparc */
-
-        dd.i32s.i0 = D2I(s0 + p02 * k2 + p12 * k5 + p22 * k8);
-        dd.i32s.i1 = D2I(s1 + p02 * k1 + p03 * k2 + p12 * k4 + p13 * k5 + p22 * k7 + p23 * k8);
-        *(FTYPE   *)(buffo + i) = dd.d64;
-
-        s0 = p02 * k0 + p03 * k1 + p12 * k3 + p13 * k4 + p22 * k6 + p23 * k7;
-        s1 = p03 * k0 + p13 * k3 + p23 * k6;
-
-#ifdef _NO_LONGLONG
-
-        o64_1 = buffo[i];
-        o64_2 = buffo[i+1];
-#if IMG_TYPE != 1
-        STORE2(FROM_S32(o64_1), FROM_S32(o64_2));
-#else
-        STORE2(o64_1 >> 24, o64_2 >> 24);
-#endif /* IMG_TYPE != 1 */
-
-#else /* _NO_LONGLONG */
-
-        o64 = *(mlib_s64*)(buffo + i);
-#if IMG_TYPE != 1
-        STORE2(FROM_S32(o64 >> 32), FROM_S32(o64));
-#else
-        STORE2(o64 >> 56, o64 >> 24);
-#endif /* IMG_TYPE != 1 */
-#endif /* _NO_LONGLONG */
-#endif /* __sparc */
-
-        sp += chan2;
-        dp += chan2;
-      }
-
-      for (; i < wid; i++) {
-        p00 = buff0[i];     p10 = buff1[i];     p20 = buff2[i];
-        p01 = buff0[i + 1]; p11 = buff1[i + 1]; p21 = buff2[i + 1];
-        p02 = buff0[i + 2]; p12 = buff1[i + 2]; p22 = buff2[i + 2];
-
-        buffi[i] = (mlib_s32)sp[0];
-        buff3[i + dx_l] = (FTYPE)buffi[i];
-
-#ifndef __sparc
-
-        d0 = D2I(p00 * k0 + p01 * k1 + p02 * k2 + p10 * k3 + p11 * k4 +
-                 p12 * k5 + p20 * k6 + p21 * k7 + p22 * k8);
-
-        dp[0] = FROM_S32(d0);
-
-#else  /* __sparc */
-
-        buffo[i] = D2I(p00 * k0 + p01 * k1 + p02 * k2 + p10 * k3 + p11 * k4 +
-                       p12 * k5 + p20 * k6 + p21 * k7 + p22 * k8);
-#if IMG_TYPE != 1
-        dp[0] = FROM_S32(buffo[i]);
-#else
-        dp[0] = buffo[i] >> 24;
-#endif /* IMG_TYPE != 1 */
-#endif /* __sparc */
-
-        sp += chan1;
-        dp += chan1;
-      }
-
-      for (; i < swid; i++) {
-        buffi[i] = (mlib_s32)sp[0];
-        buff3[i + dx_l] = (FTYPE)buffi[i];
-        sp += chan1;
-      }
-
-      for (i = 0; i < dx_l; i++) buff3[i] = buff3[dx_l];
-      for (i = 0; i < dx_r; i++) buff3[swid + dx_l + i] = buff3[swid + dx_l - 1];
-
-      if (j < hgt - dy_b - 2) sl += sll;
-      dl += dll;
-
-      buffT = buff0;
-      buff0 = buff1;
-      buff1 = buff2;
-      buff2 = buff3;
-      buff3 = buffT;
-    }
-  }
-
-#ifdef __sparc
-#if IMG_TYPE == 1
-  {
-    mlib_s32 amask = (1 << nchannel) - 1;
-
-    if ((cmask & amask) != amask) {
-      mlib_ImageXor80(adr_dst, wid, hgt, dll, nchannel, cmask);
-    } else {
-      mlib_ImageXor80_aa(adr_dst, wid*nchannel, hgt, dll);
-    }
-  }
-
-#endif /* IMG_TYPE == 1 */
-#endif /* __sparc */
-
-  if (pbuff != buff) mlib_free(pbuff);
-
-  return MLIB_SUCCESS;
-}
-
-/***************************************************************/
-#ifndef __sparc /* for x86, using integer multiplies is faster */
-
-mlib_status CONV_FUNC_I(3x3)
-{
-  DTYPE    *adr_src, *sl, *sp0, *sp1, *sp2, *sp_1, *sp_2;
-  DTYPE    *adr_dst, *dl, *dp;
-  mlib_s32 wid, hgt, sll, dll;
-  mlib_s32 nchannel, chan1, chan2, delta_chan;
-  mlib_s32 i, j, c;
-  mlib_s32 shift1, shift2;
-  mlib_s32 k0, k1, k2, k3, k4, k5, k6, k7, k8;
-  mlib_s32 p02, p03,
-           p12, p13,
-           p22, p23;
-
-#if IMG_TYPE != 1
-  shift1 = 16;
-#else
-  shift1 = 8;
-#endif /* IMG_TYPE != 1 */
-
-  shift2 = scalef_expon - shift1;
-
-  /* keep kernel in regs */
-  k0 = kern[0] >> shift1;  k1 = kern[1] >> shift1;  k2 = kern[2] >> shift1;
-  k3 = kern[3] >> shift1;  k4 = kern[4] >> shift1;  k5 = kern[5] >> shift1;
-  k6 = kern[6] >> shift1;  k7 = kern[7] >> shift1;  k8 = kern[8] >> shift1;
-
-  GET_SRC_DST_PARAMETERS(DTYPE);
-
-  chan1 = nchannel;
-  chan2 = chan1 + chan1;
-  delta_chan = 0;
-
-  if ((1 > dx_l) && (1 < wid + KSIZE1 - dx_r)) delta_chan = chan1;
-
-  for (c = 0; c < chan1; c++) {
-    if (!(cmask & (1 << (chan1 - 1 - c)))) continue;
-
-    sl = adr_src + c;
-    dl = adr_dst + c;
-
-    sp_1 = sl;
-
-    if ((1 > dy_t) && (1 < hgt + KSIZE1 - dy_b)) sl += sll;
-    sp_2 = sl;
-
-    if ((hgt - dy_b) > 0) sl += sll;
-
-    for (j = 0; j < hgt; j++) {
-      mlib_s32 s0, s1;
-      mlib_s32 pix0, pix1;
-
-      dp  = dl;
-      sp0 = sp_1;
-      sp_1 = sp_2;
-      sp_2 = sl;
-
-      sp1 = sp_1;
-      sp2 = sp_2;
-
-      p02 = sp0[0];
-      p12 = sp1[0];
-      p22 = sp2[0];
-
-      p03 = sp0[delta_chan];
-      p13 = sp1[delta_chan];
-      p23 = sp2[delta_chan];
-
-      s0 = p02 * k0 + p03 * k1 + p12 * k3 + p13 * k4 + p22 * k6 + p23 * k7;
-      s1 = p03 * k0 + p13 * k3 + p23 * k6;
-
-      sp0 += (chan1 + delta_chan);
-      sp1 += (chan1 + delta_chan);
-      sp2 += (chan1 + delta_chan);
-
-#ifdef __SUNPRO_C
-#pragma pipeloop(0)
-#endif /* __SUNPRO_C */
-      for (i = 0; i <= (wid - dx_r - 2); i += 2) {
-        p02 = sp0[0];     p12 = sp1[0];     p22 = sp2[0];
-        p03 = sp0[chan1]; p13 = sp1[chan1]; p23 = sp2[chan1];
-
-        pix0 = (s0 + p02 * k2 + p12 * k5 + p22 * k8) >> shift2;
-        pix1 = (s1 + p02 * k1 + p03 * k2 + p12 * k4 +
-                p13 * k5 + p22 * k7 + p23 * k8) >> shift2;
-
-        CLAMP_STORE(dp[0],     pix0);
-        CLAMP_STORE(dp[chan1], pix1);
-
-        s0 = p02 * k0 + p03 * k1 + p12 * k3 + p13 * k4 + p22 * k6 + p23 * k7;
-        s1 = p03 * k0 + p13 * k3 + p23 * k6;
-
-        sp0 += chan2;
-        sp1 += chan2;
-        sp2 += chan2;
-        dp += chan2;
-      }
-
-      p02 = p03; p12 = p13; p22 = p23;
-
-      for (; i < wid - dx_r; i++) {
-        p03 = sp0[0]; p13 = sp1[0]; p23 = sp2[0];
-        pix0 = (s0 + p03 * k2 + p13 * k5 + p23 * k8) >> shift2;
-        CLAMP_STORE(dp[0], pix0);
-        s0 = p02 * k0 + p03 * k1 + p12 * k3 + p13 * k4 + p22 * k6 + p23 * k7;
-        p02 = p03; p12 = p13; p22 = p23;
-        sp0 += chan1;
-        sp1 += chan1;
-        sp2 += chan1;
-        dp += chan1;
-      }
-
-      sp0 -= chan1;
-      sp1 -= chan1;
-      sp2 -= chan1;
-
-      for (; i < wid; i++) {
-        p03 = sp0[0]; p13 = sp1[0]; p23 = sp2[0];
-        pix0 = (s0 + p03 * k2 + p13 * k5 + p23 * k8) >> shift2;
-        CLAMP_STORE(dp[0], pix0);
-        s0 = p02 * k0 + p03 * k1 + p12 * k3 + p13 * k4 + p22 * k6 + p23 * k7;
-        p02 = p03; p12 = p13; p22 = p23;
-        dp += chan1;
-      }
-
-      if (j < hgt - dy_b - 1) sl += sll;
-      dl += dll;
-    }
-  }
-
-  return MLIB_SUCCESS;
-}
-
-#endif /* __sparc ( for x86, using integer multiplies is faster ) */
-
-/***************************************************************/
-#undef  KSIZE
-#define KSIZE 4
-
-mlib_status CONV_FUNC(4x4)
-{
-  FTYPE    buff[(KSIZE + 3)*BUFF_LINE];
-  FTYPE    *buff0, *buff1, *buff2, *buff3, *buff4, *buffd, *buffT;
-  FTYPE    k[KSIZE*KSIZE];
-  mlib_s32 d0, d1;
-  FTYPE    k0, k1, k2, k3, k4, k5, k6, k7;
-  FTYPE    p00, p01, p02, p03, p04,
-           p10, p11, p12, p13, p14,
-           p20, p21, p22, p23,
-           p30, p31, p32, p33;
-  DEF_VARS(DTYPE);
-  DTYPE *sl2, *sl3;
-  LOAD_KERNEL(KSIZE*KSIZE);
-  GET_SRC_DST_PARAMETERS(DTYPE);
-
-  swid = wid + KSIZE1;
-
-  if (swid > BUFF_LINE) {
-    pbuff = mlib_malloc((KSIZE + 3)*sizeof(FTYPE   )*swid);
-
-    if (pbuff == NULL) return MLIB_FAILURE;
-  }
-
-  buff0 = pbuff;
-  buff1 = buff0 + swid;
-  buff2 = buff1 + swid;
-  buff3 = buff2 + swid;
-  buff4 = buff3 + swid;
-  buffd = buff4 + swid;
-  buffo = (mlib_s32*)(buffd + swid);
-  buffi = buffo + (swid &~ 1);
-
-  swid -= (dx_l + dx_r);
-
-  chan1 = nchannel;
-  chan2 = chan1 + chan1;
-
-  for (c = 0; c < nchannel; c++) {
-    if (!(cmask & (1 << (nchannel - 1 - c)))) continue;
-
-    sl = adr_src + c;
-    dl = adr_dst + c;
-
-    if ((1 > dy_t) && (1 < hgt + KSIZE1 - dy_b)) sl1 = sl + sll;
-    else sl1 = sl;
-
-    if ((2 > dy_t) && (2 < hgt + KSIZE1 - dy_b)) sl2 = sl1 + sll;
-    else sl2 = sl1;
-
-    if ((hgt - dy_b) > 0) sl3 = sl2 + sll;
-    else sl3 = sl2;
-
-    for (i = 0; i < dx_l; i++) {
-      buff0[i] = (FTYPE)sl[0];
-      buff1[i] = (FTYPE)sl1[0];
-      buff2[i] = (FTYPE)sl2[0];
-      buff3[i] = (FTYPE)sl3[0];
-    }
-
-#ifdef __SUNPRO_C
-#pragma pipeloop(0)
-#endif /* __SUNPRO_C */
-    for (i = 0; i < swid; i++) {
-      buff0[i + dx_l] = (FTYPE)sl[i*chan1];
-      buff1[i + dx_l] = (FTYPE)sl1[i*chan1];
-      buff2[i + dx_l] = (FTYPE)sl2[i*chan1];
-      buff3[i + dx_l] = (FTYPE)sl3[i*chan1];
-    }
-
-    for (i = 0; i < dx_r; i++) {
-      buff0[swid + dx_l + i] = buff0[swid + dx_l - 1];
-      buff1[swid + dx_l + i] = buff1[swid + dx_l - 1];
-      buff2[swid + dx_l + i] = buff2[swid + dx_l - 1];
-      buff3[swid + dx_l + i] = buff3[swid + dx_l - 1];
-    }
-
-    if ((hgt - dy_b) > 1) sl = sl3 + sll;
-    else sl = sl3;
-
-    for (j = 0; j < hgt; j++) {
-      d64_2x32 dd;
-
-      /*
-       *  First loop on two first lines of kernel
-       */
-      k0 = k[0]; k1 = k[1]; k2 = k[2]; k3 = k[3];
-      k4 = k[4]; k5 = k[5]; k6 = k[6]; k7 = k[7];
-
-      sp = sl;
-      dp = dl;
-
-      p02 = buff0[0];
-      p12 = buff1[0];
-      p03 = buff0[1];
-      p13 = buff1[1];
-      p04 = buff0[2];
-
-#ifdef __SUNPRO_C
-#pragma pipeloop(0)
-#endif /* __SUNPRO_C */
-      for (i = 0; i <= (wid - 2); i += 2) {
-        p00 = p02; p10 = p12;
-        p01 = p03; p11 = p13;
-        p02 = p04; p12 = buff1[i + 2];
-        p03 = buff0[i + 3]; p13 = buff1[i + 3];
-        p04 = buff0[i + 4]; p14 = buff1[i + 4];
-
-        LOAD_BUFF(buffi);
-
-        dd.d64 = *(FTYPE   *)(buffi + i);
-        buff4[i + dx_l    ] = (FTYPE)dd.i32s.i0;
-        buff4[i + dx_l + 1] = (FTYPE)dd.i32s.i1;
-
-        buffd[i    ] = (p00 * k0 + p01 * k1 + p02 * k2 + p03 * k3 +
-                        p10 * k4 + p11 * k5 + p12 * k6 + p13 * k7);
-        buffd[i + 1] = (p01 * k0 + p02 * k1 + p03 * k2 + p04 * k3 +
-                        p11 * k4 + p12 * k5 + p13 * k6 + p14 * k7);
-
-        sp += chan2;
-      }
-
-      /*
-       *  Second loop on two last lines of kernel
-       */
-      k0 = k[ 8]; k1 = k[ 9]; k2 = k[10]; k3 = k[11];
-      k4 = k[12]; k5 = k[13]; k6 = k[14]; k7 = k[15];
-
-      p02 = buff2[0];
-      p12 = buff3[0];
-      p03 = buff2[1];
-      p13 = buff3[1];
-      p04 = buff2[2];
-
-#ifdef __SUNPRO_C
-#pragma pipeloop(0)
-#endif /* __SUNPRO_C */
-      for (i = 0; i <= (wid - 2); i += 2) {
-        p00 = p02; p10 = p12;
-        p01 = p03; p11 = p13;
-        p02 = p04; p12 = buff3[i + 2];
-        p03 = buff2[i + 3]; p13 = buff3[i + 3];
-        p04 = buff2[i + 4]; p14 = buff3[i + 4];
-
-        d0 = D2I(p00 * k0 + p01 * k1 + p02 * k2 + p03 * k3 +
-                 p10 * k4 + p11 * k5 + p12 * k6 + p13 * k7 + buffd[i]);
-        d1 = D2I(p01 * k0 + p02 * k1 + p03 * k2 + p04 * k3 +
-                 p11 * k4 + p12 * k5 + p13 * k6 + p14 * k7 + buffd[i + 1]);
-
-        dp[0    ] = FROM_S32(d0);
-        dp[chan1] = FROM_S32(d1);
-
-        dp += chan2;
-      }
-
-      /* last pixels */
-      for (; i < wid; i++) {
-        p00 = buff0[i];     p10 = buff1[i];     p20 = buff2[i];     p30 = buff3[i];
-        p01 = buff0[i + 1]; p11 = buff1[i + 1]; p21 = buff2[i + 1]; p31 = buff3[i + 1];
-        p02 = buff0[i + 2]; p12 = buff1[i + 2]; p22 = buff2[i + 2]; p32 = buff3[i + 2];
-        p03 = buff0[i + 3]; p13 = buff1[i + 3]; p23 = buff2[i + 3]; p33 = buff3[i + 3];
-
-        buff4[i + dx_l] = (FTYPE)sp[0];
-
-        buffo[i] = D2I(p00 * k[0] + p01 * k[1] + p02 * k[2] + p03 * k[3] +
-                       p10 * k[4] + p11 * k[5] + p12 * k[6] + p13 * k[7] +
-                       p20 * k[ 8] + p21 * k[ 9] + p22 * k[10] + p23 * k[11] +
-                       p30 * k[12] + p31 * k[13] + p32 * k[14] + p33 * k[15]);
-
-        dp[0] = FROM_S32(buffo[i]);
-
-        sp += chan1;
-        dp += chan1;
-      }
-
-      for (; i < swid; i++) {
-        buff4[i + dx_l] = (FTYPE)sp[0];
-        sp += chan1;
-      }
-
-      for (i = 0; i < dx_l; i++) buff4[i] = buff4[dx_l];
-      for (i = 0; i < dx_r; i++) buff4[swid + dx_l + i] = buff4[swid + dx_l - 1];
-
-      /* next line */
-
-      if (j < hgt - dy_b - 2) sl += sll;
-      dl += dll;
-
-      buffT = buff0;
-      buff0 = buff1;
-      buff1 = buff2;
-      buff2 = buff3;
-      buff3 = buff4;
-      buff4 = buffT;
-    }
-  }
-
-  if (pbuff != buff) mlib_free(pbuff);
-
-  return MLIB_SUCCESS;
-}
-
-/***************************************************************/
-#undef  KSIZE
-#define KSIZE 5
-
-mlib_status CONV_FUNC(5x5)
-{
-  FTYPE    buff[(KSIZE + 3)*BUFF_LINE];
-  FTYPE    *buff0, *buff1, *buff2, *buff3, *buff4, *buff5, *buffd, *buffT;
-  FTYPE    k[KSIZE*KSIZE];
-  mlib_s32 d0, d1;
-  FTYPE    k0, k1, k2, k3, k4, k5, k6, k7, k8, k9;
-  FTYPE    p00, p01, p02, p03, p04, p05,
-           p10, p11, p12, p13, p14, p15,
-           p20, p21, p22, p23, p24,
-           p30, p31, p32, p33, p34,
-           p40, p41, p42, p43, p44;
-  DEF_VARS(DTYPE);
-  DTYPE *sl2, *sl3, *sl4;
-  LOAD_KERNEL(KSIZE*KSIZE);
-  GET_SRC_DST_PARAMETERS(DTYPE);
-
-  swid = wid + KSIZE1;
-
-  if (swid > BUFF_LINE) {
-    pbuff = mlib_malloc((KSIZE + 3)*sizeof(FTYPE   )*swid);
-
-    if (pbuff == NULL) return MLIB_FAILURE;
-  }
-
-  buff0 = pbuff;
-  buff1 = buff0 + swid;
-  buff2 = buff1 + swid;
-  buff3 = buff2 + swid;
-  buff4 = buff3 + swid;
-  buff5 = buff4 + swid;
-  buffd = buff5 + swid;
-  buffo = (mlib_s32*)(buffd + swid);
-  buffi = buffo + (swid &~ 1);
-
-  swid -= (dx_l + dx_r);
-
-  chan1 = nchannel;
-  chan2 = chan1 + chan1;
-
-  for (c = 0; c < nchannel; c++) {
-    if (!(cmask & (1 << (nchannel - 1 - c)))) continue;
-
-    sl = adr_src + c;
-    dl = adr_dst + c;
-
-    if ((1 > dy_t) && (1 < hgt + KSIZE1 - dy_b)) sl1 = sl + sll;
-    else sl1 = sl;
-
-    if ((2 > dy_t) && (2 < hgt + KSIZE1 - dy_b)) sl2 = sl1 + sll;
-    else sl2 = sl1;
-
-    if ((3 > dy_t) && (3 < hgt + KSIZE1 - dy_b)) sl3 = sl2 + sll;
-    else sl3 = sl2;
-
-    if ((hgt - dy_b) > 0) sl4 = sl3 + sll;
-    else sl4 = sl3;
-
-    for (i = 0; i < dx_l; i++) {
-      buff0[i] = (FTYPE)sl[0];
-      buff1[i] = (FTYPE)sl1[0];
-      buff2[i] = (FTYPE)sl2[0];
-      buff3[i] = (FTYPE)sl3[0];
-      buff4[i] = (FTYPE)sl4[0];
-    }
-
-#ifdef __SUNPRO_C
-#pragma pipeloop(0)
-#endif /* __SUNPRO_C */
-    for (i = 0; i < swid; i++) {
-      buff0[i + dx_l] = (FTYPE)sl[i*chan1];
-      buff1[i + dx_l] = (FTYPE)sl1[i*chan1];
-      buff2[i + dx_l] = (FTYPE)sl2[i*chan1];
-      buff3[i + dx_l] = (FTYPE)sl3[i*chan1];
-      buff4[i + dx_l] = (FTYPE)sl4[i*chan1];
-    }
-
-    for (i = 0; i < dx_r; i++) {
-      buff0[swid + dx_l + i] = buff0[swid + dx_l - 1];
-      buff1[swid + dx_l + i] = buff1[swid + dx_l - 1];
-      buff2[swid + dx_l + i] = buff2[swid + dx_l - 1];
-      buff3[swid + dx_l + i] = buff3[swid + dx_l - 1];
-      buff4[swid + dx_l + i] = buff4[swid + dx_l - 1];
-    }
-
-    if ((hgt - dy_b) > 1) sl = sl4 + sll;
-    else sl = sl4;
-
-    for (j = 0; j < hgt; j++) {
-      d64_2x32 dd;
-
-      /*
-       *  First loop
-       */
-      k0 = k[0]; k1 = k[1]; k2 = k[2]; k3 = k[3]; k4 = k[4];
-      k5 = k[5]; k6 = k[6]; k7 = k[7]; k8 = k[8]; k9 = k[9];
-
-      sp = sl;
-      dp = dl;
-
-      p02 = buff0[0];
-      p12 = buff1[0];
-      p03 = buff0[1];
-      p13 = buff1[1];
-      p04 = buff0[2];
-      p14 = buff1[2];
-
-#ifdef __SUNPRO_C
-#pragma pipeloop(0)
-#endif /* __SUNPRO_C */
-      for (i = 0; i <= (wid - 2); i += 2) {
-        p00 = p02; p10 = p12;
-        p01 = p03; p11 = p13;
-        p02 = p04; p12 = p14;
-
-        LOAD_BUFF(buffi);
-
-        p03 = buff0[i + 3]; p13 = buff1[i + 3];
-        p04 = buff0[i + 4]; p14 = buff1[i + 4];
-        p05 = buff0[i + 5]; p15 = buff1[i + 5];
-
-        buffd[i    ] = (p00 * k0 + p01 * k1 + p02 * k2 + p03 * k3 + p04 * k4 +
-                        p10 * k5 + p11 * k6 + p12 * k7 + p13 * k8 + p14 * k9);
-        buffd[i + 1] = (p01 * k0 + p02 * k1 + p03 * k2 + p04 * k3 + p05 * k4 +
-                        p11 * k5 + p12 * k6 + p13 * k7 + p14 * k8 + p15 * k9);
-
-        sp += chan2;
-      }
-
-      /*
-       *  Second loop
-       */
-      k0 = k[10]; k1 = k[11]; k2 = k[12]; k3 = k[13]; k4 = k[14];
-      k5 = k[15]; k6 = k[16]; k7 = k[17]; k8 = k[18]; k9 = k[19];
-
-      p02 = buff2[0];
-      p12 = buff3[0];
-      p03 = buff2[1];
-      p13 = buff3[1];
-
-#ifdef __SUNPRO_C
-#pragma pipeloop(0)
-#endif /* __SUNPRO_C */
-      for (i = 0; i <= (wid - 2); i += 2) {
-        p00 = p02; p10 = p12;
-        p01 = p03; p11 = p13;
-
-        p02 = buff2[i + 2]; p12 = buff3[i + 2];
-        p03 = buff2[i + 3]; p13 = buff3[i + 3];
-        p04 = buff2[i + 4]; p14 = buff3[i + 4];
-        p05 = buff2[i + 5]; p15 = buff3[i + 5];
-
-        dd.d64 = *(FTYPE   *)(buffi + i);
-        buff5[i + dx_l    ] = (FTYPE)dd.i32s.i0;
-        buff5[i + dx_l + 1] = (FTYPE)dd.i32s.i1;
-
-        buffd[i    ] += (p00 * k0 + p01 * k1 + p02 * k2 + p03 * k3 + p04 * k4 +
-                         p10 * k5 + p11 * k6 + p12 * k7 + p13 * k8 + p14 * k9);
-        buffd[i + 1] += (p01 * k0 + p02 * k1 + p03 * k2 + p04 * k3 + p05 * k4 +
-                         p11 * k5 + p12 * k6 + p13 * k7 + p14 * k8 + p15 * k9);
-      }
-
-      /*
-       *  3 loop
-       */
-      k0 = k[20]; k1 = k[21]; k2 = k[22]; k3 = k[23]; k4 = k[24];
-
-      p02 = buff4[0];
-      p03 = buff4[1];
-      p04 = buff4[2];
-      p05 = buff4[3];
-
-#ifdef __SUNPRO_C
-#pragma pipeloop(0)
-#endif /* __SUNPRO_C */
-      for (i = 0; i <= (wid - 2); i += 2) {
-        p00 = p02; p01 = p03; p02 = p04; p03 = p05;
-
-        p04 = buff4[i + 4]; p05 = buff4[i + 5];
-
-        d0 = D2I(p00 * k0 + p01 * k1 + p02 * k2 + p03 * k3 + p04 * k4 + buffd[i]);
-        d1 = D2I(p01 * k0 + p02 * k1 + p03 * k2 + p04 * k3 + p05 * k4 + buffd[i + 1]);
-
-        dp[0    ] = FROM_S32(d0);
-        dp[chan1] = FROM_S32(d1);
-
-        dp += chan2;
-      }
-
-      /* last pixels */
-      for (; i < wid; i++) {
-        p00 = buff0[i];     p10 = buff1[i];     p20 = buff2[i];     p30 = buff3[i];
-        p01 = buff0[i + 1]; p11 = buff1[i + 1]; p21 = buff2[i + 1]; p31 = buff3[i + 1];
-        p02 = buff0[i + 2]; p12 = buff1[i + 2]; p22 = buff2[i + 2]; p32 = buff3[i + 2];
-        p03 = buff0[i + 3]; p13 = buff1[i + 3]; p23 = buff2[i + 3]; p33 = buff3[i + 3];
-        p04 = buff0[i + 4]; p14 = buff1[i + 4]; p24 = buff2[i + 4]; p34 = buff3[i + 4];
-
-        p40 = buff4[i];     p41 = buff4[i + 1]; p42 = buff4[i + 2];
-        p43 = buff4[i + 3]; p44 = buff4[i + 4];
-
-        buff5[i + dx_l] = (FTYPE)sp[0];
-
-        buffo[i] = D2I(p00 * k[0] + p01 * k[1] + p02 * k[2] + p03 * k[3] + p04 * k[4] +
-                       p10 * k[5] + p11 * k[6] + p12 * k[7] + p13 * k[8] + p14 * k[9] +
-                       p20 * k[10] + p21 * k[11] + p22 * k[12] + p23 * k[13] + p24 * k[14] +
-                       p30 * k[15] + p31 * k[16] + p32 * k[17] + p33 * k[18] + p34 * k[19] +
-                       p40 * k[20] + p41 * k[21] + p42 * k[22] + p43 * k[23] + p44 * k[24]);
-
-        dp[0] = FROM_S32(buffo[i]);
-
-        sp += chan1;
-        dp += chan1;
-      }
-
-      for (; i < swid; i++) {
-        buff5[i + dx_l] = (FTYPE)sp[0];
-        sp += chan1;
-      }
-
-      for (i = 0; i < dx_l; i++) buff5[i] = buff5[dx_l];
-      for (i = 0; i < dx_r; i++) buff5[swid + dx_l + i] = buff5[swid + dx_l - 1];
-
-      /* next line */
-
-      if (j < hgt - dy_b - 2) sl += sll;
-      dl += dll;
-
-      buffT = buff0;
-      buff0 = buff1;
-      buff1 = buff2;
-      buff2 = buff3;
-      buff3 = buff4;
-      buff4 = buff5;
-      buff5 = buffT;
-    }
-  }
-
-  if (pbuff != buff) mlib_free(pbuff);
-
-  return MLIB_SUCCESS;
-}
-
-/***************************************************************/
-#ifndef __sparc /* for x86, using integer multiplies is faster */
-
-mlib_status CONV_FUNC_I(5x5)
-{
-  mlib_s32 buff[BUFF_LINE];
-  mlib_s32 *buffd;
-  mlib_s32 k[KSIZE*KSIZE];
-  mlib_s32 shift1, shift2;
-  mlib_s32 k0, k1, k2, k3, k4, k5, k6, k7, k8, k9;
-  mlib_s32 p00, p01, p02, p03, p04, p05,
-           p10, p11, p12, p13, p14, p15;
-  DTYPE    *adr_src, *sl, *sp0, *sp1, *sp2, *sp3, *sp4;
-  DTYPE    *sp_1, *sp_2, *sp_3, *sp_4;
-  DTYPE    *adr_dst, *dl, *dp;
-  mlib_s32 *pbuff = buff;
-  mlib_s32 wid, hgt, sll, dll;
-  mlib_s32 nchannel, chan1, chan2, chan4;
-  mlib_s32 delta_chan1, delta_chan2, delta_chan3;
-  mlib_s32 i, j, c;
-
-#if IMG_TYPE != 1
-  shift1 = 16;
-#else
-  shift1 = 8;
-#endif /* IMG_TYPE != 1 */
-
-  shift2 = scalef_expon - shift1;
-
-  for (j = 0; j < KSIZE*KSIZE; j++) k[j] = kern[j] >> shift1;
-
-  GET_SRC_DST_PARAMETERS(DTYPE);
-
-  if (wid > BUFF_LINE) {
-    pbuff = mlib_malloc(sizeof(mlib_s32)*wid);
-
-    if (pbuff == NULL) return MLIB_FAILURE;
-  }
-
-  buffd = pbuff;
-
-  chan1 = nchannel;
-  chan2 = chan1 + chan1;
-
-  if ((1 > dx_l) && (1 < wid + KSIZE1 - dx_r)) delta_chan1 = chan1;
-  else delta_chan1 = 0;
-
-  if ((2 > dx_l) && (2 < wid + KSIZE1 - dx_r)) delta_chan2 = delta_chan1 + chan1;
-  else delta_chan2 = delta_chan1;
-
-  if ((3 > dx_l) && (3 < wid + KSIZE1 - dx_r)) delta_chan3 = delta_chan2 + chan1;
-  else delta_chan3 = delta_chan2;
-
-  chan4 = chan1 + delta_chan3;
-
-  for (c = 0; c < chan1; c++) {
-    if (!(cmask & (1 << (chan1 - 1 - c)))) continue;
-
-    sl = adr_src + c;
-    dl = adr_dst + c;
-
-    sp_1 = sl;
-
-    if ((1 > dy_t) && (1 < hgt + KSIZE1 - dy_b)) sl += sll;
-    sp_2 = sl;
-
-    if ((2 > dy_t) && (2 < hgt + KSIZE1 - dy_b)) sl += sll;
-    sp_3 = sl;
-
-    if ((3 > dy_t) && (3 < hgt + KSIZE1 - dy_b)) sl += sll;
-    sp_4 = sl;
-
-    if ((hgt - dy_b) > 0) sl += sll;
-
-    for (j = 0; j < hgt; j++) {
-      mlib_s32 pix0, pix1;
-
-      dp  = dl;
-      sp0 = sp_1;
-      sp_1 = sp_2;
-      sp_2 = sp_3;
-      sp_3 = sp_4;
-      sp_4 = sl;
-
-      sp1 = sp_1;
-      sp2 = sp_2;
-      sp3 = sp_3;
-      sp4 = sp_4;
-
-      /*
-       *  First loop
-       */
-
-      k0 = k[0]; k1 = k[1]; k2 = k[2]; k3 = k[3]; k4 = k[4];
-      k5 = k[5]; k6 = k[6]; k7 = k[7]; k8 = k[8]; k9 = k[9];
-
-      p02 = sp0[0];           p12 = sp1[0];
-      p03 = sp0[delta_chan1]; p13 = sp1[delta_chan1];
-      p04 = sp0[delta_chan2]; p14 = sp1[delta_chan2];
-      p05 = sp0[delta_chan3]; p15 = sp1[delta_chan3];
-
-      sp0 += chan4;
-      sp1 += chan4;
-
-#ifdef __SUNPRO_C
-#pragma pipeloop(0)
-#endif /* __SUNPRO_C */
-      for (i = 0; i <= (wid - dx_r - 2); i += 2) {
-        p00 = p02; p10 = p12;
-        p01 = p03; p11 = p13;
-        p02 = p04; p12 = p14;
-        p03 = p05; p13 = p15;
-
-        p04 = sp0[0];     p14 = sp1[0];
-        p05 = sp0[chan1]; p15 = sp1[chan1];
-
-        buffd[i    ] = (p00 * k0 + p01 * k1 + p02 * k2 + p03 * k3 + p04 * k4 +
-                        p10 * k5 + p11 * k6 + p12 * k7 + p13 * k8 + p14 * k9);
-        buffd[i + 1] = (p01 * k0 + p02 * k1 + p03 * k2 + p04 * k3 + p05 * k4 +
-                        p11 * k5 + p12 * k6 + p13 * k7 + p14 * k8 + p15 * k9);
-
-        sp0 += chan2;
-        sp1 += chan2;
-      }
-
-      p01 = p02; p02 = p03; p03 = p04; p04 = p05;
-      p11 = p12; p12 = p13; p13 = p14; p14 = p15;
-
-      for (; i < wid - dx_r; i++) {
-        p00 = p01; p10 = p11;
-        p01 = p02; p11 = p12;
-        p02 = p03; p12 = p13;
-        p03 = p04; p13 = p14;
-
-        p04 = sp0[0];     p14 = sp1[0];
-
-        buffd[i] = (p00 * k0 + p01 * k1 + p02 * k2 + p03 * k3 + p04 * k4 +
-                    p10 * k5 + p11 * k6 + p12 * k7 + p13 * k8 + p14 * k9);
-
-        sp0 += chan1;
-        sp1 += chan1;
-      }
-
-      sp0 -= chan1;
-      sp1 -= chan1;
-
-      for (; i < wid; i++) {
-        p00 = p01; p10 = p11;
-        p01 = p02; p11 = p12;
-        p02 = p03; p12 = p13;
-        p03 = p04; p13 = p14;
-
-        p04 = sp0[0];     p14 = sp1[0];
-
-        buffd[i] = (p00 * k0 + p01 * k1 + p02 * k2 + p03 * k3 + p04 * k4 +
-                    p10 * k5 + p11 * k6 + p12 * k7 + p13 * k8 + p14 * k9);
-      }
-
-      /*
-       *  Second loop
-       */
-
-      k0 = k[10]; k1 = k[11]; k2 = k[12]; k3 = k[13]; k4 = k[14];
-      k5 = k[15]; k6 = k[16]; k7 = k[17]; k8 = k[18]; k9 = k[19];
-
-      p02 = sp2[0];           p12 = sp3[0];
-      p03 = sp2[delta_chan1]; p13 = sp3[delta_chan1];
-      p04 = sp2[delta_chan2]; p14 = sp3[delta_chan2];
-      p05 = sp2[delta_chan3]; p15 = sp3[delta_chan3];
-
-      sp2 += chan4;
-      sp3 += chan4;
-
-#ifdef __SUNPRO_C
-#pragma pipeloop(0)
-#endif /* __SUNPRO_C */
-      for (i = 0; i <= (wid - dx_r - 2); i += 2) {
-        p00 = p02; p10 = p12;
-        p01 = p03; p11 = p13;
-        p02 = p04; p12 = p14;
-        p03 = p05; p13 = p15;
-
-        p04 = sp2[0];     p14 = sp3[0];
-        p05 = sp2[chan1]; p15 = sp3[chan1];
-
-        buffd[i    ] += (p00 * k0 + p01 * k1 + p02 * k2 + p03 * k3 + p04 * k4 +
-                         p10 * k5 + p11 * k6 + p12 * k7 + p13 * k8 + p14 * k9);
-        buffd[i + 1] += (p01 * k0 + p02 * k1 + p03 * k2 + p04 * k3 + p05 * k4 +
-                         p11 * k5 + p12 * k6 + p13 * k7 + p14 * k8 + p15 * k9);
-
-        sp2 += chan2;
-        sp3 += chan2;
-      }
-
-      p01 = p02; p02 = p03; p03 = p04; p04 = p05;
-      p11 = p12; p12 = p13; p13 = p14; p14 = p15;
-
-      for (; i < wid - dx_r; i++) {
-        p00 = p01; p10 = p11;
-        p01 = p02; p11 = p12;
-        p02 = p03; p12 = p13;
-        p03 = p04; p13 = p14;
-
-        p04 = sp2[0];     p14 = sp3[0];
-
-        buffd[i] += (p00 * k0 + p01 * k1 + p02 * k2 + p03 * k3 + p04 * k4 +
-                     p10 * k5 + p11 * k6 + p12 * k7 + p13 * k8 + p14 * k9);
-
-        sp2 += chan1;
-        sp3 += chan1;
-      }
-
-      sp2 -= chan1;
-      sp3 -= chan1;
-
-      for (; i < wid; i++) {
-        p00 = p01; p10 = p11;
-        p01 = p02; p11 = p12;
-        p02 = p03; p12 = p13;
-        p03 = p04; p13 = p14;
-
-        p04 = sp2[0];     p14 = sp3[0];
-
-        buffd[i] += (p00 * k0 + p01 * k1 + p02 * k2 + p03 * k3 + p04 * k4 +
-                     p10 * k5 + p11 * k6 + p12 * k7 + p13 * k8 + p14 * k9);
-      }
-
-      /*
-       *  3 loop
-       */
-
-      k0 = k[20]; k1 = k[21]; k2 = k[22]; k3 = k[23]; k4 = k[24];
-
-      p02 = sp4[0];
-      p03 = sp4[delta_chan1];
-      p04 = sp4[delta_chan2];
-      p05 = sp4[delta_chan3];
-
-      sp4 += chan4;
-
-#ifdef __SUNPRO_C
-#pragma pipeloop(0)
-#endif /* __SUNPRO_C */
-      for (i = 0; i <= (wid - dx_r - 2); i += 2) {
-        p00 = p02; p01 = p03; p02 = p04; p03 = p05;
-
-        p04 = sp4[0]; p05 = sp4[chan1];
-
-        pix0 = (buffd[i    ] + p00 * k0 + p01 * k1 + p02 * k2 +
-                p03 * k3 + p04 * k4) >> shift2;
-        pix1 = (buffd[i + 1] + p01 * k0 + p02 * k1 + p03 * k2 +
-                p04 * k3 + p05 * k4) >> shift2;
-
-        CLAMP_STORE(dp[0],     pix0);
-        CLAMP_STORE(dp[chan1], pix1);
-
-        dp  += chan2;
-        sp4 += chan2;
-      }
-
-      p01 = p02; p02 = p03; p03 = p04; p04 = p05;
-
-      for (; i < wid - dx_r; i++) {
-        p00 = p01; p01 = p02; p02 = p03; p03 = p04;
-
-        p04 = sp4[0];
-
-        pix0 = (buffd[i    ] + p00 * k0 + p01 * k1 + p02 * k2 +
-                p03 * k3 + p04 * k4) >> shift2;
-        CLAMP_STORE(dp[0],     pix0);
-
-        dp  += chan1;
-        sp4 += chan1;
-      }
-
-      sp4 -= chan1;
-
-      for (; i < wid; i++) {
-        p00 = p01; p01 = p02; p02 = p03; p03 = p04;
-
-        p04 = sp4[0];
-
-        pix0 = (buffd[i    ] + p00 * k0 + p01 * k1 + p02 * k2 +
-                p03 * k3 + p04 * k4) >> shift2;
-        CLAMP_STORE(dp[0],     pix0);
-
-        dp  += chan1;
-      }
-
-      /* next line */
-
-      if (j < hgt - dy_b - 1) sl += sll;
-      dl += dll;
-    }
-  }
-
-  if (pbuff != buff) mlib_free(pbuff);
-
-  return MLIB_SUCCESS;
-}
-
-#endif /* __sparc ( for x86, using integer multiplies is faster ) */
-
-/***************************************************************/
-#if IMG_TYPE == 1
-
-#undef  KSIZE
-#define KSIZE 7
-
-mlib_status CONV_FUNC(7x7)
-{
-  FTYPE    buff[(KSIZE + 3)*BUFF_LINE], *buffs[2*(KSIZE + 1)], *buffd;
-  FTYPE    k[KSIZE*KSIZE];
-  mlib_s32 l, m, buff_ind;
-  mlib_s32 d0, d1;
-  FTYPE    k0, k1, k2, k3, k4, k5, k6;
-  FTYPE    p0, p1, p2, p3, p4, p5, p6, p7;
-  DTYPE *sl2, *sl3, *sl4, *sl5, *sl6;
-  DEF_VARS(DTYPE);
-  LOAD_KERNEL(KSIZE*KSIZE);
-  GET_SRC_DST_PARAMETERS(DTYPE);
-
-  swid = wid + KSIZE1;
-
-  if (wid > BUFF_LINE) {
-    pbuff = mlib_malloc((KSIZE + 3)*sizeof(FTYPE   )*wid);
-
-    if (pbuff == NULL) return MLIB_FAILURE;
-  }
-
-  for (l = 0; l < KSIZE + 1; l++) buffs[l] = pbuff + l*swid;
-  for (l = 0; l < KSIZE + 1; l++) buffs[l + (KSIZE + 1)] = buffs[l];
-  buffd = buffs[KSIZE] + swid;
-  buffo = (mlib_s32*)(buffd + swid);
-  buffi = buffo + (swid &~ 1);
-
-  swid -= (dx_l + dx_r);
-
-  chan1 = nchannel;
-  chan2 = chan1 + chan1;
-
-  for (c = 0; c < nchannel; c++) {
-    if (!(cmask & (1 << (nchannel - 1 - c)))) continue;
-
-    sl = adr_src + c;
-    dl = adr_dst + c;
-
-    if ((1 > dy_t) && (1 < hgt + KSIZE1 - dy_b)) sl1 = sl + sll;
-    else sl1 = sl;
-
-    if ((2 > dy_t) && (2 < hgt + KSIZE1 - dy_b)) sl2 = sl1 + sll;
-    else sl2 = sl1;
-
-    if ((3 > dy_t) && (3 < hgt + KSIZE1 - dy_b)) sl3 = sl2 + sll;
-    else sl3 = sl2;
-
-    if ((4 > dy_t) && (4 < hgt + KSIZE1 - dy_b)) sl4 = sl3 + sll;
-    else sl4 = sl3;
-
-    if ((5 > dy_t) && (5 < hgt + KSIZE1 - dy_b)) sl5 = sl4 + sll;
-    else sl5 = sl4;
-
-    if ((hgt - dy_b) > 0) sl6 = sl5 + sll;
-    else sl6 = sl5;
-
-    for (i = 0; i < dx_l; i++) {
-      buffs[0][i] = (FTYPE)sl[0];
-      buffs[1][i] = (FTYPE)sl1[0];
-      buffs[2][i] = (FTYPE)sl2[0];
-      buffs[3][i] = (FTYPE)sl3[0];
-      buffs[4][i] = (FTYPE)sl4[0];
-      buffs[5][i] = (FTYPE)sl5[0];
-      buffs[6][i] = (FTYPE)sl6[0];
-    }
-
-#ifdef __SUNPRO_C
-#pragma pipeloop(0)
-#endif /* __SUNPRO_C */
-    for (i = 0; i < swid; i++) {
-      buffs[0][i + dx_l] = (FTYPE)sl[i*chan1];
-      buffs[1][i + dx_l] = (FTYPE)sl1[i*chan1];
-      buffs[2][i + dx_l] = (FTYPE)sl2[i*chan1];
-      buffs[3][i + dx_l] = (FTYPE)sl3[i*chan1];
-      buffs[4][i + dx_l] = (FTYPE)sl4[i*chan1];
-      buffs[5][i + dx_l] = (FTYPE)sl5[i*chan1];
-      buffs[6][i + dx_l] = (FTYPE)sl6[i*chan1];
-    }
-
-    for (i = 0; i < dx_r; i++) {
-      buffs[0][swid + dx_l + i] = buffs[0][swid + dx_l - 1];
-      buffs[1][swid + dx_l + i] = buffs[1][swid + dx_l - 1];
-      buffs[2][swid + dx_l + i] = buffs[2][swid + dx_l - 1];
-      buffs[3][swid + dx_l + i] = buffs[3][swid + dx_l - 1];
-      buffs[4][swid + dx_l + i] = buffs[4][swid + dx_l - 1];
-      buffs[5][swid + dx_l + i] = buffs[5][swid + dx_l - 1];
-      buffs[6][swid + dx_l + i] = buffs[6][swid + dx_l - 1];
-    }
-
-    buff_ind = 0;
-
-#ifdef __SUNPRO_C
-#pragma pipeloop(0)
-#endif /* __SUNPRO_C */
-    for (i = 0; i < wid; i++) buffd[i] = 0.0;
-
-    if ((hgt - dy_b) > 1) sl = sl6 + sll;
-    else sl = sl6;
-
-    for (j = 0; j < hgt; j++) {
-      FTYPE    **buffc = buffs + buff_ind;
-      FTYPE    *buffn = buffc[KSIZE];
-      FTYPE    *pk = k;
-
-      for (l = 0; l < KSIZE; l++) {
-        FTYPE    *buff = buffc[l];
-        d64_2x32 dd;
-
-        sp = sl;
-        dp = dl;
-
-        p2 = buff[0]; p3 = buff[1]; p4 = buff[2];
-        p5 = buff[3]; p6 = buff[4]; p7 = buff[5];
-
-        k0 = *pk++; k1 = *pk++; k2 = *pk++; k3 = *pk++;
-        k4 = *pk++; k5 = *pk++; k6 = *pk++;
-
-        if (l < (KSIZE - 1)) {
-#ifdef __SUNPRO_C
-#pragma pipeloop(0)
-#endif /* __SUNPRO_C */
-          for (i = 0; i <= (wid - 2); i += 2) {
-            p0 = p2; p1 = p3; p2 = p4; p3 = p5; p4 = p6; p5 = p7;
-
-            p6 = buff[i + 6]; p7 = buff[i + 7];
-
-            buffd[i    ] += p0*k0 + p1*k1 + p2*k2 + p3*k3 + p4*k4 + p5*k5 + p6*k6;
-            buffd[i + 1] += p1*k0 + p2*k1 + p3*k2 + p4*k3 + p5*k4 + p6*k5 + p7*k6;
-          }
-
-        } else {
-#ifdef __SUNPRO_C
-#pragma pipeloop(0)
-#endif /* __SUNPRO_C */
-          for (i = 0; i <= (wid - 2); i += 2) {
-            p0 = p2; p1 = p3; p2 = p4; p3 = p5; p4 = p6; p5 = p7;
-
-            p6 = buff[i + 6]; p7 = buff[i + 7];
-
-            LOAD_BUFF(buffi);
-
-            dd.d64 = *(FTYPE   *)(buffi + i);
-            buffn[i + dx_l    ] = (FTYPE)dd.i32s.i0;
-            buffn[i + dx_l + 1] = (FTYPE)dd.i32s.i1;
-
-            d0 = D2I(p0*k0 + p1*k1 + p2*k2 + p3*k3 + p4*k4 + p5*k5 + p6*k6 + buffd[i    ]);
-            d1 = D2I(p1*k0 + p2*k1 + p3*k2 + p4*k3 + p5*k4 + p6*k5 + p7*k6 + buffd[i + 1]);
-
-            dp[0    ] = FROM_S32(d0);
-            dp[chan1] = FROM_S32(d1);
-
-            buffd[i    ] = 0.0;
-            buffd[i + 1] = 0.0;
-
-            sp += chan2;
-            dp += chan2;
-          }
-        }
-      }
-
-      /* last pixels */
-      for (; i < wid; i++) {
-        FTYPE    *pk = k, s = 0;
-        mlib_s32 d0;
-
-        for (l = 0; l < KSIZE; l++) {
-          FTYPE    *buff = buffc[l] + i;
-
-          for (m = 0; m < KSIZE; m++) s += buff[m] * (*pk++);
-        }
-
-        d0 = D2I(s);
-        dp[0] = FROM_S32(d0);
-
-        buffn[i + dx_l] = (FTYPE)sp[0];
-
-        sp += chan1;
-        dp += chan1;
-      }
-
-      for (; i < swid; i++) {
-        buffn[i + dx_l] = (FTYPE)sp[0];
-        sp += chan1;
-      }
-
-      for (i = 0; i < dx_l; i++) buffn[i] = buffn[dx_l];
-      for (i = 0; i < dx_r; i++) buffn[swid + dx_l + i] = buffn[swid + dx_l - 1];
-
-      /* next line */
-
-      if (j < hgt - dy_b - 2) sl += sll;
-      dl += dll;
-
-      buff_ind++;
-
-      if (buff_ind >= KSIZE + 1) buff_ind = 0;
-    }
-  }
-
-  if (pbuff != buff) mlib_free(pbuff);
-
-  return MLIB_SUCCESS;
-}
-
-#endif /* IMG_TYPE == 1 */
-
-/***************************************************************/
 #define MAX_KER   7
 #define MAX_N    15
 #define BUFF_SIZE   1600
--- a/jdk/src/java.desktop/share/native/libmlib_image/mlib_ImageConv_u16nw.c	Thu May 19 17:48:02 2016 +0000
+++ b/jdk/src/java.desktop/share/native/libmlib_image/mlib_ImageConv_u16nw.c	Thu May 19 19:46:20 2016 +0000
@@ -144,9 +144,6 @@
 } d64_2x32;
 
 /***************************************************************/
-#define BUFF_LINE 256
-
-/***************************************************************/
 #define DEF_VARS(type)                                          \
   type     *adr_src, *sl, *sp = NULL;                           \
   type     *adr_dst, *dl, *dp = NULL;                           \
@@ -156,39 +153,6 @@
   mlib_s32 i, j, c
 
 /***************************************************************/
-#define LOAD_KERNEL3()                                                   \
-  FTYPE    scalef = DSCALE;                                              \
-  FTYPE    k0, k1, k2, k3, k4, k5, k6, k7, k8;                           \
-  FTYPE    p00, p01, p02, p03,                                           \
-           p10, p11, p12, p13,                                           \
-           p20, p21, p22, p23;                                           \
-                                                                         \
-  while (scalef_expon > 30) {                                            \
-    scalef /= (1 << 30);                                                 \
-    scalef_expon -= 30;                                                  \
-  }                                                                      \
-                                                                         \
-  scalef /= (1 << scalef_expon);                                         \
-                                                                         \
-  /* keep kernel in regs */                                              \
-  k0 = scalef * kern[0];  k1 = scalef * kern[1];  k2 = scalef * kern[2]; \
-  k3 = scalef * kern[3];  k4 = scalef * kern[4];  k5 = scalef * kern[5]; \
-  k6 = scalef * kern[6];  k7 = scalef * kern[7];  k8 = scalef * kern[8]
-
-/***************************************************************/
-#define LOAD_KERNEL(SIZE)                                       \
-  FTYPE    scalef = DSCALE;                                     \
-                                                                \
-  while (scalef_expon > 30) {                                   \
-    scalef /= (1 << 30);                                        \
-    scalef_expon -= 30;                                         \
-  }                                                             \
-                                                                \
-  scalef /= (1 << scalef_expon);                                \
-                                                                \
-  for (j = 0; j < SIZE; j++) k[j] = scalef * kern[j]
-
-/***************************************************************/
 #define GET_SRC_DST_PARAMETERS(type)                            \
   hgt = mlib_ImageGetHeight(src);                               \
   wid = mlib_ImageGetWidth(src);                                \
@@ -246,1162 +210,6 @@
 #endif /* __sparc */
 
 /***************************************************************/
-#define KSIZE  3
-
-mlib_status CONV_FUNC(3x3)(mlib_image       *dst,
-                           const mlib_image *src,
-                           const mlib_s32   *kern,
-                           mlib_s32         scalef_expon,
-                           mlib_s32         cmask)
-{
-  FTYPE    buff[(KSIZE + 2)*BUFF_LINE], *buff0, *buff1, *buff2, *buff3, *buffT;
-  DEF_VARS(DTYPE);
-  DTYPE *sl1;
-  mlib_s32 chan2;
-  mlib_s32 *buffo, *buffi;
-  DTYPE *sl2;
-#ifndef __sparc
-  mlib_s32 d0, d1;
-#endif /* __sparc */
-  LOAD_KERNEL3();
-  GET_SRC_DST_PARAMETERS(DTYPE);
-
-  if (wid > BUFF_LINE) {
-    pbuff = mlib_malloc((KSIZE + 2)*sizeof(FTYPE)*wid);
-
-    if (pbuff == NULL) return MLIB_FAILURE;
-  }
-
-  buff0 = pbuff;
-  buff1 = buff0 + wid;
-  buff2 = buff1 + wid;
-  buff3 = buff2 + wid;
-  buffo = (mlib_s32*)(buff3 + wid);
-  buffi = buffo + (wid &~ 1);
-
-  chan1 = nchannel;
-  chan2 = chan1 + chan1;
-
-  wid -= (KSIZE - 1);
-  hgt -= (KSIZE - 1);
-
-  adr_dst += ((KSIZE - 1)/2)*(dll + chan1);
-
-  for (c = 0; c < nchannel; c++) {
-    if (!(cmask & (1 << (nchannel - 1 - c)))) continue;
-
-    sl = adr_src + c;
-    dl = adr_dst + c;
-
-    sl1 = sl  + sll;
-    sl2 = sl1 + sll;
-#ifdef __SUNPRO_C
-#pragma pipeloop(0)
-#endif /* __SUNPRO_C */
-    for (i = 0; i < wid + (KSIZE - 1); i++) {
-      buff0[i] = (FTYPE)sl[i*chan1];
-      buff1[i] = (FTYPE)sl1[i*chan1];
-      buff2[i] = (FTYPE)sl2[i*chan1];
-    }
-
-    sl += KSIZE*sll;
-
-    for (j = 0; j < hgt; j++) {
-      FTYPE    s0, s1;
-
-      p02 = buff0[0];
-      p12 = buff1[0];
-      p22 = buff2[0];
-
-      p03 = buff0[1];
-      p13 = buff1[1];
-      p23 = buff2[1];
-
-      s0 = p02 * k0 + p03 * k1 + p12 * k3 + p13 * k4 + p22 * k6 + p23 * k7;
-      s1 = p03 * k0 + p13 * k3 + p23 * k6;
-
-      sp = sl;
-      dp = dl;
-
-#ifdef __SUNPRO_C
-#pragma pipeloop(0)
-#endif /* __SUNPRO_C */
-      for (i = 0; i <= (wid - 2); i += 2) {
-#ifdef __sparc
-#ifdef _NO_LONGLONG
-        mlib_s32 o64_1, o64_2;
-#else /* _NO_LONGLONG */
-        mlib_s64 o64;
-#endif /* _NO_LONGLONG */
-#endif /* __sparc */
-        d64_2x32 dd;
-
-        p02 = buff0[i + 2]; p12 = buff1[i + 2]; p22 = buff2[i + 2];
-        p03 = buff0[i + 3]; p13 = buff1[i + 3]; p23 = buff2[i + 3];
-
-        LOAD_BUFF(buffi);
-
-        dd.d64 = *(FTYPE   *)(buffi + i);
-        buff3[i    ] = (FTYPE)dd.i32s.i0;
-        buff3[i + 1] = (FTYPE)dd.i32s.i1;
-
-#ifndef __sparc
-        d0 = D2I(s0 + p02 * k2 + p12 * k5 + p22 * k8);
-        d1 = D2I(s1 + p02 * k1 + p03 * k2 + p12 * k4 + p13 * k5 + p22 * k7 + p23 * k8);
-
-        s0 = p02 * k0 + p03 * k1 + p12 * k3 + p13 * k4 + p22 * k6 + p23 * k7;
-        s1 = p03 * k0 + p13 * k3 + p23 * k6;
-
-        dp[0    ] = FROM_S32(d0);
-        dp[chan1] = FROM_S32(d1);
-
-#else /* __sparc */
-
-        dd.i32s.i0 = D2I(s0 + p02 * k2 + p12 * k5 + p22 * k8);
-        dd.i32s.i1 = D2I(s1 + p02 * k1 + p03 * k2 + p12 * k4 + p13 * k5 + p22 * k7 + p23 * k8);
-        *(FTYPE   *)(buffo + i) = dd.d64;
-
-        s0 = p02 * k0 + p03 * k1 + p12 * k3 + p13 * k4 + p22 * k6 + p23 * k7;
-        s1 = p03 * k0 + p13 * k3 + p23 * k6;
-
-#ifdef _NO_LONGLONG
-
-        o64_1 = buffo[i];
-        o64_2 = buffo[i+1];
-#if IMG_TYPE != 1
-        STORE2(FROM_S32(o64_1), FROM_S32(o64_2));
-#else
-        STORE2(o64_1 >> 24, o64_2 >> 24);
-#endif /* IMG_TYPE != 1 */
-
-#else /* _NO_LONGLONG */
-
-        o64 = *(mlib_s64*)(buffo + i);
-#if IMG_TYPE != 1
-        STORE2(FROM_S32(o64 >> 32), FROM_S32(o64));
-#else
-        STORE2(o64 >> 56, o64 >> 24);
-#endif /* IMG_TYPE != 1 */
-#endif /* _NO_LONGLONG */
-#endif /* __sparc */
-
-        sp += chan2;
-        dp += chan2;
-      }
-
-      for (; i < wid; i++) {
-        p00 = buff0[i];     p10 = buff1[i];     p20 = buff2[i];
-        p01 = buff0[i + 1]; p11 = buff1[i + 1]; p21 = buff2[i + 1];
-        p02 = buff0[i + 2]; p12 = buff1[i + 2]; p22 = buff2[i + 2];
-
-        buffi[i] = (mlib_s32)sp[0];
-        buff3[i] = (FTYPE)buffi[i];
-
-#ifndef __sparc
-
-        d0 = D2I(p00 * k0 + p01 * k1 + p02 * k2 + p10 * k3 + p11 * k4 +
-                 p12 * k5 + p20 * k6 + p21 * k7 + p22 * k8);
-
-        dp[0] = FROM_S32(d0);
-
-#else  /* __sparc */
-
-        buffo[i] = D2I(p00 * k0 + p01 * k1 + p02 * k2 + p10 * k3 + p11 * k4 +
-                       p12 * k5 + p20 * k6 + p21 * k7 + p22 * k8);
-#if IMG_TYPE != 1
-        dp[0] = FROM_S32(buffo[i]);
-#else
-        dp[0] = buffo[i] >> 24;
-#endif /* IMG_TYPE != 1 */
-#endif /* __sparc */
-
-        sp += chan1;
-        dp += chan1;
-      }
-
-      buffi[wid] = (mlib_s32)sp[0];
-      buff3[wid] = (FTYPE)buffi[wid];
-      buffi[wid + 1] = (mlib_s32)sp[chan1];
-      buff3[wid + 1] = (FTYPE)buffi[wid + 1];
-
-      sl += sll;
-      dl += dll;
-
-      buffT = buff0;
-      buff0 = buff1;
-      buff1 = buff2;
-      buff2 = buff3;
-      buff3 = buffT;
-    }
-  }
-
-#ifdef __sparc
-#if IMG_TYPE == 1
-  {
-    mlib_s32 amask = (1 << nchannel) - 1;
-
-    if ((cmask & amask) != amask) {
-      mlib_ImageXor80(adr_dst, wid, hgt, dll, nchannel, cmask);
-    } else {
-      mlib_ImageXor80_aa(adr_dst, wid*nchannel, hgt, dll);
-    }
-  }
-
-#endif /* IMG_TYPE == 1 */
-#endif /* __sparc */
-
-  if (pbuff != buff) mlib_free(pbuff);
-
-  return MLIB_SUCCESS;
-}
-
-/***************************************************************/
-#ifndef __sparc /* for x86, using integer multiplies is faster */
-
-mlib_status CONV_FUNC_I(3x3)(mlib_image       *dst,
-                             const mlib_image *src,
-                             const mlib_s32   *kern,
-                             mlib_s32         scalef_expon,
-                             mlib_s32         cmask)
-{
-  DTYPE    *adr_src, *sl, *sp0, *sp1, *sp2;
-  DTYPE    *adr_dst, *dl, *dp;
-  mlib_s32 wid, hgt, sll, dll;
-  mlib_s32 nchannel, chan1, chan2;
-  mlib_s32 i, j, c;
-  mlib_s32 shift1, shift2;
-  mlib_s32 k0, k1, k2, k3, k4, k5, k6, k7, k8;
-  mlib_s32 p02, p03,
-           p12, p13,
-           p22, p23;
-
-#if IMG_TYPE != 1
-  shift1 = 16;
-#else
-  shift1 = 8;
-#endif /* IMG_TYPE != 1 */
-
-  shift2 = scalef_expon - shift1;
-
-  /* keep kernel in regs */
-  k0 = kern[0] >> shift1;  k1 = kern[1] >> shift1;  k2 = kern[2] >> shift1;
-  k3 = kern[3] >> shift1;  k4 = kern[4] >> shift1;  k5 = kern[5] >> shift1;
-  k6 = kern[6] >> shift1;  k7 = kern[7] >> shift1;  k8 = kern[8] >> shift1;
-
-  GET_SRC_DST_PARAMETERS(DTYPE);
-
-  chan1 = nchannel;
-  chan2 = chan1 + chan1;
-
-  wid -= (KSIZE - 1);
-  hgt -= (KSIZE - 1);
-
-  adr_dst += ((KSIZE - 1)/2)*(dll + chan1);
-
-  for (c = 0; c < chan1; c++) {
-    if (!(cmask & (1 << (chan1 - 1 - c)))) continue;
-
-    sl = adr_src + c;
-    dl = adr_dst + c;
-
-    for (j = 0; j < hgt; j++) {
-      mlib_s32 s0, s1;
-      mlib_s32 pix0, pix1;
-
-      dp  = dl;
-      sp0 = sl;
-      sp1 = sp0 + sll;
-      sp2 = sp1 + sll;
-
-      p02 = sp0[0];
-      p12 = sp1[0];
-      p22 = sp2[0];
-
-      p03 = sp0[chan1];
-      p13 = sp1[chan1];
-      p23 = sp2[chan1];
-
-      s0 = p02 * k0 + p03 * k1 + p12 * k3 + p13 * k4 + p22 * k6 + p23 * k7;
-      s1 = p03 * k0 + p13 * k3 + p23 * k6;
-
-      sp0 += chan2;
-      sp1 += chan2;
-      sp2 += chan2;
-
-#ifdef __SUNPRO_C
-#pragma pipeloop(0)
-#endif /* __SUNPRO_C */
-      for (i = 0; i <= (wid - 2); i += 2) {
-        p02 = sp0[0];     p12 = sp1[0];     p22 = sp2[0];
-        p03 = sp0[chan1]; p13 = sp1[chan1]; p23 = sp2[chan1];
-
-        pix0 = (s0 + p02 * k2 + p12 * k5 + p22 * k8) >> shift2;
-        pix1 = (s1 + p02 * k1 + p03 * k2 + p12 * k4 +
-                p13 * k5 + p22 * k7 + p23 * k8) >> shift2;
-
-        CLAMP_STORE(dp[0],     pix0);
-        CLAMP_STORE(dp[chan1], pix1);
-
-        s0 = p02 * k0 + p03 * k1 + p12 * k3 + p13 * k4 + p22 * k6 + p23 * k7;
-        s1 = p03 * k0 + p13 * k3 + p23 * k6;
-
-        sp0 += chan2;
-        sp1 += chan2;
-        sp2 += chan2;
-        dp += chan2;
-      }
-
-      if (wid & 1) {
-        p02 = sp0[0]; p12 = sp1[0]; p22 = sp2[0];
-        pix0 = (s0 + p02 * k2 + p12 * k5 + p22 * k8) >> shift2;
-        CLAMP_STORE(dp[0], pix0);
-      }
-
-      sl += sll;
-      dl += dll;
-    }
-  }
-
-  return MLIB_SUCCESS;
-}
-
-#endif /* __sparc ( for x86, using integer multiplies is faster ) */
-
-/***************************************************************/
-#undef  KSIZE
-#define KSIZE 4
-
-mlib_status CONV_FUNC(4x4)(mlib_image       *dst,
-                           const mlib_image *src,
-                           const mlib_s32   *kern,
-                           mlib_s32         scalef_expon,
-                           mlib_s32         cmask)
-{
-  FTYPE    buff[(KSIZE + 3)*BUFF_LINE];
-  FTYPE    *buff0, *buff1, *buff2, *buff3, *buff4, *buffd, *buffT;
-  FTYPE    k[KSIZE*KSIZE];
-  mlib_s32 d0, d1;
-  FTYPE    k0, k1, k2, k3, k4, k5, k6, k7;
-  FTYPE    p00, p01, p02, p03, p04,
-           p10, p11, p12, p13, p14,
-           p20, p21, p22, p23,
-           p30, p31, p32, p33;
-  DEF_VARS(DTYPE);
-  DTYPE *sl1;
-  mlib_s32 chan2;
-  mlib_s32 *buffo, *buffi;
-  DTYPE *sl2, *sl3;
-  LOAD_KERNEL(KSIZE*KSIZE);
-  GET_SRC_DST_PARAMETERS(DTYPE);
-
-  if (wid > BUFF_LINE) {
-    pbuff = mlib_malloc((KSIZE + 3)*sizeof(FTYPE)*wid);
-
-    if (pbuff == NULL) return MLIB_FAILURE;
-  }
-
-  buff0 = pbuff;
-  buff1 = buff0 + wid;
-  buff2 = buff1 + wid;
-  buff3 = buff2 + wid;
-  buff4 = buff3 + wid;
-  buffd = buff4 + wid;
-  buffo = (mlib_s32*)(buffd + wid);
-  buffi = buffo + (wid &~ 1);
-
-  chan1 = nchannel;
-  chan2 = chan1 + chan1;
-
-  wid -= (KSIZE - 1);
-  hgt -= (KSIZE - 1);
-
-  adr_dst += ((KSIZE - 1)/2)*(dll + chan1);
-
-  for (c = 0; c < nchannel; c++) {
-    if (!(cmask & (1 << (nchannel - 1 - c)))) continue;
-
-    sl = adr_src + c;
-    dl = adr_dst + c;
-
-    sl1 = sl  + sll;
-    sl2 = sl1 + sll;
-    sl3 = sl2 + sll;
-#ifdef __SUNPRO_C
-#pragma pipeloop(0)
-#endif /* __SUNPRO_C */
-    for (i = 0; i < wid + (KSIZE - 1); i++) {
-      buff0[i] = (FTYPE)sl[i*chan1];
-      buff1[i] = (FTYPE)sl1[i*chan1];
-      buff2[i] = (FTYPE)sl2[i*chan1];
-      buff3[i] = (FTYPE)sl3[i*chan1];
-    }
-
-    sl += KSIZE*sll;
-
-    for (j = 0; j < hgt; j++) {
-      d64_2x32 dd;
-
-      /*
-       *  First loop on two first lines of kernel
-       */
-      k0 = k[0]; k1 = k[1]; k2 = k[2]; k3 = k[3];
-      k4 = k[4]; k5 = k[5]; k6 = k[6]; k7 = k[7];
-
-      sp = sl;
-      dp = dl;
-
-      p02 = buff0[0];
-      p12 = buff1[0];
-      p03 = buff0[1];
-      p13 = buff1[1];
-      p04 = buff0[2];
-
-#ifdef __SUNPRO_C
-#pragma pipeloop(0)
-#endif /* __SUNPRO_C */
-      for (i = 0; i <= (wid - 2); i += 2) {
-        p00 = p02; p10 = p12;
-        p01 = p03; p11 = p13;
-        p02 = p04; p12 = buff1[i + 2];
-        p03 = buff0[i + 3]; p13 = buff1[i + 3];
-        p04 = buff0[i + 4]; p14 = buff1[i + 4];
-
-        LOAD_BUFF(buffi);
-
-        dd.d64 = *(FTYPE   *)(buffi + i);
-        buff4[i    ] = (FTYPE)dd.i32s.i0;
-        buff4[i + 1] = (FTYPE)dd.i32s.i1;
-
-        buffd[i    ] = (p00 * k0 + p01 * k1 + p02 * k2 + p03 * k3 +
-                        p10 * k4 + p11 * k5 + p12 * k6 + p13 * k7);
-        buffd[i + 1] = (p01 * k0 + p02 * k1 + p03 * k2 + p04 * k3 +
-                        p11 * k4 + p12 * k5 + p13 * k6 + p14 * k7);
-
-        sp += chan2;
-        dp += chan2;
-      }
-
-      /*
-       *  Second loop on two last lines of kernel
-       */
-      k0 = k[ 8]; k1 = k[ 9]; k2 = k[10]; k3 = k[11];
-      k4 = k[12]; k5 = k[13]; k6 = k[14]; k7 = k[15];
-
-      sp = sl;
-      dp = dl;
-
-      p02 = buff2[0];
-      p12 = buff3[0];
-      p03 = buff2[1];
-      p13 = buff3[1];
-      p04 = buff2[2];
-
-#ifdef __SUNPRO_C
-#pragma pipeloop(0)
-#endif /* __SUNPRO_C */
-      for (i = 0; i <= (wid - 2); i += 2) {
-        p00 = p02; p10 = p12;
-        p01 = p03; p11 = p13;
-        p02 = p04; p12 = buff3[i + 2];
-        p03 = buff2[i + 3]; p13 = buff3[i + 3];
-        p04 = buff2[i + 4]; p14 = buff3[i + 4];
-
-        d0 = D2I(p00 * k0 + p01 * k1 + p02 * k2 + p03 * k3 +
-                 p10 * k4 + p11 * k5 + p12 * k6 + p13 * k7 + buffd[i]);
-        d1 = D2I(p01 * k0 + p02 * k1 + p03 * k2 + p04 * k3 +
-                 p11 * k4 + p12 * k5 + p13 * k6 + p14 * k7 + buffd[i + 1]);
-
-        dp[0    ] = FROM_S32(d0);
-        dp[chan1] = FROM_S32(d1);
-
-        sp += chan2;
-        dp += chan2;
-      }
-
-      /* last pixels */
-      for (; i < wid; i++) {
-        p00 = buff0[i];     p10 = buff1[i];     p20 = buff2[i];     p30 = buff3[i];
-        p01 = buff0[i + 1]; p11 = buff1[i + 1]; p21 = buff2[i + 1]; p31 = buff3[i + 1];
-        p02 = buff0[i + 2]; p12 = buff1[i + 2]; p22 = buff2[i + 2]; p32 = buff3[i + 2];
-        p03 = buff0[i + 3]; p13 = buff1[i + 3]; p23 = buff2[i + 3]; p33 = buff3[i + 3];
-
-        buff4[i] = (FTYPE)sp[0];
-
-        buffo[i] = D2I(p00 * k[0] + p01 * k[1] + p02 * k[2] + p03 * k[3] +
-                       p10 * k[4] + p11 * k[5] + p12 * k[6] + p13 * k[7] +
-                       p20 * k[ 8] + p21 * k[ 9] + p22 * k[10] + p23 * k[11] +
-                       p30 * k[12] + p31 * k[13] + p32 * k[14] + p33 * k[15]);
-
-        dp[0] = FROM_S32(buffo[i]);
-
-        sp += chan1;
-        dp += chan1;
-      }
-
-      buff4[wid    ] = (FTYPE)sp[0];
-      buff4[wid + 1] = (FTYPE)sp[chan1];
-      buff4[wid + 2] = (FTYPE)sp[chan2];
-
-      /* next line */
-      sl += sll;
-      dl += dll;
-
-      buffT = buff0;
-      buff0 = buff1;
-      buff1 = buff2;
-      buff2 = buff3;
-      buff3 = buff4;
-      buff4 = buffT;
-    }
-  }
-
-  if (pbuff != buff) mlib_free(pbuff);
-
-  return MLIB_SUCCESS;
-}
-
-/***************************************************************/
-#undef  KSIZE
-#define KSIZE 5
-
-mlib_status CONV_FUNC(5x5)(mlib_image       *dst,
-                           const mlib_image *src,
-                           const mlib_s32   *kern,
-                           mlib_s32         scalef_expon,
-                           mlib_s32         cmask)
-{
-  FTYPE    buff[(KSIZE + 3)*BUFF_LINE];
-  FTYPE    *buff0, *buff1, *buff2, *buff3, *buff4, *buff5, *buffd, *buffT;
-  FTYPE    k[KSIZE*KSIZE];
-  mlib_s32 d0, d1;
-  FTYPE    k0, k1, k2, k3, k4, k5, k6, k7, k8, k9;
-  FTYPE    p00, p01, p02, p03, p04, p05,
-           p10, p11, p12, p13, p14, p15,
-           p20, p21, p22, p23, p24,
-           p30, p31, p32, p33, p34,
-           p40, p41, p42, p43, p44;
-  DEF_VARS(DTYPE);
-  DTYPE *sl1;
-  mlib_s32 chan2;
-  mlib_s32 *buffo, *buffi;
-  DTYPE *sl2, *sl3, *sl4;
-  LOAD_KERNEL(KSIZE*KSIZE);
-  GET_SRC_DST_PARAMETERS(DTYPE);
-
-  if (wid > BUFF_LINE) {
-    pbuff = mlib_malloc((KSIZE + 3)*sizeof(FTYPE)*wid);
-
-    if (pbuff == NULL) return MLIB_FAILURE;
-  }
-
-  buff0 = pbuff;
-  buff1 = buff0 + wid;
-  buff2 = buff1 + wid;
-  buff3 = buff2 + wid;
-  buff4 = buff3 + wid;
-  buff5 = buff4 + wid;
-  buffd = buff5 + wid;
-  buffo = (mlib_s32*)(buffd + wid);
-  buffi = buffo + (wid &~ 1);
-
-  chan1 = nchannel;
-  chan2 = chan1 + chan1;
-
-  wid -= (KSIZE - 1);
-  hgt -= (KSIZE - 1);
-
-  adr_dst += ((KSIZE - 1)/2)*(dll + chan1);
-
-  for (c = 0; c < nchannel; c++) {
-    if (!(cmask & (1 << (nchannel - 1 - c)))) continue;
-
-    sl = adr_src + c;
-    dl = adr_dst + c;
-
-    sl1 = sl  + sll;
-    sl2 = sl1 + sll;
-    sl3 = sl2 + sll;
-    sl4 = sl3 + sll;
-#ifdef __SUNPRO_C
-#pragma pipeloop(0)
-#endif /* __SUNPRO_C */
-    for (i = 0; i < wid + (KSIZE - 1); i++) {
-      buff0[i] = (FTYPE)sl[i*chan1];
-      buff1[i] = (FTYPE)sl1[i*chan1];
-      buff2[i] = (FTYPE)sl2[i*chan1];
-      buff3[i] = (FTYPE)sl3[i*chan1];
-      buff4[i] = (FTYPE)sl4[i*chan1];
-    }
-
-    sl += KSIZE*sll;
-
-    for (j = 0; j < hgt; j++) {
-      d64_2x32 dd;
-
-      /*
-       *  First loop
-       */
-      k0 = k[0]; k1 = k[1]; k2 = k[2]; k3 = k[3]; k4 = k[4];
-      k5 = k[5]; k6 = k[6]; k7 = k[7]; k8 = k[8]; k9 = k[9];
-
-      sp = sl;
-      dp = dl;
-
-      p02 = buff0[0];
-      p12 = buff1[0];
-      p03 = buff0[1];
-      p13 = buff1[1];
-      p04 = buff0[2];
-      p14 = buff1[2];
-
-#ifdef __SUNPRO_C
-#pragma pipeloop(0)
-#endif /* __SUNPRO_C */
-      for (i = 0; i <= (wid - 2); i += 2) {
-        p00 = p02; p10 = p12;
-        p01 = p03; p11 = p13;
-        p02 = p04; p12 = p14;
-
-        LOAD_BUFF(buffi);
-
-        p03 = buff0[i + 3]; p13 = buff1[i + 3];
-        p04 = buff0[i + 4]; p14 = buff1[i + 4];
-        p05 = buff0[i + 5]; p15 = buff1[i + 5];
-
-        buffd[i    ] = (p00 * k0 + p01 * k1 + p02 * k2 + p03 * k3 + p04 * k4 +
-                        p10 * k5 + p11 * k6 + p12 * k7 + p13 * k8 + p14 * k9);
-        buffd[i + 1] = (p01 * k0 + p02 * k1 + p03 * k2 + p04 * k3 + p05 * k4 +
-                        p11 * k5 + p12 * k6 + p13 * k7 + p14 * k8 + p15 * k9);
-
-        sp += chan2;
-        dp += chan2;
-      }
-
-      /*
-       *  Second loop
-       */
-      k0 = k[10]; k1 = k[11]; k2 = k[12]; k3 = k[13]; k4 = k[14];
-      k5 = k[15]; k6 = k[16]; k7 = k[17]; k8 = k[18]; k9 = k[19];
-
-      sp = sl;
-      dp = dl;
-
-      p02 = buff2[0];
-      p12 = buff3[0];
-      p03 = buff2[1];
-      p13 = buff3[1];
-      p04 = buff2[2];
-      p14 = buff3[2];
-
-#ifdef __SUNPRO_C
-#pragma pipeloop(0)
-#endif /* __SUNPRO_C */
-      for (i = 0; i <= (wid - 2); i += 2) {
-        p00 = p02; p10 = p12;
-        p01 = p03; p11 = p13;
-
-        p02 = buff2[i + 2]; p12 = buff3[i + 2];
-        p03 = buff2[i + 3]; p13 = buff3[i + 3];
-        p04 = buff2[i + 4]; p14 = buff3[i + 4];
-        p05 = buff2[i + 5]; p15 = buff3[i + 5];
-
-        dd.d64 = *(FTYPE   *)(buffi + i);
-        buff5[i    ] = (FTYPE)dd.i32s.i0;
-        buff5[i + 1] = (FTYPE)dd.i32s.i1;
-
-        buffd[i    ] += (p00 * k0 + p01 * k1 + p02 * k2 + p03 * k3 + p04 * k4 +
-                         p10 * k5 + p11 * k6 + p12 * k7 + p13 * k8 + p14 * k9);
-        buffd[i + 1] += (p01 * k0 + p02 * k1 + p03 * k2 + p04 * k3 + p05 * k4 +
-                         p11 * k5 + p12 * k6 + p13 * k7 + p14 * k8 + p15 * k9);
-
-        sp += chan2;
-        dp += chan2;
-      }
-
-      /*
-       *  3 loop
-       */
-      k0 = k[20]; k1 = k[21]; k2 = k[22]; k3 = k[23]; k4 = k[24];
-
-      sp = sl;
-      dp = dl;
-
-      p02 = buff4[0];
-      p03 = buff4[1];
-      p04 = buff4[2];
-      p05 = buff4[3];
-
-#ifdef __SUNPRO_C
-#pragma pipeloop(0)
-#endif /* __SUNPRO_C */
-      for (i = 0; i <= (wid - 2); i += 2) {
-        p00 = p02; p01 = p03; p02 = p04; p03 = p05;
-
-        p04 = buff4[i + 4]; p05 = buff4[i + 5];
-
-        d0 = D2I(p00 * k0 + p01 * k1 + p02 * k2 + p03 * k3 + p04 * k4 + buffd[i]);
-        d1 = D2I(p01 * k0 + p02 * k1 + p03 * k2 + p04 * k3 + p05 * k4 + buffd[i + 1]);
-
-        dp[0    ] = FROM_S32(d0);
-        dp[chan1] = FROM_S32(d1);
-
-        sp += chan2;
-        dp += chan2;
-      }
-
-      /* last pixels */
-      for (; i < wid; i++) {
-        p00 = buff0[i];     p10 = buff1[i];     p20 = buff2[i];     p30 = buff3[i];
-        p01 = buff0[i + 1]; p11 = buff1[i + 1]; p21 = buff2[i + 1]; p31 = buff3[i + 1];
-        p02 = buff0[i + 2]; p12 = buff1[i + 2]; p22 = buff2[i + 2]; p32 = buff3[i + 2];
-        p03 = buff0[i + 3]; p13 = buff1[i + 3]; p23 = buff2[i + 3]; p33 = buff3[i + 3];
-        p04 = buff0[i + 4]; p14 = buff1[i + 4]; p24 = buff2[i + 4]; p34 = buff3[i + 4];
-
-        p40 = buff4[i];     p41 = buff4[i + 1]; p42 = buff4[i + 2];
-        p43 = buff4[i + 3]; p44 = buff4[i + 4];
-
-        buff5[i] = (FTYPE)sp[0];
-
-        buffo[i] = D2I(p00 * k[0] + p01 * k[1] + p02 * k[2] + p03 * k[3] + p04 * k[4] +
-                       p10 * k[5] + p11 * k[6] + p12 * k[7] + p13 * k[8] + p14 * k[9] +
-                       p20 * k[10] + p21 * k[11] + p22 * k[12] + p23 * k[13] + p24 * k[14] +
-                       p30 * k[15] + p31 * k[16] + p32 * k[17] + p33 * k[18] + p34 * k[19] +
-                       p40 * k[20] + p41 * k[21] + p42 * k[22] + p43 * k[23] + p44 * k[24]);
-
-        dp[0] = FROM_S32(buffo[i]);
-
-        sp += chan1;
-        dp += chan1;
-      }
-
-      buff5[wid    ] = (FTYPE)sp[0];
-      buff5[wid + 1] = (FTYPE)sp[chan1];
-      buff5[wid + 2] = (FTYPE)sp[chan2];
-      buff5[wid + 3] = (FTYPE)sp[chan2 + chan1];
-
-      /* next line */
-      sl += sll;
-      dl += dll;
-
-      buffT = buff0;
-      buff0 = buff1;
-      buff1 = buff2;
-      buff2 = buff3;
-      buff3 = buff4;
-      buff4 = buff5;
-      buff5 = buffT;
-    }
-  }
-
-  if (pbuff != buff) mlib_free(pbuff);
-
-  return MLIB_SUCCESS;
-}
-
-/***************************************************************/
-#ifndef __sparc /* for x86, using integer multiplies is faster */
-
-mlib_status CONV_FUNC_I(5x5)(mlib_image       *dst,
-                             const mlib_image *src,
-                             const mlib_s32   *kern,
-                             mlib_s32         scalef_expon,
-                             mlib_s32         cmask)
-{
-  mlib_s32 buff[BUFF_LINE];
-  mlib_s32 *buffd;
-  mlib_s32 k[KSIZE*KSIZE];
-  mlib_s32 shift1, shift2;
-  mlib_s32 k0, k1, k2, k3, k4, k5, k6, k7, k8, k9;
-  mlib_s32 p00, p01, p02, p03, p04, p05,
-           p10, p11, p12, p13, p14, p15;
-  DTYPE    *adr_src, *sl, *sp0, *sp1;
-  DTYPE    *adr_dst, *dl, *dp;
-  mlib_s32 *pbuff = buff;
-  mlib_s32 wid, hgt, sll, dll;
-  mlib_s32 nchannel, chan1, chan2, chan3, chan4;
-  mlib_s32 i, j, c;
-
-#if IMG_TYPE != 1
-  shift1 = 16;
-#else
-  shift1 = 8;
-#endif /* IMG_TYPE != 1 */
-
-  shift2 = scalef_expon - shift1;
-
-  for (j = 0; j < KSIZE*KSIZE; j++) k[j] = kern[j] >> shift1;
-
-  GET_SRC_DST_PARAMETERS(DTYPE);
-
-  if (wid > BUFF_LINE) {
-    pbuff = mlib_malloc(sizeof(mlib_s32)*wid);
-
-    if (pbuff == NULL) return MLIB_FAILURE;
-  }
-
-  buffd = pbuff;
-
-  chan1 = nchannel;
-  chan2 = chan1 + chan1;
-  chan3 = chan2 + chan1;
-  chan4 = chan3 + chan1;
-
-  wid -= (KSIZE - 1);
-  hgt -= (KSIZE - 1);
-
-  adr_dst += ((KSIZE - 1)/2)*(dll + chan1);
-
-  for (c = 0; c < chan1; c++) {
-    if (!(cmask & (1 << (chan1 - 1 - c)))) continue;
-
-    sl = adr_src + c;
-    dl = adr_dst + c;
-
-    for (j = 0; j < hgt; j++) {
-      mlib_s32 pix0, pix1;
-      /*
-       *  First loop
-       */
-      sp0 = sl;
-      sp1 = sp0 + sll;
-      dp = dl;
-
-      k0 = k[0]; k1 = k[1]; k2 = k[2]; k3 = k[3]; k4 = k[4];
-      k5 = k[5]; k6 = k[6]; k7 = k[7]; k8 = k[8]; k9 = k[9];
-
-      p02 = sp0[0];     p12 = sp1[0];
-      p03 = sp0[chan1]; p13 = sp1[chan1];
-      p04 = sp0[chan2]; p14 = sp1[chan2];
-      p05 = sp0[chan3]; p15 = sp1[chan3];
-
-      sp0 += chan4;
-      sp1 += chan4;
-
-#ifdef __SUNPRO_C
-#pragma pipeloop(0)
-#endif /* __SUNPRO_C */
-      for (i = 0; i <= (wid - 2); i += 2) {
-        p00 = p02; p10 = p12;
-        p01 = p03; p11 = p13;
-        p02 = p04; p12 = p14;
-        p03 = p05; p13 = p15;
-
-        p04 = sp0[0];     p14 = sp1[0];
-        p05 = sp0[chan1]; p15 = sp1[chan1];
-
-        buffd[i    ] = (p00 * k0 + p01 * k1 + p02 * k2 + p03 * k3 + p04 * k4 +
-                        p10 * k5 + p11 * k6 + p12 * k7 + p13 * k8 + p14 * k9);
-        buffd[i + 1] = (p01 * k0 + p02 * k1 + p03 * k2 + p04 * k3 + p05 * k4 +
-                        p11 * k5 + p12 * k6 + p13 * k7 + p14 * k8 + p15 * k9);
-
-        sp0 += chan2;
-        sp1 += chan2;
-        dp += chan2;
-      }
-
-      if (wid & 1) {
-        p00 = p02; p10 = p12;
-        p01 = p03; p11 = p13;
-        p02 = p04; p12 = p14;
-        p03 = p05; p13 = p15;
-
-        p04 = sp0[0];     p14 = sp1[0];
-
-        buffd[i] = (p00 * k0 + p01 * k1 + p02 * k2 + p03 * k3 + p04 * k4 +
-                    p10 * k5 + p11 * k6 + p12 * k7 + p13 * k8 + p14 * k9);
-      }
-
-      /*
-       *  Second loop
-       */
-      sp0 = sl + 2*sll;
-      sp1 = sp0 + sll;
-      dp = dl;
-
-      k0 = k[10]; k1 = k[11]; k2 = k[12]; k3 = k[13]; k4 = k[14];
-      k5 = k[15]; k6 = k[16]; k7 = k[17]; k8 = k[18]; k9 = k[19];
-
-      p02 = sp0[0];     p12 = sp1[0];
-      p03 = sp0[chan1]; p13 = sp1[chan1];
-      p04 = sp0[chan2]; p14 = sp1[chan2];
-      p05 = sp0[chan3]; p15 = sp1[chan3];
-
-      sp0 += chan4;
-      sp1 += chan4;
-
-#ifdef __SUNPRO_C
-#pragma pipeloop(0)
-#endif /* __SUNPRO_C */
-      for (i = 0; i <= (wid - 2); i += 2) {
-        p00 = p02; p10 = p12;
-        p01 = p03; p11 = p13;
-        p02 = p04; p12 = p14;
-        p03 = p05; p13 = p15;
-
-        p04 = sp0[0];     p14 = sp1[0];
-        p05 = sp0[chan1]; p15 = sp1[chan1];
-
-        buffd[i    ] += (p00 * k0 + p01 * k1 + p02 * k2 + p03 * k3 + p04 * k4 +
-                         p10 * k5 + p11 * k6 + p12 * k7 + p13 * k8 + p14 * k9);
-        buffd[i + 1] += (p01 * k0 + p02 * k1 + p03 * k2 + p04 * k3 + p05 * k4 +
-                         p11 * k5 + p12 * k6 + p13 * k7 + p14 * k8 + p15 * k9);
-
-        sp0 += chan2;
-        sp1 += chan2;
-        dp += chan2;
-      }
-
-      if (wid & 1) {
-        p00 = p02; p10 = p12;
-        p01 = p03; p11 = p13;
-        p02 = p04; p12 = p14;
-        p03 = p05; p13 = p15;
-
-        p04 = sp0[0];     p14 = sp1[0];
-
-        buffd[i] += (p00 * k0 + p01 * k1 + p02 * k2 + p03 * k3 + p04 * k4 +
-                     p10 * k5 + p11 * k6 + p12 * k7 + p13 * k8 + p14 * k9);
-      }
-
-      /*
-       *  3 loop
-       */
-      dp = dl;
-      sp0 = sl + 4*sll;
-
-      k0 = k[20]; k1 = k[21]; k2 = k[22]; k3 = k[23]; k4 = k[24];
-
-      p02 = sp0[0];
-      p03 = sp0[chan1];
-      p04 = sp0[chan2];
-      p05 = sp0[chan3];
-
-      sp0 += chan2 + chan2;
-
-#ifdef __SUNPRO_C
-#pragma pipeloop(0)
-#endif /* __SUNPRO_C */
-      for (i = 0; i <= (wid - 2); i += 2) {
-        p00 = p02; p01 = p03; p02 = p04; p03 = p05;
-
-        p04 = sp0[0]; p05 = sp0[chan1];
-
-        pix0 = (buffd[i    ] + p00 * k0 + p01 * k1 + p02 * k2 +
-                p03 * k3 + p04 * k4) >> shift2;
-        pix1 = (buffd[i + 1] + p01 * k0 + p02 * k1 + p03 * k2 +
-                p04 * k3 + p05 * k4) >> shift2;
-
-        CLAMP_STORE(dp[0],     pix0);
-        CLAMP_STORE(dp[chan1], pix1);
-
-        dp  += chan2;
-        sp0 += chan2;
-      }
-
-      if (wid & 1) {
-        p00 = p02; p01 = p03; p02 = p04; p03 = p05;
-
-        p04 = sp0[0];
-
-        pix0 = (buffd[i    ] + p00 * k0 + p01 * k1 + p02 * k2 +
-                p03 * k3 + p04 * k4) >> shift2;
-        CLAMP_STORE(dp[0],     pix0);
-      }
-
-      /* next line */
-      sl += sll;
-      dl += dll;
-    }
-  }
-
-  if (pbuff != buff) mlib_free(pbuff);
-
-  return MLIB_SUCCESS;
-}
-
-#endif /* __sparc ( for x86, using integer multiplies is faster ) */
-
-/***************************************************************/
-#if IMG_TYPE == 1
-
-#undef  KSIZE
-#define KSIZE 7
-
-mlib_status CONV_FUNC(7x7)(mlib_image       *dst,
-                           const mlib_image *src,
-                           const mlib_s32   *kern,
-                           mlib_s32         scalef_expon,
-                           mlib_s32         cmask)
-{
-  FTYPE    buff[(KSIZE + 3)*BUFF_LINE], *buffs[2*(KSIZE + 1)], *buffd;
-  FTYPE    k[KSIZE*KSIZE];
-  mlib_s32 l, m, buff_ind;
-  mlib_s32 d0, d1;
-  FTYPE    k0, k1, k2, k3, k4, k5, k6;
-  FTYPE    p0, p1, p2, p3, p4, p5, p6, p7;
-  DTYPE *sl2, *sl3, *sl4, *sl5, *sl6;
-  DEF_VARS(DTYPE);
-  DTYPE *sl1;
-  mlib_s32 chan2;
-  mlib_s32 *buffo, *buffi;
-  LOAD_KERNEL(KSIZE*KSIZE);
-  GET_SRC_DST_PARAMETERS(DTYPE);
-
-  if (wid > BUFF_LINE) {
-    pbuff = mlib_malloc((KSIZE + 3)*sizeof(FTYPE)*wid);
-
-    if (pbuff == NULL) return MLIB_FAILURE;
-  }
-
-  for (l = 0; l < KSIZE + 1; l++) buffs[l] = pbuff + l*wid;
-  for (l = 0; l < KSIZE + 1; l++) buffs[l + (KSIZE + 1)] = buffs[l];
-  buffd = buffs[KSIZE] + wid;
-  buffo = (mlib_s32*)(buffd + wid);
-  buffi = buffo + (wid &~ 1);
-
-  chan1 = nchannel;
-  chan2 = chan1 + chan1;
-
-  wid -= (KSIZE - 1);
-  hgt -= (KSIZE - 1);
-
-  adr_dst += ((KSIZE - 1)/2)*(dll + chan1);
-
-  for (c = 0; c < nchannel; c++) {
-    if (!(cmask & (1 << (nchannel - 1 - c)))) continue;
-
-    sl = adr_src + c;
-    dl = adr_dst + c;
-
-    sl1 = sl  + sll;
-    sl2 = sl1 + sll;
-    sl3 = sl2 + sll;
-    sl4 = sl3 + sll;
-    sl5 = sl4 + sll;
-    sl6 = sl5 + sll;
-#ifdef __SUNPRO_C
-#pragma pipeloop(0)
-#endif /* __SUNPRO_C */
-    for (i = 0; i < wid + (KSIZE - 1); i++) {
-      buffs[0][i] = (FTYPE)sl[i*chan1];
-      buffs[1][i] = (FTYPE)sl1[i*chan1];
-      buffs[2][i] = (FTYPE)sl2[i*chan1];
-      buffs[3][i] = (FTYPE)sl3[i*chan1];
-      buffs[4][i] = (FTYPE)sl4[i*chan1];
-      buffs[5][i] = (FTYPE)sl5[i*chan1];
-      buffs[6][i] = (FTYPE)sl6[i*chan1];
-    }
-
-    buff_ind = 0;
-
-#ifdef __SUNPRO_C
-#pragma pipeloop(0)
-#endif /* __SUNPRO_C */
-    for (i = 0; i < wid; i++) buffd[i] = 0.0;
-
-    sl += KSIZE*sll;
-
-    for (j = 0; j < hgt; j++) {
-      FTYPE    **buffc = buffs + buff_ind;
-      FTYPE    *buffn = buffc[KSIZE];
-      FTYPE    *pk = k;
-
-      for (l = 0; l < KSIZE; l++) {
-        FTYPE    *buff = buffc[l];
-        d64_2x32 dd;
-
-        sp = sl;
-        dp = dl;
-
-        p2 = buff[0]; p3 = buff[1]; p4 = buff[2];
-        p5 = buff[3]; p6 = buff[4]; p7 = buff[5];
-
-        k0 = *pk++; k1 = *pk++; k2 = *pk++; k3 = *pk++;
-        k4 = *pk++; k5 = *pk++; k6 = *pk++;
-
-        if (l < (KSIZE - 1)) {
-#ifdef __SUNPRO_C
-#pragma pipeloop(0)
-#endif /* __SUNPRO_C */
-          for (i = 0; i <= (wid - 2); i += 2) {
-            p0 = p2; p1 = p3; p2 = p4; p3 = p5; p4 = p6; p5 = p7;
-
-            p6 = buff[i + 6]; p7 = buff[i + 7];
-
-            buffd[i    ] += p0*k0 + p1*k1 + p2*k2 + p3*k3 + p4*k4 + p5*k5 + p6*k6;
-            buffd[i + 1] += p1*k0 + p2*k1 + p3*k2 + p4*k3 + p5*k4 + p6*k5 + p7*k6;
-          }
-
-        } else {
-#ifdef __SUNPRO_C
-#pragma pipeloop(0)
-#endif /* __SUNPRO_C */
-          for (i = 0; i <= (wid - 2); i += 2) {
-            p0 = p2; p1 = p3; p2 = p4; p3 = p5; p4 = p6; p5 = p7;
-
-            p6 = buff[i + 6]; p7 = buff[i + 7];
-
-            LOAD_BUFF(buffi);
-
-            dd.d64 = *(FTYPE   *)(buffi + i);
-            buffn[i    ] = (FTYPE)dd.i32s.i0;
-            buffn[i + 1] = (FTYPE)dd.i32s.i1;
-
-            d0 = D2I(p0*k0 + p1*k1 + p2*k2 + p3*k3 + p4*k4 + p5*k5 + p6*k6 + buffd[i    ]);
-            d1 = D2I(p1*k0 + p2*k1 + p3*k2 + p4*k3 + p5*k4 + p6*k5 + p7*k6 + buffd[i + 1]);
-
-            dp[0    ] = FROM_S32(d0);
-            dp[chan1] = FROM_S32(d1);
-
-            buffd[i    ] = 0.0;
-            buffd[i + 1] = 0.0;
-
-            sp += chan2;
-            dp += chan2;
-          }
-        }
-      }
-
-      /* last pixels */
-      for (; i < wid; i++) {
-        FTYPE    *pk = k, s = 0;
-        mlib_s32 d0;
-
-        for (l = 0; l < KSIZE; l++) {
-          FTYPE    *buff = buffc[l] + i;
-
-          for (m = 0; m < KSIZE; m++) s += buff[m] * (*pk++);
-        }
-
-        d0 = D2I(s);
-        dp[0] = FROM_S32(d0);
-
-        buffn[i] = (FTYPE)sp[0];
-
-        sp += chan1;
-        dp += chan1;
-      }
-
-      for (l = 0; l < (KSIZE - 1); l++) buffn[wid + l] = sp[l*chan1];
-
-      /* next line */
-      sl += sll;
-      dl += dll;
-
-      buff_ind++;
-
-      if (buff_ind >= KSIZE + 1) buff_ind = 0;
-    }
-  }
-
-  if (pbuff != buff) mlib_free(pbuff);
-
-  return MLIB_SUCCESS;
-}
-
-#endif /* IMG_TYPE == 1 */
-
-/***************************************************************/
 #define MAX_KER   7
 #define MAX_N    15
 
--- a/jdk/src/java.desktop/share/native/libmlib_image/mlib_c_ImageAffineIndex_BC.c	Thu May 19 17:48:02 2016 +0000
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,413 +0,0 @@
-/*
- * Copyright (c) 1998, 2003, 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.
- */
-
-
-#include "mlib_image.h"
-#include "mlib_ImageAffine.h"
-#include "mlib_ImageColormap.h"
-
-/***************************************************************/
-#define MLIB_LIMIT  512
-#define MLIB_SHIFT   16
-#define MLIB_PREC    (1 << MLIB_SHIFT)
-#define MLIB_MASK    (MLIB_PREC - 1)
-
-/***************************************************************/
-#define DTYPE  MLIB_TYPE
-
-/***************************************************************/
-#define DECLAREVAR_IND()                                        \
-  DECLAREVAR0();                                                \
-  mlib_s32  *warp_tbl   = param -> warp_tbl;                    \
-  mlib_s32  xSrc, ySrc;                                         \
-  mlib_s32  srcYStride = param -> srcYStride;                   \
-  mlib_s32  max_xsize  = param -> max_xsize;                    \
-  mlib_filter filter = param -> filter;                         \
-  MLIB_TYPE *sp, *dl;                                           \
-  mlib_d64  xf0, xf1, xf2, xf3;                                 \
-  mlib_d64  yf0, yf1, yf2, yf3;                                 \
-  mlib_d64  c0, c1, c2, c3, val0;                               \
-  mlib_s32  filterpos;                                          \
-  mlib_f32  *fptr;                                              \
-  mlib_d64  s0, s1, s2, s3;                                     \
-  mlib_s32  i, size
-
-/***************************************************************/
-#define GET_FILTERS_KOEF()                                         \
-  filterpos = (X >> FILTER_SHIFT) & FILTER_MASK;                   \
-  fptr = (mlib_f32 *) ((mlib_u8 *)mlib_filters_table + filterpos); \
-                                                                   \
-  xf0 = fptr[0];                                                   \
-  xf1 = fptr[1];                                                   \
-  xf2 = fptr[2];                                                   \
-  xf3 = fptr[3];                                                   \
-                                                                   \
-  filterpos = (Y >> FILTER_SHIFT) & FILTER_MASK;                   \
-  fptr = (mlib_f32 *) ((mlib_u8 *)mlib_filters_table + filterpos); \
-                                                                   \
-  yf0 = fptr[0];                                                   \
-  yf1 = fptr[1];                                                   \
-  yf2 = fptr[2];                                                   \
-  yf3 = fptr[3]
-
-/***************************************************************/
-#define GET_POINTER()                                           \
-  xSrc = (X >> MLIB_SHIFT)-1;                                   \
-  ySrc = (Y >> MLIB_SHIFT)-1;                                   \
-  sp = ((MLIB_TYPE **)lineAddr)[ySrc] + xSrc
-
-/***************************************************************/
-#define LOAD_FIRST_ROW(nchan, chan)                             \
-  s0 = *(lut + sp[0]*nchan + chan);                             \
-  s1 = *(lut + sp[1]*nchan + chan);                             \
-  s2 = *(lut + sp[2]*nchan + chan);                             \
-  s3 = *(lut + sp[3]*nchan + chan)
-
-/***************************************************************/
-#define COUNT_NEXT_ROW(dst, nchan, chan)                        \
-  sp = (MLIB_TYPE*)((mlib_addr)sp + srcYStride);                \
-  dst = ((*(lut + sp[0]*nchan + chan))*xf0 +                    \
-         (*(lut + sp[1]*nchan + chan))*xf1 +                    \
-         (*(lut + sp[2]*nchan + chan))*xf2 +                    \
-         (*(lut + sp[3]*nchan + chan))*xf3)
-
-/***************************************************************/
-#ifdef MLIB_USE_FTOI_CLAMPING
-
-/***********/
-#define STORE_SAT_VALUE_U8(ind)                                 \
-  dp[ind] = ((mlib_s32)(val0 - (mlib_d64)0x7F800000) >> 24) ^ 0x80
-
-/***********/
-#define STORE_SAT_VALUE_S16(ind)                                \
-  dp[ind] = ((mlib_s32)(val0)) >> 16
-
-#else
-
-/***********/
-#define STORE_SAT_VALUE_U8(ind)                                 \
-  val0 -= (mlib_d64)0x7F800000;                                 \
-  if (val0 >= MLIB_S32_MAX)                                     \
-    dp[ind] = MLIB_U8_MAX;                                      \
-  else if (val0 <= MLIB_S32_MIN)                                \
-    dp[ind] = MLIB_U8_MIN;                                      \
-  else                                                          \
-    dp[ind] = ((mlib_s32)val0 >> 24) ^ 0x80
-
-/***********/
-#define STORE_SAT_VALUE_S16(ind)                                \
-  if (val0 >= MLIB_S32_MAX)                                     \
-    dp[ind] = MLIB_S16_MAX;                                     \
-  else if (val0 <= MLIB_S32_MIN)                                \
-    dp[ind] = MLIB_S16_MIN;                                     \
-  else                                                          \
-    dp[ind] = (mlib_s32)val0 >> 16
-
-#endif /* MLIB_USE_FTOI_CLAMPING */
-
-/***************************************************************/
-#define MAKE_BC_3CH(lut_format)                                 \
-  X += dX;                                                      \
-  Y += dY;                                                      \
-  c0 = (s0*xf0 + s1*xf1 + s2*xf2 + s3*xf3);                     \
-  COUNT_NEXT_ROW(c1, 3, 0);                                     \
-  COUNT_NEXT_ROW(c2, 3, 0);                                     \
-  COUNT_NEXT_ROW(c3, 3, 0);                                     \
-  val0 = (c0*yf0 + c1*yf1 + c2*yf2 + c3*yf3);                   \
-  sp = (MLIB_TYPE*)((mlib_addr)sp - 3*srcYStride);              \
-  LOAD_FIRST_ROW(3, 1);                                         \
-  STORE_SAT_VALUE_##lut_format(0);                              \
-  c0 = (s0*xf0 + s1*xf1 + s2*xf2 + s3*xf3);                     \
-  COUNT_NEXT_ROW(c1, 3, 1);                                     \
-  COUNT_NEXT_ROW(c2, 3, 1);                                     \
-  COUNT_NEXT_ROW(c3, 3, 1);                                     \
-  val0 = (c0*yf0 + c1*yf1 + c2*yf2 + c3*yf3);                   \
-  sp = (MLIB_TYPE*)((mlib_addr)sp - 3*srcYStride);              \
-  LOAD_FIRST_ROW(3, 2);                                         \
-  STORE_SAT_VALUE_##lut_format(1);                              \
-  c0 = (s0*xf0 + s1*xf1 + s2*xf2 + s3*xf3);                     \
-  COUNT_NEXT_ROW(c1, 3, 2);                                     \
-  COUNT_NEXT_ROW(c2, 3, 2);                                     \
-  COUNT_NEXT_ROW(c3, 3, 2);                                     \
-  val0 = (c0*yf0 + c1*yf1 + c2*yf2 + c3*yf3);                   \
-  GET_FILTERS_KOEF();                                           \
-  GET_POINTER();                                                \
-  LOAD_FIRST_ROW(3, 0);                                         \
-  STORE_SAT_VALUE_##lut_format(2);
-
-/***************************************************************/
-#define MAKE_LAST_PIXEL_BC_3CH(lut_format)                      \
-  c0 = (s0*xf0 + s1*xf1 + s2*xf2 + s3*xf3);                     \
-  COUNT_NEXT_ROW(c1, 3, 0);                                     \
-  COUNT_NEXT_ROW(c2, 3, 0);                                     \
-  COUNT_NEXT_ROW(c3, 3, 0);                                     \
-  val0 = (c0*yf0 + c1*yf1 + c2*yf2 + c3*yf3);                   \
-  sp = (MLIB_TYPE*)((mlib_addr)sp - 3*srcYStride);              \
-  LOAD_FIRST_ROW(3, 1);                                         \
-  STORE_SAT_VALUE_##lut_format(0);                              \
-  c0 = (s0*xf0 + s1*xf1 + s2*xf2 + s3*xf3);                     \
-  COUNT_NEXT_ROW(c1, 3, 1);                                     \
-  COUNT_NEXT_ROW(c2, 3, 1);                                     \
-  COUNT_NEXT_ROW(c3, 3, 1);                                     \
-  val0 = (c0*yf0 + c1*yf1 + c2*yf2 + c3*yf3);                   \
-  sp = (MLIB_TYPE*)((mlib_addr)sp - 3*srcYStride);              \
-  LOAD_FIRST_ROW(3, 2);                                         \
-  STORE_SAT_VALUE_##lut_format(1);                              \
-  c0 = (s0*xf0 + s1*xf1 + s2*xf2 + s3*xf3);                     \
-  COUNT_NEXT_ROW(c1, 3, 2);                                     \
-  COUNT_NEXT_ROW(c2, 3, 2);                                     \
-  COUNT_NEXT_ROW(c3, 3, 2);                                     \
-  val0 = (c0*yf0 + c1*yf1 + c2*yf2 + c3*yf3);                   \
-  STORE_SAT_VALUE_##lut_format(2);
-
-/***************************************************************/
-#define MAKE_BC_4CH(lut_format)                                 \
-  X += dX;                                                      \
-  Y += dY;                                                      \
-  c0 = (s0*xf0 + s1*xf1 + s2*xf2 + s3*xf3);                     \
-  COUNT_NEXT_ROW(c1, 4, 0);                                     \
-  COUNT_NEXT_ROW(c2, 4, 0);                                     \
-  COUNT_NEXT_ROW(c3, 4, 0);                                     \
-  val0 = (c0*yf0 + c1*yf1 + c2*yf2 + c3*yf3);                   \
-  sp = (MLIB_TYPE*)((mlib_addr)sp - 3*srcYStride);              \
-  LOAD_FIRST_ROW(4, 1);                                         \
-  STORE_SAT_VALUE_##lut_format(0);                              \
-  c0 = (s0*xf0 + s1*xf1 + s2*xf2 + s3*xf3);                     \
-  COUNT_NEXT_ROW(c1, 4, 1);                                     \
-  COUNT_NEXT_ROW(c2, 4, 1);                                     \
-  COUNT_NEXT_ROW(c3, 4, 1);                                     \
-  val0 = (c0*yf0 + c1*yf1 + c2*yf2 + c3*yf3);                   \
-  sp = (MLIB_TYPE*)((mlib_addr)sp - 3*srcYStride);              \
-  LOAD_FIRST_ROW(4, 2);                                         \
-  STORE_SAT_VALUE_##lut_format(1);                              \
-  c0 = (s0*xf0 + s1*xf1 + s2*xf2 + s3*xf3);                     \
-  COUNT_NEXT_ROW(c1, 4, 2);                                     \
-  COUNT_NEXT_ROW(c2, 4, 2);                                     \
-  COUNT_NEXT_ROW(c3, 4, 2);                                     \
-  val0 = (c0*yf0 + c1*yf1 + c2*yf2 + c3*yf3);                   \
-  sp = (MLIB_TYPE*)((mlib_addr)sp - 3*srcYStride);              \
-  LOAD_FIRST_ROW(4, 3);                                         \
-  STORE_SAT_VALUE_##lut_format(2);                              \
-  c0 = (s0*xf0 + s1*xf1 + s2*xf2 + s3*xf3);                     \
-  COUNT_NEXT_ROW(c1, 4, 3);                                     \
-  COUNT_NEXT_ROW(c2, 4, 3);                                     \
-  COUNT_NEXT_ROW(c3, 4, 3);                                     \
-  val0 = (c0*yf0 + c1*yf1 + c2*yf2 + c3*yf3);                   \
-  GET_FILTERS_KOEF();                                           \
-  GET_POINTER();                                                \
-  LOAD_FIRST_ROW(4, 0);                                         \
-  STORE_SAT_VALUE_##lut_format(3);
-
-/***************************************************************/
-#define MAKE_LAST_PIXEL_BC_4CH(lut_format)                      \
-  c0 = (s0*xf0 + s1*xf1 + s2*xf2 + s3*xf3);                     \
-  COUNT_NEXT_ROW(c1, 4, 0);                                     \
-  COUNT_NEXT_ROW(c2, 4, 0);                                     \
-  COUNT_NEXT_ROW(c3, 4, 0);                                     \
-  val0 = (c0*yf0 + c1*yf1 + c2*yf2 + c3*yf3);                   \
-  sp = (MLIB_TYPE*)((mlib_addr)sp - 3*srcYStride);              \
-  LOAD_FIRST_ROW(4, 1);                                         \
-  STORE_SAT_VALUE_##lut_format(0);                              \
-  c0 = (s0*xf0 + s1*xf1 + s2*xf2 + s3*xf3);                     \
-  COUNT_NEXT_ROW(c1, 4, 1);                                     \
-  COUNT_NEXT_ROW(c2, 4, 1);                                     \
-  COUNT_NEXT_ROW(c3, 4, 1);                                     \
-  val0 = (c0*yf0 + c1*yf1 + c2*yf2 + c3*yf3);                   \
-  sp = (MLIB_TYPE*)((mlib_addr)sp - 3*srcYStride);              \
-  LOAD_FIRST_ROW(4, 2);                                         \
-  STORE_SAT_VALUE_##lut_format(1);                              \
-  c0 = (s0*xf0 + s1*xf1 + s2*xf2 + s3*xf3);                     \
-  COUNT_NEXT_ROW(c1, 4, 2);                                     \
-  COUNT_NEXT_ROW(c2, 4, 2);                                     \
-  COUNT_NEXT_ROW(c3, 4, 2);                                     \
-  val0 = (c0*yf0 + c1*yf1 + c2*yf2 + c3*yf3);                   \
-  sp = (MLIB_TYPE*)((mlib_addr)sp - 3*srcYStride);              \
-  LOAD_FIRST_ROW(4, 3);                                         \
-  STORE_SAT_VALUE_##lut_format(2);                              \
-  c0 = (s0*xf0 + s1*xf1 + s2*xf2 + s3*xf3);                     \
-  COUNT_NEXT_ROW(c1, 4, 3);                                     \
-  COUNT_NEXT_ROW(c2, 4, 3);                                     \
-  COUNT_NEXT_ROW(c3, 4, 3);                                     \
-  val0 = (c0*yf0 + c1*yf1 + c2*yf2 + c3*yf3);                   \
-  STORE_SAT_VALUE_##lut_format(3);
-
-/***************************************************************/
-#define FILTER_U8  ((filter == MLIB_BICUBIC) ? mlib_filters_u8f_bc  : mlib_filters_u8f_bc2)
-#define FILTER_S16 ((filter == MLIB_BICUBIC) ? mlib_filters_s16f_bc : mlib_filters_s16f_bc2)
-
-/***************************************************************/
-#define mlib_U8  mlib_u8
-#define mlib_S16 mlib_s16
-
-/***************************************************************/
-#define FUNC_AFFINEINDEX_BC_0(ITYPE, LTYPE, NCHAN)                                                  \
-  mlib_status mlib_ImageAffineIndex_##ITYPE##_##LTYPE##_##NCHAN##CH_BC(mlib_affine_param *param,    \
-                                                                       const void        *colormap) \
-  {                                                                                                 \
-    DECLAREVAR_IND();                                                                               \
-    mlib_##LTYPE buff_lcl[NCHAN * MLIB_LIMIT], *pbuff = buff_lcl, *dp;                              \
-    mlib_d64  *lut = ((mlib_d64*)mlib_ImageGetLutDoubleData(colormap) -                             \
-                      NCHAN * mlib_ImageGetLutOffset(colormap));                                    \
-    const mlib_f32 *mlib_filters_table = FILTER_##LTYPE;                                            \
-                                                                                                    \
-    if (max_xsize > MLIB_LIMIT) {                                                                   \
-      pbuff = mlib_malloc(NCHAN * sizeof(mlib_##LTYPE) * max_xsize);                                \
-      if (pbuff == NULL) return MLIB_FAILURE;                                                       \
-    }                                                                                               \
-                                                                                                    \
-    for (j = yStart; j <= yFinish; j++) {                                                           \
-                                                                                                    \
-      NEW_LINE(1);                                                                                  \
-      dp = pbuff;                                                                                   \
-                                                                                                    \
-      GET_FILTERS_KOEF();                                                                           \
-      GET_POINTER();                                                                                \
-      LOAD_FIRST_ROW(NCHAN, 0);
-
-    /* pragma pipeloop(0) must be here */
-
-/***************************************************************/
-#define FUNC_AFFINEINDEX_BC_1(ITYPE, LTYPE, NCHAN)                         \
-                                                                           \
-      for (i = 0; i < (xRight - xLeft); i++, dp += NCHAN) {                \
-        MAKE_BC_##NCHAN##CH(LTYPE);                                        \
-      }                                                                    \
-                                                                           \
-      MAKE_LAST_PIXEL_BC_##NCHAN##CH(LTYPE);                               \
-                                                                           \
-      mlib_ImageColorTrue2IndexLine_##LTYPE##_##ITYPE##_##NCHAN            \
-                                (pbuff, dl, xRight - xLeft + 1, colormap); \
-    }                                                                      \
-                                                                           \
-    if (pbuff != buff_lcl) mlib_free(pbuff);                               \
-                                                                           \
-    return MLIB_SUCCESS;                                                   \
-  }
-
-/***************************************************************/
-#undef MLIB_TYPE
-#define MLIB_TYPE mlib_u8
-
-/***************************************************************/
-#undef  FILTER_SHIFT
-#define FILTER_SHIFT 4
-#undef  FILTER_MASK
-#define FILTER_MASK  (((1 << 8) - 1) << 4)
-
-FUNC_AFFINEINDEX_BC_0(U8, U8, 3)
-#ifdef __SUNPRO_C
-#pragma pipeloop(0)
-#endif /* __SUNPRO_C */
-FUNC_AFFINEINDEX_BC_1(U8, U8, 3)
-
-/***************************************************************/
-#undef  FILTER_SHIFT
-#define FILTER_SHIFT 3
-#undef  FILTER_MASK
-#define FILTER_MASK  (((1 << 9) - 1) << 4)
-
-FUNC_AFFINEINDEX_BC_0(U8, S16, 3)
-#ifdef __SUNPRO_C
-#pragma pipeloop(0)
-#endif /* __SUNPRO_C */
-FUNC_AFFINEINDEX_BC_1(U8, S16, 3)
-
-/***************************************************************/
-#undef  FILTER_SHIFT
-#define FILTER_SHIFT 4
-#undef  FILTER_MASK
-#define FILTER_MASK  (((1 << 8) - 1) << 4)
-
-FUNC_AFFINEINDEX_BC_0(U8, U8, 4)
-#ifdef __SUNPRO_C
-#pragma pipeloop(0)
-#endif /* __SUNPRO_C */
-FUNC_AFFINEINDEX_BC_1(U8, U8, 4)
-
-/***************************************************************/
-#undef  FILTER_SHIFT
-#define FILTER_SHIFT 3
-#undef  FILTER_MASK
-#define FILTER_MASK  (((1 << 9) - 1) << 4)
-
-FUNC_AFFINEINDEX_BC_0(U8, S16, 4)
-#ifdef __SUNPRO_C
-#pragma pipeloop(0)
-#endif /* __SUNPRO_C */
-FUNC_AFFINEINDEX_BC_1(U8, S16, 4)
-
-/***************************************************************/
-#undef  MLIB_TYPE
-#define MLIB_TYPE mlib_s16
-
-/***************************************************************/
-#undef  FILTER_SHIFT
-#define FILTER_SHIFT 4
-#undef  FILTER_MASK
-#define FILTER_MASK  (((1 << 8) - 1) << 4)
-
-FUNC_AFFINEINDEX_BC_0(S16, U8, 3)
-#ifdef __SUNPRO_C
-#pragma pipeloop(0)
-#endif /* __SUNPRO_C */
-FUNC_AFFINEINDEX_BC_1(S16, U8, 3)
-
-/***************************************************************/
-#undef  FILTER_SHIFT
-#define FILTER_SHIFT 3
-#undef  FILTER_MASK
-#define FILTER_MASK  (((1 << 9) - 1) << 4)
-
-FUNC_AFFINEINDEX_BC_0(S16, S16, 3)
-#ifdef __SUNPRO_C
-#pragma pipeloop(0)
-#endif /* __SUNPRO_C */
-FUNC_AFFINEINDEX_BC_1(S16, S16, 3)
-
-/***************************************************************/
-#undef  FILTER_SHIFT
-#define FILTER_SHIFT 4
-#undef  FILTER_MASK
-#define FILTER_MASK  (((1 << 8) - 1) << 4)
-
-FUNC_AFFINEINDEX_BC_0(S16, U8, 4)
-#ifdef __SUNPRO_C
-#pragma pipeloop(0)
-#endif /* __SUNPRO_C */
-FUNC_AFFINEINDEX_BC_1(S16, U8, 4)
-
-/***************************************************************/
-#undef  FILTER_SHIFT
-#define FILTER_SHIFT 3
-#undef  FILTER_MASK
-#define FILTER_MASK  (((1 << 9) - 1) << 4)
-
-FUNC_AFFINEINDEX_BC_0(S16, S16, 4)
-#ifdef __SUNPRO_C
-#pragma pipeloop(0)
-#endif /* __SUNPRO_C */
-FUNC_AFFINEINDEX_BC_1(S16, S16, 4)
-
-/***************************************************************/
--- a/jdk/src/java.desktop/share/native/libmlib_image/mlib_c_ImageAffineIndex_BL.c	Thu May 19 17:48:02 2016 +0000
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,280 +0,0 @@
-/*
- * Copyright (c) 1998, 2003, 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.
- */
-
-
-#include "mlib_image.h"
-#include "mlib_ImageAffine.h"
-#include "mlib_ImageColormap.h"
-
-/***************************************************************/
-#define MLIB_LIMIT  512
-
-/***************************************************************/
-#define DTYPE  MLIB_TYPE
-
-/***************************************************************/
-#define DECLAREVAR_IND()                                        \
-  DECLAREVAR0();                                                \
-  mlib_s32  *warp_tbl   = param -> warp_tbl;                    \
-  mlib_s32  xSrc, ySrc;                                         \
-  mlib_s32  srcYStride = param -> srcYStride;                   \
-  mlib_s32  max_xsize  = param -> max_xsize;                    \
-  MLIB_TYPE *sp0, *sp1;                                         \
-  MLIB_TYPE *dl;                                                \
-  mlib_d64  scale = 1.0 / 65536.0;                              \
-  mlib_s32  i, size
-
-/***************************************************************/
-#define DECLARE_INTERNAL_VAR_3CH()                              \
-  mlib_d64  fdx, fdy;                                           \
-  mlib_d64  a00_0, a01_0, a10_0, a11_0;                         \
-  mlib_d64  a00_1, a01_1, a10_1, a11_1;                         \
-  mlib_d64  a00_2, a01_2, a10_2, a11_2;                         \
-  mlib_d64  pix0_0, pix1_0, res0;                               \
-  mlib_d64  pix0_1, pix1_1, res1;                               \
-  mlib_d64  pix0_2, pix1_2, res2
-
-/***************************************************************/
-#define DECLARE_INTERNAL_VAR_4CH()                              \
-  mlib_d64  fdx, fdy;                                           \
-  mlib_d64  a00_0, a01_0, a10_0, a11_0;                         \
-  mlib_d64  a00_1, a01_1, a10_1, a11_1;                         \
-  mlib_d64  a00_2, a01_2, a10_2, a11_2;                         \
-  mlib_d64  a00_3, a01_3, a10_3, a11_3;                         \
-  mlib_d64  pix0_0, pix1_0, res0;                               \
-  mlib_d64  pix0_1, pix1_1, res1;                               \
-  mlib_d64  pix0_2, pix1_2, res2;                               \
-  mlib_d64  pix0_3, pix1_3, res3
-
-/***************************************************************/
-#define GET_PIXELS_POINTERS()                                   \
-  fdx = (X & MLIB_MASK) * scale;                                \
-  fdy = (Y & MLIB_MASK) * scale;                                \
-  ySrc = MLIB_POINTER_SHIFT(Y);  Y += dY;                       \
-  xSrc = X >> MLIB_SHIFT;  X += dX;                             \
-  sp0 = MLIB_POINTER_GET(lineAddr, ySrc) + xSrc;                \
-  sp1 = (MLIB_TYPE *)((mlib_u8 *)sp0 + srcYStride)
-
-/***************************************************************/
-#define GET_COLOR_POINTERS(ind)                                 \
-  pcolor00 = (lut + sp0[0]*ind);                                \
-  pcolor10 = (lut + sp1[0]*ind);                                \
-  pcolor01 = (lut + sp0[1]*ind);                                \
-  pcolor11 = (lut + sp1[1]*ind)
-
-/***************************************************************/
-#define COUNT_BL_U8(ind)                                        \
-  pix0_##ind = a00_##ind + fdy * (a10_##ind - a00_##ind);       \
-  pix1_##ind = a01_##ind + fdy * (a11_##ind - a01_##ind);       \
-  res##ind = pix0_##ind + fdx * (pix1_##ind - pix0_##ind) + 0.5
-
-/***************************************************************/
-#define COUNT_BL_U8_3CH()                                       \
-  COUNT_BL_U8(0);                                               \
-  COUNT_BL_U8(1);                                               \
-  COUNT_BL_U8(2);
-
-/***************************************************************/
-#define COUNT_BL_U8_4CH()                                       \
-  COUNT_BL_U8_3CH();                                            \
-  COUNT_BL_U8(3);
-
-/***************************************************************/
-#define COUNT_BL_S16(ind)                                       \
-  pix0_##ind = a00_##ind + fdy * (a10_##ind - a00_##ind);       \
-  pix1_##ind = a01_##ind + fdy * (a11_##ind - a01_##ind);       \
-  res##ind = pix0_##ind + fdx * (pix1_##ind - pix0_##ind)
-
-/***************************************************************/
-#define COUNT_BL_S16_3CH()                                      \
-  COUNT_BL_S16(0);                                              \
-  COUNT_BL_S16(1);                                              \
-  COUNT_BL_S16(2);
-
-/***************************************************************/
-#define COUNT_BL_S16_4CH()                                      \
-  COUNT_BL_S16_3CH();                                           \
-  COUNT_BL_S16(3);
-
-/***************************************************************/
-#define LOAD(ind)                                               \
-  a00_##ind = pcolor00[ind];                                    \
-  a01_##ind = pcolor01[ind];                                    \
-  a10_##ind = pcolor10[ind];                                    \
-  a11_##ind = pcolor11[ind]
-
-/***************************************************************/
-#define LOAD_3CH()                                              \
-  LOAD(0);                                                      \
-  LOAD(1);                                                      \
-  LOAD(2);
-
-/***************************************************************/
-#define LOAD_4CH()                                              \
-  LOAD_3CH();                                                   \
-  LOAD(3);
-
-/***************************************************************/
-#define STORE_INTO_INTERM_BUF_3CH(LTYPE)                        \
-  dp[0] = (mlib_##LTYPE)res0;                                   \
-  dp[1] = (mlib_##LTYPE)res1;                                   \
-  dp[2] = (mlib_##LTYPE)res2
-
-/***************************************************************/
-#define STORE_INTO_INTERM_BUF_4CH(LTYPE)                        \
-  dp[0] = (mlib_##LTYPE)res0;                                   \
-  dp[1] = (mlib_##LTYPE)res1;                                   \
-  dp[2] = (mlib_##LTYPE)res2;                                   \
-  dp[3] = (mlib_##LTYPE)res3
-
-/***************************************************************/
-#undef  MLIB_TYPE
-#define MLIB_TYPE mlib_u8
-
-/***************************************************************/
-#define mlib_U8  mlib_u8
-#define mlib_S16 mlib_s16
-
-/***************************************************************/
-#define FUNC_AFFINEINDEX_BL_0(ITYPE, LTYPE, NCHAN)                                               \
-  mlib_status mlib_ImageAffineIndex_##ITYPE##_##LTYPE##_##NCHAN##CH_BL(mlib_affine_param *param, \
-                                                                       const void        *colormap) \
-  {                                                                                              \
-    DECLAREVAR_IND();                                                                            \
-    mlib_##LTYPE  *dp, buff_lcl[NCHAN*MLIB_LIMIT], *pbuff = buff_lcl;                            \
-    mlib_d64 *pcolor00, *pcolor10, *pcolor01, *pcolor11;                                         \
-    mlib_d64 *lut = mlib_ImageGetLutDoubleData(colormap);                                        \
-                                                                                                 \
-    lut -= NCHAN*mlib_ImageGetLutOffset(colormap);                                               \
-                                                                                                 \
-    if (max_xsize > MLIB_LIMIT) {                                                                \
-      pbuff = mlib_malloc(NCHAN * sizeof(mlib_##LTYPE) * max_xsize);                             \
-      if (pbuff == NULL) return MLIB_FAILURE;                                                    \
-    }                                                                                            \
-                                                                                                 \
-    for (j = yStart; j <= yFinish; j++) {                                                        \
-      DECLARE_INTERNAL_VAR_##NCHAN##CH();                                                        \
-                                                                                                 \
-      NEW_LINE(1);                                                                               \
-      dp = pbuff;                                                                                \
-                                                                                                 \
-      GET_PIXELS_POINTERS();                                                                     \
-      GET_COLOR_POINTERS(NCHAN);                                                                 \
-      LOAD_##NCHAN##CH();
-
-    /* pragma pipeloop(0) must be here */
-
-/***************************************************************/
-#define FUNC_AFFINEINDEX_BL_1(ITYPE, LTYPE, NCHAN)                   \
-      for (i = 0; i < (xRight - xLeft); i++, dp += NCHAN) {          \
-        COUNT_BL_##LTYPE##_##NCHAN##CH();                            \
-                                                                     \
-        GET_PIXELS_POINTERS();                                       \
-        GET_COLOR_POINTERS(NCHAN);                                   \
-        LOAD_##NCHAN##CH();                                          \
-                                                                     \
-        STORE_INTO_INTERM_BUF_##NCHAN##CH(LTYPE);                    \
-      }                                                              \
-                                                                     \
-      COUNT_BL_##LTYPE##_##NCHAN##CH();                              \
-      STORE_INTO_INTERM_BUF_##NCHAN##CH(LTYPE);                      \
-                                                                     \
-      mlib_ImageColorTrue2IndexLine_##LTYPE##_##ITYPE##_##NCHAN      \
-                          (pbuff, dl, xRight - xLeft + 1, colormap); \
-    }                                                                \
-                                                                     \
-    if (pbuff != buff_lcl) mlib_free(pbuff);                         \
-                                                                     \
-    return MLIB_SUCCESS;                                             \
-  }
-
-/***************************************************************/
-#undef  MLIB_TYPE
-#define MLIB_TYPE mlib_u8
-
-FUNC_AFFINEINDEX_BL_0(U8, U8, 3)
-#ifdef __SUNPRO_C
-#pragma pipeloop(0)
-#endif /* __SUNPRO_C */
-FUNC_AFFINEINDEX_BL_1(U8, U8, 3)
-
-FUNC_AFFINEINDEX_BL_0(U8, S16, 3)
-#ifdef __SUNPRO_C
-#pragma pipeloop(0)
-#endif /* __SUNPRO_C */
-FUNC_AFFINEINDEX_BL_1(U8, S16, 3)
-
-FUNC_AFFINEINDEX_BL_0(U8, U8, 4)
-#ifdef __SUNPRO_C
-#pragma pipeloop(0)
-#endif /* __SUNPRO_C */
-FUNC_AFFINEINDEX_BL_1(U8, U8, 4)
-
-FUNC_AFFINEINDEX_BL_0(U8, S16, 4)
-#ifdef __SUNPRO_C
-#pragma pipeloop(0)
-#endif /* __SUNPRO_C */
-FUNC_AFFINEINDEX_BL_1(U8, S16, 4)
-
-/***************************************************************/
-#undef  MLIB_TYPE
-#define MLIB_TYPE mlib_s16
-
-FUNC_AFFINEINDEX_BL_0(S16, U8, 3)
-#ifdef __SUNPRO_C
-#pragma pipeloop(0)
-#endif /* __SUNPRO_C */
-FUNC_AFFINEINDEX_BL_1(S16, U8, 3)
-
-FUNC_AFFINEINDEX_BL_0(S16, S16, 3)
-#ifdef __SUNPRO_C
-#pragma pipeloop(0)
-#endif /* __SUNPRO_C */
-FUNC_AFFINEINDEX_BL_1(S16, S16, 3)
-
-FUNC_AFFINEINDEX_BL_0(S16, U8, 4)
-#ifdef __SUNPRO_C
-#pragma pipeloop(0)
-#endif /* __SUNPRO_C */
-FUNC_AFFINEINDEX_BL_1(S16, U8, 4)
-
-FUNC_AFFINEINDEX_BL_0(S16, S16, 4)
-#ifdef __SUNPRO_C
-#pragma pipeloop(0)
-#endif /* __SUNPRO_C */
-FUNC_AFFINEINDEX_BL_1(S16, S16, 4)
-
-/***************************************************************/
-const type_affine_i_fun mlib_AffineFunArr_bl_i[] = {
-  mlib_ImageAffineIndex_U8_U8_3CH_BL,
-  mlib_ImageAffineIndex_U8_U8_4CH_BL,
-  mlib_ImageAffineIndex_S16_U8_3CH_BL,
-  mlib_ImageAffineIndex_S16_U8_4CH_BL,
-  mlib_ImageAffineIndex_U8_S16_3CH_BL,
-  mlib_ImageAffineIndex_U8_S16_4CH_BL,
-  mlib_ImageAffineIndex_S16_S16_3CH_BL,
-  mlib_ImageAffineIndex_S16_S16_4CH_BL
-};
-/***************************************************************/
--- a/jdk/src/java.desktop/share/native/libmlib_image/mlib_c_ImageBlendTable.c	Thu May 19 17:48:02 2016 +0000
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,263 +0,0 @@
-/*
- * Copyright (c) 1998, 2003, 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.
- */
-
-#include <mlib_image.h>
-#include "mlib_c_ImageBlendTable.h"
-
-const mlib_f32 mlib_c_blend_u8[] = {
-    0.0f,   1.0f,   2.0f,   3.0f,   4.0f,   5.0f,   6.0f,   7.0f,
-    8.0f,   9.0f,  10.0f,  11.0f,  12.0f,  13.0f,  14.0f,  15.0f,
-   16.0f,  17.0f,  18.0f,  19.0f,  20.0f,  21.0f,  22.0f,  23.0f,
-   24.0f,  25.0f,  26.0f,  27.0f,  28.0f,  29.0f,  30.0f,  31.0f,
-   32.0f,  33.0f,  34.0f,  35.0f,  36.0f,  37.0f,  38.0f,  39.0f,
-   40.0f,  41.0f,  42.0f,  43.0f,  44.0f,  45.0f,  46.0f,  47.0f,
-   48.0f,  49.0f,  50.0f,  51.0f,  52.0f,  53.0f,  54.0f,  55.0f,
-   56.0f,  57.0f,  58.0f,  59.0f,  60.0f,  61.0f,  62.0f,  63.0f,
-   64.0f,  65.0f,  66.0f,  67.0f,  68.0f,  69.0f,  70.0f,  71.0f,
-   72.0f,  73.0f,  74.0f,  75.0f,  76.0f,  77.0f,  78.0f,  79.0f,
-   80.0f,  81.0f,  82.0f,  83.0f,  84.0f,  85.0f,  86.0f,  87.0f,
-   88.0f,  89.0f,  90.0f,  91.0f,  92.0f,  93.0f,  94.0f,  95.0f,
-   96.0f,  97.0f,  98.0f,  99.0f, 100.0f, 101.0f, 102.0f, 103.0f,
-  104.0f, 105.0f, 106.0f, 107.0f, 108.0f, 109.0f, 110.0f, 111.0f,
-  112.0f, 113.0f, 114.0f, 115.0f, 116.0f, 117.0f, 118.0f, 119.0f,
-  120.0f, 121.0f, 122.0f, 123.0f, 124.0f, 125.0f, 126.0f, 127.0f,
-  128.0f, 129.0f, 130.0f, 131.0f, 132.0f, 133.0f, 134.0f, 135.0f,
-  136.0f, 137.0f, 138.0f, 139.0f, 140.0f, 141.0f, 142.0f, 143.0f,
-  144.0f, 145.0f, 146.0f, 147.0f, 148.0f, 149.0f, 150.0f, 151.0f,
-  152.0f, 153.0f, 154.0f, 155.0f, 156.0f, 157.0f, 158.0f, 159.0f,
-  160.0f, 161.0f, 162.0f, 163.0f, 164.0f, 165.0f, 166.0f, 167.0f,
-  168.0f, 169.0f, 170.0f, 171.0f, 172.0f, 173.0f, 174.0f, 175.0f,
-  176.0f, 177.0f, 178.0f, 179.0f, 180.0f, 181.0f, 182.0f, 183.0f,
-  184.0f, 185.0f, 186.0f, 187.0f, 188.0f, 189.0f, 190.0f, 191.0f,
-  192.0f, 193.0f, 194.0f, 195.0f, 196.0f, 197.0f, 198.0f, 199.0f,
-  200.0f, 201.0f, 202.0f, 203.0f, 204.0f, 205.0f, 206.0f, 207.0f,
-  208.0f, 209.0f, 210.0f, 211.0f, 212.0f, 213.0f, 214.0f, 215.0f,
-  216.0f, 217.0f, 218.0f, 219.0f, 220.0f, 221.0f, 222.0f, 223.0f,
-  224.0f, 225.0f, 226.0f, 227.0f, 228.0f, 229.0f, 230.0f, 231.0f,
-  232.0f, 233.0f, 234.0f, 235.0f, 236.0f, 237.0f, 238.0f, 239.0f,
-  240.0f, 241.0f, 242.0f, 243.0f, 244.0f, 245.0f, 246.0f, 247.0f,
-  248.0f, 249.0f, 250.0f, 251.0f, 252.0f, 253.0f, 254.0f, 255.0f,
-  256.0f
-};
-
-const mlib_f32 mlib_c_blend_Q8[] = {
-  0.00000000f, 0.00390625f, 0.00781250f, 0.01171875f,
-  0.01562500f, 0.01953125f, 0.02343750f, 0.02734375f,
-  0.03125000f, 0.03515625f, 0.03906250f, 0.04296875f,
-  0.04687500f, 0.05078125f, 0.05468750f, 0.05859375f,
-  0.06250000f, 0.06640625f, 0.07031250f, 0.07421875f,
-  0.07812500f, 0.08203125f, 0.08593750f, 0.08984375f,
-  0.09375000f, 0.09765625f, 0.10156250f, 0.10546875f,
-  0.10937500f, 0.11328125f, 0.11718750f, 0.12109375f,
-  0.12500000f, 0.12890625f, 0.13281250f, 0.13671875f,
-  0.14062500f, 0.14453125f, 0.14843750f, 0.15234375f,
-  0.15625000f, 0.16015625f, 0.16406250f, 0.16796875f,
-  0.17187500f, 0.17578125f, 0.17968750f, 0.18359375f,
-  0.18750000f, 0.19140625f, 0.19531250f, 0.19921875f,
-  0.20312500f, 0.20703125f, 0.21093750f, 0.21484375f,
-  0.21875000f, 0.22265625f, 0.22656250f, 0.23046875f,
-  0.23437500f, 0.23828125f, 0.24218750f, 0.24609375f,
-  0.25000000f, 0.25390625f, 0.25781250f, 0.26171875f,
-  0.26562500f, 0.26953125f, 0.27343750f, 0.27734375f,
-  0.28125000f, 0.28515625f, 0.28906250f, 0.29296875f,
-  0.29687500f, 0.30078125f, 0.30468750f, 0.30859375f,
-  0.31250000f, 0.31640625f, 0.32031250f, 0.32421875f,
-  0.32812500f, 0.33203125f, 0.33593750f, 0.33984375f,
-  0.34375000f, 0.34765625f, 0.35156250f, 0.35546875f,
-  0.35937500f, 0.36328125f, 0.36718750f, 0.37109375f,
-  0.37500000f, 0.37890625f, 0.38281250f, 0.38671875f,
-  0.39062500f, 0.39453125f, 0.39843750f, 0.40234375f,
-  0.40625000f, 0.41015625f, 0.41406250f, 0.41796875f,
-  0.42187500f, 0.42578125f, 0.42968750f, 0.43359375f,
-  0.43750000f, 0.44140625f, 0.44531250f, 0.44921875f,
-  0.45312500f, 0.45703125f, 0.46093750f, 0.46484375f,
-  0.46875000f, 0.47265625f, 0.47656250f, 0.48046875f,
-  0.48437500f, 0.48828125f, 0.49218750f, 0.49609375f,
-  0.50000000f, 0.50390625f, 0.50781250f, 0.51171875f,
-  0.51562500f, 0.51953125f, 0.52343750f, 0.52734375f,
-  0.53125000f, 0.53515625f, 0.53906250f, 0.54296875f,
-  0.54687500f, 0.55078125f, 0.55468750f, 0.55859375f,
-  0.56250000f, 0.56640625f, 0.57031250f, 0.57421875f,
-  0.57812500f, 0.58203125f, 0.58593750f, 0.58984375f,
-  0.59375000f, 0.59765625f, 0.60156250f, 0.60546875f,
-  0.60937500f, 0.61328125f, 0.61718750f, 0.62109375f,
-  0.62500000f, 0.62890625f, 0.63281250f, 0.63671875f,
-  0.64062500f, 0.64453125f, 0.64843750f, 0.65234375f,
-  0.65625000f, 0.66015625f, 0.66406250f, 0.66796875f,
-  0.67187500f, 0.67578125f, 0.67968750f, 0.68359375f,
-  0.68750000f, 0.69140625f, 0.69531250f, 0.69921875f,
-  0.70312500f, 0.70703125f, 0.71093750f, 0.71484375f,
-  0.71875000f, 0.72265625f, 0.72656250f, 0.73046875f,
-  0.73437500f, 0.73828125f, 0.74218750f, 0.74609375f,
-  0.75000000f, 0.75390625f, 0.75781250f, 0.76171875f,
-  0.76562500f, 0.76953125f, 0.77343750f, 0.77734375f,
-  0.78125000f, 0.78515625f, 0.78906250f, 0.79296875f,
-  0.79687500f, 0.80078125f, 0.80468750f, 0.80859375f,
-  0.81250000f, 0.81640625f, 0.82031250f, 0.82421875f,
-  0.82812500f, 0.83203125f, 0.83593750f, 0.83984375f,
-  0.84375000f, 0.84765625f, 0.85156250f, 0.85546875f,
-  0.85937500f, 0.86328125f, 0.86718750f, 0.87109375f,
-  0.87500000f, 0.87890625f, 0.88281250f, 0.88671875f,
-  0.89062500f, 0.89453125f, 0.89843750f, 0.90234375f,
-  0.90625000f, 0.91015625f, 0.91406250f, 0.91796875f,
-  0.92187500f, 0.92578125f, 0.92968750f, 0.93359375f,
-  0.93750000f, 0.94140625f, 0.94531250f, 0.94921875f,
-  0.95312500f, 0.95703125f, 0.96093750f, 0.96484375f,
-  0.96875000f, 0.97265625f, 0.97656250f, 0.98046875f,
-  0.98437500f, 0.98828125f, 0.99218750f, 0.99609375f,
-  1.00000000f, 1.00390625f, 1.00781250f, 1.01171875f,
-  1.01562500f, 1.01953125f, 1.02343750f, 1.02734375f,
-  1.03125000f, 1.03515625f, 1.03906250f, 1.04296875f,
-  1.04687500f, 1.05078125f, 1.05468750f, 1.05859375f,
-  1.06250000f, 1.06640625f, 1.07031250f, 1.07421875f,
-  1.07812500f, 1.08203125f, 1.08593750f, 1.08984375f,
-  1.09375000f, 1.09765625f, 1.10156250f, 1.10546875f,
-  1.10937500f, 1.11328125f, 1.11718750f, 1.12109375f,
-  1.12500000f, 1.12890625f, 1.13281250f, 1.13671875f,
-  1.14062500f, 1.14453125f, 1.14843750f, 1.15234375f,
-  1.15625000f, 1.16015625f, 1.16406250f, 1.16796875f,
-  1.17187500f, 1.17578125f, 1.17968750f, 1.18359375f,
-  1.18750000f, 1.19140625f, 1.19531250f, 1.19921875f,
-  1.20312500f, 1.20703125f, 1.21093750f, 1.21484375f,
-  1.21875000f, 1.22265625f, 1.22656250f, 1.23046875f,
-  1.23437500f, 1.23828125f, 1.24218750f, 1.24609375f,
-  1.25000000f, 1.25390625f, 1.25781250f, 1.26171875f,
-  1.26562500f, 1.26953125f, 1.27343750f, 1.27734375f,
-  1.28125000f, 1.28515625f, 1.28906250f, 1.29296875f,
-  1.29687500f, 1.30078125f, 1.30468750f, 1.30859375f,
-  1.31250000f, 1.31640625f, 1.32031250f, 1.32421875f,
-  1.32812500f, 1.33203125f, 1.33593750f, 1.33984375f,
-  1.34375000f, 1.34765625f, 1.35156250f, 1.35546875f,
-  1.35937500f, 1.36328125f, 1.36718750f, 1.37109375f,
-  1.37500000f, 1.37890625f, 1.38281250f, 1.38671875f,
-  1.39062500f, 1.39453125f, 1.39843750f, 1.40234375f,
-  1.40625000f, 1.41015625f, 1.41406250f, 1.41796875f,
-  1.42187500f, 1.42578125f, 1.42968750f, 1.43359375f,
-  1.43750000f, 1.44140625f, 1.44531250f, 1.44921875f,
-  1.45312500f, 1.45703125f, 1.46093750f, 1.46484375f,
-  1.46875000f, 1.47265625f, 1.47656250f, 1.48046875f,
-  1.48437500f, 1.48828125f, 1.49218750f, 1.49609375f,
-  1.50000000f, 1.50390625f, 1.50781250f, 1.51171875f,
-  1.51562500f, 1.51953125f, 1.52343750f, 1.52734375f,
-  1.53125000f, 1.53515625f, 1.53906250f, 1.54296875f,
-  1.54687500f, 1.55078125f, 1.55468750f, 1.55859375f,
-  1.56250000f, 1.56640625f, 1.57031250f, 1.57421875f,
-  1.57812500f, 1.58203125f, 1.58593750f, 1.58984375f,
-  1.59375000f, 1.59765625f, 1.60156250f, 1.60546875f,
-  1.60937500f, 1.61328125f, 1.61718750f, 1.62109375f,
-  1.62500000f, 1.62890625f, 1.63281250f, 1.63671875f,
-  1.64062500f, 1.64453125f, 1.64843750f, 1.65234375f,
-  1.65625000f, 1.66015625f, 1.66406250f, 1.66796875f,
-  1.67187500f, 1.67578125f, 1.67968750f, 1.68359375f,
-  1.68750000f, 1.69140625f, 1.69531250f, 1.69921875f,
-  1.70312500f, 1.70703125f, 1.71093750f, 1.71484375f,
-  1.71875000f, 1.72265625f, 1.72656250f, 1.73046875f,
-  1.73437500f, 1.73828125f, 1.74218750f, 1.74609375f,
-  1.75000000f, 1.75390625f, 1.75781250f, 1.76171875f,
-  1.76562500f, 1.76953125f, 1.77343750f, 1.77734375f,
-  1.78125000f, 1.78515625f, 1.78906250f, 1.79296875f,
-  1.79687500f, 1.80078125f, 1.80468750f, 1.80859375f,
-  1.81250000f, 1.81640625f, 1.82031250f, 1.82421875f,
-  1.82812500f, 1.83203125f, 1.83593750f, 1.83984375f,
-  1.84375000f, 1.84765625f, 1.85156250f, 1.85546875f,
-  1.85937500f, 1.86328125f, 1.86718750f, 1.87109375f,
-  1.87500000f, 1.87890625f, 1.88281250f, 1.88671875f,
-  1.89062500f, 1.89453125f, 1.89843750f, 1.90234375f,
-  1.90625000f, 1.91015625f, 1.91406250f, 1.91796875f,
-  1.92187500f, 1.92578125f, 1.92968750f, 1.93359375f,
-  1.93750000f, 1.94140625f, 1.94531250f, 1.94921875f,
-  1.95312500f, 1.95703125f, 1.96093750f, 1.96484375f,
-  1.96875000f, 1.97265625f, 1.97656250f, 1.98046875f,
-  1.98437500f, 1.98828125f, 1.99218750f, 1.99609375f,
-  2.00000000f
-};
-
-const mlib_f32 mlib_c_blend_u8_sat[] = {
-           0.0f,    8388608.0f,   16777216.0f,   25165824.0f,
-    33554432.0f,   41943040.0f,   50331648.0f,   58720256.0f,
-    67108864.0f,   75497472.0f,   83886080.0f,   92274688.0f,
-   100663296.0f,  109051904.0f,  117440512.0f,  125829120.0f,
-   134217728.0f,  142606336.0f,  150994944.0f,  159383552.0f,
-   167772160.0f,  176160768.0f,  184549376.0f,  192937984.0f,
-   201326592.0f,  209715200.0f,  218103808.0f,  226492416.0f,
-   234881024.0f,  243269632.0f,  251658240.0f,  260046848.0f,
-   268435456.0f,  276824064.0f,  285212672.0f,  293601280.0f,
-   301989888.0f,  310378496.0f,  318767104.0f,  327155712.0f,
-   335544320.0f,  343932928.0f,  352321536.0f,  360710144.0f,
-   369098752.0f,  377487360.0f,  385875968.0f,  394264576.0f,
-   402653184.0f,  411041792.0f,  419430400.0f,  427819008.0f,
-   436207616.0f,  444596224.0f,  452984832.0f,  461373440.0f,
-   469762048.0f,  478150656.0f,  486539264.0f,  494927872.0f,
-   503316480.0f,  511705088.0f,  520093696.0f,  528482304.0f,
-   536870912.0f,  545259520.0f,  553648128.0f,  562036736.0f,
-   570425344.0f,  578813952.0f,  587202560.0f,  595591168.0f,
-   603979776.0f,  612368384.0f,  620756992.0f,  629145600.0f,
-   637534208.0f,  645922816.0f,  654311424.0f,  662700032.0f,
-   671088640.0f,  679477248.0f,  687865856.0f,  696254464.0f,
-   704643072.0f,  713031680.0f,  721420288.0f,  729808896.0f,
-   738197504.0f,  746586112.0f,  754974720.0f,  763363328.0f,
-   771751936.0f,  780140544.0f,  788529152.0f,  796917760.0f,
-   805306368.0f,  813694976.0f,  822083584.0f,  830472192.0f,
-   838860800.0f,  847249408.0f,  855638016.0f,  864026624.0f,
-   872415232.0f,  880803840.0f,  889192448.0f,  897581056.0f,
-   905969664.0f,  914358272.0f,  922746880.0f,  931135488.0f,
-   939524096.0f,  947912704.0f,  956301312.0f,  964689920.0f,
-   973078528.0f,  981467136.0f,  989855744.0f,  998244352.0f,
-  1006632960.0f, 1015021568.0f, 1023410176.0f, 1031798784.0f,
-  1040187392.0f, 1048576000.0f, 1056964608.0f, 1065353216.0f,
-  1073741824.0f, 1082130432.0f, 1090519040.0f, 1098907648.0f,
-  1107296256.0f, 1115684864.0f, 1124073472.0f, 1132462080.0f,
-  1140850688.0f, 1149239296.0f, 1157627904.0f, 1166016512.0f,
-  1174405120.0f, 1182793728.0f, 1191182336.0f, 1199570944.0f,
-  1207959552.0f, 1216348160.0f, 1224736768.0f, 1233125376.0f,
-  1241513984.0f, 1249902592.0f, 1258291200.0f, 1266679808.0f,
-  1275068416.0f, 1283457024.0f, 1291845632.0f, 1300234240.0f,
-  1308622848.0f, 1317011456.0f, 1325400064.0f, 1333788672.0f,
-  1342177280.0f, 1350565888.0f, 1358954496.0f, 1367343104.0f,
-  1375731712.0f, 1384120320.0f, 1392508928.0f, 1400897536.0f,
-  1409286144.0f, 1417674752.0f, 1426063360.0f, 1434451968.0f,
-  1442840576.0f, 1451229184.0f, 1459617792.0f, 1468006400.0f,
-  1476395008.0f, 1484783616.0f, 1493172224.0f, 1501560832.0f,
-  1509949440.0f, 1518338048.0f, 1526726656.0f, 1535115264.0f,
-  1543503872.0f, 1551892480.0f, 1560281088.0f, 1568669696.0f,
-  1577058304.0f, 1585446912.0f, 1593835520.0f, 1602224128.0f,
-  1610612736.0f, 1619001344.0f, 1627389952.0f, 1635778560.0f,
-  1644167168.0f, 1652555776.0f, 1660944384.0f, 1669332992.0f,
-  1677721600.0f, 1686110208.0f, 1694498816.0f, 1702887424.0f,
-  1711276032.0f, 1719664640.0f, 1728053248.0f, 1736441856.0f,
-  1744830464.0f, 1753219072.0f, 1761607680.0f, 1769996288.0f,
-  1778384896.0f, 1786773504.0f, 1795162112.0f, 1803550720.0f,
-  1811939328.0f, 1820327936.0f, 1828716544.0f, 1837105152.0f,
-  1845493760.0f, 1853882368.0f, 1862270976.0f, 1870659584.0f,
-  1879048192.0f, 1887436800.0f, 1895825408.0f, 1904214016.0f,
-  1912602624.0f, 1920991232.0f, 1929379840.0f, 1937768448.0f,
-  1946157056.0f, 1954545664.0f, 1962934272.0f, 1971322880.0f,
-  1979711488.0f, 1988100096.0f, 1996488704.0f, 2004877312.0f,
-  2013265920.0f, 2021654528.0f, 2030043136.0f, 2038431744.0f,
-  2046820352.0f, 2055208960.0f, 2063597568.0f, 2071986176.0f,
-  2080374784.0f, 2088763392.0f, 2097152000.0f, 2105540608.0f,
-  2113929216.0f, 2122317824.0f, 2130706432.0f, 2139095040.0f,
-  2147483648.0f
-};
--- a/jdk/src/java.desktop/share/native/libmlib_image/mlib_c_ImageBlendTable.h	Thu May 19 17:48:02 2016 +0000
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,41 +0,0 @@
-/*
- * Copyright (c) 1998, 2003, 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.
- */
-
-/*
- *    These tables are used by C versions of the
- *    mlib_ImageBlend_... functions.
- */
-
-#ifndef MLIB_C_IMAGE_BLEND_TABLE_H
-#define MLIB_C_IMAGE_BLEND_TABLE_H
-
-#include "mlib_image.h"
-
-extern const mlib_f32 mlib_c_blend_u8[];
-extern const mlib_f32 mlib_U82F32[];
-extern const mlib_f32 mlib_c_blend_Q8[];
-extern const mlib_f32 mlib_c_blend_u8_sat[];
-
-#endif /* MLIB_C_IMAGEF_BLEND_TABLE_H */
--- a/jdk/src/java.desktop/share/native/libmlib_image/mlib_c_ImageConv.h	Thu May 19 17:48:02 2016 +0000
+++ b/jdk/src/java.desktop/share/native/libmlib_image/mlib_c_ImageConv.h	Thu May 19 19:46:20 2016 +0000
@@ -41,118 +41,6 @@
 }
 #endif /* FREE_AND_RETURN_STATUS */
 
-mlib_status mlib_c_conv2x2ext_s16(mlib_image       *dst,
-                                  const mlib_image *src,
-                                  mlib_s32         dx_l,
-                                  mlib_s32         dx_r,
-                                  mlib_s32         dy_t,
-                                  mlib_s32         dy_b,
-                                  const mlib_s32   *kern,
-                                  mlib_s32         scale,
-                                  mlib_s32         cmask);
-
-mlib_status mlib_c_conv2x2ext_u16(mlib_image       *dst,
-                                  const mlib_image *src,
-                                  mlib_s32         dx_l,
-                                  mlib_s32         dx_r,
-                                  mlib_s32         dy_t,
-                                  mlib_s32         dy_b,
-                                  const mlib_s32   *kern,
-                                  mlib_s32         scale,
-                                  mlib_s32         cmask);
-
-mlib_status mlib_c_conv2x2ext_u8(mlib_image       *dst,
-                                 const mlib_image *src,
-                                 mlib_s32         dx_l,
-                                 mlib_s32         dx_r,
-                                 mlib_s32         dy_t,
-                                 mlib_s32         dy_b,
-                                 const mlib_s32   *kern,
-                                 mlib_s32         scale,
-                                 mlib_s32         cmask);
-
-mlib_status mlib_c_conv2x2nw_s16(mlib_image       *dst,
-                                 const mlib_image *src,
-                                 const mlib_s32   *kern,
-                                 mlib_s32         scale,
-                                 mlib_s32         cmask);
-
-mlib_status mlib_c_conv2x2nw_u16(mlib_image       *dst,
-                                 const mlib_image *src,
-                                 const mlib_s32   *kern,
-                                 mlib_s32         scale,
-                                 mlib_s32         cmask);
-
-mlib_status mlib_c_conv2x2nw_u8(mlib_image       *dst,
-                                const mlib_image *src,
-                                const mlib_s32   *kern,
-                                mlib_s32         scale,
-                                mlib_s32         cmask);
-
-mlib_status mlib_c_conv3x3ext_u8(mlib_image       *dst,
-                                 const mlib_image *src,
-                                 mlib_s32         dx_l,
-                                 mlib_s32         dx_r,
-                                 mlib_s32         dy_t,
-                                 mlib_s32         dy_b,
-                                 const mlib_s32   *kern,
-                                 mlib_s32         scale,
-                                 mlib_s32         cmask);
-
-mlib_status mlib_c_conv3x3nw_u8(mlib_image       *dst,
-                                const mlib_image *src,
-                                const mlib_s32   *kern,
-                                mlib_s32         scale,
-                                mlib_s32         cmask);
-
-mlib_status mlib_c_conv4x4ext_u8(mlib_image       *dst,
-                                 const mlib_image *src,
-                                 mlib_s32         dx_l,
-                                 mlib_s32         dx_r,
-                                 mlib_s32         dy_t,
-                                 mlib_s32         dy_b,
-                                 const mlib_s32   *kern,
-                                 mlib_s32         scale,
-                                 mlib_s32         cmask);
-
-mlib_status mlib_c_conv4x4nw_u8(mlib_image       *dst,
-                                const mlib_image *src,
-                                const mlib_s32   *kern,
-                                mlib_s32         scale,
-                                mlib_s32         cmask);
-
-mlib_status mlib_c_conv5x5ext_u8(mlib_image       *dst,
-                                 const mlib_image *src,
-                                 mlib_s32         dx_l,
-                                 mlib_s32         dx_r,
-                                 mlib_s32         dy_t,
-                                 mlib_s32         dy_b,
-                                 const mlib_s32   *kern,
-                                 mlib_s32         scale,
-                                 mlib_s32         cmask);
-
-mlib_status mlib_c_conv5x5nw_u8(mlib_image       *dst,
-                                const mlib_image *src,
-                                const mlib_s32   *kern,
-                                mlib_s32         scale,
-                                mlib_s32         cmask);
-
-mlib_status mlib_c_conv7x7ext_u8(mlib_image       *dst,
-                                 const mlib_image *src,
-                                 mlib_s32         dx_l,
-                                 mlib_s32         dx_r,
-                                 mlib_s32         dy_t,
-                                 mlib_s32         dy_b,
-                                 const mlib_s32   *kern,
-                                 mlib_s32         scale,
-                                 mlib_s32         cmask);
-
-mlib_status mlib_c_conv7x7nw_u8(mlib_image       *dst,
-                                const mlib_image *src,
-                                const mlib_s32   *kern,
-                                mlib_s32         scale,
-                                mlib_s32         cmask);
-
 mlib_status mlib_c_convMxNnw_u8(mlib_image       *dst,
                                 const mlib_image *src,
                                 const mlib_s32   *kernel,
@@ -177,102 +65,6 @@
 
 #if ! defined ( __sparc ) /* for x86, using integer multiplies is faster */
 
-mlib_status mlib_i_conv3x3ext_s16(mlib_image       *dst,
-                                  const mlib_image *src,
-                                  mlib_s32         dx_l,
-                                  mlib_s32         dx_r,
-                                  mlib_s32         dy_t,
-                                  mlib_s32         dy_b,
-                                  const mlib_s32   *kern,
-                                  mlib_s32         scale,
-                                  mlib_s32         cmask);
-
-mlib_status mlib_i_conv3x3ext_u16(mlib_image       *dst,
-                                  const mlib_image *src,
-                                  mlib_s32         dx_l,
-                                  mlib_s32         dx_r,
-                                  mlib_s32         dy_t,
-                                  mlib_s32         dy_b,
-                                  const mlib_s32   *kern,
-                                  mlib_s32         scale,
-                                  mlib_s32         cmask);
-
-mlib_status mlib_i_conv3x3ext_u8(mlib_image       *dst,
-                                 const mlib_image *src,
-                                 mlib_s32         dx_l,
-                                 mlib_s32         dx_r,
-                                 mlib_s32         dy_t,
-                                 mlib_s32         dy_b,
-                                 const mlib_s32   *kern,
-                                 mlib_s32         scale,
-                                 mlib_s32         cmask);
-
-mlib_status mlib_i_conv3x3nw_s16(mlib_image       *dst,
-                                 const mlib_image *src,
-                                 const mlib_s32   *kern,
-                                 mlib_s32         scale,
-                                 mlib_s32         cmask);
-
-mlib_status mlib_i_conv3x3nw_u16(mlib_image       *dst,
-                                 const mlib_image *src,
-                                 const mlib_s32   *kern,
-                                 mlib_s32         scale,
-                                 mlib_s32         cmask);
-
-mlib_status mlib_i_conv3x3nw_u8(mlib_image       *dst,
-                                const mlib_image *src,
-                                const mlib_s32   *kern,
-                                mlib_s32         scale,
-                                mlib_s32         cmask);
-
-mlib_status mlib_i_conv5x5ext_s16(mlib_image       *dst,
-                                  const mlib_image *src,
-                                  mlib_s32         dx_l,
-                                  mlib_s32         dx_r,
-                                  mlib_s32         dy_t,
-                                  mlib_s32         dy_b,
-                                  const mlib_s32   *kern,
-                                  mlib_s32         scale,
-                                  mlib_s32         cmask);
-
-mlib_status mlib_i_conv5x5ext_u16(mlib_image       *dst,
-                                  const mlib_image *src,
-                                  mlib_s32         dx_l,
-                                  mlib_s32         dx_r,
-                                  mlib_s32         dy_t,
-                                  mlib_s32         dy_b,
-                                  const mlib_s32   *kern,
-                                  mlib_s32         scale,
-                                  mlib_s32         cmask);
-
-mlib_status mlib_i_conv5x5ext_u8(mlib_image       *dst,
-                                 const mlib_image *src,
-                                 mlib_s32         dx_l,
-                                 mlib_s32         dx_r,
-                                 mlib_s32         dy_t,
-                                 mlib_s32         dy_b,
-                                 const mlib_s32   *kern,
-                                 mlib_s32         scale,
-                                 mlib_s32         cmask);
-
-mlib_status mlib_i_conv5x5nw_s16(mlib_image       *dst,
-                                 const mlib_image *src,
-                                 const mlib_s32   *kern,
-                                 mlib_s32         scale,
-                                 mlib_s32         cmask);
-
-mlib_status mlib_i_conv5x5nw_u16(mlib_image       *dst,
-                                 const mlib_image *src,
-                                 const mlib_s32   *kern,
-                                 mlib_s32         scale,
-                                 mlib_s32         cmask);
-
-mlib_status mlib_i_conv5x5nw_u8(mlib_image       *dst,
-                                const mlib_image *src,
-                                const mlib_s32   *kern,
-                                mlib_s32         scale,
-                                mlib_s32         cmask);
-
 mlib_status mlib_i_convMxNnw_s16(mlib_image       *dst,
                                  const mlib_image *src,
                                  const mlib_s32   *kernel,
--- a/jdk/src/java.desktop/share/native/libmlib_image/mlib_c_ImageConv_f.c	Thu May 19 17:48:02 2016 +0000
+++ b/jdk/src/java.desktop/share/native/libmlib_image/mlib_c_ImageConv_f.c	Thu May 19 19:46:20 2016 +0000
@@ -29,34 +29,6 @@
 #include "mlib_c_ImageConv.h"
 
 /***************************************************************/
-#define MLIB_PARAMS_CONV_NW                                     \
-  mlib_image       *dst,                                        \
-  const mlib_image *src,                                        \
-  const mlib_s32   *kern,                                       \
-  mlib_s32         scale,                                       \
-  mlib_s32         cmask
-
-/***************************************************************/
-#define MLIB_CALL_PARAMS_CONV_NW                                \
-  dst, src, kern, scale, cmask
-
-/***************************************************************/
-#define MLIB_PARAMS_CONV_EXT                                    \
-  mlib_image       *dst,                                        \
-  const mlib_image *src,                                        \
-  mlib_s32         dx_l,                                        \
-  mlib_s32         dx_r,                                        \
-  mlib_s32         dy_t,                                        \
-  mlib_s32         dy_b,                                        \
-  const mlib_s32   *kern,                                       \
-  mlib_s32         scale,                                       \
-  mlib_s32         cmask
-
-/***************************************************************/
-#define MLIB_CALL_PARAMS_CONV_EXT                               \
-  dst, src, dx_l, dx_r, dy_t, dy_b, kern, scale, cmask
-
-/***************************************************************/
 #define MLIB_PARAMS_CONV_MN_NW                                  \
   mlib_image *dst,                                              \
   const mlib_image *src,                                        \
@@ -92,52 +64,6 @@
 
 
 /***************************************************************/
-mlib_status mlib_conv2x2nw_u8(MLIB_PARAMS_CONV_NW)
-{
-  return mlib_c_conv2x2nw_u8(MLIB_CALL_PARAMS_CONV_NW);
-}
-
-/***************************************************************/
-mlib_status mlib_conv3x3nw_u8(MLIB_PARAMS_CONV_NW)
-{
-#ifdef __sparc
-  return mlib_c_conv3x3nw_u8(MLIB_CALL_PARAMS_CONV_NW);
-#else
-
-  if (mlib_ImageConvVersion(3, 3, scale, MLIB_BYTE) == 0)
-    return mlib_c_conv3x3nw_u8(MLIB_CALL_PARAMS_CONV_NW);
-  else
-    return mlib_i_conv3x3nw_u8(MLIB_CALL_PARAMS_CONV_NW);
-#endif /* __sparc */
-}
-
-/***************************************************************/
-mlib_status mlib_conv4x4nw_u8(MLIB_PARAMS_CONV_NW)
-{
-  return mlib_c_conv4x4nw_u8(MLIB_CALL_PARAMS_CONV_NW);
-}
-
-/***************************************************************/
-mlib_status mlib_conv5x5nw_u8(MLIB_PARAMS_CONV_NW)
-{
-#ifdef __sparc
-  return mlib_c_conv5x5nw_u8(MLIB_CALL_PARAMS_CONV_NW);
-#else
-
-  if (mlib_ImageConvVersion(5, 5, scale, MLIB_BYTE) == 0)
-    return mlib_c_conv5x5nw_u8(MLIB_CALL_PARAMS_CONV_NW);
-  else
-    return mlib_i_conv5x5nw_u8(MLIB_CALL_PARAMS_CONV_NW);
-#endif /* __sparc */
-}
-
-/***************************************************************/
-mlib_status mlib_conv7x7nw_u8(MLIB_PARAMS_CONV_NW)
-{
-  return mlib_c_conv7x7nw_u8(MLIB_CALL_PARAMS_CONV_NW);
-}
-
-/***************************************************************/
 mlib_status mlib_convMxNnw_u8(MLIB_PARAMS_CONV_MN_NW)
 {
 #ifdef __sparc
@@ -152,52 +78,6 @@
 }
 
 /***************************************************************/
-mlib_status mlib_conv2x2ext_u8(MLIB_PARAMS_CONV_EXT)
-{
-  return mlib_c_conv2x2ext_u8(MLIB_CALL_PARAMS_CONV_EXT);
-}
-
-/***************************************************************/
-mlib_status mlib_conv3x3ext_u8(MLIB_PARAMS_CONV_EXT)
-{
-#ifdef __sparc
-  return mlib_c_conv3x3ext_u8(MLIB_CALL_PARAMS_CONV_EXT);
-#else
-
-  if (mlib_ImageConvVersion(3, 3, scale, MLIB_BYTE) == 0)
-    return mlib_c_conv3x3ext_u8(MLIB_CALL_PARAMS_CONV_EXT);
-  else
-    return mlib_i_conv3x3ext_u8(MLIB_CALL_PARAMS_CONV_EXT);
-#endif /* __sparc */
-}
-
-/***************************************************************/
-mlib_status mlib_conv4x4ext_u8(MLIB_PARAMS_CONV_EXT)
-{
-  return mlib_c_conv4x4ext_u8(MLIB_CALL_PARAMS_CONV_EXT);
-}
-
-/***************************************************************/
-mlib_status mlib_conv5x5ext_u8(MLIB_PARAMS_CONV_EXT)
-{
-#ifdef __sparc
-  return mlib_c_conv5x5ext_u8(MLIB_CALL_PARAMS_CONV_EXT);
-#else
-
-  if (mlib_ImageConvVersion(5, 5, scale, MLIB_BYTE) == 0)
-    return mlib_c_conv5x5ext_u8(MLIB_CALL_PARAMS_CONV_EXT);
-  else
-    return mlib_i_conv5x5ext_u8(MLIB_CALL_PARAMS_CONV_EXT);
-#endif /* __sparc */
-}
-
-/***************************************************************/
-mlib_status mlib_conv7x7ext_u8(MLIB_PARAMS_CONV_EXT)
-{
-  return mlib_c_conv7x7ext_u8(MLIB_CALL_PARAMS_CONV_EXT);
-}
-
-/***************************************************************/
 mlib_status mlib_convMxNext_u8(MLIB_PARAMS_CONV_MN_EXT)
 {
 #ifdef __sparc
@@ -212,27 +92,3 @@
 }
 
 /***************************************************************/
-mlib_status mlib_conv2x2nw_s16(MLIB_PARAMS_CONV_NW)
-{
-  return mlib_c_conv2x2nw_s16(MLIB_CALL_PARAMS_CONV_NW);
-}
-
-/***************************************************************/
-mlib_status mlib_conv2x2nw_u16(MLIB_PARAMS_CONV_NW)
-{
-  return mlib_c_conv2x2nw_u16(MLIB_CALL_PARAMS_CONV_NW);
-}
-
-/***************************************************************/
-mlib_status mlib_conv2x2ext_s16(MLIB_PARAMS_CONV_EXT)
-{
-  return mlib_c_conv2x2ext_s16(MLIB_CALL_PARAMS_CONV_EXT);
-}
-
-/***************************************************************/
-mlib_status mlib_conv2x2ext_u16(MLIB_PARAMS_CONV_EXT)
-{
-  return mlib_c_conv2x2ext_u16(MLIB_CALL_PARAMS_CONV_EXT);
-}
-
-/***************************************************************/
--- a/jdk/src/java.desktop/share/native/libmlib_image/mlib_c_ImageThresh1.h	Thu May 19 17:48:02 2016 +0000
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,103 +0,0 @@
-/*
- * Copyright (c) 2003, 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.
- */
-
-
-#ifndef __MLIB_C_IMAGETHRESH1_H
-#define __MLIB_C_IMAGETHRESH1_H
-
-#ifdef __cplusplus
-extern "C" {
-#endif /* __cplusplus */
-
-/***************************************************************/
-#define PARAMS                                                  \
-  void     *psrc,                                               \
-  void     *pdst,                                               \
-  mlib_s32 src_stride,                                          \
-  mlib_s32 dst_stride,                                          \
-  mlib_s32 width,                                               \
-  mlib_s32 height,                                              \
-  void     *__thresh,                                           \
-  void     *__ghigh,                                            \
-  void     *__glow
-
-void mlib_c_ImageThresh1_D641(PARAMS);
-void mlib_c_ImageThresh1_D642(PARAMS);
-void mlib_c_ImageThresh1_D643(PARAMS);
-void mlib_c_ImageThresh1_D644(PARAMS);
-void mlib_c_ImageThresh1_D641_1B(PARAMS, mlib_s32 dbit_off);
-void mlib_c_ImageThresh1_D642_1B(PARAMS, mlib_s32 dbit_off);
-void mlib_c_ImageThresh1_D643_1B(PARAMS, mlib_s32 dbit_off);
-void mlib_c_ImageThresh1_D644_1B(PARAMS, mlib_s32 dbit_off);
-
-void mlib_c_ImageThresh1_F321(PARAMS);
-void mlib_c_ImageThresh1_F322(PARAMS);
-void mlib_c_ImageThresh1_F323(PARAMS);
-void mlib_c_ImageThresh1_F324(PARAMS);
-void mlib_c_ImageThresh1_F321_1B(PARAMS, mlib_s32 dbit_off);
-void mlib_c_ImageThresh1_F322_1B(PARAMS, mlib_s32 dbit_off);
-void mlib_c_ImageThresh1_F323_1B(PARAMS, mlib_s32 dbit_off);
-void mlib_c_ImageThresh1_F324_1B(PARAMS, mlib_s32 dbit_off);
-
-void mlib_c_ImageThresh1_S321(PARAMS);
-void mlib_c_ImageThresh1_S322(PARAMS);
-void mlib_c_ImageThresh1_S323(PARAMS);
-void mlib_c_ImageThresh1_S324(PARAMS);
-void mlib_c_ImageThresh1_S321_1B(PARAMS, mlib_s32 dbit_off);
-void mlib_c_ImageThresh1_S322_1B(PARAMS, mlib_s32 dbit_off);
-void mlib_c_ImageThresh1_S323_1B(PARAMS, mlib_s32 dbit_off);
-void mlib_c_ImageThresh1_S324_1B(PARAMS, mlib_s32 dbit_off);
-
-void mlib_c_ImageThresh1_S161(PARAMS);
-void mlib_c_ImageThresh1_S162(PARAMS);
-void mlib_c_ImageThresh1_S163(PARAMS);
-void mlib_c_ImageThresh1_S164(PARAMS);
-void mlib_c_ImageThresh1_S161_1B(PARAMS, mlib_s32 dbit_off);
-void mlib_c_ImageThresh1_S162_1B(PARAMS, mlib_s32 dbit_off);
-void mlib_c_ImageThresh1_S163_1B(PARAMS, mlib_s32 dbit_off);
-void mlib_c_ImageThresh1_S164_1B(PARAMS, mlib_s32 dbit_off);
-
-void mlib_c_ImageThresh1_U161(PARAMS);
-void mlib_c_ImageThresh1_U162(PARAMS);
-void mlib_c_ImageThresh1_U163(PARAMS);
-void mlib_c_ImageThresh1_U164(PARAMS);
-void mlib_c_ImageThresh1_U161_1B(PARAMS, mlib_s32 dbit_off);
-void mlib_c_ImageThresh1_U162_1B(PARAMS, mlib_s32 dbit_off);
-void mlib_c_ImageThresh1_U163_1B(PARAMS, mlib_s32 dbit_off);
-void mlib_c_ImageThresh1_U164_1B(PARAMS, mlib_s32 dbit_off);
-
-void mlib_c_ImageThresh1_U81(PARAMS);
-void mlib_c_ImageThresh1_U82(PARAMS);
-void mlib_c_ImageThresh1_U83(PARAMS);
-void mlib_c_ImageThresh1_U84(PARAMS);
-void mlib_c_ImageThresh1_U81_1B(PARAMS, mlib_s32 dbit_off);
-void mlib_c_ImageThresh1_U82_1B(PARAMS, mlib_s32 dbit_off);
-void mlib_c_ImageThresh1_U83_1B(PARAMS, mlib_s32 dbit_off);
-void mlib_c_ImageThresh1_U84_1B(PARAMS, mlib_s32 dbit_off);
-
-#ifdef __cplusplus
-}
-#endif /* __cplusplus */
-#endif /* __MLIB_C_IMAGETHRESH1_H */
--- a/jdk/src/java.desktop/share/native/libmlib_image/mlib_c_ImageThresh1_U8.c	Thu May 19 17:48:02 2016 +0000
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,848 +0,0 @@
-/*
- * Copyright (c) 2003, 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.
- */
-
-
-/*
- * FUNCTION
- *      mlib_ImageThresh1 - thresholding
- *
- * SYNOPSIS
- *      mlib_status mlib_ImageThresh1(mlib_image       *dst,
- *                                    const mlib_image *src,
- *                                    const mlib_s32   *thresh,
- *                                    const mlib_s32   *ghigh,
- *                                    const mlib_s32   *glow);
- *
- * ARGUMENT
- *      dst     pointer to output image
- *      src     pointer to input image
- *      thresh  array of thresholds
- *      ghigh   array of values above thresholds
- *      glow    array of values below thresholds
- *
- * RESTRICTION
- *      The images must have the same size, and the same number
- *      of channels.
- *      The images can have 1, 2, 3, or 4 channels.
- *      The images can be in MLIB_BYTE, MLIB_SHORT or MLIB_INT data type.
- *      The type of the output image can be MLIB_BIT, or the same as the
- *      type of the input image.
- *
- * DESCRIPTION
- *      If the pixel band value is above the threshold for that channel,
- *      set the destination to the ghigh value for that channel.
- *      Otherwise, set the destination to the glow value for that channel.
- *
- *                      +- glow[c]   src[x][y][c] <= thresh[c]
- *      dst[x][y][c]  = |
- *                      +- ghigh[c]  src[x][y][c] >  thresh[c]
- */
-
-#include "mlib_image.h"
-#include "mlib_ImageCheck.h"
-#include "mlib_c_ImageThresh1.h"
-
-/***************************************************************/
-#define STYPE           mlib_u8
-#define TTYPE           mlib_s32
-#define T_SHIFT         31
-
-/***************************************************************/
-#define DO_THRESH(s0, th, gl, gh)                               \
-  (((gh) & (((th) - (TTYPE)(s0)) >> T_SHIFT)) |                 \
-   ((gl) &~ (((th) - (TTYPE)(s0)) >> T_SHIFT)))
-
-/***************************************************************/
-#define THRESH1_CMP_SHIFT(s0, th, sh)                           \
-  ((((th) - (s0)) >> T_SHIFT) & (1 << (sh)))
-
-/***************************************************************/
-#define STRIP(pd, ps, w, h, ch, th, gh, gl) {                   \
-    STYPE s0;                                                   \
-    for ( i = 0; i < h; i++ ) {                                 \
-      for (j = 0; j < w; j ++)  {                               \
-        for (k = 0; k < ch; k++) {                              \
-          s0 = ((STYPE*)ps)[i*src_stride + j*ch + k];           \
-          ((STYPE*)pd)[i*dst_stride + j*ch + k] =               \
-                (s0 <= th[k]) ? gl[k]: gh[k];                   \
-        }                                                       \
-      }                                                         \
-    }                                                           \
-  }
-
-/***************************************************************/
-#define INIT_THRESH0(n)                                         \
-  thresh0 = thresh[n];                                          \
-  ghigh0  = ghigh[n];                                           \
-  glow0   = glow[n]
-
-/***************************************************************/
-#define INIT_THRESH1(n)                                         \
-  thresh1 = thresh[n];                                          \
-  ghigh1  = ghigh[n];                                           \
-  glow1   = glow[n]
-
-/***************************************************************/
-#define INIT_THRESH2(n)                                         \
-  thresh2 = thresh[n];                                          \
-  ghigh2  = ghigh[n];                                           \
-  glow2   = glow[n]
-
-/***************************************************************/
-#define INIT_THRESH3(n)                                         \
-  thresh3 = thresh[n];                                          \
-  ghigh3  = ghigh[n];                                           \
-  glow3   = glow[n]
-
-/***************************************************************/
-#define THRESH0(s0) DO_THRESH(s0, thresh0, glow0, ghigh0)
-#define THRESH1(s0) DO_THRESH(s0, thresh1, glow1, ghigh1)
-#define THRESH2(s0) DO_THRESH(s0, thresh2, glow2, ghigh2)
-#define THRESH3(s0) DO_THRESH(s0, thresh3, glow3, ghigh3)
-
-/***************************************************************/
-void mlib_c_ImageThresh1_U81(PARAMS)
-{
-  mlib_s32 *thresh = (void *)__thresh;
-  mlib_s32 *ghigh = (void *)__ghigh;
-  mlib_s32 *glow = (void *)__glow;
-  STYPE *psrc_row = psrc;
-  STYPE *pdst_row = pdst;
-  TTYPE thresh0;
-  TTYPE ghigh0;
-  TTYPE glow0;
-  mlib_s32 i, j, k;
-
-  if (width < 16) {
-    STRIP(pdst, psrc, width, height, 1, thresh, ghigh, glow);
-    return;
-  }
-
-  INIT_THRESH0(0);
-
-  for (i = 0; i < height; i++) {
-
-#ifdef __SUNPRO_C
-#pragma pipeloop(0)
-#endif /* __SUNPRO_C */
-    for (j = 0; j <= (width - 8); j += 8) {
-      pdst_row[j] = THRESH0(psrc_row[j]);
-      pdst_row[j + 1] = THRESH0(psrc_row[j + 1]);
-      pdst_row[j + 2] = THRESH0(psrc_row[j + 2]);
-      pdst_row[j + 3] = THRESH0(psrc_row[j + 3]);
-      pdst_row[j + 4] = THRESH0(psrc_row[j + 4]);
-      pdst_row[j + 5] = THRESH0(psrc_row[j + 5]);
-      pdst_row[j + 6] = THRESH0(psrc_row[j + 6]);
-      pdst_row[j + 7] = THRESH0(psrc_row[j + 7]);
-    }
-
-    for (; j < width; j++) {
-      pdst_row[j] = THRESH0(psrc_row[j]);
-    }
-
-    psrc_row += src_stride;
-    pdst_row += dst_stride;
-  }
-}
-
-/***************************************************************/
-void mlib_c_ImageThresh1_U82(PARAMS)
-{
-  mlib_s32 *thresh = (void *)__thresh;
-  mlib_s32 *ghigh = (void *)__ghigh;
-  mlib_s32 *glow = (void *)__glow;
-  STYPE *psrc_row = psrc;
-  STYPE *pdst_row = pdst;
-  TTYPE thresh0, thresh1;
-  TTYPE ghigh0, ghigh1;
-  TTYPE glow0, glow1;
-  mlib_s32 i, j, k;
-
-  if (width < 16) {
-    STRIP(pdst, psrc, width, height, 2, thresh, ghigh, glow);
-    return;
-  }
-
-  INIT_THRESH0(0);
-  INIT_THRESH1(1);
-  width <<= 1;
-
-  for (i = 0; i < height; i++) {
-
-#ifdef __SUNPRO_C
-#pragma pipeloop(0)
-#endif /* __SUNPRO_C */
-    for (j = 0; j <= (width - 8); j += 8) {
-      pdst_row[j] = THRESH0(psrc_row[j]);
-      pdst_row[j + 1] = THRESH1(psrc_row[j + 1]);
-      pdst_row[j + 2] = THRESH0(psrc_row[j + 2]);
-      pdst_row[j + 3] = THRESH1(psrc_row[j + 3]);
-      pdst_row[j + 4] = THRESH0(psrc_row[j + 4]);
-      pdst_row[j + 5] = THRESH1(psrc_row[j + 5]);
-      pdst_row[j + 6] = THRESH0(psrc_row[j + 6]);
-      pdst_row[j + 7] = THRESH1(psrc_row[j + 7]);
-    }
-
-    for (; j < width; j += 2) {
-      pdst_row[j] = THRESH0(psrc_row[j]);
-      pdst_row[j + 1] = THRESH1(psrc_row[j + 1]);
-    }
-
-    psrc_row += src_stride;
-    pdst_row += dst_stride;
-  }
-}
-
-/***************************************************************/
-void mlib_c_ImageThresh1_U83(PARAMS)
-{
-  mlib_s32 *thresh = (void *)__thresh;
-  mlib_s32 *ghigh = (void *)__ghigh;
-  mlib_s32 *glow = (void *)__glow;
-  STYPE *psrc_row = psrc;
-  STYPE *pdst_row = pdst;
-  TTYPE thresh0, thresh1, thresh2;
-  TTYPE ghigh0, ghigh1, ghigh2;
-  TTYPE glow0, glow1, glow2;
-  mlib_s32 i, j, k;
-
-  if (width < 16) {
-    STRIP(pdst, psrc, width, height, 3, thresh, ghigh, glow);
-    return;
-  }
-
-  width = 3 * width;
-  INIT_THRESH0(0);
-  INIT_THRESH1(1);
-  INIT_THRESH2(2);
-
-  for (i = 0; i < height; i++) {
-
-#ifdef __SUNPRO_C
-#pragma pipeloop(0)
-#endif /* __SUNPRO_C */
-    for (j = 0; j <= (width - 12); j += 12) {
-      pdst_row[j] = THRESH0(psrc_row[j]);
-      pdst_row[j + 1] = THRESH1(psrc_row[j + 1]);
-      pdst_row[j + 2] = THRESH2(psrc_row[j + 2]);
-      pdst_row[j + 3] = THRESH0(psrc_row[j + 3]);
-      pdst_row[j + 4] = THRESH1(psrc_row[j + 4]);
-      pdst_row[j + 5] = THRESH2(psrc_row[j + 5]);
-      pdst_row[j + 6] = THRESH0(psrc_row[j + 6]);
-      pdst_row[j + 7] = THRESH1(psrc_row[j + 7]);
-      pdst_row[j + 8] = THRESH2(psrc_row[j + 8]);
-      pdst_row[j + 9] = THRESH0(psrc_row[j + 9]);
-      pdst_row[j + 10] = THRESH1(psrc_row[j + 10]);
-      pdst_row[j + 11] = THRESH2(psrc_row[j + 11]);
-    }
-
-    for (; j < width; j += 3) {
-      pdst_row[j] = THRESH0(psrc_row[j]);
-      pdst_row[j + 1] = THRESH1(psrc_row[j + 1]);
-      pdst_row[j + 2] = THRESH2(psrc_row[j + 2]);
-    }
-
-    psrc_row += src_stride;
-    pdst_row += dst_stride;
-  }
-}
-
-/***************************************************************/
-void mlib_c_ImageThresh1_U84(PARAMS)
-{
-  mlib_s32 *thresh = (void *)__thresh;
-  mlib_s32 *ghigh = (void *)__ghigh;
-  mlib_s32 *glow = (void *)__glow;
-  STYPE *psrc_row = psrc;
-  STYPE *pdst_row = pdst;
-  TTYPE thresh0, thresh1, thresh2, thresh3;
-  TTYPE ghigh0, ghigh1, ghigh2, ghigh3;
-  TTYPE glow0, glow1, glow2, glow3;
-  mlib_s32 i, j, k;
-
-  if (width < 16) {
-    STRIP(pdst, psrc, width, height, 4, thresh, ghigh, glow);
-    return;
-  }
-
-  INIT_THRESH0(0);
-  INIT_THRESH1(1);
-  INIT_THRESH2(2);
-  INIT_THRESH3(3);
-
-  width *= 4;
-
-  for (i = 0; i < height; i++) {
-
-#ifdef __SUNPRO_C
-#pragma pipeloop(0)
-#endif /* __SUNPRO_C */
-    for (j = 0; j <= (width - 8); j += 8) {
-      pdst_row[j] = THRESH0(psrc_row[j]);
-      pdst_row[j + 1] = THRESH1(psrc_row[j + 1]);
-      pdst_row[j + 2] = THRESH2(psrc_row[j + 2]);
-      pdst_row[j + 3] = THRESH3(psrc_row[j + 3]);
-      pdst_row[j + 4] = THRESH0(psrc_row[j + 4]);
-      pdst_row[j + 5] = THRESH1(psrc_row[j + 5]);
-      pdst_row[j + 6] = THRESH2(psrc_row[j + 6]);
-      pdst_row[j + 7] = THRESH3(psrc_row[j + 7]);
-    }
-
-    if (j < width) {
-      pdst_row[j] = THRESH0(psrc_row[j]);
-      pdst_row[j + 1] = THRESH1(psrc_row[j + 1]);
-      pdst_row[j + 2] = THRESH2(psrc_row[j + 2]);
-      pdst_row[j + 3] = THRESH3(psrc_row[j + 3]);
-    }
-
-    psrc_row += src_stride;
-    pdst_row += dst_stride;
-  }
-}
-
-/***************************************************************/
-void mlib_c_ImageThresh1_U81_1B(PARAMS,
-                                mlib_s32 dbit_off)
-{
-  mlib_s32 *thresh = (void *)__thresh;
-  mlib_s32 *ghigh = (void *)__ghigh;
-  mlib_s32 *glow = (void *)__glow;
-  STYPE *psrc_row = psrc;
-  mlib_u8 *pdst_row = pdst;
-  TTYPE thresh0 = thresh[0];
-  mlib_s32 mhigh, mlow, emask, dst0;
-  mlib_s32 i, j, jbit, l;
-
-  mhigh = (ghigh[0] > 0) ? 0xff : 0;
-  mlow = (glow[0] > 0) ? 0xff : 0;
-
-  for (i = 0; i < height; i++) {
-    j = 0;
-    jbit = 0;
-
-    if (dbit_off) {
-      mlib_s32 nume = 8 - dbit_off;
-
-      if (nume > width)
-        nume = width;
-      dst0 = 0;
-      emask = 0;
-
-      for (; j < nume; j++) {
-        emask |= (1 << (7 - (dbit_off + j)));
-        dst0 |= THRESH1_CMP_SHIFT(psrc_row[j], thresh0, 7 - (dbit_off + j));
-      }
-
-      dst0 = (mhigh & dst0) | (mlow & ~dst0);
-      pdst_row[0] = (dst0 & emask) | (pdst_row[0] & ~emask);
-      jbit++;
-    }
-
-#ifdef __SUNPRO_C
-#pragma pipeloop(0)
-#endif /* __SUNPRO_C */
-    for (; j <= (width - 16); j += 16) {
-      dst0 = THRESH1_CMP_SHIFT(psrc_row[j], thresh0, 7) |
-        THRESH1_CMP_SHIFT(psrc_row[j + 1], thresh0, 6) |
-        THRESH1_CMP_SHIFT(psrc_row[j + 2], thresh0, 5) |
-        THRESH1_CMP_SHIFT(psrc_row[j + 3], thresh0, 4) |
-        THRESH1_CMP_SHIFT(psrc_row[j + 4], thresh0, 3) |
-        THRESH1_CMP_SHIFT(psrc_row[j + 5], thresh0, 2) |
-        THRESH1_CMP_SHIFT(psrc_row[j + 6], thresh0, 1) |
-        THRESH1_CMP_SHIFT(psrc_row[j + 7], thresh0, 0);
-      dst0 = (mhigh & dst0) | (mlow & ~dst0);
-      *(pdst_row + jbit) = (mlib_u8) dst0;
-      jbit++;
-      dst0 = THRESH1_CMP_SHIFT(psrc_row[j + 8], thresh0, 7) |
-        THRESH1_CMP_SHIFT(psrc_row[j + 9], thresh0, 6) |
-        THRESH1_CMP_SHIFT(psrc_row[j + 10], thresh0, 5) |
-        THRESH1_CMP_SHIFT(psrc_row[j + 11], thresh0, 4) |
-        THRESH1_CMP_SHIFT(psrc_row[j + 12], thresh0, 3) |
-        THRESH1_CMP_SHIFT(psrc_row[j + 13], thresh0, 2) |
-        THRESH1_CMP_SHIFT(psrc_row[j + 14], thresh0, 1) |
-        THRESH1_CMP_SHIFT(psrc_row[j + 15], thresh0, 0);
-      dst0 = (mhigh & dst0) | (mlow & ~dst0);
-      *(pdst_row + jbit) = (mlib_u8) dst0;
-      jbit++;
-    }
-
-    if (width - j >= 8) {
-      dst0 = THRESH1_CMP_SHIFT(psrc_row[j], thresh0, 7) |
-        THRESH1_CMP_SHIFT(psrc_row[j + 1], thresh0, 6) |
-        THRESH1_CMP_SHIFT(psrc_row[j + 2], thresh0, 5) |
-        THRESH1_CMP_SHIFT(psrc_row[j + 3], thresh0, 4) |
-        THRESH1_CMP_SHIFT(psrc_row[j + 4], thresh0, 3) |
-        THRESH1_CMP_SHIFT(psrc_row[j + 5], thresh0, 2) |
-        THRESH1_CMP_SHIFT(psrc_row[j + 6], thresh0, 1) |
-        THRESH1_CMP_SHIFT(psrc_row[j + 7], thresh0, 0);
-      dst0 = (mhigh & dst0) | (mlow & ~dst0);
-      *(pdst_row + jbit) = (mlib_u8) dst0;
-      jbit++;
-      j += 8;
-    }
-
-    if (j < width) {
-      dst0 = 0;
-      l = 7;
-      for (; j < width; j++) {
-        dst0 |= THRESH1_CMP_SHIFT(psrc_row[j], thresh0, l);
-        l--;
-      }
-
-      emask = (0xFF << (l + 1));
-      dst0 = (mhigh & dst0) | (mlow & ~dst0);
-      pdst_row[jbit] = (dst0 & emask) | (pdst_row[jbit] & ~emask);
-    }
-
-    psrc_row += src_stride;
-    pdst_row += dst_stride;
-  }
-}
-
-/***************************************************************/
-void mlib_c_ImageThresh1_U82_1B(PARAMS,
-                                mlib_s32 dbit_off)
-{
-  mlib_s32 *thresh = (void *)__thresh;
-  mlib_s32 *ghigh = (void *)__ghigh;
-  mlib_s32 *glow = (void *)__glow;
-  STYPE *psrc_row = psrc;
-  mlib_u8 *pdst_row = pdst;
-  TTYPE thresh0 = thresh[0], thresh1 = thresh[1];
-  mlib_s32 mhigh0, mlow0, mhigh, mlow, emask, dst0;
-  mlib_s32 i, j, jbit, l;
-
-  mhigh0 = (ghigh[0] > 0) ? 0xaaa : 0;
-  mhigh0 |= (ghigh[1] > 0) ? 0x555 : 0;
-  mlow0 = (glow[0] > 0) ? 0xaaa : 0;
-  mlow0 |= (glow[1] > 0) ? 0x555 : 0;
-
-  width *= 2;
-
-  for (i = 0; i < height; i++) {
-    thresh0 = thresh[0];
-    thresh1 = thresh[1];
-
-    j = 0;
-    jbit = 0;
-    mhigh = mhigh0 >> (dbit_off & 1);
-    mlow = mlow0 >> (dbit_off & 1);
-
-    if (dbit_off) {
-      mlib_s32 nume = 8 - dbit_off;
-
-      if (nume > width)
-        nume = width;
-      dst0 = 0;
-      emask = 0;
-
-      for (; j <= (nume - 2); j += 2) {
-        emask |= (3 << (6 - (dbit_off + j)));
-        dst0 |= THRESH1_CMP_SHIFT(psrc_row[j], thresh0, 7 - (dbit_off + j));
-        dst0 |= THRESH1_CMP_SHIFT(psrc_row[j + 1], thresh1, 6 - (dbit_off + j));
-      }
-
-      if (j < nume) {
-        emask |= (1 << (7 - (dbit_off + j)));
-        dst0 |= THRESH1_CMP_SHIFT(psrc_row[j], thresh0, 7 - (dbit_off + j));
-        /* swap threshes */
-        thresh0 = thresh[1];
-        thresh1 = thresh[0];
-        j++;
-      }
-
-      dst0 = (mhigh & dst0) | (mlow & ~dst0);
-      pdst_row[0] = (dst0 & emask) | (pdst_row[0] & ~emask);
-      jbit++;
-    }
-
-#ifdef __SUNPRO_C
-#pragma pipeloop(0)
-#endif /* __SUNPRO_C */
-    for (; j <= (width - 16); j += 16) {
-      dst0 = THRESH1_CMP_SHIFT(psrc_row[j], thresh0, 7) |
-        THRESH1_CMP_SHIFT(psrc_row[j + 1], thresh1, 6) |
-        THRESH1_CMP_SHIFT(psrc_row[j + 2], thresh0, 5) |
-        THRESH1_CMP_SHIFT(psrc_row[j + 3], thresh1, 4) |
-        THRESH1_CMP_SHIFT(psrc_row[j + 4], thresh0, 3) |
-        THRESH1_CMP_SHIFT(psrc_row[j + 5], thresh1, 2) |
-        THRESH1_CMP_SHIFT(psrc_row[j + 6], thresh0, 1) |
-        THRESH1_CMP_SHIFT(psrc_row[j + 7], thresh1, 0);
-      dst0 = (mhigh & dst0) | (mlow & ~dst0);
-      *(pdst_row + jbit) = (mlib_u8) dst0;
-      jbit++;
-      dst0 = THRESH1_CMP_SHIFT(psrc_row[j + 8], thresh0, 7) |
-        THRESH1_CMP_SHIFT(psrc_row[j + 9], thresh1, 6) |
-        THRESH1_CMP_SHIFT(psrc_row[j + 10], thresh0, 5) |
-        THRESH1_CMP_SHIFT(psrc_row[j + 11], thresh1, 4) |
-        THRESH1_CMP_SHIFT(psrc_row[j + 12], thresh0, 3) |
-        THRESH1_CMP_SHIFT(psrc_row[j + 13], thresh1, 2) |
-        THRESH1_CMP_SHIFT(psrc_row[j + 14], thresh0, 1) |
-        THRESH1_CMP_SHIFT(psrc_row[j + 15], thresh1, 0);
-      dst0 = (mhigh & dst0) | (mlow & ~dst0);
-      *(pdst_row + jbit) = (mlib_u8) dst0;
-      jbit++;
-    }
-
-    if (width - j >= 8) {
-      dst0 = THRESH1_CMP_SHIFT(psrc_row[j], thresh0, 7) |
-        THRESH1_CMP_SHIFT(psrc_row[j + 1], thresh1, 6) |
-        THRESH1_CMP_SHIFT(psrc_row[j + 2], thresh0, 5) |
-        THRESH1_CMP_SHIFT(psrc_row[j + 3], thresh1, 4) |
-        THRESH1_CMP_SHIFT(psrc_row[j + 4], thresh0, 3) |
-        THRESH1_CMP_SHIFT(psrc_row[j + 5], thresh1, 2) |
-        THRESH1_CMP_SHIFT(psrc_row[j + 6], thresh0, 1) |
-        THRESH1_CMP_SHIFT(psrc_row[j + 7], thresh1, 0);
-      dst0 = (mhigh & dst0) | (mlow & ~dst0);
-      *(pdst_row + jbit) = (mlib_u8) dst0;
-      jbit++;
-      j += 8;
-    }
-
-    if (j < width) {
-      dst0 = 0;
-      l = 7;
-      for (; j <= (width - 2); j += 2) {
-        dst0 |= THRESH1_CMP_SHIFT(psrc_row[j], thresh0, l);
-        dst0 |= THRESH1_CMP_SHIFT(psrc_row[j + 1], thresh1, l - 1);
-        l -= 2;
-      }
-
-      if (j < width) {
-        dst0 |= THRESH1_CMP_SHIFT(psrc_row[j], thresh0, l);
-        l--;
-      }
-
-      emask = (0xFF << (l + 1));
-      dst0 = (mhigh & dst0) | (mlow & ~dst0);
-      pdst_row[jbit] = (dst0 & emask) | (pdst_row[jbit] & ~emask);
-    }
-
-    psrc_row += src_stride;
-    pdst_row += dst_stride;
-  }
-}
-
-/***************************************************************/
-void mlib_c_ImageThresh1_U83_1B(PARAMS,
-                                mlib_s32 dbit_off)
-{
-  mlib_s32 *thresh = (void *)__thresh;
-  mlib_s32 *ghigh = (void *)__ghigh;
-  mlib_s32 *glow = (void *)__glow;
-  STYPE *psrc_row = psrc;
-  mlib_u8 *pdst_row = pdst;
-  TTYPE thresh0, thresh1, thresh2, threshT;
-  mlib_s32 mhigh = 0, mlow = 0;
-  mlib_s32 mhigh0, mlow0, mhigh1, mlow1, mhigh2, mlow2, emask, dst0, dst1;
-  mlib_s32 i, j, jbit, k, l;
-
-  if (ghigh[0] > 0)
-    mhigh = 0x492492;
-
-  if (ghigh[1] > 0)
-    mhigh |= 0x249249;
-
-  if (ghigh[2] > 0)
-    mhigh |= 0x924924;
-
-  if (glow[0] > 0)
-    mlow = 0x492492;
-
-  if (glow[1] > 0)
-    mlow |= 0x249249;
-
-  if (glow[2] > 0)
-    mlow |= 0x924924;
-
-  width = 3 * width;
-
-  for (i = 0; i < height; i++) {
-    thresh0 = thresh[0];
-    thresh1 = thresh[1];
-    thresh2 = thresh[2];
-
-    j = 0;
-    jbit = 0;
-    mhigh0 = mhigh >> (dbit_off & 7);
-    mlow0 = mlow >> (dbit_off & 7);
-    mhigh1 = mhigh0 >> 1;
-    mlow1 = mlow0 >> 1;
-    mhigh2 = mhigh0 >> 2;
-    mlow2 = mlow0 >> 2;
-
-    if (dbit_off) {
-      mlib_s32 nume = 8 - dbit_off;
-
-      if (nume > width)
-        nume = width;
-      dst0 = 0;
-      emask = 0;
-
-      for (; j <= (nume - 3); j += 3) {
-        emask |= (7 << (5 - (dbit_off + j)));
-        dst0 |= THRESH1_CMP_SHIFT(psrc_row[j], thresh0, 7 - (dbit_off + j));
-        dst0 |= THRESH1_CMP_SHIFT(psrc_row[j + 1], thresh1, 6 - (dbit_off + j));
-        dst0 |= THRESH1_CMP_SHIFT(psrc_row[j + 2], thresh2, 5 - (dbit_off + j));
-      }
-
-      for (; j < nume; j++) {
-        emask |= (1 << (7 - (dbit_off + j)));
-        dst0 |= THRESH1_CMP_SHIFT(psrc_row[j], thresh0, 7 - (dbit_off + j));
-        /* swap threshes */
-        threshT = thresh0;
-        thresh0 = thresh1;
-        thresh1 = thresh2;
-        thresh2 = threshT;
-      }
-
-      dst0 = (mhigh0 & dst0) | (mlow0 & ~dst0);
-      pdst_row[0] = (dst0 & emask) | (pdst_row[0] & ~emask);
-      jbit++;
-
-      mhigh0 = mhigh >> (9 - nume);
-      mlow0 = mlow >> (9 - nume);
-      mhigh1 = mhigh0 >> 1;
-      mlow1 = mlow0 >> 1;
-      mhigh2 = mhigh0 >> 2;
-      mlow2 = mlow0 >> 2;
-    }
-
-#ifdef __SUNPRO_C
-#pragma pipeloop(0)
-#endif /* __SUNPRO_C */
-    for (; j <= (width - 24); j += 24) {
-      dst0 = (THRESH1_CMP_SHIFT(psrc_row[j], thresh0, 7) |
-              THRESH1_CMP_SHIFT(psrc_row[j + 1], thresh1, 6) |
-              THRESH1_CMP_SHIFT(psrc_row[j + 2], thresh2, 5) |
-              THRESH1_CMP_SHIFT(psrc_row[j + 3], thresh0, 4) |
-              THRESH1_CMP_SHIFT(psrc_row[j + 4], thresh1, 3) |
-              THRESH1_CMP_SHIFT(psrc_row[j + 5], thresh2, 2) |
-              THRESH1_CMP_SHIFT(psrc_row[j + 6], thresh0, 1) |
-              THRESH1_CMP_SHIFT(psrc_row[j + 7], thresh1, 0));
-      dst0 = (mhigh0 & dst0) | (mlow0 & ~dst0);
-      *(pdst_row + jbit) = dst0;
-      jbit++;
-      dst0 = (THRESH1_CMP_SHIFT(psrc_row[j + 8], thresh2, 7) |
-              THRESH1_CMP_SHIFT(psrc_row[j + 9], thresh0, 6) |
-              THRESH1_CMP_SHIFT(psrc_row[j + 10], thresh1, 5) |
-              THRESH1_CMP_SHIFT(psrc_row[j + 11], thresh2, 4) |
-              THRESH1_CMP_SHIFT(psrc_row[j + 12], thresh0, 3) |
-              THRESH1_CMP_SHIFT(psrc_row[j + 13], thresh1, 2) |
-              THRESH1_CMP_SHIFT(psrc_row[j + 14], thresh2, 1) |
-              THRESH1_CMP_SHIFT(psrc_row[j + 15], thresh0, 0));
-      dst0 = (mhigh1 & dst0) | (mlow1 & ~dst0);
-      *(pdst_row + jbit) = dst0;
-      jbit++;
-      dst0 = (THRESH1_CMP_SHIFT(psrc_row[j + 16], thresh1, 7) |
-              THRESH1_CMP_SHIFT(psrc_row[j + 17], thresh2, 6) |
-              THRESH1_CMP_SHIFT(psrc_row[j + 18], thresh0, 5) |
-              THRESH1_CMP_SHIFT(psrc_row[j + 19], thresh1, 4) |
-              THRESH1_CMP_SHIFT(psrc_row[j + 20], thresh2, 3) |
-              THRESH1_CMP_SHIFT(psrc_row[j + 21], thresh0, 2) |
-              THRESH1_CMP_SHIFT(psrc_row[j + 22], thresh1, 1) |
-              THRESH1_CMP_SHIFT(psrc_row[j + 23], thresh2, 0));
-      dst0 = (mhigh2 & dst0) | (mlow2 & ~dst0);
-      *(pdst_row + jbit) = dst0;
-      jbit++;
-    }
-
-    if (j < width) {
-      k = width - j;
-      dst0 = 0;
-      l = 31;
-      for (; j < width; j += 3) {
-        dst0 |= (THRESH1_CMP_SHIFT(psrc_row[j], thresh0, l) |
-                 THRESH1_CMP_SHIFT(psrc_row[j + 1], thresh1, l - 1) |
-                 THRESH1_CMP_SHIFT(psrc_row[j + 2], thresh2, l - 2));
-        l -= 3;
-      }
-
-      l = (k + 7) >> 3;
-      k = (l << 3) - k;
-      emask = (0xFF << k);
-
-      if (l == 3) {
-        dst1 = dst0 >> 24;
-        dst1 = (mhigh0 & dst1) | (mlow0 & ~dst1);
-        pdst_row[jbit] = dst1;
-        dst1 = (dst0 >> 16);
-        dst1 = (mhigh1 & dst1) | (mlow1 & ~dst1);
-        pdst_row[jbit + 1] = dst1;
-        dst1 = (dst0 >> 8);
-        dst1 = (mhigh2 & dst1) | (mlow2 & ~dst1);
-        pdst_row[jbit + 2] = (dst1 & emask) | (pdst_row[jbit + 2] & ~emask);
-      }
-      else if (l == 2) {
-        dst1 = dst0 >> 24;
-        dst1 = (mhigh0 & dst1) | (mlow0 & ~dst1);
-        pdst_row[jbit] = dst1;
-        dst1 = (dst0 >> 16);
-        dst1 = (mhigh1 & dst1) | (mlow1 & ~dst1);
-        pdst_row[jbit + 1] = (dst1 & emask) | (pdst_row[jbit + 1] & ~emask);
-      }
-      else {
-        dst1 = dst0 >> 24;
-        dst1 = (mhigh0 & dst1) | (mlow0 & ~dst1);
-        pdst_row[jbit] = (dst1 & emask) | (pdst_row[jbit] & ~emask);
-      }
-    }
-
-    psrc_row += src_stride;
-    pdst_row += dst_stride;
-  }
-}
-
-/***************************************************************/
-void mlib_c_ImageThresh1_U84_1B(PARAMS,
-                                mlib_s32 dbit_off)
-{
-  mlib_s32 *thresh = (void *)__thresh;
-  mlib_s32 *ghigh = (void *)__ghigh;
-  mlib_s32 *glow = (void *)__glow;
-  STYPE *psrc_row = psrc;
-  mlib_u8 *pdst_row = pdst;
-  TTYPE thresh0, thresh1, thresh2, thresh3, threshT;
-  mlib_s32 mhigh0, mlow0, mhigh, mlow, emask, dst0;
-  mlib_s32 i, j, jbit;
-
-  mhigh0 = (ghigh[0] > 0) ? 0x8888 : 0;
-  mhigh0 |= (ghigh[1] > 0) ? 0x4444 : 0;
-  mhigh0 |= (ghigh[2] > 0) ? 0x2222 : 0;
-  mhigh0 |= (ghigh[3] > 0) ? 0x1111 : 0;
-
-  mlow0 = (glow[0] > 0) ? 0x8888 : 0;
-  mlow0 |= (glow[1] > 0) ? 0x4444 : 0;
-  mlow0 |= (glow[2] > 0) ? 0x2222 : 0;
-  mlow0 |= (glow[3] > 0) ? 0x1111 : 0;
-
-  width *= 4;
-
-  for (i = 0; i < height; i++) {
-    thresh0 = thresh[0];
-    thresh1 = thresh[1];
-    thresh2 = thresh[2];
-    thresh3 = thresh[3];
-
-    j = 0;
-    jbit = 0;
-    mhigh = mhigh0 >> dbit_off;
-    mlow = mlow0 >> dbit_off;
-
-    if (dbit_off) {
-      mlib_s32 nume = 8 - dbit_off;
-
-      if (nume > width)
-        nume = width;
-      dst0 = 0;
-      emask = 0;
-
-      for (; j <= (nume - 4); j += 4) {
-        emask |= (0xf << (4 - (dbit_off + j)));
-        dst0 |= THRESH1_CMP_SHIFT(psrc_row[j], thresh0, 7 - (dbit_off + j));
-        dst0 |= THRESH1_CMP_SHIFT(psrc_row[j + 1], thresh1, 6 - (dbit_off + j));
-        dst0 |= THRESH1_CMP_SHIFT(psrc_row[j + 2], thresh2, 5 - (dbit_off + j));
-        dst0 |= THRESH1_CMP_SHIFT(psrc_row[j + 3], thresh3, 4 - (dbit_off + j));
-      }
-
-      for (; j < nume; j++) {
-        emask |= (1 << (7 - (dbit_off + j)));
-        dst0 |= THRESH1_CMP_SHIFT(psrc_row[j], thresh0, 7 - (dbit_off + j));
-        /* swap threshes */
-        threshT = thresh0;
-        thresh0 = thresh1;
-        thresh1 = thresh2;
-        thresh2 = thresh3;
-        thresh3 = threshT;
-      }
-
-      dst0 = (mhigh & dst0) | (mlow & ~dst0);
-      pdst_row[0] = (dst0 & emask) | (pdst_row[0] & ~emask);
-      jbit++;
-    }
-
-#ifdef __SUNPRO_C
-#pragma pipeloop(0)
-#endif /* __SUNPRO_C */
-    for (; j <= (width - 16); j += 16) {
-      dst0 = (THRESH1_CMP_SHIFT(psrc_row[j], thresh0, 7) |
-              THRESH1_CMP_SHIFT(psrc_row[j + 1], thresh1, 6) |
-              THRESH1_CMP_SHIFT(psrc_row[j + 2], thresh2, 5) |
-              THRESH1_CMP_SHIFT(psrc_row[j + 3], thresh3, 4) |
-              THRESH1_CMP_SHIFT(psrc_row[j + 4], thresh0, 3) |
-              THRESH1_CMP_SHIFT(psrc_row[j + 5], thresh1, 2) |
-              THRESH1_CMP_SHIFT(psrc_row[j + 6], thresh2, 1) |
-              THRESH1_CMP_SHIFT(psrc_row[j + 7], thresh3, 0));
-      dst0 = (mhigh & dst0) | (mlow & ~dst0);
-      pdst_row[jbit] = dst0;
-      jbit++;
-      dst0 = (THRESH1_CMP_SHIFT(psrc_row[j + 8], thresh0, 7) |
-              THRESH1_CMP_SHIFT(psrc_row[j + 9], thresh1, 6) |
-              THRESH1_CMP_SHIFT(psrc_row[j + 10], thresh2, 5) |
-              THRESH1_CMP_SHIFT(psrc_row[j + 11], thresh3, 4) |
-              THRESH1_CMP_SHIFT(psrc_row[j + 12], thresh0, 3) |
-              THRESH1_CMP_SHIFT(psrc_row[j + 13], thresh1, 2) |
-              THRESH1_CMP_SHIFT(psrc_row[j + 14], thresh2, 1) |
-              THRESH1_CMP_SHIFT(psrc_row[j + 15], thresh3, 0));
-      dst0 = (mhigh & dst0) | (mlow & ~dst0);
-      pdst_row[jbit] = dst0;
-      jbit++;
-    }
-
-    if (j <= width - 8) {
-      dst0 = (THRESH1_CMP_SHIFT(psrc_row[j], thresh0, 7) |
-              THRESH1_CMP_SHIFT(psrc_row[j + 1], thresh1, 6) |
-              THRESH1_CMP_SHIFT(psrc_row[j + 2], thresh2, 5) |
-              THRESH1_CMP_SHIFT(psrc_row[j + 3], thresh3, 4) |
-              THRESH1_CMP_SHIFT(psrc_row[j + 4], thresh0, 3) |
-              THRESH1_CMP_SHIFT(psrc_row[j + 5], thresh1, 2) |
-              THRESH1_CMP_SHIFT(psrc_row[j + 6], thresh2, 1) |
-              THRESH1_CMP_SHIFT(psrc_row[j + 7], thresh3, 0));
-      dst0 = (mhigh & dst0) | (mlow & ~dst0);
-      pdst_row[jbit] = dst0;
-      jbit++;
-      j += 8;
-    }
-
-    if (j < width) {
-      dst0 = (THRESH1_CMP_SHIFT(psrc_row[j], thresh0, 7) |
-              THRESH1_CMP_SHIFT(psrc_row[j + 1], thresh1, 6) |
-              THRESH1_CMP_SHIFT(psrc_row[j + 2], thresh2, 5) |
-              THRESH1_CMP_SHIFT(psrc_row[j + 3], thresh3, 4) |
-              THRESH1_CMP_SHIFT(psrc_row[j + 4], thresh0, 3) |
-              THRESH1_CMP_SHIFT(psrc_row[j + 5], thresh1, 2) |
-              THRESH1_CMP_SHIFT(psrc_row[j + 6], thresh2, 1));
-
-      emask = (0xFF << (8 - (width - j)));
-      dst0 = (mhigh & dst0) | (mlow & ~dst0);
-      pdst_row[jbit] = (dst0 & emask) | (pdst_row[jbit] & ~emask);
-    }
-
-    psrc_row += src_stride;
-    pdst_row += dst_stride;
-  }
-}
-
-/***************************************************************/
--- a/jdk/src/java.desktop/share/native/libmlib_image/mlib_image.h	Thu May 19 17:48:02 2016 +0000
+++ b/jdk/src/java.desktop/share/native/libmlib_image/mlib_image.h	Thu May 19 19:46:20 2016 +0000
@@ -35,7 +35,6 @@
 #include <mlib_sys.h>
 #include <mlib_image_types.h>
 #include <mlib_image_proto.h>
-#include <mlib_image_blend_proto.h>
 #include <mlib_image_get.h>
 
 #endif  /* MLIB_IMAGE_H */
--- a/jdk/src/java.desktop/share/native/libmlib_image/mlib_image_blend_proto.h	Thu May 19 17:48:02 2016 +0000
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,1448 +0,0 @@
-/*
- * Copyright (c) 1998, 2003, 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.
- */
-
-
-#ifndef __ORIG_MLIB_IMAGE_BLEND_PROTO_H
-#define __ORIG_MLIB_IMAGE_BLEND_PROTO_H
-
-#include <mlib_types.h>
-#include <mlib_status.h>
-#include <mlib_image_types.h>
-#if defined ( __MEDIALIB_OLD_NAMES_ADDED )
-#include <../include/mlib_image_blend_proto.h>
-#endif /* defined ( __MEDIALIB_OLD_NAMES_ADDED ) */
-
-#ifdef __cplusplus
-extern "C" {
-#endif /* __cplusplus */
-
-#if defined ( _MSC_VER )
-#if ! defined ( __MEDIALIB_OLD_NAMES )
-#define __MEDIALIB_OLD_NAMES
-#endif /* ! defined ( __MEDIALIB_OLD_NAMES ) */
-#endif /* defined ( _MSC_VER ) */
-
-/***********************************************************************
-
-    NOTE: f = min(ALPHAsrc2, 1 - ALPHAsrc1)
-          f = min(ALPHAscr2, 1 - ALPHAsrc1dst) for In-place function
-          ALPHA = (ALPHA, ALPHA, ALPHA, ALPHA)
-
-************************************************************************/
-
-/* dst = 0 */
-
-#if defined ( __MEDIALIB_OLD_NAMES )
-#define __mlib_ImageBlend_ZERO_ZERO mlib_ImageBlend_ZERO_ZERO
-#endif /* ! defined ( __MEDIALIB_OLD_NAMES ) */
-mlib_status  __mlib_ImageBlend_ZERO_ZERO(mlib_image *dst,
-                                         const mlib_image *src1,
-                                         const mlib_image *src2,
-                                         mlib_s32 cmask);
-
-/* src1dst = 0 */
-
-#if defined ( __MEDIALIB_OLD_NAMES )
-#define __mlib_ImageBlend_ZERO_ZERO_Inp mlib_ImageBlend_ZERO_ZERO_Inp
-#endif /* ! defined ( __MEDIALIB_OLD_NAMES ) */
-mlib_status  __mlib_ImageBlend_ZERO_ZERO_Inp(mlib_image *src1dst,
-                                             const mlib_image *src2,
-                                             mlib_s32 cmask);
-
-/* dst = src2 */
-
-#if defined ( __MEDIALIB_OLD_NAMES )
-#define __mlib_ImageBlend_ZERO_ONE mlib_ImageBlend_ZERO_ONE
-#endif /* ! defined ( __MEDIALIB_OLD_NAMES ) */
-mlib_status  __mlib_ImageBlend_ZERO_ONE(mlib_image *dst,
-                                        const mlib_image *src1,
-                                        const mlib_image *src2,
-                                        mlib_s32 cmask);
-
-/* src1dst = src2 */
-
-#if defined ( __MEDIALIB_OLD_NAMES )
-#define __mlib_ImageBlend_ZERO_ONE_Inp mlib_ImageBlend_ZERO_ONE_Inp
-#endif /* ! defined ( __MEDIALIB_OLD_NAMES ) */
-mlib_status  __mlib_ImageBlend_ZERO_ONE_Inp(mlib_image *src1dst,
-                                            const mlib_image *src2,
-                                            mlib_s32 cmask);
-
-/* dst = src2 * src1 */
-
-#if defined ( __MEDIALIB_OLD_NAMES )
-#define __mlib_ImageBlend_ZERO_DC mlib_ImageBlend_ZERO_DC
-#endif /* ! defined ( __MEDIALIB_OLD_NAMES ) */
-mlib_status  __mlib_ImageBlend_ZERO_DC(mlib_image *dst,
-                                       const mlib_image *src1,
-                                       const mlib_image *src2,
-                                       mlib_s32 cmask);
-
-/* src1dst = src2 * src1dst */
-
-#if defined ( __MEDIALIB_OLD_NAMES )
-#define __mlib_ImageBlend_ZERO_DC_Inp mlib_ImageBlend_ZERO_DC_Inp
-#endif /* ! defined ( __MEDIALIB_OLD_NAMES ) */
-mlib_status  __mlib_ImageBlend_ZERO_DC_Inp(mlib_image *src1dst,
-                                           const mlib_image *src2,
-                                           mlib_s32 cmask);
-
-/* dst = src2 * (1 - src1) */
-
-#if defined ( __MEDIALIB_OLD_NAMES )
-#define __mlib_ImageBlend_ZERO_OMDC mlib_ImageBlend_ZERO_OMDC
-#endif /* ! defined ( __MEDIALIB_OLD_NAMES ) */
-mlib_status  __mlib_ImageBlend_ZERO_OMDC(mlib_image *dst,
-                                         const mlib_image *src1,
-                                         const mlib_image *src2,
-                                         mlib_s32 cmask);
-
-/* src1dst = src2 * (1 - src1dst) */
-
-#if defined ( __MEDIALIB_OLD_NAMES )
-#define __mlib_ImageBlend_ZERO_OMDC_Inp mlib_ImageBlend_ZERO_OMDC_Inp
-#endif /* ! defined ( __MEDIALIB_OLD_NAMES ) */
-mlib_status  __mlib_ImageBlend_ZERO_OMDC_Inp(mlib_image *src1dst,
-                                             const mlib_image *src2,
-                                             mlib_s32 cmask);
-
-/* dst = src2 * ALPHAsrc2 */
-
-#if defined ( __MEDIALIB_OLD_NAMES )
-#define __mlib_ImageBlend_ZERO_SA mlib_ImageBlend_ZERO_SA
-#endif /* ! defined ( __MEDIALIB_OLD_NAMES ) */
-mlib_status  __mlib_ImageBlend_ZERO_SA(mlib_image *dst,
-                                       const mlib_image *src1,
-                                       const mlib_image *src2,
-                                       mlib_s32 cmask);
-
-/* src1dst = src2 * ALPHAsrc2 */
-
-#if defined ( __MEDIALIB_OLD_NAMES )
-#define __mlib_ImageBlend_ZERO_SA_Inp mlib_ImageBlend_ZERO_SA_Inp
-#endif /* ! defined ( __MEDIALIB_OLD_NAMES ) */
-mlib_status  __mlib_ImageBlend_ZERO_SA_Inp(mlib_image *src1dst,
-                                           const mlib_image *src2,
-                                           mlib_s32 cmask);
-
-/* dst = src2 * (1 - ALPHAsrc2) */
-
-#if defined ( __MEDIALIB_OLD_NAMES )
-#define __mlib_ImageBlend_ZERO_OMSA mlib_ImageBlend_ZERO_OMSA
-#endif /* ! defined ( __MEDIALIB_OLD_NAMES ) */
-mlib_status  __mlib_ImageBlend_ZERO_OMSA(mlib_image *dst,
-                                         const mlib_image *src1,
-                                         const mlib_image *src2,
-                                         mlib_s32 cmask);
-
-/* src1dst = src2 * (1 - ALPHAsrc2) */
-
-#if defined ( __MEDIALIB_OLD_NAMES )
-#define __mlib_ImageBlend_ZERO_OMSA_Inp mlib_ImageBlend_ZERO_OMSA_Inp
-#endif /* ! defined ( __MEDIALIB_OLD_NAMES ) */
-mlib_status  __mlib_ImageBlend_ZERO_OMSA_Inp(mlib_image *src1dst,
-                                             const mlib_image *src2,
-                                             mlib_s32 cmask);
-
-/* dst = src2 * ALPHAsrc1 */
-
-#if defined ( __MEDIALIB_OLD_NAMES )
-#define __mlib_ImageBlend_ZERO_DA mlib_ImageBlend_ZERO_DA
-#endif /* ! defined ( __MEDIALIB_OLD_NAMES ) */
-mlib_status  __mlib_ImageBlend_ZERO_DA(mlib_image *dst,
-                                       const mlib_image *src1,
-                                       const mlib_image *src2,
-                                       mlib_s32 cmask);
-
-/* src1dst = src2 * ALPHAsrc1dst */
-
-#if defined ( __MEDIALIB_OLD_NAMES )
-#define __mlib_ImageBlend_ZERO_DA_Inp mlib_ImageBlend_ZERO_DA_Inp
-#endif /* ! defined ( __MEDIALIB_OLD_NAMES ) */
-mlib_status  __mlib_ImageBlend_ZERO_DA_Inp(mlib_image *src1dst,
-                                           const mlib_image *src2,
-                                           mlib_s32 cmask);
-
-/* dst = src2 * (1 - ALPHAsrc1) */
-
-#if defined ( __MEDIALIB_OLD_NAMES )
-#define __mlib_ImageBlend_ZERO_OMDA mlib_ImageBlend_ZERO_OMDA
-#endif /* ! defined ( __MEDIALIB_OLD_NAMES ) */
-mlib_status  __mlib_ImageBlend_ZERO_OMDA(mlib_image *dst,
-                                         const mlib_image *src1,
-                                         const mlib_image *src2,
-                                         mlib_s32 cmask);
-
-/* src1dst = src2 * (1 - ALPHAsrc1dst) */
-
-#if defined ( __MEDIALIB_OLD_NAMES )
-#define __mlib_ImageBlend_ZERO_OMDA_Inp mlib_ImageBlend_ZERO_OMDA_Inp
-#endif /* ! defined ( __MEDIALIB_OLD_NAMES ) */
-mlib_status  __mlib_ImageBlend_ZERO_OMDA_Inp(mlib_image *src1dst,
-                                             const mlib_image *src2,
-                                             mlib_s32 cmask);
-
-/* dst = src2 * (f, f, f, 1) */
-
-#if defined ( __MEDIALIB_OLD_NAMES )
-#define __mlib_ImageBlend_ZERO_SAS mlib_ImageBlend_ZERO_SAS
-#endif /* ! defined ( __MEDIALIB_OLD_NAMES ) */
-mlib_status  __mlib_ImageBlend_ZERO_SAS(mlib_image *dst,
-                                        const mlib_image *src1,
-                                        const mlib_image *src2,
-                                        mlib_s32 cmask);
-
-/* src1dst = src2 * (f, f, f, 1) */
-
-#if defined ( __MEDIALIB_OLD_NAMES )
-#define __mlib_ImageBlend_ZERO_SAS_Inp mlib_ImageBlend_ZERO_SAS_Inp
-#endif /* ! defined ( __MEDIALIB_OLD_NAMES ) */
-mlib_status  __mlib_ImageBlend_ZERO_SAS_Inp(mlib_image *src1dst,
-                                            const mlib_image *src2,
-                                            mlib_s32 cmask);
-
-/* dst = src1 */
-
-#if defined ( __MEDIALIB_OLD_NAMES )
-#define __mlib_ImageBlend_ONE_ZERO mlib_ImageBlend_ONE_ZERO
-#endif /* ! defined ( __MEDIALIB_OLD_NAMES ) */
-mlib_status  __mlib_ImageBlend_ONE_ZERO(mlib_image *dst,
-                                        const mlib_image *src1,
-                                        const mlib_image *src2,
-                                        mlib_s32 cmask);
-
-/* src1dst = src1dst */
-
-#if defined ( __MEDIALIB_OLD_NAMES )
-#define __mlib_ImageBlend_ONE_ZERO_Inp mlib_ImageBlend_ONE_ZERO_Inp
-#endif /* ! defined ( __MEDIALIB_OLD_NAMES ) */
-mlib_status  __mlib_ImageBlend_ONE_ZERO_Inp(mlib_image *src1dst,
-                                            const mlib_image *src2,
-                                            mlib_s32 cmask);
-
-/* dst = src1 + src2 */
-
-#if defined ( __MEDIALIB_OLD_NAMES )
-#define __mlib_ImageBlend_ONE_ONE mlib_ImageBlend_ONE_ONE
-#endif /* ! defined ( __MEDIALIB_OLD_NAMES ) */
-mlib_status  __mlib_ImageBlend_ONE_ONE(mlib_image *dst,
-                                       const mlib_image *src1,
-                                       const mlib_image *src2,
-                                       mlib_s32 cmask);
-
-/* src1dst = src1dst + src2 */
-
-#if defined ( __MEDIALIB_OLD_NAMES )
-#define __mlib_ImageBlend_ONE_ONE_Inp mlib_ImageBlend_ONE_ONE_Inp
-#endif /* ! defined ( __MEDIALIB_OLD_NAMES ) */
-mlib_status  __mlib_ImageBlend_ONE_ONE_Inp(mlib_image *src1dst,
-                                           const mlib_image *src2,
-                                           mlib_s32 cmask);
-
-/* dst = src1 * (1 + src2) */
-
-#if defined ( __MEDIALIB_OLD_NAMES )
-#define __mlib_ImageBlend_ONE_DC mlib_ImageBlend_ONE_DC
-#endif /* ! defined ( __MEDIALIB_OLD_NAMES ) */
-mlib_status  __mlib_ImageBlend_ONE_DC(mlib_image *dst,
-                                      const mlib_image *src1,
-                                      const mlib_image *src2,
-                                      mlib_s32 cmask);
-
-/* src1dst = src1dst * (1 + src2) */
-
-#if defined ( __MEDIALIB_OLD_NAMES )
-#define __mlib_ImageBlend_ONE_DC_Inp mlib_ImageBlend_ONE_DC_Inp
-#endif /* ! defined ( __MEDIALIB_OLD_NAMES ) */
-mlib_status  __mlib_ImageBlend_ONE_DC_Inp(mlib_image *src1dst,
-                                          const mlib_image *src2,
-                                          mlib_s32 cmask);
-
-/* dst = src2 + src1 * (1 - src2) */
-
-#if defined ( __MEDIALIB_OLD_NAMES )
-#define __mlib_ImageBlend_ONE_OMDC mlib_ImageBlend_ONE_OMDC
-#endif /* ! defined ( __MEDIALIB_OLD_NAMES ) */
-mlib_status  __mlib_ImageBlend_ONE_OMDC(mlib_image *dst,
-                                        const mlib_image *src1,
-                                        const mlib_image *src2,
-                                        mlib_s32 cmask);
-
-/* src1dst = src2 + src1dst * (1 - src2) */
-
-#if defined ( __MEDIALIB_OLD_NAMES )
-#define __mlib_ImageBlend_ONE_OMDC_Inp mlib_ImageBlend_ONE_OMDC_Inp
-#endif /* ! defined ( __MEDIALIB_OLD_NAMES ) */
-mlib_status  __mlib_ImageBlend_ONE_OMDC_Inp(mlib_image *src1dst,
-                                            const mlib_image *src2,
-                                            mlib_s32 cmask);
-
-/* dst = src1 + src2 * ALPHAsrc2 */
-
-#if defined ( __MEDIALIB_OLD_NAMES )
-#define __mlib_ImageBlend_ONE_SA mlib_ImageBlend_ONE_SA
-#endif /* ! defined ( __MEDIALIB_OLD_NAMES ) */
-mlib_status  __mlib_ImageBlend_ONE_SA(mlib_image *dst,
-                                      const mlib_image *src1,
-                                      const mlib_image *src2,
-                                      mlib_s32 cmask);
-
-/* src1dst = src1dst + src2 * ALPHAsrc2 */
-
-#if defined ( __MEDIALIB_OLD_NAMES )
-#define __mlib_ImageBlend_ONE_SA_Inp mlib_ImageBlend_ONE_SA_Inp
-#endif /* ! defined ( __MEDIALIB_OLD_NAMES ) */
-mlib_status  __mlib_ImageBlend_ONE_SA_Inp(mlib_image *src1dst,
-                                          const mlib_image *src2,
-                                          mlib_s32 cmask);
-
-/* dst = src1 + src2 * (1 - ALPHAsrc2) */
-
-#if defined ( __MEDIALIB_OLD_NAMES )
-#define __mlib_ImageBlend_ONE_OMSA mlib_ImageBlend_ONE_OMSA
-#endif /* ! defined ( __MEDIALIB_OLD_NAMES ) */
-mlib_status  __mlib_ImageBlend_ONE_OMSA(mlib_image *dst,
-                                        const mlib_image *src1,
-                                        const mlib_image *src2,
-                                        mlib_s32 cmask);
-
-/* src1dst = src1dst + src2 * (1 - ALPHAsrc2) */
-
-#if defined ( __MEDIALIB_OLD_NAMES )
-#define __mlib_ImageBlend_ONE_OMSA_Inp mlib_ImageBlend_ONE_OMSA_Inp
-#endif /* ! defined ( __MEDIALIB_OLD_NAMES ) */
-mlib_status  __mlib_ImageBlend_ONE_OMSA_Inp(mlib_image *src1dst,
-                                            const mlib_image *src2,
-                                            mlib_s32 cmask);
-
-/* dst = src1 + src2 * ALPHAsrc1 */
-
-#if defined ( __MEDIALIB_OLD_NAMES )
-#define __mlib_ImageBlend_ONE_DA mlib_ImageBlend_ONE_DA
-#endif /* ! defined ( __MEDIALIB_OLD_NAMES ) */
-mlib_status  __mlib_ImageBlend_ONE_DA(mlib_image *dst,
-                                      const mlib_image *src1,
-                                      const mlib_image *src2,
-                                      mlib_s32 cmask);
-
-/* src1dst = src1dst + src2 * ALPHAsrc1dst */
-
-#if defined ( __MEDIALIB_OLD_NAMES )
-#define __mlib_ImageBlend_ONE_DA_Inp mlib_ImageBlend_ONE_DA_Inp
-#endif /* ! defined ( __MEDIALIB_OLD_NAMES ) */
-mlib_status  __mlib_ImageBlend_ONE_DA_Inp(mlib_image *src1dst,
-                                          const mlib_image *src2,
-                                          mlib_s32 cmask);
-
-/* dst = src1 + src2 * (1 - ALPHAsrc1) */
-
-#if defined ( __MEDIALIB_OLD_NAMES )
-#define __mlib_ImageBlend_ONE_OMDA mlib_ImageBlend_ONE_OMDA
-#endif /* ! defined ( __MEDIALIB_OLD_NAMES ) */
-mlib_status  __mlib_ImageBlend_ONE_OMDA(mlib_image *dst,
-                                        const mlib_image *src1,
-                                        const mlib_image *src2,
-                                        mlib_s32 cmask);
-
-/* src1dst = src1dst + src2 * (1 - ALPHAsrc1dst) */
-
-#if defined ( __MEDIALIB_OLD_NAMES )
-#define __mlib_ImageBlend_ONE_OMDA_Inp mlib_ImageBlend_ONE_OMDA_Inp
-#endif /* ! defined ( __MEDIALIB_OLD_NAMES ) */
-mlib_status  __mlib_ImageBlend_ONE_OMDA_Inp(mlib_image *src1dst,
-                                            const mlib_image *src2,
-                                            mlib_s32 cmask);
-
-/* dst = src1 + src2 * (f, f, f, 1) */
-
-#if defined ( __MEDIALIB_OLD_NAMES )
-#define __mlib_ImageBlend_ONE_SAS mlib_ImageBlend_ONE_SAS
-#endif /* ! defined ( __MEDIALIB_OLD_NAMES ) */
-mlib_status  __mlib_ImageBlend_ONE_SAS(mlib_image *dst,
-                                       const mlib_image *src1,
-                                       const mlib_image *src2,
-                                       mlib_s32 cmask);
-
-/* src1dst = src1dst + src2 * (f, f, f, 1) */
-
-#if defined ( __MEDIALIB_OLD_NAMES )
-#define __mlib_ImageBlend_ONE_SAS_Inp mlib_ImageBlend_ONE_SAS_Inp
-#endif /* ! defined ( __MEDIALIB_OLD_NAMES ) */
-mlib_status  __mlib_ImageBlend_ONE_SAS_Inp(mlib_image *src1dst,
-                                           const mlib_image *src2,
-                                           mlib_s32 cmask);
-
-/* dst = src1 * src2 */
-
-#if defined ( __MEDIALIB_OLD_NAMES )
-#define __mlib_ImageBlend_SC_ZERO mlib_ImageBlend_SC_ZERO
-#endif /* ! defined ( __MEDIALIB_OLD_NAMES ) */
-mlib_status  __mlib_ImageBlend_SC_ZERO(mlib_image *dst,
-                                       const mlib_image *src1,
-                                       const mlib_image *src2,
-                                       mlib_s32 cmask);
-
-/* src1dst = src1dst * src2 */
-
-#if defined ( __MEDIALIB_OLD_NAMES )
-#define __mlib_ImageBlend_SC_ZERO_Inp mlib_ImageBlend_SC_ZERO_Inp
-#endif /* ! defined ( __MEDIALIB_OLD_NAMES ) */
-mlib_status  __mlib_ImageBlend_SC_ZERO_Inp(mlib_image *src1dst,
-                                           const mlib_image *src2,
-                                           mlib_s32 cmask);
-
-/* dst = (src1 + 1) * src2 */
-
-#if defined ( __MEDIALIB_OLD_NAMES )
-#define __mlib_ImageBlend_SC_ONE mlib_ImageBlend_SC_ONE
-#endif /* ! defined ( __MEDIALIB_OLD_NAMES ) */
-mlib_status  __mlib_ImageBlend_SC_ONE(mlib_image *dst,
-                                      const mlib_image *src1,
-                                      const mlib_image *src2,
-                                      mlib_s32 cmask);
-
-/* src1dst = (src1dst + 1) * src2 */
-
-#if defined ( __MEDIALIB_OLD_NAMES )
-#define __mlib_ImageBlend_SC_ONE_Inp mlib_ImageBlend_SC_ONE_Inp
-#endif /* ! defined ( __MEDIALIB_OLD_NAMES ) */
-mlib_status  __mlib_ImageBlend_SC_ONE_Inp(mlib_image *src1dst,
-                                          const mlib_image *src2,
-                                          mlib_s32 cmask);
-
-/* dst = 2 * src1 * src2 */
-
-#if defined ( __MEDIALIB_OLD_NAMES )
-#define __mlib_ImageBlend_SC_DC mlib_ImageBlend_SC_DC
-#endif /* ! defined ( __MEDIALIB_OLD_NAMES ) */
-mlib_status  __mlib_ImageBlend_SC_DC(mlib_image *dst,
-                                     const mlib_image *src1,
-                                     const mlib_image *src2,
-                                     mlib_s32 cmask);
-
-/* src1dst = 2 * src1dst * src2 */
-
-#if defined ( __MEDIALIB_OLD_NAMES )
-#define __mlib_ImageBlend_SC_DC_Inp mlib_ImageBlend_SC_DC_Inp
-#endif /* ! defined ( __MEDIALIB_OLD_NAMES ) */
-mlib_status  __mlib_ImageBlend_SC_DC_Inp(mlib_image *src1dst,
-                                         const mlib_image *src2,
-                                         mlib_s32 cmask);
-
-/* dst = src2 */
-
-#if defined ( __MEDIALIB_OLD_NAMES )
-#define __mlib_ImageBlend_SC_OMDC mlib_ImageBlend_SC_OMDC
-#endif /* ! defined ( __MEDIALIB_OLD_NAMES ) */
-mlib_status  __mlib_ImageBlend_SC_OMDC(mlib_image *dst,
-                                       const mlib_image *src1,
-                                       const mlib_image *src2,
-                                       mlib_s32 cmask);
-
-/* src1dst = src2 */
-
-#if defined ( __MEDIALIB_OLD_NAMES )
-#define __mlib_ImageBlend_SC_OMDC_Inp mlib_ImageBlend_SC_OMDC_Inp
-#endif /* ! defined ( __MEDIALIB_OLD_NAMES ) */
-mlib_status  __mlib_ImageBlend_SC_OMDC_Inp(mlib_image *src1dst,
-                                           const mlib_image *src2,
-                                           mlib_s32 cmask);
-
-/* dst = src2 * (src1 + ALPHAsrc2) */
-
-#if defined ( __MEDIALIB_OLD_NAMES )
-#define __mlib_ImageBlend_SC_SA mlib_ImageBlend_SC_SA
-#endif /* ! defined ( __MEDIALIB_OLD_NAMES ) */
-mlib_status  __mlib_ImageBlend_SC_SA(mlib_image *dst,
-                                     const mlib_image *src1,
-                                     const mlib_image *src2,
-                                     mlib_s32 cmask);
-
-/* src1dst = src2 * (src1dst + ALPHAsrc2) */
-
-#if defined ( __MEDIALIB_OLD_NAMES )
-#define __mlib_ImageBlend_SC_SA_Inp mlib_ImageBlend_SC_SA_Inp
-#endif /* ! defined ( __MEDIALIB_OLD_NAMES ) */
-mlib_status  __mlib_ImageBlend_SC_SA_Inp(mlib_image *src1dst,
-                                         const mlib_image *src2,
-                                         mlib_s32 cmask);
-
-/* dst = src2 * (1 - ALPHAsrc2 + src1) */
-
-#if defined ( __MEDIALIB_OLD_NAMES )
-#define __mlib_ImageBlend_SC_OMSA mlib_ImageBlend_SC_OMSA
-#endif /* ! defined ( __MEDIALIB_OLD_NAMES ) */
-mlib_status  __mlib_ImageBlend_SC_OMSA(mlib_image *dst,
-                                       const mlib_image *src1,
-                                       const mlib_image *src2,
-                                       mlib_s32 cmask);
-
-/* src1dst = src2 * (1 - ALPHAsrc2 + src1dst) */
-
-#if defined ( __MEDIALIB_OLD_NAMES )
-#define __mlib_ImageBlend_SC_OMSA_Inp mlib_ImageBlend_SC_OMSA_Inp
-#endif /* ! defined ( __MEDIALIB_OLD_NAMES ) */
-mlib_status  __mlib_ImageBlend_SC_OMSA_Inp(mlib_image *src1dst,
-                                           const mlib_image *src2,
-                                           mlib_s32 cmask);
-
-/* dst = src2 * (src1 + ALPHAsrc1) */
-
-#if defined ( __MEDIALIB_OLD_NAMES )
-#define __mlib_ImageBlend_SC_DA mlib_ImageBlend_SC_DA
-#endif /* ! defined ( __MEDIALIB_OLD_NAMES ) */
-mlib_status  __mlib_ImageBlend_SC_DA(mlib_image *dst,
-                                     const mlib_image *src1,
-                                     const mlib_image *src2,
-                                     mlib_s32 cmask);
-
-/* src1dst = src2 * (src1dst + ALPHAsrc1dst) */
-
-#if defined ( __MEDIALIB_OLD_NAMES )
-#define __mlib_ImageBlend_SC_DA_Inp mlib_ImageBlend_SC_DA_Inp
-#endif /* ! defined ( __MEDIALIB_OLD_NAMES ) */
-mlib_status  __mlib_ImageBlend_SC_DA_Inp(mlib_image *src1dst,
-                                         const mlib_image *src2,
-                                         mlib_s32 cmask);
-
-/* dst = src2 * (1 - ALPHAsrc1 + src1) */
-
-#if defined ( __MEDIALIB_OLD_NAMES )
-#define __mlib_ImageBlend_SC_OMDA mlib_ImageBlend_SC_OMDA
-#endif /* ! defined ( __MEDIALIB_OLD_NAMES ) */
-mlib_status  __mlib_ImageBlend_SC_OMDA(mlib_image *dst,
-                                       const mlib_image *src1,
-                                       const mlib_image *src2,
-                                       mlib_s32 cmask);
-
-/* src1dst = src2 * (1 - ALPHAsrc1dst + src1dst) */
-
-#if defined ( __MEDIALIB_OLD_NAMES )
-#define __mlib_ImageBlend_SC_OMDA_Inp mlib_ImageBlend_SC_OMDA_Inp
-#endif /* ! defined ( __MEDIALIB_OLD_NAMES ) */
-mlib_status  __mlib_ImageBlend_SC_OMDA_Inp(mlib_image *src1dst,
-                                           const mlib_image *src2,
-                                           mlib_s32 cmask);
-
-/* dst = src2 * ((f, f, f, 1) + src1) */
-
-#if defined ( __MEDIALIB_OLD_NAMES )
-#define __mlib_ImageBlend_SC_SAS mlib_ImageBlend_SC_SAS
-#endif /* ! defined ( __MEDIALIB_OLD_NAMES ) */
-mlib_status  __mlib_ImageBlend_SC_SAS(mlib_image *dst,
-                                      const mlib_image *src1,
-                                      const mlib_image *src2,
-                                      mlib_s32 cmask);
-
-/* src1dst = src2 * ((f, f, f, 1) + src1dst) */
-
-#if defined ( __MEDIALIB_OLD_NAMES )
-#define __mlib_ImageBlend_SC_SAS_Inp mlib_ImageBlend_SC_SAS_Inp
-#endif /* ! defined ( __MEDIALIB_OLD_NAMES ) */
-mlib_status  __mlib_ImageBlend_SC_SAS_Inp(mlib_image *src1dst,
-                                          const mlib_image *src2,
-                                          mlib_s32 cmask);
-
-/* dst = src1 * (1 - src2) */
-
-#if defined ( __MEDIALIB_OLD_NAMES )
-#define __mlib_ImageBlend_OMSC_ZERO mlib_ImageBlend_OMSC_ZERO
-#endif /* ! defined ( __MEDIALIB_OLD_NAMES ) */
-mlib_status  __mlib_ImageBlend_OMSC_ZERO(mlib_image *dst,
-                                         const mlib_image *src1,
-                                         const mlib_image *src2,
-                                         mlib_s32 cmask);
-
-/* src1dst = src1dst * (1 - src2) */
-
-#if defined ( __MEDIALIB_OLD_NAMES )
-#define __mlib_ImageBlend_OMSC_ZERO_Inp mlib_ImageBlend_OMSC_ZERO_Inp
-#endif /* ! defined ( __MEDIALIB_OLD_NAMES ) */
-mlib_status  __mlib_ImageBlend_OMSC_ZERO_Inp(mlib_image *src1dst,
-                                             const mlib_image *src2,
-                                             mlib_s32 cmask);
-
-/* dst = src1 + src2 * (1 - src1) */
-
-#if defined ( __MEDIALIB_OLD_NAMES )
-#define __mlib_ImageBlend_OMSC_ONE mlib_ImageBlend_OMSC_ONE
-#endif /* ! defined ( __MEDIALIB_OLD_NAMES ) */
-mlib_status  __mlib_ImageBlend_OMSC_ONE(mlib_image *dst,
-                                        const mlib_image *src1,
-                                        const mlib_image *src2,
-                                        mlib_s32 cmask);
-
-/* src1dst = src1dst + src2 * (1 - src1dst) */
-
-#if defined ( __MEDIALIB_OLD_NAMES )
-#define __mlib_ImageBlend_OMSC_ONE_Inp mlib_ImageBlend_OMSC_ONE_Inp
-#endif /* ! defined ( __MEDIALIB_OLD_NAMES ) */
-mlib_status  __mlib_ImageBlend_OMSC_ONE_Inp(mlib_image *src1dst,
-                                            const mlib_image *src2,
-                                            mlib_s32 cmask);
-
-/* dst = src1 */
-
-#if defined ( __MEDIALIB_OLD_NAMES )
-#define __mlib_ImageBlend_OMSC_DC mlib_ImageBlend_OMSC_DC
-#endif /* ! defined ( __MEDIALIB_OLD_NAMES ) */
-mlib_status  __mlib_ImageBlend_OMSC_DC(mlib_image *dst,
-                                       const mlib_image *src1,
-                                       const mlib_image *src2,
-                                       mlib_s32 cmask);
-
-/* src1dst = src1dst */
-
-#if defined ( __MEDIALIB_OLD_NAMES )
-#define __mlib_ImageBlend_OMSC_DC_Inp mlib_ImageBlend_OMSC_DC_Inp
-#endif /* ! defined ( __MEDIALIB_OLD_NAMES ) */
-mlib_status  __mlib_ImageBlend_OMSC_DC_Inp(mlib_image *src1dst,
-                                           const mlib_image *src2,
-                                           mlib_s32 cmask);
-
-/* dst = src1 + src2 - 2 * src1 * src2 */
-
-#if defined ( __MEDIALIB_OLD_NAMES )
-#define __mlib_ImageBlend_OMSC_OMDC mlib_ImageBlend_OMSC_OMDC
-#endif /* ! defined ( __MEDIALIB_OLD_NAMES ) */
-mlib_status  __mlib_ImageBlend_OMSC_OMDC(mlib_image *dst,
-                                         const mlib_image *src1,
-                                         const mlib_image *src2,
-                                         mlib_s32 cmask);
-
-/* src1dst = src1dst + src2 - 2 * src1dst * src2 */
-
-#if defined ( __MEDIALIB_OLD_NAMES )
-#define __mlib_ImageBlend_OMSC_OMDC_Inp mlib_ImageBlend_OMSC_OMDC_Inp
-#endif /* ! defined ( __MEDIALIB_OLD_NAMES ) */
-mlib_status  __mlib_ImageBlend_OMSC_OMDC_Inp(mlib_image *src1dst,
-                                             const mlib_image *src2,
-                                             mlib_s32 cmask);
-
-/* dst = src1 + src2 * (ALPHAsrc2 - src1) */
-
-#if defined ( __MEDIALIB_OLD_NAMES )
-#define __mlib_ImageBlend_OMSC_SA mlib_ImageBlend_OMSC_SA
-#endif /* ! defined ( __MEDIALIB_OLD_NAMES ) */
-mlib_status  __mlib_ImageBlend_OMSC_SA(mlib_image *dst,
-                                       const mlib_image *src1,
-                                       const mlib_image *src2,
-                                       mlib_s32 cmask);
-
-/* src1dst = src1dst + src2 * (ALPHAsrc2 - src1dst) */
-
-#if defined ( __MEDIALIB_OLD_NAMES )
-#define __mlib_ImageBlend_OMSC_SA_Inp mlib_ImageBlend_OMSC_SA_Inp
-#endif /* ! defined ( __MEDIALIB_OLD_NAMES ) */
-mlib_status  __mlib_ImageBlend_OMSC_SA_Inp(mlib_image *src1dst,
-                                           const mlib_image *src2,
-                                           mlib_s32 cmask);
-
-/* dst = src1 + src2 - src2 * (src1 + ALPHAsrc2) */
-
-#if defined ( __MEDIALIB_OLD_NAMES )
-#define __mlib_ImageBlend_OMSC_OMSA mlib_ImageBlend_OMSC_OMSA
-#endif /* ! defined ( __MEDIALIB_OLD_NAMES ) */
-mlib_status  __mlib_ImageBlend_OMSC_OMSA(mlib_image *dst,
-                                         const mlib_image *src1,
-                                         const mlib_image *src2,
-                                         mlib_s32 cmask);
-
-/* src1dst = src1dst + src2 - src2 * (src1dst + ALPHAsrc2) */
-
-#if defined ( __MEDIALIB_OLD_NAMES )
-#define __mlib_ImageBlend_OMSC_OMSA_Inp mlib_ImageBlend_OMSC_OMSA_Inp
-#endif /* ! defined ( __MEDIALIB_OLD_NAMES ) */
-mlib_status  __mlib_ImageBlend_OMSC_OMSA_Inp(mlib_image *src1dst,
-                                             const mlib_image *src2,
-                                             mlib_s32 cmask);
-
-/* dst = src1 + src2 * (ALPHAsrc1 - src1) */
-
-#if defined ( __MEDIALIB_OLD_NAMES )
-#define __mlib_ImageBlend_OMSC_DA mlib_ImageBlend_OMSC_DA
-#endif /* ! defined ( __MEDIALIB_OLD_NAMES ) */
-mlib_status  __mlib_ImageBlend_OMSC_DA(mlib_image *dst,
-                                       const mlib_image *src1,
-                                       const mlib_image *src2,
-                                       mlib_s32 cmask);
-
-/* src1dst = src1dst + src2 * (ALPHAsrc1dst - src1dst) */
-
-#if defined ( __MEDIALIB_OLD_NAMES )
-#define __mlib_ImageBlend_OMSC_DA_Inp mlib_ImageBlend_OMSC_DA_Inp
-#endif /* ! defined ( __MEDIALIB_OLD_NAMES ) */
-mlib_status  __mlib_ImageBlend_OMSC_DA_Inp(mlib_image *src1dst,
-                                           const mlib_image *src2,
-                                           mlib_s32 cmask);
-
-/* dst = src1 + src2 - src2 * (src1 + ALPHAsrc1) */
-
-#if defined ( __MEDIALIB_OLD_NAMES )
-#define __mlib_ImageBlend_OMSC_OMDA mlib_ImageBlend_OMSC_OMDA
-#endif /* ! defined ( __MEDIALIB_OLD_NAMES ) */
-mlib_status  __mlib_ImageBlend_OMSC_OMDA(mlib_image *dst,
-                                         const mlib_image *src1,
-                                         const mlib_image *src2,
-                                         mlib_s32 cmask);
-
-/* src1dst = src1dst + src2 - src2 * (src1dst + ALPHAsrc1dst) */
-
-#if defined ( __MEDIALIB_OLD_NAMES )
-#define __mlib_ImageBlend_OMSC_OMDA_Inp mlib_ImageBlend_OMSC_OMDA_Inp
-#endif /* ! defined ( __MEDIALIB_OLD_NAMES ) */
-mlib_status  __mlib_ImageBlend_OMSC_OMDA_Inp(mlib_image *src1dst,
-                                             const mlib_image *src2,
-                                             mlib_s32 cmask);
-
-/* dst = src1 +  src2 * ((f, f, f, 1) - src1) */
-
-#if defined ( __MEDIALIB_OLD_NAMES )
-#define __mlib_ImageBlend_OMSC_SAS mlib_ImageBlend_OMSC_SAS
-#endif /* ! defined ( __MEDIALIB_OLD_NAMES ) */
-mlib_status  __mlib_ImageBlend_OMSC_SAS(mlib_image *dst,
-                                        const mlib_image *src1,
-                                        const mlib_image *src2,
-                                        mlib_s32 cmask);
-
-/* src1dst = src1dst +  src2 * ((f, f, f, 1) - src1dst) */
-
-#if defined ( __MEDIALIB_OLD_NAMES )
-#define __mlib_ImageBlend_OMSC_SAS_Inp mlib_ImageBlend_OMSC_SAS_Inp
-#endif /* ! defined ( __MEDIALIB_OLD_NAMES ) */
-mlib_status  __mlib_ImageBlend_OMSC_SAS_Inp(mlib_image *src1dst,
-                                            const mlib_image *src2,
-                                            mlib_s32 cmask);
-
-/* dst = src1 * ALPHAsrc2 */
-
-#if defined ( __MEDIALIB_OLD_NAMES )
-#define __mlib_ImageBlend_SA_ZERO mlib_ImageBlend_SA_ZERO
-#endif /* ! defined ( __MEDIALIB_OLD_NAMES ) */
-mlib_status  __mlib_ImageBlend_SA_ZERO(mlib_image *dst,
-                                       const mlib_image *src1,
-                                       const mlib_image *src2,
-                                       mlib_s32 cmask);
-
-/* src1dst = src1dst * ALPHAsrc2 */
-
-#if defined ( __MEDIALIB_OLD_NAMES )
-#define __mlib_ImageBlend_SA_ZERO_Inp mlib_ImageBlend_SA_ZERO_Inp
-#endif /* ! defined ( __MEDIALIB_OLD_NAMES ) */
-mlib_status  __mlib_ImageBlend_SA_ZERO_Inp(mlib_image *src1dst,
-                                           const mlib_image *src2,
-                                           mlib_s32 cmask);
-
-/* dst = src1 * ALPHAsrc2 + src2 */
-
-#if defined ( __MEDIALIB_OLD_NAMES )
-#define __mlib_ImageBlend_SA_ONE mlib_ImageBlend_SA_ONE
-#endif /* ! defined ( __MEDIALIB_OLD_NAMES ) */
-mlib_status  __mlib_ImageBlend_SA_ONE(mlib_image *dst,
-                                      const mlib_image *src1,
-                                      const mlib_image *src2,
-                                      mlib_s32 cmask);
-
-/* src1dst = src1dst * ALPHAsrc2 + src2 */
-
-#if defined ( __MEDIALIB_OLD_NAMES )
-#define __mlib_ImageBlend_SA_ONE_Inp mlib_ImageBlend_SA_ONE_Inp
-#endif /* ! defined ( __MEDIALIB_OLD_NAMES ) */
-mlib_status  __mlib_ImageBlend_SA_ONE_Inp(mlib_image *src1dst,
-                                          const mlib_image *src2,
-                                          mlib_s32 cmask);
-
-/* dst = src1 * (ALPHAsrc2 + src2) */
-
-#if defined ( __MEDIALIB_OLD_NAMES )
-#define __mlib_ImageBlend_SA_DC mlib_ImageBlend_SA_DC
-#endif /* ! defined ( __MEDIALIB_OLD_NAMES ) */
-mlib_status  __mlib_ImageBlend_SA_DC(mlib_image *dst,
-                                     const mlib_image *src1,
-                                     const mlib_image *src2,
-                                     mlib_s32 cmask);
-
-/* src1dst = src1dst * (ALPHAsrc2 + src2) */
-
-#if defined ( __MEDIALIB_OLD_NAMES )
-#define __mlib_ImageBlend_SA_DC_Inp mlib_ImageBlend_SA_DC_Inp
-#endif /* ! defined ( __MEDIALIB_OLD_NAMES ) */
-mlib_status  __mlib_ImageBlend_SA_DC_Inp(mlib_image *src1dst,
-                                         const mlib_image *src2,
-                                         mlib_s32 cmask);
-
-/* dst = src1 * (ALPHAsrc2 - src2) + src2 */
-
-#if defined ( __MEDIALIB_OLD_NAMES )
-#define __mlib_ImageBlend_SA_OMDC mlib_ImageBlend_SA_OMDC
-#endif /* ! defined ( __MEDIALIB_OLD_NAMES ) */
-mlib_status  __mlib_ImageBlend_SA_OMDC(mlib_image *dst,
-                                       const mlib_image *src1,
-                                       const mlib_image *src2,
-                                       mlib_s32 cmask);
-
-/* src1dst = src1dst * (ALPHAsrc2 - src2) + src2 */
-
-#if defined ( __MEDIALIB_OLD_NAMES )
-#define __mlib_ImageBlend_SA_OMDC_Inp mlib_ImageBlend_SA_OMDC_Inp
-#endif /* ! defined ( __MEDIALIB_OLD_NAMES ) */
-mlib_status  __mlib_ImageBlend_SA_OMDC_Inp(mlib_image *src1dst,
-                                           const mlib_image *src2,
-                                           mlib_s32 cmask);
-
-/* dst = (src1 + src2) * ALPHAsrc2 */
-
-#if defined ( __MEDIALIB_OLD_NAMES )
-#define __mlib_ImageBlend_SA_SA mlib_ImageBlend_SA_SA
-#endif /* ! defined ( __MEDIALIB_OLD_NAMES ) */
-mlib_status  __mlib_ImageBlend_SA_SA(mlib_image *dst,
-                                     const mlib_image *src1,
-                                     const mlib_image *src2,
-                                     mlib_s32 cmask);
-
-/* src1dst = (src1dst + src2) * ALPHAsrc2 */
-
-#if defined ( __MEDIALIB_OLD_NAMES )
-#define __mlib_ImageBlend_SA_SA_Inp mlib_ImageBlend_SA_SA_Inp
-#endif /* ! defined ( __MEDIALIB_OLD_NAMES ) */
-mlib_status  __mlib_ImageBlend_SA_SA_Inp(mlib_image *src1dst,
-                                         const mlib_image *src2,
-                                         mlib_s32 cmask);
-
-/* dst = (src1 - src2) * ALPHAsrc2 + src2 */
-
-#if defined ( __MEDIALIB_OLD_NAMES )
-#define __mlib_ImageBlend_SA_OMSA mlib_ImageBlend_SA_OMSA
-#endif /* ! defined ( __MEDIALIB_OLD_NAMES ) */
-mlib_status  __mlib_ImageBlend_SA_OMSA(mlib_image *dst,
-                                       const mlib_image *src1,
-                                       const mlib_image *src2,
-                                       mlib_s32 cmask);
-
-/* src1dst = (src1dst - src2) * ALPHAsrc2 + src2 */
-
-#if defined ( __MEDIALIB_OLD_NAMES )
-#define __mlib_ImageBlend_SA_OMSA_Inp mlib_ImageBlend_SA_OMSA_Inp
-#endif /* ! defined ( __MEDIALIB_OLD_NAMES ) */
-mlib_status  __mlib_ImageBlend_SA_OMSA_Inp(mlib_image *src1dst,
-                                           const mlib_image *src2,
-                                           mlib_s32 cmask);
-
-/* dst = src1 * ALPHAsrc2 + src2 * ALPHAsrc1 */
-
-#if defined ( __MEDIALIB_OLD_NAMES )
-#define __mlib_ImageBlend_SA_DA mlib_ImageBlend_SA_DA
-#endif /* ! defined ( __MEDIALIB_OLD_NAMES ) */
-mlib_status  __mlib_ImageBlend_SA_DA(mlib_image *dst,
-                                     const mlib_image *src1,
-                                     const mlib_image *src2,
-                                     mlib_s32 cmask);
-
-/* src1dst = src1dst * ALPHAsrc2 + src2 * ALPHAsrc1dst */
-
-#if defined ( __MEDIALIB_OLD_NAMES )
-#define __mlib_ImageBlend_SA_DA_Inp mlib_ImageBlend_SA_DA_Inp
-#endif /* ! defined ( __MEDIALIB_OLD_NAMES ) */
-mlib_status  __mlib_ImageBlend_SA_DA_Inp(mlib_image *src1dst,
-                                         const mlib_image *src2,
-                                         mlib_s32 cmask);
-
-/* dst = src1 * ALPHAsrc2 + src2 * (1 - ALPHAsrc1) */
-
-#if defined ( __MEDIALIB_OLD_NAMES )
-#define __mlib_ImageBlend_SA_OMDA mlib_ImageBlend_SA_OMDA
-#endif /* ! defined ( __MEDIALIB_OLD_NAMES ) */
-mlib_status  __mlib_ImageBlend_SA_OMDA(mlib_image *dst,
-                                       const mlib_image *src1,
-                                       const mlib_image *src2,
-                                       mlib_s32 cmask);
-
-/* src1dst = src1dst * ALPHAsrc2 + src2 * (1 - ALPHAsrc1dst) */
-
-#if defined ( __MEDIALIB_OLD_NAMES )
-#define __mlib_ImageBlend_SA_OMDA_Inp mlib_ImageBlend_SA_OMDA_Inp
-#endif /* ! defined ( __MEDIALIB_OLD_NAMES ) */
-mlib_status  __mlib_ImageBlend_SA_OMDA_Inp(mlib_image *src1dst,
-                                           const mlib_image *src2,
-                                           mlib_s32 cmask);
-
-/* dst = src1 * ALPHAsrc2 + src2 * (f, f, f, 1) */
-
-#if defined ( __MEDIALIB_OLD_NAMES )
-#define __mlib_ImageBlend_SA_SAS mlib_ImageBlend_SA_SAS
-#endif /* ! defined ( __MEDIALIB_OLD_NAMES ) */
-mlib_status  __mlib_ImageBlend_SA_SAS(mlib_image *dst,
-                                      const mlib_image *src1,
-                                      const mlib_image *src2,
-                                      mlib_s32 cmask);
-
-/* src1dst = src1dst * ALPHAsrc2 + src2 * (f, f, f, 1) */
-
-#if defined ( __MEDIALIB_OLD_NAMES )
-#define __mlib_ImageBlend_SA_SAS_Inp mlib_ImageBlend_SA_SAS_Inp
-#endif /* ! defined ( __MEDIALIB_OLD_NAMES ) */
-mlib_status  __mlib_ImageBlend_SA_SAS_Inp(mlib_image *src1dst,
-                                          const mlib_image *src2,
-                                          mlib_s32 cmask);
-
-/* dst = src1 * (1 - ALPHAsrc2) */
-
-#if defined ( __MEDIALIB_OLD_NAMES )
-#define __mlib_ImageBlend_OMSA_ZERO mlib_ImageBlend_OMSA_ZERO
-#endif /* ! defined ( __MEDIALIB_OLD_NAMES ) */
-mlib_status  __mlib_ImageBlend_OMSA_ZERO(mlib_image *dst,
-                                         const mlib_image *src1,
-                                         const mlib_image *src2,
-                                         mlib_s32 cmask);
-
-/* src1dst = src1dst * (1 - ALPHAsrc2) */
-
-#if defined ( __MEDIALIB_OLD_NAMES )
-#define __mlib_ImageBlend_OMSA_ZERO_Inp mlib_ImageBlend_OMSA_ZERO_Inp
-#endif /* ! defined ( __MEDIALIB_OLD_NAMES ) */
-mlib_status  __mlib_ImageBlend_OMSA_ZERO_Inp(mlib_image *src1dst,
-                                             const mlib_image *src2,
-                                             mlib_s32 cmask);
-
-/* dst = src1 * (1 - ALPHAsrc2) + src2 */
-
-#if defined ( __MEDIALIB_OLD_NAMES )
-#define __mlib_ImageBlend_OMSA_ONE mlib_ImageBlend_OMSA_ONE
-#endif /* ! defined ( __MEDIALIB_OLD_NAMES ) */
-mlib_status  __mlib_ImageBlend_OMSA_ONE(mlib_image *dst,
-                                        const mlib_image *src1,
-                                        const mlib_image *src2,
-                                        mlib_s32 cmask);
-
-/* src1dst = src1dst * (1 - ALPHAsrc2) + src2 */
-
-#if defined ( __MEDIALIB_OLD_NAMES )
-#define __mlib_ImageBlend_OMSA_ONE_Inp mlib_ImageBlend_OMSA_ONE_Inp
-#endif /* ! defined ( __MEDIALIB_OLD_NAMES ) */
-mlib_status  __mlib_ImageBlend_OMSA_ONE_Inp(mlib_image *src1dst,
-                                            const mlib_image *src2,
-                                            mlib_s32 cmask);
-
-/* dst = src1 * (1 - ALPHAsrc2 + src2) */
-
-#if defined ( __MEDIALIB_OLD_NAMES )
-#define __mlib_ImageBlend_OMSA_DC mlib_ImageBlend_OMSA_DC
-#endif /* ! defined ( __MEDIALIB_OLD_NAMES ) */
-mlib_status  __mlib_ImageBlend_OMSA_DC(mlib_image *dst,
-                                       const mlib_image *src1,
-                                       const mlib_image *src2,
-                                       mlib_s32 cmask);
-
-/* src1dst = src1dst * (1 - ALPHAsrc2 + src2) */
-
-#if defined ( __MEDIALIB_OLD_NAMES )
-#define __mlib_ImageBlend_OMSA_DC_Inp mlib_ImageBlend_OMSA_DC_Inp
-#endif /* ! defined ( __MEDIALIB_OLD_NAMES ) */
-mlib_status  __mlib_ImageBlend_OMSA_DC_Inp(mlib_image *src1dst,
-                                           const mlib_image *src2,
-                                           mlib_s32 cmask);
-
-/* dst = src1 * (1 - ALPHAsrc2 - src2) + src2 */
-
-#if defined ( __MEDIALIB_OLD_NAMES )
-#define __mlib_ImageBlend_OMSA_OMDC mlib_ImageBlend_OMSA_OMDC
-#endif /* ! defined ( __MEDIALIB_OLD_NAMES ) */
-mlib_status  __mlib_ImageBlend_OMSA_OMDC(mlib_image *dst,
-                                         const mlib_image *src1,
-                                         const mlib_image *src2,
-                                         mlib_s32 cmask);
-
-/* src1dst = src1dst * (1 - ALPHAsrc2 - src2) + src2 */
-
-#if defined ( __MEDIALIB_OLD_NAMES )
-#define __mlib_ImageBlend_OMSA_OMDC_Inp mlib_ImageBlend_OMSA_OMDC_Inp
-#endif /* ! defined ( __MEDIALIB_OLD_NAMES ) */
-mlib_status  __mlib_ImageBlend_OMSA_OMDC_Inp(mlib_image *src1dst,
-                                             const mlib_image *src2,
-                                             mlib_s32 cmask);
-
-/* dst = src1 + (src2 - src1) * ALPHAsrc2 */
-
-#if defined ( __MEDIALIB_OLD_NAMES )
-#define __mlib_ImageBlend_OMSA_SA mlib_ImageBlend_OMSA_SA
-#endif /* ! defined ( __MEDIALIB_OLD_NAMES ) */
-mlib_status  __mlib_ImageBlend_OMSA_SA(mlib_image *dst,
-                                       const mlib_image *src1,
-                                       const mlib_image *src2,
-                                       mlib_s32 cmask);
-
-/* src1dst = src1dst + (src2 - src1dst) * ALPHAsrc2 */
-
-#if defined ( __MEDIALIB_OLD_NAMES )
-#define __mlib_ImageBlend_OMSA_SA_Inp mlib_ImageBlend_OMSA_SA_Inp
-#endif /* ! defined ( __MEDIALIB_OLD_NAMES ) */
-mlib_status  __mlib_ImageBlend_OMSA_SA_Inp(mlib_image *src1dst,
-                                           const mlib_image *src2,
-                                           mlib_s32 cmask);
-
-/* dst = (src1 + src2) * (1 - ALPHAsrc2) */
-
-#if defined ( __MEDIALIB_OLD_NAMES )
-#define __mlib_ImageBlend_OMSA_OMSA mlib_ImageBlend_OMSA_OMSA
-#endif /* ! defined ( __MEDIALIB_OLD_NAMES ) */
-mlib_status  __mlib_ImageBlend_OMSA_OMSA(mlib_image *dst,
-                                         const mlib_image *src1,
-                                         const mlib_image *src2,
-                                         mlib_s32 cmask);
-
-/* src1dst = (src1dst + src2) * (1 - ALPHAsrc2) */
-
-#if defined ( __MEDIALIB_OLD_NAMES )
-#define __mlib_ImageBlend_OMSA_OMSA_Inp mlib_ImageBlend_OMSA_OMSA_Inp
-#endif /* ! defined ( __MEDIALIB_OLD_NAMES ) */
-mlib_status  __mlib_ImageBlend_OMSA_OMSA_Inp(mlib_image *src1dst,
-                                             const mlib_image *src2,
-                                             mlib_s32 cmask);
-
-/* dst = src1 * (1 - ALPHAsrc2) + src2 * ALPHAsrc1 */
-
-#if defined ( __MEDIALIB_OLD_NAMES )
-#define __mlib_ImageBlend_OMSA_DA mlib_ImageBlend_OMSA_DA
-#endif /* ! defined ( __MEDIALIB_OLD_NAMES ) */
-mlib_status  __mlib_ImageBlend_OMSA_DA(mlib_image *dst,
-                                       const mlib_image *src1,
-                                       const mlib_image *src2,
-                                       mlib_s32 cmask);
-
-/* src1dst = src1dst * (1 - ALPHAsrc2) + src2 * ALPHAsrc1dst */
-
-#if defined ( __MEDIALIB_OLD_NAMES )
-#define __mlib_ImageBlend_OMSA_DA_Inp mlib_ImageBlend_OMSA_DA_Inp
-#endif /* ! defined ( __MEDIALIB_OLD_NAMES ) */
-mlib_status  __mlib_ImageBlend_OMSA_DA_Inp(mlib_image *src1dst,
-                                           const mlib_image *src2,
-                                           mlib_s32 cmask);
-
-/* dst = src1 * (1 - ALPHAsrc2) + src2 * (1 - ALPHAsrc1) */
-
-#if defined ( __MEDIALIB_OLD_NAMES )
-#define __mlib_ImageBlend_OMSA_OMDA mlib_ImageBlend_OMSA_OMDA
-#endif /* ! defined ( __MEDIALIB_OLD_NAMES ) */
-mlib_status  __mlib_ImageBlend_OMSA_OMDA(mlib_image *dst,
-                                         const mlib_image *src1,
-                                         const mlib_image *src2,
-                                         mlib_s32 cmask);
-
-/* src1dst = src1dst * (1 - ALPHAsrc2) + src2 * (1 - ALPHAsrc1dst) */
-
-#if defined ( __MEDIALIB_OLD_NAMES )
-#define __mlib_ImageBlend_OMSA_OMDA_Inp mlib_ImageBlend_OMSA_OMDA_Inp
-#endif /* ! defined ( __MEDIALIB_OLD_NAMES ) */
-mlib_status  __mlib_ImageBlend_OMSA_OMDA_Inp(mlib_image *src1dst,
-                                             const mlib_image *src2,
-                                             mlib_s32 cmask);
-
-/* dst = src1 * (1 - ALPHAsrc2) + src2 * (f, f, f, 1) */
-
-#if defined ( __MEDIALIB_OLD_NAMES )
-#define __mlib_ImageBlend_OMSA_SAS mlib_ImageBlend_OMSA_SAS
-#endif /* ! defined ( __MEDIALIB_OLD_NAMES ) */
-mlib_status  __mlib_ImageBlend_OMSA_SAS(mlib_image *dst,
-                                        const mlib_image *src1,
-                                        const mlib_image *src2,
-                                        mlib_s32 cmask);
-
-/* src1dst = src1dst * (1 - ALPHAsrc2) + src2 * (f, f, f, 1) */
-
-#if defined ( __MEDIALIB_OLD_NAMES )
-#define __mlib_ImageBlend_OMSA_SAS_Inp mlib_ImageBlend_OMSA_SAS_Inp
-#endif /* ! defined ( __MEDIALIB_OLD_NAMES ) */
-mlib_status  __mlib_ImageBlend_OMSA_SAS_Inp(mlib_image *src1dst,
-                                            const mlib_image *src2,
-                                            mlib_s32 cmask);
-
-/* dst = src1 * ALPHAsrc1 */
-
-#if defined ( __MEDIALIB_OLD_NAMES )
-#define __mlib_ImageBlend_DA_ZERO mlib_ImageBlend_DA_ZERO
-#endif /* ! defined ( __MEDIALIB_OLD_NAMES ) */
-mlib_status  __mlib_ImageBlend_DA_ZERO(mlib_image *dst,
-                                       const mlib_image *src1,
-                                       const mlib_image *src2,
-                                       mlib_s32 cmask);
-
-/* src1dst = src1dst * ALPHAsrc1dst */
-
-#if defined ( __MEDIALIB_OLD_NAMES )
-#define __mlib_ImageBlend_DA_ZERO_Inp mlib_ImageBlend_DA_ZERO_Inp
-#endif /* ! defined ( __MEDIALIB_OLD_NAMES ) */
-mlib_status  __mlib_ImageBlend_DA_ZERO_Inp(mlib_image *src1dst,
-                                           const mlib_image *src2,
-                                           mlib_s32 cmask);
-
-/* dst = src1 * ALPHAsrc1 + src2 */
-
-#if defined ( __MEDIALIB_OLD_NAMES )
-#define __mlib_ImageBlend_DA_ONE mlib_ImageBlend_DA_ONE
-#endif /* ! defined ( __MEDIALIB_OLD_NAMES ) */
-mlib_status  __mlib_ImageBlend_DA_ONE(mlib_image *dst,
-                                      const mlib_image *src1,
-                                      const mlib_image *src2,
-                                      mlib_s32 cmask);
-
-/* src1dst = src1dst * ALPHAsrc1dst + src2 */
-
-#if defined ( __MEDIALIB_OLD_NAMES )
-#define __mlib_ImageBlend_DA_ONE_Inp mlib_ImageBlend_DA_ONE_Inp
-#endif /* ! defined ( __MEDIALIB_OLD_NAMES ) */
-mlib_status  __mlib_ImageBlend_DA_ONE_Inp(mlib_image *src1dst,
-                                          const mlib_image *src2,
-                                          mlib_s32 cmask);
-
-/* dst = src1 * (ALPHAsrc1 + src2) */
-
-#if defined ( __MEDIALIB_OLD_NAMES )
-#define __mlib_ImageBlend_DA_DC mlib_ImageBlend_DA_DC
-#endif /* ! defined ( __MEDIALIB_OLD_NAMES ) */
-mlib_status  __mlib_ImageBlend_DA_DC(mlib_image *dst,
-                                     const mlib_image *src1,
-                                     const mlib_image *src2,
-                                     mlib_s32 cmask);
-
-/* src1dst = src1dst * (ALPHAsrc1dst + src2) */
-
-#if defined ( __MEDIALIB_OLD_NAMES )
-#define __mlib_ImageBlend_DA_DC_Inp mlib_ImageBlend_DA_DC_Inp
-#endif /* ! defined ( __MEDIALIB_OLD_NAMES ) */
-mlib_status  __mlib_ImageBlend_DA_DC_Inp(mlib_image *src1dst,
-                                         const mlib_image *src2,
-                                         mlib_s32 cmask);
-
-/* dst = src1 * (ALPHAsrc1 - src2) + src2 */
-
-#if defined ( __MEDIALIB_OLD_NAMES )
-#define __mlib_ImageBlend_DA_OMDC mlib_ImageBlend_DA_OMDC
-#endif /* ! defined ( __MEDIALIB_OLD_NAMES ) */
-mlib_status  __mlib_ImageBlend_DA_OMDC(mlib_image *dst,
-                                       const mlib_image *src1,
-                                       const mlib_image *src2,
-                                       mlib_s32 cmask);
-
-/* src1dst = src1dst * (ALPHAsrc1dst - src2) + src2 */
-
-#if defined ( __MEDIALIB_OLD_NAMES )
-#define __mlib_ImageBlend_DA_OMDC_Inp mlib_ImageBlend_DA_OMDC_Inp
-#endif /* ! defined ( __MEDIALIB_OLD_NAMES ) */
-mlib_status  __mlib_ImageBlend_DA_OMDC_Inp(mlib_image *src1dst,
-                                           const mlib_image *src2,
-                                           mlib_s32 cmask);
-
-/* dst = src1 * ALPHAsrc1 + src2 * ALPHAsrc2 */
-
-#if defined ( __MEDIALIB_OLD_NAMES )
-#define __mlib_ImageBlend_DA_SA mlib_ImageBlend_DA_SA
-#endif /* ! defined ( __MEDIALIB_OLD_NAMES ) */
-mlib_status  __mlib_ImageBlend_DA_SA(mlib_image *dst,
-                                     const mlib_image *src1,
-                                     const mlib_image *src2,
-                                     mlib_s32 cmask);
-
-/* src1dst = src1dst * ALPHAsrc1dst + src2 * ALPHAsrc2 */
-
-#if defined ( __MEDIALIB_OLD_NAMES )
-#define __mlib_ImageBlend_DA_SA_Inp mlib_ImageBlend_DA_SA_Inp
-#endif /* ! defined ( __MEDIALIB_OLD_NAMES ) */
-mlib_status  __mlib_ImageBlend_DA_SA_Inp(mlib_image *src1dst,
-                                         const mlib_image *src2,
-                                         mlib_s32 cmask);
-
-/* dst = src1 * ALPHAsrc1 + src2 * (1 - ALPHAsrc2) */
-
-#if defined ( __MEDIALIB_OLD_NAMES )
-#define __mlib_ImageBlend_DA_OMSA mlib_ImageBlend_DA_OMSA
-#endif /* ! defined ( __MEDIALIB_OLD_NAMES ) */
-mlib_status  __mlib_ImageBlend_DA_OMSA(mlib_image *dst,
-                                       const mlib_image *src1,
-                                       const mlib_image *src2,
-                                       mlib_s32 cmask);
-
-/* src1dst = src1dst * ALPHAsrc1dst + src2 * (1 - ALPHAsrc2) */
-
-#if defined ( __MEDIALIB_OLD_NAMES )
-#define __mlib_ImageBlend_DA_OMSA_Inp mlib_ImageBlend_DA_OMSA_Inp
-#endif /* ! defined ( __MEDIALIB_OLD_NAMES ) */
-mlib_status  __mlib_ImageBlend_DA_OMSA_Inp(mlib_image *src1dst,
-                                           const mlib_image *src2,
-                                           mlib_s32 cmask);
-
-/* dst = (src1 + src2) * ALPHAsrc1 */
-
-#if defined ( __MEDIALIB_OLD_NAMES )
-#define __mlib_ImageBlend_DA_DA mlib_ImageBlend_DA_DA
-#endif /* ! defined ( __MEDIALIB_OLD_NAMES ) */
-mlib_status  __mlib_ImageBlend_DA_DA(mlib_image *dst,
-                                     const mlib_image *src1,
-                                     const mlib_image *src2,
-                                     mlib_s32 cmask);
-
-/* src1dst = (src1dst + src2) * ALPHAsrc1dst */
-
-#if defined ( __MEDIALIB_OLD_NAMES )
-#define __mlib_ImageBlend_DA_DA_Inp mlib_ImageBlend_DA_DA_Inp
-#endif /* ! defined ( __MEDIALIB_OLD_NAMES ) */
-mlib_status  __mlib_ImageBlend_DA_DA_Inp(mlib_image *src1dst,
-                                         const mlib_image *src2,
-                                         mlib_s32 cmask);
-
-/* dst = (src1 - src2) * ALPHAsrc1 + src2 */
-
-#if defined ( __MEDIALIB_OLD_NAMES )
-#define __mlib_ImageBlend_DA_OMDA mlib_ImageBlend_DA_OMDA
-#endif /* ! defined ( __MEDIALIB_OLD_NAMES ) */
-mlib_status  __mlib_ImageBlend_DA_OMDA(mlib_image *dst,
-                                       const mlib_image *src1,
-                                       const mlib_image *src2,
-                                       mlib_s32 cmask);
-
-/* src1dst = (src1dst - src2) * ALPHAsrc1dst + src2 */
-
-#if defined ( __MEDIALIB_OLD_NAMES )
-#define __mlib_ImageBlend_DA_OMDA_Inp mlib_ImageBlend_DA_OMDA_Inp
-#endif /* ! defined ( __MEDIALIB_OLD_NAMES ) */
-mlib_status  __mlib_ImageBlend_DA_OMDA_Inp(mlib_image *src1dst,
-                                           const mlib_image *src2,
-                                           mlib_s32 cmask);
-
-/* dst = src1 * ALPHAsrc1 + src2 * (f, f, f, 1) */
-
-#if defined ( __MEDIALIB_OLD_NAMES )
-#define __mlib_ImageBlend_DA_SAS mlib_ImageBlend_DA_SAS
-#endif /* ! defined ( __MEDIALIB_OLD_NAMES ) */
-mlib_status  __mlib_ImageBlend_DA_SAS(mlib_image *dst,
-                                      const mlib_image *src1,
-                                      const mlib_image *src2,
-                                      mlib_s32 cmask);
-
-/* src1dst = src1dst * ALPHAsrc1dst + src2 * (f, f, f, 1) */
-
-#if defined ( __MEDIALIB_OLD_NAMES )
-#define __mlib_ImageBlend_DA_SAS_Inp mlib_ImageBlend_DA_SAS_Inp
-#endif /* ! defined ( __MEDIALIB_OLD_NAMES ) */
-mlib_status  __mlib_ImageBlend_DA_SAS_Inp(mlib_image *src1dst,
-                                          const mlib_image *src2,
-                                          mlib_s32 cmask);
-
-/* dst = src1 * (1 - ALPHAsrc1) */
-
-#if defined ( __MEDIALIB_OLD_NAMES )
-#define __mlib_ImageBlend_OMDA_ZERO mlib_ImageBlend_OMDA_ZERO
-#endif /* ! defined ( __MEDIALIB_OLD_NAMES ) */
-mlib_status  __mlib_ImageBlend_OMDA_ZERO(mlib_image *dst,
-                                         const mlib_image *src1,
-                                         const mlib_image *src2,
-                                         mlib_s32 cmask);
-
-/* src1dst = src1dst * (1 - ALPHAsrc1dst) */
-
-#if defined ( __MEDIALIB_OLD_NAMES )
-#define __mlib_ImageBlend_OMDA_ZERO_Inp mlib_ImageBlend_OMDA_ZERO_Inp
-#endif /* ! defined ( __MEDIALIB_OLD_NAMES ) */
-mlib_status  __mlib_ImageBlend_OMDA_ZERO_Inp(mlib_image *src1dst,
-                                             const mlib_image *src2,
-                                             mlib_s32 cmask);
-
-/* dst = src1 * (1 - ALPHAsrc1) + src2 */
-
-#if defined ( __MEDIALIB_OLD_NAMES )
-#define __mlib_ImageBlend_OMDA_ONE mlib_ImageBlend_OMDA_ONE
-#endif /* ! defined ( __MEDIALIB_OLD_NAMES ) */
-mlib_status  __mlib_ImageBlend_OMDA_ONE(mlib_image *dst,
-                                        const mlib_image *src1,
-                                        const mlib_image *src2,
-                                        mlib_s32 cmask);
-
-/* src1dst = src1dst * (1 - ALPHAsrc1dst) + src2 */
-
-#if defined ( __MEDIALIB_OLD_NAMES )
-#define __mlib_ImageBlend_OMDA_ONE_Inp mlib_ImageBlend_OMDA_ONE_Inp
-#endif /* ! defined ( __MEDIALIB_OLD_NAMES ) */
-mlib_status  __mlib_ImageBlend_OMDA_ONE_Inp(mlib_image *src1dst,
-                                            const mlib_image *src2,
-                                            mlib_s32 cmask);
-
-/* dst = src1 * (1 - ALPHAsrc1 + src2) */
-
-#if defined ( __MEDIALIB_OLD_NAMES )
-#define __mlib_ImageBlend_OMDA_DC mlib_ImageBlend_OMDA_DC
-#endif /* ! defined ( __MEDIALIB_OLD_NAMES ) */
-mlib_status  __mlib_ImageBlend_OMDA_DC(mlib_image *dst,
-                                       const mlib_image *src1,
-                                       const mlib_image *src2,
-                                       mlib_s32 cmask);
-
-/* src1dst = src1dst * (1 - ALPHAsrc1dst + src2) */
-
-#if defined ( __MEDIALIB_OLD_NAMES )
-#define __mlib_ImageBlend_OMDA_DC_Inp mlib_ImageBlend_OMDA_DC_Inp
-#endif /* ! defined ( __MEDIALIB_OLD_NAMES ) */
-mlib_status  __mlib_ImageBlend_OMDA_DC_Inp(mlib_image *src1dst,
-                                           const mlib_image *src2,
-                                           mlib_s32 cmask);
-
-/* dst = src1 * (1 - ALPHAsrc1 - src2) + src2 */
-
-#if defined ( __MEDIALIB_OLD_NAMES )
-#define __mlib_ImageBlend_OMDA_OMDC mlib_ImageBlend_OMDA_OMDC
-#endif /* ! defined ( __MEDIALIB_OLD_NAMES ) */
-mlib_status  __mlib_ImageBlend_OMDA_OMDC(mlib_image *dst,
-                                         const mlib_image *src1,
-                                         const mlib_image *src2,
-                                         mlib_s32 cmask);
-
-/* src1dst = src1dst * (1 - ALPHAsrc1dst - src2) + src2 */
-
-#if defined ( __MEDIALIB_OLD_NAMES )
-#define __mlib_ImageBlend_OMDA_OMDC_Inp mlib_ImageBlend_OMDA_OMDC_Inp
-#endif /* ! defined ( __MEDIALIB_OLD_NAMES ) */
-mlib_status  __mlib_ImageBlend_OMDA_OMDC_Inp(mlib_image *src1dst,
-                                             const mlib_image *src2,
-                                             mlib_s32 cmask);
-
-/* dst = src1 * (1 - ALPHAsrc1) + src2 * ALPHAsrc2 */
-
-#if defined ( __MEDIALIB_OLD_NAMES )
-#define __mlib_ImageBlend_OMDA_SA mlib_ImageBlend_OMDA_SA
-#endif /* ! defined ( __MEDIALIB_OLD_NAMES ) */
-mlib_status  __mlib_ImageBlend_OMDA_SA(mlib_image *dst,
-                                       const mlib_image *src1,
-                                       const mlib_image *src2,
-                                       mlib_s32 cmask);
-
-/* src1dst = src1dst * (1 - ALPHAsrc1dst) + src2 * ALPHAsrc2 */
-
-#if defined ( __MEDIALIB_OLD_NAMES )
-#define __mlib_ImageBlend_OMDA_SA_Inp mlib_ImageBlend_OMDA_SA_Inp
-#endif /* ! defined ( __MEDIALIB_OLD_NAMES ) */
-mlib_status  __mlib_ImageBlend_OMDA_SA_Inp(mlib_image *src1dst,
-                                           const mlib_image *src2,
-                                           mlib_s32 cmask);
-
-/* dst = src1 * (1 - ALPHAsrc1) + src2 * (1 - ALPHAsrc2) */
-
-#if defined ( __MEDIALIB_OLD_NAMES )
-#define __mlib_ImageBlend_OMDA_OMSA mlib_ImageBlend_OMDA_OMSA
-#endif /* ! defined ( __MEDIALIB_OLD_NAMES ) */
-mlib_status  __mlib_ImageBlend_OMDA_OMSA(mlib_image *dst,
-                                         const mlib_image *src1,
-                                         const mlib_image *src2,
-                                         mlib_s32 cmask);
-
-/* src1dst = src1dst * (1 - ALPHAsrc1dst) + src2 * (1 - ALPHAsrc2) */
-
-#if defined ( __MEDIALIB_OLD_NAMES )
-#define __mlib_ImageBlend_OMDA_OMSA_Inp mlib_ImageBlend_OMDA_OMSA_Inp
-#endif /* ! defined ( __MEDIALIB_OLD_NAMES ) */
-mlib_status  __mlib_ImageBlend_OMDA_OMSA_Inp(mlib_image *src1dst,
-                                             const mlib_image *src2,
-                                             mlib_s32 cmask);
-
-/* dst = src1 + (src2 - src1) * ALPHAsrc1 */
-
-#if defined ( __MEDIALIB_OLD_NAMES )
-#define __mlib_ImageBlend_OMDA_DA mlib_ImageBlend_OMDA_DA
-#endif /* ! defined ( __MEDIALIB_OLD_NAMES ) */
-mlib_status  __mlib_ImageBlend_OMDA_DA(mlib_image *dst,
-                                       const mlib_image *src1,
-                                       const mlib_image *src2,
-                                       mlib_s32 cmask);
-
-/* src1dst = src1dst + (src2 - src1dst) * ALPHAsrc1dst */
-
-#if defined ( __MEDIALIB_OLD_NAMES )
-#define __mlib_ImageBlend_OMDA_DA_Inp mlib_ImageBlend_OMDA_DA_Inp
-#endif /* ! defined ( __MEDIALIB_OLD_NAMES ) */
-mlib_status  __mlib_ImageBlend_OMDA_DA_Inp(mlib_image *src1dst,
-                                           const mlib_image *src2,
-                                           mlib_s32 cmask);
-
-/* dst = (src1 + src2) * (1 - ALPHAsrc1) */
-
-#if defined ( __MEDIALIB_OLD_NAMES )
-#define __mlib_ImageBlend_OMDA_OMDA mlib_ImageBlend_OMDA_OMDA
-#endif /* ! defined ( __MEDIALIB_OLD_NAMES ) */
-mlib_status  __mlib_ImageBlend_OMDA_OMDA(mlib_image *dst,
-                                         const mlib_image *src1,
-                                         const mlib_image *src2,
-                                         mlib_s32 cmask);
-
-/* src1dst = (src1dst + src2) * (1 - ALPHAsrc1dst) */
-
-#if defined ( __MEDIALIB_OLD_NAMES )
-#define __mlib_ImageBlend_OMDA_OMDA_Inp mlib_ImageBlend_OMDA_OMDA_Inp
-#endif /* ! defined ( __MEDIALIB_OLD_NAMES ) */
-mlib_status  __mlib_ImageBlend_OMDA_OMDA_Inp(mlib_image *src1dst,
-                                             const mlib_image *src2,
-                                             mlib_s32 cmask);
-
-/* dst = src1 * (1 - ALPHAsrc1) + src2 * (f, f, f, 1) */
-
-#if defined ( __MEDIALIB_OLD_NAMES )
-#define __mlib_ImageBlend_OMDA_SAS mlib_ImageBlend_OMDA_SAS
-#endif /* ! defined ( __MEDIALIB_OLD_NAMES ) */
-mlib_status  __mlib_ImageBlend_OMDA_SAS(mlib_image *dst,
-                                        const mlib_image *src1,
-                                        const mlib_image *src2,
-                                        mlib_s32 cmask);
-
-/* src1dst = src1dst * (1 - ALPHAsrc1dst) + src2 * (f, f, f, 1) */
-
-#if defined ( __MEDIALIB_OLD_NAMES )
-#define __mlib_ImageBlend_OMDA_SAS_Inp mlib_ImageBlend_OMDA_SAS_Inp
-#endif /* ! defined ( __MEDIALIB_OLD_NAMES ) */
-mlib_status  __mlib_ImageBlend_OMDA_SAS_Inp(mlib_image *src1dst,
-                                            const mlib_image *src2,
-                                            mlib_s32 cmask);
-
-
-
-#if defined ( __MEDIALIB_OLD_NAMES )
-#define __mlib_ImageComposite mlib_ImageComposite
-#endif /* ! defined ( __MEDIALIB_OLD_NAMES ) */
-mlib_status  __mlib_ImageComposite(mlib_image *dst,
-                                   const mlib_image *src1,
-                                   const mlib_image *src2,
-                                   mlib_blend bsrc1,
-                                   mlib_blend bsrc2,
-                                   mlib_s32 cmask);
-
-
-#if defined ( __MEDIALIB_OLD_NAMES )
-#define __mlib_ImageComposite_Inp mlib_ImageComposite_Inp
-#endif /* ! defined ( __MEDIALIB_OLD_NAMES ) */
-mlib_status  __mlib_ImageComposite_Inp(mlib_image *src1dst,
-                                       const mlib_image *src2,
-                                       mlib_blend bsrc1,
-                                       mlib_blend bsrc2,
-                                       mlib_s32 cmask);
-
-#ifdef __cplusplus
-}
-#endif /* __cplusplus */
-#endif /* __ORIG_MLIB_IMAGE_BLEND_PROTO_H */
--- a/jdk/src/java.desktop/share/native/libmlib_image/mlib_image_proto.h	Thu May 19 17:48:02 2016 +0000
+++ b/jdk/src/java.desktop/share/native/libmlib_image/mlib_image_proto.h	Thu May 19 19:46:20 2016 +0000
@@ -1430,17 +1430,6 @@
 
 
 #if defined ( __MEDIALIB_OLD_NAMES )
-#define __mlib_ImageAffineIndex mlib_ImageAffineIndex
-#endif /* ! defined ( __MEDIALIB_OLD_NAMES ) */
-mlib_status  __mlib_ImageAffineIndex(mlib_image *dst,
-                                     const mlib_image *src,
-                                     const mlib_d64 *mtx,
-                                     mlib_filter filter,
-                                     mlib_edge edge,
-                                     const void *colormap);
-
-
-#if defined ( __MEDIALIB_OLD_NAMES )
 #define __mlib_ImageAffineTable mlib_ImageAffineTable
 #endif /* ! defined ( __MEDIALIB_OLD_NAMES ) */
 mlib_status  __mlib_ImageAffineTable(mlib_image *dst,
@@ -1471,17 +1460,6 @@
 
 
 #if defined ( __MEDIALIB_OLD_NAMES )
-#define __mlib_ImageAffineTransformIndex mlib_ImageAffineTransformIndex
-#endif /* ! defined ( __MEDIALIB_OLD_NAMES ) */
-mlib_status  __mlib_ImageAffineTransformIndex(mlib_image *dst,
-                                              const mlib_image *src,
-                                              const mlib_d64 *mtx,
-                                              mlib_filter filter,
-                                              mlib_edge edge,
-                                              const void *colormap);
-
-
-#if defined ( __MEDIALIB_OLD_NAMES )
 #define __mlib_ImageAffineTransform_Fp mlib_ImageAffineTransform_Fp
 #endif /* ! defined ( __MEDIALIB_OLD_NAMES ) */
 mlib_status  __mlib_ImageAffineTransform_Fp(mlib_image *dst,
@@ -1825,19 +1803,6 @@
 
 
 #if defined ( __MEDIALIB_OLD_NAMES )
-#define __mlib_ImageRotateIndex mlib_ImageRotateIndex
-#endif /* ! defined ( __MEDIALIB_OLD_NAMES ) */
-mlib_status  __mlib_ImageRotateIndex(mlib_image *dst,
-                                     const mlib_image *src,
-                                     mlib_d64 angle,
-                                     mlib_d64 xcenter,
-                                     mlib_d64 ycenter,
-                                     mlib_filter filter,
-                                     mlib_edge edge,
-                                     const void *colormap);
-
-
-#if defined ( __MEDIALIB_OLD_NAMES )
 #define __mlib_ImageRotate_Fp mlib_ImageRotate_Fp
 #endif /* ! defined ( __MEDIALIB_OLD_NAMES ) */
 mlib_status  __mlib_ImageRotate_Fp(mlib_image *dst,
@@ -1887,16 +1852,6 @@
 
 
 #if defined ( __MEDIALIB_OLD_NAMES )
-#define __mlib_ImageZoomIn2XIndex mlib_ImageZoomIn2XIndex
-#endif /* ! defined ( __MEDIALIB_OLD_NAMES ) */
-mlib_status  __mlib_ImageZoomIn2XIndex(mlib_image *dst,
-                                       const mlib_image *src,
-                                       mlib_filter filter,
-                                       mlib_edge edge,
-                                       const void *colormap);
-
-
-#if defined ( __MEDIALIB_OLD_NAMES )
 #define __mlib_ImageZoomIn2X_Fp mlib_ImageZoomIn2X_Fp
 #endif /* ! defined ( __MEDIALIB_OLD_NAMES ) */
 mlib_status  __mlib_ImageZoomIn2X_Fp(mlib_image *dst,
@@ -1915,16 +1870,6 @@
 
 
 #if defined ( __MEDIALIB_OLD_NAMES )
-#define __mlib_ImageZoomOut2XIndex mlib_ImageZoomOut2XIndex
-#endif /* ! defined ( __MEDIALIB_OLD_NAMES ) */
-mlib_status  __mlib_ImageZoomOut2XIndex(mlib_image *dst,
-                                        const mlib_image *src,
-                                        mlib_filter filter,
-                                        mlib_edge edge,
-                                        const void *colormap);
-
-
-#if defined ( __MEDIALIB_OLD_NAMES )
 #define __mlib_ImageZoomOut2X_Fp mlib_ImageZoomOut2X_Fp
 #endif /* ! defined ( __MEDIALIB_OLD_NAMES ) */
 mlib_status  __mlib_ImageZoomOut2X_Fp(mlib_image *dst,
@@ -2012,18 +1957,6 @@
 
 
 #if defined ( __MEDIALIB_OLD_NAMES )
-#define __mlib_ImageZoomIndex mlib_ImageZoomIndex
-#endif /* ! defined ( __MEDIALIB_OLD_NAMES ) */
-mlib_status  __mlib_ImageZoomIndex(mlib_image *dst,
-                                   const mlib_image *src,
-                                   mlib_d64 zoomx,
-                                   mlib_d64 zoomy,
-                                   mlib_filter filter,
-                                   mlib_edge edge,
-                                   const void *colormap);
-
-
-#if defined ( __MEDIALIB_OLD_NAMES )
 #define __mlib_ImageZoom_Fp mlib_ImageZoom_Fp
 #endif /* ! defined ( __MEDIALIB_OLD_NAMES ) */
 mlib_status  __mlib_ImageZoom_Fp(mlib_image *dst,
@@ -2312,98 +2245,6 @@
 
 
 #if defined ( __MEDIALIB_OLD_NAMES )
-#define __mlib_ImageColorTrue2IndexInit mlib_ImageColorTrue2IndexInit
-#endif /* ! defined ( __MEDIALIB_OLD_NAMES ) */
-mlib_status  __mlib_ImageColorTrue2IndexInit(void **colormap,
-                                             mlib_s32 bits,
-                                             mlib_type intype,
-                                             mlib_type outtype,
-                                             mlib_s32 channels,
-                                             mlib_s32 entries,
-                                             mlib_s32 offset,
-                                             const void **table);
-
-
-#if defined ( __MEDIALIB_OLD_NAMES )
-#define __mlib_ImageColorTrue2Index mlib_ImageColorTrue2Index
-#endif /* ! defined ( __MEDIALIB_OLD_NAMES ) */
-mlib_status  __mlib_ImageColorTrue2Index(mlib_image *dst,
-                                         const mlib_image *src,
-                                         const void *colormap);
-
-
-#if defined ( __MEDIALIB_OLD_NAMES )
-#define __mlib_ImageColorTrue2IndexFree mlib_ImageColorTrue2IndexFree
-#endif /* ! defined ( __MEDIALIB_OLD_NAMES ) */
-void  __mlib_ImageColorTrue2IndexFree(void *colormap);
-
-
-#if defined ( __MEDIALIB_OLD_NAMES )
-#define __mlib_ImageColorDitherInit mlib_ImageColorDitherInit
-#endif /* ! defined ( __MEDIALIB_OLD_NAMES ) */
-mlib_status  __mlib_ImageColorDitherInit(void **colormap,
-                                         const mlib_s32 *dimensions,
-                                         mlib_type intype,
-                                         mlib_type outtype,
-                                         mlib_s32 channels,
-                                         mlib_s32 entries,
-                                         mlib_s32 offset,
-                                         void **lut);
-
-
-#if defined ( __MEDIALIB_OLD_NAMES )
-#define __mlib_ImageColorDitherFree mlib_ImageColorDitherFree
-#endif /* ! defined ( __MEDIALIB_OLD_NAMES ) */
-void  __mlib_ImageColorDitherFree(void *colormap);
-
-
-#if defined ( __MEDIALIB_OLD_NAMES )
-#define __mlib_ImageColorErrorDiffusion3x3 mlib_ImageColorErrorDiffusion3x3
-#endif /* ! defined ( __MEDIALIB_OLD_NAMES ) */
-mlib_status  __mlib_ImageColorErrorDiffusion3x3(mlib_image *dst,
-                                                const mlib_image *src,
-                                                const mlib_s32 *kernel,
-                                                mlib_s32 scale,
-                                                const void *colormap);
-
-
-#if defined ( __MEDIALIB_OLD_NAMES )
-#define __mlib_ImageColorErrorDiffusionMxN mlib_ImageColorErrorDiffusionMxN
-#endif /* ! defined ( __MEDIALIB_OLD_NAMES ) */
-mlib_status  __mlib_ImageColorErrorDiffusionMxN(mlib_image *dst,
-                                                const mlib_image *src,
-                                                const mlib_s32 *kernel,
-                                                mlib_s32 m,
-                                                mlib_s32 n,
-                                                mlib_s32 dm,
-                                                mlib_s32 dn,
-                                                mlib_s32 scale,
-                                                const void *colormap);
-
-
-#if defined ( __MEDIALIB_OLD_NAMES )
-#define __mlib_ImageColorOrderedDither8x8 mlib_ImageColorOrderedDither8x8
-#endif /* ! defined ( __MEDIALIB_OLD_NAMES ) */
-mlib_status  __mlib_ImageColorOrderedDither8x8(mlib_image *dst,
-                                               const mlib_image *src,
-                                               const mlib_s32 *dmask,
-                                               mlib_s32 scale,
-                                               const void *colormap);
-
-
-#if defined ( __MEDIALIB_OLD_NAMES )
-#define __mlib_ImageColorOrderedDitherMxN mlib_ImageColorOrderedDitherMxN
-#endif /* ! defined ( __MEDIALIB_OLD_NAMES ) */
-mlib_status  __mlib_ImageColorOrderedDitherMxN(mlib_image *dst,
-                                               const mlib_image *src,
-                                               const mlib_s32 **dmask,
-                                               mlib_s32 m,
-                                               mlib_s32 n,
-                                               mlib_s32 scale,
-                                               const void *colormap);
-
-
-#if defined ( __MEDIALIB_OLD_NAMES )
 #define __mlib_ImageColorReplace mlib_ImageColorReplace
 #endif /* ! defined ( __MEDIALIB_OLD_NAMES ) */
 mlib_status  __mlib_ImageColorReplace(mlib_image *dst,
@@ -2694,17 +2535,6 @@
 
 
 #if defined ( __MEDIALIB_OLD_NAMES )
-#define __mlib_ImageConv2x2Index mlib_ImageConv2x2Index
-#endif /* ! defined ( __MEDIALIB_OLD_NAMES ) */
-mlib_status  __mlib_ImageConv2x2Index(mlib_image *dst,
-                                      const mlib_image *src,
-                                      const mlib_s32 *kernel,
-                                      mlib_s32 scale,
-                                      mlib_edge edge,
-                                      const void *colormap);
-
-
-#if defined ( __MEDIALIB_OLD_NAMES )
 #define __mlib_ImageConv2x2_Fp mlib_ImageConv2x2_Fp
 #endif /* ! defined ( __MEDIALIB_OLD_NAMES ) */
 mlib_status  __mlib_ImageConv2x2_Fp(mlib_image *dst,
@@ -2726,17 +2556,6 @@
 
 
 #if defined ( __MEDIALIB_OLD_NAMES )
-#define __mlib_ImageConv3x3Index mlib_ImageConv3x3Index
-#endif /* ! defined ( __MEDIALIB_OLD_NAMES ) */
-mlib_status  __mlib_ImageConv3x3Index(mlib_image *dst,
-                                      const mlib_image *src,
-                                      const mlib_s32 *kernel,
-                                      mlib_s32 scale,
-                                      mlib_edge edge,
-                                      const void *colormap);
-
-
-#if defined ( __MEDIALIB_OLD_NAMES )
 #define __mlib_ImageConv3x3_Fp mlib_ImageConv3x3_Fp
 #endif /* ! defined ( __MEDIALIB_OLD_NAMES ) */
 mlib_status  __mlib_ImageConv3x3_Fp(mlib_image *dst,
@@ -2758,17 +2577,6 @@
 
 
 #if defined ( __MEDIALIB_OLD_NAMES )
-#define __mlib_ImageConv4x4Index mlib_ImageConv4x4Index
-#endif /* ! defined ( __MEDIALIB_OLD_NAMES ) */
-mlib_status  __mlib_ImageConv4x4Index(mlib_image *dst,
-                                      const mlib_image *src,
-                                      const mlib_s32 *kernel,
-                                      mlib_s32 scale,
-                                      mlib_edge edge,
-                                      const void *colormap);
-
-
-#if defined ( __MEDIALIB_OLD_NAMES )
 #define __mlib_ImageConv4x4_Fp mlib_ImageConv4x4_Fp
 #endif /* ! defined ( __MEDIALIB_OLD_NAMES ) */
 mlib_status  __mlib_ImageConv4x4_Fp(mlib_image *dst,
@@ -2790,17 +2598,6 @@
 
 
 #if defined ( __MEDIALIB_OLD_NAMES )
-#define __mlib_ImageConv5x5Index mlib_ImageConv5x5Index
-#endif /* ! defined ( __MEDIALIB_OLD_NAMES ) */
-mlib_status  __mlib_ImageConv5x5Index(mlib_image *dst,
-                                      const mlib_image *src,
-                                      const mlib_s32 *kernel,
-                                      mlib_s32 scale,
-                                      mlib_edge edge,
-                                      const void *colormap);
-
-
-#if defined ( __MEDIALIB_OLD_NAMES )
 #define __mlib_ImageConv5x5_Fp mlib_ImageConv5x5_Fp
 #endif /* ! defined ( __MEDIALIB_OLD_NAMES ) */
 mlib_status  __mlib_ImageConv5x5_Fp(mlib_image *dst,
@@ -2822,17 +2619,6 @@
 
 
 #if defined ( __MEDIALIB_OLD_NAMES )
-#define __mlib_ImageConv7x7Index mlib_ImageConv7x7Index
-#endif /* ! defined ( __MEDIALIB_OLD_NAMES ) */
-mlib_status  __mlib_ImageConv7x7Index(mlib_image *dst,
-                                      const mlib_image *src,
-                                      const mlib_s32 *kernel,
-                                      mlib_s32 scale,
-                                      mlib_edge edge,
-                                      const void *colormap);
-
-
-#if defined ( __MEDIALIB_OLD_NAMES )
 #define __mlib_ImageConv7x7_Fp mlib_ImageConv7x7_Fp
 #endif /* ! defined ( __MEDIALIB_OLD_NAMES ) */
 mlib_status  __mlib_ImageConv7x7_Fp(mlib_image *dst,
@@ -2871,21 +2657,6 @@
 
 
 #if defined ( __MEDIALIB_OLD_NAMES )
-#define __mlib_ImageConvMxNIndex mlib_ImageConvMxNIndex
-#endif /* ! defined ( __MEDIALIB_OLD_NAMES ) */
-mlib_status  __mlib_ImageConvMxNIndex(mlib_image *dst,
-                                      const mlib_image *src,
-                                      const mlib_s32 *kernel,
-                                      mlib_s32 m,
-                                      mlib_s32 n,
-                                      mlib_s32 dm,
-                                      mlib_s32 dn,
-                                      mlib_s32 scale,
-                                      mlib_edge edge,
-                                      const void *colormap);
-
-
-#if defined ( __MEDIALIB_OLD_NAMES )
 #define __mlib_ImageConvMxN_Fp mlib_ImageConvMxN_Fp
 #endif /* ! defined ( __MEDIALIB_OLD_NAMES ) */
 mlib_status  __mlib_ImageConvMxN_Fp(mlib_image *dst,
--- a/jdk/src/java.desktop/unix/classes/sun/awt/X11/XTrayIconPeer.java	Thu May 19 17:48:02 2016 +0000
+++ b/jdk/src/java.desktop/unix/classes/sun/awt/X11/XTrayIconPeer.java	Thu May 19 19:46:20 2016 +0000
@@ -464,7 +464,7 @@
             XToolkit.postEvent(XToolkit.targetToAppContext(e.getSource()), e);
         }
         public void mouseClicked(MouseEvent e) {
-            if ((e.getClickCount() > 1 || xtiPeer.balloon.isVisible()) &&
+            if ((e.getClickCount() == 1 || xtiPeer.balloon.isVisible()) &&
                 e.getButton() == MouseEvent.BUTTON1)
             {
                 ActionEvent aev = new ActionEvent(xtiPeer.target, ActionEvent.ACTION_PERFORMED,
--- a/jdk/src/java.desktop/unix/native/libawt/awt/medialib/mlib_v_ImageCopy.c	Thu May 19 17:48:02 2016 +0000
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,193 +0,0 @@
-/*
- * Copyright (c) 2000, 2003, 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.
- */
-
-
-
-/*
- * FUNCTION
- *      mlib_ImageCopy   - Direct copy from one image to another.
- *
- * SYNOPSIS
- *      mlib_status mlib_ImageCopy(mlib_image *dst,
- *                                 mlib_image *src);
- *
- * ARGUMENT
- *      dst     pointer to output or destination image
- *      src     pointer to input or source image
- *
- * RESTRICTION
- *      src and dst must have the same size, type and number of channels.
- *      They can have 1, 2, 3 or 4 channels of MLIB_BIT, MLIB_BYTE,
- *      MLIB_SHORT, MLIB_INT, MLIB_FLOAT or MLIB_DOUBLE data type.
- *
- * DESCRIPTION
- *      Direct copy from one image to another.
- */
-
-#include <stdlib.h>
-#include "mlib_image.h"
-#include "mlib_ImageCheck.h"
-
-/***************************************************************/
-
-extern void mlib_v_ImageCopy_blk(mlib_u8 *sa, mlib_u8 *da, mlib_s32 size);
-extern void mlib_v_ImageCopy_a1(mlib_d64 *sp, mlib_d64 *dp, mlib_s32 size);
-extern void mlib_ImageCopy_na(mlib_u8 *sa, mlib_u8 *da, mlib_s32 size);
-extern void mlib_ImageCopy_bit_al(mlib_u8 *sa, mlib_u8 *da,
-                                  mlib_s32 size, mlib_s32 offset);
-extern void mlib_ImageCopy_bit_na(mlib_u8 *sa, mlib_u8 *da, mlib_s32 size,
-                                  mlib_s32 s_offset, mlib_s32 d_offset);
-
-/***************************************************************/
-
-#ifdef MLIB_TEST
-
-mlib_status mlib_v_ImageCopy(mlib_image *dst, mlib_image *src)
-
-#else
-
-mlib_status mlib_ImageCopy(mlib_image *dst, const mlib_image *src)
-
-#endif
-{
-  mlib_u8  *sa;         /* start point in source */
-  mlib_u8  *da;         /* start points in destination */
-  mlib_s32 width;       /* width in bytes of src and dst */
-  mlib_s32 height;      /* height in lines of src and dst */
-  mlib_s32 s_offset;    /* bit offset of src */
-  mlib_s32 d_offset;    /* bit offset of dst */
-  mlib_s32 stride;      /* stride in bytes in src*/
-  mlib_s32 dstride;     /* stride in bytes in dst */
-  mlib_s32 j;           /* indices for x, y */
-  mlib_s32 size;
-
-  MLIB_IMAGE_CHECK(src);
-  MLIB_IMAGE_CHECK(dst);
-  MLIB_IMAGE_TYPE_EQUAL(src, dst);
-  MLIB_IMAGE_CHAN_EQUAL(src, dst);
-  MLIB_IMAGE_SIZE_EQUAL(src, dst);
-
-  width  = mlib_ImageGetWidth(dst) * mlib_ImageGetChannels(dst);
-  height = mlib_ImageGetHeight(dst);
-  sa = (mlib_u8 *)mlib_ImageGetData(src);
-  da = (mlib_u8 *)mlib_ImageGetData(dst);
-
-  switch (mlib_ImageGetType(dst)) {
-    case MLIB_BIT:
-
-      if (!mlib_ImageIsNotOneDvector(src) &&
-          !mlib_ImageIsNotOneDvector(dst)) {
-          size = height * (width  >> 3);
-          if ((size & 0x3f) == 0 &&
-              !mlib_ImageIsNotAligned64(src) &&
-              !mlib_ImageIsNotAligned64(dst)) {
-
-              mlib_v_ImageCopy_blk(sa, da, size);
-              return MLIB_SUCCESS;
-          }
-          if (((size & 7) == 0) && !mlib_ImageIsNotAligned8(src) &&
-              !mlib_ImageIsNotAligned8(dst)) {
-
-              size >>= 3;                                /* in octlet */
-              mlib_v_ImageCopy_a1((mlib_d64 *)sa, (mlib_d64 *)da, size);
-          }
-          else {
-
-            mlib_ImageCopy_na(sa, da, size);
-          }
-        }
-      else {
-        stride = mlib_ImageGetStride(src);                /* in byte */
-        dstride = mlib_ImageGetStride(dst);               /* in byte */
-        s_offset = mlib_ImageGetBitOffset(src);           /* in bits */
-        d_offset = mlib_ImageGetBitOffset(dst);           /* in bits */
-
-        if (s_offset == d_offset) {
-          for (j = 0; j < height; j++) {
-            mlib_ImageCopy_bit_al(sa, da, width, s_offset);
-            sa += stride;
-            da += dstride;
-          }
-        } else {
-          for (j = 0; j < height; j++) {
-            mlib_ImageCopy_bit_na(sa, da, width, s_offset, d_offset);
-            sa += stride;
-            da += dstride;
-          }
-        }
-      }
-      return MLIB_SUCCESS;
-    case MLIB_BYTE:
-      break;
-    case MLIB_SHORT:
-      width *= 2;
-      break;
-    case MLIB_INT:
-    case MLIB_FLOAT:
-      width *= 4;
-      break;
-    case MLIB_DOUBLE:
-      width *= 8;
-      break;
-    default:
-      return MLIB_FAILURE;
-  }
-
-  if (!mlib_ImageIsNotOneDvector(src) &&
-      !mlib_ImageIsNotOneDvector(dst)) {
-      size = height * width;
-      if ((size & 0x3f) == 0 &&
-          !mlib_ImageIsNotAligned64(src) &&
-          !mlib_ImageIsNotAligned64(dst)) {
-
-          mlib_v_ImageCopy_blk(sa, da, size);
-          return MLIB_SUCCESS;
-      }
-      if (((size & 7) == 0) && !mlib_ImageIsNotAligned8(src) &&
-          !mlib_ImageIsNotAligned8(dst)) {
-
-          size >>= 3;                                /* in octlet */
-          mlib_v_ImageCopy_a1((mlib_d64 *)sa, (mlib_d64 *)da, size);
-      }
-      else {
-
-        mlib_ImageCopy_na(sa, da, size);
-      }
-    }
-  else {
-    stride = mlib_ImageGetStride(src);                /* in byte */
-    dstride = mlib_ImageGetStride(dst);                /* in byte */
-
-    /* row loop */
-    for (j = 0; j < height; j++) {
-      mlib_ImageCopy_na(sa, da, width);
-      sa += stride;
-      da += dstride;
-    }
-  }
-  return MLIB_SUCCESS;
-}
-
-/***************************************************************/
--- a/jdk/src/java.desktop/unix/native/libawt/awt/medialib/mlib_v_ImageCopy_blk.s	Thu May 19 17:48:02 2016 +0000
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,262 +0,0 @@
-!
-!
-! 
-! Copyright 2000 Sun Microsystems, Inc.  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.
-!
-
-
-! FUNCTION
-!      mlib_v_ImageCopy_blk   - Copy an image into another 
-!				(with Block Load/Store)
-!
-! SYNOPSIS
-!      void mlib_v_ImageCopy_blk(void *src,
-!                                void *dst, 
-!                                int size);
-!
-! ARGUMENT
-!      src     source image data
-!      dst     destination image data
-!      size    image size in bytes
-!
-! NOTES
-!      src and dst must point to 64-byte aligned addresses
-!      size must be multiple of 64
-!
-! DESCRIPTION
-!      dst = src
-!
-
-#include "vis_asi.h"
-
-! Minimum size of stack frame according to SPARC ABI
-#define MINFRAME        96
-
-! ENTRY provides the standard procedure entry code
-#define ENTRY(x) \
-	.align  4; \
-	.global x; \
-x:
-
-! SET_SIZE trails a function and sets the size for the ELF symbol table
-#define SET_SIZE(x) \
-	.size   x, (.-x)
-
-! SPARC have four integer register groups. i-registers %i0 to %i7
-! hold input data. o-registers %o0 to %o7 hold output data. l-registers
-! %l0 to %l7 hold local data. g-registers %g0 to %g7 hold global data.
-! Note that %g0 is alway zero, write to it has no program-visible effect.
-
-! When calling an assembly function, the first 6 arguments are stored
-! in i-registers from %i0 to %i5. The rest arguments are stored in stack.
-! Note that %i6 is reserved for stack pointer and %i7 for return address.
-
-! Only the first 32 f-registers can be used as 32-bit registers.
-! The last 32 f-registers can only be used as 16 64-bit registers.
-
-#define src     %i0
-#define dst     %i1
-#define sz      %i2
-
-!frame pointer  %i6
-!return addr    %i7
-
-!stack pointer  %o6
-!call link      %o7
-
-#define sa      %l0
-#define da      %l1
-#define se      %l2
-#define ns      %l3
-
-#define O0      %f16
-#define O1      %f18
-#define O2      %f20
-#define O3      %f22
-#define O4      %f24
-#define O5      %f26
-#define O6      %f28
-#define O7      %f30
-
-#define A0      %f32
-#define A1      %f34
-#define A2      %f36
-#define A3      %f38
-#define A4      %f40
-#define A5      %f42
-#define A6      %f44
-#define A7      %f46
-
-#define B0      %f48
-#define B1      %f50
-#define B2      %f52
-#define B3      %f54
-#define B4      %f56
-#define B5      %f58
-#define B6      %f60
-#define B7      %f62
-
-#define USE_BLD
-#define USE_BST
-
-#define MEMBAR_BEFORE_BLD        membar  #StoreLoad
-#define MEMBAR_AFTER_BLD         membar  #StoreLoad
-
-#ifdef USE_BLD
-#define BLD_A0                                  \
-        ldda    [sa]ASI_BLK_P,A0;               \
-        cmp     sa,se;                          \
-        blu,pt  %icc,1f;                        \
-        inc     64,sa;                          \
-        dec     64,sa;                          \
-1:
-#else
-#define BLD_A0                                  \
-        ldd     [sa +  0],A0;                   \
-        ldd     [sa +  8],A1;                   \
-        ldd     [sa + 16],A2;                   \
-        ldd     [sa + 24],A3;                   \
-        ldd     [sa + 32],A4;                   \
-        ldd     [sa + 40],A5;                   \
-        ldd     [sa + 48],A6;                   \
-        ldd     [sa + 56],A7;                   \
-        cmp     sa,se;                          \
-        blu,pt  %icc,1f;                        \
-        inc     64,sa;                          \
-        dec     64,sa;                          \
-1:
-#endif
-
-#ifdef USE_BLD
-#define BLD_B0                                  \
-        ldda    [sa]ASI_BLK_P,B0;               \
-        cmp     sa,se;                          \
-        blu,pt  %icc,1f;                        \
-        inc     64,sa;                          \
-        dec     64,sa;                          \
-1:
-#else
-#define BLD_B0                                  \
-        ldd     [sa +  0],B0;                   \
-        ldd     [sa +  8],B1;                   \
-        ldd     [sa + 16],B2;                   \
-        ldd     [sa + 24],B3;                   \
-        ldd     [sa + 32],B4;                   \
-        ldd     [sa + 40],B5;                   \
-        ldd     [sa + 48],B6;                   \
-        ldd     [sa + 56],B7;                   \
-        cmp     sa,se;                          \
-        blu,pt  %icc,1f;                        \
-        inc     64,sa;                          \
-        dec     64,sa;                          \
-1:
-#endif
-
-#ifdef USE_BST
-#define BST                                     \
-        stda    O0,[da]ASI_BLK_P;               \
-        inc     64,da;                          \
-        deccc   ns;                             \
-        ble,pn  %icc,mlib_v_ImageCopy_end;	\
-        nop
-#else
-#define BST                                     \
-        std     O0,[da +  0];                   \
-        std     O1,[da +  8];                   \
-        std     O2,[da + 16];                   \
-        std     O3,[da + 24];                   \
-        std     O4,[da + 32];                   \
-        std     O5,[da + 40];                   \
-        std     O6,[da + 48];                   \
-        std     O7,[da + 56];                   \
-        inc     64,da;                          \
-        deccc   ns;                             \
-        ble,pn  %icc,mlib_v_ImageCopy_end;	\
-        nop
-#endif
-
-#define COPY_A0					\
-        fmovd A0, O0;                           \
-        fmovd A1, O1;                           \
-        fmovd A2, O2;                           \
-        fmovd A3, O3;                           \
-        fmovd A4, O4;                           \
-        fmovd A5, O5;                           \
-        fmovd A6, O6;                           \
-        fmovd A7, O7;
-
-#define COPY_B0					\
-        fmovd B0, O0;                           \
-        fmovd B1, O1;                           \
-        fmovd B2, O2;                           \
-        fmovd B3, O3;                           \
-        fmovd B4, O4;                           \
-        fmovd B5, O5;                           \
-        fmovd B6, O6;                           \
-        fmovd B7, O7;
-
-        .section        ".text",#alloc,#execinstr
-
-        ENTRY(mlib_v_ImageCopy_blk)	! function name
-
-        save    %sp,-MINFRAME,%sp	! reserve space for stack
-                                        ! and adjust register window
-! do some error checking
-        tst     sz                      ! size > 0
-        ble,pn  %icc,mlib_v_ImageCopy_ret
-
-! calculate loop count
-        sra     sz,6,ns                 ! 64 bytes per loop
-
-        add     src,sz,se               ! end address of source
-        mov     src,sa
-        mov     dst,da
-                                        ! issue memory barrier instruction
-        MEMBAR_BEFORE_BLD               ! to ensure all previous memory load
-                                        ! and store has completed
-
-        BLD_A0
-        BLD_B0                          ! issue the 2nd block load instruction
-                                        ! to synchronize with returning data
-mlib_v_ImageCopy_bgn:
-
-        COPY_A0				! process data returned by BLD_A0
-        BLD_A0                          ! block load and sync data from BLD_B0
-        BST                             ! block store data from BLD_A0
-
-        COPY_B0				! process data returned by BLD_B0
-        BLD_B0                          ! block load and sync data from BLD_A0
-        BST                             ! block store data from BLD_B0
-
-        bg,pt   %icc,mlib_v_ImageCopy_bgn
-
-mlib_v_ImageCopy_end:
-                                        ! issue memory barrier instruction
-        MEMBAR_AFTER_BLD                ! to ensure all previous memory load
-                                        ! and store has completed.
-mlib_v_ImageCopy_ret:
-        ret                             ! return
-        restore                         ! restore register window
-
-        SET_SIZE(mlib_v_ImageCopy_blk)
--- a/jdk/src/java.desktop/unix/native/libawt/awt/medialib/vis_asi.h	Thu May 19 17:48:02 2016 +0000
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,210 +0,0 @@
-/*
- * Copyright (c) 1998, 2003, 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.
- */
-
-
-#ifndef VIS_ASI_H
-#define VIS_ASI_H
-
-/* evolved from asm_asi.h in VSDK 1.0 */
-
-#ifdef  __cplusplus
-extern "C" {
-#endif
-
-/* ASI definitions for VIS */
-
-#define         ASI_N                                   0x04
-#define         ASI_NL                                  0x0C
-#define         ASI_AIUP                                0x10
-#define         ASI_AIUS                                0x11
-#define         ASI_AIUPL                               0x18
-#define         ASI_AIUSL                               0x19
-#define         ASI_PHYS_USE_EC_L                       0x1C
-#define         ASI_PHYS_BYPASS_EC_WITH_EBIT_L          0x1D
-#define         ASI_DC_DATA                             0x46
-#define         ASI_DC_TAG                              0x47
-#define         ASI_UPA_CONTROL                         0x4A
-#define         ASI_MONDO_SEND_CTRL                     0x48
-#define         ASI_MONDO_RECEIVE_CTRL                  0x49
-#define         ASI_AFSR                                0x4C
-#define         ASI_AFAR                                0x4D
-#define         ASI_EC_TAG_DATA                         0x4E
-#define         ASI_ICACHE_DATA                         0x66
-#define         ASI_IC_INSTR                            0x66
-#define         ASI_IC_TAG                              0x67
-#define         ASI_IC_PRE_DECODE                       0x6E
-#define         ASI_IC_NEXT_FIELD                       0x6F
-#define         ASI_BLK_AIUP                            0x70
-#define         ASI_BLK_AIUS                            0x71
-#define         ASI_EC                                  0x76
-#define         ASI_BLK_AIUPL                           0x78
-#define         ASI_BLK_AIUSL                           0x79
-#define         ASI_P                                   0x80
-#define         ASI_S                                   0x81
-#define         ASI_PNF                                 0x82
-#define         ASI_SNF                                 0x83
-#define         ASI_PL                                  0x88
-#define         ASI_SL                                  0x89
-#define         ASI_PNFL                                0x8A
-#define         ASI_SNFL                                0x8B
-#define         ASI_PST8_P                              0xC0
-#define         ASI_PST8_S                              0xC1
-#define         ASI_PST16_P                             0xC2
-#define         ASI_PST16_S                             0xC3
-#define         ASI_PST32_P                             0xC4
-#define         ASI_PST32_S                             0xC5
-#define         ASI_PST8_PL                             0xC8
-#define         ASI_PST8_SL                             0xC9
-#define         ASI_PST16_PL                            0xCA
-#define         ASI_PST16_SL                            0xCB
-#define         ASI_PST32_PL                            0xCC
-#define         ASI_PST32_SL                            0xCD
-#define         ASI_FL8_P                               0xD0
-#define         ASI_FL8_S                               0xD1
-#define         ASI_FL16_P                              0xD2
-#define         ASI_FL16_S                              0xD3
-#define         ASI_FL8_PL                              0xD8
-#define         ASI_FL8_SL                              0xD9
-#define         ASI_FL16_PL                             0xDA
-#define         ASI_FL16_SL                             0xDB
-#define         ASI_COMMIT_P                            0xE0
-#define         ASI_COMMIT_S                            0xE1
-#define         ASI_BLK_P                               0xF0
-#define         ASI_BLK_S                               0xF1
-#define         ASI_BLK_PL                              0xF8
-#define         ASI_BLK_SL                              0xF9
-
-#define         ASI_NUCLEUS                             0x04
-#define         ASI_NUCLEUS_LITTLE                      0x0C
-#define         ASI_AS_IF_USER_PRIMARY                  0x10
-#define         ASI_AS_IF_USER_SECONDARY                0x11
-#define         ASI_PHYS_USE_EC                         0x14
-#define         ASI_PHYS_BYPASS_EC_WITH_EBIT            0x15
-#define         ASI_AS_IF_USER_PRIMARY_LITTLE           0x18
-#define         ASI_AS_IF_USER_SECONDARY_LITTLE         0x19
-#define         ASI_PHYS_USE_EC_LITTLE                  0x1C
-#define         ASI_PHYS_BYPASS_EC_WITH_EBIT_LITTLE     0x1D
-#define         ASI_LSU_CONTROL_REG                     0x45
-#define         ASI_DCACHE_DATA                         0x46
-#define         ASI_DCACHE_TAG                          0x47
-#define         ASI_INTR_DISPATCH_STATUS                0x48
-#define         ASI_INTR_RECEIVE                        0x49
-#define         ASI_UPA_CONFIG_REG                      0x4A
-#define         ASI_ESTATE_ERROR_EN_REG                 0x4B
-#define         ASI_ASYNC_FAULT_STATUS                  0x4C
-#define         ASI_ASYNC_FAULT_ADDR                    0x4D
-#define         ASI_ECACHE_TAG_DATA                     0x4E
-#define         ASI_OBSERVABILITY_REG                   0x4F
-#define         ASI_IMMU                                0x50
-#define         ASI_IMU_TSB_BASE                        0x50
-#define         ASI_IMU_TAG_ACCESS                      0x50
-#define         ASI_IMU_SFSR                            0x50
-#define         ASI_IMU_TAG_TARGET                      0x50
-#define         ASI_IMU_TSB_POINTER_8K                  0x51
-#define         ASI_IMU_TSB_POINTER_64K                 0x52
-#define         ASI_IMU_DATAIN                          0x54
-#define         ASI_IMMU_DATA_IN                        0x54
-#define         ASI_IMU_DATA_ACCESS                     0x55
-#define         ASI_IMU_TAG_READ                        0x56
-#define         ASI_IMU_DEMAP                           0x57
-#define         ASI_DMMU                                0x58
-#define         ASI_PRIMARY_CONTEXT                     0x58
-#define         ASI_SECONDARY_CONTEXT                   0x58
-#define         ASI_DMU_TSB_BASE                        0x58
-#define         ASI_DMU_TAG_ACCESS                      0x58
-#define         ASI_DMU_TAG_TARGET                      0x58
-#define         ASI_DMU_SFSR                            0x58
-#define         ASI_DMU_SFAR                            0x58
-#define         ASI_DMU_VA_WATCHPOINT                   0x58
-#define         ASI_DMU_PA_WATCHPOINT                   0x58
-#define         ASI_DMU_TSB_POINTER_8K                  0x59
-#define         ASI_DMU_TSB_POINTER_64K                 0x5A
-#define         ASI_DMU_TSB_POINTER_DIRECT              0x5B
-#define         ASI_DMU_DATAIN                          0x5C
-#define         ASI_DMMU_DATA_IN                        0x5C
-#define         ASI_DMU_DATA_ACCESS                     0x5D
-#define         ASI_DMU_TAG_READ                        0x5E
-#define         ASI_DMU_DEMAP                           0x5F
-#define         ASI_ICACHE_INSTR                        0x66
-#define         ASI_ICACHE_TAG                          0x67
-#define         ASI_ICACHE_PRE_DECODE                   0x6E
-#define         ASI_ICACHE_NEXT_FIELD                   0x6F
-#define         ASI_BLOCK_AS_IF_USER_PRIMARY            0x70
-#define         ASI_BLOCK_AS_IF_USER_SECONDARY          0x71
-#define         ASI_EXT                                 0x76
-#define         ASI_ECACHE                              0x76
-#define         ASI_ECACHE_DATA                         0x76
-#define         ASI_ECACHE_TAG                          0x76
-#define         ASI_SDB_INTR                            0x77
-#define         ASI_SDBH_ERR_REG                        0x77
-#define         ASI_SDBL_ERR_REG                        0x77
-#define         ASI_SDBH_CONTROL_REG                    0x77
-#define         ASI_SDBL_CONTROL_REG                    0x77
-#define         ASI_INTR_DISPATCH                       0x77
-#define         ASI_INTR_DATA0                          0x77
-#define         ASI_INTR_DATA1                          0x77
-#define         ASI_INTR_DATA2                          0x77
-#define         ASI_BLOCK_AS_IF_USER_PRIMARY_LITTLE     0x78
-#define         ASI_BLOCK_AS_IF_USER_SECONDARY_LITTLE   0x79
-#define         ASI_PRIMARY                             0x80
-#define         ASI_SECONDARY                           0x81
-#define         ASI_PRIMARY_NO_FAULT                    0x82
-#define         ASI_SECONDARY_NO_FAULT                  0x83
-#define         ASI_PRIMARY_LITTLE                      0x88
-#define         ASI_SECONDARY_LITTLE                    0x89
-#define         ASI_PRIMARY_NO_FAULT_LITTLE             0x8A
-#define         ASI_SECONDARY_NO_FAULT_LITTLE           0x8B
-#define         ASI_PST8_PRIMARY                        0xC0
-#define         ASI_PST8_SECONDARY                      0xC1
-#define         ASI_PST16_PRIMARY                       0xC2
-#define         ASI_PST16_SECONDARY                     0xC3
-#define         ASI_PST32_PRIMARY                       0xC4
-#define         ASI_PST32_SECONDARY                     0xC5
-#define         ASI_PST8_PRIMARY_LITTLE                 0xC8
-#define         ASI_PST8_SECONDARY_LITTLE               0xC9
-#define         ASI_PST16_PRIMARY_LITTLE                0xCA
-#define         ASI_PST16_SECONDARY_LITTLE              0xCB
-#define         ASI_PST32_PRIMARY_LITTLE                0xCC
-#define         ASI_PST32_SECONDARY_LITTLE              0xCD
-#define         ASI_FL8_PRIMARY                         0xD0
-#define         ASI_FL8_SECONDARY                       0xD1
-#define         ASI_FL16_PRIMARY                        0xD2
-#define         ASI_FL16_SECONDARY                      0xD3
-#define         ASI_FL8_PRIMARY_LITTLE                  0xD8
-#define         ASI_FL8_SECONDARY_LITTLE                0xD9
-#define         ASI_FL16_PRIMARY_LITTLE                 0xDA
-#define         ASI_FL16_SECONDARY_LITTLE               0xDB
-#define         ASI_COMMIT_PRIMARY                      0xE0
-#define         ASI_COMMIT_SECONDARY                    0xE1
-#define         ASI_BLOCK_PRIMARY                       0xF0
-#define         ASI_BLOCK_SECONDARY                     0xF1
-#define         ASI_BLOCK_PRIMARY_LITTLE                0xF8
-#define         ASI_BLOCK_SECONDARY_LITTLE              0xF9
-
-#ifdef  __cplusplus
-}
-#endif
-
-#endif  /* VIS_ASI_H */
--- a/jdk/src/java.desktop/unix/native/libawt_xawt/awt/gtk2_interface.c	Thu May 19 17:48:02 2016 +0000
+++ b/jdk/src/java.desktop/unix/native/libawt_xawt/awt/gtk2_interface.c	Thu May 19 19:46:20 2016 +0000
@@ -817,52 +817,22 @@
     io_handler = XSetIOErrorHandler(NULL);
 
     if (fp_gtk_check_version(2, 2, 0) == NULL) {
-        jclass clazz = (*env)->FindClass(env, "sun/misc/GThreadHelper");
-        jmethodID mid_getAndSetInitializationNeededFlag =
-                (*env)->GetStaticMethodID(env, clazz, "getAndSetInitializationNeededFlag", "()Z");
-        jmethodID mid_lock = (*env)->GetStaticMethodID(env, clazz, "lock", "()V");
-        jmethodID mid_unlock = (*env)->GetStaticMethodID(env, clazz, "unlock", "()V");
-
-        // Init the thread system to use GLib in a thread-safe mode
-        (*env)->CallStaticVoidMethod(env, clazz, mid_lock);
-        if ((*env)->ExceptionCheck(env)) {
-            AWT_UNLOCK();
-            return FALSE;
-        }
 
         // Calling g_thread_init() multiple times leads to crash on GLib < 2.24
         // We can use g_thread_get_initialized () but it is available only for
-        // GLib >= 2.20. We rely on GThreadHelper for GLib < 2.20.
+        // GLib >= 2.20.
         gboolean is_g_thread_get_initialized = FALSE;
         if (GLIB_CHECK_VERSION(2, 20, 0)) {
             is_g_thread_get_initialized = fp_g_thread_get_initialized();
         }
 
-        if (!(*env)->CallStaticBooleanMethod(env, clazz, mid_getAndSetInitializationNeededFlag)) {
-            if (!is_g_thread_get_initialized) {
-                fp_g_thread_init(NULL);
-            }
-
-            //According the GTK documentation, gdk_threads_init() should be
-            //called before gtk_init() or gtk_init_check()
-            fp_gdk_threads_init();
+        if (!is_g_thread_get_initialized) {
+            fp_g_thread_init(NULL);
         }
-        jthrowable pendExcpn = NULL;
-        // Exception raised during mid_getAndSetInitializationNeededFlag
-        // call is saved and error handling is done
-        // after unlock method is called
-        if ((pendExcpn = (*env)->ExceptionOccurred(env)) != NULL) {
-            (*env)->ExceptionClear(env);
-        }
-        (*env)->CallStaticVoidMethod(env, clazz, mid_unlock);
-        if (pendExcpn != NULL) {
-            (*env)->Throw(env, pendExcpn);
-        }
-        // check if any exception occured during mid_unlock call
-        if ((*env)->ExceptionCheck(env)) {
-            AWT_UNLOCK();
-            return FALSE;
-        }
+
+        //According the GTK documentation, gdk_threads_init() should be
+        //called before gtk_init() or gtk_init_check()
+        fp_gdk_threads_init();
     }
     result = (*fp_gtk_init_check)(NULL, NULL);
 
--- a/jdk/src/java.desktop/unix/native/libmlib_image/mlib_v_ImageAffineIndex_BC.c	Thu May 19 17:48:02 2016 +0000
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,1443 +0,0 @@
-/*
- * Copyright (c) 1998, 2003, 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.
- */
-
-
-
-#include "vis_proto.h"
-#include "mlib_image.h"
-#include "mlib_ImageColormap.h"
-#include "mlib_ImageAffine.h"
-#include "mlib_v_ImageFilters.h"
-
-/***************************************************************/
-#define MLIB_LIMIT   512
-#define MLIB_SHIFT    16
-
-/***************************************************************/
-#undef  DECLAREVAR
-#define DECLAREVAR()                                            \
-  DECLAREVAR0();                                                \
-  mlib_s32  *warp_tbl   = param -> warp_tbl;                    \
-  mlib_s32  xSrc, ySrc;                                         \
-  mlib_s32  srcYStride = param -> srcYStride;                   \
-  mlib_s32  filter     = param -> filter;                       \
-  mlib_s32  max_xsize  = param -> max_xsize;                    \
-  MLIB_TYPE *srcIndexPtr;                                       \
-  MLIB_TYPE *dstIndexPtr;                                       \
-  mlib_d64  *dstPixelPtr;                                       \
-  mlib_s32  i
-
-/***************************************************************/
-#define DECLAREVAR_U8()                                         \
-  mlib_s32  filterposx, filterposy;                             \
-  mlib_d64  sum0, sum1, sum2, sum3;                             \
-  mlib_f32  hi_row00, hi_row10, hi_row20, hi_row30;             \
-  mlib_f32  hi_row01, hi_row11, hi_row21, hi_row31;             \
-  mlib_f32  lo_row00, lo_row10, lo_row20, lo_row30;             \
-  mlib_f32  lo_row01, lo_row11, lo_row21, lo_row31;             \
-  mlib_d64  xFilter0, xFilter1, xFilter2, xFilter3, yFilter;    \
-  mlib_d64  v00, v10, v20, v30;                                 \
-  mlib_d64  v01, v11, v21, v31;                                 \
-  mlib_d64  v02, v12, v22, v32;                                 \
-  mlib_d64  v03, v13, v23, v33;                                 \
-  mlib_d64  d0, d1, d2, d3;                                     \
-  mlib_d64  d00, d10, d20, d30;                                 \
-  mlib_d64  d01, d11, d21, d31;                                 \
-  mlib_s32  cols;                                               \
-  mlib_d64  res, *xPtr
-
-/***************************************************************/
-#define DECLAREVAR_S16()                                        \
-  mlib_s32  filterposx, filterposy;                             \
-  mlib_d64  sum0, sum1, sum2, sum3;                             \
-  mlib_d64  row00, row10, row20, row30;                         \
-  mlib_d64  row01, row11, row21, row31;                         \
-  mlib_d64  row02, row12, row22, row32;                         \
-  mlib_d64  row03, row13, row23, row33;                         \
-  mlib_d64  xFilter0, xFilter1, xFilter2, xFilter3;             \
-  mlib_d64  yFilter0, yFilter1, yFilter2, yFilter3;             \
-  mlib_d64  v00, v01, v02, v03, v10, v11, v12, v13;             \
-  mlib_d64  v20, v21, v22, v23, v30, v31, v32, v33;             \
-  mlib_d64  u00, u01, u10, u11, u20, u21, u30, u31;             \
-  mlib_d64  d0, d1, d2, d3;                                     \
-  mlib_d64  *yPtr, *xPtr;                                       \
-  mlib_s32  cols;                                               \
-  mlib_d64  res;                                                \
-  mlib_f32  f_x01000100 = vis_to_float(0x01000100)
-
-/***************************************************************/
-#undef  CLIP
-#define CLIP()                                                  \
-  dstData += dstYStride;                                        \
-  xLeft = leftEdges[j];                                         \
-  xRight = rightEdges[j];                                       \
-  X = xStarts[j];                                               \
-  Y = yStarts[j];                                               \
-  PREPARE_DELTAS                                                \
-  if (xLeft > xRight)                                           \
-    continue;                                                   \
-  dstIndexPtr = (MLIB_TYPE *)dstData + xLeft;                   \
-  dstPixelPtr = dstRowPtr
-
-/***************************************************************/
-#define FADD_4BC_U8()                                           \
-  d0 = vis_fpadd16(d00, d10);                                   \
-  d1 = vis_fpadd16(d20, d30);                                   \
-  d0 = vis_fpadd16(d0, d1);                                     \
-  d2 = vis_fpadd16(d01, d11);                                   \
-  d3 = vis_fpadd16(d21, d31);                                   \
-  d2 = vis_fpadd16(d2, d3);                                     \
-  res = vis_fpack16_pair(d0, d2)
-
-/***************************************************************/
-#define LOAD_BC_U8_4CH_1PIXEL(mlib_filters_u8, mlib_filters_u8_4)      \
-  filterposy = (Y >> FILTER_SHIFT) & FILTER_MASK;                      \
-  yFilter = *((mlib_d64 *) ((mlib_u8 *)mlib_filters_u8 + filterposy)); \
-  filterposx = (X >> FILTER_SHIFT) & FILTER_MASK;                      \
-  xPtr = ((mlib_d64 *)((mlib_u8 *)mlib_filters_u8_4+4*filterposx));    \
-  xFilter0 = xPtr[0];                                                  \
-  xFilter1 = xPtr[1];                                                  \
-  xFilter2 = xPtr[2];                                                  \
-  xFilter3 = xPtr[3];                                                  \
-  X += dX;                                                             \
-  Y += dY;                                                             \
-  hi_row00 = flut[srcIndexPtr[0]];                                     \
-  lo_row00 = flut[srcIndexPtr[1]];                                     \
-  hi_row01 = flut[srcIndexPtr[2]];                                     \
-  lo_row01 = flut[srcIndexPtr[3]];                                     \
-  srcIndexPtr += srcYStride;                                           \
-  hi_row10 = flut[srcIndexPtr[0]];                                     \
-  lo_row10 = flut[srcIndexPtr[1]];                                     \
-  hi_row11 = flut[srcIndexPtr[2]];                                     \
-  lo_row11 = flut[srcIndexPtr[3]];                                     \
-  srcIndexPtr += srcYStride;                                           \
-  hi_row20 = flut[srcIndexPtr[0]];                                     \
-  lo_row20 = flut[srcIndexPtr[1]];                                     \
-  hi_row21 = flut[srcIndexPtr[2]];                                     \
-  lo_row21 = flut[srcIndexPtr[3]];                                     \
-  srcIndexPtr += srcYStride;                                           \
-  hi_row30 = flut[srcIndexPtr[0]];                                     \
-  lo_row30 = flut[srcIndexPtr[1]];                                     \
-  hi_row31 = flut[srcIndexPtr[2]];                                     \
-  lo_row31 = flut[srcIndexPtr[3]]
-
-/***************************************************************/
-#define NEXT_PIXEL_4BC()                                        \
-  xSrc = (X >> MLIB_SHIFT)-1;                                   \
-  ySrc = (Y >> MLIB_SHIFT)-1;                                   \
-  srcIndexPtr = (MLIB_TYPE *)lineAddr[ySrc] + xSrc
-
-/***************************************************************/
-#define RESULT_4BC_U8_1PIXEL(ind)                               \
-  v00 = vis_fmul8x16au(hi_row00, vis_read_hi(yFilter));         \
-  v01 = vis_fmul8x16au(lo_row00, vis_read_hi(yFilter));         \
-  v02 = vis_fmul8x16au(hi_row01, vis_read_hi(yFilter));         \
-  v03 = vis_fmul8x16au(lo_row01, vis_read_hi(yFilter));         \
-  v10 = vis_fmul8x16al(hi_row10, vis_read_hi(yFilter));         \
-  v11 = vis_fmul8x16al(lo_row10, vis_read_hi(yFilter));         \
-  sum0 = vis_fpadd16(v00, v10);                                 \
-  v12 = vis_fmul8x16al(hi_row11, vis_read_hi(yFilter));         \
-  sum1 = vis_fpadd16(v01, v11);                                 \
-  v13 = vis_fmul8x16al(lo_row11, vis_read_hi(yFilter));         \
-  sum2 = vis_fpadd16(v02, v12);                                 \
-  v20 = vis_fmul8x16au(hi_row20, vis_read_lo(yFilter));         \
-  sum3 = vis_fpadd16(v03, v13);                                 \
-  v21 = vis_fmul8x16au(lo_row20, vis_read_lo(yFilter));         \
-  sum0 = vis_fpadd16(sum0, v20);                                \
-  v22 = vis_fmul8x16au(hi_row21, vis_read_lo(yFilter));         \
-  sum1 = vis_fpadd16(sum1, v21);                                \
-  v23 = vis_fmul8x16au(lo_row21, vis_read_lo(yFilter));         \
-  sum2 = vis_fpadd16(sum2, v22);                                \
-  v30 = vis_fmul8x16al(hi_row30, vis_read_lo(yFilter));         \
-  sum3 = vis_fpadd16(sum3, v23);                                \
-  v31 = vis_fmul8x16al(lo_row30, vis_read_lo(yFilter));         \
-  sum0 = vis_fpadd16(sum0, v30);                                \
-  v32 = vis_fmul8x16al(hi_row31, vis_read_lo(yFilter));         \
-  sum1 = vis_fpadd16(sum1, v31);                                \
-  v33 = vis_fmul8x16al(lo_row31, vis_read_lo(yFilter));         \
-  sum2 = vis_fpadd16(sum2, v32);                                \
-  v00 = vis_fmul8sux16(sum0, xFilter0);                         \
-  sum3 = vis_fpadd16(sum3, v33);                                \
-  v01 = vis_fmul8ulx16(sum0, xFilter0);                         \
-  v10 = vis_fmul8sux16(sum1, xFilter1);                         \
-  d0##ind = vis_fpadd16(v00, v01);                              \
-  v11 = vis_fmul8ulx16(sum1, xFilter1);                         \
-  v20 = vis_fmul8sux16(sum2, xFilter2);                         \
-  d1##ind = vis_fpadd16(v10, v11);                              \
-  v21 = vis_fmul8ulx16(sum2, xFilter2);                         \
-  v30 = vis_fmul8sux16(sum3, xFilter3);                         \
-  d2##ind = vis_fpadd16(v20, v21);                              \
-  v31 = vis_fmul8ulx16(sum3, xFilter3);                         \
-  d3##ind = vis_fpadd16(v30, v31)
-
-/***************************************************************/
-#define BC_U8_4CH(ind, mlib_filters_u8, mlib_filters_u8_4)            \
-  v00 = vis_fmul8x16au(hi_row00, vis_read_hi(yFilter));               \
-  v01 = vis_fmul8x16au(lo_row00, vis_read_hi(yFilter));               \
-  v02 = vis_fmul8x16au(hi_row01, vis_read_hi(yFilter));               \
-  v03 = vis_fmul8x16au(lo_row01, vis_read_hi(yFilter));               \
-  hi_row00 = flut[srcIndexPtr[0]];                                    \
-  filterposy = (Y >> FILTER_SHIFT);                                   \
-  v10 = vis_fmul8x16al(hi_row10, vis_read_hi(yFilter));               \
-  lo_row00 = flut[srcIndexPtr[1]];                                    \
-  v11 = vis_fmul8x16al(lo_row10, vis_read_hi(yFilter));               \
-  sum0 = vis_fpadd16(v00, v10);                                       \
-  hi_row01 = flut[srcIndexPtr[2]];                                    \
-  v12 = vis_fmul8x16al(hi_row11, vis_read_hi(yFilter));               \
-  lo_row01 = flut[srcIndexPtr[3]];                                    \
-  filterposx = (X >> FILTER_SHIFT);                                   \
-  v13 = vis_fmul8x16al(lo_row11, vis_read_hi(yFilter));               \
-  srcIndexPtr += srcYStride;                                          \
-  hi_row10 = flut[srcIndexPtr[0]];                                    \
-  v20 = vis_fmul8x16au(hi_row20, vis_read_lo(yFilter));               \
-  sum1 = vis_fpadd16(v01, v11);                                       \
-  lo_row10 = flut[srcIndexPtr[1]];                                    \
-  X += dX;                                                            \
-  hi_row11 = flut[srcIndexPtr[2]];                                    \
-  v21 = vis_fmul8x16au(lo_row20, vis_read_lo(yFilter));               \
-  sum2 = vis_fpadd16(v02, v12);                                       \
-  lo_row11 = flut[srcIndexPtr[3]];                                    \
-  v22 = vis_fmul8x16au(hi_row21, vis_read_lo(yFilter));               \
-  srcIndexPtr += srcYStride;                                          \
-  hi_row20 = flut[srcIndexPtr[0]];                                    \
-  v23 = vis_fmul8x16au(lo_row21, vis_read_lo(yFilter));               \
-  sum3 = vis_fpadd16(v03, v13);                                       \
-  Y += dY;                                                            \
-  xSrc = (X >> MLIB_SHIFT)-1;                                         \
-  v30 = vis_fmul8x16al(hi_row30, vis_read_lo(yFilter));               \
-  sum0 = vis_fpadd16(sum0, v20);                                      \
-  lo_row20 = flut[srcIndexPtr[1]];                                    \
-  ySrc = (Y >> MLIB_SHIFT)-1;                                         \
-  hi_row21 = flut[srcIndexPtr[2]];                                    \
-  v31 = vis_fmul8x16al(lo_row30, vis_read_lo(yFilter));               \
-  sum1 = vis_fpadd16(sum1, v21);                                      \
-  filterposy &= FILTER_MASK;                                          \
-  lo_row21 = flut[srcIndexPtr[3]];                                    \
-  v32 = vis_fmul8x16al(hi_row31, vis_read_lo(yFilter));               \
-  srcIndexPtr += srcYStride;                                          \
-  filterposx &= FILTER_MASK;                                          \
-  v33 = vis_fmul8x16al(lo_row31, vis_read_lo(yFilter));               \
-  sum2 = vis_fpadd16(sum2, v22);                                      \
-  hi_row30 = flut[srcIndexPtr[0]];                                    \
-  sum3 = vis_fpadd16(sum3, v23);                                      \
-  sum0 = vis_fpadd16(sum0, v30);                                      \
-  lo_row30 = flut[srcIndexPtr[1]];                                    \
-  sum1 = vis_fpadd16(sum1, v31);                                      \
-  v00 = vis_fmul8sux16(sum0, xFilter0);                               \
-  hi_row31 = flut[srcIndexPtr[2]];                                    \
-  sum2 = vis_fpadd16(sum2, v32);                                      \
-  v01 = vis_fmul8ulx16(sum0, xFilter0);                               \
-  sum3 = vis_fpadd16(sum3, v33);                                      \
-  lo_row31 = flut[srcIndexPtr[3]];                                    \
-  v10 = vis_fmul8sux16(sum1, xFilter1);                               \
-  d0##ind = vis_fpadd16(v00, v01);                                    \
-  yFilter = *((mlib_d64 *)((mlib_u8 *)mlib_filters_u8 + filterposy)); \
-  v11 = vis_fmul8ulx16(sum1, xFilter1);                               \
-  xPtr = ((mlib_d64 *)((mlib_u8 *)mlib_filters_u8_4+4*filterposx));   \
-  xFilter0 = xPtr[0];                                                 \
-  v20 = vis_fmul8sux16(sum2, xFilter2);                               \
-  d1##ind = vis_fpadd16(v10, v11);                                    \
-  xFilter1 = xPtr[1];                                                 \
-  v21 = vis_fmul8ulx16(sum2, xFilter2);                               \
-  xFilter2 = xPtr[2];                                                 \
-  v30 = vis_fmul8sux16(sum3, xFilter3);                               \
-  d2##ind = vis_fpadd16(v20, v21);                                    \
-  xFilter3 = xPtr[3];                                                 \
-  v31 = vis_fmul8ulx16(sum3, xFilter3);                               \
-  srcIndexPtr = (MLIB_TYPE *)lineAddr[ySrc] + xSrc;                   \
-  d3##ind = vis_fpadd16(v30, v31)
-
-/***************************************************************/
-#define LOAD_BC_S16_4CH_1PIXEL(mlib_filters_s16_4)                      \
-  row00 = flut[srcIndexPtr[0]];                                         \
-  row01 = flut[srcIndexPtr[1]];                                         \
-  row02 = flut[srcIndexPtr[2]];                                         \
-  row03 = flut[srcIndexPtr[3]];                                         \
-  srcIndexPtr += srcYStride;                                            \
-  row10 = flut[srcIndexPtr[0]];                                         \
-  row11 = flut[srcIndexPtr[1]];                                         \
-  row12 = flut[srcIndexPtr[2]];                                         \
-  row13 = flut[srcIndexPtr[3]];                                         \
-  srcIndexPtr += srcYStride;                                            \
-  row20 = flut[srcIndexPtr[0]];                                         \
-  row21 = flut[srcIndexPtr[1]];                                         \
-  row22 = flut[srcIndexPtr[2]];                                         \
-  row23 = flut[srcIndexPtr[3]];                                         \
-  srcIndexPtr += srcYStride;                                            \
-  row30 = flut[srcIndexPtr[0]];                                         \
-  row31 = flut[srcIndexPtr[1]];                                         \
-  row32 = flut[srcIndexPtr[2]];                                         \
-  row33 = flut[srcIndexPtr[3]];                                         \
-  filterposy = (Y >> FILTER_SHIFT) & FILTER_MASK;                       \
-  yPtr = ((mlib_d64 *) ((mlib_u8 *)mlib_filters_s16_4 + filterposy*4)); \
-  yFilter0 = yPtr[0];                                                   \
-  yFilter1 = yPtr[1];                                                   \
-  yFilter2 = yPtr[2];                                                   \
-  yFilter3 = yPtr[3];                                                   \
-  filterposx = (X >> FILTER_SHIFT) & FILTER_MASK;                       \
-  xPtr = ((mlib_d64 *)((mlib_u8 *)mlib_filters_s16_4 + filterposx*4));  \
-  xFilter0 = xPtr[0];                                                   \
-  xFilter1 = xPtr[1];                                                   \
-  xFilter2 = xPtr[2];                                                   \
-  xFilter3 = xPtr[3];                                                   \
-  X += dX;                                                              \
-  Y += dY
-
-/***************************************************************/
-#define RESULT_4BC_S16_1PIXEL()                                 \
-  u00 = vis_fmul8sux16(row00, yFilter0);                        \
-  u01 = vis_fmul8ulx16(row00, yFilter0);                        \
-  u10 = vis_fmul8sux16(row01, yFilter0);                        \
-  u11 = vis_fmul8ulx16(row01, yFilter0);                        \
-  v00 = vis_fpadd16(u00, u01);                                  \
-  u20 = vis_fmul8sux16(row02, yFilter0);                        \
-  v01 = vis_fpadd16(u10, u11);                                  \
-  u21 = vis_fmul8ulx16(row02, yFilter0);                        \
-  u30 = vis_fmul8sux16(row03, yFilter0);                        \
-  u31 = vis_fmul8ulx16(row03, yFilter0);                        \
-  v02 = vis_fpadd16(u20, u21);                                  \
-  u00 = vis_fmul8sux16(row10, yFilter1);                        \
-  u01 = vis_fmul8ulx16(row10, yFilter1);                        \
-  v03 = vis_fpadd16(u30, u31);                                  \
-  u10 = vis_fmul8sux16(row11, yFilter1);                        \
-  u11 = vis_fmul8ulx16(row11, yFilter1);                        \
-  v10 = vis_fpadd16(u00, u01);                                  \
-  u20 = vis_fmul8sux16(row12, yFilter1);                        \
-  v11 = vis_fpadd16(u10, u11);                                  \
-  u21 = vis_fmul8ulx16(row12, yFilter1);                        \
-  u30 = vis_fmul8sux16(row13, yFilter1);                        \
-  u31 = vis_fmul8ulx16(row13, yFilter1);                        \
-  u00 = vis_fmul8sux16(row20, yFilter2);                        \
-  v12 = vis_fpadd16(u20, u21);                                  \
-  u01 = vis_fmul8ulx16(row20, yFilter2);                        \
-  v13 = vis_fpadd16(u30, u31);                                  \
-  u10 = vis_fmul8sux16(row21, yFilter2);                        \
-  u11 = vis_fmul8ulx16(row21, yFilter2);                        \
-  v20 = vis_fpadd16(u00, u01);                                  \
-  u20 = vis_fmul8sux16(row22, yFilter2);                        \
-  sum0 = vis_fpadd16(v00, v10);                                 \
-  u21 = vis_fmul8ulx16(row22, yFilter2);                        \
-  u30 = vis_fmul8sux16(row23, yFilter2);                        \
-  u31 = vis_fmul8ulx16(row23, yFilter2);                        \
-  u00 = vis_fmul8sux16(row30, yFilter3);                        \
-  u01 = vis_fmul8ulx16(row30, yFilter3);                        \
-  v21 = vis_fpadd16(u10, u11);                                  \
-  sum1 = vis_fpadd16(v01, v11);                                 \
-  u10 = vis_fmul8sux16(row31, yFilter3);                        \
-  sum2 = vis_fpadd16(v02, v12);                                 \
-  sum3 = vis_fpadd16(v03, v13);                                 \
-  v22 = vis_fpadd16(u20, u21);                                  \
-  u11 = vis_fmul8ulx16(row31, yFilter3);                        \
-  sum0 = vis_fpadd16(sum0, v20);                                \
-  u20 = vis_fmul8sux16(row32, yFilter3);                        \
-  u21 = vis_fmul8ulx16(row32, yFilter3);                        \
-  v23 = vis_fpadd16(u30, u31);                                  \
-  v30 = vis_fpadd16(u00, u01);                                  \
-  sum1 = vis_fpadd16(sum1, v21);                                \
-  u30 = vis_fmul8sux16(row33, yFilter3);                        \
-  u31 = vis_fmul8ulx16(row33, yFilter3);                        \
-  v31 = vis_fpadd16(u10, u11);                                  \
-  sum2 = vis_fpadd16(sum2, v22);                                \
-  sum3 = vis_fpadd16(sum3, v23);                                \
-  v32 = vis_fpadd16(u20, u21);                                  \
-  sum0 = vis_fpadd16(sum0, v30);                                \
-  v33 = vis_fpadd16(u30, u31);                                  \
-  v00 = vis_fmul8sux16(sum0, xFilter0);                         \
-  sum1 = vis_fpadd16(sum1, v31);                                \
-  sum2 = vis_fpadd16(sum2, v32);                                \
-  v01 = vis_fmul8ulx16(sum0, xFilter0);                         \
-  v10 = vis_fmul8sux16(sum1, xFilter1);                         \
-  sum3 = vis_fpadd16(sum3, v33);                                \
-  v11 = vis_fmul8ulx16(sum1, xFilter1);                         \
-  d0 = vis_fpadd16(v00, v01);                                   \
-  v20 = vis_fmul8sux16(sum2, xFilter2);                         \
-  v21 = vis_fmul8ulx16(sum2, xFilter2);                         \
-  d1 = vis_fpadd16(v10, v11);                                   \
-  v30 = vis_fmul8sux16(sum3, xFilter3);                         \
-  v31 = vis_fmul8ulx16(sum3, xFilter3);                         \
-  d2 = vis_fpadd16(v20, v21);                                   \
-  d3 = vis_fpadd16(v30, v31);                                   \
-  d0 = vis_fpadd16(d0, d1);                                     \
-  d2 = vis_fpadd16(d2, d3);                                     \
-  d0 = vis_fpadd16(d0, d2);                                     \
-  d2 = vis_fmuld8sux16(f_x01000100, vis_read_hi(d0));           \
-  d3 = vis_fmuld8sux16(f_x01000100, vis_read_lo(d0));           \
-  res = vis_fpackfix_pair(d2, d3)
-
-/***************************************************************/
-#define BC_S16_4CH(mlib_filters_s16_4)                                  \
-  u00 = vis_fmul8sux16(row00, yFilter0);                                \
-  u01 = vis_fmul8ulx16(row00, yFilter0);                                \
-  u10 = vis_fmul8sux16(row01, yFilter0);                                \
-  u11 = vis_fmul8ulx16(row01, yFilter0);                                \
-  v00 = vis_fpadd16(u00, u01);                                          \
-  u20 = vis_fmul8sux16(row02, yFilter0);                                \
-  v01 = vis_fpadd16(u10, u11);                                          \
-  u21 = vis_fmul8ulx16(row02, yFilter0);                                \
-  u30 = vis_fmul8sux16(row03, yFilter0);                                \
-  u31 = vis_fmul8ulx16(row03, yFilter0);                                \
-  v02 = vis_fpadd16(u20, u21);                                          \
-  row00 = flut[srcIndexPtr[0]];                                         \
-  u00 = vis_fmul8sux16(row10, yFilter1);                                \
-  u01 = vis_fmul8ulx16(row10, yFilter1);                                \
-  filterposy = (Y >> FILTER_SHIFT);                                     \
-  v03 = vis_fpadd16(u30, u31);                                          \
-  row01 = flut[srcIndexPtr[1]];                                         \
-  u10 = vis_fmul8sux16(row11, yFilter1);                                \
-  u11 = vis_fmul8ulx16(row11, yFilter1);                                \
-  v10 = vis_fpadd16(u00, u01);                                          \
-  row02 = flut[srcIndexPtr[2]];                                         \
-  u20 = vis_fmul8sux16(row12, yFilter1);                                \
-  v11 = vis_fpadd16(u10, u11);                                          \
-  u21 = vis_fmul8ulx16(row12, yFilter1);                                \
-  u30 = vis_fmul8sux16(row13, yFilter1);                                \
-  row03 = flut[srcIndexPtr[3]];                                         \
-  u31 = vis_fmul8ulx16(row13, yFilter1);                                \
-  u00 = vis_fmul8sux16(row20, yFilter2);                                \
-  filterposx = (X >> FILTER_SHIFT);                                     \
-  srcIndexPtr += srcYStride;                                            \
-  v12 = vis_fpadd16(u20, u21);                                          \
-  u01 = vis_fmul8ulx16(row20, yFilter2);                                \
-  v13 = vis_fpadd16(u30, u31);                                          \
-  row10 = flut[srcIndexPtr[0]];                                         \
-  u10 = vis_fmul8sux16(row21, yFilter2);                                \
-  X += dX;                                                              \
-  u11 = vis_fmul8ulx16(row21, yFilter2);                                \
-  v20 = vis_fpadd16(u00, u01);                                          \
-  row11 = flut[srcIndexPtr[1]];                                         \
-  u20 = vis_fmul8sux16(row22, yFilter2);                                \
-  sum0 = vis_fpadd16(v00, v10);                                         \
-  u21 = vis_fmul8ulx16(row22, yFilter2);                                \
-  row12 = flut[srcIndexPtr[2]];                                         \
-  u30 = vis_fmul8sux16(row23, yFilter2);                                \
-  u31 = vis_fmul8ulx16(row23, yFilter2);                                \
-  row13 = flut[srcIndexPtr[3]];                                         \
-  u00 = vis_fmul8sux16(row30, yFilter3);                                \
-  srcIndexPtr += srcYStride;                                            \
-  u01 = vis_fmul8ulx16(row30, yFilter3);                                \
-  v21 = vis_fpadd16(u10, u11);                                          \
-  Y += dY;                                                              \
-  xSrc = (X >> MLIB_SHIFT)-1;                                           \
-  sum1 = vis_fpadd16(v01, v11);                                         \
-  row20 = flut[srcIndexPtr[0]];                                         \
-  u10 = vis_fmul8sux16(row31, yFilter3);                                \
-  sum2 = vis_fpadd16(v02, v12);                                         \
-  sum3 = vis_fpadd16(v03, v13);                                         \
-  ySrc = (Y >> MLIB_SHIFT)-1;                                           \
-  row21 = flut[srcIndexPtr[1]];                                         \
-  v22 = vis_fpadd16(u20, u21);                                          \
-  u11 = vis_fmul8ulx16(row31, yFilter3);                                \
-  sum0 = vis_fpadd16(sum0, v20);                                        \
-  u20 = vis_fmul8sux16(row32, yFilter3);                                \
-  row22 = flut[srcIndexPtr[2]];                                         \
-  u21 = vis_fmul8ulx16(row32, yFilter3);                                \
-  v23 = vis_fpadd16(u30, u31);                                          \
-  v30 = vis_fpadd16(u00, u01);                                          \
-  filterposy &= FILTER_MASK;                                            \
-  sum1 = vis_fpadd16(sum1, v21);                                        \
-  u30 = vis_fmul8sux16(row33, yFilter3);                                \
-  row23 = flut[srcIndexPtr[3]];                                         \
-  u31 = vis_fmul8ulx16(row33, yFilter3);                                \
-  srcIndexPtr += srcYStride;                                            \
-  filterposx &= FILTER_MASK;                                            \
-  v31 = vis_fpadd16(u10, u11);                                          \
-  row30 = flut[srcIndexPtr[0]];                                         \
-  sum2 = vis_fpadd16(sum2, v22);                                        \
-  sum3 = vis_fpadd16(sum3, v23);                                        \
-  row31 = flut[srcIndexPtr[1]];                                         \
-  v32 = vis_fpadd16(u20, u21);                                          \
-  sum0 = vis_fpadd16(sum0, v30);                                        \
-  row32 = flut[srcIndexPtr[2]];                                         \
-  v33 = vis_fpadd16(u30, u31);                                          \
-  row33 = flut[srcIndexPtr[3]];                                         \
-  v00 = vis_fmul8sux16(sum0, xFilter0);                                 \
-  yPtr = ((mlib_d64 *) ((mlib_u8 *)mlib_filters_s16_4 + filterposy*4)); \
-  sum1 = vis_fpadd16(sum1, v31);                                        \
-  yFilter0 = yPtr[0];                                                   \
-  sum2 = vis_fpadd16(sum2, v32);                                        \
-  v01 = vis_fmul8ulx16(sum0, xFilter0);                                 \
-  yFilter1 = yPtr[1];                                                   \
-  v10 = vis_fmul8sux16(sum1, xFilter1);                                 \
-  sum3 = vis_fpadd16(sum3, v33);                                        \
-  yFilter2 = yPtr[2];                                                   \
-  v11 = vis_fmul8ulx16(sum1, xFilter1);                                 \
-  d0 = vis_fpadd16(v00, v01);                                           \
-  yFilter3 = yPtr[3];                                                   \
-  xPtr = ((mlib_d64 *)((mlib_u8 *)mlib_filters_s16_4 + filterposx*4));  \
-  v20 = vis_fmul8sux16(sum2, xFilter2);                                 \
-  xFilter0 = xPtr[0];                                                   \
-  v21 = vis_fmul8ulx16(sum2, xFilter2);                                 \
-  d1 = vis_fpadd16(v10, v11);                                           \
-  xFilter1 = xPtr[1];                                                   \
-  v30 = vis_fmul8sux16(sum3, xFilter3);                                 \
-  v31 = vis_fmul8ulx16(sum3, xFilter3);                                 \
-  d2 = vis_fpadd16(v20, v21);                                           \
-  xFilter2 = xPtr[2];                                                   \
-  d3 = vis_fpadd16(v30, v31);                                           \
-  xFilter3 = xPtr[3];                                                   \
-  srcIndexPtr = (MLIB_TYPE *)lineAddr[ySrc] + xSrc
-
-/***************************************************************/
-#define FADD_4BC_S16()                                          \
-  d0 = vis_fpadd16(d0, d1);                                     \
-  d2 = vis_fpadd16(d2, d3);                                     \
-  d0 = vis_fpadd16(d0, d2);                                     \
-  d2 = vis_fmuld8sux16(f_x01000100, vis_read_hi(d0));           \
-  d3 = vis_fmuld8sux16(f_x01000100, vis_read_lo(d0));           \
-  res = vis_fpackfix_pair(d2, d3)
-
-/***************************************************************/
-#undef  MLIB_TYPE
-#define MLIB_TYPE mlib_u8
-
-/***************************************************************/
-#undef  FILTER_SHIFT
-#define FILTER_SHIFT  5
-#undef  FILTER_MASK
-#define FILTER_MASK   (((1 << 8) - 1) << 3)
-
-/***************************************************************/
-mlib_status mlib_ImageAffineIndex_U8_U8_3CH_BC(mlib_affine_param *param,
-                                               const void        *colormap)
-{
-  DECLAREVAR();
-  DECLAREVAR_U8();
-  mlib_f32  *flut   = (mlib_f32 *)mlib_ImageGetLutNormalTable(colormap) -
-  mlib_ImageGetLutOffset(colormap);
-  mlib_d64  dstRowData[MLIB_LIMIT/2];
-  mlib_d64  *dstRowPtr = dstRowData;
-  const mlib_s16 *mlib_filters_table_u8, *mlib_filters_table_u8_4;
-
-  if (filter == MLIB_BICUBIC) {
-    mlib_filters_table_u8   = mlib_filters_u8_bc;
-    mlib_filters_table_u8_4 = mlib_filters_u8_bc_4;
-  } else {
-    mlib_filters_table_u8   = mlib_filters_u8_bc2;
-    mlib_filters_table_u8_4 = mlib_filters_u8_bc2_4;
-  }
-
-  if (max_xsize > MLIB_LIMIT) {
-    dstRowPtr = mlib_malloc(sizeof(mlib_d64) * ((max_xsize + 1) >> 1));
-
-    if (dstRowPtr == NULL) return MLIB_FAILURE;
-  }
-
-  vis_write_gsr(3 << 3);
-
-  for (j = yStart; j <= yFinish; j++) {
-
-    CLIP();
-
-    cols = xRight - xLeft + 1;
-
-    i = 0;
-
-    if (i <= cols - 6) {
-
-      NEXT_PIXEL_4BC();
-      LOAD_BC_U8_4CH_1PIXEL(mlib_filters_table_u8, mlib_filters_table_u8_4);
-
-      NEXT_PIXEL_4BC();
-
-      BC_U8_4CH(0, mlib_filters_table_u8, mlib_filters_table_u8_4);
-      BC_U8_4CH(1, mlib_filters_table_u8, mlib_filters_table_u8_4);
-      FADD_4BC_U8();
-
-      BC_U8_4CH(0, mlib_filters_table_u8, mlib_filters_table_u8_4);
-      BC_U8_4CH(1, mlib_filters_table_u8, mlib_filters_table_u8_4);
-
-#pragma pipeloop(0)
-      for (; i <= cols-8; i += 2) {
-        *dstPixelPtr++ = res;
-
-        FADD_4BC_U8();
-        BC_U8_4CH(0, mlib_filters_table_u8, mlib_filters_table_u8_4);
-        BC_U8_4CH(1, mlib_filters_table_u8, mlib_filters_table_u8_4);
-      }
-
-      *dstPixelPtr++ = res;
-
-      FADD_4BC_U8();
-      *dstPixelPtr++ = res;
-
-      RESULT_4BC_U8_1PIXEL(0);
-      LOAD_BC_U8_4CH_1PIXEL(mlib_filters_table_u8, mlib_filters_table_u8_4);
-      RESULT_4BC_U8_1PIXEL(1);
-      FADD_4BC_U8();
-
-      *dstPixelPtr++ = res;
-      i += 6;
-    }
-
-    if (i <= cols-4) {
-      NEXT_PIXEL_4BC();
-      LOAD_BC_U8_4CH_1PIXEL(mlib_filters_table_u8, mlib_filters_table_u8_4);
-
-      NEXT_PIXEL_4BC();
-
-      BC_U8_4CH(0, mlib_filters_table_u8, mlib_filters_table_u8_4);
-      BC_U8_4CH(1, mlib_filters_table_u8, mlib_filters_table_u8_4);
-      FADD_4BC_U8();
-      *dstPixelPtr++ = res;
-
-      RESULT_4BC_U8_1PIXEL(0);
-      LOAD_BC_U8_4CH_1PIXEL(mlib_filters_table_u8, mlib_filters_table_u8_4);
-      RESULT_4BC_U8_1PIXEL(1);
-      FADD_4BC_U8();
-
-      *dstPixelPtr++ = res;
-      i += 4;
-    }
-
-    if (i <= cols-2) {
-      NEXT_PIXEL_4BC();
-      LOAD_BC_U8_4CH_1PIXEL(mlib_filters_table_u8, mlib_filters_table_u8_4);
-      RESULT_4BC_U8_1PIXEL(0);
-
-      NEXT_PIXEL_4BC();
-      LOAD_BC_U8_4CH_1PIXEL(mlib_filters_table_u8, mlib_filters_table_u8_4);
-      RESULT_4BC_U8_1PIXEL(1);
-      FADD_4BC_U8();
-
-      *dstPixelPtr++ = res;
-      i += 2;
-    }
-
-    if (i < cols) {
-      NEXT_PIXEL_4BC();
-      LOAD_BC_U8_4CH_1PIXEL(mlib_filters_table_u8, mlib_filters_table_u8_4);
-      RESULT_4BC_U8_1PIXEL(0);
-
-      d0 = vis_fpadd16(d00, d10);
-      d1 = vis_fpadd16(d20, d30);
-      d0 = vis_fpadd16(d0, d1);
-      res = vis_fpack16_pair(d0, d0);
-      *dstPixelPtr++ = res;
-    }
-
-    mlib_ImageColorTrue2IndexLine_U8_U8_3_in_4((mlib_u8 *)dstRowPtr,
-                                               dstIndexPtr,
-                                               xRight - xLeft + 1,
-                                               colormap);
-  }
-
-  if (dstRowPtr != dstRowData) mlib_free(dstRowPtr);
-
-  return MLIB_SUCCESS;
-}
-
-/***************************************************************/
-#undef  FILTER_SHIFT
-#define FILTER_SHIFT  4
-#undef  FILTER_MASK
-#define FILTER_MASK   (((1 << 9) - 1) << 3)
-
-/***************************************************************/
-mlib_status mlib_ImageAffineIndex_U8_S16_3CH_BC(mlib_affine_param *param,
-                                                const void        *colormap)
-{
-  DECLAREVAR();
-  DECLAREVAR_S16();
-  mlib_d64 *flut   = (mlib_d64 *)mlib_ImageGetLutNormalTable(colormap) -
-  mlib_ImageGetLutOffset(colormap);
-  mlib_d64 dstRowData[MLIB_LIMIT];
-  mlib_d64 *dstRowPtr = dstRowData;
-  const mlib_s16 *mlib_filters_table_s16_4;
-
-  if (filter == MLIB_BICUBIC) {
-    mlib_filters_table_s16_4 = mlib_filters_s16_bc_4;
-  } else {
-    mlib_filters_table_s16_4 = mlib_filters_s16_bc2_4;
-  }
-
-  if (max_xsize > MLIB_LIMIT) {
-    dstRowPtr = mlib_malloc(sizeof(mlib_d64) * max_xsize);
-
-    if (dstRowPtr == NULL) return MLIB_FAILURE;
-  }
-
-  for (j = yStart; j <= yFinish; j++) {
-
-    CLIP();
-
-    vis_write_gsr(10 << 3);
-
-    cols = xRight - xLeft + 1;
-    i = 0;
-
-    if (i <= cols - 4) {
-
-      NEXT_PIXEL_4BC();
-      LOAD_BC_S16_4CH_1PIXEL(mlib_filters_table_s16_4);
-
-      NEXT_PIXEL_4BC();
-
-      BC_S16_4CH(mlib_filters_table_s16_4);
-      FADD_4BC_S16();
-
-      BC_S16_4CH(mlib_filters_table_s16_4);
-
-#pragma pipeloop(0)
-
-      for (; i < cols-4; i++) {
-        *dstPixelPtr++ = res;
-
-        FADD_4BC_S16();
-        BC_S16_4CH(mlib_filters_table_s16_4);
-      }
-
-      *dstPixelPtr++ = res;
-
-      FADD_4BC_S16();
-      *dstPixelPtr++ = res;
-
-      RESULT_4BC_S16_1PIXEL();
-      *dstPixelPtr++ = res;
-
-      LOAD_BC_S16_4CH_1PIXEL(mlib_filters_table_s16_4);
-      RESULT_4BC_S16_1PIXEL();
-      *dstPixelPtr++ = res;
-      i += 4;
-    }
-
-#pragma pipeloop(0)
-    for (; i < cols; i++) {
-      NEXT_PIXEL_4BC();
-      LOAD_BC_S16_4CH_1PIXEL(mlib_filters_table_s16_4);
-      RESULT_4BC_S16_1PIXEL();
-      *dstPixelPtr++ = res;
-    }
-
-    mlib_ImageColorTrue2IndexLine_S16_U8_3_in_4((mlib_s16 *)dstRowPtr,
-                                                dstIndexPtr,
-                                                xRight - xLeft + 1,
-                                                colormap);
-  }
-
-  if (dstRowPtr != dstRowData) mlib_free(dstRowPtr);
-
-  return MLIB_SUCCESS;
-}
-
-/***************************************************************/
-#undef  FILTER_SHIFT
-#define FILTER_SHIFT  5
-#undef  FILTER_MASK
-#define FILTER_MASK   (((1 << 8) - 1) << 3)
-
-/***************************************************************/
-mlib_status mlib_ImageAffineIndex_U8_U8_4CH_BC(mlib_affine_param *param,
-                                               const void        *colormap)
-{
-  DECLAREVAR();
-  DECLAREVAR_U8();
-  mlib_f32  *flut   = (mlib_f32 *)mlib_ImageGetLutNormalTable(colormap) -
-  mlib_ImageGetLutOffset(colormap);
-  mlib_d64  dstRowData[MLIB_LIMIT/2];
-  mlib_d64  *dstRowPtr = dstRowData;
-  const mlib_s16 *mlib_filters_table_u8, *mlib_filters_table_u8_4;
-
-  if (filter == MLIB_BICUBIC) {
-    mlib_filters_table_u8   = mlib_filters_u8_bc;
-    mlib_filters_table_u8_4 = mlib_filters_u8_bc_4;
-  } else {
-    mlib_filters_table_u8   = mlib_filters_u8_bc2;
-    mlib_filters_table_u8_4 = mlib_filters_u8_bc2_4;
-  }
-
-  if (max_xsize > MLIB_LIMIT) {
-    dstRowPtr = mlib_malloc(sizeof(mlib_d64) * ((max_xsize + 1) >> 1));
-
-    if (dstRowPtr == NULL) return MLIB_FAILURE;
-  }
-
-  vis_write_gsr(3 << 3);
-
-  for (j = yStart; j <= yFinish; j++) {
-
-    CLIP();
-
-    cols = xRight - xLeft + 1;
-
-    i = 0;
-
-    if (i <= cols - 6) {
-
-      NEXT_PIXEL_4BC();
-      LOAD_BC_U8_4CH_1PIXEL(mlib_filters_table_u8, mlib_filters_table_u8_4);
-
-      NEXT_PIXEL_4BC();
-
-      BC_U8_4CH(0, mlib_filters_table_u8, mlib_filters_table_u8_4);
-      BC_U8_4CH(1, mlib_filters_table_u8, mlib_filters_table_u8_4);
-      FADD_4BC_U8();
-
-      BC_U8_4CH(0, mlib_filters_table_u8, mlib_filters_table_u8_4);
-      BC_U8_4CH(1, mlib_filters_table_u8, mlib_filters_table_u8_4);
-
-#pragma pipeloop(0)
-      for (; i <= cols-8; i += 2) {
-        *dstPixelPtr++ = res;
-
-        FADD_4BC_U8();
-        BC_U8_4CH(0, mlib_filters_table_u8, mlib_filters_table_u8_4);
-        BC_U8_4CH(1, mlib_filters_table_u8, mlib_filters_table_u8_4);
-      }
-
-      *dstPixelPtr++ = res;
-
-      FADD_4BC_U8();
-      *dstPixelPtr++ = res;
-
-      RESULT_4BC_U8_1PIXEL(0);
-      LOAD_BC_U8_4CH_1PIXEL(mlib_filters_table_u8, mlib_filters_table_u8_4);
-      RESULT_4BC_U8_1PIXEL(1);
-      FADD_4BC_U8();
-
-      *dstPixelPtr++ = res;
-      i += 6;
-    }
-
-    if (i <= cols-4) {
-      NEXT_PIXEL_4BC();
-      LOAD_BC_U8_4CH_1PIXEL(mlib_filters_table_u8, mlib_filters_table_u8_4);
-
-      NEXT_PIXEL_4BC();
-
-      BC_U8_4CH(0, mlib_filters_table_u8, mlib_filters_table_u8_4);
-      BC_U8_4CH(1, mlib_filters_table_u8, mlib_filters_table_u8_4);
-      FADD_4BC_U8();
-      *dstPixelPtr++ = res;
-
-      RESULT_4BC_U8_1PIXEL(0);
-      LOAD_BC_U8_4CH_1PIXEL(mlib_filters_table_u8, mlib_filters_table_u8_4);
-      RESULT_4BC_U8_1PIXEL(1);
-      FADD_4BC_U8();
-
-      *dstPixelPtr++ = res;
-      i += 4;
-    }
-
-    if (i <= cols-2) {
-      NEXT_PIXEL_4BC();
-      LOAD_BC_U8_4CH_1PIXEL(mlib_filters_table_u8, mlib_filters_table_u8_4);
-      RESULT_4BC_U8_1PIXEL(0);
-
-      NEXT_PIXEL_4BC();
-      LOAD_BC_U8_4CH_1PIXEL(mlib_filters_table_u8, mlib_filters_table_u8_4);
-      RESULT_4BC_U8_1PIXEL(1);
-      FADD_4BC_U8();
-
-      *dstPixelPtr++ = res;
-      i += 2;
-    }
-
-    if (i < cols) {
-      NEXT_PIXEL_4BC();
-      LOAD_BC_U8_4CH_1PIXEL(mlib_filters_table_u8, mlib_filters_table_u8_4);
-      RESULT_4BC_U8_1PIXEL(0);
-
-      d0 = vis_fpadd16(d00, d10);
-      d1 = vis_fpadd16(d20, d30);
-      d0 = vis_fpadd16(d0, d1);
-      res = vis_fpack16_pair(d0, d0);
-      *dstPixelPtr++ = res;
-    }
-
-    mlib_ImageColorTrue2IndexLine_U8_U8_4((mlib_u8 *)dstRowPtr,
-                                          dstIndexPtr,
-                                          xRight - xLeft + 1,
-                                          colormap);
-  }
-
-  if (dstRowPtr != dstRowData) mlib_free(dstRowPtr);
-
-  return MLIB_SUCCESS;
-}
-
-/***************************************************************/
-#undef  FILTER_SHIFT
-#define FILTER_SHIFT  4
-#undef  FILTER_MASK
-#define FILTER_MASK   (((1 << 9) - 1) << 3)
-
-/***************************************************************/
-mlib_status mlib_ImageAffineIndex_U8_S16_4CH_BC(mlib_affine_param *param,
-                                                const void        *colormap)
-{
-  DECLAREVAR();
-  DECLAREVAR_S16();
-  mlib_d64 *flut   = (mlib_d64 *)mlib_ImageGetLutNormalTable(colormap) -
-  mlib_ImageGetLutOffset(colormap);
-  mlib_d64 dstRowData[MLIB_LIMIT];
-  mlib_d64 *dstRowPtr = dstRowData;
-  const mlib_s16 *mlib_filters_table_s16_4;
-
-  if (filter == MLIB_BICUBIC) {
-    mlib_filters_table_s16_4 = mlib_filters_s16_bc_4;
-  } else {
-    mlib_filters_table_s16_4 = mlib_filters_s16_bc2_4;
-  }
-
-  if (max_xsize > MLIB_LIMIT) {
-    dstRowPtr = mlib_malloc(sizeof(mlib_d64) * max_xsize);
-
-    if (dstRowPtr == NULL) return MLIB_FAILURE;
-  }
-
-  for (j = yStart; j <= yFinish; j++) {
-
-    CLIP();
-
-    vis_write_gsr(10 << 3);
-
-    cols = xRight - xLeft + 1;
-    i = 0;
-
-    if (i <= cols - 4) {
-
-      NEXT_PIXEL_4BC();
-      LOAD_BC_S16_4CH_1PIXEL(mlib_filters_table_s16_4);
-
-      NEXT_PIXEL_4BC();
-
-      BC_S16_4CH(mlib_filters_table_s16_4);
-      FADD_4BC_S16();
-
-      BC_S16_4CH(mlib_filters_table_s16_4);
-
-#pragma pipeloop(0)
-
-      for (; i < cols-4; i++) {
-        *dstPixelPtr++ = res;
-
-        FADD_4BC_S16();
-        BC_S16_4CH(mlib_filters_table_s16_4);
-      }
-
-      *dstPixelPtr++ = res;
-
-      FADD_4BC_S16();
-      *dstPixelPtr++ = res;
-
-      RESULT_4BC_S16_1PIXEL();
-      *dstPixelPtr++ = res;
-
-      LOAD_BC_S16_4CH_1PIXEL(mlib_filters_table_s16_4);
-      RESULT_4BC_S16_1PIXEL();
-      *dstPixelPtr++ = res;
-      i += 4;
-    }
-
-#pragma pipeloop(0)
-    for (; i < cols; i++) {
-      NEXT_PIXEL_4BC();
-      LOAD_BC_S16_4CH_1PIXEL(mlib_filters_table_s16_4);
-      RESULT_4BC_S16_1PIXEL();
-      *dstPixelPtr++ = res;
-    }
-
-    mlib_ImageColorTrue2IndexLine_S16_U8_4((mlib_s16 *)dstRowPtr,
-                                           dstIndexPtr,
-                                           xRight - xLeft + 1,
-                                           colormap);
-  }
-
-  if (dstRowPtr != dstRowData) mlib_free(dstRowPtr);
-
-  return MLIB_SUCCESS;
-}
-
-/***************************************************************/
-#undef  MLIB_TYPE
-#define MLIB_TYPE mlib_s16
-
-/***************************************************************/
-#undef  FILTER_SHIFT
-#define FILTER_SHIFT  5
-#undef  FILTER_MASK
-#define FILTER_MASK   (((1 << 8) - 1) << 3)
-
-/***************************************************************/
-mlib_status mlib_ImageAffineIndex_S16_U8_3CH_BC(mlib_affine_param *param,
-                                                const void        *colormap)
-{
-  DECLAREVAR();
-  DECLAREVAR_U8();
-  mlib_f32  *flut   = (mlib_f32 *)mlib_ImageGetLutNormalTable(colormap) -
-  mlib_ImageGetLutOffset(colormap);
-  mlib_d64  dstRowData[MLIB_LIMIT/2];
-  mlib_d64  *dstRowPtr = dstRowData;
-  const mlib_s16 *mlib_filters_table_u8, *mlib_filters_table_u8_4;
-
-  if (filter == MLIB_BICUBIC) {
-    mlib_filters_table_u8   = mlib_filters_u8_bc;
-    mlib_filters_table_u8_4 = mlib_filters_u8_bc_4;
-  } else {
-    mlib_filters_table_u8   = mlib_filters_u8_bc2;
-    mlib_filters_table_u8_4 = mlib_filters_u8_bc2_4;
-  }
-
-  srcYStride >>= 1;
-
-  if (max_xsize > MLIB_LIMIT) {
-    dstRowPtr = mlib_malloc(sizeof(mlib_d64) * ((max_xsize + 1) >> 1));
-
-    if (dstRowPtr == NULL) return MLIB_FAILURE;
-  }
-
-  vis_write_gsr(3 << 3);
-
-  for (j = yStart; j <= yFinish; j++) {
-
-    CLIP();
-
-    cols = xRight - xLeft + 1;
-
-    i = 0;
-
-    if (i <= cols - 6) {
-
-      NEXT_PIXEL_4BC();
-      LOAD_BC_U8_4CH_1PIXEL(mlib_filters_table_u8, mlib_filters_table_u8_4);
-
-      NEXT_PIXEL_4BC();
-
-      BC_U8_4CH(0, mlib_filters_table_u8, mlib_filters_table_u8_4);
-      BC_U8_4CH(1, mlib_filters_table_u8, mlib_filters_table_u8_4);
-      FADD_4BC_U8();
-
-      BC_U8_4CH(0, mlib_filters_table_u8, mlib_filters_table_u8_4);
-      BC_U8_4CH(1, mlib_filters_table_u8, mlib_filters_table_u8_4);
-
-#pragma pipeloop(0)
-      for (; i <= cols-8; i += 2) {
-        *dstPixelPtr++ = res;
-
-        FADD_4BC_U8();
-        BC_U8_4CH(0, mlib_filters_table_u8, mlib_filters_table_u8_4);
-        BC_U8_4CH(1, mlib_filters_table_u8, mlib_filters_table_u8_4);
-      }
-
-      *dstPixelPtr++ = res;
-
-      FADD_4BC_U8();
-      *dstPixelPtr++ = res;
-
-      RESULT_4BC_U8_1PIXEL(0);
-      LOAD_BC_U8_4CH_1PIXEL(mlib_filters_table_u8, mlib_filters_table_u8_4);
-      RESULT_4BC_U8_1PIXEL(1);
-      FADD_4BC_U8();
-
-      *dstPixelPtr++ = res;
-      i += 6;
-    }
-
-    if (i <= cols-4) {
-      NEXT_PIXEL_4BC();
-      LOAD_BC_U8_4CH_1PIXEL(mlib_filters_table_u8, mlib_filters_table_u8_4);
-
-      NEXT_PIXEL_4BC();
-
-      BC_U8_4CH(0, mlib_filters_table_u8, mlib_filters_table_u8_4);
-      BC_U8_4CH(1, mlib_filters_table_u8, mlib_filters_table_u8_4);
-      FADD_4BC_U8();
-      *dstPixelPtr++ = res;
-
-      RESULT_4BC_U8_1PIXEL(0);
-      LOAD_BC_U8_4CH_1PIXEL(mlib_filters_table_u8, mlib_filters_table_u8_4);
-      RESULT_4BC_U8_1PIXEL(1);
-      FADD_4BC_U8();
-
-      *dstPixelPtr++ = res;
-      i += 4;
-    }
-
-    if (i <= cols-2) {
-      NEXT_PIXEL_4BC();
-      LOAD_BC_U8_4CH_1PIXEL(mlib_filters_table_u8, mlib_filters_table_u8_4);
-      RESULT_4BC_U8_1PIXEL(0);
-
-      NEXT_PIXEL_4BC();
-      LOAD_BC_U8_4CH_1PIXEL(mlib_filters_table_u8, mlib_filters_table_u8_4);
-      RESULT_4BC_U8_1PIXEL(1);
-      FADD_4BC_U8();
-
-      *dstPixelPtr++ = res;
-      i += 2;
-    }
-
-    if (i < cols) {
-      NEXT_PIXEL_4BC();
-      LOAD_BC_U8_4CH_1PIXEL(mlib_filters_table_u8, mlib_filters_table_u8_4);
-      RESULT_4BC_U8_1PIXEL(0);
-
-      d0 = vis_fpadd16(d00, d10);
-      d1 = vis_fpadd16(d20, d30);
-      d0 = vis_fpadd16(d0, d1);
-      res = vis_fpack16_pair(d0, d0);
-      *dstPixelPtr++ = res;
-    }
-
-    mlib_ImageColorTrue2IndexLine_U8_S16_3_in_4((mlib_u8 *)dstRowPtr,
-                                                dstIndexPtr,
-                                                xRight - xLeft + 1,
-                                                colormap);
-  }
-
-  if (dstRowPtr != dstRowData) mlib_free(dstRowPtr);
-
-  return MLIB_SUCCESS;
-}
-
-/***************************************************************/
-#undef  FILTER_SHIFT
-#define FILTER_SHIFT  4
-#undef  FILTER_MASK
-#define FILTER_MASK   (((1 << 9) - 1) << 3)
-
-/***************************************************************/
-mlib_status mlib_ImageAffineIndex_S16_S16_3CH_BC(mlib_affine_param *param,
-                                                 const void        *colormap)
-{
-  DECLAREVAR();
-  DECLAREVAR_S16();
-  mlib_d64 *flut   = (mlib_d64 *)mlib_ImageGetLutNormalTable(colormap) -
-  mlib_ImageGetLutOffset(colormap);
-  mlib_d64 dstRowData[MLIB_LIMIT];
-  mlib_d64 *dstRowPtr = dstRowData;
-  const mlib_s16 *mlib_filters_table_s16_4;
-
-  if (filter == MLIB_BICUBIC) {
-    mlib_filters_table_s16_4 = mlib_filters_s16_bc_4;
-  } else {
-    mlib_filters_table_s16_4 = mlib_filters_s16_bc2_4;
-  }
-
-  srcYStride >>= 1;
-
-  if (max_xsize > MLIB_LIMIT) {
-    dstRowPtr = mlib_malloc(sizeof(mlib_d64) * max_xsize);
-
-    if (dstRowPtr == NULL) return MLIB_FAILURE;
-  }
-
-  for (j = yStart; j <= yFinish; j++) {
-
-    CLIP();
-
-    vis_write_gsr(10 << 3);
-
-    cols = xRight - xLeft + 1;
-    i = 0;
-
-    if (i <= cols - 4) {
-
-      NEXT_PIXEL_4BC();
-      LOAD_BC_S16_4CH_1PIXEL(mlib_filters_table_s16_4);
-
-      NEXT_PIXEL_4BC();
-
-      BC_S16_4CH(mlib_filters_table_s16_4);
-      FADD_4BC_S16();
-
-      BC_S16_4CH(mlib_filters_table_s16_4);
-
-#pragma pipeloop(0)
-
-      for (; i < cols-4; i++) {
-        *dstPixelPtr++ = res;
-
-        FADD_4BC_S16();
-        BC_S16_4CH(mlib_filters_table_s16_4);
-      }
-
-      *dstPixelPtr++ = res;
-
-      FADD_4BC_S16();
-      *dstPixelPtr++ = res;
-
-      RESULT_4BC_S16_1PIXEL();
-      *dstPixelPtr++ = res;
-
-      LOAD_BC_S16_4CH_1PIXEL(mlib_filters_table_s16_4);
-      RESULT_4BC_S16_1PIXEL();
-      *dstPixelPtr++ = res;
-      i += 4;
-    }
-
-#pragma pipeloop(0)
-    for (; i < cols; i++) {
-      NEXT_PIXEL_4BC();
-      LOAD_BC_S16_4CH_1PIXEL(mlib_filters_table_s16_4);
-      RESULT_4BC_S16_1PIXEL();
-      *dstPixelPtr++ = res;
-    }
-
-    mlib_ImageColorTrue2IndexLine_S16_S16_3_in_4((mlib_s16 *)dstRowPtr,
-                                                 dstIndexPtr,
-                                                 xRight - xLeft + 1,
-                                                 colormap);
-  }
-
-  if (dstRowPtr != dstRowData) mlib_free(dstRowPtr);
-
-  return MLIB_SUCCESS;
-}
-
-/***************************************************************/
-#undef  FILTER_SHIFT
-#define FILTER_SHIFT  5
-#undef  FILTER_MASK
-#define FILTER_MASK   (((1 << 8) - 1) << 3)
-
-/***************************************************************/
-mlib_status mlib_ImageAffineIndex_S16_U8_4CH_BC(mlib_affine_param *param,
-                                                const void        *colormap)
-{
-  DECLAREVAR();
-  DECLAREVAR_U8();
-  mlib_f32  *flut   = (mlib_f32 *)mlib_ImageGetLutNormalTable(colormap) -
-  mlib_ImageGetLutOffset(colormap);
-  mlib_d64  dstRowData[MLIB_LIMIT/2];
-  mlib_d64  *dstRowPtr = dstRowData;
-  const mlib_s16 *mlib_filters_table_u8, *mlib_filters_table_u8_4;
-
-  if (filter == MLIB_BICUBIC) {
-    mlib_filters_table_u8   = mlib_filters_u8_bc;
-    mlib_filters_table_u8_4 = mlib_filters_u8_bc_4;
-  } else {
-    mlib_filters_table_u8   = mlib_filters_u8_bc2;
-    mlib_filters_table_u8_4 = mlib_filters_u8_bc2_4;
-  }
-
-  srcYStride >>= 1;
-
-  if (max_xsize > MLIB_LIMIT) {
-    dstRowPtr = mlib_malloc(sizeof(mlib_d64) * ((max_xsize + 1) >> 1));
-
-    if (dstRowPtr == NULL) return MLIB_FAILURE;
-  }
-
-  vis_write_gsr(3 << 3);
-
-  for (j = yStart; j <= yFinish; j++) {
-
-    CLIP();
-
-    cols = xRight - xLeft + 1;
-
-    i = 0;
-
-    if (i <= cols - 6) {
-
-      NEXT_PIXEL_4BC();
-      LOAD_BC_U8_4CH_1PIXEL(mlib_filters_table_u8, mlib_filters_table_u8_4);
-
-      NEXT_PIXEL_4BC();
-
-      BC_U8_4CH(0, mlib_filters_table_u8, mlib_filters_table_u8_4);
-      BC_U8_4CH(1, mlib_filters_table_u8, mlib_filters_table_u8_4);
-      FADD_4BC_U8();
-
-      BC_U8_4CH(0, mlib_filters_table_u8, mlib_filters_table_u8_4);
-      BC_U8_4CH(1, mlib_filters_table_u8, mlib_filters_table_u8_4);
-
-#pragma pipeloop(0)
-      for (; i <= cols-8; i += 2) {
-        *dstPixelPtr++ = res;
-
-        FADD_4BC_U8();
-        BC_U8_4CH(0, mlib_filters_table_u8, mlib_filters_table_u8_4);
-        BC_U8_4CH(1, mlib_filters_table_u8, mlib_filters_table_u8_4);
-      }
-
-      *dstPixelPtr++ = res;
-
-      FADD_4BC_U8();
-      *dstPixelPtr++ = res;
-
-      RESULT_4BC_U8_1PIXEL(0);
-      LOAD_BC_U8_4CH_1PIXEL(mlib_filters_table_u8, mlib_filters_table_u8_4);
-      RESULT_4BC_U8_1PIXEL(1);
-      FADD_4BC_U8();
-
-      *dstPixelPtr++ = res;
-      i += 6;
-    }
-
-    if (i <= cols-4) {
-      NEXT_PIXEL_4BC();
-      LOAD_BC_U8_4CH_1PIXEL(mlib_filters_table_u8, mlib_filters_table_u8_4);
-
-      NEXT_PIXEL_4BC();
-
-      BC_U8_4CH(0, mlib_filters_table_u8, mlib_filters_table_u8_4);
-      BC_U8_4CH(1, mlib_filters_table_u8, mlib_filters_table_u8_4);
-      FADD_4BC_U8();
-      *dstPixelPtr++ = res;
-
-      RESULT_4BC_U8_1PIXEL(0);
-      LOAD_BC_U8_4CH_1PIXEL(mlib_filters_table_u8, mlib_filters_table_u8_4);
-      RESULT_4BC_U8_1PIXEL(1);
-      FADD_4BC_U8();
-
-      *dstPixelPtr++ = res;
-      i += 4;
-    }
-
-    if (i <= cols-2) {
-      NEXT_PIXEL_4BC();
-      LOAD_BC_U8_4CH_1PIXEL(mlib_filters_table_u8, mlib_filters_table_u8_4);
-      RESULT_4BC_U8_1PIXEL(0);
-
-      NEXT_PIXEL_4BC();
-      LOAD_BC_U8_4CH_1PIXEL(mlib_filters_table_u8, mlib_filters_table_u8_4);
-      RESULT_4BC_U8_1PIXEL(1);
-      FADD_4BC_U8();
-
-      *dstPixelPtr++ = res;
-      i += 2;
-    }
-
-    if (i < cols) {
-      NEXT_PIXEL_4BC();
-      LOAD_BC_U8_4CH_1PIXEL(mlib_filters_table_u8, mlib_filters_table_u8_4);
-      RESULT_4BC_U8_1PIXEL(0);
-
-      d0 = vis_fpadd16(d00, d10);
-      d1 = vis_fpadd16(d20, d30);
-      d0 = vis_fpadd16(d0, d1);
-      res = vis_fpack16_pair(d0, d0);
-      *dstPixelPtr++ = res;
-    }
-
-    mlib_ImageColorTrue2IndexLine_U8_S16_4((mlib_u8 *)dstRowPtr,
-                                           dstIndexPtr,
-                                           xRight - xLeft + 1,
-                                           colormap);
-  }
-
-  if (dstRowPtr != dstRowData) mlib_free(dstRowPtr);
-
-  return MLIB_SUCCESS;
-}
-
-/***************************************************************/
-#undef  FILTER_SHIFT
-#define FILTER_SHIFT  4
-#undef  FILTER_MASK
-#define FILTER_MASK   (((1 << 9) - 1) << 3)
-
-/***************************************************************/
-mlib_status mlib_ImageAffineIndex_S16_S16_4CH_BC(mlib_affine_param *param,
-                                                 const void        *colormap)
-{
-  DECLAREVAR();
-  DECLAREVAR_S16();
-  mlib_d64 *flut   = (mlib_d64 *)mlib_ImageGetLutNormalTable(colormap) -
-  mlib_ImageGetLutOffset(colormap);
-  mlib_d64 dstRowData[MLIB_LIMIT];
-  mlib_d64 *dstRowPtr = dstRowData;
-  const mlib_s16 *mlib_filters_table_s16_4;
-
-  if (filter == MLIB_BICUBIC) {
-    mlib_filters_table_s16_4 = mlib_filters_s16_bc_4;
-  } else {
-    mlib_filters_table_s16_4 = mlib_filters_s16_bc2_4;
-  }
-
-  srcYStride >>= 1;
-
-  if (max_xsize > MLIB_LIMIT) {
-    dstRowPtr = mlib_malloc(sizeof(mlib_d64) * max_xsize);
-
-    if (dstRowPtr == NULL) return MLIB_FAILURE;
-  }
-
-  for (j = yStart; j <= yFinish; j++) {
-
-    CLIP();
-
-    vis_write_gsr(10 << 3);
-
-    cols = xRight - xLeft + 1;
-    i = 0;
-
-    if (i <= cols - 4) {
-
-      NEXT_PIXEL_4BC();
-      LOAD_BC_S16_4CH_1PIXEL(mlib_filters_table_s16_4);
-
-      NEXT_PIXEL_4BC();
-
-      BC_S16_4CH(mlib_filters_table_s16_4);
-      FADD_4BC_S16();
-
-      BC_S16_4CH(mlib_filters_table_s16_4);
-
-#pragma pipeloop(0)
-
-      for (; i < cols-4; i++) {
-        *dstPixelPtr++ = res;
-
-        FADD_4BC_S16();
-        BC_S16_4CH(mlib_filters_table_s16_4);
-      }
-
-      *dstPixelPtr++ = res;
-
-      FADD_4BC_S16();
-      *dstPixelPtr++ = res;
-
-      RESULT_4BC_S16_1PIXEL();
-      *dstPixelPtr++ = res;
-
-      LOAD_BC_S16_4CH_1PIXEL(mlib_filters_table_s16_4);
-      RESULT_4BC_S16_1PIXEL();
-      *dstPixelPtr++ = res;
-      i += 4;
-    }
-
-#pragma pipeloop(0)
-    for (; i < cols; i++) {
-      NEXT_PIXEL_4BC();
-      LOAD_BC_S16_4CH_1PIXEL(mlib_filters_table_s16_4);
-      RESULT_4BC_S16_1PIXEL();
-      *dstPixelPtr++ = res;
-    }
-
-    mlib_ImageColorTrue2IndexLine_S16_S16_4((mlib_s16 *)dstRowPtr,
-                                            dstIndexPtr,
-                                            xRight - xLeft + 1,
-                                            colormap);
-  }
-
-  if (dstRowPtr != dstRowData) mlib_free(dstRowPtr);
-
-  return MLIB_SUCCESS;
-}
-
-/***************************************************************/
--- a/jdk/src/java.desktop/unix/native/libmlib_image/mlib_v_ImageAffine_BL.c	Thu May 19 17:48:02 2016 +0000
+++ b/jdk/src/java.desktop/unix/native/libmlib_image/mlib_v_ImageAffine_BL.c	Thu May 19 19:46:20 2016 +0000
@@ -33,7 +33,6 @@
 
 #include "vis_proto.h"
 #include "mlib_image.h"
-#include "mlib_ImageColormap.h"
 #include "mlib_ImageCopy.h"
 #include "mlib_ImageAffine.h"
 #include "mlib_v_ImageFilters.h"
@@ -719,134 +718,3 @@
 }
 
 /***************************************************************/
-#define LUT(x)  plut[x]
-
-mlib_status FUN_NAME(u8_i)(mlib_affine_param *param,
-                           const void        *colormap)
-{
-  DECLAREVAR();
-  mlib_s32 nchan   = mlib_ImageGetLutChannels(colormap);
-  mlib_s32 lut_off = mlib_ImageGetLutOffset(colormap);
-  mlib_f32 *plut = (mlib_f32*)mlib_ImageGetLutNormalTable(colormap) - lut_off;
-  mlib_s32 max_xsize = param -> max_xsize;
-  mlib_f32 buff[BUF_SIZE], *pbuff = buff;
-
-  if (max_xsize > BUF_SIZE) {
-    pbuff = mlib_malloc(max_xsize*sizeof(mlib_f32));
-
-    if (pbuff == NULL) return MLIB_FAILURE;
-  }
-
-  vis_write_gsr(3 << 3);
-
-  for (j = yStart; j <= yFinish; j++) {
-    mlib_f32 s0, s1, s2, s3;
-    DTYPE    *sp;
-
-    NEW_LINE(1);
-
-#pragma pipeloop(0)
-    for (i = 0; i < size; i++) {
-      GET_FILTER_XY();
-
-      sp = *(DTYPE**)((mlib_u8*)lineAddr + PTR_SHIFT(Y)) + (X >> MLIB_SHIFT);
-      s0 = LUT(sp[0]);
-      s1 = LUT(sp[1]);
-      s2 = LUT(sp[srcYStride]);
-      s3 = LUT(sp[srcYStride + 1]);
-
-      PROCESS_4CH(s0, s1, s2, s3);
-
-      pbuff[i] = vis_fpack16(dd);
-      X += dX;
-      Y += dY;
-    }
-
-    if (nchan == 3) {
-      mlib_ImageColorTrue2IndexLine_U8_U8_3_in_4((void*)pbuff, (void*)dl, size, colormap);
-    } else {
-      mlib_ImageColorTrue2IndexLine_U8_U8_4((void*)pbuff, (void*)dl, size, colormap);
-    }
-  }
-
-  if (pbuff != buff) {
-    mlib_free(pbuff);
-  }
-
-  return MLIB_SUCCESS;
-}
-
-/***************************************************************/
-#undef  DTYPE
-#define DTYPE mlib_s16
-
-mlib_status FUN_NAME(s16_i)(mlib_affine_param *param,
-                            const void        *colormap)
-{
-  DECLAREVAR();
-  mlib_s32 nchan   = mlib_ImageGetLutChannels(colormap);
-  mlib_s32 lut_off = mlib_ImageGetLutOffset(colormap);
-  mlib_f32 *plut = (mlib_f32*)mlib_ImageGetLutNormalTable(colormap) - lut_off;
-  mlib_s32 max_xsize = param -> max_xsize;
-  mlib_f32 buff[BUF_SIZE], *pbuff = buff;
-
-  srcYStride /= sizeof(DTYPE);
-
-  if (max_xsize > BUF_SIZE) {
-    pbuff = mlib_malloc(max_xsize*sizeof(mlib_f32));
-
-    if (pbuff == NULL) return MLIB_FAILURE;
-  }
-
-  vis_write_gsr(3 << 3);
-
-  for (j = yStart; j <= yFinish; j++) {
-    mlib_f32 s0, s1, s2, s3;
-    DTYPE    *sp;
-
-    NEW_LINE(1);
-
-#pragma pipeloop(0)
-    for (i = 0; i < size; i++) {
-      GET_FILTER_XY();
-
-      sp = *(DTYPE**)((mlib_u8*)lineAddr + PTR_SHIFT(Y)) + (X >> MLIB_SHIFT);
-      s0 = LUT(sp[0]);
-      s1 = LUT(sp[1]);
-      s2 = LUT(sp[srcYStride]);
-      s3 = LUT(sp[srcYStride + 1]);
-
-      PROCESS_4CH(s0, s1, s2, s3);
-
-      pbuff[i] = vis_fpack16(dd);
-      X += dX;
-      Y += dY;
-    }
-
-    if (nchan == 3) {
-      mlib_ImageColorTrue2IndexLine_U8_S16_3_in_4((void*)pbuff, (void*)dl, size, colormap);
-    } else {
-      mlib_ImageColorTrue2IndexLine_U8_S16_4((void*)pbuff, (void*)dl, size, colormap);
-    }
-  }
-
-  if (pbuff != buff) {
-    mlib_free(pbuff);
-  }
-
-  return MLIB_SUCCESS;
-}
-
-/***************************************************************/
-const type_affine_i_fun mlib_AffineFunArr_bl_i[] = {
-  mlib_ImageAffine_u8_u8_i_bl,
-  mlib_ImageAffine_u8_u8_i_bl,
-  mlib_ImageAffine_u8_s16_i_bl,
-  mlib_ImageAffine_u8_s16_i_bl,
-  mlib_ImageAffine_s16_u8_i_bl,
-  mlib_ImageAffine_s16_u8_i_bl,
-  mlib_ImageAffine_s16_s16_i_bl,
-  mlib_ImageAffine_s16_s16_i_bl
-};
-
-/***************************************************************/
--- a/jdk/src/java.desktop/unix/native/libmlib_image/mlib_v_ImageAffine_BL_S16.c	Thu May 19 17:48:02 2016 +0000
+++ b/jdk/src/java.desktop/unix/native/libmlib_image/mlib_v_ImageAffine_BL_S16.c	Thu May 19 19:46:20 2016 +0000
@@ -33,7 +33,6 @@
 
 #include "vis_proto.h"
 #include "mlib_image.h"
-#include "mlib_ImageColormap.h"
 #include "mlib_ImageCopy.h"
 #include "mlib_ImageAffine.h"
 #include "mlib_v_ImageFilters.h"
@@ -716,128 +715,3 @@
 }
 
 /***************************************************************/
-#define LUT(x)  plut[x]
-
-mlib_status FUN_NAME(s16_i)(mlib_affine_param *param,
-                            const void        *colormap)
-{
-  DECLAREVAR();
-  mlib_s32 nchan   = mlib_ImageGetLutChannels(colormap);
-  mlib_s32 lut_off = mlib_ImageGetLutOffset(colormap);
-  mlib_d64 *plut = (mlib_d64*)mlib_ImageGetLutNormalTable(colormap) - lut_off;
-  mlib_s32 max_xsize = param -> max_xsize;
-  mlib_d64 buff[BUF_SIZE], *pbuff = buff;
-
-  srcYStride /= sizeof(DTYPE);
-
-  if (max_xsize > BUF_SIZE) {
-    pbuff = mlib_malloc(max_xsize*sizeof(mlib_d64));
-
-    if (pbuff == NULL) return MLIB_FAILURE;
-  }
-
-  dX = (dX - (dX >> 31)) &~ 1; /* rounding towards ZERO */
-  dY = (dY - (dY >> 31)) &~ 1; /* rounding towards ZERO */
-  dx64 = vis_to_double_dup((((dX >> 1) & 0xFFFF) << 16) | ((dX >> 1) & 0xFFFF));
-  dy64 = vis_to_double_dup((((dY >> 1) & 0xFFFF) << 16) | ((dY >> 1) & 0xFFFF));
-
-  for (j = yStart; j <= yFinish; j++) {
-    DTYPE *sp;
-
-    NEW_LINE(1);
-
-    deltax = DOUBLE_4U16(X, X, X, X);
-    deltay = DOUBLE_4U16(Y, Y, Y, Y);
-
-#pragma pipeloop(0)
-    for (i = 0; i < size; i++) {
-      sp = *(DTYPE**)((mlib_u8*)lineAddr + PTR_SHIFT(Y)) + (X >> MLIB_SHIFT);
-      s0 = LUT(sp[0]);
-      s1 = LUT(sp[1]);
-      s2 = LUT(sp[srcYStride]);
-      s3 = LUT(sp[srcYStride + 1]);
-
-      BL_SUM();
-
-      pbuff[i] = dd;
-      X += dX;
-      Y += dY;
-    }
-
-    if (nchan == 3) {
-      mlib_ImageColorTrue2IndexLine_S16_S16_3_in_4((void*)pbuff, (void*)dl, size, colormap);
-    } else {
-      mlib_ImageColorTrue2IndexLine_S16_S16_4((void*)pbuff, (void*)dl, size, colormap);
-    }
-  }
-
-  if (pbuff != buff) {
-    mlib_free(pbuff);
-  }
-
-  return MLIB_SUCCESS;
-}
-
-/***************************************************************/
-#undef  DTYPE
-#define DTYPE mlib_u8
-
-mlib_status FUN_NAME(u8_i)(mlib_affine_param *param,
-                           const void        *colormap)
-{
-  DECLAREVAR();
-  mlib_s32 nchan   = mlib_ImageGetLutChannels(colormap);
-  mlib_s32 lut_off = mlib_ImageGetLutOffset(colormap);
-  mlib_d64 *plut = (mlib_d64*)mlib_ImageGetLutNormalTable(colormap) - lut_off;
-  mlib_s32 max_xsize = param -> max_xsize;
-  mlib_d64 buff[BUF_SIZE], *pbuff = buff;
-
-  if (max_xsize > BUF_SIZE) {
-    pbuff = mlib_malloc(max_xsize*sizeof(mlib_d64));
-
-    if (pbuff == NULL) return MLIB_FAILURE;
-  }
-
-  dX = (dX - (dX >> 31)) &~ 1; /* rounding towards ZERO */
-  dY = (dY - (dY >> 31)) &~ 1; /* rounding towards ZERO */
-  dx64 = vis_to_double_dup((((dX >> 1) & 0xFFFF) << 16) | ((dX >> 1) & 0xFFFF));
-  dy64 = vis_to_double_dup((((dY >> 1) & 0xFFFF) << 16) | ((dY >> 1) & 0xFFFF));
-
-  for (j = yStart; j <= yFinish; j++) {
-    DTYPE *sp;
-
-    NEW_LINE(1);
-
-    deltax = DOUBLE_4U16(X, X, X, X);
-    deltay = DOUBLE_4U16(Y, Y, Y, Y);
-
-#pragma pipeloop(0)
-    for (i = 0; i < size; i++) {
-      sp = *(DTYPE**)((mlib_u8*)lineAddr + PTR_SHIFT(Y)) + (X >> MLIB_SHIFT);
-      s0 = LUT(sp[0]);
-      s1 = LUT(sp[1]);
-      s2 = LUT(sp[srcYStride]);
-      s3 = LUT(sp[srcYStride + 1]);
-
-      BL_SUM();
-
-      pbuff[i] = dd;
-      X += dX;
-      Y += dY;
-    }
-
-    if (nchan == 3) {
-      mlib_ImageColorTrue2IndexLine_S16_U8_3_in_4((void*)pbuff, (void*)dl, size, colormap);
-    } else {
-      mlib_ImageColorTrue2IndexLine_S16_U8_4((void*)pbuff, (void*)dl, size, colormap);
-    }
-  }
-
-  if (pbuff != buff) {
-    mlib_free(pbuff);
-  }
-
-  return MLIB_SUCCESS;
-}
-
-/***************************************************************/
--- a/jdk/src/java.desktop/unix/native/libmlib_image/mlib_v_ImageAffine_BL_U16.c	Thu May 19 17:48:02 2016 +0000
+++ b/jdk/src/java.desktop/unix/native/libmlib_image/mlib_v_ImageAffine_BL_U16.c	Thu May 19 19:46:20 2016 +0000
@@ -33,7 +33,6 @@
 
 #include "vis_proto.h"
 #include "mlib_image.h"
-#include "mlib_ImageColormap.h"
 #include "mlib_ImageCopy.h"
 #include "mlib_ImageAffine.h"
 #include "mlib_v_ImageFilters.h"
--- a/jdk/src/java.desktop/unix/native/libmlib_image/mlib_v_ImageChannelExtract.c	Thu May 19 17:48:02 2016 +0000
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,825 +0,0 @@
-/*
- * Copyright (c) 1998, 2003, 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.
- */
-
-
-/*
- * FUNCTIONS
- *      mlib_ImageChannelExtract  - Copy the selected channels of the source
- *                                  image into the destination image
- *
- * SYNOPSIS
- *      mlib_status mlib_ImageChannelExtract(mlib_image *dst,
- *                                           mlib_image *src,
- *                                           mlib_s32   cmask);
- * ARGUMENT
- *    dst     Pointer to destination image.
- *    src     Pointer to source image.
- *    cmask   Source channel selection mask.
- *    The least significant bit (LSB) is corresponding to the
- *    last channel in the source image data.
- *    The bits with value 1 stand for the channels selected.
- *    If more than N channels are selected, the leftmost N
- *    channels are extracted, where N is the number of channels
- *    in the destination image.
- *
- * RESTRICTION
- *    The src and dst must have the same width, height and data type.
- *    The src and dst can have 1, 2, 3 or 4 channels.
- *    The src and dst can be either MLIB_BYTE, MLIB_SHORT,  MLIB_INT,
- *    MLIB_FLOAT or  MLIB_DOUBLE.
- *
- * DESCRIPTION
- *    Copy the selected channels of the source image into the
- *    destination image
- */
-
-#include <stdlib.h>
-#include "mlib_image.h"
-#include "mlib_ImageCheck.h"
-
-/***************************************************************/
-/* functions defined in mlib_ImageChannelExtract_1.c */
-
-void
-mlib_v_ImageChannelExtract_U8(mlib_u8  *src,   mlib_s32 slb,
-                              mlib_u8  *dst,   mlib_s32 dlb,
-                              mlib_s32 channels, mlib_s32 channeld,
-                              mlib_s32 width,   mlib_s32 height,
-                              mlib_s32 cmask);
-void
-mlib_v_ImageChannelExtract_S16(mlib_u16 *src,    mlib_s32 slb,
-                               mlib_u16 *dst,    mlib_s32 dlb,
-                               mlib_s32 channels, mlib_s32 channeld,
-                               mlib_s32 width,    mlib_s32 height,
-                               mlib_s32 cmask);
-void
-mlib_v_ImageChannelExtract_S32(mlib_s32 *src,    mlib_s32 slb,
-                               mlib_s32 *dst,    mlib_s32 dlb,
-                               mlib_s32 channels, mlib_s32 channeld,
-                               mlib_s32 width,    mlib_s32 height,
-                               mlib_s32 cmask);
-void
-mlib_v_ImageChannelExtract_D64(mlib_d64 *src,    mlib_s32 slb,
-                               mlib_d64 *dst,    mlib_s32 dlb,
-                               mlib_s32 channels, mlib_s32 channeld,
-                               mlib_s32 width,    mlib_s32 height,
-                               mlib_s32 cmask);
-
-/***************************************************************/
-
-void mlib_v_ImageChannelExtract_U8_2_1(mlib_u8  *sl,  mlib_s32 slb,
-                                       mlib_u8 *dl,  mlib_s32 dlb,
-                                       mlib_s32 width,   mlib_s32 height);
-
-void mlib_v_ImageChannelExtract_U8_3_2(mlib_u8  *sl,  mlib_s32 slb,
-                                       mlib_u8 *dl,  mlib_s32 dlb,
-                                       mlib_s32 width,   mlib_s32 height,
-                                       mlib_s32 count1);
-
-void mlib_v_ImageChannelExtract_U8_4_2(mlib_u8  *sl,  mlib_s32 slb,
-                                       mlib_u8  *dl,  mlib_s32 dlb,
-                                       mlib_s32 width,   mlib_s32 height,
-                                       mlib_s32 count1);
-
-void mlib_v_ImageChannelExtract_32_2_1(mlib_f32 *sl,  mlib_s32 slb,
-                                       mlib_f32 *dl,   mlib_s32 dlb,
-                                       mlib_s32 width, mlib_s32 height);
-
-void mlib_v_ImageChannelExtract_32_3_1(mlib_f32 *sl,  mlib_s32 slb,
-                                       mlib_f32 *dl,   mlib_s32 dlb,
-                                       mlib_s32 width, mlib_s32 height);
-
-void mlib_v_ImageChannelExtract_32_3_2(mlib_f32 *sp, mlib_s32 slb,
-                                       mlib_f32 *dp, mlib_s32 dlb,
-                                       mlib_s32 width, mlib_s32 height,
-                                       mlib_s32 deltac1);
-
-void mlib_v_ImageChannelExtract_32_4_1(mlib_f32 *sl,  mlib_s32 slb,
-                                       mlib_f32 *dl,   mlib_s32 dlb,
-                                       mlib_s32 width, mlib_s32 height);
-
-void mlib_v_ImageChannelExtract_32_4_2(mlib_f32 *sp, mlib_s32 slb,
-                                       mlib_f32 *dp, mlib_s32 dlb,
-                                       mlib_s32 width, mlib_s32 height,
-                                       mlib_s32 deltac1);
-
-void mlib_v_ImageChannelExtract_32_4_3(mlib_f32 *sl,  mlib_s32 slb,
-                                       mlib_f32 *dl,   mlib_s32 dlb,
-                                       mlib_s32 width, mlib_s32 height,
-                                       mlib_s32  mask_off);
-
-/***************************************************************/
-
-void
-mlib_v_ImageChannelExtract_U8_21_A8D1X8(mlib_u8  *src,
-                                        mlib_u8  *dst,
-                                        mlib_s32 dsize,
-                                        mlib_s32 cmask);
-void
-mlib_v_ImageChannelExtract_U8_21_A8D2X8(mlib_u8  *src,  mlib_s32 slb,
-                                        mlib_u8  *dst,  mlib_s32 dlb,
-                                        mlib_s32 xsize, mlib_s32 ysize,
-                                        mlib_s32 cmask);
-void
-mlib_v_ImageChannelExtract_U8_21_D1(mlib_u8  *src,
-                                    mlib_u8  *dst,
-                                    mlib_s32 dsize,
-                                    mlib_s32 cmask);
-void
-mlib_v_ImageChannelExtract_U8_21(mlib_u8  *src,  mlib_s32 slb,
-                                 mlib_u8  *dst,  mlib_s32 dlb,
-                                 mlib_s32 xsize, mlib_s32 ysize,
-                                 mlib_s32 cmask);
-void
-mlib_v_ImageChannelExtract_U8_31_A8D1X8(mlib_u8  *src,
-                                        mlib_u8  *dst,
-                                        mlib_s32 dsize,
-                                        mlib_s32 cmask);
-void
-mlib_v_ImageChannelExtract_U8_31_A8D2X8(mlib_u8  *src,  mlib_s32 slb,
-                                        mlib_u8  *dst,  mlib_s32 dlb,
-                                        mlib_s32 xsize, mlib_s32 ysize,
-                                        mlib_s32 cmask);
-void
-mlib_v_ImageChannelExtract_U8_31_D1(mlib_u8  *src,
-                                    mlib_u8  *dst,
-                                    mlib_s32 dsize,
-                                    mlib_s32 cmask);
-void
-mlib_v_ImageChannelExtract_U8_31(mlib_u8  *src,  mlib_s32 slb,
-                                 mlib_u8  *dst,  mlib_s32 dlb,
-                                 mlib_s32 xsize, mlib_s32 ysize,
-                                 mlib_s32 cmask);
-void
-mlib_v_ImageChannelExtract_U8_41_A8D1X8(mlib_u8  *src,
-                                        mlib_u8  *dst,
-                                        mlib_s32 dsize,
-                                        mlib_s32 cmask);
-void
-mlib_v_ImageChannelExtract_U8_41_A8D2X8(mlib_u8  *src,  mlib_s32 slb,
-                                        mlib_u8  *dst,  mlib_s32 dlb,
-                                        mlib_s32 xsize, mlib_s32 ysize,
-                                        mlib_s32 cmask);
-void
-mlib_v_ImageChannelExtract_U8_41_D1(mlib_u8  *src,
-                                    mlib_u8  *dst,
-                                    mlib_s32 dsize,
-                                    mlib_s32 cmask);
-void
-mlib_v_ImageChannelExtract_U8_41(mlib_u8  *src,  mlib_s32 slb,
-                                 mlib_u8  *dst,  mlib_s32 dlb,
-                                 mlib_s32 xsize, mlib_s32 ysize,
-                                 mlib_s32 cmask);
-void
-mlib_v_ImageChannelExtract_S16_11_A8D1X4(mlib_s16 *src, mlib_s16 *dst,
-                                         mlib_s32 dsize);
-void
-mlib_v_ImageChannelExtract_S16_21_A8D1X4(mlib_s16 *src,
-                                         mlib_s16 *dst,
-                                         mlib_s32 dsize,
-                                         mlib_s32 cmask);
-void
-mlib_v_ImageChannelExtract_S16_21_A8D2X4(mlib_s16 *src,  mlib_s32 slb,
-                                         mlib_s16 *dst,  mlib_s32 dlb,
-                                         mlib_s32 xsize, mlib_s32 ysize,
-                                         mlib_s32 cmask);
-void
-mlib_v_ImageChannelExtract_S16_21_D1(mlib_s16 *src,
-                                     mlib_s16 *dst,
-                                     mlib_s32 dsize,
-                                     mlib_s32 cmask);
-void
-mlib_v_ImageChannelExtract_S16_21(mlib_s16 *src,  mlib_s32 slb,
-                                  mlib_s16 *dst,  mlib_s32 dlb,
-                                  mlib_s32 xsize, mlib_s32 ysize,
-                                  mlib_s32 cmask);
-void
-mlib_v_ImageChannelExtract_S16_31_A8D1X4(mlib_s16 *src,
-                                         mlib_s16 *dst,
-                                         mlib_s32 dsize,
-                                         mlib_s32 cmask);
-void
-mlib_v_ImageChannelExtract_S16_31_A8D2X4(mlib_s16 *src,  mlib_s32 slb,
-                                         mlib_s16 *dst,  mlib_s32 dlb,
-                                         mlib_s32 xsize, mlib_s32 ysize,
-                                         mlib_s32 cmask);
-void
-mlib_v_ImageChannelExtract_S16_31_D1(mlib_s16 *src,
-                                     mlib_s16 *dst,
-                                     mlib_s32 dsize,
-                                     mlib_s32 cmask);
-void
-mlib_v_ImageChannelExtract_S16_31(mlib_s16 *src,  mlib_s32 slb,
-                                  mlib_s16 *dst,  mlib_s32 dlb,
-                                  mlib_s32 xsize, mlib_s32 ysize,
-                                  mlib_s32 cmask);
-void
-mlib_v_ImageChannelExtract_S16_41_A8D1X4(mlib_s16 *src,
-                                         mlib_s16 *dst,
-                                         mlib_s32 dsize,
-                                         mlib_s32 cmask);
-void
-mlib_v_ImageChannelExtract_S16_41_A8D2X4(mlib_s16 *src,  mlib_s32 slb,
-                                         mlib_s16 *dst,  mlib_s32 dlb,
-                                         mlib_s32 xsize, mlib_s32 ysize,
-                                         mlib_s32 cmask);
-void
-mlib_v_ImageChannelExtract_S16_41_D1(mlib_s16 *src,
-                                     mlib_s16 *dst,
-                                     mlib_s32 dsize,
-                                     mlib_s32 cmask);
-void
-mlib_v_ImageChannelExtract_S16_41(mlib_s16 *src,  mlib_s32 slb,
-                                  mlib_s16 *dst,  mlib_s32 dlb,
-                                  mlib_s32 xsize, mlib_s32 ysize,
-                                  mlib_s32 cmask);
-
-/***************************************************************/
-/* functions defined in mlib_ImageChannelExtract_43.c */
-
-void
-mlib_v_ImageChannelExtract_U8_43R_A8D1X8(mlib_u8  *src,
-                                         mlib_u8  *dst,
-                                         mlib_s32 dsize);
-void
-mlib_v_ImageChannelExtract_U8_43R_A8D2X8(mlib_u8  *src,  mlib_s32 slb,
-                                         mlib_u8  *dst,  mlib_s32 dlb,
-                                         mlib_s32 xsize, mlib_s32 ysize);
-void
-mlib_v_ImageChannelExtract_U8_43R_D1(mlib_u8  *src,
-                                     mlib_u8  *dst,
-                                     mlib_s32 dsize);
-void
-mlib_v_ImageChannelExtract_U8_43R(mlib_u8  *src,  mlib_s32 slb,
-                                  mlib_u8  *dst,  mlib_s32 dlb,
-                                  mlib_s32 xsize, mlib_s32 ysize);
-void
-mlib_v_ImageChannelExtract_S16_43R_A8D1X4(mlib_s16 *src,
-                                          mlib_s16 *dst,
-                                          mlib_s32 dsize);
-void
-mlib_v_ImageChannelExtract_S16_43R_A8D2X4(mlib_s16 *src,  mlib_s32 slb,
-                                          mlib_s16 *dst,  mlib_s32 dlb,
-                                          mlib_s32 xsize, mlib_s32 ysize);
-void
-mlib_v_ImageChannelExtract_S16_43R_D1(mlib_s16 *src,
-                                      mlib_s16 *dst,
-                                      mlib_s32 dsize);
-void
-mlib_v_ImageChannelExtract_S16_43R(mlib_s16 *src,  mlib_s32 slb,
-                                   mlib_s16 *dst,  mlib_s32 dlb,
-                                   mlib_s32 xsize, mlib_s32 ysize);
-void
-mlib_v_ImageChannelExtract_U8_43L_A8D1X8(mlib_u8  *src,
-                                         mlib_u8  *dst,
-                                         mlib_s32 dsize);
-void
-mlib_v_ImageChannelExtract_U8_43L_A8D2X8(mlib_u8  *src,  mlib_s32 slb,
-                                         mlib_u8  *dst,  mlib_s32 dlb,
-                                         mlib_s32 xsize, mlib_s32 ysize);
-void
-mlib_v_ImageChannelExtract_U8_43L_D1(mlib_u8  *src,
-                                     mlib_u8  *dst,
-                                     mlib_s32 dsize);
-void
-mlib_v_ImageChannelExtract_U8_43L(mlib_u8  *src,  mlib_s32 slb,
-                                  mlib_u8  *dst,  mlib_s32 dlb,
-                                  mlib_s32 xsize, mlib_s32 ysize);
-void
-mlib_v_ImageChannelExtract_S16_43L_A8D1X4(mlib_s16 *src,
-                                          mlib_s16 *dst,
-                                          mlib_s32 dsize);
-void
-mlib_v_ImageChannelExtract_S16_43L_A8D2X4(mlib_s16 *src,  mlib_s32 slb,
-                                          mlib_s16 *dst,  mlib_s32 dlb,
-                                          mlib_s32 xsize, mlib_s32 ysize);
-void
-mlib_v_ImageChannelExtract_S16_43L_D1(mlib_s16 *src,
-                                      mlib_s16 *dst,
-                                      mlib_s32 dsize);
-void
-mlib_v_ImageChannelExtract_S16_43L(mlib_s16 *src,  mlib_s32 slb,
-                                   mlib_s16 *dst,  mlib_s32 dlb,
-                                   mlib_s32 xsize, mlib_s32 ysize);
-
-/***************************************************************/
-
-#ifdef MLIB_TEST
-mlib_status
-mlib_v_ImageChannelExtract(mlib_image *dst,
-                           mlib_image *src,
-                           mlib_s32   cmask)
-#else
-mlib_status
-mlib_ImageChannelExtract(mlib_image *dst,
-                         mlib_image *src,
-                         mlib_s32   cmask)
-#endif
-{
-  const mlib_s32  X8 = 0x7;
-  const mlib_s32  X4 = 0x3;
-  const mlib_s32  X2 = 0x1;
-  const mlib_s32  A8D1   = MLIB_IMAGE_ALIGNED8 | MLIB_IMAGE_ONEDVECTOR;
-  const mlib_s32  A8D2X8 = MLIB_IMAGE_ALIGNED8 | MLIB_IMAGE_STRIDE8X | MLIB_IMAGE_WIDTH8X;
-  const mlib_s32  A8D2X4 = MLIB_IMAGE_ALIGNED8 | MLIB_IMAGE_STRIDE8X | MLIB_IMAGE_WIDTH4X;
-  const mlib_s32  A8D2X2 = MLIB_IMAGE_ALIGNED8 | MLIB_IMAGE_STRIDE8X | MLIB_IMAGE_WIDTH2X;
-  void      *sp;            /* pointer for pixel in src */
-  void      *dp;            /* pointer for pixel in dst */
-  mlib_s32  ncmask = 0;     /* normalized channel mask */
-  mlib_s32  channels;       /* number of channels for src */
-  mlib_s32  channeld;       /* number of channels for dst */
-  mlib_s32  width, height;  /* for src and dst */
-  mlib_s32  strides;        /* strides in bytes for src */
-  mlib_s32  strided;        /* strides in bytes for dst */
-  mlib_s32  flags;
-  mlib_s32  flagd;
-  mlib_s32  dsize;
-  int       delta0 = 0;     /* offset of first selected channel */
-  int       count1 = 0;     /* number of channels in first group */
-  int       i, bit1count = 0;
-
-  MLIB_IMAGE_CHECK(src);
-  MLIB_IMAGE_CHECK(dst);
-  MLIB_IMAGE_TYPE_EQUAL(src, dst);
-  MLIB_IMAGE_SIZE_EQUAL(src, dst);
-
-  channels = mlib_ImageGetChannels(src);
-  channeld = mlib_ImageGetChannels(dst);
-  width    = mlib_ImageGetWidth(src);
-  height   = mlib_ImageGetHeight(src);
-  strides  = mlib_ImageGetStride(src);
-  strided  = mlib_ImageGetStride(dst);
-  sp       = mlib_ImageGetData(src);
-  dp       = mlib_ImageGetData(dst);
-  flags    = mlib_ImageGetFlags(src);
-  flagd    = mlib_ImageGetFlags(dst);
-  dsize    = width * height;
-
-  /* normalize the cmask, and count the number of bit with value 1 */
-  for (i = (channels - 1); i >= 0; i--) {
-    if (((cmask & (1 << i)) != 0) && (bit1count < channeld)) {
-      ncmask += (1 << i);
-      bit1count++;
-    }
-  }
-
-  /* do not support the cases in which the number of selected channels is
-   * less than the nubmber of channels in the destination image */
-  if (bit1count < channeld) {
-    return MLIB_FAILURE;
-  }
-
-  if (channels == channeld) {
-#ifdef MLIB_TEST
-    mlib_v_ImageCopy(dst, src);
-#else
-    mlib_ImageCopy(dst, src);
-#endif
-    return MLIB_SUCCESS;
-  }
-
-  switch (mlib_ImageGetType(src)) {
-    case MLIB_BYTE:
-      if (channeld == 1) {
-        switch (channels) {
-          case 2:
-            if (((flags & A8D1) == 0) &&
-                ((flagd & A8D1) == 0) &&
-                ((dsize & X8)   == 0)) {
-              mlib_v_ImageChannelExtract_U8_21_A8D1X8((mlib_u8 *)sp,
-                                                      (mlib_u8 *)dp,
-                                                      dsize,
-                                                      ncmask);
-            }
-            else if (((flags & A8D2X8) == 0) &&
-                     ((flagd & A8D2X8) == 0)) {
-              mlib_v_ImageChannelExtract_U8_21_A8D2X8((mlib_u8 *)sp, strides,
-                                                      (mlib_u8 *)dp, strided,
-                                                      width, height,
-                                                      ncmask);
-            }
-            else if (((flags & MLIB_IMAGE_ONEDVECTOR) == 0) &&
-                     ((flagd & MLIB_IMAGE_ONEDVECTOR) == 0)) {
-              mlib_v_ImageChannelExtract_U8_21_D1((mlib_u8 *)sp,
-                                                  (mlib_u8 *)dp,
-                                                  dsize,
-                                                  ncmask);
-            }
-            else {
-              mlib_v_ImageChannelExtract_U8_21((mlib_u8 *)sp, strides,
-                                               (mlib_u8 *)dp, strided,
-                                               width, height,
-                                               ncmask);
-            }
-            return MLIB_SUCCESS;
-
-          case 3:
-            if (((flags & A8D1) == 0) &&
-                ((flagd & A8D1) == 0) &&
-                ((dsize & X8)   == 0)) {
-              mlib_v_ImageChannelExtract_U8_31_A8D1X8((mlib_u8 *)sp,
-                                                      (mlib_u8 *)dp,
-                                                      dsize,
-                                                      ncmask);
-            }
-            else if (((flags & A8D2X8) == 0) &&
-                     ((flagd & A8D2X8) == 0)) {
-              mlib_v_ImageChannelExtract_U8_31_A8D2X8((mlib_u8 *)sp, strides,
-                                                      (mlib_u8 *)dp, strided,
-                                                      width, height,
-                                                      ncmask);
-            }
-            else if (((flags & MLIB_IMAGE_ONEDVECTOR) == 0) &&
-                     ((flagd & MLIB_IMAGE_ONEDVECTOR) == 0)) {
-              mlib_v_ImageChannelExtract_U8_31_D1((mlib_u8 *)sp,
-                                                  (mlib_u8 *)dp,
-                                                  dsize,
-                                                  ncmask);
-            }
-            else {
-              mlib_v_ImageChannelExtract_U8_31((mlib_u8 *)sp, strides,
-                                               (mlib_u8 *)dp, strided,
-                                               width, height,
-                                               ncmask);
-            }
-            return MLIB_SUCCESS;
-
-          case 4:
-            if (((flags & A8D1) == 0) &&
-                ((flagd & A8D1) == 0) &&
-                ((dsize & X8)   == 0)) {
-              mlib_v_ImageChannelExtract_U8_41_A8D1X8((mlib_u8 *)sp,
-                                                      (mlib_u8 *)dp,
-                                                      dsize,
-                                                      ncmask);
-            }
-            else if (((flags & A8D2X8) == 0) &&
-                     ((flagd & A8D2X8) == 0)) {
-              mlib_v_ImageChannelExtract_U8_41_A8D2X8((mlib_u8 *)sp, strides,
-                                                      (mlib_u8 *)dp, strided,
-                                                      width, height,
-                                                      ncmask);
-            }
-            else if (((flags & MLIB_IMAGE_ONEDVECTOR) == 0) &&
-                     ((flagd & MLIB_IMAGE_ONEDVECTOR) == 0)) {
-              mlib_v_ImageChannelExtract_U8_41_D1((mlib_u8 *)sp,
-                                                  (mlib_u8 *)dp,
-                                                  dsize,
-                                                  ncmask);
-            }
-            else {
-              mlib_v_ImageChannelExtract_U8_41((mlib_u8 *)sp, strides,
-                                               (mlib_u8 *)dp, strided,
-                                               width, height,
-                                               ncmask);
-            }
-            return MLIB_SUCCESS;
-
-          default:
-            return MLIB_FAILURE;
-        }
-      }
-      else if ((channels == 4) && (channeld == 3) && (ncmask == 7)) {
-        if (((flags & A8D1) == 0) &&
-            ((flagd & A8D1) == 0) &&
-            ((dsize & X8)   == 0)) {
-          mlib_v_ImageChannelExtract_U8_43R_A8D1X8((mlib_u8 *)sp,
-                                                   (mlib_u8 *)dp,
-                                                   dsize);
-        }
-        else if (((flags & A8D2X8) == 0) &&
-                 ((flagd & A8D2X8) == 0)) {
-          mlib_v_ImageChannelExtract_U8_43R_A8D2X8((mlib_u8 *)sp, strides,
-                                                   (mlib_u8 *)dp, strided,
-                                                   width, height);
-        }
-        else if (((flags & MLIB_IMAGE_ONEDVECTOR) == 0) &&
-                 ((flagd & MLIB_IMAGE_ONEDVECTOR) == 0)) {
-          mlib_v_ImageChannelExtract_U8_43R_D1((mlib_u8 *)sp,
-                                               (mlib_u8 *)dp,
-                                               dsize);
-        }
-        else {
-          mlib_v_ImageChannelExtract_U8_43R((mlib_u8 *)sp, strides,
-                                            (mlib_u8 *)dp, strided,
-                                            width, height);
-        }
-        return MLIB_SUCCESS;
-      }
-      else if ((channels == 4) && (channeld == 3) && (ncmask == 14)) {
-        if (((flags & A8D1) == 0) &&
-            ((flagd & A8D1) == 0) &&
-            ((dsize & X8)   == 0)) {
-          mlib_v_ImageChannelExtract_U8_43L_A8D1X8((mlib_u8 *)sp,
-                                                   (mlib_u8 *)dp,
-                                                   dsize);
-        }
-        else if (((flags & A8D2X8) == 0) &&
-                 ((flagd & A8D2X8) == 0)) {
-          mlib_v_ImageChannelExtract_U8_43L_A8D2X8((mlib_u8 *)sp, strides,
-                                                   (mlib_u8 *)dp, strided,
-                                                   width, height);
-        }
-        else if (((flags & MLIB_IMAGE_ONEDVECTOR) == 0) &&
-                 ((flagd & MLIB_IMAGE_ONEDVECTOR) == 0)) {
-          mlib_v_ImageChannelExtract_U8_43L_D1((mlib_u8 *)sp,
-                                               (mlib_u8 *)dp,
-                                               dsize);
-        }
-        else {
-          mlib_v_ImageChannelExtract_U8_43L((mlib_u8 *)sp, strides,
-                                            (mlib_u8 *)dp, strided,
-                                            width, height);
-        }
-        return MLIB_SUCCESS;
-      }
-      break;
-
-    case MLIB_SHORT:
-      if (channeld == 1) {
-        switch (channels) {
-          case 2:
-            if (((flags & A8D1) == 0) &&
-                ((flagd & A8D1) == 0) &&
-                ((dsize & X4)   == 0)) {
-              mlib_v_ImageChannelExtract_S16_21_A8D1X4((mlib_s16 *)sp,
-                                                       (mlib_s16 *)dp,
-                                                       dsize,
-                                                       ncmask);
-            }
-            else if (((flags & A8D2X4) == 0) &&
-                     ((flagd & A8D2X4) == 0)) {
-              mlib_v_ImageChannelExtract_S16_21_A8D2X4((mlib_s16 *)sp, strides,
-                                                       (mlib_s16 *)dp, strided,
-                                                       width, height,
-                                                       ncmask);
-            }
-            else if (((flags & MLIB_IMAGE_ONEDVECTOR) == 0) &&
-                     ((flagd & MLIB_IMAGE_ONEDVECTOR) == 0)) {
-              mlib_v_ImageChannelExtract_S16_21_D1((mlib_s16 *)sp,
-                                                   (mlib_s16 *)dp,
-                                                   dsize,
-                                                   ncmask);
-            }
-            else {
-              mlib_v_ImageChannelExtract_S16_21((mlib_s16 *)sp, strides,
-                                                (mlib_s16 *)dp, strided,
-                                                width, height,
-                                                ncmask);
-            }
-            return MLIB_SUCCESS;
-
-          case 3:
-            if (((flags & A8D1) == 0) &&
-                ((flagd & A8D1) == 0) &&
-                ((dsize & X4)   == 0)) {
-              mlib_v_ImageChannelExtract_S16_31_A8D1X4((mlib_s16 *)sp,
-                                                       (mlib_s16 *)dp,
-                                                       dsize,
-                                                       ncmask);
-            }
-            else if (((flags & A8D2X4) == 0) &&
-                     ((flagd & A8D2X4) == 0)) {
-              mlib_v_ImageChannelExtract_S16_31_A8D2X4((mlib_s16 *)sp, strides,
-                                                       (mlib_s16 *)dp, strided,
-                                                       width, height,
-                                                       ncmask);
-            }
-            else if (((flags & MLIB_IMAGE_ONEDVECTOR) == 0) &&
-                     ((flagd & MLIB_IMAGE_ONEDVECTOR) == 0)) {
-              mlib_v_ImageChannelExtract_S16_31_D1((mlib_s16 *)sp,
-                                                   (mlib_s16 *)dp,
-                                                   dsize,
-                                                   ncmask);
-            }
-            else {
-              mlib_v_ImageChannelExtract_S16_31((mlib_s16 *)sp, strides,
-                                                (mlib_s16 *)dp, strided,
-                                                width, height,
-                                                ncmask);
-            }
-            return MLIB_SUCCESS;
-
-          case 4:
-            if (((flags & A8D1) == 0) &&
-                ((flagd & A8D1) == 0) &&
-                ((dsize & X4)   == 0)) {
-              mlib_v_ImageChannelExtract_S16_41_A8D1X4((mlib_s16 *)sp,
-                                                       (mlib_s16 *)dp,
-                                                       dsize,
-                                                       ncmask);
-            }
-            else if (((flags & A8D2X4) == 0) &&
-                     ((flagd & A8D2X4) == 0)) {
-              mlib_v_ImageChannelExtract_S16_41_A8D2X4((mlib_s16 *)sp, strides,
-                                                       (mlib_s16 *)dp, strided,
-                                                       width, height,
-                                                       ncmask);
-            }
-            else if (((flags & MLIB_IMAGE_ONEDVECTOR) == 0) &&
-                     ((flagd & MLIB_IMAGE_ONEDVECTOR) == 0)) {
-              mlib_v_ImageChannelExtract_S16_41_D1((mlib_s16 *)sp,
-                                                   (mlib_s16 *)dp,
-                                                   dsize,
-                                                   ncmask);
-            }
-            else {
-              mlib_v_ImageChannelExtract_S16_41((mlib_s16 *)sp, strides,
-                                                (mlib_s16 *)dp, strided,
-                                                width, height,
-                                                ncmask);
-            }
-            return MLIB_SUCCESS;
-          default:
-            return MLIB_FAILURE;
-        }
-      }
-      else if ((channels == 4) && (channeld == 3) && (ncmask == 7)) {
-        if (((flags & A8D1) == 0) &&
-            ((flagd & A8D1) == 0) &&
-            ((dsize & X4)   == 0)) {
-          mlib_v_ImageChannelExtract_S16_43R_A8D1X4((mlib_s16 *)sp,
-                                                    (mlib_s16 *)dp,
-                                                    dsize);
-        }
-        else if (((flags & A8D2X4) == 0) &&
-                 ((flagd & A8D2X4) == 0)) {
-          mlib_v_ImageChannelExtract_S16_43R_A8D2X4((mlib_s16 *)sp, strides,
-                                                    (mlib_s16 *)dp, strided,
-                                                    width, height);
-        }
-        else if (((flags & MLIB_IMAGE_ONEDVECTOR) == 0) &&
-                 ((flagd & MLIB_IMAGE_ONEDVECTOR) == 0)) {
-          mlib_v_ImageChannelExtract_S16_43R_D1((mlib_s16 *)sp,
-                                                (mlib_s16 *)dp,
-                                                dsize);
-        }
-        else {
-          mlib_v_ImageChannelExtract_S16_43R((mlib_s16 *)sp, strides,
-                                             (mlib_s16 *)dp, strided,
-                                             width, height);
-        }
-        return MLIB_SUCCESS;
-      }
-      else if ((channels == 4) && (channeld == 3) && (ncmask == 14)) {
-        if (((flags & A8D1) == 0) &&
-            ((flagd & A8D1) == 0) &&
-            ((dsize & X4)   == 0)) {
-          mlib_v_ImageChannelExtract_S16_43L_A8D1X4((mlib_s16 *)sp,
-                                                    (mlib_s16 *)dp,
-                                                    dsize);
-        }
-        else if (((flags & A8D2X4) == 0) &&
-                 ((flagd & A8D2X4) == 0)) {
-          mlib_v_ImageChannelExtract_S16_43L_A8D2X4((mlib_s16 *)sp, strides,
-                                                    (mlib_s16 *)dp, strided,
-                                                    width, height);
-        }
-        else if (((flags & MLIB_IMAGE_ONEDVECTOR) == 0) &&
-                 ((flagd & MLIB_IMAGE_ONEDVECTOR) == 0)) {
-          mlib_v_ImageChannelExtract_S16_43L_D1((mlib_s16 *)sp,
-                                                (mlib_s16 *)dp,
-                                                dsize);
-        }
-        else {
-          mlib_v_ImageChannelExtract_S16_43L((mlib_s16 *)sp, strides,
-                                             (mlib_s16 *)dp, strided,
-                                             width, height);
-        }
-        return MLIB_SUCCESS;
-      }
-      break;
-
-  }
-
-/***************************************************************/
-  /* From C version */
-
-  for (i = (channels - 1); i >= 0; i--) {
-    if (!(ncmask & (1 << i))) delta0++;
-    else break;
-  }
-  for (; i >= 0; i--) {
-    if (ncmask & (1 << i)) count1++;
-    else break;
-  }
-
-  switch (mlib_ImageGetType(src)) {
-    case MLIB_BYTE:
-      {
-        mlib_u8 *sl = (mlib_u8 *)sp + delta0;
-        mlib_u8 *dl = (mlib_u8 *)dp;
-
-        switch (channels*10 + channeld) {
-          case 32:
-            mlib_v_ImageChannelExtract_U8_3_2(sl, strides, dl, strided, width, height, count1);
-            return MLIB_SUCCESS;
-
-          case 42:
-            if (ncmask == 0xA || ncmask == 0x5) { /* mask 1010 or 0101 */
-              mlib_v_ImageChannelExtract_U8_2_1(sl, strides, dl, strided, 2*width, height);
-              return MLIB_SUCCESS;
-            }
-            mlib_v_ImageChannelExtract_U8_4_2(sl, strides, dl, strided, width, height, count1);
-            return MLIB_SUCCESS;
-
-          case 43:
-            mlib_v_ImageChannelExtract_U8((mlib_u8 *)sp, strides,
-                                          (mlib_u8 *)dp, strided,
-                                          channels, channeld,
-                                          width, height,
-                                          ncmask);
-            return MLIB_SUCCESS;
-
-          default: return MLIB_FAILURE;
-        }
-      }
-
-    case MLIB_SHORT:
-      mlib_v_ImageChannelExtract_S16((mlib_u16 *)sp, strides,
-                                     (mlib_u16 *)dp, strided,
-                                     channels,  channeld,
-                                     width, height,
-                                     ncmask);
-      break;
-
-    case MLIB_INT:
-    case MLIB_FLOAT:
-      {
-        mlib_f32 *sl = (mlib_f32 *)sp + delta0;
-        mlib_f32 *dl = (mlib_f32 *)dp;
-        strides /= 4;
-        strided /= 4;
-
-        switch (channels*10 + channeld) {
-          case 21:
-            mlib_v_ImageChannelExtract_32_2_1(sl, strides, dl, strided, width, height);
-            return MLIB_SUCCESS;
-
-          case 31:
-            mlib_v_ImageChannelExtract_32_3_1(sl, strides, dl, strided, width, height);
-            return MLIB_SUCCESS;
-
-          case 32:
-            mlib_v_ImageChannelExtract_32_3_2(sl, strides, dl, strided, width, height, count1);
-            return MLIB_SUCCESS;
-
-          case 41:
-            mlib_v_ImageChannelExtract_32_4_1(sl, strides, dl, strided, width, height);
-            return MLIB_SUCCESS;
-
-          case 42:
-            if (ncmask == 0xA || ncmask == 0x5) { /* mask 1010 or 0101 */
-              mlib_v_ImageChannelExtract_32_2_1(sl, strides, dl, strided, 2*width, height);
-            } else {
-              mlib_v_ImageChannelExtract_32_4_2(sl, strides, dl, strided, width, height, count1);
-            }
-            return MLIB_SUCCESS;
-
-          case 43:
-            mlib_v_ImageChannelExtract_32_4_3(sl, strides, dl, strided, width, height, count1);
-            return MLIB_SUCCESS;
-
-          default:
-            return MLIB_FAILURE;
-        }
-      }
-    case MLIB_DOUBLE:
-      mlib_v_ImageChannelExtract_D64((mlib_d64 *)sp, strides,
-                                     (mlib_d64 *)dp, strided,
-                                     channels,  channeld,
-                                     width, height,
-                                     ncmask);
-      break;
-
-    case MLIB_BIT:
-    default:
-      return MLIB_FAILURE;  /* MLIB_BIT is not supported here */
-  }
-
-  return MLIB_SUCCESS;
-}
-
-/***************************************************************/
--- a/jdk/src/java.desktop/unix/native/libmlib_image/mlib_v_ImageChannelExtract.h	Thu May 19 17:48:02 2016 +0000
+++ b/jdk/src/java.desktop/unix/native/libmlib_image/mlib_v_ImageChannelExtract.h	Thu May 19 19:46:20 2016 +0000
@@ -32,348 +32,29 @@
 extern "C" {
 #endif /* __cplusplus */
 
-void mlib_v_ImageChannelExtract_U8_21_A8D1X8(const mlib_u8 *src,
-                                             mlib_u8       *dst,
-                                             mlib_s32      dsize,
-                                             mlib_s32      cmask);
-
-void mlib_v_ImageChannelExtract_U8_21_A8D2X8(const mlib_u8 *src,
-                                             mlib_s32      slb,
-                                             mlib_u8       *dst,
-                                             mlib_s32      dlb,
-                                             mlib_s32      xsize,
-                                             mlib_s32      ysize,
-                                             mlib_s32      cmask);
-
 void mlib_v_ImageChannelExtract_U8_21_D1(const mlib_u8 *src,
                                          mlib_u8       *dst,
                                          mlib_s32      dsize,
                                          mlib_s32      cmask);
 
-void mlib_v_ImageChannelExtract_U8_21(const mlib_u8 *src,
-                                      mlib_s32      slb,
-                                      mlib_u8       *dst,
-                                      mlib_s32      dlb,
-                                      mlib_s32      xsize,
-                                      mlib_s32      ysize,
-                                      mlib_s32      cmask);
-
-void mlib_v_ImageChannelExtract_U8_31_A8D1X8(const mlib_u8 *src,
-                                             mlib_u8       *dst,
-                                             mlib_s32      dsize,
-                                             mlib_s32      cmask);
-
-void mlib_v_ImageChannelExtract_U8_31_A8D2X8(const mlib_u8 *src,
-                                             mlib_s32      slb,
-                                             mlib_u8       *dst,
-                                             mlib_s32      dlb,
-                                             mlib_s32      xsize,
-                                             mlib_s32      ysize,
-                                             mlib_s32      cmask);
-
 void mlib_v_ImageChannelExtract_U8_31_D1(const mlib_u8 *src,
                                          mlib_u8       *dst,
                                          mlib_s32      dsize,
                                          mlib_s32      cmask);
 
-void mlib_v_ImageChannelExtract_U8_31(const mlib_u8 *src,
-                                      mlib_s32      slb,
-                                      mlib_u8       *dst,
-                                      mlib_s32      dlb,
-                                      mlib_s32      xsize,
-                                      mlib_s32      ysize,
-                                      mlib_s32      cmask);
-
-void mlib_v_ImageChannelExtract_U8_41_A8D1X8(const mlib_u8 *src,
-                                             mlib_u8       *dst,
-                                             mlib_s32      dsize,
-                                             mlib_s32      cmask);
-
-void mlib_v_ImageChannelExtract_U8_41_A8D2X8(const mlib_u8 *src,
-                                             mlib_s32      slb,
-                                             mlib_u8       *dst,
-                                             mlib_s32      dlb,
-                                             mlib_s32      xsize,
-                                             mlib_s32      ysize,
-                                             mlib_s32      cmask);
-
 void mlib_v_ImageChannelExtract_U8_41_D1(const mlib_u8 *src,
                                          mlib_u8       *dst,
                                          mlib_s32      dsize,
                                          mlib_s32      cmask);
 
-void mlib_v_ImageChannelExtract_U8_41(const mlib_u8 *src,
-                                      mlib_s32      slb,
-                                      mlib_u8       *dst,
-                                      mlib_s32      dlb,
-                                      mlib_s32      xsize,
-                                      mlib_s32      ysize,
-                                      mlib_s32      cmask);
-
-void mlib_v_ImageChannelExtract_S16_21_A8D1X4(const mlib_s16 *src,
-                                              mlib_s16       *dst,
-                                              mlib_s32       dsize,
-                                              mlib_s32       cmask);
-
-void mlib_v_ImageChannelExtract_S16_21_A8D2X4(const mlib_s16 *src,
-                                              mlib_s32       slb,
-                                              mlib_s16       *dst,
-                                              mlib_s32       dlb,
-                                              mlib_s32       xsize,
-                                              mlib_s32       ysize,
-                                              mlib_s32       cmask);
-
-void mlib_v_ImageChannelExtract_S16_21_D1(const mlib_s16 *src,
-                                          mlib_s16       *dst,
-                                          mlib_s32       dsize,
-                                          mlib_s32       cmask);
-
-void mlib_v_ImageChannelExtract_S16_21(const mlib_s16 *src,
-                                       mlib_s32       slb,
-                                       mlib_s16       *dst,
-                                       mlib_s32       dlb,
-                                       mlib_s32       xsize,
-                                       mlib_s32       ysize,
-                                       mlib_s32       cmask);
-
-void mlib_v_ImageChannelExtract_S16_31_A8D1X4(const mlib_s16 *src,
-                                              mlib_s16       *dst,
-                                              mlib_s32       dsize,
-                                              mlib_s32       cmask);
-
-void mlib_v_ImageChannelExtract_S16_31_A8D2X4(const mlib_s16 *src,
-                                              mlib_s32       slb,
-                                              mlib_s16       *dst,
-                                              mlib_s32       dlb,
-                                              mlib_s32       xsize,
-                                              mlib_s32       ysize,
-                                              mlib_s32       cmask);
-
-void mlib_v_ImageChannelExtract_S16_31_D1(const mlib_s16 *src,
-                                          mlib_s16       *dst,
-                                          mlib_s32       dsize,
-                                          mlib_s32       cmask);
-
-void mlib_v_ImageChannelExtract_S16_31(const mlib_s16 *src,
-                                       mlib_s32       slb,
-                                       mlib_s16       *dst,
-                                       mlib_s32       dlb,
-                                       mlib_s32       xsize,
-                                       mlib_s32       ysize,
-                                       mlib_s32       cmask);
-
-void mlib_v_ImageChannelExtract_S16_41_A8D1X4(const mlib_s16 *src,
-                                              mlib_s16       *dst,
-                                              mlib_s32       dsize,
-                                              mlib_s32       cmask);
-
-void mlib_v_ImageChannelExtract_S16_41_A8D2X4(const mlib_s16 *src,
-                                              mlib_s32       slb,
-                                              mlib_s16       *dst,
-                                              mlib_s32       dlb,
-                                              mlib_s32       xsize,
-                                              mlib_s32       ysize,
-                                              mlib_s32       cmask);
-
-void mlib_v_ImageChannelExtract_S16_41_D1(const mlib_s16 *src,
-                                          mlib_s16       *dst,
-                                          mlib_s32       dsize,
-                                          mlib_s32       cmask);
-
-void mlib_v_ImageChannelExtract_S16_41(const mlib_s16 *src,
-                                       mlib_s32       slb,
-                                       mlib_s16       *dst,
-                                       mlib_s32       dlb,
-                                       mlib_s32       xsize,
-                                       mlib_s32       ysize,
-                                       mlib_s32       cmask);
-
-void mlib_v_ImageChannelExtract_U8_43R_A8D1X8(const mlib_u8 *src,
-                                              mlib_u8       *dst,
-                                              mlib_s32      dsize);
-
-void mlib_v_ImageChannelExtract_U8_43R_A8D2X8(const mlib_u8 *src,
-                                              mlib_s32      slb,
-                                              mlib_u8       *dst,
-                                              mlib_s32      dlb,
-                                              mlib_s32      xsize,
-                                              mlib_s32      ysize);
-
-void mlib_v_ImageChannelExtract_U8_43R_D1(const mlib_u8 *src,
-                                          mlib_u8       *dst,
-                                          mlib_s32      dsize);
-
-void mlib_v_ImageChannelExtract_U8_43R(const mlib_u8 *src,
-                                       mlib_s32      slb,
-                                       mlib_u8       *dst,
-                                       mlib_s32      dlb,
-                                       mlib_s32      xsize,
-                                       mlib_s32      ysize);
-
-void mlib_v_ImageChannelExtract_S16_43R_A8D1X4(const mlib_s16 *src,
-                                               mlib_s16       *dst,
-                                               mlib_s32       dsize);
-
-void mlib_v_ImageChannelExtract_S16_43R_A8D2X4(const mlib_s16 *src,
-                                               mlib_s32       slb,
-                                               mlib_s16       *dst,
-                                               mlib_s32       dlb,
-                                               mlib_s32       xsize,
-                                               mlib_s32       ysize);
-
-void mlib_v_ImageChannelExtract_S16_43R_D1(const mlib_s16 *src,
-                                           mlib_s16       *dst,
-                                           mlib_s32       dsize);
-
-void mlib_v_ImageChannelExtract_S16_43R(const mlib_s16 *src,
-                                        mlib_s32       slb,
-                                        mlib_s16       *dst,
-                                        mlib_s32       dlb,
-                                        mlib_s32       xsize,
-                                        mlib_s32       ysize);
-
-void mlib_v_ImageChannelExtract_U8_43L_A8D1X8(const mlib_u8 *src,
-                                              mlib_u8       *dst,
-                                              mlib_s32      dsize);
-
-void mlib_v_ImageChannelExtract_U8_43L_A8D2X8(const mlib_u8 *src,
-                                              mlib_s32      slb,
-                                              mlib_u8       *dst,
-                                              mlib_s32      dlb,
-                                              mlib_s32      xsize,
-                                              mlib_s32      ysize);
-
 void mlib_v_ImageChannelExtract_U8_43L_D1(const mlib_u8 *src,
                                           mlib_u8       *dst,
                                           mlib_s32      dsize);
 
-void mlib_v_ImageChannelExtract_U8_43L(const mlib_u8 *src,
-                                       mlib_s32      slb,
-                                       mlib_u8       *dst,
-                                       mlib_s32      dlb,
-                                       mlib_s32      xsize,
-                                       mlib_s32      ysize);
-
-void mlib_v_ImageChannelExtract_S16_43L_A8D1X4(const mlib_s16 *src,
-                                               mlib_s16       *dst,
-                                               mlib_s32       dsize);
-
-void mlib_v_ImageChannelExtract_S16_43L_A8D2X4(const mlib_s16 *src,
-                                               mlib_s32       slb,
-                                               mlib_s16       *dst,
-                                               mlib_s32       dlb,
-                                               mlib_s32       xsize,
-                                               mlib_s32       ysize);
-
 void mlib_v_ImageChannelExtract_S16_43L_D1(const mlib_s16 *src,
                                            mlib_s16       *dst,
                                            mlib_s32       dsize);
 
-void mlib_v_ImageChannelExtract_S16_43L(const mlib_s16 *src,
-                                        mlib_s32       slb,
-                                        mlib_s16       *dst,
-                                        mlib_s32       dlb,
-                                        mlib_s32       xsize,
-                                        mlib_s32       ysize);
-
-void mlib_v_ImageChannelExtract_U8_2_1(const mlib_u8 *sl,
-                                       mlib_s32      slb,
-                                       mlib_u8       *dl,
-                                       mlib_s32      dlb,
-                                       mlib_s32      width,
-                                       mlib_s32      height);
-
-void mlib_v_ImageChannelExtract_U8_3_2(const mlib_u8 *sl,
-                                       mlib_s32      slb,
-                                       mlib_u8       *dl,
-                                       mlib_s32      dlb,
-                                       mlib_s32      width,
-                                       mlib_s32      height,
-                                       mlib_s32      count1);
-
-void mlib_v_ImageChannelExtract_U8_4_2(const mlib_u8 *sl,
-                                       mlib_s32      slb,
-                                       mlib_u8       *dl,
-                                       mlib_s32      dlb,
-                                       mlib_s32      width,
-                                       mlib_s32      height,
-                                       mlib_s32      count1);
-
-void mlib_v_ImageChannelExtract_32_2_1(const mlib_f32 *sp,
-                                       mlib_s32       slb,
-                                       mlib_f32       *dp,
-                                       mlib_s32       dlb,
-                                       mlib_s32       width,
-                                       mlib_s32       height);
-
-void mlib_v_ImageChannelExtract_32_3_1(const mlib_f32 *sl,
-                                       mlib_s32       slb,
-                                       mlib_f32       *dl,
-                                       mlib_s32       dlb,
-                                       mlib_s32       width,
-                                       mlib_s32       height);
-
-void mlib_v_ImageChannelExtract_32_3_2(const mlib_f32 *sl,
-                                       mlib_s32       slb,
-                                       mlib_f32       *dl,
-                                       mlib_s32       dlb,
-                                       mlib_s32       width,
-                                       mlib_s32       height,
-                                       mlib_s32       count1);
-
-void mlib_v_ImageChannelExtract_32_4_1(const mlib_f32 *sp,
-                                       mlib_s32       slb,
-                                       mlib_f32       *dp,
-                                       mlib_s32       dlb,
-                                       mlib_s32       width,
-                                       mlib_s32       height);
-
-void mlib_v_ImageChannelExtract_32_4_2(const mlib_f32 *sl,
-                                       mlib_s32       slb,
-                                       mlib_f32       *dl,
-                                       mlib_s32       dlb,
-                                       mlib_s32       width,
-                                       mlib_s32       height,
-                                       mlib_s32       count1);
-
-void mlib_v_ImageChannelExtract_32_4_3(const mlib_f32 *sl,
-                                       mlib_s32       slb,
-                                       mlib_f32       *dl,
-                                       mlib_s32       dlb,
-                                       mlib_s32       width,
-                                       mlib_s32       height,
-                                       mlib_s32       count1);
-
-void mlib_v_ImageChannelExtract_U8(const mlib_u8 *src,
-                                   mlib_s32      slb,
-                                   mlib_u8       *dst,
-                                   mlib_s32      dlb,
-                                   mlib_s32      channels,
-                                   mlib_s32      channeld,
-                                   mlib_s32      width,
-                                   mlib_s32      height,
-                                   mlib_s32      cmask);
-
-void mlib_v_ImageChannelExtract_S16(const mlib_u16 *src,
-                                    mlib_s32       slb,
-                                    mlib_u16       *dst,
-                                    mlib_s32       dlb,
-                                    mlib_s32       channels,
-                                    mlib_s32       channeld,
-                                    mlib_s32       width,
-                                    mlib_s32       height,
-                                    mlib_s32       cmask);
-
-void mlib_v_ImageChannelExtract_D64(const mlib_d64 *src,
-                                    mlib_s32       slb,
-                                    mlib_d64       *dst,
-                                    mlib_s32       dlb,
-                                    mlib_s32       channels,
-                                    mlib_s32       channeld,
-                                    mlib_s32       width,
-                                    mlib_s32       height,
-                                    mlib_s32       cmask);
-
 #ifdef __cplusplus
 }
 #endif /* __cplusplus */
--- a/jdk/src/java.desktop/unix/native/libmlib_image/mlib_v_ImageChannelExtract_1.c	Thu May 19 17:48:02 2016 +0000
+++ b/jdk/src/java.desktop/unix/native/libmlib_image/mlib_v_ImageChannelExtract_1.c	Thu May 19 19:46:20 2016 +0000
@@ -29,30 +29,9 @@
  * FILENAME: mlib_ImageChannelExtract_1.c
  *
  * FUNCTIONS
- *      mlib_v_ImageChannelExtract_U8_21_A8D1X8
- *      mlib_v_ImageChannelExtract_U8_21_A8D2X8
  *      mlib_v_ImageChannelExtract_U8_21_D1
- *      mlib_v_ImageChannelExtract_U8_21
- *      mlib_v_ImageChannelExtract_U8_31_A8D1X8
- *      mlib_v_ImageChannelExtract_U8_31_A8D2X8
  *      mlib_v_ImageChannelExtract_U8_31_D1
- *      mlib_v_ImageChannelExtract_U8_31
- *      mlib_v_ImageChannelExtract_U8_41_A8D1X8
- *      mlib_v_ImageChannelExtract_U8_41_A8D2X8
  *      mlib_v_ImageChannelExtract_U8_41_D1
- *      mlib_v_ImageChannelExtract_U8_41
- *      mlib_v_ImageChannelExtract_S16_21_A8D1X4
- *      mlib_v_ImageChannelExtract_S16_21_A8D2X4
- *      mlib_v_ImageChannelExtract_S16_21_D1
- *      mlib_v_ImageChannelExtract_S16_21
- *      mlib_v_ImageChannelExtract_S16_31_A8D1X4
- *      mlib_v_ImageChannelExtract_S16_31_A8D2X4
- *      mlib_v_ImageChannelExtract_S16_31_D1
- *      mlib_v_ImageChannelExtract_S16_31
- *      mlib_v_ImageChannelExtract_S16_41_A8D1X4
- *      mlib_v_ImageChannelExtract_S16_41_A8D2X4
- *      mlib_v_ImageChannelExtract_S16_41_D1
- *      mlib_v_ImageChannelExtract_S16_41
  *
  * ARGUMENT
  *      src    pointer to source image data
@@ -95,100 +74,6 @@
 
 /***************************************************************/
 /* extract one channel from a 2-channel image.
- * both source and destination image data are 8-byte aligned.
- * xsize is multiple of 8.
- */
-
-void mlib_v_ImageChannelExtract_U8_21_A8D1X8(const mlib_u8 *src,
-                                             mlib_u8       *dst,
-                                             mlib_s32      dsize,
-                                             mlib_s32      cmask)
-{
-  mlib_d64 *sp, *dp;
-  mlib_d64 sd0, sd1;
-  mlib_d64 sda, sdb, sdc, sdd;
-  mlib_d64 dd;
-  mlib_s32 i;
-
-  sp = (mlib_d64 *) src;
-  dp = (mlib_d64 *) dst;
-
-  if (cmask == 2) {
-#pragma pipeloop(0)
-    for (i = 0; i < dsize / 8; i++) {
-      sd0 = *sp++;
-      sd1 = *sp++;
-      CHANNELEXTRACT_U8_21L(sd0, sd1, dd);
-      *dp++ = dd;
-    }
-  }
-  else {
-#pragma pipeloop(0)
-    for (i = 0; i < dsize / 8; i++) {
-      sd0 = *sp++;
-      sd1 = *sp++;
-      CHANNELEXTRACT_U8_21R(sd0, sd1, dd);
-      *dp++ = dd;
-    }
-  }
-}
-
-/***************************************************************/
-/* extract one channel from a 2-channel image.
- * both source and destination image data are 8-byte aligned.
- * xsize is multiple of 8.
- */
-
-void mlib_v_ImageChannelExtract_U8_21_A8D2X8(const mlib_u8 *src,
-                                             mlib_s32      slb,
-                                             mlib_u8       *dst,
-                                             mlib_s32      dlb,
-                                             mlib_s32      xsize,
-                                             mlib_s32      ysize,
-                                             mlib_s32      cmask)
-{
-  mlib_d64 *sp, *dp;
-  mlib_d64 *sl, *dl;
-  mlib_d64 sd0, sd1;
-  mlib_d64 sda, sdb, sdc, sdd;
-  mlib_d64 dd;
-  mlib_s32 i, j;
-
-  sp = sl = (mlib_d64 *) src;
-  dp = dl = (mlib_d64 *) dst;
-
-  if (cmask == 2) {
-    for (j = 0; j < ysize; j++) {
-#pragma pipeloop(0)
-      for (i = 0; i < xsize / 8; i++) {
-        sd0 = *sp++;
-        sd1 = *sp++;
-        CHANNELEXTRACT_U8_21L(sd0, sd1, dd);
-        *dp++ = dd;
-      }
-
-      sp = sl = (mlib_d64 *) ((mlib_u8 *) sl + slb);
-      dp = dl = (mlib_d64 *) ((mlib_u8 *) dl + dlb);
-    }
-  }
-  else {
-    for (j = 0; j < ysize; j++) {
-#pragma pipeloop(0)
-      for (i = 0; i < xsize / 8; i++) {
-        sd0 = *sp++;
-        sd1 = *sp++;
-        CHANNELEXTRACT_U8_21R(sd0, sd1, dd);
-        *dp++ = dd;
-      }
-
-      sp = sl = (mlib_d64 *) ((mlib_u8 *) sl + slb);
-      dp = dl = (mlib_d64 *) ((mlib_u8 *) dl + dlb);
-    }
-  }
-}
-
-/***************************************************************/
-/* extract one channel from a 2-channel image.
  */
 
 void mlib_v_ImageChannelExtract_U8_21_D1(const mlib_u8 *src,
@@ -415,32 +300,6 @@
 }
 
 /***************************************************************/
-/* extract one channel from a 2-channel image.
- */
-
-void mlib_v_ImageChannelExtract_U8_21(const mlib_u8 *src,
-                                      mlib_s32      slb,
-                                      mlib_u8       *dst,
-                                      mlib_s32      dlb,
-                                      mlib_s32      xsize,
-                                      mlib_s32      ysize,
-                                      mlib_s32      cmask)
-{
-  mlib_u8 *sa, *da;
-  mlib_u8 *sl, *dl;
-  mlib_s32 j;
-
-  sa = sl = (void *)src;
-  da = dl = dst;
-
-  for (j = 0; j < ysize; j++) {
-    mlib_v_ImageChannelExtract_U8_21_D1(sa, da, xsize, cmask);
-    sa = sl += slb;
-    da = dl += dlb;
-  }
-}
-
-/***************************************************************/
 #define CHANNELEXTRACT_U8_31L(sd0, sd1, sd2, dd)                \
   sda = vis_fpmerge(vis_read_hi(sd0), vis_read_lo(sd1));        \
   sdb = vis_fpmerge(vis_read_lo(sd0), vis_read_hi(sd2));        \
@@ -468,119 +327,6 @@
   dd  = vis_fpmerge(vis_read_hi(sdd), vis_read_lo(sde))
 
 /***************************************************************/
-void mlib_v_ImageChannelExtract_U8_31_A8D1X8(const mlib_u8 *src,
-                                             mlib_u8       *dst,
-                                             mlib_s32      dsize,
-                                             mlib_s32      cmask)
-{
-  mlib_d64 *sp, *dp;
-  mlib_d64 sd0, sd1, sd2;
-  mlib_d64 sda, sdb, sdc, sdd, sde;
-  mlib_d64 dd;
-  mlib_s32 i;
-
-  sp = (mlib_d64 *) src;
-  dp = (mlib_d64 *) dst;
-
-  if (cmask == 4) {
-#pragma pipeloop(0)
-    for (i = 0; i < dsize / 8; i++) {
-      sd0 = *sp++;
-      sd1 = *sp++;
-      sd2 = *sp++;
-      CHANNELEXTRACT_U8_31L(sd0, sd1, sd2, dd);
-      *dp++ = dd;
-    }
-  }
-  else if (cmask == 2) {
-#pragma pipeloop(0)
-    for (i = 0; i < dsize / 8; i++) {
-      sd0 = *sp++;
-      sd1 = *sp++;
-      sd2 = *sp++;
-      CHANNELEXTRACT_U8_31M(sd0, sd1, sd2, dd);
-      *dp++ = dd;
-    }
-  }
-  else {
-#pragma pipeloop(0)
-    for (i = 0; i < dsize / 8; i++) {
-      sd0 = *sp++;
-      sd1 = *sp++;
-      sd2 = *sp++;
-      CHANNELEXTRACT_U8_31R(sd0, sd1, sd2, dd);
-      *dp++ = dd;
-    }
-  }
-}
-
-/***************************************************************/
-void mlib_v_ImageChannelExtract_U8_31_A8D2X8(const mlib_u8 *src,
-                                             mlib_s32      slb,
-                                             mlib_u8       *dst,
-                                             mlib_s32      dlb,
-                                             mlib_s32      xsize,
-                                             mlib_s32      ysize,
-                                             mlib_s32      cmask)
-{
-  mlib_d64 *sp, *dp;
-  mlib_d64 *sl, *dl;
-  mlib_d64 sd0, sd1, sd2;
-  mlib_d64 sda, sdb, sdc, sdd, sde;
-  mlib_d64 dd;
-  mlib_s32 i, j;
-
-  sp = sl = (mlib_d64 *) src;
-  dp = dl = (mlib_d64 *) dst;
-
-  if (cmask == 4) {
-    for (j = 0; j < ysize; j++) {
-#pragma pipeloop(0)
-      for (i = 0; i < xsize / 8; i++) {
-        sd0 = *sp++;
-        sd1 = *sp++;
-        sd2 = *sp++;
-        CHANNELEXTRACT_U8_31L(sd0, sd1, sd2, dd);
-        *dp++ = dd;
-      }
-
-      sp = sl = (mlib_d64 *) ((mlib_u8 *) sl + slb);
-      dp = dl = (mlib_d64 *) ((mlib_u8 *) dl + dlb);
-    }
-  }
-  else if (cmask == 2) {
-    for (j = 0; j < ysize; j++) {
-#pragma pipeloop(0)
-      for (i = 0; i < xsize / 8; i++) {
-        sd0 = *sp++;
-        sd1 = *sp++;
-        sd2 = *sp++;
-        CHANNELEXTRACT_U8_31M(sd0, sd1, sd2, dd);
-        *dp++ = dd;
-      }
-
-      sp = sl = (mlib_d64 *) ((mlib_u8 *) sl + slb);
-      dp = dl = (mlib_d64 *) ((mlib_u8 *) dl + dlb);
-    }
-  }
-  else {
-    for (j = 0; j < ysize; j++) {
-#pragma pipeloop(0)
-      for (i = 0; i < xsize / 8; i++) {
-        sd0 = *sp++;
-        sd1 = *sp++;
-        sd2 = *sp++;
-        CHANNELEXTRACT_U8_31R(sd0, sd1, sd2, dd);
-        *dp++ = dd;
-      }
-
-      sp = sl = (mlib_d64 *) ((mlib_u8 *) sl + slb);
-      dp = dl = (mlib_d64 *) ((mlib_u8 *) dl + dlb);
-    }
-  }
-}
-
-/***************************************************************/
 void mlib_v_ImageChannelExtract_U8_31_D1(const mlib_u8 *src,
                                          mlib_u8       *dst,
                                          mlib_s32      dsize,
@@ -932,29 +678,6 @@
 }
 
 /***************************************************************/
-void mlib_v_ImageChannelExtract_U8_31(const mlib_u8 *src,
-                                      mlib_s32      slb,
-                                      mlib_u8       *dst,
-                                      mlib_s32      dlb,
-                                      mlib_s32      xsize,
-                                      mlib_s32      ysize,
-                                      mlib_s32      cmask)
-{
-  mlib_u8 *sa, *da;
-  mlib_u8 *sl, *dl;
-  mlib_s32 j;
-
-  sa = sl = (void *)src;
-  da = dl = dst;
-
-  for (j = 0; j < ysize; j++) {
-    mlib_v_ImageChannelExtract_U8_31_D1(sa, da, xsize, cmask);
-    sa = sl += slb;
-    da = dl += dlb;
-  }
-}
-
-/***************************************************************/
 #define CHANNELEXTRACT_U8_41L(sd0, sd1, sd2, sd3, dd)           \
   sda = vis_fpmerge(vis_read_hi(sd0), vis_read_hi(sd2));        \
   sdb = vis_fpmerge(vis_read_lo(sd0), vis_read_lo(sd2));        \
@@ -995,152 +718,6 @@
   dd  = vis_fpmerge(vis_read_lo(sde), vis_read_lo(sdf))
 
 /***************************************************************/
-void mlib_v_ImageChannelExtract_U8_41_A8D1X8(const mlib_u8 *src,
-                                             mlib_u8       *dst,
-                                             mlib_s32      dsize,
-                                             mlib_s32      cmask)
-{
-  mlib_d64 *sp, *dp;
-  mlib_d64 sd0, sd1, sd2, sd3;
-  mlib_d64 sda, sdb, sdc, sdd, sde, sdf;
-  mlib_d64 dd;
-  mlib_s32 i;
-
-  sp = (mlib_d64 *) src;
-  dp = (mlib_d64 *) dst;
-
-  if (cmask == 8) {
-#pragma pipeloop(0)
-    for (i = 0; i < dsize / 8; i++) {
-      sd0 = *sp++;
-      sd1 = *sp++;
-      sd2 = *sp++;
-      sd3 = *sp++;
-      CHANNELEXTRACT_U8_41L(sd0, sd1, sd2, sd3, dd);
-      *dp++ = dd;
-    }
-  }
-  else if (cmask == 4) {
-#pragma pipeloop(0)
-    for (i = 0; i < dsize / 8; i++) {
-      sd0 = *sp++;
-      sd1 = *sp++;
-      sd2 = *sp++;
-      sd3 = *sp++;
-      CHANNELEXTRACT_U8_41ML(sd0, sd1, sd2, sd3, dd);
-      *dp++ = dd;
-    }
-  }
-  else if (cmask == 2) {
-#pragma pipeloop(0)
-    for (i = 0; i < dsize / 8; i++) {
-      sd0 = *sp++;
-      sd1 = *sp++;
-      sd2 = *sp++;
-      sd3 = *sp++;
-      CHANNELEXTRACT_U8_41MR(sd0, sd1, sd2, sd3, dd);
-      *dp++ = dd;
-    }
-  }
-  else {
-#pragma pipeloop(0)
-    for (i = 0; i < dsize / 8; i++) {
-      sd0 = *sp++;
-      sd1 = *sp++;
-      sd2 = *sp++;
-      sd3 = *sp++;
-      CHANNELEXTRACT_U8_41R(sd0, sd1, sd2, sd3, dd);
-      *dp++ = dd;
-    }
-  }
-}
-
-/***************************************************************/
-void mlib_v_ImageChannelExtract_U8_41_A8D2X8(const mlib_u8 *src,
-                                             mlib_s32      slb,
-                                             mlib_u8       *dst,
-                                             mlib_s32      dlb,
-                                             mlib_s32      xsize,
-                                             mlib_s32      ysize,
-                                             mlib_s32      cmask)
-{
-  mlib_d64 *sp, *dp;
-  mlib_d64 *sl, *dl;
-  mlib_d64 sd0, sd1, sd2, sd3;
-  mlib_d64 sda, sdb, sdc, sdd, sde, sdf;
-  mlib_d64 dd;
-  mlib_s32 i, j;
-
-  sp = sl = (mlib_d64 *) src;
-  dp = dl = (mlib_d64 *) dst;
-
-  if (cmask == 8) {
-    for (j = 0; j < ysize; j++) {
-#pragma pipeloop(0)
-      for (i = 0; i < xsize / 8; i++) {
-        sd0 = *sp++;
-        sd1 = *sp++;
-        sd2 = *sp++;
-        sd3 = *sp++;
-        CHANNELEXTRACT_U8_41L(sd0, sd1, sd2, sd3, dd);
-        *dp++ = dd;
-      }
-
-      sp = sl = (mlib_d64 *) ((mlib_u8 *) sl + slb);
-      dp = dl = (mlib_d64 *) ((mlib_u8 *) dl + dlb);
-    }
-  }
-  else if (cmask == 4) {
-    for (j = 0; j < ysize; j++) {
-#pragma pipeloop(0)
-      for (i = 0; i < xsize / 8; i++) {
-        sd0 = *sp++;
-        sd1 = *sp++;
-        sd2 = *sp++;
-        sd3 = *sp++;
-        CHANNELEXTRACT_U8_41ML(sd0, sd1, sd2, sd3, dd);
-        *dp++ = dd;
-      }
-
-      sp = sl = (mlib_d64 *) ((mlib_u8 *) sl + slb);
-      dp = dl = (mlib_d64 *) ((mlib_u8 *) dl + dlb);
-    }
-  }
-  else if (cmask == 2) {
-    for (j = 0; j < ysize; j++) {
-#pragma pipeloop(0)
-      for (i = 0; i < xsize / 8; i++) {
-        sd0 = *sp++;
-        sd1 = *sp++;
-        sd2 = *sp++;
-        sd3 = *sp++;
-        CHANNELEXTRACT_U8_41MR(sd0, sd1, sd2, sd3, dd);
-        *dp++ = dd;
-      }
-
-      sp = sl = (mlib_d64 *) ((mlib_u8 *) sl + slb);
-      dp = dl = (mlib_d64 *) ((mlib_u8 *) dl + dlb);
-    }
-  }
-  else {
-    for (j = 0; j < ysize; j++) {
-#pragma pipeloop(0)
-      for (i = 0; i < xsize / 8; i++) {
-        sd0 = *sp++;
-        sd1 = *sp++;
-        sd2 = *sp++;
-        sd3 = *sp++;
-        CHANNELEXTRACT_U8_41R(sd0, sd1, sd2, sd3, dd);
-        *dp++ = dd;
-      }
-
-      sp = sl = (mlib_d64 *) ((mlib_u8 *) sl + slb);
-      dp = dl = (mlib_d64 *) ((mlib_u8 *) dl + dlb);
-    }
-  }
-}
-
-/***************************************************************/
 void mlib_v_ImageChannelExtract_U8_41_D1(const mlib_u8 *src,
                                          mlib_u8       *dst,
                                          mlib_s32      dsize,
@@ -1632,1560 +1209,3 @@
 }
 
 /***************************************************************/
-void mlib_v_ImageChannelExtract_U8_41(const mlib_u8 *src,
-                                      mlib_s32      slb,
-                                      mlib_u8       *dst,
-                                      mlib_s32      dlb,
-                                      mlib_s32      xsize,
-                                      mlib_s32      ysize,
-                                      mlib_s32      cmask)
-{
-  mlib_u8 *sa, *da;
-  mlib_u8 *sl, *dl;
-  mlib_s32 j;
-
-  sa = sl = (void *)src;
-  da = dl = dst;
-
-  for (j = 0; j < ysize; j++) {
-    mlib_v_ImageChannelExtract_U8_41_D1(sa, da, xsize, cmask);
-    sa = sl += slb;
-    da = dl += dlb;
-  }
-}
-
-/***************************************************************/
-#define CHANNELEXTRACT_S16_21L(sd0, sd1, dd)                    \
-  sda = vis_fpmerge(vis_read_hi(sd0), vis_read_hi(sd1));        \
-  sdb = vis_fpmerge(vis_read_lo(sd0), vis_read_lo(sd1));        \
-  sdc = vis_fpmerge(vis_read_hi(sda), vis_read_hi(sdb));        \
-  dd  = vis_fpmerge(vis_read_hi(sdc), vis_read_lo(sdc))
-
-/***************************************************************/
-#define CHANNELEXTRACT_S16_21R(sd0, sd1, dd)                    \
-  sda = vis_fpmerge(vis_read_hi(sd0), vis_read_hi(sd1));        \
-  sdb = vis_fpmerge(vis_read_lo(sd0), vis_read_lo(sd1));        \
-  sdc = vis_fpmerge(vis_read_lo(sda), vis_read_lo(sdb));        \
-  dd  = vis_fpmerge(vis_read_hi(sdc), vis_read_lo(sdc))
-
-/***************************************************************/
-/* extract one channel from a 2-channel image.
- * both source and destination image data are 8-byte aligned.
- * dsize is multiple of 4.
- */
-
-void mlib_v_ImageChannelExtract_S16_21_A8D1X4(const mlib_s16 *src,
-                                              mlib_s16       *dst,
-                                              mlib_s32       dsize,
-                                              mlib_s32       cmask)
-{
-  mlib_d64 *sp, *dp;
-  mlib_d64 sd0, sd1;
-  mlib_d64 sda, sdb, sdc;
-  mlib_d64 dd;
-  mlib_s32 i;
-
-  sp = (mlib_d64 *) src;
-  dp = (mlib_d64 *) dst;
-
-  if (cmask == 2) {
-#pragma pipeloop(0)
-    for (i = 0; i < dsize / 4; i++) {
-      sd0 = *sp++;
-      sd1 = *sp++;
-      CHANNELEXTRACT_S16_21L(sd0, sd1, dd);
-      *dp++ = dd;
-    }
-  }
-  else {
-#pragma pipeloop(0)
-    for (i = 0; i < dsize / 4; i++) {
-      sd0 = *sp++;
-      sd1 = *sp++;
-      CHANNELEXTRACT_S16_21R(sd0, sd1, dd);
-      *dp++ = dd;
-    }
-  }
-}
-
-/***************************************************************/
-void mlib_v_ImageChannelExtract_S16_21_A8D2X4(const mlib_s16 *src,
-                                              mlib_s32       slb,
-                                              mlib_s16       *dst,
-                                              mlib_s32       dlb,
-                                              mlib_s32       xsize,
-                                              mlib_s32       ysize,
-                                              mlib_s32       cmask)
-{
-  mlib_d64 *sp, *dp;
-  mlib_d64 *sl, *dl;
-  mlib_d64 sd0, sd1;
-  mlib_d64 sda, sdb, sdc;
-  mlib_d64 dd;
-  mlib_s32 i, j;
-
-  sp = sl = (mlib_d64 *) src;
-  dp = dl = (mlib_d64 *) dst;
-
-  if (cmask == 2) {
-    for (j = 0; j < ysize; j++) {
-#pragma pipeloop(0)
-      for (i = 0; i < xsize / 4; i++) {
-        sd0 = *sp++;
-        sd1 = *sp++;
-        CHANNELEXTRACT_S16_21L(sd0, sd1, dd);
-        *dp++ = dd;
-      }
-
-      sp = sl = (mlib_d64 *) ((mlib_u8 *) sl + slb);
-      dp = dl = (mlib_d64 *) ((mlib_u8 *) dl + dlb);
-    }
-  }
-  else {
-    for (j = 0; j < ysize; j++) {
-#pragma pipeloop(0)
-      for (i = 0; i < xsize / 4; i++) {
-        sd0 = *sp++;
-        sd1 = *sp++;
-        CHANNELEXTRACT_S16_21R(sd0, sd1, dd);
-        *dp++ = dd;
-      }
-
-      sp = sl = (mlib_d64 *) ((mlib_u8 *) sl + slb);
-      dp = dl = (mlib_d64 *) ((mlib_u8 *) dl + dlb);
-    }
-  }
-}
-
-/***************************************************************/
-void mlib_v_ImageChannelExtract_S16_21_D1(const mlib_s16 *src,
-                                          mlib_s16       *dst,
-                                          mlib_s32       dsize,
-                                          mlib_s32       cmask)
-{
-  mlib_s16 *sa, *da;
-  mlib_s16 *dend, *dend2;                             /* end points in dst */
-  mlib_d64 *dp;                                       /* 8-byte aligned start points in dst */
-  mlib_d64 *sp;                                       /* 8-byte aligned start point in src */
-  mlib_d64 sd0, sd1, sd2, sd3;                        /* 8-byte source data */
-  mlib_d64 sda, sdb, sdc;
-  mlib_d64 dd0, dd1;
-  mlib_s32 soff;                                      /* offset of address in src */
-  mlib_s32 doff;                                      /* offset of address in dst */
-  mlib_s32 off;                                       /* offset of dst over src */
-  mlib_s32 emask;                                     /* edge mask */
-  mlib_s32 i, n;
-
-  sa = (void *)src;
-  da = dst;
-
-  /* prepare the source address */
-  sp = (mlib_d64 *) ((mlib_addr) sa & (~7));
-  soff = ((mlib_addr) sa & 7);
-
-  /* prepare the destination addresses */
-  dp = (mlib_d64 *) ((mlib_addr) da & (~7));
-  doff = ((mlib_addr) da & 7);
-  dend = da + dsize - 1;
-  dend2 = dend - 3;
-
-  /* calculate the src's offset over dst */
-  if (cmask == 2) {
-    off = (soff / 4) * 2 - doff;
-  }
-  else {
-    off = ((soff + 3) / 4) * 2 - doff;
-  }
-
-  if (((cmask == 2) && (soff % 4 == 0)) || ((cmask == 1) && (soff % 4 != 0))) { /* extract even words */
-
-    if (off == 0) {                         /* src and dst have same alignment */
-
-      /* generate edge mask for the start point */
-      emask = vis_edge16(da, dend);
-
-      /* load 16 bytes */
-      sd0 = *sp++;
-      sd1 = *sp++;
-
-      /* extract, including some garbage at the start point */
-      CHANNELEXTRACT_S16_21L(sd0, sd1, dd0);
-
-      /* store 8 bytes result */
-      vis_pst_16(dd0, dp++, emask);
-
-      if ((mlib_addr) dp <= (mlib_addr) dend2) {
-        n = ((mlib_u8 *) dend2 - (mlib_u8 *) dp) / 8 + 1;
-
-        /* 8-pixel column loop, emask not needed */
-#pragma pipeloop(0)
-        for (i = 0; i < n; i++) {
-          sd0 = *sp++;
-          sd1 = *sp++;
-          CHANNELEXTRACT_S16_21L(sd0, sd1, dd0);
-          *dp++ = dd0;
-        }
-      }
-
-      /* end point handling */
-      if ((mlib_addr) dp <= (mlib_addr) dend) {
-        emask = vis_edge16(dp, dend);
-        sd0 = *sp++;
-        sd1 = *sp++;
-        CHANNELEXTRACT_S16_21L(sd0, sd1, dd0);
-        vis_pst_16(dd0, dp++, emask);
-      }
-    }
-    else {
-      vis_alignaddr((void *)0, off);
-
-      /* generate edge mask for the start point */
-      emask = vis_edge16(da, dend);
-
-      if (off < 0) {
-        /* load 16 bytes */
-        sd2 = *sp++;
-        sd3 = *sp++;
-
-        /* extract and store 8 bytes */
-        CHANNELEXTRACT_S16_21L(sd2, sd3, dd1);
-        vis_pst_16(vis_faligndata(dd1, dd1), dp++, emask);
-      }
-      else {
-        /* load 32 bytes */
-        sd0 = *sp++;
-        sd1 = *sp++;
-        sd2 = *sp++;
-        sd3 = *sp++;
-
-        /* extract and store 8 bytes */
-        CHANNELEXTRACT_S16_21L(sd0, sd1, dd0);
-        CHANNELEXTRACT_S16_21L(sd2, sd3, dd1);
-        vis_pst_16(vis_faligndata(dd0, dd1), dp++, emask);
-      }
-
-      if ((mlib_addr) dp <= (mlib_addr) dend2) {
-        n = ((mlib_u8 *) dend2 - (mlib_u8 *) dp) / 8 + 1;
-
-        /* 8-pixel column loop, emask not needed */
-#pragma pipeloop(0)
-        for (i = 0; i < n; i++) {
-          dd0 = dd1;
-          sd2 = *sp++;
-          sd3 = *sp++;
-          CHANNELEXTRACT_S16_21L(sd2, sd3, dd1);
-          *dp++ = vis_faligndata(dd0, dd1);
-        }
-      }
-
-      /* end point handling */
-      if ((mlib_addr) dp <= (mlib_addr) dend) {
-        emask = vis_edge16(dp, dend);
-        dd0 = dd1;
-        sd2 = *sp++;
-        sd3 = *sp++;
-        CHANNELEXTRACT_S16_21L(sd2, sd3, dd1);
-        vis_pst_16(vis_faligndata(dd0, dd1), dp++, emask);
-      }
-    }
-  }
-  else {                                    /* extract odd words */
-
-    if (off == 0) {                         /* src and dst have same alignment */
-
-      /* generate edge mask for the start point */
-      emask = vis_edge16(da, dend);
-
-      /* load 16 bytes, don't care the garbage at the start point */
-      sd0 = *sp++;
-      sd1 = *sp++;
-
-      /* extract and store 8 bytes */
-      CHANNELEXTRACT_S16_21R(sd0, sd1, dd0);
-      vis_pst_16(dd0, dp++, emask);
-
-      if ((mlib_addr) dp <= (mlib_addr) dend2) {
-        n = ((mlib_u8 *) dend2 - (mlib_u8 *) dp) / 8 + 1;
-
-        /* 8-pixel column loop, emask not needed */
-#pragma pipeloop(0)
-        for (i = 0; i < n; i++) {
-          sd0 = *sp++;
-          sd1 = *sp++;
-          CHANNELEXTRACT_S16_21R(sd0, sd1, dd0);
-          *dp++ = dd0;
-        }
-      }
-
-      /* end point handling */
-      if ((mlib_addr) dp <= (mlib_addr) dend) {
-        emask = vis_edge16(dp, dend);
-        sd0 = *sp++;
-        sd1 = *sp++;
-        CHANNELEXTRACT_S16_21R(sd0, sd1, dd0);
-        vis_pst_16(dd0, dp++, emask);
-      }
-    }
-    else {
-      vis_alignaddr((void *)0, off);
-
-      /* generate edge mask for the start point */
-      emask = vis_edge16(da, dend);
-
-      if (off < 0) {
-        /* load 16 bytes */
-        sd2 = *sp++;
-        sd3 = *sp++;
-
-        /* extract and store 8 bytes */
-        CHANNELEXTRACT_S16_21R(sd2, sd3, dd1);
-        vis_pst_16(vis_faligndata(dd1, dd1), dp++, emask);
-      }
-      else {
-        /* load 32 bytes */
-        sd0 = *sp++;
-        sd1 = *sp++;
-        sd2 = *sp++;
-        sd3 = *sp++;
-
-        /* extract and store 8 bytes */
-        CHANNELEXTRACT_S16_21R(sd0, sd1, dd0);
-        CHANNELEXTRACT_S16_21R(sd2, sd3, dd1);
-        vis_pst_16(vis_faligndata(dd0, dd1), dp++, emask);
-      }
-
-      if ((mlib_addr) dp <= (mlib_addr) dend2) {
-        n = ((mlib_u8 *) dend2 - (mlib_u8 *) dp) / 8 + 1;
-
-        /* 8-pixel column loop, emask not needed */
-#pragma pipeloop(0)
-        for (i = 0; i < n; i++) {
-          dd0 = dd1;
-          sd2 = *sp++;
-          sd3 = *sp++;
-          CHANNELEXTRACT_S16_21R(sd2, sd3, dd1);
-          *dp++ = vis_faligndata(dd0, dd1);
-        }
-      }
-
-      /* end point handling */
-      if ((mlib_addr) dp <= (mlib_addr) dend) {
-        emask = vis_edge16(dp, dend);
-        dd0 = dd1;
-        sd2 = *sp++;
-        sd3 = *sp++;
-        CHANNELEXTRACT_S16_21R(sd2, sd3, dd1);
-        vis_pst_16(vis_faligndata(dd0, dd1), dp++, emask);
-      }
-    }
-  }
-}
-
-/***************************************************************/
-void mlib_v_ImageChannelExtract_S16_21(const mlib_s16 *src,
-                                       mlib_s32       slb,
-                                       mlib_s16       *dst,
-                                       mlib_s32       dlb,
-                                       mlib_s32       xsize,
-                                       mlib_s32       ysize,
-                                       mlib_s32       cmask)
-{
-  mlib_s16 *sa, *da;
-  mlib_s16 *sl, *dl;
-  mlib_s32 j;
-
-  sa = sl = (void *)src;
-  da = dl = dst;
-
-  for (j = 0; j < ysize; j++) {
-    mlib_v_ImageChannelExtract_S16_21_D1(sa, da, xsize, cmask);
-    sa = sl = (mlib_s16 *) ((mlib_u8 *) sl + slb);
-    da = dl = (mlib_s16 *) ((mlib_u8 *) dl + dlb);
-  }
-}
-
-/***************************************************************/
-#define CHANNELEXTRACT_S16_31L(sd0, sd1, sd2, dd)               \
-  /* extract the left channel */                                \
-  sda = vis_fpmerge(vis_read_hi(sd0), vis_read_lo(sd1));        \
-  sdb = vis_fpmerge(vis_read_lo(sd0), vis_read_hi(sd2));        \
-  sdc = vis_fpmerge(vis_read_hi(sda), vis_read_lo(sdb));        \
-  dd  = vis_fpmerge(vis_read_hi(sdc), vis_read_lo(sdc))
-
-/***************************************************************/
-#define CHANNELEXTRACT_S16_31M(sd0, sd1, sd2, dd)               \
-  /* extract the middle channel */                              \
-  sda = vis_fpmerge(vis_read_hi(sd0), vis_read_lo(sd1));        \
-  sdb = vis_fpmerge(vis_read_hi(sd1), vis_read_lo(sd2));        \
-  sdc = vis_fpmerge(vis_read_lo(sda), vis_read_hi(sdb));        \
-  dd  = vis_fpmerge(vis_read_hi(sdc), vis_read_lo(sdc))
-
-/***************************************************************/
-#define CHANNELEXTRACT_S16_31R(sd0, sd1, sd2, dd)               \
-  /* extract the right channel */                               \
-  sda = vis_fpmerge(vis_read_lo(sd0), vis_read_hi(sd2));        \
-  sdb = vis_fpmerge(vis_read_hi(sd1), vis_read_lo(sd2));        \
-  sdc = vis_fpmerge(vis_read_hi(sda), vis_read_lo(sdb));        \
-  dd  = vis_fpmerge(vis_read_hi(sdc), vis_read_lo(sdc))
-
-/***************************************************************/
-void mlib_v_ImageChannelExtract_S16_31_A8D1X4(const mlib_s16 *src,
-                                              mlib_s16       *dst,
-                                              mlib_s32       dsize,
-                                              mlib_s32       cmask)
-{
-  mlib_d64 *sp, *dp;
-  mlib_d64 sd0, sd1, sd2;
-  mlib_d64 sda, sdb, sdc;
-  mlib_d64 dd;
-  mlib_s32 i;
-
-  sp = (mlib_d64 *) src;
-  dp = (mlib_d64 *) dst;
-
-  if (cmask == 4) {
-#pragma pipeloop(0)
-    for (i = 0; i < dsize / 4; i++) {
-      sd0 = *sp++;
-      sd1 = *sp++;
-      sd2 = *sp++;
-      CHANNELEXTRACT_S16_31L(sd0, sd1, sd2, dd);
-      *dp++ = dd;
-    }
-  }
-  else if (cmask == 2) {
-#pragma pipeloop(0)
-    for (i = 0; i < dsize / 4; i++) {
-      sd0 = *sp++;
-      sd1 = *sp++;
-      sd2 = *sp++;
-      CHANNELEXTRACT_S16_31M(sd0, sd1, sd2, dd);
-      *dp++ = dd;
-    }
-  }
-  else {
-#pragma pipeloop(0)
-    for (i = 0; i < dsize / 4; i++) {
-      sd0 = *sp++;
-      sd1 = *sp++;
-      sd2 = *sp++;
-      CHANNELEXTRACT_S16_31R(sd0, sd1, sd2, dd);
-      *dp++ = dd;
-    }
-  }
-}
-
-/***************************************************************/
-void mlib_v_ImageChannelExtract_S16_31_A8D2X4(const mlib_s16 *src,
-                                              mlib_s32       slb,
-                                              mlib_s16       *dst,
-                                              mlib_s32       dlb,
-                                              mlib_s32       xsize,
-                                              mlib_s32       ysize,
-                                              mlib_s32       cmask)
-{
-  mlib_d64 *sp, *dp;
-  mlib_d64 *sl, *dl;
-  mlib_d64 sd0, sd1, sd2;
-  mlib_d64 sda, sdb, sdc;
-  mlib_d64 dd;
-  mlib_s32 i, j;
-
-  sp = sl = (mlib_d64 *) src;
-  dp = dl = (mlib_d64 *) dst;
-
-  if (cmask == 4) {
-    for (j = 0; j < ysize; j++) {
-#pragma pipeloop(0)
-      for (i = 0; i < xsize / 4; i++) {
-        sd0 = *sp++;
-        sd1 = *sp++;
-        sd2 = *sp++;
-        CHANNELEXTRACT_S16_31L(sd0, sd1, sd2, dd);
-        *dp++ = dd;
-      }
-
-      sp = sl = (mlib_d64 *) ((mlib_u8 *) sl + slb);
-      dp = dl = (mlib_d64 *) ((mlib_u8 *) dl + dlb);
-    }
-  }
-  else if (cmask == 2) {
-    for (j = 0; j < ysize; j++) {
-#pragma pipeloop(0)
-      for (i = 0; i < xsize / 4; i++) {
-        sd0 = *sp++;
-        sd1 = *sp++;
-        sd2 = *sp++;
-        CHANNELEXTRACT_S16_31M(sd0, sd1, sd2, dd);
-        *dp++ = dd;
-      }
-
-      sp = sl = (mlib_d64 *) ((mlib_u8 *) sl + slb);
-      dp = dl = (mlib_d64 *) ((mlib_u8 *) dl + dlb);
-    }
-  }
-  else {
-    for (j = 0; j < ysize; j++) {
-#pragma pipeloop(0)
-      for (i = 0; i < xsize / 4; i++) {
-        sd0 = *sp++;
-        sd1 = *sp++;
-        sd2 = *sp++;
-        CHANNELEXTRACT_S16_31R(sd0, sd1, sd2, dd);
-        *dp++ = dd;
-      }
-
-      sp = sl = (mlib_d64 *) ((mlib_u8 *) sl + slb);
-      dp = dl = (mlib_d64 *) ((mlib_u8 *) dl + dlb);
-    }
-  }
-}
-
-/***************************************************************/
-void mlib_v_ImageChannelExtract_S16_31_D1(const mlib_s16 *src,
-                                          mlib_s16       *dst,
-                                          mlib_s32       dsize,
-                                          mlib_s32       cmask)
-{
-  mlib_s16 *sa, *da;
-  mlib_s16 *dend, *dend2;                             /* end points in dst */
-  mlib_d64 *dp;                                       /* 8-byte aligned start points in dst */
-  mlib_d64 *sp;                                       /* 8-byte aligned start point in src */
-  mlib_d64 sd0, sd1, sd2;                             /* 8-byte source data */
-  mlib_d64 sd3, sd4, sd5;
-  mlib_d64 sda, sdb, sdc;
-  mlib_d64 dd0, dd1;
-  mlib_s32 soff;                                      /* offset of address in src */
-  mlib_s32 doff;                                      /* offset of address in dst */
-  mlib_s32 off;                                       /* offset of src over dst */
-  mlib_s32 emask;                                     /* edge mask */
-  mlib_s32 i, n;
-
-  sa = (void *)src;
-  da = dst;
-
-  /* prepare the source address */
-  sp = (mlib_d64 *) ((mlib_addr) sa & (~7));
-  soff = ((mlib_addr) sa & 7);
-
-  /* prepare the destination addresses */
-  dp = (mlib_d64 *) ((mlib_addr) da & (~7));
-  doff = ((mlib_addr) da & 7);
-  dend = da + dsize - 1;
-  dend2 = dend - 3;
-
-  /* calculate the src's offset over dst */
-  if (cmask == 4) {
-    off = (soff / 6) * 2 - doff;
-  }
-  else if (cmask == 2) {
-    off = ((soff + 2) / 6) * 2 - doff;
-  }
-  else {
-    off = ((soff + 4) / 6) * 2 - doff;
-  }
-
-  if (((cmask == 4) && (soff % 6 == 0)) ||
-      ((cmask == 2) && (soff % 6 == 4)) ||
-      ((cmask == 1) && (soff % 6 == 2))) { /* extract left channel */
-
-    if (off == 0) {                         /* src and dst have same alignment */
-
-      /* generate edge mask for the start point */
-      emask = vis_edge16(da, dend);
-
-      /* load 16 bytes */
-      sd0 = *sp++;
-      sd1 = *sp++;
-      sd2 = *sp++;
-
-      /* extract, including some garbage at the start point */
-      CHANNELEXTRACT_S16_31L(sd0, sd1, sd2, dd0);
-
-      /* store 8 bytes result */
-      vis_pst_16(dd0, dp++, emask);
-
-      if ((mlib_addr) dp <= (mlib_addr) dend2) {
-        n = ((mlib_u8 *) dend2 - (mlib_u8 *) dp) / 8 + 1;
-
-        /* 8-pixel column loop, emask not needed */
-#pragma pipeloop(0)
-        for (i = 0; i < n; i++) {
-          sd0 = *sp++;
-          sd1 = *sp++;
-          sd2 = *sp++;
-          CHANNELEXTRACT_S16_31L(sd0, sd1, sd2, dd0);
-          *dp++ = dd0;
-        }
-      }
-
-      /* end point handling */
-      if ((mlib_addr) dp <= (mlib_addr) dend) {
-        emask = vis_edge16(dp, dend);
-        sd0 = *sp++;
-        sd1 = *sp++;
-        sd2 = *sp++;
-        CHANNELEXTRACT_S16_31L(sd0, sd1, sd2, dd0);
-        vis_pst_16(dd0, dp++, emask);
-      }
-    }
-    else {
-      vis_alignaddr((void *)0, off);
-
-      /* generate edge mask for the start point */
-      emask = vis_edge16(da, dend);
-
-      if (off < 0) {
-        /* load 24 bytes */
-        sd3 = *sp++;
-        sd4 = *sp++;
-        sd5 = *sp++;
-
-        /* extract and store 8 bytes */
-        CHANNELEXTRACT_S16_31L(sd3, sd4, sd5, dd1);
-        vis_pst_16(vis_faligndata(dd1, dd1), dp++, emask);
-      }
-      else {
-        /* load 48 bytes */
-        sd0 = *sp++;
-        sd1 = *sp++;
-        sd2 = *sp++;
-        sd3 = *sp++;
-        sd4 = *sp++;
-        sd5 = *sp++;
-
-        /* extract and store 8 bytes */
-        CHANNELEXTRACT_S16_31L(sd0, sd1, sd2, dd0);
-        CHANNELEXTRACT_S16_31L(sd3, sd4, sd5, dd1);
-        vis_pst_16(vis_faligndata(dd0, dd1), dp++, emask);
-      }
-
-      if ((mlib_addr) dp <= (mlib_addr) dend2) {
-        n = ((mlib_u8 *) dend2 - (mlib_u8 *) dp) / 8 + 1;
-
-        /* 8-pixel column loop, emask not needed */
-#pragma pipeloop(0)
-        for (i = 0; i < n; i++) {
-          dd0 = dd1;
-          sd3 = *sp++;
-          sd4 = *sp++;
-          sd5 = *sp++;
-          CHANNELEXTRACT_S16_31L(sd3, sd4, sd5, dd1);
-          *dp++ = vis_faligndata(dd0, dd1);
-        }
-      }
-
-      /* end point handling */
-      if ((mlib_addr) dp <= (mlib_addr) dend) {
-        emask = vis_edge16(dp, dend);
-        dd0 = dd1;
-        sd3 = *sp++;
-        sd4 = *sp++;
-        sd5 = *sp++;
-        CHANNELEXTRACT_S16_31L(sd3, sd4, sd5, dd1);
-        vis_pst_16(vis_faligndata(dd0, dd1), dp++, emask);
-      }
-    }
-  }
-  else if (((cmask == 4) && (soff % 6 == 2)) ||
-           ((cmask == 2) && (soff % 6 == 0)) ||
-           ((cmask == 1) && (soff % 6 == 4))) {
-    /* extract middle channel */
-
-    if (off == 0) {                         /* src and dst have same alignment */
-
-      /* generate edge mask for the start point */
-      emask = vis_edge16(da, dend);
-
-      /* load 16 bytes */
-      sd0 = *sp++;
-      sd1 = *sp++;
-      sd2 = *sp++;
-
-      /* extract, including some garbage at the start point */
-      CHANNELEXTRACT_S16_31M(sd0, sd1, sd2, dd0);
-
-      /* store 8 bytes result */
-      vis_pst_16(dd0, dp++, emask);
-
-      if ((mlib_addr) dp <= (mlib_addr) dend2) {
-        n = ((mlib_u8 *) dend2 - (mlib_u8 *) dp) / 8 + 1;
-
-        /* 8-pixel column loop, emask not needed */
-#pragma pipeloop(0)
-        for (i = 0; i < n; i++) {
-          sd0 = *sp++;
-          sd1 = *sp++;
-          sd2 = *sp++;
-          CHANNELEXTRACT_S16_31M(sd0, sd1, sd2, dd0);
-          *dp++ = dd0;
-        }
-      }
-
-      /* end point handling */
-      if ((mlib_addr) dp <= (mlib_addr) dend) {
-        emask = vis_edge16(dp, dend);
-        sd0 = *sp++;
-        sd1 = *sp++;
-        sd2 = *sp++;
-        CHANNELEXTRACT_S16_31M(sd0, sd1, sd2, dd0);
-        vis_pst_16(dd0, dp++, emask);
-      }
-    }
-    else {
-      vis_alignaddr((void *)0, off);
-
-      /* generate edge mask for the start point */
-      emask = vis_edge16(da, dend);
-
-      if (off < 0) {
-        /* load 24 bytes */
-        sd3 = *sp++;
-        sd4 = *sp++;
-        sd5 = *sp++;
-
-        /* extract and store 8 bytes */
-        CHANNELEXTRACT_S16_31M(sd3, sd4, sd5, dd1);
-        vis_pst_16(vis_faligndata(dd1, dd1), dp++, emask);
-      }
-      else {
-        /* load 48 bytes */
-        sd0 = *sp++;
-        sd1 = *sp++;
-        sd2 = *sp++;
-        sd3 = *sp++;
-        sd4 = *sp++;
-        sd5 = *sp++;
-
-        /* extract and store 8 bytes */
-        CHANNELEXTRACT_S16_31M(sd0, sd1, sd2, dd0);
-        CHANNELEXTRACT_S16_31M(sd3, sd4, sd5, dd1);
-        vis_pst_16(vis_faligndata(dd0, dd1), dp++, emask);
-      }
-
-      if ((mlib_addr) dp <= (mlib_addr) dend2) {
-        n = ((mlib_u8 *) dend2 - (mlib_u8 *) dp) / 8 + 1;
-
-        /* 8-pixel column loop, emask not needed */
-#pragma pipeloop(0)
-        for (i = 0; i < n; i++) {
-          dd0 = dd1;
-          sd3 = *sp++;
-          sd4 = *sp++;
-          sd5 = *sp++;
-          CHANNELEXTRACT_S16_31M(sd3, sd4, sd5, dd1);
-          *dp++ = vis_faligndata(dd0, dd1);
-        }
-      }
-
-      /* end point handling */
-      if ((mlib_addr) dp <= (mlib_addr) dend) {
-        emask = vis_edge16(dp, dend);
-        dd0 = dd1;
-        sd3 = *sp++;
-        sd4 = *sp++;
-        sd5 = *sp++;
-        CHANNELEXTRACT_S16_31M(sd3, sd4, sd5, dd1);
-        vis_pst_16(vis_faligndata(dd0, dd1), dp++, emask);
-      }
-    }
-  }
-  else {                                    /* extract right channel */
-
-    if (off == 0) {                         /* src and dst have same alignment */
-
-      /* generate edge mask for the start point */
-      emask = vis_edge16(da, dend);
-
-      /* load 16 bytes */
-      sd0 = *sp++;
-      sd1 = *sp++;
-      sd2 = *sp++;
-
-      /* extract, including some garbage at the start point */
-      CHANNELEXTRACT_S16_31R(sd0, sd1, sd2, dd0);
-
-      /* store 8 bytes result */
-      vis_pst_16(dd0, dp++, emask);
-
-      if ((mlib_addr) dp <= (mlib_addr) dend2) {
-        n = ((mlib_u8 *) dend2 - (mlib_u8 *) dp) / 8 + 1;
-
-        /* 8-pixel column loop, emask not needed */
-#pragma pipeloop(0)
-        for (i = 0; i < n; i++) {
-          sd0 = *sp++;
-          sd1 = *sp++;
-          sd2 = *sp++;
-          CHANNELEXTRACT_S16_31R(sd0, sd1, sd2, dd0);
-          *dp++ = dd0;
-        }
-      }
-
-      /* end point handling */
-      if ((mlib_addr) dp <= (mlib_addr) dend) {
-        emask = vis_edge16(dp, dend);
-        sd0 = *sp++;
-        sd1 = *sp++;
-        sd2 = *sp++;
-        CHANNELEXTRACT_S16_31R(sd0, sd1, sd2, dd0);
-        vis_pst_16(dd0, dp++, emask);
-      }
-    }
-    else {
-      vis_alignaddr((void *)0, off);
-
-      /* generate edge mask for the start point */
-      emask = vis_edge16(da, dend);
-
-      if (off < 0) {
-        /* load 24 bytes */
-        sd3 = *sp++;
-        sd4 = *sp++;
-        sd5 = *sp++;
-
-        /* extract and store 8 bytes */
-        CHANNELEXTRACT_S16_31R(sd3, sd4, sd5, dd1);
-        vis_pst_16(vis_faligndata(dd1, dd1), dp++, emask);
-      }
-      else {
-        /* load 48 bytes */
-        sd0 = *sp++;
-        sd1 = *sp++;
-        sd2 = *sp++;
-        sd3 = *sp++;
-        sd4 = *sp++;
-        sd5 = *sp++;
-
-        /* extract and store 8 bytes */
-        CHANNELEXTRACT_S16_31R(sd0, sd1, sd2, dd0);
-        CHANNELEXTRACT_S16_31R(sd3, sd4, sd5, dd1);
-        vis_pst_16(vis_faligndata(dd0, dd1), dp++, emask);
-      }
-
-      if ((mlib_addr) dp <= (mlib_addr) dend2) {
-        n = ((mlib_u8 *) dend2 - (mlib_u8 *) dp) / 8 + 1;
-
-        /* 8-pixel column loop, emask not needed */
-#pragma pipeloop(0)
-        for (i = 0; i < n; i++) {
-          dd0 = dd1;
-          sd3 = *sp++;
-          sd4 = *sp++;
-          sd5 = *sp++;
-          CHANNELEXTRACT_S16_31R(sd3, sd4, sd5, dd1);
-          *dp++ = vis_faligndata(dd0, dd1);
-        }
-      }
-
-      /* end point handling */
-      if ((mlib_addr) dp <= (mlib_addr) dend) {
-        emask = vis_edge16(dp, dend);
-        dd0 = dd1;
-        sd3 = *sp++;
-        sd4 = *sp++;
-        sd5 = *sp++;
-        CHANNELEXTRACT_S16_31R(sd3, sd4, sd5, dd1);
-        vis_pst_16(vis_faligndata(dd0, dd1), dp++, emask);
-      }
-    }
-  }
-}
-
-/***************************************************************/
-void mlib_v_ImageChannelExtract_S16_31(const mlib_s16 *src,
-                                       mlib_s32       slb,
-                                       mlib_s16       *dst,
-                                       mlib_s32       dlb,
-                                       mlib_s32       xsize,
-                                       mlib_s32       ysize,
-                                       mlib_s32       cmask)
-{
-  mlib_s16 *sa, *da;
-  mlib_s16 *sl, *dl;
-  mlib_s32 j;
-
-  sa = sl = (void *)src;
-  da = dl = dst;
-
-  for (j = 0; j < ysize; j++) {
-    mlib_v_ImageChannelExtract_S16_31_D1(sa, da, xsize, cmask);
-    sa = sl = (mlib_s16 *) ((mlib_u8 *) sl + slb);
-    da = dl = (mlib_s16 *) ((mlib_u8 *) dl + dlb);
-  }
-}
-
-/***************************************************************/
-#define CHANNELEXTRACT_S16_41L(sd0, sd1,  sd2, sd3, dd)         \
-  /* extract the left channel */                                \
-  sda = vis_fpmerge(vis_read_hi(sd0), vis_read_hi(sd2));        \
-  sdb = vis_fpmerge(vis_read_hi(sd1), vis_read_hi(sd3));        \
-  sdc = vis_fpmerge(vis_read_hi(sda), vis_read_hi(sdb));        \
-  dd  = vis_fpmerge(vis_read_hi(sdc), vis_read_lo(sdc))
-
-/***************************************************************/
-#define CHANNELEXTRACT_S16_41ML(sd0, sd1, sd2, sd3, dd)         \
-  /* extract the middle left channel */                         \
-  sda = vis_fpmerge(vis_read_hi(sd0), vis_read_hi(sd2));        \
-  sdb = vis_fpmerge(vis_read_hi(sd1), vis_read_hi(sd3));        \
-  sdc = vis_fpmerge(vis_read_lo(sda), vis_read_lo(sdb));        \
-  dd  = vis_fpmerge(vis_read_hi(sdc), vis_read_lo(sdc))
-
-/***************************************************************/
-#define CHANNELEXTRACT_S16_41MR(sd0, sd1, sd2, sd3, dd)         \
-  /* extract the middle right channel */                        \
-  sda = vis_fpmerge(vis_read_lo(sd0), vis_read_lo(sd2));        \
-  sdb = vis_fpmerge(vis_read_lo(sd1), vis_read_lo(sd3));        \
-  sdc = vis_fpmerge(vis_read_hi(sda), vis_read_hi(sdb));        \
-  dd  = vis_fpmerge(vis_read_hi(sdc), vis_read_lo(sdc))
-
-/***************************************************************/
-#define CHANNELEXTRACT_S16_41R(sd0, sd1, sd2, sd3, dd)          \
-  /* extract the right channel */                               \
-  sda = vis_fpmerge(vis_read_lo(sd0), vis_read_lo(sd2));        \
-  sdb = vis_fpmerge(vis_read_lo(sd1), vis_read_lo(sd3));        \
-  sdc = vis_fpmerge(vis_read_lo(sda), vis_read_lo(sdb));        \
-  dd  = vis_fpmerge(vis_read_hi(sdc), vis_read_lo(sdc))
-
-/***************************************************************/
-void mlib_v_ImageChannelExtract_S16_41_A8D1X4(const mlib_s16 *src,
-                                              mlib_s16       *dst,
-                                              mlib_s32       dsize,
-                                              mlib_s32       cmask)
-{
-  mlib_d64 *sp, *dp;
-  mlib_d64 sd0, sd1, sd2, sd3;
-  mlib_d64 sda, sdb, sdc;
-  mlib_d64 dd;
-  mlib_s32 i;
-
-  sp = (mlib_d64 *) src;
-  dp = (mlib_d64 *) dst;
-
-  if (cmask == 8) {
-#pragma pipeloop(0)
-    for (i = 0; i < dsize / 4; i++) {
-      sd0 = *sp++;
-      sd1 = *sp++;
-      sd2 = *sp++;
-      sd3 = *sp++;
-      CHANNELEXTRACT_S16_41L(sd0, sd1, sd2, sd3, dd);
-      *dp++ = dd;
-    }
-  }
-  else if (cmask == 4) {
-#pragma pipeloop(0)
-    for (i = 0; i < dsize / 4; i++) {
-      sd0 = *sp++;
-      sd1 = *sp++;
-      sd2 = *sp++;
-      sd3 = *sp++;
-      CHANNELEXTRACT_S16_41ML(sd0, sd1, sd2, sd3, dd);
-      *dp++ = dd;
-    }
-  }
-  else if (cmask == 2) {
-#pragma pipeloop(0)
-    for (i = 0; i < dsize / 4; i++) {
-      sd0 = *sp++;
-      sd1 = *sp++;
-      sd2 = *sp++;
-      sd3 = *sp++;
-      CHANNELEXTRACT_S16_41MR(sd0, sd1, sd2, sd3, dd);
-      *dp++ = dd;
-    }
-  }
-  else {
-#pragma pipeloop(0)
-    for (i = 0; i < dsize / 4; i++) {
-      sd0 = *sp++;
-      sd1 = *sp++;
-      sd2 = *sp++;
-      sd3 = *sp++;
-      CHANNELEXTRACT_S16_41R(sd0, sd1, sd2, sd3, dd);
-      *dp++ = dd;
-    }
-  }
-}
-
-/***************************************************************/
-void mlib_v_ImageChannelExtract_S16_41_A8D2X4(const mlib_s16 *src,
-                                              mlib_s32       slb,
-                                              mlib_s16       *dst,
-                                              mlib_s32       dlb,
-                                              mlib_s32       xsize,
-                                              mlib_s32       ysize,
-                                              mlib_s32       cmask)
-{
-  mlib_d64 *sp, *dp;
-  mlib_d64 *sl, *dl;
-  mlib_d64 sd0, sd1, sd2, sd3;
-  mlib_d64 sda, sdb, sdc;
-  mlib_d64 dd;
-  mlib_s32 i, j;
-
-  sp = sl = (mlib_d64 *) src;
-  dp = dl = (mlib_d64 *) dst;
-
-  if (cmask == 8) {
-    for (j = 0; j < ysize; j++) {
-#pragma pipeloop(0)
-      for (i = 0; i < xsize / 4; i++) {
-        sd0 = *sp++;
-        sd1 = *sp++;
-        sd2 = *sp++;
-        sd3 = *sp++;
-        CHANNELEXTRACT_S16_41L(sd0, sd1, sd2, sd3, dd);
-        *dp++ = dd;
-      }
-
-      sp = sl = (mlib_d64 *) ((mlib_u8 *) sl + slb);
-      dp = dl = (mlib_d64 *) ((mlib_u8 *) dl + dlb);
-    }
-  }
-  else if (cmask == 4) {
-    for (j = 0; j < ysize; j++) {
-#pragma pipeloop(0)
-      for (i = 0; i < xsize / 4; i++) {
-        sd0 = *sp++;
-        sd1 = *sp++;
-        sd2 = *sp++;
-        sd3 = *sp++;
-        CHANNELEXTRACT_S16_41ML(sd0, sd1, sd2, sd3, dd);
-        *dp++ = dd;
-      }
-
-      sp = sl = (mlib_d64 *) ((mlib_u8 *) sl + slb);
-      dp = dl = (mlib_d64 *) ((mlib_u8 *) dl + dlb);
-    }
-  }
-  else if (cmask == 2) {
-    for (j = 0; j < ysize; j++) {
-#pragma pipeloop(0)
-      for (i = 0; i < xsize / 4; i++) {
-        sd0 = *sp++;
-        sd1 = *sp++;
-        sd2 = *sp++;
-        sd3 = *sp++;
-        CHANNELEXTRACT_S16_41MR(sd0, sd1, sd2, sd3, dd);
-        *dp++ = dd;
-      }
-
-      sp = sl = (mlib_d64 *) ((mlib_u8 *) sl + slb);
-      dp = dl = (mlib_d64 *) ((mlib_u8 *) dl + dlb);
-    }
-  }
-  else {
-    for (j = 0; j < ysize; j++) {
-#pragma pipeloop(0)
-      for (i = 0; i < xsize / 4; i++) {
-        sd0 = *sp++;
-        sd1 = *sp++;
-        sd2 = *sp++;
-        sd3 = *sp++;
-        CHANNELEXTRACT_S16_41R(sd0, sd1, sd2, sd3, dd);
-        *dp++ = dd;
-      }
-
-      sp = sl = (mlib_d64 *) ((mlib_u8 *) sl + slb);
-      dp = dl = (mlib_d64 *) ((mlib_u8 *) dl + dlb);
-    }
-  }
-}
-
-/***************************************************************/
-void mlib_v_ImageChannelExtract_S16_41_D1(const mlib_s16 *src,
-                                          mlib_s16       *dst,
-                                          mlib_s32       dsize,
-                                          mlib_s32       cmask)
-{
-  mlib_s16 *sa, *da;
-  mlib_s16 *dend, *dend2;                             /* end points in dst */
-  mlib_d64 *dp;                                       /* 8-byte aligned start points in dst */
-  mlib_d64 *sp;                                       /* 8-byte aligned start point in src */
-  mlib_d64 sd0, sd1, sd2, sd3;                        /* 8-byte source data */
-  mlib_d64 sd4, sd5, sd6, sd7;
-  mlib_d64 sda, sdb, sdc;
-  mlib_d64 dd0, dd1;
-  mlib_s32 soff;                                      /* offset of address in src */
-  mlib_s32 doff;                                      /* offset of address in dst */
-  mlib_s32 off;                                       /* offset of src over dst */
-  mlib_s32 emask;                                     /* edge mask */
-  mlib_s32 i, n;
-
-  sa = (void *)src;
-  da = dst;
-
-  /* prepare the source address */
-  sp = (mlib_d64 *) ((mlib_addr) sa & (~7));
-  soff = ((mlib_addr) sa & 7);
-
-  /* prepare the destination addresses */
-  dp = (mlib_d64 *) ((mlib_addr) da & (~7));
-  doff = ((mlib_addr) da & 7);
-  dend = da + dsize - 1;
-  dend2 = dend - 3;
-
-  /* calculate the src's offset over dst */
-  if (cmask == 8) {
-    off = (soff / 8) * 2 - doff;
-  }
-  else if (cmask == 4) {
-    off = ((soff + 2) / 8) * 2 - doff;
-  }
-  else if (cmask == 2) {
-    off = ((soff + 4) / 8) * 2 - doff;
-  }
-  else {
-    off = ((soff + 6) / 8) * 2 - doff;
-  }
-
-  if (((cmask == 8) && (soff == 0)) ||
-      ((cmask == 4) && (soff == 6)) ||
-      ((cmask == 2) && (soff == 4)) ||
-      ((cmask == 1) && (soff == 2))) { /* extract left channel */
-
-    if (off == 0) {                         /* src and dst have same alignment */
-
-      /* generate edge mask for the start point */
-      emask = vis_edge16(da, dend);
-
-      /* load 16 bytes */
-      sd0 = *sp++;
-      sd1 = *sp++;
-      sd2 = *sp++;
-      sd3 = *sp++;
-
-      /* extract, including some garbage at the start point */
-      CHANNELEXTRACT_S16_41L(sd0, sd1, sd2, sd3, dd0);
-
-      /* store 8 bytes result */
-      vis_pst_16(dd0, dp++, emask);
-
-      if ((mlib_addr) dp <= (mlib_addr) dend2) {
-        n = ((mlib_u8 *) dend2 - (mlib_u8 *) dp) / 8 + 1;
-
-        /* 8-pixel column loop, emask not needed */
-#pragma pipeloop(0)
-        for (i = 0; i < n; i++) {
-          sd0 = *sp++;
-          sd1 = *sp++;
-          sd2 = *sp++;
-          sd3 = *sp++;
-          CHANNELEXTRACT_S16_41L(sd0, sd1, sd2, sd3, dd0);
-          *dp++ = dd0;
-        }
-      }
-
-      /* end point handling */
-      if ((mlib_addr) dp <= (mlib_addr) dend) {
-        emask = vis_edge16(dp, dend);
-        sd0 = *sp++;
-        sd1 = *sp++;
-        sd2 = *sp++;
-        sd3 = *sp++;
-        CHANNELEXTRACT_S16_41L(sd0, sd1, sd2, sd3, dd0);
-        vis_pst_16(dd0, dp++, emask);
-      }
-    }
-    else {
-      vis_alignaddr((void *)0, off);
-
-      /* generate edge mask for the start point */
-      emask = vis_edge16(da, dend);
-
-      if (off < 0) {
-        /* load 24 bytes */
-        sd4 = *sp++;
-        sd5 = *sp++;
-        sd6 = *sp++;
-        sd7 = *sp++;
-
-        /* extract and store 8 bytes */
-        CHANNELEXTRACT_S16_41L(sd4, sd5, sd6, sd7, dd1);
-        vis_pst_16(vis_faligndata(dd1, dd1), dp++, emask);
-      }
-      else {
-        /* load 48 bytes */
-        sd0 = *sp++;
-        sd1 = *sp++;
-        sd2 = *sp++;
-        sd3 = *sp++;
-        sd4 = *sp++;
-        sd5 = *sp++;
-        sd6 = *sp++;
-        sd7 = *sp++;
-
-        /* extract and store 8 bytes */
-        CHANNELEXTRACT_S16_41L(sd0, sd1, sd2, sd3, dd0);
-        CHANNELEXTRACT_S16_41L(sd4, sd5, sd6, sd7, dd1);
-        vis_pst_16(vis_faligndata(dd0, dd1), dp++, emask);
-      }
-
-      if ((mlib_addr) dp <= (mlib_addr) dend2) {
-        n = ((mlib_u8 *) dend2 - (mlib_u8 *) dp) / 8 + 1;
-
-        /* 8-pixel column loop, emask not needed */
-#pragma pipeloop(0)
-        for (i = 0; i < n; i++) {
-          dd0 = dd1;
-          sd4 = *sp++;
-          sd5 = *sp++;
-          sd6 = *sp++;
-          sd7 = *sp++;
-          CHANNELEXTRACT_S16_41L(sd4, sd5, sd6, sd7, dd1);
-          *dp++ = vis_faligndata(dd0, dd1);
-        }
-      }
-
-      /* end point handling */
-      if ((mlib_addr) dp <= (mlib_addr) dend) {
-        emask = vis_edge16(dp, dend);
-        dd0 = dd1;
-        sd4 = *sp++;
-        sd5 = *sp++;
-        sd6 = *sp++;
-        sd7 = *sp++;
-        CHANNELEXTRACT_S16_41L(sd4, sd5, sd6, sd7, dd1);
-        vis_pst_16(vis_faligndata(dd0, dd1), dp++, emask);
-      }
-    }
-  }
-  else if (((cmask == 8) && (soff == 2)) ||
-           ((cmask == 4) && (soff == 0)) ||
-           ((cmask == 2) && (soff == 6)) ||
-           ((cmask == 1) && (soff == 4))) { /* extract middle left channel */
-
-    if (off == 0) {                         /* src and dst have same alignment */
-
-      /* generate edge mask for the start point */
-      emask = vis_edge16(da, dend);
-
-      /* load 16 bytes */
-      sd0 = *sp++;
-      sd1 = *sp++;
-      sd2 = *sp++;
-      sd3 = *sp++;
-
-      /* extract, including some garbage at the start point */
-      CHANNELEXTRACT_S16_41ML(sd0, sd1, sd2, sd3, dd0);
-
-      /* store 8 bytes result */
-      vis_pst_16(dd0, dp++, emask);
-
-      if ((mlib_addr) dp <= (mlib_addr) dend2) {
-        n = ((mlib_u8 *) dend2 - (mlib_u8 *) dp) / 8 + 1;
-
-        /* 8-pixel column loop, emask not needed */
-#pragma pipeloop(0)
-        for (i = 0; i < n; i++) {
-          sd0 = *sp++;
-          sd1 = *sp++;
-          sd2 = *sp++;
-          sd3 = *sp++;
-          CHANNELEXTRACT_S16_41ML(sd0, sd1, sd2, sd3, dd0);
-          *dp++ = dd0;
-        }
-      }
-
-      /* end point handling */
-      if ((mlib_addr) dp <= (mlib_addr) dend) {
-        emask = vis_edge16(dp, dend);
-        sd0 = *sp++;
-        sd1 = *sp++;
-        sd2 = *sp++;
-        sd3 = *sp++;
-        CHANNELEXTRACT_S16_41ML(sd0, sd1, sd2, sd3, dd0);
-        vis_pst_16(dd0, dp++, emask);
-      }
-    }
-    else {
-      vis_alignaddr((void *)0, off);
-
-      /* generate edge mask for the start point */
-      emask = vis_edge16(da, dend);
-
-      if (off < 0) {
-        /* load 24 bytes */
-        sd4 = *sp++;
-        sd5 = *sp++;
-        sd6 = *sp++;
-        sd7 = *sp++;
-
-        /* extract and store 8 bytes */
-        CHANNELEXTRACT_S16_41ML(sd4, sd5, sd6, sd7, dd1);
-        vis_pst_16(vis_faligndata(dd1, dd1), dp++, emask);
-      }
-      else {
-        /* load 48 bytes */
-        sd0 = *sp++;
-        sd1 = *sp++;
-        sd2 = *sp++;
-        sd3 = *sp++;
-        sd4 = *sp++;
-        sd5 = *sp++;
-        sd6 = *sp++;
-        sd7 = *sp++;
-
-        /* extract and store 8 bytes */
-        CHANNELEXTRACT_S16_41ML(sd0, sd1, sd2, sd3, dd0);
-        CHANNELEXTRACT_S16_41ML(sd4, sd5, sd6, sd7, dd1);
-        vis_pst_16(vis_faligndata(dd0, dd1), dp++, emask);
-      }
-
-      if ((mlib_addr) dp <= (mlib_addr) dend2) {
-        n = ((mlib_u8 *) dend2 - (mlib_u8 *) dp) / 8 + 1;
-
-        /* 8-pixel column loop, emask not needed */
-#pragma pipeloop(0)
-        for (i = 0; i < n; i++) {
-          dd0 = dd1;
-          sd4 = *sp++;
-          sd5 = *sp++;
-          sd6 = *sp++;
-          sd7 = *sp++;
-          CHANNELEXTRACT_S16_41ML(sd4, sd5, sd6, sd7, dd1);
-          *dp++ = vis_faligndata(dd0, dd1);
-        }
-      }
-
-      /* end point handling */
-      if ((mlib_addr) dp <= (mlib_addr) dend) {
-        emask = vis_edge16(dp, dend);
-        dd0 = dd1;
-        sd4 = *sp++;
-        sd5 = *sp++;
-        sd6 = *sp++;
-        sd7 = *sp++;
-        CHANNELEXTRACT_S16_41ML(sd4, sd5, sd6, sd7, dd1);
-        vis_pst_16(vis_faligndata(dd0, dd1), dp++, emask);
-      }
-    }
-  }
-  else if (((cmask == 8) && (soff == 4)) ||
-           ((cmask == 4) && (soff == 2)) ||
-           ((cmask == 2) && (soff == 0)) ||
-           ((cmask == 1) && (soff == 6))) { /* extract middle right channel */
-
-    if (off == 0) {                         /* src and dst have same alignment */
-
-      /* generate edge mask for the start point */
-      emask = vis_edge16(da, dend);
-
-      /* load 16 bytes */
-      sd0 = *sp++;
-      sd1 = *sp++;
-      sd2 = *sp++;
-      sd3 = *sp++;
-
-      /* extract, including some garbage at the start point */
-      CHANNELEXTRACT_S16_41MR(sd0, sd1, sd2, sd3, dd0);
-
-      /* store 8 bytes result */
-      vis_pst_16(dd0, dp++, emask);
-
-      if ((mlib_addr) dp <= (mlib_addr) dend2) {
-        n = ((mlib_u8 *) dend2 - (mlib_u8 *) dp) / 8 + 1;
-
-        /* 8-pixel column loop, emask not needed */
-#pragma pipeloop(0)
-        for (i = 0; i < n; i++) {
-          sd0 = *sp++;
-          sd1 = *sp++;
-          sd2 = *sp++;
-          sd3 = *sp++;
-          CHANNELEXTRACT_S16_41MR(sd0, sd1, sd2, sd3, dd0);
-          *dp++ = dd0;
-        }
-      }
-
-      /* end point handling */
-      if ((mlib_addr) dp <= (mlib_addr) dend) {
-        emask = vis_edge16(dp, dend);
-        sd0 = *sp++;
-        sd1 = *sp++;
-        sd2 = *sp++;
-        sd3 = *sp++;
-        CHANNELEXTRACT_S16_41MR(sd0, sd1, sd2, sd3, dd0);
-        vis_pst_16(dd0, dp++, emask);
-      }
-    }
-    else {
-      vis_alignaddr((void *)0, off);
-
-      /* generate edge mask for the start point */
-      emask = vis_edge16(da, dend);
-
-      if (off < 0) {
-        /* load 24 bytes */
-        sd4 = *sp++;
-        sd5 = *sp++;
-        sd6 = *sp++;
-        sd7 = *sp++;
-
-        /* extract and store 8 bytes */
-        CHANNELEXTRACT_S16_41MR(sd4, sd5, sd6, sd7, dd1);
-        vis_pst_16(vis_faligndata(dd1, dd1), dp++, emask);
-      }
-      else {
-        /* load 48 bytes */
-        sd0 = *sp++;
-        sd1 = *sp++;
-        sd2 = *sp++;
-        sd3 = *sp++;
-        sd4 = *sp++;
-        sd5 = *sp++;
-        sd6 = *sp++;
-        sd7 = *sp++;
-
-        /* extract and store 8 bytes */
-        CHANNELEXTRACT_S16_41MR(sd0, sd1, sd2, sd3, dd0);
-        CHANNELEXTRACT_S16_41MR(sd4, sd5, sd6, sd7, dd1);
-        vis_pst_16(vis_faligndata(dd0, dd1), dp++, emask);
-      }
-
-      if ((mlib_addr) dp <= (mlib_addr) dend2) {
-        n = ((mlib_u8 *) dend2 - (mlib_u8 *) dp) / 8 + 1;
-
-        /* 8-pixel column loop, emask not needed */
-#pragma pipeloop(0)
-        for (i = 0; i < n; i++) {
-          dd0 = dd1;
-          sd4 = *sp++;
-          sd5 = *sp++;
-          sd6 = *sp++;
-          sd7 = *sp++;
-          CHANNELEXTRACT_S16_41MR(sd4, sd5, sd6, sd7, dd1);
-          *dp++ = vis_faligndata(dd0, dd1);
-        }
-      }
-
-      /* end point handling */
-      if ((mlib_addr) dp <= (mlib_addr) dend) {
-        emask = vis_edge16(dp, dend);
-        dd0 = dd1;
-        sd4 = *sp++;
-        sd5 = *sp++;
-        sd6 = *sp++;
-        sd7 = *sp++;
-        CHANNELEXTRACT_S16_41MR(sd4, sd5, sd6, sd7, dd1);
-        vis_pst_16(vis_faligndata(dd0, dd1), dp++, emask);
-      }
-    }
-  }
-  else {                                    /* extract right channel */
-    if (off == 0) {                         /* src and dst have same alignment */
-
-      /* generate edge mask for the start point */
-      emask = vis_edge16(da, dend);
-
-      /* load 16 bytes */
-      sd0 = *sp++;
-      sd1 = *sp++;
-      sd2 = *sp++;
-      sd3 = *sp++;
-
-      /* extract, including some garbage at the start point */
-      CHANNELEXTRACT_S16_41R(sd0, sd1, sd2, sd3, dd0);
-
-      /* store 8 bytes result */
-      vis_pst_16(dd0, dp++, emask);
-
-      if ((mlib_addr) dp <= (mlib_addr) dend2) {
-        n = ((mlib_u8 *) dend2 - (mlib_u8 *) dp) / 8 + 1;
-
-        /* 8-pixel column loop, emask not needed */
-#pragma pipeloop(0)
-        for (i = 0; i < n; i++) {
-          sd0 = *sp++;
-          sd1 = *sp++;
-          sd2 = *sp++;
-          sd3 = *sp++;
-          CHANNELEXTRACT_S16_41R(sd0, sd1, sd2, sd3, dd0);
-          *dp++ = dd0;
-        }
-      }
-
-      /* end point handling */
-      if ((mlib_addr) dp <= (mlib_addr) dend) {
-        emask = vis_edge16(dp, dend);
-        sd0 = *sp++;
-        sd1 = *sp++;
-        sd2 = *sp++;
-        sd3 = *sp++;
-        CHANNELEXTRACT_S16_41R(sd0, sd1, sd2, sd3, dd0);
-        vis_pst_16(dd0, dp++, emask);
-      }
-    }
-    else {
-      vis_alignaddr((void *)0, off);
-
-      /* generate edge mask for the start point */
-      emask = vis_edge16(da, dend);
-
-      if (off < 0) {
-        /* load 24 bytes */
-        sd4 = *sp++;
-        sd5 = *sp++;
-        sd6 = *sp++;
-        sd7 = *sp++;
-
-        /* extract and store 8 bytes */
-        CHANNELEXTRACT_S16_41R(sd4, sd5, sd6, sd7, dd1);
-        vis_pst_16(vis_faligndata(dd1, dd1), dp++, emask);
-      }
-
-      if ((mlib_addr) dp <= (mlib_addr) dend2) {
-        n = ((mlib_u8 *) dend2 - (mlib_u8 *) dp) / 8 + 1;
-
-        /* 8-pixel column loop, emask not needed */
-#pragma pipeloop(0)
-        for (i = 0; i < n; i++) {
-          dd0 = dd1;
-          sd4 = *sp++;
-          sd5 = *sp++;
-          sd6 = *sp++;
-          sd7 = *sp++;
-          CHANNELEXTRACT_S16_41R(sd4, sd5, sd6, sd7, dd1);
-          *dp++ = vis_faligndata(dd0, dd1);
-        }
-      }
-
-      /* end point handling */
-      if ((mlib_addr) dp <= (mlib_addr) dend) {
-        emask = vis_edge16(dp, dend);
-        dd0 = dd1;
-        sd4 = *sp++;
-        sd5 = *sp++;
-        sd6 = *sp++;
-        sd7 = *sp++;
-        CHANNELEXTRACT_S16_41R(sd4, sd5, sd6, sd7, dd1);
-        vis_pst_16(vis_faligndata(dd0, dd1), dp++, emask);
-      }
-    }
-  }
-}
-
-/***************************************************************/
-void mlib_v_ImageChannelExtract_S16_41(const mlib_s16 *src,
-                                       mlib_s32       slb,
-                                       mlib_s16       *dst,
-                                       mlib_s32       dlb,
-                                       mlib_s32       xsize,
-                                       mlib_s32       ysize,
-                                       mlib_s32       cmask)
-{
-  mlib_s16 *sa, *da;
-  mlib_s16 *sl, *dl;
-  mlib_s32 j;
-
-  sa = sl = (void *)src;
-  da = dl = dst;
-  for (j = 0; j < ysize; j++) {
-    mlib_v_ImageChannelExtract_S16_41_D1(sa, da, xsize, cmask);
-    sa = sl = (mlib_s16 *) ((mlib_u8 *) sl + slb);
-    da = dl = (mlib_s16 *) ((mlib_u8 *) dl + dlb);
-  }
-}
-
-/***************************************************************/
--- a/jdk/src/java.desktop/unix/native/libmlib_image/mlib_v_ImageChannelExtract_43.c	Thu May 19 17:48:02 2016 +0000
+++ b/jdk/src/java.desktop/unix/native/libmlib_image/mlib_v_ImageChannelExtract_43.c	Thu May 19 19:46:20 2016 +0000
@@ -29,22 +29,8 @@
  * FILENAME: mlib_v_ImageChannelExtract_43.c
  *
  * FUNCTIONS
- *      mlib_v_ImageChannelExtract_U8_43R_A8D1X8
- *      mlib_v_ImageChannelExtract_U8_43R_A8D2X8
- *      mlib_v_ImageChannelExtract_U8_43R_D1
- *      mlib_v_ImageChannelExtract_U8_43R
- *      mlib_v_ImageChannelExtract_S16_43R_A8D1X4
- *      mlib_v_ImageChannelExtract_S16_43R_A8D2X4
- *      mlib_v_ImageChannelExtract_S16_43R_D1
- *      mlib_v_ImageChannelExtract_S16_43R
- *      mlib_v_ImageChannelExtract_U8_43L_A8D1X8
- *      mlib_v_ImageChannelExtract_U8_43L_A8D2X8
  *      mlib_v_ImageChannelExtract_U8_43L_D1
- *      mlib_v_ImageChannelExtract_U8_43L
- *      mlib_v_ImageChannelExtract_S16_43L_A8D1X4
- *      mlib_v_ImageChannelExtract_S16_43L_A8D2X4
  *      mlib_v_ImageChannelExtract_S16_43L_D1
- *      mlib_v_ImageChannelExtract_S16_43L
  *
  * SYNOPSIS
  *
@@ -74,705 +60,6 @@
 #include "mlib_v_ImageChannelExtract.h"
 
 /***************************************************************/
-#define EXTRACT_U8_43R_old          /* shift right */           \
-  dd2 = vis_faligndata(sd3, dd2);    /* r7-------------- */     \
-  sd3 = vis_faligndata(sd3, sd3);                               \
-  dd2 = vis_faligndata(sd3, dd2);    /* g7r7------------ */     \
-  sd3 = vis_faligndata(sd3, sd3);                               \
-  dd2 = vis_faligndata(sd3, dd2);    /* b7g7r7---------- */     \
-  sd3 = vis_faligndata(sd3, sd3);                               \
-  sd3 = vis_faligndata(sd3, sd3);                               \
-  dd2 = vis_faligndata(sd3, dd2);    /* r6b7g7r7-------- */     \
-  sd3 = vis_faligndata(sd3, sd3);                               \
-  dd2 = vis_faligndata(sd3, dd2);    /* g6r6b7g7r7------ */     \
-  sd3 = vis_faligndata(sd3, sd3);                               \
-  dd2 = vis_faligndata(sd3, dd2);    /* b6g6r6b7g7r7---- */     \
-                                                                \
-  dd2 = vis_faligndata(sd2, dd2);    /* r5b6g6r6b7g7r7-- */     \
-  sd2 = vis_faligndata(sd2, sd2);                               \
-  dd2 = vis_faligndata(sd2, dd2);    /* g5r5b6g6r6b7g7r7 */     \
-                                                                \
-  sd2 = vis_faligndata(sd2, sd2);                               \
-  dd1 = vis_faligndata(sd2, dd1);    /* b5-------------- */     \
-  sd2 = vis_faligndata(sd2, sd2);                               \
-  sd2 = vis_faligndata(sd2, sd2);                               \
-  dd1 = vis_faligndata(sd2, dd1);    /* r4b5------------ */     \
-  sd2 = vis_faligndata(sd2, sd2);                               \
-  dd1 = vis_faligndata(sd2, dd1);    /* g4r4b5---------- */     \
-  sd2 = vis_faligndata(sd2, sd2);                               \
-  dd1 = vis_faligndata(sd2, dd1);    /* b4g4r4b5-------- */     \
-                                                                \
-  dd1 = vis_faligndata(sd1, dd1);    /* r3b4g4r4b5------ */     \
-  sd1 = vis_faligndata(sd1, sd1);                               \
-  dd1 = vis_faligndata(sd1, dd1);    /* g3r3b4g4r4b5---- */     \
-  sd1 = vis_faligndata(sd1, sd1);                               \
-  dd1 = vis_faligndata(sd1, dd1);    /* b3g3r3b4g4r4b5-- */     \
-  sd1 = vis_faligndata(sd1, sd1);                               \
-  sd1 = vis_faligndata(sd1, sd1);                               \
-  dd1 = vis_faligndata(sd1, dd1);    /* r2b3g3r3b4g4r4b5 */     \
-                                                                \
-  sd1 = vis_faligndata(sd1, sd1);                               \
-  dd0 = vis_faligndata(sd1, dd0);    /* g2-------------- */     \
-  sd1 = vis_faligndata(sd1, sd1);                               \
-  dd0 = vis_faligndata(sd1, dd0);    /* b2g2------------ */     \
-                                                                \
-  dd0 = vis_faligndata(sd0, dd0);    /* r1b2g2---------- */     \
-  sd0 = vis_faligndata(sd0, sd0);                               \
-  dd0 = vis_faligndata(sd0, dd0);    /* g1r1b2g2-------- */     \
-  sd0 = vis_faligndata(sd0, sd0);                               \
-  dd0 = vis_faligndata(sd0, dd0);    /* b1g1r1b2g2------ */     \
-  sd0 = vis_faligndata(sd0, sd0);                               \
-  sd0 = vis_faligndata(sd0, sd0);                               \
-  dd0 = vis_faligndata(sd0, dd0);    /* r0b1g1r1b2g2---- */     \
-  sd0 = vis_faligndata(sd0, sd0);                               \
-  dd0 = vis_faligndata(sd0, dd0);    /* g0r0b1g1r1b2g2-- */     \
-  sd0 = vis_faligndata(sd0, sd0);                               \
-  dd0 = vis_faligndata(sd0, dd0);           /* b0g0r0b1g1r1b2g2 */
-
-/***************************************************************/
-#define EXTRACT_U8_43R              /* shift right */           \
-  vis_alignaddr((void *)0, 5);                                  \
-  dd2 = vis_faligndata(sd3, dd2);    /* b7g7r7---------- */     \
-  sda = vis_freg_pair(vis_read_hi(sd3), vis_read_hi(sd3));      \
-  dd2 = vis_faligndata(sda, dd2);    /* b6g6r6b7g7r7---- */     \
-                                                                \
-  vis_alignaddr((void *)0, 6);                                  \
-  dd2 = vis_faligndata(sd2, dd2);    /* g5r5b6g6r6b7g7r7 */     \
-                                                                \
-  vis_alignaddr((void *)0, 5);                                  \
-  dd1 = vis_faligndata(sd2, dd1);    /* b5g5r5---------- */     \
-  sda = vis_freg_pair(vis_read_hi(sd2), vis_read_hi(sd2));      \
-  dd1 = vis_faligndata(sda, dd1);    /* b4g4r4b5g5r5---- */     \
-  dd1 = vis_faligndata(sd1, dd1);    /* b3g3r3b4g4r4b5g5 */     \
-  sda = vis_freg_pair(vis_read_hi(sd1), vis_read_hi(sd1));      \
-  vis_alignaddr((void *)0, 7);                                  \
-  dd1 = vis_faligndata(sda, dd1);    /* r2b3g3r3b4g4r4b5 */     \
-                                                                \
-  vis_alignaddr((void *)0, 5);                                  \
-  dd0 = vis_faligndata(sda, dd0);    /* b2g2r2---------- */     \
-  dd0 = vis_faligndata(sd0, dd0);    /* b1g1r1b2g2r2---- */     \
-  sda = vis_freg_pair(vis_read_hi(sd0), vis_read_hi(sd0));      \
-  dd0 = vis_faligndata(sda, dd0);           /* b0g0r0b1g1r1b2g2 */
-
-/***************************************************************/
-#define LOAD_EXTRACT_U8_43R_STORE                               \
-  sd0 = *sp++;          /* --b0g0r0--b1g1r1 */                  \
-  sd1 = *sp++;          /* --b2g2r2--b3g3r3 */                  \
-  sd2 = *sp++;          /* --b4g4r4--b5g5r5 */                  \
-  sd3 = *sp++;          /* --b6g6r6--b7g7r7 */                  \
-  EXTRACT_U8_43R;                                               \
-  *dp++ = dd0;          /* b0g0r0b1g1r1b2g2 */                  \
-  *dp++ = dd1;          /* r2b3g3r3b4g4r4b5 */                  \
-  *dp++ = dd2;                              /* g5r5b6g6r6b7g7r7 */
-
-/***************************************************************/
-#define LOAD_EXTRACT_U8_43R                                     \
-  vis_alignaddr((void *)soff, 0);                               \
-  s0 = s4;                                                      \
-  s1 = sp[1];                                                   \
-  s2 = sp[2];                                                   \
-  s3 = sp[3];                                                   \
-  s4 = sp[4];                                                   \
-  sd0 = vis_faligndata(s0, s1);                                 \
-  sd1 = vis_faligndata(s1, s2);                                 \
-  sd2 = vis_faligndata(s2, s3);                                 \
-  sd3 = vis_faligndata(s3, s4);                                 \
-  sp += 4;                                                      \
-  dd2old = dd2;                                                 \
-  EXTRACT_U8_43R
-
-/***************************************************************/
-/*
- * Both source and destination image data are 1-d vectors and
- * 8-byte aligned. And dsize is multiple of 8.
- */
-
-void mlib_v_ImageChannelExtract_U8_43R_A8D1X8(const mlib_u8 *src,
-                                              mlib_u8       *dst,
-                                              mlib_s32      dsize)
-{
-  mlib_d64 *sp, *dp;
-  mlib_d64 sd0, sd1, sd2, sd3;                        /* source data */
-  mlib_d64 dd0, dd1, dd2;                             /* dst data */
-  mlib_d64 sda;
-  mlib_s32 i;
-
-  sp = (mlib_d64 *) src;
-  dp = (mlib_d64 *) dst;
-
-  /* set GSR.offset for vis_faligndata()  */
-/* vis_alignaddr((void *)0, 7); *//* only for _old */
-
-#pragma pipeloop(0)
-  for (i = 0; i < dsize / 8; i++) {
-    LOAD_EXTRACT_U8_43R_STORE;
-  }
-}
-
-/***************************************************************/
-/*
- * Either source or destination image data are not 1-d vectors, but
- * they are 8-byte aligned. And slb and dlb are multiple of 8.
- * The xsize is multiple of 8.
- */
-
-void mlib_v_ImageChannelExtract_U8_43R_A8D2X8(const mlib_u8 *src,
-                                              mlib_s32      slb,
-                                              mlib_u8       *dst,
-                                              mlib_s32      dlb,
-                                              mlib_s32      xsize,
-                                              mlib_s32      ysize)
-{
-  mlib_d64 *sp, *dp;                                  /* 8-byte aligned pointer for pixel */
-  mlib_d64 *sl, *dl;                                  /* 8-byte aligned pointer for line */
-  mlib_d64 sd0, sd1, sd2, sd3;                        /* source data */
-  mlib_d64 dd0, dd1, dd2;                             /* dst data */
-  mlib_d64 sda;
-  mlib_s32 i, j;                                      /* indices for x, y */
-
-  /* set GSR.offset for vis_faligndata()  */
-/* vis_alignaddr((void *)0, 7); *//* only for _old */
-
-  sp = sl = (mlib_d64 *) src;
-  dp = dl = (mlib_d64 *) dst;
-
-  /* row loop */
-  for (j = 0; j < ysize; j++) {
-    /* 8-byte column loop */
-#pragma pipeloop(0)
-    for (i = 0; i < xsize / 8; i++) {
-      LOAD_EXTRACT_U8_43R_STORE;
-    }
-
-    sp = sl = (mlib_d64 *) ((mlib_u8 *) sl + slb);
-    dp = dl = (mlib_d64 *) ((mlib_u8 *) dl + dlb);
-  }
-}
-
-/***************************************************************/
-/*
- * Either source or destination data are not 8-byte aligned.
- * And dsize is in pixels.
- */
-
-void mlib_v_ImageChannelExtract_U8_43R_D1(const mlib_u8 *src,
-                                          mlib_u8       *dst,
-                                          mlib_s32      dsize)
-{
-  mlib_u8 *sa, *da;
-  mlib_u8 *dend, *dend2;                              /* end points in dst */
-  mlib_d64 *dp;                                       /* 8-byte aligned start points in dst */
-  mlib_d64 *sp;                                       /* 8-byte aligned start point in src */
-  mlib_d64 s0, s1, s2, s3, s4;                        /* 8-byte source row data */
-  mlib_d64 sd0, sd1, sd2, sd3;                        /* 8-byte source data */
-  mlib_d64 dd0, dd1, dd2;                             /* dst data */
-  mlib_d64 dd2old;                                    /* the last datum of the last step */
-  mlib_d64 sda;
-  mlib_s32 soff;                                      /* offset of address in src */
-  mlib_s32 doff;                                      /* offset of address in dst */
-  mlib_s32 emask;                                     /* edge mask */
-  mlib_s32 i, n;
-
-  sa = (void *)src;
-  da = dst;
-
-  /* prepare the source address */
-  sp = (mlib_d64 *) ((mlib_addr) sa & (~7));
-  soff = ((mlib_addr) sa & 7);
-
-  /* prepare the destination addresses */
-  dp = (mlib_d64 *) ((mlib_addr) da & (~7));
-  dend = da + dsize * 3 - 1;
-  dend2 = dend - 23;
-  doff = 8 - ((mlib_addr) da & 7);
-
-  /* generate edge mask for the start point */
-  emask = vis_edge8(da, dend);
-
-  /* load 32 byte, convert, store 24 bytes */
-  s4 = sp[0];                               /* initial value */
-  LOAD_EXTRACT_U8_43R;
-
-  if (dsize >= 8) {
-    if (doff == 8) {
-      vis_pst_8(dd0, dp++, emask);
-      *dp++ = dd1;
-      *dp++ = dd2;
-    }
-    else {
-      vis_alignaddr((void *)doff, 0);
-      vis_pst_8(vis_faligndata(dd0, dd0), dp++, emask);
-      *dp++ = vis_faligndata(dd0, dd1);
-      *dp++ = vis_faligndata(dd1, dd2);
-    }
-  }
-  else {                                    /* for very small size */
-    if (doff == 8) {
-      vis_pst_8(dd0, dp++, emask);
-      if ((mlib_addr) dp <= (mlib_addr) dend) {
-        emask = vis_edge8(dp, dend);
-        vis_pst_8(dd1, dp++, emask);
-        if ((mlib_addr) dp <= (mlib_addr) dend) {
-          emask = vis_edge8(dp, dend);
-          vis_pst_8(dd2, dp++, emask);
-        }
-      }
-    }
-    else {
-      vis_alignaddr((void *)doff, 0);
-      vis_pst_8(vis_faligndata(dd0, dd0), dp++, emask);
-      if ((mlib_addr) dp <= (mlib_addr) dend) {
-        emask = vis_edge8(dp, dend);
-        vis_pst_8(vis_faligndata(dd0, dd1), dp++, emask);
-        if ((mlib_addr) dp <= (mlib_addr) dend) {
-          emask = vis_edge8(dp, dend);
-          vis_pst_8(vis_faligndata(dd1, dd2), dp++, emask);
-          if ((mlib_addr) dp <= (mlib_addr) dend) {
-            emask = vis_edge8(dp, dend);
-            vis_pst_8(vis_faligndata(dd2, dd2), dp++, emask);
-          }
-        }
-      }
-    }
-  }
-
-  /* no edge handling is needed in the loop */
-  if (doff == 8) {
-    if ((mlib_addr) dp <= (mlib_addr) dend2) {
-      n = ((mlib_u8 *) dend2 - (mlib_u8 *) dp) / 24 + 1;
-#pragma pipeloop(0)
-      for (i = 0; i < n; i++) {
-        LOAD_EXTRACT_U8_43R;
-        *dp++ = dd0;
-        *dp++ = dd1;
-        *dp++ = dd2;
-      }
-    }
-  }
-  else {
-    if ((mlib_addr) dp <= (mlib_addr) dend2) {
-      n = ((mlib_u8 *) dend2 - (mlib_u8 *) dp) / 24 + 1;
-#pragma pipeloop(0)
-      for (i = 0; i < n; i++) {
-        LOAD_EXTRACT_U8_43R;
-        vis_alignaddr((void *)doff, 0);
-        *dp++ = vis_faligndata(dd2old, dd0);
-        *dp++ = vis_faligndata(dd0, dd1);
-        *dp++ = vis_faligndata(dd1, dd2);
-      }
-    }
-  }
-
-  if ((mlib_addr) dp <= (mlib_addr) dend) {
-    LOAD_EXTRACT_U8_43R;
-    emask = vis_edge8(dp, dend);
-    if (doff == 8) {
-      vis_pst_8(dd0, dp++, emask);
-      if ((mlib_addr) dp <= (mlib_addr) dend) {
-        emask = vis_edge8(dp, dend);
-        vis_pst_8(dd1, dp++, emask);
-        if ((mlib_addr) dp <= (mlib_addr) dend) {
-          emask = vis_edge8(dp, dend);
-          vis_pst_8(dd2, dp++, emask);
-        }
-      }
-    }
-    else {
-      vis_alignaddr((void *)doff, 0);
-      vis_pst_8(vis_faligndata(dd2old, dd0), dp++, emask);
-      if ((mlib_addr) dp <= (mlib_addr) dend) {
-        emask = vis_edge8(dp, dend);
-        vis_pst_8(vis_faligndata(dd0, dd1), dp++, emask);
-        if ((mlib_addr) dp <= (mlib_addr) dend) {
-          emask = vis_edge8(dp, dend);
-          vis_pst_8(vis_faligndata(dd1, dd2), dp++, emask);
-        }
-      }
-    }
-  }
-}
-
-/***************************************************************/
-void mlib_v_ImageChannelExtract_U8_43R(const mlib_u8 *src,
-                                       mlib_s32      slb,
-                                       mlib_u8       *dst,
-                                       mlib_s32      dlb,
-                                       mlib_s32      xsize,
-                                       mlib_s32      ysize)
-{
-  mlib_u8 *sa, *da;
-  mlib_u8 *sl, *dl;
-  mlib_s32 j;
-
-  sa = sl = (void *)src;
-  da = dl = dst;
-
-  for (j = 0; j < ysize; j++) {
-    mlib_v_ImageChannelExtract_U8_43R_D1(sa, da, xsize);
-    sa = sl += slb;
-    da = dl += dlb;
-  }
-}
-
-/***************************************************************/
-#define EXTRACT_S16_43R_old      /* shift right */              \
-                                                                \
-  dd2 = vis_faligndata(sd3, dd2);    /* r3------ */             \
-  sd3 = vis_faligndata(sd3, sd3);                               \
-  dd2 = vis_faligndata(sd3, dd2);    /* g3r3---- */             \
-  sd3 = vis_faligndata(sd3, sd3);                               \
-  dd2 = vis_faligndata(sd3, dd2);    /* b3g3r3-- */             \
-                                                                \
-  dd2 = vis_faligndata(sd2, dd2);    /* r2b3g3r3 */             \
-  sd2 = vis_faligndata(sd2, sd2);                               \
-  dd1 = vis_faligndata(sd2, dd1);    /* g2------ */             \
-  sd2 = vis_faligndata(sd2, sd2);                               \
-  dd1 = vis_faligndata(sd2, dd1);    /* b2g2---- */             \
-                                                                \
-  dd1 = vis_faligndata(sd1, dd1);    /* r1b2g2-- */             \
-  sd1 = vis_faligndata(sd1, sd1);                               \
-  dd1 = vis_faligndata(sd1, dd1);    /* g1r1b2g2 */             \
-  sd1 = vis_faligndata(sd1, sd1);                               \
-  dd0 = vis_faligndata(sd1, dd0);    /* b1------ */             \
-                                                                \
-  dd0 = vis_faligndata(sd0, dd0);    /* r0b1---- */             \
-  sd0 = vis_faligndata(sd0, sd0);                               \
-  dd0 = vis_faligndata(sd0, dd0);    /* g0r0b1-- */             \
-  sd0 = vis_faligndata(sd0, sd0);                               \
-  dd0 = vis_faligndata(sd0, dd0);           /* b0g0r0b1 */
-
-/***************************************************************/
-#define EXTRACT_S16_43R        /* shift right */                \
-                                                                \
-  vis_alignaddr((void *)0, 2);                                  \
-  dd2 = vis_faligndata(sd3, dd2);    /* b3g3r3-- */             \
-                                                                \
-  vis_alignaddr((void *)0, 6);                                  \
-  dd2 = vis_faligndata(sd2, dd2);    /* r2b3g3r3 */             \
-  vis_alignaddr((void *)0, 2);                                  \
-  dd1 = vis_faligndata(sd2, dd1);    /* b2g2r2-- */             \
-                                                                \
-  vis_alignaddr((void *)0, 4);                                  \
-  dd1 = vis_faligndata(sd1, dd1);    /* g1r1b2g2 */             \
-  vis_alignaddr((void *)0, 2);                                  \
-  dd0 = vis_faligndata(sd1, dd0);    /* b1g1r1-- */             \
-  dd0 = vis_faligndata(sd0, dd0);           /* b0g0r0b1 */
-
-/***************************************************************/
-#define LOAD_EXTRACT_S16_43R_STORE                              \
-                                                                \
-  sd0 = *sp++;          /* --b0g0r0 */                          \
-  sd1 = *sp++;          /* --b1g1r1 */                          \
-  sd2 = *sp++;          /* --b2g2r2 */                          \
-  sd3 = *sp++;          /* --b3g3r3 */                          \
-                                                                \
-  EXTRACT_S16_43R;                                              \
-                                                                \
-  *dp++ = dd0;          /* b0g0r0b1 */                          \
-  *dp++ = dd1;          /* g1r1b2g2 */                          \
-  *dp++ = dd2;                              /* r2b3g3r3 */
-
-/***************************************************************/
-#define LOAD_EXTRACT_S16_43R                                    \
-                                                                \
-  vis_alignaddr((void *)soff, 0);                               \
-  s0 = s4;                                                      \
-  s1 = sp[1];                                                   \
-  s2 = sp[2];                                                   \
-  s3 = sp[3];                                                   \
-  s4 = sp[4];                                                   \
-  sd0 = vis_faligndata(s0, s1);                                 \
-  sd1 = vis_faligndata(s1, s2);                                 \
-  sd2 = vis_faligndata(s2, s3);                                 \
-  sd3 = vis_faligndata(s3, s4);                                 \
-  sp += 4;                                                      \
-  dd2old = dd2;                                                 \
-  EXTRACT_S16_43R
-
-/***************************************************************/
-/*
- * Both source and destination image data are 1-d vectors and
- * 8-byte aligned. And size is in 4-pixels.
- */
-
-void mlib_v_ImageChannelExtract_S16_43R_A8D1X4(const mlib_s16 *src,
-                                               mlib_s16       *dst,
-                                               mlib_s32       dsize)
-{
-  mlib_d64 *sp, *dp;                                  /* 8-byte aligned pointer for pixel */
-  mlib_d64 sd0, sd1, sd2, sd3;                        /* source data */
-  mlib_d64 dd0, dd1, dd2;                             /* dst data */
-  mlib_s32 i;
-
-  sp = (mlib_d64 *) src;
-  dp = (mlib_d64 *) dst;
-
-  /* set GSR.offset for vis_faligndata()  */
-/* vis_alignaddr((void *)0, 6); *//* only for _old */
-
-#pragma pipeloop(0)
-  for (i = 0; i < dsize / 4; i++) {
-    LOAD_EXTRACT_S16_43R_STORE;
-  }
-}
-
-/***************************************************************/
-/*
- * Either source or destination image data are not 1-d vectors, but
- * they are 8-byte aligned. The xsize is multiple of 8.
- * slb and dlb are multiple of 8.
- */
-
-void mlib_v_ImageChannelExtract_S16_43R_A8D2X4(const mlib_s16 *src,
-                                               mlib_s32       slb,
-                                               mlib_s16       *dst,
-                                               mlib_s32       dlb,
-                                               mlib_s32       xsize,
-                                               mlib_s32       ysize)
-{
-  mlib_d64 *sp, *dp;                                  /* 8-byte aligned pointer for pixel */
-  mlib_d64 *sl, *dl;                                  /* 8-byte aligned pointer for line */
-  mlib_d64 sd0, sd1, sd2, sd3;                        /* source data */
-  mlib_d64 dd0, dd1, dd2;                             /* dst data */
-  mlib_s32 i, j;                                      /* indices for x, y */
-
-  /* set GSR.offset for vis_faligndata()  */
-/* vis_alignaddr((void *)0, 6); *//* only for _old */
-
-  sp = sl = (mlib_d64 *) src;
-  dp = dl = (mlib_d64 *) dst;
-
-  /* row loop */
-  for (j = 0; j < ysize; j++) {
-    /* 4-pixel column loop */
-#pragma pipeloop(0)
-    for (i = 0; i < xsize / 4; i++) {
-      LOAD_EXTRACT_S16_43R_STORE;
-    }
-
-    sp = sl = (mlib_d64 *) ((mlib_u8 *) sl + slb);
-    dp = dl = (mlib_d64 *) ((mlib_u8 *) dl + dlb);
-  }
-}
-
-/***************************************************************/
-/*
- * Either source or destination data are not 8-byte aligned.
- * And dsize is multiple of 8.
- */
-
-void mlib_v_ImageChannelExtract_S16_43R_D1(const mlib_s16 *src,
-                                           mlib_s16       *dst,
-                                           mlib_s32       dsize)
-{
-  mlib_s16 *sa, *da;                                  /* pointer for pixel */
-  mlib_s16 *dend, *dend2;                             /* end points in dst */
-  mlib_d64 *dp;                                       /* 8-byte aligned start points in dst */
-  mlib_d64 *sp;                                       /* 8-byte aligned start point in src */
-  mlib_d64 s0, s1, s2, s3, s4;                        /* 8-byte source row data */
-  mlib_d64 sd0, sd1, sd2, sd3;                        /* 8-byte source data */
-  mlib_d64 dd0, dd1, dd2;                             /* dst data */
-  mlib_d64 dd2old;                                    /* the last datum of the last step */
-  mlib_s32 soff;                                      /* offset of address in src */
-  mlib_s32 doff;                                      /* offset of address in dst */
-  mlib_s32 emask;                                     /* edge mask */
-  mlib_s32 i, n;
-
-  sa = (void *)src;
-  da = dst;
-
-  /* prepare the source address */
-  sp = (mlib_d64 *) ((mlib_addr) sa & (~7));
-  soff = ((mlib_addr) sa & 7);
-
-  /* prepare the destination addresses */
-  dp = (mlib_d64 *) ((mlib_addr) da & (~7));
-  dend = da + dsize * 3 - 1;
-  dend2 = dend - 11;
-  doff = 8 - ((mlib_addr) da & 7);
-
-  /* generate edge mask for the start point */
-  emask = vis_edge16(da, dend);
-
-  /* load 32 byte, convert, store 24 bytes */
-  s4 = sp[0];                               /* initial value */
-  LOAD_EXTRACT_S16_43R;
-
-  if (dsize >= 4) {
-    if (doff == 8) {
-      vis_pst_16(dd0, dp++, emask);
-      *dp++ = dd1;
-      *dp++ = dd2;
-    }
-    else {
-      vis_alignaddr((void *)doff, 0);
-      vis_pst_16(vis_faligndata(dd0, dd0), dp++, emask);
-      *dp++ = vis_faligndata(dd0, dd1);
-      *dp++ = vis_faligndata(dd1, dd2);
-    }
-  }
-  else {                                    /* for very small size */
-    if (doff == 8) {
-      vis_pst_16(dd0, dp++, emask);
-      if ((mlib_addr) dp <= (mlib_addr) dend) {
-        emask = vis_edge16(dp, dend);
-        vis_pst_16(dd1, dp++, emask);
-        if ((mlib_addr) dp <= (mlib_addr) dend) {
-          emask = vis_edge16(dp, dend);
-          vis_pst_16(dd2, dp++, emask);
-        }
-      }
-    }
-    else {
-      vis_alignaddr((void *)doff, 0);
-      vis_pst_16(vis_faligndata(dd0, dd0), dp++, emask);
-      if ((mlib_addr) dp <= (mlib_addr) dend) {
-        emask = vis_edge16(dp, dend);
-        vis_pst_16(vis_faligndata(dd0, dd1), dp++, emask);
-        if ((mlib_addr) dp <= (mlib_addr) dend) {
-          emask = vis_edge16(dp, dend);
-          vis_pst_16(vis_faligndata(dd1, dd2), dp++, emask);
-        }
-      }
-    }
-  }
-
-  /* no edge handling is needed in the loop */
-  if (doff == 8) {
-    if ((mlib_addr) dp <= (mlib_addr) dend2) {
-      n = ((mlib_u8 *) dend2 - (mlib_u8 *) dp) / 24 + 1;
-#pragma pipeloop(0)
-      for (i = 0; i < n; i++) {
-        LOAD_EXTRACT_S16_43R;
-        *dp++ = dd0;
-        *dp++ = dd1;
-        *dp++ = dd2;
-      }
-    }
-  }
-  else {
-    if ((mlib_addr) dp <= (mlib_addr) dend2) {
-      n = ((mlib_u8 *) dend2 - (mlib_u8 *) dp) / 24 + 1;
-#pragma pipeloop(0)
-      for (i = 0; i < n; i++) {
-        LOAD_EXTRACT_S16_43R;
-        vis_alignaddr((void *)doff, 0);
-        *dp++ = vis_faligndata(dd2old, dd0);
-        *dp++ = vis_faligndata(dd0, dd1);
-        *dp++ = vis_faligndata(dd1, dd2);
-      }
-    }
-  }
-
-  if ((mlib_addr) dp <= (mlib_addr) dend) {
-    LOAD_EXTRACT_S16_43R;
-    emask = vis_edge16(dp, dend);
-    if (doff == 8) {
-      vis_pst_16(dd0, dp++, emask);
-      if ((mlib_addr) dp <= (mlib_addr) dend) {
-        emask = vis_edge16(dp, dend);
-        vis_pst_16(dd1, dp++, emask);
-        if ((mlib_addr) dp <= (mlib_addr) dend) {
-          emask = vis_edge16(dp, dend);
-          vis_pst_16(dd2, dp++, emask);
-        }
-      }
-    }
-    else {
-      vis_alignaddr((void *)doff, 0);
-      vis_pst_16(vis_faligndata(dd2old, dd0), dp++, emask);
-      if ((mlib_addr) dp <= (mlib_addr) dend) {
-        emask = vis_edge16(dp, dend);
-        vis_pst_16(vis_faligndata(dd0, dd1), dp++, emask);
-        if ((mlib_addr) dp <= (mlib_addr) dend) {
-          emask = vis_edge16(dp, dend);
-          vis_pst_16(vis_faligndata(dd1, dd2), dp++, emask);
-        }
-      }
-    }
-  }
-}
-
-/***************************************************************/
-void mlib_v_ImageChannelExtract_S16_43R(const mlib_s16 *src,
-                                        mlib_s32       slb,
-                                        mlib_s16       *dst,
-                                        mlib_s32       dlb,
-                                        mlib_s32       xsize,
-                                        mlib_s32       ysize)
-{
-  mlib_s16 *sa, *da;
-  mlib_s16 *sl, *dl;
-  mlib_s32 j;
-
-  sa = sl = (void *)src;
-  da = dl = dst;
-
-  for (j = 0; j < ysize; j++) {
-    mlib_v_ImageChannelExtract_S16_43R_D1(sa, da, xsize);
-    sa = sl = (mlib_s16 *) ((mlib_u8 *) sl + slb);
-    da = dl = (mlib_s16 *) ((mlib_u8 *) dl + dlb);
-  }
-}
-
-/***************************************************************/
-#define EXTRACT_U8_43L_old      /* shift left */                \
-                                                                \
-  dd0 = vis_faligndata(dd0, sd0);    /* --------------r0 */     \
-  sd0 = vis_faligndata(sd0, sd0);                               \
-  dd0 = vis_faligndata(dd0, sd0);    /* ------------r0g0 */     \
-  sd0 = vis_faligndata(sd0, sd0);                               \
-  dd0 = vis_faligndata(dd0, sd0);    /* ----------r0g0b0 */     \
-  sd0 = vis_faligndata(sd0, sd0);                               \
-  sd0 = vis_faligndata(sd0, sd0);                               \
-  dd0 = vis_faligndata(dd0, sd0);    /* --------r0g0b0r1 */     \
-  sd0 = vis_faligndata(sd0, sd0);                               \
-  dd0 = vis_faligndata(dd0, sd0);    /* ------r0g0b0r1g1 */     \
-  sd0 = vis_faligndata(sd0, sd0);                               \
-  dd0 = vis_faligndata(dd0, sd0);    /* ----r0g0b0r1g1b1 */     \
-                                                                \
-  dd0 = vis_faligndata(dd0, sd1);    /* --r0g0b0r1g1b1r2 */     \
-  sd1 = vis_faligndata(sd1, sd1);                               \
-  dd0 = vis_faligndata(dd0, sd1);    /* r0g0b0r1g1b1r2g2 */     \
-                                                                \
-  sd1 = vis_faligndata(sd1, sd1);                               \
-  dd1 = vis_faligndata(dd1, sd1);    /* --------------b2 */     \
-  sd1 = vis_faligndata(sd1, sd1);                               \
-  sd1 = vis_faligndata(sd1, sd1);                               \
-  dd1 = vis_faligndata(dd1, sd1);    /* ------------b2r3 */     \
-  sd1 = vis_faligndata(sd1, sd1);                               \
-  dd1 = vis_faligndata(dd1, sd1);    /* ----------b2r3g3 */     \
-  sd1 = vis_faligndata(sd1, sd1);                               \
-  dd1 = vis_faligndata(dd1, sd1);    /* --------b2r3g3b3 */     \
-                                                                \
-  dd1 = vis_faligndata(dd1, sd2);    /* ------b2r3g3b3r4 */     \
-  sd2 = vis_faligndata(sd2, sd2);                               \
-  dd1 = vis_faligndata(dd1, sd2);    /* ----b2r3g3b3r4g4 */     \
-  sd2 = vis_faligndata(sd2, sd2);                               \
-  dd1 = vis_faligndata(dd1, sd2);    /* --b2r3g3b3r4g4b4 */     \
-  sd2 = vis_faligndata(sd2, sd2);                               \
-  sd2 = vis_faligndata(sd2, sd2);                               \
-  dd1 = vis_faligndata(dd1, sd2);    /* b2r3g3b3r4g4b4r5 */     \
-                                                                \
-  sd2 = vis_faligndata(sd2, sd2);                               \
-  dd2 = vis_faligndata(dd2, sd2);    /* --------------g5 */     \
-  sd2 = vis_faligndata(sd2, sd2);                               \
-  dd2 = vis_faligndata(dd2, sd2);    /* ------------g5b5 */     \
-                                                                \
-  dd2 = vis_faligndata(dd2, sd3);    /* ----------g5b5r6 */     \
-  sd3 = vis_faligndata(sd3, sd3);                               \
-  dd2 = vis_faligndata(dd2, sd3);    /* --------g5b5r6g6 */     \
-  sd3 = vis_faligndata(sd3, sd3);                               \
-  dd2 = vis_faligndata(dd2, sd3);    /* ------g5b5r6g6b6 */     \
-  sd3 = vis_faligndata(sd3, sd3);                               \
-  sd3 = vis_faligndata(sd3, sd3);                               \
-  dd2 = vis_faligndata(dd2, sd3);    /* ----g5b5r6g6b6r7 */     \
-  sd3 = vis_faligndata(sd3, sd3);                               \
-  dd2 = vis_faligndata(dd2, sd3);    /* --g5b5r6g6b6r7g7 */     \
-  sd3 = vis_faligndata(sd3, sd3);                               \
-  dd2 = vis_faligndata(dd2, sd3);           /* g5b5r6g6b6r7g7b7 */
-
-/***************************************************************/
 #define EXTRACT_U8_43L        /* shift left */                  \
                                                                 \
   vis_alignaddr((void *)0, 3);                                  \
@@ -801,20 +88,6 @@
   dd2 = vis_faligndata(dd2, sda);           /* g5b5r6g6b6r7g7b7 */
 
 /***************************************************************/
-#define LOAD_EXTRACT_U8_43L_STORE                               \
-                                                                \
-  sd0 = *sp++;          /* r0g0b0--r1g1b1-- */                  \
-  sd1 = *sp++;          /* r2g2b2--r3g3b3-- */                  \
-  sd2 = *sp++;          /* r4g4b4--r5g5b5-- */                  \
-  sd3 = *sp++;          /* r6g6b6--r7g7b7-- */                  \
-                                                                \
-  EXTRACT_U8_43L;                                               \
-                                                                \
-  *dp++ = dd0;          /* r0g0b0r1g1b1r2g2 */                  \
-  *dp++ = dd1;          /* b2r3g3b3r4g4b4r5 */                  \
-  *dp++ = dd2;                              /* g5b5r6g6b6r7g7b7 */
-
-/***************************************************************/
 #define LOAD_EXTRACT_U8_43L                                             \
                                                                         \
   vis_alignaddr((void *)soff, 0);                                       \
@@ -835,74 +108,6 @@
 
 /***************************************************************/
 /*
- * Both source and destination image data are 1-d vectors and
- * 8-byte aligned. And dsize is multiple of 8.
- */
-
-void mlib_v_ImageChannelExtract_U8_43L_A8D1X8(const mlib_u8 *src,
-                                              mlib_u8       *dst,
-                                              mlib_s32      dsize)
-{
-  mlib_d64 *sp, *dp;
-  mlib_d64 sd0, sd1, sd2, sd3;                        /* source data */
-  mlib_d64 dd0, dd1, dd2;                             /* dst data */
-  mlib_d64 sda;
-  mlib_s32 i;
-
-  sp = (mlib_d64 *) src;
-  dp = (mlib_d64 *) dst;
-
-  /* set GSR.offset for vis_faligndata()  */
-/* vis_alignaddr((void *)0, 1); *//* for _old only */
-
-#pragma pipeloop(0)
-  for (i = 0; i < dsize / 8; i++) {
-    LOAD_EXTRACT_U8_43L_STORE;
-  }
-}
-
-/***************************************************************/
-/*
- * Either source or destination image data are not 1-d vectors, but
- * they are 8-byte aligned. And slb and dlb are multiple of 8.
- * The xsize is multiple of 8.
- */
-
-void mlib_v_ImageChannelExtract_U8_43L_A8D2X8(const mlib_u8 *src,
-                                              mlib_s32      slb,
-                                              mlib_u8       *dst,
-                                              mlib_s32      dlb,
-                                              mlib_s32      xsize,
-                                              mlib_s32      ysize)
-{
-  mlib_d64 *sp, *dp;                                  /* 8-byte aligned pointer for pixel */
-  mlib_d64 *sl, *dl;                                  /* 8-byte aligned pointer for line */
-  mlib_d64 sd0, sd1, sd2, sd3;                        /* source data */
-  mlib_d64 dd0, dd1, dd2;                             /* dst data */
-  mlib_d64 sda;
-  mlib_s32 i, j;                                      /* indices for x, y */
-
-  /* set GSR.offset for vis_faligndata()  */
-/* vis_alignaddr((void *)0, 1); *//* for _old only */
-
-  sp = sl = (mlib_d64 *) src;
-  dp = dl = (mlib_d64 *) dst;
-
-  /* row loop */
-  for (j = 0; j < ysize; j++) {
-    /* 8-byte column loop */
-#pragma pipeloop(0)
-    for (i = 0; i < xsize / 8; i++) {
-      LOAD_EXTRACT_U8_43L_STORE;
-    }
-
-    sp = sl = (mlib_d64 *) ((mlib_u8 *) sl + slb);
-    dp = dl = (mlib_d64 *) ((mlib_u8 *) dl + dlb);
-  }
-}
-
-/***************************************************************/
-/*
  * Either source or destination data are not 8-byte aligned.
  * And ssize is multiple of 8.
  */
@@ -1045,28 +250,6 @@
 }
 
 /***************************************************************/
-void mlib_v_ImageChannelExtract_U8_43L(const mlib_u8 *src,
-                                       mlib_s32      slb,
-                                       mlib_u8       *dst,
-                                       mlib_s32      dlb,
-                                       mlib_s32      xsize,
-                                       mlib_s32      ysize)
-{
-  mlib_u8 *sa, *da;
-  mlib_u8 *sl, *dl;
-  mlib_s32 j;
-
-  sa = sl = (void *)src;
-  da = dl = dst;
-
-  for (j = 0; j < ysize; j++) {
-    mlib_v_ImageChannelExtract_U8_43L_D1(sa, da, xsize);
-    sa = sl += slb;
-    da = dl += dlb;
-  }
-}
-
-/***************************************************************/
 #define EXTRACT_S16_43L              /* shift left */           \
   vis_alignaddr((void *)0, 6);                                  \
   dd0 = vis_faligndata(dd0, sd0);    /* --r0g0b0 */             \
@@ -1083,20 +266,6 @@
   dd2 = vis_faligndata(dd2, sd3);           /* b2r3g3b3 */
 
 /***************************************************************/
-#define LOAD_EXTRACT_S16_43L_STORE                              \
-                                                                \
-  sd0 = *sp++;          /* r0g0b0-- */                          \
-  sd1 = *sp++;          /* r1g1b1-- */                          \
-  sd2 = *sp++;          /* r2g2b2-- */                          \
-  sd3 = *sp++;          /* r3g3b3-- */                          \
-                                                                \
-  EXTRACT_S16_43L;                                              \
-                                                                \
-  *dp++ = dd0;          /* r0g0b0r1 */                          \
-  *dp++ = dd1;          /* g1b1r2g2 */                          \
-  *dp++ = dd2;                              /* b2r3g3b3 */
-
-/***************************************************************/
 #define LOAD_EXTRACT_S16_43L                                    \
                                                                 \
   vis_alignaddr((void *)soff, 0);                               \
@@ -1115,72 +284,6 @@
 
 /***************************************************************/
 /*
- * Both source and destination image data are 1-d vectors and
- * 8-byte aligned. And dsize is multiple of 4.
- */
-
-void mlib_v_ImageChannelExtract_S16_43L_A8D1X4(const mlib_s16 *src,
-                                               mlib_s16       *dst,
-                                               mlib_s32       dsize)
-{
-  mlib_d64 *sp, *dp;                                  /* 8-byte aligned pointer for pixel */
-  mlib_d64 sd0, sd1, sd2, sd3;                        /* source data */
-  mlib_d64 dd0, dd1, dd2;                             /* dst data */
-  mlib_s32 i;
-
-  sp = (mlib_d64 *) src;
-  dp = (mlib_d64 *) dst;
-
-  /* set GSR.offset for vis_faligndata()  */
-/* vis_alignaddr((void *)0, 2); *//* only for _old */
-
-#pragma pipeloop(0)
-  for (i = 0; i < dsize / 4; i++) {
-    LOAD_EXTRACT_S16_43L_STORE;
-  }
-}
-
-/***************************************************************/
-/*
- * Either source or destination image data are not 1-d vectors, but
- * they are 8-byte aligned. The xsize is multiple of 4.
- * And slb and dlb are multiple of 8.
- */
-
-void mlib_v_ImageChannelExtract_S16_43L_A8D2X4(const mlib_s16 *src,
-                                               mlib_s32       slb,
-                                               mlib_s16       *dst,
-                                               mlib_s32       dlb,
-                                               mlib_s32       xsize,
-                                               mlib_s32       ysize)
-{
-  mlib_d64 *sp, *dp;                                  /* 8-byte aligned pointer for pixel */
-  mlib_d64 *sl, *dl;                                  /* 8-byte aligned pointer for line */
-  mlib_d64 sd0, sd1, sd2, sd3;                        /* source data */
-  mlib_d64 dd0, dd1, dd2;                             /* dst data */
-  mlib_s32 i, j;                                      /* indices for x, y */
-
-  /* set GSR.offset for vis_faligndata()  */
-/* vis_alignaddr((void *)0, 2); *//* only for _old */
-
-  sp = sl = (mlib_d64 *) src;
-  dp = dl = (mlib_d64 *) dst;
-
-  /* row loop */
-  for (j = 0; j < ysize; j++) {
-    /* 4-pixel column loop */
-#pragma pipeloop(0)
-    for (i = 0; i < xsize / 4; i++) {
-      LOAD_EXTRACT_S16_43L_STORE;
-    }
-
-    sp = sl = (mlib_d64 *) ((mlib_u8 *) sl + slb);
-    dp = dl = (mlib_d64 *) ((mlib_u8 *) dl + dlb);
-  }
-}
-
-/***************************************************************/
-/*
  * Either source or destination data are not 8-byte aligned.
  * And size is in pixels.
  */
@@ -1318,25 +421,3 @@
 }
 
 /***************************************************************/
-void mlib_v_ImageChannelExtract_S16_43L(const mlib_s16 *src,
-                                        mlib_s32       slb,
-                                        mlib_s16       *dst,
-                                        mlib_s32       dlb,
-                                        mlib_s32       xsize,
-                                        mlib_s32       ysize)
-{
-  mlib_s16 *sa, *da;
-  mlib_s16 *sl, *dl;
-  mlib_s32 j;
-
-  sa = sl = (void *)src;
-  da = dl = dst;
-
-  for (j = 0; j < ysize; j++) {
-    mlib_v_ImageChannelExtract_S16_43L_D1(sa, da, xsize);
-    sa = sl = (mlib_s16 *) ((mlib_u8 *) sl + slb);
-    da = dl = (mlib_s16 *) ((mlib_u8 *) dl + dlb);
-  }
-}
-
-/***************************************************************/
--- a/jdk/src/java.desktop/unix/native/libmlib_image/mlib_v_ImageChannelExtract_f.c	Thu May 19 17:48:02 2016 +0000
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,784 +0,0 @@
-/*
- * Copyright (c) 2000, 2003, 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.
- */
-
-
-
-#include <stdlib.h>
-#include "mlib_image.h"
-#include "mlib_ImageCheck.h"
-
-typedef union {
-  double d64;
-  struct {
-    float f0;
-    float f1;
-  } f32s;
-} d64_2_f32;
-
-/***************************************************************/
-
-void mlib_v_ImageChannelExtract_U8_2_1(mlib_u8  *sl,  mlib_s32 slb,
-                                       mlib_u8  *dl, mlib_s32 dlb,
-                                       mlib_s32 width, mlib_s32 height)
-{
-  mlib_u8   *sp = sl;
-  mlib_u8   *dp = dl;
-  int       i, j;
-
-  for (j = 0; j < height; j++) {
-    mlib_u8  *dend = dl + width;
-    mlib_u32 *sp2;
-    while (((mlib_addr)sp & 7) > 1) {
-      *dp++ = *sp;
-      sp += 2;
-      if (dp >= dend) break;
-    }
-    if ((mlib_addr)sp & 7) {
-      sp2 = (mlib_u32 *)(sp - 1);
-#pragma pipeloop(0)
-      for (; dp <= (dend-2); dp += 2) {
-        mlib_u32 s0;
-        s0 = *sp2++;
-        dp[0] = s0 >> 16;
-        dp[1] = s0;
-      }
-      if (dp < dend) {
-        dp[0] = sp2[0] >> 16;
-      }
-    } else {
-      sp2 = (mlib_u32 *)sp;
-#pragma pipeloop(0)
-      for (; dp <= (dend-2); dp += 2) {
-        mlib_u32 s0;
-        s0 = *sp2++;
-        dp[0] = s0 >> 24;
-        dp[1] = s0 >> 8;
-      }
-      if (dp < dend) {
-        dp[0] = sp2[0] >> 24;
-      }
-    }
-    sp = sl += slb;
-    dp = dl += dlb;
-  }
-}
-
-/***************************************************************/
-
-void mlib_v_ImageChannelExtract_U8_3_2(mlib_u8  *sl, mlib_s32 slb,
-                                       mlib_u8 *dl, mlib_s32 dlb,
-                                       mlib_s32 width, mlib_s32 height,
-                                       mlib_s32 count1)
-{
-  mlib_u8   *sp = sl;
-  mlib_u8   *dp = dl;
-  mlib_u32  *sp2;
-  mlib_u16  *dp2;
-  mlib_u16  *d2end;
-  mlib_u32  s0, s1, s2, s3;
-  int       i, j, off, count_off;
-
-  for (j = 0; j < height; j++) {
-    mlib_u8  *dend  = dl + 2*width;
-
-    if (count1 == 1) {
-      if (dp < dend) *dp++ = sp[0];
-      sp += 2;
-    }
-
-    if ((mlib_addr)dp & 1) {
-#pragma pipeloop(0)
-      for (; dp <= (dend-2); dp += 2) {
-        dp[0] = sp[0];
-        dp[1] = sp[1];
-        sp += 3;
-      }
-      if (dp < dend) {
-        dp[0] = sp[0];
-      }
-      sp = sl += slb;
-      dp = dl += dlb;
-      continue;
-    }
-
-    dp2 = (mlib_u16*)dp;
-    d2end = (mlib_u16*)((mlib_addr)dend &~ 1);
-    off = (mlib_addr)sp & 3;
-    sp2 = (mlib_u32 *)(sp - off);
-
-    switch (off) {
-
-      case 0:
-#pragma pipeloop(0)
-        for (; dp2 <= (d2end-4); dp2 += 4) {
-          s0 = sp2[0];
-          s1 = sp2[1];
-          s2 = sp2[2];
-          dp2[0] = s0 >> 16;
-          dp2[1] = (s0 << 8) | (s1 >> 24);
-          dp2[2] = s1;
-          dp2[3] = s2 >>  8;
-          sp2 += 3;
-        }
-        break;
-
-      case 1:
-#pragma pipeloop(0)
-        for (; dp2 <= (d2end-4); dp2 += 4) {
-          s0 = sp2[0];
-          s1 = sp2[1];
-          s2 = sp2[2];
-          dp2[0] = s0 >> 8;
-          dp2[1] = s1 >> 16;
-          dp2[2] = (s1 << 8) | (s2 >> 24);
-          dp2[3] = s2;
-          sp2 += 3;
-        }
-        break;
-
-      case 2:
-#pragma pipeloop(0)
-        s3 = sp2[0];
-        for (; dp2 <= (d2end-4); dp2 += 4) {
-          s0 = s3;
-          s1 = sp2[1];
-          s2 = sp2[2];
-          s3 = sp2[3];
-          dp2[0] = s0;
-          dp2[1] = s1 >> 8;
-          dp2[2] = s2 >> 16;
-          dp2[3] = (s2 << 8) | (s3 >> 24);
-          sp2 += 3;
-        }
-        break;
-
-      case 3:
-#pragma pipeloop(0)
-        s3 = sp2[0];
-        for (; dp2 <= (d2end-4); dp2 += 4) {
-          s0 = s3;
-          s1 = sp2[1];
-          s2 = sp2[2];
-          s3 = sp2[3];
-          dp2[0] = (s0 << 8) | (s1 >> 24);
-          dp2[1] = s1;
-          dp2[2] = s2 >>  8;
-          dp2[3] = s3 >> 16;
-          sp2 += 3;
-        }
-    }
-
-    sp = (mlib_u8 *)sp2 + off;
-    dp = (mlib_u8 *)dp2;
-    while (dp < dend) {
-      *dp++ = sp[0];
-      if (dp < dend) *dp++ = sp[1];
-      sp += 3;
-    }
-
-    sp = sl += slb;
-    dp = dl += dlb;
-  }
-}
-
-/***************************************************************/
-
-void mlib_v_ImageChannelExtract_U8_4_2(mlib_u8  *sl, mlib_s32 slb,
-                                       mlib_u8 *dl, mlib_s32 dlb,
-                                       mlib_s32 width, mlib_s32 height,
-                                       mlib_s32 count1)
-{
-  mlib_u8   *sp = sl;
-  mlib_u8   *dp = dl;
-  mlib_u32  *sp2;
-  mlib_u16  *dp2;
-  mlib_u16  *d2end;
-  mlib_u32  s0, s1, s2, s3;
-  int       i, j, off, count_off;
-
-  for (j = 0; j < height; j++) {
-    mlib_u8  *dend  = dl + 2*width;
-
-    if (count1 == 1) {
-      if (dp < dend) *dp++ = sp[0];
-      sp += 3;
-    }
-
-    off = (mlib_addr)sp & 3;
-
-    if (((mlib_addr)dp & 1) || (off == 3)) {
-#pragma pipeloop(0)
-      for (; dp <= (dend-2); dp += 2) {
-        dp[0] = sp[0];
-        dp[1] = sp[1];
-        sp += 4;
-      }
-      if (dp < dend) {
-        dp[0] = sp[0];
-      }
-      sp = sl += slb;
-      dp = dl += dlb;
-      continue;
-    }
-
-    dp2 = (mlib_u16*)dp;
-    d2end = (mlib_u16*)((mlib_addr)dend &~ 1);
-    sp2 = (mlib_u32 *)(sp - off);
-
-    switch (off) {
-
-      case 0:
-#pragma pipeloop(0)
-        for (; dp2 < d2end; dp2++) {
-          s0 = sp2[0];
-          dp2[0] = s0 >> 16;
-          sp2++;
-        }
-        break;
-
-      case 1:
-#pragma pipeloop(0)
-        for (; dp2 < d2end; dp2++) {
-          s0 = sp2[0];
-          dp2[0] = s0 >> 8;
-          sp2++;
-        }
-        break;
-
-      case 2:
-#pragma pipeloop(0)
-        for (; dp2 < d2end; dp2++) {
-          s0 = sp2[0];
-          dp2[0] = s0;
-          sp2++;
-        }
-        break;
-    }
-
-    sp = (mlib_u8 *)sp2 + off;
-    dp = (mlib_u8 *)dp2;
-    if (dp < dend) {
-      *dp++ = sp[0];
-    }
-
-    sp = sl += slb;
-    dp = dl += dlb;
-  }
-}
-
-/***************************************************************/
-
-void mlib_v_ImageChannelExtract_32_2_1(mlib_f32 *sp, mlib_s32 slb,
-                                       mlib_f32 *dp, mlib_s32 dlb,
-                                       mlib_s32 width, mlib_s32 height)
-{
-  mlib_d64  *sp2;
-  int       i, j, off;
-
-  for (j = 0; j < height; j++) {
-
-    if (((mlib_addr)sp & 7) == 0) {
-      sp2 = (mlib_d64 *)sp;
-#pragma pipeloop(0)
-      for (i = 0; i < width; i++) {
-        d64_2_f32 d;
-        d.d64 = sp2[i];
-        dp[i] = d.f32s.f0;
-      }
-    } else {
-      sp2 = (mlib_d64 *)(sp - 1);
-#pragma pipeloop(0)
-      for (i = 0; i < width; i++) {
-        d64_2_f32 d;
-        d.d64 = sp2[i];
-        dp[i] = d.f32s.f1;
-      }
-    }
-
-    sp += slb;
-    dp += dlb;
-  }
-}
-
-/***************************************************************/
-
-void mlib_v_ImageChannelExtract_32_3_1(mlib_f32 *sl, mlib_s32 slb,
-                                       mlib_f32 *dl, mlib_s32 dlb,
-                                       mlib_s32 width, mlib_s32 height)
-{
-  mlib_f32  *sp = sl;
-  mlib_f32  *dp = dl;
-  mlib_d64  *sp2;
-  d64_2_f32 d0;
-  int       i, j, off;
-
-  for (j = 0; j < height; j++) {
-    mlib_f32 *dend = dl + width;
-
-    if ((mlib_addr)sp & 7) {
-      dp[0] = sp[0];
-      sp += 3;
-      dp ++;
-    }
-
-    sp2 = (mlib_d64 *)sp;
-#pragma pipeloop(0)
-    for (; dp <= (dend-2); dp += 2) {
-      d64_2_f32 d0, d1;
-      d0.d64 = sp2[0];
-      d1.d64 = sp2[1];
-      dp[0] = d0.f32s.f0;
-      dp[1] = d1.f32s.f1;
-      sp2 += 3;
-    }
-
-    if (dp < dend) {
-      d0.d64 = sp2[0];
-      dp[0] = d0.f32s.f0;
-    }
-
-    sp = sl += slb;
-    dp = dl += dlb;
-  }
-}
-
-/***************************************************************/
-
-void mlib_v_ImageChannelExtract_32_3_2(mlib_f32 *sl, mlib_s32 slb,
-                                       mlib_f32 *dl, mlib_s32 dlb,
-                                       mlib_s32 width, mlib_s32 height,
-                                       mlib_s32 count1)
-{
-  mlib_f32  *sp = sl;
-  mlib_f32  *dp = dl;
-  mlib_d64  *sp2;
-  d64_2_f32 d0;
-  int       i, j, off;
-
-  for (j = 0; j < height; j++) {
-    mlib_f32 *dend = dl + 2*width;
-
-    if (count1 == 1) {
-      if (dp < dend) *dp++ = sp[0];
-      sp += 2;
-    }
-
-    if ((mlib_addr)sp & 7) {
-      if (dp < dend) *dp++ = sp[0];
-      if (dp < dend) *dp++ = sp[1];
-      sp += 3;
-    }
-
-    sp2 = (mlib_d64 *)sp;
-#pragma pipeloop(0)
-    for (; dp <= (dend-4); dp += 4) {
-      d64_2_f32 d0, d1, d2;
-      d0.d64 = sp2[0];
-      d1.d64 = sp2[1];
-      d2.d64 = sp2[2];
-      dp[0] = d0.f32s.f0;
-      dp[1] = d0.f32s.f1;
-      dp[2] = d1.f32s.f1;
-      dp[3] = d2.f32s.f0;
-      sp2 += 3;
-    }
-
-    if (dp < dend) {
-      sp = (mlib_f32 *)sp2;
-      *dp++ = sp[0];
-      if (dp < dend) *dp++ = sp[1];
-      if (dp < dend) *dp++ = sp[3];
-    }
-
-    sp = sl += slb;
-    dp = dl += dlb;
-  }
-}
-
-/***************************************************************/
-
-void mlib_v_ImageChannelExtract_32_4_1(mlib_f32 *sp, mlib_s32 slb,
-                                       mlib_f32 *dp, mlib_s32 dlb,
-                                       mlib_s32 width, mlib_s32 height)
-{
-  mlib_d64  *sp2;
-  int       i, j, off;
-
-  for (j = 0; j < height; j++) {
-
-    if (((mlib_addr)sp & 7) == 0) {
-      sp2 = (mlib_d64 *)sp;
-#pragma pipeloop(0)
-      for (i = 0; i < width; i++) {
-        d64_2_f32 d;
-        d.d64 = sp2[2*i];
-        dp[i] = d.f32s.f0;
-      }
-    } else {
-      sp2 = (mlib_d64 *)(sp - 1);
-#pragma pipeloop(0)
-      for (i = 0; i < width; i++) {
-        d64_2_f32 d;
-        d.d64 = sp2[2*i];
-        dp[i] = d.f32s.f1;
-      }
-    }
-
-    sp += slb;
-    dp += dlb;
-  }
-}
-
-/***************************************************************/
-
-void mlib_v_ImageChannelExtract_32_4_2(mlib_f32 *sl, mlib_s32 slb,
-                                       mlib_f32 *dl, mlib_s32 dlb,
-                                       mlib_s32 width, mlib_s32 height,
-                                       mlib_s32 count1)
-{
-  mlib_f32  *sp = sl;
-  mlib_f32  *dp = dl;
-  mlib_d64  *sp2;
-  int       i, j, off;
-  d64_2_f32 d0, d1;
-
-  for (j = 0; j < height; j++) {
-    mlib_f32 *dend = dl + 2*width;
-
-    if (count1 == 1) {
-      dp[0] = sp[0];
-      sp += 3;
-      dp ++;
-    }
-
-    if (((mlib_addr)sp & 7) == 0) {
-      sp2 = (mlib_d64 *)sp;
-#pragma pipeloop(0)
-      for (; dp <= (dend-2); dp += 2) {
-        d64_2_f32 d;
-        d.d64 = sp2[0];
-        dp[0] = d.f32s.f0;
-        dp[1] = d.f32s.f1;
-        sp2 += 2;
-      }
-      if (dp < dend) {
-        d0.d64 = sp2[0];
-        dp[0] = d0.f32s.f0;
-      }
-    } else {
-      sp2 = (mlib_d64 *)(sp - 1);
-#pragma pipeloop(0)
-      for (; dp <= (dend-2); dp += 2) {
-        d64_2_f32 d0, d1;
-        d0.d64 = sp2[0];
-        d1.d64 = sp2[1];
-        dp[0] = d0.f32s.f1;
-        dp[1] = d1.f32s.f0;
-        sp2 += 2;
-      }
-      if (dp < dend) {
-        d0.d64 = sp2[0];
-        dp[0] = d0.f32s.f1;
-      }
-    }
-
-    sp = sl += slb;
-    dp = dl += dlb;
-  }
-}
-
-/***************************************************************/
-
-void mlib_v_ImageChannelExtract_32_4_3(mlib_f32 *sl, mlib_s32 slb,
-                                       mlib_f32 *dl, mlib_s32 dlb,
-                                       mlib_s32 width, mlib_s32 height,
-                                       mlib_s32 count1)
-{
-  mlib_f32  *sp = sl;
-  mlib_f32  *dp = dl;
-  mlib_d64  *sp2;
-  int       i, j, k;
-  d64_2_f32 d0, d1;
-
-  for (j = 0; j < height; j++) {
-    mlib_f32 *dend = dl + 3*width;
-
-    for (k = 0; k < count1; k++) {
-      if (dp < dend) *dp++ = *sp++;
-    }
-    sp++;
-
-    if (((mlib_addr)sp & 7) == 0) {
-      sp2 = (mlib_d64 *)sp;
-#pragma pipeloop(0)
-      for (; dp <= (dend-3); dp += 3) {
-        d64_2_f32 d0, d1;
-        d0.d64 = sp2[0];
-        d1.d64 = sp2[1];
-        dp[0] = d0.f32s.f0;
-        dp[1] = d0.f32s.f1;
-        dp[2] = d1.f32s.f0;
-        sp2 += 2;
-      }
-      if (dp < dend) {
-        d0.d64 = sp2[0];
-        *dp++ = d0.f32s.f0;
-        if (dp < dend) *dp++ = d0.f32s.f1;
-      }
-    } else {
-      sp2 = (mlib_d64 *)(sp - 1);
-#pragma pipeloop(0)
-      for (; dp <= (dend-3); dp += 3) {
-        d64_2_f32 d0, d1;
-        d0.d64 = sp2[0];
-        d1.d64 = sp2[1];
-        dp[0] = d0.f32s.f1;
-        dp[1] = d1.f32s.f0;
-        dp[2] = d1.f32s.f1;
-        sp2 += 2;
-      }
-      if (dp < dend) {
-        d0.d64 = sp2[0];
-        d1.d64 = sp2[1];
-        *dp++ = d0.f32s.f1;
-        if (dp < dend) *dp++ = d1.f32s.f0;
-      }
-    }
-
-    sp = sl += slb;
-    dp = dl += dlb;
-  }
-}
-
-/***************************************************************/
-/* general channel extraction: slower due to the inner loop */
-
-void mlib_v_ImageChannelExtract_U8(mlib_u8  *src, mlib_s32 slb,
-                              mlib_u8  *dst, mlib_s32 dlb,
-                              mlib_s32 channels, mlib_s32 channeld,
-                              mlib_s32 width, mlib_s32 height,
-                              mlib_s32 cmask)
-{
-  mlib_u8   *sp;              /* pointer for pixel in src */
-  mlib_u8   *sl;              /* pointer for line in src  */
-  mlib_u8   *dp;              /* pointer for pixel in dst */
-  mlib_u8   *dl;              /* pointer for line in dst  */
-  int       i, j, k;          /* indices for x, y, channel */
-  int       deltac[5] = { 0, 1, 1, 1, 1 };
-  int       inc0, inc1, inc2, inc3;
-  mlib_u8   s0, s1, s2, s3;
-
-  deltac[channeld] = 1;
-  for (i = (channels - 1), k = 0; i >= 0; i--) {
-    if ((cmask & (1 << i)) == 0)
-      deltac[k]++;
-    else
-      k++;
-  }
-
-  deltac[channeld] = channels;
-  for (i = 1; i < channeld; i++) {
-    deltac[channeld] -= deltac[i];
-  }
-
-  sp = sl = src + deltac[0];
-  dp = dl = dst;
-
-/* Only THREE CHANNEL CASE could be executed here!!! */
-
-  inc0 = deltac[1];
-  inc1 = deltac[2] + inc0;
-  inc2 = deltac[3] + inc1;
-  for (j = 0; j < height; j++) {
-    for (i = 0; i < width; i++) {
-#pragma pipeloop(0)
-      s0 = sp[0]; s1 = sp[inc0]; s2 = sp[inc1];
-      dp[0] = s0;
-      dp[1] = s1;
-      dp[2] = s2;
-      sp   += inc2;
-      dp   += 3;
-    }
-    sp = sl += slb;
-    dp = dl += dlb;
-  }
-}
-
-/***************************************************************/
-/* general channel extraction: slower due to the inner loop */
-
-void mlib_v_ImageChannelExtract_S16(mlib_u16 *src,    mlib_s32 slb,
-                                    mlib_u16 *dst,    mlib_s32 dlb,
-                                    mlib_s32 channels, mlib_s32 channeld,
-                                    mlib_s32 width,    mlib_s32 height,
-                                    mlib_s32 cmask)
-{
-  mlib_u16   *sp;              /* pointer for pixel in src */
-  mlib_u16   *sl;              /* pointer for line in src  */
-  mlib_u16   *dp;              /* pointer for pixel in dst */
-  mlib_u16   *dl;              /* pointer for line in dst  */
-  int       i, j, k;          /* indices for x, y, channel */
-  int       deltac[5] = { 0, 1, 1, 1, 1 };
-  int       inc0, inc1, inc2, inc3;
-  mlib_u16   s0, s1, s2, s3;
-
-  slb >>= 1;
-  dlb >>= 1;
-
-  deltac[channeld] = 1;
-  for (i = (channels - 1), k = 0; i >= 0; i--) {
-    if ((cmask & (1 << i)) == 0)
-      deltac[k]++;
-    else
-      k++;
-  }
-
-  deltac[channeld] = channels;
-  for (i = 1; i < channeld; i++) {
-    deltac[channeld] -= deltac[i];
-  }
-
-  sp = sl = src + deltac[0];
-  dp = dl = dst;
-
-  if (channeld == 2) {
-    inc0 = deltac[1];
-    inc1 = deltac[2] + inc0;
-    for (j = 0; j < height; j++) {
-#pragma pipeloop(0)
-      for (i = 0; i < width; i++) {
-        s0 = sp[0]; s1 = sp[inc0];
-        dp[0] = s0;
-        dp[1] = s1;
-        sp   += inc1;
-        dp   += 2;
-      }
-      sp = sl = sl + slb;
-      dp = dl = dl + dlb;
-    }
-  } else
-
-  if (channeld == 3) {
-    inc0 = deltac[1];
-    inc1 = deltac[2] + inc0;
-    inc2 = deltac[3] + inc1;
-    for (j = 0; j < height; j++) {
-      for (i = 0; i < width; i++) {
-#pragma pipeloop(0)
-        s0 = sp[0]; s1 = sp[inc0]; s2 = sp[inc1];
-        dp[0] = s0;
-        dp[1] = s1;
-        dp[2] = s2;
-        sp   += inc2;
-        dp   += 3;
-      }
-      sp = sl = sl + slb;
-      dp = dl = dl + dlb;
-    }
-  }}
-
-/***************************************************************/
-/* general channel extraction: slower due to the inner loop */
-
-void mlib_v_ImageChannelExtract_D64(mlib_d64 *src,    mlib_s32 slb,
-                                    mlib_d64 *dst,    mlib_s32 dlb,
-                                    mlib_s32 channels, mlib_s32 channeld,
-                                    mlib_s32 width,    mlib_s32 height,
-                                    mlib_s32 cmask)
-{
-  mlib_d64   *sp;              /* pointer for pixel in src */
-  mlib_d64   *sl;              /* pointer for line in src  */
-  mlib_d64   *dp;              /* pointer for pixel in dst */
-  mlib_d64   *dl;              /* pointer for line in dst  */
-  int        i, j, k;          /* indices for x, y, channel */
-  int        deltac[5] = { 0, 1, 1, 1, 1 };
-  int        inc0, inc1, inc2, inc3;
-  mlib_d64   s0, s1, s2, s3;
-
-  deltac[channeld] = 1;
-  for (i = (channels - 1), k = 0; i >= 0; i--) {
-    if ((cmask & (1 << i)) == 0)
-      deltac[k]++;
-    else
-      k++;
-  }
-
-  deltac[channeld] = channels;
-  for (i = 1; i < channeld; i++) {
-    deltac[channeld] -= deltac[i];
-  }
-
-  sp = sl = src + deltac[0];
-  dp = dl = dst;
-
-  if (channeld == 1) {
-    for (j = 0; j < height; j++) {
-#pragma pipeloop(0)
-      for (i = 0; i < width; i++) {
-        s0 = sp[0];
-        dp[i] = s0;
-        sp   += channels;
-      }
-      sp = sl = (mlib_d64 *)((mlib_u8 *)sl + slb);
-      dp = dl = (mlib_d64 *)((mlib_u8 *)dl + dlb);
-    }
-  } else
-
-  if (channeld == 2) {
-    inc0 = deltac[1];
-    inc1 = deltac[2] + inc0;
-    for (j = 0; j < height; j++) {
-#pragma pipeloop(0)
-      for (i = 0; i < width; i++) {
-        s0 = sp[0]; s1 = sp[inc0];
-        dp[0] = s0;
-        dp[1] = s1;
-        sp   += inc1;
-        dp   += 2;
-      }
-      sp = sl = (mlib_d64 *)((mlib_u8 *)sl + slb);
-      dp = dl = (mlib_d64 *)((mlib_u8 *)dl + dlb);
-    }
-  } else
-
-  if (channeld == 3) {
-    inc0 = deltac[1];
-    inc1 = deltac[2] + inc0;
-    inc2 = deltac[3] + inc1;
-    for (j = 0; j < height; j++) {
-      for (i = 0; i < width; i++) {
-#pragma pipeloop(0)
-        s0 = sp[0]; s1 = sp[inc0]; s2 = sp[inc1];
-        dp[0] = s0;
-        dp[1] = s1;
-        dp[2] = s2;
-        sp   += inc2;
-        dp   += 3;
-      }
-      sp = sl = (mlib_d64 *)((mlib_u8 *)sl + slb);
-      dp = dl = (mlib_d64 *)((mlib_u8 *)dl + dlb);
-    }
-  }
-}
--- a/jdk/src/java.desktop/unix/native/libmlib_image/mlib_v_ImageChannelInsert.c	Thu May 19 17:48:02 2016 +0000
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,715 +0,0 @@
-/*
- * Copyright (c) 1998, 2003, 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.
- */
-
-
-
-
-/*
- * FUNCTIONS
- *      mlib_ImageChannelInsert   - Copy the source image into the selected
- *                                                        channels of the destination image
- *
- * SYNOPSIS
- *      mlib_status mlib_ImageChannelInsert(mlib_image *dst,
- *                                                                        mlib_image *src,
- *                                                                      mlib_s32   cmask);
- *
- * ARGUMENT
- *  dst     Pointer to destination image.
- *  src     Pointer to source image.
- *  cmask   Destination channel selection mask.
- *              The least significant bit (LSB) is corresponding to the
- *              last channel in the destination image data.
- *              The bits with value 1 stand for the channels selected.
- *              If more than N channels are selected, the leftmost N
- *              channels are inserted, where N is the number of channels
- *              in the source image.
- *
- * RESTRICTION
- *              The src and dst must have the same width, height and data type.
- *              The src and dst can have 1, 2, 3 or 4 channels.
- *              The src and dst can be either MLIB_BYTE, MLIB_SHORT, MLIB_INT,
- *          MLIB_FLOAT or MLIB_DOUBLE.
- *
- * DESCRIPTION
- *          Copy the source image into the selected channels of the destination
- *              image
- */
-
-#include <stdlib.h>
-#include "mlib_image.h"
-#include "mlib_ImageCheck.h"
-
-/***************************************************************/
-/* functions defined in mlib_v_ImageChannelInsert_1.c */
-
-void
-mlib_v_ImageChannelInsert_U8(mlib_u8  *src,  mlib_s32 slb,
-                             mlib_u8  *dst,  mlib_s32 dlb,
-                             mlib_s32 channels,
-                             mlib_s32 channeld,
-                             mlib_s32 width,  mlib_s32 height,
-                             mlib_s32 cmask);
-void
-mlib_v_ImageChannelInsert_D64(mlib_d64  *src,  mlib_s32 slb,
-                              mlib_d64  *dst,  mlib_s32 dlb,
-                              mlib_s32 channels,
-                              mlib_s32 channeld,
-                              mlib_s32 width,  mlib_s32 height,
-                              mlib_s32 cmask);
-void
-mlib_v_ImageChannelInsert_S16(mlib_s16 *src,  mlib_s32 slb,
-                              mlib_s16 *dst,  mlib_s32 dlb,
-                              mlib_s32 channels,
-                              mlib_s32 channeld,
-                              mlib_s32 width,  mlib_s32 height,
-                              mlib_s32 cmask);
-void
-mlib_v_ImageChannelInsert_S32(mlib_s32 *src,  mlib_s32 slb,
-                              mlib_s32 *dst,  mlib_s32 dlb,
-                              mlib_s32 channels,
-                              mlib_s32 channeld,
-                              mlib_s32 width,  mlib_s32 height,
-                              mlib_s32 cmask);
-void
-mlib_v_ImageChannelInsert_U8_12_A8D1X8(mlib_u8  *src,
-                                                               mlib_u8  *dst,
-                                                         mlib_s32 dsize,
-                                                         mlib_s32 cmask);
-void
-mlib_v_ImageChannelInsert_U8_12_A8D2X8(mlib_u8  *src,  mlib_s32 slb,
-                                                               mlib_u8  *dst,  mlib_s32 dlb,
-                                                       mlib_s32 xsize, mlib_s32 ysize,
-                                                               mlib_s32 cmask);
-void
-mlib_v_ImageChannelInsert_U8_12_D1(mlib_u8  *src,
-                                                           mlib_u8  *dst,
-                                                   mlib_s32 dsize,
-                                                           mlib_s32 cmask);
-void
-mlib_v_ImageChannelInsert_U8_12(mlib_u8  *src,  mlib_s32 slb,
-                                                        mlib_u8  *dst,  mlib_s32 dlb,
-                                                mlib_s32 xsize, mlib_s32 ysize,
-                                                        mlib_s32 cmask);
-void
-mlib_v_ImageChannelInsert_U8_13_A8D1X8(mlib_u8  *src,
-                                                               mlib_u8  *dst,
-                                                       mlib_s32 dsize,
-                                                               mlib_s32 cmask);
-void
-mlib_v_ImageChannelInsert_U8_13_A8D2X8(mlib_u8  *src,  mlib_s32 slb,
-                                                               mlib_u8  *dst,  mlib_s32 dlb,
-                                                         mlib_s32 xsize, mlib_s32 ysize,
-                                                               mlib_s32 cmask);
-void
-mlib_v_ImageChannelInsert_U8_13_D1(mlib_u8  *src,
-                                                           mlib_u8  *dst,
-                                                     mlib_s32 dsize,
-                                                           mlib_s32 cmask);
-void
-mlib_v_ImageChannelInsert_U8_13(mlib_u8  *src,  mlib_s32 slb,
-                                                        mlib_u8  *dst,  mlib_s32 dlb,
-                                                  mlib_s32 xsize, mlib_s32 ysize,
-                                                        mlib_s32 cmask);
-void
-mlib_v_ImageChannelInsert_U8_14_A8D1X8(mlib_u8  *src,
-                                                               mlib_u8  *dst,
-                                                       mlib_s32 dsize,
-                                                               mlib_s32 cmask);
-void
-mlib_v_ImageChannelInsert_U8_14_A8D2X8(mlib_u8  *src,  mlib_s32 slb,
-                                                               mlib_u8  *dst,  mlib_s32 dlb,
-                                                       mlib_s32 xsize, mlib_s32 ysize,
-                                                               mlib_s32 cmask);
-void
-mlib_v_ImageChannelInsert_U8_14_D1(mlib_u8  *src,
-                                                           mlib_u8  *dst,
-                                                   mlib_s32 dsize,
-                                                           mlib_s32 cmask);
-void
-mlib_v_ImageChannelInsert_U8_14(mlib_u8  *src,  mlib_s32 slb,
-                                                        mlib_u8  *dst,  mlib_s32 dlb,
-                                                mlib_s32 xsize, mlib_s32 ysize,
-                                                        mlib_s32 cmask);
-void
-mlib_v_ImageChannelInsert_S16_12_A8D1X4(mlib_s16 *src,
-                                                                      mlib_s16 *dst,
-                                                        mlib_s32 dsize,
-                                                                mlib_s32 cmask);
-void
-mlib_v_ImageChannelInsert_S16_12_A8D2X4(mlib_s16 *src,  mlib_s32 slb,
-                                                                      mlib_s16 *dst,  mlib_s32 dlb,
-                                                        mlib_s32 xsize, mlib_s32 ysize,
-                                                                mlib_s32 cmask);
-void
-mlib_v_ImageChannelInsert_S16_12_D1(mlib_s16 *src,
-                                                            mlib_s16 *dst,
-                                                    mlib_s32 dsize,
-                                                            mlib_s32 cmask);
-void
-mlib_v_ImageChannelInsert_S16_12(mlib_s16 *src,  mlib_s32 slb,
-                                                        mlib_s16 *dst,  mlib_s32 dlb,
-                                                  mlib_s32 xsize, mlib_s32 ysize,
-                                                  mlib_s32 cmask);
-void
-mlib_v_ImageChannelInsert_S16_13_A8D1X4(mlib_s16 *src,
-                                                                      mlib_s16 *dst,
-                                                        mlib_s32 dsize,
-                                                                mlib_s32 cmask);
-void
-mlib_v_ImageChannelInsert_S16_13_A8D2X4(mlib_s16 *src,  mlib_s32 slb,
-                                                                      mlib_s16 *dst,  mlib_s32 dlb,
-                                                        mlib_s32 xsize, mlib_s32 ysize,
-                                                                mlib_s32 cmask);
-void
-mlib_v_ImageChannelInsert_S16_13_D1(mlib_s16 *src,
-                                                            mlib_s16 *dst,
-                                                    mlib_s32 dsize,
-                                                            mlib_s32 cmask);
-void
-mlib_v_ImageChannelInsert_S16_13(mlib_s16 *src,  mlib_s32 slb,
-                                                         mlib_s16 *dst,  mlib_s32 dlb,
-                                                 mlib_s32 xsize, mlib_s32 ysize,
-                                                         mlib_s32 cmask);
-void
-mlib_v_ImageChannelInsert_S16_14_A8D1X4(mlib_s16 *src,
-                                                                      mlib_s16 *dst,
-                                                          mlib_s32 dsize,
-                                                                      mlib_s32 cmask);
-void
-mlib_v_ImageChannelInsert_S16_14_A8D2X4(mlib_s16 *src,  mlib_s32 slb,
-                                                                      mlib_s16 *dst,  mlib_s32 dlb,
-                                                          mlib_s32 xsize, mlib_s32 ysize,
-                                                                      mlib_s32 cmask);
-void
-mlib_v_ImageChannelInsert_S16_14_D1(mlib_s16 *src,
-                                                            mlib_s16 *dst,
-                                                    mlib_s32 dsize,
-                                                            mlib_s32 cmask);
-void
-mlib_v_ImageChannelInsert_S16_14(mlib_s16 *src,  mlib_s32 slb,
-                                                         mlib_s16 *dst,  mlib_s32 dlb,
-                                                 mlib_s32 xsize, mlib_s32 ysize,
-                                                         mlib_s32 cmask);
-
-/***************************************************************/
-/* functions defined in mlib_v_ImageChannelInsert_34.c */
-
-void
-mlib_v_ImageChannelInsert_U8_34R_A8D1X8(mlib_u8  *src,
-                                                                mlib_u8  *dst,
-                                                                mlib_s32 dsize);
-void
-mlib_v_ImageChannelInsert_U8_34R_A8D2X8(mlib_u8  *src,  mlib_s32 slb,
-                                                                mlib_u8  *dst,  mlib_s32 dlb,
-                                                                mlib_s32 xsize, mlib_s32 ysize);
-void
-mlib_v_ImageChannelInsert_U8_34R_D1(mlib_u8  *src,
-                                                            mlib_u8  *dst,
-                                                            mlib_s32 dsize);
-void
-mlib_v_ImageChannelInsert_U8_34R(mlib_u8  *src,  mlib_s32 slb,
-                                                 mlib_u8  *dst,  mlib_s32 dlb,
-                                                         mlib_s32 xsize, mlib_s32 ysize);
-void
-mlib_v_ImageChannelInsert_S16_34R_A8D1X4(mlib_s16 *src,
-                                                                 mlib_s16 *dst,
-                                                                 mlib_s32 dsize);
-void
-mlib_v_ImageChannelInsert_S16_34R_A8D2X4(mlib_s16 *src,  mlib_s32 slb,
-                                                                 mlib_s16 *dst,  mlib_s32 dlb,
-                                                                 mlib_s32 xsize, mlib_s32 ysize);
-void
-mlib_v_ImageChannelInsert_S16_34R_D1(mlib_s16 *src,
-                                                             mlib_s16 *dst,
-                                                             mlib_s32 dsize);
-void
-mlib_v_ImageChannelInsert_S16_34R(mlib_s16 *src,  mlib_s32 slb,
-                                                          mlib_s16 *dst,  mlib_s32 dlb,
-                                                          mlib_s32 xsize, mlib_s32 ysize);
-void
-mlib_v_ImageChannelInsert_U8_34L_A8D1X8(mlib_u8  *src,
-                                                                mlib_u8  *dst,
-                                                                mlib_s32 dsize);
-void
-mlib_v_ImageChannelInsert_U8_34L_A8D2X8(mlib_u8  *src,  mlib_s32 slb,
-                                                                mlib_u8  *dst,  mlib_s32 dlb,
-                                                        mlib_s32 xsize, mlib_s32 ysize);
-void
-mlib_v_ImageChannelInsert_U8_34L_D1(mlib_u8  *src,
-                                                            mlib_u8  *dst,
-                                                            mlib_s32 dsize);
-void
-mlib_v_ImageChannelInsert_U8_34L(mlib_u8  *src,  mlib_s32 slb,
-                                                         mlib_u8  *dst,  mlib_s32 dlb,
-                                                         mlib_s32 xsize, mlib_s32 ysize);
-void
-mlib_v_ImageChannelInsert_S16_34L_A8D1X4(mlib_s16 *src,
-                                                                 mlib_s16 *dst,
-                                                                 mlib_s32 dsize);
-void
-mlib_v_ImageChannelInsert_S16_34L_A8D2X4(mlib_s16 *src,  mlib_s32 slb,
-                                                                 mlib_s16 *dst,  mlib_s32 dlb,
-                                                                 mlib_s32 xsize, mlib_s32 ysize);
-void
-mlib_v_ImageChannelInsert_S16_34L_D1(mlib_s16 *src,
-                                                             mlib_s16 *dst,
-                                                             mlib_s32 dsize);
-void
-mlib_v_ImageChannelInsert_S16_34L(mlib_s16 *src,  mlib_s32 slb,
-                                                          mlib_s16 *dst,  mlib_s32 dlb,
-                                                          mlib_s32 xsize, mlib_s32 ysize);
-
-
-/***************************************************************/
-
-#ifdef MLIB_TEST
-mlib_status
-mlib_v_ImageChannelInsert(mlib_image *dst,
-                                            mlib_image *src,
-                                          mlib_s32   cmask)
-#else
-mlib_status
-mlib_ImageChannelInsert(mlib_image *dst,
-                                        mlib_image *src,
-                                        mlib_s32   cmask)
-#endif
-{
-  const mlib_s32  X8 = 0x7;
-  const mlib_s32  X4 = 0x3;
-  const mlib_s32  X2 = 0x1;
-  const mlib_s32  A8D1   = MLIB_IMAGE_ALIGNED8 | MLIB_IMAGE_ONEDVECTOR;
-  const mlib_s32  A8D2X8 = MLIB_IMAGE_ALIGNED8 | MLIB_IMAGE_STRIDE8X | MLIB_IMAGE_WIDTH8X;
-  const mlib_s32  A8D2X4 = MLIB_IMAGE_ALIGNED8 | MLIB_IMAGE_STRIDE8X | MLIB_IMAGE_WIDTH4X;
-  const mlib_s32  A8D2X2 = MLIB_IMAGE_ALIGNED8 | MLIB_IMAGE_STRIDE8X | MLIB_IMAGE_WIDTH2X;
-
-  void      *sp;                      /* pointer for pixel in src */
-  void      *dp;                      /* pointer for pixel in dst */
-  mlib_s32  ncmask = 0;         /* normalized channel mask */
-  mlib_s32  channels;             /* number of channels for src */
-  mlib_s32  channeld;             /* number of channels for dst */
-  mlib_s32  width, height;/* for src and dst */
-  mlib_s32  strides;              /* strides in bytes for src */
-  mlib_s32  strided;            /* strides in bytes for dst */
-  mlib_s32  flags;
-  mlib_s32  flagd;
-  mlib_s32  dsize;
-  int         i, bit1count = 0;
-
-  MLIB_IMAGE_CHECK(src);
-  MLIB_IMAGE_CHECK(dst);
-  MLIB_IMAGE_TYPE_EQUAL(src,dst);
-  MLIB_IMAGE_SIZE_EQUAL(src,dst);
-
-  channels = mlib_ImageGetChannels(src);
-  channeld = mlib_ImageGetChannels(dst);
-  width    = mlib_ImageGetWidth(src);
-  height   = mlib_ImageGetHeight(src);
-  strides  = mlib_ImageGetStride(src);
-  strided  = mlib_ImageGetStride(dst);
-  sp       = mlib_ImageGetData(src);
-  dp       = mlib_ImageGetData(dst);
-  flags    = mlib_ImageGetFlags(src);
-  flagd    = mlib_ImageGetFlags(dst);
-  dsize    = width * height;
-
-  /* normalize the cmask, and count the number of bit with value 1 */
-  for (i = (channeld - 1); i >= 0; i--) {
-    if (((cmask & (1 << i)) != 0) && (bit1count < channels)) {
-      ncmask += (1 << i);
-      bit1count++;
-    }
-  }
-
-  /* do not support the cases in which the number of selected channels is
-   * less than the nubmber of channels in the source image */
-  if (bit1count < channels) {
-    return MLIB_FAILURE;
-  }
-
-  if (((channels == 1) && (channeld == 1)) ||
-      ((channels == 2) && (channeld == 2)) ||
-      ((channels == 3) && (channeld == 3)) ||
-      ((channels == 4) && (channeld == 4))) {
-      return mlib_ImageCopy(dst, src);
-  }
-
-  switch (mlib_ImageGetType(src)) {
-    case MLIB_BYTE:
-      if (channels == 1) {
-        switch (channeld) {
-          case 2:
-            if (((flags & A8D1) == 0) &&
-                ((flagd & A8D1) == 0) &&
-                ((dsize & X8)   == 0)) {
-                mlib_v_ImageChannelInsert_U8_12_A8D1X8((mlib_u8 *)sp,
-                                                                             (mlib_u8 *)dp,
-                                                                             dsize,
-                                                                                     ncmask);
-            }
-            else if (((flags & A8D2X8) == 0) &&
-              ((flagd & A8D2X8) == 0)) {
-              mlib_v_ImageChannelInsert_U8_12_A8D2X8((mlib_u8 *)sp, strides,
-                                                                             (mlib_u8 *)dp, strided,
-                                                                             width, height,
-                                                                                     ncmask);
-            }
-            else if (((flags & MLIB_IMAGE_ONEDVECTOR) == 0) &&
-               ((flagd & MLIB_IMAGE_ONEDVECTOR) == 0)) {
-                mlib_v_ImageChannelInsert_U8_12_D1((mlib_u8 *)sp,
-                                                                                 (mlib_u8 *)dp,
-                                                                                 dsize,
-                                                                                 ncmask);
-            }
-            else {
-                mlib_v_ImageChannelInsert_U8_12((mlib_u8 *)sp, strides,
-                                                                      (mlib_u8 *)dp, strided,
-                                                                      width, height,
-                                                                              ncmask);
-            }
-            break;
-
-          case 3:
-            if (((flags & A8D1) == 0) &&
-                ((flagd & A8D1) == 0) &&
-                ((dsize & X8)   == 0)) {
-                mlib_v_ImageChannelInsert_U8_13_A8D1X8((mlib_u8 *)sp,
-                                                                                 (mlib_u8 *)dp,
-                                                                               dsize,
-                                                                                           ncmask);
-            }
-            else if (((flags & A8D2X8) == 0) &&
-              ((flagd & A8D2X8) == 0)) {
-                mlib_v_ImageChannelInsert_U8_13_A8D2X8((mlib_u8 *)sp, strides,
-                                                                                     (mlib_u8 *)dp, strided,
-                                                                             width, height,
-                                                                                     ncmask);
-            }
-            else if (((flags & MLIB_IMAGE_ONEDVECTOR) == 0) &&
-               ((flagd & MLIB_IMAGE_ONEDVECTOR) == 0)) {
-                mlib_v_ImageChannelInsert_U8_13_D1((mlib_u8 *)sp,
-                                                                                 (mlib_u8 *)dp,
-                                                                                 dsize,
-                                                                                 ncmask);
-            }
-            else {
-              mlib_v_ImageChannelInsert_U8_13((mlib_u8 *)sp, strides,
-                                                                      (mlib_u8 *)dp, strided,
-                                                                      width, height,
-                                                                      ncmask);
-            }
-            break;
-
-          case 4:
-            if (((flags & A8D1) == 0) &&
-                ((flagd & A8D1) == 0) &&
-                ((dsize & X8)   == 0)) {
-                  mlib_v_ImageChannelInsert_U8_14_A8D1X8((mlib_u8 *)sp,
-                                                                                   (mlib_u8 *)dp,
-                                                                                 dsize,
-                                                                                             ncmask);
-            }
-            else if (((flags & A8D2X8) == 0) &&
-               ((flagd & A8D2X8) == 0)) {
-               mlib_v_ImageChannelInsert_U8_14_A8D2X8((mlib_u8 *)sp, strides,
-                                                                      (mlib_u8 *)dp, strided,
-                                                                              width, height,
-                                                                                          ncmask);
-            }
-            else if (((flags & MLIB_IMAGE_ONEDVECTOR) == 0) &&
-              ((flagd & MLIB_IMAGE_ONEDVECTOR) == 0)) {
-                mlib_v_ImageChannelInsert_U8_14_D1((mlib_u8 *)sp,
-                                                                                 (mlib_u8 *)dp,
-                                                                                 dsize,
-                                                                                 ncmask);
-            }
-            else {
-              mlib_v_ImageChannelInsert_U8_14((mlib_u8 *)sp, strides,
-                                                                      (mlib_u8 *)dp, strided,
-                                                                      width, height,
-                                                                      ncmask);
-            }
-            break;
-
-          default:
-            return MLIB_FAILURE;
-        }
-      }
-      else {
-        if ((channels == 3) && (channeld == 4) && (ncmask == 7)) {
-          if (((flags & A8D1) == 0) &&
-            ((flagd & A8D1) == 0) &&
-            ((dsize & X8)   == 0)) {
-            mlib_v_ImageChannelInsert_U8_34R_A8D1X8((mlib_u8 *)sp,
-                                                                          (mlib_u8 *)dp,
-                                                                          dsize);
-          }
-        else if (((flags & A8D2X8) == 0) &&
-               ((flagd & A8D2X8) == 0)) {
-              mlib_v_ImageChannelInsert_U8_34R_A8D2X8((mlib_u8 *)sp, strides,
-                                                                                    (mlib_u8 *)dp, strided,
-                                                                              width, height);
-        }
-        else if (((flags & MLIB_IMAGE_ONEDVECTOR) == 0) &&
-               ((flagd & MLIB_IMAGE_ONEDVECTOR) == 0)) {
-              mlib_v_ImageChannelInsert_U8_34R_D1((mlib_u8 *)sp,
-                                                                          (mlib_u8 *)dp,
-                                                                          dsize);
-        }
-        else {
-              mlib_v_ImageChannelInsert_U8_34R((mlib_u8 *)sp, strides,
-                                                                      (mlib_u8 *)dp, strided,
-                                                                      width, height);
-        }
-      }
-      else if ((channels == 3) && (channeld == 4) && (ncmask == 14)) {
-        if (((flags & A8D1) == 0) &&
-            ((flagd & A8D1) == 0) &&
-            ((dsize & X8)   == 0)) {
-            mlib_v_ImageChannelInsert_U8_34L_A8D1X8((mlib_u8 *)sp,
-                                                                            (mlib_u8 *)dp,
-                                                                          dsize);
-              }
-        else if (((flags & A8D2X8) == 0) &&
-                 ((flagd & A8D2X8) == 0)) {
-                 mlib_v_ImageChannelInsert_U8_34L_A8D2X8((mlib_u8 *)sp, strides,
-                                                                                  (mlib_u8 *)dp, strided,
-                                                                          width, height);
-        }
-        else if (((flags & MLIB_IMAGE_ONEDVECTOR) == 0) &&
-                 ((flagd & MLIB_IMAGE_ONEDVECTOR) == 0)) {
-                 mlib_v_ImageChannelInsert_U8_34L_D1((mlib_u8 *)sp,
-                                                                      (mlib_u8 *)dp,
-                                                                      dsize);
-        }
-        else mlib_v_ImageChannelInsert_U8_34L((mlib_u8 *)sp, strides,
-                                                                   (mlib_u8 *)dp, strided,
-                                                                   width, height);
-        }
-      else {
-
-      mlib_v_ImageChannelInsert_U8((mlib_u8 *)sp, strides,
-                                                     (mlib_u8 *)dp, strided,
-                                                     channels, channeld,
-                                                     width, height,
-                                                     ncmask);
-      }
-  }
-  break;
-
-    case MLIB_SHORT:
-      if (channels == 1) {
-        switch (channeld) {
-          case 2:
-            if (((flags & A8D1) == 0) &&
-                ((flagd & A8D1) == 0) &&
-                ((dsize & X4)   == 0)) {
-              mlib_v_ImageChannelInsert_S16_12_A8D1X4((mlib_s16 *)sp,
-                                                                                    (mlib_s16 *)dp,
-                                                                                      dsize,
-                                                                                      ncmask);
-            }
-            else if (((flags & A8D2X4) == 0) &&
-               ((flagd & A8D2X4) == 0)) {
-              mlib_v_ImageChannelInsert_S16_12_A8D2X4((mlib_s16 *)sp, strides,
-                                                                              (mlib_s16 *)dp, strided,
-                                                                              width, height,
-                                                                                      ncmask);
-            }
-            else if (((flags & MLIB_IMAGE_ONEDVECTOR) == 0) &&
-               ((flagd & MLIB_IMAGE_ONEDVECTOR) == 0)) {
-             mlib_v_ImageChannelInsert_S16_12_D1((mlib_s16 *)sp,
-                                                                           (mlib_s16 *)dp,
-                                                                          dsize,
-                                                                                  ncmask);
-            }
-            else {
-              mlib_v_ImageChannelInsert_S16_12((mlib_s16 *)sp, strides,
-                                                                       (mlib_s16 *)dp, strided,
-                                                                       width, height,
-                                                                       ncmask);
-            }
-            break;
-
-          case 3:
-            if (((flags & A8D1) == 0) &&
-                ((flagd & A8D1) == 0) &&
-                ((dsize & X4)   == 0)) {
-              mlib_v_ImageChannelInsert_S16_13_A8D1X4((mlib_s16 *)sp,
-                                                                              (mlib_s16 *)dp,
-                                                                                      dsize,
-                                                                                      ncmask);
-            }
-            else if (((flags & A8D2X4) == 0) &&
-               ((flagd & A8D2X4) == 0)) {
-              mlib_v_ImageChannelInsert_S16_13_A8D2X4((mlib_s16 *)sp, strides,
-                                                                              (mlib_s16 *)dp, strided,
-                                                                              width, height,
-                                                                                      ncmask);
-            }
-            else if (((flags & MLIB_IMAGE_ONEDVECTOR) == 0) &&
-               ((flagd & MLIB_IMAGE_ONEDVECTOR) == 0)) {
-                mlib_v_ImageChannelInsert_S16_13_D1((mlib_s16 *)sp,
-                                                                                  (mlib_s16 *)dp,
-                                                                                  dsize,
-                                                                                  ncmask);
-            }
-            else {
-              mlib_v_ImageChannelInsert_S16_13((mlib_s16 *)sp, strides,
-                                                                       (mlib_s16 *)dp, strided,
-                                                                       width, height,
-                                                                       ncmask);
-            }
-            break;
-
-          case 4:
-            if (((flags & A8D1) == 0) &&
-                ((flagd & A8D1) == 0) &&
-                ((dsize & X4)   == 0)) {
-              mlib_v_ImageChannelInsert_S16_14_A8D1X4((mlib_s16 *)sp,
-                                                                                    (mlib_s16 *)dp,
-                                                      dsize,
-                                                      ncmask);
-            }
-            else if (((flags & A8D2X4) == 0) &&
-               ((flagd & A8D2X4) == 0)) {
-              mlib_v_ImageChannelInsert_S16_14_A8D2X4((mlib_s16 *)sp, strides,
-                                                                              (mlib_s16 *)dp, strided,
-                                                                              width, height,
-                                                                                      ncmask);
-            }
-            else if (((flags & MLIB_IMAGE_ONEDVECTOR) == 0) &&
-               ((flagd & MLIB_IMAGE_ONEDVECTOR) == 0)) {
-              mlib_v_ImageChannelInsert_S16_14_D1((mlib_s16 *)sp,
-                                                                          (mlib_s16 *)dp,
-                                                                          dsize,
-                                                                                  ncmask);
-            }
-            else {
-              mlib_v_ImageChannelInsert_S16_14((mlib_s16 *)sp, strides,
-                                                                       (mlib_s16 *)dp, strided,
-                                                                       width, height,
-                                                                       ncmask);
-            }
-            break;
-          default:
-            return MLIB_FAILURE;
-        }
-      }
-      else if ((channels == 3) && (channeld == 4) && (ncmask == 7)) {
-        if (((flags & A8D1) == 0) &&
-            ((flagd & A8D1) == 0) &&
-            ((dsize & X4)   == 0)) {
-          mlib_v_ImageChannelInsert_S16_34R_A8D1X4((mlib_s16 *)sp,
-                                                                           (mlib_s16 *)dp,
-                                                                           dsize);
-        }
-        else if (((flags & A8D2X4) == 0) &&
-           ((flagd & A8D2X4) == 0)) {
-          mlib_v_ImageChannelInsert_S16_34R_A8D2X4((mlib_s16 *)sp, strides,
-                                                                           (mlib_s16 *)dp, strided,
-                                                                           width, height);
-        }
-        else if (((flags & MLIB_IMAGE_ONEDVECTOR) == 0) &&
-           ((flagd & MLIB_IMAGE_ONEDVECTOR) == 0)) {
-          mlib_v_ImageChannelInsert_S16_34R_D1((mlib_s16 *)sp,
-                                                                       (mlib_s16 *)dp,
-                                                                       dsize);
-        }
-        else {
-          mlib_v_ImageChannelInsert_S16_34R((mlib_s16 *)sp, strides,
-                                                                    (mlib_s16 *)dp, strided,
-                                                                     width, height);
-        }
-      }
-      else if ((channels == 3) && (channeld == 4) && (ncmask == 14)) {
-        if (((flags & A8D1) == 0) &&
-            ((flagd & A8D1) == 0) &&
-            ((dsize & X4)   == 0)) {
-          mlib_v_ImageChannelInsert_S16_34L_A8D1X4((mlib_s16 *)sp,
-                                                                           (mlib_s16 *)dp,
-                                                                           dsize);
-        }
-        else if (((flags & A8D2X4) == 0) &&
-           ((flagd & A8D2X4) == 0)) {
-          mlib_v_ImageChannelInsert_S16_34L_A8D2X4((mlib_s16 *)sp, strides,
-                                                                           (mlib_s16 *)dp, strided,
-                                                                           width, height);
-        }
-        else if (((flags & MLIB_IMAGE_ONEDVECTOR) == 0) &&
-           ((flagd & MLIB_IMAGE_ONEDVECTOR) == 0)) {
-          mlib_v_ImageChannelInsert_S16_34L_D1((mlib_s16 *)sp,
-                                                                       (mlib_s16 *)dp,
-                                                                       dsize);
-        }
-        else {
-          mlib_v_ImageChannelInsert_S16_34L((mlib_s16 *)sp, strides,
-                                                                    (mlib_s16 *)dp, strided,
-                                                                    width, height);
-        }
-      }
-      else {
-        mlib_v_ImageChannelInsert_S16((mlib_s16 *)sp, strides,
-                                                              (mlib_s16 *)dp, strided,
-                                                              channels,  channeld,
-                                                              width, height,
-                                                              ncmask);
-      }
-      break;
-
-    case MLIB_INT:
-        mlib_v_ImageChannelInsert_S32((mlib_s32 *)sp, strides,
-                                      (mlib_s32 *)dp, strided,
-                                      channels, channeld,
-                                      width, height,
-                                      ncmask);
-        break;
-
-    case MLIB_FLOAT:
-        mlib_v_ImageChannelInsert_S32((mlib_s32 *)sp, strides,
-                                      (mlib_s32 *)dp, strided,
-                                      channels, channeld,
-                                      width, height,
-                                      ncmask);
-        break;
-
-
-    case MLIB_DOUBLE:
-        mlib_v_ImageChannelInsert_D64((mlib_d64 *)sp, strides,
-                                      (mlib_d64 *)dp, strided,
-                                      channels, channeld,
-                                      width, height,
-                                      ncmask);
-        break;
-
-
-    case MLIB_BIT:
-    default:
-        return MLIB_FAILURE;    /* MLIB_BIT is not supported here */
-  }
-
-  return MLIB_SUCCESS;
-}
-/***************************************************************/
--- a/jdk/src/java.desktop/unix/native/libmlib_image/mlib_v_ImageChannelInsert.h	Thu May 19 17:48:02 2016 +0000
+++ b/jdk/src/java.desktop/unix/native/libmlib_image/mlib_v_ImageChannelInsert.h	Thu May 19 19:46:20 2016 +0000
@@ -32,290 +32,21 @@
 extern "C" {
 #endif /* __cplusplus */
 
-void mlib_v_ImageChannelInsert_U8(const mlib_u8 *src,
-                                  mlib_s32      slb,
-                                  mlib_u8       *dst,
-                                  mlib_s32      dlb,
-                                  mlib_s32      channels,
-                                  mlib_s32      channeld,
-                                  mlib_s32      width,
-                                  mlib_s32      height,
-                                  mlib_s32      cmask);
-
-void mlib_v_ImageChannelInsert_D64(const mlib_d64 *src,
-                                   mlib_s32       slb,
-                                   mlib_d64       *dst,
-                                   mlib_s32       dlb,
-                                   mlib_s32       channels,
-                                   mlib_s32       channeld,
-                                   mlib_s32       width,
-                                   mlib_s32       height,
-                                   mlib_s32       cmask);
-
-void mlib_v_ImageChannelInsert_S16(const mlib_s16 *src,
-                                   mlib_s32       slb,
-                                   mlib_s16       *dst,
-                                   mlib_s32       dlb,
-                                   mlib_s32       channels,
-                                   mlib_s32       channeld,
-                                   mlib_s32       width,
-                                   mlib_s32       height,
-                                   mlib_s32       cmask);
-
-void mlib_v_ImageChannelInsert_S32(const mlib_s32 *src,
-                                   mlib_s32       slb,
-                                   mlib_s32       *dst,
-                                   mlib_s32       dlb,
-                                   mlib_s32       channels,
-                                   mlib_s32       channeld,
-                                   mlib_s32       width,
-                                   mlib_s32       height,
-                                   mlib_s32       cmask);
-
-void mlib_v_ImageChannelInsert_U8_12_A8D1X8(const mlib_u8 *src,
-                                            mlib_u8       *dst,
-                                            mlib_s32      dsize,
-                                            mlib_s32      cmask);
-
-void mlib_v_ImageChannelInsert_U8_12_A8D2X8(const mlib_u8 *src,
-                                            mlib_s32      slb,
-                                            mlib_u8       *dst,
-                                            mlib_s32      dlb,
-                                            mlib_s32      xsize,
-                                            mlib_s32      ysize,
-                                            mlib_s32      cmask);
-
 void mlib_v_ImageChannelInsert_U8_12_D1(const mlib_u8 *src,
                                         mlib_u8       *dst,
                                         mlib_s32      dsize,
                                         mlib_s32      cmask);
 
-void mlib_v_ImageChannelInsert_U8_12(const mlib_u8 *src,
-                                     mlib_s32      slb,
-                                     mlib_u8       *dst,
-                                     mlib_s32      dlb,
-                                     mlib_s32      xsize,
-                                     mlib_s32      ysize,
-                                     mlib_s32      cmask);
-
-void mlib_v_ImageChannelInsert_U8_13_A8D1X8(const mlib_u8 *src,
-                                            mlib_u8       *dst,
-                                            mlib_s32      dsize,
-                                            mlib_s32      cmask);
-
-void mlib_v_ImageChannelInsert_U8_13_A8D2X8(const mlib_u8 *src,
-                                            mlib_s32      slb,
-                                            mlib_u8       *dst,
-                                            mlib_s32      dlb,
-                                            mlib_s32      xsize,
-                                            mlib_s32      ysize,
-                                            mlib_s32      cmask);
-
 void mlib_v_ImageChannelInsert_U8_13_D1(const mlib_u8 *src,
                                         mlib_u8       *dst,
                                         mlib_s32      dsize,
                                         mlib_s32      cmask);
 
-void mlib_v_ImageChannelInsert_U8_13(const mlib_u8 *src,
-                                     mlib_s32      slb,
-                                     mlib_u8       *dst,
-                                     mlib_s32      dlb,
-                                     mlib_s32      xsize,
-                                     mlib_s32      ysize,
-                                     mlib_s32      cmask);
-
-void mlib_v_ImageChannelInsert_U8_14_A8D1X8(const mlib_u8 *src,
-                                            mlib_u8       *dst,
-                                            mlib_s32      dsize,
-                                            mlib_s32      cmask);
-
-void mlib_v_ImageChannelInsert_U8_14_A8D2X8(const mlib_u8 *src,
-                                            mlib_s32      slb,
-                                            mlib_u8       *dst,
-                                            mlib_s32      dlb,
-                                            mlib_s32      xsize,
-                                            mlib_s32      ysize,
-                                            mlib_s32      cmask);
-
 void mlib_v_ImageChannelInsert_U8_14_D1(const mlib_u8 *src,
                                         mlib_u8       *dst,
                                         mlib_s32      dsize,
                                         mlib_s32      cmask);
 
-void mlib_v_ImageChannelInsert_U8_14(const mlib_u8 *src,
-                                     mlib_s32      slb,
-                                     mlib_u8       *dst,
-                                     mlib_s32      dlb,
-                                     mlib_s32      xsize,
-                                     mlib_s32      ysize,
-                                     mlib_s32      cmask);
-
-void mlib_v_ImageChannelInsert_S16_12_A8D1X4(const mlib_s16 *src,
-                                             mlib_s16       *dst,
-                                             mlib_s32       dsize,
-                                             mlib_s32       cmask);
-
-void mlib_v_ImageChannelInsert_S16_12_A8D2X4(const mlib_s16 *src,
-                                             mlib_s32       slb,
-                                             mlib_s16       *dst,
-                                             mlib_s32       dlb,
-                                             mlib_s32       xsize,
-                                             mlib_s32       ysize,
-                                             mlib_s32       cmask);
-
-void mlib_v_ImageChannelInsert_S16_12_D1(const mlib_s16 *src,
-                                         mlib_s16       *dst,
-                                         mlib_s32       dsize,
-                                         mlib_s32       cmask);
-
-void mlib_v_ImageChannelInsert_S16_12(const mlib_s16 *src,
-                                      mlib_s32       slb,
-                                      mlib_s16       *dst,
-                                      mlib_s32       dlb,
-                                      mlib_s32       xsize,
-                                      mlib_s32       ysize,
-                                      mlib_s32       cmask);
-
-void mlib_v_ImageChannelInsert_S16_13_A8D1X4(const mlib_s16 *src,
-                                             mlib_s16       *dst,
-                                             mlib_s32       dsize,
-                                             mlib_s32       cmask);
-
-void mlib_v_ImageChannelInsert_S16_13_A8D2X4(const mlib_s16 *src,
-                                             mlib_s32       slb,
-                                             mlib_s16       *dst,
-                                             mlib_s32       dlb,
-                                             mlib_s32       xsize,
-                                             mlib_s32       ysize,
-                                             mlib_s32       cmask);
-
-void mlib_v_ImageChannelInsert_S16_13_D1(const mlib_s16 *src,
-                                         mlib_s16       *dst,
-                                         mlib_s32       dsize,
-                                         mlib_s32       cmask);
-
-void mlib_v_ImageChannelInsert_S16_13(const mlib_s16 *src,
-                                      mlib_s32       slb,
-                                      mlib_s16       *dst,
-                                      mlib_s32       dlb,
-                                      mlib_s32       xsize,
-                                      mlib_s32       ysize,
-                                      mlib_s32       cmask);
-
-void mlib_v_ImageChannelInsert_S16_14_A8D1X4(const mlib_s16 *src,
-                                             mlib_s16       *dst,
-                                             mlib_s32       dsize,
-                                             mlib_s32       cmask);
-
-void mlib_v_ImageChannelInsert_S16_14_A8D2X4(const mlib_s16 *src,
-                                             mlib_s32       slb,
-                                             mlib_s16       *dst,
-                                             mlib_s32       dlb,
-                                             mlib_s32       xsize,
-                                             mlib_s32       ysize,
-                                             mlib_s32       cmask);
-
-void mlib_v_ImageChannelInsert_S16_14_D1(const mlib_s16 *src,
-                                         mlib_s16       *dst,
-                                         mlib_s32       dsize,
-                                         mlib_s32       cmask);
-
-void mlib_v_ImageChannelInsert_S16_14(const mlib_s16 *src,
-                                      mlib_s32       slb,
-                                      mlib_s16       *dst,
-                                      mlib_s32       dlb,
-                                      mlib_s32       xsize,
-                                      mlib_s32       ysize,
-                                      mlib_s32       cmask);
-
-void mlib_v_ImageChannelInsert_U8_34R_A8D1X8(const mlib_u8 *src,
-                                             mlib_u8       *dst,
-                                             mlib_s32      dsize);
-
-void mlib_v_ImageChannelInsert_U8_34R_A8D2X8(const mlib_u8 *src,
-                                             mlib_s32      slb,
-                                             mlib_u8       *dst,
-                                             mlib_s32      dlb,
-                                             mlib_s32      xsize,
-                                             mlib_s32      ysize);
-
-void mlib_v_ImageChannelInsert_U8_34R_D1(const mlib_u8 *src,
-                                         mlib_u8       *dst,
-                                         mlib_s32      dsize);
-
-void mlib_v_ImageChannelInsert_U8_34R(const mlib_u8 *src,
-                                      mlib_s32      slb,
-                                      mlib_u8       *dst,
-                                      mlib_s32      dlb,
-                                      mlib_s32      xsize,
-                                      mlib_s32      ysize);
-
-void mlib_v_ImageChannelInsert_S16_34R_A8D1X4(const mlib_s16 *src,
-                                              mlib_s16       *dst,
-                                              mlib_s32       dsize);
-
-void mlib_v_ImageChannelInsert_S16_34R_A8D2X4(const mlib_s16 *src,
-                                              mlib_s32       slb,
-                                              mlib_s16       *dst,
-                                              mlib_s32       dlb,
-                                              mlib_s32       xsize,
-                                              mlib_s32       ysize);
-
-void mlib_v_ImageChannelInsert_S16_34R_D1(const mlib_s16 *src,
-                                          mlib_s16       *dst,
-                                          mlib_s32       dsize);
-
-void mlib_v_ImageChannelInsert_S16_34R(const mlib_s16 *src,
-                                       mlib_s32       slb,
-                                       mlib_s16       *dst,
-                                       mlib_s32       dlb,
-                                       mlib_s32       xsize,
-                                       mlib_s32       ysize);
-
-void mlib_v_ImageChannelInsert_U8_34L_A8D1X8(const mlib_u8 *src,
-                                             mlib_u8       *dst,
-                                             mlib_s32      dsize);
-
-void mlib_v_ImageChannelInsert_U8_34L_A8D2X8(const mlib_u8 *src,
-                                             mlib_s32      slb,
-                                             mlib_u8       *dst,
-                                             mlib_s32      dlb,
-                                             mlib_s32      xsize,
-                                             mlib_s32      ysize);
-
-void mlib_v_ImageChannelInsert_U8_34L_D1(const mlib_u8 *src,
-                                         mlib_u8       *dst,
-                                         mlib_s32      dsize);
-
-void mlib_v_ImageChannelInsert_U8_34L(const mlib_u8 *src,
-                                      mlib_s32      slb,
-                                      mlib_u8       *dst,
-                                      mlib_s32      dlb,
-                                      mlib_s32      xsize,
-                                      mlib_s32      ysize);
-
-void mlib_v_ImageChannelInsert_S16_34L_A8D1X4(const mlib_s16 *src,
-                                              mlib_s16       *dst,
-                                              mlib_s32       dsize);
-
-void mlib_v_ImageChannelInsert_S16_34L_A8D2X4(const mlib_s16 *src,
-                                              mlib_s32       slb,
-                                              mlib_s16       *dst,
-                                              mlib_s32       dlb,
-                                              mlib_s32       xsize,
-                                              mlib_s32       ysize);
-
-void mlib_v_ImageChannelInsert_S16_34L_D1(const mlib_s16 *src,
-                                          mlib_s16       *dst,
-                                          mlib_s32       dsize);
-
-void mlib_v_ImageChannelInsert_S16_34L(const mlib_s16 *src,
-                                       mlib_s32       slb,
-                                       mlib_s16       *dst,
-                                       mlib_s32       dlb,
-                                       mlib_s32       xsize,
-                                       mlib_s32       ysize);
-
 #ifdef __cplusplus
 }
 #endif /* __cplusplus */
--- a/jdk/src/java.desktop/unix/native/libmlib_image/mlib_v_ImageChannelInsert_1.c	Thu May 19 17:48:02 2016 +0000
+++ b/jdk/src/java.desktop/unix/native/libmlib_image/mlib_v_ImageChannelInsert_1.c	Thu May 19 19:46:20 2016 +0000
@@ -27,34 +27,9 @@
 
 /*
  * FUNCTIONS
- *      mlib_v_ImageChannelInsert_U8
- *      mlib_v_ImageChannelInsert_U8_12_A8D1X8
- *      mlib_v_ImageChannelInsert_U8_12_A8D2X8
  *      mlib_v_ImageChannelInsert_U8_12_D1
- *      mlib_v_ImageChannelInsert_U8_12
- *      mlib_v_ImageChannelInsert_U8_13_A8D1X8
- *      mlib_v_ImageChannelInsert_U8_13_A8D2X8
  *      mlib_v_ImageChannelInsert_U8_13_D1
- *      mlib_v_ImageChannelInsert_U8_13
- *      mlib_v_ImageChannelInsert_U8_14_A8D1X8
- *      mlib_v_ImageChannelInsert_U8_14_A8D2X8
  *      mlib_v_ImageChannelInsert_U8_14_D1
- *      mlib_v_ImageChannelInsert_U8_14
- *      mlib_v_ImageChannelInsert_S16
- *      mlib_v_ImageChannelInsert_S16_12_A8D1X4
- *      mlib_v_ImageChannelInsert_S16_12_A8D2X4
- *      mlib_v_ImageChannelInsert_S16_12_D1
- *      mlib_v_ImageChannelInsert_S16_12
- *      mlib_v_ImageChannelInsert_S16_13_A8D1X4
- *      mlib_v_ImageChannelInsert_S16_13_A8D2X4
- *      mlib_v_ImageChannelInsert_S16_13_D1
- *      mlib_v_ImageChannelInsert_S16_13
- *      mlib_v_ImageChannelInsert_S16_14_A8D1X4
- *      mlib_v_ImageChannelInsert_S16_14_A8D2X4
- *      mlib_v_ImageChannelInsert_S16_14_D1
- *      mlib_v_ImageChannelInsert_S16_14
- *      mlib_v_ImageChannelInsert_S32
- *      mlib_v_ImageChannelInsert_D64
  *
  * ARGUMENT
  *      src     pointer to source image data
@@ -80,424 +55,12 @@
 #include "mlib_v_ImageChannelInsert.h"
 
 /***************************************************************/
-/* general channel insertion: slower due to the inner loop */
-void mlib_v_ImageChannelInsert_U8(const mlib_u8 *src,
-                                  mlib_s32      slb,
-                                  mlib_u8       *dst,
-                                  mlib_s32      dlb,
-                                  mlib_s32      channels,
-                                  mlib_s32      channeld,
-                                  mlib_s32      width,
-                                  mlib_s32      height,
-                                  mlib_s32      cmask)
-{
-  mlib_u8 *sp;                                        /* pointer for pixel in src */
-  mlib_u8 *sl;                                        /* pointer for line in src */
-  mlib_u8 *dp;                                        /* pointer for pixel in dst */
-  mlib_u8 *dl;                                        /* pointer for line in dst */
-  mlib_s32 i, j, k;                                   /* indices for x, y, channel */
-  mlib_s32 deltac[5] = { 0, 1, 1, 1, 1 };
-  mlib_s32 inc0, inc1, inc2;
-  mlib_u8 s0, s1, s2;
-
-  deltac[channels] = 1;
-  for (i = (channeld - 1), k = 0; i >= 0; i--) {
-    if ((cmask & (1 << i)) == 0)
-      deltac[k]++;
-    else
-      k++;
-  }
-
-  deltac[channels] = channeld;
-  for (i = 1; i < channels; i++) {
-    deltac[channels] -= deltac[i];
-  }
-
-  sp = sl = (void *)src;
-  dp = dl = dst + deltac[0];
-
-  if (channels == 2) {
-    inc0 = deltac[1];
-    inc1 = deltac[2] + inc0;
-    for (j = 0; j < height; j++) {
-#pragma pipeloop(0)
-      for (i = 0; i < width; i++) {
-        s0 = sp[0];
-        s1 = sp[1];
-        dp[0] = s0;
-        dp[inc0] = s1;
-        dp += inc1;
-        sp += 2;
-      }
-
-      sp = sl += slb;
-      dp = dl += dlb;
-    }
-  }
-  else if (channels == 3) {
-    inc0 = deltac[1];
-    inc1 = deltac[2] + inc0;
-    inc2 = deltac[3] + inc1;
-    for (j = 0; j < height; j++) {
-#pragma pipeloop(0)
-      for (i = 0; i < width; i++) {
-        s0 = sp[0];
-        s1 = sp[1];
-        s2 = sp[2];
-        dp[0] = s0;
-        dp[inc0] = s1;
-        dp[inc1] = s2;
-        dp += inc2;
-        sp += 3;
-      }
-
-      sp = sl += slb;
-      dp = dl += dlb;
-    }
-  }
-}
-
-/***************************************************************/
-/* general channel insertion: slower due to the inner loop */
-void mlib_v_ImageChannelInsert_D64(const mlib_d64 *src,
-                                   mlib_s32       slb,
-                                   mlib_d64       *dst,
-                                   mlib_s32       dlb,
-                                   mlib_s32       channels,
-                                   mlib_s32       channeld,
-                                   mlib_s32       width,
-                                   mlib_s32       height,
-                                   mlib_s32       cmask)
-{
-  mlib_d64 *sp;                                       /* pointer for pixel in src */
-  mlib_d64 *sl;                                       /* pointer for line in src */
-  mlib_d64 *dp;                                       /* pointer for pixel in dst */
-  mlib_d64 *dl;                                       /* pointer for line in dst */
-  mlib_s32 i, j, k;                                   /* indices for x, y, channel */
-  mlib_s32 deltac[5] = { 0, 1, 1, 1, 1 };
-  mlib_s32 inc0, inc1, inc2;
-  mlib_d64 s0, s1, s2;
-
-  deltac[channels] = 1;
-  for (i = (channeld - 1), k = 0; i >= 0; i--) {
-    if ((cmask & (1 << i)) == 0)
-      deltac[k]++;
-    else
-      k++;
-  }
-
-  deltac[channels] = channeld;
-  for (i = 1; i < channels; i++) {
-    deltac[channels] -= deltac[i];
-  }
-
-  sp = sl = (void *)src;
-  dp = dl = dst + deltac[0];
-
-  if (channels == 1) {
-    for (j = 0; j < height; j++) {
-#pragma pipeloop(0)
-      for (i = 0; i < width; i++) {
-        s0 = sp[0];
-        dp[0] = s0;
-        dp += channeld;
-        sp++;
-      }
-
-      sp = sl = (mlib_d64 *) ((mlib_u8 *) sl + slb);
-      dp = dl = (mlib_d64 *) ((mlib_u8 *) dl + dlb);
-    }
-  }
-  else if (channels == 2) {
-    inc0 = deltac[1];
-    inc1 = deltac[2] + inc0;
-    for (j = 0; j < height; j++) {
-#pragma pipeloop(0)
-      for (i = 0; i < width; i++) {
-        s0 = sp[0];
-        s1 = sp[1];
-        dp[0] = s0;
-        dp[inc0] = s1;
-        dp += inc1;
-        sp += 2;
-      }
-
-      sp = sl = (mlib_d64 *) ((mlib_u8 *) sl + slb);
-      dp = dl = (mlib_d64 *) ((mlib_u8 *) dl + dlb);
-    }
-  }
-  else if (channels == 3) {
-    inc0 = deltac[1];
-    inc1 = deltac[2] + inc0;
-    inc2 = deltac[3] + inc1;
-    for (j = 0; j < height; j++) {
-#pragma pipeloop(0)
-      for (i = 0; i < width; i++) {
-        s0 = sp[0];
-        s1 = sp[1];
-        s2 = sp[2];
-        dp[0] = s0;
-        dp[inc0] = s1;
-        dp[inc1] = s2;
-        dp += inc2;
-        sp += 3;
-      }
-
-      sp = sl = (mlib_d64 *) ((mlib_u8 *) sl + slb);
-      dp = dl = (mlib_d64 *) ((mlib_u8 *) dl + dlb);
-    }
-  }
-}
-
-/***************************************************************/
-/* general channel insertion: slower due to the inner loop */
-void mlib_v_ImageChannelInsert_S16(const mlib_s16 *src,
-                                   mlib_s32       slb,
-                                   mlib_s16       *dst,
-                                   mlib_s32       dlb,
-                                   mlib_s32       channels,
-                                   mlib_s32       channeld,
-                                   mlib_s32       width,
-                                   mlib_s32       height,
-                                   mlib_s32       cmask)
-{
-  mlib_s16 *sp;                                       /* pointer for pixel in src */
-  mlib_s16 *sl;                                       /* pointer for line in src */
-  mlib_s16 *dp;                                       /* pointer for pixel in dst */
-  mlib_s16 *dl;                                       /* pointer for line in dst */
-  mlib_s32 i, j, k;                                   /* indices for x, y, channel */
-  mlib_s32 deltac[5] = { 0, 1, 1, 1, 1 };
-  mlib_s32 inc0, inc1, inc2;
-  mlib_s16 s0, s1, s2;
-
-  deltac[channels] = 1;
-  for (i = (channeld - 1), k = 0; i >= 0; i--) {
-    if ((cmask & (1 << i)) == 0)
-      deltac[k]++;
-    else
-      k++;
-  }
-
-  deltac[channels] = channeld;
-  for (i = 1; i < channels; i++) {
-    deltac[channels] -= deltac[i];
-  }
-
-  sp = sl = (void *)src;
-  dp = dl = dst + deltac[0];
-
-  if (channels == 2) {
-    inc0 = deltac[1];
-    inc1 = deltac[2] + inc0;
-    for (j = 0; j < height; j++) {
-#pragma pipeloop(0)
-      for (i = 0; i < width; i++) {
-        s0 = sp[0];
-        s1 = sp[1];
-        dp[0] = s0;
-        dp[inc0] = s1;
-        dp += inc1;
-        sp += 2;
-      }
-
-      sp = sl = (mlib_s16 *) ((mlib_u8 *) sl + slb);
-      dp = dl = (mlib_s16 *) ((mlib_u8 *) dl + dlb);
-    }
-  }
-  else if (channels == 3) {
-    inc0 = deltac[1];
-    inc1 = deltac[2] + inc0;
-    inc2 = deltac[3] + inc1;
-    for (j = 0; j < height; j++) {
-#pragma pipeloop(0)
-      for (i = 0; i < width; i++) {
-        s0 = sp[0];
-        s1 = sp[1];
-        s2 = sp[2];
-        dp[0] = s0;
-        dp[inc0] = s1;
-        dp[inc1] = s2;
-        dp += inc2;
-        sp += 3;
-      }
-
-      sp = sl = (mlib_s16 *) ((mlib_u8 *) sl + slb);
-      dp = dl = (mlib_s16 *) ((mlib_u8 *) dl + dlb);
-    }
-  }
-}
-
-/***************************************************************/
-/* general channel insertion: slower due to the inner loop */
-
-void mlib_v_ImageChannelInsert_S32(const mlib_s32 *src,
-                                   mlib_s32       slb,
-                                   mlib_s32       *dst,
-                                   mlib_s32       dlb,
-                                   mlib_s32       channels,
-                                   mlib_s32       channeld,
-                                   mlib_s32       width,
-                                   mlib_s32       height,
-                                   mlib_s32       cmask)
-{
-  mlib_s32 *sp;                                       /* pointer for pixel in src */
-  mlib_s32 *sl;                                       /* pointer for line in src */
-  mlib_s32 *dp;                                       /* pointer for pixel in dst */
-  mlib_s32 *dl;                                       /* pointer for line in dst */
-  mlib_s32 i, j, k;                                   /* indices for x, y, channel */
-  mlib_s32 deltac[5] = { 0, 1, 1, 1, 1 };
-  mlib_s32 inc0, inc1, inc2;
-  mlib_s32 s0, s1, s2;
-
-  deltac[channels] = 1;
-  for (i = (channeld - 1), k = 0; i >= 0; i--) {
-    if ((cmask & (1 << i)) == 0)
-      deltac[k]++;
-    else
-      k++;
-  }
-
-  deltac[channels] = channeld;
-  for (i = 1; i < channels; i++) {
-    deltac[channels] -= deltac[i];
-  }
-
-  sp = sl = (void *)src;
-  dp = dl = dst + deltac[0];
-
-  if (channels == 1) {
-    for (j = 0; j < height; j++) {
-#pragma pipeloop(0)
-      for (i = 0; i < width; i++) {
-        s0 = sp[0];
-        dp[0] = s0;
-        dp += channeld;
-        sp++;
-      }
-
-      sp = sl = (mlib_s32 *) ((mlib_u8 *) sl + slb);
-      dp = dl = (mlib_s32 *) ((mlib_u8 *) dl + dlb);
-    }
-  }
-  else if (channels == 2) {
-    inc0 = deltac[1];
-    inc1 = deltac[2] + inc0;
-    for (j = 0; j < height; j++) {
-#pragma pipeloop(0)
-      for (i = 0; i < width; i++) {
-        s0 = sp[0];
-        s1 = sp[1];
-        dp[0] = s0;
-        dp[inc0] = s1;
-        dp += inc1;
-        sp += 2;
-      }
-
-      sp = sl = (mlib_s32 *) ((mlib_u8 *) sl + slb);
-      dp = dl = (mlib_s32 *) ((mlib_u8 *) dl + dlb);
-    }
-  }
-  else if (channels == 3) {
-    inc0 = deltac[1];
-    inc1 = deltac[2] + inc0;
-    inc2 = deltac[3] + inc1;
-    for (j = 0; j < height; j++) {
-#pragma pipeloop(0)
-      for (i = 0; i < width; i++) {
-        s0 = sp[0];
-        s1 = sp[1];
-        s2 = sp[2];
-        dp[0] = s0;
-        dp[inc0] = s1;
-        dp[inc1] = s2;
-        dp += inc2;
-        sp += 3;
-      }
-
-      sp = sl = (mlib_s32 *) ((mlib_u8 *) sl + slb);
-      dp = dl = (mlib_s32 *) ((mlib_u8 *) dl + dlb);
-    }
-  }
-}
-
-/***************************************************************/
 #define INSERT_U8_12(sd0, dd0, dd1)     /* channel duplicate */ \
   dd0 = vis_fpmerge(vis_read_hi(sd0), vis_read_hi(sd0));        \
   dd1 = vis_fpmerge(vis_read_lo(sd0), vis_read_lo(sd0))
 
 /***************************************************************/
 /* insert one channel to a 2-channel image.
- * both source and destination image data are 8-byte aligned.
- * dsize is multiple of 8.
- */
-
-void mlib_v_ImageChannelInsert_U8_12_A8D1X8(const mlib_u8 *src,
-                                            mlib_u8       *dst,
-                                            mlib_s32      dsize,
-                                            mlib_s32      cmask)
-{
-  mlib_d64 *sp, *dp;
-  mlib_d64 sd0;
-  mlib_d64 dd0, dd1;
-  mlib_s32 bmask;
-  mlib_s32 i;
-
-  bmask = cmask | (cmask << 2) | (cmask << 4) | (cmask << 6);
-
-  sp = (mlib_d64 *) src;
-  dp = (mlib_d64 *) dst;
-
-#pragma pipeloop(0)
-  for (i = 0; i < dsize / 8; i++) {
-    sd0 = *sp++;
-    INSERT_U8_12(sd0, dd0, dd1);
-    vis_pst_8(dd0, dp++, bmask);
-    vis_pst_8(dd1, dp++, bmask);
-  }
-}
-
-/***************************************************************/
-/* insert one channel to a 2-channel image.
- * both source and destination image data are 8-byte aligned.
- * xsize is multiple of 8.
- */
-
-void mlib_v_ImageChannelInsert_U8_12_A8D2X8(const mlib_u8 *src,
-                                            mlib_s32      slb,
-                                            mlib_u8       *dst,
-                                            mlib_s32      dlb,
-                                            mlib_s32      xsize,
-                                            mlib_s32      ysize,
-                                            mlib_s32      cmask)
-{
-  mlib_d64 *sp, *dp;
-  mlib_d64 *sl, *dl;
-  mlib_d64 sd0;
-  mlib_d64 dd0, dd1;
-  mlib_s32 bmask;
-  mlib_s32 i, j;
-
-  bmask = cmask | (cmask << 2) | (cmask << 4) | (cmask << 6);
-
-  sp = sl = (mlib_d64 *) src;
-  dp = dl = (mlib_d64 *) dst;
-
-  for (j = 0; j < ysize; j++) {
-#pragma pipeloop(0)
-    for (i = 0; i < xsize / 8; i++) {
-      sd0 = *sp++;
-      INSERT_U8_12(sd0, dd0, dd1);
-      vis_pst_8(dd0, dp++, bmask);
-      vis_pst_8(dd1, dp++, bmask);
-    }
-
-    sp = sl = (mlib_d64 *) ((mlib_u8 *) sl + slb);
-    dp = dl = (mlib_d64 *) ((mlib_u8 *) dl + dlb);
-  }
-}
-
-/***************************************************************/
-/* insert one channel to a 2-channel image.
  */
 
 void mlib_v_ImageChannelInsert_U8_12_D1(const mlib_u8 *src,
@@ -724,56 +287,6 @@
 }
 
 /***************************************************************/
-/* insert one channel to a 2-channel image.
- */
-
-void mlib_v_ImageChannelInsert_U8_12(const mlib_u8 *src,
-                                     mlib_s32      slb,
-                                     mlib_u8       *dst,
-                                     mlib_s32      dlb,
-                                     mlib_s32      xsize,
-                                     mlib_s32      ysize,
-                                     mlib_s32      cmask)
-{
-  mlib_u8 *sa, *da;
-  mlib_u8 *sl, *dl;
-  mlib_s32 j;
-
-  sa = sl = (void *)src;
-  da = dl = dst;
-
-#pragma pipeloop(0)
-  for (j = 0; j < ysize; j++) {
-    mlib_v_ImageChannelInsert_U8_12_D1(sa, da, xsize, cmask);
-    sa = sl += slb;
-    da = dl += dlb;
-  }
-}
-
-/***************************************************************/
-#define INSERT_U8_13(sd0, dd0, dd1, dd2)                        \
-  sda = vis_fpmerge(vis_read_hi(sd0), vis_read_lo(sd0));        \
-  sdb = vis_fpmerge(vis_read_hi(sda), vis_read_lo(sda));        \
-  sdc = vis_fpmerge(vis_read_hi(sdb), vis_read_hi(sdb));        \
-  sdd = vis_fpmerge(vis_read_lo(sdb), vis_read_lo(sdb));        \
-  dd0 = vis_fpmerge(vis_read_hi(sdc), vis_read_hi(sdd));        \
-  sde = vis_fpmerge(vis_read_lo(sdc), vis_read_lo(sdd));        \
-  dd1 = vis_freg_pair(vis_read_lo(dd0), vis_read_hi(sde));      \
-  dd2 = vis_freg_pair(vis_read_lo(sde), vis_read_lo(sde))
-
-/***************************************************************/
-#define LOAD_INSERT_STORE_U8_A8(channeld)                       \
-  sd = *sp++;                                                   \
-  vis_st_u8(sd = vis_faligndata(sd, sd), da); da += channeld;   \
-  vis_st_u8(sd = vis_faligndata(sd, sd), da); da += channeld;   \
-  vis_st_u8(sd = vis_faligndata(sd, sd), da); da += channeld;   \
-  vis_st_u8(sd = vis_faligndata(sd, sd), da); da += channeld;   \
-  vis_st_u8(sd = vis_faligndata(sd, sd), da); da += channeld;   \
-  vis_st_u8(sd = vis_faligndata(sd, sd), da); da += channeld;   \
-  vis_st_u8(sd = vis_faligndata(sd, sd), da); da += channeld;   \
-  vis_st_u8(sd = vis_faligndata(sd, sd), da); da += channeld
-
-/***************************************************************/
 #define LOAD_INSERT_STORE_U8(channeld)                          \
   vis_alignaddr((void *)0, off);                                \
   sd0 = sd1;                                                    \
@@ -790,58 +303,6 @@
   vis_st_u8(sd = vis_faligndata(sd, sd), da); da += channeld
 
 /***************************************************************/
-void mlib_v_ImageChannelInsert_U8_13_A8D1X8(const mlib_u8 *src,
-                                            mlib_u8       *dst,
-                                            mlib_s32      dsize,
-                                            mlib_s32      cmask)
-{
-  mlib_u8 *da;
-  mlib_d64 *sp;
-  mlib_d64 sd;
-  mlib_s32 i;
-
-  vis_alignaddr((void *)0, 1);              /* for 1-byte left shift */
-
-  sp = (mlib_d64 *) src;
-  da = dst + (2 / cmask);                   /* 4,2,1 -> 0,1,2 */
-
-#pragma pipeloop(0)
-  for (i = 0; i < dsize / 8; i++) {
-    LOAD_INSERT_STORE_U8_A8(3);
-  }
-}
-
-/***************************************************************/
-void mlib_v_ImageChannelInsert_U8_13_A8D2X8(const mlib_u8 *src,
-                                            mlib_s32      slb,
-                                            mlib_u8       *dst,
-                                            mlib_s32      dlb,
-                                            mlib_s32      xsize,
-                                            mlib_s32      ysize,
-                                            mlib_s32      cmask)
-{
-  mlib_u8 *da, *dl;
-  mlib_d64 *sp, *sl;
-  mlib_d64 sd;
-  mlib_s32 i, j;
-
-  vis_alignaddr((void *)0, 1);
-
-  sp = sl = (mlib_d64 *) src;
-  da = dl = dst + (2 / cmask);              /* 4,2,1 -> 0,1,2 */
-
-  for (j = 0; j < ysize; j++) {
-#pragma pipeloop(0)
-    for (i = 0; i < xsize / 8; i++) {
-      LOAD_INSERT_STORE_U8_A8(3);
-    }
-
-    sp = sl = (mlib_d64 *) ((mlib_u8 *) sl + slb);
-    da = dl = (mlib_u8 *) ((mlib_u8 *) dl + dlb);
-  }
-}
-
-/***************************************************************/
 void mlib_v_ImageChannelInsert_U8_13_D1(const mlib_u8 *src,
                                         mlib_u8       *dst,
                                         mlib_s32      dsize,
@@ -908,30 +369,6 @@
 }
 
 /***************************************************************/
-void mlib_v_ImageChannelInsert_U8_13(const mlib_u8 *src,
-                                     mlib_s32      slb,
-                                     mlib_u8       *dst,
-                                     mlib_s32      dlb,
-                                     mlib_s32      xsize,
-                                     mlib_s32      ysize,
-                                     mlib_s32      cmask)
-{
-  mlib_u8 *sa, *da;
-  mlib_u8 *sl, *dl;
-  mlib_s32 j;
-
-  sa = sl = (void *)src;
-  da = dl = dst;
-
-#pragma pipeloop(0)
-  for (j = 0; j < ysize; j++) {
-    mlib_v_ImageChannelInsert_U8_13_D1(sa, da, xsize, cmask);
-    sa = sl += slb;
-    da = dl += dlb;
-  }
-}
-
-/***************************************************************/
 #define INSERT_U8_14(sd0, dd0, dd1, dd2, dd3)                   \
   sda = vis_fpmerge(vis_read_hi(sd0), vis_read_hi(sd0));        \
   sdb = vis_fpmerge(vis_read_lo(sd0), vis_read_lo(sd0));        \
@@ -941,73 +378,6 @@
   dd3 = vis_fpmerge(vis_read_lo(sdb), vis_read_lo(sdb))
 
 /***************************************************************/
-void mlib_v_ImageChannelInsert_U8_14_A8D1X8(const mlib_u8 *src,
-                                            mlib_u8       *dst,
-                                            mlib_s32      dsize,
-                                            mlib_s32      cmask)
-{
-  mlib_d64 *sp, *dp;
-  mlib_d64 sd0;
-  mlib_d64 sda, sdb;
-  mlib_d64 dd0, dd1, dd2, dd3;
-  mlib_s32 bmask;
-  mlib_s32 i;
-
-  bmask = cmask | (cmask << 4);
-
-  sp = (mlib_d64 *) src;
-  dp = (mlib_d64 *) dst;
-
-#pragma pipeloop(0)
-  for (i = 0; i < dsize / 8; i++) {
-    sd0 = *sp++;
-    INSERT_U8_14(sd0, dd0, dd1, dd2, dd3);
-    vis_pst_8(dd0, dp++, bmask);
-    vis_pst_8(dd1, dp++, bmask);
-    vis_pst_8(dd2, dp++, bmask);
-    vis_pst_8(dd3, dp++, bmask);
-  }
-}
-
-/***************************************************************/
-void mlib_v_ImageChannelInsert_U8_14_A8D2X8(const mlib_u8 *src,
-                                            mlib_s32      slb,
-                                            mlib_u8       *dst,
-                                            mlib_s32      dlb,
-                                            mlib_s32      xsize,
-                                            mlib_s32      ysize,
-                                            mlib_s32      cmask)
-{
-  mlib_d64 *sp, *dp;
-  mlib_d64 *sl, *dl;
-  mlib_d64 sd0;
-  mlib_d64 sda, sdb;
-  mlib_d64 dd0, dd1, dd2, dd3;
-  mlib_s32 bmask;
-  mlib_s32 i, j;
-
-  bmask = cmask | (cmask << 4);
-
-  sp = sl = (mlib_d64 *) src;
-  dp = dl = (mlib_d64 *) dst;
-
-  for (j = 0; j < ysize; j++) {
-#pragma pipeloop(0)
-    for (i = 0; i < xsize / 8; i++) {
-      sd0 = *sp++;
-      INSERT_U8_14(sd0, dd0, dd1, dd2, dd3);
-      vis_pst_8(dd0, dp++, bmask);
-      vis_pst_8(dd1, dp++, bmask);
-      vis_pst_8(dd2, dp++, bmask);
-      vis_pst_8(dd3, dp++, bmask);
-    }
-
-    sp = sl = (mlib_d64 *) ((mlib_u8 *) sl + slb);
-    dp = dl = (mlib_d64 *) ((mlib_u8 *) dl + dlb);
-  }
-}
-
-/***************************************************************/
 void mlib_v_ImageChannelInsert_U8_14_D1(const mlib_u8 *src,
                                         mlib_u8       *dst,
                                         mlib_s32      dsize,
@@ -1188,445 +558,5 @@
   }
 }
 
-/***************************************************************/
-void mlib_v_ImageChannelInsert_U8_14(const mlib_u8 *src,
-                                     mlib_s32      slb,
-                                     mlib_u8       *dst,
-                                     mlib_s32      dlb,
-                                     mlib_s32      xsize,
-                                     mlib_s32      ysize,
-                                     mlib_s32      cmask)
-{
-  mlib_u8 *sa, *da;
-  mlib_u8 *sl, *dl;
-  mlib_s32 j;
-
-  sa = sl = (void *)src;
-  da = dl = dst;
-
-#pragma pipeloop(0)
-  for (j = 0; j < ysize; j++) {
-    mlib_v_ImageChannelInsert_U8_14_D1(sa, da, xsize, cmask);
-    sa = sl += slb;
-    da = dl += dlb;
-  }
-}
-
-/***************************************************************/
-#define LOAD_INSERT_STORE_S16_1X_A8(channeld)                   \
-  sd  = *sp++;                                                  \
-  vis_st_u16(sd = vis_faligndata(sd, sd), da); da += channeld;  \
-  vis_st_u16(sd = vis_faligndata(sd, sd), da); da += channeld;  \
-  vis_st_u16(sd = vis_faligndata(sd, sd), da); da += channeld;  \
-  vis_st_u16(sd = vis_faligndata(sd, sd), da); da += channeld
-
-/***************************************************************/
-#define LOAD_INSERT_STORE_S16_1X(channeld)                      \
-  vis_alignaddr((void *)0, off);                                \
-  sd0 = sd1;                                                    \
-  sd1 = *sp++;                                                  \
-  sd  = vis_faligndata(sd0, sd1);                               \
-  vis_alignaddr((void *)0, 2);                                  \
-  vis_st_u16(sd = vis_faligndata(sd, sd), da); da += channeld;  \
-  vis_st_u16(sd = vis_faligndata(sd, sd), da); da += channeld;  \
-  vis_st_u16(sd = vis_faligndata(sd, sd), da); da += channeld;  \
-  vis_st_u16(sd = vis_faligndata(sd, sd), da); da += channeld
-
-/***************************************************************/
-void mlib_v_ImageChannelInsert_S16_12_A8D1X4(const mlib_s16 *src,
-                                             mlib_s16       *dst,
-                                             mlib_s32       dsize,
-                                             mlib_s32       cmask)
-{
-  mlib_s16 *da;
-  mlib_d64 *sp;
-  mlib_d64 sd;
-  mlib_s32 i;
-
-  sp = (mlib_d64 *) src;
-  da = dst + (2 - cmask);                   /* 2,1 -> 0,1 */
-
-  vis_alignaddr((void *)0, 2);
-
-#pragma pipeloop(0)
-  for (i = 0; i < dsize / 4; i++) {
-    LOAD_INSERT_STORE_S16_1X_A8(2);
-  }
-}
-
-/***************************************************************/
-void mlib_v_ImageChannelInsert_S16_12_A8D2X4(const mlib_s16 *src,
-                                             mlib_s32       slb,
-                                             mlib_s16       *dst,
-                                             mlib_s32       dlb,
-                                             mlib_s32       xsize,
-                                             mlib_s32       ysize,
-                                             mlib_s32       cmask)
-{
-  mlib_s16 *da, *dl;
-  mlib_d64 *sp, *sl;
-  mlib_d64 sd;
-  mlib_s32 i, j;
-
-  sp = sl = (mlib_d64 *) src;
-  da = dl = dst + (2 - cmask);              /* 2,1 -> 0,1 */
-
-  vis_alignaddr((void *)0, 2);
-
-  for (j = 0; j < ysize; j++) {
-#pragma pipeloop(0)
-    for (i = 0; i < xsize / 4; i++) {
-      LOAD_INSERT_STORE_S16_1X_A8(2);
-    }
-
-    sp = sl = (mlib_d64 *) ((mlib_u8 *) sl + slb);
-    da = dl = (mlib_s16 *) ((mlib_u8 *) dl + dlb);
-  }
-}
-
-/***************************************************************/
-void mlib_v_ImageChannelInsert_S16_12_D1(const mlib_s16 *src,
-                                         mlib_s16       *dst,
-                                         mlib_s32       dsize,
-                                         mlib_s32       cmask)
-{
-  mlib_s16 *sa, *da;
-  mlib_s16 *dend;                                     /* end point in destination */
-  mlib_d64 *sp;                                       /* 8-byte aligned start points in src */
-  mlib_d64 sd0, sd1, sd;                              /* 8-byte registers for source data */
-  mlib_s32 off;                                       /* offset of address alignment in src */
-  mlib_s32 i;
-
-  sa = (void *)src;
-  da = dst + (2 - cmask);                   /* 2,1 -> 0,1 */
-
-  /* prepare the src address */
-  sp = (mlib_d64 *) ((mlib_addr) sa & (~7));
-  off = (mlib_addr) sa & 7;
-
-  dend = da + dsize * 2 - 1;
-
-  sd1 = *sp++;
-
-#pragma pipeloop(0)
-  for (i = 0; i < dsize / 4; i++) {
-    LOAD_INSERT_STORE_S16_1X(2);
-  }
-
-  /* right end handling */
-  if ((mlib_addr) da <= (mlib_addr) dend) {
-
-    vis_alignaddr((void *)0, off);
-    sd0 = sd1;
-    sd1 = *sp++;
-    sd = vis_faligndata(sd0, sd1);
-
-    vis_alignaddr((void *)0, 2);
-    vis_st_u16(sd = vis_faligndata(sd, sd), da);
-    da += 2;
-    if ((mlib_addr) da <= (mlib_addr) dend) {
-      vis_st_u16(sd = vis_faligndata(sd, sd), da);
-      da += 2;
-      if ((mlib_addr) da <= (mlib_addr) dend) {
-        vis_st_u16(sd = vis_faligndata(sd, sd), da);
-      }
-    }
-  }
-}
-
-/***************************************************************/
-void mlib_v_ImageChannelInsert_S16_12(const mlib_s16 *src,
-                                      mlib_s32       slb,
-                                      mlib_s16       *dst,
-                                      mlib_s32       dlb,
-                                      mlib_s32       xsize,
-                                      mlib_s32       ysize,
-                                      mlib_s32       cmask)
-{
-  mlib_s16 *sa, *da;
-  mlib_s16 *sl, *dl;
-  mlib_s32 j;
-
-  sa = sl = (void *)src;
-  da = dl = dst;
-
-#pragma pipeloop(0)
-  for (j = 0; j < ysize; j++) {
-    mlib_v_ImageChannelInsert_S16_12_D1(sa, da, xsize, cmask);
-    sa = sl = (mlib_s16 *) ((mlib_u8 *) sl + slb);
-    da = dl = (mlib_s16 *) ((mlib_u8 *) dl + dlb);
-  }
-}
-
-/***************************************************************/
-void mlib_v_ImageChannelInsert_S16_13_A8D1X4(const mlib_s16 *src,
-                                             mlib_s16       *dst,
-                                             mlib_s32       dsize,
-                                             mlib_s32       cmask)
-{
-  mlib_s16 *da;
-  mlib_d64 *sp;
-  mlib_d64 sd;
-  mlib_s32 i;
-
-  sp = (mlib_d64 *) src;
-  da = dst + (2 / cmask);                   /* 4,2,1 -> 0,1,2 */
-
-  vis_alignaddr((void *)0, 2);
-
-#pragma pipeloop(0)
-  for (i = 0; i < dsize / 4; i++) {
-    LOAD_INSERT_STORE_S16_1X_A8(3);
-  }
-}
 
 /***************************************************************/
-void mlib_v_ImageChannelInsert_S16_13_A8D2X4(const mlib_s16 *src,
-                                             mlib_s32       slb,
-                                             mlib_s16       *dst,
-                                             mlib_s32       dlb,
-                                             mlib_s32       xsize,
-                                             mlib_s32       ysize,
-                                             mlib_s32       cmask)
-{
-  mlib_s16 *da, *dl;
-  mlib_d64 *sp, *sl;
-  mlib_d64 sd;
-  mlib_s32 i, j;
-
-  sp = sl = (mlib_d64 *) src;
-  da = dl = dst + (2 / cmask);              /* 4,2,1 -> 0,1,2 */
-
-  vis_alignaddr((void *)0, 2);
-
-  for (j = 0; j < ysize; j++) {
-#pragma pipeloop(0)
-    for (i = 0; i < xsize / 4; i++) {
-      LOAD_INSERT_STORE_S16_1X_A8(3);
-    }
-
-    sp = sl = (mlib_d64 *) ((mlib_u8 *) sl + slb);
-    da = dl = (mlib_s16 *) ((mlib_u8 *) dl + dlb);
-  }
-}
-
-/***************************************************************/
-void mlib_v_ImageChannelInsert_S16_13_D1(const mlib_s16 *src,
-                                         mlib_s16       *dst,
-                                         mlib_s32       dsize,
-                                         mlib_s32       cmask)
-{
-  mlib_s16 *sa, *da;
-  mlib_s16 *dend;                                     /* end point in destination */
-  mlib_d64 *sp;                                       /* 8-byte aligned start points in src */
-  mlib_d64 sd0, sd1, sd;                              /* 8-byte registers for source data */
-  mlib_s32 off;                                       /* offset of address alignment in src */
-  mlib_s32 i;
-
-  sa = (void *)src;
-  da = dst + (2 / cmask);                   /* 4,2,1 -> 0,1,2 */
-
-  /* prepare the src address */
-  sp = (mlib_d64 *) ((mlib_addr) sa & (~7));
-  off = (mlib_addr) sa & 7;
-
-  dend = da + dsize * 3 - 1;
-
-  sd1 = *sp++;
-
-#pragma pipeloop(0)
-  for (i = 0; i < dsize / 4; i++) {
-    LOAD_INSERT_STORE_S16_1X(3);
-  }
-
-  /* right end handling */
-  if ((mlib_addr) da <= (mlib_addr) dend) {
-
-    vis_alignaddr((void *)0, off);
-    sd0 = sd1;
-    sd1 = *sp++;
-    sd = vis_faligndata(sd0, sd1);
-
-    vis_alignaddr((void *)0, 2);
-    vis_st_u16(sd = vis_faligndata(sd, sd), da);
-    da += 3;
-    if ((mlib_addr) da <= (mlib_addr) dend) {
-      vis_st_u16(sd = vis_faligndata(sd, sd), da);
-      da += 3;
-      if ((mlib_addr) da <= (mlib_addr) dend) {
-        vis_st_u16(sd = vis_faligndata(sd, sd), da);
-      }
-    }
-  }
-}
-
-/***************************************************************/
-void mlib_v_ImageChannelInsert_S16_13(const mlib_s16 *src,
-                                      mlib_s32       slb,
-                                      mlib_s16       *dst,
-                                      mlib_s32       dlb,
-                                      mlib_s32       xsize,
-                                      mlib_s32       ysize,
-                                      mlib_s32       cmask)
-{
-  mlib_s16 *sa, *da;
-  mlib_s16 *sl, *dl;
-  mlib_s32 j;
-
-  sa = sl = (void *)src;
-  da = dl = dst;
-
-#pragma pipeloop(0)
-  for (j = 0; j < ysize; j++) {
-    mlib_v_ImageChannelInsert_S16_13_D1(sa, da, xsize, cmask);
-    sa = sl = (mlib_s16 *) ((mlib_u8 *) sl + slb);
-    da = dl = (mlib_s16 *) ((mlib_u8 *) dl + dlb);
-  }
-}
-
-/***************************************************************/
-#define INSERT_S16_14(sp, dp, bmask)    /* channel duplicate */ \
-  /* obsolete: it is slower than the vis_st_u16() version*/     \
-  sd0 = *sp++;                                                  \
-  sda = vis_fpmerge(vis_read_hi(sd0), vis_read_hi(sd0));        \
-  sdb = vis_fpmerge(vis_read_lo(sd0), vis_read_lo(sd0));        \
-  sdc = vis_fpmerge(vis_read_hi(sda), vis_read_hi(sda));        \
-  sdd = vis_fpmerge(vis_read_lo(sda), vis_read_lo(sda));        \
-  sde = vis_fpmerge(vis_read_hi(sdb), vis_read_hi(sdb));        \
-  sdf = vis_fpmerge(vis_read_lo(sdb), vis_read_lo(sdb));        \
-  dd0 = vis_fpmerge(vis_read_hi(sdc), vis_read_lo(sdc));        \
-  dd1 = vis_fpmerge(vis_read_hi(sdd), vis_read_lo(sdd));        \
-  dd2 = vis_fpmerge(vis_read_hi(sde), vis_read_lo(sde));        \
-  dd3 = vis_fpmerge(vis_read_hi(sdf), vis_read_lo(sdf));        \
-  vis_pst_16(dd0, dp++, bmask);                                 \
-  vis_pst_16(dd1, dp++, bmask);                                 \
-  vis_pst_16(dd2, dp++, bmask);                                 \
-  vis_pst_16(dd3, dp++, bmask)
-
-/***************************************************************/
-void mlib_v_ImageChannelInsert_S16_14_A8D1X4(const mlib_s16 *src,
-                                             mlib_s16       *dst,
-                                             mlib_s32       dsize,
-                                             mlib_s32       cmask)
-{
-  mlib_s16 *da;
-  mlib_d64 *sp;
-  mlib_d64 sd;
-  mlib_s32 i;
-
-  sp = (mlib_d64 *) src;
-  da = dst + (6 / cmask + 1) / 2;           /* 8,4,2,1 -> 0,1,2,3 */
-
-  vis_alignaddr((void *)0, 2);
-
-#pragma pipeloop(0)
-  for (i = 0; i < dsize / 4; i++) {
-    LOAD_INSERT_STORE_S16_1X_A8(4);
-  }
-}
-
-/***************************************************************/
-void mlib_v_ImageChannelInsert_S16_14_A8D2X4(const mlib_s16 *src,
-                                             mlib_s32       slb,
-                                             mlib_s16       *dst,
-                                             mlib_s32       dlb,
-                                             mlib_s32       xsize,
-                                             mlib_s32       ysize,
-                                             mlib_s32       cmask)
-{
-  mlib_s16 *da, *dl;
-  mlib_d64 *sp, *sl;
-  mlib_d64 sd;
-  mlib_s32 i, j;
-
-  sp = sl = (mlib_d64 *) src;
-  da = dl = dst + (6 / cmask + 1) / 2;      /* 8,4,2,1 -> 0,1,2,3 */
-
-  vis_alignaddr((void *)0, 2);
-
-  for (j = 0; j < ysize; j++) {
-#pragma pipeloop(0)
-    for (i = 0; i < xsize / 4; i++) {
-      LOAD_INSERT_STORE_S16_1X_A8(4);
-    }
-
-    sp = sl = (mlib_d64 *) ((mlib_u8 *) sl + slb);
-    da = dl = (mlib_s16 *) ((mlib_u8 *) dl + dlb);
-  }
-}
-
-/***************************************************************/
-void mlib_v_ImageChannelInsert_S16_14_D1(const mlib_s16 *src,
-                                         mlib_s16       *dst,
-                                         mlib_s32       dsize,
-                                         mlib_s32       cmask)
-{
-  mlib_s16 *sa, *da;
-  mlib_s16 *dend;                                     /* end point in destination */
-  mlib_d64 *sp;                                       /* 8-byte aligned start points in src */
-  mlib_d64 sd0, sd1, sd;                              /* 8-byte registers for source data */
-  mlib_s32 off;                                       /* offset of address alignment in src */
-  mlib_s32 i;
-
-  sa = (void *)src;
-  da = dst + (6 / cmask + 1) / 2;           /* 8,4,2,1 -> 0,1,2,3 */
-
-  /* prepare the src address */
-  sp = (mlib_d64 *) ((mlib_addr) sa & (~7));
-  off = (mlib_addr) sa & 7;
-
-  dend = da + dsize * 4 - 1;
-
-  sd1 = *sp++;
-
-#pragma pipeloop(0)
-  for (i = 0; i < dsize / 4; i++) {
-    LOAD_INSERT_STORE_S16_1X(4);
-  }
-
-  /* right end handling */
-  if ((mlib_addr) da <= (mlib_addr) dend) {
-
-    vis_alignaddr((void *)0, off);
-    sd0 = sd1;
-    sd1 = *sp++;
-    sd = vis_faligndata(sd0, sd1);
-
-    vis_alignaddr((void *)0, 2);
-    vis_st_u16(sd = vis_faligndata(sd, sd), da);
-    da += 4;
-    if ((mlib_addr) da <= (mlib_addr) dend) {
-      vis_st_u16(sd = vis_faligndata(sd, sd), da);
-      da += 4;
-      if ((mlib_addr) da <= (mlib_addr) dend) {
-        vis_st_u16(sd = vis_faligndata(sd, sd), da);
-      }
-    }
-  }
-}
-
-/***************************************************************/
-void mlib_v_ImageChannelInsert_S16_14(const mlib_s16 *src,
-                                      mlib_s32       slb,
-                                      mlib_s16       *dst,
-                                      mlib_s32       dlb,
-                                      mlib_s32       xsize,
-                                      mlib_s32       ysize,
-                                      mlib_s32       cmask)
-{
-  mlib_s16 *sa, *da;
-  mlib_s16 *sl, *dl;
-  mlib_s32 j;
-
-  sa = sl = (void *)src;
-  da = dl = dst;
-
-#pragma pipeloop(0)
-  for (j = 0; j < ysize; j++) {
-    mlib_v_ImageChannelInsert_S16_14_D1(sa, da, xsize, cmask);
-    sa = sl = (mlib_s16 *) ((mlib_u8 *) sl + slb);
-    da = dl = (mlib_s16 *) ((mlib_u8 *) dl + dlb);
-  }
-}
-
-/***************************************************************/
--- a/jdk/src/java.desktop/unix/native/libmlib_image/mlib_v_ImageChannelInsert_34.c	Thu May 19 17:48:02 2016 +0000
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,1225 +0,0 @@
-/*
- * Copyright (c) 1998, 2003, 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.
- */
-
-
-
-/*
- * FILENAME: mlib_v_ImageChannelInsert_34.c
- *
- * FUNCTIONS
- *      mlib_v_ImageChannelInsert_U8_34R_A8D1X8
- *      mlib_v_ImageChannelInsert_U8_34R_A8D2X8
- *      mlib_v_ImageChannelInsert_U8_34R_D1
- *      mlib_v_ImageChannelInsert_U8_34R
- *      mlib_v_ImageChannelInsert_S16_34R_A8D1X4
- *      mlib_v_ImageChannelInsert_S16_34R_A8D2X4
- *      mlib_v_ImageChannelInsert_S16_34R_D1
- *      mlib_v_ImageChannelInsert_S16_34R
- *      mlib_v_ImageChannelInsert_U8_34L_A8D1X8
- *      mlib_v_ImageChannelInsert_U8_34L_A8D2X8
- *      mlib_v_ImageChannelInsert_U8_34L_D1
- *      mlib_v_ImageChannelInsert_U8_34L
- *      mlib_v_ImageChannelInsert_S16_34L_A8D1X4
- *      mlib_v_ImageChannelInsert_S16_34L_A8D2X4
- *      mlib_v_ImageChannelInsert_S16_34L_D1
- *      mlib_v_ImageChannelInsert_S16_34L
- *
- * SYNOPSIS
- *
- * ARGUMENT
- *      src       pointer to source image data
- *      dst       pointer to destination image data
- *          slb   source image line stride in bytes
- *          dlb   destination image line stride in bytes
- *          dsize       image data size in pixels
- *          xsize       image width in pixels
- *          ysize       image height in lines
- *          cmask channel mask
- *
- * DESCRIPTION
- *          Insert a 3-channel image into the right or left 3 channels of
- *          a 4-channel image low level functions.
- *
- *                BGR => ABGR   (34R), or       RGB => RGBA     (34L)
- *
- * NOTE
- *          These functions are separated from mlib_v_ImageChannelInsert.c
- *          for loop unrolling and structure clarity.
- */
-
-#include <stdlib.h>
-#include "vis_proto.h"
-#include "mlib_image.h"
-
-/***************************************************************/
-#define INSERT_U8_34R                                                                         \
-  sda = vis_fpmerge(vis_read_hi(sd0), vis_read_lo(sd1));                    \
-  sdb = vis_fpmerge(vis_read_lo(sd0), vis_read_hi(sd2));                    \
-  sdc = vis_fpmerge(vis_read_hi(sd1), vis_read_lo(sd2));                    \
-  sdd = vis_fpmerge(vis_read_hi(sda), vis_read_lo(sdb));                    \
-  sde = vis_fpmerge(vis_read_lo(sda), vis_read_hi(sdc));                    \
-  sdf = vis_fpmerge(vis_read_hi(sdb), vis_read_lo(sdc));                    \
-  sdg = vis_fpmerge(vis_read_hi(sdd), vis_read_lo(sde));                    \
-  sdh = vis_fpmerge(vis_read_lo(sdd), vis_read_hi(sdf));                    \
-  sdi = vis_fpmerge(vis_read_hi(sde), vis_read_lo(sdf));                    \
-  sdj = vis_fpmerge(vis_read_hi(sdg), vis_read_hi(sdi));                    \
-  sdk = vis_fpmerge(vis_read_lo(sdg), vis_read_lo(sdi));                    \
-  sdl = vis_fpmerge(vis_read_hi(sdh), vis_read_hi(sdh));                    \
-  sdm = vis_fpmerge(vis_read_lo(sdh), vis_read_lo(sdh));                    \
-  dd0 = vis_fpmerge(vis_read_hi(sdl), vis_read_hi(sdj));                    \
-  dd1 = vis_fpmerge(vis_read_lo(sdl), vis_read_lo(sdj));                    \
-  dd2 = vis_fpmerge(vis_read_hi(sdm), vis_read_hi(sdk));                    \
-  dd3 = vis_fpmerge(vis_read_lo(sdm), vis_read_lo(sdk));
-
-/***************************************************************/
-#define LOAD_INSERT_STORE_U8_34R_A8                                                         \
-  sd0 = *sp++;                                  /* b0g0r0b1g1r1b2g2 */                  \
-  sd1 = *sp++;                                  /* r2b3g3r3b4g4r4b5 */                  \
-  sd2 = *sp++;                                  /* g5r5b6g6r6b7g7r7 */                  \
-  INSERT_U8_34R                                                                                           \
-  vis_pst_8(dd0, dp++, bmask);                                                                \
-  vis_pst_8(dd1, dp++, bmask);                                                                \
-  vis_pst_8(dd2, dp++, bmask);                                                                \
-  vis_pst_8(dd3, dp++, bmask);
-
-/***************************************************************/
-#define LOAD_INSERT_U8_34R                                                                      \
-  vis_alignaddr((void *)soff, 0);                                                             \
-  s0 = s3;                                                                                                    \
-  s1 = sp[1];                                                                                               \
-  s2 = sp[2];                                                                                               \
-  s3 = sp[3];                                                                                               \
-  sd0 = vis_faligndata(s0, s1);                                 \
-  sd1 = vis_faligndata(s1, s2);                                                               \
-  sd2 = vis_faligndata(s2, s3);                                                               \
-  sp += 3;                                                                                                    \
-  dd4 = dd3;                                                                  \
-  INSERT_U8_34R
-
-/***************************************************************/
-/*
- * Both source and destination image data are 1-d vectors and
- * 8-byte aligned. And dsize is multiple of 8.
- */
-
-void
-mlib_v_ImageChannelInsert_U8_34R_A8D1X8(mlib_u8  *src,
-                                                                mlib_u8  *dst,
-                                                                mlib_s32 dsize)
-{
-  mlib_d64  *sp, *dp;
-  mlib_d64  sd0, sd1, sd2;          /* source data */
-  mlib_d64  dd0, dd1, dd2, dd3; /* dst data */
-  mlib_d64  sda, sdb, sdc, sdd; /* intermediate variables */
-  mlib_d64  sde, sdf, sdg, sdh;
-  mlib_d64  sdi, sdj, sdk, sdl;
-  mlib_d64  sdm;
-  int       bmask = 0x77;
-  int       i;
-
-  sp = (mlib_d64 *)src;
-  dp = (mlib_d64 *)dst;
-
-#pragma pipeloop(0)
-  for (i = 0; i < dsize / 8; i++) {
-    LOAD_INSERT_STORE_U8_34R_A8;
-  }
-}
-
-/***************************************************************/
-/*
- * Either source or destination image data are not 1-d vectors, but
- * they are 8-byte aligned. And slb and dlb are multiple of 8.
- * The xsize is multiple of 8.
- */
-
-void
-mlib_v_ImageChannelInsert_U8_34R_A8D2X8(mlib_u8  *src,  mlib_s32 slb,
-                                                                mlib_u8  *dst,  mlib_s32 dlb,
-                                                                mlib_s32 xsize, mlib_s32 ysize)
-{
-  mlib_d64  *sp, *dp;             /* 8-byte aligned pointer for pixel */
-  mlib_d64  *sl, *dl;             /* 8-byte aligned pointer for line */
-  mlib_d64  sd0, sd1, sd2;      /* source data */
-  mlib_d64  dd0, dd1, dd2, dd3; /* dst data */
-  mlib_d64  sda, sdb, sdc, sdd; /* intermediate variables */
-  mlib_d64  sde, sdf, sdg, sdh;
-  mlib_d64  sdi, sdj, sdk, sdl;
-  mlib_d64  sdm;
-  int         bmask = 0x77;
-  int       i, j;               /* indices for x, y */
-
-  sp = sl = (mlib_d64 *)src;
-  dp = dl = (mlib_d64 *)dst;
-
-  /* row loop */
-  for (j = 0; j < ysize; j++) {
-    /* 8-byte column loop */
-#pragma pipeloop(0)
-    for (i = 0; i < xsize / 8; i++) {
-      LOAD_INSERT_STORE_U8_34R_A8;
-    }
-    sp = sl = (mlib_d64 *)((mlib_u8 *)sl + slb);
-    dp = dl = (mlib_d64 *)((mlib_u8 *)dl + dlb);
-  }
-}
-
-/***************************************************************/
-/*
- * either source or destination data are not 8-byte aligned.
- */
-
-void
-mlib_v_ImageChannelInsert_U8_34R_D1(mlib_u8  *src,
-                                                            mlib_u8  *dst,
-                                                            mlib_s32 dsize)
-{
-  mlib_u8   *sa, *da;
-  mlib_u8   *dend, *dend2;      /* end points in dst */
-  mlib_d64  *dp;                  /* 8-byte aligned start points in dst */
-  mlib_d64  *sp;                  /* 8-byte aligned start point in src */
-  mlib_d64  s0, s1, s2, s3;     /* 8-byte source raw data */
-  mlib_d64  sd0, sd1, sd2;      /* 8-byte source data */
-  mlib_d64  dd0, dd1, dd2, dd3; /* dst data */
-  mlib_d64  dd4;                  /* the last datum of the last step */
-  mlib_d64  sda, sdb, sdc, sdd; /* intermediate variables */
-  mlib_d64  sde, sdf, sdg, sdh;
-  mlib_d64  sdi, sdj, sdk, sdl;
-  mlib_d64  sdm;
-  int       soff;                 /* offset of address in src */
-  int       doff;                 /* offset of address in dst */
-  int       emask;              /* edge mask */
-  int         bmask;            /* channel mask */
-  int         i, n;
-
-  sa = src;
-  da = dst;
-
-  /* prepare the source address */
-  sp    = (mlib_d64 *) ((mlib_addr) sa & (~7));
-  soff  = ((mlib_addr) sa & 7);
-
-  /* prepare the destination addresses */
-  dp    = (mlib_d64 *)((mlib_addr) da & (~7));
-  dend  = da + dsize * 4 - 1;
-  dend2 = dend - 31;
-  doff  = ((mlib_addr) da & 7);
-
-  /* set band mask for vis_pst_8 to store the bytes needed */
-  bmask = 0xff & (0x7777 >> doff) ;
-
-  /* generate edge mask for the start point */
-  emask = vis_edge8(da, dend);
-
-  /* load 24 bytes, convert to 32 bytes */
-  s3 = sp[0];                                   /* initial value */
-  LOAD_INSERT_U8_34R;
-
-  if (doff == 0) {                              /* dst is 8-byte aligned */
-
-    if (dsize >= 8 ) {
-      vis_pst_8(dd0, dp++, emask & bmask);
-      vis_pst_8(dd1, dp++, bmask);
-      vis_pst_8(dd2, dp++, bmask);
-      vis_pst_8(dd3, dp++, bmask);
-    }
-    else {                                      /* for very small size */
-      vis_pst_8(dd0, dp++, emask & bmask);
-      if ((mlib_addr) dp <= (mlib_addr) dend)  {
-        emask = vis_edge8(dp, dend);
-        vis_pst_8(dd1, dp++, emask & bmask);
-        if ((mlib_addr) dp <= (mlib_addr) dend)  {
-          emask = vis_edge8(dp, dend);
-          vis_pst_8(dd2, dp++, emask & bmask);
-          if ((mlib_addr) dp <= (mlib_addr) dend)  {
-            emask = vis_edge8(dp, dend);
-            vis_pst_8(dd3, dp++, emask & bmask);
-          }
-        }
-      }
-    }
-
-    /* no edge handling is needed in the loop */
-    if ((mlib_addr) dp <= (mlib_addr) dend2)  {
-      n = ((mlib_u8 *)dend2 - (mlib_u8 *)dp) / 32 + 1;
-#pragma pipeloop(0)
-      for (i = 0; i < n; i++) {
-        LOAD_INSERT_U8_34R;
-        vis_pst_8(dd0, dp++, bmask);
-        vis_pst_8(dd1, dp++, bmask);
-        vis_pst_8(dd2, dp++, bmask);
-        vis_pst_8(dd3, dp++, bmask);
-      }
-    }
-
-    if ((mlib_addr) dp <= (mlib_addr) dend)  {
-      LOAD_INSERT_U8_34R;
-      emask = vis_edge8(dp, dend);
-      vis_pst_8(dd0, dp++, emask & bmask);
-      if ((mlib_addr) dp <= (mlib_addr) dend)  {
-        emask = vis_edge8(dp, dend);
-        vis_pst_8(dd1, dp++, emask & bmask);
-        if ((mlib_addr) dp <= (mlib_addr) dend)  {
-          emask = vis_edge8(dp, dend);
-          vis_pst_8(dd2, dp++, emask & bmask);
-          if ((mlib_addr) dp <= (mlib_addr) dend)  {
-            emask = vis_edge8(dp, dend);
-            vis_pst_8(dd3, dp++, emask & bmask);
-          }
-        }
-      }
-    }
-  }
-  else {                                        /* (doff != 0) */
-    vis_alignaddr((void *)0, -doff);
-
-    if (dsize >= 8 ) {
-      vis_pst_8(vis_faligndata(dd0, dd0), dp++, emask & bmask);
-      vis_pst_8(vis_faligndata(dd0, dd1), dp++, bmask);
-      vis_pst_8(vis_faligndata(dd1, dd2), dp++, bmask);
-      vis_pst_8(vis_faligndata(dd2, dd3), dp++, bmask);
-    }
-    else {                                      /* for very small size */
-      vis_pst_8(vis_faligndata(dd0, dd0), dp++, emask & bmask);
-      if ((mlib_addr) dp <= (mlib_addr) dend)  {
-        emask = vis_edge8(dp, dend);
-        vis_pst_8(vis_faligndata(dd0, dd1), dp++, emask & bmask);
-        if ((mlib_addr) dp <= (mlib_addr) dend)  {
-          emask = vis_edge8(dp, dend);
-          vis_pst_8(vis_faligndata(dd1, dd2), dp++, emask & bmask);
-          if ((mlib_addr) dp <= (mlib_addr) dend)  {
-            emask = vis_edge8(dp, dend);
-            vis_pst_8(vis_faligndata(dd2, dd3), dp++, emask & bmask);
-            if ((mlib_addr) dp <= (mlib_addr) dend)  {
-              emask = vis_edge8(dp, dend);
-              vis_pst_8(vis_faligndata(dd3, dd3), dp++, emask & bmask);
-            }
-          }
-        }
-      }
-    }
-
-    /* no edge handling is needed in the loop */
-    if ((mlib_addr) dp <= (mlib_addr) dend2)  {
-      n = ((mlib_u8 *)dend2 - (mlib_u8 *)dp) / 32 + 1;
-#pragma pipeloop(0)
-      for (i = 0; i < n; i++) {
-        LOAD_INSERT_U8_34R;
-        vis_alignaddr((void *)0, -doff);
-        vis_pst_8(vis_faligndata(dd4, dd0), dp++, bmask);
-        vis_pst_8(vis_faligndata(dd0, dd1), dp++, bmask);
-        vis_pst_8(vis_faligndata(dd1, dd2), dp++, bmask);
-        vis_pst_8(vis_faligndata(dd2, dd3), dp++, bmask);
-      }
-    }
-
-    if ((mlib_addr) dp <= (mlib_addr) dend)  {
-      LOAD_INSERT_U8_34R;
-      vis_alignaddr((void *)0, -doff);
-      emask = vis_edge8(dp, dend);
-      vis_pst_8(vis_faligndata(dd4, dd0), dp++, emask & bmask);
-      if ((mlib_addr) dp <= (mlib_addr) dend)  {
-        emask = vis_edge8(dp, dend);
-        vis_pst_8(vis_faligndata(dd0, dd1), dp++, emask & bmask);
-        if ((mlib_addr) dp <= (mlib_addr) dend)  {
-          emask = vis_edge8(dp, dend);
-          vis_pst_8(vis_faligndata(dd1, dd2), dp++, emask & bmask);
-          if ((mlib_addr) dp <= (mlib_addr) dend)  {
-            emask = vis_edge8(dp, dend);
-            vis_pst_8(vis_faligndata(dd2, dd3), dp++, emask & bmask);
-          }
-        }
-      }
-    }
-  }
-}
-
-/***************************************************************/
-
-void
-mlib_v_ImageChannelInsert_U8_34R(mlib_u8  *src,  mlib_s32 slb,
-                                                 mlib_u8  *dst,  mlib_s32 dlb,
-                                                         mlib_s32 xsize, mlib_s32 ysize)
-{
-  mlib_u8   *sa, *da;
-  mlib_u8   *sl, *dl;
-  int         j;
-
-  sa = sl = src;
-  da = dl = dst;
-
-#pragma pipeloop(0)
-  for (j = 0; j < ysize; j++) {
-    mlib_v_ImageChannelInsert_U8_34R_D1(sa, da, xsize);
-    sa = sl += slb;
-    da = dl += dlb;
-  }
-}
-
-/***************************************************************/
-#define INSERT_S16_34R                                                                              \
-  vis_alignaddr((void *)0, 6);                                                                \
-  dd0 = vis_faligndata(sd0, sd0);                 /* b1b0g0r0 */                \
-  vis_alignaddr((void *)0, 4);                                                                \
-  dd1 = vis_faligndata(sd0, sd1);                 /* r0b1gbr1 */                \
-  vis_alignaddr((void *)0, 2);                                                                \
-  dd2 = vis_faligndata(sd1, sd2);                       /* r1b2g2r2 */          \
-  dd3 = sd2;                                                          /* r2b3g3r3 */
-
-/***************************************************************/
-#define LOAD_INSERT_STORE_S16_34R_A8                                                      \
-  sd0 = *sp++;                                          /* b0g0r0b1 */                      \
-  sd1 = *sp++;                                          /* g1r1b2g2 */                      \
-  sd2 = *sp++;                                          /* r2b3g3r3 */                      \
-  INSERT_S16_34R                                                                                          \
-  vis_pst_16(dd0, dp++, bmask);                                                               \
-  vis_pst_16(dd1, dp++, bmask);                                                               \
-  vis_pst_16(dd2, dp++, bmask);                                                               \
-  vis_pst_16(dd3, dp++, bmask);
-
-/***************************************************************/
-#define LOAD_INSERT_S16_34R                                                                       \
-  vis_alignaddr((void *)soff, 0);                                                             \
-  s0 = s3;                                                                                                    \
-  s1 = sp[1];                                                                                               \
-  s2 = sp[2];                                                                                               \
-  s3 = sp[3];                                                                                               \
-  sd0 = vis_faligndata(s0, s1);                                                               \
-  sd1 = vis_faligndata(s1, s2);                                                               \
-  sd2 = vis_faligndata(s2, s3);                                                               \
-  sp += 3;                                                                                                    \
-  dd4 = dd3;                                                                                                \
-  INSERT_S16_34R
-
-/***************************************************************/
-/*
- * both source and destination image data are 1-d vectors and
- * 8-byte aligned.  dsize is multiple of 4.
- */
-
-void
-mlib_v_ImageChannelInsert_S16_34R_A8D1X4(mlib_s16 *src,
-                                                                 mlib_s16 *dst,
-                                                                 mlib_s32 dsize)
-{
-  mlib_d64  *sp, *dp;           /* 8-byte aligned pointer for pixel */
-  mlib_d64  sd0, sd1, sd2;      /* source data */
-  mlib_d64  dd0, dd1, dd2, dd3; /* dst data */
-  int       bmask = 0x07;       /* channel mask */
-  int       i;
-
-  sp = (mlib_d64 *)src;
-  dp = (mlib_d64 *)dst;
-
-  /* set GSR.offset for vis_faligndata()  */
-  /* vis_alignaddr((void *)0, 2); */            /* only for _old */
-
-#pragma pipeloop(0)
-  for (i = 0; i < dsize / 4; i++) {
-    LOAD_INSERT_STORE_S16_34R_A8;
-  }
-}
-
-/***************************************************************/
-/*
- * either source or destination image data are not 1-d vectors, but
- * they are 8-byte aligned.  xsize is multiple of 4.
- */
-
-void
-mlib_v_ImageChannelInsert_S16_34R_A8D2X4(mlib_s16 *src,  mlib_s32 slb,
-                                                                 mlib_s16 *dst,  mlib_s32 dlb,
-                                                                 mlib_s32 xsize, mlib_s32 ysize)
-{
-  mlib_d64  *sp, *dp;           /* 8-byte aligned pointer for pixel */
-  mlib_d64  *sl, *dl;           /* 8-byte aligned pointer for line */
-  mlib_d64  sd0, sd1, sd2;      /* source data */
-  mlib_d64  dd0, dd1, dd2, dd3; /* dst data */
-  int       bmask = 0x07;       /* channel mask */
-  int       i, j;               /* indices for x, y */
-
-  sp = sl = (mlib_d64 *)src;
-  dp = dl = (mlib_d64 *)dst;
-
-  /* row loop */
-  for (j = 0; j < ysize; j++) {
-    /* 4-pixel column loop */
-#pragma pipeloop(0)
-    for (i = 0; i < xsize / 4; i++) {
-      LOAD_INSERT_STORE_S16_34R_A8;
-    }
-    sp = sl = (mlib_d64 *)((mlib_u8 *)sl + slb);
-    dp = dl = (mlib_d64 *)((mlib_u8 *)dl + dlb);
-  }
-}
-
-/***************************************************************/
-/*
- * either source or destination data are not 8-byte aligned.
- */
-
-void
-mlib_v_ImageChannelInsert_S16_34R_D1(mlib_s16 *src,
-                                                             mlib_s16 *dst,
-                                                             mlib_s32 dsize)
-{
-  mlib_s16  *sa, *da;           /* pointer for pixel */
-  mlib_s16  *dend, *dend2;      /* end points in dst */
-  mlib_d64  *dp;                /* 8-byte aligned start points in dst */
-  mlib_d64  *sp;                /* 8-byte aligned start point in src */
-  mlib_d64  s0, s1, s2, s3;     /* 8-byte source raw data */
-  mlib_d64  sd0, sd1, sd2;      /* 8-byte source data */
-  mlib_d64  dd0, dd1, dd2, dd3; /* dst data */
-  mlib_d64  dd4;                /* the last datum of the last step */
-  int soff;             /* offset of address in src */
-  int doff;             /* offset of address in dst */
-  int       emask;              /* edge mask */
-  int       bmask;              /* channel mask */
-  int       i, n;
-
-  sa = src;
-  da = dst;
-
-  /* prepare the source address */
-  sp    = (mlib_d64 *) ((mlib_addr) sa & (~7));
-  soff  = ((mlib_addr) sa & 7);
-
-  /* prepare the destination addresses */
-  dp    = (mlib_d64 *)((mlib_addr) da & (~7));
-  dend  = da + dsize * 4 - 1;
-  dend2 = dend - 15;
-  doff  = ((mlib_addr) da & 7);
-
-  /* set channel mask for vis_pst_16 to store the words needed */
-  bmask = 0xff & (0x77 >> (doff / 2));
-
-  /* generate edge mask for the start point */
-  emask = vis_edge16(da, dend);
-
-  /* load 24 byte, convert, store 32 bytes */
-  s3 = sp[0];                                   /* initial value */
-  LOAD_INSERT_S16_34R;
-
-  if (doff == 0) {                              /* dst is 8-byte aligned */
-
-    if (dsize >= 4 ) {
-      vis_pst_16(dd0, dp++, emask & bmask);
-      vis_pst_16(dd1, dp++, bmask);
-      vis_pst_16(dd2, dp++, bmask);
-      vis_pst_16(dd3, dp++, bmask);
-    }
-    else {                                      /* for very small size */
-      vis_pst_16(dd0, dp++, emask & bmask);
-      if ((mlib_addr) dp <= (mlib_addr) dend)  {
-        emask = vis_edge16(dp, dend);
-        vis_pst_16(dd1, dp++, emask & bmask);
-        if ((mlib_addr) dp <= (mlib_addr) dend)  {
-          emask = vis_edge16(dp, dend);
-          vis_pst_16(dd2, dp++, emask & bmask);
-        }
-      }
-    }
-
-    /* no edge handling is needed in the loop */
-    if ((mlib_addr) dp <= (mlib_addr) dend2)  {
-      n = ((mlib_u8 *)dend2 - (mlib_u8 *)dp) / 32 + 1;
-#pragma pipeloop(0)
-      for (i = 0; i < n; i++) {
-        LOAD_INSERT_S16_34R;
-        vis_pst_16(dd0, dp++, bmask);
-        vis_pst_16(dd1, dp++, bmask);
-        vis_pst_16(dd2, dp++, bmask);
-        vis_pst_16(dd3, dp++, bmask);
-      }
-    }
-
-    if ((mlib_addr) dp <= (mlib_addr) dend)  {
-      LOAD_INSERT_S16_34R;
-      emask = vis_edge16(dp, dend);
-      vis_pst_16(dd0, dp++, emask & bmask);
-      if ((mlib_addr) dp <= (mlib_addr) dend)  {
-        emask = vis_edge16(dp, dend);
-        vis_pst_16(dd1, dp++, emask & bmask);
-        if ((mlib_addr) dp <= (mlib_addr) dend)  {
-          emask = vis_edge16(dp, dend);
-          vis_pst_16(dd2, dp++, emask & bmask);
-        }
-      }
-    }
-  }
-  else {                                        /* (doff != 0) */
-    vis_alignaddr((void *)0, -doff);
-
-    if (dsize >= 4 ) {
-      vis_pst_16(vis_faligndata(dd0, dd0), dp++, emask & bmask);
-      vis_pst_16(vis_faligndata(dd0, dd1), dp++, bmask);
-      vis_pst_16(vis_faligndata(dd1, dd2), dp++, bmask);
-      vis_pst_16(vis_faligndata(dd2, dd3), dp++, bmask);
-    }
-    else {                                      /* for very small size */
-      vis_pst_16(vis_faligndata(dd0, dd0), dp++, emask & bmask);
-      if ((mlib_addr) dp <= (mlib_addr) dend)  {
-        emask = vis_edge16(dp, dend);
-        vis_pst_16(vis_faligndata(dd0, dd1), dp++, emask & bmask);
-        if ((mlib_addr) dp <= (mlib_addr) dend)  {
-          emask = vis_edge16(dp, dend);
-          vis_pst_16(vis_faligndata(dd1, dd2), dp++, emask & bmask);
-          if ((mlib_addr) dp <= (mlib_addr) dend)  {
-            emask = vis_edge16(dp, dend);
-            vis_pst_16(vis_faligndata(dd2, dd3), dp++, emask & bmask);
-          }
-        }
-      }
-    }
-
-    /* no edge handling is needed in the loop */
-    if ((mlib_addr) dp <= (mlib_addr) dend2)  {
-      n = ((mlib_u8 *)dend2 - (mlib_u8 *)dp) / 32 + 1;
-#pragma pipeloop(0)
-      for (i = 0; i < n; i++) {
-        LOAD_INSERT_S16_34R;
-        vis_alignaddr((void *)0, -doff);
-        vis_pst_16(vis_faligndata(dd4, dd0), dp++, bmask);
-        vis_pst_16(vis_faligndata(dd0, dd1), dp++, bmask);
-        vis_pst_16(vis_faligndata(dd1, dd2), dp++, bmask);
-        vis_pst_16(vis_faligndata(dd2, dd3), dp++, bmask);
-      }
-    }
-
-    if ((mlib_addr) dp <= (mlib_addr) dend)  {
-      LOAD_INSERT_S16_34R;
-      vis_alignaddr((void *)0, -doff);
-      emask = vis_edge16(dp, dend);
-      vis_pst_16(vis_faligndata(dd4, dd0), dp++, emask & bmask);
-      if ((mlib_addr) dp <= (mlib_addr) dend)  {
-        emask = vis_edge16(dp, dend);
-        vis_pst_16(vis_faligndata(dd0, dd1), dp++, emask & bmask);
-        if ((mlib_addr) dp <= (mlib_addr) dend)  {
-          emask = vis_edge16(dp, dend);
-          vis_pst_16(vis_faligndata(dd1, dd2), dp++, emask & bmask);
-          if ((mlib_addr) dp <= (mlib_addr) dend)  {
-            emask = vis_edge16(dp, dend);
-            vis_pst_16(vis_faligndata(dd2, dd3), dp++, emask & bmask);
-          }
-        }
-      }
-    }
-  }
-}
-
-/***************************************************************/
-
-void
-mlib_v_ImageChannelInsert_S16_34R(mlib_s16 *src,  mlib_s32 slb,
-                                                          mlib_s16 *dst,  mlib_s32 dlb,
-                                                          mlib_s32 xsize, mlib_s32 ysize)
-{
-  mlib_s16  *sa, *da;
-  mlib_s16  *sl, *dl;
-  int       j;
-
-  sa = sl = src;
-  da = dl = dst;
-
-#pragma pipeloop(0)
-  for (j = 0; j < ysize; j++) {
-    mlib_v_ImageChannelInsert_S16_34R_D1(sa, da, xsize);
-    sa = sl = (mlib_s16 *)((mlib_u8 *)sl + slb);
-    da = dl = (mlib_s16 *)((mlib_u8 *)dl + dlb);
-  }
-}
-
-/***************************************************************/
-#define INSERT_U8_34L                                                                                 \
-  sda = vis_fpmerge(vis_read_hi(sd0), vis_read_lo(sd1));                    \
-  sdb = vis_fpmerge(vis_read_lo(sd0), vis_read_hi(sd2));                    \
-  sdc = vis_fpmerge(vis_read_hi(sd1), vis_read_lo(sd2));                    \
-  sdd = vis_fpmerge(vis_read_hi(sda), vis_read_lo(sdb));                    \
-  sde = vis_fpmerge(vis_read_lo(sda), vis_read_hi(sdc));                    \
-  sdf = vis_fpmerge(vis_read_hi(sdb), vis_read_lo(sdc));                    \
-  sdg = vis_fpmerge(vis_read_hi(sdd), vis_read_lo(sde));                    \
-  sdh = vis_fpmerge(vis_read_lo(sdd), vis_read_hi(sdf));                    \
-  sdi = vis_fpmerge(vis_read_hi(sde), vis_read_lo(sdf));                    \
-  sdj = vis_fpmerge(vis_read_hi(sdg), vis_read_hi(sdi));                    \
-  sdk = vis_fpmerge(vis_read_lo(sdg), vis_read_lo(sdi));                    \
-  sdl = vis_fpmerge(vis_read_hi(sdh), vis_read_hi(sdh));                    \
-  sdm = vis_fpmerge(vis_read_lo(sdh), vis_read_lo(sdh));                    \
-  dd0 = vis_fpmerge(vis_read_hi(sdj), vis_read_hi(sdl));                    \
-  dd1 = vis_fpmerge(vis_read_lo(sdj), vis_read_lo(sdl));                    \
-  dd2 = vis_fpmerge(vis_read_hi(sdk), vis_read_hi(sdm));                    \
-  dd3 = vis_fpmerge(vis_read_lo(sdk), vis_read_lo(sdm));
-
-/***************************************************************/
-#define LOAD_INSERT_STORE_U8_34L_A8                                                         \
-  sd0 = *sp++;                                  /* b0g0r0b1g1r1b2g2 */                  \
-  sd1 = *sp++;                                  /* r2b3g3r3b4g4r4b5 */                  \
-  sd2 = *sp++;                                  /* g5r5b6g6r6b7g7r7 */                  \
-  INSERT_U8_34L                                                                                                       \
-  vis_pst_8(dd0, dp++, bmask);                                                                \
-  vis_pst_8(dd1, dp++, bmask);                                                                \
-  vis_pst_8(dd2, dp++, bmask);                                                                \
-  vis_pst_8(dd3, dp++, bmask);
-
-/***************************************************************/
-#define LOAD_INSERT_U8_34L                                                                        \
-  vis_alignaddr((void *)soff, 0);                                                             \
-  s0 = s3;                                                                                                    \
-  s1 = sp[1];                                                                                               \
-  s2 = sp[2];                                                                                               \
-  s3 = sp[3];                                                                                               \
-  sd0 = vis_faligndata(s0, s1);                                 \
-  sd1 = vis_faligndata(s1, s2);                                                               \
-  sd2 = vis_faligndata(s2, s3);                                                               \
-  sp += 3;                                                                                                    \
-  dd4 = dd3;                                                    \
-  INSERT_U8_34L
-
-/***************************************************************/
-/*
- * Both source and destination image data are 1-d vectors and
- * 8-byte aligned. And dsize is multiple of 8.
- */
-void
-mlib_v_ImageChannelInsert_U8_34L_A8D1X8(mlib_u8  *src,
-                                                                mlib_u8  *dst,
-                                                                mlib_s32 dsize)
-{
-  mlib_d64  *sp, *dp;
-  mlib_d64  sd0, sd1, sd2;          /* source data */
-  mlib_d64  dd0, dd1, dd2, dd3; /* dst data */
-  mlib_d64  sda, sdb, sdc, sdd; /* intermediate variables */
-  mlib_d64  sde, sdf, sdg, sdh;
-  mlib_d64  sdi, sdj, sdk, sdl;
-  mlib_d64  sdm;
-  int         bmask = 0xee;
-  int         i;
-
-  sp = (mlib_d64 *)src;
-  dp = (mlib_d64 *)dst;
-
-#pragma pipeloop(0)
-  for (i = 0; i < dsize / 8; i++) {
-    LOAD_INSERT_STORE_U8_34L_A8;
-  }
-}
-
-/***************************************************************/
-/*
- * Either source or destination image data are not 1-d vectors, but
- * they are 8-byte aligned. And slb and dlb are multiple of 8.
- * The xsize is multiple of 8.
- */
-void
-mlib_v_ImageChannelInsert_U8_34L_A8D2X8(mlib_u8  *src,  mlib_s32 slb,
-                                                                mlib_u8  *dst,  mlib_s32 dlb,
-                                                        mlib_s32 xsize, mlib_s32 ysize)
-{
-  mlib_d64  *sp, *dp;           /* 8-byte aligned pointer for pixel */
-  mlib_d64  *sl, *dl;           /* 8-byte aligned pointer for line */
-  mlib_d64  sd0, sd1, sd2;      /* source data */
-  mlib_d64  dd0, dd1, dd2, dd3; /* dst data */
-  mlib_d64  sda, sdb, sdc, sdd; /* intermediate variables */
-  mlib_d64  sde, sdf, sdg, sdh;
-  mlib_d64  sdi, sdj, sdk, sdl;
-  mlib_d64  sdm;
-  int         bmask = 0xee;
-  int       i, j;               /* indices for x, y */
-
-  sp = sl = (mlib_d64 *)src;
-  dp = dl = (mlib_d64 *)dst;
-
-  /* row loop */
-  for (j = 0; j < ysize; j++) {
-    /* 8-byte column loop */
-#pragma pipeloop(0)
-    for (i = 0; i < xsize / 8; i++) {
-      LOAD_INSERT_STORE_U8_34L_A8;
-    }
-    sp = sl = (mlib_d64 *)((mlib_u8 *)sl + slb);
-    dp = dl = (mlib_d64 *)((mlib_u8 *)dl + dlb);
-  }
-}
-
-/***************************************************************/
-/*
- * either source or destination data are not 8-byte aligned.
- */
-void
-mlib_v_ImageChannelInsert_U8_34L_D1(mlib_u8  *src,
-                                                            mlib_u8  *dst,
-                                                            mlib_s32 dsize)
-{
-  mlib_u8   *sa, *da;
-  mlib_u8   *dend, *dend2;      /* end points in dst */
-  mlib_d64  *dp;                /* 8-byte aligned start points in dst */
-  mlib_d64  *sp;                /* 8-byte aligned start point in src */
-  mlib_d64  s0, s1, s2, s3;     /* 8-byte source raw data */
-  mlib_d64  sd0, sd1, sd2;      /* 8-byte source data */
-  mlib_d64  dd0, dd1, dd2, dd3; /* dst data */
-  mlib_d64  dd4;                /* the last datum of the last step */
-  mlib_d64  sda, sdb, sdc, sdd; /* intermediate variables */
-  mlib_d64  sde, sdf, sdg, sdh;
-  mlib_d64  sdi, sdj, sdk, sdl;
-  mlib_d64  sdm;
-  int       soff;               /* offset of address in src */
-  int       doff;               /* offset of address in dst */
-  int       emask;              /* edge mask */
-  int         bmask;            /* channel mask */
-  int         i, n;
-
-  sa = src;
-  da = dst;
-
-  /* prepare the source address */
-  sp    = (mlib_d64 *) ((mlib_addr) sa & (~7));
-  soff  = ((mlib_addr) sa & 7);
-
-  /* prepare the destination addresses */
-  dp    = (mlib_d64 *)((mlib_addr) da & (~7));
-  dend  = da + dsize * 4 - 1;
-  dend2 = dend - 31;
-  doff  = ((mlib_addr) da & 7);
-
-  /* set band mask for vis_pst_8 to store the bytes needed */
-  bmask = 0xff & (0xeeee >> doff) ;
-
-  /* generate edge mask for the start point */
-  emask = vis_edge8(da, dend);
-
-  /* load 24 bytes, convert to 32 bytes */
-  s3 = sp[0];                                   /* initial value */
-  LOAD_INSERT_U8_34L;
-
-  if (doff == 0) {                              /* dst is 8-byte aligned */
-
-    if (dsize >= 8 ) {
-      vis_pst_8(dd0, dp++, emask & bmask);
-      vis_pst_8(dd1, dp++, bmask);
-      vis_pst_8(dd2, dp++, bmask);
-      vis_pst_8(dd3, dp++, bmask);
-    }
-    else {                                      /* for very small size */
-      vis_pst_8(dd0, dp++, emask & bmask);
-      if ((mlib_addr) dp <= (mlib_addr) dend)  {
-        emask = vis_edge8(dp, dend);
-        vis_pst_8(dd1, dp++, emask & bmask);
-        if ((mlib_addr) dp <= (mlib_addr) dend)  {
-          emask = vis_edge8(dp, dend);
-          vis_pst_8(dd2, dp++, emask & bmask);
-          if ((mlib_addr) dp <= (mlib_addr) dend)  {
-            emask = vis_edge8(dp, dend);
-            vis_pst_8(dd3, dp++, emask & bmask);
-          }
-        }
-      }
-    }
-
-    /* no edge handling is needed in the loop */
-    if ((mlib_addr) dp <= (mlib_addr) dend2)  {
-      n = ((mlib_u8 *)dend2 - (mlib_u8 *)dp) / 32 + 1;
-#pragma pipeloop(0)
-      for (i = 0; i < n; i++) {
-        LOAD_INSERT_U8_34L;
-        vis_pst_8(dd0, dp++, bmask);
-        vis_pst_8(dd1, dp++, bmask);
-        vis_pst_8(dd2, dp++, bmask);
-        vis_pst_8(dd3, dp++, bmask);
-      }
-    }
-
-    if ((mlib_addr) dp <= (mlib_addr) dend)  {
-      LOAD_INSERT_U8_34L;
-      emask = vis_edge8(dp, dend);
-      vis_pst_8(dd0, dp++, emask & bmask);
-      if ((mlib_addr) dp <= (mlib_addr) dend)  {
-        emask = vis_edge8(dp, dend);
-        vis_pst_8(dd1, dp++, emask & bmask);
-        if ((mlib_addr) dp <= (mlib_addr) dend)  {
-          emask = vis_edge8(dp, dend);
-          vis_pst_8(dd2, dp++, emask & bmask);
-          if ((mlib_addr) dp <= (mlib_addr) dend)  {
-            emask = vis_edge8(dp, dend);
-            vis_pst_8(dd3, dp++, emask & bmask);
-          }
-        }
-      }
-    }
-  }
-  else {                                        /* (doff != 0) */
-    vis_alignaddr((void *)0, -doff);
-
-    if (dsize >= 8 ) {
-      vis_pst_8(vis_faligndata(dd0, dd0), dp++, emask & bmask);
-      vis_pst_8(vis_faligndata(dd0, dd1), dp++, bmask);
-      vis_pst_8(vis_faligndata(dd1, dd2), dp++, bmask);
-      vis_pst_8(vis_faligndata(dd2, dd3), dp++, bmask);
-    }
-    else {                                      /* for very small size */
-      vis_pst_8(vis_faligndata(dd0, dd0), dp++, emask & bmask);
-      if ((mlib_addr) dp <= (mlib_addr) dend)  {
-        emask = vis_edge8(dp, dend);
-        vis_pst_8(vis_faligndata(dd0, dd1), dp++, emask & bmask);
-        if ((mlib_addr) dp <= (mlib_addr) dend)  {
-          emask = vis_edge8(dp, dend);
-          vis_pst_8(vis_faligndata(dd1, dd2), dp++, emask & bmask);
-          if ((mlib_addr) dp <= (mlib_addr) dend)  {
-            emask = vis_edge8(dp, dend);
-            vis_pst_8(vis_faligndata(dd2, dd3), dp++, emask & bmask);
-            if ((mlib_addr) dp <= (mlib_addr) dend)  {
-              emask = vis_edge8(dp, dend);
-              vis_pst_8(vis_faligndata(dd3, dd3), dp++, emask & bmask);
-            }
-          }
-        }
-      }
-    }
-
-    /* no edge handling is needed in the loop */
-    if ((mlib_addr) dp <= (mlib_addr) dend2)  {
-      n = ((mlib_u8 *)dend2 - (mlib_u8 *)dp) / 32 + 1;
-#pragma pipeloop(0)
-      for (i = 0; i < n; i++) {
-        LOAD_INSERT_U8_34L;
-        vis_alignaddr((void *)0, -doff);
-        vis_pst_8(vis_faligndata(dd4, dd0), dp++, bmask);
-        vis_pst_8(vis_faligndata(dd0, dd1), dp++, bmask);
-        vis_pst_8(vis_faligndata(dd1, dd2), dp++, bmask);
-        vis_pst_8(vis_faligndata(dd2, dd3), dp++, bmask);
-      }
-    }
-
-    if ((mlib_addr) dp <= (mlib_addr) dend)  {
-      LOAD_INSERT_U8_34L;
-      vis_alignaddr((void *)0, -doff);
-      emask = vis_edge8(dp, dend);
-      vis_pst_8(vis_faligndata(dd4, dd0), dp++, emask & bmask);
-      if ((mlib_addr) dp <= (mlib_addr) dend)  {
-        emask = vis_edge8(dp, dend);
-        vis_pst_8(vis_faligndata(dd0, dd1), dp++, emask & bmask);
-        if ((mlib_addr) dp <= (mlib_addr) dend)  {
-          emask = vis_edge8(dp, dend);
-          vis_pst_8(vis_faligndata(dd1, dd2), dp++, emask & bmask);
-          if ((mlib_addr) dp <= (mlib_addr) dend)  {
-            emask = vis_edge8(dp, dend);
-            vis_pst_8(vis_faligndata(dd2, dd3), dp++, emask & bmask);
-          }
-        }
-      }
-    }
-  }
-}
-
-/***************************************************************/
-void
-mlib_v_ImageChannelInsert_U8_34L(mlib_u8  *src,  mlib_s32 slb,
-                                                         mlib_u8  *dst,  mlib_s32 dlb,
-                                                         mlib_s32 xsize, mlib_s32 ysize)
-{
-  mlib_u8   *sa, *da;
-  mlib_u8   *sl, *dl;
-  int         j;
-
-  sa = sl = src;
-  da = dl = dst;
-
-#pragma pipeloop(0)
-  for (j = 0; j < ysize; j++) {
-    mlib_v_ImageChannelInsert_U8_34L_D1(sa, da, xsize);
-    sa = sl += slb;
-    da = dl += dlb;
-  }
-}
-
-/***************************************************************/
-#define INSERT_S16_34L                                                                              \
-  dd0 = sd0;                                                            /* b0g0r0b1 */        \
-  vis_alignaddr((void *)0, 6);                                                                \
-  dd1 = vis_faligndata(sd0, sd1);                       /* b1gbr1b2 */        \
-  vis_alignaddr((void *)0, 4);                                                                \
-  dd2 = vis_faligndata(sd1, sd2);                         /* b2g2r2b3 */              \
-  vis_alignaddr((void *)0, 2);                                                                \
-  dd3 = vis_faligndata(sd2, sd2);                         /* b3g3r3r2 */
-
-/***************************************************************/
-#define LOAD_INSERT_STORE_S16_34L_A8                                                      \
-  sd0 = *sp++;                                          /* b0g0r0b1 */                          \
-  sd1 = *sp++;                                          /* g1r1b2g2 */                      \
-  sd2 = *sp++;                                          /* r2b3g3r3 */                      \
-  INSERT_S16_34L                                                                                          \
-  vis_pst_16(dd0, dp++, bmask);                                                               \
-  vis_pst_16(dd1, dp++, bmask);                                                               \
-  vis_pst_16(dd2, dp++, bmask);                                                               \
-  vis_pst_16(dd3, dp++, bmask);
-
-/***************************************************************/
-#define LOAD_INSERT_S16_34L                                                                       \
-  vis_alignaddr((void *)soff, 0);                                                             \
-  s0 = s3;                                                                                                    \
-  s1 = sp[1];                                                                                               \
-  s2 = sp[2];                                                                                               \
-  s3 = sp[3];                                                                                               \
-  sd0 = vis_faligndata(s0, s1);                                                               \
-  sd1 = vis_faligndata(s1, s2);                                                               \
-  sd2 = vis_faligndata(s2, s3);                                                               \
-  sp += 3;                                                                                                    \
-  dd4 = dd3;                                                                                                \
-  INSERT_S16_34L
-
-/***************************************************************/
-/*
- * both source and destination image data are 1-d vectors and
- * 8-byte aligned.  dsize is multiple of 4.
- */
-
-void
-mlib_v_ImageChannelInsert_S16_34L_A8D1X4(mlib_s16 *src,
-                                                                 mlib_s16 *dst,
-                                                                 mlib_s32 dsize)
-{
-  mlib_d64  *sp, *dp;           /* 8-byte aligned pointer for pixel */
-  mlib_d64  sd0, sd1, sd2;      /* source data */
-  mlib_d64  dd0, dd1, dd2, dd3; /* dst data */
-  int       bmask = 0x0e;       /* channel mask */
-  int       i;
-
-  sp = (mlib_d64 *)src;
-  dp = (mlib_d64 *)dst;
-
-#pragma pipeloop(0)
-  for (i = 0; i < dsize / 4; i++) {
-    LOAD_INSERT_STORE_S16_34L_A8;
-  }
-}
-
-/***************************************************************/
-/*
- * either source or destination image data are not 1-d vectors, but
- * they are 8-byte aligned.  xsize is multiple of 4.
- */
-
-void
-mlib_v_ImageChannelInsert_S16_34L_A8D2X4(mlib_s16 *src,  mlib_s32 slb,
-                                                                 mlib_s16 *dst,  mlib_s32 dlb,
-                                                                 mlib_s32 xsize, mlib_s32 ysize)
-{
-  mlib_d64  *sp, *dp;           /* 8-byte aligned pointer for pixel */
-  mlib_d64  *sl, *dl;           /* 8-byte aligned pointer for line */
-  mlib_d64  sd0, sd1, sd2;      /* source data */
-  mlib_d64  dd0, dd1, dd2, dd3; /* dst data */
-  int       bmask = 0x0e;       /* channel mask */
-  int       i, j;               /* indices for x, y */
-
-  sp = sl = (mlib_d64 *)src;
-  dp = dl = (mlib_d64 *)dst;
-
-  /* row loop */
-  for (j = 0; j < ysize; j++) {
-    /* 4-pixel column loop */
-#pragma pipeloop(0)
-    for (i = 0; i < xsize / 4; i++) {
-      LOAD_INSERT_STORE_S16_34L_A8;
-    }
-    sp = sl = (mlib_d64 *)((mlib_u8 *)sl + slb);
-    dp = dl = (mlib_d64 *)((mlib_u8 *)dl + dlb);
-  }
-}
-
-/***************************************************************/
-/*
- * either source or destination data are not 8-byte aligned.
- */
-
-void
-mlib_v_ImageChannelInsert_S16_34L_D1(mlib_s16 *src,
-                                                             mlib_s16 *dst,
-                                                             mlib_s32 dsize)
-{
-  mlib_s16  *sa, *da;           /* pointer for pixel */
-  mlib_s16  *dend, *dend2;      /* end points in dst */
-  mlib_d64  *dp;                /* 8-byte aligned start points in dst */
-  mlib_d64  *sp;                /* 8-byte aligned start point in src */
-  mlib_d64  s0, s1, s2, s3;     /* 8-byte source raw data */
-  mlib_d64  sd0, sd1, sd2;      /* 8-byte source data */
-  mlib_d64  dd0, dd1, dd2, dd3; /* dst data */
-  mlib_d64  dd4;                /* the last datum of the last step */
-  int soff;             /* offset of address in src */
-  int doff;             /* offset of address in dst */
-  int       emask;              /* edge mask */
-  int       bmask;              /* channel mask */
-  int       i, n;
-
-  sa = src;
-  da = dst;
-
-  /* prepare the source address */
-  sp    = (mlib_d64 *) ((mlib_addr) sa & (~7));
-  soff  = ((mlib_addr) sa & 7);
-
-  /* prepare the destination addresses */
-  dp    = (mlib_d64 *)((mlib_addr) da & (~7));
-  dend  = da + dsize * 4 - 1;
-  dend2 = dend - 15;
-  doff  = ((mlib_addr) da & 7);
-
-  /* set channel mask for vis_pst_16 to store the words needed */
-  bmask = 0xff & (0xee >> (doff / 2));
-
-  /* generate edge mask for the start point */
-  emask = vis_edge16(da, dend);
-
-  /* load 24 byte, convert, store 32 bytes */
-  s3 = sp[0];                                   /* initial value */
-  LOAD_INSERT_S16_34L;
-
-  if (doff == 0) {                              /* dst is 8-byte aligned */
-
-    if (dsize >= 4 ) {
-      vis_pst_16(dd0, dp++, emask & bmask);
-      vis_pst_16(dd1, dp++, bmask);
-      vis_pst_16(dd2, dp++, bmask);
-      vis_pst_16(dd3, dp++, bmask);
-    }
-    else {                                      /* for very small size */
-      vis_pst_16(dd0, dp++, emask & bmask);
-      if ((mlib_addr) dp <= (mlib_addr) dend)  {
-        emask = vis_edge16(dp, dend);
-        vis_pst_16(dd1, dp++, emask & bmask);
-        if ((mlib_addr) dp <= (mlib_addr) dend)  {
-          emask = vis_edge16(dp, dend);
-          vis_pst_16(dd2, dp++, emask & bmask);
-        }
-      }
-    }
-
-    /* no edge handling is needed in the loop */
-    if ((mlib_addr) dp <= (mlib_addr) dend2)  {
-      n = ((mlib_u8 *)dend2 - (mlib_u8 *)dp) / 32 + 1;
-#pragma pipeloop(0)
-      for (i = 0; i < n; i++) {
-        LOAD_INSERT_S16_34L;
-        vis_pst_16(dd0, dp++, bmask);
-        vis_pst_16(dd1, dp++, bmask);
-        vis_pst_16(dd2, dp++, bmask);
-        vis_pst_16(dd3, dp++, bmask);
-      }
-    }
-
-    if ((mlib_addr) dp <= (mlib_addr) dend)  {
-      LOAD_INSERT_S16_34L;
-      emask = vis_edge16(dp, dend);
-      vis_pst_16(dd0, dp++, emask & bmask);
-      if ((mlib_addr) dp <= (mlib_addr) dend)  {
-        emask = vis_edge16(dp, dend);
-        vis_pst_16(dd1, dp++, emask & bmask);
-        if ((mlib_addr) dp <= (mlib_addr) dend)  {
-          emask = vis_edge16(dp, dend);
-          vis_pst_16(dd2, dp++, emask & bmask);
-        }
-      }
-    }
-  }
-  else {                                        /* (doff != 0) */
-    vis_alignaddr((void *)0, -doff);
-
-    if (dsize >= 4 ) {
-      vis_pst_16(vis_faligndata(dd0, dd0), dp++, emask & bmask);
-      vis_pst_16(vis_faligndata(dd0, dd1), dp++, bmask);
-      vis_pst_16(vis_faligndata(dd1, dd2), dp++, bmask);
-      vis_pst_16(vis_faligndata(dd2, dd3), dp++, bmask);
-    }
-    else {                                      /* for very small size */
-      vis_pst_16(vis_faligndata(dd0, dd0), dp++, emask & bmask);
-      if ((mlib_addr) dp <= (mlib_addr) dend)  {
-        emask = vis_edge16(dp, dend);
-        vis_pst_16(vis_faligndata(dd0, dd1), dp++, emask & bmask);
-        if ((mlib_addr) dp <= (mlib_addr) dend)  {
-          emask = vis_edge16(dp, dend);
-          vis_pst_16(vis_faligndata(dd1, dd2), dp++, emask & bmask);
-          if ((mlib_addr) dp <= (mlib_addr) dend)  {
-            emask = vis_edge16(dp, dend);
-            vis_pst_16(vis_faligndata(dd2, dd3), dp++, emask & bmask);
-          }
-        }
-      }
-    }
-
-    /* no edge handling is needed in the loop */
-    if ((mlib_addr) dp <= (mlib_addr) dend2)  {
-      n = ((mlib_u8 *)dend2 - (mlib_u8 *)dp) / 32 + 1;
-#pragma pipeloop(0)
-      for (i = 0; i < n; i++) {
-        LOAD_INSERT_S16_34L;
-        vis_alignaddr((void *)0, -doff);
-        vis_pst_16(vis_faligndata(dd4, dd0), dp++, bmask);
-        vis_pst_16(vis_faligndata(dd0, dd1), dp++, bmask);
-        vis_pst_16(vis_faligndata(dd1, dd2), dp++, bmask);
-        vis_pst_16(vis_faligndata(dd2, dd3), dp++, bmask);
-      }
-    }
-
-    if ((mlib_addr) dp <= (mlib_addr) dend)  {
-      LOAD_INSERT_S16_34L;
-      vis_alignaddr((void *)0, -doff);
-      emask = vis_edge16(dp, dend);
-      vis_pst_16(vis_faligndata(dd4, dd0), dp++, emask & bmask);
-      if ((mlib_addr) dp <= (mlib_addr) dend)  {
-        emask = vis_edge16(dp, dend);
-        vis_pst_16(vis_faligndata(dd0, dd1), dp++, emask & bmask);
-        if ((mlib_addr) dp <= (mlib_addr) dend)  {
-          emask = vis_edge16(dp, dend);
-          vis_pst_16(vis_faligndata(dd1, dd2), dp++, emask & bmask);
-          if ((mlib_addr) dp <= (mlib_addr) dend)  {
-            emask = vis_edge16(dp, dend);
-            vis_pst_16(vis_faligndata(dd2, dd3), dp++, emask & bmask);
-          }
-        }
-      }
-    }
-  }
-}
-
-/***************************************************************/
-
-void
-mlib_v_ImageChannelInsert_S16_34L(mlib_s16 *src,  mlib_s32 slb,
-                                                          mlib_s16 *dst,  mlib_s32 dlb,
-                                                          mlib_s32 xsize, mlib_s32 ysize)
-{
-  mlib_s16  *sa, *da;
-  mlib_s16  *sl, *dl;
-  int       j;
-
-  sa = sl = src;
-  da = dl = dst;
-
-#pragma pipeloop(0)
-  for (j = 0; j < ysize; j++) {
-    mlib_v_ImageChannelInsert_S16_34L_D1(sa, da, xsize);
-    sa = sl = (mlib_s16 *)((mlib_u8 *)sl + slb);
-    da = dl = (mlib_s16 *)((mlib_u8 *)dl + dlb);
-  }
-}
-
-/***************************************************************/
--- a/jdk/src/java.desktop/unix/native/libmlib_image/mlib_v_ImageConv.h	Thu May 19 17:48:02 2016 +0000
+++ b/jdk/src/java.desktop/unix/native/libmlib_image/mlib_v_ImageConv.h	Thu May 19 19:46:20 2016 +0000
@@ -34,18 +34,6 @@
 
 #if defined ( VIS ) && VIS == 0x200
 
-mlib_status mlib_conv2x2_8nw_f(mlib_image       *dst,
-                               const mlib_image *src,
-                               const mlib_s32   *kern,
-                               mlib_s32         scale,
-                               mlib_s32         cmask);
-
-mlib_status mlib_conv3x3_8nw_f(mlib_image       *dst,
-                               const mlib_image *src,
-                               const mlib_s32   *kern,
-                               mlib_s32         scale,
-                               mlib_s32         cmask);
-
 mlib_status mlib_convMxN_8nw_f(mlib_image       *dst,
                                const mlib_image *src,
                                mlib_s32         m,
@@ -58,16 +46,6 @@
 
 #else
 
-mlib_status mlib_conv2x2_8nw_f(mlib_image       *dst,
-                               const mlib_image *src,
-                               const mlib_s32   *kern,
-                               mlib_s32         scale);
-
-mlib_status mlib_conv3x3_8nw_f(mlib_image       *dst,
-                               const mlib_image *src,
-                               const mlib_s32   *kern,
-                               mlib_s32         scale);
-
 mlib_status mlib_convMxN_8nw_f(mlib_image       *dst,
                                const mlib_image *src,
                                mlib_s32         m,
--- a/jdk/src/java.desktop/unix/native/libmlib_image/mlib_v_ImageConvIndex3_8_16nw.c	Thu May 19 17:48:02 2016 +0000
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,1673 +0,0 @@
-/*
- * Copyright (c) 2000, 2003, 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.
- */
-
-
-
-/*
- * FUNCTION
- *      Internal functions for mlib_ImageConv* on U8 type
- *      and MLIB_EDGE_DST_NO_WRITE mask
- *
- */
-
-/***************************************************************/
-
-#include <vis_proto.h>
-#include <mlib_image.h>
-#include <mlib_ImageCheck.h>
-#include <mlib_ImageColormap.h>
-
-/*
-  This defines switches between functions in
-  files: mlib_v_ImageConv_8nw.c,
-         mlib_v_ImageConvIndex3_8_16nw.c,
-         mlib_v_ImageConvIndex4_8_16nw.c,
-         mlib_v_ImageConvIndex3_8_16nw.c,
-         mlib_v_ImageConvIndex4_8_16nw.c
-*/
-
-#define CONV_INDEX
-
-#define DTYPE mlib_s16
-#define LTYPE mlib_u8
-
-/***************************************************************/
-
-#ifdef CONV_INDEX
-
-#define CONV_FUNC(KERN)                                         \
-  mlib_conv##KERN##_Index3_8_16nw(mlib_image *dst,              \
-                                  mlib_image *src,              \
-                                  mlib_s32   *kern,             \
-                                  mlib_s32   scale,             \
-                                  void       *colormap)
-
-#else
-
-#define CONV_FUNC(KERN)                         \
-  mlib_conv##KERN##_8nw_f(mlib_image *dst,      \
-                          mlib_image *src,      \
-                          mlib_s32   *kern,     \
-                          mlib_s32   scale)
-
-#endif
-
-/***************************************************************/
-
-#ifdef CONV_INDEX
-
-#define NCHAN  3
-
-#else
-
-#define NCHAN  nchan
-
-#endif
-
-/***************************************************************/
-
-#define DEF_VARS                                                \
-  DTYPE    *sl, *sp, *dl;                                       \
-  mlib_s32 hgt = mlib_ImageGetHeight(src);                      \
-  mlib_s32 wid = mlib_ImageGetWidth(src);                       \
-  mlib_s32 sll = mlib_ImageGetStride(src) / sizeof(DTYPE);      \
-  mlib_s32 dll = mlib_ImageGetStride(dst) / sizeof(DTYPE);      \
-  DTYPE    *adr_src = (DTYPE *)mlib_ImageGetData(src);          \
-  DTYPE    *adr_dst = (DTYPE *)mlib_ImageGetData(dst);          \
-  mlib_s32 ssize, xsize, dsize, esize, emask, buff_ind = 0;     \
-  mlib_d64 *pbuff, *dp;                                         \
-  mlib_f32 *karr = (mlib_f32 *)kern;                            \
-  mlib_s32 gsr_scale = (31 - scale) << 3;                       \
-  mlib_d64 drnd = vis_to_double_dup(mlib_round_8[31 - scale]);  \
-  mlib_s32 i, j, l
-
-/***************************************************************/
-
-#ifdef CONV_INDEX
-
-#define DEF_EXTRA_VARS                                                  \
-  int    offset = mlib_ImageGetLutOffset(colormap);                     \
-  LTYPE  **lut_table = (LTYPE**)mlib_ImageGetLutData(colormap);         \
-  LTYPE  *ltbl0 = lut_table[0] - offset;                                \
-  LTYPE  *ltbl1 = lut_table[1] - offset;                                \
-  LTYPE  *ltbl2 = lut_table[2] - offset;                                \
-  LTYPE  *ltbl3 = (NCHAN > 3) ? lut_table[3] - offset : ltbl2
-
-#else
-
-#define DEF_EXTRA_VARS                          \
-  mlib_s32 nchan = mlib_ImageGetChannels(dst)
-
-#endif
-
-/***************************************************************/
-
-#if NCHAN == 3
-
-#define LOAD_SRC() {                                            \
-    mlib_s32 s0 = sp[0], s1 = sp[1], s2 = sp[2], s3 = sp[3];    \
-    mlib_s32 s4 = sp[4], s5 = sp[5], s6 = sp[6], s7 = sp[7];    \
-    mlib_d64 t0, t1, t2;                                        \
-                                                                \
-    t2 = vis_faligndata(vis_ld_u8_i(ltbl2, s7), t2);            \
-    t2 = vis_faligndata(vis_ld_u8_i(ltbl1, s7), t2);            \
-    t2 = vis_faligndata(vis_ld_u8_i(ltbl0, s7), t2);            \
-    t2 = vis_faligndata(vis_ld_u8_i(ltbl2, s6), t2);            \
-    t2 = vis_faligndata(vis_ld_u8_i(ltbl1, s6), t2);            \
-    t2 = vis_faligndata(vis_ld_u8_i(ltbl0, s6), t2);            \
-    t2 = vis_faligndata(vis_ld_u8_i(ltbl2, s5), t2);            \
-    t2 = vis_faligndata(vis_ld_u8_i(ltbl1, s5), t2);            \
-    t1 = vis_faligndata(vis_ld_u8_i(ltbl0, s5), t1);            \
-    t1 = vis_faligndata(vis_ld_u8_i(ltbl2, s4), t1);            \
-    t1 = vis_faligndata(vis_ld_u8_i(ltbl1, s4), t1);            \
-    t1 = vis_faligndata(vis_ld_u8_i(ltbl0, s4), t1);            \
-    t1 = vis_faligndata(vis_ld_u8_i(ltbl2, s3), t1);            \
-    t1 = vis_faligndata(vis_ld_u8_i(ltbl1, s3), t1);            \
-    t1 = vis_faligndata(vis_ld_u8_i(ltbl0, s3), t1);            \
-    t1 = vis_faligndata(vis_ld_u8_i(ltbl2, s2), t1);            \
-    t0 = vis_faligndata(vis_ld_u8_i(ltbl1, s2), t0);            \
-    t0 = vis_faligndata(vis_ld_u8_i(ltbl0, s2), t0);            \
-    t0 = vis_faligndata(vis_ld_u8_i(ltbl2, s1), t0);            \
-    t0 = vis_faligndata(vis_ld_u8_i(ltbl1, s1), t0);            \
-    t0 = vis_faligndata(vis_ld_u8_i(ltbl0, s1), t0);            \
-    t0 = vis_faligndata(vis_ld_u8_i(ltbl2, s0), t0);            \
-    t0 = vis_faligndata(vis_ld_u8_i(ltbl1, s0), t0);            \
-    t0 = vis_faligndata(vis_ld_u8_i(ltbl0, s0), t0);            \
-                                                                \
-    buffn[i] = t0;                                              \
-    buffn[i + 1] = t1;                                          \
-    buffn[i + 2] = t2;                                          \
-                                                                \
-    sp += 8;                                                    \
-  }
-
-#else
-
-#define LOAD_SRC() {                                            \
-    mlib_s32 s0 = sp[0], s1 = sp[1], s2 = sp[2], s3 = sp[3];    \
-    mlib_s32 s4 = sp[4], s5 = sp[5], s6 = sp[6], s7 = sp[7];    \
-    mlib_d64 t0, t1, t2;                                        \
-                                                                \
-    t2 = vis_faligndata(vis_ld_u8_i(ltbl3, s5), t2);            \
-    t2 = vis_faligndata(vis_ld_u8_i(ltbl2, s5), t2);            \
-    t2 = vis_faligndata(vis_ld_u8_i(ltbl1, s5), t2);            \
-    t2 = vis_faligndata(vis_ld_u8_i(ltbl0, s5), t2);            \
-    t2 = vis_faligndata(vis_ld_u8_i(ltbl3, s4), t2);            \
-    t2 = vis_faligndata(vis_ld_u8_i(ltbl2, s4), t2);            \
-    t2 = vis_faligndata(vis_ld_u8_i(ltbl1, s4), t2);            \
-    t2 = vis_faligndata(vis_ld_u8_i(ltbl0, s4), t2);            \
-    t1 = vis_faligndata(vis_ld_u8_i(ltbl3, s3), t1);            \
-    t1 = vis_faligndata(vis_ld_u8_i(ltbl2, s3), t1);            \
-    t1 = vis_faligndata(vis_ld_u8_i(ltbl1, s3), t1);            \
-    t1 = vis_faligndata(vis_ld_u8_i(ltbl0, s3), t1);            \
-    t1 = vis_faligndata(vis_ld_u8_i(ltbl3, s2), t1);            \
-    t1 = vis_faligndata(vis_ld_u8_i(ltbl2, s2), t1);            \
-    t1 = vis_faligndata(vis_ld_u8_i(ltbl1, s2), t1);            \
-    t1 = vis_faligndata(vis_ld_u8_i(ltbl0, s2), t1);            \
-    t0 = vis_faligndata(vis_ld_u8_i(ltbl3, s1), t0);            \
-    t0 = vis_faligndata(vis_ld_u8_i(ltbl2, s1), t0);            \
-    t0 = vis_faligndata(vis_ld_u8_i(ltbl1, s1), t0);            \
-    t0 = vis_faligndata(vis_ld_u8_i(ltbl0, s1), t0);            \
-    t0 = vis_faligndata(vis_ld_u8_i(ltbl3, s0), t0);            \
-    t0 = vis_faligndata(vis_ld_u8_i(ltbl2, s0), t0);            \
-    t0 = vis_faligndata(vis_ld_u8_i(ltbl1, s0), t0);            \
-    t0 = vis_faligndata(vis_ld_u8_i(ltbl0, s0), t0);            \
-                                                                \
-    buffn[i] = t0;                                              \
-    buffn[i + 1] = t1;                                          \
-    buffn[i + 2] = t2;                                          \
-                                                                \
-    sp += 6;                                                    \
-  }
-
-#endif
-
-/***************************************************************/
-
-static mlib_s32 mlib_round_8[16] = { 0x00400040, 0x00200020, 0x00100010, 0x00080008,
-                                    0x00040004, 0x00020002, 0x00010001, 0x00000000,
-                                    0x00000000, 0x00000000, 0x00000000, 0x00000000,
-                                    0x00000000, 0x00000000, 0x00000000, 0x00000000 };
-
-/***************************************************************/
-
-void mlib_ImageCopy_na(mlib_u8 *sa, mlib_u8 *da, int size);
-
-/***************************************************************/
-
-#define KSIZE  2
-
-mlib_status CONV_FUNC(2x2)
-{
-  mlib_d64 *buffs[2*(KSIZE + 1)];
-  mlib_d64 *buff0, *buff1, *buffn, *buffd, *buffe;
-  mlib_d64 s00, s01, s10, s11, s0, s1;
-  mlib_d64 d0, d1, d00, d01, d10, d11;
-  DEF_VARS;
-  DEF_EXTRA_VARS;
-
-  sl = adr_src;
-  dl = adr_dst;
-
-  ssize = NCHAN*wid;
-  dsize = (ssize + 7)/8;
-  esize = dsize + 4;
-  pbuff = mlib_malloc((KSIZE + 4)*esize*sizeof(mlib_d64));
-  if (pbuff == NULL) return MLIB_FAILURE;
-
-  for (i = 0; i < (KSIZE + 1); i++) buffs[i] = pbuff + i*esize;
-  for (i = 0; i < (KSIZE + 1); i++) buffs[(KSIZE + 1) + i] = buffs[i];
-  buffd = buffs[KSIZE] + esize;
-  buffe = buffd + 2*esize;
-
-  wid -= (KSIZE - 1);
-  hgt -= (KSIZE - 1);
-  xsize = ssize - NCHAN*(KSIZE - 1);
-  emask = (0xFF00 >> (xsize & 7)) & 0xFF;
-
-  vis_write_gsr(gsr_scale + 7);
-
-  for (l = 0; l < KSIZE; l++) {
-    mlib_d64 *buffn = buffs[l];
-    sp = sl + l*sll;
-
-#ifndef CONV_INDEX
-    if ((mlib_addr)sp & 7) mlib_ImageCopy_na((void*)sp, (void*)buffn, ssize);
-
-#else
-#pragma pipeloop(0)
-    for (i = 0; i < dsize; i += 3) {
-      LOAD_SRC();
-    }
-#endif /* CONV_INDEX */
-  }
-
-  for (j = 0; j < hgt; j++) {
-    mlib_d64 **buffc = buffs + buff_ind;
-    mlib_f32 *pk = karr, k0, k1;
-    sp = sl + KSIZE*sll;
-
-    buff0 = buffc[0];
-    buff1 = buffc[1];
-    buffn = buffc[KSIZE];
-
-#ifndef CONV_INDEX
-    if ((((mlib_addr)(sl      )) & 7) == 0) buff0 = (mlib_d64*)sl;
-    if ((((mlib_addr)(sl + sll)) & 7) == 0) buff1 = (mlib_d64*)(sl + sll);
-    if ((mlib_addr)sp & 7) mlib_ImageCopy_na((void*)sp, (void*)buffn, ssize);
-#endif
-
-    k0 = pk[1];
-    k1 = pk[3];
-    vis_write_gsr(gsr_scale + NCHAN);
-
-    s01 = buff0[0];
-    s11 = buff1[0];
-#pragma pipeloop(0)
-    for (i = 0; i < (xsize + 7)/8; i++) {
-      s00 = s01;
-      s10 = s11;
-      s01 = buff0[i + 1];
-      s11 = buff1[i + 1];
-      s0  = vis_faligndata(s00, s01);
-      s1  = vis_faligndata(s10, s11);
-
-      d00 = vis_fmul8x16au(vis_read_hi(s0), k0);
-      d01 = vis_fmul8x16au(vis_read_lo(s0), k0);
-      d10 = vis_fmul8x16au(vis_read_hi(s1), k1);
-      d11 = vis_fmul8x16au(vis_read_lo(s1), k1);
-
-      d0 = vis_fpadd16(d00, d10);
-      d1 = vis_fpadd16(d01, d11);
-      buffd[2*i] = d0;
-      buffd[2*i + 1] = d1;
-    }
-
-    k0 = pk[0];
-    k1 = pk[2];
-#ifndef CONV_INDEX
-    dp = ((mlib_addr)dl & 7) ? buffe : (mlib_d64*)dl;
-
-#pragma pipeloop(0)
-    for (i = 0; i < xsize/8; i++) {
-      s0 = buff0[i];
-      s1 = buff1[i];
-
-      d00 = vis_fmul8x16au(vis_read_hi(s0), k0);
-      d01 = vis_fmul8x16au(vis_read_lo(s0), k0);
-      d10 = vis_fmul8x16au(vis_read_hi(s1), k1);
-      d11 = vis_fmul8x16au(vis_read_lo(s1), k1);
-
-      d0 = buffd[2*i];
-      d1 = buffd[2*i + 1];
-      d00 = vis_fpadd16(d00, d10);
-      d0  = vis_fpadd16(d0, drnd);
-      d0  = vis_fpadd16(d0, d00);
-      d01 = vis_fpadd16(d01, d11);
-      d1  = vis_fpadd16(d1, drnd);
-      d1  = vis_fpadd16(d1, d01);
-      dp[i] = vis_fpack16_pair(d0, d1);
-    }
-
-    if (emask) {
-      s0 = buff0[i];
-      s1 = buff1[i];
-
-      d00 = vis_fmul8x16au(vis_read_hi(s0), k0);
-      d01 = vis_fmul8x16au(vis_read_lo(s0), k0);
-      d10 = vis_fmul8x16au(vis_read_hi(s1), k1);
-      d11 = vis_fmul8x16au(vis_read_lo(s1), k1);
-
-      d0 = buffd[2*i];
-      d1 = buffd[2*i + 1];
-      d00 = vis_fpadd16(d00, d10);
-      d0  = vis_fpadd16(d0, drnd);
-      d0  = vis_fpadd16(d0, d00);
-      d01 = vis_fpadd16(d01, d11);
-      d1  = vis_fpadd16(d1, drnd);
-      d1  = vis_fpadd16(d1, d01);
-
-      d0 = vis_fpack16_pair(d0, d1);
-      vis_pst_8(d0, dp + i, emask);
-    }
-
-    if ((mlib_u8*)dp != dl) mlib_ImageCopy_na((void*)buffe, dl, xsize);
-
-#else
-    vis_write_gsr(gsr_scale + 7);
-
-#pragma pipeloop(0)
-    for (i = 0; i < dsize; i += 3) {
-      mlib_d64 d00, d01, d02, d03, d04, d05;
-      mlib_d64 d10, d11, d12, d13, d14, d15;
-      mlib_d64 d0, d1, d2, d3, d4, d5;
-      mlib_d64 s00 = buff0[i];
-      mlib_d64 s01 = buff0[i + 1];
-      mlib_d64 s02 = buff0[i + 2];
-      mlib_d64 s10 = buff1[i];
-      mlib_d64 s11 = buff1[i + 1];
-      mlib_d64 s12 = buff1[i + 2];
-
-      d00 = vis_fmul8x16au(vis_read_hi(s00), k0);
-      d01 = vis_fmul8x16au(vis_read_lo(s00), k0);
-      d02 = vis_fmul8x16au(vis_read_hi(s01), k0);
-      d03 = vis_fmul8x16au(vis_read_lo(s01), k0);
-      d04 = vis_fmul8x16au(vis_read_hi(s02), k0);
-      d05 = vis_fmul8x16au(vis_read_lo(s02), k0);
-      d10 = vis_fmul8x16au(vis_read_hi(s10), k1);
-      d11 = vis_fmul8x16au(vis_read_lo(s10), k1);
-      d12 = vis_fmul8x16au(vis_read_hi(s11), k1);
-      d13 = vis_fmul8x16au(vis_read_lo(s11), k1);
-      d14 = vis_fmul8x16au(vis_read_hi(s12), k1);
-      d15 = vis_fmul8x16au(vis_read_lo(s12), k1);
-
-      d0 = buffd[2*i];
-      d1 = buffd[2*i + 1];
-      d2 = buffd[2*i + 2];
-      d3 = buffd[2*i + 3];
-      d4 = buffd[2*i + 4];
-      d5 = buffd[2*i + 5];
-      d00 = vis_fpadd16(d00, d10);
-      d0  = vis_fpadd16(d0, drnd);
-      d0  = vis_fpadd16(d0, d00);
-      d01 = vis_fpadd16(d01, d11);
-      d1  = vis_fpadd16(d1, drnd);
-      d1  = vis_fpadd16(d1, d01);
-      d02 = vis_fpadd16(d02, d12);
-      d2  = vis_fpadd16(d2, drnd);
-      d2  = vis_fpadd16(d2, d02);
-      d03 = vis_fpadd16(d03, d13);
-      d3  = vis_fpadd16(d3, drnd);
-      d3  = vis_fpadd16(d3, d03);
-      d04 = vis_fpadd16(d04, d14);
-      d4  = vis_fpadd16(d4, drnd);
-      d4  = vis_fpadd16(d4, d04);
-      d05 = vis_fpadd16(d05, d15);
-      d5  = vis_fpadd16(d5, drnd);
-      d5  = vis_fpadd16(d5, d05);
-
-      buffe[i    ] = vis_fpack16_pair(d0, d1);
-      buffe[i + 1] = vis_fpack16_pair(d2, d3);
-      buffe[i + 2] = vis_fpack16_pair(d4, d5);
-
-      LOAD_SRC();
-    }
-
-    mlib_ImageColorTrue2IndexLine_U8_S16_3((void*)buffe, dl, wid, colormap);
-#endif /* CONV_INDEX */
-
-    sl += sll;
-    dl += dll;
-
-    buff_ind++;
-    if (buff_ind >= (KSIZE + 1)) buff_ind = 0;
-  }
-
-  mlib_free(pbuff);
-
-  return MLIB_SUCCESS;
-}
-
-/***************************************************************/
-
-#undef  KSIZE
-#define KSIZE  3
-
-mlib_status CONV_FUNC(3x3)
-{
-  mlib_d64 *buffs[2*(KSIZE + 1)];
-  mlib_d64 *buff0, *buff1, *buff2, *buffn, *buffd, *buffe;
-  mlib_d64 s00, s01, s10, s11, s20, s21, s0, s1, s2;
-  mlib_d64 dd, d0, d1, d00, d01, d10, d11, d20, d21;
-  mlib_s32 ik, ik_last, off, doff;
-  DEF_VARS;
-  DEF_EXTRA_VARS;
-
-  sl = adr_src;
-#ifdef CONV_INDEX
-  dl = adr_dst + ((KSIZE - 1)/2)*(dll + 1);
-#else
-  dl = adr_dst + ((KSIZE - 1)/2)*(dll + NCHAN);
-#endif
-
-  ssize = NCHAN*wid;
-  dsize = (ssize + 7)/8;
-  esize = dsize + 4;
-  pbuff = mlib_malloc((KSIZE + 4)*esize*sizeof(mlib_d64));
-  if (pbuff == NULL) return MLIB_FAILURE;
-
-  for (i = 0; i < (KSIZE + 1); i++) buffs[i] = pbuff + i*esize;
-  for (i = 0; i < (KSIZE + 1); i++) buffs[(KSIZE + 1) + i] = buffs[i];
-  buffd = buffs[KSIZE] + esize;
-  buffe = buffd + 2*esize;
-
-  wid -= (KSIZE - 1);
-  hgt -= (KSIZE - 1);
-  xsize = ssize - NCHAN*(KSIZE - 1);
-  emask = (0xFF00 >> (xsize & 7)) & 0xFF;
-
-  vis_write_gsr(gsr_scale + 7);
-
-  for (l = 0; l < KSIZE; l++) {
-    mlib_d64 *buffn = buffs[l];
-    sp = sl + l*sll;
-
-#ifndef CONV_INDEX
-    if ((mlib_addr)sp & 7) mlib_ImageCopy_na((void*)sp, (void*)buffn, ssize);
-#else
-#pragma pipeloop(0)
-    for (i = 0; i < dsize; i += 3) {
-      LOAD_SRC();
-    }
-#endif /* CONV_INDEX */
-  }
-
-  /* init buffer */
-#pragma pipeloop(0)
-  for (i = 0; i < (xsize + 7)/8; i++) {
-    buffd[2*i    ] = drnd;
-    buffd[2*i + 1] = drnd;
-  }
-
-  for (j = 0; j < hgt; j++) {
-    mlib_d64 **buffc = buffs + buff_ind, *pbuff0, *pbuff1, *pbuff2;
-    mlib_f32 *pk = karr, k0, k1, k2;
-    sp = sl + KSIZE*sll;
-
-    pbuff0 = buffc[0];
-    pbuff1 = buffc[1];
-    pbuff2 = buffc[2];
-    buffn  = buffc[KSIZE];
-
-#ifndef CONV_INDEX
-    if ((((mlib_addr)(sl        )) & 7) == 0) pbuff0 = (mlib_d64*)sl;
-    if ((((mlib_addr)(sl +   sll)) & 7) == 0) pbuff1 = (mlib_d64*)(sl + sll);
-    if ((((mlib_addr)(sl + 2*sll)) & 7) == 0) pbuff2 = (mlib_d64*)(sl + 2*sll);
-
-    if ((mlib_addr)sp & 7) mlib_ImageCopy_na((void*)sp, (void*)buffn, ssize);
-#endif
-
-#ifdef CONV_INDEX
-    ik_last = 0;
-#else
-    ik_last = (KSIZE - 1);
-#endif
-
-    for (ik = 0; ik < KSIZE; ik++) {
-      k0 = pk[ik];
-      k1 = pk[ik + KSIZE];
-      k2 = pk[ik + 2*KSIZE];
-
-      off  = ik*NCHAN;
-      doff = off/8;
-      off &= 7;
-      buff0 = pbuff0 + doff;
-      buff1 = pbuff1 + doff;
-      buff2 = pbuff2 + doff;
-      vis_write_gsr(gsr_scale + off);
-
-      if (ik == ik_last) continue;
-      /*if (!ik_last) {
-        if ((off & 3) || (ik == (KSIZE - 1))) {
-          ik_last = ik;
-          continue;
-        }
-      }*/
-
-      if (off == 0) {
-#pragma pipeloop(0)
-        for (i = 0; i < (xsize + 7)/8; i++) {
-          s0 = buff0[i];
-          s1 = buff1[i];
-          s2 = buff2[i];
-
-          d00 = vis_fmul8x16au(vis_read_hi(s0), k0);
-          d01 = vis_fmul8x16au(vis_read_lo(s0), k0);
-          d10 = vis_fmul8x16au(vis_read_hi(s1), k1);
-          d11 = vis_fmul8x16au(vis_read_lo(s1), k1);
-          d20 = vis_fmul8x16au(vis_read_hi(s2), k2);
-          d21 = vis_fmul8x16au(vis_read_lo(s2), k2);
-
-          d0 = buffd[2*i];
-          d1 = buffd[2*i + 1];
-          d0 = vis_fpadd16(d00, d0);
-          d0 = vis_fpadd16(d10, d0);
-          d0 = vis_fpadd16(d20, d0);
-          d1 = vis_fpadd16(d01, d1);
-          d1 = vis_fpadd16(d11, d1);
-          d1 = vis_fpadd16(d21, d1);
-          buffd[2*i] = d0;
-          buffd[2*i + 1] = d1;
-        }
-
-      } else if (off == 4) {
-        s01 = buff0[0];
-        s11 = buff1[0];
-        s21 = buff2[0];
-#pragma pipeloop(0)
-        for (i = 0; i < (xsize + 7)/8; i++) {
-          s00 = s01;
-          s10 = s11;
-          s20 = s21;
-          s01 = buff0[i + 1];
-          s11 = buff1[i + 1];
-          s21 = buff2[i + 1];
-
-          d00 = vis_fmul8x16au(vis_read_lo(s00), k0);
-          d01 = vis_fmul8x16au(vis_read_hi(s01), k0);
-          d10 = vis_fmul8x16au(vis_read_lo(s10), k1);
-          d11 = vis_fmul8x16au(vis_read_hi(s11), k1);
-          d20 = vis_fmul8x16au(vis_read_lo(s20), k2);
-          d21 = vis_fmul8x16au(vis_read_hi(s21), k2);
-
-          d0 = buffd[2*i];
-          d1 = buffd[2*i + 1];
-          d0 = vis_fpadd16(d00, d0);
-          d0 = vis_fpadd16(d10, d0);
-          d0 = vis_fpadd16(d20, d0);
-          d1 = vis_fpadd16(d01, d1);
-          d1 = vis_fpadd16(d11, d1);
-          d1 = vis_fpadd16(d21, d1);
-          buffd[2*i] = d0;
-          buffd[2*i + 1] = d1;
-        }
-
-      } else {
-        s01 = buff0[0];
-        s11 = buff1[0];
-        s21 = buff2[0];
-#pragma pipeloop(0)
-        for (i = 0; i < (xsize + 7)/8; i++) {
-          s00 = s01;
-          s10 = s11;
-          s20 = s21;
-          s01 = buff0[i + 1];
-          s11 = buff1[i + 1];
-          s21 = buff2[i + 1];
-          s0  = vis_faligndata(s00, s01);
-          s1  = vis_faligndata(s10, s11);
-          s2  = vis_faligndata(s20, s21);
-
-          d00 = vis_fmul8x16au(vis_read_hi(s0), k0);
-          d01 = vis_fmul8x16au(vis_read_lo(s0), k0);
-          d10 = vis_fmul8x16au(vis_read_hi(s1), k1);
-          d11 = vis_fmul8x16au(vis_read_lo(s1), k1);
-          d20 = vis_fmul8x16au(vis_read_hi(s2), k2);
-          d21 = vis_fmul8x16au(vis_read_lo(s2), k2);
-
-          d0 = buffd[2*i];
-          d1 = buffd[2*i + 1];
-          d0 = vis_fpadd16(d00, d0);
-          d0 = vis_fpadd16(d10, d0);
-          d0 = vis_fpadd16(d20, d0);
-          d1 = vis_fpadd16(d01, d1);
-          d1 = vis_fpadd16(d11, d1);
-          d1 = vis_fpadd16(d21, d1);
-          buffd[2*i] = d0;
-          buffd[2*i + 1] = d1;
-        }
-      }
-    }
-
-    k0 = pk[ik_last];
-    k1 = pk[ik_last + KSIZE];
-    k2 = pk[ik_last + 2*KSIZE];
-
-    off  = ik_last*NCHAN;
-    doff = off/8;
-    off &= 7;
-    buff0 = pbuff0 + doff;
-    buff1 = pbuff1 + doff;
-    buff2 = pbuff2 + doff;
-    vis_write_gsr(gsr_scale + off);
-
-#ifndef CONV_INDEX
-    dp = ((mlib_addr)dl & 7) ? buffe : (mlib_d64*)dl;
-
-    s01 = buff0[0];
-    s11 = buff1[0];
-    s21 = buff2[0];
-#pragma pipeloop(0)
-    for (i = 0; i < xsize/8; i++) {
-      s00 = s01;
-      s10 = s11;
-      s20 = s21;
-      s01 = buff0[i + 1];
-      s11 = buff1[i + 1];
-      s21 = buff2[i + 1];
-      s0  = vis_faligndata(s00, s01);
-      s1  = vis_faligndata(s10, s11);
-      s2  = vis_faligndata(s20, s21);
-
-      d00 = vis_fmul8x16au(vis_read_hi(s0), k0);
-      d01 = vis_fmul8x16au(vis_read_lo(s0), k0);
-      d10 = vis_fmul8x16au(vis_read_hi(s1), k1);
-      d11 = vis_fmul8x16au(vis_read_lo(s1), k1);
-      d20 = vis_fmul8x16au(vis_read_hi(s2), k2);
-      d21 = vis_fmul8x16au(vis_read_lo(s2), k2);
-
-      d0 = buffd[2*i];
-      d1 = buffd[2*i + 1];
-      d0 = vis_fpadd16(d0, d00);
-      d0 = vis_fpadd16(d0, d10);
-      d0 = vis_fpadd16(d0, d20);
-      d1 = vis_fpadd16(d1, d01);
-      d1 = vis_fpadd16(d1, d11);
-      d1 = vis_fpadd16(d1, d21);
-
-      dd = vis_fpack16_pair(d0, d1);
-      dp[i] = dd;
-
-      buffd[2*i    ] = drnd;
-      buffd[2*i + 1] = drnd;
-    }
-
-    if (emask) {
-      s00 = s01;
-      s10 = s11;
-      s20 = s21;
-      s01 = buff0[i + 1];
-      s11 = buff1[i + 1];
-      s21 = buff2[i + 1];
-      s0  = vis_faligndata(s00, s01);
-      s1  = vis_faligndata(s10, s11);
-      s2  = vis_faligndata(s20, s21);
-
-      d00 = vis_fmul8x16au(vis_read_hi(s0), k0);
-      d01 = vis_fmul8x16au(vis_read_lo(s0), k0);
-      d10 = vis_fmul8x16au(vis_read_hi(s1), k1);
-      d11 = vis_fmul8x16au(vis_read_lo(s1), k1);
-      d20 = vis_fmul8x16au(vis_read_hi(s2), k2);
-      d21 = vis_fmul8x16au(vis_read_lo(s2), k2);
-
-      d0 = buffd[2*i];
-      d1 = buffd[2*i + 1];
-      d0 = vis_fpadd16(d0, d00);
-      d0 = vis_fpadd16(d0, d10);
-      d0 = vis_fpadd16(d0, d20);
-      d1 = vis_fpadd16(d1, d01);
-      d1 = vis_fpadd16(d1, d11);
-      d1 = vis_fpadd16(d1, d21);
-
-      dd = vis_fpack16_pair(d0, d1);
-      vis_pst_8(dd, dp + i, emask);
-
-      buffd[2*i    ] = drnd;
-      buffd[2*i + 1] = drnd;
-    }
-
-    if ((mlib_u8*)dp != dl) mlib_ImageCopy_na((void*)buffe, dl, xsize);
-
-#else
-    vis_write_gsr(gsr_scale + 7);
-
-#pragma pipeloop(0)
-    for (i = 0; i < dsize; i += 3) {
-      mlib_d64 d00, d01, d02, d03, d04, d05;
-      mlib_d64 d10, d11, d12, d13, d14, d15;
-      mlib_d64 d20, d21, d22, d23, d24, d25;
-      mlib_d64 d0, d1, d2, d3, d4, d5;
-      mlib_d64 s00 = buff0[i];
-      mlib_d64 s01 = buff0[i + 1];
-      mlib_d64 s02 = buff0[i + 2];
-      mlib_d64 s10 = buff1[i];
-      mlib_d64 s11 = buff1[i + 1];
-      mlib_d64 s12 = buff1[i + 2];
-      mlib_d64 s20 = buff2[i];
-      mlib_d64 s21 = buff2[i + 1];
-      mlib_d64 s22 = buff2[i + 2];
-
-      d00 = vis_fmul8x16au(vis_read_hi(s00), k0);
-      d01 = vis_fmul8x16au(vis_read_lo(s00), k0);
-      d02 = vis_fmul8x16au(vis_read_hi(s01), k0);
-      d03 = vis_fmul8x16au(vis_read_lo(s01), k0);
-      d04 = vis_fmul8x16au(vis_read_hi(s02), k0);
-      d05 = vis_fmul8x16au(vis_read_lo(s02), k0);
-      d10 = vis_fmul8x16au(vis_read_hi(s10), k1);
-      d11 = vis_fmul8x16au(vis_read_lo(s10), k1);
-      d12 = vis_fmul8x16au(vis_read_hi(s11), k1);
-      d13 = vis_fmul8x16au(vis_read_lo(s11), k1);
-      d14 = vis_fmul8x16au(vis_read_hi(s12), k1);
-      d15 = vis_fmul8x16au(vis_read_lo(s12), k1);
-      d20 = vis_fmul8x16au(vis_read_hi(s20), k2);
-      d21 = vis_fmul8x16au(vis_read_lo(s20), k2);
-      d22 = vis_fmul8x16au(vis_read_hi(s21), k2);
-      d23 = vis_fmul8x16au(vis_read_lo(s21), k2);
-      d24 = vis_fmul8x16au(vis_read_hi(s22), k2);
-      d25 = vis_fmul8x16au(vis_read_lo(s22), k2);
-
-      d0 = buffd[2*i];
-      d1 = buffd[2*i + 1];
-      d2 = buffd[2*i + 2];
-      d3 = buffd[2*i + 3];
-      d4 = buffd[2*i + 4];
-      d5 = buffd[2*i + 5];
-      d0 = vis_fpadd16(d0, d00);
-      d0 = vis_fpadd16(d0, d10);
-      d0 = vis_fpadd16(d0, d20);
-      d1 = vis_fpadd16(d1, d01);
-      d1 = vis_fpadd16(d1, d11);
-      d1 = vis_fpadd16(d1, d21);
-      d2 = vis_fpadd16(d2, d02);
-      d2 = vis_fpadd16(d2, d12);
-      d2 = vis_fpadd16(d2, d22);
-      d3 = vis_fpadd16(d3, d03);
-      d3 = vis_fpadd16(d3, d13);
-      d3 = vis_fpadd16(d3, d23);
-      d4 = vis_fpadd16(d4, d04);
-      d4 = vis_fpadd16(d4, d14);
-      d4 = vis_fpadd16(d4, d24);
-      d5 = vis_fpadd16(d5, d05);
-      d5 = vis_fpadd16(d5, d15);
-      d5 = vis_fpadd16(d5, d25);
-
-      buffe[i    ] = vis_fpack16_pair(d0, d1);
-      buffe[i + 1] = vis_fpack16_pair(d2, d3);
-      buffe[i + 2] = vis_fpack16_pair(d4, d5);
-
-      buffd[2*i    ] = drnd;
-      buffd[2*i + 1] = drnd;
-      buffd[2*i + 2] = drnd;
-      buffd[2*i + 3] = drnd;
-      buffd[2*i + 4] = drnd;
-      buffd[2*i + 5] = drnd;
-
-      LOAD_SRC();
-    }
-
-    mlib_ImageColorTrue2IndexLine_U8_S16_3((void*)buffe, dl, wid, colormap);
-#endif /* CONV_INDEX */
-
-    sl += sll;
-    dl += dll;
-
-    buff_ind++;
-    if (buff_ind >= (KSIZE + 1)) buff_ind = 0;
-  }
-
-  mlib_free(pbuff);
-
-  return MLIB_SUCCESS;
-}
-
-/***************************************************************/
-
-#undef  KSIZE
-#define MAX_N   11
-
-#ifdef CONV_INDEX
-
-mlib_status mlib_convMxN_Index3_8_16nw(mlib_image *dst,
-                                       mlib_image *src,
-                                       mlib_s32   m,
-                                       mlib_s32   n,
-                                       mlib_s32   dm,
-                                       mlib_s32   dn,
-                                       mlib_s32   *kern,
-                                       mlib_s32   scale,
-                                       void       *colormap)
-
-#else
-
-mlib_status mlib_convMxN_8nw_f(mlib_image *dst,
-                               mlib_image *src,
-                               mlib_s32   m,
-                               mlib_s32   n,
-                               mlib_s32   dm,
-                               mlib_s32   dn,
-                               mlib_s32   *kern,
-                               mlib_s32   scale)
-
-#endif
-{
-  mlib_d64 *buffs_local[3*(MAX_N + 1)], **buffs = buffs_local, **buff;
-  mlib_d64 *buff0, *buff1, *buff2, *buff3, *buffn, *buffd, *buffe;
-  mlib_d64 s00, s01, s10, s11, s20, s21, s30, s31, s0, s1, s2, s3;
-  mlib_d64 d00, d01, d10, d11, d20, d21, d30, d31;
-  mlib_d64 dd, d0, d1;
-  mlib_s32 ik, jk, ik_last, jk_size, coff, off, doff;
-  DEF_VARS;
-  DEF_EXTRA_VARS;
-
-  if (n > MAX_N) {
-    buffs = mlib_malloc(3*(n + 1)*sizeof(mlib_d64*));
-    if (buffs == NULL) return MLIB_FAILURE;
-  }
-
-  buff = buffs + 2*(n + 1);
-
-  sl = adr_src;
-#ifdef CONV_INDEX
-  dl = adr_dst + dn*dll + dm;
-#else
-  dl = adr_dst + dn*dll + dm*NCHAN;
-#endif
-
-  ssize = NCHAN*wid;
-  dsize = (ssize + 7)/8;
-  esize = dsize + 4;
-  pbuff = mlib_malloc((n + 4)*esize*sizeof(mlib_d64));
-  if (pbuff == NULL) {
-    if (buffs != buffs_local) mlib_free(buffs);
-    return MLIB_FAILURE;
-  }
-
-  for (i = 0; i < (n + 1); i++) buffs[i] = pbuff + i*esize;
-  for (i = 0; i < (n + 1); i++) buffs[(n + 1) + i] = buffs[i];
-  buffd = buffs[n] + esize;
-  buffe = buffd + 2*esize;
-
-  wid -= (m - 1);
-  hgt -= (n - 1);
-  xsize = ssize - NCHAN*(m - 1);
-  emask = (0xFF00 >> (xsize & 7)) & 0xFF;
-
-  vis_write_gsr(gsr_scale + 7);
-
-  for (l = 0; l < n; l++) {
-    mlib_d64 *buffn = buffs[l];
-    sp = sl + l*sll;
-
-#ifndef CONV_INDEX
-    if ((mlib_addr)sp & 7) mlib_ImageCopy_na((void*)sp, (void*)buffn, ssize);
-#else
-#pragma pipeloop(0)
-    for (i = 0; i < dsize; i += 3) {
-      LOAD_SRC();
-    }
-#endif /* CONV_INDEX */
-  }
-
-  /* init buffer */
-#pragma pipeloop(0)
-  for (i = 0; i < (xsize + 7)/8; i++) {
-    buffd[2*i    ] = drnd;
-    buffd[2*i + 1] = drnd;
-  }
-
-  for (j = 0; j < hgt; j++) {
-    mlib_d64 **buffc = buffs + buff_ind;
-    mlib_f32 *pk = karr, k0, k1, k2, k3;
-    sp = sl + n*sll;
-
-    for (l = 0; l < n; l++) {
-      buff[l] = buffc[l];
-    }
-    buffn  = buffc[n];
-
-#ifndef CONV_INDEX
-    for (l = 0; l < n; l++) {
-      if ((((mlib_addr)(sl + l*sll)) & 7) == 0) buff[l] = (mlib_d64*)(sl + l*sll);
-    }
-    if ((mlib_addr)sp & 7) mlib_ImageCopy_na((void*)sp, (void*)buffn, ssize);
-#endif
-
-#ifdef CONV_INDEX
-    ik_last = 0;
-#else
-    ik_last = (m - 1);
-#endif
-
-    for (jk = 0; jk < n; jk += jk_size) {
-      jk_size = n - jk;
-#ifdef CONV_INDEX
-      if (jk_size >= 5) jk_size = 3;
-      if (jk_size == 4) jk_size = 2;
-#else
-      if (jk_size >= 6) jk_size = 4;
-      if (jk_size == 5) jk_size = 3;
-#endif
-      coff = 0;
-
-      if (jk_size == 2) {
-
-        for (ik = 0; ik < m; ik++, coff += NCHAN) {
-          if (!jk && ik == ik_last) continue;
-
-          k0 = pk[ik];
-          k1 = pk[ik + m];
-
-          doff  = coff/8;
-          buff0 = buff[jk    ] + doff;
-          buff1 = buff[jk + 1] + doff;
-
-          off = coff & 7;
-          vis_write_gsr(gsr_scale + off);
-
-          s01 = buff0[0];
-          s11 = buff1[0];
-#pragma pipeloop(0)
-          for (i = 0; i < (xsize + 7)/8; i++) {
-            s00 = s01;
-            s10 = s11;
-            s01 = buff0[i + 1];
-            s11 = buff1[i + 1];
-            s0  = vis_faligndata(s00, s01);
-            s1  = vis_faligndata(s10, s11);
-
-            d00 = vis_fmul8x16au(vis_read_hi(s0), k0);
-            d01 = vis_fmul8x16au(vis_read_lo(s0), k0);
-            d10 = vis_fmul8x16au(vis_read_hi(s1), k1);
-            d11 = vis_fmul8x16au(vis_read_lo(s1), k1);
-
-            d0 = buffd[2*i];
-            d1 = buffd[2*i + 1];
-            d0 = vis_fpadd16(d00, d0);
-            d0 = vis_fpadd16(d10, d0);
-            d1 = vis_fpadd16(d01, d1);
-            d1 = vis_fpadd16(d11, d1);
-            buffd[2*i] = d0;
-            buffd[2*i + 1] = d1;
-          }
-
-        }
-
-        pk += 2*m;
-
-      } else if (jk_size == 3) {
-
-        for (ik = 0; ik < m; ik++, coff += NCHAN) {
-          if (!jk && ik == ik_last) continue;
-
-          k0 = pk[ik];
-          k1 = pk[ik + m];
-          k2 = pk[ik + 2*m];
-
-          doff  = coff/8;
-          buff0 = buff[jk    ] + doff;
-          buff1 = buff[jk + 1] + doff;
-          buff2 = buff[jk + 2] + doff;
-
-          off = coff & 7;
-          vis_write_gsr(gsr_scale + off);
-
-          if (off == 0) {
-#pragma pipeloop(0)
-            for (i = 0; i < (xsize + 7)/8; i++) {
-              d0 = buffd[2*i];
-              d1 = buffd[2*i + 1];
-
-              s0 = buff0[i];
-              s1 = buff1[i];
-              s2 = buff2[i];
-
-              d00 = vis_fmul8x16au(vis_read_hi(s0), k0);
-              d01 = vis_fmul8x16au(vis_read_lo(s0), k0);
-              d10 = vis_fmul8x16au(vis_read_hi(s1), k1);
-              d11 = vis_fmul8x16au(vis_read_lo(s1), k1);
-              d20 = vis_fmul8x16au(vis_read_hi(s2), k2);
-              d21 = vis_fmul8x16au(vis_read_lo(s2), k2);
-
-              d00 = vis_fpadd16(d00, d10);
-              d0  = vis_fpadd16(d20, d0);
-              d0  = vis_fpadd16(d00, d0);
-              d01 = vis_fpadd16(d01, d11);
-              d1  = vis_fpadd16(d21, d1);
-              d1  = vis_fpadd16(d01, d1);
-              buffd[2*i] = d0;
-              buffd[2*i + 1] = d1;
-            }
-
-          } else if (off == 4) {
-            s01 = buff0[0];
-            s11 = buff1[0];
-            s21 = buff2[0];
-#pragma pipeloop(0)
-            for (i = 0; i < (xsize + 7)/8; i++) {
-              d0 = buffd[2*i];
-              d1 = buffd[2*i + 1];
-
-              s00 = s01;
-              s10 = s11;
-              s20 = s21;
-              s01 = buff0[i + 1];
-              s11 = buff1[i + 1];
-              s21 = buff2[i + 1];
-
-              d00 = vis_fmul8x16au(vis_read_lo(s00), k0);
-              d01 = vis_fmul8x16au(vis_read_hi(s01), k0);
-              d10 = vis_fmul8x16au(vis_read_lo(s10), k1);
-              d11 = vis_fmul8x16au(vis_read_hi(s11), k1);
-              d20 = vis_fmul8x16au(vis_read_lo(s20), k2);
-              d21 = vis_fmul8x16au(vis_read_hi(s21), k2);
-
-              d00 = vis_fpadd16(d00, d10);
-              d0  = vis_fpadd16(d20, d0);
-              d0  = vis_fpadd16(d00, d0);
-              d01 = vis_fpadd16(d01, d11);
-              d1  = vis_fpadd16(d21, d1);
-              d1  = vis_fpadd16(d01, d1);
-              buffd[2*i] = d0;
-              buffd[2*i + 1] = d1;
-            }
-
-          } else {
-            s01 = buff0[0];
-            s11 = buff1[0];
-            s21 = buff2[0];
-#pragma pipeloop(0)
-            for (i = 0; i < (xsize + 7)/8; i++) {
-              d0 = buffd[2*i];
-              d1 = buffd[2*i + 1];
-
-              s00 = s01;
-              s10 = s11;
-              s20 = s21;
-              s01 = buff0[i + 1];
-              s11 = buff1[i + 1];
-              s21 = buff2[i + 1];
-              s0  = vis_faligndata(s00, s01);
-              s1  = vis_faligndata(s10, s11);
-              s2  = vis_faligndata(s20, s21);
-
-              d00 = vis_fmul8x16au(vis_read_hi(s0), k0);
-              d01 = vis_fmul8x16au(vis_read_lo(s0), k0);
-              d10 = vis_fmul8x16au(vis_read_hi(s1), k1);
-              d11 = vis_fmul8x16au(vis_read_lo(s1), k1);
-              d20 = vis_fmul8x16au(vis_read_hi(s2), k2);
-              d21 = vis_fmul8x16au(vis_read_lo(s2), k2);
-
-              d00 = vis_fpadd16(d00, d10);
-              d0  = vis_fpadd16(d20, d0);
-              d0  = vis_fpadd16(d00, d0);
-              d01 = vis_fpadd16(d01, d11);
-              d1  = vis_fpadd16(d21, d1);
-              d1  = vis_fpadd16(d01, d1);
-              buffd[2*i] = d0;
-              buffd[2*i + 1] = d1;
-            }
-          }
-        }
-
-        pk += 3*m;
-
-      } else { /* jk_size == 4 */
-
-        for (ik = 0; ik < m; ik++, coff += NCHAN) {
-          if (!jk && ik == ik_last) continue;
-
-          k0 = pk[ik];
-          k1 = pk[ik + m];
-          k2 = pk[ik + 2*m];
-          k3 = pk[ik + 3*m];
-
-          doff  = coff/8;
-          buff0 = buff[jk    ] + doff;
-          buff1 = buff[jk + 1] + doff;
-          buff2 = buff[jk + 2] + doff;
-          buff3 = buff[jk + 3] + doff;
-
-          off = coff & 7;
-          vis_write_gsr(gsr_scale + off);
-
-          if (off == 0) {
-
-#pragma pipeloop(0)
-            for (i = 0; i < (xsize + 7)/8; i++) {
-              d0 = buffd[2*i];
-              d1 = buffd[2*i + 1];
-
-              s0 = buff0[i];
-              s1 = buff1[i];
-              s2 = buff2[i];
-              s3 = buff3[i];
-
-              d00 = vis_fmul8x16au(vis_read_hi(s0), k0);
-              d01 = vis_fmul8x16au(vis_read_lo(s0), k0);
-              d10 = vis_fmul8x16au(vis_read_hi(s1), k1);
-              d11 = vis_fmul8x16au(vis_read_lo(s1), k1);
-              d20 = vis_fmul8x16au(vis_read_hi(s2), k2);
-              d21 = vis_fmul8x16au(vis_read_lo(s2), k2);
-              d30 = vis_fmul8x16au(vis_read_hi(s3), k3);
-              d31 = vis_fmul8x16au(vis_read_lo(s3), k3);
-
-              d00 = vis_fpadd16(d00, d10);
-              d20 = vis_fpadd16(d20, d30);
-              d0  = vis_fpadd16(d0,  d00);
-              d0  = vis_fpadd16(d0,  d20);
-              d01 = vis_fpadd16(d01, d11);
-              d21 = vis_fpadd16(d21, d31);
-              d1  = vis_fpadd16(d1,  d01);
-              d1  = vis_fpadd16(d1,  d21);
-              buffd[2*i] = d0;
-              buffd[2*i + 1] = d1;
-            }
-
-          } else if (off == 4) {
-
-            s01 = buff0[0];
-            s11 = buff1[0];
-            s21 = buff2[0];
-            s31 = buff3[0];
-#pragma pipeloop(0)
-            for (i = 0; i < (xsize + 7)/8; i++) {
-              d0 = buffd[2*i];
-              d1 = buffd[2*i + 1];
-
-              s00 = s01;
-              s10 = s11;
-              s20 = s21;
-              s30 = s31;
-              s01 = buff0[i + 1];
-              s11 = buff1[i + 1];
-              s21 = buff2[i + 1];
-              s31 = buff3[i + 1];
-
-              d00 = vis_fmul8x16au(vis_read_lo(s00), k0);
-              d01 = vis_fmul8x16au(vis_read_hi(s01), k0);
-              d10 = vis_fmul8x16au(vis_read_lo(s10), k1);
-              d11 = vis_fmul8x16au(vis_read_hi(s11), k1);
-              d20 = vis_fmul8x16au(vis_read_lo(s20), k2);
-              d21 = vis_fmul8x16au(vis_read_hi(s21), k2);
-              d30 = vis_fmul8x16au(vis_read_lo(s30), k3);
-              d31 = vis_fmul8x16au(vis_read_hi(s31), k3);
-
-              d00 = vis_fpadd16(d00, d10);
-              d20 = vis_fpadd16(d20, d30);
-              d0  = vis_fpadd16(d0,  d00);
-              d0  = vis_fpadd16(d0,  d20);
-              d01 = vis_fpadd16(d01, d11);
-              d21 = vis_fpadd16(d21, d31);
-              d1  = vis_fpadd16(d1,  d01);
-              d1  = vis_fpadd16(d1,  d21);
-              buffd[2*i] = d0;
-              buffd[2*i + 1] = d1;
-            }
-
-          } else {
-
-            s01 = buff0[0];
-            s11 = buff1[0];
-            s21 = buff2[0];
-            s31 = buff3[0];
-#pragma pipeloop(0)
-            for (i = 0; i < (xsize + 7)/8; i++) {
-              d0 = buffd[2*i];
-              d1 = buffd[2*i + 1];
-
-              s00 = s01;
-              s10 = s11;
-              s20 = s21;
-              s30 = s31;
-              s01 = buff0[i + 1];
-              s11 = buff1[i + 1];
-              s21 = buff2[i + 1];
-              s31 = buff3[i + 1];
-              s0  = vis_faligndata(s00, s01);
-              s1  = vis_faligndata(s10, s11);
-              s2  = vis_faligndata(s20, s21);
-              s3  = vis_faligndata(s30, s31);
-
-              d00 = vis_fmul8x16au(vis_read_hi(s0), k0);
-              d01 = vis_fmul8x16au(vis_read_lo(s0), k0);
-              d10 = vis_fmul8x16au(vis_read_hi(s1), k1);
-              d11 = vis_fmul8x16au(vis_read_lo(s1), k1);
-              d20 = vis_fmul8x16au(vis_read_hi(s2), k2);
-              d21 = vis_fmul8x16au(vis_read_lo(s2), k2);
-              d30 = vis_fmul8x16au(vis_read_hi(s3), k3);
-              d31 = vis_fmul8x16au(vis_read_lo(s3), k3);
-
-              d00 = vis_fpadd16(d00, d10);
-              d20 = vis_fpadd16(d20, d30);
-              d0  = vis_fpadd16(d0,  d00);
-              d0  = vis_fpadd16(d0,  d20);
-              d01 = vis_fpadd16(d01, d11);
-              d21 = vis_fpadd16(d21, d31);
-              d1  = vis_fpadd16(d1,  d01);
-              d1  = vis_fpadd16(d1,  d21);
-              buffd[2*i] = d0;
-              buffd[2*i + 1] = d1;
-            }
-          }
-        }
-
-        pk += 4*m;
-      }
-    }
-
-    /*****************************************
-     *****************************************
-     **          Final iteration            **
-     *****************************************
-     *****************************************/
-
-    jk_size = n;
-#ifdef CONV_INDEX
-    if (jk_size >= 5) jk_size = 3;
-    if (jk_size == 4) jk_size = 2;
-#else
-    if (jk_size >= 6) jk_size = 4;
-    if (jk_size == 5) jk_size = 3;
-#endif
-
-    k0 = karr[ik_last];
-    k1 = karr[ik_last + m];
-    k2 = karr[ik_last + 2*m];
-    k3 = karr[ik_last + 3*m];
-
-    off  = ik_last*NCHAN;
-    doff = off/8;
-    off &= 7;
-    buff0 = buff[0] + doff;
-    buff1 = buff[1] + doff;
-    buff2 = buff[2] + doff;
-    buff3 = buff[3] + doff;
-    vis_write_gsr(gsr_scale + off);
-
-#ifndef CONV_INDEX
-    if (jk_size == 2) {
-      dp = ((mlib_addr)dl & 7) ? buffe : (mlib_d64*)dl;
-
-      s01 = buff0[0];
-      s11 = buff1[0];
-#pragma pipeloop(0)
-      for (i = 0; i < xsize/8; i++) {
-        s00 = s01;
-        s10 = s11;
-        s01 = buff0[i + 1];
-        s11 = buff1[i + 1];
-        s0  = vis_faligndata(s00, s01);
-        s1  = vis_faligndata(s10, s11);
-
-        d00 = vis_fmul8x16au(vis_read_hi(s0), k0);
-        d01 = vis_fmul8x16au(vis_read_lo(s0), k0);
-        d10 = vis_fmul8x16au(vis_read_hi(s1), k1);
-        d11 = vis_fmul8x16au(vis_read_lo(s1), k1);
-
-        d0 = buffd[2*i];
-        d1 = buffd[2*i + 1];
-        d0 = vis_fpadd16(d0, d00);
-        d0 = vis_fpadd16(d0, d10);
-        d1 = vis_fpadd16(d1, d01);
-        d1 = vis_fpadd16(d1, d11);
-
-        dd = vis_fpack16_pair(d0, d1);
-        dp[i] = dd;
-
-        buffd[2*i    ] = drnd;
-        buffd[2*i + 1] = drnd;
-      }
-
-      if (emask) {
-        s00 = s01;
-        s10 = s11;
-        s01 = buff0[i + 1];
-        s11 = buff1[i + 1];
-        s0  = vis_faligndata(s00, s01);
-        s1  = vis_faligndata(s10, s11);
-
-        d00 = vis_fmul8x16au(vis_read_hi(s0), k0);
-        d01 = vis_fmul8x16au(vis_read_lo(s0), k0);
-        d10 = vis_fmul8x16au(vis_read_hi(s1), k1);
-        d11 = vis_fmul8x16au(vis_read_lo(s1), k1);
-
-        d0 = buffd[2*i];
-        d1 = buffd[2*i + 1];
-        d0 = vis_fpadd16(d0, d00);
-        d0 = vis_fpadd16(d0, d10);
-        d1 = vis_fpadd16(d1, d01);
-        d1 = vis_fpadd16(d1, d11);
-
-        dd = vis_fpack16_pair(d0, d1);
-        vis_pst_8(dd, dp + i, emask);
-
-        buffd[2*i    ] = drnd;
-        buffd[2*i + 1] = drnd;
-      }
-
-      if ((mlib_u8*)dp != dl) mlib_ImageCopy_na((void*)buffe, dl, xsize);
-
-    } else if (jk_size == 3) {
-
-      dp = ((mlib_addr)dl & 7) ? buffe : (mlib_d64*)dl;
-
-      s01 = buff0[0];
-      s11 = buff1[0];
-      s21 = buff2[0];
-#pragma pipeloop(0)
-      for (i = 0; i < xsize/8; i++) {
-        s00 = s01;
-        s10 = s11;
-        s20 = s21;
-        s01 = buff0[i + 1];
-        s11 = buff1[i + 1];
-        s21 = buff2[i + 1];
-        s0  = vis_faligndata(s00, s01);
-        s1  = vis_faligndata(s10, s11);
-        s2  = vis_faligndata(s20, s21);
-
-        d00 = vis_fmul8x16au(vis_read_hi(s0), k0);
-        d01 = vis_fmul8x16au(vis_read_lo(s0), k0);
-        d10 = vis_fmul8x16au(vis_read_hi(s1), k1);
-        d11 = vis_fmul8x16au(vis_read_lo(s1), k1);
-        d20 = vis_fmul8x16au(vis_read_hi(s2), k2);
-        d21 = vis_fmul8x16au(vis_read_lo(s2), k2);
-
-        d0 = buffd[2*i];
-        d1 = buffd[2*i + 1];
-        d0 = vis_fpadd16(d0, d00);
-        d0 = vis_fpadd16(d0, d10);
-        d0 = vis_fpadd16(d0, d20);
-        d1 = vis_fpadd16(d1, d01);
-        d1 = vis_fpadd16(d1, d11);
-        d1 = vis_fpadd16(d1, d21);
-
-        dd = vis_fpack16_pair(d0, d1);
-        dp[i] = dd;
-
-        buffd[2*i    ] = drnd;
-        buffd[2*i + 1] = drnd;
-      }
-
-      if (emask) {
-        s00 = s01;
-        s10 = s11;
-        s20 = s21;
-        s01 = buff0[i + 1];
-        s11 = buff1[i + 1];
-        s21 = buff2[i + 1];
-        s0  = vis_faligndata(s00, s01);
-        s1  = vis_faligndata(s10, s11);
-        s2  = vis_faligndata(s20, s21);
-
-        d00 = vis_fmul8x16au(vis_read_hi(s0), k0);
-        d01 = vis_fmul8x16au(vis_read_lo(s0), k0);
-        d10 = vis_fmul8x16au(vis_read_hi(s1), k1);
-        d11 = vis_fmul8x16au(vis_read_lo(s1), k1);
-        d20 = vis_fmul8x16au(vis_read_hi(s2), k2);
-        d21 = vis_fmul8x16au(vis_read_lo(s2), k2);
-
-        d0 = buffd[2*i];
-        d1 = buffd[2*i + 1];
-        d0 = vis_fpadd16(d0, d00);
-        d0 = vis_fpadd16(d0, d10);
-        d0 = vis_fpadd16(d0, d20);
-        d1 = vis_fpadd16(d1, d01);
-        d1 = vis_fpadd16(d1, d11);
-        d1 = vis_fpadd16(d1, d21);
-
-        dd = vis_fpack16_pair(d0, d1);
-        vis_pst_8(dd, dp + i, emask);
-
-        buffd[2*i    ] = drnd;
-        buffd[2*i + 1] = drnd;
-      }
-
-      if ((mlib_u8*)dp != dl) mlib_ImageCopy_na((void*)buffe, dl, xsize);
-
-    } else /* if (jk_size == 4) */ {
-
-      dp = ((mlib_addr)dl & 7) ? buffe : (mlib_d64*)dl;
-
-      s01 = buff0[0];
-      s11 = buff1[0];
-      s21 = buff2[0];
-      s31 = buff3[0];
-#pragma pipeloop(0)
-      for (i = 0; i < xsize/8; i++) {
-        s00 = s01;
-        s10 = s11;
-        s20 = s21;
-        s30 = s31;
-        s01 = buff0[i + 1];
-        s11 = buff1[i + 1];
-        s21 = buff2[i + 1];
-        s31 = buff3[i + 1];
-        s0  = vis_faligndata(s00, s01);
-        s1  = vis_faligndata(s10, s11);
-        s2  = vis_faligndata(s20, s21);
-        s3  = vis_faligndata(s30, s31);
-
-        d00 = vis_fmul8x16au(vis_read_hi(s0), k0);
-        d01 = vis_fmul8x16au(vis_read_lo(s0), k0);
-        d10 = vis_fmul8x16au(vis_read_hi(s1), k1);
-        d11 = vis_fmul8x16au(vis_read_lo(s1), k1);
-        d20 = vis_fmul8x16au(vis_read_hi(s2), k2);
-        d21 = vis_fmul8x16au(vis_read_lo(s2), k2);
-        d30 = vis_fmul8x16au(vis_read_hi(s3), k3);
-        d31 = vis_fmul8x16au(vis_read_lo(s3), k3);
-
-        d0 = buffd[2*i];
-        d1 = buffd[2*i + 1];
-        d0 = vis_fpadd16(d0, d00);
-        d0 = vis_fpadd16(d0, d10);
-        d0 = vis_fpadd16(d0, d20);
-        d0 = vis_fpadd16(d0, d30);
-        d1 = vis_fpadd16(d1, d01);
-        d1 = vis_fpadd16(d1, d11);
-        d1 = vis_fpadd16(d1, d21);
-        d1 = vis_fpadd16(d1, d31);
-
-        dd = vis_fpack16_pair(d0, d1);
-        dp[i] = dd;
-
-        buffd[2*i    ] = drnd;
-        buffd[2*i + 1] = drnd;
-      }
-
-      if (emask) {
-        s00 = s01;
-        s10 = s11;
-        s20 = s21;
-        s30 = s31;
-        s01 = buff0[i + 1];
-        s11 = buff1[i + 1];
-        s21 = buff2[i + 1];
-        s31 = buff3[i + 1];
-        s0  = vis_faligndata(s00, s01);
-        s1  = vis_faligndata(s10, s11);
-        s2  = vis_faligndata(s20, s21);
-        s3  = vis_faligndata(s30, s31);
-
-        d00 = vis_fmul8x16au(vis_read_hi(s0), k0);
-        d01 = vis_fmul8x16au(vis_read_lo(s0), k0);
-        d10 = vis_fmul8x16au(vis_read_hi(s1), k1);
-        d11 = vis_fmul8x16au(vis_read_lo(s1), k1);
-        d20 = vis_fmul8x16au(vis_read_hi(s2), k2);
-        d21 = vis_fmul8x16au(vis_read_lo(s2), k2);
-        d30 = vis_fmul8x16au(vis_read_hi(s3), k3);
-        d31 = vis_fmul8x16au(vis_read_lo(s3), k3);
-
-        d0 = buffd[2*i];
-        d1 = buffd[2*i + 1];
-        d0 = vis_fpadd16(d0, d00);
-        d0 = vis_fpadd16(d0, d10);
-        d0 = vis_fpadd16(d0, d20);
-        d0 = vis_fpadd16(d0, d30);
-        d1 = vis_fpadd16(d1, d01);
-        d1 = vis_fpadd16(d1, d11);
-        d1 = vis_fpadd16(d1, d21);
-        d1 = vis_fpadd16(d1, d31);
-
-        dd = vis_fpack16_pair(d0, d1);
-        vis_pst_8(dd, dp + i, emask);
-
-        buffd[2*i    ] = drnd;
-        buffd[2*i + 1] = drnd;
-      }
-
-      if ((mlib_u8*)dp != dl) mlib_ImageCopy_na((void*)buffe, dl, xsize);
-    }
-
-#else /* CONV_INDEX */
-
-    if (jk_size == 2) {
-      vis_write_gsr(gsr_scale + 7);
-
-#pragma pipeloop(0)
-      for (i = 0; i < dsize; i += 3) {
-        mlib_d64 d00, d01, d02, d03, d04, d05;
-        mlib_d64 d10, d11, d12, d13, d14, d15;
-        mlib_d64 d0, d1, d2, d3, d4, d5;
-        mlib_d64 s00 = buff0[i];
-        mlib_d64 s01 = buff0[i + 1];
-        mlib_d64 s02 = buff0[i + 2];
-        mlib_d64 s10 = buff1[i];
-        mlib_d64 s11 = buff1[i + 1];
-        mlib_d64 s12 = buff1[i + 2];
-
-        d00 = vis_fmul8x16au(vis_read_hi(s00), k0);
-        d01 = vis_fmul8x16au(vis_read_lo(s00), k0);
-        d02 = vis_fmul8x16au(vis_read_hi(s01), k0);
-        d03 = vis_fmul8x16au(vis_read_lo(s01), k0);
-        d04 = vis_fmul8x16au(vis_read_hi(s02), k0);
-        d05 = vis_fmul8x16au(vis_read_lo(s02), k0);
-        d10 = vis_fmul8x16au(vis_read_hi(s10), k1);
-        d11 = vis_fmul8x16au(vis_read_lo(s10), k1);
-        d12 = vis_fmul8x16au(vis_read_hi(s11), k1);
-        d13 = vis_fmul8x16au(vis_read_lo(s11), k1);
-        d14 = vis_fmul8x16au(vis_read_hi(s12), k1);
-        d15 = vis_fmul8x16au(vis_read_lo(s12), k1);
-
-        d0 = buffd[2*i];
-        d1 = buffd[2*i + 1];
-        d2 = buffd[2*i + 2];
-        d3 = buffd[2*i + 3];
-        d4 = buffd[2*i + 4];
-        d5 = buffd[2*i + 5];
-        d0 = vis_fpadd16(d0, d00);
-        d0 = vis_fpadd16(d0, d10);
-        d1 = vis_fpadd16(d1, d01);
-        d1 = vis_fpadd16(d1, d11);
-        d2 = vis_fpadd16(d2, d02);
-        d2 = vis_fpadd16(d2, d12);
-        d3 = vis_fpadd16(d3, d03);
-        d3 = vis_fpadd16(d3, d13);
-        d4 = vis_fpadd16(d4, d04);
-        d4 = vis_fpadd16(d4, d14);
-        d5 = vis_fpadd16(d5, d05);
-        d5 = vis_fpadd16(d5, d15);
-
-        buffe[i    ] = vis_fpack16_pair(d0, d1);
-        buffe[i + 1] = vis_fpack16_pair(d2, d3);
-        buffe[i + 2] = vis_fpack16_pair(d4, d5);
-
-        buffd[2*i    ] = drnd;
-        buffd[2*i + 1] = drnd;
-        buffd[2*i + 2] = drnd;
-        buffd[2*i + 3] = drnd;
-        buffd[2*i + 4] = drnd;
-        buffd[2*i + 5] = drnd;
-
-        LOAD_SRC();
-      }
-
-    } else /* if (jk_size == 3) */ {
-      vis_write_gsr(gsr_scale + 7);
-
-#pragma pipeloop(0)
-      for (i = 0; i < dsize; i += 3) {
-        mlib_d64 d00, d01, d02, d03, d04, d05;
-        mlib_d64 d10, d11, d12, d13, d14, d15;
-        mlib_d64 d20, d21, d22, d23, d24, d25;
-        mlib_d64 d0, d1, d2, d3, d4, d5;
-        mlib_d64 s00 = buff0[i];
-        mlib_d64 s01 = buff0[i + 1];
-        mlib_d64 s02 = buff0[i + 2];
-        mlib_d64 s10 = buff1[i];
-        mlib_d64 s11 = buff1[i + 1];
-        mlib_d64 s12 = buff1[i + 2];
-        mlib_d64 s20 = buff2[i];
-        mlib_d64 s21 = buff2[i + 1];
-        mlib_d64 s22 = buff2[i + 2];
-
-        d00 = vis_fmul8x16au(vis_read_hi(s00), k0);
-        d01 = vis_fmul8x16au(vis_read_lo(s00), k0);
-        d02 = vis_fmul8x16au(vis_read_hi(s01), k0);
-        d03 = vis_fmul8x16au(vis_read_lo(s01), k0);
-        d04 = vis_fmul8x16au(vis_read_hi(s02), k0);
-        d05 = vis_fmul8x16au(vis_read_lo(s02), k0);
-        d10 = vis_fmul8x16au(vis_read_hi(s10), k1);
-        d11 = vis_fmul8x16au(vis_read_lo(s10), k1);
-        d12 = vis_fmul8x16au(vis_read_hi(s11), k1);
-        d13 = vis_fmul8x16au(vis_read_lo(s11), k1);
-        d14 = vis_fmul8x16au(vis_read_hi(s12), k1);
-        d15 = vis_fmul8x16au(vis_read_lo(s12), k1);
-        d20 = vis_fmul8x16au(vis_read_hi(s20), k2);
-        d21 = vis_fmul8x16au(vis_read_lo(s20), k2);
-        d22 = vis_fmul8x16au(vis_read_hi(s21), k2);
-        d23 = vis_fmul8x16au(vis_read_lo(s21), k2);
-        d24 = vis_fmul8x16au(vis_read_hi(s22), k2);
-        d25 = vis_fmul8x16au(vis_read_lo(s22), k2);
-
-        d0 = buffd[2*i];
-        d1 = buffd[2*i + 1];
-        d2 = buffd[2*i + 2];
-        d3 = buffd[2*i + 3];
-        d4 = buffd[2*i + 4];
-        d5 = buffd[2*i + 5];
-        d0 = vis_fpadd16(d0, d00);
-        d0 = vis_fpadd16(d0, d10);
-        d0 = vis_fpadd16(d0, d20);
-        d1 = vis_fpadd16(d1, d01);
-        d1 = vis_fpadd16(d1, d11);
-        d1 = vis_fpadd16(d1, d21);
-        d2 = vis_fpadd16(d2, d02);
-        d2 = vis_fpadd16(d2, d12);
-        d2 = vis_fpadd16(d2, d22);
-        d3 = vis_fpadd16(d3, d03);
-        d3 = vis_fpadd16(d3, d13);
-        d3 = vis_fpadd16(d3, d23);
-        d4 = vis_fpadd16(d4, d04);
-        d4 = vis_fpadd16(d4, d14);
-        d4 = vis_fpadd16(d4, d24);
-        d5 = vis_fpadd16(d5, d05);
-        d5 = vis_fpadd16(d5, d15);
-        d5 = vis_fpadd16(d5, d25);
-
-        buffe[i    ] = vis_fpack16_pair(d0, d1);
-        buffe[i + 1] = vis_fpack16_pair(d2, d3);
-        buffe[i + 2] = vis_fpack16_pair(d4, d5);
-
-        buffd[2*i    ] = drnd;
-        buffd[2*i + 1] = drnd;
-        buffd[2*i + 2] = drnd;
-        buffd[2*i + 3] = drnd;
-        buffd[2*i + 4] = drnd;
-        buffd[2*i + 5] = drnd;
-
-        LOAD_SRC();
-      }
-    }
-#endif /* CONV_INDEX */
-
-#ifdef CONV_INDEX
-    mlib_ImageColorTrue2IndexLine_U8_S16_3((void*)buffe, dl, wid, colormap);
-#endif /* CONV_INDEX */
-
-    sl += sll;
-    dl += dll;
-
-    buff_ind++;
-    if (buff_ind >= (n + 1)) buff_ind = 0;
-  }
-
-  mlib_free(pbuff);
-  if (buffs != buffs_local) mlib_free(buffs);
-
-  return MLIB_SUCCESS;
-}
-
-/***************************************************************/
--- a/jdk/src/java.desktop/unix/native/libmlib_image/mlib_v_ImageConvIndex3_8_8nw.c	Thu May 19 17:48:02 2016 +0000
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,1673 +0,0 @@
-/*
- * Copyright (c) 2000, 2003, 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.
- */
-
-
-
-/*
- * FUNCTION
- *      Internal functions for mlib_ImageConv* on U8 type
- *      and MLIB_EDGE_DST_NO_WRITE mask
- *
- */
-
-/***************************************************************/
-
-#include <vis_proto.h>
-#include <mlib_image.h>
-#include <mlib_ImageCheck.h>
-#include <mlib_ImageColormap.h>
-
-/*
-  This defines switches between functions in
-  files: mlib_v_ImageConv_8nw.c,
-         mlib_v_ImageConvIndex3_8_8nw.c,
-         mlib_v_ImageConvIndex4_8_8nw.c,
-         mlib_v_ImageConvIndex3_8_16nw.c,
-         mlib_v_ImageConvIndex4_8_16nw.c
-*/
-
-#define CONV_INDEX
-
-#define DTYPE mlib_u8
-#define LTYPE mlib_u8
-
-/***************************************************************/
-
-#ifdef CONV_INDEX
-
-#define CONV_FUNC(KERN)                                 \
-  mlib_conv##KERN##_Index3_8_8nw(mlib_image *dst,       \
-                                 mlib_image *src,       \
-                                 mlib_s32   *kern,      \
-                                 mlib_s32   scale,      \
-                                 void       *colormap)
-
-#else
-
-#define CONV_FUNC(KERN)                         \
-  mlib_conv##KERN##_8nw_f(mlib_image *dst,      \
-                          mlib_image *src,      \
-                          mlib_s32   *kern,     \
-                          mlib_s32   scale)
-
-#endif
-
-/***************************************************************/
-
-#ifdef CONV_INDEX
-
-#define NCHAN  3
-
-#else
-
-#define NCHAN  nchan
-
-#endif
-
-/***************************************************************/
-
-#define DEF_VARS                                                \
-  DTYPE    *sl, *sp, *dl;                                       \
-  mlib_s32 hgt = mlib_ImageGetHeight(src);                      \
-  mlib_s32 wid = mlib_ImageGetWidth(src);                       \
-  mlib_s32 sll = mlib_ImageGetStride(src) / sizeof(DTYPE);      \
-  mlib_s32 dll = mlib_ImageGetStride(dst) / sizeof(DTYPE);      \
-  DTYPE    *adr_src = (DTYPE *)mlib_ImageGetData(src);          \
-  DTYPE    *adr_dst = (DTYPE *)mlib_ImageGetData(dst);          \
-  mlib_s32 ssize, xsize, dsize, esize, emask, buff_ind = 0;     \
-  mlib_d64 *pbuff, *dp;                                         \
-  mlib_f32 *karr = (mlib_f32 *)kern;                            \
-  mlib_s32 gsr_scale = (31 - scale) << 3;                       \
-  mlib_d64 drnd = vis_to_double_dup(mlib_round_8[31 - scale]);  \
-  mlib_s32 i, j, l
-
-/***************************************************************/
-
-#ifdef CONV_INDEX
-
-#define DEF_EXTRA_VARS                                                  \
-  int    offset = mlib_ImageGetLutOffset(colormap);                     \
-  LTYPE  **lut_table = (LTYPE**)mlib_ImageGetLutData(colormap);         \
-  LTYPE  *ltbl0 = lut_table[0] - offset;                                \
-  LTYPE  *ltbl1 = lut_table[1] - offset;                                \
-  LTYPE  *ltbl2 = lut_table[2] - offset;                                \
-  LTYPE  *ltbl3 = (NCHAN > 3) ? lut_table[3] - offset : ltbl2
-
-#else
-
-#define DEF_EXTRA_VARS                          \
-  mlib_s32 nchan = mlib_ImageGetChannels(dst)
-
-#endif
-
-/***************************************************************/
-
-#if NCHAN == 3
-
-#define LOAD_SRC() {                                            \
-    mlib_s32 s0 = sp[0], s1 = sp[1], s2 = sp[2], s3 = sp[3];    \
-    mlib_s32 s4 = sp[4], s5 = sp[5], s6 = sp[6], s7 = sp[7];    \
-    mlib_d64 t0, t1, t2;                                        \
-                                                                \
-    t2 = vis_faligndata(vis_ld_u8_i(ltbl2, s7), t2);            \
-    t2 = vis_faligndata(vis_ld_u8_i(ltbl1, s7), t2);            \
-    t2 = vis_faligndata(vis_ld_u8_i(ltbl0, s7), t2);            \
-    t2 = vis_faligndata(vis_ld_u8_i(ltbl2, s6), t2);            \
-    t2 = vis_faligndata(vis_ld_u8_i(ltbl1, s6), t2);            \
-    t2 = vis_faligndata(vis_ld_u8_i(ltbl0, s6), t2);            \
-    t2 = vis_faligndata(vis_ld_u8_i(ltbl2, s5), t2);            \
-    t2 = vis_faligndata(vis_ld_u8_i(ltbl1, s5), t2);            \
-    t1 = vis_faligndata(vis_ld_u8_i(ltbl0, s5), t1);            \
-    t1 = vis_faligndata(vis_ld_u8_i(ltbl2, s4), t1);            \
-    t1 = vis_faligndata(vis_ld_u8_i(ltbl1, s4), t1);            \
-    t1 = vis_faligndata(vis_ld_u8_i(ltbl0, s4), t1);            \
-    t1 = vis_faligndata(vis_ld_u8_i(ltbl2, s3), t1);            \
-    t1 = vis_faligndata(vis_ld_u8_i(ltbl1, s3), t1);            \
-    t1 = vis_faligndata(vis_ld_u8_i(ltbl0, s3), t1);            \
-    t1 = vis_faligndata(vis_ld_u8_i(ltbl2, s2), t1);            \
-    t0 = vis_faligndata(vis_ld_u8_i(ltbl1, s2), t0);            \
-    t0 = vis_faligndata(vis_ld_u8_i(ltbl0, s2), t0);            \
-    t0 = vis_faligndata(vis_ld_u8_i(ltbl2, s1), t0);            \
-    t0 = vis_faligndata(vis_ld_u8_i(ltbl1, s1), t0);            \
-    t0 = vis_faligndata(vis_ld_u8_i(ltbl0, s1), t0);            \
-    t0 = vis_faligndata(vis_ld_u8_i(ltbl2, s0), t0);            \
-    t0 = vis_faligndata(vis_ld_u8_i(ltbl1, s0), t0);            \
-    t0 = vis_faligndata(vis_ld_u8_i(ltbl0, s0), t0);            \
-                                                                \
-    buffn[i] = t0;                                              \
-    buffn[i + 1] = t1;                                          \
-    buffn[i + 2] = t2;                                          \
-                                                                \
-    sp += 8;                                                    \
-  }
-
-#else
-
-#define LOAD_SRC() {                                            \
-    mlib_s32 s0 = sp[0], s1 = sp[1], s2 = sp[2], s3 = sp[3];    \
-    mlib_s32 s4 = sp[4], s5 = sp[5], s6 = sp[6], s7 = sp[7];    \
-    mlib_d64 t0, t1, t2;                                        \
-                                                                \
-    t2 = vis_faligndata(vis_ld_u8_i(ltbl3, s5), t2);            \
-    t2 = vis_faligndata(vis_ld_u8_i(ltbl2, s5), t2);            \
-    t2 = vis_faligndata(vis_ld_u8_i(ltbl1, s5), t2);            \
-    t2 = vis_faligndata(vis_ld_u8_i(ltbl0, s5), t2);            \
-    t2 = vis_faligndata(vis_ld_u8_i(ltbl3, s4), t2);            \
-    t2 = vis_faligndata(vis_ld_u8_i(ltbl2, s4), t2);            \
-    t2 = vis_faligndata(vis_ld_u8_i(ltbl1, s4), t2);            \
-    t2 = vis_faligndata(vis_ld_u8_i(ltbl0, s4), t2);            \
-    t1 = vis_faligndata(vis_ld_u8_i(ltbl3, s3), t1);            \
-    t1 = vis_faligndata(vis_ld_u8_i(ltbl2, s3), t1);            \
-    t1 = vis_faligndata(vis_ld_u8_i(ltbl1, s3), t1);            \
-    t1 = vis_faligndata(vis_ld_u8_i(ltbl0, s3), t1);            \
-    t1 = vis_faligndata(vis_ld_u8_i(ltbl3, s2), t1);            \
-    t1 = vis_faligndata(vis_ld_u8_i(ltbl2, s2), t1);            \
-    t1 = vis_faligndata(vis_ld_u8_i(ltbl1, s2), t1);            \
-    t1 = vis_faligndata(vis_ld_u8_i(ltbl0, s2), t1);            \
-    t0 = vis_faligndata(vis_ld_u8_i(ltbl3, s1), t0);            \
-    t0 = vis_faligndata(vis_ld_u8_i(ltbl2, s1), t0);            \
-    t0 = vis_faligndata(vis_ld_u8_i(ltbl1, s1), t0);            \
-    t0 = vis_faligndata(vis_ld_u8_i(ltbl0, s1), t0);            \
-    t0 = vis_faligndata(vis_ld_u8_i(ltbl3, s0), t0);            \
-    t0 = vis_faligndata(vis_ld_u8_i(ltbl2, s0), t0);            \
-    t0 = vis_faligndata(vis_ld_u8_i(ltbl1, s0), t0);            \
-    t0 = vis_faligndata(vis_ld_u8_i(ltbl0, s0), t0);            \
-                                                                \
-    buffn[i] = t0;                                              \
-    buffn[i + 1] = t1;                                          \
-    buffn[i + 2] = t2;                                          \
-                                                                \
-    sp += 6;                                                    \
-  }
-
-#endif
-
-/***************************************************************/
-
-static mlib_s32 mlib_round_8[16] = { 0x00400040, 0x00200020, 0x00100010, 0x00080008,
-                                    0x00040004, 0x00020002, 0x00010001, 0x00000000,
-                                    0x00000000, 0x00000000, 0x00000000, 0x00000000,
-                                    0x00000000, 0x00000000, 0x00000000, 0x00000000 };
-
-/***************************************************************/
-
-void mlib_ImageCopy_na(mlib_u8 *sa, mlib_u8 *da, int size);
-
-/***************************************************************/
-
-#define KSIZE  2
-
-mlib_status CONV_FUNC(2x2)
-{
-  mlib_d64 *buffs[2*(KSIZE + 1)];
-  mlib_d64 *buff0, *buff1, *buffn, *buffd, *buffe;
-  mlib_d64 s00, s01, s10, s11, s0, s1;
-  mlib_d64 d0, d1, d00, d01, d10, d11;
-  DEF_VARS;
-  DEF_EXTRA_VARS;
-
-  sl = adr_src;
-  dl = adr_dst;
-
-  ssize = NCHAN*wid;
-  dsize = (ssize + 7)/8;
-  esize = dsize + 4;
-  pbuff = mlib_malloc((KSIZE + 4)*esize*sizeof(mlib_d64));
-  if (pbuff == NULL) return MLIB_FAILURE;
-
-  for (i = 0; i < (KSIZE + 1); i++) buffs[i] = pbuff + i*esize;
-  for (i = 0; i < (KSIZE + 1); i++) buffs[(KSIZE + 1) + i] = buffs[i];
-  buffd = buffs[KSIZE] + esize;
-  buffe = buffd + 2*esize;
-
-  wid -= (KSIZE - 1);
-  hgt -= (KSIZE - 1);
-  xsize = ssize - NCHAN*(KSIZE - 1);
-  emask = (0xFF00 >> (xsize & 7)) & 0xFF;
-
-  vis_write_gsr(gsr_scale + 7);
-
-  for (l = 0; l < KSIZE; l++) {
-    mlib_d64 *buffn = buffs[l];
-    sp = sl + l*sll;
-
-#ifndef CONV_INDEX
-    if ((mlib_addr)sp & 7) mlib_ImageCopy_na((void*)sp, (void*)buffn, ssize);
-
-#else
-#pragma pipeloop(0)
-    for (i = 0; i < dsize; i += 3) {
-      LOAD_SRC();
-    }
-#endif /* CONV_INDEX */
-  }
-
-  for (j = 0; j < hgt; j++) {
-    mlib_d64 **buffc = buffs + buff_ind;
-    mlib_f32 *pk = karr, k0, k1;
-    sp = sl + KSIZE*sll;
-
-    buff0 = buffc[0];
-    buff1 = buffc[1];
-    buffn = buffc[KSIZE];
-
-#ifndef CONV_INDEX
-    if ((((mlib_addr)(sl      )) & 7) == 0) buff0 = (mlib_d64*)sl;
-    if ((((mlib_addr)(sl + sll)) & 7) == 0) buff1 = (mlib_d64*)(sl + sll);
-    if ((mlib_addr)sp & 7) mlib_ImageCopy_na((void*)sp, (void*)buffn, ssize);
-#endif
-
-    k0 = pk[1];
-    k1 = pk[3];
-    vis_write_gsr(gsr_scale + NCHAN);
-
-    s01 = buff0[0];
-    s11 = buff1[0];
-#pragma pipeloop(0)
-    for (i = 0; i < (xsize + 7)/8; i++) {
-      s00 = s01;
-      s10 = s11;
-      s01 = buff0[i + 1];
-      s11 = buff1[i + 1];
-      s0  = vis_faligndata(s00, s01);
-      s1  = vis_faligndata(s10, s11);
-
-      d00 = vis_fmul8x16au(vis_read_hi(s0), k0);
-      d01 = vis_fmul8x16au(vis_read_lo(s0), k0);
-      d10 = vis_fmul8x16au(vis_read_hi(s1), k1);
-      d11 = vis_fmul8x16au(vis_read_lo(s1), k1);
-
-      d0 = vis_fpadd16(d00, d10);
-      d1 = vis_fpadd16(d01, d11);
-      buffd[2*i] = d0;
-      buffd[2*i + 1] = d1;
-    }
-
-    k0 = pk[0];
-    k1 = pk[2];
-#ifndef CONV_INDEX
-    dp = ((mlib_addr)dl & 7) ? buffe : (mlib_d64*)dl;
-
-#pragma pipeloop(0)
-    for (i = 0; i < xsize/8; i++) {
-      s0 = buff0[i];
-      s1 = buff1[i];
-
-      d00 = vis_fmul8x16au(vis_read_hi(s0), k0);
-      d01 = vis_fmul8x16au(vis_read_lo(s0), k0);
-      d10 = vis_fmul8x16au(vis_read_hi(s1), k1);
-      d11 = vis_fmul8x16au(vis_read_lo(s1), k1);
-
-      d0 = buffd[2*i];
-      d1 = buffd[2*i + 1];
-      d00 = vis_fpadd16(d00, d10);
-      d0  = vis_fpadd16(d0, drnd);
-      d0  = vis_fpadd16(d0, d00);
-      d01 = vis_fpadd16(d01, d11);
-      d1  = vis_fpadd16(d1, drnd);
-      d1  = vis_fpadd16(d1, d01);
-      dp[i] = vis_fpack16_pair(d0, d1);
-    }
-
-    if (emask) {
-      s0 = buff0[i];
-      s1 = buff1[i];
-
-      d00 = vis_fmul8x16au(vis_read_hi(s0), k0);
-      d01 = vis_fmul8x16au(vis_read_lo(s0), k0);
-      d10 = vis_fmul8x16au(vis_read_hi(s1), k1);
-      d11 = vis_fmul8x16au(vis_read_lo(s1), k1);
-
-      d0 = buffd[2*i];
-      d1 = buffd[2*i + 1];
-      d00 = vis_fpadd16(d00, d10);
-      d0  = vis_fpadd16(d0, drnd);
-      d0  = vis_fpadd16(d0, d00);
-      d01 = vis_fpadd16(d01, d11);
-      d1  = vis_fpadd16(d1, drnd);
-      d1  = vis_fpadd16(d1, d01);
-
-      d0 = vis_fpack16_pair(d0, d1);
-      vis_pst_8(d0, dp + i, emask);
-    }
-
-    if ((mlib_u8*)dp != dl) mlib_ImageCopy_na((void*)buffe, dl, xsize);
-
-#else
-    vis_write_gsr(gsr_scale + 7);
-
-#pragma pipeloop(0)
-    for (i = 0; i < dsize; i += 3) {
-      mlib_d64 d00, d01, d02, d03, d04, d05;
-      mlib_d64 d10, d11, d12, d13, d14, d15;
-      mlib_d64 d0, d1, d2, d3, d4, d5;
-      mlib_d64 s00 = buff0[i];
-      mlib_d64 s01 = buff0[i + 1];
-      mlib_d64 s02 = buff0[i + 2];
-      mlib_d64 s10 = buff1[i];
-      mlib_d64 s11 = buff1[i + 1];
-      mlib_d64 s12 = buff1[i + 2];
-
-      d00 = vis_fmul8x16au(vis_read_hi(s00), k0);
-      d01 = vis_fmul8x16au(vis_read_lo(s00), k0);
-      d02 = vis_fmul8x16au(vis_read_hi(s01), k0);
-      d03 = vis_fmul8x16au(vis_read_lo(s01), k0);
-      d04 = vis_fmul8x16au(vis_read_hi(s02), k0);
-      d05 = vis_fmul8x16au(vis_read_lo(s02), k0);
-      d10 = vis_fmul8x16au(vis_read_hi(s10), k1);
-      d11 = vis_fmul8x16au(vis_read_lo(s10), k1);
-      d12 = vis_fmul8x16au(vis_read_hi(s11), k1);
-      d13 = vis_fmul8x16au(vis_read_lo(s11), k1);
-      d14 = vis_fmul8x16au(vis_read_hi(s12), k1);
-      d15 = vis_fmul8x16au(vis_read_lo(s12), k1);
-
-      d0 = buffd[2*i];
-      d1 = buffd[2*i + 1];
-      d2 = buffd[2*i + 2];
-      d3 = buffd[2*i + 3];
-      d4 = buffd[2*i + 4];
-      d5 = buffd[2*i + 5];
-      d00 = vis_fpadd16(d00, d10);
-      d0  = vis_fpadd16(d0, drnd);
-      d0  = vis_fpadd16(d0, d00);
-      d01 = vis_fpadd16(d01, d11);
-      d1  = vis_fpadd16(d1, drnd);
-      d1  = vis_fpadd16(d1, d01);
-      d02 = vis_fpadd16(d02, d12);
-      d2  = vis_fpadd16(d2, drnd);
-      d2  = vis_fpadd16(d2, d02);
-      d03 = vis_fpadd16(d03, d13);
-      d3  = vis_fpadd16(d3, drnd);
-      d3  = vis_fpadd16(d3, d03);
-      d04 = vis_fpadd16(d04, d14);
-      d4  = vis_fpadd16(d4, drnd);
-      d4  = vis_fpadd16(d4, d04);
-      d05 = vis_fpadd16(d05, d15);
-      d5  = vis_fpadd16(d5, drnd);
-      d5  = vis_fpadd16(d5, d05);
-
-      buffe[i    ] = vis_fpack16_pair(d0, d1);
-      buffe[i + 1] = vis_fpack16_pair(d2, d3);
-      buffe[i + 2] = vis_fpack16_pair(d4, d5);
-
-      LOAD_SRC();
-    }
-
-    mlib_ImageColorTrue2IndexLine_U8_U8_3((void*)buffe, dl, wid, colormap);
-#endif /* CONV_INDEX */
-
-    sl += sll;
-    dl += dll;
-
-    buff_ind++;
-    if (buff_ind >= (KSIZE + 1)) buff_ind = 0;
-  }
-
-  mlib_free(pbuff);
-
-  return MLIB_SUCCESS;
-}
-
-/***************************************************************/
-
-#undef  KSIZE
-#define KSIZE  3
-
-mlib_status CONV_FUNC(3x3)
-{
-  mlib_d64 *buffs[2*(KSIZE + 1)];
-  mlib_d64 *buff0, *buff1, *buff2, *buffn, *buffd, *buffe;
-  mlib_d64 s00, s01, s10, s11, s20, s21, s0, s1, s2;
-  mlib_d64 dd, d0, d1, d00, d01, d10, d11, d20, d21;
-  mlib_s32 ik, ik_last, off, doff;
-  DEF_VARS;
-  DEF_EXTRA_VARS;
-
-  sl = adr_src;
-#ifdef CONV_INDEX
-  dl = adr_dst + ((KSIZE - 1)/2)*(dll + 1);
-#else
-  dl = adr_dst + ((KSIZE - 1)/2)*(dll + NCHAN);
-#endif
-
-  ssize = NCHAN*wid;
-  dsize = (ssize + 7)/8;
-  esize = dsize + 4;
-  pbuff = mlib_malloc((KSIZE + 4)*esize*sizeof(mlib_d64));
-  if (pbuff == NULL) return MLIB_FAILURE;
-
-  for (i = 0; i < (KSIZE + 1); i++) buffs[i] = pbuff + i*esize;
-  for (i = 0; i < (KSIZE + 1); i++) buffs[(KSIZE + 1) + i] = buffs[i];
-  buffd = buffs[KSIZE] + esize;
-  buffe = buffd + 2*esize;
-
-  wid -= (KSIZE - 1);
-  hgt -= (KSIZE - 1);
-  xsize = ssize - NCHAN*(KSIZE - 1);
-  emask = (0xFF00 >> (xsize & 7)) & 0xFF;
-
-  vis_write_gsr(gsr_scale + 7);
-
-  for (l = 0; l < KSIZE; l++) {
-    mlib_d64 *buffn = buffs[l];
-    sp = sl + l*sll;
-
-#ifndef CONV_INDEX
-    if ((mlib_addr)sp & 7) mlib_ImageCopy_na((void*)sp, (void*)buffn, ssize);
-#else
-#pragma pipeloop(0)
-    for (i = 0; i < dsize; i += 3) {
-      LOAD_SRC();
-    }
-#endif /* CONV_INDEX */
-  }
-
-  /* init buffer */
-#pragma pipeloop(0)
-  for (i = 0; i < (xsize + 7)/8; i++) {
-    buffd[2*i    ] = drnd;
-    buffd[2*i + 1] = drnd;
-  }
-
-  for (j = 0; j < hgt; j++) {
-    mlib_d64 **buffc = buffs + buff_ind, *pbuff0, *pbuff1, *pbuff2;
-    mlib_f32 *pk = karr, k0, k1, k2;
-    sp = sl + KSIZE*sll;
-
-    pbuff0 = buffc[0];
-    pbuff1 = buffc[1];
-    pbuff2 = buffc[2];
-    buffn  = buffc[KSIZE];
-
-#ifndef CONV_INDEX
-    if ((((mlib_addr)(sl        )) & 7) == 0) pbuff0 = (mlib_d64*)sl;
-    if ((((mlib_addr)(sl +   sll)) & 7) == 0) pbuff1 = (mlib_d64*)(sl + sll);
-    if ((((mlib_addr)(sl + 2*sll)) & 7) == 0) pbuff2 = (mlib_d64*)(sl + 2*sll);
-
-    if ((mlib_addr)sp & 7) mlib_ImageCopy_na((void*)sp, (void*)buffn, ssize);
-#endif
-
-#ifdef CONV_INDEX
-    ik_last = 0;
-#else
-    ik_last = (KSIZE - 1);
-#endif
-
-    for (ik = 0; ik < KSIZE; ik++) {
-      k0 = pk[ik];
-      k1 = pk[ik + KSIZE];
-      k2 = pk[ik + 2*KSIZE];
-
-      off  = ik*NCHAN;
-      doff = off/8;
-      off &= 7;
-      buff0 = pbuff0 + doff;
-      buff1 = pbuff1 + doff;
-      buff2 = pbuff2 + doff;
-      vis_write_gsr(gsr_scale + off);
-
-      if (ik == ik_last) continue;
-      /*if (!ik_last) {
-        if ((off & 3) || (ik == (KSIZE - 1))) {
-          ik_last = ik;
-          continue;
-        }
-      }*/
-
-      if (off == 0) {
-#pragma pipeloop(0)
-        for (i = 0; i < (xsize + 7)/8; i++) {
-          s0 = buff0[i];
-          s1 = buff1[i];
-          s2 = buff2[i];
-
-          d00 = vis_fmul8x16au(vis_read_hi(s0), k0);
-          d01 = vis_fmul8x16au(vis_read_lo(s0), k0);
-          d10 = vis_fmul8x16au(vis_read_hi(s1), k1);
-          d11 = vis_fmul8x16au(vis_read_lo(s1), k1);
-          d20 = vis_fmul8x16au(vis_read_hi(s2), k2);
-          d21 = vis_fmul8x16au(vis_read_lo(s2), k2);
-
-          d0 = buffd[2*i];
-          d1 = buffd[2*i + 1];
-          d0 = vis_fpadd16(d00, d0);
-          d0 = vis_fpadd16(d10, d0);
-          d0 = vis_fpadd16(d20, d0);
-          d1 = vis_fpadd16(d01, d1);
-          d1 = vis_fpadd16(d11, d1);
-          d1 = vis_fpadd16(d21, d1);
-          buffd[2*i] = d0;
-          buffd[2*i + 1] = d1;
-        }
-
-      } else if (off == 4) {
-        s01 = buff0[0];
-        s11 = buff1[0];
-        s21 = buff2[0];
-#pragma pipeloop(0)
-        for (i = 0; i < (xsize + 7)/8; i++) {
-          s00 = s01;
-          s10 = s11;
-          s20 = s21;
-          s01 = buff0[i + 1];
-          s11 = buff1[i + 1];
-          s21 = buff2[i + 1];
-
-          d00 = vis_fmul8x16au(vis_read_lo(s00), k0);
-          d01 = vis_fmul8x16au(vis_read_hi(s01), k0);
-          d10 = vis_fmul8x16au(vis_read_lo(s10), k1);
-          d11 = vis_fmul8x16au(vis_read_hi(s11), k1);
-          d20 = vis_fmul8x16au(vis_read_lo(s20), k2);
-          d21 = vis_fmul8x16au(vis_read_hi(s21), k2);
-
-          d0 = buffd[2*i];
-          d1 = buffd[2*i + 1];
-          d0 = vis_fpadd16(d00, d0);
-          d0 = vis_fpadd16(d10, d0);
-          d0 = vis_fpadd16(d20, d0);
-          d1 = vis_fpadd16(d01, d1);
-          d1 = vis_fpadd16(d11, d1);
-          d1 = vis_fpadd16(d21, d1);
-          buffd[2*i] = d0;
-          buffd[2*i + 1] = d1;
-        }
-
-      } else {
-        s01 = buff0[0];
-        s11 = buff1[0];
-        s21 = buff2[0];
-#pragma pipeloop(0)
-        for (i = 0; i < (xsize + 7)/8; i++) {
-          s00 = s01;
-          s10 = s11;
-          s20 = s21;
-          s01 = buff0[i + 1];
-          s11 = buff1[i + 1];
-          s21 = buff2[i + 1];
-          s0  = vis_faligndata(s00, s01);
-          s1  = vis_faligndata(s10, s11);
-          s2  = vis_faligndata(s20, s21);
-
-          d00 = vis_fmul8x16au(vis_read_hi(s0), k0);
-          d01 = vis_fmul8x16au(vis_read_lo(s0), k0);
-          d10 = vis_fmul8x16au(vis_read_hi(s1), k1);
-          d11 = vis_fmul8x16au(vis_read_lo(s1), k1);
-          d20 = vis_fmul8x16au(vis_read_hi(s2), k2);
-          d21 = vis_fmul8x16au(vis_read_lo(s2), k2);
-
-          d0 = buffd[2*i];
-          d1 = buffd[2*i + 1];
-          d0 = vis_fpadd16(d00, d0);
-          d0 = vis_fpadd16(d10, d0);
-          d0 = vis_fpadd16(d20, d0);
-          d1 = vis_fpadd16(d01, d1);
-          d1 = vis_fpadd16(d11, d1);
-          d1 = vis_fpadd16(d21, d1);
-          buffd[2*i] = d0;
-          buffd[2*i + 1] = d1;
-        }
-      }
-    }
-
-    k0 = pk[ik_last];
-    k1 = pk[ik_last + KSIZE];
-    k2 = pk[ik_last + 2*KSIZE];
-
-    off  = ik_last*NCHAN;
-    doff = off/8;
-    off &= 7;
-    buff0 = pbuff0 + doff;
-    buff1 = pbuff1 + doff;
-    buff2 = pbuff2 + doff;
-    vis_write_gsr(gsr_scale + off);
-
-#ifndef CONV_INDEX
-    dp = ((mlib_addr)dl & 7) ? buffe : (mlib_d64*)dl;
-
-    s01 = buff0[0];
-    s11 = buff1[0];
-    s21 = buff2[0];
-#pragma pipeloop(0)
-    for (i = 0; i < xsize/8; i++) {
-      s00 = s01;
-      s10 = s11;
-      s20 = s21;
-      s01 = buff0[i + 1];
-      s11 = buff1[i + 1];
-      s21 = buff2[i + 1];
-      s0  = vis_faligndata(s00, s01);
-      s1  = vis_faligndata(s10, s11);
-      s2  = vis_faligndata(s20, s21);
-
-      d00 = vis_fmul8x16au(vis_read_hi(s0), k0);
-      d01 = vis_fmul8x16au(vis_read_lo(s0), k0);
-      d10 = vis_fmul8x16au(vis_read_hi(s1), k1);
-      d11 = vis_fmul8x16au(vis_read_lo(s1), k1);
-      d20 = vis_fmul8x16au(vis_read_hi(s2), k2);
-      d21 = vis_fmul8x16au(vis_read_lo(s2), k2);
-
-      d0 = buffd[2*i];
-      d1 = buffd[2*i + 1];
-      d0 = vis_fpadd16(d0, d00);
-      d0 = vis_fpadd16(d0, d10);
-      d0 = vis_fpadd16(d0, d20);
-      d1 = vis_fpadd16(d1, d01);
-      d1 = vis_fpadd16(d1, d11);
-      d1 = vis_fpadd16(d1, d21);
-
-      dd = vis_fpack16_pair(d0, d1);
-      dp[i] = dd;
-
-      buffd[2*i    ] = drnd;
-      buffd[2*i + 1] = drnd;
-    }
-
-    if (emask) {
-      s00 = s01;
-      s10 = s11;
-      s20 = s21;
-      s01 = buff0[i + 1];
-      s11 = buff1[i + 1];
-      s21 = buff2[i + 1];
-      s0  = vis_faligndata(s00, s01);
-      s1  = vis_faligndata(s10, s11);
-      s2  = vis_faligndata(s20, s21);
-
-      d00 = vis_fmul8x16au(vis_read_hi(s0), k0);
-      d01 = vis_fmul8x16au(vis_read_lo(s0), k0);
-      d10 = vis_fmul8x16au(vis_read_hi(s1), k1);
-      d11 = vis_fmul8x16au(vis_read_lo(s1), k1);
-      d20 = vis_fmul8x16au(vis_read_hi(s2), k2);
-      d21 = vis_fmul8x16au(vis_read_lo(s2), k2);
-
-      d0 = buffd[2*i];
-      d1 = buffd[2*i + 1];
-      d0 = vis_fpadd16(d0, d00);
-      d0 = vis_fpadd16(d0, d10);
-      d0 = vis_fpadd16(d0, d20);
-      d1 = vis_fpadd16(d1, d01);
-      d1 = vis_fpadd16(d1, d11);
-      d1 = vis_fpadd16(d1, d21);
-
-      dd = vis_fpack16_pair(d0, d1);
-      vis_pst_8(dd, dp + i, emask);
-
-      buffd[2*i    ] = drnd;
-      buffd[2*i + 1] = drnd;
-    }
-
-    if ((mlib_u8*)dp != dl) mlib_ImageCopy_na((void*)buffe, dl, xsize);
-
-#else
-    vis_write_gsr(gsr_scale + 7);
-
-#pragma pipeloop(0)
-    for (i = 0; i < dsize; i += 3) {
-      mlib_d64 d00, d01, d02, d03, d04, d05;
-      mlib_d64 d10, d11, d12, d13, d14, d15;
-      mlib_d64 d20, d21, d22, d23, d24, d25;
-      mlib_d64 d0, d1, d2, d3, d4, d5;
-      mlib_d64 s00 = buff0[i];
-      mlib_d64 s01 = buff0[i + 1];
-      mlib_d64 s02 = buff0[i + 2];
-      mlib_d64 s10 = buff1[i];
-      mlib_d64 s11 = buff1[i + 1];
-      mlib_d64 s12 = buff1[i + 2];
-      mlib_d64 s20 = buff2[i];
-      mlib_d64 s21 = buff2[i + 1];
-      mlib_d64 s22 = buff2[i + 2];
-
-      d00 = vis_fmul8x16au(vis_read_hi(s00), k0);
-      d01 = vis_fmul8x16au(vis_read_lo(s00), k0);
-      d02 = vis_fmul8x16au(vis_read_hi(s01), k0);
-      d03 = vis_fmul8x16au(vis_read_lo(s01), k0);
-      d04 = vis_fmul8x16au(vis_read_hi(s02), k0);
-      d05 = vis_fmul8x16au(vis_read_lo(s02), k0);
-      d10 = vis_fmul8x16au(vis_read_hi(s10), k1);
-      d11 = vis_fmul8x16au(vis_read_lo(s10), k1);
-      d12 = vis_fmul8x16au(vis_read_hi(s11), k1);
-      d13 = vis_fmul8x16au(vis_read_lo(s11), k1);
-      d14 = vis_fmul8x16au(vis_read_hi(s12), k1);
-      d15 = vis_fmul8x16au(vis_read_lo(s12), k1);
-      d20 = vis_fmul8x16au(vis_read_hi(s20), k2);
-      d21 = vis_fmul8x16au(vis_read_lo(s20), k2);
-      d22 = vis_fmul8x16au(vis_read_hi(s21), k2);
-      d23 = vis_fmul8x16au(vis_read_lo(s21), k2);
-      d24 = vis_fmul8x16au(vis_read_hi(s22), k2);
-      d25 = vis_fmul8x16au(vis_read_lo(s22), k2);
-
-      d0 = buffd[2*i];
-      d1 = buffd[2*i + 1];
-      d2 = buffd[2*i + 2];
-      d3 = buffd[2*i + 3];
-      d4 = buffd[2*i + 4];
-      d5 = buffd[2*i + 5];
-      d0 = vis_fpadd16(d0, d00);
-      d0 = vis_fpadd16(d0, d10);
-      d0 = vis_fpadd16(d0, d20);
-      d1 = vis_fpadd16(d1, d01);
-      d1 = vis_fpadd16(d1, d11);
-      d1 = vis_fpadd16(d1, d21);
-      d2 = vis_fpadd16(d2, d02);
-      d2 = vis_fpadd16(d2, d12);
-      d2 = vis_fpadd16(d2, d22);
-      d3 = vis_fpadd16(d3, d03);
-      d3 = vis_fpadd16(d3, d13);
-      d3 = vis_fpadd16(d3, d23);
-      d4 = vis_fpadd16(d4, d04);
-      d4 = vis_fpadd16(d4, d14);
-      d4 = vis_fpadd16(d4, d24);
-      d5 = vis_fpadd16(d5, d05);
-      d5 = vis_fpadd16(d5, d15);
-      d5 = vis_fpadd16(d5, d25);
-
-      buffe[i    ] = vis_fpack16_pair(d0, d1);
-      buffe[i + 1] = vis_fpack16_pair(d2, d3);
-      buffe[i + 2] = vis_fpack16_pair(d4, d5);
-
-      buffd[2*i    ] = drnd;
-      buffd[2*i + 1] = drnd;
-      buffd[2*i + 2] = drnd;
-      buffd[2*i + 3] = drnd;
-      buffd[2*i + 4] = drnd;
-      buffd[2*i + 5] = drnd;
-
-      LOAD_SRC();
-    }
-
-    mlib_ImageColorTrue2IndexLine_U8_U8_3((void*)buffe, dl, wid, colormap);
-#endif /* CONV_INDEX */
-
-    sl += sll;
-    dl += dll;
-
-    buff_ind++;
-    if (buff_ind >= (KSIZE + 1)) buff_ind = 0;
-  }
-
-  mlib_free(pbuff);
-
-  return MLIB_SUCCESS;
-}
-
-/***************************************************************/
-
-#undef  KSIZE
-#define MAX_N   11
-
-#ifdef CONV_INDEX
-
-mlib_status mlib_convMxN_Index3_8_8nw(mlib_image *dst,
-                                      mlib_image *src,
-                                      mlib_s32   m,
-                                      mlib_s32   n,
-                                      mlib_s32   dm,
-                                      mlib_s32   dn,
-                                      mlib_s32   *kern,
-                                      mlib_s32   scale,
-                                      void       *colormap)
-
-#else
-
-mlib_status mlib_convMxN_8nw_f(mlib_image *dst,
-                               mlib_image *src,
-                               mlib_s32   m,
-                               mlib_s32   n,
-                               mlib_s32   dm,
-                               mlib_s32   dn,
-                               mlib_s32   *kern,
-                               mlib_s32   scale)
-
-#endif
-{
-  mlib_d64 *buffs_local[3*(MAX_N + 1)], **buffs = buffs_local, **buff;
-  mlib_d64 *buff0, *buff1, *buff2, *buff3, *buffn, *buffd, *buffe;
-  mlib_d64 s00, s01, s10, s11, s20, s21, s30, s31, s0, s1, s2, s3;
-  mlib_d64 d00, d01, d10, d11, d20, d21, d30, d31;
-  mlib_d64 dd, d0, d1;
-  mlib_s32 ik, jk, ik_last, jk_size, coff, off, doff;
-  DEF_VARS;
-  DEF_EXTRA_VARS;
-
-  if (n > MAX_N) {
-    buffs = mlib_malloc(3*(n + 1)*sizeof(mlib_d64*));
-    if (buffs == NULL) return MLIB_FAILURE;
-  }
-
-  buff = buffs + 2*(n + 1);
-
-  sl = adr_src;
-#ifdef CONV_INDEX
-  dl = adr_dst + dn*dll + dm;
-#else
-  dl = adr_dst + dn*dll + dm*NCHAN;
-#endif
-
-  ssize = NCHAN*wid;
-  dsize = (ssize + 7)/8;
-  esize = dsize + 4;
-  pbuff = mlib_malloc((n + 4)*esize*sizeof(mlib_d64));
-  if (pbuff == NULL) {
-    if (buffs != buffs_local) mlib_free(buffs);
-    return MLIB_FAILURE;
-  }
-
-  for (i = 0; i < (n + 1); i++) buffs[i] = pbuff + i*esize;
-  for (i = 0; i < (n + 1); i++) buffs[(n + 1) + i] = buffs[i];
-  buffd = buffs[n] + esize;
-  buffe = buffd + 2*esize;
-
-  wid -= (m - 1);
-  hgt -= (n - 1);
-  xsize = ssize - NCHAN*(m - 1);
-  emask = (0xFF00 >> (xsize & 7)) & 0xFF;
-
-  vis_write_gsr(gsr_scale + 7);
-
-  for (l = 0; l < n; l++) {
-    mlib_d64 *buffn = buffs[l];
-    sp = sl + l*sll;
-
-#ifndef CONV_INDEX
-    if ((mlib_addr)sp & 7) mlib_ImageCopy_na((void*)sp, (void*)buffn, ssize);
-#else
-#pragma pipeloop(0)
-    for (i = 0; i < dsize; i += 3) {
-      LOAD_SRC();
-    }
-#endif /* CONV_INDEX */
-  }
-
-  /* init buffer */
-#pragma pipeloop(0)
-  for (i = 0; i < (xsize + 7)/8; i++) {
-    buffd[2*i    ] = drnd;
-    buffd[2*i + 1] = drnd;
-  }
-
-  for (j = 0; j < hgt; j++) {
-    mlib_d64 **buffc = buffs + buff_ind;
-    mlib_f32 *pk = karr, k0, k1, k2, k3;
-    sp = sl + n*sll;
-
-    for (l = 0; l < n; l++) {
-      buff[l] = buffc[l];
-    }
-    buffn  = buffc[n];
-
-#ifndef CONV_INDEX
-    for (l = 0; l < n; l++) {
-      if ((((mlib_addr)(sl + l*sll)) & 7) == 0) buff[l] = (mlib_d64*)(sl + l*sll);
-    }
-    if ((mlib_addr)sp & 7) mlib_ImageCopy_na((void*)sp, (void*)buffn, ssize);
-#endif
-
-#ifdef CONV_INDEX
-    ik_last = 0;
-#else
-    ik_last = (m - 1);
-#endif
-
-    for (jk = 0; jk < n; jk += jk_size) {
-      jk_size = n - jk;
-#ifdef CONV_INDEX
-      if (jk_size >= 5) jk_size = 3;
-      if (jk_size == 4) jk_size = 2;
-#else
-      if (jk_size >= 6) jk_size = 4;
-      if (jk_size == 5) jk_size = 3;
-#endif
-      coff = 0;
-
-      if (jk_size == 2) {
-
-        for (ik = 0; ik < m; ik++, coff += NCHAN) {
-          if (!jk && ik == ik_last) continue;
-
-          k0 = pk[ik];
-          k1 = pk[ik + m];
-
-          doff  = coff/8;
-          buff0 = buff[jk    ] + doff;
-          buff1 = buff[jk + 1] + doff;
-
-          off = coff & 7;
-          vis_write_gsr(gsr_scale + off);
-
-          s01 = buff0[0];
-          s11 = buff1[0];
-#pragma pipeloop(0)
-          for (i = 0; i < (xsize + 7)/8; i++) {
-            s00 = s01;
-            s10 = s11;
-            s01 = buff0[i + 1];
-            s11 = buff1[i + 1];
-            s0  = vis_faligndata(s00, s01);
-            s1  = vis_faligndata(s10, s11);
-
-            d00 = vis_fmul8x16au(vis_read_hi(s0), k0);
-            d01 = vis_fmul8x16au(vis_read_lo(s0), k0);
-            d10 = vis_fmul8x16au(vis_read_hi(s1), k1);
-            d11 = vis_fmul8x16au(vis_read_lo(s1), k1);
-
-            d0 = buffd[2*i];
-            d1 = buffd[2*i + 1];
-            d0 = vis_fpadd16(d00, d0);
-            d0 = vis_fpadd16(d10, d0);
-            d1 = vis_fpadd16(d01, d1);
-            d1 = vis_fpadd16(d11, d1);
-            buffd[2*i] = d0;
-            buffd[2*i + 1] = d1;
-          }
-
-        }
-
-        pk += 2*m;
-
-      } else if (jk_size == 3) {
-
-        for (ik = 0; ik < m; ik++, coff += NCHAN) {
-          if (!jk && ik == ik_last) continue;
-
-          k0 = pk[ik];
-          k1 = pk[ik + m];
-          k2 = pk[ik + 2*m];
-
-          doff  = coff/8;
-          buff0 = buff[jk    ] + doff;
-          buff1 = buff[jk + 1] + doff;
-          buff2 = buff[jk + 2] + doff;
-
-          off = coff & 7;
-          vis_write_gsr(gsr_scale + off);
-
-          if (off == 0) {
-#pragma pipeloop(0)
-            for (i = 0; i < (xsize + 7)/8; i++) {
-              d0 = buffd[2*i];
-              d1 = buffd[2*i + 1];
-
-              s0 = buff0[i];
-              s1 = buff1[i];
-              s2 = buff2[i];
-
-              d00 = vis_fmul8x16au(vis_read_hi(s0), k0);
-              d01 = vis_fmul8x16au(vis_read_lo(s0), k0);
-              d10 = vis_fmul8x16au(vis_read_hi(s1), k1);
-              d11 = vis_fmul8x16au(vis_read_lo(s1), k1);
-              d20 = vis_fmul8x16au(vis_read_hi(s2), k2);
-              d21 = vis_fmul8x16au(vis_read_lo(s2), k2);
-
-              d00 = vis_fpadd16(d00, d10);
-              d0  = vis_fpadd16(d20, d0);
-              d0  = vis_fpadd16(d00, d0);
-              d01 = vis_fpadd16(d01, d11);
-              d1  = vis_fpadd16(d21, d1);
-              d1  = vis_fpadd16(d01, d1);
-              buffd[2*i] = d0;
-              buffd[2*i + 1] = d1;
-            }
-
-          } else if (off == 4) {
-            s01 = buff0[0];
-            s11 = buff1[0];
-            s21 = buff2[0];
-#pragma pipeloop(0)
-            for (i = 0; i < (xsize + 7)/8; i++) {
-              d0 = buffd[2*i];
-              d1 = buffd[2*i + 1];
-
-              s00 = s01;
-              s10 = s11;
-              s20 = s21;
-              s01 = buff0[i + 1];
-              s11 = buff1[i + 1];
-              s21 = buff2[i + 1];
-
-              d00 = vis_fmul8x16au(vis_read_lo(s00), k0);
-              d01 = vis_fmul8x16au(vis_read_hi(s01), k0);
-              d10 = vis_fmul8x16au(vis_read_lo(s10), k1);
-              d11 = vis_fmul8x16au(vis_read_hi(s11), k1);
-              d20 = vis_fmul8x16au(vis_read_lo(s20), k2);
-              d21 = vis_fmul8x16au(vis_read_hi(s21), k2);
-
-              d00 = vis_fpadd16(d00, d10);
-              d0  = vis_fpadd16(d20, d0);
-              d0  = vis_fpadd16(d00, d0);
-              d01 = vis_fpadd16(d01, d11);
-              d1  = vis_fpadd16(d21, d1);
-              d1  = vis_fpadd16(d01, d1);
-              buffd[2*i] = d0;
-              buffd[2*i + 1] = d1;
-            }
-
-          } else {
-            s01 = buff0[0];
-            s11 = buff1[0];
-            s21 = buff2[0];
-#pragma pipeloop(0)
-            for (i = 0; i < (xsize + 7)/8; i++) {
-              d0 = buffd[2*i];
-              d1 = buffd[2*i + 1];
-
-              s00 = s01;
-              s10 = s11;
-              s20 = s21;
-              s01 = buff0[i + 1];
-              s11 = buff1[i + 1];
-              s21 = buff2[i + 1];
-              s0  = vis_faligndata(s00, s01);
-              s1  = vis_faligndata(s10, s11);
-              s2  = vis_faligndata(s20, s21);
-
-              d00 = vis_fmul8x16au(vis_read_hi(s0), k0);
-              d01 = vis_fmul8x16au(vis_read_lo(s0), k0);
-              d10 = vis_fmul8x16au(vis_read_hi(s1), k1);
-              d11 = vis_fmul8x16au(vis_read_lo(s1), k1);
-              d20 = vis_fmul8x16au(vis_read_hi(s2), k2);
-              d21 = vis_fmul8x16au(vis_read_lo(s2), k2);
-
-              d00 = vis_fpadd16(d00, d10);
-              d0  = vis_fpadd16(d20, d0);
-              d0  = vis_fpadd16(d00, d0);
-              d01 = vis_fpadd16(d01, d11);
-              d1  = vis_fpadd16(d21, d1);
-              d1  = vis_fpadd16(d01, d1);
-              buffd[2*i] = d0;
-              buffd[2*i + 1] = d1;
-            }
-          }
-        }
-
-        pk += 3*m;
-
-      } else { /* jk_size == 4 */
-
-        for (ik = 0; ik < m; ik++, coff += NCHAN) {
-          if (!jk && ik == ik_last) continue;
-
-          k0 = pk[ik];
-          k1 = pk[ik + m];
-          k2 = pk[ik + 2*m];
-          k3 = pk[ik + 3*m];
-
-          doff  = coff/8;
-          buff0 = buff[jk    ] + doff;
-          buff1 = buff[jk + 1] + doff;
-          buff2 = buff[jk + 2] + doff;
-          buff3 = buff[jk + 3] + doff;
-
-          off = coff & 7;
-          vis_write_gsr(gsr_scale + off);
-
-          if (off == 0) {
-
-#pragma pipeloop(0)
-            for (i = 0; i < (xsize + 7)/8; i++) {
-              d0 = buffd[2*i];
-              d1 = buffd[2*i + 1];
-
-              s0 = buff0[i];
-              s1 = buff1[i];
-              s2 = buff2[i];
-              s3 = buff3[i];
-
-              d00 = vis_fmul8x16au(vis_read_hi(s0), k0);
-              d01 = vis_fmul8x16au(vis_read_lo(s0), k0);
-              d10 = vis_fmul8x16au(vis_read_hi(s1), k1);
-              d11 = vis_fmul8x16au(vis_read_lo(s1), k1);
-              d20 = vis_fmul8x16au(vis_read_hi(s2), k2);
-              d21 = vis_fmul8x16au(vis_read_lo(s2), k2);
-              d30 = vis_fmul8x16au(vis_read_hi(s3), k3);
-              d31 = vis_fmul8x16au(vis_read_lo(s3), k3);
-
-              d00 = vis_fpadd16(d00, d10);
-              d20 = vis_fpadd16(d20, d30);
-              d0  = vis_fpadd16(d0,  d00);
-              d0  = vis_fpadd16(d0,  d20);
-              d01 = vis_fpadd16(d01, d11);
-              d21 = vis_fpadd16(d21, d31);
-              d1  = vis_fpadd16(d1,  d01);
-              d1  = vis_fpadd16(d1,  d21);
-              buffd[2*i] = d0;
-              buffd[2*i + 1] = d1;
-            }
-
-          } else if (off == 4) {
-
-            s01 = buff0[0];
-            s11 = buff1[0];
-            s21 = buff2[0];
-            s31 = buff3[0];
-#pragma pipeloop(0)
-            for (i = 0; i < (xsize + 7)/8; i++) {
-              d0 = buffd[2*i];
-              d1 = buffd[2*i + 1];
-
-              s00 = s01;
-              s10 = s11;
-              s20 = s21;
-              s30 = s31;
-              s01 = buff0[i + 1];
-              s11 = buff1[i + 1];
-              s21 = buff2[i + 1];
-              s31 = buff3[i + 1];
-
-              d00 = vis_fmul8x16au(vis_read_lo(s00), k0);
-              d01 = vis_fmul8x16au(vis_read_hi(s01), k0);
-              d10 = vis_fmul8x16au(vis_read_lo(s10), k1);
-              d11 = vis_fmul8x16au(vis_read_hi(s11), k1);
-              d20 = vis_fmul8x16au(vis_read_lo(s20), k2);
-              d21 = vis_fmul8x16au(vis_read_hi(s21), k2);
-              d30 = vis_fmul8x16au(vis_read_lo(s30), k3);
-              d31 = vis_fmul8x16au(vis_read_hi(s31), k3);
-
-              d00 = vis_fpadd16(d00, d10);
-              d20 = vis_fpadd16(d20, d30);
-              d0  = vis_fpadd16(d0,  d00);
-              d0  = vis_fpadd16(d0,  d20);
-              d01 = vis_fpadd16(d01, d11);
-              d21 = vis_fpadd16(d21, d31);
-              d1  = vis_fpadd16(d1,  d01);
-              d1  = vis_fpadd16(d1,  d21);
-              buffd[2*i] = d0;
-              buffd[2*i + 1] = d1;
-            }
-
-          } else {
-
-            s01 = buff0[0];
-            s11 = buff1[0];
-            s21 = buff2[0];
-            s31 = buff3[0];
-#pragma pipeloop(0)
-            for (i = 0; i < (xsize + 7)/8; i++) {
-              d0 = buffd[2*i];
-              d1 = buffd[2*i + 1];
-
-              s00 = s01;
-              s10 = s11;
-              s20 = s21;
-              s30 = s31;
-              s01 = buff0[i + 1];
-              s11 = buff1[i + 1];
-              s21 = buff2[i + 1];
-              s31 = buff3[i + 1];
-              s0  = vis_faligndata(s00, s01);
-              s1  = vis_faligndata(s10, s11);
-              s2  = vis_faligndata(s20, s21);
-              s3  = vis_faligndata(s30, s31);
-
-              d00 = vis_fmul8x16au(vis_read_hi(s0), k0);
-              d01 = vis_fmul8x16au(vis_read_lo(s0), k0);
-              d10 = vis_fmul8x16au(vis_read_hi(s1), k1);
-              d11 = vis_fmul8x16au(vis_read_lo(s1), k1);
-              d20 = vis_fmul8x16au(vis_read_hi(s2), k2);
-              d21 = vis_fmul8x16au(vis_read_lo(s2), k2);
-              d30 = vis_fmul8x16au(vis_read_hi(s3), k3);
-              d31 = vis_fmul8x16au(vis_read_lo(s3), k3);
-
-              d00 = vis_fpadd16(d00, d10);
-              d20 = vis_fpadd16(d20, d30);
-              d0  = vis_fpadd16(d0,  d00);
-              d0  = vis_fpadd16(d0,  d20);
-              d01 = vis_fpadd16(d01, d11);
-              d21 = vis_fpadd16(d21, d31);
-              d1  = vis_fpadd16(d1,  d01);
-              d1  = vis_fpadd16(d1,  d21);
-              buffd[2*i] = d0;
-              buffd[2*i + 1] = d1;
-            }
-          }
-        }
-
-        pk += 4*m;
-      }
-    }
-
-    /*****************************************
-     *****************************************
-     **          Final iteration            **
-     *****************************************
-     *****************************************/
-
-    jk_size = n;
-#ifdef CONV_INDEX
-    if (jk_size >= 5) jk_size = 3;
-    if (jk_size == 4) jk_size = 2;
-#else
-    if (jk_size >= 6) jk_size = 4;
-    if (jk_size == 5) jk_size = 3;
-#endif
-
-    k0 = karr[ik_last];
-    k1 = karr[ik_last + m];
-    k2 = karr[ik_last + 2*m];
-    k3 = karr[ik_last + 3*m];
-
-    off  = ik_last*NCHAN;
-    doff = off/8;
-    off &= 7;
-    buff0 = buff[0] + doff;
-    buff1 = buff[1] + doff;
-    buff2 = buff[2] + doff;
-    buff3 = buff[3] + doff;
-    vis_write_gsr(gsr_scale + off);
-
-#ifndef CONV_INDEX
-    if (jk_size == 2) {
-      dp = ((mlib_addr)dl & 7) ? buffe : (mlib_d64*)dl;
-
-      s01 = buff0[0];
-      s11 = buff1[0];
-#pragma pipeloop(0)
-      for (i = 0; i < xsize/8; i++) {
-        s00 = s01;
-        s10 = s11;
-        s01 = buff0[i + 1];
-        s11 = buff1[i + 1];
-        s0  = vis_faligndata(s00, s01);
-        s1  = vis_faligndata(s10, s11);
-
-        d00 = vis_fmul8x16au(vis_read_hi(s0), k0);
-        d01 = vis_fmul8x16au(vis_read_lo(s0), k0);
-        d10 = vis_fmul8x16au(vis_read_hi(s1), k1);
-        d11 = vis_fmul8x16au(vis_read_lo(s1), k1);
-
-        d0 = buffd[2*i];
-        d1 = buffd[2*i + 1];
-        d0 = vis_fpadd16(d0, d00);
-        d0 = vis_fpadd16(d0, d10);
-        d1 = vis_fpadd16(d1, d01);
-        d1 = vis_fpadd16(d1, d11);
-
-        dd = vis_fpack16_pair(d0, d1);
-        dp[i] = dd;
-
-        buffd[2*i    ] = drnd;
-        buffd[2*i + 1] = drnd;
-      }
-
-      if (emask) {
-        s00 = s01;
-        s10 = s11;
-        s01 = buff0[i + 1];
-        s11 = buff1[i + 1];
-        s0  = vis_faligndata(s00, s01);
-        s1  = vis_faligndata(s10, s11);
-
-        d00 = vis_fmul8x16au(vis_read_hi(s0), k0);
-        d01 = vis_fmul8x16au(vis_read_lo(s0), k0);
-        d10 = vis_fmul8x16au(vis_read_hi(s1), k1);
-        d11 = vis_fmul8x16au(vis_read_lo(s1), k1);
-
-        d0 = buffd[2*i];
-        d1 = buffd[2*i + 1];
-        d0 = vis_fpadd16(d0, d00);
-        d0 = vis_fpadd16(d0, d10);
-        d1 = vis_fpadd16(d1, d01);
-        d1 = vis_fpadd16(d1, d11);
-
-        dd = vis_fpack16_pair(d0, d1);
-        vis_pst_8(dd, dp + i, emask);
-
-        buffd[2*i    ] = drnd;
-        buffd[2*i + 1] = drnd;
-      }
-
-      if ((mlib_u8*)dp != dl) mlib_ImageCopy_na((void*)buffe, dl, xsize);
-
-    } else if (jk_size == 3) {
-
-      dp = ((mlib_addr)dl & 7) ? buffe : (mlib_d64*)dl;
-
-      s01 = buff0[0];
-      s11 = buff1[0];
-      s21 = buff2[0];
-#pragma pipeloop(0)
-      for (i = 0; i < xsize/8; i++) {
-        s00 = s01;
-        s10 = s11;
-        s20 = s21;
-        s01 = buff0[i + 1];
-        s11 = buff1[i + 1];
-        s21 = buff2[i + 1];
-        s0  = vis_faligndata(s00, s01);
-        s1  = vis_faligndata(s10, s11);
-        s2  = vis_faligndata(s20, s21);
-
-        d00 = vis_fmul8x16au(vis_read_hi(s0), k0);
-        d01 = vis_fmul8x16au(vis_read_lo(s0), k0);
-        d10 = vis_fmul8x16au(vis_read_hi(s1), k1);
-        d11 = vis_fmul8x16au(vis_read_lo(s1), k1);
-        d20 = vis_fmul8x16au(vis_read_hi(s2), k2);
-        d21 = vis_fmul8x16au(vis_read_lo(s2), k2);
-
-        d0 = buffd[2*i];
-        d1 = buffd[2*i + 1];
-        d0 = vis_fpadd16(d0, d00);
-        d0 = vis_fpadd16(d0, d10);
-        d0 = vis_fpadd16(d0, d20);
-        d1 = vis_fpadd16(d1, d01);
-        d1 = vis_fpadd16(d1, d11);
-        d1 = vis_fpadd16(d1, d21);
-
-        dd = vis_fpack16_pair(d0, d1);
-        dp[i] = dd;
-
-        buffd[2*i    ] = drnd;
-        buffd[2*i + 1] = drnd;
-      }
-
-      if (emask) {
-        s00 = s01;
-        s10 = s11;
-        s20 = s21;
-        s01 = buff0[i + 1];
-        s11 = buff1[i + 1];
-        s21 = buff2[i + 1];
-        s0  = vis_faligndata(s00, s01);
-        s1  = vis_faligndata(s10, s11);
-        s2  = vis_faligndata(s20, s21);
-
-        d00 = vis_fmul8x16au(vis_read_hi(s0), k0);
-        d01 = vis_fmul8x16au(vis_read_lo(s0), k0);
-        d10 = vis_fmul8x16au(vis_read_hi(s1), k1);
-        d11 = vis_fmul8x16au(vis_read_lo(s1), k1);
-        d20 = vis_fmul8x16au(vis_read_hi(s2), k2);
-        d21 = vis_fmul8x16au(vis_read_lo(s2), k2);
-
-        d0 = buffd[2*i];
-        d1 = buffd[2*i + 1];
-        d0 = vis_fpadd16(d0, d00);
-        d0 = vis_fpadd16(d0, d10);
-        d0 = vis_fpadd16(d0, d20);
-        d1 = vis_fpadd16(d1, d01);
-        d1 = vis_fpadd16(d1, d11);
-        d1 = vis_fpadd16(d1, d21);
-
-        dd = vis_fpack16_pair(d0, d1);
-        vis_pst_8(dd, dp + i, emask);
-
-        buffd[2*i    ] = drnd;
-        buffd[2*i + 1] = drnd;
-      }
-
-      if ((mlib_u8*)dp != dl) mlib_ImageCopy_na((void*)buffe, dl, xsize);
-
-    } else /* if (jk_size == 4) */ {
-
-      dp = ((mlib_addr)dl & 7) ? buffe : (mlib_d64*)dl;
-
-      s01 = buff0[0];
-      s11 = buff1[0];
-      s21 = buff2[0];
-      s31 = buff3[0];
-#pragma pipeloop(0)
-      for (i = 0; i < xsize/8; i++) {
-        s00 = s01;
-        s10 = s11;
-        s20 = s21;
-        s30 = s31;
-        s01 = buff0[i + 1];
-        s11 = buff1[i + 1];
-        s21 = buff2[i + 1];
-        s31 = buff3[i + 1];
-        s0  = vis_faligndata(s00, s01);
-        s1  = vis_faligndata(s10, s11);
-        s2  = vis_faligndata(s20, s21);
-        s3  = vis_faligndata(s30, s31);
-
-        d00 = vis_fmul8x16au(vis_read_hi(s0), k0);
-        d01 = vis_fmul8x16au(vis_read_lo(s0), k0);
-        d10 = vis_fmul8x16au(vis_read_hi(s1), k1);
-        d11 = vis_fmul8x16au(vis_read_lo(s1), k1);
-        d20 = vis_fmul8x16au(vis_read_hi(s2), k2);
-        d21 = vis_fmul8x16au(vis_read_lo(s2), k2);
-        d30 = vis_fmul8x16au(vis_read_hi(s3), k3);
-        d31 = vis_fmul8x16au(vis_read_lo(s3), k3);
-
-        d0 = buffd[2*i];
-        d1 = buffd[2*i + 1];
-        d0 = vis_fpadd16(d0, d00);
-        d0 = vis_fpadd16(d0, d10);
-        d0 = vis_fpadd16(d0, d20);
-        d0 = vis_fpadd16(d0, d30);
-        d1 = vis_fpadd16(d1, d01);
-        d1 = vis_fpadd16(d1, d11);
-        d1 = vis_fpadd16(d1, d21);
-        d1 = vis_fpadd16(d1, d31);
-
-        dd = vis_fpack16_pair(d0, d1);
-        dp[i] = dd;
-
-        buffd[2*i    ] = drnd;
-        buffd[2*i + 1] = drnd;
-      }
-
-      if (emask) {
-        s00 = s01;
-        s10 = s11;
-        s20 = s21;
-        s30 = s31;
-        s01 = buff0[i + 1];
-        s11 = buff1[i + 1];
-        s21 = buff2[i + 1];
-        s31 = buff3[i + 1];
-        s0  = vis_faligndata(s00, s01);
-        s1  = vis_faligndata(s10, s11);
-        s2  = vis_faligndata(s20, s21);
-        s3  = vis_faligndata(s30, s31);
-
-        d00 = vis_fmul8x16au(vis_read_hi(s0), k0);
-        d01 = vis_fmul8x16au(vis_read_lo(s0), k0);
-        d10 = vis_fmul8x16au(vis_read_hi(s1), k1);
-        d11 = vis_fmul8x16au(vis_read_lo(s1), k1);
-        d20 = vis_fmul8x16au(vis_read_hi(s2), k2);
-        d21 = vis_fmul8x16au(vis_read_lo(s2), k2);
-        d30 = vis_fmul8x16au(vis_read_hi(s3), k3);
-        d31 = vis_fmul8x16au(vis_read_lo(s3), k3);
-
-        d0 = buffd[2*i];
-        d1 = buffd[2*i + 1];
-        d0 = vis_fpadd16(d0, d00);
-        d0 = vis_fpadd16(d0, d10);
-        d0 = vis_fpadd16(d0, d20);
-        d0 = vis_fpadd16(d0, d30);
-        d1 = vis_fpadd16(d1, d01);
-        d1 = vis_fpadd16(d1, d11);
-        d1 = vis_fpadd16(d1, d21);
-        d1 = vis_fpadd16(d1, d31);
-
-        dd = vis_fpack16_pair(d0, d1);
-        vis_pst_8(dd, dp + i, emask);
-
-        buffd[2*i    ] = drnd;
-        buffd[2*i + 1] = drnd;
-      }
-
-      if ((mlib_u8*)dp != dl) mlib_ImageCopy_na((void*)buffe, dl, xsize);
-    }
-
-#else /* CONV_INDEX */
-
-    if (jk_size == 2) {
-      vis_write_gsr(gsr_scale + 7);
-
-#pragma pipeloop(0)
-      for (i = 0; i < dsize; i += 3) {
-        mlib_d64 d00, d01, d02, d03, d04, d05;
-        mlib_d64 d10, d11, d12, d13, d14, d15;
-        mlib_d64 d0, d1, d2, d3, d4, d5;
-        mlib_d64 s00 = buff0[i];
-        mlib_d64 s01 = buff0[i + 1];
-        mlib_d64 s02 = buff0[i + 2];
-        mlib_d64 s10 = buff1[i];
-        mlib_d64 s11 = buff1[i + 1];
-        mlib_d64 s12 = buff1[i + 2];
-
-        d00 = vis_fmul8x16au(vis_read_hi(s00), k0);
-        d01 = vis_fmul8x16au(vis_read_lo(s00), k0);
-        d02 = vis_fmul8x16au(vis_read_hi(s01), k0);
-        d03 = vis_fmul8x16au(vis_read_lo(s01), k0);
-        d04 = vis_fmul8x16au(vis_read_hi(s02), k0);
-        d05 = vis_fmul8x16au(vis_read_lo(s02), k0);
-        d10 = vis_fmul8x16au(vis_read_hi(s10), k1);
-        d11 = vis_fmul8x16au(vis_read_lo(s10), k1);
-        d12 = vis_fmul8x16au(vis_read_hi(s11), k1);
-        d13 = vis_fmul8x16au(vis_read_lo(s11), k1);
-        d14 = vis_fmul8x16au(vis_read_hi(s12), k1);
-        d15 = vis_fmul8x16au(vis_read_lo(s12), k1);
-
-        d0 = buffd[2*i];
-        d1 = buffd[2*i + 1];
-        d2 = buffd[2*i + 2];
-        d3 = buffd[2*i + 3];
-        d4 = buffd[2*i + 4];
-        d5 = buffd[2*i + 5];
-        d0 = vis_fpadd16(d0, d00);
-        d0 = vis_fpadd16(d0, d10);
-        d1 = vis_fpadd16(d1, d01);
-        d1 = vis_fpadd16(d1, d11);
-        d2 = vis_fpadd16(d2, d02);
-        d2 = vis_fpadd16(d2, d12);
-        d3 = vis_fpadd16(d3, d03);
-        d3 = vis_fpadd16(d3, d13);
-        d4 = vis_fpadd16(d4, d04);
-        d4 = vis_fpadd16(d4, d14);
-        d5 = vis_fpadd16(d5, d05);
-        d5 = vis_fpadd16(d5, d15);
-
-        buffe[i    ] = vis_fpack16_pair(d0, d1);
-        buffe[i + 1] = vis_fpack16_pair(d2, d3);
-        buffe[i + 2] = vis_fpack16_pair(d4, d5);
-
-        buffd[2*i    ] = drnd;
-        buffd[2*i + 1] = drnd;
-        buffd[2*i + 2] = drnd;
-        buffd[2*i + 3] = drnd;
-        buffd[2*i + 4] = drnd;
-        buffd[2*i + 5] = drnd;
-
-        LOAD_SRC();
-      }
-
-    } else /* if (jk_size == 3) */ {
-      vis_write_gsr(gsr_scale + 7);
-
-#pragma pipeloop(0)
-      for (i = 0; i < dsize; i += 3) {
-        mlib_d64 d00, d01, d02, d03, d04, d05;
-        mlib_d64 d10, d11, d12, d13, d14, d15;
-        mlib_d64 d20, d21, d22, d23, d24, d25;
-        mlib_d64 d0, d1, d2, d3, d4, d5;
-        mlib_d64 s00 = buff0[i];
-        mlib_d64 s01 = buff0[i + 1];
-        mlib_d64 s02 = buff0[i + 2];
-        mlib_d64 s10 = buff1[i];
-        mlib_d64 s11 = buff1[i + 1];
-        mlib_d64 s12 = buff1[i + 2];
-        mlib_d64 s20 = buff2[i];
-        mlib_d64 s21 = buff2[i + 1];
-        mlib_d64 s22 = buff2[i + 2];
-
-        d00 = vis_fmul8x16au(vis_read_hi(s00), k0);
-        d01 = vis_fmul8x16au(vis_read_lo(s00), k0);
-        d02 = vis_fmul8x16au(vis_read_hi(s01), k0);
-        d03 = vis_fmul8x16au(vis_read_lo(s01), k0);
-        d04 = vis_fmul8x16au(vis_read_hi(s02), k0);
-        d05 = vis_fmul8x16au(vis_read_lo(s02), k0);
-        d10 = vis_fmul8x16au(vis_read_hi(s10), k1);
-        d11 = vis_fmul8x16au(vis_read_lo(s10), k1);
-        d12 = vis_fmul8x16au(vis_read_hi(s11), k1);
-        d13 = vis_fmul8x16au(vis_read_lo(s11), k1);
-        d14 = vis_fmul8x16au(vis_read_hi(s12), k1);
-        d15 = vis_fmul8x16au(vis_read_lo(s12), k1);
-        d20 = vis_fmul8x16au(vis_read_hi(s20), k2);
-        d21 = vis_fmul8x16au(vis_read_lo(s20), k2);
-        d22 = vis_fmul8x16au(vis_read_hi(s21), k2);
-        d23 = vis_fmul8x16au(vis_read_lo(s21), k2);
-        d24 = vis_fmul8x16au(vis_read_hi(s22), k2);
-        d25 = vis_fmul8x16au(vis_read_lo(s22), k2);
-
-        d0 = buffd[2*i];
-        d1 = buffd[2*i + 1];
-        d2 = buffd[2*i + 2];
-        d3 = buffd[2*i + 3];
-        d4 = buffd[2*i + 4];
-        d5 = buffd[2*i + 5];
-        d0 = vis_fpadd16(d0, d00);
-        d0 = vis_fpadd16(d0, d10);
-        d0 = vis_fpadd16(d0, d20);
-        d1 = vis_fpadd16(d1, d01);
-        d1 = vis_fpadd16(d1, d11);
-        d1 = vis_fpadd16(d1, d21);
-        d2 = vis_fpadd16(d2, d02);
-        d2 = vis_fpadd16(d2, d12);
-        d2 = vis_fpadd16(d2, d22);
-        d3 = vis_fpadd16(d3, d03);
-        d3 = vis_fpadd16(d3, d13);
-        d3 = vis_fpadd16(d3, d23);
-        d4 = vis_fpadd16(d4, d04);
-        d4 = vis_fpadd16(d4, d14);
-        d4 = vis_fpadd16(d4, d24);
-        d5 = vis_fpadd16(d5, d05);
-        d5 = vis_fpadd16(d5, d15);
-        d5 = vis_fpadd16(d5, d25);
-
-        buffe[i    ] = vis_fpack16_pair(d0, d1);
-        buffe[i + 1] = vis_fpack16_pair(d2, d3);
-        buffe[i + 2] = vis_fpack16_pair(d4, d5);
-
-        buffd[2*i    ] = drnd;
-        buffd[2*i + 1] = drnd;
-        buffd[2*i + 2] = drnd;
-        buffd[2*i + 3] = drnd;
-        buffd[2*i + 4] = drnd;
-        buffd[2*i + 5] = drnd;
-
-        LOAD_SRC();
-      }
-    }
-#endif /* CONV_INDEX */
-
-#ifdef CONV_INDEX
-    mlib_ImageColorTrue2IndexLine_U8_U8_3((void*)buffe, dl, wid, colormap);
-#endif /* CONV_INDEX */
-
-    sl += sll;
-    dl += dll;
-
-    buff_ind++;
-    if (buff_ind >= (n + 1)) buff_ind = 0;
-  }
-
-  mlib_free(pbuff);
-  if (buffs != buffs_local) mlib_free(buffs);
-
-  return MLIB_SUCCESS;
-}
-
-/***************************************************************/
--- a/jdk/src/java.desktop/unix/native/libmlib_image/mlib_v_ImageConv_8nw.c	Thu May 19 17:48:02 2016 +0000
+++ b/jdk/src/java.desktop/unix/native/libmlib_image/mlib_v_ImageConv_8nw.c	Thu May 19 19:46:20 2016 +0000
@@ -34,58 +34,16 @@
 #include "vis_proto.h"
 #include "mlib_image.h"
 #include "mlib_ImageCheck.h"
-#include "mlib_ImageColormap.h"
 #include "mlib_ImageCopy.h"
 #include "mlib_ImageConv.h"
 #include "mlib_v_ImageConv.h"
 
-/*
-  This defines switches between functions in
-  files: mlib_v_ImageConvIndex3_8_8nw.c,
-         mlib_v_ImageConvIndex4_8_8nw.c,
-         mlib_v_ImageConvIndex3_8_16nw.c,
-         mlib_v_ImageConvIndex4_8_16nw.c
-*/
-
-/*#define CONV_INDEX*/
-
 /***************************************************************/
 #define DTYPE mlib_u8
-#define LTYPE mlib_u8
 
 /***************************************************************/
-#ifdef CONV_INDEX
-
-#define CONV_FUNC(KERN)                                         \
-  mlib_conv##KERN##_Index3_8_8nw(mlib_image       *dst,         \
-                                 const mlib_image *src,         \
-                                 const mlib_s32   *kern,        \
-                                 mlib_s32         scale,        \
-                                 const void       *colormap)
-
-#else
-
-#define CONV_FUNC(KERN)                                         \
-  mlib_conv##KERN##_8nw_f(mlib_image       *dst,                \
-                          const mlib_image *src,                \
-                          const mlib_s32   *kern,               \
-                          mlib_s32         scale)
-
-#endif /* CONV_INDEX */
-
-#define ColorTrue2IndexLine mlib_ImageColorTrue2IndexLine_U8_U8_3
-
-/***************************************************************/
-#ifdef CONV_INDEX
-
-#define NCHAN  3
-
-#else
-
 #define NCHAN  nchan
 
-#endif /* CONV_INDEX */
-
 /***************************************************************/
 #define DEF_VARS                                                \
   DTYPE    *sl, *sp, *dl;                                       \
@@ -103,104 +61,9 @@
   mlib_s32 i, j, l
 
 /***************************************************************/
-#ifdef CONV_INDEX
-
-#define DEF_EXTRA_VARS                                          \
-  mlib_s32 offset = mlib_ImageGetLutOffset(colormap);           \
-  LTYPE  **lut_table = (LTYPE**)mlib_ImageGetLutData(colormap); \
-  LTYPE  *ltbl0 = lut_table[0] - offset;                        \
-  LTYPE  *ltbl1 = lut_table[1] - offset;                        \
-  LTYPE  *ltbl2 = lut_table[2] - offset;                        \
-  LTYPE  *ltbl3 = (NCHAN > 3) ? lut_table[3] - offset : ltbl2
-
-#else
-
 #define DEF_EXTRA_VARS                                          \
   mlib_s32 nchan = mlib_ImageGetChannels(dst)
 
-#endif /* CONV_INDEX */
-
-/***************************************************************/
-#if NCHAN == 3
-
-#define LOAD_SRC() {                                            \
-    mlib_s32 s0 = sp[0], s1 = sp[1], s2 = sp[2], s3 = sp[3];    \
-    mlib_s32 s4 = sp[4], s5 = sp[5], s6 = sp[6], s7 = sp[7];    \
-    mlib_d64 t0, t1, t2;                                        \
-                                                                \
-    t2 = vis_faligndata(vis_ld_u8_i(ltbl2, s7), t2);            \
-    t2 = vis_faligndata(vis_ld_u8_i(ltbl1, s7), t2);            \
-    t2 = vis_faligndata(vis_ld_u8_i(ltbl0, s7), t2);            \
-    t2 = vis_faligndata(vis_ld_u8_i(ltbl2, s6), t2);            \
-    t2 = vis_faligndata(vis_ld_u8_i(ltbl1, s6), t2);            \
-    t2 = vis_faligndata(vis_ld_u8_i(ltbl0, s6), t2);            \
-    t2 = vis_faligndata(vis_ld_u8_i(ltbl2, s5), t2);            \
-    t2 = vis_faligndata(vis_ld_u8_i(ltbl1, s5), t2);            \
-    t1 = vis_faligndata(vis_ld_u8_i(ltbl0, s5), t1);            \
-    t1 = vis_faligndata(vis_ld_u8_i(ltbl2, s4), t1);            \
-    t1 = vis_faligndata(vis_ld_u8_i(ltbl1, s4), t1);            \
-    t1 = vis_faligndata(vis_ld_u8_i(ltbl0, s4), t1);            \
-    t1 = vis_faligndata(vis_ld_u8_i(ltbl2, s3), t1);            \
-    t1 = vis_faligndata(vis_ld_u8_i(ltbl1, s3), t1);            \
-    t1 = vis_faligndata(vis_ld_u8_i(ltbl0, s3), t1);            \
-    t1 = vis_faligndata(vis_ld_u8_i(ltbl2, s2), t1);            \
-    t0 = vis_faligndata(vis_ld_u8_i(ltbl1, s2), t0);            \
-    t0 = vis_faligndata(vis_ld_u8_i(ltbl0, s2), t0);            \
-    t0 = vis_faligndata(vis_ld_u8_i(ltbl2, s1), t0);            \
-    t0 = vis_faligndata(vis_ld_u8_i(ltbl1, s1), t0);            \
-    t0 = vis_faligndata(vis_ld_u8_i(ltbl0, s1), t0);            \
-    t0 = vis_faligndata(vis_ld_u8_i(ltbl2, s0), t0);            \
-    t0 = vis_faligndata(vis_ld_u8_i(ltbl1, s0), t0);            \
-    t0 = vis_faligndata(vis_ld_u8_i(ltbl0, s0), t0);            \
-                                                                \
-    buffn[i] = t0;                                              \
-    buffn[i + 1] = t1;                                          \
-    buffn[i + 2] = t2;                                          \
-                                                                \
-    sp += 8;                                                    \
-  }
-
-#else
-
-#define LOAD_SRC() {                                            \
-    mlib_s32 s0 = sp[0], s1 = sp[1], s2 = sp[2], s3 = sp[3];    \
-    mlib_s32 s4 = sp[4], s5 = sp[5], s6 = sp[6], s7 = sp[7];    \
-    mlib_d64 t0, t1, t2;                                        \
-                                                                \
-    t2 = vis_faligndata(vis_ld_u8_i(ltbl3, s5), t2);            \
-    t2 = vis_faligndata(vis_ld_u8_i(ltbl2, s5), t2);            \
-    t2 = vis_faligndata(vis_ld_u8_i(ltbl1, s5), t2);            \
-    t2 = vis_faligndata(vis_ld_u8_i(ltbl0, s5), t2);            \
-    t2 = vis_faligndata(vis_ld_u8_i(ltbl3, s4), t2);            \
-    t2 = vis_faligndata(vis_ld_u8_i(ltbl2, s4), t2);            \
-    t2 = vis_faligndata(vis_ld_u8_i(ltbl1, s4), t2);            \
-    t2 = vis_faligndata(vis_ld_u8_i(ltbl0, s4), t2);            \
-    t1 = vis_faligndata(vis_ld_u8_i(ltbl3, s3), t1);            \
-    t1 = vis_faligndata(vis_ld_u8_i(ltbl2, s3), t1);            \
-    t1 = vis_faligndata(vis_ld_u8_i(ltbl1, s3), t1);            \
-    t1 = vis_faligndata(vis_ld_u8_i(ltbl0, s3), t1);            \
-    t1 = vis_faligndata(vis_ld_u8_i(ltbl3, s2), t1);            \
-    t1 = vis_faligndata(vis_ld_u8_i(ltbl2, s2), t1);            \
-    t1 = vis_faligndata(vis_ld_u8_i(ltbl1, s2), t1);            \
-    t1 = vis_faligndata(vis_ld_u8_i(ltbl0, s2), t1);            \
-    t0 = vis_faligndata(vis_ld_u8_i(ltbl3, s1), t0);            \
-    t0 = vis_faligndata(vis_ld_u8_i(ltbl2, s1), t0);            \
-    t0 = vis_faligndata(vis_ld_u8_i(ltbl1, s1), t0);            \
-    t0 = vis_faligndata(vis_ld_u8_i(ltbl0, s1), t0);            \
-    t0 = vis_faligndata(vis_ld_u8_i(ltbl3, s0), t0);            \
-    t0 = vis_faligndata(vis_ld_u8_i(ltbl2, s0), t0);            \
-    t0 = vis_faligndata(vis_ld_u8_i(ltbl1, s0), t0);            \
-    t0 = vis_faligndata(vis_ld_u8_i(ltbl0, s0), t0);            \
-                                                                \
-    buffn[i] = t0;                                              \
-    buffn[i + 1] = t1;                                          \
-    buffn[i + 2] = t2;                                          \
-                                                                \
-    sp += 6;                                                    \
-  }
-
-#endif /* NCHAN == 3 */
-
 /***************************************************************/
 static const mlib_s32 mlib_round_8[16] = {
   0x00400040, 0x00200020, 0x00100010, 0x00080008,
@@ -210,651 +73,8 @@
 };
 
 /***************************************************************/
-#define KSIZE  2
-
-mlib_status CONV_FUNC(2x2)
-{
-  mlib_d64 *buffs[2 * (KSIZE + 1)];
-  mlib_d64 *buff0, *buff1, *buffn, *buffd, *buffe;
-  mlib_d64 s00, s01, s10, s11, s0, s1;
-  mlib_d64 d0, d1, d00, d01, d10, d11;
-  DEF_VARS;
-  DEF_EXTRA_VARS;
-
-  sl = adr_src;
-  dl = adr_dst;
-
-  ssize = NCHAN * wid;
-  dsize = (ssize + 7) / 8;
-  esize = dsize + 4;
-  pbuff = mlib_malloc((KSIZE + 4) * esize * sizeof(mlib_d64));
-
-  if (pbuff == NULL)
-    return MLIB_FAILURE;
-
-  for (i = 0; i < (KSIZE + 1); i++)
-    buffs[i] = pbuff + i * esize;
-  for (i = 0; i < (KSIZE + 1); i++)
-    buffs[(KSIZE + 1) + i] = buffs[i];
-  buffd = buffs[KSIZE] + esize;
-  buffe = buffd + 2 * esize;
-
-  wid -= (KSIZE - 1);
-  hgt -= (KSIZE - 1);
-  xsize = ssize - NCHAN * (KSIZE - 1);
-  emask = (0xFF00 >> (xsize & 7)) & 0xFF;
-
-  vis_write_gsr(gsr_scale + 7);
-
-  for (l = 0; l < KSIZE; l++) {
-    mlib_d64 *buffn = buffs[l];
-    sp = sl + l * sll;
-
-#ifndef CONV_INDEX
-
-    if ((mlib_addr) sp & 7)
-      mlib_ImageCopy_na((void *)sp, (void *)buffn, ssize);
-
-#else
-#pragma pipeloop(0)
-    for (i = 0; i < dsize; i += 3) {
-      LOAD_SRC();
-    }
-
-#endif /* CONV_INDEX */
-  }
-
-  for (j = 0; j < hgt; j++) {
-    mlib_d64 **buffc = buffs + buff_ind;
-    mlib_f32 *pk = karr, k0, k1;
-    sp = sl + KSIZE * sll;
-
-    buff0 = buffc[0];
-    buff1 = buffc[1];
-    buffn = buffc[KSIZE];
-
-#ifndef CONV_INDEX
-
-    if ((((mlib_addr) (sl)) & 7) == 0)
-      buff0 = (mlib_d64 *) sl;
-
-    if ((((mlib_addr) (sl + sll)) & 7) == 0)
-      buff1 = (mlib_d64 *) (sl + sll);
-
-    if ((mlib_addr) sp & 7)
-      mlib_ImageCopy_na((void *)sp, (void *)buffn, ssize);
-#endif /* CONV_INDEX */
-
-    k0 = pk[1];
-    k1 = pk[3];
-    vis_write_gsr(gsr_scale + NCHAN);
-
-    s01 = buff0[0];
-    s11 = buff1[0];
-#pragma pipeloop(0)
-    for (i = 0; i < (xsize + 7) / 8; i++) {
-      s00 = s01;
-      s10 = s11;
-      s01 = buff0[i + 1];
-      s11 = buff1[i + 1];
-      s0 = vis_faligndata(s00, s01);
-      s1 = vis_faligndata(s10, s11);
-
-      d00 = vis_fmul8x16au(vis_read_hi(s0), k0);
-      d01 = vis_fmul8x16au(vis_read_lo(s0), k0);
-      d10 = vis_fmul8x16au(vis_read_hi(s1), k1);
-      d11 = vis_fmul8x16au(vis_read_lo(s1), k1);
-
-      d0 = vis_fpadd16(d00, d10);
-      d1 = vis_fpadd16(d01, d11);
-      buffd[2 * i] = d0;
-      buffd[2 * i + 1] = d1;
-    }
-
-    k0 = pk[0];
-    k1 = pk[2];
-#ifndef CONV_INDEX
-    dp = ((mlib_addr) dl & 7) ? buffe : (mlib_d64 *) dl;
-
-#pragma pipeloop(0)
-    for (i = 0; i < xsize / 8; i++) {
-      s0 = buff0[i];
-      s1 = buff1[i];
-
-      d00 = vis_fmul8x16au(vis_read_hi(s0), k0);
-      d01 = vis_fmul8x16au(vis_read_lo(s0), k0);
-      d10 = vis_fmul8x16au(vis_read_hi(s1), k1);
-      d11 = vis_fmul8x16au(vis_read_lo(s1), k1);
-
-      d0 = buffd[2 * i];
-      d1 = buffd[2 * i + 1];
-      d00 = vis_fpadd16(d00, d10);
-      d0 = vis_fpadd16(d0, drnd);
-      d0 = vis_fpadd16(d0, d00);
-      d01 = vis_fpadd16(d01, d11);
-      d1 = vis_fpadd16(d1, drnd);
-      d1 = vis_fpadd16(d1, d01);
-      dp[i] = vis_fpack16_pair(d0, d1);
-    }
-
-    if (emask) {
-      s0 = buff0[i];
-      s1 = buff1[i];
-
-      d00 = vis_fmul8x16au(vis_read_hi(s0), k0);
-      d01 = vis_fmul8x16au(vis_read_lo(s0), k0);
-      d10 = vis_fmul8x16au(vis_read_hi(s1), k1);
-      d11 = vis_fmul8x16au(vis_read_lo(s1), k1);
-
-      d0 = buffd[2 * i];
-      d1 = buffd[2 * i + 1];
-      d00 = vis_fpadd16(d00, d10);
-      d0 = vis_fpadd16(d0, drnd);
-      d0 = vis_fpadd16(d0, d00);
-      d01 = vis_fpadd16(d01, d11);
-      d1 = vis_fpadd16(d1, drnd);
-      d1 = vis_fpadd16(d1, d01);
-
-      d0 = vis_fpack16_pair(d0, d1);
-      vis_pst_8(d0, dp + i, emask);
-    }
-
-    if ((mlib_u8 *) dp != dl)
-      mlib_ImageCopy_na((void *)buffe, dl, xsize);
-
-#else
-    vis_write_gsr(gsr_scale + 7);
-
-#pragma pipeloop(0)
-    for (i = 0; i < dsize; i += 3) {
-      mlib_d64 d00, d01, d02, d03, d04, d05;
-      mlib_d64 d10, d11, d12, d13, d14, d15;
-      mlib_d64 d0, d1, d2, d3, d4, d5;
-      mlib_d64 s00 = buff0[i];
-      mlib_d64 s01 = buff0[i + 1];
-      mlib_d64 s02 = buff0[i + 2];
-      mlib_d64 s10 = buff1[i];
-      mlib_d64 s11 = buff1[i + 1];
-      mlib_d64 s12 = buff1[i + 2];
-
-      d00 = vis_fmul8x16au(vis_read_hi(s00), k0);
-      d01 = vis_fmul8x16au(vis_read_lo(s00), k0);
-      d02 = vis_fmul8x16au(vis_read_hi(s01), k0);
-      d03 = vis_fmul8x16au(vis_read_lo(s01), k0);
-      d04 = vis_fmul8x16au(vis_read_hi(s02), k0);
-      d05 = vis_fmul8x16au(vis_read_lo(s02), k0);
-      d10 = vis_fmul8x16au(vis_read_hi(s10), k1);
-      d11 = vis_fmul8x16au(vis_read_lo(s10), k1);
-      d12 = vis_fmul8x16au(vis_read_hi(s11), k1);
-      d13 = vis_fmul8x16au(vis_read_lo(s11), k1);
-      d14 = vis_fmul8x16au(vis_read_hi(s12), k1);
-      d15 = vis_fmul8x16au(vis_read_lo(s12), k1);
-
-      d0 = buffd[2 * i];
-      d1 = buffd[2 * i + 1];
-      d2 = buffd[2 * i + 2];
-      d3 = buffd[2 * i + 3];
-      d4 = buffd[2 * i + 4];
-      d5 = buffd[2 * i + 5];
-      d00 = vis_fpadd16(d00, d10);
-      d0 = vis_fpadd16(d0, drnd);
-      d0 = vis_fpadd16(d0, d00);
-      d01 = vis_fpadd16(d01, d11);
-      d1 = vis_fpadd16(d1, drnd);
-      d1 = vis_fpadd16(d1, d01);
-      d02 = vis_fpadd16(d02, d12);
-      d2 = vis_fpadd16(d2, drnd);
-      d2 = vis_fpadd16(d2, d02);
-      d03 = vis_fpadd16(d03, d13);
-      d3 = vis_fpadd16(d3, drnd);
-      d3 = vis_fpadd16(d3, d03);
-      d04 = vis_fpadd16(d04, d14);
-      d4 = vis_fpadd16(d4, drnd);
-      d4 = vis_fpadd16(d4, d04);
-      d05 = vis_fpadd16(d05, d15);
-      d5 = vis_fpadd16(d5, drnd);
-      d5 = vis_fpadd16(d5, d05);
-
-      buffe[i] = vis_fpack16_pair(d0, d1);
-      buffe[i + 1] = vis_fpack16_pair(d2, d3);
-      buffe[i + 2] = vis_fpack16_pair(d4, d5);
-
-      LOAD_SRC();
-    }
-
-    ColorTrue2IndexLine((void *)buffe, dl, wid, colormap);
-#endif /* CONV_INDEX */
-
-    sl += sll;
-    dl += dll;
-
-    buff_ind++;
-
-    if (buff_ind >= (KSIZE + 1))
-      buff_ind = 0;
-  }
-
-  mlib_free(pbuff);
-
-  return MLIB_SUCCESS;
-}
-
-/***************************************************************/
-#undef  KSIZE
-#define KSIZE  3
-
-mlib_status CONV_FUNC(3x3)
-{
-  mlib_d64 *buffs[2 * (KSIZE + 1)];
-  mlib_d64 *buff0, *buff1, *buff2, *buffn, *buffd, *buffe;
-  mlib_d64 s00, s01, s10, s11, s20, s21, s0, s1, s2;
-  mlib_d64 dd, d0, d1, d00, d01, d10, d11, d20, d21;
-  mlib_s32 ik, ik_last, off, doff;
-  DEF_VARS;
-  DEF_EXTRA_VARS;
-
-  sl = adr_src;
-#ifdef CONV_INDEX
-  dl = adr_dst + ((KSIZE - 1) / 2) * (dll + 1);
-#else
-  dl = adr_dst + ((KSIZE - 1) / 2) * (dll + NCHAN);
-#endif /* CONV_INDEX */
-
-  ssize = NCHAN * wid;
-  dsize = (ssize + 7) / 8;
-  esize = dsize + 4;
-  pbuff = mlib_malloc((KSIZE + 4) * esize * sizeof(mlib_d64));
-
-  if (pbuff == NULL)
-    return MLIB_FAILURE;
-
-  for (i = 0; i < (KSIZE + 1); i++)
-    buffs[i] = pbuff + i * esize;
-  for (i = 0; i < (KSIZE + 1); i++)
-    buffs[(KSIZE + 1) + i] = buffs[i];
-  buffd = buffs[KSIZE] + esize;
-  buffe = buffd + 2 * esize;
-
-  wid -= (KSIZE - 1);
-  hgt -= (KSIZE - 1);
-  xsize = ssize - NCHAN * (KSIZE - 1);
-  emask = (0xFF00 >> (xsize & 7)) & 0xFF;
-
-  vis_write_gsr(gsr_scale + 7);
-
-  for (l = 0; l < KSIZE; l++) {
-    mlib_d64 *buffn = buffs[l];
-    sp = sl + l * sll;
-
-#ifndef CONV_INDEX
-
-    if ((mlib_addr) sp & 7)
-      mlib_ImageCopy_na((void *)sp, (void *)buffn, ssize);
-#else
-#pragma pipeloop(0)
-    for (i = 0; i < dsize; i += 3) {
-      LOAD_SRC();
-    }
-
-#endif /* CONV_INDEX */
-  }
-
-  /* init buffer */
-#pragma pipeloop(0)
-  for (i = 0; i < (xsize + 7) / 8; i++) {
-    buffd[2 * i] = drnd;
-    buffd[2 * i + 1] = drnd;
-  }
-
-  for (j = 0; j < hgt; j++) {
-    mlib_d64 **buffc = buffs + buff_ind, *pbuff0, *pbuff1, *pbuff2;
-    mlib_f32 *pk = karr, k0, k1, k2;
-    sp = sl + KSIZE * sll;
-
-    pbuff0 = buffc[0];
-    pbuff1 = buffc[1];
-    pbuff2 = buffc[2];
-    buffn = buffc[KSIZE];
-
-#ifndef CONV_INDEX
-
-    if ((((mlib_addr) (sl)) & 7) == 0)
-      pbuff0 = (mlib_d64 *) sl;
-
-    if ((((mlib_addr) (sl + sll)) & 7) == 0)
-      pbuff1 = (mlib_d64 *) (sl + sll);
-
-    if ((((mlib_addr) (sl + 2 * sll)) & 7) == 0)
-      pbuff2 = (mlib_d64 *) (sl + 2 * sll);
-
-    if ((mlib_addr) sp & 7)
-      mlib_ImageCopy_na((void *)sp, (void *)buffn, ssize);
-#endif /* CONV_INDEX */
-
-#ifdef CONV_INDEX
-    ik_last = 0;
-#else
-    ik_last = (KSIZE - 1);
-#endif /* CONV_INDEX */
-
-    for (ik = 0; ik < KSIZE; ik++) {
-      k0 = pk[ik];
-      k1 = pk[ik + KSIZE];
-      k2 = pk[ik + 2 * KSIZE];
-
-      off = ik * NCHAN;
-      doff = off / 8;
-      off &= 7;
-      buff0 = pbuff0 + doff;
-      buff1 = pbuff1 + doff;
-      buff2 = pbuff2 + doff;
-      vis_write_gsr(gsr_scale + off);
-
-      if (ik == ik_last)
-        continue;
-      /*if (!ik_last) {
-       * if ((off & 3) || (ik == (KSIZE - 1))) {
-       * ik_last = ik;
-       * continue;
-       * }
-       * } */
-
-      if (off == 0) {
-#pragma pipeloop(0)
-        for (i = 0; i < (xsize + 7) / 8; i++) {
-          s0 = buff0[i];
-          s1 = buff1[i];
-          s2 = buff2[i];
-
-          d00 = vis_fmul8x16au(vis_read_hi(s0), k0);
-          d01 = vis_fmul8x16au(vis_read_lo(s0), k0);
-          d10 = vis_fmul8x16au(vis_read_hi(s1), k1);
-          d11 = vis_fmul8x16au(vis_read_lo(s1), k1);
-          d20 = vis_fmul8x16au(vis_read_hi(s2), k2);
-          d21 = vis_fmul8x16au(vis_read_lo(s2), k2);
-
-          d0 = buffd[2 * i];
-          d1 = buffd[2 * i + 1];
-          d0 = vis_fpadd16(d00, d0);
-          d0 = vis_fpadd16(d10, d0);
-          d0 = vis_fpadd16(d20, d0);
-          d1 = vis_fpadd16(d01, d1);
-          d1 = vis_fpadd16(d11, d1);
-          d1 = vis_fpadd16(d21, d1);
-          buffd[2 * i] = d0;
-          buffd[2 * i + 1] = d1;
-        }
-      }
-      else if (off == 4) {
-        s01 = buff0[0];
-        s11 = buff1[0];
-        s21 = buff2[0];
-#pragma pipeloop(0)
-        for (i = 0; i < (xsize + 7) / 8; i++) {
-          s00 = s01;
-          s10 = s11;
-          s20 = s21;
-          s01 = buff0[i + 1];
-          s11 = buff1[i + 1];
-          s21 = buff2[i + 1];
-
-          d00 = vis_fmul8x16au(vis_read_lo(s00), k0);
-          d01 = vis_fmul8x16au(vis_read_hi(s01), k0);
-          d10 = vis_fmul8x16au(vis_read_lo(s10), k1);
-          d11 = vis_fmul8x16au(vis_read_hi(s11), k1);
-          d20 = vis_fmul8x16au(vis_read_lo(s20), k2);
-          d21 = vis_fmul8x16au(vis_read_hi(s21), k2);
-
-          d0 = buffd[2 * i];
-          d1 = buffd[2 * i + 1];
-          d0 = vis_fpadd16(d00, d0);
-          d0 = vis_fpadd16(d10, d0);
-          d0 = vis_fpadd16(d20, d0);
-          d1 = vis_fpadd16(d01, d1);
-          d1 = vis_fpadd16(d11, d1);
-          d1 = vis_fpadd16(d21, d1);
-          buffd[2 * i] = d0;
-          buffd[2 * i + 1] = d1;
-        }
-      }
-      else {
-        s01 = buff0[0];
-        s11 = buff1[0];
-        s21 = buff2[0];
-#pragma pipeloop(0)
-        for (i = 0; i < (xsize + 7) / 8; i++) {
-          s00 = s01;
-          s10 = s11;
-          s20 = s21;
-          s01 = buff0[i + 1];
-          s11 = buff1[i + 1];
-          s21 = buff2[i + 1];
-          s0 = vis_faligndata(s00, s01);
-          s1 = vis_faligndata(s10, s11);
-          s2 = vis_faligndata(s20, s21);
-
-          d00 = vis_fmul8x16au(vis_read_hi(s0), k0);
-          d01 = vis_fmul8x16au(vis_read_lo(s0), k0);
-          d10 = vis_fmul8x16au(vis_read_hi(s1), k1);
-          d11 = vis_fmul8x16au(vis_read_lo(s1), k1);
-          d20 = vis_fmul8x16au(vis_read_hi(s2), k2);
-          d21 = vis_fmul8x16au(vis_read_lo(s2), k2);
-
-          d0 = buffd[2 * i];
-          d1 = buffd[2 * i + 1];
-          d0 = vis_fpadd16(d00, d0);
-          d0 = vis_fpadd16(d10, d0);
-          d0 = vis_fpadd16(d20, d0);
-          d1 = vis_fpadd16(d01, d1);
-          d1 = vis_fpadd16(d11, d1);
-          d1 = vis_fpadd16(d21, d1);
-          buffd[2 * i] = d0;
-          buffd[2 * i + 1] = d1;
-        }
-      }
-    }
-
-    k0 = pk[ik_last];
-    k1 = pk[ik_last + KSIZE];
-    k2 = pk[ik_last + 2 * KSIZE];
-
-    off = ik_last * NCHAN;
-    doff = off / 8;
-    off &= 7;
-    buff0 = pbuff0 + doff;
-    buff1 = pbuff1 + doff;
-    buff2 = pbuff2 + doff;
-    vis_write_gsr(gsr_scale + off);
-
-#ifndef CONV_INDEX
-    dp = ((mlib_addr) dl & 7) ? buffe : (mlib_d64 *) dl;
-
-    s01 = buff0[0];
-    s11 = buff1[0];
-    s21 = buff2[0];
-#pragma pipeloop(0)
-    for (i = 0; i < xsize / 8; i++) {
-      s00 = s01;
-      s10 = s11;
-      s20 = s21;
-      s01 = buff0[i + 1];
-      s11 = buff1[i + 1];
-      s21 = buff2[i + 1];
-      s0 = vis_faligndata(s00, s01);
-      s1 = vis_faligndata(s10, s11);
-      s2 = vis_faligndata(s20, s21);
-
-      d00 = vis_fmul8x16au(vis_read_hi(s0), k0);
-      d01 = vis_fmul8x16au(vis_read_lo(s0), k0);
-      d10 = vis_fmul8x16au(vis_read_hi(s1), k1);
-      d11 = vis_fmul8x16au(vis_read_lo(s1), k1);
-      d20 = vis_fmul8x16au(vis_read_hi(s2), k2);
-      d21 = vis_fmul8x16au(vis_read_lo(s2), k2);
-
-      d0 = buffd[2 * i];
-      d1 = buffd[2 * i + 1];
-      d0 = vis_fpadd16(d0, d00);
-      d0 = vis_fpadd16(d0, d10);
-      d0 = vis_fpadd16(d0, d20);
-      d1 = vis_fpadd16(d1, d01);
-      d1 = vis_fpadd16(d1, d11);
-      d1 = vis_fpadd16(d1, d21);
-
-      dd = vis_fpack16_pair(d0, d1);
-      dp[i] = dd;
-
-      buffd[2 * i] = drnd;
-      buffd[2 * i + 1] = drnd;
-    }
-
-    if (emask) {
-      s00 = s01;
-      s10 = s11;
-      s20 = s21;
-      s01 = buff0[i + 1];
-      s11 = buff1[i + 1];
-      s21 = buff2[i + 1];
-      s0 = vis_faligndata(s00, s01);
-      s1 = vis_faligndata(s10, s11);
-      s2 = vis_faligndata(s20, s21);
-
-      d00 = vis_fmul8x16au(vis_read_hi(s0), k0);
-      d01 = vis_fmul8x16au(vis_read_lo(s0), k0);
-      d10 = vis_fmul8x16au(vis_read_hi(s1), k1);
-      d11 = vis_fmul8x16au(vis_read_lo(s1), k1);
-      d20 = vis_fmul8x16au(vis_read_hi(s2), k2);
-      d21 = vis_fmul8x16au(vis_read_lo(s2), k2);
-
-      d0 = buffd[2 * i];
-      d1 = buffd[2 * i + 1];
-      d0 = vis_fpadd16(d0, d00);
-      d0 = vis_fpadd16(d0, d10);
-      d0 = vis_fpadd16(d0, d20);
-      d1 = vis_fpadd16(d1, d01);
-      d1 = vis_fpadd16(d1, d11);
-      d1 = vis_fpadd16(d1, d21);
-
-      dd = vis_fpack16_pair(d0, d1);
-      vis_pst_8(dd, dp + i, emask);
-
-      buffd[2 * i] = drnd;
-      buffd[2 * i + 1] = drnd;
-    }
-
-    if ((mlib_u8 *) dp != dl)
-      mlib_ImageCopy_na((void *)buffe, dl, xsize);
-
-#else
-    vis_write_gsr(gsr_scale + 7);
-
-#pragma pipeloop(0)
-    for (i = 0; i < dsize; i += 3) {
-      mlib_d64 d00, d01, d02, d03, d04, d05;
-      mlib_d64 d10, d11, d12, d13, d14, d15;
-      mlib_d64 d20, d21, d22, d23, d24, d25;
-      mlib_d64 d0, d1, d2, d3, d4, d5;
-      mlib_d64 s00 = buff0[i];
-      mlib_d64 s01 = buff0[i + 1];
-      mlib_d64 s02 = buff0[i + 2];
-      mlib_d64 s10 = buff1[i];
-      mlib_d64 s11 = buff1[i + 1];
-      mlib_d64 s12 = buff1[i + 2];
-      mlib_d64 s20 = buff2[i];
-      mlib_d64 s21 = buff2[i + 1];
-      mlib_d64 s22 = buff2[i + 2];
-
-      d00 = vis_fmul8x16au(vis_read_hi(s00), k0);
-      d01 = vis_fmul8x16au(vis_read_lo(s00), k0);
-      d02 = vis_fmul8x16au(vis_read_hi(s01), k0);
-      d03 = vis_fmul8x16au(vis_read_lo(s01), k0);
-      d04 = vis_fmul8x16au(vis_read_hi(s02), k0);
-      d05 = vis_fmul8x16au(vis_read_lo(s02), k0);
-      d10 = vis_fmul8x16au(vis_read_hi(s10), k1);
-      d11 = vis_fmul8x16au(vis_read_lo(s10), k1);
-      d12 = vis_fmul8x16au(vis_read_hi(s11), k1);
-      d13 = vis_fmul8x16au(vis_read_lo(s11), k1);
-      d14 = vis_fmul8x16au(vis_read_hi(s12), k1);
-      d15 = vis_fmul8x16au(vis_read_lo(s12), k1);
-      d20 = vis_fmul8x16au(vis_read_hi(s20), k2);
-      d21 = vis_fmul8x16au(vis_read_lo(s20), k2);
-      d22 = vis_fmul8x16au(vis_read_hi(s21), k2);
-      d23 = vis_fmul8x16au(vis_read_lo(s21), k2);
-      d24 = vis_fmul8x16au(vis_read_hi(s22), k2);
-      d25 = vis_fmul8x16au(vis_read_lo(s22), k2);
-
-      d0 = buffd[2 * i];
-      d1 = buffd[2 * i + 1];
-      d2 = buffd[2 * i + 2];
-      d3 = buffd[2 * i + 3];
-      d4 = buffd[2 * i + 4];
-      d5 = buffd[2 * i + 5];
-      d0 = vis_fpadd16(d0, d00);
-      d0 = vis_fpadd16(d0, d10);
-      d0 = vis_fpadd16(d0, d20);
-      d1 = vis_fpadd16(d1, d01);
-      d1 = vis_fpadd16(d1, d11);
-      d1 = vis_fpadd16(d1, d21);
-      d2 = vis_fpadd16(d2, d02);
-      d2 = vis_fpadd16(d2, d12);
-      d2 = vis_fpadd16(d2, d22);
-      d3 = vis_fpadd16(d3, d03);
-      d3 = vis_fpadd16(d3, d13);
-      d3 = vis_fpadd16(d3, d23);
-      d4 = vis_fpadd16(d4, d04);
-      d4 = vis_fpadd16(d4, d14);
-      d4 = vis_fpadd16(d4, d24);
-      d5 = vis_fpadd16(d5, d05);
-      d5 = vis_fpadd16(d5, d15);
-      d5 = vis_fpadd16(d5, d25);
-
-      buffe[i] = vis_fpack16_pair(d0, d1);
-      buffe[i + 1] = vis_fpack16_pair(d2, d3);
-      buffe[i + 2] = vis_fpack16_pair(d4, d5);
-
-      buffd[2 * i] = drnd;
-      buffd[2 * i + 1] = drnd;
-      buffd[2 * i + 2] = drnd;
-      buffd[2 * i + 3] = drnd;
-      buffd[2 * i + 4] = drnd;
-      buffd[2 * i + 5] = drnd;
-
-      LOAD_SRC();
-    }
-
-    ColorTrue2IndexLine((void *)buffe, dl, wid, colormap);
-#endif /* CONV_INDEX */
-
-    sl += sll;
-    dl += dll;
-
-    buff_ind++;
-
-    if (buff_ind >= (KSIZE + 1))
-      buff_ind = 0;
-  }
-
-  mlib_free(pbuff);
-
-  return MLIB_SUCCESS;
-}
-
-/***************************************************************/
-#undef  KSIZE
 #define MAX_N   11
 
-#ifdef CONV_INDEX
-
-mlib_status mlib_convMxN_Index3_8_8nw(mlib_image       *dst,
-                                      const mlib_image *src,
-                                      mlib_s32         m,
-                                      mlib_s32         n,
-                                      mlib_s32         dm,
-                                      mlib_s32         dn,
-                                      const mlib_s32   *kern,
-                                      mlib_s32         scale,
-                                      const void       *colormap)
-#else
-
 mlib_status mlib_convMxN_8nw_f(mlib_image       *dst,
                                const mlib_image *src,
                                mlib_s32         m,
@@ -863,7 +83,6 @@
                                mlib_s32         dn,
                                const mlib_s32   *kern,
                                mlib_s32         scale)
-#endif /* CONV_INDEX */
 {
   mlib_d64 *buffs_local[3 * (MAX_N + 1)], **buffs = buffs_local, **buff;
   mlib_d64 *buff0, *buff1, *buff2, *buff3, *buffn, *buffd, *buffe;
@@ -884,11 +103,7 @@
   buff = buffs + 2 * (n + 1);
 
   sl = adr_src;
-#ifdef CONV_INDEX
-  dl = adr_dst + dn * dll + dm;
-#else
   dl = adr_dst + dn * dll + dm * NCHAN;
-#endif /* CONV_INDEX */
 
   ssize = NCHAN * wid;
   dsize = (ssize + 7) / 8;
@@ -919,17 +134,8 @@
     mlib_d64 *buffn = buffs[l];
     sp = sl + l * sll;
 
-#ifndef CONV_INDEX
-
     if ((mlib_addr) sp & 7)
       mlib_ImageCopy_na((void *)sp, (void *)buffn, ssize);
-#else
-#pragma pipeloop(0)
-    for (i = 0; i < dsize; i += 3) {
-      LOAD_SRC();
-    }
-
-#endif /* CONV_INDEX */
   }
 
   /* init buffer */
@@ -950,7 +156,6 @@
 
     buffn = buffc[n];
 
-#ifndef CONV_INDEX
     for (l = 0; l < n; l++) {
       if ((((mlib_addr) (sl + l * sll)) & 7) == 0)
         buff[l] = (mlib_d64 *) (sl + l * sll);
@@ -958,31 +163,18 @@
 
     if ((mlib_addr) sp & 7)
       mlib_ImageCopy_na((void *)sp, (void *)buffn, ssize);
-#endif /* CONV_INDEX */
 
-#ifdef CONV_INDEX
-    ik_last = 0;
-#else
     ik_last = (m - 1);
-#endif /* CONV_INDEX */
 
     for (jk = 0; jk < n; jk += jk_size) {
       jk_size = n - jk;
-#ifdef CONV_INDEX
-
-      if (jk_size >= 5)
-        jk_size = 3;
-
-      if (jk_size == 4)
-        jk_size = 2;
-#else
 
       if (jk_size >= 6)
         jk_size = 4;
 
       if (jk_size == 5)
         jk_size = 3;
-#endif /* CONV_INDEX */
+
       coff = 0;
 
       if (jk_size == 1) {
@@ -1335,21 +527,12 @@
      *****************************************/
 
     jk_size = n;
-#ifdef CONV_INDEX
-
-    if (jk_size >= 5)
-      jk_size = 3;
-
-    if (jk_size == 4)
-      jk_size = 2;
-#else
 
     if (jk_size >= 6)
       jk_size = 4;
 
     if (jk_size == 5)
       jk_size = 3;
-#endif /* CONV_INDEX */
 
     k0 = karr[ik_last];
     k1 = karr[ik_last + m];
@@ -1365,8 +548,6 @@
     buff3 = buff[3] + doff;
     vis_write_gsr(gsr_scale + off);
 
-#ifndef CONV_INDEX
-
     if (jk_size == 1) {
       dp = ((mlib_addr) dl & 7) ? buffe : (mlib_d64 *) dl;
 
@@ -1652,200 +833,6 @@
         mlib_ImageCopy_na((void *)buffe, dl, xsize);
     }
 
-#else /* CONV_INDEX */
-
-    if (jk_size == 1) {
-      vis_write_gsr(gsr_scale + 7);
-
-#pragma pipeloop(0)
-      for (i = 0; i < dsize; i += 3) {
-        mlib_d64 d00, d01, d02, d03, d04, d05;
-        mlib_d64 d10, d11, d12, d13, d14, d15;
-        mlib_d64 d0, d1, d2, d3, d4, d5;
-        mlib_d64 s00 = buff0[i];
-        mlib_d64 s01 = buff0[i + 1];
-        mlib_d64 s02 = buff0[i + 2];
-
-        d00 = vis_fmul8x16au(vis_read_hi(s00), k0);
-        d01 = vis_fmul8x16au(vis_read_lo(s00), k0);
-        d02 = vis_fmul8x16au(vis_read_hi(s01), k0);
-        d03 = vis_fmul8x16au(vis_read_lo(s01), k0);
-        d04 = vis_fmul8x16au(vis_read_hi(s02), k0);
-        d05 = vis_fmul8x16au(vis_read_lo(s02), k0);
-
-        d0 = buffd[2 * i];
-        d1 = buffd[2 * i + 1];
-        d2 = buffd[2 * i + 2];
-        d3 = buffd[2 * i + 3];
-        d4 = buffd[2 * i + 4];
-        d5 = buffd[2 * i + 5];
-        d0 = vis_fpadd16(d0, d00);
-        d1 = vis_fpadd16(d1, d01);
-        d2 = vis_fpadd16(d2, d02);
-        d3 = vis_fpadd16(d3, d03);
-        d4 = vis_fpadd16(d4, d04);
-        d5 = vis_fpadd16(d5, d05);
-
-        buffe[i] = vis_fpack16_pair(d0, d1);
-        buffe[i + 1] = vis_fpack16_pair(d2, d3);
-        buffe[i + 2] = vis_fpack16_pair(d4, d5);
-
-        buffd[2 * i] = drnd;
-        buffd[2 * i + 1] = drnd;
-        buffd[2 * i + 2] = drnd;
-        buffd[2 * i + 3] = drnd;
-        buffd[2 * i + 4] = drnd;
-        buffd[2 * i + 5] = drnd;
-
-        LOAD_SRC();
-      }
-    }
-    else if (jk_size == 2) {
-      vis_write_gsr(gsr_scale + 7);
-
-#pragma pipeloop(0)
-      for (i = 0; i < dsize; i += 3) {
-        mlib_d64 d00, d01, d02, d03, d04, d05;
-        mlib_d64 d10, d11, d12, d13, d14, d15;
-        mlib_d64 d0, d1, d2, d3, d4, d5;
-        mlib_d64 s00 = buff0[i];
-        mlib_d64 s01 = buff0[i + 1];
-        mlib_d64 s02 = buff0[i + 2];
-        mlib_d64 s10 = buff1[i];
-        mlib_d64 s11 = buff1[i + 1];
-        mlib_d64 s12 = buff1[i + 2];
-
-        d00 = vis_fmul8x16au(vis_read_hi(s00), k0);
-        d01 = vis_fmul8x16au(vis_read_lo(s00), k0);
-        d02 = vis_fmul8x16au(vis_read_hi(s01), k0);
-        d03 = vis_fmul8x16au(vis_read_lo(s01), k0);
-        d04 = vis_fmul8x16au(vis_read_hi(s02), k0);
-        d05 = vis_fmul8x16au(vis_read_lo(s02), k0);
-        d10 = vis_fmul8x16au(vis_read_hi(s10), k1);
-        d11 = vis_fmul8x16au(vis_read_lo(s10), k1);
-        d12 = vis_fmul8x16au(vis_read_hi(s11), k1);
-        d13 = vis_fmul8x16au(vis_read_lo(s11), k1);
-        d14 = vis_fmul8x16au(vis_read_hi(s12), k1);
-        d15 = vis_fmul8x16au(vis_read_lo(s12), k1);
-
-        d0 = buffd[2 * i];
-        d1 = buffd[2 * i + 1];
-        d2 = buffd[2 * i + 2];
-        d3 = buffd[2 * i + 3];
-        d4 = buffd[2 * i + 4];
-        d5 = buffd[2 * i + 5];
-        d0 = vis_fpadd16(d0, d00);
-        d0 = vis_fpadd16(d0, d10);
-        d1 = vis_fpadd16(d1, d01);
-        d1 = vis_fpadd16(d1, d11);
-        d2 = vis_fpadd16(d2, d02);
-        d2 = vis_fpadd16(d2, d12);
-        d3 = vis_fpadd16(d3, d03);
-        d3 = vis_fpadd16(d3, d13);
-        d4 = vis_fpadd16(d4, d04);
-        d4 = vis_fpadd16(d4, d14);
-        d5 = vis_fpadd16(d5, d05);
-        d5 = vis_fpadd16(d5, d15);
-
-        buffe[i] = vis_fpack16_pair(d0, d1);
-        buffe[i + 1] = vis_fpack16_pair(d2, d3);
-        buffe[i + 2] = vis_fpack16_pair(d4, d5);
-
-        buffd[2 * i] = drnd;
-        buffd[2 * i + 1] = drnd;
-        buffd[2 * i + 2] = drnd;
-        buffd[2 * i + 3] = drnd;
-        buffd[2 * i + 4] = drnd;
-        buffd[2 * i + 5] = drnd;
-
-        LOAD_SRC();
-      }
-    }
-    else {                                  /* if (jk_size == 3) */
-
-      vis_write_gsr(gsr_scale + 7);
-
-#pragma pipeloop(0)
-      for (i = 0; i < dsize; i += 3) {
-        mlib_d64 d00, d01, d02, d03, d04, d05;
-        mlib_d64 d10, d11, d12, d13, d14, d15;
-        mlib_d64 d20, d21, d22, d23, d24, d25;
-        mlib_d64 d0, d1, d2, d3, d4, d5;
-        mlib_d64 s00 = buff0[i];
-        mlib_d64 s01 = buff0[i + 1];
-        mlib_d64 s02 = buff0[i + 2];
-        mlib_d64 s10 = buff1[i];
-        mlib_d64 s11 = buff1[i + 1];
-        mlib_d64 s12 = buff1[i + 2];
-        mlib_d64 s20 = buff2[i];
-        mlib_d64 s21 = buff2[i + 1];
-        mlib_d64 s22 = buff2[i + 2];
-
-        d00 = vis_fmul8x16au(vis_read_hi(s00), k0);
-        d01 = vis_fmul8x16au(vis_read_lo(s00), k0);
-        d02 = vis_fmul8x16au(vis_read_hi(s01), k0);
-        d03 = vis_fmul8x16au(vis_read_lo(s01), k0);
-        d04 = vis_fmul8x16au(vis_read_hi(s02), k0);
-        d05 = vis_fmul8x16au(vis_read_lo(s02), k0);
-        d10 = vis_fmul8x16au(vis_read_hi(s10), k1);
-        d11 = vis_fmul8x16au(vis_read_lo(s10), k1);
-        d12 = vis_fmul8x16au(vis_read_hi(s11), k1);
-        d13 = vis_fmul8x16au(vis_read_lo(s11), k1);
-        d14 = vis_fmul8x16au(vis_read_hi(s12), k1);
-        d15 = vis_fmul8x16au(vis_read_lo(s12), k1);
-        d20 = vis_fmul8x16au(vis_read_hi(s20), k2);
-        d21 = vis_fmul8x16au(vis_read_lo(s20), k2);
-        d22 = vis_fmul8x16au(vis_read_hi(s21), k2);
-        d23 = vis_fmul8x16au(vis_read_lo(s21), k2);
-        d24 = vis_fmul8x16au(vis_read_hi(s22), k2);
-        d25 = vis_fmul8x16au(vis_read_lo(s22), k2);
-
-        d0 = buffd[2 * i];
-        d1 = buffd[2 * i + 1];
-        d2 = buffd[2 * i + 2];
-        d3 = buffd[2 * i + 3];
-        d4 = buffd[2 * i + 4];
-        d5 = buffd[2 * i + 5];
-        d0 = vis_fpadd16(d0, d00);
-        d0 = vis_fpadd16(d0, d10);
-        d0 = vis_fpadd16(d0, d20);
-        d1 = vis_fpadd16(d1, d01);
-        d1 = vis_fpadd16(d1, d11);
-        d1 = vis_fpadd16(d1, d21);
-        d2 = vis_fpadd16(d2, d02);
-        d2 = vis_fpadd16(d2, d12);
-        d2 = vis_fpadd16(d2, d22);
-        d3 = vis_fpadd16(d3, d03);
-        d3 = vis_fpadd16(d3, d13);
-        d3 = vis_fpadd16(d3, d23);
-        d4 = vis_fpadd16(d4, d04);
-        d4 = vis_fpadd16(d4, d14);
-        d4 = vis_fpadd16(d4, d24);
-        d5 = vis_fpadd16(d5, d05);
-        d5 = vis_fpadd16(d5, d15);
-        d5 = vis_fpadd16(d5, d25);
-
-        buffe[i] = vis_fpack16_pair(d0, d1);
-        buffe[i + 1] = vis_fpack16_pair(d2, d3);
-        buffe[i + 2] = vis_fpack16_pair(d4, d5);
-
-        buffd[2 * i] = drnd;
-        buffd[2 * i + 1] = drnd;
-        buffd[2 * i + 2] = drnd;
-        buffd[2 * i + 3] = drnd;
-        buffd[2 * i + 4] = drnd;
-        buffd[2 * i + 5] = drnd;
-
-        LOAD_SRC();
-      }
-    }
-
-#endif /* CONV_INDEX */
-
-#ifdef CONV_INDEX
-    ColorTrue2IndexLine((void *)buffe, dl, wid, colormap);
-#endif /* CONV_INDEX */
-
     sl += sll;
     dl += dll;
 
--- a/jdk/src/java.desktop/windows/classes/sun/java2d/windows/WindowsFlags.java	Thu May 19 17:48:02 2016 +0000
+++ b/jdk/src/java.desktop/windows/classes/sun/java2d/windows/WindowsFlags.java	Thu May 19 19:46:20 2016 +0000
@@ -55,8 +55,6 @@
      *               This flag can force us to use d3d
      *               anyway in these situations.  Or, this flag can force us to
      *               not use d3d in a situation where we would use it otherwise.
-     *      translAccelEnabled: usage: "-Dsun.java2d.translaccel=true"
-     *               equivalent to sun.java2d.d3d=true
      *      offscreenSharingEnabled: usage: "-Dsun.java2d.offscreenSharing=true"
      *               Turns on the ability to share a hardware-accelerated
      *               offscreen surface through the JAWT interface.  See
@@ -67,23 +65,6 @@
      *               without being very sure that we will be willing to support
      *               that API in the future regardless of other native
      *               rendering pipeline changes.
-     *      accelReset: usage: "-Dsun.java2d.accelReset"
-     *               This flag tells us to reset any persistent information
-     *               the display device acceleration characteristics so that
-     *               we are forced to retest these characteristics.  This flag
-     *               is primarily used for debugging purposes (to allow testing
-     *               of the persistent storage mechanisms) but may also be
-     *               needed by some users if, for example, a driver upgrade
-     *               may change the runtime characteristics and they want the
-     *               tests to be re-run.
-     *      checkRegistry: usage: "-Dsun.java2d.checkRegistry"
-     *               This flag tells us to output the current registry settings
-     *               (after our initialization) to the console.
-     *      disableRegistry: usage: "-Dsun.java2d.disableRegistry"
-     *               This flag tells us to disable all registry-related
-     *               activities.  It is mainly here for debugging purposes,
-     *               to allow us to see whether any runtime bugs are caused
-     *               by or related to registry problems.
      *      magPresent: usage: "-Djavax.accessibility.screen_magnifier_present"
      *               This flag is set either on the command line or in the
      *               properties file.  It tells Swing whether the user is
@@ -121,9 +102,6 @@
     private static boolean oglEnabled;
     private static boolean oglVerbose;
     private static boolean offscreenSharingEnabled;
-    private static boolean accelReset;
-    private static boolean checkRegistry;
-    private static boolean disableRegistry;
     private static boolean magPresent;
     private static boolean setHighDPIAware;
     // TODO: other flags, including nopixfmt
@@ -234,11 +212,6 @@
                 }
                 offscreenSharingEnabled =
                     getBooleanProp("sun.java2d.offscreenSharing", false);
-                accelReset = getBooleanProp("sun.java2d.accelReset", false);
-                checkRegistry =
-                    getBooleanProp("sun.java2d.checkRegistry", false);
-                disableRegistry =
-                    getBooleanProp("sun.java2d.disableRegistry", false);
                 String dpiOverride = System.getProperty("sun.java2d.dpiaware");
                 if (dpiOverride != null) {
                     setHighDPIAware = dpiOverride.equalsIgnoreCase("true");
@@ -265,22 +238,12 @@
         System.out.println("WindowsFlags (Java):");
         System.out.println("  ddEnabled: " + ddEnabled + "\n" +
                            "  ddOffscreenEnabled: " + ddOffscreenEnabled + "\n" +
-                           "  ddVramForced: " + ddVramForced + "\n" +
-                           "  ddLockEnabled: " + ddLockEnabled + "\n" +
-                           "  ddLockSet: " + ddLockSet + "\n" +
-                           "  ddBlitEnabled: " + ddBlitEnabled + "\n" +
-                           "  ddScaleEnabled: " + ddScaleEnabled + "\n" +
                            "  d3dEnabled: " + d3dEnabled + "\n" +
                            "  d3dSet: " + d3dSet + "\n" +
                            "  oglEnabled: " + oglEnabled + "\n" +
                            "  oglVerbose: " + oglVerbose + "\n" +
                            "  gdiBlitEnabled: " + gdiBlitEnabled + "\n" +
-                           "  translAccelEnabled: " + translAccelEnabled + "\n" +
-                           "  offscreenSharingEnabled: " + offscreenSharingEnabled + "\n" +
-                           "  accelReset: " + accelReset + "\n" +
-                           "  checkRegistry: " + checkRegistry + "\n" +
-                           "  disableRegistry: " + disableRegistry + "\n" +
-                           "  d3dTexBPP: " + d3dTexBpp);
+                           "  offscreenSharingEnabled: " + offscreenSharingEnabled);
         */
     }
 
@@ -304,10 +267,6 @@
         return gdiBlitEnabled;
     }
 
-    public static boolean isTranslucentAccelerationEnabled() {
-        return d3dEnabled;
-    }
-
     public static boolean isOffscreenSharingEnabled() {
         return offscreenSharingEnabled;
     }
--- a/jdk/src/java.desktop/windows/native/libawt/java2d/d3d/D3DBadHardware.h	Thu May 19 17:48:02 2016 +0000
+++ b/jdk/src/java.desktop/windows/native/libawt/java2d/d3d/D3DBadHardware.h	Thu May 19 19:46:20 2016 +0000
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2007, 2013, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2007, 2016, 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
@@ -51,131 +51,8 @@
 
 static const ADAPTER_INFO badHardware[] = {
 
-    // Intel HD
-    // Clarkdale (Desktop) GMA HD Lines
-    { 0x8086, 0x0042, NO_VERSION, OS_ALL },
-    // Arrandale (Mobile) GMA HD Lines
-    { 0x8086, 0x0046, NO_VERSION, OS_ALL },
-
-    // Sandy Bridge HD Graphics 3000/2000
-    { 0x8086, 0x0102, NO_VERSION, OS_ALL },
-    { 0x8086, 0x0106, NO_VERSION, OS_ALL },
-    { 0x8086, 0x0112, NO_VERSION, OS_ALL },
-    { 0x8086, 0x0116, NO_VERSION, OS_ALL },
-    { 0x8086, 0x0122, NO_VERSION, OS_ALL },
-    { 0x8086, 0x0126, NO_VERSION, OS_ALL },
-    { 0x8086, 0x010A, NO_VERSION, OS_ALL },
-
-    // Ivy Bridge
-    { 0x8086, 0x0162, D_VERSION(6,14,10,5437), OS_WINXP | OS_WINXP_64 },
-    { 0x8086, 0x0162, D_VERSION(9,18,10,3257), OS_VISTA | OS_WINDOWS7 },
-    { 0x8086, 0x0166, D_VERSION(6,14,10,5437), OS_WINXP | OS_WINXP_64 },
-    { 0x8086, 0x0166, D_VERSION(9,18,10,3257), OS_VISTA | OS_WINDOWS7 },
-    { 0x8086, 0x016A, D_VERSION(6,14,10,5437), OS_WINXP | OS_WINXP_64 },
-    { 0x8086, 0x016A, D_VERSION(9,18,10,3257), OS_VISTA | OS_WINDOWS7 },
-    { 0x8086, 0x0152, D_VERSION(6,14,10,5437), OS_WINXP | OS_WINXP_64 },
-    { 0x8086, 0x0152, D_VERSION(9,18,10,3257), OS_VISTA | OS_WINDOWS7 },
-    { 0x8086, 0x0156, D_VERSION(6,14,10,5437), OS_WINXP | OS_WINXP_64 },
-    { 0x8086, 0x0156, D_VERSION(9,18,10,3257), OS_VISTA | OS_WINDOWS7 },
-    { 0x8086, 0x015A, D_VERSION(6,14,10,5437), OS_WINXP | OS_WINXP_64 },
-    { 0x8086, 0x015A, D_VERSION(9,18,10,3257), OS_VISTA | OS_WINDOWS7 },
-
-    // Haswell
-    { 0x8086, 0x0402, D_VERSION(6,14,10,5437), OS_WINXP | OS_WINXP_64 },
-    { 0x8086, 0x0402, D_VERSION(9,18,10,3257), OS_VISTA | OS_WINDOWS7 },
-    { 0x8086, 0x0406, D_VERSION(6,14,10,5437), OS_WINXP | OS_WINXP_64 },
-    { 0x8086, 0x0406, D_VERSION(9,18,10,3257), OS_VISTA | OS_WINDOWS7 },
-    { 0x8086, 0x0412, D_VERSION(6,14,10,5437), OS_WINXP | OS_WINXP_64 },
-    { 0x8086, 0x0412, D_VERSION(9,18,10,3257), OS_VISTA | OS_WINDOWS7 },
-    { 0x8086, 0x0416, D_VERSION(6,14,10,5437), OS_WINXP | OS_WINXP_64 },
-    { 0x8086, 0x0416, D_VERSION(9,18,10,3257), OS_VISTA | OS_WINDOWS7 },
-    { 0x8086, 0x041E, D_VERSION(6,14,10,5437), OS_WINXP | OS_WINXP_64 },
-    { 0x8086, 0x041E, D_VERSION(9,18,10,3257), OS_VISTA | OS_WINDOWS7 },
-    { 0x8086, 0x040A, D_VERSION(6,14,10,5437), OS_WINXP | OS_WINXP_64 },
-    { 0x8086, 0x040A, D_VERSION(9,18,10,3257), OS_VISTA | OS_WINDOWS7 },
-    { 0x8086, 0x041A, D_VERSION(6,14,10,5437), OS_WINXP | OS_WINXP_64 },
-    { 0x8086, 0x041A, D_VERSION(9,18,10,3257), OS_VISTA | OS_WINDOWS7 },
-    { 0x8086, 0x0A06, D_VERSION(6,14,10,5437), OS_WINXP | OS_WINXP_64 },
-    { 0x8086, 0x0A06, D_VERSION(9,18,10,3257), OS_VISTA | OS_WINDOWS7 },
-    { 0x8086, 0x0A16, D_VERSION(6,14,10,5437), OS_WINXP | OS_WINXP_64 },
-    { 0x8086, 0x0A16, D_VERSION(9,18,10,3257), OS_VISTA | OS_WINDOWS7 },
-    { 0x8086, 0x0A26, D_VERSION(6,14,10,5437), OS_WINXP | OS_WINXP_64 },
-    { 0x8086, 0x0A26, D_VERSION(9,18,10,3257), OS_VISTA | OS_WINDOWS7 },
-    { 0x8086, 0x0A2E, D_VERSION(6,14,10,5437), OS_WINXP | OS_WINXP_64 },
-    { 0x8086, 0x0A2E, D_VERSION(9,18,10,3257), OS_VISTA | OS_WINDOWS7 },
-    { 0x8086, 0x0A1E, D_VERSION(6,14,10,5437), OS_WINXP | OS_WINXP_64 },
-    { 0x8086, 0x0A1E, D_VERSION(9,18,10,3257), OS_VISTA | OS_WINDOWS7 },
-    { 0x8086, 0x0A0E, D_VERSION(6,14,10,5437), OS_WINXP | OS_WINXP_64 },
-    { 0x8086, 0x0A0E, D_VERSION(9,18,10,3257), OS_VISTA | OS_WINDOWS7 },
-    { 0x8086, 0x0D26, D_VERSION(6,14,10,5437), OS_WINXP | OS_WINXP_64 },
-    { 0x8086, 0x0D26, D_VERSION(9,18,10,3257), OS_VISTA | OS_WINDOWS7 },
-    { 0x8086, 0x0D22, D_VERSION(6,14,10,5437), OS_WINXP | OS_WINXP_64 },
-    { 0x8086, 0x0D22, D_VERSION(9,18,10,3257), OS_VISTA | OS_WINDOWS7 },
-
-    // Reason: workaround for 6620073, 6612195
-    // Intel 740
-    { 0x8086, 0x7800, NO_VERSION, OS_ALL },
-    { 0x8086, 0x1240, NO_VERSION, OS_ALL },
-    { 0x8086, 0x7121, NO_VERSION, OS_ALL },
-    { 0x8086, 0x7123, NO_VERSION, OS_ALL },
-    { 0x8086, 0x7125, NO_VERSION, OS_ALL },
-    { 0x8086, 0x1132, NO_VERSION, OS_ALL },
-    // IEG
-    { 0x8086, 0x2562, NO_VERSION, OS_ALL },
-    { 0x8086, 0x3577, NO_VERSION, OS_ALL },
-    { 0x8086, 0x2572, NO_VERSION, OS_ALL },
-    { 0x8086, 0x3582, NO_VERSION, OS_ALL },
-    { 0x8086, 0x358E, NO_VERSION, OS_ALL },
-    // GMA
-    { 0x8086, 0x2582, NO_VERSION, OS_ALL },
-    { 0x8086, 0x2782, NO_VERSION, OS_ALL },
-    { 0x8086, 0x2592, NO_VERSION, OS_ALL },
-    { 0x8086, 0x2792, NO_VERSION, OS_ALL },
-    { 0x8086, 0x2772, NO_VERSION, OS_ALL },
-    { 0x8086, 0x2776, NO_VERSION, OS_ALL },
-    { 0x8086, 0x27A2, NO_VERSION, OS_ALL },
-    { 0x8086, 0x27A6, NO_VERSION, OS_ALL },
-    { 0x8086, 0x27AE, NO_VERSION, OS_ALL },
-    { 0x8086, 0x29D2, NO_VERSION, OS_ALL },
-    { 0x8086, 0x29D3, NO_VERSION, OS_ALL },
-    { 0x8086, 0x29B2, NO_VERSION, OS_ALL },
-    { 0x8086, 0x29B3, NO_VERSION, OS_ALL },
-    { 0x8086, 0x29C2, NO_VERSION, OS_ALL },
-    { 0x8086, 0x29C3, NO_VERSION, OS_ALL },
-    { 0x8086, 0xA001, NO_VERSION, OS_ALL },
-    { 0x8086, 0xA002, NO_VERSION, OS_ALL },
-    { 0x8086, 0xA011, NO_VERSION, OS_ALL },
-    { 0x8086, 0xA012, NO_VERSION, OS_ALL },
-    // GMA
-    { 0x8086, 0x2972, NO_VERSION, OS_ALL },
-    { 0x8086, 0x2973, NO_VERSION, OS_ALL },
-    { 0x8086, 0x2992, NO_VERSION, OS_ALL },
-    { 0x8086, 0x2993, NO_VERSION, OS_ALL },
-    { 0x8086, 0x29A2, NO_VERSION, OS_ALL },
-    { 0x8086, 0x29A3, NO_VERSION, OS_ALL },
-    { 0x8086, 0x2982, NO_VERSION, OS_ALL },
-    { 0x8086, 0x2983, NO_VERSION, OS_ALL },
-    { 0x8086, 0x2A02, NO_VERSION, OS_ALL },
-    { 0x8086, 0x2A03, NO_VERSION, OS_ALL },
-    { 0x8086, 0x2A12, NO_VERSION, OS_ALL },
-    { 0x8086, 0x2A13, NO_VERSION, OS_ALL },
-
-    // Eaglelake (Desktop) GMA 4500 Lines
-    { 0x8086, 0x2E42, NO_VERSION, OS_ALL },
-    { 0x8086, 0x2E43, NO_VERSION, OS_ALL },
-    { 0x8086, 0x2E92, NO_VERSION, OS_ALL },
-    { 0x8086, 0x2E93, NO_VERSION, OS_ALL },
-    { 0x8086, 0x2E12, NO_VERSION, OS_ALL },
-    { 0x8086, 0x2E13, NO_VERSION, OS_ALL },
-    // Eaglelake (Desktop) GMA X4500 Lines
-    { 0x8086, 0x2E32, NO_VERSION, OS_ALL },
-    { 0x8086, 0x2E33, NO_VERSION, OS_ALL },
-    { 0x8086, 0x2E22, NO_VERSION, OS_ALL },
-    // Eaglelake (Desktop) GMA X4500HD Lines
-    { 0x8086, 0x2E23, NO_VERSION, OS_ALL },
-    // Cantiga (Mobile) GMA 4500MHD Lines
-    { 0x8086, 0x2A42, NO_VERSION, OS_ALL },
-    { 0x8086, 0x2A43, NO_VERSION, OS_ALL },
+    // All Intel Chips.
+    { 0x8086, ALL_DEVICEIDS, NO_VERSION, OS_ALL },
 
     // ATI Mobility Radeon X1600, X1400, X1450, X1300, X1350
     // Reason: workaround for 6613066, 6687166
--- a/jdk/src/java.desktop/windows/native/libawt/java2d/windows/WindowsFlags.cpp	Thu May 19 17:48:02 2016 +0000
+++ b/jdk/src/java.desktop/windows/native/libawt/java2d/windows/WindowsFlags.cpp	Thu May 19 19:46:20 2016 +0000
@@ -27,13 +27,10 @@
 #include "Trace.h"
 #include "WindowsFlags.h"
 
-BOOL      accelReset;         // reset registry 2d acceleration settings
 BOOL      useD3D = TRUE;      // d3d enabled flag
                               // initially is TRUE to allow D3D preloading
 BOOL      forceD3DUsage;      // force d3d on or off
 jboolean  g_offscreenSharing; // JAWT accelerated surface sharing
-BOOL      checkRegistry;      // Diagnostic tool: outputs 2d registry settings
-BOOL      disableRegistry;    // Diagnostic tool: disables registry interaction
 BOOL      setHighDPIAware;    // Whether to set the high-DPI awareness flag
 
 extern WCHAR *j2dAccelKey;       // Name of java2d root key
@@ -95,12 +92,6 @@
     g_offscreenSharing = GetStaticBoolean(env, wFlagsClass,
                                           "offscreenSharingEnabled");
     JNU_CHECK_EXCEPTION(env);
-    accelReset = GetStaticBoolean(env, wFlagsClass, "accelReset");
-    JNU_CHECK_EXCEPTION(env);
-    checkRegistry = GetStaticBoolean(env, wFlagsClass, "checkRegistry");
-    JNU_CHECK_EXCEPTION(env);
-    disableRegistry = GetStaticBoolean(env, wFlagsClass, "disableRegistry");
-    JNU_CHECK_EXCEPTION(env);
 
     setHighDPIAware =
         (IS_WINVISTA && GetStaticBoolean(env, wFlagsClass, "setHighDPIAware"));
@@ -113,12 +104,6 @@
                 (forceD3DUsage ? "true" : "false"));
     J2dTraceLn1(J2D_TRACE_INFO, "  offscreenSharing = %s",
                 (g_offscreenSharing ? "true" : "false"));
-    J2dTraceLn1(J2D_TRACE_INFO, "  accelReset = %s",
-                (accelReset ? "true" : "false"));
-    J2dTraceLn1(J2D_TRACE_INFO, "  checkRegistry = %s",
-                (checkRegistry ? "true" : "false"));
-    J2dTraceLn1(J2D_TRACE_INFO, "  disableRegistry = %s",
-                (disableRegistry ? "true" : "false"));
     J2dTraceLn1(J2D_TRACE_INFO, "  setHighDPIAware = %s",
                 (setHighDPIAware ? "true" : "false"));
 }
--- a/jdk/src/java.desktop/windows/native/libawt/java2d/windows/WindowsFlags.h	Thu May 19 17:48:02 2016 +0000
+++ b/jdk/src/java.desktop/windows/native/libawt/java2d/windows/WindowsFlags.h	Thu May 19 19:46:20 2016 +0000
@@ -27,12 +27,9 @@
 #ifndef WINDOWSFLAGS_H
 #define WINDOWSFLAGS_H
 
-extern BOOL      accelReset;         // reset registry 2d acceleration settings
 extern BOOL      useD3D;             // d3d enabled flag
 extern BOOL      forceD3DUsage;      // force d3d on or off
 extern jboolean  g_offscreenSharing; // JAWT accelerated surface sharing
-extern BOOL      checkRegistry;      // Diag tool: outputs 2d registry settings
-extern BOOL      disableRegistry;    // Diag tool: disables registry interaction
 extern BOOL      setHighDPIAware;    // whether to set High DPI Aware flag on Vista
 
 void SetD3DEnabledFlag(JNIEnv *env, BOOL d3dEnabled, BOOL d3dSet);
--- a/jdk/src/java.desktop/windows/native/libawt/windows/awt_Component.cpp	Thu May 19 17:48:02 2016 +0000
+++ b/jdk/src/java.desktop/windows/native/libawt/windows/awt_Component.cpp	Thu May 19 19:46:20 2016 +0000
@@ -2720,6 +2720,7 @@
     {java_awt_event_KeyEvent_VK_SHIFT,            VK_SHIFT},
     {java_awt_event_KeyEvent_VK_CONTROL,          VK_CONTROL},
     {java_awt_event_KeyEvent_VK_ALT,              VK_MENU},
+    {java_awt_event_KeyEvent_VK_ALT_GRAPH,        VK_RMENU},
     {java_awt_event_KeyEvent_VK_NUM_LOCK,         VK_NUMLOCK},
 
     // Miscellaneous Windows keys
--- a/jdk/src/java.desktop/windows/native/libawt/windows/awt_Robot.cpp	Thu May 19 17:48:02 2016 +0000
+++ b/jdk/src/java.desktop/windows/native/libawt/windows/awt_Robot.cpp	Thu May 19 19:46:20 2016 +0000
@@ -335,6 +335,9 @@
     } else {
         // get the scancode from the virtual key
         scancode = ::MapVirtualKey(vkey, 0);
+        if (vkey == VK_RMENU) {
+            dwFlags |= KEYEVENTF_EXTENDEDKEY;
+        }
         keybd_event(vkey, scancode, dwFlags, 0);
     }
 }
--- a/jdk/src/java.desktop/windows/native/libawt/windows/awt_TrayIcon.cpp	Thu May 19 17:48:02 2016 +0000
+++ b/jdk/src/java.desktop/windows/native/libawt/windows/awt_TrayIcon.cpp	Thu May 19 19:46:20 2016 +0000
@@ -93,6 +93,12 @@
 
 void AwtTrayIcon::Dispose() {
     SendTrayMessage(NIM_DELETE);
+
+    // Destroy the icon to avoid leak of GDI objects
+    if (m_nid.hIcon != NULL) {
+        ::DestroyIcon(m_nid.hIcon);
+    }
+
     UnlinkObjects();
 
     if (--sm_instCount == 0) {
--- a/jdk/src/java.httpclient/share/classes/java/net/http/AsyncSSLDelegate.java	Thu May 19 17:48:02 2016 +0000
+++ b/jdk/src/java.httpclient/share/classes/java/net/http/AsyncSSLDelegate.java	Thu May 19 19:46:20 2016 +0000
@@ -26,7 +26,6 @@
 import java.io.Closeable;
 import java.io.IOException;
 import java.nio.ByteBuffer;
-import java.util.Arrays;
 import java.util.LinkedList;
 import java.util.concurrent.ExecutorService;
 import java.util.function.Consumer;
@@ -557,25 +556,37 @@
     }
 
     static void logParams(SSLParameters p) {
-        if (!Log.ssl())
+        if (!Log.ssl()) {
             return;
+        }
+
         Log.logSSL("SSLParameters:");
         if (p == null) {
             Log.logSSL("Null params");
             return;
         }
-        for (String cipher : p.getCipherSuites()) {
-            Log.logSSL("cipher: {0}\n", cipher);
+
+        if (p.getCipherSuites() != null) {
+            for (String cipher : p.getCipherSuites()) {
+                Log.logSSL("cipher: {0}\n", cipher);
+            }
         }
+
+        // SSLParameters.getApplicationProtocols() can't return null
         for (String approto : p.getApplicationProtocols()) {
             Log.logSSL("application protocol: {0}\n", approto);
         }
-        for (String protocol : p.getProtocols()) {
-            Log.logSSL("protocol: {0}\n", protocol);
+
+        if (p.getProtocols() != null) {
+            for (String protocol : p.getProtocols()) {
+                Log.logSSL("protocol: {0}\n", protocol);
+            }
         }
-        if (p.getServerNames() != null)
+
+        if (p.getServerNames() != null) {
             for (SNIServerName sname : p.getServerNames()) {
                 Log.logSSL("server name: {0}\n", sname.toString());
+            }
         }
     }
 
--- a/jdk/src/java.httpclient/share/classes/java/net/http/HttpClientImpl.java	Thu May 19 17:48:02 2016 +0000
+++ b/jdk/src/java.httpclient/share/classes/java/net/http/HttpClientImpl.java	Thu May 19 19:46:20 2016 +0000
@@ -35,6 +35,7 @@
 import java.nio.channels.SelectableChannel;
 import java.nio.channels.SelectionKey;
 import java.nio.channels.Selector;
+import java.nio.channels.SocketChannel;
 import java.security.NoSuchAlgorithmException;
 import java.util.ArrayList;
 import java.util.Iterator;
@@ -155,6 +156,15 @@
         selmgr.register(exchange);
     }
 
+    /**
+     * Only used from RawChannel to disconnect the channel from
+     * the selector
+     */
+    void cancelRegistration(SocketChannel s) {
+        selmgr.cancel(s);
+    }
+
+
     Http2ClientImpl client2() {
         return client2;
     }
@@ -220,6 +230,13 @@
             selector.wakeup();
         }
 
+        synchronized void cancel(SocketChannel e) {
+            SelectionKey key = e.keyFor(selector);
+            if (key != null)
+                key.cancel();
+            selector.wakeup();
+        }
+
         void wakeupSelector() {
             selector.wakeup();
         }
--- a/jdk/src/java.httpclient/share/classes/java/net/http/HttpHeaders1.java	Thu May 19 17:48:02 2016 +0000
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,29 +0,0 @@
-/*
- * Copyright (c) 2015, 2016, 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
- */
-
-package java.net.http;
-
-public interface HttpHeaders1 extends HttpHeaders {
-    public void makeUnmodifiable();
-}
--- a/jdk/src/java.httpclient/share/classes/java/net/http/HttpResponseImpl.java	Thu May 19 17:48:02 2016 +0000
+++ b/jdk/src/java.httpclient/share/classes/java/net/http/HttpResponseImpl.java	Thu May 19 19:46:20 2016 +0000
@@ -176,7 +176,7 @@
      *
      * @return
      */
-    RawChannel rawChannel() {
+    RawChannel rawChannel() throws IOException {
         if (rawchan == null) {
             rawchan = new RawChannel(request.client(), connection);
         }
--- a/jdk/src/java.httpclient/share/classes/java/net/http/Log.java	Thu May 19 17:48:02 2016 +0000
+++ b/jdk/src/java.httpclient/share/classes/java/net/http/Log.java	Thu May 19 19:46:20 2016 +0000
@@ -88,7 +88,7 @@
                         logging |= TRACE;
                         break;
                     case "all":
-                        logging |= CONTENT|HEADERS|REQUESTS|FRAMES|ERRORS|TRACE;
+                        logging |= CONTENT|HEADERS|REQUESTS|FRAMES|ERRORS|TRACE|SSL;
                         break;
                 }
                 if (val.startsWith("frames")) {
--- a/jdk/src/java.httpclient/share/classes/java/net/http/RawChannel.java	Thu May 19 17:48:02 2016 +0000
+++ b/jdk/src/java.httpclient/share/classes/java/net/http/RawChannel.java	Thu May 19 19:46:20 2016 +0000
@@ -29,6 +29,7 @@
 import java.nio.channels.GatheringByteChannel;
 import java.nio.channels.SelectableChannel;
 import java.nio.channels.SelectionKey;
+import java.nio.channels.SocketChannel;
 
 //
 // Used to implement WebSocket. Each RawChannel corresponds to a TCP connection
@@ -56,9 +57,21 @@
     interface NonBlockingEvent extends RawEvent {
     }
 
-    RawChannel(HttpClientImpl client, HttpConnection connection) {
+    RawChannel(HttpClientImpl client, HttpConnection connection)
+                                                throws IOException {
         this.client = client;
         this.connection = connection;
+        SocketChannel chan = connection.channel();
+        client.cancelRegistration(chan);
+        chan.configureBlocking(false);
+    }
+
+    SocketChannel socketChannel() {
+        return connection.channel();
+    }
+
+    ByteBuffer getRemaining() {
+        return connection.getRemaining();
     }
 
     private class RawAsyncEvent extends AsyncEvent {
--- a/jdk/src/java.httpclient/share/classes/java/net/http/WSOpeningHandshake.java	Thu May 19 17:48:02 2016 +0000
+++ b/jdk/src/java.httpclient/share/classes/java/net/http/WSOpeningHandshake.java	Thu May 19 19:46:20 2016 +0000
@@ -24,6 +24,8 @@
  */
 package java.net.http;
 
+import java.io.UncheckedIOException;
+import java.io.IOException;
 import java.net.URI;
 import java.net.URISyntaxException;
 import java.nio.charset.StandardCharsets;
@@ -126,6 +128,8 @@
                         return CompletableFuture.completedFuture(result);
                     } catch (WebSocketHandshakeException e) {
                         return CompletableFuture.failedFuture(e);
+                    } catch (UncheckedIOException ee) {
+                        return CompletableFuture.failedFuture(ee.getCause());
                     }
                 });
     }
@@ -149,7 +153,12 @@
         checkAccept(response, h);
         checkExtensions(response, h);
         String subprotocol = checkAndReturnSubprotocol(response, h);
-        RawChannel channel = ((HttpResponseImpl) response).rawChannel();
+        RawChannel channel = null;
+        try {
+            channel = ((HttpResponseImpl) response).rawChannel();
+        } catch (IOException e) {
+            throw new UncheckedIOException(e);
+        }
         return new Result(subprotocol, channel);
     }
 
--- a/jdk/src/java.instrument/share/native/libinstrument/InvocationAdapter.c	Thu May 19 17:48:02 2016 +0000
+++ b/jdk/src/java.instrument/share/native/libinstrument/InvocationAdapter.c	Thu May 19 19:46:20 2016 +0000
@@ -518,18 +518,22 @@
 splitPathList(const char* str, int* pathCount, char*** paths) {
     int count = 0;
     char** segments = NULL;
+    char** new_segments;
     char* c = (char*) str;
     while (*c != '\0') {
         while (*c == ' ') c++;          /* skip leading spaces */
         if (*c == '\0') {
             break;
         }
-        if (segments == NULL) {
-            segments = (char**)malloc( sizeof(char**) );
-        } else {
-            segments = (char**)realloc( segments, (count+1)*sizeof(char**) );
+        new_segments = (char**)realloc(segments, (count+1)*sizeof(char*));
+        if (new_segments == NULL) {
+            jplis_assert(0);
+            free(segments);
+            count = 0;
+            segments = NULL;
+            break;
         }
-        jplis_assert(segments != (char**)NULL);
+        segments = new_segments;
         segments[count++] = c;
         c = strchr(c, ' ');
         if (c == NULL) {
--- a/jdk/src/java.logging/share/classes/java/util/logging/LogManager.java	Thu May 19 17:48:02 2016 +0000
+++ b/jdk/src/java.logging/share/classes/java/util/logging/LogManager.java	Thu May 19 19:46:20 2016 +0000
@@ -2506,15 +2506,12 @@
         }
     }
 
-    // Management Support
-    private static LoggingMXBean loggingMXBean = null;
     /**
      * String representation of the
      * {@link javax.management.ObjectName} for the management interface
      * for the logging facility.
      *
      * @see java.lang.management.PlatformLoggingMXBean
-     * @see java.util.logging.LoggingMXBean
      *
      * @since 1.5
      */
@@ -2523,24 +2520,21 @@
 
     /**
      * Returns {@code LoggingMXBean} for managing loggers.
-     * An alternative way to manage loggers is through the
-     * {@link java.lang.management.PlatformLoggingMXBean} interface
-     * that can be obtained by calling:
-     * <pre>
-     *     PlatformLoggingMXBean logging = {@link java.lang.management.ManagementFactory#getPlatformMXBean(Class)
-     *         ManagementFactory.getPlatformMXBean}(PlatformLoggingMXBean.class);
-     * </pre>
      *
      * @return a {@link LoggingMXBean} object.
      *
+     * @deprecated {@code java.util.logging.LoggingMXBean} is deprecated and
+     *      replaced with {@code java.lang.management.PlatformLoggingMXBean}. Use
+     *      {@link java.lang.management.ManagementFactory#getPlatformMXBean(Class)
+     *      ManagementFactory.getPlatformMXBean}(PlatformLoggingMXBean.class)
+     *      instead.
+     *
      * @see java.lang.management.PlatformLoggingMXBean
      * @since 1.5
      */
+    @Deprecated(since="9")
     public static synchronized LoggingMXBean getLoggingMXBean() {
-        if (loggingMXBean == null) {
-            loggingMXBean =  new Logging();
-        }
-        return loggingMXBean;
+        return Logging.getInstance();
     }
 
     /**
--- a/jdk/src/java.logging/share/classes/java/util/logging/Logging.java	Thu May 19 17:48:02 2016 +0000
+++ b/jdk/src/java.logging/share/classes/java/util/logging/Logging.java	Thu May 19 19:46:20 2016 +0000
@@ -44,16 +44,18 @@
  * @see Logger
  * @see LogManager
  */
-class Logging implements LoggingMXBean {
+@SuppressWarnings("deprecation") // implements LoggingMXBean
+final class Logging implements LoggingMXBean {
 
     private static LogManager logManager = LogManager.getLogManager();
 
     /** Constructor of Logging which is the implementation class
      *  of LoggingMXBean.
      */
-    Logging() {
+    private Logging() {
     }
 
+    @Override
     public List<String> getLoggerNames() {
         Enumeration<String> loggers = logManager.getLoggerNames();
         ArrayList<String> array = new ArrayList<>();
@@ -65,6 +67,7 @@
     }
 
     private static String EMPTY_STRING = "";
+    @Override
     public String getLoggerLevel(String loggerName) {
         Logger l = logManager.getLogger(loggerName);
         if (l == null) {
@@ -79,6 +82,7 @@
         }
     }
 
+    @Override
     public void setLoggerLevel(String loggerName, String levelName) {
         if (loggerName == null) {
             throw new NullPointerException("loggerName is null");
@@ -102,6 +106,7 @@
         logger.setLevel(level);
     }
 
+    @Override
     public String getParentLoggerName( String loggerName ) {
         Logger l = logManager.getLogger( loggerName );
         if (l == null) {
@@ -116,4 +121,11 @@
             return p.getName();
         }
     }
+
+    static Logging getInstance() {
+        return INSTANCE;
+    }
+
+    private static final Logging INSTANCE = new Logging();
+
 }
--- a/jdk/src/java.logging/share/classes/java/util/logging/LoggingMXBean.java	Thu May 19 17:48:02 2016 +0000
+++ b/jdk/src/java.logging/share/classes/java/util/logging/LoggingMXBean.java	Thu May 19 19:46:20 2016 +0000
@@ -27,30 +27,23 @@
 
 
 /**
- * The management interface for the logging facility. It is recommended
- * to use the {@link java.lang.management.PlatformLoggingMXBean} management
- * interface that implements all attributes defined in this
- * {@code LoggingMXBean}.  The
- * {@link java.lang.management.ManagementFactory#getPlatformMXBean(Class)
- * ManagementFactory.getPlatformMXBean} method can be used to obtain
- * the {@code PlatformLoggingMXBean} object representing the management
- * interface for logging.
+ * The management interface for the logging facility.
  *
- * <p>There is a single global instance of the {@code LoggingMXBean}.
- * This instance is an {@link javax.management.MXBean MXBean} that
- * can be obtained by calling the {@link LogManager#getLoggingMXBean}
- * method or from the
- * {@linkplain java.lang.management.ManagementFactory#getPlatformMBeanServer
+ * {@link java.lang.management.PlatformLoggingMXBean
+ * java.lang.management.PlatformLoggingMXBean} is the management interface
+ * for logging facility registered in the {@link
+ * java.lang.management.ManagementFactory#getPlatformMBeanServer()
  * platform MBeanServer}.
- * <p>
- * The {@link javax.management.ObjectName ObjectName} that uniquely identifies
- * the management interface for logging within the {@code MBeanServer} is:
- * <pre>
- *    {@link LogManager#LOGGING_MXBEAN_NAME java.util.logging:type=Logging}
- * </pre>
- * <p>
- * The instance registered in the platform {@code MBeanServer}
- * is also a {@link java.lang.management.PlatformLoggingMXBean}.
+ * It is recommended to use the {@code PlatformLoggingMXBean} obtained via
+ * the {@link java.lang.management.ManagementFactory#getPlatformMXBean(Class)
+ * ManagementFactory.getPlatformMXBean(PlatformLoggingMXBean.class)} method.
+ *
+ * @deprecated {@code LoggingMXBean} is no longer a {@link
+ * java.lang.management.PlatformManagedObject platform MXBean} and is replaced
+ * with {@link java.lang.management.PlatformLoggingMXBean}.
+ * It will not register in the platform {@code MBeanServer}.
+ * Use {@code ManagementFactory.getPlatformMXBean(PlatformLoggingMXBean.class)}
+ * instead.
  *
  * @author  Ron Mann
  * @author  Mandy Chung
@@ -58,6 +51,7 @@
  *
  * @see java.lang.management.PlatformLoggingMXBean
  */
+@Deprecated(since="9")
 public interface LoggingMXBean {
 
     /**
--- a/jdk/src/java.management/share/classes/java/lang/management/ManagementFactory.java	Thu May 19 17:48:02 2016 +0000
+++ b/jdk/src/java.management/share/classes/java/lang/management/ManagementFactory.java	Thu May 19 19:46:20 2016 +0000
@@ -598,9 +598,8 @@
 
         try {
             final ObjectName objName = new ObjectName(mxbeanName);
-            // skip the isInstanceOf check for LoggingMXBean
             String intfName = mxbeanInterface.getName();
-            if (!connection.isInstanceOf(objName, intfName)) {
+            if (!isInstanceOf(connection, objName, intfName)) {
                 throw new IllegalArgumentException(mxbeanName +
                     " is not an instance of " + mxbeanInterface);
             }
@@ -616,6 +615,33 @@
         }
     }
 
+    // This makes it possible to obtain an instance of LoggingMXBean
+    // using newPlatformMXBeanProxy(mbs, on, LoggingMXBean.class)
+    // even though the underlying MXBean no longer implements
+    // java.util.logging.LoggingMXBean.
+    // Altough java.util.logging.LoggingMXBean is deprecated, an application
+    // that uses newPlatformMXBeanProxy(mbs, on, LoggingMXBean.class) will
+    // continue to work.
+    //
+    private static boolean isInstanceOf(MBeanServerConnection connection,
+            ObjectName objName, String intfName)
+            throws InstanceNotFoundException, IOException
+    {
+        // special case for java.util.logging.LoggingMXBean.
+        // java.util.logging.LoggingMXBean is deprecated and
+        // replaced with java.lang.management.PlatformLoggingMXBean,
+        // so we will consider that any MBean implementing
+        // java.lang.management.PlatformLoggingMXBean also implements
+        // java.util.logging.LoggingMXBean.
+        if ("java.util.logging.LoggingMXBean".equals(intfName)) {
+            if (connection.isInstanceOf(objName,
+                    PlatformLoggingMXBean.class.getName())) {
+                return true;
+            }
+        }
+        return connection.isInstanceOf(objName, intfName);
+    }
+
     /**
      * Returns the platform MXBean implementing
      * the given {@code mxbeanInterface} which is specified
--- a/jdk/src/java.management/share/classes/java/lang/management/PlatformLoggingMXBean.java	Thu May 19 17:48:02 2016 +0000
+++ b/jdk/src/java.management/share/classes/java/lang/management/PlatformLoggingMXBean.java	Thu May 19 19:46:20 2016 +0000
@@ -44,10 +44,6 @@
  *      {@link java.util.logging.LogManager#LOGGING_MXBEAN_NAME java.util.logging:type=Logging}
  * </pre>
  *
- * <p>The instance registered in the platform {@code MBeanServer} with
- * this {@code ObjectName} implements all attributes defined by
- * {@link java.util.logging.LoggingMXBean}.
- *
  * @since   1.7
  */
 public interface PlatformLoggingMXBean extends PlatformManagedObject {
--- a/jdk/src/java.management/share/classes/sun/management/ManagementFactoryHelper.java	Thu May 19 17:48:02 2016 +0000
+++ b/jdk/src/java.management/share/classes/sun/management/ManagementFactoryHelper.java	Thu May 19 19:46:20 2016 +0000
@@ -26,6 +26,8 @@
 package sun.management;
 
 import java.lang.management.*;
+import java.lang.reflect.InvocationTargetException;
+import java.lang.reflect.Method;
 import javax.management.InstanceAlreadyExistsException;
 import javax.management.InstanceNotFoundException;
 import javax.management.MBeanServer;
@@ -43,9 +45,13 @@
 import java.util.ArrayList;
 import java.util.List;
 
-import java.lang.reflect.Constructor;
-import java.lang.reflect.InvocationTargetException;
+import java.lang.reflect.Module;
+import java.lang.reflect.UndeclaredThrowableException;
 import java.security.PrivilegedAction;
+import java.util.Collections;
+import java.util.HashMap;
+import java.util.Map;
+import java.util.Optional;
 
 /**
  * ManagementFactoryHelper provides static factory methods to create
@@ -66,6 +72,7 @@
         return jvm;
     }
 
+    static final String LOGGING_MXBEAN_NAME = "java.util.logging:type=Logging";
     private static ClassLoadingImpl    classMBean = null;
     private static MemoryImpl          memoryMBean = null;
     private static ThreadImpl          threadMBean = null;
@@ -145,74 +152,138 @@
     }
 
     public static PlatformLoggingMXBean getPlatformLoggingMXBean() {
-        if (LoggingMXBeanSupport.isAvailable()) {
-            return PlatformLoggingImpl.instance;
+        if (LoggingMXBeanAccess.isAvailable()) {
+            return PlatformLoggingImpl.MBEAN;
         } else {
             return null;
         }
     }
 
     public static boolean isPlatformLoggingMXBeanAvailable() {
-        return LoggingMXBeanSupport.isAvailable();
+        return LoggingMXBeanAccess.isAvailable();
     }
 
-    /**
-     * The logging MXBean object is an instance of
-     * PlatformLoggingMXBean and java.util.logging.LoggingMXBean
-     * but it can't directly implement two MXBean interfaces
-     * as a compliant MXBean implements exactly one MXBean interface,
-     * or if it implements one interface that is a subinterface of
-     * all the others; otherwise, it is a non-compliant MXBean
-     * and MBeanServer will throw NotCompliantMBeanException.
-     * See the Definition of an MXBean section in javax.management.MXBean spec.
-     *
-     * To create a compliant logging MXBean, define a LoggingMXBean interface
-     * that extend PlatformLoggingMXBean and j.u.l.LoggingMXBean
-    */
-    public interface LoggingMXBean
-        extends PlatformLoggingMXBean, java.util.logging.LoggingMXBean {
-    }
-
-    // This is a trick: if java.util.logging is not present then
-    // attempting to access something that implements
-    // java.util.logging.LoggingMXBean will trigger a CNFE.
-    // So we cannot directly call any static method or access any static field
-    // on PlatformLoggingImpl, as we would risk raising a CNFE.
-    // Instead we use this intermediate LoggingMXBeanSupport class to determine
+    // The LoggingMXBeanAccess class uses reflection to determine
     // whether java.util.logging is present, and load the actual LoggingMXBean
     // implementation.
     //
-    static final class LoggingMXBeanSupport {
-        final static Object loggingImpl =
-                AccessController.doPrivileged(new PrivilegedAction<Object>() {
-            @Override
-            public Object run() {
-                try {
-                    // create a LoggingProxyImpl instance when
-                    // java.util.logging classes exist
-                    Class<?> c = Class.forName("java.util.logging.Logging", true, null);
-                    Constructor<?> cons = c.getDeclaredConstructor();
-                    cons.setAccessible(true);
-                    return cons.newInstance();
-                } catch (ClassNotFoundException cnf) {
-                    return null;
-                } catch (NoSuchMethodException | InstantiationException
-                        | IllegalAccessException | InvocationTargetException e) {
-                    throw new AssertionError(e);
-                }
-            }});
+    static final class LoggingMXBeanAccess {
+
+        final static String LOG_MANAGER_CLASS_NAME = "java.util.logging.LogManager";
+        final static String LOGGING_MXBEAN_CLASS_NAME = "java.util.logging.LoggingMXBean";
+        final static Class<?> LOG_MANAGER_CLASS = loadLoggingClass(LOG_MANAGER_CLASS_NAME);
 
         static boolean isAvailable() {
-            return loggingImpl != null;
+            return LOG_MANAGER_CLASS != null;
+        }
+
+        private static Class<?> loadLoggingClass(String className) {
+            return AccessController.doPrivileged(new PrivilegedAction<>() {
+                @Override
+                public Class<?> run() {
+                    Optional<Module> logging = java.lang.reflect.Layer.boot()
+                        .findModule("java.logging");
+                    if (logging.isPresent()) {
+                        return Class.forName(logging.get(), className);
+                    }
+                    return null;
+                }
+            });
+        }
+
+        private Map<String, Method> initMethodMap(Object impl) {
+            if (impl == null) {
+                return Collections.emptyMap();
+            }
+            Class<?> intfClass = loadLoggingClass(LOGGING_MXBEAN_CLASS_NAME);
+            final Map<String, Method> methodsMap = new HashMap<>();
+            for (Method m : intfClass.getMethods()) {
+                try {
+                    // Sanity checking: all public methods present in
+                    // java.util.logging.LoggingMXBean should
+                    // also be in PlatformLoggingMXBean
+                    Method specMethod = PlatformLoggingMXBean.class
+                             .getMethod(m.getName(), m.getParameterTypes());
+                    if (specMethod.getReturnType().isAssignableFrom(m.getReturnType())) {
+                        if (methodsMap.putIfAbsent(m.getName(), m) != null) {
+                            throw new RuntimeException("unexpected polymorphic method: "
+                                     + m.getName());
+                        }
+                    }
+                } catch (NoSuchMethodException x) {
+                    // All methods in java.util.logging.LoggingMXBean should
+                    // also be in PlatformLoggingMXBean
+                    throw new InternalError(x);
+                }
+            }
+            return Collections.unmodifiableMap(methodsMap);
         }
+
+        private static Object getMXBeanImplementation() {
+            if (!isAvailable()) {
+                // should not happen
+                throw new NoClassDefFoundError(LOG_MANAGER_CLASS_NAME);
+            }
+            try {
+                final Method m = LOG_MANAGER_CLASS.getMethod("getLoggingMXBean");
+                return m.invoke(null);
+            } catch (NoSuchMethodException
+                    | IllegalAccessException
+                    | InvocationTargetException x) {
+                throw new ExceptionInInitializerError(x);
+            }
+         }
+
+        // The implementation object, which will be invoked through
+        // reflection. The implementation does not need to implement
+        // PlatformLoggingMXBean, but must declare the same methods
+        // with same signatures, and they must be public, with one
+        // exception:
+        // getObjectName will not be called on the implementation object,
+        // so the implementation object does not need to declare such
+        // a method.
+        final Object impl = getMXBeanImplementation();
+        final Map<String, Method> methods = initMethodMap(impl);
+
+        LoggingMXBeanAccess() {
+        }
+
+        <T> T invoke(String methodName, Object... args) {
+            Method m = methods.get(methodName);
+            if (m == null) {
+                throw new UnsupportedOperationException(methodName);
+            }
+            try {
+                @SuppressWarnings("unchecked")
+                T result = (T) m.invoke(impl, args);
+                return result;
+            } catch (IllegalAccessException ex) {
+                throw new UnsupportedOperationException(ex);
+            } catch (InvocationTargetException ex) {
+                throw unwrap(ex);
+            }
+        }
+
+        private static RuntimeException unwrap(InvocationTargetException x) {
+            Throwable t = x.getCause();
+            if (t instanceof RuntimeException) {
+                return (RuntimeException)t;
+            }
+            if (t instanceof Error) {
+                throw (Error)t;
+            }
+            return new UndeclaredThrowableException(t == null ? x : t);
+        }
+
+
     }
 
-    static class PlatformLoggingImpl implements LoggingMXBean
-    {
-        final static java.util.logging.LoggingMXBean impl =
-                (java.util.logging.LoggingMXBean) LoggingMXBeanSupport.loggingImpl;
-        final static PlatformLoggingMXBean instance = new PlatformLoggingImpl();
-        final static String LOGGING_MXBEAN_NAME = "java.util.logging:type=Logging";
+    static final class PlatformLoggingImpl implements PlatformLoggingMXBean {
+
+        private final LoggingMXBeanAccess loggingAccess;
+        private PlatformLoggingImpl(LoggingMXBeanAccess loggingAccess) {
+            this.loggingAccess = loggingAccess;
+        }
 
         private volatile ObjectName objname;  // created lazily
         @Override
@@ -232,23 +303,29 @@
 
         @Override
         public java.util.List<String> getLoggerNames() {
-            return impl.getLoggerNames();
+            return loggingAccess.invoke("getLoggerNames");
         }
 
         @Override
         public String getLoggerLevel(String loggerName) {
-            return impl.getLoggerLevel(loggerName);
+            return loggingAccess.invoke("getLoggerLevel", loggerName);
         }
 
         @Override
         public void setLoggerLevel(String loggerName, String levelName) {
-            impl.setLoggerLevel(loggerName, levelName);
+            loggingAccess.invoke("setLoggerLevel", loggerName, levelName);
         }
 
         @Override
         public String getParentLoggerName(String loggerName) {
-            return impl.getParentLoggerName(loggerName);
+            return loggingAccess.invoke("getParentLoggerName", loggerName);
         }
+
+        private static PlatformLoggingImpl getInstance() {
+            return new PlatformLoggingImpl(new LoggingMXBeanAccess());
+         }
+
+        static final PlatformLoggingMXBean MBEAN = getInstance();
     }
 
     private static List<BufferPoolMXBean> bufferPools = null;
--- a/jdk/src/jdk.attach/share/classes/sun/tools/attach/HotSpotVirtualMachine.java	Thu May 19 17:48:02 2016 +0000
+++ b/jdk/src/jdk.attach/share/classes/sun/tools/attach/HotSpotVirtualMachine.java	Thu May 19 19:46:20 2016 +0000
@@ -258,7 +258,7 @@
     /*
      * Convenience method for simple commands
      */
-    private InputStream executeCommand(String cmd, Object ... args) throws IOException {
+    public InputStream executeCommand(String cmd, Object ... args) throws IOException {
         try {
             return execute(cmd, args);
         } catch (AgentLoadException x) {
--- a/jdk/src/jdk.internal.le/share/classes/jdk/internal/jline/console/ConsoleReader.java	Thu May 19 17:48:02 2016 +0000
+++ b/jdk/src/jdk.internal.le/share/classes/jdk/internal/jline/console/ConsoleReader.java	Thu May 19 19:46:20 2016 +0000
@@ -2498,6 +2498,12 @@
                     //ignore
                 }
 
+                if (o instanceof Runnable) {
+                    ((Runnable) o).run();
+                    sb.setLength(0);
+                    continue;
+                }
+
                 // Search mode.
                 //
                 // Note that we have to do this first, because if there is a command
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/jdk/src/jdk.internal.le/share/classes/jdk/internal/jline/extra/EditingHistory.java	Thu May 19 19:46:20 2016 +0000
@@ -0,0 +1,418 @@
+/*
+ * Copyright (c) 2015, 2016, 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.internal.jline.extra;
+
+import java.io.IOException;
+import java.lang.reflect.Method;
+import java.util.ArrayList;
+import java.util.Collection;
+import java.util.Iterator;
+import java.util.List;
+import java.util.ListIterator;
+import java.util.function.Supplier;
+
+import jdk.internal.jline.console.ConsoleReader;
+import jdk.internal.jline.console.KeyMap;
+import jdk.internal.jline.console.history.History;
+import jdk.internal.jline.console.history.History.Entry;
+import jdk.internal.jline.console.history.MemoryHistory;
+
+/*Public for tests (HistoryTest).
+ */
+public abstract class EditingHistory implements History {
+
+    private final History fullHistory;
+    private History currentDelegate;
+
+    protected EditingHistory(ConsoleReader in, Iterable<? extends String> originalHistory) {
+        this.fullHistory = new MemoryHistory();
+        this.currentDelegate = fullHistory;
+        bind(in, CTRL_UP,
+             (Runnable) () -> moveHistoryToSnippet(in, ((EditingHistory) in.getHistory())::previousSnippet));
+        bind(in, CTRL_DOWN,
+             (Runnable) () -> moveHistoryToSnippet(in, ((EditingHistory) in.getHistory())::nextSnippet));
+        load(originalHistory);
+    }
+
+    private void moveHistoryToSnippet(ConsoleReader in, Supplier<Boolean> action) {
+        if (!action.get()) {
+            try {
+                in.beep();
+            } catch (IOException ex) {
+                throw new IllegalStateException(ex);
+            }
+        } else {
+            try {
+                //could use:
+                //in.resetPromptLine(in.getPrompt(), in.getHistory().current().toString(), -1);
+                //but that would mean more re-writing on the screen, (and prints an additional
+                //empty line), so using setBuffer directly:
+                Method setBuffer = in.getClass().getDeclaredMethod("setBuffer", String.class);
+
+                setBuffer.setAccessible(true);
+                setBuffer.invoke(in, in.getHistory().current().toString());
+                in.flush();
+            } catch (ReflectiveOperationException | IOException ex) {
+                throw new IllegalStateException(ex);
+            }
+        }
+    }
+
+    private void bind(ConsoleReader in, String shortcut, Object action) {
+        KeyMap km = in.getKeys();
+        for (int i = 0; i < shortcut.length(); i++) {
+            Object value = km.getBound(Character.toString(shortcut.charAt(i)));
+            if (value instanceof KeyMap) {
+                km = (KeyMap) value;
+            } else {
+                km.bind(shortcut.substring(i), action);
+            }
+        }
+    }
+
+    private static final String CTRL_UP = "\033\133\061\073\065\101"; //Ctrl-UP
+    private static final String CTRL_DOWN = "\033\133\061\073\065\102"; //Ctrl-DOWN
+
+    @Override
+    public int size() {
+        return currentDelegate.size();
+    }
+
+    @Override
+    public boolean isEmpty() {
+        return currentDelegate.isEmpty();
+    }
+
+    @Override
+    public int index() {
+        return currentDelegate.index();
+    }
+
+    @Override
+    public void clear() {
+        if (currentDelegate != fullHistory)
+            throw new IllegalStateException("narrowed");
+        currentDelegate.clear();
+    }
+
+    @Override
+    public CharSequence get(int index) {
+        return currentDelegate.get(index);
+    }
+
+    @Override
+    public void add(CharSequence line) {
+        NarrowingHistoryLine currentLine = null;
+        int origIndex = fullHistory.index();
+        int fullSize;
+        try {
+            fullHistory.moveToEnd();
+            fullSize = fullHistory.index();
+            if (currentDelegate == fullHistory) {
+                if (origIndex < fullHistory.index()) {
+                    for (Entry entry : fullHistory) {
+                        if (!(entry.value() instanceof NarrowingHistoryLine))
+                            continue;
+                        int[] cluster = ((NarrowingHistoryLine) entry.value()).span;
+                        if (cluster[0] == origIndex && cluster[1] > cluster[0]) {
+                            currentDelegate = new MemoryHistory();
+                            for (int i = cluster[0]; i <= cluster[1]; i++) {
+                                currentDelegate.add(fullHistory.get(i));
+                            }
+                        }
+                    }
+                }
+            }
+            fullHistory.moveToEnd();
+            while (fullHistory.previous()) {
+                CharSequence c = fullHistory.current();
+                if (c instanceof NarrowingHistoryLine) {
+                    currentLine = (NarrowingHistoryLine) c;
+                    break;
+                }
+            }
+        } finally {
+            fullHistory.moveTo(origIndex);
+        }
+        if (currentLine == null || currentLine.span[1] != (-1)) {
+            line = currentLine = new NarrowingHistoryLine(line, fullSize);
+        }
+        StringBuilder complete = new StringBuilder();
+        for (int i = currentLine.span[0]; i < fullSize; i++) {
+            complete.append(fullHistory.get(i));
+        }
+        complete.append(line);
+        if (isComplete(complete)) {
+            currentLine.span[1] = fullSize; //TODO: +1?
+            currentDelegate = fullHistory;
+        }
+        fullHistory.add(line);
+    }
+
+    protected abstract boolean isComplete(CharSequence input);
+
+    @Override
+    public void set(int index, CharSequence item) {
+        if (currentDelegate != fullHistory)
+            throw new IllegalStateException("narrowed");
+        currentDelegate.set(index, item);
+    }
+
+    @Override
+    public CharSequence remove(int i) {
+        if (currentDelegate != fullHistory)
+            throw new IllegalStateException("narrowed");
+        return currentDelegate.remove(i);
+    }
+
+    @Override
+    public CharSequence removeFirst() {
+        if (currentDelegate != fullHistory)
+            throw new IllegalStateException("narrowed");
+        return currentDelegate.removeFirst();
+    }
+
+    @Override
+    public CharSequence removeLast() {
+        if (currentDelegate != fullHistory)
+            throw new IllegalStateException("narrowed");
+        return currentDelegate.removeLast();
+    }
+
+    @Override
+    public void replace(CharSequence item) {
+        if (currentDelegate != fullHistory)
+            throw new IllegalStateException("narrowed");
+        currentDelegate.replace(item);
+    }
+
+    @Override
+    public ListIterator<Entry> entries(int index) {
+        return currentDelegate.entries(index);
+    }
+
+    @Override
+    public ListIterator<Entry> entries() {
+        return currentDelegate.entries();
+    }
+
+    @Override
+    public Iterator<Entry> iterator() {
+        return currentDelegate.iterator();
+    }
+
+    @Override
+    public CharSequence current() {
+        return currentDelegate.current();
+    }
+
+    @Override
+    public boolean previous() {
+        return currentDelegate.previous();
+    }
+
+    @Override
+    public boolean next() {
+        return currentDelegate.next();
+    }
+
+    @Override
+    public boolean moveToFirst() {
+        return currentDelegate.moveToFirst();
+    }
+
+    @Override
+    public boolean moveToLast() {
+        return currentDelegate.moveToLast();
+    }
+
+    @Override
+    public boolean moveTo(int index) {
+        return currentDelegate.moveTo(index);
+    }
+
+    @Override
+    public void moveToEnd() {
+        currentDelegate.moveToEnd();
+    }
+
+    public boolean previousSnippet() {
+        for (int i = index() - 1; i >= 0; i--) {
+            if (get(i) instanceof NarrowingHistoryLine) {
+                moveTo(i);
+                return true;
+            }
+        }
+
+        return false;
+    }
+
+    public boolean nextSnippet() {
+        for (int i = index() + 1; i < size(); i++) {
+            if (get(i) instanceof NarrowingHistoryLine) {
+                moveTo(i);
+                return true;
+            }
+        }
+
+        if (index() < size()) {
+            moveToEnd();
+            return true;
+        }
+
+        return false;
+    }
+
+    public final void load(Iterable<? extends String> originalHistory) {
+        NarrowingHistoryLine currentHistoryLine = null;
+        boolean start = true;
+        int currentLine = 0;
+        for (String historyItem : originalHistory) {
+            StringBuilder line = new StringBuilder(historyItem);
+            int trailingBackSlashes = countTrailintBackslashes(line);
+            boolean continuation = trailingBackSlashes % 2 != 0;
+            line.delete(line.length() - trailingBackSlashes / 2 - (continuation ? 1 : 0), line.length());
+            if (start) {
+                class PersistentNarrowingHistoryLine extends NarrowingHistoryLine implements PersistentEntryMarker {
+                    public PersistentNarrowingHistoryLine(CharSequence delegate, int start) {
+                        super(delegate, start);
+                    }
+                }
+                fullHistory.add(currentHistoryLine = new PersistentNarrowingHistoryLine(line, currentLine));
+            } else {
+                class PersistentLine implements CharSequence, PersistentEntryMarker {
+                    private final CharSequence delegate;
+                    public PersistentLine(CharSequence delegate) {
+                        this.delegate = delegate;
+                    }
+                    @Override public int length() {
+                        return delegate.length();
+                    }
+                    @Override public char charAt(int index) {
+                        return delegate.charAt(index);
+                    }
+                    @Override public CharSequence subSequence(int start, int end) {
+                        return delegate.subSequence(start, end);
+                    }
+                    @Override public String toString() {
+                        return delegate.toString();
+                    }
+                }
+                fullHistory.add(new PersistentLine(line));
+            }
+            start = !continuation;
+            currentHistoryLine.span[1] = currentLine;
+            currentLine++;
+        }
+    }
+
+    public Collection<? extends String> save() {
+        Collection<String> result = new ArrayList<>();
+        Iterator<Entry> entries = fullHistory.iterator();
+
+        if (entries.hasNext()) {
+            Entry entry = entries.next();
+            while (entry != null) {
+                StringBuilder historyLine = new StringBuilder(entry.value());
+                int trailingBackSlashes = countTrailintBackslashes(historyLine);
+                for (int i = 0; i < trailingBackSlashes; i++) {
+                    historyLine.append("\\");
+                }
+                entry = entries.hasNext() ? entries.next() : null;
+                if (entry != null && !(entry.value() instanceof NarrowingHistoryLine)) {
+                    historyLine.append("\\");
+                }
+                result.add(historyLine.toString());
+            }
+        }
+
+        return result;
+    }
+
+    private int countTrailintBackslashes(CharSequence text) {
+        int count = 0;
+
+        for (int i = text.length() - 1; i >= 0; i--) {
+            if (text.charAt(i) == '\\') {
+                count++;
+            } else {
+                break;
+            }
+        }
+
+        return count;
+    }
+
+    public List<String> currentSessionEntries() {
+        List<String> result = new ArrayList<>();
+
+        for (Entry e : fullHistory) {
+            if (!(e.value() instanceof PersistentEntryMarker)) {
+                result.add(e.value().toString());
+            }
+        }
+
+        return result;
+    }
+
+    public void fullHistoryReplace(String source) {
+        fullHistory.replace(source);
+    }
+
+    private class NarrowingHistoryLine implements CharSequence {
+        private final CharSequence delegate;
+        private final int[] span;
+
+        public NarrowingHistoryLine(CharSequence delegate, int start) {
+            this.delegate = delegate;
+            this.span = new int[] {start, -1};
+        }
+
+        @Override
+        public int length() {
+            return delegate.length();
+        }
+
+        @Override
+        public char charAt(int index) {
+            return delegate.charAt(index);
+        }
+
+        @Override
+        public CharSequence subSequence(int start, int end) {
+            return delegate.subSequence(start, end);
+        }
+
+        @Override
+        public String toString() {
+            return delegate.toString();
+        }
+
+    }
+
+    private interface PersistentEntryMarker {}
+}
+
--- a/jdk/src/jdk.internal.le/share/classes/module-info.java	Thu May 19 17:48:02 2016 +0000
+++ b/jdk/src/jdk.internal.le/share/classes/module-info.java	Thu May 19 19:46:20 2016 +0000
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2015, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2015, 2016, Oracle and/or its affiliates. All rights reserved.
  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
  *
  * This code is free software; you can redistribute it and/or modify it
@@ -36,6 +36,9 @@
     exports jdk.internal.jline.console.history to
         jdk.scripting.nashorn.shell,
         jdk.jshell;
+    exports jdk.internal.jline.extra to
+        jdk.scripting.nashorn.shell,
+        jdk.jshell;
     exports jdk.internal.jline.internal to
         jdk.scripting.nashorn.shell,
         jdk.jshell;
--- a/jdk/src/jdk.jcmd/share/classes/jdk/internal/vm/agent/spi/ToolProvider.java	Thu May 19 17:48:02 2016 +0000
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,42 +0,0 @@
-/*
- * Copyright (c) 2016, 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.internal.vm.agent.spi;
-
-/**
- * Service interface for jdk.hotspot.agent to provide the tools that
- * jstack, jmap, jinfo will invoke, if present.
- */
-public interface ToolProvider {
-    /**
-     * Returns the name of the tool provider
-     */
-    String getName();
-
-    /**
-     * Invoke the tool provider with the given arguments
-     */
-    void run(String... arguments);
-}
--- a/jdk/src/jdk.jcmd/share/classes/jdk/internal/vm/agent/spi/ToolProviderFinder.java	Thu May 19 17:48:02 2016 +0000
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,46 +0,0 @@
-/*
- * Copyright (c) 2016, 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.internal.vm.agent.spi;
-
-import java.lang.reflect.Layer;
-import java.util.HashMap;
-import java.util.Map;
-import java.util.ServiceLoader;
-
-public final class ToolProviderFinder {
-    private static final Map<String, ToolProvider> providers = init();
-
-    public static ToolProvider find(String name) {
-        return providers.get(name);
-    }
-
-    private static Map<String, ToolProvider> init() {
-        Map<String, ToolProvider> providers = new HashMap<>();
-        ServiceLoader.load(Layer.boot(), ToolProvider.class)
-                     .forEach(p -> providers.putIfAbsent(p.getName(), p));
-        return providers;
-    }
-}
--- a/jdk/src/jdk.jcmd/share/classes/module-info.java	Thu May 19 17:48:02 2016 +0000
+++ b/jdk/src/jdk.jcmd/share/classes/module-info.java	Thu May 19 19:46:20 2016 +0000
@@ -26,9 +26,4 @@
 module jdk.jcmd {
     requires jdk.attach;
     requires jdk.jvmstat;
-
-    exports jdk.internal.vm.agent.spi to jdk.hotspot.agent;
-
-    uses jdk.internal.vm.agent.spi.ToolProvider;
 }
-
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/jdk/src/jdk.jcmd/share/classes/sun/tools/common/ProcessArgumentMatcher.java	Thu May 19 19:46:20 2016 +0000
@@ -0,0 +1,128 @@
+/*
+ * Copyright (c) 2016, 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 sun.tools.common;
+
+import java.net.URISyntaxException;
+import java.util.ArrayList;
+import java.util.Collection;
+import java.util.List;
+
+import com.sun.tools.attach.VirtualMachine;
+import com.sun.tools.attach.VirtualMachineDescriptor;
+
+import sun.jvmstat.monitor.MonitorException;
+import sun.jvmstat.monitor.MonitoredHost;
+import sun.jvmstat.monitor.MonitoredVm;
+import sun.jvmstat.monitor.MonitoredVmUtil;
+import sun.jvmstat.monitor.VmIdentifier;
+
+/**
+ * Class for finding process matching a process argument,
+ * excluding tool it self and returning a list containing
+ * the process identifiers.
+ */
+public class ProcessArgumentMatcher {
+    private String excludeCls;
+    private String matchClass = null;
+    private String singlePid = null;
+    private boolean matchAll = false;
+
+    public ProcessArgumentMatcher(String pidArg, Class<?> excludeClass) {
+        excludeCls = excludeClass.getName();
+        if (pidArg == null || pidArg.isEmpty()) {
+            throw new IllegalArgumentException("Pid string is invalid");
+        }
+        if (pidArg.charAt(0) == '-') {
+            throw new IllegalArgumentException("Unrecognized " + pidArg);
+        }
+        try {
+            long pid = Long.parseLong(pidArg);
+            if (pid == 0) {
+                matchAll = true;
+            } else {
+                singlePid = String.valueOf(pid);
+            }
+        } catch (NumberFormatException nfe) {
+            matchClass = pidArg;
+        }
+    }
+
+    private boolean check(VirtualMachineDescriptor vmd) {
+        String mainClass = null;
+        try {
+            VmIdentifier vmId = new VmIdentifier(vmd.id());
+            MonitoredHost monitoredHost = MonitoredHost.getMonitoredHost(vmId);
+            MonitoredVm monitoredVm = monitoredHost.getMonitoredVm(vmId, -1);
+            mainClass = MonitoredVmUtil.mainClass(monitoredVm, true);
+            monitoredHost.detach(monitoredVm);
+        } catch (NullPointerException npe) {
+            // There is a potential race, where a running java app is being
+            // queried, unfortunately the java app has shutdown after this
+            // method is started but before getMonitoredVM is called.
+            // If this is the case, then the /tmp/hsperfdata_xxx/pid file
+            // will have disappeared and we will get a NullPointerException.
+            // Handle this gracefully....
+            return false;
+        } catch (MonitorException | URISyntaxException e) {
+            if (e.getMessage() != null) {
+                System.err.println(e.getMessage());
+            } else {
+                Throwable cause = e.getCause();
+                if ((cause != null) && (cause.getMessage() != null)) {
+                    System.err.println(cause.getMessage());
+                } else {
+                    e.printStackTrace();
+                }
+            }
+            return false;
+        }
+
+        if (mainClass.equals(excludeCls)) {
+            return false;
+        }
+
+        if (matchAll || mainClass.indexOf(matchClass) != -1) {
+            return true;
+        }
+
+        return false;
+    }
+
+    public Collection<String> getPids() {
+        Collection<String> pids = new ArrayList<>();
+        if (singlePid != null) {
+            pids.add(singlePid);
+            return pids;
+        }
+        List<VirtualMachineDescriptor> vmds = VirtualMachine.list();
+        for (VirtualMachineDescriptor vmd : vmds) {
+            if (check(vmd)) {
+                pids.add(vmd.id());
+            }
+        }
+        return pids;
+    }
+}
--- a/jdk/src/jdk.jcmd/share/classes/sun/tools/jcmd/Arguments.java	Thu May 19 17:48:02 2016 +0000
+++ b/jdk/src/jdk.jcmd/share/classes/sun/tools/jcmd/Arguments.java	Thu May 19 19:46:20 2016 +0000
@@ -33,16 +33,14 @@
     private boolean listProcesses = false;
     private boolean listCounters  = false;
     private boolean showUsage     = false;
-    private int     pid           = -1;
     private String  command       = null;
-    private String  processSubstring;
+    private String  processString = null;
 
     public boolean isListProcesses() { return listProcesses; }
     public boolean isListCounters() { return listCounters; }
     public boolean isShowUsage() { return showUsage; }
-    public int getPid() { return pid; }
     public String getCommand() { return command; }
-    public String getProcessSubstring() { return processSubstring; }
+    public String getProcessString() { return processString; }
 
     public Arguments(String[] args) {
         if (args.length == 0 || args[0].equals("-l")) {
@@ -55,15 +53,7 @@
             return;
         }
 
-        try {
-            pid = Integer.parseInt(args[0]);
-        } catch (NumberFormatException ex) {
-            // use as a partial class-name instead
-            if (args[0].charAt(0) != '-') {
-                // unless it starts with a '-'
-                processSubstring = args[0];
-            }
-        }
+        processString = args[0];
 
         StringBuilder sb = new StringBuilder();
         for (int i = 1; i < args.length; i++) {
--- a/jdk/src/jdk.jcmd/share/classes/sun/tools/jcmd/JCmd.java	Thu May 19 17:48:02 2016 +0000
+++ b/jdk/src/jdk.jcmd/share/classes/sun/tools/jcmd/JCmd.java	Thu May 19 19:46:20 2016 +0000
@@ -29,22 +29,22 @@
 import java.io.IOException;
 import java.io.UnsupportedEncodingException;
 import java.util.List;
-import java.util.ArrayList;
+import java.util.Collection;
+import java.util.Collections;
 import java.util.Comparator;
 import java.net.URISyntaxException;
 
 import com.sun.tools.attach.AttachOperationFailedException;
 import com.sun.tools.attach.VirtualMachine;
 import com.sun.tools.attach.VirtualMachineDescriptor;
-import com.sun.tools.attach.AgentLoadException;
 import com.sun.tools.attach.AttachNotSupportedException;
 
 import sun.tools.attach.HotSpotVirtualMachine;
+import sun.tools.common.ProcessArgumentMatcher;
 import sun.tools.jstat.JStatLogger;
 import sun.jvmstat.monitor.Monitor;
 import sun.jvmstat.monitor.MonitoredHost;
 import sun.jvmstat.monitor.MonitoredVm;
-import sun.jvmstat.monitor.MonitoredVmUtil;
 import sun.jvmstat.monitor.MonitorException;
 import sun.jvmstat.monitor.VmIdentifier;
 
@@ -73,52 +73,18 @@
             System.exit(0);
         }
 
-        List<String> pids = new ArrayList<String>();
-        if (arg.getPid() == 0) {
-            // find all VMs
-            List<VirtualMachineDescriptor> vmds = VirtualMachine.list();
-            for (VirtualMachineDescriptor vmd : vmds) {
-                if (!isJCmdProcess(vmd)) {
-                    pids.add(vmd.id());
-                }
-            }
-        } else if (arg.getProcessSubstring() != null) {
-            // use the partial class-name match
-            List<VirtualMachineDescriptor> vmds = VirtualMachine.list();
-            for (VirtualMachineDescriptor vmd : vmds) {
-                if (isJCmdProcess(vmd)) {
-                    continue;
-                }
-                try {
-                    String mainClass = getMainClass(vmd);
-                    if (mainClass != null
-                        && mainClass.indexOf(arg.getProcessSubstring()) != -1) {
-                            pids.add(vmd.id());
-                    }
-                } catch (MonitorException|URISyntaxException e) {
-                    if (e.getMessage() != null) {
-                        System.err.println(e.getMessage());
-                    } else {
-                        Throwable cause = e.getCause();
-                        if ((cause != null) && (cause.getMessage() != null)) {
-                            System.err.println(cause.getMessage());
-                        } else {
-                            e.printStackTrace();
-                        }
-                    }
-                }
-            }
-            if (pids.isEmpty()) {
-                System.err.println("Could not find any processes matching : '"
-                                   + arg.getProcessSubstring() + "'");
-                System.exit(1);
-            }
-        } else if (arg.getPid() == -1) {
+        Collection<String> pids = Collections.emptyList();
+        try {
+            ProcessArgumentMatcher ap = new ProcessArgumentMatcher(arg.getProcessString(), JCmd.class);
+            pids = ap.getPids();
+        } catch (IllegalArgumentException iae) {
             System.err.println("Invalid pid specified");
             System.exit(1);
-        } else {
-            // Use the found pid
-            pids.add(arg.getPid() + "");
+        }
+        if (pids.isEmpty()) {
+            System.err.println("Could not find any processes matching : '"
+                               + arg.getProcessString() + "'");
+            System.exit(1);
         }
 
         boolean success = true;
@@ -199,36 +165,6 @@
         }
     }
 
-    private static boolean isJCmdProcess(VirtualMachineDescriptor vmd) {
-        try {
-            String mainClass = getMainClass(vmd);
-            return mainClass != null && mainClass.equals(JCmd.class.getName());
-        } catch (URISyntaxException|MonitorException ex) {
-            return false;
-        }
-    }
-
-    private static String getMainClass(VirtualMachineDescriptor vmd)
-            throws URISyntaxException, MonitorException {
-        try {
-            String mainClass = null;
-            VmIdentifier vmId = new VmIdentifier(vmd.id());
-            MonitoredHost monitoredHost = MonitoredHost.getMonitoredHost(vmId);
-            MonitoredVm monitoredVm = monitoredHost.getMonitoredVm(vmId, -1);
-            mainClass = MonitoredVmUtil.mainClass(monitoredVm, true);
-            monitoredHost.detach(monitoredVm);
-            return mainClass;
-        } catch(NullPointerException e) {
-            // There is a potential race, where a running java app is being
-            // queried, unfortunately the java app has shutdown after this
-            // method is started but before getMonitoredVM is called.
-            // If this is the case, then the /tmp/hsperfdata_xxx/pid file
-            // will have disappeared and we will get a NullPointerException.
-            // Handle this gracefully....
-            return null;
-        }
-    }
-
     /**
      * Class to compare two Monitor objects by name in ascending order.
      * (from jstat)
--- a/jdk/src/jdk.jcmd/share/classes/sun/tools/jinfo/JInfo.java	Thu May 19 17:48:02 2016 +0000
+++ b/jdk/src/jdk.jcmd/share/classes/sun/tools/jinfo/JInfo.java	Thu May 19 19:46:20 2016 +0000
@@ -25,15 +25,14 @@
 
 package sun.tools.jinfo;
 
-import java.util.Arrays;
 import java.io.IOException;
 import java.io.InputStream;
+import java.util.Collection;
 
 import com.sun.tools.attach.VirtualMachine;
 
 import sun.tools.attach.HotSpotVirtualMachine;
-import jdk.internal.vm.agent.spi.ToolProvider;
-import jdk.internal.vm.agent.spi.ToolProviderFinder;
+import sun.tools.common.ProcessArgumentMatcher;
 
 /*
  * This class is the main class for the JInfo utility. It parses its arguments
@@ -41,157 +40,96 @@
  * or an SA tool.
  */
 final public class JInfo {
-    private static final String SA_JINFO_TOOL_NAME = "jinfo";
-    private boolean useSA = false;
-    private String[] args = null;
 
-    private JInfo(String[] args) throws IllegalArgumentException {
+    public static void main(String[] args) throws Exception {
         if (args.length == 0) {
-            throw new IllegalArgumentException();
+            usage(1); // no arguments
         }
+        checkForUnsupportedOptions(args);
 
-        int argCopyIndex = 0;
-        // First determine if we should launch SA or not
-        if (args[0].equals("-F")) {
-            // delete the -F
-            argCopyIndex = 1;
-            useSA = true;
-        } else if (args[0].equals("-flags")
-                   || args[0].equals("-sysprops"))
-        {
-            if (args.length == 2) {
-                if (!isPid(args[1])) {
-                    // If args[1] doesn't parse to a number then
-                    // it must be the SA debug server
-                    // (otherwise it is the pid)
-                    useSA = true;
-                }
-            } else if (args.length == 3) {
-                // arguments include an executable and a core file
-                useSA = true;
-            } else {
-                throw new IllegalArgumentException();
+        boolean doFlag = false;
+        boolean doFlags = false;
+        boolean doSysprops = false;
+
+        // Parse the options (arguments starting with "-" )
+        int optionCount = 0;
+        while (optionCount < args.length) {
+            String arg = args[optionCount];
+            if (!arg.startsWith("-")) {
+                break;
             }
-        } else if (!args[0].startsWith("-")) {
-            if (args.length == 2) {
-                // the only arguments are an executable and a core file
-                useSA = true;
-            } else if (args.length == 1) {
-                if (!isPid(args[0])) {
-                    // The only argument is not a PID; it must be SA debug
-                    // server
-                    useSA = true;
-                }
-            } else {
-                throw new IllegalArgumentException();
+
+            optionCount++;
+
+            if (arg.equals("-help") || arg.equals("-h")) {
+                usage(0);
             }
-        } else if (args[0].equals("-h") || args[0].equals("-help")) {
-            if (args.length > 1) {
-                throw new IllegalArgumentException();
+
+            if (arg.equals("-flag")) {
+                doFlag = true;
+                continue;
             }
-        } else if (args[0].equals("-flag")) {
-            if (args.length == 3) {
-                if (!isPid(args[2])) {
-                    throw new IllegalArgumentException();
-                }
-            } else {
-                throw new IllegalArgumentException();
+
+            if (arg.equals("-flags")) {
+                doFlags = true;
+                continue;
             }
-        } else {
-            throw new IllegalArgumentException();
-        }
 
-        this.args = Arrays.copyOfRange(args, argCopyIndex, args.length);
-    }
-
-    @SuppressWarnings("fallthrough")
-    private void execute() throws Exception {
-        if (args[0].equals("-h")
-            || args[0].equals("-help")) {
-            usage(0);
+            if (arg.equals("-sysprops")) {
+                doSysprops = true;
+                continue;
+            }
         }
 
-        if (useSA) {
-            // SA only supports -flags or -sysprops
-            if (args[0].startsWith("-")) {
-                if (!(args[0].equals("-flags") || args[0].equals("-sysprops"))) {
-                    usage(1);
+        // Next we check the parameter count. -flag allows extra parameters
+        int paramCount = args.length - optionCount;
+        if ((doFlag && paramCount != 2) || ((!doFlag && paramCount != 1))) {
+            usage(1);
+        }
+
+        if (!doFlag && !doFlags && !doSysprops) {
+            // Print flags and sysporps if no options given
+            ProcessArgumentMatcher ap = new ProcessArgumentMatcher(args[optionCount], JInfo.class);
+            Collection<String> pids = ap.getPids();
+            for (String pid : pids) {
+                if (pids.size() > 1) {
+                    System.out.println("Pid:" + pid);
+                }
+                sysprops(pid);
+                System.out.println();
+                flags(pid);
+                System.out.println();
+                commandLine(pid);
+            }
+        }
+
+        if (doFlag) {
+            ProcessArgumentMatcher ap = new ProcessArgumentMatcher(args[optionCount+1], JInfo.class);
+            Collection<String> pids = ap.getPids();
+            for (String pid : pids) {
+                if (pids.size() > 1) {
+                    System.out.println("Pid:" + pid);
+                }
+                flag(pid, args[optionCount]);
+            }
+        }
+        else if (doFlags || doSysprops) {
+            ProcessArgumentMatcher ap = new ProcessArgumentMatcher(args[optionCount], JInfo.class);
+            Collection<String> pids = ap.getPids();
+            for (String pid : pids) {
+                if (pids.size() > 1) {
+                    System.out.println("Pid:" + pid);
+                }
+                if (doFlags) {
+                    flags(pid);
+                }
+                else if (doSysprops) {
+                    sysprops(pid);
                 }
             }
-
-            // invoke SA which does it's own argument parsing
-            runTool();
-
-        } else {
-            // Now we can parse arguments for the non-SA case
-            String pid = null;
-
-            switch(args[0]) {
-                case "-flag":
-                    if (args.length != 3) {
-                        usage(1);
-                    }
-                    String option = args[1];
-                    pid = args[2];
-                    flag(pid, option);
-                    break;
-                case "-flags":
-                    if (args.length != 2) {
-                        usage(1);
-                    }
-                    pid = args[1];
-                    flags(pid);
-                    break;
-                case "-sysprops":
-                    if (args.length != 2) {
-                        usage(1);
-                    }
-                    pid = args[1];
-                    sysprops(pid);
-                    break;
-                case "-help":
-                case "-h":
-                    usage(0);
-                    // Fall through
-                default:
-                    if (args.length == 1) {
-                        // no flags specified, we do -sysprops and -flags
-                        pid = args[0];
-                        sysprops(pid);
-                        System.out.println();
-                        flags(pid);
-                        System.out.println();
-                        commandLine(pid);
-                    } else {
-                        usage(1);
-                    }
-            }
         }
     }
 
-    public static void main(String[] args) throws Exception {
-        JInfo jinfo = null;
-        try {
-            jinfo = new JInfo(args);
-            jinfo.execute();
-        } catch (IllegalArgumentException e) {
-            usage(1);
-        }
-    }
-
-    private static boolean isPid(String arg) {
-        return arg.matches("[0-9]+");
-    }
-
-    // Invoke SA tool with the given arguments
-    private void runTool() throws Exception {
-        ToolProvider tool = ToolProviderFinder.find(SA_JINFO_TOOL_NAME);
-        if (tool == null) {
-            usage(1);
-        }
-        tool.run(args);
-    }
-
     private static void flag(String pid, String option) throws IOException {
         HotSpotVirtualMachine vm = (HotSpotVirtualMachine) attach(pid);
         String flag;
@@ -274,46 +212,49 @@
         vm.detach();
     }
 
-
-    // print usage message
-    private static void usage(int exit) {
-        boolean usageSA = ToolProviderFinder.find(SA_JINFO_TOOL_NAME) != null;
+    private static void checkForUnsupportedOptions(String[] args) {
+        // Check arguments for -F, and non-numeric value
+        // and warn the user that SA is not supported anymore
+        int maxCount = 1;
+        int paramCount = 0;
 
-        System.err.println("Usage:");
-        if (usageSA) {
-            System.err.println("    jinfo [option] <pid>");
-            System.err.println("        (to connect to a running process)");
-            System.err.println("    jinfo -F [option] <pid>");
-            System.err.println("        (to connect to a hung process)");
-            System.err.println("    jinfo [option] <executable> <core>");
-            System.err.println("        (to connect to a core file)");
-            System.err.println("    jinfo [option] [server_id@]<remote server IP or hostname>");
-            System.err.println("        (to connect to remote debug server)");
-            System.err.println("");
-            System.err.println("where <option> is one of:");
-            System.err.println("  for running processes:");
-            System.err.println("    -flag <name>         to print the value of the named VM flag");
-            System.err.println("    -flag [+|-]<name>    to enable or disable the named VM flag");
-            System.err.println("    -flag <name>=<value> to set the named VM flag to the given value");
-            System.err.println("  for running or hung processes and core files:");
-            System.err.println("    -flags               to print VM flags");
-            System.err.println("    -sysprops            to print Java system properties");
-            System.err.println("    <no option>          to print both VM flags and system properties");
-            System.err.println("    -h | -help           to print this help message");
-        } else {
-            System.err.println("    jinfo <option> <pid>");
-            System.err.println("       (to connect to a running process)");
-            System.err.println("");
-            System.err.println("where <option> is one of:");
-            System.err.println("    -flag <name>         to print the value of the named VM flag");
-            System.err.println("    -flag [+|-]<name>    to enable or disable the named VM flag");
-            System.err.println("    -flag <name>=<value> to set the named VM flag to the given value");
-            System.err.println("    -flags               to print VM flags");
-            System.err.println("    -sysprops            to print Java system properties");
-            System.err.println("    <no option>          to print both VM flags and system properties");
-            System.err.println("    -h | -help           to print this help message");
+        for (String s : args) {
+            if (s.equals("-F")) {
+                SAOptionError("-F option used");
+            }
+            if (s.equals("-flag")) {
+                maxCount = 2;
+            }
+            if (! s.startsWith("-")) {
+                paramCount += 1;
+            }
         }
 
+        if (paramCount > maxCount) {
+            SAOptionError("More than " + maxCount + " non-option argument");
+        }
+    }
+
+    private static void SAOptionError(String msg) {
+        System.err.println("Error: " + msg);
+        System.err.println("Cannot connect to core dump or remote debug server. Use jhsdb jinfo instead");
+        System.exit(1);
+    }
+
+     // print usage message
+    private static void usage(int exit) {
+        System.err.println("Usage:");
+        System.err.println("    jinfo <option> <pid>");
+        System.err.println("       (to connect to a running process)");
+        System.err.println("");
+        System.err.println("where <option> is one of:");
+        System.err.println("    -flag <name>         to print the value of the named VM flag");
+        System.err.println("    -flag [+|-]<name>    to enable or disable the named VM flag");
+        System.err.println("    -flag <name>=<value> to set the named VM flag to the given value");
+        System.err.println("    -flags               to print VM flags");
+        System.err.println("    -sysprops            to print Java system properties");
+        System.err.println("    <no option>          to print both VM flags and system properties");
+        System.err.println("    -h | -help           to print this help message");
         System.exit(exit);
     }
 }
--- a/jdk/src/jdk.jcmd/share/classes/sun/tools/jmap/JMap.java	Thu May 19 17:48:02 2016 +0000
+++ b/jdk/src/jdk.jcmd/share/classes/sun/tools/jmap/JMap.java	Thu May 19 19:46:20 2016 +0000
@@ -28,12 +28,13 @@
 import java.io.File;
 import java.io.IOException;
 import java.io.InputStream;
+import java.io.UnsupportedEncodingException;
+import java.util.Collection;
 
 import com.sun.tools.attach.VirtualMachine;
 import com.sun.tools.attach.AttachNotSupportedException;
 import sun.tools.attach.HotSpotVirtualMachine;
-import jdk.internal.vm.agent.spi.ToolProvider;
-import jdk.internal.vm.agent.spi.ToolProviderFinder;
+import sun.tools.common.ProcessArgumentMatcher;
 
 /*
  * This class is the main class for the JMap utility. It parses its arguments
@@ -44,34 +45,18 @@
  */
 public class JMap {
 
-    // Options handled by the attach mechanism
-    private static String HISTO_OPTION = "-histo";
-    private static String LIVE_HISTO_OPTION = "-histo:live";
-    private static String DUMP_OPTION_PREFIX = "-dump:";
-
-    // These options imply the use of a SA tool
-    private static String SA_TOOL_OPTIONS =
-      "-heap|-heap:format=b|-clstats|-finalizerinfo";
-
-    // The -F (force) option is currently not passed through to SA
-    private static String FORCE_SA_OPTION = "-F";
-
-    // Default option (if nothing provided)
-    private static String DEFAULT_OPTION = "-pmap";
-
     public static void main(String[] args) throws Exception {
         if (args.length == 0) {
             usage(1); // no arguments
         }
 
-        // used to indicate if we should use SA
-        boolean useSA = false;
+        checkForUnsupportedOptions(args);
 
-        // the chosen option (-heap, -dump:*, ... )
+        // the chosen option
         String option = null;
 
         // First iterate over the options (arguments starting with -).  There should be
-        // one (but maybe two if -F is also used).
+        // one.
         int optionCount = 0;
         while (optionCount < args.length) {
             String arg = args[optionCount];
@@ -80,8 +65,6 @@
             }
             if (arg.equals("-help") || arg.equals("-h")) {
                 usage(0);
-            } else if (arg.equals(FORCE_SA_OPTION)) {
-                useSA = true;
             } else {
                 if (option != null) {
                     usage(1);  // option already specified
@@ -93,123 +76,102 @@
 
         // if no option provided then use default.
         if (option == null) {
-            option = DEFAULT_OPTION;
-        }
-        if (option.matches(SA_TOOL_OPTIONS)) {
-            useSA = true;
+            usage(0);
         }
 
-        // Next we check the parameter count. For the SA tools there are
-        // one or two parameters. For the built-in -dump option there is
-        // only one parameter (the process-id)
+        // Next we check the parameter count.
         int paramCount = args.length - optionCount;
-        if (paramCount == 0 || paramCount > 2) {
+        if (paramCount != 1) {
             usage(1);
         }
 
-        if (optionCount == 0 || paramCount != 1) {
-            useSA = true;
-        } else {
-            // the parameter for the -dump option is a process-id.
-            // If it doesn't parse to a number then it must be SA
-            // debug server
-            if (!args[optionCount].matches("[0-9]+")) {
-                useSA = true;
+        String pidArg = args[1];
+        // Here we handle the built-in options
+        // As more options are added we should create an abstract tool class and
+        // have a table to map the options
+        ProcessArgumentMatcher ap = new ProcessArgumentMatcher(pidArg, JMap.class);
+        Collection<String> pids = ap.getPids();
+        for (String pid : pids) {
+            if (pids.size() > 1) {
+                System.out.println("Pid:" + pid);
             }
-        }
-
-
-        // at this point we know if we are executing an SA tool or a built-in
-        // option.
-
-        if (useSA) {
-            // parameters (<pid> or <exe> <core>)
-            String params[] = new String[paramCount];
-            for (int i=optionCount; i<args.length; i++ ){
-                params[i-optionCount] = args[i];
-            }
-            runTool(option, params);
-
-        } else {
-            String pid = args[1];
-            // Here we handle the built-in options
-            // As more options are added we should create an abstract tool class and
-            // have a table to map the options
-            if (option.equals(HISTO_OPTION)) {
-                histo(pid, false);
-            } else if (option.equals(LIVE_HISTO_OPTION)) {
-                histo(pid, true);
-            } else if (option.startsWith(DUMP_OPTION_PREFIX)) {
-                dump(pid, option);
+            if (option.equals("-histo")) {
+                histo(pid, "");
+            } else if (option.startsWith("-histo:")) {
+                histo(pid, option.substring("-histo:".length()));
+            } else if (option.startsWith("-dump:")) {
+                dump(pid, option.substring("-dump:".length()));
+            } else if (option.equals("-finalizerinfo")) {
+                executeCommandForPid(pid, "jcmd", "GC.finalizer_info");
+            } else if (option.equals("-clstats")) {
+                executeCommandForPid(pid, "jcmd", "GC.class_stats");
             } else {
-                usage(1);
+              usage(1);
             }
         }
     }
 
-    // Invoke SA tool  with the given arguments
-    private static void runTool(String option, String args[]) throws Exception {
-        String[][] tools = {
-            { "-pmap",          "pmap"             },
-            { "-heap",          "heapSummary"      },
-            { "-heap:format=b", "heapDumper"       },
-            { "-histo",         "objectHistogram"  },
-            { "-clstats",       "classLoaderStats" },
-            { "-finalizerinfo", "finalizerInfo"    },
-        };
-
-        String name = null;
-
-        // -dump option needs to be handled in a special way
-        if (option.startsWith(DUMP_OPTION_PREFIX)) {
-            // first check that the option can be parsed
-            String fn = parseDumpOptions(option);
-            if (fn == null) {
-                usage(1);
-            }
+    private static void executeCommandForPid(String pid, String command, Object ... args)
+        throws AttachNotSupportedException, IOException,
+               UnsupportedEncodingException {
+        VirtualMachine vm = VirtualMachine.attach(pid);
 
-            // tool for heap dumping
-            name = "heapDumper";
+        // Cast to HotSpotVirtualMachine as this is an
+        // implementation specific method.
+        HotSpotVirtualMachine hvm = (HotSpotVirtualMachine) vm;
+        try (InputStream in = hvm.executeCommand(command, args)) {
+          // read to EOF and just print output
+          byte b[] = new byte[256];
+          int n;
+          do {
+              n = in.read(b);
+              if (n > 0) {
+                  String s = new String(b, 0, n, "UTF-8");
+                  System.out.print(s);
+              }
+          } while (n > 0);
+        }
+        vm.detach();
+    }
 
-            // HeapDumper -f <file>
-            args = prepend(fn, args);
-            args = prepend("-f", args);
-        } else {
-            int i=0;
-            while (i < tools.length) {
-                if (option.equals(tools[i][0])) {
-                    name = tools[i][1];
-                    break;
-                }
-                i++;
-            }
+    private static void histo(String pid, String options)
+        throws AttachNotSupportedException, IOException,
+               UnsupportedEncodingException {
+        String liveopt = "-all";
+        if (options.equals("") || options.equals("all")) {
+            //  pass
         }
-        if (name == null) {
-            usage(1);   // no mapping to tool
+        else if (options.equals("live")) {
+            liveopt = "-live";
         }
-
-        // Tool not available on this platform.
-        ToolProvider tool = ToolProviderFinder.find(name);
-        if (tool == null) {
+        else {
             usage(1);
         }
 
-        // invoke the main method with the arguments
-        tool.run(args);
+        // inspectHeap is not the same as jcmd GC.class_histogram
+        executeCommandForPid(pid, "inspectheap", liveopt);
     }
 
-    private static final String LIVE_OBJECTS_OPTION = "-live";
-    private static final String ALL_OBJECTS_OPTION = "-all";
-    private static void histo(String pid, boolean live) throws IOException {
-        VirtualMachine vm = attach(pid);
-        InputStream in = ((HotSpotVirtualMachine)vm).
-            heapHisto(live ? LIVE_OBJECTS_OPTION : ALL_OBJECTS_OPTION);
-        drain(vm, in);
-    }
+    private static void dump(String pid, String options)
+        throws AttachNotSupportedException, IOException,
+               UnsupportedEncodingException {
+
+        String subopts[] = options.split(",");
+        String filename = null;
+        String liveopt = "-all";
 
-    private static void dump(String pid, String options) throws IOException {
-        // parse the options to get the dump filename
-        String filename = parseDumpOptions(options);
+        for (int i = 0; i < subopts.length; i++) {
+            String subopt = subopts[i];
+            if (subopt.equals("live")) {
+                liveopt = "-live";
+            } else if (subopt.startsWith("file=")) {
+                // file=<file> - check that <file> is specified
+                if (subopt.length() > 5) {
+                    filename = subopt.substring(5);
+                }
+            }
+        }
+
         if (filename == null) {
             usage(1);  // invalid options or no filename
         }
@@ -219,156 +181,73 @@
         // working directory rather than the directory where jmap
         // is executed.
         filename = new File(filename).getCanonicalPath();
-
-        // dump live objects only or not
-        boolean live = isDumpLiveObjects(options);
-
-        VirtualMachine vm = attach(pid);
-        System.out.println("Dumping heap to " + filename + " ...");
-        InputStream in = ((HotSpotVirtualMachine)vm).
-            dumpHeap((Object)filename,
-                     (live ? LIVE_OBJECTS_OPTION : ALL_OBJECTS_OPTION));
-        drain(vm, in);
+        // dumpHeap is not the same as jcmd GC.heap_dump
+        executeCommandForPid(pid, "dumpheap", filename, liveopt);
     }
 
-    // Parse the options to the -dump option. Valid options are format=b and
-    // file=<file>. Returns <file> if provided. Returns null if <file> not
-    // provided, or invalid option.
-    private static String parseDumpOptions(String arg) {
-        assert arg.startsWith(DUMP_OPTION_PREFIX);
+    private static void checkForUnsupportedOptions(String[] args) {
+        // Check arguments for -F, -m, and non-numeric value
+        // and warn the user that SA is not supported anymore
+
+        int paramCount = 0;
 
-        String filename = null;
+        for (String s : args) {
+            if (s.equals("-F")) {
+                SAOptionError("-F option used");
+            }
 
-        // options are separated by comma (,)
-        String options[] = arg.substring(DUMP_OPTION_PREFIX.length()).split(",");
-
-        for (int i=0; i<options.length; i++) {
-            String option = options[i];
+            if (s.equals("-heap")) {
+                SAOptionError("-heap option used");
+            }
 
-            if (option.equals("format=b")) {
-                // ignore format (not needed at this time)
-            } else if (option.equals("live")) {
-                // a valid suboption
-            } else {
+            /* Reimplemented using jcmd, output format is different
+               from original one
+
+            if (s.equals("-clstats")) {
+                warnSA("-clstats option used");
+            }
 
-                // file=<file> - check that <file> is specified
-                if (option.startsWith("file=")) {
-                    filename = option.substring(5);
-                    if (filename.length() == 0) {
-                        return null;
-                    }
-                } else {
-                    return null;  // option not recognized
-                }
+            if (s.equals("-finalizerinfo")) {
+                warnSA("-finalizerinfo option used");
+            }
+            */
+
+            if (! s.startsWith("-")) {
+                paramCount += 1;
             }
         }
-        return filename;
-    }
 
-    private static boolean isDumpLiveObjects(String arg) {
-        // options are separated by comma (,)
-        String options[] = arg.substring(DUMP_OPTION_PREFIX.length()).split(",");
-        for (String suboption : options) {
-            if (suboption.equals("live")) {
-                return true;
-            }
-        }
-        return false;
-    }
-
-    // Attach to <pid>, existing if we fail to attach
-    private static VirtualMachine attach(String pid) {
-        try {
-            return VirtualMachine.attach(pid);
-        } catch (Exception x) {
-            String msg = x.getMessage();
-            if (msg != null) {
-                System.err.println(pid + ": " + msg);
-            } else {
-                x.printStackTrace();
-            }
-            if ((x instanceof AttachNotSupportedException) && haveSA()) {
-                System.err.println("The -F option can be used when the " +
-                  "target process is not responding");
-            }
-            System.exit(1);
-            return null; // keep compiler happy
+        if (paramCount > 1) {
+            SAOptionError("More than one non-option argument");
         }
     }
 
-    // Read the stream from the target VM until EOF, then detach
-    private static void drain(VirtualMachine vm, InputStream in) throws IOException {
-        // read to EOF and just print output
-        byte b[] = new byte[256];
-        int n;
-        do {
-            n = in.read(b);
-            if (n > 0) {
-                String s = new String(b, 0, n, "UTF-8");
-                System.out.print(s);
-            }
-        } while (n > 0);
-        in.close();
-        vm.detach();
-    }
-
-    // return a new string array with arg as the first element
-    private static String[] prepend(String arg, String args[]) {
-        String[] newargs = new String[args.length+1];
-        newargs[0] = arg;
-        System.arraycopy(args, 0, newargs, 1, args.length);
-        return newargs;
-    }
-
-    // returns true if SA is available
-    private static boolean haveSA() {
-        return ToolProviderFinder.find("heapSummary") != null;
+    private static void SAOptionError(String msg) {
+        System.err.println("Error: " + msg);
+        System.err.println("Cannot connect to core dump or remote debug server. Use jhsdb jmap instead");
+        System.exit(1);
     }
 
     // print usage message
     private static void usage(int exit) {
         System.err.println("Usage:");
-        if (haveSA()) {
-            System.err.println("    jmap [option] <pid>");
-            System.err.println("        (to connect to running process)");
-            System.err.println("    jmap [option] <executable <core>");
-            System.err.println("        (to connect to a core file)");
-            System.err.println("    jmap [option] [server_id@]<remote server IP or hostname>");
-            System.err.println("        (to connect to remote debug server)");
-            System.err.println("");
-            System.err.println("where <option> is one of:");
-            System.err.println("    <none>               to print same info as Solaris pmap");
-            System.err.println("    -heap                to print java heap summary");
-            System.err.println("    -histo[:live]        to print histogram of java object heap; if the \"live\"");
-            System.err.println("                         suboption is specified, only count live objects");
-            System.err.println("    -clstats             to print class loader statistics");
-            System.err.println("    -finalizerinfo       to print information on objects awaiting finalization");
-            System.err.println("    -dump:<dump-options> to dump java heap in hprof binary format");
-            System.err.println("                         dump-options:");
-            System.err.println("                           live         dump only live objects; if not specified,");
-            System.err.println("                                        all objects in the heap are dumped.");
-            System.err.println("                           format=b     binary format");
-            System.err.println("                           file=<file>  dump heap to <file>");
-            System.err.println("                         Example: jmap -dump:live,format=b,file=heap.bin <pid>");
-            System.err.println("    -F                   force. Use with -dump:<dump-options> <pid> or -histo");
-            System.err.println("                         to force a heap dump or histogram when <pid> does not");
-            System.err.println("                         respond. The \"live\" suboption is not supported");
-            System.err.println("                         in this mode.");
-            System.err.println("    -h | -help           to print this help message");
-            System.err.println("    -J<flag>             to pass <flag> directly to the runtime system");
-        } else {
-            System.err.println("    jmap -histo <pid>");
-            System.err.println("      (to connect to running process and print histogram of java object heap");
-            System.err.println("    jmap -dump:<dump-options> <pid>");
-            System.err.println("      (to connect to running process and dump java heap)");
-            System.err.println("");
-            System.err.println("    dump-options:");
-            System.err.println("      format=b     binary default");
-            System.err.println("      file=<file>  dump heap to <file>");
-            System.err.println("");
-            System.err.println("    Example:       jmap -dump:format=b,file=heap.bin <pid>");
-        }
-
+        System.err.println("    jmap -clstats <pid>");
+        System.err.println("        to connect to running process and print class loader statistics");
+        System.err.println("    jmap -finalizerinfo <pid>");
+        System.err.println("        to connect to running process and print information on objects awaiting finalization");
+        System.err.println("    jmap -histo[:live] <pid>");
+        System.err.println("        to connect to running process and print histogram of java object heap");
+        System.err.println("        if the \"live\" suboption is specified, only count live objects");
+        System.err.println("    jmap -dump:<dump-options> <pid>");
+        System.err.println("        to connect to running process and dump java heap");
+        System.err.println("");
+        System.err.println("    dump-options:");
+        System.err.println("      live         dump only live objects; if not specified,");
+        System.err.println("                   all objects in the heap are dumped.");
+        System.err.println("      format=b     binary format");
+        System.err.println("      file=<file>  dump heap to <file>");
+        System.err.println("");
+        System.err.println("    Example: jmap -dump:live,format=b,file=heap.bin <pid>");
         System.exit(exit);
     }
 }
--- a/jdk/src/jdk.jcmd/share/classes/sun/tools/jstack/JStack.java	Thu May 19 17:48:02 2016 +0000
+++ b/jdk/src/jdk.jcmd/share/classes/sun/tools/jstack/JStack.java	Thu May 19 19:46:20 2016 +0000
@@ -26,12 +26,11 @@
 package sun.tools.jstack;
 
 import java.io.InputStream;
+import java.util.Collection;
 
 import com.sun.tools.attach.VirtualMachine;
-import com.sun.tools.attach.AttachNotSupportedException;
 import sun.tools.attach.HotSpotVirtualMachine;
-import jdk.internal.vm.agent.spi.ToolProvider;
-import jdk.internal.vm.agent.spi.ToolProviderFinder;
+import sun.tools.common.ProcessArgumentMatcher;
 
 /*
  * This class is the main class for the JStack utility. It parses its arguments
@@ -39,15 +38,14 @@
  * obtained the thread dump from a target process using the VM attach mechanism
  */
 public class JStack {
-    private static final String SA_JSTACK_TOOL_NAME = "jstack";
 
     public static void main(String[] args) throws Exception {
         if (args.length == 0) {
             usage(1); // no arguments
         }
 
-        boolean useSA = false;
-        boolean mixed = false;
+        checkForUnsupportedOptions(args);
+
         boolean locks = false;
 
         // Parse the options (arguments starting with "-" )
@@ -60,87 +58,40 @@
             if (arg.equals("-help") || arg.equals("-h")) {
                 usage(0);
             }
-            else if (arg.equals("-F")) {
-                useSA = true;
-            }
             else {
-                if (arg.equals("-m")) {
-                    mixed = true;
+                if (arg.equals("-l")) {
+                    locks = true;
                 } else {
-                    if (arg.equals("-l")) {
-                       locks = true;
-                    } else {
-                        usage(1);
-                    }
+                    usage(1);
                 }
             }
             optionCount++;
         }
 
-        // mixed stack implies SA tool
-        if (mixed) {
-            useSA = true;
-        }
-
-        // Next we check the parameter count. If there are two parameters
-        // we assume core file and executable so we use SA.
+        // Next we check the parameter count.
         int paramCount = args.length - optionCount;
-        if (paramCount == 0 || paramCount > 2) {
+        if (paramCount != 1) {
             usage(1);
         }
-        if (paramCount == 2) {
-            useSA = true;
+
+        // pass -l to thread dump operation to get extra lock info
+        String pidArg = args[optionCount];
+        String params[];
+        if (locks) {
+            params = new String[] { "-l" };
         } else {
-            // If we can't parse it as a pid then it must be debug server
-            if (!args[optionCount].matches("[0-9]+")) {
-                useSA = true;
-            }
+            params = new String[0];
         }
-
-        // now execute using the SA JStack tool or the built-in thread dumper
-        if (useSA) {
-            // parameters (<pid> or <exe> <core>
-            String params[] = new String[paramCount];
-            for (int i=optionCount; i<args.length; i++ ){
-                params[i-optionCount] = args[i];
-            }
-            runJStackTool(mixed, locks, params);
-        } else {
-            // pass -l to thread dump operation to get extra lock info
-            String pid = args[optionCount];
-            String params[];
-            if (locks) {
-                params = new String[] { "-l" };
-            } else {
-                params = new String[0];
+        ProcessArgumentMatcher ap = new ProcessArgumentMatcher(pidArg, JStack.class);
+        Collection<String> pids = ap.getPids();
+        for (String pid : pids) {
+            if (pids.size() > 1) {
+                System.out.println("Pid:" + pid);
             }
             runThreadDump(pid, params);
         }
     }
 
-    // SA JStack tool
-    private static boolean isAgentToolPresent() {
-        return ToolProviderFinder.find(SA_JSTACK_TOOL_NAME) != null;
-    }
-
-    private static void runJStackTool(boolean mixed, boolean locks, String args[]) throws Exception {
-        ToolProvider tool = ToolProviderFinder.find(SA_JSTACK_TOOL_NAME);
-        if (tool == null) {
-            usage(1);            // SA not available
-        }
-
-        // JStack tool also takes -m and -l arguments
-        if (mixed) {
-            args = prepend("-m", args);
-        }
-        if (locks) {
-            args = prepend("-l", args);
-        }
-
-        tool.run(args);
-    }
-
-
     // Attach to pid and perform a thread dump
     private static void runThreadDump(String pid, String args[]) throws Exception {
         VirtualMachine vm = null;
@@ -153,10 +104,6 @@
             } else {
                 x.printStackTrace();
             }
-            if ((x instanceof AttachNotSupportedException) && isAgentToolPresent()) {
-                System.err.println("The -F option can be used when the target " +
-                    "process is not responding");
-            }
             System.exit(1);
         }
 
@@ -178,12 +125,35 @@
         vm.detach();
     }
 
-    // return a new string array with arg as the first element
-    private static String[] prepend(String arg, String args[]) {
-        String[] newargs = new String[args.length+1];
-        newargs[0] = arg;
-        System.arraycopy(args, 0, newargs, 1, args.length);
-        return newargs;
+    private static void checkForUnsupportedOptions(String[] args) {
+        // Check arguments for -F, -m, and non-numeric value
+        // and warn the user that SA is not supported anymore
+
+        int paramCount = 0;
+
+        for (String s : args) {
+            if (s.equals("-F")) {
+                SAOptionError("-F option used");
+            }
+
+            if (s.equals("-m")) {
+                SAOptionError("-m option used");
+            }
+
+            if (! s.startsWith("-")) {
+                paramCount += 1;
+            }
+        }
+
+        if (paramCount > 1) {
+            SAOptionError("More than one non-option argument");
+        }
+    }
+
+    private static void SAOptionError(String msg) {
+        System.err.println("Error: " + msg);
+        System.err.println("Cannot connect to core dump or remote debug server. Use jhsdb jstack instead");
+        System.exit(1);
     }
 
     // print usage message
@@ -191,25 +161,8 @@
         System.err.println("Usage:");
         System.err.println("    jstack [-l] <pid>");
         System.err.println("        (to connect to running process)");
-
-        if (isAgentToolPresent()) {
-            System.err.println("    jstack -F [-m] [-l] <pid>");
-            System.err.println("        (to connect to a hung process)");
-            System.err.println("    jstack [-m] [-l] <executable> <core>");
-            System.err.println("        (to connect to a core file)");
-            System.err.println("    jstack [-m] [-l] [server_id@]<remote server IP or hostname>");
-            System.err.println("        (to connect to a remote debug server)");
-        }
-
         System.err.println("");
         System.err.println("Options:");
-
-        if (isAgentToolPresent()) {
-            System.err.println("    -F  to force a thread dump. Use when jstack <pid> does not respond" +
-                " (process is hung)");
-            System.err.println("    -m  to print both java and native frames (mixed mode)");
-        }
-
         System.err.println("    -l  long listing. Prints additional information about locks");
         System.err.println("    -h or -help to print this help message");
         System.exit(exit);
--- a/jdk/src/jdk.jdi/share/classes/com/sun/tools/example/debug/tty/Commands.java	Thu May 19 17:48:02 2016 +0000
+++ b/jdk/src/jdk.jdi/share/classes/com/sun/tools/example/debug/tty/Commands.java	Thu May 19 19:46:20 2016 +0000
@@ -1534,7 +1534,6 @@
             PathSearchingVirtualMachine vm = (PathSearchingVirtualMachine)Env.vm();
             MessageOutput.println("base directory:", vm.baseDirectory());
             MessageOutput.println("classpath:", vm.classPath().toString());
-            MessageOutput.println("bootclasspath:", vm.bootClassPath().toString());
         } else {
             MessageOutput.println("The VM does not use paths");
         }
--- a/jdk/src/jdk.jdi/share/classes/com/sun/tools/example/debug/tty/EventHandler.java	Thu May 19 17:48:02 2016 +0000
+++ b/jdk/src/jdk.jdi/share/classes/com/sun/tools/example/debug/tty/EventHandler.java	Thu May 19 19:46:20 2016 +0000
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 1998, 2011, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 1998, 2016, 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
@@ -133,6 +133,10 @@
             if (!vmDied) {
                 vmDisconnectEvent(event);
             }
+            /*
+             * Inform jdb command line processor that jdb is being shutdown. JDK-8154144.
+             */
+            ((TTY)notifier).setShuttingDown(true);
             Env.shutdown(shutdownMessageKey);
             return false;
         } else {
--- a/jdk/src/jdk.jdi/share/classes/com/sun/tools/example/debug/tty/TTY.java	Thu May 19 17:48:02 2016 +0000
+++ b/jdk/src/jdk.jdi/share/classes/com/sun/tools/example/debug/tty/TTY.java	Thu May 19 19:46:20 2016 +0000
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 1998, 2011, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 1998, 2016, 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
@@ -56,6 +56,16 @@
      */
     private static final String progname = "jdb";
 
+    private volatile boolean shuttingDown = false;
+
+    public void setShuttingDown(boolean s) {
+       shuttingDown = s;
+    }
+
+    public boolean isShuttingDown() {
+        return shuttingDown;
+    }
+
     @Override
     public void vmStartEvent(VMStartEvent se)  {
         Thread.yield();  // fetch output
@@ -750,7 +760,13 @@
             while (true) {
                 String ln = in.readLine();
                 if (ln == null) {
-                    MessageOutput.println("Input stream closed.");
+                    /*
+                     *  Jdb is being shutdown because debuggee exited, ignore any 'null'
+                     *  returned by readLine() during shutdown. JDK-8154144.
+                     */
+                    if (!isShuttingDown()) {
+                        MessageOutput.println("Input stream closed.");
+                    }
                     ln = "quit";
                 }
 
--- a/jdk/src/jdk.jdi/share/classes/com/sun/tools/example/debug/tty/TTYResources.java	Thu May 19 17:48:02 2016 +0000
+++ b/jdk/src/jdk.jdi/share/classes/com/sun/tools/example/debug/tty/TTYResources.java	Thu May 19 19:46:20 2016 +0000
@@ -74,7 +74,6 @@
         {"Array element is not a method", "Array element is not a method"},
         {"Array index must be a integer type", "Array index must be a integer type"},
         {"base directory:", "base directory: {0}"},
-        {"bootclasspath:", "bootclasspath: {0}"},
         {"Breakpoint hit:", "Breakpoint hit: "},
         {"breakpoint", "breakpoint {0}"},
         {"Breakpoints set:", "Breakpoints set:"},
--- a/jdk/src/jdk.jdi/share/classes/com/sun/tools/example/debug/tty/TTYResources_ja.java	Thu May 19 17:48:02 2016 +0000
+++ b/jdk/src/jdk.jdi/share/classes/com/sun/tools/example/debug/tty/TTYResources_ja.java	Thu May 19 19:46:20 2016 +0000
@@ -74,7 +74,6 @@
         {"Array element is not a method", "\u914D\u5217\u8981\u7D20\u306F\u30E1\u30BD\u30C3\u30C9\u3067\u306F\u3042\u308A\u307E\u305B\u3093"},
         {"Array index must be a integer type", "\u914D\u5217\u306E\u6DFB\u3048\u5B57\u306F\u6574\u6570\u578B\u3067\u3042\u308B\u5FC5\u8981\u304C\u3042\u308A\u307E\u3059"},
         {"base directory:", "\u30D9\u30FC\u30B9\u30FB\u30C7\u30A3\u30EC\u30AF\u30C8\u30EA: {0}"},
-        {"bootclasspath:", "\u30D6\u30FC\u30C8\u30FB\u30AF\u30E9\u30B9\u30D1\u30B9: {0}"},
         {"Breakpoint hit:", "\u30D2\u30C3\u30C8\u3057\u305F\u30D6\u30EC\u30FC\u30AF\u30DD\u30A4\u30F3\u30C8: "},
         {"breakpoint", "\u30D6\u30EC\u30FC\u30AF\u30DD\u30A4\u30F3\u30C8{0}"},
         {"Breakpoints set:", "\u8A2D\u5B9A\u3055\u308C\u3066\u3044\u308B\u30D6\u30EC\u30FC\u30AF\u30DD\u30A4\u30F3\u30C8:"},
--- a/jdk/src/jdk.jdi/share/classes/com/sun/tools/example/debug/tty/TTYResources_zh_CN.java	Thu May 19 17:48:02 2016 +0000
+++ b/jdk/src/jdk.jdi/share/classes/com/sun/tools/example/debug/tty/TTYResources_zh_CN.java	Thu May 19 19:46:20 2016 +0000
@@ -74,7 +74,6 @@
         {"Array element is not a method", "\u6570\u7EC4\u5143\u7D20\u4E0D\u662F\u65B9\u6CD5"},
         {"Array index must be a integer type", "\u6570\u7EC4\u7D22\u5F15\u5FC5\u987B\u4E3A\u6574\u6570\u7C7B\u578B"},
         {"base directory:", "\u57FA\u76EE\u5F55: {0}"},
-        {"bootclasspath:", "\u5F15\u5BFC\u7C7B\u8DEF\u5F84: {0}"},
         {"Breakpoint hit:", "\u65AD\u70B9\u547D\u4E2D: "},
         {"breakpoint", "\u65AD\u70B9{0}"},
         {"Breakpoints set:", "\u65AD\u70B9\u96C6:"},
--- a/jdk/src/jdk.jdi/share/classes/com/sun/tools/jdi/VirtualMachineImpl.java	Thu May 19 17:48:02 2016 +0000
+++ b/jdk/src/jdk.jdi/share/classes/com/sun/tools/jdi/VirtualMachineImpl.java	Thu May 19 19:46:20 2016 +0000
@@ -1439,7 +1439,7 @@
    }
 
    public List<String> bootClassPath() {
-       return Arrays.asList(getClasspath().bootclasspaths);
+       return Collections.emptyList();
    }
 
    public String baseDirectory() {
--- a/jdk/src/jdk.jdwp.agent/share/native/libjdwp/VirtualMachineImpl.c	Thu May 19 17:48:02 2016 +0000
+++ b/jdk/src/jdk.jdwp.agent/share/native/libjdwp/VirtualMachineImpl.c	Thu May 19 19:46:20 2016 +0000
@@ -126,7 +126,7 @@
             int writtenCount = 0;
             int i;
 
-            for (i=0; i<classCount; i++) {
+            for (i = 0; i < classCount; i++) {
                 jclass clazz = theClasses[i];
                 jint status = classStatus(clazz);
                 char *candidate_signature = NULL;
@@ -141,7 +141,13 @@
 
                 error = classSignature(clazz, &candidate_signature, NULL);
                 if (error != JVMTI_ERROR_NONE) {
-                    break;
+                  // Clazz become invalid since the time we get the class list
+                  // Skip this entry
+                  if (error == JVMTI_ERROR_INVALID_CLASS) {
+                    continue;
+                  }
+
+                  break;
                 }
 
                 if (strcmp(candidate_signature, signature) == 0) {
--- a/jdk/src/jdk.jdwp.agent/share/native/libjdwp/invoker.c	Thu May 19 17:48:02 2016 +0000
+++ b/jdk/src/jdk.jdwp.agent/share/native/libjdwp/invoker.c	Thu May 19 19:46:20 2016 +0000
@@ -277,12 +277,14 @@
 
     JDI_ASSERT(thread);
 
+    debugMonitorEnter(invokerLock);
     request = threadControl_getInvokeRequest(thread);
     if (request == NULL) {
         EXIT_ERROR(AGENT_ERROR_INVALID_THREAD, "getting thread invoke request");
     }
 
     request->available = JNI_TRUE;
+    debugMonitorExit(invokerLock);
 }
 
 jvmtiError
@@ -739,29 +741,20 @@
 }
 
 jboolean
-invoker_isPending(jthread thread)
+invoker_isEnabled(jthread thread)
 {
     InvokeRequest *request;
+    jboolean isEnabled;
 
     JDI_ASSERT(thread);
+    debugMonitorEnter(invokerLock);
     request = threadControl_getInvokeRequest(thread);
     if (request == NULL) {
         EXIT_ERROR(AGENT_ERROR_INVALID_THREAD, "getting thread invoke request");
     }
-    return request->pending;
-}
-
-jboolean
-invoker_isEnabled(jthread thread)
-{
-    InvokeRequest *request;
-
-    JDI_ASSERT(thread);
-    request = threadControl_getInvokeRequest(thread);
-    if (request == NULL) {
-        EXIT_ERROR(AGENT_ERROR_INVALID_THREAD, "getting thread invoke request");
-    }
-    return request->available;
+    isEnabled = request->available;
+    debugMonitorExit(invokerLock);
+    return isEnabled;
 }
 
 void
--- a/jdk/src/jdk.jdwp.agent/share/native/libjdwp/invoker.h	Thu May 19 17:48:02 2016 +0000
+++ b/jdk/src/jdk.jdwp.agent/share/native/libjdwp/invoker.h	Thu May 19 19:46:20 2016 +0000
@@ -67,7 +67,6 @@
 jboolean invoker_doInvoke(jthread thread);
 
 void invoker_completeInvokeRequest(jthread thread);
-jboolean invoker_isPending(jthread thread);
 jboolean invoker_isEnabled(jthread thread);
 void invoker_detach(InvokeRequest *request);
 
--- a/jdk/src/jdk.jlink/share/classes/jdk/tools/jlink/Jlink.java	Thu May 19 17:48:02 2016 +0000
+++ b/jdk/src/jdk.jlink/share/classes/jdk/tools/jlink/Jlink.java	Thu May 19 19:46:20 2016 +0000
@@ -34,11 +34,9 @@
 import java.util.Set;
 import jdk.tools.jlink.internal.JlinkTask;
 import jdk.tools.jlink.plugin.Plugin;
-import jdk.tools.jlink.plugin.PluginContext;
 import jdk.tools.jlink.plugin.PluginException;
 import jdk.tools.jlink.plugin.ExecutableImage;
 import jdk.tools.jlink.builder.ImageBuilder;
-import jdk.tools.jlink.internal.PluginContextImpl;
 import jdk.tools.jlink.internal.PluginRepository;
 
 /**
@@ -71,7 +69,6 @@
         private final List<Plugin> plugins;
         private final ImageBuilder imageBuilder;
         private final String lastSorterPluginName;
-        private final PluginContext pluginContext;
 
         /**
          * Empty plugins configuration.
@@ -86,7 +83,7 @@
          * @param plugins List of plugins.
          */
         public PluginsConfiguration(List<Plugin> plugins) {
-            this(plugins, null, null, null);
+            this(plugins, null, null);
         }
 
         /**
@@ -101,28 +98,10 @@
          */
         public PluginsConfiguration(List<Plugin> plugins,
                 ImageBuilder imageBuilder, String lastSorterPluginName) {
-            this(plugins, imageBuilder, lastSorterPluginName, null);
-        }
-
-        /**
-         * Plugins configuration with a last sorter and an ImageBuilder. No
-         * sorting can occur after the last sorter plugin. The ImageBuilder is
-         * in charge to layout the image content on disk.
-         *
-         * @param plugins List of transformer plugins.
-         * @param imageBuilder Image builder.
-         * @param lastSorterPluginName Name of last sorter plugin, no sorting
-         * @param ctx the plugin context
-         * can occur after it.
-         */
-        public PluginsConfiguration(List<Plugin> plugins,
-                ImageBuilder imageBuilder, String lastSorterPluginName,
-                PluginContext ctx) {
             this.plugins = plugins == null ? Collections.emptyList()
                     : plugins;
             this.imageBuilder = imageBuilder;
             this.lastSorterPluginName = lastSorterPluginName;
-            this.pluginContext = ctx != null? ctx : new PluginContextImpl();
         }
 
         /**
@@ -146,13 +125,6 @@
             return lastSorterPluginName;
         }
 
-        /**
-         * @return the pluginContext
-         */
-        public PluginContext getPluginContext() {
-            return pluginContext;
-        }
-
         @Override
         public String toString() {
             StringBuilder builder = new StringBuilder();
--- a/jdk/src/jdk.jlink/share/classes/jdk/tools/jlink/builder/DefaultImageBuilder.java	Thu May 19 17:48:02 2016 +0000
+++ b/jdk/src/jdk.jlink/share/classes/jdk/tools/jlink/builder/DefaultImageBuilder.java	Thu May 19 19:46:20 2016 +0000
@@ -1,3 +1,4 @@
+
 /*
  * Copyright (c) 2015, Oracle and/or its affiliates. All rights reserved.
  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
@@ -24,8 +25,6 @@
  */
 package jdk.tools.jlink.builder;
 
-import jdk.tools.jlink.plugin.ExecutableImage;
-import jdk.tools.jlink.plugin.PluginException;
 import java.io.BufferedOutputStream;
 import java.io.BufferedWriter;
 import java.io.ByteArrayInputStream;
@@ -47,8 +46,10 @@
 import java.nio.file.attribute.PosixFileAttributeView;
 import java.nio.file.attribute.PosixFilePermission;
 import java.util.ArrayList;
+import java.util.Collections;
 import java.util.HashSet;
 import java.util.List;
+import java.util.Map;
 import java.util.Objects;
 import java.util.Optional;
 import java.util.Properties;
@@ -56,23 +57,40 @@
 import jdk.tools.jlink.internal.BasicImageWriter;
 import jdk.tools.jlink.internal.plugins.FileCopierPlugin;
 import jdk.tools.jlink.internal.plugins.FileCopierPlugin.SymImageFile;
-import jdk.tools.jlink.plugin.Pool;
-import jdk.tools.jlink.plugin.Pool.Module;
-import jdk.tools.jlink.plugin.Pool.ModuleData;
+import jdk.tools.jlink.plugin.ExecutableImage;
+import jdk.tools.jlink.plugin.ModulePool;
+import jdk.tools.jlink.plugin.ModuleEntry;
+import jdk.tools.jlink.plugin.PluginException;
 
 /**
  *
  * Default Image Builder. This builder creates the default runtime image layout.
  */
-public class DefaultImageBuilder implements ImageBuilder {
+public final class DefaultImageBuilder implements ImageBuilder {
 
     /**
      * The default java executable Image.
      */
-    static class DefaultExecutableImage extends ExecutableImage {
+    static final class DefaultExecutableImage implements ExecutableImage {
+
+        private final Path home;
+        private final List<String> args;
+        private final Set<String> modules;
 
         public DefaultExecutableImage(Path home, Set<String> modules) {
-            super(home, modules, createArgs(home));
+            this(home, modules, createArgs(home));
+        }
+
+        private DefaultExecutableImage(Path home, Set<String> modules,
+                List<String> args) {
+            Objects.requireNonNull(home);
+            Objects.requireNonNull(args);
+            if (!Files.exists(home)) {
+                throw new IllegalArgumentException("Invalid image home");
+            }
+            this.home = home;
+            this.modules = Collections.unmodifiableSet(modules);
+            this.args = Collections.unmodifiableList(args);
         }
 
         private static List<String> createArgs(Path home) {
@@ -84,6 +102,21 @@
         }
 
         @Override
+        public Path getHome() {
+            return home;
+        }
+
+        @Override
+        public Set<String> getModules() {
+            return modules;
+        }
+
+        @Override
+        public List<String> getExecutionArgs() {
+            return args;
+        }
+
+        @Override
         public void storeLaunchArgs(List<String> args) {
             try {
                 patchScripts(this, args);
@@ -111,17 +144,19 @@
         Files.createDirectories(mdir);
     }
 
-    private void storeFiles(Set<String> modules, Properties release) throws IOException {
+    private void storeFiles(Set<String> modules, Map<String, String> release) throws IOException {
         if (release != null) {
-            addModules(release, modules);
+            Properties props = new Properties();
+            props.putAll(release);
+            addModules(props, modules);
             File r = new File(root.toFile(), "release");
             try (FileOutputStream fo = new FileOutputStream(r)) {
-                release.store(fo, null);
+                props.store(fo, null);
             }
         }
     }
 
-    private void addModules(Properties release, Set<String> modules) throws IOException {
+    private void addModules(Properties props, Set<String> modules) throws IOException {
         StringBuilder builder = new StringBuilder();
         int i = 0;
         for (String m : modules) {
@@ -131,28 +166,32 @@
             }
             i++;
         }
-        release.setProperty("MODULES", builder.toString());
+        props.setProperty("MODULES", builder.toString());
     }
 
     @Override
-    public void storeFiles(Pool files, Properties release) {
+    public void storeFiles(ModulePool files) {
         try {
-            for (ModuleData f : files.getContent()) {
-               if (!f.getType().equals(Pool.ModuleDataType.CLASS_OR_RESOURCE)) {
-                    accept(f);
+            files.entries().forEach(f -> {
+                if (!f.getType().equals(ModuleEntry.Type.CLASS_OR_RESOURCE)) {
+                    try {
+                        accept(f);
+                    } catch (IOException ioExp) {
+                        throw new UncheckedIOException(ioExp);
+                    }
                 }
-            }
-            for (Module m : files.getModules()) {
+            });
+            files.modules().forEach(m -> {
                 // Only add modules that contain packages
                 if (!m.getAllPackages().isEmpty()) {
                     // Skip the fake module used by FileCopierPlugin when copying files.
                     if (m.getName().equals(FileCopierPlugin.FAKE_MODULE)) {
-                       continue;
+                        return;
                     }
                     modules.add(m.getName());
                 }
-            }
-            storeFiles(modules, release);
+            });
+            storeFiles(modules, files.getReleaseProperties());
 
             if (Files.getFileStore(root).supportsFileAttributeView(PosixFileAttributeView.class)) {
                 // launchers in the bin directory need execute permission
@@ -168,8 +207,8 @@
                 Path lib = root.resolve("lib");
                 if (Files.isDirectory(lib)) {
                     Files.find(lib, 2, (path, attrs) -> {
-                        return path.getFileName().toString().equals("jspawnhelper") ||
-                               path.getFileName().toString().equals("jexec");
+                        return path.getFileName().toString().equals("jspawnhelper")
+                                || path.getFileName().toString().equals("jexec");
                     }).forEach(this::setExecutable);
                 }
             }
@@ -180,27 +219,23 @@
         }
     }
 
-    @Override
-    public void storeFiles(Pool files) {
-        storeFiles(files, new Properties());
-    }
-
     /**
      * Generates launcher scripts.
+     *
      * @param imageContent The image content.
      * @param modules The set of modules that the runtime image contains.
      * @throws IOException
      */
-    protected void prepareApplicationFiles(Pool imageContent, Set<String> modules) throws IOException {
+    protected void prepareApplicationFiles(ModulePool imageContent, Set<String> modules) throws IOException {
         // generate launch scripts for the modules with a main class
         for (String module : modules) {
             String path = "/" + module + "/module-info.class";
-            ModuleData res = imageContent.get(path);
-            if (res == null) {
+            Optional<ModuleEntry> res = imageContent.findEntry(path);
+            if (!res.isPresent()) {
                 throw new IOException("module-info.class not found for " + module + " module");
             }
             Optional<String> mainClass;
-            ByteArrayInputStream stream = new ByteArrayInputStream(res.getBytes());
+            ByteArrayInputStream stream = new ByteArrayInputStream(res.get().getBytes());
             mainClass = ModuleDescriptor.read(stream).mainClass();
             if (mainClass.isPresent()) {
                 Path cmd = root.resolve("bin").resolve(module);
@@ -263,9 +298,9 @@
         }
     }
 
-    private void accept(ModuleData file) throws IOException {
+    private void accept(ModuleEntry file) throws IOException {
         String fullPath = file.getPath();
-        String module = "/" + file.getModule()+ "/";
+        String module = "/" + file.getModule() + "/";
         String filename = fullPath.substring(module.length());
         // Remove radical native|config|...
         filename = filename.substring(filename.indexOf('/') + 1);
@@ -404,8 +439,7 @@
 
     public static ExecutableImage getExecutableImage(Path root) {
         if (Files.exists(root.resolve("bin").resolve(getJavaProcessName()))) {
-            return new DefaultImageBuilder.DefaultExecutableImage(root,
-                    retrieveModules(root));
+            return new DefaultExecutableImage(root, retrieveModules(root));
         }
         return null;
     }
--- a/jdk/src/jdk.jlink/share/classes/jdk/tools/jlink/builder/ImageBuilder.java	Thu May 19 17:48:02 2016 +0000
+++ b/jdk/src/jdk.jlink/share/classes/jdk/tools/jlink/builder/ImageBuilder.java	Thu May 19 19:46:20 2016 +0000
@@ -29,7 +29,7 @@
 
 import jdk.tools.jlink.plugin.ExecutableImage;
 import jdk.tools.jlink.plugin.PluginException;
-import jdk.tools.jlink.plugin.Pool;
+import jdk.tools.jlink.plugin.ModulePool;
 
 /**
  * Implement this interface to develop your own image layout. First the jimage
@@ -45,7 +45,7 @@
      * @param release the release properties
      * @throws PluginException
      */
-    public default void storeFiles(Pool content, Properties release) {
+    public default void storeFiles(ModulePool content, Properties release) {
         storeFiles(content);
     }
 
@@ -55,7 +55,7 @@
      * @param content Pool of module content.
      * @throws PluginException
      */
-    public default void storeFiles(Pool content) {
+    public default void storeFiles(ModulePool content) {
         throw new UnsupportedOperationException("storeFiles");
     }
 
--- a/jdk/src/jdk.jlink/share/classes/jdk/tools/jlink/internal/ImageFileCreator.java	Thu May 19 17:48:02 2016 +0000
+++ b/jdk/src/jdk.jlink/share/classes/jdk/tools/jlink/internal/ImageFileCreator.java	Thu May 19 19:46:20 2016 +0000
@@ -44,12 +44,11 @@
 import java.util.stream.Stream;
 import jdk.tools.jlink.internal.Archive.Entry;
 import jdk.tools.jlink.internal.Archive.Entry.EntryType;
-import jdk.tools.jlink.internal.PoolImpl.CompressedModuleData;
+import jdk.tools.jlink.internal.ModulePoolImpl.CompressedModuleData;
 import jdk.tools.jlink.plugin.ExecutableImage;
 import jdk.tools.jlink.plugin.PluginException;
-import jdk.tools.jlink.plugin.Pool;
-import jdk.tools.jlink.plugin.Pool.ModuleData;
-import jdk.tools.jlink.plugin.Pool.ModuleDataType;
+import jdk.tools.jlink.plugin.ModulePool;
+import jdk.tools.jlink.plugin.ModuleEntry;
 
 /**
  * An image (native endian.)
@@ -145,7 +144,7 @@
                                     }));
             ByteOrder order = ByteOrder.nativeOrder();
             BasicImageWriter writer = new BasicImageWriter(order);
-            PoolImpl pool = createPools(archives, entriesForModule, order, writer);
+            ModulePoolImpl pool = createPools(archives, entriesForModule, order, writer);
             try (OutputStream fos = Files.newOutputStream(jimageFile);
                     BufferedOutputStream bos = new BufferedOutputStream(fos);
                     DataOutputStream out = new DataOutputStream(bos)) {
@@ -163,9 +162,9 @@
             ByteOrder byteOrder)
             throws IOException {
         BasicImageWriter writer = new BasicImageWriter(byteOrder);
-        PoolImpl allContent = createPools(archives,
+        ModulePoolImpl allContent = createPools(archives,
                 entriesForModule, byteOrder, writer);
-        PoolImpl result = generateJImage(allContent,
+        ModulePoolImpl result = generateJImage(allContent,
              writer, plugins, plugins.getJImageFileOutputStream());
 
         //Handle files.
@@ -176,12 +175,12 @@
         }
     }
 
-    private static PoolImpl generateJImage(PoolImpl allContent,
+    private static ModulePoolImpl generateJImage(ModulePoolImpl allContent,
             BasicImageWriter writer,
             ImagePluginStack pluginSupport,
             DataOutputStream out
     ) throws IOException {
-        PoolImpl resultResources;
+        ModulePoolImpl resultResources;
         try {
             resultResources = pluginSupport.visitResources(allContent);
         } catch (PluginException pe) {
@@ -190,14 +189,14 @@
             throw new IOException(ex);
         }
         Set<String> duplicates = new HashSet<>();
-        long offset = 0;
+        long[] offset = new long[1];
 
-        List<ModuleData> content = new ArrayList<>();
+        List<ModuleEntry> content = new ArrayList<>();
         List<String> paths = new ArrayList<>();
                  // the order of traversing the resources and the order of
         // the module content being written must be the same
-        for (ModuleData res : resultResources.getContent()) {
-            if (res.getType().equals(ModuleDataType.CLASS_OR_RESOURCE)) {
+        resultResources.entries().forEach(res -> {
+            if (res.getType().equals(ModuleEntry.Type.CLASS_OR_RESOURCE)) {
                 String path = res.getPath();
                 content.add(res);
                 long uncompressedSize = res.getLength();
@@ -216,24 +215,24 @@
                     // TODO Need to hang bytes on resource and write
                     // from resource not zip.
                     // Skipping resource throws off writing from zip.
-                    offset += onFileSize;
-                    continue;
+                    offset[0] += onFileSize;
+                    return;
                 }
                 duplicates.add(path);
-                writer.addLocation(path, offset, compressedSize, uncompressedSize);
+                writer.addLocation(path, offset[0], compressedSize, uncompressedSize);
                 paths.add(path);
-                offset += onFileSize;
+                offset[0] += onFileSize;
             }
-        }
+        });
 
-        ImageResourcesTree tree = new ImageResourcesTree(offset, writer, paths);
+        ImageResourcesTree tree = new ImageResourcesTree(offset[0], writer, paths);
 
         // write header and indices
         byte[] bytes = writer.getBytes();
         out.write(bytes, 0, bytes.length);
 
         // write module content
-        for (ModuleData res : content) {
+        for (ModuleEntry res : content) {
             byte[] buf = res.getBytes();
             out.write(buf, 0, buf.length);
         }
@@ -245,26 +244,26 @@
         return resultResources;
     }
 
-    private static Pool.ModuleDataType mapImageFileType(EntryType type) {
+    private static ModuleEntry.Type mapImageFileType(EntryType type) {
         switch(type) {
             case CONFIG: {
-                return Pool.ModuleDataType.CONFIG;
+                return ModuleEntry.Type.CONFIG;
             }
             case NATIVE_CMD: {
-                return Pool.ModuleDataType.NATIVE_CMD;
+                return ModuleEntry.Type.NATIVE_CMD;
             }
             case NATIVE_LIB: {
-                return Pool.ModuleDataType.NATIVE_LIB;
+                return ModuleEntry.Type.NATIVE_LIB;
             }
         }
         return null;
     }
 
-    private static PoolImpl createPools(Set<Archive> archives,
+    private static ModulePoolImpl createPools(Set<Archive> archives,
             Map<String, List<Entry>> entriesForModule,
             ByteOrder byteOrder,
             BasicImageWriter writer) throws IOException {
-        PoolImpl resources = new PoolImpl(byteOrder, new StringTable() {
+        ModulePoolImpl resources = new ModulePoolImpl(byteOrder, new StringTable() {
 
             @Override
             public int addString(String str) {
@@ -291,7 +290,7 @@
                             path = "/" + mn + "/" + path;
                         }
                         try {
-                            resources.add(Pool.newResource(path, bytes));
+                            resources.add(ModuleEntry.create(path, bytes));
                         } catch (Exception ex) {
                             throw new IOException(ex);
                         }
@@ -300,7 +299,7 @@
                     try {
                         // Entry.path() contains the kind of file native, conf, bin, ...
                         // Keep it to avoid naming conflict (eg: native/jvm.cfg and config/jvm.cfg
-                        resources.add(Pool.newImageFile(mn,
+                        resources.add(ModuleEntry.create(mn,
                                 "/" + mn + "/" + entry.path(), mapImageFileType(entry.type()),
                                 entry.stream(), entry.size()));
                     } catch (Exception ex) {
--- a/jdk/src/jdk.jlink/share/classes/jdk/tools/jlink/internal/ImagePluginConfiguration.java	Thu May 19 17:48:02 2016 +0000
+++ b/jdk/src/jdk.jlink/share/classes/jdk/tools/jlink/internal/ImagePluginConfiguration.java	Thu May 19 19:46:20 2016 +0000
@@ -28,22 +28,17 @@
 
 import java.io.IOException;
 import java.util.ArrayList;
-import java.util.Collections;
-import java.util.HashMap;
 import java.util.LinkedHashMap;
 import java.util.List;
 import java.util.Map;
 import java.util.Map.Entry;
-import java.util.Objects;
-import java.util.Properties;
 import jdk.tools.jlink.plugin.ExecutableImage;
 import jdk.tools.jlink.builder.ImageBuilder;
 import jdk.tools.jlink.Jlink;
 import jdk.tools.jlink.plugin.Plugin;
-import jdk.tools.jlink.plugin.PluginContext;
 import jdk.tools.jlink.plugin.PluginException;
-import jdk.tools.jlink.plugin.Plugin.CATEGORY;
-import jdk.tools.jlink.plugin.Pool;
+import jdk.tools.jlink.plugin.Plugin.Category;
+import jdk.tools.jlink.plugin.ModulePool;
 import jdk.tools.jlink.plugin.PostProcessorPlugin;
 import jdk.tools.jlink.plugin.TransformerPlugin;
 
@@ -52,17 +47,18 @@
  */
 public final class ImagePluginConfiguration {
 
-    private static final List<Plugin.CATEGORY> CATEGORIES_ORDER = new ArrayList<>();
+    private static final List<Plugin.Category> CATEGORIES_ORDER = new ArrayList<>();
 
     static {
-        CATEGORIES_ORDER.add(Plugin.CATEGORY.FILTER);
-        CATEGORIES_ORDER.add(Plugin.CATEGORY.TRANSFORMER);
-        CATEGORIES_ORDER.add(Plugin.CATEGORY.MODULEINFO_TRANSFORMER);
-        CATEGORIES_ORDER.add(Plugin.CATEGORY.SORTER);
-        CATEGORIES_ORDER.add(Plugin.CATEGORY.COMPRESSOR);
-        CATEGORIES_ORDER.add(Plugin.CATEGORY.VERIFIER);
-        CATEGORIES_ORDER.add(Plugin.CATEGORY.PROCESSOR);
-        CATEGORIES_ORDER.add(Plugin.CATEGORY.PACKAGER);
+        CATEGORIES_ORDER.add(Plugin.Category.FILTER);
+        CATEGORIES_ORDER.add(Plugin.Category.TRANSFORMER);
+        CATEGORIES_ORDER.add(Plugin.Category.MODULEINFO_TRANSFORMER);
+        CATEGORIES_ORDER.add(Plugin.Category.SORTER);
+        CATEGORIES_ORDER.add(Plugin.Category.COMPRESSOR);
+        CATEGORIES_ORDER.add(Plugin.Category.METAINFO_ADDER);
+        CATEGORIES_ORDER.add(Plugin.Category.VERIFIER);
+        CATEGORIES_ORDER.add(Plugin.Category.PROCESSOR);
+        CATEGORIES_ORDER.add(Plugin.Category.PACKAGER);
     }
 
     private ImagePluginConfiguration() {
@@ -76,8 +72,8 @@
         if (pluginsConfiguration == null) {
             return new ImagePluginStack();
         }
-        Map<Plugin.CATEGORY, List<Plugin>> plugins = new LinkedHashMap<>();
-        for (Plugin.CATEGORY cat : CATEGORIES_ORDER) {
+        Map<Plugin.Category, List<Plugin>> plugins = new LinkedHashMap<>();
+        for (Plugin.Category cat : CATEGORIES_ORDER) {
             plugins.put(cat, new ArrayList<>());
         }
 
@@ -89,7 +85,7 @@
                         + " added more than once to stack ");
             }
             seen.add(plug.getName());
-            CATEGORY category = Utils.getCategory(plug);
+            Category category = Utils.getCategory(plug);
             if (category == null) {
                 throw new PluginException("Invalid category for "
                         + plug.getName());
@@ -100,10 +96,10 @@
 
         List<TransformerPlugin> transformerPlugins = new ArrayList<>();
         List<PostProcessorPlugin> postProcessingPlugins = new ArrayList<>();
-        for (Entry<Plugin.CATEGORY, List<Plugin>> entry : plugins.entrySet()) {
+        for (Entry<Plugin.Category, List<Plugin>> entry : plugins.entrySet()) {
             // Sort according to plugin constraints
             List<Plugin> orderedPlugins = PluginOrderingGraph.sort(entry.getValue());
-            CATEGORY category = entry.getKey();
+            Category category = entry.getKey();
             for (Plugin p : orderedPlugins) {
                 if (Utils.isPostProcessor(category)) {
                     @SuppressWarnings("unchecked")
@@ -143,14 +139,13 @@
                 }
 
                 @Override
-                public void storeFiles(Pool files) {
+                public void storeFiles(ModulePool files) {
                     throw new PluginException("No directory setup to store files");
                 }
             };
         }
 
-        PluginContext ctxt = pluginsConfiguration.getPluginContext();
         return new ImagePluginStack(builder, transformerPlugins,
-                lastSorter, postProcessingPlugins, ctxt);
+                lastSorter, postProcessingPlugins);
     }
 }
--- a/jdk/src/jdk.jlink/share/classes/jdk/tools/jlink/internal/ImagePluginStack.java	Thu May 19 17:48:02 2016 +0000
+++ b/jdk/src/jdk.jlink/share/classes/jdk/tools/jlink/internal/ImagePluginStack.java	Thu May 19 19:46:20 2016 +0000
@@ -37,20 +37,21 @@
 import java.util.List;
 import java.util.Map;
 import java.util.Objects;
-import java.util.Properties;
+import java.util.Optional;
 import java.util.Set;
+import java.util.function.Function;
 import java.util.stream.Collectors;
 import java.util.stream.Stream;
 
 import jdk.internal.jimage.decompressor.Decompressor;
 import jdk.tools.jlink.plugin.Plugin;
-import jdk.tools.jlink.plugin.PluginContext;
 import jdk.tools.jlink.plugin.ExecutableImage;
 import jdk.tools.jlink.builder.ImageBuilder;
 import jdk.tools.jlink.plugin.TransformerPlugin;
 import jdk.tools.jlink.plugin.PluginException;
-import jdk.tools.jlink.plugin.Pool;
-import jdk.tools.jlink.plugin.Pool.ModuleData;
+import jdk.tools.jlink.plugin.ModulePool;
+import jdk.tools.jlink.plugin.LinkModule;
+import jdk.tools.jlink.plugin.ModuleEntry;
 import jdk.tools.jlink.plugin.PostProcessorPlugin;
 
 /**
@@ -64,9 +65,9 @@
         ExecutableImage retrieve(ImagePluginStack stack) throws IOException;
     }
 
-    public static final class OrderedResourcePool extends PoolImpl {
+    public static final class OrderedResourcePool extends ModulePoolImpl {
 
-        private final List<ModuleData> orderedList = new ArrayList<>();
+        private final List<ModuleEntry> orderedList = new ArrayList<>();
 
         public OrderedResourcePool(ByteOrder order, StringTable table) {
             super(order, table);
@@ -78,22 +79,22 @@
          * @param resource The Resource to add.
          */
         @Override
-        public void add(ModuleData resource) {
+        public void add(ModuleEntry resource) {
             super.add(resource);
             orderedList.add(resource);
         }
 
-        List<ModuleData> getOrderedList() {
+        List<ModuleEntry> getOrderedList() {
             return Collections.unmodifiableList(orderedList);
         }
     }
 
-    private final static class CheckOrderResourcePool extends PoolImpl {
+    private final static class CheckOrderResourcePool extends ModulePoolImpl {
 
-        private final List<ModuleData> orderedList;
+        private final List<ModuleEntry> orderedList;
         private int currentIndex;
 
-        public CheckOrderResourcePool(ByteOrder order, List<ModuleData> orderedList, StringTable table) {
+        public CheckOrderResourcePool(ByteOrder order, List<ModuleEntry> orderedList, StringTable table) {
             super(order, table);
             this.orderedList = orderedList;
         }
@@ -104,8 +105,8 @@
          * @param resource The Resource to add.
          */
         @Override
-        public void add(ModuleData resource) {
-            ModuleData ordered = orderedList.get(currentIndex);
+        public void add(ModuleEntry resource) {
+            ModuleEntry ordered = orderedList.get(currentIndex);
             if (!resource.equals(ordered)) {
                 throw new PluginException("Resource " + resource.getPath() + " not in the right order");
             }
@@ -166,26 +167,16 @@
     private final List<ResourcePrevisitor> resourcePrevisitors = new ArrayList<>();
 
     private final ImageBuilder imageBuilder;
-    private final Properties release;
 
     public ImagePluginStack() {
         this(null, Collections.emptyList(), null,
-                Collections.emptyList(), null);
+                Collections.emptyList());
     }
 
     public ImagePluginStack(ImageBuilder imageBuilder,
             List<TransformerPlugin> contentPlugins,
             Plugin lastSorter,
             List<PostProcessorPlugin> postprocessingPlugins) {
-        this(imageBuilder, contentPlugins, lastSorter,
-            postprocessingPlugins, null);
-    }
-
-    public ImagePluginStack(ImageBuilder imageBuilder,
-            List<TransformerPlugin> contentPlugins,
-            Plugin lastSorter,
-            List<PostProcessorPlugin> postprocessingPlugins,
-            PluginContext ctxt) {
         Objects.requireNonNull(contentPlugins);
         this.lastSorter = lastSorter;
         for (TransformerPlugin p : contentPlugins) {
@@ -200,7 +191,6 @@
             this.postProcessingPlugins.add(p);
         }
         this.imageBuilder = imageBuilder;
-        this.release = ctxt != null? ctxt.getReleaseProperties() : new Properties();
     }
 
     public void operate(ImageProvider provider) throws Exception {
@@ -231,12 +221,12 @@
      * @return The result of the visit.
      * @throws IOException
      */
-    public PoolImpl visitResources(PoolImpl resources)
+    public ModulePoolImpl visitResources(ModulePoolImpl resources)
             throws Exception {
         Objects.requireNonNull(resources);
         resources.setReadOnly();
         if (resources.isEmpty()) {
-            return new PoolImpl(resources.getByteOrder(),
+            return new ModulePoolImpl(resources.getByteOrder(),
                     resources.getStringTable());
         }
         PreVisitStrings previsit = new PreVisitStrings();
@@ -250,11 +240,11 @@
             resources.getStringTable().addString(s);
         }
 
-        PoolImpl current = resources;
-        List<Pool.ModuleData> frozenOrder = null;
+        ModulePoolImpl current = resources;
+        List<ModuleEntry> frozenOrder = null;
         for (TransformerPlugin p : contentPlugins) {
             current.setReadOnly();
-            PoolImpl output = null;
+            ModulePoolImpl output = null;
             if (p == lastSorter) {
                 if (frozenOrder != null) {
                     throw new Exception("Order of resources is already frozen. Plugin "
@@ -268,7 +258,7 @@
                     output = new CheckOrderResourcePool(current.getByteOrder(),
                             frozenOrder, resources.getStringTable());
                 } else {
-                    output = new PoolImpl(current.getByteOrder(),
+                    output = new ModulePoolImpl(current.getByteOrder(),
                             resources.getStringTable());
                 }
             }
@@ -287,15 +277,15 @@
     }
 
     /**
-     * This pool wrap the original pool and automatically uncompress moduledata
+     * This pool wrap the original pool and automatically uncompress ModuleEntry
      * if needed.
      */
-    private class LastPool extends Pool {
-        private class LastModule implements Module {
+    private class LastPool implements ModulePool {
+        private class LastModule implements LinkModule {
 
-            private final Module module;
+            final LinkModule module;
 
-            LastModule(Module module) {
+            LastModule(LinkModule module) {
                 this.module = module;
             }
 
@@ -305,9 +295,9 @@
             }
 
             @Override
-            public ModuleData get(String path) {
-                ModuleData d = module.get(path);
-                return getUncompressed(d);
+            public Optional<ModuleEntry> findEntry(String path) {
+                Optional<ModuleEntry> d = module.findEntry(path);
+                return d.isPresent()? Optional.of(getUncompressed(d.get())) : Optional.empty();
             }
 
             @Override
@@ -316,7 +306,7 @@
             }
 
             @Override
-            public void add(ModuleData data) {
+            public void add(ModuleEntry data) {
                 throw new PluginException("pool is readonly");
             }
 
@@ -331,19 +321,24 @@
             }
 
             @Override
-            public Collection<ModuleData> getContent() {
-                List<ModuleData> lst = new ArrayList<>();
-                for(ModuleData md : module.getContent()) {
+            public Stream<ModuleEntry> entries() {
+                List<ModuleEntry> lst = new ArrayList<>();
+                module.entries().forEach(md -> {
                     lst.add(getUncompressed(md));
-                }
-                return lst;
+                });
+                return lst.stream();
+            }
+
+            @Override
+            public int getEntryCount() {
+                return module.getEntryCount();
             }
         }
-        private final PoolImpl pool;
+        private final ModulePoolImpl pool;
         Decompressor decompressor = new Decompressor();
-        Collection<ModuleData> content;
+        Collection<ModuleEntry> content;
 
-        LastPool(PoolImpl pool) {
+        LastPool(ModulePoolImpl pool) {
             this.pool = pool;
         }
 
@@ -353,23 +348,14 @@
         }
 
         @Override
-        public void add(ModuleData resource) {
+        public void add(ModuleEntry resource) {
             throw new PluginException("pool is readonly");
         }
 
-        /**
-         * Retrieves the module of the provided name.
-         *
-         * @param name The module name
-         * @return the module or null if the module doesn't exist.
-         */
         @Override
-        public Module getModule(String name) {
-            Module module = pool.getModule(name);
-            if (module != null) {
-                module = new LastModule(module);
-            }
-            return module;
+        public Optional<LinkModule> findModule(String name) {
+            Optional<LinkModule> module = pool.findModule(name);
+            return module.isPresent()? Optional.of(new LastModule(module.get())) : Optional.empty();
         }
 
         /**
@@ -378,45 +364,55 @@
          * @return The collection of modules.
          */
         @Override
-        public Collection<Module> getModules() {
-            List<Module> modules = new ArrayList<>();
-            for (Module m : pool.getModules()) {
+        public Stream<? extends LinkModule> modules() {
+            List<LinkModule> modules = new ArrayList<>();
+            pool.modules().forEach(m -> {
                 modules.add(new LastModule(m));
-            }
-            return modules;
+            });
+            return modules.stream();
+        }
+
+        @Override
+        public int getModuleCount() {
+            return pool.getModuleCount();
         }
 
         /**
          * Get all resources contained in this pool instance.
          *
-         * @return The collection of resources;
+         * @return The stream of resources;
          */
         @Override
-        public Collection<ModuleData> getContent() {
+        public Stream<? extends ModuleEntry> entries() {
             if (content == null) {
                 content = new ArrayList<>();
-                for (ModuleData md : pool.getContent()) {
+                pool.entries().forEach(md -> {
                     content.add(getUncompressed(md));
-                }
+                });
             }
-            return content;
+            return content.stream();
+        }
+
+        @Override
+        public int getEntryCount() {
+            return pool.getEntryCount();
         }
 
         /**
          * Get the resource for the passed path.
          *
          * @param path A resource path
-         * @return A Resource instance or null if the resource is not found
+         * @return A Resource instance if the resource is found
          */
         @Override
-        public ModuleData get(String path) {
+        public Optional<ModuleEntry> findEntry(String path) {
             Objects.requireNonNull(path);
-            Pool.ModuleData res = pool.get(path);
-            return getUncompressed(res);
+            Optional<ModuleEntry> res = pool.findEntry(path);
+            return res.isPresent()? Optional.of(getUncompressed(res.get())) : Optional.empty();
         }
 
         @Override
-        public boolean contains(ModuleData res) {
+        public boolean contains(ModuleEntry res) {
             return pool.contains(res);
         }
 
@@ -426,8 +422,8 @@
         }
 
         @Override
-        public void visit(Visitor visitor, Pool output) {
-            pool.visit(visitor, output);
+        public void transformAndCopy(Function<ModuleEntry, ModuleEntry> visitor, ModulePool output) {
+            pool.transformAndCopy(visitor, output);
         }
 
         @Override
@@ -435,14 +431,19 @@
             return pool.getByteOrder();
         }
 
-        private ModuleData getUncompressed(ModuleData res) {
+        @Override
+        public Map<String, String> getReleaseProperties() {
+            return Collections.unmodifiableMap(pool.getReleaseProperties());
+        }
+
+        private ModuleEntry getUncompressed(ModuleEntry res) {
             if (res != null) {
-                if (res instanceof PoolImpl.CompressedModuleData) {
+                if (res instanceof ModulePoolImpl.CompressedModuleData) {
                     try {
                         byte[] bytes = decompressor.decompressResource(getByteOrder(),
                                 (int offset) -> pool.getStringTable().getString(offset),
                                 res.getBytes());
-                        res = Pool.newResource(res.getPath(),
+                        res = ModuleEntry.create(res.getPath(),
                                 new ByteArrayInputStream(bytes),
                                 bytes.length);
                     } catch (IOException ex) {
@@ -462,20 +463,24 @@
      * @param writer
      * @throws java.lang.Exception
      */
-    public void storeFiles(PoolImpl original, PoolImpl transformed,
+    public void storeFiles(ModulePoolImpl original, ModulePoolImpl transformed,
             BasicImageWriter writer)
             throws Exception {
         Objects.requireNonNull(original);
-        try {
-            // fill release information available from transformed "java.base" module!
-            ModuleDescriptor desc = transformed.getModule("java.base").getDescriptor();
-            desc.osName().ifPresent(s -> release.put("OS_NAME", s));
-            desc.osVersion().ifPresent(s -> release.put("OS_VERSION", s));
-            desc.osArch().ifPresent(s -> release.put("OS_ARCH", s));
-        } catch (Exception ignored) {
-        }
+        Objects.requireNonNull(transformed);
+        Optional<LinkModule> javaBase = transformed.findModule("java.base");
+        javaBase.ifPresent(mod -> {
+            try {
+                Map<String, String> release = transformed.getReleaseProperties();
+                // fill release information available from transformed "java.base" module!
+                ModuleDescriptor desc = mod.getDescriptor();
+                desc.osName().ifPresent(s -> release.put("OS_NAME", s));
+                desc.osVersion().ifPresent(s -> release.put("OS_VERSION", s));
+                desc.osArch().ifPresent(s -> release.put("OS_ARCH", s));
+            } catch (Exception ignored) {}
+        });
 
-        imageBuilder.storeFiles(new LastPool(transformed), release);
+        imageBuilder.storeFiles(new LastPool(transformed));
     }
 
     public ExecutableImage getExecutableImage() throws IOException {
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/jdk/src/jdk.jlink/share/classes/jdk/tools/jlink/internal/ModuleEntryImpl.java	Thu May 19 19:46:20 2016 +0000
@@ -0,0 +1,164 @@
+/*
+ * Copyright (c) 2016, Oracle and/or its affiliates. All rights reserved.
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * This code is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License version 2 only, as
+ * published by the Free Software Foundation.  Oracle designates this
+ * particular file as subject to the "Classpath" exception as provided
+ * by Oracle in the LICENSE file that accompanied this code.
+ *
+ * This code is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
+ * version 2 for more details (a copy is included in the LICENSE file that
+ * accompanied this code).
+ *
+ * You should have received a copy of the GNU General Public License version
+ * 2 along with this work; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
+ *
+ * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
+ * or visit www.oracle.com if you need additional information or have any
+ * questions.
+ */
+
+package jdk.tools.jlink.internal;
+
+import java.io.IOException;
+import java.io.InputStream;
+import java.io.UncheckedIOException;
+import java.util.Objects;
+import jdk.tools.jlink.plugin.ModuleEntry;
+
+/**
+ * A LinkModuleEntry is the elementary unit of data inside an image. It is
+ * generally a file. e.g.: a java class file, a resource file, a shared library,
+ * ...
+ * <br>
+ * A LinkModuleEntry is identified by a path of the form:
+ * <ul>
+ * <li>For jimage content: /{module name}/{package1}/.../{packageN}/{file
+ * name}</li>
+ * <li>For other files (shared lib, launchers, config, ...):/{module name}/
+ * {@literal bin|conf|native}/{dir1}>/.../{dirN}/{file name}</li>
+ * </ul>
+ */
+public class ModuleEntryImpl implements ModuleEntry {
+
+    private final Type type;
+    private final String path;
+    private final String module;
+    private final long length;
+    private final InputStream stream;
+    private byte[] buffer;
+
+    /**
+     * Create a new LinkModuleEntry.
+     *
+     * @param module The module name.
+     * @param path The data path identifier.
+     * @param type The data type.
+     * @param stream The data content stream.
+     * @param length The stream length.
+     */
+    public ModuleEntryImpl(String module, String path, Type type, InputStream stream, long length) {
+        Objects.requireNonNull(module);
+        Objects.requireNonNull(path);
+        Objects.requireNonNull(type);
+        Objects.requireNonNull(stream);
+        this.path = path;
+        this.type = type;
+        this.module = module;
+        this.stream = stream;
+        this.length = length;
+    }
+
+    /**
+     * The LinkModuleEntry module name.
+     *
+     * @return The module name.
+     */
+    @Override
+    public final String getModule() {
+        return module;
+    }
+
+    /**
+     * The LinkModuleEntry path.
+     *
+     * @return The module path.
+     */
+    @Override
+    public final String getPath() {
+        return path;
+    }
+
+    /**
+     * The LinkModuleEntry's type.
+     *
+     * @return The data type.
+     */
+    @Override
+    public final Type getType() {
+        return type;
+    }
+
+    /**
+     * The LinkModuleEntry content as an array of byte.
+     *
+     * @return An Array of bytes.
+     */
+    @Override
+    public byte[] getBytes() {
+        if (buffer == null) {
+            try (InputStream is = stream) {
+                buffer = is.readAllBytes();
+            } catch (IOException ex) {
+                throw new UncheckedIOException(ex);
+            }
+        }
+        return buffer;
+    }
+
+    /**
+     * The LinkModuleEntry content length.
+     *
+     * @return The length.
+     */
+    @Override
+    public long getLength() {
+        return length;
+    }
+
+    /**
+     * The LinkModuleEntry stream.
+     *
+     * @return The module data stream.
+     */
+    @Override
+    public InputStream stream() {
+        return stream;
+    }
+
+    @Override
+    public int hashCode() {
+        int hash = 7;
+        hash = 89 * hash + Objects.hashCode(this.path);
+        return hash;
+    }
+
+    @Override
+    public boolean equals(Object other) {
+        if (!(other instanceof ModuleEntryImpl)) {
+            return false;
+        }
+        ModuleEntryImpl f = (ModuleEntryImpl) other;
+        return f.path.equals(path);
+    }
+
+    @Override
+    public String toString() {
+        return getPath();
+    }
+}
\ No newline at end of file
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/jdk/src/jdk.jlink/share/classes/jdk/tools/jlink/internal/ModulePoolImpl.java	Thu May 19 19:46:20 2016 +0000
@@ -0,0 +1,421 @@
+/*
+ * Copyright (c) 2015, Oracle and/or its affiliates. All rights reserved.
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * This code is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License version 2 only, as
+ * published by the Free Software Foundation.  Oracle designates this
+ * particular file as subject to the "Classpath" exception as provided
+ * by Oracle in the LICENSE file that accompanied this code.
+ *
+ * This code is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
+ * version 2 for more details (a copy is included in the LICENSE file that
+ * accompanied this code).
+ *
+ * You should have received a copy of the GNU General Public License version
+ * 2 along with this work; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
+ *
+ * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
+ * or visit www.oracle.com if you need additional information or have any
+ * questions.
+ */
+package jdk.tools.jlink.internal;
+
+import java.io.ByteArrayInputStream;
+import java.io.InputStream;
+import java.lang.module.ModuleDescriptor;
+import java.nio.ByteBuffer;
+import java.nio.ByteOrder;
+import java.util.Collections;
+import java.util.HashMap;
+import java.util.HashSet;
+import java.util.LinkedHashMap;
+import java.util.Map;
+import java.util.Objects;
+import java.util.Optional;
+import java.util.Set;
+import java.util.function.Function;
+import java.util.stream.Stream;
+import jdk.internal.jimage.decompressor.CompressedResourceHeader;
+import jdk.tools.jlink.plugin.ModulePool;
+import jdk.tools.jlink.plugin.LinkModule;
+import jdk.tools.jlink.plugin.ModuleEntry;
+import jdk.tools.jlink.plugin.PluginException;
+import jdk.tools.jlink.internal.plugins.FileCopierPlugin;
+
+/**
+ * Pool of module data.
+ */
+public class ModulePoolImpl implements ModulePool {
+
+    private class ModuleImpl implements LinkModule {
+
+        final Map<String, ModuleEntry> moduleContent = new LinkedHashMap<>();
+        private ModuleDescriptor descriptor;
+        final String name;
+
+        private ModuleImpl(String name) {
+            this.name = name;
+        }
+
+        @Override
+        public String getName() {
+            return name;
+        }
+
+        @Override
+        public Optional<ModuleEntry> findEntry(String path) {
+            if (!path.startsWith("/")) {
+                path = "/" + path;
+            }
+            if (!path.startsWith("/" + name)) {
+                path = "/" + name + path;
+            }
+            return Optional.ofNullable(moduleContent.get(path));
+        }
+
+        @Override
+        public ModuleDescriptor getDescriptor() {
+            if (descriptor == null) {
+                String p = "/" + name + "/module-info.class";
+                Optional<ModuleEntry> content = findEntry(p);
+                if (!content.isPresent()) {
+                    throw new PluginException("No module-info for " + name
+                            + " module");
+                }
+                ByteBuffer bb = ByteBuffer.wrap(content.get().getBytes());
+                descriptor = ModuleDescriptor.read(bb);
+            }
+            return descriptor;
+        }
+
+        @Override
+        public void add(ModuleEntry data) {
+            if (isReadOnly()) {
+                throw new PluginException("LinkConfiguration is readonly");
+            }
+            Objects.requireNonNull(data);
+            if (!data.getModule().equals(name)) {
+                throw new PluginException("Can't add resource " + data.getPath()
+                        + " to module " + name);
+            }
+            ModulePoolImpl.this.add(data);
+        }
+
+        @Override
+        public Set<String> getAllPackages() {
+            Set<String> pkgs = new HashSet<>();
+            moduleContent.values().stream().filter(m -> m.getType().
+                    equals(ModuleEntry.Type.CLASS_OR_RESOURCE)).forEach(res -> {
+                // Module metadata only contains packages with .class files
+                if (ImageFileCreator.isClassPackage(res.getPath())) {
+                    String[] split = ImageFileCreator.splitPath(res.getPath());
+                    String pkg = split[1];
+                    if (pkg != null && !pkg.isEmpty()) {
+                        pkgs.add(pkg);
+                    }
+                }
+            });
+            return pkgs;
+        }
+
+        @Override
+        public String toString() {
+            return getName();
+        }
+
+        @Override
+        public Stream<? extends ModuleEntry> entries() {
+            return moduleContent.values().stream();
+        }
+
+        @Override
+        public int getEntryCount() {
+            return moduleContent.values().size();
+        }
+    }
+
+    private final Map<String, ModuleEntry> resources = new LinkedHashMap<>();
+    private final Map<String, ModuleImpl> modules = new LinkedHashMap<>();
+    private final ModuleImpl fileCopierModule = new ModuleImpl(FileCopierPlugin.FAKE_MODULE);
+    private Map<String, String> releaseProps = new HashMap<>();
+
+    private final ByteOrder order;
+
+    private boolean isReadOnly;
+    private final StringTable table;
+
+    public ModulePoolImpl() {
+        this(ByteOrder.nativeOrder());
+    }
+
+    public ModulePoolImpl(ByteOrder order) {
+        this(order, new StringTable() {
+
+            @Override
+            public int addString(String str) {
+                return -1;
+            }
+
+            @Override
+            public String getString(int id) {
+                return null;
+            }
+        });
+    }
+
+    public ModulePoolImpl(ByteOrder order, StringTable table) {
+        this.order = order;
+        this.table = table;
+    }
+
+    /**
+     * Add a ModuleEntry.
+     *
+     * @param data The ModuleEntry to add.
+     */
+    @Override
+    public void add(ModuleEntry data) {
+        if (isReadOnly()) {
+            throw new PluginException("LinkConfiguration is readonly");
+        }
+        Objects.requireNonNull(data);
+        if (resources.get(data.getPath()) != null) {
+            throw new PluginException("Resource " + data.getPath()
+                    + " already present");
+        }
+        String modulename = data.getModule();
+        ModuleImpl m = modules.get(modulename);
+        // ## TODO: FileCopierPlugin should not add content to a module
+        // FAKE_MODULE is not really a module to be added in the image
+        if (FileCopierPlugin.FAKE_MODULE.equals(modulename)) {
+            m = fileCopierModule;
+        }
+        if (m == null) {
+            m = new ModuleImpl(modulename);
+            modules.put(modulename, m);
+        }
+        resources.put(data.getPath(), data);
+        m.moduleContent.put(data.getPath(), data);
+    }
+
+    /**
+     * Retrieves the module for the provided name.
+     *
+     * @param name The module name
+     * @return the module of matching name, if found
+     */
+    @Override
+    public Optional<LinkModule> findModule(String name) {
+        Objects.requireNonNull(name);
+        return Optional.ofNullable(modules.get(name));
+    }
+
+    /**
+     * The stream of modules contained in this LinkConfiguration.
+     *
+     * @return The stream of modules.
+     */
+    @Override
+    public Stream<? extends LinkModule> modules() {
+        return modules.values().stream();
+    }
+
+    /**
+     * Return the number of LinkModule count in this LinkConfiguration.
+     *
+     * @return the module count.
+     */
+    @Override
+    public int getModuleCount() {
+        return modules.size();
+    }
+
+    /**
+     * Get all ModuleEntry contained in this LinkConfiguration instance.
+     *
+     * @return The stream of LinkModuleEntries.
+     */
+    @Override
+    public Stream<? extends ModuleEntry> entries() {
+        return resources.values().stream();
+    }
+
+    /**
+     * Return the number of ModuleEntry count in this LinkConfiguration.
+     *
+     * @return the entry count.
+     */
+    @Override
+    public int getEntryCount() {
+        return resources.values().size();
+    }
+
+    /**
+     * Get the ModuleEntry for the passed path.
+     *
+     * @param path A data path
+     * @return A ModuleEntry instance or null if the data is not found
+     */
+    @Override
+    public Optional<ModuleEntry> findEntry(String path) {
+        Objects.requireNonNull(path);
+        return Optional.ofNullable(resources.get(path));
+    }
+
+    /**
+     * Check if the LinkConfiguration contains the given ModuleEntry.
+     *
+     * @param data The module data to check existence for.
+     * @return The module data or null if not found.
+     */
+    @Override
+    public boolean contains(ModuleEntry data) {
+        Objects.requireNonNull(data);
+        return findEntry(data.getPath()).isPresent();
+    }
+
+    /**
+     * Check if the LinkConfiguration contains some content at all.
+     *
+     * @return True, no content, false otherwise.
+     */
+    @Override
+    public boolean isEmpty() {
+        return resources.isEmpty();
+    }
+
+    /**
+     * Visit each ModuleEntry in this LinkConfiguration to transform it and
+     * copy the transformed ModuleEntry to the output LinkConfiguration.
+     *
+     * @param transform The function called for each ModuleEntry found in
+     * the LinkConfiguration. The transform function should return a
+     * ModuleEntry instance which will be added to the output or it should
+     * return null if the passed ModuleEntry is to be ignored for the
+     * output.
+     *
+     * @param output The LinkConfiguration to be filled with Visitor returned
+     * ModuleEntry.
+     */
+    @Override
+    public void transformAndCopy(Function<ModuleEntry, ModuleEntry> transform,
+            ModulePool output) {
+        entries().forEach(resource -> {
+            ModuleEntry res = transform.apply(resource);
+            if (res != null) {
+                output.add(res);
+            }
+        });
+    }
+
+    /**
+     * The ByteOrder currently in use when generating the jimage file.
+     *
+     * @return The ByteOrder.
+     */
+    @Override
+    public ByteOrder getByteOrder() {
+        return order;
+    }
+
+    @Override
+    public Map<String, String> getReleaseProperties() {
+        return isReadOnly()? Collections.unmodifiableMap(releaseProps) : releaseProps;
+    }
+
+    public StringTable getStringTable() {
+        return table;
+    }
+
+    /**
+     * Make this Resources instance read-only. No resource can be added.
+     */
+    public void setReadOnly() {
+        isReadOnly = true;
+    }
+
+    /**
+     * Read only state.
+     *
+     * @return true if readonly false otherwise.
+     */
+    @Override
+    public boolean isReadOnly() {
+        return isReadOnly;
+    }
+
+    /**
+     * A resource that has been compressed.
+     */
+    public static final class CompressedModuleData extends ModuleEntryImpl {
+
+        final long uncompressed_size;
+
+        private CompressedModuleData(String module, String path,
+                InputStream stream, long size,
+                long uncompressed_size) {
+            super(module, path, ModuleEntry.Type.CLASS_OR_RESOURCE, stream, size);
+            this.uncompressed_size = uncompressed_size;
+        }
+
+        public long getUncompressedSize() {
+            return uncompressed_size;
+        }
+
+        @Override
+        public boolean equals(Object other) {
+            if (!(other instanceof CompressedModuleData)) {
+                return false;
+            }
+            CompressedModuleData f = (CompressedModuleData) other;
+            return f.getPath().equals(getPath());
+        }
+
+        @Override
+        public int hashCode() {
+            return super.hashCode();
+        }
+    }
+
+    public static CompressedModuleData newCompressedResource(ModuleEntry original,
+            ByteBuffer compressed,
+            String plugin, String pluginConfig, StringTable strings,
+            ByteOrder order) {
+        Objects.requireNonNull(original);
+        Objects.requireNonNull(compressed);
+        Objects.requireNonNull(plugin);
+
+        boolean isTerminal = !(original instanceof CompressedModuleData);
+        long uncompressed_size = original.getLength();
+        if (original instanceof CompressedModuleData) {
+            CompressedModuleData comp = (CompressedModuleData) original;
+            uncompressed_size = comp.getUncompressedSize();
+        }
+        int nameOffset = strings.addString(plugin);
+        int configOffset = -1;
+        if (pluginConfig != null) {
+            configOffset = strings.addString(plugin);
+        }
+        CompressedResourceHeader rh
+                = new CompressedResourceHeader(compressed.limit(), original.getLength(),
+                        nameOffset, configOffset, isTerminal);
+        // Merge header with content;
+        byte[] h = rh.getBytes(order);
+        ByteBuffer bb = ByteBuffer.allocate(compressed.limit() + h.length);
+        bb.order(order);
+        bb.put(h);
+        bb.put(compressed);
+        byte[] contentWithHeader = bb.array();
+
+        CompressedModuleData compressedResource
+                = new CompressedModuleData(original.getModule(), original.getPath(),
+                        new ByteArrayInputStream(contentWithHeader),
+                        contentWithHeader.length, uncompressed_size);
+        return compressedResource;
+    }
+
+}
--- a/jdk/src/jdk.jlink/share/classes/jdk/tools/jlink/internal/PluginContextImpl.java	Thu May 19 17:48:02 2016 +0000
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,37 +0,0 @@
-/*
- * Copyright (c) 2016, Oracle and/or its affiliates. All rights reserved.
- * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
- *
- * This code is free software; you can redistribute it and/or modify it
- * under the terms of the GNU General Public License version 2 only, as
- * published by the Free Software Foundation.  Oracle designates this
- * particular file as subject to the "Classpath" exception as provided
- * by Oracle in the LICENSE file that accompanied this code.
- *
- * This code is distributed in the hope that it will be useful, but WITHOUT
- * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
- * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
- * version 2 for more details (a copy is included in the LICENSE file that
- * accompanied this code).
- *
- * You should have received a copy of the GNU General Public License version
- * 2 along with this work; if not, write to the Free Software Foundation,
- * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
- *
- * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
- * or visit www.oracle.com if you need additional information or have any
- * questions.
- */
-package jdk.tools.jlink.internal;
-
-import java.util.Properties;
-
-import jdk.tools.jlink.plugin.PluginContext;
-
-public final class PluginContextImpl implements PluginContext {
-    private final Properties releaseProps = new Properties();
-
-    public Properties getReleaseProperties() {
-        return releaseProps;
-    }
-}
--- a/jdk/src/jdk.jlink/share/classes/jdk/tools/jlink/internal/PoolImpl.java	Thu May 19 17:48:02 2016 +0000
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,167 +0,0 @@
-/*
- * Copyright (c) 2015, Oracle and/or its affiliates. All rights reserved.
- * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
- *
- * This code is free software; you can redistribute it and/or modify it
- * under the terms of the GNU General Public License version 2 only, as
- * published by the Free Software Foundation.  Oracle designates this
- * particular file as subject to the "Classpath" exception as provided
- * by Oracle in the LICENSE file that accompanied this code.
- *
- * This code is distributed in the hope that it will be useful, but WITHOUT
- * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
- * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
- * version 2 for more details (a copy is included in the LICENSE file that
- * accompanied this code).
- *
- * You should have received a copy of the GNU General Public License version
- * 2 along with this work; if not, write to the Free Software Foundation,
- * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
- *
- * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
- * or visit www.oracle.com if you need additional information or have any
- * questions.
- */
-package jdk.tools.jlink.internal;
-
-import java.io.ByteArrayInputStream;
-import java.io.InputStream;
-import java.nio.ByteBuffer;
-import java.nio.ByteOrder;
-import java.util.Objects;
-import jdk.internal.jimage.decompressor.CompressedResourceHeader;
-import jdk.tools.jlink.plugin.Pool;
-
-/**
- * Pool of module data.
- */
-public class PoolImpl extends Pool {
-
-    /**
-     * A resource that has been compressed.
-     */
-    public static final class CompressedModuleData extends ModuleData {
-
-        private final long uncompressed_size;
-
-        private CompressedModuleData(String module, String path,
-                InputStream stream, long size,
-                long uncompressed_size) {
-            super(module, path, ModuleDataType.CLASS_OR_RESOURCE, stream, size);
-            this.uncompressed_size = uncompressed_size;
-        }
-
-        public long getUncompressedSize() {
-            return uncompressed_size;
-        }
-
-        @Override
-        public boolean equals(Object other) {
-            if (!(other instanceof CompressedModuleData)) {
-                return false;
-            }
-            CompressedModuleData f = (CompressedModuleData) other;
-            return f.getPath().equals(getPath());
-        }
-
-        @Override
-        public int hashCode() {
-            return super.hashCode();
-        }
-    }
-
-    private boolean isReadOnly;
-    private final StringTable table;
-
-    public PoolImpl() {
-        this(ByteOrder.nativeOrder(), new StringTable() {
-
-            @Override
-            public int addString(String str) {
-                return -1;
-            }
-            @Override
-            public String getString(int id) {
-                return null;
-            }
-        });
-    }
-
-    public PoolImpl(ByteOrder order) {
-        this(order, new StringTable() {
-
-            @Override
-            public int addString(String str) {
-                return -1;
-            }
-            @Override
-            public String getString(int id) {
-                return null;
-            }
-        });
-    }
-
-    public PoolImpl(ByteOrder order, StringTable table) {
-        super(order);
-        this.table = table;
-    }
-
-    public StringTable getStringTable() {
-        return table;
-    }
-
-    /**
-     * Make this Resources instance read-only. No resource can be added.
-     */
-    public void setReadOnly() {
-        isReadOnly = true;
-    }
-
-    /**
-     * Read only state.
-     *
-     * @return true if readonly false otherwise.
-     */
-    @Override
-    public boolean isReadOnly() {
-        return isReadOnly;
-    }
-
-    public static CompressedModuleData newCompressedResource(ModuleData original,
-            ByteBuffer compressed,
-            String plugin, String pluginConfig, StringTable strings,
-            ByteOrder order) {
-        Objects.requireNonNull(original);
-        Objects.requireNonNull(compressed);
-        Objects.requireNonNull(plugin);
-
-        boolean isTerminal = !(original instanceof CompressedModuleData);
-        long uncompressed_size = original.getLength();
-        if (original instanceof CompressedModuleData) {
-            CompressedModuleData comp = (CompressedModuleData) original;
-            uncompressed_size = comp.getUncompressedSize();
-        }
-        int nameOffset = strings.addString(plugin);
-        int configOffset = -1;
-        if (pluginConfig != null) {
-            configOffset = strings.addString(plugin);
-        }
-        CompressedResourceHeader rh
-                = new CompressedResourceHeader(compressed.limit(), original.getLength(),
-                        nameOffset, configOffset, isTerminal);
-        // Merge header with content;
-        byte[] h = rh.getBytes(order);
-        ByteBuffer bb = ByteBuffer.allocate(compressed.limit() + h.length);
-        bb.order(order);
-        bb.put(h);
-        bb.put(compressed);
-        byte[] contentWithHeader = bb.array();
-
-        CompressedModuleData compressedResource
-                = new CompressedModuleData(original.getModule(), original.getPath(),
-                        new ByteArrayInputStream(contentWithHeader),
-                        contentWithHeader.length, uncompressed_size);
-        return compressedResource;
-    }
-
-}
--- a/jdk/src/jdk.jlink/share/classes/jdk/tools/jlink/internal/ResourcePrevisitor.java	Thu May 19 17:48:02 2016 +0000
+++ b/jdk/src/jdk.jlink/share/classes/jdk/tools/jlink/internal/ResourcePrevisitor.java	Thu May 19 19:46:20 2016 +0000
@@ -24,7 +24,7 @@
  */
 package jdk.tools.jlink.internal;
 
-import jdk.tools.jlink.plugin.Pool;
+import jdk.tools.jlink.plugin.ModulePool;
 
 /**
  * Plugin wishing to pre-visit the resources must implement this interface.
@@ -44,5 +44,5 @@
      * usage.
      * @throws PluginException
      */
-    public void previsit(Pool resources, StringTable strings);
+    public void previsit(ModulePool resources, StringTable strings);
 }
--- a/jdk/src/jdk.jlink/share/classes/jdk/tools/jlink/internal/TaskHelper.java	Thu May 19 17:48:02 2016 +0000
+++ b/jdk/src/jdk.jlink/share/classes/jdk/tools/jlink/internal/TaskHelper.java	Thu May 19 19:46:20 2016 +0000
@@ -52,7 +52,7 @@
 import jdk.tools.jlink.Jlink;
 import jdk.tools.jlink.Jlink.PluginsConfiguration;
 import jdk.tools.jlink.plugin.Plugin;
-import jdk.tools.jlink.plugin.Plugin.CATEGORY;
+import jdk.tools.jlink.plugin.Plugin.Category;
 import jdk.tools.jlink.builder.DefaultImageBuilder;
 import jdk.tools.jlink.builder.ImageBuilder;
 import jdk.tools.jlink.plugin.PluginException;
@@ -346,7 +346,6 @@
                 }
             }
 
-            PluginContextImpl pluginContext = new PluginContextImpl();
             List<Plugin> pluginsList = new ArrayList<>();
             for (Entry<Plugin, List<Map<String, String>>> entry : pluginToMaps.entrySet()) {
                 Plugin plugin = entry.getKey();
@@ -356,7 +355,7 @@
                 // we call configure once for each occurrence. It is upto the plugin
                 // to 'merge' and/or 'override' arguments.
                 for (Map<String, String> map : argsMaps) {
-                    plugin.configure(Collections.unmodifiableMap(map), pluginContext);
+                    plugin.configure(Collections.unmodifiableMap(map));
                 }
 
                 if (!Utils.isDisabled(plugin)) {
@@ -371,7 +370,7 @@
 
             }
             return new Jlink.PluginsConfiguration(pluginsList,
-                    builder, lastSorter, pluginContext);
+                    builder, lastSorter);
         }
     }
 
@@ -594,7 +593,7 @@
                          + ": " + plugin.getClass().getName());
                     log.println(bundleHelper.getMessage("main.plugin.module")
                          + ": " + plugin.getClass().getModule().getName());
-                    CATEGORY category = Utils.getCategory(plugin);
+                    Category category = Utils.getCategory(plugin);
                     log.println(bundleHelper.getMessage("main.plugin.category")
                          + ": " + category.getName());
                     log.println(bundleHelper.getMessage("main.plugin.state")
--- a/jdk/src/jdk.jlink/share/classes/jdk/tools/jlink/internal/Utils.java	Thu May 19 17:48:02 2016 +0000
+++ b/jdk/src/jdk.jlink/share/classes/jdk/tools/jlink/internal/Utils.java	Thu May 19 19:46:20 2016 +0000
@@ -30,7 +30,6 @@
 import java.util.List;
 import java.util.function.Function;
 import jdk.tools.jlink.plugin.Plugin;
-import jdk.tools.jlink.plugin.Plugin.PluginType;
 
 public class Utils {
 
@@ -50,25 +49,26 @@
         return arguments;
     };
 
-    public static boolean isPostProcessor(Plugin.CATEGORY category) {
-        return category.equals(Plugin.CATEGORY.VERIFIER)
-                || category.equals(Plugin.CATEGORY.PROCESSOR)
-                || category.equals(Plugin.CATEGORY.PACKAGER);
+    public static boolean isPostProcessor(Plugin.Category category) {
+        return category.equals(Plugin.Category.VERIFIER)
+                || category.equals(Plugin.Category.PROCESSOR)
+                || category.equals(Plugin.Category.PACKAGER);
     }
 
-    public static boolean isPreProcessor(Plugin.CATEGORY category) {
-        return category.equals(Plugin.CATEGORY.COMPRESSOR)
-                || category.equals(Plugin.CATEGORY.FILTER)
-                || category.equals(Plugin.CATEGORY.MODULEINFO_TRANSFORMER)
-                || category.equals(Plugin.CATEGORY.SORTER)
-                || category.equals(Plugin.CATEGORY.TRANSFORMER);
+    public static boolean isPreProcessor(Plugin.Category category) {
+        return category.equals(Plugin.Category.COMPRESSOR)
+                || category.equals(Plugin.Category.FILTER)
+                || category.equals(Plugin.Category.MODULEINFO_TRANSFORMER)
+                || category.equals(Plugin.Category.SORTER)
+                || category.equals(Plugin.Category.TRANSFORMER)
+                || category.equals(Plugin.Category.METAINFO_ADDER);
     }
 
     public static boolean isPostProcessor(Plugin prov) {
         if (prov.getType() != null) {
-            for (PluginType pt : prov.getType()) {
-                if (pt instanceof Plugin.CATEGORY) {
-                    return isPostProcessor((Plugin.CATEGORY) pt);
+            for (Plugin.Category pt : prov.getType()) {
+                if (pt instanceof Plugin.Category) {
+                    return isPostProcessor(pt);
                 }
             }
         }
@@ -77,20 +77,20 @@
 
     public static boolean isPreProcessor(Plugin prov) {
         if (prov.getType() != null) {
-            for (PluginType pt : prov.getType()) {
-                if (pt instanceof Plugin.CATEGORY) {
-                    return isPreProcessor((Plugin.CATEGORY) pt);
+            for (Plugin.Category pt : prov.getType()) {
+                if (pt instanceof Plugin.Category) {
+                    return isPreProcessor(pt);
                 }
             }
         }
         return false;
     }
 
-    public static Plugin.CATEGORY getCategory(Plugin provider) {
+    public static Plugin.Category getCategory(Plugin provider) {
         if (provider.getType() != null) {
-            for (Plugin.PluginType t : provider.getType()) {
-                if (t instanceof Plugin.CATEGORY) {
-                    return (Plugin.CATEGORY) t;
+            for (Plugin.Category t : provider.getType()) {
+                if (t instanceof Plugin.Category) {
+                    return t;
                 }
             }
         }
@@ -140,15 +140,15 @@
     }
 
     public static boolean isFunctional(Plugin prov) {
-        return prov.getState().contains(Plugin.STATE.FUNCTIONAL);
+        return prov.getState().contains(Plugin.State.FUNCTIONAL);
     }
 
     public static boolean isAutoEnabled(Plugin prov) {
-        return prov.getState().contains(Plugin.STATE.AUTO_ENABLED);
+        return prov.getState().contains(Plugin.State.AUTO_ENABLED);
     }
 
     public static boolean isDisabled(Plugin prov) {
-        return prov.getState().contains(Plugin.STATE.DISABLED);
+        return prov.getState().contains(Plugin.State.DISABLED);
     }
 
     // is this a builtin (jdk.jlink) plugin?
--- a/jdk/src/jdk.jlink/share/classes/jdk/tools/jlink/internal/packager/AppRuntimeImageBuilder.java	Thu May 19 17:48:02 2016 +0000
+++ b/jdk/src/jdk.jlink/share/classes/jdk/tools/jlink/internal/packager/AppRuntimeImageBuilder.java	Thu May 19 19:46:20 2016 +0000
@@ -30,7 +30,7 @@
 import jdk.tools.jlink.builder.ImageBuilder;
 import jdk.tools.jlink.plugin.Plugin;
 import jdk.tools.jlink.builder.*;
-import jdk.tools.jlink.plugin.Pool;
+import jdk.tools.jlink.plugin.ModulePool;
 
 import java.io.ByteArrayOutputStream;
 import java.io.File;
--- a/jdk/src/jdk.jlink/share/classes/jdk/tools/jlink/internal/plugins/DefaultCompressPlugin.java	Thu May 19 17:48:02 2016 +0000
+++ b/jdk/src/jdk.jlink/share/classes/jdk/tools/jlink/internal/plugins/DefaultCompressPlugin.java	Thu May 19 19:46:20 2016 +0000
@@ -26,16 +26,13 @@
 
 import java.io.IOException;
 import java.io.UncheckedIOException;
-import java.util.ArrayList;
 import java.util.Collections;
 import java.util.HashSet;
-import java.util.List;
 import java.util.Map;
 import java.util.Set;
 
-import jdk.tools.jlink.plugin.PluginException;
-import jdk.tools.jlink.internal.PoolImpl;
-import jdk.tools.jlink.plugin.Pool;
+import jdk.tools.jlink.internal.ModulePoolImpl;
+import jdk.tools.jlink.plugin.ModulePool;
 import jdk.tools.jlink.plugin.TransformerPlugin;
 import jdk.tools.jlink.internal.ImagePluginStack;
 import jdk.tools.jlink.internal.ResourcePrevisitor;
@@ -62,10 +59,10 @@
     }
 
     @Override
-    public void visit(Pool in, Pool out) {
+    public void visit(ModulePool in, ModulePool out) {
         if (ss != null && zip != null) {
-            Pool output = new ImagePluginStack.OrderedResourcePool(in.getByteOrder(),
-                    ((PoolImpl) in).getStringTable());
+            ModulePool output = new ImagePluginStack.OrderedResourcePool(in.getByteOrder(),
+                    ((ModulePoolImpl) in).getStringTable());
             ss.visit(in, output);
             zip.visit(output, out);
         } else if (ss != null) {
@@ -76,16 +73,16 @@
     }
 
     @Override
-    public void previsit(Pool resources, StringTable strings) {
+    public void previsit(ModulePool resources, StringTable strings) {
         if (ss != null) {
             ss.previsit(resources, strings);
         }
     }
 
     @Override
-    public Set<PluginType> getType() {
-        Set<PluginType> set = new HashSet<>();
-        set.add(CATEGORY.COMPRESSOR);
+    public Set<Category> getType() {
+        Set<Category> set = new HashSet<>();
+        set.add(Category.COMPRESSOR);
         return Collections.unmodifiableSet(set);
     }
 
--- a/jdk/src/jdk.jlink/share/classes/jdk/tools/jlink/internal/plugins/ExcludeFilesPlugin.java	Thu May 19 17:48:02 2016 +0000
+++ b/jdk/src/jdk.jlink/share/classes/jdk/tools/jlink/internal/plugins/ExcludeFilesPlugin.java	Thu May 19 19:46:20 2016 +0000
@@ -32,8 +32,8 @@
 import java.util.Set;
 import java.util.function.Predicate;
 import jdk.tools.jlink.plugin.TransformerPlugin;
-import jdk.tools.jlink.plugin.Pool;
-import jdk.tools.jlink.plugin.Pool.ModuleDataType;
+import jdk.tools.jlink.plugin.ModulePool;
+import jdk.tools.jlink.plugin.ModuleEntry;
 import jdk.tools.jlink.internal.Utils;
 
 /**
@@ -51,9 +51,9 @@
     }
 
     @Override
-    public void visit(Pool in, Pool out) {
-        in.visit((file) -> {
-            if (!file.getType().equals(ModuleDataType.CLASS_OR_RESOURCE)) {
+    public void visit(ModulePool in, ModulePool out) {
+        in.transformAndCopy((file) -> {
+            if (!file.getType().equals(ModuleEntry.Type.CLASS_OR_RESOURCE)) {
                 file = predicate.test(file.getPath()) ? file : null;
             }
             return file;
@@ -61,9 +61,9 @@
     }
 
     @Override
-    public Set<PluginType> getType() {
-        Set<PluginType> set = new HashSet<>();
-        set.add(CATEGORY.FILTER);
+    public Set<Category> getType() {
+        Set<Category> set = new HashSet<>();
+        set.add(Category.FILTER);
         return Collections.unmodifiableSet(set);
     }
 
--- a/jdk/src/jdk.jlink/share/classes/jdk/tools/jlink/internal/plugins/ExcludePlugin.java	Thu May 19 17:48:02 2016 +0000
+++ b/jdk/src/jdk.jlink/share/classes/jdk/tools/jlink/internal/plugins/ExcludePlugin.java	Thu May 19 19:46:20 2016 +0000
@@ -32,7 +32,8 @@
 import java.util.function.Predicate;
 import jdk.tools.jlink.plugin.PluginException;
 import jdk.tools.jlink.plugin.TransformerPlugin;
-import jdk.tools.jlink.plugin.Pool;
+import jdk.tools.jlink.plugin.ModuleEntry;
+import jdk.tools.jlink.plugin.ModulePool;
 import jdk.tools.jlink.internal.Utils;
 
 /**
@@ -50,9 +51,9 @@
     }
 
     @Override
-    public void visit(Pool in, Pool out) {
-        in.visit((resource) -> {
-            if (resource.getType().equals(Pool.ModuleDataType.CLASS_OR_RESOURCE)) {
+    public void visit(ModulePool in, ModulePool out) {
+        in.transformAndCopy((resource) -> {
+            if (resource.getType().equals(ModuleEntry.Type.CLASS_OR_RESOURCE)) {
                 resource = predicate.test(resource.getPath()) ? resource : null;
             }
             return resource;
@@ -75,9 +76,9 @@
     }
 
     @Override
-    public Set<PluginType> getType() {
-        Set<PluginType> set = new HashSet<>();
-        set.add(CATEGORY.FILTER);
+    public Set<Category> getType() {
+        Set<Category> set = new HashSet<>();
+        set.add(Category.FILTER);
         return Collections.unmodifiableSet(set);
     }
 
--- a/jdk/src/jdk.jlink/share/classes/jdk/tools/jlink/internal/plugins/ExcludeVMPlugin.java	Thu May 19 17:48:02 2016 +0000
+++ b/jdk/src/jdk.jlink/share/classes/jdk/tools/jlink/internal/plugins/ExcludeVMPlugin.java	Thu May 19 19:46:20 2016 +0000
@@ -40,9 +40,10 @@
 import java.util.function.Predicate;
 import java.util.stream.Collectors;
 import jdk.tools.jlink.plugin.TransformerPlugin;
-import jdk.tools.jlink.plugin.Pool;
-import jdk.tools.jlink.plugin.Pool.ModuleDataType;
+import jdk.tools.jlink.plugin.ModuleEntry;
+import jdk.tools.jlink.plugin.ModulePool;
 import jdk.tools.jlink.internal.Utils;
+import jdk.tools.jlink.plugin.ModuleEntry;
 import jdk.tools.jlink.plugin.PluginException;
 
 /**
@@ -102,24 +103,24 @@
      * e.g.: /java.base/native/amd64/server/libjvm.so
      * /java.base/native/server/libjvm.dylib
      */
-    private List<Pool.ModuleData> getVMs(Pool in) {
+    private List<ModuleEntry> getVMs(ModulePool in) {
         String jvmlib = jvmlib();
-        List<Pool.ModuleData> ret = in.getModule("java.base").getContent().stream().filter((t) -> {
+        List<ModuleEntry> ret = in.findModule("java.base").get().entries().filter((t) -> {
             return t.getPath().endsWith("/" + jvmlib);
         }).collect(Collectors.toList());
         return ret;
     }
 
     @Override
-    public void visit(Pool in, Pool out) {
+    public void visit(ModulePool in, ModulePool out) {
         String jvmlib = jvmlib();
         TreeSet<Jvm> existing = new TreeSet<>(new JvmComparator());
         TreeSet<Jvm> removed = new TreeSet<>(new JvmComparator());
         if (!keepAll) {
             // First retrieve all available VM names and removed VM
-            List<Pool.ModuleData> jvms = getVMs(in);
+            List<ModuleEntry> jvms = getVMs(in);
             for (Jvm jvm : Jvm.values()) {
-                for (Pool.ModuleData md : jvms) {
+                for (ModuleEntry md : jvms) {
                     if (md.getPath().endsWith("/" + jvm.getName() + "/" + jvmlib)) {
                         existing.add(jvm);
                         if (isRemoved(md)) {
@@ -137,9 +138,9 @@
         }
 
         // Rewrite the jvm.cfg file.
-        in.visit((file) -> {
+        in.transformAndCopy((file) -> {
             if (!keepAll) {
-                if (file.getType().equals(ModuleDataType.NATIVE_LIB)) {
+                if (file.getType().equals(ModuleEntry.Type.NATIVE_LIB)) {
                     if (file.getPath().endsWith(JVM_CFG)) {
                         try {
                             file = handleJvmCfgFile(file, existing, removed);
@@ -155,14 +156,14 @@
 
     }
 
-    private boolean isRemoved(Pool.ModuleData file) {
+    private boolean isRemoved(ModuleEntry file) {
         return !predicate.test(file.getPath());
     }
 
     @Override
-    public Set<PluginType> getType() {
-        Set<PluginType> set = new HashSet<>();
-        set.add(CATEGORY.FILTER);
+    public Set<Category> getType() {
+        Set<Category> set = new HashSet<>();
+        set.add(Category.FILTER);
         return Collections.unmodifiableSet(set);
     }
 
@@ -217,7 +218,7 @@
         }
     }
 
-    private Pool.ModuleData handleJvmCfgFile(Pool.ModuleData orig,
+    private ModuleEntry handleJvmCfgFile(ModuleEntry orig,
             TreeSet<Jvm> existing,
             TreeSet<Jvm> removed) throws IOException {
         if (keepAll) {
@@ -253,7 +254,7 @@
 
         byte[] content = builder.toString().getBytes(StandardCharsets.UTF_8);
 
-        return Pool.newImageFile(orig.getModule(),
+        return ModuleEntry.create(orig.getModule(),
                 orig.getPath(),
                 orig.getType(),
                 new ByteArrayInputStream(content), content.length);
--- a/jdk/src/jdk.jlink/share/classes/jdk/tools/jlink/internal/plugins/FileCopierPlugin.java	Thu May 19 17:48:02 2016 +0000
+++ b/jdk/src/jdk.jlink/share/classes/jdk/tools/jlink/internal/plugins/FileCopierPlugin.java	Thu May 19 19:46:20 2016 +0000
@@ -41,10 +41,10 @@
 import java.util.Map;
 import java.util.Objects;
 import java.util.Set;
+import jdk.tools.jlink.internal.ModuleEntryImpl;
 import jdk.tools.jlink.plugin.PluginException;
-import jdk.tools.jlink.plugin.Pool;
-import jdk.tools.jlink.plugin.Pool.ModuleData;
-import jdk.tools.jlink.plugin.Pool.ModuleDataType;
+import jdk.tools.jlink.plugin.ModuleEntry;
+import jdk.tools.jlink.plugin.ModulePool;
 import jdk.tools.jlink.plugin.TransformerPlugin;
 import jdk.tools.jlink.internal.Utils;
 
@@ -68,12 +68,12 @@
     /**
      * Symbolic link to another path.
      */
-    public static abstract class SymImageFile extends Pool.ModuleData {
+    public static abstract class SymImageFile extends ModuleEntryImpl {
 
         private final String targetPath;
 
         public SymImageFile(String targetPath, String module, String path,
-                Pool.ModuleDataType type, InputStream stream, long size) {
+                ModuleEntry.Type type, InputStream stream, long size) {
             super(module, path, type, stream, size);
             this.targetPath = targetPath;
         }
@@ -86,7 +86,7 @@
     private static final class SymImageFileImpl extends SymImageFile {
 
         public SymImageFileImpl(String targetPath, Path file, String module,
-                String path, ModuleDataType type) {
+                String path, ModuleEntry.Type type) {
             super(targetPath, module, path, type, newStream(file), length(file));
         }
     }
@@ -110,11 +110,11 @@
     private static final class DirectoryCopy implements FileVisitor<Path> {
 
         private final Path source;
-        private final Pool pool;
+        private final ModulePool pool;
         private final String targetDir;
         private final List<SymImageFile> symlinks = new ArrayList<>();
 
-        DirectoryCopy(Path source, Pool pool, String targetDir) {
+        DirectoryCopy(Path source, ModulePool pool, String targetDir) {
             this.source = source;
             this.pool = pool;
             this.targetDir = targetDir;
@@ -148,7 +148,7 @@
                 }
                 SymImageFileImpl impl = new SymImageFileImpl(symTarget.toString(),
                         file, path, Objects.requireNonNull(file.getFileName()).toString(),
-                        Pool.ModuleDataType.OTHER);
+                        ModuleEntry.Type.OTHER);
                 symlinks.add(impl);
             } else {
                 addFile(pool, file, path);
@@ -172,14 +172,14 @@
         }
     }
 
-    private static void addFile(Pool pool, Path file, String path)
+    private static void addFile(ModulePool pool, Path file, String path)
             throws IOException {
         Objects.requireNonNull(pool);
         Objects.requireNonNull(file);
         Objects.requireNonNull(path);
-        ModuleData impl = Pool.newImageFile(FAKE_MODULE,
+        ModuleEntry impl = ModuleEntry.create(FAKE_MODULE,
                 "/" + FAKE_MODULE + "/other/" + path,
-                Pool.ModuleDataType.OTHER, newStream(file), length(file));
+                ModuleEntry.Type.OTHER, newStream(file), length(file));
         try {
             pool.add(impl);
         } catch (Exception ex) {
@@ -188,9 +188,9 @@
     }
 
     @Override
-    public Set<PluginType> getType() {
-        Set<PluginType> set = new HashSet<>();
-        set.add(CATEGORY.TRANSFORMER);
+    public Set<Category> getType() {
+        Set<Category> set = new HashSet<>();
+        set.add(Category.TRANSFORMER);
         return Collections.unmodifiableSet(set);
     }
 
@@ -239,8 +239,8 @@
     }
 
     @Override
-    public void visit(Pool in, Pool out) {
-        in.visit((file) -> {
+    public void visit(ModulePool in, ModulePool out) {
+        in.transformAndCopy((file) -> {
             return file;
         }, out);
 
--- a/jdk/src/jdk.jlink/share/classes/jdk/tools/jlink/internal/plugins/GenerateJLIClassesPlugin.java	Thu May 19 17:48:02 2016 +0000
+++ b/jdk/src/jdk.jlink/share/classes/jdk/tools/jlink/internal/plugins/GenerateJLIClassesPlugin.java	Thu May 19 19:46:20 2016 +0000
@@ -33,8 +33,9 @@
 import java.util.Map;
 import java.util.Set;
 import java.util.stream.Collectors;
+import jdk.tools.jlink.plugin.ModuleEntry;
 import jdk.tools.jlink.plugin.PluginException;
-import jdk.tools.jlink.plugin.Pool;
+import jdk.tools.jlink.plugin.ModulePool;
 import jdk.tools.jlink.plugin.TransformerPlugin;
 
 /**
@@ -60,8 +61,8 @@
     }
 
     @Override
-    public Set<PluginType> getType() {
-        return Collections.singleton(CATEGORY.TRANSFORMER);
+    public Set<Category> getType() {
+        return Collections.singleton(Category.TRANSFORMER);
     }
 
     @Override
@@ -75,8 +76,8 @@
     }
 
     @Override
-    public Set<STATE> getState() {
-        return EnumSet.of(STATE.AUTO_ENABLED, STATE.FUNCTIONAL);
+    public Set<State> getState() {
+        return EnumSet.of(State.AUTO_ENABLED, State.FUNCTIONAL);
     }
 
     @Override
@@ -151,8 +152,8 @@
     }
 
     @Override
-    public void visit(Pool in, Pool out) {
-        for (Pool.ModuleData data : in.getContent()) {
+    public void visit(ModulePool in, ModulePool out) {
+        in.entries().forEach(data -> {
             if (("/java.base/" + BMH + ".class").equals(data.getPath())) {
                 // Add BoundMethodHandle unchanged
                 out.add(data);
@@ -162,11 +163,11 @@
                     out.add(data);
                 }
             }
-        }
+        });
     }
 
     @SuppressWarnings("unchecked")
-    private void generateConcreteClass(String types, Pool.ModuleData data, Pool out) {
+    private void generateConcreteClass(String types, ModuleEntry data, ModulePool out) {
         try {
             // Generate class
             Map.Entry<String, byte[]> result = (Map.Entry<String, byte[]>)
@@ -175,9 +176,9 @@
             byte[] bytes = result.getValue();
 
             // Add class to pool
-            Pool.ModuleData ndata = new Pool.ModuleData(data.getModule(),
+            ModuleEntry ndata = ModuleEntry.create(data.getModule(),
                     "/java.base/" + className + ".class",
-                    Pool.ModuleDataType.CLASS_OR_RESOURCE,
+                    ModuleEntry.Type.CLASS_OR_RESOURCE,
                     new ByteArrayInputStream(bytes), bytes.length);
             if (!out.contains(ndata)) {
                 out.add(ndata);
--- a/jdk/src/jdk.jlink/share/classes/jdk/tools/jlink/internal/plugins/IncludeLocalesPlugin.java	Thu May 19 17:48:02 2016 +0000
+++ b/jdk/src/jdk.jlink/share/classes/jdk/tools/jlink/internal/plugins/IncludeLocalesPlugin.java	Thu May 19 19:46:20 2016 +0000
@@ -34,6 +34,7 @@
 import java.util.Locale;
 import java.util.List;
 import java.util.Map;
+import java.util.Optional;
 import java.util.Set;
 import java.util.function.Predicate;
 import java.util.regex.Pattern;
@@ -44,9 +45,10 @@
 import jdk.tools.jlink.internal.ResourcePrevisitor;
 import jdk.tools.jlink.internal.StringTable;
 import jdk.tools.jlink.internal.Utils;
+import jdk.tools.jlink.plugin.LinkModule;
+import jdk.tools.jlink.plugin.ModuleEntry;
 import jdk.tools.jlink.plugin.PluginException;
-import jdk.tools.jlink.plugin.Pool;
-import jdk.tools.jlink.plugin.Pool.ModuleDataType;
+import jdk.tools.jlink.plugin.ModulePool;
 import jdk.tools.jlink.plugin.TransformerPlugin;
 
 /**
@@ -112,19 +114,19 @@
     }
 
     @Override
-    public void visit(Pool in, Pool out) {
-        in.visit((resource) -> {
+    public void visit(ModulePool in, ModulePool out) {
+        in.transformAndCopy((resource) -> {
             if (resource.getModule().equals(MODULENAME)) {
                 String path = resource.getPath();
                 resource = predicate.test(path) ? resource: null;
                 if (resource != null &&
-                    resource.getType().equals(ModuleDataType.CLASS_OR_RESOURCE)) {
+                    resource.getType().equals(ModuleEntry.Type.CLASS_OR_RESOURCE)) {
                     byte[] bytes = resource.getBytes();
                     ClassReader cr = new ClassReader(bytes);
                     if (Arrays.stream(cr.getInterfaces())
                         .anyMatch(i -> i.contains(METAINFONAME)) &&
                         stripUnsupportedLocales(bytes, cr)) {
-                        resource = new Pool.ModuleData(MODULENAME, path,
+                        resource = ModuleEntry.create(MODULENAME, path,
                             resource.getType(),
                             new ByteArrayInputStream(bytes), bytes.length);
                     }
@@ -135,9 +137,9 @@
     }
 
     @Override
-    public Set<PluginType> getType() {
-        Set<PluginType> set = new HashSet<>();
-        set.add(CATEGORY.FILTER);
+    public Set<Category> getType() {
+        Set<Category> set = new HashSet<>();
+        set.add(Category.FILTER);
         return Collections.unmodifiableSet(set);
     }
 
@@ -172,12 +174,13 @@
     }
 
     @Override
-    public void previsit(Pool resources, StringTable strings) {
+    public void previsit(ModulePool resources, StringTable strings) {
         final Pattern p = Pattern.compile(".*((Data_)|(Names_))(?<tag>.*)\\.class");
-        Pool.Module module = resources.getModule(MODULENAME);
+        Optional<LinkModule> optMod = resources.findModule(MODULENAME);
 
         // jdk.localedata module validation
-        if (module != null) {
+        if (optMod.isPresent()) {
+            LinkModule module = optMod.get();
             Set<String> packages = module.getAllPackages();
             if (!packages.containsAll(LOCALEDATA_PACKAGES)) {
                 throw new PluginException(PluginsResourceBundle.getMessage(NAME + ".missingpackages") +
@@ -186,7 +189,7 @@
                         .collect(Collectors.joining(",\n\t")));
             }
 
-            available = Stream.concat(module.getContent().stream()
+            available = Stream.concat(module.entries()
                                         .map(md -> p.matcher(md.getPath()))
                                         .filter(m -> m.matches())
                                         .map(m -> m.group("tag").replaceAll("_", "-")),
--- a/jdk/src/jdk.jlink/share/classes/jdk/tools/jlink/internal/plugins/OptimizationPlugin.java	Thu May 19 17:48:02 2016 +0000
+++ b/jdk/src/jdk.jlink/share/classes/jdk/tools/jlink/internal/plugins/OptimizationPlugin.java	Thu May 19 19:46:20 2016 +0000
@@ -24,7 +24,6 @@
  */
 package jdk.tools.jlink.internal.plugins;
 
-import java.io.FileNotFoundException;
 import java.io.FileOutputStream;
 import java.io.IOException;
 import java.io.OutputStream;
@@ -287,9 +286,9 @@
     }
 
     @Override
-    public Set<PluginType> getType() {
-        Set<PluginType> set = new HashSet<>();
-        set.add(CATEGORY.TRANSFORMER);
+    public Set<Category> getType() {
+        Set<Category> set = new HashSet<>();
+        set.add(Category.TRANSFORMER);
         return Collections.unmodifiableSet(set);
     }
 }
--- a/jdk/src/jdk.jlink/share/classes/jdk/tools/jlink/internal/plugins/OrderResourcesPlugin.java	Thu May 19 17:48:02 2016 +0000
+++ b/jdk/src/jdk.jlink/share/classes/jdk/tools/jlink/internal/plugins/OrderResourcesPlugin.java	Thu May 19 19:46:20 2016 +0000
@@ -36,9 +36,8 @@
 import java.util.Set;
 import java.util.function.ToIntFunction;
 import jdk.tools.jlink.plugin.PluginException;
-import jdk.tools.jlink.plugin.Pool;
-import jdk.tools.jlink.plugin.Pool.ModuleData;
-import jdk.tools.jlink.plugin.Pool.ModuleDataType;
+import jdk.tools.jlink.plugin.ModuleEntry;
+import jdk.tools.jlink.plugin.ModulePool;
 import jdk.tools.jlink.plugin.TransformerPlugin;
 import jdk.tools.jlink.internal.Utils;
 
@@ -62,15 +61,15 @@
     }
 
     static class SortWrapper {
-        private final ModuleData resource;
+        private final ModuleEntry resource;
         private final int ordinal;
 
-        SortWrapper(ModuleData resource, int ordinal) {
+        SortWrapper(ModuleEntry resource, int ordinal) {
             this.resource = resource;
             this.ordinal = ordinal;
         }
 
-        ModuleData getResource() {
+        ModuleEntry getResource() {
             return resource;
         }
 
@@ -95,7 +94,7 @@
         return path;
     }
 
-    private int getOrdinal(ModuleData resource) {
+    private int getOrdinal(ModuleEntry resource) {
         String path = resource.getPath();
 
         Integer value = orderedPaths.get(stripModule(path));
@@ -126,23 +125,23 @@
     }
 
     @Override
-    public void visit(Pool in, Pool out) {
-        in.getContent().stream()
+    public void visit(ModulePool in, ModulePool out) {
+        in.entries()
                 .filter(resource -> resource.getType()
-                        .equals(ModuleDataType.CLASS_OR_RESOURCE))
+                        .equals(ModuleEntry.Type.CLASS_OR_RESOURCE))
                 .map((resource) -> new SortWrapper(resource, getOrdinal(resource)))
                 .sorted(OrderResourcesPlugin::compare)
                 .forEach((wrapper) -> out.add(wrapper.getResource()));
-        in.getContent().stream()
+        in.entries()
                 .filter(other -> !other.getType()
-                        .equals(ModuleDataType.CLASS_OR_RESOURCE))
+                        .equals(ModuleEntry.Type.CLASS_OR_RESOURCE))
                 .forEach((other) -> out.add(other));
     }
 
     @Override
-    public Set<PluginType> getType() {
-        Set<PluginType> set = new HashSet<>();
-        set.add(CATEGORY.SORTER);
+    public Set<Category> getType() {
+        Set<Category> set = new HashSet<>();
+        set.add(Category.SORTER);
 
         return Collections.unmodifiableSet(set);
     }
--- a/jdk/src/jdk.jlink/share/classes/jdk/tools/jlink/internal/plugins/ReleaseInfoPlugin.java	Thu May 19 17:48:02 2016 +0000
+++ b/jdk/src/jdk.jlink/share/classes/jdk/tools/jlink/internal/plugins/ReleaseInfoPlugin.java	Thu May 19 19:46:20 2016 +0000
@@ -24,34 +24,33 @@
  */
 package jdk.tools.jlink.internal.plugins;
 
-import java.lang.module.ModuleDescriptor;
 import java.io.FileInputStream;
 import java.io.IOException;
 import java.util.Collections;
 import java.util.EnumSet;
-import java.util.List;
+import java.util.HashMap;
 import java.util.Map;
+import java.util.Properties;
 import java.util.Set;
-import java.util.Properties;
-
+import java.util.function.Function;
 import jdk.tools.jlink.internal.Utils;
-import jdk.tools.jlink.plugin.ExecutableImage;
-import jdk.tools.jlink.plugin.PluginContext;
-import jdk.tools.jlink.plugin.PluginException;
-import jdk.tools.jlink.plugin.Pool;
-import jdk.tools.jlink.plugin.PostProcessorPlugin;
+import jdk.tools.jlink.plugin.ModulePool;
+import jdk.tools.jlink.plugin.Plugin.Category;
+import jdk.tools.jlink.plugin.Plugin.State;
+import jdk.tools.jlink.plugin.TransformerPlugin;
 
 /**
  * This plugin adds/deletes information for 'release' file.
  */
-public final class ReleaseInfoPlugin implements PostProcessorPlugin {
+public final class ReleaseInfoPlugin implements TransformerPlugin {
     // option name
     public static final String NAME = "release-info";
     public static final String KEYS = "keys";
+    private final Map<String, String> release = new HashMap<>();
 
     @Override
-    public Set<PluginType> getType() {
-        return Collections.singleton(CATEGORY.PROCESSOR);
+    public Set<Category> getType() {
+        return Collections.singleton(Category.METAINFO_ADDER);
     }
 
     @Override
@@ -65,8 +64,8 @@
     }
 
     @Override
-    public Set<STATE> getState() {
-        return EnumSet.of(STATE.FUNCTIONAL);
+    public Set<State> getState() {
+        return EnumSet.of(State.FUNCTIONAL);
     }
 
     @Override
@@ -80,49 +79,49 @@
     }
 
     @Override
-    public void configure(Map<String, String> config, PluginContext ctx) {
-        Properties release = ctx != null? ctx.getReleaseProperties() : null;
-        if (release != null) {
-            String operation = config.get(NAME);
-            switch (operation) {
-                case "add": {
-                    // leave it to open-ended! source, java_version, java_full_version
-                    // can be passed via this option like:
-                    //
-                    //     --release-info add:build_type=fastdebug,source=openjdk,java_version=9
-                    // and put whatever value that was passed in command line.
+    public void configure(Map<String, String> config) {
+        String operation = config.get(NAME);
+        switch (operation) {
+            case "add": {
+                // leave it to open-ended! source, java_version, java_full_version
+                // can be passed via this option like:
+                //
+                //     --release-info add:build_type=fastdebug,source=openjdk,java_version=9
+                // and put whatever value that was passed in command line.
 
-                    config.keySet().stream().
-                        filter(s -> !NAME.equals(s)).
-                        forEach(s -> release.put(s, config.get(s)));
-                }
-                break;
+                config.keySet().stream().
+                    filter(s -> !NAME.equals(s)).
+                    forEach(s -> release.put(s, config.get(s)));
+            }
+            break;
 
-                case "del": {
-                    // --release-info del:keys=openjdk,java_version
-                    String[] keys = Utils.listParser.apply(config.get(KEYS));
-                    for (String k : keys) {
-                        release.remove(k);
-                    }
+            case "del": {
+                // --release-info del:keys=openjdk,java_version
+                String[] keys = Utils.listParser.apply(config.get(KEYS));
+                for (String k : keys) {
+                    release.remove(k);
                 }
-                break;
+            }
+            break;
 
-                default: {
-                    // --release-info <file>
-                    try (FileInputStream fis = new FileInputStream(operation)) {
-                        release.load(fis);
-                    } catch (IOException exp) {
-                        throw new RuntimeException(exp);
-                    }
+            default: {
+                // --release-info <file>
+                Properties props = new Properties();
+                try (FileInputStream fis = new FileInputStream(operation)) {
+                    props.load(fis);
+                } catch (IOException exp) {
+                    throw new RuntimeException(exp);
                 }
-                break;
+                props.forEach((k, v) -> release.put(k.toString(), v.toString()));
             }
+            break;
         }
     }
 
     @Override
-    public List<String> process(ExecutableImage image) {
-        // Nothing to do! Release info copied already during configure!
-        return Collections.emptyList();
+    public void visit(ModulePool in, ModulePool out) {
+        in.transformAndCopy(Function.identity(), out);
+        out.getReleaseProperties().putAll(in.getReleaseProperties());
+        out.getReleaseProperties().putAll(release);
     }
 }
--- a/jdk/src/jdk.jlink/share/classes/jdk/tools/jlink/internal/plugins/StringSharingPlugin.java	Thu May 19 17:48:02 2016 +0000
+++ b/jdk/src/jdk.jlink/share/classes/jdk/tools/jlink/internal/plugins/StringSharingPlugin.java	Thu May 19 19:46:20 2016 +0000
@@ -56,11 +56,11 @@
 import jdk.internal.jimage.decompressor.CompressIndexes;
 import jdk.internal.jimage.decompressor.SignatureParser;
 import jdk.internal.jimage.decompressor.StringSharingDecompressor;
-import jdk.tools.jlink.internal.PoolImpl;
+import jdk.tools.jlink.internal.ModulePoolImpl;
 import jdk.tools.jlink.plugin.TransformerPlugin;
 import jdk.tools.jlink.plugin.PluginException;
-import jdk.tools.jlink.plugin.Pool;
-import jdk.tools.jlink.plugin.Pool.ModuleData;
+import jdk.tools.jlink.plugin.ModuleEntry;
+import jdk.tools.jlink.plugin.ModulePool;
 import jdk.tools.jlink.internal.ResourcePrevisitor;
 import jdk.tools.jlink.internal.StringTable;
 import jdk.tools.jlink.internal.Utils;
@@ -228,7 +228,7 @@
             }
         }
 
-        public byte[] transform(ModuleData resource, Pool out,
+        public byte[] transform(ModuleEntry resource, ModulePool out,
                 StringTable strings) throws IOException, Exception {
             byte[] content = resource.getBytes();
             ClassFile cf;
@@ -243,7 +243,7 @@
         }
 
         @SuppressWarnings("fallthrough")
-        private byte[] optimize(ModuleData resource, Pool resources,
+        private byte[] optimize(ModuleEntry resource, ModulePool resources,
                 StringTable strings,
                 Set<Integer> descriptorIndexes, byte[] content) throws Exception {
             DataInputStream stream = new DataInputStream(new ByteArrayInputStream(content));
@@ -348,27 +348,27 @@
     }
 
     @Override
-    public Set<PluginType> getType() {
-        Set<PluginType> set = new HashSet<>();
-        set.add(CATEGORY.COMPRESSOR);
+    public Set<Category> getType() {
+        Set<Category> set = new HashSet<>();
+        set.add(Category.COMPRESSOR);
         return Collections.unmodifiableSet(set);
     }
 
     @Override
-    public void visit(Pool in, Pool result) {
+    public void visit(ModulePool in, ModulePool result) {
         CompactCPHelper visit = new CompactCPHelper();
-        in.visit((resource) -> {
-            ModuleData res = resource;
+        in.transformAndCopy((resource) -> {
+            ModuleEntry res = resource;
             if (predicate.test(resource.getPath()) && resource.getPath().endsWith(".class")) {
                 byte[] compressed = null;
                 try {
-                    compressed = visit.transform(resource, result, ((PoolImpl) in).getStringTable());
+                    compressed = visit.transform(resource, result, ((ModulePoolImpl) in).getStringTable());
                 } catch (Exception ex) {
                     throw new PluginException(ex);
                 }
-                res = PoolImpl.newCompressedResource(resource,
+                res = ModulePoolImpl.newCompressedResource(resource,
                         ByteBuffer.wrap(compressed), getName(), null,
-                        ((PoolImpl) in).getStringTable(), in.getByteOrder());
+                        ((ModulePoolImpl) in).getStringTable(), in.getByteOrder());
             }
             return res;
         }, result);
@@ -405,10 +405,10 @@
     }
 
     @Override
-    public void previsit(Pool resources, StringTable strings) {
+    public void previsit(ModulePool resources, StringTable strings) {
         CompactCPHelper preVisit = new CompactCPHelper();
-        for (ModuleData resource : resources.getContent()) {
-            if (resource.getType().equals(Pool.ModuleDataType.CLASS_OR_RESOURCE)
+        resources.entries().forEach(resource -> {
+            if (resource.getType().equals(ModuleEntry.Type.CLASS_OR_RESOURCE)
                     && resource.getPath().endsWith(".class") && predicate.test(resource.getPath())) {
                 try {
                     preVisit.transform(resource, null, strings);
@@ -416,6 +416,6 @@
                     throw new PluginException(ex);
                 }
             }
-        }
+        });
     }
 }
--- a/jdk/src/jdk.jlink/share/classes/jdk/tools/jlink/internal/plugins/StripDebugPlugin.java	Thu May 19 17:48:02 2016 +0000
+++ b/jdk/src/jdk.jlink/share/classes/jdk/tools/jlink/internal/plugins/StripDebugPlugin.java	Thu May 19 19:46:20 2016 +0000
@@ -29,14 +29,12 @@
 import java.io.UncheckedIOException;
 import java.util.Collections;
 import java.util.HashSet;
-import java.util.Map;
 import java.util.Set;
 import java.util.function.Predicate;
 import jdk.internal.org.objectweb.asm.ClassReader;
 import jdk.internal.org.objectweb.asm.ClassWriter;
-import jdk.tools.jlink.plugin.Pool;
-import jdk.tools.jlink.plugin.Pool.ModuleData;
-import jdk.tools.jlink.plugin.Pool.ModuleDataType;
+import jdk.tools.jlink.plugin.ModuleEntry;
+import jdk.tools.jlink.plugin.ModulePool;
 import jdk.tools.jlink.plugin.TransformerPlugin;
 
 /**
@@ -61,9 +59,9 @@
     }
 
     @Override
-    public Set<PluginType> getType() {
-        Set<PluginType> set = new HashSet<>();
-        set.add(CATEGORY.TRANSFORMER);
+    public Set<Category> getType() {
+        Set<Category> set = new HashSet<>();
+        set.add(Category.TRANSFORMER);
         return Collections.unmodifiableSet(set);
     }
 
@@ -73,11 +71,11 @@
     }
 
     @Override
-    public void visit(Pool in, Pool out) {
+    public void visit(ModulePool in, ModulePool out) {
         //remove *.diz files as well as debug attributes.
-        in.visit((resource) -> {
-            ModuleData res = resource;
-            if (resource.getType().equals(ModuleDataType.CLASS_OR_RESOURCE)) {
+        in.transformAndCopy((resource) -> {
+            ModuleEntry res = resource;
+            if (resource.getType().equals(ModuleEntry.Type.CLASS_OR_RESOURCE)) {
                 String path = resource.getPath();
                 if (path.endsWith(".class")) {
                     if (path.endsWith("module-info.class")) {
@@ -87,7 +85,7 @@
                         ClassWriter writer = new ClassWriter(ClassWriter.COMPUTE_MAXS);
                         reader.accept(writer, ClassReader.SKIP_DEBUG);
                         byte[] content = writer.toByteArray();
-                        res = Pool.newResource(path, new ByteArrayInputStream(content), content.length);
+                        res = ModuleEntry.create(path, new ByteArrayInputStream(content), content.length);
                     }
                 }
             } else if (predicate.test(res.getPath())) {
--- a/jdk/src/jdk.jlink/share/classes/jdk/tools/jlink/internal/plugins/StripNativeCommandsPlugin.java	Thu May 19 17:48:02 2016 +0000
+++ b/jdk/src/jdk.jlink/share/classes/jdk/tools/jlink/internal/plugins/StripNativeCommandsPlugin.java	Thu May 19 19:46:20 2016 +0000
@@ -26,9 +26,9 @@
 
 import java.util.Collections;
 import java.util.HashSet;
-import java.util.Map;
 import java.util.Set;
-import jdk.tools.jlink.plugin.Pool;
+import jdk.tools.jlink.plugin.ModuleEntry;
+import jdk.tools.jlink.plugin.ModulePool;
 import jdk.tools.jlink.plugin.TransformerPlugin;
 
 /**
@@ -45,16 +45,16 @@
     }
 
     @Override
-    public Set<PluginType> getType() {
-        Set<PluginType> set = new HashSet<>();
-        set.add(CATEGORY.FILTER);
+    public Set<Category> getType() {
+        Set<Category> set = new HashSet<>();
+        set.add(Category.FILTER);
         return Collections.unmodifiableSet(set);
     }
 
     @Override
-    public void visit(Pool in, Pool out) {
-        in.visit((file) -> {
-            return file.getType() == Pool.ModuleDataType.NATIVE_CMD ? null : file;
+    public void visit(ModulePool in, ModulePool out) {
+        in.transformAndCopy((file) -> {
+            return file.getType() == ModuleEntry.Type.NATIVE_CMD ? null : file;
         }, out);
     }
 
--- a/jdk/src/jdk.jlink/share/classes/jdk/tools/jlink/internal/plugins/SystemModuleDescriptorPlugin.java	Thu May 19 17:48:02 2016 +0000
+++ b/jdk/src/jdk.jlink/share/classes/jdk/tools/jlink/internal/plugins/SystemModuleDescriptorPlugin.java	Thu May 19 19:46:20 2016 +0000
@@ -36,6 +36,7 @@
 import java.util.HashMap;
 import java.util.List;
 import java.util.Map;
+import java.util.Optional;
 import java.util.Set;
 import java.util.stream.Collectors;
 
@@ -50,9 +51,10 @@
 
 import static jdk.internal.org.objectweb.asm.Opcodes.*;
 import jdk.tools.jlink.plugin.PluginException;
-import jdk.tools.jlink.plugin.Pool;
+import jdk.tools.jlink.plugin.ModulePool;
 import jdk.tools.jlink.plugin.TransformerPlugin;
 import jdk.tools.jlink.internal.plugins.SystemModuleDescriptorPlugin.Builder.*;
+import jdk.tools.jlink.plugin.ModuleEntry;
 
 /**
  * Jlink plugin to reconstitute module descriptors for installed modules.
@@ -81,8 +83,8 @@
     }
 
     @Override
-    public Set<PluginType> getType() {
-        return Collections.singleton(CATEGORY.TRANSFORMER);
+    public Set<Category> getType() {
+        return Collections.singleton(Category.TRANSFORMER);
     }
 
     @Override
@@ -96,9 +98,9 @@
     }
 
     @Override
-    public Set<STATE> getState() {
-        return enabled ? EnumSet.of(STATE.AUTO_ENABLED, STATE.FUNCTIONAL)
-                       : EnumSet.of(STATE.DISABLED);
+    public Set<State> getState() {
+        return enabled ? EnumSet.of(State.AUTO_ENABLED, State.FUNCTIONAL)
+                       : EnumSet.of(State.DISABLED);
     }
 
     @Override
@@ -110,7 +112,7 @@
 
 
     @Override
-    public void visit(Pool in, Pool out) {
+    public void visit(ModulePool in, ModulePool out) {
         if (!enabled) {
             throw new PluginException(NAME + " was set");
         }
@@ -119,13 +121,14 @@
 
         // generate the byte code to create ModuleDescriptors
         // skip parsing module-info.class and skip name check
-        for (Pool.Module module : in.getModules()) {
-            Pool.ModuleData data = module.get("module-info.class");
-            if (data == null) {
+        in.modules().forEach(module -> {
+            Optional<ModuleEntry> optData = module.findEntry("module-info.class");
+            if (! optData.isPresent()) {
                 // automatic module not supported yet
                 throw new PluginException("module-info.class not found for " +
                                           module.getName() + " module");
             }
+            ModuleEntry data = optData.get();
             assert module.getName().equals(data.getModule());
             try {
                 ByteArrayInputStream bain = new ByteArrayInputStream(data.getBytes());
@@ -141,7 +144,7 @@
                     ModuleInfoRewriter minfoWriter =
                         new ModuleInfoRewriter(bain, mbuilder.conceals());
                     // replace with the overridden version
-                    data = new Pool.ModuleData(data.getModule(),
+                    data = ModuleEntry.create(data.getModule(),
                                                data.getPath(),
                                                data.getType(),
                                                minfoWriter.stream(),
@@ -151,19 +154,17 @@
             } catch (IOException e) {
                 throw new PluginException(e);
             }
-
-        }
+        });
 
         // Generate the new class
         ClassWriter cwriter = builder.build();
-        for (Pool.ModuleData data : in.getContent()) {
+        in.entries().forEach(data -> {
             if (data.getPath().endsWith("module-info.class"))
-                continue;
-
+                return;
             if (builder.isOverriddenClass(data.getPath())) {
                 byte[] bytes = cwriter.toByteArray();
-                Pool.ModuleData ndata =
-                    new Pool.ModuleData(data.getModule(),
+                ModuleEntry ndata =
+                    ModuleEntry.create(data.getModule(),
                                         data.getPath(),
                                         data.getType(),
                                         new ByteArrayInputStream(bytes),
@@ -172,7 +173,7 @@
             } else {
                 out.add(data);
             }
-        }
+        });
     }
 
     /*
--- a/jdk/src/jdk.jlink/share/classes/jdk/tools/jlink/internal/plugins/ZipPlugin.java	Thu May 19 17:48:02 2016 +0000
+++ b/jdk/src/jdk.jlink/share/classes/jdk/tools/jlink/internal/plugins/ZipPlugin.java	Thu May 19 19:46:20 2016 +0000
@@ -34,10 +34,9 @@
 import java.util.function.Predicate;
 import java.util.zip.Deflater;
 import jdk.tools.jlink.plugin.PluginException;
-import jdk.tools.jlink.internal.PoolImpl;
-import jdk.tools.jlink.plugin.Pool;
-import jdk.tools.jlink.plugin.Pool.ModuleData;
-import jdk.tools.jlink.plugin.Pool.ModuleDataType;
+import jdk.tools.jlink.internal.ModulePoolImpl;
+import jdk.tools.jlink.plugin.ModuleEntry;
+import jdk.tools.jlink.plugin.ModulePool;
 import jdk.tools.jlink.plugin.TransformerPlugin;
 import jdk.tools.jlink.internal.Utils;
 
@@ -68,9 +67,9 @@
     }
 
     @Override
-    public Set<PluginType> getType() {
-        Set<PluginType> set = new HashSet<>();
-        set.add(CATEGORY.COMPRESSOR);
+    public Set<Category> getType() {
+        Set<Category> set = new HashSet<>();
+        set.add(Category.COMPRESSOR);
         return Collections.unmodifiableSet(set);
     }
 
@@ -124,16 +123,16 @@
     }
 
     @Override
-    public void visit(Pool in, Pool out) {
-        in.visit((resource) -> {
-            ModuleData res = resource;
-            if (resource.getType().equals(ModuleDataType.CLASS_OR_RESOURCE)
+    public void visit(ModulePool in, ModulePool out) {
+        in.transformAndCopy((resource) -> {
+            ModuleEntry res = resource;
+            if (resource.getType().equals(ModuleEntry.Type.CLASS_OR_RESOURCE)
                     && predicate.test(resource.getPath())) {
                 byte[] compressed;
                 compressed = compress(resource.getBytes());
-                res = PoolImpl.newCompressedResource(resource,
+                res = ModulePoolImpl.newCompressedResource(resource,
                         ByteBuffer.wrap(compressed), getName(), null,
-                        ((PoolImpl) in).getStringTable(), in.getByteOrder());
+                        ((ModulePoolImpl) in).getStringTable(), in.getByteOrder());
             }
             return res;
         }, out);
--- a/jdk/src/jdk.jlink/share/classes/jdk/tools/jlink/internal/plugins/asm/AsmPlugin.java	Thu May 19 17:48:02 2016 +0000
+++ b/jdk/src/jdk.jlink/share/classes/jdk/tools/jlink/internal/plugins/asm/AsmPlugin.java	Thu May 19 19:46:20 2016 +0000
@@ -26,9 +26,9 @@
 
 import java.util.Objects;
 import jdk.tools.jlink.plugin.TransformerPlugin;
-import jdk.tools.jlink.plugin.Pool;
-import jdk.tools.jlink.plugin.Pool.ModuleData;
-import jdk.tools.jlink.internal.PoolImpl;
+import jdk.tools.jlink.plugin.ModuleEntry;
+import jdk.tools.jlink.plugin.ModulePool;
+import jdk.tools.jlink.internal.ModulePoolImpl;
 
 /**
  * Extend this class to develop your own plugin in order to transform jimage
@@ -41,17 +41,17 @@
     }
 
     @Override
-    public void visit(Pool allContent, Pool outResources) {
+    public void visit(ModulePool allContent, ModulePool outResources) {
         Objects.requireNonNull(allContent);
         Objects.requireNonNull(outResources);
-        PoolImpl resources = new PoolImpl(allContent.getByteOrder());
-        for(ModuleData md : allContent.getContent()) {
-            if(md.getType().equals(Pool.ModuleDataType.CLASS_OR_RESOURCE)) {
+        ModulePoolImpl resources = new ModulePoolImpl(allContent.getByteOrder());
+        allContent.entries().forEach(md -> {
+            if(md.getType().equals(ModuleEntry.Type.CLASS_OR_RESOURCE)) {
                 resources.add(md);
             } else {
                 outResources.add(md);
             }
-        }
+        });
         AsmPools pools = new AsmPools(resources);
         visit(pools);
         pools.fillOutputResources(outResources);
--- a/jdk/src/jdk.jlink/share/classes/jdk/tools/jlink/internal/plugins/asm/AsmPool.java	Thu May 19 17:48:02 2016 +0000
+++ b/jdk/src/jdk.jlink/share/classes/jdk/tools/jlink/internal/plugins/asm/AsmPool.java	Thu May 19 19:46:20 2016 +0000
@@ -24,13 +24,12 @@
  */
 package jdk.tools.jlink.internal.plugins.asm;
 
-import java.io.InputStream;
-import java.nio.ByteBuffer;
 import java.util.Collection;
 import java.util.List;
 import jdk.internal.org.objectweb.asm.ClassReader;
 import jdk.internal.org.objectweb.asm.ClassWriter;
-import jdk.tools.jlink.plugin.Pool;
+import jdk.tools.jlink.plugin.ModuleEntry;
+import jdk.tools.jlink.plugin.ModulePool;
 
 /**
  * A pool of ClassReader and other resource files.
@@ -138,14 +137,14 @@
          * @return The ClassReader or null if the class is not found.
          * @throws jdk.tools.jlink.plugin.PluginException
          */
-        public ClassReader getClassReader(Pool.ModuleData res);
+        public ClassReader getClassReader(ModuleEntry res);
 
         /**
          * Returns all the classes contained in the writable pool.
          *
          * @return The collection of classes.
          */
-        public Collection<Pool.ModuleData> getClasses();
+        public Collection<ModuleEntry> getClasses();
     }
 
     /**
@@ -185,14 +184,14 @@
          * @param res The java resource
          * @return The Resource or null if the resource is not found.
          */
-        public ResourceFile getResourceFile(Pool.ModuleData res);
+        public ResourceFile getResourceFile(ModuleEntry res);
 
         /**
          * Returns all the resources contained in the writable pool.
          *
          * @return The array of resources.
          */
-        public Collection<Pool.ModuleData> getResourceFiles();
+        public Collection<ModuleEntry> getResourceFiles();
     }
 
     /**
@@ -206,7 +205,7 @@
          * @return The resource paths ordered in the way to use for storage in the jimage.
          * @throws jdk.tools.jlink.plugin.PluginException
          */
-        public List<String> sort(Pool resources);
+        public List<String> sort(ModulePool resources);
     }
 
     /**
@@ -237,7 +236,7 @@
      *
      * @return The classes.
      */
-    public Collection<Pool.ModuleData> getClasses();
+    public Collection<ModuleEntry> getClasses();
 
     /**
      * Returns the resources contained in the pool. Resources are all the file
@@ -245,7 +244,7 @@
      *
      * @return The array of resource files.
      */
-    public Collection<Pool.ModuleData> getResourceFiles();
+    public Collection<ModuleEntry> getResourceFiles();
 
     /**
      * Retrieves a resource based on the binary name. This name doesn't contain
@@ -266,7 +265,7 @@
      * @param res The resource
      * @return The resource file or null if it doesn't exist.
      */
-    public ResourceFile getResourceFile(Pool.ModuleData res);
+    public ResourceFile getResourceFile(ModuleEntry res);
 
     /**
      * Retrieve a ClassReader from the pool.
@@ -284,7 +283,7 @@
      * @return A reader or null if the class is unknown
      * @throws jdk.tools.jlink.plugin.PluginException
      */
-    public ClassReader getClassReader(Pool.ModuleData res);
+    public ClassReader getClassReader(ModuleEntry res);
 
     /**
      * To visit the set of ClassReaders.
@@ -310,6 +309,6 @@
      * @param output The pool used to fill the jimage.
      * @throws jdk.tools.jlink.plugin.PluginException
      */
-    public void fillOutputResources(Pool output);
+    public void fillOutputResources(ModulePool output);
 
 }
--- a/jdk/src/jdk.jlink/share/classes/jdk/tools/jlink/internal/plugins/asm/AsmPoolImpl.java	Thu May 19 17:48:02 2016 +0000
+++ b/jdk/src/jdk.jlink/share/classes/jdk/tools/jlink/internal/plugins/asm/AsmPoolImpl.java	Thu May 19 19:46:20 2016 +0000
@@ -41,15 +41,14 @@
 import java.util.Map;
 import java.util.Map.Entry;
 import java.util.Objects;
-import java.util.Optional;
 import java.util.Set;
 import jdk.internal.org.objectweb.asm.ClassReader;
 import jdk.internal.org.objectweb.asm.ClassWriter;
 import jdk.tools.jlink.internal.ImageFileCreator;
-import jdk.tools.jlink.internal.PoolImpl;
+import jdk.tools.jlink.internal.ModulePoolImpl;
+import jdk.tools.jlink.plugin.ModuleEntry;
 import jdk.tools.jlink.plugin.PluginException;
-import jdk.tools.jlink.plugin.Pool;
-import jdk.tools.jlink.plugin.Pool.ModuleData;
+import jdk.tools.jlink.plugin.ModulePool;
 
 /**
  * A pool of ClassReader and other resource files. This class allows to
@@ -94,7 +93,7 @@
             }
 
             byte[] content = writer.toByteArray();
-            ModuleData res = Pool.newResource(path,
+            ModuleEntry res = ModuleEntry.create(path,
                     new ByteArrayInputStream(content), content.length);
             transformedClasses.put(className, res);
         }
@@ -108,7 +107,7 @@
         public void forgetClass(String className) {
             Objects.requireNonNull(className);
             // do we have a resource?
-            ModuleData res = transformedClasses.get(className);
+            ModuleEntry res = transformedClasses.get(className);
             if (res == null) {
                 res = inputClasses.get(className);
                 if (res == null) {
@@ -130,7 +129,7 @@
         @Override
         public ClassReader getClassReader(String binaryName) {
             Objects.requireNonNull(binaryName);
-            ModuleData res = transformedClasses.get(binaryName);
+            ModuleEntry res = transformedClasses.get(binaryName);
             ClassReader reader = null;
             if (res != null) {
                 reader = getClassReader(res);
@@ -144,16 +143,16 @@
          * @return The array of transformed classes.
          */
         @Override
-        public Collection<ModuleData> getClasses() {
-            List<ModuleData> classes = new ArrayList<>();
-            for (Entry<String, ModuleData> entry : transformedClasses.entrySet()) {
+        public Collection<ModuleEntry> getClasses() {
+            List<ModuleEntry> classes = new ArrayList<>();
+            for (Entry<String, ModuleEntry> entry : transformedClasses.entrySet()) {
                 classes.add(entry.getValue());
             }
             return classes;
         }
 
         @Override
-        public ClassReader getClassReader(ModuleData res) {
+        public ClassReader getClassReader(ModuleEntry res) {
             return newClassReader(res.getBytes());
         }
     }
@@ -176,7 +175,7 @@
         public void addResourceFile(ResourceFile resFile) {
             Objects.requireNonNull(resFile);
             String path = toResourceNamePath(resFile.getPath());
-            ModuleData res = Pool.newResource(path, resFile.getContent());
+            ModuleEntry res = ModuleEntry.create(path, resFile.getContent());
             transformedResources.put(resFile.getPath(), res);
         }
 
@@ -191,7 +190,7 @@
             Objects.requireNonNull(resourceName);
             String path = toResourceNamePath(resourceName);
             // do we have a resource?
-            ModuleData res = transformedResources.get(resourceName);
+            ModuleEntry res = transformedResources.get(resourceName);
             if (res == null) {
                 res = inputResources.get(resourceName);
                 if (res == null) {
@@ -212,7 +211,7 @@
         @Override
         public ResourceFile getResourceFile(String name) {
             Objects.requireNonNull(name);
-            ModuleData res = transformedResources.get(name);
+            ModuleEntry res = transformedResources.get(name);
             ResourceFile resFile = null;
             if (res != null) {
                 resFile = getResourceFile(res);
@@ -226,24 +225,24 @@
          * @return The array of transformed classes.
          */
         @Override
-        public Collection<ModuleData> getResourceFiles() {
-            List<ModuleData> resources = new ArrayList<>();
-            for (Entry<String, ModuleData> entry : transformedResources.entrySet()) {
+        public Collection<ModuleEntry> getResourceFiles() {
+            List<ModuleEntry> resources = new ArrayList<>();
+            for (Entry<String, ModuleEntry> entry : transformedResources.entrySet()) {
                 resources.add(entry.getValue());
             }
             return resources;
         }
 
         @Override
-        public ResourceFile getResourceFile(ModuleData res) {
+        public ResourceFile getResourceFile(ModuleEntry res) {
             return new ResourceFile(toJavaBinaryResourceName(res.getPath()),
                     res.getBytes());
         }
     }
 
-    private final Pool jimageResources;
-    private final Map<String, ModuleData> inputClasses;
-    private final Map<String, ModuleData> inputResources;
+    private final ModulePool jimageResources;
+    private final Map<String, ModuleEntry> inputClasses;
+    private final Map<String, ModuleEntry> inputResources;
     private final Map<String, String> inputClassPackageMapping;
     private final Map<String, String> inputOtherPackageMapping;
 
@@ -254,9 +253,9 @@
 
     private Sorter sorter;
 
-    private final Map<String, ModuleData> transformedClasses
+    private final Map<String, ModuleEntry> transformedClasses
             =            new LinkedHashMap<>();
-    private final Map<String, ModuleData> transformedResources
+    private final Map<String, ModuleEntry> transformedResources
             =            new LinkedHashMap<>();
     private final List<String> forgetResources = new ArrayList<>();
     private final Map<String, String> newPackageMapping = new HashMap<>();
@@ -274,7 +273,7 @@
      * @param pools The resource pools.
      * @param descriptor The module descriptor.
      */
-    AsmPoolImpl(Pool inputResources, String moduleName,
+    AsmPoolImpl(ModulePool inputResources, String moduleName,
             AsmPools pools,
             ModuleDescriptor descriptor) {
         Objects.requireNonNull(inputResources);
@@ -285,11 +284,11 @@
         this.moduleName = moduleName;
         this.pools = pools;
         this.descriptor = descriptor;
-        Map<String, ModuleData> classes = new LinkedHashMap<>();
-        Map<String, ModuleData> resources = new LinkedHashMap<>();
+        Map<String, ModuleEntry> classes = new LinkedHashMap<>();
+        Map<String, ModuleEntry> resources = new LinkedHashMap<>();
         Map<String, String> packageClassToModule = new HashMap<>();
         Map<String, String> packageOtherToModule = new HashMap<>();
-        for (ModuleData res : inputResources.getContent()) {
+        inputResources.entries().forEach(res -> {
             if (res.getPath().endsWith(".class")) {
                 classes.put(toJavaBinaryClassName(res.getPath()), res);
             } else {
@@ -305,7 +304,7 @@
                     packageOtherToModule.put(split[1], res.getModule());
                 }
             }
-        }
+        });
         this.inputClasses = Collections.unmodifiableMap(classes);
         this.inputResources = Collections.unmodifiableMap(resources);
 
@@ -356,7 +355,7 @@
      * @return The array of classes.
      */
     @Override
-    public Collection<ModuleData> getClasses() {
+    public Collection<ModuleEntry> getClasses() {
         return inputClasses.values();
     }
 
@@ -367,7 +366,7 @@
      * @return The array of classes.
      */
     @Override
-    public Collection<ModuleData> getResourceFiles() {
+    public Collection<ModuleEntry> getResourceFiles() {
         return inputResources.values();
     }
 
@@ -385,7 +384,7 @@
     @Override
     public ResourceFile getResourceFile(String binaryName) {
         Objects.requireNonNull(binaryName);
-        ModuleData res = inputResources.get(binaryName);
+        ModuleEntry res = inputResources.get(binaryName);
         ResourceFile resFile = null;
         if (res != null) {
             resFile = getResourceFile(res);
@@ -402,7 +401,7 @@
     @Override
     public ClassReader getClassReader(String binaryName) {
         Objects.requireNonNull(binaryName);
-        ModuleData res = inputClasses.get(binaryName);
+        ModuleEntry res = inputClasses.get(binaryName);
         ClassReader reader = null;
         if (res != null) {
             reader = getClassReader(res);
@@ -411,13 +410,13 @@
     }
 
     @Override
-    public ResourceFile getResourceFile(ModuleData res) {
+    public ResourceFile getResourceFile(ModuleEntry res) {
         return new ResourceFile(toJavaBinaryResourceName(res.getPath()),
                 res.getBytes());
     }
 
     @Override
-    public ClassReader getClassReader(ModuleData res) {
+    public ClassReader getClassReader(ModuleEntry res) {
         return newClassReader(res.getBytes());
     }
 
@@ -505,7 +504,7 @@
     @Override
     public void visitClassReaders(ClassReaderVisitor visitor) {
         Objects.requireNonNull(visitor);
-        for (ModuleData res : getClasses()) {
+        for (ModuleEntry res : getClasses()) {
             ClassReader reader = newClassReader(res.getBytes());
             ClassWriter writer = visitor.visit(reader);
             if (writer != null) {
@@ -523,7 +522,7 @@
     @Override
     public void visitResourceFiles(ResourceFileVisitor visitor) {
         Objects.requireNonNull(visitor);
-        for (ModuleData resource : getResourceFiles()) {
+        for (ModuleEntry resource : getResourceFiles()) {
             ResourceFile resFile
                     = new ResourceFile(toJavaBinaryResourceName(resource.getPath()),
                             resource.getBytes());
@@ -540,18 +539,18 @@
      * been set, it is used to sort the returned resources.     *
      */
     @Override
-    public void fillOutputResources(Pool outputResources) {
+    public void fillOutputResources(ModulePool outputResources) {
         List<String> added = new ArrayList<>();
         // If the sorter is null, use the input order.
         // New resources are added at the end
         // First input classes that have not been removed
-        Pool output = new PoolImpl(outputResources.getByteOrder(),
-                ((PoolImpl)outputResources).getStringTable());
-        for (ModuleData inResource : jimageResources.getContent()) {
+        ModulePool output = new ModulePoolImpl(outputResources.getByteOrder(),
+                ((ModulePoolImpl)outputResources).getStringTable());
+        jimageResources.entries().forEach(inResource -> {
             if (!forgetResources.contains(inResource.getPath())) {
-                ModuleData resource = inResource;
+                ModuleEntry resource = inResource;
                 // Do we have a transformed class with the same name?
-                ModuleData res = transformedResources.
+                ModuleEntry res = transformedResources.
                         get(toJavaBinaryResourceName(inResource.getPath()));
                 if (res != null) {
                     resource = res;
@@ -565,10 +564,10 @@
                 output.add(resource);
                 added.add(resource.getPath());
             }
-        }
+        });
         // Then new resources
-        for (Map.Entry<String, ModuleData> entry : transformedResources.entrySet()) {
-            ModuleData resource = entry.getValue();
+        for (Map.Entry<String, ModuleEntry> entry : transformedResources.entrySet()) {
+            ModuleEntry resource = entry.getValue();
             if (!forgetResources.contains(resource.getPath())) {
                 if (!added.contains(resource.getPath())) {
                     output.add(resource);
@@ -576,8 +575,8 @@
             }
         }
         // And new classes
-        for (Map.Entry<String, ModuleData> entry : transformedClasses.entrySet()) {
-            ModuleData resource = entry.getValue();
+        for (Map.Entry<String, ModuleEntry> entry : transformedClasses.entrySet()) {
+            ModuleEntry resource = entry.getValue();
             if (!forgetResources.contains(resource.getPath())) {
                 if (!added.contains(resource.getPath())) {
                     output.add(resource);
--- a/jdk/src/jdk.jlink/share/classes/jdk/tools/jlink/internal/plugins/asm/AsmPools.java	Thu May 19 17:48:02 2016 +0000
+++ b/jdk/src/jdk.jlink/share/classes/jdk/tools/jlink/internal/plugins/asm/AsmPools.java	Thu May 19 19:46:20 2016 +0000
@@ -41,11 +41,11 @@
 import java.util.Set;
 import jdk.internal.org.objectweb.asm.ClassReader;
 import jdk.internal.org.objectweb.asm.ClassWriter;
-import jdk.tools.jlink.internal.PoolImpl;
+import jdk.tools.jlink.internal.ModulePoolImpl;
 import jdk.tools.jlink.internal.plugins.asm.AsmPool.Sorter;
+import jdk.tools.jlink.plugin.ModuleEntry;
 import jdk.tools.jlink.plugin.PluginException;
-import jdk.tools.jlink.plugin.Pool;
-import jdk.tools.jlink.plugin.Pool.ModuleData;
+import jdk.tools.jlink.plugin.ModulePool;
 
 /**
  * A container for pools of ClassReader and other resource files. A pool of all
@@ -97,10 +97,10 @@
             }
 
             @Override
-            public Collection<Pool.ModuleData> getClasses() {
-                List<Pool.ModuleData> all = new ArrayList<>();
+            public Collection<ModuleEntry> getClasses() {
+                List<ModuleEntry> all = new ArrayList<>();
                 visitAllPools((AsmModulePool pool) -> {
-                    for (Pool.ModuleData rf : pool.getTransformedClasses().getClasses()) {
+                    for (ModuleEntry rf : pool.getTransformedClasses().getClasses()) {
                         all.add(rf);
                     }
                 });
@@ -108,7 +108,7 @@
             }
 
             @Override
-            public ClassReader getClassReader(Pool.ModuleData res) {
+            public ClassReader getClassReader(ModuleEntry res) {
                 return visitPools((AsmModulePool pool) -> {
                     return pool.getTransformedClasses().getClassReader(res);
                 });
@@ -140,10 +140,10 @@
             }
 
             @Override
-            public Collection<Pool.ModuleData> getResourceFiles() {
-                List<Pool.ModuleData> all = new ArrayList<>();
+            public Collection<ModuleEntry> getResourceFiles() {
+                List<ModuleEntry> all = new ArrayList<>();
                 visitAllPools((AsmModulePool pool) -> {
-                    for (Pool.ModuleData rf : pool.getTransformedResourceFiles().getResourceFiles()) {
+                    for (ModuleEntry rf : pool.getTransformedResourceFiles().getResourceFiles()) {
                         all.add(rf);
                     }
                 });
@@ -151,7 +151,7 @@
             }
 
             @Override
-            public ResourceFile getResourceFile(Pool.ModuleData res) {
+            public ResourceFile getResourceFile(ModuleEntry res) {
                 return visitPools((AsmModulePool pool) -> {
                     return pool.getTransformedResourceFiles().getResourceFile(res);
                 });
@@ -175,10 +175,10 @@
         }
 
         @Override
-        public Collection<Pool.ModuleData> getClasses() {
-            List<Pool.ModuleData> all = new ArrayList<>();
+        public Collection<ModuleEntry> getClasses() {
+            List<ModuleEntry> all = new ArrayList<>();
             visitAllPools((AsmModulePool pool) -> {
-                for (Pool.ModuleData rf : pool.getClasses()) {
+                for (ModuleEntry rf : pool.getClasses()) {
                     all.add(rf);
                 }
             });
@@ -186,10 +186,10 @@
         }
 
         @Override
-        public Collection<Pool.ModuleData> getResourceFiles() {
-            List<Pool.ModuleData> all = new ArrayList<>();
+        public Collection<ModuleEntry> getResourceFiles() {
+            List<ModuleEntry> all = new ArrayList<>();
             visitAllPools((AsmModulePool pool) -> {
-                for (Pool.ModuleData rf : pool.getResourceFiles()) {
+                for (ModuleEntry rf : pool.getResourceFiles()) {
                     all.add(rf);
                 }
             });
@@ -211,14 +211,14 @@
         }
 
         @Override
-        public ResourceFile getResourceFile(Pool.ModuleData res) {
+        public ResourceFile getResourceFile(ModuleEntry res) {
             return visitPools((AsmModulePool pool) -> {
                 return pool.getResourceFile(res);
             });
         }
 
         @Override
-        public ClassReader getClassReader(Pool.ModuleData res) {
+        public ClassReader getClassReader(ModuleEntry res) {
             return visitPoolsEx((AsmModulePool pool) -> {
                 return pool.getClassReader(res);
             });
@@ -239,7 +239,7 @@
         }
 
         @Override
-        public void fillOutputResources(Pool outputResources) {
+        public void fillOutputResources(ModulePool outputResources) {
             AsmPools.this.fillOutputResources(outputResources);
         }
 
@@ -324,15 +324,15 @@
      *
      * @param inputResources The raw resources to build the pool from.
      */
-    public AsmPools(Pool inputResources) {
+    public AsmPools(ModulePool inputResources) {
         Objects.requireNonNull(inputResources);
-        Map<String, Pool> resPools = new LinkedHashMap<>();
+        Map<String, ModulePool> resPools = new LinkedHashMap<>();
         Map<String, ModuleDescriptor> descriptors = new HashMap<>();
-        for (Pool.ModuleData res : inputResources.getContent()) {
-            Pool p = resPools.get(res.getModule());
+        inputResources.entries().forEach(res -> {
+            ModulePool p = resPools.get(res.getModule());
             if (p == null) {
-                p = new PoolImpl(inputResources.getByteOrder(),
-                        ((PoolImpl)inputResources).getStringTable());
+                p = new ModulePoolImpl(inputResources.getByteOrder(),
+                        ((ModulePoolImpl)inputResources).getStringTable());
                 resPools.put(res.getModule(), p);
             }
             if (res.getPath().endsWith("module-info.class")) {
@@ -341,11 +341,11 @@
                 descriptors.put(res.getModule(), descriptor);
             }
             p.add(res);
-        }
+        });
         poolsArray = new AsmModulePool[resPools.size()];
         int i = 0;
 
-        for (Entry<String, Pool> entry : resPools.entrySet()) {
+        for (Entry<String, ModulePool> entry : resPools.entrySet()) {
             ModuleDescriptor descriptor = descriptors.get(entry.getKey());
             if (descriptor == null) {
                 throw new PluginException("module-info.class not found for " + entry.getKey() + " module");
@@ -405,7 +405,7 @@
      *
      * @param outputResources The pool used to fill the jimage.
      */
-    public void fillOutputResources(Pool outputResources) {
+    public void fillOutputResources(ModulePool outputResources) {
         // First sort modules
         List<String> modules = new ArrayList<>();
         for (String k : pools.keySet()) {
@@ -414,8 +414,8 @@
         if (moduleSorter != null) {
             modules = moduleSorter.sort(modules);
         }
-        Pool output = new PoolImpl(outputResources.getByteOrder(),
-                ((PoolImpl)outputResources).getStringTable());
+        ModulePool output = new ModulePoolImpl(outputResources.getByteOrder(),
+                ((ModulePoolImpl)outputResources).getStringTable());
         for (String mn : modules) {
             AsmPool pool = pools.get(mn);
             pool.fillOutputResources(output);
@@ -423,17 +423,17 @@
         sort(outputResources, output, global.sorter);
     }
 
-    static void sort(Pool outputResources,
-            Pool transientOutput, Sorter sorter) {
+    static void sort(ModulePool outputResources,
+            ModulePool transientOutput, Sorter sorter) {
         if (sorter != null) {
             List<String> order = sorter.sort(transientOutput);
             for (String s : order) {
-                outputResources.add(transientOutput.get(s));
+                outputResources.add(transientOutput.findEntry(s).get());
             }
         } else {
-            for (ModuleData res : transientOutput.getContent()) {
+            transientOutput.entries().forEach(res-> {
                 outputResources.add(res);
-            }
+            });
         }
     }
 
--- a/jdk/src/jdk.jlink/share/classes/jdk/tools/jlink/plugin/ExecutableImage.java	Thu May 19 17:48:02 2016 +0000
+++ b/jdk/src/jdk.jlink/share/classes/jdk/tools/jlink/plugin/ExecutableImage.java	Thu May 19 19:46:20 2016 +0000
@@ -24,66 +24,41 @@
  */
 package jdk.tools.jlink.plugin;
 
-import java.nio.file.Files;
 import java.nio.file.Path;
-import java.util.Collections;
 import java.util.List;
-import java.util.Objects;
 import java.util.Set;
 
 /**
- * An executable runtime image. Instance of this class contains the information
- * needed to create image processes.
+ * An executable runtime image. Contains the information about the executable
+ * image created.
  */
-public abstract class ExecutableImage {
-
-    private final Path home;
-    private final List<String> args;
-    private final Set<String> modules;
-
-    protected ExecutableImage(Path home, Set<String> modules,
-            List<String> args) {
-        Objects.requireNonNull(home);
-        Objects.requireNonNull(args);
-        if (!Files.exists(home)) {
-            throw new IllegalArgumentException("Invalid image home");
-        }
-        this.home = home;
-        this.modules = Collections.unmodifiableSet(modules);
-        this.args = Collections.unmodifiableList(args);
-    }
+public interface ExecutableImage {
 
     /**
      * Image home directory,
      *
      * @return The home directory.
      */
-    public Path getHome() {
-        return home;
-    }
+    public Path getHome();
 
     /**
      * The names of the modules located in the image.
      *
      * @return The set of modules.
      */
-    public Set<String> getModules() {
-        return modules;
-    }
+    public Set<String> getModules();
 
     /**
      * The list of arguments required to execute the image.
      *
      * @return The list of arguments.
      */
-    public List<String> getExecutionArgs() {
-        return args;
-    }
+    public List<String> getExecutionArgs();
 
     /**
      * Store new arguments required to execute the image.
      *
      * @param args Additional arguments
      */
-    public abstract void storeLaunchArgs(List<String> args);
+    public void storeLaunchArgs(List<String> args);
 }
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/jdk/src/jdk.jlink/share/classes/jdk/tools/jlink/plugin/LinkModule.java	Thu May 19 19:46:20 2016 +0000
@@ -0,0 +1,87 @@
+/*
+ * Copyright (c) 2016, Oracle and/or its affiliates. All rights reserved.
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * This code is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License version 2 only, as
+ * published by the Free Software Foundation.  Oracle designates this
+ * particular file as subject to the "Classpath" exception as provided
+ * by Oracle in the LICENSE file that accompanied this code.
+ *
+ * This code is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
+ * version 2 for more details (a copy is included in the LICENSE file that
+ * accompanied this code).
+ *
+ * You should have received a copy of the GNU General Public License version
+ * 2 along with this work; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
+ *
+ * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
+ * or visit www.oracle.com if you need additional information or have any
+ * questions.
+ */
+package jdk.tools.jlink.plugin;
+
+import java.lang.module.ModuleDescriptor;
+import java.util.Optional;
+import java.util.Set;
+import java.util.stream.Stream;
+
+/**
+  * Link-time representation of a Java module.
+  */
+public interface LinkModule {
+
+    /**
+     * The module name.
+     *
+     * @return The name.
+     */
+    public String getName();
+
+    /**
+     * Retrieves a LinkModuleEntry from the given path (e.g:
+     * /mymodule/com.foo.bar/MyClass.class)
+     *
+     * @param path The piece of data path.
+     * @return A LinkModuleEntry of the given path, if found.
+     */
+    public Optional<ModuleEntry> findEntry(String path);
+
+    /**
+     * The module descriptor of this module.
+     *
+     * @return The module descriptor.
+     */
+    public ModuleDescriptor getDescriptor();
+
+    /**
+     * Add a LinkModuleEntry to this module.
+     *
+     * @param data The LinkModuleEntry to add.
+     */
+    public void add(ModuleEntry data);
+
+    /**
+     * Retrieves all the packages located in this module.
+     *
+     * @return The set of packages.
+     */
+    public Set<String> getAllPackages();
+
+    /**
+     * Retrieves the stream of LinkModuleEntry.
+     *
+     * @return The LinkModuleEntry stream.
+     */
+    public Stream<? extends ModuleEntry> entries();
+
+    /**
+     * Return the number of LinkModuleEntry count in this LinkModule.
+     *
+     * @return the entry count.
+     */
+    public int getEntryCount();
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/jdk/src/jdk.jlink/share/classes/jdk/tools/jlink/plugin/ModuleEntry.java	Thu May 19 19:46:20 2016 +0000
@@ -0,0 +1,155 @@
+/*
+ * Copyright (c) 2016, Oracle and/or its affiliates. All rights reserved.
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * This code is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License version 2 only, as
+ * published by the Free Software Foundation.  Oracle designates this
+ * particular file as subject to the "Classpath" exception as provided
+ * by Oracle in the LICENSE file that accompanied this code.
+ *
+ * This code is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
+ * version 2 for more details (a copy is included in the LICENSE file that
+ * accompanied this code).
+ *
+ * You should have received a copy of the GNU General Public License version
+ * 2 along with this work; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
+ *
+ * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
+ * or visit www.oracle.com if you need additional information or have any
+ * questions.
+ */
+package jdk.tools.jlink.plugin;
+
+import java.io.ByteArrayInputStream;
+import java.io.InputStream;
+import java.util.Objects;
+import jdk.tools.jlink.internal.ImageFileCreator;
+import jdk.tools.jlink.internal.ModuleEntryImpl;
+
+/**
+ * A LinkModuleEntry is the elementary unit of data inside an image. It is
+ * generally a file. e.g.: a java class file, a resource file, a shared library,
+ * ...
+ * <br>
+ * A LinkModuleEntry is identified by a path of the form:
+ * <ul>
+ * <li>For jimage content: /{module name}/{package1}/.../{packageN}/{file
+ * name}</li>
+ * <li>For other files (shared lib, launchers, config, ...):/{module name}/
+ * {@literal bin|conf|native}/{dir1}>/.../{dirN}/{file name}</li>
+ * </ul>
+ */
+public interface ModuleEntry {
+
+    /**
+     * Type of module data.
+     * <li>
+     * <ul>CLASS_OR_RESOURCE: A java class or resource file.</ul>
+     * <ul>CONFIG: A configuration file.</ul>
+     * <ul>NATIVE_CMD: A native process launcher.</ul>
+     * <ul>NATIVE_LIB: A native library.</ul>
+     * <ul>OTHER: Other kind of file.</ul>
+     * </li>
+     */
+    public enum Type {
+        CLASS_OR_RESOURCE,
+        CONFIG,
+        NATIVE_CMD,
+        NATIVE_LIB,
+        OTHER
+    }
+    /**
+     * The LinkModuleEntry module name.
+     *
+     * @return The module name.
+     */
+    public String getModule();
+
+    /**
+     * The LinkModuleEntry path.
+     *
+     * @return The module path.
+     */
+    public String getPath();
+
+    /**
+     * The LinkModuleEntry's type.
+     *
+     * @return The data type.
+     */
+    public Type getType();
+
+    /**
+     * The LinkModuleEntry content as an array of byte.
+     *
+     * @return An Array of bytes.
+     */
+    public byte[] getBytes();
+
+    /**
+     * The LinkModuleEntry content length.
+     *
+     * @return The length.
+     */
+    public long getLength();
+
+    /**
+     * The LinkModuleEntry stream.
+     *
+     * @return The module data stream.
+     */
+    public InputStream stream();
+
+
+    /**
+     * Create a LinkModuleEntry located inside a jimage file. Such
+     * LinkModuleEntry has a Type being equals to CLASS_OR_RESOURCE.
+     *
+     * @param path The complete resource path (contains the module radical).
+     * @param content The resource content.
+     * @param size The content size.
+     * @return A new LinkModuleEntry.
+     */
+    public static ModuleEntry create(String path, InputStream content, long size) {
+        Objects.requireNonNull(path);
+        Objects.requireNonNull(content);
+        String[] split = ImageFileCreator.splitPath(path);
+        String module = split[0];
+        return new ModuleEntryImpl(module, path, Type.CLASS_OR_RESOURCE, content, size);
+    }
+
+    /**
+     * Create a LinkModuleEntry for a file that will be located inside a jimage
+     * file.
+     *
+     * @param path The resource path.
+     * @param content The resource content.
+     * @return A new LinkModuleEntry.
+     */
+    public static ModuleEntry create(String path, byte[] content) {
+        return create(path, new ByteArrayInputStream(content),
+                content.length);
+    }
+
+    /**
+     * Create a LinkModuleEntry for a file that will be located outside a jimage
+     * file.
+     *
+     * @param module The module in which this files is located.
+     * @param path The file path locator (doesn't contain the module name).
+     * @param type The LinkModuleEntry type.
+     * @param content The file content.
+     * @param size The content size.
+     * @return A new LinkModuleEntry.
+     */
+    public static ModuleEntry create(String module, String path, ModuleEntry.Type type,
+            InputStream content, long size) {
+        Objects.requireNonNull(path);
+        Objects.requireNonNull(content);
+        return new ModuleEntryImpl(module, path, type, content, size);
+    }
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/jdk/src/jdk.jlink/share/classes/jdk/tools/jlink/plugin/ModulePool.java	Thu May 19 19:46:20 2016 +0000
@@ -0,0 +1,136 @@
+/*
+ * Copyright (c) 2015, Oracle and/or its affiliates. All rights reserved.
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * This code is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License version 2 only, as
+ * published by the Free Software Foundation.  Oracle designates this
+ * particular file as subject to the "Classpath" exception as provided
+ * by Oracle in the LICENSE file that accompanied this code.
+ *
+ * This code is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
+ * version 2 for more details (a copy is included in the LICENSE file that
+ * accompanied this code).
+ *
+ * You should have received a copy of the GNU General Public License version
+ * 2 along with this work; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
+ *
+ * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
+ * or visit www.oracle.com if you need additional information or have any
+ * questions.
+ */
+package jdk.tools.jlink.plugin;
+
+import java.nio.ByteOrder;
+import java.util.Map;
+import java.util.Optional;
+import java.util.function.Function;
+import java.util.stream.Stream;
+
+/**
+ * Pool of module data.
+ */
+public interface ModulePool {
+/**
+     * Is this a read-only ModulePool?
+     *
+     * @return true if this is a read-only configuration.
+     */
+    public boolean isReadOnly();
+
+    /**
+     * Add a ModuleEntry.
+     *
+     * @param data The ModuleEntry to add.
+     */
+    public void add(ModuleEntry data);
+    /**
+     * Retrieves the module for the provided name.
+     *
+     * @param name The module name
+     * @return the module of matching name, if found
+     */
+    public Optional<LinkModule> findModule(String name);
+
+    /**
+     * The stream of modules contained in this ModulePool.
+     *
+     * @return The stream of modules.
+     */
+    public Stream<? extends LinkModule> modules();
+
+    /**
+     * Return the number of LinkModule count in this ModulePool.
+     *
+     * @return the module count.
+     */
+    public int getModuleCount();
+
+    /**
+     * Get all ModuleEntry contained in this ModulePool instance.
+     *
+     * @return The stream of LinkModuleEntries.
+     */
+    public Stream<? extends ModuleEntry> entries();
+
+    /**
+     * Return the number of ModuleEntry count in this ModulePool.
+     *
+     * @return the entry count.
+     */
+    public int getEntryCount();
+
+    /**
+     * Get the ModuleEntry for the passed path.
+     *
+     * @param path A data path
+     * @return A ModuleEntry instance or null if the data is not found
+     */
+   public Optional<ModuleEntry> findEntry(String path);
+
+    /**
+     * Check if the ModulePool contains the given ModuleEntry.
+     *
+     * @param data The module data to check existence for.
+     * @return The module data or null if not found.
+     */
+    public boolean contains(ModuleEntry data);
+
+    /**
+     * Check if the ModulePool contains some content at all.
+     *
+     * @return True, no content, false otherwise.
+     */
+    public boolean isEmpty();
+
+    /**
+     * Visit each ModuleEntry in this ModulePool to transform it and copy
+     * the transformed ModuleEntry to the output ModulePool.
+     *
+     * @param transform The function called for each ModuleEntry found in the
+     * ModulePool. The transform function should return a ModuleEntry
+     * instance which will be added to the output or it should return null if
+     * the passed ModuleEntry is to be ignored for the output.
+     *
+     * @param output The ModulePool to be filled with Visitor returned
+     * ModuleEntry.
+     */
+    public void transformAndCopy(Function<ModuleEntry, ModuleEntry> transform, ModulePool output);
+
+    /**
+     * The ByteOrder currently in use when generating the jimage file.
+     *
+     * @return The ByteOrder.
+     */
+    public ByteOrder getByteOrder();
+
+    /**
+     * Release properties such as OS, CPU name, version etc.
+     *
+     * @return the release properties
+     */
+    public Map<String, String> getReleaseProperties();
+}
--- a/jdk/src/jdk.jlink/share/classes/jdk/tools/jlink/plugin/Plugin.java	Thu May 19 17:48:02 2016 +0000
+++ b/jdk/src/jdk.jlink/share/classes/jdk/tools/jlink/plugin/Plugin.java	Thu May 19 19:46:20 2016 +0000
@@ -26,7 +26,6 @@
 
 import java.util.Collections;
 import java.util.EnumSet;
-import java.util.List;
 import java.util.Map;
 import java.util.Set;
 import jdk.tools.jlink.internal.plugins.PluginsResourceBundle;
@@ -37,14 +36,6 @@
 public interface Plugin {
 
     /**
-     * Type of plugin.
-     */
-    public interface PluginType {
-
-        public String getName();
-    }
-
-    /**
      * Order of categories:
      * <ol>
      * <li>FILTER: Filter in/out resources or files.</li>
@@ -53,28 +44,29 @@
      * <li>MODULEINFO_TRANSFORMER: Transform only module-info.class</li>
      * <li>SORTER: Sort resources within the resource container.</li>
      * <li>COMPRESSOR: Compress resource within the resouce containers.</li>
+     * <li>METAINFO_ADDER: Added meta info (like release, copyright etc.)</li>
      * <li>VERIFIER: Does some image verification.</li>
      * <li>PROCESSOR: Does some post processing on image.</li>
      * <li>PACKAGER: Final processing</li>
      * </ol>
      */
-    public enum CATEGORY implements PluginType {
+    public enum Category {
         FILTER("FILTER"),
         TRANSFORMER("TRANSFORMER"),
         MODULEINFO_TRANSFORMER("MODULEINFO_TRANSFORMER"),
         SORTER("SORTER"),
         COMPRESSOR("COMPRESSOR"),
+        METAINFO_ADDER("METAINFO_ADDER"),
         VERIFIER("VERIFIER"),
         PROCESSOR("PROCESSOR"),
         PACKAGER("PACKAGER");
 
         private final String name;
 
-        CATEGORY(String name) {
+        Category(String name) {
             this.name = name;
         }
 
-        @Override
         public String getName() {
             return name;
         }
@@ -91,7 +83,7 @@
      * {@link #getStateDescription() getStateDescription} method</li>
      * </ul>
      */
-    public enum STATE {
+    public enum State {
         DISABLED,
         AUTO_ENABLED,
         FUNCTIONAL
@@ -101,7 +93,7 @@
      * The Plugin set of types.
      * @return The set of types.
      */
-    public default Set<PluginType> getType() {
+    public default Set<Category> getType() {
         return Collections.emptySet();
     }
 
@@ -109,8 +101,8 @@
      * The Plugin set of states.
      * @return The set of states.
      */
-    public default Set<STATE> getState() {
-        return EnumSet.of(STATE.FUNCTIONAL);
+    public default Set<State> getState() {
+        return EnumSet.of(State.FUNCTIONAL);
     }
 
     /**
@@ -191,7 +183,7 @@
      * @return A status description.
      */
     public default String getStateDescription() {
-        return getState().contains(STATE.FUNCTIONAL)
+        return getState().contains(State.FUNCTIONAL)
                 ? PluginsResourceBundle.getMessage("main.status.ok")
                 : PluginsResourceBundle.getMessage("main.status.not.ok");
     }
@@ -206,18 +198,4 @@
      */
     public default void configure(Map<String, String> config) {
     }
-
-    /**
-     * Configure the plugin based on the passed configuration.
-     * This method is called prior to invoke the plugin.
-     *
-     * @param config The plugin configuration.
-     * @param ctx The plugin context
-     * @throws IllegalArgumentException if a mandatory argument is missing or
-     * if an argument has invalid value.
-     *
-     */
-    public default void configure(Map<String, String> config, PluginContext ctx) {
-        configure(config);
-    }
 }
--- a/jdk/src/jdk.jlink/share/classes/jdk/tools/jlink/plugin/PluginContext.java	Thu May 19 17:48:02 2016 +0000
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,37 +0,0 @@
-/*
- * Copyright (c) 2016, Oracle and/or its affiliates. All rights reserved.
- * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
- *
- * This code is free software; you can redistribute it and/or modify it
- * under the terms of the GNU General Public License version 2 only, as
- * published by the Free Software Foundation.  Oracle designates this
- * particular file as subject to the "Classpath" exception as provided
- * by Oracle in the LICENSE file that accompanied this code.
- *
- * This code is distributed in the hope that it will be useful, but WITHOUT
- * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
- * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
- * version 2 for more details (a copy is included in the LICENSE file that
- * accompanied this code).
- *
- * You should have received a copy of the GNU General Public License version
- * 2 along with this work; if not, write to the Free Software Foundation,
- * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
- *
- * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
- * or visit www.oracle.com if you need additional information or have any
- * questions.
- */
-package jdk.tools.jlink.plugin;
-
-import java.util.Properties;
-
-/**
- * Interface to plugin (container) context.
- */
-public interface PluginContext {
-    /**
-     * Returns 'release' properties
-     */
-    public Properties getReleaseProperties();
-}
--- a/jdk/src/jdk.jlink/share/classes/jdk/tools/jlink/plugin/Pool.java	Thu May 19 17:48:02 2016 +0000
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,528 +0,0 @@
-/*
- * Copyright (c) 2015, Oracle and/or its affiliates. All rights reserved.
- * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
- *
- * This code is free software; you can redistribute it and/or modify it
- * under the terms of the GNU General Public License version 2 only, as
- * published by the Free Software Foundation.  Oracle designates this
- * particular file as subject to the "Classpath" exception as provided
- * by Oracle in the LICENSE file that accompanied this code.
- *
- * This code is distributed in the hope that it will be useful, but WITHOUT
- * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
- * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
- * version 2 for more details (a copy is included in the LICENSE file that
- * accompanied this code).
- *
- * You should have received a copy of the GNU General Public License version
- * 2 along with this work; if not, write to the Free Software Foundation,
- * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
- *
- * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
- * or visit www.oracle.com if you need additional information or have any
- * questions.
- */
-package jdk.tools.jlink.plugin;
-
-import java.io.ByteArrayInputStream;
-import java.io.IOException;
-import java.io.InputStream;
-import java.io.UncheckedIOException;
-import java.lang.module.ModuleDescriptor;
-import java.nio.ByteBuffer;
-import java.nio.ByteOrder;
-import java.util.Collection;
-import java.util.Collections;
-import java.util.HashSet;
-import java.util.LinkedHashMap;
-import java.util.Map;
-import java.util.Objects;
-import java.util.Set;
-import jdk.tools.jlink.internal.ImageFileCreator;
-import jdk.tools.jlink.internal.plugins.FileCopierPlugin;
-
-/**
- * Pool of module data.
- *
- */
-public abstract class Pool {
-
-    /**
-     * Interface to visit the content of a Pool.
-     */
-    public interface Visitor {
-
-        /**
-         * Called for each visited ModuleData.
-         *
-         * @param content A ModuleData
-         * @return A ModuleData instance or null if the passed ModuleData is to
-         * be removed from the image.
-         * @throws PluginException
-         */
-        public ModuleData visit(ModuleData content);
-    }
-
-    /**
-     * Type of module data.
-     * <li>
-     * <ul>CLASS_OR_RESOURCE: A java class or resource file.</ul>
-     * <ul>CONFIG: A configuration file.</ul>
-     * <ul>NATIVE_CMD: A native process launcher.</ul>
-     * <ul>NATIVE_LIB: A native library.</ul>
-     * <ul>OTHER: Other kind of file.</ul>
-     * </li>
-     */
-    public static enum ModuleDataType {
-
-        CLASS_OR_RESOURCE,
-        CONFIG,
-        NATIVE_CMD,
-        NATIVE_LIB,
-        OTHER;
-    }
-
-    /**
-     * A module in the pool.
-     */
-    public interface Module {
-
-        /**
-         * The module name.
-         *
-         * @return The name.
-         */
-        public String getName();
-
-        /**
-         * Retrieves a ModuleData from a path (e.g:
-         * /mymodule/com.foo.bar/MyClass.class)
-         *
-         * @param path The piece of data path.
-         * @return A ModuleData or null if the path doesn't identify a
-         * ModuleData.
-         */
-        public ModuleData get(String path);
-
-        /**
-         * The module descriptor of this module.
-         *
-         * @return The module descriptor.
-         */
-        public ModuleDescriptor getDescriptor();
-
-        /**
-         * Add a ModuleData to this module.
-         *
-         * @param data The ModuleData to add.
-         */
-        public void add(ModuleData data);
-
-        /**
-         * Retrieves all the packages located in this module.
-         *
-         * @return The set of packages.
-         */
-        public Set<String> getAllPackages();
-
-        /**
-         * Retrieves the collection of ModuleData.
-         *
-         * @return The ModuleData collection.
-         */
-        public Collection<ModuleData> getContent();
-
-    }
-
-    private class ModuleImpl implements Module {
-
-        private final Map<String, ModuleData> moduleContent = new LinkedHashMap<>();
-        private ModuleDescriptor descriptor;
-        private final String name;
-
-        private ModuleImpl(String name) {
-            this.name = name;
-        }
-
-        @Override
-        public String getName() {
-            return name;
-        }
-
-        @Override
-        public ModuleData get(String path) {
-            if (!path.startsWith("/")) {
-                path = "/" + path;
-            }
-            if (!path.startsWith("/" + name)) {
-                path = "/" + name + path;
-            }
-            return moduleContent.get(path);
-        }
-
-        @Override
-        public ModuleDescriptor getDescriptor() {
-            if (descriptor == null) {
-                String p = "/" + name + "/module-info.class";
-                ModuleData content = moduleContent.get(p);
-                if (content == null) {
-                    throw new PluginException("No module-info for " + name
-                            + " module");
-                }
-                ByteBuffer bb = ByteBuffer.wrap(content.getBytes());
-                descriptor = ModuleDescriptor.read(bb);
-            }
-            return descriptor;
-        }
-
-        @Override
-        public void add(ModuleData data) {
-            if (isReadOnly()) {
-                throw new PluginException("pool is readonly");
-            }
-            Objects.requireNonNull(data);
-            if (!data.getModule().equals(name)) {
-                throw new PluginException("Can't add resource " + data.getPath()
-                        + " to module " + name);
-            }
-            Pool.this.add(data);
-        }
-
-        @Override
-        public Set<String> getAllPackages() {
-            Set<String> pkgs = new HashSet<>();
-            moduleContent.values().stream().filter(m -> m.getType().
-                    equals(ModuleDataType.CLASS_OR_RESOURCE)).forEach((res) -> {
-                // Module metadata only contains packages with .class files
-                if (ImageFileCreator.isClassPackage(res.getPath())) {
-                    String[] split = ImageFileCreator.splitPath(res.getPath());
-                    String pkg = split[1];
-                    if (pkg != null && !pkg.isEmpty()) {
-                        pkgs.add(pkg);
-                    }
-                }
-            });
-            return pkgs;
-        }
-
-        @Override
-        public String toString() {
-            return getName();
-        }
-
-        @Override
-        public Collection<ModuleData> getContent() {
-            return Collections.unmodifiableCollection(moduleContent.values());
-        }
-    }
-
-    /**
-     * A ModuleData is the elementary unit of data inside an image. It is
-     * generally a file. e.g.: a java class file, a resource file, a shared
-     * library, ...
-     * <br>
-     * A ModuleData is identified by a path of the form:
-     * <ul>
-     * <li>For jimage content: /{module name}/{package1}/.../{packageN}/{file
-     * name}</li>
-     * <li>For other files (shared lib, launchers, config, ...):/{module name}/
-     * {@literal bin|conf|native}/{dir1}/.../{dirN}/{file name}</li>
-     * </ul>
-     */
-    public static class ModuleData {
-
-        private final ModuleDataType type;
-        private final String path;
-        private final String module;
-        private final long length;
-        private final InputStream stream;
-        private byte[] buffer;
-
-        /**
-         * Create a new ModuleData.
-         *
-         * @param module The module name.
-         * @param path The data path identifier.
-         * @param type The data type.
-         * @param stream The data content stream.
-         * @param length The stream length.
-         */
-        public ModuleData(String module, String path, ModuleDataType type,
-                InputStream stream, long length) {
-            Objects.requireNonNull(module);
-            Objects.requireNonNull(path);
-            Objects.requireNonNull(type);
-            Objects.requireNonNull(stream);
-            this.path = path;
-            this.type = type;
-            this.module = module;
-            this.stream = stream;
-            this.length = length;
-        }
-
-        /**
-         * The ModuleData module name.
-         *
-         * @return The module name.
-         */
-        public final String getModule() {
-            return module;
-        }
-
-        /**
-         * The ModuleData path.
-         *
-         * @return The module path.
-         */
-        public final String getPath() {
-            return path;
-        }
-
-        /**
-         * The ModuleData type.
-         *
-         * @return The data type.
-         */
-        public final ModuleDataType getType() {
-            return type;
-        }
-
-        /**
-         * The ModuleData content as an array of byte.
-         *
-         * @return An Array of bytes.
-         */
-        public byte[] getBytes() {
-            if (buffer == null) {
-                try {
-                    buffer = stream.readAllBytes();
-                } catch (IOException ex) {
-                    throw new UncheckedIOException(ex);
-                }
-            }
-            return buffer;
-        }
-
-        /**
-         * The ModuleData content length.
-         *
-         * @return The length.
-         */
-        public long getLength() {
-            return length;
-        }
-
-        /**
-         * The ModuleData stream.
-         *
-         * @return The module data stream.
-         */
-        public InputStream stream() {
-            return stream;
-        }
-
-        @Override
-        public int hashCode() {
-            int hash = 7;
-            hash = 89 * hash + Objects.hashCode(this.path);
-            return hash;
-        }
-
-        @Override
-        public boolean equals(Object other) {
-            if (!(other instanceof ModuleData)) {
-                return false;
-            }
-            ModuleData f = (ModuleData) other;
-            return f.path.equals(path);
-        }
-
-        @Override
-        public String toString() {
-            return getPath();
-        }
-    }
-
-    private final Map<String, ModuleData> resources = new LinkedHashMap<>();
-    private final Map<String, ModuleImpl> modules = new LinkedHashMap<>();
-    private final ModuleImpl fileCopierModule = new ModuleImpl(FileCopierPlugin.FAKE_MODULE);
-
-    private final ByteOrder order;
-
-    protected Pool() {
-        this(ByteOrder.nativeOrder());
-    }
-
-    protected Pool(ByteOrder order) {
-        Objects.requireNonNull(order);
-        this.order = order;
-    }
-
-    /**
-     * Read only state. No data can be added to a ReadOnly Pool.
-     *
-     * @return true if readonly false otherwise.
-     */
-    public abstract boolean isReadOnly();
-
-    /**
-     * Add a ModuleData.
-     *
-     * @param data The ModuleData to add.
-     */
-    public void add(ModuleData data) {
-        if (isReadOnly()) {
-            throw new PluginException("pool is readonly");
-        }
-        Objects.requireNonNull(data);
-        if (resources.get(data.getPath()) != null) {
-            throw new PluginException("Resource " + data.getPath()
-                    + " already present");
-        }
-        String modulename = data.getModule();
-        ModuleImpl m = modules.get(modulename);
-        // ## TODO: FileCopierPlugin should not add content to a module
-        // FAKE_MODULE is not really a module to be added in the image
-        if (FileCopierPlugin.FAKE_MODULE.equals(modulename)) {
-            m = fileCopierModule;
-        }
-        if (m == null) {
-            m = new ModuleImpl(modulename);
-            modules.put(modulename, m);
-        }
-        resources.put(data.getPath(), data);
-        m.moduleContent.put(data.getPath(), data);
-    }
-
-    /**
-     * Retrieves the module for the provided name.
-     *
-     * @param name The module name
-     * @return the module or null if the module doesn't exist.
-     */
-    public Module getModule(String name) {
-        Objects.requireNonNull(name);
-        return modules.get(name);
-    }
-
-    /**
-     * The collection of modules contained in this pool.
-     *
-     * @return The collection of modules.
-     */
-    public Collection<Module> getModules() {
-        return Collections.unmodifiableCollection(modules.values());
-    }
-
-    /**
-     * Get all ModuleData contained in this pool instance.
-     *
-     * @return The collection of resources;
-     */
-    public Collection<ModuleData> getContent() {
-        return Collections.unmodifiableCollection(resources.values());
-    }
-
-    /**
-     * Get the ModuleData for the passed path.
-     *
-     * @param path A data path
-     * @return A ModuleData instance or null if the data is not found
-     */
-    public ModuleData get(String path) {
-        Objects.requireNonNull(path);
-        return resources.get(path);
-    }
-
-    /**
-     * Check if the pool contains this data.
-     *
-     * @param data The module data to check existence for.
-     * @return The module data or null if not found.
-     */
-    public boolean contains(ModuleData data) {
-        Objects.requireNonNull(data);
-        return get(data.getPath()) != null;
-    }
-
-    /**
-     * Check if the Pool contains some content.
-     *
-     * @return True, no content, false otherwise.
-     */
-    public boolean isEmpty() {
-        return resources.isEmpty();
-    }
-
-    /**
-     * Visit the pool.
-     *
-     * @param visitor The Visitor called for each ModuleData found in the pool.
-     * @param output The pool to be filled with Visitor returned ModuleData.
-     */
-    public void visit(Visitor visitor, Pool output) {
-        for (ModuleData resource : getContent()) {
-            ModuleData res = visitor.visit(resource);
-            if (res != null) {
-                output.add(res);
-            }
-        }
-    }
-
-    /**
-     * The ByteOrder currently in use when generating the jimage file.
-     *
-     * @return The ByteOrder.
-     */
-    public ByteOrder getByteOrder() {
-        return order;
-    }
-
-    /**
-     * Create a ModuleData located inside a jimage file. Such ModuleData has a
-     * ModuleDataType being equals to CLASS_OR_RESOURCE.
-     *
-     * @param path The complete resource path (contains the module radical).
-     * @param content The resource content.
-     * @param size The content size.
-     * @return A new ModuleData.
-     */
-    public static ModuleData newResource(String path, InputStream content, long size) {
-        Objects.requireNonNull(path);
-        Objects.requireNonNull(content);
-        String[] split = ImageFileCreator.splitPath(path);
-        String module = split[0];
-        return new ModuleData(module, path, ModuleDataType.CLASS_OR_RESOURCE, content, size);
-    }
-
-    /**
-     * Create a ModuleData for a file that will be located inside a jimage file.
-     *
-     * @param path The resource path.
-     * @param content The resource content.
-     * @return A new ModuleData.
-     */
-    public static ModuleData newResource(String path, byte[] content) {
-        return newResource(path, new ByteArrayInputStream(content),
-                content.length);
-    }
-
-    /**
-     * Create a ModuleData for a file that will be located outside a jimage
-     * file.
-     *
-     * @param module The module in which this files is located.
-     * @param path The file path locator (doesn't contain the module name).
-     * @param type The ModuleData type.
-     * @param content The file content.
-     * @param size The content size.
-     * @return A new ModuleData.
-     */
-    public static ModuleData newImageFile(String module, String path, ModuleDataType type,
-            InputStream content, long size) {
-        Objects.requireNonNull(path);
-        Objects.requireNonNull(content);
-        return new ModuleData(module, path, type, content, size);
-    }
-
-}
--- a/jdk/src/jdk.jlink/share/classes/jdk/tools/jlink/plugin/TransformerPlugin.java	Thu May 19 17:48:02 2016 +0000
+++ b/jdk/src/jdk.jlink/share/classes/jdk/tools/jlink/plugin/TransformerPlugin.java	Thu May 19 19:46:20 2016 +0000
@@ -40,5 +40,5 @@
      *
      * @throws PluginException
      */
-    public void visit(Pool in, Pool out);
+    public void visit(ModulePool in, ModulePool out);
 }
--- a/jdk/src/jdk.jlink/share/classes/module-info.java	Thu May 19 17:48:02 2016 +0000
+++ b/jdk/src/jdk.jlink/share/classes/module-info.java	Thu May 19 19:46:20 2016 +0000
@@ -24,9 +24,7 @@
  */
 
 module jdk.jlink {
-    exports jdk.tools.jlink;
     exports jdk.tools.jlink.plugin;
-    exports jdk.tools.jlink.builder;
 
     requires jdk.internal.opt;
     requires jdk.jdeps;
@@ -46,5 +44,5 @@
     provides jdk.tools.jlink.plugin.TransformerPlugin with jdk.tools.jlink.internal.plugins.ExcludeVMPlugin;
     provides jdk.tools.jlink.plugin.TransformerPlugin with jdk.tools.jlink.internal.plugins.IncludeLocalesPlugin;
     provides jdk.tools.jlink.plugin.TransformerPlugin with jdk.tools.jlink.internal.plugins.GenerateJLIClassesPlugin;
-    provides jdk.tools.jlink.plugin.PostProcessorPlugin with jdk.tools.jlink.internal.plugins.ReleaseInfoPlugin;
+    provides jdk.tools.jlink.plugin.TransformerPlugin with jdk.tools.jlink.internal.plugins.ReleaseInfoPlugin;
 }
--- a/jdk/src/jdk.pack200/share/native/common-unpack/constants.h	Thu May 19 17:48:02 2016 +0000
+++ b/jdk/src/jdk.pack200/share/native/common-unpack/constants.h	Thu May 19 19:46:20 2016 +0000
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2001, 2013, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2001, 2016, Oracle and/or its affiliates. All rights reserved.
  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
  *
  * This code is free software; you can redistribute it and/or modify it
@@ -23,30 +23,10 @@
  * questions.
  */
 
-/*
-  Java Class Version numbers history
-  1.0 to 1.3.X 45,3
-  1.4 to 1.4.X 46,0
-  1.5 to 1.5.X 49,0
-  1.6 to 1.5.x 50,0 NOTE Assumed for now
-*/
-
 // classfile constants
 #define JAVA_MAGIC 0xCAFEBABE
-#define JAVA_MIN_MAJOR_VERSION 45
-#define JAVA_MIN_MINOR_VERSION 3
 
-#define JAVA5_MAX_MAJOR_VERSION 49
-#define JAVA5_MAX_MINOR_VERSION 0
-
-#define JAVA6_MAX_MAJOR_VERSION 50
-#define JAVA6_MAX_MINOR_VERSION 0
-
-#define JAVA7_MAX_MAJOR_VERSION 51
-#define JAVA7_MAX_MINOR_VERSION 0
-
-#define JAVA8_MAX_MAJOR_VERSION 52
-#define JAVA8_MAX_MINOR_VERSION 0
+// Class version history, refer to Constants.java
 
 // package file constants
 #define JAVA_PACKAGE_MAGIC 0xCAFED00D
--- a/jdk/src/jdk.unsupported/share/classes/sun/misc/SoftCache.java	Thu May 19 17:48:02 2016 +0000
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,462 +0,0 @@
-/*
- * Copyright (c) 1998, 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 sun.misc;
-
-import java.lang.ref.SoftReference;
-import java.lang.ref.ReferenceQueue;
-
-import java.util.Iterator;
-import java.util.Map;
-import java.util.AbstractMap;
-import java.util.HashMap;
-import java.util.Set;
-import java.util.AbstractSet;
-import java.util.NoSuchElementException;
-
-
-/**
- * A memory-sensitive implementation of the <code>Map</code> interface.
- *
- * <p> A <code>SoftCache</code> object uses {@link java.lang.ref.SoftReference
- * soft references} to implement a memory-sensitive hash map.  If the garbage
- * collector determines at a certain point in time that a value object in a
- * <code>SoftCache</code> entry is no longer strongly reachable, then it may
- * remove that entry in order to release the memory occupied by the value
- * object.  All <code>SoftCache</code> objects are guaranteed to be completely
- * cleared before the virtual machine will throw an
- * <code>OutOfMemoryError</code>.  Because of this automatic clearing feature,
- * the behavior of this class is somewhat different from that of other
- * <code>Map</code> implementations.
- *
- * <p> Both null values and the null key are supported.  This class has the
- * same performance characteristics as the <code>HashMap</code> class, and has
- * the same efficiency parameters of <em>initial capacity</em> and <em>load
- * factor</em>.
- *
- * <p> Like most collection classes, this class is not synchronized.  A
- * synchronized <code>SoftCache</code> may be constructed using the
- * <code>Collections.synchronizedMap</code> method.
- *
- * <p> In typical usage this class will be subclassed and the <code>fill</code>
- * method will be overridden.  When the <code>get</code> method is invoked on a
- * key for which there is no mapping in the cache, it will in turn invoke the
- * <code>fill</code> method on that key in an attempt to construct a
- * corresponding value.  If the <code>fill</code> method returns such a value
- * then the cache will be updated and the new value will be returned.  Thus,
- * for example, a simple URL-content cache can be constructed as follows:
- *
- * <pre>
- *     public class URLCache extends SoftCache {
- *         protected Object fill(Object key) {
- *             return ((URL)key).getContent();
- *         }
- *     }
- * </pre>
- *
- * <p> The behavior of the <code>SoftCache</code> class depends in part upon
- * the actions of the garbage collector, so several familiar (though not
- * required) <code>Map</code> invariants do not hold for this class.  <p>
- * Because entries are removed from a <code>SoftCache</code> in response to
- * dynamic advice from the garbage collector, a <code>SoftCache</code> may
- * behave as though an unknown thread is silently removing entries.  In
- * particular, even if you synchronize on a <code>SoftCache</code> instance and
- * invoke none of its mutator methods, it is possible for the <code>size</code>
- * method to return smaller values over time, for the <code>isEmpty</code>
- * method to return <code>false</code> and then <code>true</code>, for the
- * <code>containsKey</code> method to return <code>true</code> and later
- * <code>false</code> for a given key, for the <code>get</code> method to
- * return a value for a given key but later return <code>null</code>, for the
- * <code>put</code> method to return <code>null</code> and the
- * <code>remove</code> method to return <code>false</code> for a key that
- * previously appeared to be in the map, and for successive examinations of the
- * key set, the value set, and the entry set to yield successively smaller
- * numbers of elements.
- *
- * @author      Mark Reinhold
- * @since       1.2
- * @see         java.util.HashMap
- * @see         java.lang.ref.SoftReference
- * @deprecated No direct replacement; {@link java.util.WeakHashMap}
- * addresses a related by different use-case.
- */
-
-@Deprecated
-public class SoftCache extends AbstractMap<Object, Object> implements Map<Object, Object> {
-
-    /* The basic idea of this implementation is to maintain an internal HashMap
-       that maps keys to soft references whose referents are the keys' values;
-       the various accessor methods dereference these soft references before
-       returning values.  Because we don't have access to the innards of the
-       HashMap, each soft reference must contain the key that maps to it so
-       that the processQueue method can remove keys whose values have been
-       discarded.  Thus the HashMap actually maps keys to instances of the
-       ValueCell class, which is a simple extension of the SoftReference class.
-     */
-
-
-    private static class ValueCell extends SoftReference<Object> {
-        private static Object INVALID_KEY = new Object();
-        private static int dropped = 0;
-        private Object key;
-
-        private ValueCell(Object key, Object value, ReferenceQueue<Object> queue) {
-            super(value, queue);
-            this.key = key;
-        }
-
-        private static ValueCell create(Object key, Object value,
-                                        ReferenceQueue<Object> queue)
-        {
-            if (value == null) return null;
-            return new ValueCell(key, value, queue);
-        }
-
-        private static Object strip(Object val, boolean drop) {
-            if (val == null) return null;
-            ValueCell vc = (ValueCell)val;
-            Object o = vc.get();
-            if (drop) vc.drop();
-            return o;
-        }
-
-        private boolean isValid() {
-            return (key != INVALID_KEY);
-        }
-
-        private void drop() {
-            super.clear();
-            key = INVALID_KEY;
-            dropped++;
-        }
-
-    }
-
-
-    /* Hash table mapping keys to ValueCells */
-    private Map<Object, Object> hash;
-
-    /* Reference queue for cleared ValueCells */
-    private ReferenceQueue<Object> queue = new ReferenceQueue<>();
-
-
-    /* Process any ValueCells that have been cleared and enqueued by the
-       garbage collector.  This method should be invoked once by each public
-       mutator in this class.  We don't invoke this method in public accessors
-       because that can lead to surprising ConcurrentModificationExceptions.
-     */
-    private void processQueue() {
-        ValueCell vc;
-        while ((vc = (ValueCell)queue.poll()) != null) {
-            if (vc.isValid()) hash.remove(vc.key);
-            else ValueCell.dropped--;
-        }
-    }
-
-
-    /* -- Constructors -- */
-
-    /**
-     * Construct a new, empty <code>SoftCache</code> with the given
-     * initial capacity and the given load factor.
-     *
-     * @param  initialCapacity  The initial capacity of the cache
-     *
-     * @param  loadFactor       A number between 0.0 and 1.0
-     *
-     * @throws IllegalArgumentException  If the initial capacity is less than
-     *                                   or equal to zero, or if the load
-     *                                   factor is less than zero
-     */
-    public SoftCache(int initialCapacity, float loadFactor) {
-        hash = new HashMap<>(initialCapacity, loadFactor);
-    }
-
-    /**
-     * Construct a new, empty <code>SoftCache</code> with the given
-     * initial capacity and the default load factor.
-     *
-     * @param  initialCapacity  The initial capacity of the cache
-     *
-     * @throws IllegalArgumentException  If the initial capacity is less than
-     *                                   or equal to zero
-     */
-    public SoftCache(int initialCapacity) {
-        hash = new HashMap<>(initialCapacity);
-    }
-
-    /**
-     * Construct a new, empty <code>SoftCache</code> with the default
-     * capacity and the default load factor.
-     */
-    public SoftCache() {
-        hash = new HashMap<>();
-    }
-
-
-    /* -- Simple queries -- */
-
-    /**
-     * Return the number of key-value mappings in this cache.  The time
-     * required by this operation is linear in the size of the map.
-     */
-    public int size() {
-        return entrySet().size();
-    }
-
-    /**
-     * Return <code>true</code> if this cache contains no key-value mappings.
-     */
-    public boolean isEmpty() {
-        return entrySet().isEmpty();
-    }
-
-    /**
-     * Return <code>true</code> if this cache contains a mapping for the
-     * specified key.  If there is no mapping for the key, this method will not
-     * attempt to construct one by invoking the <code>fill</code> method.
-     *
-     * @param   key   The key whose presence in the cache is to be tested
-     */
-    public boolean containsKey(Object key) {
-        return ValueCell.strip(hash.get(key), false) != null;
-    }
-
-
-    /* -- Lookup and modification operations -- */
-
-    /**
-     * Create a value object for the given <code>key</code>.  This method is
-     * invoked by the <code>get</code> method when there is no entry for
-     * <code>key</code>.  If this method returns a non-<code>null</code> value,
-     * then the cache will be updated to map <code>key</code> to that value,
-     * and that value will be returned by the <code>get</code> method.
-     *
-     * <p> The default implementation of this method simply returns
-     * <code>null</code> for every <code>key</code> value.  A subclass may
-     * override this method to provide more useful behavior.
-     *
-     * @param  key  The key for which a value is to be computed
-     *
-     * @return      A value for <code>key</code>, or <code>null</code> if one
-     *              could not be computed
-     * @see #get
-     */
-    protected Object fill(Object key) {
-        return null;
-    }
-
-    /**
-     * Return the value to which this cache maps the specified
-     * <code>key</code>.  If the cache does not presently contain a value for
-     * this key, then invoke the <code>fill</code> method in an attempt to
-     * compute such a value.  If that method returns a non-<code>null</code>
-     * value, then update the cache and return the new value.  Otherwise,
-     * return <code>null</code>.
-     *
-     * <p> Note that because this method may update the cache, it is considered
-     * a mutator and may cause <code>ConcurrentModificationException</code>s to
-     * be thrown if invoked while an iterator is in use.
-     *
-     * @param  key  The key whose associated value, if any, is to be returned
-     *
-     * @see #fill
-     */
-    public Object get(Object key) {
-        processQueue();
-        Object v = hash.get(key);
-        if (v == null) {
-            v = fill(key);
-            if (v != null) {
-                hash.put(key, ValueCell.create(key, v, queue));
-                return v;
-            }
-        }
-        return ValueCell.strip(v, false);
-    }
-
-    /**
-     * Update this cache so that the given <code>key</code> maps to the given
-     * <code>value</code>.  If the cache previously contained a mapping for
-     * <code>key</code> then that mapping is replaced and the old value is
-     * returned.
-     *
-     * @param  key    The key that is to be mapped to the given
-     *                <code>value</code>
-     * @param  value  The value to which the given <code>key</code> is to be
-     *                mapped
-     *
-     * @return  The previous value to which this key was mapped, or
-     *          <code>null</code> if there was no mapping for the key
-     */
-    public Object put(Object key, Object value) {
-        processQueue();
-        ValueCell vc = ValueCell.create(key, value, queue);
-        return ValueCell.strip(hash.put(key, vc), true);
-    }
-
-    /**
-     * Remove the mapping for the given <code>key</code> from this cache, if
-     * present.
-     *
-     * @param  key  The key whose mapping is to be removed
-     *
-     * @return  The value to which this key was mapped, or <code>null</code> if
-     *          there was no mapping for the key
-     */
-    public Object remove(Object key) {
-        processQueue();
-        return ValueCell.strip(hash.remove(key), true);
-    }
-
-    /**
-     * Remove all mappings from this cache.
-     */
-    public void clear() {
-        processQueue();
-        hash.clear();
-    }
-
-
-    /* -- Views -- */
-
-    private static boolean valEquals(Object o1, Object o2) {
-        return (o1 == null) ? (o2 == null) : o1.equals(o2);
-    }
-
-
-    /* Internal class for entries.
-       Because it uses SoftCache.this.queue, this class cannot be static.
-     */
-    private class Entry implements Map.Entry<Object, Object> {
-        private Map.Entry<Object, Object> ent;
-        private Object value;   /* Strong reference to value, to prevent the GC
-                                   from flushing the value while this Entry
-                                   exists */
-
-        Entry(Map.Entry<Object, Object> ent, Object value) {
-            this.ent = ent;
-            this.value = value;
-        }
-
-        public Object getKey() {
-            return ent.getKey();
-        }
-
-        public Object getValue() {
-            return value;
-        }
-
-        public Object setValue(Object value) {
-            return ent.setValue(ValueCell.create(ent.getKey(), value, queue));
-        }
-
-        @SuppressWarnings("unchecked")
-        public boolean equals(Object o) {
-            if (! (o instanceof Map.Entry)) return false;
-            Map.Entry<Object, Object> e = (Map.Entry<Object, Object>)o;
-            return (valEquals(ent.getKey(), e.getKey())
-                    && valEquals(value, e.getValue()));
-        }
-
-        public int hashCode() {
-            Object k;
-            return ((((k = getKey()) == null) ? 0 : k.hashCode())
-                    ^ ((value == null) ? 0 : value.hashCode()));
-        }
-
-    }
-
-
-    /* Internal class for entry sets */
-    private class EntrySet extends AbstractSet<Map.Entry<Object, Object>> {
-        Set<Map.Entry<Object, Object>> hashEntries = hash.entrySet();
-
-        public Iterator<Map.Entry<Object, Object>> iterator() {
-
-            return new Iterator<Map.Entry<Object, Object>>() {
-                Iterator<Map.Entry<Object, Object>> hashIterator = hashEntries.iterator();
-                Entry next = null;
-
-                public boolean hasNext() {
-                    while (hashIterator.hasNext()) {
-                        Map.Entry<Object, Object> ent = hashIterator.next();
-                        ValueCell vc = (ValueCell)ent.getValue();
-                        Object v = null;
-                        if ((vc != null) && ((v = vc.get()) == null)) {
-                            /* Value has been flushed by GC */
-                            continue;
-                        }
-                        next = new Entry(ent, v);
-                        return true;
-                    }
-                    return false;
-                }
-
-                public Map.Entry<Object, Object> next() {
-                    if ((next == null) && !hasNext())
-                        throw new NoSuchElementException();
-                    Entry e = next;
-                    next = null;
-                    return e;
-                }
-
-                public void remove() {
-                    hashIterator.remove();
-                }
-
-            };
-        }
-
-        public boolean isEmpty() {
-            return !(iterator().hasNext());
-        }
-
-        public int size() {
-            int j = 0;
-            for (Iterator<Map.Entry<Object, Object>> i = iterator(); i.hasNext(); i.next()) j++;
-            return j;
-        }
-
-        public boolean remove(Object o) {
-            processQueue();
-            if (o instanceof Entry) return hashEntries.remove(((Entry)o).ent);
-            else return false;
-        }
-
-    }
-
-
-    private Set<Map.Entry<Object, Object>> entrySet = null;
-
-    /**
-     * Return a <code>Set</code> view of the mappings in this cache.
-     */
-    public Set<Map.Entry<Object, Object>> entrySet() {
-        if (entrySet == null) entrySet = new EntrySet();
-        return entrySet;
-    }
-
-}
--- a/jdk/src/jdk.unsupported/unix/classes/sun/misc/GThreadHelper.java	Thu May 19 17:48:02 2016 +0000
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,87 +0,0 @@
-/*
- * Copyright (c) 2013, 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 sun.misc;
-
-import java.util.concurrent.locks.ReentrantLock;
-
-/**
- * This class is used to prevent multiple calling of g_thread_init ()
- * and gdk_thread_init ().
- *
- * Since version 2.24 of GLib, calling g_thread_init () multiple times is
- * allowed, but it will crash for older versions. There are two ways to
- * find out if g_thread_init () has been called:
- * g_thread_get_initialized (), but it was introduced in 2.20
- * g_thread_supported (), but it is a macro and cannot be loaded with dlsym.
- *
- * usage:
- * <pre>
- * lock();
- * try {
- *    if (!getAndSetInitializationNeededFlag()) {
- *        //call to g_thread_init();
- *        //call to gdk_thread_init();
- *    }
- * } finally {
- *    unlock();
- * }
- * </pre>
- */
-public final class GThreadHelper {
-
-    private static final ReentrantLock LOCK = new ReentrantLock();
-    private static boolean isGThreadInitialized = false;
-
-    /**
-     * Acquires the lock.
-     */
-    public static void lock() {
-        LOCK.lock();
-    }
-
-    /**
-     * Releases the lock.
-     */
-    public static void unlock() {
-        LOCK.unlock();
-    }
-
-    /**
-     * Gets current value of initialization flag and sets it to {@code true}.
-     * MUST be called under the lock.
-     *
-     * A return value of {@code false} indicates that the calling code
-     * should call the g_thread_init() and gdk_thread_init() functions
-     * before releasing the lock.
-     *
-     * @return {@code true} if initialization has been completed.
-     */
-    public static boolean getAndSetInitializationNeededFlag() {
-        boolean ret = isGThreadInitialized;
-        isGThreadInitialized = true;
-        return ret;
-    }
-}
--- a/jdk/test/ProblemList.txt	Thu May 19 17:48:02 2016 +0000
+++ b/jdk/test/ProblemList.txt	Thu May 19 19:46:20 2016 +0000
@@ -116,10 +116,8 @@
 
 # jdk_beans
 
-java/beans/XMLEncoder/Test4903007.java                          8060027 generic-all
-java/beans/XMLEncoder/java_awt_GridBagLayout.java               8060027 generic-all
-java/beans/XMLDecoder/8028054/TestConstructorFinder.java        8060027 generic-all
-java/beans/XMLDecoder/8028054/TestMethodFinder.java             8060027 generic-all
+java/beans/XMLDecoder/8028054/TestConstructorFinder.java        8156579 generic-all
+java/beans/XMLDecoder/8028054/TestMethodFinder.java             8156579 generic-all
 
 java/beans/Introspector/8132566/OverridePropertyInfoTest.java   8132565 generic-all
 java/beans/Introspector/8132566/OverrideUserDefPropertyInfoTest.java 8132565 generic-all
@@ -145,6 +143,12 @@
 
 ############################################################################
 
+# jdk_io
+
+java/io/pathNames/GeneralWin32.java                             8156595 windows-all
+
+############################################################################
+
 # jdk_jmx
 
 com/sun/management/OperatingSystemMXBean/GetProcessCpuLoad.java 8030957 aix-all
@@ -294,7 +298,6 @@
 
 # jdk_sound
 
-javax/sound/midi/Gervill/SoftProvider/GetDevice.java            8059743 generic-all
 javax/sound/sampled/DirectAudio/bug6400879.java                 8148915 linux-all
 
 ############################################################################
--- a/jdk/test/com/sun/jdi/ReferrersTest.java	Thu May 19 17:48:02 2016 +0000
+++ b/jdk/test/com/sun/jdi/ReferrersTest.java	Thu May 19 19:46:20 2016 +0000
@@ -446,7 +446,7 @@
         if (rt instanceof ClassType) {
             ClassType ct = (ClassType)rt;
             String name = ct.name();
-            if (name.equals("sun.misc.SoftCache$ValueCell")) {
+            if (name.equals("sun.awt.SoftCache$ValueCell")) {
                 return;
             }
             if (name.equals("java.lang.ref.Finalizer")) {
--- a/jdk/test/java/awt/Robot/ModifierRobotKey/ModifierRobotKeyTest.java	Thu May 19 17:48:02 2016 +0000
+++ b/jdk/test/java/awt/Robot/ModifierRobotKey/ModifierRobotKeyTest.java	Thu May 19 19:46:20 2016 +0000
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2007, 2014, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2007, 2016, 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
@@ -21,17 +21,23 @@
  * questions.
  */
 
-
-import java.awt.*;
-import java.awt.event.*;
+import java.awt.BorderLayout;
+import java.awt.Canvas;
+import java.awt.EventQueue;
+import java.awt.Frame;
+import java.awt.event.FocusAdapter;
+import java.awt.event.FocusEvent;
+import java.awt.event.InputEvent;
+import java.awt.event.KeyAdapter;
+import java.awt.event.KeyEvent;
+import java.awt.event.MouseEvent;
 
 import static jdk.testlibrary.Asserts.assertTrue;
 
 /*
- * @test
+ * @test 8155742
  * @summary Make sure that modifier key mask is set when robot press
- * some key with one or more modifiers.
- *
+ *          some key with one or more modifiers.
  * @library ../../../../lib/testlibrary/
  * @build ExtendedRobot
  * @run main ModifierRobotKeyTest
@@ -60,15 +66,17 @@
     }
 
     public ModifierRobotKeyTest() throws Exception {
-        modifierKeys =  new int[3];
+        modifierKeys =  new int[4];
         modifierKeys[0] = KeyEvent.VK_SHIFT;
         modifierKeys[1] = KeyEvent.VK_CONTROL;
         modifierKeys[2] = KeyEvent.VK_ALT;
+        modifierKeys[3] = KeyEvent.VK_ALT_GRAPH;
 
-        inputMasks = new int[3];
+        inputMasks = new int[4];
         inputMasks[0] =  InputEvent.SHIFT_MASK;
         inputMasks[1] =  InputEvent.CTRL_MASK;
         inputMasks[2] =  InputEvent.ALT_MASK;
+        inputMasks[3] =  InputEvent.ALT_GRAPH_MASK;
 
         modifierStatus = new boolean[modifierKeys.length];
 
--- a/jdk/test/java/awt/Toolkit/DynamicLayout/bug7172833.java	Thu May 19 17:48:02 2016 +0000
+++ b/jdk/test/java/awt/Toolkit/DynamicLayout/bug7172833.java	Thu May 19 19:46:20 2016 +0000
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2013, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2013, 2015, Oracle and/or its affiliates. All rights reserved.
  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
  *
  * This code is free software; you can redistribute it and/or modify it
@@ -45,16 +45,34 @@
 
     public static void main(final String[] args) throws Exception {
         final StubbedToolkit t = new StubbedToolkit();
-
+        final Boolean dynamicLayoutSupported
+                = (Boolean) t.getDesktopProperty("awt.dynamicLayoutSupported");
         t.setDynamicLayout(true);
         if(!t.isDynamicLayoutSet()){
             throw new RuntimeException("'true' expected but 'false' returned");
         }
+        if (dynamicLayoutSupported) {
+            if (!t.isDynamicLayoutActive()) {
+                throw new RuntimeException("is inactive but set+supported");
+            }
+        } else {
+            if (t.isDynamicLayoutActive()) {
+                throw new RuntimeException("is active but unsupported");
+            }
+        }
 
         t.setDynamicLayout(false);
         if(t.isDynamicLayoutSet()){
             throw new RuntimeException("'false' expected but 'true' returned");
         }
+        if (dynamicLayoutSupported) {
+            // Layout is supported and was set to false, cannot verifym because
+            // the native system is free to ignore our request.
+        } else {
+            if (t.isDynamicLayoutActive()) {
+                throw new RuntimeException("is active but unset+unsupported");
+            }
+        }
     }
 
     static final class StubbedToolkit extends Toolkit {
--- a/jdk/test/java/awt/TrayIcon/ActionEventTest/ActionEventTest.java	Thu May 19 17:48:02 2016 +0000
+++ b/jdk/test/java/awt/TrayIcon/ActionEventTest/ActionEventTest.java	Thu May 19 19:46:20 2016 +0000
@@ -23,10 +23,13 @@
 
 /*
  * @test
- * @bug 6191390
+ * @bug 6191390 8154328
  * @summary Verify that ActionEvent is received with correct modifiers set.
  * @library ../../../../lib/testlibrary ../
+ * @library /java/awt/patchlib
+ * @build java.desktop/java.awt.Helper
  * @build ExtendedRobot SystemTrayIconHelper
+ * @run main ActionEventTest
  */
 
 import java.awt.Image;
@@ -46,6 +49,7 @@
     Image image;
     TrayIcon icon;
     Robot robot;
+    boolean actionPerformed;
 
     public static void main(String[] args) throws Exception {
         if (!SystemTray.isSupported()) {
@@ -82,6 +86,7 @@
         icon.addActionListener(new ActionListener() {
             @Override
             public void actionPerformed(ActionEvent ae) {
+                actionPerformed = true;
                 int md = ae.getModifiers();
                 int expectedMask = ActionEvent.ALT_MASK | ActionEvent.CTRL_MASK
                         | ActionEvent.SHIFT_MASK;
@@ -102,6 +107,9 @@
     }
 
     public void clear() {
+        robot.keyRelease(KeyEvent.VK_ALT);
+        robot.keyRelease(KeyEvent.VK_SHIFT);
+        robot.keyRelease(KeyEvent.VK_CONTROL);
         SystemTray.getSystemTray().remove(icon);
     }
 
@@ -123,10 +131,9 @@
         robot.delay(100);
         robot.mousePress(InputEvent.BUTTON1_DOWN_MASK);
         robot.mouseRelease(InputEvent.BUTTON1_DOWN_MASK);
-        robot.delay(100);
         robot.waitForIdle();
-        robot.keyRelease(KeyEvent.VK_ALT);
-        robot.keyRelease(KeyEvent.VK_SHIFT);
-        robot.keyRelease(KeyEvent.VK_CONTROL);
+        if (!actionPerformed) {
+            robot.delay(500);
+        }
     }
 }
--- a/jdk/test/java/awt/TrayIcon/TrayIconMouseTest/TrayIconMouseTest.java	Thu May 19 17:48:02 2016 +0000
+++ b/jdk/test/java/awt/TrayIcon/TrayIconMouseTest/TrayIconMouseTest.java	Thu May 19 19:46:20 2016 +0000
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2007, 2015, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2007, 2016, 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
@@ -21,16 +21,19 @@
  * questions.
  */
 
-import java.awt.*;
-import java.awt.event.*;
+import java.awt.EventQueue;
+import java.awt.Point;
+import java.awt.SystemTray;
+import java.awt.TrayIcon;
+import java.awt.event.InputEvent;
 import java.awt.image.BufferedImage;
 
 /*
- * @test
- * @summary Check if ActionEvent is triggered by a TrayIcon only when
- *          it is double clicked using mouse button 1 (or single clicked
- *          with button 3 (on Mac OS X))
- * @author Dmitriy Ermashov (dmitriy.ermashov@oracle.com)
+ * @test 6384991
+ * @summary Check if ActionEvent is triggered by a TrayIcon when
+ *          it is double clicked with mouse button 1 on windows
+ *          or single clicked with button 3 on Mac OS X
+ *          or single clicked with button 1 on rest.
  * @library /java/awt/patchlib
  * @library ../../../../lib/testlibrary ../
  * @build java.desktop/java.awt.Helper
@@ -42,19 +45,17 @@
 
     TrayIcon icon;
     ExtendedRobot robot;
-
     boolean actionPerformed = false;
     Object actionLock = new Object();
     static boolean isMacOS = false;
-
+    static boolean isWinOS = false;
+    static boolean isOelOS = false;
     String caption = "Sample Icon";
-
     int[] buttonTypes = {
         InputEvent.BUTTON1_MASK,
         InputEvent.BUTTON2_MASK,
         InputEvent.BUTTON3_MASK
     };
-
     String[] buttonNames = {
         "BUTTON1",
         "BUTTON2",
@@ -62,30 +63,31 @@
     };
 
     public static void main(String[] args) throws Exception {
-        if (! SystemTray.isSupported()) {
-            System.out.println("SystemTray not supported on the platform under test. " +
-                    "Marking the test passed");
+        if (!SystemTray.isSupported()) {
+            System.out.println("SystemTray not supported on the platform "
+                    + "under test. Marking the test passed");
         } else {
-            if (System.getProperty("os.name").toLowerCase().startsWith("mac")) {
+            String osName = System.getProperty("os.name").toLowerCase();
+            if (osName.startsWith("mac")) {
                 isMacOS = true;
-            } else if (SystemTrayIconHelper.isOel7()) {
-                System.out.println("OEL 7 doesn't support double click in " +
-                        "systray. Skipped");
-                return;
+            } else if (osName.startsWith("win")) {
+                isWinOS = true;
+            } else {
+                isOelOS = SystemTrayIconHelper.isOel7();
             }
             new TrayIconMouseTest().doTest();
         }
     }
 
-    TrayIconMouseTest() throws Exception{
+    TrayIconMouseTest() throws Exception {
         robot = new ExtendedRobot();
         EventQueue.invokeAndWait(this::initializeGUI);
     }
 
     void initializeGUI() {
-
         SystemTray tray = SystemTray.getSystemTray();
-        icon = new TrayIcon(new BufferedImage(20, 20, BufferedImage.TYPE_INT_RGB), caption);
+        icon = new TrayIcon(
+                new BufferedImage(20, 20, BufferedImage.TYPE_INT_RGB), caption);
         icon.addActionListener(event -> {
             actionPerformed = true;
             synchronized (actionLock) {
@@ -103,31 +105,32 @@
     }
 
     private void doTest() throws Exception {
-
         Point iconPosition = SystemTrayIconHelper.getTrayIconLocation(icon);
-        if (iconPosition == null)
+        if (iconPosition == null) {
             throw new RuntimeException("Unable to find the icon location!");
-
+        }
         robot.mouseMove(iconPosition.x, iconPosition.y);
         robot.waitForIdle();
 
         for (int i = 0; i < buttonTypes.length; i++) {
             actionPerformed = false;
             robot.click(buttonTypes[i]);
-            robot.waitForIdle(6000);
-
-            if (isMacOS && actionPerformed && i == 2) {
+            robot.waitForIdle();
+            delayIfRequired();
 
-            }else if (isMacOS && i == 2) {
-                throw new RuntimeException("FAIL: ActionEvent NOT triggered when " +
-                        buttonNames[i] + " is single clicked on Mac OS");
-            }else if (actionPerformed) {
-                throw new RuntimeException("FAIL: ActionEvent triggered when " +
-                        buttonNames[i] + " is single clicked");
+            if (isMacOS && i == 2 && !actionPerformed) {
+                throw new RuntimeException("FAIL: ActionEvent NOT triggered "
+                    + "when " + buttonNames[i] + " is single clicked on Mac");
+            } else if (isWinOS && actionPerformed) {
+                throw new RuntimeException("FAIL: ActionEvent triggered "
+                    + "when " + buttonNames[i] + " is single clicked");
+            } else if (!isMacOS && !isWinOS && i == 0 && !actionPerformed) {
+                throw new RuntimeException("FAIL: ActionEvent NOT triggered "
+                    + "when " + buttonNames[i] + " is single clicked");
             }
         }
 
-        if(!isMacOS) {
+        if (!isMacOS && !isOelOS) {
             for (int i = 0; i < buttonTypes.length; i++) {
                 for (int j = 0; j < buttonTypes.length; j++) {
                     if (j != i) {
@@ -136,13 +139,22 @@
                         robot.mousePress(buttonTypes[j]);
                         robot.mouseRelease(buttonTypes[j]);
                         robot.mouseRelease(buttonTypes[i]);
-
                         robot.waitForIdle();
+                        delayIfRequired();
 
-                        if (actionPerformed)
-                            throw new RuntimeException("FAIL: ActionEvent triggered when " +
-                                    buttonNames[i] + " and " + buttonNames[j] +
-                                    " is clicked and released");
+                        if (isWinOS) {
+                            if (actionPerformed) {
+                                throw new RuntimeException(
+                                    "FAIL: ActionEvent triggered when "
+                                    + buttonNames[i] + " & " + buttonNames[j]
+                                    + " is clicked and released");
+                            }
+
+                        } else if ((i == 0 || j == 0) && !actionPerformed) {
+                            throw new RuntimeException("FAIL: ActionEvent is "
+                                + "NOT triggered when " + buttonNames[i] + " & "
+                                + buttonNames[j] + " is pressed & released");
+                        }
                     }
                 }
             }
@@ -150,31 +162,34 @@
             for (int i = 0; i < buttonTypes.length; i++) {
                 actionPerformed = false;
                 robot.mousePress(buttonTypes[i]);
-                robot.delay(50);
                 robot.mouseRelease(buttonTypes[i]);
                 robot.delay(50);
                 robot.mousePress(buttonTypes[i]);
-                robot.delay(50);
                 robot.mouseRelease(buttonTypes[i]);
+                robot.waitForIdle();
+                delayIfRequired();
 
                 if (i == 0) {
-                    if (! actionPerformed) {
-                        synchronized (actionLock) {
-                            try {
-                                actionLock.wait(6000);
-                            } catch (Exception e) {
-                            }
-                        }
+                    if (!actionPerformed) {
+                        throw new RuntimeException("FAIL: ActionEvent not "
+                                + "triggered when " + buttonNames[i]
+                                + " is double clicked");
                     }
-                    if (! actionPerformed)
-                        throw new RuntimeException("FAIL: ActionEvent not triggered when " +
-                                buttonNames[i] + " is double clicked");
-                } else {
-                    robot.waitForIdle();
+                } else if (actionPerformed) {
+                    throw new RuntimeException("FAIL: ActionEvent "
+                            + "triggered when " + buttonNames[i]
+                            + " is double clicked");
+                }
+            }
+        }
+    }
 
-                    if (actionPerformed)
-                        throw new RuntimeException("FAIL: ActionEvent triggered when " +
-                                buttonNames[i] + " is double clicked");
+    public void delayIfRequired() {
+        if (!actionPerformed) {
+            synchronized (actionLock) {
+                try {
+                    actionLock.wait(500);
+                } catch (Exception e) {
                 }
             }
         }
--- a/jdk/test/java/awt/dnd/Button2DragTest/Button2DragTest.html	Thu May 19 17:48:02 2016 +0000
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,45 +0,0 @@
-<!--
- Copyright (c) 2006, 2013, 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.
--->
-
-<html>
-<!--
-  @test
-  @bug 4955110
-  @summary tests that a drag ends on button2 release
-  @author Alexander.Gerasimov area=dnd
-  @library    ../../regtesthelpers
-  @build      Util
-  @run applet/othervm Button2DragTest.html
-  -->
-<head>
-<title>  </title>
-</head>
-<body>
-
-<h1>Button2DragTest<br>Bug ID: 4955110</h1>
-
-<p> This is an AUTOMATIC test, simply wait for completion </p>
-
-<APPLET CODE="Button2DragTest.class" WIDTH=200 HEIGHT=200></APPLET>
-</body>
-</html>
--- a/jdk/test/java/awt/dnd/Button2DragTest/Button2DragTest.java	Thu May 19 17:48:02 2016 +0000
+++ b/jdk/test/java/awt/dnd/Button2DragTest/Button2DragTest.java	Thu May 19 19:46:20 2016 +0000
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2006, 2014, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2006, 2016, 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
@@ -21,45 +21,52 @@
  * questions.
  */
 
-/*
-  test
-  @bug 4955110
-  @summary tests that a drag ends on button2 release
-  @author Alexander.Gerasimov area=dnd
-  @library    ../../regtesthelpers
-  @build      Util
-  @run applet/othervm Button2DragTest.html
-*/
+import java.awt.Frame;
+import java.awt.Point;
+import java.awt.Robot;
+import java.awt.datatransfer.StringSelection;
+import java.awt.dnd.DnDConstants;
+import java.awt.dnd.DragGestureEvent;
+import java.awt.dnd.DragGestureListener;
+import java.awt.dnd.DragSource;
+import java.awt.dnd.DragSourceAdapter;
+import java.awt.dnd.DragSourceDropEvent;
+import java.awt.dnd.DragSourceListener;
+import java.awt.dnd.DropTarget;
+import java.awt.dnd.DropTargetAdapter;
+import java.awt.dnd.DropTargetDropEvent;
+import java.awt.event.InputEvent;
 
+import test.java.awt.regtesthelpers.Util;
 
 /**
- * Button2DragTest.java
- *
- * summary: tests that DragSourceDragEvent.getDropAction() accords to its new spec
- *          (does not depend on the user drop action)
- *
+ * @test
+ * @bug 4955110
+ * @summary tests that DragSourceDragEvent.getDropAction() accords to its new
+ *          spec (does not depend on the user drop action)
+ * @library ../../regtesthelpers
+ * @build Util
+ * @run main/othervm Button2DragTest
+ * @author Alexander.Gerasimov area=dnd
  */
-
-import java.applet.Applet;
-import java.awt.*;
-import java.awt.event.*;
-import java.awt.datatransfer.*;
-import java.awt.dnd.*;
-import test.java.awt.regtesthelpers.Util;
-
-
-public class Button2DragTest extends Applet {
+public final class Button2DragTest {
 
     private volatile boolean dropSuccess;
 
-    private Frame frame;
-
+    private static Frame frame;
 
-    public void init() {
-        // Set up the environment -- set the layout manager, add
-        // buttons, etc.
-        setLayout(new BorderLayout());
+    public static void main(final String[] args) {
+        Button2DragTest test = new Button2DragTest();
+        try {
+            test.run();
+        } finally {
+            if (frame != null) {
+                frame.dispose();
+            }
+        }
+    }
 
+    public void run() {
         frame = new Frame();
 
         final DragSourceListener dragSourceListener = new DragSourceAdapter() {
@@ -84,20 +91,13 @@
             }
         };
         new DropTarget(frame, dropTargetListener);
-    }
-
-
-    public void start() {
-        //Get things going.  Request focus, set size, et cetera
-        setSize(200,200);
-        setVisible(true);
-        validate();
 
         //What would normally go into main() will probably go here.
         //Use System.out.println for diagnostic messages that you want
         //to read after the test is done.
-
+        frame.setUndecorated(true);
         frame.setBounds(100, 100, 200, 200);
+        frame.setLocationRelativeTo(null);
         frame.setVisible(true);
 
         Robot robot = Util.createRobot();
--- a/jdk/test/java/awt/event/MouseEvent/AltGraphModifierTest/AltGraphModifierTest.java	Thu May 19 17:48:02 2016 +0000
+++ b/jdk/test/java/awt/event/MouseEvent/AltGraphModifierTest/AltGraphModifierTest.java	Thu May 19 19:46:20 2016 +0000
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2015, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2015, 2016, 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
@@ -44,13 +44,9 @@
                 = {
                     "This test is for verifying Alt-Gr modifier of an event.",
                     "Windows :-",
-                    "1. Please check if Alt-Gr key is present on keyboard.",
-                    "2. If present, press the Alt-Gr key and perform",
-                    "   mouse click on the TestWindow.",
-                    "3. If Alt-Gr key is not present, press Ctrl+Alt keys &",
-                    "   perform mouse click on the TestWindow.",
-                    "4. Test will exit by itself with appropriate result.",
-                    "",
+                    "1. Click Pass.",
+                    "2. Alt-Gr modifier is tested under Robot tests.",
+                    " ",
                     "Linux :-",
                     "1. Please check if Alt-Gr key is present on keyboard.",
                     "2. If present, press the Alt-Gr key and perform",
@@ -63,10 +59,11 @@
                     "6. Press Right Alt Key & perform mouse click on the",
                     "   TestWindow",
                     "7. Test will exit by itself with appropriate result.",
-                    "",
+                    " ",
                     "Mac :-",
-                    "   Mac fix is under progress, & will be fixed soon.",
-                    "   Please click Fail"
+                    "1. Press Right Option key on the keyboard and mouse click",
+                    "   on the TestWindow",
+                    "3. Test will exit by itself with appropriate result.",
                 };
 
         Sysout.createDialog();
@@ -77,7 +74,7 @@
     public static void initTestWindow() {
         mainFrame = new Frame();
         mainFrame.setTitle("TestWindow");
-        mainFrame.setSize(300, 200);
+        mainFrame.setBounds(700, 10, 300, 300);
         mainFrame.addMouseListener(new MouseAdapter() {
             @Override
             public void mousePressed(MouseEvent e) {
--- a/jdk/test/java/awt/print/Dialog/RestoreActiveWindowTest/RestoreActiveWindowTest.html	Thu May 19 17:48:02 2016 +0000
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,43 +0,0 @@
-<!--
- Copyright (c) 2007, 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.
--->
-
-<html>
-<!--  
-  @test
-  @bug 6365992 6379599
-  @summary REG: Showing and disposing a native print dialog makes the main frame inactive, Win32
-  @author Dmitry.Cherepanov@SUN.COM area=awt.printdialog
-  @run applet/manual=yesno RestoreActiveWindowTest.html
-  -->
-<head>
-<title>RestoreActiveWindowTest</title>
-</head>
-<body>
-
-<h1>RestoreActiveWindowTest<br>Bug ID: 6365992</h1>
-
-<p> See the dialog box (usually in upper left corner) for instructions</p>
-
-<APPLET CODE="RestoreActiveWindowTest.class" WIDTH=200 HEIGHT=200></APPLET>
-</body>
-</html>
--- a/jdk/test/java/awt/print/Dialog/RestoreActiveWindowTest/RestoreActiveWindowTest.java	Thu May 19 17:48:02 2016 +0000
+++ b/jdk/test/java/awt/print/Dialog/RestoreActiveWindowTest/RestoreActiveWindowTest.java	Thu May 19 19:46:20 2016 +0000
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2007, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2007, 2016, 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
@@ -22,210 +22,194 @@
  */
 
 /*
-  test
-  @bug 6365992 6379599
-  @summary REG: Showing and disposing a native print dialog makes the main frame inactive, Win32
-  @author Dmitry.Cherepanov@SUN.COM area=awt.printdialog
-  @run applet/manual=yesno RestoreActiveWindowTest.html
-*/
-
-import java.applet.Applet;
-import java.awt.*;
-import java.awt.event.*;
-import java.awt.print.*;
-import javax.print.attribute.*;
-
-public class RestoreActiveWindowTest extends Applet
-{
-    Button showBtn1 = new Button("show a native print dialog");
-    Button showBtn2 = new Button("show a native page dialog");
+ * @test
+ * @bug 6365992 6379599 8137137
+ * @summary REG: Showing and disposing a native print dialog makes the main
+ *  frame inactive, Win32
+ * @run main/manual RestoreActiveWindowTest
+ */
+import java.awt.Frame;
+import java.awt.Button;
+import java.awt.GridBagLayout;
+import java.awt.Panel;
+import java.awt.TextArea;
+import java.awt.GridLayout;
+import java.awt.GridBagConstraints;
+import java.awt.Color;
+import java.awt.event.ActionEvent;
+import java.awt.event.ActionListener;
+import java.awt.event.WindowAdapter;
+import java.awt.event.WindowEvent;
+import java.awt.print.PrinterJob;
+import java.awt.print.PageFormat;
 
-    public void init()
-    {
-        showBtn1.addActionListener(new ActionListener(){
-                public void actionPerformed(ActionEvent ae) {
-                    PrinterJob.getPrinterJob().printDialog();
-                }
-            });
-        showBtn2.addActionListener(new ActionListener(){
-                public void actionPerformed(ActionEvent ae){
-                    PrinterJob.getPrinterJob().pageDialog(new PageFormat());
-                }
-            });
-
-        add(showBtn1);
-        add(showBtn2);
-
-        String[] instructions = {
-            "1.1) Click on 'show a native print dialog'. A native print dialog will come up.",
-            "1.2) Click on the 'close'(X) button. The dialog will be closed.",
-            "1.3) After the dialog closing another window should become the active window.",
-            "1.4) If there no any active window then the test failed.",
-            "2.1) Click on 'show a native page dialog'. A native page dialog will come up.",
-            "2.2) Click on the 'close'(X) button. The dialog will be closed.",
-            "2.3) After the dialog closing another window should become the active window.",
-            "2.4) If there no any active window then the test failed.",
-            "3) Test Passed."
-        };
-
-        Sysout.createDialogWithInstructions( instructions );
-
-    }//End  init()
+public class RestoreActiveWindowTest implements ActionListener {
 
-   public void start ()
-    {
-      //Get things going.  Request focus, set size, et cetera
-      setSize (200,200);
-      show();
-
-    }// start()
-
-    //The rest of this class is the actions which perform the test...
+    private static Frame mainFrame;
+    private static Button printDialogButton;
+    private static Button pageDialogButton;
+    private static Frame instructionFrame;
+    private static GridBagLayout layout;
+    private static Panel mainControlPanel;
+    private static Panel resultButtonPanel;
+    private static TextArea instructionTextArea;
+    private static Button passButton;
+    private static Button failButton;
+    private static Thread mainThread = null;
+    private static boolean testPassed = false;
+    private static boolean isInterrupted = false;
+    private static final int testTimeOut = 300000;
+    private static String testFailMessage;
 
-    //Use Sysout.println to communicate with the user NOT System.out!!
-    //Sysout.println ("Something Happened!");
-
-}// class ManualYesNoTest
-
-/* Place other classes related to the test after this line */
-
-
-
-
+    public void createAndShowGUI() {
+        mainFrame = new Frame("Test");
+        mainFrame.setSize(200, 200);
+        mainFrame.setLocationRelativeTo(null);
+        mainFrame.setLayout(new GridLayout(2, 1));
 
-/****************************************************
- Standard Test Machinery
- DO NOT modify anything below -- it's a standard
-  chunk of code whose purpose is to make user
-  interaction uniform, and thereby make it simpler
-  to read and understand someone else's test.
- ****************************************************/
+        printDialogButton = new Button("show a native print dialog");
+        pageDialogButton = new Button("show a native page dialog");
+        printDialogButton.addActionListener(new ActionListener() {
+            @Override
+            public void actionPerformed(ActionEvent ae) {
+                PrinterJob.getPrinterJob().printDialog();
+                setButtonEnable(true);
+                testFailMessage = "Print dialog test failed.";
+            }
+        });
+        pageDialogButton.addActionListener(new ActionListener() {
+            @Override
+            public void actionPerformed(ActionEvent ae) {
+                PrinterJob.getPrinterJob().pageDialog(new PageFormat());
+                setButtonEnable(true);
+                testFailMessage = "Page dialog test failed.";
+            }
+        });
 
-/**
- This is part of the standard test machinery.
- It creates a dialog (with the instructions), and is the interface
-  for sending text messages to the user.
- To print the instructions, send an array of strings to Sysout.createDialog
-  WithInstructions method.  Put one line of instructions per array entry.
- To display a message for the tester to see, simply call Sysout.println
-  with the string to be displayed.
- This mimics System.out.println but works within the test harness as well
-  as standalone.
- */
+        mainFrame.add(printDialogButton);
+        mainFrame.add(pageDialogButton);
+        mainFrame.setVisible(true);
 
-class Sysout
-{
-    private static TestDialog dialog;
-
-    public static void createDialogWithInstructions( String[] instructions )
-    {
-        dialog = new TestDialog( new Frame(), "Instructions" );
-        dialog.printInstructions( instructions );
-        dialog.setVisible(true);
-        println( "Any messages for the tester will display here." );
+       mainFrame.addWindowListener(new WindowAdapter() {
+            public void windowClosing(WindowEvent we) {
+                cleanUp();
+                throw new RuntimeException("User has closed the test window "
+                        + "without clicking Pass or Fail.");
+            }
+        });
     }
 
-    public static void createDialog( )
-    {
-        dialog = new TestDialog( new Frame(), "Instructions" );
-        String[] defInstr = { "Instructions will appear here. ", "" } ;
-        dialog.printInstructions( defInstr );
-        dialog.setVisible(true);
-        println( "Any messages for the tester will display here." );
-    }
+    private void createInstructionUI() {
+        instructionFrame = new Frame("Native Print Dialog and Page Dialog");
+        layout = new GridBagLayout();
+        mainControlPanel = new Panel(layout);
+        resultButtonPanel = new Panel(layout);
 
+        GridBagConstraints gbc = new GridBagConstraints();
+        String instructions
+                = "\nINSTRUCTIONS:\n"
+                + "\n   1. Click on the 'show a native print dialog' button. A "
+                + "native print dialog will come up."
+                + "\n   2. Click on the 'Cancel' button on Mac OS X or "
+                + "'close'(X) on other paltforms. Dialog will be closed."
+                + "\n   3. After the dialog is closed another window should "
+                + "become the active window."
+                + "\n   4. If there no any active window then the test has "
+                + "failed. Click on 'Fail' Button."
+                + "\n   5. Click on the 'show a native page dialog' button. A "
+                + "native page dialog will come up."
+                + "\n   6. Click on the 'Cancel' button on Mac OS X or "
+                + "'close'(X) on other paltforms. Dialog will be closed."
+                + "\n   7. After the dialog is closed another window should "
+                + "become the active window."
+                + "\n   8. If there no any active window then the test has "
+                + "failed. Click on 'Fail' Button."
+                + "\n   9. Test Passed. Click on 'Pass' Button.";
 
-    public static void printInstructions( String[] instructions )
-    {
-        dialog.printInstructions( instructions );
-    }
+        instructionTextArea = new TextArea(13, 80);
+        instructionTextArea.setText(instructions);
+        instructionTextArea.setEnabled(false);
+        instructionTextArea.setBackground(Color.white);
+
+        gbc.gridx = 0;
+        gbc.gridy = 0;
+        gbc.weightx = 0.5;
+        gbc.fill = GridBagConstraints.HORIZONTAL;
+        mainControlPanel.add(instructionTextArea, gbc);
+
+        passButton = new Button("Pass");
+        passButton.setName("Pass");
+        passButton.addActionListener((ActionListener) this);
 
+        failButton = new Button("Fail");
+        failButton.setName("Fail");
+        failButton.addActionListener((ActionListener) this);
 
-    public static void println( String messageIn )
-    {
-        dialog.displayMessage( messageIn );
+        setButtonEnable(false);
+
+        gbc.gridx = 0;
+        gbc.gridy = 0;
+        resultButtonPanel.add(passButton, gbc);
+        gbc.gridx = 1;
+        gbc.gridy = 0;
+        resultButtonPanel.add(failButton, gbc);
+        gbc.gridx = 0;
+        gbc.gridy = 1;
+        mainControlPanel.add(resultButtonPanel, gbc);
+
+        instructionFrame.add(mainControlPanel);
+        instructionFrame.pack();
+        instructionFrame.setVisible(true);
     }
 
-}// Sysout  class
-
-/**
-  This is part of the standard test machinery.  It provides a place for the
-   test instructions to be displayed, and a place for interactive messages
-   to the user to be displayed.
-  To have the test instructions displayed, see Sysout.
-  To have a message to the user be displayed, see Sysout.
-  Do not call anything in this dialog directly.
-  */
-class TestDialog extends Dialog
-{
-
-    TextArea instructionsText;
-    TextArea messageText;
-    int maxStringLength = 80;
-
-    //DO NOT call this directly, go through Sysout
-    public TestDialog( Frame frame, String name )
-    {
-        super( frame, name );
-        int scrollBoth = TextArea.SCROLLBARS_BOTH;
-        instructionsText = new TextArea( "", 15, maxStringLength, scrollBoth );
-        add( "North", instructionsText );
-
-        messageText = new TextArea( "", 5, maxStringLength, scrollBoth );
-        add("Center", messageText);
-
-        pack();
-
-        setVisible(true);
-    }// TestDialog()
-
-    //DO NOT call this directly, go through Sysout
-    public void printInstructions( String[] instructions )
-    {
-        //Clear out any current instructions
-        instructionsText.setText( "" );
+    @Override
+    public void actionPerformed(ActionEvent ae) {
+        if (ae.getSource() instanceof Button) {
+            Button btn = (Button) ae.getSource();
+            switch (btn.getName()) {
+                case "Pass":
+                    testPassed = true;
+                    isInterrupted = true;
+                    mainThread.interrupt();
+                    break;
+                case "Fail":
+                    testPassed = false;
+                    isInterrupted = true;
+                    mainThread.interrupt();
+                    break;
+            }
+        }
+    }
 
-        //Go down array of instruction strings
-
-        String printStr, remainingStr;
-        for( int i=0; i < instructions.length; i++ )
-        {
-            //chop up each into pieces maxSringLength long
-            remainingStr = instructions[ i ];
-            while( remainingStr.length() > 0 )
-            {
-                //if longer than max then chop off first max chars to print
-                if( remainingStr.length() >= maxStringLength )
-                {
-                    //Try to chop on a word boundary
-                    int posOfSpace = remainingStr.
-                        lastIndexOf( ' ', maxStringLength - 1 );
-
-                    if( posOfSpace <= 0 ) posOfSpace = maxStringLength - 1;
-
-                    printStr = remainingStr.substring( 0, posOfSpace + 1 );
-                    remainingStr = remainingStr.substring( posOfSpace + 1 );
-                }
-                //else just print
-                else
-                {
-                    printStr = remainingStr;
-                    remainingStr = "";
-                }
-
-                instructionsText.append( printStr + "\n" );
-
-            }// while
-
-        }// for
-
-    }//printInstructions()
-
-    //DO NOT call this directly, go through Sysout
-    public void displayMessage( String messageIn )
-    {
-        messageText.append( messageIn + "\n" );
-        System.out.println(messageIn);
+    private static void setButtonEnable(boolean status) {
+        passButton.setEnabled(status);
+        failButton.setEnabled(status);
     }
 
-}// TestDialog  class
+    private static void cleanUp() {
+        mainFrame.dispose();
+        instructionFrame.dispose();
+    }
+
+    public static void main(String args[]) {
+        RestoreActiveWindowTest printDialogs = new RestoreActiveWindowTest();
+        printDialogs.createInstructionUI();
+        printDialogs.createAndShowGUI();
+
+        mainThread = Thread.currentThread();
+        try {
+            mainThread.sleep(testTimeOut);
+        } catch (InterruptedException ex) {
+            if (!testPassed) {
+                throw new RuntimeException(testFailMessage);
+            }
+        } finally {
+            cleanUp();
+        }
+
+        if (!isInterrupted) {
+            throw new RuntimeException("Test Timed out after "
+                    + testTimeOut / 1000 + " seconds");
+        }
+    }
+}
--- a/jdk/test/java/beans/Introspector/AnonymousClassBeanPropertyTest.java	Thu May 19 17:48:02 2016 +0000
+++ b/jdk/test/java/beans/Introspector/AnonymousClassBeanPropertyTest.java	Thu May 19 19:46:20 2016 +0000
@@ -33,7 +33,7 @@
 
 /**
  * @test
- * @bug 8132973 8132732 8155013
+ * @bug 8132973 8132732 8155013 8154958
  * @summary Some check for BeanProperty annotation
  * @author a.stepanov
  * @run main AnonymousClassBeanPropertyTest
@@ -62,6 +62,10 @@
 
     // ---------- test cases (interfaces) ----------
 
+    public interface IPublic {
+        double getX();
+    }
+
     private interface IGet {
         double getX();
     }
@@ -113,6 +117,10 @@
         void setX(double a[]);
     }
 
+    private interface IIs {
+        boolean isX();
+    }
+
 
     // ---------- checks ----------
 
@@ -124,7 +132,7 @@
         return ok;
     }
 
-    private static boolean checkInfo(Class<?> c, String what) {
+    private static boolean checkInfo(Class<?> c, String what, boolean checkVals) {
 
         BeanInfo i;
         try { i = Introspector.getBeanInfo(c, Object.class); }
@@ -154,6 +162,8 @@
         ok &= check("visualUpdate",
             (boolean) d.getValue("visualUpdate"), UPDATE);
 
+        if (!checkVals) { return ok; }
+
         Object vals[] = (Object[]) d.getValue("enumerationValues");
         if (vals == null) {
             System.out.println("null enumerationValues");
@@ -210,8 +220,10 @@
             (boolean) d.getValue("visualUpdate"), !UPDATE);
 
         Object vals[] = (Object[]) d.getValue("enumerationValues");
-        if (vals != null || vals.length > 0) {
-            System.out.println("non-empty enumerationValues");
+        if (vals != null && vals.length > 0) {
+            System.out.println("non-empty enumerationValues:");
+            for (Object v: vals) { System.out.print(v.toString()); }
+            System.out.println();
             return false;
         }
 
@@ -228,6 +240,31 @@
 
         //----------------------------------------------------------------------
 
+        // TODO: please uncomment/update after 8154958 fix
+        /*
+        IPublic testPublic = new IPublic() {
+            @BeanProperty(
+                description  = DESCRIPTION,
+                bound        = BOUND,
+                expert       = EXPERT,
+                hidden       = HIDDEN,
+                preferred    = PREFERRED,
+                required     = REQUIRED,
+                visualUpdate = UPDATE,
+                enumerationValues = {V_NAME})
+            @Override
+            public double getX() { return X; }
+
+            public void addPropertyChangeListener(PropertyChangeListener l)    {}
+            public void removePropertyChangeListener(PropertyChangeListener l) {}
+        };
+        ok = checkInfo(testPublic.getClass(), "IPublic", true);
+        System.out.println("OK = " + ok);
+        passed = passed && ok;
+        */
+
+        //----------------------------------------------------------------------
+
         IGet testGet = new IGet() {
             @BeanProperty(
                 description  = DESCRIPTION,
@@ -244,7 +281,7 @@
             public void addPropertyChangeListener(PropertyChangeListener l)    {}
             public void removePropertyChangeListener(PropertyChangeListener l) {}
         };
-        ok = checkInfo(testGet.getClass(), "IGet");
+        ok = checkInfo(testGet.getClass(), "IGet", true);
         System.out.println("OK = " + ok);
         passed = passed && ok;
 
@@ -269,7 +306,7 @@
             public void addPropertyChangeListener(PropertyChangeListener l)    {}
             public void removePropertyChangeListener(PropertyChangeListener l) {}
         };
-        ok = checkInfo(testSet.getClass(), "ISet");
+        ok = checkInfo(testSet.getClass(), "ISet", true);
         System.out.println("OK = " + ok);
         passed = passed && ok;
 
@@ -294,7 +331,7 @@
             public void addPropertyChangeListener(PropertyChangeListener l)    {}
             public void removePropertyChangeListener(PropertyChangeListener l) {}
         };
-        ok = checkInfo(testGetByIndex.getClass(), "IGetByIndex");
+        ok = checkInfo(testGetByIndex.getClass(), "IGetByIndex", true);
         System.out.println("OK = " + ok);
         passed = passed && ok;
 
@@ -319,7 +356,7 @@
             public void addPropertyChangeListener(PropertyChangeListener l)    {}
             public void removePropertyChangeListener(PropertyChangeListener l) {}
         };
-        ok = checkInfo(testSetByIndex.getClass(), "ISetByIndex");
+        ok = checkInfo(testSetByIndex.getClass(), "ISetByIndex", true);
         System.out.println("OK = " + ok);
         passed = passed && ok;
 
@@ -346,7 +383,7 @@
             public void addPropertyChangeListener(PropertyChangeListener l)    {}
             public void removePropertyChangeListener(PropertyChangeListener l) {}
         };
-        ok = checkInfo(testGetArray.getClass(), "IGetArray");
+        ok = checkInfo(testGetArray.getClass(), "IGetArray", true);
         System.out.println("OK = " + ok);
         passed = passed && ok;
         */
@@ -374,7 +411,7 @@
             public void addPropertyChangeListener(PropertyChangeListener l)    {}
             public void removePropertyChangeListener(PropertyChangeListener l) {}
         };
-        ok = checkInfo(testSetArray.getClass(), "ISetArray");
+        ok = checkInfo(testSetArray.getClass(), "ISetArray", true);
         System.out.println("OK = " + ok);
         passed = passed && ok;
         */
@@ -402,7 +439,7 @@
             public void addPropertyChangeListener(PropertyChangeListener l)    {}
             public void removePropertyChangeListener(PropertyChangeListener l) {}
         };
-        ok = checkInfo(testGetBoth_1.getClass(), "IGetBoth-1");
+        ok = checkInfo(testGetBoth_1.getClass(), "IGetBoth-1", true);
         System.out.println("OK = " + ok);
         passed = passed && ok;
 
@@ -429,7 +466,7 @@
             public void addPropertyChangeListener(PropertyChangeListener l)    {}
             public void removePropertyChangeListener(PropertyChangeListener l) {}
         };
-        ok = checkInfo(testGetBoth_2.getClass(), "IGetBoth-2");
+        ok = checkInfo(testGetBoth_2.getClass(), "IGetBoth-2", true);
         System.out.println("OK = " + ok);
         passed = passed && ok;
         */
@@ -465,11 +502,11 @@
             public void addPropertyChangeListener(PropertyChangeListener l)    {}
             public void removePropertyChangeListener(PropertyChangeListener l) {}
         };
-        ok = checkInfo(testGetBoth_3.getClass(), "IGetBoth-3");
+        ok = checkInfo(testGetBoth_3.getClass(), "IGetBoth-3", true);
         System.out.println("OK = " + ok);
         ok2 = checkAlternativeInfo(testGetBoth_3.getClass(), "IGetBoth-3");
         System.out.println("OK = " + ok2);
-        passed = passed && ok && ok2;
+        passed = passed && (ok || ok2);
         */
 
         //----------------------------------------------------------------------
@@ -495,7 +532,7 @@
             public void addPropertyChangeListener(PropertyChangeListener l)    {}
             public void removePropertyChangeListener(PropertyChangeListener l) {}
         };
-        ok = checkInfo(testSetBoth_1.getClass(), "ISetBoth-1");
+        ok = checkInfo(testSetBoth_1.getClass(), "ISetBoth-1", true);
         System.out.println("OK = " + ok);
         passed = passed && ok;
 
@@ -522,7 +559,7 @@
             public void addPropertyChangeListener(PropertyChangeListener l)    {}
             public void removePropertyChangeListener(PropertyChangeListener l) {}
         };
-        ok = checkInfo(testSetBoth_2.getClass(), "ISetBoth-2");
+        ok = checkInfo(testSetBoth_2.getClass(), "ISetBoth-2", true);
         System.out.println("OK = " + ok);
         passed = passed && ok;
         */
@@ -558,11 +595,11 @@
             public void addPropertyChangeListener(PropertyChangeListener l)    {}
             public void removePropertyChangeListener(PropertyChangeListener l) {}
         };
-        ok = checkInfo(testSetBoth_3.getClass(), "ISetBoth-3");
+        ok = checkInfo(testSetBoth_3.getClass(), "ISetBoth-3", true);
         System.out.println("OK = " + ok);
         ok2 = checkAlternativeInfo(testSetBoth_3.getClass(), "ISetBoth-3");
         System.out.println("OK = " + ok2);
-        passed = passed && ok && ok2;
+        passed = passed && (ok || ok2);
         */
 
         //----------------------------------------------------------------------
@@ -588,7 +625,7 @@
             public void addPropertyChangeListener(PropertyChangeListener l)    {}
             public void removePropertyChangeListener(PropertyChangeListener l) {}
         };
-        ok = checkInfo(testGetSet_1.getClass(), "IGetSet-1");
+        ok = checkInfo(testGetSet_1.getClass(), "IGetSet-1", true);
         System.out.println("OK = " + ok);
         passed = passed && ok;
 
@@ -614,7 +651,7 @@
             public void addPropertyChangeListener(PropertyChangeListener l)    {}
             public void removePropertyChangeListener(PropertyChangeListener l) {}
         };
-        ok = checkInfo(testGetSet_2.getClass(), "IGetSet-2");
+        ok = checkInfo(testGetSet_2.getClass(), "IGetSet-2", true);
         System.out.println("OK = " + ok);
         passed = passed && ok;
 
@@ -649,11 +686,11 @@
             public void addPropertyChangeListener(PropertyChangeListener l)    {}
             public void removePropertyChangeListener(PropertyChangeListener l) {}
         };
-        ok = checkInfo(testGetSet_3.getClass(), "IGetSet-3");
+        ok = checkInfo(testGetSet_3.getClass(), "IGetSet-3", true);
         System.out.println("OK = " + ok);
         ok2 = checkAlternativeInfo(testGetSet_3.getClass(), "IGetSet-3");
         System.out.println("OK = " + ok2);
-        passed = passed && ok && ok2;
+        passed = passed && (ok || ok2);
         */
 
         //----------------------------------------------------------------------
@@ -679,7 +716,7 @@
             public void addPropertyChangeListener(PropertyChangeListener l)    {}
             public void removePropertyChangeListener(PropertyChangeListener l) {}
         };
-        ok = checkInfo(testGetSetByIndex_1.getClass(), "IGetSetByIndex-1");
+        ok = checkInfo(testGetSetByIndex_1.getClass(), "IGetSetByIndex-1", true);
         System.out.println("OK = " + ok);
         passed = passed && ok;
 
@@ -705,7 +742,7 @@
             public void addPropertyChangeListener(PropertyChangeListener l)    {}
             public void removePropertyChangeListener(PropertyChangeListener l) {}
         };
-        ok = checkInfo(testGetSetByIndex_2.getClass(), "IGetSetByIndex-2");
+        ok = checkInfo(testGetSetByIndex_2.getClass(), "IGetSetByIndex-2", true);
         System.out.println("OK = " + ok);
         passed = passed && ok;
 
@@ -744,12 +781,12 @@
             public void addPropertyChangeListener(PropertyChangeListener l)    {}
             public void removePropertyChangeListener(PropertyChangeListener l) {}
         };
-        ok = checkInfo(testGetSetByIndex_3.getClass(), "IGetSetByIndex-3");
+        ok = checkInfo(testGetSetByIndex_3.getClass(), "IGetSetByIndex-3", true);
         System.out.println("OK = " + ok);
         ok2 = checkAlternativeInfo(
             testGetSetByIndex_3.getClass(), "IGetSetByIndex-3");
         System.out.println("OK = " + ok2);
-        passed = passed && ok && ok2;
+        passed = passed && (ok || ok2);
         */
 
         //----------------------------------------------------------------------
@@ -781,7 +818,7 @@
             public void addPropertyChangeListener(PropertyChangeListener l)    {}
             public void removePropertyChangeListener(PropertyChangeListener l) {}
         };
-        ok = checkInfo(testGetSetBoth_1.getClass(), "IGetSetBoth-1");
+        ok = checkInfo(testGetSetBoth_1.getClass(), "IGetSetBoth-1", true);
         System.out.println("OK = " + ok);
         passed = passed && ok;
         */
@@ -813,7 +850,7 @@
             public void addPropertyChangeListener(PropertyChangeListener l)    {}
             public void removePropertyChangeListener(PropertyChangeListener l) {}
         };
-        ok = checkInfo(testGetSetBoth_2.getClass(), "IGetSetBoth-2");
+        ok = checkInfo(testGetSetBoth_2.getClass(), "IGetSetBoth-2", true);
         System.out.println("OK = " + ok);
         passed = passed && ok;
         */
@@ -853,14 +890,135 @@
             public void addPropertyChangeListener(PropertyChangeListener l)    {}
             public void removePropertyChangeListener(PropertyChangeListener l) {}
         };
-        ok = checkInfo(testGetSetBoth_3.getClass(), "IGetSetBoth-3");
+        ok = checkInfo(testGetSetBoth_3.getClass(), "IGetSetBoth-3", true);
         System.out.println("OK = " + ok);
         ok2 = checkAlternativeInfo(
             testGetSetBoth_3.getClass(), "IGetSetBoth-3");
         System.out.println("OK = " + ok2);
-        passed = passed && ok && ok2;
+        passed = passed && (ok || ok2);
         */
 
+        //----------------------------------------------------------------------
+
+        IIs testIs_1 = new IIs() {
+
+            @BeanProperty(
+                description  = DESCRIPTION,
+                bound        = BOUND,
+                expert       = EXPERT,
+                hidden       = HIDDEN,
+                preferred    = PREFERRED,
+                required     = REQUIRED,
+                visualUpdate = UPDATE)
+            @Override
+            public boolean isX() { return false; }
+
+            public void addPropertyChangeListener(PropertyChangeListener l)    {}
+            public void removePropertyChangeListener(PropertyChangeListener l) {}
+        };
+        ok = checkInfo(testIs_1.getClass(), "IIs-1", false);
+        System.out.println("OK = " + ok);
+        passed = passed && ok;
+
+
+        IIs testIs_2 = new IIs() {
+
+            private boolean b;
+
+            @Override
+            public boolean isX() { return b; }
+
+            @BeanProperty(
+                description  = DESCRIPTION,
+                bound        = BOUND,
+                expert       = EXPERT,
+                hidden       = HIDDEN,
+                preferred    = PREFERRED,
+                required     = REQUIRED,
+                visualUpdate = UPDATE)
+            public void setX(boolean v) { b = v; }
+
+            public void addPropertyChangeListener(PropertyChangeListener l)    {}
+            public void removePropertyChangeListener(PropertyChangeListener l) {}
+        };
+        ok = checkInfo(testIs_2.getClass(), "IIs-2", false);
+        System.out.println("OK = " + ok);
+        passed = passed && ok;
+
+
+        IIs testIs_3 = new IIs() {
+
+            @BeanProperty(
+                description  = DESCRIPTION,
+                bound        = BOUND,
+                expert       = EXPERT,
+                hidden       = HIDDEN,
+                preferred    = PREFERRED,
+                required     = REQUIRED,
+                visualUpdate = UPDATE)
+            @Override
+            public boolean isX() { return false; }
+
+            @BeanProperty(
+                description  = DESCRIPTION_2,
+                bound        = !BOUND,
+                expert       = !EXPERT,
+                hidden       = !HIDDEN,
+                preferred    = !PREFERRED,
+                required     = !REQUIRED,
+                visualUpdate = !UPDATE)
+            public boolean getX() { return false; }
+
+            public void addPropertyChangeListener(PropertyChangeListener l)    {}
+            public void removePropertyChangeListener(PropertyChangeListener l) {}
+        };
+        ok = checkInfo(testIs_3.getClass(), "IIs-3", false);
+        System.out.println("OK = " + ok);
+        ok2 = checkAlternativeInfo(testIs_3.getClass(), "IIs-3");
+        System.out.println("OK = " + ok2);
+        passed = passed && (ok || ok2);
+
+        // TODO: please uncomment/update after 8132973 fix
+        /*
+        IIs testIs_4 = new IIs() {
+
+            private boolean b;
+
+            @BeanProperty(
+                description  = DESCRIPTION,
+                bound        = BOUND,
+                expert       = EXPERT,
+                hidden       = HIDDEN,
+                preferred    = PREFERRED,
+                required     = REQUIRED,
+                visualUpdate = UPDATE)
+            @Override
+            public boolean isX() { return b; }
+
+            @BeanProperty(
+                description  = DESCRIPTION_2,
+                bound        = !BOUND,
+                expert       = !EXPERT,
+                hidden       = !HIDDEN,
+                preferred    = !PREFERRED,
+                required     = !REQUIRED,
+                visualUpdate = !UPDATE)
+            public void setX(boolean v) { b = v; }
+
+            public void addPropertyChangeListener(PropertyChangeListener l)    {}
+            public void removePropertyChangeListener(PropertyChangeListener l) {}
+        };
+        ok = checkInfo(testIs_4.getClass(), "IIs-4", false);
+        System.out.println("OK = " + ok);
+        ok2 = checkAlternativeInfo(testIs_4.getClass(), "IIs-4");
+        System.out.println("OK = " + ok2);
+        passed = passed && (ok || ok2);
+        */
+
+
+        //----------------------------------------------------------------------
+
+
         if (!passed) { throw new RuntimeException("test failed"); }
         System.out.println("\ntest passed");
     }
--- a/jdk/test/java/beans/Introspector/BeanPropertyTest.java	Thu May 19 17:48:02 2016 +0000
+++ b/jdk/test/java/beans/Introspector/BeanPropertyTest.java	Thu May 19 19:46:20 2016 +0000
@@ -33,7 +33,7 @@
 
 /**
  * @test
- * @bug 8132703 8132163 8132732 8132973 8154756 8132888
+ * @bug 8132703 8132163 8132732 8132973 8154756 8132888 8155103
  * @summary Some check for BeanProperty annotation
  * @author a.stepanov
  * @run main BeanPropertyTest
@@ -853,6 +853,64 @@
         public void removePropertyChangeListener(PropertyChangeListener l) {}
     }
 
+    // JDK-8155103
+    public static enum E {
+
+        ONE,
+        TWO {
+            @BeanProperty(
+            description  = DESCRIPTION,
+            bound        = BOUND,
+            expert       = EXPERT,
+            hidden       = HIDDEN,
+            preferred    = PREFERRED,
+            required     = REQUIRED,
+            visualUpdate = UPDATE,
+            enumerationValues = {V_NAME})
+            public void setX(int v) {}
+
+            public void addPropertyChangeListener(PropertyChangeListener l)    {}
+            public void removePropertyChangeListener(PropertyChangeListener l) {}
+        };
+
+        @BeanProperty(
+            description  = DESCRIPTION,
+            bound        = BOUND,
+            expert       = EXPERT,
+            hidden       = HIDDEN,
+            preferred    = PREFERRED,
+            required     = REQUIRED,
+            visualUpdate = UPDATE,
+            enumerationValues = {V_NAME})
+        public void setX(int v) {}
+
+        public void addPropertyChangeListener(PropertyChangeListener l)    {}
+        public void removePropertyChangeListener(PropertyChangeListener l) {}
+
+    }
+
+    private static enum EB {
+
+        TRUE(true), FALSE(false);
+
+        private boolean b;
+        private EB(boolean v) { b = v; }
+
+        @BeanProperty(
+            description  = DESCRIPTION,
+            bound        = BOUND,
+            expert       = EXPERT,
+            hidden       = HIDDEN,
+            preferred    = PREFERRED,
+            required     = REQUIRED,
+            visualUpdate = UPDATE)
+        public boolean isTrue() { return true; }
+
+        public void addPropertyChangeListener(PropertyChangeListener l)    {}
+        public void removePropertyChangeListener(PropertyChangeListener l) {}
+
+    }
+
 
     // ---------- checks ----------
 
@@ -953,7 +1011,7 @@
     }
 
     private static boolean ignoreVals(Class<?> c) {
-        return (c.equals(Self.class) || c.equals(SelfArr.class));
+        return (c.equals(Self.class) || c.equals(SelfArr.class)) || c.equals(EB.class);
     }
 
 
@@ -1003,6 +1061,29 @@
             passed = passed && ok;
         }
 
+        // enums
+
+        Class<?> enumCases[] = {
+
+            // TODO: uncomment/update after 8155103 fix
+            //E.class, E.TWO.getClass(), EB.class
+        };
+
+        int ne = 1;
+        for (Class<?> c: enumCases) {
+
+            System.out.println("\nEnum-" + ne + ":");
+            ne++;
+
+            BeanInfo i;
+            try { i = Introspector.getBeanInfo(c, Object.class); }
+            catch (IntrospectionException e) { throw new RuntimeException(e); }
+            boolean ok = checkInfo(i, !ignoreVals(c));
+            System.out.println(ok ? "OK" : "NOK");
+            passed = passed && ok;
+        }
+
+
         if (!passed) { throw new RuntimeException("test failed"); }
         System.out.println("\ntest passed");
     }
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/jdk/test/java/beans/Introspector/InheritanceBeanPropertyTest.java	Thu May 19 19:46:20 2016 +0000
@@ -0,0 +1,1281 @@
+/*
+ * Copyright (c) 2016, 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.
+ */
+
+import java.beans.BeanInfo;
+import java.beans.BeanProperty;
+import java.beans.IntrospectionException;
+import java.beans.Introspector;
+import java.beans.PropertyChangeListener;
+import java.beans.PropertyDescriptor;
+
+import java.util.Arrays;
+
+
+/**
+ * @test
+ * @bug 8132565 8155013
+ * @summary Some inheritance check for BeanProperty annotation
+ * @author a.stepanov
+ * @run main InheritanceBeanPropertyTest
+ */
+
+
+public class InheritanceBeanPropertyTest {
+
+    private final static String  DESCRIPTION = "TEST";
+    private final static boolean BOUND       = true;
+    private final static boolean EXPERT      = false;
+    private final static boolean HIDDEN      = true;
+    private final static boolean PREFERRED   = false;
+    private final static boolean REQUIRED    = true;
+    private final static boolean UPDATE      = false;
+
+    private final static double X = java.lang.Math.PI;
+
+    private final static String
+        V_NAME  = "java.lang.Math.PI",
+        V_SHORT = "PI",
+        V = Double.toString(X);
+
+    private final static String DESCRIPTION_2 = "XYZ";
+
+
+    // ---------- test cases ----------
+
+    public static class BaseGet {
+
+        private final static String TESTCASE = "base getter";
+
+        public double getX() { return X; }
+    }
+
+    public static class OverloadGet extends BaseGet {
+
+        private final static String TESTCASE = "overload getter";
+
+        private final double x[] = {X, X, X};
+
+        @BeanProperty(
+            description  = DESCRIPTION,
+            bound        = BOUND,
+            expert       = EXPERT,
+            hidden       = HIDDEN,
+            preferred    = PREFERRED,
+            required     = REQUIRED,
+            visualUpdate = UPDATE,
+            enumerationValues = {V_NAME})
+        public double getX(int i) { return x[i]; } // indexed
+
+        public void addPropertyChangeListener(PropertyChangeListener l)    {}
+        public void removePropertyChangeListener(PropertyChangeListener l) {}
+    }
+
+    // ----------
+
+    public static class BaseSet {
+
+        private final static String TESTCASE = "base setter";
+
+        double u;
+        public void setX(double v) { u = v; }
+    }
+
+    public static class OverloadSet extends BaseSet {
+
+        private final static String TESTCASE = "overload setter";
+
+        private final double x[] = {X, X, X};
+
+        @BeanProperty(
+            description  = DESCRIPTION,
+            bound        = BOUND,
+            expert       = EXPERT,
+            hidden       = HIDDEN,
+            preferred    = PREFERRED,
+            required     = REQUIRED,
+            visualUpdate = UPDATE,
+            enumerationValues = {V_NAME})
+        public void setX(int i, double v) { x[i] = v; } // indexed
+
+        public void addPropertyChangeListener(PropertyChangeListener l)    {}
+        public void removePropertyChangeListener(PropertyChangeListener l) {}
+    }
+
+    // ----------
+
+    public static class BaseIGet {
+
+        protected final double x[] = {X, X, X};
+        public double[] getX() { return x; }
+    }
+
+    public static class OverloadIGet extends BaseIGet {
+
+        private final static String TESTCASE = "overload indexed getter";
+
+        @BeanProperty(
+            description  = DESCRIPTION,
+            bound        = BOUND,
+            expert       = EXPERT,
+            hidden       = HIDDEN,
+            preferred    = PREFERRED,
+            required     = REQUIRED,
+            visualUpdate = UPDATE,
+            enumerationValues = {V_NAME})
+        public double getX(int i) { return x[i]; }
+
+        public void addPropertyChangeListener(PropertyChangeListener l)    {}
+        public void removePropertyChangeListener(PropertyChangeListener l) {}
+    }
+
+    // ----------
+
+    public static class BaseISet {
+
+        protected double x[] = {X, X, X};
+        public void setX(double a[]) { x = Arrays.copyOf(a, a.length); }
+    }
+
+    public static class OverloadISet extends BaseISet {
+
+        private final static String TESTCASE = "overload indexed setter";
+
+        @BeanProperty(
+            description  = DESCRIPTION,
+            bound        = BOUND,
+            expert       = EXPERT,
+            hidden       = HIDDEN,
+            preferred    = PREFERRED,
+            required     = REQUIRED,
+            visualUpdate = UPDATE,
+            enumerationValues = {V_NAME})
+        public void setX(int i, double v) { x[i] = v; }
+
+        public void addPropertyChangeListener(PropertyChangeListener l)    {}
+        public void removePropertyChangeListener(PropertyChangeListener l) {}
+    }
+
+    // ----------
+
+    public static class BoolGet {
+
+        @BeanProperty(
+            description  = DESCRIPTION_2,
+            bound        = !BOUND,
+            expert       = !EXPERT,
+            hidden       = !HIDDEN,
+            preferred    = !PREFERRED,
+            required     = !REQUIRED,
+            visualUpdate = !UPDATE)
+        public boolean getX() { return false; }
+    }
+
+    public static class BoolGetIs extends BoolGet {
+
+        private final static String TESTCASE = "base boolean getter + is";
+
+        @BeanProperty(
+            description  = DESCRIPTION,
+            bound        = BOUND,
+            expert       = EXPERT,
+            hidden       = HIDDEN,
+            preferred    = PREFERRED,
+            required     = REQUIRED,
+            visualUpdate = UPDATE)
+        public boolean isX() { return false; }
+
+        public void addPropertyChangeListener(PropertyChangeListener l)    {}
+        public void removePropertyChangeListener(PropertyChangeListener l) {}
+    }
+    // ----------
+
+    public static class BoolIs {
+
+        @BeanProperty(
+            description  = DESCRIPTION_2,
+            bound        = !BOUND,
+            expert       = !EXPERT,
+            hidden       = !HIDDEN,
+            preferred    = !PREFERRED,
+            required     = !REQUIRED,
+            visualUpdate = !UPDATE)
+        public boolean isX() { return false; }
+    }
+
+    public static class BoolIsGet extends BoolIs {
+
+        private final static String TESTCASE = "base is + boolean getter";
+
+        @BeanProperty(
+            description  = DESCRIPTION,
+            bound        = BOUND,
+            expert       = EXPERT,
+            hidden       = HIDDEN,
+            preferred    = PREFERRED,
+            required     = REQUIRED,
+            visualUpdate = UPDATE)
+        public boolean getX() { return false; }
+
+        public void addPropertyChangeListener(PropertyChangeListener l)    {}
+        public void removePropertyChangeListener(PropertyChangeListener l) {}
+    }
+
+    // ----------
+
+    public static class AnnotatedGet {
+
+        private final static String TESTCASE = "annotated super getter";
+
+        @BeanProperty(
+            description  = DESCRIPTION,
+            bound        = BOUND,
+            expert       = EXPERT,
+            hidden       = HIDDEN,
+            preferred    = PREFERRED,
+            required     = REQUIRED,
+            visualUpdate = UPDATE,
+            enumerationValues = {V_NAME})
+        public double getX() { return 0.; }
+
+        public void addPropertyChangeListener(PropertyChangeListener l)    {}
+        public void removePropertyChangeListener(PropertyChangeListener l) {}
+    }
+
+    public static class OverrideAnnotatedGet extends AnnotatedGet {
+
+        private final static String TESTCASE = "override annotated getter";
+
+        @Override
+        public double getX() { return X; }
+    }
+
+    // ----------
+
+    public static class AnnotatedIs {
+
+        private final static String TESTCASE = "annotated super is";
+
+        @BeanProperty(
+            description  = DESCRIPTION,
+            bound        = BOUND,
+            expert       = EXPERT,
+            hidden       = HIDDEN,
+            preferred    = PREFERRED,
+            required     = REQUIRED,
+            visualUpdate = UPDATE,
+            enumerationValues = {V_NAME})
+        public boolean isX() { return false; }
+
+        public void addPropertyChangeListener(PropertyChangeListener l)    {}
+        public void removePropertyChangeListener(PropertyChangeListener l) {}
+    }
+
+    public static class OverrideAnnotatedIs extends AnnotatedIs {
+
+        private final static String TESTCASE = "override annotated is";
+
+        @Override
+        public boolean isX() { return false; }
+    }
+
+    // ----------
+
+    public static class AnnotatedSet {
+
+        private final static String TESTCASE = "annotated super set";
+
+        protected double x;
+
+        @BeanProperty(
+            description  = DESCRIPTION,
+            bound        = BOUND,
+            expert       = EXPERT,
+            hidden       = HIDDEN,
+            preferred    = PREFERRED,
+            required     = REQUIRED,
+            visualUpdate = UPDATE,
+            enumerationValues = {V_NAME})
+        public void setX(double v) { x = -v; }
+
+        public void addPropertyChangeListener(PropertyChangeListener l)    {}
+        public void removePropertyChangeListener(PropertyChangeListener l) {}
+    }
+
+    public static class OverrideAnnotatedSet extends AnnotatedSet {
+
+        private final static String TESTCASE = "override annotated setter";
+
+        @Override
+        public void setX(double v) { x = v; }
+    }
+
+    // ----------
+
+    public static class AnnotatedGet2 {
+
+        protected double x;
+
+        @BeanProperty(
+            description  = DESCRIPTION_2,
+            bound        = !BOUND,
+            expert       = !EXPERT,
+            hidden       = !HIDDEN,
+            preferred    = !PREFERRED,
+            required     = !REQUIRED,
+            visualUpdate = !UPDATE)
+        public double getX() { return 0.; }
+    }
+
+    public static class OverrideAnnotatedGet2 extends AnnotatedGet2 {
+
+        private final static String TESTCASE = "override annotated getter - 2";
+
+        @BeanProperty(
+            description  = DESCRIPTION,
+            bound        = BOUND,
+            expert       = EXPERT,
+            hidden       = HIDDEN,
+            preferred    = PREFERRED,
+            required     = REQUIRED,
+            visualUpdate = UPDATE,
+            enumerationValues = {V_NAME})
+        @Override
+        public double getX() { return X; }
+
+        public void addPropertyChangeListener(PropertyChangeListener l)    {}
+        public void removePropertyChangeListener(PropertyChangeListener l) {}
+    }
+
+    public static class AnnotatedGet2Ext extends AnnotatedGet2 {
+
+        private final static String TESTCASE = "extend annotated getter - 2";
+
+        @BeanProperty(
+            description  = DESCRIPTION,
+            bound        = BOUND,
+            expert       = EXPERT,
+            hidden       = HIDDEN,
+            preferred    = PREFERRED,
+            required     = REQUIRED,
+            visualUpdate = UPDATE,
+            enumerationValues = {V_NAME})
+        public void setX(double v) { x = v; }
+
+        public void addPropertyChangeListener(PropertyChangeListener l)    {}
+        public void removePropertyChangeListener(PropertyChangeListener l) {}
+    }
+
+    // ----------
+
+    public static class AnnotatedIs2 {
+
+        protected boolean b = false;
+
+        @BeanProperty(
+            description  = DESCRIPTION_2,
+            bound        = !BOUND,
+            expert       = !EXPERT,
+            hidden       = !HIDDEN,
+            preferred    = !PREFERRED,
+            required     = !REQUIRED,
+            visualUpdate = !UPDATE)
+        public boolean isX() { return false; }
+    }
+
+    public static class OverrideAnnotatedIs2 extends AnnotatedIs2 {
+
+        private final static String TESTCASE = "override annotated is - 2";
+
+        @BeanProperty(
+            description  = DESCRIPTION,
+            bound        = BOUND,
+            expert       = EXPERT,
+            hidden       = HIDDEN,
+            preferred    = PREFERRED,
+            required     = REQUIRED,
+            visualUpdate = UPDATE)
+        @Override
+        public boolean isX() { return b; }
+
+        public void addPropertyChangeListener(PropertyChangeListener l)    {}
+        public void removePropertyChangeListener(PropertyChangeListener l) {}
+    }
+
+    public static class AnnotatedIs2Ext extends AnnotatedIs2 {
+
+        private final static String TESTCASE = "extend annotated is - 2";
+
+        @BeanProperty(
+            description  = DESCRIPTION,
+            bound        = BOUND,
+            expert       = EXPERT,
+            hidden       = HIDDEN,
+            preferred    = PREFERRED,
+            required     = REQUIRED,
+            visualUpdate = UPDATE)
+        public void setX(boolean v) { b = v; }
+
+        public void addPropertyChangeListener(PropertyChangeListener l)    {}
+        public void removePropertyChangeListener(PropertyChangeListener l) {}
+    }
+
+    // ----------
+
+    public static class AnnotatedSet2 {
+
+        protected double x;
+
+        @BeanProperty(
+            description  = DESCRIPTION_2,
+            bound        = !BOUND,
+            expert       = !EXPERT,
+            hidden       = !HIDDEN,
+            preferred    = !PREFERRED,
+            required     = !REQUIRED,
+            visualUpdate = !UPDATE)
+        public void setX(double v) { x = -v; }
+    }
+
+    public static class OverrideAnnotatedSet2 extends AnnotatedSet2 {
+
+        private final static String TESTCASE = "override annotated setter - 2";
+
+        @BeanProperty(
+            description  = DESCRIPTION,
+            bound        = BOUND,
+            expert       = EXPERT,
+            hidden       = HIDDEN,
+            preferred    = PREFERRED,
+            required     = REQUIRED,
+            visualUpdate = UPDATE,
+            enumerationValues = {V_NAME})
+        @Override
+        public void setX(double v) { x = v; }
+
+        public void addPropertyChangeListener(PropertyChangeListener l)    {}
+        public void removePropertyChangeListener(PropertyChangeListener l) {}
+    }
+
+    public static class AnnotatedSet2Ext extends AnnotatedSet2 {
+
+        private final static String TESTCASE = "extend annotated setter - 2";
+
+        @BeanProperty(
+            description  = DESCRIPTION,
+            bound        = BOUND,
+            expert       = EXPERT,
+            hidden       = HIDDEN,
+            preferred    = PREFERRED,
+            required     = REQUIRED,
+            visualUpdate = UPDATE,
+            enumerationValues = {V_NAME})
+        public double getX() { return x; }
+
+        public void addPropertyChangeListener(PropertyChangeListener l)    {}
+        public void removePropertyChangeListener(PropertyChangeListener l) {}
+    }
+
+    // ----------
+
+    public abstract static class AbstractGet {
+
+        @BeanProperty(
+            description  = DESCRIPTION_2,
+            bound        = !BOUND,
+            expert       = !EXPERT,
+            hidden       = !HIDDEN,
+            preferred    = !PREFERRED,
+            required     = !REQUIRED,
+            visualUpdate = !UPDATE)
+        public abstract double getX();
+    }
+
+    public static class OverrideAbstractGet extends AbstractGet {
+
+        private final static String TESTCASE =
+            "override abstract annotated getter";
+
+        @Override
+        public double getX() { return X; }
+    }
+
+    public static class OverrideAbstractGet2 extends AbstractGet {
+
+        private final static String TESTCASE =
+            "override abstract annotated getter - 2";
+
+        @BeanProperty(
+            description  = DESCRIPTION,
+            bound        = BOUND,
+            expert       = EXPERT,
+            hidden       = HIDDEN,
+            preferred    = PREFERRED,
+            required     = REQUIRED,
+            visualUpdate = UPDATE,
+            enumerationValues = {V_NAME})
+        @Override
+        public double getX() { return X; }
+
+        public void addPropertyChangeListener(PropertyChangeListener l)    {}
+        public void removePropertyChangeListener(PropertyChangeListener l) {}
+    }
+
+    public abstract static class AbstractGetExt extends AbstractGet {
+
+        private final static String TESTCASE =
+            "extend abstract annotated getter";
+
+        @BeanProperty(
+            description  = DESCRIPTION,
+            bound        = BOUND,
+            expert       = EXPERT,
+            hidden       = HIDDEN,
+            preferred    = PREFERRED,
+            required     = REQUIRED,
+            visualUpdate = UPDATE,
+            enumerationValues = {V_NAME})
+        public abstract void setX(double v);
+
+        public void addPropertyChangeListener(PropertyChangeListener l)    {}
+        public void removePropertyChangeListener(PropertyChangeListener l) {}
+    }
+
+    // ----------
+
+    public abstract static class AbstractIs {
+
+        @BeanProperty(
+            description  = DESCRIPTION_2,
+            bound        = !BOUND,
+            expert       = !EXPERT,
+            hidden       = !HIDDEN,
+            preferred    = !PREFERRED,
+            required     = !REQUIRED,
+            visualUpdate = !UPDATE)
+        public abstract boolean isX();
+    }
+
+    public static class OverrideAbstractIs extends AbstractIs {
+
+        private final static String TESTCASE =
+            "override abstract annotated is";
+
+        @Override
+        public boolean isX() { return true; }
+    }
+
+    public static class OverrideAbstractIs2 extends AbstractIs {
+
+        private final static String TESTCASE =
+            "override abstract annotated is - 2";
+
+        @BeanProperty(
+            description  = DESCRIPTION,
+            bound        = BOUND,
+            expert       = EXPERT,
+            hidden       = HIDDEN,
+            preferred    = PREFERRED,
+            required     = REQUIRED,
+            visualUpdate = UPDATE)
+        @Override
+        public boolean isX() { return true; }
+
+        public void addPropertyChangeListener(PropertyChangeListener l)    {}
+        public void removePropertyChangeListener(PropertyChangeListener l) {}
+    }
+
+
+    public abstract static class AbstractIsExt extends AbstractIs {
+
+        private final static String TESTCASE =
+            "extend abstract annotated is";
+
+        @BeanProperty(
+            description  = DESCRIPTION,
+            bound        = BOUND,
+            expert       = EXPERT,
+            hidden       = HIDDEN,
+            preferred    = PREFERRED,
+            required     = REQUIRED,
+            visualUpdate = UPDATE)
+        public abstract boolean getX();
+
+        public void addPropertyChangeListener(PropertyChangeListener l)    {}
+        public void removePropertyChangeListener(PropertyChangeListener l) {}
+    }
+
+    // ----------
+
+    public abstract static class AbstractSet {
+
+        @BeanProperty(
+            description  = DESCRIPTION_2,
+            bound        = !BOUND,
+            expert       = !EXPERT,
+            hidden       = !HIDDEN,
+            preferred    = !PREFERRED,
+            required     = !REQUIRED,
+            visualUpdate = !UPDATE)
+        public abstract void setX(double v);
+    }
+
+    public static class OverrideAbstractSet extends AbstractSet {
+
+        private final static String TESTCASE =
+            "override abstract annotated setter";
+
+        private double x;
+
+        @Override
+        public void setX(double v) { x = v; }
+    }
+
+    public static class OverrideAbstractSet2 extends AbstractSet {
+
+        private final static String TESTCASE =
+            "override abstract annotated setter - 2";
+
+        private double x;
+
+        @BeanProperty(
+            description  = DESCRIPTION,
+            bound        = BOUND,
+            expert       = EXPERT,
+            hidden       = HIDDEN,
+            preferred    = PREFERRED,
+            required     = REQUIRED,
+            visualUpdate = UPDATE,
+            enumerationValues = {V_NAME})
+        @Override
+        public void setX(double v) { x = v; }
+
+        public void addPropertyChangeListener(PropertyChangeListener l)    {}
+        public void removePropertyChangeListener(PropertyChangeListener l) {}
+    }
+
+    public abstract static class AbstractSetExt extends AbstractSet {
+
+        private final static String TESTCASE =
+            "extend abstract annotated setter";
+
+        @BeanProperty(
+            description  = DESCRIPTION,
+            bound        = BOUND,
+            expert       = EXPERT,
+            hidden       = HIDDEN,
+            preferred    = PREFERRED,
+            required     = REQUIRED,
+            visualUpdate = UPDATE,
+            enumerationValues = {V_NAME})
+        public abstract void setX(double v[]);
+
+        public void addPropertyChangeListener(PropertyChangeListener l)    {}
+        public void removePropertyChangeListener(PropertyChangeListener l) {}
+    }
+
+    // ----------
+
+    public static abstract class AbstractGet2 {
+
+        private final static String TESTCASE = "abstract super getter";
+
+        @BeanProperty(
+            description  = DESCRIPTION,
+            bound        = BOUND,
+            expert       = EXPERT,
+            hidden       = HIDDEN,
+            preferred    = PREFERRED,
+            required     = REQUIRED,
+            visualUpdate = UPDATE,
+            enumerationValues = {V_NAME})
+        public abstract double getX();
+
+        public void addPropertyChangeListener(PropertyChangeListener l)    {}
+        public void removePropertyChangeListener(PropertyChangeListener l) {}
+    }
+
+    public static abstract class AbstractGet2Ext extends AbstractGet2 {
+
+        @BeanProperty(
+            description  = DESCRIPTION_2,
+            bound        = !BOUND,
+            expert       = !EXPERT,
+            hidden       = !HIDDEN,
+            preferred    = !PREFERRED,
+            required     = !REQUIRED,
+            visualUpdate = !UPDATE)
+        public abstract void setX(double a[]);
+    }
+
+    // ----------
+
+    public static interface IGet {
+
+        @BeanProperty(
+            description  = DESCRIPTION_2,
+            bound        = !BOUND,
+            expert       = !EXPERT,
+            hidden       = !HIDDEN,
+            preferred    = !PREFERRED,
+            required     = !REQUIRED,
+            visualUpdate = !UPDATE)
+        double getX();
+    }
+
+    public static class IGetImpl implements IGet {
+
+        private final static String TESTCASE = "implement getter interface";
+
+        @Override
+        public double getX() { return X; }
+    }
+
+    public static class IGetImpl2 implements IGet {
+
+        private final static String TESTCASE = "implement getter interface - 2";
+
+        @BeanProperty(
+            description  = DESCRIPTION,
+            bound        = BOUND,
+            expert       = EXPERT,
+            hidden       = HIDDEN,
+            preferred    = PREFERRED,
+            required     = REQUIRED,
+            visualUpdate = UPDATE,
+            enumerationValues = {V_NAME})
+        @Override
+        public double getX() { return X; }
+
+        public void addPropertyChangeListener(PropertyChangeListener l)    {}
+        public void removePropertyChangeListener(PropertyChangeListener l) {}
+    }
+
+    public abstract static class IGetImpl3 implements IGet {
+
+        private final static String TESTCASE = "implement getter interface - 3";
+
+        @BeanProperty(
+            description  = DESCRIPTION,
+            bound        = BOUND,
+            expert       = EXPERT,
+            hidden       = HIDDEN,
+            preferred    = PREFERRED,
+            required     = REQUIRED,
+            visualUpdate = UPDATE,
+            enumerationValues = {V_NAME})
+        public abstract void setX(double v);
+
+        public void addPropertyChangeListener(PropertyChangeListener l)    {}
+        public void removePropertyChangeListener(PropertyChangeListener l) {}
+    }
+
+    // ----------
+
+    public static interface IIs {
+
+        @BeanProperty(
+            description  = DESCRIPTION_2,
+            bound        = !BOUND,
+            expert       = !EXPERT,
+            hidden       = !HIDDEN,
+            preferred    = !PREFERRED,
+            required     = !REQUIRED,
+            visualUpdate = !UPDATE)
+        public boolean isX();
+    }
+
+    public static class IIsImpl implements IIs {
+
+        private final static String TESTCASE = "implement is interface";
+
+        @Override
+        public boolean isX() { return true; }
+    }
+
+    public static class IIsImpl2 implements IIs {
+
+        private final static String TESTCASE = "implement is interface - 2";
+
+        @BeanProperty(
+            description  = DESCRIPTION,
+            bound        = BOUND,
+            expert       = EXPERT,
+            hidden       = HIDDEN,
+            preferred    = PREFERRED,
+            required     = REQUIRED,
+            visualUpdate = UPDATE)
+        @Override
+        public boolean isX() { return true; }
+
+        public void addPropertyChangeListener(PropertyChangeListener l)    {}
+        public void removePropertyChangeListener(PropertyChangeListener l) {}
+    }
+
+    public abstract static class IIsImpl3 implements IIs {
+
+        private final static String TESTCASE = "implement is interface - 3";
+
+        @BeanProperty(
+            description  = DESCRIPTION,
+            bound        = BOUND,
+            expert       = EXPERT,
+            hidden       = HIDDEN,
+            preferred    = PREFERRED,
+            required     = REQUIRED,
+            visualUpdate = UPDATE)
+        public abstract void setX(boolean v);
+
+        public void addPropertyChangeListener(PropertyChangeListener l)    {}
+        public void removePropertyChangeListener(PropertyChangeListener l) {}
+    }
+
+    // ----------
+
+    public static interface ISet {
+
+        @BeanProperty(
+            description  = DESCRIPTION_2,
+            bound        = !BOUND,
+            expert       = !EXPERT,
+            hidden       = !HIDDEN,
+            preferred    = !PREFERRED,
+            required     = !REQUIRED,
+            visualUpdate = !UPDATE)
+        public void setX(double v);
+    }
+
+    public static class ISetImpl implements ISet {
+
+        private final static String TESTCASE = "implement getter interface";
+
+        private double x;
+
+        @Override
+        public void setX(double v) { x = v; }
+    }
+
+    public static class ISetImpl2 implements ISet {
+
+        private final static String TESTCASE = "implement getter interface - 2";
+
+        private double x;
+
+        @BeanProperty(
+            description  = DESCRIPTION,
+            bound        = BOUND,
+            expert       = EXPERT,
+            hidden       = HIDDEN,
+            preferred    = PREFERRED,
+            required     = REQUIRED,
+            visualUpdate = UPDATE,
+            enumerationValues = {V_NAME})
+        @Override
+        public void setX(double v) { x = v; }
+
+        public void addPropertyChangeListener(PropertyChangeListener l)    {}
+        public void removePropertyChangeListener(PropertyChangeListener l) {}
+    }
+
+    public abstract static class ISetImpl3 implements ISet {
+
+        private final static String TESTCASE = "implement getter interface - 3";
+
+        @BeanProperty(
+            description  = DESCRIPTION,
+            bound        = BOUND,
+            expert       = EXPERT,
+            hidden       = HIDDEN,
+            preferred    = PREFERRED,
+            required     = REQUIRED,
+            visualUpdate = UPDATE,
+            enumerationValues = {V_NAME})
+        public abstract double getX();
+
+        public void addPropertyChangeListener(PropertyChangeListener l)    {}
+        public void removePropertyChangeListener(PropertyChangeListener l) {}
+    }
+
+    // ----------
+
+    public static interface ISet2 {
+
+        final static String TESTCASE = "super interface - setter";
+
+        @BeanProperty(
+            description  = DESCRIPTION,
+            bound        = BOUND,
+            expert       = EXPERT,
+            hidden       = HIDDEN,
+            preferred    = PREFERRED,
+            required     = REQUIRED,
+            visualUpdate = UPDATE,
+            enumerationValues = {V_NAME})
+        public void setX(double v);
+
+        public void addPropertyChangeListener(PropertyChangeListener l);
+        public void removePropertyChangeListener(PropertyChangeListener l);
+    }
+
+    public static class ISet2Impl implements ISet2 {
+
+        private double x;
+
+        @BeanProperty(
+            description  = DESCRIPTION_2,
+            bound        = !BOUND,
+            expert       = !EXPERT,
+            hidden       = !HIDDEN,
+            preferred    = !PREFERRED,
+            required     = !REQUIRED,
+            visualUpdate = !UPDATE)
+        @Override
+        public void setX(double v) { x = v; }
+
+        @Override
+        public void addPropertyChangeListener(PropertyChangeListener l) {}
+        @Override
+        public void removePropertyChangeListener(PropertyChangeListener l) {}
+    }
+
+    // ----------
+
+    public static interface IGet2 {
+
+        final static String TESTCASE = "super interface - indexed getter";
+
+        @BeanProperty(
+            description  = DESCRIPTION,
+            bound        = BOUND,
+            expert       = EXPERT,
+            hidden       = HIDDEN,
+            preferred    = PREFERRED,
+            required     = REQUIRED,
+            visualUpdate = UPDATE,
+            enumerationValues = {V_NAME})
+        public double[] getX();
+
+        public void addPropertyChangeListener(PropertyChangeListener l);
+        public void removePropertyChangeListener(PropertyChangeListener l);
+    }
+
+    public static class IGet2Impl implements IGet2 {
+
+        @BeanProperty(
+            description  = DESCRIPTION_2,
+            bound        = !BOUND,
+            expert       = !EXPERT,
+            hidden       = !HIDDEN,
+            preferred    = !PREFERRED,
+            required     = !REQUIRED,
+            visualUpdate = !UPDATE)
+        @Override
+        public double[] getX() { return new double[]{X, X}; }
+
+        @Override
+        public void addPropertyChangeListener(PropertyChangeListener l) {}
+        @Override
+        public void removePropertyChangeListener(PropertyChangeListener l) {}
+    }
+
+    // ----------
+
+    public static class ProtectedGet {
+
+        @BeanProperty(
+            description  = DESCRIPTION_2,
+            bound        = !BOUND,
+            expert       = !EXPERT,
+            hidden       = !HIDDEN,
+            preferred    = !PREFERRED,
+            required     = !REQUIRED,
+            visualUpdate = !UPDATE)
+        protected double getX() { return 0.; }
+    }
+
+    public static class OverrideProtectedGet extends ProtectedGet {
+
+        final static String TESTCASE = "override protected getter";
+
+        @BeanProperty(
+            description  = DESCRIPTION,
+            bound        = BOUND,
+            expert       = EXPERT,
+            hidden       = HIDDEN,
+            preferred    = PREFERRED,
+            required     = REQUIRED,
+            visualUpdate = UPDATE,
+            enumerationValues = {V_NAME})
+        @Override
+        public double getX() { return X; }
+
+        public void addPropertyChangeListener(PropertyChangeListener l) {}
+        public void removePropertyChangeListener(PropertyChangeListener l) {}
+    }
+
+    // ----------
+
+    // static getter - see also JDK-8154938
+    public static class StaticGet {
+
+        @BeanProperty(
+            description  = DESCRIPTION_2,
+            bound        = !BOUND,
+            expert       = !EXPERT,
+            hidden       = !HIDDEN,
+            preferred    = !PREFERRED,
+            required     = !REQUIRED,
+            visualUpdate = !UPDATE)
+        public static double getProp() { return 0.; }
+    }
+
+    public static class HideStaticGet extends StaticGet {
+
+        final static String TESTCASE = "hide static getter";
+
+        public double getX() { return X; } // add to get the "default" info
+        public static double getProp() { return X; }
+    }
+
+    // TODO: if 8154938 is considered to be a real issue,
+    // create one more test case "HideStaticGet2 extends StaticGet" with an
+    // annotated getter and check the correctness of the corresponding bean info
+
+    // ---------- checks ----------
+
+    private static boolean check(String what, boolean v, boolean ref) {
+
+        boolean ok = (v == ref);
+        if (!ok) { System.out.println(
+            "invalid " + what + ": " + v + ", expected: " + ref); }
+        return ok;
+    }
+
+    private static boolean checkInfo(BeanInfo i, boolean ignoreValsCheck) {
+
+        System.out.println("checking info...");
+
+        PropertyDescriptor descriptors[] = i.getPropertyDescriptors();
+        int nd = descriptors.length;
+        if (nd != 1) {
+            System.out.println("invalid number of descriptors: " + nd);
+            return false;
+        }
+
+        PropertyDescriptor d = descriptors[0];
+
+        String descr = d.getShortDescription();
+        boolean ok = descr.equals(DESCRIPTION);
+        if (!ok) { System.out.println("invalid description: " + descr +
+                ", expected: " + DESCRIPTION); }
+
+        ok &= check("isBound",  d.isBound(),  BOUND);
+        ok &= check("isExpert", d.isExpert(), EXPERT);
+        ok &= check("isHidden", d.isHidden(), HIDDEN);
+        ok &= check("isPreferred", d.isPreferred(), PREFERRED);
+        ok &= check("required", (boolean) d.getValue("required"), REQUIRED);
+        ok &= check("visualUpdate",
+            (boolean) d.getValue("visualUpdate"), UPDATE);
+
+        if (ignoreValsCheck) { return ok; }
+
+        Object vals[] = (Object[]) d.getValue("enumerationValues");
+        if (vals == null) {
+            System.out.println("null enumerationValues");
+            return false;
+        }
+
+        boolean okVals = (
+            (vals.length == 3) &&
+             vals[0].toString().equals(V_SHORT) &&
+             vals[1].toString().equals(V)       &&
+             vals[2].toString().equals(V_NAME));
+
+        if (!okVals) { System.out.println("invalid enumerationValues"); }
+
+        return (ok && okVals);
+    }
+
+    private static boolean checkDefault(BeanInfo i) {
+
+        System.out.println("checking default info...");
+
+        PropertyDescriptor descriptors[] = i.getPropertyDescriptors();
+        int nd = descriptors.length;
+        if (nd != 1) {
+            System.out.println("invalid number of descriptors: " + nd);
+            return false;
+        }
+
+        PropertyDescriptor d = descriptors[0];
+
+        String descr = d.getShortDescription();
+        boolean ok = descr.equals("x");
+        if (!ok) { System.out.println("invalid description: " + descr +
+                ", expected: x"); }
+
+        ok &= check("isBound",  d.isBound(),  false);
+        ok &= check("isExpert", d.isExpert(), false);
+        ok &= check("isHidden", d.isHidden(), false);
+        ok &= check("isPreferred", d.isPreferred(), false);
+        ok &= check("required", (boolean) d.getValue("required"), false);
+        ok &= check("visualUpdate",
+            (boolean) d.getValue("visualUpdate"), false);
+
+        Object vals[] = (Object[]) d.getValue("enumerationValues");
+        if (vals != null && vals.length > 0) {
+            System.out.println("non-empty enumerationValues");
+            ok = false;
+        }
+
+        return ok;
+    }
+
+    // do not check enumerationValues for these classes
+    private static boolean ignoreVals(Class<?> c) {
+        return (
+            c.equals(BoolGetIs.class)            ||
+            c.equals(BoolIsGet.class)            ||
+            c.equals(AnnotatedIs.class)          ||
+            c.equals(OverrideAnnotatedIs2.class) ||
+            c.equals(AnnotatedIs2Ext.class)      ||
+            c.equals(OverrideAbstractIs.class)   ||
+            c.equals(OverrideAbstractIs2.class)  ||
+            c.equals(AbstractIsExt.class)        ||
+            c.equals(OverrideAbstractIs.class)   ||
+            c.equals(IIsImpl.class)              ||
+            c.equals(IIsImpl2.class)             ||
+            c.equals(IIsImpl3.class)
+        );
+    }
+
+    // default property descriptor data are expected for these classes
+    private static boolean isDefault(Class<?> c) {
+        return (
+            c.equals(OverrideAnnotatedGet.class) ||
+            c.equals(OverrideAnnotatedIs.class ) ||
+            c.equals(OverrideAnnotatedSet.class) ||
+            c.equals(OverrideAbstractGet.class)  ||
+            c.equals(OverrideAbstractIs.class)   ||
+            c.equals(OverrideAbstractSet.class)  ||
+            c.equals(IGetImpl.class)             ||
+            c.equals(IIsImpl.class)              ||
+            c.equals(ISetImpl.class)             ||
+            c.equals(BaseGet.class)              ||
+            c.equals(BaseSet.class)              ||
+            c.equals(HideStaticGet.class)
+        );
+    }
+
+
+    // ---------- run test ----------
+
+    public static void main(String[] args) throws Exception {
+
+        Class<?>
+            ic1 = ISet2Impl.class.getInterfaces()[0],
+            ic2 = IGet2Impl.class.getInterfaces()[0];
+
+        Class<?> cases[] = {
+
+            OverloadGet.class,
+            OverloadGet.class.getSuperclass(),
+            OverloadSet.class,
+            OverloadSet.class.getSuperclass(),
+            OverloadIGet.class,
+            OverloadISet.class,
+
+            // TODO: uncomment/update after 8132565 fix
+            //BoolGetIs.class,
+            //BoolIsGet.class,
+            //OverrideAnnotatedGet.class,
+            //OverrideAnnotatedIs.class,
+            //OverrideAnnotatedSet.class,
+            //OverrideAnnotatedGet2.class,
+            //AnnotatedGet2Ext.class,
+            //OverrideAnnotatedIs2.class
+            //AnnotatedIs2Ext.class,
+            //OverrideAnnotatedSet2.class,
+            //AnnotatedSet2Ext.class,
+
+            OverrideAnnotatedGet.class.getSuperclass(),
+            OverrideAnnotatedIs.class.getSuperclass(),
+            OverrideAnnotatedSet.class.getSuperclass(),
+
+            // TODO: uncomment/update after 8132565 fix
+            //OverrideAbstractGet.class,
+            //OverrideAbstractGet2.class,
+            //AbstractGetExt.class,
+            //OverrideAbstractIs.class,
+            //OverrideAbstractIs2.class,
+            //AbstractIsExt.class
+            //OverrideAbstractSet.class,
+            //OverrideAbstractSet2.class,
+            //AbstractSetExt.class,
+
+            AbstractGet2Ext.class.getSuperclass(),
+            IGetImpl.class,
+            IGetImpl2.class,
+            IGetImpl3.class,
+            IIsImpl.class,
+            IIsImpl2.class,
+            IIsImpl3.class,
+            ISetImpl.class,
+            ISetImpl2.class,
+            ISetImpl3.class,
+            ic1,
+            // ic2,  // TODO: uncomment/update after 8155013 fix
+            OverrideProtectedGet.class,
+            HideStaticGet.class
+        };
+
+        boolean passed = true;
+
+        for (Class<?> c: cases) {
+
+            java.lang.reflect.Field f = c.getDeclaredField("TESTCASE");
+            f.setAccessible(true);
+            String descr = f.get(c).toString();
+
+            System.out.println("\n" + c.getSimpleName() + " (" + descr + "):");
+            BeanInfo i;
+            try {
+                i = Introspector.getBeanInfo(c,
+                    (c.equals(ic1) || c.equals(ic2)) ? null : Object.class);
+            }
+            catch (IntrospectionException e) { throw new RuntimeException(e); }
+
+            boolean ok;
+
+            if (isDefault(c)) {
+                ok = checkDefault(i);
+            } else {
+                ok = checkInfo(i, ignoreVals(c));
+            }
+            System.out.println(ok ? "OK" : "NOK");
+            passed = passed && ok;
+        }
+
+        if (!passed) { throw new RuntimeException("test failed"); }
+        System.out.println("\ntest passed");
+    }
+}
--- a/jdk/test/java/beans/XMLEncoder/Test4625418.java	Thu May 19 17:48:02 2016 +0000
+++ b/jdk/test/java/beans/XMLEncoder/Test4625418.java	Thu May 19 19:46:20 2016 +0000
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2006, 2007, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2006, 2016, 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
@@ -26,332 +26,338 @@
  * @bug 4625418
  * @summary Tests XML <a href="http://download.java.net/jdk6/docs/technotes/guides/intl/encoding.doc.html">encoding</a>
  * @author Sergey Malenkov
- *
- * @run main Test4625418 ASCII
- * @run main Test4625418 Big5
- * ?run main Test4625418 Big5-HKSCS
- * ?run main Test4625418 Big5_HKSCS
- * @run main Test4625418 Big5_Solaris
- * ?run main Test4625418 Cp037
- * @run main Test4625418 Cp1006
- * ?run main Test4625418 Cp1025
- * -run main Test4625418 Cp1026
- * @run main Test4625418 Cp1046
- * @run main Test4625418 Cp1047
- * @run main Test4625418 Cp1097
- * @run main Test4625418 Cp1098
- * ?run main Test4625418 Cp1112
- * ?run main Test4625418 Cp1122
- * ?run main Test4625418 Cp1123
- * @run main Test4625418 Cp1124
- * ?run main Test4625418 Cp1140
- * ?run main Test4625418 Cp1141
- * ?run main Test4625418 Cp1142
- * ?run main Test4625418 Cp1143
- * ?run main Test4625418 Cp1144
- * ?run main Test4625418 Cp1145
- * ?run main Test4625418 Cp1146
- * ?run main Test4625418 Cp1147
- * ?run main Test4625418 Cp1148
- * ?run main Test4625418 Cp1149
- * @run main Test4625418 Cp1250
- * @run main Test4625418 Cp1251
- * @run main Test4625418 Cp1252
- * @run main Test4625418 Cp1253
- * @run main Test4625418 Cp1254
- * @run main Test4625418 Cp1255
- * @run main Test4625418 Cp1256
- * @run main Test4625418 Cp1257
- * @run main Test4625418 Cp1258
- * ?run main Test4625418 Cp1381
- * ?run main Test4625418 Cp1383
- * ?run main Test4625418 Cp273
- * ?run main Test4625418 Cp277
- * ?run main Test4625418 Cp278
- * ?run main Test4625418 Cp280
- * ?run main Test4625418 Cp284
- * ?run main Test4625418 Cp285
- * ?run main Test4625418 Cp297
- * ?run main Test4625418 Cp33722
- * ?run main Test4625418 Cp420
- * ?run main Test4625418 Cp424
- * @run main Test4625418 Cp437
- * ?run main Test4625418 Cp500
- * ?run main Test4625418 Cp50220
- * ?run main Test4625418 Cp50221
- * @run main Test4625418 Cp737
- * @run main Test4625418 Cp775
- * -run main Test4625418 Cp834
- * ?run main Test4625418 Cp838
- * @run main Test4625418 Cp850
- * @run main Test4625418 Cp852
- * @run main Test4625418 Cp855
- * @run main Test4625418 Cp856
- * @run main Test4625418 Cp857
- * @run main Test4625418 Cp858
- * @run main Test4625418 Cp860
- * @run main Test4625418 Cp861
- * @run main Test4625418 Cp862
- * @run main Test4625418 Cp863
- * @run main Test4625418 Cp864
- * @run main Test4625418 Cp865
- * @run main Test4625418 Cp866
- * @run main Test4625418 Cp868
- * @run main Test4625418 Cp869
- * ?run main Test4625418 Cp870
- * ?run main Test4625418 Cp871
- * @run main Test4625418 Cp874
- * ?run main Test4625418 Cp875
- * ?run main Test4625418 Cp918
- * @run main Test4625418 Cp921
- * @run main Test4625418 Cp922
- * -run main Test4625418 Cp930
- * @run main Test4625418 Cp933
- * ?run main Test4625418 Cp935
- * ?run main Test4625418 Cp937
- * ?run main Test4625418 Cp939
- * ?run main Test4625418 Cp942
- * ?run main Test4625418 Cp942C
- * @run main Test4625418 Cp943
- * ?run main Test4625418 Cp943C
- * @run main Test4625418 Cp948
- * @run main Test4625418 Cp949
- * ?run main Test4625418 Cp949C
- * @run main Test4625418 Cp950
- * @run main Test4625418 Cp964
- * ?run main Test4625418 Cp970
- * ?run main Test4625418 EUC-JP
- * @run main Test4625418 EUC-KR
- * @run main Test4625418 EUC_CN
- * ?run main Test4625418 EUC_JP
- * ?run main Test4625418 EUC_JP_LINUX
- * ?run main Test4625418 EUC_JP_Solaris
- * @run main Test4625418 EUC_KR
- * ?run main Test4625418 EUC_TW
- * @run main Test4625418 GB18030
- * @run main Test4625418 GB2312
- * @run main Test4625418 GBK
- * ?run main Test4625418 IBM-Thai
- * @run main Test4625418 IBM00858
- * ?run main Test4625418 IBM01140
- * ?run main Test4625418 IBM01141
- * ?run main Test4625418 IBM01142
- * ?run main Test4625418 IBM01143
- * ?run main Test4625418 IBM01144
- * ?run main Test4625418 IBM01145
- * ?run main Test4625418 IBM01146
- * ?run main Test4625418 IBM01147
- * ?run main Test4625418 IBM01148
- * ?run main Test4625418 IBM01149
- * ?run main Test4625418 IBM037
- * -run main Test4625418 IBM1026
- * @run main Test4625418 IBM1047
- * ?run main Test4625418 IBM273
- * ?run main Test4625418 IBM277
- * ?run main Test4625418 IBM278
- * ?run main Test4625418 IBM280
- * ?run main Test4625418 IBM284
- * ?run main Test4625418 IBM285
- * ?run main Test4625418 IBM297
- * ?run main Test4625418 IBM420
- * ?run main Test4625418 IBM424
- * @run main Test4625418 IBM437
- * ?run main Test4625418 IBM500
- * @run main Test4625418 IBM775
- * @run main Test4625418 IBM850
- * @run main Test4625418 IBM852
- * @run main Test4625418 IBM855
- * @run main Test4625418 IBM857
- * @run main Test4625418 IBM860
- * @run main Test4625418 IBM861
- * @run main Test4625418 IBM862
- * @run main Test4625418 IBM863
- * @run main Test4625418 IBM864
- * @run main Test4625418 IBM865
- * @run main Test4625418 IBM866
- * @run main Test4625418 IBM868
- * @run main Test4625418 IBM869
- * ?run main Test4625418 IBM870
- * ?run main Test4625418 IBM871
- * ?run main Test4625418 IBM918
- * ?run main Test4625418 ISCII91
- * -run main Test4625418 ISO-2022-CN
- * @run main Test4625418 ISO-2022-JP
- * @run main Test4625418 ISO-2022-KR
- * @run main Test4625418 ISO-8859-1
- * @run main Test4625418 ISO-8859-13
- * @run main Test4625418 ISO-8859-15
- * @run main Test4625418 ISO-8859-2
- * @run main Test4625418 ISO-8859-3
- * @run main Test4625418 ISO-8859-4
- * @run main Test4625418 ISO-8859-5
- * @run main Test4625418 ISO-8859-6
- * @run main Test4625418 ISO-8859-7
- * @run main Test4625418 ISO-8859-8
- * @run main Test4625418 ISO-8859-9
- * -run main Test4625418 ISO2022CN
- * @run main Test4625418 ISO2022JP
- * @run main Test4625418 ISO2022KR
- * -run main Test4625418 ISO2022_CN_CNS
- * -run main Test4625418 ISO2022_CN_GB
- * @run main Test4625418 ISO8859_1
- * @run main Test4625418 ISO8859_13
- * @run main Test4625418 ISO8859_15
- * @run main Test4625418 ISO8859_2
- * @run main Test4625418 ISO8859_3
- * @run main Test4625418 ISO8859_4
- * @run main Test4625418 ISO8859_5
- * @run main Test4625418 ISO8859_6
- * @run main Test4625418 ISO8859_7
- * @run main Test4625418 ISO8859_8
- * @run main Test4625418 ISO8859_9
- * -run main Test4625418 JISAutoDetect
- * ?run main Test4625418 JIS_X0201
- * -run main Test4625418 JIS_X0212-1990
- * @run main Test4625418 KOI8-R
- * @run main Test4625418 KOI8-U
- * @run main Test4625418 KOI8_R
- * @run main Test4625418 KOI8_U
- * @run main Test4625418 MS874
- * ?run main Test4625418 MS932
- * ?run main Test4625418 MS936
- * @run main Test4625418 MS949
- * @run main Test4625418 MS950
- * ?run main Test4625418 MS950_HKSCS
- * @run main Test4625418 MacArabic
- * @run main Test4625418 MacCentralEurope
- * @run main Test4625418 MacCroatian
- * @run main Test4625418 MacCyrillic
- * -run main Test4625418 MacDingbat
- * @run main Test4625418 MacGreek
- * @run main Test4625418 MacHebrew
- * @run main Test4625418 MacIceland
- * @run main Test4625418 MacRoman
- * @run main Test4625418 MacRomania
- * -run main Test4625418 MacSymbol
- * @run main Test4625418 MacThai
- * @run main Test4625418 MacTurkish
- * @run main Test4625418 MacUkraine
- * ?run main Test4625418 PCK
- * ?run main Test4625418 SJIS
- * ?run main Test4625418 Shift_JIS
- * @run main Test4625418 TIS-620
- * @run main Test4625418 TIS620
- * @run main Test4625418 US-ASCII
- * @run main Test4625418 UTF-16
- * @run main Test4625418 UTF-16BE
- * @run main Test4625418 UTF-16LE
- * @run main Test4625418 UTF-32
- * @run main Test4625418 UTF-32BE
- * @run main Test4625418 UTF-32LE
- * @run main Test4625418 UTF-8
- * @run main Test4625418 UTF8
- * @run main Test4625418 UTF_32
- * @run main Test4625418 UTF_32BE
- * -run main Test4625418 UTF_32BE_BOM
- * @run main Test4625418 UTF_32LE
- * -run main Test4625418 UTF_32LE_BOM
- * @run main Test4625418 UnicodeBig
- * @run main Test4625418 UnicodeBigUnmarked
- * @run main Test4625418 UnicodeLittle
- * @run main Test4625418 UnicodeLittleUnmarked
- * @run main Test4625418 windows-1250
- * @run main Test4625418 windows-1251
- * @run main Test4625418 windows-1252
- * @run main Test4625418 windows-1253
- * @run main Test4625418 windows-1254
- * @run main Test4625418 windows-1255
- * @run main Test4625418 windows-1256
- * @run main Test4625418 windows-1257
- * @run main Test4625418 windows-1258
- * ?run main Test4625418 windows-31j
- * -run main Test4625418 x-Big5_Solaris
- * ?run main Test4625418 x-EUC-TW
- * @run main Test4625418 x-IBM1006
- * ?run main Test4625418 x-IBM1025
- * @run main Test4625418 x-IBM1046
- * @run main Test4625418 x-IBM1097
- * @run main Test4625418 x-IBM1098
- * ?run main Test4625418 x-IBM1112
- * ?run main Test4625418 x-IBM1122
- * ?run main Test4625418 x-IBM1123
- * @run main Test4625418 x-IBM1124
- * ?run main Test4625418 x-IBM1381
- * ?run main Test4625418 x-IBM1383
- * ?run main Test4625418 x-IBM33722
- * @run main Test4625418 x-IBM737
- * -run main Test4625418 x-IBM834
- * @run main Test4625418 x-IBM856
- * @run main Test4625418 x-IBM874
- * ?run main Test4625418 x-IBM875
- * @run main Test4625418 x-IBM921
- * @run main Test4625418 x-IBM922
- * -run main Test4625418 x-IBM930
- * @run main Test4625418 x-IBM933
- * ?run main Test4625418 x-IBM935
- * ?run main Test4625418 x-IBM937
- * ?run main Test4625418 x-IBM939
- * ?run main Test4625418 x-IBM942
- * ?run main Test4625418 x-IBM942C
- * @run main Test4625418 x-IBM943
- * ?run main Test4625418 x-IBM943C
- * @run main Test4625418 x-IBM948
- * @run main Test4625418 x-IBM949
- * ?run main Test4625418 x-IBM949C
- * @run main Test4625418 x-IBM950
- * @run main Test4625418 x-IBM964
- * ?run main Test4625418 x-IBM970
- * ?run main Test4625418 x-ISCII91
- * -run main Test4625418 x-ISO2022-CN-CNS
- * -run main Test4625418 x-ISO2022-CN-GB
- * -run main Test4625418 x-JIS0208
- * -run main Test4625418 x-JISAutoDetect
- * @run main Test4625418 x-Johab
- * ?run main Test4625418 x-MS950-HKSCS
- * @run main Test4625418 x-MacArabic
- * @run main Test4625418 x-MacCentralEurope
- * @run main Test4625418 x-MacCroatian
- * @run main Test4625418 x-MacCyrillic
- * -run main Test4625418 x-MacDingbat
- * @run main Test4625418 x-MacGreek
- * @run main Test4625418 x-MacHebrew
- * @run main Test4625418 x-MacIceland
- * @run main Test4625418 x-MacRoman
- * @run main Test4625418 x-MacRomania
- * -run main Test4625418 x-MacSymbol
- * @run main Test4625418 x-MacThai
- * @run main Test4625418 x-MacTurkish
- * @run main Test4625418 x-MacUkraine
- * ?run main Test4625418 x-PCK
- * @run main Test4625418 x-UTF-16LE-BOM
- * -run main Test4625418 x-UTF-32BE-BOM
- * -run main Test4625418 x-UTF-32LE-BOM
- * ?run main Test4625418 x-euc-jp-linux
- * ?run main Test4625418 x-eucJP-Open
- * @run main Test4625418 x-iso-8859-11
- * @run main Test4625418 x-mswin-936
- * ?run main Test4625418 x-windows-50220
- * ?run main Test4625418 x-windows-50221
- * @run main Test4625418 x-windows-874
- * @run main Test4625418 x-windows-949
- * @run main Test4625418 x-windows-950
- * ?run main Test4625418 x-windows-iso2022jp
+ * @run main/timeout=360 Test4625418
  */
 
 import java.beans.ExceptionListener;
 import java.beans.XMLDecoder;
 import java.beans.XMLEncoder;
-import java.io.File;
-import java.io.FileInputStream;
-import java.io.FileNotFoundException;
-import java.io.FileOutputStream;
+import java.io.ByteArrayInputStream;
+import java.io.ByteArrayOutputStream;
+import java.io.InputStream;
 import java.nio.charset.IllegalCharsetNameException;
 import java.nio.charset.UnsupportedCharsetException;
 
 public final class Test4625418 implements ExceptionListener {
-    public static void main(String[] args) {
-        new Test4625418(args[0]).test(createString(0x10000));
-        System.out.println("Test passed: " + args[0]);
+
+    private static final String[] encodings = {
+        "ASCII",
+        "Big5",
+        //"Big5-HKSCS",
+        //"Big5_HKSCS",
+        "Big5_Solaris",
+        //"Cp037",
+        "Cp1006",
+        //"Cp1025",
+        //"Cp1026",
+        "Cp1046",
+        "Cp1047",
+        "Cp1097",
+        "Cp1098",
+        //"Cp1112",
+        //"Cp1122",
+        //"Cp1123",
+        "Cp1124",
+        //"Cp1140",
+        //"Cp1141",
+        //"Cp1142",
+        //"Cp1143",
+        //"Cp1144",
+        //"Cp1145",
+        //"Cp1146",
+        //"Cp1147",
+        //"Cp1148",
+        //"Cp1149",
+        "Cp1250",
+        "Cp1251",
+        "Cp1252",
+        "Cp1253",
+        "Cp1254",
+        "Cp1255",
+        "Cp1256",
+        "Cp1257",
+        "Cp1258",
+        //"Cp1381",
+        //"Cp1383",
+        //"Cp273",
+        //"Cp277",
+        //"Cp278",
+        //"Cp280",
+        //"Cp284",
+        //"Cp285",
+        //"Cp297",
+        //"Cp33722",
+        //"Cp420",
+        //"Cp424",
+        "Cp437",
+        //"Cp500",
+        //"Cp50220",
+        //"Cp50221",
+        "Cp737",
+        "Cp775",
+        //"Cp834",
+        //"Cp838",
+        "Cp850",
+        "Cp852",
+        "Cp855",
+        "Cp856",
+        "Cp857",
+        "Cp858",
+        "Cp860",
+        "Cp861",
+        "Cp862",
+        "Cp863",
+        "Cp864",
+        "Cp865",
+        "Cp866",
+        "Cp868",
+        "Cp869",
+        //"Cp870",
+        //"Cp871",
+        "Cp874",
+        //"Cp875",
+        //"Cp918",
+        "Cp921",
+        "Cp922",
+        //"Cp930",
+        "Cp933",
+        //"Cp935",
+        //"Cp937",
+        //"Cp939",
+        //"Cp942",
+        //"Cp942C",
+        "Cp943",
+        //"Cp943C",
+        "Cp948",
+        "Cp949",
+        //"Cp949C",
+        "Cp950",
+        "Cp964",
+        //"Cp970",
+        //"EUC-JP",
+        "EUC-KR",
+        "EUC_CN",
+        //"EUC_JP",
+        //"EUC_JP_LINUX",
+        //"EUC_JP_Solaris",
+        "EUC_KR",
+        //"EUC_TW",
+        "GB18030",
+        "GB2312",
+        "GBK",
+        //"IBM-Thai",
+        "IBM00858",
+        //"IBM01140",
+        //"IBM01141",
+        //"IBM01142",
+        //"IBM01143",
+        //"IBM01144",
+        //"IBM01145",
+        //"IBM01146",
+        //"IBM01147",
+        //"IBM01148",
+        //"IBM01149",
+        //"IBM037",
+        //"IBM1026",
+        "IBM1047",
+        //"IBM273",
+        //"IBM277",
+        //"IBM278",
+        //"IBM280",
+        //"IBM284",
+        //"IBM285",
+        //"IBM297",
+        //"IBM420",
+        //"IBM424",
+        "IBM437",
+        //"IBM500",
+        "IBM775",
+        "IBM850",
+        "IBM852",
+        "IBM855",
+        "IBM857",
+        "IBM860",
+        "IBM861",
+        "IBM862",
+        "IBM863",
+        "IBM864",
+        "IBM865",
+        "IBM866",
+        "IBM868",
+        "IBM869",
+        //"IBM870",
+        //"IBM871",
+        //"IBM918",
+        //"ISCII91",
+        //"ISO-2022-CN",
+        "ISO-2022-JP",
+        "ISO-2022-KR",
+        "ISO-8859-1",
+        "ISO-8859-13",
+        "ISO-8859-15",
+        "ISO-8859-2",
+        "ISO-8859-3",
+        "ISO-8859-4",
+        "ISO-8859-5",
+        "ISO-8859-6",
+        "ISO-8859-7",
+        "ISO-8859-8",
+        "ISO-8859-9",
+        //"ISO2022CN",
+        "ISO2022JP",
+        "ISO2022KR",
+        //"ISO2022_CN_CNS",
+        //"ISO2022_CN_GB",
+        "ISO8859_1",
+        "ISO8859_13",
+        "ISO8859_15",
+        "ISO8859_2",
+        "ISO8859_3",
+        "ISO8859_4",
+        "ISO8859_5",
+        "ISO8859_6",
+        "ISO8859_7",
+        "ISO8859_8",
+        "ISO8859_9",
+        //"JISAutoDetect",
+        //"JIS_X0201",
+        //"JIS_X0212-1990",
+        "KOI8-R",
+        "KOI8-U",
+        "KOI8_R",
+        "KOI8_U",
+        "MS874",
+        //"MS932",
+        //"MS936",
+        "MS949",
+        "MS950",
+        //"MS950_HKSCS",
+        "MacArabic",
+        "MacCentralEurope",
+        "MacCroatian",
+        "MacCyrillic",
+        //"MacDingbat",
+        "MacGreek",
+        "MacHebrew",
+        "MacIceland",
+        "MacRoman",
+        "MacRomania",
+        //"MacSymbol",
+        "MacThai",
+        "MacTurkish",
+        "MacUkraine",
+        //"PCK",
+        //"SJIS",
+        //"Shift_JIS",
+        "TIS-620",
+        "TIS620",
+        "US-ASCII",
+        "UTF-16",
+        "UTF-16BE",
+        "UTF-16LE",
+        "UTF-32",
+        "UTF-32BE",
+        "UTF-32LE",
+        "UTF-8",
+        "UTF8",
+        "UTF_32",
+        "UTF_32BE",
+        //"UTF_32BE_BOM",
+        "UTF_32LE",
+        //"UTF_32LE_BOM",
+        "UnicodeBig",
+        "UnicodeBigUnmarked",
+        "UnicodeLittle",
+        "UnicodeLittleUnmarked",
+        "windows-1250",
+        "windows-1251",
+        "windows-1252",
+        "windows-1253",
+        "windows-1254",
+        "windows-1255",
+        "windows-1256",
+        "windows-1257",
+        "windows-1258",
+        //"windows-31j",
+        //"x-Big5_Solaris",
+        //"x-EUC-TW",
+        "x-IBM1006",
+        //"x-IBM1025",
+        "x-IBM1046",
+        "x-IBM1097",
+        "x-IBM1098",
+        //"x-IBM1112",
+        //"x-IBM1122",
+        //"x-IBM1123",
+        "x-IBM1124",
+        //"x-IBM1381",
+        //"x-IBM1383",
+        //"x-IBM33722",
+        "x-IBM737",
+        //"x-IBM834",
+        "x-IBM856",
+        "x-IBM874",
+        //"x-IBM875",
+        "x-IBM921",
+        "x-IBM922",
+        //"x-IBM930",
+        "x-IBM933",
+        //"x-IBM935",
+        //"x-IBM937",
+        //"x-IBM939",
+        //"x-IBM942",
+        //"x-IBM942C",
+        "x-IBM943",
+        //"x-IBM943C",
+        "x-IBM948",
+        "x-IBM949",
+        //"x-IBM949C",
+        "x-IBM950",
+        "x-IBM964",
+        //"x-IBM970",
+        //"x-ISCII91",
+        //"x-ISO2022-CN-CNS",
+        //"x-ISO2022-CN-GB",
+        //"x-JIS0208",
+        //"x-JISAutoDetect",
+        "x-Johab",
+        //"x-MS950-HKSCS",
+        "x-MacArabic",
+        "x-MacCentralEurope",
+        "x-MacCroatian",
+        "x-MacCyrillic",
+        //"x-MacDingbat",
+        "x-MacGreek",
+        "x-MacHebrew",
+        "x-MacIceland",
+        "x-MacRoman",
+        "x-MacRomania",
+        //"x-MacSymbol",
+        "x-MacThai",
+        "x-MacTurkish",
+        "x-MacUkraine",
+        //"x-PCK",
+        "x-UTF-16LE-BOM",
+        //"x-UTF-32BE-BOM",
+        //"x-UTF-32LE-BOM",
+        //"x-euc-jp-linux",
+        //"x-eucJP-Open",
+        "x-iso-8859-11",
+        "x-mswin-936",
+        //"x-windows-50220",
+        //"x-windows-50221",
+        "x-windows-874",
+        "x-windows-949",
+        "x-windows-950",
+        //"x-windows-iso2022jp",
+    };
+
+    public static void main(final String[] args) {
+        final String string = createString(0x10000);
+        for (String encoding : encodings) {
+            System.out.println("Test encoding: " + encoding);
+            new Test4625418(encoding).test(string);
+        }
     }
 
     private static String createString(int length) {
@@ -364,33 +370,27 @@
 
     private final String encoding;
 
-    private Test4625418(String encoding) {
+    private Test4625418(final String encoding) {
         this.encoding = encoding;
     }
 
     private void test(String string) {
         try {
-            File file = new File("4625418." + this.encoding + ".xml");
-
-            FileOutputStream output = new FileOutputStream(file);
+            ByteArrayOutputStream output = new ByteArrayOutputStream();
             XMLEncoder encoder = new XMLEncoder(output, this.encoding, true, 0);
             encoder.setExceptionListener(this);
             encoder.writeObject(string);
             encoder.close();
 
-            FileInputStream input = new FileInputStream(file);
+            InputStream input = new ByteArrayInputStream(output.toByteArray());
             XMLDecoder decoder = new XMLDecoder(input);
             decoder.setExceptionListener(this);
             Object object = decoder.readObject();
             decoder.close();
 
-            if (!string.equals(object))
+            if (!string.equals(object)) {
                 throw new Error(this.encoding + " - can't read properly");
-
-            file.delete();
-        }
-        catch (FileNotFoundException exception) {
-            throw new Error(this.encoding + " - file not found", exception);
+            }
         }
         catch (IllegalCharsetNameException exception) {
             throw new Error(this.encoding + " - illegal charset name", exception);
--- a/jdk/test/java/lang/Class/getDeclaredField/FieldSetAccessibleTest.java	Thu May 19 17:48:02 2016 +0000
+++ b/jdk/test/java/lang/Class/getDeclaredField/FieldSetAccessibleTest.java	Thu May 19 19:46:20 2016 +0000
@@ -228,12 +228,18 @@
     }
 
     static boolean test(String s, boolean addExports) {
+        String clsName = s.replace('/', '.').substring(0, s.length() - 6);
         try {
+            System.out.println("Loading " + clsName);
             final Class<?> c = Class.forName(
-                    s.replace('/', '.').substring(0, s.length() - 6),
+                    clsName,
                     false,
                     systemClassLoader);
             return test(c, addExports);
+        } catch (VerifyError ve) {
+            System.err.println("VerifyError for " + clsName);
+            ve.printStackTrace(System.err);
+            failed.add(s);
         } catch (Exception t) {
             t.printStackTrace(System.err);
             failed.add(s);
--- a/jdk/test/java/lang/ClassLoader/deadlock/TestCrossDelegate.sh	Thu May 19 17:48:02 2016 +0000
+++ b/jdk/test/java/lang/ClassLoader/deadlock/TestCrossDelegate.sh	Thu May 19 19:46:20 2016 +0000
@@ -106,7 +106,7 @@
 # run test
 ${TESTJAVA}${FS}bin${FS}java \
         ${TESTVMOPTS} \
-        -verbose:class -Xlog:classload -cp . \
+        -verbose:class -Xlog:class+load -cp . \
         -Dtest.classes=${TESTCLASSES} \
         Starter cross
 # -XX:+UnlockDiagnosticVMOptions -XX:+UnsyncloadClass \
--- a/jdk/test/java/lang/ClassLoader/deadlock/TestOneWayDelegate.sh	Thu May 19 17:48:02 2016 +0000
+++ b/jdk/test/java/lang/ClassLoader/deadlock/TestOneWayDelegate.sh	Thu May 19 19:46:20 2016 +0000
@@ -102,7 +102,7 @@
 # run test
 ${TESTJAVA}${FS}bin${FS}java \
         ${TESTVMOPTS} \
-        -verbose:class -Xlog:classload -cp . \
+        -verbose:class -Xlog:class+load -cp . \
         -Dtest.classes=${TESTCLASSES} \
         Starter one-way
 # -XX:+UnlockDiagnosticVMOptions -XX:+UnsyncloadClass \
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/jdk/test/java/lang/StackWalker/CountLocalSlots.java	Thu May 19 19:46:20 2016 +0000
@@ -0,0 +1,61 @@
+/*
+ * Copyright (c) 2016 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 8147039
+ * @summary Confirm locals[] always has expected length, even for "dead" locals
+ * @compile LocalsAndOperands.java
+ * @run testng/othervm -Xcomp CountLocalSlots
+ */
+
+import org.testng.annotations.Test;
+import java.lang.StackWalker.StackFrame;
+
+public class CountLocalSlots {
+    final static boolean debug = true;
+
+    @Test(dataProvider = "provider", dataProviderClass = LocalsAndOperands.class)
+    public void countLocalSlots(StackFrame... frames) {
+        for (StackFrame frame : frames) {
+            if (debug) {
+                System.out.println("Running countLocalSlots");
+                LocalsAndOperands.dumpStackWithLocals(frames);
+            }
+            // Confirm expected number of locals
+            String methodName = frame.getMethodName();
+            Integer expectedObj = (Integer) LocalsAndOperands.Tester.NUM_LOCALS.get(methodName);
+            if (expectedObj == null) {
+                if (!debug) { LocalsAndOperands.dumpStackWithLocals(frames); }
+                throw new RuntimeException("No NUM_LOCALS entry for " +
+                        methodName + "().  Update test?");
+            }
+            Object[] locals = (Object[]) LocalsAndOperands.invokeGetLocals(frame);
+            if (locals.length != expectedObj) {
+                if (!debug) { LocalsAndOperands.dumpStackWithLocals(frames); }
+                throw new RuntimeException(methodName + "(): number of locals (" +
+                        locals.length + ") did not match expected (" + expectedObj + ")");
+            }
+        }
+    }
+}
--- a/jdk/test/java/lang/StackWalker/LocalsAndOperands.java	Thu May 19 17:48:02 2016 +0000
+++ b/jdk/test/java/lang/StackWalker/LocalsAndOperands.java	Thu May 19 19:46:20 2016 +0000
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2015, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2015, 2016 Oracle and/or its affiliates. All rights reserved.
  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
  *
  * This code is free software; you can redistribute it and/or modify it
@@ -23,17 +23,20 @@
 
 /*
  * @test
- * @bug 8020968
- * @summary Sanity test for locals and operands
- * @run main LocalsAndOperands
+ * @bug 8020968 8147039
+ * @summary Tests for locals and operands
+ * @run testng LocalsAndOperands
  */
 
+import org.testng.annotations.*;
 import java.lang.StackWalker.StackFrame;
 import java.lang.reflect.*;
-import java.util.List;
-import java.util.stream.Collectors;
+import java.util.*;
+import java.util.stream.*;
 
 public class LocalsAndOperands {
+    static final boolean debug = true;
+
     static Class<?> liveStackFrameClass;
     static Class<?> primitiveValueClass;
     static StackWalker extendedWalker;
@@ -41,92 +44,319 @@
     static Method getOperands;
     static Method getMonitors;
     static Method primitiveType;
-    public static void main(String... args) throws Exception {
-        liveStackFrameClass = Class.forName("java.lang.LiveStackFrame");
-        primitiveValueClass = Class.forName("java.lang.LiveStackFrame$PrimitiveValue");
+
+    static {
+        try {
+            liveStackFrameClass = Class.forName("java.lang.LiveStackFrame");
+            primitiveValueClass = Class.forName("java.lang.LiveStackFrame$PrimitiveValue");
+
+            getLocals = liveStackFrameClass.getDeclaredMethod("getLocals");
+            getLocals.setAccessible(true);
+
+            getOperands = liveStackFrameClass.getDeclaredMethod("getStack");
+            getOperands.setAccessible(true);
+
+            getMonitors = liveStackFrameClass.getDeclaredMethod("getMonitors");
+            getMonitors.setAccessible(true);
 
-        getLocals = liveStackFrameClass.getDeclaredMethod("getLocals");
-        getLocals.setAccessible(true);
+            primitiveType = primitiveValueClass.getDeclaredMethod("type");
+            primitiveType.setAccessible(true);
 
-        getOperands = liveStackFrameClass.getDeclaredMethod("getStack");
-        getOperands.setAccessible(true);
+            Method method = liveStackFrameClass.getMethod("getStackWalker");
+            method.setAccessible(true);
+            extendedWalker = (StackWalker) method.invoke(null);
+        } catch (Throwable t) { throw new RuntimeException(t); }
+    }
+
+    /** Helper method to return a StackFrame's locals */
+    static Object[] invokeGetLocals(StackFrame arg) {
+        try {
+            return (Object[]) getLocals.invoke(arg);
+        } catch (Exception e) { throw new RuntimeException(e); }
+    }
 
-        getMonitors = liveStackFrameClass.getDeclaredMethod("getMonitors");
-        getMonitors.setAccessible(true);
+    /*****************
+     * DataProviders *
+     *****************/
 
-        primitiveType = primitiveValueClass.getDeclaredMethod("type");
-        primitiveType.setAccessible(true);
+    /** Calls testLocals() and provides LiveStackFrames for testLocals* methods */
+    @DataProvider
+    public static StackFrame[][] provider() {
+        return new StackFrame[][] {
+            new Tester().testLocals()
+        };
+    }
 
-        Method method = liveStackFrameClass.getMethod("getStackWalker");
-        method.setAccessible(true);
-        extendedWalker = (StackWalker) method.invoke(null);
-        new LocalsAndOperands(extendedWalker, true).test();
+    /**
+     * Calls testLocalsKeepAlive() and provides LiveStackFrames for testLocals* methods.
+     * Local variables in testLocalsKeepAlive() are ensured to not become dead.
+     */
+    @DataProvider
+    public static StackFrame[][] keepAliveProvider() {
+        return new StackFrame[][] {
+            new Tester().testLocalsKeepAlive()
+        };
+    }
 
-        // no access to local and operands.
-        new LocalsAndOperands(StackWalker.getInstance(), false).test();
+    /**
+     * Provides StackFrames from a StackWalker without the LOCALS_AND_OPERANDS
+     * option.
+     */
+    @DataProvider
+    public static StackFrame[][] noLocalsProvider() {
+        // Use default StackWalker
+        return new StackFrame[][] {
+            new Tester(StackWalker.getInstance(), true).testLocals()
+        };
     }
 
-    private final StackWalker walker;
-    private final boolean extended;
-    LocalsAndOperands(StackWalker walker, boolean extended) {
-        this.walker = walker;
-        this.extended = extended;
+    /**
+     * Calls testLocals() and provides LiveStackFrames for *all* called methods,
+     * including test infrastructure (jtreg, testng, etc)
+     *
+     */
+    @DataProvider
+    public static StackFrame[][] unfilteredProvider() {
+        return new StackFrame[][] {
+            new Tester(extendedWalker, false).testLocals()
+        };
+    }
+
+    /****************
+     * Test methods *
+     ****************/
+
+    /**
+     * Check for expected local values and types in the LiveStackFrame
+     */
+    @Test(dataProvider = "keepAliveProvider")
+    public static void checkLocalValues(StackFrame... frames) {
+        if (debug) {
+            System.out.println("Running checkLocalValues");
+            dumpStackWithLocals(frames);
+        }
+        Arrays.stream(frames).filter(f -> f.getMethodName()
+                                           .equals("testLocalsKeepAlive"))
+                                           .forEach(
+            f -> {
+                Object[] locals = invokeGetLocals(f);
+                for (int i = 0; i < locals.length; i++) {
+                    // Value
+                    String expected = Tester.LOCAL_VALUES[i];
+                    Object observed = locals[i];
+                    if (expected != null /* skip nulls in golden values */ &&
+                            !expected.equals(observed.toString())) {
+                        System.err.println("Local value mismatch:");
+                        if (!debug) { dumpStackWithLocals(frames); }
+                        throw new RuntimeException("local " + i + " value is " +
+                                observed + ", expected " + expected);
+                    }
+
+                    // Type
+                    expected = Tester.LOCAL_TYPES[i];
+                    observed = type(locals[i]);
+                    if (expected != null /* skip nulls in golden values */ &&
+                            !expected.equals(observed)) {
+                        System.err.println("Local type mismatch:");
+                        if (!debug) { dumpStackWithLocals(frames); }
+                        throw new RuntimeException("local " + i + " type is " +
+                                observed + ", expected " + expected);
+                    }
+                }
+            }
+        );
+    }
+
+    /**
+     * Basic sanity check for locals and operands
+     */
+    @Test(dataProvider = "provider")
+    public static void sanityCheck(StackFrame... frames) {
+        if (debug) {
+            System.out.println("Running sanityCheck");
+        }
+        try {
+            Stream<StackFrame> stream = Arrays.stream(frames);
+            if (debug) {
+                stream.forEach(LocalsAndOperands::printLocals);
+            } else {
+                System.out.println(stream.count() + " frames");
+            }
+        } catch (Throwable t) {
+            dumpStackWithLocals(frames);
+            throw t;
+        }
     }
 
-    synchronized void test() throws Exception {
-        int x = 10;
-        char c = 'z';
-        String hi = "himom";
-        long l = 1000000L;
-        double d =  3.1415926;
-
-        List<StackWalker.StackFrame> frames = walker.walk(s -> s.collect(Collectors.toList()));
-        if (extended) {
-            for (StackWalker.StackFrame f : frames) {
-                System.out.println("frame: " + f);
-                Object[] locals = (Object[]) getLocals.invoke(f);
-                for (int i = 0; i < locals.length; i++) {
-                    System.out.format("  local %d: %s type %s\n", i, locals[i], type(locals[i]));
+    /**
+     * Sanity check for locals and operands, including testng/jtreg frames
+     */
+    @Test(dataProvider = "unfilteredProvider")
+    public static void unfilteredSanityCheck(StackFrame... frames) {
+        if (debug) {
+            System.out.println("Running unfilteredSanityCheck");
+        }
+        try {
+            Stream<StackFrame> stream = Arrays.stream(frames);
+            if (debug) {
+                stream.forEach(f -> { System.out.println(f + ": " +
+                        invokeGetLocals(f).length + " locals"); } );
+            } else {
+                System.out.println(stream.count() + " frames");
+            }
+        } catch (Throwable t) {
+            dumpStackWithLocals(frames);
+            throw t;
+        }
+    }
 
-                    // check for non-null locals in LocalsAndOperands.test()
-                    if (f.getClassName().equals("LocalsAndOperands") &&
-                            f.getMethodName().equals("test")) {
-                        if (locals[i] == null) {
-                            throw new RuntimeException("kept-alive locals should not be null");
-                        }
-                    }
-                }
+    /**
+     * Test that LiveStackFrames are not provided with the default StackWalker
+     * options.
+     */
+    @Test(dataProvider = "noLocalsProvider")
+    public static void withoutLocalsAndOperands(StackFrame... frames) {
+        for (StackFrame frame : frames) {
+            if (liveStackFrameClass.isInstance(frame)) {
+                throw new RuntimeException("should not be LiveStackFrame");
+            }
+        }
+    }
+
+    static class Tester {
+        private StackWalker walker;
+        private boolean filter = true; // Filter out testng/jtreg/etc frames?
+
+        Tester() {
+            this.walker = extendedWalker;
+        }
 
-                Object[] operands = (Object[]) getOperands.invoke(f);
-                for (int i = 0; i < operands.length; i++) {
-                    System.out.format("  operand %d: %s type %s%n", i, operands[i],
-                                      type(operands[i]));
-                }
+        Tester(StackWalker walker, boolean filter) {
+            this.walker = walker;
+            this.filter = filter;
+        }
 
-                Object[] monitors = (Object[]) getMonitors.invoke(f);
-                for (int i = 0; i < monitors.length; i++) {
-                    System.out.format("  monitor %d: %s%n", i, monitors[i]);
-                }
-            }
-        } else {
-            for (StackFrame f : frames) {
-                if (liveStackFrameClass.isInstance(f)) {
-                    throw new RuntimeException("should not be LiveStackFrame");
-                }
+        /**
+         * Perform stackwalk without keeping local variables alive and return an
+         * array of the collected StackFrames
+         */
+        private synchronized StackFrame[] testLocals() {
+            // Unused local variables will become dead
+            int x = 10;
+            char c = 'z';
+            String hi = "himom";
+            long l = 1000000L;
+            double d =  3.1415926;
+
+            if (filter) {
+                return walker.walk(s -> s.filter(f -> TEST_METHODS.contains(f
+                        .getMethodName())).collect(Collectors.toList()))
+                        .toArray(new StackFrame[0]);
+            } else {
+                return walker.walk(s -> s.collect(Collectors.toList()))
+                        .toArray(new StackFrame[0]);
             }
         }
-        // Use local variables so they stay alive
-        System.out.println("Stayin' alive: "+x+" "+c+" "+hi+" "+l+" "+d);
+
+        /**
+         * Perform stackwalk, keeping local variables alive, and return a list of
+         * the collected StackFrames
+         */
+        private synchronized StackFrame[] testLocalsKeepAlive() {
+            int x = 10;
+            char c = 'z';
+            String hi = "himom";
+            long l = 1000000L;
+            double d =  3.1415926;
+
+            List<StackWalker.StackFrame> frames;
+            if (filter) {
+                frames = walker.walk(s -> s.filter(f -> TEST_METHODS.contains(f
+                        .getMethodName())).collect(Collectors.toList()));
+            } else {
+                frames = walker.walk(s -> s.collect(Collectors.toList()));
+            }
+
+            // Use local variables so they stay alive
+            System.out.println("Stayin' alive: "+x+" "+c+" "+hi+" "+l+" "+d);
+            return frames.toArray(new StackFrame[0]); // FIXME: convert to Array here
+        }
+
+        // Expected values for locals in testLocals() & testLocalsKeepAlive()
+        // TODO: use real values instead of Strings, rebuild doubles & floats, etc
+        private final static String[] LOCAL_VALUES = new String[] {
+            null, // skip, LocalsAndOperands$Tester@XXX identity is different each run
+            "10",
+            "122",
+            "himom",
+            "0",
+            null, // skip, fix in 8156073
+            null, // skip, fix in 8156073
+            null, // skip, fix in 8156073
+            "0"
+        };
+
+        // Expected types for locals in testLocals() & testLocalsKeepAlive()
+        // TODO: use real types
+        private final static String[] LOCAL_TYPES = new String[] {
+            null, // skip
+            "I",
+            "I",
+            "java.lang.String",
+            "I",
+            "I",
+            "I",
+            "I",
+            "I"
+        };
+
+        final static Map NUM_LOCALS = Map.of("testLocals", 8,
+                                             "testLocalsKeepAlive",
+                                             LOCAL_VALUES.length);
+        private final static Collection<String> TEST_METHODS = NUM_LOCALS.keySet();
     }
 
-    String type(Object o) throws Exception {
-        if (o == null) {
-            return "null";
-        } else if (primitiveValueClass.isInstance(o)) {
-            char c = (char)primitiveType.invoke(o);
-            return String.valueOf(c);
-        } else {
-            return o.getClass().getName();
-        }
+    /**
+     * Print stack trace with locals
+     */
+    public static void dumpStackWithLocals(StackFrame...frames) {
+        Arrays.stream(frames).forEach(LocalsAndOperands::printLocals);
+    }
+
+    /**
+     * Print the StackFrame and an indexed list of its locals
+     */
+    public static void printLocals(StackWalker.StackFrame frame) {
+        try {
+            System.out.println(frame);
+            Object[] locals = (Object[]) getLocals.invoke(frame);
+            for (int i = 0; i < locals.length; i++) {
+                System.out.format("  local %d: %s type %s\n", i, locals[i], type(locals[i]));
+            }
+
+            Object[] operands = (Object[]) getOperands.invoke(frame);
+            for (int i = 0; i < operands.length; i++) {
+                System.out.format("  operand %d: %s type %s%n", i, operands[i],
+                                  type(operands[i]));
+            }
+
+            Object[] monitors = (Object[]) getMonitors.invoke(frame);
+            for (int i = 0; i < monitors.length; i++) {
+                System.out.format("  monitor %d: %s%n", i, monitors[i]);
+            }
+        } catch (Exception e) { throw new RuntimeException(e); }
+    }
+
+    private static String type(Object o) {
+        try {
+            if (o == null) {
+                return "null";
+            } else if (primitiveValueClass.isInstance(o)) {
+                char c = (char)primitiveType.invoke(o);
+                return String.valueOf(c);
+            } else {
+                return o.getClass().getName();
+            }
+        } catch(Exception e) { throw new RuntimeException(e); }
     }
 }
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/jdk/test/java/lang/StackWalker/LocalsCrash.java	Thu May 19 19:46:20 2016 +0000
@@ -0,0 +1,74 @@
+/*
+ * Copyright (c) 2016 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 8147039
+ * @summary Test for -Xcomp crash that happened before 8147039 fix
+ * @run testng/othervm -Xcomp LocalsCrash
+ */
+
+import org.testng.annotations.*;
+import java.lang.reflect.*;
+import java.util.List;
+import java.util.stream.Collectors;
+
+public class LocalsCrash {
+    static Class<?> liveStackFrameClass;
+    static Method getStackWalker;
+
+    static {
+        try {
+            liveStackFrameClass = Class.forName("java.lang.LiveStackFrame");
+            getStackWalker = liveStackFrameClass.getMethod("getStackWalker");
+            getStackWalker.setAccessible(true);
+        } catch (Throwable t) { throw new RuntimeException(t); }
+    }
+
+    private StackWalker walker;
+
+    LocalsCrash() {
+        try {
+            walker = (StackWalker) getStackWalker.invoke(null);
+        } catch (Exception e) { throw new RuntimeException(e); }
+    }
+
+    @Test
+    public void test00() { doStackWalk(); }
+
+    @Test
+    public void test01() { doStackWalk(); }
+
+    private synchronized List<StackWalker.StackFrame> doStackWalk() {
+        try {
+            // Unused local variables will become dead
+            int x = 10;
+            char c = 'z';
+            String hi = "himom";
+            long l = 1000000L;
+            double d =  3.1415926;
+
+            return walker.walk(s -> s.collect(Collectors.toList()));
+        } catch (Exception e) { throw new RuntimeException(e); }
+    }
+}
--- a/jdk/test/java/lang/instrument/appendToClassLoaderSearch/ClassUnloadTest.sh	Thu May 19 17:48:02 2016 +0000
+++ b/jdk/test/java/lang/instrument/appendToClassLoaderSearch/ClassUnloadTest.sh	Thu May 19 19:46:20 2016 +0000
@@ -80,5 +80,5 @@
 
 # Finally we run the test
 (cd "${TESTCLASSES}"; \
-  $JAVA ${TESTVMOPTS} -Xverify:none -Xlog:classunload \
+  $JAVA ${TESTVMOPTS} -Xverify:none -Xlog:class+unload \
     -javaagent:ClassUnloadTest.jar ClassUnloadTest "${OTHERDIR}" Bar.jar)
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/jdk/test/java/lang/invoke/ArrayLengthTest.java	Thu May 19 19:46:20 2016 +0000
@@ -0,0 +1,81 @@
+/*
+ * Copyright (c) 2016, 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.
+ */
+
+/* @test
+ * @run testng/othervm -ea -esa test.java.lang.invoke.ArrayLengthTest
+ */
+package test.java.lang.invoke;
+
+import java.lang.invoke.MethodHandle;
+import java.lang.invoke.MethodHandles;
+
+import static org.testng.AssertJUnit.*;
+
+import org.testng.annotations.*;
+
+public class ArrayLengthTest {
+
+    @DataProvider
+    Object[][] arrayClasses() {
+        return new Object[][] {
+                {int[].class},
+                {long[].class},
+                {float[].class},
+                {double[].class},
+                {boolean[].class},
+                {byte[].class},
+                {short[].class},
+                {char[].class},
+                {Object[].class},
+                {StringBuffer[].class}
+        };
+    }
+
+    @Test(dataProvider = "arrayClasses")
+    public void testArrayLength(Class<?> arrayClass) throws Throwable {
+        MethodHandle arrayLength = MethodHandles.arrayLength(arrayClass);
+        assertEquals(int.class, arrayLength.type().returnType());
+        assertEquals(arrayClass, arrayLength.type().parameterType(0));
+        Object array = MethodHandles.arrayConstructor(arrayClass).invoke(10);
+        assertEquals(10, arrayLength.invoke(array));
+    }
+
+    @Test(dataProvider = "arrayClasses", expectedExceptions = NullPointerException.class)
+    public void testArrayLengthInvokeNPE(Class<?> arrayClass) throws Throwable {
+        MethodHandle arrayLength = MethodHandles.arrayLength(arrayClass);
+        arrayLength.invoke(null);
+    }
+
+    @Test(expectedExceptions = IllegalArgumentException.class)
+    public void testArrayLengthNoArray() {
+        MethodHandles.arrayLength(String.class);
+    }
+
+    @Test(expectedExceptions = NullPointerException.class)
+    public void testArrayLengthNPE() {
+        MethodHandles.arrayLength(null);
+    }
+
+}
--- a/jdk/test/java/lang/invoke/VarHandles/VarHandleBaseTest.java	Thu May 19 17:48:02 2016 +0000
+++ b/jdk/test/java/lang/invoke/VarHandles/VarHandleBaseTest.java	Thu May 19 19:46:20 2016 +0000
@@ -40,6 +40,7 @@
 
 abstract class VarHandleBaseTest {
     static final int ITERS = Integer.getInteger("iters", 1);
+    static final int WEAK_ATTEMPTS = Integer.getInteger("weakAttempts", 10);
 
     interface ThrowingRunnable {
         void run() throws Throwable;
@@ -211,7 +212,6 @@
     }
 
     static MethodHandle findVirtual(VarHandle vh, TestAccessMode tam, MethodType mt) {
-        mt = vh.accessModeType(tam.toAccessMode());
         MethodHandle mh;
         try {
             mh = MethodHandles.publicLookup().
@@ -221,36 +221,26 @@
         } catch (Exception e) {
             throw new RuntimeException(e);
         }
-        return bind(vh, tam, mh, mt);
+        return bind(vh, mh, mt);
     }
 
-    static MethodHandle varHandleInvokerWithAccessModeType(VarHandle vh, TestAccessMode tam, MethodType mt) {
-        mt = vh.accessModeType(tam.toAccessMode());
+    static MethodHandle varHandleInvoker(VarHandle vh, TestAccessMode tam, MethodType mt) {
         MethodHandle mh = MethodHandles.varHandleInvoker(
                 tam.toAccessMode(),
                 mt);
 
-        return bind(vh, tam, mh, mt);
+        return bind(vh, mh, mt);
     }
 
-    static MethodHandle varHandleInvokerWithSymbolicTypeDescriptor(VarHandle vh, TestAccessMode tam, MethodType mt) {
-        MethodHandle mh = MethodHandles.varHandleInvoker(
-                tam.toAccessMode(),
-                mt);
-
-        return bind(vh, tam, mh, mt);
-    }
-
-    static MethodHandle varHandleExactInvokerWithAccessModeType(VarHandle vh, TestAccessMode tam, MethodType mt) {
-        mt = vh.accessModeType(tam.toAccessMode());
+    static MethodHandle varHandleExactInvoker(VarHandle vh, TestAccessMode tam, MethodType mt) {
         MethodHandle mh = MethodHandles.varHandleExactInvoker(
                 tam.toAccessMode(),
                 mt);
 
-        return bind(vh, tam, mh, mt);
+        return bind(vh, mh, mt);
     }
 
-    private static MethodHandle bind(VarHandle vh, TestAccessMode testAccessMode, MethodHandle mh, MethodType emt) {
+    private static MethodHandle bind(VarHandle vh, MethodHandle mh, MethodType emt) {
         assertEquals(mh.type(), emt.insertParameterTypes(0, VarHandle.class),
                      "MethodHandle type differs from access mode type");
 
@@ -268,33 +258,30 @@
     enum VarHandleToMethodHandle {
         VAR_HANDLE_TO_METHOD_HANDLE(
                 "VarHandle.toMethodHandle",
+                true,
                 VarHandleBaseTest::toMethodHandle),
         METHOD_HANDLES_LOOKUP_FIND_VIRTUAL(
                 "Lookup.findVirtual",
+                false,
                 VarHandleBaseTest::findVirtual),
-        METHOD_HANDLES_VAR_HANDLE_INVOKER_WITH_ACCESS_MODE_TYPE(
-                "MethodHandles.varHandleInvoker(accessModeType)",
-                VarHandleBaseTest::varHandleInvokerWithAccessModeType),
-        METHOD_HANDLES_VAR_HANDLE_INVOKER_WITH_SYMBOLIC_TYPE_DESCRIPTOR(
-                "MethodHandles.varHandleInvoker(symbolicTypeDescriptor)",
-                VarHandleBaseTest::varHandleInvokerWithSymbolicTypeDescriptor),
-        METHOD_HANDLES_VAR_HANDLE_EXACT_INVOKER_WITH_ACCESS_MODE_TYPE(
-                "MethodHandles.varHandleExactInvoker(accessModeType)",
-                VarHandleBaseTest::varHandleExactInvokerWithAccessModeType);
+        METHOD_HANDLES_VAR_HANDLE_INVOKER(
+                "MethodHandles.varHandleInvoker",
+                false,
+                VarHandleBaseTest::varHandleInvoker),
+        METHOD_HANDLES_VAR_HANDLE_EXACT_INVOKER(
+                "MethodHandles.varHandleExactInvoker",
+                true,
+                VarHandleBaseTest::varHandleExactInvoker);
 
         final String desc;
+        final boolean isExact;
         final TriFunction<VarHandle, TestAccessMode, MethodType, MethodHandle> f;
-        final boolean exact;
 
-        VarHandleToMethodHandle(String desc, TriFunction<VarHandle, TestAccessMode, MethodType, MethodHandle> f) {
-            this(desc, f, false);
-        }
-
-        VarHandleToMethodHandle(String desc, TriFunction<VarHandle, TestAccessMode, MethodType, MethodHandle> f,
-                                boolean exact) {
+        VarHandleToMethodHandle(String desc, boolean isExact,
+                                TriFunction<VarHandle, TestAccessMode, MethodType, MethodHandle> f) {
             this.desc = desc;
             this.f = f;
-            this.exact = exact;
+            this.isExact = isExact;
         }
 
         MethodHandle apply(VarHandle vh, TestAccessMode am, MethodType mt) {
@@ -363,6 +350,15 @@
             return amToHandle.computeIfAbsent(
                     amt, k -> f.apply(vh, am, mt));
         }
+
+        Class<? extends Throwable> getWMTEOOrOther(Class<? extends Throwable> c) {
+            return f.isExact ? WrongMethodTypeException.class : c;
+        }
+
+        void checkWMTEOrCCE(ThrowingRunnable r) {
+            checkWithThrowable(getWMTEOOrOther(ClassCastException.class), null, r);
+        }
+
     }
 
     interface AccessTestAction<T> {
@@ -475,4 +471,4 @@
             assertEquals(mt.parameterType(mt.parameterCount() - 1), vh.varType());
         }
     }
-}
\ No newline at end of file
+}
--- a/jdk/test/java/lang/invoke/VarHandles/VarHandleTestAccessBoolean.java	Thu May 19 17:48:02 2016 +0000
+++ b/jdk/test/java/lang/invoke/VarHandles/VarHandleTestAccessBoolean.java	Thu May 19 19:46:20 2016 +0000
@@ -293,6 +293,10 @@
         });
 
         checkUOE(() -> {
+            boolean r = (boolean) vh.getAndSet(recv, true);
+        });
+
+        checkUOE(() -> {
             boolean o = (boolean) vh.getAndAdd(recv, true);
         });
 
@@ -379,6 +383,10 @@
         });
 
         checkUOE(() -> {
+            boolean r = (boolean) vh.getAndSet(true);
+        });
+
+        checkUOE(() -> {
             boolean o = (boolean) vh.getAndAdd(true);
         });
 
@@ -455,6 +463,10 @@
         });
 
         checkUOE(() -> {
+            boolean r = (boolean) vh.getAndSet(recv, true);
+        });
+
+        checkUOE(() -> {
             boolean o = (boolean) vh.getAndAdd(recv, true);
         });
 
@@ -531,6 +543,10 @@
         });
 
         checkUOE(() -> {
+            boolean r = (boolean) vh.getAndSet(true);
+        });
+
+        checkUOE(() -> {
             boolean o = (boolean) vh.getAndAdd(true);
         });
 
@@ -614,6 +630,10 @@
         });
 
         checkUOE(() -> {
+            boolean r = (boolean) vh.getAndSet(array, i, true);
+        });
+
+        checkUOE(() -> {
             boolean o = (boolean) vh.getAndAdd(array, i, true);
         });
 
--- a/jdk/test/java/lang/invoke/VarHandles/VarHandleTestAccessByte.java	Thu May 19 17:48:02 2016 +0000
+++ b/jdk/test/java/lang/invoke/VarHandles/VarHandleTestAccessByte.java	Thu May 19 19:46:20 2016 +0000
@@ -293,6 +293,10 @@
         });
 
         checkUOE(() -> {
+            byte r = (byte) vh.getAndSet(recv, (byte)1);
+        });
+
+        checkUOE(() -> {
             byte o = (byte) vh.getAndAdd(recv, (byte)1);
         });
 
@@ -379,6 +383,10 @@
         });
 
         checkUOE(() -> {
+            byte r = (byte) vh.getAndSet((byte)1);
+        });
+
+        checkUOE(() -> {
             byte o = (byte) vh.getAndAdd((byte)1);
         });
 
@@ -455,6 +463,10 @@
         });
 
         checkUOE(() -> {
+            byte r = (byte) vh.getAndSet(recv, (byte)1);
+        });
+
+        checkUOE(() -> {
             byte o = (byte) vh.getAndAdd(recv, (byte)1);
         });
 
@@ -531,6 +543,10 @@
         });
 
         checkUOE(() -> {
+            byte r = (byte) vh.getAndSet((byte)1);
+        });
+
+        checkUOE(() -> {
             byte o = (byte) vh.getAndAdd((byte)1);
         });
 
@@ -614,6 +630,10 @@
         });
 
         checkUOE(() -> {
+            byte r = (byte) vh.getAndSet(array, i, (byte)1);
+        });
+
+        checkUOE(() -> {
             byte o = (byte) vh.getAndAdd(array, i, (byte)1);
         });
 
--- a/jdk/test/java/lang/invoke/VarHandles/VarHandleTestAccessChar.java	Thu May 19 17:48:02 2016 +0000
+++ b/jdk/test/java/lang/invoke/VarHandles/VarHandleTestAccessChar.java	Thu May 19 19:46:20 2016 +0000
@@ -293,6 +293,10 @@
         });
 
         checkUOE(() -> {
+            char r = (char) vh.getAndSet(recv, 'a');
+        });
+
+        checkUOE(() -> {
             char o = (char) vh.getAndAdd(recv, 'a');
         });
 
@@ -379,6 +383,10 @@
         });
 
         checkUOE(() -> {
+            char r = (char) vh.getAndSet('a');
+        });
+
+        checkUOE(() -> {
             char o = (char) vh.getAndAdd('a');
         });
 
@@ -455,6 +463,10 @@
         });
 
         checkUOE(() -> {
+            char r = (char) vh.getAndSet(recv, 'a');
+        });
+
+        checkUOE(() -> {
             char o = (char) vh.getAndAdd(recv, 'a');
         });
 
@@ -531,6 +543,10 @@
         });
 
         checkUOE(() -> {
+            char r = (char) vh.getAndSet('a');
+        });
+
+        checkUOE(() -> {
             char o = (char) vh.getAndAdd('a');
         });
 
@@ -614,6 +630,10 @@
         });
 
         checkUOE(() -> {
+            char r = (char) vh.getAndSet(array, i, 'a');
+        });
+
+        checkUOE(() -> {
             char o = (char) vh.getAndAdd(array, i, 'a');
         });
 
--- a/jdk/test/java/lang/invoke/VarHandles/VarHandleTestAccessDouble.java	Thu May 19 17:48:02 2016 +0000
+++ b/jdk/test/java/lang/invoke/VarHandles/VarHandleTestAccessDouble.java	Thu May 19 19:46:20 2016 +0000
@@ -293,6 +293,10 @@
         });
 
         checkUOE(() -> {
+            double r = (double) vh.getAndSet(recv, 1.0d);
+        });
+
+        checkUOE(() -> {
             double o = (double) vh.getAndAdd(recv, 1.0d);
         });
 
@@ -379,6 +383,10 @@
         });
 
         checkUOE(() -> {
+            double r = (double) vh.getAndSet(1.0d);
+        });
+
+        checkUOE(() -> {
             double o = (double) vh.getAndAdd(1.0d);
         });
 
@@ -455,6 +463,10 @@
         });
 
         checkUOE(() -> {
+            double r = (double) vh.getAndSet(recv, 1.0d);
+        });
+
+        checkUOE(() -> {
             double o = (double) vh.getAndAdd(recv, 1.0d);
         });
 
@@ -531,6 +543,10 @@
         });
 
         checkUOE(() -> {
+            double r = (double) vh.getAndSet(1.0d);
+        });
+
+        checkUOE(() -> {
             double o = (double) vh.getAndAdd(1.0d);
         });
 
@@ -614,6 +630,10 @@
         });
 
         checkUOE(() -> {
+            double r = (double) vh.getAndSet(array, i, 1.0d);
+        });
+
+        checkUOE(() -> {
             double o = (double) vh.getAndAdd(array, i, 1.0d);
         });
 
--- a/jdk/test/java/lang/invoke/VarHandles/VarHandleTestAccessFloat.java	Thu May 19 17:48:02 2016 +0000
+++ b/jdk/test/java/lang/invoke/VarHandles/VarHandleTestAccessFloat.java	Thu May 19 19:46:20 2016 +0000
@@ -293,6 +293,10 @@
         });
 
         checkUOE(() -> {
+            float r = (float) vh.getAndSet(recv, 1.0f);
+        });
+
+        checkUOE(() -> {
             float o = (float) vh.getAndAdd(recv, 1.0f);
         });
 
@@ -379,6 +383,10 @@
         });
 
         checkUOE(() -> {
+            float r = (float) vh.getAndSet(1.0f);
+        });
+
+        checkUOE(() -> {
             float o = (float) vh.getAndAdd(1.0f);
         });
 
@@ -455,6 +463,10 @@
         });
 
         checkUOE(() -> {
+            float r = (float) vh.getAndSet(recv, 1.0f);
+        });
+
+        checkUOE(() -> {
             float o = (float) vh.getAndAdd(recv, 1.0f);
         });
 
@@ -531,6 +543,10 @@
         });
 
         checkUOE(() -> {
+            float r = (float) vh.getAndSet(1.0f);
+        });
+
+        checkUOE(() -> {
             float o = (float) vh.getAndAdd(1.0f);
         });
 
@@ -614,6 +630,10 @@
         });
 
         checkUOE(() -> {
+            float r = (float) vh.getAndSet(array, i, 1.0f);
+        });
+
+        checkUOE(() -> {
             float o = (float) vh.getAndAdd(array, i, 1.0f);
         });
 
--- a/jdk/test/java/lang/invoke/VarHandles/VarHandleTestAccessInt.java	Thu May 19 17:48:02 2016 +0000
+++ b/jdk/test/java/lang/invoke/VarHandles/VarHandleTestAccessInt.java	Thu May 19 19:46:20 2016 +0000
@@ -402,29 +402,41 @@
         }
 
         {
-            boolean r = vh.weakCompareAndSet(recv, 1, 2);
-            assertEquals(r, true, "weakCompareAndSet int");
+            boolean success = false;
+            for (int c = 0; c < WEAK_ATTEMPTS && !success; c++) {
+                success = vh.weakCompareAndSet(recv, 1, 2);
+            }
+            assertEquals(success, true, "weakCompareAndSet int");
             int x = (int) vh.get(recv);
             assertEquals(x, 2, "weakCompareAndSet int value");
         }
 
         {
-            boolean r = vh.weakCompareAndSetAcquire(recv, 2, 1);
-            assertEquals(r, true, "weakCompareAndSetAcquire int");
+            boolean success = false;
+            for (int c = 0; c < WEAK_ATTEMPTS && !success; c++) {
+                success = vh.weakCompareAndSetAcquire(recv, 2, 1);
+            }
+            assertEquals(success, true, "weakCompareAndSetAcquire int");
             int x = (int) vh.get(recv);
             assertEquals(x, 1, "weakCompareAndSetAcquire int");
         }
 
         {
-            boolean r = vh.weakCompareAndSetRelease(recv, 1, 2);
-            assertEquals(r, true, "weakCompareAndSetRelease int");
+            boolean success = false;
+            for (int c = 0; c < WEAK_ATTEMPTS && !success; c++) {
+                success = vh.weakCompareAndSetRelease(recv, 1, 2);
+            }
+            assertEquals(success, true, "weakCompareAndSetRelease int");
             int x = (int) vh.get(recv);
             assertEquals(x, 2, "weakCompareAndSetRelease int");
         }
 
         {
-            boolean r = vh.weakCompareAndSetVolatile(recv, 2, 1);
-            assertEquals(r, true, "weakCompareAndSetVolatile int");
+            boolean success = false;
+            for (int c = 0; c < WEAK_ATTEMPTS && !success; c++) {
+                success = vh.weakCompareAndSetVolatile(recv, 2, 1);
+            }
+            assertEquals(success, true, "weakCompareAndSetVolatile int");
             int x = (int) vh.get(recv);
             assertEquals(x, 1, "weakCompareAndSetVolatile int value");
         }
@@ -543,36 +555,48 @@
         }
 
         {
-            boolean r = (boolean) vh.weakCompareAndSet(1, 2);
-            assertEquals(r, true, "weakCompareAndSet int");
+            boolean success = false;
+            for (int c = 0; c < WEAK_ATTEMPTS && !success; c++) {
+                success = vh.weakCompareAndSet(1, 2);
+            }
+            assertEquals(success, true, "weakCompareAndSet int");
             int x = (int) vh.get();
             assertEquals(x, 2, "weakCompareAndSet int value");
         }
 
         {
-            boolean r = (boolean) vh.weakCompareAndSetAcquire(2, 1);
-            assertEquals(r, true, "weakCompareAndSetAcquire int");
+            boolean success = false;
+            for (int c = 0; c < WEAK_ATTEMPTS && !success; c++) {
+                success = vh.weakCompareAndSetAcquire(2, 1);
+            }
+            assertEquals(success, true, "weakCompareAndSetAcquire int");
             int x = (int) vh.get();
             assertEquals(x, 1, "weakCompareAndSetAcquire int");
         }
 
         {
-            boolean r = (boolean) vh.weakCompareAndSetRelease(1, 2);
-            assertEquals(r, true, "weakCompareAndSetRelease int");
+            boolean success = false;
+            for (int c = 0; c < WEAK_ATTEMPTS && !success; c++) {
+                success = vh.weakCompareAndSetRelease(1, 2);
+            }
+            assertEquals(success, true, "weakCompareAndSetRelease int");
             int x = (int) vh.get();
             assertEquals(x, 2, "weakCompareAndSetRelease int");
         }
 
         {
-            boolean r = (boolean) vh.weakCompareAndSetVolatile(2, 1);
-            assertEquals(r, true, "weakCompareAndSetVolatile int");
+            boolean success = false;
+            for (int c = 0; c < WEAK_ATTEMPTS && !success; c++) {
+                success = vh.weakCompareAndSetRelease(2, 1);
+            }
+            assertEquals(success, true, "weakCompareAndSetVolatile int");
             int x = (int) vh.get();
-            assertEquals(x, 1, "weakCompareAndSetVolatile int value");
+            assertEquals(x, 1, "weakCompareAndSetVolatile int");
         }
 
         // Compare set and get
         {
-            int o = (int) vh.getAndSet( 2);
+            int o = (int) vh.getAndSet(2);
             assertEquals(o, 1, "getAndSet int");
             int x = (int) vh.get();
             assertEquals(x, 2, "getAndSet int value");
@@ -687,31 +711,43 @@
             }
 
             {
-                boolean r = vh.weakCompareAndSet(array, i, 1, 2);
-                assertEquals(r, true, "weakCompareAndSet int");
+                boolean success = false;
+                for (int c = 0; c < WEAK_ATTEMPTS && !success; c++) {
+                    success = vh.weakCompareAndSet(array, i, 1, 2);
+                }
+                assertEquals(success, true, "weakCompareAndSet int");
                 int x = (int) vh.get(array, i);
                 assertEquals(x, 2, "weakCompareAndSet int value");
             }
 
             {
-                boolean r = vh.weakCompareAndSetAcquire(array, i, 2, 1);
-                assertEquals(r, true, "weakCompareAndSetAcquire int");
+                boolean success = false;
+                for (int c = 0; c < WEAK_ATTEMPTS && !success; c++) {
+                    success = vh.weakCompareAndSetAcquire(array, i, 2, 1);
+                }
+                assertEquals(success, true, "weakCompareAndSetAcquire int");
                 int x = (int) vh.get(array, i);
                 assertEquals(x, 1, "weakCompareAndSetAcquire int");
             }
 
             {
-                boolean r = vh.weakCompareAndSetRelease(array, i, 1, 2);
-                assertEquals(r, true, "weakCompareAndSetRelease int");
+                boolean success = false;
+                for (int c = 0; c < WEAK_ATTEMPTS && !success; c++) {
+                    success = vh.weakCompareAndSetRelease(array, i, 1, 2);
+                }
+                assertEquals(success, true, "weakCompareAndSetRelease int");
                 int x = (int) vh.get(array, i);
                 assertEquals(x, 2, "weakCompareAndSetRelease int");
             }
 
             {
-                boolean r = vh.weakCompareAndSetVolatile(array, i, 2, 1);
-                assertEquals(r, true, "weakCompareAndSetVolatile int");
+                boolean success = false;
+                for (int c = 0; c < WEAK_ATTEMPTS && !success; c++) {
+                    success = vh.weakCompareAndSetVolatile(array, i, 2, 1);
+                }
+                assertEquals(success, true, "weakCompareAndSetVolatile int");
                 int x = (int) vh.get(array, i);
-                assertEquals(x, 1, "weakCompareAndSetVolatile int value");
+                assertEquals(x, 1, "weakCompareAndSetVolatile int");
             }
 
             // Compare set and get
--- a/jdk/test/java/lang/invoke/VarHandles/VarHandleTestAccessLong.java	Thu May 19 17:48:02 2016 +0000
+++ b/jdk/test/java/lang/invoke/VarHandles/VarHandleTestAccessLong.java	Thu May 19 19:46:20 2016 +0000
@@ -402,29 +402,41 @@
         }
 
         {
-            boolean r = vh.weakCompareAndSet(recv, 1L, 2L);
-            assertEquals(r, true, "weakCompareAndSet long");
+            boolean success = false;
+            for (int c = 0; c < WEAK_ATTEMPTS && !success; c++) {
+                success = vh.weakCompareAndSet(recv, 1L, 2L);
+            }
+            assertEquals(success, true, "weakCompareAndSet long");
             long x = (long) vh.get(recv);
             assertEquals(x, 2L, "weakCompareAndSet long value");
         }
 
         {
-            boolean r = vh.weakCompareAndSetAcquire(recv, 2L, 1L);
-            assertEquals(r, true, "weakCompareAndSetAcquire long");
+            boolean success = false;
+            for (int c = 0; c < WEAK_ATTEMPTS && !success; c++) {
+                success = vh.weakCompareAndSetAcquire(recv, 2L, 1L);
+            }
+            assertEquals(success, true, "weakCompareAndSetAcquire long");
             long x = (long) vh.get(recv);
             assertEquals(x, 1L, "weakCompareAndSetAcquire long");
         }
 
         {
-            boolean r = vh.weakCompareAndSetRelease(recv, 1L, 2L);
-            assertEquals(r, true, "weakCompareAndSetRelease long");
+            boolean success = false;
+            for (int c = 0; c < WEAK_ATTEMPTS && !success; c++) {
+                success = vh.weakCompareAndSetRelease(recv, 1L, 2L);
+            }
+            assertEquals(success, true, "weakCompareAndSetRelease long");
             long x = (long) vh.get(recv);
             assertEquals(x, 2L, "weakCompareAndSetRelease long");
         }
 
         {
-            boolean r = vh.weakCompareAndSetVolatile(recv, 2L, 1L);
-            assertEquals(r, true, "weakCompareAndSetVolatile long");
+            boolean success = false;
+            for (int c = 0; c < WEAK_ATTEMPTS && !success; c++) {
+                success = vh.weakCompareAndSetVolatile(recv, 2L, 1L);
+            }
+            assertEquals(success, true, "weakCompareAndSetVolatile long");
             long x = (long) vh.get(recv);
             assertEquals(x, 1L, "weakCompareAndSetVolatile long value");
         }
@@ -543,36 +555,48 @@
         }
 
         {
-            boolean r = (boolean) vh.weakCompareAndSet(1L, 2L);
-            assertEquals(r, true, "weakCompareAndSet long");
+            boolean success = false;
+            for (int c = 0; c < WEAK_ATTEMPTS && !success; c++) {
+                success = vh.weakCompareAndSet(1L, 2L);
+            }
+            assertEquals(success, true, "weakCompareAndSet long");
             long x = (long) vh.get();
             assertEquals(x, 2L, "weakCompareAndSet long value");
         }
 
         {
-            boolean r = (boolean) vh.weakCompareAndSetAcquire(2L, 1L);
-            assertEquals(r, true, "weakCompareAndSetAcquire long");
+            boolean success = false;
+            for (int c = 0; c < WEAK_ATTEMPTS && !success; c++) {
+                success = vh.weakCompareAndSetAcquire(2L, 1L);
+            }
+            assertEquals(success, true, "weakCompareAndSetAcquire long");
             long x = (long) vh.get();
             assertEquals(x, 1L, "weakCompareAndSetAcquire long");
         }
 
         {
-            boolean r = (boolean) vh.weakCompareAndSetRelease(1L, 2L);
-            assertEquals(r, true, "weakCompareAndSetRelease long");
+            boolean success = false;
+            for (int c = 0; c < WEAK_ATTEMPTS && !success; c++) {
+                success = vh.weakCompareAndSetRelease(1L, 2L);
+            }
+            assertEquals(success, true, "weakCompareAndSetRelease long");
             long x = (long) vh.get();
             assertEquals(x, 2L, "weakCompareAndSetRelease long");
         }
 
         {
-            boolean r = (boolean) vh.weakCompareAndSetVolatile(2L, 1L);
-            assertEquals(r, true, "weakCompareAndSetVolatile long");
+            boolean success = false;
+            for (int c = 0; c < WEAK_ATTEMPTS && !success; c++) {
+                success = vh.weakCompareAndSetRelease(2L, 1L);
+            }
+            assertEquals(success, true, "weakCompareAndSetVolatile long");
             long x = (long) vh.get();
-            assertEquals(x, 1L, "weakCompareAndSetVolatile long value");
+            assertEquals(x, 1L, "weakCompareAndSetVolatile long");
         }
 
         // Compare set and get
         {
-            long o = (long) vh.getAndSet( 2L);
+            long o = (long) vh.getAndSet(2L);
             assertEquals(o, 1L, "getAndSet long");
             long x = (long) vh.get();
             assertEquals(x, 2L, "getAndSet long value");
@@ -687,31 +711,43 @@
             }
 
             {
-                boolean r = vh.weakCompareAndSet(array, i, 1L, 2L);
-                assertEquals(r, true, "weakCompareAndSet long");
+                boolean success = false;
+                for (int c = 0; c < WEAK_ATTEMPTS && !success; c++) {
+                    success = vh.weakCompareAndSet(array, i, 1L, 2L);
+                }
+                assertEquals(success, true, "weakCompareAndSet long");
                 long x = (long) vh.get(array, i);
                 assertEquals(x, 2L, "weakCompareAndSet long value");
             }
 
             {
-                boolean r = vh.weakCompareAndSetAcquire(array, i, 2L, 1L);
-                assertEquals(r, true, "weakCompareAndSetAcquire long");
+                boolean success = false;
+                for (int c = 0; c < WEAK_ATTEMPTS && !success; c++) {
+                    success = vh.weakCompareAndSetAcquire(array, i, 2L, 1L);
+                }
+                assertEquals(success, true, "weakCompareAndSetAcquire long");
                 long x = (long) vh.get(array, i);
                 assertEquals(x, 1L, "weakCompareAndSetAcquire long");
             }
 
             {
-                boolean r = vh.weakCompareAndSetRelease(array, i, 1L, 2L);
-                assertEquals(r, true, "weakCompareAndSetRelease long");
+                boolean success = false;
+                for (int c = 0; c < WEAK_ATTEMPTS && !success; c++) {
+                    success = vh.weakCompareAndSetRelease(array, i, 1L, 2L);
+                }
+                assertEquals(success, true, "weakCompareAndSetRelease long");
                 long x = (long) vh.get(array, i);
                 assertEquals(x, 2L, "weakCompareAndSetRelease long");
             }
 
             {
-                boolean r = vh.weakCompareAndSetVolatile(array, i, 2L, 1L);
-                assertEquals(r, true, "weakCompareAndSetVolatile long");
+                boolean success = false;
+                for (int c = 0; c < WEAK_ATTEMPTS && !success; c++) {
+                    success = vh.weakCompareAndSetVolatile(array, i, 2L, 1L);
+                }
+                assertEquals(success, true, "weakCompareAndSetVolatile long");
                 long x = (long) vh.get(array, i);
-                assertEquals(x, 1L, "weakCompareAndSetVolatile long value");
+                assertEquals(x, 1L, "weakCompareAndSetVolatile long");
             }
 
             // Compare set and get
--- a/jdk/test/java/lang/invoke/VarHandles/VarHandleTestAccessShort.java	Thu May 19 17:48:02 2016 +0000
+++ b/jdk/test/java/lang/invoke/VarHandles/VarHandleTestAccessShort.java	Thu May 19 19:46:20 2016 +0000
@@ -293,6 +293,10 @@
         });
 
         checkUOE(() -> {
+            short r = (short) vh.getAndSet(recv, (short)1);
+        });
+
+        checkUOE(() -> {
             short o = (short) vh.getAndAdd(recv, (short)1);
         });
 
@@ -379,6 +383,10 @@
         });
 
         checkUOE(() -> {
+            short r = (short) vh.getAndSet((short)1);
+        });
+
+        checkUOE(() -> {
             short o = (short) vh.getAndAdd((short)1);
         });
 
@@ -455,6 +463,10 @@
         });
 
         checkUOE(() -> {
+            short r = (short) vh.getAndSet(recv, (short)1);
+        });
+
+        checkUOE(() -> {
             short o = (short) vh.getAndAdd(recv, (short)1);
         });
 
@@ -531,6 +543,10 @@
         });
 
         checkUOE(() -> {
+            short r = (short) vh.getAndSet((short)1);
+        });
+
+        checkUOE(() -> {
             short o = (short) vh.getAndAdd((short)1);
         });
 
@@ -614,6 +630,10 @@
         });
 
         checkUOE(() -> {
+            short r = (short) vh.getAndSet(array, i, (short)1);
+        });
+
+        checkUOE(() -> {
             short o = (short) vh.getAndAdd(array, i, (short)1);
         });
 
--- a/jdk/test/java/lang/invoke/VarHandles/VarHandleTestAccessString.java	Thu May 19 17:48:02 2016 +0000
+++ b/jdk/test/java/lang/invoke/VarHandles/VarHandleTestAccessString.java	Thu May 19 19:46:20 2016 +0000
@@ -416,29 +416,41 @@
         }
 
         {
-            boolean r = vh.weakCompareAndSet(recv, "foo", "bar");
-            assertEquals(r, true, "weakCompareAndSet String");
+            boolean success = false;
+            for (int c = 0; c < WEAK_ATTEMPTS && !success; c++) {
+                success = vh.weakCompareAndSet(recv, "foo", "bar");
+            }
+            assertEquals(success, true, "weakCompareAndSet String");
             String x = (String) vh.get(recv);
             assertEquals(x, "bar", "weakCompareAndSet String value");
         }
 
         {
-            boolean r = vh.weakCompareAndSetAcquire(recv, "bar", "foo");
-            assertEquals(r, true, "weakCompareAndSetAcquire String");
+            boolean success = false;
+            for (int c = 0; c < WEAK_ATTEMPTS && !success; c++) {
+                success = vh.weakCompareAndSetAcquire(recv, "bar", "foo");
+            }
+            assertEquals(success, true, "weakCompareAndSetAcquire String");
             String x = (String) vh.get(recv);
             assertEquals(x, "foo", "weakCompareAndSetAcquire String");
         }
 
         {
-            boolean r = vh.weakCompareAndSetRelease(recv, "foo", "bar");
-            assertEquals(r, true, "weakCompareAndSetRelease String");
+            boolean success = false;
+            for (int c = 0; c < WEAK_ATTEMPTS && !success; c++) {
+                success = vh.weakCompareAndSetRelease(recv, "foo", "bar");
+            }
+            assertEquals(success, true, "weakCompareAndSetRelease String");
             String x = (String) vh.get(recv);
             assertEquals(x, "bar", "weakCompareAndSetRelease String");
         }
 
         {
-            boolean r = vh.weakCompareAndSetVolatile(recv, "bar", "foo");
-            assertEquals(r, true, "weakCompareAndSetVolatile String");
+            boolean success = false;
+            for (int c = 0; c < WEAK_ATTEMPTS && !success; c++) {
+                success = vh.weakCompareAndSetVolatile(recv, "bar", "foo");
+            }
+            assertEquals(success, true, "weakCompareAndSetVolatile String");
             String x = (String) vh.get(recv);
             assertEquals(x, "foo", "weakCompareAndSetVolatile String value");
         }
@@ -555,36 +567,48 @@
         }
 
         {
-            boolean r = (boolean) vh.weakCompareAndSet("foo", "bar");
-            assertEquals(r, true, "weakCompareAndSet String");
+            boolean success = false;
+            for (int c = 0; c < WEAK_ATTEMPTS && !success; c++) {
+                success = vh.weakCompareAndSet("foo", "bar");
+            }
+            assertEquals(success, true, "weakCompareAndSet String");
             String x = (String) vh.get();
             assertEquals(x, "bar", "weakCompareAndSet String value");
         }
 
         {
-            boolean r = (boolean) vh.weakCompareAndSetAcquire("bar", "foo");
-            assertEquals(r, true, "weakCompareAndSetAcquire String");
+            boolean success = false;
+            for (int c = 0; c < WEAK_ATTEMPTS && !success; c++) {
+                success = vh.weakCompareAndSetAcquire("bar", "foo");
+            }
+            assertEquals(success, true, "weakCompareAndSetAcquire String");
             String x = (String) vh.get();
             assertEquals(x, "foo", "weakCompareAndSetAcquire String");
         }
 
         {
-            boolean r = (boolean) vh.weakCompareAndSetRelease("foo", "bar");
-            assertEquals(r, true, "weakCompareAndSetRelease String");
+            boolean success = false;
+            for (int c = 0; c < WEAK_ATTEMPTS && !success; c++) {
+                success = vh.weakCompareAndSetRelease("foo", "bar");
+            }
+            assertEquals(success, true, "weakCompareAndSetRelease String");
             String x = (String) vh.get();
             assertEquals(x, "bar", "weakCompareAndSetRelease String");
         }
 
         {
-            boolean r = (boolean) vh.weakCompareAndSetVolatile("bar", "foo");
-            assertEquals(r, true, "weakCompareAndSetVolatile String");
+            boolean success = false;
+            for (int c = 0; c < WEAK_ATTEMPTS && !success; c++) {
+                success = vh.weakCompareAndSetRelease("bar", "foo");
+            }
+            assertEquals(success, true, "weakCompareAndSetVolatile String");
             String x = (String) vh.get();
-            assertEquals(x, "foo", "weakCompareAndSetVolatile String value");
+            assertEquals(x, "foo", "weakCompareAndSetVolatile String");
         }
 
         // Compare set and get
         {
-            String o = (String) vh.getAndSet( "bar");
+            String o = (String) vh.getAndSet("bar");
             assertEquals(o, "foo", "getAndSet String");
             String x = (String) vh.get();
             assertEquals(x, "bar", "getAndSet String value");
@@ -697,31 +721,43 @@
             }
 
             {
-                boolean r = vh.weakCompareAndSet(array, i, "foo", "bar");
-                assertEquals(r, true, "weakCompareAndSet String");
+                boolean success = false;
+                for (int c = 0; c < WEAK_ATTEMPTS && !success; c++) {
+                    success = vh.weakCompareAndSet(array, i, "foo", "bar");
+                }
+                assertEquals(success, true, "weakCompareAndSet String");
                 String x = (String) vh.get(array, i);
                 assertEquals(x, "bar", "weakCompareAndSet String value");
             }
 
             {
-                boolean r = vh.weakCompareAndSetAcquire(array, i, "bar", "foo");
-                assertEquals(r, true, "weakCompareAndSetAcquire String");
+                boolean success = false;
+                for (int c = 0; c < WEAK_ATTEMPTS && !success; c++) {
+                    success = vh.weakCompareAndSetAcquire(array, i, "bar", "foo");
+                }
+                assertEquals(success, true, "weakCompareAndSetAcquire String");
                 String x = (String) vh.get(array, i);
                 assertEquals(x, "foo", "weakCompareAndSetAcquire String");
             }
 
             {
-                boolean r = vh.weakCompareAndSetRelease(array, i, "foo", "bar");
-                assertEquals(r, true, "weakCompareAndSetRelease String");
+                boolean success = false;
+                for (int c = 0; c < WEAK_ATTEMPTS && !success; c++) {
+                    success = vh.weakCompareAndSetRelease(array, i, "foo", "bar");
+                }
+                assertEquals(success, true, "weakCompareAndSetRelease String");
                 String x = (String) vh.get(array, i);
                 assertEquals(x, "bar", "weakCompareAndSetRelease String");
             }
 
             {
-                boolean r = vh.weakCompareAndSetVolatile(array, i, "bar", "foo");
-                assertEquals(r, true, "weakCompareAndSetVolatile String");
+                boolean success = false;
+                for (int c = 0; c < WEAK_ATTEMPTS && !success; c++) {
+                    success = vh.weakCompareAndSetVolatile(array, i, "bar", "foo");
+                }
+                assertEquals(success, true, "weakCompareAndSetVolatile String");
                 String x = (String) vh.get(array, i);
-                assertEquals(x, "foo", "weakCompareAndSetVolatile String value");
+                assertEquals(x, "foo", "weakCompareAndSetVolatile String");
             }
 
             // Compare set and get
--- a/jdk/test/java/lang/invoke/VarHandles/VarHandleTestByteArrayAsChar.java	Thu May 19 17:48:02 2016 +0000
+++ b/jdk/test/java/lang/invoke/VarHandles/VarHandleTestByteArrayAsChar.java	Thu May 19 19:46:20 2016 +0000
@@ -50,7 +50,7 @@
 
     static final char VALUE_2 = (char)0x1112;
 
-    static final char VALUE_3 = (char)0x2122;
+    static final char VALUE_3 = (char)0xFFFE;
 
 
     @Override
@@ -254,6 +254,10 @@
                 vh.setOpaque(array, ci, VALUE_1);
             });
             checkUOE(() -> {
+                boolean r = vh.compareAndSet(array, ci, VALUE_1, VALUE_2);
+            });
+
+            checkUOE(() -> {
                 char r = (char) vh.compareAndExchangeVolatile(array, ci, VALUE_2, VALUE_1);
             });
 
--- a/jdk/test/java/lang/invoke/VarHandles/VarHandleTestByteArrayAsDouble.java	Thu May 19 17:48:02 2016 +0000
+++ b/jdk/test/java/lang/invoke/VarHandles/VarHandleTestByteArrayAsDouble.java	Thu May 19 19:46:20 2016 +0000
@@ -50,7 +50,7 @@
 
     static final double VALUE_2 = 0x1112131415161718L;
 
-    static final double VALUE_3 = 0x2122232425262728L;
+    static final double VALUE_3 = 0xFFFEFDFCFBFAF9F8L;
 
 
     @Override
@@ -254,9 +254,7 @@
             checkROBE(() -> {
                 double o = (double) vh.getAndSet(array, ci, VALUE_1);
             });
-            checkUOE(() -> {
-                boolean r = vh.compareAndSet(array, ci, VALUE_1, VALUE_2);
-            });
+
 
             checkUOE(() -> {
                 double o = (double) vh.getAndAdd(array, ci, VALUE_1);
@@ -700,22 +698,31 @@
                 }
 
                 {
-                    boolean r = vh.weakCompareAndSet(array, i, VALUE_1, VALUE_2);
-                    assertEquals(r, true, "weakCompareAndSet double");
+                    boolean success = false;
+                    for (int c = 0; c < WEAK_ATTEMPTS && !success; c++) {
+                        success = vh.weakCompareAndSet(array, i, VALUE_1, VALUE_2);
+                    }
+                    assertEquals(success, true, "weakCompareAndSet double");
                     double x = (double) vh.get(array, i);
                     assertEquals(x, VALUE_2, "weakCompareAndSet double value");
                 }
 
                 {
-                    boolean r = vh.weakCompareAndSetAcquire(array, i, VALUE_2, VALUE_1);
-                    assertEquals(r, true, "weakCompareAndSetAcquire double");
+                    boolean success = false;
+                    for (int c = 0; c < WEAK_ATTEMPTS && !success; c++) {
+                        success = vh.weakCompareAndSetAcquire(array, i, VALUE_2, VALUE_1);
+                    }
+                    assertEquals(success, true, "weakCompareAndSetAcquire double");
                     double x = (double) vh.get(array, i);
                     assertEquals(x, VALUE_1, "weakCompareAndSetAcquire double");
                 }
 
                 {
-                    boolean r = vh.weakCompareAndSetRelease(array, i, VALUE_1, VALUE_2);
-                    assertEquals(r, true, "weakCompareAndSetRelease double");
+                    boolean success = false;
+                    for (int c = 0; c < WEAK_ATTEMPTS && !success; c++) {
+                        success = vh.weakCompareAndSetRelease(array, i, VALUE_1, VALUE_2);
+                    }
+                    assertEquals(success, true, "weakCompareAndSetRelease double");
                     double x = (double) vh.get(array, i);
                     assertEquals(x, VALUE_2, "weakCompareAndSetRelease double");
                 }
@@ -840,22 +847,31 @@
                 }
 
                 {
-                    boolean r = vh.weakCompareAndSet(array, i, VALUE_1, VALUE_2);
-                    assertEquals(r, true, "weakCompareAndSet double");
+                    boolean success = false;
+                    for (int c = 0; c < WEAK_ATTEMPTS && !success; c++) {
+                        success = vh.weakCompareAndSet(array, i, VALUE_1, VALUE_2);
+                    }
+                    assertEquals(success, true, "weakCompareAndSet double");
                     double x = (double) vh.get(array, i);
                     assertEquals(x, VALUE_2, "weakCompareAndSet double value");
                 }
 
                 {
-                    boolean r = vh.weakCompareAndSetAcquire(array, i, VALUE_2, VALUE_1);
-                    assertEquals(r, true, "weakCompareAndSetAcquire double");
+                    boolean success = false;
+                    for (int c = 0; c < WEAK_ATTEMPTS && !success; c++) {
+                        success = vh.weakCompareAndSetAcquire(array, i, VALUE_2, VALUE_1);
+                    }
+                    assertEquals(success, true, "weakCompareAndSetAcquire double");
                     double x = (double) vh.get(array, i);
                     assertEquals(x, VALUE_1, "weakCompareAndSetAcquire double");
                 }
 
                 {
-                    boolean r = vh.weakCompareAndSetRelease(array, i, VALUE_1, VALUE_2);
-                    assertEquals(r, true, "weakCompareAndSetRelease double");
+                    boolean success = false;
+                    for (int c = 0; c < WEAK_ATTEMPTS && !success; c++) {
+                        success = vh.weakCompareAndSetRelease(array, i, VALUE_1, VALUE_2);
+                    }
+                    assertEquals(success, true, "weakCompareAndSetRelease double");
                     double x = (double) vh.get(array, i);
                     assertEquals(x, VALUE_2, "weakCompareAndSetRelease double");
                 }
--- a/jdk/test/java/lang/invoke/VarHandles/VarHandleTestByteArrayAsFloat.java	Thu May 19 17:48:02 2016 +0000
+++ b/jdk/test/java/lang/invoke/VarHandles/VarHandleTestByteArrayAsFloat.java	Thu May 19 19:46:20 2016 +0000
@@ -50,7 +50,7 @@
 
     static final float VALUE_2 = 0x11121314;
 
-    static final float VALUE_3 = 0x21222324;
+    static final float VALUE_3 = 0xFFFEFDFC;
 
 
     @Override
@@ -254,9 +254,7 @@
             checkROBE(() -> {
                 float o = (float) vh.getAndSet(array, ci, VALUE_1);
             });
-            checkUOE(() -> {
-                boolean r = vh.compareAndSet(array, ci, VALUE_1, VALUE_2);
-            });
+
 
             checkUOE(() -> {
                 float o = (float) vh.getAndAdd(array, ci, VALUE_1);
@@ -700,22 +698,31 @@
                 }
 
                 {
-                    boolean r = vh.weakCompareAndSet(array, i, VALUE_1, VALUE_2);
-                    assertEquals(r, true, "weakCompareAndSet float");
+                    boolean success = false;
+                    for (int c = 0; c < WEAK_ATTEMPTS && !success; c++) {
+                        success = vh.weakCompareAndSet(array, i, VALUE_1, VALUE_2);
+                    }
+                    assertEquals(success, true, "weakCompareAndSet float");
                     float x = (float) vh.get(array, i);
                     assertEquals(x, VALUE_2, "weakCompareAndSet float value");
                 }
 
                 {
-                    boolean r = vh.weakCompareAndSetAcquire(array, i, VALUE_2, VALUE_1);
-                    assertEquals(r, true, "weakCompareAndSetAcquire float");
+                    boolean success = false;
+                    for (int c = 0; c < WEAK_ATTEMPTS && !success; c++) {
+                        success = vh.weakCompareAndSetAcquire(array, i, VALUE_2, VALUE_1);
+                    }
+                    assertEquals(success, true, "weakCompareAndSetAcquire float");
                     float x = (float) vh.get(array, i);
                     assertEquals(x, VALUE_1, "weakCompareAndSetAcquire float");
                 }
 
                 {
-                    boolean r = vh.weakCompareAndSetRelease(array, i, VALUE_1, VALUE_2);
-                    assertEquals(r, true, "weakCompareAndSetRelease float");
+                    boolean success = false;
+                    for (int c = 0; c < WEAK_ATTEMPTS && !success; c++) {
+                        success = vh.weakCompareAndSetRelease(array, i, VALUE_1, VALUE_2);
+                    }
+                    assertEquals(success, true, "weakCompareAndSetRelease float");
                     float x = (float) vh.get(array, i);
                     assertEquals(x, VALUE_2, "weakCompareAndSetRelease float");
                 }
@@ -840,22 +847,31 @@
                 }
 
                 {
-                    boolean r = vh.weakCompareAndSet(array, i, VALUE_1, VALUE_2);
-                    assertEquals(r, true, "weakCompareAndSet float");
+                    boolean success = false;
+                    for (int c = 0; c < WEAK_ATTEMPTS && !success; c++) {
+                        success = vh.weakCompareAndSet(array, i, VALUE_1, VALUE_2);
+                    }
+                    assertEquals(success, true, "weakCompareAndSet float");
                     float x = (float) vh.get(array, i);
                     assertEquals(x, VALUE_2, "weakCompareAndSet float value");
                 }
 
                 {
-                    boolean r = vh.weakCompareAndSetAcquire(array, i, VALUE_2, VALUE_1);
-                    assertEquals(r, true, "weakCompareAndSetAcquire float");
+                    boolean success = false;
+                    for (int c = 0; c < WEAK_ATTEMPTS && !success; c++) {
+                        success = vh.weakCompareAndSetAcquire(array, i, VALUE_2, VALUE_1);
+                    }
+                    assertEquals(success, true, "weakCompareAndSetAcquire float");
                     float x = (float) vh.get(array, i);
                     assertEquals(x, VALUE_1, "weakCompareAndSetAcquire float");
                 }
 
                 {
-                    boolean r = vh.weakCompareAndSetRelease(array, i, VALUE_1, VALUE_2);
-                    assertEquals(r, true, "weakCompareAndSetRelease float");
+                    boolean success = false;
+                    for (int c = 0; c < WEAK_ATTEMPTS && !success; c++) {
+                        success = vh.weakCompareAndSetRelease(array, i, VALUE_1, VALUE_2);
+                    }
+                    assertEquals(success, true, "weakCompareAndSetRelease float");
                     float x = (float) vh.get(array, i);
                     assertEquals(x, VALUE_2, "weakCompareAndSetRelease float");
                 }
--- a/jdk/test/java/lang/invoke/VarHandles/VarHandleTestByteArrayAsInt.java	Thu May 19 17:48:02 2016 +0000
+++ b/jdk/test/java/lang/invoke/VarHandles/VarHandleTestByteArrayAsInt.java	Thu May 19 19:46:20 2016 +0000
@@ -50,7 +50,7 @@
 
     static final int VALUE_2 = 0x11121314;
 
-    static final int VALUE_3 = 0x21222324;
+    static final int VALUE_3 = 0xFFFEFDFC;
 
 
     @Override
@@ -247,9 +247,7 @@
             checkROBE(() -> {
                 int o = (int) vh.getAndSet(array, ci, VALUE_1);
             });
-            checkUOE(() -> {
-                boolean r = vh.compareAndSet(array, ci, VALUE_1, VALUE_2);
-            });
+
 
             checkROBE(() -> {
                 int o = (int) vh.getAndAdd(array, ci, VALUE_1);
@@ -714,22 +712,31 @@
                 }
 
                 {
-                    boolean r = vh.weakCompareAndSet(array, i, VALUE_1, VALUE_2);
-                    assertEquals(r, true, "weakCompareAndSet int");
+                    boolean success = false;
+                    for (int c = 0; c < WEAK_ATTEMPTS && !success; c++) {
+                        success = vh.weakCompareAndSet(array, i, VALUE_1, VALUE_2);
+                    }
+                    assertEquals(success, true, "weakCompareAndSet int");
                     int x = (int) vh.get(array, i);
                     assertEquals(x, VALUE_2, "weakCompareAndSet int value");
                 }
 
                 {
-                    boolean r = vh.weakCompareAndSetAcquire(array, i, VALUE_2, VALUE_1);
-                    assertEquals(r, true, "weakCompareAndSetAcquire int");
+                    boolean success = false;
+                    for (int c = 0; c < WEAK_ATTEMPTS && !success; c++) {
+                        success = vh.weakCompareAndSetAcquire(array, i, VALUE_2, VALUE_1);
+                    }
+                    assertEquals(success, true, "weakCompareAndSetAcquire int");
                     int x = (int) vh.get(array, i);
                     assertEquals(x, VALUE_1, "weakCompareAndSetAcquire int");
                 }
 
                 {
-                    boolean r = vh.weakCompareAndSetRelease(array, i, VALUE_1, VALUE_2);
-                    assertEquals(r, true, "weakCompareAndSetRelease int");
+                    boolean success = false;
+                    for (int c = 0; c < WEAK_ATTEMPTS && !success; c++) {
+                        success = vh.weakCompareAndSetRelease(array, i, VALUE_1, VALUE_2);
+                    }
+                    assertEquals(success, true, "weakCompareAndSetRelease int");
                     int x = (int) vh.get(array, i);
                     assertEquals(x, VALUE_2, "weakCompareAndSetRelease int");
                 }
@@ -863,22 +870,31 @@
                 }
 
                 {
-                    boolean r = vh.weakCompareAndSet(array, i, VALUE_1, VALUE_2);
-                    assertEquals(r, true, "weakCompareAndSet int");
+                    boolean success = false;
+                    for (int c = 0; c < WEAK_ATTEMPTS && !success; c++) {
+                        success = vh.weakCompareAndSet(array, i, VALUE_1, VALUE_2);
+                    }
+                    assertEquals(success, true, "weakCompareAndSet int");
                     int x = (int) vh.get(array, i);
                     assertEquals(x, VALUE_2, "weakCompareAndSet int value");
                 }
 
                 {
-                    boolean r = vh.weakCompareAndSetAcquire(array, i, VALUE_2, VALUE_1);
-                    assertEquals(r, true, "weakCompareAndSetAcquire int");
+                    boolean success = false;
+                    for (int c = 0; c < WEAK_ATTEMPTS && !success; c++) {
+                        success = vh.weakCompareAndSetAcquire(array, i, VALUE_2, VALUE_1);
+                    }
+                    assertEquals(success, true, "weakCompareAndSetAcquire int");
                     int x = (int) vh.get(array, i);
                     assertEquals(x, VALUE_1, "weakCompareAndSetAcquire int");
                 }
 
                 {
-                    boolean r = vh.weakCompareAndSetRelease(array, i, VALUE_1, VALUE_2);
-                    assertEquals(r, true, "weakCompareAndSetRelease int");
+                    boolean success = false;
+                    for (int c = 0; c < WEAK_ATTEMPTS && !success; c++) {
+                        success = vh.weakCompareAndSetRelease(array, i, VALUE_1, VALUE_2);
+                    }
+                    assertEquals(success, true, "weakCompareAndSetRelease int");
                     int x = (int) vh.get(array, i);
                     assertEquals(x, VALUE_2, "weakCompareAndSetRelease int");
                 }
--- a/jdk/test/java/lang/invoke/VarHandles/VarHandleTestByteArrayAsLong.java	Thu May 19 17:48:02 2016 +0000
+++ b/jdk/test/java/lang/invoke/VarHandles/VarHandleTestByteArrayAsLong.java	Thu May 19 19:46:20 2016 +0000
@@ -50,7 +50,7 @@
 
     static final long VALUE_2 = 0x1112131415161718L;
 
-    static final long VALUE_3 = 0x2122232425262728L;
+    static final long VALUE_3 = 0xFFFEFDFCFBFAF9F8L;
 
 
     @Override
@@ -247,9 +247,7 @@
             checkROBE(() -> {
                 long o = (long) vh.getAndSet(array, ci, VALUE_1);
             });
-            checkUOE(() -> {
-                boolean r = vh.compareAndSet(array, ci, VALUE_1, VALUE_2);
-            });
+
 
             checkROBE(() -> {
                 long o = (long) vh.getAndAdd(array, ci, VALUE_1);
@@ -714,22 +712,31 @@
                 }
 
                 {
-                    boolean r = vh.weakCompareAndSet(array, i, VALUE_1, VALUE_2);
-                    assertEquals(r, true, "weakCompareAndSet long");
+                    boolean success = false;
+                    for (int c = 0; c < WEAK_ATTEMPTS && !success; c++) {
+                        success = vh.weakCompareAndSet(array, i, VALUE_1, VALUE_2);
+                    }
+                    assertEquals(success, true, "weakCompareAndSet long");
                     long x = (long) vh.get(array, i);
                     assertEquals(x, VALUE_2, "weakCompareAndSet long value");
                 }
 
                 {
-                    boolean r = vh.weakCompareAndSetAcquire(array, i, VALUE_2, VALUE_1);
-                    assertEquals(r, true, "weakCompareAndSetAcquire long");
+                    boolean success = false;
+                    for (int c = 0; c < WEAK_ATTEMPTS && !success; c++) {
+                        success = vh.weakCompareAndSetAcquire(array, i, VALUE_2, VALUE_1);
+                    }
+                    assertEquals(success, true, "weakCompareAndSetAcquire long");
                     long x = (long) vh.get(array, i);
                     assertEquals(x, VALUE_1, "weakCompareAndSetAcquire long");
                 }
 
                 {
-                    boolean r = vh.weakCompareAndSetRelease(array, i, VALUE_1, VALUE_2);
-                    assertEquals(r, true, "weakCompareAndSetRelease long");
+                    boolean success = false;
+                    for (int c = 0; c < WEAK_ATTEMPTS && !success; c++) {
+                        success = vh.weakCompareAndSetRelease(array, i, VALUE_1, VALUE_2);
+                    }
+                    assertEquals(success, true, "weakCompareAndSetRelease long");
                     long x = (long) vh.get(array, i);
                     assertEquals(x, VALUE_2, "weakCompareAndSetRelease long");
                 }
@@ -863,22 +870,31 @@
                 }
 
                 {
-                    boolean r = vh.weakCompareAndSet(array, i, VALUE_1, VALUE_2);
-                    assertEquals(r, true, "weakCompareAndSet long");
+                    boolean success = false;
+                    for (int c = 0; c < WEAK_ATTEMPTS && !success; c++) {
+                        success = vh.weakCompareAndSet(array, i, VALUE_1, VALUE_2);
+                    }
+                    assertEquals(success, true, "weakCompareAndSet long");
                     long x = (long) vh.get(array, i);
                     assertEquals(x, VALUE_2, "weakCompareAndSet long value");
                 }
 
                 {
-                    boolean r = vh.weakCompareAndSetAcquire(array, i, VALUE_2, VALUE_1);
-                    assertEquals(r, true, "weakCompareAndSetAcquire long");
+                    boolean success = false;
+                    for (int c = 0; c < WEAK_ATTEMPTS && !success; c++) {
+                        success = vh.weakCompareAndSetAcquire(array, i, VALUE_2, VALUE_1);
+                    }
+                    assertEquals(success, true, "weakCompareAndSetAcquire long");
                     long x = (long) vh.get(array, i);
                     assertEquals(x, VALUE_1, "weakCompareAndSetAcquire long");
                 }
 
                 {
-                    boolean r = vh.weakCompareAndSetRelease(array, i, VALUE_1, VALUE_2);
-                    assertEquals(r, true, "weakCompareAndSetRelease long");
+                    boolean success = false;
+                    for (int c = 0; c < WEAK_ATTEMPTS && !success; c++) {
+                        success = vh.weakCompareAndSetRelease(array, i, VALUE_1, VALUE_2);
+                    }
+                    assertEquals(success, true, "weakCompareAndSetRelease long");
                     long x = (long) vh.get(array, i);
                     assertEquals(x, VALUE_2, "weakCompareAndSetRelease long");
                 }
--- a/jdk/test/java/lang/invoke/VarHandles/VarHandleTestByteArrayAsShort.java	Thu May 19 17:48:02 2016 +0000
+++ b/jdk/test/java/lang/invoke/VarHandles/VarHandleTestByteArrayAsShort.java	Thu May 19 19:46:20 2016 +0000
@@ -50,7 +50,7 @@
 
     static final short VALUE_2 = (short)0x1112;
 
-    static final short VALUE_3 = (short)0x2122;
+    static final short VALUE_3 = (short)0xFFFE;
 
 
     @Override
@@ -254,6 +254,10 @@
                 vh.setOpaque(array, ci, VALUE_1);
             });
             checkUOE(() -> {
+                boolean r = vh.compareAndSet(array, ci, VALUE_1, VALUE_2);
+            });
+
+            checkUOE(() -> {
                 short r = (short) vh.compareAndExchangeVolatile(array, ci, VALUE_2, VALUE_1);
             });
 
--- a/jdk/test/java/lang/invoke/VarHandles/VarHandleTestMethodHandleAccessInt.java	Thu May 19 17:48:02 2016 +0000
+++ b/jdk/test/java/lang/invoke/VarHandles/VarHandleTestMethodHandleAccessInt.java	Thu May 19 19:46:20 2016 +0000
@@ -208,31 +208,43 @@
         }
 
         {
-            boolean r = (boolean) hs.get(TestAccessMode.WEAK_COMPARE_AND_SET).invokeExact(recv, 1, 2);
-            assertEquals(r, true, "weakCompareAndSet int");
+            boolean success = false;
+            for (int c = 0; c < WEAK_ATTEMPTS && !success; c++) {
+                success = (boolean) hs.get(TestAccessMode.WEAK_COMPARE_AND_SET).invokeExact(recv, 1, 2);
+            }
+            assertEquals(success, true, "weakCompareAndSet int");
             int x = (int) hs.get(TestAccessMode.GET).invokeExact(recv);
             assertEquals(x, 2, "weakCompareAndSet int value");
         }
 
         {
-            boolean r = (boolean) hs.get(TestAccessMode.WEAK_COMPARE_AND_SET_ACQUIRE).invokeExact(recv, 2, 1);
-            assertEquals(r, true, "weakCompareAndSetAcquire int");
+            boolean success = false;
+            for (int c = 0; c < WEAK_ATTEMPTS && !success; c++) {
+                success = (boolean) hs.get(TestAccessMode.WEAK_COMPARE_AND_SET_ACQUIRE).invokeExact(recv, 2, 1);
+            }
+            assertEquals(success, true, "weakCompareAndSetAcquire int");
             int x = (int) hs.get(TestAccessMode.GET).invokeExact(recv);
             assertEquals(x, 1, "weakCompareAndSetAcquire int");
         }
 
         {
-            boolean r = (boolean) hs.get(TestAccessMode.WEAK_COMPARE_AND_SET_RELEASE).invokeExact(recv, 1, 2);
-            assertEquals(r, true, "weakCompareAndSetRelease int");
+            boolean success = false;
+            for (int c = 0; c < WEAK_ATTEMPTS && !success; c++) {
+                success = (boolean) hs.get(TestAccessMode.WEAK_COMPARE_AND_SET_RELEASE).invokeExact(recv, 1, 2);
+            }
+            assertEquals(success, true, "weakCompareAndSetRelease int");
             int x = (int) hs.get(TestAccessMode.GET).invokeExact(recv);
             assertEquals(x, 2, "weakCompareAndSetRelease int");
         }
 
         {
-            boolean r = (boolean) hs.get(TestAccessMode.WEAK_COMPARE_AND_SET_VOLATILE).invokeExact(recv, 2, 1);
-            assertEquals(r, true, "weakCompareAndSetVolatile int");
+            boolean success = false;
+            for (int c = 0; c < WEAK_ATTEMPTS && !success; c++) {
+                success = (boolean) hs.get(TestAccessMode.WEAK_COMPARE_AND_SET_VOLATILE).invokeExact(recv, 2, 1);
+            }
+            assertEquals(success, true, "weakCompareAndSetVolatile int");
             int x = (int) hs.get(TestAccessMode.GET).invokeExact(recv);
-            assertEquals(x, 1, "weakCompareAndSetVolatile int value");
+            assertEquals(x, 1, "weakCompareAndSetVolatile int");
         }
 
         // Compare set and get
@@ -349,36 +361,48 @@
         }
 
         {
-            boolean r = (boolean) hs.get(TestAccessMode.WEAK_COMPARE_AND_SET).invokeExact(1, 2);
-            assertEquals(r, true, "weakCompareAndSet int");
+            boolean success = false;
+            for (int c = 0; c < WEAK_ATTEMPTS && !success; c++) {
+                success = (boolean) hs.get(TestAccessMode.WEAK_COMPARE_AND_SET).invokeExact(1, 2);
+            }
+            assertEquals(success, true, "weakCompareAndSet int");
             int x = (int) hs.get(TestAccessMode.GET).invokeExact();
             assertEquals(x, 2, "weakCompareAndSet int value");
         }
 
         {
-            boolean r = (boolean) hs.get(TestAccessMode.WEAK_COMPARE_AND_SET_ACQUIRE).invokeExact(2, 1);
-            assertEquals(r, true, "weakCompareAndSetAcquire int");
+            boolean success = false;
+            for (int c = 0; c < WEAK_ATTEMPTS && !success; c++) {
+                success = (boolean) hs.get(TestAccessMode.WEAK_COMPARE_AND_SET_ACQUIRE).invokeExact(2, 1);
+            }
+            assertEquals(success, true, "weakCompareAndSetAcquire int");
             int x = (int) hs.get(TestAccessMode.GET).invokeExact();
             assertEquals(x, 1, "weakCompareAndSetAcquire int");
         }
 
         {
-            boolean r = (boolean) hs.get(TestAccessMode.WEAK_COMPARE_AND_SET_RELEASE).invokeExact(1, 2);
-            assertEquals(r, true, "weakCompareAndSetRelease int");
+            boolean success = false;
+            for (int c = 0; c < WEAK_ATTEMPTS && !success; c++) {
+                success = (boolean) hs.get(TestAccessMode.WEAK_COMPARE_AND_SET_RELEASE).invokeExact(1, 2);
+            }
+            assertEquals(success, true, "weakCompareAndSetRelease int");
             int x = (int) hs.get(TestAccessMode.GET).invokeExact();
             assertEquals(x, 2, "weakCompareAndSetRelease int");
         }
 
         {
-            boolean r = (boolean) hs.get(TestAccessMode.WEAK_COMPARE_AND_SET_VOLATILE).invokeExact(2, 1);
-            assertEquals(r, true, "weakCompareAndSetVolatile int");
+            boolean success = false;
+            for (int c = 0; c < WEAK_ATTEMPTS && !success; c++) {
+                success = (boolean) hs.get(TestAccessMode.WEAK_COMPARE_AND_SET_VOLATILE).invokeExact(2, 1);
+            }
+            assertEquals(success, true, "weakCompareAndSetVolatile int");
             int x = (int) hs.get(TestAccessMode.GET).invokeExact();
-            assertEquals(x, 1, "weakCompareAndSetVolatile int value");
+            assertEquals(x, 1, "weakCompareAndSetVolatile int");
         }
 
         // Compare set and get
         {
-            int o = (int) hs.get(TestAccessMode.GET_AND_SET).invokeExact(2);
+            int o = (int) hs.get(TestAccessMode.GET_AND_SET).invokeExact( 2);
             assertEquals(o, 1, "getAndSet int");
             int x = (int) hs.get(TestAccessMode.GET).invokeExact();
             assertEquals(x, 2, "getAndSet int value");
@@ -493,31 +517,43 @@
             }
 
             {
-                boolean r = (boolean) hs.get(TestAccessMode.WEAK_COMPARE_AND_SET).invokeExact(array, i, 1, 2);
-                assertEquals(r, true, "weakCompareAndSet int");
+                boolean success = false;
+                for (int c = 0; c < WEAK_ATTEMPTS && !success; c++) {
+                    success = (boolean) hs.get(TestAccessMode.WEAK_COMPARE_AND_SET).invokeExact(array, i, 1, 2);
+                }
+                assertEquals(success, true, "weakCompareAndSet int");
                 int x = (int) hs.get(TestAccessMode.GET).invokeExact(array, i);
                 assertEquals(x, 2, "weakCompareAndSet int value");
             }
 
             {
-                boolean r = (boolean) hs.get(TestAccessMode.WEAK_COMPARE_AND_SET_ACQUIRE).invokeExact(array, i, 2, 1);
-                assertEquals(r, true, "weakCompareAndSetAcquire int");
+                boolean success = false;
+                for (int c = 0; c < WEAK_ATTEMPTS && !success; c++) {
+                    success = (boolean) hs.get(TestAccessMode.WEAK_COMPARE_AND_SET_ACQUIRE).invokeExact(array, i, 2, 1);
+                }
+                assertEquals(success, true, "weakCompareAndSetAcquire int");
                 int x = (int) hs.get(TestAccessMode.GET).invokeExact(array, i);
                 assertEquals(x, 1, "weakCompareAndSetAcquire int");
             }
 
             {
-                boolean r = (boolean) hs.get(TestAccessMode.WEAK_COMPARE_AND_SET_RELEASE).invokeExact(array, i, 1, 2);
-                assertEquals(r, true, "weakCompareAndSetRelease int");
+                boolean success = false;
+                for (int c = 0; c < WEAK_ATTEMPTS && !success; c++) {
+                    success = (boolean) hs.get(TestAccessMode.WEAK_COMPARE_AND_SET_RELEASE).invokeExact(array, i, 1, 2);
+                }
+                assertEquals(success, true, "weakCompareAndSetRelease int");
                 int x = (int) hs.get(TestAccessMode.GET).invokeExact(array, i);
                 assertEquals(x, 2, "weakCompareAndSetRelease int");
             }
 
             {
-                boolean r = (boolean) hs.get(TestAccessMode.WEAK_COMPARE_AND_SET_VOLATILE).invokeExact(array, i, 2, 1);
-                assertEquals(r, true, "weakCompareAndSetVolatile int");
+                boolean success = false;
+                for (int c = 0; c < WEAK_ATTEMPTS && !success; c++) {
+                    success = (boolean) hs.get(TestAccessMode.WEAK_COMPARE_AND_SET_VOLATILE).invokeExact(array, i, 2, 1);
+                }
+                assertEquals(success, true, "weakCompareAndSetVolatile int");
                 int x = (int) hs.get(TestAccessMode.GET).invokeExact(array, i);
-                assertEquals(x, 1, "weakCompareAndSetVolatile int value");
+                assertEquals(x, 1, "weakCompareAndSetVolatile int");
             }
 
             // Compare set and get
--- a/jdk/test/java/lang/invoke/VarHandles/VarHandleTestMethodHandleAccessLong.java	Thu May 19 17:48:02 2016 +0000
+++ b/jdk/test/java/lang/invoke/VarHandles/VarHandleTestMethodHandleAccessLong.java	Thu May 19 19:46:20 2016 +0000
@@ -208,31 +208,43 @@
         }
 
         {
-            boolean r = (boolean) hs.get(TestAccessMode.WEAK_COMPARE_AND_SET).invokeExact(recv, 1L, 2L);
-            assertEquals(r, true, "weakCompareAndSet long");
+            boolean success = false;
+            for (int c = 0; c < WEAK_ATTEMPTS && !success; c++) {
+                success = (boolean) hs.get(TestAccessMode.WEAK_COMPARE_AND_SET).invokeExact(recv, 1L, 2L);
+            }
+            assertEquals(success, true, "weakCompareAndSet long");
             long x = (long) hs.get(TestAccessMode.GET).invokeExact(recv);
             assertEquals(x, 2L, "weakCompareAndSet long value");
         }
 
         {
-            boolean r = (boolean) hs.get(TestAccessMode.WEAK_COMPARE_AND_SET_ACQUIRE).invokeExact(recv, 2L, 1L);
-            assertEquals(r, true, "weakCompareAndSetAcquire long");
+            boolean success = false;
+            for (int c = 0; c < WEAK_ATTEMPTS && !success; c++) {
+                success = (boolean) hs.get(TestAccessMode.WEAK_COMPARE_AND_SET_ACQUIRE).invokeExact(recv, 2L, 1L);
+            }
+            assertEquals(success, true, "weakCompareAndSetAcquire long");
             long x = (long) hs.get(TestAccessMode.GET).invokeExact(recv);
             assertEquals(x, 1L, "weakCompareAndSetAcquire long");
         }
 
         {
-            boolean r = (boolean) hs.get(TestAccessMode.WEAK_COMPARE_AND_SET_RELEASE).invokeExact(recv, 1L, 2L);
-            assertEquals(r, true, "weakCompareAndSetRelease long");
+            boolean success = false;
+            for (int c = 0; c < WEAK_ATTEMPTS && !success; c++) {
+                success = (boolean) hs.get(TestAccessMode.WEAK_COMPARE_AND_SET_RELEASE).invokeExact(recv, 1L, 2L);
+            }
+            assertEquals(success, true, "weakCompareAndSetRelease long");
             long x = (long) hs.get(TestAccessMode.GET).invokeExact(recv);
             assertEquals(x, 2L, "weakCompareAndSetRelease long");
         }
 
         {
-            boolean r = (boolean) hs.get(TestAccessMode.WEAK_COMPARE_AND_SET_VOLATILE).invokeExact(recv, 2L, 1L);
-            assertEquals(r, true, "weakCompareAndSetVolatile long");
+            boolean success = false;
+            for (int c = 0; c < WEAK_ATTEMPTS && !success; c++) {
+                success = (boolean) hs.get(TestAccessMode.WEAK_COMPARE_AND_SET_VOLATILE).invokeExact(recv, 2L, 1L);
+            }
+            assertEquals(success, true, "weakCompareAndSetVolatile long");
             long x = (long) hs.get(TestAccessMode.GET).invokeExact(recv);
-            assertEquals(x, 1L, "weakCompareAndSetVolatile long value");
+            assertEquals(x, 1L, "weakCompareAndSetVolatile long");
         }
 
         // Compare set and get
@@ -349,36 +361,48 @@
         }
 
         {
-            boolean r = (boolean) hs.get(TestAccessMode.WEAK_COMPARE_AND_SET).invokeExact(1L, 2L);
-            assertEquals(r, true, "weakCompareAndSet long");
+            boolean success = false;
+            for (int c = 0; c < WEAK_ATTEMPTS && !success; c++) {
+                success = (boolean) hs.get(TestAccessMode.WEAK_COMPARE_AND_SET).invokeExact(1L, 2L);
+            }
+            assertEquals(success, true, "weakCompareAndSet long");
             long x = (long) hs.get(TestAccessMode.GET).invokeExact();
             assertEquals(x, 2L, "weakCompareAndSet long value");
         }
 
         {
-            boolean r = (boolean) hs.get(TestAccessMode.WEAK_COMPARE_AND_SET_ACQUIRE).invokeExact(2L, 1L);
-            assertEquals(r, true, "weakCompareAndSetAcquire long");
+            boolean success = false;
+            for (int c = 0; c < WEAK_ATTEMPTS && !success; c++) {
+                success = (boolean) hs.get(TestAccessMode.WEAK_COMPARE_AND_SET_ACQUIRE).invokeExact(2L, 1L);
+            }
+            assertEquals(success, true, "weakCompareAndSetAcquire long");
             long x = (long) hs.get(TestAccessMode.GET).invokeExact();
             assertEquals(x, 1L, "weakCompareAndSetAcquire long");
         }
 
         {
-            boolean r = (boolean) hs.get(TestAccessMode.WEAK_COMPARE_AND_SET_RELEASE).invokeExact(1L, 2L);
-            assertEquals(r, true, "weakCompareAndSetRelease long");
+            boolean success = false;
+            for (int c = 0; c < WEAK_ATTEMPTS && !success; c++) {
+                success = (boolean) hs.get(TestAccessMode.WEAK_COMPARE_AND_SET_RELEASE).invokeExact(1L, 2L);
+            }
+            assertEquals(success, true, "weakCompareAndSetRelease long");
             long x = (long) hs.get(TestAccessMode.GET).invokeExact();
             assertEquals(x, 2L, "weakCompareAndSetRelease long");
         }
 
         {
-            boolean r = (boolean) hs.get(TestAccessMode.WEAK_COMPARE_AND_SET_VOLATILE).invokeExact(2L, 1L);
-            assertEquals(r, true, "weakCompareAndSetVolatile long");
+            boolean success = false;
+            for (int c = 0; c < WEAK_ATTEMPTS && !success; c++) {
+                success = (boolean) hs.get(TestAccessMode.WEAK_COMPARE_AND_SET_VOLATILE).invokeExact(2L, 1L);
+            }
+            assertEquals(success, true, "weakCompareAndSetVolatile long");
             long x = (long) hs.get(TestAccessMode.GET).invokeExact();
-            assertEquals(x, 1L, "weakCompareAndSetVolatile long value");
+            assertEquals(x, 1L, "weakCompareAndSetVolatile long");
         }
 
         // Compare set and get
         {
-            long o = (long) hs.get(TestAccessMode.GET_AND_SET).invokeExact(2L);
+            long o = (long) hs.get(TestAccessMode.GET_AND_SET).invokeExact( 2L);
             assertEquals(o, 1L, "getAndSet long");
             long x = (long) hs.get(TestAccessMode.GET).invokeExact();
             assertEquals(x, 2L, "getAndSet long value");
@@ -493,31 +517,43 @@
             }
 
             {
-                boolean r = (boolean) hs.get(TestAccessMode.WEAK_COMPARE_AND_SET).invokeExact(array, i, 1L, 2L);
-                assertEquals(r, true, "weakCompareAndSet long");
+                boolean success = false;
+                for (int c = 0; c < WEAK_ATTEMPTS && !success; c++) {
+                    success = (boolean) hs.get(TestAccessMode.WEAK_COMPARE_AND_SET).invokeExact(array, i, 1L, 2L);
+                }
+                assertEquals(success, true, "weakCompareAndSet long");
                 long x = (long) hs.get(TestAccessMode.GET).invokeExact(array, i);
                 assertEquals(x, 2L, "weakCompareAndSet long value");
             }
 
             {
-                boolean r = (boolean) hs.get(TestAccessMode.WEAK_COMPARE_AND_SET_ACQUIRE).invokeExact(array, i, 2L, 1L);
-                assertEquals(r, true, "weakCompareAndSetAcquire long");
+                boolean success = false;
+                for (int c = 0; c < WEAK_ATTEMPTS && !success; c++) {
+                    success = (boolean) hs.get(TestAccessMode.WEAK_COMPARE_AND_SET_ACQUIRE).invokeExact(array, i, 2L, 1L);
+                }
+                assertEquals(success, true, "weakCompareAndSetAcquire long");
                 long x = (long) hs.get(TestAccessMode.GET).invokeExact(array, i);
                 assertEquals(x, 1L, "weakCompareAndSetAcquire long");
             }
 
             {
-                boolean r = (boolean) hs.get(TestAccessMode.WEAK_COMPARE_AND_SET_RELEASE).invokeExact(array, i, 1L, 2L);
-                assertEquals(r, true, "weakCompareAndSetRelease long");
+                boolean success = false;
+                for (int c = 0; c < WEAK_ATTEMPTS && !success; c++) {
+                    success = (boolean) hs.get(TestAccessMode.WEAK_COMPARE_AND_SET_RELEASE).invokeExact(array, i, 1L, 2L);
+                }
+                assertEquals(success, true, "weakCompareAndSetRelease long");
                 long x = (long) hs.get(TestAccessMode.GET).invokeExact(array, i);
                 assertEquals(x, 2L, "weakCompareAndSetRelease long");
             }
 
             {
-                boolean r = (boolean) hs.get(TestAccessMode.WEAK_COMPARE_AND_SET_VOLATILE).invokeExact(array, i, 2L, 1L);
-                assertEquals(r, true, "weakCompareAndSetVolatile long");
+                boolean success = false;
+                for (int c = 0; c < WEAK_ATTEMPTS && !success; c++) {
+                    success = (boolean) hs.get(TestAccessMode.WEAK_COMPARE_AND_SET_VOLATILE).invokeExact(array, i, 2L, 1L);
+                }
+                assertEquals(success, true, "weakCompareAndSetVolatile long");
                 long x = (long) hs.get(TestAccessMode.GET).invokeExact(array, i);
-                assertEquals(x, 1L, "weakCompareAndSetVolatile long value");
+                assertEquals(x, 1L, "weakCompareAndSetVolatile long");
             }
 
             // Compare set and get
--- a/jdk/test/java/lang/invoke/VarHandles/VarHandleTestMethodHandleAccessString.java	Thu May 19 17:48:02 2016 +0000
+++ b/jdk/test/java/lang/invoke/VarHandles/VarHandleTestMethodHandleAccessString.java	Thu May 19 19:46:20 2016 +0000
@@ -208,31 +208,43 @@
         }
 
         {
-            boolean r = (boolean) hs.get(TestAccessMode.WEAK_COMPARE_AND_SET).invokeExact(recv, "foo", "bar");
-            assertEquals(r, true, "weakCompareAndSet String");
+            boolean success = false;
+            for (int c = 0; c < WEAK_ATTEMPTS && !success; c++) {
+                success = (boolean) hs.get(TestAccessMode.WEAK_COMPARE_AND_SET).invokeExact(recv, "foo", "bar");
+            }
+            assertEquals(success, true, "weakCompareAndSet String");
             String x = (String) hs.get(TestAccessMode.GET).invokeExact(recv);
             assertEquals(x, "bar", "weakCompareAndSet String value");
         }
 
         {
-            boolean r = (boolean) hs.get(TestAccessMode.WEAK_COMPARE_AND_SET_ACQUIRE).invokeExact(recv, "bar", "foo");
-            assertEquals(r, true, "weakCompareAndSetAcquire String");
+            boolean success = false;
+            for (int c = 0; c < WEAK_ATTEMPTS && !success; c++) {
+                success = (boolean) hs.get(TestAccessMode.WEAK_COMPARE_AND_SET_ACQUIRE).invokeExact(recv, "bar", "foo");
+            }
+            assertEquals(success, true, "weakCompareAndSetAcquire String");
             String x = (String) hs.get(TestAccessMode.GET).invokeExact(recv);
             assertEquals(x, "foo", "weakCompareAndSetAcquire String");
         }
 
         {
-            boolean r = (boolean) hs.get(TestAccessMode.WEAK_COMPARE_AND_SET_RELEASE).invokeExact(recv, "foo", "bar");
-            assertEquals(r, true, "weakCompareAndSetRelease String");
+            boolean success = false;
+            for (int c = 0; c < WEAK_ATTEMPTS && !success; c++) {
+                success = (boolean) hs.get(TestAccessMode.WEAK_COMPARE_AND_SET_RELEASE).invokeExact(recv, "foo", "bar");
+            }
+            assertEquals(success, true, "weakCompareAndSetRelease String");
             String x = (String) hs.get(TestAccessMode.GET).invokeExact(recv);
             assertEquals(x, "bar", "weakCompareAndSetRelease String");
         }
 
         {
-            boolean r = (boolean) hs.get(TestAccessMode.WEAK_COMPARE_AND_SET_VOLATILE).invokeExact(recv, "bar", "foo");
-            assertEquals(r, true, "weakCompareAndSetVolatile String");
+            boolean success = false;
+            for (int c = 0; c < WEAK_ATTEMPTS && !success; c++) {
+                success = (boolean) hs.get(TestAccessMode.WEAK_COMPARE_AND_SET_VOLATILE).invokeExact(recv, "bar", "foo");
+            }
+            assertEquals(success, true, "weakCompareAndSetVolatile String");
             String x = (String) hs.get(TestAccessMode.GET).invokeExact(recv);
-            assertEquals(x, "foo", "weakCompareAndSetVolatile String value");
+            assertEquals(x, "foo", "weakCompareAndSetVolatile String");
         }
 
         // Compare set and get
@@ -345,36 +357,48 @@
         }
 
         {
-            boolean r = (boolean) hs.get(TestAccessMode.WEAK_COMPARE_AND_SET).invokeExact("foo", "bar");
-            assertEquals(r, true, "weakCompareAndSet String");
+            boolean success = false;
+            for (int c = 0; c < WEAK_ATTEMPTS && !success; c++) {
+                success = (boolean) hs.get(TestAccessMode.WEAK_COMPARE_AND_SET).invokeExact("foo", "bar");
+            }
+            assertEquals(success, true, "weakCompareAndSet String");
             String x = (String) hs.get(TestAccessMode.GET).invokeExact();
             assertEquals(x, "bar", "weakCompareAndSet String value");
         }
 
         {
-            boolean r = (boolean) hs.get(TestAccessMode.WEAK_COMPARE_AND_SET_ACQUIRE).invokeExact("bar", "foo");
-            assertEquals(r, true, "weakCompareAndSetAcquire String");
+            boolean success = false;
+            for (int c = 0; c < WEAK_ATTEMPTS && !success; c++) {
+                success = (boolean) hs.get(TestAccessMode.WEAK_COMPARE_AND_SET_ACQUIRE).invokeExact("bar", "foo");
+            }
+            assertEquals(success, true, "weakCompareAndSetAcquire String");
             String x = (String) hs.get(TestAccessMode.GET).invokeExact();
             assertEquals(x, "foo", "weakCompareAndSetAcquire String");
         }
 
         {
-            boolean r = (boolean) hs.get(TestAccessMode.WEAK_COMPARE_AND_SET_RELEASE).invokeExact("foo", "bar");
-            assertEquals(r, true, "weakCompareAndSetRelease String");
+            boolean success = false;
+            for (int c = 0; c < WEAK_ATTEMPTS && !success; c++) {
+                success = (boolean) hs.get(TestAccessMode.WEAK_COMPARE_AND_SET_RELEASE).invokeExact("foo", "bar");
+            }
+            assertEquals(success, true, "weakCompareAndSetRelease String");
             String x = (String) hs.get(TestAccessMode.GET).invokeExact();
             assertEquals(x, "bar", "weakCompareAndSetRelease String");
         }
 
         {
-            boolean r = (boolean) hs.get(TestAccessMode.WEAK_COMPARE_AND_SET_VOLATILE).invokeExact("bar", "foo");
-            assertEquals(r, true, "weakCompareAndSetVolatile String");
+            boolean success = false;
+            for (int c = 0; c < WEAK_ATTEMPTS && !success; c++) {
+                success = (boolean) hs.get(TestAccessMode.WEAK_COMPARE_AND_SET_VOLATILE).invokeExact("bar", "foo");
+            }
+            assertEquals(success, true, "weakCompareAndSetVolatile String");
             String x = (String) hs.get(TestAccessMode.GET).invokeExact();
-            assertEquals(x, "foo", "weakCompareAndSetVolatile String value");
+            assertEquals(x, "foo", "weakCompareAndSetVolatile String");
         }
 
         // Compare set and get
         {
-            String o = (String) hs.get(TestAccessMode.GET_AND_SET).invokeExact("bar");
+            String o = (String) hs.get(TestAccessMode.GET_AND_SET).invokeExact( "bar");
             assertEquals(o, "foo", "getAndSet String");
             String x = (String) hs.get(TestAccessMode.GET).invokeExact();
             assertEquals(x, "bar", "getAndSet String value");
@@ -485,31 +509,43 @@
             }
 
             {
-                boolean r = (boolean) hs.get(TestAccessMode.WEAK_COMPARE_AND_SET).invokeExact(array, i, "foo", "bar");
-                assertEquals(r, true, "weakCompareAndSet String");
+                boolean success = false;
+                for (int c = 0; c < WEAK_ATTEMPTS && !success; c++) {
+                    success = (boolean) hs.get(TestAccessMode.WEAK_COMPARE_AND_SET).invokeExact(array, i, "foo", "bar");
+                }
+                assertEquals(success, true, "weakCompareAndSet String");
                 String x = (String) hs.get(TestAccessMode.GET).invokeExact(array, i);
                 assertEquals(x, "bar", "weakCompareAndSet String value");
             }
 
             {
-                boolean r = (boolean) hs.get(TestAccessMode.WEAK_COMPARE_AND_SET_ACQUIRE).invokeExact(array, i, "bar", "foo");
-                assertEquals(r, true, "weakCompareAndSetAcquire String");
+                boolean success = false;
+                for (int c = 0; c < WEAK_ATTEMPTS && !success; c++) {
+                    success = (boolean) hs.get(TestAccessMode.WEAK_COMPARE_AND_SET_ACQUIRE).invokeExact(array, i, "bar", "foo");
+                }
+                assertEquals(success, true, "weakCompareAndSetAcquire String");
                 String x = (String) hs.get(TestAccessMode.GET).invokeExact(array, i);
                 assertEquals(x, "foo", "weakCompareAndSetAcquire String");
             }
 
             {
-                boolean r = (boolean) hs.get(TestAccessMode.WEAK_COMPARE_AND_SET_RELEASE).invokeExact(array, i, "foo", "bar");
-                assertEquals(r, true, "weakCompareAndSetRelease String");
+                boolean success = false;
+                for (int c = 0; c < WEAK_ATTEMPTS && !success; c++) {
+                    success = (boolean) hs.get(TestAccessMode.WEAK_COMPARE_AND_SET_RELEASE).invokeExact(array, i, "foo", "bar");
+                }
+                assertEquals(success, true, "weakCompareAndSetRelease String");
                 String x = (String) hs.get(TestAccessMode.GET).invokeExact(array, i);
                 assertEquals(x, "bar", "weakCompareAndSetRelease String");
             }
 
             {
-                boolean r = (boolean) hs.get(TestAccessMode.WEAK_COMPARE_AND_SET_VOLATILE).invokeExact(array, i, "bar", "foo");
-                assertEquals(r, true, "weakCompareAndSetVolatile String");
+                boolean success = false;
+                for (int c = 0; c < WEAK_ATTEMPTS && !success; c++) {
+                    success = (boolean) hs.get(TestAccessMode.WEAK_COMPARE_AND_SET_VOLATILE).invokeExact(array, i, "bar", "foo");
+                }
+                assertEquals(success, true, "weakCompareAndSetVolatile String");
                 String x = (String) hs.get(TestAccessMode.GET).invokeExact(array, i);
-                assertEquals(x, "foo", "weakCompareAndSetVolatile String value");
+                assertEquals(x, "foo", "weakCompareAndSetVolatile String");
             }
 
             // Compare set and get
--- a/jdk/test/java/lang/invoke/VarHandles/VarHandleTestMethodTypeBoolean.java	Thu May 19 17:48:02 2016 +0000
+++ b/jdk/test/java/lang/invoke/VarHandles/VarHandleTestMethodTypeBoolean.java	Thu May 19 19:46:20 2016 +0000
@@ -23,6 +23,7 @@
 
 /*
  * @test
+ * @bug 8156486
  * @run testng/othervm VarHandleTestMethodTypeBoolean
  * @run testng/othervm -Djava.lang.invoke.VarHandle.VAR_HANDLE_GUARDS=false VarHandleTestMethodTypeBoolean
  */
@@ -81,27 +82,28 @@
     public Object[][] accessTestCaseProvider() throws Exception {
         List<AccessTestCase<?>> cases = new ArrayList<>();
 
-        cases.add(new VarHandleAccessTestCase("Instance field wrong method type",
+        cases.add(new VarHandleAccessTestCase("Instance field",
                                               vhField, vh -> testInstanceFieldWrongMethodType(this, vh),
                                               false));
 
-        cases.add(new VarHandleAccessTestCase("Static field wrong method type",
+        cases.add(new VarHandleAccessTestCase("Static field",
                                               vhStaticField, VarHandleTestMethodTypeBoolean::testStaticFieldWrongMethodType,
                                               false));
 
-        cases.add(new VarHandleAccessTestCase("Array wrong method type",
+        cases.add(new VarHandleAccessTestCase("Array",
                                               vhArray, VarHandleTestMethodTypeBoolean::testArrayWrongMethodType,
                                               false));
+
         for (VarHandleToMethodHandle f : VarHandleToMethodHandle.values()) {
-            cases.add(new MethodHandleAccessTestCase("Instance field wrong method type",
+            cases.add(new MethodHandleAccessTestCase("Instance field",
                                                      vhField, f, hs -> testInstanceFieldWrongMethodType(this, hs),
                                                      false));
 
-            cases.add(new MethodHandleAccessTestCase("Static field wrong method type",
+            cases.add(new MethodHandleAccessTestCase("Static field",
                                                      vhStaticField, f, VarHandleTestMethodTypeBoolean::testStaticFieldWrongMethodType,
                                                      false));
 
-            cases.add(new MethodHandleAccessTestCase("Array wrong method type",
+            cases.add(new MethodHandleAccessTestCase("Array",
                                                      vhArray, f, VarHandleTestMethodTypeBoolean::testArrayWrongMethodType,
                                                      false));
         }
@@ -329,63 +331,63 @@
         for (TestAccessMode am : testAccessModesOfType(TestAccessType.GET)) {
             // Incorrect argument types
             checkNPE(() -> { // null receiver
-                boolean x = (boolean) hs.get(am, methodType(boolean.class, Void.class)).
-                    invoke(null);
+                boolean x = (boolean) hs.get(am, methodType(boolean.class, VarHandleTestMethodTypeBoolean.class)).
+                    invokeExact((VarHandleTestMethodTypeBoolean) null);
             });
-            checkCCE(() -> { // receiver reference class
+            hs.checkWMTEOrCCE(() -> { // receiver reference class
                 boolean x = (boolean) hs.get(am, methodType(boolean.class, Class.class)).
-                    invoke(Void.class);
+                    invokeExact(Void.class);
             });
             checkWMTE(() -> { // receiver primitive class
                 boolean x = (boolean) hs.get(am, methodType(boolean.class, int.class)).
-                    invoke(0);
+                    invokeExact(0);
             });
             // Incorrect return type
             checkWMTE(() -> { // reference class
-                Void x = (Void) hs.get(am, methodType(boolean.class, VarHandleTestMethodTypeBoolean.class)).
-                    invoke(recv);
+                Void x = (Void) hs.get(am, methodType(Void.class, VarHandleTestMethodTypeBoolean.class)).
+                    invokeExact(recv);
             });
             checkWMTE(() -> { // primitive class
                 int x = (int) hs.get(am, methodType(int.class, VarHandleTestMethodTypeBoolean.class)).
-                    invoke(recv);
+                    invokeExact(recv);
             });
             // Incorrect arity
             checkWMTE(() -> { // 0
                 boolean x = (boolean) hs.get(am, methodType(boolean.class)).
-                    invoke();
+                    invokeExact();
             });
             checkWMTE(() -> { // >
                 boolean x = (boolean) hs.get(am, methodType(boolean.class, VarHandleTestMethodTypeBoolean.class, Class.class)).
-                    invoke(recv, Void.class);
+                    invokeExact(recv, Void.class);
             });
         }
 
         for (TestAccessMode am : testAccessModesOfType(TestAccessType.SET)) {
             // Incorrect argument types
             checkNPE(() -> { // null receiver
-                hs.get(am, methodType(void.class, Void.class, boolean.class)).
-                    invoke(null, true);
+                hs.get(am, methodType(void.class, VarHandleTestMethodTypeBoolean.class, boolean.class)).
+                    invokeExact((VarHandleTestMethodTypeBoolean) null, true);
             });
-            checkCCE(() -> { // receiver reference class
+            hs.checkWMTEOrCCE(() -> { // receiver reference class
                 hs.get(am, methodType(void.class, Class.class, boolean.class)).
-                    invoke(Void.class, true);
+                    invokeExact(Void.class, true);
             });
             checkWMTE(() -> { // value reference class
                 hs.get(am, methodType(void.class, VarHandleTestMethodTypeBoolean.class, Class.class)).
-                    invoke(recv, Void.class);
+                    invokeExact(recv, Void.class);
             });
             checkWMTE(() -> { // receiver primitive class
                 hs.get(am, methodType(void.class, int.class, boolean.class)).
-                    invoke(0, true);
+                    invokeExact(0, true);
             });
             // Incorrect arity
             checkWMTE(() -> { // 0
                 hs.get(am, methodType(void.class)).
-                    invoke();
+                    invokeExact();
             });
             checkWMTE(() -> { // >
                 hs.get(am, methodType(void.class, VarHandleTestMethodTypeBoolean.class, boolean.class, Class.class)).
-                    invoke(recv, true, Void.class);
+                    invokeExact(recv, true, Void.class);
             });
         }
 
@@ -513,32 +515,32 @@
             // Incorrect return type
             checkWMTE(() -> { // reference class
                 Void x = (Void) hs.get(am, methodType(Void.class)).
-                    invoke();
+                    invokeExact();
             });
             checkWMTE(() -> { // primitive class
                 int x = (int) hs.get(am, methodType(int.class)).
-                    invoke();
+                    invokeExact();
             });
             // Incorrect arity
             checkWMTE(() -> { // >
                 boolean x = (boolean) hs.get(am, methodType(Class.class)).
-                    invoke(Void.class);
+                    invokeExact(Void.class);
             });
         }
 
         for (TestAccessMode am : testAccessModesOfType(TestAccessType.SET)) {
             checkWMTE(() -> { // value reference class
                 hs.get(am, methodType(void.class, Class.class)).
-                    invoke(Void.class);
+                    invokeExact(Void.class);
             });
             // Incorrect arity
             checkWMTE(() -> { // 0
                 hs.get(am, methodType(void.class)).
-                    invoke();
+                    invokeExact();
             });
             checkWMTE(() -> { // >
                 hs.get(am, methodType(void.class, boolean.class, Class.class)).
-                    invoke(true, Void.class);
+                    invokeExact(true, Void.class);
             });
         }
 
@@ -783,71 +785,71 @@
         for (TestAccessMode am : testAccessModesOfType(TestAccessType.GET)) {
             // Incorrect argument types
             checkNPE(() -> { // null array
-                boolean x = (boolean) hs.get(am, methodType(boolean.class, Void.class, int.class)).
-                    invoke(null, 0);
+                boolean x = (boolean) hs.get(am, methodType(boolean.class, boolean[].class, int.class)).
+                    invokeExact((boolean[]) null, 0);
             });
-            checkCCE(() -> { // array reference class
+            hs.checkWMTEOrCCE(() -> { // array reference class
                 boolean x = (boolean) hs.get(am, methodType(boolean.class, Class.class, int.class)).
-                    invoke(Void.class, 0);
+                    invokeExact(Void.class, 0);
             });
             checkWMTE(() -> { // array primitive class
                 boolean x = (boolean) hs.get(am, methodType(boolean.class, int.class, int.class)).
-                    invoke(0, 0);
+                    invokeExact(0, 0);
             });
             checkWMTE(() -> { // index reference class
                 boolean x = (boolean) hs.get(am, methodType(boolean.class, boolean[].class, Class.class)).
-                    invoke(array, Void.class);
+                    invokeExact(array, Void.class);
             });
             // Incorrect return type
             checkWMTE(() -> { // reference class
                 Void x = (Void) hs.get(am, methodType(Void.class, boolean[].class, int.class)).
-                    invoke(array, 0);
+                    invokeExact(array, 0);
             });
             checkWMTE(() -> { // primitive class
                 int x = (int) hs.get(am, methodType(int.class, boolean[].class, int.class)).
-                    invoke(array, 0);
+                    invokeExact(array, 0);
             });
             // Incorrect arity
             checkWMTE(() -> { // 0
                 boolean x = (boolean) hs.get(am, methodType(boolean.class)).
-                    invoke();
+                    invokeExact();
             });
             checkWMTE(() -> { // >
                 boolean x = (boolean) hs.get(am, methodType(boolean.class, boolean[].class, int.class, Class.class)).
-                    invoke(array, 0, Void.class);
+                    invokeExact(array, 0, Void.class);
             });
         }
 
         for (TestAccessMode am : testAccessModesOfType(TestAccessType.SET)) {
             // Incorrect argument types
             checkNPE(() -> { // null array
-                hs.get(am, methodType(void.class, Void.class, int.class, boolean.class)).
-                    invoke(null, 0, true);
+                hs.get(am, methodType(void.class, boolean[].class, int.class, boolean.class)).
+                    invokeExact((boolean[]) null, 0, true);
             });
-            checkCCE(() -> { // array reference class
+            hs.checkWMTEOrCCE(() -> { // array reference class
                 hs.get(am, methodType(void.class, Class.class, int.class, boolean.class)).
-                    invoke(Void.class, 0, true);
+                    invokeExact(Void.class, 0, true);
             });
             checkWMTE(() -> { // value reference class
                 hs.get(am, methodType(void.class, boolean[].class, int.class, Class.class)).
-                    invoke(array, 0, Void.class);
+                    invokeExact(array, 0, Void.class);
             });
             checkWMTE(() -> { // receiver primitive class
                 hs.get(am, methodType(void.class, int.class, int.class, boolean.class)).
-                    invoke(0, 0, true);
+                    invokeExact(0, 0, true);
             });
             checkWMTE(() -> { // index reference class
                 hs.get(am, methodType(void.class, boolean[].class, Class.class, boolean.class)).
-                    invoke(array, Void.class, true);
+                    invokeExact(array, Void.class, true);
             });
             // Incorrect arity
             checkWMTE(() -> { // 0
                 hs.get(am, methodType(void.class)).
-                    invoke();
+                    invokeExact();
             });
             checkWMTE(() -> { // >
                 hs.get(am, methodType(void.class, boolean[].class, int.class, Class.class)).
-                    invoke(array, 0, true, Void.class);
+                    invokeExact(array, 0, true, Void.class);
             });
         }
 
--- a/jdk/test/java/lang/invoke/VarHandles/VarHandleTestMethodTypeByte.java	Thu May 19 17:48:02 2016 +0000
+++ b/jdk/test/java/lang/invoke/VarHandles/VarHandleTestMethodTypeByte.java	Thu May 19 19:46:20 2016 +0000
@@ -23,6 +23,7 @@
 
 /*
  * @test
+ * @bug 8156486
  * @run testng/othervm VarHandleTestMethodTypeByte
  * @run testng/othervm -Djava.lang.invoke.VarHandle.VAR_HANDLE_GUARDS=false VarHandleTestMethodTypeByte
  */
@@ -81,27 +82,28 @@
     public Object[][] accessTestCaseProvider() throws Exception {
         List<AccessTestCase<?>> cases = new ArrayList<>();
 
-        cases.add(new VarHandleAccessTestCase("Instance field wrong method type",
+        cases.add(new VarHandleAccessTestCase("Instance field",
                                               vhField, vh -> testInstanceFieldWrongMethodType(this, vh),
                                               false));
 
-        cases.add(new VarHandleAccessTestCase("Static field wrong method type",
+        cases.add(new VarHandleAccessTestCase("Static field",
                                               vhStaticField, VarHandleTestMethodTypeByte::testStaticFieldWrongMethodType,
                                               false));
 
-        cases.add(new VarHandleAccessTestCase("Array wrong method type",
+        cases.add(new VarHandleAccessTestCase("Array",
                                               vhArray, VarHandleTestMethodTypeByte::testArrayWrongMethodType,
                                               false));
+
         for (VarHandleToMethodHandle f : VarHandleToMethodHandle.values()) {
-            cases.add(new MethodHandleAccessTestCase("Instance field wrong method type",
+            cases.add(new MethodHandleAccessTestCase("Instance field",
                                                      vhField, f, hs -> testInstanceFieldWrongMethodType(this, hs),
                                                      false));
 
-            cases.add(new MethodHandleAccessTestCase("Static field wrong method type",
+            cases.add(new MethodHandleAccessTestCase("Static field",
                                                      vhStaticField, f, VarHandleTestMethodTypeByte::testStaticFieldWrongMethodType,
                                                      false));
 
-            cases.add(new MethodHandleAccessTestCase("Array wrong method type",
+            cases.add(new MethodHandleAccessTestCase("Array",
                                                      vhArray, f, VarHandleTestMethodTypeByte::testArrayWrongMethodType,
                                                      false));
         }
@@ -329,63 +331,63 @@
         for (TestAccessMode am : testAccessModesOfType(TestAccessType.GET)) {
             // Incorrect argument types
             checkNPE(() -> { // null receiver
-                byte x = (byte) hs.get(am, methodType(byte.class, Void.class)).
-                    invoke(null);
+                byte x = (byte) hs.get(am, methodType(byte.class, VarHandleTestMethodTypeByte.class)).
+                    invokeExact((VarHandleTestMethodTypeByte) null);
             });
-            checkCCE(() -> { // receiver reference class
+            hs.checkWMTEOrCCE(() -> { // receiver reference class
                 byte x = (byte) hs.get(am, methodType(byte.class, Class.class)).
-                    invoke(Void.class);
+                    invokeExact(Void.class);
             });
             checkWMTE(() -> { // receiver primitive class
                 byte x = (byte) hs.get(am, methodType(byte.class, int.class)).
-                    invoke(0);
+                    invokeExact(0);
             });
             // Incorrect return type
             checkWMTE(() -> { // reference class
-                Void x = (Void) hs.get(am, methodType(byte.class, VarHandleTestMethodTypeByte.class)).
-                    invoke(recv);
+                Void x = (Void) hs.get(am, methodType(Void.class, VarHandleTestMethodTypeByte.class)).
+                    invokeExact(recv);
             });
             checkWMTE(() -> { // primitive class
                 boolean x = (boolean) hs.get(am, methodType(boolean.class, VarHandleTestMethodTypeByte.class)).
-                    invoke(recv);
+                    invokeExact(recv);
             });
             // Incorrect arity
             checkWMTE(() -> { // 0
                 byte x = (byte) hs.get(am, methodType(byte.class)).
-                    invoke();
+                    invokeExact();
             });
             checkWMTE(() -> { // >
                 byte x = (byte) hs.get(am, methodType(byte.class, VarHandleTestMethodTypeByte.class, Class.class)).
-                    invoke(recv, Void.class);
+                    invokeExact(recv, Void.class);
             });
         }
 
         for (TestAccessMode am : testAccessModesOfType(TestAccessType.SET)) {
             // Incorrect argument types
             checkNPE(() -> { // null receiver
-                hs.get(am, methodType(void.class, Void.class, byte.class)).
-                    invoke(null, (byte)1);
+                hs.get(am, methodType(void.class, VarHandleTestMethodTypeByte.class, byte.class)).
+                    invokeExact((VarHandleTestMethodTypeByte) null, (byte)1);
             });
-            checkCCE(() -> { // receiver reference class
+            hs.checkWMTEOrCCE(() -> { // receiver reference class
                 hs.get(am, methodType(void.class, Class.class, byte.class)).
-                    invoke(Void.class, (byte)1);
+                    invokeExact(Void.class, (byte)1);
             });
             checkWMTE(() -> { // value reference class
                 hs.get(am, methodType(void.class, VarHandleTestMethodTypeByte.class, Class.class)).
-                    invoke(recv, Void.class);
+                    invokeExact(recv, Void.class);
             });
             checkWMTE(() -> { // receiver primitive class
                 hs.get(am, methodType(void.class, int.class, byte.class)).
-                    invoke(0, (byte)1);
+                    invokeExact(0, (byte)1);
             });
             // Incorrect arity
             checkWMTE(() -> { // 0
                 hs.get(am, methodType(void.class)).
-                    invoke();
+                    invokeExact();
             });
             checkWMTE(() -> { // >
                 hs.get(am, methodType(void.class, VarHandleTestMethodTypeByte.class, byte.class, Class.class)).
-                    invoke(recv, (byte)1, Void.class);
+                    invokeExact(recv, (byte)1, Void.class);
             });
         }
 
@@ -513,32 +515,32 @@
             // Incorrect return type
             checkWMTE(() -> { // reference class
                 Void x = (Void) hs.get(am, methodType(Void.class)).
-                    invoke();
+                    invokeExact();
             });
             checkWMTE(() -> { // primitive class
                 boolean x = (boolean) hs.get(am, methodType(boolean.class)).
-                    invoke();
+                    invokeExact();
             });
             // Incorrect arity
             checkWMTE(() -> { // >
                 byte x = (byte) hs.get(am, methodType(Class.class)).
-                    invoke(Void.class);
+                    invokeExact(Void.class);
             });
         }
 
         for (TestAccessMode am : testAccessModesOfType(TestAccessType.SET)) {
             checkWMTE(() -> { // value reference class
                 hs.get(am, methodType(void.class, Class.class)).
-                    invoke(Void.class);
+                    invokeExact(Void.class);
             });
             // Incorrect arity
             checkWMTE(() -> { // 0
                 hs.get(am, methodType(void.class)).
-                    invoke();
+                    invokeExact();
             });
             checkWMTE(() -> { // >
                 hs.get(am, methodType(void.class, byte.class, Class.class)).
-                    invoke((byte)1, Void.class);
+                    invokeExact((byte)1, Void.class);
             });
         }
 
@@ -783,71 +785,71 @@
         for (TestAccessMode am : testAccessModesOfType(TestAccessType.GET)) {
             // Incorrect argument types
             checkNPE(() -> { // null array
-                byte x = (byte) hs.get(am, methodType(byte.class, Void.class, int.class)).
-                    invoke(null, 0);
+                byte x = (byte) hs.get(am, methodType(byte.class, byte[].class, int.class)).
+                    invokeExact((byte[]) null, 0);
             });
-            checkCCE(() -> { // array reference class
+            hs.checkWMTEOrCCE(() -> { // array reference class
                 byte x = (byte) hs.get(am, methodType(byte.class, Class.class, int.class)).
-                    invoke(Void.class, 0);
+                    invokeExact(Void.class, 0);
             });
             checkWMTE(() -> { // array primitive class
                 byte x = (byte) hs.get(am, methodType(byte.class, int.class, int.class)).
-                    invoke(0, 0);
+                    invokeExact(0, 0);
             });
             checkWMTE(() -> { // index reference class
                 byte x = (byte) hs.get(am, methodType(byte.class, byte[].class, Class.class)).
-                    invoke(array, Void.class);
+                    invokeExact(array, Void.class);
             });
             // Incorrect return type
             checkWMTE(() -> { // reference class
                 Void x = (Void) hs.get(am, methodType(Void.class, byte[].class, int.class)).
-                    invoke(array, 0);
+                    invokeExact(array, 0);
             });
             checkWMTE(() -> { // primitive class
                 boolean x = (boolean) hs.get(am, methodType(boolean.class, byte[].class, int.class)).
-                    invoke(array, 0);
+                    invokeExact(array, 0);
             });
             // Incorrect arity
             checkWMTE(() -> { // 0
                 byte x = (byte) hs.get(am, methodType(byte.class)).
-                    invoke();
+                    invokeExact();
             });
             checkWMTE(() -> { // >
                 byte x = (byte) hs.get(am, methodType(byte.class, byte[].class, int.class, Class.class)).
-                    invoke(array, 0, Void.class);
+                    invokeExact(array, 0, Void.class);
             });
         }
 
         for (TestAccessMode am : testAccessModesOfType(TestAccessType.SET)) {
             // Incorrect argument types
             checkNPE(() -> { // null array
-                hs.get(am, methodType(void.class, Void.class, int.class, byte.class)).
-                    invoke(null, 0, (byte)1);
+                hs.get(am, methodType(void.class, byte[].class, int.class, byte.class)).
+                    invokeExact((byte[]) null, 0, (byte)1);
             });
-            checkCCE(() -> { // array reference class
+            hs.checkWMTEOrCCE(() -> { // array reference class
                 hs.get(am, methodType(void.class, Class.class, int.class, byte.class)).
-                    invoke(Void.class, 0, (byte)1);
+                    invokeExact(Void.class, 0, (byte)1);
             });
             checkWMTE(() -> { // value reference class
                 hs.get(am, methodType(void.class, byte[].class, int.class, Class.class)).
-                    invoke(array, 0, Void.class);
+                    invokeExact(array, 0, Void.class);
             });
             checkWMTE(() -> { // receiver primitive class
                 hs.get(am, methodType(void.class, int.class, int.class, byte.class)).
-                    invoke(0, 0, (byte)1);
+                    invokeExact(0, 0, (byte)1);
             });
             checkWMTE(() -> { // index reference class
                 hs.get(am, methodType(void.class, byte[].class, Class.class, byte.class)).
-                    invoke(array, Void.class, (byte)1);
+                    invokeExact(array, Void.class, (byte)1);
             });
             // Incorrect arity
             checkWMTE(() -> { // 0
                 hs.get(am, methodType(void.class)).
-                    invoke();
+                    invokeExact();
             });
             checkWMTE(() -> { // >
                 hs.get(am, methodType(void.class, byte[].class, int.class, Class.class)).
-                    invoke(array, 0, (byte)1, Void.class);
+                    invokeExact(array, 0, (byte)1, Void.class);
             });
         }
 
--- a/jdk/test/java/lang/invoke/VarHandles/VarHandleTestMethodTypeChar.java	Thu May 19 17:48:02 2016 +0000
+++ b/jdk/test/java/lang/invoke/VarHandles/VarHandleTestMethodTypeChar.java	Thu May 19 19:46:20 2016 +0000
@@ -23,6 +23,7 @@
 
 /*
  * @test
+ * @bug 8156486
  * @run testng/othervm VarHandleTestMethodTypeChar
  * @run testng/othervm -Djava.lang.invoke.VarHandle.VAR_HANDLE_GUARDS=false VarHandleTestMethodTypeChar
  */
@@ -81,27 +82,28 @@
     public Object[][] accessTestCaseProvider() throws Exception {
         List<AccessTestCase<?>> cases = new ArrayList<>();
 
-        cases.add(new VarHandleAccessTestCase("Instance field wrong method type",
+        cases.add(new VarHandleAccessTestCase("Instance field",
                                               vhField, vh -> testInstanceFieldWrongMethodType(this, vh),
                                               false));
 
-        cases.add(new VarHandleAccessTestCase("Static field wrong method type",
+        cases.add(new VarHandleAccessTestCase("Static field",
                                               vhStaticField, VarHandleTestMethodTypeChar::testStaticFieldWrongMethodType,
                                               false));
 
-        cases.add(new VarHandleAccessTestCase("Array wrong method type",
+        cases.add(new VarHandleAccessTestCase("Array",
                                               vhArray, VarHandleTestMethodTypeChar::testArrayWrongMethodType,
                                               false));
+
         for (VarHandleToMethodHandle f : VarHandleToMethodHandle.values()) {
-            cases.add(new MethodHandleAccessTestCase("Instance field wrong method type",
+            cases.add(new MethodHandleAccessTestCase("Instance field",
                                                      vhField, f, hs -> testInstanceFieldWrongMethodType(this, hs),
                                                      false));
 
-            cases.add(new MethodHandleAccessTestCase("Static field wrong method type",
+            cases.add(new MethodHandleAccessTestCase("Static field",
                                                      vhStaticField, f, VarHandleTestMethodTypeChar::testStaticFieldWrongMethodType,
                                                      false));
 
-            cases.add(new MethodHandleAccessTestCase("Array wrong method type",
+            cases.add(new MethodHandleAccessTestCase("Array",
                                                      vhArray, f, VarHandleTestMethodTypeChar::testArrayWrongMethodType,
                                                      false));
         }
@@ -329,63 +331,63 @@
         for (TestAccessMode am : testAccessModesOfType(TestAccessType.GET)) {
             // Incorrect argument types
             checkNPE(() -> { // null receiver
-                char x = (char) hs.get(am, methodType(char.class, Void.class)).
-                    invoke(null);
+                char x = (char) hs.get(am, methodType(char.class, VarHandleTestMethodTypeChar.class)).
+                    invokeExact((VarHandleTestMethodTypeChar) null);
             });
-            checkCCE(() -> { // receiver reference class
+            hs.checkWMTEOrCCE(() -> { // receiver reference class
                 char x = (char) hs.get(am, methodType(char.class, Class.class)).
-                    invoke(Void.class);
+                    invokeExact(Void.class);
             });
             checkWMTE(() -> { // receiver primitive class
                 char x = (char) hs.get(am, methodType(char.class, int.class)).
-                    invoke(0);
+                    invokeExact(0);
             });
             // Incorrect return type
             checkWMTE(() -> { // reference class
-                Void x = (Void) hs.get(am, methodType(char.class, VarHandleTestMethodTypeChar.class)).
-                    invoke(recv);
+                Void x = (Void) hs.get(am, methodType(Void.class, VarHandleTestMethodTypeChar.class)).
+                    invokeExact(recv);
             });
             checkWMTE(() -> { // primitive class
                 boolean x = (boolean) hs.get(am, methodType(boolean.class, VarHandleTestMethodTypeChar.class)).
-                    invoke(recv);
+                    invokeExact(recv);
             });
             // Incorrect arity
             checkWMTE(() -> { // 0
                 char x = (char) hs.get(am, methodType(char.class)).
-                    invoke();
+                    invokeExact();
             });
             checkWMTE(() -> { // >
                 char x = (char) hs.get(am, methodType(char.class, VarHandleTestMethodTypeChar.class, Class.class)).
-                    invoke(recv, Void.class);
+                    invokeExact(recv, Void.class);
             });
         }
 
         for (TestAccessMode am : testAccessModesOfType(TestAccessType.SET)) {
             // Incorrect argument types
             checkNPE(() -> { // null receiver
-                hs.get(am, methodType(void.class, Void.class, char.class)).
-                    invoke(null, 'a');
+                hs.get(am, methodType(void.class, VarHandleTestMethodTypeChar.class, char.class)).
+                    invokeExact((VarHandleTestMethodTypeChar) null, 'a');
             });
-            checkCCE(() -> { // receiver reference class
+            hs.checkWMTEOrCCE(() -> { // receiver reference class
                 hs.get(am, methodType(void.class, Class.class, char.class)).
-                    invoke(Void.class, 'a');
+                    invokeExact(Void.class, 'a');
             });
             checkWMTE(() -> { // value reference class
                 hs.get(am, methodType(void.class, VarHandleTestMethodTypeChar.class, Class.class)).
-                    invoke(recv, Void.class);
+                    invokeExact(recv, Void.class);
             });
             checkWMTE(() -> { // receiver primitive class
                 hs.get(am, methodType(void.class, int.class, char.class)).
-                    invoke(0, 'a');
+                    invokeExact(0, 'a');
             });
             // Incorrect arity
             checkWMTE(() -> { // 0
                 hs.get(am, methodType(void.class)).
-                    invoke();
+                    invokeExact();
             });
             checkWMTE(() -> { // >
                 hs.get(am, methodType(void.class, VarHandleTestMethodTypeChar.class, char.class, Class.class)).
-                    invoke(recv, 'a', Void.class);
+                    invokeExact(recv, 'a', Void.class);
             });
         }
 
@@ -513,32 +515,32 @@
             // Incorrect return type
             checkWMTE(() -> { // reference class
                 Void x = (Void) hs.get(am, methodType(Void.class)).
-                    invoke();
+                    invokeExact();
             });
             checkWMTE(() -> { // primitive class
                 boolean x = (boolean) hs.get(am, methodType(boolean.class)).
-                    invoke();
+                    invokeExact();
             });
             // Incorrect arity
             checkWMTE(() -> { // >
                 char x = (char) hs.get(am, methodType(Class.class)).
-                    invoke(Void.class);
+                    invokeExact(Void.class);
             });
         }
 
         for (TestAccessMode am : testAccessModesOfType(TestAccessType.SET)) {
             checkWMTE(() -> { // value reference class
                 hs.get(am, methodType(void.class, Class.class)).
-                    invoke(Void.class);
+                    invokeExact(Void.class);
             });
             // Incorrect arity
             checkWMTE(() -> { // 0
                 hs.get(am, methodType(void.class)).
-                    invoke();
+                    invokeExact();
             });
             checkWMTE(() -> { // >
                 hs.get(am, methodType(void.class, char.class, Class.class)).
-                    invoke('a', Void.class);
+                    invokeExact('a', Void.class);
             });
         }
 
@@ -783,71 +785,71 @@
         for (TestAccessMode am : testAccessModesOfType(TestAccessType.GET)) {
             // Incorrect argument types
             checkNPE(() -> { // null array
-                char x = (char) hs.get(am, methodType(char.class, Void.class, int.class)).
-                    invoke(null, 0);
+                char x = (char) hs.get(am, methodType(char.class, char[].class, int.class)).
+                    invokeExact((char[]) null, 0);
             });
-            checkCCE(() -> { // array reference class
+            hs.checkWMTEOrCCE(() -> { // array reference class
                 char x = (char) hs.get(am, methodType(char.class, Class.class, int.class)).
-                    invoke(Void.class, 0);
+                    invokeExact(Void.class, 0);
             });
             checkWMTE(() -> { // array primitive class
                 char x = (char) hs.get(am, methodType(char.class, int.class, int.class)).
-                    invoke(0, 0);
+                    invokeExact(0, 0);
             });
             checkWMTE(() -> { // index reference class
                 char x = (char) hs.get(am, methodType(char.class, char[].class, Class.class)).
-                    invoke(array, Void.class);
+                    invokeExact(array, Void.class);
             });
             // Incorrect return type
             checkWMTE(() -> { // reference class
                 Void x = (Void) hs.get(am, methodType(Void.class, char[].class, int.class)).
-                    invoke(array, 0);
+                    invokeExact(array, 0);
             });
             checkWMTE(() -> { // primitive class
                 boolean x = (boolean) hs.get(am, methodType(boolean.class, char[].class, int.class)).
-                    invoke(array, 0);
+                    invokeExact(array, 0);
             });
             // Incorrect arity
             checkWMTE(() -> { // 0
                 char x = (char) hs.get(am, methodType(char.class)).
-                    invoke();
+                    invokeExact();
             });
             checkWMTE(() -> { // >
                 char x = (char) hs.get(am, methodType(char.class, char[].class, int.class, Class.class)).
-                    invoke(array, 0, Void.class);
+                    invokeExact(array, 0, Void.class);
             });
         }
 
         for (TestAccessMode am : testAccessModesOfType(TestAccessType.SET)) {
             // Incorrect argument types
             checkNPE(() -> { // null array
-                hs.get(am, methodType(void.class, Void.class, int.class, char.class)).
-                    invoke(null, 0, 'a');
+                hs.get(am, methodType(void.class, char[].class, int.class, char.class)).
+                    invokeExact((char[]) null, 0, 'a');
             });
-            checkCCE(() -> { // array reference class
+            hs.checkWMTEOrCCE(() -> { // array reference class
                 hs.get(am, methodType(void.class, Class.class, int.class, char.class)).
-                    invoke(Void.class, 0, 'a');
+                    invokeExact(Void.class, 0, 'a');
             });
             checkWMTE(() -> { // value reference class
                 hs.get(am, methodType(void.class, char[].class, int.class, Class.class)).
-                    invoke(array, 0, Void.class);
+                    invokeExact(array, 0, Void.class);
             });
             checkWMTE(() -> { // receiver primitive class
                 hs.get(am, methodType(void.class, int.class, int.class, char.class)).
-                    invoke(0, 0, 'a');
+                    invokeExact(0, 0, 'a');
             });
             checkWMTE(() -> { // index reference class
                 hs.get(am, methodType(void.class, char[].class, Class.class, char.class)).
-                    invoke(array, Void.class, 'a');
+                    invokeExact(array, Void.class, 'a');
             });
             // Incorrect arity
             checkWMTE(() -> { // 0
                 hs.get(am, methodType(void.class)).
-                    invoke();
+                    invokeExact();
             });
             checkWMTE(() -> { // >
                 hs.get(am, methodType(void.class, char[].class, int.class, Class.class)).
-                    invoke(array, 0, 'a', Void.class);
+                    invokeExact(array, 0, 'a', Void.class);
             });
         }
 
--- a/jdk/test/java/lang/invoke/VarHandles/VarHandleTestMethodTypeDouble.java	Thu May 19 17:48:02 2016 +0000
+++ b/jdk/test/java/lang/invoke/VarHandles/VarHandleTestMethodTypeDouble.java	Thu May 19 19:46:20 2016 +0000
@@ -23,6 +23,7 @@
 
 /*
  * @test
+ * @bug 8156486
  * @run testng/othervm VarHandleTestMethodTypeDouble
  * @run testng/othervm -Djava.lang.invoke.VarHandle.VAR_HANDLE_GUARDS=false VarHandleTestMethodTypeDouble
  */
@@ -81,27 +82,28 @@
     public Object[][] accessTestCaseProvider() throws Exception {
         List<AccessTestCase<?>> cases = new ArrayList<>();
 
-        cases.add(new VarHandleAccessTestCase("Instance field wrong method type",
+        cases.add(new VarHandleAccessTestCase("Instance field",
                                               vhField, vh -> testInstanceFieldWrongMethodType(this, vh),
                                               false));
 
-        cases.add(new VarHandleAccessTestCase("Static field wrong method type",
+        cases.add(new VarHandleAccessTestCase("Static field",
                                               vhStaticField, VarHandleTestMethodTypeDouble::testStaticFieldWrongMethodType,
                                               false));
 
-        cases.add(new VarHandleAccessTestCase("Array wrong method type",
+        cases.add(new VarHandleAccessTestCase("Array",
                                               vhArray, VarHandleTestMethodTypeDouble::testArrayWrongMethodType,
                                               false));
+
         for (VarHandleToMethodHandle f : VarHandleToMethodHandle.values()) {
-            cases.add(new MethodHandleAccessTestCase("Instance field wrong method type",
+            cases.add(new MethodHandleAccessTestCase("Instance field",
                                                      vhField, f, hs -> testInstanceFieldWrongMethodType(this, hs),
                                                      false));
 
-            cases.add(new MethodHandleAccessTestCase("Static field wrong method type",
+            cases.add(new MethodHandleAccessTestCase("Static field",
                                                      vhStaticField, f, VarHandleTestMethodTypeDouble::testStaticFieldWrongMethodType,
                                                      false));
 
-            cases.add(new MethodHandleAccessTestCase("Array wrong method type",
+            cases.add(new MethodHandleAccessTestCase("Array",
                                                      vhArray, f, VarHandleTestMethodTypeDouble::testArrayWrongMethodType,
                                                      false));
         }
@@ -329,63 +331,63 @@
         for (TestAccessMode am : testAccessModesOfType(TestAccessType.GET)) {
             // Incorrect argument types
             checkNPE(() -> { // null receiver
-                double x = (double) hs.get(am, methodType(double.class, Void.class)).
-                    invoke(null);
+                double x = (double) hs.get(am, methodType(double.class, VarHandleTestMethodTypeDouble.class)).
+                    invokeExact((VarHandleTestMethodTypeDouble) null);
             });
-            checkCCE(() -> { // receiver reference class
+            hs.checkWMTEOrCCE(() -> { // receiver reference class
                 double x = (double) hs.get(am, methodType(double.class, Class.class)).
-                    invoke(Void.class);
+                    invokeExact(Void.class);
             });
             checkWMTE(() -> { // receiver primitive class
                 double x = (double) hs.get(am, methodType(double.class, int.class)).
-                    invoke(0);
+                    invokeExact(0);
             });
             // Incorrect return type
             checkWMTE(() -> { // reference class
-                Void x = (Void) hs.get(am, methodType(double.class, VarHandleTestMethodTypeDouble.class)).
-                    invoke(recv);
+                Void x = (Void) hs.get(am, methodType(Void.class, VarHandleTestMethodTypeDouble.class)).
+                    invokeExact(recv);
             });
             checkWMTE(() -> { // primitive class
                 boolean x = (boolean) hs.get(am, methodType(boolean.class, VarHandleTestMethodTypeDouble.class)).
-                    invoke(recv);
+                    invokeExact(recv);
             });
             // Incorrect arity
             checkWMTE(() -> { // 0
                 double x = (double) hs.get(am, methodType(double.class)).
-                    invoke();
+                    invokeExact();
             });
             checkWMTE(() -> { // >
                 double x = (double) hs.get(am, methodType(double.class, VarHandleTestMethodTypeDouble.class, Class.class)).
-                    invoke(recv, Void.class);
+                    invokeExact(recv, Void.class);
             });
         }
 
         for (TestAccessMode am : testAccessModesOfType(TestAccessType.SET)) {
             // Incorrect argument types
             checkNPE(() -> { // null receiver
-                hs.get(am, methodType(void.class, Void.class, double.class)).
-                    invoke(null, 1.0d);
+                hs.get(am, methodType(void.class, VarHandleTestMethodTypeDouble.class, double.class)).
+                    invokeExact((VarHandleTestMethodTypeDouble) null, 1.0d);
             });
-            checkCCE(() -> { // receiver reference class
+            hs.checkWMTEOrCCE(() -> { // receiver reference class
                 hs.get(am, methodType(void.class, Class.class, double.class)).
-                    invoke(Void.class, 1.0d);
+                    invokeExact(Void.class, 1.0d);
             });
             checkWMTE(() -> { // value reference class
                 hs.get(am, methodType(void.class, VarHandleTestMethodTypeDouble.class, Class.class)).
-                    invoke(recv, Void.class);
+                    invokeExact(recv, Void.class);
             });
             checkWMTE(() -> { // receiver primitive class
                 hs.get(am, methodType(void.class, int.class, double.class)).
-                    invoke(0, 1.0d);
+                    invokeExact(0, 1.0d);
             });
             // Incorrect arity
             checkWMTE(() -> { // 0
                 hs.get(am, methodType(void.class)).
-                    invoke();
+                    invokeExact();
             });
             checkWMTE(() -> { // >
                 hs.get(am, methodType(void.class, VarHandleTestMethodTypeDouble.class, double.class, Class.class)).
-                    invoke(recv, 1.0d, Void.class);
+                    invokeExact(recv, 1.0d, Void.class);
             });
         }
 
@@ -513,32 +515,32 @@
             // Incorrect return type
             checkWMTE(() -> { // reference class
                 Void x = (Void) hs.get(am, methodType(Void.class)).
-                    invoke();
+                    invokeExact();
             });
             checkWMTE(() -> { // primitive class
                 boolean x = (boolean) hs.get(am, methodType(boolean.class)).
-                    invoke();
+                    invokeExact();
             });
             // Incorrect arity
             checkWMTE(() -> { // >
                 double x = (double) hs.get(am, methodType(Class.class)).
-                    invoke(Void.class);
+                    invokeExact(Void.class);
             });
         }
 
         for (TestAccessMode am : testAccessModesOfType(TestAccessType.SET)) {
             checkWMTE(() -> { // value reference class
                 hs.get(am, methodType(void.class, Class.class)).
-                    invoke(Void.class);
+                    invokeExact(Void.class);
             });
             // Incorrect arity
             checkWMTE(() -> { // 0
                 hs.get(am, methodType(void.class)).
-                    invoke();
+                    invokeExact();
             });
             checkWMTE(() -> { // >
                 hs.get(am, methodType(void.class, double.class, Class.class)).
-                    invoke(1.0d, Void.class);
+                    invokeExact(1.0d, Void.class);
             });
         }
 
@@ -783,71 +785,71 @@
         for (TestAccessMode am : testAccessModesOfType(TestAccessType.GET)) {
             // Incorrect argument types
             checkNPE(() -> { // null array
-                double x = (double) hs.get(am, methodType(double.class, Void.class, int.class)).
-                    invoke(null, 0);
+                double x = (double) hs.get(am, methodType(double.class, double[].class, int.class)).
+                    invokeExact((double[]) null, 0);
             });
-            checkCCE(() -> { // array reference class
+            hs.checkWMTEOrCCE(() -> { // array reference class
                 double x = (double) hs.get(am, methodType(double.class, Class.class, int.class)).
-                    invoke(Void.class, 0);
+                    invokeExact(Void.class, 0);
             });
             checkWMTE(() -> { // array primitive class
                 double x = (double) hs.get(am, methodType(double.class, int.class, int.class)).
-                    invoke(0, 0);
+                    invokeExact(0, 0);
             });
             checkWMTE(() -> { // index reference class
                 double x = (double) hs.get(am, methodType(double.class, double[].class, Class.class)).
-                    invoke(array, Void.class);
+                    invokeExact(array, Void.class);
             });
             // Incorrect return type
             checkWMTE(() -> { // reference class
                 Void x = (Void) hs.get(am, methodType(Void.class, double[].class, int.class)).
-                    invoke(array, 0);
+                    invokeExact(array, 0);
             });
             checkWMTE(() -> { // primitive class
                 boolean x = (boolean) hs.get(am, methodType(boolean.class, double[].class, int.class)).
-                    invoke(array, 0);
+                    invokeExact(array, 0);
             });
             // Incorrect arity
             checkWMTE(() -> { // 0
                 double x = (double) hs.get(am, methodType(double.class)).
-                    invoke();
+                    invokeExact();
             });
             checkWMTE(() -> { // >
                 double x = (double) hs.get(am, methodType(double.class, double[].class, int.class, Class.class)).
-                    invoke(array, 0, Void.class);
+                    invokeExact(array, 0, Void.class);
             });
         }
 
         for (TestAccessMode am : testAccessModesOfType(TestAccessType.SET)) {
             // Incorrect argument types
             checkNPE(() -> { // null array
-                hs.get(am, methodType(void.class, Void.class, int.class, double.class)).
-                    invoke(null, 0, 1.0d);
+                hs.get(am, methodType(void.class, double[].class, int.class, double.class)).
+                    invokeExact((double[]) null, 0, 1.0d);
             });
-            checkCCE(() -> { // array reference class
+            hs.checkWMTEOrCCE(() -> { // array reference class
                 hs.get(am, methodType(void.class, Class.class, int.class, double.class)).
-                    invoke(Void.class, 0, 1.0d);
+                    invokeExact(Void.class, 0, 1.0d);
             });
             checkWMTE(() -> { // value reference class
                 hs.get(am, methodType(void.class, double[].class, int.class, Class.class)).
-                    invoke(array, 0, Void.class);
+                    invokeExact(array, 0, Void.class);
             });
             checkWMTE(() -> { // receiver primitive class
                 hs.get(am, methodType(void.class, int.class, int.class, double.class)).
-                    invoke(0, 0, 1.0d);
+                    invokeExact(0, 0, 1.0d);
             });
             checkWMTE(() -> { // index reference class
                 hs.get(am, methodType(void.class, double[].class, Class.class, double.class)).
-                    invoke(array, Void.class, 1.0d);
+                    invokeExact(array, Void.class, 1.0d);
             });
             // Incorrect arity
             checkWMTE(() -> { // 0
                 hs.get(am, methodType(void.class)).
-                    invoke();
+                    invokeExact();
             });
             checkWMTE(() -> { // >
                 hs.get(am, methodType(void.class, double[].class, int.class, Class.class)).
-                    invoke(array, 0, 1.0d, Void.class);
+                    invokeExact(array, 0, 1.0d, Void.class);
             });
         }
 
--- a/jdk/test/java/lang/invoke/VarHandles/VarHandleTestMethodTypeFloat.java	Thu May 19 17:48:02 2016 +0000
+++ b/jdk/test/java/lang/invoke/VarHandles/VarHandleTestMethodTypeFloat.java	Thu May 19 19:46:20 2016 +0000
@@ -23,6 +23,7 @@
 
 /*
  * @test
+ * @bug 8156486
  * @run testng/othervm VarHandleTestMethodTypeFloat
  * @run testng/othervm -Djava.lang.invoke.VarHandle.VAR_HANDLE_GUARDS=false VarHandleTestMethodTypeFloat
  */
@@ -81,27 +82,28 @@
     public Object[][] accessTestCaseProvider() throws Exception {
         List<AccessTestCase<?>> cases = new ArrayList<>();
 
-        cases.add(new VarHandleAccessTestCase("Instance field wrong method type",
+        cases.add(new VarHandleAccessTestCase("Instance field",
                                               vhField, vh -> testInstanceFieldWrongMethodType(this, vh),
                                               false));
 
-        cases.add(new VarHandleAccessTestCase("Static field wrong method type",
+        cases.add(new VarHandleAccessTestCase("Static field",
                                               vhStaticField, VarHandleTestMethodTypeFloat::testStaticFieldWrongMethodType,
                                               false));
 
-        cases.add(new VarHandleAccessTestCase("Array wrong method type",
+        cases.add(new VarHandleAccessTestCase("Array",
                                               vhArray, VarHandleTestMethodTypeFloat::testArrayWrongMethodType,
                                               false));
+
         for (VarHandleToMethodHandle f : VarHandleToMethodHandle.values()) {
-            cases.add(new MethodHandleAccessTestCase("Instance field wrong method type",
+            cases.add(new MethodHandleAccessTestCase("Instance field",
                                                      vhField, f, hs -> testInstanceFieldWrongMethodType(this, hs),
                                                      false));
 
-            cases.add(new MethodHandleAccessTestCase("Static field wrong method type",
+            cases.add(new MethodHandleAccessTestCase("Static field",
                                                      vhStaticField, f, VarHandleTestMethodTypeFloat::testStaticFieldWrongMethodType,
                                                      false));
 
-            cases.add(new MethodHandleAccessTestCase("Array wrong method type",
+            cases.add(new MethodHandleAccessTestCase("Array",
                                                      vhArray, f, VarHandleTestMethodTypeFloat::testArrayWrongMethodType,
                                                      false));
         }
@@ -329,63 +331,63 @@
         for (TestAccessMode am : testAccessModesOfType(TestAccessType.GET)) {
             // Incorrect argument types
             checkNPE(() -> { // null receiver
-                float x = (float) hs.get(am, methodType(float.class, Void.class)).
-                    invoke(null);
+                float x = (float) hs.get(am, methodType(float.class, VarHandleTestMethodTypeFloat.class)).
+                    invokeExact((VarHandleTestMethodTypeFloat) null);
             });
-            checkCCE(() -> { // receiver reference class
+            hs.checkWMTEOrCCE(() -> { // receiver reference class
                 float x = (float) hs.get(am, methodType(float.class, Class.class)).
-                    invoke(Void.class);
+                    invokeExact(Void.class);
             });
             checkWMTE(() -> { // receiver primitive class
                 float x = (float) hs.get(am, methodType(float.class, int.class)).
-                    invoke(0);
+                    invokeExact(0);
             });
             // Incorrect return type
             checkWMTE(() -> { // reference class
-                Void x = (Void) hs.get(am, methodType(float.class, VarHandleTestMethodTypeFloat.class)).
-                    invoke(recv);
+                Void x = (Void) hs.get(am, methodType(Void.class, VarHandleTestMethodTypeFloat.class)).
+                    invokeExact(recv);
             });
             checkWMTE(() -> { // primitive class
                 boolean x = (boolean) hs.get(am, methodType(boolean.class, VarHandleTestMethodTypeFloat.class)).
-                    invoke(recv);
+                    invokeExact(recv);
             });
             // Incorrect arity
             checkWMTE(() -> { // 0
                 float x = (float) hs.get(am, methodType(float.class)).
-                    invoke();
+                    invokeExact();
             });
             checkWMTE(() -> { // >
                 float x = (float) hs.get(am, methodType(float.class, VarHandleTestMethodTypeFloat.class, Class.class)).
-                    invoke(recv, Void.class);
+                    invokeExact(recv, Void.class);
             });
         }
 
         for (TestAccessMode am : testAccessModesOfType(TestAccessType.SET)) {
             // Incorrect argument types
             checkNPE(() -> { // null receiver
-                hs.get(am, methodType(void.class, Void.class, float.class)).
-                    invoke(null, 1.0f);
+                hs.get(am, methodType(void.class, VarHandleTestMethodTypeFloat.class, float.class)).
+                    invokeExact((VarHandleTestMethodTypeFloat) null, 1.0f);
             });
-            checkCCE(() -> { // receiver reference class
+            hs.checkWMTEOrCCE(() -> { // receiver reference class
                 hs.get(am, methodType(void.class, Class.class, float.class)).
-                    invoke(Void.class, 1.0f);
+                    invokeExact(Void.class, 1.0f);
             });
             checkWMTE(() -> { // value reference class
                 hs.get(am, methodType(void.class, VarHandleTestMethodTypeFloat.class, Class.class)).
-                    invoke(recv, Void.class);
+                    invokeExact(recv, Void.class);
             });
             checkWMTE(() -> { // receiver primitive class
                 hs.get(am, methodType(void.class, int.class, float.class)).
-                    invoke(0, 1.0f);
+                    invokeExact(0, 1.0f);
             });
             // Incorrect arity
             checkWMTE(() -> { // 0
                 hs.get(am, methodType(void.class)).
-                    invoke();
+                    invokeExact();
             });
             checkWMTE(() -> { // >
                 hs.get(am, methodType(void.class, VarHandleTestMethodTypeFloat.class, float.class, Class.class)).
-                    invoke(recv, 1.0f, Void.class);
+                    invokeExact(recv, 1.0f, Void.class);
             });
         }
 
@@ -513,32 +515,32 @@
             // Incorrect return type
             checkWMTE(() -> { // reference class
                 Void x = (Void) hs.get(am, methodType(Void.class)).
-                    invoke();
+                    invokeExact();
             });
             checkWMTE(() -> { // primitive class
                 boolean x = (boolean) hs.get(am, methodType(boolean.class)).
-                    invoke();
+                    invokeExact();
             });
             // Incorrect arity
             checkWMTE(() -> { // >
                 float x = (float) hs.get(am, methodType(Class.class)).
-                    invoke(Void.class);
+                    invokeExact(Void.class);
             });
         }
 
         for (TestAccessMode am : testAccessModesOfType(TestAccessType.SET)) {
             checkWMTE(() -> { // value reference class
                 hs.get(am, methodType(void.class, Class.class)).
-                    invoke(Void.class);
+                    invokeExact(Void.class);
             });
             // Incorrect arity
             checkWMTE(() -> { // 0
                 hs.get(am, methodType(void.class)).
-                    invoke();
+                    invokeExact();
             });
             checkWMTE(() -> { // >
                 hs.get(am, methodType(void.class, float.class, Class.class)).
-                    invoke(1.0f, Void.class);
+                    invokeExact(1.0f, Void.class);
             });
         }
 
@@ -783,71 +785,71 @@
         for (TestAccessMode am : testAccessModesOfType(TestAccessType.GET)) {
             // Incorrect argument types
             checkNPE(() -> { // null array
-                float x = (float) hs.get(am, methodType(float.class, Void.class, int.class)).
-                    invoke(null, 0);
+                float x = (float) hs.get(am, methodType(float.class, float[].class, int.class)).
+                    invokeExact((float[]) null, 0);
             });
-            checkCCE(() -> { // array reference class
+            hs.checkWMTEOrCCE(() -> { // array reference class
                 float x = (float) hs.get(am, methodType(float.class, Class.class, int.class)).
-                    invoke(Void.class, 0);
+                    invokeExact(Void.class, 0);
             });
             checkWMTE(() -> { // array primitive class
                 float x = (float) hs.get(am, methodType(float.class, int.class, int.class)).
-                    invoke(0, 0);
+                    invokeExact(0, 0);
             });
             checkWMTE(() -> { // index reference class
                 float x = (float) hs.get(am, methodType(float.class, float[].class, Class.class)).
-                    invoke(array, Void.class);
+                    invokeExact(array, Void.class);
             });
             // Incorrect return type
             checkWMTE(() -> { // reference class
                 Void x = (Void) hs.get(am, methodType(Void.class, float[].class, int.class)).
-                    invoke(array, 0);
+                    invokeExact(array, 0);
             });
             checkWMTE(() -> { // primitive class
                 boolean x = (boolean) hs.get(am, methodType(boolean.class, float[].class, int.class)).
-                    invoke(array, 0);
+                    invokeExact(array, 0);
             });
             // Incorrect arity
             checkWMTE(() -> { // 0
                 float x = (float) hs.get(am, methodType(float.class)).
-                    invoke();
+                    invokeExact();
             });
             checkWMTE(() -> { // >
                 float x = (float) hs.get(am, methodType(float.class, float[].class, int.class, Class.class)).
-                    invoke(array, 0, Void.class);
+                    invokeExact(array, 0, Void.class);
             });
         }
 
         for (TestAccessMode am : testAccessModesOfType(TestAccessType.SET)) {
             // Incorrect argument types
             checkNPE(() -> { // null array
-                hs.get(am, methodType(void.class, Void.class, int.class, float.class)).
-                    invoke(null, 0, 1.0f);
+                hs.get(am, methodType(void.class, float[].class, int.class, float.class)).
+                    invokeExact((float[]) null, 0, 1.0f);
             });
-            checkCCE(() -> { // array reference class
+            hs.checkWMTEOrCCE(() -> { // array reference class
                 hs.get(am, methodType(void.class, Class.class, int.class, float.class)).
-                    invoke(Void.class, 0, 1.0f);
+                    invokeExact(Void.class, 0, 1.0f);
             });
             checkWMTE(() -> { // value reference class
                 hs.get(am, methodType(void.class, float[].class, int.class, Class.class)).
-                    invoke(array, 0, Void.class);
+                    invokeExact(array, 0, Void.class);
             });
             checkWMTE(() -> { // receiver primitive class
                 hs.get(am, methodType(void.class, int.class, int.class, float.class)).
-                    invoke(0, 0, 1.0f);
+                    invokeExact(0, 0, 1.0f);
             });
             checkWMTE(() -> { // index reference class
                 hs.get(am, methodType(void.class, float[].class, Class.class, float.class)).
-                    invoke(array, Void.class, 1.0f);
+                    invokeExact(array, Void.class, 1.0f);
             });
             // Incorrect arity
             checkWMTE(() -> { // 0
                 hs.get(am, methodType(void.class)).
-                    invoke();
+                    invokeExact();
             });
             checkWMTE(() -> { // >
                 hs.get(am, methodType(void.class, float[].class, int.class, Class.class)).
-                    invoke(array, 0, 1.0f, Void.class);
+                    invokeExact(array, 0, 1.0f, Void.class);
             });
         }
 
--- a/jdk/test/java/lang/invoke/VarHandles/VarHandleTestMethodTypeInt.java	Thu May 19 17:48:02 2016 +0000
+++ b/jdk/test/java/lang/invoke/VarHandles/VarHandleTestMethodTypeInt.java	Thu May 19 19:46:20 2016 +0000
@@ -23,6 +23,7 @@
 
 /*
  * @test
+ * @bug 8156486
  * @run testng/othervm VarHandleTestMethodTypeInt
  * @run testng/othervm -Djava.lang.invoke.VarHandle.VAR_HANDLE_GUARDS=false VarHandleTestMethodTypeInt
  */
@@ -81,27 +82,28 @@
     public Object[][] accessTestCaseProvider() throws Exception {
         List<AccessTestCase<?>> cases = new ArrayList<>();
 
-        cases.add(new VarHandleAccessTestCase("Instance field wrong method type",
+        cases.add(new VarHandleAccessTestCase("Instance field",
                                               vhField, vh -> testInstanceFieldWrongMethodType(this, vh),
                                               false));
 
-        cases.add(new VarHandleAccessTestCase("Static field wrong method type",
+        cases.add(new VarHandleAccessTestCase("Static field",
                                               vhStaticField, VarHandleTestMethodTypeInt::testStaticFieldWrongMethodType,
                                               false));
 
-        cases.add(new VarHandleAccessTestCase("Array wrong method type",
+        cases.add(new VarHandleAccessTestCase("Array",
                                               vhArray, VarHandleTestMethodTypeInt::testArrayWrongMethodType,
                                               false));
+
         for (VarHandleToMethodHandle f : VarHandleToMethodHandle.values()) {
-            cases.add(new MethodHandleAccessTestCase("Instance field wrong method type",
+            cases.add(new MethodHandleAccessTestCase("Instance field",
                                                      vhField, f, hs -> testInstanceFieldWrongMethodType(this, hs),
                                                      false));
 
-            cases.add(new MethodHandleAccessTestCase("Static field wrong method type",
+            cases.add(new MethodHandleAccessTestCase("Static field",
                                                      vhStaticField, f, VarHandleTestMethodTypeInt::testStaticFieldWrongMethodType,
                                                      false));
 
-            cases.add(new MethodHandleAccessTestCase("Array wrong method type",
+            cases.add(new MethodHandleAccessTestCase("Array",
                                                      vhArray, f, VarHandleTestMethodTypeInt::testArrayWrongMethodType,
                                                      false));
         }
@@ -644,211 +646,211 @@
         for (TestAccessMode am : testAccessModesOfType(TestAccessType.GET)) {
             // Incorrect argument types
             checkNPE(() -> { // null receiver
-                int x = (int) hs.get(am, methodType(int.class, Void.class)).
-                    invoke(null);
+                int x = (int) hs.get(am, methodType(int.class, VarHandleTestMethodTypeInt.class)).
+                    invokeExact((VarHandleTestMethodTypeInt) null);
             });
-            checkCCE(() -> { // receiver reference class
+            hs.checkWMTEOrCCE(() -> { // receiver reference class
                 int x = (int) hs.get(am, methodType(int.class, Class.class)).
-                    invoke(Void.class);
+                    invokeExact(Void.class);
             });
             checkWMTE(() -> { // receiver primitive class
                 int x = (int) hs.get(am, methodType(int.class, int.class)).
-                    invoke(0);
+                    invokeExact(0);
             });
             // Incorrect return type
             checkWMTE(() -> { // reference class
-                Void x = (Void) hs.get(am, methodType(int.class, VarHandleTestMethodTypeInt.class)).
-                    invoke(recv);
+                Void x = (Void) hs.get(am, methodType(Void.class, VarHandleTestMethodTypeInt.class)).
+                    invokeExact(recv);
             });
             checkWMTE(() -> { // primitive class
                 boolean x = (boolean) hs.get(am, methodType(boolean.class, VarHandleTestMethodTypeInt.class)).
-                    invoke(recv);
+                    invokeExact(recv);
             });
             // Incorrect arity
             checkWMTE(() -> { // 0
                 int x = (int) hs.get(am, methodType(int.class)).
-                    invoke();
+                    invokeExact();
             });
             checkWMTE(() -> { // >
                 int x = (int) hs.get(am, methodType(int.class, VarHandleTestMethodTypeInt.class, Class.class)).
-                    invoke(recv, Void.class);
+                    invokeExact(recv, Void.class);
             });
         }
 
         for (TestAccessMode am : testAccessModesOfType(TestAccessType.SET)) {
             // Incorrect argument types
             checkNPE(() -> { // null receiver
-                hs.get(am, methodType(void.class, Void.class, int.class)).
-                    invoke(null, 1);
+                hs.get(am, methodType(void.class, VarHandleTestMethodTypeInt.class, int.class)).
+                    invokeExact((VarHandleTestMethodTypeInt) null, 1);
             });
-            checkCCE(() -> { // receiver reference class
+            hs.checkWMTEOrCCE(() -> { // receiver reference class
                 hs.get(am, methodType(void.class, Class.class, int.class)).
-                    invoke(Void.class, 1);
+                    invokeExact(Void.class, 1);
             });
             checkWMTE(() -> { // value reference class
                 hs.get(am, methodType(void.class, VarHandleTestMethodTypeInt.class, Class.class)).
-                    invoke(recv, Void.class);
+                    invokeExact(recv, Void.class);
             });
             checkWMTE(() -> { // receiver primitive class
                 hs.get(am, methodType(void.class, int.class, int.class)).
-                    invoke(0, 1);
+                    invokeExact(0, 1);
             });
             // Incorrect arity
             checkWMTE(() -> { // 0
                 hs.get(am, methodType(void.class)).
-                    invoke();
+                    invokeExact();
             });
             checkWMTE(() -> { // >
                 hs.get(am, methodType(void.class, VarHandleTestMethodTypeInt.class, int.class, Class.class)).
-                    invoke(recv, 1, Void.class);
+                    invokeExact(recv, 1, Void.class);
             });
         }
 
         for (TestAccessMode am : testAccessModesOfType(TestAccessType.COMPARE_AND_SET)) {
             // Incorrect argument types
             checkNPE(() -> { // null receiver
-                boolean r = (boolean) hs.get(am, methodType(boolean.class, Void.class, int.class, int.class)).
-                    invoke(null, 1, 1);
+                boolean r = (boolean) hs.get(am, methodType(boolean.class, VarHandleTestMethodTypeInt.class, int.class, int.class)).
+                    invokeExact((VarHandleTestMethodTypeInt) null, 1, 1);
             });
-            checkCCE(() -> { // receiver reference class
+            hs.checkWMTEOrCCE(() -> { // receiver reference class
                 boolean r = (boolean) hs.get(am, methodType(boolean.class, Class.class, int.class, int.class)).
-                    invoke(Void.class, 1, 1);
+                    invokeExact(Void.class, 1, 1);
             });
             checkWMTE(() -> { // expected reference class
                 boolean r = (boolean) hs.get(am, methodType(boolean.class, VarHandleTestMethodTypeInt.class, Class.class, int.class)).
-                    invoke(recv, Void.class, 1);
+                    invokeExact(recv, Void.class, 1);
             });
             checkWMTE(() -> { // actual reference class
                 boolean r = (boolean) hs.get(am, methodType(boolean.class, VarHandleTestMethodTypeInt.class, int.class, Class.class)).
-                    invoke(recv, 1, Void.class);
+                    invokeExact(recv, 1, Void.class);
             });
             checkWMTE(() -> { // receiver primitive class
                 boolean r = (boolean) hs.get(am, methodType(boolean.class, int.class , int.class, int.class)).
-                    invoke(0, 1, 1);
+                    invokeExact(0, 1, 1);
             });
             // Incorrect arity
             checkWMTE(() -> { // 0
                 boolean r = (boolean) hs.get(am, methodType(boolean.class)).
-                    invoke();
+                    invokeExact();
             });
             checkWMTE(() -> { // >
                 boolean r = (boolean) hs.get(am, methodType(boolean.class, VarHandleTestMethodTypeInt.class, int.class, int.class, Class.class)).
-                    invoke(recv, 1, 1, Void.class);
+                    invokeExact(recv, 1, 1, Void.class);
             });
         }
 
         for (TestAccessMode am : testAccessModesOfType(TestAccessType.COMPARE_AND_EXCHANGE)) {
             checkNPE(() -> { // null receiver
-                int x = (int) hs.get(am, methodType(int.class, Void.class, int.class, int.class)).
-                    invoke(null, 1, 1);
+                int x = (int) hs.get(am, methodType(int.class, VarHandleTestMethodTypeInt.class, int.class, int.class)).
+                    invokeExact((VarHandleTestMethodTypeInt) null, 1, 1);
             });
-            checkCCE(() -> { // receiver reference class
+            hs.checkWMTEOrCCE(() -> { // receiver reference class
                 int x = (int) hs.get(am, methodType(int.class, Class.class, int.class, int.class)).
-                    invoke(Void.class, 1, 1);
+                    invokeExact(Void.class, 1, 1);
             });
             checkWMTE(() -> { // expected reference class
                 int x = (int) hs.get(am, methodType(int.class, VarHandleTestMethodTypeInt.class, Class.class, int.class)).
-                    invoke(recv, Void.class, 1);
+                    invokeExact(recv, Void.class, 1);
             });
             checkWMTE(() -> { // actual reference class
                 int x = (int) hs.get(am, methodType(int.class, VarHandleTestMethodTypeInt.class, int.class, Class.class)).
-                    invoke(recv, 1, Void.class);
+                    invokeExact(recv, 1, Void.class);
             });
             checkWMTE(() -> { // reciever primitive class
                 int x = (int) hs.get(am, methodType(int.class, int.class , int.class, int.class)).
-                    invoke(0, 1, 1);
+                    invokeExact(0, 1, 1);
             });
             // Incorrect return type
             checkWMTE(() -> { // reference class
                 Void r = (Void) hs.get(am, methodType(Void.class, VarHandleTestMethodTypeInt.class , int.class, int.class)).
-                    invoke(recv, 1, 1);
+                    invokeExact(recv, 1, 1);
             });
             checkWMTE(() -> { // primitive class
                 boolean x = (boolean) hs.get(am, methodType(boolean.class, VarHandleTestMethodTypeInt.class , int.class, int.class)).
-                    invoke(recv, 1, 1);
+                    invokeExact(recv, 1, 1);
             });
             // Incorrect arity
             checkWMTE(() -> { // 0
                 int x = (int) hs.get(am, methodType(int.class)).
-                    invoke();
+                    invokeExact();
             });
             checkWMTE(() -> { // >
                 int x = (int) hs.get(am, methodType(int.class, VarHandleTestMethodTypeInt.class, int.class, int.class, Class.class)).
-                    invoke(recv, 1, 1, Void.class);
+                    invokeExact(recv, 1, 1, Void.class);
             });
         }
 
         for (TestAccessMode am : testAccessModesOfType(TestAccessType.GET_AND_SET)) {
             checkNPE(() -> { // null receiver
-                int x = (int) hs.get(am, methodType(int.class, Void.class, int.class)).
-                    invoke(null, 1);
+                int x = (int) hs.get(am, methodType(int.class, VarHandleTestMethodTypeInt.class, int.class)).
+                    invokeExact((VarHandleTestMethodTypeInt) null, 1);
             });
-            checkCCE(() -> { // receiver reference class
+            hs.checkWMTEOrCCE(() -> { // receiver reference class
                 int x = (int) hs.get(am, methodType(int.class, Class.class, int.class)).
-                    invoke(Void.class, 1);
+                    invokeExact(Void.class, 1);
             });
             checkWMTE(() -> { // value reference class
                 int x = (int) hs.get(am, methodType(int.class, VarHandleTestMethodTypeInt.class, Class.class)).
-                    invoke(recv, Void.class);
+                    invokeExact(recv, Void.class);
             });
             checkWMTE(() -> { // reciever primitive class
                 int x = (int) hs.get(am, methodType(int.class, int.class, int.class)).
-                    invoke(0, 1);
+                    invokeExact(0, 1);
             });
             // Incorrect return type
             checkWMTE(() -> { // reference class
                 Void r = (Void) hs.get(am, methodType(Void.class, VarHandleTestMethodTypeInt.class, int.class)).
-                    invoke(recv, 1);
+                    invokeExact(recv, 1);
             });
             checkWMTE(() -> { // primitive class
                 boolean x = (boolean) hs.get(am, methodType(boolean.class, VarHandleTestMethodTypeInt.class, int.class)).
-                    invoke(recv, 1);
+                    invokeExact(recv, 1);
             });
             // Incorrect arity
             checkWMTE(() -> { // 0
                 int x = (int) hs.get(am, methodType(int.class)).
-                    invoke();
+                    invokeExact();
             });
             checkWMTE(() -> { // >
                 int x = (int) hs.get(am, methodType(int.class, VarHandleTestMethodTypeInt.class, int.class)).
-                    invoke(recv, 1, Void.class);
+                    invokeExact(recv, 1, Void.class);
             });
         }
 
         for (TestAccessMode am : testAccessModesOfType(TestAccessType.GET_AND_ADD)) {
             checkNPE(() -> { // null receiver
-                int x = (int) hs.get(am, methodType(int.class, Void.class, int.class)).
-                    invoke(null, 1);
+                int x = (int) hs.get(am, methodType(int.class, VarHandleTestMethodTypeInt.class, int.class)).
+                    invokeExact((VarHandleTestMethodTypeInt) null, 1);
             });
-            checkCCE(() -> { // receiver reference class
+            hs.checkWMTEOrCCE(() -> { // receiver reference class
                 int x = (int) hs.get(am, methodType(int.class, Class.class, int.class)).
-                    invoke(Void.class, 1);
+                    invokeExact(Void.class, 1);
             });
             checkWMTE(() -> { // value reference class
                 int x = (int) hs.get(am, methodType(int.class, VarHandleTestMethodTypeInt.class, Class.class)).
-                    invoke(recv, Void.class);
+                    invokeExact(recv, Void.class);
             });
             checkWMTE(() -> { // reciever primitive class
                 int x = (int) hs.get(am, methodType(int.class, int.class, int.class)).
-                    invoke(0, 1);
+                    invokeExact(0, 1);
             });
             // Incorrect return type
             checkWMTE(() -> { // reference class
                 Void r = (Void) hs.get(am, methodType(Void.class, VarHandleTestMethodTypeInt.class, int.class)).
-                    invoke(recv, 1);
+                    invokeExact(recv, 1);
             });
             checkWMTE(() -> { // primitive class
                 boolean x = (boolean) hs.get(am, methodType(boolean.class, VarHandleTestMethodTypeInt.class, int.class)).
-                    invoke(recv, 1);
+                    invokeExact(recv, 1);
             });
             // Incorrect arity
             checkWMTE(() -> { // 0
                 int x = (int) hs.get(am, methodType(int.class)).
-                    invoke();
+                    invokeExact();
             });
             checkWMTE(() -> { // >
                 int x = (int) hs.get(am, methodType(int.class, VarHandleTestMethodTypeInt.class, int.class)).
-                    invoke(recv, 1, Void.class);
+                    invokeExact(recv, 1, Void.class);
             });
         }
     }
@@ -1190,52 +1192,52 @@
             // Incorrect return type
             checkWMTE(() -> { // reference class
                 Void x = (Void) hs.get(am, methodType(Void.class)).
-                    invoke();
+                    invokeExact();
             });
             checkWMTE(() -> { // primitive class
                 boolean x = (boolean) hs.get(am, methodType(boolean.class)).
-                    invoke();
+                    invokeExact();
             });
             // Incorrect arity
             checkWMTE(() -> { // >
                 int x = (int) hs.get(am, methodType(Class.class)).
-                    invoke(Void.class);
+                    invokeExact(Void.class);
             });
         }
 
         for (TestAccessMode am : testAccessModesOfType(TestAccessType.SET)) {
             checkWMTE(() -> { // value reference class
                 hs.get(am, methodType(void.class, Class.class)).
-                    invoke(Void.class);
+                    invokeExact(Void.class);
             });
             // Incorrect arity
             checkWMTE(() -> { // 0
                 hs.get(am, methodType(void.class)).
-                    invoke();
+                    invokeExact();
             });
             checkWMTE(() -> { // >
                 hs.get(am, methodType(void.class, int.class, Class.class)).
-                    invoke(1, Void.class);
+                    invokeExact(1, Void.class);
             });
         }
         for (TestAccessMode am : testAccessModesOfType(TestAccessType.COMPARE_AND_SET)) {
             // Incorrect argument types
             checkWMTE(() -> { // expected reference class
                 boolean r = (boolean) hs.get(am, methodType(boolean.class, Class.class, int.class)).
-                    invoke(Void.class, 1);
+                    invokeExact(Void.class, 1);
             });
             checkWMTE(() -> { // actual reference class
                 boolean r = (boolean) hs.get(am, methodType(boolean.class, int.class, Class.class)).
-                    invoke(1, Void.class);
+                    invokeExact(1, Void.class);
             });
             // Incorrect arity
             checkWMTE(() -> { // 0
                 boolean r = (boolean) hs.get(am, methodType(boolean.class)).
-                    invoke();
+                    invokeExact();
             });
             checkWMTE(() -> { // >
                 boolean r = (boolean) hs.get(am, methodType(boolean.class, int.class, int.class, Class.class)).
-                    invoke(1, 1, Void.class);
+                    invokeExact(1, 1, Void.class);
             });
         }
 
@@ -1243,29 +1245,29 @@
             // Incorrect argument types
             checkWMTE(() -> { // expected reference class
                 int x = (int) hs.get(am, methodType(int.class, Class.class, int.class)).
-                    invoke(Void.class, 1);
+                    invokeExact(Void.class, 1);
             });
             checkWMTE(() -> { // actual reference class
                 int x = (int) hs.get(am, methodType(int.class, int.class, Class.class)).
-                    invoke(1, Void.class);
+                    invokeExact(1, Void.class);
             });
             // Incorrect return type
             checkWMTE(() -> { // reference class
                 Void r = (Void) hs.get(am, methodType(Void.class, int.class, int.class)).
-                    invoke(1, 1);
+                    invokeExact(1, 1);
             });
             checkWMTE(() -> { // primitive class
                 boolean x = (boolean) hs.get(am, methodType(boolean.class, int.class, int.class)).
-                    invoke(1, 1);
+                    invokeExact(1, 1);
             });
             // Incorrect arity
             checkWMTE(() -> { // 0
                 int x = (int) hs.get(am, methodType(int.class)).
-                    invoke();
+                    invokeExact();
             });
             checkWMTE(() -> { // >
                 int x = (int) hs.get(am, methodType(int.class, int.class, int.class, Class.class)).
-                    invoke(1, 1, Void.class);
+                    invokeExact(1, 1, Void.class);
             });
         }
 
@@ -1273,25 +1275,25 @@
             // Incorrect argument types
             checkWMTE(() -> { // value reference class
                 int x = (int) hs.get(am, methodType(int.class, Class.class)).
-                    invoke(Void.class);
+                    invokeExact(Void.class);
             });
             // Incorrect return type
             checkWMTE(() -> { // reference class
                 Void r = (Void) hs.get(am, methodType(Void.class, int.class)).
-                    invoke(1);
+                    invokeExact(1);
             });
             checkWMTE(() -> { // primitive class
                 boolean x = (boolean) hs.get(am, methodType(boolean.class, int.class)).
-                    invoke(1);
+                    invokeExact(1);
             });
             // Incorrect arity
             checkWMTE(() -> { // 0
                 int x = (int) hs.get(am, methodType(int.class)).
-                    invoke();
+                    invokeExact();
             });
             checkWMTE(() -> { // >
                 int x = (int) hs.get(am, methodType(int.class, int.class, Class.class)).
-                    invoke(1, Void.class);
+                    invokeExact(1, Void.class);
             });
         }
 
@@ -1299,25 +1301,25 @@
             // Incorrect argument types
             checkWMTE(() -> { // value reference class
                 int x = (int) hs.get(am, methodType(int.class, Class.class)).
-                    invoke(Void.class);
+                    invokeExact(Void.class);
             });
             // Incorrect return type
             checkWMTE(() -> { // reference class
                 Void r = (Void) hs.get(am, methodType(Void.class, int.class)).
-                    invoke(1);
+                    invokeExact(1);
             });
             checkWMTE(() -> { // primitive class
                 boolean x = (boolean) hs.get(am, methodType(boolean.class, int.class)).
-                    invoke(1);
+                    invokeExact(1);
             });
             // Incorrect arity
             checkWMTE(() -> { // 0
                 int x = (int) hs.get(am, methodType(int.class)).
-                    invoke();
+                    invokeExact();
             });
             checkWMTE(() -> { // >
                 int x = (int) hs.get(am, methodType(int.class, int.class, Class.class)).
-                    invoke(1, Void.class);
+                    invokeExact(1, Void.class);
             });
         }
     }
@@ -1909,237 +1911,237 @@
         for (TestAccessMode am : testAccessModesOfType(TestAccessType.GET)) {
             // Incorrect argument types
             checkNPE(() -> { // null array
-                int x = (int) hs.get(am, methodType(int.class, Void.class, int.class)).
-                    invoke(null, 0);
+                int x = (int) hs.get(am, methodType(int.class, int[].class, int.class)).
+                    invokeExact((int[]) null, 0);
             });
-            checkCCE(() -> { // array reference class
+            hs.checkWMTEOrCCE(() -> { // array reference class
                 int x = (int) hs.get(am, methodType(int.class, Class.class, int.class)).
-                    invoke(Void.class, 0);
+                    invokeExact(Void.class, 0);
             });
             checkWMTE(() -> { // array primitive class
                 int x = (int) hs.get(am, methodType(int.class, int.class, int.class)).
-                    invoke(0, 0);
+                    invokeExact(0, 0);
             });
             checkWMTE(() -> { // index reference class
                 int x = (int) hs.get(am, methodType(int.class, int[].class, Class.class)).
-                    invoke(array, Void.class);
+                    invokeExact(array, Void.class);
             });
             // Incorrect return type
             checkWMTE(() -> { // reference class
                 Void x = (Void) hs.get(am, methodType(Void.class, int[].class, int.class)).
-                    invoke(array, 0);
+                    invokeExact(array, 0);
             });
             checkWMTE(() -> { // primitive class
                 boolean x = (boolean) hs.get(am, methodType(boolean.class, int[].class, int.class)).
-                    invoke(array, 0);
+                    invokeExact(array, 0);
             });
             // Incorrect arity
             checkWMTE(() -> { // 0
                 int x = (int) hs.get(am, methodType(int.class)).
-                    invoke();
+                    invokeExact();
             });
             checkWMTE(() -> { // >
                 int x = (int) hs.get(am, methodType(int.class, int[].class, int.class, Class.class)).
-                    invoke(array, 0, Void.class);
+                    invokeExact(array, 0, Void.class);
             });
         }
 
         for (TestAccessMode am : testAccessModesOfType(TestAccessType.SET)) {
             // Incorrect argument types
             checkNPE(() -> { // null array
-                hs.get(am, methodType(void.class, Void.class, int.class, int.class)).
-                    invoke(null, 0, 1);
+                hs.get(am, methodType(void.class, int[].class, int.class, int.class)).
+                    invokeExact((int[]) null, 0, 1);
             });
-            checkCCE(() -> { // array reference class
+            hs.checkWMTEOrCCE(() -> { // array reference class
                 hs.get(am, methodType(void.class, Class.class, int.class, int.class)).
-                    invoke(Void.class, 0, 1);
+                    invokeExact(Void.class, 0, 1);
             });
             checkWMTE(() -> { // value reference class
                 hs.get(am, methodType(void.class, int[].class, int.class, Class.class)).
-                    invoke(array, 0, Void.class);
+                    invokeExact(array, 0, Void.class);
             });
             checkWMTE(() -> { // receiver primitive class
                 hs.get(am, methodType(void.class, int.class, int.class, int.class)).
-                    invoke(0, 0, 1);
+                    invokeExact(0, 0, 1);
             });
             checkWMTE(() -> { // index reference class
                 hs.get(am, methodType(void.class, int[].class, Class.class, int.class)).
-                    invoke(array, Void.class, 1);
+                    invokeExact(array, Void.class, 1);
             });
             // Incorrect arity
             checkWMTE(() -> { // 0
                 hs.get(am, methodType(void.class)).
-                    invoke();
+                    invokeExact();
             });
             checkWMTE(() -> { // >
                 hs.get(am, methodType(void.class, int[].class, int.class, Class.class)).
-                    invoke(array, 0, 1, Void.class);
+                    invokeExact(array, 0, 1, Void.class);
             });
         }
         for (TestAccessMode am : testAccessModesOfType(TestAccessType.COMPARE_AND_SET)) {
             // Incorrect argument types
             checkNPE(() -> { // null receiver
-                boolean r = (boolean) hs.get(am, methodType(boolean.class, Void.class, int.class, int.class, int.class)).
-                    invoke(null, 0, 1, 1);
+                boolean r = (boolean) hs.get(am, methodType(boolean.class, int[].class, int.class, int.class, int.class)).
+                    invokeExact((int[]) null, 0, 1, 1);
             });
-            checkCCE(() -> { // receiver reference class
+            hs.checkWMTEOrCCE(() -> { // receiver reference class
                 boolean r = (boolean) hs.get(am, methodType(boolean.class, Class.class, int.class, int.class, int.class)).
-                    invoke(Void.class, 0, 1, 1);
+                    invokeExact(Void.class, 0, 1, 1);
             });
             checkWMTE(() -> { // expected reference class
                 boolean r = (boolean) hs.get(am, methodType(boolean.class, int[].class, int.class, Class.class, int.class)).
-                    invoke(array, 0, Void.class, 1);
+                    invokeExact(array, 0, Void.class, 1);
             });
             checkWMTE(() -> { // actual reference class
                 boolean r = (boolean) hs.get(am, methodType(boolean.class, int[].class, int.class, int.class, Class.class)).
-                    invoke(array, 0, 1, Void.class);
+                    invokeExact(array, 0, 1, Void.class);
             });
             checkWMTE(() -> { // receiver primitive class
                 boolean r = (boolean) hs.get(am, methodType(boolean.class, int.class, int.class, int.class, int.class)).
-                    invoke(0, 0, 1, 1);
+                    invokeExact(0, 0, 1, 1);
             });
             checkWMTE(() -> { // index reference class
                 boolean r = (boolean) hs.get(am, methodType(boolean.class, int[].class, Class.class, int.class, int.class)).
-                    invoke(array, Void.class, 1, 1);
+                    invokeExact(array, Void.class, 1, 1);
             });
             // Incorrect arity
             checkWMTE(() -> { // 0
                 boolean r = (boolean) hs.get(am, methodType(boolean.class)).
-                    invoke();
+                    invokeExact();
             });
             checkWMTE(() -> { // >
                 boolean r = (boolean) hs.get(am, methodType(boolean.class, int[].class, int.class, int.class, int.class, Class.class)).
-                    invoke(array, 0, 1, 1, Void.class);
+                    invokeExact(array, 0, 1, 1, Void.class);
             });
         }
 
         for (TestAccessMode am : testAccessModesOfType(TestAccessType.COMPARE_AND_EXCHANGE)) {
             // Incorrect argument types
             checkNPE(() -> { // null receiver
-                int x = (int) hs.get(am, methodType(int.class, Void.class, int.class, int.class, int.class)).
-                    invoke(null, 0, 1, 1);
+                int x = (int) hs.get(am, methodType(int.class, int[].class, int.class, int.class, int.class)).
+                    invokeExact((int[]) null, 0, 1, 1);
             });
-            checkCCE(() -> { // array reference class
+            hs.checkWMTEOrCCE(() -> { // array reference class
                 int x = (int) hs.get(am, methodType(int.class, Class.class, int.class, int.class, int.class)).
-                    invoke(Void.class, 0, 1, 1);
+                    invokeExact(Void.class, 0, 1, 1);
             });
             checkWMTE(() -> { // expected reference class
                 int x = (int) hs.get(am, methodType(int.class, int[].class, int.class, Class.class, int.class)).
-                    invoke(array, 0, Void.class, 1);
+                    invokeExact(array, 0, Void.class, 1);
             });
             checkWMTE(() -> { // actual reference class
                 int x = (int) hs.get(am, methodType(int.class, int[].class, int.class, int.class, Class.class)).
-                    invoke(array, 0, 1, Void.class);
+                    invokeExact(array, 0, 1, Void.class);
             });
             checkWMTE(() -> { // array primitive class
                 int x = (int) hs.get(am, methodType(int.class, int.class, int.class, int.class, int.class)).
-                    invoke(0, 0, 1, 1);
+                    invokeExact(0, 0, 1, 1);
             });
             checkWMTE(() -> { // index reference class
                 int x = (int) hs.get(am, methodType(int.class, int[].class, Class.class, int.class, int.class)).
-                    invoke(array, Void.class, 1, 1);
+                    invokeExact(array, Void.class, 1, 1);
             });
             // Incorrect return type
             checkWMTE(() -> { // reference class
                 Void r = (Void) hs.get(am, methodType(Void.class, int[].class, int.class, int.class, int.class)).
-                    invoke(array, 0, 1, 1);
+                    invokeExact(array, 0, 1, 1);
             });
             checkWMTE(() -> { // primitive class
                 boolean x = (boolean) hs.get(am, methodType(boolean.class, int[].class, int.class, int.class, int.class)).
-                    invoke(array, 0, 1, 1);
+                    invokeExact(array, 0, 1, 1);
             });
             // Incorrect arity
             checkWMTE(() -> { // 0
                 int x = (int) hs.get(am, methodType(int.class)).
-                    invoke();
+                    invokeExact();
             });
             checkWMTE(() -> { // >
                 int x = (int) hs.get(am, methodType(int.class, int[].class, int.class, int.class, int.class, Class.class)).
-                    invoke(array, 0, 1, 1, Void.class);
+                    invokeExact(array, 0, 1, 1, Void.class);
             });
         }
 
         for (TestAccessMode am : testAccessModesOfType(TestAccessType.GET_AND_SET)) {
             // Incorrect argument types
             checkNPE(() -> { // null array
-                int x = (int) hs.get(am, methodType(int.class, Void.class, int.class, int.class)).
-                    invoke(null, 0, 1);
+                int x = (int) hs.get(am, methodType(int.class, int[].class, int.class, int.class)).
+                    invokeExact((int[]) null, 0, 1);
             });
-            checkCCE(() -> { // array reference class
+            hs.checkWMTEOrCCE(() -> { // array reference class
                 int x = (int) hs.get(am, methodType(int.class, Class.class, int.class, int.class)).
-                    invoke(Void.class, 0, 1);
+                    invokeExact(Void.class, 0, 1);
             });
             checkWMTE(() -> { // value reference class
                 int x = (int) hs.get(am, methodType(int.class, int[].class, int.class, Class.class)).
-                    invoke(array, 0, Void.class);
+                    invokeExact(array, 0, Void.class);
             });
             checkWMTE(() -> { // array primitive class
                 int x = (int) hs.get(am, methodType(int.class, int.class, int.class, int.class)).
-                    invoke(0, 0, 1);
+                    invokeExact(0, 0, 1);
             });
             checkWMTE(() -> { // index reference class
                 int x = (int) hs.get(am, methodType(int.class, int[].class, Class.class, int.class)).
-                    invoke(array, Void.class, 1);
+                    invokeExact(array, Void.class, 1);
             });
             // Incorrect return type
             checkWMTE(() -> { // reference class
                 Void r = (Void) hs.get(am, methodType(Void.class, int[].class, int.class, int.class)).
-                    invoke(array, 0, 1);
+                    invokeExact(array, 0, 1);
             });
             checkWMTE(() -> { // primitive class
                 boolean x = (boolean) hs.get(am, methodType(boolean.class, int[].class, int.class, int.class)).
-                    invoke(array, 0, 1);
+                    invokeExact(array, 0, 1);
             });
             // Incorrect arity
             checkWMTE(() -> { // 0
                 int x = (int) hs.get(am, methodType(int.class)).
-                    invoke();
+                    invokeExact();
             });
             checkWMTE(() -> { // >
                 int x = (int) hs.get(am, methodType(int.class, int[].class, int.class, int.class, Class.class)).
-                    invoke(array, 0, 1, Void.class);
+                    invokeExact(array, 0, 1, Void.class);
             });
         }
 
         for (TestAccessMode am : testAccessModesOfType(TestAccessType.GET_AND_ADD)) {
             // Incorrect argument types
             checkNPE(() -> { // null array
-                int x = (int) hs.get(am, methodType(int.class, Void.class, int.class, int.class)).
-                    invoke(null, 0, 1);
+                int x = (int) hs.get(am, methodType(int.class, int[].class, int.class, int.class)).
+                    invokeExact((int[]) null, 0, 1);
             });
-            checkCCE(() -> { // array reference class
+            hs.checkWMTEOrCCE(() -> { // array reference class
                 int x = (int) hs.get(am, methodType(int.class, Class.class, int.class, int.class)).
-                    invoke(Void.class, 0, 1);
+                    invokeExact(Void.class, 0, 1);
             });
             checkWMTE(() -> { // value reference class
                 int x = (int) hs.get(am, methodType(int.class, int[].class, int.class, Class.class)).
-                    invoke(array, 0, Void.class);
+                    invokeExact(array, 0, Void.class);
             });
             checkWMTE(() -> { // array primitive class
                 int x = (int) hs.get(am, methodType(int.class, int.class, int.class, int.class)).
-                    invoke(0, 0, 1);
+                    invokeExact(0, 0, 1);
             });
             checkWMTE(() -> { // index reference class
                 int x = (int) hs.get(am, methodType(int.class, int[].class, Class.class, int.class)).
-                    invoke(array, Void.class, 1);
+                    invokeExact(array, Void.class, 1);
             });
             // Incorrect return type
             checkWMTE(() -> { // reference class
                 Void r = (Void) hs.get(am, methodType(Void.class, int[].class, int.class, int.class)).
-                    invoke(array, 0, 1);
+                    invokeExact(array, 0, 1);
             });
             checkWMTE(() -> { // primitive class
                 boolean x = (boolean) hs.get(am, methodType(boolean.class, int[].class, int.class, int.class)).
-                    invoke(array, 0, 1);
+                    invokeExact(array, 0, 1);
             });
             // Incorrect arity
             checkWMTE(() -> { // 0
                 int x = (int) hs.get(am, methodType(int.class)).
-                    invoke();
+                    invokeExact();
             });
             checkWMTE(() -> { // >
                 int x = (int) hs.get(am, methodType(int.class, int[].class, int.class, int.class, Class.class)).
-                    invoke(array, 0, 1, Void.class);
+                    invokeExact(array, 0, 1, Void.class);
             });
         }
     }
--- a/jdk/test/java/lang/invoke/VarHandles/VarHandleTestMethodTypeLong.java	Thu May 19 17:48:02 2016 +0000
+++ b/jdk/test/java/lang/invoke/VarHandles/VarHandleTestMethodTypeLong.java	Thu May 19 19:46:20 2016 +0000
@@ -23,6 +23,7 @@
 
 /*
  * @test
+ * @bug 8156486
  * @run testng/othervm VarHandleTestMethodTypeLong
  * @run testng/othervm -Djava.lang.invoke.VarHandle.VAR_HANDLE_GUARDS=false VarHandleTestMethodTypeLong
  */
@@ -81,27 +82,28 @@
     public Object[][] accessTestCaseProvider() throws Exception {
         List<AccessTestCase<?>> cases = new ArrayList<>();
 
-        cases.add(new VarHandleAccessTestCase("Instance field wrong method type",
+        cases.add(new VarHandleAccessTestCase("Instance field",
                                               vhField, vh -> testInstanceFieldWrongMethodType(this, vh),
                                               false));
 
-        cases.add(new VarHandleAccessTestCase("Static field wrong method type",
+        cases.add(new VarHandleAccessTestCase("Static field",
                                               vhStaticField, VarHandleTestMethodTypeLong::testStaticFieldWrongMethodType,
                                               false));
 
-        cases.add(new VarHandleAccessTestCase("Array wrong method type",
+        cases.add(new VarHandleAccessTestCase("Array",
                                               vhArray, VarHandleTestMethodTypeLong::testArrayWrongMethodType,
                                               false));
+
         for (VarHandleToMethodHandle f : VarHandleToMethodHandle.values()) {
-            cases.add(new MethodHandleAccessTestCase("Instance field wrong method type",
+            cases.add(new MethodHandleAccessTestCase("Instance field",
                                                      vhField, f, hs -> testInstanceFieldWrongMethodType(this, hs),
                                                      false));
 
-            cases.add(new MethodHandleAccessTestCase("Static field wrong method type",
+            cases.add(new MethodHandleAccessTestCase("Static field",
                                                      vhStaticField, f, VarHandleTestMethodTypeLong::testStaticFieldWrongMethodType,
                                                      false));
 
-            cases.add(new MethodHandleAccessTestCase("Array wrong method type",
+            cases.add(new MethodHandleAccessTestCase("Array",
                                                      vhArray, f, VarHandleTestMethodTypeLong::testArrayWrongMethodType,
                                                      false));
         }
@@ -644,211 +646,211 @@
         for (TestAccessMode am : testAccessModesOfType(TestAccessType.GET)) {
             // Incorrect argument types
             checkNPE(() -> { // null receiver
-                long x = (long) hs.get(am, methodType(long.class, Void.class)).
-                    invoke(null);
+                long x = (long) hs.get(am, methodType(long.class, VarHandleTestMethodTypeLong.class)).
+                    invokeExact((VarHandleTestMethodTypeLong) null);
             });
-            checkCCE(() -> { // receiver reference class
+            hs.checkWMTEOrCCE(() -> { // receiver reference class
                 long x = (long) hs.get(am, methodType(long.class, Class.class)).
-                    invoke(Void.class);
+                    invokeExact(Void.class);
             });
             checkWMTE(() -> { // receiver primitive class
                 long x = (long) hs.get(am, methodType(long.class, int.class)).
-                    invoke(0);
+                    invokeExact(0);
             });
             // Incorrect return type
             checkWMTE(() -> { // reference class
-                Void x = (Void) hs.get(am, methodType(long.class, VarHandleTestMethodTypeLong.class)).
-                    invoke(recv);
+                Void x = (Void) hs.get(am, methodType(Void.class, VarHandleTestMethodTypeLong.class)).
+                    invokeExact(recv);
             });
             checkWMTE(() -> { // primitive class
                 boolean x = (boolean) hs.get(am, methodType(boolean.class, VarHandleTestMethodTypeLong.class)).
-                    invoke(recv);
+                    invokeExact(recv);
             });
             // Incorrect arity
             checkWMTE(() -> { // 0
                 long x = (long) hs.get(am, methodType(long.class)).
-                    invoke();
+                    invokeExact();
             });
             checkWMTE(() -> { // >
                 long x = (long) hs.get(am, methodType(long.class, VarHandleTestMethodTypeLong.class, Class.class)).
-                    invoke(recv, Void.class);
+                    invokeExact(recv, Void.class);
             });
         }
 
         for (TestAccessMode am : testAccessModesOfType(TestAccessType.SET)) {
             // Incorrect argument types
             checkNPE(() -> { // null receiver
-                hs.get(am, methodType(void.class, Void.class, long.class)).
-                    invoke(null, 1L);
+                hs.get(am, methodType(void.class, VarHandleTestMethodTypeLong.class, long.class)).
+                    invokeExact((VarHandleTestMethodTypeLong) null, 1L);
             });
-            checkCCE(() -> { // receiver reference class
+            hs.checkWMTEOrCCE(() -> { // receiver reference class
                 hs.get(am, methodType(void.class, Class.class, long.class)).
-                    invoke(Void.class, 1L);
+                    invokeExact(Void.class, 1L);
             });
             checkWMTE(() -> { // value reference class
                 hs.get(am, methodType(void.class, VarHandleTestMethodTypeLong.class, Class.class)).
-                    invoke(recv, Void.class);
+                    invokeExact(recv, Void.class);
             });
             checkWMTE(() -> { // receiver primitive class
                 hs.get(am, methodType(void.class, int.class, long.class)).
-                    invoke(0, 1L);
+                    invokeExact(0, 1L);
             });
             // Incorrect arity
             checkWMTE(() -> { // 0
                 hs.get(am, methodType(void.class)).
-                    invoke();
+                    invokeExact();
             });
             checkWMTE(() -> { // >
                 hs.get(am, methodType(void.class, VarHandleTestMethodTypeLong.class, long.class, Class.class)).
-                    invoke(recv, 1L, Void.class);
+                    invokeExact(recv, 1L, Void.class);
             });
         }
 
         for (TestAccessMode am : testAccessModesOfType(TestAccessType.COMPARE_AND_SET)) {
             // Incorrect argument types
             checkNPE(() -> { // null receiver
-                boolean r = (boolean) hs.get(am, methodType(boolean.class, Void.class, long.class, long.class)).
-                    invoke(null, 1L, 1L);
+                boolean r = (boolean) hs.get(am, methodType(boolean.class, VarHandleTestMethodTypeLong.class, long.class, long.class)).
+                    invokeExact((VarHandleTestMethodTypeLong) null, 1L, 1L);
             });
-            checkCCE(() -> { // receiver reference class
+            hs.checkWMTEOrCCE(() -> { // receiver reference class
                 boolean r = (boolean) hs.get(am, methodType(boolean.class, Class.class, long.class, long.class)).
-                    invoke(Void.class, 1L, 1L);
+                    invokeExact(Void.class, 1L, 1L);
             });
             checkWMTE(() -> { // expected reference class
                 boolean r = (boolean) hs.get(am, methodType(boolean.class, VarHandleTestMethodTypeLong.class, Class.class, long.class)).
-                    invoke(recv, Void.class, 1L);
+                    invokeExact(recv, Void.class, 1L);
             });
             checkWMTE(() -> { // actual reference class
                 boolean r = (boolean) hs.get(am, methodType(boolean.class, VarHandleTestMethodTypeLong.class, long.class, Class.class)).
-                    invoke(recv, 1L, Void.class);
+                    invokeExact(recv, 1L, Void.class);
             });
             checkWMTE(() -> { // receiver primitive class
                 boolean r = (boolean) hs.get(am, methodType(boolean.class, int.class , long.class, long.class)).
-                    invoke(0, 1L, 1L);
+                    invokeExact(0, 1L, 1L);
             });
             // Incorrect arity
             checkWMTE(() -> { // 0
                 boolean r = (boolean) hs.get(am, methodType(boolean.class)).
-                    invoke();
+                    invokeExact();
             });
             checkWMTE(() -> { // >
                 boolean r = (boolean) hs.get(am, methodType(boolean.class, VarHandleTestMethodTypeLong.class, long.class, long.class, Class.class)).
-                    invoke(recv, 1L, 1L, Void.class);
+                    invokeExact(recv, 1L, 1L, Void.class);
             });
         }
 
         for (TestAccessMode am : testAccessModesOfType(TestAccessType.COMPARE_AND_EXCHANGE)) {
             checkNPE(() -> { // null receiver
-                long x = (long) hs.get(am, methodType(long.class, Void.class, long.class, long.class)).
-                    invoke(null, 1L, 1L);
+                long x = (long) hs.get(am, methodType(long.class, VarHandleTestMethodTypeLong.class, long.class, long.class)).
+                    invokeExact((VarHandleTestMethodTypeLong) null, 1L, 1L);
             });
-            checkCCE(() -> { // receiver reference class
+            hs.checkWMTEOrCCE(() -> { // receiver reference class
                 long x = (long) hs.get(am, methodType(long.class, Class.class, long.class, long.class)).
-                    invoke(Void.class, 1L, 1L);
+                    invokeExact(Void.class, 1L, 1L);
             });
             checkWMTE(() -> { // expected reference class
                 long x = (long) hs.get(am, methodType(long.class, VarHandleTestMethodTypeLong.class, Class.class, long.class)).
-                    invoke(recv, Void.class, 1L);
+                    invokeExact(recv, Void.class, 1L);
             });
             checkWMTE(() -> { // actual reference class
                 long x = (long) hs.get(am, methodType(long.class, VarHandleTestMethodTypeLong.class, long.class, Class.class)).
-                    invoke(recv, 1L, Void.class);
+                    invokeExact(recv, 1L, Void.class);
             });
             checkWMTE(() -> { // reciever primitive class
                 long x = (long) hs.get(am, methodType(long.class, int.class , long.class, long.class)).
-                    invoke(0, 1L, 1L);
+                    invokeExact(0, 1L, 1L);
             });
             // Incorrect return type
             checkWMTE(() -> { // reference class
                 Void r = (Void) hs.get(am, methodType(Void.class, VarHandleTestMethodTypeLong.class , long.class, long.class)).
-                    invoke(recv, 1L, 1L);
+                    invokeExact(recv, 1L, 1L);
             });
             checkWMTE(() -> { // primitive class
                 boolean x = (boolean) hs.get(am, methodType(boolean.class, VarHandleTestMethodTypeLong.class , long.class, long.class)).
-                    invoke(recv, 1L, 1L);
+                    invokeExact(recv, 1L, 1L);
             });
             // Incorrect arity
             checkWMTE(() -> { // 0
                 long x = (long) hs.get(am, methodType(long.class)).
-                    invoke();
+                    invokeExact();
             });
             checkWMTE(() -> { // >
                 long x = (long) hs.get(am, methodType(long.class, VarHandleTestMethodTypeLong.class, long.class, long.class, Class.class)).
-                    invoke(recv, 1L, 1L, Void.class);
+                    invokeExact(recv, 1L, 1L, Void.class);
             });
         }
 
         for (TestAccessMode am : testAccessModesOfType(TestAccessType.GET_AND_SET)) {
             checkNPE(() -> { // null receiver
-                long x = (long) hs.get(am, methodType(long.class, Void.class, long.class)).
-                    invoke(null, 1L);
+                long x = (long) hs.get(am, methodType(long.class, VarHandleTestMethodTypeLong.class, long.class)).
+                    invokeExact((VarHandleTestMethodTypeLong) null, 1L);
             });
-            checkCCE(() -> { // receiver reference class
+            hs.checkWMTEOrCCE(() -> { // receiver reference class
                 long x = (long) hs.get(am, methodType(long.class, Class.class, long.class)).
-                    invoke(Void.class, 1L);
+                    invokeExact(Void.class, 1L);
             });
             checkWMTE(() -> { // value reference class
                 long x = (long) hs.get(am, methodType(long.class, VarHandleTestMethodTypeLong.class, Class.class)).
-                    invoke(recv, Void.class);
+                    invokeExact(recv, Void.class);
             });
             checkWMTE(() -> { // reciever primitive class
                 long x = (long) hs.get(am, methodType(long.class, int.class, long.class)).
-                    invoke(0, 1L);
+                    invokeExact(0, 1L);
             });
             // Incorrect return type
             checkWMTE(() -> { // reference class
                 Void r = (Void) hs.get(am, methodType(Void.class, VarHandleTestMethodTypeLong.class, long.class)).
-                    invoke(recv, 1L);
+                    invokeExact(recv, 1L);
             });
             checkWMTE(() -> { // primitive class
                 boolean x = (boolean) hs.get(am, methodType(boolean.class, VarHandleTestMethodTypeLong.class, long.class)).
-                    invoke(recv, 1L);
+                    invokeExact(recv, 1L);
             });
             // Incorrect arity
             checkWMTE(() -> { // 0
                 long x = (long) hs.get(am, methodType(long.class)).
-                    invoke();
+                    invokeExact();
             });
             checkWMTE(() -> { // >
                 long x = (long) hs.get(am, methodType(long.class, VarHandleTestMethodTypeLong.class, long.class)).
-                    invoke(recv, 1L, Void.class);
+                    invokeExact(recv, 1L, Void.class);
             });
         }
 
         for (TestAccessMode am : testAccessModesOfType(TestAccessType.GET_AND_ADD)) {
             checkNPE(() -> { // null receiver
-                long x = (long) hs.get(am, methodType(long.class, Void.class, long.class)).
-                    invoke(null, 1L);
+                long x = (long) hs.get(am, methodType(long.class, VarHandleTestMethodTypeLong.class, long.class)).
+                    invokeExact((VarHandleTestMethodTypeLong) null, 1L);
             });
-            checkCCE(() -> { // receiver reference class
+            hs.checkWMTEOrCCE(() -> { // receiver reference class
                 long x = (long) hs.get(am, methodType(long.class, Class.class, long.class)).
-                    invoke(Void.class, 1L);
+                    invokeExact(Void.class, 1L);
             });
             checkWMTE(() -> { // value reference class
                 long x = (long) hs.get(am, methodType(long.class, VarHandleTestMethodTypeLong.class, Class.class)).
-                    invoke(recv, Void.class);
+                    invokeExact(recv, Void.class);
             });
             checkWMTE(() -> { // reciever primitive class
                 long x = (long) hs.get(am, methodType(long.class, int.class, long.class)).
-                    invoke(0, 1L);
+                    invokeExact(0, 1L);
             });
             // Incorrect return type
             checkWMTE(() -> { // reference class
                 Void r = (Void) hs.get(am, methodType(Void.class, VarHandleTestMethodTypeLong.class, long.class)).
-                    invoke(recv, 1L);
+                    invokeExact(recv, 1L);
             });
             checkWMTE(() -> { // primitive class
                 boolean x = (boolean) hs.get(am, methodType(boolean.class, VarHandleTestMethodTypeLong.class, long.class)).
-                    invoke(recv, 1L);
+                    invokeExact(recv, 1L);
             });
             // Incorrect arity
             checkWMTE(() -> { // 0
                 long x = (long) hs.get(am, methodType(long.class)).
-                    invoke();
+                    invokeExact();
             });
             checkWMTE(() -> { // >
                 long x = (long) hs.get(am, methodType(long.class, VarHandleTestMethodTypeLong.class, long.class)).
-                    invoke(recv, 1L, Void.class);
+                    invokeExact(recv, 1L, Void.class);
             });
         }
     }
@@ -1190,52 +1192,52 @@
             // Incorrect return type
             checkWMTE(() -> { // reference class
                 Void x = (Void) hs.get(am, methodType(Void.class)).
-                    invoke();
+                    invokeExact();
             });
             checkWMTE(() -> { // primitive class
                 boolean x = (boolean) hs.get(am, methodType(boolean.class)).
-                    invoke();
+                    invokeExact();
             });
             // Incorrect arity
             checkWMTE(() -> { // >
                 long x = (long) hs.get(am, methodType(Class.class)).
-                    invoke(Void.class);
+                    invokeExact(Void.class);
             });
         }
 
         for (TestAccessMode am : testAccessModesOfType(TestAccessType.SET)) {
             checkWMTE(() -> { // value reference class
                 hs.get(am, methodType(void.class, Class.class)).
-                    invoke(Void.class);
+                    invokeExact(Void.class);
             });
             // Incorrect arity
             checkWMTE(() -> { // 0
                 hs.get(am, methodType(void.class)).
-                    invoke();
+                    invokeExact();
             });
             checkWMTE(() -> { // >
                 hs.get(am, methodType(void.class, long.class, Class.class)).
-                    invoke(1L, Void.class);
+                    invokeExact(1L, Void.class);
             });
         }
         for (TestAccessMode am : testAccessModesOfType(TestAccessType.COMPARE_AND_SET)) {
             // Incorrect argument types
             checkWMTE(() -> { // expected reference class
                 boolean r = (boolean) hs.get(am, methodType(boolean.class, Class.class, long.class)).
-                    invoke(Void.class, 1L);
+                    invokeExact(Void.class, 1L);
             });
             checkWMTE(() -> { // actual reference class
                 boolean r = (boolean) hs.get(am, methodType(boolean.class, long.class, Class.class)).
-                    invoke(1L, Void.class);
+                    invokeExact(1L, Void.class);
             });
             // Incorrect arity
             checkWMTE(() -> { // 0
                 boolean r = (boolean) hs.get(am, methodType(boolean.class)).
-                    invoke();
+                    invokeExact();
             });
             checkWMTE(() -> { // >
                 boolean r = (boolean) hs.get(am, methodType(boolean.class, long.class, long.class, Class.class)).
-                    invoke(1L, 1L, Void.class);
+                    invokeExact(1L, 1L, Void.class);
             });
         }
 
@@ -1243,29 +1245,29 @@
             // Incorrect argument types
             checkWMTE(() -> { // expected reference class
                 long x = (long) hs.get(am, methodType(long.class, Class.class, long.class)).
-                    invoke(Void.class, 1L);
+                    invokeExact(Void.class, 1L);
             });
             checkWMTE(() -> { // actual reference class
                 long x = (long) hs.get(am, methodType(long.class, long.class, Class.class)).
-                    invoke(1L, Void.class);
+                    invokeExact(1L, Void.class);
             });
             // Incorrect return type
             checkWMTE(() -> { // reference class
                 Void r = (Void) hs.get(am, methodType(Void.class, long.class, long.class)).
-                    invoke(1L, 1L);
+                    invokeExact(1L, 1L);
             });
             checkWMTE(() -> { // primitive class
                 boolean x = (boolean) hs.get(am, methodType(boolean.class, long.class, long.class)).
-                    invoke(1L, 1L);
+                    invokeExact(1L, 1L);
             });
             // Incorrect arity
             checkWMTE(() -> { // 0
                 long x = (long) hs.get(am, methodType(long.class)).
-                    invoke();
+                    invokeExact();
             });
             checkWMTE(() -> { // >
                 long x = (long) hs.get(am, methodType(long.class, long.class, long.class, Class.class)).
-                    invoke(1L, 1L, Void.class);
+                    invokeExact(1L, 1L, Void.class);
             });
         }
 
@@ -1273,25 +1275,25 @@
             // Incorrect argument types
             checkWMTE(() -> { // value reference class
                 long x = (long) hs.get(am, methodType(long.class, Class.class)).
-                    invoke(Void.class);
+                    invokeExact(Void.class);
             });
             // Incorrect return type
             checkWMTE(() -> { // reference class
                 Void r = (Void) hs.get(am, methodType(Void.class, long.class)).
-                    invoke(1L);
+                    invokeExact(1L);
             });
             checkWMTE(() -> { // primitive class
                 boolean x = (boolean) hs.get(am, methodType(boolean.class, long.class)).
-                    invoke(1L);
+                    invokeExact(1L);
             });
             // Incorrect arity
             checkWMTE(() -> { // 0
                 long x = (long) hs.get(am, methodType(long.class)).
-                    invoke();
+                    invokeExact();
             });
             checkWMTE(() -> { // >
                 long x = (long) hs.get(am, methodType(long.class, long.class, Class.class)).
-                    invoke(1L, Void.class);
+                    invokeExact(1L, Void.class);
             });
         }
 
@@ -1299,25 +1301,25 @@
             // Incorrect argument types
             checkWMTE(() -> { // value reference class
                 long x = (long) hs.get(am, methodType(long.class, Class.class)).
-                    invoke(Void.class);
+                    invokeExact(Void.class);
             });
             // Incorrect return type
             checkWMTE(() -> { // reference class
                 Void r = (Void) hs.get(am, methodType(Void.class, long.class)).
-                    invoke(1L);
+                    invokeExact(1L);
             });
             checkWMTE(() -> { // primitive class
                 boolean x = (boolean) hs.get(am, methodType(boolean.class, long.class)).
-                    invoke(1L);
+                    invokeExact(1L);
             });
             // Incorrect arity
             checkWMTE(() -> { // 0
                 long x = (long) hs.get(am, methodType(long.class)).
-                    invoke();
+                    invokeExact();
             });
             checkWMTE(() -> { // >
                 long x = (long) hs.get(am, methodType(long.class, long.class, Class.class)).
-                    invoke(1L, Void.class);
+                    invokeExact(1L, Void.class);
             });
         }
     }
@@ -1909,237 +1911,237 @@
         for (TestAccessMode am : testAccessModesOfType(TestAccessType.GET)) {
             // Incorrect argument types
             checkNPE(() -> { // null array
-                long x = (long) hs.get(am, methodType(long.class, Void.class, int.class)).
-                    invoke(null, 0);
+                long x = (long) hs.get(am, methodType(long.class, long[].class, int.class)).
+                    invokeExact((long[]) null, 0);
             });
-            checkCCE(() -> { // array reference class
+            hs.checkWMTEOrCCE(() -> { // array reference class
                 long x = (long) hs.get(am, methodType(long.class, Class.class, int.class)).
-                    invoke(Void.class, 0);
+                    invokeExact(Void.class, 0);
             });
             checkWMTE(() -> { // array primitive class
                 long x = (long) hs.get(am, methodType(long.class, int.class, int.class)).
-                    invoke(0, 0);
+                    invokeExact(0, 0);
             });
             checkWMTE(() -> { // index reference class
                 long x = (long) hs.get(am, methodType(long.class, long[].class, Class.class)).
-                    invoke(array, Void.class);
+                    invokeExact(array, Void.class);
             });
             // Incorrect return type
             checkWMTE(() -> { // reference class
                 Void x = (Void) hs.get(am, methodType(Void.class, long[].class, int.class)).
-                    invoke(array, 0);
+                    invokeExact(array, 0);
             });
             checkWMTE(() -> { // primitive class
                 boolean x = (boolean) hs.get(am, methodType(boolean.class, long[].class, int.class)).
-                    invoke(array, 0);
+                    invokeExact(array, 0);
             });
             // Incorrect arity
             checkWMTE(() -> { // 0
                 long x = (long) hs.get(am, methodType(long.class)).
-                    invoke();
+                    invokeExact();
             });
             checkWMTE(() -> { // >
                 long x = (long) hs.get(am, methodType(long.class, long[].class, int.class, Class.class)).
-                    invoke(array, 0, Void.class);
+                    invokeExact(array, 0, Void.class);
             });
         }
 
         for (TestAccessMode am : testAccessModesOfType(TestAccessType.SET)) {
             // Incorrect argument types
             checkNPE(() -> { // null array
-                hs.get(am, methodType(void.class, Void.class, int.class, long.class)).
-                    invoke(null, 0, 1L);
+                hs.get(am, methodType(void.class, long[].class, int.class, long.class)).
+                    invokeExact((long[]) null, 0, 1L);
             });
-            checkCCE(() -> { // array reference class
+            hs.checkWMTEOrCCE(() -> { // array reference class
                 hs.get(am, methodType(void.class, Class.class, int.class, long.class)).
-                    invoke(Void.class, 0, 1L);
+                    invokeExact(Void.class, 0, 1L);
             });
             checkWMTE(() -> { // value reference class
                 hs.get(am, methodType(void.class, long[].class, int.class, Class.class)).
-                    invoke(array, 0, Void.class);
+                    invokeExact(array, 0, Void.class);
             });
             checkWMTE(() -> { // receiver primitive class
                 hs.get(am, methodType(void.class, int.class, int.class, long.class)).
-                    invoke(0, 0, 1L);
+                    invokeExact(0, 0, 1L);
             });
             checkWMTE(() -> { // index reference class
                 hs.get(am, methodType(void.class, long[].class, Class.class, long.class)).
-                    invoke(array, Void.class, 1L);
+                    invokeExact(array, Void.class, 1L);
             });
             // Incorrect arity
             checkWMTE(() -> { // 0
                 hs.get(am, methodType(void.class)).
-                    invoke();
+                    invokeExact();
             });
             checkWMTE(() -> { // >
                 hs.get(am, methodType(void.class, long[].class, int.class, Class.class)).
-                    invoke(array, 0, 1L, Void.class);
+                    invokeExact(array, 0, 1L, Void.class);
             });
         }
         for (TestAccessMode am : testAccessModesOfType(TestAccessType.COMPARE_AND_SET)) {
             // Incorrect argument types
             checkNPE(() -> { // null receiver
-                boolean r = (boolean) hs.get(am, methodType(boolean.class, Void.class, int.class, long.class, long.class)).
-                    invoke(null, 0, 1L, 1L);
+                boolean r = (boolean) hs.get(am, methodType(boolean.class, long[].class, int.class, long.class, long.class)).
+                    invokeExact((long[]) null, 0, 1L, 1L);
             });
-            checkCCE(() -> { // receiver reference class
+            hs.checkWMTEOrCCE(() -> { // receiver reference class
                 boolean r = (boolean) hs.get(am, methodType(boolean.class, Class.class, int.class, long.class, long.class)).
-                    invoke(Void.class, 0, 1L, 1L);
+                    invokeExact(Void.class, 0, 1L, 1L);
             });
             checkWMTE(() -> { // expected reference class
                 boolean r = (boolean) hs.get(am, methodType(boolean.class, long[].class, int.class, Class.class, long.class)).
-                    invoke(array, 0, Void.class, 1L);
+                    invokeExact(array, 0, Void.class, 1L);
             });
             checkWMTE(() -> { // actual reference class
                 boolean r = (boolean) hs.get(am, methodType(boolean.class, long[].class, int.class, long.class, Class.class)).
-                    invoke(array, 0, 1L, Void.class);
+                    invokeExact(array, 0, 1L, Void.class);
             });
             checkWMTE(() -> { // receiver primitive class
                 boolean r = (boolean) hs.get(am, methodType(boolean.class, int.class, int.class, long.class, long.class)).
-                    invoke(0, 0, 1L, 1L);
+                    invokeExact(0, 0, 1L, 1L);
             });
             checkWMTE(() -> { // index reference class
                 boolean r = (boolean) hs.get(am, methodType(boolean.class, long[].class, Class.class, long.class, long.class)).
-                    invoke(array, Void.class, 1L, 1L);
+                    invokeExact(array, Void.class, 1L, 1L);
             });
             // Incorrect arity
             checkWMTE(() -> { // 0
                 boolean r = (boolean) hs.get(am, methodType(boolean.class)).
-                    invoke();
+                    invokeExact();
             });
             checkWMTE(() -> { // >
                 boolean r = (boolean) hs.get(am, methodType(boolean.class, long[].class, int.class, long.class, long.class, Class.class)).
-                    invoke(array, 0, 1L, 1L, Void.class);
+                    invokeExact(array, 0, 1L, 1L, Void.class);
             });
         }
 
         for (TestAccessMode am : testAccessModesOfType(TestAccessType.COMPARE_AND_EXCHANGE)) {
             // Incorrect argument types
             checkNPE(() -> { // null receiver
-                long x = (long) hs.get(am, methodType(long.class, Void.class, int.class, long.class, long.class)).
-                    invoke(null, 0, 1L, 1L);
+                long x = (long) hs.get(am, methodType(long.class, long[].class, int.class, long.class, long.class)).
+                    invokeExact((long[]) null, 0, 1L, 1L);
             });
-            checkCCE(() -> { // array reference class
+            hs.checkWMTEOrCCE(() -> { // array reference class
                 long x = (long) hs.get(am, methodType(long.class, Class.class, int.class, long.class, long.class)).
-                    invoke(Void.class, 0, 1L, 1L);
+                    invokeExact(Void.class, 0, 1L, 1L);
             });
             checkWMTE(() -> { // expected reference class
                 long x = (long) hs.get(am, methodType(long.class, long[].class, int.class, Class.class, long.class)).
-                    invoke(array, 0, Void.class, 1L);
+                    invokeExact(array, 0, Void.class, 1L);
             });
             checkWMTE(() -> { // actual reference class
                 long x = (long) hs.get(am, methodType(long.class, long[].class, int.class, long.class, Class.class)).
-                    invoke(array, 0, 1L, Void.class);
+                    invokeExact(array, 0, 1L, Void.class);
             });
             checkWMTE(() -> { // array primitive class
                 long x = (long) hs.get(am, methodType(long.class, int.class, int.class, long.class, long.class)).
-                    invoke(0, 0, 1L, 1L);
+                    invokeExact(0, 0, 1L, 1L);
             });
             checkWMTE(() -> { // index reference class
                 long x = (long) hs.get(am, methodType(long.class, long[].class, Class.class, long.class, long.class)).
-                    invoke(array, Void.class, 1L, 1L);
+                    invokeExact(array, Void.class, 1L, 1L);
             });
             // Incorrect return type
             checkWMTE(() -> { // reference class
                 Void r = (Void) hs.get(am, methodType(Void.class, long[].class, int.class, long.class, long.class)).
-                    invoke(array, 0, 1L, 1L);
+                    invokeExact(array, 0, 1L, 1L);
             });
             checkWMTE(() -> { // primitive class
                 boolean x = (boolean) hs.get(am, methodType(boolean.class, long[].class, int.class, long.class, long.class)).
-                    invoke(array, 0, 1L, 1L);
+                    invokeExact(array, 0, 1L, 1L);
             });
             // Incorrect arity
             checkWMTE(() -> { // 0
                 long x = (long) hs.get(am, methodType(long.class)).
-                    invoke();
+                    invokeExact();
             });
             checkWMTE(() -> { // >
                 long x = (long) hs.get(am, methodType(long.class, long[].class, int.class, long.class, long.class, Class.class)).
-                    invoke(array, 0, 1L, 1L, Void.class);
+                    invokeExact(array, 0, 1L, 1L, Void.class);
             });
         }
 
         for (TestAccessMode am : testAccessModesOfType(TestAccessType.GET_AND_SET)) {
             // Incorrect argument types
             checkNPE(() -> { // null array
-                long x = (long) hs.get(am, methodType(long.class, Void.class, int.class, long.class)).
-                    invoke(null, 0, 1L);
+                long x = (long) hs.get(am, methodType(long.class, long[].class, int.class, long.class)).
+                    invokeExact((long[]) null, 0, 1L);
             });
-            checkCCE(() -> { // array reference class
+            hs.checkWMTEOrCCE(() -> { // array reference class
                 long x = (long) hs.get(am, methodType(long.class, Class.class, int.class, long.class)).
-                    invoke(Void.class, 0, 1L);
+                    invokeExact(Void.class, 0, 1L);
             });
             checkWMTE(() -> { // value reference class
                 long x = (long) hs.get(am, methodType(long.class, long[].class, int.class, Class.class)).
-                    invoke(array, 0, Void.class);
+                    invokeExact(array, 0, Void.class);
             });
             checkWMTE(() -> { // array primitive class
                 long x = (long) hs.get(am, methodType(long.class, int.class, int.class, long.class)).
-                    invoke(0, 0, 1L);
+                    invokeExact(0, 0, 1L);
             });
             checkWMTE(() -> { // index reference class
                 long x = (long) hs.get(am, methodType(long.class, long[].class, Class.class, long.class)).
-                    invoke(array, Void.class, 1L);
+                    invokeExact(array, Void.class, 1L);
             });
             // Incorrect return type
             checkWMTE(() -> { // reference class
                 Void r = (Void) hs.get(am, methodType(Void.class, long[].class, int.class, long.class)).
-                    invoke(array, 0, 1L);
+                    invokeExact(array, 0, 1L);
             });
             checkWMTE(() -> { // primitive class
                 boolean x = (boolean) hs.get(am, methodType(boolean.class, long[].class, int.class, long.class)).
-                    invoke(array, 0, 1L);
+                    invokeExact(array, 0, 1L);
             });
             // Incorrect arity
             checkWMTE(() -> { // 0
                 long x = (long) hs.get(am, methodType(long.class)).
-                    invoke();
+                    invokeExact();
             });
             checkWMTE(() -> { // >
                 long x = (long) hs.get(am, methodType(long.class, long[].class, int.class, long.class, Class.class)).
-                    invoke(array, 0, 1L, Void.class);
+                    invokeExact(array, 0, 1L, Void.class);
             });
         }
 
         for (TestAccessMode am : testAccessModesOfType(TestAccessType.GET_AND_ADD)) {
             // Incorrect argument types
             checkNPE(() -> { // null array
-                long x = (long) hs.get(am, methodType(long.class, Void.class, int.class, long.class)).
-                    invoke(null, 0, 1L);
+                long x = (long) hs.get(am, methodType(long.class, long[].class, int.class, long.class)).
+                    invokeExact((long[]) null, 0, 1L);
             });
-            checkCCE(() -> { // array reference class
+            hs.checkWMTEOrCCE(() -> { // array reference class
                 long x = (long) hs.get(am, methodType(long.class, Class.class, int.class, long.class)).
-                    invoke(Void.class, 0, 1L);
+                    invokeExact(Void.class, 0, 1L);
             });
             checkWMTE(() -> { // value reference class
                 long x = (long) hs.get(am, methodType(long.class, long[].class, int.class, Class.class)).
-                    invoke(array, 0, Void.class);
+                    invokeExact(array, 0, Void.class);
             });
             checkWMTE(() -> { // array primitive class
                 long x = (long) hs.get(am, methodType(long.class, int.class, int.class, long.class)).
-                    invoke(0, 0, 1L);
+                    invokeExact(0, 0, 1L);
             });
             checkWMTE(() -> { // index reference class
                 long x = (long) hs.get(am, methodType(long.class, long[].class, Class.class, long.class)).
-                    invoke(array, Void.class, 1L);
+                    invokeExact(array, Void.class, 1L);
             });
             // Incorrect return type
             checkWMTE(() -> { // reference class
                 Void r = (Void) hs.get(am, methodType(Void.class, long[].class, int.class, long.class)).
-                    invoke(array, 0, 1L);
+                    invokeExact(array, 0, 1L);
             });
             checkWMTE(() -> { // primitive class
                 boolean x = (boolean) hs.get(am, methodType(boolean.class, long[].class, int.class, long.class)).
-                    invoke(array, 0, 1L);
+                    invokeExact(array, 0, 1L);
             });
             // Incorrect arity
             checkWMTE(() -> { // 0
                 long x = (long) hs.get(am, methodType(long.class)).
-                    invoke();
+                    invokeExact();
             });
             checkWMTE(() -> { // >
                 long x = (long) hs.get(am, methodType(long.class, long[].class, int.class, long.class, Class.class)).
-                    invoke(array, 0, 1L, Void.class);
+                    invokeExact(array, 0, 1L, Void.class);
             });
         }
     }
--- a/jdk/test/java/lang/invoke/VarHandles/VarHandleTestMethodTypeShort.java	Thu May 19 17:48:02 2016 +0000
+++ b/jdk/test/java/lang/invoke/VarHandles/VarHandleTestMethodTypeShort.java	Thu May 19 19:46:20 2016 +0000
@@ -23,6 +23,7 @@
 
 /*
  * @test
+ * @bug 8156486
  * @run testng/othervm VarHandleTestMethodTypeShort
  * @run testng/othervm -Djava.lang.invoke.VarHandle.VAR_HANDLE_GUARDS=false VarHandleTestMethodTypeShort
  */
@@ -81,27 +82,28 @@
     public Object[][] accessTestCaseProvider() throws Exception {
         List<AccessTestCase<?>> cases = new ArrayList<>();
 
-        cases.add(new VarHandleAccessTestCase("Instance field wrong method type",
+        cases.add(new VarHandleAccessTestCase("Instance field",
                                               vhField, vh -> testInstanceFieldWrongMethodType(this, vh),
                                               false));
 
-        cases.add(new VarHandleAccessTestCase("Static field wrong method type",
+        cases.add(new VarHandleAccessTestCase("Static field",
                                               vhStaticField, VarHandleTestMethodTypeShort::testStaticFieldWrongMethodType,
                                               false));
 
-        cases.add(new VarHandleAccessTestCase("Array wrong method type",
+        cases.add(new VarHandleAccessTestCase("Array",
                                               vhArray, VarHandleTestMethodTypeShort::testArrayWrongMethodType,
                                               false));
+
         for (VarHandleToMethodHandle f : VarHandleToMethodHandle.values()) {
-            cases.add(new MethodHandleAccessTestCase("Instance field wrong method type",
+            cases.add(new MethodHandleAccessTestCase("Instance field",
                                                      vhField, f, hs -> testInstanceFieldWrongMethodType(this, hs),
                                                      false));
 
-            cases.add(new MethodHandleAccessTestCase("Static field wrong method type",
+            cases.add(new MethodHandleAccessTestCase("Static field",
                                                      vhStaticField, f, VarHandleTestMethodTypeShort::testStaticFieldWrongMethodType,
                                                      false));
 
-            cases.add(new MethodHandleAccessTestCase("Array wrong method type",
+            cases.add(new MethodHandleAccessTestCase("Array",
                                                      vhArray, f, VarHandleTestMethodTypeShort::testArrayWrongMethodType,
                                                      false));
         }
@@ -329,63 +331,63 @@
         for (TestAccessMode am : testAccessModesOfType(TestAccessType.GET)) {
             // Incorrect argument types
             checkNPE(() -> { // null receiver
-                short x = (short) hs.get(am, methodType(short.class, Void.class)).
-                    invoke(null);
+                short x = (short) hs.get(am, methodType(short.class, VarHandleTestMethodTypeShort.class)).
+                    invokeExact((VarHandleTestMethodTypeShort) null);
             });
-            checkCCE(() -> { // receiver reference class
+            hs.checkWMTEOrCCE(() -> { // receiver reference class
                 short x = (short) hs.get(am, methodType(short.class, Class.class)).
-                    invoke(Void.class);
+                    invokeExact(Void.class);
             });
             checkWMTE(() -> { // receiver primitive class
                 short x = (short) hs.get(am, methodType(short.class, int.class)).
-                    invoke(0);
+                    invokeExact(0);
             });
             // Incorrect return type
             checkWMTE(() -> { // reference class
-                Void x = (Void) hs.get(am, methodType(short.class, VarHandleTestMethodTypeShort.class)).
-                    invoke(recv);
+                Void x = (Void) hs.get(am, methodType(Void.class, VarHandleTestMethodTypeShort.class)).
+                    invokeExact(recv);
             });
             checkWMTE(() -> { // primitive class
                 boolean x = (boolean) hs.get(am, methodType(boolean.class, VarHandleTestMethodTypeShort.class)).
-                    invoke(recv);
+                    invokeExact(recv);
             });
             // Incorrect arity
             checkWMTE(() -> { // 0
                 short x = (short) hs.get(am, methodType(short.class)).
-                    invoke();
+                    invokeExact();
             });
             checkWMTE(() -> { // >
                 short x = (short) hs.get(am, methodType(short.class, VarHandleTestMethodTypeShort.class, Class.class)).
-                    invoke(recv, Void.class);
+                    invokeExact(recv, Void.class);
             });
         }
 
         for (TestAccessMode am : testAccessModesOfType(TestAccessType.SET)) {
             // Incorrect argument types
             checkNPE(() -> { // null receiver
-                hs.get(am, methodType(void.class, Void.class, short.class)).
-                    invoke(null, (short)1);
+                hs.get(am, methodType(void.class, VarHandleTestMethodTypeShort.class, short.class)).
+                    invokeExact((VarHandleTestMethodTypeShort) null, (short)1);
             });
-            checkCCE(() -> { // receiver reference class
+            hs.checkWMTEOrCCE(() -> { // receiver reference class
                 hs.get(am, methodType(void.class, Class.class, short.class)).
-                    invoke(Void.class, (short)1);
+                    invokeExact(Void.class, (short)1);
             });
             checkWMTE(() -> { // value reference class
                 hs.get(am, methodType(void.class, VarHandleTestMethodTypeShort.class, Class.class)).
-                    invoke(recv, Void.class);
+                    invokeExact(recv, Void.class);
             });
             checkWMTE(() -> { // receiver primitive class
                 hs.get(am, methodType(void.class, int.class, short.class)).
-                    invoke(0, (short)1);
+                    invokeExact(0, (short)1);
             });
             // Incorrect arity
             checkWMTE(() -> { // 0
                 hs.get(am, methodType(void.class)).
-                    invoke();
+                    invokeExact();
             });
             checkWMTE(() -> { // >
                 hs.get(am, methodType(void.class, VarHandleTestMethodTypeShort.class, short.class, Class.class)).
-                    invoke(recv, (short)1, Void.class);
+                    invokeExact(recv, (short)1, Void.class);
             });
         }
 
@@ -513,32 +515,32 @@
             // Incorrect return type
             checkWMTE(() -> { // reference class
                 Void x = (Void) hs.get(am, methodType(Void.class)).
-                    invoke();
+                    invokeExact();
             });
             checkWMTE(() -> { // primitive class
                 boolean x = (boolean) hs.get(am, methodType(boolean.class)).
-                    invoke();
+                    invokeExact();
             });
             // Incorrect arity
             checkWMTE(() -> { // >
                 short x = (short) hs.get(am, methodType(Class.class)).
-                    invoke(Void.class);
+                    invokeExact(Void.class);
             });
         }
 
         for (TestAccessMode am : testAccessModesOfType(TestAccessType.SET)) {
             checkWMTE(() -> { // value reference class
                 hs.get(am, methodType(void.class, Class.class)).
-                    invoke(Void.class);
+                    invokeExact(Void.class);
             });
             // Incorrect arity
             checkWMTE(() -> { // 0
                 hs.get(am, methodType(void.class)).
-                    invoke();
+                    invokeExact();
             });
             checkWMTE(() -> { // >
                 hs.get(am, methodType(void.class, short.class, Class.class)).
-                    invoke((short)1, Void.class);
+                    invokeExact((short)1, Void.class);
             });
         }
 
@@ -783,71 +785,71 @@
         for (TestAccessMode am : testAccessModesOfType(TestAccessType.GET)) {
             // Incorrect argument types
             checkNPE(() -> { // null array
-                short x = (short) hs.get(am, methodType(short.class, Void.class, int.class)).
-                    invoke(null, 0);
+                short x = (short) hs.get(am, methodType(short.class, short[].class, int.class)).
+                    invokeExact((short[]) null, 0);
             });
-            checkCCE(() -> { // array reference class
+            hs.checkWMTEOrCCE(() -> { // array reference class
                 short x = (short) hs.get(am, methodType(short.class, Class.class, int.class)).
-                    invoke(Void.class, 0);
+                    invokeExact(Void.class, 0);
             });
             checkWMTE(() -> { // array primitive class
                 short x = (short) hs.get(am, methodType(short.class, int.class, int.class)).
-                    invoke(0, 0);
+                    invokeExact(0, 0);
             });
             checkWMTE(() -> { // index reference class
                 short x = (short) hs.get(am, methodType(short.class, short[].class, Class.class)).
-                    invoke(array, Void.class);
+                    invokeExact(array, Void.class);
             });
             // Incorrect return type
             checkWMTE(() -> { // reference class
                 Void x = (Void) hs.get(am, methodType(Void.class, short[].class, int.class)).
-                    invoke(array, 0);
+                    invokeExact(array, 0);
             });
             checkWMTE(() -> { // primitive class
                 boolean x = (boolean) hs.get(am, methodType(boolean.class, short[].class, int.class)).
-                    invoke(array, 0);
+                    invokeExact(array, 0);
             });
             // Incorrect arity
             checkWMTE(() -> { // 0
                 short x = (short) hs.get(am, methodType(short.class)).
-                    invoke();
+                    invokeExact();
             });
             checkWMTE(() -> { // >
                 short x = (short) hs.get(am, methodType(short.class, short[].class, int.class, Class.class)).
-                    invoke(array, 0, Void.class);
+                    invokeExact(array, 0, Void.class);
             });
         }
 
         for (TestAccessMode am : testAccessModesOfType(TestAccessType.SET)) {
             // Incorrect argument types
             checkNPE(() -> { // null array
-                hs.get(am, methodType(void.class, Void.class, int.class, short.class)).
-                    invoke(null, 0, (short)1);
+                hs.get(am, methodType(void.class, short[].class, int.class, short.class)).
+                    invokeExact((short[]) null, 0, (short)1);
             });
-            checkCCE(() -> { // array reference class
+            hs.checkWMTEOrCCE(() -> { // array reference class
                 hs.get(am, methodType(void.class, Class.class, int.class, short.class)).
-                    invoke(Void.class, 0, (short)1);
+                    invokeExact(Void.class, 0, (short)1);
             });
             checkWMTE(() -> { // value reference class
                 hs.get(am, methodType(void.class, short[].class, int.class, Class.class)).
-                    invoke(array, 0, Void.class);
+                    invokeExact(array, 0, Void.class);
             });
             checkWMTE(() -> { // receiver primitive class
                 hs.get(am, methodType(void.class, int.class, int.class, short.class)).
-                    invoke(0, 0, (short)1);
+                    invokeExact(0, 0, (short)1);
             });
             checkWMTE(() -> { // index reference class
                 hs.get(am, methodType(void.class, short[].class, Class.class, short.class)).
-                    invoke(array, Void.class, (short)1);
+                    invokeExact(array, Void.class, (short)1);
             });
             // Incorrect arity
             checkWMTE(() -> { // 0
                 hs.get(am, methodType(void.class)).
-                    invoke();
+                    invokeExact();
             });
             checkWMTE(() -> { // >
                 hs.get(am, methodType(void.class, short[].class, int.class, Class.class)).
-                    invoke(array, 0, (short)1, Void.class);
+                    invokeExact(array, 0, (short)1, Void.class);
             });
         }
 
--- a/jdk/test/java/lang/invoke/VarHandles/VarHandleTestMethodTypeString.java	Thu May 19 17:48:02 2016 +0000
+++ b/jdk/test/java/lang/invoke/VarHandles/VarHandleTestMethodTypeString.java	Thu May 19 19:46:20 2016 +0000
@@ -23,6 +23,7 @@
 
 /*
  * @test
+ * @bug 8156486
  * @run testng/othervm VarHandleTestMethodTypeString
  * @run testng/othervm -Djava.lang.invoke.VarHandle.VAR_HANDLE_GUARDS=false VarHandleTestMethodTypeString
  */
@@ -81,27 +82,28 @@
     public Object[][] accessTestCaseProvider() throws Exception {
         List<AccessTestCase<?>> cases = new ArrayList<>();
 
-        cases.add(new VarHandleAccessTestCase("Instance field wrong method type",
+        cases.add(new VarHandleAccessTestCase("Instance field",
                                               vhField, vh -> testInstanceFieldWrongMethodType(this, vh),
                                               false));
 
-        cases.add(new VarHandleAccessTestCase("Static field wrong method type",
+        cases.add(new VarHandleAccessTestCase("Static field",
                                               vhStaticField, VarHandleTestMethodTypeString::testStaticFieldWrongMethodType,
                                               false));
 
-        cases.add(new VarHandleAccessTestCase("Array wrong method type",
+        cases.add(new VarHandleAccessTestCase("Array",
                                               vhArray, VarHandleTestMethodTypeString::testArrayWrongMethodType,
                                               false));
+
         for (VarHandleToMethodHandle f : VarHandleToMethodHandle.values()) {
-            cases.add(new MethodHandleAccessTestCase("Instance field wrong method type",
+            cases.add(new MethodHandleAccessTestCase("Instance field",
                                                      vhField, f, hs -> testInstanceFieldWrongMethodType(this, hs),
                                                      false));
 
-            cases.add(new MethodHandleAccessTestCase("Static field wrong method type",
+            cases.add(new MethodHandleAccessTestCase("Static field",
                                                      vhStaticField, f, VarHandleTestMethodTypeString::testStaticFieldWrongMethodType,
                                                      false));
 
-            cases.add(new MethodHandleAccessTestCase("Array wrong method type",
+            cases.add(new MethodHandleAccessTestCase("Array",
                                                      vhArray, f, VarHandleTestMethodTypeString::testArrayWrongMethodType,
                                                      false));
         }
@@ -586,174 +588,174 @@
         for (TestAccessMode am : testAccessModesOfType(TestAccessType.GET)) {
             // Incorrect argument types
             checkNPE(() -> { // null receiver
-                String x = (String) hs.get(am, methodType(String.class, Void.class)).
-                    invoke(null);
+                String x = (String) hs.get(am, methodType(String.class, VarHandleTestMethodTypeString.class)).
+                    invokeExact((VarHandleTestMethodTypeString) null);
             });
-            checkCCE(() -> { // receiver reference class
+            hs.checkWMTEOrCCE(() -> { // receiver reference class
                 String x = (String) hs.get(am, methodType(String.class, Class.class)).
-                    invoke(Void.class);
+                    invokeExact(Void.class);
             });
             checkWMTE(() -> { // receiver primitive class
                 String x = (String) hs.get(am, methodType(String.class, int.class)).
-                    invoke(0);
+                    invokeExact(0);
             });
             // Incorrect return type
-            checkCCE(() -> { // reference class
-                Void x = (Void) hs.get(am, methodType(String.class, VarHandleTestMethodTypeString.class)).
-                    invoke(recv);
+            hs.checkWMTEOrCCE(() -> { // reference class
+                Void x = (Void) hs.get(am, methodType(Void.class, VarHandleTestMethodTypeString.class)).
+                    invokeExact(recv);
             });
             checkWMTE(() -> { // primitive class
                 boolean x = (boolean) hs.get(am, methodType(boolean.class, VarHandleTestMethodTypeString.class)).
-                    invoke(recv);
+                    invokeExact(recv);
             });
             // Incorrect arity
             checkWMTE(() -> { // 0
                 String x = (String) hs.get(am, methodType(String.class)).
-                    invoke();
+                    invokeExact();
             });
             checkWMTE(() -> { // >
                 String x = (String) hs.get(am, methodType(String.class, VarHandleTestMethodTypeString.class, Class.class)).
-                    invoke(recv, Void.class);
+                    invokeExact(recv, Void.class);
             });
         }
 
         for (TestAccessMode am : testAccessModesOfType(TestAccessType.SET)) {
             // Incorrect argument types
             checkNPE(() -> { // null receiver
-                hs.get(am, methodType(void.class, Void.class, String.class)).
-                    invoke(null, "foo");
+                hs.get(am, methodType(void.class, VarHandleTestMethodTypeString.class, String.class)).
+                    invokeExact((VarHandleTestMethodTypeString) null, "foo");
             });
-            checkCCE(() -> { // receiver reference class
+            hs.checkWMTEOrCCE(() -> { // receiver reference class
                 hs.get(am, methodType(void.class, Class.class, String.class)).
-                    invoke(Void.class, "foo");
+                    invokeExact(Void.class, "foo");
             });
-            checkCCE(() -> { // value reference class
+            hs.checkWMTEOrCCE(() -> { // value reference class
                 hs.get(am, methodType(void.class, VarHandleTestMethodTypeString.class, Class.class)).
-                    invoke(recv, Void.class);
+                    invokeExact(recv, Void.class);
             });
             checkWMTE(() -> { // receiver primitive class
                 hs.get(am, methodType(void.class, int.class, String.class)).
-                    invoke(0, "foo");
+                    invokeExact(0, "foo");
             });
             // Incorrect arity
             checkWMTE(() -> { // 0
                 hs.get(am, methodType(void.class)).
-                    invoke();
+                    invokeExact();
             });
             checkWMTE(() -> { // >
                 hs.get(am, methodType(void.class, VarHandleTestMethodTypeString.class, String.class, Class.class)).
-                    invoke(recv, "foo", Void.class);
+                    invokeExact(recv, "foo", Void.class);
             });
         }
 
         for (TestAccessMode am : testAccessModesOfType(TestAccessType.COMPARE_AND_SET)) {
             // Incorrect argument types
             checkNPE(() -> { // null receiver
-                boolean r = (boolean) hs.get(am, methodType(boolean.class, Void.class, String.class, String.class)).
-                    invoke(null, "foo", "foo");
+                boolean r = (boolean) hs.get(am, methodType(boolean.class, VarHandleTestMethodTypeString.class, String.class, String.class)).
+                    invokeExact((VarHandleTestMethodTypeString) null, "foo", "foo");
             });
-            checkCCE(() -> { // receiver reference class
+            hs.checkWMTEOrCCE(() -> { // receiver reference class
                 boolean r = (boolean) hs.get(am, methodType(boolean.class, Class.class, String.class, String.class)).
-                    invoke(Void.class, "foo", "foo");
+                    invokeExact(Void.class, "foo", "foo");
             });
-            checkCCE(() -> { // expected reference class
+            hs.checkWMTEOrCCE(() -> { // expected reference class
                 boolean r = (boolean) hs.get(am, methodType(boolean.class, VarHandleTestMethodTypeString.class, Class.class, String.class)).
-                    invoke(recv, Void.class, "foo");
+                    invokeExact(recv, Void.class, "foo");
             });
-            checkCCE(() -> { // actual reference class
+            hs.checkWMTEOrCCE(() -> { // actual reference class
                 boolean r = (boolean) hs.get(am, methodType(boolean.class, VarHandleTestMethodTypeString.class, String.class, Class.class)).
-                    invoke(recv, "foo", Void.class);
+                    invokeExact(recv, "foo", Void.class);
             });
             checkWMTE(() -> { // receiver primitive class
                 boolean r = (boolean) hs.get(am, methodType(boolean.class, int.class , String.class, String.class)).
-                    invoke(0, "foo", "foo");
+                    invokeExact(0, "foo", "foo");
             });
             // Incorrect arity
             checkWMTE(() -> { // 0
                 boolean r = (boolean) hs.get(am, methodType(boolean.class)).
-                    invoke();
+                    invokeExact();
             });
             checkWMTE(() -> { // >
                 boolean r = (boolean) hs.get(am, methodType(boolean.class, VarHandleTestMethodTypeString.class, String.class, String.class, Class.class)).
-                    invoke(recv, "foo", "foo", Void.class);
+                    invokeExact(recv, "foo", "foo", Void.class);
             });
         }
 
         for (TestAccessMode am : testAccessModesOfType(TestAccessType.COMPARE_AND_EXCHANGE)) {
             checkNPE(() -> { // null receiver
-                String x = (String) hs.get(am, methodType(String.class, Void.class, String.class, String.class)).
-                    invoke(null, "foo", "foo");
+                String x = (String) hs.get(am, methodType(String.class, VarHandleTestMethodTypeString.class, String.class, String.class)).
+                    invokeExact((VarHandleTestMethodTypeString) null, "foo", "foo");
             });
-            checkCCE(() -> { // receiver reference class
+            hs.checkWMTEOrCCE(() -> { // receiver reference class
                 String x = (String) hs.get(am, methodType(String.class, Class.class, String.class, String.class)).
-                    invoke(Void.class, "foo", "foo");
+                    invokeExact(Void.class, "foo", "foo");
             });
-            checkCCE(() -> { // expected reference class
+            hs.checkWMTEOrCCE(() -> { // expected reference class
                 String x = (String) hs.get(am, methodType(String.class, VarHandleTestMethodTypeString.class, Class.class, String.class)).
-                    invoke(recv, Void.class, "foo");
+                    invokeExact(recv, Void.class, "foo");
             });
-            checkCCE(() -> { // actual reference class
+            hs.checkWMTEOrCCE(() -> { // actual reference class
                 String x = (String) hs.get(am, methodType(String.class, VarHandleTestMethodTypeString.class, String.class, Class.class)).
-                    invoke(recv, "foo", Void.class);
+                    invokeExact(recv, "foo", Void.class);
             });
             checkWMTE(() -> { // reciever primitive class
                 String x = (String) hs.get(am, methodType(String.class, int.class , String.class, String.class)).
-                    invoke(0, "foo", "foo");
+                    invokeExact(0, "foo", "foo");
             });
             // Incorrect return type
-            checkCCE(() -> { // reference class
+            hs.checkWMTEOrCCE(() -> { // reference class
                 Void r = (Void) hs.get(am, methodType(Void.class, VarHandleTestMethodTypeString.class , String.class, String.class)).
-                    invoke(recv, "foo", "foo");
+                    invokeExact(recv, "foo", "foo");
             });
             checkWMTE(() -> { // primitive class
                 boolean x = (boolean) hs.get(am, methodType(boolean.class, VarHandleTestMethodTypeString.class , String.class, String.class)).
-                    invoke(recv, "foo", "foo");
+                    invokeExact(recv, "foo", "foo");
             });
             // Incorrect arity
             checkWMTE(() -> { // 0
                 String x = (String) hs.get(am, methodType(String.class)).
-                    invoke();
+                    invokeExact();
             });
             checkWMTE(() -> { // >
                 String x = (String) hs.get(am, methodType(String.class, VarHandleTestMethodTypeString.class, String.class, String.class, Class.class)).
-                    invoke(recv, "foo", "foo", Void.class);
+                    invokeExact(recv, "foo", "foo", Void.class);
             });
         }
 
         for (TestAccessMode am : testAccessModesOfType(TestAccessType.GET_AND_SET)) {
             checkNPE(() -> { // null receiver
-                String x = (String) hs.get(am, methodType(String.class, Void.class, String.class)).
-                    invoke(null, "foo");
+                String x = (String) hs.get(am, methodType(String.class, VarHandleTestMethodTypeString.class, String.class)).
+                    invokeExact((VarHandleTestMethodTypeString) null, "foo");
             });
-            checkCCE(() -> { // receiver reference class
+            hs.checkWMTEOrCCE(() -> { // receiver reference class
                 String x = (String) hs.get(am, methodType(String.class, Class.class, String.class)).
-                    invoke(Void.class, "foo");
+                    invokeExact(Void.class, "foo");
             });
-            checkCCE(() -> { // value reference class
+            hs.checkWMTEOrCCE(() -> { // value reference class
                 String x = (String) hs.get(am, methodType(String.class, VarHandleTestMethodTypeString.class, Class.class)).
-                    invoke(recv, Void.class);
+                    invokeExact(recv, Void.class);
             });
             checkWMTE(() -> { // reciever primitive class
                 String x = (String) hs.get(am, methodType(String.class, int.class, String.class)).
-                    invoke(0, "foo");
+                    invokeExact(0, "foo");
             });
             // Incorrect return type
-            checkCCE(() -> { // reference class
+            hs.checkWMTEOrCCE(() -> { // reference class
                 Void r = (Void) hs.get(am, methodType(Void.class, VarHandleTestMethodTypeString.class, String.class)).
-                    invoke(recv, "foo");
+                    invokeExact(recv, "foo");
             });
             checkWMTE(() -> { // primitive class
                 boolean x = (boolean) hs.get(am, methodType(boolean.class, VarHandleTestMethodTypeString.class, String.class)).
-                    invoke(recv, "foo");
+                    invokeExact(recv, "foo");
             });
             // Incorrect arity
             checkWMTE(() -> { // 0
                 String x = (String) hs.get(am, methodType(String.class)).
-                    invoke();
+                    invokeExact();
             });
             checkWMTE(() -> { // >
                 String x = (String) hs.get(am, methodType(String.class, VarHandleTestMethodTypeString.class, String.class)).
-                    invoke(recv, "foo", Void.class);
+                    invokeExact(recv, "foo", Void.class);
             });
         }
 
@@ -1054,110 +1056,110 @@
 
         for (TestAccessMode am : testAccessModesOfType(TestAccessType.GET)) {
             // Incorrect return type
-            checkCCE(() -> { // reference class
+            hs.checkWMTEOrCCE(() -> { // reference class
                 Void x = (Void) hs.get(am, methodType(Void.class)).
-                    invoke();
+                    invokeExact();
             });
             checkWMTE(() -> { // primitive class
                 boolean x = (boolean) hs.get(am, methodType(boolean.class)).
-                    invoke();
+                    invokeExact();
             });
             // Incorrect arity
             checkWMTE(() -> { // >
                 String x = (String) hs.get(am, methodType(Class.class)).
-                    invoke(Void.class);
+                    invokeExact(Void.class);
             });
         }
 
         for (TestAccessMode am : testAccessModesOfType(TestAccessType.SET)) {
-            checkCCE(() -> { // value reference class
+            hs.checkWMTEOrCCE(() -> { // value reference class
                 hs.get(am, methodType(void.class, Class.class)).
-                    invoke(Void.class);
+                    invokeExact(Void.class);
             });
             // Incorrect arity
             checkWMTE(() -> { // 0
                 hs.get(am, methodType(void.class)).
-                    invoke();
+                    invokeExact();
             });
             checkWMTE(() -> { // >
                 hs.get(am, methodType(void.class, String.class, Class.class)).
-                    invoke("foo", Void.class);
+                    invokeExact("foo", Void.class);
             });
         }
         for (TestAccessMode am : testAccessModesOfType(TestAccessType.COMPARE_AND_SET)) {
             // Incorrect argument types
-            checkCCE(() -> { // expected reference class
+            hs.checkWMTEOrCCE(() -> { // expected reference class
                 boolean r = (boolean) hs.get(am, methodType(boolean.class, Class.class, String.class)).
-                    invoke(Void.class, "foo");
+                    invokeExact(Void.class, "foo");
             });
-            checkCCE(() -> { // actual reference class
+            hs.checkWMTEOrCCE(() -> { // actual reference class
                 boolean r = (boolean) hs.get(am, methodType(boolean.class, String.class, Class.class)).
-                    invoke("foo", Void.class);
+                    invokeExact("foo", Void.class);
             });
             // Incorrect arity
             checkWMTE(() -> { // 0
                 boolean r = (boolean) hs.get(am, methodType(boolean.class)).
-                    invoke();
+                    invokeExact();
             });
             checkWMTE(() -> { // >
                 boolean r = (boolean) hs.get(am, methodType(boolean.class, String.class, String.class, Class.class)).
-                    invoke("foo", "foo", Void.class);
+                    invokeExact("foo", "foo", Void.class);
             });
         }
 
         for (TestAccessMode am : testAccessModesOfType(TestAccessType.COMPARE_AND_EXCHANGE)) {
             // Incorrect argument types
-            checkCCE(() -> { // expected reference class
+            hs.checkWMTEOrCCE(() -> { // expected reference class
                 String x = (String) hs.get(am, methodType(String.class, Class.class, String.class)).
-                    invoke(Void.class, "foo");
+                    invokeExact(Void.class, "foo");
             });
-            checkCCE(() -> { // actual reference class
+            hs.checkWMTEOrCCE(() -> { // actual reference class
                 String x = (String) hs.get(am, methodType(String.class, String.class, Class.class)).
-                    invoke("foo", Void.class);
+                    invokeExact("foo", Void.class);
             });
             // Incorrect return type
-            checkCCE(() -> { // reference class
+            hs.checkWMTEOrCCE(() -> { // reference class
                 Void r = (Void) hs.get(am, methodType(Void.class, String.class, String.class)).
-                    invoke("foo", "foo");
+                    invokeExact("foo", "foo");
             });
             checkWMTE(() -> { // primitive class
                 boolean x = (boolean) hs.get(am, methodType(boolean.class, String.class, String.class)).
-                    invoke("foo", "foo");
+                    invokeExact("foo", "foo");
             });
             // Incorrect arity
             checkWMTE(() -> { // 0
                 String x = (String) hs.get(am, methodType(String.class)).
-                    invoke();
+                    invokeExact();
             });
             checkWMTE(() -> { // >
                 String x = (String) hs.get(am, methodType(String.class, String.class, String.class, Class.class)).
-                    invoke("foo", "foo", Void.class);
+                    invokeExact("foo", "foo", Void.class);
             });
         }
 
         for (TestAccessMode am : testAccessModesOfType(TestAccessType.GET_AND_SET)) {
             // Incorrect argument types
-            checkCCE(() -> { // value reference class
+            hs.checkWMTEOrCCE(() -> { // value reference class
                 String x = (String) hs.get(am, methodType(String.class, Class.class)).
-                    invoke(Void.class);
+                    invokeExact(Void.class);
             });
             // Incorrect return type
-            checkCCE(() -> { // reference class
+            hs.checkWMTEOrCCE(() -> { // reference class
                 Void r = (Void) hs.get(am, methodType(Void.class, String.class)).
-                    invoke("foo");
+                    invokeExact("foo");
             });
             checkWMTE(() -> { // primitive class
                 boolean x = (boolean) hs.get(am, methodType(boolean.class, String.class)).
-                    invoke("foo");
+                    invokeExact("foo");
             });
             // Incorrect arity
             checkWMTE(() -> { // 0
                 String x = (String) hs.get(am, methodType(String.class)).
-                    invoke();
+                    invokeExact();
             });
             checkWMTE(() -> { // >
                 String x = (String) hs.get(am, methodType(String.class, String.class, Class.class)).
-                    invoke("foo", Void.class);
+                    invokeExact("foo", Void.class);
             });
         }
 
@@ -1686,195 +1688,195 @@
         for (TestAccessMode am : testAccessModesOfType(TestAccessType.GET)) {
             // Incorrect argument types
             checkNPE(() -> { // null array
-                String x = (String) hs.get(am, methodType(String.class, Void.class, int.class)).
-                    invoke(null, 0);
+                String x = (String) hs.get(am, methodType(String.class, String[].class, int.class)).
+                    invokeExact((String[]) null, 0);
             });
-            checkCCE(() -> { // array reference class
+            hs.checkWMTEOrCCE(() -> { // array reference class
                 String x = (String) hs.get(am, methodType(String.class, Class.class, int.class)).
-                    invoke(Void.class, 0);
+                    invokeExact(Void.class, 0);
             });
             checkWMTE(() -> { // array primitive class
                 String x = (String) hs.get(am, methodType(String.class, int.class, int.class)).
-                    invoke(0, 0);
+                    invokeExact(0, 0);
             });
             checkWMTE(() -> { // index reference class
                 String x = (String) hs.get(am, methodType(String.class, String[].class, Class.class)).
-                    invoke(array, Void.class);
+                    invokeExact(array, Void.class);
             });
             // Incorrect return type
-            checkCCE(() -> { // reference class
+            hs.checkWMTEOrCCE(() -> { // reference class
                 Void x = (Void) hs.get(am, methodType(Void.class, String[].class, int.class)).
-                    invoke(array, 0);
+                    invokeExact(array, 0);
             });
             checkWMTE(() -> { // primitive class
                 boolean x = (boolean) hs.get(am, methodType(boolean.class, String[].class, int.class)).
-                    invoke(array, 0);
+                    invokeExact(array, 0);
             });
             // Incorrect arity
             checkWMTE(() -> { // 0
                 String x = (String) hs.get(am, methodType(String.class)).
-                    invoke();
+                    invokeExact();
             });
             checkWMTE(() -> { // >
                 String x = (String) hs.get(am, methodType(String.class, String[].class, int.class, Class.class)).
-                    invoke(array, 0, Void.class);
+                    invokeExact(array, 0, Void.class);
             });
         }
 
         for (TestAccessMode am : testAccessModesOfType(TestAccessType.SET)) {
             // Incorrect argument types
             checkNPE(() -> { // null array
-                hs.get(am, methodType(void.class, Void.class, int.class, String.class)).
-                    invoke(null, 0, "foo");
+                hs.get(am, methodType(void.class, String[].class, int.class, String.class)).
+                    invokeExact((String[]) null, 0, "foo");
             });
-            checkCCE(() -> { // array reference class
+            hs.checkWMTEOrCCE(() -> { // array reference class
                 hs.get(am, methodType(void.class, Class.class, int.class, String.class)).
-                    invoke(Void.class, 0, "foo");
+                    invokeExact(Void.class, 0, "foo");
             });
-            checkCCE(() -> { // value reference class
+            hs.checkWMTEOrCCE(() -> { // value reference class
                 hs.get(am, methodType(void.class, String[].class, int.class, Class.class)).
-                    invoke(array, 0, Void.class);
+                    invokeExact(array, 0, Void.class);
             });
             checkWMTE(() -> { // receiver primitive class
                 hs.get(am, methodType(void.class, int.class, int.class, String.class)).
-                    invoke(0, 0, "foo");
+                    invokeExact(0, 0, "foo");
             });
             checkWMTE(() -> { // index reference class
                 hs.get(am, methodType(void.class, String[].class, Class.class, String.class)).
-                    invoke(array, Void.class, "foo");
+                    invokeExact(array, Void.class, "foo");
             });
             // Incorrect arity
             checkWMTE(() -> { // 0
                 hs.get(am, methodType(void.class)).
-                    invoke();
+                    invokeExact();
             });
             checkWMTE(() -> { // >
                 hs.get(am, methodType(void.class, String[].class, int.class, Class.class)).
-                    invoke(array, 0, "foo", Void.class);
+                    invokeExact(array, 0, "foo", Void.class);
             });
         }
         for (TestAccessMode am : testAccessModesOfType(TestAccessType.COMPARE_AND_SET)) {
             // Incorrect argument types
             checkNPE(() -> { // null receiver
-                boolean r = (boolean) hs.get(am, methodType(boolean.class, Void.class, int.class, String.class, String.class)).
-                    invoke(null, 0, "foo", "foo");
+                boolean r = (boolean) hs.get(am, methodType(boolean.class, String[].class, int.class, String.class, String.class)).
+                    invokeExact((String[]) null, 0, "foo", "foo");
             });
-            checkCCE(() -> { // receiver reference class
+            hs.checkWMTEOrCCE(() -> { // receiver reference class
                 boolean r = (boolean) hs.get(am, methodType(boolean.class, Class.class, int.class, String.class, String.class)).
-                    invoke(Void.class, 0, "foo", "foo");
+                    invokeExact(Void.class, 0, "foo", "foo");
             });
-            checkCCE(() -> { // expected reference class
+            hs.checkWMTEOrCCE(() -> { // expected reference class
                 boolean r = (boolean) hs.get(am, methodType(boolean.class, String[].class, int.class, Class.class, String.class)).
-                    invoke(array, 0, Void.class, "foo");
+                    invokeExact(array, 0, Void.class, "foo");
             });
-            checkCCE(() -> { // actual reference class
+            hs.checkWMTEOrCCE(() -> { // actual reference class
                 boolean r = (boolean) hs.get(am, methodType(boolean.class, String[].class, int.class, String.class, Class.class)).
-                    invoke(array, 0, "foo", Void.class);
+                    invokeExact(array, 0, "foo", Void.class);
             });
             checkWMTE(() -> { // receiver primitive class
                 boolean r = (boolean) hs.get(am, methodType(boolean.class, int.class, int.class, String.class, String.class)).
-                    invoke(0, 0, "foo", "foo");
+                    invokeExact(0, 0, "foo", "foo");
             });
             checkWMTE(() -> { // index reference class
                 boolean r = (boolean) hs.get(am, methodType(boolean.class, String[].class, Class.class, String.class, String.class)).
-                    invoke(array, Void.class, "foo", "foo");
+                    invokeExact(array, Void.class, "foo", "foo");
             });
             // Incorrect arity
             checkWMTE(() -> { // 0
                 boolean r = (boolean) hs.get(am, methodType(boolean.class)).
-                    invoke();
+                    invokeExact();
             });
             checkWMTE(() -> { // >
                 boolean r = (boolean) hs.get(am, methodType(boolean.class, String[].class, int.class, String.class, String.class, Class.class)).
-                    invoke(array, 0, "foo", "foo", Void.class);
+                    invokeExact(array, 0, "foo", "foo", Void.class);
             });
         }
 
         for (TestAccessMode am : testAccessModesOfType(TestAccessType.COMPARE_AND_EXCHANGE)) {
             // Incorrect argument types
             checkNPE(() -> { // null receiver
-                String x = (String) hs.get(am, methodType(String.class, Void.class, int.class, String.class, String.class)).
-                    invoke(null, 0, "foo", "foo");
+                String x = (String) hs.get(am, methodType(String.class, String[].class, int.class, String.class, String.class)).
+                    invokeExact((String[]) null, 0, "foo", "foo");
             });
-            checkCCE(() -> { // array reference class
+            hs.checkWMTEOrCCE(() -> { // array reference class
                 String x = (String) hs.get(am, methodType(String.class, Class.class, int.class, String.class, String.class)).
-                    invoke(Void.class, 0, "foo", "foo");
+                    invokeExact(Void.class, 0, "foo", "foo");
             });
-            checkCCE(() -> { // expected reference class
+            hs.checkWMTEOrCCE(() -> { // expected reference class
                 String x = (String) hs.get(am, methodType(String.class, String[].class, int.class, Class.class, String.class)).
-                    invoke(array, 0, Void.class, "foo");
+                    invokeExact(array, 0, Void.class, "foo");
             });
-            checkCCE(() -> { // actual reference class
+            hs.checkWMTEOrCCE(() -> { // actual reference class
                 String x = (String) hs.get(am, methodType(String.class, String[].class, int.class, String.class, Class.class)).
-                    invoke(array, 0, "foo", Void.class);
+                    invokeExact(array, 0, "foo", Void.class);
             });
             checkWMTE(() -> { // array primitive class
                 String x = (String) hs.get(am, methodType(String.class, int.class, int.class, String.class, String.class)).
-                    invoke(0, 0, "foo", "foo");
+                    invokeExact(0, 0, "foo", "foo");
             });
             checkWMTE(() -> { // index reference class
                 String x = (String) hs.get(am, methodType(String.class, String[].class, Class.class, String.class, String.class)).
-                    invoke(array, Void.class, "foo", "foo");
+                    invokeExact(array, Void.class, "foo", "foo");
             });
             // Incorrect return type
-            checkCCE(() -> { // reference class
+            hs.checkWMTEOrCCE(() -> { // reference class
                 Void r = (Void) hs.get(am, methodType(Void.class, String[].class, int.class, String.class, String.class)).
-                    invoke(array, 0, "foo", "foo");
+                    invokeExact(array, 0, "foo", "foo");
             });
             checkWMTE(() -> { // primitive class
                 boolean x = (boolean) hs.get(am, methodType(boolean.class, String[].class, int.class, String.class, String.class)).
-                    invoke(array, 0, "foo", "foo");
+                    invokeExact(array, 0, "foo", "foo");
             });
             // Incorrect arity
             checkWMTE(() -> { // 0
                 String x = (String) hs.get(am, methodType(String.class)).
-                    invoke();
+                    invokeExact();
             });
             checkWMTE(() -> { // >
                 String x = (String) hs.get(am, methodType(String.class, String[].class, int.class, String.class, String.class, Class.class)).
-                    invoke(array, 0, "foo", "foo", Void.class);
+                    invokeExact(array, 0, "foo", "foo", Void.class);
             });
         }
 
         for (TestAccessMode am : testAccessModesOfType(TestAccessType.GET_AND_SET)) {
             // Incorrect argument types
             checkNPE(() -> { // null array
-                String x = (String) hs.get(am, methodType(String.class, Void.class, int.class, String.class)).
-                    invoke(null, 0, "foo");
+                String x = (String) hs.get(am, methodType(String.class, String[].class, int.class, String.class)).
+                    invokeExact((String[]) null, 0, "foo");
             });
-            checkCCE(() -> { // array reference class
+            hs.checkWMTEOrCCE(() -> { // array reference class
                 String x = (String) hs.get(am, methodType(String.class, Class.class, int.class, String.class)).
-                    invoke(Void.class, 0, "foo");
+                    invokeExact(Void.class, 0, "foo");
             });
-            checkCCE(() -> { // value reference class
+            hs.checkWMTEOrCCE(() -> { // value reference class
                 String x = (String) hs.get(am, methodType(String.class, String[].class, int.class, Class.class)).
-                    invoke(array, 0, Void.class);
+                    invokeExact(array, 0, Void.class);
             });
             checkWMTE(() -> { // array primitive class
                 String x = (String) hs.get(am, methodType(String.class, int.class, int.class, String.class)).
-                    invoke(0, 0, "foo");
+                    invokeExact(0, 0, "foo");
             });
             checkWMTE(() -> { // index reference class
                 String x = (String) hs.get(am, methodType(String.class, String[].class, Class.class, String.class)).
-                    invoke(array, Void.class, "foo");
+                    invokeExact(array, Void.class, "foo");
             });
             // Incorrect return type
-            checkCCE(() -> { // reference class
+            hs.checkWMTEOrCCE(() -> { // reference class
                 Void r = (Void) hs.get(am, methodType(Void.class, String[].class, int.class, String.class)).
-                    invoke(array, 0, "foo");
+                    invokeExact(array, 0, "foo");
             });
             checkWMTE(() -> { // primitive class
                 boolean x = (boolean) hs.get(am, methodType(boolean.class, String[].class, int.class, String.class)).
-                    invoke(array, 0, "foo");
+                    invokeExact(array, 0, "foo");
             });
             // Incorrect arity
             checkWMTE(() -> { // 0
                 String x = (String) hs.get(am, methodType(String.class)).
-                    invoke();
+                    invokeExact();
             });
             checkWMTE(() -> { // >
                 String x = (String) hs.get(am, methodType(String.class, String[].class, int.class, String.class, Class.class)).
-                    invoke(array, 0, "foo", Void.class);
+                    invokeExact(array, 0, "foo", Void.class);
             });
         }
 
--- a/jdk/test/java/lang/invoke/VarHandles/X-VarHandleTestAccess.java.template	Thu May 19 17:48:02 2016 +0000
+++ b/jdk/test/java/lang/invoke/VarHandles/X-VarHandleTestAccess.java.template	Thu May 19 19:46:20 2016 +0000
@@ -309,6 +309,10 @@
         checkUOE(() -> {
             boolean r = vh.weakCompareAndSetRelease(recv, $value1$, $value2$);
         });
+
+        checkUOE(() -> {
+            $type$ r = ($type$) vh.getAndSet(recv, $value1$);
+        });
 #end[CAS]
 
 #if[!AtomicAdd]
@@ -399,6 +403,10 @@
         checkUOE(() -> {
             boolean r = vh.weakCompareAndSetRelease($value1$, $value2$);
         });
+
+        checkUOE(() -> {
+            $type$ r = ($type$) vh.getAndSet($value1$);
+        });
 #end[CAS]
 
 #if[!AtomicAdd]
@@ -504,29 +512,41 @@
         }
 
         {
-            boolean r = vh.weakCompareAndSet(recv, $value1$, $value2$);
-            assertEquals(r, true, "weakCompareAndSet $type$");
+            boolean success = false;
+            for (int c = 0; c < WEAK_ATTEMPTS && !success; c++) {
+                success = vh.weakCompareAndSet(recv, $value1$, $value2$);
+            }
+            assertEquals(success, true, "weakCompareAndSet $type$");
             $type$ x = ($type$) vh.get(recv);
             assertEquals(x, $value2$, "weakCompareAndSet $type$ value");
         }
 
         {
-            boolean r = vh.weakCompareAndSetAcquire(recv, $value2$, $value1$);
-            assertEquals(r, true, "weakCompareAndSetAcquire $type$");
+            boolean success = false;
+            for (int c = 0; c < WEAK_ATTEMPTS && !success; c++) {
+                success = vh.weakCompareAndSetAcquire(recv, $value2$, $value1$);
+            }
+            assertEquals(success, true, "weakCompareAndSetAcquire $type$");
             $type$ x = ($type$) vh.get(recv);
             assertEquals(x, $value1$, "weakCompareAndSetAcquire $type$");
         }
 
         {
-            boolean r = vh.weakCompareAndSetRelease(recv, $value1$, $value2$);
-            assertEquals(r, true, "weakCompareAndSetRelease $type$");
+            boolean success = false;
+            for (int c = 0; c < WEAK_ATTEMPTS && !success; c++) {
+                success = vh.weakCompareAndSetRelease(recv, $value1$, $value2$);
+            }
+            assertEquals(success, true, "weakCompareAndSetRelease $type$");
             $type$ x = ($type$) vh.get(recv);
             assertEquals(x, $value2$, "weakCompareAndSetRelease $type$");
         }
 
         {
-            boolean r = vh.weakCompareAndSetVolatile(recv, $value2$, $value1$);
-            assertEquals(r, true, "weakCompareAndSetVolatile $type$");
+            boolean success = false;
+            for (int c = 0; c < WEAK_ATTEMPTS && !success; c++) {
+                success = vh.weakCompareAndSetVolatile(recv, $value2$, $value1$);
+            }
+            assertEquals(success, true, "weakCompareAndSetVolatile $type$");
             $type$ x = ($type$) vh.get(recv);
             assertEquals(x, $value1$, "weakCompareAndSetVolatile $type$ value");
         }
@@ -586,6 +606,10 @@
         checkUOE(() -> {
             boolean r = vh.weakCompareAndSetRelease(recv, $value1$, $value2$);
         });
+
+        checkUOE(() -> {
+            $type$ r = ($type$) vh.getAndSet(recv, $value1$);
+        });
 #end[CAS]
 
 #if[!AtomicAdd]
@@ -691,36 +715,48 @@
         }
 
         {
-            boolean r = (boolean) vh.weakCompareAndSet($value1$, $value2$);
-            assertEquals(r, true, "weakCompareAndSet $type$");
+            boolean success = false;
+            for (int c = 0; c < WEAK_ATTEMPTS && !success; c++) {
+                success = vh.weakCompareAndSet($value1$, $value2$);
+            }
+            assertEquals(success, true, "weakCompareAndSet $type$");
             $type$ x = ($type$) vh.get();
             assertEquals(x, $value2$, "weakCompareAndSet $type$ value");
         }
 
         {
-            boolean r = (boolean) vh.weakCompareAndSetAcquire($value2$, $value1$);
-            assertEquals(r, true, "weakCompareAndSetAcquire $type$");
+            boolean success = false;
+            for (int c = 0; c < WEAK_ATTEMPTS && !success; c++) {
+                success = vh.weakCompareAndSetAcquire($value2$, $value1$);
+            }
+            assertEquals(success, true, "weakCompareAndSetAcquire $type$");
             $type$ x = ($type$) vh.get();
             assertEquals(x, $value1$, "weakCompareAndSetAcquire $type$");
         }
 
         {
-            boolean r = (boolean) vh.weakCompareAndSetRelease($value1$, $value2$);
-            assertEquals(r, true, "weakCompareAndSetRelease $type$");
+            boolean success = false;
+            for (int c = 0; c < WEAK_ATTEMPTS && !success; c++) {
+                success = vh.weakCompareAndSetRelease($value1$, $value2$);
+            }
+            assertEquals(success, true, "weakCompareAndSetRelease $type$");
             $type$ x = ($type$) vh.get();
             assertEquals(x, $value2$, "weakCompareAndSetRelease $type$");
         }
 
         {
-            boolean r = (boolean) vh.weakCompareAndSetVolatile($value2$, $value1$);
-            assertEquals(r, true, "weakCompareAndSetVolatile $type$");
+            boolean success = false;
+            for (int c = 0; c < WEAK_ATTEMPTS && !success; c++) {
+                success = vh.weakCompareAndSetRelease($value2$, $value1$);
+            }
+            assertEquals(success, true, "weakCompareAndSetVolatile $type$");
             $type$ x = ($type$) vh.get();
-            assertEquals(x, $value1$, "weakCompareAndSetVolatile $type$ value");
+            assertEquals(x, $value1$, "weakCompareAndSetVolatile $type$");
         }
 
         // Compare set and get
         {
-            $type$ o = ($type$) vh.getAndSet( $value2$);
+            $type$ o = ($type$) vh.getAndSet($value2$);
             assertEquals(o, $value1$, "getAndSet $type$");
             $type$ x = ($type$) vh.get();
             assertEquals(x, $value2$, "getAndSet $type$ value");
@@ -773,6 +809,10 @@
         checkUOE(() -> {
             boolean r = vh.weakCompareAndSetRelease($value1$, $value2$);
         });
+
+        checkUOE(() -> {
+            $type$ r = ($type$) vh.getAndSet($value1$);
+        });
 #end[CAS]
 
 #if[!AtomicAdd]
@@ -881,31 +921,43 @@
             }
 
             {
-                boolean r = vh.weakCompareAndSet(array, i, $value1$, $value2$);
-                assertEquals(r, true, "weakCompareAndSet $type$");
+                boolean success = false;
+                for (int c = 0; c < WEAK_ATTEMPTS && !success; c++) {
+                    success = vh.weakCompareAndSet(array, i, $value1$, $value2$);
+                }
+                assertEquals(success, true, "weakCompareAndSet $type$");
                 $type$ x = ($type$) vh.get(array, i);
                 assertEquals(x, $value2$, "weakCompareAndSet $type$ value");
             }
 
             {
-                boolean r = vh.weakCompareAndSetAcquire(array, i, $value2$, $value1$);
-                assertEquals(r, true, "weakCompareAndSetAcquire $type$");
+                boolean success = false;
+                for (int c = 0; c < WEAK_ATTEMPTS && !success; c++) {
+                    success = vh.weakCompareAndSetAcquire(array, i, $value2$, $value1$);
+                }
+                assertEquals(success, true, "weakCompareAndSetAcquire $type$");
                 $type$ x = ($type$) vh.get(array, i);
                 assertEquals(x, $value1$, "weakCompareAndSetAcquire $type$");
             }
 
             {
-                boolean r = vh.weakCompareAndSetRelease(array, i, $value1$, $value2$);
-                assertEquals(r, true, "weakCompareAndSetRelease $type$");
+                boolean success = false;
+                for (int c = 0; c < WEAK_ATTEMPTS && !success; c++) {
+                    success = vh.weakCompareAndSetRelease(array, i, $value1$, $value2$);
+                }
+                assertEquals(success, true, "weakCompareAndSetRelease $type$");
                 $type$ x = ($type$) vh.get(array, i);
                 assertEquals(x, $value2$, "weakCompareAndSetRelease $type$");
             }
 
             {
-                boolean r = vh.weakCompareAndSetVolatile(array, i, $value2$, $value1$);
-                assertEquals(r, true, "weakCompareAndSetVolatile $type$");
+                boolean success = false;
+                for (int c = 0; c < WEAK_ATTEMPTS && !success; c++) {
+                    success = vh.weakCompareAndSetVolatile(array, i, $value2$, $value1$);
+                }
+                assertEquals(success, true, "weakCompareAndSetVolatile $type$");
                 $type$ x = ($type$) vh.get(array, i);
-                assertEquals(x, $value1$, "weakCompareAndSetVolatile $type$ value");
+                assertEquals(x, $value1$, "weakCompareAndSetVolatile $type$");
             }
 
             // Compare set and get
@@ -967,6 +1019,10 @@
         checkUOE(() -> {
             boolean r = vh.weakCompareAndSetRelease(array, i, $value1$, $value2$);
         });
+
+        checkUOE(() -> {
+            $type$ r = ($type$) vh.getAndSet(array, i, $value1$);
+        });
 #end[CAS]
 
 #if[!AtomicAdd]
--- a/jdk/test/java/lang/invoke/VarHandles/X-VarHandleTestByteArrayView.java.template	Thu May 19 17:48:02 2016 +0000
+++ b/jdk/test/java/lang/invoke/VarHandles/X-VarHandleTestByteArrayView.java.template	Thu May 19 19:46:20 2016 +0000
@@ -311,10 +311,12 @@
             checkROBE(() -> {
                 $type$ o = ($type$) vh.getAndSet(array, ci, VALUE_1);
             });
+
+#else[CAS]
             checkUOE(() -> {
                 boolean r = vh.compareAndSet(array, ci, VALUE_1, VALUE_2);
             });
-#else[CAS]
+
             checkUOE(() -> {
                 $type$ r = ($type$) vh.compareAndExchangeVolatile(array, ci, VALUE_2, VALUE_1);
             });
@@ -884,22 +886,31 @@
                 }
 
                 {
-                    boolean r = vh.weakCompareAndSet(array, i, VALUE_1, VALUE_2);
-                    assertEquals(r, true, "weakCompareAndSet $type$");
+                    boolean success = false;
+                    for (int c = 0; c < WEAK_ATTEMPTS && !success; c++) {
+                        success = vh.weakCompareAndSet(array, i, VALUE_1, VALUE_2);
+                    }
+                    assertEquals(success, true, "weakCompareAndSet $type$");
                     $type$ x = ($type$) vh.get(array, i);
                     assertEquals(x, VALUE_2, "weakCompareAndSet $type$ value");
                 }
 
                 {
-                    boolean r = vh.weakCompareAndSetAcquire(array, i, VALUE_2, VALUE_1);
-                    assertEquals(r, true, "weakCompareAndSetAcquire $type$");
+                    boolean success = false;
+                    for (int c = 0; c < WEAK_ATTEMPTS && !success; c++) {
+                        success = vh.weakCompareAndSetAcquire(array, i, VALUE_2, VALUE_1);
+                    }
+                    assertEquals(success, true, "weakCompareAndSetAcquire $type$");
                     $type$ x = ($type$) vh.get(array, i);
                     assertEquals(x, VALUE_1, "weakCompareAndSetAcquire $type$");
                 }
 
                 {
-                    boolean r = vh.weakCompareAndSetRelease(array, i, VALUE_1, VALUE_2);
-                    assertEquals(r, true, "weakCompareAndSetRelease $type$");
+                    boolean success = false;
+                    for (int c = 0; c < WEAK_ATTEMPTS && !success; c++) {
+                        success = vh.weakCompareAndSetRelease(array, i, VALUE_1, VALUE_2);
+                    }
+                    assertEquals(success, true, "weakCompareAndSetRelease $type$");
                     $type$ x = ($type$) vh.get(array, i);
                     assertEquals(x, VALUE_2, "weakCompareAndSetRelease $type$");
                 }
@@ -1037,22 +1048,31 @@
                 }
 
                 {
-                    boolean r = vh.weakCompareAndSet(array, i, VALUE_1, VALUE_2);
-                    assertEquals(r, true, "weakCompareAndSet $type$");
+                    boolean success = false;
+                    for (int c = 0; c < WEAK_ATTEMPTS && !success; c++) {
+                        success = vh.weakCompareAndSet(array, i, VALUE_1, VALUE_2);
+                    }
+                    assertEquals(success, true, "weakCompareAndSet $type$");
                     $type$ x = ($type$) vh.get(array, i);
                     assertEquals(x, VALUE_2, "weakCompareAndSet $type$ value");
                 }
 
                 {
-                    boolean r = vh.weakCompareAndSetAcquire(array, i, VALUE_2, VALUE_1);
-                    assertEquals(r, true, "weakCompareAndSetAcquire $type$");
+                    boolean success = false;
+                    for (int c = 0; c < WEAK_ATTEMPTS && !success; c++) {
+                        success = vh.weakCompareAndSetAcquire(array, i, VALUE_2, VALUE_1);
+                    }
+                    assertEquals(success, true, "weakCompareAndSetAcquire $type$");
                     $type$ x = ($type$) vh.get(array, i);
                     assertEquals(x, VALUE_1, "weakCompareAndSetAcquire $type$");
                 }
 
                 {
-                    boolean r = vh.weakCompareAndSetRelease(array, i, VALUE_1, VALUE_2);
-                    assertEquals(r, true, "weakCompareAndSetRelease $type$");
+                    boolean success = false;
+                    for (int c = 0; c < WEAK_ATTEMPTS && !success; c++) {
+                        success = vh.weakCompareAndSetRelease(array, i, VALUE_1, VALUE_2);
+                    }
+                    assertEquals(success, true, "weakCompareAndSetRelease $type$");
                     $type$ x = ($type$) vh.get(array, i);
                     assertEquals(x, VALUE_2, "weakCompareAndSetRelease $type$");
                 }
--- a/jdk/test/java/lang/invoke/VarHandles/X-VarHandleTestMethodHandleAccess.java.template	Thu May 19 17:48:02 2016 +0000
+++ b/jdk/test/java/lang/invoke/VarHandles/X-VarHandleTestMethodHandleAccess.java.template	Thu May 19 19:46:20 2016 +0000
@@ -209,31 +209,43 @@
         }
 
         {
-            boolean r = (boolean) hs.get(TestAccessMode.WEAK_COMPARE_AND_SET).invokeExact(recv, $value1$, $value2$);
-            assertEquals(r, true, "weakCompareAndSet $type$");
+            boolean success = false;
+            for (int c = 0; c < WEAK_ATTEMPTS && !success; c++) {
+                success = (boolean) hs.get(TestAccessMode.WEAK_COMPARE_AND_SET).invokeExact(recv, $value1$, $value2$);
+            }
+            assertEquals(success, true, "weakCompareAndSet $type$");
             $type$ x = ($type$) hs.get(TestAccessMode.GET).invokeExact(recv);
             assertEquals(x, $value2$, "weakCompareAndSet $type$ value");
         }
 
         {
-            boolean r = (boolean) hs.get(TestAccessMode.WEAK_COMPARE_AND_SET_ACQUIRE).invokeExact(recv, $value2$, $value1$);
-            assertEquals(r, true, "weakCompareAndSetAcquire $type$");
+            boolean success = false;
+            for (int c = 0; c < WEAK_ATTEMPTS && !success; c++) {
+                success = (boolean) hs.get(TestAccessMode.WEAK_COMPARE_AND_SET_ACQUIRE).invokeExact(recv, $value2$, $value1$);
+            }
+            assertEquals(success, true, "weakCompareAndSetAcquire $type$");
             $type$ x = ($type$) hs.get(TestAccessMode.GET).invokeExact(recv);
             assertEquals(x, $value1$, "weakCompareAndSetAcquire $type$");
         }
 
         {
-            boolean r = (boolean) hs.get(TestAccessMode.WEAK_COMPARE_AND_SET_RELEASE).invokeExact(recv, $value1$, $value2$);
-            assertEquals(r, true, "weakCompareAndSetRelease $type$");
+            boolean success = false;
+            for (int c = 0; c < WEAK_ATTEMPTS && !success; c++) {
+                success = (boolean) hs.get(TestAccessMode.WEAK_COMPARE_AND_SET_RELEASE).invokeExact(recv, $value1$, $value2$);
+            }
+            assertEquals(success, true, "weakCompareAndSetRelease $type$");
             $type$ x = ($type$) hs.get(TestAccessMode.GET).invokeExact(recv);
             assertEquals(x, $value2$, "weakCompareAndSetRelease $type$");
         }
 
         {
-            boolean r = (boolean) hs.get(TestAccessMode.WEAK_COMPARE_AND_SET_VOLATILE).invokeExact(recv, $value2$, $value1$);
-            assertEquals(r, true, "weakCompareAndSetVolatile $type$");
+            boolean success = false;
+            for (int c = 0; c < WEAK_ATTEMPTS && !success; c++) {
+                success = (boolean) hs.get(TestAccessMode.WEAK_COMPARE_AND_SET_VOLATILE).invokeExact(recv, $value2$, $value1$);
+            }
+            assertEquals(success, true, "weakCompareAndSetVolatile $type$");
             $type$ x = ($type$) hs.get(TestAccessMode.GET).invokeExact(recv);
-            assertEquals(x, $value1$, "weakCompareAndSetVolatile $type$ value");
+            assertEquals(x, $value1$, "weakCompareAndSetVolatile $type$");
         }
 
         // Compare set and get
@@ -380,36 +392,48 @@
         }
 
         {
-            boolean r = (boolean) hs.get(TestAccessMode.WEAK_COMPARE_AND_SET).invokeExact($value1$, $value2$);
-            assertEquals(r, true, "weakCompareAndSet $type$");
+            boolean success = false;
+            for (int c = 0; c < WEAK_ATTEMPTS && !success; c++) {
+                success = (boolean) hs.get(TestAccessMode.WEAK_COMPARE_AND_SET).invokeExact($value1$, $value2$);
+            }
+            assertEquals(success, true, "weakCompareAndSet $type$");
             $type$ x = ($type$) hs.get(TestAccessMode.GET).invokeExact();
             assertEquals(x, $value2$, "weakCompareAndSet $type$ value");
         }
 
         {
-            boolean r = (boolean) hs.get(TestAccessMode.WEAK_COMPARE_AND_SET_ACQUIRE).invokeExact($value2$, $value1$);
-            assertEquals(r, true, "weakCompareAndSetAcquire $type$");
+            boolean success = false;
+            for (int c = 0; c < WEAK_ATTEMPTS && !success; c++) {
+                success = (boolean) hs.get(TestAccessMode.WEAK_COMPARE_AND_SET_ACQUIRE).invokeExact($value2$, $value1$);
+            }
+            assertEquals(success, true, "weakCompareAndSetAcquire $type$");
             $type$ x = ($type$) hs.get(TestAccessMode.GET).invokeExact();
             assertEquals(x, $value1$, "weakCompareAndSetAcquire $type$");
         }
 
         {
-            boolean r = (boolean) hs.get(TestAccessMode.WEAK_COMPARE_AND_SET_RELEASE).invokeExact($value1$, $value2$);
-            assertEquals(r, true, "weakCompareAndSetRelease $type$");
+            boolean success = false;
+            for (int c = 0; c < WEAK_ATTEMPTS && !success; c++) {
+                success = (boolean) hs.get(TestAccessMode.WEAK_COMPARE_AND_SET_RELEASE).invokeExact($value1$, $value2$);
+            }
+            assertEquals(success, true, "weakCompareAndSetRelease $type$");
             $type$ x = ($type$) hs.get(TestAccessMode.GET).invokeExact();
             assertEquals(x, $value2$, "weakCompareAndSetRelease $type$");
         }
 
         {
-            boolean r = (boolean) hs.get(TestAccessMode.WEAK_COMPARE_AND_SET_VOLATILE).invokeExact($value2$, $value1$);
-            assertEquals(r, true, "weakCompareAndSetVolatile $type$");
+            boolean success = false;
+            for (int c = 0; c < WEAK_ATTEMPTS && !success; c++) {
+                success = (boolean) hs.get(TestAccessMode.WEAK_COMPARE_AND_SET_VOLATILE).invokeExact($value2$, $value1$);
+            }
+            assertEquals(success, true, "weakCompareAndSetVolatile $type$");
             $type$ x = ($type$) hs.get(TestAccessMode.GET).invokeExact();
-            assertEquals(x, $value1$, "weakCompareAndSetVolatile $type$ value");
+            assertEquals(x, $value1$, "weakCompareAndSetVolatile $type$");
         }
 
         // Compare set and get
         {
-            $type$ o = ($type$) hs.get(TestAccessMode.GET_AND_SET).invokeExact($value2$);
+            $type$ o = ($type$) hs.get(TestAccessMode.GET_AND_SET).invokeExact( $value2$);
             assertEquals(o, $value1$, "getAndSet $type$");
             $type$ x = ($type$) hs.get(TestAccessMode.GET).invokeExact();
             assertEquals(x, $value2$, "getAndSet $type$ value");
@@ -554,31 +578,43 @@
             }
 
             {
-                boolean r = (boolean) hs.get(TestAccessMode.WEAK_COMPARE_AND_SET).invokeExact(array, i, $value1$, $value2$);
-                assertEquals(r, true, "weakCompareAndSet $type$");
+                boolean success = false;
+                for (int c = 0; c < WEAK_ATTEMPTS && !success; c++) {
+                    success = (boolean) hs.get(TestAccessMode.WEAK_COMPARE_AND_SET).invokeExact(array, i, $value1$, $value2$);
+                }
+                assertEquals(success, true, "weakCompareAndSet $type$");
                 $type$ x = ($type$) hs.get(TestAccessMode.GET).invokeExact(array, i);
                 assertEquals(x, $value2$, "weakCompareAndSet $type$ value");
             }
 
             {
-                boolean r = (boolean) hs.get(TestAccessMode.WEAK_COMPARE_AND_SET_ACQUIRE).invokeExact(array, i, $value2$, $value1$);
-                assertEquals(r, true, "weakCompareAndSetAcquire $type$");
+                boolean success = false;
+                for (int c = 0; c < WEAK_ATTEMPTS && !success; c++) {
+                    success = (boolean) hs.get(TestAccessMode.WEAK_COMPARE_AND_SET_ACQUIRE).invokeExact(array, i, $value2$, $value1$);
+                }
+                assertEquals(success, true, "weakCompareAndSetAcquire $type$");
                 $type$ x = ($type$) hs.get(TestAccessMode.GET).invokeExact(array, i);
                 assertEquals(x, $value1$, "weakCompareAndSetAcquire $type$");
             }
 
             {
-                boolean r = (boolean) hs.get(TestAccessMode.WEAK_COMPARE_AND_SET_RELEASE).invokeExact(array, i, $value1$, $value2$);
-                assertEquals(r, true, "weakCompareAndSetRelease $type$");
+                boolean success = false;
+                for (int c = 0; c < WEAK_ATTEMPTS && !success; c++) {
+                    success = (boolean) hs.get(TestAccessMode.WEAK_COMPARE_AND_SET_RELEASE).invokeExact(array, i, $value1$, $value2$);
+                }
+                assertEquals(success, true, "weakCompareAndSetRelease $type$");
                 $type$ x = ($type$) hs.get(TestAccessMode.GET).invokeExact(array, i);
                 assertEquals(x, $value2$, "weakCompareAndSetRelease $type$");
             }
 
             {
-                boolean r = (boolean) hs.get(TestAccessMode.WEAK_COMPARE_AND_SET_VOLATILE).invokeExact(array, i, $value2$, $value1$);
-                assertEquals(r, true, "weakCompareAndSetVolatile $type$");
+                boolean success = false;
+                for (int c = 0; c < WEAK_ATTEMPTS && !success; c++) {
+                    success = (boolean) hs.get(TestAccessMode.WEAK_COMPARE_AND_SET_VOLATILE).invokeExact(array, i, $value2$, $value1$);
+                }
+                assertEquals(success, true, "weakCompareAndSetVolatile $type$");
                 $type$ x = ($type$) hs.get(TestAccessMode.GET).invokeExact(array, i);
-                assertEquals(x, $value1$, "weakCompareAndSetVolatile $type$ value");
+                assertEquals(x, $value1$, "weakCompareAndSetVolatile $type$");
             }
 
             // Compare set and get
--- a/jdk/test/java/lang/invoke/VarHandles/X-VarHandleTestMethodType.java.template	Thu May 19 17:48:02 2016 +0000
+++ b/jdk/test/java/lang/invoke/VarHandles/X-VarHandleTestMethodType.java.template	Thu May 19 19:46:20 2016 +0000
@@ -23,6 +23,7 @@
 
 /*
  * @test
+ * @bug 8156486
  * @run testng/othervm VarHandleTestMethodType$Type$
  * @run testng/othervm -Djava.lang.invoke.VarHandle.VAR_HANDLE_GUARDS=false VarHandleTestMethodType$Type$
  */
@@ -81,27 +82,28 @@
     public Object[][] accessTestCaseProvider() throws Exception {
         List<AccessTestCase<?>> cases = new ArrayList<>();
 
-        cases.add(new VarHandleAccessTestCase("Instance field wrong method type",
+        cases.add(new VarHandleAccessTestCase("Instance field",
                                               vhField, vh -> testInstanceFieldWrongMethodType(this, vh),
                                               false));
 
-        cases.add(new VarHandleAccessTestCase("Static field wrong method type",
+        cases.add(new VarHandleAccessTestCase("Static field",
                                               vhStaticField, VarHandleTestMethodType$Type$::testStaticFieldWrongMethodType,
                                               false));
 
-        cases.add(new VarHandleAccessTestCase("Array wrong method type",
+        cases.add(new VarHandleAccessTestCase("Array",
                                               vhArray, VarHandleTestMethodType$Type$::testArrayWrongMethodType,
                                               false));
+
         for (VarHandleToMethodHandle f : VarHandleToMethodHandle.values()) {
-            cases.add(new MethodHandleAccessTestCase("Instance field wrong method type",
+            cases.add(new MethodHandleAccessTestCase("Instance field",
                                                      vhField, f, hs -> testInstanceFieldWrongMethodType(this, hs),
                                                      false));
 
-            cases.add(new MethodHandleAccessTestCase("Static field wrong method type",
+            cases.add(new MethodHandleAccessTestCase("Static field",
                                                      vhStaticField, f, VarHandleTestMethodType$Type$::testStaticFieldWrongMethodType,
                                                      false));
 
-            cases.add(new MethodHandleAccessTestCase("Array wrong method type",
+            cases.add(new MethodHandleAccessTestCase("Array",
                                                      vhArray, f, VarHandleTestMethodType$Type$::testArrayWrongMethodType,
                                                      false));
         }
@@ -648,63 +650,63 @@
         for (TestAccessMode am : testAccessModesOfType(TestAccessType.GET)) {
             // Incorrect argument types
             checkNPE(() -> { // null receiver
-                $type$ x = ($type$) hs.get(am, methodType($type$.class, Void.class)).
-                    invoke(null);
+                $type$ x = ($type$) hs.get(am, methodType($type$.class, VarHandleTestMethodType$Type$.class)).
+                    invokeExact((VarHandleTestMethodType$Type$) null);
             });
-            checkCCE(() -> { // receiver reference class
+            hs.checkWMTEOrCCE(() -> { // receiver reference class
                 $type$ x = ($type$) hs.get(am, methodType($type$.class, Class.class)).
-                    invoke(Void.class);
+                    invokeExact(Void.class);
             });
             checkWMTE(() -> { // receiver primitive class
                 $type$ x = ($type$) hs.get(am, methodType($type$.class, int.class)).
-                    invoke(0);
+                    invokeExact(0);
             });
             // Incorrect return type
-            check{#if[String]?CCE:WMTE}(() -> { // reference class
-                Void x = (Void) hs.get(am, methodType($type$.class, VarHandleTestMethodType$Type$.class)).
-                    invoke(recv);
+            {#if[String]?hs.checkWMTEOrCCE:checkWMTE}(() -> { // reference class
+                Void x = (Void) hs.get(am, methodType(Void.class, VarHandleTestMethodType$Type$.class)).
+                    invokeExact(recv);
             });
             checkWMTE(() -> { // primitive class
                 $wrong_primitive_type$ x = ($wrong_primitive_type$) hs.get(am, methodType($wrong_primitive_type$.class, VarHandleTestMethodType$Type$.class)).
-                    invoke(recv);
+                    invokeExact(recv);
             });
             // Incorrect arity
             checkWMTE(() -> { // 0
                 $type$ x = ($type$) hs.get(am, methodType($type$.class)).
-                    invoke();
+                    invokeExact();
             });
             checkWMTE(() -> { // >
                 $type$ x = ($type$) hs.get(am, methodType($type$.class, VarHandleTestMethodType$Type$.class, Class.class)).
-                    invoke(recv, Void.class);
+                    invokeExact(recv, Void.class);
             });
         }
 
         for (TestAccessMode am : testAccessModesOfType(TestAccessType.SET)) {
             // Incorrect argument types
             checkNPE(() -> { // null receiver
-                hs.get(am, methodType(void.class, Void.class, $type$.class)).
-                    invoke(null, $value1$);
+                hs.get(am, methodType(void.class, VarHandleTestMethodType$Type$.class, $type$.class)).
+                    invokeExact((VarHandleTestMethodType$Type$) null, $value1$);
             });
-            checkCCE(() -> { // receiver reference class
+            hs.checkWMTEOrCCE(() -> { // receiver reference class
                 hs.get(am, methodType(void.class, Class.class, $type$.class)).
-                    invoke(Void.class, $value1$);
+                    invokeExact(Void.class, $value1$);
             });
-            check{#if[String]?CCE:WMTE}(() -> { // value reference class
+            {#if[String]?hs.checkWMTEOrCCE:checkWMTE}(() -> { // value reference class
                 hs.get(am, methodType(void.class, VarHandleTestMethodType$Type$.class, Class.class)).
-                    invoke(recv, Void.class);
+                    invokeExact(recv, Void.class);
             });
             checkWMTE(() -> { // receiver primitive class
                 hs.get(am, methodType(void.class, int.class, $type$.class)).
-                    invoke(0, $value1$);
+                    invokeExact(0, $value1$);
             });
             // Incorrect arity
             checkWMTE(() -> { // 0
                 hs.get(am, methodType(void.class)).
-                    invoke();
+                    invokeExact();
             });
             checkWMTE(() -> { // >
                 hs.get(am, methodType(void.class, VarHandleTestMethodType$Type$.class, $type$.class, Class.class)).
-                    invoke(recv, $value1$, Void.class);
+                    invokeExact(recv, $value1$, Void.class);
             });
         }
 
@@ -712,111 +714,111 @@
         for (TestAccessMode am : testAccessModesOfType(TestAccessType.COMPARE_AND_SET)) {
             // Incorrect argument types
             checkNPE(() -> { // null receiver
-                boolean r = (boolean) hs.get(am, methodType(boolean.class, Void.class, $type$.class, $type$.class)).
-                    invoke(null, $value1$, $value1$);
+                boolean r = (boolean) hs.get(am, methodType(boolean.class, VarHandleTestMethodType$Type$.class, $type$.class, $type$.class)).
+                    invokeExact((VarHandleTestMethodType$Type$) null, $value1$, $value1$);
             });
-            checkCCE(() -> { // receiver reference class
+            hs.checkWMTEOrCCE(() -> { // receiver reference class
                 boolean r = (boolean) hs.get(am, methodType(boolean.class, Class.class, $type$.class, $type$.class)).
-                    invoke(Void.class, $value1$, $value1$);
+                    invokeExact(Void.class, $value1$, $value1$);
             });
-            check{#if[String]?CCE:WMTE}(() -> { // expected reference class
+            {#if[String]?hs.checkWMTEOrCCE:checkWMTE}(() -> { // expected reference class
                 boolean r = (boolean) hs.get(am, methodType(boolean.class, VarHandleTestMethodType$Type$.class, Class.class, $type$.class)).
-                    invoke(recv, Void.class, $value1$);
+                    invokeExact(recv, Void.class, $value1$);
             });
-            check{#if[String]?CCE:WMTE}(() -> { // actual reference class
+            {#if[String]?hs.checkWMTEOrCCE:checkWMTE}(() -> { // actual reference class
                 boolean r = (boolean) hs.get(am, methodType(boolean.class, VarHandleTestMethodType$Type$.class, $type$.class, Class.class)).
-                    invoke(recv, $value1$, Void.class);
+                    invokeExact(recv, $value1$, Void.class);
             });
             checkWMTE(() -> { // receiver primitive class
                 boolean r = (boolean) hs.get(am, methodType(boolean.class, int.class , $type$.class, $type$.class)).
-                    invoke(0, $value1$, $value1$);
+                    invokeExact(0, $value1$, $value1$);
             });
             // Incorrect arity
             checkWMTE(() -> { // 0
                 boolean r = (boolean) hs.get(am, methodType(boolean.class)).
-                    invoke();
+                    invokeExact();
             });
             checkWMTE(() -> { // >
                 boolean r = (boolean) hs.get(am, methodType(boolean.class, VarHandleTestMethodType$Type$.class, $type$.class, $type$.class, Class.class)).
-                    invoke(recv, $value1$, $value1$, Void.class);
+                    invokeExact(recv, $value1$, $value1$, Void.class);
             });
         }
 
         for (TestAccessMode am : testAccessModesOfType(TestAccessType.COMPARE_AND_EXCHANGE)) {
             checkNPE(() -> { // null receiver
-                $type$ x = ($type$) hs.get(am, methodType($type$.class, Void.class, $type$.class, $type$.class)).
-                    invoke(null, $value1$, $value1$);
+                $type$ x = ($type$) hs.get(am, methodType($type$.class, VarHandleTestMethodType$Type$.class, $type$.class, $type$.class)).
+                    invokeExact((VarHandleTestMethodType$Type$) null, $value1$, $value1$);
             });
-            checkCCE(() -> { // receiver reference class
+            hs.checkWMTEOrCCE(() -> { // receiver reference class
                 $type$ x = ($type$) hs.get(am, methodType($type$.class, Class.class, $type$.class, $type$.class)).
-                    invoke(Void.class, $value1$, $value1$);
+                    invokeExact(Void.class, $value1$, $value1$);
             });
-            check{#if[String]?CCE:WMTE}(() -> { // expected reference class
+            {#if[String]?hs.checkWMTEOrCCE:checkWMTE}(() -> { // expected reference class
                 $type$ x = ($type$) hs.get(am, methodType($type$.class, VarHandleTestMethodType$Type$.class, Class.class, $type$.class)).
-                    invoke(recv, Void.class, $value1$);
+                    invokeExact(recv, Void.class, $value1$);
             });
-            check{#if[String]?CCE:WMTE}(() -> { // actual reference class
+            {#if[String]?hs.checkWMTEOrCCE:checkWMTE}(() -> { // actual reference class
                 $type$ x = ($type$) hs.get(am, methodType($type$.class, VarHandleTestMethodType$Type$.class, $type$.class, Class.class)).
-                    invoke(recv, $value1$, Void.class);
+                    invokeExact(recv, $value1$, Void.class);
             });
             checkWMTE(() -> { // reciever primitive class
                 $type$ x = ($type$) hs.get(am, methodType($type$.class, int.class , $type$.class, $type$.class)).
-                    invoke(0, $value1$, $value1$);
+                    invokeExact(0, $value1$, $value1$);
             });
             // Incorrect return type
-            check{#if[String]?CCE:WMTE}(() -> { // reference class
+            {#if[String]?hs.checkWMTEOrCCE:checkWMTE}(() -> { // reference class
                 Void r = (Void) hs.get(am, methodType(Void.class, VarHandleTestMethodType$Type$.class , $type$.class, $type$.class)).
-                    invoke(recv, $value1$, $value1$);
+                    invokeExact(recv, $value1$, $value1$);
             });
             checkWMTE(() -> { // primitive class
                 $wrong_primitive_type$ x = ($wrong_primitive_type$) hs.get(am, methodType($wrong_primitive_type$.class, VarHandleTestMethodType$Type$.class , $type$.class, $type$.class)).
-                    invoke(recv, $value1$, $value1$);
+                    invokeExact(recv, $value1$, $value1$);
             });
             // Incorrect arity
             checkWMTE(() -> { // 0
                 $type$ x = ($type$) hs.get(am, methodType($type$.class)).
-                    invoke();
+                    invokeExact();
             });
             checkWMTE(() -> { // >
                 $type$ x = ($type$) hs.get(am, methodType($type$.class, VarHandleTestMethodType$Type$.class, $type$.class, $type$.class, Class.class)).
-                    invoke(recv, $value1$, $value1$, Void.class);
+                    invokeExact(recv, $value1$, $value1$, Void.class);
             });
         }
 
         for (TestAccessMode am : testAccessModesOfType(TestAccessType.GET_AND_SET)) {
             checkNPE(() -> { // null receiver
-                $type$ x = ($type$) hs.get(am, methodType($type$.class, Void.class, $type$.class)).
-                    invoke(null, $value1$);
+                $type$ x = ($type$) hs.get(am, methodType($type$.class, VarHandleTestMethodType$Type$.class, $type$.class)).
+                    invokeExact((VarHandleTestMethodType$Type$) null, $value1$);
             });
-            checkCCE(() -> { // receiver reference class
+            hs.checkWMTEOrCCE(() -> { // receiver reference class
                 $type$ x = ($type$) hs.get(am, methodType($type$.class, Class.class, $type$.class)).
-                    invoke(Void.class, $value1$);
+                    invokeExact(Void.class, $value1$);
             });
-            check{#if[String]?CCE:WMTE}(() -> { // value reference class
+            {#if[String]?hs.checkWMTEOrCCE:checkWMTE}(() -> { // value reference class
                 $type$ x = ($type$) hs.get(am, methodType($type$.class, VarHandleTestMethodType$Type$.class, Class.class)).
-                    invoke(recv, Void.class);
+                    invokeExact(recv, Void.class);
             });
             checkWMTE(() -> { // reciever primitive class
                 $type$ x = ($type$) hs.get(am, methodType($type$.class, int.class, $type$.class)).
-                    invoke(0, $value1$);
+                    invokeExact(0, $value1$);
             });
             // Incorrect return type
-            check{#if[String]?CCE:WMTE}(() -> { // reference class
+            {#if[String]?hs.checkWMTEOrCCE:checkWMTE}(() -> { // reference class
                 Void r = (Void) hs.get(am, methodType(Void.class, VarHandleTestMethodType$Type$.class, $type$.class)).
-                    invoke(recv, $value1$);
+                    invokeExact(recv, $value1$);
             });
             checkWMTE(() -> { // primitive class
                 $wrong_primitive_type$ x = ($wrong_primitive_type$) hs.get(am, methodType($wrong_primitive_type$.class, VarHandleTestMethodType$Type$.class, $type$.class)).
-                    invoke(recv, $value1$);
+                    invokeExact(recv, $value1$);
             });
             // Incorrect arity
             checkWMTE(() -> { // 0
                 $type$ x = ($type$) hs.get(am, methodType($type$.class)).
-                    invoke();
+                    invokeExact();
             });
             checkWMTE(() -> { // >
                 $type$ x = ($type$) hs.get(am, methodType($type$.class, VarHandleTestMethodType$Type$.class, $type$.class)).
-                    invoke(recv, $value1$, Void.class);
+                    invokeExact(recv, $value1$, Void.class);
             });
         }
 #end[CAS]
@@ -824,38 +826,38 @@
 #if[AtomicAdd]
         for (TestAccessMode am : testAccessModesOfType(TestAccessType.GET_AND_ADD)) {
             checkNPE(() -> { // null receiver
-                $type$ x = ($type$) hs.get(am, methodType($type$.class, Void.class, $type$.class)).
-                    invoke(null, $value1$);
+                $type$ x = ($type$) hs.get(am, methodType($type$.class, VarHandleTestMethodType$Type$.class, $type$.class)).
+                    invokeExact((VarHandleTestMethodType$Type$) null, $value1$);
             });
-            checkCCE(() -> { // receiver reference class
+            hs.checkWMTEOrCCE(() -> { // receiver reference class
                 $type$ x = ($type$) hs.get(am, methodType($type$.class, Class.class, $type$.class)).
-                    invoke(Void.class, $value1$);
+                    invokeExact(Void.class, $value1$);
             });
-            check{#if[String]?CCE:WMTE}(() -> { // value reference class
+            {#if[String]?hs.checkWMTEOrCCE:checkWMTE}(() -> { // value reference class
                 $type$ x = ($type$) hs.get(am, methodType($type$.class, VarHandleTestMethodType$Type$.class, Class.class)).
-                    invoke(recv, Void.class);
+                    invokeExact(recv, Void.class);
             });
             checkWMTE(() -> { // reciever primitive class
                 $type$ x = ($type$) hs.get(am, methodType($type$.class, int.class, $type$.class)).
-                    invoke(0, $value1$);
+                    invokeExact(0, $value1$);
             });
             // Incorrect return type
-            check{#if[String]?CCE:WMTE}(() -> { // reference class
+            {#if[String]?hs.checkWMTEOrCCE:checkWMTE}(() -> { // reference class
                 Void r = (Void) hs.get(am, methodType(Void.class, VarHandleTestMethodType$Type$.class, $type$.class)).
-                    invoke(recv, $value1$);
+                    invokeExact(recv, $value1$);
             });
             checkWMTE(() -> { // primitive class
                 $wrong_primitive_type$ x = ($wrong_primitive_type$) hs.get(am, methodType($wrong_primitive_type$.class, VarHandleTestMethodType$Type$.class, $type$.class)).
-                    invoke(recv, $value1$);
+                    invokeExact(recv, $value1$);
             });
             // Incorrect arity
             checkWMTE(() -> { // 0
                 $type$ x = ($type$) hs.get(am, methodType($type$.class)).
-                    invoke();
+                    invokeExact();
             });
             checkWMTE(() -> { // >
                 $type$ x = ($type$) hs.get(am, methodType($type$.class, VarHandleTestMethodType$Type$.class, $type$.class)).
-                    invoke(recv, $value1$, Void.class);
+                    invokeExact(recv, $value1$, Void.class);
             });
         }
 #end[AtomicAdd]
@@ -1200,111 +1202,111 @@
 
         for (TestAccessMode am : testAccessModesOfType(TestAccessType.GET)) {
             // Incorrect return type
-            check{#if[String]?CCE:WMTE}(() -> { // reference class
+            {#if[String]?hs.checkWMTEOrCCE:checkWMTE}(() -> { // reference class
                 Void x = (Void) hs.get(am, methodType(Void.class)).
-                    invoke();
+                    invokeExact();
             });
             checkWMTE(() -> { // primitive class
                 $wrong_primitive_type$ x = ($wrong_primitive_type$) hs.get(am, methodType($wrong_primitive_type$.class)).
-                    invoke();
+                    invokeExact();
             });
             // Incorrect arity
             checkWMTE(() -> { // >
                 $type$ x = ($type$) hs.get(am, methodType(Class.class)).
-                    invoke(Void.class);
+                    invokeExact(Void.class);
             });
         }
 
         for (TestAccessMode am : testAccessModesOfType(TestAccessType.SET)) {
-            check{#if[String]?CCE:WMTE}(() -> { // value reference class
+            {#if[String]?hs.checkWMTEOrCCE:checkWMTE}(() -> { // value reference class
                 hs.get(am, methodType(void.class, Class.class)).
-                    invoke(Void.class);
+                    invokeExact(Void.class);
             });
             // Incorrect arity
             checkWMTE(() -> { // 0
                 hs.get(am, methodType(void.class)).
-                    invoke();
+                    invokeExact();
             });
             checkWMTE(() -> { // >
                 hs.get(am, methodType(void.class, $type$.class, Class.class)).
-                    invoke($value1$, Void.class);
+                    invokeExact($value1$, Void.class);
             });
         }
 #if[CAS]
         for (TestAccessMode am : testAccessModesOfType(TestAccessType.COMPARE_AND_SET)) {
             // Incorrect argument types
-            check{#if[String]?CCE:WMTE}(() -> { // expected reference class
+            {#if[String]?hs.checkWMTEOrCCE:checkWMTE}(() -> { // expected reference class
                 boolean r = (boolean) hs.get(am, methodType(boolean.class, Class.class, $type$.class)).
-                    invoke(Void.class, $value1$);
+                    invokeExact(Void.class, $value1$);
             });
-            check{#if[String]?CCE:WMTE}(() -> { // actual reference class
+            {#if[String]?hs.checkWMTEOrCCE:checkWMTE}(() -> { // actual reference class
                 boolean r = (boolean) hs.get(am, methodType(boolean.class, $type$.class, Class.class)).
-                    invoke($value1$, Void.class);
+                    invokeExact($value1$, Void.class);
             });
             // Incorrect arity
             checkWMTE(() -> { // 0
                 boolean r = (boolean) hs.get(am, methodType(boolean.class)).
-                    invoke();
+                    invokeExact();
             });
             checkWMTE(() -> { // >
                 boolean r = (boolean) hs.get(am, methodType(boolean.class, $type$.class, $type$.class, Class.class)).
-                    invoke($value1$, $value1$, Void.class);
+                    invokeExact($value1$, $value1$, Void.class);
             });
         }
 
         for (TestAccessMode am : testAccessModesOfType(TestAccessType.COMPARE_AND_EXCHANGE)) {
             // Incorrect argument types
-            check{#if[String]?CCE:WMTE}(() -> { // expected reference class
+            {#if[String]?hs.checkWMTEOrCCE:checkWMTE}(() -> { // expected reference class
                 $type$ x = ($type$) hs.get(am, methodType($type$.class, Class.class, $type$.class)).
-                    invoke(Void.class, $value1$);
+                    invokeExact(Void.class, $value1$);
             });
-            check{#if[String]?CCE:WMTE}(() -> { // actual reference class
+            {#if[String]?hs.checkWMTEOrCCE:checkWMTE}(() -> { // actual reference class
                 $type$ x = ($type$) hs.get(am, methodType($type$.class, $type$.class, Class.class)).
-                    invoke($value1$, Void.class);
+                    invokeExact($value1$, Void.class);
             });
             // Incorrect return type
-            check{#if[String]?CCE:WMTE}(() -> { // reference class
+            {#if[String]?hs.checkWMTEOrCCE:checkWMTE}(() -> { // reference class
                 Void r = (Void) hs.get(am, methodType(Void.class, $type$.class, $type$.class)).
-                    invoke($value1$, $value1$);
+                    invokeExact($value1$, $value1$);
             });
             checkWMTE(() -> { // primitive class
                 $wrong_primitive_type$ x = ($wrong_primitive_type$) hs.get(am, methodType($wrong_primitive_type$.class, $type$.class, $type$.class)).
-                    invoke($value1$, $value1$);
+                    invokeExact($value1$, $value1$);
             });
             // Incorrect arity
             checkWMTE(() -> { // 0
                 $type$ x = ($type$) hs.get(am, methodType($type$.class)).
-                    invoke();
+                    invokeExact();
             });
             checkWMTE(() -> { // >
                 $type$ x = ($type$) hs.get(am, methodType($type$.class, $type$.class, $type$.class, Class.class)).
-                    invoke($value1$, $value1$, Void.class);
+                    invokeExact($value1$, $value1$, Void.class);
             });
         }
 
         for (TestAccessMode am : testAccessModesOfType(TestAccessType.GET_AND_SET)) {
             // Incorrect argument types
-            check{#if[String]?CCE:WMTE}(() -> { // value reference class
+            {#if[String]?hs.checkWMTEOrCCE:checkWMTE}(() -> { // value reference class
                 $type$ x = ($type$) hs.get(am, methodType($type$.class, Class.class)).
-                    invoke(Void.class);
+                    invokeExact(Void.class);
             });
             // Incorrect return type
-            check{#if[String]?CCE:WMTE}(() -> { // reference class
+            {#if[String]?hs.checkWMTEOrCCE:checkWMTE}(() -> { // reference class
                 Void r = (Void) hs.get(am, methodType(Void.class, $type$.class)).
-                    invoke($value1$);
+                    invokeExact($value1$);
             });
             checkWMTE(() -> { // primitive class
                 $wrong_primitive_type$ x = ($wrong_primitive_type$) hs.get(am, methodType($wrong_primitive_type$.class, $type$.class)).
-                    invoke($value1$);
+                    invokeExact($value1$);
             });
             // Incorrect arity
             checkWMTE(() -> { // 0
                 $type$ x = ($type$) hs.get(am, methodType($type$.class)).
-                    invoke();
+                    invokeExact();
             });
             checkWMTE(() -> { // >
                 $type$ x = ($type$) hs.get(am, methodType($type$.class, $type$.class, Class.class)).
-                    invoke($value1$, Void.class);
+                    invokeExact($value1$, Void.class);
             });
         }
 #end[CAS]
@@ -1314,25 +1316,25 @@
             // Incorrect argument types
             check{#if[String]?CCE:WMTE}(() -> { // value reference class
                 $type$ x = ($type$) hs.get(am, methodType($type$.class, Class.class)).
-                    invoke(Void.class);
+                    invokeExact(Void.class);
             });
             // Incorrect return type
             check{#if[String]?CCE:WMTE}(() -> { // reference class
                 Void r = (Void) hs.get(am, methodType(Void.class, $type$.class)).
-                    invoke($value1$);
+                    invokeExact($value1$);
             });
             checkWMTE(() -> { // primitive class
                 $wrong_primitive_type$ x = ($wrong_primitive_type$) hs.get(am, methodType($wrong_primitive_type$.class, $type$.class)).
-                    invoke($value1$);
+                    invokeExact($value1$);
             });
             // Incorrect arity
             checkWMTE(() -> { // 0
                 $type$ x = ($type$) hs.get(am, methodType($type$.class)).
-                    invoke();
+                    invokeExact();
             });
             checkWMTE(() -> { // >
                 $type$ x = ($type$) hs.get(am, methodType($type$.class, $type$.class, Class.class)).
-                    invoke($value1$, Void.class);
+                    invokeExact($value1$, Void.class);
             });
         }
 #end[AtomicAdd]
@@ -1929,196 +1931,196 @@
         for (TestAccessMode am : testAccessModesOfType(TestAccessType.GET)) {
             // Incorrect argument types
             checkNPE(() -> { // null array
-                $type$ x = ($type$) hs.get(am, methodType($type$.class, Void.class, int.class)).
-                    invoke(null, 0);
+                $type$ x = ($type$) hs.get(am, methodType($type$.class, $type$[].class, int.class)).
+                    invokeExact(($type$[]) null, 0);
             });
-            checkCCE(() -> { // array reference class
+            hs.checkWMTEOrCCE(() -> { // array reference class
                 $type$ x = ($type$) hs.get(am, methodType($type$.class, Class.class, int.class)).
-                    invoke(Void.class, 0);
+                    invokeExact(Void.class, 0);
             });
             checkWMTE(() -> { // array primitive class
                 $type$ x = ($type$) hs.get(am, methodType($type$.class, int.class, int.class)).
-                    invoke(0, 0);
+                    invokeExact(0, 0);
             });
             checkWMTE(() -> { // index reference class
                 $type$ x = ($type$) hs.get(am, methodType($type$.class, $type$[].class, Class.class)).
-                    invoke(array, Void.class);
+                    invokeExact(array, Void.class);
             });
             // Incorrect return type
-            check{#if[String]?CCE:WMTE}(() -> { // reference class
+            {#if[String]?hs.checkWMTEOrCCE:checkWMTE}(() -> { // reference class
                 Void x = (Void) hs.get(am, methodType(Void.class, $type$[].class, int.class)).
-                    invoke(array, 0);
+                    invokeExact(array, 0);
             });
             checkWMTE(() -> { // primitive class
                 $wrong_primitive_type$ x = ($wrong_primitive_type$) hs.get(am, methodType($wrong_primitive_type$.class, $type$[].class, int.class)).
-                    invoke(array, 0);
+                    invokeExact(array, 0);
             });
             // Incorrect arity
             checkWMTE(() -> { // 0
                 $type$ x = ($type$) hs.get(am, methodType($type$.class)).
-                    invoke();
+                    invokeExact();
             });
             checkWMTE(() -> { // >
                 $type$ x = ($type$) hs.get(am, methodType($type$.class, $type$[].class, int.class, Class.class)).
-                    invoke(array, 0, Void.class);
+                    invokeExact(array, 0, Void.class);
             });
         }
 
         for (TestAccessMode am : testAccessModesOfType(TestAccessType.SET)) {
             // Incorrect argument types
             checkNPE(() -> { // null array
-                hs.get(am, methodType(void.class, Void.class, int.class, $type$.class)).
-                    invoke(null, 0, $value1$);
+                hs.get(am, methodType(void.class, $type$[].class, int.class, $type$.class)).
+                    invokeExact(($type$[]) null, 0, $value1$);
             });
-            checkCCE(() -> { // array reference class
+            hs.checkWMTEOrCCE(() -> { // array reference class
                 hs.get(am, methodType(void.class, Class.class, int.class, $type$.class)).
-                    invoke(Void.class, 0, $value1$);
+                    invokeExact(Void.class, 0, $value1$);
             });
-            check{#if[String]?CCE:WMTE}(() -> { // value reference class
+            {#if[String]?hs.checkWMTEOrCCE:checkWMTE}(() -> { // value reference class
                 hs.get(am, methodType(void.class, $type$[].class, int.class, Class.class)).
-                    invoke(array, 0, Void.class);
+                    invokeExact(array, 0, Void.class);
             });
             checkWMTE(() -> { // receiver primitive class
                 hs.get(am, methodType(void.class, int.class, int.class, $type$.class)).
-                    invoke(0, 0, $value1$);
+                    invokeExact(0, 0, $value1$);
             });
             checkWMTE(() -> { // index reference class
                 hs.get(am, methodType(void.class, $type$[].class, Class.class, $type$.class)).
-                    invoke(array, Void.class, $value1$);
+                    invokeExact(array, Void.class, $value1$);
             });
             // Incorrect arity
             checkWMTE(() -> { // 0
                 hs.get(am, methodType(void.class)).
-                    invoke();
+                    invokeExact();
             });
             checkWMTE(() -> { // >
                 hs.get(am, methodType(void.class, $type$[].class, int.class, Class.class)).
-                    invoke(array, 0, $value1$, Void.class);
+                    invokeExact(array, 0, $value1$, Void.class);
             });
         }
 #if[CAS]
         for (TestAccessMode am : testAccessModesOfType(TestAccessType.COMPARE_AND_SET)) {
             // Incorrect argument types
             checkNPE(() -> { // null receiver
-                boolean r = (boolean) hs.get(am, methodType(boolean.class, Void.class, int.class, $type$.class, $type$.class)).
-                    invoke(null, 0, $value1$, $value1$);
+                boolean r = (boolean) hs.get(am, methodType(boolean.class, $type$[].class, int.class, $type$.class, $type$.class)).
+                    invokeExact(($type$[]) null, 0, $value1$, $value1$);
             });
-            checkCCE(() -> { // receiver reference class
+            hs.checkWMTEOrCCE(() -> { // receiver reference class
                 boolean r = (boolean) hs.get(am, methodType(boolean.class, Class.class, int.class, $type$.class, $type$.class)).
-                    invoke(Void.class, 0, $value1$, $value1$);
+                    invokeExact(Void.class, 0, $value1$, $value1$);
             });
-            check{#if[String]?CCE:WMTE}(() -> { // expected reference class
+            {#if[String]?hs.checkWMTEOrCCE:checkWMTE}(() -> { // expected reference class
                 boolean r = (boolean) hs.get(am, methodType(boolean.class, $type$[].class, int.class, Class.class, $type$.class)).
-                    invoke(array, 0, Void.class, $value1$);
+                    invokeExact(array, 0, Void.class, $value1$);
             });
-            check{#if[String]?CCE:WMTE}(() -> { // actual reference class
+            {#if[String]?hs.checkWMTEOrCCE:checkWMTE}(() -> { // actual reference class
                 boolean r = (boolean) hs.get(am, methodType(boolean.class, $type$[].class, int.class, $type$.class, Class.class)).
-                    invoke(array, 0, $value1$, Void.class);
+                    invokeExact(array, 0, $value1$, Void.class);
             });
             checkWMTE(() -> { // receiver primitive class
                 boolean r = (boolean) hs.get(am, methodType(boolean.class, int.class, int.class, $type$.class, $type$.class)).
-                    invoke(0, 0, $value1$, $value1$);
+                    invokeExact(0, 0, $value1$, $value1$);
             });
             checkWMTE(() -> { // index reference class
                 boolean r = (boolean) hs.get(am, methodType(boolean.class, $type$[].class, Class.class, $type$.class, $type$.class)).
-                    invoke(array, Void.class, $value1$, $value1$);
+                    invokeExact(array, Void.class, $value1$, $value1$);
             });
             // Incorrect arity
             checkWMTE(() -> { // 0
                 boolean r = (boolean) hs.get(am, methodType(boolean.class)).
-                    invoke();
+                    invokeExact();
             });
             checkWMTE(() -> { // >
                 boolean r = (boolean) hs.get(am, methodType(boolean.class, $type$[].class, int.class, $type$.class, $type$.class, Class.class)).
-                    invoke(array, 0, $value1$, $value1$, Void.class);
+                    invokeExact(array, 0, $value1$, $value1$, Void.class);
             });
         }
 
         for (TestAccessMode am : testAccessModesOfType(TestAccessType.COMPARE_AND_EXCHANGE)) {
             // Incorrect argument types
             checkNPE(() -> { // null receiver
-                $type$ x = ($type$) hs.get(am, methodType($type$.class, Void.class, int.class, $type$.class, $type$.class)).
-                    invoke(null, 0, $value1$, $value1$);
+                $type$ x = ($type$) hs.get(am, methodType($type$.class, $type$[].class, int.class, $type$.class, $type$.class)).
+                    invokeExact(($type$[]) null, 0, $value1$, $value1$);
             });
-            checkCCE(() -> { // array reference class
+            hs.checkWMTEOrCCE(() -> { // array reference class
                 $type$ x = ($type$) hs.get(am, methodType($type$.class, Class.class, int.class, $type$.class, $type$.class)).
-                    invoke(Void.class, 0, $value1$, $value1$);
+                    invokeExact(Void.class, 0, $value1$, $value1$);
             });
-            check{#if[String]?CCE:WMTE}(() -> { // expected reference class
+            {#if[String]?hs.checkWMTEOrCCE:checkWMTE}(() -> { // expected reference class
                 $type$ x = ($type$) hs.get(am, methodType($type$.class, $type$[].class, int.class, Class.class, $type$.class)).
-                    invoke(array, 0, Void.class, $value1$);
+                    invokeExact(array, 0, Void.class, $value1$);
             });
-            check{#if[String]?CCE:WMTE}(() -> { // actual reference class
+            {#if[String]?hs.checkWMTEOrCCE:checkWMTE}(() -> { // actual reference class
                 $type$ x = ($type$) hs.get(am, methodType($type$.class, $type$[].class, int.class, $type$.class, Class.class)).
-                    invoke(array, 0, $value1$, Void.class);
+                    invokeExact(array, 0, $value1$, Void.class);
             });
             checkWMTE(() -> { // array primitive class
                 $type$ x = ($type$) hs.get(am, methodType($type$.class, int.class, int.class, $type$.class, $type$.class)).
-                    invoke(0, 0, $value1$, $value1$);
+                    invokeExact(0, 0, $value1$, $value1$);
             });
             checkWMTE(() -> { // index reference class
                 $type$ x = ($type$) hs.get(am, methodType($type$.class, $type$[].class, Class.class, $type$.class, $type$.class)).
-                    invoke(array, Void.class, $value1$, $value1$);
+                    invokeExact(array, Void.class, $value1$, $value1$);
             });
             // Incorrect return type
-            check{#if[String]?CCE:WMTE}(() -> { // reference class
+            {#if[String]?hs.checkWMTEOrCCE:checkWMTE}(() -> { // reference class
                 Void r = (Void) hs.get(am, methodType(Void.class, $type$[].class, int.class, $type$.class, $type$.class)).
-                    invoke(array, 0, $value1$, $value1$);
+                    invokeExact(array, 0, $value1$, $value1$);
             });
             checkWMTE(() -> { // primitive class
                 $wrong_primitive_type$ x = ($wrong_primitive_type$) hs.get(am, methodType($wrong_primitive_type$.class, $type$[].class, int.class, $type$.class, $type$.class)).
-                    invoke(array, 0, $value1$, $value1$);
+                    invokeExact(array, 0, $value1$, $value1$);
             });
             // Incorrect arity
             checkWMTE(() -> { // 0
                 $type$ x = ($type$) hs.get(am, methodType($type$.class)).
-                    invoke();
+                    invokeExact();
             });
             checkWMTE(() -> { // >
                 $type$ x = ($type$) hs.get(am, methodType($type$.class, $type$[].class, int.class, $type$.class, $type$.class, Class.class)).
-                    invoke(array, 0, $value1$, $value1$, Void.class);
+                    invokeExact(array, 0, $value1$, $value1$, Void.class);
             });
         }
 
         for (TestAccessMode am : testAccessModesOfType(TestAccessType.GET_AND_SET)) {
             // Incorrect argument types
             checkNPE(() -> { // null array
-                $type$ x = ($type$) hs.get(am, methodType($type$.class, Void.class, int.class, $type$.class)).
-                    invoke(null, 0, $value1$);
+                $type$ x = ($type$) hs.get(am, methodType($type$.class, $type$[].class, int.class, $type$.class)).
+                    invokeExact(($type$[]) null, 0, $value1$);
             });
-            checkCCE(() -> { // array reference class
+            hs.checkWMTEOrCCE(() -> { // array reference class
                 $type$ x = ($type$) hs.get(am, methodType($type$.class, Class.class, int.class, $type$.class)).
-                    invoke(Void.class, 0, $value1$);
+                    invokeExact(Void.class, 0, $value1$);
             });
-            check{#if[String]?CCE:WMTE}(() -> { // value reference class
+            {#if[String]?hs.checkWMTEOrCCE:checkWMTE}(() -> { // value reference class
                 $type$ x = ($type$) hs.get(am, methodType($type$.class, $type$[].class, int.class, Class.class)).
-                    invoke(array, 0, Void.class);
+                    invokeExact(array, 0, Void.class);
             });
             checkWMTE(() -> { // array primitive class
                 $type$ x = ($type$) hs.get(am, methodType($type$.class, int.class, int.class, $type$.class)).
-                    invoke(0, 0, $value1$);
+                    invokeExact(0, 0, $value1$);
             });
             checkWMTE(() -> { // index reference class
                 $type$ x = ($type$) hs.get(am, methodType($type$.class, $type$[].class, Class.class, $type$.class)).
-                    invoke(array, Void.class, $value1$);
+                    invokeExact(array, Void.class, $value1$);
             });
             // Incorrect return type
-            check{#if[String]?CCE:WMTE}(() -> { // reference class
+            {#if[String]?hs.checkWMTEOrCCE:checkWMTE}(() -> { // reference class
                 Void r = (Void) hs.get(am, methodType(Void.class, $type$[].class, int.class, $type$.class)).
-                    invoke(array, 0, $value1$);
+                    invokeExact(array, 0, $value1$);
             });
             checkWMTE(() -> { // primitive class
                 $wrong_primitive_type$ x = ($wrong_primitive_type$) hs.get(am, methodType($wrong_primitive_type$.class, $type$[].class, int.class, $type$.class)).
-                    invoke(array, 0, $value1$);
+                    invokeExact(array, 0, $value1$);
             });
             // Incorrect arity
             checkWMTE(() -> { // 0
                 $type$ x = ($type$) hs.get(am, methodType($type$.class)).
-                    invoke();
+                    invokeExact();
             });
             checkWMTE(() -> { // >
                 $type$ x = ($type$) hs.get(am, methodType($type$.class, $type$[].class, int.class, $type$.class, Class.class)).
-                    invoke(array, 0, $value1$, Void.class);
+                    invokeExact(array, 0, $value1$, Void.class);
             });
         }
 #end[CAS]
@@ -2127,42 +2129,42 @@
         for (TestAccessMode am : testAccessModesOfType(TestAccessType.GET_AND_ADD)) {
             // Incorrect argument types
             checkNPE(() -> { // null array
-                $type$ x = ($type$) hs.get(am, methodType($type$.class, Void.class, int.class, $type$.class)).
-                    invoke(null, 0, $value1$);
+                $type$ x = ($type$) hs.get(am, methodType($type$.class, $type$[].class, int.class, $type$.class)).
+                    invokeExact(($type$[]) null, 0, $value1$);
             });
-            checkCCE(() -> { // array reference class
+            hs.checkWMTEOrCCE(() -> { // array reference class
                 $type$ x = ($type$) hs.get(am, methodType($type$.class, Class.class, int.class, $type$.class)).
-                    invoke(Void.class, 0, $value1$);
+                    invokeExact(Void.class, 0, $value1$);
             });
-            check{#if[String]?CCE:WMTE}(() -> { // value reference class
+            {#if[String]?hs.checkWMTEOrCCE:checkWMTE}(() -> { // value reference class
                 $type$ x = ($type$) hs.get(am, methodType($type$.class, $type$[].class, int.class, Class.class)).
-                    invoke(array, 0, Void.class);
+                    invokeExact(array, 0, Void.class);
             });
             checkWMTE(() -> { // array primitive class
                 $type$ x = ($type$) hs.get(am, methodType($type$.class, int.class, int.class, $type$.class)).
-                    invoke(0, 0, $value1$);
+                    invokeExact(0, 0, $value1$);
             });
             checkWMTE(() -> { // index reference class
                 $type$ x = ($type$) hs.get(am, methodType($type$.class, $type$[].class, Class.class, $type$.class)).
-                    invoke(array, Void.class, $value1$);
+                    invokeExact(array, Void.class, $value1$);
             });
             // Incorrect return type
-            check{#if[String]?CCE:WMTE}(() -> { // reference class
+            {#if[String]?hs.checkWMTEOrCCE:checkWMTE}(() -> { // reference class
                 Void r = (Void) hs.get(am, methodType(Void.class, $type$[].class, int.class, $type$.class)).
-                    invoke(array, 0, $value1$);
+                    invokeExact(array, 0, $value1$);
             });
             checkWMTE(() -> { // primitive class
                 $wrong_primitive_type$ x = ($wrong_primitive_type$) hs.get(am, methodType($wrong_primitive_type$.class, $type$[].class, int.class, $type$.class)).
-                    invoke(array, 0, $value1$);
+                    invokeExact(array, 0, $value1$);
             });
             // Incorrect arity
             checkWMTE(() -> { // 0
                 $type$ x = ($type$) hs.get(am, methodType($type$.class)).
-                    invoke();
+                    invokeExact();
             });
             checkWMTE(() -> { // >
                 $type$ x = ($type$) hs.get(am, methodType($type$.class, $type$[].class, int.class, $type$.class, Class.class)).
-                    invoke(array, 0, $value1$, Void.class);
+                    invokeExact(array, 0, $value1$, Void.class);
             });
         }
 #end[AtomicAdd]
--- a/jdk/test/java/lang/invoke/VarHandles/generate-vh-tests.sh	Thu May 19 17:48:02 2016 +0000
+++ b/jdk/test/java/lang/invoke/VarHandles/generate-vh-tests.sh	Thu May 19 19:46:20 2016 +0000
@@ -113,36 +113,40 @@
       ;;
   esac
 
+  # The value of `value3` is chosen such that when added to `value1` or `value2`
+  # it will result in carrying of bits over to the next byte, thereby detecting
+  # possible errors in endianness conversion e.g. if say for atomic addition the
+  # augend is incorrectly processed
   case $type in
     short)
       value1=(short)0x0102
       value2=(short)0x1112
-      value3=(short)0x2122
+      value3=(short)0xFFFE
       ;;
     char)
       value1=(char)0x0102
       value2=(char)0x1112
-      value3=(char)0x2122
+      value3=(char)0xFFFE
       ;;
     int)
       value1=0x01020304
       value2=0x11121314
-      value3=0x21222324
+      value3=0xFFFEFDFC
       ;;
     long)
       value1=0x0102030405060708L
       value2=0x1112131415161718L
-      value3=0x2122232425262728L
+      value3=0xFFFEFDFCFBFAF9F8L
       ;;
     float)
       value1=0x01020304
       value2=0x11121314
-      value3=0x21222324
+      value3=0xFFFEFDFC
       ;;
     double)
       value1=0x0102030405060708L
       value2=0x1112131415161718L
-      value3=0x2122232425262728L
+      value3=0xFFFEFDFCFBFAF9F8L
       ;;
   esac
 
--- a/jdk/test/java/lang/management/MemoryMXBean/ResetPeakMemoryUsage.java	Thu May 19 17:48:02 2016 +0000
+++ b/jdk/test/java/lang/management/MemoryMXBean/ResetPeakMemoryUsage.java	Thu May 19 19:46:20 2016 +0000
@@ -36,9 +36,13 @@
  * @modules jdk.management
  * @build jdk.testlibrary.* ResetPeakMemoryUsage MemoryUtil RunUtil
  * @run main ResetPeakMemoryUsage
+ * @requires vm.opt.ExplicitGCInvokesConcurrent != "true"
+ * @requires vm.opt.ExplicitGCInvokesConcurrentAndUnloadsClasses != "true"
+ * @requires vm.opt.DisableExplicitGC != "true"
  */
 
 import java.lang.management.*;
+import java.lang.ref.WeakReference;
 import java.util.*;
 
 public class ResetPeakMemoryUsage {
@@ -100,6 +104,7 @@
         printMemoryUsage(usage0, peak0);
 
         obj = new Object[largeArraySize];
+        WeakReference<Object> weakRef = new WeakReference<>(obj);
 
         MemoryUsage usage1 = mpool.getUsage();
         MemoryUsage peak1 = mpool.getPeakUsage();
@@ -124,7 +129,11 @@
         // The object is now garbage and do a GC
         // memory usage should drop
         obj = null;
-        mbean.gc();
+
+        //This will cause sure shot GC unlike Runtime.gc() invoked by mbean.gc()
+        while(weakRef.get() != null) {
+            mbean.gc();
+        }
 
         MemoryUsage usage2 = mpool.getUsage();
         MemoryUsage peak2 = mpool.getPeakUsage();
--- a/jdk/test/java/lang/management/PlatformLoggingMXBean/PlatformLoggingMXBeanTest.java	Thu May 19 17:48:02 2016 +0000
+++ b/jdk/test/java/lang/management/PlatformLoggingMXBean/PlatformLoggingMXBeanTest.java	Thu May 19 19:46:20 2016 +0000
@@ -270,8 +270,7 @@
         // Calling getMBeanInfo will throw exception if not found.
         platformMBS.getMBeanInfo(objName);
 
-        if (!platformMBS.isInstanceOf(objName, "java.lang.management.PlatformLoggingMXBean") ||
-            !platformMBS.isInstanceOf(objName, "java.util.logging.LoggingMXBean")) {
+        if (!platformMBS.isInstanceOf(objName, "java.lang.management.PlatformLoggingMXBean")) {
             throw new RuntimeException(objName + " is of unexpected type");
         }
 
--- a/jdk/test/java/lang/reflect/Layer/LayerAndLoadersTest.java	Thu May 19 17:48:02 2016 +0000
+++ b/jdk/test/java/lang/reflect/Layer/LayerAndLoadersTest.java	Thu May 19 19:46:20 2016 +0000
@@ -24,6 +24,7 @@
 /**
  * @test
  * @library /lib/testlibrary
+ * @modules jdk.compiler
  * @build LayerAndLoadersTest CompilerUtils ModuleUtils
  * @run testng LayerAndLoadersTest
  * @summary Tests for java.lang.reflect.Layer@createWithXXX methods
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/jdk/test/java/net/httpclient/http2/TLSConnection.java	Thu May 19 19:46:20 2016 +0000
@@ -0,0 +1,247 @@
+/*
+ * Copyright (c) 2016, 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.
+ */
+
+import java.io.File;
+import java.io.IOException;
+import java.io.InputStream;
+import java.io.OutputStream;
+import java.net.URI;
+import java.net.URISyntaxException;
+import java.net.http.Http2Handler;
+import java.net.http.Http2TestExchange;
+import java.net.http.Http2TestServer;
+import java.net.http.HttpClient;
+import java.net.http.HttpRequest;
+import java.net.http.HttpResponse;
+import javax.net.ssl.SSLParameters;
+import javax.net.ssl.SSLSession;
+
+/*
+ * @test
+ * @bug 8150769 8157107
+ * @summary Checks that SSL parameters can be set for HTTP/2 connection
+ * @modules java.httpclient
+ * @compile/module=java.httpclient java/net/http/Http2Handler.java
+ * @compile/module=java.httpclient java/net/http/Http2TestExchange.java
+ * @compile/module=java.httpclient java/net/http/Http2TestServer.java
+ * @run main/othervm TLSConnection
+ */
+public class TLSConnection {
+
+    private static final String KEYSTORE = System.getProperty("test.src")
+            + File.separator + "keystore.p12";
+   private static final String PASSWORD = "password";
+
+    public static void main(String[] args) throws Exception {
+
+        // enable all logging
+        System.setProperty("java.net.http.HttpClient.log", "all,frames:all");
+
+        // initialize JSSE
+        System.setProperty("javax.net.ssl.keyStore", KEYSTORE);
+        System.setProperty("javax.net.ssl.keyStorePassword", PASSWORD);
+        System.setProperty("javax.net.ssl.trustStore", KEYSTORE);
+        System.setProperty("javax.net.ssl.trustStorePassword", PASSWORD);
+
+        Handler handler = new Handler();
+
+        try (Http2TestServer server = new Http2TestServer(true, 0, handler)) {
+            server.start();
+
+            int port = server.getAddress().getPort();
+            String uriString = "https://127.0.0.1:" + Integer.toString(port);
+
+            // run test cases
+            boolean success = true;
+
+            SSLParameters parameters = null;
+            success &= expectFailure(
+                    "Test #1: SSL parameters is null, expect NPE",
+                    () -> connect(uriString, parameters),
+                    NullPointerException.class);
+
+            success &= expectSuccess(
+                    "Test #2: default SSL parameters, "
+                            + "expect successful connection",
+                    () -> connect(uriString, new SSLParameters()));
+            success &= checkProtocol(handler.getSSLSession(), "TLSv1.2");
+
+            // set SSL_DHE_RSA_WITH_3DES_EDE_CBC_SHA cipher suite
+            // which has less priority in default cipher suite list
+            success &= expectSuccess(
+                    "Test #3: SSL parameters with "
+                            + "SSL_DHE_RSA_WITH_3DES_EDE_CBC_SHA cipher suite, "
+                            + "expect successful connection",
+                    () -> connect(uriString, new SSLParameters(
+                            new String[] { "SSL_DHE_RSA_WITH_3DES_EDE_CBC_SHA" })));
+            success &= checkProtocol(handler.getSSLSession(), "TLSv1.2");
+            success &= checkCipherSuite(handler.getSSLSession(),
+                    "SSL_DHE_RSA_WITH_3DES_EDE_CBC_SHA");
+
+            // set TLS_RSA_WITH_AES_128_CBC_SHA cipher suite
+            // which has less priority in default cipher suite list
+            // also set TLSv11 protocol
+            success &= expectSuccess(
+                    "Test #4: SSL parameters with "
+                            + "TLS_RSA_WITH_AES_128_CBC_SHA cipher suite,"
+                            + " expect successful connection",
+                    () -> connect(uriString, new SSLParameters(
+                            new String[] { "TLS_RSA_WITH_AES_128_CBC_SHA" },
+                            new String[] { "TLSv1.1" })));
+            success &= checkProtocol(handler.getSSLSession(), "TLSv1.1");
+            success &= checkCipherSuite(handler.getSSLSession(),
+                    "TLS_RSA_WITH_AES_128_CBC_SHA");
+
+            if (success) {
+                System.out.println("Test passed");
+            } else {
+                throw new RuntimeException("At least one test case failed");
+            }
+        }
+    }
+
+    private static interface Test {
+
+        public void run() throws Exception;
+    }
+
+    private static class Handler implements Http2Handler {
+
+        private static final byte[] BODY = "Test response".getBytes();
+
+        private volatile SSLSession sslSession;
+
+        @Override
+        public void handle(Http2TestExchange t) throws IOException {
+            System.out.println("Handler: received request to "
+                    + t.getRequestURI());
+
+            try (InputStream is = t.getRequestBody()) {
+                byte[] body = is.readAllBytes();
+                System.out.println("Handler: read " + body.length
+                        + " bytes of body: ");
+                System.out.println(new String(body));
+            }
+
+            try (OutputStream os = t.getResponseBody()) {
+                t.sendResponseHeaders(200, BODY.length);
+                os.write(BODY);
+            }
+
+            sslSession = t.getSSLSession();
+        }
+
+        SSLSession getSSLSession() {
+            return sslSession;
+        }
+    }
+
+    private static void connect(String uriString, SSLParameters sslParameters)
+            throws URISyntaxException, IOException, InterruptedException {
+
+        String body = HttpClient.create()
+                .sslParameters(sslParameters)
+                .version(HttpClient.Version.HTTP_2)
+                .build()
+                .request(new URI(uriString))
+                .body(HttpRequest.fromString("body"))
+                .GET()
+                .response()
+                .body(HttpResponse.asString());
+
+        System.out.println("Response: " + body);
+    }
+
+    private static boolean checkProtocol(SSLSession session, String protocol) {
+        if (session == null) {
+            System.out.println("Check protocol: no session provided");
+            return false;
+        }
+
+        System.out.println("Check protocol: negotiated protocol: "
+                + session.getProtocol());
+        System.out.println("Check protocol: expected protocol: "
+                + protocol);
+        if (!protocol.equals(session.getProtocol())) {
+            System.out.println("Check protocol: unexpected negotiated protocol");
+            return false;
+        }
+
+        return true;
+    }
+
+    private static boolean checkCipherSuite(SSLSession session, String ciphersuite) {
+        if (session == null) {
+            System.out.println("Check protocol: no session provided");
+            return false;
+        }
+
+        System.out.println("Check protocol: negotiated ciphersuite: "
+                + session.getCipherSuite());
+        System.out.println("Check protocol: expected ciphersuite: "
+                + ciphersuite);
+        if (!ciphersuite.equals(session.getCipherSuite())) {
+            System.out.println("Check protocol: unexpected negotiated ciphersuite");
+            return false;
+        }
+
+        return true;
+    }
+
+    private static boolean expectSuccess(String message, Test test) {
+        System.out.println(message);
+        try {
+            test.run();
+            System.out.println("Passed");
+            return true;
+        } catch (Exception e) {
+            System.out.println("Failed: unexpected exception:");
+            e.printStackTrace(System.out);
+            return false;
+        }
+    }
+
+    private static boolean expectFailure(String message, Test test,
+            Class<? extends Throwable> expectedException) {
+
+        System.out.println(message);
+        try {
+            test.run();
+            System.out.println("Failed: unexpected successful connection");
+            return false;
+        } catch (Exception e) {
+            System.out.println("Got an exception:");
+            e.printStackTrace(System.out);
+            if (expectedException != null
+                    && !expectedException.isAssignableFrom(e.getClass())) {
+                System.out.printf("Failed: expected %s, but got %s%n",
+                        expectedException.getName(),
+                        e.getClass().getName());
+                return false;
+            }
+            System.out.println("Passed: expected exception");
+            return true;
+        }
+    }
+
+}
--- a/jdk/test/java/net/httpclient/http2/java.httpclient/java/net/http/Http2TestServer.java	Thu May 19 17:48:02 2016 +0000
+++ b/jdk/test/java/net/httpclient/http2/java.httpclient/java/net/http/Http2TestServer.java	Thu May 19 19:46:20 2016 +0000
@@ -42,7 +42,7 @@
  * Http2Handler on additional threads. All threads
  * obtained from the supplied ExecutorService.
  */
-public class Http2TestServer {
+public class Http2TestServer implements AutoCloseable {
     final ServerSocket server;
     boolean secure;
     SettingsFrame serverSettings, clientSettings;
@@ -156,4 +156,9 @@
         });
     }
 
+    @Override
+    public void close() throws Exception {
+        stop();
+    }
+
 }
--- a/jdk/test/java/nio/Buffer/Order-X.java.template	Thu May 19 17:48:02 2016 +0000
+++ b/jdk/test/java/nio/Buffer/Order-X.java.template	Thu May 19 19:46:20 2016 +0000
@@ -52,8 +52,5 @@
         buf = $Type$Buffer.allocate(LENGTH);
         ck(buf.order(), nord);
         ck$Type$Buffer(buf, nord);
-
-        ck$Type$Buffer(ByteBuffer.allocate(LENGTH).as$Type$Buffer(), be);
-        ck$Type$Buffer(ByteBuffer.allocateDirect(LENGTH).as$Type$Buffer(), be);
     }
 }
--- a/jdk/test/java/nio/Buffer/Order.java	Thu May 19 17:48:02 2016 +0000
+++ b/jdk/test/java/nio/Buffer/Order.java	Thu May 19 19:46:20 2016 +0000
@@ -51,25 +51,31 @@
         ck(bb.asDoubleBuffer().order(), bb.order());
     }
 
+    private static void ckCopyViews(ByteBuffer bb) {
+        ck(bb.asReadOnlyBuffer().order(), be);
+        ck(bb.duplicate().order(), be);
+        ck(bb.slice().order(), be);
+    }
+
     private static void ckByteBuffer(ByteBuffer bb) {
         ckViews(bb);
+        ckCopyViews(bb);
         bb.order(be);
         ckViews(bb);
+        ckCopyViews(bb);
         bb.order(le);
         ckViews(bb);
-
-        if (bb.hasArray()) {
-            byte[] array = bb.array();
-            ck(ByteBuffer.wrap(array, LENGTH/2, LENGTH/2).order(), be);
-            ck(ByteBuffer.wrap(array).order(), be);
-            ck(bb.asReadOnlyBuffer().order(), be);
-            ck(bb.duplicate().order(), be);
-            ck(bb.slice().order(), be);
-        }
+        ckCopyViews(bb);
     }
 
     public static void main(String args[]) throws Exception {
 
+        ck(ByteBuffer.wrap(new byte[LENGTH], LENGTH/2, LENGTH/2).order(), be);
+        ck(ByteBuffer.wrap(new byte[LENGTH]).order(), be);
+        ck(ByteBuffer.wrap(new byte[LENGTH], LENGTH/2, LENGTH/2).order(be).order(), be);
+        ck(ByteBuffer.wrap(new byte[LENGTH]).order(be).order(), be);
+        ck(ByteBuffer.wrap(new byte[LENGTH], LENGTH/2, LENGTH/2).order(le).order(), le);
+        ck(ByteBuffer.wrap(new byte[LENGTH]).order(le).order(), le);
         ck(ByteBuffer.allocate(LENGTH).order(), be);
         ck(ByteBuffer.allocateDirect(LENGTH).order(), be);
         ck(ByteBuffer.allocate(LENGTH).order(be).order(), be);
--- a/jdk/test/java/nio/Buffer/OrderChar.java	Thu May 19 17:48:02 2016 +0000
+++ b/jdk/test/java/nio/Buffer/OrderChar.java	Thu May 19 19:46:20 2016 +0000
@@ -52,8 +52,5 @@
         buf = CharBuffer.allocate(LENGTH);
         ck(buf.order(), nord);
         ckCharBuffer(buf, nord);
-
-        ckCharBuffer(ByteBuffer.allocate(LENGTH).asCharBuffer(), be);
-        ckCharBuffer(ByteBuffer.allocateDirect(LENGTH).asCharBuffer(), be);
     }
 }
--- a/jdk/test/java/nio/Buffer/OrderDouble.java	Thu May 19 17:48:02 2016 +0000
+++ b/jdk/test/java/nio/Buffer/OrderDouble.java	Thu May 19 19:46:20 2016 +0000
@@ -52,8 +52,5 @@
         buf = DoubleBuffer.allocate(LENGTH);
         ck(buf.order(), nord);
         ckDoubleBuffer(buf, nord);
-
-        ckDoubleBuffer(ByteBuffer.allocate(LENGTH).asDoubleBuffer(), be);
-        ckDoubleBuffer(ByteBuffer.allocateDirect(LENGTH).asDoubleBuffer(), be);
     }
 }
--- a/jdk/test/java/nio/Buffer/OrderFloat.java	Thu May 19 17:48:02 2016 +0000
+++ b/jdk/test/java/nio/Buffer/OrderFloat.java	Thu May 19 19:46:20 2016 +0000
@@ -52,8 +52,5 @@
         buf = FloatBuffer.allocate(LENGTH);
         ck(buf.order(), nord);
         ckFloatBuffer(buf, nord);
-
-        ckFloatBuffer(ByteBuffer.allocate(LENGTH).asFloatBuffer(), be);
-        ckFloatBuffer(ByteBuffer.allocateDirect(LENGTH).asFloatBuffer(), be);
     }
 }
--- a/jdk/test/java/nio/Buffer/OrderInt.java	Thu May 19 17:48:02 2016 +0000
+++ b/jdk/test/java/nio/Buffer/OrderInt.java	Thu May 19 19:46:20 2016 +0000
@@ -52,8 +52,5 @@
         buf = IntBuffer.allocate(LENGTH);
         ck(buf.order(), nord);
         ckIntBuffer(buf, nord);
-
-        ckIntBuffer(ByteBuffer.allocate(LENGTH).asIntBuffer(), be);
-        ckIntBuffer(ByteBuffer.allocateDirect(LENGTH).asIntBuffer(), be);
     }
 }
--- a/jdk/test/java/nio/Buffer/OrderLong.java	Thu May 19 17:48:02 2016 +0000
+++ b/jdk/test/java/nio/Buffer/OrderLong.java	Thu May 19 19:46:20 2016 +0000
@@ -52,8 +52,5 @@
         buf = LongBuffer.allocate(LENGTH);
         ck(buf.order(), nord);
         ckLongBuffer(buf, nord);
-
-        ckLongBuffer(ByteBuffer.allocate(LENGTH).asLongBuffer(), be);
-        ckLongBuffer(ByteBuffer.allocateDirect(LENGTH).asLongBuffer(), be);
     }
 }
--- a/jdk/test/java/nio/Buffer/OrderShort.java	Thu May 19 17:48:02 2016 +0000
+++ b/jdk/test/java/nio/Buffer/OrderShort.java	Thu May 19 19:46:20 2016 +0000
@@ -52,8 +52,5 @@
         buf = ShortBuffer.allocate(LENGTH);
         ck(buf.order(), nord);
         ckShortBuffer(buf, nord);
-
-        ckShortBuffer(ByteBuffer.allocate(LENGTH).asShortBuffer(), be);
-        ckShortBuffer(ByteBuffer.allocateDirect(LENGTH).asShortBuffer(), be);
     }
 }
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/jdk/test/java/security/SecureRandom/ApiTest.java	Thu May 19 19:46:20 2016 +0000
@@ -0,0 +1,365 @@
+/*
+ * Copyright (c) 2016, 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 8141039
+ * @library /lib/testlibrary
+ * @summary This test do API coverage for SecureRandom. It covers most of
+ *          supported operations along with possible positive and negative
+ *          parameters for DRBG mechanism.
+ * @run main ApiTest Hash_DRBG
+ * @run main ApiTest HMAC_DRBG
+ * @run main ApiTest CTR_DRBG
+ * @run main ApiTest SHA1PRNG
+ * @run main ApiTest NATIVE
+ */
+import java.security.NoSuchAlgorithmException;
+import java.security.SecureRandom;
+import java.security.Security;
+import java.security.SecureRandomParameters;
+import java.security.DrbgParameters;
+import java.security.DrbgParameters.Instantiation;
+import java.security.DrbgParameters.Capability;
+import javax.crypto.Cipher;
+
+public class ApiTest {
+
+    private static final boolean SHOULD_PASS = true;
+    private static final long SEED = 1l;
+    private static final String INVALID_ALGO = "INVALID";
+    private static final String DRBG_CONFIG = "securerandom.drbg.config";
+    private static final String DRBG_CONFIG_VALUE
+            = Security.getProperty(DRBG_CONFIG);
+
+    public static void main(String[] args) throws Exception {
+
+        if (args == null || args.length < 1) {
+            throw new RuntimeException("No mechanism available to run test.");
+        }
+        String mech
+                = "NATIVE".equals(args[0]) ? supportedNativeAlgo() : args[0];
+        String[] algs = null;
+        boolean success = true;
+
+        try {
+            if (!isDRBG(mech)) {
+                SecureRandom random = SecureRandom.getInstance(mech);
+                verifyAPI(random, mech);
+                return;
+            } else if (mech.equals("CTR_DRBG")) {
+                algs = new String[]{"AES-128", "AES-192", "AES-256",
+                    INVALID_ALGO};
+            } else if (mech.equals("Hash_DRBG") || mech.equals("HMAC_DRBG")) {
+                algs = new String[]{"SHA-224", "SHA-256", "SHA-512/224",
+                    "SHA-512/256", "SHA-384", "SHA-512", INVALID_ALGO};
+            } else {
+                throw new RuntimeException(
+                        String.format("Not a valid mechanism '%s'", mech));
+            }
+            runForEachMech(mech, algs);
+        } catch (Exception e) {
+            e.printStackTrace(System.out);
+            success = false;
+        }
+
+        if (!success) {
+            throw new RuntimeException("At least one test failed.");
+        }
+    }
+
+    /**
+     * Run the test for a DRBG mechanism with a possible set of parameter
+     * combination.
+     * @param mech DRBG mechanism name
+     * @param algs Algorithm supported by each mechanism
+     * @throws Exception
+     */
+    private static void runForEachMech(String mech, String[] algs)
+            throws Exception {
+        for (String alg : algs) {
+            runForEachAlg(mech, alg);
+        }
+    }
+
+    private static void runForEachAlg(String mech, String alg)
+            throws Exception {
+        for (int strength : new int[]{Integer.MIN_VALUE, -1, 0, 1, 223, 224,
+            192, 255, 256}) {
+            for (Capability cp : Capability.values()) {
+                for (byte[] pr : new byte[][]{null, new byte[]{},
+                    "personal".getBytes()}) {
+                    SecureRandomParameters param
+                            = DrbgParameters.instantiation(strength, cp, pr);
+                    runForEachParam(mech, alg, param);
+                }
+            }
+        }
+    }
+
+    private static void runForEachParam(String mech, String alg,
+            SecureRandomParameters param) throws Exception {
+
+        for (boolean df : new Boolean[]{true, false}) {
+            try {
+                Security.setProperty(DRBG_CONFIG, mech + "," + alg + ","
+                        + (df ? "use_df" : "no_df"));
+                System.out.printf("%nParameter for SecureRandom "
+                        + "mechanism: %s is (param:%s, algo:%s, df:%s)",
+                        mech, param, alg, df);
+                SecureRandom sr = SecureRandom.getInstance("DRBG", param);
+                verifyAPI(sr, mech);
+            } catch (NoSuchAlgorithmException e) {
+                // Verify exception status for current test.
+                checkException(getDefaultAlg(mech, alg), param, e);
+            } finally {
+                Security.setProperty(DRBG_CONFIG, DRBG_CONFIG_VALUE);
+            }
+        }
+    }
+
+    /**
+     * Returns the algorithm supported for input mechanism.
+     * @param mech Mechanism name
+     * @param alg Algorithm name
+     * @return Algorithm name
+     */
+    private static String getDefaultAlg(String mech, String alg)
+            throws NoSuchAlgorithmException {
+        if (alg == null) {
+            switch (mech) {
+                case "Hash_DRBG":
+                case "HMAC_DRBG":
+                    return "SHA-256";
+                case "CTR_DRBG":
+                    return (Cipher.getMaxAllowedKeyLength("AES") < 256)
+                            ? "AES-128" : "AES-256";
+                default:
+                    throw new RuntimeException("Mechanism not supported");
+            }
+        }
+        return alg;
+    }
+
+    /**
+     * Verify the exception type either it is expected to occur or not.
+     * @param alg Algorithm name
+     * @param param DRBG parameter
+     * @param e Exception to verify
+     * @throws NoSuchAlgorithmException
+     */
+    private static void checkException(String alg, SecureRandomParameters param,
+            NoSuchAlgorithmException e) throws NoSuchAlgorithmException {
+
+        int strength = ((Instantiation) param).getStrength();
+        boolean error = true;
+        switch (alg) {
+            case INVALID_ALGO:
+                error = false;
+                break;
+            case "SHA-224":
+            case "SHA-512/224":
+                if (strength > 192) {
+                    error = false;
+                }
+                break;
+            case "SHA-256":
+            case "SHA-512/256":
+            case "SHA-384":
+            case "SHA-512":
+                if (strength > 256) {
+                    error = false;
+                }
+                break;
+            case "AES-128":
+            case "AES-192":
+            case "AES-256":
+                int algoStrength = Integer.parseInt(alg.replaceAll("AES-", ""));
+                int maxStrengthSupported = Cipher.getMaxAllowedKeyLength("AES");
+                if (strength > maxStrengthSupported
+                        || algoStrength > maxStrengthSupported) {
+                    error = false;
+                }
+                break;
+        }
+        if (error) {
+            throw new RuntimeException("Unknown :", e);
+        }
+    }
+
+    /**
+     * Find if the mechanism is a DRBG mechanism.
+     * @param mech Mechanism name
+     * @return True for DRBG mechanism else False
+     */
+    private static boolean isDRBG(String mech) {
+        return mech.contains("_DRBG");
+    }
+
+    /**
+     * Find the name of supported native mechanism name for current platform.
+     */
+    private static String supportedNativeAlgo() {
+        String nativeSr = "Windows-PRNG";
+        try {
+            SecureRandom.getInstance(nativeSr);
+        } catch (NoSuchAlgorithmException e) {
+            nativeSr = "NativePRNG";
+        }
+        return nativeSr;
+    }
+
+    /**
+     * Test a possible set of SecureRandom API for a SecureRandom instance.
+     * @param random SecureRandom instance
+     * @param mech Mechanism used to create SecureRandom instance
+     */
+    private static void verifyAPI(SecureRandom random, String mech)
+            throws Exception {
+
+        System.out.printf("%nTest SecureRandom mechanism: %s for provider: %s",
+                mech, random.getProvider().getName());
+        byte[] output = new byte[2];
+
+        // Generate random number.
+        random.nextBytes(output);
+
+        // Seed the SecureRandom with a generated seed value of lesser size.
+        byte[] seed = random.generateSeed(1);
+        random.setSeed(seed);
+        random.nextBytes(output);
+
+        // Seed the SecureRandom with a fixed seed value.
+        random.setSeed(SEED);
+        random.nextBytes(output);
+
+        // Seed the SecureRandom with a larger seed value.
+        seed = random.generateSeed(128);
+        random.setSeed(seed);
+        random.nextBytes(output);
+
+        // Additional operation only supported for DRBG based SecureRandom.
+        // Execute the code block and expect to pass for DRBG. If it will fail
+        // then it should fail with specified exception type. Else the case
+        // will be considered as a test case failure.
+        matchExc(() -> {
+            random.reseed();
+            random.nextBytes(output);
+        },
+                isDRBG(mech),
+                UnsupportedOperationException.class,
+                String.format("PASS - Unsupported reseed() method for "
+                        + "SecureRandom Algorithm %s ", mech));
+
+        matchExc(() -> {
+            random.reseed(DrbgParameters.reseed(false, new byte[]{}));
+            random.nextBytes(output);
+        },
+                isDRBG(mech),
+                UnsupportedOperationException.class,
+                String.format("PASS - Unsupported reseed(param) method for "
+                        + "SecureRandom Algorithm %s ", mech));
+
+        matchExc(() -> {
+            random.reseed(DrbgParameters.reseed(true, new byte[]{}));
+            random.nextBytes(output);
+        },
+                isDRBG(mech),
+                !isSupportPR(mech, random) ? IllegalArgumentException.class
+                        : UnsupportedOperationException.class,
+                String.format("PASS - Unsupported or illegal reseed(param) "
+                        + "method for SecureRandom Algorithm %s ", mech));
+
+        matchExc(() -> random.nextBytes(output,
+                DrbgParameters.nextBytes(-1, false, new byte[]{})),
+                isDRBG(mech),
+                UnsupportedOperationException.class,
+                String.format("PASS - Unsupported nextBytes(out, nextByteParam)"
+                        + " method for SecureRandom Algorithm %s ", mech));
+
+        matchExc(() -> random.nextBytes(output,
+                DrbgParameters.nextBytes(-1, true, new byte[]{})),
+                isDRBG(mech),
+                !isSupportPR(mech, random) ? IllegalArgumentException.class
+                        : UnsupportedOperationException.class,
+                String.format("PASS - Unsupported or illegal "
+                        + "nextBytes(out, nextByteParam) method for "
+                        + "SecureRandom Algorithm %s ", mech));
+
+        matchExc(() -> {
+            random.reseed(null);
+            random.nextBytes(output);
+        },
+                !SHOULD_PASS,
+                IllegalArgumentException.class,
+                "PASS - Test is expected to fail when parameter for reseed() "
+                + "is null");
+
+        matchExc(() -> random.nextBytes(output, null),
+                !SHOULD_PASS,
+                IllegalArgumentException.class,
+                "PASS - Test is expected to fail when parameter for nextBytes()"
+                + " is null");
+
+    }
+
+    private static boolean isSupportPR(String mech, SecureRandom random) {
+        return (isDRBG(mech) && ((Instantiation) random.getParameters())
+                .getCapability()
+                .supportsPredictionResistance());
+    }
+
+    private interface RunnableCode {
+
+        void run() throws Exception;
+    }
+
+    /**
+     * Execute a given code block and verify, if the exception type is expected.
+     * @param r Code block to run
+     * @param ex Expected exception type
+     * @param shouldPass If the code execution expected to pass without failure
+     * @param msg Message to log in case of expected failure
+     */
+    private static void matchExc(RunnableCode r, boolean shouldPass, Class ex,
+            String msg) {
+        try {
+            r.run();
+            if (!shouldPass) {
+                throw new RuntimeException("Excecution should fail here.");
+            }
+        } catch (Exception e) {
+            System.out.printf("%nOccured exception: %s - Expected exception: "
+                    + "%s : ", e.getClass(), ex.getCanonicalName());
+            if (ex.isAssignableFrom(e.getClass())) {
+                System.out.printf("%n%s : Expected Exception occured: %s : ",
+                        e.getClass(), msg);
+            } else if (shouldPass) {
+                throw new RuntimeException(e);
+            } else {
+                System.out.printf("Ignore the following exception: %s%n",
+                        e.getMessage());
+            }
+        }
+    }
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/jdk/test/java/security/SecureRandom/EnoughSeedTest.java	Thu May 19 19:46:20 2016 +0000
@@ -0,0 +1,100 @@
+/*
+ * Copyright (c) 2016, 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 8141039
+ * @library /lib/testlibrary
+ * @summary Check SecureRandom generate expected seed counts what the caller
+ *          asked for.
+ * @run main EnoughSeedTest
+ */
+import java.security.SecureRandom;
+import java.security.Security;
+import static java.lang.Math.*;
+
+public class EnoughSeedTest {
+
+    private static final String DRBG_CONFIG = "securerandom.drbg.config";
+    private static final String DRBG_CONFIG_VALUE
+            = Security.getProperty(DRBG_CONFIG);
+
+    public static void main(String[] args) {
+
+        boolean success = true;
+        for (String mech : new String[]{
+            "SHA1PRNG", "Hash_DRBG", "HMAC_DRBG", "CTR_DRBG"}) {
+            System.out.printf("%nTest for SecureRandom algorithm: '%s'", mech);
+            try {
+                SecureRandom sr = null;
+                if (!mech.contains("_DRBG")) {
+                    sr = SecureRandom.getInstance(mech);
+                } else {
+                    Security.setProperty(DRBG_CONFIG, mech);
+                    sr = SecureRandom.getInstance("DRBG");
+                }
+
+                success &= forEachSeedBytes(sr);
+                System.out.printf("%nCompleted test for SecureRandom "
+                        + "mechanism: '%s'", mech);
+            } catch (Exception e) {
+                success &= false;
+                e.printStackTrace(System.out);
+            } finally {
+                Security.setProperty(DRBG_CONFIG, DRBG_CONFIG_VALUE);
+            }
+        }
+        if (!success) {
+            throw new RuntimeException("At least one test failed.");
+        }
+    }
+
+    /**
+     * Generates fixed number of seed bytes through a SecureRandom instance
+     * to verify it's seed generation status.
+     * @param sr SecureRandom instance
+     * @return The test success indicator
+     */
+    private static boolean forEachSeedBytes(SecureRandom sr) {
+        boolean success = true;
+        sr.setSeed(1l);
+        for (int seedByte : new int[]{Integer.MIN_VALUE, -1, 0, 1, 256, 1024,
+            Short.MAX_VALUE, (int) pow(2, 20)}) {
+            try {
+                byte[] seed = sr.generateSeed(seedByte);
+                if (seed.length != seedByte) {
+                    throw new RuntimeException("Not able to produce expected "
+                            + "seed size.");
+                }
+            } catch (IllegalArgumentException e) {
+                if (seedByte >= 0) {
+                    throw new RuntimeException("Unknown Exception occured.", e);
+                }
+                System.out.printf("%nPASS - Exception expected when required "
+                        + "seed size requested is negative: %s", seedByte);
+            }
+        }
+        return success;
+    }
+
+}
--- a/jdk/test/java/security/SecureRandom/GetAlgorithm.java	Thu May 19 17:48:02 2016 +0000
+++ b/jdk/test/java/security/SecureRandom/GetAlgorithm.java	Thu May 19 19:46:20 2016 +0000
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2003, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2003, 2016, Oracle and/or its affiliates. All rights reserved.
  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
  *
  * This code is free software; you can redistribute it and/or modify it
@@ -23,49 +23,54 @@
 
 /**
  * @test
- * @bug 4915392
+ * @bug 4915392 8141039
  * @summary test that the getAlgorithm() method works correctly
  * @author Andreas Sterbenz
+ * @run main GetAlgorithm
  */
-
 import java.io.*;
-
 import java.security.*;
+import java.util.Arrays;
+import java.util.List;
 
 public class GetAlgorithm {
 
-    private final static String BASE = System.getProperty("test.src", ".");
+    private static final String BASE = System.getProperty("test.src", ".");
+    private static final String DRBG_CONFIG = "securerandom.drbg.config";
+    private static final String DRBG_CONFIG_VALUE
+            = Security.getProperty(DRBG_CONFIG);
 
     public static void main(String[] args) throws Exception {
-        SecureRandom sr;
-
-        sr = new SecureRandom();
+        SecureRandom sr = new SecureRandom();
         if (sr.getAlgorithm().equals("unknown")) {
             throw new Exception("Unknown: " + sr.getAlgorithm());
         }
 
-        sr = SecureRandom.getInstance("SHA1PRNG");
-        check("SHA1PRNG", sr);
+        for (String mech : new String[]{supportedNativeAlgo(), "SHA1PRNG",
+            "Hash_DRBG", "HMAC_DRBG", "CTR_DRBG"}) {
+            if (!mech.contains("_DRBG")) {
+                check(mech, SecureRandom.getInstance(mech));
+            } else {
+                try {
+                    Security.setProperty(DRBG_CONFIG, mech);
+                    check("DRBG", SecureRandom.getInstance("DRBG"));
+                } finally {
+                    Security.setProperty(DRBG_CONFIG, DRBG_CONFIG_VALUE);
+                }
+            }
+        }
+        check("unknown", new MySecureRandom());
 
-//      OutputStream out = new FileOutputStream("sha1prng.bin");
-//      ObjectOutputStream oout = new ObjectOutputStream(out);
-//      sr.nextInt();
-//      oout.writeObject(sr);
-//      oout.flush();
-//      oout.close();
-
-        sr = new MySecureRandom();
-        check("unknown", sr);
-
-        InputStream in = new FileInputStream(new File(BASE, "sha1prng-old.bin"));
+        InputStream in = new FileInputStream(
+                new File(BASE, "sha1prng-old.bin"));
         ObjectInputStream oin = new ObjectInputStream(in);
-        sr = (SecureRandom)oin.readObject();
+        sr = (SecureRandom) oin.readObject();
         oin.close();
         check("unknown", sr);
 
         in = new FileInputStream(new File(BASE, "sha1prng-new.bin"));
         oin = new ObjectInputStream(in);
-        sr = (SecureRandom)oin.readObject();
+        sr = (SecureRandom) oin.readObject();
         oin.close();
         check("SHA1PRNG", sr);
 
@@ -83,4 +88,17 @@
 
     }
 
+    /**
+     * Find the name of supported native mechanism name for current platform.
+     */
+    private static String supportedNativeAlgo() {
+        String nativeSr = "Windows-PRNG";
+        try {
+            SecureRandom.getInstance(nativeSr);
+        } catch (NoSuchAlgorithmException e) {
+            nativeSr = "NativePRNG";
+        }
+        return nativeSr;
+    }
+
 }
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/jdk/test/java/security/SecureRandom/GetInstanceTest.java	Thu May 19 19:46:20 2016 +0000
@@ -0,0 +1,312 @@
+/*
+ * Copyright (c) 2016, 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 8141039
+ * @library /lib/testlibrary
+ * @summary SecureRandom supports multiple getInstance method including
+ *          getInstanceStrong() method. This test verifies a set of possible
+ *          cases for getInstance with different SecureRandom mechanism
+ *          supported in Java.
+ * @run main GetInstanceTest
+ */
+import java.security.NoSuchAlgorithmException;
+import java.security.NoSuchProviderException;
+import java.security.SecureRandom;
+import java.security.SecureRandomParameters;
+import java.security.DrbgParameters;
+
+import static java.security.DrbgParameters.Capability.*;
+
+import java.security.Security;
+import java.util.Arrays;
+
+import jdk.testlibrary.Asserts;
+
+public class GetInstanceTest {
+
+    private static final boolean PASS = true;
+    private static final String INVALID_ALGO = "INVALID";
+    private static final String SUN_PROVIDER = "SUN";
+    private static final String INVALID_PROVIDER = "INVALID";
+    private static final String STRONG_ALG_SEC_PROP
+            = "securerandom.strongAlgorithms";
+    private static final String DRBG_CONFIG = "securerandom.drbg.config";
+    private static final String DRBG_CONFIG_VALUE
+            = Security.getProperty(DRBG_CONFIG);
+
+    public static void main(String[] args) throws Exception {
+
+        boolean success = true;
+        // Only accepted failure is NoSuchAlgorithmException.
+        // For any other failure the test case will fail here.
+        SecureRandom sr = matchExc(() -> SecureRandom.getInstanceStrong(),
+                PASS, NoSuchAlgorithmException.class,
+                "PASS - Undefined security Property "
+                + "'securerandom.strongAlgorithms'");
+        System.out.format("Current platform supports mechanism: '%s' through "
+                + "provider: '%s' for the method getInstanceStrong().",
+                sr.getAlgorithm(), sr.getProvider().getName());
+
+        // DRBG name should appear with "securerandom.strongAlgorithms"
+        // security property.
+        String origDRBGConfig = Security.getProperty(STRONG_ALG_SEC_PROP);
+        if (!origDRBGConfig.contains("DRBG")) {
+            throw new RuntimeException("DRBG is not associated with default "
+                    + "strong algorithm through security Property: "
+                    + "'securerandom.strongAlgorithms'.");
+        }
+        Security.setProperty(STRONG_ALG_SEC_PROP, "DRBG:SUN");
+        sr = matchExc(() -> SecureRandom.getInstanceStrong(),
+                PASS, NoSuchAlgorithmException.class,
+                "PASS - Undefined security Property "
+                + "'securerandom.strongAlgorithms'");
+        checkAttributes(sr, "DRBG");
+        Security.setProperty(STRONG_ALG_SEC_PROP, origDRBGConfig);
+
+        for (String mech : new String[]{
+            "SHA1PRNG", "Hash_DRBG", "HMAC_DRBG", "CTR_DRBG", INVALID_ALGO,}) {
+            System.out.printf("%nTest SecureRandom mechanism: '%s'", mech);
+            try {
+                if (isDRBG(mech)) {
+                    Security.setProperty(DRBG_CONFIG, mech);
+                }
+                verifyInstance(mech);
+            } catch (Exception e) {
+                e.printStackTrace(System.out);
+                success = false;
+            } finally {
+                Security.setProperty(DRBG_CONFIG, DRBG_CONFIG_VALUE);
+            }
+        }
+        if (!success) {
+            throw new RuntimeException("At least one test failed.");
+        }
+    }
+
+    private static void verifyInstance(String mech) throws Exception {
+
+        String srAlgo = isDRBG(mech) ? "DRBG" : mech;
+
+        // Test for getInstance(algorithm) method.
+        // It should pass for all case other than invalid algorithm name.
+        // If it fails then the expected exception type should be
+        // NoSuchAlgorithmException. Any other Exception type occured will be
+        // treated as failure.
+        checkAttributes(
+                matchExc(() -> SecureRandom.getInstance(srAlgo), !(nsa(mech)),
+                        NoSuchAlgorithmException.class,
+                        String.format("PASS - It is expected to fail for"
+                                + " getInstance(algorithm) when algorithm: '%s'"
+                                + " is null or invalid.", mech)), mech);
+        // Test for getInstance(algorithm, provider) method.
+        checkAttributes(
+                matchExc(() -> SecureRandom.getInstance(srAlgo,
+                                Security.getProvider(SUN_PROVIDER)),
+                        !(nsa(mech)),
+                        NoSuchAlgorithmException.class,
+                        String.format("PASS - It is expected to fail for"
+                                + " getInstance(algorithm, provider) when"
+                                + " algorithm:'%s' is null or invalid.", mech)),
+                mech);
+        // Test for getInstance(algorithm, providerName) method.
+        checkAttributes(
+                matchExc(() -> SecureRandom.getInstance(srAlgo, SUN_PROVIDER),
+                        !(nsa(mech)), NoSuchAlgorithmException.class,
+                        String.format("PASS - It is expected to fail for "
+                                + "getInstance(algorithm, providerName) when "
+                                + "algorithm: '%s' is null or invalid.", mech)),
+                mech);
+        // Test for getInstance(algorithm, providerName) method.
+        checkAttributes(
+                matchExc(() -> SecureRandom.getInstance(
+                                srAlgo, INVALID_PROVIDER),
+                        !PASS, NoSuchProviderException.class,
+                        String.format("PASS - It is expected to fail for "
+                                + "getInstance(algorithm, providerName) when "
+                                + "provider name: '%s' is invalid and "
+                                + "algorithm: '%s'", INVALID_PROVIDER, mech)),
+                mech);
+
+        // Run the test for a set of SecureRandomParameters
+        for (SecureRandomParameters param : Arrays.asList(null,
+                DrbgParameters.instantiation(-1, NONE, null))) {
+
+            System.out.printf("%nRunning DRBG param getInstance() methods "
+                    + "for algorithm: %s and DRBG param type: %s", mech,
+                    (param != null) ? param.getClass().getName() : param);
+
+            // Following Test are applicable for new DRBG methods only.
+            // Test for getInstance(algorithm, params) method.
+            // Tests are expected to pass for DRBG type with valid parameter
+            // If it fails the expected exception type is derived from
+            // getExcType(mech, param) method. If exception type is not
+            // expected then the test will be considered as failure.
+            checkAttributes(
+                    matchExc(() -> SecureRandom.getInstance(srAlgo, param),
+                            (isDRBG(mech)) && (isValidDRBGParam(param)),
+                            getExcType(mech, param),
+                            String.format("PASS - It is expected to fail "
+                                    + "for getInstance(algorithm, params) "
+                                    + "for algorithm: %s and parameter: %s",
+                                    mech, param)),
+                    mech);
+            // Test for getInstance(algorithm, params, provider) method.
+            checkAttributes(
+                    matchExc(() -> SecureRandom.getInstance(srAlgo, param,
+                                    Security.getProvider(SUN_PROVIDER)),
+                            (isDRBG(mech)) && (isValidDRBGParam(param)),
+                            getExcType(mech, param),
+                            String.format("PASS - It is expected to fail "
+                                    + "for getInstance(algorithm, params, "
+                                    + "provider) for algorithm: %s and "
+                                    + "parameter: %s", mech, param)),
+                    mech);
+            // Test for getInstance(algorithm, params, providerName) method.
+            checkAttributes(
+                    matchExc(() -> SecureRandom.getInstance(srAlgo, param,
+                                    SUN_PROVIDER),
+                            (isDRBG(mech)) && (isValidDRBGParam(param)),
+                            getExcType(mech, param),
+                            String.format("PASS - It is expected to fail "
+                                    + "for getInstance(algorithm, params, "
+                                    + "providerName) for algorithm: %s and "
+                                    + "parameter: %s", mech, param)), mech);
+            // getInstance(algorithm, params, providerName) when
+            // providerName is invalid
+            checkAttributes(
+                    matchExc(() -> SecureRandom.getInstance(srAlgo, param,
+                                    INVALID_PROVIDER),
+                            !PASS, ((param == null)
+                                    ? IllegalArgumentException.class
+                                    : NoSuchProviderException.class),
+                            String.format("PASS - It is expected to fail "
+                                    + "for getInstance(algorithm, params, "
+                                    + "providerName) when param is null or"
+                                    + " provider: %s is invalid for "
+                                    + "algorithm: '%s'", INVALID_PROVIDER,
+                                    mech)), mech);
+            // getInstance(algorithm, params, provider) when provider=null
+            checkAttributes(
+                    matchExc(() -> SecureRandom.getInstance(srAlgo, param,
+                                    (String) null),
+                            !PASS, IllegalArgumentException.class,
+                            String.format("PASS - It is expected to fail "
+                                    + "for getInstance(algorithm, params, "
+                                    + "providerName) when provider name "
+                                    + "is null")), mech);
+            // getInstance(algorithm, params, providerName) when
+            // providerName is empty.
+            checkAttributes(
+                    matchExc(() -> SecureRandom.getInstance(
+                                    srAlgo, param, ""),
+                            !PASS, IllegalArgumentException.class,
+                            String.format("PASS - It is expected to fail "
+                                    + "for getInstance(algorithm, params, "
+                                    + "providerName) when provider name "
+                                    + "is empty")), mech);
+        }
+    }
+
+    private static boolean isValidDRBGParam(SecureRandomParameters param) {
+        return (param instanceof DrbgParameters.Instantiation);
+    }
+
+    /**
+     * If the mechanism should occur NoSuchAlgorithmException.
+     */
+    private static boolean nsa(String mech) {
+        return mech.equals(INVALID_ALGO);
+    }
+
+    /**
+     * Verify if the mechanism is DRBG type.
+     * @param mech Mechanism name
+     * @return True if the mechanism name is DRBG type else False.
+     */
+    private static boolean isDRBG(String mech) {
+        return mech.contains("_DRBG");
+    }
+
+    /**
+     * Type of exception expected for a SecureRandom instance when exception
+     * occurred while calling getInstance method with a fixed set of parameter.
+     * @param mech Mechanism used to create a SecureRandom instance
+     * @param param Parameter to getInstance() method
+     * @return Exception type expected
+     */
+    private static Class getExcType(String mech, SecureRandomParameters param) {
+        return ((isDRBG(mech) && !isValidDRBGParam(param)) || param == null)
+                ? IllegalArgumentException.class
+                : NoSuchAlgorithmException.class;
+    }
+
+    private interface RunnableCode {
+
+        SecureRandom run() throws Exception;
+    }
+
+    /**
+     * Execute a given code block and verify, if the exception type is expected.
+     * @param r Code block to run
+     * @param ex Expected exception type
+     * @param shouldPass If the code execution expected to pass without failure
+     * @param msg Message to log in case of expected failure
+     */
+    private static SecureRandom matchExc(RunnableCode r, boolean shouldPass,
+            Class ex, String msg) {
+        SecureRandom sr = null;
+        try {
+            sr = r.run();
+            if (!shouldPass) {
+                throw new RuntimeException("Excecution should fail here.");
+            }
+        } catch (Exception e) {
+            System.out.printf("%nOccured exception: %s - Expected exception: %s"
+                    + " : ", e.getClass(), ex.getCanonicalName());
+            if (ex.isAssignableFrom(e.getClass())) {
+                System.out.printf("%n%s : Expected Exception: %s : ",
+                        e.getClass(), msg);
+            } else if (shouldPass) {
+                throw new RuntimeException(e);
+            } else {
+                System.out.printf("%nIgnore the following exception: %s%n",
+                        e.getMessage());
+            }
+        }
+        return sr;
+    }
+
+    /**
+     * Check specific attributes of a SecureRandom instance.
+     */
+    private static void checkAttributes(SecureRandom sr, String mech) {
+        if (sr == null) {
+            return;
+        }
+        Asserts.assertEquals(sr.getAlgorithm(), (isDRBG(mech) ? "DRBG" : mech));
+        Asserts.assertEquals(sr.getProvider().getName(), SUN_PROVIDER);
+    }
+
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/jdk/test/java/security/SecureRandom/MultiThreadTest.java	Thu May 19 19:46:20 2016 +0000
@@ -0,0 +1,182 @@
+/*
+ * Copyright (c) 2016, 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.
+ */
+
+import java.math.BigInteger;
+import java.security.NoSuchAlgorithmException;
+import java.security.SecureRandom;
+import java.security.Security;
+import java.util.concurrent.Callable;
+import java.util.concurrent.CompletionService;
+import java.util.concurrent.CountDownLatch;
+import java.util.concurrent.ExecutionException;
+import java.util.concurrent.ExecutorCompletionService;
+import java.util.concurrent.ExecutorService;
+import java.util.concurrent.Executors;
+import java.util.concurrent.ThreadFactory;
+import static java.lang.Math.*;
+
+/*
+ * @test
+ * @bug 8141039
+ * @library /lib/testlibrary
+ * @summary Test behavior of a shared SecureRandom object when it is operated
+ *          by multiple threads concurrently.
+ * @run main MultiThreadTest
+ */
+public class MultiThreadTest {
+
+    private static final byte[] GEN_RND_BYTES = {1};
+    private static final String DRBG_CONFIG = "securerandom.drbg.config";
+    private static final String DRBG_CONFIG_VALUE
+            = Security.getProperty(DRBG_CONFIG);
+
+    private enum SEED {
+
+        NONE, RESEED, SETSEED
+    }
+
+    public static void main(String[] args) {
+
+        boolean success = true;
+        for (int byteLen : GEN_RND_BYTES) {
+            for (SEED reSeed : SEED.values()) {
+                for (String mech : new String[]{
+                    "SHA1PRNG", "Hash_DRBG", "HMAC_DRBG", "CTR_DRBG"}) {
+                    try {
+                        forEachMech(mech, byteLen, reSeed);
+                    } catch (Exception e) {
+                        success = false;
+                        e.printStackTrace(System.out);
+                    } finally {
+                        Security.setProperty(DRBG_CONFIG, DRBG_CONFIG_VALUE);
+                    }
+                }
+            }
+        }
+
+        if (!success) {
+            throw new RuntimeException("At least one test failed.");
+        }
+    }
+
+    /**
+     * Generate a number of threads to fetch random numbers of certain bits
+     * generated through a shared SecureRandom instance.
+     * @param mech Mechanism name
+     * @param byteLen Number of bytes of random number to produce
+     * @param reSeed Call reseed() before generating random numbers
+     * @throws NoSuchAlgorithmException
+     * @throws InterruptedException
+     * @throws ExecutionException
+     */
+    private static void forEachMech(String mech, int byteLen, SEED reSeed)
+            throws NoSuchAlgorithmException, InterruptedException,
+            ExecutionException {
+
+        if ("SHA1PRNG".equals(mech) && SEED.RESEED.equals(reSeed)) {
+            System.out.printf(
+                    "%nreseed() api is not supported for '%s'", mech);
+            return;
+        }
+        System.out.printf("%nTest SecureRandom mechanism: '%s' with support of"
+                + " reseed: '%s'", mech, reSeed);
+        int threadCount = (int) pow(2, 8 * byteLen);
+        System.out.printf("%nCreating %s number of threads to generate secure "
+                + "random numbers concurrently.", threadCount);
+
+        ExecutorService executor
+                = Executors.newCachedThreadPool(new ThreadFactory() {
+                    @Override
+                    public Thread newThread(Runnable r) {
+                        Thread t = Executors.defaultThreadFactory()
+                        .newThread(r);
+                        t.setDaemon(true);
+                        return t;
+                    }
+                });
+        CompletionService<Integer> completionService
+                = new ExecutorCompletionService<Integer>(executor);
+
+        CountDownLatch latch = new CountDownLatch(1);
+        SecureRandom rnd = null;
+        if (!mech.contains("_DRBG")) {
+            rnd = SecureRandom.getInstance(mech);
+        } else {
+            Security.setProperty(DRBG_CONFIG, mech);
+            rnd = SecureRandom.getInstance("DRBG");
+        }
+        try {
+            for (int i = 0; i < threadCount; i++) {
+                completionService.submit(new Task(rnd, latch, byteLen, reSeed));
+            }
+            latch.countDown();
+
+            for (int i = 0; i < threadCount; i++) {
+                completionService.take();
+            }
+        } finally {
+            executor.shutdown();
+        }
+        System.out.printf("%nCompleted Test for algorithm '%s' with thread "
+                + "counts to '%s' using reseeding '%s'",
+                mech, threadCount, reSeed);
+
+    }
+
+    /**
+     * Define a Task to be executed by multiple thread to produce random numbers
+     * from a shared SecureRandom instance.
+     */
+    private static class Task implements Callable<Integer> {
+
+        private final SecureRandom random;
+        private final CountDownLatch latch;
+        private final SEED reSeed;
+        private final int byteSize;
+
+        public Task(SecureRandom random, CountDownLatch latch, int byteSize,
+                SEED reSeed) {
+            this.random = random;
+            this.latch = latch;
+            this.byteSize = byteSize;
+            this.reSeed = reSeed;
+        }
+
+        @Override
+        public Integer call() throws Exception {
+            latch.await();
+            switch (this.reSeed) {
+                case RESEED:
+                    this.random.reseed();
+                    break;
+                case SETSEED:
+                    this.random.setSeed(1l);
+                    break;
+            }
+            byte[] bytes = new byte[byteSize];
+            random.nextBytes(bytes);
+            return new BigInteger(bytes).intValue();
+        }
+    }
+
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/jdk/test/java/security/SecureRandom/SerializedSeedTest.java	Thu May 19 19:46:20 2016 +0000
@@ -0,0 +1,214 @@
+/*
+ * Copyright (c) 2016, 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 8141039
+ * @library /lib/testlibrary
+ * @summary When random number is generated through the a SecureRandom instance
+ *          as well from it's serialized instance in the same time then the
+ *          generated random numbers should be different when one or both are
+ *          reseeded.
+ * @run main SerializedSeedTest
+ */
+import java.io.ByteArrayOutputStream;
+import java.io.IOException;
+import java.io.ObjectInputStream;
+import java.io.ObjectOutputStream;
+import java.io.ByteArrayInputStream;
+import java.security.NoSuchAlgorithmException;
+import java.security.SecureRandom;
+import java.security.Security;
+import jdk.testlibrary.Asserts;
+
+public class SerializedSeedTest {
+
+    private static final byte[] SEED = "seed".getBytes();
+    private static final String DRBG_CONFIG = "securerandom.drbg.config";
+    private static final String DRBG_CONFIG_VALUE
+            = Security.getProperty(DRBG_CONFIG);
+
+    public static void main(String[] args) {
+        boolean success = true;
+
+        for (String mech : new String[]{
+            "SHA1PRNG", "Hash_DRBG", "HMAC_DRBG", "CTR_DRBG"}) {
+            System.out.printf(
+                    "%nRunning test for SecureRandom mechanism: '%s'", mech);
+            try {
+                // Serialize without seed and compare generated random numbers
+                // produced through original and serialized instances.
+                SecureRandom orig = getSRInstance(mech);
+                SecureRandom copy = deserializedCopy(orig);
+                System.out.printf("%nSerialize without seed. Generated random"
+                        + " numbers should be different.");
+                check(orig, copy, false, mech);
+
+                // Serialize after default seed and compare generated random
+                // numbers produced through original and serialized instances.
+                orig = getSRInstance(mech);
+                orig.nextInt(); // Default seeded
+                copy = deserializedCopy(orig);
+                System.out.printf("%nSerialize after default seed. Generated"
+                        + " random numbers should be same till 20-bytes.");
+                check(orig, copy, !isDRBG(mech), mech);
+
+                // Serialize after explicit seed and compare generated random
+                // numbers produced through original and serialized instances.
+                orig = getSRInstance(mech);
+                orig.setSeed(SEED); // Explicitly seeded
+                copy = deserializedCopy(orig);
+                System.out.printf("%nSerialize after explicit seed. Generated "
+                        + "random numbers should be same till 20-bytes.");
+                check(orig, copy, !isDRBG(mech), mech);
+
+                // Serialize without seed but original is explicitly seeded
+                // before generating any random number. Then compare generated
+                // random numbers produced through original and serialized
+                // instances.
+                orig = getSRInstance(mech);
+                copy = deserializedCopy(orig);
+                orig.setSeed(SEED); // Explicitly seeded
+                System.out.printf("%nSerialize without seed. When original is "
+                        + "explicitly seeded before generating random numbers,"
+                        + " Generated random numbers should be different.");
+                check(orig, copy, false, mech);
+
+                // Serialize after default seed but original is explicitly
+                // seeded before generating any random number. Then compare
+                // generated random numbers produced through original and
+                // serialized instances.
+                orig = getSRInstance(mech);
+                orig.nextInt(); // Default seeded
+                copy = deserializedCopy(orig);
+                orig.setSeed(SEED); // Explicitly seeded
+                System.out.printf("%nSerialize after default seed but original "
+                        + "is explicitly seeded before generating random number"
+                        + ". Generated random numbers should be different.");
+                check(orig, copy, false, mech);
+
+                // Serialize after explicit seed but original is explicitly
+                // seeded again before generating random number. Then compare
+                // generated random numbers produced through original and
+                // serialized instances.
+                orig = getSRInstance(mech);
+                orig.setSeed(SEED); // Explicitly seeded
+                copy = deserializedCopy(orig);
+                orig.setSeed(SEED); // Explicitly seeded
+                System.out.printf("%nSerialize after explicit seed but "
+                        + "original is explicitly seeded again before "
+                        + "generating random number. Generated random "
+                        + "numbers should be different.");
+                check(orig, copy, false, mech);
+
+            } catch (Exception e) {
+                e.printStackTrace(System.out);
+                success = false;
+            } finally {
+                Security.setProperty(DRBG_CONFIG, DRBG_CONFIG_VALUE);
+            }
+            System.out.printf("%n------Completed Test for %s------", mech);
+        }
+
+        if (!success) {
+            throw new RuntimeException("At least one test failed.");
+        }
+    }
+
+    /**
+     * Find if the mechanism is a DRBG mechanism.
+     * @param mech Mechanism name
+     * @return True for DRBG mechanism else False
+     */
+    private static boolean isDRBG(String mech) {
+        return mech.contains("_DRBG");
+    }
+
+    /**
+     * Verify the similarity of random numbers generated though both original
+     * as well as deserialized instance.
+     */
+    private static void check(SecureRandom orig, SecureRandom copy,
+            boolean equal, String mech) {
+        int o = orig.nextInt();
+        int c = copy.nextInt();
+        System.out.printf("%nRandom number generated for mechanism: '%s' "
+                + "from original instance as: '%s' and from serialized "
+                + "instance as: '%s'", mech, o, c);
+        if (equal) {
+            Asserts.assertEquals(o, c, mech);
+        } else {
+            Asserts.assertNotEquals(o, c, mech);
+        }
+    }
+
+    /**
+     * Get a copy of SecureRandom instance through deserialization.
+     * @param orig Original SecureRandom instance
+     * @return Deserialized SecureRandom instance
+     * @throws IOException
+     * @throws ClassNotFoundException
+     */
+    private static SecureRandom deserializedCopy(SecureRandom orig)
+            throws IOException, ClassNotFoundException {
+        return deserialize(serialize(orig));
+    }
+
+    /**
+     * Deserialize the SecureRandom object.
+     */
+    private static SecureRandom deserialize(byte[] serialized)
+            throws IOException, ClassNotFoundException {
+        SecureRandom sr = null;
+        try (ByteArrayInputStream bis = new ByteArrayInputStream(serialized);
+                ObjectInputStream ois = new ObjectInputStream(bis)) {
+            sr = (SecureRandom) ois.readObject();
+        }
+        return sr;
+    }
+
+    /**
+     * Serialize the given SecureRandom object.
+     */
+    private static byte[] serialize(SecureRandom sr) throws IOException {
+        try (ByteArrayOutputStream bos = new ByteArrayOutputStream();
+                ObjectOutputStream oos = new ObjectOutputStream(bos)) {
+            oos.writeObject(sr);
+            return bos.toByteArray();
+        }
+    }
+
+    /**
+     * Create a SecureRandom instance for a given mechanism.
+     */
+    private static SecureRandom getSRInstance(String mech)
+            throws NoSuchAlgorithmException {
+        if (!isDRBG(mech)) {
+            return SecureRandom.getInstance(mech);
+        } else {
+            Security.setProperty(DRBG_CONFIG, mech);
+            return SecureRandom.getInstance("DRBG");
+        }
+    }
+
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/jdk/test/java/sql/TEST.properties	Thu May 19 19:46:20 2016 +0000
@@ -0,0 +1,2 @@
+modules = java.sql
+
--- a/jdk/test/java/util/Objects/CheckIndex.java	Thu May 19 17:48:02 2016 +0000
+++ b/jdk/test/java/util/Objects/CheckIndex.java	Thu May 19 19:46:20 2016 +0000
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2015, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2015, 2016 Oracle and/or its affiliates. All rights reserved.
  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
  *
  * This code is free software; you can redistribute it and/or modify it
@@ -23,11 +23,13 @@
 
 /**
  * @test
- * @summary IndexOutOfBoundsException check index tests
+ * @summary Objects.checkIndex/jdk.internal.util.Preconditions.checkIndex tests
  * @run testng CheckIndex
- * @bug 8135248 8142493
+ * @bug 8135248 8142493 8155794
+ * @modules java.base/jdk.internal.util
  */
 
+import jdk.internal.util.Preconditions;
 import org.testng.annotations.DataProvider;
 import org.testng.annotations.Test;
 
@@ -95,7 +97,7 @@
     public void testCheckIndex(int index, int length, boolean withinBounds) {
         String expectedMessage = withinBounds
                                  ? null
-                                 : Objects.outOfBoundsExceptionFormatter(IndexOutOfBoundsException::new).
+                                 : Preconditions.outOfBoundsExceptionFormatter(IndexOutOfBoundsException::new).
                 apply("checkIndex", List.of(index, length)).getMessage();
 
         BiConsumer<Class<? extends RuntimeException>, IntSupplier> checker = (ec, s) -> {
@@ -117,21 +119,21 @@
         };
 
         checker.accept(AssertingOutOfBoundsException.class,
-                     () -> Objects.checkIndex(index, length,
-                                              assertingOutOfBounds(expectedMessage, "checkIndex", index, length)));
+                     () -> Preconditions.checkIndex(index, length,
+                                                    assertingOutOfBounds(expectedMessage, "checkIndex", index, length)));
         checker.accept(IndexOutOfBoundsException.class,
-                     () -> Objects.checkIndex(index, length,
-                                              assertingOutOfBoundsReturnNull("checkIndex", index, length)));
+                     () -> Preconditions.checkIndex(index, length,
+                                                    assertingOutOfBoundsReturnNull("checkIndex", index, length)));
         checker.accept(IndexOutOfBoundsException.class,
-                     () -> Objects.checkIndex(index, length, null));
+                     () -> Preconditions.checkIndex(index, length, null));
         checker.accept(IndexOutOfBoundsException.class,
                      () -> Objects.checkIndex(index, length));
         checker.accept(ArrayIndexOutOfBoundsException.class,
-                     () -> Objects.checkIndex(index, length,
-                                              Objects.outOfBoundsExceptionFormatter(ArrayIndexOutOfBoundsException::new)));
+                     () -> Preconditions.checkIndex(index, length,
+                                                    Preconditions.outOfBoundsExceptionFormatter(ArrayIndexOutOfBoundsException::new)));
         checker.accept(StringIndexOutOfBoundsException.class,
-                     () -> Objects.checkIndex(index, length,
-                                              Objects.outOfBoundsExceptionFormatter(StringIndexOutOfBoundsException::new)));
+                     () -> Preconditions.checkIndex(index, length,
+                                                    Preconditions.outOfBoundsExceptionFormatter(StringIndexOutOfBoundsException::new)));
     }
 
 
@@ -157,7 +159,7 @@
     public void testCheckFromToIndex(int fromIndex, int toIndex, int length, boolean withinBounds) {
         String expectedMessage = withinBounds
                                  ? null
-                                 : Objects.outOfBoundsExceptionFormatter(IndexOutOfBoundsException::new).
+                                 : Preconditions.outOfBoundsExceptionFormatter(IndexOutOfBoundsException::new).
                 apply("checkFromToIndex", List.of(fromIndex, toIndex, length)).getMessage();
 
         BiConsumer<Class<? extends RuntimeException>, IntSupplier> check = (ec, s) -> {
@@ -179,21 +181,21 @@
         };
 
         check.accept(AssertingOutOfBoundsException.class,
-                     () -> Objects.checkFromToIndex(fromIndex, toIndex, length,
-                                                    assertingOutOfBounds(expectedMessage, "checkFromToIndex", fromIndex, toIndex, length)));
+                     () -> Preconditions.checkFromToIndex(fromIndex, toIndex, length,
+                                                          assertingOutOfBounds(expectedMessage, "checkFromToIndex", fromIndex, toIndex, length)));
         check.accept(IndexOutOfBoundsException.class,
-                     () -> Objects.checkFromToIndex(fromIndex, toIndex, length,
-                                                    assertingOutOfBoundsReturnNull("checkFromToIndex", fromIndex, toIndex, length)));
+                     () -> Preconditions.checkFromToIndex(fromIndex, toIndex, length,
+                                                          assertingOutOfBoundsReturnNull("checkFromToIndex", fromIndex, toIndex, length)));
         check.accept(IndexOutOfBoundsException.class,
-                     () -> Objects.checkFromToIndex(fromIndex, toIndex, length, null));
+                     () -> Preconditions.checkFromToIndex(fromIndex, toIndex, length, null));
         check.accept(IndexOutOfBoundsException.class,
                      () -> Objects.checkFromToIndex(fromIndex, toIndex, length));
         check.accept(ArrayIndexOutOfBoundsException.class,
-                     () -> Objects.checkFromToIndex(fromIndex, toIndex, length,
-                                              Objects.outOfBoundsExceptionFormatter(ArrayIndexOutOfBoundsException::new)));
+                     () -> Preconditions.checkFromToIndex(fromIndex, toIndex, length,
+                                                          Preconditions.outOfBoundsExceptionFormatter(ArrayIndexOutOfBoundsException::new)));
         check.accept(StringIndexOutOfBoundsException.class,
-                     () -> Objects.checkFromToIndex(fromIndex, toIndex, length,
-                                              Objects.outOfBoundsExceptionFormatter(StringIndexOutOfBoundsException::new)));
+                     () -> Preconditions.checkFromToIndex(fromIndex, toIndex, length,
+                                                          Preconditions.outOfBoundsExceptionFormatter(StringIndexOutOfBoundsException::new)));
     }
 
 
@@ -226,7 +228,7 @@
     public void testCheckFromIndexSize(int fromIndex, int size, int length, boolean withinBounds) {
         String expectedMessage = withinBounds
                                  ? null
-                                 : Objects.outOfBoundsExceptionFormatter(IndexOutOfBoundsException::new).
+                                 : Preconditions.outOfBoundsExceptionFormatter(IndexOutOfBoundsException::new).
                 apply("checkFromIndexSize", List.of(fromIndex, size, length)).getMessage();
 
         BiConsumer<Class<? extends RuntimeException>, IntSupplier> check = (ec, s) -> {
@@ -248,27 +250,27 @@
         };
 
         check.accept(AssertingOutOfBoundsException.class,
-                     () -> Objects.checkFromIndexSize(fromIndex, size, length,
-                                                      assertingOutOfBounds(expectedMessage, "checkFromIndexSize", fromIndex, size, length)));
+                     () -> Preconditions.checkFromIndexSize(fromIndex, size, length,
+                                                            assertingOutOfBounds(expectedMessage, "checkFromIndexSize", fromIndex, size, length)));
         check.accept(IndexOutOfBoundsException.class,
-                     () -> Objects.checkFromIndexSize(fromIndex, size, length,
-                                                      assertingOutOfBoundsReturnNull("checkFromIndexSize", fromIndex, size, length)));
+                     () -> Preconditions.checkFromIndexSize(fromIndex, size, length,
+                                                            assertingOutOfBoundsReturnNull("checkFromIndexSize", fromIndex, size, length)));
         check.accept(IndexOutOfBoundsException.class,
-                     () -> Objects.checkFromIndexSize(fromIndex, size, length, null));
+                     () -> Preconditions.checkFromIndexSize(fromIndex, size, length, null));
         check.accept(IndexOutOfBoundsException.class,
                      () -> Objects.checkFromIndexSize(fromIndex, size, length));
         check.accept(ArrayIndexOutOfBoundsException.class,
-                     () -> Objects.checkFromIndexSize(fromIndex, size, length,
-                                                    Objects.outOfBoundsExceptionFormatter(ArrayIndexOutOfBoundsException::new)));
+                     () -> Preconditions.checkFromIndexSize(fromIndex, size, length,
+                                                            Preconditions.outOfBoundsExceptionFormatter(ArrayIndexOutOfBoundsException::new)));
         check.accept(StringIndexOutOfBoundsException.class,
-                     () -> Objects.checkFromIndexSize(fromIndex, size, length,
-                                                    Objects.outOfBoundsExceptionFormatter(StringIndexOutOfBoundsException::new)));
+                     () -> Preconditions.checkFromIndexSize(fromIndex, size, length,
+                                                            Preconditions.outOfBoundsExceptionFormatter(StringIndexOutOfBoundsException::new)));
     }
 
     @Test
     public void uniqueMessagesForCheckKinds() {
         BiFunction<String, List<Integer>, IndexOutOfBoundsException> f =
-                Objects.outOfBoundsExceptionFormatter(IndexOutOfBoundsException::new);
+                Preconditions.outOfBoundsExceptionFormatter(IndexOutOfBoundsException::new);
 
         List<String> messages = new ArrayList<>();
         // Exact arguments
--- a/jdk/test/java/util/concurrent/locks/Lock/TimedAcquireLeak.java	Thu May 19 17:48:02 2016 +0000
+++ b/jdk/test/java/util/concurrent/locks/Lock/TimedAcquireLeak.java	Thu May 19 19:46:20 2016 +0000
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2007, 2012, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2007, 2016, 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
@@ -167,7 +167,7 @@
                             final String childPid,
                             final String className) {
         final String regex =
-            "(?m)^ *[0-9]+: +([0-9]+) +[0-9]+ +\\Q"+className+"\\E$";
+            "(?m)^ *[0-9]+: +([0-9]+) +[0-9]+ +\\Q"+className+"\\E(?:$| )";
         final Callable<Integer> objectsInUse =
             new Callable<Integer>() { public Integer call() {
                 Integer i = Integer.parseInt(
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/jdk/test/javax/accessibility/8017112/AccessibleIndexInParentTest.java	Thu May 19 19:46:20 2016 +0000
@@ -0,0 +1,68 @@
+/*
+ * Copyright (c) 2016, 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.
+ */
+
+import java.awt.Component;
+import javax.swing.JLabel;
+import javax.swing.JTabbedPane;
+import javax.swing.SwingUtilities;
+import javax.accessibility.Accessible;
+import javax.accessibility.AccessibleContext;
+/*
+ * @test
+ * @bug 8017112
+ * @summary JTabbedPane components have inconsistent accessibility tree
+ * @run main AccessibleIndexInParentTest
+ */
+
+public class AccessibleIndexInParentTest {
+
+    public static void main(String[] args) throws Exception {
+        SwingUtilities.invokeAndWait(AccessibleIndexInParentTest::test);
+    }
+
+    private static void test() {
+
+        int N = 5;
+        JTabbedPane tabbedPane = new JTabbedPane();
+
+        for (int i = 0; i < N; i++) {
+            tabbedPane.addTab("Title: " + i, new JLabel("Component: " + i));
+        }
+
+        for (int i = 0; i < tabbedPane.getTabCount(); i++) {
+            Component child = tabbedPane.getComponentAt(i);
+
+            AccessibleContext ac = child.getAccessibleContext();
+            if (ac == null) {
+                throw new RuntimeException("Accessible Context is null!");
+            }
+
+            int index = ac.getAccessibleIndexInParent();
+            Accessible parent = ac.getAccessibleParent();
+
+            if (parent.getAccessibleContext().getAccessibleChild(index) != child) {
+                throw new RuntimeException("Wrong getAccessibleIndexInParent!");
+            }
+        }
+    }
+}
\ No newline at end of file
--- a/jdk/test/javax/net/ssl/HttpsURLConnection/Equals.java	Thu May 19 17:48:02 2016 +0000
+++ b/jdk/test/javax/net/ssl/HttpsURLConnection/Equals.java	Thu May 19 19:46:20 2016 +0000
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2014, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2014, 2016, 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
@@ -24,6 +24,7 @@
 /**
  * @test
  * @library /lib/testlibrary
+ * @modules jdk.httpserver
  * @build jdk.testlibrary.SimpleSSLContext
  * @run main Equals
  * @bug 8055299
--- a/jdk/test/javax/net/ssl/ServerName/BestEffortOnLazyConnected.java	Thu May 19 17:48:02 2016 +0000
+++ b/jdk/test/javax/net/ssl/ServerName/BestEffortOnLazyConnected.java	Thu May 19 19:46:20 2016 +0000
@@ -34,9 +34,6 @@
  */
 
 import java.io.*;
-import java.nio.*;
-import java.nio.channels.*;
-import java.util.*;
 import java.net.*;
 import javax.net.ssl.*;
 
@@ -197,6 +194,7 @@
                 hostname);
         // Ignore the test if the hostname does not sound like a domain name.
         if ((hostname == null) || hostname.isEmpty() ||
+                !hostname.contains(".") || hostname.endsWith(".") ||
                 hostname.startsWith("localhost") ||
                 Character.isDigit(hostname.charAt(hostname.length() - 1))) {
 
--- a/jdk/test/javax/net/ssl/TLS/CipherTestUtils.java	Thu May 19 17:48:02 2016 +0000
+++ b/jdk/test/javax/net/ssl/TLS/CipherTestUtils.java	Thu May 19 19:46:20 2016 +0000
@@ -1,5 +1,5 @@
 /**
- * Copyright (c) 2010, 2014, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2010, 2016, 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
@@ -202,6 +202,8 @@
         @Override
         public abstract void run();
 
+        abstract int getPort();
+
         void handleRequest(InputStream in, OutputStream out)
                 throws IOException {
             boolean newline = false;
@@ -528,9 +530,9 @@
         return ks;
     }
 
-    public static void main(PeerFactory peerFactory, String mode,
-            String expectedException)
-            throws Exception {
+    public static int mainServer(PeerFactory peerFactory,
+            String expectedException) throws Exception {
+
         long time = System.currentTimeMillis();
         setTestedArguments(peerFactory.getTestedProtocol(),
                 peerFactory.getTestedCipher());
@@ -540,33 +542,49 @@
         secureRandom.nextInt();
 
         CipherTestUtils cipherTest = CipherTestUtils.getInstance();
-        if (mode.equalsIgnoreCase("Server")) {  // server mode
-            Thread serverThread = new Thread(peerFactory.newServer(cipherTest),
-                    "Server");
-            serverThread.start();
-        } else if (mode.equalsIgnoreCase("Client")) {
-            peerFactory.newClient(cipherTest).run();
-            cipherTest.checkResult(expectedException);
-            JSSEServer.closeServer = true;
-        } else {
-            throw new RuntimeException("unsupported mode");
-        }
+        Server server = peerFactory.newServer(cipherTest, PeerFactory.FREE_PORT);
+        Thread serverThread = new Thread(server, "Server");
+        serverThread.start();
+
         time = System.currentTimeMillis() - time;
         System.out.println("Elapsed time " + time);
 
+        return server.getPort();
+    }
+
+    public static void mainClient(PeerFactory peerFactory, int port,
+            String expectedException) throws Exception {
+
+        long time = System.currentTimeMillis();
+        setTestedArguments(peerFactory.getTestedProtocol(),
+                peerFactory.getTestedCipher());
+
+        System.out.print(
+                " Initializing test '" + peerFactory.getName() + "'...");
+        secureRandom.nextInt();
+
+        CipherTestUtils cipherTest = CipherTestUtils.getInstance();
+        peerFactory.newClient(cipherTest, port).run();
+        cipherTest.checkResult(expectedException);
+        JSSEServer.closeServer = true;
+
+        time = System.currentTimeMillis() - time;
+        System.out.println("Elapsed time " + time);
     }
 
     public static abstract class PeerFactory {
 
+        public static final int FREE_PORT = 0;
+
         abstract String getName();
 
         abstract String getTestedProtocol();
 
         abstract String getTestedCipher();
 
-        abstract Client newClient(CipherTestUtils cipherTest) throws Exception;
+        abstract Client newClient(CipherTestUtils cipherTest, int testPort) throws Exception;
 
-        abstract Server newServer(CipherTestUtils cipherTest) throws Exception;
+        abstract Server newServer(CipherTestUtils cipherTest, int testPort) throws Exception;
 
         boolean isSupported(String cipherSuite) {
             return true;
--- a/jdk/test/javax/net/ssl/TLS/JSSEServer.java	Thu May 19 17:48:02 2016 +0000
+++ b/jdk/test/javax/net/ssl/TLS/JSSEServer.java	Thu May 19 19:46:20 2016 +0000
@@ -1,5 +1,5 @@
 /**
- * Copyright (c) 2010, 2014, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2010, 2016, 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
@@ -77,4 +77,8 @@
             }
         }
     }
+
+    int getPort() {
+        return serverSocket.getLocalPort();
+    }
 }
--- a/jdk/test/javax/net/ssl/TLS/TestJSSE.java	Thu May 19 17:48:02 2016 +0000
+++ b/jdk/test/javax/net/ssl/TLS/TestJSSE.java	Thu May 19 19:46:20 2016 +0000
@@ -27,10 +27,8 @@
 /**
  * @test
  * @bug 8049429
- * @library ../../../../lib/testlibrary/
  * @modules java.management
  *          jdk.crypto.ec/sun.security.ec
- * @build jdk.testlibrary.Utils
  * @compile CipherTestUtils.java JSSEClient.java JSSEServer.java
  * @summary Test that all cipher suites work in all versions and all client
  * authentication types. The way this is setup the server is stateless and
@@ -86,7 +84,6 @@
 
         String serverProtocol = System.getProperty("SERVER_PROTOCOL");
         String clientProtocol = System.getProperty("CLIENT_PROTOCOL");
-        int port = jdk.testlibrary.Utils.getFreePort();
         String cipher = System.getProperty("CIPHER");
         if (serverProtocol == null
                 || clientProtocol == null
@@ -97,7 +94,7 @@
         out.println("ServerProtocol =" + serverProtocol);
         out.println("ClientProtocol =" + clientProtocol);
         out.println("Cipher         =" + cipher);
-        server(serverProtocol, cipher, port, args);
+        int port = server(serverProtocol, cipher, args);
         client(port, clientProtocol, cipher, args);
 
     }
@@ -112,28 +109,30 @@
         out.println(" Testing - Protocol : " + testProtocols);
         out.println(" Testing - Cipher : " + testCipher);
         try {
-            CipherTestUtils.main(new JSSEFactory(LOCAL_IP,
-                    testPort, testProtocols,
-                    testCipher, "client JSSE"),
-                    "client", expectedException);
+            CipherTestUtils.mainClient(new JSSEFactory(LOCAL_IP, testProtocols,
+                        testCipher, "Client JSSE"),
+                    testPort, expectedException);
         } catch (Exception e) {
             throw new RuntimeException(e);
         }
     }
 
-    public static void server(String testProtocol, String testCipher,
-            int testPort,
+    public static int server(String testProtocol, String testCipher,
             String... exception) throws Exception {
+
         String expectedException = exception.length >= 1
                 ? exception[0] : null;
         out.println(" This is Server");
         out.println(" Testing Protocol: " + testProtocol);
         out.println(" Testing Cipher: " + testCipher);
-        out.println(" Testing Port: " + testPort);
+
         try {
-            CipherTestUtils.main(new JSSEFactory(null, testPort,
-                    testProtocol, testCipher, "Server JSSE"),
-                    "Server", expectedException);
+            int port = CipherTestUtils.mainServer(new JSSEFactory(
+                        null, testProtocol, testCipher, "Server JSSE"),
+                    expectedException);
+
+            out.println(" Testing Port: " + port);
+            return port;
         } catch (Exception e) {
             throw new RuntimeException(e);
         }
@@ -142,15 +141,13 @@
     private static class JSSEFactory extends CipherTestUtils.PeerFactory {
 
         final String testedCipherSuite, testedProtocol, testHost;
-        final int testPort;
         final String name;
 
-        JSSEFactory(String testHost, int testPort, String testedProtocol,
+        JSSEFactory(String testHost, String testedProtocol,
                 String testedCipherSuite, String name) {
             this.testedCipherSuite = testedCipherSuite;
             this.testedProtocol = testedProtocol;
             this.testHost = testHost;
-            this.testPort = testPort;
             this.name = name;
         }
 
@@ -170,14 +167,14 @@
         }
 
         @Override
-        CipherTestUtils.Client newClient(CipherTestUtils cipherTest)
+        CipherTestUtils.Client newClient(CipherTestUtils cipherTest, int testPort)
                 throws Exception {
             return new JSSEClient(cipherTest, testHost, testPort,
                     testedProtocol, testedCipherSuite);
         }
 
         @Override
-        CipherTestUtils.Server newServer(CipherTestUtils cipherTest)
+        CipherTestUtils.Server newServer(CipherTestUtils cipherTest, int testPort)
                 throws Exception {
             return new JSSEServer(cipherTest, testPort,
                     testedProtocol, testedCipherSuite);
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/jdk/test/javax/net/ssl/etc/README	Thu May 19 19:46:20 2016 +0000
@@ -0,0 +1,94 @@
+Keystores used for the JSSE regression test suite.
+
+keystore
+truststore
+==========
+
+These are the primary two keystores and contain entries for testing most
+of the JSSE regression test files.  There are three entries, one RSA-based,
+one DSA-based and one EC-based.  If they expire, simply recreate them
+using keytool and most of the test cases should work.
+
+The password on both files is:
+
+    passphrase
+
+There are no individual key entry passwords at this time.
+
+
+keystore entries
+================
+
+Alias name: dummy
+-----------------
+Creation date: May 16, 2016
+Entry type: PrivateKeyEntry
+Certificate chain length: 1
+Certificate[1]:
+Owner: CN=dummy.example.com, OU=Dummy, O=Dummy, L=Cupertino, ST=CA, C=US
+Issuer: CN=dummy.example.com, OU=Dummy, O=Dummy, L=Cupertino, ST=CA, C=US
+Serial number: 57399b87
+Valid from: Mon May 16 10:06:38 UTC 2016 until: Sat May 16 10:06:38 UTC 2026
+Signature algorithm name: SHA256withRSA
+Version: 1
+
+This can be generated using hacked (update the keytool source code so that
+it can be used for version 1 X.509 certificate) keytool command:
+% keytool -genkeypair -alias dummy -keyalg RSA -keysize 2048 \
+  -sigalg SHA256withRSA \
+  -dname "CN=dummy.example.com, OU=Dummy, O=Dummy, L=Cupertino, ST=CA, C=US" \
+  -validity 3652 -keypass passphrase -keystore keystore -storepass passphrase
+
+
+Alias name: dummyecdsa
+----------------------
+Creation date: May 16, 2016
+Entry type: PrivateKeyEntry
+Certificate chain length: 1
+Certificate[1]:
+Owner: CN=dummy.example.com, OU=Dummy, O=Dummy, L=Cupertino, ST=CA, C=US
+Issuer: CN=dummy.example.com, OU=Dummy, O=Dummy, L=Cupertino, ST=CA, C=US
+Serial number: 57399c1d
+Valid from: Mon May 16 10:09:01 UTC 2016 until: Sat May 16 10:09:01 UTC 2026
+Signature algorithm name: SHA256withECDSA
+Version: 1
+
+This can be generated using hacked (update the keytool source code so that
+it can be used for version 1 X.509 certificate) keytool command:
+% keytool -genkeypair -alias dummy -keyalg EC -keysize 256 \
+  -sigalg SHA256withECDSA \
+  -dname "CN=dummy.example.com, OU=Dummy, O=Dummy, L=Cupertino, ST=CA, C=US" \
+  -validity 3652 -keypass passphrase -keystore keystore -storepass passphrase
+
+Alias name: dummydsa
+--------------------
+Creation date: Mar 11, 2007
+Entry type: PrivateKeyEntry
+Certificate chain length: 1
+Certificate[1]:
+Owner: CN=dummy.example.com, OU=Dummy, O=Dummy, L=Cupertino, ST=CA, C=US
+Issuer: CN=dummy.example.com, OU=Dummy, O=Dummy, L=Cupertino, ST=CA, C=US
+Serial number: 45f3a314
+Valid from: Sun Mar 11 06:35:00 UTC 2007 until: Wed Mar 08 06:35:00 UTC 2017
+Certificate fingerprints:
+Signature algorithm name: SHA1withDSA
+Version: 1
+
+This can be generated using hacked (update the keytool source code so that
+it can be used for version 1 X.509 certificate) keytool command:
+% keytool -genkeypair -alias dummy -keyalg DSA -keysize 1024 \
+  -sigalg SHA1withDSA \
+  -dname "CN=dummy.example.com, OU=Dummy, O=Dummy, L=Cupertino, ST=CA, C=US" \
+  -validity 3652 -keypass passphrase -keystore keystore -storepass passphrase
+
+
+truststore entries
+==================
+This key store contains only trusted certificate entries.  The same
+certificates are used in both keystore and truststore.
+
+
+unknown_keystore
+================
+A keystore you can use when you don't want things to be verified.
+Use this with keystore/truststore, and you'll never get a match.
Binary file jdk/test/javax/net/ssl/etc/keystore has changed
Binary file jdk/test/javax/net/ssl/etc/truststore has changed
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/jdk/test/javax/rmi/TEST.properties	Thu May 19 19:46:20 2016 +0000
@@ -0,0 +1,1 @@
+modules = java.rmi
--- a/jdk/test/javax/script/ProviderTest.sh	Thu May 19 17:48:02 2016 +0000
+++ b/jdk/test/javax/script/ProviderTest.sh	Thu May 19 19:46:20 2016 +0000
@@ -43,8 +43,18 @@
     -C ${TESTCLASSES} DummyScriptEngineFactory.class \
     -C "${TESTSRC}" META-INF/services/javax.script.ScriptEngineFactory
 
-echo "Running test ..."
+echo "Running test with security manager ..."
+$JAVA ${TESTVMOPTS} -Djava.security.manager -classpath \
+  "${TESTCLASSES}${PS}${TESTCLASSES}/dummy.jar" \
+  ProviderTest
 
+ret=$?
+if [ $ret -ne 0 ]
+then
+  exit $ret
+fi
+
+echo "Running test without security manager ..."
 $JAVA ${TESTVMOPTS} -classpath \
   "${TESTCLASSES}${PS}${TESTCLASSES}/dummy.jar" \
   ProviderTest
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/jdk/test/javax/script/TEST.properties	Thu May 19 19:46:20 2016 +0000
@@ -0,0 +1,1 @@
+modules = java.scripting
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/jdk/test/javax/sound/sampled/spi/AudioFileReader/RecognizeHugeAiffFiles.java	Thu May 19 19:46:20 2016 +0000
@@ -0,0 +1,247 @@
+/*
+ * Copyright (c) 2016, 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.
+ */
+
+import java.io.ByteArrayInputStream;
+
+import javax.sound.sampled.AudioFileFormat;
+import javax.sound.sampled.AudioFormat;
+import javax.sound.sampled.AudioInputStream;
+import javax.sound.sampled.AudioSystem;
+
+/**
+ * @test
+ * @bug 6729836
+ */
+public final class RecognizeHugeAiffFiles {
+
+    /**
+     * The maximum number of sample frames per AIFF specification.
+     */
+    private static final /* unsigned int */ long MAX_UNSIGNED_INT = 0xffffffffL;
+
+    /**
+     * The supported aiff sample size in bits.
+     */
+    private static final byte[] aiffBits = {
+            1, 2, 4, 8, 11, 16, 20, 24, 27, 32
+    };
+
+    /**
+     * The list of supported sample rates.
+     */
+    private static final int[] sampleRates = {
+            8000, 11025, 16000, 22050, 32000, 37800, 44056, 44100, 47250, 48000,
+            50000, 50400, 88200, 96000, 176400, 192000, 352800, 2822400,
+            5644800, Integer.MAX_VALUE
+    };
+
+    /**
+     * The list of supported channels.
+     */
+    private static final int[] channels = {
+            1, 2, 3, 4, 5, 6, 7, 8, 9, 10
+    };
+
+    /**
+     * The list of supported number of frames.
+     * <p>
+     * The {@code MAX_UNSIGNED_INT} is a maximum.
+     */
+    private static final long[] numberOfFrames = {
+            0, 1, 2, 3, Integer.MAX_VALUE - 1, Integer.MAX_VALUE,
+            (long) Integer.MAX_VALUE + 1, MAX_UNSIGNED_INT - 1, MAX_UNSIGNED_INT
+    };
+
+    public static void main(final String[] args) throws Exception {
+        for (final byte bits : aiffBits) {
+            for (final int sampleRate : sampleRates) {
+                for (final int channel : channels) {
+                    for (final long dataSize : numberOfFrames) {
+                        testAFF(bits, sampleRate, channel, dataSize);
+                        testAIS(bits, sampleRate, channel, dataSize);
+                    }
+                }
+            }
+        }
+    }
+
+    /**
+     * Tests the {@code AudioFileFormat} fetched from the fake header.
+     * <p>
+     * Note that the frameLength and byteLength are stored as int which means
+     * that {@code AudioFileFormat} will store the data above {@code MAX_INT} as
+     * NOT_SPECIFIED.
+     */
+    private static void testAFF(final byte bits, final int rate,
+                                final int channel, final long frameLength)
+            throws Exception {
+        final byte[] header = createHeader(bits, rate, channel, frameLength);
+        final ByteArrayInputStream fake = new ByteArrayInputStream(header);
+        final AudioFileFormat aff = AudioSystem.getAudioFileFormat(fake);
+
+        if (aff.getType() != AudioFileFormat.Type.AIFF) {
+            throw new RuntimeException("Error");
+        }
+
+        if (frameLength <= Integer.MAX_VALUE) {
+            if (aff.getFrameLength() != frameLength) {
+                System.err.println("Expected: " + frameLength);
+                System.err.println("Actual: " + aff.getFrameLength());
+                throw new RuntimeException();
+            }
+        } else {
+            if (aff.getFrameLength() != AudioSystem.NOT_SPECIFIED) {
+                System.err.println("Expected: " + AudioSystem.NOT_SPECIFIED);
+                System.err.println("Actual: " + aff.getFrameLength());
+                throw new RuntimeException();
+            }
+        }
+        validateFormat(bits, rate, channel, aff.getFormat());
+    }
+
+    /**
+     * Tests the {@code AudioInputStream} fetched from the fake header.
+     * <p>
+     * Note that the frameLength is stored as long which means that {@code
+     * AudioInputStream} must store all possible data from aiff file.
+     */
+    private static void testAIS(final byte bits, final int rate,
+                                final int channel, final long frameLength)
+            throws Exception {
+        final byte[] header = createHeader(bits, rate, channel, frameLength);
+        final ByteArrayInputStream fake = new ByteArrayInputStream(header);
+        final AudioInputStream ais = AudioSystem.getAudioInputStream(fake);
+        final AudioFormat format = ais.getFormat();
+
+        if (frameLength != ais.getFrameLength()) {
+            System.err.println("Expected: " + frameLength);
+            System.err.println("Actual: " + ais.getFrameLength());
+            throw new RuntimeException();
+        }
+        if (ais.available() < 0) {
+            System.err.println("available should be >=0: " + ais.available());
+            throw new RuntimeException();
+        }
+
+        validateFormat(bits, rate, channel, format);
+    }
+
+    /**
+     * Tests that format contains the same data as were provided to the fake
+     * stream.
+     */
+    private static void validateFormat(final byte bits, final int rate,
+                                       final int channel,
+                                       final AudioFormat format) {
+
+        if (Float.compare(format.getSampleRate(), rate) != 0) {
+            System.err.println("Expected: " + rate);
+            System.err.println("Actual: " + format.getSampleRate());
+            throw new RuntimeException();
+        }
+        if (format.getChannels() != channel) {
+            System.err.println("Expected: " + channel);
+            System.err.println("Actual: " + format.getChannels());
+            throw new RuntimeException();
+        }
+        int frameSize = ((bits + 7) / 8) * channel;
+        if (format.getFrameSize() != frameSize) {
+            System.out.println("Expected: " + frameSize);
+            System.err.println("Actual: " + format.getFrameSize());
+            throw new RuntimeException();
+        }
+    }
+
+    private static final int DOUBLE_MANTISSA_LENGTH = 52;
+    private static final int DOUBLE_EXPONENT_LENGTH = 11;
+    private static final long DOUBLE_SIGN_MASK     = 0x8000000000000000L;
+    private static final long DOUBLE_EXPONENT_MASK = 0x7FF0000000000000L;
+    private static final long DOUBLE_MANTISSA_MASK = 0x000FFFFFFFFFFFFFL;
+    private static final int DOUBLE_EXPONENT_OFFSET = 1023;
+
+    private static final int EXTENDED_EXPONENT_OFFSET = 16383;
+    private static final int EXTENDED_MANTISSA_LENGTH = 63;
+    private static final int EXTENDED_EXPONENT_LENGTH = 15;
+    private static final long EXTENDED_INTEGER_MASK = 0x8000000000000000L;
+
+    /**
+     * Creates the custom header of the AIFF file. It is expected that all
+     * passed data are supported.
+     */
+    private static byte[] createHeader(final byte bits, final int rate,
+                                       final int channel, final long frameLength) {
+        long doubleBits = Double.doubleToLongBits(rate);
+
+        long sign = (doubleBits & DOUBLE_SIGN_MASK)
+                >> (DOUBLE_EXPONENT_LENGTH + DOUBLE_MANTISSA_LENGTH);
+        long doubleExponent = (doubleBits & DOUBLE_EXPONENT_MASK)
+                >> DOUBLE_MANTISSA_LENGTH;
+        long doubleMantissa = doubleBits & DOUBLE_MANTISSA_MASK;
+
+        long extendedExponent = doubleExponent - DOUBLE_EXPONENT_OFFSET
+                + EXTENDED_EXPONENT_OFFSET;
+        long extendedMantissa = doubleMantissa
+                << (EXTENDED_MANTISSA_LENGTH - DOUBLE_MANTISSA_LENGTH);
+        long extendedSign = sign << EXTENDED_EXPONENT_LENGTH;
+        short extendedBits79To64 = (short) (extendedSign | extendedExponent);
+        long extendedBits63To0 = EXTENDED_INTEGER_MASK | extendedMantissa;
+
+        return new byte[]{
+                // AIFF_MAGIC
+                0x46, 0x4f, 0x52, 0x4d,
+                // fileLength (will use the number of frames for testing)
+                (byte) (frameLength >> 24), (byte) (frameLength >> 16),
+                (byte) (frameLength >> 8), (byte) frameLength,
+                //  form aiff
+                0x41, 0x49, 0x46, 0x46,
+                // COMM_MAGIC
+                0x43, 0x4f, 0x4d, 0x4d,
+                // comm chunk size
+                0, 0, 0, 18,
+                // channels
+                (byte) (channel >> 8),(byte) channel,
+                // numSampleFrames
+                (byte) (frameLength >> 24), (byte) (frameLength >> 16),
+                (byte) (frameLength >> 8), (byte) (frameLength),
+                // samplesize
+                (byte) (bits >> 8),(byte) (bits),
+                // samplerate
+                (byte) (extendedBits79To64 >> 8),
+                (byte) extendedBits79To64,
+                (byte) (extendedBits63To0 >> 56),
+                (byte) (extendedBits63To0 >> 48),
+                (byte) (extendedBits63To0 >> 40),
+                (byte) (extendedBits63To0 >> 32), (byte) (extendedBits63To0 >> 24),
+                (byte) (extendedBits63To0 >> 16), (byte) (extendedBits63To0 >> 8),
+                (byte) extendedBits63To0,
+                // SND_MAGIC
+                0x53, 0x53, 0x4e, 0x44,
+                // data chunk size
+                0, 0, 0, 0,
+                // dataOffset
+                0, 0, 0, 0,
+                // blocksize
+                0, 0, 0, 0,
+        };
+    }
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/jdk/test/javax/sound/sampled/spi/AudioFileReader/RecognizeHugeAuFiles.java	Thu May 19 19:46:20 2016 +0000
@@ -0,0 +1,232 @@
+/*
+ * Copyright (c) 2016, 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.
+ */
+
+import java.io.ByteArrayInputStream;
+
+import javax.sound.sampled.AudioFileFormat;
+import javax.sound.sampled.AudioFormat;
+import javax.sound.sampled.AudioInputStream;
+import javax.sound.sampled.AudioSystem;
+
+/**
+ * @test
+ * @bug 6729836
+ */
+public final class RecognizeHugeAuFiles {
+
+    /**
+     * The size of the header's data.
+     */
+    private static final byte AU_HEADER = 44;
+
+    /**
+     * This value should be used if the size in bytes is unknown.
+     */
+    private static final /* unsigned int */ long MAX_UNSIGNED_INT = 0xffffffffL;
+
+    /**
+     * The list of supported au formats and sample size in bits per format.
+     */
+    private static final byte[][] auTypeBits = {
+            {1, 8}, {2, 8}, {3, 16}, {4, 24}, {5, 32}, {6, 32}, {27, 8}
+    };
+
+    /**
+     * The list of supported sample rates(stored as unsigned int).
+     */
+    private static final int[] sampleRates = {
+            8000, 11025, 16000, 22050, 32000, 37800, 44056, 44100, 47250, 48000,
+            50000, 50400, 88200, 96000, 176400, 192000, 352800, 2822400,
+            5644800, Integer.MAX_VALUE
+    };
+
+    /**
+     * The list of supported channels (stored as unsigned int).
+     */
+    private static final int[] channels = {
+            1, 2, 3, 4, 5, 6, 7, 8, 9, 10
+    };
+
+    /**
+     * The list of supported size of data (stored as unsigned int).
+     * <p>
+     * The {@code MAX_UNSIGNED_INT} used if the size in bytes is unknown.
+     */
+    private static final long[] dataSizes = {
+            0, 1, 2, 3, Integer.MAX_VALUE - AU_HEADER, Integer.MAX_VALUE - 1,
+            Integer.MAX_VALUE, (long) Integer.MAX_VALUE + 1,
+            (long) Integer.MAX_VALUE + AU_HEADER, MAX_UNSIGNED_INT - AU_HEADER,
+            MAX_UNSIGNED_INT - 1, MAX_UNSIGNED_INT
+    };
+
+    public static void main(final String[] args) throws Exception {
+        for (final byte[] type : auTypeBits) {
+            for (final int sampleRate : sampleRates) {
+                for (final int channel : channels) {
+                    for (final long dataSize : dataSizes) {
+                        testAFF(type, sampleRate, channel, dataSize);
+                        testAIS(type, sampleRate, channel, dataSize);
+                    }
+                }
+            }
+        }
+    }
+
+    /**
+     * Tests the {@code AudioFileFormat} fetched from the fake header.
+     * <p>
+     * Note that the frameLength and byteLength are stored as int which means
+     * that {@code AudioFileFormat} will store the data above {@code  MAX_INT}
+     * as NOT_SPECIFIED.
+     */
+    private static void testAFF(final byte[] type, final int rate,
+                                final int channel, final long size)
+            throws Exception {
+        final byte[] header = createHeader(type, rate, channel, size);
+        final ByteArrayInputStream fake = new ByteArrayInputStream(header);
+        final AudioFileFormat aff = AudioSystem.getAudioFileFormat(fake);
+        final AudioFormat format = aff.getFormat();
+
+        if (aff.getType() != AudioFileFormat.Type.AU) {
+            throw new RuntimeException("Error");
+        }
+
+        final long frameLength = size / format.getFrameSize();
+        if (size != MAX_UNSIGNED_INT && frameLength <= Integer.MAX_VALUE) {
+            if (aff.getFrameLength() != frameLength) {
+                System.err.println("Expected: " + frameLength);
+                System.err.println("Actual: " + aff.getFrameLength());
+                throw new RuntimeException();
+            }
+        } else {
+            if (aff.getFrameLength() != AudioSystem.NOT_SPECIFIED) {
+                System.err.println("Expected: " + AudioSystem.NOT_SPECIFIED);
+                System.err.println("Actual: " + aff.getFrameLength());
+                throw new RuntimeException();
+            }
+        }
+
+        final long byteLength = size + AU_HEADER;
+        if (byteLength <= Integer.MAX_VALUE) {
+            if (aff.getByteLength() != byteLength) {
+                System.err.println("Expected: " + byteLength);
+                System.err.println("Actual: " + aff.getByteLength());
+                throw new RuntimeException();
+            }
+        } else {
+            if (aff.getByteLength() != AudioSystem.NOT_SPECIFIED) {
+                System.err.println("Expected: " + AudioSystem.NOT_SPECIFIED);
+                System.err.println("Actual: " + aff.getByteLength());
+                throw new RuntimeException();
+            }
+        }
+        validateFormat(type[1], rate, channel, aff.getFormat());
+    }
+
+    /**
+     * Tests the {@code AudioInputStream} fetched from the fake header.
+     * <p>
+     * Note that the frameLength is stored as long which means
+     * that {@code AudioInputStream} must store all possible data from au file.
+     */
+    private static void testAIS(final byte[] type, final int rate,
+                                final int channel, final long size)
+            throws Exception {
+        final byte[] header = createHeader(type, rate, channel, size);
+        final ByteArrayInputStream fake = new ByteArrayInputStream(header);
+        final AudioInputStream ais = AudioSystem.getAudioInputStream(fake);
+        final AudioFormat format = ais.getFormat();
+        final long frameLength = size / format.getFrameSize();
+        if (size != MAX_UNSIGNED_INT) {
+            if (frameLength != ais.getFrameLength()) {
+                System.err.println("Expected: " + frameLength);
+                System.err.println("Actual: " + ais.getFrameLength());
+                throw new RuntimeException();
+            }
+        } else {
+            if (ais.getFrameLength() != AudioSystem.NOT_SPECIFIED) {
+                System.err.println("Expected: " + AudioSystem.NOT_SPECIFIED);
+                System.err.println("Actual: " + ais.getFrameLength());
+                throw new RuntimeException();
+            }
+        }
+        if (ais.available() < 0) {
+            System.err.println("available should be >=0: " + ais.available());
+            throw new RuntimeException();
+        }
+        validateFormat(type[1], rate, channel, format);
+    }
+
+    /**
+     * Tests that format contains the same data as were provided to the fake
+     * stream.
+     */
+    private static void validateFormat(final byte bits, final int rate,
+                                       final int channel,
+                                       final AudioFormat format) {
+
+        if (Float.compare(format.getSampleRate(), rate) != 0) {
+            System.out.println("Expected: " + rate);
+            System.out.println("Actual: " + format.getSampleRate());
+            throw new RuntimeException();
+        }
+        if (format.getChannels() != channel) {
+            System.out.println("Expected: " + channel);
+            System.out.println("Actual: " + format.getChannels());
+            throw new RuntimeException();
+        }
+        int frameSize = ((bits + 7) / 8) * channel;
+        if (format.getFrameSize() != frameSize) {
+            System.out.println("Expected: " + frameSize);
+            System.out.println("Actual: " + format.getFrameSize());
+            throw new RuntimeException();
+        }
+    }
+
+    /**
+     * Creates the custom header of the AU file. It is expected that all passed
+     * data are supported.
+     */
+    private static byte[] createHeader(final byte[] type, final int rate,
+                                       final int channel, final long size) {
+        return new byte[]{
+                // AU_SUN_MAGIC
+                0x2e, 0x73, 0x6e, 0x64,
+                // headerSize
+                0, 0, 0, AU_HEADER,
+                // dataSize
+                (byte) (size >> 24), (byte) (size >> 16), (byte) (size >> 8),
+                (byte) size,
+                // encoding
+                0, 0, 0, type[0],
+                // sampleRate
+                (byte) (rate >> 24), (byte) (rate >> 16), (byte) (rate >> 8),
+                (byte) (rate),
+                // channels
+                (byte) (channel >> 24), (byte) (channel >> 16),
+                (byte) (channel >> 8), (byte) (channel),
+                // data
+                0, 0, 0, 0, 0, 0
+        };
+    }
+}
--- a/jdk/test/javax/sound/sampled/spi/AudioFileReader/RecognizeHugeWaveExtFiles.java	Thu May 19 17:48:02 2016 +0000
+++ b/jdk/test/javax/sound/sampled/spi/AudioFileReader/RecognizeHugeWaveExtFiles.java	Thu May 19 19:46:20 2016 +0000
@@ -125,7 +125,7 @@
      * Tests the {@code AudioInputStream} fetched from the fake header.
      * <p>
      * Note that the frameLength is stored as long which means that {@code
-     * AudioInputStream} must store all possible data from au file.
+     * AudioInputStream} must store all possible data from wave file.
      */
     private static void testAIS(final int[] type, final int rate,
                                 final int channel, final long size)
@@ -166,8 +166,9 @@
             System.err.println("Actual: " + format.getChannels());
             throw new RuntimeException();
         }
-        if (format.getFrameSize() != ((bits + 7) / 8) * channel) {
-            System.err.println("Expected: " + (bits * channel + 1) / 8);
+        int frameSize = ((bits + 7) / 8) * channel;
+        if (format.getFrameSize() != frameSize) {
+            System.err.println("Expected: " + frameSize);
             System.err.println("Actual: " + format.getFrameSize());
             throw new RuntimeException();
         }
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/jdk/test/javax/sound/sampled/spi/AudioFileReader/RecognizeHugeWaveFiles.java	Thu May 19 19:46:20 2016 +0000
@@ -0,0 +1,227 @@
+/*
+ * Copyright (c) 2016, 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.
+ */
+
+import java.io.ByteArrayInputStream;
+
+import javax.sound.sampled.AudioFileFormat;
+import javax.sound.sampled.AudioFormat;
+import javax.sound.sampled.AudioInputStream;
+import javax.sound.sampled.AudioSystem;
+
+/**
+ * @test
+ * @bug 8132782 6729836
+ */
+public final class RecognizeHugeWaveFiles {
+
+    /**
+     * The maximum size in bytes per WAVE specification.
+     */
+    private static final /*unsigned int */ long MAX_UNSIGNED_INT = 0xffffffffL;
+
+    /**
+     * The  supported wave pcm_float format and sample size in bits.
+     */
+    private static final byte[][] waveTypeBits = {
+            {0x0001/*WAVE_FORMAT_PCM*/,1},
+            {0x0001/*WAVE_FORMAT_PCM*/,2},
+            {0x0001/*WAVE_FORMAT_PCM*/,4},
+            {0x0001/*WAVE_FORMAT_PCM*/,8},
+            {0x0001/*WAVE_FORMAT_PCM*/,16},
+            {0x0001/*WAVE_FORMAT_PCM*/,20},
+            {0x0001/*WAVE_FORMAT_PCM*/,24},
+            {0x0001/*WAVE_FORMAT_PCM*/,32},
+            {0x0003/*WAVE_FORMAT_IEEE_FLOAT*/, 32},
+            {0x0006/*WAVE_FORMAT_ALAW*/, 8},
+            {0x0007/*WAVE_FORMAT_MULAW*/, 8}
+    };
+
+    /**
+     * The list of supported sample rates(stored as unsigned int).
+     */
+    private static final int[] sampleRates = {
+            8000, 11025, 16000, 22050, 32000, 37800, 44056, 44100, 47250, 48000,
+            50000, 50400, 88200, 96000, 176400, 192000, 352800, 2822400,
+            5644800, Integer.MAX_VALUE
+    };
+
+    /**
+     * The list of supported channels (stored as unsigned int).
+     */
+    private static final int[] channels = {
+            1, 2, 3, 4, 5, 6, 7, 8, 9, 10
+    };
+
+    /**
+     * The list of supported size of data (stored as unsigned int).
+     * <p>
+     * The {@code MAX_UNSIGNED_INT} is a maximum size.
+     */
+    private static final long[] dataSizes = {
+            0, 1, 2, 3, Integer.MAX_VALUE - 1, Integer.MAX_VALUE,
+            (long) Integer.MAX_VALUE + 1, MAX_UNSIGNED_INT - 1, MAX_UNSIGNED_INT
+    };
+
+    public static void main(final String[] args) throws Exception {
+        for (final byte[] type : waveTypeBits) {
+            for (final int sampleRate : sampleRates) {
+                for (final int channel : channels) {
+                    for (final long dataSize : dataSizes) {
+                        testAFF(type, sampleRate, channel, dataSize);
+                        testAIS(type, sampleRate, channel, dataSize);
+                    }
+                }
+            }
+        }
+    }
+
+    /**
+     * Tests the {@code AudioFileFormat} fetched from the fake header.
+     * <p>
+     * Note that the frameLength and byteLength are stored as int which means
+     * that {@code AudioFileFormat} will store the data above {@code MAX_INT} as
+     * NOT_SPECIFIED.
+     */
+    private static void testAFF(final byte[] type, final int rate,
+                                final int channel, final long size)
+            throws Exception {
+        final byte[] header = createHeader(type, rate, channel, size);
+        final ByteArrayInputStream fake = new ByteArrayInputStream(header);
+        final AudioFileFormat aff = AudioSystem.getAudioFileFormat(fake);
+        final AudioFormat format = aff.getFormat();
+
+        if (aff.getType() != AudioFileFormat.Type.WAVE) {
+            throw new RuntimeException("Error");
+        }
+
+        final long frameLength = size / format.getFrameSize();
+        if (frameLength <= Integer.MAX_VALUE) {
+            if (aff.getFrameLength() != frameLength) {
+                System.err.println("Expected: " + frameLength);
+                System.err.println("Actual: " + aff.getFrameLength());
+                throw new RuntimeException();
+            }
+        } else {
+            if (aff.getFrameLength() != AudioSystem.NOT_SPECIFIED) {
+                System.err.println("Expected: " + AudioSystem.NOT_SPECIFIED);
+                System.err.println("Actual: " + aff.getFrameLength());
+                throw new RuntimeException();
+            }
+        }
+        validateFormat(type[1], rate, channel, aff.getFormat());
+    }
+
+    /**
+     * Tests the {@code AudioInputStream} fetched from the fake header.
+     * <p>
+     * Note that the frameLength is stored as long which means that {@code
+     * AudioInputStream} must store all possible data from wave file.
+     */
+    private static void testAIS(final byte[] type, final int rate,
+                                final int channel, final long size)
+            throws Exception {
+        final byte[] header = createHeader(type, rate, channel, size);
+        final ByteArrayInputStream fake = new ByteArrayInputStream(header);
+        final AudioInputStream ais = AudioSystem.getAudioInputStream(fake);
+        final AudioFormat format = ais.getFormat();
+        final long frameLength = size / format.getFrameSize();
+        if (frameLength != ais.getFrameLength()) {
+            System.err.println("Expected: " + frameLength);
+            System.err.println("Actual: " + ais.getFrameLength());
+            throw new RuntimeException();
+        }
+        if (ais.available() < 0) {
+            System.err.println("available should be >=0: " + ais.available());
+            throw new RuntimeException();
+        }
+
+        validateFormat(type[1], rate, channel, format);
+    }
+
+    /**
+     * Tests that format contains the same data as were provided to the fake
+     * stream.
+     */
+    private static void validateFormat(final byte bits, final int rate,
+                                       final int channel,
+                                       final AudioFormat format) {
+
+        if (Float.compare(format.getSampleRate(), rate) != 0) {
+            System.err.println("Expected: " + rate);
+            System.err.println("Actual: " + format.getSampleRate());
+            throw new RuntimeException();
+        }
+        if (format.getChannels() != channel) {
+            System.err.println("Expected: " + channel);
+            System.err.println("Actual: " + format.getChannels());
+            throw new RuntimeException();
+        }
+        int frameSize = ((bits + 7) / 8) * channel;
+        if (format.getFrameSize() != frameSize) {
+            System.err.println("Expected: " + frameSize);
+            System.err.println("Actual: " + format.getFrameSize());
+            throw new RuntimeException();
+        }
+    }
+
+    /**
+     * Creates the custom header of the WAVE file. It is expected that all
+     * passed data are supported.
+     */
+    private static byte[] createHeader(final byte[] type, final int rate,
+                                       final int channel, final long size) {
+        final int frameSize = ((type[1] + 7) / 8) * channel;
+        return new byte[]{
+                // RIFF_MAGIC
+                0x52, 0x49, 0x46, 0x46,
+                // fileLength
+                -1, -1, -1, -1,
+                //  waveMagic
+                0x57, 0x41, 0x56, 0x45,
+                // FMT_MAGIC
+                0x66, 0x6d, 0x74, 0x20,
+                // size
+                16, 0, 0, 0,
+                // wav_type  WAVE_FORMAT_IEEE_FLOAT
+                type[0], 0,
+                // channels
+                (byte) (channel), (byte) (channel >> 8),
+                // samplerate
+                (byte) (rate), (byte) (rate >> 8), (byte) (rate >> 16),
+                (byte) (rate >> 24),
+                // framerate
+                1, 0, 0, 0,
+                // framesize
+                (byte) (frameSize), (byte) (frameSize >> 8),
+                // bits
+                type[1], 0,
+                // DATA_MAGIC
+                0x64, 0x61, 0x74, 0x61,
+                // data size
+                (byte) (size), (byte) (size >> 8), (byte) (size >> 16),
+                (byte) (size >> 24)
+                // data
+                , 0, 0, 0, 0, 0
+        };
+    }
+}
--- a/jdk/test/javax/sound/sampled/spi/AudioFileReader/RecognizeHugeWaveFloatFiles.java	Thu May 19 17:48:02 2016 +0000
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,216 +0,0 @@
-/*
- * Copyright (c) 2016, 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.
- */
-
-import java.io.ByteArrayInputStream;
-
-import javax.sound.sampled.AudioFileFormat;
-import javax.sound.sampled.AudioFormat;
-import javax.sound.sampled.AudioInputStream;
-import javax.sound.sampled.AudioSystem;
-
-/**
- * @test
- * @bug 8132782
- */
-public final class RecognizeHugeWaveFloatFiles {
-
-    /**
-     * The maximum size in bytes per WAVE specification.
-     */
-    private static final /*unsigned int */ long MAX_UNSIGNED_INT = 0xffffffffL;
-
-    /**
-     * The  supported wave pcm_float format and sample size in bits.
-     */
-    private static final byte[][] waveTypeBits = {
-            {0x0003/*WAVE_FORMAT_IEEE_FLOAT*/, 32}
-    };
-
-    /**
-     * The list of supported sample rates(stored as unsigned int).
-     */
-    private static final int[] sampleRates = {
-            8000, 11025, 16000, 22050, 32000, 37800, 44056, 44100, 47250, 48000,
-            50000, 50400, 88200, 96000, 176400, 192000, 352800, 2822400,
-            5644800, Integer.MAX_VALUE
-    };
-
-    /**
-     * The list of supported channels (stored as unsigned int).
-     */
-    private static final int[] channels = {
-            1, 2, 3, 4, 5, 6, 7, 8, 9, 10
-    };
-
-    /**
-     * The list of supported size of data (stored as unsigned int).
-     * <p>
-     * The {@code MAX_UNSIGNED_INT} is a maximum size.
-     */
-    private static final long[] dataSizes = {
-            0, 1, 2, 3, Integer.MAX_VALUE - 1, Integer.MAX_VALUE,
-            (long) Integer.MAX_VALUE + 1, MAX_UNSIGNED_INT - 1, MAX_UNSIGNED_INT
-    };
-
-    public static void main(final String[] args) throws Exception {
-        for (final byte[] type : waveTypeBits) {
-            for (final int sampleRate : sampleRates) {
-                for (final int channel : channels) {
-                    for (final long dataSize : dataSizes) {
-                        testAFF(type, sampleRate, channel, dataSize);
-                        testAIS(type, sampleRate, channel, dataSize);
-                    }
-                }
-            }
-        }
-    }
-
-    /**
-     * Tests the {@code AudioFileFormat} fetched from the fake header.
-     * <p>
-     * Note that the frameLength and byteLength are stored as int which means
-     * that {@code AudioFileFormat} will store the data above {@code MAX_INT} as
-     * NOT_SPECIFIED.
-     */
-    private static void testAFF(final byte[] type, final int rate,
-                                final int channel, final long size)
-            throws Exception {
-        final byte[] header = createHeader(type, rate, channel, size);
-        final ByteArrayInputStream fake = new ByteArrayInputStream(header);
-        final AudioFileFormat aff = AudioSystem.getAudioFileFormat(fake);
-        final AudioFormat format = aff.getFormat();
-
-        if (aff.getType() != AudioFileFormat.Type.WAVE) {
-            throw new RuntimeException("Error");
-        }
-
-        final long frameLength = size / format.getFrameSize();
-        if (frameLength <= Integer.MAX_VALUE) {
-            if (aff.getFrameLength() != frameLength) {
-                System.err.println("Expected: " + frameLength);
-                System.err.println("Actual: " + aff.getFrameLength());
-                throw new RuntimeException();
-            }
-        } else {
-            if (aff.getFrameLength() != AudioSystem.NOT_SPECIFIED) {
-                System.err.println("Expected: " + AudioSystem.NOT_SPECIFIED);
-                System.err.println("Actual: " + aff.getFrameLength());
-                throw new RuntimeException();
-            }
-        }
-        validateFormat(type[1], rate, channel, aff.getFormat());
-    }
-
-    /**
-     * Tests the {@code AudioInputStream} fetched from the fake header.
-     * <p>
-     * Note that the frameLength is stored as long which means that {@code
-     * AudioInputStream} must store all possible data from au file.
-     */
-    private static void testAIS(final byte[] type, final int rate,
-                                final int channel, final long size)
-            throws Exception {
-        final byte[] header = createHeader(type, rate, channel, size);
-        final ByteArrayInputStream fake = new ByteArrayInputStream(header);
-        final AudioInputStream ais = AudioSystem.getAudioInputStream(fake);
-        final AudioFormat format = ais.getFormat();
-        final long frameLength = size / format.getFrameSize();
-        if (frameLength != ais.getFrameLength()) {
-            System.err.println("Expected: " + frameLength);
-            System.err.println("Actual: " + ais.getFrameLength());
-            throw new RuntimeException();
-        }
-        if (ais.available() < 0) {
-            System.err.println("available should be >=0: " + ais.available());
-            throw new RuntimeException();
-        }
-
-        validateFormat(type[1], rate, channel, format);
-    }
-
-    /**
-     * Tests that format contains the same data as were provided to the fake
-     * stream.
-     */
-    private static void validateFormat(final byte bits, final int rate,
-                                       final int channel,
-                                       final AudioFormat format) {
-
-        if (Float.compare(format.getSampleRate(), rate) != 0) {
-            System.err.println("Expected: " + rate);
-            System.err.println("Actual: " + format.getSampleRate());
-            throw new RuntimeException();
-        }
-        if (format.getChannels() != channel) {
-            System.err.println("Expected: " + channel);
-            System.err.println("Actual: " + format.getChannels());
-            throw new RuntimeException();
-        }
-        if (format.getFrameSize() != ((bits + 7) / 8) * channel) {
-            System.err.println("Expected: " + (bits * channel + 1) / 8);
-            System.err.println("Actual: " + format.getFrameSize());
-            throw new RuntimeException();
-        }
-    }
-
-    /**
-     * Creates the custom header of the WAVE file. It is expected that all
-     * passed data are supported.
-     */
-    private static byte[] createHeader(final byte[] type, final int rate,
-                                       final int channel, final long size) {
-        final int frameSize = ((type[1] + 7) / 8) * channel;
-        return new byte[]{
-                // RIFF_MAGIC
-                0x52, 0x49, 0x46, 0x46,
-                // fileLength
-                -1, -1, -1, -1,
-                //  waveMagic
-                0x57, 0x41, 0x56, 0x45,
-                // FMT_MAGIC
-                0x66, 0x6d, 0x74, 0x20,
-                // size
-                16, 0, 0, 0,
-                // wav_type  WAVE_FORMAT_IEEE_FLOAT
-                type[0], 0,
-                // channels
-                (byte) (channel), (byte) (channel >> 8),
-                // samplerate
-                (byte) (rate), (byte) (rate >> 8), (byte) (rate >> 16),
-                (byte) (rate >> 24),
-                // framerate
-                1, 0, 0, 0,
-                // framesize
-                (byte) (frameSize), (byte) (frameSize >> 8),
-                // bits
-                type[1], 0,
-                // DATA_MAGIC
-                0x64, 0x61, 0x74, 0x61,
-                // data size
-                (byte) (size), (byte) (size >> 8), (byte) (size >> 16),
-                (byte) (size >> 24)
-                // data
-                , 0, 0, 0, 0, 0
-        };
-    }
-}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/jdk/test/javax/swing/JFileChooser/8152677/SelectAllFilesFilterTest.java	Thu May 19 19:46:20 2016 +0000
@@ -0,0 +1,108 @@
+/*
+ * Copyright (c) 2016, 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.
+ */
+
+import java.awt.Component;
+import java.awt.Container;
+import java.awt.Robot;
+import javax.swing.JComboBox;
+import javax.swing.JFileChooser;
+import javax.swing.JLabel;
+import javax.swing.SwingUtilities;
+import javax.swing.filechooser.FileFilter;
+import javax.swing.filechooser.FileNameExtensionFilter;
+
+/*
+ * @test
+ * @bug 8152677
+ * @requires (os.family == "mac")
+ * @summary [macosx] All files filter can't be selected in JFileChooser
+ * @run main SelectAllFilesFilterTest
+ */
+
+public class SelectAllFilesFilterTest {
+
+    private static final String LABEL_TEXT = "File Format:";
+    private static volatile JFileChooser fileChooser;
+    private static JComboBox comboBox;
+
+    public static void main(String[] args) throws Exception {
+
+        SwingUtilities.invokeLater(SelectAllFilesFilterTest::createAndShowGUI);
+
+        while (fileChooser == null) {
+            Thread.sleep(100);
+        }
+
+        Robot robot = new Robot();
+        robot.waitForIdle();
+
+        SwingUtilities.invokeAndWait(() -> {
+            comboBox = findComboBox(fileChooser);
+            comboBox.setSelectedIndex(0);
+        });
+        robot.waitForIdle();
+
+        SwingUtilities.invokeAndWait(() -> {
+            int selectedIndex = comboBox.getSelectedIndex();
+            fileChooser.setVisible(false);
+
+            if (selectedIndex != 0) {
+                throw new RuntimeException("Select All file filter is not selected!");
+            }
+        });
+    }
+
+    private static void createAndShowGUI() {
+        fileChooser = new JFileChooser();
+        fileChooser.setAcceptAllFileFilterUsed(true);
+        fileChooser.setDialogType(JFileChooser.OPEN_DIALOG);
+
+        FileFilter txtFilter = new FileNameExtensionFilter("Text files", "txt");
+        fileChooser.addChoosableFileFilter(txtFilter);
+        fileChooser.setFileFilter(txtFilter);
+        fileChooser.showOpenDialog(null);
+    }
+
+    private static JComboBox findComboBox(Component comp) {
+
+        if (comp instanceof JLabel) {
+            JLabel label = (JLabel) comp;
+            if (LABEL_TEXT.equals(label.getText())) {
+                return (JComboBox) label.getLabelFor();
+            }
+        }
+
+        if (comp instanceof Container) {
+            Container cont = (Container) comp;
+            for (int i = 0; i < cont.getComponentCount(); i++) {
+
+                JComboBox result = findComboBox(cont.getComponent(i));
+                if (result != null) {
+                    return result;
+                }
+            }
+        }
+
+        return null;
+    }
+}
--- a/jdk/test/javax/swing/JMenuItem/ActionListenerCalledTwice/ActionListenerCalledTwiceTest.java	Thu May 19 17:48:02 2016 +0000
+++ b/jdk/test/javax/swing/JMenuItem/ActionListenerCalledTwice/ActionListenerCalledTwiceTest.java	Thu May 19 19:46:20 2016 +0000
@@ -21,23 +21,23 @@
  * questions.
  */
 
-/*
+ /*
  * @test
- * @bug 7160951
+ * @bug 7160951 8152492
  * @summary [macosx] ActionListener called twice for JMenuItem using ScreenMenuBar
  * @author vera.akulova@oracle.com
  * @library ../../../../lib/testlibrary
  * @build jdk.testlibrary.OSInfo
  * @run main ActionListenerCalledTwiceTest
  */
-
 import jdk.testlibrary.OSInfo;
 import java.awt.*;
 import java.awt.event.*;
 import javax.swing.*;
 
 public class ActionListenerCalledTwiceTest {
-    static String menuItems[] = { "Item1", "Item2", "Item3", "Item4", "Item5", "Item6" };
+
+    static String menuItems[] = {"Item1", "Item2", "Item3", "Item4", "Item5", "Item6"};
     static KeyStroke keyStrokes[] = {
         KeyStroke.getKeyStroke(KeyEvent.VK_E, InputEvent.META_MASK),
         KeyStroke.getKeyStroke(KeyEvent.VK_DELETE, 0),
@@ -46,8 +46,10 @@
         KeyStroke.getKeyStroke(KeyEvent.VK_E, InputEvent.CTRL_MASK),
         KeyStroke.getKeyStroke(KeyEvent.VK_EQUALS, InputEvent.META_MASK)
     };
+    static JMenu menu;
+    static JFrame frame;
+    static volatile int listenerCallCounter = 0;
 
-    static volatile int listenerCallCounter = 0;
     public static void main(String[] args) throws Exception {
         if (OSInfo.getOSType() != OSInfo.OSType.MACOSX) {
             System.out.println("This test is for MacOS only. Automatically passed on other platforms.");
@@ -82,33 +84,38 @@
             robot.waitForIdle();
 
             if (listenerCallCounter != 1) {
-                throw new Exception("Test failed: ActionListener for " + menuItems[i] +
-                    " called " + listenerCallCounter + " times instead of 1!");
+                throw new Exception("Test failed: ActionListener for " + menuItems[i]
+                        + " called " + listenerCallCounter + " times instead of 1!");
             }
 
             listenerCallCounter = 0;
         }
+        SwingUtilities.invokeAndWait(new Runnable() {
+            public void run() {
+                frame.dispose();
+            }
+        });
     }
 
     private static void createAndShowGUI() {
-        JMenu menu = new JMenu("Menu");
+        menu = new JMenu("Menu");
 
         for (int i = 0; i < menuItems.length; ++i) {
             JMenuItem newItem = new JMenuItem(menuItems[i]);
             newItem.setAccelerator(keyStrokes[i]);
             newItem.addActionListener(
-                new ActionListener(){
-                    public void actionPerformed(ActionEvent e) {
-                        listenerCallCounter++;
-                    }
+                    new ActionListener() {
+                public void actionPerformed(ActionEvent e) {
+                    listenerCallCounter++;
                 }
+            }
             );
             menu.add(newItem);
         }
 
         JMenuBar bar = new JMenuBar();
         bar.add(menu);
-        JFrame frame = new JFrame("Test");
+        frame = new JFrame("Test");
         frame.setJMenuBar(bar);
         frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
         frame.pack();
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/jdk/test/javax/swing/JSpinner/6421058/bug6421058.java	Thu May 19 19:46:20 2016 +0000
@@ -0,0 +1,94 @@
+/*
+ * Copyright (c) 2016, 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 6421058
+  * @summary Verify font of the text field is changed to the font of
+  *        JSpinner if the font of text field was NOT set by the user
+  * @run main bug6421058
+  */
+
+import java.awt.Font;
+import javax.swing.JFrame;
+import javax.swing.JSpinner;
+import javax.swing.JSpinner.DefaultEditor;
+import javax.swing.SwingUtilities;
+import javax.swing.UIManager;
+import javax.swing.UnsupportedLookAndFeelException;
+import javax.swing.plaf.UIResource;
+import static javax.swing.UIManager.getInstalledLookAndFeels;
+
+public class bug6421058 implements Runnable {
+
+    public static void main(final String[] args) throws Exception {
+        for (final UIManager.LookAndFeelInfo laf : getInstalledLookAndFeels()) {
+            SwingUtilities.invokeAndWait(() -> setLookAndFeel(laf));
+            SwingUtilities.invokeAndWait(new bug6421058());
+        }
+    }
+
+    @Override
+    public void run() {
+        final JFrame mainFrame = new JFrame();
+        try {
+            testDefaultFont(mainFrame);
+        } finally {
+            mainFrame.dispose();
+        }
+    }
+
+    private static void testDefaultFont(final JFrame frame) {
+        frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
+
+        JSpinner spinner = new JSpinner();
+        frame.add(spinner);
+        frame.setSize(300, 100);
+        frame.setVisible(true);
+
+        final DefaultEditor editor = (DefaultEditor) spinner.getEditor();
+        final Font editorFont = editor.getTextField().getFont();
+
+        /*
+         * Validate that the font of the text field is changed to the
+         * font of JSpinner if the font of text field was not set by the
+         * user.
+         */
+
+        if (!(editorFont instanceof UIResource)) {
+            throw new RuntimeException("Font must be UIResource");
+        }
+        if (!editorFont.equals(spinner.getFont())) {
+            throw new RuntimeException("Wrong FONT");
+        }
+    }
+
+    private static void setLookAndFeel(final UIManager.LookAndFeelInfo laf) {
+        try {
+            UIManager.setLookAndFeel(laf.getClassName());
+        } catch (ClassNotFoundException | InstantiationException |
+                UnsupportedLookAndFeelException | IllegalAccessException e) {
+            throw new RuntimeException(e);
+        }
+    }
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/jdk/test/javax/swing/LookAndFeel/8145547/DemandGTK.java	Thu May 19 19:46:20 2016 +0000
@@ -0,0 +1,71 @@
+/*
+ * Copyright (c) 2016, Oracle and/or its affiliates. All rights reserved.
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * This code is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License version 2 only, as
+ * published by the Free Software Foundation.
+ *
+ * This code is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
+ * version 2 for more details (a copy is included in the LICENSE file that
+ * accompanied this code).
+ *
+ * You should have received a copy of the GNU General Public License version
+ * 2 along with this work; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
+ *
+ * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
+ * or visit www.oracle.com if you need additional information or have any
+ * questions.
+ */
+
+/*
+  @test
+  @summary  Tests that GTK LaF is supported on solaris
+            regardless of jdk.gtk.version flag values.
+  @bug 8156121
+  @requires (os.name == "linux" | os.name == "solaris")
+  @run main/othervm -Djdk.gtk.version=2 DemandGTK
+  @run main/othervm -Djdk.gtk.version=3 DemandGTK
+*/
+
+import javax.swing.JFrame;
+import javax.swing.UIManager;
+import javax.swing.SwingUtilities;
+import java.awt.Robot;
+
+public class DemandGTK {
+
+    static JFrame frame;
+    public static void createAndShow() {
+        try {
+            UIManager.setLookAndFeel("com.sun.java.swing.plaf.gtk.GTKLookAndFeel");
+        } catch(Exception cnf) {
+            cnf.printStackTrace();
+            throw new RuntimeException("GTK LaF must be supported");
+        }
+        frame = new JFrame("JFrame");
+        frame.setSize(200, 200);
+
+        frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
+        frame.setVisible(true);
+    }
+
+    /**
+     * @param args the command line arguments
+     */
+    public static void main(String[] args) throws Exception {
+        SwingUtilities.invokeAndWait(DemandGTK::createAndShow);
+        Robot robot = new Robot();
+        robot.waitForIdle();
+        robot.delay(1000);
+        SwingUtilities.invokeAndWait( () -> {
+            frame.setVisible(false);
+            frame.dispose();
+        });
+
+    }
+}
+
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/jdk/test/javax/swing/LookAndFeel/8145547/DemandGTK2.sh	Thu May 19 19:46:20 2016 +0000
@@ -0,0 +1,89 @@
+#!/bin/ksh -p
+
+#
+# Copyright (c) 2016, Oracle and/or its affiliates. All rights reserved.
+# DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+#
+# This code is free software; you can redistribute it and/or modify it
+# under the terms of the GNU General Public License version 2 only, as
+# published by the Free Software Foundation.
+#
+# This code is distributed in the hope that it will be useful, but WITHOUT
+# ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+# FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
+# version 2 for more details (a copy is included in the LICENSE file that
+# accompanied this code).
+#
+# You should have received a copy of the GNU General Public License version
+# 2 along with this work; if not, write to the Free Software Foundation,
+# Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
+#
+# Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
+# or visit www.oracle.com if you need additional information or have any
+# questions.
+#
+
+#   @test
+#   @summary  Try to force GTK2. We must bail out to GTK3 (if any) if no 2 available.
+#
+#   @compile ProvokeGTK.java
+#   @requires os.family == "linux"
+#   @run shell/timeout=400 DemandGTK2.sh
+
+#
+# Note that we depend on
+# strace in the PATH
+# /sbin/ldconfig (which may be not in PATH)
+# It is true for OEL 7 and Ubuntu 14, 16
+# but may fail in future. Save tomorrow for tomorrow.
+#
+# Read DemandGTK2.txt how to prepare GTK2-less machine.
+#
+
+which strace
+if [ $?  -ne 0 ]
+then
+    echo "Please provide strace: \"which strace\" failed."
+    exit 1
+fi
+
+HAVE_2=`/sbin/ldconfig -v 2>/dev/null | grep libgtk-x11-2 | wc -l`
+HAVE_3=`/sbin/ldconfig -v 2>/dev/null | grep libgtk-3.so | wc -l`
+
+
+if [ "${HAVE_2}" = "0" ]
+then
+    
+    if [ "${HAVE_3}" = "0" ]
+    then
+        echo "Neither GTK2 nor GTK3 found: system misconfiguration. Exit."
+        exit 1
+    fi
+    echo "No GTK 2 library found: we should bail out to 3"
+    strace -o strace.log -fe open ${TESTJAVA}/bin/java  -cp ${TESTCLASSPATH}  -Djdk.gtk.version=2 ProvokeGTK
+    EXECRES=$?
+    grep  'libgtk-3.*=\ *[0-9]*$' strace.log > logg
+else
+    echo "There is GTK 2 library: we should use it"
+    strace -o strace.log -fe open ${TESTJAVA}/bin/java  -cp ${TESTCLASSPATH}  -Djdk.gtk.version=2 ProvokeGTK
+    EXECRES=$?
+    grep  'libgtk-x11.*=\ *[0-9]*$' strace.log > logg
+fi
+
+if [ ${EXECRES}  -ne 0 ]
+then
+    echo "java execution failed for unknown reason, see logs"
+    exit 2
+fi
+
+cat logg
+if [ -s logg ]
+then
+    echo "Success."
+    exit 0
+else
+    echo "Failed. Examine logs."
+    exit 3
+fi
+
+
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/jdk/test/javax/swing/LookAndFeel/8145547/DemandGTK2.txt	Thu May 19 19:46:20 2016 +0000
@@ -0,0 +1,36 @@
+How to prepare an Ubuntu machine for GTK-2-less test run.
+
+The test DemandGTK2.sh should work well without GTK-2 switching to version 3
+if there's no GTK-2 library available. 
+At the moment, it's not easy to find a system with GTK-3 and without GTK-2:
+many programs still depend on version 2.
+We can, however, rename GTK-2 library for a single test run and then restore
+it back.
+
+(1) Find GTK2 library: run
+  /sbin/ldconfig -v 2>/dev/null |  grep libgtk-x11-2
+
+It will output one or two lines like 
+libgtk-x11-2.0.so.0 -> libgtk-x11-2.0.so.0.2400.23
+Search for the target of that symlink for instance with locate:
+locate libgtk-x11-2.0.so.0.2400.23
+Finally, you'll find the libraries. On my current machine they are
+/usr/lib/i386-linux-gnu/libgtk-x11-2.0.so.0.2400.23
+/usr/lib/x86_64-linux-gnu/libgtk-x11-2.0.so.0.2400.23
+
+I'm running 64-bit JDK and need to tamper with x86_64 copy only.
+
+(2) Find running programs depending on this library. They probably would crash
+if you rename it. Stop them for this test run.
+That said, I'm afraid it would be impossible to do on a system older than Ubuntu 16.04.
+On my Ubuntu 16.04 I have only hud-service using this library, and that's OK, it will restart
+after a crash, if any.
+To find these programs, run
+lsof /usr/lib/x86_64-linux-gnu/libgtk-x11-2.0.so.0.2400.23
+
+(3) Now,
+sudo mv  /usr/lib/x86_64-linux-gnu/libgtk-x11-2.0.so.0.2400.23  /usr/lib/x86_64-linux-gnu/bak.libgtk-x11-2.0.so.0.2400.23
+jtreg DemandGTK2.sh 
+sudo mv  /usr/lib/x86_64-linux-gnu/bak.libgtk-x11-2.0.so.0.2400.23  /usr/lib/x86_64-linux-gnu/libgtk-x11-2.0.so.0.2400.23
+
+Needless to say, you should substitute your own library path and however you run jtreg.
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/jdk/test/javax/swing/LookAndFeel/8145547/DemandGTK3.sh	Thu May 19 19:46:20 2016 +0000
@@ -0,0 +1,81 @@
+#!/bin/ksh -p
+
+#
+# Copyright (c) 2016, Oracle and/or its affiliates. All rights reserved.
+# DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+#
+# This code is free software; you can redistribute it and/or modify it
+# under the terms of the GNU General Public License version 2 only, as
+# published by the Free Software Foundation.
+#
+# This code is distributed in the hope that it will be useful, but WITHOUT
+# ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+# FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
+# version 2 for more details (a copy is included in the LICENSE file that
+# accompanied this code).
+#
+# You should have received a copy of the GNU General Public License version
+# 2 along with this work; if not, write to the Free Software Foundation,
+# Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
+#
+# Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
+# or visit www.oracle.com if you need additional information or have any
+# questions.
+#
+
+
+#   @test
+#   @summary  Try to force GTK3. We must bail out to GTK2 if no 3 available.
+#
+#   @compile ProvokeGTK.java
+#   @requires os.family == "linux"
+#   @run shell/timeout=400 DemandGTK3.sh
+
+#
+# Note that we depend on
+# strace in the PATH
+# /sbin/ldconfig (which may be is not in PATH)
+# It is true for OEL 7 and Ubuntu 14, 16
+# but may fail in future. Save tomorrow for tomorrow.
+#
+
+which strace
+if [ $?  -ne 0 ]
+then
+    echo "Please provide strace: \"which strace\" failed."
+    exit 1
+fi
+
+HAVE_3=`/sbin/ldconfig -v 2>/dev/null | grep libgtk-3.so | wc -l`
+
+
+if [ "${HAVE_3}" = "0" ]
+then
+    
+    echo "No GTK 3 library found: we should bail out to 2"
+    strace -o strace.log -fe open ${TESTJAVA}/bin/java  -cp ${TESTCLASSPATH}  -Djdk.gtk.version=3 ProvokeGTK
+    EXECRES=$?
+    grep  'libgtk-x11.*=\ *[0-9]*$' strace.log > logg
+else
+    echo "There is GTK 3 library: we should use it"
+    strace -o strace.log -fe open ${TESTJAVA}/bin/java  -cp ${TESTCLASSPATH}  -Djdk.gtk.version=3 ProvokeGTK
+    EXECRES=$?
+    grep  'libgtk-3.*=\ *[0-9]*$' strace.log > logg
+fi
+
+if [ ${EXECRES}  -ne 0 ]
+then
+    echo "java execution failed for unknown reason, see logs"
+    exit 2
+fi
+
+cat logg
+if [  -s logg ]
+then
+    echo "Success."
+    exit 0
+else
+    echo "Failed. Examine logs."
+    exit 3
+fi
+
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/jdk/test/javax/swing/LookAndFeel/8145547/ProvokeGTK.java	Thu May 19 19:46:20 2016 +0000
@@ -0,0 +1,57 @@
+/*
+ * Copyright (c) 2016, 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.
+ */
+
+import javax.swing.JFrame;
+import javax.swing.UIManager;
+import javax.swing.SwingUtilities;
+
+public class ProvokeGTK {
+
+    static JFrame frame;
+    public static void createAndShow() {
+        try {
+            UIManager.setLookAndFeel("com.sun.java.swing.plaf.gtk.GTKLookAndFeel");
+        } catch(Exception cnf) {
+            cnf.printStackTrace();
+        }
+        frame = new JFrame("JFrame");
+        frame.setSize(200, 200);
+
+        frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
+        frame.setVisible(true);
+    }
+
+    /**
+     * @param args the command line arguments
+     */
+    public static void main(String[] args) throws Exception {
+        SwingUtilities.invokeAndWait(ProvokeGTK::createAndShow);
+        Thread.sleep(1000);
+        SwingUtilities.invokeAndWait( () -> {
+            frame.setVisible(false);
+            frame.dispose();
+        });
+
+    }
+}
+
--- a/jdk/test/javax/xml/bind/xjc/8032884/XjcOptionalPropertyTest.java	Thu May 19 17:48:02 2016 +0000
+++ b/jdk/test/javax/xml/bind/xjc/8032884/XjcOptionalPropertyTest.java	Thu May 19 19:46:20 2016 +0000
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2014, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2014, 2016, Oracle and/or its affiliates. All rights reserved.
  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
  *
  * This code is free software; you can redistribute it and/or modify it
@@ -23,47 +23,107 @@
 
 /*
  * @test
- * @bug 8032884
+ * @bug 8032884 8072579
  * @summary Globalbindings optionalProperty="primitive" does not work when minOccurs=0
- * @run shell compile-schema.sh
- * @compile -addmods java.xml.bind XjcOptionalPropertyTest.java
- * @run main/othervm XjcOptionalPropertyTest
+ * @library /lib/testlibrary
+ * @modules java.xml.bind
+ * @run testng/othervm XjcOptionalPropertyTest
  */
 
 import java.io.IOException;
 import java.lang.reflect.Method;
+import java.net.URL;
+import java.net.URLClassLoader;
+import java.nio.file.Files;
+import java.nio.file.Path;
+import java.nio.file.Paths;
+import static java.nio.file.StandardCopyOption.REPLACE_EXISTING;
+import java.util.Arrays;
+import jdk.testlibrary.JDKToolLauncher;
+import org.testng.Assert;
+import org.testng.annotations.BeforeTest;
+import org.testng.annotations.Test;
 
 public class XjcOptionalPropertyTest {
 
-    public static void main(String[] args) throws IOException {
-
-        generated.Foo foo = new generated.Foo();
-        log("foo = " + foo);
+    @Test
+    public void optionalPropertyTest() throws Exception {
+        runXjc();
+        compileXjcGeneratedClasses();
+        URLClassLoader testClassLoader;
+        testClassLoader = URLClassLoader.newInstance(new URL[]{testWorkDirUrl});
+        Class fooClass = testClassLoader.loadClass(CLASS_TO_TEST);
+        Object foo = fooClass.newInstance();
         Method[] methods = foo.getClass().getMethods();
-        log("Found [" + methods.length + "] methods");
+        System.out.println("Found [" + methods.length + "] methods");
         for (int i = 0; i < methods.length; i++) {
             Method method = methods[i];
             if (method.getName().equals("setFoo")) {
-                log("Checking method [" + method.getName() + "]");
+                System.out.println("Checking method [" + method.getName() + "]");
                 Class[] parameterTypes = method.getParameterTypes();
-                if (parameterTypes.length != 1)
-                    fail("more than 1 parameter");
-                if (!parameterTypes[0].isPrimitive()) {
-                    fail("Found [" + parameterTypes[0].getName() + "], but expected primitive!");
-                }
+                Assert.assertEquals(parameterTypes.length, 1);
+                Assert.assertTrue(parameterTypes[0].isPrimitive());
                 break;
             }
         }
-        log("TEST PASSED.");
+    }
 
+    @BeforeTest
+    public void setUp() throws IOException {
+        // Create test directory inside scratch
+        testWorkDir = Paths.get(System.getProperty("user.dir", "."));
+        // Save its URL
+        testWorkDirUrl = testWorkDir.toUri().toURL();
+        // Get test source directory path
+        testSrcDir = Paths.get(System.getProperty("test.src", "."));
+        // Get path of xjc result folder
+        xjcResultDir = testWorkDir.resolve(TEST_PACKAGE);
+        // Copy schema document file to scratch directory
+        Files.copy(testSrcDir.resolve(XSD_FILENAME), testWorkDir.resolve(XSD_FILENAME), REPLACE_EXISTING);
+    }
+
+    // Compile schema file into java classes definitions
+    void runXjc() throws Exception {
+        // Prepare process builder to run schemagen tool and save its output
+        JDKToolLauncher xjcLauncher = JDKToolLauncher.createUsingTestJDK("xjc");
+        xjcLauncher.addToolArg(XSD_FILENAME);
+        System.out.println("Executing xjc command: " + Arrays.asList(xjcLauncher.getCommand()));
+        ProcessBuilder pb = new ProcessBuilder(xjcLauncher.getCommand());
+        // Set xjc work directory with the input java file
+        pb.directory(testWorkDir.toFile());
+        pb.inheritIO();
+        Process p = pb.start();
+        p.waitFor();
+        p.destroy();
     }
 
-    private static void fail(String message) {
-        throw new RuntimeException(message);
+    // Compile java classes with javac tool
+    void compileXjcGeneratedClasses() throws Exception {
+        JDKToolLauncher javacLauncher = JDKToolLauncher.createUsingTestJDK("javac");
+        javacLauncher.addToolArg("-addmods");
+        javacLauncher.addToolArg("java.xml.bind");
+        javacLauncher.addToolArg(xjcResultDir.resolve("Foo.java").toString());
+        System.out.println("Compiling xjc generated class: " + Arrays.asList(javacLauncher.getCommand()));
+        ProcessBuilder pb = new ProcessBuilder(javacLauncher.getCommand());
+        pb.inheritIO();
+        pb.directory(testWorkDir.toFile());
+        Process p = pb.start();
+        p.waitFor();
+        p.destroy();
     }
 
-    private static void log(String msg) {
-        System.out.println(msg);
-    }
-
+    // Test schema filename
+    static final String XSD_FILENAME = "optional-property-schema.xsd";
+    // Test package with generated class
+    static final String TEST_PACKAGE = "anamespace";
+    // Name of generated java class
+    static final String CLASS_TO_TEST = TEST_PACKAGE+".Foo";
+    // Test working directory
+    Path testWorkDir;
+    // Test working directory URL
+    URL testWorkDirUrl;
+    // Directory with test src
+    Path testSrcDir;
+    // Directory with java files generated by xjc
+    Path xjcResultDir;
 }
--- a/jdk/test/javax/xml/bind/xjc/8032884/compile-schema.sh	Thu May 19 17:48:02 2016 +0000
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,39 +0,0 @@
-#! /bin/sh
-
-#
-# Copyright (c) 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.
-#
-# 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.
-#
-
-#
-
-if [ "x$TESTJAVA" = x ]; then
-  TESTJAVA=$1; shift
-  TESTCLASSES=.
-fi
-
-echo "cleaning generated files ..."
-rm -rfv ${TESTSRC}/generated
-
-echo "compiling [optional-property-schema.xsd] schema ..."
-$TESTJAVA/bin/xjc -p generated -d ${TESTSRC} ${TESTSRC}/optional-property-schema.xsd
-
-echo "Schema compiled. Verification of generated files can be done now."
--- a/jdk/test/javax/xml/bind/xjc/8145039/JaxbMarshallTest.java	Thu May 19 17:48:02 2016 +0000
+++ b/jdk/test/javax/xml/bind/xjc/8145039/JaxbMarshallTest.java	Thu May 19 19:46:20 2016 +0000
@@ -23,10 +23,10 @@
 
 /*
  * @test
- * @bug 8145039
+ * @bug 8145039 8157096
  * @summary Check that marshalling of xjc generated class doesn't throw
  *          ClassCast exception.
- * @modules javax.xml.bind
+ * @modules java.xml.bind
  * @library /lib/testlibrary
  * @run testng/othervm JaxbMarshallTest
  */
@@ -127,6 +127,8 @@
     // Compile java classes with javac tool
     void compileXjcGeneratedClasses() throws Exception {
         JDKToolLauncher javacLauncher = JDKToolLauncher.createUsingTestJDK("javac");
+        javacLauncher.addToolArg("-addmods");
+        javacLauncher.addToolArg("java.xml.bind");
         javacLauncher.addToolArg(xjcResultDir.resolve("ObjectFactory.java").toString());
         javacLauncher.addToolArg(xjcResultDir.resolve("TypesLongList.java").toString());
         javacLauncher.addToolArg(xjcResultDir.resolve("package-info.java").toString());
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/jdk/test/javax/xml/jaxp/TEST.properties	Thu May 19 19:46:20 2016 +0000
@@ -0,0 +1,1 @@
+modules = java.xml
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/jdk/test/jdk/internal/jline/extra/HistoryTest.java	Thu May 19 19:46:20 2016 +0000
@@ -0,0 +1,177 @@
+/*
+ * Copyright (c) 2015, 2016, Oracle and/or its affiliates. All rights reserved.
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * This code is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License version 2 only, as
+ * published by the Free Software Foundation.
+ *
+ * This code is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
+ * version 2 for more details (a copy is included in the LICENSE file that
+ * accompanied this code).
+ *
+ * You should have received a copy of the GNU General Public License version
+ * 2 along with this work; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
+ *
+ * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
+ * or visit www.oracle.com if you need additional information or have any
+ * questions.
+ */
+
+/*
+ * @test
+ * @summary Test Completion
+ * @modules jdk.internal.le/jdk.internal.jline
+ *          jdk.internal.le/jdk.internal.jline.console
+ *          jdk.internal.le/jdk.internal.jline.console.history
+ *          jdk.internal.le/jdk.internal.jline.extra
+ * @build HistoryTest
+ * @run testng HistoryTest
+ */
+
+import java.io.ByteArrayInputStream;
+import java.io.ByteArrayOutputStream;
+import java.io.IOException;
+import java.util.Arrays;
+import java.util.Collection;
+import java.util.Collections;
+import java.util.concurrent.atomic.AtomicBoolean;
+
+import jdk.internal.jline.UnsupportedTerminal;
+import jdk.internal.jline.console.ConsoleReader;
+import jdk.internal.jline.console.history.MemoryHistory;
+import jdk.internal.jline.extra.EditingHistory;
+
+import org.testng.annotations.Test;
+
+import static org.testng.Assert.*;
+
+@Test
+public class HistoryTest {
+
+    public void testHistory() throws IOException {
+        ConsoleReader in = new ConsoleReader(new ByteArrayInputStream(new byte[0]), new ByteArrayOutputStream(), new UnsupportedTerminal());
+        AtomicBoolean complete = new AtomicBoolean();
+        EditingHistory history = new EditingHistory(in, Collections.emptyList()) {
+            @Override
+            protected boolean isComplete(CharSequence input) {
+                return complete.get();
+            }
+        };
+        complete.set(false); history.add("void test() {");
+        complete.set(false); history.add("    System.err.println(1);");
+        complete.set(true);  history.add("}");
+        complete.set(true);  history.add("/exit");
+
+        previousAndAssert(history, "/exit");
+
+        history.previous(); history.previous(); history.previous();
+
+        complete.set(false); history.add("void test() { /*changed*/");
+
+        complete.set(true);
+        previousAndAssert(history, "}");
+        previousAndAssert(history, "    System.err.println(1);");
+        previousAndAssert(history, "void test() {");
+
+        assertFalse(history.previous());
+
+        nextAndAssert(history, "    System.err.println(1);");
+        nextAndAssert(history, "}");
+        nextAndAssert(history, "");
+
+        complete.set(false); history.add("    System.err.println(2);");
+        complete.set(true);  history.add("} /*changed*/");
+
+        assertEquals(history.size(), 7);
+
+        Collection<? extends String> persistentHistory = history.save();
+
+        history = new EditingHistory(in, persistentHistory) {
+            @Override
+            protected boolean isComplete(CharSequence input) {
+                return complete.get();
+            }
+        };
+
+        previousSnippetAndAssert(history, "void test() { /*changed*/");
+        previousSnippetAndAssert(history, "/exit");
+        previousSnippetAndAssert(history, "void test() {");
+
+        assertFalse(history.previousSnippet());
+
+        nextSnippetAndAssert(history, "/exit");
+        nextSnippetAndAssert(history, "void test() { /*changed*/");
+        nextSnippetAndAssert(history, "");
+
+        assertFalse(history.nextSnippet());
+
+        complete.set(false); history.add("{");
+        complete.set(true);  history.add("}");
+
+        persistentHistory = history.save();
+
+        history = new EditingHistory(in, persistentHistory) {
+            @Override
+            protected boolean isComplete(CharSequence input) {
+                return complete.get();
+            }
+        };
+
+        previousSnippetAndAssert(history, "{");
+        previousSnippetAndAssert(history, "void test() { /*changed*/");
+        previousSnippetAndAssert(history, "/exit");
+        previousSnippetAndAssert(history, "void test() {");
+
+        while (history.next());
+
+        complete.set(true);  history.add("/*current1*/");
+        complete.set(true);  history.add("/*current2*/");
+        complete.set(true);  history.add("/*current3*/");
+
+        assertEquals(history.currentSessionEntries(), Arrays.asList("/*current1*/", "/*current2*/", "/*current3*/"));
+
+        history.remove(0);
+
+        assertEquals(history.currentSessionEntries(), Arrays.asList("/*current1*/", "/*current2*/", "/*current3*/"));
+
+        while (history.size() > 2)
+            history.remove(0);
+
+        assertEquals(history.currentSessionEntries(), Arrays.asList("/*current2*/", "/*current3*/"));
+
+        for (int i = 0; i < MemoryHistory.DEFAULT_MAX_SIZE * 2; i++) {
+            complete.set(true);  history.add("/exit");
+        }
+
+        complete.set(false); history.add("void test() { /*after full*/");
+        complete.set(false); history.add("    System.err.println(1);");
+        complete.set(true);  history.add("}");
+
+        previousSnippetAndAssert(history, "void test() { /*after full*/");
+    }
+
+    private void previousAndAssert(EditingHistory history, String expected) {
+        assertTrue(history.previous());
+        assertEquals(history.current().toString(), expected);
+    }
+
+    private void nextAndAssert(EditingHistory history, String expected) {
+        assertTrue(history.next());
+        assertEquals(history.current().toString(), expected);
+    }
+
+    private void previousSnippetAndAssert(EditingHistory history, String expected) {
+        assertTrue(history.previousSnippet());
+        assertEquals(history.current().toString(), expected);
+    }
+
+    private void nextSnippetAndAssert(EditingHistory history, String expected) {
+        assertTrue(history.nextSnippet());
+        assertEquals(history.current().toString(), expected);
+    }
+
+}
--- a/jdk/test/jdk/modules/scenarios/overlappingpackages/OverlappingPackagesTest.java	Thu May 19 17:48:02 2016 +0000
+++ b/jdk/test/jdk/modules/scenarios/overlappingpackages/OverlappingPackagesTest.java	Thu May 19 19:46:20 2016 +0000
@@ -66,13 +66,7 @@
         }
         Path srcMisc = SRC_DIR.resolve("misc");
         Path modsMisc = MODS_DIR.resolve("misc");
-        assertTrue(CompilerUtils.compile(srcMisc.resolve("sun")
-                                                .resolve("misc")
-                                                .resolve("Unsafe.java"),
-                                         modsMisc,
-                                         "-Xmodule:java.base"));
-        assertTrue(CompilerUtils.compile(srcMisc.resolve("module-info.java"),
-                                         modsMisc));
+        assertTrue(CompilerUtils.compile(srcMisc, modsMisc));
     }
 
     /**
@@ -92,7 +86,7 @@
 
     /**
      * Run the test with "-addmods misc", the misc module has package
-     * sun.misc and so should overlap with the base module.
+     * jdk.internal.misc and so should overlap with the base module.
      */
     public void testOverlapWithBaseModule() throws Exception {
         int exitValue
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/jdk/test/jdk/modules/scenarios/overlappingpackages/src/misc/jdk/internal/misc/Unsafe.java	Thu May 19 19:46:20 2016 +0000
@@ -0,0 +1,32 @@
+/*
+ * Copyright (c) 2015, Oracle and/or its affiliates. All rights reserved.
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * This code is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License version 2 only, as
+ * published by the Free Software Foundation.
+ *
+ * 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.internal.misc;
+
+public class Unsafe {
+    private Unsafe() { }
+
+    public static long getLong(long address) {
+        return 0L;
+    }
+}
--- a/jdk/test/jdk/modules/scenarios/overlappingpackages/src/misc/module-info.java	Thu May 19 17:48:02 2016 +0000
+++ b/jdk/test/jdk/modules/scenarios/overlappingpackages/src/misc/module-info.java	Thu May 19 19:46:20 2016 +0000
@@ -22,6 +22,6 @@
  */
 
 module misc {
-    exports sun.misc;
+    exports jdk.internal.misc;
 }
 
--- a/jdk/test/jdk/modules/scenarios/overlappingpackages/src/misc/sun/misc/Unsafe.java	Thu May 19 17:48:02 2016 +0000
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,32 +0,0 @@
-/*
- * Copyright (c) 2015, Oracle and/or its affiliates. All rights reserved.
- * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
- *
- * This code is free software; you can redistribute it and/or modify it
- * under the terms of the GNU General Public License version 2 only, as
- * published by the Free Software Foundation.
- *
- * 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 sun.misc;
-
-public class Unsafe {
-    private Unsafe() { }
-
-    public static long getLong(long address) {
-        return 0L;
-    }
-}
--- a/jdk/test/lib/testlibrary/CompilerUtils.java	Thu May 19 17:48:02 2016 +0000
+++ b/jdk/test/lib/testlibrary/CompilerUtils.java	Thu May 19 19:46:20 2016 +0000
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2015, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2015, 2016, 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
@@ -50,13 +50,21 @@
      *
      * @return true if the compilation is successful
      *
-     * @throws IOException if there is an I/O error scanning the source tree or
-     *                     creating the destination directory
+     * @throws IOException
+     *         if there is an I/O error scanning the source tree or
+     *         creating the destination directory
+     * @throws UnsupportedOperationException
+     *         if there is no system java compiler
      */
     public static boolean compile(Path source, Path destination, String ... options)
         throws IOException
     {
         JavaCompiler compiler = ToolProvider.getSystemJavaCompiler();
+        if (compiler == null) {
+            // no compiler available
+            throw new UnsupportedOperationException("Unable to get system java compiler. " +
+                "Perhaps, jdk.compiler module is not available.");
+        }
         StandardJavaFileManager jfm = compiler.getStandardFileManager(null, null, null);
 
         List<Path> sources
--- a/jdk/test/sun/applet/DeprecatedAppletViewer/DeprecatedAppletViewer.java	Thu May 19 17:48:02 2016 +0000
+++ b/jdk/test/sun/applet/DeprecatedAppletViewer/DeprecatedAppletViewer.java	Thu May 19 19:46:20 2016 +0000
@@ -32,17 +32,18 @@
  */
 public final class DeprecatedAppletViewer {
 
-    private static final String TEXT = "AppletViewer is deprecated.";
+    private static final String TEXT
+            = "Warning: Applet API and AppletViewer are deprecated.";
 
     public static void main(final String[] args) {
-        final PrintStream old = System.out;
+        final PrintStream old = System.err;
         final ByteArrayOutputStream baos = new ByteArrayOutputStream(1000);
         final PrintStream ps = new PrintStream(baos);
         try {
-            System.setOut(ps);
+            System.setErr(ps);
             sun.applet.Main.main(new String[]{});
         } finally {
-            System.setOut(old);
+            System.setErr(old);
         }
 
         final String text = new String(baos.toByteArray());
--- a/jdk/test/sun/net/www/protocol/https/HttpsURLConnection/ImpactOnSNI.java	Thu May 19 17:48:02 2016 +0000
+++ b/jdk/test/sun/net/www/protocol/https/HttpsURLConnection/ImpactOnSNI.java	Thu May 19 19:46:20 2016 +0000
@@ -235,6 +235,7 @@
                 hostname);
         // Ignore the test if the hostname does not sound like a domain name.
         if ((hostname == null) || hostname.isEmpty() ||
+                !hostname.contains(".") || hostname.endsWith(".") ||
                 hostname.startsWith("localhost") ||
                 Character.isDigit(hostname.charAt(hostname.length() - 1))) {
 
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/jdk/test/sun/security/provider/PolicyFile/BadPolicyFile.java	Thu May 19 19:46:20 2016 +0000
@@ -0,0 +1,51 @@
+/*
+ * Copyright (c) 2016, 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 8150468
+ * @summary check that a badly formatted policy file is handled correctly
+ * @run main/othervm BadPolicyFile
+ */
+
+import java.io.File;
+import java.net.URI;
+import java.security.AccessControlException;
+import java.security.Policy;
+import java.security.URIParameter;
+
+public class BadPolicyFile {
+
+    public static void main(String[] args) throws Exception {
+        URI uri = new File(System.getProperty("test.src", "."),
+                           "BadPolicyFile.policy").toURI();
+        Policy.setPolicy(Policy.getInstance("JavaPolicy", new URIParameter(uri)));
+        System.setSecurityManager(new SecurityManager());
+        try {
+            String javahome = System.getProperty("java.home");
+            throw new Exception("Expected AccessControlException");
+        } catch (AccessControlException ace) {
+            System.out.println("Test PASSED");
+        }
+    }
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/jdk/test/sun/security/provider/PolicyFile/BadPolicyFile.policy	Thu May 19 19:46:20 2016 +0000
@@ -0,0 +1,4 @@
+grant {
+    // permission statement is missing trailing semi-colon
+    permission "java.util.PropertyPermission" "java.home", "read"
+};
--- a/jdk/test/sun/security/provider/SecureRandom/StrongSecureRandom.java	Thu May 19 17:48:02 2016 +0000
+++ b/jdk/test/sun/security/provider/SecureRandom/StrongSecureRandom.java	Thu May 19 19:46:20 2016 +0000
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2013, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2013, 2016, 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
@@ -21,11 +21,11 @@
  * questions.
  */
 
-/**
+/*
  * @test
- * @bug 6425477
+ * @bug 6425477 8141039
  * @summary Better support for generation of high entropy random numbers
- * @run main/othervm StrongSecureRandom
+ * @run main StrongSecureRandom
  */
 import java.security.*;
 import java.util.*;
@@ -35,7 +35,10 @@
  */
 public class StrongSecureRandom {
 
-    private static String os = System.getProperty("os.name", "unknown");
+    private static final String os = System.getProperty("os.name", "unknown");
+    private static final String DRBG_CONFIG = "securerandom.drbg.config";
+    private static final String DRBG_CONFIG_VALUE
+            = Security.getProperty(DRBG_CONFIG);
 
     private static void testDefaultEgd() throws Exception {
         // No SecurityManager installed.
@@ -47,31 +50,53 @@
         }
     }
 
-    private static void testSHA1PRNGImpl() throws Exception {
-        SecureRandom sr;
-        byte[] ba;
-
-        String urandom = "file:/dev/urandom";
+    /**
+     * Verify if the mechanism is DRBG type.
+     * @param mech Mechanism name
+     * @return True if the mechanism name is DRBG type else False.
+     */
+    private static boolean isDRBG(String mech) {
+        return mech.contains("_DRBG");
+    }
 
-        System.out.println("Testing new SeedGenerator and EGD");
+    private static void testSecureRandomImpl(String algo, boolean drbg)
+            throws Exception {
 
-        Security.setProperty("securerandom.source", urandom);
-        if (!Security.getProperty("securerandom.source").equals(urandom)) {
-            throw new Exception("Couldn't set securerandom.source");
-        }
+        byte[] ba;
+        final String secureRandomSource
+                = Security.getProperty("securerandom.source");
+        try {
+            String urandom = "file:/dev/urandom";
+
+            System.out.println("Testing new SeedGenerator and EGD");
 
-        /*
-         * Take out a large number of bytes in hopes of blocking.
-         * Don't expect this to happen, unless something is broken on Linux
-         */
-        sr = SecureRandom.getInstance("SHA1PRNG");
-        if (!sr.getAlgorithm().equals("SHA1PRNG")) {
-            throw new Exception("sr.getAlgorithm(): " + sr.getAlgorithm());
+            Security.setProperty("securerandom.source", urandom);
+            if (!Security.getProperty("securerandom.source").equals(urandom)) {
+                throw new Exception("Couldn't set securerandom.source");
+            }
+
+            /*
+             * Take out a large number of bytes in hopes of blocking.
+             * Don't expect this to happen, unless something is broken on Linux
+             */
+            SecureRandom sr = null;
+            if (drbg) {
+                Security.setProperty(DRBG_CONFIG, algo);
+                sr = SecureRandom.getInstance("DRBG");
+            } else {
+                sr = SecureRandom.getInstance(algo);
+            }
+            if (!sr.getAlgorithm().equals(isDRBG(algo) ? "DRBG" : algo)) {
+                throw new Exception("sr.getAlgorithm(): " + sr.getAlgorithm());
+            }
+
+            ba = sr.generateSeed(4096);
+            sr.nextBytes(ba);
+            sr.setSeed(ba);
+        } finally {
+            Security.setProperty("securerandom.source", secureRandomSource);
+            Security.setProperty(DRBG_CONFIG, DRBG_CONFIG_VALUE);
         }
-
-        ba = sr.generateSeed(4096);
-        sr.nextBytes(ba);
-        sr.setSeed(ba);
     }
 
     private static void testNativePRNGImpls() throws Exception {
@@ -85,7 +110,7 @@
             return;
         }
 
-        System.out.println("    Testing regular");
+        System.out.println("Testing regular");
         sr = SecureRandom.getInstance("NativePRNG");
         if (!sr.getAlgorithm().equals("NativePRNG")) {
             throw new Exception("sr.getAlgorithm(): " + sr.getAlgorithm());
@@ -94,7 +119,7 @@
         sr.nextBytes(ba);
         sr.setSeed(ba);
 
-        System.out.println("    Testing NonBlocking");
+        System.out.println("Testing NonBlocking");
         sr = SecureRandom.getInstance("NativePRNGNonBlocking");
         if (!sr.getAlgorithm().equals("NativePRNGNonBlocking")) {
             throw new Exception("sr.getAlgorithm(): " + sr.getAlgorithm());
@@ -108,7 +133,7 @@
             return;
         }
 
-        System.out.println("    Testing Blocking");
+        System.out.println("Testing Blocking");
         sr = SecureRandom.getInstance("NativePRNGBlocking");
         if (!sr.getAlgorithm().equals("NativePRNGBlocking")) {
             throw new Exception("sr.getAlgorithm(): " + sr.getAlgorithm());
@@ -141,9 +166,15 @@
             throws Exception {
 
         System.out.println("Testing: '" + property + "' " + expected);
-
-        Security.setProperty("securerandom.strongAlgorithms", property);
-        testStrongInstance(expected);
+        final String origStrongAlgoProp
+                = Security.getProperty("securerandom.strongAlgorithms");
+        try {
+            Security.setProperty("securerandom.strongAlgorithms", property);
+            testStrongInstance(expected);
+        } finally {
+            Security.setProperty(
+                    "securerandom.strongAlgorithms", origStrongAlgoProp);
+        }
     }
 
     private static void testProperties() throws Exception {
@@ -228,7 +259,10 @@
 
     public static void main(String args[]) throws Exception {
         testDefaultEgd();
-        testSHA1PRNGImpl();
+        for (String algo : new String[]{
+            "SHA1PRNG", "Hash_DRBG", "HMAC_DRBG", "CTR_DRBG"}) {
+            testSecureRandomImpl(algo, isDRBG(algo));
+        }
         testNativePRNGImpls();
         testAllImpls();
 
--- a/jdk/test/sun/security/provider/SeedGenerator/SeedGeneratorChoice.java	Thu May 19 17:48:02 2016 +0000
+++ b/jdk/test/sun/security/provider/SeedGenerator/SeedGeneratorChoice.java	Thu May 19 19:46:20 2016 +0000
@@ -1,5 +1,6 @@
 /*
- * Copyright (c) 2010, 2011, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2010, 2011, 2016, Oracle and/or its affiliates. All rights
+ * reserved.
  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
  *
  * This code is free software; you can redistribute it and/or modify it
@@ -23,7 +24,7 @@
 
 /*
  * @test
- * @bug 6998583
+ * @bug 6998583 8141039
  * @summary NativeSeedGenerator is making 8192 byte read requests from
  *             entropy pool on each init.
  * @run main SeedGeneratorChoice
@@ -39,14 +40,24 @@
  * We should always fall back to the ThreadedSeedGenerator if exceptions
  * are encountered with user defined source of entropy.
  */
-
 import java.security.SecureRandom;
+import java.security.Security;
 
 public class SeedGeneratorChoice {
 
     public static void main(String... arguments) throws Exception {
-        byte[] bytes;
-        SecureRandom prng = SecureRandom.getInstance("SHA1PRNG");
-        bytes = prng.generateSeed(1);
+        for (String mech : new String[]{"SHA1PRNG", "Hash_DRBG", "HMAC_DRBG",
+            "CTR_DRBG"}) {
+
+            SecureRandom prng = null;
+            if (!mech.contains("_DRBG")) {
+                prng = SecureRandom.getInstance(mech);
+            } else {
+                Security.setProperty("securerandom.drbg.config", mech);
+                prng = SecureRandom.getInstance("DRBG");
+            }
+            prng.generateSeed(1);
+        }
     }
+
 }
--- a/jdk/test/sun/security/rsa/SpecTest.java	Thu May 19 17:48:02 2016 +0000
+++ b/jdk/test/sun/security/rsa/SpecTest.java	Thu May 19 19:46:20 2016 +0000
@@ -24,7 +24,6 @@
 /**
  * @test
  * @bug 8044199 8137231
- * @key intermittent
  * @summary Check same KeyPair's private key and public key have same modulus.
  * also check public key's public exponent equals to given spec's public
  * exponent. Only key size 1024 is tested with RSAKeyGenParameterSpec.F0 (3).
--- a/jdk/test/sun/tools/jhsdb/BasicLauncherTest.java	Thu May 19 17:48:02 2016 +0000
+++ b/jdk/test/sun/tools/jhsdb/BasicLauncherTest.java	Thu May 19 19:46:20 2016 +0000
@@ -31,9 +31,12 @@
  * @run main BasicLauncherTest
  */
 
+import static jdk.testlibrary.Asserts.assertTrue;
+
 import java.io.BufferedReader;
 import java.io.IOException;
 import java.io.InputStreamReader;
+import java.io.File;
 import java.util.ArrayList;
 import java.util.List;
 import java.util.Arrays;
@@ -99,7 +102,7 @@
 
         System.out.println("Starting LingeredApp");
         try {
-            theApp = LingeredApp.startApp();
+            theApp = LingeredApp.startApp(Arrays.asList("-Xmx256m"));
 
             System.out.println("Starting " + toolName + " " + toolArgs.get(0) + " against " + theApp.getPid());
             JDKToolLauncher launcher = JDKToolLauncher.createUsingTestJDK(toolName);
@@ -129,6 +132,21 @@
         launch(expectedMessage, Arrays.asList(toolArgs));
     }
 
+    public static void testHeapDump() throws IOException {
+        File dump = new File("jhsdb.jmap.dump." +
+                             System.currentTimeMillis() + ".hprof");
+        if (dump.exists()) {
+            dump.delete();
+        }
+        dump.deleteOnExit();
+
+        launch("heap written to", "jmap",
+               "--binaryheap", "--dumpfile=" + dump.getAbsolutePath());
+
+        assertTrue(dump.exists() && dump.isFile(),
+                   "Could not create dump file " + dump.getAbsolutePath());
+    }
+
     public static void main(String[] args)
         throws IOException {
 
@@ -145,6 +163,8 @@
         launch("Java System Properties", "jinfo");
         launch("java.threads", "jsnap");
 
+        testHeapDump();
+
         // The test throws RuntimeException on error.
         // IOException is thrown if LingeredApp can't start because of some bad
         // environment condition
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/jdk/test/sun/tools/jhsdb/heapconfig/JMapHeapConfigTest.java	Thu May 19 19:46:20 2016 +0000
@@ -0,0 +1,166 @@
+/*
+ * Copyright (c) 2015, Oracle and/or its affiliates. All rights reserved.
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * This code is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License version 2 only, as
+ * published by the Free Software Foundation.
+ *
+ * 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.
+ */
+
+import java.io.IOException;
+import java.math.BigDecimal;
+import java.util.ArrayList;
+import java.util.HashMap;
+import java.util.List;
+import java.util.Map;
+
+import jdk.test.lib.apps.LingeredApp;
+import jdk.testlibrary.Utils;
+import jdk.testlibrary.Platform;
+
+/*
+ * @test
+ * @bug 8042397
+ * @summary Unit test for jmap utility test heap configuration reader
+ * @modules jdk.hotspot.agent/sun.jvm.hotspot
+ * @library /test/lib/share/classes
+ * @library /lib/testlibrary
+ * @build jdk.testlibrary.*
+ * @build jdk.test.lib.apps.*
+ * @build JMapHeapConfigTest TmtoolTestScenario
+ * @run main JMapHeapConfigTest
+ */
+public class JMapHeapConfigTest {
+
+    static final String expectedJMapValues[] = {
+        "MinHeapFreeRatio",
+        "MaxHeapFreeRatio",
+        "MaxHeapSize",
+        "NewSize",
+        "MaxNewSize",
+        "OldSize",
+        "NewRatio",
+        "SurvivorRatio",
+        "MetaspaceSize",
+        "CompressedClassSpaceSize",
+        "G1HeapRegionSize"};
+
+    // ignoring MaxMetaspaceSize
+
+    static final String desiredMaxHeapSize = "-Xmx128m";
+
+    private static Map<String, String> parseJMapOutput(List<String> jmapOutput) {
+        Map<String, String> heapConfigMap = new HashMap<String, String>();
+        boolean shouldParse = false;
+
+        for (String line : jmapOutput) {
+            line = line.trim();
+
+            if (line.startsWith("Heap Configuration:")) {
+                shouldParse = true;
+                continue;
+            }
+
+            if (line.startsWith("Heap Usage:")) {
+                shouldParse = false;
+                continue;
+            }
+
+            if (shouldParse && !line.equals("")) {
+                String[] lv = line.split("\\s+");
+                try {
+                    heapConfigMap.put(lv[0], lv[2]);
+                } catch (ArrayIndexOutOfBoundsException ex) {
+                    // Ignore mailformed lines
+                }
+            }
+        }
+        return heapConfigMap;
+    }
+
+    // Compare stored values
+    private static void compareValues(Map<String, String> parsedJMapOutput, Map<String, String> parsedVmOutput) {
+        for (String key : expectedJMapValues) {
+            try {
+                String jmapVal = parsedJMapOutput.get(key);
+                if (jmapVal == null) {
+                    throw new RuntimeException("Key '" + key + "' doesn't exists in jmap output");
+                }
+
+                String vmVal = parsedVmOutput.get(key);
+                if (vmVal == null) {
+                    throw new RuntimeException("Key '" + key + "' doesn't exists in vm output");
+                }
+
+                if (new BigDecimal(jmapVal).compareTo(new BigDecimal(vmVal)) != 0) {
+                    throw new RuntimeException(String.format("Key %s doesn't match %s vs %s", key, vmVal, jmapVal));
+                }
+            } catch (NumberFormatException ex) {
+                throw new RuntimeException("Unexpected key '" + key + "' value", ex);
+            }
+        }
+    }
+
+    public static void main(String[] args) throws Exception {
+        System.out.println("Starting JMapHeapConfigTest");
+
+        if (!Platform.shouldSAAttach()) {
+            // Silently skip the test if we don't have enough permissions to attach
+            System.err.println("Error! Insufficient permissions to attach.");
+            return;
+        }
+
+        if (!LingeredApp.isLastModifiedWorking()) {
+            // Exact behaviour of the test depends to operating system and the test nature,
+            // so just print the warning and continue
+            System.err.println("Warning! Last modified time doesn't work.");
+        }
+
+        boolean mx_found = false;
+        List<String> jvmOptions = Utils.getVmOptions();
+        for (String option : jvmOptions) {
+            if (option.startsWith("-Xmx")) {
+               System.out.println("INFO: maximum heap size set by JTREG as " + option);
+               mx_found = true;
+               break;
+           }
+        }
+
+        // Forward vm options to LingeredApp
+        ArrayList<String> cmd = new ArrayList();
+        cmd.addAll(Utils.getVmOptions());
+        if (!mx_found) {
+            cmd.add(desiredMaxHeapSize);
+            System.out.println("INFO: maximum heap size set explicitly as " + desiredMaxHeapSize);
+        }
+        cmd.add("-XX:+PrintFlagsFinal");
+
+        TmtoolTestScenario tmt = TmtoolTestScenario.create("jmap", "--heap");
+        int exitcode = tmt.launch(cmd);
+        if (exitcode != 0) {
+            throw new RuntimeException("Test FAILED jmap exits with non zero exit code " + exitcode);
+        }
+
+        Map<String,String> parsedJmapOutput = parseJMapOutput(tmt.getToolOutput());
+        Map<String,String> parsedVMOutput = tmt.parseFlagsFinal();
+
+        compareValues(parsedJmapOutput, parsedVMOutput);
+
+        // If test fails it throws RuntimeException
+        System.out.println("Test PASSED");
+    }
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/jdk/test/sun/tools/jhsdb/heapconfig/TmtoolTestScenario.java	Thu May 19 19:46:20 2016 +0000
@@ -0,0 +1,144 @@
+/*
+ * Copyright (c) 2015, Oracle and/or its affiliates. All rights reserved.
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * This code is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License version 2 only, as
+ * published by the Free Software Foundation.
+ *
+ * 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.
+ */
+import java.io.BufferedReader;
+import java.io.IOException;
+import java.io.InputStreamReader;
+import java.math.BigDecimal;
+import java.util.ArrayList;
+import java.util.Arrays;
+import java.util.HashMap;
+import java.util.List;
+import java.util.Map;
+import java.util.logging.Level;
+import java.util.logging.Logger;
+
+import jdk.test.lib.apps.LingeredApp;
+import jdk.testlibrary.JDKToolLauncher;
+import jdk.testlibrary.Utils;
+
+public class TmtoolTestScenario {
+
+    private final ArrayList<String> toolOutput = new ArrayList<String>();
+    private LingeredApp theApp = null;
+    private final String toolName;
+    private final String[] toolArgs;
+
+    /**
+     *  @param toolName - name of tool to test
+     *  @param toolArgs - tool arguments
+     *  @return the object
+     */
+    public static TmtoolTestScenario create(String toolName, String... toolArgs) {
+        return new TmtoolTestScenario(toolName, toolArgs);
+    }
+
+    /**
+     * @return STDOUT of tool
+     */
+    public List<String> getToolOutput() {
+        return toolOutput;
+    }
+
+    /**
+     *
+     * @return STDOUT of test app
+     */
+    public List<String> getAppOutput() {
+        return theApp.getAppOutput();
+    }
+
+    /**
+     * @return Value of the app output with -XX:+PrintFlagsFinal as a map.
+     */
+    public Map<String, String>  parseFlagsFinal() {
+        List<String> astr = theApp.getAppOutput();
+        Map<String, String> vmMap = new HashMap<String, String>();
+
+        for (String line : astr) {
+            String[] lv = line.trim().split("\\s+");
+            try {
+                vmMap.put(lv[1], lv[3]);
+            } catch (ArrayIndexOutOfBoundsException ex) {
+                // ignore mailformed lines
+            }
+        }
+        return vmMap;
+    }
+
+    /**
+     *
+     * @param vmArgs  - vm and java arguments to launch test app
+     * @return exit code of tool
+     */
+    public int launch(List<String> vmArgs) {
+        System.out.println("Starting LingeredApp");
+        try {
+            try {
+                List<String> vmArgsExtended = new ArrayList<String>();
+                vmArgsExtended.add("-XX:+UsePerfData");
+                vmArgsExtended.addAll(vmArgs);
+                theApp = LingeredApp.startApp(vmArgsExtended);
+
+                System.out.println("Starting " + toolName + " against " + theApp.getPid());
+                JDKToolLauncher launcher = JDKToolLauncher.createUsingTestJDK("jhsdb");
+                launcher.addToolArg(toolName);
+
+                for (String cmd : toolArgs) {
+                    launcher.addToolArg(cmd);
+                }
+                launcher.addToolArg("--pid");
+                launcher.addToolArg(Long.toString(theApp.getPid()));
+
+                ProcessBuilder processBuilder = new ProcessBuilder(launcher.getCommand());
+                processBuilder.redirectError(ProcessBuilder.Redirect.INHERIT);
+                Process toolProcess = processBuilder.start();
+
+                // By default child process output stream redirected to pipe, so we are reading it in foreground.
+                BufferedReader reader = new BufferedReader(new InputStreamReader(toolProcess.getInputStream()));
+
+                String line;
+                while ((line = reader.readLine()) != null) {
+                    toolOutput.add(line.trim());
+                }
+
+                toolProcess.waitFor();
+
+                return toolProcess.exitValue();
+            } finally {
+                LingeredApp.stopApp(theApp);
+            }
+        } catch (IOException | InterruptedException ex) {
+            throw new RuntimeException("Test ERROR " + ex, ex);
+        }
+    }
+
+    public void launch(String... appArgs) throws IOException {
+        launch(Arrays.asList(appArgs));
+    }
+
+    private TmtoolTestScenario(String toolName, String[] toolArgs) {
+        this.toolName = toolName;
+        this.toolArgs = toolArgs;
+    }
+
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/jdk/test/sun/tools/jinfo/BasicJInfoTest.java	Thu May 19 19:46:20 2016 +0000
@@ -0,0 +1,89 @@
+/*
+ * Copyright (c) 2005, 2016, 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.
+ */
+
+import java.util.Arrays;
+
+import jdk.testlibrary.JDKToolLauncher;
+import jdk.testlibrary.OutputAnalyzer;
+import jdk.testlibrary.ProcessTools;
+
+/*
+ * @test
+ * @summary Unit test for jinfo utility
+ * @library /lib/testlibrary
+ * @build jdk.testlibrary.*
+ * @run main BasicJInfoTest
+ */
+public class BasicJInfoTest {
+
+    private static ProcessBuilder processBuilder = new ProcessBuilder();
+
+    public static void main(String[] args) throws Exception {
+        testJinfoNoArgs();
+        testJinfoFlags();
+        testJinfoProps();
+        testJinfoFlagInvalid();
+    }
+
+    private static void testJinfoNoArgs() throws Exception {
+        OutputAnalyzer output = jinfo();
+        output.shouldContain("-XX");
+        output.shouldContain("test.jdk=");
+        output.shouldHaveExitValue(0);
+    }
+
+    private static void testJinfoFlagInvalid() throws Exception {
+        OutputAnalyzer output = jinfo("-flag");
+        output.shouldHaveExitValue(1);
+    }
+
+    private static void testJinfoFlags() throws Exception {
+        OutputAnalyzer output = jinfo("-flags");
+        output.shouldContain("-XX");
+        output.shouldHaveExitValue(0);
+    }
+
+    private static void testJinfoProps() throws Exception {
+        OutputAnalyzer output = jinfo("-props");
+        output.shouldContain("test.jdk=");
+        output.shouldHaveExitValue(0);
+    }
+
+    private static OutputAnalyzer jinfo(String... toolArgs) throws Exception {
+        JDKToolLauncher launcher = JDKToolLauncher.createUsingTestJDK("jinfo");
+        if (toolArgs != null) {
+            for (String toolArg : toolArgs) {
+                launcher.addToolArg(toolArg);
+            }
+        }
+        launcher.addToolArg(Long.toString(ProcessTools.getProcessId()));
+
+        processBuilder.command(launcher.getCommand());
+        System.out.println(Arrays.toString(processBuilder.command().toArray()).replace(",", ""));
+        OutputAnalyzer output = ProcessTools.executeProcess(processBuilder);
+        System.out.println(output.getOutput());
+
+        return output;
+    }
+
+}
--- a/jdk/test/sun/tools/jinfo/JInfoHelper.java	Thu May 19 17:48:02 2016 +0000
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,74 +0,0 @@
-/*
- * Copyright (c) 2014, 2015, Oracle and/or its affiliates. All rights reserved.
- * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
- *
- * This code is free software; you can redistribute it and/or modify it
- * under the terms of the GNU General Public License version 2 only, as
- * published by the Free Software Foundation.  Oracle designates this
- * particular file as subject to the "Classpath" exception as provided
- * by Oracle in the LICENSE file that accompanied this code.
- *
- * This code is distributed in the hope that it will be useful, but WITHOUT
- * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
- * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
- * version 2 for more details (a copy is included in the LICENSE file that
- * accompanied this code).
- *
- * You should have received a copy of the GNU General Public License version
- * 2 along with this work; if not, write to the Free Software Foundation,
- * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
- *
- * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
- * or visit www.oracle.com if you need additional information or have any
- * questions.
- */
-
-import java.util.Arrays;
-
-import jdk.testlibrary.JDKToolLauncher;
-import jdk.testlibrary.OutputAnalyzer;
-import jdk.testlibrary.ProcessTools;
-
-/**
- *  The helper class for running jinfo utility.
- */
-public final class JInfoHelper {
-
-    /**
-     * Print configuration information for the current process
-     *
-     * @param toolArgs List of jinfo options
-     */
-    public static OutputAnalyzer jinfo(String... toolArgs) throws Exception {
-        return jinfo(true, toolArgs);
-    }
-
-    /**
-     * Print usage information
-     *
-     * @param toolArgs List of jinfo options
-     */
-    public static OutputAnalyzer jinfoNoPid(String... toolArgs) throws Exception {
-        return jinfo(false, toolArgs);
-    }
-
-    private static OutputAnalyzer jinfo(boolean toPid, String... toolArgs) throws Exception {
-        JDKToolLauncher launcher = JDKToolLauncher.createUsingTestJDK("jinfo");
-        if (toolArgs != null) {
-            for (String toolArg : toolArgs) {
-                launcher.addToolArg(toolArg);
-            }
-        }
-        if (toPid) {
-            launcher.addToolArg(Long.toString(ProcessTools.getProcessId()));
-        }
-
-        ProcessBuilder processBuilder = new ProcessBuilder(launcher.getCommand());
-        System.out.println(Arrays.toString(processBuilder.command().toArray()).replace(",", ""));
-        OutputAnalyzer output = ProcessTools.executeProcess(processBuilder);
-        System.out.println(output.getOutput());
-
-        return output;
-    }
-
-}
--- a/jdk/test/sun/tools/jinfo/JInfoLauncherTest.java	Thu May 19 17:48:02 2016 +0000
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,343 +0,0 @@
-/*
- * Copyright (c) 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.
- */
-
-import org.testng.annotations.Test;
-import org.testng.annotations.BeforeClass;
-import sun.tools.jinfo.JInfo;
-
-import java.lang.reflect.Constructor;
-import java.lang.reflect.Field;
-import java.util.Arrays;
-
-import static org.testng.Assert.*;
-
-/**
- * @test
- * @bug 8039080
- * @modules jdk.jcmd/sun.tools.jinfo
- * @run testng JInfoLauncherTest
- * @summary Test JInfo launcher argument parsing
- */
-@Test
-public class JInfoLauncherTest {
-    public static final String VALIDATION_EXCEPTION_CLSNAME =
-                                IllegalArgumentException.class.getName();
-
-    private Constructor<JInfo> jInfoConstructor;
-    private Field fldUseSA;
-
-    @BeforeClass
-    public void setup() throws Exception {
-        jInfoConstructor = JInfo.class.getDeclaredConstructor(String[].class);
-        jInfoConstructor.setAccessible(true);
-        fldUseSA = JInfo.class.getDeclaredField("useSA");
-        fldUseSA.setAccessible(true);
-    }
-
-    private JInfo newJInfo(String[] args) throws Exception {
-        try {
-            return jInfoConstructor.newInstance((Object) args);
-        } catch (Exception e) {
-            if (isValidationException(e.getCause())) {
-                throw (Exception)e.getCause();
-            }
-            throw e;
-        }
-    }
-
-    private boolean getUseSA(JInfo jinfo) throws Exception {
-        return fldUseSA.getBoolean(jinfo);
-    }
-
-    private void cmdPID(String cmd, String ... params) throws Exception {
-        int offset = (cmd != null ? 1 : 0);
-        String[] args = new String[offset + params.length];
-        args[0] = cmd;
-        System.arraycopy(params, 0, args, offset, params.length);
-        JInfo j = newJInfo(args);
-        assertFalse(getUseSA(j), "Local jinfo must not forward to SA");
-    }
-
-    private void cmdCore(String cmd, String ... params) throws Exception {
-        int offset = (cmd != null ? 1 : 0);
-        String[] args = new String[offset + params.length];
-        args[0] = cmd;
-        System.arraycopy(params, 0, args, offset, params.length);
-        JInfo j = newJInfo(args);
-        assertTrue(getUseSA(j), "Core jinfo must forward to SA");
-    }
-
-    private void cmdRemote(String cmd, String ... params) throws Exception {
-        int offset = (cmd != null ? 1 : 0);
-        String[] args = new String[offset + params.length];
-        args[0] = cmd;
-        System.arraycopy(params, 0, args, offset, params.length);
-        JInfo j = newJInfo(args);
-        assertTrue(getUseSA(j), "Remote jinfo must forward to SA");
-    }
-
-    private void cmdExtraArgs(String cmd, int argsLen) throws Exception {
-        String[] args = new String[argsLen + 1 + (cmd != null ? 1 : 0)];
-        Arrays.fill(args, "a");
-        if (cmd != null) {
-            args[0] = cmd;
-        } else {
-            cmd = "default";
-        }
-        try {
-            JInfo j = newJInfo(args);
-            fail("\"" + cmd + "\" does not support more than " + argsLen +
-                 " arguments");
-        } catch (Exception e) {
-            if (!isValidationException(e)) {
-                throw e;
-            }
-            // ignore
-        }
-    }
-
-    private void cmdMissingArgs(String cmd, int reqArgs) throws Exception {
-        String[] args = new String[reqArgs - 1 + (cmd != null ? 1 : 0)];
-        Arrays.fill(args, "a");
-        if (cmd != null) {
-            args[0] = cmd;
-        } else {
-            cmd = "default";
-        }
-        try {
-            JInfo j = newJInfo(args);
-            fail("\"" + cmd + "\" requires at least " + reqArgs + " argument");
-        } catch (Exception e) {
-            if (!isValidationException(e)) {
-                throw e;
-            }
-            // ignore
-        }
-    }
-
-    public void testDefaultPID() throws Exception {
-        cmdPID(null, "1234");
-    }
-
-    public void testFlagsPID() throws Exception {
-        cmdPID("-flags", "1234");
-    }
-
-    public void testSyspropsPID() throws Exception {
-        cmdPID("-sysprops", "1234");
-    }
-
-    public void testReadFlagPID() throws Exception {
-        cmdPID("-flag", "SomeManagementFlag", "1234");
-    }
-
-    public void testSetFlag1PID() throws Exception {
-        cmdPID("-flag", "+SomeManagementFlag", "1234");
-    }
-
-    public void testSetFlag2PID() throws Exception {
-        cmdPID("-flag", "-SomeManagementFlag", "1234");
-    }
-
-    public void testSetFlag3PID() throws Exception {
-        cmdPID("-flag", "SomeManagementFlag=314", "1234");
-    }
-
-    public void testDefaultCore() throws Exception {
-        cmdCore(null, "myapp.exe", "my.core");
-    }
-
-    public void testFlagsCore() throws Exception {
-        cmdCore("-flags", "myapp.exe", "my.core");
-    }
-
-    public void testSyspropsCore() throws Exception {
-        cmdCore("-sysprops", "myapp.exe", "my.core");
-    }
-
-    public void testReadFlagCore() throws Exception {
-        try {
-            cmdCore("-flag", "SomeManagementFlag", "myapp.exe", "my.core");
-            fail("Flags can not be read from core files");
-        } catch (Exception e) {
-            if (!isValidationException(e)) {
-                throw e;
-            }
-            // ignore
-        }
-    }
-
-    public void testSetFlag1Core() throws Exception {
-        try {
-            cmdCore("-flag", "+SomeManagementFlag", "myapp.exe", "my.core");
-            fail("Flags can not be set in core files");
-        } catch (Exception e) {
-            if (!isValidationException(e)) {
-                throw e;
-            }
-            // ignore
-        }
-    }
-
-    public void testSetFlag2Core() throws Exception {
-        try {
-            cmdCore("-flag", "-SomeManagementFlag", "myapp.exe", "my.core");
-            fail("Flags can not be set in core files");
-        } catch (Exception e) {
-            if (!isValidationException(e)) {
-                throw e;
-            }
-            // ignore
-        }
-    }
-
-    public void testSetFlag3Core() throws Exception {
-        try {
-            cmdCore("-flag", "SomeManagementFlag=314", "myapp.exe", "my.core");
-            fail("Flags can not be set in core files");
-        } catch (Exception e) {
-            if (!isValidationException(e)) {
-                throw e;
-            }
-            // ignore
-        }
-    }
-
-    public void testDefaultRemote() throws Exception {
-        cmdRemote(null, "serverid@host");
-    }
-
-    public void testFlagsRemote() throws Exception {
-        cmdRemote("-flags", "serverid@host");
-    }
-
-    public void testSyspropsRemote() throws Exception {
-        cmdRemote("-sysprops", "serverid@host");
-    }
-
-    public void testReadFlagRemote() throws Exception {
-        try {
-            cmdCore("-flag", "SomeManagementFlag", "serverid@host");
-            fail("Flags can not be read from SA server");
-        } catch (Exception e) {
-            if (!isValidationException(e)) {
-                throw e;
-            }
-            // ignore
-        }
-    }
-
-    public void testSetFlag1Remote() throws Exception {
-        try {
-            cmdCore("-flag", "+SomeManagementFlag","serverid@host");
-            fail("Flags can not be set on SA server");
-        } catch (Exception e) {
-            if (!isValidationException(e)) {
-                throw e;
-            }
-            // ignore
-        }
-    }
-
-    public void testSetFlag2Remote() throws Exception {
-        try {
-            cmdCore("-flag", "-SomeManagementFlag", "serverid@host");
-            fail("Flags can not be read set on SA server");
-        } catch (Exception e) {
-            if (!isValidationException(e)) {
-                throw e;
-            }
-            // ignore
-        }
-    }
-
-    public void testSetFlag3Remote() throws Exception {
-        try {
-            cmdCore("-flag", "SomeManagementFlag=314", "serverid@host");
-            fail("Flags can not be read set on SA server");
-        } catch (Exception e) {
-            if (!isValidationException(e)) {
-                throw e;
-            }
-            // ignore
-        }
-    }
-
-    public void testDefaultExtraArgs() throws Exception {
-        cmdExtraArgs(null, 2);
-    }
-
-    public void testFlagsExtraArgs() throws Exception {
-        cmdExtraArgs("-flags", 2);
-    }
-
-    public void testSyspropsExtraArgs() throws Exception {
-        cmdExtraArgs("-sysprops", 2);
-    }
-
-    public void testFlagExtraArgs() throws Exception {
-        cmdExtraArgs("-flag", 2);
-    }
-
-    public void testHelp1ExtraArgs() throws Exception {
-        cmdExtraArgs("-h", 0);
-    }
-
-    public void testHelp2ExtraArgs() throws Exception {
-        cmdExtraArgs("-help", 0);
-    }
-
-    public void testDefaultMissingArgs() throws Exception {
-        cmdMissingArgs(null, 1);
-    }
-
-    public void testFlagsMissingArgs() throws Exception {
-        cmdMissingArgs("-flags", 1);
-    }
-
-    public void testSyspropsMissingArgs() throws Exception {
-        cmdMissingArgs("-sysprops", 1);
-    }
-
-    public void testFlagMissingArgs() throws Exception {
-        cmdMissingArgs("-flag", 2);
-    }
-
-    public void testUnknownCommand() throws Exception {
-        try {
-            JInfo j = newJInfo(new String[]{"-unknown_command"});
-            fail("JInfo accepts unknown commands");
-        } catch (Exception e) {
-            if (!isValidationException(e)) {
-                throw e;
-            }
-            // ignore
-        }
-    }
-
-    private static boolean isValidationException(Throwable e) {
-        return e.getClass().getName().equals(VALIDATION_EXCEPTION_CLSNAME);
-    }
-}
--- a/jdk/test/sun/tools/jinfo/JInfoRunningProcessFlagTest.java	Thu May 19 17:48:02 2016 +0000
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,129 +0,0 @@
-/*
- * Copyright (c) 2014, 2015, Oracle and/or its affiliates. All rights reserved.
- * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
- *
- * This code is free software; you can redistribute it and/or modify it
- * under the terms of the GNU General Public License version 2 only, as
- * published by the Free Software Foundation.  Oracle designates this
- * particular file as subject to the "Classpath" exception as provided
- * by Oracle in the LICENSE file that accompanied this code.
- *
- * This code is distributed in the hope that it will be useful, but WITHOUT
- * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
- * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
- * version 2 for more details (a copy is included in the LICENSE file that
- * accompanied this code).
- *
- * You should have received a copy of the GNU General Public License version
- * 2 along with this work; if not, write to the Free Software Foundation,
- * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
- *
- * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
- * or visit www.oracle.com if you need additional information or have any
- * questions.
- */
-
-import java.lang.management.ManagementFactory;
-import com.sun.management.HotSpotDiagnosticMXBean;
-import jdk.testlibrary.OutputAnalyzer;
-import static jdk.testlibrary.Platform.isSolaris;
-import static jdk.testlibrary.Asserts.assertEquals;
-import static jdk.testlibrary.Asserts.assertNotEquals;
-import static jdk.testlibrary.Asserts.assertTrue;
-
-/**
- * @test
- * @summary The test sanity checks 'jinfo -flag' option.
- * @library /lib/testlibrary
- * @modules java.management
- * @build jdk.testlibrary.* JInfoHelper
- * @run main/othervm -XX:+HeapDumpOnOutOfMemoryError JInfoRunningProcessFlagTest
- */
-public class JInfoRunningProcessFlagTest {
-
-    public static void main(String[] args) throws Exception {
-        testFlag();
-        testFlagPlus();
-        testFlagMinus();
-        testFlagEqual();
-
-        testInvalidFlag();
-
-        testSolarisSpecificFlag();
-    }
-
-    private static void testFlag() throws Exception {
-        OutputAnalyzer output = JInfoHelper.jinfo("-flag", "HeapDumpOnOutOfMemoryError");
-        output.shouldHaveExitValue(0);
-        assertTrue(output.getStderr().isEmpty(), "'jinfo -flag HeapDumpOnOutOfMemoryError' stderr should be empty");
-        output.shouldContain("+HeapDumpOnOutOfMemoryError");
-    }
-
-    private static void testFlagPlus() throws Exception {
-        OutputAnalyzer output = JInfoHelper.jinfo("-flag", "+HeapDumpOnOutOfMemoryError");
-        output.shouldHaveExitValue(0);
-        output = JInfoHelper.jinfo("-flag", "HeapDumpOnOutOfMemoryError");
-        output.shouldHaveExitValue(0);
-        output.shouldContain("+HeapDumpOnOutOfMemoryError");
-        verifyIsEnabled("HeapDumpOnOutOfMemoryError");
-    }
-
-    private static void testFlagMinus() throws Exception {
-        OutputAnalyzer output = JInfoHelper.jinfo("-flag", "-HeapDumpOnOutOfMemoryError");
-        output.shouldHaveExitValue(0);
-        output = JInfoHelper.jinfo("-flag", "HeapDumpOnOutOfMemoryError");
-        output.shouldHaveExitValue(0);
-        output.shouldContain("-HeapDumpOnOutOfMemoryError");
-        verifyIsDisabled("HeapDumpOnOutOfMemoryError");
-    }
-
-    private static void testFlagEqual() throws Exception {
-        OutputAnalyzer output = JInfoHelper.jinfo("-flag", "HeapDumpOnOutOfMemoryError=1");
-        output.shouldHaveExitValue(0);
-        output = JInfoHelper.jinfo("-flag", "HeapDumpOnOutOfMemoryError");
-        output.shouldHaveExitValue(0);
-        output.shouldContain("+HeapDumpOnOutOfMemoryError");
-        verifyIsEnabled("HeapDumpOnOutOfMemoryError");
-    }
-
-    private static void testInvalidFlag() throws Exception {
-        OutputAnalyzer output = JInfoHelper.jinfo("-flag", "monkey");
-        assertNotEquals(output.getExitValue(), 0, "A non-zero exit code should be returned for invalid flag");
-    }
-
-    private static void testSolarisSpecificFlag() throws Exception {
-        if (!isSolaris())
-            return;
-
-        OutputAnalyzer output = JInfoHelper.jinfo("-flag", "+ExtendedDTraceProbes");
-        output.shouldHaveExitValue(0);
-        output = JInfoHelper.jinfo();
-        output.shouldContain("+ExtendedDTraceProbes");
-        verifyIsEnabled("ExtendedDTraceProbes");
-
-        output = JInfoHelper.jinfo("-flag", "-ExtendedDTraceProbes");
-        output.shouldHaveExitValue(0);
-        output = JInfoHelper.jinfo();
-        output.shouldContain("-ExtendedDTraceProbes");
-        verifyIsDisabled("ExtendedDTraceProbes");
-
-        output = JInfoHelper.jinfo("-flag", "ExtendedDTraceProbes");
-        output.shouldContain("-ExtendedDTraceProbes");
-        output.shouldHaveExitValue(0);
-    }
-
-    private static void verifyIsEnabled(String flag) {
-        HotSpotDiagnosticMXBean hotspotDiagnostic =
-                ManagementFactory.getPlatformMXBean(HotSpotDiagnosticMXBean.class);
-        String flagValue = hotspotDiagnostic.getVMOption(flag).getValue();
-        assertEquals(flagValue, "true", "Expected '" + flag + "' flag be enabled");
-    }
-
-    private static void verifyIsDisabled(String flag) {
-        HotSpotDiagnosticMXBean hotspotDiagnostic =
-                ManagementFactory.getPlatformMXBean(HotSpotDiagnosticMXBean.class);
-        String flagValue = hotspotDiagnostic.getVMOption(flag).getValue();
-        assertEquals(flagValue, "false", "Expected '" + flag + "' flag be disabled");
-    }
-
-}
--- a/jdk/test/sun/tools/jinfo/JInfoRunningProcessTest.java	Thu May 19 17:48:02 2016 +0000
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,65 +0,0 @@
-/*
- * Copyright (c) 2014, 2015, Oracle and/or its affiliates. All rights reserved.
- * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
- *
- * This code is free software; you can redistribute it and/or modify it
- * under the terms of the GNU General Public License version 2 only, as
- * published by the Free Software Foundation.  Oracle designates this
- * particular file as subject to the "Classpath" exception as provided
- * by Oracle in the LICENSE file that accompanied this code.
- *
- * This code is distributed in the hope that it will be useful, but WITHOUT
- * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
- * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
- * version 2 for more details (a copy is included in the LICENSE file that
- * accompanied this code).
- *
- * You should have received a copy of the GNU General Public License version
- * 2 along with this work; if not, write to the Free Software Foundation,
- * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
- *
- * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
- * or visit www.oracle.com if you need additional information or have any
- * questions.
- */
-
-import jdk.testlibrary.OutputAnalyzer;
-import static jdk.testlibrary.Asserts.assertTrue;
-
-/**
- * @test
- * @summary The test sanity checks functionality of 'jinfo', 'jinfo -sysprops' and 'jinfo -flags'
- * @library /lib/testlibrary
- * @modules java.management
- * @build jdk.testlibrary.* JInfoHelper
- * @run main/othervm -XX:+HeapDumpOnOutOfMemoryError JInfoRunningProcessTest
- */
-public class JInfoRunningProcessTest {
-
-    public static void main(String[] args) throws Exception {
-        testNoOptions();
-        testSysprops();
-        testFlags();
-    }
-
-    private static void testNoOptions() throws Exception {
-        OutputAnalyzer output = JInfoHelper.jinfo();
-        output.shouldHaveExitValue(0);
-        assertTrue(output.getStderr().isEmpty(), "'jinfo' stderr should be empty");
-        output.shouldContain("+HeapDumpOnOutOfMemoryError");
-    }
-
-    private static void testSysprops() throws Exception {
-        OutputAnalyzer output = JInfoHelper.jinfo("-sysprops");
-        output.shouldHaveExitValue(0);
-        assertTrue(output.getStderr().isEmpty(), "'jinfo -sysprops' stderr should be empty");
-    }
-
-    private static void testFlags() throws Exception {
-        OutputAnalyzer output = JInfoHelper.jinfo("-flags");
-        output.shouldHaveExitValue(0);
-        assertTrue(output.getStderr().isEmpty(), "'jinfo -flags' stderr should be empty");
-        output.shouldContain("+HeapDumpOnOutOfMemoryError");
-    }
-
-}
--- a/jdk/test/sun/tools/jinfo/JInfoSanityTest.java	Thu May 19 17:48:02 2016 +0000
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,77 +0,0 @@
-/*
- * Copyright (c) 2014, 2015, Oracle and/or its affiliates. All rights reserved.
- * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
- *
- * This code is free software; you can redistribute it and/or modify it
- * under the terms of the GNU General Public License version 2 only, as
- * published by the Free Software Foundation.  Oracle designates this
- * particular file as subject to the "Classpath" exception as provided
- * by Oracle in the LICENSE file that accompanied this code.
- *
- * This code is distributed in the hope that it will be useful, but WITHOUT
- * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
- * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
- * version 2 for more details (a copy is included in the LICENSE file that
- * accompanied this code).
- *
- * You should have received a copy of the GNU General Public License version
- * 2 along with this work; if not, write to the Free Software Foundation,
- * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
- *
- * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
- * or visit www.oracle.com if you need additional information or have any
- * questions.
- */
-
-import static jdk.testlibrary.Asserts.assertNotEquals;
-import static jdk.testlibrary.Asserts.assertTrue;
-import static jdk.testlibrary.Asserts.assertFalse;
-import jdk.testlibrary.OutputAnalyzer;
-
-/**
- * @test
- * @summary The test sanity checks functionality of 'jinfo -h', 'jinfo -help',
- *          and verifies jinfo exits abnormally if started with invalid options.
- * @library /lib/testlibrary
- * @modules java.management
- * @build jdk.testlibrary.* JInfoHelper
- * @run main JInfoSanityTest
- */
-public class JInfoSanityTest {
-
-    public static void main(String[] args) throws Exception {
-        test_h();
-        test_help();
-        testVersion();
-        testUnknownHost();
-    }
-
-    private static void test_h() throws Exception {
-        OutputAnalyzer output = JInfoHelper.jinfoNoPid("-h");
-        output.shouldHaveExitValue(0);
-        assertFalse(output.getStderr().isEmpty(), "'jinfo -h' stderr should not be empty");
-        assertTrue(output.getStdout().isEmpty(), "'jinfo -h' stdout should be empty");
-    }
-
-    private static void test_help() throws Exception {
-        OutputAnalyzer output = JInfoHelper.jinfoNoPid("-help");
-        output.shouldHaveExitValue(0);
-        assertFalse(output.getStderr().isEmpty(), "'jinfo -help' stderr should not be empty");
-        assertTrue(output.getStdout().isEmpty(), "'jinfo -help' stdout should be empty");
-    }
-
-    private static void testVersion() throws Exception {
-        OutputAnalyzer output = JInfoHelper.jinfoNoPid("-version");
-        output.shouldHaveExitValue(1);
-        assertFalse(output.getStderr().isEmpty(), "'jinfo -version' stderr should not be empty");
-        assertTrue(output.getStdout().isEmpty(), "'jinfo -version' stdout should be empty");
-    }
-
-    private static void testUnknownHost() throws Exception {
-        String unknownHost = "Oja781nh2ev7vcvbajdg-Sda1-C";
-        OutputAnalyzer output = JInfoHelper.jinfoNoPid("med@" + unknownHost);
-        assertNotEquals(output.getExitValue(), 0, "A non-zero exit code should be returned for invalid operation");
-        output.shouldMatch(".*(Connection refused to host\\:|UnknownHostException\\:) " + unknownHost + ".*");
-    }
-
-}
--- a/jdk/test/sun/tools/jmap/BasicJMapTest.java	Thu May 19 17:48:02 2016 +0000
+++ b/jdk/test/sun/tools/jmap/BasicJMapTest.java	Thu May 19 19:46:20 2016 +0000
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2005, 2015, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2005, 2016, 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
@@ -34,12 +34,10 @@
 
 /*
  * @test
- * @bug 6321286
  * @summary Unit test for jmap utility
  * @key intermittent
  * @library /lib/testlibrary
  * @library /test/lib/share/classes
- * @modules java.management
  * @build jdk.testlibrary.*
  * @build jdk.test.lib.hprof.*
  * @build jdk.test.lib.hprof.model.*
@@ -54,6 +52,8 @@
     public static void main(String[] args) throws Exception {
         testHisto();
         testHistoLive();
+        testFinalizerInfo();
+        testClstats();
         testDump();
         testDumpLive();
     }
@@ -68,6 +68,16 @@
         output.shouldHaveExitValue(0);
     }
 
+    private static void testFinalizerInfo() throws Exception {
+        OutputAnalyzer output = jmap("-finalizerinfo");
+        output.shouldHaveExitValue(0);
+    }
+
+    private static void testClstats() throws Exception {
+        OutputAnalyzer output = jmap("-clstats");
+        output.shouldHaveExitValue(0);
+    }
+
     private static void testDump() throws Exception {
         dump(false);
     }
@@ -105,7 +115,6 @@
 
     private static OutputAnalyzer jmap(String... toolArgs) throws Exception {
         JDKToolLauncher launcher = JDKToolLauncher.createUsingTestJDK("jmap");
-        launcher.addVMArg("-XX:+UsePerfData");
         if (toolArgs != null) {
             for (String toolArg : toolArgs) {
                 launcher.addToolArg(toolArg);
--- a/jdk/test/sun/tools/jmap/heapconfig/JMapHeapConfigTest.java	Thu May 19 17:48:02 2016 +0000
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,166 +0,0 @@
-/*
- * Copyright (c) 2015, Oracle and/or its affiliates. All rights reserved.
- * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
- *
- * This code is free software; you can redistribute it and/or modify it
- * under the terms of the GNU General Public License version 2 only, as
- * published by the Free Software Foundation.
- *
- * 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.
- */
-
-import java.io.IOException;
-import java.math.BigDecimal;
-import java.util.ArrayList;
-import java.util.HashMap;
-import java.util.List;
-import java.util.Map;
-
-import jdk.test.lib.apps.LingeredApp;
-import jdk.testlibrary.Utils;
-import jdk.testlibrary.Platform;
-
-/*
- * @test
- * @bug 8042397
- * @summary Unit test for jmap utility test heap configuration reader
- * @library /test/lib/share/classes
- * @library /lib/testlibrary
- * @modules java.management
- * @build jdk.testlibrary.*
- * @build jdk.test.lib.apps.*
- * @build JMapHeapConfigTest TmtoolTestScenario
- * @run main JMapHeapConfigTest
- */
-public class JMapHeapConfigTest {
-
-    static final String expectedJMapValues[] = {
-        "MinHeapFreeRatio",
-        "MaxHeapFreeRatio",
-        "MaxHeapSize",
-        "NewSize",
-        "MaxNewSize",
-        "OldSize",
-        "NewRatio",
-        "SurvivorRatio",
-        "MetaspaceSize",
-        "CompressedClassSpaceSize",
-        "G1HeapRegionSize"};
-
-    // ignoring MaxMetaspaceSize
-
-    static final String desiredMaxHeapSize = "-Xmx128m";
-
-    private static Map<String, String> parseJMapOutput(List<String> jmapOutput) {
-        Map<String, String> heapConfigMap = new HashMap<String, String>();
-        boolean shouldParse = false;
-
-        for (String line : jmapOutput) {
-            line = line.trim();
-
-            if (line.startsWith("Heap Configuration:")) {
-                shouldParse = true;
-                continue;
-            }
-
-            if (line.startsWith("Heap Usage:")) {
-                shouldParse = false;
-                continue;
-            }
-
-            if (shouldParse && !line.equals("")) {
-                String[] lv = line.split("\\s+");
-                try {
-                    heapConfigMap.put(lv[0], lv[2]);
-                } catch (ArrayIndexOutOfBoundsException ex) {
-                    // Ignore mailformed lines
-                }
-            }
-        }
-        return heapConfigMap;
-    }
-
-    // Compare stored values
-    private static void compareValues(Map<String, String> parsedJMapOutput, Map<String, String> parsedVmOutput) {
-        for (String key : expectedJMapValues) {
-            try {
-                String jmapVal = parsedJMapOutput.get(key);
-                if (jmapVal == null) {
-                    throw new RuntimeException("Key '" + key + "' doesn't exists in jmap output");
-                }
-
-                String vmVal = parsedVmOutput.get(key);
-                if (vmVal == null) {
-                    throw new RuntimeException("Key '" + key + "' doesn't exists in vm output");
-                }
-
-                if (new BigDecimal(jmapVal).compareTo(new BigDecimal(vmVal)) != 0) {
-                    throw new RuntimeException(String.format("Key %s doesn't match %s vs %s", key, vmVal, jmapVal));
-                }
-            } catch (NumberFormatException ex) {
-                throw new RuntimeException("Unexpected key '" + key + "' value", ex);
-            }
-        }
-    }
-
-    public static void main(String[] args) throws Exception {
-        System.out.println("Starting JMapHeapConfigTest");
-
-        if (!Platform.shouldSAAttach()) {
-            // Silently skip the test if we don't have enough permissions to attach
-            System.err.println("Error! Insufficient permissions to attach.");
-            return;
-        }
-
-        if (!LingeredApp.isLastModifiedWorking()) {
-            // Exact behaviour of the test depends to operating system and the test nature,
-            // so just print the warning and continue
-            System.err.println("Warning! Last modified time doesn't work.");
-        }
-
-        boolean mx_found = false;
-        List<String> jvmOptions = Utils.getVmOptions();
-        for (String option : jvmOptions) {
-            if (option.startsWith("-Xmx")) {
-               System.out.println("INFO: maximum heap size set by JTREG as " + option);
-               mx_found = true;
-               break;
-           }
-        }
-
-        // Forward vm options to LingeredApp
-        ArrayList<String> cmd = new ArrayList();
-        cmd.addAll(Utils.getVmOptions());
-        if (!mx_found) {
-            cmd.add(desiredMaxHeapSize);
-            System.out.println("INFO: maximum heap size set explicitly as " + desiredMaxHeapSize);
-        }
-        cmd.add("-XX:+PrintFlagsFinal");
-
-        TmtoolTestScenario tmt = TmtoolTestScenario.create("jmap", "-heap");
-        int exitcode = tmt.launch(cmd);
-        if (exitcode != 0) {
-            throw new RuntimeException("Test FAILED jmap exits with non zero exit code " + exitcode);
-        }
-
-        Map<String,String> parsedJmapOutput = parseJMapOutput(tmt.getToolOutput());
-        Map<String,String> parsedVMOutput = tmt.parseFlagsFinal();
-
-        compareValues(parsedJmapOutput, parsedVMOutput);
-
-        // If test fails it throws RuntimeException
-        System.out.println("Test PASSED");
-    }
-}
--- a/jdk/test/sun/tools/jmap/heapconfig/TmtoolTestScenario.java	Thu May 19 17:48:02 2016 +0000
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,142 +0,0 @@
-/*
- * Copyright (c) 2015, Oracle and/or its affiliates. All rights reserved.
- * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
- *
- * This code is free software; you can redistribute it and/or modify it
- * under the terms of the GNU General Public License version 2 only, as
- * published by the Free Software Foundation.
- *
- * 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.
- */
-import java.io.BufferedReader;
-import java.io.IOException;
-import java.io.InputStreamReader;
-import java.math.BigDecimal;
-import java.util.ArrayList;
-import java.util.Arrays;
-import java.util.HashMap;
-import java.util.List;
-import java.util.Map;
-import java.util.logging.Level;
-import java.util.logging.Logger;
-
-import jdk.test.lib.apps.LingeredApp;
-import jdk.testlibrary.JDKToolLauncher;
-import jdk.testlibrary.Utils;
-
-public class TmtoolTestScenario {
-
-    private final ArrayList<String> toolOutput = new ArrayList<String>();
-    private LingeredApp theApp = null;
-    private final String toolName;
-    private final String[] toolArgs;
-
-    /**
-     *  @param toolName - name of tool to test
-     *  @param toolArgs - tool arguments
-     *  @return the object
-     */
-    public static TmtoolTestScenario create(String toolName, String... toolArgs) {
-        return new TmtoolTestScenario(toolName, toolArgs);
-    }
-
-    /**
-     * @return STDOUT of tool
-     */
-    public List<String> getToolOutput() {
-        return toolOutput;
-    }
-
-    /**
-     *
-     * @return STDOUT of test app
-     */
-    public List<String> getAppOutput() {
-        return theApp.getAppOutput();
-    }
-
-    /**
-     * @return Value of the app output with -XX:+PrintFlagsFinal as a map.
-     */
-    public Map<String, String>  parseFlagsFinal() {
-        List<String> astr = theApp.getAppOutput();
-        Map<String, String> vmMap = new HashMap<String, String>();
-
-        for (String line : astr) {
-            String[] lv = line.trim().split("\\s+");
-            try {
-                vmMap.put(lv[1], lv[3]);
-            } catch (ArrayIndexOutOfBoundsException ex) {
-                // ignore mailformed lines
-            }
-        }
-        return vmMap;
-    }
-
-    /**
-     *
-     * @param vmArgs  - vm and java arguments to launch test app
-     * @return exit code of tool
-     */
-    public int launch(List<String> vmArgs) {
-        System.out.println("Starting LingeredApp");
-        try {
-            try {
-                List<String> vmArgsExtended = new ArrayList<String>();
-                vmArgsExtended.add("-XX:+UsePerfData");
-                vmArgsExtended.addAll(vmArgs);
-                theApp = LingeredApp.startApp(vmArgsExtended);
-
-                System.out.println("Starting " + toolName + " against " + theApp.getPid());
-                JDKToolLauncher launcher = JDKToolLauncher.createUsingTestJDK(toolName);
-
-                for (String cmd : toolArgs) {
-                    launcher.addToolArg(cmd);
-                }
-                launcher.addToolArg(Long.toString(theApp.getPid()));
-
-                ProcessBuilder processBuilder = new ProcessBuilder(launcher.getCommand());
-                processBuilder.redirectError(ProcessBuilder.Redirect.INHERIT);
-                Process toolProcess = processBuilder.start();
-
-                // By default child process output stream redirected to pipe, so we are reading it in foreground.
-                BufferedReader reader = new BufferedReader(new InputStreamReader(toolProcess.getInputStream()));
-
-                String line;
-                while ((line = reader.readLine()) != null) {
-                    toolOutput.add(line.trim());
-                }
-
-                toolProcess.waitFor();
-
-                return toolProcess.exitValue();
-            } finally {
-                LingeredApp.stopApp(theApp);
-            }
-        } catch (IOException | InterruptedException ex) {
-            throw new RuntimeException("Test ERROR " + ex, ex);
-        }
-    }
-
-    public void launch(String... appArgs) throws IOException {
-        launch(Arrays.asList(appArgs));
-    }
-
-    private TmtoolTestScenario(String toolName, String[] toolArgs) {
-        this.toolName = toolName;
-        this.toolArgs = toolArgs;
-    }
-
-}
--- a/jdk/test/sun/tools/jstack/BasicJStackTest.java	Thu May 19 17:48:02 2016 +0000
+++ b/jdk/test/sun/tools/jstack/BasicJStackTest.java	Thu May 19 19:46:20 2016 +0000
@@ -29,10 +29,8 @@
 
 /*
  * @test
- * @bug 6260070
  * @summary Unit test for jstack utility
  * @library /lib/testlibrary
- * @modules java.management
  * @build jdk.testlibrary.*
  * @run main BasicJStackTest
  */
--- a/jdk/test/sun/tools/jstack/DeadlockDetectionTest.java	Thu May 19 17:48:02 2016 +0000
+++ b/jdk/test/sun/tools/jstack/DeadlockDetectionTest.java	Thu May 19 19:46:20 2016 +0000
@@ -39,7 +39,6 @@
  * @summary Test deadlock detection
  * @library /test/lib/share/classes
  * @library /lib/testlibrary
- * @modules java.management
  * @build jdk.testlibrary.*
  * @build jdk.test.lib.apps.*
  * @build DeadlockDetectionTest
--- a/jdk/test/sun/util/logging/PlatformLoggerTest.java	Thu May 19 17:48:02 2016 +0000
+++ b/jdk/test/sun/util/logging/PlatformLoggerTest.java	Thu May 19 19:46:20 2016 +0000
@@ -31,7 +31,6 @@
  *
  * @modules java.base/sun.util.logging
  *          java.logging/sun.util.logging.internal
- * @compile -XDignore.symbol.file PlatformLoggerTest.java
  * @run main/othervm PlatformLoggerTest
  */
 
@@ -42,25 +41,31 @@
 import static sun.util.logging.PlatformLogger.Level.*;
 
 public class PlatformLoggerTest {
+
+    static Logger logger;
+    static PlatformLogger bar;
+    static PlatformLogger goo;
+    static PlatformLogger foo;
+
     public static void main(String[] args) throws Exception {
         final String FOO_PLATFORM_LOGGER = "test.platformlogger.foo";
         final String BAR_PLATFORM_LOGGER = "test.platformlogger.bar";
         final String GOO_PLATFORM_LOGGER = "test.platformlogger.goo";
         final String BAR_LOGGER = "test.logger.bar";
-        PlatformLogger goo = PlatformLogger.getLogger(GOO_PLATFORM_LOGGER);
+        goo = PlatformLogger.getLogger(GOO_PLATFORM_LOGGER);
         // test the PlatformLogger methods
         testLogMethods(goo);
 
         // Create a platform logger using the default
-        PlatformLogger foo = PlatformLogger.getLogger(FOO_PLATFORM_LOGGER);
+        foo = PlatformLogger.getLogger(FOO_PLATFORM_LOGGER);
         checkPlatformLogger(foo, FOO_PLATFORM_LOGGER);
 
         // create a java.util.logging.Logger
         // now java.util.logging.Logger should be created for each platform logger
-        Logger logger = Logger.getLogger(BAR_LOGGER);
+        logger = Logger.getLogger(BAR_LOGGER);
         logger.setLevel(Level.WARNING);
 
-        PlatformLogger bar = PlatformLogger.getLogger(BAR_PLATFORM_LOGGER);
+        bar = PlatformLogger.getLogger(BAR_PLATFORM_LOGGER);
         checkPlatformLogger(bar, BAR_PLATFORM_LOGGER);
 
         // test the PlatformLogger methods
--- a/jdk/test/tools/jimage/VerifyJimage.java	Thu May 19 17:48:02 2016 +0000
+++ b/jdk/test/tools/jimage/VerifyJimage.java	Thu May 19 19:46:20 2016 +0000
@@ -188,7 +188,11 @@
                         String cn = removeModule(n).replaceAll("\\.class$", "").replace('/', '.');
                         count.incrementAndGet();
                         try {
+                            System.out.println("Loading " + cn);
                             Class.forName(cn, false, loader);
+                        } catch (VerifyError ve) {
+                            System.err.println("VerifyError for " + cn);
+                            failed.add(reader.imageName() + ": " + cn + " not verified: " + ve.getMessage());
                         } catch (ClassNotFoundException e) {
                             failed.add(reader.imageName() + ": " + cn + " not found");
                         }
--- a/jdk/test/tools/jlink/DefaultProviderTest.java	Thu May 19 17:48:02 2016 +0000
+++ b/jdk/test/tools/jlink/DefaultProviderTest.java	Thu May 19 19:46:20 2016 +0000
@@ -33,7 +33,7 @@
 import jdk.tools.jlink.internal.PluginRepository;
 import jdk.tools.jlink.plugin.Plugin;
 import jdk.tools.jlink.plugin.PluginException;
-import jdk.tools.jlink.plugin.Pool;
+import jdk.tools.jlink.plugin.ModulePool;
 import jdk.tools.jlink.plugin.TransformerPlugin;
 import tests.Helper;
 
@@ -65,26 +65,26 @@
         private boolean enabled = true;
 
         @Override
-        public Set<PluginType> getType() {
-            Set<PluginType> set = new HashSet<>();
-            set.add(CATEGORY.TRANSFORMER);
+        public Set<Category> getType() {
+            Set<Category> set = new HashSet<>();
+            set.add(Category.TRANSFORMER);
             return Collections.unmodifiableSet(set);
         }
 
         @Override
-        public Set<STATE> getState() {
-             return enabled ? EnumSet.of(STATE.AUTO_ENABLED, STATE.FUNCTIONAL)
-                : EnumSet.of(STATE.DISABLED);
+        public Set<State> getState() {
+             return enabled ? EnumSet.of(State.AUTO_ENABLED, State.FUNCTIONAL)
+                : EnumSet.of(State.DISABLED);
         }
 
         @Override
-        public void visit(Pool in, Pool out) {
+        public void visit(ModulePool in, ModulePool out) {
             if (!enabled) {
                 throw new PluginException(NAME + " was set");
             }
 
             DefaultProviderTest.isNewPluginsCalled = true;
-            in.visit((Pool.ModuleData content) -> {
+            in.transformAndCopy(content -> {
                 return content;
             }, out);
         }
--- a/jdk/test/tools/jlink/ImageFileCreatorTest.java	Thu May 19 17:48:02 2016 +0000
+++ b/jdk/test/tools/jlink/ImageFileCreatorTest.java	Thu May 19 19:46:20 2016 +0000
@@ -39,7 +39,7 @@
 import jdk.tools.jlink.internal.ImagePluginStack;
 import jdk.tools.jlink.plugin.ExecutableImage;
 import jdk.tools.jlink.builder.ImageBuilder;
-import jdk.tools.jlink.plugin.Pool;
+import jdk.tools.jlink.plugin.ModulePool;
 
 
 /*
@@ -47,6 +47,7 @@
  * @summary ImageFileCreator class test
  * @author Jean-Francois Denise
  * @modules jdk.jlink/jdk.tools.jlink.internal
+ *          jdk.jlink/jdk.tools.jlink.builder
  *          java.base/jdk.internal.jimage
  * @run main/othervm -verbose:gc -Xmx1g ImageFileCreatorTest
  */
@@ -214,7 +215,7 @@
             }
 
             @Override
-            public void storeFiles(Pool content) {
+            public void storeFiles(ModulePool content) {
             }
         };
 
--- a/jdk/test/tools/jlink/ImageFilePoolTest.java	Thu May 19 17:48:02 2016 +0000
+++ b/jdk/test/tools/jlink/ImageFilePoolTest.java	Thu May 19 19:46:20 2016 +0000
@@ -31,11 +31,12 @@
  */
 
 import java.io.ByteArrayInputStream;
-import jdk.tools.jlink.internal.PoolImpl;
-import jdk.tools.jlink.plugin.Pool;
-import jdk.tools.jlink.plugin.Pool.ModuleData;
-import jdk.tools.jlink.plugin.Pool.ModuleDataType;
-import jdk.tools.jlink.plugin.Pool.Visitor;
+import java.util.Optional;
+import java.util.function.Function;
+import jdk.tools.jlink.internal.ModuleEntryImpl;
+import jdk.tools.jlink.internal.ModulePoolImpl;
+import jdk.tools.jlink.plugin.ModuleEntry;
+import jdk.tools.jlink.plugin.ModulePool;
 
 public class ImageFilePoolTest {
     public static void main(String[] args) throws Exception {
@@ -50,45 +51,45 @@
     private static final String SUFFIX = "END";
 
     private void checkVisitor() throws Exception {
-        Pool input = new PoolImpl();
+        ModulePool input = new ModulePoolImpl();
         for (int i = 0; i < 1000; ++i) {
             String module = "module" + (i / 100);
             input.add(new InMemoryImageFile(module, "/" + module + "/java/class" + i,
-                    ModuleDataType.CONFIG, "class" + i));
+                    ModuleEntry.Type.CONFIG, "class" + i));
         }
-        if (input.getContent().size() != 1000) {
+        if (input.getEntryCount() != 1000) {
             throw new AssertionError();
         }
-        Pool output = new PoolImpl();
+        ModulePool output = new ModulePoolImpl();
         ResourceVisitor visitor = new ResourceVisitor();
-        input.visit(visitor, output);
+        input.transformAndCopy(visitor, output);
         if (visitor.getAmountBefore() == 0) {
             throw new AssertionError("Resources not found");
         }
-        if (visitor.getAmountBefore() != input.getContent().size()) {
+        if (visitor.getAmountBefore() != input.getEntryCount()) {
             throw new AssertionError("Number of visited resources. Expected: " +
-                    visitor.getAmountBefore() + ", got: " + input.getContent().size());
+                    visitor.getAmountBefore() + ", got: " + input.getEntryCount());
         }
-        if (visitor.getAmountAfter() != output.getContent().size()) {
+        if (visitor.getAmountAfter() != output.getEntryCount()) {
             throw new AssertionError("Number of added resources. Expected: " +
-                    visitor.getAmountAfter() + ", got: " + output.getContent().size());
+                    visitor.getAmountAfter() + ", got: " + output.getEntryCount());
         }
-        for (ModuleData outFile : output.getContent()) {
+        output.entries().forEach(outFile -> {
             String path = outFile.getPath().replaceAll(SUFFIX + "$", "");
-            ModuleData inFile = input.get(path);
-            if (inFile == null) {
+            Optional<ModuleEntry> inFile = input.findEntry(path);
+            if (!inFile.isPresent()) {
                 throw new AssertionError("Unknown resource: " + path);
             }
-        }
+        });
     }
 
-    private static class ResourceVisitor implements Visitor {
+    private static class ResourceVisitor implements Function<ModuleEntry, ModuleEntry> {
 
         private int amountBefore;
         private int amountAfter;
 
         @Override
-        public ModuleData visit(ModuleData file) {
+        public ModuleEntry apply(ModuleEntry file) {
             int index = ++amountBefore % 3;
             switch (index) {
                 case 0:
@@ -113,7 +114,7 @@
     }
 
     private void checkNegative() throws Exception {
-        PoolImpl input = new PoolImpl();
+        ModulePoolImpl input = new ModulePoolImpl();
         try {
             input.add(null);
             throw new AssertionError("NullPointerException is not thrown");
@@ -126,30 +127,30 @@
         } catch (NullPointerException e) {
             // expected
         }
-        if (input.get("unknown") != null) {
-            throw new AssertionError("ImageFilePool does not return null for unknown file");
+        if (input.findEntry("unknown").isPresent()) {
+            throw new AssertionError("ImageFileModulePool does not return null for unknown file");
         }
-        if (input.contains(new InMemoryImageFile("", "unknown", ModuleDataType.CONFIG, "unknown"))) {
+        if (input.contains(new InMemoryImageFile("", "unknown", ModuleEntry.Type.CONFIG, "unknown"))) {
             throw new AssertionError("'contain' returns true for unknown file");
         }
-        input.add(new InMemoryImageFile("", "/aaa/bbb", ModuleDataType.CONFIG, ""));
+        input.add(new InMemoryImageFile("", "/aaa/bbb", ModuleEntry.Type.CONFIG, ""));
         try {
-            input.add(new InMemoryImageFile("", "/aaa/bbb", ModuleDataType.CONFIG, ""));
+            input.add(new InMemoryImageFile("", "/aaa/bbb", ModuleEntry.Type.CONFIG, ""));
             throw new AssertionError("Exception expected");
         } catch (Exception e) {
             // expected
         }
         input.setReadOnly();
         try {
-            input.add(new InMemoryImageFile("", "/aaa/ccc", ModuleDataType.CONFIG, ""));
+            input.add(new InMemoryImageFile("", "/aaa/ccc", ModuleEntry.Type.CONFIG, ""));
             throw new AssertionError("Exception expected");
         } catch (Exception e) {
             // expected
         }
     }
 
-    private static class InMemoryImageFile extends ModuleData {
-        public InMemoryImageFile(String module, String path, ModuleDataType type, String content) {
+    private static class InMemoryImageFile extends ModuleEntryImpl {
+        public InMemoryImageFile(String module, String path, ModuleEntry.Type type, String content) {
             super(module, path, type, new ByteArrayInputStream(content.getBytes()), content.getBytes().length);
         }
     }
--- a/jdk/test/tools/jlink/IntegrationTest.java	Thu May 19 17:48:02 2016 +0000
+++ b/jdk/test/tools/jlink/IntegrationTest.java	Thu May 19 19:46:20 2016 +0000
@@ -39,7 +39,7 @@
 import jdk.tools.jlink.Jlink.PluginsConfiguration;
 import jdk.tools.jlink.builder.DefaultImageBuilder;
 import jdk.tools.jlink.plugin.ExecutableImage;
-import jdk.tools.jlink.plugin.Pool;
+import jdk.tools.jlink.plugin.ModulePool;
 import jdk.tools.jlink.plugin.PostProcessorPlugin;
 import jdk.tools.jlink.plugin.TransformerPlugin;
 import jdk.tools.jlink.internal.plugins.DefaultCompressPlugin;
@@ -56,6 +56,8 @@
  * @library ../lib
  * @modules java.base/jdk.internal.jimage
  *          jdk.jdeps/com.sun.tools.classfile
+ *          jdk.jlink/jdk.tools.jlink
+ *          jdk.jlink/jdk.tools.jlink.builder
  *          jdk.jlink/jdk.tools.jlink.internal
  *          jdk.jlink/jdk.tools.jlink.internal.plugins
  *          jdk.jlink/jdk.tools.jmod
@@ -88,9 +90,9 @@
         }
 
         @Override
-        public Set<PluginType> getType() {
-            Set<PluginType> set = new HashSet<>();
-            set.add(CATEGORY.PROCESSOR);
+        public Set<Category> getType() {
+            Set<Category> set = new HashSet<>();
+            set.add(Category.PROCESSOR);
             return Collections.unmodifiableSet(set);
         }
 
@@ -128,18 +130,18 @@
         }
 
         @Override
-        public void visit(Pool in, Pool out) {
+        public void visit(ModulePool in, ModulePool out) {
             System.err.println(NAME + index);
             ordered.add(index);
-            in.visit((file) -> {
+            in.transformAndCopy((file) -> {
                 return file;
             }, out);
         }
 
         @Override
-        public Set<PluginType> getType() {
-            Set<PluginType> set = new HashSet<>();
-            set.add(CATEGORY.TRANSFORMER);
+        public Set<Category> getType() {
+            Set<Category> set = new HashSet<>();
+            set.add(Category.TRANSFORMER);
             return Collections.unmodifiableSet(set);
         }
 
--- a/jdk/test/tools/jlink/JLinkOptimTest.java	Thu May 19 17:48:02 2016 +0000
+++ b/jdk/test/tools/jlink/JLinkOptimTest.java	Thu May 19 19:46:20 2016 +0000
@@ -23,15 +23,15 @@
 import jdk.internal.org.objectweb.asm.tree.MethodNode;
 import jdk.internal.org.objectweb.asm.tree.TryCatchBlockNode;
 import jdk.tools.jlink.internal.PluginRepository;
-import jdk.tools.jlink.internal.PoolImpl;
+import jdk.tools.jlink.internal.ModulePoolImpl;
 import jdk.tools.jlink.internal.plugins.OptimizationPlugin;
 import jdk.tools.jlink.internal.plugins.asm.AsmModulePool;
 import jdk.tools.jlink.internal.plugins.asm.AsmPlugin;
 import jdk.tools.jlink.internal.plugins.asm.AsmPools;
 import jdk.tools.jlink.internal.plugins.optim.ControlFlow;
 import jdk.tools.jlink.internal.plugins.optim.ControlFlow.Block;
-import jdk.tools.jlink.plugin.Pool;
-import jdk.tools.jlink.plugin.Pool.ModuleData;
+import jdk.tools.jlink.plugin.ModuleEntry;
+import jdk.tools.jlink.plugin.ModulePool;
 
 import tests.Helper;
 import tests.JImageGenerator;
@@ -134,9 +134,9 @@
         }
 
         @Override
-        public Set<PluginType> getType() {
-            Set<PluginType> set = new HashSet<>();
-            set.add(CATEGORY.TRANSFORMER);
+        public Set<Category> getType() {
+            Set<Category> set = new HashSet<>();
+            set.add(Category.TRANSFORMER);
             return Collections.unmodifiableSet(set);
         }
     }
@@ -150,13 +150,13 @@
         FileSystem fs = FileSystems.getFileSystem(URI.create("jrt:/"));
         Path root = fs.getPath("/modules/java.base");
         // Access module-info.class to be reused as fake module-info.class
-        List<ModuleData> javabaseResources = new ArrayList<>();
+        List<ModuleEntry> javabaseResources = new ArrayList<>();
         try (Stream<Path> stream = Files.walk(root)) {
             for (Iterator<Path> iterator = stream.iterator(); iterator.hasNext();) {
                 Path p = iterator.next();
                 if (Files.isRegularFile(p)) {
                     try {
-                        javabaseResources.add(Pool.newResource(p.toString().
+                        javabaseResources.add(ModuleEntry.create(p.toString().
                                 substring("/modules".length()), Files.readAllBytes(p)));
                     } catch (Exception ex) {
                         throw new RuntimeException(ex);
@@ -166,18 +166,18 @@
         }
 
         //forName folding
-        PoolImpl pool = new PoolImpl();
+        ModulePoolImpl pool = new ModulePoolImpl();
         byte[] content = Files.readAllBytes(classes.
                 resolve("optim").resolve("ForNameTestCase.class"));
         byte[] content2 = Files.readAllBytes(classes.
                 resolve("optim").resolve("AType.class"));
         byte[] mcontent = Files.readAllBytes(classes.resolve("module-info.class"));
 
-        pool.add(Pool.newResource("/optimplugin/optim/ForNameTestCase.class", content));
-        pool.add(Pool.newResource("/optimplugin/optim/AType.class", content2));
-        pool.add(Pool.newResource("/optimplugin/module-info.class", mcontent));
+        pool.add(ModuleEntry.create("/optimplugin/optim/ForNameTestCase.class", content));
+        pool.add(ModuleEntry.create("/optimplugin/optim/AType.class", content2));
+        pool.add(ModuleEntry.create("/optimplugin/module-info.class", mcontent));
 
-        for (ModuleData r : javabaseResources) {
+        for (ModuleEntry r : javabaseResources) {
             pool.add(r);
         }
 
@@ -186,10 +186,10 @@
         optional.put(OptimizationPlugin.NAME, OptimizationPlugin.FORNAME_REMOVAL);
         optional.put(OptimizationPlugin.LOG, "forName.log");
         plugin.configure(optional);
-        Pool out = new PoolImpl();
+        ModulePool out = new ModulePoolImpl();
         plugin.visit(pool, out);
 
-        ModuleData result = out.getContent().iterator().next();
+        ModuleEntry result = out.entries().iterator().next();
 
         ClassReader optimReader = new ClassReader(result.getBytes());
         ClassNode optimClass = new ClassNode();
--- a/jdk/test/tools/jlink/JLinkOptionsTest.java	Thu May 19 17:48:02 2016 +0000
+++ b/jdk/test/tools/jlink/JLinkOptionsTest.java	Thu May 19 19:46:20 2016 +0000
@@ -24,7 +24,7 @@
 import java.util.List;
 import java.util.Map;
 import java.util.Set;
-import jdk.tools.jlink.plugin.Pool;
+import jdk.tools.jlink.plugin.ModulePool;
 import jdk.tools.jlink.internal.PluginRepository;
 import jdk.tools.jlink.plugin.TransformerPlugin;
 
@@ -62,7 +62,7 @@
         }
 
         @Override
-        public void visit(Pool in, Pool out) {
+        public void visit(ModulePool in, ModulePool out) {
 
         }
 
--- a/jdk/test/tools/jlink/JLinkPostProcessingTest.java	Thu May 19 17:48:02 2016 +0000
+++ b/jdk/test/tools/jlink/JLinkPostProcessingTest.java	Thu May 19 19:46:20 2016 +0000
@@ -75,9 +75,9 @@
         }
 
         @Override
-        public Set<PluginType> getType() {
-            Set<PluginType> set = new HashSet<>();
-            set.add(CATEGORY.PROCESSOR);
+        public Set<Category> getType() {
+            Set<Category> set = new HashSet<>();
+            set.add(Category.PROCESSOR);
             return Collections.unmodifiableSet(set);
         }
 
--- a/jdk/test/tools/jlink/ResourcePoolTest.java	Thu May 19 17:48:02 2016 +0000
+++ b/jdk/test/tools/jlink/ResourcePoolTest.java	Thu May 19 19:46:20 2016 +0000
@@ -37,14 +37,14 @@
 import java.util.Collection;
 import java.util.HashSet;
 import java.util.List;
+import java.util.Optional;
 import java.util.Set;
-
-import jdk.tools.jlink.internal.PoolImpl;
-import jdk.tools.jlink.plugin.Pool;
-import jdk.tools.jlink.plugin.Pool.Module;
-import jdk.tools.jlink.plugin.Pool.ModuleData;
-import jdk.tools.jlink.plugin.Pool.ModuleDataType;
-import jdk.tools.jlink.plugin.Pool.Visitor;
+import java.util.function.Function;
+import jdk.tools.jlink.internal.ModulePoolImpl;
+import jdk.tools.jlink.plugin.ModulePool;
+import jdk.tools.jlink.plugin.LinkModule;
+import jdk.tools.jlink.plugin.ModuleEntry;
+import jdk.tools.jlink.plugin.ModulePool;
 
 public class ResourcePoolTest {
 
@@ -61,54 +61,53 @@
     private static final String SUFFIX = "END";
 
     private void checkResourceVisitor() throws Exception {
-        Pool input = new PoolImpl();
+        ModulePool input = new ModulePoolImpl();
         for (int i = 0; i < 1000; ++i) {
             String module = "/module" + (i / 10);
             String resourcePath = module + "/java/package" + i;
             byte[] bytes = resourcePath.getBytes();
-            input.add(new ModuleData(module, resourcePath,
-                    ModuleDataType.CLASS_OR_RESOURCE,
+            input.add(ModuleEntry.create(module, resourcePath,
+                    ModuleEntry.Type.CLASS_OR_RESOURCE,
                     new ByteArrayInputStream(bytes), bytes.length));
         }
-        Pool output = new PoolImpl();
+        ModulePool output = new ModulePoolImpl();
         ResourceVisitor visitor = new ResourceVisitor();
-        input.visit(visitor, output);
+        input.transformAndCopy(visitor, output);
         if (visitor.getAmountBefore() == 0) {
             throw new AssertionError("Resources not found");
         }
-        if (visitor.getAmountBefore() != input.getContent().size()) {
+        if (visitor.getAmountBefore() != input.getEntryCount()) {
             throw new AssertionError("Number of visited resources. Expected: " +
-                    visitor.getAmountBefore() + ", got: " + input.getContent().size());
+                    visitor.getAmountBefore() + ", got: " + input.getEntryCount());
         }
-        if (visitor.getAmountAfter() != output.getContent().size()) {
+        if (visitor.getAmountAfter() != output.getEntryCount()) {
             throw new AssertionError("Number of added resources. Expected: " +
-                    visitor.getAmountAfter() + ", got: " + output.getContent().size());
+                    visitor.getAmountAfter() + ", got: " + output.getEntryCount());
         }
-        for (ModuleData outResource : output.getContent()) {
+        output.entries().forEach(outResource -> {
             String path = outResource.getPath().replaceAll(SUFFIX + "$", "");
-            ModuleData inResource = input.get(path);
-            if (inResource == null) {
+            if (!input.findEntry(path).isPresent()) {
                 throw new AssertionError("Unknown resource: " + path);
             }
-        }
+        });
     }
 
-    private static class ResourceVisitor implements Visitor {
+    private static class ResourceVisitor implements Function<ModuleEntry, ModuleEntry> {
 
         private int amountBefore;
         private int amountAfter;
 
         @Override
-        public ModuleData visit(ModuleData resource) {
+        public ModuleEntry apply(ModuleEntry resource) {
             int index = ++amountBefore % 3;
             switch (index) {
                 case 0:
                     ++amountAfter;
-                    return new ModuleData(resource.getModule(), resource.getPath() + SUFFIX,
+                    return ModuleEntry.create(resource.getModule(), resource.getPath() + SUFFIX,
                             resource.getType(), resource.stream(), resource.getLength());
                 case 1:
                     ++amountAfter;
-                    return new ModuleData(resource.getModule(), resource.getPath(),
+                    return ModuleEntry.create(resource.getModule(), resource.getPath(),
                             resource.getType(), resource.stream(), resource.getLength());
             }
             return null;
@@ -133,8 +132,8 @@
         samples.add("javax/management/ObjectName");
         test(samples, (resources, module, path) -> {
             try {
-                resources.add(new ModuleData(module, path,
-                        ModuleDataType.CLASS_OR_RESOURCE,
+                resources.add(ModuleEntry.create(module, path,
+                        ModuleEntry.Type.CLASS_OR_RESOURCE,
                         new ByteArrayInputStream(new byte[0]), 0));
             } catch (Exception ex) {
                 throw new RuntimeException(ex);
@@ -142,12 +141,12 @@
         });
         test(samples, (resources, module, path) -> {
             try {
-                resources.add(PoolImpl.
-                        newCompressedResource(new ModuleData(module, path,
-                                ModuleDataType.CLASS_OR_RESOURCE,
+                resources.add(ModulePoolImpl.
+                        newCompressedResource(ModuleEntry.create(module, path,
+                                ModuleEntry.Type.CLASS_OR_RESOURCE,
                                 new ByteArrayInputStream(new byte[0]), 0),
                                 ByteBuffer.allocate(99), "bitcruncher", null,
-                                ((PoolImpl)resources).getStringTable(), ByteOrder.nativeOrder()));
+                                ((ModulePoolImpl)resources).getStringTable(), ByteOrder.nativeOrder()));
             } catch (Exception ex) {
                 throw new RuntimeException(ex);
             }
@@ -158,7 +157,7 @@
         if (samples.isEmpty()) {
             throw new AssertionError("No sample to test");
         }
-        Pool resources = new PoolImpl();
+        ModulePool resources = new ModulePoolImpl();
         Set<String> modules = new HashSet<>();
         for (int i = 0; i < samples.size(); i++) {
             String module = samples.get(i);
@@ -173,70 +172,69 @@
             i++;
             String clazz = samples.get(i);
             String path = "/" + module + "/" + clazz + ".class";
-            ModuleData res = resources.get(path);
-            checkModule(resources, res);
-            if (res == null) {
+            Optional<ModuleEntry> res = resources.findEntry(path);
+            if (!res.isPresent()) {
                 throw new AssertionError("Resource not found " + path);
             }
-            ModuleData res2 = resources.get(clazz);
-            if (res2 != null) {
+            checkModule(resources, res.get());
+            if (resources.findEntry(clazz).isPresent()) {
                 throw new AssertionError("Resource found " + clazz);
             }
         }
-        if (resources.getContent().size() != samples.size() / 2) {
+        if (resources.getEntryCount() != samples.size() / 2) {
             throw new AssertionError("Invalid number of resources");
         }
     }
 
-    private void checkModule(Pool resources, ModuleData res) {
-        Module m = resources.getModule(res.getModule());
-        if (m == null) {
+    private void checkModule(ModulePool resources, ModuleEntry res) {
+        Optional<LinkModule> optMod = resources.findModule(res.getModule());
+        if (!optMod.isPresent()) {
             throw new AssertionError("No module " + res.getModule());
         }
+        LinkModule m = optMod.get();
         if (!m.getName().equals(res.getModule())) {
             throw new AssertionError("Not right module name " + res.getModule());
         }
-        if (m.get(res.getPath()) == null) {
+        if (!m.findEntry(res.getPath()).isPresent()) {
             throw new AssertionError("resource " + res.getPath()
                     + " not in module " + m.getName());
         }
     }
 
     private void checkResourcesAfterCompression() throws Exception {
-        PoolImpl resources1 = new PoolImpl();
-        ModuleData res1 = new ModuleData("module1", "/module1/toto1",
-                ModuleDataType.CLASS_OR_RESOURCE,
+        ModulePoolImpl resources1 = new ModulePoolImpl();
+        ModuleEntry res1 = ModuleEntry.create("module1", "/module1/toto1",
+                ModuleEntry.Type.CLASS_OR_RESOURCE,
                 new ByteArrayInputStream(new byte[0]), 0);
-        ModuleData res2 = new ModuleData("module2", "/module2/toto1",
-                ModuleDataType.CLASS_OR_RESOURCE,
+        ModuleEntry res2 = ModuleEntry.create("module2", "/module2/toto1",
+                ModuleEntry.Type.CLASS_OR_RESOURCE,
                 new ByteArrayInputStream(new byte[0]), 0);
         resources1.add(res1);
         resources1.add(res2);
 
         checkResources(resources1, res1, res2);
-        Pool resources2 = new PoolImpl();
-        ModuleData res3 = new ModuleData("module2", "/module2/toto1",
-                ModuleDataType.CLASS_OR_RESOURCE,
+        ModulePool resources2 = new ModulePoolImpl();
+        ModuleEntry res3 = ModuleEntry.create("module2", "/module2/toto1",
+                ModuleEntry.Type.CLASS_OR_RESOURCE,
                 new ByteArrayInputStream(new byte[7]), 7);
         resources2.add(res3);
-        resources2.add(PoolImpl.newCompressedResource(res1,
+        resources2.add(ModulePoolImpl.newCompressedResource(res1,
                 ByteBuffer.allocate(7), "zip", null, resources1.getStringTable(),
                 ByteOrder.nativeOrder()));
         checkResources(resources2, res1, res2);
     }
 
-    private void checkResources(Pool resources, ModuleData... expected) {
-        Collection<Module> ms = resources.getModules();
+    private void checkResources(ModulePool resources, ModuleEntry... expected) {
         List<String> modules = new ArrayList();
-        for(Module m : ms) {
+        resources.modules().forEach(m -> {
             modules.add(m.getName());
-        }
-        for (ModuleData res : expected) {
+        });
+        for (ModuleEntry res : expected) {
             if (!resources.contains(res)) {
                 throw new AssertionError("Resource not found: " + res);
             }
 
-            if (resources.get(res.getPath()) == null) {
+            if (!resources.findEntry(res.getPath()).isPresent()) {
                 throw new AssertionError("Resource not found: " + res);
             }
 
@@ -244,7 +242,7 @@
                 throw new AssertionError("Module not found: " + res.getModule());
             }
 
-            if (!resources.getContent().contains(res)) {
+            if (!resources.contains(res)) {
                 throw new AssertionError("Resources not found: " + res);
             }
 
@@ -260,17 +258,17 @@
             throw new AssertionError("ReadOnly resources");
         }
 
-        ((PoolImpl) resources).setReadOnly();
+        ((ModulePoolImpl) resources).setReadOnly();
         try {
-            resources.add(new ModuleData("module2",  "/module2/toto1",
-                    ModuleDataType.CLASS_OR_RESOURCE, new ByteArrayInputStream(new byte[0]), 0));
-            throw new AssertionError("Pool is read-only, but an exception is not thrown");
+            resources.add(ModuleEntry.create("module2",  "/module2/toto1",
+                    ModuleEntry.Type.CLASS_OR_RESOURCE, new ByteArrayInputStream(new byte[0]), 0));
+            throw new AssertionError("ModulePool is read-only, but an exception is not thrown");
         } catch (Exception ex) {
             // Expected
         }
     }
 
     interface ResourceAdder {
-        void add(Pool resources, String module, String path);
+        void add(ModulePool resources, String module, String path);
     }
 }
--- a/jdk/test/tools/jlink/SecurityTest.java	Thu May 19 17:48:02 2016 +0000
+++ b/jdk/test/tools/jlink/SecurityTest.java	Thu May 19 19:46:20 2016 +0000
@@ -25,6 +25,7 @@
  * @test
  * @summary Test JlinkPermission
  * @author Jean-Francois Denise
+ * @modules jdk.jlink/jdk.tools.jlink
  * @run main/othervm SecurityTest
  */
 
--- a/jdk/test/tools/jlink/asmplugin/AddForgetResourcesTest.java	Thu May 19 17:48:02 2016 +0000
+++ b/jdk/test/tools/jlink/asmplugin/AddForgetResourcesTest.java	Thu May 19 19:46:20 2016 +0000
@@ -55,8 +55,8 @@
 import jdk.tools.jlink.internal.plugins.asm.AsmPool.WritableClassPool;
 import jdk.tools.jlink.internal.plugins.asm.AsmPool.WritableResourcePool;
 import jdk.tools.jlink.internal.plugins.asm.AsmPools;
-import jdk.tools.jlink.plugin.Pool;
-import jdk.tools.jlink.plugin.Pool.ModuleData;
+import jdk.tools.jlink.plugin.ModuleEntry;
+import jdk.tools.jlink.plugin.ModulePool;
 
 public class AddForgetResourcesTest extends AsmPluginTestBase {
 
@@ -82,7 +82,7 @@
                 new ComboPlugin()
         };
         for (TestPlugin p : plugins) {
-            Pool out = p.visit(getPool());
+            ModulePool out = p.visit(getPool());
             p.test(getPool(), out);
         }
     }
@@ -124,7 +124,7 @@
             AsmGlobalPool globalPool = pools.getGlobalPool();
             WritableClassPool transformedClasses = globalPool.getTransformedClasses();
             expected = globalPool.getClasses().size();
-            for (ModuleData res : globalPool.getClasses()) {
+            for (ModuleEntry res : globalPool.getClasses()) {
                 ClassReader reader = globalPool.getClassReader(res);
                 String className = reader.getClassName();
                 if (!className.endsWith("module-info")) {
@@ -137,14 +137,14 @@
         }
 
         @Override
-        public void test(Pool inResources, Pool outResources) {
-            Collection<ModuleData> inClasses = extractClasses(inResources);
-            Collection<ModuleData> outClasses = extractClasses(outResources);
+        public void test(ModulePool inResources, ModulePool outResources) {
+            Collection<ModuleEntry> inClasses = extractClasses(inResources);
+            Collection<ModuleEntry> outClasses = extractClasses(outResources);
             if (expected != outClasses.size()) {
                 throw new AssertionError("Classes were not added. Expected: " + expected
                         + ", got: " + outClasses.size());
             }
-            for (ModuleData in : inClasses) {
+            for (ModuleEntry in : inClasses) {
                 String path = in.getPath();
                 if (!outClasses.contains(in)) {
                     throw new AssertionError("Class not found: " + path);
@@ -153,7 +153,7 @@
                     continue;
                 }
                 String modifiedPath = path.replace(".class", SUFFIX + ".class");
-                if (!outClasses.contains(Pool.newResource(modifiedPath, new byte[0]))) {
+                if (!outClasses.contains(ModuleEntry.create(modifiedPath, new byte[0]))) {
                     throw new AssertionError("Class not found: " + modifiedPath);
                 }
             }
@@ -166,7 +166,7 @@
         public void visit() {
             AsmPools pools = getPools();
             AsmGlobalPool globalPool = pools.getGlobalPool();
-            for (ModuleData res : globalPool.getResourceFiles()) {
+            for (ModuleEntry res : globalPool.getResourceFiles()) {
                 String path = res.getPath();
                 String moduleName = getModule(path);
                 AsmModulePool modulePool = pools.getModulePool(moduleName);
@@ -177,20 +177,20 @@
         }
 
         @Override
-        public void test(Pool in, Pool out) throws Exception {
-            Collection<ModuleData> inResources = extractResources(in);
-            Collection<ModuleData> outResources = extractResources(out);
+        public void test(ModulePool in, ModulePool out) throws Exception {
+            Collection<ModuleEntry> inResources = extractResources(in);
+            Collection<ModuleEntry> outResources = extractResources(out);
             if (2 * inResources.size() != outResources.size()) {
                 throw new AssertionError("Classes were not added. Expected: " + (2 * inResources.size())
                         + ", got: " + outResources.size());
             }
-            for (ModuleData r : inResources) {
+            for (ModuleEntry r : inResources) {
                 String path = r.getPath();
                 if (!outResources.contains(r)) {
                     throw new AssertionError("Class not found: " + path);
                 }
                 String modifiedPath = path + SUFFIX;
-                if (!outResources.contains(Pool.newResource(modifiedPath, new byte[0]))) {
+                if (!outResources.contains(ModuleEntry.create(modifiedPath, new byte[0]))) {
                     throw new AssertionError("Class not found: " + modifiedPath);
                 }
             }
@@ -204,7 +204,7 @@
             AsmPools pools = getPools();
             AsmGlobalPool globalPool = pools.getGlobalPool();
             WritableClassPool transformedClasses = globalPool.getTransformedClasses();
-            for (ModuleData res : globalPool.getClasses()) {
+            for (ModuleEntry res : globalPool.getClasses()) {
                 ClassReader reader = globalPool.getClassReader(res);
                 ClassWriter writer = new ClassWriter(reader, ClassWriter.COMPUTE_FRAMES);
                 reader.accept(new AddMethodClassVisitor(writer), ClassReader.EXPAND_FRAMES);
@@ -213,14 +213,14 @@
         }
 
         @Override
-        public void test(Pool inResources, Pool outResources) throws Exception {
-            Collection<ModuleData> inClasses = extractClasses(inResources);
-            Collection<ModuleData> outClasses = extractClasses(outResources);
+        public void test(ModulePool inResources, ModulePool outResources) throws Exception {
+            Collection<ModuleEntry> inClasses = extractClasses(inResources);
+            Collection<ModuleEntry> outClasses = extractClasses(outResources);
             if (inClasses.size() != outClasses.size()) {
                 throw new AssertionError("Number of classes. Expected: " + (inClasses.size())
                         + ", got: " + outClasses.size());
             }
-            for (ModuleData out : outClasses) {
+            for (ModuleEntry out : outClasses) {
                 String path = out.getPath();
                 if (!inClasses.contains(out)) {
                     throw new AssertionError("Class not found: " + path);
@@ -248,7 +248,7 @@
         public void visit() {
             AsmPools pools = getPools();
             AsmGlobalPool globalPool = pools.getGlobalPool();
-            for (ModuleData res : globalPool.getResourceFiles()) {
+            for (ModuleEntry res : globalPool.getResourceFiles()) {
                 String path = res.getPath();
                 AsmModulePool modulePool = pools.getModulePool(getModule(path));
                 modulePool.getTransformedResourceFiles().addResourceFile(new ResourceFile(removeModule(path),
@@ -257,14 +257,14 @@
         }
 
         @Override
-        public void test(Pool in, Pool out) throws Exception {
-            Collection<ModuleData> inResources = extractResources(in);
-            Collection<ModuleData> outResources = extractResources(out);
+        public void test(ModulePool in, ModulePool out) throws Exception {
+            Collection<ModuleEntry> inResources = extractResources(in);
+            Collection<ModuleEntry> outResources = extractResources(out);
             if (inResources.size() != outResources.size()) {
                 throw new AssertionError("Number of resources. Expected: " + inResources.size()
                         + ", got: " + outResources.size());
             }
-            for (ModuleData r : outResources) {
+            for (ModuleEntry r : outResources) {
                 String path = r.getPath();
                 if (!inResources.contains(r)) {
                     throw new AssertionError("Resource not found: " + path);
@@ -287,7 +287,7 @@
             AsmGlobalPool globalPool = pools.getGlobalPool();
             WritableClassPool transformedClasses = globalPool.getTransformedClasses();
             int i = 0;
-            for (ModuleData res : globalPool.getClasses()) {
+            for (ModuleEntry res : globalPool.getClasses()) {
                 String path = removeModule(res.getPath());
                 String className = path.replace(".class", "");
                 if ((i & 1) == 0 && !className.endsWith("module-info")) {
@@ -300,8 +300,8 @@
         }
 
         @Override
-        public void test(Pool inResources, Pool outResources) throws Exception {
-            Collection<ModuleData> outClasses = extractClasses(outResources);
+        public void test(ModulePool inResources, ModulePool outResources) throws Exception {
+            Collection<ModuleEntry> outClasses = extractClasses(outResources);
             if (expected != outClasses.size()) {
                 throw new AssertionError("Number of classes. Expected: " + expected +
                         ", got: " + outClasses.size());
@@ -318,7 +318,7 @@
             AsmPools pools = getPools();
             AsmGlobalPool globalPool = pools.getGlobalPool();
             int i = 0;
-            for (ModuleData res : globalPool.getResourceFiles()) {
+            for (ModuleEntry res : globalPool.getResourceFiles()) {
                 String path = res.getPath();
                 if (!path.contains("META-INF/services")) {
                     if ((i & 1) == 0) {
@@ -335,8 +335,8 @@
         }
 
         @Override
-        public void test(Pool in, Pool out) throws Exception {
-            Collection<ModuleData> outResources = extractResources(out);
+        public void test(ModulePool in, ModulePool out) throws Exception {
+            Collection<ModuleEntry> outResources = extractResources(out);
             if (expectedAmount != outResources.size()) {
                 throw new AssertionError("Number of classes. Expected: " + expectedAmount
                         + ", got: " + outResources.size());
@@ -354,7 +354,7 @@
             AsmGlobalPool globalPool = pools.getGlobalPool();
             WritableClassPool transformedClasses = globalPool.getTransformedClasses();
             int i = 0;
-            for (ModuleData res : globalPool.getClasses()) {
+            for (ModuleEntry res : globalPool.getClasses()) {
                 ClassReader reader = globalPool.getClassReader(res);
                 String className = reader.getClassName();
                 ClassWriter writer = new ClassWriter(reader, ClassWriter.COMPUTE_FRAMES);
@@ -374,8 +374,8 @@
         }
 
         @Override
-        public void test(Pool inResources, Pool outResources) throws Exception {
-            Collection<ModuleData> outClasses = extractClasses(outResources);
+        public void test(ModulePool inResources, ModulePool outResources) throws Exception {
+            Collection<ModuleEntry> outClasses = extractClasses(outResources);
             if (expected != outClasses.size()) {
                 throw new AssertionError("Number of classes. Expected: " + expected
                         + ", got: " + outClasses.size());
@@ -392,7 +392,7 @@
             AsmPools pools = getPools();
             AsmGlobalPool globalPool = pools.getGlobalPool();
             int i = 0;
-            for (ModuleData res : globalPool.getResourceFiles()) {
+            for (ModuleEntry res : globalPool.getResourceFiles()) {
                 String path = res.getPath();
                 String moduleName = getModule(path);
                 if (!path.contains("META-INF")) {
@@ -412,8 +412,8 @@
         }
 
         @Override
-        public void test(Pool inResources, Pool out) throws Exception {
-            Collection<ModuleData> outResources = extractResources(out);
+        public void test(ModulePool inResources, ModulePool out) throws Exception {
+            Collection<ModuleEntry> outResources = extractResources(out);
             if (expectedAmount != outResources.size()) {
                 throw new AssertionError("Number of classes. Expected: " + expectedAmount
                         + ", got: " + outResources.size());
@@ -446,7 +446,7 @@
         }
 
         @Override
-        public void test(Pool inResources, Pool outResources) throws Exception {
+        public void test(ModulePool inResources, ModulePool outResources) throws Exception {
             if (!isVisitCalled()) {
                 throw new AssertionError("Resources not visited");
             }
@@ -455,7 +455,7 @@
                 throw new AssertionError("Number of transformed classes not equal to expected");
             }
             // Check that only renamed classes and resource files are in the result.
-            for (ModuleData r : outResources.getContent()) {
+            outResources.entries().forEach(r -> {
                 String resourceName = r.getPath();
                 if (resourceName.endsWith(".class") && !resourceName.endsWith("module-info.class")) {
                     if (!resourceName.endsWith(SUFFIX + ".class")) {
@@ -467,7 +467,7 @@
                         throw new AssertionError("Resource file not renamed " + resourceName);
                     }
                 }
-            }
+            });
         }
 
         private void renameResources() throws IOException {
@@ -476,7 +476,7 @@
             for (Map.Entry<String, List<String>> mod : MODULES.entrySet()) {
                 String moduleName = mod.getKey();
                 AsmModulePool modulePool = pools.getModulePool(moduleName);
-                for (ModuleData res : modulePool.getResourceFiles()) {
+                for (ModuleEntry res : modulePool.getResourceFiles()) {
                     ResourceFile resFile = modulePool.getResourceFile(res);
                     if (resFile.getPath().startsWith("META-INF/services/")) {
                         String newContent = new String(resFile.getContent()) + SUFFIX;
@@ -492,7 +492,7 @@
             AsmPools pools = getPools();
             AsmGlobalPool globalPool = pools.getGlobalPool();
             WritableClassPool transformedClasses = globalPool.getTransformedClasses();
-            for (ModuleData res : globalPool.getClasses()) {
+            for (ModuleEntry res : globalPool.getClasses()) {
                 if (res.getPath().endsWith("module-info.class")) {
                     continue;
                 }
--- a/jdk/test/tools/jlink/asmplugin/AsmPluginTestBase.java	Thu May 19 17:48:02 2016 +0000
+++ b/jdk/test/tools/jlink/asmplugin/AsmPluginTestBase.java	Thu May 19 19:46:20 2016 +0000
@@ -38,23 +38,23 @@
 import java.util.function.Predicate;
 import java.util.stream.Collectors;
 import java.util.stream.Stream;
-import jdk.tools.jlink.internal.PoolImpl;
+import jdk.tools.jlink.internal.ModulePoolImpl;
 import jdk.tools.jlink.internal.StringTable;
 
 import jdk.tools.jlink.internal.plugins.asm.AsmPlugin;
 import jdk.tools.jlink.internal.plugins.asm.AsmPools;
-import jdk.tools.jlink.plugin.Pool;
-import jdk.tools.jlink.plugin.Pool.ModuleData;
+import jdk.tools.jlink.plugin.ModuleEntry;
+import jdk.tools.jlink.plugin.ModulePool;
 
 public abstract class AsmPluginTestBase {
 
     protected static final String TEST_MODULE = "jlink.test";
     protected static final Map<String, List<String>> MODULES;
 
-    private static final Predicate<ModuleData> isClass = r -> r.getPath().endsWith(".class");
+    private static final Predicate<ModuleEntry> isClass = r -> r.getPath().endsWith(".class");
     private final List<String> classes;
     private final List<String> resources;
-    private final Pool pool;
+    private final ModulePool pool;
 
     static {
         Map<String, List<String>> map = new HashMap<>();
@@ -75,7 +75,7 @@
             List<String> classes = new ArrayList<>();
             List<String> resources = new ArrayList<>();
 
-            pool = new PoolImpl();
+            pool = new ModulePoolImpl();
 
             FileSystem fs = FileSystems.getFileSystem(URI.create("jrt:/"));
             Path root = fs.getPath("/modules");
@@ -100,7 +100,7 @@
                                     MODULES.get(module).add(toResourceFile(p));
                                 }
                                 resources.add(toPath(p.toString()));
-                                ModuleData res = Pool.newResource(toPath(p.toString()), content);
+                                ModuleEntry res = ModuleEntry.create(toPath(p.toString()), content);
                                 pool.add(res);
                             } catch (Exception ex) {
                                 throw new RuntimeException(ex);
@@ -110,17 +110,17 @@
                 }
             }
             // There is more than 10 classes in java.base...
-            if (classes.size() < 10 || pool.getContent().size() < 10) {
+            if (classes.size() < 10 || pool.getEntryCount() < 10) {
                 throw new AssertionError("Not expected resource or class number");
             }
 
             //Add a fake resource file
             String content = "java.lang.Object";
             String path = "META-INF/services/com.foo.BarProvider";
-            ModuleData resFile = Pool.newResource("/" + TEST_MODULE + "/" +
+            ModuleEntry resFile = ModuleEntry.create("/" + TEST_MODULE + "/" +
                     path, content.getBytes());
             pool.add(resFile);
-            ModuleData fakeInfoFile = Pool.newResource("/" + TEST_MODULE
+            ModuleEntry fakeInfoFile = ModuleEntry.create("/" + TEST_MODULE
                     + "/module-info.class", moduleInfos.get(0));
             pool.add(fakeInfoFile);
             MODULES.get(TEST_MODULE).add(path);
@@ -144,20 +144,20 @@
         return resources;
     }
 
-    public Pool getPool() {
+    public ModulePool getPool() {
         return pool;
     }
 
     public abstract void test() throws Exception;
 
-    public Collection<ModuleData> extractClasses(Pool pool) {
-        return pool.getContent().stream()
+    public Collection<ModuleEntry> extractClasses(ModulePool pool) {
+        return pool.entries()
                 .filter(isClass)
                 .collect(Collectors.toSet());
     }
 
-    public Collection<ModuleData> extractResources(Pool pool) {
-        return pool.getContent().stream()
+    public Collection<ModuleEntry> extractResources(ModulePool pool) {
+        return pool.entries()
                 .filter(isClass.negate())
                 .collect(Collectors.toSet());
     }
@@ -209,9 +209,9 @@
             return pools != null;
         }
 
-        public Pool visit(Pool inResources) throws IOException {
+        public ModulePool visit(ModulePool inResources) throws IOException {
             try {
-                Pool outResources = new PoolImpl(inResources.getByteOrder(), new StringTable() {
+                ModulePool outResources = new ModulePoolImpl(inResources.getByteOrder(), new StringTable() {
                     @Override
                     public int addString(String str) {
                         return -1;
@@ -239,7 +239,7 @@
         }
 
         public abstract void visit();
-        public abstract void test(Pool inResources, Pool outResources) throws Exception;
+        public abstract void test(ModulePool inResources, ModulePool outResources) throws Exception;
 
         @Override
         public String getName() {
--- a/jdk/test/tools/jlink/asmplugin/BasicTest.java	Thu May 19 17:48:02 2016 +0000
+++ b/jdk/test/tools/jlink/asmplugin/BasicTest.java	Thu May 19 19:46:20 2016 +0000
@@ -45,8 +45,8 @@
 import jdk.internal.org.objectweb.asm.ClassReader;
 import jdk.tools.jlink.internal.plugins.asm.AsmModulePool;
 import jdk.tools.jlink.internal.plugins.asm.AsmPool;
-import jdk.tools.jlink.plugin.Pool;
-import jdk.tools.jlink.plugin.Pool.ModuleData;
+import jdk.tools.jlink.plugin.ModuleEntry;
+import jdk.tools.jlink.plugin.ModulePool;
 
 public class BasicTest extends AsmPluginTestBase {
 
@@ -61,7 +61,7 @@
     @Override
     public void test() throws Exception {
         BasicPlugin basicPlugin = new BasicPlugin(getClasses());
-        Pool res = basicPlugin.visit(getPool());
+        ModulePool res = basicPlugin.visit(getPool());
         basicPlugin.test(getPool(), res);
     }
 
@@ -107,13 +107,13 @@
         }
 
         @Override
-        public void test(Pool inResources, Pool outResources) throws Exception {
+        public void test(ModulePool inResources, ModulePool outResources) throws Exception {
             if (!isVisitCalled()) {
                 throw new AssertionError("Resources not visited");
             }
-            if (inResources.getContent().size() != outResources.getContent().size()) {
-                throw new AssertionError("Input size " + inResources.getContent().size() +
-                        " != to " + outResources.getContent().size());
+            if (inResources.getEntryCount() != outResources.getEntryCount()) {
+                throw new AssertionError("Input size " + inResources.getEntryCount() +
+                        " != to " + outResources.getEntryCount());
             }
         }
 
@@ -142,7 +142,7 @@
 
         private void testPools() throws IOException {
             Set<String> remain = new HashSet<>(classes);
-            for (ModuleData res : getPools().getGlobalPool().getClasses()) {
+            for (ModuleEntry res : getPools().getGlobalPool().getClasses()) {
                 ClassReader reader = getPools().getGlobalPool().getClassReader(res);
                 String className = reader.getClassName();
                 // Wrong naming of module-info.class in ASM
--- a/jdk/test/tools/jlink/asmplugin/IdentityPluginTest.java	Thu May 19 17:48:02 2016 +0000
+++ b/jdk/test/tools/jlink/asmplugin/IdentityPluginTest.java	Thu May 19 19:46:20 2016 +0000
@@ -35,14 +35,15 @@
 
 import java.io.ByteArrayInputStream;
 import java.io.IOException;
+import java.io.UncheckedIOException;
 
 import jdk.internal.org.objectweb.asm.ClassReader;
 import jdk.internal.org.objectweb.asm.ClassVisitor;
 import jdk.internal.org.objectweb.asm.ClassWriter;
 import jdk.internal.org.objectweb.asm.Opcodes;
 import jdk.tools.jlink.internal.plugins.asm.AsmPool.WritableClassPool;
-import jdk.tools.jlink.plugin.Pool;
-import jdk.tools.jlink.plugin.Pool.ModuleData;
+import jdk.tools.jlink.plugin.ModuleEntry;
+import jdk.tools.jlink.plugin.ModulePool;
 
 public class IdentityPluginTest extends AsmPluginTestBase {
 
@@ -56,7 +57,7 @@
 
     public void test() throws Exception {
         IdentityPlugin asm = new IdentityPlugin();
-        Pool resourcePool = asm.visit(getPool());
+        ModulePool resourcePool = asm.visit(getPool());
         asm.test(getPool(), resourcePool);
     }
 
@@ -64,7 +65,7 @@
 
         @Override
         public void visit() {
-            for (ModuleData res : getPools().getGlobalPool().getClasses()) {
+            for (ModuleEntry res : getPools().getGlobalPool().getClasses()) {
                 if (res.getPath().endsWith("module-info.class")) {
                     continue;
                 }
@@ -77,7 +78,7 @@
         }
 
         @Override
-        public void test(Pool inResources, Pool outResources) throws IOException {
+        public void test(ModulePool inResources, ModulePool outResources) throws IOException {
             if (outResources.isEmpty()) {
                 throw new AssertionError("Empty result");
             }
@@ -93,13 +94,17 @@
                     throw new AssertionError("Class not transformed " + className);
                 }
             }
-            for (ModuleData r : outResources.getContent()) {
+            outResources.entries().forEach(r -> {
                 if (r.getPath().endsWith(".class") && !r.getPath().endsWith("module-info.class")) {
-                    ClassReader reader = new ClassReader(new ByteArrayInputStream(r.getBytes()));
-                    ClassWriter w = new ClassWriter(reader, ClassWriter.COMPUTE_FRAMES);
-                    reader.accept(w, ClassReader.EXPAND_FRAMES);
+                    try {
+                        ClassReader reader = new ClassReader(new ByteArrayInputStream(r.getBytes()));
+                        ClassWriter w = new ClassWriter(reader, ClassWriter.COMPUTE_FRAMES);
+                        reader.accept(w, ClassReader.EXPAND_FRAMES);
+                    } catch (IOException exp) {
+                        throw new UncheckedIOException(exp);
+                    }
                 }
-            }
+            });
         }
 
         @Override
--- a/jdk/test/tools/jlink/asmplugin/NegativeTest.java	Thu May 19 17:48:02 2016 +0000
+++ b/jdk/test/tools/jlink/asmplugin/NegativeTest.java	Thu May 19 19:46:20 2016 +0000
@@ -43,7 +43,7 @@
 import jdk.internal.org.objectweb.asm.ClassWriter;
 import jdk.internal.org.objectweb.asm.Opcodes;
 import jdk.tools.jlink.plugin.Plugin;
-import jdk.tools.jlink.internal.PoolImpl;
+import jdk.tools.jlink.internal.ModulePoolImpl;
 import jdk.tools.jlink.internal.StringTable;
 import jdk.tools.jlink.internal.plugins.asm.AsmGlobalPool;
 import jdk.tools.jlink.internal.plugins.asm.AsmModulePool;
@@ -51,7 +51,7 @@
 import jdk.tools.jlink.internal.plugins.asm.AsmPool.ResourceFile;
 import jdk.tools.jlink.internal.plugins.asm.AsmPools;
 import jdk.tools.jlink.plugin.PluginException;
-import jdk.tools.jlink.plugin.Pool;
+import jdk.tools.jlink.plugin.ModulePool;
 
 public class NegativeTest extends AsmPluginTestBase {
     public static void main(String[] args) throws Exception {
@@ -102,7 +102,7 @@
                 }
             }
         };
-        Pool resources = new PoolImpl(ByteOrder.BIG_ENDIAN, new StringTable() {
+        ModulePool resources = new ModulePoolImpl(ByteOrder.BIG_ENDIAN, new StringTable() {
             @Override
             public int addString(String str) {
                 return -1;
@@ -136,7 +136,7 @@
                 action(() -> pools.fillOutputResources(null), "Output resource is null", NullPointerException.class);
             }
         };
-        Pool resources = new PoolImpl(ByteOrder.BIG_ENDIAN, new StringTable() {
+        ModulePool resources = new ModulePoolImpl(ByteOrder.BIG_ENDIAN, new StringTable() {
             @Override
             public int addString(String str) {
                 return -1;
--- a/jdk/test/tools/jlink/asmplugin/PackageMappingTest.java	Thu May 19 17:48:02 2016 +0000
+++ b/jdk/test/tools/jlink/asmplugin/PackageMappingTest.java	Thu May 19 19:46:20 2016 +0000
@@ -48,8 +48,8 @@
 import jdk.tools.jlink.internal.plugins.asm.AsmPool.ResourceFile;
 import jdk.tools.jlink.internal.plugins.asm.AsmPool.WritableResourcePool;
 import jdk.tools.jlink.plugin.PluginException;
-import jdk.tools.jlink.plugin.Pool;
-import jdk.tools.jlink.plugin.Pool.ModuleData;
+import jdk.tools.jlink.plugin.ModuleEntry;
+import jdk.tools.jlink.plugin.ModulePool;
 
 public class PackageMappingTest extends AsmPluginTestBase {
 
@@ -72,7 +72,7 @@
             new PackageMappingPlugin(newFiles, true)
         };
         for (TestPlugin p : plugins) {
-            Pool pool = p.visit(getPool());
+            ModulePool pool = p.visit(getPool());
             p.test(getPool(), pool);
         }
     }
@@ -105,12 +105,12 @@
         }
 
         @Override
-        public void test(Pool inResources, Pool outResources) {
+        public void test(ModulePool inResources, ModulePool outResources) {
             Set<String> in = getPools().getGlobalPool().getResourceFiles().stream()
-                    .map(ModuleData::getPath)
+                    .map(ModuleEntry::getPath)
                     .collect(Collectors.toSet());
             Set<String> out = extractResources(outResources).stream()
-                    .map(ModuleData::getPath)
+                    .map(ModuleEntry::getPath)
                     .collect(Collectors.toSet());
             in.addAll(PackageMappingTest.this.newFiles);
             if (!Objects.equals(in, out)) {
--- a/jdk/test/tools/jlink/asmplugin/SortingTest.java	Thu May 19 17:48:02 2016 +0000
+++ b/jdk/test/tools/jlink/asmplugin/SortingTest.java	Thu May 19 19:46:20 2016 +0000
@@ -35,12 +35,13 @@
 import java.io.IOException;
 import java.util.ArrayList;
 import java.util.List;
+import java.util.Optional;
 import java.util.stream.Collectors;
 
 import jdk.tools.jlink.internal.plugins.asm.AsmModulePool;
 import jdk.tools.jlink.plugin.PluginException;
-import jdk.tools.jlink.plugin.Pool;
-import jdk.tools.jlink.plugin.Pool.ModuleData;
+import jdk.tools.jlink.plugin.ModuleEntry;
+import jdk.tools.jlink.plugin.ModulePool;
 
 public class SortingTest extends AsmPluginTestBase {
 
@@ -66,7 +67,7 @@
         List<String> sorted = new ArrayList<>(getResources());
         sorted.sort(null);
         ClassSorterPlugin sorterPlugin = new ClassSorterPlugin(sorted);
-        Pool resourcePool = sorterPlugin.visit(getPool());
+        ModulePool resourcePool = sorterPlugin.visit(getPool());
         sorterPlugin.test(getPool(), resourcePool);
     }
 
@@ -78,7 +79,7 @@
         List<String> sorted = new ArrayList<>(getResources());
         sorted.sort((s1, s2) -> -getModuleName(s1).compareTo(getModuleName(s2)));
         ModuleSorterPlugin sorterPlugin = new ModuleSorterPlugin();
-        Pool resourcePool = sorterPlugin.visit(getPool());
+        ModulePool resourcePool = sorterPlugin.visit(getPool());
         sorterPlugin.test(getPool(), resourcePool);
     }
 
@@ -88,8 +89,8 @@
         public void visit() {
             for (AsmModulePool modulePool : getPools().getModulePools()) {
                 modulePool.setSorter(resources -> {
-                    List<String> sort = resources.getContent().stream()
-                            .map(ModuleData::getPath)
+                    List<String> sort = resources.entries()
+                            .map(ModuleEntry::getPath)
                             .collect(Collectors.toList());
                     sort.sort(null);
                     return sort;
@@ -102,21 +103,21 @@
         }
 
         @Override
-        public void test(Pool inResources, Pool outResources) throws Exception {
+        public void test(ModulePool inResources, ModulePool outResources) throws Exception {
             if (!isVisitCalled()) {
                 throw new AssertionError("Resources not visited");
             }
-            List<String> sortedResourcePaths = outResources.getContent().stream()
-                    .map(ModuleData::getPath)
+            List<String> sortedResourcePaths = outResources.entries()
+                    .map(ModuleEntry::getPath)
                     .collect(Collectors.toList());
 
             List<String> defaultResourceOrder = new ArrayList<>();
-            for (ModuleData r : inResources.getContent()) {
-                if (!inResources.getContent().contains(r)) {
+            inResources.entries().forEach(r -> {
+                if (!inResources.contains(r)) {
                     throw new AssertionError("Resource " + r.getPath() + " not in result pool");
                 }
                 defaultResourceOrder.add(r.getPath());
-            }
+            });
             // Check that default sorting is not equal to sorted one
             if (defaultResourceOrder.equals(sortedResourcePaths)) {
                 throw new AssertionError("Sorting not applied, default ordering");
@@ -147,27 +148,28 @@
         public void visit() {
             getPools().getGlobalPool().setSorter(
                     (resources) -> expectedClassesOrder.stream()
-                            .map(resources::get)
-                            .map(ModuleData::getPath)
+                            .map(resources::findEntry)
+                            .map(Optional::get)
+                            .map(ModuleEntry::getPath)
                             .collect(Collectors.toList()));
         }
 
         @Override
-        public void test(Pool inResources, Pool outResources) throws Exception {
+        public void test(ModulePool inResources, ModulePool outResources) throws Exception {
             if (!isVisitCalled()) {
                 throw new AssertionError("Resources not visited");
             }
-            List<String> sortedResourcePaths = outResources.getContent().stream()
-                    .map(ModuleData::getPath)
+            List<String> sortedResourcePaths = outResources.entries()
+                    .map(ModuleEntry::getPath)
                     .collect(Collectors.toList());
 
             List<String> defaultResourceOrder = new ArrayList<>();
-            for (ModuleData r : getPool().getContent()) {
-                if (!getPool().getContent().contains(r)) {
+            getPool().entries().forEach(r -> {
+                if (!getPool().contains(r)) {
                     throw new AssertionError("Resource " + r.getPath() + " not in result pool");
                 }
                 defaultResourceOrder.add(r.getPath());
-            }
+            });
             // Check that default sorting is not equal to sorted one
             if (defaultResourceOrder.equals(sortedResourcePaths)) {
                 throw new AssertionError("Sorting not applied, default ordering");
--- a/jdk/test/tools/jlink/asmplugin/VisitorTest.java	Thu May 19 17:48:02 2016 +0000
+++ b/jdk/test/tools/jlink/asmplugin/VisitorTest.java	Thu May 19 19:46:20 2016 +0000
@@ -46,8 +46,8 @@
 import jdk.tools.jlink.internal.plugins.asm.AsmPool.ResourceFile;
 import jdk.tools.jlink.internal.plugins.asm.AsmPool.ResourceFileVisitor;
 import jdk.tools.jlink.internal.plugins.asm.AsmPools;
-import jdk.tools.jlink.plugin.Pool;
-import jdk.tools.jlink.plugin.Pool.ModuleData;
+import jdk.tools.jlink.plugin.ModuleEntry;
+import jdk.tools.jlink.plugin.ModulePool;
 
 public class VisitorTest extends AsmPluginTestBase {
 
@@ -69,7 +69,7 @@
         };
         for (TestPlugin p : plugins) {
             System.err.println("Testing: " + p.getName());
-            Pool out = p.visit(getPool());
+            ModulePool out = p.visit(getPool());
             p.test(getPool(), out);
         }
     }
@@ -149,15 +149,15 @@
         }
 
         @Override
-        public void test(Pool in, Pool out) throws Exception {
-            Collection<ModuleData> inClasses = getPool.apply(getPools()).getClasses();
+        public void test(ModulePool in, ModulePool out) throws Exception {
+            Collection<ModuleEntry> inClasses = getPool.apply(getPools()).getClasses();
             if (inClasses.size() != classReaderVisitor.getAmount()) {
                 throw new AssertionError("Testing " + name + ". Number of visited classes. Expected: " +
                         inClasses.size() + ", got: " + classReaderVisitor.getAmount());
             }
-            Collection<ModuleData> outClasses = extractClasses(out);
+            Collection<ModuleEntry> outClasses = extractClasses(out);
             int changedClasses = 0;
-            for (ModuleData r : outClasses) {
+            for (ModuleEntry r : outClasses) {
                 if (r.getPath().endsWith("Changed.class")) {
                     ++changedClasses;
                 }
@@ -192,15 +192,15 @@
         }
 
         @Override
-        public void test(Pool in, Pool out) throws Exception {
-            Collection<ModuleData> inResources = getPool.apply(getPools()).getResourceFiles();
+        public void test(ModulePool in, ModulePool out) throws Exception {
+            Collection<ModuleEntry> inResources = getPool.apply(getPools()).getResourceFiles();
             if (inResources.size() != resourceFileVisitor.getAmount()) {
                 throw new AssertionError("Testing " + name + ". Number of visited resources. Expected: " +
                         inResources.size() + ", got: " + resourceFileVisitor.getAmount());
             }
-            Collection<ModuleData> outResources = extractResources(out);
+            Collection<ModuleEntry> outResources = extractResources(out);
             int changedClasses = 0;
-            for (ModuleData r : outResources) {
+            for (ModuleEntry r : outResources) {
                 if (r.getPath().endsWith("Changed")) {
                     ++changedClasses;
                 }
--- a/jdk/test/tools/jlink/customplugin/plugin/CustomPlugin.java	Thu May 19 17:48:02 2016 +0000
+++ b/jdk/test/tools/jlink/customplugin/plugin/CustomPlugin.java	Thu May 19 19:46:20 2016 +0000
@@ -26,7 +26,9 @@
 import java.util.HashSet;
 import java.util.Map;
 import java.util.Set;
-import jdk.tools.jlink.plugin.Pool;
+import java.util.function.Function;
+import jdk.tools.jlink.plugin.ModuleEntry;
+import jdk.tools.jlink.plugin.ModulePool;
 import jdk.tools.jlink.plugin.TransformerPlugin;
 
 public class CustomPlugin implements TransformerPlugin {
@@ -37,13 +39,8 @@
     }
 
     @Override
-    public void visit(Pool in, Pool out) {
-        in.visit(new Pool.Visitor() {
-            @Override
-            public Pool.ModuleData visit(Pool.ModuleData content) {
-                return content;
-            }
-        }, out);
+    public void visit(ModulePool in, ModulePool out) {
+        in.transformAndCopy(Function.identity(), out);
     }
 
     @Override
@@ -61,9 +58,9 @@
     }
 
     @Override
-    public Set<PluginType> getType() {
-        Set<PluginType> set = new HashSet<>();
-        set.add(CATEGORY.PROCESSOR);
+    public Set<Category> getType() {
+        Set<Category> set = new HashSet<>();
+        set.add(Category.PROCESSOR);
         return Collections.unmodifiableSet(set);
     }
 }
--- a/jdk/test/tools/jlink/customplugin/plugin/HelloPlugin.java	Thu May 19 17:48:02 2016 +0000
+++ b/jdk/test/tools/jlink/customplugin/plugin/HelloPlugin.java	Thu May 19 19:46:20 2016 +0000
@@ -29,8 +29,8 @@
 import java.util.HashSet;
 import java.util.Map;
 import java.util.Set;
-import jdk.tools.jlink.plugin.Pool;
-import jdk.tools.jlink.plugin.Pool.ModuleData;
+import jdk.tools.jlink.plugin.ModuleEntry;
+import jdk.tools.jlink.plugin.ModulePool;
 import jdk.tools.jlink.plugin.TransformerPlugin;
 
 /**
@@ -49,23 +49,23 @@
     }
 
     @Override
-    public void visit(Pool inResources, Pool outResources) {
+    public void visit(ModulePool inResources, ModulePool outResources) {
         try {
             System.out.println("Hello!!!!!!!!!!");
             File f = new File(OUTPUT_FILE);
             f.createNewFile();
-            for (ModuleData res : inResources.getContent()) {
+            inResources.entries().forEach(res -> {
                 outResources.add(res);
-            }
+            });
         } catch (IOException ex) {
             throw new UncheckedIOException(ex);
         }
     }
 
     @Override
-    public Set<PluginType> getType() {
-        Set<PluginType> set = new HashSet<>();
-        set.add(CATEGORY.TRANSFORMER);
+    public Set<Category> getType() {
+        Set<Category> set = new HashSet<>();
+        set.add(Category.TRANSFORMER);
         return Collections.unmodifiableSet(set);
     }
 
--- a/jdk/test/tools/jlink/plugins/CompressorPluginTest.java	Thu May 19 17:48:02 2016 +0000
+++ b/jdk/test/tools/jlink/plugins/CompressorPluginTest.java	Thu May 19 19:46:20 2016 +0000
@@ -53,14 +53,14 @@
 import jdk.internal.jimage.decompressor.ResourceDecompressorFactory;
 import jdk.internal.jimage.decompressor.StringSharingDecompressorFactory;
 import jdk.internal.jimage.decompressor.ZipDecompressorFactory;
-import jdk.tools.jlink.internal.PoolImpl;
+import jdk.tools.jlink.internal.ModulePoolImpl;
 import jdk.tools.jlink.internal.StringTable;
 import jdk.tools.jlink.internal.plugins.DefaultCompressPlugin;
 import jdk.tools.jlink.internal.plugins.StringSharingPlugin;
 import jdk.tools.jlink.internal.plugins.ZipPlugin;
 import jdk.tools.jlink.plugin.Plugin;
-import jdk.tools.jlink.plugin.Pool;
-import jdk.tools.jlink.plugin.Pool.ModuleData;
+import jdk.tools.jlink.plugin.ModuleEntry;
+import jdk.tools.jlink.plugin.ModulePool;
 import jdk.tools.jlink.plugin.TransformerPlugin;
 
 public class CompressorPluginTest {
@@ -86,7 +86,7 @@
                     new ZipDecompressorFactory()
                 });
 
-        Pool classes = gatherClasses(javabase);
+        ModulePool classes = gatherClasses(javabase);
         // compress = String sharing
         checkCompress(classes, new StringSharingPlugin(), null,
                 new ResourceDecompressorFactory[]{
@@ -173,8 +173,8 @@
                 Collections.singletonList(".*IOException.class"));
     }
 
-    private Pool gatherResources(Path module) throws Exception {
-        Pool pool = new PoolImpl(ByteOrder.nativeOrder(), new StringTable() {
+    private ModulePool gatherResources(Path module) throws Exception {
+        ModulePool pool = new ModulePoolImpl(ByteOrder.nativeOrder(), new StringTable() {
 
             @Override
             public int addString(String str) {
@@ -191,15 +191,15 @@
                 Path p = iterator.next();
                 if (Files.isRegularFile(p)) {
                     byte[] content = Files.readAllBytes(p);
-                    pool.add(Pool.newResource(p.toString(), content));
+                    pool.add(ModuleEntry.create(p.toString(), content));
                 }
             }
         }
         return pool;
     }
 
-    private Pool gatherClasses(Path module) throws Exception {
-        Pool pool = new PoolImpl(ByteOrder.nativeOrder(), new StringTable() {
+    private ModulePool gatherClasses(Path module) throws Exception {
+        ModulePool pool = new ModulePoolImpl(ByteOrder.nativeOrder(), new StringTable() {
 
             @Override
             public int addString(String str) {
@@ -216,27 +216,27 @@
                 Path p = iterator.next();
                 if (Files.isRegularFile(p) && p.toString().endsWith(".class")) {
                     byte[] content = Files.readAllBytes(p);
-                    pool.add(Pool.newResource(p.toString(), content));
+                    pool.add(ModuleEntry.create(p.toString(), content));
                 }
             }
         }
         return pool;
     }
 
-    private void checkCompress(Pool resources, Plugin prov,
+    private void checkCompress(ModulePool resources, Plugin prov,
             Properties config,
             ResourceDecompressorFactory[] factories) throws Exception {
         checkCompress(resources, prov, config, factories, Collections.emptyList(), Collections.emptyList());
     }
 
-    private void checkCompress(Pool resources, Plugin prov,
+    private void checkCompress(ModulePool resources, Plugin prov,
             Properties config,
             ResourceDecompressorFactory[] factories,
             List<String> includes,
             List<String> excludes) throws Exception {
-        long original = 0;
-        long compressed = 0;
-        for (ModuleData resource : resources.getContent()) {
+        long[] original = new long[1];
+        long[] compressed = new long[1];
+        resources.entries().forEach(resource -> {
             List<Pattern> includesPatterns = includes.stream()
                     .map(Pattern::compile)
                     .collect(Collectors.toList());
@@ -252,7 +252,7 @@
             }
             prov.configure(props);
             final Map<Integer, String> strings = new HashMap<>();
-            PoolImpl inputResources = new PoolImpl(ByteOrder.nativeOrder(), new StringTable() {
+            ModulePoolImpl inputResources = new ModulePoolImpl(ByteOrder.nativeOrder(), new StringTable() {
                 @Override
                 public int addString(String str) {
                     int id = strID;
@@ -267,32 +267,32 @@
                 }
             });
             inputResources.add(resource);
-            Pool compressedResources = applyCompressor(prov, inputResources, resource, includesPatterns, excludesPatterns);
-            original += resource.getLength();
-            compressed += compressedResources.get(resource.getPath()).getLength();
+            ModulePool compressedResources = applyCompressor(prov, inputResources, resource, includesPatterns, excludesPatterns);
+            original[0] += resource.getLength();
+            compressed[0] += compressedResources.findEntry(resource.getPath()).get().getLength();
             applyDecompressors(factories, inputResources, compressedResources, strings, includesPatterns, excludesPatterns);
-        }
+        });
         String compressors = Stream.of(factories)
                 .map(Object::getClass)
                 .map(Class::getSimpleName)
                 .collect(Collectors.joining(", "));
-        String size = "Compressed size: " + compressed + ", original size: " + original;
+        String size = "Compressed size: " + compressed[0] + ", original size: " + original[0];
         System.out.println("Used " + compressors + ". " + size);
-        if (original <= compressed) {
+        if (original[0] <= compressed[0]) {
             throw new AssertionError("java.base not compressed.");
         }
     }
 
-    private Pool applyCompressor(Plugin plugin,
-            PoolImpl inputResources,
-            ModuleData res,
+    private ModulePool applyCompressor(Plugin plugin,
+            ModulePoolImpl inputResources,
+            ModuleEntry res,
             List<Pattern> includesPatterns,
-            List<Pattern> excludesPatterns) throws Exception {
+            List<Pattern> excludesPatterns) {
         TransformerPlugin compressor = (TransformerPlugin) plugin;
-        Pool compressedPool = new PoolImpl(ByteOrder.nativeOrder(), inputResources.getStringTable());
-        compressor.visit(inputResources, compressedPool);
+        ModulePool compressedModulePool = new ModulePoolImpl(ByteOrder.nativeOrder(), inputResources.getStringTable());
+        compressor.visit(inputResources, compressedModulePool);
         String path = res.getPath();
-        ModuleData compressed = compressedPool.get(path);
+        ModuleEntry compressed = compressedModulePool.findEntry(path).get();
         CompressedResourceHeader header
                 = CompressedResourceHeader.readFromResource(ByteOrder.nativeOrder(), compressed.getBytes());
         if (isIncluded(includesPatterns, excludesPatterns, path)) {
@@ -310,29 +310,33 @@
         } else if (header != null) {
             throw new AssertionError("Path should not be compressed: " + path);
         }
-        return compressedPool;
+        return compressedModulePool;
     }
 
     private void applyDecompressors(ResourceDecompressorFactory[] decompressors,
-            Pool inputResources,
-            Pool compressedResources,
+            ModulePool inputResources,
+            ModulePool compressedResources,
             Map<Integer, String> strings,
             List<Pattern> includesPatterns,
-            List<Pattern> excludesPatterns) throws Exception {
-        for (ModuleData compressed : compressedResources.getContent()) {
+            List<Pattern> excludesPatterns) {
+        compressedResources.entries().forEach(compressed -> {
             CompressedResourceHeader header = CompressedResourceHeader.readFromResource(
                     ByteOrder.nativeOrder(), compressed.getBytes());
             String path = compressed.getPath();
-            ModuleData orig = inputResources.get(path);
+            ModuleEntry orig = inputResources.findEntry(path).get();
             if (!isIncluded(includesPatterns, excludesPatterns, path)) {
-                continue;
+                return;
             }
             byte[] decompressed = compressed.getBytes();
             for (ResourceDecompressorFactory factory : decompressors) {
-                ResourceDecompressor decompressor = factory.newDecompressor(new Properties());
-                decompressed = decompressor.decompress(
+                try {
+                    ResourceDecompressor decompressor = factory.newDecompressor(new Properties());
+                    decompressed = decompressor.decompress(
                         strings::get, decompressed,
                         CompressedResourceHeader.getSize(), header.getUncompressedSize());
+                } catch (Exception exp) {
+                    throw new RuntimeException(exp);
+                }
             }
 
             if (decompressed.length != orig.getLength()) {
@@ -345,7 +349,7 @@
                     throw new AssertionError("Decompressed and original differ at index " + i);
                 }
             }
-        }
+        });
     }
 
     private boolean isIncluded(List<Pattern> includesPatterns, List<Pattern> excludesPatterns, String path) {
--- a/jdk/test/tools/jlink/plugins/ExcludeFilesPluginTest.java	Thu May 19 17:48:02 2016 +0000
+++ b/jdk/test/tools/jlink/plugins/ExcludeFilesPluginTest.java	Thu May 19 19:46:20 2016 +0000
@@ -35,12 +35,11 @@
 import java.nio.file.Files;
 import java.util.HashMap;
 import java.util.Map;
-import jdk.tools.jlink.internal.PoolImpl;
+import jdk.tools.jlink.internal.ModulePoolImpl;
 
 import jdk.tools.jlink.internal.plugins.ExcludeFilesPlugin;
-import jdk.tools.jlink.plugin.Pool;
-import jdk.tools.jlink.plugin.Pool.ModuleData;
-import jdk.tools.jlink.plugin.Pool.ModuleDataType;
+import jdk.tools.jlink.plugin.ModuleEntry;
+import jdk.tools.jlink.plugin.ModulePool;
 import jdk.tools.jlink.plugin.TransformerPlugin;
 
 public class ExcludeFilesPluginTest {
@@ -73,20 +72,20 @@
         prop.put(ExcludeFilesPlugin.NAME, s);
         ExcludeFilesPlugin fplug = new ExcludeFilesPlugin();
         fplug.configure(prop);
-        PoolImpl files = new PoolImpl();
-        PoolImpl fresult = new PoolImpl();
-        ModuleData f = Pool.newImageFile(module, "/" + module + "/" + sample,
-                ModuleDataType.CONFIG, new ByteArrayInputStream(new byte[0]), 0);
+        ModulePoolImpl files = new ModulePoolImpl();
+        ModulePoolImpl fresult = new ModulePoolImpl();
+        ModuleEntry f = ModuleEntry.create(module, "/" + module + "/" + sample,
+                ModuleEntry.Type.CONFIG, new ByteArrayInputStream(new byte[0]), 0);
         files.add(f);
 
         fplug.visit(files, fresult);
 
         if (exclude) {
-            if (fresult.getContent().contains(f)) {
+            if (fresult.contains(f)) {
                 throw new Exception(sample + " should be excluded by " + s);
             }
         } else {
-            if (!fresult.getContent().contains(f)) {
+            if (!fresult.contains(f)) {
                 throw new Exception(sample + " shouldn't be excluded by " + s);
             }
         }
--- a/jdk/test/tools/jlink/plugins/ExcludePluginTest.java	Thu May 19 17:48:02 2016 +0000
+++ b/jdk/test/tools/jlink/plugins/ExcludePluginTest.java	Thu May 19 19:46:20 2016 +0000
@@ -34,11 +34,11 @@
 import java.nio.file.Files;
 import java.util.HashMap;
 import java.util.Map;
-import jdk.tools.jlink.internal.PoolImpl;
+import jdk.tools.jlink.internal.ModulePoolImpl;
 
 import jdk.tools.jlink.internal.plugins.ExcludePlugin;
-import jdk.tools.jlink.plugin.Pool;
-import jdk.tools.jlink.plugin.Pool.ModuleData;
+import jdk.tools.jlink.plugin.ModuleEntry;
+import jdk.tools.jlink.plugin.ModulePool;
 
 public class ExcludePluginTest {
 
@@ -75,17 +75,17 @@
         prop.put(ExcludePlugin.NAME, s);
         ExcludePlugin excludePlugin = new ExcludePlugin();
         excludePlugin.configure(prop);
-        Pool resources = new PoolImpl();
-        ModuleData resource = Pool.newResource(sample, new byte[0]);
+        ModulePool resources = new ModulePoolImpl();
+        ModuleEntry resource = ModuleEntry.create(sample, new byte[0]);
         resources.add(resource);
-        Pool result = new PoolImpl();
+        ModulePool result = new ModulePoolImpl();
         excludePlugin.visit(resources, result);
         if (exclude) {
-            if (result.getContent().contains(resource)) {
+            if (result.contains(resource)) {
                 throw new AssertionError(sample + " should be excluded by " + s);
             }
         } else {
-            if (!result.getContent().contains(resource)) {
+            if (!result.contains(resource)) {
                 throw new AssertionError(sample + " shouldn't be excluded by " + s);
             }
         }
--- a/jdk/test/tools/jlink/plugins/ExcludeVMPluginTest.java	Thu May 19 17:48:02 2016 +0000
+++ b/jdk/test/tools/jlink/plugins/ExcludeVMPluginTest.java	Thu May 19 19:46:20 2016 +0000
@@ -32,13 +32,12 @@
 import java.io.ByteArrayInputStream;
 import java.util.HashMap;
 import java.util.Map;
-import jdk.tools.jlink.internal.PoolImpl;
+import jdk.tools.jlink.internal.ModulePoolImpl;
 
 import jdk.tools.jlink.internal.plugins.ExcludeVMPlugin;
 import jdk.tools.jlink.plugin.Plugin;
-import jdk.tools.jlink.plugin.Pool;
-import jdk.tools.jlink.plugin.Pool.ModuleData;
-import jdk.tools.jlink.plugin.Pool.ModuleDataType;
+import jdk.tools.jlink.plugin.ModulePool;
+import jdk.tools.jlink.plugin.ModuleEntry;
 import jdk.tools.jlink.plugin.TransformerPlugin;
 
 public class ExcludeVMPluginTest {
@@ -165,14 +164,14 @@
     private void doCheckVM(String vm, String[] input, String jvmcfg, String[] expectedOutput, String expectdJvmCfg) throws Exception {
         // Create a pool with jvm.cfg and the input paths.
         byte[] jvmcfgContent = jvmcfg.getBytes();
-        Pool pool = new PoolImpl();
-        pool.add(Pool.newImageFile("java.base", "/java.base/native/jvm.cfg",
-                ModuleDataType.NATIVE_LIB, new ByteArrayInputStream(jvmcfgContent), jvmcfgContent.length));
+        ModulePool pool = new ModulePoolImpl();
+        pool.add(ModuleEntry.create("java.base", "/java.base/native/jvm.cfg",
+                ModuleEntry.Type.NATIVE_LIB, new ByteArrayInputStream(jvmcfgContent), jvmcfgContent.length));
         for (String in : input) {
-            pool.add(Pool.newImageFile("java.base", in,
-                    ModuleDataType.NATIVE_LIB, new ByteArrayInputStream(new byte[0]), 0));
+            pool.add(ModuleEntry.create("java.base", in,
+                    ModuleEntry.Type.NATIVE_LIB, new ByteArrayInputStream(new byte[0]), 0));
         }
-        Pool out = new PoolImpl();
+        ModulePool out = new ModulePoolImpl();
 
         TransformerPlugin p = new ExcludeVMPlugin();
         Map<String, String> config = new HashMap<>();
@@ -182,22 +181,22 @@
         p.configure(config);
         p.visit(pool, out);
 
-        String newContent = new String(out.get("/java.base/native/jvm.cfg").stream().readAllBytes());
+        String newContent = new String(out.findEntry("/java.base/native/jvm.cfg").get().stream().readAllBytes());
 
         if (!expectdJvmCfg.equals(newContent)) {
             throw new Exception("Got content " + newContent + " expected " + expectdJvmCfg);
         }
 
-        if (out.getContent().size() != (expectedOutput.length + 1)) {
-            for (ModuleData m : out.getContent()) {
+        if (out.getEntryCount() != (expectedOutput.length + 1)) {
+            out.entries().forEach(m -> {
                 System.err.println(m.getPath());
-            }
-            throw new Exception("Invalid output size " + out.getContent().size() + " expected " + (expectedOutput.length + 1));
+            });
+            throw new Exception("Invalid output size " + out.getEntryCount() + " expected " + (expectedOutput.length + 1));
         }
 
-        for (ModuleData md : out.getContent()) {
+        out.entries().forEach(md -> {
             if (md.getPath().equals("/java.base/native/jvm.cfg")) {
-                continue;
+                return;
             }
             boolean contained = false;
             for (String o : expectedOutput) {
@@ -207,9 +206,9 @@
                 }
             }
             if (!contained) {
-                throw new Exception(md.getPath() + " not expected");
+                throw new RuntimeException(md.getPath() + " not expected");
             }
-        }
+        });
 
     }
 
--- a/jdk/test/tools/jlink/plugins/FileCopierPluginTest.java	Thu May 19 17:48:02 2016 +0000
+++ b/jdk/test/tools/jlink/plugins/FileCopierPluginTest.java	Thu May 19 19:46:20 2016 +0000
@@ -26,6 +26,7 @@
  * @summary Test files copy plugin
  * @author Jean-Francois Denise
  * @modules jdk.jlink/jdk.tools.jlink.internal
+ *          jdk.jlink/jdk.tools.jlink.builder
  *          jdk.jlink/jdk.tools.jlink.internal.plugins
  * @run main FileCopierPluginTest
  */
@@ -36,13 +37,12 @@
 import java.util.Collections;
 import java.util.HashMap;
 import java.util.Map;
-import jdk.tools.jlink.internal.PoolImpl;
+import jdk.tools.jlink.internal.ModulePoolImpl;
 import jdk.tools.jlink.builder.DefaultImageBuilder;
 
 import jdk.tools.jlink.internal.plugins.FileCopierPlugin;
-import jdk.tools.jlink.plugin.Pool;
-import jdk.tools.jlink.plugin.Pool.ModuleData;
-import jdk.tools.jlink.plugin.Pool.ModuleDataType;
+import jdk.tools.jlink.plugin.ModuleEntry;
+import jdk.tools.jlink.plugin.ModulePool;
 
 public class FileCopierPluginTest {
 
@@ -85,21 +85,20 @@
         Map<String, String> conf = new HashMap<>();
         conf.put(FileCopierPlugin.NAME, builder.toString());
         plug.configure(conf);
-        Pool pool = new PoolImpl();
-        plug.visit(new PoolImpl(), pool);
-        if (pool.getContent().size() != expected) {
+        ModulePool pool = new ModulePoolImpl();
+        plug.visit(new ModulePoolImpl(), pool);
+        if (pool.getEntryCount() != expected) {
             throw new AssertionError("Wrong number of added files");
         }
-        for (ModuleData f : pool.getContent()) {
-            if (!f.getType().equals(ModuleDataType.OTHER)) {
+        pool.entries().forEach(f -> {
+            if (!f.getType().equals(ModuleEntry.Type.OTHER)) {
                 throw new AssertionError("Invalid type " + f.getType()
                         + " for file " + f.getPath());
             }
             if (f.stream() == null) {
                 throw new AssertionError("Null stream for file " + f.getPath());
             }
-
-        }
+        });
         Path root = new File(".").toPath();
         DefaultImageBuilder imgbuilder = new DefaultImageBuilder(root);
         imgbuilder.storeFiles(pool);
--- a/jdk/test/tools/jlink/plugins/LastSorterTest.java	Thu May 19 17:48:02 2016 +0000
+++ b/jdk/test/tools/jlink/plugins/LastSorterTest.java	Thu May 19 19:46:20 2016 +0000
@@ -26,6 +26,7 @@
  * @summary Test last sorter property
  * @author Jean-Francois Denise
  * @modules jdk.jlink/jdk.tools.jlink.internal
+ *          jdk.jlink/jdk.tools.jlink
  * @run main/othervm LastSorterTest
  */
 
@@ -40,12 +41,12 @@
 import jdk.tools.jlink.internal.ImagePluginConfiguration;
 import jdk.tools.jlink.internal.PluginRepository;
 import jdk.tools.jlink.internal.ImagePluginStack;
-import jdk.tools.jlink.internal.PoolImpl;
+import jdk.tools.jlink.internal.ModulePoolImpl;
 import jdk.tools.jlink.Jlink;
 import jdk.tools.jlink.Jlink.PluginsConfiguration;
 import jdk.tools.jlink.plugin.Plugin;
-import jdk.tools.jlink.plugin.Pool;
-import jdk.tools.jlink.plugin.Pool.ModuleData;
+import jdk.tools.jlink.plugin.ModuleEntry;
+import jdk.tools.jlink.plugin.ModulePool;
 import jdk.tools.jlink.plugin.TransformerPlugin;
 
 public class LastSorterTest {
@@ -80,7 +81,7 @@
         ImagePluginStack stack = ImagePluginConfiguration.parseConfiguration(config);
 
         // check order
-        PoolImpl res = fillOutResourcePool();
+        ModulePoolImpl res = fillOutResourceModulePool();
 
         try {
             stack.visitResources(res);
@@ -91,18 +92,18 @@
         }
     }
 
-    private PoolImpl fillOutResourcePool() throws Exception {
-        PoolImpl res = new PoolImpl();
-        res.add(Pool.newResource("/eee/bbb/res1.class", new byte[90]));
-        res.add(Pool.newResource("/aaaa/bbb/res2.class", new byte[90]));
-        res.add(Pool.newResource("/bbb/aa/res1.class", new byte[90]));
-        res.add(Pool.newResource("/aaaa/bbb/res3.class", new byte[90]));
-        res.add(Pool.newResource("/bbb/aa/res2.class", new byte[90]));
-        res.add(Pool.newResource("/fff/bbb/res1.class", new byte[90]));
-        res.add(Pool.newResource("/aaaa/bbb/res1.class", new byte[90]));
-        res.add(Pool.newResource("/bbb/aa/res3.class", new byte[90]));
-        res.add(Pool.newResource("/ccc/bbb/res1.class", new byte[90]));
-        res.add(Pool.newResource("/ddd/bbb/res1.class", new byte[90]));
+    private ModulePoolImpl fillOutResourceModulePool() throws Exception {
+        ModulePoolImpl res = new ModulePoolImpl();
+        res.add(ModuleEntry.create("/eee/bbb/res1.class", new byte[90]));
+        res.add(ModuleEntry.create("/aaaa/bbb/res2.class", new byte[90]));
+        res.add(ModuleEntry.create("/bbb/aa/res1.class", new byte[90]));
+        res.add(ModuleEntry.create("/aaaa/bbb/res3.class", new byte[90]));
+        res.add(ModuleEntry.create("/bbb/aa/res2.class", new byte[90]));
+        res.add(ModuleEntry.create("/fff/bbb/res1.class", new byte[90]));
+        res.add(ModuleEntry.create("/aaaa/bbb/res1.class", new byte[90]));
+        res.add(ModuleEntry.create("/bbb/aa/res3.class", new byte[90]));
+        res.add(ModuleEntry.create("/ccc/bbb/res1.class", new byte[90]));
+        res.add(ModuleEntry.create("/ddd/bbb/res1.class", new byte[90]));
         return res;
     }
 
@@ -124,7 +125,7 @@
         ImagePluginStack stack = ImagePluginConfiguration.parseConfiguration(config);
 
         // check order
-        PoolImpl res = fillOutResourcePool();
+        ModulePoolImpl res = fillOutResourceModulePool();
 
         stack.visitResources(res);
     }
@@ -159,7 +160,7 @@
         ImagePluginStack stack = ImagePluginConfiguration.parseConfiguration(config);
 
         // check order
-        PoolImpl res = fillOutResourcePool();
+        ModulePoolImpl res = fillOutResourceModulePool();
         try {
             stack.visitResources(res);
             throw new AssertionError("Order was changed after the last sorter, but no exception occurred");
@@ -178,17 +179,17 @@
         }
 
         @Override
-        public void visit(Pool resources, Pool output) {
-            List<ModuleData> paths = new ArrayList<>();
-            for (ModuleData res : resources.getContent()) {
+        public void visit(ModulePool resources, ModulePool output) {
+            List<ModuleEntry> paths = new ArrayList<>();
+            resources.entries().forEach(res -> {
                 if (res.getPath().startsWith(starts)) {
                     paths.add(0, res);
                 } else {
                     paths.add(res);
                 }
-            }
+            });
 
-            for (ModuleData r : paths) {
+            for (ModuleEntry r : paths) {
                 output.add(r);
             }
         }
@@ -199,9 +200,9 @@
         }
 
         @Override
-        public Set<PluginType> getType() {
-            Set<PluginType> set = new HashSet<>();
-            set.add(CATEGORY.TRANSFORMER);
+        public Set<Category> getType() {
+            Set<Category> set = new HashSet<>();
+            set.add(Category.TRANSFORMER);
             return Collections.unmodifiableSet(set);
         }
 
--- a/jdk/test/tools/jlink/plugins/OrderResourcesPluginTest.java	Thu May 19 17:48:02 2016 +0000
+++ b/jdk/test/tools/jlink/plugins/OrderResourcesPluginTest.java	Thu May 19 19:46:20 2016 +0000
@@ -36,11 +36,12 @@
 import java.util.Collection;
 import java.util.HashMap;
 import java.util.Map;
-import jdk.tools.jlink.internal.PoolImpl;
+import java.util.stream.Collectors;
 
+import jdk.tools.jlink.internal.ModulePoolImpl;
 import jdk.tools.jlink.internal.plugins.OrderResourcesPlugin;
-import jdk.tools.jlink.plugin.Pool;
-import jdk.tools.jlink.plugin.Pool.ModuleData;
+import jdk.tools.jlink.plugin.ModuleEntry;
+import jdk.tools.jlink.plugin.ModulePool;
 import jdk.tools.jlink.plugin.TransformerPlugin;
 
 public class OrderResourcesPluginTest {
@@ -50,52 +51,52 @@
     }
 
     public void test() throws Exception {
-        ModuleData[] array = {
-                Pool.newResource("/module1/toto1.class", new byte[0]),
-                Pool.newResource("/module2/toto2.class", new byte[0]),
-                Pool.newResource("/module3/toto3.class", new byte[0]),
-                Pool.newResource("/module3/toto3/module-info.class", new byte[0]),
-                Pool.newResource("/zazou/toto.class", new byte[0]),
-                Pool.newResource("/module4/zazou.class", new byte[0]),
-                Pool.newResource("/module5/toto5.class", new byte[0]),
-                Pool.newResource("/module6/toto6/module-info.class", new byte[0])
+        ModuleEntry[] array = {
+                ModuleEntry.create("/module1/toto1.class", new byte[0]),
+                ModuleEntry.create("/module2/toto2.class", new byte[0]),
+                ModuleEntry.create("/module3/toto3.class", new byte[0]),
+                ModuleEntry.create("/module3/toto3/module-info.class", new byte[0]),
+                ModuleEntry.create("/zazou/toto.class", new byte[0]),
+                ModuleEntry.create("/module4/zazou.class", new byte[0]),
+                ModuleEntry.create("/module5/toto5.class", new byte[0]),
+                ModuleEntry.create("/module6/toto6/module-info.class", new byte[0])
         };
 
-        ModuleData[] sorted = {
-                Pool.newResource("/zazou/toto.class", new byte[0]),
-                Pool.newResource("/module3/toto3/module-info.class", new byte[0]),
-                Pool.newResource("/module6/toto6/module-info.class", new byte[0]),
-                Pool.newResource("/module1/toto1.class", new byte[0]),
-                Pool.newResource("/module2/toto2.class", new byte[0]),
-                Pool.newResource("/module3/toto3.class", new byte[0]),
-                Pool.newResource("/module4/zazou.class", new byte[0]),
-                Pool.newResource("/module5/toto5.class", new byte[0])
+        ModuleEntry[] sorted = {
+                ModuleEntry.create("/zazou/toto.class", new byte[0]),
+                ModuleEntry.create("/module3/toto3/module-info.class", new byte[0]),
+                ModuleEntry.create("/module6/toto6/module-info.class", new byte[0]),
+                ModuleEntry.create("/module1/toto1.class", new byte[0]),
+                ModuleEntry.create("/module2/toto2.class", new byte[0]),
+                ModuleEntry.create("/module3/toto3.class", new byte[0]),
+                ModuleEntry.create("/module4/zazou.class", new byte[0]),
+                ModuleEntry.create("/module5/toto5.class", new byte[0])
         };
 
-        ModuleData[] sorted2 = {
-            Pool.newResource("/module5/toto5.class", new byte[0]),
-            Pool.newResource("/module6/toto6/module-info.class", new byte[0]),
-            Pool.newResource("/module4/zazou.class", new byte[0]),
-            Pool.newResource("/module3/toto3.class", new byte[0]),
-            Pool.newResource("/module3/toto3/module-info.class", new byte[0]),
-            Pool.newResource("/module1/toto1.class", new byte[0]),
-            Pool.newResource("/module2/toto2.class", new byte[0]),
-            Pool.newResource("/zazou/toto.class", new byte[0])
+        ModuleEntry[] sorted2 = {
+            ModuleEntry.create("/module5/toto5.class", new byte[0]),
+            ModuleEntry.create("/module6/toto6/module-info.class", new byte[0]),
+            ModuleEntry.create("/module4/zazou.class", new byte[0]),
+            ModuleEntry.create("/module3/toto3.class", new byte[0]),
+            ModuleEntry.create("/module3/toto3/module-info.class", new byte[0]),
+            ModuleEntry.create("/module1/toto1.class", new byte[0]),
+            ModuleEntry.create("/module2/toto2.class", new byte[0]),
+            ModuleEntry.create("/zazou/toto.class", new byte[0])
         };
 
-        Pool resources = new PoolImpl();
-        for (ModuleData r : array) {
+        ModulePool resources = new ModulePoolImpl();
+        for (ModuleEntry r : array) {
             resources.add(r);
         }
 
         {
-            Pool out = new PoolImpl();
+            ModulePool out = new ModulePoolImpl();
             Map<String, String> config = new HashMap<>();
             config.put(OrderResourcesPlugin.NAME, "/zazou/*,*/module-info.class");
             TransformerPlugin p = new OrderResourcesPlugin();
             p.configure(config);
             p.visit(resources, out);
-            check(out.getContent(), sorted);
+            check(out.entries().collect(Collectors.toList()), sorted);
         }
 
         {
@@ -112,26 +113,26 @@
             }
             Files.write(order.toPath(), builder.toString().getBytes());
 
-            Pool out = new PoolImpl();
+            ModulePool out = new ModulePoolImpl();
             Map<String, String> config = new HashMap<>();
             config.put(OrderResourcesPlugin.NAME, "@" + order.getAbsolutePath());
             TransformerPlugin p = new OrderResourcesPlugin();
             p.configure(config);
             p.visit(resources, out);
-            check(out.getContent(), sorted2);
+            check(out.entries().collect(Collectors.toList()), sorted2);
 
         }
     }
 
-    private void check(Collection<ModuleData> outResources,
-            ModuleData[] sorted) {
+    private void check(Collection<ModuleEntry> outResources,
+            ModuleEntry[] sorted) {
         if (outResources.size() != sorted.length) {
             throw new AssertionError("Wrong number of resources:\n"
                     + "expected: " + Arrays.toString(sorted) + ",\n"
                     + "     got: " + outResources);
         }
         int i = 0;
-        for (ModuleData r : outResources) {
+        for (ModuleEntry r : outResources) {
             System.err.println("Resource: " + r);
             if (!sorted[i].getPath().equals(r.getPath())) {
                 throw new AssertionError("Resource not properly sorted, difference at: " + i + "\n"
--- a/jdk/test/tools/jlink/plugins/PluginOrderTest.java	Thu May 19 17:48:02 2016 +0000
+++ b/jdk/test/tools/jlink/plugins/PluginOrderTest.java	Thu May 19 19:46:20 2016 +0000
@@ -44,8 +44,8 @@
 
 import jdk.tools.jlink.internal.PluginOrderingGraph;
 import jdk.tools.jlink.plugin.Plugin;
-import jdk.tools.jlink.plugin.Plugin.CATEGORY;
-import jdk.tools.jlink.plugin.Pool;
+import jdk.tools.jlink.plugin.Plugin.Category;
+import jdk.tools.jlink.plugin.ModulePool;
 import jdk.tools.jlink.plugin.TransformerPlugin;
 
 public class PluginOrderTest {
@@ -96,8 +96,8 @@
         set.add("plug2");
         List<Plugin> plugins = new ArrayList<>();
         plugins.add(new Plug("plug2", Collections.emptySet(), Collections.emptySet(),
-                CATEGORY.TRANSFORMER));
-        plugins.add(new Plug("plug1", set, Collections.emptySet(), CATEGORY.TRANSFORMER));
+                Category.TRANSFORMER));
+        plugins.add(new Plug("plug1", set, Collections.emptySet(), Category.TRANSFORMER));
         List<Plugin> ordered = PluginOrderingGraph.sort(plugins);
         if (ordered.get(0) != plugins.get(1) || ordered.get(1) != plugins.get(0)) {
             throw new Exception("Invalid sorting");
@@ -108,32 +108,32 @@
         Set<String> lst1 = new HashSet<>();
         lst1.add("plug2");
         lst1.add("plug3");
-        Plugin p1 = new Plug("plug1", lst1, Collections.emptySet(), CATEGORY.TRANSFORMER);
+        Plugin p1 = new Plug("plug1", lst1, Collections.emptySet(), Category.TRANSFORMER);
 
-        Plugin p2 = new Plug("plug2", Collections.emptySet(), Collections.emptySet(), CATEGORY.TRANSFORMER);
+        Plugin p2 = new Plug("plug2", Collections.emptySet(), Collections.emptySet(), Category.TRANSFORMER);
 
         Set<String> lst3 = new HashSet<>();
         lst3.add("plug4");
         lst3.add("plug6");
-        Plugin p3 = new Plug("plug3", lst3, Collections.emptySet(), CATEGORY.TRANSFORMER);
+        Plugin p3 = new Plug("plug3", lst3, Collections.emptySet(), Category.TRANSFORMER);
 
-        Plugin p4 = new Plug("plug4", Collections.emptySet(), Collections.emptySet(), CATEGORY.TRANSFORMER);
+        Plugin p4 = new Plug("plug4", Collections.emptySet(), Collections.emptySet(), Category.TRANSFORMER);
 
         Set<String> lst5 = new HashSet<>();
         lst5.add("plug3");
         lst5.add("plug1");
         lst5.add("plug2");
         lst5.add("plug6");
-        Plugin p5 = new Plug("plug5", lst5, Collections.emptySet(), CATEGORY.TRANSFORMER);
+        Plugin p5 = new Plug("plug5", lst5, Collections.emptySet(), Category.TRANSFORMER);
 
         Set<String> lst6 = new HashSet<>();
         lst6.add("plug4");
         lst6.add("plug2");
-        Plugin p6 = new Plug("plug6", lst6, Collections.emptySet(), CATEGORY.TRANSFORMER);
+        Plugin p6 = new Plug("plug6", lst6, Collections.emptySet(), Category.TRANSFORMER);
 
-        Plugin p7 = new Plug("plug7", Collections.emptySet(), Collections.emptySet(), CATEGORY.TRANSFORMER);
+        Plugin p7 = new Plug("plug7", Collections.emptySet(), Collections.emptySet(), Category.TRANSFORMER);
 
-        Plugin p8 = new Plug("plug8", Collections.emptySet(), Collections.emptySet(), CATEGORY.TRANSFORMER);
+        Plugin p8 = new Plug("plug8", Collections.emptySet(), Collections.emptySet(), Category.TRANSFORMER);
 
         List<Plugin> plugins = new ArrayList<>();
         plugins.add(p1);
@@ -153,11 +153,11 @@
         set2.add("plug1");
         List<Plugin> plugins = new ArrayList<>();
         plugins.add(new Plug("plug2", set2, Collections.emptySet(),
-                CATEGORY.TRANSFORMER));
+                Category.TRANSFORMER));
 
         Set<String> set1 = new HashSet<>();
         set1.add("plug2");
-        plugins.add(new Plug("plug1", set1, Collections.emptySet(), CATEGORY.TRANSFORMER));
+        plugins.add(new Plug("plug1", set1, Collections.emptySet(), Category.TRANSFORMER));
         PluginOrderingGraph.sort(plugins);
 
     }
@@ -166,31 +166,31 @@
         Set<String> lst1 = new HashSet<>();
         lst1.add("plug2");
         lst1.add("plug3");
-        Plugin p1 = new Plug("plug1", lst1, Collections.emptySet(), CATEGORY.TRANSFORMER);
+        Plugin p1 = new Plug("plug1", lst1, Collections.emptySet(), Category.TRANSFORMER);
 
-        Plugin p2 = new Plug("plug2", Collections.emptySet(), Collections.emptySet(), CATEGORY.TRANSFORMER);
+        Plugin p2 = new Plug("plug2", Collections.emptySet(), Collections.emptySet(), Category.TRANSFORMER);
 
         Set<String> lst3 = new HashSet<>();
         lst3.add("plug4");
         lst3.add("plug6");
-        Plugin p3 = new Plug("plug3", lst3, Collections.emptySet(), CATEGORY.TRANSFORMER);
+        Plugin p3 = new Plug("plug3", lst3, Collections.emptySet(), Category.TRANSFORMER);
 
-        Plugin p4 = new Plug("plug4", Collections.emptySet(), Collections.emptySet(), CATEGORY.TRANSFORMER);
+        Plugin p4 = new Plug("plug4", Collections.emptySet(), Collections.emptySet(), Category.TRANSFORMER);
 
         Set<String> lst5 = new HashSet<>();
         lst5.add("plug3");
         lst5.add("plug1");
         lst5.add("plug2");
-        Plugin p5 = new Plug("plug5", lst5, Collections.emptySet(), CATEGORY.TRANSFORMER);
+        Plugin p5 = new Plug("plug5", lst5, Collections.emptySet(), Category.TRANSFORMER);
 
         Set<String> lst6 = new HashSet<>();
         lst6.add("plug4");
         lst6.add("plug1");
-        Plugin p6 = new Plug("plug6", lst6, Collections.emptySet(), CATEGORY.TRANSFORMER);
+        Plugin p6 = new Plug("plug6", lst6, Collections.emptySet(), Category.TRANSFORMER);
 
-        Plugin p7 = new Plug("plug7", Collections.emptySet(), Collections.emptySet(), CATEGORY.TRANSFORMER);
+        Plugin p7 = new Plug("plug7", Collections.emptySet(), Collections.emptySet(), Category.TRANSFORMER);
 
-        Plugin p8 = new Plug("plug8", Collections.emptySet(), Collections.emptySet(), CATEGORY.TRANSFORMER);
+        Plugin p8 = new Plug("plug8", Collections.emptySet(), Collections.emptySet(), Category.TRANSFORMER);
 
         List<Plugin> plugins = new ArrayList<>();
         plugins.add(p1);
@@ -208,8 +208,8 @@
         Set<String> lst1 = new HashSet<>();
         lst1.add("plug2");
         lst1.add("plug3");
-        Plugin p = new Plug("plug1", lst1, Collections.emptySet(), CATEGORY.TRANSFORMER);
-        Plugin p2 = new Plug("plug2", Collections.emptySet(), Collections.emptySet(), CATEGORY.TRANSFORMER);
+        Plugin p = new Plug("plug1", lst1, Collections.emptySet(), Category.TRANSFORMER);
+        Plugin p2 = new Plug("plug2", Collections.emptySet(), Collections.emptySet(), Category.TRANSFORMER);
 
         Set<String> lst3 = new HashSet<>();
         lst3.add("plug2");
@@ -217,7 +217,7 @@
         Set<String> lst4 = new HashSet<>();
         lst4.add("plug1");
 
-        Plugin p3 = new Plug("plug3", lst4, lst3, CATEGORY.TRANSFORMER);
+        Plugin p3 = new Plug("plug3", lst4, lst3, Category.TRANSFORMER);
         List<Plugin> plugins = new ArrayList<>();
         plugins.add(p);
         plugins.add(p2);
@@ -229,10 +229,10 @@
 
         private final Set<String> isBefore;
         private final Set<String> isAfter;
-        private final CATEGORY category;
+        private final Category category;
         private final String name;
 
-        private Plug(String name, Set<String> isBefore, Set<String> isAfter, CATEGORY category) {
+        private Plug(String name, Set<String> isBefore, Set<String> isAfter, Category category) {
             this.name = name;
             this.isBefore = isBefore;
             this.isAfter = isAfter;
@@ -255,12 +255,12 @@
         }
 
         @Override
-        public void visit(Pool in, Pool out) {
+        public void visit(ModulePool in, ModulePool out) {
 
         }
 
         @Override
-        public Set<PluginType> getType() {
+        public Set<Category> getType() {
             return Collections.singleton(category);
         }
 
--- a/jdk/test/tools/jlink/plugins/PluginsNegativeTest.java	Thu May 19 17:48:02 2016 +0000
+++ b/jdk/test/tools/jlink/plugins/PluginsNegativeTest.java	Thu May 19 19:46:20 2016 +0000
@@ -26,6 +26,7 @@
  * @summary Negative test for ImagePluginStack.
  * @author Andrei Eremeev
  * @modules jdk.jlink/jdk.tools.jlink.internal
+ *          jdk.jlink/jdk.tools.jlink
  * @run main/othervm PluginsNegativeTest
  */
 import java.lang.reflect.Layer;
@@ -39,11 +40,12 @@
 import jdk.tools.jlink.internal.ImagePluginConfiguration;
 import jdk.tools.jlink.internal.PluginRepository;
 import jdk.tools.jlink.internal.ImagePluginStack;
-import jdk.tools.jlink.internal.PoolImpl;
+import jdk.tools.jlink.internal.ModulePoolImpl;
 import jdk.tools.jlink.Jlink;
 import jdk.tools.jlink.Jlink.PluginsConfiguration;
 import jdk.tools.jlink.plugin.Plugin;
-import jdk.tools.jlink.plugin.Pool;
+import jdk.tools.jlink.plugin.ModuleEntry;
+import jdk.tools.jlink.plugin.ModulePool;
 import jdk.tools.jlink.plugin.TransformerPlugin;
 
 public class PluginsNegativeTest {
@@ -96,8 +98,8 @@
         plugins.add(createPlugin("plugin"));
         ImagePluginStack stack = ImagePluginConfiguration.parseConfiguration(new PluginsConfiguration(plugins,
                 null, null));
-        PoolImpl inResources = new PoolImpl();
-        inResources.add(Pool.newResource("/aaa/bbb/A", new byte[10]));
+        ModulePoolImpl inResources = new ModulePoolImpl();
+        inResources.add(ModuleEntry.create("/aaa/bbb/A", new byte[10]));
         try {
             stack.visitResources(inResources);
             throw new AssertionError("Exception expected when output resource is empty");
@@ -110,8 +112,8 @@
         plugins.add(createPlugin("plugin"));
         ImagePluginStack stack = ImagePluginConfiguration.parseConfiguration(new PluginsConfiguration(plugins,
                 null, null));
-        PoolImpl inResources = new PoolImpl();
-        PoolImpl outResources = (PoolImpl) stack.visitResources(inResources);
+        ModulePoolImpl inResources = new ModulePoolImpl();
+        ModulePoolImpl outResources = (ModulePoolImpl) stack.visitResources(inResources);
         if (!outResources.isEmpty()) {
             throw new AssertionError("Output resource is not empty");
         }
@@ -126,7 +128,7 @@
         }
 
         @Override
-        public void visit(Pool inResources, Pool outResources) {
+        public void visit(ModulePool inResources, ModulePool outResources) {
             // do nothing
         }
 
@@ -136,9 +138,9 @@
         }
 
         @Override
-        public Set<PluginType> getType() {
-            Set<PluginType> set = new HashSet<>();
-            set.add(CATEGORY.TRANSFORMER);
+        public Set<Category> getType() {
+            Set<Category> set = new HashSet<>();
+            set.add(Category.TRANSFORMER);
             return Collections.unmodifiableSet(set);
         }
 
--- a/jdk/test/tools/jlink/plugins/PrevisitorTest.java	Thu May 19 17:48:02 2016 +0000
+++ b/jdk/test/tools/jlink/plugins/PrevisitorTest.java	Thu May 19 19:46:20 2016 +0000
@@ -26,6 +26,7 @@
  * @summary Test previsitor
  * @author Andrei Eremeev
  * @modules jdk.jlink/jdk.tools.jlink.internal
+ *          jdk.jlink/jdk.tools.jlink
  * @run main/othervm PrevisitorTest
  */
 import java.nio.ByteOrder;
@@ -36,19 +37,20 @@
 import java.util.HashSet;
 import java.util.List;
 import java.util.Map;
+import java.util.Optional;
 import java.util.Set;
 import java.util.stream.Collectors;
 
 import jdk.tools.jlink.internal.ImagePluginConfiguration;
 import jdk.tools.jlink.internal.PluginRepository;
 import jdk.tools.jlink.internal.ImagePluginStack;
-import jdk.tools.jlink.internal.PoolImpl;
+import jdk.tools.jlink.internal.ModulePoolImpl;
 import jdk.tools.jlink.internal.ResourcePrevisitor;
 import jdk.tools.jlink.internal.StringTable;
 import jdk.tools.jlink.Jlink;
 import jdk.tools.jlink.plugin.Plugin;
-import jdk.tools.jlink.plugin.Pool;
-import jdk.tools.jlink.plugin.Pool.ModuleData;
+import jdk.tools.jlink.plugin.ModuleEntry;
+import jdk.tools.jlink.plugin.ModulePool;
 import jdk.tools.jlink.plugin.TransformerPlugin;
 
 public class PrevisitorTest {
@@ -68,17 +70,17 @@
         plugins.add(createPlugin(CustomPlugin.NAME));
         ImagePluginStack stack = ImagePluginConfiguration.parseConfiguration(new Jlink.PluginsConfiguration(plugins,
                 null, null));
-        PoolImpl inResources = new PoolImpl(ByteOrder.nativeOrder(), new CustomStringTable());
-        inResources.add(Pool.newResource("/aaa/bbb/res1.class", new byte[90]));
-        inResources.add(Pool.newResource("/aaa/bbb/res2.class", new byte[90]));
-        inResources.add(Pool.newResource("/aaa/bbb/res3.class", new byte[90]));
-        inResources.add(Pool.newResource("/aaa/ddd/res1.class", new byte[90]));
-        inResources.add(Pool.newResource("/aaa/res1.class", new byte[90]));
-        Pool outResources = stack.visitResources(inResources);
-        Collection<String> input = inResources.getContent().stream()
+        ModulePoolImpl inResources = new ModulePoolImpl(ByteOrder.nativeOrder(), new CustomStringTable());
+        inResources.add(ModuleEntry.create("/aaa/bbb/res1.class", new byte[90]));
+        inResources.add(ModuleEntry.create("/aaa/bbb/res2.class", new byte[90]));
+        inResources.add(ModuleEntry.create("/aaa/bbb/res3.class", new byte[90]));
+        inResources.add(ModuleEntry.create("/aaa/ddd/res1.class", new byte[90]));
+        inResources.add(ModuleEntry.create("/aaa/res1.class", new byte[90]));
+        ModulePool outResources = stack.visitResources(inResources);
+        Collection<String> input = inResources.entries()
                 .map(Object::toString)
                 .collect(Collectors.toList());
-        Collection<String> output = outResources.getContent().stream()
+        Collection<String> output = outResources.entries()
                 .map(Object::toString)
                 .collect(Collectors.toList());
         if (!input.equals(output)) {
@@ -114,19 +116,20 @@
         private boolean isPrevisitCalled = false;
 
         @Override
-        public void visit(Pool inResources, Pool outResources) {
+        public void visit(ModulePool inResources, ModulePool outResources) {
             if (!isPrevisitCalled) {
                 throw new AssertionError("Previsit was not called");
             }
             CustomStringTable table = (CustomStringTable)
-                    ((PoolImpl) inResources).getStringTable();
+                    ((ModulePoolImpl) inResources).getStringTable();
             if (table.size() == 0) {
                 throw new AssertionError("Table is empty");
             }
             Map<String, Integer> count = new HashMap<>();
             for (int i = 0; i < table.size(); ++i) {
                 String s = table.getString(i);
-                if (inResources.get(s) != null) {
+                Optional<ModuleEntry> e = inResources.findEntry(s);
+                if (e.isPresent()) {
                     throw new AssertionError();
                 }
                 count.compute(s, (k, c) -> 1 + (c == null ? 0 : c));
@@ -136,9 +139,9 @@
                     throw new AssertionError("Expected one entry in the table, got: " + v + " for " + k);
                 }
             });
-            for (ModuleData r : inResources.getContent()) {
+            inResources.entries().forEach(r -> {
                 outResources.add(r);
-            }
+            });
         }
 
         @Override
@@ -147,21 +150,21 @@
         }
 
         @Override
-        public void previsit(Pool resources, StringTable strings) {
+        public void previsit(ModulePool resources, StringTable strings) {
             isPrevisitCalled = true;
-            for (ModuleData r : resources.getContent()) {
+            resources.entries().forEach(r -> {
                 String s = r.getPath();
                 int lastIndexOf = s.lastIndexOf('/');
                 if (lastIndexOf >= 0) {
                     strings.addString(s.substring(0, lastIndexOf));
                 }
-            }
+            });
         }
 
         @Override
-        public Set<PluginType> getType() {
-            Set<PluginType> set = new HashSet<>();
-            set.add(CATEGORY.TRANSFORMER);
+        public Set<Category> getType() {
+            Set<Category> set = new HashSet<>();
+            set.add(Category.TRANSFORMER);
             return Collections.unmodifiableSet(set);
         }
     }
--- a/jdk/test/tools/jlink/plugins/StringSharingPluginTest.java	Thu May 19 17:48:02 2016 +0000
+++ b/jdk/test/tools/jlink/plugins/StringSharingPluginTest.java	Thu May 19 19:46:20 2016 +0000
@@ -38,6 +38,8 @@
  * @run main StringSharingPluginTest
  */
 
+import java.io.IOException;
+import java.io.UncheckedIOException;
 import java.nio.ByteBuffer;
 import java.nio.ByteOrder;
 import java.nio.file.Files;
@@ -50,11 +52,11 @@
 
 import jdk.internal.jimage.decompressor.CompressedResourceHeader;
 import jdk.internal.jimage.decompressor.StringSharingDecompressor;
-import jdk.tools.jlink.internal.PoolImpl;
+import jdk.tools.jlink.internal.ModulePoolImpl;
 import jdk.tools.jlink.internal.StringTable;
 import jdk.tools.jlink.internal.plugins.StringSharingPlugin;
-import jdk.tools.jlink.plugin.Pool;
-import jdk.tools.jlink.plugin.Pool.ModuleData;
+import jdk.tools.jlink.plugin.ModuleEntry;
+import jdk.tools.jlink.plugin.ModulePool;
 import jdk.tools.jlink.plugin.TransformerPlugin;
 import tests.Helper;
 import tests.JImageValidator;
@@ -78,7 +80,7 @@
         Map<String, Integer> map = new HashMap<>();
         Map<Integer, String> reversedMap = new HashMap<>();
 
-        PoolImpl resources = new PoolImpl(ByteOrder.nativeOrder(), new StringTable() {
+        ModulePoolImpl resources = new ModulePoolImpl(ByteOrder.nativeOrder(), new StringTable() {
             @Override
             public int addString(String str) {
                 Integer id = map.get(str);
@@ -104,7 +106,7 @@
                     byte[] content = Files.readAllBytes(p);
                     String path = p.toString().replace('\\', '/');
                     path = path.substring("/modules".length());
-                    ModuleData res = Pool.newResource(path, content);
+                    ModuleEntry res = ModuleEntry.create(path, content);
                     resources.add(res);
                 } catch (Exception ex) {
                     throw new RuntimeException(ex);
@@ -115,19 +117,23 @@
             stream.forEach(c);
         }
         TransformerPlugin plugin = new StringSharingPlugin();
-        PoolImpl result = new PoolImpl(resources.getByteOrder(), resources.getStringTable());
+        ModulePoolImpl result = new ModulePoolImpl(resources.getByteOrder(), resources.getStringTable());
         plugin.visit(resources, result);
 
         if (result.isEmpty()) {
             throw new AssertionError("No result");
         }
 
-        for (ModuleData res : result.getContent()) {
+        result.entries().forEach(res -> {
             if (res.getPath().endsWith(".class")) {
-                byte[] uncompacted = StringSharingDecompressor.normalize(reversedMap::get, res.getBytes(),
+                try {
+                    byte[] uncompacted = StringSharingDecompressor.normalize(reversedMap::get, res.getBytes(),
                         CompressedResourceHeader.getSize());
-                JImageValidator.readClass(uncompacted);
+                    JImageValidator.readClass(uncompacted);
+                } catch (IOException exp) {
+                    throw new UncheckedIOException(exp);
+                }
             }
-        }
+        });
     }
 }
--- a/jdk/test/tools/jlink/plugins/StripDebugPluginTest.java	Thu May 19 17:48:02 2016 +0000
+++ b/jdk/test/tools/jlink/plugins/StripDebugPluginTest.java	Thu May 19 19:46:20 2016 +0000
@@ -54,10 +54,10 @@
 import com.sun.tools.classfile.Method;
 import java.util.HashMap;
 import java.util.Map;
-import jdk.tools.jlink.internal.PoolImpl;
+import jdk.tools.jlink.internal.ModulePoolImpl;
 import jdk.tools.jlink.internal.plugins.StripDebugPlugin;
-import jdk.tools.jlink.plugin.Pool;
-import jdk.tools.jlink.plugin.Pool.ModuleData;
+import jdk.tools.jlink.plugin.ModuleEntry;
+import jdk.tools.jlink.plugin.ModulePool;
 import jdk.tools.jlink.plugin.TransformerPlugin;
 import tests.Helper;
 
@@ -106,7 +106,7 @@
         path = path.replace('\\', '/');
         StripDebugPlugin debug = new StripDebugPlugin();
         debug.configure(new HashMap<>());
-        ModuleData result1 = stripDebug(debug, Pool.newResource(path,content), path, infoPath, moduleInfo);
+        ModuleEntry result1 = stripDebug(debug, ModuleEntry.create(path,content), path, infoPath, moduleInfo);
 
         if (!path.endsWith("module-info.class")) {
             if (result1.getLength() >= content.length) {
@@ -116,7 +116,7 @@
             checkDebugAttributes(result1.getBytes());
         }
 
-        ModuleData result2 = stripDebug(debug, result1, path, infoPath, moduleInfo);
+        ModuleEntry result2 = stripDebug(debug, result1, path, infoPath, moduleInfo);
         if (result1.getLength() != result2.getLength()) {
             throw new AssertionError("removing debug info twice reduces class size of "
                     + path);
@@ -124,18 +124,18 @@
         checkDebugAttributes(result1.getBytes());
     }
 
-    private ModuleData stripDebug(TransformerPlugin debug, ModuleData classResource,
+    private ModuleEntry stripDebug(TransformerPlugin debug, ModuleEntry classResource,
             String path, String infoPath, byte[] moduleInfo) throws Exception {
-        Pool resources = new PoolImpl();
+        ModulePool resources = new ModulePoolImpl();
         resources.add(classResource);
         if (!path.endsWith("module-info.class")) {
-            ModuleData res2 = Pool.newResource(infoPath, moduleInfo);
+            ModuleEntry res2 = ModuleEntry.create(infoPath, moduleInfo);
             resources.add(res2);
         }
-        Pool results = new PoolImpl();
+        ModulePool results = new ModulePoolImpl();
         debug.visit(resources, results);
         System.out.println(classResource.getPath());
-        return results.get(classResource.getPath());
+        return results.findEntry(classResource.getPath()).get();
     }
 
     private void checkDebugAttributes(byte[] strippedClassFile) throws IOException, ConstantPoolException {
--- a/jdk/test/tools/launcher/modules/patch/PatchTest.java	Thu May 19 17:48:02 2016 +0000
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,196 +0,0 @@
-/*
- * Copyright (c) 2015, 2016, 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
- * @library /lib/testlibrary
- * @modules jdk.compiler
- * @build PatchTest CompilerUtils JarUtils jdk.testlibrary.*
- * @run testng PatchTest
- * @summary Basic test for -Xpatch
- */
-
-import java.io.File;
-import java.nio.file.Files;
-import java.nio.file.Path;
-import java.nio.file.Paths;
-import java.util.stream.Collectors;
-import java.util.stream.Stream;
-
-import static jdk.testlibrary.ProcessTools.*;
-
-import org.testng.annotations.BeforeTest;
-import org.testng.annotations.Test;
-import static org.testng.Assert.*;
-
-
-/**
- * Compiles and launches a test that uses -Xpatch with two directories of
- * classes to override existing and add new classes to modules in the
- * boot layer.
- *
- * The classes overridden or added via -Xpatch all define a public no-arg
- * constructor and override toString to return "hi". This allows the launched
- * test to check that the overridden classes are loaded.
- */
-
-@Test
-public class PatchTest {
-
-    // top-level source directory
-    private static final String TEST_SRC = System.getProperty("test.src");
-
-    // source/destination tree for the test module
-    private static final Path SRC_DIR = Paths.get(TEST_SRC, "src");
-    private static final Path MODS_DIR = Paths.get("mods");
-
-    // source/destination tree for patch tree 1
-    private static final Path SRC1_DIR = Paths.get(TEST_SRC, "src1");
-    private static final Path PATCHES1_DIR = Paths.get("patches1");
-
-    // source/destination tree for patch tree 2
-    private static final Path SRC2_DIR = Paths.get(TEST_SRC, "src2");
-    private static final Path PATCHES2_DIR = Paths.get("patches2");
-
-    // destination directory for patches packaged as JAR files
-    private static final Path PATCHES_DIR = Paths.get("patches");
-
-
-    // the classes overridden or added with -Xpatch
-    private static final String[] CLASSES = {
-
-        // java.base = boot loader
-        "java.base/java.text.Annotation",           // override class
-        "java.base/java.text.AnnotationBuddy",      // add class to package
-        "java.base/java.lang2.Object",              // new package
-
-        // jdk.naming.dns = platform class loader
-        "jdk.naming.dns/com.sun.jndi.dns.DnsClient",
-        "jdk.naming.dns/com.sun.jndi.dns.DnsClientBuddy",
-        "jdk.naming.dns/com.sun.jndi.dns2.Zone",
-
-        // jdk.compiler = application class loaded
-        "jdk.compiler/com.sun.tools.javac.Main",
-        "jdk.compiler/com.sun.tools.javac.MainBuddy",
-        "jdk.compiler/com.sun.tools.javac2.Main",
-
-    };
-
-
-    @BeforeTest
-    public void setup() throws Exception {
-
-        // javac -d mods/test src/test/**
-        boolean compiled= CompilerUtils.compile(SRC_DIR.resolve("test"),
-                                                MODS_DIR.resolve("test"));
-        assertTrue(compiled, "classes did not compile");
-
-        // javac -Xmodule:$MODULE -d patches1/$MODULE patches1/$MODULE/**
-        // jar cf patches/$MODULE-1.jar -C patches1/$MODULE .
-        for (Path src : Files.newDirectoryStream(SRC1_DIR)) {
-            Path output = PATCHES1_DIR.resolve(src.getFileName());
-            String mn = src.getFileName().toString();
-            compiled  = CompilerUtils.compile(src, output, "-Xmodule:" + mn);
-            assertTrue(compiled, "classes did not compile");
-            JarUtils.createJarFile(PATCHES_DIR.resolve(mn + "-1.jar"), output);
-        }
-
-        // javac -Xmodule:$MODULE -d patches2/$MODULE patches2/$MODULE/**
-        // jar cf patches/$MODULE-2.jar -C patches2/$MODULE .
-        for (Path src : Files.newDirectoryStream(SRC2_DIR)) {
-            Path output = PATCHES2_DIR.resolve(src.getFileName());
-            String mn = src.getFileName().toString();
-            compiled  = CompilerUtils.compile(src, output, "-Xmodule:" + mn);
-            assertTrue(compiled, "classes did not compile");
-            JarUtils.createJarFile(PATCHES_DIR.resolve(mn + "-2.jar"), output);
-        }
-
-    }
-
-    /**
-     * Run test with patches to java.base, jdk.naming.dns and jdk.compiler
-     */
-    void runTest(String basePatches, String dnsPatches, String compilerPatches)
-        throws Exception
-    {
-        // the argument to the test is the list of classes overridden or added
-        String arg = Stream.of(CLASSES).collect(Collectors.joining(","));
-
-        int exitValue
-            =  executeTestJava("-Xpatch:java.base=" + basePatches,
-                               "-Xpatch:jdk.naming.dns=" + dnsPatches,
-                               "-Xpatch:jdk.compiler=" + compilerPatches,
-                               "-XaddExports:java.base/java.lang2=test",
-                               "-XaddExports:jdk.naming.dns/com.sun.jndi.dns=test",
-                               "-XaddExports:jdk.naming.dns/com.sun.jndi.dns2=test",
-                               "-XaddExports:jdk.compiler/com.sun.tools.javac2=test",
-                               "-addmods", "jdk.naming.dns,jdk.compiler",
-                               "-mp", MODS_DIR.toString(),
-                               "-m", "test/jdk.test.Main", arg)
-                .outputTo(System.out)
-                .errorTo(System.out)
-                .getExitValue();
-
-        assertTrue(exitValue == 0);
-    }
-
-
-    /**
-     * Run test with -Xpatch and exploded patches
-     */
-    public void testWithExplodedPatches() throws Exception {
-
-        // patches1/java.base:patches2/java.base
-        String basePatches = PATCHES1_DIR.resolve("java.base")
-                + File.pathSeparator + PATCHES2_DIR.resolve("java.base");
-
-        String dnsPatches = PATCHES1_DIR.resolve("jdk.naming.dns")
-                + File.pathSeparator + PATCHES2_DIR.resolve("jdk.naming.dns");
-
-        String compilerPatches = PATCHES1_DIR.resolve("jdk.compiler")
-                + File.pathSeparator + PATCHES2_DIR.resolve("jdk.compiler");
-
-        runTest(basePatches, dnsPatches, compilerPatches);
-    }
-
-
-    /**
-     * Run test with -Xpatch and patches in JAR files
-     */
-    public void testWitJarPatches() throws Exception {
-
-        // patches/java.base-1.jar:patches/java-base-2.jar
-        String basePatches = PATCHES_DIR.resolve("java.base-1.jar")
-                + File.pathSeparator + PATCHES_DIR.resolve("java.base-2.jar");
-
-        String dnsPatches = PATCHES_DIR.resolve("jdk.naming.dns-1.jar")
-                +  File.pathSeparator + PATCHES_DIR.resolve("jdk.naming.dns-2.jar");
-
-        String compilerPatches = PATCHES_DIR.resolve("jdk.compiler-1.jar")
-                +  File.pathSeparator + PATCHES_DIR.resolve("jdk.compiler-2.jar");
-
-        runTest(basePatches, dnsPatches, compilerPatches);
-
-    }
-
-}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/jdk/test/tools/launcher/modules/patch/basic/PatchTest.java	Thu May 19 19:46:20 2016 +0000
@@ -0,0 +1,196 @@
+/*
+ * Copyright (c) 2015, 2016, 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
+ * @library /lib/testlibrary
+ * @modules jdk.compiler
+ * @build PatchTest CompilerUtils JarUtils jdk.testlibrary.*
+ * @run testng PatchTest
+ * @summary Basic test for -Xpatch
+ */
+
+import java.io.File;
+import java.nio.file.Files;
+import java.nio.file.Path;
+import java.nio.file.Paths;
+import java.util.stream.Collectors;
+import java.util.stream.Stream;
+
+import static jdk.testlibrary.ProcessTools.*;
+
+import org.testng.annotations.BeforeTest;
+import org.testng.annotations.Test;
+import static org.testng.Assert.*;
+
+
+/**
+ * Compiles and launches a test that uses -Xpatch with two directories of
+ * classes to override existing and add new classes to modules in the
+ * boot layer.
+ *
+ * The classes overridden or added via -Xpatch all define a public no-arg
+ * constructor and override toString to return "hi". This allows the launched
+ * test to check that the overridden classes are loaded.
+ */
+
+@Test
+public class PatchTest {
+
+    // top-level source directory
+    private static final String TEST_SRC = System.getProperty("test.src");
+
+    // source/destination tree for the test module
+    private static final Path SRC_DIR = Paths.get(TEST_SRC, "src");
+    private static final Path MODS_DIR = Paths.get("mods");
+
+    // source/destination tree for patch tree 1
+    private static final Path SRC1_DIR = Paths.get(TEST_SRC, "src1");
+    private static final Path PATCHES1_DIR = Paths.get("patches1");
+
+    // source/destination tree for patch tree 2
+    private static final Path SRC2_DIR = Paths.get(TEST_SRC, "src2");
+    private static final Path PATCHES2_DIR = Paths.get("patches2");
+
+    // destination directory for patches packaged as JAR files
+    private static final Path PATCHES_DIR = Paths.get("patches");
+
+
+    // the classes overridden or added with -Xpatch
+    private static final String[] CLASSES = {
+
+        // java.base = boot loader
+        "java.base/java.text.Annotation",           // override class
+        "java.base/java.text.AnnotationBuddy",      // add class to package
+        "java.base/java.lang2.Object",              // new package
+
+        // jdk.naming.dns = platform class loader
+        "jdk.naming.dns/com.sun.jndi.dns.DnsClient",
+        "jdk.naming.dns/com.sun.jndi.dns.DnsClientBuddy",
+        "jdk.naming.dns/com.sun.jndi.dns2.Zone",
+
+        // jdk.compiler = application class loaded
+        "jdk.compiler/com.sun.tools.javac.Main",
+        "jdk.compiler/com.sun.tools.javac.MainBuddy",
+        "jdk.compiler/com.sun.tools.javac2.Main",
+
+    };
+
+
+    @BeforeTest
+    public void setup() throws Exception {
+
+        // javac -d mods/test src/test/**
+        boolean compiled= CompilerUtils.compile(SRC_DIR.resolve("test"),
+                                                MODS_DIR.resolve("test"));
+        assertTrue(compiled, "classes did not compile");
+
+        // javac -Xmodule:$MODULE -d patches1/$MODULE patches1/$MODULE/**
+        // jar cf patches/$MODULE-1.jar -C patches1/$MODULE .
+        for (Path src : Files.newDirectoryStream(SRC1_DIR)) {
+            Path output = PATCHES1_DIR.resolve(src.getFileName());
+            String mn = src.getFileName().toString();
+            compiled  = CompilerUtils.compile(src, output, "-Xmodule:" + mn);
+            assertTrue(compiled, "classes did not compile");
+            JarUtils.createJarFile(PATCHES_DIR.resolve(mn + "-1.jar"), output);
+        }
+
+        // javac -Xmodule:$MODULE -d patches2/$MODULE patches2/$MODULE/**
+        // jar cf patches/$MODULE-2.jar -C patches2/$MODULE .
+        for (Path src : Files.newDirectoryStream(SRC2_DIR)) {
+            Path output = PATCHES2_DIR.resolve(src.getFileName());
+            String mn = src.getFileName().toString();
+            compiled  = CompilerUtils.compile(src, output, "-Xmodule:" + mn);
+            assertTrue(compiled, "classes did not compile");
+            JarUtils.createJarFile(PATCHES_DIR.resolve(mn + "-2.jar"), output);
+        }
+
+    }
+
+    /**
+     * Run test with patches to java.base, jdk.naming.dns and jdk.compiler
+     */
+    void runTest(String basePatches, String dnsPatches, String compilerPatches)
+        throws Exception
+    {
+        // the argument to the test is the list of classes overridden or added
+        String arg = Stream.of(CLASSES).collect(Collectors.joining(","));
+
+        int exitValue
+            =  executeTestJava("-Xpatch:java.base=" + basePatches,
+                               "-Xpatch:jdk.naming.dns=" + dnsPatches,
+                               "-Xpatch:jdk.compiler=" + compilerPatches,
+                               "-XaddExports:java.base/java.lang2=test",
+                               "-XaddExports:jdk.naming.dns/com.sun.jndi.dns=test",
+                               "-XaddExports:jdk.naming.dns/com.sun.jndi.dns2=test",
+                               "-XaddExports:jdk.compiler/com.sun.tools.javac2=test",
+                               "-addmods", "jdk.naming.dns,jdk.compiler",
+                               "-mp", MODS_DIR.toString(),
+                               "-m", "test/jdk.test.Main", arg)
+                .outputTo(System.out)
+                .errorTo(System.out)
+                .getExitValue();
+
+        assertTrue(exitValue == 0);
+    }
+
+
+    /**
+     * Run test with -Xpatch and exploded patches
+     */
+    public void testWithExplodedPatches() throws Exception {
+
+        // patches1/java.base:patches2/java.base
+        String basePatches = PATCHES1_DIR.resolve("java.base")
+                + File.pathSeparator + PATCHES2_DIR.resolve("java.base");
+
+        String dnsPatches = PATCHES1_DIR.resolve("jdk.naming.dns")
+                + File.pathSeparator + PATCHES2_DIR.resolve("jdk.naming.dns");
+
+        String compilerPatches = PATCHES1_DIR.resolve("jdk.compiler")
+                + File.pathSeparator + PATCHES2_DIR.resolve("jdk.compiler");
+
+        runTest(basePatches, dnsPatches, compilerPatches);
+    }
+
+
+    /**
+     * Run test with -Xpatch and patches in JAR files
+     */
+    public void testWitJarPatches() throws Exception {
+
+        // patches/java.base-1.jar:patches/java-base-2.jar
+        String basePatches = PATCHES_DIR.resolve("java.base-1.jar")
+                + File.pathSeparator + PATCHES_DIR.resolve("java.base-2.jar");
+
+        String dnsPatches = PATCHES_DIR.resolve("jdk.naming.dns-1.jar")
+                +  File.pathSeparator + PATCHES_DIR.resolve("jdk.naming.dns-2.jar");
+
+        String compilerPatches = PATCHES_DIR.resolve("jdk.compiler-1.jar")
+                +  File.pathSeparator + PATCHES_DIR.resolve("jdk.compiler-2.jar");
+
+        runTest(basePatches, dnsPatches, compilerPatches);
+
+    }
+
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/jdk/test/tools/launcher/modules/patch/basic/src/test/jdk/test/Main.java	Thu May 19 19:46:20 2016 +0000
@@ -0,0 +1,74 @@
+/**
+ * Copyright (c) 2015, Oracle and/or its affiliates. All rights reserved.
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * This code is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License version 2 only, as
+ * published by the Free Software Foundation.
+ *
+ * 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.
+ */
+
+/**
+ * Used with -Xpatch to exercise the replacement or addition of classes
+ * in modules that are linked into the runtime image.
+ */
+
+package jdk.test;
+
+import java.lang.reflect.Module;
+
+public class Main {
+
+    public static void main(String[] args) throws Exception {
+
+        for (String moduleAndClass : args[0].split(",")) {
+            String mn = moduleAndClass.split("/")[0];
+            String cn = moduleAndClass.split("/")[1];
+
+            // load class
+            Class<?> c = Class.forName(cn);
+
+            // check in expected module
+            Module m = c.getModule();
+            assertEquals(m.getName(), mn);
+
+            // instantiate object
+            Main.class.getModule().addReads(m);
+            Object obj = c.newInstance();
+
+            // check that the expected version of the class is loaded
+            System.out.print(moduleAndClass);
+            String s = obj.toString();
+            System.out.println(" says " + s);
+            assertEquals(s, "hi");
+
+            // check Module getResourceAsStream
+            String rn = cn.replace('.', '/') + ".class";
+            assertNotNull(m.getResourceAsStream(rn));
+        }
+    }
+
+
+    static void assertEquals(Object o1, Object o2) {
+        if (!o1.equals(o2))
+            throw new RuntimeException("assertion failed");
+    }
+
+    static void assertNotNull(Object o) {
+        if (o == null)
+            throw new RuntimeException("unexpected null");
+    }
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/jdk/test/tools/launcher/modules/patch/basic/src/test/module-info.java	Thu May 19 19:46:20 2016 +0000
@@ -0,0 +1,25 @@
+/**
+ * Copyright (c) 2015, Oracle and/or its affiliates. All rights reserved.
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * This code is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License version 2 only, as
+ * published by the Free Software Foundation.
+ *
+ * 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.
+ */
+
+module test {
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/jdk/test/tools/launcher/modules/patch/basic/src1/java.base/java/text/Annotation.java	Thu May 19 19:46:20 2016 +0000
@@ -0,0 +1,28 @@
+/*
+ * Copyright (c) 2015, Oracle and/or its affiliates. All rights reserved.
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * This code is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License version 2 only, as
+ * published by the Free Software Foundation.
+ *
+ * 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 java.text;
+
+public class Annotation {
+    public String toString() { return "hi"; }
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/jdk/test/tools/launcher/modules/patch/basic/src1/java.base/java/text/AnnotationBuddy.java	Thu May 19 19:46:20 2016 +0000
@@ -0,0 +1,28 @@
+/*
+ * Copyright (c) 2015, Oracle and/or its affiliates. All rights reserved.
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * This code is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License version 2 only, as
+ * published by the Free Software Foundation.
+ *
+ * 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 java.text;
+
+public class AnnotationBuddy {
+    public String toString() { return "hi"; }
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/jdk/test/tools/launcher/modules/patch/basic/src1/jdk.compiler/com/sun/tools/javac/Main.java	Thu May 19 19:46:20 2016 +0000
@@ -0,0 +1,28 @@
+/*
+ * Copyright (c) 2015, Oracle and/or its affiliates. All rights reserved.
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * This code is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License version 2 only, as
+ * published by the Free Software Foundation.
+ *
+ * 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 com.sun.tools.javac;
+
+public class Main {
+    public String toString() { return "hi"; }
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/jdk/test/tools/launcher/modules/patch/basic/src1/jdk.compiler/com/sun/tools/javac/MainBuddy.java	Thu May 19 19:46:20 2016 +0000
@@ -0,0 +1,28 @@
+/*
+ * Copyright (c) 2015, Oracle and/or its affiliates. All rights reserved.
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * This code is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License version 2 only, as
+ * published by the Free Software Foundation.
+ *
+ * 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 com.sun.tools.javac;
+
+public class MainBuddy {
+    public String toString() { return "hi"; }
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/jdk/test/tools/launcher/modules/patch/basic/src1/jdk.naming.dns/com/sun/jndi/dns/DnsClient.java	Thu May 19 19:46:20 2016 +0000
@@ -0,0 +1,28 @@
+/*
+ * Copyright (c) 2015, Oracle and/or its affiliates. All rights reserved.
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * This code is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License version 2 only, as
+ * published by the Free Software Foundation.
+ *
+ * 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 com.sun.jndi.dns;
+
+public class DnsClient {
+    public String toString() { return "hi"; }
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/jdk/test/tools/launcher/modules/patch/basic/src1/jdk.naming.dns/com/sun/jndi/dns/DnsClientBuddy.java	Thu May 19 19:46:20 2016 +0000
@@ -0,0 +1,28 @@
+/*
+ * Copyright (c) 2015, Oracle and/or its affiliates. All rights reserved.
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * This code is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License version 2 only, as
+ * published by the Free Software Foundation.
+ *
+ * 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 com.sun.jndi.dns;
+
+public class DnsClientBuddy {
+    public String toString() { return "hi"; }
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/jdk/test/tools/launcher/modules/patch/basic/src2/java.base/java/lang2/Object.java	Thu May 19 19:46:20 2016 +0000
@@ -0,0 +1,28 @@
+/**
+ * Copyright (c) 2015, Oracle and/or its affiliates. All rights reserved.
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * This code is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License version 2 only, as
+ * published by the Free Software Foundation.
+ *
+ * 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 java.lang2;
+
+public class Object {
+    public String toString() { return "hi"; }
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/jdk/test/tools/launcher/modules/patch/basic/src2/jdk.compiler/com/sun/tools/javac2/Main.java	Thu May 19 19:46:20 2016 +0000
@@ -0,0 +1,28 @@
+/**
+ * Copyright (c) 2015, Oracle and/or its affiliates. All rights reserved.
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * This code is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License version 2 only, as
+ * published by the Free Software Foundation.
+ *
+ * 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 com.sun.tools.javac2;
+
+public class Main {
+    public String toString() { return "hi"; }
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/jdk/test/tools/launcher/modules/patch/basic/src2/jdk.naming.dns/com/sun/jndi/dns2/Zone.java	Thu May 19 19:46:20 2016 +0000
@@ -0,0 +1,28 @@
+/**
+ * Copyright (c) 2015, Oracle and/or its affiliates. All rights reserved.
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * This code is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License version 2 only, as
+ * published by the Free Software Foundation.
+ *
+ * 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 com.sun.jndi.dns2;
+
+public class Zone {
+    public String toString() { return "hi"; }
+}
--- a/jdk/test/tools/launcher/modules/patch/src/test/jdk/test/Main.java	Thu May 19 17:48:02 2016 +0000
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,74 +0,0 @@
-/**
- * Copyright (c) 2015, Oracle and/or its affiliates. All rights reserved.
- * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
- *
- * This code is free software; you can redistribute it and/or modify it
- * under the terms of the GNU General Public License version 2 only, as
- * published by the Free Software Foundation.
- *
- * 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.
- */
-
-/**
- * Used with -Xpatch to exercise the replacement or addition of classes
- * in modules that are linked into the runtime image.
- */
-
-package jdk.test;
-
-import java.lang.reflect.Module;
-
-public class Main {
-
-    public static void main(String[] args) throws Exception {
-
-        for (String moduleAndClass : args[0].split(",")) {
-            String mn = moduleAndClass.split("/")[0];
-            String cn = moduleAndClass.split("/")[1];
-
-            // load class
-            Class<?> c = Class.forName(cn);
-
-            // check in expected module
-            Module m = c.getModule();
-            assertEquals(m.getName(), mn);
-
-            // instantiate object
-            Main.class.getModule().addReads(m);
-            Object obj = c.newInstance();
-
-            // check that the expected version of the class is loaded
-            System.out.print(moduleAndClass);
-            String s = obj.toString();
-            System.out.println(" says " + s);
-            assertEquals(s, "hi");
-
-            // check Module getResourceAsStream
-            String rn = cn.replace('.', '/') + ".class";
-            assertNotNull(m.getResourceAsStream(rn));
-        }
-    }
-
-
-    static void assertEquals(Object o1, Object o2) {
-        if (!o1.equals(o2))
-            throw new RuntimeException("assertion failed");
-    }
-
-    static void assertNotNull(Object o) {
-        if (o == null)
-            throw new RuntimeException("unexpected null");
-    }
-}
--- a/jdk/test/tools/launcher/modules/patch/src/test/module-info.java	Thu May 19 17:48:02 2016 +0000
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,25 +0,0 @@
-/**
- * Copyright (c) 2015, Oracle and/or its affiliates. All rights reserved.
- * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
- *
- * This code is free software; you can redistribute it and/or modify it
- * under the terms of the GNU General Public License version 2 only, as
- * published by the Free Software Foundation.
- *
- * 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.
- */
-
-module test {
-}
--- a/jdk/test/tools/launcher/modules/patch/src1/java.base/java/text/Annotation.java	Thu May 19 17:48:02 2016 +0000
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,28 +0,0 @@
-/*
- * Copyright (c) 2015, Oracle and/or its affiliates. All rights reserved.
- * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
- *
- * This code is free software; you can redistribute it and/or modify it
- * under the terms of the GNU General Public License version 2 only, as
- * published by the Free Software Foundation.
- *
- * 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 java.text;
-
-public class Annotation {
-    public String toString() { return "hi"; }
-}
--- a/jdk/test/tools/launcher/modules/patch/src1/java.base/java/text/AnnotationBuddy.java	Thu May 19 17:48:02 2016 +0000
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,28 +0,0 @@
-/*
- * Copyright (c) 2015, Oracle and/or its affiliates. All rights reserved.
- * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
- *
- * This code is free software; you can redistribute it and/or modify it
- * under the terms of the GNU General Public License version 2 only, as
- * published by the Free Software Foundation.
- *
- * 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 java.text;
-
-public class AnnotationBuddy {
-    public String toString() { return "hi"; }
-}
--- a/jdk/test/tools/launcher/modules/patch/src1/jdk.compiler/com/sun/tools/javac/Main.java	Thu May 19 17:48:02 2016 +0000
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,28 +0,0 @@
-/*
- * Copyright (c) 2015, Oracle and/or its affiliates. All rights reserved.
- * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
- *
- * This code is free software; you can redistribute it and/or modify it
- * under the terms of the GNU General Public License version 2 only, as
- * published by the Free Software Foundation.
- *
- * 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 com.sun.tools.javac;
-
-public class Main {
-    public String toString() { return "hi"; }
-}
--- a/jdk/test/tools/launcher/modules/patch/src1/jdk.compiler/com/sun/tools/javac/MainBuddy.java	Thu May 19 17:48:02 2016 +0000
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,28 +0,0 @@
-/*
- * Copyright (c) 2015, Oracle and/or its affiliates. All rights reserved.
- * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
- *
- * This code is free software; you can redistribute it and/or modify it
- * under the terms of the GNU General Public License version 2 only, as
- * published by the Free Software Foundation.
- *
- * 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 com.sun.tools.javac;
-
-public class MainBuddy {
-    public String toString() { return "hi"; }
-}
--- a/jdk/test/tools/launcher/modules/patch/src1/jdk.naming.dns/com/sun/jndi/dns/DnsClient.java	Thu May 19 17:48:02 2016 +0000
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,28 +0,0 @@
-/*
- * Copyright (c) 2015, Oracle and/or its affiliates. All rights reserved.
- * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
- *
- * This code is free software; you can redistribute it and/or modify it
- * under the terms of the GNU General Public License version 2 only, as
- * published by the Free Software Foundation.
- *
- * 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 com.sun.jndi.dns;
-
-public class DnsClient {
-    public String toString() { return "hi"; }
-}
--- a/jdk/test/tools/launcher/modules/patch/src1/jdk.naming.dns/com/sun/jndi/dns/DnsClientBuddy.java	Thu May 19 17:48:02 2016 +0000
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,28 +0,0 @@
-/*
- * Copyright (c) 2015, Oracle and/or its affiliates. All rights reserved.
- * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
- *
- * This code is free software; you can redistribute it and/or modify it
- * under the terms of the GNU General Public License version 2 only, as
- * published by the Free Software Foundation.
- *
- * 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 com.sun.jndi.dns;
-
-public class DnsClientBuddy {
-    public String toString() { return "hi"; }
-}
--- a/jdk/test/tools/launcher/modules/patch/src2/java.base/java/lang2/Object.java	Thu May 19 17:48:02 2016 +0000
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,28 +0,0 @@
-/**
- * Copyright (c) 2015, Oracle and/or its affiliates. All rights reserved.
- * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
- *
- * This code is free software; you can redistribute it and/or modify it
- * under the terms of the GNU General Public License version 2 only, as
- * published by the Free Software Foundation.
- *
- * 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 java.lang2;
-
-public class Object {
-    public String toString() { return "hi"; }
-}
--- a/jdk/test/tools/launcher/modules/patch/src2/jdk.compiler/com/sun/tools/javac2/Main.java	Thu May 19 17:48:02 2016 +0000
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,28 +0,0 @@
-/**
- * Copyright (c) 2015, Oracle and/or its affiliates. All rights reserved.
- * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
- *
- * This code is free software; you can redistribute it and/or modify it
- * under the terms of the GNU General Public License version 2 only, as
- * published by the Free Software Foundation.
- *
- * 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 com.sun.tools.javac2;
-
-public class Main {
-    public String toString() { return "hi"; }
-}
--- a/jdk/test/tools/launcher/modules/patch/src2/jdk.naming.dns/com/sun/jndi/dns2/Zone.java	Thu May 19 17:48:02 2016 +0000
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,28 +0,0 @@
-/**
- * Copyright (c) 2015, Oracle and/or its affiliates. All rights reserved.
- * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
- *
- * This code is free software; you can redistribute it and/or modify it
- * under the terms of the GNU General Public License version 2 only, as
- * published by the Free Software Foundation.
- *
- * 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 com.sun.jndi.dns2;
-
-public class Zone {
-    public String toString() { return "hi"; }
-}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/jdk/test/tools/launcher/modules/patch/systemmodules/PatchSystemModules.java	Thu May 19 19:46:20 2016 +0000
@@ -0,0 +1,225 @@
+/**
+ * Copyright (c) 2016, 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 8157068
+ * @summary Patch java.base and user module with Hashes attribute tied with
+ *          other module.
+ * @library /lib/testlibrary
+ * @modules jdk.compiler
+ * @build CompilerUtils
+ * @run testng PatchSystemModules
+ */
+
+import java.io.File;
+import java.nio.file.Files;
+import java.nio.file.Path;
+import java.nio.file.Paths;
+import java.util.ArrayList;
+import java.util.List;
+import java.util.stream.Stream;
+
+import jdk.testlibrary.FileUtils;
+import jdk.testlibrary.JDKToolFinder;
+import org.testng.annotations.BeforeTest;
+import org.testng.annotations.Test;
+
+import static jdk.testlibrary.ProcessTools.executeCommand;
+import static org.testng.Assert.*;
+
+public class PatchSystemModules {
+    private static final String JAVA_HOME = System.getProperty("java.home");
+
+    private static final Path TEST_SRC = Paths.get(System.getProperty("test.src"));
+    private static final Path PATCH_SRC_DIR = TEST_SRC.resolve("src1");
+
+    private static final Path JMODS = Paths.get(JAVA_HOME, "jmods");
+    private static final Path MODS_DIR = Paths.get("mods");
+    private static final Path JARS_DIR = Paths.get("jars");
+    private static final Path PATCH_DIR = Paths.get("patches");
+    private static final Path IMAGE = Paths.get("image");
+
+    private static final String JAVA_BASE = "java.base";
+    private final String[] modules = new String[] { "m1", "m2" };
+
+    @BeforeTest
+    private void setup() throws Throwable {
+        Path src = TEST_SRC.resolve("src");
+        for (String name : modules) {
+            assertTrue(CompilerUtils.compile(src.resolve(name),
+                                             MODS_DIR,
+                                             "-modulesourcepath", src.toString()));
+        }
+
+        // compile patched source
+        assertTrue(CompilerUtils.compile(PATCH_SRC_DIR.resolve(JAVA_BASE),
+                                         PATCH_DIR.resolve(JAVA_BASE),
+                                         "-Xmodule:java.base"));
+        assertTrue(CompilerUtils.compile(PATCH_SRC_DIR.resolve("m2"),
+                                         PATCH_DIR.resolve("m2")));
+
+        // create an image with only m1 and m2
+        if (Files.exists(JMODS)) {
+            // create an image with m1,m2
+            createImage();
+        }
+    }
+
+    @Test
+    public void test() throws Throwable {
+        Path patchedJavaBase = PATCH_DIR.resolve(JAVA_BASE);
+        Path patchedM2 = PATCH_DIR.resolve("m2");
+
+        Path home = Paths.get(JAVA_HOME);
+        runTest(home,
+                "-mp", MODS_DIR.toString(),
+                "-m", "m1/p1.Main", "1");
+        runTest(home,
+                "-Xpatch:java.base=" + patchedJavaBase.toString(),
+                "-mp", MODS_DIR.toString(),
+                "-m", "m1/p1.Main", "1");
+
+        runTest(home,
+                "-Xpatch:m2=" + patchedM2.toString(),
+                "-mp", MODS_DIR.toString(),
+                "-m", "m1/p1.Main", "2");
+    }
+
+    @Test
+    public void testImage() throws Throwable {
+        if (Files.notExists(JMODS))
+            return;
+
+        Path patchedJavaBase = PATCH_DIR.resolve(JAVA_BASE);
+        Path patchedM2 = PATCH_DIR.resolve("m2");
+
+        runTest(IMAGE,
+                "-m", "m1/p1.Main", "1");
+        runTest(IMAGE,
+                "-Xpatch:java.base=" + patchedJavaBase.toString(),
+                "-m", "m1/p1.Main", "1");
+        runTest(IMAGE,
+                "-Xpatch:m2=" + patchedM2.toString(),
+                "-m", "m1/p1.Main", "2");
+    }
+
+    @Test
+    public void upgradeTiedModule() throws Throwable {
+        if (Files.notExists(JMODS))
+            return;
+
+        Path m1 = MODS_DIR.resolve("m1.jar");
+
+        // create another m1.jar
+        jar("--create",
+            "--file=" + m1.toString(),
+            "-C", MODS_DIR.resolve("m1").toString(), ".");
+
+        // Fail to upgrade m1.jar with mismatched hash
+        runTestWithExitCode(getJava(IMAGE),
+                "-upgrademodulepath", m1.toString(),
+                "-m", "m1/p1.Main");
+
+        runTestWithExitCode(getJava(IMAGE),
+                "-Xpatch:java.base=" + PATCH_DIR.resolve(JAVA_BASE).toString(),
+                "-upgrademodulepath", m1.toString(),
+                "-m", "m1/p1.Main", "1");
+    }
+
+    private void runTestWithExitCode(String... options) throws Throwable {
+        assertTrue(executeCommand(options)
+                        .outputTo(System.out)
+                        .errorTo(System.out)
+                        .shouldContain("differs to expected hash")
+                        .getExitValue() != 0);
+    }
+
+    private void runTest(Path image, String... opts) throws Throwable {
+        String[] options =
+            Stream.concat(Stream.of(getJava(image)),
+                          Stream.of(opts))
+                  .toArray(String[]::new);
+
+        ProcessBuilder pb = new ProcessBuilder(options);
+        int exitValue =  executeCommand(pb)
+                            .outputTo(System.out)
+                            .errorTo(System.out)
+                            .getExitValue();
+
+        assertTrue(exitValue == 0);
+    }
+
+    static void createImage() throws Throwable {
+        FileUtils.deleteFileTreeUnchecked(JARS_DIR);
+        FileUtils.deleteFileTreeUnchecked(IMAGE);
+
+        Files.createDirectories(JARS_DIR);
+        Path m1 = JARS_DIR.resolve("m1.jar");
+        Path m2 = JARS_DIR.resolve("m2.jar");
+
+        // hash m1 in m2's Hashes attribute
+        jar("--create",
+            "--file=" + m1.toString(),
+            "-C", MODS_DIR.resolve("m1").toString(), ".");
+
+        jar("--create",
+            "--file=" + m2.toString(),
+            "--modulepath", JARS_DIR.toString(),
+            "--hash-modules", "m1",
+            "-C", MODS_DIR.resolve("m2").toString(), ".");
+
+
+        String mpath = JARS_DIR.toString() + File.pathSeparator + JMODS.toString();
+        execTool("jlink", "--modulepath", mpath,
+                 "--addmods", "m1",
+                 "--output", IMAGE.toString());
+    }
+
+    static void jar(String... args) throws Throwable {
+        execTool("jar", args);
+    }
+
+    static void execTool(String tool, String... args) throws Throwable {
+        String path = JDKToolFinder.getJDKTool(tool);
+        List<String> commands = new ArrayList<>();
+        commands.add(path);
+        Stream.of(args).forEach(commands::add);
+        ProcessBuilder pb = new ProcessBuilder(commands);
+        int exitValue =  executeCommand(pb)
+            .outputTo(System.out)
+            .errorTo(System.out)
+            .shouldNotContain("no module is recorded in hash")
+            .getExitValue();
+
+        assertTrue(exitValue == 0);
+    }
+
+    static String getJava(Path image) {
+        boolean isWindows = System.getProperty("os.name").toLowerCase().startsWith("win");
+        Path java = image.resolve("bin").resolve(isWindows ? "java.exe" : "java");
+        if (Files.notExists(java))
+            throw new RuntimeException(java + " not found");
+        return java.toAbsolutePath().toString();
+    }
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/jdk/test/tools/launcher/modules/patch/systemmodules/src/m1/module-info.java	Thu May 19 19:46:20 2016 +0000
@@ -0,0 +1,26 @@
+/**
+ * Copyright (c) 2016, 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.
+ */
+
+module m1 {
+    requires m2;
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/jdk/test/tools/launcher/modules/patch/systemmodules/src/m1/p1/Main.java	Thu May 19 19:46:20 2016 +0000
@@ -0,0 +1,34 @@
+/**
+ * Copyright (c) 2016, 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 p1;
+
+public class Main {
+    public static void main(String[] args) throws Exception {
+        int version = p2.Lib.version();
+        int expected = args.length == 0 ? 1 : Integer.parseInt(args[0]);
+
+        if (version != expected)
+            throw new RuntimeException(version + " != " + expected + " (expected)");
+    }
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/jdk/test/tools/launcher/modules/patch/systemmodules/src/m2/module-info.java	Thu May 19 19:46:20 2016 +0000
@@ -0,0 +1,26 @@
+/**
+ * Copyright (c) 2016, 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.
+ */
+
+module m2 {
+    exports p2;
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/jdk/test/tools/launcher/modules/patch/systemmodules/src/m2/p2/Lib.java	Thu May 19 19:46:20 2016 +0000
@@ -0,0 +1,30 @@
+/**
+ * Copyright (c) 2016, 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 p2;
+
+public class Lib {
+    public static int version() {
+        return 1;
+    }
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/jdk/test/tools/launcher/modules/patch/systemmodules/src1/java.base/jdk/internal/modules/SystemModules.java	Thu May 19 19:46:20 2016 +0000
@@ -0,0 +1,32 @@
+/*
+ * Copyright (c) 2016, 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 jdk.internal.module;
+
+/*
+ * Test -Xpatch:java.base=jdk/modules/java.base to override
+ * java.base with an exploded image
+ */
+public final class SystemModules {
+    public static final String[] MODULE_NAMES = new String[0];
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/jdk/test/tools/launcher/modules/patch/systemmodules/src1/m2/p2/Lib.java	Thu May 19 19:46:20 2016 +0000
@@ -0,0 +1,30 @@
+/**
+ * Copyright (c) 2016, 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 p2;
+
+public class Lib {
+    public static int version() {
+        return 2;
+    }
+}
--- a/jdk/test/tools/pack200/TestNormal.java	Thu May 19 17:48:02 2016 +0000
+++ b/jdk/test/tools/pack200/TestNormal.java	Thu May 19 19:46:20 2016 +0000
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2013, 2014, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2013, 2016, 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
@@ -25,85 +25,37 @@
 /*
  * @test
  * @run main/timeout=600 TestNormal
- * @bug 8020802
+ * @bug 8020802 8156807
  * @summary Need an ability to create jar files that are invariant to the pack200 packing/unpacking
  * @author Alexander Zuev
  */
 
 import java.io.*;
-import java.util.Collections;
-import java.util.Properties;
-import java.util.jar.JarEntry;
-import java.util.jar.JarFile;
 
 public class TestNormal {
     private static String FS = File.separator;
 
     public static void main(String args[]) throws Exception {
-        Properties p = System.getProperties();
-        String java_home = p.getProperty("test.jdk");
         String testdir = Utils.TEST_CLS_DIR.getAbsolutePath();
 
         try {
-            execJavaCommand(java_home, "jar cnf normalized.jar -C " + testdir + " .");
-            execJavaCommand(java_home, "jar cf original.jar -C " + testdir + " .");
-            execJavaCommand(java_home, "pack200 -r repacked.jar original.jar");
-            compareJars(new JarFile("normalized.jar"), new JarFile("repacked.jar"));
-        } finally {
-            String[] cleanupList = {"normalized.jar", "original.jar", "repacked.jar"};
-            for (String s : cleanupList) {
-                delete(new File(s));
-            }
-        }
-    }
+            String jarCmd = Utils.getJarCmd();
+            String packCmd = Utils.getPack200Cmd();
 
-    public static void execJavaCommand(String java_home, String cmd) throws Exception {
-        Process proc = Runtime.getRuntime().exec(java_home + FS + "bin" + FS + cmd);
-        String s;
-        BufferedReader stdInput =
-                new BufferedReader(new InputStreamReader(proc.getInputStream()));
-        BufferedReader stdError =
-                new BufferedReader(new InputStreamReader(proc.getErrorStream()));
-        while ((s = stdInput.readLine()) != null) {
-            System.out.println(s);
-        }
-        while ((s = stdError.readLine()) != null) {
-            System.err.println(s);
-        }
-    }
+            // create the original jar
+            Utils.runExec(jarCmd, "cf", "original.jar", "-C", testdir, ".");
+
+            // create the reference jar
+            Utils.runExec(packCmd, "-r", "repacked.jar", "original.jar");
 
-    public static void compareJars(JarFile jf1, JarFile jf2) throws Exception {
-        try {
-            if (jf1.size() != jf2.size()) {
-                throw new Exception("Jars " + jf1.getName() + " and " + jf2.getName()
-                        + " have different number of entries");
-            }
-            for (JarEntry elem1 : Collections.list(jf1.entries())) {
-                JarEntry elem2 = jf2.getJarEntry(elem1.getName());
-                if (elem2 == null) {
-                    throw new Exception("Element " + elem1.getName() + " is missing from " + jf2.getName());
-                }
-                if (!elem1.isDirectory() && elem1.getCrc() != elem2.getCrc()) {
-                    throw new Exception("The crc of " + elem1.getName() + " is different.");
-                }
-            }
+            // create the normalized jar using jar(1)
+            Utils.runExec(jarCmd, "cnf", "normalized.jar", "-C", testdir, ".");
+
+            // compare archive contents bit wise, these should be identical!
+            Utils.doCompareBitWise(new File("repacked.jar"),
+                    new File("normalized.jar"));
         } finally {
-            jf1.close();
-            jf2.close();
-        }
-    }
-
-    static void delete(File f) throws IOException {
-        if (!f.exists()) {
-            return;
-        }
-        if (f.isDirectory()) {
-            for (File c : f.listFiles()) {
-                delete(c);
-            }
-        }
-        if (!f.delete()) {
-            throw new FileNotFoundException("Failed to delete file: " + f);
+           Utils.cleanup();
         }
     }
 }
--- a/jdk/test/tools/pack200/Utils.java	Thu May 19 17:48:02 2016 +0000
+++ b/jdk/test/tools/pack200/Utils.java	Thu May 19 19:46:20 2016 +0000
@@ -33,7 +33,6 @@
 import java.io.InputStreamReader;
 import java.io.PrintStream;
 import java.net.URI;
-import java.net.URL;
 import java.nio.charset.Charset;
 import java.nio.file.attribute.BasicFileAttributes;
 import java.nio.file.FileSystem;
@@ -483,9 +482,15 @@
         }
         return out;
     }
+
+    static List<String> runExec(String... cmds) {
+        return runExec(Arrays.asList(cmds));
+    }
+
     static List<String> runExec(List<String> cmdsList) {
         return runExec(cmdsList, null);
     }
+
     static List<String> runExec(List<String> cmdsList, Map<String, String> penv) {
         ArrayList<String> alist = new ArrayList<String>();
         ProcessBuilder pb =