I messed up my commit by commiting at modules/ level when there were
also changes in native-src/  -- sorry about that.

It's not been a good week already.

Regards,
Tim

George Harley wrote:
> Hi Tim,
> 
> Fixed by your revision 417397 change. Looks like I just chose a bad time
> to update from the repository.
> 
> Thanks,
> George
> 
> 
> 
> George Harley wrote:
>> Hi Tim,
>>
>> I have started to see test errors in my local Windows XP sandbox since
>> this commit. In particular there are three tests in the new
>> org.apache.harmony.tests.nio.AddressUtilTest class that throw
>> java.lang.UnsatisfiedLinkError on account of not being able to locate
>> the native implementation of AddressUtil.getFDAddress(FileDescriptor).
>>
>> Will look at this a bit closer now - maybe it's a screw up in my
>> environment - but thought you should know sooner rather than...
>>
>> Best regards,
>> George
>>
>>
>>
>> [EMAIL PROTECTED] wrote:
>>> Author: tellison
>>> Date: Tue Jun 27 02:28:15 2006
>>> New Revision: 417385
>>>
>>> URL: http://svn.apache.org/viewvc?rev=417385&view=rev
>>> Log:
>>> Apply patch HARMONY-578 ([classlib][nio] NIO should provide some
>>> utility classes for the JNI 1.4 enhancement)
>>>
>>> Added:
>>>    
>>> incubator/harmony/enhanced/classlib/trunk/modules/nio/src/main/java/org/apache/harmony/nio/AddressUtil.java
>>>   
>>> (with props)
>>>    
>>> incubator/harmony/enhanced/classlib/trunk/modules/nio/src/main/native/
>>>    
>>> incubator/harmony/enhanced/classlib/trunk/modules/nio/src/main/native/nio/
>>>
>>>    
>>> incubator/harmony/enhanced/classlib/trunk/modules/nio/src/main/native/nio/linux/
>>>
>>>    
>>> incubator/harmony/enhanced/classlib/trunk/modules/nio/src/main/native/nio/linux/libhynio.exp
>>>
>>>    
>>> incubator/harmony/enhanced/classlib/trunk/modules/nio/src/main/native/nio/linux/makefile
>>>
>>>    
>>> incubator/harmony/enhanced/classlib/trunk/modules/nio/src/main/native/nio/shared/
>>>   
>>> (with props)
>>>    
>>> incubator/harmony/enhanced/classlib/trunk/modules/nio/src/main/native/nio/shared/AddressUtil.c
>>>   
>>> (with props)
>>>    
>>> incubator/harmony/enhanced/classlib/trunk/modules/nio/src/main/native/nio/shared/AddressUtil.h
>>>
>>>    
>>> incubator/harmony/enhanced/classlib/trunk/modules/nio/src/main/native/nio/shared/DirectBufferUtil.c
>>>   
>>> (with props)
>>>    
>>> incubator/harmony/enhanced/classlib/trunk/modules/nio/src/main/native/nio/windows/
>>>   
>>> (with props)
>>>    
>>> incubator/harmony/enhanced/classlib/trunk/modules/nio/src/main/native/nio/windows/hynio.def
>>>
>>>    
>>> incubator/harmony/enhanced/classlib/trunk/modules/nio/src/main/native/nio/windows/hynio.rc
>>>
>>>    
>>> incubator/harmony/enhanced/classlib/trunk/modules/nio/src/main/native/nio/windows/makefile
>>>
>>>    
>>> incubator/harmony/enhanced/classlib/trunk/modules/nio/src/test/java/org/apache/harmony/tests/nio/AddressUtilTest.java
>>>   
>>> (with props)
>>> Modified:
>>>     incubator/harmony/enhanced/classlib/trunk/modules/nio/build.xml
>>>    
>>> incubator/harmony/enhanced/classlib/trunk/modules/nio/make/hyproperties.xml
>>>
>>>    
>>> incubator/harmony/enhanced/classlib/trunk/modules/nio/src/main/java/org/apache/harmony/nio/internal/FileChannelImpl.java
>>>
>>>
>>> Modified:
>>> incubator/harmony/enhanced/classlib/trunk/modules/nio/build.xml
>>> URL:
>>> http://svn.apache.org/viewvc/incubator/harmony/enhanced/classlib/trunk/modules/nio/build.xml?rev=417385&r1=417384&r2=417385&view=diff
>>>
>>> ==============================================================================
>>>
>>> --- incubator/harmony/enhanced/classlib/trunk/modules/nio/build.xml
>>> (original)
>>> +++ incubator/harmony/enhanced/classlib/trunk/modules/nio/build.xml
>>> Tue Jun 27 02:28:15 2006
>>> @@ -39,12 +39,39 @@
>>>  
>>>      <target name="test" depends="build, compile.tests, run.tests" />
>>>  
>>> +     <!-- Build natives.-->
>>> +     <target name="build.native">
>>> +     <exec failonerror="true" +              
>>> executable="${make.command}" +              
>>> dir="${hy.nio.src.main.native}/nio/${hy.os}">
>>> +             <env key="HY_HDK" value="${hy.hdk}" />
>>> +         </exec>
>>> + +     <!-- Copy the built shared libs over to the jre/bin dir -->
>>> +     <copy todir="${hy.jdk}/jre/bin" overwrite="yes">
>>> +             <fileset dir="${hy.nio.src.main.native}/nio">
>>> +                 <patternset includes="*${shlib.suffix}*" />
>>> +             </fileset>
>>> +         </copy>
>>> +     </target>
>>> +
>>>      <target name="clean">
>>>          <delete includeemptydirs="true" failonerror="false">
>>>              <fileset refid="classes" />
>>>              <fileset dir="${hy.nio.bin.test}" />
>>>          </delete>
>>>      </target>
>>> +
>>> +     <!-- Clean natives. -->
>>> +     <target name="clean.native">
>>> +     <exec failonerror="true" +              
>>> executable="${make.command}" +              
>>> dir="${hy.nio.src.main.native}/nio/${hy.os}">
>>> +             <env key="HY_HDK" value="${hy.hdk}" />
>>> +         <arg line="clean" />
>>> +         </exec>
>>> +     </target>
>>> +
>>>  
>>>      <target name="compile.java">
>>>          <echo message="Compiling NIO classes" />
>>>
>>> Modified:
>>> incubator/harmony/enhanced/classlib/trunk/modules/nio/make/hyproperties.xml
>>>
>>> URL:
>>> http://svn.apache.org/viewvc/incubator/harmony/enhanced/classlib/trunk/modules/nio/make/hyproperties.xml?rev=417385&r1=417384&r2=417385&view=diff
>>>
>>> ==============================================================================
>>>
>>> ---
>>> incubator/harmony/enhanced/classlib/trunk/modules/nio/make/hyproperties.xml
>>> (original)
>>> +++
>>> incubator/harmony/enhanced/classlib/trunk/modules/nio/make/hyproperties.xml
>>> Tue Jun 27 02:28:15 2006
>>> @@ -21,6 +21,7 @@
>>>           <main>
>>>              <java location="src/main/java" />
>>>              <resources location="src/main/resources" />
>>> +            <native location="src/main/native" />
>>>           </main>
>>>           <test>
>>>              <java location="src/test/java" />
>>>
>>> Added:
>>> incubator/harmony/enhanced/classlib/trunk/modules/nio/src/main/java/org/apache/harmony/nio/AddressUtil.java
>>>
>>> URL:
>>> http://svn.apache.org/viewvc/incubator/harmony/enhanced/classlib/trunk/modules/nio/src/main/java/org/apache/harmony/nio/AddressUtil.java?rev=417385&view=auto
>>>
>>> ==============================================================================
>>>
>>> ---
>>> incubator/harmony/enhanced/classlib/trunk/modules/nio/src/main/java/org/apache/harmony/nio/AddressUtil.java
>>> (added)
>>> +++
>>> incubator/harmony/enhanced/classlib/trunk/modules/nio/src/main/java/org/apache/harmony/nio/AddressUtil.java
>>> Tue Jun 27 02:28:15 2006
>>> @@ -0,0 +1,68 @@
>>> +/* Copyright 2006 The Apache Software Foundation or its licensors,
>>> as applicable
>>> + * + * 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.
>>> + */
>>> +
>>> +package org.apache.harmony.nio;
>>> +
>>> +import java.io.FileDescriptor;
>>> +import java.nio.Buffer;
>>> +import java.nio.channels.Channel;
>>> +
>>> +import org.apache.harmony.luni.platform.FileDescriptorHandler;
>>> +import org.apache.harmony.nio.internal.DirectBuffer;
>>> +import org.apache.harmony.nio.internal.FileChannelImpl;
>>> +
>>> +public class AddressUtil {
>>> +
>>> +    /**
>>> +     * Gets the address of a direct buffer.
>>> +     * +     * @param buf
>>> +     *            the direct buffer whose address shall be return
>>> +     * @return the address of the buffer given
>>> +     */
>>> +    public static long getDirectBufferAddress(Buffer buf) {
>>> +        if (!(buf instanceof DirectBuffer)) {
>>> +            return 0;
>>> +        }
>>> +        return ((DirectBuffer) buf).getBaseAddress().toLong();
>>> +    }
>>> +    +    /**
>>> +     * Gets the address of native resource held by the given
>>> channel, if has any.
>>> +     * +     * For network related channel, including SocketChannel,
>>> ServerSocketChannel +     * and DatagramChannel, this method returns
>>> a int of Socket handler in Linux +     * while returns a SOCKET
>>> (UINT_PTR) in windows.
>>> +     * +     * For 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 long 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 long getFDAddress(FileDescriptor fd);
>>> +}
>>> \ No newline at end of file
>>>
>>> Propchange:
>>> incubator/harmony/enhanced/classlib/trunk/modules/nio/src/main/java/org/apache/harmony/nio/AddressUtil.java
>>>
>>> ------------------------------------------------------------------------------
>>>
>>>     svn:eol-style = native
>>>
>>> Modified:
>>> incubator/harmony/enhanced/classlib/trunk/modules/nio/src/main/java/org/apache/harmony/nio/internal/FileChannelImpl.java
>>>
>>> URL:
>>> http://svn.apache.org/viewvc/incubator/harmony/enhanced/classlib/trunk/modules/nio/src/main/java/org/apache/harmony/nio/internal/FileChannelImpl.java?rev=417385&r1=417384&r2=417385&view=diff
>>>
>>> ==============================================================================
>>>
>>> ---
>>> incubator/harmony/enhanced/classlib/trunk/modules/nio/src/main/java/org/apache/harmony/nio/internal/FileChannelImpl.java
>>> (original)
>>> +++
>>> incubator/harmony/enhanced/classlib/trunk/modules/nio/src/main/java/org/apache/harmony/nio/internal/FileChannelImpl.java
>>> Tue Jun 27 02:28:15 2006
>>> @@ -596,4 +596,8 @@
>>>          }
>>>          return bytesWritten;
>>>      }
>>> +    +    public long getHandle(){
>>> +        return handle;
>>> +    }
>>>  }
>>>
>>> Added:
>>> incubator/harmony/enhanced/classlib/trunk/modules/nio/src/main/native/nio/linux/libhynio.exp
>>>
>>> URL:
>>> http://svn.apache.org/viewvc/incubator/harmony/enhanced/classlib/trunk/modules/nio/src/main/native/nio/linux/libhynio.exp?rev=417385&view=auto
>>>
>>> ==============================================================================
>>>
>>> ---
>>> incubator/harmony/enhanced/classlib/trunk/modules/nio/src/main/native/nio/linux/libhynio.exp
>>> (added)
>>> +++
>>> incubator/harmony/enhanced/classlib/trunk/modules/nio/src/main/native/nio/linux/libhynio.exp
>>> Tue Jun 27 02:28:15 2006
>>> @@ -0,0 +1,8 @@
>>> +HYNIO_0.1 {
>>> +    global :
>>> +        NewDirectByteBuffer;
>>> +        GetDirectBufferAddress;
>>> +        GetDirectBufferCapacity;
>>> +        Java_org_apache_harmony_nio_AddressUtil_getFDAddress;
>>> +    local : *;
>>> +};
>>>
>>> Added:
>>> incubator/harmony/enhanced/classlib/trunk/modules/nio/src/main/native/nio/linux/makefile
>>>
>>> URL:
>>> http://svn.apache.org/viewvc/incubator/harmony/enhanced/classlib/trunk/modules/nio/src/main/native/nio/linux/makefile?rev=417385&view=auto
>>>
>>> ==============================================================================
>>>
>>> ---
>>> incubator/harmony/enhanced/classlib/trunk/modules/nio/src/main/native/nio/linux/makefile
>>> (added)
>>> +++
>>> incubator/harmony/enhanced/classlib/trunk/modules/nio/src/main/native/nio/linux/makefile
>>> Tue Jun 27 02:28:15 2006
>>> @@ -0,0 +1,32 @@
>>> +# Copyright 2006 The Apache Software Foundation or its licensors, as
>>> applicable
>>> +# +# 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.
>>> +
>>> +#
>>> +# Makefile for module 'nio'
>>> +#
>>> +
>>> +include $(HY_HDK)/build/make/makefile.include
>>> +
>>> +CFLAGS += -fpic -I$(SHARED)common -I$(SHARED)fdlibm
>>> +
>>> +BUILDFILES = \
>>> +    ../shared/DirectBufferUtil.o ../shared/AddressUtil.o +
>>> +MDLLIBFILES = \
>>> +    $(LIBPATH)libhycommon.a $(LIBPATH)libhyzip.a \
>>> +    $(LIBPATH)libhypool.a $(LIBPATH)libhyfdlibm.a
>>> +
>>> +DLLNAME = ../libhynio.so
>>> +
>>> +include $(HY_HDK)/build/make/rules.mk
>>>
>>> Propchange:
>>> incubator/harmony/enhanced/classlib/trunk/modules/nio/src/main/native/nio/shared/
>>>
>>> ------------------------------------------------------------------------------
>>>
>>> --- svn:ignore (added)
>>> +++ svn:ignore Tue Jun 27 02:28:15 2006
>>> @@ -0,0 +1 @@
>>> +*.obj
>>>
>>> Added:
>>> incubator/harmony/enhanced/classlib/trunk/modules/nio/src/main/native/nio/shared/AddressUtil.c
>>>
>>> URL:
>>> http://svn.apache.org/viewvc/incubator/harmony/enhanced/classlib/trunk/modules/nio/src/main/native/nio/shared/AddressUtil.c?rev=417385&view=auto
>>>
>>> ==============================================================================
>>>
>>> ---
>>> incubator/harmony/enhanced/classlib/trunk/modules/nio/src/main/native/nio/shared/AddressUtil.c
>>> (added)
>>> +++
>>> incubator/harmony/enhanced/classlib/trunk/modules/nio/src/main/native/nio/shared/AddressUtil.c
>>> Tue Jun 27 02:28:15 2006
>>> @@ -0,0 +1,43 @@
>>> +/* Copyright 2006 The Apache Software Foundation or its licensors,
>>> as applicable
>>> + * + * 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 "hysock.h"
>>> +#include "AddressUtil.h"
>>> +
>>> +/*
>>> + * Class:     org_apache_harmony_nio_AddressUtil
>>> + * Method:    getFDAddress
>>> + * Signature: (Ljava/io/FileDescriptor;)J
>>> + */
>>> +JNIEXPORT jlong JNICALL
>>> Java_org_apache_harmony_nio_AddressUtil_getFDAddress
>>> +  (JNIEnv * env, jclass clz, jobject fd){
>>> +    jclass descriptorCLS;
>>> +    jfieldID descriptorFID;
>>> +    hysocket_t hysocketP;
>>> +    //TODO add to cache
>>> +    descriptorCLS = (*env)->FindClass (env, "java/io/FileDescriptor");
>>> +    if (NULL == descriptorCLS){
>>> +        return 0;
>>> +    }
>>> +    descriptorFID = (*env)->GetFieldID (env, descriptorCLS,
>>> "descriptor", "J");
>>> +    if (NULL == descriptorFID){
>>> +        return 0;
>>> +    }
>>> +    hysocketP = (hysocket_t) ((*env)->GetLongField (env, fd,
>>> descriptorFID));
>>> +    return SOCKET_CAST(hysocketP);
>>> +}
>>> +
>>> +
>>> +
>>>
>>> Propchange:
>>> incubator/harmony/enhanced/classlib/trunk/modules/nio/src/main/native/nio/shared/AddressUtil.c
>>>
>>> ------------------------------------------------------------------------------
>>>
>>>     svn:eol-style = native
>>>
>>> Added:
>>> incubator/harmony/enhanced/classlib/trunk/modules/nio/src/main/native/nio/shared/AddressUtil.h
>>>
>>> URL:
>>> http://svn.apache.org/viewvc/incubator/harmony/enhanced/classlib/trunk/modules/nio/src/main/native/nio/shared/AddressUtil.h?rev=417385&view=auto
>>>
>>> ==============================================================================
>>>
>>> ---
>>> incubator/harmony/enhanced/classlib/trunk/modules/nio/src/main/native/nio/shared/AddressUtil.h
>>> (added)
>>> +++
>>> incubator/harmony/enhanced/classlib/trunk/modules/nio/src/main/native/nio/shared/AddressUtil.h
>>> Tue Jun 27 02:28:15 2006
>>> @@ -0,0 +1,36 @@
>>> +/* Copyright 2006 The Apache Software Foundation or its licensors,
>>> as applicable
>>> + * + * 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.
>>> + */
>>> +
>>> +/* DO NOT EDIT THIS FILE - it is machine generated */
>>> +#include <jni.h>
>>> +/* Header for class org_apache_harmony_nio_AddressUtil */
>>> +
>>> +#ifndef _Included_org_apache_harmony_nio_AddressUtil
>>> +#define _Included_org_apache_harmony_nio_AddressUtil
>>> +#ifdef __cplusplus
>>> +extern "C" {
>>> +#endif
>>> +/*
>>> + * Class:     org_apache_harmony_nio_AddressUtil
>>> + * Method:    getFDAddress
>>> + * Signature: (Ljava/io/FileDescriptor;)J
>>> + */
>>> +JNIEXPORT jlong JNICALL
>>> Java_org_apache_harmony_nio_AddressUtil_getFDAddress
>>> +  (JNIEnv *, jclass, jobject);
>>> +
>>> +#ifdef __cplusplus
>>> +}
>>> +#endif
>>> +#endif
>>>
>>> Added:
>>> incubator/harmony/enhanced/classlib/trunk/modules/nio/src/main/native/nio/shared/DirectBufferUtil.c
>>>
>>> URL:
>>> http://svn.apache.org/viewvc/incubator/harmony/enhanced/classlib/trunk/modules/nio/src/main/native/nio/shared/DirectBufferUtil.c?rev=417385&view=auto
>>>
>>> ==============================================================================
>>>
>>> ---
>>> incubator/harmony/enhanced/classlib/trunk/modules/nio/src/main/native/nio/shared/DirectBufferUtil.c
>>> (added)
>>> +++
>>> incubator/harmony/enhanced/classlib/trunk/modules/nio/src/main/native/nio/shared/DirectBufferUtil.c
>>> Tue Jun 27 02:28:15 2006
>>> @@ -0,0 +1,119 @@
>>> +/* Copyright 2006 The Apache Software Foundation or its licensors,
>>> as applicable
>>> + * + * 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 <jni.h>
>>> +
>>> +/*
>>> + * For JNI
>>> + * Method:    NewDirectByteBuffer
>>> + * Signature: (JJ)Ljava/nio/ByteBuffer;
>>> + */
>>> +jobject NewDirectByteBuffer
>>> +  (JNIEnv * env, jlong address, jlong capacity){
>>> +      jmethodID newBufferMethod;
>>> +      jclass directBufferClass;
>>> +      jclass platformaddressClass;
>>> +      jobject platformaddress;
>>> +      jmethodID onMethod;
>>> +          directBufferClass = (*env)->FindClass (env,
>>> "java/nio/ReadWriteDirectByteBuffer");
>>> +      if (!directBufferClass){
>>> +                return NULL;
>>> +      }
>>> +      newBufferMethod = (*env)->GetMethodID (env, directBufferClass,
>>> "<init>",
>>> +            
>>> "(Lorg/apache/harmony/luni/platform/PlatformAddress;II)V");
>>> +      if (!newBufferMethod){
>>> +                return NULL;
>>> +      }
>>> +      platformaddressClass = (*env)->FindClass (env,
>>> "org/apache/harmony/luni/platform/PlatformAddress");
>>> +      if (!platformaddressClass){
>>> +                return NULL;
>>> +      }
>>> +      onMethod = (*env)->GetStaticMethodID (env,
>>> platformaddressClass, "on",
>>> +             "(J)Lorg/apache/harmony/luni/platform/PlatformAddress;");
>>> +      if (!onMethod){
>>> +                return NULL;
>>> +      }
>>> +      platformaddress = (*env)->CallStaticObjectMethod(env,
>>> platformaddressClass, onMethod, address);
>>> +      return (*env)->NewObject(env, directBufferClass,
>>> newBufferMethod, platformaddress, capacity, 0);
>>> +  }
>>> +
>>> +/*
>>> + * For JNI
>>> + * Method:    GetDirectBufferAddress
>>> + * Signature: (Ljava/nio/Buffer;)J
>>> + */
>>> +jlong GetDirectBufferAddress
>>> +  (JNIEnv * env, jobject buf){
>>> +      jmethodID tempMethod;
>>> +      jclass tempClass;
>>> +      jobject platformAddr;
>>> +      jclass platformAddrClass;
>>> +      jmethodID toLongMethod;
>>> +      +          tempClass = (*env)->FindClass (env,
>>> "org/apache/harmony/nio/internal/DirectBuffer");
>>> +      if (!tempClass){
>>> +                return 0;
>>> +      }
>>> +      if (JNI_FALSE == (*env)->IsInstanceOf(env, buf, tempClass)){
>>> +          return 0;
>>> +      }      +      tempMethod = (*env)->GetMethodID (env,
>>> tempClass, "getBaseAddress",
>>> +            
>>> "()Lorg/apache/harmony/luni/platform/PlatformAddress;");           
>>> +      if (!tempMethod){
>>> +                return 0;
>>> +      }      +      platformAddr = (*env)->CallObjectMethod(env,
>>> buf, tempMethod);
>>> +      platformAddrClass = (*env)->FindClass (env,
>>> "org/apache/harmony/luni/platform/PlatformAddress");
>>> +      if (!platformAddrClass){
>>> +                return 0;
>>> +      }
>>> +      toLongMethod = (*env)->GetMethodID (env, platformAddrClass,
>>> "toLong",
>>> +             "()J");
>>> +      if (!toLongMethod){
>>> +                return 0;
>>> +      }
>>> +      return  (*env)->CallLongMethod(env, platformAddr,
>>> toLongMethod);      +  }
>>> +
>>> +/*
>>> + * For JNI
>>> + * Method:    GetDirectBufferCapacity
>>> + * Signature: (Ljava/nio/Buffer;)J
>>> + */
>>> +jlong GetDirectBufferCapacity
>>> +  (JNIEnv * env, jobject buf){
>>> +      jfieldID fieldCapacity;
>>> +      jclass directBufferClass;
>>> +      jclass bufferClass;
>>> +          directBufferClass = (*env)->FindClass (env,
>>> "org/apache/harmony/nio/internal/DirectBuffer");
>>> +      if (!directBufferClass){
>>> +                return -1;
>>> +      }
>>> +      if (JNI_FALSE == (*env)->IsInstanceOf(env, buf,
>>> directBufferClass)){
>>> +          return -1;
>>> +      }
>>> +      bufferClass = (*env)->FindClass (env, "java/nio/Buffer");
>>> +      if (!bufferClass){
>>> +                return -1;
>>> +      }
>>> +      fieldCapacity = (*env)->GetFieldID (env, bufferClass, "capacity",
>>> +             "I");
>>> +      if (!fieldCapacity){
>>> +                return -1;
>>> +      }
>>> +      return (*env)->GetIntField(env, buf, fieldCapacity);
>>> +  }
>>> +
>>> +
>>>
>>> Propchange:
>>> incubator/harmony/enhanced/classlib/trunk/modules/nio/src/main/native/nio/shared/DirectBufferUtil.c
>>>
>>> ------------------------------------------------------------------------------
>>>
>>>     svn:eol-style = native
>>>
>>> Propchange:
>>> incubator/harmony/enhanced/classlib/trunk/modules/nio/src/main/native/nio/windows/
>>>
>>> ------------------------------------------------------------------------------
>>>
>>> --- svn:ignore (added)
>>> +++ svn:ignore Tue Jun 27 02:28:15 2006
>>> @@ -0,0 +1,2 @@
>>> +*.RES
>>> +*.pdb
>>>
>>> Added:
>>> incubator/harmony/enhanced/classlib/trunk/modules/nio/src/main/native/nio/windows/hynio.def
>>>
>>> URL:
>>> http://svn.apache.org/viewvc/incubator/harmony/enhanced/classlib/trunk/modules/nio/src/main/native/nio/windows/hynio.def?rev=417385&view=auto
>>>
>>> ==============================================================================
>>>
>>> ---
>>> incubator/harmony/enhanced/classlib/trunk/modules/nio/src/main/native/nio/windows/hynio.def
>>> (added)
>>> +++
>>> incubator/harmony/enhanced/classlib/trunk/modules/nio/src/main/native/nio/windows/hynio.def
>>> Tue Jun 27 02:28:15 2006
>>> @@ -0,0 +1,12 @@
>>> +LIBRARY    HYNIO
>>> +
>>> +SECTIONS
>>> +    .data    READ WRITE
>>> +    .text    EXECUTE READ
>>> +
>>> +EXPORTS
>>> +    Java_org_apache_harmony_nio_AddressUtil_getFDAddress
>>> +    NewDirectByteBuffer
>>> +    GetDirectBufferAddress
>>> +    GetDirectBufferCapacity
>>> +
>>>
>>> Added:
>>> incubator/harmony/enhanced/classlib/trunk/modules/nio/src/main/native/nio/windows/hynio.rc
>>>
>>> URL:
>>> http://svn.apache.org/viewvc/incubator/harmony/enhanced/classlib/trunk/modules/nio/src/main/native/nio/windows/hynio.rc?rev=417385&view=auto
>>>
>>> ==============================================================================
>>>
>>> ---
>>> incubator/harmony/enhanced/classlib/trunk/modules/nio/src/main/native/nio/windows/hynio.rc
>>> (added)
>>> +++
>>> incubator/harmony/enhanced/classlib/trunk/modules/nio/src/main/native/nio/windows/hynio.rc
>>> Tue Jun 27 02:28:15 2006
>>> @@ -0,0 +1,47 @@
>>> +;
>>> +; Copyright 2006 The Apache Software Foundation or its licensors, as
>>> applicable
>>> +; +; 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 <windows.h>
>>> +#include <winver.h>
>>> +
>>> +VS_VERSION_INFO VERSIONINFO
>>> + FILEVERSION 0,1,0,0
>>> + PRODUCTVERSION 0,1,0,0
>>> + FILEFLAGSMASK 0x3fL
>>> + FILEFLAGS 0x0L
>>> + FILEOS VOS_NT_WINDOWS32
>>> + FILETYPE VFT_DLL
>>> + FILESUBTYPE 0x0L
>>> +BEGIN
>>> +    BLOCK "StringFileInfo"
>>> +    BEGIN
>>> +        BLOCK "040904b0"
>>> +        BEGIN
>>> +            VALUE "CompanyName", "The Apache Software Foundation.\0"
>>> +            VALUE "FileDescription", "NIO native code\0"
>>> +            VALUE "FileVersion", "0.1\0"
>>> +            VALUE "InternalName", "nio\0"
>>> +            VALUE "LegalCopyright", "(c) Copyright 1991, 2005 The
>>> Apache Software Foundation or its licensors, as applicable.\0"
>>> +            VALUE "OriginalFilename", "hynio.dll\0"
>>> +            VALUE "ProductName", "Apache Harmony\0"
>>> +            VALUE "ProductVersion", "0.1\0"
>>> +        END
>>> +    END
>>> +    BLOCK "VarFileInfo"
>>> +    BEGIN
>>> +        VALUE "Translation", 0x0409, 1200
>>> +    END
>>> +END
>>>
>>> Added:
>>> incubator/harmony/enhanced/classlib/trunk/modules/nio/src/main/native/nio/windows/makefile
>>>
>>> URL:
>>> http://svn.apache.org/viewvc/incubator/harmony/enhanced/classlib/trunk/modules/nio/src/main/native/nio/windows/makefile?rev=417385&view=auto
>>>
>>> ==============================================================================
>>>
>>> ---
>>> incubator/harmony/enhanced/classlib/trunk/modules/nio/src/main/native/nio/windows/makefile
>>> (added)
>>> +++
>>> incubator/harmony/enhanced/classlib/trunk/modules/nio/src/main/native/nio/windows/makefile
>>> Tue Jun 27 02:28:15 2006
>>> @@ -0,0 +1,41 @@
>>> +# Copyright 2006 The Apache Software Foundation or its licensors, as
>>> applicable
>>> +# +# 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.
>>> +
>>> +#
>>> +# Makefile for module 'nio'
>>> +#
>>> +
>>> +!include <$(HY_HDK)\build\make\defines.mak>
>>> +
>>> +SHAREDSUB=..\shared\# comment to avoid \ being treated as continuation
>>> +LIBBASE=hynio
>>> +DLLNAME=$(DLLPATH)$(LIBBASE).dll
>>> +LIBNAME=$(LIBPATH)$(LIBBASE).lib
>>> +HYCFLAGS = $(HYCFLAGS) /I$(SHAREDSUB) /I$(SHARED)common
>>> /I$(SHARED)fdlibm
>>> +HYLDFLAGS = $(HYLDFLAGS) -def:$(LIBBASE).def
>>> +
>>> +BUILDFILES = \
>>> +  $(SHAREDSUB)DirectBufferUtil.obj $(SHAREDSUB)AddressUtil.obj
>>> +VIRTFILES = hynio.res
>>> +
>>> +SYSLIBFILES = ws2_32.lib Iphlpapi.lib
>>> +
>>> +MDLLIBFILES = \
>>> +  $(LIBPATH)hycommon.lib $(LIBPATH)hysig.lib $(LIBPATH)hyzip.lib
>>> $(LIBPATH)hyzlib.lib \
>>> +  $(LIBPATH)hypool.lib $(LIBPATH)hyfdlibm.lib $(LIBPATH)hythr.lib
>>> $(LIBPATH)vmi.lib
>>> +  +DLLBASE=0x13200000
>>> +COMMENT=/comment:"nio component native code. (c) Copyright 1991,
>>> 2005 The Apache Software Foundation or its licensors, as applicable."
>>> +
>>> +!include <$(HY_HDK)\build\make\rules.mak>
>>>
>>> Added:
>>> incubator/harmony/enhanced/classlib/trunk/modules/nio/src/test/java/org/apache/harmony/tests/nio/AddressUtilTest.java
>>>
>>> URL:
>>> http://svn.apache.org/viewvc/incubator/harmony/enhanced/classlib/trunk/modules/nio/src/test/java/org/apache/harmony/tests/nio/AddressUtilTest.java?rev=417385&view=auto
>>>
>>> ==============================================================================
>>>
>>> ---
>>> incubator/harmony/enhanced/classlib/trunk/modules/nio/src/test/java/org/apache/harmony/tests/nio/AddressUtilTest.java
>>> (added)
>>> +++
>>> incubator/harmony/enhanced/classlib/trunk/modules/nio/src/test/java/org/apache/harmony/tests/nio/AddressUtilTest.java
>>> Tue Jun 27 02:28:15 2006
>>> @@ -0,0 +1,89 @@
>>> +/* Copyright 2006 The Apache Software Foundation or its licensors,
>>> as applicable
>>> + * + * 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.
>>> + */
>>> +
>>> +package org.apache.harmony.tests.nio;
>>> +
>>> +import java.io.FileInputStream;
>>> +import java.io.IOException;
>>> +import java.nio.ByteBuffer;
>>> +import java.nio.channels.Channel;
>>> +import java.nio.channels.DatagramChannel;
>>> +import java.nio.channels.FileChannel;
>>> +import java.nio.channels.ServerSocketChannel;
>>> +import java.nio.channels.SocketChannel;
>>> +
>>> +import junit.framework.TestCase;
>>> +
>>> +import org.apache.harmony.nio.AddressUtil;
>>> +
>>> +public class AddressUtilTest extends TestCase {
>>> +    +    /**
>>> +     * @tests AddressUtil#getDirectBufferAddress
>>> +     */
>>> +    public void test_getDirectBufferAddress() throws Exception {
>>> +        ByteBuffer buf = ByteBuffer.allocateDirect(10);
>>> +        assertTrue(AddressUtil.getDirectBufferAddress(buf) != 0);
>>> +    }
>>> +    +    /**
>>> +     * @tests AddressUtil#getChannelAddress
>>> +     */
>>> +    public void test_getFileChannelAddress() throws Exception {
>>> +//        FileChannel fc = new
>>> FileInputStream("src/main/java/org/apache/harmony/nio/AddressUtil.java").getChannel();
>>>
>>> +//        assertTrue(AddressUtil.getChannelAddress(fc) > 0);
>>> +    }
>>> +    +    /**
>>> +     * @tests AddressUtil#getChannelAddress
>>> +     */
>>> +    public void test_getSocketChannelAddress() throws Exception {
>>> +        SocketChannel sc = SocketChannel.open();
>>> +        assertTrue(AddressUtil.getChannelAddress(sc)>0);
>>> +    }
>>> +    +    /**
>>> +     * @tests AddressUtil#getChannelAddress
>>> +     */
>>> +    public void test_getDatagramChannelAddress() throws Exception {
>>> +        DatagramChannel dc = DatagramChannel.open();
>>> +        assertTrue(AddressUtil.getChannelAddress(dc)>0);
>>> +    }
>>> +    +    /**
>>> +     * @tests AddressUtil#getChannelAddress
>>> +     */
>>> +    public void test_getServerSocketChannelAddress() throws Exception {
>>> +        ServerSocketChannel ssc = ServerSocketChannel.open();
>>> +        assertTrue(AddressUtil.getChannelAddress(ssc)>0);
>>> +    }  +    +    /**
>>> +     * @tests AddressUtil#getChannelAddress
>>> +     */
>>> +    public void test_getNonNativeChannelAddress() throws Exception{
>>> +        Channel channel = new MockChannel();
>>> +        assertEquals(0, AddressUtil.getChannelAddress(channel));
>>> +    }
>>> +    +    private static class MockChannel implements Channel{
>>> +        public boolean isOpen() {
>>> +            return false;
>>> +        }
>>> +        public void close() throws IOException {
>>> +        }
>>> +    }
>>> +}
>>> +   Propchange:
>>> incubator/harmony/enhanced/classlib/trunk/modules/nio/src/test/java/org/apache/harmony/tests/nio/AddressUtilTest.java
>>>
>>> ------------------------------------------------------------------------------
>>>
>>>     svn:eol-style = native
>>>
>>>
>>>
>>>   
>>
>>
> 
> 
> ---------------------------------------------------------------------
> Terms of use : http://incubator.apache.org/harmony/mailing.html
> To unsubscribe, e-mail: [EMAIL PROTECTED]
> For additional commands, e-mail: [EMAIL PROTECTED]
> 
> 

-- 

Tim Ellison ([EMAIL PROTECTED])
IBM Java technology centre, UK.

---------------------------------------------------------------------
Terms of use : http://incubator.apache.org/harmony/mailing.html
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]

Reply via email to