|
From: <ls...@us...> - 2009-04-01 18:57:35
|
Revision: 5209
http://jnode.svn.sourceforge.net/jnode/?rev=5209&view=rev
Author: lsantha
Date: 2009-04-01 18:57:30 +0000 (Wed, 01 Apr 2009)
Log Message:
-----------
Separating jnode specific code from classlib.
Modified Paths:
--------------
trunk/all/conf/openjdk-annotations.properties
trunk/core/src/core/org/jnode/vm/MemoryResourceImpl.java
Added Paths:
-----------
trunk/core/src/classpath/java/java/nio/VMDirectByteBuffer.java
trunk/core/src/classpath/java/java/nio/channels/VMChannels.java
trunk/core/src/classpath/vm/java/nio/MemoryRawData.java
trunk/core/src/classpath/vm/java/nio/NativeVMDirectByteBuffer.java
trunk/core/src/classpath/vm/java/nio/channels/NativeVMChannels.java
Removed Paths:
-------------
trunk/core/src/classpath/vm/java/nio/VMDirectByteBuffer.java
trunk/core/src/classpath/vm/java/nio/channels/VMChannels.java
Modified: trunk/all/conf/openjdk-annotations.properties
===================================================================
--- trunk/all/conf/openjdk-annotations.properties 2009-04-01 15:03:30 UTC (rev 5208)
+++ trunk/all/conf/openjdk-annotations.properties 2009-04-01 18:57:30 UTC (rev 5209)
@@ -18,6 +18,7 @@
java/net/ServerSocket.class=SharedStatics
java/net/Socket.class=SharedStatics
java/net/URLConnection.class=SharedStatics
+java/nio/VMDirectByteBuffer.class=MagicPermission
java/nio/charset/Charset.class=SharedStatics
java/nio/charset/CoderResult.class=SharedStatics
# TODO Policy might need to be isolated
Copied: trunk/core/src/classpath/java/java/nio/VMDirectByteBuffer.java (from rev 5208, trunk/core/src/classpath/vm/java/nio/VMDirectByteBuffer.java)
===================================================================
--- trunk/core/src/classpath/java/java/nio/VMDirectByteBuffer.java (rev 0)
+++ trunk/core/src/classpath/java/java/nio/VMDirectByteBuffer.java 2009-04-01 18:57:30 UTC (rev 5209)
@@ -0,0 +1,42 @@
+/*
+ * $Id$
+ *
+ * Copyright (C) 2003-2009 JNode.org
+ *
+ * This library is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as published
+ * by the Free Software Foundation; either version 2.1 of the License, or
+ * (at your option) any later version.
+ *
+ * This library 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 Lesser General Public
+ * License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * along with this library; If not, write to the Free Software Foundation, Inc.,
+ * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
+ */
+
+package java.nio;
+
+import gnu.classpath.Pointer;
+
+public final class VMDirectByteBuffer {
+
+ native static Pointer allocate(int capacity);
+
+ native static void free(Pointer address);
+
+ native static byte get(Pointer address, int index);
+
+ native static void get(Pointer address, int index, byte[] dst, int offset, int length);
+
+ native static void put(Pointer address, int index, byte value);
+
+ native static void put(Pointer address, int index, byte[] src, int offset, int length);
+
+ native static Pointer adjustAddress(Pointer address, int offset);
+
+ native static void shiftDown(Pointer address, int dst_offset, int src_offset, int count);
+}
Property changes on: trunk/core/src/classpath/java/java/nio/VMDirectByteBuffer.java
___________________________________________________________________
Added: svn:keywords
+ Author Date Id Revision
Added: svn:eol-style
+ native
Copied: trunk/core/src/classpath/java/java/nio/channels/VMChannels.java (from rev 5208, trunk/core/src/classpath/vm/java/nio/channels/VMChannels.java)
===================================================================
--- trunk/core/src/classpath/java/java/nio/channels/VMChannels.java (rev 0)
+++ trunk/core/src/classpath/java/java/nio/channels/VMChannels.java 2009-04-01 18:57:30 UTC (rev 5209)
@@ -0,0 +1,43 @@
+/*
+ * $Id$
+ *
+ * Copyright (C) 2003-2009 JNode.org
+ *
+ * This library is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as published
+ * by the Free Software Foundation; either version 2.1 of the License, or
+ * (at your option) any later version.
+ *
+ * This library 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 Lesser General Public
+ * License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * along with this library; If not, write to the Free Software Foundation, Inc.,
+ * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
+ */
+
+package java.nio.channels;
+
+import java.io.InputStream;
+import java.io.OutputStream;
+
+final class VMChannels {
+ /**
+ * This class isn't intended to be instantiated.
+ */
+ private VMChannels() {
+ // Do nothing here.
+ }
+
+ /**
+ * Constructs a stream that reads bytes from the given channel.
+ */
+ native static InputStream newInputStream(ReadableByteChannel ch);
+
+ /**
+ * Constructs a stream that writes bytes to the given channel.
+ */
+ native static OutputStream newOutputStream(WritableByteChannel ch);
+}
Property changes on: trunk/core/src/classpath/java/java/nio/channels/VMChannels.java
___________________________________________________________________
Added: svn:keywords
+ Author Date Id Revision
Added: svn:eol-style
+ native
Added: trunk/core/src/classpath/vm/java/nio/MemoryRawData.java
===================================================================
--- trunk/core/src/classpath/vm/java/nio/MemoryRawData.java (rev 0)
+++ trunk/core/src/classpath/vm/java/nio/MemoryRawData.java 2009-04-01 18:57:30 UTC (rev 5209)
@@ -0,0 +1,54 @@
+package java.nio;
+
+import gnu.classpath.Pointer;
+import org.jnode.system.MemoryResource;
+import org.jnode.system.ResourceManager;
+import org.jnode.system.ResourceOwner;
+import org.jnode.system.SimpleResourceOwner;
+import org.jnode.system.ResourceNotFreeException;
+import org.jnode.naming.InitialNaming;
+import org.vmmagic.unboxed.Address;
+import javax.naming.NameNotFoundException;
+
+/**
+ *
+ */
+public class MemoryRawData extends Pointer {
+
+ final MemoryResource resource;
+ final Address address;
+
+ MemoryRawData(int size) {
+ try {
+ final ResourceManager rm = InitialNaming.lookup(ResourceManager.NAME);
+ final ResourceOwner owner = new SimpleResourceOwner("java.nio");
+ this.resource = rm.claimMemoryResource(owner, null, size,
+ ResourceManager.MEMMODE_NORMAL);
+ this.address = resource.getAddress();
+ } catch (NameNotFoundException ex) {
+ throw new Error("Cannot find ResourceManager", ex);
+ } catch (ResourceNotFreeException ex) {
+ throw new Error("Cannot allocate direct memory", ex);
+ }
+ }
+
+ MemoryRawData(MemoryResource resource) {
+ this.resource = resource;
+ this.address = resource.getAddress();
+ }
+
+ /**
+ * Wrap a bytebuffer around the given memory resource.
+ *
+ * @param resource a memory resource to wrap
+ * @return the new ByteBuffer
+ */
+ public static ByteBuffer wrap(MemoryResource resource) {
+ final Object owner = resource.getOwner();
+ final Pointer address = new MemoryRawData(resource);
+ final int size = resource.getSize().toInt();
+ final ByteBuffer result = new DirectByteBufferImpl.ReadWrite(owner, address, size, size, 0);
+ result.mark();
+ return result;
+ }
+}
Added: trunk/core/src/classpath/vm/java/nio/NativeVMDirectByteBuffer.java
===================================================================
--- trunk/core/src/classpath/vm/java/nio/NativeVMDirectByteBuffer.java (rev 0)
+++ trunk/core/src/classpath/vm/java/nio/NativeVMDirectByteBuffer.java 2009-04-01 18:57:30 UTC (rev 5209)
@@ -0,0 +1,51 @@
+package java.nio;
+
+import gnu.classpath.Pointer;
+import org.jnode.system.MemoryResource;
+import org.jnode.system.ResourceNotFreeException;
+import org.vmmagic.unboxed.Offset;
+import org.vmmagic.unboxed.Extent;
+
+/**
+ *
+ */
+public class NativeVMDirectByteBuffer {
+ static Pointer allocate(int capacity) {
+ return new MemoryRawData(capacity);
+ }
+
+ static void free(Pointer address) {
+ ((MemoryRawData) address).resource.release();
+ }
+
+ static byte get(Pointer address, int index) {
+ final MemoryRawData mrd = (MemoryRawData) address;
+ return mrd.address.loadByte(Offset.fromIntZeroExtend(index));
+ }
+
+ static void get(Pointer address, int index, byte[] dst, int offset, int length) {
+ ((MemoryRawData) address).resource.getBytes(index, dst, offset, length);
+ }
+
+ static void put(Pointer address, int index, byte value) {
+ ((MemoryRawData) address).resource.setByte(index, value);
+ }
+
+ static void put(Pointer address, int index, byte[] src, int offset, int length) {
+ ((MemoryRawData) address).resource.setBytes(src, offset, index, length);
+ }
+
+ static Pointer adjustAddress(Pointer address, int offset) {
+ final MemoryResource res = ((MemoryRawData) address).resource;
+ final Extent size = res.getSize().sub(offset);
+ try {
+ return new MemoryRawData(res.claimChildResource(Offset.fromIntZeroExtend(offset), size, true));
+ } catch (ResourceNotFreeException ex) {
+ throw new Error("Cannot adjustAddress", ex);
+ }
+ }
+
+ static void shiftDown(Pointer address, int dst_offset, int src_offset, int count) {
+ ((MemoryRawData) address).resource.copy(src_offset, dst_offset, count);
+ }
+}
Deleted: trunk/core/src/classpath/vm/java/nio/VMDirectByteBuffer.java
===================================================================
--- trunk/core/src/classpath/vm/java/nio/VMDirectByteBuffer.java 2009-04-01 15:03:30 UTC (rev 5208)
+++ trunk/core/src/classpath/vm/java/nio/VMDirectByteBuffer.java 2009-04-01 18:57:30 UTC (rev 5209)
@@ -1,122 +0,0 @@
-/*
- * $Id$
- *
- * Copyright (C) 2003-2009 JNode.org
- *
- * This library is free software; you can redistribute it and/or modify it
- * under the terms of the GNU Lesser General Public License as published
- * by the Free Software Foundation; either version 2.1 of the License, or
- * (at your option) any later version.
- *
- * This library 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 Lesser General Public
- * License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public License
- * along with this library; If not, write to the Free Software Foundation, Inc.,
- * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
- */
-
-package java.nio;
-
-import gnu.classpath.Pointer;
-
-import javax.naming.NameNotFoundException;
-
-import org.jnode.naming.InitialNaming;
-import org.jnode.system.MemoryResource;
-import org.jnode.system.ResourceManager;
-import org.jnode.system.ResourceNotFreeException;
-import org.jnode.system.ResourceOwner;
-import org.jnode.system.SimpleResourceOwner;
-import org.jnode.vm.annotation.MagicPermission;
-import org.vmmagic.unboxed.Address;
-import org.vmmagic.unboxed.Extent;
-import org.vmmagic.unboxed.Offset;
-
-@MagicPermission
-public final class VMDirectByteBuffer {
-
- static Pointer allocate(int capacity) {
- return new MemoryRawData(capacity);
- }
-
- /**
- * Wrap a bytebuffer around the given memory resource.
- * @param resource
- * @return
- */
- public static ByteBuffer wrap(MemoryResource resource) {
- final Object owner = resource.getOwner();
- final Pointer address = new MemoryRawData(resource);
- final int size = resource.getSize().toInt();
- final ByteBuffer result = new DirectByteBufferImpl.ReadWrite(owner, address, size, size, 0);
- result.mark();
- return result;
- }
-
- static void free(Pointer address) {
- ((MemoryRawData)address).resource.release();
- }
-
- static byte get(Pointer address, int index) {
- final MemoryRawData mrd = (MemoryRawData)address;
- final byte value = mrd.address.loadByte(Offset.fromIntZeroExtend(index));
- return value;
- }
-
- static void get(Pointer address, int index, byte[] dst, int offset,
- int length) {
- ((MemoryRawData)address).resource.getBytes(index, dst, offset, length);
- }
-
- static void put(Pointer address, int index, byte value) {
- ((MemoryRawData)address).resource.setByte(index, value);
- }
-
- static void put(Pointer address, int index, byte[] src, int offset, int length)
- {
- ((MemoryRawData)address).resource.setBytes(src, offset, index, length);
- }
-
- static Pointer adjustAddress(Pointer address, int offset) {
- final MemoryResource res = ((MemoryRawData)address).resource;
- final Extent size = res.getSize().sub(offset);
- try {
- return new MemoryRawData(res.claimChildResource(Offset.fromIntZeroExtend(offset), size, true));
- } catch (ResourceNotFreeException ex) {
- throw new Error("Cannot adjustAddress", ex);
- }
- }
-
- static void shiftDown(Pointer address, int dst_offset, int src_offset,
- int count) {
- ((MemoryRawData)address).resource.copy(src_offset, dst_offset, count);
- }
-
- private static class MemoryRawData extends Pointer {
-
- final MemoryResource resource;
- final Address address;
-
- public MemoryRawData(int size) {
- try {
- final ResourceManager rm = InitialNaming.lookup(ResourceManager.NAME);
- final ResourceOwner owner = new SimpleResourceOwner("java.nio");
- this.resource = rm.claimMemoryResource(owner, null, size,
- ResourceManager.MEMMODE_NORMAL);
- this.address = resource.getAddress();
- } catch (NameNotFoundException ex) {
- throw new Error("Cannot find ResourceManager", ex);
- } catch (ResourceNotFreeException ex) {
- throw new Error("Cannot allocate direct memory", ex);
- }
- }
-
- public MemoryRawData(MemoryResource resource) {
- this.resource = resource;
- this.address = resource.getAddress();
- }
- }
-}
Added: trunk/core/src/classpath/vm/java/nio/channels/NativeVMChannels.java
===================================================================
--- trunk/core/src/classpath/vm/java/nio/channels/NativeVMChannels.java (rev 0)
+++ trunk/core/src/classpath/vm/java/nio/channels/NativeVMChannels.java 2009-04-01 18:57:30 UTC (rev 5209)
@@ -0,0 +1,58 @@
+package java.nio.channels;
+
+import java.io.InputStream;
+import java.io.FileInputStream;
+import java.io.OutputStream;
+import java.io.FileOutputStream;
+import java.lang.reflect.Constructor;
+import java.lang.reflect.InvocationTargetException;
+import gnu.java.nio.channels.FileChannelImpl;
+import gnu.java.nio.ChannelInputStream;
+import gnu.java.nio.ChannelOutputStream;
+
+/**
+ *
+ */
+public class NativeVMChannels {
+ /**
+ * Constructs a stream that reads bytes from the given channel.
+ */
+ static InputStream newInputStream(ReadableByteChannel ch) {
+ if (ch instanceof FileChannelImpl)
+ return (FileInputStream) createStream(FileInputStream.class, ch);
+
+ return new ChannelInputStream(ch);
+ }
+
+ /**
+ * Constructs a stream that writes bytes to the given channel.
+ */
+ static OutputStream newOutputStream(WritableByteChannel ch) {
+ if (ch instanceof FileChannelImpl)
+ return (FileOutputStream) createStream(FileOutputStream.class, ch);
+
+ return new ChannelOutputStream(ch);
+ }
+
+ private static Object createStream(Class streamClass, Channel ch) {
+ try {
+ Class[] argTypes = new Class[1];
+ argTypes[0] = FileChannelImpl.class;
+ Constructor constructor = streamClass.getDeclaredConstructor(argTypes);
+ constructor.setAccessible(true);
+ Object[] args = new Object[1];
+ args[0] = ch;
+ return constructor.newInstance(args);
+ } catch (IllegalAccessException e) {
+ // Ignored.
+ } catch (InstantiationException e) {
+ // Ignored.
+ } catch (InvocationTargetException e) {
+ // Ignored.
+ } catch (NoSuchMethodException e) {
+ // Ignored.
+ }
+
+ return null;
+ }
+}
Deleted: trunk/core/src/classpath/vm/java/nio/channels/VMChannels.java
===================================================================
--- trunk/core/src/classpath/vm/java/nio/channels/VMChannels.java 2009-04-01 15:03:30 UTC (rev 5208)
+++ trunk/core/src/classpath/vm/java/nio/channels/VMChannels.java 2009-04-01 18:57:30 UTC (rev 5209)
@@ -1,84 +0,0 @@
-/*
- * $Id$
- *
- * Copyright (C) 2003-2009 JNode.org
- *
- * This library is free software; you can redistribute it and/or modify it
- * under the terms of the GNU Lesser General Public License as published
- * by the Free Software Foundation; either version 2.1 of the License, or
- * (at your option) any later version.
- *
- * This library 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 Lesser General Public
- * License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public License
- * along with this library; If not, write to the Free Software Foundation, Inc.,
- * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
- */
-
-package java.nio.channels;
-
-import gnu.java.nio.ChannelInputStream;
-import gnu.java.nio.ChannelOutputStream;
-import gnu.java.nio.channels.FileChannelImpl;
-
-import java.io.FileInputStream;
-import java.io.FileOutputStream;
-import java.io.InputStream;
-import java.io.OutputStream;
-import java.lang.reflect.Constructor;
-import java.lang.reflect.InvocationTargetException;
-
-final class VMChannels {
- /**
- * This class isn't intended to be instantiated.
- */
- private VMChannels() {
- // Do nothing here.
- }
-
- private static Object createStream(Class streamClass, Channel ch) {
- try {
- Class[] argTypes = new Class[1];
- argTypes[0] = FileChannelImpl.class;
- Constructor constructor = streamClass
- .getDeclaredConstructor(argTypes);
- constructor.setAccessible(true);
- Object[] args = new Object[1];
- args[0] = ch;
- return constructor.newInstance(args);
- } catch (IllegalAccessException e) {
- // Ignored.
- } catch (InstantiationException e) {
- // Ignored.
- } catch (InvocationTargetException e) {
- // Ignored.
- } catch (NoSuchMethodException e) {
- // Ignored.
- }
-
- return null;
- }
-
- /**
- * Constructs a stream that reads bytes from the given channel.
- */
- static InputStream newInputStream(ReadableByteChannel ch) {
- if (ch instanceof FileChannelImpl)
- return (FileInputStream) createStream(FileInputStream.class, ch);
-
- return new ChannelInputStream(ch);
- }
-
- /**
- * Constructs a stream that writes bytes to the given channel.
- */
- static OutputStream newOutputStream(WritableByteChannel ch) {
- if (ch instanceof FileChannelImpl)
- return (FileOutputStream) createStream(FileOutputStream.class, ch);
-
- return new ChannelOutputStream(ch);
- }
-}
Modified: trunk/core/src/core/org/jnode/vm/MemoryResourceImpl.java
===================================================================
--- trunk/core/src/core/org/jnode/vm/MemoryResourceImpl.java 2009-04-01 15:03:30 UTC (rev 5208)
+++ trunk/core/src/core/org/jnode/vm/MemoryResourceImpl.java 2009-04-01 18:57:30 UTC (rev 5209)
@@ -21,7 +21,7 @@
package org.jnode.vm;
import java.nio.ByteBuffer;
-import java.nio.VMDirectByteBuffer;
+import java.nio.MemoryRawData;
import org.jnode.system.MemoryResource;
import org.jnode.system.MultiMediaMemoryResource;
@@ -139,7 +139,7 @@
* @return a bytebuffer that has the same content as this resource
*/
public ByteBuffer asByteBuffer() {
- return VMDirectByteBuffer.wrap(this);
+ return MemoryRawData.wrap(this);
}
/**
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|