Use OpenJdk implementation of java.util.zip.*
- Move some of the internal implementation details of libcore's
zipfile into StrictJarFile.
- TODO: Adler32 continues to use old native code from libcore, this
must be switched over.
- InflaterInputStream: |closed| becomes protected.
- ZipFile : Always use mmap.
- ZipEntry : Add a long dataOffset.
- Switch all native code over to explicit registration.
Change-Id: Id5519b4548ea1eb22fd182edfbd2c804dc6f3bb5
diff --git a/NativeCode.mk b/NativeCode.mk
index 0ae615e..3ad4e1a 100644
--- a/NativeCode.mk
+++ b/NativeCode.mk
@@ -47,6 +47,13 @@
LOCAL_SRC_FILES :=
endef
+define include-openjdk-native-dir
+ LOCAL_SRC_FILES :=
+ include $(LOCAL_PATH)/$(1)/openjdksub.mk
+ openjdk_core_src_files += $$(addprefix $(1)/,$$(LOCAL_SRC_FILES))
+ LOCAL_SRC_FILES :=
+endef
+
# Set up the default state. Note: We use CLEAR_VARS here, even though
# we aren't quite defining a new rule yet, to make sure that the
# sub.mk files don't see anything stray from the last rule that was
@@ -56,6 +63,13 @@
LOCAL_MODULE := $(core_magic_local_target)
LOCAL_ADDITIONAL_DEPENDENCIES := $(LOCAL_PATH)/NativeCode.mk
core_src_files :=
+openjdk_core_src_files :=
+
+#Include the sub.m in openjdk.
+$(foreach dir, \
+ ojluni/src/main/native, \
+ $(eval $(call include-openjdk-native-dir,$(dir))))
+
# Include the sub.mk files.
$(foreach dir, \
@@ -90,6 +104,27 @@
include external/stlport/libstlport.mk
include $(BUILD_SHARED_LIBRARY)
+include $(CLEAR_VARS)
+
+LOCAL_CFLAGS += -Wall
+LOCAL_CFLAGS += $(core_cflags)
+LOCAL_CPPFLAGS += $(core_cppflags)
+ifeq ($(TARGET_ARCH),arm)
+# Ignore "note: the mangling of 'va_list' has changed in GCC 4.4"
+LOCAL_CFLAGS += -Wno-psabi
+endif
+
+# Define the rules.
+LOCAL_SRC_FILES := $(openjdk_core_src_files)
+LOCAL_C_INCLUDES := $(core_c_includes)
+LOCAL_SHARED_LIBRARIES := $(core_shared_libraries) libcrypto libssl libz
+LOCAL_SHARED_LIBRARIES += libart libnativehelper libdl
+LOCAL_STATIC_LIBRARIES := $(core_static_libraries) libfdlibm
+LOCAL_MODULE_TAGS := optional
+LOCAL_MODULE := libopenjdkjavacore
+include external/stlport/libstlport.mk
+include $(BUILD_SHARED_LIBRARY)
+
# Test JNI library.
ifeq ($(LIBCORE_SKIP_TESTS),)
diff --git a/jvm.h b/jvm.h
new file mode 100644
index 0000000..ed51dd1
--- /dev/null
+++ b/jvm.h
@@ -0,0 +1,1483 @@
+/*
+ * Copyright (c) 1997, 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.
+ */
+
+#ifndef _JAVASOFT_JVM_H_
+#define _JAVASOFT_JVM_H_
+
+#include <sys/stat.h>
+#include <stdio.h>
+
+#include "jni.h"
+#include "jvm_md.h"
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+/*
+ * This file contains additional functions exported from the VM.
+ * These functions are complementary to the standard JNI support.
+ * There are three parts to this file:
+ *
+ * First, this file contains the VM-related functions needed by native
+ * libraries in the standard Java API. For example, the java.lang.Object
+ * class needs VM-level functions that wait for and notify monitors.
+ *
+ * Second, this file contains the functions and constant definitions
+ * needed by the byte code verifier and class file format checker.
+ * These functions allow the verifier and format checker to be written
+ * in a VM-independent way.
+ *
+ * Third, this file contains various I/O and nerwork operations needed
+ * by the standard Java I/O and network APIs.
+ */
+
+/*
+ * Bump the version number when either of the following happens:
+ *
+ * 1. There is a change in JVM_* functions.
+ *
+ * 2. There is a change in the contract between VM and Java classes.
+ * For example, if the VM relies on a new private field in Thread
+ * class.
+ */
+
+#define JVM_INTERFACE_VERSION 4
+
+JNIEXPORT jint JNICALL
+JVM_GetInterfaceVersion(void);
+
+/*************************************************************************
+ PART 1: Functions for Native Libraries
+ ************************************************************************/
+/*
+ * java.lang.Object
+ */
+JNIEXPORT jint JNICALL
+JVM_IHashCode(JNIEnv *env, jobject obj);
+
+JNIEXPORT void JNICALL
+JVM_MonitorWait(JNIEnv *env, jobject obj, jlong ms);
+
+JNIEXPORT void JNICALL
+JVM_MonitorNotify(JNIEnv *env, jobject obj);
+
+JNIEXPORT void JNICALL
+JVM_MonitorNotifyAll(JNIEnv *env, jobject obj);
+
+JNIEXPORT jobject JNICALL
+JVM_Clone(JNIEnv *env, jobject obj);
+
+/*
+ * java.lang.String
+ */
+JNIEXPORT jstring JNICALL
+JVM_InternString(JNIEnv *env, jstring str);
+
+/*
+ * java.lang.System
+ */
+JNIEXPORT jlong JNICALL
+JVM_CurrentTimeMillis(JNIEnv *env, jclass ignored);
+
+JNIEXPORT jlong JNICALL
+JVM_NanoTime(JNIEnv *env, jclass ignored);
+
+JNIEXPORT void JNICALL
+JVM_ArrayCopy(JNIEnv *env, jclass ignored, jobject src, jint src_pos,
+ jobject dst, jint dst_pos, jint length);
+
+JNIEXPORT jobject JNICALL
+JVM_InitProperties(JNIEnv *env, jobject p);
+
+/*
+ * java.io.File
+ */
+JNIEXPORT void JNICALL
+JVM_OnExit(void (*func)(void));
+
+/*
+ * java.lang.Runtime
+ */
+JNIEXPORT void JNICALL
+JVM_Exit(jint code);
+
+JNIEXPORT void JNICALL
+JVM_Halt(jint code);
+
+JNIEXPORT void JNICALL
+JVM_GC(void);
+
+/* Returns the number of real-time milliseconds that have elapsed since the
+ * least-recently-inspected heap object was last inspected by the garbage
+ * collector.
+ *
+ * For simple stop-the-world collectors this value is just the time
+ * since the most recent collection. For generational collectors it is the
+ * time since the oldest generation was most recently collected. Other
+ * collectors are free to return a pessimistic estimate of the elapsed time, or
+ * simply the time since the last full collection was performed.
+ *
+ * Note that in the presence of reference objects, a given object that is no
+ * longer strongly reachable may have to be inspected multiple times before it
+ * can be reclaimed.
+ */
+JNIEXPORT jlong JNICALL
+JVM_MaxObjectInspectionAge(void);
+
+JNIEXPORT void JNICALL
+JVM_TraceInstructions(jboolean on);
+
+JNIEXPORT void JNICALL
+JVM_TraceMethodCalls(jboolean on);
+
+JNIEXPORT jlong JNICALL
+JVM_TotalMemory(void);
+
+JNIEXPORT jlong JNICALL
+JVM_FreeMemory(void);
+
+JNIEXPORT jlong JNICALL
+JVM_MaxMemory(void);
+
+JNIEXPORT jint JNICALL
+JVM_ActiveProcessorCount(void);
+
+JNIEXPORT jstring JVM_NativeLoad(JNIEnv* env, jstring javaFilename, jobject javaLoader,
+ jstring javaLdLibraryPath);
+
+JNIEXPORT void * JNICALL
+JVM_LoadLibrary(const char *name);
+
+JNIEXPORT void JNICALL
+JVM_UnloadLibrary(void * handle);
+
+JNIEXPORT void * JNICALL
+JVM_FindLibraryEntry(void *handle, const char *name);
+
+JNIEXPORT jboolean JNICALL
+JVM_IsSupportedJNIVersion(jint version);
+
+/*
+ * java.lang.Float and java.lang.Double
+ */
+JNIEXPORT jboolean JNICALL
+JVM_IsNaN(jdouble d);
+
+/*
+ * java.lang.Throwable
+ */
+JNIEXPORT void JNICALL
+JVM_FillInStackTrace(JNIEnv *env, jobject throwable);
+
+JNIEXPORT void JNICALL
+JVM_PrintStackTrace(JNIEnv *env, jobject throwable, jobject printable);
+
+JNIEXPORT jint JNICALL
+JVM_GetStackTraceDepth(JNIEnv *env, jobject throwable);
+
+JNIEXPORT jobject JNICALL
+JVM_GetStackTraceElement(JNIEnv *env, jobject throwable, jint index);
+
+/*
+ * java.lang.Compiler
+ */
+JNIEXPORT void JNICALL
+JVM_InitializeCompiler (JNIEnv *env, jclass compCls);
+
+JNIEXPORT jboolean JNICALL
+JVM_IsSilentCompiler(JNIEnv *env, jclass compCls);
+
+JNIEXPORT jboolean JNICALL
+JVM_CompileClass(JNIEnv *env, jclass compCls, jclass cls);
+
+JNIEXPORT jboolean JNICALL
+JVM_CompileClasses(JNIEnv *env, jclass cls, jstring jname);
+
+JNIEXPORT jobject JNICALL
+JVM_CompilerCommand(JNIEnv *env, jclass compCls, jobject arg);
+
+JNIEXPORT void JNICALL
+JVM_EnableCompiler(JNIEnv *env, jclass compCls);
+
+JNIEXPORT void JNICALL
+JVM_DisableCompiler(JNIEnv *env, jclass compCls);
+
+/*
+ * java.lang.Thread
+ */
+JNIEXPORT void JNICALL
+JVM_StartThread(JNIEnv *env, jobject thread, jlong stack_size, jboolean daemon);
+
+JNIEXPORT void JNICALL
+JVM_StopThread(JNIEnv *env, jobject thread, jobject exception);
+
+JNIEXPORT jboolean JNICALL
+JVM_IsThreadAlive(JNIEnv *env, jobject thread);
+
+JNIEXPORT void JNICALL
+JVM_SuspendThread(JNIEnv *env, jobject thread);
+
+JNIEXPORT void JNICALL
+JVM_ResumeThread(JNIEnv *env, jobject thread);
+
+JNIEXPORT void JNICALL
+JVM_SetThreadPriority(JNIEnv *env, jobject thread, jint prio);
+
+JNIEXPORT void JNICALL
+JVM_Yield(JNIEnv *env, jclass threadClass);
+
+JNIEXPORT void JNICALL
+JVM_Sleep(JNIEnv *env, jclass threadClass, jobject java_object, jlong millis);
+
+JNIEXPORT jobject JNICALL
+JVM_CurrentThread(JNIEnv *env, jclass threadClass);
+
+JNIEXPORT jint JNICALL
+JVM_CountStackFrames(JNIEnv *env, jobject thread);
+
+JNIEXPORT void JNICALL
+JVM_Interrupt(JNIEnv *env, jobject thread);
+
+JNIEXPORT jboolean JNICALL
+JVM_IsInterrupted(JNIEnv *env, jobject thread, jboolean clearInterrupted);
+
+JNIEXPORT jboolean JNICALL
+JVM_HoldsLock(JNIEnv *env, jclass threadClass, jobject obj);
+
+JNIEXPORT void JNICALL
+JVM_DumpAllStacks(JNIEnv *env, jclass unused);
+
+JNIEXPORT jobjectArray JNICALL
+JVM_GetAllThreads(JNIEnv *env, jclass dummy);
+
+JNIEXPORT void JNICALL
+JVM_SetNativeThreadName(JNIEnv *env, jobject jthread, jstring name);
+
+/* getStackTrace() and getAllStackTraces() method */
+JNIEXPORT jobjectArray JNICALL
+JVM_DumpThreads(JNIEnv *env, jclass threadClass, jobjectArray threads);
+
+/*
+ * java.lang.SecurityManager
+ */
+JNIEXPORT jclass JNICALL
+JVM_CurrentLoadedClass(JNIEnv *env);
+
+JNIEXPORT jobject JNICALL
+JVM_CurrentClassLoader(JNIEnv *env);
+
+JNIEXPORT jobjectArray JNICALL
+JVM_GetClassContext(JNIEnv *env);
+
+JNIEXPORT jint JNICALL
+JVM_ClassDepth(JNIEnv *env, jstring name);
+
+JNIEXPORT jint JNICALL
+JVM_ClassLoaderDepth(JNIEnv *env);
+
+/*
+ * java.lang.Package
+ */
+JNIEXPORT jstring JNICALL
+JVM_GetSystemPackage(JNIEnv *env, jstring name);
+
+JNIEXPORT jobjectArray JNICALL
+JVM_GetSystemPackages(JNIEnv *env);
+
+/*
+ * java.io.ObjectInputStream
+ */
+JNIEXPORT jobject JNICALL
+JVM_AllocateNewObject(JNIEnv *env, jobject obj, jclass currClass,
+ jclass initClass);
+
+JNIEXPORT jobject JNICALL
+JVM_AllocateNewArray(JNIEnv *env, jobject obj, jclass currClass,
+ jint length);
+
+JNIEXPORT jobject JNICALL
+JVM_LatestUserDefinedLoader(JNIEnv *env);
+
+/*
+ * This function has been deprecated and should not be considered
+ * part of the specified JVM interface.
+ */
+JNIEXPORT jclass JNICALL
+JVM_LoadClass0(JNIEnv *env, jobject obj, jclass currClass,
+ jstring currClassName);
+
+/*
+ * java.lang.reflect.Array
+ */
+JNIEXPORT jint JNICALL
+JVM_GetArrayLength(JNIEnv *env, jobject arr);
+
+JNIEXPORT jobject JNICALL
+JVM_GetArrayElement(JNIEnv *env, jobject arr, jint index);
+
+JNIEXPORT jvalue JNICALL
+JVM_GetPrimitiveArrayElement(JNIEnv *env, jobject arr, jint index, jint wCode);
+
+JNIEXPORT void JNICALL
+JVM_SetArrayElement(JNIEnv *env, jobject arr, jint index, jobject val);
+
+JNIEXPORT void JNICALL
+JVM_SetPrimitiveArrayElement(JNIEnv *env, jobject arr, jint index, jvalue v,
+ unsigned char vCode);
+
+JNIEXPORT jobject JNICALL
+JVM_NewArray(JNIEnv *env, jclass eltClass, jint length);
+
+JNIEXPORT jobject JNICALL
+JVM_NewMultiArray(JNIEnv *env, jclass eltClass, jintArray dim);
+
+/*
+ * java.lang.Class and java.lang.ClassLoader
+ */
+/*
+ * Returns the class in which the code invoking the native method
+ * belongs.
+ *
+ * Note that in JDK 1.1, native methods did not create a frame.
+ * In 1.2, they do. Therefore native methods like Class.forName
+ * can no longer look at the current frame for the caller class.
+ */
+JNIEXPORT jclass JNICALL
+JVM_GetCallerClass(JNIEnv *env, int n);
+
+/*
+ * Find primitive classes
+ * utf: class name
+ */
+JNIEXPORT jclass JNICALL
+JVM_FindPrimitiveClass(JNIEnv *env, const char *utf);
+
+/*
+ * Link the class
+ */
+JNIEXPORT void JNICALL
+JVM_ResolveClass(JNIEnv *env, jclass cls);
+
+/*
+ * Find a class from a boot class loader. Returns NULL if class not found.
+ */
+JNIEXPORT jclass JNICALL
+JVM_FindClassFromBootLoader(JNIEnv *env, const char *name);
+
+/*
+ * Find a class from a given class loader. Throw ClassNotFoundException
+ * or NoClassDefFoundError depending on the value of the last
+ * argument.
+ */
+JNIEXPORT jclass JNICALL
+JVM_FindClassFromClassLoader(JNIEnv *env, const char *name, jboolean init,
+ jobject loader, jboolean throwError);
+
+/*
+ * Find a class from a given class.
+ */
+JNIEXPORT jclass JNICALL
+JVM_FindClassFromClass(JNIEnv *env, const char *name, jboolean init,
+ jclass from);
+
+/* Find a loaded class cached by the VM */
+JNIEXPORT jclass JNICALL
+JVM_FindLoadedClass(JNIEnv *env, jobject loader, jstring name);
+
+/* Define a class */
+JNIEXPORT jclass JNICALL
+JVM_DefineClass(JNIEnv *env, const char *name, jobject loader, const jbyte *buf,
+ jsize len, jobject pd);
+
+/* Define a class with a source (added in JDK1.5) */
+JNIEXPORT jclass JNICALL
+JVM_DefineClassWithSource(JNIEnv *env, const char *name, jobject loader,
+ const jbyte *buf, jsize len, jobject pd,
+ const char *source);
+
+/*
+ * Reflection support functions
+ */
+
+JNIEXPORT jstring JNICALL
+JVM_GetClassName(JNIEnv *env, jclass cls);
+
+JNIEXPORT jobjectArray JNICALL
+JVM_GetClassInterfaces(JNIEnv *env, jclass cls);
+
+JNIEXPORT jobject JNICALL
+JVM_GetClassLoader(JNIEnv *env, jclass cls);
+
+JNIEXPORT jboolean JNICALL
+JVM_IsInterface(JNIEnv *env, jclass cls);
+
+JNIEXPORT jobjectArray JNICALL
+JVM_GetClassSigners(JNIEnv *env, jclass cls);
+
+JNIEXPORT void JNICALL
+JVM_SetClassSigners(JNIEnv *env, jclass cls, jobjectArray signers);
+
+JNIEXPORT jobject JNICALL
+JVM_GetProtectionDomain(JNIEnv *env, jclass cls);
+
+JNIEXPORT void JNICALL
+JVM_SetProtectionDomain(JNIEnv *env, jclass cls, jobject protection_domain);
+
+JNIEXPORT jboolean JNICALL
+JVM_IsArrayClass(JNIEnv *env, jclass cls);
+
+JNIEXPORT jboolean JNICALL
+JVM_IsPrimitiveClass(JNIEnv *env, jclass cls);
+
+JNIEXPORT jclass JNICALL
+JVM_GetComponentType(JNIEnv *env, jclass cls);
+
+JNIEXPORT jint JNICALL
+JVM_GetClassModifiers(JNIEnv *env, jclass cls);
+
+JNIEXPORT jobjectArray JNICALL
+JVM_GetDeclaredClasses(JNIEnv *env, jclass ofClass);
+
+JNIEXPORT jclass JNICALL
+JVM_GetDeclaringClass(JNIEnv *env, jclass ofClass);
+
+/* Generics support (JDK 1.5) */
+JNIEXPORT jstring JNICALL
+JVM_GetClassSignature(JNIEnv *env, jclass cls);
+
+/* Annotations support (JDK 1.5) */
+JNIEXPORT jbyteArray JNICALL
+JVM_GetClassAnnotations(JNIEnv *env, jclass cls);
+
+/*
+ * New (JDK 1.4) reflection implementation
+ */
+
+JNIEXPORT jobjectArray JNICALL
+JVM_GetClassDeclaredMethods(JNIEnv *env, jclass ofClass, jboolean publicOnly);
+
+JNIEXPORT jobjectArray JNICALL
+JVM_GetClassDeclaredFields(JNIEnv *env, jclass ofClass, jboolean publicOnly);
+
+JNIEXPORT jobjectArray JNICALL
+JVM_GetClassDeclaredConstructors(JNIEnv *env, jclass ofClass, jboolean publicOnly);
+
+/* Differs from JVM_GetClassModifiers in treatment of inner classes.
+ This returns the access flags for the class as specified in the
+ class file rather than searching the InnerClasses attribute (if
+ present) to find the source-level access flags. Only the values of
+ the low 13 bits (i.e., a mask of 0x1FFF) are guaranteed to be
+ valid. */
+JNIEXPORT jint JNICALL
+JVM_GetClassAccessFlags(JNIEnv *env, jclass cls);
+
+/* The following two reflection routines are still needed due to startup time issues */
+/*
+ * java.lang.reflect.Method
+ */
+JNIEXPORT jobject JNICALL
+JVM_InvokeMethod(JNIEnv *env, jobject method, jobject obj, jobjectArray args0);
+
+/*
+ * java.lang.reflect.Constructor
+ */
+JNIEXPORT jobject JNICALL
+JVM_NewInstanceFromConstructor(JNIEnv *env, jobject c, jobjectArray args0);
+
+/*
+ * Constant pool access; currently used to implement reflective access to annotations (JDK 1.5)
+ */
+
+JNIEXPORT jobject JNICALL
+JVM_GetClassConstantPool(JNIEnv *env, jclass cls);
+
+JNIEXPORT jint JNICALL JVM_ConstantPoolGetSize
+(JNIEnv *env, jobject unused, jobject jcpool);
+
+JNIEXPORT jclass JNICALL JVM_ConstantPoolGetClassAt
+(JNIEnv *env, jobject unused, jobject jcpool, jint index);
+
+JNIEXPORT jclass JNICALL JVM_ConstantPoolGetClassAtIfLoaded
+(JNIEnv *env, jobject unused, jobject jcpool, jint index);
+
+JNIEXPORT jobject JNICALL JVM_ConstantPoolGetMethodAt
+(JNIEnv *env, jobject unused, jobject jcpool, jint index);
+
+JNIEXPORT jobject JNICALL JVM_ConstantPoolGetMethodAtIfLoaded
+(JNIEnv *env, jobject unused, jobject jcpool, jint index);
+
+JNIEXPORT jobject JNICALL JVM_ConstantPoolGetFieldAt
+(JNIEnv *env, jobject unused, jobject jcpool, jint index);
+
+JNIEXPORT jobject JNICALL JVM_ConstantPoolGetFieldAtIfLoaded
+(JNIEnv *env, jobject unused, jobject jcpool, jint index);
+
+JNIEXPORT jobjectArray JNICALL JVM_ConstantPoolGetMemberRefInfoAt
+(JNIEnv *env, jobject unused, jobject jcpool, jint index);
+
+JNIEXPORT jint JNICALL JVM_ConstantPoolGetIntAt
+(JNIEnv *env, jobject unused, jobject jcpool, jint index);
+
+JNIEXPORT jlong JNICALL JVM_ConstantPoolGetLongAt
+(JNIEnv *env, jobject unused, jobject jcpool, jint index);
+
+JNIEXPORT jfloat JNICALL JVM_ConstantPoolGetFloatAt
+(JNIEnv *env, jobject unused, jobject jcpool, jint index);
+
+JNIEXPORT jdouble JNICALL JVM_ConstantPoolGetDoubleAt
+(JNIEnv *env, jobject unused, jobject jcpool, jint index);
+
+JNIEXPORT jstring JNICALL JVM_ConstantPoolGetStringAt
+(JNIEnv *env, jobject unused, jobject jcpool, jint index);
+
+JNIEXPORT jstring JNICALL JVM_ConstantPoolGetUTF8At
+(JNIEnv *env, jobject unused, jobject jcpool, jint index);
+
+/*
+ * java.security.*
+ */
+
+JNIEXPORT jobject JNICALL
+JVM_DoPrivileged(JNIEnv *env, jclass cls,
+ jobject action, jobject context, jboolean wrapException);
+
+JNIEXPORT jobject JNICALL
+JVM_GetInheritedAccessControlContext(JNIEnv *env, jclass cls);
+
+JNIEXPORT jobject JNICALL
+JVM_GetStackAccessControlContext(JNIEnv *env, jclass cls);
+
+/*
+ * Signal support, used to implement the shutdown sequence. Every VM must
+ * support JVM_SIGINT and JVM_SIGTERM, raising the former for user interrupts
+ * (^C) and the latter for external termination (kill, system shutdown, etc.).
+ * Other platform-dependent signal values may also be supported.
+ */
+
+JNIEXPORT void * JNICALL
+JVM_RegisterSignal(jint sig, void *handler);
+
+JNIEXPORT jboolean JNICALL
+JVM_RaiseSignal(jint sig);
+
+JNIEXPORT jint JNICALL
+JVM_FindSignal(const char *name);
+
+/*
+ * Retrieve the assertion directives for the specified class.
+ */
+JNIEXPORT jboolean JNICALL
+JVM_DesiredAssertionStatus(JNIEnv *env, jclass unused, jclass cls);
+
+/*
+ * Retrieve the assertion directives from the VM.
+ */
+JNIEXPORT jobject JNICALL
+JVM_AssertionStatusDirectives(JNIEnv *env, jclass unused);
+
+/*
+ * java.util.concurrent.AtomicLong
+ */
+JNIEXPORT jboolean JNICALL
+JVM_SupportsCX8(void);
+
+/*
+ * com.sun.dtrace.jsdt support
+ */
+
+#define JVM_TRACING_DTRACE_VERSION 1
+
+/*
+ * Structure to pass one probe description to JVM
+ */
+typedef struct {
+ jmethodID method;
+ jstring function;
+ jstring name;
+ void* reserved[4]; // for future use
+} JVM_DTraceProbe;
+
+/**
+ * Encapsulates the stability ratings for a DTrace provider field
+ */
+typedef struct {
+ jint nameStability;
+ jint dataStability;
+ jint dependencyClass;
+} JVM_DTraceInterfaceAttributes;
+
+/*
+ * Structure to pass one provider description to JVM
+ */
+typedef struct {
+ jstring name;
+ JVM_DTraceProbe* probes;
+ jint probe_count;
+ JVM_DTraceInterfaceAttributes providerAttributes;
+ JVM_DTraceInterfaceAttributes moduleAttributes;
+ JVM_DTraceInterfaceAttributes functionAttributes;
+ JVM_DTraceInterfaceAttributes nameAttributes;
+ JVM_DTraceInterfaceAttributes argsAttributes;
+ void* reserved[4]; // for future use
+} JVM_DTraceProvider;
+
+/*
+ * Get the version number the JVM was built with
+ */
+JNIEXPORT jint JNICALL
+JVM_DTraceGetVersion(JNIEnv* env);
+
+/*
+ * Register new probe with given signature, return global handle
+ *
+ * The version passed in is the version that the library code was
+ * built with.
+ */
+JNIEXPORT jlong JNICALL
+JVM_DTraceActivate(JNIEnv* env, jint version, jstring module_name,
+ jint providers_count, JVM_DTraceProvider* providers);
+
+/*
+ * Check JSDT probe
+ */
+JNIEXPORT jboolean JNICALL
+JVM_DTraceIsProbeEnabled(JNIEnv* env, jmethodID method);
+
+/*
+ * Destroy custom DOF
+ */
+JNIEXPORT void JNICALL
+JVM_DTraceDispose(JNIEnv* env, jlong activation_handle);
+
+/*
+ * Check to see if DTrace is supported by OS
+ */
+JNIEXPORT jboolean JNICALL
+JVM_DTraceIsSupported(JNIEnv* env);
+
+/*************************************************************************
+ PART 2: Support for the Verifier and Class File Format Checker
+ ************************************************************************/
+/*
+ * Return the class name in UTF format. The result is valid
+ * until JVM_ReleaseUTf is called.
+ *
+ * The caller must treat the string as a constant and not modify it
+ * in any way.
+ */
+JNIEXPORT const char * JNICALL
+JVM_GetClassNameUTF(JNIEnv *env, jclass cb);
+
+/*
+ * Returns the constant pool types in the buffer provided by "types."
+ */
+JNIEXPORT void JNICALL
+JVM_GetClassCPTypes(JNIEnv *env, jclass cb, unsigned char *types);
+
+/*
+ * Returns the number of Constant Pool entries.
+ */
+JNIEXPORT jint JNICALL
+JVM_GetClassCPEntriesCount(JNIEnv *env, jclass cb);
+
+/*
+ * Returns the number of *declared* fields or methods.
+ */
+JNIEXPORT jint JNICALL
+JVM_GetClassFieldsCount(JNIEnv *env, jclass cb);
+
+JNIEXPORT jint JNICALL
+JVM_GetClassMethodsCount(JNIEnv *env, jclass cb);
+
+/*
+ * Returns the CP indexes of exceptions raised by a given method.
+ * Places the result in the given buffer.
+ *
+ * The method is identified by method_index.
+ */
+JNIEXPORT void JNICALL
+JVM_GetMethodIxExceptionIndexes(JNIEnv *env, jclass cb, jint method_index,
+ unsigned short *exceptions);
+/*
+ * Returns the number of exceptions raised by a given method.
+ * The method is identified by method_index.
+ */
+JNIEXPORT jint JNICALL
+JVM_GetMethodIxExceptionsCount(JNIEnv *env, jclass cb, jint method_index);
+
+/*
+ * Returns the byte code sequence of a given method.
+ * Places the result in the given buffer.
+ *
+ * The method is identified by method_index.
+ */
+JNIEXPORT void JNICALL
+JVM_GetMethodIxByteCode(JNIEnv *env, jclass cb, jint method_index,
+ unsigned char *code);
+
+/*
+ * Returns the length of the byte code sequence of a given method.
+ * The method is identified by method_index.
+ */
+JNIEXPORT jint JNICALL
+JVM_GetMethodIxByteCodeLength(JNIEnv *env, jclass cb, jint method_index);
+
+/*
+ * A structure used to a capture exception table entry in a Java method.
+ */
+typedef struct {
+ jint start_pc;
+ jint end_pc;
+ jint handler_pc;
+ jint catchType;
+} JVM_ExceptionTableEntryType;
+
+/*
+ * Returns the exception table entry at entry_index of a given method.
+ * Places the result in the given buffer.
+ *
+ * The method is identified by method_index.
+ */
+JNIEXPORT void JNICALL
+JVM_GetMethodIxExceptionTableEntry(JNIEnv *env, jclass cb, jint method_index,
+ jint entry_index,
+ JVM_ExceptionTableEntryType *entry);
+
+/*
+ * Returns the length of the exception table of a given method.
+ * The method is identified by method_index.
+ */
+JNIEXPORT jint JNICALL
+JVM_GetMethodIxExceptionTableLength(JNIEnv *env, jclass cb, int index);
+
+/*
+ * Returns the modifiers of a given field.
+ * The field is identified by field_index.
+ */
+JNIEXPORT jint JNICALL
+JVM_GetFieldIxModifiers(JNIEnv *env, jclass cb, int index);
+
+/*
+ * Returns the modifiers of a given method.
+ * The method is identified by method_index.
+ */
+JNIEXPORT jint JNICALL
+JVM_GetMethodIxModifiers(JNIEnv *env, jclass cb, int index);
+
+/*
+ * Returns the number of local variables of a given method.
+ * The method is identified by method_index.
+ */
+JNIEXPORT jint JNICALL
+JVM_GetMethodIxLocalsCount(JNIEnv *env, jclass cb, int index);
+
+/*
+ * Returns the number of arguments (including this pointer) of a given method.
+ * The method is identified by method_index.
+ */
+JNIEXPORT jint JNICALL
+JVM_GetMethodIxArgsSize(JNIEnv *env, jclass cb, int index);
+
+/*
+ * Returns the maximum amount of stack (in words) used by a given method.
+ * The method is identified by method_index.
+ */
+JNIEXPORT jint JNICALL
+JVM_GetMethodIxMaxStack(JNIEnv *env, jclass cb, int index);
+
+/*
+ * Is a given method a constructor.
+ * The method is identified by method_index.
+ */
+JNIEXPORT jboolean JNICALL
+JVM_IsConstructorIx(JNIEnv *env, jclass cb, int index);
+
+/*
+ * Returns the name of a given method in UTF format.
+ * The result remains valid until JVM_ReleaseUTF is called.
+ *
+ * The caller must treat the string as a constant and not modify it
+ * in any way.
+ */
+JNIEXPORT const char * JNICALL
+JVM_GetMethodIxNameUTF(JNIEnv *env, jclass cb, jint index);
+
+/*
+ * Returns the signature of a given method in UTF format.
+ * The result remains valid until JVM_ReleaseUTF is called.
+ *
+ * The caller must treat the string as a constant and not modify it
+ * in any way.
+ */
+JNIEXPORT const char * JNICALL
+JVM_GetMethodIxSignatureUTF(JNIEnv *env, jclass cb, jint index);
+
+/*
+ * Returns the name of the field refered to at a given constant pool
+ * index.
+ *
+ * The result is in UTF format and remains valid until JVM_ReleaseUTF
+ * is called.
+ *
+ * The caller must treat the string as a constant and not modify it
+ * in any way.
+ */
+JNIEXPORT const char * JNICALL
+JVM_GetCPFieldNameUTF(JNIEnv *env, jclass cb, jint index);
+
+/*
+ * Returns the name of the method refered to at a given constant pool
+ * index.
+ *
+ * The result is in UTF format and remains valid until JVM_ReleaseUTF
+ * is called.
+ *
+ * The caller must treat the string as a constant and not modify it
+ * in any way.
+ */
+JNIEXPORT const char * JNICALL
+JVM_GetCPMethodNameUTF(JNIEnv *env, jclass cb, jint index);
+
+/*
+ * Returns the signature of the method refered to at a given constant pool
+ * index.
+ *
+ * The result is in UTF format and remains valid until JVM_ReleaseUTF
+ * is called.
+ *
+ * The caller must treat the string as a constant and not modify it
+ * in any way.
+ */
+JNIEXPORT const char * JNICALL
+JVM_GetCPMethodSignatureUTF(JNIEnv *env, jclass cb, jint index);
+
+/*
+ * Returns the signature of the field refered to at a given constant pool
+ * index.
+ *
+ * The result is in UTF format and remains valid until JVM_ReleaseUTF
+ * is called.
+ *
+ * The caller must treat the string as a constant and not modify it
+ * in any way.
+ */
+JNIEXPORT const char * JNICALL
+JVM_GetCPFieldSignatureUTF(JNIEnv *env, jclass cb, jint index);
+
+/*
+ * Returns the class name refered to at a given constant pool index.
+ *
+ * The result is in UTF format and remains valid until JVM_ReleaseUTF
+ * is called.
+ *
+ * The caller must treat the string as a constant and not modify it
+ * in any way.
+ */
+JNIEXPORT const char * JNICALL
+JVM_GetCPClassNameUTF(JNIEnv *env, jclass cb, jint index);
+
+/*
+ * Returns the class name refered to at a given constant pool index.
+ *
+ * The constant pool entry must refer to a CONSTANT_Fieldref.
+ *
+ * The result is in UTF format and remains valid until JVM_ReleaseUTF
+ * is called.
+ *
+ * The caller must treat the string as a constant and not modify it
+ * in any way.
+ */
+JNIEXPORT const char * JNICALL
+JVM_GetCPFieldClassNameUTF(JNIEnv *env, jclass cb, jint index);
+
+/*
+ * Returns the class name refered to at a given constant pool index.
+ *
+ * The constant pool entry must refer to CONSTANT_Methodref or
+ * CONSTANT_InterfaceMethodref.
+ *
+ * The result is in UTF format and remains valid until JVM_ReleaseUTF
+ * is called.
+ *
+ * The caller must treat the string as a constant and not modify it
+ * in any way.
+ */
+JNIEXPORT const char * JNICALL
+JVM_GetCPMethodClassNameUTF(JNIEnv *env, jclass cb, jint index);
+
+/*
+ * Returns the modifiers of a field in calledClass. The field is
+ * referred to in class cb at constant pool entry index.
+ *
+ * The caller must treat the string as a constant and not modify it
+ * in any way.
+ *
+ * Returns -1 if the field does not exist in calledClass.
+ */
+JNIEXPORT jint JNICALL
+JVM_GetCPFieldModifiers(JNIEnv *env, jclass cb, int index, jclass calledClass);
+
+/*
+ * Returns the modifiers of a method in calledClass. The method is
+ * referred to in class cb at constant pool entry index.
+ *
+ * Returns -1 if the method does not exist in calledClass.
+ */
+JNIEXPORT jint JNICALL
+JVM_GetCPMethodModifiers(JNIEnv *env, jclass cb, int index, jclass calledClass);
+
+/*
+ * Releases the UTF string obtained from the VM.
+ */
+JNIEXPORT void JNICALL
+JVM_ReleaseUTF(const char *utf);
+
+/*
+ * Compare if two classes are in the same package.
+ */
+JNIEXPORT jboolean JNICALL
+JVM_IsSameClassPackage(JNIEnv *env, jclass class1, jclass class2);
+
+/* Get classfile constants */
+#include "classfile_constants.h"
+
+/*
+ * A function defined by the byte-code verifier and called by the VM.
+ * This is not a function implemented in the VM.
+ *
+ * Returns JNI_FALSE if verification fails. A detailed error message
+ * will be places in msg_buf, whose length is specified by buf_len.
+ */
+typedef jboolean (*verifier_fn_t)(JNIEnv *env,
+ jclass cb,
+ char * msg_buf,
+ jint buf_len);
+
+
+/*
+ * Support for a VM-independent class format checker.
+ */
+typedef struct {
+ unsigned long code; /* byte code */
+ unsigned long excs; /* exceptions */
+ unsigned long etab; /* catch table */
+ unsigned long lnum; /* line number */
+ unsigned long lvar; /* local vars */
+} method_size_info;
+
+typedef struct {
+ unsigned int constants; /* constant pool */
+ unsigned int fields;
+ unsigned int methods;
+ unsigned int interfaces;
+ unsigned int fields2; /* number of static 2-word fields */
+ unsigned int innerclasses; /* # of records in InnerClasses attr */
+
+ method_size_info clinit; /* memory used in clinit */
+ method_size_info main; /* used everywhere else */
+} class_size_info;
+
+/*
+ * Functions defined in libjava.so to perform string conversions.
+ *
+ */
+
+typedef jstring (*to_java_string_fn_t)(JNIEnv *env, char *str);
+
+typedef char *(*to_c_string_fn_t)(JNIEnv *env, jstring s, jboolean *b);
+
+/* This is the function defined in libjava.so that performs class
+ * format checks. This functions fills in size information about
+ * the class file and returns:
+ *
+ * 0: good
+ * -1: out of memory
+ * -2: bad format
+ * -3: unsupported version
+ * -4: bad class name
+ */
+
+typedef jint (*check_format_fn_t)(char *class_name,
+ unsigned char *data,
+ unsigned int data_size,
+ class_size_info *class_size,
+ char *message_buffer,
+ jint buffer_length,
+ jboolean measure_only,
+ jboolean check_relaxed);
+
+#define JVM_RECOGNIZED_CLASS_MODIFIERS (JVM_ACC_PUBLIC | \
+ JVM_ACC_FINAL | \
+ JVM_ACC_SUPER | \
+ JVM_ACC_INTERFACE | \
+ JVM_ACC_ABSTRACT | \
+ JVM_ACC_ANNOTATION | \
+ JVM_ACC_ENUM | \
+ JVM_ACC_SYNTHETIC)
+
+#define JVM_RECOGNIZED_FIELD_MODIFIERS (JVM_ACC_PUBLIC | \
+ JVM_ACC_PRIVATE | \
+ JVM_ACC_PROTECTED | \
+ JVM_ACC_STATIC | \
+ JVM_ACC_FINAL | \
+ JVM_ACC_VOLATILE | \
+ JVM_ACC_TRANSIENT | \
+ JVM_ACC_ENUM | \
+ JVM_ACC_SYNTHETIC)
+
+#define JVM_RECOGNIZED_METHOD_MODIFIERS (JVM_ACC_PUBLIC | \
+ JVM_ACC_PRIVATE | \
+ JVM_ACC_PROTECTED | \
+ JVM_ACC_STATIC | \
+ JVM_ACC_FINAL | \
+ JVM_ACC_SYNCHRONIZED | \
+ JVM_ACC_BRIDGE | \
+ JVM_ACC_VARARGS | \
+ JVM_ACC_NATIVE | \
+ JVM_ACC_ABSTRACT | \
+ JVM_ACC_STRICT | \
+ JVM_ACC_SYNTHETIC)
+
+/*
+ * This is the function defined in libjava.so to perform path
+ * canonicalization. VM call this function before opening jar files
+ * to load system classes.
+ *
+ */
+
+typedef int (*canonicalize_fn_t)(JNIEnv *env, char *orig, char *out, int len);
+
+/*************************************************************************
+ PART 3: I/O and Network Support
+ ************************************************************************/
+
+/* Note that the JVM IO functions are expected to return JVM_IO_ERR
+ * when there is any kind of error. The caller can then use the
+ * platform specific support (e.g., errno) to get the detailed
+ * error info. The JVM_GetLastErrorString procedure may also be used
+ * to obtain a descriptive error string.
+ */
+#define JVM_IO_ERR (-1)
+
+/* For interruptible IO. Returning JVM_IO_INTR indicates that an IO
+ * operation has been disrupted by Thread.interrupt. There are a
+ * number of technical difficulties related to interruptible IO that
+ * need to be solved. For example, most existing programs do not handle
+ * InterruptedIOExceptions specially, they simply treat those as any
+ * IOExceptions, which typically indicate fatal errors.
+ *
+ * There are also two modes of operation for interruptible IO. In the
+ * resumption mode, an interrupted IO operation is guaranteed not to
+ * have any side-effects, and can be restarted. In the termination mode,
+ * an interrupted IO operation corrupts the underlying IO stream, so
+ * that the only reasonable operation on an interrupted stream is to
+ * close that stream. The resumption mode seems to be impossible to
+ * implement on Win32 and Solaris. Implementing the termination mode is
+ * easier, but it's not clear that's the right semantics.
+ *
+ * Interruptible IO is not supported on Win32.It can be enabled/disabled
+ * using a compile-time flag on Solaris. Third-party JVM ports do not
+ * need to implement interruptible IO.
+ */
+#define JVM_IO_INTR (-2)
+
+/* Write a string into the given buffer, in the platform's local encoding,
+ * that describes the most recent system-level error to occur in this thread.
+ * Return the length of the string or zero if no error occurred.
+ */
+JNIEXPORT jint JNICALL
+JVM_GetLastErrorString(char *buf, int len);
+
+/*
+ * Convert a pathname into native format. This function does syntactic
+ * cleanup, such as removing redundant separator characters. It modifies
+ * the given pathname string in place.
+ */
+JNIEXPORT char * JNICALL
+JVM_NativePath(char *);
+
+/*
+ * JVM I/O error codes
+ */
+#define JVM_EEXIST -100
+
+/*
+ * Open a file descriptor. This function returns a negative error code
+ * on error, and a non-negative integer that is the file descriptor on
+ * success.
+ */
+JNIEXPORT jint JNICALL
+JVM_Open(const char *fname, jint flags, jint mode);
+
+/*
+ * Close a file descriptor. This function returns -1 on error, and 0
+ * on success.
+ *
+ * fd the file descriptor to close.
+ */
+JNIEXPORT jint JNICALL
+JVM_Close(jint fd);
+
+/*
+ * Read data from a file decriptor into a char array.
+ *
+ * fd the file descriptor to read from.
+ * buf the buffer where to put the read data.
+ * nbytes the number of bytes to read.
+ *
+ * This function returns -1 on error, and 0 on success.
+ */
+JNIEXPORT jint JNICALL
+JVM_Read(jint fd, char *buf, jint nbytes);
+
+/*
+ * Write data from a char array to a file decriptor.
+ *
+ * fd the file descriptor to read from.
+ * buf the buffer from which to fetch the data.
+ * nbytes the number of bytes to write.
+ *
+ * This function returns -1 on error, and 0 on success.
+ */
+JNIEXPORT jint JNICALL
+JVM_Write(jint fd, char *buf, jint nbytes);
+
+/*
+ * Move the file descriptor pointer from whence by offset.
+ *
+ * fd the file descriptor to move.
+ * offset the number of bytes to move it by.
+ * whence the start from where to move it.
+ *
+ * This function returns the resulting pointer location.
+ */
+JNIEXPORT jlong JNICALL
+JVM_Lseek(jint fd, jlong offset, jint whence);
+
+/*
+ * Set the length of the file associated with the given descriptor to the given
+ * length. If the new length is longer than the current length then the file
+ * is extended; the contents of the extended portion are not defined. The
+ * value of the file pointer is undefined after this procedure returns.
+ */
+JNIEXPORT jint JNICALL
+JVM_SetLength(jint fd, jlong length);
+
+/*
+ * Synchronize the file descriptor's in memory state with that of the
+ * physical device. Return of -1 is an error, 0 is OK.
+ */
+JNIEXPORT jint JNICALL
+JVM_Sync(jint fd);
+
+/*
+ * Networking library support
+ */
+
+JNIEXPORT jint JNICALL
+JVM_InitializeSocketLibrary(void);
+
+struct sockaddr;
+
+JNIEXPORT jint JNICALL
+JVM_Socket(jint domain, jint type, jint protocol);
+
+JNIEXPORT jint JNICALL
+JVM_SocketClose(jint fd);
+
+JNIEXPORT jint JNICALL
+JVM_SocketShutdown(jint fd, jint howto);
+
+JNIEXPORT jint JNICALL
+JVM_Recv(jint fd, char *buf, jint nBytes, jint flags);
+
+JNIEXPORT jint JNICALL
+JVM_Send(jint fd, char *buf, jint nBytes, jint flags);
+
+JNIEXPORT jint JNICALL
+JVM_Timeout(int fd, long timeout);
+
+JNIEXPORT jint JNICALL
+JVM_Listen(jint fd, jint count);
+
+JNIEXPORT jint JNICALL
+JVM_Connect(jint fd, struct sockaddr *him, jint len);
+
+JNIEXPORT jint JNICALL
+JVM_Bind(jint fd, struct sockaddr *him, jint len);
+
+JNIEXPORT jint JNICALL
+JVM_Accept(jint fd, struct sockaddr *him, jint *len);
+
+JNIEXPORT jint JNICALL
+JVM_RecvFrom(jint fd, char *buf, int nBytes,
+ int flags, struct sockaddr *from, int *fromlen);
+
+JNIEXPORT jint JNICALL
+JVM_SendTo(jint fd, char *buf, int len,
+ int flags, struct sockaddr *to, int tolen);
+
+JNIEXPORT jint JNICALL
+JVM_SocketAvailable(jint fd, jint *result);
+
+
+JNIEXPORT jint JNICALL
+JVM_GetSockName(jint fd, struct sockaddr *him, int *len);
+
+JNIEXPORT jint JNICALL
+JVM_GetSockOpt(jint fd, int level, int optname, char *optval, int *optlen);
+
+JNIEXPORT jint JNICALL
+JVM_SetSockOpt(jint fd, int level, int optname, const char *optval, int optlen);
+
+JNIEXPORT int JNICALL
+JVM_GetHostName(char* name, int namelen);
+
+/*
+ * The standard printing functions supported by the Java VM. (Should they
+ * be renamed to JVM_* in the future?
+ */
+
+/*
+ * BE CAREFUL! The following functions do not implement the
+ * full feature set of standard C printf formats.
+ */
+int
+jio_vsnprintf(char *str, size_t count, const char *fmt, va_list args);
+
+int
+jio_snprintf(char *str, size_t count, const char *fmt, ...);
+
+int
+jio_fprintf(FILE *, const char *fmt, ...);
+
+int
+jio_vfprintf(FILE *, const char *fmt, va_list args);
+
+
+JNIEXPORT void * JNICALL
+JVM_RawMonitorCreate(void);
+
+JNIEXPORT void JNICALL
+JVM_RawMonitorDestroy(void *mon);
+
+JNIEXPORT jint JNICALL
+JVM_RawMonitorEnter(void *mon);
+
+JNIEXPORT void JNICALL
+JVM_RawMonitorExit(void *mon);
+
+/*
+ * java.lang.management support
+ */
+JNIEXPORT void* JNICALL
+JVM_GetManagement(jint version);
+
+/*
+ * com.sun.tools.attach.VirtualMachine support
+ *
+ * Initialize the agent properties with the properties maintained in the VM.
+ */
+JNIEXPORT jobject JNICALL
+JVM_InitAgentProperties(JNIEnv *env, jobject agent_props);
+
+/* Generics reflection support.
+ *
+ * Returns information about the given class's EnclosingMethod
+ * attribute, if present, or null if the class had no enclosing
+ * method.
+ *
+ * If non-null, the returned array contains three elements. Element 0
+ * is the java.lang.Class of which the enclosing method is a member,
+ * and elements 1 and 2 are the java.lang.Strings for the enclosing
+ * method's name and descriptor, respectively.
+ */
+JNIEXPORT jobjectArray JNICALL
+JVM_GetEnclosingMethodInfo(JNIEnv* env, jclass ofClass);
+
+/*
+ * Java thread state support
+ */
+enum {
+ JAVA_THREAD_STATE_NEW = 0,
+ JAVA_THREAD_STATE_RUNNABLE = 1,
+ JAVA_THREAD_STATE_BLOCKED = 2,
+ JAVA_THREAD_STATE_WAITING = 3,
+ JAVA_THREAD_STATE_TIMED_WAITING = 4,
+ JAVA_THREAD_STATE_TERMINATED = 5,
+ JAVA_THREAD_STATE_COUNT = 6
+};
+
+/*
+ * Returns an array of the threadStatus values representing the
+ * given Java thread state. Returns NULL if the VM version is
+ * incompatible with the JDK or doesn't support the given
+ * Java thread state.
+ */
+JNIEXPORT jintArray JNICALL
+JVM_GetThreadStateValues(JNIEnv* env, jint javaThreadState);
+
+/*
+ * Returns an array of the substate names representing the
+ * given Java thread state. Returns NULL if the VM version is
+ * incompatible with the JDK or the VM doesn't support
+ * the given Java thread state.
+ * values must be the jintArray returned from JVM_GetThreadStateValues
+ * and javaThreadState.
+ */
+JNIEXPORT jobjectArray JNICALL
+JVM_GetThreadStateNames(JNIEnv* env, jint javaThreadState, jintArray values);
+
+/* =========================================================================
+ * The following defines a private JVM interface that the JDK can query
+ * for the JVM version and capabilities. sun.misc.Version defines
+ * the methods for getting the VM version and its capabilities.
+ *
+ * When a new bit is added, the following should be updated to provide
+ * access to the new capability:
+ * HS: JVM_GetVersionInfo and Abstract_VM_Version class
+ * SDK: Version class
+ *
+ * Similary, a private JDK interface JDK_GetVersionInfo0 is defined for
+ * JVM to query for the JDK version and capabilities.
+ *
+ * When a new bit is added, the following should be updated to provide
+ * access to the new capability:
+ * HS: JDK_Version class
+ * SDK: JDK_GetVersionInfo0
+ *
+ * ==========================================================================
+ */
+typedef struct {
+ /* Naming convention of RE build version string: n.n.n[_uu[c]][-<identifier>]-bxx */
+ unsigned int jvm_version; /* Consists of major, minor, micro (n.n.n) */
+ /* and build number (xx) */
+ unsigned int update_version : 8; /* Update release version (uu) */
+ unsigned int special_update_version : 8; /* Special update release version (c)*/
+ unsigned int reserved1 : 16;
+ unsigned int reserved2;
+
+ /* The following bits represents JVM supports that JDK has dependency on.
+ * JDK can use these bits to determine which JVM version
+ * and support it has to maintain runtime compatibility.
+ *
+ * When a new bit is added in a minor or update release, make sure
+ * the new bit is also added in the main/baseline.
+ */
+ unsigned int is_attach_supported : 1;
+ unsigned int is_kernel_jvm : 1;
+ unsigned int : 30;
+ unsigned int : 32;
+ unsigned int : 32;
+} jvm_version_info;
+
+#define JVM_VERSION_MAJOR(version) ((version & 0xFF000000) >> 24)
+#define JVM_VERSION_MINOR(version) ((version & 0x00FF0000) >> 16)
+#define JVM_VERSION_MICRO(version) ((version & 0x0000FF00) >> 8)
+
+/* Build number is available only for RE builds.
+ * It will be zero for internal builds.
+ */
+#define JVM_VERSION_BUILD(version) ((version & 0x000000FF))
+
+JNIEXPORT void JNICALL
+JVM_GetVersionInfo(JNIEnv* env, jvm_version_info* info, size_t info_size);
+
+typedef struct {
+ // Naming convention of RE build version string: n.n.n[_uu[c]][-<identifier>]-bxx
+ unsigned int jdk_version; /* Consists of major, minor, micro (n.n.n) */
+ /* and build number (xx) */
+ unsigned int update_version : 8; /* Update release version (uu) */
+ unsigned int special_update_version : 8; /* Special update release version (c)*/
+ unsigned int reserved1 : 16;
+ unsigned int reserved2;
+
+ /* The following bits represents new JDK supports that VM has dependency on.
+ * VM implementation can use these bits to determine which JDK version
+ * and support it has to maintain runtime compatibility.
+ *
+ * When a new bit is added in a minor or update release, make sure
+ * the new bit is also added in the main/baseline.
+ */
+ unsigned int thread_park_blocker : 1;
+ unsigned int post_vm_init_hook_enabled : 1;
+ unsigned int : 30;
+ unsigned int : 32;
+ unsigned int : 32;
+} jdk_version_info;
+
+#define JDK_VERSION_MAJOR(version) ((version & 0xFF000000) >> 24)
+#define JDK_VERSION_MINOR(version) ((version & 0x00FF0000) >> 16)
+#define JDK_VERSION_MICRO(version) ((version & 0x0000FF00) >> 8)
+
+/* Build number is available only for RE build (i.e. JDK_BUILD_NUMBER is set to bNN)
+ * It will be zero for internal builds.
+ */
+#define JDK_VERSION_BUILD(version) ((version & 0x000000FF))
+
+/*
+ * This is the function JDK_GetVersionInfo0 defined in libjava.so
+ * that is dynamically looked up by JVM.
+ */
+typedef void (*jdk_version_info_fn_t)(jdk_version_info* info, size_t info_size);
+
+/*
+ * This structure is used by the launcher to get the default thread
+ * stack size from the VM using JNI_GetDefaultJavaVMInitArgs() with a
+ * version of 1.1. As it is not supported otherwise, it has been removed
+ * from jni.h
+ */
+typedef struct JDK1_1InitArgs {
+ jint version;
+
+ char **properties;
+ jint checkSource;
+ jint nativeStackSize;
+ jint javaStackSize;
+ jint minHeapSize;
+ jint maxHeapSize;
+ jint verifyMode;
+ char *classpath;
+
+ jint (JNICALL *vfprintf)(FILE *fp, const char *format, va_list args);
+ void (JNICALL *exit)(jint code);
+ void (JNICALL *abort)(void);
+
+ jint enableClassGC;
+ jint enableVerboseGC;
+ jint disableAsyncGC;
+ jint verbose;
+ jboolean debugging;
+ jint debugPort;
+} JDK1_1InitArgs;
+
+
+#ifdef __cplusplus
+} /* extern "C" */
+
+#endif /* __cplusplus */
+
+#endif /* !_JAVASOFT_JVM_H_ */
diff --git a/luni/src/main/java/java/util/jar/StrictJarFile.java b/luni/src/main/java/java/util/jar/StrictJarFile.java
index 0f4f166..10e0ab8 100644
--- a/luni/src/main/java/java/util/jar/StrictJarFile.java
+++ b/luni/src/main/java/java/util/jar/StrictJarFile.java
@@ -27,6 +27,7 @@
import java.util.HashMap;
import java.util.Iterator;
import java.util.zip.Inflater;
+import java.util.zip.InflaterInputStream;
import java.util.zip.ZipEntry;
import java.util.zip.ZipFile;
import libcore.io.IoUtils;
@@ -162,14 +163,14 @@
private InputStream getZipInputStream(ZipEntry ze) {
if (ze.getMethod() == ZipEntry.STORED) {
- return new ZipFile.RAFStream(raf, ze.getDataOffset(),
+ return new RAFStream(raf, ze.getDataOffset(),
ze.getDataOffset() + ze.getSize());
} else {
- final ZipFile.RAFStream wrapped = new ZipFile.RAFStream(
+ final RAFStream wrapped = new RAFStream(
raf, ze.getDataOffset(), ze.getDataOffset() + ze.getCompressedSize());
int bufSize = Math.max(1024, (int) Math.min(ze.getSize(), 65535L));
- return new ZipFile.ZipInflaterInputStream(wrapped, new Inflater(true), bufSize, ze);
+ return new ZipInflaterInputStream(wrapped, new Inflater(true), bufSize, ze);
}
}
@@ -303,6 +304,107 @@
}
}
+ /** @hide */
+ public static class ZipInflaterInputStream extends InflaterInputStream {
+ private final ZipEntry entry;
+ private long bytesRead = 0;
+
+ public ZipInflaterInputStream(InputStream is, Inflater inf, int bsize, ZipEntry entry) {
+ super(is, inf, bsize);
+ this.entry = entry;
+ }
+
+ @Override public int read(byte[] buffer, int byteOffset, int byteCount) throws IOException {
+ final int i;
+ try {
+ i = super.read(buffer, byteOffset, byteCount);
+ } catch (IOException e) {
+ throw new IOException("Error reading data for " + entry.getName() + " near offset "
+ + bytesRead, e);
+ }
+ if (i == -1) {
+ if (entry.getSize() != bytesRead) {
+ throw new IOException("Size mismatch on inflated file: " + bytesRead + " vs "
+ + entry.getSize());
+ }
+ } else {
+ bytesRead += i;
+ }
+ return i;
+ }
+
+ @Override public int available() throws IOException {
+ if (closed) {
+ // Our superclass will throw an exception, but there's a jtreg test that
+ // explicitly checks that the InputStream returned from ZipFile.getInputStream
+ // returns 0 even when closed.
+ return 0;
+ }
+ return super.available() == 0 ? 0 : (int) (entry.getSize() - bytesRead);
+ }
+ }
+
+ /**
+ * Wrap a stream around a RandomAccessFile. The RandomAccessFile is shared
+ * among all streams returned by getInputStream(), so we have to synchronize
+ * access to it. (We can optimize this by adding buffering here to reduce
+ * collisions.)
+ *
+ * <p>We could support mark/reset, but we don't currently need them.
+ *
+ * @hide
+ */
+ public static class RAFStream extends InputStream {
+ private final RandomAccessFile sharedRaf;
+ private long endOffset;
+ private long offset;
+
+
+ public RAFStream(RandomAccessFile raf, long initialOffset, long endOffset) {
+ sharedRaf = raf;
+ offset = initialOffset;
+ this.endOffset = endOffset;
+ }
+
+ public RAFStream(RandomAccessFile raf, long initialOffset) throws IOException {
+ this(raf, initialOffset, raf.length());
+ }
+
+ @Override public int available() throws IOException {
+ return (offset < endOffset ? 1 : 0);
+ }
+
+ @Override public int read() throws IOException {
+ return Streams.readSingleByte(this);
+ }
+
+ @Override public int read(byte[] buffer, int byteOffset, int byteCount) throws IOException {
+ synchronized (sharedRaf) {
+ final long length = endOffset - offset;
+ if (byteCount > length) {
+ byteCount = (int) length;
+ }
+ sharedRaf.seek(offset);
+ int count = sharedRaf.read(buffer, byteOffset, byteCount);
+ if (count > 0) {
+ offset += count;
+ return count;
+ } else {
+ return -1;
+ }
+ }
+ }
+
+ @Override public long skip(long byteCount) throws IOException {
+ if (byteCount > endOffset - offset) {
+ byteCount = endOffset - offset;
+ }
+ offset += byteCount;
+ return byteCount;
+ }
+ }
+
+
private static native long nativeOpenJarFile(String fileName) throws IOException;
private static native long nativeStartIteration(long nativeHandle, String prefix);
private static native ZipEntry nativeNextEntry(long iterationHandle);
diff --git a/luni/src/main/native/Register.cpp b/luni/src/main/native/Register.cpp
index 3f6bd56..eadb6db 100644
--- a/luni/src/main/native/Register.cpp
+++ b/luni/src/main/native/Register.cpp
@@ -50,10 +50,6 @@
REGISTER(register_java_nio_ByteOrder);
REGISTER(register_java_nio_charset_Charsets);
REGISTER(register_java_util_jar_StrictJarFile);
- REGISTER(register_java_util_zip_Adler32);
- REGISTER(register_java_util_zip_CRC32);
- REGISTER(register_java_util_zip_Deflater);
- REGISTER(register_java_util_zip_Inflater);
REGISTER(register_libcore_icu_AlphabeticIndex);
REGISTER(register_libcore_icu_DateIntervalFormat);
REGISTER(register_libcore_icu_ICU);
diff --git a/luni/src/main/native/java_util_jar_StrictJarFile.cpp b/luni/src/main/native/java_util_jar_StrictJarFile.cpp
index efcc74c..5afc9bc 100644
--- a/luni/src/main/native/java_util_jar_StrictJarFile.cpp
+++ b/luni/src/main/native/java_util_jar_StrictJarFile.cpp
@@ -28,6 +28,15 @@
#include "ziparchive/zip_archive.h"
#include "cutils/log.h"
+static jfieldID nameID;
+static jfieldID timeID;
+static jfieldID crcID;
+static jfieldID sizeID;
+static jfieldID csizeID;
+static jfieldID methodID;
+static jfieldID dataOffsetID;
+static jmethodID zipEntryCtorID;
+
static void throwIoException(JNIEnv* env, const int32_t errorCode) {
jniThrowException(env, "java/io/IOException", ErrorCodeString(errorCode));
}
@@ -53,31 +62,33 @@
return env->NewObject(stringClass.get(), stringCtor, javaNameBytes);
}
-static jobject newZipEntry(JNIEnv* env, const ZipEntry& entry, const jobject entryName,
- const uint16_t nameLength) {
+static jobject newZipEntry(JNIEnv* env, const ZipEntry& entry, const jobject entryName) {
ScopedLocalRef<jclass> zipEntryClass(env, env->FindClass("java/util/zip/ZipEntry"));
- const jmethodID zipEntryCtor = env->GetMethodID(zipEntryClass.get(), "<init>",
- "(Ljava/lang/String;Ljava/lang/String;JJJIII[BIJJ)V");
+ if (nameID == 0) {
+ nameID = env->GetFieldID(zipEntryClass.get(), "name", "Ljava/lang/String;");
+ timeID = env->GetFieldID(zipEntryClass.get(), "time", "J");
+ crcID = env->GetFieldID(zipEntryClass.get(), "crc", "J");
+ sizeID = env->GetFieldID(zipEntryClass.get(), "size", "J");
+ csizeID = env->GetFieldID(zipEntryClass.get(), "csize", "J");
+ methodID = env->GetFieldID(zipEntryClass.get(), "method", "I");
+ dataOffsetID = env->GetFieldID(zipEntryClass.get(), "dataOffset", "J");
+ zipEntryCtorID = env->GetMethodID(zipEntryClass.get(), "<init>","()V");
+ }
- return env->NewObject(zipEntryClass.get(),
- zipEntryCtor,
- entryName,
- NULL, // comment
- static_cast<jlong>(entry.crc32),
- static_cast<jlong>(entry.compressed_length),
- static_cast<jlong>(entry.uncompressed_length),
- static_cast<jint>(entry.method),
- static_cast<jint>(0), // time
- static_cast<jint>(0), // modData
- NULL, // byte[] extra
- static_cast<jint>(nameLength),
- static_cast<jlong>(-1), // local header offset
- static_cast<jlong>(entry.offset));
+ jobject result = env->NewObject(zipEntryClass.get(), zipEntryCtorID);
+ env->SetObjectField(result, nameID, entryName);
+ env->SetLongField(result, timeID, 0L);
+ env->SetLongField(result, crcID, entry.crc32);
+ env->SetLongField(result, sizeID, entry.uncompressed_length);
+ env->SetLongField(result, csizeID, entry.compressed_length);
+ env->SetIntField(result, methodID, entry.method);
+ env->SetLongField(result, dataOffsetID, entry.offset);
+ return result;
}
static jobject newZipEntry(JNIEnv* env, const ZipEntry& entry, const char* name,
const uint16_t nameLength) {
- return newZipEntry(env, entry, constructString(env, name, nameLength), nameLength);
+ return newZipEntry(env, entry, constructString(env, name, nameLength));
}
static jlong StrictJarFile_nativeOpenJarFile(JNIEnv* env, jobject, jstring fileName) {
@@ -177,7 +188,7 @@
return NULL;
}
- return newZipEntry(env, data, entryName, entryNameChars.size());
+ return newZipEntry(env, data, entryName);
}
static void StrictJarFile_nativeClose(JNIEnv*, jobject, jlong nativeHandle) {
diff --git a/luni/src/main/native/sub.mk b/luni/src/main/native/sub.mk
index 258a19f..acf61a0 100644
--- a/luni/src/main/native/sub.mk
+++ b/luni/src/main/native/sub.mk
@@ -30,10 +30,6 @@
java_nio_ByteOrder.cpp \
java_nio_charset_Charsets.cpp \
java_util_jar_StrictJarFile.cpp \
- java_util_zip_Adler32.cpp \
- java_util_zip_CRC32.cpp \
- java_util_zip_Deflater.cpp \
- java_util_zip_Inflater.cpp \
libcore_icu_AlphabeticIndex.cpp \
libcore_icu_DateIntervalFormat.cpp \
libcore_icu_ICU.cpp \
diff --git a/ojluni/src/main/java/java/util/zip/Adler32.java b/ojluni/src/main/java/java/util/zip/Adler32.java
index d7a18dd..cb38670 100755
--- a/ojluni/src/main/java/java/util/zip/Adler32.java
+++ b/ojluni/src/main/java/java/util/zip/Adler32.java
@@ -25,8 +25,10 @@
package java.util.zip;
+/* ----- BEGIN android -----
import java.nio.ByteBuffer;
import sun.nio.ch.DirectBuffer;
+----- END android ----- */
/**
* A class that can be used to compute the Adler-32 checksum of a data
@@ -38,7 +40,10 @@
*/
public
class Adler32 implements Checksum {
- private int adler = 1;
+ /* ----- BEGIN android -----
+ private int adler = 1;*/
+ private long adler = 1;
+ // ----- END android -----
/**
* Creates a new Adler32 object.
@@ -53,7 +58,10 @@
* @param b the byte to update the checksum with
*/
public void update(int b) {
- adler = update(adler, b);
+ /* ----- BEGIN android -----
+ adler = update(adler, b);*/
+ adler = updateByteImpl(b, adler);
+ // ----- END android -----
}
/**
@@ -66,7 +74,10 @@
if (off < 0 || len < 0 || off > b.length - len) {
throw new ArrayIndexOutOfBoundsException();
}
- adler = updateBytes(adler, b, off, len);
+ /* ----- BEGIN android -----
+ adler = updateBytes(adler, b, off, len);*/
+ adler = updateImpl(b, off, len, adler);
+ // ----- END android -----
}
/**
@@ -75,7 +86,10 @@
* @param b the byte array to update the checksum with
*/
public void update(byte[] b) {
- adler = updateBytes(adler, b, 0, b.length);
+ /* ----- BEGIN android -----
+ adler = updateBytes(adler, b, 0, b.length);*/
+ update(b, 0, b.length);
+ // ----- END android -----
}
/**
@@ -90,6 +104,7 @@
*
* @param buffer the ByteBuffer to update the checksum with
*/
+ /* ----- BEGIN android -----
private void update(ByteBuffer buffer) {
int pos = buffer.position();
int limit = buffer.limit();
@@ -108,6 +123,7 @@
}
buffer.position(limit);
}
+ ----- END android ----- */
/**
* Resets the checksum to initial value.
@@ -120,9 +136,13 @@
* Returns the checksum value.
*/
public long getValue() {
- return (long)adler & 0xffffffffL;
+ /* ----- BEGIN android -----
+ return (long)adler & 0xffffffffL;*/
+ return adler;
+ // ----- END android -----
}
+ /* ----- BEGIN android -----
// Set up JavaUtilZipAccess in SharedSecrets
static {
sun.misc.SharedSecrets.setJavaUtilZipAccess(new sun.misc.JavaUtilZipAccess() {
@@ -136,5 +156,10 @@
private native static int updateBytes(int adler, byte[] b, int off,
int len);
private native static int updateByteBuffer(int adler, long addr,
- int off, int len);
+ int off, int len);*/
+ private native long updateImpl(byte[] buf, int offset, int byteCount, long adler1);
+
+ private native long updateByteImpl(int val, long adler1);
+ // ----- END android -----
+
}
diff --git a/ojluni/src/main/java/java/util/zip/InflaterInputStream.java b/ojluni/src/main/java/java/util/zip/InflaterInputStream.java
index 53e16ee..b8bfb16 100755
--- a/ojluni/src/main/java/java/util/zip/InflaterInputStream.java
+++ b/ojluni/src/main/java/java/util/zip/InflaterInputStream.java
@@ -55,7 +55,9 @@
*/
protected int len;
- private boolean closed = false;
+ // Android-changed: closed is now protected.
+ protected boolean closed = false;
+
// this flag is set to true after EOF has reached
private boolean reachEOF = false;
diff --git a/ojluni/src/main/java/java/util/zip/ZipEntry.java b/ojluni/src/main/java/java/util/zip/ZipEntry.java
index b2b2562..1ade795 100755
--- a/ojluni/src/main/java/java/util/zip/ZipEntry.java
+++ b/ojluni/src/main/java/java/util/zip/ZipEntry.java
@@ -43,6 +43,8 @@
int flag = 0; // general purpose flag
byte[] extra; // optional extra field data for entry
String comment; // optional comment string for entry
+ // Android-changed: Add dataOffset for internal use.
+ long dataOffset;
/**
* Compression method for uncompressed entries.
@@ -87,6 +89,7 @@
flag = e.flag;
extra = e.extra;
comment = e.comment;
+ dataOffset = e.dataOffset;
}
/*
@@ -94,6 +97,11 @@
*/
ZipEntry() {}
+ /** @hide */
+ public long getDataOffset() {
+ return dataOffset;
+ }
+
/**
* Returns the name of the entry.
* @return the name of the entry
diff --git a/ojluni/src/main/java/java/util/zip/ZipFile.java b/ojluni/src/main/java/java/util/zip/ZipFile.java
index b6dbc24..5de1924 100755
--- a/ojluni/src/main/java/java/util/zip/ZipFile.java
+++ b/ojluni/src/main/java/java/util/zip/ZipFile.java
@@ -87,11 +87,8 @@
private static final boolean usemmap;
static {
- // A system prpperty to disable mmap use to avoid vm crash when
- // in-use zip file is accidently overwritten by others.
- String prop = sun.misc.VM.getSavedProperty("sun.zip.disableMemoryMapping");
- usemmap = (prop == null ||
- !(prop.length() == 0 || prop.equalsIgnoreCase("true")));
+ // Android-changed: always use mmap.
+ usemmap = true;
}
/**
@@ -213,8 +210,6 @@
this.zc = ZipCoder.get(charset);
long t0 = System.nanoTime();
jzfile = open(name, mode, file.lastModified(), usemmap);
- sun.misc.PerfCounter.getZipFileOpenTime().addElapsedTimeFrom(t0);
- sun.misc.PerfCounter.getZipFileCount().increment();
this.name = name;
this.total = getTotal(jzfile);
this.locsig = startsWithLOC(jzfile);
@@ -739,16 +734,6 @@
}
}
- static {
- sun.misc.SharedSecrets.setJavaUtilZipFileAccess(
- new sun.misc.JavaUtilZipFileAccess() {
- public boolean startsWithLocHeader(ZipFile zip) {
- return zip.startsWithLocHeader();
- }
- }
- );
- }
-
/**
* Returns {@code true} if, and only if, the zip file begins with {@code
* LOCSIG}.
diff --git a/ojluni/src/main/native/Register.cpp b/ojluni/src/main/native/Register.cpp
new file mode 100644
index 0000000..3bff990
--- /dev/null
+++ b/ojluni/src/main/native/Register.cpp
@@ -0,0 +1,48 @@
+/*
+ * Copyright (C) 2010 The Android Open Source Project
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+#define LOG_TAG "libcore" // We'll be next to "dalvikvm" in the log; make the distinction clear.
+
+#include "cutils/log.h"
+#include "JniConstants.h"
+#include "ScopedLocalFrame.h"
+
+#include <stdlib.h>
+
+extern "C" {
+
+extern void register_java_util_zip_ZipFile(JNIEnv*);
+extern void register_java_util_zip_Inflater(JNIEnv*);
+extern void register_java_util_zip_Deflater(JNIEnv*);
+extern void register_java_util_zip_CRC32(JNIEnv*);
+
+}
+
+// DalvikVM calls this on startup, so we can statically register all our native methods.
+jint JNI_OnLoad(JavaVM* vm, void*) {
+ JNIEnv* env;
+ if (vm->GetEnv(reinterpret_cast<void**>(&env), JNI_VERSION_1_6) != JNI_OK) {
+ ALOGE("JavaVM::GetEnv() failed");
+ abort();
+ }
+
+ ScopedLocalFrame localFrame(env);
+ register_java_util_zip_ZipFile(env);
+ register_java_util_zip_Inflater(env);
+ register_java_util_zip_Deflater(env);
+ register_java_util_zip_CRC32(env);
+ return JNI_VERSION_1_6;
+}
diff --git a/ojluni/src/main/native/io_util.c b/ojluni/src/main/native/io_util.c
old mode 100755
new mode 100644
index e17652a..1ab605c
--- a/ojluni/src/main/native/io_util.c
+++ b/ojluni/src/main/native/io_util.c
@@ -26,6 +26,7 @@
#include <stdlib.h>
#include <string.h>
#include <stddef.h>
+#include <stdio.h>
#include "jni.h"
#include "jni_util.h"
diff --git a/ojluni/src/main/native/java_util_zip_CRC32.c b/ojluni/src/main/native/java_util_zip_CRC32.c
old mode 100755
new mode 100644
index 689b34b..83b7287
--- a/ojluni/src/main/native/java_util_zip_CRC32.c
+++ b/ojluni/src/main/native/java_util_zip_CRC32.c
@@ -27,14 +27,18 @@
* Native method support for java.util.zip.CRC32
*/
+#include "JNIHelp.h"
#include "jni.h"
#include "jni_util.h"
#include <zlib.h>
#include "java_util_zip_CRC32.h"
+#define NATIVE_METHOD(className, functionName, signature) \
+{ #functionName, signature, (void*)(className ## _ ## functionName) }
+
JNIEXPORT jint JNICALL
-Java_java_util_zip_CRC32_update(JNIEnv *env, jclass cls, jint crc, jint b)
+CRC32_update(JNIEnv *env, jclass cls, jint crc, jint b)
{
Bytef buf[1];
@@ -43,7 +47,7 @@
}
JNIEXPORT jint JNICALL
-Java_java_util_zip_CRC32_updateBytes(JNIEnv *env, jclass cls, jint crc,
+CRC32_updateBytes(JNIEnv *env, jclass cls, jint crc,
jarray b, jint off, jint len)
{
Bytef *buf = (*env)->GetPrimitiveArrayCritical(env, b, 0);
@@ -58,3 +62,12 @@
{
return crc32(crc, (Bytef*)buf, len);
}
+
+static JNINativeMethod gMethods[] = {
+ NATIVE_METHOD(CRC32, update, "(II)I"),
+ NATIVE_METHOD(CRC32, updateBytes, "(I[BII)I"),
+};
+
+void register_java_util_zip_CRC32(JNIEnv* env) {
+ jniRegisterNativeMethods(env, "java/util/zip/CRC32", gMethods, NELEM(gMethods));
+}
diff --git a/ojluni/src/main/native/java_util_zip_Deflater.c b/ojluni/src/main/native/java_util_zip_Deflater.c
old mode 100755
new mode 100644
index dbf5ea4..59cce4c
--- a/ojluni/src/main/native/java_util_zip_Deflater.c
+++ b/ojluni/src/main/native/java_util_zip_Deflater.c
@@ -29,6 +29,7 @@
#include <stdio.h>
#include <stdlib.h>
+#include "JNIHelp.h"
#include "jlong.h"
#include "jni.h"
#include "jni_util.h"
@@ -36,6 +37,9 @@
#include "java_util_zip_Deflater.h"
+#define NATIVE_METHOD(className, functionName, signature) \
+{ #functionName, signature, (void*)(className ## _ ## functionName) }
+
#define DEF_MEM_LEVEL 8
static jfieldID levelID;
@@ -46,7 +50,7 @@
static jfieldID bufID, offID, lenID;
JNIEXPORT void JNICALL
-Java_java_util_zip_Deflater_initIDs(JNIEnv *env, jclass cls)
+Deflater_initIDs(JNIEnv *env, jclass cls)
{
levelID = (*env)->GetFieldID(env, cls, "level", "I");
strategyID = (*env)->GetFieldID(env, cls, "strategy", "I");
@@ -59,7 +63,7 @@
}
JNIEXPORT jlong JNICALL
-Java_java_util_zip_Deflater_init(JNIEnv *env, jclass cls, jint level,
+Deflater_init(JNIEnv *env, jclass cls, jint level,
jint strategy, jboolean nowrap)
{
z_stream *strm = calloc(1, sizeof(z_stream));
@@ -92,7 +96,7 @@
}
JNIEXPORT void JNICALL
-Java_java_util_zip_Deflater_setDictionary(JNIEnv *env, jclass cls, jlong addr,
+Deflater_setDictionary(JNIEnv *env, jclass cls, jlong addr,
jarray b, jint off, jint len)
{
Bytef *buf = (*env)->GetPrimitiveArrayCritical(env, b, 0);
@@ -115,7 +119,7 @@
}
JNIEXPORT jint JNICALL
-Java_java_util_zip_Deflater_deflateBytes(JNIEnv *env, jobject this, jlong addr,
+Deflater_deflateBytes(JNIEnv *env, jobject this, jlong addr,
jarray b, jint off, jint len, jint flush)
{
z_stream *strm = jlong_to_ptr(addr);
@@ -210,13 +214,13 @@
}
JNIEXPORT jint JNICALL
-Java_java_util_zip_Deflater_getAdler(JNIEnv *env, jclass cls, jlong addr)
+Deflater_getAdler(JNIEnv *env, jclass cls, jlong addr)
{
return ((z_stream *)jlong_to_ptr(addr))->adler;
}
JNIEXPORT void JNICALL
-Java_java_util_zip_Deflater_reset(JNIEnv *env, jclass cls, jlong addr)
+Deflater_reset(JNIEnv *env, jclass cls, jlong addr)
{
if (deflateReset((z_stream *)jlong_to_ptr(addr)) != Z_OK) {
JNU_ThrowInternalError(env, 0);
@@ -224,7 +228,7 @@
}
JNIEXPORT void JNICALL
-Java_java_util_zip_Deflater_end(JNIEnv *env, jclass cls, jlong addr)
+Deflater_end(JNIEnv *env, jclass cls, jlong addr)
{
if (deflateEnd((z_stream *)jlong_to_ptr(addr)) == Z_STREAM_ERROR) {
JNU_ThrowInternalError(env, 0);
@@ -232,3 +236,17 @@
free((z_stream *)jlong_to_ptr(addr));
}
}
+
+static JNINativeMethod gMethods[] = {
+ NATIVE_METHOD(Deflater, initIDs, "()V"),
+ NATIVE_METHOD(Deflater, init, "(IIZ)J"),
+ NATIVE_METHOD(Deflater, setDictionary, "(J[BII)V"),
+ NATIVE_METHOD(Deflater, deflateBytes, "(J[BIII)I"),
+ NATIVE_METHOD(Deflater, getAdler, "(J)I"),
+ NATIVE_METHOD(Deflater, reset, "(J)V"),
+ NATIVE_METHOD(Deflater, end, "(J)V"),
+};
+
+void register_java_util_zip_Deflater(JNIEnv* env) {
+ jniRegisterNativeMethods(env, "java/util/zip/Deflater", gMethods, NELEM(gMethods));
+}
diff --git a/ojluni/src/main/native/java_util_zip_Inflater.c b/ojluni/src/main/native/java_util_zip_Inflater.c
old mode 100755
new mode 100644
index 062a892..0cb6112
--- a/ojluni/src/main/native/java_util_zip_Inflater.c
+++ b/ojluni/src/main/native/java_util_zip_Inflater.c
@@ -31,6 +31,7 @@
#include <stdlib.h>
#include <errno.h>
#include <string.h>
+#include "JNIHelp.h"
#include "jlong.h"
#include "jni.h"
#include "jvm.h"
@@ -38,6 +39,9 @@
#include <zlib.h>
#include "java_util_zip_Inflater.h"
+#define NATIVE_METHOD(className, functionName, signature) \
+{ #functionName, signature, (void*)(className ## _ ## functionName) }
+
#define ThrowDataFormatException(env, msg) \
JNU_ThrowByName(env, "java/util/zip/DataFormatException", msg)
@@ -46,7 +50,7 @@
static jfieldID bufID, offID, lenID;
JNIEXPORT void JNICALL
-Java_java_util_zip_Inflater_initIDs(JNIEnv *env, jclass cls)
+Inflater_initIDs(JNIEnv *env, jclass cls)
{
needDictID = (*env)->GetFieldID(env, cls, "needDict", "Z");
finishedID = (*env)->GetFieldID(env, cls, "finished", "Z");
@@ -56,7 +60,7 @@
}
JNIEXPORT jlong JNICALL
-Java_java_util_zip_Inflater_init(JNIEnv *env, jclass cls, jboolean nowrap)
+Inflater_init(JNIEnv *env, jclass cls, jboolean nowrap)
{
z_stream *strm = calloc(1, sizeof(z_stream));
@@ -82,7 +86,7 @@
}
JNIEXPORT void JNICALL
-Java_java_util_zip_Inflater_setDictionary(JNIEnv *env, jclass cls, jlong addr,
+Inflater_setDictionary(JNIEnv *env, jclass cls, jlong addr,
jarray b, jint off, jint len)
{
Bytef *buf = (*env)->GetPrimitiveArrayCritical(env, b, 0);
@@ -105,7 +109,7 @@
}
JNIEXPORT jint JNICALL
-Java_java_util_zip_Inflater_inflateBytes(JNIEnv *env, jobject this, jlong addr,
+Inflater_inflateBytes(JNIEnv *env, jobject this, jlong addr,
jarray b, jint off, jint len)
{
z_stream *strm = jlong_to_ptr(addr);
@@ -169,13 +173,13 @@
}
JNIEXPORT jint JNICALL
-Java_java_util_zip_Inflater_getAdler(JNIEnv *env, jclass cls, jlong addr)
+Inflater_getAdler(JNIEnv *env, jclass cls, jlong addr)
{
return ((z_stream *)jlong_to_ptr(addr))->adler;
}
JNIEXPORT void JNICALL
-Java_java_util_zip_Inflater_reset(JNIEnv *env, jclass cls, jlong addr)
+Inflater_reset(JNIEnv *env, jclass cls, jlong addr)
{
if (inflateReset(jlong_to_ptr(addr)) != Z_OK) {
JNU_ThrowInternalError(env, 0);
@@ -183,7 +187,7 @@
}
JNIEXPORT void JNICALL
-Java_java_util_zip_Inflater_end(JNIEnv *env, jclass cls, jlong addr)
+Inflater_end(JNIEnv *env, jclass cls, jlong addr)
{
if (inflateEnd(jlong_to_ptr(addr)) == Z_STREAM_ERROR) {
JNU_ThrowInternalError(env, 0);
@@ -191,3 +195,17 @@
free(jlong_to_ptr(addr));
}
}
+
+static JNINativeMethod gMethods[] = {
+ NATIVE_METHOD(Inflater, initIDs, "()V"),
+ NATIVE_METHOD(Inflater, init, "(Z)J"),
+ NATIVE_METHOD(Inflater, setDictionary, "(J[BII)V"),
+ NATIVE_METHOD(Inflater, inflateBytes, "(J[BII)I"),
+ NATIVE_METHOD(Inflater, getAdler, "(J)I"),
+ NATIVE_METHOD(Inflater, reset, "(J)V"),
+ NATIVE_METHOD(Inflater, end, "(J)V"),
+};
+
+void register_java_util_zip_Inflater(JNIEnv* env) {
+ jniRegisterNativeMethods(env, "java/util/zip/Inflater", gMethods, NELEM(gMethods));
+}
diff --git a/ojluni/src/main/native/java_util_zip_Inflater.h b/ojluni/src/main/native/java_util_zip_Inflater.h
old mode 100755
new mode 100644
index 0fcec49..dde7311
--- a/ojluni/src/main/native/java_util_zip_Inflater.h
+++ b/ojluni/src/main/native/java_util_zip_Inflater.h
@@ -12,7 +12,7 @@
* Method: initIDs
* Signature: ()V
*/
-JNIEXPORT void JNICALL Java_java_util_zip_Inflater_initIDs
+JNIEXPORT void JNICALL Inflater_initIDs
(JNIEnv *, jclass);
/*
@@ -20,7 +20,7 @@
* Method: init
* Signature: (Z)J
*/
-JNIEXPORT jlong JNICALL Java_java_util_zip_Inflater_init
+JNIEXPORT jlong JNICALL Inflater_init
(JNIEnv *, jclass, jboolean);
/*
@@ -28,7 +28,7 @@
* Method: setDictionary
* Signature: (J[BII)V
*/
-JNIEXPORT void JNICALL Java_java_util_zip_Inflater_setDictionary
+JNIEXPORT void JNICALL Inflater_setDictionary
(JNIEnv *, jclass, jlong, jbyteArray, jint, jint);
/*
@@ -36,7 +36,7 @@
* Method: inflateBytes
* Signature: (J[BII)I
*/
-JNIEXPORT jint JNICALL Java_java_util_zip_Inflater_inflateBytes
+JNIEXPORT jint JNICALL Inflater_inflateBytes
(JNIEnv *, jobject, jlong, jbyteArray, jint, jint);
/*
@@ -44,7 +44,7 @@
* Method: getAdler
* Signature: (J)I
*/
-JNIEXPORT jint JNICALL Java_java_util_zip_Inflater_getAdler
+JNIEXPORT jint JNICALL Inflater_getAdler
(JNIEnv *, jclass, jlong);
/*
@@ -52,7 +52,7 @@
* Method: reset
* Signature: (J)V
*/
-JNIEXPORT void JNICALL Java_java_util_zip_Inflater_reset
+JNIEXPORT void JNICALL Inflater_reset
(JNIEnv *, jclass, jlong);
/*
@@ -60,7 +60,7 @@
* Method: end
* Signature: (J)V
*/
-JNIEXPORT void JNICALL Java_java_util_zip_Inflater_end
+JNIEXPORT void JNICALL Inflater_end
(JNIEnv *, jclass, jlong);
#ifdef __cplusplus
diff --git a/ojluni/src/main/native/java_util_zip_ZipFile.c b/ojluni/src/main/native/java_util_zip_ZipFile.c
old mode 100755
new mode 100644
index 30fbfdd..651d71c
--- a/ojluni/src/main/native/java_util_zip_ZipFile.c
+++ b/ojluni/src/main/native/java_util_zip_ZipFile.c
@@ -33,6 +33,7 @@
#include <errno.h>
#include <ctype.h>
#include <assert.h>
+#include "JNIHelp.h"
#include "jlong.h"
#include "jvm.h"
#include "jni.h"
@@ -45,7 +46,9 @@
#endif
#include "java_util_zip_ZipFile.h"
-#include "java_util_jar_JarFile.h"
+
+#define NATIVE_METHOD(className, functionName, signature) \
+{ #functionName, signature, (void*)(className ## _ ## functionName) }
#define DEFLATED 8
#define STORED 0
@@ -56,7 +59,7 @@
static int OPEN_DELETE = java_util_zip_ZipFile_OPEN_DELETE;
JNIEXPORT void JNICALL
-Java_java_util_zip_ZipFile_initIDs(JNIEnv *env, jclass cls)
+ZipFile_initIDs(JNIEnv *env, jclass cls)
{
jzfileID = (*env)->GetFieldID(env, cls, "jzfile", "J");
assert(jzfileID != 0);
@@ -80,7 +83,7 @@
}
JNIEXPORT jlong JNICALL
-Java_java_util_zip_ZipFile_open(JNIEnv *env, jclass cls, jstring name,
+ZipFile_open(JNIEnv *env, jclass cls, jstring name,
jint mode, jlong lastModified,
jboolean usemmap)
{
@@ -130,7 +133,7 @@
}
JNIEXPORT jint JNICALL
-Java_java_util_zip_ZipFile_getTotal(JNIEnv *env, jclass cls, jlong zfile)
+ZipFile_getTotal(JNIEnv *env, jclass cls, jlong zfile)
{
jzfile *zip = jlong_to_ptr(zfile);
@@ -138,7 +141,7 @@
}
JNIEXPORT jboolean JNICALL
-Java_java_util_zip_ZipFile_startsWithLOC(JNIEnv *env, jclass cls, jlong zfile)
+ZipFile_startsWithLOC(JNIEnv *env, jclass cls, jlong zfile)
{
jzfile *zip = jlong_to_ptr(zfile);
@@ -146,14 +149,14 @@
}
JNIEXPORT void JNICALL
-Java_java_util_zip_ZipFile_close(JNIEnv *env, jclass cls, jlong zfile)
+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)
+ZipFile_getEntry(JNIEnv *env, jclass cls, jlong zfile,
+ jbyteArray name, jboolean addSlash)
{
#define MAXNAME 1024
jzfile *zip = jlong_to_ptr(zfile);
@@ -184,7 +187,7 @@
}
JNIEXPORT void JNICALL
-Java_java_util_zip_ZipFile_freeEntry(JNIEnv *env, jclass cls, jlong zfile,
+ZipFile_freeEntry(JNIEnv *env, jclass cls, jlong zfile,
jlong zentry)
{
jzfile *zip = jlong_to_ptr(zfile);
@@ -193,7 +196,7 @@
}
JNIEXPORT jlong JNICALL
-Java_java_util_zip_ZipFile_getNextEntry(JNIEnv *env, jclass cls, jlong zfile,
+ZipFile_getNextEntry(JNIEnv *env, jclass cls, jlong zfile,
jint n)
{
jzentry *ze = ZIP_GetNextEntry(jlong_to_ptr(zfile), n);
@@ -201,51 +204,49 @@
}
JNIEXPORT jint JNICALL
-Java_java_util_zip_ZipFile_getEntryMethod(JNIEnv *env, jclass cls, jlong zentry)
+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)
+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)
+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)
+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)
+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)
+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)
+ZipFile_getCommentBytes(JNIEnv *env, jclass cls, jlong zfile)
{
jzfile *zip = jlong_to_ptr(zfile);
jbyteArray jba = NULL;
@@ -259,9 +260,7 @@
}
JNIEXPORT jbyteArray JNICALL
-Java_java_util_zip_ZipFile_getEntryBytes(JNIEnv *env,
- jclass cls,
- jlong zentry, jint type)
+ZipFile_getEntryBytes(JNIEnv *env, jclass cls, jlong zentry, jint type)
{
jzentry *ze = jlong_to_ptr(zentry);
int len = 0;
@@ -297,9 +296,9 @@
}
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)
+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;
@@ -334,57 +333,8 @@
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)
+ZipFile_getZipMessage(JNIEnv *env, jclass cls, jlong zfile)
{
jzfile *zip = jlong_to_ptr(zfile);
char *msg = zip->msg;
@@ -393,3 +343,28 @@
}
return JNU_NewStringPlatform(env, msg);
}
+
+static JNINativeMethod gMethods[] = {
+ NATIVE_METHOD(ZipFile, initIDs, "()V"),
+ NATIVE_METHOD(ZipFile, getEntry, "(J[BZ)J"),
+ NATIVE_METHOD(ZipFile, freeEntry, "(JJ)V"),
+ NATIVE_METHOD(ZipFile, getNextEntry, "(JI)J"),
+ NATIVE_METHOD(ZipFile, close, "(J)V"),
+ NATIVE_METHOD(ZipFile, open, "(Ljava/lang/String;IJZ)J"),
+ NATIVE_METHOD(ZipFile, getTotal, "(J)I"),
+ NATIVE_METHOD(ZipFile, startsWithLOC, "(J)Z"),
+ NATIVE_METHOD(ZipFile, read, "(JJJ[BII)I"),
+ NATIVE_METHOD(ZipFile, getEntryTime, "(J)J"),
+ NATIVE_METHOD(ZipFile, getEntryCrc, "(J)J"),
+ NATIVE_METHOD(ZipFile, getEntryCSize, "(J)J"),
+ NATIVE_METHOD(ZipFile, getEntrySize, "(J)J"),
+ NATIVE_METHOD(ZipFile, getEntryMethod, "(J)I"),
+ NATIVE_METHOD(ZipFile, getEntryFlag, "(J)I"),
+ NATIVE_METHOD(ZipFile, getCommentBytes, "(J)[B"),
+ NATIVE_METHOD(ZipFile, getEntryBytes, "(JI)[B"),
+ NATIVE_METHOD(ZipFile, getZipMessage, "(J)Ljava/lang/String;"),
+};
+
+void register_java_util_zip_ZipFile(JNIEnv* env) {
+ jniRegisterNativeMethods(env, "java/util/zip/ZipFile", gMethods, NELEM(gMethods));
+}
diff --git a/ojluni/src/main/native/java_util_zip_ZipFile.h b/ojluni/src/main/native/java_util_zip_ZipFile.h
old mode 100755
new mode 100644
index d58b4f0..059a908
--- a/ojluni/src/main/native/java_util_zip_ZipFile.h
+++ b/ojluni/src/main/native/java_util_zip_ZipFile.h
@@ -26,7 +26,7 @@
* Method: initIDs
* Signature: ()V
*/
-JNIEXPORT void JNICALL Java_java_util_zip_ZipFile_initIDs
+JNIEXPORT void JNICALL ZipFile_initIDs
(JNIEnv *, jclass);
/*
@@ -34,7 +34,7 @@
* Method: getEntry
* Signature: (J[BZ)J
*/
-JNIEXPORT jlong JNICALL Java_java_util_zip_ZipFile_getEntry
+JNIEXPORT jlong JNICALL ZipFile_getEntry
(JNIEnv *, jclass, jlong, jbyteArray, jboolean);
/*
@@ -42,7 +42,7 @@
* Method: freeEntry
* Signature: (JJ)V
*/
-JNIEXPORT void JNICALL Java_java_util_zip_ZipFile_freeEntry
+JNIEXPORT void JNICALL ZipFile_freeEntry
(JNIEnv *, jclass, jlong, jlong);
/*
@@ -50,7 +50,7 @@
* Method: getNextEntry
* Signature: (JI)J
*/
-JNIEXPORT jlong JNICALL Java_java_util_zip_ZipFile_getNextEntry
+JNIEXPORT jlong JNICALL ZipFile_getNextEntry
(JNIEnv *, jclass, jlong, jint);
/*
@@ -58,7 +58,7 @@
* Method: close
* Signature: (J)V
*/
-JNIEXPORT void JNICALL Java_java_util_zip_ZipFile_close
+JNIEXPORT void JNICALL ZipFile_close
(JNIEnv *, jclass, jlong);
/*
@@ -66,7 +66,7 @@
* Method: open
* Signature: (Ljava/lang/String;IJZ)J
*/
-JNIEXPORT jlong JNICALL Java_java_util_zip_ZipFile_open
+JNIEXPORT jlong JNICALL ZipFile_open
(JNIEnv *, jclass, jstring, jint, jlong, jboolean);
/*
@@ -74,7 +74,7 @@
* Method: getTotal
* Signature: (J)I
*/
-JNIEXPORT jint JNICALL Java_java_util_zip_ZipFile_getTotal
+JNIEXPORT jint JNICALL ZipFile_getTotal
(JNIEnv *, jclass, jlong);
/*
@@ -82,7 +82,7 @@
* Method: startsWithLOC
* Signature: (J)Z
*/
-JNIEXPORT jboolean JNICALL Java_java_util_zip_ZipFile_startsWithLOC
+JNIEXPORT jboolean JNICALL ZipFile_startsWithLOC
(JNIEnv *, jclass, jlong);
/*
@@ -90,7 +90,7 @@
* Method: read
* Signature: (JJJ[BII)I
*/
-JNIEXPORT jint JNICALL Java_java_util_zip_ZipFile_read
+JNIEXPORT jint JNICALL ZipFile_read
(JNIEnv *, jclass, jlong, jlong, jlong, jbyteArray, jint, jint);
/*
@@ -98,7 +98,7 @@
* Method: getEntryTime
* Signature: (J)J
*/
-JNIEXPORT jlong JNICALL Java_java_util_zip_ZipFile_getEntryTime
+JNIEXPORT jlong JNICALL ZipFile_getEntryTime
(JNIEnv *, jclass, jlong);
/*
@@ -106,7 +106,7 @@
* Method: getEntryCrc
* Signature: (J)J
*/
-JNIEXPORT jlong JNICALL Java_java_util_zip_ZipFile_getEntryCrc
+JNIEXPORT jlong JNICALL ZipFile_getEntryCrc
(JNIEnv *, jclass, jlong);
/*
@@ -114,7 +114,7 @@
* Method: getEntryCSize
* Signature: (J)J
*/
-JNIEXPORT jlong JNICALL Java_java_util_zip_ZipFile_getEntryCSize
+JNIEXPORT jlong JNICALL ZipFile_getEntryCSize
(JNIEnv *, jclass, jlong);
/*
@@ -122,7 +122,7 @@
* Method: getEntrySize
* Signature: (J)J
*/
-JNIEXPORT jlong JNICALL Java_java_util_zip_ZipFile_getEntrySize
+JNIEXPORT jlong JNICALL ZipFile_getEntrySize
(JNIEnv *, jclass, jlong);
/*
@@ -130,7 +130,7 @@
* Method: getEntryMethod
* Signature: (J)I
*/
-JNIEXPORT jint JNICALL Java_java_util_zip_ZipFile_getEntryMethod
+JNIEXPORT jint JNICALL ZipFile_getEntryMethod
(JNIEnv *, jclass, jlong);
/*
@@ -138,7 +138,7 @@
* Method: getEntryFlag
* Signature: (J)I
*/
-JNIEXPORT jint JNICALL Java_java_util_zip_ZipFile_getEntryFlag
+JNIEXPORT jint JNICALL ZipFile_getEntryFlag
(JNIEnv *, jclass, jlong);
/*
@@ -146,7 +146,7 @@
* Method: getCommentBytes
* Signature: (J)[B
*/
-JNIEXPORT jbyteArray JNICALL Java_java_util_zip_ZipFile_getCommentBytes
+JNIEXPORT jbyteArray JNICALL ZipFile_getCommentBytes
(JNIEnv *, jclass, jlong);
/*
@@ -154,7 +154,7 @@
* Method: getEntryBytes
* Signature: (JI)[B
*/
-JNIEXPORT jbyteArray JNICALL Java_java_util_zip_ZipFile_getEntryBytes
+JNIEXPORT jbyteArray JNICALL ZipFile_getEntryBytes
(JNIEnv *, jclass, jlong, jint);
/*
@@ -162,7 +162,7 @@
* Method: getZipMessage
* Signature: (J)Ljava/lang/String;
*/
-JNIEXPORT jstring JNICALL Java_java_util_zip_ZipFile_getZipMessage
+JNIEXPORT jstring JNICALL ZipFile_getZipMessage
(JNIEnv *, jclass, jlong);
#ifdef __cplusplus
diff --git a/ojluni/src/main/native/jni_util.c b/ojluni/src/main/native/jni_util.c
old mode 100755
new mode 100644
index 3ef707f..c503cb8
--- a/ojluni/src/main/native/jni_util.c
+++ b/ojluni/src/main/native/jni_util.c
@@ -25,6 +25,7 @@
#include <stdlib.h>
#include <string.h>
+#include <stdio.h>
#include "jvm.h"
#include "jni.h"
diff --git a/ojluni/src/main/native/jvm.h b/ojluni/src/main/native/jvm.h
old mode 100755
new mode 100644
index f298cca..0f439e5
--- a/ojluni/src/main/native/jvm.h
+++ b/ojluni/src/main/native/jvm.h
@@ -27,6 +27,7 @@
#define _JAVASOFT_JVM_H_
#include <sys/stat.h>
+#include <stdio.h>
#include "jni.h"
#include "jvm_md.h"
diff --git a/ojluni/src/main/native/openjdksub.mk b/ojluni/src/main/native/openjdksub.mk
new file mode 100644
index 0000000..aedf82e
--- /dev/null
+++ b/ojluni/src/main/native/openjdksub.mk
@@ -0,0 +1,24 @@
+# -*- mode: makefile -*-
+# This file is included by the top-level libcore Android.mk.
+# It's not a normal makefile, so we don't include CLEAR_VARS
+# or BUILD_*_LIBRARY.
+
+srcdir := ojluni/src/main/native
+LOCAL_SRC_FILES := \
+ java_util_zip_ZipFile.c \
+ java_util_zip_Inflater.c \
+ java_util_zip_Deflater.c \
+ java_util_zip_CRC32.c \
+ zip_util.c \
+ jni_util.c \
+ jni_util_md.c \
+ io_util.c \
+ canonicalize_md.c \
+ FileDescriptor_md.c \
+ Register.cpp \
+
+LOCAL_C_INCLUDES += \
+ libcore/$(srcdir) \
+ external/fdlibm \
+ external/openssl/include \
+ external/zlib
diff --git a/ojluni/src/main/native/zip_util.c b/ojluni/src/main/native/zip_util.c
old mode 100755
new mode 100644
index 00c231b..abf1fec
--- a/ojluni/src/main/native/zip_util.c
+++ b/ojluni/src/main/native/zip_util.c
@@ -584,15 +584,17 @@
}
}
- if (cenlen > endpos)
+ if (cenlen > endpos) {
ZIP_FORMAT_ERROR("invalid END header (bad central directory size)");
+ }
cenpos = endpos - cenlen;
/* Get position of first local file (LOC) header, taking into
* account that there may be a stub prefixed to the zip file. */
zip->locpos = cenpos - cenoff;
- if (zip->locpos < 0)
+ if (zip->locpos < 0) {
ZIP_FORMAT_ERROR("invalid END header (bad central directory offset)");
+ }
#ifdef USE_MMAP
if (zip->usemmap) {
@@ -680,19 +682,25 @@
method = CENHOW(cp);
nlen = CENNAM(cp);
- if (GETSIG(cp) != CENSIG)
+ if (GETSIG(cp) != CENSIG) {
ZIP_FORMAT_ERROR("invalid CEN header (bad signature)");
- if (CENFLG(cp) & 1)
+ }
+ if (CENFLG(cp) & 1) {
ZIP_FORMAT_ERROR("invalid CEN header (encrypted entry)");
- if (method != STORED && method != DEFLATED)
+ }
+ if (method != STORED && method != DEFLATED) {
ZIP_FORMAT_ERROR("invalid CEN header (bad compression method)");
- if (cp + CENHDR + nlen > cenend)
+ }
+ if (cp + CENHDR + nlen > cenend) {
ZIP_FORMAT_ERROR("invalid CEN header (bad header size)");
+ }
/* if the entry is metadata add it to our metadata names */
- if (isMetaName((char *)cp+CENHDR, nlen))
- if (addMetaName(zip, (char *)cp+CENHDR, nlen) != 0)
+ if (isMetaName((char *)cp+CENHDR, nlen)) {
+ if (addMetaName(zip, (char *)cp+CENHDR, nlen) != 0) {
goto Catch;
+ }
+ }
/* Record the CEN offset and the name hash in our hash cell. */
entries[i].cenpos = cenpos + (cp - cenbuf);
@@ -703,8 +711,9 @@
entries[i].next = table[hsh];
table[hsh] = i;
}
- if (cp != cenend)
+ if (cp != cenend) {
ZIP_FORMAT_ERROR("invalid CEN header (bad header size)");
+ }
zip->total = i;
goto Finally;
diff --git a/openjdk_java_files b/openjdk_java_files
index 6cce0f8..d2e237c 100644
--- a/openjdk_java_files
+++ b/openjdk_java_files
@@ -711,3 +711,30 @@
java/util/prefs/Preferences.java
java/util/prefs/XmlSupport.java
java/util/prefs/Base64.java
+java/util/zip/CheckedInputStream.java
+java/util/zip/CheckedOutputStream.java
+java/util/zip/ZipException.java
+java/util/zip/ZipError.java
+java/util/zip/DataFormatException.java
+java/util/zip/Checksum.java
+java/util/zip/Adler32.java
+java/java/util/zip/CRC32.java
+java/java/util/zip/GZIPOutputStream.java
+java/java/util/zip/ZipOutputStream.java
+java/util/zip/ZipConstants64.java
+java/util/zip/ZipCoder.java
+sun/nio/cs/ArrayEncoder.java
+sun/nio/cs/ArrayEncoder.java
+sun/nio/cs/ArrayDecoder.java
+java/util/zip/DeflaterOutputStream.java
+java/util/zip/ZipEntry.java
+java/util/zip/ZipInputStream.java
+java/util/zip/ZipFile.java
+java/util/zip/InflaterInputStream.java
+java/util/zip/GZIPInputStream.java
+java/util/zip/Inflater.java
+java/util/zip/ZStreamRef.java
+java/sun/misc/Cleaner.java
+java/util/zip/Deflater.java
+java/util/zip/DeflaterInputStream.java
+java/util/zip/InflaterOutputStream.java