diff options
Diffstat (limited to 'nio')
-rw-r--r-- | nio/src/main/java/org/apache/harmony/nio/AddressUtil.java | 35 | ||||
-rw-r--r-- | nio/src/main/native/org_apache_harmony_nio_AddressUtil.cpp | 73 | ||||
-rw-r--r-- | nio/src/main/native/sub.mk | 16 |
3 files changed, 5 insertions, 119 deletions
diff --git a/nio/src/main/java/org/apache/harmony/nio/AddressUtil.java b/nio/src/main/java/org/apache/harmony/nio/AddressUtil.java index 315fe57..d39b1ea 100644 --- a/nio/src/main/java/org/apache/harmony/nio/AddressUtil.java +++ b/nio/src/main/java/org/apache/harmony/nio/AddressUtil.java @@ -58,33 +58,8 @@ public class AddressUtil { return ((DirectBuffer) buf).getEffectiveAddress().toInt(); } - /** - * Gets the address of native resource held by the given channel, if it has - * any. - * - * For network related channel, including {@link SocketChannel}, - * {@link ServerSocketChannel} and {@link DatagramChannel}, this method - * returns the Socket handle (long) in Linux, and returns a SOCKET - * (UINT_PTR) in windows. - * - * For {@link FileChannel}, this method returns the native file descriptor. - * - * For other channels, this method return 0, which means unsupported - * operation. - * - * @param channel - * the given channel which may holds a native resource address - * @return the address of native resource held by the given channel, if any, - * otherwise return 0 - */ - public static int getChannelAddress(Channel channel){ - if (channel instanceof FileDescriptorHandler) { - return getFDAddress(((FileDescriptorHandler) channel).getFD()); - } else if (channel instanceof FileChannelImpl) { - return ((FileChannelImpl) channel).getHandle(); - } - return 0; - } - - private static native int getFDAddress(FileDescriptor fd); -}
\ No newline at end of file + // BEGIN android-removed: dead code (the native side of which was scary!) + //public static int getChannelAddress(Channel channel); + //private static native int getFDAddress(FileDescriptor fd); + // END android-removed +} diff --git a/nio/src/main/native/org_apache_harmony_nio_AddressUtil.cpp b/nio/src/main/native/org_apache_harmony_nio_AddressUtil.cpp deleted file mode 100644 index cb665de..0000000 --- a/nio/src/main/native/org_apache_harmony_nio_AddressUtil.cpp +++ /dev/null @@ -1,73 +0,0 @@ -/* - * Copyright (C) 2007 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. - */ - -#include "JNIHelp.h" -#include "AndroidSystemNatives.h" - -#include <stdlib.h> -#include <unistd.h> -#include <sys/types.h> -#include <sys/stat.h> - -#define SOCKET_CAST(x) ((struct hysocket_struct*) x)->sock - -typedef jint OSSOCKET; - -typedef struct hysocket_struct -{ - OSSOCKET sock; - unsigned short family; -} hysocket_struct; - -typedef struct hysocket_struct *hysocket_t; - -/* - * Internal helper function. - * - * Get the file descriptor. - */ -static jint getFd(JNIEnv* env, jclass clazz, jobject fd) -{ - jclass descriptorCLS; - jfieldID descriptorFID; - hysocket_t* hysocketP; - - descriptorCLS = env->FindClass("java/io/FileDescriptor"); - if (NULL == descriptorCLS){ - return 0; - } - descriptorFID = env->GetFieldID(descriptorCLS, "descriptor", "I"); - if (NULL == descriptorFID){ - return 0; - } - jint result = env->GetIntField(fd, descriptorFID); - hysocketP = (hysocket_t*) (result); - return SOCKET_CAST(hysocketP); -} - -/* - * JNI registration - */ -static JNINativeMethod gMethods[] = { - /* name, signature, funcPtr */ - { "getFDAddress", "(Ljava/io/FileDescriptor;)I", (void*) getFd } -}; - -int register_org_apache_harmony_nio_AddressUtil(JNIEnv* env) -{ - return jniRegisterNativeMethods(env, "org/apache/harmony/nio/AddressUtil", - gMethods, NELEM(gMethods)); -} diff --git a/nio/src/main/native/sub.mk b/nio/src/main/native/sub.mk deleted file mode 100644 index 750d216..0000000 --- a/nio/src/main/native/sub.mk +++ /dev/null @@ -1,16 +0,0 @@ -# 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. - -LOCAL_SRC_FILES := \ - org_apache_harmony_nio_AddressUtil.cpp - -LOCAL_C_INCLUDES += - -# Any shared/static libs that are listed here must also -# be listed in libs/nativehelper/Android.mk. -# TODO: fix this requirement - -LOCAL_SHARED_LIBRARIES += - -LOCAL_STATIC_LIBRARIES += |