Initial import of OpenJdk files.
Create new libcore/ojluni directory with src/main/java and
src/main/native subdirectiories.
Build ojluni into core-oj jar.
Use openjdk classes from java.awt.font package.
Copy all files from jdk/src/share/classes and jdk/src/solaris/classes
directories in openjdk into libcore/ojluni/src/main/java.
Copy following native files from openjdk to
libcore/ojluni/src/main/native:
jdk/src/solaris/native/java/io/canonicalize_md.c
build/linux-amd64/include/classfile_constants.h
jdk/src/share/native/java/net/DatagramPacket.c
jdk/src/solaris/native/sun/net/spi/DefaultProxySelector.c
jdk/src/share/native/java/lang/Double.c
jdk/src/share/native/java/lang/fdlibm/include/fdlibm.h
jdk/src/solaris/native/sun/nio/ch/FileChannelImpl.c
jdk/src/solaris/native/java/io/FileDescriptor_md.c
jdk/src/solaris/native/sun/nio/ch/FileDispatcherImpl.c
jdk/src/share/native/java/io/FileInputStream.c
jdk/src/solaris/native/sun/nio/ch/FileKey.c
jdk/src/solaris/native/java/io/FileOutputStream_md.c
jdk/src/solaris/native/java/io/FileSystem_md.c
jdk/src/share/native/java/lang/Float.c
jdk/src/share/native/java/net/Inet4Address.c
jdk/src/solaris/native/java/net/Inet4AddressImpl.c
jdk/src/share/native/java/net/Inet6Address.c
jdk/src/solaris/native/java/net/Inet6AddressImpl.c
jdk/src/share/native/java/net/InetAddress.c
jdk/src/solaris/native/java/net/InetAddressImplFactory.c
jdk/src/share/native/java/io/io_util.c
jdk/src/solaris/native/sun/nio/ch/IOUtil.c
jdk/src/share/native/java/io/io_util.h
jdk/src/solaris/native/java/io/io_util_md.c
jdk/src/solaris/native/java/io/io_util_md.h
build/linux-amd64/tmp/java/java.nio/nio/CClassHeaders/java_io_FileDescriptor.h
build/linux-amd64/tmp/java/java.lang/java/CClassHeaders/java_io_FileInputStream.h
build/linux-amd64/tmp/java/java.lang/java/CClassHeaders/java_io_FileOutputStream.h
build/linux-amd64/tmp/java/java.lang/java/CClassHeaders/java_io_FileSystem.h
build/linux-amd64/tmp/java/java.lang/java/CClassHeaders/java_io_ObjectStreamClass.h
build/linux-amd64/tmp/java/java.lang/java/CClassHeaders/java_io_UnixFileSystem.h
build/linux-amd64/tmp/java/java.lang/java/CClassHeaders/java_lang_Double.h
build/linux-amd64/tmp/java/java.lang/java/CClassHeaders/java_lang_Float.h
build/linux-amd64/tmp/java/java.lang/java/CClassHeaders/java_lang_Integer.h
build/linux-amd64/tmp/java/java.lang/java/CClassHeaders/java_lang_Long.h
build/linux-amd64/tmp/java/java.lang/java/CClassHeaders/java_lang_Runtime.h
build/linux-amd64/tmp/java/java.lang/java/CClassHeaders/java_lang_Shutdown.h
build/linux-amd64/tmp/java/java.lang/java/CClassHeaders/java_lang_StrictMath.h
build/linux-amd64/tmp/java/java.lang/java/CClassHeaders/java_lang_String.h
build/linux-amd64/tmp/java/java.lang/java/CClassHeaders/java_lang_System.h
build/linux-amd64/tmp/java/java.lang/java/CClassHeaders/java_lang_Thread.h
build/linux-amd64/tmp/java/java.lang/java/CClassHeaders/java_lang_Throwable.h
build/linux-amd64/tmp/sun/java.net/net/CClassHeaders/java_net_DatagramPacket.h
build/linux-amd64/tmp/sun/java.net/net/CClassHeaders/java_net_Inet4Address.h
build/linux-amd64/tmp/sun/java.net/net/CClassHeaders/java_net_Inet4AddressImpl.h
build/linux-amd64/tmp/sun/java.net/net/CClassHeaders/java_net_Inet6Address.h
build/linux-amd64/tmp/sun/java.net/net/CClassHeaders/java_net_Inet6AddressImpl.h
build/linux-amd64/tmp/sun/java.net/net/CClassHeaders/java_net_InetAddress.h
build/linux-amd64/tmp/sun/java.net/net/CClassHeaders/java_net_InetAddressImplFactory.h
build/linux-amd64/tmp/sun/java.net/net/CClassHeaders/java_net_NetworkInterface.h
build/linux-amd64/tmp/sun/java.net/net/CClassHeaders/java_net_PlainDatagramSocketImpl.h
build/linux-amd64/tmp/sun/java.net/net/CClassHeaders/java_net_PlainSocketImpl.h
build/linux-amd64/tmp/sun/java.net/net/CClassHeaders/java_net_SocketInputStream.h
build/linux-amd64/tmp/sun/java.net/net/CClassHeaders/java_net_SocketOptions.h
build/linux-amd64/tmp/sun/java.net/net/CClassHeaders/java_net_SocketOutputStream.h
jdk/src/share/native/java/lang/java_props.h
jdk/src/solaris/native/java/lang/java_props_md.c
jdk/src/share/native/java/util/zip/Adler32.c as java_util_zip_Adler32.c
jdk/src/share/native/java/util/zip/CRC32.c as java_util_zip_CRC32.c
build/linux-amd64/tmp/sun/java.util.zip/zip/CClassHeaders/java_util_zip_CRC32.h
jdk/src/share/native/java/util/zip/Deflater.c as java_util_zip_Deflater.c
build/linux-amd64/tmp/sun/java.util.zip/zip/CClassHeaders/java_util_zip_Deflater.h
jdk/src/share/native/java/util/zip/Inflater.c as java_util_zip_Inflater.c
build/linux-amd64/tmp/sun/java.util.zip/zip/CClassHeaders/java_util_zip_Inflater.h
jdk/src/share/native/java/util/zip/ZipFile.c as java_util_zip_ZipFile.c
build/linux-amd64/tmp/sun/java.util.zip/zip/CClassHeaders/java_util_zip_ZipFile.h
jdk/src/share/native/java/lang/fdlibm/include/jfdlibm.h
jdk/src/share/native/common/jlong.h
jdk/src/solaris/native/common/jlong_md.h
jdk/src/share/native/common/jni_util.c
jdk/src/share/native/common/jni_util.h
jdk/src/solaris/native/common/jni_util_md.c
jdk/src/share/javavm/export/jvm.h
jdk/src/solaris/javavm/export/jvm_md.h
jdk/src/solaris/native/java/net/linux_close.c
jdk/src/share/native/sun/misc/NativeSignalHandler.c
jdk/src/solaris/native/sun/nio/ch/NativeThread.c
jdk/src/share/native/java/net/net_util.c
jdk/src/share/native/java/net/net_util.h
jdk/src/solaris/native/java/net/net_util_md.c
jdk/src/solaris/native/java/net/net_util_md.h
jdk/src/solaris/native/java/net/NetworkInterface.c
jdk/src/share/native/sun/nio/ch/nio.h
jdk/src/solaris/native/sun/nio/ch/nio_util.h
jdk/src/share/native/java/io/ObjectStreamClass.c
jdk/src/solaris/native/java/net/PlainDatagramSocketImpl.c
jdk/src/solaris/native/java/net/PlainSocketImpl.c
jdk/src/solaris/native/java/lang/ProcessEnvironment_md.c
jdk/src/share/native/java/lang/Runtime.c
jdk/src/share/native/java/lang/Shutdown.c
jdk/src/share/native/sun/misc/Signal.c
jdk/src/solaris/native/java/net/SocketInputStream.c
jdk/src/solaris/native/java/net/SocketOutputStream.c
jdk/src/share/native/java/lang/StrictMath.c
jdk/src/share/native/java/lang/String.c
build/linux-amd64/tmp/java/java.lang/java/CClassHeaders/sun_misc_NativeSignalHandler.h
build/linux-amd64/tmp/java/java.lang/java/CClassHeaders/sun_misc_Signal.h
build/linux-amd64/tmp/sun/java.net/net/CClassHeaders/sun_net_spi_DefaultProxySelector.h
build/linux-amd64/tmp/java/java.nio/nio/CClassHeaders/sun_nio_ch_FileChannelImpl.h
build/linux-amd64/tmp/java/java.nio/nio/CClassHeaders/sun_nio_ch_FileDispatcherImpl.h
build/linux-amd64/tmp/java/java.nio/nio/CClassHeaders/sun_nio_ch_FileKey.h
build/linux-amd64/tmp/java/java.nio/nio/CClassHeaders/sun_nio_ch_IOStatus.h
build/linux-amd64/tmp/java/java.nio/nio/CClassHeaders/sun_nio_ch_IOUtil.h
build/linux-amd64/tmp/java/java.nio/nio/CClassHeaders/sun_nio_ch_NativeThread.h
jdk/src/share/native/java/lang/System.c
jdk/src/share/native/java/lang/Thread.c
jdk/src/share/native/java/lang/Throwable.c
jdk/src/solaris/native/java/io/UnixFileSystem_md.c
jdk/src/solaris/native/java/lang/UNIXProcess_md.c
jdk/src/share/native/java/util/zip/zip_util.c
jdk/src/share/native/java/util/zip/zip_util.h
Change-Id: Ib237df4e1b7b5b4d9f12e74d189e6ec9eed3c31d
diff --git a/ojluni/src/main/native/java_util_zip_ZipFile.c b/ojluni/src/main/native/java_util_zip_ZipFile.c
new file mode 100755
index 0000000..30fbfdd
--- /dev/null
+++ b/ojluni/src/main/native/java_util_zip_ZipFile.c
@@ -0,0 +1,395 @@
+/*
+ * Copyright (c) 1998, 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.
+ */
+
+/*
+ * Native method support for java.util.zip.ZipFile
+ */
+
+#include <stdio.h>
+#include <stdlib.h>
+#include <string.h>
+#include <errno.h>
+#include <ctype.h>
+#include <assert.h>
+#include "jlong.h"
+#include "jvm.h"
+#include "jni.h"
+#include "jni_util.h"
+#include "zip_util.h"
+#ifdef WIN32
+#include "io_util_md.h"
+#else
+#include "io_util.h"
+#endif
+
+#include "java_util_zip_ZipFile.h"
+#include "java_util_jar_JarFile.h"
+
+#define DEFLATED 8
+#define STORED 0
+
+static jfieldID jzfileID;
+
+static int OPEN_READ = java_util_zip_ZipFile_OPEN_READ;
+static int OPEN_DELETE = java_util_zip_ZipFile_OPEN_DELETE;
+
+JNIEXPORT void JNICALL
+Java_java_util_zip_ZipFile_initIDs(JNIEnv *env, jclass cls)
+{
+ jzfileID = (*env)->GetFieldID(env, cls, "jzfile", "J");
+ assert(jzfileID != 0);
+}
+
+static void
+ThrowZipException(JNIEnv *env, const char *msg)
+{
+ jstring s = NULL;
+ jobject x;
+
+ if (msg != NULL) {
+ s = JNU_NewStringPlatform(env, msg);
+ }
+ x = JNU_NewObjectByName(env,
+ "java/util/zip/ZipException",
+ "(Ljava/lang/String;)V", s);
+ if (x != NULL) {
+ (*env)->Throw(env, x);
+ }
+}
+
+JNIEXPORT jlong JNICALL
+Java_java_util_zip_ZipFile_open(JNIEnv *env, jclass cls, jstring name,
+ jint mode, jlong lastModified,
+ jboolean usemmap)
+{
+ const char *path = JNU_GetStringPlatformChars(env, name, 0);
+ char *msg = 0;
+ jlong result = 0;
+ int flag = 0;
+ jzfile *zip = 0;
+
+ if (mode & OPEN_READ) flag |= O_RDONLY;
+ if (mode & OPEN_DELETE) flag |= JVM_O_DELETE;
+
+ if (path != 0) {
+ zip = ZIP_Get_From_Cache(path, &msg, lastModified);
+ if (zip == 0 && msg == 0) {
+ ZFILE zfd = 0;
+#ifdef WIN32
+ zfd = winFileHandleOpen(env, name, flag);
+ if (zfd == -1) {
+ /* Exception already pending. */
+ goto finally;
+ }
+#else
+ zfd = JVM_Open(path, flag, 0);
+ if (zfd < 0) {
+ throwFileNotFoundException(env, name);
+ goto finally;
+ }
+#endif
+ zip = ZIP_Put_In_Cache0(path, zfd, &msg, lastModified, usemmap);
+ }
+
+ if (zip != 0) {
+ result = ptr_to_jlong(zip);
+ } else if (msg != 0) {
+ ThrowZipException(env, msg);
+ free(msg);
+ } else if (errno == ENOMEM) {
+ JNU_ThrowOutOfMemoryError(env, 0);
+ } else {
+ ThrowZipException(env, "error in opening zip file");
+ }
+finally:
+ JNU_ReleaseStringPlatformChars(env, name, path);
+ }
+ return result;
+}
+
+JNIEXPORT jint JNICALL
+Java_java_util_zip_ZipFile_getTotal(JNIEnv *env, jclass cls, jlong zfile)
+{
+ jzfile *zip = jlong_to_ptr(zfile);
+
+ return zip->total;
+}
+
+JNIEXPORT jboolean JNICALL
+Java_java_util_zip_ZipFile_startsWithLOC(JNIEnv *env, jclass cls, jlong zfile)
+{
+ jzfile *zip = jlong_to_ptr(zfile);
+
+ return zip->locsig;
+}
+
+JNIEXPORT void JNICALL
+Java_java_util_zip_ZipFile_close(JNIEnv *env, jclass cls, jlong zfile)
+{
+ ZIP_Close(jlong_to_ptr(zfile));
+}
+
+JNIEXPORT jlong JNICALL
+Java_java_util_zip_ZipFile_getEntry(JNIEnv *env, jclass cls, jlong zfile,
+ jbyteArray name, jboolean addSlash)
+{
+#define MAXNAME 1024
+ jzfile *zip = jlong_to_ptr(zfile);
+ jsize ulen = (*env)->GetArrayLength(env, name);
+ char buf[MAXNAME+2], *path;
+ jzentry *ze;
+
+ if (ulen > MAXNAME) {
+ path = malloc(ulen + 2);
+ if (path == 0) {
+ JNU_ThrowOutOfMemoryError(env, 0);
+ return 0;
+ }
+ } else {
+ path = buf;
+ }
+ (*env)->GetByteArrayRegion(env, name, 0, ulen, (jbyte *)path);
+ path[ulen] = '\0';
+ if (addSlash == JNI_FALSE) {
+ ze = ZIP_GetEntry(zip, path, 0);
+ } else {
+ ze = ZIP_GetEntry(zip, path, (jint)ulen);
+ }
+ if (path != buf) {
+ free(path);
+ }
+ return ptr_to_jlong(ze);
+}
+
+JNIEXPORT void JNICALL
+Java_java_util_zip_ZipFile_freeEntry(JNIEnv *env, jclass cls, jlong zfile,
+ jlong zentry)
+{
+ jzfile *zip = jlong_to_ptr(zfile);
+ jzentry *ze = jlong_to_ptr(zentry);
+ ZIP_FreeEntry(zip, ze);
+}
+
+JNIEXPORT jlong JNICALL
+Java_java_util_zip_ZipFile_getNextEntry(JNIEnv *env, jclass cls, jlong zfile,
+ jint n)
+{
+ jzentry *ze = ZIP_GetNextEntry(jlong_to_ptr(zfile), n);
+ return ptr_to_jlong(ze);
+}
+
+JNIEXPORT jint JNICALL
+Java_java_util_zip_ZipFile_getEntryMethod(JNIEnv *env, jclass cls, jlong zentry)
+{
+ jzentry *ze = jlong_to_ptr(zentry);
+ return ze->csize != 0 ? DEFLATED : STORED;
+}
+
+JNIEXPORT jint JNICALL
+Java_java_util_zip_ZipFile_getEntryFlag(JNIEnv *env, jclass cls, jlong zentry)
+{
+ jzentry *ze = jlong_to_ptr(zentry);
+ return ze->flag;
+}
+
+JNIEXPORT jlong JNICALL
+Java_java_util_zip_ZipFile_getEntryCSize(JNIEnv *env, jclass cls, jlong zentry)
+{
+ jzentry *ze = jlong_to_ptr(zentry);
+ return ze->csize != 0 ? ze->csize : ze->size;
+}
+
+JNIEXPORT jlong JNICALL
+Java_java_util_zip_ZipFile_getEntrySize(JNIEnv *env, jclass cls, jlong zentry)
+{
+ jzentry *ze = jlong_to_ptr(zentry);
+ return ze->size;
+}
+
+JNIEXPORT jlong JNICALL
+Java_java_util_zip_ZipFile_getEntryTime(JNIEnv *env, jclass cls, jlong zentry)
+{
+ jzentry *ze = jlong_to_ptr(zentry);
+ return (jlong)ze->time & 0xffffffffUL;
+}
+
+JNIEXPORT jlong JNICALL
+Java_java_util_zip_ZipFile_getEntryCrc(JNIEnv *env, jclass cls, jlong zentry)
+{
+ jzentry *ze = jlong_to_ptr(zentry);
+ return (jlong)ze->crc & 0xffffffffUL;
+}
+
+JNIEXPORT jbyteArray JNICALL
+Java_java_util_zip_ZipFile_getCommentBytes(JNIEnv *env,
+ jclass cls,
+ jlong zfile)
+{
+ jzfile *zip = jlong_to_ptr(zfile);
+ jbyteArray jba = NULL;
+
+ if (zip->comment != NULL) {
+ if ((jba = (*env)->NewByteArray(env, zip->clen)) == NULL)
+ return NULL;
+ (*env)->SetByteArrayRegion(env, jba, 0, zip->clen, (jbyte*)zip->comment);
+ }
+ return jba;
+}
+
+JNIEXPORT jbyteArray JNICALL
+Java_java_util_zip_ZipFile_getEntryBytes(JNIEnv *env,
+ jclass cls,
+ jlong zentry, jint type)
+{
+ jzentry *ze = jlong_to_ptr(zentry);
+ int len = 0;
+ jbyteArray jba = NULL;
+ switch (type) {
+ case java_util_zip_ZipFile_JZENTRY_NAME:
+ if (ze->name != 0) {
+ len = (int)strlen(ze->name);
+ if (len == 0 || (jba = (*env)->NewByteArray(env, len)) == NULL)
+ break;
+ (*env)->SetByteArrayRegion(env, jba, 0, len, (jbyte *)ze->name);
+ }
+ break;
+ case java_util_zip_ZipFile_JZENTRY_EXTRA:
+ if (ze->extra != 0) {
+ unsigned char *bp = (unsigned char *)&ze->extra[0];
+ len = (bp[0] | (bp[1] << 8));
+ if (len <= 0 || (jba = (*env)->NewByteArray(env, len)) == NULL)
+ break;
+ (*env)->SetByteArrayRegion(env, jba, 0, len, &ze->extra[2]);
+ }
+ break;
+ case java_util_zip_ZipFile_JZENTRY_COMMENT:
+ if (ze->comment != 0) {
+ len = (int)strlen(ze->comment);
+ if (len == 0 || (jba = (*env)->NewByteArray(env, len)) == NULL)
+ break;
+ (*env)->SetByteArrayRegion(env, jba, 0, len, (jbyte*)ze->comment);
+ }
+ break;
+ }
+ return jba;
+}
+
+JNIEXPORT jint JNICALL
+Java_java_util_zip_ZipFile_read(JNIEnv *env, jclass cls, jlong zfile,
+ jlong zentry, jlong pos, jbyteArray bytes,
+ jint off, jint len)
+{
+ jzfile *zip = jlong_to_ptr(zfile);
+ char *msg;
+
+#define BUFSIZE 8192
+ /* copy via tmp stack buffer: */
+ jbyte buf[BUFSIZE];
+
+ if (len > BUFSIZE) {
+ len = BUFSIZE;
+ }
+
+ ZIP_Lock(zip);
+ len = ZIP_Read(zip, jlong_to_ptr(zentry), pos, buf, len);
+ msg = zip->msg;
+ ZIP_Unlock(zip);
+ if (len != -1) {
+ (*env)->SetByteArrayRegion(env, bytes, off, len, buf);
+ }
+
+ if (len == -1) {
+ if (msg != 0) {
+ ThrowZipException(env, msg);
+ } else {
+ char errmsg[128];
+ sprintf(errmsg, "errno: %d, error: %s\n",
+ errno, "Error reading ZIP file");
+ JNU_ThrowIOExceptionWithLastError(env, errmsg);
+ }
+ }
+
+ return len;
+}
+
+/*
+ * Returns an array of strings representing the names of all entries
+ * that begin with "META-INF/" (case ignored). This native method is
+ * used in JarFile as an optimization when looking up manifest and
+ * signature file entries. Returns null if no entries were found.
+ */
+JNIEXPORT jobjectArray JNICALL
+Java_java_util_jar_JarFile_getMetaInfEntryNames(JNIEnv *env, jobject obj)
+{
+ jlong zfile = (*env)->GetLongField(env, obj, jzfileID);
+ jzfile *zip;
+ int i, count;
+ jobjectArray result = 0;
+
+ if (zfile == 0) {
+ JNU_ThrowByName(env,
+ "java/lang/IllegalStateException", "zip file closed");
+ return NULL;
+ }
+ zip = jlong_to_ptr(zfile);
+
+ /* count the number of valid ZIP metanames */
+ count = 0;
+ if (zip->metanames != 0) {
+ for (i = 0; i < zip->metacount; i++) {
+ if (zip->metanames[i] != 0) {
+ count++;
+ }
+ }
+ }
+
+ /* If some names were found then build array of java strings */
+ if (count > 0) {
+ jclass cls = (*env)->FindClass(env, "java/lang/String");
+ result = (*env)->NewObjectArray(env, count, cls, 0);
+ if (result != 0) {
+ for (i = 0; i < count; i++) {
+ jstring str = (*env)->NewStringUTF(env, zip->metanames[i]);
+ if (str == 0) {
+ break;
+ }
+ (*env)->SetObjectArrayElement(env, result, i, str);
+ (*env)->DeleteLocalRef(env, str);
+ }
+ }
+ }
+ return result;
+}
+
+JNIEXPORT jstring JNICALL
+Java_java_util_zip_ZipFile_getZipMessage(JNIEnv *env, jclass cls, jlong zfile)
+{
+ jzfile *zip = jlong_to_ptr(zfile);
+ char *msg = zip->msg;
+ if (msg == NULL) {
+ return NULL;
+ }
+ return JNU_NewStringPlatform(env, msg);
+}