8074428: Move pack200, unpack200, libpack200 to jdk.pack200
authormchung
Fri, 06 Mar 2015 09:02:26 -0800
changeset 29368 be944a521c76
parent 29367 eaa2bfc500e8
child 29369 8f9f8aa1e8e9
8074428: Move pack200, unpack200, libpack200 to jdk.pack200 Reviewed-by: alanb, weijun, erikj, ihse
jdk/make/launcher/Launcher-jdk.pack200.gmk
jdk/make/launcher/Launcher-jdk.runtime.gmk
jdk/make/lib/Lib-jdk.pack200.gmk
jdk/make/lib/Lib-jdk.runtime.gmk
jdk/src/jdk.pack200/share/native/common-unpack/bands.cpp
jdk/src/jdk.pack200/share/native/common-unpack/bands.h
jdk/src/jdk.pack200/share/native/common-unpack/bytes.cpp
jdk/src/jdk.pack200/share/native/common-unpack/bytes.h
jdk/src/jdk.pack200/share/native/common-unpack/coding.cpp
jdk/src/jdk.pack200/share/native/common-unpack/coding.h
jdk/src/jdk.pack200/share/native/common-unpack/constants.h
jdk/src/jdk.pack200/share/native/common-unpack/defines.h
jdk/src/jdk.pack200/share/native/common-unpack/unpack.cpp
jdk/src/jdk.pack200/share/native/common-unpack/unpack.h
jdk/src/jdk.pack200/share/native/common-unpack/utils.cpp
jdk/src/jdk.pack200/share/native/common-unpack/utils.h
jdk/src/jdk.pack200/share/native/common-unpack/zip.cpp
jdk/src/jdk.pack200/share/native/common-unpack/zip.h
jdk/src/jdk.pack200/share/native/libunpack/jni.cpp
jdk/src/jdk.pack200/share/native/unpack200/main.cpp
jdk/src/jdk.pack200/windows/native/unpack200/unpack200_proto.exe.manifest
jdk/src/jdk.runtime/share/native/common-unpack/bands.cpp
jdk/src/jdk.runtime/share/native/common-unpack/bands.h
jdk/src/jdk.runtime/share/native/common-unpack/bytes.cpp
jdk/src/jdk.runtime/share/native/common-unpack/bytes.h
jdk/src/jdk.runtime/share/native/common-unpack/coding.cpp
jdk/src/jdk.runtime/share/native/common-unpack/coding.h
jdk/src/jdk.runtime/share/native/common-unpack/constants.h
jdk/src/jdk.runtime/share/native/common-unpack/defines.h
jdk/src/jdk.runtime/share/native/common-unpack/unpack.cpp
jdk/src/jdk.runtime/share/native/common-unpack/unpack.h
jdk/src/jdk.runtime/share/native/common-unpack/utils.cpp
jdk/src/jdk.runtime/share/native/common-unpack/utils.h
jdk/src/jdk.runtime/share/native/common-unpack/zip.cpp
jdk/src/jdk.runtime/share/native/common-unpack/zip.h
jdk/src/jdk.runtime/share/native/libunpack/jni.cpp
jdk/src/jdk.runtime/share/native/unpack200/main.cpp
jdk/src/jdk.runtime/windows/native/unpack200/unpack200_proto.exe.manifest
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/jdk/make/launcher/Launcher-jdk.pack200.gmk	Fri Mar 06 09:02:26 2015 -0800
@@ -0,0 +1,109 @@
+#
+# Copyright (c) 2011, 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.
+#
+
+include LauncherCommon.gmk
+
+$(eval $(call SetupLauncher,pack200, \
+    -DJAVA_ARGS='{ "-J-ms8m"$(COMMA) "com.sun.java.util.jar.pack.Driver"$(COMMA) }'))
+
+################################################################################
+# The order of the object files on the link command line affects the size of the resulting
+# binary (at least on linux) which causes the size to differ between old and new build.
+
+UNPACKEXE_SRC := $(JDK_TOPDIR)/src/jdk.pack200/share/native/common-unpack \
+    $(JDK_TOPDIR)/src/jdk.pack200/share/native/unpack200
+UNPACKEXE_CFLAGS := -I$(JDK_TOPDIR)/src/jdk.pack200/share/native/common-unpack \
+    -I$(JDK_TOPDIR)/src/java.base/share/native/libjava \
+    -I$(JDK_TOPDIR)/src/java.base/$(OPENJDK_TARGET_OS_TYPE)/native/libjava
+
+ifeq ($(USE_EXTERNAL_LIBZ), true)
+  UNPACKEXE_CFLAGS += -DSYSTEM_ZLIB
+  UNPACKEXE_ZIPOBJS := -lz
+else
+  UNPACKEXE_CFLAGS += -I$(JDK_TOPDIR)/src/java.base/share/native/libzip/zlib-1.2.8
+  UNPACKEXE_ZIPOBJS := $(SUPPORT_OUTPUTDIR)/native/java.base/libzip/zcrc32$(OBJ_SUFFIX) \
+      $(SUPPORT_OUTPUTDIR)/native/java.base/libzip/deflate$(OBJ_SUFFIX) \
+      $(SUPPORT_OUTPUTDIR)/native/java.base/libzip/trees$(OBJ_SUFFIX) \
+      $(SUPPORT_OUTPUTDIR)/native/java.base/libzip/zadler32$(OBJ_SUFFIX) \
+      $(SUPPORT_OUTPUTDIR)/native/java.base/libzip/compress$(OBJ_SUFFIX) \
+      $(SUPPORT_OUTPUTDIR)/native/java.base/libzip/zutil$(OBJ_SUFFIX) \
+      $(SUPPORT_OUTPUTDIR)/native/java.base/libzip/inflate$(OBJ_SUFFIX) \
+      $(SUPPORT_OUTPUTDIR)/native/java.base/libzip/infback$(OBJ_SUFFIX) \
+      $(SUPPORT_OUTPUTDIR)/native/java.base/libzip/inftrees$(OBJ_SUFFIX) \
+      $(SUPPORT_OUTPUTDIR)/native/java.base/libzip/inffast$(OBJ_SUFFIX)
+
+endif
+
+UNPACKEXE_LANG := C
+ifeq ($(OPENJDK_TARGET_OS), solaris)
+  UNPACKEXE_LANG := C++
+endif
+
+# The linker on older SuSE distros (e.g. on SLES 10) complains with:
+# "Invalid version tag `SUNWprivate_1.1'. Only anonymous version tag is allowed in executable."
+# if feeded with a version script which contains named tags.
+ifeq ($(USING_BROKEN_SUSE_LD), yes)
+  UNPACK_MAPFILE = $(JDK_TOPDIR)/make/mapfiles/libunpack/mapfile-vers-unpack200.anonymous
+else
+  UNPACK_MAPFILE = $(JDK_TOPDIR)/make/mapfiles/libunpack/mapfile-vers-unpack200
+endif
+
+$(eval $(call SetupNativeCompilation,BUILD_UNPACKEXE, \
+    SRC := $(UNPACKEXE_SRC), \
+    LANG := $(UNPACKEXE_LANG), \
+    OPTIMIZATION := LOW, \
+    CFLAGS := $(UNPACKEXE_CFLAGS) $(CXXFLAGS_JDKEXE) -DFULL, \
+    CFLAGS_release := -DPRODUCT, \
+    CFLAGS_linux := -fPIC, \
+    CFLAGS_solaris := -KPIC, \
+    CFLAGS_macosx := -fPIC, \
+    MAPFILE := $(UNPACK_MAPFILE),\
+    LDFLAGS := $(UNPACKEXE_ZIPOBJS) \
+        $(LDFLAGS_JDKEXE) $(LDFLAGS_CXX_JDK) \
+        $(call SET_SHARED_LIBRARY_NAME,$(LIBRARY_PREFIX)unpack$(SHARED_LIBRARY_SUFFIX)) \
+        $(call SET_SHARED_LIBRARY_ORIGIN), \
+    LDFLAGS_linux := -lc, \
+    LDFLAGS_solaris := $(UNPACKEXE_LDFLAGS_solaris) -lc, \
+    LDFLAGS_SUFFIX := $(LIBCXX), \
+    OBJECT_DIR := $(SUPPORT_OUTPUTDIR)/native/$(MODULE)/unpackexe$(OUTPUT_SUBDIR), \
+    OUTPUT_DIR := $(SUPPORT_OUTPUTDIR)/modules_cmds/$(MODULE), \
+    PROGRAM := unpack200, \
+    VERSIONINFO_RESOURCE := $(GLOBAL_VERSION_INFO_RESOURCE), \
+    RC_FLAGS := $(RC_FLAGS) \
+        -D "JDK_FNAME=unpack200.exe" \
+        -D "JDK_INTERNAL_NAME=unpack200" \
+        -D "JDK_FTYPE=0x1L", \
+    DEBUG_SYMBOLS := true, \
+    MANIFEST := $(JDK_TOPDIR)/src/jdk.pack200/windows/native/unpack200/unpack200_proto.exe.manifest))
+
+ifneq ($(USE_EXTERNAL_LIBZ), true)
+
+  $(BUILD_UNPACKEXE): $(UNPACKEXE_ZIPOBJS)
+
+endif
+
+TARGETS += $(BUILD_UNPACKEXE)
+
+################################################################################
--- a/jdk/make/launcher/Launcher-jdk.runtime.gmk	Fri Mar 06 13:30:49 2015 +0300
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,109 +0,0 @@
-#
-# Copyright (c) 2011, 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.
-#
-
-include LauncherCommon.gmk
-
-$(eval $(call SetupLauncher,pack200, \
-    -DJAVA_ARGS='{ "-J-ms8m"$(COMMA) "com.sun.java.util.jar.pack.Driver"$(COMMA) }'))
-
-################################################################################
-# The order of the object files on the link command line affects the size of the resulting
-# binary (at least on linux) which causes the size to differ between old and new build.
-
-UNPACKEXE_SRC := $(JDK_TOPDIR)/src/jdk.runtime/share/native/common-unpack \
-    $(JDK_TOPDIR)/src/jdk.runtime/share/native/unpack200
-UNPACKEXE_CFLAGS := -I$(JDK_TOPDIR)/src/jdk.runtime/share/native/common-unpack \
-    -I$(JDK_TOPDIR)/src/java.base/share/native/libjava \
-    -I$(JDK_TOPDIR)/src/java.base/$(OPENJDK_TARGET_OS_TYPE)/native/libjava
-
-ifeq ($(USE_EXTERNAL_LIBZ), true)
-  UNPACKEXE_CFLAGS += -DSYSTEM_ZLIB
-  UNPACKEXE_ZIPOBJS := -lz
-else
-  UNPACKEXE_CFLAGS += -I$(JDK_TOPDIR)/src/java.base/share/native/libzip/zlib-1.2.8
-  UNPACKEXE_ZIPOBJS := $(SUPPORT_OUTPUTDIR)/native/java.base/libzip/zcrc32$(OBJ_SUFFIX) \
-      $(SUPPORT_OUTPUTDIR)/native/java.base/libzip/deflate$(OBJ_SUFFIX) \
-      $(SUPPORT_OUTPUTDIR)/native/java.base/libzip/trees$(OBJ_SUFFIX) \
-      $(SUPPORT_OUTPUTDIR)/native/java.base/libzip/zadler32$(OBJ_SUFFIX) \
-      $(SUPPORT_OUTPUTDIR)/native/java.base/libzip/compress$(OBJ_SUFFIX) \
-      $(SUPPORT_OUTPUTDIR)/native/java.base/libzip/zutil$(OBJ_SUFFIX) \
-      $(SUPPORT_OUTPUTDIR)/native/java.base/libzip/inflate$(OBJ_SUFFIX) \
-      $(SUPPORT_OUTPUTDIR)/native/java.base/libzip/infback$(OBJ_SUFFIX) \
-      $(SUPPORT_OUTPUTDIR)/native/java.base/libzip/inftrees$(OBJ_SUFFIX) \
-      $(SUPPORT_OUTPUTDIR)/native/java.base/libzip/inffast$(OBJ_SUFFIX)
-
-endif
-
-UNPACKEXE_LANG := C
-ifeq ($(OPENJDK_TARGET_OS), solaris)
-  UNPACKEXE_LANG := C++
-endif
-
-# The linker on older SuSE distros (e.g. on SLES 10) complains with:
-# "Invalid version tag `SUNWprivate_1.1'. Only anonymous version tag is allowed in executable."
-# if feeded with a version script which contains named tags.
-ifeq ($(USING_BROKEN_SUSE_LD), yes)
-  UNPACK_MAPFILE = $(JDK_TOPDIR)/make/mapfiles/libunpack/mapfile-vers-unpack200.anonymous
-else
-  UNPACK_MAPFILE = $(JDK_TOPDIR)/make/mapfiles/libunpack/mapfile-vers-unpack200
-endif
-
-$(eval $(call SetupNativeCompilation,BUILD_UNPACKEXE, \
-    SRC := $(UNPACKEXE_SRC), \
-    LANG := $(UNPACKEXE_LANG), \
-    OPTIMIZATION := LOW, \
-    CFLAGS := $(UNPACKEXE_CFLAGS) $(CXXFLAGS_JDKEXE) -DFULL, \
-    CFLAGS_release := -DPRODUCT, \
-    CFLAGS_linux := -fPIC, \
-    CFLAGS_solaris := -KPIC, \
-    CFLAGS_macosx := -fPIC, \
-    MAPFILE := $(UNPACK_MAPFILE),\
-    LDFLAGS := $(UNPACKEXE_ZIPOBJS) \
-        $(LDFLAGS_JDKEXE) $(LDFLAGS_CXX_JDK) \
-        $(call SET_SHARED_LIBRARY_NAME,$(LIBRARY_PREFIX)unpack$(SHARED_LIBRARY_SUFFIX)) \
-        $(call SET_SHARED_LIBRARY_ORIGIN), \
-    LDFLAGS_linux := -lc, \
-    LDFLAGS_solaris := $(UNPACKEXE_LDFLAGS_solaris) -lc, \
-    LDFLAGS_SUFFIX := $(LIBCXX), \
-    OBJECT_DIR := $(SUPPORT_OUTPUTDIR)/native/$(MODULE)/unpackexe$(OUTPUT_SUBDIR), \
-    OUTPUT_DIR := $(SUPPORT_OUTPUTDIR)/modules_cmds/$(MODULE), \
-    PROGRAM := unpack200, \
-    VERSIONINFO_RESOURCE := $(GLOBAL_VERSION_INFO_RESOURCE), \
-    RC_FLAGS := $(RC_FLAGS) \
-        -D "JDK_FNAME=unpack200.exe" \
-        -D "JDK_INTERNAL_NAME=unpack200" \
-        -D "JDK_FTYPE=0x1L", \
-    DEBUG_SYMBOLS := true, \
-    MANIFEST := $(JDK_TOPDIR)/src/jdk.runtime/windows/native/unpack200/unpack200_proto.exe.manifest))
-
-ifneq ($(USE_EXTERNAL_LIBZ), true)
-
-  $(BUILD_UNPACKEXE): $(UNPACKEXE_ZIPOBJS)
-
-endif
-
-TARGETS += $(BUILD_UNPACKEXE)
-
-################################################################################
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/jdk/make/lib/Lib-jdk.pack200.gmk	Fri Mar 06 09:02:26 2015 -0800
@@ -0,0 +1,61 @@
+#
+# Copyright (c) 2011, 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.
+#
+
+include LibCommon.gmk
+
+################################################################################
+
+$(eval $(call SetupNativeCompilation,BUILD_LIBUNPACK, \
+    LIBRARY := unpack, \
+    OUTPUT_DIR := $(INSTALL_LIBRARIES_HERE), \
+    SRC := $(JDK_TOPDIR)/src/jdk.pack200/share/native/libunpack \
+        $(JDK_TOPDIR)/src/jdk.pack200/share/native/common-unpack, \
+    LANG := C++, \
+    OPTIMIZATION := LOW, \
+    CFLAGS := $(CXXFLAGS_JDKLIB) \
+        -DNO_ZLIB -DUNPACK_JNI -DFULL \
+        -I$(SUPPORT_OUTPUTDIR)/headers/java.base \
+        -I$(JDK_TOPDIR)/src/jdk.pack200/share/native/common-unpack \
+        $(LIBJAVA_HEADER_FLAGS), \
+    CFLAGS_release := -DPRODUCT, \
+    MAPFILE := $(JDK_TOPDIR)/make/mapfiles/libunpack/mapfile-vers, \
+    LDFLAGS := $(LDFLAGS_JDKLIB) $(LDFLAGS_CXX_JDK) \
+        $(call SET_SHARED_LIBRARY_ORIGIN), \
+    LDFLAGS_windows := -map:$(SUPPORT_OUTPUTDIR)/native/$(MODULE)/unpack.map -debug \
+        jvm.lib $(WIN_JAVA_LIB), \
+    LDFLAGS_SUFFIX_unix := -ljvm $(LIBCXX) -ljava -lc, \
+    OBJECT_DIR := $(SUPPORT_OUTPUTDIR)/native/$(MODULE)/libunpack, \
+    VERSIONINFO_RESOURCE := $(GLOBAL_VERSION_INFO_RESOURCE), \
+    RC_FLAGS := $(RC_FLAGS) \
+        -D "JDK_FNAME=unpack.dll" \
+        -D "JDK_INTERNAL_NAME=unpack" \
+        -D "JDK_FTYPE=0x2L", \
+    DEBUG_SYMBOLS := $(DEBUG_ALL_BINARIES)))
+
+$(BUILD_LIBUNPACK): $(call FindLib, java.base, java)
+
+TARGETS += $(BUILD_LIBUNPACK)
+
+################################################################################
--- a/jdk/make/lib/Lib-jdk.runtime.gmk	Fri Mar 06 13:30:49 2015 +0300
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,61 +0,0 @@
-#
-# Copyright (c) 2011, 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.
-#
-
-include LibCommon.gmk
-
-################################################################################
-
-$(eval $(call SetupNativeCompilation,BUILD_LIBUNPACK, \
-    LIBRARY := unpack, \
-    OUTPUT_DIR := $(INSTALL_LIBRARIES_HERE), \
-    SRC := $(JDK_TOPDIR)/src/jdk.runtime/share/native/libunpack \
-        $(JDK_TOPDIR)/src/jdk.runtime/share/native/common-unpack, \
-    LANG := C++, \
-    OPTIMIZATION := LOW, \
-    CFLAGS := $(CXXFLAGS_JDKLIB) \
-        -DNO_ZLIB -DUNPACK_JNI -DFULL \
-        -I$(SUPPORT_OUTPUTDIR)/headers/java.base \
-        -I$(JDK_TOPDIR)/src/jdk.runtime/share/native/common-unpack \
-        $(LIBJAVA_HEADER_FLAGS), \
-    CFLAGS_release := -DPRODUCT, \
-    MAPFILE := $(JDK_TOPDIR)/make/mapfiles/libunpack/mapfile-vers, \
-    LDFLAGS := $(LDFLAGS_JDKLIB) $(LDFLAGS_CXX_JDK) \
-        $(call SET_SHARED_LIBRARY_ORIGIN), \
-    LDFLAGS_windows := -map:$(SUPPORT_OUTPUTDIR)/native/$(MODULE)/unpack.map -debug \
-        jvm.lib $(WIN_JAVA_LIB), \
-    LDFLAGS_SUFFIX_unix := -ljvm $(LIBCXX) -ljava -lc, \
-    OBJECT_DIR := $(SUPPORT_OUTPUTDIR)/native/$(MODULE)/libunpack, \
-    VERSIONINFO_RESOURCE := $(GLOBAL_VERSION_INFO_RESOURCE), \
-    RC_FLAGS := $(RC_FLAGS) \
-        -D "JDK_FNAME=unpack.dll" \
-        -D "JDK_INTERNAL_NAME=unpack" \
-        -D "JDK_FTYPE=0x2L", \
-    DEBUG_SYMBOLS := $(DEBUG_ALL_BINARIES)))
-
-$(BUILD_LIBUNPACK): $(call FindLib, java.base, java)
-
-TARGETS += $(BUILD_LIBUNPACK)
-
-################################################################################
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/jdk/src/jdk.pack200/share/native/common-unpack/bands.cpp	Fri Mar 06 09:02:26 2015 -0800
@@ -0,0 +1,486 @@
+/*
+ * Copyright (c) 2002, 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.
+ */
+
+// -*- C++ -*-
+// Small program for unpacking specially compressed Java packages.
+// John R. Rose
+
+#include <sys/types.h>
+
+#include <stdio.h>
+#include <string.h>
+#include <stdlib.h>
+#include <stdarg.h>
+
+#include "defines.h"
+#include "bytes.h"
+#include "utils.h"
+#include "coding.h"
+#include "bands.h"
+
+#include "constants.h"
+#include "unpack.h"
+
+inline void band::abort(const char* msg) { u->abort(msg); }
+inline bool band::aborting() { return u->aborting(); }
+
+void band::readData(int expectedLength) {
+  CHECK;
+  assert(expectedLength >= 0);
+  assert(vs[0].cmk == cmk_ERROR);
+  if (expectedLength != 0) {
+    assert(length == 0);
+    length = expectedLength;
+  }
+  if (length == 0) {
+    assert((rplimit = cm.vs0.rp = u->rp) != null);
+    return;
+  }
+  assert(length > 0);
+
+  bool is_BYTE1 = (defc->spec == BYTE1_spec);
+
+  if (is_BYTE1) {
+    // No possibility of coding change.  Sizing is exact.
+    u->ensure_input(length);
+  } else {
+    // Make a conservatively generous estimate of band size in bytes.
+    // Assume B == 5 everywhere.
+    // Assume awkward pop with all {U} values (2*5 per value)
+    jlong generous = (jlong) length * (B_MAX*3+1) + C_SLOP;
+    u->ensure_input(generous);
+  }
+
+  // Read one value to see what it might be.
+  int XB = _meta_default;
+  int cp1 = 0, cp2 = 0;
+  if (!is_BYTE1) {
+    // must be a variable-length coding
+    assert(defc->B() > 1 && defc->L() > 0);
+    // must have already read from previous band:
+    assert(bn >= BAND_LIMIT || bn <= 0
+           || bn == e_cp_Utf8_big_chars
+           || endsWith(name, "_lo")  // preceded by _hi conditional band
+           || bn == e_file_options  // preceded by conditional band
+           || u->rp == u->all_bands[bn-1].maxRP()
+           || u->all_bands[bn-1].defc == null);
+
+    value_stream xvs;
+    coding* valc = defc;
+    if (valc->D() != 0) {
+      valc = coding::findBySpec(defc->B(), defc->H(), defc->S());
+      assert(!valc->isMalloc);
+    }
+    xvs.init(u->rp, u->rplimit, valc);
+    CHECK;
+    int X = xvs.getInt();
+    if (valc->S() != 0) {
+      assert(valc->min <= -256);
+      XB = -1-X;
+    } else {
+      int L = valc->L();
+      assert(valc->max >= L+255);
+      XB = X-L;
+    }
+    if (0 <= XB && XB < 256) {
+      // Skip over the escape value.
+      u->rp = xvs.rp;
+      cp1 = 1;
+    } else {
+      // No, it's still default.
+      XB = _meta_default;
+    }
+  }
+
+  if (XB <= _meta_canon_max) {
+    byte XB_byte = (byte) XB;
+    byte* XB_ptr = &XB_byte;
+    cm.init(u->rp, u->rplimit, XB_ptr, 0, defc, length, null);
+    CHECK;
+  } else {
+    NOT_PRODUCT(byte* meta_rp0 = u->meta_rp);
+    assert(u->meta_rp != null);
+    // Scribble the initial byte onto the band.
+    byte* save_meta_rp = --u->meta_rp;
+    byte  save_meta_xb = (*save_meta_rp);
+    (*save_meta_rp) = (byte) XB;
+    cm.init(u->rp, u->rplimit, u->meta_rp, 0, defc, length, null);
+    (*save_meta_rp) = save_meta_xb;  // put it back, just to be tidy
+    NOT_PRODUCT(cp2 = (int)(u->meta_rp - meta_rp0));
+  }
+  rplimit = u->rp;
+
+  rewind();
+
+#ifndef PRODUCT
+  PRINTCR((3,"readFrom %s at %p [%d values, %d bytes, cp=%d/%d]",
+           (name?name:"(band)"), minRP(), length, size(), cp1, cp2));
+  if (u->verbose_bands || u->verbose >= 4) dump();
+
+  if (ix != null && u->verbose != 0 && length > 0) {
+    // Check referential integrity early, for easier debugging.
+    band saved = (*this);  // save state
+    for (int i = 0; i < length; i++) {
+      int n = vs[0].getInt() - nullOK;
+      entry *ref = ix->get(n);
+      assert(ref != null || n == -1);
+    }
+    (*this) = saved;
+  }
+#endif
+}
+
+#ifndef PRODUCT
+void band::dump() {
+  band saved = (*this);  // save state
+  const char* b_name = name;
+  char b_name_buf[100];
+  if (b_name == null) {
+    char* bp = &b_name_buf[0];
+    b_name = bp;
+    sprintf(bp, "#%d/%d", bn, le_kind); bp += strlen(bp);
+    if (le_bci != 0)  { sprintf(bp, "/bci%d",  le_bci);  bp += strlen(bp); }
+    if (le_back != 0) { sprintf(bp, "/back%d", le_back); bp += strlen(bp); }
+    if (le_len != 0)  { sprintf(bp, "/len%d",  le_len);  bp += strlen(bp); }
+  }
+  fprintf(u->errstrm, "band %s[%d]%s", b_name, length, (length==0?"\n":" {"));
+  if (length > 0) {
+    for (int i = 0; i < length; i++) {
+      const char* eol = (length > 10 && i % 10 == 0) ? "\n" : " ";
+      fprintf(u->errstrm, "%s%d", eol, vs[0].getInt());
+    }
+    fprintf(u->errstrm, " }\n");
+  }
+  (*this) = saved;
+}
+#endif
+
+void band::setIndex(cpindex* ix_) {
+  assert(ix_ == null || ixTag == ix_->ixTag);
+  ix = ix_;
+}
+void band::setIndexByTag(byte tag) {
+  setIndex(u->cp.getIndex(tag));
+}
+
+entry* band::getRefCommon(cpindex* ix_, bool nullOKwithCaller) {
+  CHECK_0;
+  if (ix_ == NULL) {
+      abort("no index");
+      return NULL;
+  }
+  assert(ix_->ixTag == ixTag
+         || ((ixTag == CONSTANT_All ||
+              ixTag == CONSTANT_LoadableValue ||
+              ixTag == CONSTANT_AnyMember)
+         || (ixTag == CONSTANT_FieldSpecific &&
+              ix_->ixTag >= CONSTANT_Integer  &&
+              ix_->ixTag <= CONSTANT_String))
+         );
+  int n = vs[0].getInt() - nullOK;
+  // Note: band-local nullOK means null encodes as 0.
+  // But nullOKwithCaller means caller is willing to tolerate a null.
+  entry *ref = ix_->get(n);
+  if (ref == null && !(nullOKwithCaller && n == -1))
+    abort(n == -1 ? "null ref" : "bad ref");
+  return ref;
+}
+
+jlong band::getLong(band& lo_band, bool have_hi) {
+  band& hi_band = (*this);
+  assert(lo_band.bn == hi_band.bn + 1);
+  uint lo = lo_band.getInt();
+  if (!have_hi) {
+    assert(hi_band.length == 0);
+    return makeLong(0, lo);
+  }
+  uint hi = hi_band.getInt();
+  return makeLong(hi, lo);
+}
+
+int band::getIntTotal() {
+  CHECK_0;
+  if (length == 0)  return 0;
+  if (total_memo > 0)  return total_memo-1;
+  int total = getInt();
+  // overflow checks require that none of the addends are <0,
+  // and that the partial sums never overflow (wrap negative)
+  if (total < 0) {
+    abort("overflow detected");
+    return 0;
+  }
+  for (int k = length-1; k > 0; k--) {
+    int prev_total = total;
+    total += vs[0].getInt();
+    if (total < prev_total) {
+      abort("overflow detected");
+      return 0;
+    }
+  }
+  rewind();
+  total_memo = total+1;
+  return total;
+}
+
+int band::getIntCount(int tag) {
+  CHECK_0;
+  if (length == 0)  return 0;
+  if (tag >= HIST0_MIN && tag <= HIST0_MAX) {
+    if (hist0 == null) {
+      // Lazily calculate an approximate histogram.
+      hist0 = U_NEW(int, (HIST0_MAX - HIST0_MIN)+1);
+      CHECK_0;
+      for (int k = length; k > 0; k--) {
+        int x = vs[0].getInt();
+        if (x >= HIST0_MIN && x <= HIST0_MAX)
+          hist0[x - HIST0_MIN] += 1;
+      }
+      rewind();
+    }
+    return hist0[tag - HIST0_MIN];
+  }
+  int total = 0;
+  for (int k = length; k > 0; k--) {
+    total += (vs[0].getInt() == tag) ? 1 : 0;
+  }
+  rewind();
+  return total;
+}
+
+#define INDEX_INIT(tag, nullOK, subindex) \
+        ((tag) + (subindex)*SUBINDEX_BIT + (nullOK)*256)
+
+#define INDEX(tag)          INDEX_INIT(tag, 0, 0)
+#define NULL_OR_INDEX(tag)  INDEX_INIT(tag, 1, 0)
+#define SUB_INDEX(tag)      INDEX_INIT(tag, 0, 1)
+#define NO_INDEX            0
+
+struct band_init {
+  int         bn;
+  const char* name;
+  int   defc;
+  int   index;
+};
+
+#define BAND_INIT(name, cspec, ix) \
+  { e_##name,  #name, /*debug only*/ \
+    cspec, ix }
+
+const band_init all_band_inits[BAND_LIMIT+1] = {
+//BAND_INIT(archive_magic, BYTE1_spec, 0),
+//BAND_INIT(archive_header, UNSIGNED5_spec, 0),
+//BAND_INIT(band_headers, BYTE1_spec, 0),
+  BAND_INIT(cp_Utf8_prefix, DELTA5_spec, 0),
+  BAND_INIT(cp_Utf8_suffix, UNSIGNED5_spec, 0),
+  BAND_INIT(cp_Utf8_chars, CHAR3_spec, 0),
+  BAND_INIT(cp_Utf8_big_suffix, DELTA5_spec, 0),
+  BAND_INIT(cp_Utf8_big_chars, DELTA5_spec, 0),
+  BAND_INIT(cp_Int, UDELTA5_spec, 0),
+  BAND_INIT(cp_Float, UDELTA5_spec, 0),
+  BAND_INIT(cp_Long_hi, UDELTA5_spec, 0),
+  BAND_INIT(cp_Long_lo, DELTA5_spec, 0),
+  BAND_INIT(cp_Double_hi, UDELTA5_spec, 0),
+  BAND_INIT(cp_Double_lo, DELTA5_spec, 0),
+  BAND_INIT(cp_String, UDELTA5_spec, INDEX(CONSTANT_Utf8)),
+  BAND_INIT(cp_Class, UDELTA5_spec, INDEX(CONSTANT_Utf8)),
+  BAND_INIT(cp_Signature_form, DELTA5_spec, INDEX(CONSTANT_Utf8)),
+  BAND_INIT(cp_Signature_classes, UDELTA5_spec, INDEX(CONSTANT_Class)),
+  BAND_INIT(cp_Descr_name, DELTA5_spec, INDEX(CONSTANT_Utf8)),
+  BAND_INIT(cp_Descr_type, UDELTA5_spec, INDEX(CONSTANT_Signature)),
+  BAND_INIT(cp_Field_class, DELTA5_spec, INDEX(CONSTANT_Class)),
+  BAND_INIT(cp_Field_desc, UDELTA5_spec, INDEX(CONSTANT_NameandType)),
+  BAND_INIT(cp_Method_class, DELTA5_spec, INDEX(CONSTANT_Class)),
+  BAND_INIT(cp_Method_desc, UDELTA5_spec, INDEX(CONSTANT_NameandType)),
+  BAND_INIT(cp_Imethod_class, DELTA5_spec, INDEX(CONSTANT_Class)),
+  BAND_INIT(cp_Imethod_desc, UDELTA5_spec, INDEX(CONSTANT_NameandType)),
+  BAND_INIT(cp_MethodHandle_refkind, DELTA5_spec, 0),
+  BAND_INIT(cp_MethodHandle_member, UDELTA5_spec, INDEX(CONSTANT_AnyMember)),
+  BAND_INIT(cp_MethodType, UDELTA5_spec, INDEX(CONSTANT_Signature)),
+  BAND_INIT(cp_BootstrapMethod_ref, DELTA5_spec, INDEX(CONSTANT_MethodHandle)),
+  BAND_INIT(cp_BootstrapMethod_arg_count, UDELTA5_spec, 0),
+  BAND_INIT(cp_BootstrapMethod_arg, DELTA5_spec, INDEX(CONSTANT_LoadableValue)),
+  BAND_INIT(cp_InvokeDynamic_spec, DELTA5_spec, INDEX(CONSTANT_BootstrapMethod)),
+  BAND_INIT(cp_InvokeDynamic_desc, UDELTA5_spec, INDEX(CONSTANT_NameandType)),
+  BAND_INIT(attr_definition_headers, BYTE1_spec, 0),
+  BAND_INIT(attr_definition_name, UNSIGNED5_spec, INDEX(CONSTANT_Utf8)),
+  BAND_INIT(attr_definition_layout, UNSIGNED5_spec, INDEX(CONSTANT_Utf8)),
+  BAND_INIT(ic_this_class, UDELTA5_spec, INDEX(CONSTANT_Class)),
+  BAND_INIT(ic_flags, UNSIGNED5_spec, 0),
+  BAND_INIT(ic_outer_class, DELTA5_spec, NULL_OR_INDEX(CONSTANT_Class)),
+  BAND_INIT(ic_name, DELTA5_spec, NULL_OR_INDEX(CONSTANT_Utf8)),
+  BAND_INIT(class_this, DELTA5_spec, INDEX(CONSTANT_Class)),
+  BAND_INIT(class_super, DELTA5_spec, INDEX(CONSTANT_Class)),
+  BAND_INIT(class_interface_count, DELTA5_spec, 0),
+  BAND_INIT(class_interface, DELTA5_spec, INDEX(CONSTANT_Class)),
+  BAND_INIT(class_field_count, DELTA5_spec, 0),
+  BAND_INIT(class_method_count, DELTA5_spec, 0),
+  BAND_INIT(field_descr, DELTA5_spec, INDEX(CONSTANT_NameandType)),
+  BAND_INIT(field_flags_hi, UNSIGNED5_spec, 0),
+  BAND_INIT(field_flags_lo, UNSIGNED5_spec, 0),
+  BAND_INIT(field_attr_count, UNSIGNED5_spec, 0),
+  BAND_INIT(field_attr_indexes, UNSIGNED5_spec, 0),
+  BAND_INIT(field_attr_calls, UNSIGNED5_spec, 0),
+  BAND_INIT(field_ConstantValue_KQ, UNSIGNED5_spec, INDEX(CONSTANT_FieldSpecific)),
+  BAND_INIT(field_Signature_RS, UNSIGNED5_spec, INDEX(CONSTANT_Signature)),
+  BAND_INIT(field_metadata_bands, -1, -1),
+  BAND_INIT(field_attr_bands, -1, -1),
+  BAND_INIT(method_descr, MDELTA5_spec, INDEX(CONSTANT_NameandType)),
+  BAND_INIT(method_flags_hi, UNSIGNED5_spec, 0),
+  BAND_INIT(method_flags_lo, UNSIGNED5_spec, 0),
+  BAND_INIT(method_attr_count, UNSIGNED5_spec, 0),
+  BAND_INIT(method_attr_indexes, UNSIGNED5_spec, 0),
+  BAND_INIT(method_attr_calls, UNSIGNED5_spec, 0),
+  BAND_INIT(method_Exceptions_N, UNSIGNED5_spec, 0),
+  BAND_INIT(method_Exceptions_RC, UNSIGNED5_spec, INDEX(CONSTANT_Class)),
+  BAND_INIT(method_Signature_RS, UNSIGNED5_spec, INDEX(CONSTANT_Signature)),
+  BAND_INIT(method_metadata_bands, -1, -1),
+  BAND_INIT(method_MethodParameters_NB, BYTE1_spec, 0),
+  BAND_INIT(method_MethodParameters_name_RUN, UNSIGNED5_spec, NULL_OR_INDEX(CONSTANT_Utf8)),
+  BAND_INIT(method_MethodParameters_flag_FH, UNSIGNED5_spec, 0),
+  BAND_INIT(method_attr_bands, -1, -1),
+  BAND_INIT(class_flags_hi, UNSIGNED5_spec, 0),
+  BAND_INIT(class_flags_lo, UNSIGNED5_spec, 0),
+  BAND_INIT(class_attr_count, UNSIGNED5_spec, 0),
+  BAND_INIT(class_attr_indexes, UNSIGNED5_spec, 0),
+  BAND_INIT(class_attr_calls, UNSIGNED5_spec, 0),
+  BAND_INIT(class_SourceFile_RUN, UNSIGNED5_spec, NULL_OR_INDEX(CONSTANT_Utf8)),
+  BAND_INIT(class_EnclosingMethod_RC, UNSIGNED5_spec, INDEX(CONSTANT_Class)),
+  BAND_INIT(class_EnclosingMethod_RDN, UNSIGNED5_spec, NULL_OR_INDEX(CONSTANT_NameandType)),
+  BAND_INIT(class_Signature_RS, UNSIGNED5_spec, INDEX(CONSTANT_Signature)),
+  BAND_INIT(class_metadata_bands, -1, -1),
+  BAND_INIT(class_InnerClasses_N, UNSIGNED5_spec, 0),
+  BAND_INIT(class_InnerClasses_RC, UNSIGNED5_spec, INDEX(CONSTANT_Class)),
+  BAND_INIT(class_InnerClasses_F, UNSIGNED5_spec, 0),
+  BAND_INIT(class_InnerClasses_outer_RCN, UNSIGNED5_spec, NULL_OR_INDEX(CONSTANT_Class)),
+  BAND_INIT(class_InnerClasses_name_RUN, UNSIGNED5_spec, NULL_OR_INDEX(CONSTANT_Utf8)),
+  BAND_INIT(class_ClassFile_version_minor_H, UNSIGNED5_spec, 0),
+  BAND_INIT(class_ClassFile_version_major_H, UNSIGNED5_spec, 0),
+  BAND_INIT(class_attr_bands, -1, -1),
+  BAND_INIT(code_headers, BYTE1_spec, 0),
+  BAND_INIT(code_max_stack, UNSIGNED5_spec, 0),
+  BAND_INIT(code_max_na_locals, UNSIGNED5_spec, 0),
+  BAND_INIT(code_handler_count, UNSIGNED5_spec, 0),
+  BAND_INIT(code_handler_start_P, BCI5_spec, 0),
+  BAND_INIT(code_handler_end_PO, BRANCH5_spec, 0),
+  BAND_INIT(code_handler_catch_PO, BRANCH5_spec, 0),
+  BAND_INIT(code_handler_class_RCN, UNSIGNED5_spec, NULL_OR_INDEX(CONSTANT_Class)),
+  BAND_INIT(code_flags_hi, UNSIGNED5_spec, 0),
+  BAND_INIT(code_flags_lo, UNSIGNED5_spec, 0),
+  BAND_INIT(code_attr_count, UNSIGNED5_spec, 0),
+  BAND_INIT(code_attr_indexes, UNSIGNED5_spec, 0),
+  BAND_INIT(code_attr_calls, UNSIGNED5_spec, 0),
+  BAND_INIT(code_StackMapTable_N, UNSIGNED5_spec, 0),
+  BAND_INIT(code_StackMapTable_frame_T, BYTE1_spec, 0),
+  BAND_INIT(code_StackMapTable_local_N, UNSIGNED5_spec, 0),
+  BAND_INIT(code_StackMapTable_stack_N, UNSIGNED5_spec, 0),
+  BAND_INIT(code_StackMapTable_offset, UNSIGNED5_spec, 0),
+  BAND_INIT(code_StackMapTable_T, BYTE1_spec, 0),
+  BAND_INIT(code_StackMapTable_RC, UNSIGNED5_spec, INDEX(CONSTANT_Class)),
+  BAND_INIT(code_StackMapTable_P, BCI5_spec, 0),
+  BAND_INIT(code_LineNumberTable_N, UNSIGNED5_spec, 0),
+  BAND_INIT(code_LineNumberTable_bci_P, BCI5_spec, 0),
+  BAND_INIT(code_LineNumberTable_line, UNSIGNED5_spec, 0),
+  BAND_INIT(code_LocalVariableTable_N, UNSIGNED5_spec, 0),
+  BAND_INIT(code_LocalVariableTable_bci_P, BCI5_spec, 0),
+  BAND_INIT(code_LocalVariableTable_span_O, BRANCH5_spec, 0),
+  BAND_INIT(code_LocalVariableTable_name_RU, UNSIGNED5_spec, INDEX(CONSTANT_Utf8)),
+  BAND_INIT(code_LocalVariableTable_type_RS, UNSIGNED5_spec, INDEX(CONSTANT_Signature)),
+  BAND_INIT(code_LocalVariableTable_slot, UNSIGNED5_spec, 0),
+  BAND_INIT(code_LocalVariableTypeTable_N, UNSIGNED5_spec, 0),
+  BAND_INIT(code_LocalVariableTypeTable_bci_P, BCI5_spec, 0),
+  BAND_INIT(code_LocalVariableTypeTable_span_O, BRANCH5_spec, 0),
+  BAND_INIT(code_LocalVariableTypeTable_name_RU, UNSIGNED5_spec, INDEX(CONSTANT_Utf8)),
+  BAND_INIT(code_LocalVariableTypeTable_type_RS, UNSIGNED5_spec, INDEX(CONSTANT_Signature)),
+  BAND_INIT(code_LocalVariableTypeTable_slot, UNSIGNED5_spec, 0),
+  BAND_INIT(code_attr_bands, -1, -1),
+  BAND_INIT(bc_codes, BYTE1_spec, 0),
+  BAND_INIT(bc_case_count, UNSIGNED5_spec, 0),
+  BAND_INIT(bc_case_value, DELTA5_spec, 0),
+  BAND_INIT(bc_byte, BYTE1_spec, 0),
+  BAND_INIT(bc_short, DELTA5_spec, 0),
+  BAND_INIT(bc_local, UNSIGNED5_spec, 0),
+  BAND_INIT(bc_label, BRANCH5_spec, 0),
+  BAND_INIT(bc_intref, DELTA5_spec, INDEX(CONSTANT_Integer)),
+  BAND_INIT(bc_floatref, DELTA5_spec, INDEX(CONSTANT_Float)),
+  BAND_INIT(bc_longref, DELTA5_spec, INDEX(CONSTANT_Long)),
+  BAND_INIT(bc_doubleref, DELTA5_spec, INDEX(CONSTANT_Double)),
+  BAND_INIT(bc_stringref, DELTA5_spec, INDEX(CONSTANT_String)),
+  BAND_INIT(bc_loadablevalueref, DELTA5_spec, INDEX(CONSTANT_LoadableValue)),
+  BAND_INIT(bc_classref, UNSIGNED5_spec, NULL_OR_INDEX(CONSTANT_Class)),
+  BAND_INIT(bc_fieldref, DELTA5_spec, INDEX(CONSTANT_Fieldref)),
+  BAND_INIT(bc_methodref, UNSIGNED5_spec, INDEX(CONSTANT_Methodref)),
+  BAND_INIT(bc_imethodref, DELTA5_spec, INDEX(CONSTANT_InterfaceMethodref)),
+  BAND_INIT(bc_indyref, DELTA5_spec, INDEX(CONSTANT_InvokeDynamic)),
+  BAND_INIT(bc_thisfield, UNSIGNED5_spec, SUB_INDEX(CONSTANT_Fieldref)),
+  BAND_INIT(bc_superfield, UNSIGNED5_spec, SUB_INDEX(CONSTANT_Fieldref)),
+  BAND_INIT(bc_thismethod, UNSIGNED5_spec, SUB_INDEX(CONSTANT_Methodref)),
+  BAND_INIT(bc_supermethod, UNSIGNED5_spec, SUB_INDEX(CONSTANT_Methodref)),
+  BAND_INIT(bc_initref, UNSIGNED5_spec, SUB_INDEX(CONSTANT_Methodref)),
+  BAND_INIT(bc_escref, UNSIGNED5_spec, INDEX(CONSTANT_All)),
+  BAND_INIT(bc_escrefsize, UNSIGNED5_spec, 0),
+  BAND_INIT(bc_escsize, UNSIGNED5_spec, 0),
+  BAND_INIT(bc_escbyte, BYTE1_spec, 0),
+  BAND_INIT(file_name, UNSIGNED5_spec, INDEX(CONSTANT_Utf8)),
+  BAND_INIT(file_size_hi, UNSIGNED5_spec, 0),
+  BAND_INIT(file_size_lo, UNSIGNED5_spec, 0),
+  BAND_INIT(file_modtime, DELTA5_spec, 0),
+  BAND_INIT(file_options, UNSIGNED5_spec, 0),
+//BAND_INIT(file_bits, BYTE1_spec, 0),
+  { 0, NULL, 0, 0 }
+};
+
+band* band::makeBands(unpacker* u) {
+  band* tmp_all_bands = U_NEW(band, BAND_LIMIT);
+  for (int i = 0; i < BAND_LIMIT; i++) {
+    assert((byte*)&all_band_inits[i+1]
+           < (byte*)all_band_inits+sizeof(all_band_inits));
+    const band_init& bi = all_band_inits[i];
+    band&            b  = tmp_all_bands[i];
+    coding*          defc = coding::findBySpec(bi.defc);
+    assert((defc == null) == (bi.defc == -1));  // no garbage, please
+    assert(defc == null || !defc->isMalloc);
+    assert(bi.bn == i);  // band array consistent w/ band enum
+    b.init(u, i, defc);
+    if (bi.index > 0) {
+      b.nullOK = ((bi.index >> 8) & 1);
+      b.ixTag = (bi.index & 0xFF);
+    }
+#ifndef PRODUCT
+    b.name = bi.name;
+#endif
+  }
+  return tmp_all_bands;
+}
+
+void band::initIndexes(unpacker* u) {
+  band* tmp_all_bands = u->all_bands;
+  for (int i = 0; i < BAND_LIMIT; i++) {
+    band* scan = &tmp_all_bands[i];
+    uint tag = scan->ixTag;  // Cf. #define INDEX(tag) above
+    if (tag != 0 && tag != CONSTANT_FieldSpecific && (tag & SUBINDEX_BIT) == 0) {
+      scan->setIndex(u->cp.getIndex(tag));
+    }
+  }
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/jdk/src/jdk.pack200/share/native/common-unpack/bands.h	Fri Mar 06 09:02:26 2015 -0800
@@ -0,0 +1,481 @@
+/*
+ * Copyright (c) 2002, 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.
+ */
+
+// -*- C++ -*-
+struct entry;
+struct cpindex;
+struct unpacker;
+
+struct band {
+  const char*   name;
+  int           bn;             // band_number of this band
+  coding*       defc;           // default coding method
+  cpindex*      ix;             // CP entry mapping, if CPRefBand
+  byte          ixTag;          // 0 or 1; null is coded as (nullOK?0:-1)
+  byte          nullOK;         // 0 or 1; null is coded as (nullOK?0:-1)
+  int           length;         // expected # values
+  unpacker*     u;              // back pointer
+
+  value_stream  vs[2];         // source of values
+  coding_method cm;            // method used for initial state of vs[0]
+  byte*         rplimit;       // end of band (encoded, transmitted)
+
+  int           total_memo;    // cached value of getIntTotal, or -1
+  int*          hist0;         // approximate. histogram
+  enum { HIST0_MIN = 0, HIST0_MAX = 255 }; // catches the usual cases
+
+  // properties for attribute layout elements:
+  byte          le_kind;       // EK_XXX
+  byte          le_bci;        // 0,EK_BCI,EK_BCD,EK_BCO
+  byte          le_back;       // ==EF_BACK
+  byte          le_len;        // 0,1,2,4 (size in classfile), or call addr
+  band**        le_body;       // body of repl, union, call (null-terminated)
+  // Note:  EK_CASE elements use hist0 to record union tags.
+  #define       le_casetags    hist0
+
+  band& nextBand() { return this[1]; }
+  band& prevBand() { return this[-1]; }
+
+  void init(unpacker* u_, int bn_, coding* defc_) {
+    u    = u_;
+    cm.u = u_;
+    bn   = bn_;
+    defc = defc_;
+  }
+  void init(unpacker* u_, int bn_, int defcSpec) {
+    init(u_, bn_, coding::findBySpec(defcSpec));
+  }
+  void initRef(int ixTag_ = 0, bool nullOK_ = false) {
+    ixTag  = ixTag_;
+    nullOK = nullOK_;
+    setIndexByTag(ixTag);
+  }
+
+  void expectMoreLength(int l) {
+    assert(length >= 0);      // able to accept a length
+    assert((int)l >= 0);      // no overflow
+    assert(rplimit == null);  // readData not yet called
+    length += l;
+    assert(length >= l);      // no overflow
+  }
+
+  void setIndex(cpindex* ix_);
+  void setIndexByTag(byte tag);
+
+  // Parse the band and its meta-coding header.
+  void readData(int expectedLength = 0);
+
+  // Reset the band for another pass (Cf. Java Band.resetForSecondPass.)
+  void rewind() {
+    cm.reset(&vs[0]);
+  }
+
+  byte* &curRP()    { return vs[0].rp; }
+  byte*  minRP()    { return cm.vs0.rp; }
+  byte*  maxRP()    { return rplimit; }
+  size_t size()     { return maxRP() - minRP(); }
+
+  int    getByte()  { assert(ix == null); return vs[0].getByte(); }
+  int    getInt()   { assert(ix == null); return vs[0].getInt(); }
+  entry* getRefN()  { return getRefCommon(ix, true); }
+  entry* getRef()   { return getRefCommon(ix, false); }
+  entry* getRefUsing(cpindex* ix2)
+                    { assert(ix == null); return getRefCommon(ix2, true); }
+  entry* getRefCommon(cpindex* ix, bool nullOK);
+  jlong  getLong(band& lo_band, bool have_hi);
+
+  static jlong makeLong(uint hi, uint lo) {
+    return ((julong)hi << 32) + (((julong)lo << 32) >> 32);
+  }
+
+  int    getIntTotal();
+  int    getIntCount(int tag);
+
+  static band* makeBands(unpacker* u);
+  static void initIndexes(unpacker* u);
+
+#ifndef PRODUCT
+  void dump();
+#endif
+
+  void abort(const char* msg = null); //{ u->abort(msg); }
+  bool aborting(); //{ return u->aborting(); }
+};
+
+extern band all_bands[];
+
+#define BAND_LOCAL /* \
+  band* band_temp = all_bands; \
+  band* all_bands = band_temp */
+
+// Band schema:
+enum band_number {
+  //e_archive_magic,
+  //e_archive_header,
+  //e_band_headers,
+
+    // constant pool contents
+    e_cp_Utf8_prefix,
+    e_cp_Utf8_suffix,
+    e_cp_Utf8_chars,
+    e_cp_Utf8_big_suffix,
+    e_cp_Utf8_big_chars,
+    e_cp_Int,
+    e_cp_Float,
+    e_cp_Long_hi,
+    e_cp_Long_lo,
+    e_cp_Double_hi,
+    e_cp_Double_lo,
+    e_cp_String,
+    e_cp_Class,
+    e_cp_Signature_form,
+    e_cp_Signature_classes,
+    e_cp_Descr_name,
+    e_cp_Descr_type,
+    e_cp_Field_class,
+    e_cp_Field_desc,
+    e_cp_Method_class,
+    e_cp_Method_desc,
+    e_cp_Imethod_class,
+    e_cp_Imethod_desc,
+    e_cp_MethodHandle_refkind,
+    e_cp_MethodHandle_member,
+    e_cp_MethodType,
+    e_cp_BootstrapMethod_ref,
+    e_cp_BootstrapMethod_arg_count,
+    e_cp_BootstrapMethod_arg,
+    e_cp_InvokeDynamic_spec,
+    e_cp_InvokeDynamic_desc,
+
+    // bands which define transmission of attributes
+    e_attr_definition_headers,
+    e_attr_definition_name,
+    e_attr_definition_layout,
+
+    // band for hardwired InnerClasses attribute (shared across the package)
+    e_ic_this_class,
+    e_ic_flags,
+    // These bands contain data only where flags sets ACC_IC_LONG_FORM:
+    e_ic_outer_class,
+    e_ic_name,
+
+    // bands for carrying class schema information:
+    e_class_this,
+    e_class_super,
+    e_class_interface_count,
+    e_class_interface,
+
+    // bands for class members
+    e_class_field_count,
+    e_class_method_count,
+
+    e_field_descr,
+    e_field_flags_hi,
+    e_field_flags_lo,
+    e_field_attr_count,
+    e_field_attr_indexes,
+    e_field_attr_calls,
+    e_field_ConstantValue_KQ,
+    e_field_Signature_RS,
+    e_field_metadata_bands,
+    e_field_attr_bands,
+
+    e_method_descr,
+    e_method_flags_hi,
+    e_method_flags_lo,
+    e_method_attr_count,
+    e_method_attr_indexes,
+    e_method_attr_calls,
+    e_method_Exceptions_N,
+    e_method_Exceptions_RC,
+    e_method_Signature_RS,
+    e_method_metadata_bands,
+    e_method_MethodParameters_NB,
+    e_method_MethodParameters_name_RUN,
+    e_method_MethodParameters_flag_FH,
+    e_method_attr_bands,
+
+    e_class_flags_hi,
+    e_class_flags_lo,
+    e_class_attr_count,
+    e_class_attr_indexes,
+    e_class_attr_calls,
+    e_class_SourceFile_RUN,
+    e_class_EnclosingMethod_RC,
+    e_class_EnclosingMethod_RDN,
+    e_class_Signature_RS,
+    e_class_metadata_bands,
+    e_class_InnerClasses_N,
+    e_class_InnerClasses_RC,
+    e_class_InnerClasses_F,
+    e_class_InnerClasses_outer_RCN,
+    e_class_InnerClasses_name_RUN,
+    e_class_ClassFile_version_minor_H,
+    e_class_ClassFile_version_major_H,
+    e_class_attr_bands,
+
+    e_code_headers,
+    e_code_max_stack,
+    e_code_max_na_locals,
+    e_code_handler_count,
+    e_code_handler_start_P,
+    e_code_handler_end_PO,
+    e_code_handler_catch_PO,
+    e_code_handler_class_RCN,
+
+    // code attributes
+    e_code_flags_hi,
+    e_code_flags_lo,
+    e_code_attr_count,
+    e_code_attr_indexes,
+    e_code_attr_calls,
+    e_code_StackMapTable_N,
+    e_code_StackMapTable_frame_T,
+    e_code_StackMapTable_local_N,
+    e_code_StackMapTable_stack_N,
+    e_code_StackMapTable_offset,
+    e_code_StackMapTable_T,
+    e_code_StackMapTable_RC,
+    e_code_StackMapTable_P,
+    e_code_LineNumberTable_N,
+    e_code_LineNumberTable_bci_P,
+    e_code_LineNumberTable_line,
+    e_code_LocalVariableTable_N,
+    e_code_LocalVariableTable_bci_P,
+    e_code_LocalVariableTable_span_O,
+    e_code_LocalVariableTable_name_RU,
+    e_code_LocalVariableTable_type_RS,
+    e_code_LocalVariableTable_slot,
+    e_code_LocalVariableTypeTable_N,
+    e_code_LocalVariableTypeTable_bci_P,
+    e_code_LocalVariableTypeTable_span_O,
+    e_code_LocalVariableTypeTable_name_RU,
+    e_code_LocalVariableTypeTable_type_RS,
+    e_code_LocalVariableTypeTable_slot,
+    e_code_attr_bands,
+
+    // bands for bytecodes
+    e_bc_codes,
+    // remaining bands provide typed opcode fields required by the bc_codes
+
+    e_bc_case_count,
+    e_bc_case_value,
+    e_bc_byte,
+    e_bc_short,
+    e_bc_local,
+    e_bc_label,
+
+    // ldc* operands:
+    e_bc_intref,
+    e_bc_floatref,
+    e_bc_longref,
+    e_bc_doubleref,
+    e_bc_stringref,
+    e_bc_loadablevalueref,
+    e_bc_classref,
+
+    e_bc_fieldref,
+    e_bc_methodref,
+    e_bc_imethodref,
+    e_bc_indyref,
+
+    // _self_linker_op family
+    e_bc_thisfield,
+    e_bc_superfield,
+    e_bc_thismethod,
+    e_bc_supermethod,
+
+    // bc_invokeinit family:
+    e_bc_initref,
+
+    // bytecode escape sequences
+    e_bc_escref,
+    e_bc_escrefsize,
+    e_bc_escsize,
+    e_bc_escbyte,
+
+    // file attributes and contents
+    e_file_name,
+    e_file_size_hi,
+    e_file_size_lo,
+    e_file_modtime,
+    e_file_options,
+    //e_file_bits,  // handled specially as an appendix
+
+    BAND_LIMIT
+};
+
+// Symbolic names for bands, as if in a giant global struct:
+//#define archive_magic all_bands[e_archive_magic]
+//#define archive_header all_bands[e_archive_header]
+//#define band_headers all_bands[e_band_headers]
+#define cp_Utf8_prefix all_bands[e_cp_Utf8_prefix]
+#define cp_Utf8_suffix all_bands[e_cp_Utf8_suffix]
+#define cp_Utf8_chars all_bands[e_cp_Utf8_chars]
+#define cp_Utf8_big_suffix all_bands[e_cp_Utf8_big_suffix]
+#define cp_Utf8_big_chars all_bands[e_cp_Utf8_big_chars]
+#define cp_Int all_bands[e_cp_Int]
+#define cp_Float all_bands[e_cp_Float]
+#define cp_Long_hi all_bands[e_cp_Long_hi]
+#define cp_Long_lo all_bands[e_cp_Long_lo]
+#define cp_Double_hi all_bands[e_cp_Double_hi]
+#define cp_Double_lo all_bands[e_cp_Double_lo]
+#define cp_String all_bands[e_cp_String]
+#define cp_Class all_bands[e_cp_Class]
+#define cp_Signature_form all_bands[e_cp_Signature_form]
+#define cp_Signature_classes all_bands[e_cp_Signature_classes]
+#define cp_Descr_name all_bands[e_cp_Descr_name]
+#define cp_Descr_type all_bands[e_cp_Descr_type]
+#define cp_Field_class all_bands[e_cp_Field_class]
+#define cp_Field_desc all_bands[e_cp_Field_desc]
+#define cp_Method_class all_bands[e_cp_Method_class]
+#define cp_Method_desc all_bands[e_cp_Method_desc]
+#define cp_Imethod_class all_bands[e_cp_Imethod_class]
+#define cp_Imethod_desc all_bands[e_cp_Imethod_desc]
+#define cp_MethodHandle_refkind all_bands[e_cp_MethodHandle_refkind]
+#define cp_MethodHandle_member all_bands[e_cp_MethodHandle_member]
+#define cp_MethodType all_bands[e_cp_MethodType]
+#define cp_BootstrapMethod_ref all_bands[e_cp_BootstrapMethod_ref]
+#define cp_BootstrapMethod_arg_count all_bands[e_cp_BootstrapMethod_arg_count]
+#define cp_BootstrapMethod_arg all_bands[e_cp_BootstrapMethod_arg]
+#define cp_InvokeDynamic_spec  all_bands[e_cp_InvokeDynamic_spec]
+#define cp_InvokeDynamic_desc all_bands[e_cp_InvokeDynamic_desc]
+#define attr_definition_headers all_bands[e_attr_definition_headers]
+#define attr_definition_name all_bands[e_attr_definition_name]
+#define attr_definition_layout all_bands[e_attr_definition_layout]
+#define ic_this_class all_bands[e_ic_this_class]
+#define ic_flags all_bands[e_ic_flags]
+#define ic_outer_class all_bands[e_ic_outer_class]
+#define ic_name all_bands[e_ic_name]
+#define class_this all_bands[e_class_this]
+#define class_super all_bands[e_class_super]
+#define class_interface_count all_bands[e_class_interface_count]
+#define class_interface all_bands[e_class_interface]
+#define class_field_count all_bands[e_class_field_count]
+#define class_method_count all_bands[e_class_method_count]
+#define field_descr all_bands[e_field_descr]
+#define field_flags_hi all_bands[e_field_flags_hi]
+#define field_flags_lo all_bands[e_field_flags_lo]
+#define field_attr_count all_bands[e_field_attr_count]
+#define field_attr_indexes all_bands[e_field_attr_indexes]
+#define field_ConstantValue_KQ all_bands[e_field_ConstantValue_KQ]
+#define field_Signature_RS all_bands[e_field_Signature_RS]
+#define field_attr_bands all_bands[e_field_attr_bands]
+#define method_descr all_bands[e_method_descr]
+#define method_flags_hi all_bands[e_method_flags_hi]
+#define method_flags_lo all_bands[e_method_flags_lo]
+#define method_attr_count all_bands[e_method_attr_count]
+#define method_attr_indexes all_bands[e_method_attr_indexes]
+#define method_Exceptions_N all_bands[e_method_Exceptions_N]
+#define method_Exceptions_RC all_bands[e_method_Exceptions_RC]
+#define method_Signature_RS all_bands[e_method_Signature_RS]
+#define method_MethodParameters_NB all_bands[e_method_MethodParameters_NB]
+#define method_MethodParameters_name_RUN all_bands[e_method_MethodParameters_name_RUN]
+#define method_MethodParameters_flag_FH all_bands[e_method_MethodParameters_flag_FH]
+#define method_attr_bands all_bands[e_method_attr_bands]
+#define class_flags_hi all_bands[e_class_flags_hi]
+#define class_flags_lo all_bands[e_class_flags_lo]
+#define class_attr_count all_bands[e_class_attr_count]
+#define class_attr_indexes all_bands[e_class_attr_indexes]
+#define class_SourceFile_RUN all_bands[e_class_SourceFile_RUN]
+#define class_EnclosingMethod_RC all_bands[e_class_EnclosingMethod_RC]
+#define class_EnclosingMethod_RDN all_bands[e_class_EnclosingMethod_RDN]
+#define class_Signature_RS all_bands[e_class_Signature_RS]
+#define class_InnerClasses_N all_bands[e_class_InnerClasses_N]
+#define class_InnerClasses_RC all_bands[e_class_InnerClasses_RC]
+#define class_InnerClasses_F all_bands[e_class_InnerClasses_F]
+#define class_InnerClasses_outer_RCN all_bands[e_class_InnerClasses_outer_RCN]
+#define class_InnerClasses_name_RUN all_bands[e_class_InnerClasses_name_RUN]
+#define class_ClassFile_version_minor_H all_bands[e_class_ClassFile_version_minor_H]
+#define class_ClassFile_version_major_H all_bands[e_class_ClassFile_version_major_H]
+#define class_attr_bands all_bands[e_class_attr_bands]
+#define code_headers all_bands[e_code_headers]
+#define code_max_stack all_bands[e_code_max_stack]
+#define code_max_na_locals all_bands[e_code_max_na_locals]
+#define code_handler_count all_bands[e_code_handler_count]
+#define code_handler_start_P all_bands[e_code_handler_start_P]
+#define code_handler_end_PO all_bands[e_code_handler_end_PO]
+#define code_handler_catch_PO all_bands[e_code_handler_catch_PO]
+#define code_handler_class_RCN all_bands[e_code_handler_class_RCN]
+#define code_flags_hi all_bands[e_code_flags_hi]
+#define code_flags_lo all_bands[e_code_flags_lo]
+#define code_attr_count all_bands[e_code_attr_count]
+#define code_attr_indexes all_bands[e_code_attr_indexes]
+#define code_StackMapTable_N all_bands[e_code_StackMapTable_N]
+#define code_StackMapTable_frame_T all_bands[e_code_StackMapTable_frame_T]
+#define code_StackMapTable_local_N all_bands[e_code_StackMapTable_local_N]
+#define code_StackMapTable_stack_N all_bands[e_code_StackMapTable_stack_N]
+#define code_StackMapTable_offset all_bands[e_code_StackMapTable_offset]
+#define code_StackMapTable_T all_bands[e_code_StackMapTable_T]
+#define code_StackMapTable_RC all_bands[e_code_StackMapTable_RC]
+#define code_StackMapTable_P all_bands[e_code_StackMapTable_P]
+#define code_LineNumberTable_N all_bands[e_code_LineNumberTable_N]
+#define code_LineNumberTable_bci_P all_bands[e_code_LineNumberTable_bci_P]
+#define code_LineNumberTable_line all_bands[e_code_LineNumberTable_line]
+#define code_LocalVariableTable_N all_bands[e_code_LocalVariableTable_N]
+#define code_LocalVariableTable_bci_P all_bands[e_code_LocalVariableTable_bci_P]
+#define code_LocalVariableTable_span_O all_bands[e_code_LocalVariableTable_span_O]
+#define code_LocalVariableTable_name_RU all_bands[e_code_LocalVariableTable_name_RU]
+#define code_LocalVariableTable_type_RS all_bands[e_code_LocalVariableTable_type_RS]
+#define code_LocalVariableTable_slot all_bands[e_code_LocalVariableTable_slot]
+#define code_LocalVariableTypeTable_N all_bands[e_code_LocalVariableTypeTable_N]
+#define code_LocalVariableTypeTable_bci_P all_bands[e_code_LocalVariableTypeTable_bci_P]
+#define code_LocalVariableTypeTable_span_O all_bands[e_code_LocalVariableTypeTable_span_O]
+#define code_LocalVariableTypeTable_name_RU all_bands[e_code_LocalVariableTypeTable_name_RU]
+#define code_LocalVariableTypeTable_type_RS all_bands[e_code_LocalVariableTypeTable_type_RS]
+#define code_LocalVariableTypeTable_slot all_bands[e_code_LocalVariableTypeTable_slot]
+#define code_attr_bands all_bands[e_code_attr_bands]
+#define bc_codes all_bands[e_bc_codes]
+#define bc_case_count all_bands[e_bc_case_count]
+#define bc_case_value all_bands[e_bc_case_value]
+#define bc_byte all_bands[e_bc_byte]
+#define bc_short all_bands[e_bc_short]
+#define bc_local all_bands[e_bc_local]
+#define bc_label all_bands[e_bc_label]
+#define bc_intref all_bands[e_bc_intref]
+#define bc_floatref all_bands[e_bc_floatref]
+#define bc_longref all_bands[e_bc_longref]
+#define bc_doubleref all_bands[e_bc_doubleref]
+#define bc_stringref all_bands[e_bc_stringref]
+#define bc_loadablevalueref all_bands[e_bc_loadablevalueref]
+#define bc_classref all_bands[e_bc_classref]
+#define bc_fieldref all_bands[e_bc_fieldref]
+#define bc_methodref all_bands[e_bc_methodref]
+#define bc_imethodref all_bands[e_bc_imethodref]
+#define bc_indyref all_bands[e_bc_indyref]
+#define bc_thisfield all_bands[e_bc_thisfield]
+#define bc_superfield all_bands[e_bc_superfield]
+#define bc_thismethod all_bands[e_bc_thismethod]
+#define bc_supermethod all_bands[e_bc_supermethod]
+#define bc_initref all_bands[e_bc_initref]
+#define bc_escref all_bands[e_bc_escref]
+#define bc_escrefsize all_bands[e_bc_escrefsize]
+#define bc_escsize all_bands[e_bc_escsize]
+#define bc_escbyte all_bands[e_bc_escbyte]
+#define file_name all_bands[e_file_name]
+#define file_size_hi all_bands[e_file_size_hi]
+#define file_size_lo all_bands[e_file_size_lo]
+#define file_modtime all_bands[e_file_modtime]
+#define file_options all_bands[e_file_options]
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/jdk/src/jdk.pack200/share/native/common-unpack/bytes.cpp	Fri Mar 06 09:02:26 2015 -0800
@@ -0,0 +1,193 @@
+/*
+ * Copyright (c) 2001, 2010, 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 <stdio.h>
+#include <stdlib.h>
+#include <string.h>
+#include "defines.h"
+#include "bytes.h"
+#include "utils.h"
+
+
+static byte dummy[1 << 10];
+
+bool bytes::inBounds(const void* p) {
+  return p >= ptr && p < limit();
+}
+
+void bytes::malloc(size_t len_) {
+  len = len_;
+  ptr = NEW(byte, add_size(len_, 1));  // add trailing zero byte always
+  if (ptr == null) {
+    // set ptr to some victim memory, to ease escape
+    set(dummy, sizeof(dummy)-1);
+    unpack_abort(ERROR_ENOMEM);
+  }
+}
+
+void bytes::realloc(size_t len_) {
+  if (len == len_)   return;  // nothing to do
+  if (ptr == dummy)  return;  // escaping from an error
+  if (ptr == null) {
+    malloc(len_);
+    return;
+  }
+  byte* oldptr = ptr;
+  ptr = (len_ >= PSIZE_MAX) ? null : (byte*)::realloc(ptr, add_size(len_, 1));
+  if (ptr != null)  {
+    mtrace('r', oldptr, 0);
+    mtrace('m', ptr, len_+1);
+    if (len < len_)  memset(ptr+len, 0, len_-len);
+    ptr[len_] = 0;
+    len = len_;
+  } else {
+    ptr = oldptr;  // ease our escape
+    unpack_abort(ERROR_ENOMEM);
+  }
+}
+
+void bytes::free() {
+  if (ptr == dummy)  return;  // escaping from an error
+  if (ptr != null) {
+    mtrace('f', ptr, 0);
+    ::free(ptr);
+  }
+  len = 0;
+  ptr = 0;
+}
+
+int bytes::indexOf(byte c) {
+  byte* p = (byte*) memchr(ptr, c, len);
+  return (p == 0) ? -1 : (int)(p - ptr);
+}
+
+byte* bytes::writeTo(byte* bp) {
+  memcpy(bp, ptr, len);
+  return bp+len;
+}
+
+int bytes::compareTo(bytes& other) {
+  size_t l1 = len;
+  size_t l2 = other.len;
+  int cmp = memcmp(ptr, other.ptr, (l1 < l2) ? l1 : l2);
+  if (cmp != 0)  return cmp;
+  return (l1 < l2) ? -1 : (l1 > l2) ? 1 : 0;
+}
+
+void bytes::saveFrom(const void* ptr_, size_t len_) {
+  malloc(len_);
+  // Save as much as possible.  (Helps unpacker::abort.)
+  if (len_ > len) {
+    assert(ptr == dummy);  // error recovery
+    len_ = len;
+  }
+  copyFrom(ptr_, len_);
+}
+
+//#TODO: Need to fix for exception handling
+void bytes::copyFrom(const void* ptr_, size_t len_, size_t offset) {
+  assert(len_ == 0 || inBounds(ptr + offset));
+  assert(len_ == 0 || inBounds(ptr + offset+len_-1));
+  memcpy(ptr+offset, ptr_, len_);
+}
+
+
+#ifndef PRODUCT
+const char* bytes::string() {
+  if (len == 0)  return "";
+  if (ptr[len] == 0 && strlen((char*)ptr) == len)  return (const char*) ptr;
+  bytes junk;
+  junk.saveFrom(*this);
+  return (char*) junk.ptr;
+}
+#endif
+
+// Make sure there are 'o' bytes beyond the fill pointer,
+// advance the fill pointer, and return the old fill pointer.
+byte* fillbytes::grow(size_t s) {
+  size_t nlen = add_size(b.len, s);
+  if (nlen <= allocated) {
+    b.len = nlen;
+    return limit()-s;
+  }
+  size_t maxlen = nlen;
+  if (maxlen < 128)          maxlen = 128;
+  if (maxlen < allocated*2)  maxlen = allocated*2;
+  if (allocated == 0) {
+    // Initial buffer was not malloced.  Do not reallocate it.
+    bytes old = b;
+    b.malloc(maxlen);
+    if (b.len == maxlen)
+      old.writeTo(b.ptr);
+  } else {
+    b.realloc(maxlen);
+  }
+  allocated = b.len;
+  if (allocated != maxlen) {
+    assert(unpack_aborting());
+    b.len = nlen-s;  // back up
+    return dummy;    // scribble during error recov.
+  }
+  // after realloc, recompute pointers
+  b.len = nlen;
+  assert(b.len <= allocated);
+  return limit()-s;
+}
+
+void fillbytes::ensureSize(size_t s) {
+  if (allocated >= s)  return;
+  size_t len0 = b.len;
+  grow(s - size());
+  b.len = len0;  // put it back
+}
+
+int ptrlist::indexOf(const void* x) {
+  int len = length();
+  for (int i = 0; i < len; i++) {
+    if (get(i) == x)  return i;
+  }
+  return -1;
+}
+
+void ptrlist::freeAll() {
+  int len = length();
+  for (int i = 0; i < len; i++) {
+    void* p = (void*) get(i);
+    if (p != null)  {
+      mtrace('f', p, 0);
+      ::free(p);
+    }
+  }
+  free();
+}
+
+int intlist::indexOf(int x) {
+  int len = length();
+  for (int i = 0; i < len; i++) {
+    if (get(i) == x)  return i;
+  }
+  return -1;
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/jdk/src/jdk.pack200/share/native/common-unpack/bytes.h	Fri Mar 06 09:02:26 2015 -0800
@@ -0,0 +1,144 @@
+/*
+ * Copyright (c) 2001, 2008, 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.
+ */
+
+#ifdef WIN32_LEAN_AND_MEAN
+typedef signed char byte ;
+#endif
+
+struct bytes {
+  byte*  ptr;
+  size_t len;
+  byte*  limit() { return ptr+len; }
+
+  void set(byte* ptr_, size_t len_) { ptr = ptr_; len = len_; }
+  void set(const char* str)         { ptr = (byte*)str; len = strlen(str); }
+  bool inBounds(const void* p);     // p in [ptr, limit)
+  void malloc(size_t len_);
+  void realloc(size_t len_);
+  void free();
+  void copyFrom(const void* ptr_, size_t len_, size_t offset = 0);
+  void saveFrom(const void* ptr_, size_t len_);
+  void saveFrom(const char* str) { saveFrom(str, strlen(str)); }
+  void copyFrom(bytes& other, size_t offset = 0) {
+    copyFrom(other.ptr, other.len, offset);
+  }
+  void saveFrom(bytes& other) {
+    saveFrom(other.ptr, other.len);
+  }
+  void clear(int fill_byte = 0) { memset(ptr, fill_byte, len); }
+  byte* writeTo(byte* bp);
+  bool equals(bytes& other) { return 0 == compareTo(other); }
+  int compareTo(bytes& other);
+  bool contains(byte c) { return indexOf(c) >= 0; }
+  int indexOf(byte c);
+  // substrings:
+  static bytes of(byte* ptr, size_t len) {
+    bytes res;
+    res.set(ptr, len);
+    return res;
+  }
+  bytes slice(size_t beg, size_t end) {
+    bytes res;
+    res.ptr = ptr + beg;
+    res.len = end - beg;
+    assert(res.len == 0 || inBounds(res.ptr) && inBounds(res.limit()-1));
+    return res;
+  }
+  // building C strings inside byte buffers:
+  bytes& strcat(const char* str) { ::strcat((char*)ptr, str); return *this; }
+  bytes& strcat(bytes& other) { ::strncat((char*)ptr, (char*)other.ptr, other.len); return *this; }
+  char* strval() { assert(strlen((char*)ptr) == len); return (char*) ptr; }
+#ifdef PRODUCT
+  const char* string() { return 0; }
+#else
+  const char* string();
+#endif
+};
+#define BYTES_OF(var) (bytes::of((byte*)&(var), sizeof(var)))
+
+struct fillbytes {
+  bytes b;
+  size_t allocated;
+
+  byte*  base()               { return b.ptr; }
+  size_t size()               { return b.len; }
+  byte*  limit()              { return b.limit(); }          // logical limit
+  void   setLimit(byte* lp)   { assert(isAllocated(lp)); b.len = lp - b.ptr; }
+  byte*  end()                { return b.ptr + allocated; }  // physical limit
+  byte*  loc(size_t o)        { assert(o < b.len); return b.ptr + o; }
+  void   init()               { allocated = 0; b.set(null, 0); }
+  void   init(size_t s)       { init(); ensureSize(s); }
+  void   free()               { if (allocated != 0) b.free(); allocated = 0; }
+  void   empty()              { b.len = 0; }
+  byte*  grow(size_t s);      // grow so that limit() += s
+  int    getByte(uint i)      { return *loc(i) & 0xFF; }
+  void   addByte(byte x)      { *grow(1) = x; }
+  void   ensureSize(size_t s); // make sure allocated >= s
+  void   trimToSize()         { if (allocated > size())  b.realloc(allocated = size()); }
+  bool   canAppend(size_t s)  { return allocated > b.len+s; }
+  bool   isAllocated(byte* p) { return p >= base() && p <= end(); } //asserts
+  void   set(bytes& src)      { set(src.ptr, src.len); }
+
+  void set(byte* ptr, size_t len) {
+    b.set(ptr, len);
+    allocated = 0;   // mark as not reallocatable
+  }
+
+  // block operations on resizing byte buffer:
+  fillbytes& append(const void* ptr_, size_t len_)
+    { memcpy(grow(len_), ptr_, len_); return (*this); }
+  fillbytes& append(bytes& other)
+    { return append(other.ptr, other.len); }
+  fillbytes& append(const char* str)
+    { return append(str, strlen(str)); }
+};
+
+struct ptrlist : fillbytes {
+  typedef const void* cvptr;
+  int    length()     { return (int)(size() / sizeof(cvptr)); }
+  cvptr* base()       { return (cvptr*) fillbytes::base(); }
+  cvptr& get(int i)   { return *(cvptr*)loc(i * sizeof(cvptr)); }
+  cvptr* limit()      { return (cvptr*) fillbytes::limit(); }
+  void   add(cvptr x) { *(cvptr*)grow(sizeof(x)) = x; }
+  void   popTo(int l) { assert(l <= length()); b.len = l * sizeof(cvptr); }
+  int    indexOf(cvptr x);
+  bool   contains(cvptr x) { return indexOf(x) >= 0; }
+  void   freeAll();   // frees every ptr on the list, plus the list itself
+};
+// Use a macro rather than mess with subtle mismatches
+// between member and non-member function pointers.
+#define PTRLIST_QSORT(ptrls, fn) \
+  ::qsort((ptrls).base(), (ptrls).length(), sizeof(void*), fn)
+
+struct intlist : fillbytes {
+  int    length()     { return (int)(size() / sizeof(int)); }
+  int*   base()       { return (int*) fillbytes::base(); }
+  int&   get(int i)   { return *(int*)loc(i * sizeof(int)); }
+  int*   limit()      { return (int*) fillbytes::limit(); }
+  void   add(int x)   { *(int*)grow(sizeof(x)) = x; }
+  void   popTo(int l) { assert(l <= length()); b.len = l * sizeof(int); }
+  int    indexOf(int x);
+  bool   contains(int x) { return indexOf(x) >= 0; }
+};
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/jdk/src/jdk.pack200/share/native/common-unpack/coding.cpp	Fri Mar 06 09:02:26 2015 -0800
@@ -0,0 +1,989 @@
+/*
+ * Copyright (c) 2002, 2009, 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.
+ */
+
+// -*- C++ -*-
+// Small program for unpacking specially compressed Java packages.
+// John R. Rose
+
+#include <stdio.h>
+#include <string.h>
+#include <stdlib.h>
+#include <stdarg.h>
+
+#include "jni_util.h"
+
+#include "defines.h"
+#include "bytes.h"
+#include "utils.h"
+#include "coding.h"
+
+#include "constants.h"
+#include "unpack.h"
+
+extern coding basic_codings[];
+
+#define CODING_PRIVATE(spec) \
+  int spec_ = spec; \
+  int B = CODING_B(spec_); \
+  int H = CODING_H(spec_); \
+  int L = 256 - H; \
+  int S = CODING_S(spec_); \
+  int D = CODING_D(spec_)
+
+#define IS_NEG_CODE(S, codeVal) \
+  ( (((int)(codeVal)+1) & ((1<<S)-1)) == 0 )
+
+#define DECODE_SIGN_S1(ux) \
+  ( ((uint)(ux) >> 1) ^ -((int)(ux) & 1) )
+
+static maybe_inline
+int decode_sign(int S, uint ux) {  // == Coding.decodeSign32
+  assert(S > 0);
+  uint sigbits = (ux >> S);
+  if (IS_NEG_CODE(S, ux))
+    return (int)(    ~sigbits);
+  else
+    return (int)(ux - sigbits);
+  // Note that (int)(ux-sigbits) can be negative, if ux is large enough.
+}
+
+coding* coding::init() {
+  if (umax > 0)  return this;  // already done
+  assert(spec != 0);  // sanity
+
+  // fill in derived fields
+  CODING_PRIVATE(spec);
+
+  // Return null if 'arb(BHSD)' parameter constraints are not met:
+  if (B < 1 || B > B_MAX)  return null;
+  if (H < 1 || H > 256)    return null;
+  if (S < 0 || S > 2)      return null;
+  if (D < 0 || D > 1)      return null;
+  if (B == 1 && H != 256)  return null;  // 1-byte coding must be fixed-size
+  if (B >= 5 && H == 256)  return null;  // no 5-byte fixed-size coding
+
+  // first compute the range of the coding, in 64 bits
+  jlong range = 0;
+  {
+    jlong H_i = 1;
+    for (int i = 0; i < B; i++) {
+      range += H_i;
+      H_i *= H;
+    }
+    range *= L;
+    range += H_i;
+  }
+  assert(range > 0);  // no useless codings, please
+
+  int this_umax;
+
+  // now, compute min and max
+  if (range >= ((jlong)1 << 32)) {
+    this_umax  = INT_MAX_VALUE;
+    this->umin = INT_MIN_VALUE;
+    this->max  = INT_MAX_VALUE;
+    this->min  = INT_MIN_VALUE;
+  } else {
+    this_umax = (range > INT_MAX_VALUE) ? INT_MAX_VALUE : (int)range-1;
+    this->max = this_umax;
+    this->min = this->umin = 0;
+    if (S != 0 && range != 0) {
+      int Smask = (1<<S)-1;
+      jlong maxPosCode = range-1;
+      jlong maxNegCode = range-1;
+      while (IS_NEG_CODE(S,  maxPosCode))  --maxPosCode;
+      while (!IS_NEG_CODE(S, maxNegCode))  --maxNegCode;
+      int maxPos = decode_sign(S, (uint)maxPosCode);
+      if (maxPos < 0)
+        this->max = INT_MAX_VALUE;  // 32-bit wraparound
+      else
+        this->max = maxPos;
+      if (maxNegCode < 0)
+        this->min = 0;  // No negative codings at all.
+      else
+        this->min = decode_sign(S, (uint)maxNegCode);
+    }
+  }
+
+  assert(!(isFullRange | isSigned | isSubrange)); // init
+  if (min < 0)
+    this->isSigned = true;
+  if (max < INT_MAX_VALUE && range <= INT_MAX_VALUE)
+    this->isSubrange = true;
+  if (max == INT_MAX_VALUE && min == INT_MIN_VALUE)
+    this->isFullRange = true;
+
+  // do this last, to reduce MT exposure (should have a membar too)
+  this->umax = this_umax;
+
+  return this;
+}
+
+coding* coding::findBySpec(int spec) {
+  for (coding* scan = &basic_codings[0]; ; scan++) {
+    if (scan->spec == spec)
+      return scan->init();
+    if (scan->spec == 0)
+      break;
+  }
+  coding* ptr = NEW(coding, 1);
+  CHECK_NULL_RETURN(ptr, 0);
+  coding* c = ptr->initFrom(spec);
+  if (c == null) {
+    mtrace('f', ptr, 0);
+    ::free(ptr);
+  } else
+    // else caller should free it...
+    c->isMalloc = true;
+  return c;
+}
+
+coding* coding::findBySpec(int B, int H, int S, int D) {
+  if (B < 1 || B > B_MAX)  return null;
+  if (H < 1 || H > 256)    return null;
+  if (S < 0 || S > 2)      return null;
+  if (D < 0 || D > 1)      return null;
+  return findBySpec(CODING_SPEC(B, H, S, D));
+}
+
+void coding::free() {
+  if (isMalloc) {
+    mtrace('f', this, 0);
+    ::free(this);
+  }
+}
+
+void coding_method::reset(value_stream* state) {
+  assert(state->rp == state->rplimit);  // not in mid-stream, please
+  //assert(this == vs0.cm);
+  state[0] = vs0;
+  if (uValues != null) {
+    uValues->reset(state->helper());
+  }
+}
+
+maybe_inline
+uint coding::parse(byte* &rp, int B, int H) {
+  int L = 256-H;
+  byte* ptr = rp;
+  // hand peel the i==0 part of the loop:
+  uint b_i = *ptr++ & 0xFF;
+  if (B == 1 || b_i < (uint)L)
+    { rp = ptr; return b_i; }
+  uint sum = b_i;
+  uint H_i = H;
+  assert(B <= B_MAX);
+  for (int i = 2; i <= B_MAX; i++) { // easy for compilers to unroll if desired
+    b_i = *ptr++ & 0xFF;
+    sum += b_i * H_i;
+    if (i == B || b_i < (uint)L)
+      { rp = ptr; return sum; }
+    H_i *= H;
+  }
+  assert(false);
+  return 0;
+}
+
+maybe_inline
+uint coding::parse_lgH(byte* &rp, int B, int H, int lgH) {
+  assert(H == (1<<lgH));
+  int L = 256-(1<<lgH);
+  byte* ptr = rp;
+  // hand peel the i==0 part of the loop:
+  uint b_i = *ptr++ & 0xFF;
+  if (B == 1 || b_i < (uint)L)
+    { rp = ptr; return b_i; }
+  uint sum = b_i;
+  uint lg_H_i = lgH;
+  assert(B <= B_MAX);
+  for (int i = 2; i <= B_MAX; i++) { // easy for compilers to unroll if desired
+    b_i = *ptr++ & 0xFF;
+    sum += b_i << lg_H_i;
+    if (i == B || b_i < (uint)L)
+      { rp = ptr; return sum; }
+    lg_H_i += lgH;
+  }
+  assert(false);
+  return 0;
+}
+
+static const char ERB[] = "EOF reading band";
+
+maybe_inline
+void coding::parseMultiple(byte* &rp, int N, byte* limit, int B, int H) {
+  if (N < 0) {
+    abort("bad value count");
+    return;
+  }
+  byte* ptr = rp;
+  if (B == 1 || H == 256) {
+    size_t len = (size_t)N*B;
+    if (len / B != (size_t)N || ptr+len > limit) {
+      abort(ERB);
+      return;
+    }
+    rp = ptr+len;
+    return;
+  }
+  // Note:  We assume rp has enough zero-padding.
+  int L = 256-H;
+  int n = B;
+  while (N > 0) {
+    ptr += 1;
+    if (--n == 0) {
+      // end of encoding at B bytes, regardless of byte value
+    } else {
+      int b = (ptr[-1] & 0xFF);
+      if (b >= L) {
+        // keep going, unless we find a byte < L
+        continue;
+      }
+    }
+    // found the last byte
+    N -= 1;
+    n = B;   // reset length counter
+    // do an error check here
+    if (ptr > limit) {
+      abort(ERB);
+      return;
+    }
+  }
+  rp = ptr;
+  return;
+}
+
+bool value_stream::hasHelper() {
+  // If my coding method is a pop-style method,
+  // then I need a second value stream to transmit
+  // unfavored values.
+  // This can be determined by examining fValues.
+  return cm->fValues != null;
+}
+
+void value_stream::init(byte* rp_, byte* rplimit_, coding* defc) {
+  rp = rp_;
+  rplimit = rplimit_;
+  sum = 0;
+  cm = null;  // no need in the simple case
+  setCoding(defc);
+}
+
+void value_stream::setCoding(coding* defc) {
+  if (defc == null) {
+    unpack_abort("bad coding");
+    defc = coding::findByIndex(_meta_canon_min);  // random pick for recovery
+  }
+
+  c = (*defc);
+
+  // choose cmk
+  cmk = cmk_ERROR;
+  switch (c.spec) {
+  case BYTE1_spec:      cmk = cmk_BYTE1;        break;
+  case CHAR3_spec:      cmk = cmk_CHAR3;        break;
+  case UNSIGNED5_spec:  cmk = cmk_UNSIGNED5;    break;
+  case DELTA5_spec:     cmk = cmk_DELTA5;       break;
+  case BCI5_spec:       cmk = cmk_BCI5;         break;
+  case BRANCH5_spec:    cmk = cmk_BRANCH5;      break;
+  default:
+    if (c.D() == 0) {
+      switch (c.S()) {
+      case 0:  cmk = cmk_BHS0;  break;
+      case 1:  cmk = cmk_BHS1;  break;
+      default: cmk = cmk_BHS;   break;
+      }
+    } else {
+      if (c.S() == 1) {
+        if (c.isFullRange)   cmk = cmk_BHS1D1full;
+        if (c.isSubrange)    cmk = cmk_BHS1D1sub;
+      }
+      if (cmk == cmk_ERROR)  cmk = cmk_BHSD1;
+    }
+  }
+}
+
+static maybe_inline
+int getPopValue(value_stream* self, uint uval) {
+  if (uval > 0) {
+    // note that the initial parse performed a range check
+    assert(uval <= (uint)self->cm->fVlength);
+    return self->cm->fValues[uval-1];
+  } else {
+    // take an unfavored value
+    return self->helper()->getInt();
+  }
+}
+
+maybe_inline
+int coding::sumInUnsignedRange(int x, int y) {
+  assert(isSubrange);
+  int range = (int)(umax+1);
+  assert(range > 0);
+  x += y;
+  if (x != (int)((jlong)(x-y) + (jlong)y)) {
+    // 32-bit overflow interferes with range reduction.
+    // Back off from the overflow by adding a multiple of range:
+    if (x < 0) {
+      x -= range;
+      assert(x >= 0);
+    } else {
+      x += range;
+      assert(x < 0);
+    }
+  }
+  if (x < 0) {
+    x += range;
+    if (x >= 0)  return x;
+  } else if (x >= range) {
+    x -= range;
+    if (x < range)  return x;
+  } else {
+    // in range
+    return x;
+  }
+  // do it the hard way
+  x %= range;
+  if (x < 0)  x += range;
+  return x;
+}
+
+static maybe_inline
+int getDeltaValue(value_stream* self, uint uval, bool isSubrange) {
+  assert((uint)(self->c.isSubrange) == (uint)isSubrange);
+  assert(self->c.isSubrange | self->c.isFullRange);
+  if (isSubrange)
+    return self->sum = self->c.sumInUnsignedRange(self->sum, (int)uval);
+  else
+    return self->sum += (int) uval;
+}
+
+bool value_stream::hasValue() {
+  if (rp < rplimit)      return true;
+  if (cm == null)        return false;
+  if (cm->next == null)  return false;
+  cm->next->reset(this);
+  return hasValue();
+}
+
+int value_stream::getInt() {
+  if (rp >= rplimit) {
+    // Advance to next coding segment.
+    if (rp > rplimit || cm == null || cm->next == null) {
+      // Must perform this check and throw an exception on bad input.
+      unpack_abort(ERB);
+      return 0;
+    }
+    cm->next->reset(this);
+    return getInt();
+  }
+
+  CODING_PRIVATE(c.spec);
+  uint uval;
+  enum {
+    B5 = 5,
+    B3 = 3,
+    H128 = 128,
+    H64 = 64,
+    H4 = 4
+  };
+  switch (cmk) {
+  case cmk_BHS:
+    assert(D == 0);
+    uval = coding::parse(rp, B, H);
+    if (S == 0)
+      return (int) uval;
+    return decode_sign(S, uval);
+
+  case cmk_BHS0:
+    assert(S == 0 && D == 0);
+    uval = coding::parse(rp, B, H);
+    return (int) uval;
+
+  case cmk_BHS1:
+    assert(S == 1 && D == 0);
+    uval = coding::parse(rp, B, H);
+    return DECODE_SIGN_S1(uval);
+
+  case cmk_BYTE1:
+    assert(c.spec == BYTE1_spec);
+    assert(B == 1 && H == 256 && S == 0 && D == 0);
+    return *rp++ & 0xFF;
+
+  case cmk_CHAR3:
+    assert(c.spec == CHAR3_spec);
+    assert(B == B3 && H == H128 && S == 0 && D == 0);
+    return coding::parse_lgH(rp, B3, H128, 7);
+
+  case cmk_UNSIGNED5:
+    assert(c.spec == UNSIGNED5_spec);
+    assert(B == B5 && H == H64 && S == 0 && D == 0);
+    return coding::parse_lgH(rp, B5, H64, 6);
+
+  case cmk_BHSD1:
+    assert(D == 1);
+    uval = coding::parse(rp, B, H);
+    if (S != 0)
+      uval = (uint) decode_sign(S, uval);
+    return getDeltaValue(this, uval, (bool)c.isSubrange);
+
+  case cmk_BHS1D1full:
+    assert(S == 1 && D == 1 && c.isFullRange);
+    uval = coding::parse(rp, B, H);
+    uval = (uint) DECODE_SIGN_S1(uval);
+    return getDeltaValue(this, uval, false);
+
+  case cmk_BHS1D1sub:
+    assert(S == 1 && D == 1 && c.isSubrange);
+    uval = coding::parse(rp, B, H);
+    uval = (uint) DECODE_SIGN_S1(uval);
+    return getDeltaValue(this, uval, true);
+
+  case cmk_DELTA5:
+    assert(c.spec == DELTA5_spec);
+    assert(B == B5 && H == H64 && S == 1 && D == 1 && c.isFullRange);
+    uval = coding::parse_lgH(rp, B5, H64, 6);
+    sum += DECODE_SIGN_S1(uval);
+    return sum;
+
+  case cmk_BCI5:
+    assert(c.spec == BCI5_spec);
+    assert(B == B5 && H == H4 && S == 0 && D == 0);
+    return coding::parse_lgH(rp, B5, H4, 2);
+
+  case cmk_BRANCH5:
+    assert(c.spec == BRANCH5_spec);
+    assert(B == B5 && H == H4 && S == 2 && D == 0);
+    uval = coding::parse_lgH(rp, B5, H4, 2);
+    return decode_sign(S, uval);
+
+  case cmk_pop:
+    uval = coding::parse(rp, B, H);
+    if (S != 0) {
+      uval = (uint) decode_sign(S, uval);
+    }
+    if (D != 0) {
+      assert(c.isSubrange | c.isFullRange);
+      if (c.isSubrange)
+        sum = c.sumInUnsignedRange(sum, (int) uval);
+      else
+        sum += (int) uval;
+      uval = (uint) sum;
+    }
+    return getPopValue(this, uval);
+
+  case cmk_pop_BHS0:
+    assert(S == 0 && D == 0);
+    uval = coding::parse(rp, B, H);
+    return getPopValue(this, uval);
+
+  case cmk_pop_BYTE1:
+    assert(c.spec == BYTE1_spec);
+    assert(B == 1 && H == 256 && S == 0 && D == 0);
+    return getPopValue(this, *rp++ & 0xFF);
+
+  default:
+    break;
+  }
+  assert(false);
+  return 0;
+}
+
+static maybe_inline
+int moreCentral(int x, int y) {  // used to find end of Pop.{F}
+  // Suggested implementation from the Pack200 specification:
+  uint kx = (x >> 31) ^ (x << 1);
+  uint ky = (y >> 31) ^ (y << 1);
+  return (kx < ky? x: y);
+}
+//static maybe_inline
+//int moreCentral2(int x, int y, int min) {
+//  // Strict implementation of buggy 150.7 specification.
+//  // The bug is that the spec. says absolute-value ties are broken
+//  // in favor of positive numbers, but the suggested implementation
+//  // (also mentioned in the spec.) breaks ties in favor of negative numbers.
+//  if ((x + y) != 0)
+//    return min;
+//  else
+//    // return the other value, which breaks a tie in the positive direction
+//    return (x > y)? x: y;
+//}
+
+static const byte* no_meta[] = {null};
+#define NO_META (*(byte**)no_meta)
+enum { POP_FAVORED_N = -2 };
+
+// mode bits
+#define DISABLE_RUN  1  // used immediately inside ACodee
+#define DISABLE_POP  2  // used recursively in all pop sub-bands
+
+// This function knows all about meta-coding.
+void coding_method::init(byte* &band_rp, byte* band_limit,
+                         byte* &meta_rp, int mode,
+                         coding* defc, int N,
+                         intlist* valueSink) {
+  assert(N != 0);
+
+  assert(u != null);  // must be pre-initialized
+  //if (u == null)  u = unpacker::current();  // expensive
+
+  int op = (meta_rp == null) ? _meta_default :  (*meta_rp++ & 0xFF);
+  coding* foundc = null;
+  coding* to_free = null;
+
+  if (op == _meta_default) {
+    foundc = defc;
+    // and fall through
+
+  } else if (op >= _meta_canon_min && op <= _meta_canon_max) {
+    foundc = coding::findByIndex(op);
+    // and fall through
+
+  } else if (op == _meta_arb) {
+    int args = (*meta_rp++ & 0xFF);
+    // args = (D:[0..1] + 2*S[0..2] + 8*(B:[1..5]-1))
+    int D = ((args >> 0) & 1);
+    int S = ((args >> 1) & 3);
+    int B = ((args >> 3) & -1) + 1;
+    // & (H[1..256]-1)
+    int H = (*meta_rp++ & 0xFF) + 1;
+    foundc = coding::findBySpec(B, H, S, D);
+    to_free = foundc;  // findBySpec may dynamically allocate
+    if (foundc == null) {
+      abort("illegal arb. coding");
+      return;
+    }
+    // and fall through
+
+  } else if (op >= _meta_run && op < _meta_pop) {
+    int args = (op - _meta_run);
+    // args: KX:[0..3] + 4*(KBFlag:[0..1]) + 8*(ABDef:[0..2])
+    int KX     = ((args >> 0) & 3);
+    int KBFlag = ((args >> 2) & 1);
+    int ABDef  = ((args >> 3) & -1);
+    assert(ABDef <= 2);
+    // & KB: one of [0..255] if KBFlag=1
+    int KB     = (!KBFlag? 3: (*meta_rp++ & 0xFF));
+    int K      = (KB+1) << (KX * 4);
+    int N2 = (N >= 0) ? N-K : N;
+    if (N == 0 || (N2 <= 0 && N2 != N)) {
+      abort("illegal run encoding");
+      return;
+    }
+    if ((mode & DISABLE_RUN) != 0) {
+      abort("illegal nested run encoding");
+      return;
+    }
+
+    // & Enc{ ACode } if ADef=0  (ABDef != 1)
+    // No direct nesting of 'run' in ACode, but in BCode it's OK.
+    int disRun = mode | DISABLE_RUN;
+    if (ABDef == 1) {
+      this->init(band_rp, band_limit, NO_META, disRun, defc, K, valueSink);
+    } else {
+      this->init(band_rp, band_limit, meta_rp, disRun, defc, K, valueSink);
+    }
+    CHECK;
+
+    // & Enc{ BCode } if BDef=0  (ABDef != 2)
+    coding_method* tail = U_NEW(coding_method, 1);
+    CHECK_NULL(tail);
+    tail->u = u;
+
+    // The 'run' codings may be nested indirectly via 'pop' codings.
+    // This means that this->next may already be filled in, if
+    // ACode was of type 'pop' with a 'run' token coding.
+    // No problem:  Just chain the upcoming BCode onto the end.
+    for (coding_method* self = this; ; self = self->next) {
+      if (self->next == null) {
+        self->next = tail;
+        break;
+      }
+    }
+
+    if (ABDef == 2) {
+      tail->init(band_rp, band_limit, NO_META, mode, defc, N2, valueSink);
+    } else {
+      tail->init(band_rp, band_limit, meta_rp, mode, defc, N2, valueSink);
+    }
+    // Note:  The preceding calls to init should be tail-recursive.
+
+    return;  // done; no falling through
+
+  } else if (op >= _meta_pop && op < _meta_limit) {
+    int args = (op - _meta_pop);
+    // args: (FDef:[0..1]) + 2*UDef:[0..1] + 4*(TDefL:[0..11])
+    int FDef  = ((args >> 0) & 1);
+    int UDef  = ((args >> 1) & 1);
+    int TDefL = ((args >> 2) & -1);
+    assert(TDefL <= 11);
+    int TDef  = (TDefL > 0);
+    int TL    = (TDefL <= 6) ? (2 << TDefL) : (256 - (4 << (11-TDefL)));
+    int TH    = (256-TL);
+    if (N <= 0) {
+      abort("illegal pop encoding");
+      return;
+    }
+    if ((mode & DISABLE_POP) != 0) {
+      abort("illegal nested pop encoding");
+      return;
+    }
+
+    // No indirect nesting of 'pop', but 'run' is OK.
+    int disPop = DISABLE_POP;
+
+    // & Enc{ FCode } if FDef=0
+    int FN = POP_FAVORED_N;
+    assert(valueSink == null);
+    intlist fValueSink; fValueSink.init();
+    coding_method fval;
+    BYTES_OF(fval).clear(); fval.u = u;
+    if (FDef != 0) {
+      fval.init(band_rp, band_limit, NO_META, disPop, defc, FN, &fValueSink);
+    } else {
+      fval.init(band_rp, band_limit, meta_rp, disPop, defc, FN, &fValueSink);
+    }
+    bytes fvbuf;
+    fValues  = (u->saveTo(fvbuf, fValueSink.b), (int*) fvbuf.ptr);
+    fVlength = fValueSink.length();  // i.e., the parameter K
+    fValueSink.free();
+    CHECK;
+
+    // Skip the first {F} run in all subsequent passes.
+    // The next call to this->init(...) will set vs0.rp to point after the {F}.
+
+    // & Enc{ TCode } if TDef=0  (TDefL==0)
+    if (TDef != 0) {
+      coding* tcode = coding::findBySpec(1, 256);  // BYTE1
+      // find the most narrowly sufficient code:
+      for (int B = 2; B <= B_MAX; B++) {
+        if (fVlength <= tcode->umax)  break;  // found it
+        tcode->free();
+        tcode = coding::findBySpec(B, TH);
+        CHECK_NULL(tcode);
+      }
+      if (!(fVlength <= tcode->umax)) {
+        abort("pop.L value too small");
+        return;
+      }
+      this->init(band_rp, band_limit, NO_META, disPop, tcode, N, null);
+      tcode->free();
+    } else {
+      this->init(band_rp, band_limit, meta_rp, disPop,  defc, N, null);
+    }
+    CHECK;
+
+    // Count the number of zero tokens right now.
+    // Also verify that they are in bounds.
+    int UN = 0;   // one {U} for each zero in {T}
+    value_stream vs = vs0;
+    for (int i = 0; i < N; i++) {
+      uint val = vs.getInt();
+      if (val == 0)  UN += 1;
+      if (!(val <= (uint)fVlength)) {
+        abort("pop token out of range");
+        return;
+      }
+    }
+    vs.done();
+
+    // & Enc{ UCode } if UDef=0
+    if (UN != 0) {
+      uValues = U_NEW(coding_method, 1);
+      CHECK_NULL(uValues);
+      uValues->u = u;
+      if (UDef != 0) {
+        uValues->init(band_rp, band_limit, NO_META, disPop, defc, UN, null);
+      } else {
+        uValues->init(band_rp, band_limit, meta_rp, disPop, defc, UN, null);
+      }
+    } else {
+      if (UDef == 0) {
+        int uop = (*meta_rp++ & 0xFF);
+        if (uop > _meta_canon_max)
+          // %%% Spec. requires the more strict (uop != _meta_default).
+          abort("bad meta-coding for empty pop/U");
+      }
+    }
+
+    // Bug fix for 6259542
+    // Last of all, adjust vs0.cmk to the 'pop' flavor
+    for (coding_method* self = this; self != null; self = self->next) {
+        coding_method_kind cmk2 = cmk_pop;
+        switch (self->vs0.cmk) {
+        case cmk_BHS0:   cmk2 = cmk_pop_BHS0;   break;
+        case cmk_BYTE1:  cmk2 = cmk_pop_BYTE1;  break;
+        default: break;
+        }
+        self->vs0.cmk = cmk2;
+        if (self != this) {
+          assert(self->fValues == null); // no double init
+          self->fValues  = this->fValues;
+          self->fVlength = this->fVlength;
+          assert(self->uValues == null); // must stay null
+        }
+    }
+
+    return;  // done; no falling through
+
+  } else {
+    abort("bad meta-coding");
+    return;
+  }
+
+  // Common code here skips a series of values with one coding.
+  assert(foundc != null);
+
+  assert(vs0.cmk == cmk_ERROR);  // no garbage, please
+  assert(vs0.rp == null);  // no garbage, please
+  assert(vs0.rplimit == null);  // no garbage, please
+  assert(vs0.sum == 0);  // no garbage, please
+
+  vs0.init(band_rp, band_limit, foundc);
+
+  // Done with foundc.  Free if necessary.
+  if (to_free != null) {
+    to_free->free();
+    to_free = null;
+  }
+  foundc = null;
+
+  coding& c = vs0.c;
+  CODING_PRIVATE(c.spec);
+  // assert sane N
+  assert((uint)N < INT_MAX_VALUE || N == POP_FAVORED_N);
+
+  // Look at the values, or at least skip over them quickly.
+  if (valueSink == null) {
+    // Skip and ignore values in the first pass.
+    c.parseMultiple(band_rp, N, band_limit, B, H);
+  } else if (N >= 0) {
+    // Pop coding, {F} sequence, initial run of values...
+    assert((mode & DISABLE_POP) != 0);
+    value_stream vs = vs0;
+    for (int n = 0; n < N; n++) {
+      int val = vs.getInt();
+      valueSink->add(val);
+    }
+    band_rp = vs.rp;
+  } else {
+    // Pop coding, {F} sequence, final run of values...
+    assert((mode & DISABLE_POP) != 0);
+    assert(N == POP_FAVORED_N);
+    int min = INT_MIN_VALUE;  // farthest from the center
+    // min2 is based on the buggy specification of centrality in version 150.7
+    // no known implementations transmit this value, but just in case...
+    //int min2 = INT_MIN_VALUE;
+    int last = 0;
+    // if there were initial runs, find the potential sentinels in them:
+    for (int i = 0; i < valueSink->length(); i++) {
+      last = valueSink->get(i);
+      min = moreCentral(min, last);
+      //min2 = moreCentral2(min2, last, min);
+    }
+    value_stream vs = vs0;
+    for (;;) {
+      int val = vs.getInt();
+      if (valueSink->length() > 0 &&
+          (val == last || val == min)) //|| val == min2
+        break;
+      valueSink->add(val);
+      CHECK;
+      last = val;
+      min = moreCentral(min, last);
+      //min2 = moreCentral2(min2, last, min);
+    }
+    band_rp = vs.rp;
+  }
+  CHECK;
+
+  // Get an accurate upper limit now.
+  vs0.rplimit = band_rp;
+  vs0.cm = this;
+
+  return; // success
+}
+
+coding basic_codings[] = {
+  // This one is not a usable irregular coding, but is used by cp_Utf8_chars.
+  CODING_INIT(3,128,0,0),
+
+  // Fixed-length codings:
+  CODING_INIT(1,256,0,0),
+  CODING_INIT(1,256,1,0),
+  CODING_INIT(1,256,0,1),
+  CODING_INIT(1,256,1,1),
+  CODING_INIT(2,256,0,0),
+  CODING_INIT(2,256,1,0),
+  CODING_INIT(2,256,0,1),
+  CODING_INIT(2,256,1,1),
+  CODING_INIT(3,256,0,0),
+  CODING_INIT(3,256,1,0),
+  CODING_INIT(3,256,0,1),
+  CODING_INIT(3,256,1,1),
+  CODING_INIT(4,256,0,0),
+  CODING_INIT(4,256,1,0),
+  CODING_INIT(4,256,0,1),
+  CODING_INIT(4,256,1,1),
+
+  // Full-range variable-length codings:
+  CODING_INIT(5,  4,0,0),
+  CODING_INIT(5,  4,1,0),
+  CODING_INIT(5,  4,2,0),
+  CODING_INIT(5, 16,0,0),
+  CODING_INIT(5, 16,1,0),
+  CODING_INIT(5, 16,2,0),
+  CODING_INIT(5, 32,0,0),
+  CODING_INIT(5, 32,1,0),
+  CODING_INIT(5, 32,2,0),
+  CODING_INIT(5, 64,0,0),
+  CODING_INIT(5, 64,1,0),
+  CODING_INIT(5, 64,2,0),
+  CODING_INIT(5,128,0,0),
+  CODING_INIT(5,128,1,0),
+  CODING_INIT(5,128,2,0),
+
+  CODING_INIT(5,  4,0,1),
+  CODING_INIT(5,  4,1,1),
+  CODING_INIT(5,  4,2,1),
+  CODING_INIT(5, 16,0,1),
+  CODING_INIT(5, 16,1,1),
+  CODING_INIT(5, 16,2,1),
+  CODING_INIT(5, 32,0,1),
+  CODING_INIT(5, 32,1,1),
+  CODING_INIT(5, 32,2,1),
+  CODING_INIT(5, 64,0,1),
+  CODING_INIT(5, 64,1,1),
+  CODING_INIT(5, 64,2,1),
+  CODING_INIT(5,128,0,1),
+  CODING_INIT(5,128,1,1),
+  CODING_INIT(5,128,2,1),
+
+  // Variable length subrange codings:
+  CODING_INIT(2,192,0,0),
+  CODING_INIT(2,224,0,0),
+  CODING_INIT(2,240,0,0),
+  CODING_INIT(2,248,0,0),
+  CODING_INIT(2,252,0,0),
+
+  CODING_INIT(2,  8,0,1),
+  CODING_INIT(2,  8,1,1),
+  CODING_INIT(2, 16,0,1),
+  CODING_INIT(2, 16,1,1),
+  CODING_INIT(2, 32,0,1),
+  CODING_INIT(2, 32,1,1),
+  CODING_INIT(2, 64,0,1),
+  CODING_INIT(2, 64,1,1),
+  CODING_INIT(2,128,0,1),
+  CODING_INIT(2,128,1,1),
+  CODING_INIT(2,192,0,1),
+  CODING_INIT(2,192,1,1),
+  CODING_INIT(2,224,0,1),
+  CODING_INIT(2,224,1,1),
+  CODING_INIT(2,240,0,1),
+  CODING_INIT(2,240,1,1),
+  CODING_INIT(2,248,0,1),
+  CODING_INIT(2,248,1,1),
+
+  CODING_INIT(3,192,0,0),
+  CODING_INIT(3,224,0,0),
+  CODING_INIT(3,240,0,0),
+  CODING_INIT(3,248,0,0),
+  CODING_INIT(3,252,0,0),
+
+  CODING_INIT(3,  8,0,1),
+  CODING_INIT(3,  8,1,1),
+  CODING_INIT(3, 16,0,1),
+  CODING_INIT(3, 16,1,1),
+  CODING_INIT(3, 32,0,1),
+  CODING_INIT(3, 32,1,1),
+  CODING_INIT(3, 64,0,1),
+  CODING_INIT(3, 64,1,1),
+  CODING_INIT(3,128,0,1),
+  CODING_INIT(3,128,1,1),
+  CODING_INIT(3,192,0,1),
+  CODING_INIT(3,192,1,1),
+  CODING_INIT(3,224,0,1),
+  CODING_INIT(3,224,1,1),
+  CODING_INIT(3,240,0,1),
+  CODING_INIT(3,240,1,1),
+  CODING_INIT(3,248,0,1),
+  CODING_INIT(3,248,1,1),
+
+  CODING_INIT(4,192,0,0),
+  CODING_INIT(4,224,0,0),
+  CODING_INIT(4,240,0,0),
+  CODING_INIT(4,248,0,0),
+  CODING_INIT(4,252,0,0),
+
+  CODING_INIT(4,  8,0,1),
+  CODING_INIT(4,  8,1,1),
+  CODING_INIT(4, 16,0,1),
+  CODING_INIT(4, 16,1,1),
+  CODING_INIT(4, 32,0,1),
+  CODING_INIT(4, 32,1,1),
+  CODING_INIT(4, 64,0,1),
+  CODING_INIT(4, 64,1,1),
+  CODING_INIT(4,128,0,1),
+  CODING_INIT(4,128,1,1),
+  CODING_INIT(4,192,0,1),
+  CODING_INIT(4,192,1,1),
+  CODING_INIT(4,224,0,1),
+  CODING_INIT(4,224,1,1),
+  CODING_INIT(4,240,0,1),
+  CODING_INIT(4,240,1,1),
+  CODING_INIT(4,248,0,1),
+  CODING_INIT(4,248,1,1),
+  CODING_INIT(0,0,0,0)
+};
+#define BASIC_INDEX_LIMIT \
+        (int)(sizeof(basic_codings)/sizeof(basic_codings[0])-1)
+
+coding* coding::findByIndex(int idx) {
+#ifndef PRODUCT
+  /* Tricky assert here, constants and gcc complains about it without local. */
+  int index_limit = BASIC_INDEX_LIMIT;
+  assert(_meta_canon_min == 1 && _meta_canon_max+1 == index_limit);
+#endif
+  if (idx >= _meta_canon_min && idx <= _meta_canon_max)
+    return basic_codings[idx].init();
+  else
+    return null;
+}
+
+#ifndef PRODUCT
+const char* coding::string() {
+  CODING_PRIVATE(spec);
+  bytes buf;
+  buf.malloc(100);
+  char maxS[20], minS[20];
+  sprintf(maxS, "%d", max);
+  sprintf(minS, "%d", min);
+  if (max == INT_MAX_VALUE)  strcpy(maxS, "max");
+  if (min == INT_MIN_VALUE)  strcpy(minS, "min");
+  sprintf((char*)buf.ptr, "(%d,%d,%d,%d) L=%d r=[%s,%s]",
+          B,H,S,D,L,minS,maxS);
+  return (const char*) buf.ptr;
+}
+#endif
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/jdk/src/jdk.pack200/share/native/common-unpack/coding.h	Fri Mar 06 09:02:26 2015 -0800
@@ -0,0 +1,226 @@
+/*
+ * Copyright (c) 2002, 2008, 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.
+ */
+
+struct unpacker;
+
+#define INT_MAX_VALUE ((int)0x7FFFFFFF)
+#define INT_MIN_VALUE ((int)0x80000000)
+
+#define CODING_SPEC(B, H, S, D) ((B)<<20|(H)<<8|(S)<<4|(D)<<0)
+#define CODING_B(x) ((x)>>20 & 0xF)
+#define CODING_H(x) ((x)>>8  & 0xFFF)
+#define CODING_S(x) ((x)>>4  & 0xF)
+#define CODING_D(x) ((x)>>0  & 0xF)
+
+#define CODING_INIT(B, H, S, D) \
+  { CODING_SPEC(B, H, S, D) , 0, 0, 0, 0, 0, 0, 0, 0}
+
+// For debugging purposes, some compilers do not like this and will complain.
+//    #define long do_not_use_C_long_types_use_jlong_or_int
+// Use of the type "long" is problematic, do not use it.
+
+struct coding {
+  int  spec;  // B,H,S,D
+
+  // Handy values derived from the spec:
+  int B() { return CODING_B(spec); }
+  int H() { return CODING_H(spec); }
+  int S() { return CODING_S(spec); }
+  int D() { return CODING_D(spec); }
+  int L() { return 256-CODING_H(spec); }
+  int  min, max;
+  int  umin, umax;
+  char isSigned, isSubrange, isFullRange, isMalloc;
+
+  coding* init();  // returns self or null if error
+  coding* initFrom(int spec_) {
+    assert(this->spec == 0);
+    this->spec = spec_;
+    return init();
+  }
+
+  static coding* findBySpec(int spec);
+  static coding* findBySpec(int B, int H, int S=0, int D=0);
+  static coding* findByIndex(int irregularCodingIndex);
+
+  static uint parse(byte* &rp, int B, int H);
+  static uint parse_lgH(byte* &rp, int B, int H, int lgH);
+  static void parseMultiple(byte* &rp, int N, byte* limit, int B, int H);
+
+  uint parse(byte* &rp) {
+    return parse(rp, CODING_B(spec), CODING_H(spec));
+  }
+  void parseMultiple(byte* &rp, int N, byte* limit) {
+    parseMultiple(rp, N, limit, CODING_B(spec), CODING_H(spec));
+  }
+
+  bool canRepresent(int x)         { return (x >= min  && x <= max);  }
+  bool canRepresentUnsigned(int x) { return (x >= umin && x <= umax); }
+
+  int sumInUnsignedRange(int x, int y);
+
+  int readFrom(byte* &rpVar, int* dbase);
+  void readArrayFrom(byte* &rpVar, int* dbase, int length, int* values);
+  void skipArrayFrom(byte* &rpVar, int length) {
+    readArrayFrom(rpVar, (int*)NULL, length, (int*)NULL);
+  }
+
+#ifndef PRODUCT
+  const char* string();
+#endif
+
+  void free();  // free self if isMalloc
+
+  // error handling
+  static void abort(const char* msg = null) { unpack_abort(msg); }
+};
+
+enum coding_method_kind {
+  cmk_ERROR,
+  cmk_BHS,
+  cmk_BHS0,
+  cmk_BHS1,
+  cmk_BHSD1,
+  cmk_BHS1D1full,  // isFullRange
+  cmk_BHS1D1sub,   // isSubRange
+
+  // special cases hand-optimized (~50% of all decoded values)
+  cmk_BYTE1,         //(1,256)      6%
+  cmk_CHAR3,         //(3,128)      7%
+  cmk_UNSIGNED5,     //(5,64)      13%
+  cmk_DELTA5,        //(5,64,1,1)   5%
+  cmk_BCI5,          //(5,4)       18%
+  cmk_BRANCH5,       //(5,4,2)      4%
+//cmk_UNSIGNED5H16,  //(5,16)       5%
+//cmk_UNSIGNED2H4,   //(2,4)        6%
+//cmk_DELTA4H8,      //(4,8,1,1)   10%
+//cmk_DELTA3H16,     //(3,16,1,1)   9%
+  cmk_BHS_LIMIT,
+
+  cmk_pop,
+  cmk_pop_BHS0,
+  cmk_pop_BYTE1,
+  cmk_pop_LIMIT,
+
+  cmk_LIMIT
+};
+
+enum {
+  BYTE1_spec       = CODING_SPEC(1, 256, 0, 0),
+  CHAR3_spec       = CODING_SPEC(3, 128, 0, 0),
+  UNSIGNED4_spec   = CODING_SPEC(4, 256, 0, 0),
+  UNSIGNED5_spec   = CODING_SPEC(5, 64, 0, 0),
+  SIGNED5_spec     = CODING_SPEC(5, 64, 1, 0),
+  DELTA5_spec      = CODING_SPEC(5, 64, 1, 1),
+  UDELTA5_spec     = CODING_SPEC(5, 64, 0, 1),
+  MDELTA5_spec     = CODING_SPEC(5, 64, 2, 1),
+  BCI5_spec        = CODING_SPEC(5, 4, 0, 0),
+  BRANCH5_spec     = CODING_SPEC(5, 4, 2, 0)
+};
+
+enum {
+  B_MAX = 5,
+  C_SLOP = B_MAX*10
+};
+
+struct coding_method;
+
+// iterator under the control of a meta-coding
+struct value_stream {
+  // current coding of values or values
+  coding c;               // B,H,S,D,etc.
+  coding_method_kind cmk; // type of decoding needed
+  byte* rp;               // read pointer
+  byte* rplimit;          // final value of read pointer
+  int sum;                // partial sum of all values so far (D=1 only)
+  coding_method* cm;      // coding method that defines this stream
+
+  void init(byte* band_rp, byte* band_limit, coding* defc);
+  void init(byte* band_rp, byte* band_limit, int spec)
+    { init(band_rp, band_limit, coding::findBySpec(spec)); }
+
+  void setCoding(coding* c);
+  void setCoding(int spec) { setCoding(coding::findBySpec(spec)); }
+
+  // Parse and decode a single value.
+  int getInt();
+
+  // Parse and decode a single byte, with no error checks.
+  int getByte() {
+    assert(cmk == cmk_BYTE1);
+    assert(rp < rplimit);
+    return *rp++ & 0xFF;
+  }
+
+  // Used only for asserts.
+  bool hasValue();
+
+  void done() { assert(!hasValue()); }
+
+  // Sometimes a value stream has an auxiliary (but there are never two).
+  value_stream* helper() {
+    assert(hasHelper());
+    return this+1;
+  }
+  bool hasHelper();
+
+  // error handling
+  //  inline void abort(const char* msg);
+  //  inline void aborting();
+};
+
+struct coding_method {
+  value_stream vs0;       // initial state snapshot (vs.meta==this)
+
+  coding_method* next;    // what to do when we run out of bytes
+
+  // these fields are used for pop codes only:
+  int* fValues;           // favored value array
+  int  fVlength;          // maximum favored value token
+  coding_method* uValues; // unfavored value stream
+
+  // pointer to outer unpacker, for error checks etc.
+  unpacker* u;
+
+  // Initialize a value stream.
+  void reset(value_stream* state);
+
+  // Parse a band header, size a band, and initialize for further action.
+  // band_rp advances (but not past band_limit), and meta_rp advances.
+  // The mode gives context, such as "inside a pop".
+  // The defc and N are the incoming parameters to a meta-coding.
+  // The value sink is used to collect output values, when desired.
+  void init(byte* &band_rp, byte* band_limit,
+            byte* &meta_rp, int mode,
+            coding* defc, int N,
+            intlist* valueSink);
+
+  // error handling
+  void abort(const char* msg) { unpack_abort(msg, u); }
+  bool aborting()             { return unpack_aborting(u); }
+};
+
+//inline void value_stream::abort(const char* msg) { cm->abort(msg); }
+//inline void value_stream::aborting()             { cm->aborting(); }
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/jdk/src/jdk.pack200/share/native/common-unpack/constants.h	Fri Mar 06 09:02:26 2015 -0800
@@ -0,0 +1,517 @@
+/*
+ * Copyright (c) 2001, 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.
+ */
+
+/*
+  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
+
+// package file constants
+#define JAVA_PACKAGE_MAGIC 0xCAFED00D
+#define JAVA5_PACKAGE_MAJOR_VERSION 150
+#define JAVA5_PACKAGE_MINOR_VERSION 7
+
+#define JAVA6_PACKAGE_MAJOR_VERSION 160
+#define JAVA6_PACKAGE_MINOR_VERSION 1
+
+#define JAVA7_PACKAGE_MAJOR_VERSION 170
+#define JAVA7_PACKAGE_MINOR_VERSION 1
+
+#define JAVA8_PACKAGE_MAJOR_VERSION 171
+#define JAVA8_PACKAGE_MINOR_VERSION 0
+
+// magic number for gzip streams (for processing pack200-gzip data)
+#define GZIP_MAGIC      0x1F8B0800
+#define GZIP_MAGIC_MASK 0xFFFFFF00  // last byte is variable "flg" field
+
+enum {
+    CONSTANT_None               = 0,
+    CONSTANT_Utf8               = 1,
+    CONSTANT_unused             = 2,     /* unused, was Unicode */
+    CONSTANT_Integer            = 3,
+    CONSTANT_Float              = 4,
+    CONSTANT_Long               = 5,
+    CONSTANT_Double             = 6,
+    CONSTANT_Class              = 7,
+    CONSTANT_String             = 8,
+    CONSTANT_Fieldref           = 9,
+    CONSTANT_Methodref          = 10,
+    CONSTANT_InterfaceMethodref = 11,
+    CONSTANT_NameandType        = 12,
+    CONSTANT_unused13           = 13,
+    CONSTANT_unused14           = 14,
+    CONSTANT_MethodHandle       = 15,
+    CONSTANT_MethodType         = 16,
+    CONSTANT_unused17           = 17,
+    CONSTANT_InvokeDynamic      = 18,
+    CONSTANT_Limit              = 19,
+    CONSTANT_Signature          = CONSTANT_unused13,
+    CONSTANT_BootstrapMethod    = CONSTANT_unused17, // used only for InvokeDynamic
+    CONSTANT_All                = 50,                // combined global map
+    CONSTANT_LoadableValue      = 51,                // used for 'KL' and qldc operands
+    CONSTANT_AnyMember          = 52,                // union of refs to field or (interface) method
+    CONSTANT_FieldSpecific      = 53,                // used only for 'KQ' ConstantValue attrs
+    CONSTANT_GroupFirst         = CONSTANT_All,      // start group marker
+    CONSTANT_GroupLimit         = 54,                // end group marker
+
+    // CONSTANT_MethodHandle reference kinds
+    REF_getField         = 1,
+    REF_getStatic        = 2,
+    REF_putField         = 3,
+    REF_putStatic        = 4,
+    REF_invokeVirtual    = 5,
+    REF_invokeStatic     = 6,
+    REF_invokeSpecial    = 7,
+    REF_newInvokeSpecial = 8,
+    REF_invokeInterface  = 9,
+
+    SUBINDEX_BIT = 64,  // combined with CONSTANT_xxx for ixTag
+
+    ACC_STATIC       = 0x0008,
+    ACC_IC_LONG_FORM = (1<<16), //for ic_flags
+
+    CLASS_ATTR_SourceFile                            = 17,
+    CLASS_ATTR_EnclosingMethod                       = 18,
+    CLASS_ATTR_InnerClasses                          = 23,
+    CLASS_ATTR_ClassFile_version                     = 24,
+    CLASS_ATTR_BootstrapMethods                      = 25,
+    FIELD_ATTR_ConstantValue                         = 17,
+    METHOD_ATTR_Code                                 = 17,
+    METHOD_ATTR_Exceptions                           = 18,
+    METHOD_ATTR_RuntimeVisibleParameterAnnotations   = 23,
+    METHOD_ATTR_RuntimeInvisibleParameterAnnotations = 24,
+    METHOD_ATTR_AnnotationDefault                    = 25,
+    METHOD_ATTR_MethodParameters                     = 26,
+    CODE_ATTR_StackMapTable          = 0,
+    CODE_ATTR_LineNumberTable        = 1,
+    CODE_ATTR_LocalVariableTable     = 2,
+    CODE_ATTR_LocalVariableTypeTable = 3,
+    //X_ATTR_Synthetic = 12,  // ACC_SYNTHETIC; not predefined
+    X_ATTR_Signature                   = 19,
+    X_ATTR_Deprecated                  = 20,
+    X_ATTR_RuntimeVisibleAnnotations   = 21,
+    X_ATTR_RuntimeInvisibleAnnotations = 22,
+    X_ATTR_RuntimeVisibleTypeAnnotations   = 27,
+    X_ATTR_RuntimeInvisibleTypeAnnotations = 28,
+    X_ATTR_OVERFLOW                    = 16,
+    X_ATTR_LIMIT_NO_FLAGS_HI           = 32,
+    X_ATTR_LIMIT_FLAGS_HI              = 63,
+
+#define O_ATTR_DO(F) \
+        F(X_ATTR_OVERFLOW,01) \
+          /*(end)*/
+#define X_ATTR_DO(F) \
+        O_ATTR_DO(F) \
+        F(X_ATTR_Signature,Signature) \
+        F(X_ATTR_Deprecated,Deprecated) \
+        F(X_ATTR_RuntimeVisibleAnnotations,RuntimeVisibleAnnotations) \
+        F(X_ATTR_RuntimeInvisibleAnnotations,RuntimeInvisibleAnnotations) \
+        F(X_ATTR_RuntimeVisibleTypeAnnotations,RuntimeVisibleTypeAnnotations) \
+        F(X_ATTR_RuntimeInvisibleTypeAnnotations,RuntimeInvisibleTypeAnnotations) \
+        /*F(X_ATTR_Synthetic,Synthetic)*/ \
+          /*(end)*/
+#define CLASS_ATTR_DO(F) \
+        F(CLASS_ATTR_SourceFile,SourceFile) \
+        F(CLASS_ATTR_InnerClasses,InnerClasses) \
+        F(CLASS_ATTR_EnclosingMethod,EnclosingMethod) \
+        F(CLASS_ATTR_ClassFile_version,02) \
+        F(CLASS_ATTR_BootstrapMethods,BootstrapMethods) \
+          /*(end)*/
+#define FIELD_ATTR_DO(F) \
+        F(FIELD_ATTR_ConstantValue,ConstantValue) \
+          /*(end)*/
+#define METHOD_ATTR_DO(F) \
+        F(METHOD_ATTR_Code,Code) \
+        F(METHOD_ATTR_Exceptions,Exceptions) \
+        F(METHOD_ATTR_RuntimeVisibleParameterAnnotations,RuntimeVisibleParameterAnnotations) \
+        F(METHOD_ATTR_RuntimeInvisibleParameterAnnotations,RuntimeInvisibleParameterAnnotations) \
+        F(METHOD_ATTR_AnnotationDefault,AnnotationDefault) \
+        F(METHOD_ATTR_MethodParameters,MethodParameters) \
+          /*(end)*/
+#define CODE_ATTR_DO(F) \
+        F(CODE_ATTR_StackMapTable,StackMapTable) \
+        F(CODE_ATTR_LineNumberTable,LineNumberTable) \
+        F(CODE_ATTR_LocalVariableTable,LocalVariableTable) \
+        F(CODE_ATTR_LocalVariableTypeTable,LocalVariableTypeTable) \
+          /*(end)*/
+#define ALL_ATTR_DO(F) \
+        X_ATTR_DO(F) \
+        CLASS_ATTR_DO(F) \
+        FIELD_ATTR_DO(F) \
+        METHOD_ATTR_DO(F) \
+        CODE_ATTR_DO(F) \
+          /*(end)*/
+
+    // attribute "context types"
+    ATTR_CONTEXT_CLASS  = 0,
+    ATTR_CONTEXT_FIELD  = 1,
+    ATTR_CONTEXT_METHOD = 2,
+    ATTR_CONTEXT_CODE   = 3,
+    ATTR_CONTEXT_LIMIT  = 4,
+
+    // constants for parsed layouts (stored in band::le_kind)
+    EK_NONE = 0,     // not a layout element
+    EK_INT  = 'I',   // B H I SH etc., also FH etc.
+    EK_BCI  = 'P',   // PH etc.
+    EK_BCID = 'Q',   // POH etc.
+    EK_BCO  = 'O',   // OH etc.
+    EK_REPL = 'N',   // NH[...] etc.
+    EK_REF  = 'R',   // RUH, RUNH, KQH, etc.
+    EK_UN   = 'T',   // TB(...)[...] etc.
+    EK_CASE = 'K',   // (...)[...] etc.
+    EK_CALL = '(',   // (0), (1), etc.
+    EK_CBLE = '[',   // [...][...] etc.
+    NO_BAND_INDEX = -1,
+
+    // File option bits, from LSB in ascending bit position.
+    FO_DEFLATE_HINT           = 1<<0,
+    FO_IS_CLASS_STUB          = 1<<1,
+
+    // Archive option bits, from LSB in ascending bit position:
+    AO_HAVE_SPECIAL_FORMATS   = 1<<0,
+    AO_HAVE_CP_NUMBERS        = 1<<1,
+    AO_HAVE_ALL_CODE_FLAGS    = 1<<2,
+    AO_HAVE_CP_EXTRAS         = 1<<3,
+    AO_HAVE_FILE_HEADERS      = 1<<4,
+    AO_DEFLATE_HINT           = 1<<5,
+    AO_HAVE_FILE_MODTIME      = 1<<6,
+    AO_HAVE_FILE_OPTIONS      = 1<<7,
+    AO_HAVE_FILE_SIZE_HI      = 1<<8,
+    AO_HAVE_CLASS_FLAGS_HI    = 1<<9,
+    AO_HAVE_FIELD_FLAGS_HI    = 1<<10,
+    AO_HAVE_METHOD_FLAGS_HI   = 1<<11,
+    AO_HAVE_CODE_FLAGS_HI     = 1<<12,
+    AO_UNUSED_MBZ             = (-1)<<13, // options bits reserved for future use.
+
+#define ARCHIVE_BIT_DO(F) \
+         F(AO_HAVE_SPECIAL_FORMATS) \
+         F(AO_HAVE_CP_NUMBERS) \
+         F(AO_HAVE_ALL_CODE_FLAGS) \
+         F(AO_HAVE_CP_EXTRAS) \
+         F(AO_HAVE_FILE_HEADERS) \
+         F(AO_DEFLATE_HINT) \
+         F(AO_HAVE_FILE_MODTIME) \
+         F(AO_HAVE_FILE_OPTIONS) \
+         F(AO_HAVE_FILE_SIZE_HI) \
+         F(AO_HAVE_CLASS_FLAGS_HI) \
+         F(AO_HAVE_FIELD_FLAGS_HI) \
+         F(AO_HAVE_METHOD_FLAGS_HI) \
+         F(AO_HAVE_CODE_FLAGS_HI) \
+          /*(end)*/
+
+    // Constants for decoding attribute definition header bytes.
+    ADH_CONTEXT_MASK   = 0x3,  // (hdr & ADH_CONTEXT_MASK)
+    ADH_BIT_SHIFT      = 0x2,  // (hdr >> ADH_BIT_SHIFT)
+    ADH_BIT_IS_LSB     = 1,    // (hdr >> ADH_BIT_SHIFT) - ADH_BIT_IS_LSB
+#define ADH_BYTE(context, index) \
+        ((((index) + ADH_BIT_IS_LSB)<<ADH_BIT_SHIFT) + (context))
+#define ADH_BYTE_CONTEXT(adhb) \
+        ((adhb) & ADH_CONTEXT_MASK)
+#define ADH_BYTE_INDEX(adhb) \
+        (((adhb) >> ADH_BIT_SHIFT) - ADH_BIT_IS_LSB)
+
+    NO_MODTIME = 0,  // null modtime value
+
+    // meta-coding
+    _meta_default   = 0,
+    _meta_canon_min = 1,
+    _meta_canon_max = 115,
+    _meta_arb       = 116,
+    _meta_run       = 117,
+    _meta_pop       = 141,
+    _meta_limit     = 189,
+    _meta_error     = 255,
+
+    _xxx_1_end
+};
+
+// Bytecodes.
+
+enum {
+  bc_nop                  =   0, // 0x00
+  bc_aconst_null          =   1, // 0x01
+  bc_iconst_m1            =   2, // 0x02
+  bc_iconst_0             =   3, // 0x03
+  bc_iconst_1             =   4, // 0x04
+  bc_iconst_2             =   5, // 0x05
+  bc_iconst_3             =   6, // 0x06
+  bc_iconst_4             =   7, // 0x07
+  bc_iconst_5             =   8, // 0x08
+  bc_lconst_0             =   9, // 0x09
+  bc_lconst_1             =  10, // 0x0a
+  bc_fconst_0             =  11, // 0x0b
+  bc_fconst_1             =  12, // 0x0c
+  bc_fconst_2             =  13, // 0x0d
+  bc_dconst_0             =  14, // 0x0e
+  bc_dconst_1             =  15, // 0x0f
+  bc_bipush               =  16, // 0x10
+  bc_sipush               =  17, // 0x11
+  bc_ldc                  =  18, // 0x12
+  bc_ldc_w                =  19, // 0x13
+  bc_ldc2_w               =  20, // 0x14
+  bc_iload                =  21, // 0x15
+  bc_lload                =  22, // 0x16
+  bc_fload                =  23, // 0x17
+  bc_dload                =  24, // 0x18
+  bc_aload                =  25, // 0x19
+  bc_iload_0              =  26, // 0x1a
+  bc_iload_1              =  27, // 0x1b
+  bc_iload_2              =  28, // 0x1c
+  bc_iload_3              =  29, // 0x1d
+  bc_lload_0              =  30, // 0x1e
+  bc_lload_1              =  31, // 0x1f
+  bc_lload_2              =  32, // 0x20
+  bc_lload_3              =  33, // 0x21
+  bc_fload_0              =  34, // 0x22
+  bc_fload_1              =  35, // 0x23
+  bc_fload_2              =  36, // 0x24
+  bc_fload_3              =  37, // 0x25
+  bc_dload_0              =  38, // 0x26
+  bc_dload_1              =  39, // 0x27
+  bc_dload_2              =  40, // 0x28
+  bc_dload_3              =  41, // 0x29
+  bc_aload_0              =  42, // 0x2a
+  bc_aload_1              =  43, // 0x2b
+  bc_aload_2              =  44, // 0x2c
+  bc_aload_3              =  45, // 0x2d
+  bc_iaload               =  46, // 0x2e
+  bc_laload               =  47, // 0x2f
+  bc_faload               =  48, // 0x30
+  bc_daload               =  49, // 0x31
+  bc_aaload               =  50, // 0x32
+  bc_baload               =  51, // 0x33
+  bc_caload               =  52, // 0x34
+  bc_saload               =  53, // 0x35
+  bc_istore               =  54, // 0x36
+  bc_lstore               =  55, // 0x37
+  bc_fstore               =  56, // 0x38
+  bc_dstore               =  57, // 0x39
+  bc_astore               =  58, // 0x3a
+  bc_istore_0             =  59, // 0x3b
+  bc_istore_1             =  60, // 0x3c
+  bc_istore_2             =  61, // 0x3d
+  bc_istore_3             =  62, // 0x3e
+  bc_lstore_0             =  63, // 0x3f
+  bc_lstore_1             =  64, // 0x40
+  bc_lstore_2             =  65, // 0x41
+  bc_lstore_3             =  66, // 0x42
+  bc_fstore_0             =  67, // 0x43
+  bc_fstore_1             =  68, // 0x44
+  bc_fstore_2             =  69, // 0x45
+  bc_fstore_3             =  70, // 0x46
+  bc_dstore_0             =  71, // 0x47
+  bc_dstore_1             =  72, // 0x48
+  bc_dstore_2             =  73, // 0x49
+  bc_dstore_3             =  74, // 0x4a
+  bc_astore_0             =  75, // 0x4b
+  bc_astore_1             =  76, // 0x4c
+  bc_astore_2             =  77, // 0x4d
+  bc_astore_3             =  78, // 0x4e
+  bc_iastore              =  79, // 0x4f
+  bc_lastore              =  80, // 0x50
+  bc_fastore              =  81, // 0x51
+  bc_dastore              =  82, // 0x52
+  bc_aastore              =  83, // 0x53
+  bc_bastore              =  84, // 0x54
+  bc_castore              =  85, // 0x55
+  bc_sastore              =  86, // 0x56
+  bc_pop                  =  87, // 0x57
+  bc_pop2                 =  88, // 0x58
+  bc_dup                  =  89, // 0x59
+  bc_dup_x1               =  90, // 0x5a
+  bc_dup_x2               =  91, // 0x5b
+  bc_dup2                 =  92, // 0x5c
+  bc_dup2_x1              =  93, // 0x5d
+  bc_dup2_x2              =  94, // 0x5e
+  bc_swap                 =  95, // 0x5f
+  bc_iadd                 =  96, // 0x60
+  bc_ladd                 =  97, // 0x61
+  bc_fadd                 =  98, // 0x62
+  bc_dadd                 =  99, // 0x63
+  bc_isub                 = 100, // 0x64
+  bc_lsub                 = 101, // 0x65
+  bc_fsub                 = 102, // 0x66
+  bc_dsub                 = 103, // 0x67
+  bc_imul                 = 104, // 0x68
+  bc_lmul                 = 105, // 0x69
+  bc_fmul                 = 106, // 0x6a
+  bc_dmul                 = 107, // 0x6b
+  bc_idiv                 = 108, // 0x6c
+  bc_ldiv                 = 109, // 0x6d
+  bc_fdiv                 = 110, // 0x6e
+  bc_ddiv                 = 111, // 0x6f
+  bc_irem                 = 112, // 0x70
+  bc_lrem                 = 113, // 0x71
+  bc_frem                 = 114, // 0x72
+  bc_drem                 = 115, // 0x73
+  bc_ineg                 = 116, // 0x74
+  bc_lneg                 = 117, // 0x75
+  bc_fneg                 = 118, // 0x76
+  bc_dneg                 = 119, // 0x77
+  bc_ishl                 = 120, // 0x78
+  bc_lshl                 = 121, // 0x79
+  bc_ishr                 = 122, // 0x7a
+  bc_lshr                 = 123, // 0x7b
+  bc_iushr                = 124, // 0x7c
+  bc_lushr                = 125, // 0x7d
+  bc_iand                 = 126, // 0x7e
+  bc_land                 = 127, // 0x7f
+  bc_ior                  = 128, // 0x80
+  bc_lor                  = 129, // 0x81
+  bc_ixor                 = 130, // 0x82
+  bc_lxor                 = 131, // 0x83
+  bc_iinc                 = 132, // 0x84
+  bc_i2l                  = 133, // 0x85
+  bc_i2f                  = 134, // 0x86
+  bc_i2d                  = 135, // 0x87
+  bc_l2i                  = 136, // 0x88
+  bc_l2f                  = 137, // 0x89
+  bc_l2d                  = 138, // 0x8a
+  bc_f2i                  = 139, // 0x8b
+  bc_f2l                  = 140, // 0x8c
+  bc_f2d                  = 141, // 0x8d
+  bc_d2i                  = 142, // 0x8e
+  bc_d2l                  = 143, // 0x8f
+  bc_d2f                  = 144, // 0x90
+  bc_i2b                  = 145, // 0x91
+  bc_i2c                  = 146, // 0x92
+  bc_i2s                  = 147, // 0x93
+  bc_lcmp                 = 148, // 0x94
+  bc_fcmpl                = 149, // 0x95
+  bc_fcmpg                = 150, // 0x96
+  bc_dcmpl                = 151, // 0x97
+  bc_dcmpg                = 152, // 0x98
+  bc_ifeq                 = 153, // 0x99
+  bc_ifne                 = 154, // 0x9a
+  bc_iflt                 = 155, // 0x9b
+  bc_ifge                 = 156, // 0x9c
+  bc_ifgt                 = 157, // 0x9d
+  bc_ifle                 = 158, // 0x9e
+  bc_if_icmpeq            = 159, // 0x9f
+  bc_if_icmpne            = 160, // 0xa0
+  bc_if_icmplt            = 161, // 0xa1
+  bc_if_icmpge            = 162, // 0xa2
+  bc_if_icmpgt            = 163, // 0xa3
+  bc_if_icmple            = 164, // 0xa4
+  bc_if_acmpeq            = 165, // 0xa5
+  bc_if_acmpne            = 166, // 0xa6
+  bc_goto                 = 167, // 0xa7
+  bc_jsr                  = 168, // 0xa8
+  bc_ret                  = 169, // 0xa9
+  bc_tableswitch          = 170, // 0xaa
+  bc_lookupswitch         = 171, // 0xab
+  bc_ireturn              = 172, // 0xac
+  bc_lreturn              = 173, // 0xad
+  bc_freturn              = 174, // 0xae
+  bc_dreturn              = 175, // 0xaf
+  bc_areturn              = 176, // 0xb0
+  bc_return               = 177, // 0xb1
+  bc_getstatic            = 178, // 0xb2
+  bc_putstatic            = 179, // 0xb3
+  bc_getfield             = 180, // 0xb4
+  bc_putfield             = 181, // 0xb5
+  bc_invokevirtual        = 182, // 0xb6
+  bc_invokespecial        = 183, // 0xb7
+  bc_invokestatic         = 184, // 0xb8
+  bc_invokeinterface      = 185, // 0xb9
+  bc_invokedynamic        = 186, // 0xba
+  bc_new                  = 187, // 0xbb
+  bc_newarray             = 188, // 0xbc
+  bc_anewarray            = 189, // 0xbd
+  bc_arraylength          = 190, // 0xbe
+  bc_athrow               = 191, // 0xbf
+  bc_checkcast            = 192, // 0xc0
+  bc_instanceof           = 193, // 0xc1
+  bc_monitorenter         = 194, // 0xc2
+  bc_monitorexit          = 195, // 0xc3
+  bc_wide                 = 196, // 0xc4
+  bc_multianewarray       = 197, // 0xc5
+  bc_ifnull               = 198, // 0xc6
+  bc_ifnonnull            = 199, // 0xc7
+  bc_goto_w               = 200, // 0xc8
+  bc_jsr_w                = 201, // 0xc9
+  bc_bytecode_limit       = 202  // 0xca
+};
+
+enum {
+  bc_end_marker = 255,
+  bc_byte_escape = 254,
+  bc_ref_escape = 253,
+
+  _first_linker_op = bc_getstatic,
+  _last_linker_op  = bc_invokestatic,
+  _num_linker_ops  = (_last_linker_op - _first_linker_op) + 1,
+  _self_linker_op  = bc_bytecode_limit,
+  _self_linker_aload_flag = 1*_num_linker_ops,
+  _self_linker_super_flag = 2*_num_linker_ops,
+  _self_linker_limit = _self_linker_op + 4*_num_linker_ops,
+
+  _invokeinit_op = _self_linker_limit,
+  _invokeinit_self_option = 0,
+  _invokeinit_super_option = 1,
+  _invokeinit_new_option = 2,
+  _invokeinit_limit = _invokeinit_op+3,
+
+  _xldc_op = _invokeinit_limit,
+  bc_sldc = bc_ldc,      // previously named bc_aldc
+  bc_cldc = _xldc_op+0,
+  bc_ildc = _xldc_op+1,
+  bc_fldc = _xldc_op+2,
+  bc_sldc_w = bc_ldc_w,  // previously named bc_aldc_w
+  bc_cldc_w = _xldc_op+3,
+  bc_ildc_w = _xldc_op+4,
+  bc_fldc_w = _xldc_op+5,
+  bc_lldc2_w = bc_ldc2_w,
+  bc_dldc2_w = _xldc_op+6,
+  // anything other primitive, string, or class must be handled with qldc:
+  bc_qldc    = _xldc_op+7,
+  bc_qldc_w  = _xldc_op+8,
+  _xldc_limit = _xldc_op+9,
+  _invoke_int_op = _xldc_limit,
+  _invokespecial_int = _invoke_int_op+0,
+  _invokestatic_int = _invoke_int_op+1,
+  _invoke_int_limit =  _invoke_int_op+2,
+  _xxx_3_end
+};
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/jdk/src/jdk.pack200/share/native/common-unpack/defines.h	Fri Mar 06 09:02:26 2015 -0800
@@ -0,0 +1,170 @@
+/*
+ * Copyright (c) 2001, 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.
+ */
+
+// random definitions
+
+#ifdef _MSC_VER
+#include <windows.h>
+#include <winuser.h>
+#else
+#include <unistd.h>
+#endif
+
+#ifndef NO_ZLIB
+#include <zconf.h>
+#endif
+
+#ifndef FULL
+#define FULL 1 /* Adds <500 bytes to the zipped final product. */
+#endif
+
+#if FULL  // define this if you want debugging and/or compile-time attributes
+#define IF_FULL(x) x
+#else
+#define IF_FULL(x) /*x*/
+#endif
+
+#ifdef PRODUCT
+#define IF_PRODUCT(xxx) xxx
+#define NOT_PRODUCT(xxx)
+#define assert(p)
+#define PRINTCR(args)
+#define VERSION_STRING "%s version %s\n"
+#else
+#define IF_PRODUCT(xxx)
+#define NOT_PRODUCT(xxx) xxx
+#define assert(p) ((p) || assert_failed(#p))
+#define PRINTCR(args)  u->verbose && u->printcr_if_verbose args
+#define VERSION_STRING "%s version non-product %s\n"
+extern "C" void breakpoint();
+extern int assert_failed(const char*);
+#define BREAK (breakpoint())
+#endif
+
+// Build-time control of some C++ inlining.
+// To make a slightly faster smaller binary, say "CC -Dmaybe_inline=inline"
+#ifndef maybe_inline
+#define maybe_inline /*inline*/
+#endif
+// By marking larger member functions inline, we remove external linkage.
+#ifndef local_inline
+#define local_inline inline
+#endif
+
+// Error messages that we have
+#define ERROR_ENOMEM    "Native allocation failed"
+#define ERROR_FORMAT    "Corrupted pack file"
+#define ERROR_RESOURCE  "Cannot extract resource file"
+#define ERROR_OVERFLOW  "Internal buffer overflow"
+#define ERROR_INTERNAL  "Internal error"
+#define ERROR_INIT      "cannot init class members"
+
+#define LOGFILE_STDOUT "-"
+#define LOGFILE_STDERR ""
+
+#define lengthof(array) (sizeof(array)/sizeof(array[0]))
+
+#define NEW(T, n)    (T*) must_malloc((int)(scale_size(n, sizeof(T))))
+#define U_NEW(T, n)  (T*) u->alloc(scale_size(n, sizeof(T)))
+#define T_NEW(T, n)  (T*) u->temp_alloc(scale_size(n, sizeof(T)))
+
+
+// bytes and byte arrays
+
+typedef unsigned int uint;
+#if defined(NO_ZLIB)
+#ifdef _LP64
+typedef unsigned int uLong; // Historical zlib, should be 32-bit.
+#else
+typedef unsigned long uLong;
+#endif
+#endif
+#ifdef _MSC_VER
+typedef LONGLONG        jlong;
+typedef DWORDLONG       julong;
+#define MKDIR(dir)      mkdir(dir)
+#define getpid()        _getpid()
+#define PATH_MAX        MAX_PATH
+#define dup2(a,b)       _dup2(a,b)
+#define strcasecmp(s1, s2) _stricmp(s1,s2)
+#define tempname        _tempname
+#define sleep           Sleep
+#define snprintf        _snprintf
+#else
+typedef signed char byte;
+#ifdef _LP64
+typedef long jlong;
+typedef long unsigned julong;
+#else
+typedef long long jlong;
+typedef long long unsigned julong;
+#endif
+#define MKDIR(dir) mkdir(dir, 0777);
+#endif
+
+#ifdef OLDCC
+typedef int bool;
+enum { false, true };
+#endif
+
+#define null (0)
+
+/* Must cast to void *, then size_t, then int. */
+#define ptrlowbits(x)  ((int)(size_t)(void*)(x))
+
+/* Back and forth from jlong to pointer */
+#define ptr2jlong(x)  ((jlong)(size_t)(void*)(x))
+#define jlong2ptr(x)  ((void*)(size_t)(x))
+
+// Keys used by Java:
+#define UNPACK_DEFLATE_HINT             "unpack.deflate.hint"
+
+#define COM_PREFIX                      "com.sun.java.util.jar.pack."
+#define UNPACK_MODIFICATION_TIME        COM_PREFIX"unpack.modification.time"
+#define DEBUG_VERBOSE                   COM_PREFIX"verbose"
+
+#define ZIP_ARCHIVE_MARKER_COMMENT      "PACK200"
+
+// The following are not known to the Java classes:
+#define UNPACK_LOG_FILE                 COM_PREFIX"unpack.log.file"
+#define UNPACK_REMOVE_PACKFILE          COM_PREFIX"unpack.remove.packfile"
+
+
+// Called from unpacker layers
+#define _CHECK_DO(t,x)          { if (t) {x;} }
+
+#define CHECK                   _CHECK_DO(aborting(), return)
+#define CHECK_(y)               _CHECK_DO(aborting(), return y)
+#define CHECK_0                 _CHECK_DO(aborting(), return 0)
+
+#define CHECK_COUNT(t)          if (t < 0){abort("bad value count");} CHECK
+
+#define STR_TRUE   "true"
+#define STR_FALSE  "false"
+
+#define STR_TF(x)  ((x) ?  STR_TRUE : STR_FALSE)
+#define BOOL_TF(x) (((x) != null && strcmp((x),STR_TRUE) == 0) ? true : false)
+
+#define DEFAULT_ARCHIVE_MODTIME 1060000000 // Aug 04, 2003 5:26 PM PDT
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/jdk/src/jdk.pack200/share/native/common-unpack/unpack.cpp	Fri Mar 06 09:02:26 2015 -0800
@@ -0,0 +1,5215 @@
+/*
+ * Copyright (c) 2001, 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.
+ */
+
+// -*- C++ -*-
+// Program for unpacking specially compressed Java packages.
+// John R. Rose
+
+/*
+ * When compiling for a 64bit LP64 system (longs and pointers being 64bits),
+ *    the printf format %ld is correct and use of %lld will cause warning
+ *    errors from some compilers (gcc/g++).
+ * _LP64 can be explicitly set (used on Linux).
+ * Should be checking for the Visual C++ since the _LP64 is set on the 64-bit
+ * systems but the correct format prefix for 64-bit integers is ll.
+ * Solaris compilers will define __sparcv9 or __x86_64 on 64bit compilations.
+ */
+#if !defined (_MSC_VER) && \
+    (defined(_LP64) || defined(__sparcv9) || defined(__x86_64))
+  #define LONG_LONG_FORMAT "%ld"
+  #define LONG_LONG_HEX_FORMAT "%lx"
+#else
+  #define LONG_LONG_FORMAT "%lld"
+  #define LONG_LONG_HEX_FORMAT "%016llx"
+#endif
+
+#include <sys/types.h>
+
+#include <stdio.h>
+#include <string.h>
+#include <stdlib.h>
+#include <stdarg.h>
+
+#include <limits.h>
+#include <time.h>
+
+
+
+
+#include "defines.h"
+#include "bytes.h"
+#include "utils.h"
+#include "coding.h"
+#include "bands.h"
+
+#include "constants.h"
+
+#include "zip.h"
+
+#include "unpack.h"
+
+
+// tags, in canonical order:
+static const byte TAGS_IN_ORDER[] = {
+  CONSTANT_Utf8,
+  CONSTANT_Integer,
+  CONSTANT_Float,
+  CONSTANT_Long,
+  CONSTANT_Double,
+  CONSTANT_String,
+  CONSTANT_Class,
+  CONSTANT_Signature,
+  CONSTANT_NameandType,
+  CONSTANT_Fieldref,
+  CONSTANT_Methodref,
+  CONSTANT_InterfaceMethodref,
+  // constants defined as of JDK 7
+  CONSTANT_MethodHandle,
+  CONSTANT_MethodType,
+  CONSTANT_BootstrapMethod,
+  CONSTANT_InvokeDynamic
+};
+#define N_TAGS_IN_ORDER (sizeof TAGS_IN_ORDER)
+
+#ifndef PRODUCT
+static const char* TAG_NAME[] = {
+  "*None",
+  "Utf8",
+  "*Unicode",
+  "Integer",
+  "Float",
+  "Long",
+  "Double",
+  "Class",
+  "String",
+  "Fieldref",
+  "Methodref",
+  "InterfaceMethodref",
+  "NameandType",
+  "*Signature",
+  "unused14",
+  "MethodHandle",
+  "MethodType",
+  "*BootstrapMethod",
+  "InvokeDynamic",
+  0
+};
+
+static const char* ATTR_CONTEXT_NAME[] = {  // match ATTR_CONTEXT_NAME, etc.
+  "class", "field", "method", "code"
+};
+
+#else
+
+#define ATTR_CONTEXT_NAME ((const char**)null)
+
+#endif
+
+// Note that REQUESTED_LDC comes first, then the normal REQUESTED,
+// in the regular constant pool.
+enum { REQUESTED_NONE = -1,
+       // The codes below REQUESTED_NONE are in constant pool output order,
+       // for the sake of outputEntry_cmp:
+       REQUESTED_LDC = -99, REQUESTED
+};
+
+#define NO_INORD ((uint)-1)
+
+struct entry {
+  byte tag;
+
+  #if 0
+  byte bits;
+  enum {
+    //EB_EXTRA = 1,
+    EB_SUPER = 2
+  };
+  #endif
+  unsigned short nrefs;  // pack w/ tag
+
+  int  outputIndex;
+  uint inord;   // &cp.entries[cp.tag_base[this->tag]+this->inord] == this
+
+  entry* *refs;
+
+  // put last to pack best
+  union {
+    bytes b;
+    int i;
+    jlong l;
+  } value;
+
+  void requestOutputIndex(cpool& cp, int req = REQUESTED);
+  int getOutputIndex() {
+    assert(outputIndex > REQUESTED_NONE);
+    return outputIndex;
+  }
+
+  entry* ref(int refnum) {
+    assert((uint)refnum < nrefs);
+    return refs[refnum];
+  }
+
+  const char* utf8String() {
+    assert(tagMatches(CONSTANT_Utf8));
+    assert(value.b.len == strlen((const char*)value.b.ptr));
+    return (const char*)value.b.ptr;
+  }
+
+  entry* className() {
+    assert(tagMatches(CONSTANT_Class));
+    return ref(0);
+  }
+
+  entry* memberClass() {
+    assert(tagMatches(CONSTANT_AnyMember));
+    return ref(0);
+  }
+
+  entry* memberDescr() {
+    assert(tagMatches(CONSTANT_AnyMember));
+    return ref(1);
+  }
+
+  entry* descrName() {
+    assert(tagMatches(CONSTANT_NameandType));
+    return ref(0);
+  }
+
+  entry* descrType() {
+    assert(tagMatches(CONSTANT_NameandType));
+    return ref(1);
+  }
+
+  int typeSize();
+
+  bytes& asUtf8();
+  int    asInteger() { assert(tag == CONSTANT_Integer); return value.i; }
+
+  bool isUtf8(bytes& b) { return tagMatches(CONSTANT_Utf8) && value.b.equals(b); }
+
+  bool isDoubleWord() { return tag == CONSTANT_Double || tag == CONSTANT_Long; }
+
+  bool tagMatches(byte tag2) {
+    return (tag2 == tag)
+      || (tag2 == CONSTANT_Utf8 && tag == CONSTANT_Signature)
+      #ifndef PRODUCT
+      || (tag2 == CONSTANT_FieldSpecific
+          && tag >= CONSTANT_Integer && tag <= CONSTANT_String && tag != CONSTANT_Class)
+      || (tag2 == CONSTANT_AnyMember
+          && tag >= CONSTANT_Fieldref && tag <= CONSTANT_InterfaceMethodref)
+      #endif
+      ;
+  }
+
+#ifdef PRODUCT
+  char* string() { return 0; }
+#else
+  char* string();  // see far below
+#endif
+};
+
+entry* cpindex::get(uint i) {
+  if (i >= len)
+    return null;
+  else if (base1 != null)
+    // primary index
+    return &base1[i];
+  else
+    // secondary index
+    return base2[i];
+}
+
+inline bytes& entry::asUtf8() {
+  assert(tagMatches(CONSTANT_Utf8));
+  return value.b;
+}
+
+int entry::typeSize() {
+  assert(tagMatches(CONSTANT_Utf8));
+  const char* sigp = (char*) value.b.ptr;
+  switch (*sigp) {
+  case '(': sigp++; break;  // skip opening '('
+  case 'D':
+  case 'J': return 2; // double field
+  default:  return 1; // field
+  }
+  int siglen = 0;
+  for (;;) {
+    int ch = *sigp++;
+    switch (ch) {
+    case 'D': case 'J':
+      siglen += 1;
+      break;
+    case '[':
+      // Skip rest of array info.
+      while (ch == '[') { ch = *sigp++; }
+      if (ch != 'L')  break;
+      // else fall through
+    case 'L':
+      sigp = strchr(sigp, ';');
+      if (sigp == null) {
+          unpack_abort("bad data");
+          return 0;
+      }
+      sigp += 1;
+      break;
+    case ')':  // closing ')'
+      return siglen;
+    }
+    siglen += 1;
+  }
+}
+
+inline cpindex* cpool::getFieldIndex(entry* classRef) {
+  if (classRef == NULL) { abort("missing class reference"); return NULL; }
+  assert(classRef->tagMatches(CONSTANT_Class));
+  assert((uint)classRef->inord < (uint)tag_count[CONSTANT_Class]);
+  return &member_indexes[classRef->inord*2+0];
+}
+inline cpindex* cpool::getMethodIndex(entry* classRef) {
+  if (classRef == NULL) { abort("missing class reference"); return NULL; }
+  assert(classRef->tagMatches(CONSTANT_Class));
+  assert((uint)classRef->inord < (uint)tag_count[CONSTANT_Class]);
+  return &member_indexes[classRef->inord*2+1];
+}
+
+struct inner_class {
+  entry* inner;
+  entry* outer;
+  entry* name;
+  int    flags;
+  inner_class* next_sibling;
+  bool   requested;
+};
+
+// Here is where everything gets deallocated:
+void unpacker::free() {
+  int i;
+  assert(jniobj == null); // caller resp.
+  assert(infileptr == null);  // caller resp.
+  if (jarout != null)  jarout->reset();
+  if (gzin != null)    { gzin->free(); gzin = null; }
+  if (free_input)  input.free();
+  // free everybody ever allocated with U_NEW or (recently) with T_NEW
+  assert(smallbuf.base()  == null || mallocs.contains(smallbuf.base()));
+  assert(tsmallbuf.base() == null || tmallocs.contains(tsmallbuf.base()));
+  mallocs.freeAll();
+  tmallocs.freeAll();
+  smallbuf.init();
+  tsmallbuf.init();
+  bcimap.free();
+  class_fixup_type.free();
+  class_fixup_offset.free();
+  class_fixup_ref.free();
+  code_fixup_type.free();
+  code_fixup_offset.free();
+  code_fixup_source.free();
+  requested_ics.free();
+  cp.requested_bsms.free();
+  cur_classfile_head.free();
+  cur_classfile_tail.free();
+  for (i = 0; i < ATTR_CONTEXT_LIMIT; i++)
+    attr_defs[i].free();
+
+  // free CP state
+  cp.outputEntries.free();
+  for (i = 0; i < CONSTANT_Limit; i++)
+    cp.tag_extras[i].free();
+}
+
+// input handling
+// Attempts to advance rplimit so that (rplimit-rp) is at least 'more'.
+// Will eagerly read ahead by larger chunks, if possible.
+// Returns false if (rplimit-rp) is not at least 'more',
+// unless rplimit hits input.limit().
+bool unpacker::ensure_input(jlong more) {
+  julong want = more - input_remaining();
+  if ((jlong)want <= 0)          return true;  // it's already in the buffer
+  if (rplimit == input.limit())  return true;  // not expecting any more
+
+  if (read_input_fn == null) {
+    // assume it is already all there
+    bytes_read += input.limit() - rplimit;
+    rplimit = input.limit();
+    return true;
+  }
+  CHECK_0;
+
+  julong remaining = (input.limit() - rplimit);  // how much left to read?
+  byte* rpgoal = (want >= remaining)? input.limit(): rplimit + (size_t)want;
+  enum { CHUNK_SIZE = (1<<14) };
+  julong fetch = want;
+  if (fetch < CHUNK_SIZE)
+    fetch = CHUNK_SIZE;
+  if (fetch > remaining*3/4)
+    fetch = remaining;
+  // Try to fetch at least "more" bytes.
+  while ((jlong)fetch > 0) {
+    jlong nr = (*read_input_fn)(this, rplimit, fetch, remaining);
+    if (nr <= 0) {
+      return (rplimit >= rpgoal);
+    }
+    remaining -= nr;
+    rplimit += nr;
+    fetch -= nr;
+    bytes_read += nr;
+    assert(remaining == (julong)(input.limit() - rplimit));
+  }
+  return true;
+}
+
+// output handling
+
+fillbytes* unpacker::close_output(fillbytes* which) {
+  assert(wp != null);
+  if (which == null) {
+    if (wpbase == cur_classfile_head.base()) {
+      which = &cur_classfile_head;
+    } else {
+      which = &cur_classfile_tail;
+    }
+  }
+  assert(wpbase  == which->base());
+  assert(wplimit == which->end());
+  which->setLimit(wp);
+  wp      = null;
+  wplimit = null;
+  //wpbase = null;
+  return which;
+}
+
+//maybe_inline
+void unpacker::ensure_put_space(size_t size) {
+  if (wp + size <= wplimit)  return;
+  // Determine which segment needs expanding.
+  fillbytes* which = close_output();
+  byte* wp0 = which->grow(size);
+  wpbase  = which->base();
+  wplimit = which->end();
+  wp = wp0;
+}
+
+maybe_inline
+byte* unpacker::put_space(size_t size) {
+  byte* wp0 = wp;
+  byte* wp1 = wp0 + size;
+  if (wp1 > wplimit) {
+    ensure_put_space(size);
+    wp0 = wp;
+    wp1 = wp0 + size;
+  }
+  wp = wp1;
+  return wp0;
+}
+
+maybe_inline
+void unpacker::putu2_at(byte* wp, int n) {
+  if (n != (unsigned short)n) {
+    unpack_abort(ERROR_OVERFLOW);
+    return;
+  }
+  wp[0] = (n) >> 8;
+  wp[1] = (n) >> 0;
+}
+
+maybe_inline
+void unpacker::putu4_at(byte* wp, int n) {
+  wp[0] = (n) >> 24;
+  wp[1] = (n) >> 16;
+  wp[2] = (n) >> 8;
+  wp[3] = (n) >> 0;
+}
+
+maybe_inline
+void unpacker::putu8_at(byte* wp, jlong n) {
+  putu4_at(wp+0, (int)((julong)n >> 32));
+  putu4_at(wp+4, (int)((julong)n >> 0));
+}
+
+maybe_inline
+void unpacker::putu2(int n) {
+  putu2_at(put_space(2), n);
+}
+
+maybe_inline
+void unpacker::putu4(int n) {
+  putu4_at(put_space(4), n);
+}
+
+maybe_inline
+void unpacker::putu8(jlong n) {
+  putu8_at(put_space(8), n);
+}
+
+maybe_inline
+int unpacker::putref_index(entry* e, int size) {
+  if (e == null)
+    return 0;
+  else if (e->outputIndex > REQUESTED_NONE)
+    return e->outputIndex;
+  else if (e->tag == CONSTANT_Signature)
+    return putref_index(e->ref(0), size);
+  else {
+    e->requestOutputIndex(cp, (size == 1 ? REQUESTED_LDC : REQUESTED));
+    // Later on we'll fix the bits.
+    class_fixup_type.addByte(size);
+    class_fixup_offset.add((int)wpoffset());
+    class_fixup_ref.add(e);
+#ifdef PRODUCT
+    return 0;
+#else
+    return 0x20+size;  // 0x22 is easy to eyeball
+#endif
+  }
+}
+
+maybe_inline
+void unpacker::putref(entry* e) {
+  int oidx = putref_index(e, 2);
+  putu2_at(put_space(2), oidx);
+}
+
+maybe_inline
+void unpacker::putu1ref(entry* e) {
+  int oidx = putref_index(e, 1);
+  putu1_at(put_space(1), oidx);
+}
+
+
+static int total_cp_size[] = {0, 0};
+static int largest_cp_ref[] = {0, 0};
+static int hash_probes[] = {0, 0};
+
+// Allocation of small and large blocks.
+
+enum { CHUNK = (1 << 14), SMALL = (1 << 9) };
+
+// Call malloc.  Try to combine small blocks and free much later.
+void* unpacker::alloc_heap(size_t size, bool smallOK, bool temp) {
+  if (!smallOK || size > SMALL) {
+    void* res = must_malloc((int)size);
+    (temp ? &tmallocs : &mallocs)->add(res);
+    return res;
+  }
+  fillbytes& xsmallbuf = *(temp ? &tsmallbuf : &smallbuf);
+  if (!xsmallbuf.canAppend(size+1)) {
+    xsmallbuf.init(CHUNK);
+    (temp ? &tmallocs : &mallocs)->add(xsmallbuf.base());
+  }
+  int growBy = (int)size;
+  growBy += -growBy & 7;  // round up mod 8
+  return xsmallbuf.grow(growBy);
+}
+
+maybe_inline
+void unpacker::saveTo(bytes& b, byte* ptr, size_t len) {
+  b.ptr = U_NEW(byte, add_size(len,1));
+  if (aborting()) {
+    b.len = 0;
+    return;
+  }
+  b.len = len;
+  b.copyFrom(ptr, len);
+}
+
+bool testBit(int archive_options, int bitMask) {
+    return (archive_options & bitMask) != 0;
+}
+
+// Read up through band_headers.
+// Do the archive_size dance to set the size of the input mega-buffer.
+void unpacker::read_file_header() {
+  // Read file header to determine file type and total size.
+  enum {
+    MAGIC_BYTES = 4,
+    AH_LENGTH_0 = 3,  // archive_header_0 = {minver, majver, options}
+    AH_LENGTH_MIN = 15, // observed in spec {header_0[3], cp_counts[8], class_counts[4]}
+    AH_LENGTH_0_MAX = AH_LENGTH_0 + 1,  // options might have 2 bytes
+    AH_LENGTH   = 30, //maximum archive header length (w/ all fields)
+    // Length contributions from optional header fields:
+    AH_LENGTH_S = 2, // archive_header_S = optional {size_hi, size_lo}
+    AH_ARCHIVE_SIZE_HI = 0, // offset in archive_header_S
+    AH_ARCHIVE_SIZE_LO = 1, // offset in archive_header_S
+    AH_FILE_HEADER_LEN = 5, // file_counts = {{size_hi, size_lo), next, modtile, files}
+    AH_SPECIAL_FORMAT_LEN = 2, // special_count = {layouts, band_headers}
+    AH_CP_NUMBER_LEN = 4,      // cp_number_counts = {int, float, long, double}
+    AH_CP_EXTRA_LEN = 4,        // cp_attr_counts = {MH, MT, InDy, BSM}
+    ARCHIVE_SIZE_MIN = AH_LENGTH_MIN - AH_LENGTH_0 - AH_LENGTH_S,
+    FIRST_READ  = MAGIC_BYTES + AH_LENGTH_MIN
+  };
+
+  assert(AH_LENGTH_MIN    == 15); // # of UNSIGNED5 fields required after archive_magic
+  // An absolute minimum null archive is magic[4], {minver,majver,options}[3],
+  // archive_size[0], cp_counts[8], class_counts[4], for a total of 19 bytes.
+  // (Note that archive_size is optional; it may be 0..10 bytes in length.)
+  // The first read must capture everything up through the options field.
+  // This happens to work even if {minver,majver,options} is a pathological
+  // 15 bytes long.  Legal pack files limit those three fields to 1+1+2 bytes.
+  assert(FIRST_READ >= MAGIC_BYTES + AH_LENGTH_0 * B_MAX);
+
+  // Up through archive_size, the largest possible archive header is
+  // magic[4], {minver,majver,options}[4], archive_size[10].
+  // (Note only the low 12 bits of options are allowed to be non-zero.)
+  // In order to parse archive_size, we need at least this many bytes
+  // in the first read.  Of course, if archive_size_hi is more than
+  // a byte, we probably will fail to allocate the buffer, since it
+  // will be many gigabytes long.  This is a practical, not an
+  // architectural limit to Pack200 archive sizes.
+  assert(FIRST_READ >= MAGIC_BYTES + AH_LENGTH_0_MAX + 2*B_MAX);
+
+  bool foreign_buf = (read_input_fn == null);
+  byte initbuf[(int)FIRST_READ + (int)C_SLOP + 200];  // 200 is for JAR I/O
+  if (foreign_buf) {
+    // inbytes is all there is
+    input.set(inbytes);
+    rp      = input.base();
+    rplimit = input.limit();
+  } else {
+    // inbytes, if not empty, contains some read-ahead we must use first
+    // ensure_input will take care of copying it into initbuf,
+    // then querying read_input_fn for any additional data needed.
+    // However, the caller must assume that we use up all of inbytes.
+    // There is no way to tell the caller that we used only part of them.
+    // Therefore, the caller must use only a bare minimum of read-ahead.
+    if (inbytes.len > FIRST_READ) {
+      abort("too much read-ahead");
+      return;
+    }
+    input.set(initbuf, sizeof(initbuf));
+    input.b.clear();
+    input.b.copyFrom(inbytes);
+    rplimit = rp = input.base();
+    rplimit += inbytes.len;
+    bytes_read += inbytes.len;
+  }
+  // Read only 19 bytes, which is certain to contain #archive_options fields,
+  // but is certain not to overflow past the archive_header.
+  input.b.len = FIRST_READ;
+  if (!ensure_input(FIRST_READ))
+    abort("EOF reading archive magic number");
+
+  if (rp[0] == 'P' && rp[1] == 'K') {
+#ifdef UNPACK_JNI
+    // Java driver must handle this case before we get this far.
+    abort("encountered a JAR header in unpacker");
+#else
+    // In the Unix-style program, we simply simulate a copy command.
+    // Copy until EOF; assume the JAR file is the last segment.
+    fprintf(errstrm, "Copy-mode.\n");
+    for (;;) {
+      jarout->write_data(rp, (int)input_remaining());
+      if (foreign_buf)
+        break;  // one-time use of a passed in buffer
+      if (input.size() < CHUNK) {
+        // Get some breathing room.
+        input.set(U_NEW(byte, (size_t) CHUNK + C_SLOP), (size_t) CHUNK);
+        CHECK;
+      }
+      rp = rplimit = input.base();
+      if (!ensure_input(1))
+        break;
+    }
+    jarout->closeJarFile(false);
+#endif
+    return;
+  }
+
+  // Read the magic number.
+  magic = 0;
+  for (int i1 = 0; i1 < (int)sizeof(magic); i1++) {
+    magic <<= 8;
+    magic += (*rp++ & 0xFF);
+  }
+
+  // Read the first 3 values from the header.
+  value_stream hdr;
+  int          hdrVals = 0;
+  int          hdrValsSkipped = 0;  // for assert
+  hdr.init(rp, rplimit, UNSIGNED5_spec);
+  minver = hdr.getInt();
+  majver = hdr.getInt();
+  hdrVals += 2;
+
+  int majmin[4][2] = {
+      {JAVA5_PACKAGE_MAJOR_VERSION, JAVA5_PACKAGE_MINOR_VERSION},
+      {JAVA6_PACKAGE_MAJOR_VERSION, JAVA6_PACKAGE_MINOR_VERSION},
+      {JAVA7_PACKAGE_MAJOR_VERSION, JAVA7_PACKAGE_MINOR_VERSION},
+      {JAVA8_PACKAGE_MAJOR_VERSION, JAVA8_PACKAGE_MINOR_VERSION}
+  };
+  int majminfound = false;
+  for (int i = 0 ; i < 4 ; i++) {
+      if (majver == majmin[i][0] && minver == majmin[i][1]) {
+          majminfound = true;
+          break;
+      }
+  }
+  if (majminfound == null) {
+    char message[200];
+    sprintf(message, "@" ERROR_FORMAT ": magic/ver = "
+            "%08X/%d.%d should be %08X/%d.%d OR %08X/%d.%d OR %08X/%d.%d OR %08X/%d.%d\n",
+            magic, majver, minver,
+            JAVA_PACKAGE_MAGIC, JAVA5_PACKAGE_MAJOR_VERSION, JAVA5_PACKAGE_MINOR_VERSION,
+            JAVA_PACKAGE_MAGIC, JAVA6_PACKAGE_MAJOR_VERSION, JAVA6_PACKAGE_MINOR_VERSION,
+            JAVA_PACKAGE_MAGIC, JAVA7_PACKAGE_MAJOR_VERSION, JAVA7_PACKAGE_MINOR_VERSION,
+            JAVA_PACKAGE_MAGIC, JAVA8_PACKAGE_MAJOR_VERSION, JAVA8_PACKAGE_MINOR_VERSION);
+    abort(message);
+  }
+  CHECK;
+
+  archive_options = hdr.getInt();
+  hdrVals += 1;
+  assert(hdrVals == AH_LENGTH_0);  // first three fields only
+  bool haveSizeHi = testBit(archive_options, AO_HAVE_FILE_SIZE_HI);
+  bool haveModTime = testBit(archive_options, AO_HAVE_FILE_MODTIME);
+  bool haveFileOpt = testBit(archive_options, AO_HAVE_FILE_OPTIONS);
+
+  bool haveSpecial = testBit(archive_options, AO_HAVE_SPECIAL_FORMATS);
+  bool haveFiles = testBit(archive_options, AO_HAVE_FILE_HEADERS);
+  bool haveNumbers = testBit(archive_options, AO_HAVE_CP_NUMBERS);
+  bool haveCPExtra = testBit(archive_options, AO_HAVE_CP_EXTRAS);
+
+  if (majver < JAVA7_PACKAGE_MAJOR_VERSION) {
+    if (haveCPExtra) {
+        abort("Format bits for Java 7 must be zero in previous releases");
+        return;
+    }
+  }
+  if (testBit(archive_options, AO_UNUSED_MBZ)) {
+    abort("High archive option bits are reserved and must be zero");
+    return;
+  }
+  if (haveFiles) {
+    uint hi = hdr.getInt();
+    uint lo = hdr.getInt();
+    julong x = band::makeLong(hi, lo);
+    archive_size = (size_t) x;
+    if (archive_size != x) {
+      // Silly size specified; force overflow.
+      archive_size = PSIZE_MAX+1;
+    }
+    hdrVals += 2;
+  } else {
+    hdrValsSkipped += 2;
+  }
+
+  // Now we can size the whole archive.
+  // Read everything else into a mega-buffer.
+  rp = hdr.rp;
+  int header_size_0 = (int)(rp - input.base()); // used-up header (4byte + 3int)
+  int header_size_1 = (int)(rplimit - rp);      // buffered unused initial fragment
+  int header_size   = header_size_0+header_size_1;
+  unsized_bytes_read = header_size_0;
+  CHECK;
+  if (foreign_buf) {
+    if (archive_size > (size_t)header_size_1) {
+      abort("EOF reading fixed input buffer");
+      return;
+    }
+  } else if (archive_size != 0) {
+    if (archive_size < ARCHIVE_SIZE_MIN) {
+      abort("impossible archive size");  // bad input data
+      return;
+    }
+    if (archive_size < header_size_1) {
+      abort("too much read-ahead");  // somehow we pre-fetched too much?
+      return;
+    }
+    input.set(U_NEW(byte, add_size(header_size_0, archive_size, C_SLOP)),
+              (size_t) header_size_0 + archive_size);
+    CHECK;
+    assert(input.limit()[0] == 0);
+    // Move all the bytes we read initially into the real buffer.
+    input.b.copyFrom(initbuf, header_size);
+    rp      = input.b.ptr + header_size_0;
+    rplimit = input.b.ptr + header_size;
+  } else {
+    // It's more complicated and painful.
+    // A zero archive_size means that we must read until EOF.
+    input.init(CHUNK*2);
+    CHECK;
+    input.b.len = input.allocated;
+    rp = rplimit = input.base();
+    // Set up input buffer as if we already read the header:
+    input.b.copyFrom(initbuf, header_size);
+    CHECK;
+    rplimit += header_size;
+    while (ensure_input(input.limit() - rp)) {
+      size_t dataSoFar = input_remaining();
+      size_t nextSize = add_size(dataSoFar, CHUNK);
+      input.ensureSize(nextSize);
+      CHECK;
+      input.b.len = input.allocated;
+      rp = rplimit = input.base();
+      rplimit += dataSoFar;
+    }
+    size_t dataSize = (rplimit - input.base());
+    input.b.len = dataSize;
+    input.grow(C_SLOP);
+    CHECK;
+    free_input = true;  // free it later
+    input.b.len = dataSize;
+    assert(input.limit()[0] == 0);
+    rp = rplimit = input.base();
+    rplimit += dataSize;
+    rp += header_size_0;  // already scanned these bytes...
+  }
+  live_input = true;    // mark as "do not reuse"
+  if (aborting()) {
+    abort("cannot allocate large input buffer for package file");
+    return;
+  }
+
+  // read the rest of the header fields  int assertSkipped = AH_LENGTH_MIN - AH_LENGTH_0 - AH_LENGTH_S;
+  int remainingHeaders = AH_LENGTH_MIN - AH_LENGTH_0 - AH_LENGTH_S;
+  if (haveSpecial)
+    remainingHeaders += AH_SPECIAL_FORMAT_LEN;
+  if (haveFiles)
+     remainingHeaders += AH_FILE_HEADER_LEN;
+  if (haveNumbers)
+    remainingHeaders += AH_CP_NUMBER_LEN;
+  if (haveCPExtra)
+    remainingHeaders += AH_CP_EXTRA_LEN;
+
+  ensure_input(remainingHeaders * B_MAX);
+  CHECK;
+  hdr.rp      = rp;
+  hdr.rplimit = rplimit;
+
+  if (haveFiles) {
+    archive_next_count = hdr.getInt();
+    CHECK_COUNT(archive_next_count);
+    archive_modtime = hdr.getInt();
+    file_count = hdr.getInt();
+    CHECK_COUNT(file_count);
+    hdrVals += 3;
+  } else {
+    hdrValsSkipped += 3;
+  }
+
+  if (haveSpecial) {
+    band_headers_size = hdr.getInt();
+    CHECK_COUNT(band_headers_size);
+    attr_definition_count = hdr.getInt();
+    CHECK_COUNT(attr_definition_count);
+    hdrVals += 2;
+  } else {
+    hdrValsSkipped += 2;
+  }
+
+  int cp_counts[N_TAGS_IN_ORDER];
+  for (int k = 0; k < (int)N_TAGS_IN_ORDER; k++) {
+    if (!haveNumbers) {
+      switch (TAGS_IN_ORDER[k]) {
+      case CONSTANT_Integer:
+      case CONSTANT_Float:
+      case CONSTANT_Long:
+      case CONSTANT_Double:
+        cp_counts[k] = 0;
+        hdrValsSkipped += 1;
+        continue;
+      }
+    }
+    if (!haveCPExtra) {
+        switch(TAGS_IN_ORDER[k]) {
+        case CONSTANT_MethodHandle:
+        case CONSTANT_MethodType:
+        case CONSTANT_InvokeDynamic:
+        case CONSTANT_BootstrapMethod:
+          cp_counts[k] = 0;
+          hdrValsSkipped += 1;
+          continue;
+        }
+    }
+    cp_counts[k] = hdr.getInt();
+    CHECK_COUNT(cp_counts[k]);
+    hdrVals += 1;
+  }
+
+  ic_count = hdr.getInt();
+  CHECK_COUNT(ic_count);
+  default_class_minver = hdr.getInt();
+  default_class_majver = hdr.getInt();
+  class_count = hdr.getInt();
+  CHECK_COUNT(class_count);
+  hdrVals += 4;
+
+  // done with archive_header, time to reconcile to ensure
+  // we have read everything correctly
+  hdrVals += hdrValsSkipped;
+  assert(hdrVals == AH_LENGTH);
+  rp = hdr.rp;
+  if (rp > rplimit)
+    abort("EOF reading archive header");
+
+  // Now size the CP.
+#ifndef PRODUCT
+  // bool x = (N_TAGS_IN_ORDER == CONSTANT_Limit);
+  // assert(x);
+#endif //PRODUCT
+  cp.init(this, cp_counts);
+  CHECK;
+
+  default_file_modtime = archive_modtime;
+  if (default_file_modtime == 0 && haveModTime)
+    default_file_modtime = DEFAULT_ARCHIVE_MODTIME;  // taken from driver
+  if (testBit(archive_options, AO_DEFLATE_HINT))
+    default_file_options |= FO_DEFLATE_HINT;
+
+  // meta-bytes, if any, immediately follow archive header
+  //band_headers.readData(band_headers_size);
+  ensure_input(band_headers_size);
+  if (input_remaining() < (size_t)band_headers_size) {
+    abort("EOF reading band headers");
+    return;
+  }
+  bytes band_headers;
+  // The "1+" allows an initial byte to be pushed on the front.
+  band_headers.set(1+U_NEW(byte, 1+band_headers_size+C_SLOP),
+                   band_headers_size);
+  CHECK;
+  // Start scanning band headers here:
+  band_headers.copyFrom(rp, band_headers.len);
+  rp += band_headers.len;
+  assert(rp <= rplimit);
+  meta_rp = band_headers.ptr;
+  // Put evil meta-codes at the end of the band headers,
+  // so we are sure to throw an error if we run off the end.
+  bytes::of(band_headers.limit(), C_SLOP).clear(_meta_error);
+}
+
+void unpacker::finish() {
+  if (verbose >= 1) {
+    fprintf(errstrm,
+            "A total of "
+            LONG_LONG_FORMAT " bytes were read in %d segment(s).\n",
+            (bytes_read_before_reset+bytes_read),
+            segments_read_before_reset+1);
+    fprintf(errstrm,
+            "A total of "
+            LONG_LONG_FORMAT " file content bytes were written.\n",
+            (bytes_written_before_reset+bytes_written));
+    fprintf(errstrm,
+            "A total of %d files (of which %d are classes) were written to output.\n",
+            files_written_before_reset+files_written,
+            classes_written_before_reset+classes_written);
+  }
+  if (jarout != null)
+    jarout->closeJarFile(true);
+  if (errstrm != null) {
+    if (errstrm == stdout || errstrm == stderr) {
+      fflush(errstrm);
+    } else {
+      fclose(errstrm);
+    }
+    errstrm = null;
+    errstrm_name = null;
+  }
+}
+
+
+// Cf. PackageReader.readConstantPoolCounts
+void cpool::init(unpacker* u_, int counts[CONSTANT_Limit]) {
+  this->u = u_;
+
+  // Fill-pointer for CP.
+  int next_entry = 0;
+
+  // Size the constant pool:
+  for (int k = 0; k < (int)N_TAGS_IN_ORDER; k++) {
+    byte tag = TAGS_IN_ORDER[k];
+    int  len = counts[k];
+    tag_count[tag] = len;
+    tag_base[tag] = next_entry;
+    next_entry += len;
+    // Detect and defend against constant pool size overflow.
+    // (Pack200 forbids the sum of CP counts to exceed 2^29-1.)
+    enum {
+      CP_SIZE_LIMIT = (1<<29),
+      IMPLICIT_ENTRY_COUNT = 1  // empty Utf8 string
+    };
+    if (len >= (1<<29) || len < 0
+        || next_entry >= CP_SIZE_LIMIT+IMPLICIT_ENTRY_COUNT) {
+      abort("archive too large:  constant pool limit exceeded");
+      return;
+    }
+  }
+
+  // Close off the end of the CP:
+  nentries = next_entry;
+
+  // place a limit on future CP growth:
+  int generous = 0;
+  generous = add_size(generous, u->ic_count); // implicit name
+  generous = add_size(generous, u->ic_count); // outer
+  generous = add_size(generous, u->ic_count); // outer.utf8
+  generous = add_size(generous, 40); // WKUs, misc
+  generous = add_size(generous, u->class_count); // implicit SourceFile strings
+  maxentries = add_size(nentries, generous);
+
+  // Note that this CP does not include "empty" entries
+  // for longs and doubles.  Those are introduced when
+  // the entries are renumbered for classfile output.
+
+  entries = U_NEW(entry, maxentries);
+  CHECK;
+
+  first_extra_entry = &entries[nentries];
+
+  // Initialize the standard indexes.
+  for (int tag = 0; tag < CONSTANT_Limit; tag++) {
+    entry* cpMap = &entries[tag_base[tag]];
+    tag_index[tag].init(tag_count[tag], cpMap, tag);
+  }
+
+  // Initialize *all* our entries once
+  for (int i = 0 ; i < maxentries ; i++)
+    entries[i].outputIndex = REQUESTED_NONE;
+
+  initGroupIndexes();
+  // Initialize hashTab to a generous power-of-two size.
+  uint pow2 = 1;
+  uint target = maxentries + maxentries/2;  // 60% full
+  while (pow2 < target)  pow2 <<= 1;
+  hashTab = U_NEW(entry*, hashTabLength = pow2);
+}
+
+static byte* store_Utf8_char(byte* cp, unsigned short ch) {
+  if (ch >= 0x001 && ch <= 0x007F) {
+    *cp++ = (byte) ch;
+  } else if (ch <= 0x07FF) {
+    *cp++ = (byte) (0xC0 | ((ch >>  6) & 0x1F));
+    *cp++ = (byte) (0x80 | ((ch >>  0) & 0x3F));
+  } else {
+    *cp++ = (byte) (0xE0 | ((ch >> 12) & 0x0F));
+    *cp++ = (byte) (0x80 | ((ch >>  6) & 0x3F));
+    *cp++ = (byte) (0x80 | ((ch >>  0) & 0x3F));
+  }
+  return cp;
+}
+
+static byte* skip_Utf8_chars(byte* cp, int len) {
+  for (;; cp++) {
+    int ch = *cp & 0xFF;
+    if ((ch & 0xC0) != 0x80) {
+      if (len-- == 0)
+        return cp;
+      if (ch < 0x80 && len == 0)
+        return cp+1;
+    }
+  }
+}
+
+static int compare_Utf8_chars(bytes& b1, bytes& b2) {
+  int l1 = (int)b1.len;
+  int l2 = (int)b2.len;
+  int l0 = (l1 < l2) ? l1 : l2;
+  byte* p1 = b1.ptr;
+  byte* p2 = b2.ptr;
+  int c0 = 0;
+  for (int i = 0; i < l0; i++) {
+    int c1 = p1[i] & 0xFF;
+    int c2 = p2[i] & 0xFF;
+    if (c1 != c2) {
+      // Before returning the obvious answer,
+      // check to see if c1 or c2 is part of a 0x0000,
+      // which encodes as {0xC0,0x80}.  The 0x0000 is the
+      // lowest-sorting Java char value, and yet it encodes
+      // as if it were the first char after 0x7F, which causes
+      // strings containing nulls to sort too high.  All other
+      // comparisons are consistent between Utf8 and Java chars.
+      if (c1 == 0xC0 && (p1[i+1] & 0xFF) == 0x80)  c1 = 0;
+      if (c2 == 0xC0 && (p2[i+1] & 0xFF) == 0x80)  c2 = 0;
+      if (c0 == 0xC0) {
+        assert(((c1|c2) & 0xC0) == 0x80);  // c1 & c2 are extension chars
+        if (c1 == 0x80)  c1 = 0;  // will sort below c2
+        if (c2 == 0x80)  c2 = 0;  // will sort below c1
+      }
+      return c1 - c2;
+    }
+    c0 = c1;  // save away previous char
+  }
+  // common prefix is identical; return length difference if any
+  return l1 - l2;
+}
+
+// Cf. PackageReader.readUtf8Bands
+local_inline
+void unpacker::read_Utf8_values(entry* cpMap, int len) {
+  // Implicit first Utf8 string is the empty string.
+  enum {
+    // certain bands begin with implicit zeroes
+    PREFIX_SKIP_2 = 2,
+    SUFFIX_SKIP_1 = 1
+  };
+
+  int i;
+
+  // First band:  Read lengths of shared prefixes.
+  if (len > PREFIX_SKIP_2)
+    cp_Utf8_prefix.readData(len - PREFIX_SKIP_2);
+    NOT_PRODUCT(else cp_Utf8_prefix.readData(0));  // for asserts
+
+  // Second band:  Read lengths of unshared suffixes:
+  if (len > SUFFIX_SKIP_1)
+    cp_Utf8_suffix.readData(len - SUFFIX_SKIP_1);
+    NOT_PRODUCT(else cp_Utf8_suffix.readData(0));  // for asserts
+
+  bytes* allsuffixes = T_NEW(bytes, len);
+  CHECK;
+
+  int nbigsuf = 0;
+  fillbytes charbuf;    // buffer to allocate small strings
+  charbuf.init();
+
+  // Third band:  Read the char values in the unshared suffixes:
+  cp_Utf8_chars.readData(cp_Utf8_suffix.getIntTotal());
+  for (i = 0; i < len; i++) {
+    int suffix = (i < SUFFIX_SKIP_1)? 0: cp_Utf8_suffix.getInt();
+    if (suffix < 0) {
+      abort("bad utf8 suffix");
+      return;
+    }
+    if (suffix == 0 && i >= SUFFIX_SKIP_1) {
+      // chars are packed in cp_Utf8_big_chars
+      nbigsuf += 1;
+      continue;
+    }
+    bytes& chars  = allsuffixes[i];
+    uint size3    = suffix * 3;     // max Utf8 length
+    bool isMalloc = (suffix > SMALL);
+    if (isMalloc) {
+      chars.malloc(size3);
+    } else {
+      if (!charbuf.canAppend(size3+1)) {
+        assert(charbuf.allocated == 0 || tmallocs.contains(charbuf.base()));
+        charbuf.init(CHUNK);  // Reset to new buffer.
+        tmallocs.add(charbuf.base());
+      }
+      chars.set(charbuf.grow(size3+1), size3);
+    }
+    CHECK;
+    byte* chp = chars.ptr;
+    for (int j = 0; j < suffix; j++) {
+      unsigned short ch = cp_Utf8_chars.getInt();
+      chp = store_Utf8_char(chp, ch);
+    }
+    // shrink to fit:
+    if (isMalloc) {
+      chars.realloc(chp - chars.ptr);
+      CHECK;
+      tmallocs.add(chars.ptr); // free it later
+    } else {
+      int shrink = (int)(chars.limit() - chp);
+      chars.len -= shrink;
+      charbuf.b.len -= shrink;  // ungrow to reclaim buffer space
+      // Note that we did not reclaim the final '\0'.
+      assert(chars.limit() == charbuf.limit()-1);
+      assert(strlen((char*)chars.ptr) == chars.len);
+    }
+  }
+  //cp_Utf8_chars.done();
+#ifndef PRODUCT
+  charbuf.b.set(null, 0); // tidy
+#endif
+
+  // Fourth band:  Go back and size the specially packed strings.
+  int maxlen = 0;
+  cp_Utf8_big_suffix.readData(nbigsuf);
+  cp_Utf8_suffix.rewind();
+  for (i = 0; i < len; i++) {
+    int suffix = (i < SUFFIX_SKIP_1)? 0: cp_Utf8_suffix.getInt();
+    int prefix = (i < PREFIX_SKIP_2)? 0: cp_Utf8_prefix.getInt();
+    if (prefix < 0 || prefix+suffix < 0) {
+       abort("bad utf8 prefix");
+       return;
+    }
+    bytes& chars = allsuffixes[i];
+    if (suffix == 0 && i >= SUFFIX_SKIP_1) {
+      suffix = cp_Utf8_big_suffix.getInt();
+      assert(chars.ptr == null);
+      chars.len = suffix;  // just a momentary hack
+    } else {
+      assert(chars.ptr != null);
+    }
+    if (maxlen < prefix + suffix) {
+      maxlen = prefix + suffix;
+    }
+  }
+  //cp_Utf8_suffix.done();      // will use allsuffixes[i].len (ptr!=null)
+  //cp_Utf8_big_suffix.done();  // will use allsuffixes[i].len
+
+  // Fifth band(s):  Get the specially packed characters.
+  cp_Utf8_big_suffix.rewind();
+  for (i = 0; i < len; i++) {
+    bytes& chars = allsuffixes[i];
+    if (chars.ptr != null)  continue;  // already input
+    int suffix = (int)chars.len;  // pick up the hack
+    uint size3 = suffix * 3;
+    if (suffix == 0)  continue;  // done with empty string
+    chars.malloc(size3);
+    CHECK;
+    byte* chp = chars.ptr;
+    band saved_band = cp_Utf8_big_chars;
+    cp_Utf8_big_chars.readData(suffix);
+    CHECK;
+    for (int j = 0; j < suffix; j++) {
+      unsigned short ch = cp_Utf8_big_chars.getInt();
+      CHECK;
+      chp = store_Utf8_char(chp, ch);
+    }
+    chars.realloc(chp - chars.ptr);
+    CHECK;
+    tmallocs.add(chars.ptr);  // free it later
+    //cp_Utf8_big_chars.done();
+    cp_Utf8_big_chars = saved_band;  // reset the band for the next string
+  }
+  cp_Utf8_big_chars.readData(0);  // zero chars
+  //cp_Utf8_big_chars.done();
+
+  // Finally, sew together all the prefixes and suffixes.
+  bytes bigbuf;
+  bigbuf.malloc(maxlen * 3 + 1);  // max Utf8 length, plus slop for null
+  CHECK;
+  int prevlen = 0;  // previous string length (in chars)
+  tmallocs.add(bigbuf.ptr);  // free after this block
+  CHECK;
+  cp_Utf8_prefix.rewind();
+  for (i = 0; i < len; i++) {
+    bytes& chars = allsuffixes[i];
+    int prefix = (i < PREFIX_SKIP_2)? 0: cp_Utf8_prefix.getInt();
+    CHECK;
+    int suffix = (int)chars.len;
+    byte* fillp;
+    // by induction, the buffer is already filled with the prefix
+    // make sure the prefix value is not corrupted, though:
+    if (prefix > prevlen) {
+       abort("utf8 prefix overflow");
+       return;
+    }
+    fillp = skip_Utf8_chars(bigbuf.ptr, prefix);
+    // copy the suffix into the same buffer:
+    fillp = chars.writeTo(fillp);
+    assert(bigbuf.inBounds(fillp));
+    *fillp = 0;  // bigbuf must contain a well-formed Utf8 string
+    int length = (int)(fillp - bigbuf.ptr);
+    bytes& value = cpMap[i].value.b;
+    value.set(U_NEW(byte, add_size(length,1)), length);
+    value.copyFrom(bigbuf.ptr, length);
+    CHECK;
+    // Index all Utf8 strings
+    entry* &htref = cp.hashTabRef(CONSTANT_Utf8, value);
+    if (htref == null) {
+      // Note that if two identical strings are transmitted,
+      // the first is taken to be the canonical one.
+      htref = &cpMap[i];
+    }
+    prevlen = prefix + suffix;
+  }
+  //cp_Utf8_prefix.done();
+
+  // Free intermediate buffers.
+  free_temps();
+}
+
+local_inline
+void unpacker::read_single_words(band& cp_band, entry* cpMap, int len) {
+  cp_band.readData(len);
+  for (int i = 0; i < len; i++) {
+    cpMap[i].value.i = cp_band.getInt();  // coding handles signs OK
+  }
+}
+
+maybe_inline
+void unpacker::read_double_words(band& cp_bands, entry* cpMap, int len) {
+  band& cp_band_hi = cp_bands;
+  band& cp_band_lo = cp_bands.nextBand();
+  cp_band_hi.readData(len);
+  cp_band_lo.readData(len);
+  for (int i = 0; i < len; i++) {
+    cpMap[i].value.l = cp_band_hi.getLong(cp_band_lo, true);
+  }
+  //cp_band_hi.done();
+  //cp_band_lo.done();
+}
+
+maybe_inline
+void unpacker::read_single_refs(band& cp_band, byte refTag, entry* cpMap, int len) {
+  assert(refTag == CONSTANT_Utf8);
+  cp_band.setIndexByTag(refTag);
+  cp_band.readData(len);
+  CHECK;
+  int indexTag = (cp_band.bn == e_cp_Class) ? CONSTANT_Class : 0;
+  for (int i = 0; i < len; i++) {
+    entry& e = cpMap[i];
+    e.refs = U_NEW(entry*, e.nrefs = 1);
+    entry* utf = cp_band.getRef();
+    CHECK;
+    e.refs[0] = utf;
+    e.value.b = utf->value.b;  // copy value of Utf8 string to self
+    if (indexTag != 0) {
+      // Maintain cross-reference:
+      entry* &htref = cp.hashTabRef(indexTag, e.value.b);
+      if (htref == null) {
+        // Note that if two identical classes are transmitted,
+        // the first is taken to be the canonical one.
+        htref = &e;
+      }
+    }
+  }
+  //cp_band.done();
+}
+
+maybe_inline
+void unpacker::read_double_refs(band& cp_band, byte ref1Tag, byte ref2Tag,
+                                entry* cpMap, int len) {
+  band& cp_band1 = cp_band;
+  band& cp_band2 = cp_band.nextBand();
+  cp_band1.setIndexByTag(ref1Tag);
+  cp_band2.setIndexByTag(ref2Tag);
+  cp_band1.readData(len);
+  cp_band2.readData(len);
+  CHECK;
+  for (int i = 0; i < len; i++) {
+    entry& e = cpMap[i];
+    e.refs = U_NEW(entry*, e.nrefs = 2);
+    e.refs[0] = cp_band1.getRef();
+    CHECK;
+    e.refs[1] = cp_band2.getRef();
+    CHECK;
+  }
+  //cp_band1.done();
+  //cp_band2.done();
+}
+
+// Cf. PackageReader.readSignatureBands
+maybe_inline
+void unpacker::read_signature_values(entry* cpMap, int len) {
+  cp_Signature_form.setIndexByTag(CONSTANT_Utf8);
+  cp_Signature_form.readData(len);
+  CHECK;
+  int ncTotal = 0;
+  int i;
+  for (i = 0; i < len; i++) {
+    entry& e = cpMap[i];
+    entry& form = *cp_Signature_form.getRef();
+    CHECK;
+    int nc = 0;
+
+    for ( const char* ncp = form.utf8String() ; *ncp; ncp++) {
+      if (*ncp == 'L')  nc++;
+    }
+
+    ncTotal += nc;
+    e.refs = U_NEW(entry*, cpMap[i].nrefs = 1 + nc);
+    CHECK;
+    e.refs[0] = &form;
+  }
+  //cp_Signature_form.done();
+  cp_Signature_classes.setIndexByTag(CONSTANT_Class);
+  cp_Signature_classes.readData(ncTotal);
+  for (i = 0; i < len; i++) {
+    entry& e = cpMap[i];
+    for (int j = 1; j < e.nrefs; j++) {
+      e.refs[j] = cp_Signature_classes.getRef();
+      CHECK;
+    }
+  }
+  //cp_Signature_classes.done();
+}
+
+maybe_inline
+void unpacker::checkLegacy(const char* name) {
+  if (u->majver < JAVA7_PACKAGE_MAJOR_VERSION) {
+      char message[100];
+      snprintf(message, 99, "unexpected band %s\n", name);
+      abort(message);
+  }
+}
+
+maybe_inline
+void unpacker::read_method_handle(entry* cpMap, int len) {
+  if (len > 0) {
+    checkLegacy(cp_MethodHandle_refkind.name);
+  }
+  cp_MethodHandle_refkind.readData(len);
+  cp_MethodHandle_member.setIndexByTag(CONSTANT_AnyMember);
+  cp_MethodHandle_member.readData(len);
+  for (int i = 0 ; i < len ; i++) {
+    entry& e = cpMap[i];
+    e.value.i = cp_MethodHandle_refkind.getInt();
+    e.refs = U_NEW(entry*, e.nrefs = 1);
+    e.refs[0] = cp_MethodHandle_member.getRef();
+    CHECK;
+  }
+}
+
+maybe_inline
+void unpacker::read_method_type(entry* cpMap, int len) {
+  if (len > 0) {
+    checkLegacy(cp_MethodType.name);
+  }
+  cp_MethodType.setIndexByTag(CONSTANT_Signature);
+  cp_MethodType.readData(len);
+  for (int i = 0 ; i < len ; i++) {
+      entry& e = cpMap[i];
+      e.refs = U_NEW(entry*, e.nrefs = 1);
+      e.refs[0] = cp_MethodType.getRef();
+      CHECK;
+  }
+}
+
+maybe_inline
+void unpacker::read_bootstrap_methods(entry* cpMap, int len) {
+  if (len > 0) {
+    checkLegacy(cp_BootstrapMethod_ref.name);
+  }
+  cp_BootstrapMethod_ref.setIndexByTag(CONSTANT_MethodHandle);
+  cp_BootstrapMethod_ref.readData(len);
+
+  cp_BootstrapMethod_arg_count.readData(len);
+  int totalArgCount = cp_BootstrapMethod_arg_count.getIntTotal();
+  cp_BootstrapMethod_arg.setIndexByTag(CONSTANT_LoadableValue);
+  cp_BootstrapMethod_arg.readData(totalArgCount);
+  for (int i = 0; i < len; i++) {
+    entry& e = cpMap[i];
+    int argc = cp_BootstrapMethod_arg_count.getInt();
+    e.value.i = argc;
+    e.refs = U_NEW(entry*, e.nrefs = argc + 1);
+    e.refs[0] = cp_BootstrapMethod_ref.getRef();
+    for (int j = 1 ; j < e.nrefs ; j++) {
+      e.refs[j] = cp_BootstrapMethod_arg.getRef();
+      CHECK;
+    }
+  }
+}
+// Cf. PackageReader.readConstantPool
+void unpacker::read_cp() {
+  byte* rp0 = rp;
+
+  int i;
+
+  for (int k = 0; k < (int)N_TAGS_IN_ORDER; k++) {
+    byte tag = TAGS_IN_ORDER[k];
+    int  len = cp.tag_count[tag];
+    int base = cp.tag_base[tag];
+
+    PRINTCR((1,"Reading %d %s entries...", len, NOT_PRODUCT(TAG_NAME[tag])+0));
+    entry* cpMap = &cp.entries[base];
+    for (i = 0; i < len; i++) {
+      cpMap[i].tag = tag;
+      cpMap[i].inord = i;
+    }
+    // Initialize the tag's CP index right away, since it might be needed
+    // in the next pass to initialize the CP for another tag.
+#ifndef PRODUCT
+    cpindex* ix = &cp.tag_index[tag];
+    assert(ix->ixTag == tag);
+    assert((int)ix->len   == len);
+    assert(ix->base1 == cpMap);
+#endif
+
+    switch (tag) {
+    case CONSTANT_Utf8:
+      read_Utf8_values(cpMap, len);
+      break;
+    case CONSTANT_Integer:
+      read_single_words(cp_Int, cpMap, len);
+      break;
+    case CONSTANT_Float:
+      read_single_words(cp_Float, cpMap, len);
+      break;
+    case CONSTANT_Long:
+      read_double_words(cp_Long_hi /*& cp_Long_lo*/, cpMap, len);
+      break;
+    case CONSTANT_Double:
+      read_double_words(cp_Double_hi /*& cp_Double_lo*/, cpMap, len);
+      break;
+    case CONSTANT_String:
+      read_single_refs(cp_String, CONSTANT_Utf8, cpMap, len);
+      break;
+    case CONSTANT_Class:
+      read_single_refs(cp_Class, CONSTANT_Utf8, cpMap, len);
+      break;
+    case CONSTANT_Signature:
+      read_signature_values(cpMap, len);
+      break;
+    case CONSTANT_NameandType:
+      read_double_refs(cp_Descr_name /*& cp_Descr_type*/,
+                       CONSTANT_Utf8, CONSTANT_Signature,
+                       cpMap, len);
+      break;
+    case CONSTANT_Fieldref:
+      read_double_refs(cp_Field_class /*& cp_Field_desc*/,
+                       CONSTANT_Class, CONSTANT_NameandType,
+                       cpMap, len);
+      break;
+    case CONSTANT_Methodref:
+      read_double_refs(cp_Method_class /*& cp_Method_desc*/,
+                       CONSTANT_Class, CONSTANT_NameandType,
+                       cpMap, len);
+      break;
+    case CONSTANT_InterfaceMethodref:
+      read_double_refs(cp_Imethod_class /*& cp_Imethod_desc*/,
+                       CONSTANT_Class, CONSTANT_NameandType,
+                       cpMap, len);
+      break;
+    case CONSTANT_MethodHandle:
+      // consumes cp_MethodHandle_refkind and cp_MethodHandle_member
+      read_method_handle(cpMap, len);
+      break;
+    case CONSTANT_MethodType:
+      // consumes cp_MethodType
+      read_method_type(cpMap, len);
+      break;
+    case CONSTANT_InvokeDynamic:
+      read_double_refs(cp_InvokeDynamic_spec, CONSTANT_BootstrapMethod,
+                       CONSTANT_NameandType,
+                       cpMap, len);
+      break;
+    case CONSTANT_BootstrapMethod:
+      // consumes cp_BootstrapMethod_ref, cp_BootstrapMethod_arg_count and cp_BootstrapMethod_arg
+      read_bootstrap_methods(cpMap, len);
+      break;
+    default:
+      assert(false);
+      break;
+    }
+    CHECK;
+  }
+
+  cp.expandSignatures();
+  CHECK;
+  cp.initMemberIndexes();
+  CHECK;
+
+  PRINTCR((1,"parsed %d constant pool entries in %d bytes", cp.nentries, (rp - rp0)));
+
+  #define SNAME(n,s) #s "\0"
+  const char* symNames = (
+    ALL_ATTR_DO(SNAME)
+    "<init>"
+  );
+  #undef SNAME
+
+  for (int sn = 0; sn < cpool::s_LIMIT; sn++) {
+    assert(symNames[0] >= '0' && symNames[0] <= 'Z');  // sanity
+    bytes name; name.set(symNames);
+    if (name.len > 0 && name.ptr[0] != '0') {
+      cp.sym[sn] = cp.ensureUtf8(name);
+      PRINTCR((4, "well-known sym %d=%s", sn, cp.sym[sn]->string()));
+    }
+    symNames += name.len + 1;  // skip trailing null to next name
+  }
+
+  band::initIndexes(this);
+}
+
+static band* no_bands[] = { null };  // shared empty body
+
+inline
+band& unpacker::attr_definitions::fixed_band(int e_class_xxx) {
+  return u->all_bands[xxx_flags_hi_bn + (e_class_xxx-e_class_flags_hi)];
+}
+inline band& unpacker::attr_definitions::xxx_flags_hi()
+  { return fixed_band(e_class_flags_hi); }
+inline band& unpacker::attr_definitions::xxx_flags_lo()
+  { return fixed_band(e_class_flags_lo); }
+inline band& unpacker::attr_definitions::xxx_attr_count()
+  { return fixed_band(e_class_attr_count); }
+inline band& unpacker::attr_definitions::xxx_attr_indexes()
+  { return fixed_band(e_class_attr_indexes); }
+inline band& unpacker::attr_definitions::xxx_attr_calls()
+  { return fixed_band(e_class_attr_calls); }
+
+
+inline
+unpacker::layout_definition*
+unpacker::attr_definitions::defineLayout(int idx,
+                                         entry* nameEntry,
+                                         const char* layout) {
+  const char* name = nameEntry->value.b.strval();
+  layout_definition* lo = defineLayout(idx, name, layout);
+  CHECK_0;
+  lo->nameEntry = nameEntry;
+  return lo;
+}
+
+unpacker::layout_definition*
+unpacker::attr_definitions::defineLayout(int idx,
+                                         const char* name,
+                                         const char* layout) {
+  assert(flag_limit != 0);  // must be set up already
+  if (idx >= 0) {
+    // Fixed attr.
+    if (idx >= (int)flag_limit)
+      abort("attribute index too large");
+    if (isRedefined(idx))
+      abort("redefined attribute index");
+    redef |= ((julong)1<<idx);
+  } else {
+    idx = flag_limit + overflow_count.length();
+    overflow_count.add(0);  // make a new counter
+  }
+  layout_definition* lo = U_NEW(layout_definition, 1);
+  CHECK_0;
+  lo->idx = idx;
+  lo->name = name;
+  lo->layout = layout;
+  for (int adds = (idx+1) - layouts.length(); adds > 0; adds--) {
+    layouts.add(null);
+  }
+  CHECK_0;
+  layouts.get(idx) = lo;
+  return lo;
+}
+
+band**
+unpacker::attr_definitions::buildBands(unpacker::layout_definition* lo) {
+  int i;
+  if (lo->elems != null)
+    return lo->bands();
+  if (lo->layout[0] == '\0') {
+    lo->elems = no_bands;
+  } else {
+    // Create bands for this attribute by parsing the layout.
+    bool hasCallables = lo->hasCallables();
+    bands_made = 0x10000;  // base number for bands made
+    const char* lp = lo->layout;
+    lp = parseLayout(lp, lo->elems, -1);
+    CHECK_0;
+    if (lp[0] != '\0' || band_stack.length() > 0) {
+      abort("garbage at end of layout");
+    }
+    band_stack.popTo(0);
+    CHECK_0;
+
+    // Fix up callables to point at their callees.
+    band** bands = lo->elems;
+    assert(bands == lo->bands());
+    int num_callables = 0;
+    if (hasCallables) {
+      while (bands[num_callables] != null) {
+        if (bands[num_callables]->le_kind != EK_CBLE) {
+          abort("garbage mixed with callables");
+          break;
+        }
+        num_callables += 1;
+      }
+    }
+    for (i = 0; i < calls_to_link.length(); i++) {
+      band& call = *(band*) calls_to_link.get(i);
+      assert(call.le_kind == EK_CALL);
+      // Determine the callee.
+      int call_num = call.le_len;
+      if (call_num < 0 || call_num >= num_callables) {
+        abort("bad call in layout");
+        break;
+      }
+      band& cble = *bands[call_num];
+      // Link the call to it.
+      call.le_body[0] = &cble;
+      // Distinguish backward calls and callables:
+      assert(cble.le_kind == EK_CBLE);
+      assert(cble.le_len == call_num);
+      cble.le_back |= call.le_back;
+    }
+    calls_to_link.popTo(0);
+  }
+  return lo->elems;
+}
+
+/* attribute layout language parser
+
+  attribute_layout:
+        ( layout_element )* | ( callable )+
+  layout_element:
+        ( integral | replication | union | call | reference )
+
+  callable:
+        '[' body ']'
+  body:
+        ( layout_element )+
+
+  integral:
+        ( unsigned_int | signed_int | bc_index | bc_offset | flag )
+  unsigned_int:
+        uint_type
+  signed_int:
+        'S' uint_type
+  any_int:
+        ( unsigned_int | signed_int )
+  bc_index:
+        ( 'P' uint_type | 'PO' uint_type )
+  bc_offset:
+        'O' any_int
+  flag:
+        'F' uint_type
+  uint_type:
+        ( 'B' | 'H' | 'I' | 'V' )
+
+  replication:
+        'N' uint_type '[' body ']'
+
+  union:
+        'T' any_int (union_case)* '(' ')' '[' (body)? ']'
+  union_case:
+        '(' union_case_tag (',' union_case_tag)* ')' '[' (body)? ']'
+  union_case_tag:
+        ( numeral | numeral '-' numeral )
+  call:
+        '(' numeral ')'
+
+  reference:
+        reference_type ( 'N' )? uint_type
+  reference_type:
+        ( constant_ref | schema_ref | utf8_ref | untyped_ref )
+  constant_ref:
+        ( 'KI' | 'KJ' | 'KF' | 'KD' | 'KS' | 'KQ' )
+  schema_ref:
+        ( 'RC' | 'RS' | 'RD' | 'RF' | 'RM' | 'RI' )
+  utf8_ref:
+        'RU'
+  untyped_ref:
+        'RQ'
+
+  numeral:
+        '(' ('-')? (digit)+ ')'
+  digit:
+        ( '0' | '1' | '2' | '3' | '4' | '5' | '6' | '7' | '8' | '9' )
+
+*/
+
+const char*
+unpacker::attr_definitions::parseIntLayout(const char* lp, band* &res,
+                                           byte le_kind, bool can_be_signed) {
+  const char* lp0 = lp;
+  band* b = U_NEW(band, 1);
+  CHECK_(lp);
+  char le = *lp++;
+  int spec = UNSIGNED5_spec;
+  if (le == 'S' && can_be_signed) {
+    // Note:  This is the last use of sign.  There is no 'EF_SIGN'.
+    spec = SIGNED5_spec;
+    le = *lp++;
+  } else if (le == 'B') {
+    spec = BYTE1_spec;  // unsigned byte
+  }
+  b->init(u, bands_made++, spec);
+  b->le_kind = le_kind;
+  int le_len = 0;
+  switch (le) {
+  case 'B': le_len = 1; break;
+  case 'H': le_len = 2; break;
+  case 'I': le_len = 4; break;
+  case 'V': le_len = 0; break;
+  default:  abort("bad layout element");
+  }
+  b->le_len = le_len;
+  band_stack.add(b);
+  res = b;
+  return lp;
+}
+
+const char*
+unpacker::attr_definitions::parseNumeral(const char* lp, int &res) {
+  const char* lp0 = lp;
+  bool sgn = false;
+  if (*lp == '0') { res = 0; return lp+1; }  // special case '0'
+  if (*lp == '-') { sgn = true; lp++; }
+  const char* dp = lp;
+  int con = 0;
+  while (*dp >= '0' && *dp <= '9') {
+    int con0 = con;
+    con *= 10;
+    con += (*dp++) - '0';
+    if (con <= con0) { con = -1; break; }  //  numeral overflow
+  }
+  if (lp == dp) {
+    abort("missing numeral in layout");
+    return "";
+  }
+  lp = dp;
+  if (con < 0 && !(sgn && con == -con)) {
+    // (Portability note:  Misses the error if int is not 32 bits.)
+    abort("numeral overflow");
+    return "" ;
+  }
+  if (sgn)  con = -con;
+  res = con;
+  return lp;
+}
+
+band**
+unpacker::attr_definitions::popBody(int bs_base) {
+  // Return everything that was pushed, as a null-terminated pointer array.
+  int bs_limit = band_stack.length();
+  if (bs_base == bs_limit) {
+    return no_bands;
+  } else {
+    int nb = bs_limit - bs_base;
+    band** res = U_NEW(band*, add_size(nb, 1));
+    CHECK_(no_bands);
+    for (int i = 0; i < nb; i++) {
+      band* b = (band*) band_stack.get(bs_base + i);
+      res[i] = b;
+    }
+    band_stack.popTo(bs_base);
+    return res;
+  }
+}
+
+const char*
+unpacker::attr_definitions::parseLayout(const char* lp, band** &res,
+                                        int curCble) {
+  const char* lp0 = lp;
+  int bs_base = band_stack.length();
+  bool top_level = (bs_base == 0);
+  band* b;
+  enum { can_be_signed = true };  // optional arg to parseIntLayout
+
+  for (bool done = false; !done; ) {
+    switch (*lp++) {
+    case 'B': case 'H': case 'I': case 'V': // unsigned_int
+    case 'S': // signed_int
+      --lp; // reparse
+    case 'F':
+      lp = parseIntLayout(lp, b, EK_INT);
+      break;
+    case 'P':
+      {
+        int le_bci = EK_BCI;
+        if (*lp == 'O') {
+          ++lp;
+          le_bci = EK_BCID;
+        }
+        assert(*lp != 'S');  // no PSH, etc.
+        lp = parseIntLayout(lp, b, EK_INT);
+        b->le_bci = le_bci;
+        if (le_bci == EK_BCI)
+          b->defc = coding::findBySpec(BCI5_spec);
+        else
+          b->defc = coding::findBySpec(BRANCH5_spec);
+      }
+      break;
+    case 'O':
+      lp = parseIntLayout(lp, b, EK_INT, can_be_signed);
+      b->le_bci = EK_BCO;
+      b->defc = coding::findBySpec(BRANCH5_spec);
+      break;
+    case 'N': // replication: 'N' uint '[' elem ... ']'
+      lp = parseIntLayout(lp, b, EK_REPL);
+      assert(*lp == '[');
+      ++lp;
+      lp = parseLayout(lp, b->le_body, curCble);
+      CHECK_(lp);
+      break;
+    case 'T': // union: 'T' any_int union_case* '(' ')' '[' body ']'
+      lp = parseIntLayout(lp, b, EK_UN, can_be_signed);
+      {
+        int union_base = band_stack.length();
+        for (;;) {   // for each case
+          band& k_case = *U_NEW(band, 1);
+          CHECK_(lp);
+          band_stack.add(&k_case);
+          k_case.le_kind = EK_CASE;
+          k_case.bn = bands_made++;
+          if (*lp++ != '(') {
+            abort("bad union case");
+            return "";
+          }
+          if (*lp++ != ')') {
+            --lp;  // reparse
+            // Read some case values.  (Use band_stack for temp. storage.)
+            int case_base = band_stack.length();
+            for (;;) {
+              int caseval = 0;
+              lp = parseNumeral(lp, caseval);
+              band_stack.add((void*)(size_t)caseval);
+              if (*lp == '-') {
+                // new in version 160, allow (1-5) for (1,2,3,4,5)
+                if (u->majver < JAVA6_PACKAGE_MAJOR_VERSION) {
+                  abort("bad range in union case label (old archive format)");
+                  return "";
+                }
+                int caselimit = caseval;
+                lp++;
+                lp = parseNumeral(lp, caselimit);
+                if (caseval >= caselimit
+                    || (uint)(caselimit - caseval) > 0x10000) {
+                  // Note:  0x10000 is arbitrary implementation restriction.
+                  // We can remove it later if it's important to.
+                  abort("bad range in union case label");
+                  return "";
+                }
+                for (;;) {
+                  ++caseval;
+                  band_stack.add((void*)(size_t)caseval);
+                  if (caseval == caselimit)  break;
+                }
+              }
+              if (*lp != ',')  break;
+              lp++;
+            }
+            if (*lp++ != ')') {
+              abort("bad case label");
+              return "";
+            }
+            // save away the case labels
+            int ntags = band_stack.length() - case_base;
+            int* tags = U_NEW(int, add_size(ntags, 1));
+            CHECK_(lp);
+            k_case.le_casetags = tags;
+            *tags++ = ntags;
+            for (int i = 0; i < ntags; i++) {
+              *tags++ = ptrlowbits(band_stack.get(case_base+i));
+            }
+            band_stack.popTo(case_base);
+            CHECK_(lp);
+          }
+          // Got le_casetags.  Now grab the body.
+          assert(*lp == '[');
+          ++lp;
+          lp = parseLayout(lp, k_case.le_body, curCble);
+          CHECK_(lp);
+          if (k_case.le_casetags == null)  break;  // done
+        }
+        b->le_body = popBody(union_base);
+      }
+      break;
+    case '(': // call: '(' -?NN* ')'
+      {
+        band& call = *U_NEW(band, 1);
+        CHECK_(lp);
+        band_stack.add(&call);
+        call.le_kind = EK_CALL;
+        call.bn = bands_made++;
+        call.le_body = U_NEW(band*, 2); // fill in later
+        int call_num = 0;
+        lp = parseNumeral(lp, call_num);
+        call.le_back = (call_num <= 0);
+        call_num += curCble;  // numeral is self-relative offset
+        call.le_len = call_num;  //use le_len as scratch
+        calls_to_link.add(&call);
+        CHECK_(lp);
+        if (*lp++ != ')') {
+          abort("bad call label");
+          return "";
+        }
+      }
+      break;
+    case 'K': // reference_type: constant_ref
+    case 'R': // reference_type: schema_ref
+      {
+        int ixTag = CONSTANT_None;
+        if (lp[-1] == 'K') {
+          switch (*lp++) {
+          case 'I': ixTag = CONSTANT_Integer; break;
+          case 'J': ixTag = CONSTANT_Long; break;
+          case 'F': ixTag = CONSTANT_Float; break;
+          case 'D': ixTag = CONSTANT_Double; break;
+          case 'S': ixTag = CONSTANT_String; break;
+          case 'Q': ixTag = CONSTANT_FieldSpecific; break;
+
+          // new in 1.7
+          case 'M': ixTag = CONSTANT_MethodHandle; break;
+          case 'T': ixTag = CONSTANT_MethodType; break;
+          case 'L': ixTag = CONSTANT_LoadableValue; break;
+          }
+        } else {
+          switch (*lp++) {
+          case 'C': ixTag = CONSTANT_Class; break;
+          case 'S': ixTag = CONSTANT_Signature; break;
+          case 'D': ixTag = CONSTANT_NameandType; break;
+          case 'F': ixTag = CONSTANT_Fieldref; break;
+          case 'M': ixTag = CONSTANT_Methodref; break;
+          case 'I': ixTag = CONSTANT_InterfaceMethodref; break;
+          case 'U': ixTag = CONSTANT_Utf8; break; //utf8_ref
+          case 'Q': ixTag = CONSTANT_All; break; //untyped_ref
+
+          // new in 1.7
+          case 'Y': ixTag = CONSTANT_InvokeDynamic; break;
+          case 'B': ixTag = CONSTANT_BootstrapMethod; break;
+          case 'N': ixTag = CONSTANT_AnyMember; break;
+          }
+        }
+        if (ixTag == CONSTANT_None) {
+          abort("bad reference layout");
+          break;
+        }
+        bool nullOK = false;
+        if (*lp == 'N') {
+          nullOK = true;
+          lp++;
+        }
+        lp = parseIntLayout(lp, b, EK_REF);
+        b->defc = coding::findBySpec(UNSIGNED5_spec);
+        b->initRef(ixTag, nullOK);
+      }
+      break;
+    case '[':
+      {
+        // [callable1][callable2]...
+        if (!top_level) {
+          abort("bad nested callable");
+          break;
+        }
+        curCble += 1;
+        NOT_PRODUCT(int call_num = band_stack.length() - bs_base);
+        band& cble = *U_NEW(band, 1);
+        CHECK_(lp);
+        band_stack.add(&cble);
+        cble.le_kind = EK_CBLE;
+        NOT_PRODUCT(cble.le_len = call_num);
+        cble.bn = bands_made++;
+        lp = parseLayout(lp, cble.le_body, curCble);
+      }
+      break;
+    case ']':
+      // Hit a closing brace.  This ends whatever body we were in.
+      done = true;
+      break;
+    case '\0':
+      // Hit a null.  Also ends the (top-level) body.
+      --lp;  // back up, so caller can see the null also
+      done = true;
+      break;
+    default:
+      abort("bad layout");
+      break;
+    }
+    CHECK_(lp);
+  }
+
+  // Return the accumulated bands:
+  res = popBody(bs_base);
+  return lp;
+}
+
+void unpacker::read_attr_defs() {
+  int i;
+
+  // Tell each AD which attrc it is and where its fixed flags are:
+  attr_defs[ATTR_CONTEXT_CLASS].attrc            = ATTR_CONTEXT_CLASS;
+  attr_defs[ATTR_CONTEXT_CLASS].xxx_flags_hi_bn  = e_class_flags_hi;
+  attr_defs[ATTR_CONTEXT_FIELD].attrc            = ATTR_CONTEXT_FIELD;
+  attr_defs[ATTR_CONTEXT_FIELD].xxx_flags_hi_bn  = e_field_flags_hi;
+  attr_defs[ATTR_CONTEXT_METHOD].attrc           = ATTR_CONTEXT_METHOD;
+  attr_defs[ATTR_CONTEXT_METHOD].xxx_flags_hi_bn = e_method_flags_hi;
+  attr_defs[ATTR_CONTEXT_CODE].attrc             = ATTR_CONTEXT_CODE;
+  attr_defs[ATTR_CONTEXT_CODE].xxx_flags_hi_bn   = e_code_flags_hi;
+
+  // Decide whether bands for the optional high flag words are present.
+  attr_defs[ATTR_CONTEXT_CLASS]
+    .setHaveLongFlags(testBit(archive_options, AO_HAVE_CLASS_FLAGS_HI));
+  attr_defs[ATTR_CONTEXT_FIELD]
+    .setHaveLongFlags(testBit(archive_options, AO_HAVE_FIELD_FLAGS_HI));
+  attr_defs[ATTR_CONTEXT_METHOD]
+    .setHaveLongFlags(testBit(archive_options, AO_HAVE_METHOD_FLAGS_HI));
+  attr_defs[ATTR_CONTEXT_CODE]
+    .setHaveLongFlags(testBit(archive_options, AO_HAVE_CODE_FLAGS_HI));
+
+  // Set up built-in attrs.
+  // (The simple ones are hard-coded.  The metadata layouts are not.)
+  const char* md_layout = (
+    // parameter annotations:
+#define MDL0 \
+    "[NB[(1)]]"
+    MDL0
+    // annotations:
+#define MDL1 \
+    "[NH[(1)]]"
+    MDL1
+#define MDL2 \
+    "[RSHNH[RUH(1)]]"
+    MDL2
+    // element_value:
+#define MDL3 \
+    "[TB"                        \
+      "(66,67,73,83,90)[KIH]"    \
+      "(68)[KDH]"                \
+      "(70)[KFH]"                \
+      "(74)[KJH]"                \
+      "(99)[RSH]"                \
+      "(101)[RSHRUH]"            \
+      "(115)[RUH]"               \
+      "(91)[NH[(0)]]"            \
+      "(64)["                    \
+        /* nested annotation: */ \
+        "RSH"                    \
+        "NH[RUH(0)]"             \
+        "]"                      \
+      "()[]"                     \
+    "]"
+    MDL3
+    );
+
+  const char* md_layout_P = md_layout;
+  const char* md_layout_A = md_layout+strlen(MDL0);
+  const char* md_layout_V = md_layout+strlen(MDL0 MDL1 MDL2);
+  assert(0 == strncmp(&md_layout_A[-3], ")]][", 4));
+  assert(0 == strncmp(&md_layout_V[-3], ")]][", 4));
+
+const char* type_md_layout(
+    "[NH[(1)(2)(3)]]"
+    // target-type + target_info
+    "[TB"
+       "(0,1)[B]"
+       "(16)[FH]"
+       "(17,18)[BB]"
+       "(19,20,21)[]"
+       "(22)[B]"
+       "(23)[H]"
+       "(64,65)[NH[PHOHH]]"
+       "(66)[H]"
+       "(67,68,69,70)[PH]"
+       "(71,72,73,74,75)[PHB]"
+       "()[]]"
+    // target-path
+    "[NB[BB]]"
+    // annotation + element_value
+    MDL2
+    MDL3
+);
+
+  for (i = 0; i < ATTR_CONTEXT_LIMIT; i++) {
+    attr_definitions& ad = attr_defs[i];
+    if (i != ATTR_CONTEXT_CODE) {
+      ad.defineLayout(X_ATTR_RuntimeVisibleAnnotations,
+                      "RuntimeVisibleAnnotations", md_layout_A);
+      ad.defineLayout(X_ATTR_RuntimeInvisibleAnnotations,
+                      "RuntimeInvisibleAnnotations", md_layout_A);
+      if (i == ATTR_CONTEXT_METHOD) {
+        ad.defineLayout(METHOD_ATTR_RuntimeVisibleParameterAnnotations,
+                        "RuntimeVisibleParameterAnnotations", md_layout_P);
+        ad.defineLayout(METHOD_ATTR_RuntimeInvisibleParameterAnnotations,
+                        "RuntimeInvisibleParameterAnnotations", md_layout_P);
+        ad.defineLayout(METHOD_ATTR_AnnotationDefault,
+                        "AnnotationDefault", md_layout_V);
+      }
+    }
+    ad.defineLayout(X_ATTR_RuntimeVisibleTypeAnnotations,
+                    "RuntimeVisibleTypeAnnotations", type_md_layout);
+    ad.defineLayout(X_ATTR_RuntimeInvisibleTypeAnnotations,
+                    "RuntimeInvisibleTypeAnnotations", type_md_layout);
+  }
+
+  attr_definition_headers.readData(attr_definition_count);
+  attr_definition_name.readData(attr_definition_count);
+  attr_definition_layout.readData(attr_definition_count);
+
+  CHECK;
+
+  // Initialize correct predef bits, to distinguish predefs from new defs.
+#define ORBIT(n,s) |((julong)1<<n)
+  attr_defs[ATTR_CONTEXT_CLASS].predef
+    = (0 X_ATTR_DO(ORBIT) CLASS_ATTR_DO(ORBIT));
+  attr_defs[ATTR_CONTEXT_FIELD].predef
+    = (0 X_ATTR_DO(ORBIT) FIELD_ATTR_DO(ORBIT));
+  attr_defs[ATTR_CONTEXT_METHOD].predef
+    = (0 X_ATTR_DO(ORBIT) METHOD_ATTR_DO(ORBIT));
+  attr_defs[ATTR_CONTEXT_CODE].predef
+    = (0 O_ATTR_DO(ORBIT) CODE_ATTR_DO(ORBIT));
+#undef ORBIT
+  // Clear out the redef bits, folding them back into predef.
+  for (i = 0; i < ATTR_CONTEXT_LIMIT; i++) {
+    attr_defs[i].predef |= attr_defs[i].redef;
+    attr_defs[i].redef = 0;
+  }
+
+  // Now read the transmitted locally defined attrs.
+  // This will set redef bits again.
+  for (i = 0; i < attr_definition_count; i++) {
+    int    header  = attr_definition_headers.getByte();
+    int    attrc   = ADH_BYTE_CONTEXT(header);
+    int    idx     = ADH_BYTE_INDEX(header);
+    entry* name    = attr_definition_name.getRef();
+    CHECK;
+    entry* layout  = attr_definition_layout.getRef();
+    CHECK;
+    attr_defs[attrc].defineLayout(idx, name, layout->value.b.strval());
+  }
+}
+
+#define NO_ENTRY_YET ((entry*)-1)
+
+static bool isDigitString(bytes& x, int beg, int end) {
+  if (beg == end)  return false;  // null string
+  byte* xptr = x.ptr;
+  for (int i = beg; i < end; i++) {
+    char ch = xptr[i];
+    if (!(ch >= '0' && ch <= '9'))  return false;
+  }
+  return true;
+}
+
+enum {  // constants for parsing class names
+  SLASH_MIN = '.',
+  SLASH_MAX = '/',
+  DOLLAR_MIN = 0,
+  DOLLAR_MAX = '-'
+};
+
+static int lastIndexOf(int chmin, int chmax, bytes& x, int pos) {
+  byte* ptr = x.ptr;
+  for (byte* cp = ptr + pos; --cp >= ptr; ) {
+    assert(x.inBounds(cp));
+    if (*cp >= chmin && *cp <= chmax)
+      return (int)(cp - ptr);
+  }
+  return -1;
+}
+
+maybe_inline
+inner_class* cpool::getIC(entry* inner) {
+  if (inner == null)  return null;
+  assert(inner->tag == CONSTANT_Class);
+  if (inner->inord == NO_INORD)  return null;
+  inner_class* ic = ic_index[inner->inord];
+  assert(ic == null || ic->inner == inner);
+  return ic;
+}
+
+maybe_inline
+inner_class* cpool::getFirstChildIC(entry* outer) {
+  if (outer == null)  return null;
+  assert(outer->tag == CONSTANT_Class);
+  if (outer->inord == NO_INORD)  return null;
+  inner_class* ic = ic_child_index[outer->inord];
+  assert(ic == null || ic->outer == outer);
+  return ic;
+}
+
+maybe_inline
+inner_class* cpool::getNextChildIC(inner_class* child) {
+  inner_class* ic = child->next_sibling;
+  assert(ic == null || ic->outer == child->outer);
+  return ic;
+}
+
+void unpacker::read_ics() {
+  int i;
+  int index_size = cp.tag_count[CONSTANT_Class];
+  inner_class** ic_index       = U_NEW(inner_class*, index_size);
+  inner_class** ic_child_index = U_NEW(inner_class*, index_size);
+  cp.ic_index = ic_index;
+  cp.ic_child_index = ic_child_index;
+  ics = U_NEW(inner_class, ic_count);
+  ic_this_class.readData(ic_count);
+  ic_flags.readData(ic_count);
+  CHECK;
+  // Scan flags to get count of long-form bands.
+  int long_forms = 0;
+  for (i = 0; i < ic_count; i++) {
+    int flags = ic_flags.getInt();  // may be long form!
+    if ((flags & ACC_IC_LONG_FORM) != 0) {
+      long_forms += 1;
+      ics[i].name = NO_ENTRY_YET;
+    }
+    flags &= ~ACC_IC_LONG_FORM;
+    entry* inner = ic_this_class.getRef();
+    CHECK;
+    uint inord = inner->inord;
+    assert(inord < (uint)cp.tag_count[CONSTANT_Class]);
+    if (ic_index[inord] != null) {
+      abort("identical inner class");
+      break;
+    }
+    ic_index[inord] = &ics[i];
+    ics[i].inner = inner;
+    ics[i].flags = flags;
+    assert(cp.getIC(inner) == &ics[i]);
+  }
+  CHECK;
+  //ic_this_class.done();
+  //ic_flags.done();
+  ic_outer_class.readData(long_forms);
+  ic_name.readData(long_forms);
+  for (i = 0; i < ic_count; i++) {
+    if (ics[i].name == NO_ENTRY_YET) {
+      // Long form.
+      ics[i].outer = ic_outer_class.getRefN();
+      CHECK;
+      ics[i].name  = ic_name.getRefN();
+      CHECK;
+    } else {
+      // Fill in outer and name based on inner.
+      bytes& n = ics[i].inner->value.b;
+      bytes pkgOuter;
+      bytes number;
+      bytes name;
+      // Parse n into pkgOuter and name (and number).
+      PRINTCR((5, "parse short IC name %s", n.ptr));
+      int dollar1, dollar2;  // pointers to $ in the pattern
+      // parse n = (<pkg>/)*<outer>($<number>)?($<name>)?
+      int nlen = (int)n.len;
+      int pkglen = lastIndexOf(SLASH_MIN,  SLASH_MAX,  n, nlen) + 1;
+      dollar2    = lastIndexOf(DOLLAR_MIN, DOLLAR_MAX, n, nlen);
+      if (dollar2 < 0) {
+         abort();
+         return;
+      }
+      assert(dollar2 >= pkglen);
+      if (isDigitString(n, dollar2+1, nlen)) {
+        // n = (<pkg>/)*<outer>$<number>
+        number = n.slice(dollar2+1, nlen);
+        name.set(null,0);
+        dollar1 = dollar2;
+      } else if (pkglen < (dollar1
+                           = lastIndexOf(DOLLAR_MIN, DOLLAR_MAX, n, dollar2-1))
+                 && isDigitString(n, dollar1+1, dollar2)) {
+        // n = (<pkg>/)*<outer>$<number>$<name>
+        number = n.slice(dollar1+1, dollar2);
+        name = n.slice(dollar2+1, nlen);
+      } else {
+        // n = (<pkg>/)*<outer>$<name>
+        dollar1 = dollar2;
+        number.set(null,0);
+        name = n.slice(dollar2+1, nlen);
+      }
+      if (number.ptr == null)
+        pkgOuter = n.slice(0, dollar1);
+      else
+        pkgOuter.set(null,0);
+      PRINTCR((5,"=> %s$ 0%s $%s",
+              pkgOuter.string(), number.string(), name.string()));
+
+      if (pkgOuter.ptr != null)
+        ics[i].outer = cp.ensureClass(pkgOuter);
+
+      if (name.ptr != null)
+        ics[i].name = cp.ensureUtf8(name);
+    }
+
+    // update child/sibling list
+    if (ics[i].outer != null) {
+      uint outord = ics[i].outer->inord;
+      if (outord != NO_INORD) {
+        assert(outord < (uint)cp.tag_count[CONSTANT_Class]);
+        ics[i].next_sibling = ic_child_index[outord];
+        ic_child_index[outord] = &ics[i];
+      }
+    }
+  }
+  //ic_outer_class.done();
+  //ic_name.done();
+}
+
+void unpacker::read_classes() {
+  PRINTCR((1,"  ...scanning %d classes...", class_count));
+  class_this.readData(class_count);
+  class_super.readData(class_count);
+  class_interface_count.readData(class_count);
+  class_interface.readData(class_interface_count.getIntTotal());
+
+  CHECK;
+
+  #if 0
+  int i;
+  // Make a little mark on super-classes.
+  for (i = 0; i < class_count; i++) {
+    entry* e = class_super.getRefN();
+    if (e != null)  e->bits |= entry::EB_SUPER;
+  }
+  class_super.rewind();
+  #endif
+
+  // Members.
+  class_field_count.readData(class_count);
+  class_method_count.readData(class_count);
+
+  CHECK;
+
+  int field_count = class_field_count.getIntTotal();
+  int method_count = class_method_count.getIntTotal();
+
+  field_descr.readData(field_count);
+  read_attrs(ATTR_CONTEXT_FIELD, field_count);
+  CHECK;
+
+  method_descr.readData(method_count);
+  read_attrs(ATTR_CONTEXT_METHOD, method_count);
+
+  CHECK;
+
+  read_attrs(ATTR_CONTEXT_CLASS, class_count);
+  CHECK;
+
+  read_code_headers();
+
+  PRINTCR((1,"scanned %d classes, %d fields, %d methods, %d code headers",
+          class_count, field_count, method_count, code_count));
+}
+
+maybe_inline
+int unpacker::attr_definitions::predefCount(uint idx) {
+  return isPredefined(idx) ? flag_count[idx] : 0;
+}
+
+void unpacker::read_attrs(int attrc, int obj_count) {
+  attr_definitions& ad = attr_defs[attrc];
+  assert(ad.attrc == attrc);
+
+  int i, idx, count;
+
+  CHECK;
+
+  bool haveLongFlags = ad.haveLongFlags();
+
+  band& xxx_flags_hi = ad.xxx_flags_hi();
+  assert(endsWith(xxx_flags_hi.name, "_flags_hi"));
+  if (haveLongFlags)
+    xxx_flags_hi.readData(obj_count);
+  CHECK;
+
+  band& xxx_flags_lo = ad.xxx_flags_lo();
+  assert(endsWith(xxx_flags_lo.name, "_flags_lo"));
+  xxx_flags_lo.readData(obj_count);
+  CHECK;
+
+  // pre-scan flags, counting occurrences of each index bit
+  julong indexMask = ad.flagIndexMask();  // which flag bits are index bits?
+  for (i = 0; i < obj_count; i++) {
+    julong indexBits = xxx_flags_hi.getLong(xxx_flags_lo, haveLongFlags);
+    if ((indexBits & ~indexMask) > (ushort)-1) {
+      abort("undefined attribute flag bit");
+      return;
+    }
+    indexBits &= indexMask;  // ignore classfile flag bits
+    for (idx = 0; indexBits != 0; idx++, indexBits >>= 1) {
+      ad.flag_count[idx] += (int)(indexBits & 1);
+    }
+  }
+  // we'll scan these again later for output:
+  xxx_flags_lo.rewind();
+  xxx_flags_hi.rewind();
+
+  band& xxx_attr_count = ad.xxx_attr_count();
+  assert(endsWith(xxx_attr_count.name, "_attr_count"));
+  // There is one count element for each 1<<16 bit set in flags:
+  xxx_attr_count.readData(ad.predefCount(X_ATTR_OVERFLOW));
+  CHECK;
+
+  band& xxx_attr_indexes = ad.xxx_attr_indexes();
+  assert(endsWith(xxx_attr_indexes.name, "_attr_indexes"));
+  int overflowIndexCount = xxx_attr_count.getIntTotal();
+  xxx_attr_indexes.readData(overflowIndexCount);
+  CHECK;
+  // pre-scan attr indexes, counting occurrences of each value
+  for (i = 0; i < overflowIndexCount; i++) {
+    idx = xxx_attr_indexes.getInt();
+    if (!ad.isIndex(idx)) {
+      abort("attribute index out of bounds");
+      return;
+    }
+    ad.getCount(idx) += 1;
+  }
+  xxx_attr_indexes.rewind();  // we'll scan it again later for output
+
+  // We will need a backward call count for each used backward callable.
+  int backwardCounts = 0;
+  for (idx = 0; idx < ad.layouts.length(); idx++) {
+    layout_definition* lo = ad.getLayout(idx);
+    if (lo != null && ad.getCount(idx) != 0) {
+      // Build the bands lazily, only when they are used.
+      band** bands = ad.buildBands(lo);
+      CHECK;
+      if (lo->hasCallables()) {
+        for (i = 0; bands[i] != null; i++) {
+          if (bands[i]->le_back) {
+            assert(bands[i]->le_kind == EK_CBLE);
+            backwardCounts += 1;
+          }
+        }
+      }
+    }
+  }
+  ad.xxx_attr_calls().readData(backwardCounts);
+  CHECK;
+
+  // Read built-in bands.
+  // Mostly, these are hand-coded equivalents to readBandData().
+  switch (attrc) {
+  case ATTR_CONTEXT_CLASS:
+
+    count = ad.predefCount(CLASS_ATTR_SourceFile);
+    class_SourceFile_RUN.readData(count);
+    CHECK;
+
+    count = ad.predefCount(CLASS_ATTR_EnclosingMethod);
+    class_EnclosingMethod_RC.readData(count);
+    class_EnclosingMethod_RDN.readData(count);
+    CHECK;
+
+    count = ad.predefCount(X_ATTR_Signature);
+    class_Signature_RS.readData(count);
+    CHECK;
+
+    ad.readBandData(X_ATTR_RuntimeVisibleAnnotations);
+    ad.readBandData(X_ATTR_RuntimeInvisibleAnnotations);
+    CHECK;
+
+    count = ad.predefCount(CLASS_ATTR_InnerClasses);
+    class_InnerClasses_N.readData(count);
+    CHECK;
+
+    count = class_InnerClasses_N.getIntTotal();
+    class_InnerClasses_RC.readData(count);
+    class_InnerClasses_F.readData(count);
+    CHECK;
+    // Drop remaining columns wherever flags are zero:
+    count -= class_InnerClasses_F.getIntCount(0);
+    class_InnerClasses_outer_RCN.readData(count);
+    class_InnerClasses_name_RUN.readData(count);
+    CHECK;
+
+    count = ad.predefCount(CLASS_ATTR_ClassFile_version);
+    class_ClassFile_version_minor_H.readData(count);
+    class_ClassFile_version_major_H.readData(count);
+    CHECK;
+
+    ad.readBandData(X_ATTR_RuntimeVisibleTypeAnnotations);
+    ad.readBandData(X_ATTR_RuntimeInvisibleTypeAnnotations);
+    CHECK;
+    break;
+
+  case ATTR_CONTEXT_FIELD:
+
+    count = ad.predefCount(FIELD_ATTR_ConstantValue);
+    field_ConstantValue_KQ.readData(count);
+    CHECK;
+
+    count = ad.predefCount(X_ATTR_Signature);
+    field_Signature_RS.readData(count);
+    CHECK;
+
+    ad.readBandData(X_ATTR_RuntimeVisibleAnnotations);
+    ad.readBandData(X_ATTR_RuntimeInvisibleAnnotations);
+    CHECK;
+
+    ad.readBandData(X_ATTR_RuntimeVisibleTypeAnnotations);
+    ad.readBandData(X_ATTR_RuntimeInvisibleTypeAnnotations);
+    CHECK;
+    break;
+
+  case ATTR_CONTEXT_METHOD:
+
+    code_count = ad.predefCount(METHOD_ATTR_Code);
+    // Code attrs are handled very specially below...
+
+    count = ad.predefCount(METHOD_ATTR_Exceptions);
+    method_Exceptions_N.readData(count);
+    count = method_Exceptions_N.getIntTotal();
+    method_Exceptions_RC.readData(count);
+    CHECK;
+
+    count = ad.predefCount(X_ATTR_Signature);
+    method_Signature_RS.readData(count);
+    CHECK;
+
+    ad.readBandData(X_ATTR_RuntimeVisibleAnnotations);
+    ad.readBandData(X_ATTR_RuntimeInvisibleAnnotations);
+    ad.readBandData(METHOD_ATTR_RuntimeVisibleParameterAnnotations);
+    ad.readBandData(METHOD_ATTR_RuntimeInvisibleParameterAnnotations);
+    ad.readBandData(METHOD_ATTR_AnnotationDefault);
+    CHECK;
+
+    count = ad.predefCount(METHOD_ATTR_MethodParameters);
+    method_MethodParameters_NB.readData(count);
+    count = method_MethodParameters_NB.getIntTotal();
+    method_MethodParameters_name_RUN.readData(count);
+    method_MethodParameters_flag_FH.readData(count);
+    CHECK;
+
+    ad.readBandData(X_ATTR_RuntimeVisibleTypeAnnotations);
+    ad.readBandData(X_ATTR_RuntimeInvisibleTypeAnnotations);
+    CHECK;
+
+    break;
+
+  case ATTR_CONTEXT_CODE:
+    // (keep this code aligned with its brother in unpacker::write_attrs)
+    count = ad.predefCount(CODE_ATTR_StackMapTable);
+    // disable this feature in old archives!
+    if (count != 0 && majver < JAVA6_PACKAGE_MAJOR_VERSION) {
+      abort("undefined StackMapTable attribute (old archive format)");
+      return;
+    }
+    code_StackMapTable_N.readData(count);
+    CHECK;
+    count = code_StackMapTable_N.getIntTotal();
+    code_StackMapTable_frame_T.readData(count);
+    CHECK;
+    // the rest of it depends in a complicated way on frame tags
+    {
+      int fat_frame_count = 0;
+      int offset_count = 0;
+      int type_count = 0;
+      for (int k = 0; k < count; k++) {
+        int tag = code_StackMapTable_frame_T.getByte();
+        if (tag <= 127) {
+          // (64-127)  [(2)]
+          if (tag >= 64)  type_count++;
+        } else if (tag <= 251) {
+          // (247)     [(1)(2)]
+          // (248-251) [(1)]
+          if (tag >= 247)  offset_count++;
+          if (tag == 247)  type_count++;
+        } else if (tag <= 254) {
+          // (252)     [(1)(2)]
+          // (253)     [(1)(2)(2)]
+          // (254)     [(1)(2)(2)(2)]
+          offset_count++;
+          type_count += (tag - 251);
+        } else {
+          // (255)     [(1)NH[(2)]NH[(2)]]
+          fat_frame_count++;
+        }
+      }
+
+      // done pre-scanning frame tags:
+      code_StackMapTable_frame_T.rewind();
+
+      // deal completely with fat frames:
+      offset_count += fat_frame_count;
+      code_StackMapTable_local_N.readData(fat_frame_count);
+      CHECK;
+      type_count += code_StackMapTable_local_N.getIntTotal();
+      code_StackMapTable_stack_N.readData(fat_frame_count);
+      type_count += code_StackMapTable_stack_N.getIntTotal();
+      CHECK;
+      // read the rest:
+      code_StackMapTable_offset.readData(offset_count);
+      code_StackMapTable_T.readData(type_count);
+      CHECK;
+      // (7) [RCH]
+      count = code_StackMapTable_T.getIntCount(7);
+      code_StackMapTable_RC.readData(count);
+      CHECK;
+      // (8) [PH]
+      count = code_StackMapTable_T.getIntCount(8);
+      code_StackMapTable_P.readData(count);
+      CHECK;
+    }
+
+    count = ad.predefCount(CODE_ATTR_LineNumberTable);
+    code_LineNumberTable_N.readData(count);
+    CHECK;
+    count = code_LineNumberTable_N.getIntTotal();
+    code_LineNumberTable_bci_P.readData(count);
+    code_LineNumberTable_line.readData(count);
+    CHECK;
+
+    count = ad.predefCount(CODE_ATTR_LocalVariableTable);
+    code_LocalVariableTable_N.readData(count);
+    CHECK;
+    count = code_LocalVariableTable_N.getIntTotal();
+    code_LocalVariableTable_bci_P.readData(count);
+    code_LocalVariableTable_span_O.readData(count);
+    code_LocalVariableTable_name_RU.readData(count);
+    code_LocalVariableTable_type_RS.readData(count);
+    code_LocalVariableTable_slot.readData(count);
+    CHECK;
+
+    count = ad.predefCount(CODE_ATTR_LocalVariableTypeTable);
+    code_LocalVariableTypeTable_N.readData(count);
+    count = code_LocalVariableTypeTable_N.getIntTotal();
+    code_LocalVariableTypeTable_bci_P.readData(count);
+    code_LocalVariableTypeTable_span_O.readData(count);
+    code_LocalVariableTypeTable_name_RU.readData(count);
+    code_LocalVariableTypeTable_type_RS.readData(count);
+    code_LocalVariableTypeTable_slot.readData(count);
+    CHECK;
+
+    ad.readBandData(X_ATTR_RuntimeVisibleTypeAnnotations);
+    ad.readBandData(X_ATTR_RuntimeInvisibleTypeAnnotations);
+    CHECK;
+
+    break;
+  }
+
+  // Read compressor-defined bands.
+  for (idx = 0; idx < ad.layouts.length(); idx++) {
+    if (ad.getLayout(idx) == null)
+      continue;  // none at this fixed index <32
+    if (idx < (int)ad.flag_limit && ad.isPredefined(idx))
+      continue;  // already handled
+    if (ad.getCount(idx) == 0)
+      continue;  // no attributes of this type (then why transmit layouts?)
+    ad.readBandData(idx);
+  }
+}
+
+void unpacker::attr_definitions::readBandData(int idx) {
+  int j;
+  uint count = getCount(idx);
+  if (count == 0)  return;
+  layout_definition* lo = getLayout(idx);
+  if (lo != null) {
+    PRINTCR((1, "counted %d [redefined = %d predefined = %d] attributes of type %s.%s",
+            count, isRedefined(idx), isPredefined(idx),
+            ATTR_CONTEXT_NAME[attrc], lo->name));
+  }
+  bool hasCallables = lo->hasCallables();
+  band** bands = lo->bands();
+  if (!hasCallables) {
+    // Read through the rest of the bands in a regular way.
+    readBandData(bands, count);
+  } else {
+    // Deal with the callables.
+    // First set up the forward entry count for each callable.
+    // This is stored on band::length of the callable.
+    bands[0]->expectMoreLength(count);
+    for (j = 0; bands[j] != null; j++) {
+      band& j_cble = *bands[j];
+      assert(j_cble.le_kind == EK_CBLE);
+      if (j_cble.le_back) {
+        // Add in the predicted effects of backward calls, too.
+        int back_calls = xxx_attr_calls().getInt();
+        j_cble.expectMoreLength(back_calls);
+        // In a moment, more forward calls may increment j_cble.length.
+      }
+    }
+    // Now consult whichever callables have non-zero entry counts.
+    readBandData(bands, (uint)-1);
+  }
+}
+
+// Recursive helper to the previous function:
+void unpacker::attr_definitions::readBandData(band** body, uint count) {
+  int j, k;
+  for (j = 0; body[j] != null; j++) {
+    band& b = *body[j];
+    if (b.defc != null) {
+      // It has data, so read it.
+      b.readData(count);
+    }
+    switch (b.le_kind) {
+    case EK_REPL:
+      {
+        int reps = b.getIntTotal();
+        readBandData(b.le_body, reps);
+      }
+      break;
+    case EK_UN:
+      {
+        int remaining = count;
+        for (k = 0; b.le_body[k] != null; k++) {
+          band& k_case = *b.le_body[k];
+          int   k_count = 0;
+          if (k_case.le_casetags == null) {
+            k_count = remaining;  // last (empty) case
+          } else {
+            int* tags = k_case.le_casetags;
+            int ntags = *tags++;  // 1st element is length (why not?)
+            while (ntags-- > 0) {
+              int tag = *tags++;
+              k_count += b.getIntCount(tag);
+            }
+          }
+          readBandData(k_case.le_body, k_count);
+          remaining -= k_count;
+        }
+        assert(remaining == 0);
+      }
+      break;
+    case EK_CALL:
+      // Push the count forward, if it is not a backward call.
+      if (!b.le_back) {
+        band& cble = *b.le_body[0];
+        assert(cble.le_kind == EK_CBLE);
+        cble.expectMoreLength(count);
+      }
+      break;
+    case EK_CBLE:
+      assert((int)count == -1);  // incoming count is meaningless
+      k = b.length;
+      assert(k >= 0);
+      // This is intended and required for non production mode.
+      assert((b.length = -1)); // make it unable to accept more calls now.
+      readBandData(b.le_body, k);
+      break;
+    }
+  }
+}
+
+static inline
+band** findMatchingCase(int matchTag, band** cases) {
+  for (int k = 0; cases[k] != null; k++) {
+    band& k_case = *cases[k];
+    if (k_case.le_casetags != null) {
+      // If it has tags, it must match a tag.
+      int* tags = k_case.le_casetags;
+      int ntags = *tags++;  // 1st element is length
+      for (; ntags > 0; ntags--) {
+        int tag = *tags++;
+        if (tag == matchTag)
+          break;
+      }
+      if (ntags == 0)
+        continue;   // does not match
+    }
+    return k_case.le_body;
+  }
+  return null;
+}
+
+// write attribute band data:
+void unpacker::putlayout(band** body) {
+  int i;
+  int prevBII = -1;
+  int prevBCI = -1;
+  if (body == NULL) {
+    abort("putlayout: unexpected NULL for body");
+    return;
+  }
+  for (i = 0; body[i] != null; i++) {
+    band& b = *body[i];
+    byte le_kind = b.le_kind;
+
+    // Handle scalar part, if any.
+    int    x = 0;
+    entry* e = null;
+    if (b.defc != null) {
+      // It has data, so unparse an element.
+      if (b.ixTag != CONSTANT_None) {
+        assert(le_kind == EK_REF);
+        if (b.ixTag == CONSTANT_FieldSpecific)
+          e = b.getRefUsing(cp.getKQIndex());
+        else
+          e = b.getRefN();
+        CHECK;
+        switch (b.le_len) {
+        case 0: break;
+        case 1: putu1ref(e); break;
+        case 2: putref(e); break;
+        case 4: putu2(0); putref(e); break;
+        default: assert(false);
+        }
+      } else {
+        assert(le_kind == EK_INT || le_kind == EK_REPL || le_kind == EK_UN);
+        x = b.getInt();
+
+        assert(!b.le_bci || prevBCI == (int)to_bci(prevBII));
+        switch (b.le_bci) {
+        case EK_BCI:   // PH:  transmit R(bci), store bci
+          x = to_bci(prevBII = x);
+          prevBCI = x;
+          break;
+        case EK_BCID:  // POH: transmit D(R(bci)), store bci
+          x = to_bci(prevBII += x);
+          prevBCI = x;
+          break;
+        case EK_BCO:   // OH:  transmit D(R(bci)), store D(bci)
+          x = to_bci(prevBII += x) - prevBCI;
+          prevBCI += x;
+          break;
+        }
+        assert(!b.le_bci || prevBCI == (int)to_bci(prevBII));
+
+        switch (b.le_len) {
+        case 0: break;
+        case 1: putu1(x); break;
+        case 2: putu2(x); break;
+        case 4: putu4(x); break;
+        default: assert(false);
+        }
+      }
+    }
+
+    // Handle subparts, if any.
+    switch (le_kind) {
+    case EK_REPL:
+      // x is the repeat count
+      while (x-- > 0) {
+        putlayout(b.le_body);
+      }
+      break;
+    case EK_UN:
+      // x is the tag
+      putlayout(findMatchingCase(x, b.le_body));
+      break;
+    case EK_CALL:
+      {
+        band& cble = *b.le_body[0];
+        assert(cble.le_kind == EK_CBLE);
+        assert(cble.le_len == b.le_len);
+        putlayout(cble.le_body);
+      }
+      break;
+
+    #ifndef PRODUCT
+    case EK_CBLE:
+    case EK_CASE:
+      assert(false);  // should not reach here
+    #endif
+    }
+  }
+}
+
+void unpacker::read_files() {
+  file_name.readData(file_count);
+  if (testBit(archive_options, AO_HAVE_FILE_SIZE_HI))
+    file_size_hi.readData(file_count);
+  file_size_lo.readData(file_count);
+  if (testBit(archive_options, AO_HAVE_FILE_MODTIME))
+    file_modtime.readData(file_count);
+  int allFiles = file_count + class_count;
+  if (testBit(archive_options, AO_HAVE_FILE_OPTIONS)) {
+    file_options.readData(file_count);
+    // FO_IS_CLASS_STUB might be set, causing overlap between classes and files
+    for (int i = 0; i < file_count; i++) {
+      if ((file_options.getInt() & FO_IS_CLASS_STUB) != 0) {
+        allFiles -= 1;  // this one counts as both class and file
+      }
+    }
+    file_options.rewind();
+  }
+  assert((default_file_options & FO_IS_CLASS_STUB) == 0);
+  files_remaining = allFiles;
+}
+
+maybe_inline
+void unpacker::get_code_header(int& max_stack,
+                               int& max_na_locals,
+                               int& handler_count,
+                               int& cflags) {
+  int sc = code_headers.getByte();
+  if (sc == 0) {
+    max_stack = max_na_locals = handler_count = cflags = -1;
+    return;
+  }
+  // Short code header is the usual case:
+  int nh;
+  int mod;
+  if (sc < 1 + 12*12) {
+    sc -= 1;
+    nh = 0;
+    mod = 12;
+  } else if (sc < 1 + 12*12 + 8*8) {
+    sc -= 1 + 12*12;
+    nh = 1;
+    mod = 8;
+  } else {
+    assert(sc < 1 + 12*12 + 8*8 + 7*7);
+    sc -= 1 + 12*12 + 8*8;
+    nh = 2;
+    mod = 7;
+  }
+  max_stack     = sc % mod;
+  max_na_locals = sc / mod;  // caller must add static, siglen
+  handler_count = nh;
+  if (testBit(archive_options, AO_HAVE_ALL_CODE_FLAGS))
+    cflags      = -1;
+  else
+    cflags      = 0;  // this one has no attributes
+}
+
+// Cf. PackageReader.readCodeHeaders
+void unpacker::read_code_headers() {
+  code_headers.readData(code_count);
+  CHECK;
+  int totalHandlerCount = 0;
+  int totalFlagsCount   = 0;
+  for (int i = 0; i < code_count; i++) {
+    int max_stack, max_locals, handler_count, cflags;
+    get_code_header(max_stack, max_locals, handler_count, cflags);
+    if (max_stack < 0)      code_max_stack.expectMoreLength(1);
+    if (max_locals < 0)     code_max_na_locals.expectMoreLength(1);
+    if (handler_count < 0)  code_handler_count.expectMoreLength(1);
+    else                    totalHandlerCount += handler_count;
+    if (cflags < 0)         totalFlagsCount += 1;
+  }
+  code_headers.rewind();  // replay later during writing
+
+  code_max_stack.readData();
+  code_max_na_locals.readData();
+  code_handler_count.readData();
+  totalHandlerCount += code_handler_count.getIntTotal();
+  CHECK;
+
+  // Read handler specifications.
+  // Cf. PackageReader.readCodeHandlers.
+  code_handler_start_P.readData(totalHandlerCount);
+  code_handler_end_PO.readData(totalHandlerCount);
+  code_handler_catch_PO.readData(totalHandlerCount);
+  code_handler_class_RCN.readData(totalHandlerCount);
+  CHECK;
+
+  read_attrs(ATTR_CONTEXT_CODE, totalFlagsCount);
+  CHECK;
+}
+
+static inline bool is_in_range(uint n, uint min, uint max) {
+  return n - min <= max - min;  // unsigned arithmetic!
+}
+static inline bool is_field_op(int bc) {
+  return is_in_range(bc, bc_getstatic, bc_putfield);
+}
+static inline bool is_invoke_init_op(int bc) {
+  return is_in_range(bc, _invokeinit_op, _invokeinit_limit-1);
+}
+static inline bool is_self_linker_op(int bc) {
+  return is_in_range(bc, _self_linker_op, _self_linker_limit-1);
+}
+static bool is_branch_op(int bc) {
+  return is_in_range(bc, bc_ifeq,   bc_jsr)
+      || is_in_range(bc, bc_ifnull, bc_jsr_w);
+}
+static bool is_local_slot_op(int bc) {
+  return is_in_range(bc, bc_iload,  bc_aload)
+      || is_in_range(bc, bc_istore, bc_astore)
+      || bc == bc_iinc || bc == bc_ret;
+}
+band* unpacker::ref_band_for_op(int bc) {
+  switch (bc) {
+  case bc_ildc:
+  case bc_ildc_w:
+    return &bc_intref;
+  case bc_fldc:
+  case bc_fldc_w:
+    return &bc_floatref;
+  case bc_lldc2_w:
+    return &bc_longref;
+  case bc_dldc2_w:
+    return &bc_doubleref;
+  case bc_sldc:
+  case bc_sldc_w:
+    return &bc_stringref;
+  case bc_cldc:
+  case bc_cldc_w:
+    return &bc_classref;
+  case bc_qldc: case bc_qldc_w:
+    return &bc_loadablevalueref;
+
+  case bc_getstatic:
+  case bc_putstatic:
+  case bc_getfield:
+  case bc_putfield:
+    return &bc_fieldref;
+
+  case _invokespecial_int:
+  case _invokestatic_int:
+    return &bc_imethodref;
+  case bc_invokevirtual:
+  case bc_invokespecial:
+  case bc_invokestatic:
+    return &bc_methodref;
+  case bc_invokeinterface:
+    return &bc_imethodref;
+  case bc_invokedynamic:
+    return &bc_indyref;
+
+  case bc_new:
+  case bc_anewarray:
+  case bc_checkcast:
+  case bc_instanceof:
+  case bc_multianewarray:
+    return &bc_classref;
+  }
+  return null;
+}
+
+maybe_inline
+band* unpacker::ref_band_for_self_op(int bc, bool& isAloadVar, int& origBCVar) {
+  if (!is_self_linker_op(bc))  return null;
+  int idx = (bc - _self_linker_op);
+  bool isSuper = (idx >= _self_linker_super_flag);
+  if (isSuper)  idx -= _self_linker_super_flag;
+  bool isAload = (idx >= _self_linker_aload_flag);
+  if (isAload)  idx -= _self_linker_aload_flag;
+  int origBC = _first_linker_op + idx;
+  bool isField = is_field_op(origBC);
+  isAloadVar = isAload;
+  origBCVar  = _first_linker_op + idx;
+  if (!isSuper)
+    return isField? &bc_thisfield: &bc_thismethod;
+  else
+    return isField? &bc_superfield: &bc_supermethod;
+}
+
+// Cf. PackageReader.readByteCodes
+inline  // called exactly once => inline
+void unpacker::read_bcs() {
+  PRINTCR((3, "reading compressed bytecodes and operands for %d codes...",
+          code_count));
+
+  // read from bc_codes and bc_case_count
+  fillbytes all_switch_ops;
+  all_switch_ops.init();
+  CHECK;
+
+  // Read directly from rp/rplimit.
+  //Do this later:  bc_codes.readData(...)
+  byte* rp0 = rp;
+
+  band* bc_which;
+  byte* opptr = rp;
+  byte* oplimit = rplimit;
+
+  bool  isAload;  // passed by ref and then ignored
+  int   junkBC;   // passed by ref and then ignored
+  for (int k = 0; k < code_count; k++) {
+    // Scan one method:
+    for (;;) {
+      if (opptr+2 > oplimit) {
+        rp = opptr;
+        ensure_input(2);
+        oplimit = rplimit;
+        rp = rp0;  // back up
+      }
+      if (opptr == oplimit) { abort(); break; }
+      int bc = *opptr++ & 0xFF;
+      bool isWide = false;
+      if (bc == bc_wide) {
+        if (opptr == oplimit) { abort(); break; }
+        bc = *opptr++ & 0xFF;
+        isWide = true;
+      }
+      // Adjust expectations of various band sizes.
+      switch (bc) {
+      case bc_tableswitch:
+      case bc_lookupswitch:
+        all_switch_ops.addByte(bc);
+        break;
+      case bc_iinc:
+        bc_local.expectMoreLength(1);
+        bc_which = isWide ? &bc_short : &bc_byte;
+        bc_which->expectMoreLength(1);
+        break;
+      case bc_sipush:
+        bc_short.expectMoreLength(1);
+        break;
+      case bc_bipush:
+        bc_byte.expectMoreLength(1);
+        break;
+      case bc_newarray:
+        bc_byte.expectMoreLength(1);
+        break;
+      case bc_multianewarray:
+        assert(ref_band_for_op(bc) == &bc_classref);
+        bc_classref.expectMoreLength(1);
+        bc_byte.expectMoreLength(1);
+        break;
+      case bc_ref_escape:
+        bc_escrefsize.expectMoreLength(1);
+        bc_escref.expectMoreLength(1);
+        break;
+      case bc_byte_escape:
+        bc_escsize.expectMoreLength(1);
+        // bc_escbyte will have to be counted too
+        break;
+      default:
+        if (is_invoke_init_op(bc)) {
+          bc_initref.expectMoreLength(1);
+          break;
+        }
+        bc_which = ref_band_for_self_op(bc, isAload, junkBC);
+        if (bc_which != null) {
+          bc_which->expectMoreLength(1);
+          break;
+        }
+        if (is_branch_op(bc)) {
+          bc_label.expectMoreLength(1);
+          break;
+        }
+        bc_which = ref_band_for_op(bc);
+        if (bc_which != null) {
+          bc_which->expectMoreLength(1);
+          assert(bc != bc_multianewarray);  // handled elsewhere
+          break;
+        }
+        if (is_local_slot_op(bc)) {
+          bc_local.expectMoreLength(1);
+          break;
+        }
+        break;
+      case bc_end_marker:
+        // Increment k and test against code_count.
+        goto doneScanningMethod;
+      }
+    }
+  doneScanningMethod:{}
+    if (aborting())  break;
+  }
+
+  // Go through the formality, so we can use it in a regular fashion later:
+  assert(rp == rp0);
+  bc_codes.readData((int)(opptr - rp));
+
+  int i = 0;
+
+  // To size instruction bands correctly, we need info on switches:
+  bc_case_count.readData((int)all_switch_ops.size());
+  for (i = 0; i < (int)all_switch_ops.size(); i++) {
+    int caseCount = bc_case_count.getInt();
+    int bc        = all_switch_ops.getByte(i);
+    bc_label.expectMoreLength(1+caseCount); // default label + cases
+    bc_case_value.expectMoreLength(bc == bc_tableswitch ? 1 : caseCount);
+    PRINTCR((2, "switch bc=%d caseCount=%d", bc, caseCount));
+  }
+  bc_case_count.rewind();  // uses again for output
+
+  all_switch_ops.free();
+
+  for (i = e_bc_case_value; i <= e_bc_escsize; i++) {
+    all_bands[i].readData();
+  }
+
+  // The bc_escbyte band is counted by the immediately previous band.
+  bc_escbyte.readData(bc_escsize.getIntTotal());
+
+  PRINTCR((3, "scanned %d opcode and %d operand bytes for %d codes...",
+          (int)(bc_codes.size()),
+          (int)(bc_escsize.maxRP() - bc_case_value.minRP()),
+          code_count));
+}
+
+void unpacker::read_bands() {
+  byte* rp0 = rp;
+  CHECK;
+  read_file_header();
+  CHECK;
+
+  if (cp.nentries == 0) {
+    // read_file_header failed to read a CP, because it copied a JAR.
+    return;
+  }
+
+  // Do this after the file header has been read:
+  check_options();
+
+  read_cp();
+  CHECK;
+  read_attr_defs();
+  CHECK;
+  read_ics();
+  CHECK;
+  read_classes();
+  CHECK;
+  read_bcs();
+  CHECK;
+  read_files();
+}
+
+/// CP routines
+
+entry*& cpool::hashTabRef(byte tag, bytes& b) {
+  PRINTCR((5, "hashTabRef tag=%d %s[%d]", tag, b.string(), b.len));
+  uint hash = tag + (int)b.len;
+  for (int i = 0; i < (int)b.len; i++) {
+    hash = hash * 31 + (0xFF & b.ptr[i]);
+  }
+  entry**  ht = hashTab;
+  int    hlen = hashTabLength;
+  assert((hlen & (hlen-1)) == 0);  // must be power of 2
+  uint hash1 = hash & (hlen-1);    // == hash % hlen
+  uint hash2 = 0;                  // lazily computed (requires mod op.)
+  int probes = 0;
+  while (ht[hash1] != null) {
+    entry& e = *ht[hash1];
+    if (e.value.b.equals(b) && e.tag == tag)
+      break;
+    if (hash2 == 0)
+      // Note:  hash2 must be relatively prime to hlen, hence the "|1".
+      hash2 = (((hash % 499) & (hlen-1)) | 1);
+    hash1 += hash2;
+    if (hash1 >= (uint)hlen)  hash1 -= hlen;
+    assert(hash1 < (uint)hlen);
+    assert(++probes < hlen);
+  }
+  #ifndef PRODUCT
+  hash_probes[0] += 1;
+  hash_probes[1] += probes;
+  #endif
+  PRINTCR((5, " => @%d %p", hash1, ht[hash1]));
+  return ht[hash1];
+}
+
+maybe_inline
+static void insert_extra(entry* e, ptrlist& extras) {
+  // This ordering helps implement the Pack200 requirement
+  // of a predictable CP order in the class files produced.
+  e->inord = NO_INORD;  // mark as an "extra"
+  extras.add(e);
+  // Note:  We will sort the list (by string-name) later.
+}
+
+entry* cpool::ensureUtf8(bytes& b) {
+  entry*& ix = hashTabRef(CONSTANT_Utf8, b);
+  if (ix != null)  return ix;
+  // Make one.
+  if (nentries == maxentries) {
+    abort("cp utf8 overflow");
+    return &entries[tag_base[CONSTANT_Utf8]];  // return something
+  }
+  entry& e = entries[nentries++];
+  e.tag = CONSTANT_Utf8;
+  u->saveTo(e.value.b, b);
+  assert(&e >= first_extra_entry);
+  insert_extra(&e, tag_extras[CONSTANT_Utf8]);
+  PRINTCR((4,"ensureUtf8 miss %s", e.string()));
+  return ix = &e;
+}
+
+entry* cpool::ensureClass(bytes& b) {
+  entry*& ix = hashTabRef(CONSTANT_Class, b);
+  if (ix != null)  return ix;
+  // Make one.
+  if (nentries == maxentries) {
+    abort("cp class overflow");
+    return &entries[tag_base[CONSTANT_Class]];  // return something
+  }
+  entry& e = entries[nentries++];
+  e.tag = CONSTANT_Class;
+  e.nrefs = 1;
+  e.refs = U_NEW(entry*, 1);
+  ix = &e;  // hold my spot in the index
+  entry* utf = ensureUtf8(b);
+  e.refs[0] = utf;
+  e.value.b = utf->value.b;
+  assert(&e >= first_extra_entry);
+  insert_extra(&e, tag_extras[CONSTANT_Class]);
+  PRINTCR((4,"ensureClass miss %s", e.string()));
+  return &e;
+}
+
+void cpool::expandSignatures() {
+  int i;
+  int nsigs = 0;
+  int nreused = 0;
+  int first_sig = tag_base[CONSTANT_Signature];
+  int sig_limit = tag_count[CONSTANT_Signature] + first_sig;
+  fillbytes buf;
+  buf.init(1<<10);
+  CHECK;
+  for (i = first_sig; i < sig_limit; i++) {
+    entry& e = entries[i];
+    assert(e.tag == CONSTANT_Signature);
+    int refnum = 0;
+    bytes form = e.refs[refnum++]->asUtf8();
+    buf.empty();
+    for (int j = 0; j < (int)form.len; j++) {
+      int c = form.ptr[j];
+      buf.addByte(c);
+      if (c == 'L') {
+        entry* cls = e.refs[refnum++];
+        buf.append(cls->className()->asUtf8());
+      }
+    }
+    assert(refnum == e.nrefs);
+    bytes& sig = buf.b;
+    PRINTCR((5,"signature %d %s -> %s", i, form.ptr, sig.ptr));
+
+    // try to find a pre-existing Utf8:
+    entry* &e2 = hashTabRef(CONSTANT_Utf8, sig);
+    if (e2 != null) {
+      assert(e2->isUtf8(sig));
+      e.value.b = e2->value.b;
+      e.refs[0] = e2;
+      e.nrefs = 1;
+      PRINTCR((5,"signature replaced %d => %s", i, e.string()));
+      nreused++;
+    } else {
+      // there is no other replacement; reuse this CP entry as a Utf8
+      u->saveTo(e.value.b, sig);
+      e.tag = CONSTANT_Utf8;
+      e.nrefs = 0;
+      e2 = &e;
+      PRINTCR((5,"signature changed %d => %s", e.inord, e.string()));
+    }
+    nsigs++;
+  }
+  PRINTCR((1,"expanded %d signatures (reused %d utfs)", nsigs, nreused));
+  buf.free();
+
+  // go expunge all references to remaining signatures:
+  for (i = 0; i < (int)nentries; i++) {
+    entry& e = entries[i];
+    for (int j = 0; j < e.nrefs; j++) {
+      entry*& e2 = e.refs[j];
+      if (e2 != null && e2->tag == CONSTANT_Signature)
+        e2 = e2->refs[0];
+    }
+  }
+}
+
+bool isLoadableValue(int tag) {
+  switch(tag) {
+    case CONSTANT_Integer:
+    case CONSTANT_Float:
+    case CONSTANT_Long:
+    case CONSTANT_Double:
+    case CONSTANT_String:
+    case CONSTANT_Class:
+    case CONSTANT_MethodHandle:
+    case CONSTANT_MethodType:
+      return true;
+    default:
+      return false;
+  }
+}
+/*
+ * this method can be used to size an array using null as the parameter,
+ * thereafter can be reused to initialize the array using a valid pointer
+ * as a parameter.
+ */
+int cpool::initLoadableValues(entry** loadable_entries) {
+  int loadable_count = 0;
+  for (int i = 0; i < (int)N_TAGS_IN_ORDER; i++) {
+    int tag = TAGS_IN_ORDER[i];
+    if (!isLoadableValue(tag))
+      continue;
+    if (loadable_entries != NULL) {
+      for (int n = 0 ; n < tag_count[tag] ; n++) {
+        loadable_entries[loadable_count + n] = &entries[tag_base[tag] + n];
+      }
+    }
+    loadable_count += tag_count[tag];
+  }
+  return loadable_count;
+}
+
+// Initialize various views into the constant pool.
+void cpool::initGroupIndexes() {
+  // Initialize All
+  int all_count = 0;
+  for (int tag = CONSTANT_None ; tag < CONSTANT_Limit ; tag++) {
+    all_count += tag_count[tag];
+  }
+  entry* all_entries = &entries[tag_base[CONSTANT_None]];
+  tag_group_count[CONSTANT_All - CONSTANT_All] = all_count;
+  tag_group_index[CONSTANT_All - CONSTANT_All].init(all_count, all_entries, CONSTANT_All);
+
+  // Initialize LoadableValues
+  int loadable_count = initLoadableValues(NULL);
+  entry** loadable_entries = U_NEW(entry*, loadable_count);
+  initLoadableValues(loadable_entries);
+  tag_group_count[CONSTANT_LoadableValue - CONSTANT_All] = loadable_count;
+  tag_group_index[CONSTANT_LoadableValue - CONSTANT_All].init(loadable_count,
+                  loadable_entries, CONSTANT_LoadableValue);
+
+// Initialize AnyMembers
+  int any_count = tag_count[CONSTANT_Fieldref] +
+                  tag_count[CONSTANT_Methodref] +
+                  tag_count[CONSTANT_InterfaceMethodref];
+  entry *any_entries = &entries[tag_base[CONSTANT_Fieldref]];
+  tag_group_count[CONSTANT_AnyMember - CONSTANT_All] = any_count;
+  tag_group_index[CONSTANT_AnyMember - CONSTANT_All].init(any_count,
+                                               any_entries, CONSTANT_AnyMember);
+}
+
+void cpool::initMemberIndexes() {
+  // This function does NOT refer to any class schema.
+  // It is totally internal to the cpool.
+  int i, j;
+
+  // Get the pre-existing indexes:
+  int   nclasses = tag_count[CONSTANT_Class];
+  entry* classes = tag_base[CONSTANT_Class] + entries;
+  int   nfields  = tag_count[CONSTANT_Fieldref];
+  entry* fields  = tag_base[CONSTANT_Fieldref] + entries;
+  int   nmethods = tag_count[CONSTANT_Methodref];
+  entry* methods = tag_base[CONSTANT_Methodref] + entries;
+
+  int*     field_counts  = T_NEW(int, nclasses);
+  int*     method_counts = T_NEW(int, nclasses);
+  cpindex* all_indexes   = U_NEW(cpindex, nclasses*2);
+  entry**  field_ix      = U_NEW(entry*, add_size(nfields, nclasses));
+  entry**  method_ix     = U_NEW(entry*, add_size(nmethods, nclasses));
+
+  for (j = 0; j < nfields; j++) {
+    entry& f = fields[j];
+    i = f.memberClass()->inord;
+    assert(i < nclasses);
+    field_counts[i]++;
+  }
+  for (j = 0; j < nmethods; j++) {
+    entry& m = methods[j];
+    i = m.memberClass()->inord;
+    assert(i < nclasses);
+    method_counts[i]++;
+  }
+
+  int fbase = 0, mbase = 0;
+  for (i = 0; i < nclasses; i++) {
+    int fc = field_counts[i];
+    int mc = method_counts[i];
+    all_indexes[i*2+0].init(fc, field_ix+fbase,
+                            CONSTANT_Fieldref  + SUBINDEX_BIT);
+    all_indexes[i*2+1].init(mc, method_ix+mbase,
+                            CONSTANT_Methodref + SUBINDEX_BIT);
+    // reuse field_counts and member_counts as fill pointers:
+    field_counts[i] = fbase;
+    method_counts[i] = mbase;
+    PRINTCR((3, "class %d fields @%d[%d] methods @%d[%d]",
+            i, fbase, fc, mbase, mc));
+    fbase += fc+1;
+    mbase += mc+1;
+    // (the +1 leaves a space between every subarray)
+  }
+  assert(fbase == nfields+nclasses);
+  assert(mbase == nmethods+nclasses);
+
+  for (j = 0; j < nfields; j++) {
+    entry& f = fields[j];
+    i = f.memberClass()->inord;
+    field_ix[field_counts[i]++] = &f;
+  }
+  for (j = 0; j < nmethods; j++) {
+    entry& m = methods[j];
+    i = m.memberClass()->inord;
+    method_ix[method_counts[i]++] = &m;
+  }
+
+  member_indexes = all_indexes;
+
+#ifndef PRODUCT
+  // Test the result immediately on every class and field.
+  int fvisited = 0, mvisited = 0;
+  int prevord, len;
+  for (i = 0; i < nclasses; i++) {
+    entry*   cls = &classes[i];
+    cpindex* fix = getFieldIndex(cls);
+    cpindex* mix = getMethodIndex(cls);
+    PRINTCR((2, "field and method index for %s [%d] [%d]",
+            cls->string(), mix->len, fix->len));
+    prevord = -1;
+    for (j = 0, len = fix->len; j < len; j++) {
+      entry* f = fix->get(j);
+      assert(f != null);
+      PRINTCR((3, "- field %s", f->string()));
+      assert(f->memberClass() == cls);
+      assert(prevord < (int)f->inord);
+      prevord = f->inord;
+      fvisited++;
+    }
+    assert(fix->base2[j] == null);
+    prevord = -1;
+    for (j = 0, len = mix->len; j < len; j++) {
+      entry* m = mix->get(j);
+      assert(m != null);
+      PRINTCR((3, "- method %s", m->string()));
+      assert(m->memberClass() == cls);
+      assert(prevord < (int)m->inord);
+      prevord = m->inord;
+      mvisited++;
+    }
+    assert(mix->base2[j] == null);
+  }
+  assert(fvisited == nfields);
+  assert(mvisited == nmethods);
+#endif
+
+  // Free intermediate buffers.
+  u->free_temps();
+}
+
+void entry::requestOutputIndex(cpool& cp, int req) {
+  assert(outputIndex <= REQUESTED_NONE);  // must not have assigned indexes yet
+  if (tag == CONSTANT_Signature) {
+    ref(0)->requestOutputIndex(cp, req);
+    return;
+  }
+  assert(req == REQUESTED || req == REQUESTED_LDC);
+  if (outputIndex != REQUESTED_NONE) {
+    if (req == REQUESTED_LDC)
+      outputIndex = req;  // this kind has precedence
+    return;
+  }
+  outputIndex = req;
+  //assert(!cp.outputEntries.contains(this));
+  assert(tag != CONSTANT_Signature);
+  // The BSMs are jetisoned to a side table, however all references
+  // that the BSMs refer to,  need to be considered.
+  if (tag == CONSTANT_BootstrapMethod) {
+    // this is a a pseudo-op entry; an attribute will be generated later on
+    cp.requested_bsms.add(this);
+  } else {
+    // all other tag types go into real output file CP:
+    cp.outputEntries.add(this);
+  }
+  for (int j = 0; j < nrefs; j++) {
+    ref(j)->requestOutputIndex(cp);
+  }
+}
+
+void cpool::resetOutputIndexes() {
+    /*
+     * reset those few entries that are being used in the current class
+     * (Caution since this method is called after every class written, a loop
+     * over every global constant pool entry would be a quadratic cost.)
+     */
+
+  int noes    = outputEntries.length();
+  entry** oes = (entry**) outputEntries.base();
+  for (int i = 0 ; i < noes ; i++) {
+    entry& e = *oes[i];
+    e.outputIndex = REQUESTED_NONE;
+  }
+
+  // do the same for bsms and reset them if required
+  int nbsms = requested_bsms.length();
+  entry** boes = (entry**) requested_bsms.base();
+  for (int i = 0 ; i < nbsms ; i++) {
+    entry& e = *boes[i];
+    e.outputIndex = REQUESTED_NONE;
+  }
+  outputIndexLimit = 0;
+  outputEntries.empty();
+#ifndef PRODUCT
+  // ensure things are cleared out
+  for (int i = 0; i < (int)maxentries; i++)
+    assert(entries[i].outputIndex == REQUESTED_NONE);
+#endif
+}
+
+static const byte TAG_ORDER[CONSTANT_Limit] = {
+  0, 1, 0, 2, 3, 4, 5, 7, 6, 10, 11, 12, 9, 8, 0, 13, 14, 15, 16
+};
+
+extern "C"
+int outputEntry_cmp(const void* e1p, const void* e2p) {
+  // Sort entries according to the Pack200 rules for deterministic
+  // constant pool ordering.
+  //
+  // The four sort keys as follows, in order of decreasing importance:
+  //   1. ldc first, then non-ldc guys
+  //   2. normal cp_All entries by input order (i.e., address order)
+  //   3. after that, extra entries by lexical order (as in tag_extras[*])
+  entry& e1 = *(entry*) *(void**) e1p;
+  entry& e2 = *(entry*) *(void**) e2p;
+  int   oi1 = e1.outputIndex;
+  int   oi2 = e2.outputIndex;
+  assert(oi1 == REQUESTED || oi1 == REQUESTED_LDC);
+  assert(oi2 == REQUESTED || oi2 == REQUESTED_LDC);
+  if (oi1 != oi2) {
+    if (oi1 == REQUESTED_LDC)  return 0-1;
+    if (oi2 == REQUESTED_LDC)  return 1-0;
+    // Else fall through; neither is an ldc request.
+  }
+  if (e1.inord != NO_INORD || e2.inord != NO_INORD) {
+    // One or both is normal.  Use input order.
+    if (&e1 > &e2)  return 1-0;
+    if (&e1 < &e2)  return 0-1;
+    return 0;  // equal pointers
+  }
+  // Both are extras.  Sort by tag and then by value.
+  if (e1.tag != e2.tag) {
+    return TAG_ORDER[e1.tag] - TAG_ORDER[e2.tag];
+  }
+  // If the tags are the same, use string comparison.
+  return compare_Utf8_chars(e1.value.b, e2.value.b);
+}
+
+void cpool::computeOutputIndexes() {
+  int i;
+
+#ifndef PRODUCT
+  // outputEntries must be a complete list of those requested:
+  static uint checkStart = 0;
+  int checkStep = 1;
+  if (nentries > 100)  checkStep = nentries / 100;
+  for (i = (int)(checkStart++ % checkStep); i < (int)nentries; i += checkStep) {
+    entry& e = entries[i];
+    if (e.tag == CONSTANT_BootstrapMethod) {
+      if (e.outputIndex != REQUESTED_NONE) {
+        assert(requested_bsms.contains(&e));
+      } else {
+        assert(!requested_bsms.contains(&e));
+      }
+    } else {
+      if (e.outputIndex != REQUESTED_NONE) {
+        assert(outputEntries.contains(&e));
+      } else {
+        assert(!outputEntries.contains(&e));
+      }
+    }
+  }
+
+  // check hand-initialization of TAG_ORDER
+  for (i = 0; i < (int)N_TAGS_IN_ORDER; i++) {
+    byte tag = TAGS_IN_ORDER[i];
+    assert(TAG_ORDER[tag] == i+1);
+  }
+#endif
+
+  int    noes =           outputEntries.length();
+  entry** oes = (entry**) outputEntries.base();
+
+  // Sort the output constant pool into the order required by Pack200.
+  PTRLIST_QSORT(outputEntries, outputEntry_cmp);
+
+  // Allocate a new index for each entry that needs one.
+  // We do this in two passes, one for LDC entries and one for the rest.
+  int nextIndex = 1;  // always skip index #0 in output cpool
+  for (i = 0; i < noes; i++) {
+    entry& e = *oes[i];
+    assert(e.outputIndex >= REQUESTED_LDC);
+    e.outputIndex = nextIndex++;
+    if (e.isDoubleWord())  nextIndex++;  // do not use the next index
+  }
+  outputIndexLimit = nextIndex;
+  PRINTCR((3,"renumbering CP to %d entries", outputIndexLimit));
+}
+
+#ifndef PRODUCT
+// debugging goo
+
+unpacker* debug_u;
+
+static bytes& getbuf(int len) {  // for debugging only!
+  static int bn = 0;
+  static bytes bufs[8];
+  bytes& buf = bufs[bn++ & 7];
+  while ((int)buf.len < len+10)
+    buf.realloc(buf.len ? buf.len * 2 : 1000);
+  buf.ptr[0] = 0;  // for the sake of strcat
+  return buf;
+}
+
+char* entry::string() {
+  bytes buf;
+  switch (tag) {
+  case CONSTANT_None:
+    return (char*)"<empty>";
+  case CONSTANT_Signature:
+    if (value.b.ptr == null)
+      return ref(0)->string();
+    // else fall through:
+  case CONSTANT_Utf8:
+    buf = value.b;
+    break;
+  case CONSTANT_Integer:
+  case CONSTANT_Float:
+    buf = getbuf(12);
+    sprintf((char*)buf.ptr, "0x%08x", value.i);
+    break;
+  case CONSTANT_Long:
+  case CONSTANT_Double:
+    buf = getbuf(24);
+    sprintf((char*)buf.ptr, "0x" LONG_LONG_HEX_FORMAT, value.l);
+    break;
+  default:
+    if (nrefs == 0) {
+      buf = getbuf(20);
+      sprintf((char*)buf.ptr, TAG_NAME[tag]);
+    } else if (nrefs == 1) {
+      return refs[0]->string();
+    } else {
+      char* s1 = refs[0]->string();
+      char* s2 = refs[1]->string();
+      buf = getbuf((int)strlen(s1) + 1 + (int)strlen(s2) + 4 + 1);
+      buf.strcat(s1).strcat(" ").strcat(s2);
+      if (nrefs > 2)  buf.strcat(" ...");
+    }
+  }
+  return (char*)buf.ptr;
+}
+
+void print_cp_entry(int i) {
+  entry& e = debug_u->cp.entries[i];
+  char buf[30];
+  sprintf(buf, ((uint)e.tag < CONSTANT_Limit)? TAG_NAME[e.tag]: "%d", e.tag);
+  printf(" %d\t%s %s\n", i, buf, e.string());
+}
+
+void print_cp_entries(int beg, int end) {
+  for (int i = beg; i < end; i++)
+    print_cp_entry(i);
+}
+
+void print_cp() {
+  print_cp_entries(0, debug_u->cp.nentries);
+}
+
+#endif
+
+// Unpacker Start
+
+const char str_tf[] = "true\0false";
+#undef STR_TRUE
+#undef STR_FALSE
+#define STR_TRUE   (&str_tf[0])
+#define STR_FALSE  (&str_tf[5])
+
+const char* unpacker::get_option(const char* prop) {
+  if (prop == null )  return null;
+  if (strcmp(prop, UNPACK_DEFLATE_HINT) == 0) {
+    return deflate_hint_or_zero == 0? null : STR_TF(deflate_hint_or_zero > 0);
+#ifdef HAVE_STRIP
+  } else if (strcmp(prop, UNPACK_STRIP_COMPILE) == 0) {
+    return STR_TF(strip_compile);
+  } else if (strcmp(prop, UNPACK_STRIP_DEBUG) == 0) {
+    return STR_TF(strip_debug);
+  } else if (strcmp(prop, UNPACK_STRIP_JCOV) == 0) {
+    return STR_TF(strip_jcov);
+#endif /*HAVE_STRIP*/
+  } else if (strcmp(prop, UNPACK_REMOVE_PACKFILE) == 0) {
+    return STR_TF(remove_packfile);
+  } else if (strcmp(prop, DEBUG_VERBOSE) == 0) {
+    return saveIntStr(verbose);
+  } else if (strcmp(prop, UNPACK_MODIFICATION_TIME) == 0) {
+    return (modification_time_or_zero == 0)? null:
+      saveIntStr(modification_time_or_zero);
+  } else if (strcmp(prop, UNPACK_LOG_FILE) == 0) {
+    return log_file;
+  } else {
+    return NULL; // unknown option ignore
+  }
+}
+
+bool unpacker::set_option(const char* prop, const char* value) {
+  if (prop == NULL)  return false;
+  if (strcmp(prop, UNPACK_DEFLATE_HINT) == 0) {
+    deflate_hint_or_zero = ( (value == null || strcmp(value, "keep") == 0)
+                                ? 0: BOOL_TF(value) ? +1: -1);
+#ifdef HAVE_STRIP
+  } else if (strcmp(prop, UNPACK_STRIP_COMPILE) == 0) {
+    strip_compile = STR_TF(value);
+  } else if (strcmp(prop, UNPACK_STRIP_DEBUG) == 0) {
+    strip_debug = STR_TF(value);
+  } else if (strcmp(prop, UNPACK_STRIP_JCOV) == 0) {
+    strip_jcov = STR_TF(value);
+#endif /*HAVE_STRIP*/
+  } else if (strcmp(prop, UNPACK_REMOVE_PACKFILE) == 0) {
+    remove_packfile = STR_TF(value);
+  } else if (strcmp(prop, DEBUG_VERBOSE) == 0) {
+    verbose = (value == null)? 0: atoi(value);
+  } else if (strcmp(prop, DEBUG_VERBOSE ".bands") == 0) {
+#ifndef PRODUCT
+    verbose_bands = (value == null)? 0: atoi(value);
+#endif
+  } else if (strcmp(prop, UNPACK_MODIFICATION_TIME) == 0) {
+    if (value == null || (strcmp(value, "keep") == 0)) {
+      modification_time_or_zero = 0;
+    } else if (strcmp(value, "now") == 0) {
+      time_t now;
+      time(&now);
+      modification_time_or_zero = (int) now;
+    } else {
+      modification_time_or_zero = atoi(value);
+      if (modification_time_or_zero == 0)
+        modification_time_or_zero = 1;  // make non-zero
+    }
+  } else if (strcmp(prop, UNPACK_LOG_FILE) == 0) {
+    log_file = (value == null)? value: saveStr(value);
+  } else {
+    return false; // unknown option ignore
+  }
+  return true;
+}
+
+// Deallocate all internal storage and reset to a clean state.
+// Do not disturb any input or output connections, including
+// infileptr, infileno, inbytes, read_input_fn, jarout, or errstrm.
+// Do not reset any unpack options.
+void unpacker::reset() {
+  bytes_read_before_reset      += bytes_read;
+  bytes_written_before_reset   += bytes_written;
+  files_written_before_reset   += files_written;
+  classes_written_before_reset += classes_written;
+  segments_read_before_reset   += 1;
+  if (verbose >= 2) {
+    fprintf(errstrm,
+            "After segment %d, "
+            LONG_LONG_FORMAT " bytes read and "
+            LONG_LONG_FORMAT " bytes written.\n",
+            segments_read_before_reset-1,
+            bytes_read_before_reset, bytes_written_before_reset);
+    fprintf(errstrm,
+            "After segment %d, %d files (of which %d are classes) written to output.\n",
+            segments_read_before_reset-1,
+            files_written_before_reset, classes_written_before_reset);
+    if (archive_next_count != 0) {
+      fprintf(errstrm,
+              "After segment %d, %d segment%s remaining (estimated).\n",
+              segments_read_before_reset-1,
+              archive_next_count, archive_next_count==1?"":"s");
+    }
+  }
+
+  unpacker save_u = (*this);  // save bytewise image
+  infileptr = null;  // make asserts happy
+  jniobj = null;  // make asserts happy
+  jarout = null;  // do not close the output jar
+  gzin = null;  // do not close the input gzip stream
+  bytes esn;
+  if (errstrm_name != null) {
+    esn.saveFrom(errstrm_name);
+  } else {
+    esn.set(null, 0);
+  }
+  this->free();
+  mtrace('s', 0, 0);  // note the boundary between segments
+  this->init(read_input_fn);
+
+  // restore selected interface state:
+#define SAVE(x) this->x = save_u.x
+  SAVE(jniobj);
+  SAVE(jnienv);
+  SAVE(infileptr);  // buffered
+  SAVE(infileno);   // unbuffered
+  SAVE(inbytes);    // direct
+  SAVE(jarout);
+  SAVE(gzin);
+  //SAVE(read_input_fn);
+  SAVE(errstrm);
+  SAVE(verbose);  // verbose level, 0 means no output
+  SAVE(strip_compile);
+  SAVE(strip_debug);
+  SAVE(strip_jcov);
+  SAVE(remove_packfile);
+  SAVE(deflate_hint_or_zero);  // ==0 means not set, otherwise -1 or 1
+  SAVE(modification_time_or_zero);
+  SAVE(bytes_read_before_reset);
+  SAVE(bytes_written_before_reset);
+  SAVE(files_written_before_reset);
+  SAVE(classes_written_before_reset);
+  SAVE(segments_read_before_reset);
+#undef SAVE
+  if (esn.len > 0) {
+    errstrm_name = saveStr(esn.strval());
+    esn.free();
+  }
+  log_file = errstrm_name;
+  // Note:  If we use strip_names, watch out:  They get nuked here.
+}
+
+void unpacker::init(read_input_fn_t input_fn) {
+  int i;
+  NOT_PRODUCT(debug_u = this);
+  BYTES_OF(*this).clear();
+#ifndef PRODUCT
+  free();  // just to make sure freeing is idempotent
+#endif
+  this->u = this;    // self-reference for U_NEW macro
+  errstrm = stdout;  // default error-output
+  log_file = LOGFILE_STDOUT;
+  read_input_fn = input_fn;
+  all_bands = band::makeBands(this);
+  // Make a default jar buffer; caller may safely overwrite it.
+  jarout = U_NEW(jar, 1);
+  jarout->init(this);
+  for (i = 0; i < ATTR_CONTEXT_LIMIT; i++)
+    attr_defs[i].u = u;  // set up outer ptr
+}
+
+const char* unpacker::get_abort_message() {
+   return abort_message;
+}
+
+void unpacker::dump_options() {
+  static const char* opts[] = {
+    UNPACK_LOG_FILE,
+    UNPACK_DEFLATE_HINT,
+#ifdef HAVE_STRIP
+    UNPACK_STRIP_COMPILE,
+    UNPACK_STRIP_DEBUG,
+    UNPACK_STRIP_JCOV,
+#endif /*HAVE_STRIP*/
+    UNPACK_REMOVE_PACKFILE,
+    DEBUG_VERBOSE,
+    UNPACK_MODIFICATION_TIME,
+    null
+  };
+  for (int i = 0; opts[i] != null; i++) {
+    const char* str = get_option(opts[i]);
+    if (str == null) {
+      if (verbose == 0)  continue;
+      str = "(not set)";
+    }
+    fprintf(errstrm, "%s=%s\n", opts[i], str);
+  }
+}
+
+
+// Usage: unpack a byte buffer
+// packptr is a reference to byte buffer containing a
+// packed file and len is the length of the buffer.
+// If null, the callback is used to fill an internal buffer.
+void unpacker::start(void* packptr, size_t len) {
+  CHECK;
+  NOT_PRODUCT(debug_u = this);
+  if (packptr != null && len != 0) {
+    inbytes.set((byte*) packptr, len);
+  }
+  CHECK;
+  read_bands();
+}
+
+void unpacker::check_options() {
+  const char* strue  = "true";
+  const char* sfalse = "false";
+  if (deflate_hint_or_zero != 0) {
+    bool force_deflate_hint = (deflate_hint_or_zero > 0);
+    if (force_deflate_hint)
+      default_file_options |= FO_DEFLATE_HINT;
+    else
+      default_file_options &= ~FO_DEFLATE_HINT;
+    // Turn off per-file deflate hint by force.
+    suppress_file_options |= FO_DEFLATE_HINT;
+  }
+  if (modification_time_or_zero != 0) {
+    default_file_modtime = modification_time_or_zero;
+    // Turn off per-file modtime by force.
+    archive_options &= ~AO_HAVE_FILE_MODTIME;
+  }
+  // %%% strip_compile, etc...
+}
+
+// classfile writing
+
+void unpacker::reset_cur_classfile() {
+  // set defaults
+  cur_class_minver = default_class_minver;
+  cur_class_majver = default_class_majver;
+
+  // reset constant pool state
+  cp.resetOutputIndexes();
+
+  // reset fixups
+  class_fixup_type.empty();
+  class_fixup_offset.empty();
+  class_fixup_ref.empty();
+  requested_ics.empty();
+  cp.requested_bsms.empty();
+}
+
+cpindex* cpool::getKQIndex() {
+  char ch = '?';
+  if (u->cur_descr != null) {
+    entry* type = u->cur_descr->descrType();
+    ch = type->value.b.ptr[0];
+  }
+  byte tag = CONSTANT_Integer;
+  switch (ch) {
+  case 'L': tag = CONSTANT_String;   break;
+  case 'I': tag = CONSTANT_Integer;  break;
+  case 'J': tag = CONSTANT_Long;     break;
+  case 'F': tag = CONSTANT_Float;    break;
+  case 'D': tag = CONSTANT_Double;   break;
+  case 'B': case 'S': case 'C':
+  case 'Z': tag = CONSTANT_Integer;  break;
+  default:  abort("bad KQ reference"); break;
+  }
+  return getIndex(tag);
+}
+
+uint unpacker::to_bci(uint bii) {
+  uint  len =         bcimap.length();
+  uint* map = (uint*) bcimap.base();
+  assert(len > 0);  // must be initialized before using to_bci
+  if (bii < len)
+    return map[bii];
+  // Else it's a fractional or out-of-range BCI.
+  uint key = bii-len;
+  for (int i = len; ; i--) {
+    if (map[i-1]-(i-1) <= key)
+      break;
+    else
+      --bii;
+  }
+  return bii;
+}
+
+void unpacker::put_stackmap_type() {
+  int tag = code_StackMapTable_T.getByte();
+  putu1(tag);
+  switch (tag) {
+  case 7: // (7) [RCH]
+    putref(code_StackMapTable_RC.getRef());
+    break;
+  case 8: // (8) [PH]
+    putu2(to_bci(code_StackMapTable_P.getInt()));
+    break;
+  }
+}
+
+// Functions for writing code.
+
+maybe_inline
+void unpacker::put_label(int curIP, int size) {
+  code_fixup_type.addByte(size);
+  code_fixup_offset.add((int)put_empty(size));
+  code_fixup_source.add(curIP);
+}
+
+inline  // called exactly once => inline
+void unpacker::write_bc_ops() {
+  bcimap.empty();
+  code_fixup_type.empty();
+  code_fixup_offset.empty();
+  code_fixup_source.empty();
+
+  band* bc_which;
+
+  byte*  opptr = bc_codes.curRP();
+  // No need for oplimit, since the codes are pre-counted.
+
+  size_t codeBase = wpoffset();
+
+  bool   isAload;  // copy-out result
+  int    origBC;
+
+  entry* thisClass  = cur_class;
+  entry* superClass = cur_super;
+  entry* newClass   = null;  // class of last _new opcode
+
+  // overwrite any prior index on these bands; it changes w/ current class:
+  bc_thisfield.setIndex(    cp.getFieldIndex( thisClass));
+  bc_thismethod.setIndex(   cp.getMethodIndex(thisClass));
+  if (superClass != null) {
+    bc_superfield.setIndex( cp.getFieldIndex( superClass));
+    bc_supermethod.setIndex(cp.getMethodIndex(superClass));
+  } else {
+    NOT_PRODUCT(bc_superfield.setIndex(null));
+    NOT_PRODUCT(bc_supermethod.setIndex(null));
+  }
+  CHECK;
+
+  for (int curIP = 0; ; curIP++) {
+    int curPC = (int)(wpoffset() - codeBase);
+    bcimap.add(curPC);
+    ensure_put_space(10);  // covers most instrs w/o further bounds check
+    int bc = *opptr++ & 0xFF;
+
+    putu1_fast(bc);
+    // Note:  See '--wp' below for pseudo-bytecodes like bc_end_marker.
+
+    bool isWide = false;
+    if (bc == bc_wide) {
+      bc = *opptr++ & 0xFF;
+      putu1_fast(bc);
+      isWide = true;
+    }
+    switch (bc) {
+    case bc_end_marker:
+      --wp;  // not really part of the code
+      assert(opptr <= bc_codes.maxRP());
+      bc_codes.curRP() = opptr;  // advance over this in bc_codes
+      goto doneScanningMethod;
+    case bc_tableswitch: // apc:  (df, lo, hi, (hi-lo+1)*(label))
+    case bc_lookupswitch: // apc:  (df, nc, nc*(case, label))
+      {
+        int caseCount = bc_case_count.getInt();
+        while (((wpoffset() - codeBase) % 4) != 0)  putu1_fast(0);
+        ensure_put_space(30 + caseCount*8);
+        put_label(curIP, 4);  //int df = bc_label.getInt();
+        if (bc == bc_tableswitch) {
+          int lo = bc_case_value.getInt();
+          int hi = lo + caseCount-1;
+          putu4(lo);
+          putu4(hi);
+          for (int j = 0; j < caseCount; j++) {
+            put_label(curIP, 4); //int lVal = bc_label.getInt();
+            //int cVal = lo + j;
+          }
+        } else {
+          putu4(caseCount);
+          for (int j = 0; j < caseCount; j++) {
+            int cVal = bc_case_value.getInt();
+            putu4(cVal);
+            put_label(curIP, 4); //int lVal = bc_label.getInt();
+          }
+        }
+        assert((int)to_bci(curIP) == curPC);
+        continue;
+      }
+    case bc_iinc:
+      {
+        int local = bc_local.getInt();
+        int delta = (isWide ? bc_short : bc_byte).getInt();
+        if (isWide) {
+          putu2(local);
+          putu2(delta);
+        } else {
+          putu1_fast(local);
+          putu1_fast(delta);
+        }
+        continue;
+      }
+    case bc_sipush:
+      {
+        int val = bc_short.getInt();
+        putu2(val);
+        continue;
+      }
+    case bc_bipush:
+    case bc_newarray:
+      {
+        int val = bc_byte.getByte();
+        putu1_fast(val);
+        continue;
+      }
+    case bc_ref_escape:
+      {
+        // Note that insnMap has one entry for this.
+        --wp;  // not really part of the code
+        int size = bc_escrefsize.getInt();
+        entry* ref = bc_escref.getRefN();
+        CHECK;
+        switch (size) {
+        case 1: putu1ref(ref); break;
+        case 2: putref(ref);   break;
+        default: assert(false);
+        }
+        continue;
+      }
+    case bc_byte_escape:
+      {
+        // Note that insnMap has one entry for all these bytes.
+        --wp;  // not really part of the code
+        int size = bc_escsize.getInt();
+        ensure_put_space(size);
+        for (int j = 0; j < size; j++)
+          putu1_fast(bc_escbyte.getByte());
+        continue;
+      }
+    default:
+      if (is_invoke_init_op(bc)) {
+        origBC = bc_invokespecial;
+        entry* classRef;
+        switch (bc - _invokeinit_op) {
+        case _invokeinit_self_option:   classRef = thisClass;  break;
+        case _invokeinit_super_option:  classRef = superClass; break;
+        default: assert(bc == _invokeinit_op+_invokeinit_new_option);
+        case _invokeinit_new_option:    classRef = newClass;   break;
+        }
+        wp[-1] = origBC;  // overwrite with origBC
+        int coding = bc_initref.getInt();
+        // Find the nth overloading of <init> in classRef.
+        entry*   ref = null;
+        cpindex* ix = cp.getMethodIndex(classRef);
+        CHECK;
+        for (int j = 0, which_init = 0; ; j++) {
+          ref = (ix == null)? null: ix->get(j);
+          if (ref == null)  break;  // oops, bad input
+          assert(ref->tag == CONSTANT_Methodref);
+          if (ref->memberDescr()->descrName() == cp.sym[cpool::s_lt_init_gt]) {
+            if (which_init++ == coding)  break;
+          }
+        }
+        putref(ref);
+        continue;
+      }
+      bc_which = ref_band_for_self_op(bc, isAload, origBC);
+      if (bc_which != null) {
+        if (!isAload) {
+          wp[-1] = origBC;  // overwrite with origBC
+        } else {
+          wp[-1] = bc_aload_0;  // overwrite with _aload_0
+          // Note: insnMap keeps the _aload_0 separate.
+          bcimap.add(++curPC);
+          ++curIP;
+          putu1_fast(origBC);
+        }
+        entry* ref = bc_which->getRef();
+        CHECK;
+        putref(ref);
+        continue;
+      }
+      if (is_branch_op(bc)) {
+        //int lVal = bc_label.getInt();
+        if (bc < bc_goto_w) {
+          put_label(curIP, 2);  //putu2(lVal & 0xFFFF);
+        } else {
+          assert(bc <= bc_jsr_w);
+          put_label(curIP, 4);  //putu4(lVal);
+        }
+        assert((int)to_bci(curIP) == curPC);
+        continue;
+      }
+      bc_which = ref_band_for_op(bc);
+      if (bc_which != null) {
+        entry* ref = bc_which->getRefCommon(bc_which->ix, bc_which->nullOK);
+        CHECK;
+        if (ref == null && bc_which == &bc_classref) {
+          // Shorthand for class self-references.
+          ref = thisClass;
+        }
+        origBC = bc;
+        switch (bc) {
+        case _invokestatic_int:
+          origBC = bc_invokestatic;
+          break;
+        case _invokespecial_int:
+          origBC = bc_invokespecial;
+          break;
+        case bc_ildc:
+        case bc_cldc:
+        case bc_fldc:
+        case bc_sldc:
+        case bc_qldc:
+          origBC = bc_ldc;
+          break;
+        case bc_ildc_w:
+        case bc_cldc_w:
+        case bc_fldc_w:
+        case bc_sldc_w:
+        case bc_qldc_w:
+          origBC = bc_ldc_w;
+          break;
+        case bc_lldc2_w:
+        case bc_dldc2_w:
+          origBC = bc_ldc2_w;
+          break;
+        case bc_new:
+          newClass = ref;
+          break;
+        }
+        wp[-1] = origBC;  // overwrite with origBC
+        if (origBC == bc_ldc) {
+          putu1ref(ref);
+        } else {
+          putref(ref);
+        }
+        if (origBC == bc_multianewarray) {
+          // Copy the trailing byte also.
+          int val = bc_byte.getByte();
+          putu1_fast(val);
+        } else if (origBC == bc_invokeinterface) {
+          int argSize = ref->memberDescr()->descrType()->typeSize();
+          putu1_fast(1 + argSize);
+          putu1_fast(0);
+        } else if (origBC == bc_invokedynamic) {
+          // pad the next two byte
+          putu1_fast(0);
+          putu1_fast(0);
+        }
+        continue;
+      }
+      if (is_local_slot_op(bc)) {
+        int local = bc_local.getInt();
+        if (isWide) {
+          putu2(local);
+          if (bc == bc_iinc) {
+            int iVal = bc_short.getInt();
+            putu2(iVal);
+          }
+        } else {
+          putu1_fast(local);
+          if (bc == bc_iinc) {
+            int iVal = bc_byte.getByte();
+            putu1_fast(iVal);
+          }
+        }
+        continue;
+      }
+      // Random bytecode.  Just copy it.
+      assert(bc < bc_bytecode_limit);
+    }
+  }
+ doneScanningMethod:{}
+  //bcimap.add(curPC);  // PC limit is already also in map, from bc_end_marker
+
+  // Armed with a bcimap, we can now fix up all the labels.
+  for (int i = 0; i < (int)code_fixup_type.size(); i++) {
+    int   type   = code_fixup_type.getByte(i);
+    byte* bp     = wp_at(code_fixup_offset.get(i));
+    int   curIP  = code_fixup_source.get(i);
+    int   destIP = curIP + bc_label.getInt();
+    int   span   = to_bci(destIP) - to_bci(curIP);
+    switch (type) {
+    case 2: putu2_at(bp, (ushort)span); break;
+    case 4: putu4_at(bp,         span); break;
+    default: assert(false);
+    }
+  }
+}
+
+inline  // called exactly once => inline
+void unpacker::write_code() {
+  int j;
+
+  int max_stack, max_locals, handler_count, cflags;
+  get_code_header(max_stack, max_locals, handler_count, cflags);
+
+  if (max_stack < 0)      max_stack = code_max_stack.getInt();
+  if (max_locals < 0)     max_locals = code_max_na_locals.getInt();
+  if (handler_count < 0)  handler_count = code_handler_count.getInt();
+
+  int siglen = cur_descr->descrType()->typeSize();
+  CHECK;
+  if ((cur_descr_flags & ACC_STATIC) == 0)  siglen++;
+  max_locals += siglen;
+
+  putu2(max_stack);
+  putu2(max_locals);
+  size_t bcbase = put_empty(4);
+
+  // Write the bytecodes themselves.
+  write_bc_ops();
+  CHECK;
+
+  byte* bcbasewp = wp_at(bcbase);
+  putu4_at(bcbasewp, (int)(wp - (bcbasewp+4)));  // size of code attr
+
+  putu2(handler_count);
+  for (j = 0; j < handler_count; j++) {
+    int bii = code_handler_start_P.getInt();
+    putu2(to_bci(bii));
+    bii    += code_handler_end_PO.getInt();
+    putu2(to_bci(bii));
+    bii    += code_handler_catch_PO.getInt();
+    putu2(to_bci(bii));
+    putref(code_handler_class_RCN.getRefN());
+    CHECK;
+  }
+
+  julong indexBits = cflags;
+  if (cflags < 0) {
+    bool haveLongFlags = attr_defs[ATTR_CONTEXT_CODE].haveLongFlags();
+    indexBits = code_flags_hi.getLong(code_flags_lo, haveLongFlags);
+  }
+  write_attrs(ATTR_CONTEXT_CODE, indexBits);
+}
+
+int unpacker::write_attrs(int attrc, julong indexBits) {
+  CHECK_0;
+  if (indexBits == 0) {
+    // Quick short-circuit.
+    putu2(0);
+    return 0;
+  }
+
+  attr_definitions& ad = attr_defs[attrc];
+
+  int i, j, j2, idx, count;
+
+  int oiCount = 0;
+  if (ad.isPredefined(X_ATTR_OVERFLOW)
+      && (indexBits & ((julong)1<<X_ATTR_OVERFLOW)) != 0) {
+    indexBits -= ((julong)1<<X_ATTR_OVERFLOW);
+    oiCount = ad.xxx_attr_count().getInt();
+  }
+
+  int bitIndexes[X_ATTR_LIMIT_FLAGS_HI];
+  int biCount = 0;
+
+  // Fill bitIndexes with index bits, in order.
+  for (idx = 0; indexBits != 0; idx++, indexBits >>= 1) {
+    if ((indexBits & 1) != 0)
+      bitIndexes[biCount++] = idx;
+  }
+  assert(biCount <= (int)lengthof(bitIndexes));
+
+  // Write a provisional attribute count, perhaps to be corrected later.
+  int naOffset = (int)wpoffset();
+  int na0 = biCount + oiCount;
+  putu2(na0);
+
+  int na = 0;
+  for (i = 0; i < na0; i++) {
+    if (i < biCount)
+      idx = bitIndexes[i];
+    else
+      idx = ad.xxx_attr_indexes().getInt();
+    assert(ad.isIndex(idx));
+    entry* aname = null;
+    entry* ref;  // scratch
+    size_t abase = put_empty(2+4);
+    CHECK_0;
+    if (idx < (int)ad.flag_limit && ad.isPredefined(idx)) {
+      // Switch on the attrc and idx simultaneously.
+      switch (ADH_BYTE(attrc, idx)) {
+
+      case ADH_BYTE(ATTR_CONTEXT_CLASS,  X_ATTR_OVERFLOW):
+      case ADH_BYTE(ATTR_CONTEXT_FIELD,  X_ATTR_OVERFLOW):
+      case ADH_BYTE(ATTR_CONTEXT_METHOD, X_ATTR_OVERFLOW):
+      case ADH_BYTE(ATTR_CONTEXT_CODE,   X_ATTR_OVERFLOW):
+        // no attribute at all, so back up on this one
+        wp = wp_at(abase);
+        continue;
+
+      case ADH_BYTE(ATTR_CONTEXT_CLASS, CLASS_ATTR_ClassFile_version):
+        cur_class_minver = class_ClassFile_version_minor_H.getInt();
+        cur_class_majver = class_ClassFile_version_major_H.getInt();
+        // back up; not a real attribute
+        wp = wp_at(abase);
+        continue;
+
+      case ADH_BYTE(ATTR_CONTEXT_CLASS, CLASS_ATTR_InnerClasses):
+        // note the existence of this attr, but save for later
+        if (cur_class_has_local_ics)
+          abort("too many InnerClasses attrs");
+        cur_class_has_local_ics = true;
+        wp = wp_at(abase);
+        continue;
+
+      case ADH_BYTE(ATTR_CONTEXT_CLASS, CLASS_ATTR_SourceFile):
+        aname = cp.sym[cpool::s_SourceFile];
+        ref = class_SourceFile_RUN.getRefN();
+        CHECK_0;
+        if (ref == null) {
+          bytes& n = cur_class->ref(0)->value.b;
+          // parse n = (<pkg>/)*<outer>?($<id>)*
+          int pkglen = lastIndexOf(SLASH_MIN,  SLASH_MAX,  n, (int)n.len)+1;
+          bytes prefix = n.slice(pkglen, n.len);
+          for (;;) {
+            // Work backwards, finding all '$', '#', etc.
+            int dollar = lastIndexOf(DOLLAR_MIN, DOLLAR_MAX, prefix, (int)prefix.len);
+            if (dollar < 0)  break;
+            prefix = prefix.slice(0, dollar);
+          }
+          const char* suffix = ".java";
+          int len = (int)(prefix.len + strlen(suffix));
+          bytes name; name.set(T_NEW(byte, add_size(len, 1)), len);
+          name.strcat(prefix).strcat(suffix);
+          ref = cp.ensureUtf8(name);
+        }
+        putref(ref);
+        break;
+
+      case ADH_BYTE(ATTR_CONTEXT_CLASS, CLASS_ATTR_EnclosingMethod):
+        aname = cp.sym[cpool::s_EnclosingMethod];
+        putref(class_EnclosingMethod_RC.getRefN());
+        CHECK_0;
+        putref(class_EnclosingMethod_RDN.getRefN());
+        break;
+
+      case ADH_BYTE(ATTR_CONTEXT_FIELD, FIELD_ATTR_ConstantValue):
+        aname = cp.sym[cpool::s_ConstantValue];
+        putref(field_ConstantValue_KQ.getRefUsing(cp.getKQIndex()));
+        break;
+
+      case ADH_BYTE(ATTR_CONTEXT_METHOD, METHOD_ATTR_Code):
+        aname = cp.sym[cpool::s_Code];
+        write_code();
+        break;
+
+      case ADH_BYTE(ATTR_CONTEXT_METHOD, METHOD_ATTR_Exceptions):
+        aname = cp.sym[cpool::s_Exceptions];
+        putu2(count = method_Exceptions_N.getInt());
+        for (j = 0; j < count; j++) {
+          putref(method_Exceptions_RC.getRefN());
+          CHECK_0;
+        }
+        break;
+
+      case ADH_BYTE(ATTR_CONTEXT_METHOD, METHOD_ATTR_MethodParameters):
+        aname = cp.sym[cpool::s_MethodParameters];
+        putu1(count = method_MethodParameters_NB.getByte());
+        for (j = 0; j < count; j++) {
+          putref(method_MethodParameters_name_RUN.getRefN());
+          putu2(method_MethodParameters_flag_FH.getInt());
+        }
+        break;
+
+      case ADH_BYTE(ATTR_CONTEXT_CODE, CODE_ATTR_StackMapTable):
+        aname = cp.sym[cpool::s_StackMapTable];
+        // (keep this code aligned with its brother in unpacker::read_attrs)
+        putu2(count = code_StackMapTable_N.getInt());
+        for (j = 0; j < count; j++) {
+          int tag = code_StackMapTable_frame_T.getByte();
+          putu1(tag);
+          if (tag <= 127) {
+            // (64-127)  [(2)]
+            if (tag >= 64)  put_stackmap_type();
+          } else if (tag <= 251) {
+            // (247)     [(1)(2)]
+            // (248-251) [(1)]
+            if (tag >= 247)  putu2(code_StackMapTable_offset.getInt());
+            if (tag == 247)  put_stackmap_type();
+          } else if (tag <= 254) {
+            // (252)     [(1)(2)]
+            // (253)     [(1)(2)(2)]
+            // (254)     [(1)(2)(2)(2)]
+            putu2(code_StackMapTable_offset.getInt());
+            CHECK_0;
+            for (int k = (tag - 251); k > 0; k--) {
+              put_stackmap_type();
+              CHECK_0;
+            }
+          } else {
+            // (255)     [(1)NH[(2)]NH[(2)]]
+            putu2(code_StackMapTable_offset.getInt());
+            putu2(j2 = code_StackMapTable_local_N.getInt());
+            while (j2-- > 0) {put_stackmap_type(); CHECK_0;}
+            putu2(j2 = code_StackMapTable_stack_N.getInt());
+            while (j2-- > 0)  {put_stackmap_type(); CHECK_0;}
+          }
+        }
+        break;
+
+      case ADH_BYTE(ATTR_CONTEXT_CODE, CODE_ATTR_LineNumberTable):
+        aname = cp.sym[cpool::s_LineNumberTable];
+        putu2(count = code_LineNumberTable_N.getInt());
+        for (j = 0; j < count; j++) {
+          putu2(to_bci(code_LineNumberTable_bci_P.getInt()));
+          putu2(code_LineNumberTable_line.getInt());
+        }
+        break;
+
+      case ADH_BYTE(ATTR_CONTEXT_CODE, CODE_ATTR_LocalVariableTable):
+        aname = cp.sym[cpool::s_LocalVariableTable];
+        putu2(count = code_LocalVariableTable_N.getInt());
+        for (j = 0; j < count; j++) {
+          int bii = code_LocalVariableTable_bci_P.getInt();
+          int bci = to_bci(bii);
+          putu2(bci);
+          bii    += code_LocalVariableTable_span_O.getInt();
+          putu2(to_bci(bii) - bci);
+          putref(code_LocalVariableTable_name_RU.getRefN());
+          CHECK_0;
+          putref(code_LocalVariableTable_type_RS.getRefN());
+          CHECK_0;
+          putu2(code_LocalVariableTable_slot.getInt());
+        }
+        break;
+
+      case ADH_BYTE(ATTR_CONTEXT_CODE, CODE_ATTR_LocalVariableTypeTable):
+        aname = cp.sym[cpool::s_LocalVariableTypeTable];
+        putu2(count = code_LocalVariableTypeTable_N.getInt());
+        for (j = 0; j < count; j++) {
+          int bii = code_LocalVariableTypeTable_bci_P.getInt();
+          int bci = to_bci(bii);
+          putu2(bci);
+          bii    += code_LocalVariableTypeTable_span_O.getInt();
+          putu2(to_bci(bii) - bci);
+          putref(code_LocalVariableTypeTable_name_RU.getRefN());
+          CHECK_0;
+          putref(code_LocalVariableTypeTable_type_RS.getRefN());
+          CHECK_0;
+          putu2(code_LocalVariableTypeTable_slot.getInt());
+        }
+        break;
+
+      case ADH_BYTE(ATTR_CONTEXT_CLASS, X_ATTR_Signature):
+        aname = cp.sym[cpool::s_Signature];
+        putref(class_Signature_RS.getRefN());
+        break;
+
+      case ADH_BYTE(ATTR_CONTEXT_FIELD, X_ATTR_Signature):
+        aname = cp.sym[cpool::s_Signature];
+        putref(field_Signature_RS.getRefN());
+        break;
+
+      case ADH_BYTE(ATTR_CONTEXT_METHOD, X_ATTR_Signature):
+        aname = cp.sym[cpool::s_Signature];
+        putref(method_Signature_RS.getRefN());
+        break;
+
+      case ADH_BYTE(ATTR_CONTEXT_CLASS,  X_ATTR_Deprecated):
+      case ADH_BYTE(ATTR_CONTEXT_FIELD,  X_ATTR_Deprecated):
+      case ADH_BYTE(ATTR_CONTEXT_METHOD, X_ATTR_Deprecated):
+        aname = cp.sym[cpool::s_Deprecated];
+        // no data
+        break;
+      }
+    }
+    CHECK_0;
+    if (aname == null) {
+      // Unparse a compressor-defined attribute.
+      layout_definition* lo = ad.getLayout(idx);
+      if (lo == null) {
+        abort("bad layout index");
+        break;
+      }
+      assert((int)lo->idx == idx);
+      aname = lo->nameEntry;
+      if (aname == null) {
+        bytes nameb; nameb.set(lo->name);
+        aname = cp.ensureUtf8(nameb);
+        // Cache the name entry for next time.
+        lo->nameEntry = aname;
+      }
+      // Execute all the layout elements.
+      band** bands = lo->bands();
+      if (lo->hasCallables()) {
+        band& cble = *bands[0];
+        assert(cble.le_kind == EK_CBLE);
+        bands = cble.le_body;
+      }
+      putlayout(bands);
+    }
+
+    if (aname == null)
+      abort("bad attribute index");
+    CHECK_0;
+
+    byte* wp1 = wp;
+    wp = wp_at(abase);
+
+    // DTRT if this attr is on the strip-list.
+    // (Note that we emptied the data out of the band first.)
+    if (ad.strip_names.contains(aname)) {
+      continue;
+    }
+
+    // patch the name and length
+    putref(aname);
+    putu4((int)(wp1 - (wp+4)));  // put the attr size
+    wp = wp1;
+    na++;  // count the attrs actually written
+  }
+
+  if (na != na0)
+    // Refresh changed count.
+    putu2_at(wp_at(naOffset), na);
+  return na;
+}
+
+void unpacker::write_members(int num, int attrc) {
+  CHECK;
+  attr_definitions& ad = attr_defs[attrc];
+  band& member_flags_hi = ad.xxx_flags_hi();
+  band& member_flags_lo = ad.xxx_flags_lo();
+  band& member_descr = (&member_flags_hi)[e_field_descr-e_field_flags_hi];
+  assert(endsWith(member_descr.name, "_descr"));
+  assert(endsWith(member_flags_lo.name, "_flags_lo"));
+  assert(endsWith(member_flags_lo.name, "_flags_lo"));
+  bool haveLongFlags = ad.haveLongFlags();
+
+  putu2(num);
+  julong indexMask = attr_defs[attrc].flagIndexMask();
+  for (int i = 0; i < num; i++) {
+    julong mflags = member_flags_hi.getLong(member_flags_lo, haveLongFlags);
+    entry* mdescr = member_descr.getRef();
+    cur_descr = mdescr;
+    putu2(cur_descr_flags = (ushort)(mflags & ~indexMask));
+    CHECK;
+    putref(mdescr->descrName());
+    putref(mdescr->descrType());
+    write_attrs(attrc, (mflags & indexMask));
+    CHECK;
+  }
+  cur_descr = null;
+}
+
+extern "C"
+int raw_address_cmp(const void* p1p, const void* p2p) {
+  void* p1 = *(void**) p1p;
+  void* p2 = *(void**) p2p;
+  return (p1 > p2)? 1: (p1 < p2)? -1: 0;
+}
+
+/*
+ * writes the InnerClass attributes and returns the updated attribute
+ */
+int  unpacker::write_ics(int naOffset, int na) {
+#ifdef ASSERT
+  for (int i = 0; i < ic_count; i++) {
+    assert(!ics[i].requested);
+  }
+#endif
+  // First, consult the global table and the local constant pool,
+  // and decide on the globally implied inner classes.
+  // (Note that we read the cpool's outputIndex fields, but we
+  // do not yet write them, since the local IC attribute might
+  // reverse a global decision to declare an IC.)
+  assert(requested_ics.length() == 0);  // must start out empty
+  // Always include all members of the current class.
+  for (inner_class* child = cp.getFirstChildIC(cur_class);
+       child != null;
+       child = cp.getNextChildIC(child)) {
+    child->requested = true;
+    requested_ics.add(child);
+  }
+  // And, for each inner class mentioned in the constant pool,
+  // include it and all its outers.
+  int    noes =           cp.outputEntries.length();
+  entry** oes = (entry**) cp.outputEntries.base();
+  for (int i = 0; i < noes; i++) {
+    entry& e = *oes[i];
+    if (e.tag != CONSTANT_Class)  continue;  // wrong sort
+    for (inner_class* ic = cp.getIC(&e);
+         ic != null;
+         ic = cp.getIC(ic->outer)) {
+      if (ic->requested)  break;  // already processed
+      ic->requested = true;
+      requested_ics.add(ic);
+    }
+  }
+  int local_ics = requested_ics.length();
+  // Second, consult a local attribute (if any) and adjust the global set.
+  inner_class* extra_ics = null;
+  int      num_extra_ics = 0;
+  if (cur_class_has_local_ics) {
+    // adjust the set of ICs by symmetric set difference w/ the locals
+    num_extra_ics = class_InnerClasses_N.getInt();
+    if (num_extra_ics == 0) {
+      // Explicit zero count has an irregular meaning:  It deletes the attr.
+      local_ics = 0;  // (short-circuit all tests of requested bits)
+    } else {
+      extra_ics = T_NEW(inner_class, num_extra_ics);
+      // Note:  extra_ics will be freed up by next call to get_next_file().
+    }
+  }
+  for (int i = 0; i < num_extra_ics; i++) {
+    inner_class& extra_ic = extra_ics[i];
+    extra_ic.inner = class_InnerClasses_RC.getRef();
+    CHECK_0;
+    // Find the corresponding equivalent global IC:
+    inner_class* global_ic = cp.getIC(extra_ic.inner);
+    int flags = class_InnerClasses_F.getInt();
+    if (flags == 0) {
+      // The extra IC is simply a copy of a global IC.
+      if (global_ic == null) {
+        abort("bad reference to inner class");
+        break;
+      }
+      extra_ic = (*global_ic);  // fill in rest of fields
+    } else {
+      flags &= ~ACC_IC_LONG_FORM;  // clear high bit if set to get clean zero
+      extra_ic.flags = flags;
+      extra_ic.outer = class_InnerClasses_outer_RCN.getRefN();
+      CHECK_0;
+      extra_ic.name  = class_InnerClasses_name_RUN.getRefN();
+      CHECK_0;
+      // Detect if this is an exact copy of the global tuple.
+      if (global_ic != null) {
+        if (global_ic->flags != extra_ic.flags ||
+            global_ic->outer != extra_ic.outer ||
+            global_ic->name  != extra_ic.name) {
+          global_ic = null;  // not really the same, so break the link
+        }
+      }
+    }
+    if (global_ic != null && global_ic->requested) {
+      // This local repetition reverses the globally implied request.
+      global_ic->requested = false;
+      extra_ic.requested = false;
+      local_ics -= 1;
+    } else {
+      // The global either does not exist, or is not yet requested.
+      extra_ic.requested = true;
+      local_ics += 1;
+    }
+  }
+  // Finally, if there are any that survived, put them into an attribute.
+  // (Note that a zero-count attribute is always deleted.)
+  // The putref calls below will tell the constant pool to add any
+  // necessary local CP references to support the InnerClasses attribute.
+  // This step must be the last round of additions to the local CP.
+  if (local_ics > 0) {
+    // append the new attribute:
+    putref(cp.sym[cpool::s_InnerClasses]);
+    putu4(2 + 2*4*local_ics);
+    putu2(local_ics);
+    PTRLIST_QSORT(requested_ics, raw_address_cmp);
+    int num_global_ics = requested_ics.length();
+    for (int i = -num_global_ics; i < num_extra_ics; i++) {
+      inner_class* ic;
+      if (i < 0)
+        ic = (inner_class*) requested_ics.get(num_global_ics+i);
+      else
+        ic = &extra_ics[i];
+      if (ic->requested) {
+        putref(ic->inner);
+        putref(ic->outer);
+        putref(ic->name);
+        putu2(ic->flags);
+        NOT_PRODUCT(local_ics--);
+      }
+    }
+    assert(local_ics == 0);           // must balance
+    putu2_at(wp_at(naOffset), ++na);  // increment class attr count
+  }
+
+  // Tidy up global 'requested' bits:
+  for (int i = requested_ics.length(); --i >= 0; ) {
+    inner_class* ic = (inner_class*) requested_ics.get(i);
+    ic->requested = false;
+  }
+  requested_ics.empty();
+  return na;
+}
+
+/*
+ * Writes the BootstrapMethods attribute and returns the updated attribute count
+ */
+int unpacker::write_bsms(int naOffset, int na) {
+  cur_class_local_bsm_count = cp.requested_bsms.length();
+  if (cur_class_local_bsm_count > 0) {
+    int    noes =           cp.outputEntries.length();
+    entry** oes = (entry**) cp.outputEntries.base();
+    PTRLIST_QSORT(cp.requested_bsms, outputEntry_cmp);
+    // append the BootstrapMethods attribute (after the InnerClasses attr):
+    putref(cp.sym[cpool::s_BootstrapMethods]);
+    // make a note of the offset, for lazy patching
+    int sizeOffset = (int)wpoffset();
+    putu4(-99);  // attr size will be patched
+    putu2(cur_class_local_bsm_count);
+    int written_bsms = 0;
+    for (int i = 0 ; i < cur_class_local_bsm_count ; i++) {
+      entry* e = (entry*)cp.requested_bsms.get(i);
+      assert(e->outputIndex != REQUESTED_NONE);
+      // output index is the index within the array
+      e->outputIndex = i;
+      putref(e->refs[0]);  // bsm
+      putu2(e->nrefs-1);  // number of args after bsm
+      for (int j = 1; j < e->nrefs; j++) {
+        putref(e->refs[j]);
+      }
+      written_bsms += 1;
+    }
+    assert(written_bsms == cur_class_local_bsm_count);  // else insane
+    byte* sizewp = wp_at(sizeOffset);
+    putu4_at(sizewp, (int)(wp - (sizewp+4)));  // size of code attr
+    putu2_at(wp_at(naOffset), ++na);  // increment class attr count
+  }
+  return na;
+}
+
+void unpacker::write_classfile_tail() {
+
+  cur_classfile_tail.empty();
+  set_output(&cur_classfile_tail);
+
+  int i, num;
+
+  attr_definitions& ad = attr_defs[ATTR_CONTEXT_CLASS];
+
+  bool haveLongFlags = ad.haveLongFlags();
+  julong kflags = class_flags_hi.getLong(class_flags_lo, haveLongFlags);
+  julong indexMask = ad.flagIndexMask();
+
+  cur_class = class_this.getRef();
+  CHECK;
+  cur_super = class_super.getRef();
+  CHECK;
+
+  if (cur_super == cur_class)  cur_super = null;
+  // special representation for java/lang/Object
+
+  putu2((ushort)(kflags & ~indexMask));
+  putref(cur_class);
+  putref(cur_super);
+
+  putu2(num = class_interface_count.getInt());
+  for (i = 0; i < num; i++) {
+    putref(class_interface.getRef());
+    CHECK;
+  }
+
+  write_members(class_field_count.getInt(),  ATTR_CONTEXT_FIELD);
+  write_members(class_method_count.getInt(), ATTR_CONTEXT_METHOD);
+  CHECK;
+
+  cur_class_has_local_ics = false;  // may be set true by write_attrs
+
+  int naOffset = (int)wpoffset();   // note the attr count location
+  int na = write_attrs(ATTR_CONTEXT_CLASS, (kflags & indexMask));
+  CHECK;
+
+  na = write_bsms(naOffset, na);
+  CHECK;
+
+  // choose which inner classes (if any) pertain to k:
+  na = write_ics(naOffset, na);
+  CHECK;
+
+  close_output();
+  cp.computeOutputIndexes();
+
+  // rewrite CP references in the tail
+  int nextref = 0;
+  for (i = 0; i < (int)class_fixup_type.size(); i++) {
+    int    type = class_fixup_type.getByte(i);
+    byte*  fixp = wp_at(class_fixup_offset.get(i));
+    entry* e    = (entry*)class_fixup_ref.get(nextref++);
+    int    idx  = e->getOutputIndex();
+    switch (type) {
+    case 1:  putu1_at(fixp, idx);  break;
+    case 2:  putu2_at(fixp, idx);  break;
+    default: assert(false);  // should not reach here
+    }
+  }
+  CHECK;
+}
+
+void unpacker::write_classfile_head() {
+  cur_classfile_head.empty();
+  set_output(&cur_classfile_head);
+
+  putu4(JAVA_MAGIC);
+  putu2(cur_class_minver);
+  putu2(cur_class_majver);
+  putu2(cp.outputIndexLimit);
+
+  int checkIndex = 1;
+  int    noes =           cp.outputEntries.length();
+  entry** oes = (entry**) cp.outputEntries.base();
+  for (int i = 0; i < noes; i++) {
+    entry& e = *oes[i];
+    assert(e.getOutputIndex() == checkIndex++);
+    byte tag = e.tag;
+    assert(tag != CONSTANT_Signature);
+    putu1(tag);
+    switch (tag) {
+    case CONSTANT_Utf8:
+      putu2((int)e.value.b.len);
+      put_bytes(e.value.b);
+      break;
+    case CONSTANT_Integer:
+    case CONSTANT_Float:
+      putu4(e.value.i);
+      break;
+    case CONSTANT_Long:
+    case CONSTANT_Double:
+      putu8(e.value.l);
+      assert(checkIndex++);
+      break;
+    case CONSTANT_Class:
+    case CONSTANT_String:
+      // just write the ref
+      putu2(e.refs[0]->getOutputIndex());
+      break;
+    case CONSTANT_Fieldref:
+    case CONSTANT_Methodref:
+    case CONSTANT_InterfaceMethodref:
+    case CONSTANT_NameandType:
+    case CONSTANT_InvokeDynamic:
+      putu2(e.refs[0]->getOutputIndex());
+      putu2(e.refs[1]->getOutputIndex());
+      break;
+    case CONSTANT_MethodHandle:
+        putu1(e.value.i);
+        putu2(e.refs[0]->getOutputIndex());
+        break;
+    case CONSTANT_MethodType:
+      putu2(e.refs[0]->getOutputIndex());
+      break;
+    case CONSTANT_BootstrapMethod: // should not happen
+    default:
+      abort(ERROR_INTERNAL);
+    }
+  }
+
+#ifndef PRODUCT
+  total_cp_size[0] += cp.outputIndexLimit;
+  total_cp_size[1] += (int)cur_classfile_head.size();
+#endif
+  close_output();
+}
+
+unpacker::file* unpacker::get_next_file() {
+  CHECK_0;
+  free_temps();
+  if (files_remaining == 0) {
+    // Leave a clue that we're exhausted.
+    cur_file.name = null;
+    cur_file.size = null;
+    if (archive_size != 0) {
+      julong predicted_size = unsized_bytes_read + archive_size;
+      if (predicted_size != bytes_read)
+        abort("archive header had incorrect size");
+    }
+    return null;
+  }
+  files_remaining -= 1;
+  assert(files_written < file_count || classes_written < class_count);
+  cur_file.name = "";
+  cur_file.size = 0;
+  cur_file.modtime = default_file_modtime;
+  cur_file.options = default_file_options;
+  cur_file.data[0].set(null, 0);
+  cur_file.data[1].set(null, 0);
+  if (files_written < file_count) {
+    entry* e = file_name.getRef();
+    CHECK_0;
+    cur_file.name = e->utf8String();
+    bool haveLongSize = (testBit(archive_options, AO_HAVE_FILE_SIZE_HI));
+    cur_file.size = file_size_hi.getLong(file_size_lo, haveLongSize);
+    if (testBit(archive_options, AO_HAVE_FILE_MODTIME))
+      cur_file.modtime += file_modtime.getInt();  //relative to archive modtime
+    if (testBit(archive_options, AO_HAVE_FILE_OPTIONS))
+      cur_file.options |= file_options.getInt() & ~suppress_file_options;
+  } else if (classes_written < class_count) {
+    // there is a class for a missing file record
+    cur_file.options |= FO_IS_CLASS_STUB;
+  }
+  if ((cur_file.options & FO_IS_CLASS_STUB) != 0) {
+    assert(classes_written < class_count);
+    classes_written += 1;
+    if (cur_file.size != 0) {
+      abort("class file size transmitted");
+      return null;
+    }
+    reset_cur_classfile();
+
+    // write the meat of the classfile:
+    write_classfile_tail();
+    cur_file.data[1] = cur_classfile_tail.b;
+    CHECK_0;
+
+    // write the CP of the classfile, second:
+    write_classfile_head();
+    cur_file.data[0] = cur_classfile_head.b;
+    CHECK_0;
+
+    cur_file.size += cur_file.data[0].len;
+    cur_file.size += cur_file.data[1].len;
+    if (cur_file.name[0] == '\0') {
+      bytes& prefix = cur_class->ref(0)->value.b;
+      const char* suffix = ".class";
+      int len = (int)(prefix.len + strlen(suffix));
+      bytes name; name.set(T_NEW(byte, add_size(len, 1)), len);
+      cur_file.name = name.strcat(prefix).strcat(suffix).strval();
+    }
+  } else {
+    // If there is buffered file data, produce a pointer to it.
+    if (cur_file.size != (size_t) cur_file.size) {
+      // Silly size specified.
+      abort("resource file too large");
+      return null;
+    }
+    size_t rpleft = input_remaining();
+    if (rpleft > 0) {
+      if (rpleft > cur_file.size)
+        rpleft = (size_t) cur_file.size;
+      cur_file.data[0].set(rp, rpleft);
+      rp += rpleft;
+    }
+    if (rpleft < cur_file.size) {
+      // Caller must read the rest.
+      size_t fleft = (size_t)cur_file.size - rpleft;
+      bytes_read += fleft;  // Credit it to the overall archive size.
+    }
+  }
+  CHECK_0;
+  bytes_written += cur_file.size;
+  files_written += 1;
+  return &cur_file;
+}
+
+// Write a file to jarout.
+void unpacker::write_file_to_jar(unpacker::file* f) {
+  size_t htsize = f->data[0].len + f->data[1].len;
+  julong fsize = f->size;
+#ifndef PRODUCT
+  if (nowrite NOT_PRODUCT(|| skipfiles-- > 0)) {
+    PRINTCR((2,"would write %d bytes to %s", (int) fsize, f->name));
+    return;
+  }
+#endif
+  if (htsize == fsize) {
+    jarout->addJarEntry(f->name, f->deflate_hint(), f->modtime,
+                        f->data[0], f->data[1]);
+  } else {
+    assert(input_remaining() == 0);
+    bytes part1, part2;
+    part1.len = f->data[0].len;
+    part1.set(T_NEW(byte, part1.len), part1.len);
+    part1.copyFrom(f->data[0]);
+    assert(f->data[1].len == 0);
+    part2.set(null, 0);
+    size_t fleft = (size_t) fsize - part1.len;
+    assert(bytes_read > fleft);  // part2 already credited by get_next_file
+    bytes_read -= fleft;
+    if (fleft > 0) {
+      // Must read some more.
+      if (live_input) {
+        // Stop using the input buffer.  Make a new one:
+        if (free_input)  input.free();
+        input.init(fleft > (1<<12) ? fleft : (1<<12));
+        free_input = true;
+        live_input = false;
+      } else {
+        // Make it large enough.
+        assert(free_input);  // must be reallocable
+        input.ensureSize(fleft);
+      }
+      rplimit = rp = input.base();
+      CHECK;
+      input.setLimit(rp + fleft);
+      if (!ensure_input(fleft))
+        abort("EOF reading resource file");
+      part2.ptr = input_scan();
+      part2.len = input_remaining();
+      rplimit = rp = input.base();
+    }
+    jarout->addJarEntry(f->name, f->deflate_hint(), f->modtime,
+                        part1, part2);
+  }
+  if (verbose >= 3) {
+    fprintf(errstrm, "Wrote "
+                     LONG_LONG_FORMAT " bytes to: %s\n", fsize, f->name);
+  }
+}
+
+// Redirect the stdio to the specified file in the unpack.log.file option
+void unpacker::redirect_stdio() {
+  if (log_file == null) {
+    log_file = LOGFILE_STDOUT;
+  }
+  if (log_file == errstrm_name)
+    // Nothing more to be done.
+    return;
+  errstrm_name = log_file;
+  if (strcmp(log_file, LOGFILE_STDERR) == 0) {
+    errstrm = stderr;
+    return;
+  } else if (strcmp(log_file, LOGFILE_STDOUT) == 0) {
+    errstrm = stdout;
+    return;
+  } else if (log_file[0] != '\0' && (errstrm = fopen(log_file,"a+")) != NULL) {
+    return;
+  } else {
+    fprintf(stderr, "Can not open log file %s\n", log_file);
+    // Last resort
+    // (Do not use stdout, since it might be jarout->jarfp.)
+    errstrm = stderr;
+    log_file = errstrm_name = LOGFILE_STDERR;
+  }
+}
+
+#ifndef PRODUCT
+int unpacker::printcr_if_verbose(int level, const char* fmt ...) {
+  if (verbose < level)  return 0;
+  va_list vl;
+  va_start(vl, fmt);
+  char fmtbuf[300];
+  strcpy(fmtbuf+100, fmt);
+  strcat(fmtbuf+100, "\n");
+  char* fmt2 = fmtbuf+100;
+  while (level-- > 0)  *--fmt2 = ' ';
+  vfprintf(errstrm, fmt2, vl);
+  return 1;  // for ?: usage
+}
+#endif
+
+void unpacker::abort(const char* message) {
+  if (message == null)  message = "error unpacking archive";
+#ifdef UNPACK_JNI
+  if (message[0] == '@') {  // secret convention for sprintf
+     bytes saved;
+     saved.saveFrom(message+1);
+     mallocs.add(message = saved.strval());
+   }
+  abort_message = message;
+  return;
+#else
+  if (message[0] == '@')  ++message;
+  fprintf(errstrm, "%s\n", message);
+#ifndef PRODUCT
+  fflush(errstrm);
+  ::abort();
+#else
+  exit(-1);
+#endif
+#endif // JNI
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/jdk/src/jdk.pack200/share/native/common-unpack/unpack.h	Fri Mar 06 09:02:26 2015 -0800
@@ -0,0 +1,510 @@
+/*
+ * Copyright (c) 2002, 2012, 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.
+ */
+// Global Structures
+struct jar;
+struct gunzip;
+struct band;
+struct cpool;
+struct entry;
+struct cpindex;
+struct inner_class;
+struct value_stream;
+
+struct cpindex {
+  uint    len;
+  entry*  base1;   // base of primary index
+  entry** base2;   // base of secondary index
+  byte    ixTag;   // type of entries (!= CONSTANT_None), plus 64 if sub-index
+  enum { SUB_TAG = 64 };
+
+  entry* get(uint i);
+
+  void init(int len_, entry* base1_, int ixTag_) {
+    len = len_;
+    base1 = base1_;
+    base2 = null;
+    ixTag = ixTag_;
+  }
+  void init(int len_, entry** base2_, int ixTag_) {
+    len = len_;
+    base1 = null;
+    base2 = base2_;
+    ixTag = ixTag_;
+  }
+};
+
+struct cpool {
+  uint  nentries;
+  entry* entries;
+  entry* first_extra_entry;
+  uint maxentries;      // total allocated size of entries
+
+  // Position and size of each homogeneous subrange:
+  int     tag_count[CONSTANT_Limit];
+  int     tag_base[CONSTANT_Limit];
+  cpindex tag_index[CONSTANT_Limit];
+  ptrlist tag_extras[CONSTANT_Limit];
+
+  int     tag_group_count[CONSTANT_GroupLimit - CONSTANT_GroupFirst];
+  cpindex tag_group_index[CONSTANT_GroupLimit - CONSTANT_GroupFirst];
+
+  cpindex* member_indexes;   // indexed by 2*CONSTANT_Class.inord
+  cpindex* getFieldIndex(entry* classRef);
+  cpindex* getMethodIndex(entry* classRef);
+
+  inner_class** ic_index;
+  inner_class** ic_child_index;
+  inner_class* getIC(entry* inner);
+  inner_class* getFirstChildIC(entry* outer);
+  inner_class* getNextChildIC(inner_class* child);
+
+  int outputIndexLimit;  // index limit after renumbering
+  ptrlist outputEntries; // list of entry* needing output idx assigned
+  ptrlist requested_bsms; // which bsms need output?
+
+  entry** hashTab;
+  uint    hashTabLength;
+  entry*& hashTabRef(byte tag, bytes& b);
+  entry*  ensureUtf8(bytes& b);
+  entry*  ensureClass(bytes& b);
+
+  // Well-known Utf8 symbols.
+  enum {
+    #define SNAME(n,s) s_##s,
+    ALL_ATTR_DO(SNAME)
+    #undef SNAME
+    s_lt_init_gt,  // <init>
+    s_LIMIT
+  };
+  entry* sym[s_LIMIT];
+
+  // read counts from hdr, allocate main arrays
+  void init(unpacker* u, int counts[CONSTANT_Limit]);
+
+  // pointer to outer unpacker, for error checks etc.
+  unpacker* u;
+
+  int getCount(byte tag) {
+    if ((uint)tag >= CONSTANT_GroupFirst) {
+      assert((uint)tag < CONSTANT_GroupLimit);
+      return tag_group_count[(uint)tag - CONSTANT_GroupFirst];
+    } else {
+      assert((uint)tag < CONSTANT_Limit);
+      return tag_count[(uint)tag];
+    }
+  }
+  cpindex* getIndex(byte tag) {
+    if ((uint)tag >= CONSTANT_GroupFirst) {
+      assert((uint)tag < CONSTANT_GroupLimit);
+      return &tag_group_index[(uint)tag - CONSTANT_GroupFirst];
+    } else {
+      assert((uint)tag < CONSTANT_Limit);
+      return &tag_index[(uint)tag];
+    }
+  }
+
+  cpindex* getKQIndex();  // uses cur_descr
+
+  void expandSignatures();
+  void initGroupIndexes();
+  void initMemberIndexes();
+  int  initLoadableValues(entry** loadable_entries);
+
+  void computeOutputOrder();
+  void computeOutputIndexes();
+  void resetOutputIndexes();
+
+  // error handling
+  inline void abort(const char* msg);
+  inline bool aborting();
+};
+
+/*
+ * The unpacker provides the entry points to the unpack engine,
+ * as well as maintains the state of the engine.
+ */
+struct unpacker {
+  // One element of the resulting JAR.
+  struct file {
+    const char* name;
+    julong      size;
+    int         modtime;
+    int         options;
+    bytes       data[2];
+    // Note:  If Sum(data[*].len) < size,
+    // remaining bytes must be read directly from the input stream.
+    bool deflate_hint() { return ((options & FO_DEFLATE_HINT) != 0); }
+  };
+
+  // back pointer to NativeUnpacker obj and Java environment
+  void* jniobj;
+  void* jnienv;
+
+  // global pointer to self, if not running under JNI (not multi-thread safe)
+  static unpacker* non_mt_current;
+
+  // if running Unix-style, here are the inputs and outputs
+  FILE* infileptr;  // buffered
+  int   infileno;   // unbuffered
+  bytes inbytes;    // direct
+  gunzip* gzin;     // gunzip filter, if any
+  jar*  jarout;     // output JAR file
+  uint  gzcrc;      // CRC gathered from gzip content
+
+#ifndef PRODUCT
+  int   nowrite;
+  int   skipfiles;
+  int   verbose_bands;
+#endif
+
+  // pointer to self, for U_NEW macro
+  unpacker* u;
+
+  // private abort message string, allocated to PATH_MAX*2
+  const char* abort_message;
+  ptrlist mallocs;      // list of guys to free when we are all done
+  ptrlist tmallocs;     // list of guys to free on next client request
+  fillbytes smallbuf;   // supplies small alloc requests
+  fillbytes tsmallbuf;  // supplies temporary small alloc requests
+
+  // option management members
+  int   verbose;  // verbose level, 0 means no output
+  bool  strip_compile;
+  bool  strip_debug;
+  bool  strip_jcov;
+  bool  remove_packfile;
+  int   deflate_hint_or_zero;  // ==0 means not set, otherwise -1 or 1
+  int   modification_time_or_zero;
+
+  FILE*       errstrm;
+  const char* errstrm_name;
+
+  const char* log_file;
+
+  // input stream
+  fillbytes input;       // the whole block (size is predicted, has slop too)
+  bool      live_input;  // is the data in this block live?
+  bool      free_input;  // must the input buffer be freed?
+  byte*     rp;          // read pointer (< rplimit <= input.limit())
+  byte*     rplimit;     // how much of the input block has been read?
+  julong    bytes_read;
+  int       unsized_bytes_read;
+
+  // callback to read at least one byte, up to available input
+  typedef jlong (*read_input_fn_t)(unpacker* self, void* buf, jlong minlen, jlong maxlen);
+  read_input_fn_t read_input_fn;
+
+  // archive header fields
+  int      magic, minver, majver;
+  size_t   archive_size;
+  int      archive_next_count, archive_options, archive_modtime;
+  int      band_headers_size;
+  int      file_count, attr_definition_count, ic_count, class_count;
+  int      default_class_minver, default_class_majver;
+  int      default_file_options, suppress_file_options;  // not header fields
+  int      default_archive_modtime, default_file_modtime;  // not header fields
+  int      code_count;  // not a header field
+  int      files_remaining;  // not a header field
+
+  // engine state
+  band*        all_bands;   // indexed by band_number
+  byte*        meta_rp;     // read-pointer into (copy of) band_headers
+  cpool        cp;          // all constant pool information
+  inner_class* ics;         // InnerClasses
+
+  // output stream
+  bytes    output;      // output block (either classfile head or tail)
+  byte*    wp;          // write pointer (< wplimit == output.limit())
+  byte*    wpbase;      // write pointer starting address (<= wp)
+  byte*    wplimit;     // how much of the output block has been written?
+
+  // output state
+  file      cur_file;
+  entry*    cur_class;  // CONSTANT_Class entry
+  entry*    cur_super;  // CONSTANT_Class entry or null
+  entry*    cur_descr;  // CONSTANT_NameandType entry
+  int       cur_descr_flags;  // flags corresponding to cur_descr
+  int       cur_class_minver, cur_class_majver;
+  bool      cur_class_has_local_ics;
+  int       cur_class_local_bsm_count;
+  fillbytes cur_classfile_head;
+  fillbytes cur_classfile_tail;
+  int       files_written;   // also tells which file we're working on
+  int       classes_written; // also tells which class we're working on
+  julong    bytes_written;
+  intlist   bcimap;
+  fillbytes class_fixup_type;
+  intlist   class_fixup_offset;
+  ptrlist   class_fixup_ref;
+  fillbytes code_fixup_type;    // which format of branch operand?
+  intlist   code_fixup_offset;  // location of operand needing fixup
+  intlist   code_fixup_source;  // encoded ID of branch insn
+  ptrlist   requested_ics;      // which ics need output?
+
+  // stats pertaining to multiple segments (updated on reset)
+  julong    bytes_read_before_reset;
+  julong    bytes_written_before_reset;
+  int       files_written_before_reset;
+  int       classes_written_before_reset;
+  int       segments_read_before_reset;
+
+  // attribute state
+  struct layout_definition {
+    uint          idx;        // index (0..31...) which identifies this layout
+    const char*   name;       // name of layout
+    entry*        nameEntry;
+    const char*   layout;     // string of layout (not yet parsed)
+    band**        elems;      // array of top-level layout elems (or callables)
+
+    bool hasCallables()   { return layout[0] == '['; }
+    band** bands()        { assert(elems != null); return elems; }
+  };
+  struct attr_definitions {
+    unpacker* u;  // pointer to self, for U_NEW macro
+    int     xxx_flags_hi_bn;// locator for flags, count, indexes, calls bands
+    int     attrc;          // ATTR_CONTEXT_CLASS, etc.
+    uint    flag_limit;     // 32 or 63, depending on archive_options bit
+    julong  predef;         // mask of built-in definitions
+    julong  redef;          // mask of local flag definitions or redefinitions
+    ptrlist layouts;        // local (compressor-defined) defs, in index order
+    int     flag_count[X_ATTR_LIMIT_FLAGS_HI];
+    intlist overflow_count;
+    ptrlist strip_names;    // what attribute names are being stripped?
+    ptrlist band_stack;     // Temp., used during layout parsing.
+    ptrlist calls_to_link;  //  (ditto)
+    int     bands_made;     //  (ditto)
+
+    void free() {
+      layouts.free();
+      overflow_count.free();
+      strip_names.free();
+      band_stack.free();
+      calls_to_link.free();
+    }
+
+    // Locate the five fixed bands.
+    band& xxx_flags_hi();
+    band& xxx_flags_lo();
+    band& xxx_attr_count();
+    band& xxx_attr_indexes();
+    band& xxx_attr_calls();
+    band& fixed_band(int e_class_xxx);
+
+    // Register a new layout, and make bands for it.
+    layout_definition* defineLayout(int idx, const char* name, const char* layout);
+    layout_definition* defineLayout(int idx, entry* nameEntry, const char* layout);
+    band** buildBands(layout_definition* lo);
+
+    // Parse a layout string or part of one, recursively if necessary.
+    const char* parseLayout(const char* lp,    band** &res, int curCble);
+    const char* parseNumeral(const char* lp,   int    &res);
+    const char* parseIntLayout(const char* lp, band*  &res, byte le_kind,
+                               bool can_be_signed = false);
+    band** popBody(int band_stack_base);  // pops a body off band_stack
+
+    // Read data into the bands of the idx-th layout.
+    void readBandData(int idx);  // parse layout, make bands, read data
+    void readBandData(band** body, uint count);  // recursive helper
+
+    layout_definition* getLayout(uint idx) {
+      if (idx >= (uint)layouts.length())  return null;
+      return (layout_definition*) layouts.get(idx);
+    }
+
+    void setHaveLongFlags(bool z) {
+      assert(flag_limit == 0);  // not set up yet
+      flag_limit = (z? X_ATTR_LIMIT_FLAGS_HI: X_ATTR_LIMIT_NO_FLAGS_HI);
+    }
+    bool haveLongFlags() {
+     assert(flag_limit == X_ATTR_LIMIT_NO_FLAGS_HI ||
+            flag_limit == X_ATTR_LIMIT_FLAGS_HI);
+      return flag_limit == X_ATTR_LIMIT_FLAGS_HI;
+    }
+
+    // Return flag_count if idx is predef and not redef, else zero.
+    int predefCount(uint idx);
+
+    bool isRedefined(uint idx) {
+      if (idx >= flag_limit) return false;
+      return (bool)((redef >> idx) & 1);
+    }
+    bool isPredefined(uint idx) {
+      if (idx >= flag_limit) return false;
+      return (bool)(((predef & ~redef) >> idx) & 1);
+    }
+    julong flagIndexMask() {
+      return (predef | redef);
+    }
+    bool isIndex(uint idx) {
+      assert(flag_limit != 0);  // must be set up already
+      if (idx < flag_limit)
+        return (bool)(((predef | redef) >> idx) & 1);
+      else
+        return (idx - flag_limit < (uint)overflow_count.length());
+    }
+    int& getCount(uint idx) {
+      assert(isIndex(idx));
+      if (idx < flag_limit)
+        return flag_count[idx];
+      else
+        return overflow_count.get(idx - flag_limit);
+    }
+    bool aborting()             { return u->aborting(); }
+    void abort(const char* msg) { u->abort(msg); }
+  };
+
+  attr_definitions attr_defs[ATTR_CONTEXT_LIMIT];
+
+  // Initialization
+  void         init(read_input_fn_t input_fn = null);
+  // Resets to a known sane state
+  void         reset();
+  // Deallocates all storage.
+  void         free();
+  // Deallocates temporary storage (volatile after next client call).
+  void         free_temps() { tsmallbuf.init(); tmallocs.freeAll(); }
+
+  // Option management methods
+  bool         set_option(const char* option, const char* value);
+  const char*  get_option(const char* option);
+
+  void         dump_options();
+
+  // Fetching input.
+  bool   ensure_input(jlong more);
+  byte*  input_scan()               { return rp; }
+  size_t input_remaining()          { return rplimit - rp; }
+  size_t input_consumed()           { return rp - input.base(); }
+
+  // Entry points to the unpack engine
+  static int   run(int argc, char **argv);   // Unix-style entry point.
+  void         check_options();
+  void         start(void* packptr = null, size_t len = 0);
+  void         redirect_stdio();
+  void         write_file_to_jar(file* f);
+  void         finish();
+
+  // Public post unpack methods
+  int          get_files_remaining()    { return files_remaining; }
+  int          get_segments_remaining() { return archive_next_count; }
+  file*        get_next_file();  // returns null on last file
+
+  // General purpose methods
+  void*        alloc(size_t size) { return alloc_heap(size, true); }
+  void*        temp_alloc(size_t size) { return alloc_heap(size, true, true); }
+  void*        alloc_heap(size_t size, bool smallOK = false, bool temp = false);
+  void         saveTo(bytes& b, const char* str) { saveTo(b, (byte*)str, strlen(str)); }
+  void         saveTo(bytes& b, bytes& data) { saveTo(b, data.ptr, data.len); }
+  void         saveTo(bytes& b, byte* ptr, size_t len); //{ b.ptr = U_NEW...}
+  const char*  saveStr(const char* str) { bytes buf; saveTo(buf, str); return buf.strval(); }
+  const char*  saveIntStr(int num) { char buf[30]; sprintf(buf, "%d", num); return saveStr(buf); }
+#ifndef PRODUCT
+  int printcr_if_verbose(int level, const char* fmt,...);
+#endif
+  const char*  get_abort_message();
+  void         abort(const char* s = null);
+  bool         aborting() { return abort_message != null; }
+  static unpacker* current();  // find current instance
+  void checkLegacy(const char* name);
+  // Output management
+  void set_output(fillbytes* which) {
+    assert(wp == null);
+    which->ensureSize(1 << 12);  // covers the average classfile
+    wpbase  = which->base();
+    wp      = which->limit();
+    wplimit = which->end();
+  }
+  fillbytes* close_output(fillbytes* which = null);  // inverse of set_output
+
+  // These take an implicit parameter of wp/wplimit, and resize as necessary:
+  byte*  put_space(size_t len);  // allocates space at wp, returns pointer
+  size_t put_empty(size_t s)    { byte* p = put_space(s); return p - wpbase; }
+  void   ensure_put_space(size_t len);
+  void   put_bytes(bytes& b)    { b.writeTo(put_space(b.len)); }
+  void   putu1(int n)           { putu1_at(put_space(1), n); }
+  void   putu1_fast(int n)      { putu1_at(wp++,         n); }
+  void   putu2(int n);       // { putu2_at(put_space(2), n); }
+  void   putu4(int n);       // { putu4_at(put_space(4), n); }
+  void   putu8(jlong n);     // { putu8_at(put_space(8), n); }
+  void   putref(entry* e);   // { putu2_at(put_space(2), putref_index(e, 2)); }
+  void   putu1ref(entry* e); // { putu1_at(put_space(1), putref_index(e, 1)); }
+  int    putref_index(entry* e, int size);  // size in [1..2]
+  void   put_label(int curIP, int size);    // size in {2,4}
+  void   putlayout(band** body);
+  void   put_stackmap_type();
+
+  size_t wpoffset() { return (size_t)(wp - wpbase); }  // (unvariant across overflow)
+  byte*  wp_at(size_t offset) { return wpbase + offset; }
+  uint to_bci(uint bii);
+  void get_code_header(int& max_stack,
+                       int& max_na_locals,
+                       int& handler_count,
+                       int& cflags);
+  band* ref_band_for_self_op(int bc, bool& isAloadVar, int& origBCVar);
+  band* ref_band_for_op(int bc);
+
+  // Definitions of standard classfile int formats:
+  static void putu1_at(byte* wp, int n) { assert(n == (n & 0xFF)); wp[0] = n; }
+  static void putu2_at(byte* wp, int n);
+  static void putu4_at(byte* wp, int n);
+  static void putu8_at(byte* wp, jlong n);
+
+  // Private stuff
+  void reset_cur_classfile();
+  void write_classfile_tail();
+  void write_classfile_head();
+  void write_code();
+  void write_bc_ops();
+  void write_members(int num, int attrc);  // attrc=ATTR_CONTEXT_FIELD/METHOD
+  int  write_attrs(int attrc, julong indexBits);
+  int  write_ics(int naOffset, int na);
+  int  write_bsms(int naOffset, int na);
+
+  // The readers
+  void read_bands();
+  void read_file_header();
+  void read_cp();
+  void read_cp_counts(value_stream& hdr);
+  void read_attr_defs();
+  void read_ics();
+  void read_attrs(int attrc, int obj_count);
+  void read_classes();
+  void read_code_headers();
+  void read_bcs();
+  void read_bc_ops();
+  void read_files();
+  void read_Utf8_values(entry* cpMap, int len);
+  void read_single_words(band& cp_band, entry* cpMap, int len);
+  void read_double_words(band& cp_bands, entry* cpMap, int len);
+  void read_single_refs(band& cp_band, byte refTag, entry* cpMap, int len);
+  void read_double_refs(band& cp_band, byte ref1Tag, byte ref2Tag, entry* cpMap, int len);
+  void read_signature_values(entry* cpMap, int len);
+  void read_method_handle(entry* cpMap, int len);
+  void read_method_type(entry* cpMap, int len);
+  void read_bootstrap_methods(entry* cpMap, int len);
+};
+
+inline void cpool::abort(const char* msg) { u->abort(msg); }
+inline bool cpool::aborting()             { return u->aborting(); }
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/jdk/src/jdk.pack200/share/native/common-unpack/utils.cpp	Fri Mar 06 09:02:26 2015 -0800
@@ -0,0 +1,180 @@
+/*
+ * Copyright (c) 2001, 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.
+ */
+
+#include <stdarg.h>
+#include <stdio.h>
+#include <stdlib.h>
+#include <string.h>
+#include <limits.h>
+
+#include <sys/stat.h>
+
+#ifdef _MSC_VER
+#include <direct.h>
+#include <io.h>
+#include <process.h>
+#else
+#include <unistd.h>
+#endif
+
+#include "constants.h"
+#include "defines.h"
+#include "bytes.h"
+#include "utils.h"
+
+#include "unpack.h"
+
+void* must_malloc(size_t size) {
+  size_t msize = size;
+  #ifdef USE_MTRACE
+  if (msize >= 0 && msize < sizeof(int))
+    msize = sizeof(int);  // see 0xbaadf00d below
+  #endif
+  void* ptr = (msize > PSIZE_MAX || msize <= 0) ? null : malloc(msize);
+  if (ptr != null) {
+    memset(ptr, 0, size);
+  } else {
+    unpack_abort(ERROR_ENOMEM);
+  }
+  mtrace('m', ptr, size);
+  return ptr;
+}
+
+void mkdirs(int oklen, char* path) {
+
+  if (strlen(path) <= (size_t)oklen)  return;
+  char dir[PATH_MAX];
+
+  strcpy(dir, path);
+  char* slash = strrchr(dir, '/');
+  if (slash == 0)  return;
+  *slash = 0;
+  mkdirs(oklen, dir);
+  MKDIR(dir);
+}
+
+
+#ifndef PRODUCT
+void breakpoint() { }  // hook for debugger
+int assert_failed(const char* p) {
+  char message[1<<12];
+  sprintf(message, "@assert failed: %s\n", p);
+  fprintf(stdout, 1+message);
+  breakpoint();
+  unpack_abort(message);
+  return 0;
+}
+#endif
+
+void unpack_abort(const char* msg, unpacker* u) {
+  if (msg == null)  msg = "corrupt pack file or internal error";
+  if (u == null)
+    u = unpacker::current();
+  if (u == null) {
+    fprintf(stderr, "Error: unpacker: %s\n", msg);
+    ::abort();
+    return;
+  }
+  u->abort(msg);
+}
+
+bool unpack_aborting(unpacker* u) {
+  if (u == null)
+    u = unpacker::current();
+  if (u == null) {
+    fprintf(stderr, "Error: unpacker: no current instance\n");
+    ::abort();
+    return true;
+  }
+  return u->aborting();
+}
+
+#ifdef USE_MTRACE
+// Use this occasionally for detecting storage leaks in unpack.
+void mtrace(char c, void* ptr, size_t size) {
+  if (c == 'f')  *(int*)ptr = 0xbaadf00d;
+  static FILE* mtfp;
+  if (mtfp == (FILE*)-1)  return;
+  if (mtfp == null) {
+    if (getenv("USE_MTRACE") == null) {
+      mtfp = (FILE*)-1;
+      return;
+    }
+    char fname[1024];
+    sprintf(fname, "mtr%d.txt", getpid());
+    mtfp = fopen(fname, "w");
+    if (mtfp == null)
+      mtfp = stdout;
+  }
+  fprintf(mtfp, "%c %p %p\n", c, ptr, (void*)size);
+}
+
+/* # Script for processing memory traces.
+   # It should report only a limited number (2) of "suspended" blocks,
+   # even if a large number of archive segments are processed.
+   # It should report no "leaked" blocks at all.
+   nawk < mtr*.txt '
+   function checkleaks(what) {
+     nd = 0
+     for (ptr in allocated) {
+       if (allocated[ptr] == 1) {
+         print NR ": " what " " ptr
+         #allocated[ptr] = 0  # stop the dangle
+         nd++
+       }
+     }
+     if (nd > 0)  print NR ": count " what " " nd
+   }
+
+   /^[mfr]/ {
+       ptr = $2
+       a1 = ($1 == "m")? 1: 0
+       a0 = 0+allocated[ptr]
+       allocated[ptr] = a1
+       if (a0 + a1 != 1) {
+         if (a0 == 0 && a1 == 0)
+           print NR ": double free " ptr
+         else if (a0 == 1 && a1 == 1)
+           print NR ": double malloc " ptr
+         else
+           print NR ": oddity " $0
+       }
+       next
+     }
+
+   /^s/ {
+     checkleaks("suspended")
+     next
+   }
+
+   {
+     print NR ": unrecognized " $0
+   }
+   END {
+     checkleaks("leaked")
+   }
+'
+*/
+#endif // USE_MTRACE
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/jdk/src/jdk.pack200/share/native/common-unpack/utils.h	Fri Mar 06 09:02:26 2015 -0800
@@ -0,0 +1,67 @@
+/*
+ * Copyright (c) 2001, 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.
+ */
+
+//Definitions of our util functions
+
+void* must_malloc(size_t size);
+#ifndef USE_MTRACE
+#define mtrace(c, ptr, size)
+#else
+void mtrace(char c, void* ptr, size_t size);
+#endif
+
+// overflow management
+#define OVERFLOW ((uint)-1)
+#define PSIZE_MAX (OVERFLOW/2)  /* normal size limit */
+
+inline size_t scale_size(size_t size, size_t scale) {
+  return (size > PSIZE_MAX / scale) ? OVERFLOW : size * scale;
+}
+
+inline size_t add_size(size_t size1, size_t size2) {
+  return ((size1 | size2 | (size1 + size2)) > PSIZE_MAX)
+    ? OVERFLOW
+    : size1 + size2;
+}
+
+inline size_t add_size(size_t size1, size_t size2, int size3) {
+  return add_size(add_size(size1, size2), size3);
+}
+
+// These may be expensive, because they have to go via Java TSD,
+// if the optional u argument is missing.
+struct unpacker;
+extern void unpack_abort(const char* msg, unpacker* u = null);
+extern bool unpack_aborting(unpacker* u = null);
+
+#ifndef PRODUCT
+inline bool endsWith(const char* str, const char* suf) {
+  size_t len1 = strlen(str);
+  size_t len2 = strlen(suf);
+  return (len1 > len2 && 0 == strcmp(str + (len1-len2), suf));
+}
+#endif
+
+void mkdirs(int oklen, char* path);
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/jdk/src/jdk.pack200/share/native/common-unpack/zip.cpp	Fri Mar 06 09:02:26 2015 -0800
@@ -0,0 +1,668 @@
+/*
+ * Copyright (c) 2001, 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.
+ */
+
+/**
+ * Note: Lifted from uncrunch.c from jdk sources
+ */
+#include <stdio.h>
+#include <string.h>
+#include <errno.h>
+#include <time.h>
+
+#include <stdlib.h>
+
+#ifndef _MSC_VER
+#include <strings.h>
+#endif
+
+#include "defines.h"
+#include "bytes.h"
+#include "utils.h"
+
+#include "constants.h"
+#include "unpack.h"
+
+#include "zip.h"
+
+#ifdef NO_ZLIB
+
+inline bool jar::deflate_bytes(bytes& head, bytes& tail) {
+  return false;
+}
+inline uint jar::get_crc32(uint c, uchar *ptr, uint len) { return 0; }
+#define Z_NULL NULL
+
+#else // Have ZLIB
+
+#include <zlib.h>
+
+inline uint jar::get_crc32(uint c, uchar *ptr, uint len) { return crc32(c, ptr, len); }
+
+#endif // End of ZLIB
+
+#ifdef _BIG_ENDIAN
+#define SWAP_BYTES(a) \
+    ((((a) << 8) & 0xff00) | 0x00ff) & (((a) >> 8) | 0xff00)
+#else
+#define SWAP_BYTES(a)  (a)
+#endif
+
+#define GET_INT_LO(a) \
+    SWAP_BYTES(a & 0xFFFF)
+
+#define GET_INT_HI(a) \
+    SWAP_BYTES((a >> 16) & 0xFFFF)
+
+static const ushort jarmagic[2] = { SWAP_BYTES(0xCAFE), 0 };
+
+void jar::init(unpacker* u_) {
+  BYTES_OF(*this).clear();
+  u = u_;
+  u->jarout = this;
+}
+
+// Write data to the ZIP output stream.
+void jar::write_data(void* buff, int len) {
+  while (len > 0) {
+    int rc = (int)fwrite(buff, 1, len, jarfp);
+    if (rc <= 0) {
+      fprintf(u->errstrm, "Error: write on output file failed err=%d\n",errno);
+      exit(1); // Called only from the native standalone unpacker
+    }
+    output_file_offset += rc;
+    buff = ((char *)buff) + rc;
+    len -= rc;
+  }
+}
+
+void jar::add_to_jar_directory(const char* fname, bool store, int modtime,
+                               int len, int clen, uLong crc) {
+  uint fname_length = (uint)strlen(fname);
+  ushort header[23];
+  if (modtime == 0)  modtime = default_modtime;
+  uLong dostime = get_dostime(modtime);
+
+  header[0] = (ushort)SWAP_BYTES(0x4B50);
+  header[1] = (ushort)SWAP_BYTES(0x0201);
+  header[2] = (ushort)SWAP_BYTES(( store ) ? 0x0A : 0x14);
+
+  // required version
+  header[3] = (ushort)SWAP_BYTES(( store ) ? 0x0A : 0x14);
+
+  // Flags - UTF-8 compression and separating crc and sizes
+  // into separate headers for deflated file
+  header[4] = ( store ) ? SWAP_BYTES(0x0800) : 0x0808;
+
+  // Compression method 8=deflate.
+  header[5] = ( store ) ? 0x0 : SWAP_BYTES(0x08);
+
+  // Last modified date and time.
+  header[6] = (ushort)GET_INT_LO(dostime);
+  header[7] = (ushort)GET_INT_HI(dostime);
+
+  // CRC
+  header[8] = (ushort)GET_INT_LO(crc);
+  header[9] = (ushort)GET_INT_HI(crc);
+
+  // Compressed length:
+  header[10] = (ushort)GET_INT_LO(clen);
+  header[11] = (ushort)GET_INT_HI(clen);
+
+  // Uncompressed length.
+  header[12] = (ushort)GET_INT_LO(len);
+  header[13] = (ushort)GET_INT_HI(len);
+
+  // Filename length
+  header[14] = (ushort)SWAP_BYTES(fname_length);
+  // So called "extra field" length.
+  // If it's the first record we must add JAR magic sequence
+  header[15] = ( central_directory_count ) ? 0 : (ushort)SWAP_BYTES(4);
+  // So called "comment" length.
+  header[16] = 0;
+  // Disk number start
+  header[17] = 0;
+  // File flags => binary
+  header[18] = 0;
+  // More file flags
+  header[19] = 0;
+  header[20] = 0;
+  // Offset within ZIP file.
+  header[21] = (ushort)GET_INT_LO(output_file_offset);
+  header[22] = (ushort)GET_INT_HI(output_file_offset);
+
+  // Copy the whole thing into the central directory.
+  central_directory.append(header, sizeof(header));
+
+  // Copy the fname to the header.
+  central_directory.append(fname, fname_length);
+
+  // Add jar magic for the first record
+  if (central_directory_count == 0) {
+    central_directory.append((void *)jarmagic, sizeof(jarmagic));
+  }
+
+  central_directory_count++;
+}
+
+void jar::write_jar_header(const char* fname, bool store, int modtime,
+                           int len, int clen, uint crc) {
+  uint fname_length = (uint)strlen(fname);
+  ushort header[15];
+  if (modtime == 0)  modtime = default_modtime;
+  uLong dostime = get_dostime(modtime);
+
+  // ZIP LOC magic.
+  header[0] = (ushort)SWAP_BYTES(0x4B50);
+  header[1] = (ushort)SWAP_BYTES(0x0403);
+
+  // Version
+  header[2] = (ushort)SWAP_BYTES(( store ) ? 0x0A : 0x14);
+
+  // General purpose flags - same as in the Central Directory
+  header[3] = ( store ) ? SWAP_BYTES(0x0800) : 0x0808;
+
+  // Compression method = deflate
+  header[4] = ( store ) ? 0x0 : SWAP_BYTES(0x08);
+
+  // Last modified date and time.
+  header[5] = (ushort)GET_INT_LO(dostime);
+  header[6] = (ushort)GET_INT_HI(dostime);
+
+  // CRC, 0 if deflated, will come separately in extra header
+  header[7] = ( store ) ? (ushort)GET_INT_LO(crc) : 0;
+  header[8] = ( store ) ? (ushort)GET_INT_HI(crc) : 0;
+
+  // Compressed length, 0 if deflated
+  header[9] = ( store ) ? (ushort)GET_INT_LO(clen) : 0;
+  header[10] = ( store ) ? (ushort)GET_INT_HI(clen) : 0;
+
+  // Uncompressed length, 0 if deflated
+  header[11] = ( store ) ? (ushort)GET_INT_LO(len) : 0;
+  header[12] = ( store ) ? (ushort)GET_INT_HI(len) : 0;
+
+  // Filename length
+  header[13] = (ushort)SWAP_BYTES(fname_length);
+  // So called "extra field" length.
+  header[14] = ( central_directory_count - 1 ) ? 0 : (ushort)SWAP_BYTES(4);
+
+  // Write the LOC header to the output file.
+  write_data(header, (int)sizeof(header));
+
+  // Copy the fname to the header.
+  write_data((char*)fname, (int)fname_length);
+
+  if (central_directory_count == 1) {
+    // Write JAR magic sequence
+    write_data((void *)jarmagic, (int)sizeof(jarmagic));
+  }
+}
+
+void jar::write_jar_extra(int len, int clen, uint crc) {
+  ushort header[8];
+  // Extra field signature
+  header[0] = (ushort)SWAP_BYTES(0x4B50);
+  header[1] = (ushort)SWAP_BYTES(0x0807);
+  // CRC
+  header[2] = (ushort)GET_INT_LO(crc);
+  header[3] = (ushort)GET_INT_HI(crc);
+  // Compressed length
+  header[4] = (ushort)GET_INT_LO(clen);
+  header[5] = (ushort)GET_INT_HI(clen);
+  // Uncompressed length
+  header[6] = (ushort)GET_INT_LO(len);
+  header[7] = (ushort)GET_INT_HI(len);
+
+  write_data(header, sizeof(header));
+}
+
+static const char marker_comment[] = ZIP_ARCHIVE_MARKER_COMMENT;
+
+void jar::write_central_directory() {
+  bytes mc; mc.set(marker_comment);
+
+  ushort header[11];
+  ushort header64[38];
+
+  // Create the End of Central Directory structure.
+  header[0] = (ushort)SWAP_BYTES(0x4B50);
+  header[1] = (ushort)SWAP_BYTES(0x0605);
+  // disk numbers
+  header[2] = 0;
+  header[3] = 0;
+  // Number of entries in central directory.
+  header[4] = ( central_directory_count >= 0xffff ) ? 0xffff : (ushort)SWAP_BYTES(central_directory_count);
+  header[5] = ( central_directory_count >= 0xffff ) ? 0xffff : (ushort)SWAP_BYTES(central_directory_count);
+  // Size of the central directory}
+  header[6] = (ushort)GET_INT_LO((int)central_directory.size());
+  header[7] = (ushort)GET_INT_HI((int)central_directory.size());
+  // Offset of central directory within disk.
+  header[8] = (ushort)GET_INT_LO(output_file_offset);
+  header[9] = (ushort)GET_INT_HI(output_file_offset);
+  // zipfile comment length;
+  header[10] = (ushort)SWAP_BYTES((int)mc.len);
+
+  // Write the central directory.
+  PRINTCR((2, "Central directory at %d\n", output_file_offset));
+  write_data(central_directory.b);
+
+  // If number of records exceeds the 0xFFFF we need to prepend extended
+  // Zip64 End of Central Directory record and its locator to the old
+  // style ECD record
+  if (central_directory_count > 0xFFFF) {
+    // Zip64 END signature
+    header64[0] = (ushort)SWAP_BYTES(0x4B50);
+    header64[1] = (ushort)0x0606;
+    // Size of header (long)
+    header64[2] = (ushort)SWAP_BYTES(44);;
+    header64[3] = 0;
+    header64[4] = 0;
+    header64[5] = 0;
+    // Version produced and required (short)
+    header64[6] = (ushort)SWAP_BYTES(45);
+    header64[7] = (ushort)SWAP_BYTES(45);
+    // Current disk number (int)
+    header64[8] = 0;
+    header64[9] = 0;
+    // Central directory start disk (int)
+    header64[10] = 0;
+    header64[11] = 0;
+    // Count of records on disk (long)
+    header64[12] = (ushort)GET_INT_LO(central_directory_count);
+    header64[13] = (ushort)GET_INT_HI(central_directory_count);
+    header64[14] = 0;
+    header64[15] = 0;
+    // Count of records totally (long)
+    header64[16] = (ushort)GET_INT_LO(central_directory_count);
+    header64[17] = (ushort)GET_INT_HI(central_directory_count);
+    header64[18] = 0;
+    header64[19] = 0;
+    // Length of the central directory (long)
+    header64[20] = header[6];
+    header64[21] = header[7];
+    header64[22] = 0;
+    header64[23] = 0;
+    // Offset of central directory (long)
+    header64[24] = header[8];
+    header64[25] = header[9];
+    header64[26] = 0;
+    header64[27] = 0;
+    // Zip64 end of central directory locator
+    // Locator signature
+    header64[28] = (ushort)SWAP_BYTES(0x4B50);
+    header64[29] = (ushort)SWAP_BYTES(0x0706);
+    // Start disk number (int)
+    header64[30] = 0;
+    header64[31] = 0;
+    // Offset of zip64 END record (long)
+    header64[32] = (ushort)GET_INT_LO(output_file_offset);
+    header64[33] = (ushort)GET_INT_HI(output_file_offset);
+    header64[34] = 0;
+    header64[35] = 0;
+    // Total number of disks (int)
+    header64[36] = (ushort)SWAP_BYTES(1);
+    header64[37] = 0;
+    write_data(header64, (int)sizeof(header64));
+  }
+
+  // Write the End of Central Directory structure.
+  PRINTCR((2, "end-of-directory at %d\n", output_file_offset));
+  write_data(header, (int)sizeof(header));
+
+  PRINTCR((2, "writing zip comment\n"));
+  // Write the comment.
+  write_data(mc);
+}
+
+// Public API
+
+// Open a Jar file and initialize.
+void jar::openJarFile(const char* fname) {
+  if (!jarfp) {
+    PRINTCR((1, "jar::openJarFile: opening %s\n",fname));
+    jarfp = fopen(fname, "wb");
+    if (!jarfp) {
+      fprintf(u->errstrm, "Error: Could not open jar file: %s\n",fname);
+      exit(3); // Called only from the native standalone unpacker
+    }
+  }
+}
+
+// Add a ZIP entry and copy the file data
+void jar::addJarEntry(const char* fname,
+                      bool deflate_hint, int modtime,
+                      bytes& head, bytes& tail) {
+  int len = (int)(head.len + tail.len);
+  int clen = 0;
+
+  uint crc = get_crc32(0,Z_NULL,0);
+  if (head.len != 0)
+    crc = get_crc32(crc, (uchar *)head.ptr, (uint)head.len);
+  if (tail.len != 0)
+    crc = get_crc32(crc, (uchar *)tail.ptr, (uint)tail.len);
+
+  bool deflate = (deflate_hint && len > 0);
+
+  if (deflate) {
+    if (deflate_bytes(head, tail) == false) {
+      PRINTCR((2, "Reverting to store fn=%s\t%d -> %d\n",
+              fname, len, deflated.size()));
+      deflate = false;
+    }
+  }
+  clen = (int)((deflate) ? deflated.size() : len);
+  add_to_jar_directory(fname, !deflate, modtime, len, clen, crc);
+  write_jar_header(    fname, !deflate, modtime, len, clen, crc);
+
+  if (deflate) {
+    write_data(deflated.b);
+    // Write deflated information in extra header
+    write_jar_extra(len, clen, crc);
+  } else {
+    write_data(head);
+    write_data(tail);
+  }
+}
+
+// Add a ZIP entry for a directory name no data
+void jar::addDirectoryToJarFile(const char* dir_name) {
+  bool store = true;
+  add_to_jar_directory((const char*)dir_name, store, default_modtime, 0, 0, 0);
+  write_jar_header(    (const char*)dir_name, store, default_modtime, 0, 0, 0);
+}
+
+// Write out the central directory and close the jar file.
+void jar::closeJarFile(bool central) {
+  if (jarfp) {
+    fflush(jarfp);
+    if (central) write_central_directory();
+    fflush(jarfp);
+    fclose(jarfp);
+    PRINTCR((2, "jar::closeJarFile:closed jar-file\n"));
+  }
+  reset();
+}
+
+/* Convert the date y/n/d and time h:m:s to a four byte DOS date and
+ *  time (date in high two bytes, time in low two bytes allowing magnitude
+ *  comparison).
+ */
+inline
+uLong jar::dostime(int y, int n, int d, int h, int m, int s) {
+  return y < 1980 ? dostime(1980, 1, 1, 0, 0, 0) :
+    (((uLong)y - 1980) << 25) | ((uLong)n << 21) | ((uLong)d << 16) |
+    ((uLong)h << 11) | ((uLong)m << 5) | ((uLong)s >> 1);
+}
+
+#ifdef _REENTRANT // solaris
+extern "C" struct tm *gmtime_r(const time_t *, struct tm *);
+#else
+#define gmtime_r(t, s) gmtime(t)
+#endif
+/*
+ * Return the Unix time in DOS format
+ */
+uLong jar::get_dostime(int modtime) {
+  // see defines.h
+  if (modtime != 0 && modtime == modtime_cache)
+    return dostime_cache;
+  if (modtime != 0 && default_modtime == 0)
+    default_modtime = modtime;  // catch a reasonable default
+  time_t t = modtime;
+  struct tm sbuf;
+  (void)memset((void*)&sbuf,0, sizeof(sbuf));
+  struct tm* s = gmtime_r(&t, &sbuf);
+  if (s == NULL) {
+    fprintf(u->errstrm, "Error: gmtime failure, invalid input archive\n");
+    exit(-1);
+  }
+  modtime_cache = modtime;
+  dostime_cache = dostime(s->tm_year + 1900, s->tm_mon + 1, s->tm_mday,
+                          s->tm_hour, s->tm_min, s->tm_sec);
+  //printf("modtime %d => %d\n", modtime_cache, dostime_cache);
+  return dostime_cache;
+}
+
+
+
+#ifndef NO_ZLIB
+
+/* Returns true on success, and will set the clen to the compressed
+   length, the caller should verify if true and clen less than the
+   input data
+*/
+bool jar::deflate_bytes(bytes& head, bytes& tail) {
+  int len = (int)(head.len + tail.len);
+
+  z_stream zs;
+  BYTES_OF(zs).clear();
+
+  // NOTE: the window size should always be -MAX_WBITS normally -15.
+  // unzip/zipup.c and java/Deflater.c
+
+  int error = deflateInit2(&zs, Z_DEFAULT_COMPRESSION, Z_DEFLATED,
+                           -MAX_WBITS, 8, Z_DEFAULT_STRATEGY);
+  if (error != Z_OK) {
+    switch (error) {
+    case Z_MEM_ERROR:
+      PRINTCR((2, "Error: deflate error : Out of memory \n"));
+      break;
+    case Z_STREAM_ERROR:
+      PRINTCR((2,"Error: deflate error : Invalid compression level \n"));
+      break;
+    case Z_VERSION_ERROR:
+      PRINTCR((2,"Error: deflate error : Invalid version\n"));
+      break;
+    default:
+      PRINTCR((2,"Error: Internal deflate error error = %d\n", error));
+    }
+    return false;
+  }
+
+  deflated.empty();
+  zs.next_out  = (uchar*) deflated.grow(add_size(len, (len/2)));
+  zs.avail_out = (int)deflated.size();
+
+  zs.next_in = (uchar*)head.ptr;
+  zs.avail_in = (int)head.len;
+
+  bytes* first = &head;
+  bytes* last  = &tail;
+  if (last->len == 0) {
+    first = null;
+    last = &head;
+  } else if (first->len == 0) {
+    first = null;
+  }
+
+  if (first != null && error == Z_OK) {
+    zs.next_in = (uchar*) first->ptr;
+    zs.avail_in = (int)first->len;
+    error = deflate(&zs, Z_NO_FLUSH);
+  }
+  if (error == Z_OK) {
+    zs.next_in = (uchar*) last->ptr;
+    zs.avail_in = (int)last->len;
+    error = deflate(&zs, Z_FINISH);
+  }
+  if (error == Z_STREAM_END) {
+    if ((int)zs.total_out > 0) {
+      // Even if compressed size is bigger than uncompressed, write it
+      PRINTCR((2, "deflate compressed data %d -> %d\n", len, zs.total_out));
+      deflated.b.len = zs.total_out;
+      deflateEnd(&zs);
+      return true;
+    }
+    PRINTCR((2, "deflate expanded data %d -> %d\n", len, zs.total_out));
+    deflateEnd(&zs);
+    return false;
+  }
+
+  deflateEnd(&zs);
+  PRINTCR((2, "Error: deflate error deflate did not finish error=%d\n",error));
+  return false;
+}
+
+// Callback for fetching data from a GZIP input stream
+static jlong read_input_via_gzip(unpacker* u,
+                                  void* buf, jlong minlen, jlong maxlen) {
+  assert(minlen <= maxlen);  // don't talk nonsense
+  jlong numread = 0;
+  char* bufptr = (char*) buf;
+  char* inbuf = u->gzin->inbuf;
+  size_t inbuflen = sizeof(u->gzin->inbuf);
+  unpacker::read_input_fn_t read_gzin_fn =
+    (unpacker::read_input_fn_t) u->gzin->read_input_fn;
+  z_stream& zs = *(z_stream*) u->gzin->zstream;
+  while (numread < minlen) {
+    int readlen = (1 << 16);  // pretty arbitrary
+    if (readlen > (maxlen - numread))
+      readlen = (int)(maxlen - numread);
+    zs.next_out = (uchar*) bufptr;
+    zs.avail_out = readlen;
+    if (zs.avail_in == 0) {
+      zs.avail_in = (int) read_gzin_fn(u, inbuf, 1, inbuflen);
+      zs.next_in = (uchar*) inbuf;
+    }
+    int error = inflate(&zs, Z_NO_FLUSH);
+    if (error != Z_OK && error != Z_STREAM_END) {
+      u->abort("error inflating input");
+      break;
+    }
+    int nr = readlen - zs.avail_out;
+    u->gzcrc = crc32(u->gzcrc, (const unsigned char *)bufptr, nr);
+    numread += nr;
+    bufptr += nr;
+    assert(numread <= maxlen);
+    if (error == Z_STREAM_END) {
+      enum { TRAILER_LEN = 8 };
+      // skip 8-byte trailer
+      if (zs.avail_in >= TRAILER_LEN) {
+        zs.avail_in -= TRAILER_LEN;
+      } else {
+        // Bug: 5023768,we read past the TRAILER_LEN to see if there is
+        // any extraneous data, as we don't support concatenated .gz
+        // files just yet.
+        int extra = (int) read_gzin_fn(u, inbuf, 1, inbuflen);
+        zs.avail_in += extra - TRAILER_LEN;
+      }
+      // %%% should check final CRC and length here
+      // %%% should check for concatenated *.gz files here
+      if (zs.avail_in > 0)
+        u->abort("garbage after end of deflated input stream");
+      // pop this filter off:
+      u->gzin->free();
+      break;
+    }
+  }
+
+  //fprintf(u->errstrm, "readInputFn(%d,%d) => %d (gunzip)\n",
+  //        (int)minlen, (int)maxlen, (int)numread);
+  return numread;
+}
+
+void gunzip::init(unpacker* u_) {
+  BYTES_OF(*this).clear();
+  u = u_;
+  assert(u->gzin == null);  // once only, please
+  read_input_fn = (void*)u->read_input_fn;
+  zstream = NEW(z_stream, 1);
+  u->gzin = this;
+  u->read_input_fn = read_input_via_gzip;
+  u->gzcrc = crc32(0L, Z_NULL, 0);
+}
+
+void gunzip::start(int magic) {
+  assert((magic & GZIP_MAGIC_MASK) == GZIP_MAGIC);
+  int gz_flg = (magic & 0xFF);  // keep "flg", discard other 3 bytes
+  enum {
+    FHCRC    = (1<<1),
+    FEXTRA   = (1<<2),
+    FNAME    = (1<<3),
+    FCOMMENT = (1<<4)
+  };
+  char gz_mtime[4];
+  char gz_xfl[1];
+  char gz_os[1];
+  char gz_extra_len[2];
+  char gz_hcrc[2];
+  char gz_ignore;
+  // do not save extra, name, comment
+  read_fixed_field(gz_mtime, sizeof(gz_mtime));
+  read_fixed_field(gz_xfl, sizeof(gz_xfl));
+  read_fixed_field(gz_os, sizeof(gz_os));
+  if (gz_flg & FEXTRA) {
+    read_fixed_field(gz_extra_len, sizeof(gz_extra_len));
+    int extra_len = gz_extra_len[0] & 0xFF;
+    extra_len += (gz_extra_len[1] & 0xFF) << 8;
+    for (; extra_len > 0; extra_len--) {
+      read_fixed_field(&gz_ignore, 1);
+    }
+  }
+  int null_terms = 0;
+  if (gz_flg & FNAME)     null_terms++;
+  if (gz_flg & FCOMMENT)  null_terms++;
+  for (; null_terms; null_terms--) {
+    for (;;) {
+      gz_ignore = 0;
+      read_fixed_field(&gz_ignore, 1);
+      if (gz_ignore == 0)  break;
+    }
+  }
+  if (gz_flg & FHCRC)
+    read_fixed_field(gz_hcrc, sizeof(gz_hcrc));
+
+  if (aborting())  return;
+
+  // now the input stream is ready to read into the inflater
+  int error = inflateInit2((z_stream*) zstream, -MAX_WBITS);
+  if (error != Z_OK) { abort("cannot create input"); return; }
+}
+
+void gunzip::free() {
+  assert(u->gzin == this);
+  u->gzin = null;
+  u->read_input_fn = (unpacker::read_input_fn_t) this->read_input_fn;
+  inflateEnd((z_stream*) zstream);
+  mtrace('f', zstream, 0);
+  ::free(zstream);
+  zstream = null;
+  mtrace('f', this, 0);
+  ::free(this);
+}
+
+void gunzip::read_fixed_field(char* buf, size_t buflen) {
+  if (aborting())  return;
+  jlong nr = ((unpacker::read_input_fn_t)read_input_fn)
+    (u, buf, buflen, buflen);
+  if ((size_t)nr != buflen)
+    u->abort("short stream header");
+}
+
+#else // NO_ZLIB
+
+void gunzip::free() {
+}
+
+#endif // NO_ZLIB
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/jdk/src/jdk.pack200/share/native/common-unpack/zip.h	Fri Mar 06 09:02:26 2015 -0800
@@ -0,0 +1,113 @@
+/*
+ * Copyright (c) 2001, 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.
+ */
+
+#define ushort unsigned short
+#define uint   unsigned int
+#define uchar  unsigned char
+
+struct unpacker;
+
+struct jar {
+  // JAR file writer
+  FILE*       jarfp;
+  int         default_modtime;
+
+  // Used by unix2dostime:
+  int         modtime_cache;
+  uLong       dostime_cache;
+
+  // Private members
+  fillbytes   central_directory;
+  uint        central_directory_count;
+  uint        output_file_offset;
+  fillbytes   deflated;  // temporary buffer
+
+  // pointer to outer unpacker, for error checks etc.
+  unpacker* u;
+
+  // Public Methods
+  void openJarFile(const char* fname);
+  void addJarEntry(const char* fname,
+                   bool deflate_hint, int modtime,
+                   bytes& head, bytes& tail);
+  void addDirectoryToJarFile(const char* dir_name);
+  void closeJarFile(bool central);
+
+  void init(unpacker* u_);
+
+  void free() {
+    central_directory.free();
+    deflated.free();
+  }
+
+  void reset() {
+    free();
+    init(u);
+  }
+
+  // Private Methods
+  void write_data(void* ptr, int len);
+  void write_data(bytes& b) { write_data(b.ptr, (int)b.len); }
+  void add_to_jar_directory(const char* fname, bool store, int modtime,
+                            int len, int clen, uLong crc);
+  void write_jar_header(const char* fname, bool store, int modtime,
+                        int len, int clen, unsigned int crc);
+  void write_jar_extra(int len, int clen, unsigned int crc);
+  void write_central_directory();
+  uLong dostime(int y, int n, int d, int h, int m, int s);
+  uLong get_dostime(int modtime);
+
+  // The definitions of these depend on the NO_ZLIB option:
+  bool deflate_bytes(bytes& head, bytes& tail);
+  static uint get_crc32(uint c, unsigned char *ptr, uint len);
+
+  // error handling
+  void abort(const char* msg) { unpack_abort(msg, u); }
+  bool aborting()             { return unpack_aborting(u); }
+};
+
+struct gunzip {
+  // optional gzip input stream control block
+
+  // pointer to outer unpacker, for error checks etc.
+  unpacker* u;
+
+  void* read_input_fn;  // underlying byte stream
+  void* zstream;        // inflater state
+  char inbuf[1 << 14];   // input buffer
+
+  void init(unpacker* u_);  // pushes new value on u->read_input_fn
+
+  void free();
+
+  void start(int magic);
+
+  // private stuff
+  void read_fixed_field(char* buf, size_t buflen);
+
+  // error handling
+  void abort(const char* msg) { unpack_abort(msg, u); }
+  bool aborting()             { return unpack_aborting(u); }
+};
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/jdk/src/jdk.pack200/share/native/libunpack/jni.cpp	Fri Mar 06 09:02:26 2015 -0800
@@ -0,0 +1,345 @@
+/*
+ * Copyright (c) 2003, 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.
+ */
+#include <sys/types.h>
+
+#include <stdio.h>
+#include <string.h>
+#include <stdlib.h>
+#include <stdarg.h>
+
+
+#include <limits.h>
+
+#include <com_sun_java_util_jar_pack_NativeUnpack.h>
+
+#include "jni_util.h"
+
+#include "defines.h"
+#include "bytes.h"
+#include "utils.h"
+#include "coding.h"
+#include "bands.h"
+#include "constants.h"
+#include "zip.h"
+#include "unpack.h"
+
+
+static jfieldID  unpackerPtrFID;
+static jmethodID currentInstMID;
+static jmethodID readInputMID;
+static jclass    NIclazz;
+static jmethodID getUnpackerPtrMID;
+
+static char* dbg = null;
+
+#define THROW_IOE(x) JNU_ThrowIOException(env,x)
+
+#define CHECK_EXCEPTION_RETURN_VOID_THROW_IOE(CERVTI_exception, CERVTI_message) \
+    do { \
+        if ((env)->ExceptionOccurred()) { \
+            THROW_IOE(CERVTI_message); \
+            return; \
+        } \
+        if ((CERVTI_exception) == NULL) { \
+                THROW_IOE(CERVTI_message); \
+                return; \
+        } \
+    } while (JNI_FALSE)
+
+
+#define CHECK_EXCEPTION_RETURN_VALUE(CERL_exception, CERL_return_value) \
+    do { \
+        if ((env)->ExceptionOccurred()) { \
+            return CERL_return_value; \
+        } \
+        if ((CERL_exception) == NULL) { \
+            return CERL_return_value; \
+        } \
+    } while (JNI_FALSE)
+
+
+// If these useful macros aren't defined in jni_util.h then define them here
+#ifndef CHECK_NULL_RETURN
+#define CHECK_NULL_RETURN(x, y) \
+    do { \
+        if ((x) == NULL) return (y); \
+    } while (JNI_FALSE)
+#endif
+
+#ifndef CHECK_EXCEPTION_RETURN
+#define CHECK_EXCEPTION_RETURN(env, y) \
+    do { \
+        if ((*env)->ExceptionCheck(env)) return (y); \
+    } while (JNI_FALSE)
+#endif
+
+static jlong read_input_via_jni(unpacker* self,
+                                void* buf, jlong minlen, jlong maxlen);
+
+static unpacker* get_unpacker(JNIEnv *env, jobject pObj, bool noCreate=false) {
+  unpacker* uPtr;
+  jlong p = env->CallLongMethod(pObj, getUnpackerPtrMID);
+  uPtr = (unpacker*)jlong2ptr(p);
+  if (uPtr == null) {
+    if (noCreate)  return null;
+    uPtr = new unpacker();
+    if (uPtr == null) {
+      THROW_IOE(ERROR_ENOMEM);
+      return null;
+    }
+    //fprintf(stderr, "get_unpacker(%p) uPtr=%p initializing\n", pObj, uPtr);
+    uPtr->init(read_input_via_jni);
+    uPtr->jniobj = (void*) env->NewGlobalRef(pObj);
+    env->SetLongField(pObj, unpackerPtrFID, ptr2jlong(uPtr));
+  }
+  uPtr->jnienv = env;  // keep refreshing this in case of MT access
+  return uPtr;
+}
+
+// This is the harder trick:  Pull the current state out of mid-air.
+static unpacker* get_unpacker() {
+  //fprintf(stderr, "get_unpacker()\n");
+  JavaVM* vm = null;
+  jsize nVM = 0;
+  jint retval = JNI_GetCreatedJavaVMs(&vm, 1, &nVM);
+  // other VM implements may differ, thus for correctness, we need these checks
+  if (retval != JNI_OK || nVM != 1)
+    return null;
+  void* envRaw = null;
+  vm->GetEnv(&envRaw, JNI_VERSION_1_1);
+  JNIEnv* env = (JNIEnv*) envRaw;
+  //fprintf(stderr, "get_unpacker() env=%p\n", env);
+  CHECK_NULL_RETURN(env, NULL);
+  jobject pObj = env->CallStaticObjectMethod(NIclazz, currentInstMID);
+  // We should check upon the known non-null variable because here we want to check
+  // only for pending exceptions. If pObj is null we'll deal with it later.
+  CHECK_EXCEPTION_RETURN_VALUE(env, NULL);
+  //fprintf(stderr, "get_unpacker0() pObj=%p\n", pObj);
+  if (pObj != null) {
+    // Got pObj and env; now do it the easy way.
+    return get_unpacker(env, pObj);
+  }
+  // this should really not happen, if it does something is seriously
+  // wrong throw an exception
+  THROW_IOE(ERROR_INTERNAL);
+  return null;
+}
+
+static void free_unpacker(JNIEnv *env, jobject pObj, unpacker* uPtr) {
+  if (uPtr != null) {
+    //fprintf(stderr, "free_unpacker(%p) uPtr=%p\n", pObj, uPtr);
+    env->DeleteGlobalRef((jobject) uPtr->jniobj);
+    uPtr->jniobj = null;
+    uPtr->free();
+    delete uPtr;
+    env->SetLongField(pObj, unpackerPtrFID, (jlong)null);
+   }
+}
+
+unpacker* unpacker::current() {
+  return get_unpacker();
+}
+
+// Callback for fetching data, Java style.  Calls NativeUnpack.readInputFn().
+static jlong read_input_via_jni(unpacker* self,
+                                void* buf, jlong minlen, jlong maxlen) {
+  JNIEnv* env = (JNIEnv*) self->jnienv;
+  jobject pbuf = env->NewDirectByteBuffer(buf, maxlen);
+  return env->CallLongMethod((jobject) self->jniobj, readInputMID,
+                             pbuf, minlen);
+}
+
+JNIEXPORT void JNICALL
+Java_com_sun_java_util_jar_pack_NativeUnpack_initIDs(JNIEnv *env, jclass clazz) {
+#ifndef PRODUCT
+  dbg = getenv("DEBUG_ATTACH");
+  while( dbg != null) { sleep(10); }
+#endif
+  NIclazz = (jclass) env->NewGlobalRef(clazz);
+
+  unpackerPtrFID = env->GetFieldID(clazz, "unpackerPtr", "J");
+  CHECK_EXCEPTION_RETURN_VOID_THROW_IOE(unpackerPtrFID, ERROR_INIT);
+
+  currentInstMID = env->GetStaticMethodID(clazz, "currentInstance",
+                                          "()Ljava/lang/Object;");
+  CHECK_EXCEPTION_RETURN_VOID_THROW_IOE(currentInstMID, ERROR_INIT);
+
+  readInputMID = env->GetMethodID(clazz, "readInputFn",
+                                  "(Ljava/nio/ByteBuffer;J)J");
+  CHECK_EXCEPTION_RETURN_VOID_THROW_IOE(readInputMID, ERROR_INIT);
+
+  getUnpackerPtrMID = env->GetMethodID(clazz, "getUnpackerPtr", "()J");
+  CHECK_EXCEPTION_RETURN_VOID_THROW_IOE(getUnpackerPtrMID, ERROR_INIT);
+}
+
+JNIEXPORT jlong JNICALL
+Java_com_sun_java_util_jar_pack_NativeUnpack_start(JNIEnv *env, jobject pObj,
+                                   jobject pBuf, jlong offset) {
+  // try to get the unpacker pointer the hard way first, we do this to ensure
+  // valid object pointers and env is intact, if not now is good time to bail.
+  unpacker* uPtr = get_unpacker();
+  //fprintf(stderr, "start(%p) uPtr=%p initializing\n", pObj, uPtr);
+  CHECK_EXCEPTION_RETURN_VALUE(uPtr, -1);
+  // redirect our io to the default log file or whatever.
+  uPtr->redirect_stdio();
+
+  void*  buf    = null;
+  size_t buflen = 0;
+  if (pBuf != null) {
+    buf    = env->GetDirectBufferAddress(pBuf);
+    buflen = (size_t)env->GetDirectBufferCapacity(pBuf);
+    if (buflen == 0)  buf = null;
+    if (buf == null) { THROW_IOE(ERROR_INTERNAL); return 0; }
+    if ((size_t)offset >= buflen)
+      { buf = null; buflen = 0; }
+    else
+      { buf = (char*)buf + (size_t)offset; buflen -= (size_t)offset; }
+  }
+  // before we start off we make sure there is no other error by the time we
+  // get here
+  if (uPtr->aborting()) {
+    THROW_IOE(uPtr->get_abort_message());
+    return 0;
+  }
+  uPtr->start(buf, buflen);
+  if (uPtr->aborting()) {
+    THROW_IOE(uPtr->get_abort_message());
+    return 0;
+  }
+
+  return ((jlong)
+          uPtr->get_segments_remaining() << 32)
+    + uPtr->get_files_remaining();
+}
+
+JNIEXPORT jboolean JNICALL
+Java_com_sun_java_util_jar_pack_NativeUnpack_getNextFile(JNIEnv *env, jobject pObj,
+                                         jobjectArray pParts) {
+
+  unpacker* uPtr = get_unpacker(env, pObj);
+  CHECK_EXCEPTION_RETURN_VALUE(uPtr, false);
+  unpacker::file* filep = uPtr->get_next_file();
+
+  if (uPtr->aborting()) {
+    THROW_IOE(uPtr->get_abort_message());
+    return false;
+  }
+
+  CHECK_NULL_RETURN(filep, false);
+  assert(filep == &uPtr->cur_file);
+
+  int pidx = 0, iidx = 0;
+  jintArray pIntParts = (jintArray) env->GetObjectArrayElement(pParts, pidx++);
+  CHECK_EXCEPTION_RETURN_VALUE(pIntParts, false);
+  jint*     intParts  = env->GetIntArrayElements(pIntParts, null);
+  intParts[iidx++] = (jint)( (julong)filep->size >> 32 );
+  intParts[iidx++] = (jint)( (julong)filep->size >>  0 );
+  intParts[iidx++] = filep->modtime;
+  intParts[iidx++] = filep->deflate_hint() ? 1 : 0;
+  env->ReleaseIntArrayElements(pIntParts, intParts, JNI_COMMIT);
+  jstring filename = env->NewStringUTF(filep->name);
+  CHECK_EXCEPTION_RETURN_VALUE(filename, false);
+  env->SetObjectArrayElement(pParts, pidx++, filename);
+  CHECK_EXCEPTION_RETURN_VALUE(uPtr, false);
+  jobject pDataBuf = null;
+  if (filep->data[0].len > 0) {
+    pDataBuf = env->NewDirectByteBuffer(filep->data[0].ptr,
+                                        filep->data[0].len);
+    CHECK_EXCEPTION_RETURN_VALUE(pDataBuf, false);
+  }
+  env->SetObjectArrayElement(pParts, pidx++, pDataBuf);
+  CHECK_EXCEPTION_RETURN_VALUE(uPtr, false);
+  pDataBuf = null;
+  if (filep->data[1].len > 0) {
+    pDataBuf = env->NewDirectByteBuffer(filep->data[1].ptr,
+                                        filep->data[1].len);
+    CHECK_EXCEPTION_RETURN_VALUE(pDataBuf, false);
+  }
+  env->SetObjectArrayElement(pParts, pidx++, pDataBuf);
+  CHECK_EXCEPTION_RETURN_VALUE(uPtr, false);
+
+  return true;
+}
+
+
+JNIEXPORT jobject JNICALL
+Java_com_sun_java_util_jar_pack_NativeUnpack_getUnusedInput(JNIEnv *env, jobject pObj) {
+  unpacker* uPtr = get_unpacker(env, pObj);
+  CHECK_EXCEPTION_RETURN_VALUE(uPtr, NULL);
+  unpacker::file* filep = &uPtr->cur_file;
+
+  if (uPtr->aborting()) {
+    THROW_IOE(uPtr->get_abort_message());
+    return false;
+  }
+
+  // We have fetched all the files.
+  // Now swallow up any remaining input.
+  if (uPtr->input_remaining() == 0) {
+    return null;
+  } else {
+    bytes remaining_bytes;
+    remaining_bytes.malloc(uPtr->input_remaining());
+    remaining_bytes.copyFrom(uPtr->input_scan(), uPtr->input_remaining());
+    return env->NewDirectByteBuffer(remaining_bytes.ptr, remaining_bytes.len);
+  }
+}
+
+JNIEXPORT jlong JNICALL
+Java_com_sun_java_util_jar_pack_NativeUnpack_finish(JNIEnv *env, jobject pObj) {
+  unpacker* uPtr = get_unpacker(env, pObj, false);
+  CHECK_EXCEPTION_RETURN_VALUE(uPtr, NULL);
+  size_t consumed = uPtr->input_consumed();
+  free_unpacker(env, pObj, uPtr);
+  return consumed;
+}
+
+JNIEXPORT jboolean JNICALL
+Java_com_sun_java_util_jar_pack_NativeUnpack_setOption(JNIEnv *env, jobject pObj,
+                                       jstring pProp, jstring pValue) {
+  unpacker*   uPtr  = get_unpacker(env, pObj);
+  const char* prop  = env->GetStringUTFChars(pProp, JNI_FALSE);
+  CHECK_EXCEPTION_RETURN_VALUE(prop, false);
+  const char* value = env->GetStringUTFChars(pValue, JNI_FALSE);
+  CHECK_EXCEPTION_RETURN_VALUE(value, false);
+  jboolean   retval = uPtr->set_option(prop, value);
+  env->ReleaseStringUTFChars(pProp,  prop);
+  env->ReleaseStringUTFChars(pValue, value);
+  return retval;
+}
+
+JNIEXPORT jstring JNICALL
+Java_com_sun_java_util_jar_pack_NativeUnpack_getOption(JNIEnv *env, jobject pObj,
+                                       jstring pProp) {
+
+  unpacker*   uPtr  = get_unpacker(env, pObj);
+  CHECK_EXCEPTION_RETURN_VALUE(uPtr, NULL);
+  const char* prop  = env->GetStringUTFChars(pProp, JNI_FALSE);
+  CHECK_EXCEPTION_RETURN_VALUE(prop, NULL);
+  const char* value = uPtr->get_option(prop);
+  CHECK_EXCEPTION_RETURN_VALUE(value, NULL);
+  env->ReleaseStringUTFChars(pProp, prop);
+  return env->NewStringUTF(value);
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/jdk/src/jdk.pack200/share/native/unpack200/main.cpp	Fri Mar 06 09:02:26 2015 -0800
@@ -0,0 +1,470 @@
+/*
+ * Copyright (c) 2003, 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.
+ */
+#ifdef _ALLBSD_SOURCE
+#include <stdint.h>
+#define THRTYPE intptr_t
+#else
+#define THRTYPE int
+#endif
+
+#include <sys/types.h>
+
+#include <stdio.h>
+#include <string.h>
+#include <stdlib.h>
+#include <stdarg.h>
+#include <errno.h>
+
+#include <limits.h>
+#include <time.h>
+
+#if defined(unix) && !defined(PRODUCT)
+#include "pthread.h"
+#define THREAD_SELF ((THRTYPE)pthread_self())
+#endif
+
+#include "defines.h"
+#include "bytes.h"
+#include "utils.h"
+#include "coding.h"
+#include "bands.h"
+
+#include "constants.h"
+
+#include "zip.h"
+
+#include "unpack.h"
+
+
+int main(int argc, char **argv) {
+    return unpacker::run(argc, argv);
+}
+
+// Dealing with big-endian arch
+#ifdef _BIG_ENDIAN
+#define SWAP_INT(a) (((a>>24)&0xff) | ((a<<8)&0xff0000) | ((a>>8)&0xff00) | ((a<<24)&0xff000000))
+#else
+#define SWAP_INT(a) (a)
+#endif
+
+// Single-threaded, implementation, not reentrant.
+// Includes a weak error check against MT access.
+#ifndef THREAD_SELF
+#define THREAD_SELF ((THRTYPE) 0)
+#endif
+NOT_PRODUCT(static THRTYPE uThread = -1;)
+
+unpacker* unpacker::non_mt_current = null;
+unpacker* unpacker::current() {
+  //assert(uThread == THREAD_SELF);
+  return non_mt_current;
+}
+static void set_current_unpacker(unpacker* u) {
+  unpacker::non_mt_current = u;
+  assert(((uThread = (u == null) ? (THRTYPE) -1 : THREAD_SELF),
+          true));
+}
+
+// Callback for fetching data, Unix style.
+static jlong read_input_via_stdio(unpacker* u,
+                                  void* buf, jlong minlen, jlong maxlen) {
+  assert(minlen <= maxlen);  // don't talk nonsense
+  jlong numread = 0;
+  char* bufptr = (char*) buf;
+  while (numread < minlen) {
+    // read available input, up to buf.length or maxlen
+    int readlen = (1<<16);
+    if (readlen > (maxlen - numread))
+      readlen = (int)(maxlen - numread);
+    int nr = 0;
+    if (u->infileptr != null) {
+      nr = (int)fread(bufptr, 1, readlen, u->infileptr);
+    } else {
+#ifndef WIN32
+      // we prefer unbuffered inputs
+      nr = (int)read(u->infileno, bufptr, readlen);
+#else
+      nr = (int)fread(bufptr, 1, readlen, stdin);
+#endif
+    }
+    if (nr <= 0) {
+      if (errno != EINTR)
+        break;
+      nr = 0;
+    }
+    numread += nr;
+    bufptr += nr;
+    assert(numread <= maxlen);
+  }
+  //fprintf(u->errstrm, "readInputFn(%d,%d) => %d\n",
+  //        (int)minlen, (int)maxlen, (int)numread);
+  return numread;
+}
+
+enum { EOF_MAGIC = 0, BAD_MAGIC = -1 };
+static int read_magic(unpacker* u, char peek[], int peeklen) {
+  assert(peeklen == 4);  // magic numbers are always 4 bytes
+  jlong nr = (u->read_input_fn)(u, peek, peeklen, peeklen);
+  if (nr != peeklen) {
+    return (nr == 0) ? EOF_MAGIC : BAD_MAGIC;
+  }
+  int magic = 0;
+  for (int i = 0; i < peeklen; i++) {
+    magic <<= 8;
+    magic += peek[i] & 0xFF;
+  }
+  return magic;
+}
+
+static void setup_gzin(unpacker* u) {
+  gunzip* gzin = NEW(gunzip, 1);
+  gzin->init(u);
+}
+
+static const char* nbasename(const char* progname) {
+  const char* slash = strrchr(progname, '/');
+  if (slash != null)  progname = ++slash;
+  return progname;
+}
+
+static const char* usage_lines[] = {
+  "Usage:  %s [-opt... | --option=value]... x.pack[.gz] y.jar\n",
+    "\n",
+    "Unpacking Options\n",
+    "  -H{h}, --deflate-hint={h}     override transmitted deflate hint: true, false, or keep (default)\n",
+    "  -r, --remove-pack-file        remove input file after unpacking\n",
+    "  -v, --verbose                 increase program verbosity\n",
+    "  -q, --quiet                   set verbosity to lowest level\n",
+    "  -l{F}, --log-file={F}         output to the given log file, or '-' for standard output (default)\n",
+    "  -?, -h, --help                print this message\n",
+    "  -V, --version                 print program version\n",
+    "  -J{X}                         Java VM argument (ignored)\n",
+    null
+};
+
+static void usage(unpacker* u, const char* progname, bool full = false) {
+  // WinMain does not set argv[0] to the progrname
+  progname = (progname != null) ? nbasename(progname) : "unpack200";
+  for (int i = 0; usage_lines[i] != null; i++) {
+    fprintf(u->errstrm, usage_lines[i], progname);
+    if (!full) {
+      fprintf(u->errstrm,
+              "(For more information, run %s --help .)\n", progname);
+      break;
+    }
+  }
+}
+
+// argument parsing
+static char** init_args(int argc, char** argv, int &envargc) {
+  const char* env = getenv("UNPACK200_FLAGS");
+  ptrlist envargs;
+  envargs.init();
+  if (env != null) {
+    char* buf = (char*) strdup(env);
+    const char* delim = "\n\t ";
+    for (char* p = strtok(buf, delim); p != null; p = strtok(null, delim)) {
+      envargs.add(p);
+    }
+  }
+  // allocate extra margin at both head and tail
+  char** argp = NEW(char*, envargs.length()+argc+1);
+  char** argp0 = argp;
+  int i;
+  for (i = 0; i < envargs.length(); i++) {
+    *argp++ = (char*) envargs.get(i);
+  }
+  for (i = 1; i < argc; i++) {
+    // note: skip argv[0] (program name)
+    *argp++ = (char*) strdup(argv[i]);  // make a scratch copy
+  }
+  *argp = null; // sentinel
+  envargc = envargs.length();  // report this count to next_arg
+  envargs.free();
+  return argp0;
+}
+
+static int strpcmp(const char* str, const char* pfx) {
+  return strncmp(str, pfx, strlen(pfx));
+}
+
+static const char flag_opts[] = "vqrVh?";
+static const char string_opts[] = "HlJ";
+
+static int next_arg(char** &argp) {
+  char* arg = *argp;
+  if (arg == null || arg[0] != '-') { // end of option list
+    return 0;
+  }
+  //printf("opt: %s\n", arg);
+  char ach = arg[1];
+  if (ach == '\0') {
+    // ++argp;  // do not pop this arg
+    return 0;  // bare "-" is stdin/stdout
+  } else if (arg[1] == '-') {  // --foo option
+    static const char* keys[] = {
+      "Hdeflate-hint=",
+      "vverbose",
+      "qquiet",
+      "rremove-pack-file",
+      "llog-file=",
+      "Vversion",
+      "hhelp",
+      null };
+    if (arg[2] == '\0') {  // end of option list
+      ++argp;  // pop the "--"
+      return 0;
+    }
+    for (int i = 0; keys[i] != null; i++) {
+      const char* key = keys[i];
+      char kch = *key++;
+      if (strchr(key, '=') == null) {
+        if (!strcmp(arg+2, key)) {
+          ++argp;  // pop option arg
+          return kch;
+        }
+      } else {
+        if (!strpcmp(arg+2, key)) {
+          *argp += 2 + strlen(key);  // remove "--"+key from arg
+          return kch;
+        }
+      }
+    }
+  } else if (strchr(flag_opts, ach) != null) {  // plain option
+    if (arg[2] == '\0') {
+      ++argp;
+    } else {
+      // in-place edit of "-vxyz" to "-xyz"
+      arg += 1;  // skip original '-'
+      arg[0] = '-';
+      *argp = arg;
+    }
+    //printf("  key => %c\n", ach);
+    return ach;
+  } else if (strchr(string_opts, ach) != null) {  // argument-bearing option
+    if (arg[2] == '\0') {
+      if (argp[1] == null)  return -1;  // no next arg
+      ++argp;  // leave the argument in place
+    } else {
+      // in-place edit of "-Hxyz" to "xyz"
+      arg += 2;  // skip original '-H'
+      *argp = arg;
+    }
+    //printf("  key => %c\n", ach);
+    return ach;
+  }
+  return -1;  // bad argument
+}
+
+static const char sccsver[] = "1.30, 07/05/05";
+
+// Usage:  unpackage input.pack output.jar
+int unpacker::run(int argc, char **argv) {
+  unpacker u;
+  u.init(read_input_via_stdio);
+  set_current_unpacker(&u);
+
+  jar jarout;
+  jarout.init(&u);
+
+  int envargc = 0;
+  char** argbuf = init_args(argc, argv, envargc);
+  char** arg0 = argbuf+envargc;
+  char** argp = argbuf;
+
+  int verbose = 0;
+  char* logfile = null;
+
+  for (;;) {
+    const char* arg = (*argp == null)? "": u.saveStr(*argp);
+    bool isenvarg = (argp < arg0);
+    int ach = next_arg(argp);
+    bool hasoptarg = (ach != 0 && strchr(string_opts, ach) != null);
+    if (ach == 0 && argp >= arg0)  break;
+    if (isenvarg && argp == arg0 && hasoptarg)  ach = 0;  // don't pull from cmdline
+    switch (ach) {
+    case 'H':  u.set_option(UNPACK_DEFLATE_HINT,*argp++); break;
+    case 'v':  ++verbose; break;
+    case 'q':  verbose = 0; break;
+    case 'r':  u.set_option(UNPACK_REMOVE_PACKFILE,"1"); break;
+    case 'l':  logfile = *argp++; break;
+    case 'J':  argp += 1; break;  // skip ignored -Jxxx parameter
+
+    case 'V':
+      fprintf(u.errstrm, VERSION_STRING, nbasename(argv[0]), sccsver);
+      exit(0);
+
+    case 'h':
+    case '?':
+      usage(&u, argv[0], true);
+      exit(1);
+
+    default:
+      const char* inenv = isenvarg? " in ${UNPACK200_FLAGS}": "";
+      if (hasoptarg)
+        fprintf(u.errstrm, "Missing option string%s: %s\n", inenv, arg);
+      else
+        fprintf(u.errstrm, "Unrecognized argument%s: %s\n", inenv, arg);
+      usage(&u, argv[0]);
+      exit(2);
+    }
+  }
+
+  if (verbose != 0) {
+    u.set_option(DEBUG_VERBOSE, u.saveIntStr(verbose));
+  }
+  if (logfile != null) {
+    u.set_option(UNPACK_LOG_FILE, logfile);
+  }
+
+  u.redirect_stdio();
+
+  const char* source_file      = *argp++;
+  const char* destination_file = *argp++;
+
+  if (source_file == null || destination_file == null || *argp != null) {
+    usage(&u, argv[0]);
+    exit(2);
+  }
+
+  if (verbose != 0) {
+    fprintf(u.errstrm,
+            "Unpacking from %s to %s\n", source_file, destination_file);
+  }
+  bool& remove_source = u.remove_packfile;
+
+  if (strcmp(source_file, "-") == 0) {
+    remove_source = false;
+    u.infileno = fileno(stdin);
+  } else {
+    u.infileptr = fopen(source_file, "rb");
+    if (u.infileptr == null) {
+       fprintf(u.errstrm,
+               "Error: Could not open input file: %s\n", source_file);
+       exit(3); // Called only from the native standalone unpacker
+    }
+  }
+
+  if (strcmp(destination_file, "-") == 0) {
+    jarout.jarfp = stdout;
+    if (u.errstrm == stdout) // do not mix output
+      u.set_option(UNPACK_LOG_FILE, LOGFILE_STDERR);
+  } else {
+    jarout.openJarFile(destination_file);
+    assert(jarout.jarfp != null);
+  }
+
+  if (verbose != 0)
+    u.dump_options();
+
+  char peek[4];
+  int magic;
+
+  // check for GZIP input
+  magic = read_magic(&u, peek, (int)sizeof(peek));
+  if ((magic & GZIP_MAGIC_MASK) == GZIP_MAGIC) {
+    // Oops; must slap an input filter on this data.
+    setup_gzin(&u);
+    u.gzin->start(magic);
+    if (!u.aborting()) {
+      u.start();
+    }
+  } else {
+    u.gzcrc = 0;
+    u.start(peek, sizeof(peek));
+  }
+
+  // Note:  The checks to u.aborting() are necessary to gracefully
+  // terminate processing when the first segment throws an error.
+
+  for (;;) {
+    if (u.aborting())  break;
+
+    // Each trip through this loop unpacks one segment
+    // and then resets the unpacker.
+    for (unpacker::file* filep; (filep = u.get_next_file()) != null; ) {
+      if (u.aborting())  break;
+      u.write_file_to_jar(filep);
+    }
+    if (u.aborting())  break;
+
+    // Peek ahead for more data.
+    magic = read_magic(&u, peek, (int)sizeof(peek));
+    if (magic != (int)JAVA_PACKAGE_MAGIC) {
+      if (magic != EOF_MAGIC)
+        u.abort("garbage after end of pack archive");
+      break;   // all done
+    }
+
+    // Release all storage from parsing the old segment.
+    u.reset();
+
+    // Restart, beginning with the peek-ahead.
+    u.start(peek, sizeof(peek));
+  }
+
+
+
+  int status = 0;
+  if (u.aborting()) {
+    fprintf(u.errstrm, "Error: %s\n", u.get_abort_message());
+    status = 1;
+  }
+
+  if (!u.aborting() && u.infileptr != null) {
+    if (u.gzcrc != 0) {
+      // Read the CRC information from the gzip container
+      fseek(u.infileptr, -8, SEEK_END);
+      uint filecrc;
+      fread(&filecrc, sizeof(filecrc), 1, u.infileptr);
+      if (u.gzcrc != SWAP_INT(filecrc)) { // CRC error
+        if (strcmp(destination_file, "-") != 0) {
+          // Output is not stdout, remove it, it's broken
+          if (u.jarout != null)
+            u.jarout->closeJarFile(false);
+          remove(destination_file);
+        }
+        // Print out the error and exit with return code != 0
+        u.abort("CRC error, invalid compressed data.");
+      }
+    }
+    fclose(u.infileptr);
+    u.infileptr = null;
+  }
+
+  if (!u.aborting() && remove_source)
+    remove(source_file);
+
+  if (verbose != 0) {
+    fprintf(u.errstrm, "unpacker completed with status=%d\n", status);
+  }
+
+  u.finish();
+
+  u.free();  // tidy up malloc blocks
+  set_current_unpacker(null);  // clean up global pointer
+
+  return status;
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/jdk/src/jdk.pack200/windows/native/unpack200/unpack200_proto.exe.manifest	Fri Mar 06 09:02:26 2015 -0800
@@ -0,0 +1,19 @@
+<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
+<assembly xmlns="urn:schemas-microsoft-com:asm.v1" manifestVersion="1.0"> 
+  <assemblyIdentity version="IMVERSION"
+     processorArchitecture="X86"
+     name="unpack200.exe"
+     type="win32"/> 
+
+  <description>Java(TM) SE Runtime Environment unpack200 Process.</description> 
+  <!-- Identify the application security requirements. -->
+  <trustInfo xmlns="urn:schemas-microsoft-com:asm.v3">
+    <security>
+      <requestedPrivileges>
+        <requestedExecutionLevel
+          level="asInvoker"
+          uiAccess="false"/>
+        </requestedPrivileges>
+       </security>
+  </trustInfo>
+</assembly>
--- a/jdk/src/jdk.runtime/share/native/common-unpack/bands.cpp	Fri Mar 06 13:30:49 2015 +0300
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,486 +0,0 @@
-/*
- * Copyright (c) 2002, 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.
- */
-
-// -*- C++ -*-
-// Small program for unpacking specially compressed Java packages.
-// John R. Rose
-
-#include <sys/types.h>
-
-#include <stdio.h>
-#include <string.h>
-#include <stdlib.h>
-#include <stdarg.h>
-
-#include "defines.h"
-#include "bytes.h"
-#include "utils.h"
-#include "coding.h"
-#include "bands.h"
-
-#include "constants.h"
-#include "unpack.h"
-
-inline void band::abort(const char* msg) { u->abort(msg); }
-inline bool band::aborting() { return u->aborting(); }
-
-void band::readData(int expectedLength) {
-  CHECK;
-  assert(expectedLength >= 0);
-  assert(vs[0].cmk == cmk_ERROR);
-  if (expectedLength != 0) {
-    assert(length == 0);
-    length = expectedLength;
-  }
-  if (length == 0) {
-    assert((rplimit = cm.vs0.rp = u->rp) != null);
-    return;
-  }
-  assert(length > 0);
-
-  bool is_BYTE1 = (defc->spec == BYTE1_spec);
-
-  if (is_BYTE1) {
-    // No possibility of coding change.  Sizing is exact.
-    u->ensure_input(length);
-  } else {
-    // Make a conservatively generous estimate of band size in bytes.
-    // Assume B == 5 everywhere.
-    // Assume awkward pop with all {U} values (2*5 per value)
-    jlong generous = (jlong) length * (B_MAX*3+1) + C_SLOP;
-    u->ensure_input(generous);
-  }
-
-  // Read one value to see what it might be.
-  int XB = _meta_default;
-  int cp1 = 0, cp2 = 0;
-  if (!is_BYTE1) {
-    // must be a variable-length coding
-    assert(defc->B() > 1 && defc->L() > 0);
-    // must have already read from previous band:
-    assert(bn >= BAND_LIMIT || bn <= 0
-           || bn == e_cp_Utf8_big_chars
-           || endsWith(name, "_lo")  // preceded by _hi conditional band
-           || bn == e_file_options  // preceded by conditional band
-           || u->rp == u->all_bands[bn-1].maxRP()
-           || u->all_bands[bn-1].defc == null);
-
-    value_stream xvs;
-    coding* valc = defc;
-    if (valc->D() != 0) {
-      valc = coding::findBySpec(defc->B(), defc->H(), defc->S());
-      assert(!valc->isMalloc);
-    }
-    xvs.init(u->rp, u->rplimit, valc);
-    CHECK;
-    int X = xvs.getInt();
-    if (valc->S() != 0) {
-      assert(valc->min <= -256);
-      XB = -1-X;
-    } else {
-      int L = valc->L();
-      assert(valc->max >= L+255);
-      XB = X-L;
-    }
-    if (0 <= XB && XB < 256) {
-      // Skip over the escape value.
-      u->rp = xvs.rp;
-      cp1 = 1;
-    } else {
-      // No, it's still default.
-      XB = _meta_default;
-    }
-  }
-
-  if (XB <= _meta_canon_max) {
-    byte XB_byte = (byte) XB;
-    byte* XB_ptr = &XB_byte;
-    cm.init(u->rp, u->rplimit, XB_ptr, 0, defc, length, null);
-    CHECK;
-  } else {
-    NOT_PRODUCT(byte* meta_rp0 = u->meta_rp);
-    assert(u->meta_rp != null);
-    // Scribble the initial byte onto the band.
-    byte* save_meta_rp = --u->meta_rp;
-    byte  save_meta_xb = (*save_meta_rp);
-    (*save_meta_rp) = (byte) XB;
-    cm.init(u->rp, u->rplimit, u->meta_rp, 0, defc, length, null);
-    (*save_meta_rp) = save_meta_xb;  // put it back, just to be tidy
-    NOT_PRODUCT(cp2 = (int)(u->meta_rp - meta_rp0));
-  }
-  rplimit = u->rp;
-
-  rewind();
-
-#ifndef PRODUCT
-  PRINTCR((3,"readFrom %s at %p [%d values, %d bytes, cp=%d/%d]",
-           (name?name:"(band)"), minRP(), length, size(), cp1, cp2));
-  if (u->verbose_bands || u->verbose >= 4) dump();
-
-  if (ix != null && u->verbose != 0 && length > 0) {
-    // Check referential integrity early, for easier debugging.
-    band saved = (*this);  // save state
-    for (int i = 0; i < length; i++) {
-      int n = vs[0].getInt() - nullOK;
-      entry *ref = ix->get(n);
-      assert(ref != null || n == -1);
-    }
-    (*this) = saved;
-  }
-#endif
-}
-
-#ifndef PRODUCT
-void band::dump() {
-  band saved = (*this);  // save state
-  const char* b_name = name;
-  char b_name_buf[100];
-  if (b_name == null) {
-    char* bp = &b_name_buf[0];
-    b_name = bp;
-    sprintf(bp, "#%d/%d", bn, le_kind); bp += strlen(bp);
-    if (le_bci != 0)  { sprintf(bp, "/bci%d",  le_bci);  bp += strlen(bp); }
-    if (le_back != 0) { sprintf(bp, "/back%d", le_back); bp += strlen(bp); }
-    if (le_len != 0)  { sprintf(bp, "/len%d",  le_len);  bp += strlen(bp); }
-  }
-  fprintf(u->errstrm, "band %s[%d]%s", b_name, length, (length==0?"\n":" {"));
-  if (length > 0) {
-    for (int i = 0; i < length; i++) {
-      const char* eol = (length > 10 && i % 10 == 0) ? "\n" : " ";
-      fprintf(u->errstrm, "%s%d", eol, vs[0].getInt());
-    }
-    fprintf(u->errstrm, " }\n");
-  }
-  (*this) = saved;
-}
-#endif
-
-void band::setIndex(cpindex* ix_) {
-  assert(ix_ == null || ixTag == ix_->ixTag);
-  ix = ix_;
-}
-void band::setIndexByTag(byte tag) {
-  setIndex(u->cp.getIndex(tag));
-}
-
-entry* band::getRefCommon(cpindex* ix_, bool nullOKwithCaller) {
-  CHECK_0;
-  if (ix_ == NULL) {
-      abort("no index");
-      return NULL;
-  }
-  assert(ix_->ixTag == ixTag
-         || ((ixTag == CONSTANT_All ||
-              ixTag == CONSTANT_LoadableValue ||
-              ixTag == CONSTANT_AnyMember)
-         || (ixTag == CONSTANT_FieldSpecific &&
-              ix_->ixTag >= CONSTANT_Integer  &&
-              ix_->ixTag <= CONSTANT_String))
-         );
-  int n = vs[0].getInt() - nullOK;
-  // Note: band-local nullOK means null encodes as 0.
-  // But nullOKwithCaller means caller is willing to tolerate a null.
-  entry *ref = ix_->get(n);
-  if (ref == null && !(nullOKwithCaller && n == -1))
-    abort(n == -1 ? "null ref" : "bad ref");
-  return ref;
-}
-
-jlong band::getLong(band& lo_band, bool have_hi) {
-  band& hi_band = (*this);
-  assert(lo_band.bn == hi_band.bn + 1);
-  uint lo = lo_band.getInt();
-  if (!have_hi) {
-    assert(hi_band.length == 0);
-    return makeLong(0, lo);
-  }
-  uint hi = hi_band.getInt();
-  return makeLong(hi, lo);
-}
-
-int band::getIntTotal() {
-  CHECK_0;
-  if (length == 0)  return 0;
-  if (total_memo > 0)  return total_memo-1;
-  int total = getInt();
-  // overflow checks require that none of the addends are <0,
-  // and that the partial sums never overflow (wrap negative)
-  if (total < 0) {
-    abort("overflow detected");
-    return 0;
-  }
-  for (int k = length-1; k > 0; k--) {
-    int prev_total = total;
-    total += vs[0].getInt();
-    if (total < prev_total) {
-      abort("overflow detected");
-      return 0;
-    }
-  }
-  rewind();
-  total_memo = total+1;
-  return total;
-}
-
-int band::getIntCount(int tag) {
-  CHECK_0;
-  if (length == 0)  return 0;
-  if (tag >= HIST0_MIN && tag <= HIST0_MAX) {
-    if (hist0 == null) {
-      // Lazily calculate an approximate histogram.
-      hist0 = U_NEW(int, (HIST0_MAX - HIST0_MIN)+1);
-      CHECK_0;
-      for (int k = length; k > 0; k--) {
-        int x = vs[0].getInt();
-        if (x >= HIST0_MIN && x <= HIST0_MAX)
-          hist0[x - HIST0_MIN] += 1;
-      }
-      rewind();
-    }
-    return hist0[tag - HIST0_MIN];
-  }
-  int total = 0;
-  for (int k = length; k > 0; k--) {
-    total += (vs[0].getInt() == tag) ? 1 : 0;
-  }
-  rewind();
-  return total;
-}
-
-#define INDEX_INIT(tag, nullOK, subindex) \
-        ((tag) + (subindex)*SUBINDEX_BIT + (nullOK)*256)
-
-#define INDEX(tag)          INDEX_INIT(tag, 0, 0)
-#define NULL_OR_INDEX(tag)  INDEX_INIT(tag, 1, 0)
-#define SUB_INDEX(tag)      INDEX_INIT(tag, 0, 1)
-#define NO_INDEX            0
-
-struct band_init {
-  int         bn;
-  const char* name;
-  int   defc;
-  int   index;
-};
-
-#define BAND_INIT(name, cspec, ix) \
-  { e_##name,  #name, /*debug only*/ \
-    cspec, ix }
-
-const band_init all_band_inits[BAND_LIMIT+1] = {
-//BAND_INIT(archive_magic, BYTE1_spec, 0),
-//BAND_INIT(archive_header, UNSIGNED5_spec, 0),
-//BAND_INIT(band_headers, BYTE1_spec, 0),
-  BAND_INIT(cp_Utf8_prefix, DELTA5_spec, 0),
-  BAND_INIT(cp_Utf8_suffix, UNSIGNED5_spec, 0),
-  BAND_INIT(cp_Utf8_chars, CHAR3_spec, 0),
-  BAND_INIT(cp_Utf8_big_suffix, DELTA5_spec, 0),
-  BAND_INIT(cp_Utf8_big_chars, DELTA5_spec, 0),
-  BAND_INIT(cp_Int, UDELTA5_spec, 0),
-  BAND_INIT(cp_Float, UDELTA5_spec, 0),
-  BAND_INIT(cp_Long_hi, UDELTA5_spec, 0),
-  BAND_INIT(cp_Long_lo, DELTA5_spec, 0),
-  BAND_INIT(cp_Double_hi, UDELTA5_spec, 0),
-  BAND_INIT(cp_Double_lo, DELTA5_spec, 0),
-  BAND_INIT(cp_String, UDELTA5_spec, INDEX(CONSTANT_Utf8)),
-  BAND_INIT(cp_Class, UDELTA5_spec, INDEX(CONSTANT_Utf8)),
-  BAND_INIT(cp_Signature_form, DELTA5_spec, INDEX(CONSTANT_Utf8)),
-  BAND_INIT(cp_Signature_classes, UDELTA5_spec, INDEX(CONSTANT_Class)),
-  BAND_INIT(cp_Descr_name, DELTA5_spec, INDEX(CONSTANT_Utf8)),
-  BAND_INIT(cp_Descr_type, UDELTA5_spec, INDEX(CONSTANT_Signature)),
-  BAND_INIT(cp_Field_class, DELTA5_spec, INDEX(CONSTANT_Class)),
-  BAND_INIT(cp_Field_desc, UDELTA5_spec, INDEX(CONSTANT_NameandType)),
-  BAND_INIT(cp_Method_class, DELTA5_spec, INDEX(CONSTANT_Class)),
-  BAND_INIT(cp_Method_desc, UDELTA5_spec, INDEX(CONSTANT_NameandType)),
-  BAND_INIT(cp_Imethod_class, DELTA5_spec, INDEX(CONSTANT_Class)),
-  BAND_INIT(cp_Imethod_desc, UDELTA5_spec, INDEX(CONSTANT_NameandType)),
-  BAND_INIT(cp_MethodHandle_refkind, DELTA5_spec, 0),
-  BAND_INIT(cp_MethodHandle_member, UDELTA5_spec, INDEX(CONSTANT_AnyMember)),
-  BAND_INIT(cp_MethodType, UDELTA5_spec, INDEX(CONSTANT_Signature)),
-  BAND_INIT(cp_BootstrapMethod_ref, DELTA5_spec, INDEX(CONSTANT_MethodHandle)),
-  BAND_INIT(cp_BootstrapMethod_arg_count, UDELTA5_spec, 0),
-  BAND_INIT(cp_BootstrapMethod_arg, DELTA5_spec, INDEX(CONSTANT_LoadableValue)),
-  BAND_INIT(cp_InvokeDynamic_spec, DELTA5_spec, INDEX(CONSTANT_BootstrapMethod)),
-  BAND_INIT(cp_InvokeDynamic_desc, UDELTA5_spec, INDEX(CONSTANT_NameandType)),
-  BAND_INIT(attr_definition_headers, BYTE1_spec, 0),
-  BAND_INIT(attr_definition_name, UNSIGNED5_spec, INDEX(CONSTANT_Utf8)),
-  BAND_INIT(attr_definition_layout, UNSIGNED5_spec, INDEX(CONSTANT_Utf8)),
-  BAND_INIT(ic_this_class, UDELTA5_spec, INDEX(CONSTANT_Class)),
-  BAND_INIT(ic_flags, UNSIGNED5_spec, 0),
-  BAND_INIT(ic_outer_class, DELTA5_spec, NULL_OR_INDEX(CONSTANT_Class)),
-  BAND_INIT(ic_name, DELTA5_spec, NULL_OR_INDEX(CONSTANT_Utf8)),
-  BAND_INIT(class_this, DELTA5_spec, INDEX(CONSTANT_Class)),
-  BAND_INIT(class_super, DELTA5_spec, INDEX(CONSTANT_Class)),
-  BAND_INIT(class_interface_count, DELTA5_spec, 0),
-  BAND_INIT(class_interface, DELTA5_spec, INDEX(CONSTANT_Class)),
-  BAND_INIT(class_field_count, DELTA5_spec, 0),
-  BAND_INIT(class_method_count, DELTA5_spec, 0),
-  BAND_INIT(field_descr, DELTA5_spec, INDEX(CONSTANT_NameandType)),
-  BAND_INIT(field_flags_hi, UNSIGNED5_spec, 0),
-  BAND_INIT(field_flags_lo, UNSIGNED5_spec, 0),
-  BAND_INIT(field_attr_count, UNSIGNED5_spec, 0),
-  BAND_INIT(field_attr_indexes, UNSIGNED5_spec, 0),
-  BAND_INIT(field_attr_calls, UNSIGNED5_spec, 0),
-  BAND_INIT(field_ConstantValue_KQ, UNSIGNED5_spec, INDEX(CONSTANT_FieldSpecific)),
-  BAND_INIT(field_Signature_RS, UNSIGNED5_spec, INDEX(CONSTANT_Signature)),
-  BAND_INIT(field_metadata_bands, -1, -1),
-  BAND_INIT(field_attr_bands, -1, -1),
-  BAND_INIT(method_descr, MDELTA5_spec, INDEX(CONSTANT_NameandType)),
-  BAND_INIT(method_flags_hi, UNSIGNED5_spec, 0),
-  BAND_INIT(method_flags_lo, UNSIGNED5_spec, 0),
-  BAND_INIT(method_attr_count, UNSIGNED5_spec, 0),
-  BAND_INIT(method_attr_indexes, UNSIGNED5_spec, 0),
-  BAND_INIT(method_attr_calls, UNSIGNED5_spec, 0),
-  BAND_INIT(method_Exceptions_N, UNSIGNED5_spec, 0),
-  BAND_INIT(method_Exceptions_RC, UNSIGNED5_spec, INDEX(CONSTANT_Class)),
-  BAND_INIT(method_Signature_RS, UNSIGNED5_spec, INDEX(CONSTANT_Signature)),
-  BAND_INIT(method_metadata_bands, -1, -1),
-  BAND_INIT(method_MethodParameters_NB, BYTE1_spec, 0),
-  BAND_INIT(method_MethodParameters_name_RUN, UNSIGNED5_spec, NULL_OR_INDEX(CONSTANT_Utf8)),
-  BAND_INIT(method_MethodParameters_flag_FH, UNSIGNED5_spec, 0),
-  BAND_INIT(method_attr_bands, -1, -1),
-  BAND_INIT(class_flags_hi, UNSIGNED5_spec, 0),
-  BAND_INIT(class_flags_lo, UNSIGNED5_spec, 0),
-  BAND_INIT(class_attr_count, UNSIGNED5_spec, 0),
-  BAND_INIT(class_attr_indexes, UNSIGNED5_spec, 0),
-  BAND_INIT(class_attr_calls, UNSIGNED5_spec, 0),
-  BAND_INIT(class_SourceFile_RUN, UNSIGNED5_spec, NULL_OR_INDEX(CONSTANT_Utf8)),
-  BAND_INIT(class_EnclosingMethod_RC, UNSIGNED5_spec, INDEX(CONSTANT_Class)),
-  BAND_INIT(class_EnclosingMethod_RDN, UNSIGNED5_spec, NULL_OR_INDEX(CONSTANT_NameandType)),
-  BAND_INIT(class_Signature_RS, UNSIGNED5_spec, INDEX(CONSTANT_Signature)),
-  BAND_INIT(class_metadata_bands, -1, -1),
-  BAND_INIT(class_InnerClasses_N, UNSIGNED5_spec, 0),
-  BAND_INIT(class_InnerClasses_RC, UNSIGNED5_spec, INDEX(CONSTANT_Class)),
-  BAND_INIT(class_InnerClasses_F, UNSIGNED5_spec, 0),
-  BAND_INIT(class_InnerClasses_outer_RCN, UNSIGNED5_spec, NULL_OR_INDEX(CONSTANT_Class)),
-  BAND_INIT(class_InnerClasses_name_RUN, UNSIGNED5_spec, NULL_OR_INDEX(CONSTANT_Utf8)),
-  BAND_INIT(class_ClassFile_version_minor_H, UNSIGNED5_spec, 0),
-  BAND_INIT(class_ClassFile_version_major_H, UNSIGNED5_spec, 0),
-  BAND_INIT(class_attr_bands, -1, -1),
-  BAND_INIT(code_headers, BYTE1_spec, 0),
-  BAND_INIT(code_max_stack, UNSIGNED5_spec, 0),
-  BAND_INIT(code_max_na_locals, UNSIGNED5_spec, 0),
-  BAND_INIT(code_handler_count, UNSIGNED5_spec, 0),
-  BAND_INIT(code_handler_start_P, BCI5_spec, 0),
-  BAND_INIT(code_handler_end_PO, BRANCH5_spec, 0),
-  BAND_INIT(code_handler_catch_PO, BRANCH5_spec, 0),
-  BAND_INIT(code_handler_class_RCN, UNSIGNED5_spec, NULL_OR_INDEX(CONSTANT_Class)),
-  BAND_INIT(code_flags_hi, UNSIGNED5_spec, 0),
-  BAND_INIT(code_flags_lo, UNSIGNED5_spec, 0),
-  BAND_INIT(code_attr_count, UNSIGNED5_spec, 0),
-  BAND_INIT(code_attr_indexes, UNSIGNED5_spec, 0),
-  BAND_INIT(code_attr_calls, UNSIGNED5_spec, 0),
-  BAND_INIT(code_StackMapTable_N, UNSIGNED5_spec, 0),
-  BAND_INIT(code_StackMapTable_frame_T, BYTE1_spec, 0),
-  BAND_INIT(code_StackMapTable_local_N, UNSIGNED5_spec, 0),
-  BAND_INIT(code_StackMapTable_stack_N, UNSIGNED5_spec, 0),
-  BAND_INIT(code_StackMapTable_offset, UNSIGNED5_spec, 0),
-  BAND_INIT(code_StackMapTable_T, BYTE1_spec, 0),
-  BAND_INIT(code_StackMapTable_RC, UNSIGNED5_spec, INDEX(CONSTANT_Class)),
-  BAND_INIT(code_StackMapTable_P, BCI5_spec, 0),
-  BAND_INIT(code_LineNumberTable_N, UNSIGNED5_spec, 0),
-  BAND_INIT(code_LineNumberTable_bci_P, BCI5_spec, 0),
-  BAND_INIT(code_LineNumberTable_line, UNSIGNED5_spec, 0),
-  BAND_INIT(code_LocalVariableTable_N, UNSIGNED5_spec, 0),
-  BAND_INIT(code_LocalVariableTable_bci_P, BCI5_spec, 0),
-  BAND_INIT(code_LocalVariableTable_span_O, BRANCH5_spec, 0),
-  BAND_INIT(code_LocalVariableTable_name_RU, UNSIGNED5_spec, INDEX(CONSTANT_Utf8)),
-  BAND_INIT(code_LocalVariableTable_type_RS, UNSIGNED5_spec, INDEX(CONSTANT_Signature)),
-  BAND_INIT(code_LocalVariableTable_slot, UNSIGNED5_spec, 0),
-  BAND_INIT(code_LocalVariableTypeTable_N, UNSIGNED5_spec, 0),
-  BAND_INIT(code_LocalVariableTypeTable_bci_P, BCI5_spec, 0),
-  BAND_INIT(code_LocalVariableTypeTable_span_O, BRANCH5_spec, 0),
-  BAND_INIT(code_LocalVariableTypeTable_name_RU, UNSIGNED5_spec, INDEX(CONSTANT_Utf8)),
-  BAND_INIT(code_LocalVariableTypeTable_type_RS, UNSIGNED5_spec, INDEX(CONSTANT_Signature)),
-  BAND_INIT(code_LocalVariableTypeTable_slot, UNSIGNED5_spec, 0),
-  BAND_INIT(code_attr_bands, -1, -1),
-  BAND_INIT(bc_codes, BYTE1_spec, 0),
-  BAND_INIT(bc_case_count, UNSIGNED5_spec, 0),
-  BAND_INIT(bc_case_value, DELTA5_spec, 0),
-  BAND_INIT(bc_byte, BYTE1_spec, 0),
-  BAND_INIT(bc_short, DELTA5_spec, 0),
-  BAND_INIT(bc_local, UNSIGNED5_spec, 0),
-  BAND_INIT(bc_label, BRANCH5_spec, 0),
-  BAND_INIT(bc_intref, DELTA5_spec, INDEX(CONSTANT_Integer)),
-  BAND_INIT(bc_floatref, DELTA5_spec, INDEX(CONSTANT_Float)),
-  BAND_INIT(bc_longref, DELTA5_spec, INDEX(CONSTANT_Long)),
-  BAND_INIT(bc_doubleref, DELTA5_spec, INDEX(CONSTANT_Double)),
-  BAND_INIT(bc_stringref, DELTA5_spec, INDEX(CONSTANT_String)),
-  BAND_INIT(bc_loadablevalueref, DELTA5_spec, INDEX(CONSTANT_LoadableValue)),
-  BAND_INIT(bc_classref, UNSIGNED5_spec, NULL_OR_INDEX(CONSTANT_Class)),
-  BAND_INIT(bc_fieldref, DELTA5_spec, INDEX(CONSTANT_Fieldref)),
-  BAND_INIT(bc_methodref, UNSIGNED5_spec, INDEX(CONSTANT_Methodref)),
-  BAND_INIT(bc_imethodref, DELTA5_spec, INDEX(CONSTANT_InterfaceMethodref)),
-  BAND_INIT(bc_indyref, DELTA5_spec, INDEX(CONSTANT_InvokeDynamic)),
-  BAND_INIT(bc_thisfield, UNSIGNED5_spec, SUB_INDEX(CONSTANT_Fieldref)),
-  BAND_INIT(bc_superfield, UNSIGNED5_spec, SUB_INDEX(CONSTANT_Fieldref)),
-  BAND_INIT(bc_thismethod, UNSIGNED5_spec, SUB_INDEX(CONSTANT_Methodref)),
-  BAND_INIT(bc_supermethod, UNSIGNED5_spec, SUB_INDEX(CONSTANT_Methodref)),
-  BAND_INIT(bc_initref, UNSIGNED5_spec, SUB_INDEX(CONSTANT_Methodref)),
-  BAND_INIT(bc_escref, UNSIGNED5_spec, INDEX(CONSTANT_All)),
-  BAND_INIT(bc_escrefsize, UNSIGNED5_spec, 0),
-  BAND_INIT(bc_escsize, UNSIGNED5_spec, 0),
-  BAND_INIT(bc_escbyte, BYTE1_spec, 0),
-  BAND_INIT(file_name, UNSIGNED5_spec, INDEX(CONSTANT_Utf8)),
-  BAND_INIT(file_size_hi, UNSIGNED5_spec, 0),
-  BAND_INIT(file_size_lo, UNSIGNED5_spec, 0),
-  BAND_INIT(file_modtime, DELTA5_spec, 0),
-  BAND_INIT(file_options, UNSIGNED5_spec, 0),
-//BAND_INIT(file_bits, BYTE1_spec, 0),
-  { 0, NULL, 0, 0 }
-};
-
-band* band::makeBands(unpacker* u) {
-  band* tmp_all_bands = U_NEW(band, BAND_LIMIT);
-  for (int i = 0; i < BAND_LIMIT; i++) {
-    assert((byte*)&all_band_inits[i+1]
-           < (byte*)all_band_inits+sizeof(all_band_inits));
-    const band_init& bi = all_band_inits[i];
-    band&            b  = tmp_all_bands[i];
-    coding*          defc = coding::findBySpec(bi.defc);
-    assert((defc == null) == (bi.defc == -1));  // no garbage, please
-    assert(defc == null || !defc->isMalloc);
-    assert(bi.bn == i);  // band array consistent w/ band enum
-    b.init(u, i, defc);
-    if (bi.index > 0) {
-      b.nullOK = ((bi.index >> 8) & 1);
-      b.ixTag = (bi.index & 0xFF);
-    }
-#ifndef PRODUCT
-    b.name = bi.name;
-#endif
-  }
-  return tmp_all_bands;
-}
-
-void band::initIndexes(unpacker* u) {
-  band* tmp_all_bands = u->all_bands;
-  for (int i = 0; i < BAND_LIMIT; i++) {
-    band* scan = &tmp_all_bands[i];
-    uint tag = scan->ixTag;  // Cf. #define INDEX(tag) above
-    if (tag != 0 && tag != CONSTANT_FieldSpecific && (tag & SUBINDEX_BIT) == 0) {
-      scan->setIndex(u->cp.getIndex(tag));
-    }
-  }
-}
--- a/jdk/src/jdk.runtime/share/native/common-unpack/bands.h	Fri Mar 06 13:30:49 2015 +0300
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,481 +0,0 @@
-/*
- * Copyright (c) 2002, 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.
- */
-
-// -*- C++ -*-
-struct entry;
-struct cpindex;
-struct unpacker;
-
-struct band {
-  const char*   name;
-  int           bn;             // band_number of this band
-  coding*       defc;           // default coding method
-  cpindex*      ix;             // CP entry mapping, if CPRefBand
-  byte          ixTag;          // 0 or 1; null is coded as (nullOK?0:-1)
-  byte          nullOK;         // 0 or 1; null is coded as (nullOK?0:-1)
-  int           length;         // expected # values
-  unpacker*     u;              // back pointer
-
-  value_stream  vs[2];         // source of values
-  coding_method cm;            // method used for initial state of vs[0]
-  byte*         rplimit;       // end of band (encoded, transmitted)
-
-  int           total_memo;    // cached value of getIntTotal, or -1
-  int*          hist0;         // approximate. histogram
-  enum { HIST0_MIN = 0, HIST0_MAX = 255 }; // catches the usual cases
-
-  // properties for attribute layout elements:
-  byte          le_kind;       // EK_XXX
-  byte          le_bci;        // 0,EK_BCI,EK_BCD,EK_BCO
-  byte          le_back;       // ==EF_BACK
-  byte          le_len;        // 0,1,2,4 (size in classfile), or call addr
-  band**        le_body;       // body of repl, union, call (null-terminated)
-  // Note:  EK_CASE elements use hist0 to record union tags.
-  #define       le_casetags    hist0
-
-  band& nextBand() { return this[1]; }
-  band& prevBand() { return this[-1]; }
-
-  void init(unpacker* u_, int bn_, coding* defc_) {
-    u    = u_;
-    cm.u = u_;
-    bn   = bn_;
-    defc = defc_;
-  }
-  void init(unpacker* u_, int bn_, int defcSpec) {
-    init(u_, bn_, coding::findBySpec(defcSpec));
-  }
-  void initRef(int ixTag_ = 0, bool nullOK_ = false) {
-    ixTag  = ixTag_;
-    nullOK = nullOK_;
-    setIndexByTag(ixTag);
-  }
-
-  void expectMoreLength(int l) {
-    assert(length >= 0);      // able to accept a length
-    assert((int)l >= 0);      // no overflow
-    assert(rplimit == null);  // readData not yet called
-    length += l;
-    assert(length >= l);      // no overflow
-  }
-
-  void setIndex(cpindex* ix_);
-  void setIndexByTag(byte tag);
-
-  // Parse the band and its meta-coding header.
-  void readData(int expectedLength = 0);
-
-  // Reset the band for another pass (Cf. Java Band.resetForSecondPass.)
-  void rewind() {
-    cm.reset(&vs[0]);
-  }
-
-  byte* &curRP()    { return vs[0].rp; }
-  byte*  minRP()    { return cm.vs0.rp; }
-  byte*  maxRP()    { return rplimit; }
-  size_t size()     { return maxRP() - minRP(); }
-
-  int    getByte()  { assert(ix == null); return vs[0].getByte(); }
-  int    getInt()   { assert(ix == null); return vs[0].getInt(); }
-  entry* getRefN()  { return getRefCommon(ix, true); }
-  entry* getRef()   { return getRefCommon(ix, false); }
-  entry* getRefUsing(cpindex* ix2)
-                    { assert(ix == null); return getRefCommon(ix2, true); }
-  entry* getRefCommon(cpindex* ix, bool nullOK);
-  jlong  getLong(band& lo_band, bool have_hi);
-
-  static jlong makeLong(uint hi, uint lo) {
-    return ((julong)hi << 32) + (((julong)lo << 32) >> 32);
-  }
-
-  int    getIntTotal();
-  int    getIntCount(int tag);
-
-  static band* makeBands(unpacker* u);
-  static void initIndexes(unpacker* u);
-
-#ifndef PRODUCT
-  void dump();
-#endif
-
-  void abort(const char* msg = null); //{ u->abort(msg); }
-  bool aborting(); //{ return u->aborting(); }
-};
-
-extern band all_bands[];
-
-#define BAND_LOCAL /* \
-  band* band_temp = all_bands; \
-  band* all_bands = band_temp */
-
-// Band schema:
-enum band_number {
-  //e_archive_magic,
-  //e_archive_header,
-  //e_band_headers,
-
-    // constant pool contents
-    e_cp_Utf8_prefix,
-    e_cp_Utf8_suffix,
-    e_cp_Utf8_chars,
-    e_cp_Utf8_big_suffix,
-    e_cp_Utf8_big_chars,
-    e_cp_Int,
-    e_cp_Float,
-    e_cp_Long_hi,
-    e_cp_Long_lo,
-    e_cp_Double_hi,
-    e_cp_Double_lo,
-    e_cp_String,
-    e_cp_Class,
-    e_cp_Signature_form,
-    e_cp_Signature_classes,
-    e_cp_Descr_name,
-    e_cp_Descr_type,
-    e_cp_Field_class,
-    e_cp_Field_desc,
-    e_cp_Method_class,
-    e_cp_Method_desc,
-    e_cp_Imethod_class,
-    e_cp_Imethod_desc,
-    e_cp_MethodHandle_refkind,
-    e_cp_MethodHandle_member,
-    e_cp_MethodType,
-    e_cp_BootstrapMethod_ref,
-    e_cp_BootstrapMethod_arg_count,
-    e_cp_BootstrapMethod_arg,
-    e_cp_InvokeDynamic_spec,
-    e_cp_InvokeDynamic_desc,
-
-    // bands which define transmission of attributes
-    e_attr_definition_headers,
-    e_attr_definition_name,
-    e_attr_definition_layout,
-
-    // band for hardwired InnerClasses attribute (shared across the package)
-    e_ic_this_class,
-    e_ic_flags,
-    // These bands contain data only where flags sets ACC_IC_LONG_FORM:
-    e_ic_outer_class,
-    e_ic_name,
-
-    // bands for carrying class schema information:
-    e_class_this,
-    e_class_super,
-    e_class_interface_count,
-    e_class_interface,
-
-    // bands for class members
-    e_class_field_count,
-    e_class_method_count,
-
-    e_field_descr,
-    e_field_flags_hi,
-    e_field_flags_lo,
-    e_field_attr_count,
-    e_field_attr_indexes,
-    e_field_attr_calls,
-    e_field_ConstantValue_KQ,
-    e_field_Signature_RS,
-    e_field_metadata_bands,
-    e_field_attr_bands,
-
-    e_method_descr,
-    e_method_flags_hi,
-    e_method_flags_lo,
-    e_method_attr_count,
-    e_method_attr_indexes,
-    e_method_attr_calls,
-    e_method_Exceptions_N,
-    e_method_Exceptions_RC,
-    e_method_Signature_RS,
-    e_method_metadata_bands,
-    e_method_MethodParameters_NB,
-    e_method_MethodParameters_name_RUN,
-    e_method_MethodParameters_flag_FH,
-    e_method_attr_bands,
-
-    e_class_flags_hi,
-    e_class_flags_lo,
-    e_class_attr_count,
-    e_class_attr_indexes,
-    e_class_attr_calls,
-    e_class_SourceFile_RUN,
-    e_class_EnclosingMethod_RC,
-    e_class_EnclosingMethod_RDN,
-    e_class_Signature_RS,
-    e_class_metadata_bands,
-    e_class_InnerClasses_N,
-    e_class_InnerClasses_RC,
-    e_class_InnerClasses_F,
-    e_class_InnerClasses_outer_RCN,
-    e_class_InnerClasses_name_RUN,
-    e_class_ClassFile_version_minor_H,
-    e_class_ClassFile_version_major_H,
-    e_class_attr_bands,
-
-    e_code_headers,
-    e_code_max_stack,
-    e_code_max_na_locals,
-    e_code_handler_count,
-    e_code_handler_start_P,
-    e_code_handler_end_PO,
-    e_code_handler_catch_PO,
-    e_code_handler_class_RCN,
-
-    // code attributes
-    e_code_flags_hi,
-    e_code_flags_lo,
-    e_code_attr_count,
-    e_code_attr_indexes,
-    e_code_attr_calls,
-    e_code_StackMapTable_N,
-    e_code_StackMapTable_frame_T,
-    e_code_StackMapTable_local_N,
-    e_code_StackMapTable_stack_N,
-    e_code_StackMapTable_offset,
-    e_code_StackMapTable_T,
-    e_code_StackMapTable_RC,
-    e_code_StackMapTable_P,
-    e_code_LineNumberTable_N,
-    e_code_LineNumberTable_bci_P,
-    e_code_LineNumberTable_line,
-    e_code_LocalVariableTable_N,
-    e_code_LocalVariableTable_bci_P,
-    e_code_LocalVariableTable_span_O,
-    e_code_LocalVariableTable_name_RU,
-    e_code_LocalVariableTable_type_RS,
-    e_code_LocalVariableTable_slot,
-    e_code_LocalVariableTypeTable_N,
-    e_code_LocalVariableTypeTable_bci_P,
-    e_code_LocalVariableTypeTable_span_O,
-    e_code_LocalVariableTypeTable_name_RU,
-    e_code_LocalVariableTypeTable_type_RS,
-    e_code_LocalVariableTypeTable_slot,
-    e_code_attr_bands,
-
-    // bands for bytecodes
-    e_bc_codes,
-    // remaining bands provide typed opcode fields required by the bc_codes
-
-    e_bc_case_count,
-    e_bc_case_value,
-    e_bc_byte,
-    e_bc_short,
-    e_bc_local,
-    e_bc_label,
-
-    // ldc* operands:
-    e_bc_intref,
-    e_bc_floatref,
-    e_bc_longref,
-    e_bc_doubleref,
-    e_bc_stringref,
-    e_bc_loadablevalueref,
-    e_bc_classref,
-
-    e_bc_fieldref,
-    e_bc_methodref,
-    e_bc_imethodref,
-    e_bc_indyref,
-
-    // _self_linker_op family
-    e_bc_thisfield,
-    e_bc_superfield,
-    e_bc_thismethod,
-    e_bc_supermethod,
-
-    // bc_invokeinit family:
-    e_bc_initref,
-
-    // bytecode escape sequences
-    e_bc_escref,
-    e_bc_escrefsize,
-    e_bc_escsize,
-    e_bc_escbyte,
-
-    // file attributes and contents
-    e_file_name,
-    e_file_size_hi,
-    e_file_size_lo,
-    e_file_modtime,
-    e_file_options,
-    //e_file_bits,  // handled specially as an appendix
-
-    BAND_LIMIT
-};
-
-// Symbolic names for bands, as if in a giant global struct:
-//#define archive_magic all_bands[e_archive_magic]
-//#define archive_header all_bands[e_archive_header]
-//#define band_headers all_bands[e_band_headers]
-#define cp_Utf8_prefix all_bands[e_cp_Utf8_prefix]
-#define cp_Utf8_suffix all_bands[e_cp_Utf8_suffix]
-#define cp_Utf8_chars all_bands[e_cp_Utf8_chars]
-#define cp_Utf8_big_suffix all_bands[e_cp_Utf8_big_suffix]
-#define cp_Utf8_big_chars all_bands[e_cp_Utf8_big_chars]
-#define cp_Int all_bands[e_cp_Int]
-#define cp_Float all_bands[e_cp_Float]
-#define cp_Long_hi all_bands[e_cp_Long_hi]
-#define cp_Long_lo all_bands[e_cp_Long_lo]
-#define cp_Double_hi all_bands[e_cp_Double_hi]
-#define cp_Double_lo all_bands[e_cp_Double_lo]
-#define cp_String all_bands[e_cp_String]
-#define cp_Class all_bands[e_cp_Class]
-#define cp_Signature_form all_bands[e_cp_Signature_form]
-#define cp_Signature_classes all_bands[e_cp_Signature_classes]
-#define cp_Descr_name all_bands[e_cp_Descr_name]
-#define cp_Descr_type all_bands[e_cp_Descr_type]
-#define cp_Field_class all_bands[e_cp_Field_class]
-#define cp_Field_desc all_bands[e_cp_Field_desc]
-#define cp_Method_class all_bands[e_cp_Method_class]
-#define cp_Method_desc all_bands[e_cp_Method_desc]
-#define cp_Imethod_class all_bands[e_cp_Imethod_class]
-#define cp_Imethod_desc all_bands[e_cp_Imethod_desc]
-#define cp_MethodHandle_refkind all_bands[e_cp_MethodHandle_refkind]
-#define cp_MethodHandle_member all_bands[e_cp_MethodHandle_member]
-#define cp_MethodType all_bands[e_cp_MethodType]
-#define cp_BootstrapMethod_ref all_bands[e_cp_BootstrapMethod_ref]
-#define cp_BootstrapMethod_arg_count all_bands[e_cp_BootstrapMethod_arg_count]
-#define cp_BootstrapMethod_arg all_bands[e_cp_BootstrapMethod_arg]
-#define cp_InvokeDynamic_spec  all_bands[e_cp_InvokeDynamic_spec]
-#define cp_InvokeDynamic_desc all_bands[e_cp_InvokeDynamic_desc]
-#define attr_definition_headers all_bands[e_attr_definition_headers]
-#define attr_definition_name all_bands[e_attr_definition_name]
-#define attr_definition_layout all_bands[e_attr_definition_layout]
-#define ic_this_class all_bands[e_ic_this_class]
-#define ic_flags all_bands[e_ic_flags]
-#define ic_outer_class all_bands[e_ic_outer_class]
-#define ic_name all_bands[e_ic_name]
-#define class_this all_bands[e_class_this]
-#define class_super all_bands[e_class_super]
-#define class_interface_count all_bands[e_class_interface_count]
-#define class_interface all_bands[e_class_interface]
-#define class_field_count all_bands[e_class_field_count]
-#define class_method_count all_bands[e_class_method_count]
-#define field_descr all_bands[e_field_descr]
-#define field_flags_hi all_bands[e_field_flags_hi]
-#define field_flags_lo all_bands[e_field_flags_lo]
-#define field_attr_count all_bands[e_field_attr_count]
-#define field_attr_indexes all_bands[e_field_attr_indexes]
-#define field_ConstantValue_KQ all_bands[e_field_ConstantValue_KQ]
-#define field_Signature_RS all_bands[e_field_Signature_RS]
-#define field_attr_bands all_bands[e_field_attr_bands]
-#define method_descr all_bands[e_method_descr]
-#define method_flags_hi all_bands[e_method_flags_hi]
-#define method_flags_lo all_bands[e_method_flags_lo]
-#define method_attr_count all_bands[e_method_attr_count]
-#define method_attr_indexes all_bands[e_method_attr_indexes]
-#define method_Exceptions_N all_bands[e_method_Exceptions_N]
-#define method_Exceptions_RC all_bands[e_method_Exceptions_RC]
-#define method_Signature_RS all_bands[e_method_Signature_RS]
-#define method_MethodParameters_NB all_bands[e_method_MethodParameters_NB]
-#define method_MethodParameters_name_RUN all_bands[e_method_MethodParameters_name_RUN]
-#define method_MethodParameters_flag_FH all_bands[e_method_MethodParameters_flag_FH]
-#define method_attr_bands all_bands[e_method_attr_bands]
-#define class_flags_hi all_bands[e_class_flags_hi]
-#define class_flags_lo all_bands[e_class_flags_lo]
-#define class_attr_count all_bands[e_class_attr_count]
-#define class_attr_indexes all_bands[e_class_attr_indexes]
-#define class_SourceFile_RUN all_bands[e_class_SourceFile_RUN]
-#define class_EnclosingMethod_RC all_bands[e_class_EnclosingMethod_RC]
-#define class_EnclosingMethod_RDN all_bands[e_class_EnclosingMethod_RDN]
-#define class_Signature_RS all_bands[e_class_Signature_RS]
-#define class_InnerClasses_N all_bands[e_class_InnerClasses_N]
-#define class_InnerClasses_RC all_bands[e_class_InnerClasses_RC]
-#define class_InnerClasses_F all_bands[e_class_InnerClasses_F]
-#define class_InnerClasses_outer_RCN all_bands[e_class_InnerClasses_outer_RCN]
-#define class_InnerClasses_name_RUN all_bands[e_class_InnerClasses_name_RUN]
-#define class_ClassFile_version_minor_H all_bands[e_class_ClassFile_version_minor_H]
-#define class_ClassFile_version_major_H all_bands[e_class_ClassFile_version_major_H]
-#define class_attr_bands all_bands[e_class_attr_bands]
-#define code_headers all_bands[e_code_headers]
-#define code_max_stack all_bands[e_code_max_stack]
-#define code_max_na_locals all_bands[e_code_max_na_locals]
-#define code_handler_count all_bands[e_code_handler_count]
-#define code_handler_start_P all_bands[e_code_handler_start_P]
-#define code_handler_end_PO all_bands[e_code_handler_end_PO]
-#define code_handler_catch_PO all_bands[e_code_handler_catch_PO]
-#define code_handler_class_RCN all_bands[e_code_handler_class_RCN]
-#define code_flags_hi all_bands[e_code_flags_hi]
-#define code_flags_lo all_bands[e_code_flags_lo]
-#define code_attr_count all_bands[e_code_attr_count]
-#define code_attr_indexes all_bands[e_code_attr_indexes]
-#define code_StackMapTable_N all_bands[e_code_StackMapTable_N]
-#define code_StackMapTable_frame_T all_bands[e_code_StackMapTable_frame_T]
-#define code_StackMapTable_local_N all_bands[e_code_StackMapTable_local_N]
-#define code_StackMapTable_stack_N all_bands[e_code_StackMapTable_stack_N]
-#define code_StackMapTable_offset all_bands[e_code_StackMapTable_offset]
-#define code_StackMapTable_T all_bands[e_code_StackMapTable_T]
-#define code_StackMapTable_RC all_bands[e_code_StackMapTable_RC]
-#define code_StackMapTable_P all_bands[e_code_StackMapTable_P]
-#define code_LineNumberTable_N all_bands[e_code_LineNumberTable_N]
-#define code_LineNumberTable_bci_P all_bands[e_code_LineNumberTable_bci_P]
-#define code_LineNumberTable_line all_bands[e_code_LineNumberTable_line]
-#define code_LocalVariableTable_N all_bands[e_code_LocalVariableTable_N]
-#define code_LocalVariableTable_bci_P all_bands[e_code_LocalVariableTable_bci_P]
-#define code_LocalVariableTable_span_O all_bands[e_code_LocalVariableTable_span_O]
-#define code_LocalVariableTable_name_RU all_bands[e_code_LocalVariableTable_name_RU]
-#define code_LocalVariableTable_type_RS all_bands[e_code_LocalVariableTable_type_RS]
-#define code_LocalVariableTable_slot all_bands[e_code_LocalVariableTable_slot]
-#define code_LocalVariableTypeTable_N all_bands[e_code_LocalVariableTypeTable_N]
-#define code_LocalVariableTypeTable_bci_P all_bands[e_code_LocalVariableTypeTable_bci_P]
-#define code_LocalVariableTypeTable_span_O all_bands[e_code_LocalVariableTypeTable_span_O]
-#define code_LocalVariableTypeTable_name_RU all_bands[e_code_LocalVariableTypeTable_name_RU]
-#define code_LocalVariableTypeTable_type_RS all_bands[e_code_LocalVariableTypeTable_type_RS]
-#define code_LocalVariableTypeTable_slot all_bands[e_code_LocalVariableTypeTable_slot]
-#define code_attr_bands all_bands[e_code_attr_bands]
-#define bc_codes all_bands[e_bc_codes]
-#define bc_case_count all_bands[e_bc_case_count]
-#define bc_case_value all_bands[e_bc_case_value]
-#define bc_byte all_bands[e_bc_byte]
-#define bc_short all_bands[e_bc_short]
-#define bc_local all_bands[e_bc_local]
-#define bc_label all_bands[e_bc_label]
-#define bc_intref all_bands[e_bc_intref]
-#define bc_floatref all_bands[e_bc_floatref]
-#define bc_longref all_bands[e_bc_longref]
-#define bc_doubleref all_bands[e_bc_doubleref]
-#define bc_stringref all_bands[e_bc_stringref]
-#define bc_loadablevalueref all_bands[e_bc_loadablevalueref]
-#define bc_classref all_bands[e_bc_classref]
-#define bc_fieldref all_bands[e_bc_fieldref]
-#define bc_methodref all_bands[e_bc_methodref]
-#define bc_imethodref all_bands[e_bc_imethodref]
-#define bc_indyref all_bands[e_bc_indyref]
-#define bc_thisfield all_bands[e_bc_thisfield]
-#define bc_superfield all_bands[e_bc_superfield]
-#define bc_thismethod all_bands[e_bc_thismethod]
-#define bc_supermethod all_bands[e_bc_supermethod]
-#define bc_initref all_bands[e_bc_initref]
-#define bc_escref all_bands[e_bc_escref]
-#define bc_escrefsize all_bands[e_bc_escrefsize]
-#define bc_escsize all_bands[e_bc_escsize]
-#define bc_escbyte all_bands[e_bc_escbyte]
-#define file_name all_bands[e_file_name]
-#define file_size_hi all_bands[e_file_size_hi]
-#define file_size_lo all_bands[e_file_size_lo]
-#define file_modtime all_bands[e_file_modtime]
-#define file_options all_bands[e_file_options]
--- a/jdk/src/jdk.runtime/share/native/common-unpack/bytes.cpp	Fri Mar 06 13:30:49 2015 +0300
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,193 +0,0 @@
-/*
- * Copyright (c) 2001, 2010, 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 <stdio.h>
-#include <stdlib.h>
-#include <string.h>
-#include "defines.h"
-#include "bytes.h"
-#include "utils.h"
-
-
-static byte dummy[1 << 10];
-
-bool bytes::inBounds(const void* p) {
-  return p >= ptr && p < limit();
-}
-
-void bytes::malloc(size_t len_) {
-  len = len_;
-  ptr = NEW(byte, add_size(len_, 1));  // add trailing zero byte always
-  if (ptr == null) {
-    // set ptr to some victim memory, to ease escape
-    set(dummy, sizeof(dummy)-1);
-    unpack_abort(ERROR_ENOMEM);
-  }
-}
-
-void bytes::realloc(size_t len_) {
-  if (len == len_)   return;  // nothing to do
-  if (ptr == dummy)  return;  // escaping from an error
-  if (ptr == null) {
-    malloc(len_);
-    return;
-  }
-  byte* oldptr = ptr;
-  ptr = (len_ >= PSIZE_MAX) ? null : (byte*)::realloc(ptr, add_size(len_, 1));
-  if (ptr != null)  {
-    mtrace('r', oldptr, 0);
-    mtrace('m', ptr, len_+1);
-    if (len < len_)  memset(ptr+len, 0, len_-len);
-    ptr[len_] = 0;
-    len = len_;
-  } else {
-    ptr = oldptr;  // ease our escape
-    unpack_abort(ERROR_ENOMEM);
-  }
-}
-
-void bytes::free() {
-  if (ptr == dummy)  return;  // escaping from an error
-  if (ptr != null) {
-    mtrace('f', ptr, 0);
-    ::free(ptr);
-  }
-  len = 0;
-  ptr = 0;
-}
-
-int bytes::indexOf(byte c) {
-  byte* p = (byte*) memchr(ptr, c, len);
-  return (p == 0) ? -1 : (int)(p - ptr);
-}
-
-byte* bytes::writeTo(byte* bp) {
-  memcpy(bp, ptr, len);
-  return bp+len;
-}
-
-int bytes::compareTo(bytes& other) {
-  size_t l1 = len;
-  size_t l2 = other.len;
-  int cmp = memcmp(ptr, other.ptr, (l1 < l2) ? l1 : l2);
-  if (cmp != 0)  return cmp;
-  return (l1 < l2) ? -1 : (l1 > l2) ? 1 : 0;
-}
-
-void bytes::saveFrom(const void* ptr_, size_t len_) {
-  malloc(len_);
-  // Save as much as possible.  (Helps unpacker::abort.)
-  if (len_ > len) {
-    assert(ptr == dummy);  // error recovery
-    len_ = len;
-  }
-  copyFrom(ptr_, len_);
-}
-
-//#TODO: Need to fix for exception handling
-void bytes::copyFrom(const void* ptr_, size_t len_, size_t offset) {
-  assert(len_ == 0 || inBounds(ptr + offset));
-  assert(len_ == 0 || inBounds(ptr + offset+len_-1));
-  memcpy(ptr+offset, ptr_, len_);
-}
-
-
-#ifndef PRODUCT
-const char* bytes::string() {
-  if (len == 0)  return "";
-  if (ptr[len] == 0 && strlen((char*)ptr) == len)  return (const char*) ptr;
-  bytes junk;
-  junk.saveFrom(*this);
-  return (char*) junk.ptr;
-}
-#endif
-
-// Make sure there are 'o' bytes beyond the fill pointer,
-// advance the fill pointer, and return the old fill pointer.
-byte* fillbytes::grow(size_t s) {
-  size_t nlen = add_size(b.len, s);
-  if (nlen <= allocated) {
-    b.len = nlen;
-    return limit()-s;
-  }
-  size_t maxlen = nlen;
-  if (maxlen < 128)          maxlen = 128;
-  if (maxlen < allocated*2)  maxlen = allocated*2;
-  if (allocated == 0) {
-    // Initial buffer was not malloced.  Do not reallocate it.
-    bytes old = b;
-    b.malloc(maxlen);
-    if (b.len == maxlen)
-      old.writeTo(b.ptr);
-  } else {
-    b.realloc(maxlen);
-  }
-  allocated = b.len;
-  if (allocated != maxlen) {
-    assert(unpack_aborting());
-    b.len = nlen-s;  // back up
-    return dummy;    // scribble during error recov.
-  }
-  // after realloc, recompute pointers
-  b.len = nlen;
-  assert(b.len <= allocated);
-  return limit()-s;
-}
-
-void fillbytes::ensureSize(size_t s) {
-  if (allocated >= s)  return;
-  size_t len0 = b.len;
-  grow(s - size());
-  b.len = len0;  // put it back
-}
-
-int ptrlist::indexOf(const void* x) {
-  int len = length();
-  for (int i = 0; i < len; i++) {
-    if (get(i) == x)  return i;
-  }
-  return -1;
-}
-
-void ptrlist::freeAll() {
-  int len = length();
-  for (int i = 0; i < len; i++) {
-    void* p = (void*) get(i);
-    if (p != null)  {
-      mtrace('f', p, 0);
-      ::free(p);
-    }
-  }
-  free();
-}
-
-int intlist::indexOf(int x) {
-  int len = length();
-  for (int i = 0; i < len; i++) {
-    if (get(i) == x)  return i;
-  }
-  return -1;
-}
--- a/jdk/src/jdk.runtime/share/native/common-unpack/bytes.h	Fri Mar 06 13:30:49 2015 +0300
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,144 +0,0 @@
-/*
- * Copyright (c) 2001, 2008, 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.
- */
-
-#ifdef WIN32_LEAN_AND_MEAN
-typedef signed char byte ;
-#endif
-
-struct bytes {
-  byte*  ptr;
-  size_t len;
-  byte*  limit() { return ptr+len; }
-
-  void set(byte* ptr_, size_t len_) { ptr = ptr_; len = len_; }
-  void set(const char* str)         { ptr = (byte*)str; len = strlen(str); }
-  bool inBounds(const void* p);     // p in [ptr, limit)
-  void malloc(size_t len_);
-  void realloc(size_t len_);
-  void free();
-  void copyFrom(const void* ptr_, size_t len_, size_t offset = 0);
-  void saveFrom(const void* ptr_, size_t len_);
-  void saveFrom(const char* str) { saveFrom(str, strlen(str)); }
-  void copyFrom(bytes& other, size_t offset = 0) {
-    copyFrom(other.ptr, other.len, offset);
-  }
-  void saveFrom(bytes& other) {
-    saveFrom(other.ptr, other.len);
-  }
-  void clear(int fill_byte = 0) { memset(ptr, fill_byte, len); }
-  byte* writeTo(byte* bp);
-  bool equals(bytes& other) { return 0 == compareTo(other); }
-  int compareTo(bytes& other);
-  bool contains(byte c) { return indexOf(c) >= 0; }
-  int indexOf(byte c);
-  // substrings:
-  static bytes of(byte* ptr, size_t len) {
-    bytes res;
-    res.set(ptr, len);
-    return res;
-  }
-  bytes slice(size_t beg, size_t end) {
-    bytes res;
-    res.ptr = ptr + beg;
-    res.len = end - beg;
-    assert(res.len == 0 || inBounds(res.ptr) && inBounds(res.limit()-1));
-    return res;
-  }
-  // building C strings inside byte buffers:
-  bytes& strcat(const char* str) { ::strcat((char*)ptr, str); return *this; }
-  bytes& strcat(bytes& other) { ::strncat((char*)ptr, (char*)other.ptr, other.len); return *this; }
-  char* strval() { assert(strlen((char*)ptr) == len); return (char*) ptr; }
-#ifdef PRODUCT
-  const char* string() { return 0; }
-#else
-  const char* string();
-#endif
-};
-#define BYTES_OF(var) (bytes::of((byte*)&(var), sizeof(var)))
-
-struct fillbytes {
-  bytes b;
-  size_t allocated;
-
-  byte*  base()               { return b.ptr; }
-  size_t size()               { return b.len; }
-  byte*  limit()              { return b.limit(); }          // logical limit
-  void   setLimit(byte* lp)   { assert(isAllocated(lp)); b.len = lp - b.ptr; }
-  byte*  end()                { return b.ptr + allocated; }  // physical limit
-  byte*  loc(size_t o)        { assert(o < b.len); return b.ptr + o; }
-  void   init()               { allocated = 0; b.set(null, 0); }
-  void   init(size_t s)       { init(); ensureSize(s); }
-  void   free()               { if (allocated != 0) b.free(); allocated = 0; }
-  void   empty()              { b.len = 0; }
-  byte*  grow(size_t s);      // grow so that limit() += s
-  int    getByte(uint i)      { return *loc(i) & 0xFF; }
-  void   addByte(byte x)      { *grow(1) = x; }
-  void   ensureSize(size_t s); // make sure allocated >= s
-  void   trimToSize()         { if (allocated > size())  b.realloc(allocated = size()); }
-  bool   canAppend(size_t s)  { return allocated > b.len+s; }
-  bool   isAllocated(byte* p) { return p >= base() && p <= end(); } //asserts
-  void   set(bytes& src)      { set(src.ptr, src.len); }
-
-  void set(byte* ptr, size_t len) {
-    b.set(ptr, len);
-    allocated = 0;   // mark as not reallocatable
-  }
-
-  // block operations on resizing byte buffer:
-  fillbytes& append(const void* ptr_, size_t len_)
-    { memcpy(grow(len_), ptr_, len_); return (*this); }
-  fillbytes& append(bytes& other)
-    { return append(other.ptr, other.len); }
-  fillbytes& append(const char* str)
-    { return append(str, strlen(str)); }
-};
-
-struct ptrlist : fillbytes {
-  typedef const void* cvptr;
-  int    length()     { return (int)(size() / sizeof(cvptr)); }
-  cvptr* base()       { return (cvptr*) fillbytes::base(); }
-  cvptr& get(int i)   { return *(cvptr*)loc(i * sizeof(cvptr)); }
-  cvptr* limit()      { return (cvptr*) fillbytes::limit(); }
-  void   add(cvptr x) { *(cvptr*)grow(sizeof(x)) = x; }
-  void   popTo(int l) { assert(l <= length()); b.len = l * sizeof(cvptr); }
-  int    indexOf(cvptr x);
-  bool   contains(cvptr x) { return indexOf(x) >= 0; }
-  void   freeAll();   // frees every ptr on the list, plus the list itself
-};
-// Use a macro rather than mess with subtle mismatches
-// between member and non-member function pointers.
-#define PTRLIST_QSORT(ptrls, fn) \
-  ::qsort((ptrls).base(), (ptrls).length(), sizeof(void*), fn)
-
-struct intlist : fillbytes {
-  int    length()     { return (int)(size() / sizeof(int)); }
-  int*   base()       { return (int*) fillbytes::base(); }
-  int&   get(int i)   { return *(int*)loc(i * sizeof(int)); }
-  int*   limit()      { return (int*) fillbytes::limit(); }
-  void   add(int x)   { *(int*)grow(sizeof(x)) = x; }
-  void   popTo(int l) { assert(l <= length()); b.len = l * sizeof(int); }
-  int    indexOf(int x);
-  bool   contains(int x) { return indexOf(x) >= 0; }
-};
--- a/jdk/src/jdk.runtime/share/native/common-unpack/coding.cpp	Fri Mar 06 13:30:49 2015 +0300
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,989 +0,0 @@
-/*
- * Copyright (c) 2002, 2009, 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.
- */
-
-// -*- C++ -*-
-// Small program for unpacking specially compressed Java packages.
-// John R. Rose
-
-#include <stdio.h>
-#include <string.h>
-#include <stdlib.h>
-#include <stdarg.h>
-
-#include "jni_util.h"
-
-#include "defines.h"
-#include "bytes.h"
-#include "utils.h"
-#include "coding.h"
-
-#include "constants.h"
-#include "unpack.h"
-
-extern coding basic_codings[];
-
-#define CODING_PRIVATE(spec) \
-  int spec_ = spec; \
-  int B = CODING_B(spec_); \
-  int H = CODING_H(spec_); \
-  int L = 256 - H; \
-  int S = CODING_S(spec_); \
-  int D = CODING_D(spec_)
-
-#define IS_NEG_CODE(S, codeVal) \
-  ( (((int)(codeVal)+1) & ((1<<S)-1)) == 0 )
-
-#define DECODE_SIGN_S1(ux) \
-  ( ((uint)(ux) >> 1) ^ -((int)(ux) & 1) )
-
-static maybe_inline
-int decode_sign(int S, uint ux) {  // == Coding.decodeSign32
-  assert(S > 0);
-  uint sigbits = (ux >> S);
-  if (IS_NEG_CODE(S, ux))
-    return (int)(    ~sigbits);
-  else
-    return (int)(ux - sigbits);
-  // Note that (int)(ux-sigbits) can be negative, if ux is large enough.
-}
-
-coding* coding::init() {
-  if (umax > 0)  return this;  // already done
-  assert(spec != 0);  // sanity
-
-  // fill in derived fields
-  CODING_PRIVATE(spec);
-
-  // Return null if 'arb(BHSD)' parameter constraints are not met:
-  if (B < 1 || B > B_MAX)  return null;
-  if (H < 1 || H > 256)    return null;
-  if (S < 0 || S > 2)      return null;
-  if (D < 0 || D > 1)      return null;
-  if (B == 1 && H != 256)  return null;  // 1-byte coding must be fixed-size
-  if (B >= 5 && H == 256)  return null;  // no 5-byte fixed-size coding
-
-  // first compute the range of the coding, in 64 bits
-  jlong range = 0;
-  {
-    jlong H_i = 1;
-    for (int i = 0; i < B; i++) {
-      range += H_i;
-      H_i *= H;
-    }
-    range *= L;
-    range += H_i;
-  }
-  assert(range > 0);  // no useless codings, please
-
-  int this_umax;
-
-  // now, compute min and max
-  if (range >= ((jlong)1 << 32)) {
-    this_umax  = INT_MAX_VALUE;
-    this->umin = INT_MIN_VALUE;
-    this->max  = INT_MAX_VALUE;
-    this->min  = INT_MIN_VALUE;
-  } else {
-    this_umax = (range > INT_MAX_VALUE) ? INT_MAX_VALUE : (int)range-1;
-    this->max = this_umax;
-    this->min = this->umin = 0;
-    if (S != 0 && range != 0) {
-      int Smask = (1<<S)-1;
-      jlong maxPosCode = range-1;
-      jlong maxNegCode = range-1;
-      while (IS_NEG_CODE(S,  maxPosCode))  --maxPosCode;
-      while (!IS_NEG_CODE(S, maxNegCode))  --maxNegCode;
-      int maxPos = decode_sign(S, (uint)maxPosCode);
-      if (maxPos < 0)
-        this->max = INT_MAX_VALUE;  // 32-bit wraparound
-      else
-        this->max = maxPos;
-      if (maxNegCode < 0)
-        this->min = 0;  // No negative codings at all.
-      else
-        this->min = decode_sign(S, (uint)maxNegCode);
-    }
-  }
-
-  assert(!(isFullRange | isSigned | isSubrange)); // init
-  if (min < 0)
-    this->isSigned = true;
-  if (max < INT_MAX_VALUE && range <= INT_MAX_VALUE)
-    this->isSubrange = true;
-  if (max == INT_MAX_VALUE && min == INT_MIN_VALUE)
-    this->isFullRange = true;
-
-  // do this last, to reduce MT exposure (should have a membar too)
-  this->umax = this_umax;
-
-  return this;
-}
-
-coding* coding::findBySpec(int spec) {
-  for (coding* scan = &basic_codings[0]; ; scan++) {
-    if (scan->spec == spec)
-      return scan->init();
-    if (scan->spec == 0)
-      break;
-  }
-  coding* ptr = NEW(coding, 1);
-  CHECK_NULL_RETURN(ptr, 0);
-  coding* c = ptr->initFrom(spec);
-  if (c == null) {
-    mtrace('f', ptr, 0);
-    ::free(ptr);
-  } else
-    // else caller should free it...
-    c->isMalloc = true;
-  return c;
-}
-
-coding* coding::findBySpec(int B, int H, int S, int D) {
-  if (B < 1 || B > B_MAX)  return null;
-  if (H < 1 || H > 256)    return null;
-  if (S < 0 || S > 2)      return null;
-  if (D < 0 || D > 1)      return null;
-  return findBySpec(CODING_SPEC(B, H, S, D));
-}
-
-void coding::free() {
-  if (isMalloc) {
-    mtrace('f', this, 0);
-    ::free(this);
-  }
-}
-
-void coding_method::reset(value_stream* state) {
-  assert(state->rp == state->rplimit);  // not in mid-stream, please
-  //assert(this == vs0.cm);
-  state[0] = vs0;
-  if (uValues != null) {
-    uValues->reset(state->helper());
-  }
-}
-
-maybe_inline
-uint coding::parse(byte* &rp, int B, int H) {
-  int L = 256-H;
-  byte* ptr = rp;
-  // hand peel the i==0 part of the loop:
-  uint b_i = *ptr++ & 0xFF;
-  if (B == 1 || b_i < (uint)L)
-    { rp = ptr; return b_i; }
-  uint sum = b_i;
-  uint H_i = H;
-  assert(B <= B_MAX);
-  for (int i = 2; i <= B_MAX; i++) { // easy for compilers to unroll if desired
-    b_i = *ptr++ & 0xFF;
-    sum += b_i * H_i;
-    if (i == B || b_i < (uint)L)
-      { rp = ptr; return sum; }
-    H_i *= H;
-  }
-  assert(false);
-  return 0;
-}
-
-maybe_inline
-uint coding::parse_lgH(byte* &rp, int B, int H, int lgH) {
-  assert(H == (1<<lgH));
-  int L = 256-(1<<lgH);
-  byte* ptr = rp;
-  // hand peel the i==0 part of the loop:
-  uint b_i = *ptr++ & 0xFF;
-  if (B == 1 || b_i < (uint)L)
-    { rp = ptr; return b_i; }
-  uint sum = b_i;
-  uint lg_H_i = lgH;
-  assert(B <= B_MAX);
-  for (int i = 2; i <= B_MAX; i++) { // easy for compilers to unroll if desired
-    b_i = *ptr++ & 0xFF;
-    sum += b_i << lg_H_i;
-    if (i == B || b_i < (uint)L)
-      { rp = ptr; return sum; }
-    lg_H_i += lgH;
-  }
-  assert(false);
-  return 0;
-}
-
-static const char ERB[] = "EOF reading band";
-
-maybe_inline
-void coding::parseMultiple(byte* &rp, int N, byte* limit, int B, int H) {
-  if (N < 0) {
-    abort("bad value count");
-    return;
-  }
-  byte* ptr = rp;
-  if (B == 1 || H == 256) {
-    size_t len = (size_t)N*B;
-    if (len / B != (size_t)N || ptr+len > limit) {
-      abort(ERB);
-      return;
-    }
-    rp = ptr+len;
-    return;
-  }
-  // Note:  We assume rp has enough zero-padding.
-  int L = 256-H;
-  int n = B;
-  while (N > 0) {
-    ptr += 1;
-    if (--n == 0) {
-      // end of encoding at B bytes, regardless of byte value
-    } else {
-      int b = (ptr[-1] & 0xFF);
-      if (b >= L) {
-        // keep going, unless we find a byte < L
-        continue;
-      }
-    }
-    // found the last byte
-    N -= 1;
-    n = B;   // reset length counter
-    // do an error check here
-    if (ptr > limit) {
-      abort(ERB);
-      return;
-    }
-  }
-  rp = ptr;
-  return;
-}
-
-bool value_stream::hasHelper() {
-  // If my coding method is a pop-style method,
-  // then I need a second value stream to transmit
-  // unfavored values.
-  // This can be determined by examining fValues.
-  return cm->fValues != null;
-}
-
-void value_stream::init(byte* rp_, byte* rplimit_, coding* defc) {
-  rp = rp_;
-  rplimit = rplimit_;
-  sum = 0;
-  cm = null;  // no need in the simple case
-  setCoding(defc);
-}
-
-void value_stream::setCoding(coding* defc) {
-  if (defc == null) {
-    unpack_abort("bad coding");
-    defc = coding::findByIndex(_meta_canon_min);  // random pick for recovery
-  }
-
-  c = (*defc);
-
-  // choose cmk
-  cmk = cmk_ERROR;
-  switch (c.spec) {
-  case BYTE1_spec:      cmk = cmk_BYTE1;        break;
-  case CHAR3_spec:      cmk = cmk_CHAR3;        break;
-  case UNSIGNED5_spec:  cmk = cmk_UNSIGNED5;    break;
-  case DELTA5_spec:     cmk = cmk_DELTA5;       break;
-  case BCI5_spec:       cmk = cmk_BCI5;         break;
-  case BRANCH5_spec:    cmk = cmk_BRANCH5;      break;
-  default:
-    if (c.D() == 0) {
-      switch (c.S()) {
-      case 0:  cmk = cmk_BHS0;  break;
-      case 1:  cmk = cmk_BHS1;  break;
-      default: cmk = cmk_BHS;   break;
-      }
-    } else {
-      if (c.S() == 1) {
-        if (c.isFullRange)   cmk = cmk_BHS1D1full;
-        if (c.isSubrange)    cmk = cmk_BHS1D1sub;
-      }
-      if (cmk == cmk_ERROR)  cmk = cmk_BHSD1;
-    }
-  }
-}
-
-static maybe_inline
-int getPopValue(value_stream* self, uint uval) {
-  if (uval > 0) {
-    // note that the initial parse performed a range check
-    assert(uval <= (uint)self->cm->fVlength);
-    return self->cm->fValues[uval-1];
-  } else {
-    // take an unfavored value
-    return self->helper()->getInt();
-  }
-}
-
-maybe_inline
-int coding::sumInUnsignedRange(int x, int y) {
-  assert(isSubrange);
-  int range = (int)(umax+1);
-  assert(range > 0);
-  x += y;
-  if (x != (int)((jlong)(x-y) + (jlong)y)) {
-    // 32-bit overflow interferes with range reduction.
-    // Back off from the overflow by adding a multiple of range:
-    if (x < 0) {
-      x -= range;
-      assert(x >= 0);
-    } else {
-      x += range;
-      assert(x < 0);
-    }
-  }
-  if (x < 0) {
-    x += range;
-    if (x >= 0)  return x;
-  } else if (x >= range) {
-    x -= range;
-    if (x < range)  return x;
-  } else {
-    // in range
-    return x;
-  }
-  // do it the hard way
-  x %= range;
-  if (x < 0)  x += range;
-  return x;
-}
-
-static maybe_inline
-int getDeltaValue(value_stream* self, uint uval, bool isSubrange) {
-  assert((uint)(self->c.isSubrange) == (uint)isSubrange);
-  assert(self->c.isSubrange | self->c.isFullRange);
-  if (isSubrange)
-    return self->sum = self->c.sumInUnsignedRange(self->sum, (int)uval);
-  else
-    return self->sum += (int) uval;
-}
-
-bool value_stream::hasValue() {
-  if (rp < rplimit)      return true;
-  if (cm == null)        return false;
-  if (cm->next == null)  return false;
-  cm->next->reset(this);
-  return hasValue();
-}
-
-int value_stream::getInt() {
-  if (rp >= rplimit) {
-    // Advance to next coding segment.
-    if (rp > rplimit || cm == null || cm->next == null) {
-      // Must perform this check and throw an exception on bad input.
-      unpack_abort(ERB);
-      return 0;
-    }
-    cm->next->reset(this);
-    return getInt();
-  }
-
-  CODING_PRIVATE(c.spec);
-  uint uval;
-  enum {
-    B5 = 5,
-    B3 = 3,
-    H128 = 128,
-    H64 = 64,
-    H4 = 4
-  };
-  switch (cmk) {
-  case cmk_BHS:
-    assert(D == 0);
-    uval = coding::parse(rp, B, H);
-    if (S == 0)
-      return (int) uval;
-    return decode_sign(S, uval);
-
-  case cmk_BHS0:
-    assert(S == 0 && D == 0);
-    uval = coding::parse(rp, B, H);
-    return (int) uval;
-
-  case cmk_BHS1:
-    assert(S == 1 && D == 0);
-    uval = coding::parse(rp, B, H);
-    return DECODE_SIGN_S1(uval);
-
-  case cmk_BYTE1:
-    assert(c.spec == BYTE1_spec);
-    assert(B == 1 && H == 256 && S == 0 && D == 0);
-    return *rp++ & 0xFF;
-
-  case cmk_CHAR3:
-    assert(c.spec == CHAR3_spec);
-    assert(B == B3 && H == H128 && S == 0 && D == 0);
-    return coding::parse_lgH(rp, B3, H128, 7);
-
-  case cmk_UNSIGNED5:
-    assert(c.spec == UNSIGNED5_spec);
-    assert(B == B5 && H == H64 && S == 0 && D == 0);
-    return coding::parse_lgH(rp, B5, H64, 6);
-
-  case cmk_BHSD1:
-    assert(D == 1);
-    uval = coding::parse(rp, B, H);
-    if (S != 0)
-      uval = (uint) decode_sign(S, uval);
-    return getDeltaValue(this, uval, (bool)c.isSubrange);
-
-  case cmk_BHS1D1full:
-    assert(S == 1 && D == 1 && c.isFullRange);
-    uval = coding::parse(rp, B, H);
-    uval = (uint) DECODE_SIGN_S1(uval);
-    return getDeltaValue(this, uval, false);
-
-  case cmk_BHS1D1sub:
-    assert(S == 1 && D == 1 && c.isSubrange);
-    uval = coding::parse(rp, B, H);
-    uval = (uint) DECODE_SIGN_S1(uval);
-    return getDeltaValue(this, uval, true);
-
-  case cmk_DELTA5:
-    assert(c.spec == DELTA5_spec);
-    assert(B == B5 && H == H64 && S == 1 && D == 1 && c.isFullRange);
-    uval = coding::parse_lgH(rp, B5, H64, 6);
-    sum += DECODE_SIGN_S1(uval);
-    return sum;
-
-  case cmk_BCI5:
-    assert(c.spec == BCI5_spec);
-    assert(B == B5 && H == H4 && S == 0 && D == 0);
-    return coding::parse_lgH(rp, B5, H4, 2);
-
-  case cmk_BRANCH5:
-    assert(c.spec == BRANCH5_spec);
-    assert(B == B5 && H == H4 && S == 2 && D == 0);
-    uval = coding::parse_lgH(rp, B5, H4, 2);
-    return decode_sign(S, uval);
-
-  case cmk_pop:
-    uval = coding::parse(rp, B, H);
-    if (S != 0) {
-      uval = (uint) decode_sign(S, uval);
-    }
-    if (D != 0) {
-      assert(c.isSubrange | c.isFullRange);
-      if (c.isSubrange)
-        sum = c.sumInUnsignedRange(sum, (int) uval);
-      else
-        sum += (int) uval;
-      uval = (uint) sum;
-    }
-    return getPopValue(this, uval);
-
-  case cmk_pop_BHS0:
-    assert(S == 0 && D == 0);
-    uval = coding::parse(rp, B, H);
-    return getPopValue(this, uval);
-
-  case cmk_pop_BYTE1:
-    assert(c.spec == BYTE1_spec);
-    assert(B == 1 && H == 256 && S == 0 && D == 0);
-    return getPopValue(this, *rp++ & 0xFF);
-
-  default:
-    break;
-  }
-  assert(false);
-  return 0;
-}
-
-static maybe_inline
-int moreCentral(int x, int y) {  // used to find end of Pop.{F}
-  // Suggested implementation from the Pack200 specification:
-  uint kx = (x >> 31) ^ (x << 1);
-  uint ky = (y >> 31) ^ (y << 1);
-  return (kx < ky? x: y);
-}
-//static maybe_inline
-//int moreCentral2(int x, int y, int min) {
-//  // Strict implementation of buggy 150.7 specification.
-//  // The bug is that the spec. says absolute-value ties are broken
-//  // in favor of positive numbers, but the suggested implementation
-//  // (also mentioned in the spec.) breaks ties in favor of negative numbers.
-//  if ((x + y) != 0)
-//    return min;
-//  else
-//    // return the other value, which breaks a tie in the positive direction
-//    return (x > y)? x: y;
-//}
-
-static const byte* no_meta[] = {null};
-#define NO_META (*(byte**)no_meta)
-enum { POP_FAVORED_N = -2 };
-
-// mode bits
-#define DISABLE_RUN  1  // used immediately inside ACodee
-#define DISABLE_POP  2  // used recursively in all pop sub-bands
-
-// This function knows all about meta-coding.
-void coding_method::init(byte* &band_rp, byte* band_limit,
-                         byte* &meta_rp, int mode,
-                         coding* defc, int N,
-                         intlist* valueSink) {
-  assert(N != 0);
-
-  assert(u != null);  // must be pre-initialized
-  //if (u == null)  u = unpacker::current();  // expensive
-
-  int op = (meta_rp == null) ? _meta_default :  (*meta_rp++ & 0xFF);
-  coding* foundc = null;
-  coding* to_free = null;
-
-  if (op == _meta_default) {
-    foundc = defc;
-    // and fall through
-
-  } else if (op >= _meta_canon_min && op <= _meta_canon_max) {
-    foundc = coding::findByIndex(op);
-    // and fall through
-
-  } else if (op == _meta_arb) {
-    int args = (*meta_rp++ & 0xFF);
-    // args = (D:[0..1] + 2*S[0..2] + 8*(B:[1..5]-1))
-    int D = ((args >> 0) & 1);
-    int S = ((args >> 1) & 3);
-    int B = ((args >> 3) & -1) + 1;
-    // & (H[1..256]-1)
-    int H = (*meta_rp++ & 0xFF) + 1;
-    foundc = coding::findBySpec(B, H, S, D);
-    to_free = foundc;  // findBySpec may dynamically allocate
-    if (foundc == null) {
-      abort("illegal arb. coding");
-      return;
-    }
-    // and fall through
-
-  } else if (op >= _meta_run && op < _meta_pop) {
-    int args = (op - _meta_run);
-    // args: KX:[0..3] + 4*(KBFlag:[0..1]) + 8*(ABDef:[0..2])
-    int KX     = ((args >> 0) & 3);
-    int KBFlag = ((args >> 2) & 1);
-    int ABDef  = ((args >> 3) & -1);
-    assert(ABDef <= 2);
-    // & KB: one of [0..255] if KBFlag=1
-    int KB     = (!KBFlag? 3: (*meta_rp++ & 0xFF));
-    int K      = (KB+1) << (KX * 4);
-    int N2 = (N >= 0) ? N-K : N;
-    if (N == 0 || (N2 <= 0 && N2 != N)) {
-      abort("illegal run encoding");
-      return;
-    }
-    if ((mode & DISABLE_RUN) != 0) {
-      abort("illegal nested run encoding");
-      return;
-    }
-
-    // & Enc{ ACode } if ADef=0  (ABDef != 1)
-    // No direct nesting of 'run' in ACode, but in BCode it's OK.
-    int disRun = mode | DISABLE_RUN;
-    if (ABDef == 1) {
-      this->init(band_rp, band_limit, NO_META, disRun, defc, K, valueSink);
-    } else {
-      this->init(band_rp, band_limit, meta_rp, disRun, defc, K, valueSink);
-    }
-    CHECK;
-
-    // & Enc{ BCode } if BDef=0  (ABDef != 2)
-    coding_method* tail = U_NEW(coding_method, 1);
-    CHECK_NULL(tail);
-    tail->u = u;
-
-    // The 'run' codings may be nested indirectly via 'pop' codings.
-    // This means that this->next may already be filled in, if
-    // ACode was of type 'pop' with a 'run' token coding.
-    // No problem:  Just chain the upcoming BCode onto the end.
-    for (coding_method* self = this; ; self = self->next) {
-      if (self->next == null) {
-        self->next = tail;
-        break;
-      }
-    }
-
-    if (ABDef == 2) {
-      tail->init(band_rp, band_limit, NO_META, mode, defc, N2, valueSink);
-    } else {
-      tail->init(band_rp, band_limit, meta_rp, mode, defc, N2, valueSink);
-    }
-    // Note:  The preceding calls to init should be tail-recursive.
-
-    return;  // done; no falling through
-
-  } else if (op >= _meta_pop && op < _meta_limit) {
-    int args = (op - _meta_pop);
-    // args: (FDef:[0..1]) + 2*UDef:[0..1] + 4*(TDefL:[0..11])
-    int FDef  = ((args >> 0) & 1);
-    int UDef  = ((args >> 1) & 1);
-    int TDefL = ((args >> 2) & -1);
-    assert(TDefL <= 11);
-    int TDef  = (TDefL > 0);
-    int TL    = (TDefL <= 6) ? (2 << TDefL) : (256 - (4 << (11-TDefL)));
-    int TH    = (256-TL);
-    if (N <= 0) {
-      abort("illegal pop encoding");
-      return;
-    }
-    if ((mode & DISABLE_POP) != 0) {
-      abort("illegal nested pop encoding");
-      return;
-    }
-
-    // No indirect nesting of 'pop', but 'run' is OK.
-    int disPop = DISABLE_POP;
-
-    // & Enc{ FCode } if FDef=0
-    int FN = POP_FAVORED_N;
-    assert(valueSink == null);
-    intlist fValueSink; fValueSink.init();
-    coding_method fval;
-    BYTES_OF(fval).clear(); fval.u = u;
-    if (FDef != 0) {
-      fval.init(band_rp, band_limit, NO_META, disPop, defc, FN, &fValueSink);
-    } else {
-      fval.init(band_rp, band_limit, meta_rp, disPop, defc, FN, &fValueSink);
-    }
-    bytes fvbuf;
-    fValues  = (u->saveTo(fvbuf, fValueSink.b), (int*) fvbuf.ptr);
-    fVlength = fValueSink.length();  // i.e., the parameter K
-    fValueSink.free();
-    CHECK;
-
-    // Skip the first {F} run in all subsequent passes.
-    // The next call to this->init(...) will set vs0.rp to point after the {F}.
-
-    // & Enc{ TCode } if TDef=0  (TDefL==0)
-    if (TDef != 0) {
-      coding* tcode = coding::findBySpec(1, 256);  // BYTE1
-      // find the most narrowly sufficient code:
-      for (int B = 2; B <= B_MAX; B++) {
-        if (fVlength <= tcode->umax)  break;  // found it
-        tcode->free();
-        tcode = coding::findBySpec(B, TH);
-        CHECK_NULL(tcode);
-      }
-      if (!(fVlength <= tcode->umax)) {
-        abort("pop.L value too small");
-        return;
-      }
-      this->init(band_rp, band_limit, NO_META, disPop, tcode, N, null);
-      tcode->free();
-    } else {
-      this->init(band_rp, band_limit, meta_rp, disPop,  defc, N, null);
-    }
-    CHECK;
-
-    // Count the number of zero tokens right now.
-    // Also verify that they are in bounds.
-    int UN = 0;   // one {U} for each zero in {T}
-    value_stream vs = vs0;
-    for (int i = 0; i < N; i++) {
-      uint val = vs.getInt();
-      if (val == 0)  UN += 1;
-      if (!(val <= (uint)fVlength)) {
-        abort("pop token out of range");
-        return;
-      }
-    }
-    vs.done();
-
-    // & Enc{ UCode } if UDef=0
-    if (UN != 0) {
-      uValues = U_NEW(coding_method, 1);
-      CHECK_NULL(uValues);
-      uValues->u = u;
-      if (UDef != 0) {
-        uValues->init(band_rp, band_limit, NO_META, disPop, defc, UN, null);
-      } else {
-        uValues->init(band_rp, band_limit, meta_rp, disPop, defc, UN, null);
-      }
-    } else {
-      if (UDef == 0) {
-        int uop = (*meta_rp++ & 0xFF);
-        if (uop > _meta_canon_max)
-          // %%% Spec. requires the more strict (uop != _meta_default).
-          abort("bad meta-coding for empty pop/U");
-      }
-    }
-
-    // Bug fix for 6259542
-    // Last of all, adjust vs0.cmk to the 'pop' flavor
-    for (coding_method* self = this; self != null; self = self->next) {
-        coding_method_kind cmk2 = cmk_pop;
-        switch (self->vs0.cmk) {
-        case cmk_BHS0:   cmk2 = cmk_pop_BHS0;   break;
-        case cmk_BYTE1:  cmk2 = cmk_pop_BYTE1;  break;
-        default: break;
-        }
-        self->vs0.cmk = cmk2;
-        if (self != this) {
-          assert(self->fValues == null); // no double init
-          self->fValues  = this->fValues;
-          self->fVlength = this->fVlength;
-          assert(self->uValues == null); // must stay null
-        }
-    }
-
-    return;  // done; no falling through
-
-  } else {
-    abort("bad meta-coding");
-    return;
-  }
-
-  // Common code here skips a series of values with one coding.
-  assert(foundc != null);
-
-  assert(vs0.cmk == cmk_ERROR);  // no garbage, please
-  assert(vs0.rp == null);  // no garbage, please
-  assert(vs0.rplimit == null);  // no garbage, please
-  assert(vs0.sum == 0);  // no garbage, please
-
-  vs0.init(band_rp, band_limit, foundc);
-
-  // Done with foundc.  Free if necessary.
-  if (to_free != null) {
-    to_free->free();
-    to_free = null;
-  }
-  foundc = null;
-
-  coding& c = vs0.c;
-  CODING_PRIVATE(c.spec);
-  // assert sane N
-  assert((uint)N < INT_MAX_VALUE || N == POP_FAVORED_N);
-
-  // Look at the values, or at least skip over them quickly.
-  if (valueSink == null) {
-    // Skip and ignore values in the first pass.
-    c.parseMultiple(band_rp, N, band_limit, B, H);
-  } else if (N >= 0) {
-    // Pop coding, {F} sequence, initial run of values...
-    assert((mode & DISABLE_POP) != 0);
-    value_stream vs = vs0;
-    for (int n = 0; n < N; n++) {
-      int val = vs.getInt();
-      valueSink->add(val);
-    }
-    band_rp = vs.rp;
-  } else {
-    // Pop coding, {F} sequence, final run of values...
-    assert((mode & DISABLE_POP) != 0);
-    assert(N == POP_FAVORED_N);
-    int min = INT_MIN_VALUE;  // farthest from the center
-    // min2 is based on the buggy specification of centrality in version 150.7
-    // no known implementations transmit this value, but just in case...
-    //int min2 = INT_MIN_VALUE;
-    int last = 0;
-    // if there were initial runs, find the potential sentinels in them:
-    for (int i = 0; i < valueSink->length(); i++) {
-      last = valueSink->get(i);
-      min = moreCentral(min, last);
-      //min2 = moreCentral2(min2, last, min);
-    }
-    value_stream vs = vs0;
-    for (;;) {
-      int val = vs.getInt();
-      if (valueSink->length() > 0 &&
-          (val == last || val == min)) //|| val == min2
-        break;
-      valueSink->add(val);
-      CHECK;
-      last = val;
-      min = moreCentral(min, last);
-      //min2 = moreCentral2(min2, last, min);
-    }
-    band_rp = vs.rp;
-  }
-  CHECK;
-
-  // Get an accurate upper limit now.
-  vs0.rplimit = band_rp;
-  vs0.cm = this;
-
-  return; // success
-}
-
-coding basic_codings[] = {
-  // This one is not a usable irregular coding, but is used by cp_Utf8_chars.
-  CODING_INIT(3,128,0,0),
-
-  // Fixed-length codings:
-  CODING_INIT(1,256,0,0),
-  CODING_INIT(1,256,1,0),
-  CODING_INIT(1,256,0,1),
-  CODING_INIT(1,256,1,1),
-  CODING_INIT(2,256,0,0),
-  CODING_INIT(2,256,1,0),
-  CODING_INIT(2,256,0,1),
-  CODING_INIT(2,256,1,1),
-  CODING_INIT(3,256,0,0),
-  CODING_INIT(3,256,1,0),
-  CODING_INIT(3,256,0,1),
-  CODING_INIT(3,256,1,1),
-  CODING_INIT(4,256,0,0),
-  CODING_INIT(4,256,1,0),
-  CODING_INIT(4,256,0,1),
-  CODING_INIT(4,256,1,1),
-
-  // Full-range variable-length codings:
-  CODING_INIT(5,  4,0,0),
-  CODING_INIT(5,  4,1,0),
-  CODING_INIT(5,  4,2,0),
-  CODING_INIT(5, 16,0,0),
-  CODING_INIT(5, 16,1,0),
-  CODING_INIT(5, 16,2,0),
-  CODING_INIT(5, 32,0,0),
-  CODING_INIT(5, 32,1,0),
-  CODING_INIT(5, 32,2,0),
-  CODING_INIT(5, 64,0,0),
-  CODING_INIT(5, 64,1,0),
-  CODING_INIT(5, 64,2,0),
-  CODING_INIT(5,128,0,0),
-  CODING_INIT(5,128,1,0),
-  CODING_INIT(5,128,2,0),
-
-  CODING_INIT(5,  4,0,1),
-  CODING_INIT(5,  4,1,1),
-  CODING_INIT(5,  4,2,1),
-  CODING_INIT(5, 16,0,1),
-  CODING_INIT(5, 16,1,1),
-  CODING_INIT(5, 16,2,1),
-  CODING_INIT(5, 32,0,1),
-  CODING_INIT(5, 32,1,1),
-  CODING_INIT(5, 32,2,1),
-  CODING_INIT(5, 64,0,1),
-  CODING_INIT(5, 64,1,1),
-  CODING_INIT(5, 64,2,1),
-  CODING_INIT(5,128,0,1),
-  CODING_INIT(5,128,1,1),
-  CODING_INIT(5,128,2,1),
-
-  // Variable length subrange codings:
-  CODING_INIT(2,192,0,0),
-  CODING_INIT(2,224,0,0),
-  CODING_INIT(2,240,0,0),
-  CODING_INIT(2,248,0,0),
-  CODING_INIT(2,252,0,0),
-
-  CODING_INIT(2,  8,0,1),
-  CODING_INIT(2,  8,1,1),
-  CODING_INIT(2, 16,0,1),
-  CODING_INIT(2, 16,1,1),
-  CODING_INIT(2, 32,0,1),
-  CODING_INIT(2, 32,1,1),
-  CODING_INIT(2, 64,0,1),
-  CODING_INIT(2, 64,1,1),
-  CODING_INIT(2,128,0,1),
-  CODING_INIT(2,128,1,1),
-  CODING_INIT(2,192,0,1),
-  CODING_INIT(2,192,1,1),
-  CODING_INIT(2,224,0,1),
-  CODING_INIT(2,224,1,1),
-  CODING_INIT(2,240,0,1),
-  CODING_INIT(2,240,1,1),
-  CODING_INIT(2,248,0,1),
-  CODING_INIT(2,248,1,1),
-
-  CODING_INIT(3,192,0,0),
-  CODING_INIT(3,224,0,0),
-  CODING_INIT(3,240,0,0),
-  CODING_INIT(3,248,0,0),
-  CODING_INIT(3,252,0,0),
-
-  CODING_INIT(3,  8,0,1),
-  CODING_INIT(3,  8,1,1),
-  CODING_INIT(3, 16,0,1),
-  CODING_INIT(3, 16,1,1),
-  CODING_INIT(3, 32,0,1),
-  CODING_INIT(3, 32,1,1),
-  CODING_INIT(3, 64,0,1),
-  CODING_INIT(3, 64,1,1),
-  CODING_INIT(3,128,0,1),
-  CODING_INIT(3,128,1,1),
-  CODING_INIT(3,192,0,1),
-  CODING_INIT(3,192,1,1),
-  CODING_INIT(3,224,0,1),
-  CODING_INIT(3,224,1,1),
-  CODING_INIT(3,240,0,1),
-  CODING_INIT(3,240,1,1),
-  CODING_INIT(3,248,0,1),
-  CODING_INIT(3,248,1,1),
-
-  CODING_INIT(4,192,0,0),
-  CODING_INIT(4,224,0,0),
-  CODING_INIT(4,240,0,0),
-  CODING_INIT(4,248,0,0),
-  CODING_INIT(4,252,0,0),
-
-  CODING_INIT(4,  8,0,1),
-  CODING_INIT(4,  8,1,1),
-  CODING_INIT(4, 16,0,1),
-  CODING_INIT(4, 16,1,1),
-  CODING_INIT(4, 32,0,1),
-  CODING_INIT(4, 32,1,1),
-  CODING_INIT(4, 64,0,1),
-  CODING_INIT(4, 64,1,1),
-  CODING_INIT(4,128,0,1),
-  CODING_INIT(4,128,1,1),
-  CODING_INIT(4,192,0,1),
-  CODING_INIT(4,192,1,1),
-  CODING_INIT(4,224,0,1),
-  CODING_INIT(4,224,1,1),
-  CODING_INIT(4,240,0,1),
-  CODING_INIT(4,240,1,1),
-  CODING_INIT(4,248,0,1),
-  CODING_INIT(4,248,1,1),
-  CODING_INIT(0,0,0,0)
-};
-#define BASIC_INDEX_LIMIT \
-        (int)(sizeof(basic_codings)/sizeof(basic_codings[0])-1)
-
-coding* coding::findByIndex(int idx) {
-#ifndef PRODUCT
-  /* Tricky assert here, constants and gcc complains about it without local. */
-  int index_limit = BASIC_INDEX_LIMIT;
-  assert(_meta_canon_min == 1 && _meta_canon_max+1 == index_limit);
-#endif
-  if (idx >= _meta_canon_min && idx <= _meta_canon_max)
-    return basic_codings[idx].init();
-  else
-    return null;
-}
-
-#ifndef PRODUCT
-const char* coding::string() {
-  CODING_PRIVATE(spec);
-  bytes buf;
-  buf.malloc(100);
-  char maxS[20], minS[20];
-  sprintf(maxS, "%d", max);
-  sprintf(minS, "%d", min);
-  if (max == INT_MAX_VALUE)  strcpy(maxS, "max");
-  if (min == INT_MIN_VALUE)  strcpy(minS, "min");
-  sprintf((char*)buf.ptr, "(%d,%d,%d,%d) L=%d r=[%s,%s]",
-          B,H,S,D,L,minS,maxS);
-  return (const char*) buf.ptr;
-}
-#endif
--- a/jdk/src/jdk.runtime/share/native/common-unpack/coding.h	Fri Mar 06 13:30:49 2015 +0300
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,226 +0,0 @@
-/*
- * Copyright (c) 2002, 2008, 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.
- */
-
-struct unpacker;
-
-#define INT_MAX_VALUE ((int)0x7FFFFFFF)
-#define INT_MIN_VALUE ((int)0x80000000)
-
-#define CODING_SPEC(B, H, S, D) ((B)<<20|(H)<<8|(S)<<4|(D)<<0)
-#define CODING_B(x) ((x)>>20 & 0xF)
-#define CODING_H(x) ((x)>>8  & 0xFFF)
-#define CODING_S(x) ((x)>>4  & 0xF)
-#define CODING_D(x) ((x)>>0  & 0xF)
-
-#define CODING_INIT(B, H, S, D) \
-  { CODING_SPEC(B, H, S, D) , 0, 0, 0, 0, 0, 0, 0, 0}
-
-// For debugging purposes, some compilers do not like this and will complain.
-//    #define long do_not_use_C_long_types_use_jlong_or_int
-// Use of the type "long" is problematic, do not use it.
-
-struct coding {
-  int  spec;  // B,H,S,D
-
-  // Handy values derived from the spec:
-  int B() { return CODING_B(spec); }
-  int H() { return CODING_H(spec); }
-  int S() { return CODING_S(spec); }
-  int D() { return CODING_D(spec); }
-  int L() { return 256-CODING_H(spec); }
-  int  min, max;
-  int  umin, umax;
-  char isSigned, isSubrange, isFullRange, isMalloc;
-
-  coding* init();  // returns self or null if error
-  coding* initFrom(int spec_) {
-    assert(this->spec == 0);
-    this->spec = spec_;
-    return init();
-  }
-
-  static coding* findBySpec(int spec);
-  static coding* findBySpec(int B, int H, int S=0, int D=0);
-  static coding* findByIndex(int irregularCodingIndex);
-
-  static uint parse(byte* &rp, int B, int H);
-  static uint parse_lgH(byte* &rp, int B, int H, int lgH);
-  static void parseMultiple(byte* &rp, int N, byte* limit, int B, int H);
-
-  uint parse(byte* &rp) {
-    return parse(rp, CODING_B(spec), CODING_H(spec));
-  }
-  void parseMultiple(byte* &rp, int N, byte* limit) {
-    parseMultiple(rp, N, limit, CODING_B(spec), CODING_H(spec));
-  }
-
-  bool canRepresent(int x)         { return (x >= min  && x <= max);  }
-  bool canRepresentUnsigned(int x) { return (x >= umin && x <= umax); }
-
-  int sumInUnsignedRange(int x, int y);
-
-  int readFrom(byte* &rpVar, int* dbase);
-  void readArrayFrom(byte* &rpVar, int* dbase, int length, int* values);
-  void skipArrayFrom(byte* &rpVar, int length) {
-    readArrayFrom(rpVar, (int*)NULL, length, (int*)NULL);
-  }
-
-#ifndef PRODUCT
-  const char* string();
-#endif
-
-  void free();  // free self if isMalloc
-
-  // error handling
-  static void abort(const char* msg = null) { unpack_abort(msg); }
-};
-
-enum coding_method_kind {
-  cmk_ERROR,
-  cmk_BHS,
-  cmk_BHS0,
-  cmk_BHS1,
-  cmk_BHSD1,
-  cmk_BHS1D1full,  // isFullRange
-  cmk_BHS1D1sub,   // isSubRange
-
-  // special cases hand-optimized (~50% of all decoded values)
-  cmk_BYTE1,         //(1,256)      6%
-  cmk_CHAR3,         //(3,128)      7%
-  cmk_UNSIGNED5,     //(5,64)      13%
-  cmk_DELTA5,        //(5,64,1,1)   5%
-  cmk_BCI5,          //(5,4)       18%
-  cmk_BRANCH5,       //(5,4,2)      4%
-//cmk_UNSIGNED5H16,  //(5,16)       5%
-//cmk_UNSIGNED2H4,   //(2,4)        6%
-//cmk_DELTA4H8,      //(4,8,1,1)   10%
-//cmk_DELTA3H16,     //(3,16,1,1)   9%
-  cmk_BHS_LIMIT,
-
-  cmk_pop,
-  cmk_pop_BHS0,
-  cmk_pop_BYTE1,
-  cmk_pop_LIMIT,
-
-  cmk_LIMIT
-};
-
-enum {
-  BYTE1_spec       = CODING_SPEC(1, 256, 0, 0),
-  CHAR3_spec       = CODING_SPEC(3, 128, 0, 0),
-  UNSIGNED4_spec   = CODING_SPEC(4, 256, 0, 0),
-  UNSIGNED5_spec   = CODING_SPEC(5, 64, 0, 0),
-  SIGNED5_spec     = CODING_SPEC(5, 64, 1, 0),
-  DELTA5_spec      = CODING_SPEC(5, 64, 1, 1),
-  UDELTA5_spec     = CODING_SPEC(5, 64, 0, 1),
-  MDELTA5_spec     = CODING_SPEC(5, 64, 2, 1),
-  BCI5_spec        = CODING_SPEC(5, 4, 0, 0),
-  BRANCH5_spec     = CODING_SPEC(5, 4, 2, 0)
-};
-
-enum {
-  B_MAX = 5,
-  C_SLOP = B_MAX*10
-};
-
-struct coding_method;
-
-// iterator under the control of a meta-coding
-struct value_stream {
-  // current coding of values or values
-  coding c;               // B,H,S,D,etc.
-  coding_method_kind cmk; // type of decoding needed
-  byte* rp;               // read pointer
-  byte* rplimit;          // final value of read pointer
-  int sum;                // partial sum of all values so far (D=1 only)
-  coding_method* cm;      // coding method that defines this stream
-
-  void init(byte* band_rp, byte* band_limit, coding* defc);
-  void init(byte* band_rp, byte* band_limit, int spec)
-    { init(band_rp, band_limit, coding::findBySpec(spec)); }
-
-  void setCoding(coding* c);
-  void setCoding(int spec) { setCoding(coding::findBySpec(spec)); }
-
-  // Parse and decode a single value.
-  int getInt();
-
-  // Parse and decode a single byte, with no error checks.
-  int getByte() {
-    assert(cmk == cmk_BYTE1);
-    assert(rp < rplimit);
-    return *rp++ & 0xFF;
-  }
-
-  // Used only for asserts.
-  bool hasValue();
-
-  void done() { assert(!hasValue()); }
-
-  // Sometimes a value stream has an auxiliary (but there are never two).
-  value_stream* helper() {
-    assert(hasHelper());
-    return this+1;
-  }
-  bool hasHelper();
-
-  // error handling
-  //  inline void abort(const char* msg);
-  //  inline void aborting();
-};
-
-struct coding_method {
-  value_stream vs0;       // initial state snapshot (vs.meta==this)
-
-  coding_method* next;    // what to do when we run out of bytes
-
-  // these fields are used for pop codes only:
-  int* fValues;           // favored value array
-  int  fVlength;          // maximum favored value token
-  coding_method* uValues; // unfavored value stream
-
-  // pointer to outer unpacker, for error checks etc.
-  unpacker* u;
-
-  // Initialize a value stream.
-  void reset(value_stream* state);
-
-  // Parse a band header, size a band, and initialize for further action.
-  // band_rp advances (but not past band_limit), and meta_rp advances.
-  // The mode gives context, such as "inside a pop".
-  // The defc and N are the incoming parameters to a meta-coding.
-  // The value sink is used to collect output values, when desired.
-  void init(byte* &band_rp, byte* band_limit,
-            byte* &meta_rp, int mode,
-            coding* defc, int N,
-            intlist* valueSink);
-
-  // error handling
-  void abort(const char* msg) { unpack_abort(msg, u); }
-  bool aborting()             { return unpack_aborting(u); }
-};
-
-//inline void value_stream::abort(const char* msg) { cm->abort(msg); }
-//inline void value_stream::aborting()             { cm->aborting(); }
--- a/jdk/src/jdk.runtime/share/native/common-unpack/constants.h	Fri Mar 06 13:30:49 2015 +0300
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,517 +0,0 @@
-/*
- * Copyright (c) 2001, 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.
- */
-
-/*
-  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
-
-// package file constants
-#define JAVA_PACKAGE_MAGIC 0xCAFED00D
-#define JAVA5_PACKAGE_MAJOR_VERSION 150
-#define JAVA5_PACKAGE_MINOR_VERSION 7
-
-#define JAVA6_PACKAGE_MAJOR_VERSION 160
-#define JAVA6_PACKAGE_MINOR_VERSION 1
-
-#define JAVA7_PACKAGE_MAJOR_VERSION 170
-#define JAVA7_PACKAGE_MINOR_VERSION 1
-
-#define JAVA8_PACKAGE_MAJOR_VERSION 171
-#define JAVA8_PACKAGE_MINOR_VERSION 0
-
-// magic number for gzip streams (for processing pack200-gzip data)
-#define GZIP_MAGIC      0x1F8B0800
-#define GZIP_MAGIC_MASK 0xFFFFFF00  // last byte is variable "flg" field
-
-enum {
-    CONSTANT_None               = 0,
-    CONSTANT_Utf8               = 1,
-    CONSTANT_unused             = 2,     /* unused, was Unicode */
-    CONSTANT_Integer            = 3,
-    CONSTANT_Float              = 4,
-    CONSTANT_Long               = 5,
-    CONSTANT_Double             = 6,
-    CONSTANT_Class              = 7,
-    CONSTANT_String             = 8,
-    CONSTANT_Fieldref           = 9,
-    CONSTANT_Methodref          = 10,
-    CONSTANT_InterfaceMethodref = 11,
-    CONSTANT_NameandType        = 12,
-    CONSTANT_unused13           = 13,
-    CONSTANT_unused14           = 14,
-    CONSTANT_MethodHandle       = 15,
-    CONSTANT_MethodType         = 16,
-    CONSTANT_unused17           = 17,
-    CONSTANT_InvokeDynamic      = 18,
-    CONSTANT_Limit              = 19,
-    CONSTANT_Signature          = CONSTANT_unused13,
-    CONSTANT_BootstrapMethod    = CONSTANT_unused17, // used only for InvokeDynamic
-    CONSTANT_All                = 50,                // combined global map
-    CONSTANT_LoadableValue      = 51,                // used for 'KL' and qldc operands
-    CONSTANT_AnyMember          = 52,                // union of refs to field or (interface) method
-    CONSTANT_FieldSpecific      = 53,                // used only for 'KQ' ConstantValue attrs
-    CONSTANT_GroupFirst         = CONSTANT_All,      // start group marker
-    CONSTANT_GroupLimit         = 54,                // end group marker
-
-    // CONSTANT_MethodHandle reference kinds
-    REF_getField         = 1,
-    REF_getStatic        = 2,
-    REF_putField         = 3,
-    REF_putStatic        = 4,
-    REF_invokeVirtual    = 5,
-    REF_invokeStatic     = 6,
-    REF_invokeSpecial    = 7,
-    REF_newInvokeSpecial = 8,
-    REF_invokeInterface  = 9,
-
-    SUBINDEX_BIT = 64,  // combined with CONSTANT_xxx for ixTag
-
-    ACC_STATIC       = 0x0008,
-    ACC_IC_LONG_FORM = (1<<16), //for ic_flags
-
-    CLASS_ATTR_SourceFile                            = 17,
-    CLASS_ATTR_EnclosingMethod                       = 18,
-    CLASS_ATTR_InnerClasses                          = 23,
-    CLASS_ATTR_ClassFile_version                     = 24,
-    CLASS_ATTR_BootstrapMethods                      = 25,
-    FIELD_ATTR_ConstantValue                         = 17,
-    METHOD_ATTR_Code                                 = 17,
-    METHOD_ATTR_Exceptions                           = 18,
-    METHOD_ATTR_RuntimeVisibleParameterAnnotations   = 23,
-    METHOD_ATTR_RuntimeInvisibleParameterAnnotations = 24,
-    METHOD_ATTR_AnnotationDefault                    = 25,
-    METHOD_ATTR_MethodParameters                     = 26,
-    CODE_ATTR_StackMapTable          = 0,
-    CODE_ATTR_LineNumberTable        = 1,
-    CODE_ATTR_LocalVariableTable     = 2,
-    CODE_ATTR_LocalVariableTypeTable = 3,
-    //X_ATTR_Synthetic = 12,  // ACC_SYNTHETIC; not predefined
-    X_ATTR_Signature                   = 19,
-    X_ATTR_Deprecated                  = 20,
-    X_ATTR_RuntimeVisibleAnnotations   = 21,
-    X_ATTR_RuntimeInvisibleAnnotations = 22,
-    X_ATTR_RuntimeVisibleTypeAnnotations   = 27,
-    X_ATTR_RuntimeInvisibleTypeAnnotations = 28,
-    X_ATTR_OVERFLOW                    = 16,
-    X_ATTR_LIMIT_NO_FLAGS_HI           = 32,
-    X_ATTR_LIMIT_FLAGS_HI              = 63,
-
-#define O_ATTR_DO(F) \
-        F(X_ATTR_OVERFLOW,01) \
-          /*(end)*/
-#define X_ATTR_DO(F) \
-        O_ATTR_DO(F) \
-        F(X_ATTR_Signature,Signature) \
-        F(X_ATTR_Deprecated,Deprecated) \
-        F(X_ATTR_RuntimeVisibleAnnotations,RuntimeVisibleAnnotations) \
-        F(X_ATTR_RuntimeInvisibleAnnotations,RuntimeInvisibleAnnotations) \
-        F(X_ATTR_RuntimeVisibleTypeAnnotations,RuntimeVisibleTypeAnnotations) \
-        F(X_ATTR_RuntimeInvisibleTypeAnnotations,RuntimeInvisibleTypeAnnotations) \
-        /*F(X_ATTR_Synthetic,Synthetic)*/ \
-          /*(end)*/
-#define CLASS_ATTR_DO(F) \
-        F(CLASS_ATTR_SourceFile,SourceFile) \
-        F(CLASS_ATTR_InnerClasses,InnerClasses) \
-        F(CLASS_ATTR_EnclosingMethod,EnclosingMethod) \
-        F(CLASS_ATTR_ClassFile_version,02) \
-        F(CLASS_ATTR_BootstrapMethods,BootstrapMethods) \
-          /*(end)*/
-#define FIELD_ATTR_DO(F) \
-        F(FIELD_ATTR_ConstantValue,ConstantValue) \
-          /*(end)*/
-#define METHOD_ATTR_DO(F) \
-        F(METHOD_ATTR_Code,Code) \
-        F(METHOD_ATTR_Exceptions,Exceptions) \
-        F(METHOD_ATTR_RuntimeVisibleParameterAnnotations,RuntimeVisibleParameterAnnotations) \
-        F(METHOD_ATTR_RuntimeInvisibleParameterAnnotations,RuntimeInvisibleParameterAnnotations) \
-        F(METHOD_ATTR_AnnotationDefault,AnnotationDefault) \
-        F(METHOD_ATTR_MethodParameters,MethodParameters) \
-          /*(end)*/
-#define CODE_ATTR_DO(F) \
-        F(CODE_ATTR_StackMapTable,StackMapTable) \
-        F(CODE_ATTR_LineNumberTable,LineNumberTable) \
-        F(CODE_ATTR_LocalVariableTable,LocalVariableTable) \
-        F(CODE_ATTR_LocalVariableTypeTable,LocalVariableTypeTable) \
-          /*(end)*/
-#define ALL_ATTR_DO(F) \
-        X_ATTR_DO(F) \
-        CLASS_ATTR_DO(F) \
-        FIELD_ATTR_DO(F) \
-        METHOD_ATTR_DO(F) \
-        CODE_ATTR_DO(F) \
-          /*(end)*/
-
-    // attribute "context types"
-    ATTR_CONTEXT_CLASS  = 0,
-    ATTR_CONTEXT_FIELD  = 1,
-    ATTR_CONTEXT_METHOD = 2,
-    ATTR_CONTEXT_CODE   = 3,
-    ATTR_CONTEXT_LIMIT  = 4,
-
-    // constants for parsed layouts (stored in band::le_kind)
-    EK_NONE = 0,     // not a layout element
-    EK_INT  = 'I',   // B H I SH etc., also FH etc.
-    EK_BCI  = 'P',   // PH etc.
-    EK_BCID = 'Q',   // POH etc.
-    EK_BCO  = 'O',   // OH etc.
-    EK_REPL = 'N',   // NH[...] etc.
-    EK_REF  = 'R',   // RUH, RUNH, KQH, etc.
-    EK_UN   = 'T',   // TB(...)[...] etc.
-    EK_CASE = 'K',   // (...)[...] etc.
-    EK_CALL = '(',   // (0), (1), etc.
-    EK_CBLE = '[',   // [...][...] etc.
-    NO_BAND_INDEX = -1,
-
-    // File option bits, from LSB in ascending bit position.
-    FO_DEFLATE_HINT           = 1<<0,
-    FO_IS_CLASS_STUB          = 1<<1,
-
-    // Archive option bits, from LSB in ascending bit position:
-    AO_HAVE_SPECIAL_FORMATS   = 1<<0,
-    AO_HAVE_CP_NUMBERS        = 1<<1,
-    AO_HAVE_ALL_CODE_FLAGS    = 1<<2,
-    AO_HAVE_CP_EXTRAS         = 1<<3,
-    AO_HAVE_FILE_HEADERS      = 1<<4,
-    AO_DEFLATE_HINT           = 1<<5,
-    AO_HAVE_FILE_MODTIME      = 1<<6,
-    AO_HAVE_FILE_OPTIONS      = 1<<7,
-    AO_HAVE_FILE_SIZE_HI      = 1<<8,
-    AO_HAVE_CLASS_FLAGS_HI    = 1<<9,
-    AO_HAVE_FIELD_FLAGS_HI    = 1<<10,
-    AO_HAVE_METHOD_FLAGS_HI   = 1<<11,
-    AO_HAVE_CODE_FLAGS_HI     = 1<<12,
-    AO_UNUSED_MBZ             = (-1)<<13, // options bits reserved for future use.
-
-#define ARCHIVE_BIT_DO(F) \
-         F(AO_HAVE_SPECIAL_FORMATS) \
-         F(AO_HAVE_CP_NUMBERS) \
-         F(AO_HAVE_ALL_CODE_FLAGS) \
-         F(AO_HAVE_CP_EXTRAS) \
-         F(AO_HAVE_FILE_HEADERS) \
-         F(AO_DEFLATE_HINT) \
-         F(AO_HAVE_FILE_MODTIME) \
-         F(AO_HAVE_FILE_OPTIONS) \
-         F(AO_HAVE_FILE_SIZE_HI) \
-         F(AO_HAVE_CLASS_FLAGS_HI) \
-         F(AO_HAVE_FIELD_FLAGS_HI) \
-         F(AO_HAVE_METHOD_FLAGS_HI) \
-         F(AO_HAVE_CODE_FLAGS_HI) \
-          /*(end)*/
-
-    // Constants for decoding attribute definition header bytes.
-    ADH_CONTEXT_MASK   = 0x3,  // (hdr & ADH_CONTEXT_MASK)
-    ADH_BIT_SHIFT      = 0x2,  // (hdr >> ADH_BIT_SHIFT)
-    ADH_BIT_IS_LSB     = 1,    // (hdr >> ADH_BIT_SHIFT) - ADH_BIT_IS_LSB
-#define ADH_BYTE(context, index) \
-        ((((index) + ADH_BIT_IS_LSB)<<ADH_BIT_SHIFT) + (context))
-#define ADH_BYTE_CONTEXT(adhb) \
-        ((adhb) & ADH_CONTEXT_MASK)
-#define ADH_BYTE_INDEX(adhb) \
-        (((adhb) >> ADH_BIT_SHIFT) - ADH_BIT_IS_LSB)
-
-    NO_MODTIME = 0,  // null modtime value
-
-    // meta-coding
-    _meta_default   = 0,
-    _meta_canon_min = 1,
-    _meta_canon_max = 115,
-    _meta_arb       = 116,
-    _meta_run       = 117,
-    _meta_pop       = 141,
-    _meta_limit     = 189,
-    _meta_error     = 255,
-
-    _xxx_1_end
-};
-
-// Bytecodes.
-
-enum {
-  bc_nop                  =   0, // 0x00
-  bc_aconst_null          =   1, // 0x01
-  bc_iconst_m1            =   2, // 0x02
-  bc_iconst_0             =   3, // 0x03
-  bc_iconst_1             =   4, // 0x04
-  bc_iconst_2             =   5, // 0x05
-  bc_iconst_3             =   6, // 0x06
-  bc_iconst_4             =   7, // 0x07
-  bc_iconst_5             =   8, // 0x08
-  bc_lconst_0             =   9, // 0x09
-  bc_lconst_1             =  10, // 0x0a
-  bc_fconst_0             =  11, // 0x0b
-  bc_fconst_1             =  12, // 0x0c
-  bc_fconst_2             =  13, // 0x0d
-  bc_dconst_0             =  14, // 0x0e
-  bc_dconst_1             =  15, // 0x0f
-  bc_bipush               =  16, // 0x10
-  bc_sipush               =  17, // 0x11
-  bc_ldc                  =  18, // 0x12
-  bc_ldc_w                =  19, // 0x13
-  bc_ldc2_w               =  20, // 0x14
-  bc_iload                =  21, // 0x15
-  bc_lload                =  22, // 0x16
-  bc_fload                =  23, // 0x17
-  bc_dload                =  24, // 0x18
-  bc_aload                =  25, // 0x19
-  bc_iload_0              =  26, // 0x1a
-  bc_iload_1              =  27, // 0x1b
-  bc_iload_2              =  28, // 0x1c
-  bc_iload_3              =  29, // 0x1d
-  bc_lload_0              =  30, // 0x1e
-  bc_lload_1              =  31, // 0x1f
-  bc_lload_2              =  32, // 0x20
-  bc_lload_3              =  33, // 0x21
-  bc_fload_0              =  34, // 0x22
-  bc_fload_1              =  35, // 0x23
-  bc_fload_2              =  36, // 0x24
-  bc_fload_3              =  37, // 0x25
-  bc_dload_0              =  38, // 0x26
-  bc_dload_1              =  39, // 0x27
-  bc_dload_2              =  40, // 0x28
-  bc_dload_3              =  41, // 0x29
-  bc_aload_0              =  42, // 0x2a
-  bc_aload_1              =  43, // 0x2b
-  bc_aload_2              =  44, // 0x2c
-  bc_aload_3              =  45, // 0x2d
-  bc_iaload               =  46, // 0x2e
-  bc_laload               =  47, // 0x2f
-  bc_faload               =  48, // 0x30
-  bc_daload               =  49, // 0x31
-  bc_aaload               =  50, // 0x32
-  bc_baload               =  51, // 0x33
-  bc_caload               =  52, // 0x34
-  bc_saload               =  53, // 0x35
-  bc_istore               =  54, // 0x36
-  bc_lstore               =  55, // 0x37
-  bc_fstore               =  56, // 0x38
-  bc_dstore               =  57, // 0x39
-  bc_astore               =  58, // 0x3a
-  bc_istore_0             =  59, // 0x3b
-  bc_istore_1             =  60, // 0x3c
-  bc_istore_2             =  61, // 0x3d
-  bc_istore_3             =  62, // 0x3e
-  bc_lstore_0             =  63, // 0x3f
-  bc_lstore_1             =  64, // 0x40
-  bc_lstore_2             =  65, // 0x41
-  bc_lstore_3             =  66, // 0x42
-  bc_fstore_0             =  67, // 0x43
-  bc_fstore_1             =  68, // 0x44
-  bc_fstore_2             =  69, // 0x45
-  bc_fstore_3             =  70, // 0x46
-  bc_dstore_0             =  71, // 0x47
-  bc_dstore_1             =  72, // 0x48
-  bc_dstore_2             =  73, // 0x49
-  bc_dstore_3             =  74, // 0x4a
-  bc_astore_0             =  75, // 0x4b
-  bc_astore_1             =  76, // 0x4c
-  bc_astore_2             =  77, // 0x4d
-  bc_astore_3             =  78, // 0x4e
-  bc_iastore              =  79, // 0x4f
-  bc_lastore              =  80, // 0x50
-  bc_fastore              =  81, // 0x51
-  bc_dastore              =  82, // 0x52
-  bc_aastore              =  83, // 0x53
-  bc_bastore              =  84, // 0x54
-  bc_castore              =  85, // 0x55
-  bc_sastore              =  86, // 0x56
-  bc_pop                  =  87, // 0x57
-  bc_pop2                 =  88, // 0x58
-  bc_dup                  =  89, // 0x59
-  bc_dup_x1               =  90, // 0x5a
-  bc_dup_x2               =  91, // 0x5b
-  bc_dup2                 =  92, // 0x5c
-  bc_dup2_x1              =  93, // 0x5d
-  bc_dup2_x2              =  94, // 0x5e
-  bc_swap                 =  95, // 0x5f
-  bc_iadd                 =  96, // 0x60
-  bc_ladd                 =  97, // 0x61
-  bc_fadd                 =  98, // 0x62
-  bc_dadd                 =  99, // 0x63
-  bc_isub                 = 100, // 0x64
-  bc_lsub                 = 101, // 0x65
-  bc_fsub                 = 102, // 0x66
-  bc_dsub                 = 103, // 0x67
-  bc_imul                 = 104, // 0x68
-  bc_lmul                 = 105, // 0x69
-  bc_fmul                 = 106, // 0x6a
-  bc_dmul                 = 107, // 0x6b
-  bc_idiv                 = 108, // 0x6c
-  bc_ldiv                 = 109, // 0x6d
-  bc_fdiv                 = 110, // 0x6e
-  bc_ddiv                 = 111, // 0x6f
-  bc_irem                 = 112, // 0x70
-  bc_lrem                 = 113, // 0x71
-  bc_frem                 = 114, // 0x72
-  bc_drem                 = 115, // 0x73
-  bc_ineg                 = 116, // 0x74
-  bc_lneg                 = 117, // 0x75
-  bc_fneg                 = 118, // 0x76
-  bc_dneg                 = 119, // 0x77
-  bc_ishl                 = 120, // 0x78
-  bc_lshl                 = 121, // 0x79
-  bc_ishr                 = 122, // 0x7a
-  bc_lshr                 = 123, // 0x7b
-  bc_iushr                = 124, // 0x7c
-  bc_lushr                = 125, // 0x7d
-  bc_iand                 = 126, // 0x7e
-  bc_land                 = 127, // 0x7f
-  bc_ior                  = 128, // 0x80
-  bc_lor                  = 129, // 0x81
-  bc_ixor                 = 130, // 0x82
-  bc_lxor                 = 131, // 0x83
-  bc_iinc                 = 132, // 0x84
-  bc_i2l                  = 133, // 0x85
-  bc_i2f                  = 134, // 0x86
-  bc_i2d                  = 135, // 0x87
-  bc_l2i                  = 136, // 0x88
-  bc_l2f                  = 137, // 0x89
-  bc_l2d                  = 138, // 0x8a
-  bc_f2i                  = 139, // 0x8b
-  bc_f2l                  = 140, // 0x8c
-  bc_f2d                  = 141, // 0x8d
-  bc_d2i                  = 142, // 0x8e
-  bc_d2l                  = 143, // 0x8f
-  bc_d2f                  = 144, // 0x90
-  bc_i2b                  = 145, // 0x91
-  bc_i2c                  = 146, // 0x92
-  bc_i2s                  = 147, // 0x93
-  bc_lcmp                 = 148, // 0x94
-  bc_fcmpl                = 149, // 0x95
-  bc_fcmpg                = 150, // 0x96
-  bc_dcmpl                = 151, // 0x97
-  bc_dcmpg                = 152, // 0x98
-  bc_ifeq                 = 153, // 0x99
-  bc_ifne                 = 154, // 0x9a
-  bc_iflt                 = 155, // 0x9b
-  bc_ifge                 = 156, // 0x9c
-  bc_ifgt                 = 157, // 0x9d
-  bc_ifle                 = 158, // 0x9e
-  bc_if_icmpeq            = 159, // 0x9f
-  bc_if_icmpne            = 160, // 0xa0
-  bc_if_icmplt            = 161, // 0xa1
-  bc_if_icmpge            = 162, // 0xa2
-  bc_if_icmpgt            = 163, // 0xa3
-  bc_if_icmple            = 164, // 0xa4
-  bc_if_acmpeq            = 165, // 0xa5
-  bc_if_acmpne            = 166, // 0xa6
-  bc_goto                 = 167, // 0xa7
-  bc_jsr                  = 168, // 0xa8
-  bc_ret                  = 169, // 0xa9
-  bc_tableswitch          = 170, // 0xaa
-  bc_lookupswitch         = 171, // 0xab
-  bc_ireturn              = 172, // 0xac
-  bc_lreturn              = 173, // 0xad
-  bc_freturn              = 174, // 0xae
-  bc_dreturn              = 175, // 0xaf
-  bc_areturn              = 176, // 0xb0
-  bc_return               = 177, // 0xb1
-  bc_getstatic            = 178, // 0xb2
-  bc_putstatic            = 179, // 0xb3
-  bc_getfield             = 180, // 0xb4
-  bc_putfield             = 181, // 0xb5
-  bc_invokevirtual        = 182, // 0xb6
-  bc_invokespecial        = 183, // 0xb7
-  bc_invokestatic         = 184, // 0xb8
-  bc_invokeinterface      = 185, // 0xb9
-  bc_invokedynamic        = 186, // 0xba
-  bc_new                  = 187, // 0xbb
-  bc_newarray             = 188, // 0xbc
-  bc_anewarray            = 189, // 0xbd
-  bc_arraylength          = 190, // 0xbe
-  bc_athrow               = 191, // 0xbf
-  bc_checkcast            = 192, // 0xc0
-  bc_instanceof           = 193, // 0xc1
-  bc_monitorenter         = 194, // 0xc2
-  bc_monitorexit          = 195, // 0xc3
-  bc_wide                 = 196, // 0xc4
-  bc_multianewarray       = 197, // 0xc5
-  bc_ifnull               = 198, // 0xc6
-  bc_ifnonnull            = 199, // 0xc7
-  bc_goto_w               = 200, // 0xc8
-  bc_jsr_w                = 201, // 0xc9
-  bc_bytecode_limit       = 202  // 0xca
-};
-
-enum {
-  bc_end_marker = 255,
-  bc_byte_escape = 254,
-  bc_ref_escape = 253,
-
-  _first_linker_op = bc_getstatic,
-  _last_linker_op  = bc_invokestatic,
-  _num_linker_ops  = (_last_linker_op - _first_linker_op) + 1,
-  _self_linker_op  = bc_bytecode_limit,
-  _self_linker_aload_flag = 1*_num_linker_ops,
-  _self_linker_super_flag = 2*_num_linker_ops,
-  _self_linker_limit = _self_linker_op + 4*_num_linker_ops,
-
-  _invokeinit_op = _self_linker_limit,
-  _invokeinit_self_option = 0,
-  _invokeinit_super_option = 1,
-  _invokeinit_new_option = 2,
-  _invokeinit_limit = _invokeinit_op+3,
-
-  _xldc_op = _invokeinit_limit,
-  bc_sldc = bc_ldc,      // previously named bc_aldc
-  bc_cldc = _xldc_op+0,
-  bc_ildc = _xldc_op+1,
-  bc_fldc = _xldc_op+2,
-  bc_sldc_w = bc_ldc_w,  // previously named bc_aldc_w
-  bc_cldc_w = _xldc_op+3,
-  bc_ildc_w = _xldc_op+4,
-  bc_fldc_w = _xldc_op+5,
-  bc_lldc2_w = bc_ldc2_w,
-  bc_dldc2_w = _xldc_op+6,
-  // anything other primitive, string, or class must be handled with qldc:
-  bc_qldc    = _xldc_op+7,
-  bc_qldc_w  = _xldc_op+8,
-  _xldc_limit = _xldc_op+9,
-  _invoke_int_op = _xldc_limit,
-  _invokespecial_int = _invoke_int_op+0,
-  _invokestatic_int = _invoke_int_op+1,
-  _invoke_int_limit =  _invoke_int_op+2,
-  _xxx_3_end
-};
--- a/jdk/src/jdk.runtime/share/native/common-unpack/defines.h	Fri Mar 06 13:30:49 2015 +0300
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,170 +0,0 @@
-/*
- * Copyright (c) 2001, 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.
- */
-
-// random definitions
-
-#ifdef _MSC_VER
-#include <windows.h>
-#include <winuser.h>
-#else
-#include <unistd.h>
-#endif
-
-#ifndef NO_ZLIB
-#include <zconf.h>
-#endif
-
-#ifndef FULL
-#define FULL 1 /* Adds <500 bytes to the zipped final product. */
-#endif
-
-#if FULL  // define this if you want debugging and/or compile-time attributes
-#define IF_FULL(x) x
-#else
-#define IF_FULL(x) /*x*/
-#endif
-
-#ifdef PRODUCT
-#define IF_PRODUCT(xxx) xxx
-#define NOT_PRODUCT(xxx)
-#define assert(p)
-#define PRINTCR(args)
-#define VERSION_STRING "%s version %s\n"
-#else
-#define IF_PRODUCT(xxx)
-#define NOT_PRODUCT(xxx) xxx
-#define assert(p) ((p) || assert_failed(#p))
-#define PRINTCR(args)  u->verbose && u->printcr_if_verbose args
-#define VERSION_STRING "%s version non-product %s\n"
-extern "C" void breakpoint();
-extern int assert_failed(const char*);
-#define BREAK (breakpoint())
-#endif
-
-// Build-time control of some C++ inlining.
-// To make a slightly faster smaller binary, say "CC -Dmaybe_inline=inline"
-#ifndef maybe_inline
-#define maybe_inline /*inline*/
-#endif
-// By marking larger member functions inline, we remove external linkage.
-#ifndef local_inline
-#define local_inline inline
-#endif
-
-// Error messages that we have
-#define ERROR_ENOMEM    "Native allocation failed"
-#define ERROR_FORMAT    "Corrupted pack file"
-#define ERROR_RESOURCE  "Cannot extract resource file"
-#define ERROR_OVERFLOW  "Internal buffer overflow"
-#define ERROR_INTERNAL  "Internal error"
-#define ERROR_INIT      "cannot init class members"
-
-#define LOGFILE_STDOUT "-"
-#define LOGFILE_STDERR ""
-
-#define lengthof(array) (sizeof(array)/sizeof(array[0]))
-
-#define NEW(T, n)    (T*) must_malloc((int)(scale_size(n, sizeof(T))))
-#define U_NEW(T, n)  (T*) u->alloc(scale_size(n, sizeof(T)))
-#define T_NEW(T, n)  (T*) u->temp_alloc(scale_size(n, sizeof(T)))
-
-
-// bytes and byte arrays
-
-typedef unsigned int uint;
-#if defined(NO_ZLIB)
-#ifdef _LP64
-typedef unsigned int uLong; // Historical zlib, should be 32-bit.
-#else
-typedef unsigned long uLong;
-#endif
-#endif
-#ifdef _MSC_VER
-typedef LONGLONG        jlong;
-typedef DWORDLONG       julong;
-#define MKDIR(dir)      mkdir(dir)
-#define getpid()        _getpid()
-#define PATH_MAX        MAX_PATH
-#define dup2(a,b)       _dup2(a,b)
-#define strcasecmp(s1, s2) _stricmp(s1,s2)
-#define tempname        _tempname
-#define sleep           Sleep
-#define snprintf        _snprintf
-#else
-typedef signed char byte;
-#ifdef _LP64
-typedef long jlong;
-typedef long unsigned julong;
-#else
-typedef long long jlong;
-typedef long long unsigned julong;
-#endif
-#define MKDIR(dir) mkdir(dir, 0777);
-#endif
-
-#ifdef OLDCC
-typedef int bool;
-enum { false, true };
-#endif
-
-#define null (0)
-
-/* Must cast to void *, then size_t, then int. */
-#define ptrlowbits(x)  ((int)(size_t)(void*)(x))
-
-/* Back and forth from jlong to pointer */
-#define ptr2jlong(x)  ((jlong)(size_t)(void*)(x))
-#define jlong2ptr(x)  ((void*)(size_t)(x))
-
-// Keys used by Java:
-#define UNPACK_DEFLATE_HINT             "unpack.deflate.hint"
-
-#define COM_PREFIX                      "com.sun.java.util.jar.pack."
-#define UNPACK_MODIFICATION_TIME        COM_PREFIX"unpack.modification.time"
-#define DEBUG_VERBOSE                   COM_PREFIX"verbose"
-
-#define ZIP_ARCHIVE_MARKER_COMMENT      "PACK200"
-
-// The following are not known to the Java classes:
-#define UNPACK_LOG_FILE                 COM_PREFIX"unpack.log.file"
-#define UNPACK_REMOVE_PACKFILE          COM_PREFIX"unpack.remove.packfile"
-
-
-// Called from unpacker layers
-#define _CHECK_DO(t,x)          { if (t) {x;} }
-
-#define CHECK                   _CHECK_DO(aborting(), return)
-#define CHECK_(y)               _CHECK_DO(aborting(), return y)
-#define CHECK_0                 _CHECK_DO(aborting(), return 0)
-
-#define CHECK_COUNT(t)          if (t < 0){abort("bad value count");} CHECK
-
-#define STR_TRUE   "true"
-#define STR_FALSE  "false"
-
-#define STR_TF(x)  ((x) ?  STR_TRUE : STR_FALSE)
-#define BOOL_TF(x) (((x) != null && strcmp((x),STR_TRUE) == 0) ? true : false)
-
-#define DEFAULT_ARCHIVE_MODTIME 1060000000 // Aug 04, 2003 5:26 PM PDT
--- a/jdk/src/jdk.runtime/share/native/common-unpack/unpack.cpp	Fri Mar 06 13:30:49 2015 +0300
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,5215 +0,0 @@
-/*
- * Copyright (c) 2001, 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.
- */
-
-// -*- C++ -*-
-// Program for unpacking specially compressed Java packages.
-// John R. Rose
-
-/*
- * When compiling for a 64bit LP64 system (longs and pointers being 64bits),
- *    the printf format %ld is correct and use of %lld will cause warning
- *    errors from some compilers (gcc/g++).
- * _LP64 can be explicitly set (used on Linux).
- * Should be checking for the Visual C++ since the _LP64 is set on the 64-bit
- * systems but the correct format prefix for 64-bit integers is ll.
- * Solaris compilers will define __sparcv9 or __x86_64 on 64bit compilations.
- */
-#if !defined (_MSC_VER) && \
-    (defined(_LP64) || defined(__sparcv9) || defined(__x86_64))
-  #define LONG_LONG_FORMAT "%ld"
-  #define LONG_LONG_HEX_FORMAT "%lx"
-#else
-  #define LONG_LONG_FORMAT "%lld"
-  #define LONG_LONG_HEX_FORMAT "%016llx"
-#endif
-
-#include <sys/types.h>
-
-#include <stdio.h>
-#include <string.h>
-#include <stdlib.h>
-#include <stdarg.h>
-
-#include <limits.h>
-#include <time.h>
-
-
-
-
-#include "defines.h"
-#include "bytes.h"
-#include "utils.h"
-#include "coding.h"
-#include "bands.h"
-
-#include "constants.h"
-
-#include "zip.h"
-
-#include "unpack.h"
-
-
-// tags, in canonical order:
-static const byte TAGS_IN_ORDER[] = {
-  CONSTANT_Utf8,
-  CONSTANT_Integer,
-  CONSTANT_Float,
-  CONSTANT_Long,
-  CONSTANT_Double,
-  CONSTANT_String,
-  CONSTANT_Class,
-  CONSTANT_Signature,
-  CONSTANT_NameandType,
-  CONSTANT_Fieldref,
-  CONSTANT_Methodref,
-  CONSTANT_InterfaceMethodref,
-  // constants defined as of JDK 7
-  CONSTANT_MethodHandle,
-  CONSTANT_MethodType,
-  CONSTANT_BootstrapMethod,
-  CONSTANT_InvokeDynamic
-};
-#define N_TAGS_IN_ORDER (sizeof TAGS_IN_ORDER)
-
-#ifndef PRODUCT
-static const char* TAG_NAME[] = {
-  "*None",
-  "Utf8",
-  "*Unicode",
-  "Integer",
-  "Float",
-  "Long",
-  "Double",
-  "Class",
-  "String",
-  "Fieldref",
-  "Methodref",
-  "InterfaceMethodref",
-  "NameandType",
-  "*Signature",
-  "unused14",
-  "MethodHandle",
-  "MethodType",
-  "*BootstrapMethod",
-  "InvokeDynamic",
-  0
-};
-
-static const char* ATTR_CONTEXT_NAME[] = {  // match ATTR_CONTEXT_NAME, etc.
-  "class", "field", "method", "code"
-};
-
-#else
-
-#define ATTR_CONTEXT_NAME ((const char**)null)
-
-#endif
-
-// Note that REQUESTED_LDC comes first, then the normal REQUESTED,
-// in the regular constant pool.
-enum { REQUESTED_NONE = -1,
-       // The codes below REQUESTED_NONE are in constant pool output order,
-       // for the sake of outputEntry_cmp:
-       REQUESTED_LDC = -99, REQUESTED
-};
-
-#define NO_INORD ((uint)-1)
-
-struct entry {
-  byte tag;
-
-  #if 0
-  byte bits;
-  enum {
-    //EB_EXTRA = 1,
-    EB_SUPER = 2
-  };
-  #endif
-  unsigned short nrefs;  // pack w/ tag
-
-  int  outputIndex;
-  uint inord;   // &cp.entries[cp.tag_base[this->tag]+this->inord] == this
-
-  entry* *refs;
-
-  // put last to pack best
-  union {
-    bytes b;
-    int i;
-    jlong l;
-  } value;
-
-  void requestOutputIndex(cpool& cp, int req = REQUESTED);
-  int getOutputIndex() {
-    assert(outputIndex > REQUESTED_NONE);
-    return outputIndex;
-  }
-
-  entry* ref(int refnum) {
-    assert((uint)refnum < nrefs);
-    return refs[refnum];
-  }
-
-  const char* utf8String() {
-    assert(tagMatches(CONSTANT_Utf8));
-    assert(value.b.len == strlen((const char*)value.b.ptr));
-    return (const char*)value.b.ptr;
-  }
-
-  entry* className() {
-    assert(tagMatches(CONSTANT_Class));
-    return ref(0);
-  }
-
-  entry* memberClass() {
-    assert(tagMatches(CONSTANT_AnyMember));
-    return ref(0);
-  }
-
-  entry* memberDescr() {
-    assert(tagMatches(CONSTANT_AnyMember));
-    return ref(1);
-  }
-
-  entry* descrName() {
-    assert(tagMatches(CONSTANT_NameandType));
-    return ref(0);
-  }
-
-  entry* descrType() {
-    assert(tagMatches(CONSTANT_NameandType));
-    return ref(1);
-  }
-
-  int typeSize();
-
-  bytes& asUtf8();
-  int    asInteger() { assert(tag == CONSTANT_Integer); return value.i; }
-
-  bool isUtf8(bytes& b) { return tagMatches(CONSTANT_Utf8) && value.b.equals(b); }
-
-  bool isDoubleWord() { return tag == CONSTANT_Double || tag == CONSTANT_Long; }
-
-  bool tagMatches(byte tag2) {
-    return (tag2 == tag)
-      || (tag2 == CONSTANT_Utf8 && tag == CONSTANT_Signature)
-      #ifndef PRODUCT
-      || (tag2 == CONSTANT_FieldSpecific
-          && tag >= CONSTANT_Integer && tag <= CONSTANT_String && tag != CONSTANT_Class)
-      || (tag2 == CONSTANT_AnyMember
-          && tag >= CONSTANT_Fieldref && tag <= CONSTANT_InterfaceMethodref)
-      #endif
-      ;
-  }
-
-#ifdef PRODUCT
-  char* string() { return 0; }
-#else
-  char* string();  // see far below
-#endif
-};
-
-entry* cpindex::get(uint i) {
-  if (i >= len)
-    return null;
-  else if (base1 != null)
-    // primary index
-    return &base1[i];
-  else
-    // secondary index
-    return base2[i];
-}
-
-inline bytes& entry::asUtf8() {
-  assert(tagMatches(CONSTANT_Utf8));
-  return value.b;
-}
-
-int entry::typeSize() {
-  assert(tagMatches(CONSTANT_Utf8));
-  const char* sigp = (char*) value.b.ptr;
-  switch (*sigp) {
-  case '(': sigp++; break;  // skip opening '('
-  case 'D':
-  case 'J': return 2; // double field
-  default:  return 1; // field
-  }
-  int siglen = 0;
-  for (;;) {
-    int ch = *sigp++;
-    switch (ch) {
-    case 'D': case 'J':
-      siglen += 1;
-      break;
-    case '[':
-      // Skip rest of array info.
-      while (ch == '[') { ch = *sigp++; }
-      if (ch != 'L')  break;
-      // else fall through
-    case 'L':
-      sigp = strchr(sigp, ';');
-      if (sigp == null) {
-          unpack_abort("bad data");
-          return 0;
-      }
-      sigp += 1;
-      break;
-    case ')':  // closing ')'
-      return siglen;
-    }
-    siglen += 1;
-  }
-}
-
-inline cpindex* cpool::getFieldIndex(entry* classRef) {
-  if (classRef == NULL) { abort("missing class reference"); return NULL; }
-  assert(classRef->tagMatches(CONSTANT_Class));
-  assert((uint)classRef->inord < (uint)tag_count[CONSTANT_Class]);
-  return &member_indexes[classRef->inord*2+0];
-}
-inline cpindex* cpool::getMethodIndex(entry* classRef) {
-  if (classRef == NULL) { abort("missing class reference"); return NULL; }
-  assert(classRef->tagMatches(CONSTANT_Class));
-  assert((uint)classRef->inord < (uint)tag_count[CONSTANT_Class]);
-  return &member_indexes[classRef->inord*2+1];
-}
-
-struct inner_class {
-  entry* inner;
-  entry* outer;
-  entry* name;
-  int    flags;
-  inner_class* next_sibling;
-  bool   requested;
-};
-
-// Here is where everything gets deallocated:
-void unpacker::free() {
-  int i;
-  assert(jniobj == null); // caller resp.
-  assert(infileptr == null);  // caller resp.
-  if (jarout != null)  jarout->reset();
-  if (gzin != null)    { gzin->free(); gzin = null; }
-  if (free_input)  input.free();
-  // free everybody ever allocated with U_NEW or (recently) with T_NEW
-  assert(smallbuf.base()  == null || mallocs.contains(smallbuf.base()));
-  assert(tsmallbuf.base() == null || tmallocs.contains(tsmallbuf.base()));
-  mallocs.freeAll();
-  tmallocs.freeAll();
-  smallbuf.init();
-  tsmallbuf.init();
-  bcimap.free();
-  class_fixup_type.free();
-  class_fixup_offset.free();
-  class_fixup_ref.free();
-  code_fixup_type.free();
-  code_fixup_offset.free();
-  code_fixup_source.free();
-  requested_ics.free();
-  cp.requested_bsms.free();
-  cur_classfile_head.free();
-  cur_classfile_tail.free();
-  for (i = 0; i < ATTR_CONTEXT_LIMIT; i++)
-    attr_defs[i].free();
-
-  // free CP state
-  cp.outputEntries.free();
-  for (i = 0; i < CONSTANT_Limit; i++)
-    cp.tag_extras[i].free();
-}
-
-// input handling
-// Attempts to advance rplimit so that (rplimit-rp) is at least 'more'.
-// Will eagerly read ahead by larger chunks, if possible.
-// Returns false if (rplimit-rp) is not at least 'more',
-// unless rplimit hits input.limit().
-bool unpacker::ensure_input(jlong more) {
-  julong want = more - input_remaining();
-  if ((jlong)want <= 0)          return true;  // it's already in the buffer
-  if (rplimit == input.limit())  return true;  // not expecting any more
-
-  if (read_input_fn == null) {
-    // assume it is already all there
-    bytes_read += input.limit() - rplimit;
-    rplimit = input.limit();
-    return true;
-  }
-  CHECK_0;
-
-  julong remaining = (input.limit() - rplimit);  // how much left to read?
-  byte* rpgoal = (want >= remaining)? input.limit(): rplimit + (size_t)want;
-  enum { CHUNK_SIZE = (1<<14) };
-  julong fetch = want;
-  if (fetch < CHUNK_SIZE)
-    fetch = CHUNK_SIZE;
-  if (fetch > remaining*3/4)
-    fetch = remaining;
-  // Try to fetch at least "more" bytes.
-  while ((jlong)fetch > 0) {
-    jlong nr = (*read_input_fn)(this, rplimit, fetch, remaining);
-    if (nr <= 0) {
-      return (rplimit >= rpgoal);
-    }
-    remaining -= nr;
-    rplimit += nr;
-    fetch -= nr;
-    bytes_read += nr;
-    assert(remaining == (julong)(input.limit() - rplimit));
-  }
-  return true;
-}
-
-// output handling
-
-fillbytes* unpacker::close_output(fillbytes* which) {
-  assert(wp != null);
-  if (which == null) {
-    if (wpbase == cur_classfile_head.base()) {
-      which = &cur_classfile_head;
-    } else {
-      which = &cur_classfile_tail;
-    }
-  }
-  assert(wpbase  == which->base());
-  assert(wplimit == which->end());
-  which->setLimit(wp);
-  wp      = null;
-  wplimit = null;
-  //wpbase = null;
-  return which;
-}
-
-//maybe_inline
-void unpacker::ensure_put_space(size_t size) {
-  if (wp + size <= wplimit)  return;
-  // Determine which segment needs expanding.
-  fillbytes* which = close_output();
-  byte* wp0 = which->grow(size);
-  wpbase  = which->base();
-  wplimit = which->end();
-  wp = wp0;
-}
-
-maybe_inline
-byte* unpacker::put_space(size_t size) {
-  byte* wp0 = wp;
-  byte* wp1 = wp0 + size;
-  if (wp1 > wplimit) {
-    ensure_put_space(size);
-    wp0 = wp;
-    wp1 = wp0 + size;
-  }
-  wp = wp1;
-  return wp0;
-}
-
-maybe_inline
-void unpacker::putu2_at(byte* wp, int n) {
-  if (n != (unsigned short)n) {
-    unpack_abort(ERROR_OVERFLOW);
-    return;
-  }
-  wp[0] = (n) >> 8;
-  wp[1] = (n) >> 0;
-}
-
-maybe_inline
-void unpacker::putu4_at(byte* wp, int n) {
-  wp[0] = (n) >> 24;
-  wp[1] = (n) >> 16;
-  wp[2] = (n) >> 8;
-  wp[3] = (n) >> 0;
-}
-
-maybe_inline
-void unpacker::putu8_at(byte* wp, jlong n) {
-  putu4_at(wp+0, (int)((julong)n >> 32));
-  putu4_at(wp+4, (int)((julong)n >> 0));
-}
-
-maybe_inline
-void unpacker::putu2(int n) {
-  putu2_at(put_space(2), n);
-}
-
-maybe_inline
-void unpacker::putu4(int n) {
-  putu4_at(put_space(4), n);
-}
-
-maybe_inline
-void unpacker::putu8(jlong n) {
-  putu8_at(put_space(8), n);
-}
-
-maybe_inline
-int unpacker::putref_index(entry* e, int size) {
-  if (e == null)
-    return 0;
-  else if (e->outputIndex > REQUESTED_NONE)
-    return e->outputIndex;
-  else if (e->tag == CONSTANT_Signature)
-    return putref_index(e->ref(0), size);
-  else {
-    e->requestOutputIndex(cp, (size == 1 ? REQUESTED_LDC : REQUESTED));
-    // Later on we'll fix the bits.
-    class_fixup_type.addByte(size);
-    class_fixup_offset.add((int)wpoffset());
-    class_fixup_ref.add(e);
-#ifdef PRODUCT
-    return 0;
-#else
-    return 0x20+size;  // 0x22 is easy to eyeball
-#endif
-  }
-}
-
-maybe_inline
-void unpacker::putref(entry* e) {
-  int oidx = putref_index(e, 2);
-  putu2_at(put_space(2), oidx);
-}
-
-maybe_inline
-void unpacker::putu1ref(entry* e) {
-  int oidx = putref_index(e, 1);
-  putu1_at(put_space(1), oidx);
-}
-
-
-static int total_cp_size[] = {0, 0};
-static int largest_cp_ref[] = {0, 0};
-static int hash_probes[] = {0, 0};
-
-// Allocation of small and large blocks.
-
-enum { CHUNK = (1 << 14), SMALL = (1 << 9) };
-
-// Call malloc.  Try to combine small blocks and free much later.
-void* unpacker::alloc_heap(size_t size, bool smallOK, bool temp) {
-  if (!smallOK || size > SMALL) {
-    void* res = must_malloc((int)size);
-    (temp ? &tmallocs : &mallocs)->add(res);
-    return res;
-  }
-  fillbytes& xsmallbuf = *(temp ? &tsmallbuf : &smallbuf);
-  if (!xsmallbuf.canAppend(size+1)) {
-    xsmallbuf.init(CHUNK);
-    (temp ? &tmallocs : &mallocs)->add(xsmallbuf.base());
-  }
-  int growBy = (int)size;
-  growBy += -growBy & 7;  // round up mod 8
-  return xsmallbuf.grow(growBy);
-}
-
-maybe_inline
-void unpacker::saveTo(bytes& b, byte* ptr, size_t len) {
-  b.ptr = U_NEW(byte, add_size(len,1));
-  if (aborting()) {
-    b.len = 0;
-    return;
-  }
-  b.len = len;
-  b.copyFrom(ptr, len);
-}
-
-bool testBit(int archive_options, int bitMask) {
-    return (archive_options & bitMask) != 0;
-}
-
-// Read up through band_headers.
-// Do the archive_size dance to set the size of the input mega-buffer.
-void unpacker::read_file_header() {
-  // Read file header to determine file type and total size.
-  enum {
-    MAGIC_BYTES = 4,
-    AH_LENGTH_0 = 3,  // archive_header_0 = {minver, majver, options}
-    AH_LENGTH_MIN = 15, // observed in spec {header_0[3], cp_counts[8], class_counts[4]}
-    AH_LENGTH_0_MAX = AH_LENGTH_0 + 1,  // options might have 2 bytes
-    AH_LENGTH   = 30, //maximum archive header length (w/ all fields)
-    // Length contributions from optional header fields:
-    AH_LENGTH_S = 2, // archive_header_S = optional {size_hi, size_lo}
-    AH_ARCHIVE_SIZE_HI = 0, // offset in archive_header_S
-    AH_ARCHIVE_SIZE_LO = 1, // offset in archive_header_S
-    AH_FILE_HEADER_LEN = 5, // file_counts = {{size_hi, size_lo), next, modtile, files}
-    AH_SPECIAL_FORMAT_LEN = 2, // special_count = {layouts, band_headers}
-    AH_CP_NUMBER_LEN = 4,      // cp_number_counts = {int, float, long, double}
-    AH_CP_EXTRA_LEN = 4,        // cp_attr_counts = {MH, MT, InDy, BSM}
-    ARCHIVE_SIZE_MIN = AH_LENGTH_MIN - AH_LENGTH_0 - AH_LENGTH_S,
-    FIRST_READ  = MAGIC_BYTES + AH_LENGTH_MIN
-  };
-
-  assert(AH_LENGTH_MIN    == 15); // # of UNSIGNED5 fields required after archive_magic
-  // An absolute minimum null archive is magic[4], {minver,majver,options}[3],
-  // archive_size[0], cp_counts[8], class_counts[4], for a total of 19 bytes.
-  // (Note that archive_size is optional; it may be 0..10 bytes in length.)
-  // The first read must capture everything up through the options field.
-  // This happens to work even if {minver,majver,options} is a pathological
-  // 15 bytes long.  Legal pack files limit those three fields to 1+1+2 bytes.
-  assert(FIRST_READ >= MAGIC_BYTES + AH_LENGTH_0 * B_MAX);
-
-  // Up through archive_size, the largest possible archive header is
-  // magic[4], {minver,majver,options}[4], archive_size[10].
-  // (Note only the low 12 bits of options are allowed to be non-zero.)
-  // In order to parse archive_size, we need at least this many bytes
-  // in the first read.  Of course, if archive_size_hi is more than
-  // a byte, we probably will fail to allocate the buffer, since it
-  // will be many gigabytes long.  This is a practical, not an
-  // architectural limit to Pack200 archive sizes.
-  assert(FIRST_READ >= MAGIC_BYTES + AH_LENGTH_0_MAX + 2*B_MAX);
-
-  bool foreign_buf = (read_input_fn == null);
-  byte initbuf[(int)FIRST_READ + (int)C_SLOP + 200];  // 200 is for JAR I/O
-  if (foreign_buf) {
-    // inbytes is all there is
-    input.set(inbytes);
-    rp      = input.base();
-    rplimit = input.limit();
-  } else {
-    // inbytes, if not empty, contains some read-ahead we must use first
-    // ensure_input will take care of copying it into initbuf,
-    // then querying read_input_fn for any additional data needed.
-    // However, the caller must assume that we use up all of inbytes.
-    // There is no way to tell the caller that we used only part of them.
-    // Therefore, the caller must use only a bare minimum of read-ahead.
-    if (inbytes.len > FIRST_READ) {
-      abort("too much read-ahead");
-      return;
-    }
-    input.set(initbuf, sizeof(initbuf));
-    input.b.clear();
-    input.b.copyFrom(inbytes);
-    rplimit = rp = input.base();
-    rplimit += inbytes.len;
-    bytes_read += inbytes.len;
-  }
-  // Read only 19 bytes, which is certain to contain #archive_options fields,
-  // but is certain not to overflow past the archive_header.
-  input.b.len = FIRST_READ;
-  if (!ensure_input(FIRST_READ))
-    abort("EOF reading archive magic number");
-
-  if (rp[0] == 'P' && rp[1] == 'K') {
-#ifdef UNPACK_JNI
-    // Java driver must handle this case before we get this far.
-    abort("encountered a JAR header in unpacker");
-#else
-    // In the Unix-style program, we simply simulate a copy command.
-    // Copy until EOF; assume the JAR file is the last segment.
-    fprintf(errstrm, "Copy-mode.\n");
-    for (;;) {
-      jarout->write_data(rp, (int)input_remaining());
-      if (foreign_buf)
-        break;  // one-time use of a passed in buffer
-      if (input.size() < CHUNK) {
-        // Get some breathing room.
-        input.set(U_NEW(byte, (size_t) CHUNK + C_SLOP), (size_t) CHUNK);
-        CHECK;
-      }
-      rp = rplimit = input.base();
-      if (!ensure_input(1))
-        break;
-    }
-    jarout->closeJarFile(false);
-#endif
-    return;
-  }
-
-  // Read the magic number.
-  magic = 0;
-  for (int i1 = 0; i1 < (int)sizeof(magic); i1++) {
-    magic <<= 8;
-    magic += (*rp++ & 0xFF);
-  }
-
-  // Read the first 3 values from the header.
-  value_stream hdr;
-  int          hdrVals = 0;
-  int          hdrValsSkipped = 0;  // for assert
-  hdr.init(rp, rplimit, UNSIGNED5_spec);
-  minver = hdr.getInt();
-  majver = hdr.getInt();
-  hdrVals += 2;
-
-  int majmin[4][2] = {
-      {JAVA5_PACKAGE_MAJOR_VERSION, JAVA5_PACKAGE_MINOR_VERSION},
-      {JAVA6_PACKAGE_MAJOR_VERSION, JAVA6_PACKAGE_MINOR_VERSION},
-      {JAVA7_PACKAGE_MAJOR_VERSION, JAVA7_PACKAGE_MINOR_VERSION},
-      {JAVA8_PACKAGE_MAJOR_VERSION, JAVA8_PACKAGE_MINOR_VERSION}
-  };
-  int majminfound = false;
-  for (int i = 0 ; i < 4 ; i++) {
-      if (majver == majmin[i][0] && minver == majmin[i][1]) {
-          majminfound = true;
-          break;
-      }
-  }
-  if (majminfound == null) {
-    char message[200];
-    sprintf(message, "@" ERROR_FORMAT ": magic/ver = "
-            "%08X/%d.%d should be %08X/%d.%d OR %08X/%d.%d OR %08X/%d.%d OR %08X/%d.%d\n",
-            magic, majver, minver,
-            JAVA_PACKAGE_MAGIC, JAVA5_PACKAGE_MAJOR_VERSION, JAVA5_PACKAGE_MINOR_VERSION,
-            JAVA_PACKAGE_MAGIC, JAVA6_PACKAGE_MAJOR_VERSION, JAVA6_PACKAGE_MINOR_VERSION,
-            JAVA_PACKAGE_MAGIC, JAVA7_PACKAGE_MAJOR_VERSION, JAVA7_PACKAGE_MINOR_VERSION,
-            JAVA_PACKAGE_MAGIC, JAVA8_PACKAGE_MAJOR_VERSION, JAVA8_PACKAGE_MINOR_VERSION);
-    abort(message);
-  }
-  CHECK;
-
-  archive_options = hdr.getInt();
-  hdrVals += 1;
-  assert(hdrVals == AH_LENGTH_0);  // first three fields only
-  bool haveSizeHi = testBit(archive_options, AO_HAVE_FILE_SIZE_HI);
-  bool haveModTime = testBit(archive_options, AO_HAVE_FILE_MODTIME);
-  bool haveFileOpt = testBit(archive_options, AO_HAVE_FILE_OPTIONS);
-
-  bool haveSpecial = testBit(archive_options, AO_HAVE_SPECIAL_FORMATS);
-  bool haveFiles = testBit(archive_options, AO_HAVE_FILE_HEADERS);
-  bool haveNumbers = testBit(archive_options, AO_HAVE_CP_NUMBERS);
-  bool haveCPExtra = testBit(archive_options, AO_HAVE_CP_EXTRAS);
-
-  if (majver < JAVA7_PACKAGE_MAJOR_VERSION) {
-    if (haveCPExtra) {
-        abort("Format bits for Java 7 must be zero in previous releases");
-        return;
-    }
-  }
-  if (testBit(archive_options, AO_UNUSED_MBZ)) {
-    abort("High archive option bits are reserved and must be zero");
-    return;
-  }
-  if (haveFiles) {
-    uint hi = hdr.getInt();
-    uint lo = hdr.getInt();
-    julong x = band::makeLong(hi, lo);
-    archive_size = (size_t) x;
-    if (archive_size != x) {
-      // Silly size specified; force overflow.
-      archive_size = PSIZE_MAX+1;
-    }
-    hdrVals += 2;
-  } else {
-    hdrValsSkipped += 2;
-  }
-
-  // Now we can size the whole archive.
-  // Read everything else into a mega-buffer.
-  rp = hdr.rp;
-  int header_size_0 = (int)(rp - input.base()); // used-up header (4byte + 3int)
-  int header_size_1 = (int)(rplimit - rp);      // buffered unused initial fragment
-  int header_size   = header_size_0+header_size_1;
-  unsized_bytes_read = header_size_0;
-  CHECK;
-  if (foreign_buf) {
-    if (archive_size > (size_t)header_size_1) {
-      abort("EOF reading fixed input buffer");
-      return;
-    }
-  } else if (archive_size != 0) {
-    if (archive_size < ARCHIVE_SIZE_MIN) {
-      abort("impossible archive size");  // bad input data
-      return;
-    }
-    if (archive_size < header_size_1) {
-      abort("too much read-ahead");  // somehow we pre-fetched too much?
-      return;
-    }
-    input.set(U_NEW(byte, add_size(header_size_0, archive_size, C_SLOP)),
-              (size_t) header_size_0 + archive_size);
-    CHECK;
-    assert(input.limit()[0] == 0);
-    // Move all the bytes we read initially into the real buffer.
-    input.b.copyFrom(initbuf, header_size);
-    rp      = input.b.ptr + header_size_0;
-    rplimit = input.b.ptr + header_size;
-  } else {
-    // It's more complicated and painful.
-    // A zero archive_size means that we must read until EOF.
-    input.init(CHUNK*2);
-    CHECK;
-    input.b.len = input.allocated;
-    rp = rplimit = input.base();
-    // Set up input buffer as if we already read the header:
-    input.b.copyFrom(initbuf, header_size);
-    CHECK;
-    rplimit += header_size;
-    while (ensure_input(input.limit() - rp)) {
-      size_t dataSoFar = input_remaining();
-      size_t nextSize = add_size(dataSoFar, CHUNK);
-      input.ensureSize(nextSize);
-      CHECK;
-      input.b.len = input.allocated;
-      rp = rplimit = input.base();
-      rplimit += dataSoFar;
-    }
-    size_t dataSize = (rplimit - input.base());
-    input.b.len = dataSize;
-    input.grow(C_SLOP);
-    CHECK;
-    free_input = true;  // free it later
-    input.b.len = dataSize;
-    assert(input.limit()[0] == 0);
-    rp = rplimit = input.base();
-    rplimit += dataSize;
-    rp += header_size_0;  // already scanned these bytes...
-  }
-  live_input = true;    // mark as "do not reuse"
-  if (aborting()) {
-    abort("cannot allocate large input buffer for package file");
-    return;
-  }
-
-  // read the rest of the header fields  int assertSkipped = AH_LENGTH_MIN - AH_LENGTH_0 - AH_LENGTH_S;
-  int remainingHeaders = AH_LENGTH_MIN - AH_LENGTH_0 - AH_LENGTH_S;
-  if (haveSpecial)
-    remainingHeaders += AH_SPECIAL_FORMAT_LEN;
-  if (haveFiles)
-     remainingHeaders += AH_FILE_HEADER_LEN;
-  if (haveNumbers)
-    remainingHeaders += AH_CP_NUMBER_LEN;
-  if (haveCPExtra)
-    remainingHeaders += AH_CP_EXTRA_LEN;
-
-  ensure_input(remainingHeaders * B_MAX);
-  CHECK;
-  hdr.rp      = rp;
-  hdr.rplimit = rplimit;
-
-  if (haveFiles) {
-    archive_next_count = hdr.getInt();
-    CHECK_COUNT(archive_next_count);
-    archive_modtime = hdr.getInt();
-    file_count = hdr.getInt();
-    CHECK_COUNT(file_count);
-    hdrVals += 3;
-  } else {
-    hdrValsSkipped += 3;
-  }
-
-  if (haveSpecial) {
-    band_headers_size = hdr.getInt();
-    CHECK_COUNT(band_headers_size);
-    attr_definition_count = hdr.getInt();
-    CHECK_COUNT(attr_definition_count);
-    hdrVals += 2;
-  } else {
-    hdrValsSkipped += 2;
-  }
-
-  int cp_counts[N_TAGS_IN_ORDER];
-  for (int k = 0; k < (int)N_TAGS_IN_ORDER; k++) {
-    if (!haveNumbers) {
-      switch (TAGS_IN_ORDER[k]) {
-      case CONSTANT_Integer:
-      case CONSTANT_Float:
-      case CONSTANT_Long:
-      case CONSTANT_Double:
-        cp_counts[k] = 0;
-        hdrValsSkipped += 1;
-        continue;
-      }
-    }
-    if (!haveCPExtra) {
-        switch(TAGS_IN_ORDER[k]) {
-        case CONSTANT_MethodHandle:
-        case CONSTANT_MethodType:
-        case CONSTANT_InvokeDynamic:
-        case CONSTANT_BootstrapMethod:
-          cp_counts[k] = 0;
-          hdrValsSkipped += 1;
-          continue;
-        }
-    }
-    cp_counts[k] = hdr.getInt();
-    CHECK_COUNT(cp_counts[k]);
-    hdrVals += 1;
-  }
-
-  ic_count = hdr.getInt();
-  CHECK_COUNT(ic_count);
-  default_class_minver = hdr.getInt();
-  default_class_majver = hdr.getInt();
-  class_count = hdr.getInt();
-  CHECK_COUNT(class_count);
-  hdrVals += 4;
-
-  // done with archive_header, time to reconcile to ensure
-  // we have read everything correctly
-  hdrVals += hdrValsSkipped;
-  assert(hdrVals == AH_LENGTH);
-  rp = hdr.rp;
-  if (rp > rplimit)
-    abort("EOF reading archive header");
-
-  // Now size the CP.
-#ifndef PRODUCT
-  // bool x = (N_TAGS_IN_ORDER == CONSTANT_Limit);
-  // assert(x);
-#endif //PRODUCT
-  cp.init(this, cp_counts);
-  CHECK;
-
-  default_file_modtime = archive_modtime;
-  if (default_file_modtime == 0 && haveModTime)
-    default_file_modtime = DEFAULT_ARCHIVE_MODTIME;  // taken from driver
-  if (testBit(archive_options, AO_DEFLATE_HINT))
-    default_file_options |= FO_DEFLATE_HINT;
-
-  // meta-bytes, if any, immediately follow archive header
-  //band_headers.readData(band_headers_size);
-  ensure_input(band_headers_size);
-  if (input_remaining() < (size_t)band_headers_size) {
-    abort("EOF reading band headers");
-    return;
-  }
-  bytes band_headers;
-  // The "1+" allows an initial byte to be pushed on the front.
-  band_headers.set(1+U_NEW(byte, 1+band_headers_size+C_SLOP),
-                   band_headers_size);
-  CHECK;
-  // Start scanning band headers here:
-  band_headers.copyFrom(rp, band_headers.len);
-  rp += band_headers.len;
-  assert(rp <= rplimit);
-  meta_rp = band_headers.ptr;
-  // Put evil meta-codes at the end of the band headers,
-  // so we are sure to throw an error if we run off the end.
-  bytes::of(band_headers.limit(), C_SLOP).clear(_meta_error);
-}
-
-void unpacker::finish() {
-  if (verbose >= 1) {
-    fprintf(errstrm,
-            "A total of "
-            LONG_LONG_FORMAT " bytes were read in %d segment(s).\n",
-            (bytes_read_before_reset+bytes_read),
-            segments_read_before_reset+1);
-    fprintf(errstrm,
-            "A total of "
-            LONG_LONG_FORMAT " file content bytes were written.\n",
-            (bytes_written_before_reset+bytes_written));
-    fprintf(errstrm,
-            "A total of %d files (of which %d are classes) were written to output.\n",
-            files_written_before_reset+files_written,
-            classes_written_before_reset+classes_written);
-  }
-  if (jarout != null)
-    jarout->closeJarFile(true);
-  if (errstrm != null) {
-    if (errstrm == stdout || errstrm == stderr) {
-      fflush(errstrm);
-    } else {
-      fclose(errstrm);
-    }
-    errstrm = null;
-    errstrm_name = null;
-  }
-}
-
-
-// Cf. PackageReader.readConstantPoolCounts
-void cpool::init(unpacker* u_, int counts[CONSTANT_Limit]) {
-  this->u = u_;
-
-  // Fill-pointer for CP.
-  int next_entry = 0;
-
-  // Size the constant pool:
-  for (int k = 0; k < (int)N_TAGS_IN_ORDER; k++) {
-    byte tag = TAGS_IN_ORDER[k];
-    int  len = counts[k];
-    tag_count[tag] = len;
-    tag_base[tag] = next_entry;
-    next_entry += len;
-    // Detect and defend against constant pool size overflow.
-    // (Pack200 forbids the sum of CP counts to exceed 2^29-1.)
-    enum {
-      CP_SIZE_LIMIT = (1<<29),
-      IMPLICIT_ENTRY_COUNT = 1  // empty Utf8 string
-    };
-    if (len >= (1<<29) || len < 0
-        || next_entry >= CP_SIZE_LIMIT+IMPLICIT_ENTRY_COUNT) {
-      abort("archive too large:  constant pool limit exceeded");
-      return;
-    }
-  }
-
-  // Close off the end of the CP:
-  nentries = next_entry;
-
-  // place a limit on future CP growth:
-  int generous = 0;
-  generous = add_size(generous, u->ic_count); // implicit name
-  generous = add_size(generous, u->ic_count); // outer
-  generous = add_size(generous, u->ic_count); // outer.utf8
-  generous = add_size(generous, 40); // WKUs, misc
-  generous = add_size(generous, u->class_count); // implicit SourceFile strings
-  maxentries = add_size(nentries, generous);
-
-  // Note that this CP does not include "empty" entries
-  // for longs and doubles.  Those are introduced when
-  // the entries are renumbered for classfile output.
-
-  entries = U_NEW(entry, maxentries);
-  CHECK;
-
-  first_extra_entry = &entries[nentries];
-
-  // Initialize the standard indexes.
-  for (int tag = 0; tag < CONSTANT_Limit; tag++) {
-    entry* cpMap = &entries[tag_base[tag]];
-    tag_index[tag].init(tag_count[tag], cpMap, tag);
-  }
-
-  // Initialize *all* our entries once
-  for (int i = 0 ; i < maxentries ; i++)
-    entries[i].outputIndex = REQUESTED_NONE;
-
-  initGroupIndexes();
-  // Initialize hashTab to a generous power-of-two size.
-  uint pow2 = 1;
-  uint target = maxentries + maxentries/2;  // 60% full
-  while (pow2 < target)  pow2 <<= 1;
-  hashTab = U_NEW(entry*, hashTabLength = pow2);
-}
-
-static byte* store_Utf8_char(byte* cp, unsigned short ch) {
-  if (ch >= 0x001 && ch <= 0x007F) {
-    *cp++ = (byte) ch;
-  } else if (ch <= 0x07FF) {
-    *cp++ = (byte) (0xC0 | ((ch >>  6) & 0x1F));
-    *cp++ = (byte) (0x80 | ((ch >>  0) & 0x3F));
-  } else {
-    *cp++ = (byte) (0xE0 | ((ch >> 12) & 0x0F));
-    *cp++ = (byte) (0x80 | ((ch >>  6) & 0x3F));
-    *cp++ = (byte) (0x80 | ((ch >>  0) & 0x3F));
-  }
-  return cp;
-}
-
-static byte* skip_Utf8_chars(byte* cp, int len) {
-  for (;; cp++) {
-    int ch = *cp & 0xFF;
-    if ((ch & 0xC0) != 0x80) {
-      if (len-- == 0)
-        return cp;
-      if (ch < 0x80 && len == 0)
-        return cp+1;
-    }
-  }
-}
-
-static int compare_Utf8_chars(bytes& b1, bytes& b2) {
-  int l1 = (int)b1.len;
-  int l2 = (int)b2.len;
-  int l0 = (l1 < l2) ? l1 : l2;
-  byte* p1 = b1.ptr;
-  byte* p2 = b2.ptr;
-  int c0 = 0;
-  for (int i = 0; i < l0; i++) {
-    int c1 = p1[i] & 0xFF;
-    int c2 = p2[i] & 0xFF;
-    if (c1 != c2) {
-      // Before returning the obvious answer,
-      // check to see if c1 or c2 is part of a 0x0000,
-      // which encodes as {0xC0,0x80}.  The 0x0000 is the
-      // lowest-sorting Java char value, and yet it encodes
-      // as if it were the first char after 0x7F, which causes
-      // strings containing nulls to sort too high.  All other
-      // comparisons are consistent between Utf8 and Java chars.
-      if (c1 == 0xC0 && (p1[i+1] & 0xFF) == 0x80)  c1 = 0;
-      if (c2 == 0xC0 && (p2[i+1] & 0xFF) == 0x80)  c2 = 0;
-      if (c0 == 0xC0) {
-        assert(((c1|c2) & 0xC0) == 0x80);  // c1 & c2 are extension chars
-        if (c1 == 0x80)  c1 = 0;  // will sort below c2
-        if (c2 == 0x80)  c2 = 0;  // will sort below c1
-      }
-      return c1 - c2;
-    }
-    c0 = c1;  // save away previous char
-  }
-  // common prefix is identical; return length difference if any
-  return l1 - l2;
-}
-
-// Cf. PackageReader.readUtf8Bands
-local_inline
-void unpacker::read_Utf8_values(entry* cpMap, int len) {
-  // Implicit first Utf8 string is the empty string.
-  enum {
-    // certain bands begin with implicit zeroes
-    PREFIX_SKIP_2 = 2,
-    SUFFIX_SKIP_1 = 1
-  };
-
-  int i;
-
-  // First band:  Read lengths of shared prefixes.
-  if (len > PREFIX_SKIP_2)
-    cp_Utf8_prefix.readData(len - PREFIX_SKIP_2);
-    NOT_PRODUCT(else cp_Utf8_prefix.readData(0));  // for asserts
-
-  // Second band:  Read lengths of unshared suffixes:
-  if (len > SUFFIX_SKIP_1)
-    cp_Utf8_suffix.readData(len - SUFFIX_SKIP_1);
-    NOT_PRODUCT(else cp_Utf8_suffix.readData(0));  // for asserts
-
-  bytes* allsuffixes = T_NEW(bytes, len);
-  CHECK;
-
-  int nbigsuf = 0;
-  fillbytes charbuf;    // buffer to allocate small strings
-  charbuf.init();
-
-  // Third band:  Read the char values in the unshared suffixes:
-  cp_Utf8_chars.readData(cp_Utf8_suffix.getIntTotal());
-  for (i = 0; i < len; i++) {
-    int suffix = (i < SUFFIX_SKIP_1)? 0: cp_Utf8_suffix.getInt();
-    if (suffix < 0) {
-      abort("bad utf8 suffix");
-      return;
-    }
-    if (suffix == 0 && i >= SUFFIX_SKIP_1) {
-      // chars are packed in cp_Utf8_big_chars
-      nbigsuf += 1;
-      continue;
-    }
-    bytes& chars  = allsuffixes[i];
-    uint size3    = suffix * 3;     // max Utf8 length
-    bool isMalloc = (suffix > SMALL);
-    if (isMalloc) {
-      chars.malloc(size3);
-    } else {
-      if (!charbuf.canAppend(size3+1)) {
-        assert(charbuf.allocated == 0 || tmallocs.contains(charbuf.base()));
-        charbuf.init(CHUNK);  // Reset to new buffer.
-        tmallocs.add(charbuf.base());
-      }
-      chars.set(charbuf.grow(size3+1), size3);
-    }
-    CHECK;
-    byte* chp = chars.ptr;
-    for (int j = 0; j < suffix; j++) {
-      unsigned short ch = cp_Utf8_chars.getInt();
-      chp = store_Utf8_char(chp, ch);
-    }
-    // shrink to fit:
-    if (isMalloc) {
-      chars.realloc(chp - chars.ptr);
-      CHECK;
-      tmallocs.add(chars.ptr); // free it later
-    } else {
-      int shrink = (int)(chars.limit() - chp);
-      chars.len -= shrink;
-      charbuf.b.len -= shrink;  // ungrow to reclaim buffer space
-      // Note that we did not reclaim the final '\0'.
-      assert(chars.limit() == charbuf.limit()-1);
-      assert(strlen((char*)chars.ptr) == chars.len);
-    }
-  }
-  //cp_Utf8_chars.done();
-#ifndef PRODUCT
-  charbuf.b.set(null, 0); // tidy
-#endif
-
-  // Fourth band:  Go back and size the specially packed strings.
-  int maxlen = 0;
-  cp_Utf8_big_suffix.readData(nbigsuf);
-  cp_Utf8_suffix.rewind();
-  for (i = 0; i < len; i++) {
-    int suffix = (i < SUFFIX_SKIP_1)? 0: cp_Utf8_suffix.getInt();
-    int prefix = (i < PREFIX_SKIP_2)? 0: cp_Utf8_prefix.getInt();
-    if (prefix < 0 || prefix+suffix < 0) {
-       abort("bad utf8 prefix");
-       return;
-    }
-    bytes& chars = allsuffixes[i];
-    if (suffix == 0 && i >= SUFFIX_SKIP_1) {
-      suffix = cp_Utf8_big_suffix.getInt();
-      assert(chars.ptr == null);
-      chars.len = suffix;  // just a momentary hack
-    } else {
-      assert(chars.ptr != null);
-    }
-    if (maxlen < prefix + suffix) {
-      maxlen = prefix + suffix;
-    }
-  }
-  //cp_Utf8_suffix.done();      // will use allsuffixes[i].len (ptr!=null)
-  //cp_Utf8_big_suffix.done();  // will use allsuffixes[i].len
-
-  // Fifth band(s):  Get the specially packed characters.
-  cp_Utf8_big_suffix.rewind();
-  for (i = 0; i < len; i++) {
-    bytes& chars = allsuffixes[i];
-    if (chars.ptr != null)  continue;  // already input
-    int suffix = (int)chars.len;  // pick up the hack
-    uint size3 = suffix * 3;
-    if (suffix == 0)  continue;  // done with empty string
-    chars.malloc(size3);
-    CHECK;
-    byte* chp = chars.ptr;
-    band saved_band = cp_Utf8_big_chars;
-    cp_Utf8_big_chars.readData(suffix);
-    CHECK;
-    for (int j = 0; j < suffix; j++) {
-      unsigned short ch = cp_Utf8_big_chars.getInt();
-      CHECK;
-      chp = store_Utf8_char(chp, ch);
-    }
-    chars.realloc(chp - chars.ptr);
-    CHECK;
-    tmallocs.add(chars.ptr);  // free it later
-    //cp_Utf8_big_chars.done();
-    cp_Utf8_big_chars = saved_band;  // reset the band for the next string
-  }
-  cp_Utf8_big_chars.readData(0);  // zero chars
-  //cp_Utf8_big_chars.done();
-
-  // Finally, sew together all the prefixes and suffixes.
-  bytes bigbuf;
-  bigbuf.malloc(maxlen * 3 + 1);  // max Utf8 length, plus slop for null
-  CHECK;
-  int prevlen = 0;  // previous string length (in chars)
-  tmallocs.add(bigbuf.ptr);  // free after this block
-  CHECK;
-  cp_Utf8_prefix.rewind();
-  for (i = 0; i < len; i++) {
-    bytes& chars = allsuffixes[i];
-    int prefix = (i < PREFIX_SKIP_2)? 0: cp_Utf8_prefix.getInt();
-    CHECK;
-    int suffix = (int)chars.len;
-    byte* fillp;
-    // by induction, the buffer is already filled with the prefix
-    // make sure the prefix value is not corrupted, though:
-    if (prefix > prevlen) {
-       abort("utf8 prefix overflow");
-       return;
-    }
-    fillp = skip_Utf8_chars(bigbuf.ptr, prefix);
-    // copy the suffix into the same buffer:
-    fillp = chars.writeTo(fillp);
-    assert(bigbuf.inBounds(fillp));
-    *fillp = 0;  // bigbuf must contain a well-formed Utf8 string
-    int length = (int)(fillp - bigbuf.ptr);
-    bytes& value = cpMap[i].value.b;
-    value.set(U_NEW(byte, add_size(length,1)), length);
-    value.copyFrom(bigbuf.ptr, length);
-    CHECK;
-    // Index all Utf8 strings
-    entry* &htref = cp.hashTabRef(CONSTANT_Utf8, value);
-    if (htref == null) {
-      // Note that if two identical strings are transmitted,
-      // the first is taken to be the canonical one.
-      htref = &cpMap[i];
-    }
-    prevlen = prefix + suffix;
-  }
-  //cp_Utf8_prefix.done();
-
-  // Free intermediate buffers.
-  free_temps();
-}
-
-local_inline
-void unpacker::read_single_words(band& cp_band, entry* cpMap, int len) {
-  cp_band.readData(len);
-  for (int i = 0; i < len; i++) {
-    cpMap[i].value.i = cp_band.getInt();  // coding handles signs OK
-  }
-}
-
-maybe_inline
-void unpacker::read_double_words(band& cp_bands, entry* cpMap, int len) {
-  band& cp_band_hi = cp_bands;
-  band& cp_band_lo = cp_bands.nextBand();
-  cp_band_hi.readData(len);
-  cp_band_lo.readData(len);
-  for (int i = 0; i < len; i++) {
-    cpMap[i].value.l = cp_band_hi.getLong(cp_band_lo, true);
-  }
-  //cp_band_hi.done();
-  //cp_band_lo.done();
-}
-
-maybe_inline
-void unpacker::read_single_refs(band& cp_band, byte refTag, entry* cpMap, int len) {
-  assert(refTag == CONSTANT_Utf8);
-  cp_band.setIndexByTag(refTag);
-  cp_band.readData(len);
-  CHECK;
-  int indexTag = (cp_band.bn == e_cp_Class) ? CONSTANT_Class : 0;
-  for (int i = 0; i < len; i++) {
-    entry& e = cpMap[i];
-    e.refs = U_NEW(entry*, e.nrefs = 1);
-    entry* utf = cp_band.getRef();
-    CHECK;
-    e.refs[0] = utf;
-    e.value.b = utf->value.b;  // copy value of Utf8 string to self
-    if (indexTag != 0) {
-      // Maintain cross-reference:
-      entry* &htref = cp.hashTabRef(indexTag, e.value.b);
-      if (htref == null) {
-        // Note that if two identical classes are transmitted,
-        // the first is taken to be the canonical one.
-        htref = &e;
-      }
-    }
-  }
-  //cp_band.done();
-}
-
-maybe_inline
-void unpacker::read_double_refs(band& cp_band, byte ref1Tag, byte ref2Tag,
-                                entry* cpMap, int len) {
-  band& cp_band1 = cp_band;
-  band& cp_band2 = cp_band.nextBand();
-  cp_band1.setIndexByTag(ref1Tag);
-  cp_band2.setIndexByTag(ref2Tag);
-  cp_band1.readData(len);
-  cp_band2.readData(len);
-  CHECK;
-  for (int i = 0; i < len; i++) {
-    entry& e = cpMap[i];
-    e.refs = U_NEW(entry*, e.nrefs = 2);
-    e.refs[0] = cp_band1.getRef();
-    CHECK;
-    e.refs[1] = cp_band2.getRef();
-    CHECK;
-  }
-  //cp_band1.done();
-  //cp_band2.done();
-}
-
-// Cf. PackageReader.readSignatureBands
-maybe_inline
-void unpacker::read_signature_values(entry* cpMap, int len) {
-  cp_Signature_form.setIndexByTag(CONSTANT_Utf8);
-  cp_Signature_form.readData(len);
-  CHECK;
-  int ncTotal = 0;
-  int i;
-  for (i = 0; i < len; i++) {
-    entry& e = cpMap[i];
-    entry& form = *cp_Signature_form.getRef();
-    CHECK;
-    int nc = 0;
-
-    for ( const char* ncp = form.utf8String() ; *ncp; ncp++) {
-      if (*ncp == 'L')  nc++;
-    }
-
-    ncTotal += nc;
-    e.refs = U_NEW(entry*, cpMap[i].nrefs = 1 + nc);
-    CHECK;
-    e.refs[0] = &form;
-  }
-  //cp_Signature_form.done();
-  cp_Signature_classes.setIndexByTag(CONSTANT_Class);
-  cp_Signature_classes.readData(ncTotal);
-  for (i = 0; i < len; i++) {
-    entry& e = cpMap[i];
-    for (int j = 1; j < e.nrefs; j++) {
-      e.refs[j] = cp_Signature_classes.getRef();
-      CHECK;
-    }
-  }
-  //cp_Signature_classes.done();
-}
-
-maybe_inline
-void unpacker::checkLegacy(const char* name) {
-  if (u->majver < JAVA7_PACKAGE_MAJOR_VERSION) {
-      char message[100];
-      snprintf(message, 99, "unexpected band %s\n", name);
-      abort(message);
-  }
-}
-
-maybe_inline
-void unpacker::read_method_handle(entry* cpMap, int len) {
-  if (len > 0) {
-    checkLegacy(cp_MethodHandle_refkind.name);
-  }
-  cp_MethodHandle_refkind.readData(len);
-  cp_MethodHandle_member.setIndexByTag(CONSTANT_AnyMember);
-  cp_MethodHandle_member.readData(len);
-  for (int i = 0 ; i < len ; i++) {
-    entry& e = cpMap[i];
-    e.value.i = cp_MethodHandle_refkind.getInt();
-    e.refs = U_NEW(entry*, e.nrefs = 1);
-    e.refs[0] = cp_MethodHandle_member.getRef();
-    CHECK;
-  }
-}
-
-maybe_inline
-void unpacker::read_method_type(entry* cpMap, int len) {
-  if (len > 0) {
-    checkLegacy(cp_MethodType.name);
-  }
-  cp_MethodType.setIndexByTag(CONSTANT_Signature);
-  cp_MethodType.readData(len);
-  for (int i = 0 ; i < len ; i++) {
-      entry& e = cpMap[i];
-      e.refs = U_NEW(entry*, e.nrefs = 1);
-      e.refs[0] = cp_MethodType.getRef();
-      CHECK;
-  }
-}
-
-maybe_inline
-void unpacker::read_bootstrap_methods(entry* cpMap, int len) {
-  if (len > 0) {
-    checkLegacy(cp_BootstrapMethod_ref.name);
-  }
-  cp_BootstrapMethod_ref.setIndexByTag(CONSTANT_MethodHandle);
-  cp_BootstrapMethod_ref.readData(len);
-
-  cp_BootstrapMethod_arg_count.readData(len);
-  int totalArgCount = cp_BootstrapMethod_arg_count.getIntTotal();
-  cp_BootstrapMethod_arg.setIndexByTag(CONSTANT_LoadableValue);
-  cp_BootstrapMethod_arg.readData(totalArgCount);
-  for (int i = 0; i < len; i++) {
-    entry& e = cpMap[i];
-    int argc = cp_BootstrapMethod_arg_count.getInt();
-    e.value.i = argc;
-    e.refs = U_NEW(entry*, e.nrefs = argc + 1);
-    e.refs[0] = cp_BootstrapMethod_ref.getRef();
-    for (int j = 1 ; j < e.nrefs ; j++) {
-      e.refs[j] = cp_BootstrapMethod_arg.getRef();
-      CHECK;
-    }
-  }
-}
-// Cf. PackageReader.readConstantPool
-void unpacker::read_cp() {
-  byte* rp0 = rp;
-
-  int i;
-
-  for (int k = 0; k < (int)N_TAGS_IN_ORDER; k++) {
-    byte tag = TAGS_IN_ORDER[k];
-    int  len = cp.tag_count[tag];
-    int base = cp.tag_base[tag];
-
-    PRINTCR((1,"Reading %d %s entries...", len, NOT_PRODUCT(TAG_NAME[tag])+0));
-    entry* cpMap = &cp.entries[base];
-    for (i = 0; i < len; i++) {
-      cpMap[i].tag = tag;
-      cpMap[i].inord = i;
-    }
-    // Initialize the tag's CP index right away, since it might be needed
-    // in the next pass to initialize the CP for another tag.
-#ifndef PRODUCT
-    cpindex* ix = &cp.tag_index[tag];
-    assert(ix->ixTag == tag);
-    assert((int)ix->len   == len);
-    assert(ix->base1 == cpMap);
-#endif
-
-    switch (tag) {
-    case CONSTANT_Utf8:
-      read_Utf8_values(cpMap, len);
-      break;
-    case CONSTANT_Integer:
-      read_single_words(cp_Int, cpMap, len);
-      break;
-    case CONSTANT_Float:
-      read_single_words(cp_Float, cpMap, len);
-      break;
-    case CONSTANT_Long:
-      read_double_words(cp_Long_hi /*& cp_Long_lo*/, cpMap, len);
-      break;
-    case CONSTANT_Double:
-      read_double_words(cp_Double_hi /*& cp_Double_lo*/, cpMap, len);
-      break;
-    case CONSTANT_String:
-      read_single_refs(cp_String, CONSTANT_Utf8, cpMap, len);
-      break;
-    case CONSTANT_Class:
-      read_single_refs(cp_Class, CONSTANT_Utf8, cpMap, len);
-      break;
-    case CONSTANT_Signature:
-      read_signature_values(cpMap, len);
-      break;
-    case CONSTANT_NameandType:
-      read_double_refs(cp_Descr_name /*& cp_Descr_type*/,
-                       CONSTANT_Utf8, CONSTANT_Signature,
-                       cpMap, len);
-      break;
-    case CONSTANT_Fieldref:
-      read_double_refs(cp_Field_class /*& cp_Field_desc*/,
-                       CONSTANT_Class, CONSTANT_NameandType,
-                       cpMap, len);
-      break;
-    case CONSTANT_Methodref:
-      read_double_refs(cp_Method_class /*& cp_Method_desc*/,
-                       CONSTANT_Class, CONSTANT_NameandType,
-                       cpMap, len);
-      break;
-    case CONSTANT_InterfaceMethodref:
-      read_double_refs(cp_Imethod_class /*& cp_Imethod_desc*/,
-                       CONSTANT_Class, CONSTANT_NameandType,
-                       cpMap, len);
-      break;
-    case CONSTANT_MethodHandle:
-      // consumes cp_MethodHandle_refkind and cp_MethodHandle_member
-      read_method_handle(cpMap, len);
-      break;
-    case CONSTANT_MethodType:
-      // consumes cp_MethodType
-      read_method_type(cpMap, len);
-      break;
-    case CONSTANT_InvokeDynamic:
-      read_double_refs(cp_InvokeDynamic_spec, CONSTANT_BootstrapMethod,
-                       CONSTANT_NameandType,
-                       cpMap, len);
-      break;
-    case CONSTANT_BootstrapMethod:
-      // consumes cp_BootstrapMethod_ref, cp_BootstrapMethod_arg_count and cp_BootstrapMethod_arg
-      read_bootstrap_methods(cpMap, len);
-      break;
-    default:
-      assert(false);
-      break;
-    }
-    CHECK;
-  }
-
-  cp.expandSignatures();
-  CHECK;
-  cp.initMemberIndexes();
-  CHECK;
-
-  PRINTCR((1,"parsed %d constant pool entries in %d bytes", cp.nentries, (rp - rp0)));
-
-  #define SNAME(n,s) #s "\0"
-  const char* symNames = (
-    ALL_ATTR_DO(SNAME)
-    "<init>"
-  );
-  #undef SNAME
-
-  for (int sn = 0; sn < cpool::s_LIMIT; sn++) {
-    assert(symNames[0] >= '0' && symNames[0] <= 'Z');  // sanity
-    bytes name; name.set(symNames);
-    if (name.len > 0 && name.ptr[0] != '0') {
-      cp.sym[sn] = cp.ensureUtf8(name);
-      PRINTCR((4, "well-known sym %d=%s", sn, cp.sym[sn]->string()));
-    }
-    symNames += name.len + 1;  // skip trailing null to next name
-  }
-
-  band::initIndexes(this);
-}
-
-static band* no_bands[] = { null };  // shared empty body
-
-inline
-band& unpacker::attr_definitions::fixed_band(int e_class_xxx) {
-  return u->all_bands[xxx_flags_hi_bn + (e_class_xxx-e_class_flags_hi)];
-}
-inline band& unpacker::attr_definitions::xxx_flags_hi()
-  { return fixed_band(e_class_flags_hi); }
-inline band& unpacker::attr_definitions::xxx_flags_lo()
-  { return fixed_band(e_class_flags_lo); }
-inline band& unpacker::attr_definitions::xxx_attr_count()
-  { return fixed_band(e_class_attr_count); }
-inline band& unpacker::attr_definitions::xxx_attr_indexes()
-  { return fixed_band(e_class_attr_indexes); }
-inline band& unpacker::attr_definitions::xxx_attr_calls()
-  { return fixed_band(e_class_attr_calls); }
-
-
-inline
-unpacker::layout_definition*
-unpacker::attr_definitions::defineLayout(int idx,
-                                         entry* nameEntry,
-                                         const char* layout) {
-  const char* name = nameEntry->value.b.strval();
-  layout_definition* lo = defineLayout(idx, name, layout);
-  CHECK_0;
-  lo->nameEntry = nameEntry;
-  return lo;
-}
-
-unpacker::layout_definition*
-unpacker::attr_definitions::defineLayout(int idx,
-                                         const char* name,
-                                         const char* layout) {
-  assert(flag_limit != 0);  // must be set up already
-  if (idx >= 0) {
-    // Fixed attr.
-    if (idx >= (int)flag_limit)
-      abort("attribute index too large");
-    if (isRedefined(idx))
-      abort("redefined attribute index");
-    redef |= ((julong)1<<idx);
-  } else {
-    idx = flag_limit + overflow_count.length();
-    overflow_count.add(0);  // make a new counter
-  }
-  layout_definition* lo = U_NEW(layout_definition, 1);
-  CHECK_0;
-  lo->idx = idx;
-  lo->name = name;
-  lo->layout = layout;
-  for (int adds = (idx+1) - layouts.length(); adds > 0; adds--) {
-    layouts.add(null);
-  }
-  CHECK_0;
-  layouts.get(idx) = lo;
-  return lo;
-}
-
-band**
-unpacker::attr_definitions::buildBands(unpacker::layout_definition* lo) {
-  int i;
-  if (lo->elems != null)
-    return lo->bands();
-  if (lo->layout[0] == '\0') {
-    lo->elems = no_bands;
-  } else {
-    // Create bands for this attribute by parsing the layout.
-    bool hasCallables = lo->hasCallables();
-    bands_made = 0x10000;  // base number for bands made
-    const char* lp = lo->layout;
-    lp = parseLayout(lp, lo->elems, -1);
-    CHECK_0;
-    if (lp[0] != '\0' || band_stack.length() > 0) {
-      abort("garbage at end of layout");
-    }
-    band_stack.popTo(0);
-    CHECK_0;
-
-    // Fix up callables to point at their callees.
-    band** bands = lo->elems;
-    assert(bands == lo->bands());
-    int num_callables = 0;
-    if (hasCallables) {
-      while (bands[num_callables] != null) {
-        if (bands[num_callables]->le_kind != EK_CBLE) {
-          abort("garbage mixed with callables");
-          break;
-        }
-        num_callables += 1;
-      }
-    }
-    for (i = 0; i < calls_to_link.length(); i++) {
-      band& call = *(band*) calls_to_link.get(i);
-      assert(call.le_kind == EK_CALL);
-      // Determine the callee.
-      int call_num = call.le_len;
-      if (call_num < 0 || call_num >= num_callables) {
-        abort("bad call in layout");
-        break;
-      }
-      band& cble = *bands[call_num];
-      // Link the call to it.
-      call.le_body[0] = &cble;
-      // Distinguish backward calls and callables:
-      assert(cble.le_kind == EK_CBLE);
-      assert(cble.le_len == call_num);
-      cble.le_back |= call.le_back;
-    }
-    calls_to_link.popTo(0);
-  }
-  return lo->elems;
-}
-
-/* attribute layout language parser
-
-  attribute_layout:
-        ( layout_element )* | ( callable )+
-  layout_element:
-        ( integral | replication | union | call | reference )
-
-  callable:
-        '[' body ']'
-  body:
-        ( layout_element )+
-
-  integral:
-        ( unsigned_int | signed_int | bc_index | bc_offset | flag )
-  unsigned_int:
-        uint_type
-  signed_int:
-        'S' uint_type
-  any_int:
-        ( unsigned_int | signed_int )
-  bc_index:
-        ( 'P' uint_type | 'PO' uint_type )
-  bc_offset:
-        'O' any_int
-  flag:
-        'F' uint_type
-  uint_type:
-        ( 'B' | 'H' | 'I' | 'V' )
-
-  replication:
-        'N' uint_type '[' body ']'
-
-  union:
-        'T' any_int (union_case)* '(' ')' '[' (body)? ']'
-  union_case:
-        '(' union_case_tag (',' union_case_tag)* ')' '[' (body)? ']'
-  union_case_tag:
-        ( numeral | numeral '-' numeral )
-  call:
-        '(' numeral ')'
-
-  reference:
-        reference_type ( 'N' )? uint_type
-  reference_type:
-        ( constant_ref | schema_ref | utf8_ref | untyped_ref )
-  constant_ref:
-        ( 'KI' | 'KJ' | 'KF' | 'KD' | 'KS' | 'KQ' )
-  schema_ref:
-        ( 'RC' | 'RS' | 'RD' | 'RF' | 'RM' | 'RI' )
-  utf8_ref:
-        'RU'
-  untyped_ref:
-        'RQ'
-
-  numeral:
-        '(' ('-')? (digit)+ ')'
-  digit:
-        ( '0' | '1' | '2' | '3' | '4' | '5' | '6' | '7' | '8' | '9' )
-
-*/
-
-const char*
-unpacker::attr_definitions::parseIntLayout(const char* lp, band* &res,
-                                           byte le_kind, bool can_be_signed) {
-  const char* lp0 = lp;
-  band* b = U_NEW(band, 1);
-  CHECK_(lp);
-  char le = *lp++;
-  int spec = UNSIGNED5_spec;
-  if (le == 'S' && can_be_signed) {
-    // Note:  This is the last use of sign.  There is no 'EF_SIGN'.
-    spec = SIGNED5_spec;
-    le = *lp++;
-  } else if (le == 'B') {
-    spec = BYTE1_spec;  // unsigned byte
-  }
-  b->init(u, bands_made++, spec);
-  b->le_kind = le_kind;
-  int le_len = 0;
-  switch (le) {
-  case 'B': le_len = 1; break;
-  case 'H': le_len = 2; break;
-  case 'I': le_len = 4; break;
-  case 'V': le_len = 0; break;
-  default:  abort("bad layout element");
-  }
-  b->le_len = le_len;
-  band_stack.add(b);
-  res = b;
-  return lp;
-}
-
-const char*
-unpacker::attr_definitions::parseNumeral(const char* lp, int &res) {
-  const char* lp0 = lp;
-  bool sgn = false;
-  if (*lp == '0') { res = 0; return lp+1; }  // special case '0'
-  if (*lp == '-') { sgn = true; lp++; }
-  const char* dp = lp;
-  int con = 0;
-  while (*dp >= '0' && *dp <= '9') {
-    int con0 = con;
-    con *= 10;
-    con += (*dp++) - '0';
-    if (con <= con0) { con = -1; break; }  //  numeral overflow
-  }
-  if (lp == dp) {
-    abort("missing numeral in layout");
-    return "";
-  }
-  lp = dp;
-  if (con < 0 && !(sgn && con == -con)) {
-    // (Portability note:  Misses the error if int is not 32 bits.)
-    abort("numeral overflow");
-    return "" ;
-  }
-  if (sgn)  con = -con;
-  res = con;
-  return lp;
-}
-
-band**
-unpacker::attr_definitions::popBody(int bs_base) {
-  // Return everything that was pushed, as a null-terminated pointer array.
-  int bs_limit = band_stack.length();
-  if (bs_base == bs_limit) {
-    return no_bands;
-  } else {
-    int nb = bs_limit - bs_base;
-    band** res = U_NEW(band*, add_size(nb, 1));
-    CHECK_(no_bands);
-    for (int i = 0; i < nb; i++) {
-      band* b = (band*) band_stack.get(bs_base + i);
-      res[i] = b;
-    }
-    band_stack.popTo(bs_base);
-    return res;
-  }
-}
-
-const char*
-unpacker::attr_definitions::parseLayout(const char* lp, band** &res,
-                                        int curCble) {
-  const char* lp0 = lp;
-  int bs_base = band_stack.length();
-  bool top_level = (bs_base == 0);
-  band* b;
-  enum { can_be_signed = true };  // optional arg to parseIntLayout
-
-  for (bool done = false; !done; ) {
-    switch (*lp++) {
-    case 'B': case 'H': case 'I': case 'V': // unsigned_int
-    case 'S': // signed_int
-      --lp; // reparse
-    case 'F':
-      lp = parseIntLayout(lp, b, EK_INT);
-      break;
-    case 'P':
-      {
-        int le_bci = EK_BCI;
-        if (*lp == 'O') {
-          ++lp;
-          le_bci = EK_BCID;
-        }
-        assert(*lp != 'S');  // no PSH, etc.
-        lp = parseIntLayout(lp, b, EK_INT);
-        b->le_bci = le_bci;
-        if (le_bci == EK_BCI)
-          b->defc = coding::findBySpec(BCI5_spec);
-        else
-          b->defc = coding::findBySpec(BRANCH5_spec);
-      }
-      break;
-    case 'O':
-      lp = parseIntLayout(lp, b, EK_INT, can_be_signed);
-      b->le_bci = EK_BCO;
-      b->defc = coding::findBySpec(BRANCH5_spec);
-      break;
-    case 'N': // replication: 'N' uint '[' elem ... ']'
-      lp = parseIntLayout(lp, b, EK_REPL);
-      assert(*lp == '[');
-      ++lp;
-      lp = parseLayout(lp, b->le_body, curCble);
-      CHECK_(lp);
-      break;
-    case 'T': // union: 'T' any_int union_case* '(' ')' '[' body ']'
-      lp = parseIntLayout(lp, b, EK_UN, can_be_signed);
-      {
-        int union_base = band_stack.length();
-        for (;;) {   // for each case
-          band& k_case = *U_NEW(band, 1);
-          CHECK_(lp);
-          band_stack.add(&k_case);
-          k_case.le_kind = EK_CASE;
-          k_case.bn = bands_made++;
-          if (*lp++ != '(') {
-            abort("bad union case");
-            return "";
-          }
-          if (*lp++ != ')') {
-            --lp;  // reparse
-            // Read some case values.  (Use band_stack for temp. storage.)
-            int case_base = band_stack.length();
-            for (;;) {
-              int caseval = 0;
-              lp = parseNumeral(lp, caseval);
-              band_stack.add((void*)(size_t)caseval);
-              if (*lp == '-') {
-                // new in version 160, allow (1-5) for (1,2,3,4,5)
-                if (u->majver < JAVA6_PACKAGE_MAJOR_VERSION) {
-                  abort("bad range in union case label (old archive format)");
-                  return "";
-                }
-                int caselimit = caseval;
-                lp++;
-                lp = parseNumeral(lp, caselimit);
-                if (caseval >= caselimit
-                    || (uint)(caselimit - caseval) > 0x10000) {
-                  // Note:  0x10000 is arbitrary implementation restriction.
-                  // We can remove it later if it's important to.
-                  abort("bad range in union case label");
-                  return "";
-                }
-                for (;;) {
-                  ++caseval;
-                  band_stack.add((void*)(size_t)caseval);
-                  if (caseval == caselimit)  break;
-                }
-              }
-              if (*lp != ',')  break;
-              lp++;
-            }
-            if (*lp++ != ')') {
-              abort("bad case label");
-              return "";
-            }
-            // save away the case labels
-            int ntags = band_stack.length() - case_base;
-            int* tags = U_NEW(int, add_size(ntags, 1));
-            CHECK_(lp);
-            k_case.le_casetags = tags;
-            *tags++ = ntags;
-            for (int i = 0; i < ntags; i++) {
-              *tags++ = ptrlowbits(band_stack.get(case_base+i));
-            }
-            band_stack.popTo(case_base);
-            CHECK_(lp);
-          }
-          // Got le_casetags.  Now grab the body.
-          assert(*lp == '[');
-          ++lp;
-          lp = parseLayout(lp, k_case.le_body, curCble);
-          CHECK_(lp);
-          if (k_case.le_casetags == null)  break;  // done
-        }
-        b->le_body = popBody(union_base);
-      }
-      break;
-    case '(': // call: '(' -?NN* ')'
-      {
-        band& call = *U_NEW(band, 1);
-        CHECK_(lp);
-        band_stack.add(&call);
-        call.le_kind = EK_CALL;
-        call.bn = bands_made++;
-        call.le_body = U_NEW(band*, 2); // fill in later
-        int call_num = 0;
-        lp = parseNumeral(lp, call_num);
-        call.le_back = (call_num <= 0);
-        call_num += curCble;  // numeral is self-relative offset
-        call.le_len = call_num;  //use le_len as scratch
-        calls_to_link.add(&call);
-        CHECK_(lp);
-        if (*lp++ != ')') {
-          abort("bad call label");
-          return "";
-        }
-      }
-      break;
-    case 'K': // reference_type: constant_ref
-    case 'R': // reference_type: schema_ref
-      {
-        int ixTag = CONSTANT_None;
-        if (lp[-1] == 'K') {
-          switch (*lp++) {
-          case 'I': ixTag = CONSTANT_Integer; break;
-          case 'J': ixTag = CONSTANT_Long; break;
-          case 'F': ixTag = CONSTANT_Float; break;
-          case 'D': ixTag = CONSTANT_Double; break;
-          case 'S': ixTag = CONSTANT_String; break;
-          case 'Q': ixTag = CONSTANT_FieldSpecific; break;
-
-          // new in 1.7
-          case 'M': ixTag = CONSTANT_MethodHandle; break;
-          case 'T': ixTag = CONSTANT_MethodType; break;
-          case 'L': ixTag = CONSTANT_LoadableValue; break;
-          }
-        } else {
-          switch (*lp++) {
-          case 'C': ixTag = CONSTANT_Class; break;
-          case 'S': ixTag = CONSTANT_Signature; break;
-          case 'D': ixTag = CONSTANT_NameandType; break;
-          case 'F': ixTag = CONSTANT_Fieldref; break;
-          case 'M': ixTag = CONSTANT_Methodref; break;
-          case 'I': ixTag = CONSTANT_InterfaceMethodref; break;
-          case 'U': ixTag = CONSTANT_Utf8; break; //utf8_ref
-          case 'Q': ixTag = CONSTANT_All; break; //untyped_ref
-
-          // new in 1.7
-          case 'Y': ixTag = CONSTANT_InvokeDynamic; break;
-          case 'B': ixTag = CONSTANT_BootstrapMethod; break;
-          case 'N': ixTag = CONSTANT_AnyMember; break;
-          }
-        }
-        if (ixTag == CONSTANT_None) {
-          abort("bad reference layout");
-          break;
-        }
-        bool nullOK = false;
-        if (*lp == 'N') {
-          nullOK = true;
-          lp++;
-        }
-        lp = parseIntLayout(lp, b, EK_REF);
-        b->defc = coding::findBySpec(UNSIGNED5_spec);
-        b->initRef(ixTag, nullOK);
-      }
-      break;
-    case '[':
-      {
-        // [callable1][callable2]...
-        if (!top_level) {
-          abort("bad nested callable");
-          break;
-        }
-        curCble += 1;
-        NOT_PRODUCT(int call_num = band_stack.length() - bs_base);
-        band& cble = *U_NEW(band, 1);
-        CHECK_(lp);
-        band_stack.add(&cble);
-        cble.le_kind = EK_CBLE;
-        NOT_PRODUCT(cble.le_len = call_num);
-        cble.bn = bands_made++;
-        lp = parseLayout(lp, cble.le_body, curCble);
-      }
-      break;
-    case ']':
-      // Hit a closing brace.  This ends whatever body we were in.
-      done = true;
-      break;
-    case '\0':
-      // Hit a null.  Also ends the (top-level) body.
-      --lp;  // back up, so caller can see the null also
-      done = true;
-      break;
-    default:
-      abort("bad layout");
-      break;
-    }
-    CHECK_(lp);
-  }
-
-  // Return the accumulated bands:
-  res = popBody(bs_base);
-  return lp;
-}
-
-void unpacker::read_attr_defs() {
-  int i;
-
-  // Tell each AD which attrc it is and where its fixed flags are:
-  attr_defs[ATTR_CONTEXT_CLASS].attrc            = ATTR_CONTEXT_CLASS;
-  attr_defs[ATTR_CONTEXT_CLASS].xxx_flags_hi_bn  = e_class_flags_hi;
-  attr_defs[ATTR_CONTEXT_FIELD].attrc            = ATTR_CONTEXT_FIELD;
-  attr_defs[ATTR_CONTEXT_FIELD].xxx_flags_hi_bn  = e_field_flags_hi;
-  attr_defs[ATTR_CONTEXT_METHOD].attrc           = ATTR_CONTEXT_METHOD;
-  attr_defs[ATTR_CONTEXT_METHOD].xxx_flags_hi_bn = e_method_flags_hi;
-  attr_defs[ATTR_CONTEXT_CODE].attrc             = ATTR_CONTEXT_CODE;
-  attr_defs[ATTR_CONTEXT_CODE].xxx_flags_hi_bn   = e_code_flags_hi;
-
-  // Decide whether bands for the optional high flag words are present.
-  attr_defs[ATTR_CONTEXT_CLASS]
-    .setHaveLongFlags(testBit(archive_options, AO_HAVE_CLASS_FLAGS_HI));
-  attr_defs[ATTR_CONTEXT_FIELD]
-    .setHaveLongFlags(testBit(archive_options, AO_HAVE_FIELD_FLAGS_HI));
-  attr_defs[ATTR_CONTEXT_METHOD]
-    .setHaveLongFlags(testBit(archive_options, AO_HAVE_METHOD_FLAGS_HI));
-  attr_defs[ATTR_CONTEXT_CODE]
-    .setHaveLongFlags(testBit(archive_options, AO_HAVE_CODE_FLAGS_HI));
-
-  // Set up built-in attrs.
-  // (The simple ones are hard-coded.  The metadata layouts are not.)
-  const char* md_layout = (
-    // parameter annotations:
-#define MDL0 \
-    "[NB[(1)]]"
-    MDL0
-    // annotations:
-#define MDL1 \
-    "[NH[(1)]]"
-    MDL1
-#define MDL2 \
-    "[RSHNH[RUH(1)]]"
-    MDL2
-    // element_value:
-#define MDL3 \
-    "[TB"                        \
-      "(66,67,73,83,90)[KIH]"    \
-      "(68)[KDH]"                \
-      "(70)[KFH]"                \
-      "(74)[KJH]"                \
-      "(99)[RSH]"                \
-      "(101)[RSHRUH]"            \
-      "(115)[RUH]"               \
-      "(91)[NH[(0)]]"            \
-      "(64)["                    \
-        /* nested annotation: */ \
-        "RSH"                    \
-        "NH[RUH(0)]"             \
-        "]"                      \
-      "()[]"                     \
-    "]"
-    MDL3
-    );
-
-  const char* md_layout_P = md_layout;
-  const char* md_layout_A = md_layout+strlen(MDL0);
-  const char* md_layout_V = md_layout+strlen(MDL0 MDL1 MDL2);
-  assert(0 == strncmp(&md_layout_A[-3], ")]][", 4));
-  assert(0 == strncmp(&md_layout_V[-3], ")]][", 4));
-
-const char* type_md_layout(
-    "[NH[(1)(2)(3)]]"
-    // target-type + target_info
-    "[TB"
-       "(0,1)[B]"
-       "(16)[FH]"
-       "(17,18)[BB]"
-       "(19,20,21)[]"
-       "(22)[B]"
-       "(23)[H]"
-       "(64,65)[NH[PHOHH]]"
-       "(66)[H]"
-       "(67,68,69,70)[PH]"
-       "(71,72,73,74,75)[PHB]"
-       "()[]]"
-    // target-path
-    "[NB[BB]]"
-    // annotation + element_value
-    MDL2
-    MDL3
-);
-
-  for (i = 0; i < ATTR_CONTEXT_LIMIT; i++) {
-    attr_definitions& ad = attr_defs[i];
-    if (i != ATTR_CONTEXT_CODE) {
-      ad.defineLayout(X_ATTR_RuntimeVisibleAnnotations,
-                      "RuntimeVisibleAnnotations", md_layout_A);
-      ad.defineLayout(X_ATTR_RuntimeInvisibleAnnotations,
-                      "RuntimeInvisibleAnnotations", md_layout_A);
-      if (i == ATTR_CONTEXT_METHOD) {
-        ad.defineLayout(METHOD_ATTR_RuntimeVisibleParameterAnnotations,
-                        "RuntimeVisibleParameterAnnotations", md_layout_P);
-        ad.defineLayout(METHOD_ATTR_RuntimeInvisibleParameterAnnotations,
-                        "RuntimeInvisibleParameterAnnotations", md_layout_P);
-        ad.defineLayout(METHOD_ATTR_AnnotationDefault,
-                        "AnnotationDefault", md_layout_V);
-      }
-    }
-    ad.defineLayout(X_ATTR_RuntimeVisibleTypeAnnotations,
-                    "RuntimeVisibleTypeAnnotations", type_md_layout);
-    ad.defineLayout(X_ATTR_RuntimeInvisibleTypeAnnotations,
-                    "RuntimeInvisibleTypeAnnotations", type_md_layout);
-  }
-
-  attr_definition_headers.readData(attr_definition_count);
-  attr_definition_name.readData(attr_definition_count);
-  attr_definition_layout.readData(attr_definition_count);
-
-  CHECK;
-
-  // Initialize correct predef bits, to distinguish predefs from new defs.
-#define ORBIT(n,s) |((julong)1<<n)
-  attr_defs[ATTR_CONTEXT_CLASS].predef
-    = (0 X_ATTR_DO(ORBIT) CLASS_ATTR_DO(ORBIT));
-  attr_defs[ATTR_CONTEXT_FIELD].predef
-    = (0 X_ATTR_DO(ORBIT) FIELD_ATTR_DO(ORBIT));
-  attr_defs[ATTR_CONTEXT_METHOD].predef
-    = (0 X_ATTR_DO(ORBIT) METHOD_ATTR_DO(ORBIT));
-  attr_defs[ATTR_CONTEXT_CODE].predef
-    = (0 O_ATTR_DO(ORBIT) CODE_ATTR_DO(ORBIT));
-#undef ORBIT
-  // Clear out the redef bits, folding them back into predef.
-  for (i = 0; i < ATTR_CONTEXT_LIMIT; i++) {
-    attr_defs[i].predef |= attr_defs[i].redef;
-    attr_defs[i].redef = 0;
-  }
-
-  // Now read the transmitted locally defined attrs.
-  // This will set redef bits again.
-  for (i = 0; i < attr_definition_count; i++) {
-    int    header  = attr_definition_headers.getByte();
-    int    attrc   = ADH_BYTE_CONTEXT(header);
-    int    idx     = ADH_BYTE_INDEX(header);
-    entry* name    = attr_definition_name.getRef();
-    CHECK;
-    entry* layout  = attr_definition_layout.getRef();
-    CHECK;
-    attr_defs[attrc].defineLayout(idx, name, layout->value.b.strval());
-  }
-}
-
-#define NO_ENTRY_YET ((entry*)-1)
-
-static bool isDigitString(bytes& x, int beg, int end) {
-  if (beg == end)  return false;  // null string
-  byte* xptr = x.ptr;
-  for (int i = beg; i < end; i++) {
-    char ch = xptr[i];
-    if (!(ch >= '0' && ch <= '9'))  return false;
-  }
-  return true;
-}
-
-enum {  // constants for parsing class names
-  SLASH_MIN = '.',
-  SLASH_MAX = '/',
-  DOLLAR_MIN = 0,
-  DOLLAR_MAX = '-'
-};
-
-static int lastIndexOf(int chmin, int chmax, bytes& x, int pos) {
-  byte* ptr = x.ptr;
-  for (byte* cp = ptr + pos; --cp >= ptr; ) {
-    assert(x.inBounds(cp));
-    if (*cp >= chmin && *cp <= chmax)
-      return (int)(cp - ptr);
-  }
-  return -1;
-}
-
-maybe_inline
-inner_class* cpool::getIC(entry* inner) {
-  if (inner == null)  return null;
-  assert(inner->tag == CONSTANT_Class);
-  if (inner->inord == NO_INORD)  return null;
-  inner_class* ic = ic_index[inner->inord];
-  assert(ic == null || ic->inner == inner);
-  return ic;
-}
-
-maybe_inline
-inner_class* cpool::getFirstChildIC(entry* outer) {
-  if (outer == null)  return null;
-  assert(outer->tag == CONSTANT_Class);
-  if (outer->inord == NO_INORD)  return null;
-  inner_class* ic = ic_child_index[outer->inord];
-  assert(ic == null || ic->outer == outer);
-  return ic;
-}
-
-maybe_inline
-inner_class* cpool::getNextChildIC(inner_class* child) {
-  inner_class* ic = child->next_sibling;
-  assert(ic == null || ic->outer == child->outer);
-  return ic;
-}
-
-void unpacker::read_ics() {
-  int i;
-  int index_size = cp.tag_count[CONSTANT_Class];
-  inner_class** ic_index       = U_NEW(inner_class*, index_size);
-  inner_class** ic_child_index = U_NEW(inner_class*, index_size);
-  cp.ic_index = ic_index;
-  cp.ic_child_index = ic_child_index;
-  ics = U_NEW(inner_class, ic_count);
-  ic_this_class.readData(ic_count);
-  ic_flags.readData(ic_count);
-  CHECK;
-  // Scan flags to get count of long-form bands.
-  int long_forms = 0;
-  for (i = 0; i < ic_count; i++) {
-    int flags = ic_flags.getInt();  // may be long form!
-    if ((flags & ACC_IC_LONG_FORM) != 0) {
-      long_forms += 1;
-      ics[i].name = NO_ENTRY_YET;
-    }
-    flags &= ~ACC_IC_LONG_FORM;
-    entry* inner = ic_this_class.getRef();
-    CHECK;
-    uint inord = inner->inord;
-    assert(inord < (uint)cp.tag_count[CONSTANT_Class]);
-    if (ic_index[inord] != null) {
-      abort("identical inner class");
-      break;
-    }
-    ic_index[inord] = &ics[i];
-    ics[i].inner = inner;
-    ics[i].flags = flags;
-    assert(cp.getIC(inner) == &ics[i]);
-  }
-  CHECK;
-  //ic_this_class.done();
-  //ic_flags.done();
-  ic_outer_class.readData(long_forms);
-  ic_name.readData(long_forms);
-  for (i = 0; i < ic_count; i++) {
-    if (ics[i].name == NO_ENTRY_YET) {
-      // Long form.
-      ics[i].outer = ic_outer_class.getRefN();
-      CHECK;
-      ics[i].name  = ic_name.getRefN();
-      CHECK;
-    } else {
-      // Fill in outer and name based on inner.
-      bytes& n = ics[i].inner->value.b;
-      bytes pkgOuter;
-      bytes number;
-      bytes name;
-      // Parse n into pkgOuter and name (and number).
-      PRINTCR((5, "parse short IC name %s", n.ptr));
-      int dollar1, dollar2;  // pointers to $ in the pattern
-      // parse n = (<pkg>/)*<outer>($<number>)?($<name>)?
-      int nlen = (int)n.len;
-      int pkglen = lastIndexOf(SLASH_MIN,  SLASH_MAX,  n, nlen) + 1;
-      dollar2    = lastIndexOf(DOLLAR_MIN, DOLLAR_MAX, n, nlen);
-      if (dollar2 < 0) {
-         abort();
-         return;
-      }
-      assert(dollar2 >= pkglen);
-      if (isDigitString(n, dollar2+1, nlen)) {
-        // n = (<pkg>/)*<outer>$<number>
-        number = n.slice(dollar2+1, nlen);
-        name.set(null,0);
-        dollar1 = dollar2;
-      } else if (pkglen < (dollar1
-                           = lastIndexOf(DOLLAR_MIN, DOLLAR_MAX, n, dollar2-1))
-                 && isDigitString(n, dollar1+1, dollar2)) {
-        // n = (<pkg>/)*<outer>$<number>$<name>
-        number = n.slice(dollar1+1, dollar2);
-        name = n.slice(dollar2+1, nlen);
-      } else {
-        // n = (<pkg>/)*<outer>$<name>
-        dollar1 = dollar2;
-        number.set(null,0);
-        name = n.slice(dollar2+1, nlen);
-      }
-      if (number.ptr == null)
-        pkgOuter = n.slice(0, dollar1);
-      else
-        pkgOuter.set(null,0);
-      PRINTCR((5,"=> %s$ 0%s $%s",
-              pkgOuter.string(), number.string(), name.string()));
-
-      if (pkgOuter.ptr != null)
-        ics[i].outer = cp.ensureClass(pkgOuter);
-
-      if (name.ptr != null)
-        ics[i].name = cp.ensureUtf8(name);
-    }
-
-    // update child/sibling list
-    if (ics[i].outer != null) {
-      uint outord = ics[i].outer->inord;
-      if (outord != NO_INORD) {
-        assert(outord < (uint)cp.tag_count[CONSTANT_Class]);
-        ics[i].next_sibling = ic_child_index[outord];
-        ic_child_index[outord] = &ics[i];
-      }
-    }
-  }
-  //ic_outer_class.done();
-  //ic_name.done();
-}
-
-void unpacker::read_classes() {
-  PRINTCR((1,"  ...scanning %d classes...", class_count));
-  class_this.readData(class_count);
-  class_super.readData(class_count);
-  class_interface_count.readData(class_count);
-  class_interface.readData(class_interface_count.getIntTotal());
-
-  CHECK;
-
-  #if 0
-  int i;
-  // Make a little mark on super-classes.
-  for (i = 0; i < class_count; i++) {
-    entry* e = class_super.getRefN();
-    if (e != null)  e->bits |= entry::EB_SUPER;
-  }
-  class_super.rewind();
-  #endif
-
-  // Members.
-  class_field_count.readData(class_count);
-  class_method_count.readData(class_count);
-
-  CHECK;
-
-  int field_count = class_field_count.getIntTotal();
-  int method_count = class_method_count.getIntTotal();
-
-  field_descr.readData(field_count);
-  read_attrs(ATTR_CONTEXT_FIELD, field_count);
-  CHECK;
-
-  method_descr.readData(method_count);
-  read_attrs(ATTR_CONTEXT_METHOD, method_count);
-
-  CHECK;
-
-  read_attrs(ATTR_CONTEXT_CLASS, class_count);
-  CHECK;
-
-  read_code_headers();
-
-  PRINTCR((1,"scanned %d classes, %d fields, %d methods, %d code headers",
-          class_count, field_count, method_count, code_count));
-}
-
-maybe_inline
-int unpacker::attr_definitions::predefCount(uint idx) {
-  return isPredefined(idx) ? flag_count[idx] : 0;
-}
-
-void unpacker::read_attrs(int attrc, int obj_count) {
-  attr_definitions& ad = attr_defs[attrc];
-  assert(ad.attrc == attrc);
-
-  int i, idx, count;
-
-  CHECK;
-
-  bool haveLongFlags = ad.haveLongFlags();
-
-  band& xxx_flags_hi = ad.xxx_flags_hi();
-  assert(endsWith(xxx_flags_hi.name, "_flags_hi"));
-  if (haveLongFlags)
-    xxx_flags_hi.readData(obj_count);
-  CHECK;
-
-  band& xxx_flags_lo = ad.xxx_flags_lo();
-  assert(endsWith(xxx_flags_lo.name, "_flags_lo"));
-  xxx_flags_lo.readData(obj_count);
-  CHECK;
-
-  // pre-scan flags, counting occurrences of each index bit
-  julong indexMask = ad.flagIndexMask();  // which flag bits are index bits?
-  for (i = 0; i < obj_count; i++) {
-    julong indexBits = xxx_flags_hi.getLong(xxx_flags_lo, haveLongFlags);
-    if ((indexBits & ~indexMask) > (ushort)-1) {
-      abort("undefined attribute flag bit");
-      return;
-    }
-    indexBits &= indexMask;  // ignore classfile flag bits
-    for (idx = 0; indexBits != 0; idx++, indexBits >>= 1) {
-      ad.flag_count[idx] += (int)(indexBits & 1);
-    }
-  }
-  // we'll scan these again later for output:
-  xxx_flags_lo.rewind();
-  xxx_flags_hi.rewind();
-
-  band& xxx_attr_count = ad.xxx_attr_count();
-  assert(endsWith(xxx_attr_count.name, "_attr_count"));
-  // There is one count element for each 1<<16 bit set in flags:
-  xxx_attr_count.readData(ad.predefCount(X_ATTR_OVERFLOW));
-  CHECK;
-
-  band& xxx_attr_indexes = ad.xxx_attr_indexes();
-  assert(endsWith(xxx_attr_indexes.name, "_attr_indexes"));
-  int overflowIndexCount = xxx_attr_count.getIntTotal();
-  xxx_attr_indexes.readData(overflowIndexCount);
-  CHECK;
-  // pre-scan attr indexes, counting occurrences of each value
-  for (i = 0; i < overflowIndexCount; i++) {
-    idx = xxx_attr_indexes.getInt();
-    if (!ad.isIndex(idx)) {
-      abort("attribute index out of bounds");
-      return;
-    }
-    ad.getCount(idx) += 1;
-  }
-  xxx_attr_indexes.rewind();  // we'll scan it again later for output
-
-  // We will need a backward call count for each used backward callable.
-  int backwardCounts = 0;
-  for (idx = 0; idx < ad.layouts.length(); idx++) {
-    layout_definition* lo = ad.getLayout(idx);
-    if (lo != null && ad.getCount(idx) != 0) {
-      // Build the bands lazily, only when they are used.
-      band** bands = ad.buildBands(lo);
-      CHECK;
-      if (lo->hasCallables()) {
-        for (i = 0; bands[i] != null; i++) {
-          if (bands[i]->le_back) {
-            assert(bands[i]->le_kind == EK_CBLE);
-            backwardCounts += 1;
-          }
-        }
-      }
-    }
-  }
-  ad.xxx_attr_calls().readData(backwardCounts);
-  CHECK;
-
-  // Read built-in bands.
-  // Mostly, these are hand-coded equivalents to readBandData().
-  switch (attrc) {
-  case ATTR_CONTEXT_CLASS:
-
-    count = ad.predefCount(CLASS_ATTR_SourceFile);
-    class_SourceFile_RUN.readData(count);
-    CHECK;
-
-    count = ad.predefCount(CLASS_ATTR_EnclosingMethod);
-    class_EnclosingMethod_RC.readData(count);
-    class_EnclosingMethod_RDN.readData(count);
-    CHECK;
-
-    count = ad.predefCount(X_ATTR_Signature);
-    class_Signature_RS.readData(count);
-    CHECK;
-
-    ad.readBandData(X_ATTR_RuntimeVisibleAnnotations);
-    ad.readBandData(X_ATTR_RuntimeInvisibleAnnotations);
-    CHECK;
-
-    count = ad.predefCount(CLASS_ATTR_InnerClasses);
-    class_InnerClasses_N.readData(count);
-    CHECK;
-
-    count = class_InnerClasses_N.getIntTotal();
-    class_InnerClasses_RC.readData(count);
-    class_InnerClasses_F.readData(count);
-    CHECK;
-    // Drop remaining columns wherever flags are zero:
-    count -= class_InnerClasses_F.getIntCount(0);
-    class_InnerClasses_outer_RCN.readData(count);
-    class_InnerClasses_name_RUN.readData(count);
-    CHECK;
-
-    count = ad.predefCount(CLASS_ATTR_ClassFile_version);
-    class_ClassFile_version_minor_H.readData(count);
-    class_ClassFile_version_major_H.readData(count);
-    CHECK;
-
-    ad.readBandData(X_ATTR_RuntimeVisibleTypeAnnotations);
-    ad.readBandData(X_ATTR_RuntimeInvisibleTypeAnnotations);
-    CHECK;
-    break;
-
-  case ATTR_CONTEXT_FIELD:
-
-    count = ad.predefCount(FIELD_ATTR_ConstantValue);
-    field_ConstantValue_KQ.readData(count);
-    CHECK;
-
-    count = ad.predefCount(X_ATTR_Signature);
-    field_Signature_RS.readData(count);
-    CHECK;
-
-    ad.readBandData(X_ATTR_RuntimeVisibleAnnotations);
-    ad.readBandData(X_ATTR_RuntimeInvisibleAnnotations);
-    CHECK;
-
-    ad.readBandData(X_ATTR_RuntimeVisibleTypeAnnotations);
-    ad.readBandData(X_ATTR_RuntimeInvisibleTypeAnnotations);
-    CHECK;
-    break;
-
-  case ATTR_CONTEXT_METHOD:
-
-    code_count = ad.predefCount(METHOD_ATTR_Code);
-    // Code attrs are handled very specially below...
-
-    count = ad.predefCount(METHOD_ATTR_Exceptions);
-    method_Exceptions_N.readData(count);
-    count = method_Exceptions_N.getIntTotal();
-    method_Exceptions_RC.readData(count);
-    CHECK;
-
-    count = ad.predefCount(X_ATTR_Signature);
-    method_Signature_RS.readData(count);
-    CHECK;
-
-    ad.readBandData(X_ATTR_RuntimeVisibleAnnotations);
-    ad.readBandData(X_ATTR_RuntimeInvisibleAnnotations);
-    ad.readBandData(METHOD_ATTR_RuntimeVisibleParameterAnnotations);
-    ad.readBandData(METHOD_ATTR_RuntimeInvisibleParameterAnnotations);
-    ad.readBandData(METHOD_ATTR_AnnotationDefault);
-    CHECK;
-
-    count = ad.predefCount(METHOD_ATTR_MethodParameters);
-    method_MethodParameters_NB.readData(count);
-    count = method_MethodParameters_NB.getIntTotal();
-    method_MethodParameters_name_RUN.readData(count);
-    method_MethodParameters_flag_FH.readData(count);
-    CHECK;
-
-    ad.readBandData(X_ATTR_RuntimeVisibleTypeAnnotations);
-    ad.readBandData(X_ATTR_RuntimeInvisibleTypeAnnotations);
-    CHECK;
-
-    break;
-
-  case ATTR_CONTEXT_CODE:
-    // (keep this code aligned with its brother in unpacker::write_attrs)
-    count = ad.predefCount(CODE_ATTR_StackMapTable);
-    // disable this feature in old archives!
-    if (count != 0 && majver < JAVA6_PACKAGE_MAJOR_VERSION) {
-      abort("undefined StackMapTable attribute (old archive format)");
-      return;
-    }
-    code_StackMapTable_N.readData(count);
-    CHECK;
-    count = code_StackMapTable_N.getIntTotal();
-    code_StackMapTable_frame_T.readData(count);
-    CHECK;
-    // the rest of it depends in a complicated way on frame tags
-    {
-      int fat_frame_count = 0;
-      int offset_count = 0;
-      int type_count = 0;
-      for (int k = 0; k < count; k++) {
-        int tag = code_StackMapTable_frame_T.getByte();
-        if (tag <= 127) {
-          // (64-127)  [(2)]
-          if (tag >= 64)  type_count++;
-        } else if (tag <= 251) {
-          // (247)     [(1)(2)]
-          // (248-251) [(1)]
-          if (tag >= 247)  offset_count++;
-          if (tag == 247)  type_count++;
-        } else if (tag <= 254) {
-          // (252)     [(1)(2)]
-          // (253)     [(1)(2)(2)]
-          // (254)     [(1)(2)(2)(2)]
-          offset_count++;
-          type_count += (tag - 251);
-        } else {
-          // (255)     [(1)NH[(2)]NH[(2)]]
-          fat_frame_count++;
-        }
-      }
-
-      // done pre-scanning frame tags:
-      code_StackMapTable_frame_T.rewind();
-
-      // deal completely with fat frames:
-      offset_count += fat_frame_count;
-      code_StackMapTable_local_N.readData(fat_frame_count);
-      CHECK;
-      type_count += code_StackMapTable_local_N.getIntTotal();
-      code_StackMapTable_stack_N.readData(fat_frame_count);
-      type_count += code_StackMapTable_stack_N.getIntTotal();
-      CHECK;
-      // read the rest:
-      code_StackMapTable_offset.readData(offset_count);
-      code_StackMapTable_T.readData(type_count);
-      CHECK;
-      // (7) [RCH]
-      count = code_StackMapTable_T.getIntCount(7);
-      code_StackMapTable_RC.readData(count);
-      CHECK;
-      // (8) [PH]
-      count = code_StackMapTable_T.getIntCount(8);
-      code_StackMapTable_P.readData(count);
-      CHECK;
-    }
-
-    count = ad.predefCount(CODE_ATTR_LineNumberTable);
-    code_LineNumberTable_N.readData(count);
-    CHECK;
-    count = code_LineNumberTable_N.getIntTotal();
-    code_LineNumberTable_bci_P.readData(count);
-    code_LineNumberTable_line.readData(count);
-    CHECK;
-
-    count = ad.predefCount(CODE_ATTR_LocalVariableTable);
-    code_LocalVariableTable_N.readData(count);
-    CHECK;
-    count = code_LocalVariableTable_N.getIntTotal();
-    code_LocalVariableTable_bci_P.readData(count);
-    code_LocalVariableTable_span_O.readData(count);
-    code_LocalVariableTable_name_RU.readData(count);
-    code_LocalVariableTable_type_RS.readData(count);
-    code_LocalVariableTable_slot.readData(count);
-    CHECK;
-
-    count = ad.predefCount(CODE_ATTR_LocalVariableTypeTable);
-    code_LocalVariableTypeTable_N.readData(count);
-    count = code_LocalVariableTypeTable_N.getIntTotal();
-    code_LocalVariableTypeTable_bci_P.readData(count);
-    code_LocalVariableTypeTable_span_O.readData(count);
-    code_LocalVariableTypeTable_name_RU.readData(count);
-    code_LocalVariableTypeTable_type_RS.readData(count);
-    code_LocalVariableTypeTable_slot.readData(count);
-    CHECK;
-
-    ad.readBandData(X_ATTR_RuntimeVisibleTypeAnnotations);
-    ad.readBandData(X_ATTR_RuntimeInvisibleTypeAnnotations);
-    CHECK;
-
-    break;
-  }
-
-  // Read compressor-defined bands.
-  for (idx = 0; idx < ad.layouts.length(); idx++) {
-    if (ad.getLayout(idx) == null)
-      continue;  // none at this fixed index <32
-    if (idx < (int)ad.flag_limit && ad.isPredefined(idx))
-      continue;  // already handled
-    if (ad.getCount(idx) == 0)
-      continue;  // no attributes of this type (then why transmit layouts?)
-    ad.readBandData(idx);
-  }
-}
-
-void unpacker::attr_definitions::readBandData(int idx) {
-  int j;
-  uint count = getCount(idx);
-  if (count == 0)  return;
-  layout_definition* lo = getLayout(idx);
-  if (lo != null) {
-    PRINTCR((1, "counted %d [redefined = %d predefined = %d] attributes of type %s.%s",
-            count, isRedefined(idx), isPredefined(idx),
-            ATTR_CONTEXT_NAME[attrc], lo->name));
-  }
-  bool hasCallables = lo->hasCallables();
-  band** bands = lo->bands();
-  if (!hasCallables) {
-    // Read through the rest of the bands in a regular way.
-    readBandData(bands, count);
-  } else {
-    // Deal with the callables.
-    // First set up the forward entry count for each callable.
-    // This is stored on band::length of the callable.
-    bands[0]->expectMoreLength(count);
-    for (j = 0; bands[j] != null; j++) {
-      band& j_cble = *bands[j];
-      assert(j_cble.le_kind == EK_CBLE);
-      if (j_cble.le_back) {
-        // Add in the predicted effects of backward calls, too.
-        int back_calls = xxx_attr_calls().getInt();
-        j_cble.expectMoreLength(back_calls);
-        // In a moment, more forward calls may increment j_cble.length.
-      }
-    }
-    // Now consult whichever callables have non-zero entry counts.
-    readBandData(bands, (uint)-1);
-  }
-}
-
-// Recursive helper to the previous function:
-void unpacker::attr_definitions::readBandData(band** body, uint count) {
-  int j, k;
-  for (j = 0; body[j] != null; j++) {
-    band& b = *body[j];
-    if (b.defc != null) {
-      // It has data, so read it.
-      b.readData(count);
-    }
-    switch (b.le_kind) {
-    case EK_REPL:
-      {
-        int reps = b.getIntTotal();
-        readBandData(b.le_body, reps);
-      }
-      break;
-    case EK_UN:
-      {
-        int remaining = count;
-        for (k = 0; b.le_body[k] != null; k++) {
-          band& k_case = *b.le_body[k];
-          int   k_count = 0;
-          if (k_case.le_casetags == null) {
-            k_count = remaining;  // last (empty) case
-          } else {
-            int* tags = k_case.le_casetags;
-            int ntags = *tags++;  // 1st element is length (why not?)
-            while (ntags-- > 0) {
-              int tag = *tags++;
-              k_count += b.getIntCount(tag);
-            }
-          }
-          readBandData(k_case.le_body, k_count);
-          remaining -= k_count;
-        }
-        assert(remaining == 0);
-      }
-      break;
-    case EK_CALL:
-      // Push the count forward, if it is not a backward call.
-      if (!b.le_back) {
-        band& cble = *b.le_body[0];
-        assert(cble.le_kind == EK_CBLE);
-        cble.expectMoreLength(count);
-      }
-      break;
-    case EK_CBLE:
-      assert((int)count == -1);  // incoming count is meaningless
-      k = b.length;
-      assert(k >= 0);
-      // This is intended and required for non production mode.
-      assert((b.length = -1)); // make it unable to accept more calls now.
-      readBandData(b.le_body, k);
-      break;
-    }
-  }
-}
-
-static inline
-band** findMatchingCase(int matchTag, band** cases) {
-  for (int k = 0; cases[k] != null; k++) {
-    band& k_case = *cases[k];
-    if (k_case.le_casetags != null) {
-      // If it has tags, it must match a tag.
-      int* tags = k_case.le_casetags;
-      int ntags = *tags++;  // 1st element is length
-      for (; ntags > 0; ntags--) {
-        int tag = *tags++;
-        if (tag == matchTag)
-          break;
-      }
-      if (ntags == 0)
-        continue;   // does not match
-    }
-    return k_case.le_body;
-  }
-  return null;
-}
-
-// write attribute band data:
-void unpacker::putlayout(band** body) {
-  int i;
-  int prevBII = -1;
-  int prevBCI = -1;
-  if (body == NULL) {
-    abort("putlayout: unexpected NULL for body");
-    return;
-  }
-  for (i = 0; body[i] != null; i++) {
-    band& b = *body[i];
-    byte le_kind = b.le_kind;
-
-    // Handle scalar part, if any.
-    int    x = 0;
-    entry* e = null;
-    if (b.defc != null) {
-      // It has data, so unparse an element.
-      if (b.ixTag != CONSTANT_None) {
-        assert(le_kind == EK_REF);
-        if (b.ixTag == CONSTANT_FieldSpecific)
-          e = b.getRefUsing(cp.getKQIndex());
-        else
-          e = b.getRefN();
-        CHECK;
-        switch (b.le_len) {
-        case 0: break;
-        case 1: putu1ref(e); break;
-        case 2: putref(e); break;
-        case 4: putu2(0); putref(e); break;
-        default: assert(false);
-        }
-      } else {
-        assert(le_kind == EK_INT || le_kind == EK_REPL || le_kind == EK_UN);
-        x = b.getInt();
-
-        assert(!b.le_bci || prevBCI == (int)to_bci(prevBII));
-        switch (b.le_bci) {
-        case EK_BCI:   // PH:  transmit R(bci), store bci
-          x = to_bci(prevBII = x);
-          prevBCI = x;
-          break;
-        case EK_BCID:  // POH: transmit D(R(bci)), store bci
-          x = to_bci(prevBII += x);
-          prevBCI = x;
-          break;
-        case EK_BCO:   // OH:  transmit D(R(bci)), store D(bci)
-          x = to_bci(prevBII += x) - prevBCI;
-          prevBCI += x;
-          break;
-        }
-        assert(!b.le_bci || prevBCI == (int)to_bci(prevBII));
-
-        switch (b.le_len) {
-        case 0: break;
-        case 1: putu1(x); break;
-        case 2: putu2(x); break;
-        case 4: putu4(x); break;
-        default: assert(false);
-        }
-      }
-    }
-
-    // Handle subparts, if any.
-    switch (le_kind) {
-    case EK_REPL:
-      // x is the repeat count
-      while (x-- > 0) {
-        putlayout(b.le_body);
-      }
-      break;
-    case EK_UN:
-      // x is the tag
-      putlayout(findMatchingCase(x, b.le_body));
-      break;
-    case EK_CALL:
-      {
-        band& cble = *b.le_body[0];
-        assert(cble.le_kind == EK_CBLE);
-        assert(cble.le_len == b.le_len);
-        putlayout(cble.le_body);
-      }
-      break;
-
-    #ifndef PRODUCT
-    case EK_CBLE:
-    case EK_CASE:
-      assert(false);  // should not reach here
-    #endif
-    }
-  }
-}
-
-void unpacker::read_files() {
-  file_name.readData(file_count);
-  if (testBit(archive_options, AO_HAVE_FILE_SIZE_HI))
-    file_size_hi.readData(file_count);
-  file_size_lo.readData(file_count);
-  if (testBit(archive_options, AO_HAVE_FILE_MODTIME))
-    file_modtime.readData(file_count);
-  int allFiles = file_count + class_count;
-  if (testBit(archive_options, AO_HAVE_FILE_OPTIONS)) {
-    file_options.readData(file_count);
-    // FO_IS_CLASS_STUB might be set, causing overlap between classes and files
-    for (int i = 0; i < file_count; i++) {
-      if ((file_options.getInt() & FO_IS_CLASS_STUB) != 0) {
-        allFiles -= 1;  // this one counts as both class and file
-      }
-    }
-    file_options.rewind();
-  }
-  assert((default_file_options & FO_IS_CLASS_STUB) == 0);
-  files_remaining = allFiles;
-}
-
-maybe_inline
-void unpacker::get_code_header(int& max_stack,
-                               int& max_na_locals,
-                               int& handler_count,
-                               int& cflags) {
-  int sc = code_headers.getByte();
-  if (sc == 0) {
-    max_stack = max_na_locals = handler_count = cflags = -1;
-    return;
-  }
-  // Short code header is the usual case:
-  int nh;
-  int mod;
-  if (sc < 1 + 12*12) {
-    sc -= 1;
-    nh = 0;
-    mod = 12;
-  } else if (sc < 1 + 12*12 + 8*8) {
-    sc -= 1 + 12*12;
-    nh = 1;
-    mod = 8;
-  } else {
-    assert(sc < 1 + 12*12 + 8*8 + 7*7);
-    sc -= 1 + 12*12 + 8*8;
-    nh = 2;
-    mod = 7;
-  }
-  max_stack     = sc % mod;
-  max_na_locals = sc / mod;  // caller must add static, siglen
-  handler_count = nh;
-  if (testBit(archive_options, AO_HAVE_ALL_CODE_FLAGS))
-    cflags      = -1;
-  else
-    cflags      = 0;  // this one has no attributes
-}
-
-// Cf. PackageReader.readCodeHeaders
-void unpacker::read_code_headers() {
-  code_headers.readData(code_count);
-  CHECK;
-  int totalHandlerCount = 0;
-  int totalFlagsCount   = 0;
-  for (int i = 0; i < code_count; i++) {
-    int max_stack, max_locals, handler_count, cflags;
-    get_code_header(max_stack, max_locals, handler_count, cflags);
-    if (max_stack < 0)      code_max_stack.expectMoreLength(1);
-    if (max_locals < 0)     code_max_na_locals.expectMoreLength(1);
-    if (handler_count < 0)  code_handler_count.expectMoreLength(1);
-    else                    totalHandlerCount += handler_count;
-    if (cflags < 0)         totalFlagsCount += 1;
-  }
-  code_headers.rewind();  // replay later during writing
-
-  code_max_stack.readData();
-  code_max_na_locals.readData();
-  code_handler_count.readData();
-  totalHandlerCount += code_handler_count.getIntTotal();
-  CHECK;
-
-  // Read handler specifications.
-  // Cf. PackageReader.readCodeHandlers.
-  code_handler_start_P.readData(totalHandlerCount);
-  code_handler_end_PO.readData(totalHandlerCount);
-  code_handler_catch_PO.readData(totalHandlerCount);
-  code_handler_class_RCN.readData(totalHandlerCount);
-  CHECK;
-
-  read_attrs(ATTR_CONTEXT_CODE, totalFlagsCount);
-  CHECK;
-}
-
-static inline bool is_in_range(uint n, uint min, uint max) {
-  return n - min <= max - min;  // unsigned arithmetic!
-}
-static inline bool is_field_op(int bc) {
-  return is_in_range(bc, bc_getstatic, bc_putfield);
-}
-static inline bool is_invoke_init_op(int bc) {
-  return is_in_range(bc, _invokeinit_op, _invokeinit_limit-1);
-}
-static inline bool is_self_linker_op(int bc) {
-  return is_in_range(bc, _self_linker_op, _self_linker_limit-1);
-}
-static bool is_branch_op(int bc) {
-  return is_in_range(bc, bc_ifeq,   bc_jsr)
-      || is_in_range(bc, bc_ifnull, bc_jsr_w);
-}
-static bool is_local_slot_op(int bc) {
-  return is_in_range(bc, bc_iload,  bc_aload)
-      || is_in_range(bc, bc_istore, bc_astore)
-      || bc == bc_iinc || bc == bc_ret;
-}
-band* unpacker::ref_band_for_op(int bc) {
-  switch (bc) {
-  case bc_ildc:
-  case bc_ildc_w:
-    return &bc_intref;
-  case bc_fldc:
-  case bc_fldc_w:
-    return &bc_floatref;
-  case bc_lldc2_w:
-    return &bc_longref;
-  case bc_dldc2_w:
-    return &bc_doubleref;
-  case bc_sldc:
-  case bc_sldc_w:
-    return &bc_stringref;
-  case bc_cldc:
-  case bc_cldc_w:
-    return &bc_classref;
-  case bc_qldc: case bc_qldc_w:
-    return &bc_loadablevalueref;
-
-  case bc_getstatic:
-  case bc_putstatic:
-  case bc_getfield:
-  case bc_putfield:
-    return &bc_fieldref;
-
-  case _invokespecial_int:
-  case _invokestatic_int:
-    return &bc_imethodref;
-  case bc_invokevirtual:
-  case bc_invokespecial:
-  case bc_invokestatic:
-    return &bc_methodref;
-  case bc_invokeinterface:
-    return &bc_imethodref;
-  case bc_invokedynamic:
-    return &bc_indyref;
-
-  case bc_new:
-  case bc_anewarray:
-  case bc_checkcast:
-  case bc_instanceof:
-  case bc_multianewarray:
-    return &bc_classref;
-  }
-  return null;
-}
-
-maybe_inline
-band* unpacker::ref_band_for_self_op(int bc, bool& isAloadVar, int& origBCVar) {
-  if (!is_self_linker_op(bc))  return null;
-  int idx = (bc - _self_linker_op);
-  bool isSuper = (idx >= _self_linker_super_flag);
-  if (isSuper)  idx -= _self_linker_super_flag;
-  bool isAload = (idx >= _self_linker_aload_flag);
-  if (isAload)  idx -= _self_linker_aload_flag;
-  int origBC = _first_linker_op + idx;
-  bool isField = is_field_op(origBC);
-  isAloadVar = isAload;
-  origBCVar  = _first_linker_op + idx;
-  if (!isSuper)
-    return isField? &bc_thisfield: &bc_thismethod;
-  else
-    return isField? &bc_superfield: &bc_supermethod;
-}
-
-// Cf. PackageReader.readByteCodes
-inline  // called exactly once => inline
-void unpacker::read_bcs() {
-  PRINTCR((3, "reading compressed bytecodes and operands for %d codes...",
-          code_count));
-
-  // read from bc_codes and bc_case_count
-  fillbytes all_switch_ops;
-  all_switch_ops.init();
-  CHECK;
-
-  // Read directly from rp/rplimit.
-  //Do this later:  bc_codes.readData(...)
-  byte* rp0 = rp;
-
-  band* bc_which;
-  byte* opptr = rp;
-  byte* oplimit = rplimit;
-
-  bool  isAload;  // passed by ref and then ignored
-  int   junkBC;   // passed by ref and then ignored
-  for (int k = 0; k < code_count; k++) {
-    // Scan one method:
-    for (;;) {
-      if (opptr+2 > oplimit) {
-        rp = opptr;
-        ensure_input(2);
-        oplimit = rplimit;
-        rp = rp0;  // back up
-      }
-      if (opptr == oplimit) { abort(); break; }
-      int bc = *opptr++ & 0xFF;
-      bool isWide = false;
-      if (bc == bc_wide) {
-        if (opptr == oplimit) { abort(); break; }
-        bc = *opptr++ & 0xFF;
-        isWide = true;
-      }
-      // Adjust expectations of various band sizes.
-      switch (bc) {
-      case bc_tableswitch:
-      case bc_lookupswitch:
-        all_switch_ops.addByte(bc);
-        break;
-      case bc_iinc:
-        bc_local.expectMoreLength(1);
-        bc_which = isWide ? &bc_short : &bc_byte;
-        bc_which->expectMoreLength(1);
-        break;
-      case bc_sipush:
-        bc_short.expectMoreLength(1);
-        break;
-      case bc_bipush:
-        bc_byte.expectMoreLength(1);
-        break;
-      case bc_newarray:
-        bc_byte.expectMoreLength(1);
-        break;
-      case bc_multianewarray:
-        assert(ref_band_for_op(bc) == &bc_classref);
-        bc_classref.expectMoreLength(1);
-        bc_byte.expectMoreLength(1);
-        break;
-      case bc_ref_escape:
-        bc_escrefsize.expectMoreLength(1);
-        bc_escref.expectMoreLength(1);
-        break;
-      case bc_byte_escape:
-        bc_escsize.expectMoreLength(1);
-        // bc_escbyte will have to be counted too
-        break;
-      default:
-        if (is_invoke_init_op(bc)) {
-          bc_initref.expectMoreLength(1);
-          break;
-        }
-        bc_which = ref_band_for_self_op(bc, isAload, junkBC);
-        if (bc_which != null) {
-          bc_which->expectMoreLength(1);
-          break;
-        }
-        if (is_branch_op(bc)) {
-          bc_label.expectMoreLength(1);
-          break;
-        }
-        bc_which = ref_band_for_op(bc);
-        if (bc_which != null) {
-          bc_which->expectMoreLength(1);
-          assert(bc != bc_multianewarray);  // handled elsewhere
-          break;
-        }
-        if (is_local_slot_op(bc)) {
-          bc_local.expectMoreLength(1);
-          break;
-        }
-        break;
-      case bc_end_marker:
-        // Increment k and test against code_count.
-        goto doneScanningMethod;
-      }
-    }
-  doneScanningMethod:{}
-    if (aborting())  break;
-  }
-
-  // Go through the formality, so we can use it in a regular fashion later:
-  assert(rp == rp0);
-  bc_codes.readData((int)(opptr - rp));
-
-  int i = 0;
-
-  // To size instruction bands correctly, we need info on switches:
-  bc_case_count.readData((int)all_switch_ops.size());
-  for (i = 0; i < (int)all_switch_ops.size(); i++) {
-    int caseCount = bc_case_count.getInt();
-    int bc        = all_switch_ops.getByte(i);
-    bc_label.expectMoreLength(1+caseCount); // default label + cases
-    bc_case_value.expectMoreLength(bc == bc_tableswitch ? 1 : caseCount);
-    PRINTCR((2, "switch bc=%d caseCount=%d", bc, caseCount));
-  }
-  bc_case_count.rewind();  // uses again for output
-
-  all_switch_ops.free();
-
-  for (i = e_bc_case_value; i <= e_bc_escsize; i++) {
-    all_bands[i].readData();
-  }
-
-  // The bc_escbyte band is counted by the immediately previous band.
-  bc_escbyte.readData(bc_escsize.getIntTotal());
-
-  PRINTCR((3, "scanned %d opcode and %d operand bytes for %d codes...",
-          (int)(bc_codes.size()),
-          (int)(bc_escsize.maxRP() - bc_case_value.minRP()),
-          code_count));
-}
-
-void unpacker::read_bands() {
-  byte* rp0 = rp;
-  CHECK;
-  read_file_header();
-  CHECK;
-
-  if (cp.nentries == 0) {
-    // read_file_header failed to read a CP, because it copied a JAR.
-    return;
-  }
-
-  // Do this after the file header has been read:
-  check_options();
-
-  read_cp();
-  CHECK;
-  read_attr_defs();
-  CHECK;
-  read_ics();
-  CHECK;
-  read_classes();
-  CHECK;
-  read_bcs();
-  CHECK;
-  read_files();
-}
-
-/// CP routines
-
-entry*& cpool::hashTabRef(byte tag, bytes& b) {
-  PRINTCR((5, "hashTabRef tag=%d %s[%d]", tag, b.string(), b.len));
-  uint hash = tag + (int)b.len;
-  for (int i = 0; i < (int)b.len; i++) {
-    hash = hash * 31 + (0xFF & b.ptr[i]);
-  }
-  entry**  ht = hashTab;
-  int    hlen = hashTabLength;
-  assert((hlen & (hlen-1)) == 0);  // must be power of 2
-  uint hash1 = hash & (hlen-1);    // == hash % hlen
-  uint hash2 = 0;                  // lazily computed (requires mod op.)
-  int probes = 0;
-  while (ht[hash1] != null) {
-    entry& e = *ht[hash1];
-    if (e.value.b.equals(b) && e.tag == tag)
-      break;
-    if (hash2 == 0)
-      // Note:  hash2 must be relatively prime to hlen, hence the "|1".
-      hash2 = (((hash % 499) & (hlen-1)) | 1);
-    hash1 += hash2;
-    if (hash1 >= (uint)hlen)  hash1 -= hlen;
-    assert(hash1 < (uint)hlen);
-    assert(++probes < hlen);
-  }
-  #ifndef PRODUCT
-  hash_probes[0] += 1;
-  hash_probes[1] += probes;
-  #endif
-  PRINTCR((5, " => @%d %p", hash1, ht[hash1]));
-  return ht[hash1];
-}
-
-maybe_inline
-static void insert_extra(entry* e, ptrlist& extras) {
-  // This ordering helps implement the Pack200 requirement
-  // of a predictable CP order in the class files produced.
-  e->inord = NO_INORD;  // mark as an "extra"
-  extras.add(e);
-  // Note:  We will sort the list (by string-name) later.
-}
-
-entry* cpool::ensureUtf8(bytes& b) {
-  entry*& ix = hashTabRef(CONSTANT_Utf8, b);
-  if (ix != null)  return ix;
-  // Make one.
-  if (nentries == maxentries) {
-    abort("cp utf8 overflow");
-    return &entries[tag_base[CONSTANT_Utf8]];  // return something
-  }
-  entry& e = entries[nentries++];
-  e.tag = CONSTANT_Utf8;
-  u->saveTo(e.value.b, b);
-  assert(&e >= first_extra_entry);
-  insert_extra(&e, tag_extras[CONSTANT_Utf8]);
-  PRINTCR((4,"ensureUtf8 miss %s", e.string()));
-  return ix = &e;
-}
-
-entry* cpool::ensureClass(bytes& b) {
-  entry*& ix = hashTabRef(CONSTANT_Class, b);
-  if (ix != null)  return ix;
-  // Make one.
-  if (nentries == maxentries) {
-    abort("cp class overflow");
-    return &entries[tag_base[CONSTANT_Class]];  // return something
-  }
-  entry& e = entries[nentries++];
-  e.tag = CONSTANT_Class;
-  e.nrefs = 1;
-  e.refs = U_NEW(entry*, 1);
-  ix = &e;  // hold my spot in the index
-  entry* utf = ensureUtf8(b);
-  e.refs[0] = utf;
-  e.value.b = utf->value.b;
-  assert(&e >= first_extra_entry);
-  insert_extra(&e, tag_extras[CONSTANT_Class]);
-  PRINTCR((4,"ensureClass miss %s", e.string()));
-  return &e;
-}
-
-void cpool::expandSignatures() {
-  int i;
-  int nsigs = 0;
-  int nreused = 0;
-  int first_sig = tag_base[CONSTANT_Signature];
-  int sig_limit = tag_count[CONSTANT_Signature] + first_sig;
-  fillbytes buf;
-  buf.init(1<<10);
-  CHECK;
-  for (i = first_sig; i < sig_limit; i++) {
-    entry& e = entries[i];
-    assert(e.tag == CONSTANT_Signature);
-    int refnum = 0;
-    bytes form = e.refs[refnum++]->asUtf8();
-    buf.empty();
-    for (int j = 0; j < (int)form.len; j++) {
-      int c = form.ptr[j];
-      buf.addByte(c);
-      if (c == 'L') {
-        entry* cls = e.refs[refnum++];
-        buf.append(cls->className()->asUtf8());
-      }
-    }
-    assert(refnum == e.nrefs);
-    bytes& sig = buf.b;
-    PRINTCR((5,"signature %d %s -> %s", i, form.ptr, sig.ptr));
-
-    // try to find a pre-existing Utf8:
-    entry* &e2 = hashTabRef(CONSTANT_Utf8, sig);
-    if (e2 != null) {
-      assert(e2->isUtf8(sig));
-      e.value.b = e2->value.b;
-      e.refs[0] = e2;
-      e.nrefs = 1;
-      PRINTCR((5,"signature replaced %d => %s", i, e.string()));
-      nreused++;
-    } else {
-      // there is no other replacement; reuse this CP entry as a Utf8
-      u->saveTo(e.value.b, sig);
-      e.tag = CONSTANT_Utf8;
-      e.nrefs = 0;
-      e2 = &e;
-      PRINTCR((5,"signature changed %d => %s", e.inord, e.string()));
-    }
-    nsigs++;
-  }
-  PRINTCR((1,"expanded %d signatures (reused %d utfs)", nsigs, nreused));
-  buf.free();
-
-  // go expunge all references to remaining signatures:
-  for (i = 0; i < (int)nentries; i++) {
-    entry& e = entries[i];
-    for (int j = 0; j < e.nrefs; j++) {
-      entry*& e2 = e.refs[j];
-      if (e2 != null && e2->tag == CONSTANT_Signature)
-        e2 = e2->refs[0];
-    }
-  }
-}
-
-bool isLoadableValue(int tag) {
-  switch(tag) {
-    case CONSTANT_Integer:
-    case CONSTANT_Float:
-    case CONSTANT_Long:
-    case CONSTANT_Double:
-    case CONSTANT_String:
-    case CONSTANT_Class:
-    case CONSTANT_MethodHandle:
-    case CONSTANT_MethodType:
-      return true;
-    default:
-      return false;
-  }
-}
-/*
- * this method can be used to size an array using null as the parameter,
- * thereafter can be reused to initialize the array using a valid pointer
- * as a parameter.
- */
-int cpool::initLoadableValues(entry** loadable_entries) {
-  int loadable_count = 0;
-  for (int i = 0; i < (int)N_TAGS_IN_ORDER; i++) {
-    int tag = TAGS_IN_ORDER[i];
-    if (!isLoadableValue(tag))
-      continue;
-    if (loadable_entries != NULL) {
-      for (int n = 0 ; n < tag_count[tag] ; n++) {
-        loadable_entries[loadable_count + n] = &entries[tag_base[tag] + n];
-      }
-    }
-    loadable_count += tag_count[tag];
-  }
-  return loadable_count;
-}
-
-// Initialize various views into the constant pool.
-void cpool::initGroupIndexes() {
-  // Initialize All
-  int all_count = 0;
-  for (int tag = CONSTANT_None ; tag < CONSTANT_Limit ; tag++) {
-    all_count += tag_count[tag];
-  }
-  entry* all_entries = &entries[tag_base[CONSTANT_None]];
-  tag_group_count[CONSTANT_All - CONSTANT_All] = all_count;
-  tag_group_index[CONSTANT_All - CONSTANT_All].init(all_count, all_entries, CONSTANT_All);
-
-  // Initialize LoadableValues
-  int loadable_count = initLoadableValues(NULL);
-  entry** loadable_entries = U_NEW(entry*, loadable_count);
-  initLoadableValues(loadable_entries);
-  tag_group_count[CONSTANT_LoadableValue - CONSTANT_All] = loadable_count;
-  tag_group_index[CONSTANT_LoadableValue - CONSTANT_All].init(loadable_count,
-                  loadable_entries, CONSTANT_LoadableValue);
-
-// Initialize AnyMembers
-  int any_count = tag_count[CONSTANT_Fieldref] +
-                  tag_count[CONSTANT_Methodref] +
-                  tag_count[CONSTANT_InterfaceMethodref];
-  entry *any_entries = &entries[tag_base[CONSTANT_Fieldref]];
-  tag_group_count[CONSTANT_AnyMember - CONSTANT_All] = any_count;
-  tag_group_index[CONSTANT_AnyMember - CONSTANT_All].init(any_count,
-                                               any_entries, CONSTANT_AnyMember);
-}
-
-void cpool::initMemberIndexes() {
-  // This function does NOT refer to any class schema.
-  // It is totally internal to the cpool.
-  int i, j;
-
-  // Get the pre-existing indexes:
-  int   nclasses = tag_count[CONSTANT_Class];
-  entry* classes = tag_base[CONSTANT_Class] + entries;
-  int   nfields  = tag_count[CONSTANT_Fieldref];
-  entry* fields  = tag_base[CONSTANT_Fieldref] + entries;
-  int   nmethods = tag_count[CONSTANT_Methodref];
-  entry* methods = tag_base[CONSTANT_Methodref] + entries;
-
-  int*     field_counts  = T_NEW(int, nclasses);
-  int*     method_counts = T_NEW(int, nclasses);
-  cpindex* all_indexes   = U_NEW(cpindex, nclasses*2);
-  entry**  field_ix      = U_NEW(entry*, add_size(nfields, nclasses));
-  entry**  method_ix     = U_NEW(entry*, add_size(nmethods, nclasses));
-
-  for (j = 0; j < nfields; j++) {
-    entry& f = fields[j];
-    i = f.memberClass()->inord;
-    assert(i < nclasses);
-    field_counts[i]++;
-  }
-  for (j = 0; j < nmethods; j++) {
-    entry& m = methods[j];
-    i = m.memberClass()->inord;
-    assert(i < nclasses);
-    method_counts[i]++;
-  }
-
-  int fbase = 0, mbase = 0;
-  for (i = 0; i < nclasses; i++) {
-    int fc = field_counts[i];
-    int mc = method_counts[i];
-    all_indexes[i*2+0].init(fc, field_ix+fbase,
-                            CONSTANT_Fieldref  + SUBINDEX_BIT);
-    all_indexes[i*2+1].init(mc, method_ix+mbase,
-                            CONSTANT_Methodref + SUBINDEX_BIT);
-    // reuse field_counts and member_counts as fill pointers:
-    field_counts[i] = fbase;
-    method_counts[i] = mbase;
-    PRINTCR((3, "class %d fields @%d[%d] methods @%d[%d]",
-            i, fbase, fc, mbase, mc));
-    fbase += fc+1;
-    mbase += mc+1;
-    // (the +1 leaves a space between every subarray)
-  }
-  assert(fbase == nfields+nclasses);
-  assert(mbase == nmethods+nclasses);
-
-  for (j = 0; j < nfields; j++) {
-    entry& f = fields[j];
-    i = f.memberClass()->inord;
-    field_ix[field_counts[i]++] = &f;
-  }
-  for (j = 0; j < nmethods; j++) {
-    entry& m = methods[j];
-    i = m.memberClass()->inord;
-    method_ix[method_counts[i]++] = &m;
-  }
-
-  member_indexes = all_indexes;
-
-#ifndef PRODUCT
-  // Test the result immediately on every class and field.
-  int fvisited = 0, mvisited = 0;
-  int prevord, len;
-  for (i = 0; i < nclasses; i++) {
-    entry*   cls = &classes[i];
-    cpindex* fix = getFieldIndex(cls);
-    cpindex* mix = getMethodIndex(cls);
-    PRINTCR((2, "field and method index for %s [%d] [%d]",
-            cls->string(), mix->len, fix->len));
-    prevord = -1;
-    for (j = 0, len = fix->len; j < len; j++) {
-      entry* f = fix->get(j);
-      assert(f != null);
-      PRINTCR((3, "- field %s", f->string()));
-      assert(f->memberClass() == cls);
-      assert(prevord < (int)f->inord);
-      prevord = f->inord;
-      fvisited++;
-    }
-    assert(fix->base2[j] == null);
-    prevord = -1;
-    for (j = 0, len = mix->len; j < len; j++) {
-      entry* m = mix->get(j);
-      assert(m != null);
-      PRINTCR((3, "- method %s", m->string()));
-      assert(m->memberClass() == cls);
-      assert(prevord < (int)m->inord);
-      prevord = m->inord;
-      mvisited++;
-    }
-    assert(mix->base2[j] == null);
-  }
-  assert(fvisited == nfields);
-  assert(mvisited == nmethods);
-#endif
-
-  // Free intermediate buffers.
-  u->free_temps();
-}
-
-void entry::requestOutputIndex(cpool& cp, int req) {
-  assert(outputIndex <= REQUESTED_NONE);  // must not have assigned indexes yet
-  if (tag == CONSTANT_Signature) {
-    ref(0)->requestOutputIndex(cp, req);
-    return;
-  }
-  assert(req == REQUESTED || req == REQUESTED_LDC);
-  if (outputIndex != REQUESTED_NONE) {
-    if (req == REQUESTED_LDC)
-      outputIndex = req;  // this kind has precedence
-    return;
-  }
-  outputIndex = req;
-  //assert(!cp.outputEntries.contains(this));
-  assert(tag != CONSTANT_Signature);
-  // The BSMs are jetisoned to a side table, however all references
-  // that the BSMs refer to,  need to be considered.
-  if (tag == CONSTANT_BootstrapMethod) {
-    // this is a a pseudo-op entry; an attribute will be generated later on
-    cp.requested_bsms.add(this);
-  } else {
-    // all other tag types go into real output file CP:
-    cp.outputEntries.add(this);
-  }
-  for (int j = 0; j < nrefs; j++) {
-    ref(j)->requestOutputIndex(cp);
-  }
-}
-
-void cpool::resetOutputIndexes() {
-    /*
-     * reset those few entries that are being used in the current class
-     * (Caution since this method is called after every class written, a loop
-     * over every global constant pool entry would be a quadratic cost.)
-     */
-
-  int noes    = outputEntries.length();
-  entry** oes = (entry**) outputEntries.base();
-  for (int i = 0 ; i < noes ; i++) {
-    entry& e = *oes[i];
-    e.outputIndex = REQUESTED_NONE;
-  }
-
-  // do the same for bsms and reset them if required
-  int nbsms = requested_bsms.length();
-  entry** boes = (entry**) requested_bsms.base();
-  for (int i = 0 ; i < nbsms ; i++) {
-    entry& e = *boes[i];
-    e.outputIndex = REQUESTED_NONE;
-  }
-  outputIndexLimit = 0;
-  outputEntries.empty();
-#ifndef PRODUCT
-  // ensure things are cleared out
-  for (int i = 0; i < (int)maxentries; i++)
-    assert(entries[i].outputIndex == REQUESTED_NONE);
-#endif
-}
-
-static const byte TAG_ORDER[CONSTANT_Limit] = {
-  0, 1, 0, 2, 3, 4, 5, 7, 6, 10, 11, 12, 9, 8, 0, 13, 14, 15, 16
-};
-
-extern "C"
-int outputEntry_cmp(const void* e1p, const void* e2p) {
-  // Sort entries according to the Pack200 rules for deterministic
-  // constant pool ordering.
-  //
-  // The four sort keys as follows, in order of decreasing importance:
-  //   1. ldc first, then non-ldc guys
-  //   2. normal cp_All entries by input order (i.e., address order)
-  //   3. after that, extra entries by lexical order (as in tag_extras[*])
-  entry& e1 = *(entry*) *(void**) e1p;
-  entry& e2 = *(entry*) *(void**) e2p;
-  int   oi1 = e1.outputIndex;
-  int   oi2 = e2.outputIndex;
-  assert(oi1 == REQUESTED || oi1 == REQUESTED_LDC);
-  assert(oi2 == REQUESTED || oi2 == REQUESTED_LDC);
-  if (oi1 != oi2) {
-    if (oi1 == REQUESTED_LDC)  return 0-1;
-    if (oi2 == REQUESTED_LDC)  return 1-0;
-    // Else fall through; neither is an ldc request.
-  }
-  if (e1.inord != NO_INORD || e2.inord != NO_INORD) {
-    // One or both is normal.  Use input order.
-    if (&e1 > &e2)  return 1-0;
-    if (&e1 < &e2)  return 0-1;
-    return 0;  // equal pointers
-  }
-  // Both are extras.  Sort by tag and then by value.
-  if (e1.tag != e2.tag) {
-    return TAG_ORDER[e1.tag] - TAG_ORDER[e2.tag];
-  }
-  // If the tags are the same, use string comparison.
-  return compare_Utf8_chars(e1.value.b, e2.value.b);
-}
-
-void cpool::computeOutputIndexes() {
-  int i;
-
-#ifndef PRODUCT
-  // outputEntries must be a complete list of those requested:
-  static uint checkStart = 0;
-  int checkStep = 1;
-  if (nentries > 100)  checkStep = nentries / 100;
-  for (i = (int)(checkStart++ % checkStep); i < (int)nentries; i += checkStep) {
-    entry& e = entries[i];
-    if (e.tag == CONSTANT_BootstrapMethod) {
-      if (e.outputIndex != REQUESTED_NONE) {
-        assert(requested_bsms.contains(&e));
-      } else {
-        assert(!requested_bsms.contains(&e));
-      }
-    } else {
-      if (e.outputIndex != REQUESTED_NONE) {
-        assert(outputEntries.contains(&e));
-      } else {
-        assert(!outputEntries.contains(&e));
-      }
-    }
-  }
-
-  // check hand-initialization of TAG_ORDER
-  for (i = 0; i < (int)N_TAGS_IN_ORDER; i++) {
-    byte tag = TAGS_IN_ORDER[i];
-    assert(TAG_ORDER[tag] == i+1);
-  }
-#endif
-
-  int    noes =           outputEntries.length();
-  entry** oes = (entry**) outputEntries.base();
-
-  // Sort the output constant pool into the order required by Pack200.
-  PTRLIST_QSORT(outputEntries, outputEntry_cmp);
-
-  // Allocate a new index for each entry that needs one.
-  // We do this in two passes, one for LDC entries and one for the rest.
-  int nextIndex = 1;  // always skip index #0 in output cpool
-  for (i = 0; i < noes; i++) {
-    entry& e = *oes[i];
-    assert(e.outputIndex >= REQUESTED_LDC);
-    e.outputIndex = nextIndex++;
-    if (e.isDoubleWord())  nextIndex++;  // do not use the next index
-  }
-  outputIndexLimit = nextIndex;
-  PRINTCR((3,"renumbering CP to %d entries", outputIndexLimit));
-}
-
-#ifndef PRODUCT
-// debugging goo
-
-unpacker* debug_u;
-
-static bytes& getbuf(int len) {  // for debugging only!
-  static int bn = 0;
-  static bytes bufs[8];
-  bytes& buf = bufs[bn++ & 7];
-  while ((int)buf.len < len+10)
-    buf.realloc(buf.len ? buf.len * 2 : 1000);
-  buf.ptr[0] = 0;  // for the sake of strcat
-  return buf;
-}
-
-char* entry::string() {
-  bytes buf;
-  switch (tag) {
-  case CONSTANT_None:
-    return (char*)"<empty>";
-  case CONSTANT_Signature:
-    if (value.b.ptr == null)
-      return ref(0)->string();
-    // else fall through:
-  case CONSTANT_Utf8:
-    buf = value.b;
-    break;
-  case CONSTANT_Integer:
-  case CONSTANT_Float:
-    buf = getbuf(12);
-    sprintf((char*)buf.ptr, "0x%08x", value.i);
-    break;
-  case CONSTANT_Long:
-  case CONSTANT_Double:
-    buf = getbuf(24);
-    sprintf((char*)buf.ptr, "0x" LONG_LONG_HEX_FORMAT, value.l);
-    break;
-  default:
-    if (nrefs == 0) {
-      buf = getbuf(20);
-      sprintf((char*)buf.ptr, TAG_NAME[tag]);
-    } else if (nrefs == 1) {
-      return refs[0]->string();
-    } else {
-      char* s1 = refs[0]->string();
-      char* s2 = refs[1]->string();
-      buf = getbuf((int)strlen(s1) + 1 + (int)strlen(s2) + 4 + 1);
-      buf.strcat(s1).strcat(" ").strcat(s2);
-      if (nrefs > 2)  buf.strcat(" ...");
-    }
-  }
-  return (char*)buf.ptr;
-}
-
-void print_cp_entry(int i) {
-  entry& e = debug_u->cp.entries[i];
-  char buf[30];
-  sprintf(buf, ((uint)e.tag < CONSTANT_Limit)? TAG_NAME[e.tag]: "%d", e.tag);
-  printf(" %d\t%s %s\n", i, buf, e.string());
-}
-
-void print_cp_entries(int beg, int end) {
-  for (int i = beg; i < end; i++)
-    print_cp_entry(i);
-}
-
-void print_cp() {
-  print_cp_entries(0, debug_u->cp.nentries);
-}
-
-#endif
-
-// Unpacker Start
-
-const char str_tf[] = "true\0false";
-#undef STR_TRUE
-#undef STR_FALSE
-#define STR_TRUE   (&str_tf[0])
-#define STR_FALSE  (&str_tf[5])
-
-const char* unpacker::get_option(const char* prop) {
-  if (prop == null )  return null;
-  if (strcmp(prop, UNPACK_DEFLATE_HINT) == 0) {
-    return deflate_hint_or_zero == 0? null : STR_TF(deflate_hint_or_zero > 0);
-#ifdef HAVE_STRIP
-  } else if (strcmp(prop, UNPACK_STRIP_COMPILE) == 0) {
-    return STR_TF(strip_compile);
-  } else if (strcmp(prop, UNPACK_STRIP_DEBUG) == 0) {
-    return STR_TF(strip_debug);
-  } else if (strcmp(prop, UNPACK_STRIP_JCOV) == 0) {
-    return STR_TF(strip_jcov);
-#endif /*HAVE_STRIP*/
-  } else if (strcmp(prop, UNPACK_REMOVE_PACKFILE) == 0) {
-    return STR_TF(remove_packfile);
-  } else if (strcmp(prop, DEBUG_VERBOSE) == 0) {
-    return saveIntStr(verbose);
-  } else if (strcmp(prop, UNPACK_MODIFICATION_TIME) == 0) {
-    return (modification_time_or_zero == 0)? null:
-      saveIntStr(modification_time_or_zero);
-  } else if (strcmp(prop, UNPACK_LOG_FILE) == 0) {
-    return log_file;
-  } else {
-    return NULL; // unknown option ignore
-  }
-}
-
-bool unpacker::set_option(const char* prop, const char* value) {
-  if (prop == NULL)  return false;
-  if (strcmp(prop, UNPACK_DEFLATE_HINT) == 0) {
-    deflate_hint_or_zero = ( (value == null || strcmp(value, "keep") == 0)
-                                ? 0: BOOL_TF(value) ? +1: -1);
-#ifdef HAVE_STRIP
-  } else if (strcmp(prop, UNPACK_STRIP_COMPILE) == 0) {
-    strip_compile = STR_TF(value);
-  } else if (strcmp(prop, UNPACK_STRIP_DEBUG) == 0) {
-    strip_debug = STR_TF(value);
-  } else if (strcmp(prop, UNPACK_STRIP_JCOV) == 0) {
-    strip_jcov = STR_TF(value);
-#endif /*HAVE_STRIP*/
-  } else if (strcmp(prop, UNPACK_REMOVE_PACKFILE) == 0) {
-    remove_packfile = STR_TF(value);
-  } else if (strcmp(prop, DEBUG_VERBOSE) == 0) {
-    verbose = (value == null)? 0: atoi(value);
-  } else if (strcmp(prop, DEBUG_VERBOSE ".bands") == 0) {
-#ifndef PRODUCT
-    verbose_bands = (value == null)? 0: atoi(value);
-#endif
-  } else if (strcmp(prop, UNPACK_MODIFICATION_TIME) == 0) {
-    if (value == null || (strcmp(value, "keep") == 0)) {
-      modification_time_or_zero = 0;
-    } else if (strcmp(value, "now") == 0) {
-      time_t now;
-      time(&now);
-      modification_time_or_zero = (int) now;
-    } else {
-      modification_time_or_zero = atoi(value);
-      if (modification_time_or_zero == 0)
-        modification_time_or_zero = 1;  // make non-zero
-    }
-  } else if (strcmp(prop, UNPACK_LOG_FILE) == 0) {
-    log_file = (value == null)? value: saveStr(value);
-  } else {
-    return false; // unknown option ignore
-  }
-  return true;
-}
-
-// Deallocate all internal storage and reset to a clean state.
-// Do not disturb any input or output connections, including
-// infileptr, infileno, inbytes, read_input_fn, jarout, or errstrm.
-// Do not reset any unpack options.
-void unpacker::reset() {
-  bytes_read_before_reset      += bytes_read;
-  bytes_written_before_reset   += bytes_written;
-  files_written_before_reset   += files_written;
-  classes_written_before_reset += classes_written;
-  segments_read_before_reset   += 1;
-  if (verbose >= 2) {
-    fprintf(errstrm,
-            "After segment %d, "
-            LONG_LONG_FORMAT " bytes read and "
-            LONG_LONG_FORMAT " bytes written.\n",
-            segments_read_before_reset-1,
-            bytes_read_before_reset, bytes_written_before_reset);
-    fprintf(errstrm,
-            "After segment %d, %d files (of which %d are classes) written to output.\n",
-            segments_read_before_reset-1,
-            files_written_before_reset, classes_written_before_reset);
-    if (archive_next_count != 0) {
-      fprintf(errstrm,
-              "After segment %d, %d segment%s remaining (estimated).\n",
-              segments_read_before_reset-1,
-              archive_next_count, archive_next_count==1?"":"s");
-    }
-  }
-
-  unpacker save_u = (*this);  // save bytewise image
-  infileptr = null;  // make asserts happy
-  jniobj = null;  // make asserts happy
-  jarout = null;  // do not close the output jar
-  gzin = null;  // do not close the input gzip stream
-  bytes esn;
-  if (errstrm_name != null) {
-    esn.saveFrom(errstrm_name);
-  } else {
-    esn.set(null, 0);
-  }
-  this->free();
-  mtrace('s', 0, 0);  // note the boundary between segments
-  this->init(read_input_fn);
-
-  // restore selected interface state:
-#define SAVE(x) this->x = save_u.x
-  SAVE(jniobj);
-  SAVE(jnienv);
-  SAVE(infileptr);  // buffered
-  SAVE(infileno);   // unbuffered
-  SAVE(inbytes);    // direct
-  SAVE(jarout);
-  SAVE(gzin);
-  //SAVE(read_input_fn);
-  SAVE(errstrm);
-  SAVE(verbose);  // verbose level, 0 means no output
-  SAVE(strip_compile);
-  SAVE(strip_debug);
-  SAVE(strip_jcov);
-  SAVE(remove_packfile);
-  SAVE(deflate_hint_or_zero);  // ==0 means not set, otherwise -1 or 1
-  SAVE(modification_time_or_zero);
-  SAVE(bytes_read_before_reset);
-  SAVE(bytes_written_before_reset);
-  SAVE(files_written_before_reset);
-  SAVE(classes_written_before_reset);
-  SAVE(segments_read_before_reset);
-#undef SAVE
-  if (esn.len > 0) {
-    errstrm_name = saveStr(esn.strval());
-    esn.free();
-  }
-  log_file = errstrm_name;
-  // Note:  If we use strip_names, watch out:  They get nuked here.
-}
-
-void unpacker::init(read_input_fn_t input_fn) {
-  int i;
-  NOT_PRODUCT(debug_u = this);
-  BYTES_OF(*this).clear();
-#ifndef PRODUCT
-  free();  // just to make sure freeing is idempotent
-#endif
-  this->u = this;    // self-reference for U_NEW macro
-  errstrm = stdout;  // default error-output
-  log_file = LOGFILE_STDOUT;
-  read_input_fn = input_fn;
-  all_bands = band::makeBands(this);
-  // Make a default jar buffer; caller may safely overwrite it.
-  jarout = U_NEW(jar, 1);
-  jarout->init(this);
-  for (i = 0; i < ATTR_CONTEXT_LIMIT; i++)
-    attr_defs[i].u = u;  // set up outer ptr
-}
-
-const char* unpacker::get_abort_message() {
-   return abort_message;
-}
-
-void unpacker::dump_options() {
-  static const char* opts[] = {
-    UNPACK_LOG_FILE,
-    UNPACK_DEFLATE_HINT,
-#ifdef HAVE_STRIP
-    UNPACK_STRIP_COMPILE,
-    UNPACK_STRIP_DEBUG,
-    UNPACK_STRIP_JCOV,
-#endif /*HAVE_STRIP*/
-    UNPACK_REMOVE_PACKFILE,
-    DEBUG_VERBOSE,
-    UNPACK_MODIFICATION_TIME,
-    null
-  };
-  for (int i = 0; opts[i] != null; i++) {
-    const char* str = get_option(opts[i]);
-    if (str == null) {
-      if (verbose == 0)  continue;
-      str = "(not set)";
-    }
-    fprintf(errstrm, "%s=%s\n", opts[i], str);
-  }
-}
-
-
-// Usage: unpack a byte buffer
-// packptr is a reference to byte buffer containing a
-// packed file and len is the length of the buffer.
-// If null, the callback is used to fill an internal buffer.
-void unpacker::start(void* packptr, size_t len) {
-  CHECK;
-  NOT_PRODUCT(debug_u = this);
-  if (packptr != null && len != 0) {
-    inbytes.set((byte*) packptr, len);
-  }
-  CHECK;
-  read_bands();
-}
-
-void unpacker::check_options() {
-  const char* strue  = "true";
-  const char* sfalse = "false";
-  if (deflate_hint_or_zero != 0) {
-    bool force_deflate_hint = (deflate_hint_or_zero > 0);
-    if (force_deflate_hint)
-      default_file_options |= FO_DEFLATE_HINT;
-    else
-      default_file_options &= ~FO_DEFLATE_HINT;
-    // Turn off per-file deflate hint by force.
-    suppress_file_options |= FO_DEFLATE_HINT;
-  }
-  if (modification_time_or_zero != 0) {
-    default_file_modtime = modification_time_or_zero;
-    // Turn off per-file modtime by force.
-    archive_options &= ~AO_HAVE_FILE_MODTIME;
-  }
-  // %%% strip_compile, etc...
-}
-
-// classfile writing
-
-void unpacker::reset_cur_classfile() {
-  // set defaults
-  cur_class_minver = default_class_minver;
-  cur_class_majver = default_class_majver;
-
-  // reset constant pool state
-  cp.resetOutputIndexes();
-
-  // reset fixups
-  class_fixup_type.empty();
-  class_fixup_offset.empty();
-  class_fixup_ref.empty();
-  requested_ics.empty();
-  cp.requested_bsms.empty();
-}
-
-cpindex* cpool::getKQIndex() {
-  char ch = '?';
-  if (u->cur_descr != null) {
-    entry* type = u->cur_descr->descrType();
-    ch = type->value.b.ptr[0];
-  }
-  byte tag = CONSTANT_Integer;
-  switch (ch) {
-  case 'L': tag = CONSTANT_String;   break;
-  case 'I': tag = CONSTANT_Integer;  break;
-  case 'J': tag = CONSTANT_Long;     break;
-  case 'F': tag = CONSTANT_Float;    break;
-  case 'D': tag = CONSTANT_Double;   break;
-  case 'B': case 'S': case 'C':
-  case 'Z': tag = CONSTANT_Integer;  break;
-  default:  abort("bad KQ reference"); break;
-  }
-  return getIndex(tag);
-}
-
-uint unpacker::to_bci(uint bii) {
-  uint  len =         bcimap.length();
-  uint* map = (uint*) bcimap.base();
-  assert(len > 0);  // must be initialized before using to_bci
-  if (bii < len)
-    return map[bii];
-  // Else it's a fractional or out-of-range BCI.
-  uint key = bii-len;
-  for (int i = len; ; i--) {
-    if (map[i-1]-(i-1) <= key)
-      break;
-    else
-      --bii;
-  }
-  return bii;
-}
-
-void unpacker::put_stackmap_type() {
-  int tag = code_StackMapTable_T.getByte();
-  putu1(tag);
-  switch (tag) {
-  case 7: // (7) [RCH]
-    putref(code_StackMapTable_RC.getRef());
-    break;
-  case 8: // (8) [PH]
-    putu2(to_bci(code_StackMapTable_P.getInt()));
-    break;
-  }
-}
-
-// Functions for writing code.
-
-maybe_inline
-void unpacker::put_label(int curIP, int size) {
-  code_fixup_type.addByte(size);
-  code_fixup_offset.add((int)put_empty(size));
-  code_fixup_source.add(curIP);
-}
-
-inline  // called exactly once => inline
-void unpacker::write_bc_ops() {
-  bcimap.empty();
-  code_fixup_type.empty();
-  code_fixup_offset.empty();
-  code_fixup_source.empty();
-
-  band* bc_which;
-
-  byte*  opptr = bc_codes.curRP();
-  // No need for oplimit, since the codes are pre-counted.
-
-  size_t codeBase = wpoffset();
-
-  bool   isAload;  // copy-out result
-  int    origBC;
-
-  entry* thisClass  = cur_class;
-  entry* superClass = cur_super;
-  entry* newClass   = null;  // class of last _new opcode
-
-  // overwrite any prior index on these bands; it changes w/ current class:
-  bc_thisfield.setIndex(    cp.getFieldIndex( thisClass));
-  bc_thismethod.setIndex(   cp.getMethodIndex(thisClass));
-  if (superClass != null) {
-    bc_superfield.setIndex( cp.getFieldIndex( superClass));
-    bc_supermethod.setIndex(cp.getMethodIndex(superClass));
-  } else {
-    NOT_PRODUCT(bc_superfield.setIndex(null));
-    NOT_PRODUCT(bc_supermethod.setIndex(null));
-  }
-  CHECK;
-
-  for (int curIP = 0; ; curIP++) {
-    int curPC = (int)(wpoffset() - codeBase);
-    bcimap.add(curPC);
-    ensure_put_space(10);  // covers most instrs w/o further bounds check
-    int bc = *opptr++ & 0xFF;
-
-    putu1_fast(bc);
-    // Note:  See '--wp' below for pseudo-bytecodes like bc_end_marker.
-
-    bool isWide = false;
-    if (bc == bc_wide) {
-      bc = *opptr++ & 0xFF;
-      putu1_fast(bc);
-      isWide = true;
-    }
-    switch (bc) {
-    case bc_end_marker:
-      --wp;  // not really part of the code
-      assert(opptr <= bc_codes.maxRP());
-      bc_codes.curRP() = opptr;  // advance over this in bc_codes
-      goto doneScanningMethod;
-    case bc_tableswitch: // apc:  (df, lo, hi, (hi-lo+1)*(label))
-    case bc_lookupswitch: // apc:  (df, nc, nc*(case, label))
-      {
-        int caseCount = bc_case_count.getInt();
-        while (((wpoffset() - codeBase) % 4) != 0)  putu1_fast(0);
-        ensure_put_space(30 + caseCount*8);
-        put_label(curIP, 4);  //int df = bc_label.getInt();
-        if (bc == bc_tableswitch) {
-          int lo = bc_case_value.getInt();
-          int hi = lo + caseCount-1;
-          putu4(lo);
-          putu4(hi);
-          for (int j = 0; j < caseCount; j++) {
-            put_label(curIP, 4); //int lVal = bc_label.getInt();
-            //int cVal = lo + j;
-          }
-        } else {
-          putu4(caseCount);
-          for (int j = 0; j < caseCount; j++) {
-            int cVal = bc_case_value.getInt();
-            putu4(cVal);
-            put_label(curIP, 4); //int lVal = bc_label.getInt();
-          }
-        }
-        assert((int)to_bci(curIP) == curPC);
-        continue;
-      }
-    case bc_iinc:
-      {
-        int local = bc_local.getInt();
-        int delta = (isWide ? bc_short : bc_byte).getInt();
-        if (isWide) {
-          putu2(local);
-          putu2(delta);
-        } else {
-          putu1_fast(local);
-          putu1_fast(delta);
-        }
-        continue;
-      }
-    case bc_sipush:
-      {
-        int val = bc_short.getInt();
-        putu2(val);
-        continue;
-      }
-    case bc_bipush:
-    case bc_newarray:
-      {
-        int val = bc_byte.getByte();
-        putu1_fast(val);
-        continue;
-      }
-    case bc_ref_escape:
-      {
-        // Note that insnMap has one entry for this.
-        --wp;  // not really part of the code
-        int size = bc_escrefsize.getInt();
-        entry* ref = bc_escref.getRefN();
-        CHECK;
-        switch (size) {
-        case 1: putu1ref(ref); break;
-        case 2: putref(ref);   break;
-        default: assert(false);
-        }
-        continue;
-      }
-    case bc_byte_escape:
-      {
-        // Note that insnMap has one entry for all these bytes.
-        --wp;  // not really part of the code
-        int size = bc_escsize.getInt();
-        ensure_put_space(size);
-        for (int j = 0; j < size; j++)
-          putu1_fast(bc_escbyte.getByte());
-        continue;
-      }
-    default:
-      if (is_invoke_init_op(bc)) {
-        origBC = bc_invokespecial;
-        entry* classRef;
-        switch (bc - _invokeinit_op) {
-        case _invokeinit_self_option:   classRef = thisClass;  break;
-        case _invokeinit_super_option:  classRef = superClass; break;
-        default: assert(bc == _invokeinit_op+_invokeinit_new_option);
-        case _invokeinit_new_option:    classRef = newClass;   break;
-        }
-        wp[-1] = origBC;  // overwrite with origBC
-        int coding = bc_initref.getInt();
-        // Find the nth overloading of <init> in classRef.
-        entry*   ref = null;
-        cpindex* ix = cp.getMethodIndex(classRef);
-        CHECK;
-        for (int j = 0, which_init = 0; ; j++) {
-          ref = (ix == null)? null: ix->get(j);
-          if (ref == null)  break;  // oops, bad input
-          assert(ref->tag == CONSTANT_Methodref);
-          if (ref->memberDescr()->descrName() == cp.sym[cpool::s_lt_init_gt]) {
-            if (which_init++ == coding)  break;
-          }
-        }
-        putref(ref);
-        continue;
-      }
-      bc_which = ref_band_for_self_op(bc, isAload, origBC);
-      if (bc_which != null) {
-        if (!isAload) {
-          wp[-1] = origBC;  // overwrite with origBC
-        } else {
-          wp[-1] = bc_aload_0;  // overwrite with _aload_0
-          // Note: insnMap keeps the _aload_0 separate.
-          bcimap.add(++curPC);
-          ++curIP;
-          putu1_fast(origBC);
-        }
-        entry* ref = bc_which->getRef();
-        CHECK;
-        putref(ref);
-        continue;
-      }
-      if (is_branch_op(bc)) {
-        //int lVal = bc_label.getInt();
-        if (bc < bc_goto_w) {
-          put_label(curIP, 2);  //putu2(lVal & 0xFFFF);
-        } else {
-          assert(bc <= bc_jsr_w);
-          put_label(curIP, 4);  //putu4(lVal);
-        }
-        assert((int)to_bci(curIP) == curPC);
-        continue;
-      }
-      bc_which = ref_band_for_op(bc);
-      if (bc_which != null) {
-        entry* ref = bc_which->getRefCommon(bc_which->ix, bc_which->nullOK);
-        CHECK;
-        if (ref == null && bc_which == &bc_classref) {
-          // Shorthand for class self-references.
-          ref = thisClass;
-        }
-        origBC = bc;
-        switch (bc) {
-        case _invokestatic_int:
-          origBC = bc_invokestatic;
-          break;
-        case _invokespecial_int:
-          origBC = bc_invokespecial;
-          break;
-        case bc_ildc:
-        case bc_cldc:
-        case bc_fldc:
-        case bc_sldc:
-        case bc_qldc:
-          origBC = bc_ldc;
-          break;
-        case bc_ildc_w:
-        case bc_cldc_w:
-        case bc_fldc_w:
-        case bc_sldc_w:
-        case bc_qldc_w:
-          origBC = bc_ldc_w;
-          break;
-        case bc_lldc2_w:
-        case bc_dldc2_w:
-          origBC = bc_ldc2_w;
-          break;
-        case bc_new:
-          newClass = ref;
-          break;
-        }
-        wp[-1] = origBC;  // overwrite with origBC
-        if (origBC == bc_ldc) {
-          putu1ref(ref);
-        } else {
-          putref(ref);
-        }
-        if (origBC == bc_multianewarray) {
-          // Copy the trailing byte also.
-          int val = bc_byte.getByte();
-          putu1_fast(val);
-        } else if (origBC == bc_invokeinterface) {
-          int argSize = ref->memberDescr()->descrType()->typeSize();
-          putu1_fast(1 + argSize);
-          putu1_fast(0);
-        } else if (origBC == bc_invokedynamic) {
-          // pad the next two byte
-          putu1_fast(0);
-          putu1_fast(0);
-        }
-        continue;
-      }
-      if (is_local_slot_op(bc)) {
-        int local = bc_local.getInt();
-        if (isWide) {
-          putu2(local);
-          if (bc == bc_iinc) {
-            int iVal = bc_short.getInt();
-            putu2(iVal);
-          }
-        } else {
-          putu1_fast(local);
-          if (bc == bc_iinc) {
-            int iVal = bc_byte.getByte();
-            putu1_fast(iVal);
-          }
-        }
-        continue;
-      }
-      // Random bytecode.  Just copy it.
-      assert(bc < bc_bytecode_limit);
-    }
-  }
- doneScanningMethod:{}
-  //bcimap.add(curPC);  // PC limit is already also in map, from bc_end_marker
-
-  // Armed with a bcimap, we can now fix up all the labels.
-  for (int i = 0; i < (int)code_fixup_type.size(); i++) {
-    int   type   = code_fixup_type.getByte(i);
-    byte* bp     = wp_at(code_fixup_offset.get(i));
-    int   curIP  = code_fixup_source.get(i);
-    int   destIP = curIP + bc_label.getInt();
-    int   span   = to_bci(destIP) - to_bci(curIP);
-    switch (type) {
-    case 2: putu2_at(bp, (ushort)span); break;
-    case 4: putu4_at(bp,         span); break;
-    default: assert(false);
-    }
-  }
-}
-
-inline  // called exactly once => inline
-void unpacker::write_code() {
-  int j;
-
-  int max_stack, max_locals, handler_count, cflags;
-  get_code_header(max_stack, max_locals, handler_count, cflags);
-
-  if (max_stack < 0)      max_stack = code_max_stack.getInt();
-  if (max_locals < 0)     max_locals = code_max_na_locals.getInt();
-  if (handler_count < 0)  handler_count = code_handler_count.getInt();
-
-  int siglen = cur_descr->descrType()->typeSize();
-  CHECK;
-  if ((cur_descr_flags & ACC_STATIC) == 0)  siglen++;
-  max_locals += siglen;
-
-  putu2(max_stack);
-  putu2(max_locals);
-  size_t bcbase = put_empty(4);
-
-  // Write the bytecodes themselves.
-  write_bc_ops();
-  CHECK;
-
-  byte* bcbasewp = wp_at(bcbase);
-  putu4_at(bcbasewp, (int)(wp - (bcbasewp+4)));  // size of code attr
-
-  putu2(handler_count);
-  for (j = 0; j < handler_count; j++) {
-    int bii = code_handler_start_P.getInt();
-    putu2(to_bci(bii));
-    bii    += code_handler_end_PO.getInt();
-    putu2(to_bci(bii));
-    bii    += code_handler_catch_PO.getInt();
-    putu2(to_bci(bii));
-    putref(code_handler_class_RCN.getRefN());
-    CHECK;
-  }
-
-  julong indexBits = cflags;
-  if (cflags < 0) {
-    bool haveLongFlags = attr_defs[ATTR_CONTEXT_CODE].haveLongFlags();
-    indexBits = code_flags_hi.getLong(code_flags_lo, haveLongFlags);
-  }
-  write_attrs(ATTR_CONTEXT_CODE, indexBits);
-}
-
-int unpacker::write_attrs(int attrc, julong indexBits) {
-  CHECK_0;
-  if (indexBits == 0) {
-    // Quick short-circuit.
-    putu2(0);
-    return 0;
-  }
-
-  attr_definitions& ad = attr_defs[attrc];
-
-  int i, j, j2, idx, count;
-
-  int oiCount = 0;
-  if (ad.isPredefined(X_ATTR_OVERFLOW)
-      && (indexBits & ((julong)1<<X_ATTR_OVERFLOW)) != 0) {
-    indexBits -= ((julong)1<<X_ATTR_OVERFLOW);
-    oiCount = ad.xxx_attr_count().getInt();
-  }
-
-  int bitIndexes[X_ATTR_LIMIT_FLAGS_HI];
-  int biCount = 0;
-
-  // Fill bitIndexes with index bits, in order.
-  for (idx = 0; indexBits != 0; idx++, indexBits >>= 1) {
-    if ((indexBits & 1) != 0)
-      bitIndexes[biCount++] = idx;
-  }
-  assert(biCount <= (int)lengthof(bitIndexes));
-
-  // Write a provisional attribute count, perhaps to be corrected later.
-  int naOffset = (int)wpoffset();
-  int na0 = biCount + oiCount;
-  putu2(na0);
-
-  int na = 0;
-  for (i = 0; i < na0; i++) {
-    if (i < biCount)
-      idx = bitIndexes[i];
-    else
-      idx = ad.xxx_attr_indexes().getInt();
-    assert(ad.isIndex(idx));
-    entry* aname = null;
-    entry* ref;  // scratch
-    size_t abase = put_empty(2+4);
-    CHECK_0;
-    if (idx < (int)ad.flag_limit && ad.isPredefined(idx)) {
-      // Switch on the attrc and idx simultaneously.
-      switch (ADH_BYTE(attrc, idx)) {
-
-      case ADH_BYTE(ATTR_CONTEXT_CLASS,  X_ATTR_OVERFLOW):
-      case ADH_BYTE(ATTR_CONTEXT_FIELD,  X_ATTR_OVERFLOW):
-      case ADH_BYTE(ATTR_CONTEXT_METHOD, X_ATTR_OVERFLOW):
-      case ADH_BYTE(ATTR_CONTEXT_CODE,   X_ATTR_OVERFLOW):
-        // no attribute at all, so back up on this one
-        wp = wp_at(abase);
-        continue;
-
-      case ADH_BYTE(ATTR_CONTEXT_CLASS, CLASS_ATTR_ClassFile_version):
-        cur_class_minver = class_ClassFile_version_minor_H.getInt();
-        cur_class_majver = class_ClassFile_version_major_H.getInt();
-        // back up; not a real attribute
-        wp = wp_at(abase);
-        continue;
-
-      case ADH_BYTE(ATTR_CONTEXT_CLASS, CLASS_ATTR_InnerClasses):
-        // note the existence of this attr, but save for later
-        if (cur_class_has_local_ics)
-          abort("too many InnerClasses attrs");
-        cur_class_has_local_ics = true;
-        wp = wp_at(abase);
-        continue;
-
-      case ADH_BYTE(ATTR_CONTEXT_CLASS, CLASS_ATTR_SourceFile):
-        aname = cp.sym[cpool::s_SourceFile];
-        ref = class_SourceFile_RUN.getRefN();
-        CHECK_0;
-        if (ref == null) {
-          bytes& n = cur_class->ref(0)->value.b;
-          // parse n = (<pkg>/)*<outer>?($<id>)*
-          int pkglen = lastIndexOf(SLASH_MIN,  SLASH_MAX,  n, (int)n.len)+1;
-          bytes prefix = n.slice(pkglen, n.len);
-          for (;;) {
-            // Work backwards, finding all '$', '#', etc.
-            int dollar = lastIndexOf(DOLLAR_MIN, DOLLAR_MAX, prefix, (int)prefix.len);
-            if (dollar < 0)  break;
-            prefix = prefix.slice(0, dollar);
-          }
-          const char* suffix = ".java";
-          int len = (int)(prefix.len + strlen(suffix));
-          bytes name; name.set(T_NEW(byte, add_size(len, 1)), len);
-          name.strcat(prefix).strcat(suffix);
-          ref = cp.ensureUtf8(name);
-        }
-        putref(ref);
-        break;
-
-      case ADH_BYTE(ATTR_CONTEXT_CLASS, CLASS_ATTR_EnclosingMethod):
-        aname = cp.sym[cpool::s_EnclosingMethod];
-        putref(class_EnclosingMethod_RC.getRefN());
-        CHECK_0;
-        putref(class_EnclosingMethod_RDN.getRefN());
-        break;
-
-      case ADH_BYTE(ATTR_CONTEXT_FIELD, FIELD_ATTR_ConstantValue):
-        aname = cp.sym[cpool::s_ConstantValue];
-        putref(field_ConstantValue_KQ.getRefUsing(cp.getKQIndex()));
-        break;
-
-      case ADH_BYTE(ATTR_CONTEXT_METHOD, METHOD_ATTR_Code):
-        aname = cp.sym[cpool::s_Code];
-        write_code();
-        break;
-
-      case ADH_BYTE(ATTR_CONTEXT_METHOD, METHOD_ATTR_Exceptions):
-        aname = cp.sym[cpool::s_Exceptions];
-        putu2(count = method_Exceptions_N.getInt());
-        for (j = 0; j < count; j++) {
-          putref(method_Exceptions_RC.getRefN());
-          CHECK_0;
-        }
-        break;
-
-      case ADH_BYTE(ATTR_CONTEXT_METHOD, METHOD_ATTR_MethodParameters):
-        aname = cp.sym[cpool::s_MethodParameters];
-        putu1(count = method_MethodParameters_NB.getByte());
-        for (j = 0; j < count; j++) {
-          putref(method_MethodParameters_name_RUN.getRefN());
-          putu2(method_MethodParameters_flag_FH.getInt());
-        }
-        break;
-
-      case ADH_BYTE(ATTR_CONTEXT_CODE, CODE_ATTR_StackMapTable):
-        aname = cp.sym[cpool::s_StackMapTable];
-        // (keep this code aligned with its brother in unpacker::read_attrs)
-        putu2(count = code_StackMapTable_N.getInt());
-        for (j = 0; j < count; j++) {
-          int tag = code_StackMapTable_frame_T.getByte();
-          putu1(tag);
-          if (tag <= 127) {
-            // (64-127)  [(2)]
-            if (tag >= 64)  put_stackmap_type();
-          } else if (tag <= 251) {
-            // (247)     [(1)(2)]
-            // (248-251) [(1)]
-            if (tag >= 247)  putu2(code_StackMapTable_offset.getInt());
-            if (tag == 247)  put_stackmap_type();
-          } else if (tag <= 254) {
-            // (252)     [(1)(2)]
-            // (253)     [(1)(2)(2)]
-            // (254)     [(1)(2)(2)(2)]
-            putu2(code_StackMapTable_offset.getInt());
-            CHECK_0;
-            for (int k = (tag - 251); k > 0; k--) {
-              put_stackmap_type();
-              CHECK_0;
-            }
-          } else {
-            // (255)     [(1)NH[(2)]NH[(2)]]
-            putu2(code_StackMapTable_offset.getInt());
-            putu2(j2 = code_StackMapTable_local_N.getInt());
-            while (j2-- > 0) {put_stackmap_type(); CHECK_0;}
-            putu2(j2 = code_StackMapTable_stack_N.getInt());
-            while (j2-- > 0)  {put_stackmap_type(); CHECK_0;}
-          }
-        }
-        break;
-
-      case ADH_BYTE(ATTR_CONTEXT_CODE, CODE_ATTR_LineNumberTable):
-        aname = cp.sym[cpool::s_LineNumberTable];
-        putu2(count = code_LineNumberTable_N.getInt());
-        for (j = 0; j < count; j++) {
-          putu2(to_bci(code_LineNumberTable_bci_P.getInt()));
-          putu2(code_LineNumberTable_line.getInt());
-        }
-        break;
-
-      case ADH_BYTE(ATTR_CONTEXT_CODE, CODE_ATTR_LocalVariableTable):
-        aname = cp.sym[cpool::s_LocalVariableTable];
-        putu2(count = code_LocalVariableTable_N.getInt());
-        for (j = 0; j < count; j++) {
-          int bii = code_LocalVariableTable_bci_P.getInt();
-          int bci = to_bci(bii);
-          putu2(bci);
-          bii    += code_LocalVariableTable_span_O.getInt();
-          putu2(to_bci(bii) - bci);
-          putref(code_LocalVariableTable_name_RU.getRefN());
-          CHECK_0;
-          putref(code_LocalVariableTable_type_RS.getRefN());
-          CHECK_0;
-          putu2(code_LocalVariableTable_slot.getInt());
-        }
-        break;
-
-      case ADH_BYTE(ATTR_CONTEXT_CODE, CODE_ATTR_LocalVariableTypeTable):
-        aname = cp.sym[cpool::s_LocalVariableTypeTable];
-        putu2(count = code_LocalVariableTypeTable_N.getInt());
-        for (j = 0; j < count; j++) {
-          int bii = code_LocalVariableTypeTable_bci_P.getInt();
-          int bci = to_bci(bii);
-          putu2(bci);
-          bii    += code_LocalVariableTypeTable_span_O.getInt();
-          putu2(to_bci(bii) - bci);
-          putref(code_LocalVariableTypeTable_name_RU.getRefN());
-          CHECK_0;
-          putref(code_LocalVariableTypeTable_type_RS.getRefN());
-          CHECK_0;
-          putu2(code_LocalVariableTypeTable_slot.getInt());
-        }
-        break;
-
-      case ADH_BYTE(ATTR_CONTEXT_CLASS, X_ATTR_Signature):
-        aname = cp.sym[cpool::s_Signature];
-        putref(class_Signature_RS.getRefN());
-        break;
-
-      case ADH_BYTE(ATTR_CONTEXT_FIELD, X_ATTR_Signature):
-        aname = cp.sym[cpool::s_Signature];
-        putref(field_Signature_RS.getRefN());
-        break;
-
-      case ADH_BYTE(ATTR_CONTEXT_METHOD, X_ATTR_Signature):
-        aname = cp.sym[cpool::s_Signature];
-        putref(method_Signature_RS.getRefN());
-        break;
-
-      case ADH_BYTE(ATTR_CONTEXT_CLASS,  X_ATTR_Deprecated):
-      case ADH_BYTE(ATTR_CONTEXT_FIELD,  X_ATTR_Deprecated):
-      case ADH_BYTE(ATTR_CONTEXT_METHOD, X_ATTR_Deprecated):
-        aname = cp.sym[cpool::s_Deprecated];
-        // no data
-        break;
-      }
-    }
-    CHECK_0;
-    if (aname == null) {
-      // Unparse a compressor-defined attribute.
-      layout_definition* lo = ad.getLayout(idx);
-      if (lo == null) {
-        abort("bad layout index");
-        break;
-      }
-      assert((int)lo->idx == idx);
-      aname = lo->nameEntry;
-      if (aname == null) {
-        bytes nameb; nameb.set(lo->name);
-        aname = cp.ensureUtf8(nameb);
-        // Cache the name entry for next time.
-        lo->nameEntry = aname;
-      }
-      // Execute all the layout elements.
-      band** bands = lo->bands();
-      if (lo->hasCallables()) {
-        band& cble = *bands[0];
-        assert(cble.le_kind == EK_CBLE);
-        bands = cble.le_body;
-      }
-      putlayout(bands);
-    }
-
-    if (aname == null)
-      abort("bad attribute index");
-    CHECK_0;
-
-    byte* wp1 = wp;
-    wp = wp_at(abase);
-
-    // DTRT if this attr is on the strip-list.
-    // (Note that we emptied the data out of the band first.)
-    if (ad.strip_names.contains(aname)) {
-      continue;
-    }
-
-    // patch the name and length
-    putref(aname);
-    putu4((int)(wp1 - (wp+4)));  // put the attr size
-    wp = wp1;
-    na++;  // count the attrs actually written
-  }
-
-  if (na != na0)
-    // Refresh changed count.
-    putu2_at(wp_at(naOffset), na);
-  return na;
-}
-
-void unpacker::write_members(int num, int attrc) {
-  CHECK;
-  attr_definitions& ad = attr_defs[attrc];
-  band& member_flags_hi = ad.xxx_flags_hi();
-  band& member_flags_lo = ad.xxx_flags_lo();
-  band& member_descr = (&member_flags_hi)[e_field_descr-e_field_flags_hi];
-  assert(endsWith(member_descr.name, "_descr"));
-  assert(endsWith(member_flags_lo.name, "_flags_lo"));
-  assert(endsWith(member_flags_lo.name, "_flags_lo"));
-  bool haveLongFlags = ad.haveLongFlags();
-
-  putu2(num);
-  julong indexMask = attr_defs[attrc].flagIndexMask();
-  for (int i = 0; i < num; i++) {
-    julong mflags = member_flags_hi.getLong(member_flags_lo, haveLongFlags);
-    entry* mdescr = member_descr.getRef();
-    cur_descr = mdescr;
-    putu2(cur_descr_flags = (ushort)(mflags & ~indexMask));
-    CHECK;
-    putref(mdescr->descrName());
-    putref(mdescr->descrType());
-    write_attrs(attrc, (mflags & indexMask));
-    CHECK;
-  }
-  cur_descr = null;
-}
-
-extern "C"
-int raw_address_cmp(const void* p1p, const void* p2p) {
-  void* p1 = *(void**) p1p;
-  void* p2 = *(void**) p2p;
-  return (p1 > p2)? 1: (p1 < p2)? -1: 0;
-}
-
-/*
- * writes the InnerClass attributes and returns the updated attribute
- */
-int  unpacker::write_ics(int naOffset, int na) {
-#ifdef ASSERT
-  for (int i = 0; i < ic_count; i++) {
-    assert(!ics[i].requested);
-  }
-#endif
-  // First, consult the global table and the local constant pool,
-  // and decide on the globally implied inner classes.
-  // (Note that we read the cpool's outputIndex fields, but we
-  // do not yet write them, since the local IC attribute might
-  // reverse a global decision to declare an IC.)
-  assert(requested_ics.length() == 0);  // must start out empty
-  // Always include all members of the current class.
-  for (inner_class* child = cp.getFirstChildIC(cur_class);
-       child != null;
-       child = cp.getNextChildIC(child)) {
-    child->requested = true;
-    requested_ics.add(child);
-  }
-  // And, for each inner class mentioned in the constant pool,
-  // include it and all its outers.
-  int    noes =           cp.outputEntries.length();
-  entry** oes = (entry**) cp.outputEntries.base();
-  for (int i = 0; i < noes; i++) {
-    entry& e = *oes[i];
-    if (e.tag != CONSTANT_Class)  continue;  // wrong sort
-    for (inner_class* ic = cp.getIC(&e);
-         ic != null;
-         ic = cp.getIC(ic->outer)) {
-      if (ic->requested)  break;  // already processed
-      ic->requested = true;
-      requested_ics.add(ic);
-    }
-  }
-  int local_ics = requested_ics.length();
-  // Second, consult a local attribute (if any) and adjust the global set.
-  inner_class* extra_ics = null;
-  int      num_extra_ics = 0;
-  if (cur_class_has_local_ics) {
-    // adjust the set of ICs by symmetric set difference w/ the locals
-    num_extra_ics = class_InnerClasses_N.getInt();
-    if (num_extra_ics == 0) {
-      // Explicit zero count has an irregular meaning:  It deletes the attr.
-      local_ics = 0;  // (short-circuit all tests of requested bits)
-    } else {
-      extra_ics = T_NEW(inner_class, num_extra_ics);
-      // Note:  extra_ics will be freed up by next call to get_next_file().
-    }
-  }
-  for (int i = 0; i < num_extra_ics; i++) {
-    inner_class& extra_ic = extra_ics[i];
-    extra_ic.inner = class_InnerClasses_RC.getRef();
-    CHECK_0;
-    // Find the corresponding equivalent global IC:
-    inner_class* global_ic = cp.getIC(extra_ic.inner);
-    int flags = class_InnerClasses_F.getInt();
-    if (flags == 0) {
-      // The extra IC is simply a copy of a global IC.
-      if (global_ic == null) {
-        abort("bad reference to inner class");
-        break;
-      }
-      extra_ic = (*global_ic);  // fill in rest of fields
-    } else {
-      flags &= ~ACC_IC_LONG_FORM;  // clear high bit if set to get clean zero
-      extra_ic.flags = flags;
-      extra_ic.outer = class_InnerClasses_outer_RCN.getRefN();
-      CHECK_0;
-      extra_ic.name  = class_InnerClasses_name_RUN.getRefN();
-      CHECK_0;
-      // Detect if this is an exact copy of the global tuple.
-      if (global_ic != null) {
-        if (global_ic->flags != extra_ic.flags ||
-            global_ic->outer != extra_ic.outer ||
-            global_ic->name  != extra_ic.name) {
-          global_ic = null;  // not really the same, so break the link
-        }
-      }
-    }
-    if (global_ic != null && global_ic->requested) {
-      // This local repetition reverses the globally implied request.
-      global_ic->requested = false;
-      extra_ic.requested = false;
-      local_ics -= 1;
-    } else {
-      // The global either does not exist, or is not yet requested.
-      extra_ic.requested = true;
-      local_ics += 1;
-    }
-  }
-  // Finally, if there are any that survived, put them into an attribute.
-  // (Note that a zero-count attribute is always deleted.)
-  // The putref calls below will tell the constant pool to add any
-  // necessary local CP references to support the InnerClasses attribute.
-  // This step must be the last round of additions to the local CP.
-  if (local_ics > 0) {
-    // append the new attribute:
-    putref(cp.sym[cpool::s_InnerClasses]);
-    putu4(2 + 2*4*local_ics);
-    putu2(local_ics);
-    PTRLIST_QSORT(requested_ics, raw_address_cmp);
-    int num_global_ics = requested_ics.length();
-    for (int i = -num_global_ics; i < num_extra_ics; i++) {
-      inner_class* ic;
-      if (i < 0)
-        ic = (inner_class*) requested_ics.get(num_global_ics+i);
-      else
-        ic = &extra_ics[i];
-      if (ic->requested) {
-        putref(ic->inner);
-        putref(ic->outer);
-        putref(ic->name);
-        putu2(ic->flags);
-        NOT_PRODUCT(local_ics--);
-      }
-    }
-    assert(local_ics == 0);           // must balance
-    putu2_at(wp_at(naOffset), ++na);  // increment class attr count
-  }
-
-  // Tidy up global 'requested' bits:
-  for (int i = requested_ics.length(); --i >= 0; ) {
-    inner_class* ic = (inner_class*) requested_ics.get(i);
-    ic->requested = false;
-  }
-  requested_ics.empty();
-  return na;
-}
-
-/*
- * Writes the BootstrapMethods attribute and returns the updated attribute count
- */
-int unpacker::write_bsms(int naOffset, int na) {
-  cur_class_local_bsm_count = cp.requested_bsms.length();
-  if (cur_class_local_bsm_count > 0) {
-    int    noes =           cp.outputEntries.length();
-    entry** oes = (entry**) cp.outputEntries.base();
-    PTRLIST_QSORT(cp.requested_bsms, outputEntry_cmp);
-    // append the BootstrapMethods attribute (after the InnerClasses attr):
-    putref(cp.sym[cpool::s_BootstrapMethods]);
-    // make a note of the offset, for lazy patching
-    int sizeOffset = (int)wpoffset();
-    putu4(-99);  // attr size will be patched
-    putu2(cur_class_local_bsm_count);
-    int written_bsms = 0;
-    for (int i = 0 ; i < cur_class_local_bsm_count ; i++) {
-      entry* e = (entry*)cp.requested_bsms.get(i);
-      assert(e->outputIndex != REQUESTED_NONE);
-      // output index is the index within the array
-      e->outputIndex = i;
-      putref(e->refs[0]);  // bsm
-      putu2(e->nrefs-1);  // number of args after bsm
-      for (int j = 1; j < e->nrefs; j++) {
-        putref(e->refs[j]);
-      }
-      written_bsms += 1;
-    }
-    assert(written_bsms == cur_class_local_bsm_count);  // else insane
-    byte* sizewp = wp_at(sizeOffset);
-    putu4_at(sizewp, (int)(wp - (sizewp+4)));  // size of code attr
-    putu2_at(wp_at(naOffset), ++na);  // increment class attr count
-  }
-  return na;
-}
-
-void unpacker::write_classfile_tail() {
-
-  cur_classfile_tail.empty();
-  set_output(&cur_classfile_tail);
-
-  int i, num;
-
-  attr_definitions& ad = attr_defs[ATTR_CONTEXT_CLASS];
-
-  bool haveLongFlags = ad.haveLongFlags();
-  julong kflags = class_flags_hi.getLong(class_flags_lo, haveLongFlags);
-  julong indexMask = ad.flagIndexMask();
-
-  cur_class = class_this.getRef();
-  CHECK;
-  cur_super = class_super.getRef();
-  CHECK;
-
-  if (cur_super == cur_class)  cur_super = null;
-  // special representation for java/lang/Object
-
-  putu2((ushort)(kflags & ~indexMask));
-  putref(cur_class);
-  putref(cur_super);
-
-  putu2(num = class_interface_count.getInt());
-  for (i = 0; i < num; i++) {
-    putref(class_interface.getRef());
-    CHECK;
-  }
-
-  write_members(class_field_count.getInt(),  ATTR_CONTEXT_FIELD);
-  write_members(class_method_count.getInt(), ATTR_CONTEXT_METHOD);
-  CHECK;
-
-  cur_class_has_local_ics = false;  // may be set true by write_attrs
-
-  int naOffset = (int)wpoffset();   // note the attr count location
-  int na = write_attrs(ATTR_CONTEXT_CLASS, (kflags & indexMask));
-  CHECK;
-
-  na = write_bsms(naOffset, na);
-  CHECK;
-
-  // choose which inner classes (if any) pertain to k:
-  na = write_ics(naOffset, na);
-  CHECK;
-
-  close_output();
-  cp.computeOutputIndexes();
-
-  // rewrite CP references in the tail
-  int nextref = 0;
-  for (i = 0; i < (int)class_fixup_type.size(); i++) {
-    int    type = class_fixup_type.getByte(i);
-    byte*  fixp = wp_at(class_fixup_offset.get(i));
-    entry* e    = (entry*)class_fixup_ref.get(nextref++);
-    int    idx  = e->getOutputIndex();
-    switch (type) {
-    case 1:  putu1_at(fixp, idx);  break;
-    case 2:  putu2_at(fixp, idx);  break;
-    default: assert(false);  // should not reach here
-    }
-  }
-  CHECK;
-}
-
-void unpacker::write_classfile_head() {
-  cur_classfile_head.empty();
-  set_output(&cur_classfile_head);
-
-  putu4(JAVA_MAGIC);
-  putu2(cur_class_minver);
-  putu2(cur_class_majver);
-  putu2(cp.outputIndexLimit);
-
-  int checkIndex = 1;
-  int    noes =           cp.outputEntries.length();
-  entry** oes = (entry**) cp.outputEntries.base();
-  for (int i = 0; i < noes; i++) {
-    entry& e = *oes[i];
-    assert(e.getOutputIndex() == checkIndex++);
-    byte tag = e.tag;
-    assert(tag != CONSTANT_Signature);
-    putu1(tag);
-    switch (tag) {
-    case CONSTANT_Utf8:
-      putu2((int)e.value.b.len);
-      put_bytes(e.value.b);
-      break;
-    case CONSTANT_Integer:
-    case CONSTANT_Float:
-      putu4(e.value.i);
-      break;
-    case CONSTANT_Long:
-    case CONSTANT_Double:
-      putu8(e.value.l);
-      assert(checkIndex++);
-      break;
-    case CONSTANT_Class:
-    case CONSTANT_String:
-      // just write the ref
-      putu2(e.refs[0]->getOutputIndex());
-      break;
-    case CONSTANT_Fieldref:
-    case CONSTANT_Methodref:
-    case CONSTANT_InterfaceMethodref:
-    case CONSTANT_NameandType:
-    case CONSTANT_InvokeDynamic:
-      putu2(e.refs[0]->getOutputIndex());
-      putu2(e.refs[1]->getOutputIndex());
-      break;
-    case CONSTANT_MethodHandle:
-        putu1(e.value.i);
-        putu2(e.refs[0]->getOutputIndex());
-        break;
-    case CONSTANT_MethodType:
-      putu2(e.refs[0]->getOutputIndex());
-      break;
-    case CONSTANT_BootstrapMethod: // should not happen
-    default:
-      abort(ERROR_INTERNAL);
-    }
-  }
-
-#ifndef PRODUCT
-  total_cp_size[0] += cp.outputIndexLimit;
-  total_cp_size[1] += (int)cur_classfile_head.size();
-#endif
-  close_output();
-}
-
-unpacker::file* unpacker::get_next_file() {
-  CHECK_0;
-  free_temps();
-  if (files_remaining == 0) {
-    // Leave a clue that we're exhausted.
-    cur_file.name = null;
-    cur_file.size = null;
-    if (archive_size != 0) {
-      julong predicted_size = unsized_bytes_read + archive_size;
-      if (predicted_size != bytes_read)
-        abort("archive header had incorrect size");
-    }
-    return null;
-  }
-  files_remaining -= 1;
-  assert(files_written < file_count || classes_written < class_count);
-  cur_file.name = "";
-  cur_file.size = 0;
-  cur_file.modtime = default_file_modtime;
-  cur_file.options = default_file_options;
-  cur_file.data[0].set(null, 0);
-  cur_file.data[1].set(null, 0);
-  if (files_written < file_count) {
-    entry* e = file_name.getRef();
-    CHECK_0;
-    cur_file.name = e->utf8String();
-    bool haveLongSize = (testBit(archive_options, AO_HAVE_FILE_SIZE_HI));
-    cur_file.size = file_size_hi.getLong(file_size_lo, haveLongSize);
-    if (testBit(archive_options, AO_HAVE_FILE_MODTIME))
-      cur_file.modtime += file_modtime.getInt();  //relative to archive modtime
-    if (testBit(archive_options, AO_HAVE_FILE_OPTIONS))
-      cur_file.options |= file_options.getInt() & ~suppress_file_options;
-  } else if (classes_written < class_count) {
-    // there is a class for a missing file record
-    cur_file.options |= FO_IS_CLASS_STUB;
-  }
-  if ((cur_file.options & FO_IS_CLASS_STUB) != 0) {
-    assert(classes_written < class_count);
-    classes_written += 1;
-    if (cur_file.size != 0) {
-      abort("class file size transmitted");
-      return null;
-    }
-    reset_cur_classfile();
-
-    // write the meat of the classfile:
-    write_classfile_tail();
-    cur_file.data[1] = cur_classfile_tail.b;
-    CHECK_0;
-
-    // write the CP of the classfile, second:
-    write_classfile_head();
-    cur_file.data[0] = cur_classfile_head.b;
-    CHECK_0;
-
-    cur_file.size += cur_file.data[0].len;
-    cur_file.size += cur_file.data[1].len;
-    if (cur_file.name[0] == '\0') {
-      bytes& prefix = cur_class->ref(0)->value.b;
-      const char* suffix = ".class";
-      int len = (int)(prefix.len + strlen(suffix));
-      bytes name; name.set(T_NEW(byte, add_size(len, 1)), len);
-      cur_file.name = name.strcat(prefix).strcat(suffix).strval();
-    }
-  } else {
-    // If there is buffered file data, produce a pointer to it.
-    if (cur_file.size != (size_t) cur_file.size) {
-      // Silly size specified.
-      abort("resource file too large");
-      return null;
-    }
-    size_t rpleft = input_remaining();
-    if (rpleft > 0) {
-      if (rpleft > cur_file.size)
-        rpleft = (size_t) cur_file.size;
-      cur_file.data[0].set(rp, rpleft);
-      rp += rpleft;
-    }
-    if (rpleft < cur_file.size) {
-      // Caller must read the rest.
-      size_t fleft = (size_t)cur_file.size - rpleft;
-      bytes_read += fleft;  // Credit it to the overall archive size.
-    }
-  }
-  CHECK_0;
-  bytes_written += cur_file.size;
-  files_written += 1;
-  return &cur_file;
-}
-
-// Write a file to jarout.
-void unpacker::write_file_to_jar(unpacker::file* f) {
-  size_t htsize = f->data[0].len + f->data[1].len;
-  julong fsize = f->size;
-#ifndef PRODUCT
-  if (nowrite NOT_PRODUCT(|| skipfiles-- > 0)) {
-    PRINTCR((2,"would write %d bytes to %s", (int) fsize, f->name));
-    return;
-  }
-#endif
-  if (htsize == fsize) {
-    jarout->addJarEntry(f->name, f->deflate_hint(), f->modtime,
-                        f->data[0], f->data[1]);
-  } else {
-    assert(input_remaining() == 0);
-    bytes part1, part2;
-    part1.len = f->data[0].len;
-    part1.set(T_NEW(byte, part1.len), part1.len);
-    part1.copyFrom(f->data[0]);
-    assert(f->data[1].len == 0);
-    part2.set(null, 0);
-    size_t fleft = (size_t) fsize - part1.len;
-    assert(bytes_read > fleft);  // part2 already credited by get_next_file
-    bytes_read -= fleft;
-    if (fleft > 0) {
-      // Must read some more.
-      if (live_input) {
-        // Stop using the input buffer.  Make a new one:
-        if (free_input)  input.free();
-        input.init(fleft > (1<<12) ? fleft : (1<<12));
-        free_input = true;
-        live_input = false;
-      } else {
-        // Make it large enough.
-        assert(free_input);  // must be reallocable
-        input.ensureSize(fleft);
-      }
-      rplimit = rp = input.base();
-      CHECK;
-      input.setLimit(rp + fleft);
-      if (!ensure_input(fleft))
-        abort("EOF reading resource file");
-      part2.ptr = input_scan();
-      part2.len = input_remaining();
-      rplimit = rp = input.base();
-    }
-    jarout->addJarEntry(f->name, f->deflate_hint(), f->modtime,
-                        part1, part2);
-  }
-  if (verbose >= 3) {
-    fprintf(errstrm, "Wrote "
-                     LONG_LONG_FORMAT " bytes to: %s\n", fsize, f->name);
-  }
-}
-
-// Redirect the stdio to the specified file in the unpack.log.file option
-void unpacker::redirect_stdio() {
-  if (log_file == null) {
-    log_file = LOGFILE_STDOUT;
-  }
-  if (log_file == errstrm_name)
-    // Nothing more to be done.
-    return;
-  errstrm_name = log_file;
-  if (strcmp(log_file, LOGFILE_STDERR) == 0) {
-    errstrm = stderr;
-    return;
-  } else if (strcmp(log_file, LOGFILE_STDOUT) == 0) {
-    errstrm = stdout;
-    return;
-  } else if (log_file[0] != '\0' && (errstrm = fopen(log_file,"a+")) != NULL) {
-    return;
-  } else {
-    fprintf(stderr, "Can not open log file %s\n", log_file);
-    // Last resort
-    // (Do not use stdout, since it might be jarout->jarfp.)
-    errstrm = stderr;
-    log_file = errstrm_name = LOGFILE_STDERR;
-  }
-}
-
-#ifndef PRODUCT
-int unpacker::printcr_if_verbose(int level, const char* fmt ...) {
-  if (verbose < level)  return 0;
-  va_list vl;
-  va_start(vl, fmt);
-  char fmtbuf[300];
-  strcpy(fmtbuf+100, fmt);
-  strcat(fmtbuf+100, "\n");
-  char* fmt2 = fmtbuf+100;
-  while (level-- > 0)  *--fmt2 = ' ';
-  vfprintf(errstrm, fmt2, vl);
-  return 1;  // for ?: usage
-}
-#endif
-
-void unpacker::abort(const char* message) {
-  if (message == null)  message = "error unpacking archive";
-#ifdef UNPACK_JNI
-  if (message[0] == '@') {  // secret convention for sprintf
-     bytes saved;
-     saved.saveFrom(message+1);
-     mallocs.add(message = saved.strval());
-   }
-  abort_message = message;
-  return;
-#else
-  if (message[0] == '@')  ++message;
-  fprintf(errstrm, "%s\n", message);
-#ifndef PRODUCT
-  fflush(errstrm);
-  ::abort();
-#else
-  exit(-1);
-#endif
-#endif // JNI
-}
--- a/jdk/src/jdk.runtime/share/native/common-unpack/unpack.h	Fri Mar 06 13:30:49 2015 +0300
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,510 +0,0 @@
-/*
- * Copyright (c) 2002, 2012, 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.
- */
-// Global Structures
-struct jar;
-struct gunzip;
-struct band;
-struct cpool;
-struct entry;
-struct cpindex;
-struct inner_class;
-struct value_stream;
-
-struct cpindex {
-  uint    len;
-  entry*  base1;   // base of primary index
-  entry** base2;   // base of secondary index
-  byte    ixTag;   // type of entries (!= CONSTANT_None), plus 64 if sub-index
-  enum { SUB_TAG = 64 };
-
-  entry* get(uint i);
-
-  void init(int len_, entry* base1_, int ixTag_) {
-    len = len_;
-    base1 = base1_;
-    base2 = null;
-    ixTag = ixTag_;
-  }
-  void init(int len_, entry** base2_, int ixTag_) {
-    len = len_;
-    base1 = null;
-    base2 = base2_;
-    ixTag = ixTag_;
-  }
-};
-
-struct cpool {
-  uint  nentries;
-  entry* entries;
-  entry* first_extra_entry;
-  uint maxentries;      // total allocated size of entries
-
-  // Position and size of each homogeneous subrange:
-  int     tag_count[CONSTANT_Limit];
-  int     tag_base[CONSTANT_Limit];
-  cpindex tag_index[CONSTANT_Limit];
-  ptrlist tag_extras[CONSTANT_Limit];
-
-  int     tag_group_count[CONSTANT_GroupLimit - CONSTANT_GroupFirst];
-  cpindex tag_group_index[CONSTANT_GroupLimit - CONSTANT_GroupFirst];
-
-  cpindex* member_indexes;   // indexed by 2*CONSTANT_Class.inord
-  cpindex* getFieldIndex(entry* classRef);
-  cpindex* getMethodIndex(entry* classRef);
-
-  inner_class** ic_index;
-  inner_class** ic_child_index;
-  inner_class* getIC(entry* inner);
-  inner_class* getFirstChildIC(entry* outer);
-  inner_class* getNextChildIC(inner_class* child);
-
-  int outputIndexLimit;  // index limit after renumbering
-  ptrlist outputEntries; // list of entry* needing output idx assigned
-  ptrlist requested_bsms; // which bsms need output?
-
-  entry** hashTab;
-  uint    hashTabLength;
-  entry*& hashTabRef(byte tag, bytes& b);
-  entry*  ensureUtf8(bytes& b);
-  entry*  ensureClass(bytes& b);
-
-  // Well-known Utf8 symbols.
-  enum {
-    #define SNAME(n,s) s_##s,
-    ALL_ATTR_DO(SNAME)
-    #undef SNAME
-    s_lt_init_gt,  // <init>
-    s_LIMIT
-  };
-  entry* sym[s_LIMIT];
-
-  // read counts from hdr, allocate main arrays
-  void init(unpacker* u, int counts[CONSTANT_Limit]);
-
-  // pointer to outer unpacker, for error checks etc.
-  unpacker* u;
-
-  int getCount(byte tag) {
-    if ((uint)tag >= CONSTANT_GroupFirst) {
-      assert((uint)tag < CONSTANT_GroupLimit);
-      return tag_group_count[(uint)tag - CONSTANT_GroupFirst];
-    } else {
-      assert((uint)tag < CONSTANT_Limit);
-      return tag_count[(uint)tag];
-    }
-  }
-  cpindex* getIndex(byte tag) {
-    if ((uint)tag >= CONSTANT_GroupFirst) {
-      assert((uint)tag < CONSTANT_GroupLimit);
-      return &tag_group_index[(uint)tag - CONSTANT_GroupFirst];
-    } else {
-      assert((uint)tag < CONSTANT_Limit);
-      return &tag_index[(uint)tag];
-    }
-  }
-
-  cpindex* getKQIndex();  // uses cur_descr
-
-  void expandSignatures();
-  void initGroupIndexes();
-  void initMemberIndexes();
-  int  initLoadableValues(entry** loadable_entries);
-
-  void computeOutputOrder();
-  void computeOutputIndexes();
-  void resetOutputIndexes();
-
-  // error handling
-  inline void abort(const char* msg);
-  inline bool aborting();
-};
-
-/*
- * The unpacker provides the entry points to the unpack engine,
- * as well as maintains the state of the engine.
- */
-struct unpacker {
-  // One element of the resulting JAR.
-  struct file {
-    const char* name;
-    julong      size;
-    int         modtime;
-    int         options;
-    bytes       data[2];
-    // Note:  If Sum(data[*].len) < size,
-    // remaining bytes must be read directly from the input stream.
-    bool deflate_hint() { return ((options & FO_DEFLATE_HINT) != 0); }
-  };
-
-  // back pointer to NativeUnpacker obj and Java environment
-  void* jniobj;
-  void* jnienv;
-
-  // global pointer to self, if not running under JNI (not multi-thread safe)
-  static unpacker* non_mt_current;
-
-  // if running Unix-style, here are the inputs and outputs
-  FILE* infileptr;  // buffered
-  int   infileno;   // unbuffered
-  bytes inbytes;    // direct
-  gunzip* gzin;     // gunzip filter, if any
-  jar*  jarout;     // output JAR file
-  uint  gzcrc;      // CRC gathered from gzip content
-
-#ifndef PRODUCT
-  int   nowrite;
-  int   skipfiles;
-  int   verbose_bands;
-#endif
-
-  // pointer to self, for U_NEW macro
-  unpacker* u;
-
-  // private abort message string, allocated to PATH_MAX*2
-  const char* abort_message;
-  ptrlist mallocs;      // list of guys to free when we are all done
-  ptrlist tmallocs;     // list of guys to free on next client request
-  fillbytes smallbuf;   // supplies small alloc requests
-  fillbytes tsmallbuf;  // supplies temporary small alloc requests
-
-  // option management members
-  int   verbose;  // verbose level, 0 means no output
-  bool  strip_compile;
-  bool  strip_debug;
-  bool  strip_jcov;
-  bool  remove_packfile;
-  int   deflate_hint_or_zero;  // ==0 means not set, otherwise -1 or 1
-  int   modification_time_or_zero;
-
-  FILE*       errstrm;
-  const char* errstrm_name;
-
-  const char* log_file;
-
-  // input stream
-  fillbytes input;       // the whole block (size is predicted, has slop too)
-  bool      live_input;  // is the data in this block live?
-  bool      free_input;  // must the input buffer be freed?
-  byte*     rp;          // read pointer (< rplimit <= input.limit())
-  byte*     rplimit;     // how much of the input block has been read?
-  julong    bytes_read;
-  int       unsized_bytes_read;
-
-  // callback to read at least one byte, up to available input
-  typedef jlong (*read_input_fn_t)(unpacker* self, void* buf, jlong minlen, jlong maxlen);
-  read_input_fn_t read_input_fn;
-
-  // archive header fields
-  int      magic, minver, majver;
-  size_t   archive_size;
-  int      archive_next_count, archive_options, archive_modtime;
-  int      band_headers_size;
-  int      file_count, attr_definition_count, ic_count, class_count;
-  int      default_class_minver, default_class_majver;
-  int      default_file_options, suppress_file_options;  // not header fields
-  int      default_archive_modtime, default_file_modtime;  // not header fields
-  int      code_count;  // not a header field
-  int      files_remaining;  // not a header field
-
-  // engine state
-  band*        all_bands;   // indexed by band_number
-  byte*        meta_rp;     // read-pointer into (copy of) band_headers
-  cpool        cp;          // all constant pool information
-  inner_class* ics;         // InnerClasses
-
-  // output stream
-  bytes    output;      // output block (either classfile head or tail)
-  byte*    wp;          // write pointer (< wplimit == output.limit())
-  byte*    wpbase;      // write pointer starting address (<= wp)
-  byte*    wplimit;     // how much of the output block has been written?
-
-  // output state
-  file      cur_file;
-  entry*    cur_class;  // CONSTANT_Class entry
-  entry*    cur_super;  // CONSTANT_Class entry or null
-  entry*    cur_descr;  // CONSTANT_NameandType entry
-  int       cur_descr_flags;  // flags corresponding to cur_descr
-  int       cur_class_minver, cur_class_majver;
-  bool      cur_class_has_local_ics;
-  int       cur_class_local_bsm_count;
-  fillbytes cur_classfile_head;
-  fillbytes cur_classfile_tail;
-  int       files_written;   // also tells which file we're working on
-  int       classes_written; // also tells which class we're working on
-  julong    bytes_written;
-  intlist   bcimap;
-  fillbytes class_fixup_type;
-  intlist   class_fixup_offset;
-  ptrlist   class_fixup_ref;
-  fillbytes code_fixup_type;    // which format of branch operand?
-  intlist   code_fixup_offset;  // location of operand needing fixup
-  intlist   code_fixup_source;  // encoded ID of branch insn
-  ptrlist   requested_ics;      // which ics need output?
-
-  // stats pertaining to multiple segments (updated on reset)
-  julong    bytes_read_before_reset;
-  julong    bytes_written_before_reset;
-  int       files_written_before_reset;
-  int       classes_written_before_reset;
-  int       segments_read_before_reset;
-
-  // attribute state
-  struct layout_definition {
-    uint          idx;        // index (0..31...) which identifies this layout
-    const char*   name;       // name of layout
-    entry*        nameEntry;
-    const char*   layout;     // string of layout (not yet parsed)
-    band**        elems;      // array of top-level layout elems (or callables)
-
-    bool hasCallables()   { return layout[0] == '['; }
-    band** bands()        { assert(elems != null); return elems; }
-  };
-  struct attr_definitions {
-    unpacker* u;  // pointer to self, for U_NEW macro
-    int     xxx_flags_hi_bn;// locator for flags, count, indexes, calls bands
-    int     attrc;          // ATTR_CONTEXT_CLASS, etc.
-    uint    flag_limit;     // 32 or 63, depending on archive_options bit
-    julong  predef;         // mask of built-in definitions
-    julong  redef;          // mask of local flag definitions or redefinitions
-    ptrlist layouts;        // local (compressor-defined) defs, in index order
-    int     flag_count[X_ATTR_LIMIT_FLAGS_HI];
-    intlist overflow_count;
-    ptrlist strip_names;    // what attribute names are being stripped?
-    ptrlist band_stack;     // Temp., used during layout parsing.
-    ptrlist calls_to_link;  //  (ditto)
-    int     bands_made;     //  (ditto)
-
-    void free() {
-      layouts.free();
-      overflow_count.free();
-      strip_names.free();
-      band_stack.free();
-      calls_to_link.free();
-    }
-
-    // Locate the five fixed bands.
-    band& xxx_flags_hi();
-    band& xxx_flags_lo();
-    band& xxx_attr_count();
-    band& xxx_attr_indexes();
-    band& xxx_attr_calls();
-    band& fixed_band(int e_class_xxx);
-
-    // Register a new layout, and make bands for it.
-    layout_definition* defineLayout(int idx, const char* name, const char* layout);
-    layout_definition* defineLayout(int idx, entry* nameEntry, const char* layout);
-    band** buildBands(layout_definition* lo);
-
-    // Parse a layout string or part of one, recursively if necessary.
-    const char* parseLayout(const char* lp,    band** &res, int curCble);
-    const char* parseNumeral(const char* lp,   int    &res);
-    const char* parseIntLayout(const char* lp, band*  &res, byte le_kind,
-                               bool can_be_signed = false);
-    band** popBody(int band_stack_base);  // pops a body off band_stack
-
-    // Read data into the bands of the idx-th layout.
-    void readBandData(int idx);  // parse layout, make bands, read data
-    void readBandData(band** body, uint count);  // recursive helper
-
-    layout_definition* getLayout(uint idx) {
-      if (idx >= (uint)layouts.length())  return null;
-      return (layout_definition*) layouts.get(idx);
-    }
-
-    void setHaveLongFlags(bool z) {
-      assert(flag_limit == 0);  // not set up yet
-      flag_limit = (z? X_ATTR_LIMIT_FLAGS_HI: X_ATTR_LIMIT_NO_FLAGS_HI);
-    }
-    bool haveLongFlags() {
-     assert(flag_limit == X_ATTR_LIMIT_NO_FLAGS_HI ||
-            flag_limit == X_ATTR_LIMIT_FLAGS_HI);
-      return flag_limit == X_ATTR_LIMIT_FLAGS_HI;
-    }
-
-    // Return flag_count if idx is predef and not redef, else zero.
-    int predefCount(uint idx);
-
-    bool isRedefined(uint idx) {
-      if (idx >= flag_limit) return false;
-      return (bool)((redef >> idx) & 1);
-    }
-    bool isPredefined(uint idx) {
-      if (idx >= flag_limit) return false;
-      return (bool)(((predef & ~redef) >> idx) & 1);
-    }
-    julong flagIndexMask() {
-      return (predef | redef);
-    }
-    bool isIndex(uint idx) {
-      assert(flag_limit != 0);  // must be set up already
-      if (idx < flag_limit)
-        return (bool)(((predef | redef) >> idx) & 1);
-      else
-        return (idx - flag_limit < (uint)overflow_count.length());
-    }
-    int& getCount(uint idx) {
-      assert(isIndex(idx));
-      if (idx < flag_limit)
-        return flag_count[idx];
-      else
-        return overflow_count.get(idx - flag_limit);
-    }
-    bool aborting()             { return u->aborting(); }
-    void abort(const char* msg) { u->abort(msg); }
-  };
-
-  attr_definitions attr_defs[ATTR_CONTEXT_LIMIT];
-
-  // Initialization
-  void         init(read_input_fn_t input_fn = null);
-  // Resets to a known sane state
-  void         reset();
-  // Deallocates all storage.
-  void         free();
-  // Deallocates temporary storage (volatile after next client call).
-  void         free_temps() { tsmallbuf.init(); tmallocs.freeAll(); }
-
-  // Option management methods
-  bool         set_option(const char* option, const char* value);
-  const char*  get_option(const char* option);
-
-  void         dump_options();
-
-  // Fetching input.
-  bool   ensure_input(jlong more);
-  byte*  input_scan()               { return rp; }
-  size_t input_remaining()          { return rplimit - rp; }
-  size_t input_consumed()           { return rp - input.base(); }
-
-  // Entry points to the unpack engine
-  static int   run(int argc, char **argv);   // Unix-style entry point.
-  void         check_options();
-  void         start(void* packptr = null, size_t len = 0);
-  void         redirect_stdio();
-  void         write_file_to_jar(file* f);
-  void         finish();
-
-  // Public post unpack methods
-  int          get_files_remaining()    { return files_remaining; }
-  int          get_segments_remaining() { return archive_next_count; }
-  file*        get_next_file();  // returns null on last file
-
-  // General purpose methods
-  void*        alloc(size_t size) { return alloc_heap(size, true); }
-  void*        temp_alloc(size_t size) { return alloc_heap(size, true, true); }
-  void*        alloc_heap(size_t size, bool smallOK = false, bool temp = false);
-  void         saveTo(bytes& b, const char* str) { saveTo(b, (byte*)str, strlen(str)); }
-  void         saveTo(bytes& b, bytes& data) { saveTo(b, data.ptr, data.len); }
-  void         saveTo(bytes& b, byte* ptr, size_t len); //{ b.ptr = U_NEW...}
-  const char*  saveStr(const char* str) { bytes buf; saveTo(buf, str); return buf.strval(); }
-  const char*  saveIntStr(int num) { char buf[30]; sprintf(buf, "%d", num); return saveStr(buf); }
-#ifndef PRODUCT
-  int printcr_if_verbose(int level, const char* fmt,...);
-#endif
-  const char*  get_abort_message();
-  void         abort(const char* s = null);
-  bool         aborting() { return abort_message != null; }
-  static unpacker* current();  // find current instance
-  void checkLegacy(const char* name);
-  // Output management
-  void set_output(fillbytes* which) {
-    assert(wp == null);
-    which->ensureSize(1 << 12);  // covers the average classfile
-    wpbase  = which->base();
-    wp      = which->limit();
-    wplimit = which->end();
-  }
-  fillbytes* close_output(fillbytes* which = null);  // inverse of set_output
-
-  // These take an implicit parameter of wp/wplimit, and resize as necessary:
-  byte*  put_space(size_t len);  // allocates space at wp, returns pointer
-  size_t put_empty(size_t s)    { byte* p = put_space(s); return p - wpbase; }
-  void   ensure_put_space(size_t len);
-  void   put_bytes(bytes& b)    { b.writeTo(put_space(b.len)); }
-  void   putu1(int n)           { putu1_at(put_space(1), n); }
-  void   putu1_fast(int n)      { putu1_at(wp++,         n); }
-  void   putu2(int n);       // { putu2_at(put_space(2), n); }
-  void   putu4(int n);       // { putu4_at(put_space(4), n); }
-  void   putu8(jlong n);     // { putu8_at(put_space(8), n); }
-  void   putref(entry* e);   // { putu2_at(put_space(2), putref_index(e, 2)); }
-  void   putu1ref(entry* e); // { putu1_at(put_space(1), putref_index(e, 1)); }
-  int    putref_index(entry* e, int size);  // size in [1..2]
-  void   put_label(int curIP, int size);    // size in {2,4}
-  void   putlayout(band** body);
-  void   put_stackmap_type();
-
-  size_t wpoffset() { return (size_t)(wp - wpbase); }  // (unvariant across overflow)
-  byte*  wp_at(size_t offset) { return wpbase + offset; }
-  uint to_bci(uint bii);
-  void get_code_header(int& max_stack,
-                       int& max_na_locals,
-                       int& handler_count,
-                       int& cflags);
-  band* ref_band_for_self_op(int bc, bool& isAloadVar, int& origBCVar);
-  band* ref_band_for_op(int bc);
-
-  // Definitions of standard classfile int formats:
-  static void putu1_at(byte* wp, int n) { assert(n == (n & 0xFF)); wp[0] = n; }
-  static void putu2_at(byte* wp, int n);
-  static void putu4_at(byte* wp, int n);
-  static void putu8_at(byte* wp, jlong n);
-
-  // Private stuff
-  void reset_cur_classfile();
-  void write_classfile_tail();
-  void write_classfile_head();
-  void write_code();
-  void write_bc_ops();
-  void write_members(int num, int attrc);  // attrc=ATTR_CONTEXT_FIELD/METHOD
-  int  write_attrs(int attrc, julong indexBits);
-  int  write_ics(int naOffset, int na);
-  int  write_bsms(int naOffset, int na);
-
-  // The readers
-  void read_bands();
-  void read_file_header();
-  void read_cp();
-  void read_cp_counts(value_stream& hdr);
-  void read_attr_defs();
-  void read_ics();
-  void read_attrs(int attrc, int obj_count);
-  void read_classes();
-  void read_code_headers();
-  void read_bcs();
-  void read_bc_ops();
-  void read_files();
-  void read_Utf8_values(entry* cpMap, int len);
-  void read_single_words(band& cp_band, entry* cpMap, int len);
-  void read_double_words(band& cp_bands, entry* cpMap, int len);
-  void read_single_refs(band& cp_band, byte refTag, entry* cpMap, int len);
-  void read_double_refs(band& cp_band, byte ref1Tag, byte ref2Tag, entry* cpMap, int len);
-  void read_signature_values(entry* cpMap, int len);
-  void read_method_handle(entry* cpMap, int len);
-  void read_method_type(entry* cpMap, int len);
-  void read_bootstrap_methods(entry* cpMap, int len);
-};
-
-inline void cpool::abort(const char* msg) { u->abort(msg); }
-inline bool cpool::aborting()             { return u->aborting(); }
--- a/jdk/src/jdk.runtime/share/native/common-unpack/utils.cpp	Fri Mar 06 13:30:49 2015 +0300
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,180 +0,0 @@
-/*
- * Copyright (c) 2001, 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.
- */
-
-#include <stdarg.h>
-#include <stdio.h>
-#include <stdlib.h>
-#include <string.h>
-#include <limits.h>
-
-#include <sys/stat.h>
-
-#ifdef _MSC_VER
-#include <direct.h>
-#include <io.h>
-#include <process.h>
-#else
-#include <unistd.h>
-#endif
-
-#include "constants.h"
-#include "defines.h"
-#include "bytes.h"
-#include "utils.h"
-
-#include "unpack.h"
-
-void* must_malloc(size_t size) {
-  size_t msize = size;
-  #ifdef USE_MTRACE
-  if (msize >= 0 && msize < sizeof(int))
-    msize = sizeof(int);  // see 0xbaadf00d below
-  #endif
-  void* ptr = (msize > PSIZE_MAX || msize <= 0) ? null : malloc(msize);
-  if (ptr != null) {
-    memset(ptr, 0, size);
-  } else {
-    unpack_abort(ERROR_ENOMEM);
-  }
-  mtrace('m', ptr, size);
-  return ptr;
-}
-
-void mkdirs(int oklen, char* path) {
-
-  if (strlen(path) <= (size_t)oklen)  return;
-  char dir[PATH_MAX];
-
-  strcpy(dir, path);
-  char* slash = strrchr(dir, '/');
-  if (slash == 0)  return;
-  *slash = 0;
-  mkdirs(oklen, dir);
-  MKDIR(dir);
-}
-
-
-#ifndef PRODUCT
-void breakpoint() { }  // hook for debugger
-int assert_failed(const char* p) {
-  char message[1<<12];
-  sprintf(message, "@assert failed: %s\n", p);
-  fprintf(stdout, 1+message);
-  breakpoint();
-  unpack_abort(message);
-  return 0;
-}
-#endif
-
-void unpack_abort(const char* msg, unpacker* u) {
-  if (msg == null)  msg = "corrupt pack file or internal error";
-  if (u == null)
-    u = unpacker::current();
-  if (u == null) {
-    fprintf(stderr, "Error: unpacker: %s\n", msg);
-    ::abort();
-    return;
-  }
-  u->abort(msg);
-}
-
-bool unpack_aborting(unpacker* u) {
-  if (u == null)
-    u = unpacker::current();
-  if (u == null) {
-    fprintf(stderr, "Error: unpacker: no current instance\n");
-    ::abort();
-    return true;
-  }
-  return u->aborting();
-}
-
-#ifdef USE_MTRACE
-// Use this occasionally for detecting storage leaks in unpack.
-void mtrace(char c, void* ptr, size_t size) {
-  if (c == 'f')  *(int*)ptr = 0xbaadf00d;
-  static FILE* mtfp;
-  if (mtfp == (FILE*)-1)  return;
-  if (mtfp == null) {
-    if (getenv("USE_MTRACE") == null) {
-      mtfp = (FILE*)-1;
-      return;
-    }
-    char fname[1024];
-    sprintf(fname, "mtr%d.txt", getpid());
-    mtfp = fopen(fname, "w");
-    if (mtfp == null)
-      mtfp = stdout;
-  }
-  fprintf(mtfp, "%c %p %p\n", c, ptr, (void*)size);
-}
-
-/* # Script for processing memory traces.
-   # It should report only a limited number (2) of "suspended" blocks,
-   # even if a large number of archive segments are processed.
-   # It should report no "leaked" blocks at all.
-   nawk < mtr*.txt '
-   function checkleaks(what) {
-     nd = 0
-     for (ptr in allocated) {
-       if (allocated[ptr] == 1) {
-         print NR ": " what " " ptr
-         #allocated[ptr] = 0  # stop the dangle
-         nd++
-       }
-     }
-     if (nd > 0)  print NR ": count " what " " nd
-   }
-
-   /^[mfr]/ {
-       ptr = $2
-       a1 = ($1 == "m")? 1: 0
-       a0 = 0+allocated[ptr]
-       allocated[ptr] = a1
-       if (a0 + a1 != 1) {
-         if (a0 == 0 && a1 == 0)
-           print NR ": double free " ptr
-         else if (a0 == 1 && a1 == 1)
-           print NR ": double malloc " ptr
-         else
-           print NR ": oddity " $0
-       }
-       next
-     }
-
-   /^s/ {
-     checkleaks("suspended")
-     next
-   }
-
-   {
-     print NR ": unrecognized " $0
-   }
-   END {
-     checkleaks("leaked")
-   }
-'
-*/
-#endif // USE_MTRACE
--- a/jdk/src/jdk.runtime/share/native/common-unpack/utils.h	Fri Mar 06 13:30:49 2015 +0300
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,67 +0,0 @@
-/*
- * Copyright (c) 2001, 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.
- */
-
-//Definitions of our util functions
-
-void* must_malloc(size_t size);
-#ifndef USE_MTRACE
-#define mtrace(c, ptr, size)
-#else
-void mtrace(char c, void* ptr, size_t size);
-#endif
-
-// overflow management
-#define OVERFLOW ((uint)-1)
-#define PSIZE_MAX (OVERFLOW/2)  /* normal size limit */
-
-inline size_t scale_size(size_t size, size_t scale) {
-  return (size > PSIZE_MAX / scale) ? OVERFLOW : size * scale;
-}
-
-inline size_t add_size(size_t size1, size_t size2) {
-  return ((size1 | size2 | (size1 + size2)) > PSIZE_MAX)
-    ? OVERFLOW
-    : size1 + size2;
-}
-
-inline size_t add_size(size_t size1, size_t size2, int size3) {
-  return add_size(add_size(size1, size2), size3);
-}
-
-// These may be expensive, because they have to go via Java TSD,
-// if the optional u argument is missing.
-struct unpacker;
-extern void unpack_abort(const char* msg, unpacker* u = null);
-extern bool unpack_aborting(unpacker* u = null);
-
-#ifndef PRODUCT
-inline bool endsWith(const char* str, const char* suf) {
-  size_t len1 = strlen(str);
-  size_t len2 = strlen(suf);
-  return (len1 > len2 && 0 == strcmp(str + (len1-len2), suf));
-}
-#endif
-
-void mkdirs(int oklen, char* path);
--- a/jdk/src/jdk.runtime/share/native/common-unpack/zip.cpp	Fri Mar 06 13:30:49 2015 +0300
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,668 +0,0 @@
-/*
- * Copyright (c) 2001, 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.
- */
-
-/**
- * Note: Lifted from uncrunch.c from jdk sources
- */
-#include <stdio.h>
-#include <string.h>
-#include <errno.h>
-#include <time.h>
-
-#include <stdlib.h>
-
-#ifndef _MSC_VER
-#include <strings.h>
-#endif
-
-#include "defines.h"
-#include "bytes.h"
-#include "utils.h"
-
-#include "constants.h"
-#include "unpack.h"
-
-#include "zip.h"
-
-#ifdef NO_ZLIB
-
-inline bool jar::deflate_bytes(bytes& head, bytes& tail) {
-  return false;
-}
-inline uint jar::get_crc32(uint c, uchar *ptr, uint len) { return 0; }
-#define Z_NULL NULL
-
-#else // Have ZLIB
-
-#include <zlib.h>
-
-inline uint jar::get_crc32(uint c, uchar *ptr, uint len) { return crc32(c, ptr, len); }
-
-#endif // End of ZLIB
-
-#ifdef _BIG_ENDIAN
-#define SWAP_BYTES(a) \
-    ((((a) << 8) & 0xff00) | 0x00ff) & (((a) >> 8) | 0xff00)
-#else
-#define SWAP_BYTES(a)  (a)
-#endif
-
-#define GET_INT_LO(a) \
-    SWAP_BYTES(a & 0xFFFF)
-
-#define GET_INT_HI(a) \
-    SWAP_BYTES((a >> 16) & 0xFFFF)
-
-static const ushort jarmagic[2] = { SWAP_BYTES(0xCAFE), 0 };
-
-void jar::init(unpacker* u_) {
-  BYTES_OF(*this).clear();
-  u = u_;
-  u->jarout = this;
-}
-
-// Write data to the ZIP output stream.
-void jar::write_data(void* buff, int len) {
-  while (len > 0) {
-    int rc = (int)fwrite(buff, 1, len, jarfp);
-    if (rc <= 0) {
-      fprintf(u->errstrm, "Error: write on output file failed err=%d\n",errno);
-      exit(1); // Called only from the native standalone unpacker
-    }
-    output_file_offset += rc;
-    buff = ((char *)buff) + rc;
-    len -= rc;
-  }
-}
-
-void jar::add_to_jar_directory(const char* fname, bool store, int modtime,
-                               int len, int clen, uLong crc) {
-  uint fname_length = (uint)strlen(fname);
-  ushort header[23];
-  if (modtime == 0)  modtime = default_modtime;
-  uLong dostime = get_dostime(modtime);
-
-  header[0] = (ushort)SWAP_BYTES(0x4B50);
-  header[1] = (ushort)SWAP_BYTES(0x0201);
-  header[2] = (ushort)SWAP_BYTES(( store ) ? 0x0A : 0x14);
-
-  // required version
-  header[3] = (ushort)SWAP_BYTES(( store ) ? 0x0A : 0x14);
-
-  // Flags - UTF-8 compression and separating crc and sizes
-  // into separate headers for deflated file
-  header[4] = ( store ) ? SWAP_BYTES(0x0800) : 0x0808;
-
-  // Compression method 8=deflate.
-  header[5] = ( store ) ? 0x0 : SWAP_BYTES(0x08);
-
-  // Last modified date and time.
-  header[6] = (ushort)GET_INT_LO(dostime);
-  header[7] = (ushort)GET_INT_HI(dostime);
-
-  // CRC
-  header[8] = (ushort)GET_INT_LO(crc);
-  header[9] = (ushort)GET_INT_HI(crc);
-
-  // Compressed length:
-  header[10] = (ushort)GET_INT_LO(clen);
-  header[11] = (ushort)GET_INT_HI(clen);
-
-  // Uncompressed length.
-  header[12] = (ushort)GET_INT_LO(len);
-  header[13] = (ushort)GET_INT_HI(len);
-
-  // Filename length
-  header[14] = (ushort)SWAP_BYTES(fname_length);
-  // So called "extra field" length.
-  // If it's the first record we must add JAR magic sequence
-  header[15] = ( central_directory_count ) ? 0 : (ushort)SWAP_BYTES(4);
-  // So called "comment" length.
-  header[16] = 0;
-  // Disk number start
-  header[17] = 0;
-  // File flags => binary
-  header[18] = 0;
-  // More file flags
-  header[19] = 0;
-  header[20] = 0;
-  // Offset within ZIP file.
-  header[21] = (ushort)GET_INT_LO(output_file_offset);
-  header[22] = (ushort)GET_INT_HI(output_file_offset);
-
-  // Copy the whole thing into the central directory.
-  central_directory.append(header, sizeof(header));
-
-  // Copy the fname to the header.
-  central_directory.append(fname, fname_length);
-
-  // Add jar magic for the first record
-  if (central_directory_count == 0) {
-    central_directory.append((void *)jarmagic, sizeof(jarmagic));
-  }
-
-  central_directory_count++;
-}
-
-void jar::write_jar_header(const char* fname, bool store, int modtime,
-                           int len, int clen, uint crc) {
-  uint fname_length = (uint)strlen(fname);
-  ushort header[15];
-  if (modtime == 0)  modtime = default_modtime;
-  uLong dostime = get_dostime(modtime);
-
-  // ZIP LOC magic.
-  header[0] = (ushort)SWAP_BYTES(0x4B50);
-  header[1] = (ushort)SWAP_BYTES(0x0403);
-
-  // Version
-  header[2] = (ushort)SWAP_BYTES(( store ) ? 0x0A : 0x14);
-
-  // General purpose flags - same as in the Central Directory
-  header[3] = ( store ) ? SWAP_BYTES(0x0800) : 0x0808;
-
-  // Compression method = deflate
-  header[4] = ( store ) ? 0x0 : SWAP_BYTES(0x08);
-
-  // Last modified date and time.
-  header[5] = (ushort)GET_INT_LO(dostime);
-  header[6] = (ushort)GET_INT_HI(dostime);
-
-  // CRC, 0 if deflated, will come separately in extra header
-  header[7] = ( store ) ? (ushort)GET_INT_LO(crc) : 0;
-  header[8] = ( store ) ? (ushort)GET_INT_HI(crc) : 0;
-
-  // Compressed length, 0 if deflated
-  header[9] = ( store ) ? (ushort)GET_INT_LO(clen) : 0;
-  header[10] = ( store ) ? (ushort)GET_INT_HI(clen) : 0;
-
-  // Uncompressed length, 0 if deflated
-  header[11] = ( store ) ? (ushort)GET_INT_LO(len) : 0;
-  header[12] = ( store ) ? (ushort)GET_INT_HI(len) : 0;
-
-  // Filename length
-  header[13] = (ushort)SWAP_BYTES(fname_length);
-  // So called "extra field" length.
-  header[14] = ( central_directory_count - 1 ) ? 0 : (ushort)SWAP_BYTES(4);
-
-  // Write the LOC header to the output file.
-  write_data(header, (int)sizeof(header));
-
-  // Copy the fname to the header.
-  write_data((char*)fname, (int)fname_length);
-
-  if (central_directory_count == 1) {
-    // Write JAR magic sequence
-    write_data((void *)jarmagic, (int)sizeof(jarmagic));
-  }
-}
-
-void jar::write_jar_extra(int len, int clen, uint crc) {
-  ushort header[8];
-  // Extra field signature
-  header[0] = (ushort)SWAP_BYTES(0x4B50);
-  header[1] = (ushort)SWAP_BYTES(0x0807);
-  // CRC
-  header[2] = (ushort)GET_INT_LO(crc);
-  header[3] = (ushort)GET_INT_HI(crc);
-  // Compressed length
-  header[4] = (ushort)GET_INT_LO(clen);
-  header[5] = (ushort)GET_INT_HI(clen);
-  // Uncompressed length
-  header[6] = (ushort)GET_INT_LO(len);
-  header[7] = (ushort)GET_INT_HI(len);
-
-  write_data(header, sizeof(header));
-}
-
-static const char marker_comment[] = ZIP_ARCHIVE_MARKER_COMMENT;
-
-void jar::write_central_directory() {
-  bytes mc; mc.set(marker_comment);
-
-  ushort header[11];
-  ushort header64[38];
-
-  // Create the End of Central Directory structure.
-  header[0] = (ushort)SWAP_BYTES(0x4B50);
-  header[1] = (ushort)SWAP_BYTES(0x0605);
-  // disk numbers
-  header[2] = 0;
-  header[3] = 0;
-  // Number of entries in central directory.
-  header[4] = ( central_directory_count >= 0xffff ) ? 0xffff : (ushort)SWAP_BYTES(central_directory_count);
-  header[5] = ( central_directory_count >= 0xffff ) ? 0xffff : (ushort)SWAP_BYTES(central_directory_count);
-  // Size of the central directory}
-  header[6] = (ushort)GET_INT_LO((int)central_directory.size());
-  header[7] = (ushort)GET_INT_HI((int)central_directory.size());
-  // Offset of central directory within disk.
-  header[8] = (ushort)GET_INT_LO(output_file_offset);
-  header[9] = (ushort)GET_INT_HI(output_file_offset);
-  // zipfile comment length;
-  header[10] = (ushort)SWAP_BYTES((int)mc.len);
-
-  // Write the central directory.
-  PRINTCR((2, "Central directory at %d\n", output_file_offset));
-  write_data(central_directory.b);
-
-  // If number of records exceeds the 0xFFFF we need to prepend extended
-  // Zip64 End of Central Directory record and its locator to the old
-  // style ECD record
-  if (central_directory_count > 0xFFFF) {
-    // Zip64 END signature
-    header64[0] = (ushort)SWAP_BYTES(0x4B50);
-    header64[1] = (ushort)0x0606;
-    // Size of header (long)
-    header64[2] = (ushort)SWAP_BYTES(44);;
-    header64[3] = 0;
-    header64[4] = 0;
-    header64[5] = 0;
-    // Version produced and required (short)
-    header64[6] = (ushort)SWAP_BYTES(45);
-    header64[7] = (ushort)SWAP_BYTES(45);
-    // Current disk number (int)
-    header64[8] = 0;
-    header64[9] = 0;
-    // Central directory start disk (int)
-    header64[10] = 0;
-    header64[11] = 0;
-    // Count of records on disk (long)
-    header64[12] = (ushort)GET_INT_LO(central_directory_count);
-    header64[13] = (ushort)GET_INT_HI(central_directory_count);
-    header64[14] = 0;
-    header64[15] = 0;
-    // Count of records totally (long)
-    header64[16] = (ushort)GET_INT_LO(central_directory_count);
-    header64[17] = (ushort)GET_INT_HI(central_directory_count);
-    header64[18] = 0;
-    header64[19] = 0;
-    // Length of the central directory (long)
-    header64[20] = header[6];
-    header64[21] = header[7];
-    header64[22] = 0;
-    header64[23] = 0;
-    // Offset of central directory (long)
-    header64[24] = header[8];
-    header64[25] = header[9];
-    header64[26] = 0;
-    header64[27] = 0;
-    // Zip64 end of central directory locator
-    // Locator signature
-    header64[28] = (ushort)SWAP_BYTES(0x4B50);
-    header64[29] = (ushort)SWAP_BYTES(0x0706);
-    // Start disk number (int)
-    header64[30] = 0;
-    header64[31] = 0;
-    // Offset of zip64 END record (long)
-    header64[32] = (ushort)GET_INT_LO(output_file_offset);
-    header64[33] = (ushort)GET_INT_HI(output_file_offset);
-    header64[34] = 0;
-    header64[35] = 0;
-    // Total number of disks (int)
-    header64[36] = (ushort)SWAP_BYTES(1);
-    header64[37] = 0;
-    write_data(header64, (int)sizeof(header64));
-  }
-
-  // Write the End of Central Directory structure.
-  PRINTCR((2, "end-of-directory at %d\n", output_file_offset));
-  write_data(header, (int)sizeof(header));
-
-  PRINTCR((2, "writing zip comment\n"));
-  // Write the comment.
-  write_data(mc);
-}
-
-// Public API
-
-// Open a Jar file and initialize.
-void jar::openJarFile(const char* fname) {
-  if (!jarfp) {
-    PRINTCR((1, "jar::openJarFile: opening %s\n",fname));
-    jarfp = fopen(fname, "wb");
-    if (!jarfp) {
-      fprintf(u->errstrm, "Error: Could not open jar file: %s\n",fname);
-      exit(3); // Called only from the native standalone unpacker
-    }
-  }
-}
-
-// Add a ZIP entry and copy the file data
-void jar::addJarEntry(const char* fname,
-                      bool deflate_hint, int modtime,
-                      bytes& head, bytes& tail) {
-  int len = (int)(head.len + tail.len);
-  int clen = 0;
-
-  uint crc = get_crc32(0,Z_NULL,0);
-  if (head.len != 0)
-    crc = get_crc32(crc, (uchar *)head.ptr, (uint)head.len);
-  if (tail.len != 0)
-    crc = get_crc32(crc, (uchar *)tail.ptr, (uint)tail.len);
-
-  bool deflate = (deflate_hint && len > 0);
-
-  if (deflate) {
-    if (deflate_bytes(head, tail) == false) {
-      PRINTCR((2, "Reverting to store fn=%s\t%d -> %d\n",
-              fname, len, deflated.size()));
-      deflate = false;
-    }
-  }
-  clen = (int)((deflate) ? deflated.size() : len);
-  add_to_jar_directory(fname, !deflate, modtime, len, clen, crc);
-  write_jar_header(    fname, !deflate, modtime, len, clen, crc);
-
-  if (deflate) {
-    write_data(deflated.b);
-    // Write deflated information in extra header
-    write_jar_extra(len, clen, crc);
-  } else {
-    write_data(head);
-    write_data(tail);
-  }
-}
-
-// Add a ZIP entry for a directory name no data
-void jar::addDirectoryToJarFile(const char* dir_name) {
-  bool store = true;
-  add_to_jar_directory((const char*)dir_name, store, default_modtime, 0, 0, 0);
-  write_jar_header(    (const char*)dir_name, store, default_modtime, 0, 0, 0);
-}
-
-// Write out the central directory and close the jar file.
-void jar::closeJarFile(bool central) {
-  if (jarfp) {
-    fflush(jarfp);
-    if (central) write_central_directory();
-    fflush(jarfp);
-    fclose(jarfp);
-    PRINTCR((2, "jar::closeJarFile:closed jar-file\n"));
-  }
-  reset();
-}
-
-/* Convert the date y/n/d and time h:m:s to a four byte DOS date and
- *  time (date in high two bytes, time in low two bytes allowing magnitude
- *  comparison).
- */
-inline
-uLong jar::dostime(int y, int n, int d, int h, int m, int s) {
-  return y < 1980 ? dostime(1980, 1, 1, 0, 0, 0) :
-    (((uLong)y - 1980) << 25) | ((uLong)n << 21) | ((uLong)d << 16) |
-    ((uLong)h << 11) | ((uLong)m << 5) | ((uLong)s >> 1);
-}
-
-#ifdef _REENTRANT // solaris
-extern "C" struct tm *gmtime_r(const time_t *, struct tm *);
-#else
-#define gmtime_r(t, s) gmtime(t)
-#endif
-/*
- * Return the Unix time in DOS format
- */
-uLong jar::get_dostime(int modtime) {
-  // see defines.h
-  if (modtime != 0 && modtime == modtime_cache)
-    return dostime_cache;
-  if (modtime != 0 && default_modtime == 0)
-    default_modtime = modtime;  // catch a reasonable default
-  time_t t = modtime;
-  struct tm sbuf;
-  (void)memset((void*)&sbuf,0, sizeof(sbuf));
-  struct tm* s = gmtime_r(&t, &sbuf);
-  if (s == NULL) {
-    fprintf(u->errstrm, "Error: gmtime failure, invalid input archive\n");
-    exit(-1);
-  }
-  modtime_cache = modtime;
-  dostime_cache = dostime(s->tm_year + 1900, s->tm_mon + 1, s->tm_mday,
-                          s->tm_hour, s->tm_min, s->tm_sec);
-  //printf("modtime %d => %d\n", modtime_cache, dostime_cache);
-  return dostime_cache;
-}
-
-
-
-#ifndef NO_ZLIB
-
-/* Returns true on success, and will set the clen to the compressed
-   length, the caller should verify if true and clen less than the
-   input data
-*/
-bool jar::deflate_bytes(bytes& head, bytes& tail) {
-  int len = (int)(head.len + tail.len);
-
-  z_stream zs;
-  BYTES_OF(zs).clear();
-
-  // NOTE: the window size should always be -MAX_WBITS normally -15.
-  // unzip/zipup.c and java/Deflater.c
-
-  int error = deflateInit2(&zs, Z_DEFAULT_COMPRESSION, Z_DEFLATED,
-                           -MAX_WBITS, 8, Z_DEFAULT_STRATEGY);
-  if (error != Z_OK) {
-    switch (error) {
-    case Z_MEM_ERROR:
-      PRINTCR((2, "Error: deflate error : Out of memory \n"));
-      break;
-    case Z_STREAM_ERROR:
-      PRINTCR((2,"Error: deflate error : Invalid compression level \n"));
-      break;
-    case Z_VERSION_ERROR:
-      PRINTCR((2,"Error: deflate error : Invalid version\n"));
-      break;
-    default:
-      PRINTCR((2,"Error: Internal deflate error error = %d\n", error));
-    }
-    return false;
-  }
-
-  deflated.empty();
-  zs.next_out  = (uchar*) deflated.grow(add_size(len, (len/2)));
-  zs.avail_out = (int)deflated.size();
-
-  zs.next_in = (uchar*)head.ptr;
-  zs.avail_in = (int)head.len;
-
-  bytes* first = &head;
-  bytes* last  = &tail;
-  if (last->len == 0) {
-    first = null;
-    last = &head;
-  } else if (first->len == 0) {
-    first = null;
-  }
-
-  if (first != null && error == Z_OK) {
-    zs.next_in = (uchar*) first->ptr;
-    zs.avail_in = (int)first->len;
-    error = deflate(&zs, Z_NO_FLUSH);
-  }
-  if (error == Z_OK) {
-    zs.next_in = (uchar*) last->ptr;
-    zs.avail_in = (int)last->len;
-    error = deflate(&zs, Z_FINISH);
-  }
-  if (error == Z_STREAM_END) {
-    if ((int)zs.total_out > 0) {
-      // Even if compressed size is bigger than uncompressed, write it
-      PRINTCR((2, "deflate compressed data %d -> %d\n", len, zs.total_out));
-      deflated.b.len = zs.total_out;
-      deflateEnd(&zs);
-      return true;
-    }
-    PRINTCR((2, "deflate expanded data %d -> %d\n", len, zs.total_out));
-    deflateEnd(&zs);
-    return false;
-  }
-
-  deflateEnd(&zs);
-  PRINTCR((2, "Error: deflate error deflate did not finish error=%d\n",error));
-  return false;
-}
-
-// Callback for fetching data from a GZIP input stream
-static jlong read_input_via_gzip(unpacker* u,
-                                  void* buf, jlong minlen, jlong maxlen) {
-  assert(minlen <= maxlen);  // don't talk nonsense
-  jlong numread = 0;
-  char* bufptr = (char*) buf;
-  char* inbuf = u->gzin->inbuf;
-  size_t inbuflen = sizeof(u->gzin->inbuf);
-  unpacker::read_input_fn_t read_gzin_fn =
-    (unpacker::read_input_fn_t) u->gzin->read_input_fn;
-  z_stream& zs = *(z_stream*) u->gzin->zstream;
-  while (numread < minlen) {
-    int readlen = (1 << 16);  // pretty arbitrary
-    if (readlen > (maxlen - numread))
-      readlen = (int)(maxlen - numread);
-    zs.next_out = (uchar*) bufptr;
-    zs.avail_out = readlen;
-    if (zs.avail_in == 0) {
-      zs.avail_in = (int) read_gzin_fn(u, inbuf, 1, inbuflen);
-      zs.next_in = (uchar*) inbuf;
-    }
-    int error = inflate(&zs, Z_NO_FLUSH);
-    if (error != Z_OK && error != Z_STREAM_END) {
-      u->abort("error inflating input");
-      break;
-    }
-    int nr = readlen - zs.avail_out;
-    u->gzcrc = crc32(u->gzcrc, (const unsigned char *)bufptr, nr);
-    numread += nr;
-    bufptr += nr;
-    assert(numread <= maxlen);
-    if (error == Z_STREAM_END) {
-      enum { TRAILER_LEN = 8 };
-      // skip 8-byte trailer
-      if (zs.avail_in >= TRAILER_LEN) {
-        zs.avail_in -= TRAILER_LEN;
-      } else {
-        // Bug: 5023768,we read past the TRAILER_LEN to see if there is
-        // any extraneous data, as we don't support concatenated .gz
-        // files just yet.
-        int extra = (int) read_gzin_fn(u, inbuf, 1, inbuflen);
-        zs.avail_in += extra - TRAILER_LEN;
-      }
-      // %%% should check final CRC and length here
-      // %%% should check for concatenated *.gz files here
-      if (zs.avail_in > 0)
-        u->abort("garbage after end of deflated input stream");
-      // pop this filter off:
-      u->gzin->free();
-      break;
-    }
-  }
-
-  //fprintf(u->errstrm, "readInputFn(%d,%d) => %d (gunzip)\n",
-  //        (int)minlen, (int)maxlen, (int)numread);
-  return numread;
-}
-
-void gunzip::init(unpacker* u_) {
-  BYTES_OF(*this).clear();
-  u = u_;
-  assert(u->gzin == null);  // once only, please
-  read_input_fn = (void*)u->read_input_fn;
-  zstream = NEW(z_stream, 1);
-  u->gzin = this;
-  u->read_input_fn = read_input_via_gzip;
-  u->gzcrc = crc32(0L, Z_NULL, 0);
-}
-
-void gunzip::start(int magic) {
-  assert((magic & GZIP_MAGIC_MASK) == GZIP_MAGIC);
-  int gz_flg = (magic & 0xFF);  // keep "flg", discard other 3 bytes
-  enum {
-    FHCRC    = (1<<1),
-    FEXTRA   = (1<<2),
-    FNAME    = (1<<3),
-    FCOMMENT = (1<<4)
-  };
-  char gz_mtime[4];
-  char gz_xfl[1];
-  char gz_os[1];
-  char gz_extra_len[2];
-  char gz_hcrc[2];
-  char gz_ignore;
-  // do not save extra, name, comment
-  read_fixed_field(gz_mtime, sizeof(gz_mtime));
-  read_fixed_field(gz_xfl, sizeof(gz_xfl));
-  read_fixed_field(gz_os, sizeof(gz_os));
-  if (gz_flg & FEXTRA) {
-    read_fixed_field(gz_extra_len, sizeof(gz_extra_len));
-    int extra_len = gz_extra_len[0] & 0xFF;
-    extra_len += (gz_extra_len[1] & 0xFF) << 8;
-    for (; extra_len > 0; extra_len--) {
-      read_fixed_field(&gz_ignore, 1);
-    }
-  }
-  int null_terms = 0;
-  if (gz_flg & FNAME)     null_terms++;
-  if (gz_flg & FCOMMENT)  null_terms++;
-  for (; null_terms; null_terms--) {
-    for (;;) {
-      gz_ignore = 0;
-      read_fixed_field(&gz_ignore, 1);
-      if (gz_ignore == 0)  break;
-    }
-  }
-  if (gz_flg & FHCRC)
-    read_fixed_field(gz_hcrc, sizeof(gz_hcrc));
-
-  if (aborting())  return;
-
-  // now the input stream is ready to read into the inflater
-  int error = inflateInit2((z_stream*) zstream, -MAX_WBITS);
-  if (error != Z_OK) { abort("cannot create input"); return; }
-}
-
-void gunzip::free() {
-  assert(u->gzin == this);
-  u->gzin = null;
-  u->read_input_fn = (unpacker::read_input_fn_t) this->read_input_fn;
-  inflateEnd((z_stream*) zstream);
-  mtrace('f', zstream, 0);
-  ::free(zstream);
-  zstream = null;
-  mtrace('f', this, 0);
-  ::free(this);
-}
-
-void gunzip::read_fixed_field(char* buf, size_t buflen) {
-  if (aborting())  return;
-  jlong nr = ((unpacker::read_input_fn_t)read_input_fn)
-    (u, buf, buflen, buflen);
-  if ((size_t)nr != buflen)
-    u->abort("short stream header");
-}
-
-#else // NO_ZLIB
-
-void gunzip::free() {
-}
-
-#endif // NO_ZLIB
--- a/jdk/src/jdk.runtime/share/native/common-unpack/zip.h	Fri Mar 06 13:30:49 2015 +0300
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,113 +0,0 @@
-/*
- * Copyright (c) 2001, 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.
- */
-
-#define ushort unsigned short
-#define uint   unsigned int
-#define uchar  unsigned char
-
-struct unpacker;
-
-struct jar {
-  // JAR file writer
-  FILE*       jarfp;
-  int         default_modtime;
-
-  // Used by unix2dostime:
-  int         modtime_cache;
-  uLong       dostime_cache;
-
-  // Private members
-  fillbytes   central_directory;
-  uint        central_directory_count;
-  uint        output_file_offset;
-  fillbytes   deflated;  // temporary buffer
-
-  // pointer to outer unpacker, for error checks etc.
-  unpacker* u;
-
-  // Public Methods
-  void openJarFile(const char* fname);
-  void addJarEntry(const char* fname,
-                   bool deflate_hint, int modtime,
-                   bytes& head, bytes& tail);
-  void addDirectoryToJarFile(const char* dir_name);
-  void closeJarFile(bool central);
-
-  void init(unpacker* u_);
-
-  void free() {
-    central_directory.free();
-    deflated.free();
-  }
-
-  void reset() {
-    free();
-    init(u);
-  }
-
-  // Private Methods
-  void write_data(void* ptr, int len);
-  void write_data(bytes& b) { write_data(b.ptr, (int)b.len); }
-  void add_to_jar_directory(const char* fname, bool store, int modtime,
-                            int len, int clen, uLong crc);
-  void write_jar_header(const char* fname, bool store, int modtime,
-                        int len, int clen, unsigned int crc);
-  void write_jar_extra(int len, int clen, unsigned int crc);
-  void write_central_directory();
-  uLong dostime(int y, int n, int d, int h, int m, int s);
-  uLong get_dostime(int modtime);
-
-  // The definitions of these depend on the NO_ZLIB option:
-  bool deflate_bytes(bytes& head, bytes& tail);
-  static uint get_crc32(uint c, unsigned char *ptr, uint len);
-
-  // error handling
-  void abort(const char* msg) { unpack_abort(msg, u); }
-  bool aborting()             { return unpack_aborting(u); }
-};
-
-struct gunzip {
-  // optional gzip input stream control block
-
-  // pointer to outer unpacker, for error checks etc.
-  unpacker* u;
-
-  void* read_input_fn;  // underlying byte stream
-  void* zstream;        // inflater state
-  char inbuf[1 << 14];   // input buffer
-
-  void init(unpacker* u_);  // pushes new value on u->read_input_fn
-
-  void free();
-
-  void start(int magic);
-
-  // private stuff
-  void read_fixed_field(char* buf, size_t buflen);
-
-  // error handling
-  void abort(const char* msg) { unpack_abort(msg, u); }
-  bool aborting()             { return unpack_aborting(u); }
-};
--- a/jdk/src/jdk.runtime/share/native/libunpack/jni.cpp	Fri Mar 06 13:30:49 2015 +0300
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,345 +0,0 @@
-/*
- * Copyright (c) 2003, 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.
- */
-#include <sys/types.h>
-
-#include <stdio.h>
-#include <string.h>
-#include <stdlib.h>
-#include <stdarg.h>
-
-
-#include <limits.h>
-
-#include <com_sun_java_util_jar_pack_NativeUnpack.h>
-
-#include "jni_util.h"
-
-#include "defines.h"
-#include "bytes.h"
-#include "utils.h"
-#include "coding.h"
-#include "bands.h"
-#include "constants.h"
-#include "zip.h"
-#include "unpack.h"
-
-
-static jfieldID  unpackerPtrFID;
-static jmethodID currentInstMID;
-static jmethodID readInputMID;
-static jclass    NIclazz;
-static jmethodID getUnpackerPtrMID;
-
-static char* dbg = null;
-
-#define THROW_IOE(x) JNU_ThrowIOException(env,x)
-
-#define CHECK_EXCEPTION_RETURN_VOID_THROW_IOE(CERVTI_exception, CERVTI_message) \
-    do { \
-        if ((env)->ExceptionOccurred()) { \
-            THROW_IOE(CERVTI_message); \
-            return; \
-        } \
-        if ((CERVTI_exception) == NULL) { \
-                THROW_IOE(CERVTI_message); \
-                return; \
-        } \
-    } while (JNI_FALSE)
-
-
-#define CHECK_EXCEPTION_RETURN_VALUE(CERL_exception, CERL_return_value) \
-    do { \
-        if ((env)->ExceptionOccurred()) { \
-            return CERL_return_value; \
-        } \
-        if ((CERL_exception) == NULL) { \
-            return CERL_return_value; \
-        } \
-    } while (JNI_FALSE)
-
-
-// If these useful macros aren't defined in jni_util.h then define them here
-#ifndef CHECK_NULL_RETURN
-#define CHECK_NULL_RETURN(x, y) \
-    do { \
-        if ((x) == NULL) return (y); \
-    } while (JNI_FALSE)
-#endif
-
-#ifndef CHECK_EXCEPTION_RETURN
-#define CHECK_EXCEPTION_RETURN(env, y) \
-    do { \
-        if ((*env)->ExceptionCheck(env)) return (y); \
-    } while (JNI_FALSE)
-#endif
-
-static jlong read_input_via_jni(unpacker* self,
-                                void* buf, jlong minlen, jlong maxlen);
-
-static unpacker* get_unpacker(JNIEnv *env, jobject pObj, bool noCreate=false) {
-  unpacker* uPtr;
-  jlong p = env->CallLongMethod(pObj, getUnpackerPtrMID);
-  uPtr = (unpacker*)jlong2ptr(p);
-  if (uPtr == null) {
-    if (noCreate)  return null;
-    uPtr = new unpacker();
-    if (uPtr == null) {
-      THROW_IOE(ERROR_ENOMEM);
-      return null;
-    }
-    //fprintf(stderr, "get_unpacker(%p) uPtr=%p initializing\n", pObj, uPtr);
-    uPtr->init(read_input_via_jni);
-    uPtr->jniobj = (void*) env->NewGlobalRef(pObj);
-    env->SetLongField(pObj, unpackerPtrFID, ptr2jlong(uPtr));
-  }
-  uPtr->jnienv = env;  // keep refreshing this in case of MT access
-  return uPtr;
-}
-
-// This is the harder trick:  Pull the current state out of mid-air.
-static unpacker* get_unpacker() {
-  //fprintf(stderr, "get_unpacker()\n");
-  JavaVM* vm = null;
-  jsize nVM = 0;
-  jint retval = JNI_GetCreatedJavaVMs(&vm, 1, &nVM);
-  // other VM implements may differ, thus for correctness, we need these checks
-  if (retval != JNI_OK || nVM != 1)
-    return null;
-  void* envRaw = null;
-  vm->GetEnv(&envRaw, JNI_VERSION_1_1);
-  JNIEnv* env = (JNIEnv*) envRaw;
-  //fprintf(stderr, "get_unpacker() env=%p\n", env);
-  CHECK_NULL_RETURN(env, NULL);
-  jobject pObj = env->CallStaticObjectMethod(NIclazz, currentInstMID);
-  // We should check upon the known non-null variable because here we want to check
-  // only for pending exceptions. If pObj is null we'll deal with it later.
-  CHECK_EXCEPTION_RETURN_VALUE(env, NULL);
-  //fprintf(stderr, "get_unpacker0() pObj=%p\n", pObj);
-  if (pObj != null) {
-    // Got pObj and env; now do it the easy way.
-    return get_unpacker(env, pObj);
-  }
-  // this should really not happen, if it does something is seriously
-  // wrong throw an exception
-  THROW_IOE(ERROR_INTERNAL);
-  return null;
-}
-
-static void free_unpacker(JNIEnv *env, jobject pObj, unpacker* uPtr) {
-  if (uPtr != null) {
-    //fprintf(stderr, "free_unpacker(%p) uPtr=%p\n", pObj, uPtr);
-    env->DeleteGlobalRef((jobject) uPtr->jniobj);
-    uPtr->jniobj = null;
-    uPtr->free();
-    delete uPtr;
-    env->SetLongField(pObj, unpackerPtrFID, (jlong)null);
-   }
-}
-
-unpacker* unpacker::current() {
-  return get_unpacker();
-}
-
-// Callback for fetching data, Java style.  Calls NativeUnpack.readInputFn().
-static jlong read_input_via_jni(unpacker* self,
-                                void* buf, jlong minlen, jlong maxlen) {
-  JNIEnv* env = (JNIEnv*) self->jnienv;
-  jobject pbuf = env->NewDirectByteBuffer(buf, maxlen);
-  return env->CallLongMethod((jobject) self->jniobj, readInputMID,
-                             pbuf, minlen);
-}
-
-JNIEXPORT void JNICALL
-Java_com_sun_java_util_jar_pack_NativeUnpack_initIDs(JNIEnv *env, jclass clazz) {
-#ifndef PRODUCT
-  dbg = getenv("DEBUG_ATTACH");
-  while( dbg != null) { sleep(10); }
-#endif
-  NIclazz = (jclass) env->NewGlobalRef(clazz);
-
-  unpackerPtrFID = env->GetFieldID(clazz, "unpackerPtr", "J");
-  CHECK_EXCEPTION_RETURN_VOID_THROW_IOE(unpackerPtrFID, ERROR_INIT);
-
-  currentInstMID = env->GetStaticMethodID(clazz, "currentInstance",
-                                          "()Ljava/lang/Object;");
-  CHECK_EXCEPTION_RETURN_VOID_THROW_IOE(currentInstMID, ERROR_INIT);
-
-  readInputMID = env->GetMethodID(clazz, "readInputFn",
-                                  "(Ljava/nio/ByteBuffer;J)J");
-  CHECK_EXCEPTION_RETURN_VOID_THROW_IOE(readInputMID, ERROR_INIT);
-
-  getUnpackerPtrMID = env->GetMethodID(clazz, "getUnpackerPtr", "()J");
-  CHECK_EXCEPTION_RETURN_VOID_THROW_IOE(getUnpackerPtrMID, ERROR_INIT);
-}
-
-JNIEXPORT jlong JNICALL
-Java_com_sun_java_util_jar_pack_NativeUnpack_start(JNIEnv *env, jobject pObj,
-                                   jobject pBuf, jlong offset) {
-  // try to get the unpacker pointer the hard way first, we do this to ensure
-  // valid object pointers and env is intact, if not now is good time to bail.
-  unpacker* uPtr = get_unpacker();
-  //fprintf(stderr, "start(%p) uPtr=%p initializing\n", pObj, uPtr);
-  CHECK_EXCEPTION_RETURN_VALUE(uPtr, -1);
-  // redirect our io to the default log file or whatever.
-  uPtr->redirect_stdio();
-
-  void*  buf    = null;
-  size_t buflen = 0;
-  if (pBuf != null) {
-    buf    = env->GetDirectBufferAddress(pBuf);
-    buflen = (size_t)env->GetDirectBufferCapacity(pBuf);
-    if (buflen == 0)  buf = null;
-    if (buf == null) { THROW_IOE(ERROR_INTERNAL); return 0; }
-    if ((size_t)offset >= buflen)
-      { buf = null; buflen = 0; }
-    else
-      { buf = (char*)buf + (size_t)offset; buflen -= (size_t)offset; }
-  }
-  // before we start off we make sure there is no other error by the time we
-  // get here
-  if (uPtr->aborting()) {
-    THROW_IOE(uPtr->get_abort_message());
-    return 0;
-  }
-  uPtr->start(buf, buflen);
-  if (uPtr->aborting()) {
-    THROW_IOE(uPtr->get_abort_message());
-    return 0;
-  }
-
-  return ((jlong)
-          uPtr->get_segments_remaining() << 32)
-    + uPtr->get_files_remaining();
-}
-
-JNIEXPORT jboolean JNICALL
-Java_com_sun_java_util_jar_pack_NativeUnpack_getNextFile(JNIEnv *env, jobject pObj,
-                                         jobjectArray pParts) {
-
-  unpacker* uPtr = get_unpacker(env, pObj);
-  CHECK_EXCEPTION_RETURN_VALUE(uPtr, false);
-  unpacker::file* filep = uPtr->get_next_file();
-
-  if (uPtr->aborting()) {
-    THROW_IOE(uPtr->get_abort_message());
-    return false;
-  }
-
-  CHECK_NULL_RETURN(filep, false);
-  assert(filep == &uPtr->cur_file);
-
-  int pidx = 0, iidx = 0;
-  jintArray pIntParts = (jintArray) env->GetObjectArrayElement(pParts, pidx++);
-  CHECK_EXCEPTION_RETURN_VALUE(pIntParts, false);
-  jint*     intParts  = env->GetIntArrayElements(pIntParts, null);
-  intParts[iidx++] = (jint)( (julong)filep->size >> 32 );
-  intParts[iidx++] = (jint)( (julong)filep->size >>  0 );
-  intParts[iidx++] = filep->modtime;
-  intParts[iidx++] = filep->deflate_hint() ? 1 : 0;
-  env->ReleaseIntArrayElements(pIntParts, intParts, JNI_COMMIT);
-  jstring filename = env->NewStringUTF(filep->name);
-  CHECK_EXCEPTION_RETURN_VALUE(filename, false);
-  env->SetObjectArrayElement(pParts, pidx++, filename);
-  CHECK_EXCEPTION_RETURN_VALUE(uPtr, false);
-  jobject pDataBuf = null;
-  if (filep->data[0].len > 0) {
-    pDataBuf = env->NewDirectByteBuffer(filep->data[0].ptr,
-                                        filep->data[0].len);
-    CHECK_EXCEPTION_RETURN_VALUE(pDataBuf, false);
-  }
-  env->SetObjectArrayElement(pParts, pidx++, pDataBuf);
-  CHECK_EXCEPTION_RETURN_VALUE(uPtr, false);
-  pDataBuf = null;
-  if (filep->data[1].len > 0) {
-    pDataBuf = env->NewDirectByteBuffer(filep->data[1].ptr,
-                                        filep->data[1].len);
-    CHECK_EXCEPTION_RETURN_VALUE(pDataBuf, false);
-  }
-  env->SetObjectArrayElement(pParts, pidx++, pDataBuf);
-  CHECK_EXCEPTION_RETURN_VALUE(uPtr, false);
-
-  return true;
-}
-
-
-JNIEXPORT jobject JNICALL
-Java_com_sun_java_util_jar_pack_NativeUnpack_getUnusedInput(JNIEnv *env, jobject pObj) {
-  unpacker* uPtr = get_unpacker(env, pObj);
-  CHECK_EXCEPTION_RETURN_VALUE(uPtr, NULL);
-  unpacker::file* filep = &uPtr->cur_file;
-
-  if (uPtr->aborting()) {
-    THROW_IOE(uPtr->get_abort_message());
-    return false;
-  }
-
-  // We have fetched all the files.
-  // Now swallow up any remaining input.
-  if (uPtr->input_remaining() == 0) {
-    return null;
-  } else {
-    bytes remaining_bytes;
-    remaining_bytes.malloc(uPtr->input_remaining());
-    remaining_bytes.copyFrom(uPtr->input_scan(), uPtr->input_remaining());
-    return env->NewDirectByteBuffer(remaining_bytes.ptr, remaining_bytes.len);
-  }
-}
-
-JNIEXPORT jlong JNICALL
-Java_com_sun_java_util_jar_pack_NativeUnpack_finish(JNIEnv *env, jobject pObj) {
-  unpacker* uPtr = get_unpacker(env, pObj, false);
-  CHECK_EXCEPTION_RETURN_VALUE(uPtr, NULL);
-  size_t consumed = uPtr->input_consumed();
-  free_unpacker(env, pObj, uPtr);
-  return consumed;
-}
-
-JNIEXPORT jboolean JNICALL
-Java_com_sun_java_util_jar_pack_NativeUnpack_setOption(JNIEnv *env, jobject pObj,
-                                       jstring pProp, jstring pValue) {
-  unpacker*   uPtr  = get_unpacker(env, pObj);
-  const char* prop  = env->GetStringUTFChars(pProp, JNI_FALSE);
-  CHECK_EXCEPTION_RETURN_VALUE(prop, false);
-  const char* value = env->GetStringUTFChars(pValue, JNI_FALSE);
-  CHECK_EXCEPTION_RETURN_VALUE(value, false);
-  jboolean   retval = uPtr->set_option(prop, value);
-  env->ReleaseStringUTFChars(pProp,  prop);
-  env->ReleaseStringUTFChars(pValue, value);
-  return retval;
-}
-
-JNIEXPORT jstring JNICALL
-Java_com_sun_java_util_jar_pack_NativeUnpack_getOption(JNIEnv *env, jobject pObj,
-                                       jstring pProp) {
-
-  unpacker*   uPtr  = get_unpacker(env, pObj);
-  CHECK_EXCEPTION_RETURN_VALUE(uPtr, NULL);
-  const char* prop  = env->GetStringUTFChars(pProp, JNI_FALSE);
-  CHECK_EXCEPTION_RETURN_VALUE(prop, NULL);
-  const char* value = uPtr->get_option(prop);
-  CHECK_EXCEPTION_RETURN_VALUE(value, NULL);
-  env->ReleaseStringUTFChars(pProp, prop);
-  return env->NewStringUTF(value);
-}
--- a/jdk/src/jdk.runtime/share/native/unpack200/main.cpp	Fri Mar 06 13:30:49 2015 +0300
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,470 +0,0 @@
-/*
- * Copyright (c) 2003, 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.
- */
-#ifdef _ALLBSD_SOURCE
-#include <stdint.h>
-#define THRTYPE intptr_t
-#else
-#define THRTYPE int
-#endif
-
-#include <sys/types.h>
-
-#include <stdio.h>
-#include <string.h>
-#include <stdlib.h>
-#include <stdarg.h>
-#include <errno.h>
-
-#include <limits.h>
-#include <time.h>
-
-#if defined(unix) && !defined(PRODUCT)
-#include "pthread.h"
-#define THREAD_SELF ((THRTYPE)pthread_self())
-#endif
-
-#include "defines.h"
-#include "bytes.h"
-#include "utils.h"
-#include "coding.h"
-#include "bands.h"
-
-#include "constants.h"
-
-#include "zip.h"
-
-#include "unpack.h"
-
-
-int main(int argc, char **argv) {
-    return unpacker::run(argc, argv);
-}
-
-// Dealing with big-endian arch
-#ifdef _BIG_ENDIAN
-#define SWAP_INT(a) (((a>>24)&0xff) | ((a<<8)&0xff0000) | ((a>>8)&0xff00) | ((a<<24)&0xff000000))
-#else
-#define SWAP_INT(a) (a)
-#endif
-
-// Single-threaded, implementation, not reentrant.
-// Includes a weak error check against MT access.
-#ifndef THREAD_SELF
-#define THREAD_SELF ((THRTYPE) 0)
-#endif
-NOT_PRODUCT(static THRTYPE uThread = -1;)
-
-unpacker* unpacker::non_mt_current = null;
-unpacker* unpacker::current() {
-  //assert(uThread == THREAD_SELF);
-  return non_mt_current;
-}
-static void set_current_unpacker(unpacker* u) {
-  unpacker::non_mt_current = u;
-  assert(((uThread = (u == null) ? (THRTYPE) -1 : THREAD_SELF),
-          true));
-}
-
-// Callback for fetching data, Unix style.
-static jlong read_input_via_stdio(unpacker* u,
-                                  void* buf, jlong minlen, jlong maxlen) {
-  assert(minlen <= maxlen);  // don't talk nonsense
-  jlong numread = 0;
-  char* bufptr = (char*) buf;
-  while (numread < minlen) {
-    // read available input, up to buf.length or maxlen
-    int readlen = (1<<16);
-    if (readlen > (maxlen - numread))
-      readlen = (int)(maxlen - numread);
-    int nr = 0;
-    if (u->infileptr != null) {
-      nr = (int)fread(bufptr, 1, readlen, u->infileptr);
-    } else {
-#ifndef WIN32
-      // we prefer unbuffered inputs
-      nr = (int)read(u->infileno, bufptr, readlen);
-#else
-      nr = (int)fread(bufptr, 1, readlen, stdin);
-#endif
-    }
-    if (nr <= 0) {
-      if (errno != EINTR)
-        break;
-      nr = 0;
-    }
-    numread += nr;
-    bufptr += nr;
-    assert(numread <= maxlen);
-  }
-  //fprintf(u->errstrm, "readInputFn(%d,%d) => %d\n",
-  //        (int)minlen, (int)maxlen, (int)numread);
-  return numread;
-}
-
-enum { EOF_MAGIC = 0, BAD_MAGIC = -1 };
-static int read_magic(unpacker* u, char peek[], int peeklen) {
-  assert(peeklen == 4);  // magic numbers are always 4 bytes
-  jlong nr = (u->read_input_fn)(u, peek, peeklen, peeklen);
-  if (nr != peeklen) {
-    return (nr == 0) ? EOF_MAGIC : BAD_MAGIC;
-  }
-  int magic = 0;
-  for (int i = 0; i < peeklen; i++) {
-    magic <<= 8;
-    magic += peek[i] & 0xFF;
-  }
-  return magic;
-}
-
-static void setup_gzin(unpacker* u) {
-  gunzip* gzin = NEW(gunzip, 1);
-  gzin->init(u);
-}
-
-static const char* nbasename(const char* progname) {
-  const char* slash = strrchr(progname, '/');
-  if (slash != null)  progname = ++slash;
-  return progname;
-}
-
-static const char* usage_lines[] = {
-  "Usage:  %s [-opt... | --option=value]... x.pack[.gz] y.jar\n",
-    "\n",
-    "Unpacking Options\n",
-    "  -H{h}, --deflate-hint={h}     override transmitted deflate hint: true, false, or keep (default)\n",
-    "  -r, --remove-pack-file        remove input file after unpacking\n",
-    "  -v, --verbose                 increase program verbosity\n",
-    "  -q, --quiet                   set verbosity to lowest level\n",
-    "  -l{F}, --log-file={F}         output to the given log file, or '-' for standard output (default)\n",
-    "  -?, -h, --help                print this message\n",
-    "  -V, --version                 print program version\n",
-    "  -J{X}                         Java VM argument (ignored)\n",
-    null
-};
-
-static void usage(unpacker* u, const char* progname, bool full = false) {
-  // WinMain does not set argv[0] to the progrname
-  progname = (progname != null) ? nbasename(progname) : "unpack200";
-  for (int i = 0; usage_lines[i] != null; i++) {
-    fprintf(u->errstrm, usage_lines[i], progname);
-    if (!full) {
-      fprintf(u->errstrm,
-              "(For more information, run %s --help .)\n", progname);
-      break;
-    }
-  }
-}
-
-// argument parsing
-static char** init_args(int argc, char** argv, int &envargc) {
-  const char* env = getenv("UNPACK200_FLAGS");
-  ptrlist envargs;
-  envargs.init();
-  if (env != null) {
-    char* buf = (char*) strdup(env);
-    const char* delim = "\n\t ";
-    for (char* p = strtok(buf, delim); p != null; p = strtok(null, delim)) {
-      envargs.add(p);
-    }
-  }
-  // allocate extra margin at both head and tail
-  char** argp = NEW(char*, envargs.length()+argc+1);
-  char** argp0 = argp;
-  int i;
-  for (i = 0; i < envargs.length(); i++) {
-    *argp++ = (char*) envargs.get(i);
-  }
-  for (i = 1; i < argc; i++) {
-    // note: skip argv[0] (program name)
-    *argp++ = (char*) strdup(argv[i]);  // make a scratch copy
-  }
-  *argp = null; // sentinel
-  envargc = envargs.length();  // report this count to next_arg
-  envargs.free();
-  return argp0;
-}
-
-static int strpcmp(const char* str, const char* pfx) {
-  return strncmp(str, pfx, strlen(pfx));
-}
-
-static const char flag_opts[] = "vqrVh?";
-static const char string_opts[] = "HlJ";
-
-static int next_arg(char** &argp) {
-  char* arg = *argp;
-  if (arg == null || arg[0] != '-') { // end of option list
-    return 0;
-  }
-  //printf("opt: %s\n", arg);
-  char ach = arg[1];
-  if (ach == '\0') {
-    // ++argp;  // do not pop this arg
-    return 0;  // bare "-" is stdin/stdout
-  } else if (arg[1] == '-') {  // --foo option
-    static const char* keys[] = {
-      "Hdeflate-hint=",
-      "vverbose",
-      "qquiet",
-      "rremove-pack-file",
-      "llog-file=",
-      "Vversion",
-      "hhelp",
-      null };
-    if (arg[2] == '\0') {  // end of option list
-      ++argp;  // pop the "--"
-      return 0;
-    }
-    for (int i = 0; keys[i] != null; i++) {
-      const char* key = keys[i];
-      char kch = *key++;
-      if (strchr(key, '=') == null) {
-        if (!strcmp(arg+2, key)) {
-          ++argp;  // pop option arg
-          return kch;
-        }
-      } else {
-        if (!strpcmp(arg+2, key)) {
-          *argp += 2 + strlen(key);  // remove "--"+key from arg
-          return kch;
-        }
-      }
-    }
-  } else if (strchr(flag_opts, ach) != null) {  // plain option
-    if (arg[2] == '\0') {
-      ++argp;
-    } else {
-      // in-place edit of "-vxyz" to "-xyz"
-      arg += 1;  // skip original '-'
-      arg[0] = '-';
-      *argp = arg;
-    }
-    //printf("  key => %c\n", ach);
-    return ach;
-  } else if (strchr(string_opts, ach) != null) {  // argument-bearing option
-    if (arg[2] == '\0') {
-      if (argp[1] == null)  return -1;  // no next arg
-      ++argp;  // leave the argument in place
-    } else {
-      // in-place edit of "-Hxyz" to "xyz"
-      arg += 2;  // skip original '-H'
-      *argp = arg;
-    }
-    //printf("  key => %c\n", ach);
-    return ach;
-  }
-  return -1;  // bad argument
-}
-
-static const char sccsver[] = "1.30, 07/05/05";
-
-// Usage:  unpackage input.pack output.jar
-int unpacker::run(int argc, char **argv) {
-  unpacker u;
-  u.init(read_input_via_stdio);
-  set_current_unpacker(&u);
-
-  jar jarout;
-  jarout.init(&u);
-
-  int envargc = 0;
-  char** argbuf = init_args(argc, argv, envargc);
-  char** arg0 = argbuf+envargc;
-  char** argp = argbuf;
-
-  int verbose = 0;
-  char* logfile = null;
-
-  for (;;) {
-    const char* arg = (*argp == null)? "": u.saveStr(*argp);
-    bool isenvarg = (argp < arg0);
-    int ach = next_arg(argp);
-    bool hasoptarg = (ach != 0 && strchr(string_opts, ach) != null);
-    if (ach == 0 && argp >= arg0)  break;
-    if (isenvarg && argp == arg0 && hasoptarg)  ach = 0;  // don't pull from cmdline
-    switch (ach) {
-    case 'H':  u.set_option(UNPACK_DEFLATE_HINT,*argp++); break;
-    case 'v':  ++verbose; break;
-    case 'q':  verbose = 0; break;
-    case 'r':  u.set_option(UNPACK_REMOVE_PACKFILE,"1"); break;
-    case 'l':  logfile = *argp++; break;
-    case 'J':  argp += 1; break;  // skip ignored -Jxxx parameter
-
-    case 'V':
-      fprintf(u.errstrm, VERSION_STRING, nbasename(argv[0]), sccsver);
-      exit(0);
-
-    case 'h':
-    case '?':
-      usage(&u, argv[0], true);
-      exit(1);
-
-    default:
-      const char* inenv = isenvarg? " in ${UNPACK200_FLAGS}": "";
-      if (hasoptarg)
-        fprintf(u.errstrm, "Missing option string%s: %s\n", inenv, arg);
-      else
-        fprintf(u.errstrm, "Unrecognized argument%s: %s\n", inenv, arg);
-      usage(&u, argv[0]);
-      exit(2);
-    }
-  }
-
-  if (verbose != 0) {
-    u.set_option(DEBUG_VERBOSE, u.saveIntStr(verbose));
-  }
-  if (logfile != null) {
-    u.set_option(UNPACK_LOG_FILE, logfile);
-  }
-
-  u.redirect_stdio();
-
-  const char* source_file      = *argp++;
-  const char* destination_file = *argp++;
-
-  if (source_file == null || destination_file == null || *argp != null) {
-    usage(&u, argv[0]);
-    exit(2);
-  }
-
-  if (verbose != 0) {
-    fprintf(u.errstrm,
-            "Unpacking from %s to %s\n", source_file, destination_file);
-  }
-  bool& remove_source = u.remove_packfile;
-
-  if (strcmp(source_file, "-") == 0) {
-    remove_source = false;
-    u.infileno = fileno(stdin);
-  } else {
-    u.infileptr = fopen(source_file, "rb");
-    if (u.infileptr == null) {
-       fprintf(u.errstrm,
-               "Error: Could not open input file: %s\n", source_file);
-       exit(3); // Called only from the native standalone unpacker
-    }
-  }
-
-  if (strcmp(destination_file, "-") == 0) {
-    jarout.jarfp = stdout;
-    if (u.errstrm == stdout) // do not mix output
-      u.set_option(UNPACK_LOG_FILE, LOGFILE_STDERR);
-  } else {
-    jarout.openJarFile(destination_file);
-    assert(jarout.jarfp != null);
-  }
-
-  if (verbose != 0)
-    u.dump_options();
-
-  char peek[4];
-  int magic;
-
-  // check for GZIP input
-  magic = read_magic(&u, peek, (int)sizeof(peek));
-  if ((magic & GZIP_MAGIC_MASK) == GZIP_MAGIC) {
-    // Oops; must slap an input filter on this data.
-    setup_gzin(&u);
-    u.gzin->start(magic);
-    if (!u.aborting()) {
-      u.start();
-    }
-  } else {
-    u.gzcrc = 0;
-    u.start(peek, sizeof(peek));
-  }
-
-  // Note:  The checks to u.aborting() are necessary to gracefully
-  // terminate processing when the first segment throws an error.
-
-  for (;;) {
-    if (u.aborting())  break;
-
-    // Each trip through this loop unpacks one segment
-    // and then resets the unpacker.
-    for (unpacker::file* filep; (filep = u.get_next_file()) != null; ) {
-      if (u.aborting())  break;
-      u.write_file_to_jar(filep);
-    }
-    if (u.aborting())  break;
-
-    // Peek ahead for more data.
-    magic = read_magic(&u, peek, (int)sizeof(peek));
-    if (magic != (int)JAVA_PACKAGE_MAGIC) {
-      if (magic != EOF_MAGIC)
-        u.abort("garbage after end of pack archive");
-      break;   // all done
-    }
-
-    // Release all storage from parsing the old segment.
-    u.reset();
-
-    // Restart, beginning with the peek-ahead.
-    u.start(peek, sizeof(peek));
-  }
-
-
-
-  int status = 0;
-  if (u.aborting()) {
-    fprintf(u.errstrm, "Error: %s\n", u.get_abort_message());
-    status = 1;
-  }
-
-  if (!u.aborting() && u.infileptr != null) {
-    if (u.gzcrc != 0) {
-      // Read the CRC information from the gzip container
-      fseek(u.infileptr, -8, SEEK_END);
-      uint filecrc;
-      fread(&filecrc, sizeof(filecrc), 1, u.infileptr);
-      if (u.gzcrc != SWAP_INT(filecrc)) { // CRC error
-        if (strcmp(destination_file, "-") != 0) {
-          // Output is not stdout, remove it, it's broken
-          if (u.jarout != null)
-            u.jarout->closeJarFile(false);
-          remove(destination_file);
-        }
-        // Print out the error and exit with return code != 0
-        u.abort("CRC error, invalid compressed data.");
-      }
-    }
-    fclose(u.infileptr);
-    u.infileptr = null;
-  }
-
-  if (!u.aborting() && remove_source)
-    remove(source_file);
-
-  if (verbose != 0) {
-    fprintf(u.errstrm, "unpacker completed with status=%d\n", status);
-  }
-
-  u.finish();
-
-  u.free();  // tidy up malloc blocks
-  set_current_unpacker(null);  // clean up global pointer
-
-  return status;
-}
--- a/jdk/src/jdk.runtime/windows/native/unpack200/unpack200_proto.exe.manifest	Fri Mar 06 13:30:49 2015 +0300
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,19 +0,0 @@
-<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
-<assembly xmlns="urn:schemas-microsoft-com:asm.v1" manifestVersion="1.0"> 
-  <assemblyIdentity version="IMVERSION"
-     processorArchitecture="X86"
-     name="unpack200.exe"
-     type="win32"/> 
-
-  <description>Java(TM) SE Runtime Environment unpack200 Process.</description> 
-  <!-- Identify the application security requirements. -->
-  <trustInfo xmlns="urn:schemas-microsoft-com:asm.v3">
-    <security>
-      <requestedPrivileges>
-        <requestedExecutionLevel
-          level="asInvoker"
-          uiAccess="false"/>
-        </requestedPrivileges>
-       </security>
-  </trustInfo>
-</assembly>