History

Implemented internal FileDescriptor class with it's native module

Dmitry Kabak (userdima committed 13 years ago

Commit be0f4591 parent b7c872b4 files · +173 −-1Browse files

Showing the changes to java/pkg (4 of 4 files). Show all

Unified · Split

4 files
  1. java/pkg/java/io/FileDescriptor.class +0 −0
  2. java/pkg/java/io/FileDescriptor.java +86 −0
  3. java/pkg/java/io/FileDescriptor_L.b +72 −0
  4. java/pkg/java/io/FileDescriptor_L.m +16 −0
java/pkg/java/io/FileDescriptor.class+0−0

Binary file not shown.

java/pkg/java/io/FileDescriptor.java+86−0
@@ -0,0 +1,86 @@
1+/*
2+ * Copyright (c) 1994, 2011, Oracle and/or its affiliates. All rights reserved.
3+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
4+ *
5+ * This code is free software; you can redistribute it and/or modify it
6+ * under the terms of the GNU General Public License version 2 only, as
7+ * published by the Free Software Foundation. Oracle designates this
8+ * particular file as subject to the "Classpath" exception as provided
9+ * by Oracle in the LICENSE file that accompanied this code.
10+ *
11+ * This code is distributed in the hope that it will be useful, but WITHOUT
12+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
13+ * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
14+ * version 2 for more details (a copy is included in the LICENSE file that
15+ * accompanied this code).
16+ *
17+ * You should have received a copy of the GNU General Public License version
18+ * 2 along with this work; if not, write to the Free Software Foundation,
19+ * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
20+ *
21+ * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
22+ * or visit www.oracle.com if you need additional information or have any
23+ * questions.
24+ */
25+package java.io;
26+
27+//import java.io.*;
28+//import java.util.Properties;
29+//import java.util.PropertyPermission;
30+//import java.util.StringTokenizer;
31+//import java.security.AccessController;
32+//import java.security.PrivilegedAction;
33+//import java.security.AllPermission;
34+//import java.nio.channels.Channel;
35+//import java.nio.channels.spi.SelectorProvider;
36+//import sun.nio.ch.Interruptible;
37+//import sun.reflect.Reflection;
38+//import sun.security.util.SecurityConstants;
39+//import sun.reflect.annotation.AnnotationType;
40+
41+/**
42+ * The <code>FileDescriptor</code> class is the internal to Inferno's jvm
43+ * class representing internal file descriptor.
44+ *
45+ * Mainly provides in, out and err file descriptors.
46+ *
47+ * @author kabbi
48+ */
49+public final class FileDescriptor {
50+
51+ public static FileDescriptor in = new FileDescriptor();
52+
53+ public static FileDescriptor out = new FileDescriptor();
54+
55+ public static FileDescriptor err = new FileDescriptor();
56+
57+ static {
58+ in = initSystemFD(in, 0);
59+ out = initSystemFD(out, 1);
60+ err = initSystemFD(err, 2);
61+ }
62+
63+ /** Don't let anyone instantiate this class */
64+ private FileDescriptor() {
65+ }
66+
67+ /**
68+ * Init some FileDescriptor object with system numeric fd number
69+ *
70+ * @param fd FileDescriptor object
71+ * @param number system fd index
72+ */
73+ public final static native FileDescriptor initSystemFD(FileDescriptor fd, int number);
74+
75+ /**
76+ * Check if this file descriptor is valid.
77+ */
78+ public final native boolean valid();
79+
80+ /*
81+ * Flush all the buffers and wait till every operation is completed.
82+ * Means nothing in Inferno, as all the operations are synchronous.
83+ */
84+ public final native void sync();
85+
86+}
java/pkg/java/io/FileDescriptor_L.b+72−0
@@ -0,0 +1,72 @@
1+implement FileDescriptor_L;
2+
3+# javal v1.3 generated file: edit with care
4+
5+include "jni.m";
6+ jni : JNI;
7+ ClassModule,
8+ JString,
9+ JArray,
10+ JArrayI,
11+ JArrayC,
12+ JArrayB,
13+ JArrayS,
14+ JArrayJ,
15+ JArrayF,
16+ JArrayD,
17+ JArrayZ,
18+ JArrayJObject,
19+ JArrayJClass,
20+ JArrayJString,
21+ JClass,
22+ JThread,
23+ JObject : import jni;
24+
25+#>> extra pre includes here
26+ sys : import jni;
27+ FALSE : import jni;
28+ TRUE : import jni;
29+#<<
30+
31+include "FileDescriptor_L.m";
32+
33+#>> extra post includes here
34+#<<
35+
36+init( jni_p : JNI )
37+{
38+ # save java native inteface mod instance
39+ jni = jni_p;
40+ #>>extra initialization here
41+ sys = jni->sys;
42+ #<<
43+}
44+
45+valid_Z( this : ref FileDescriptor_obj) : int
46+{#>>
47+ if (this.fd != nil)
48+ return TRUE;
49+ else
50+ return FALSE;
51+}#<<
52+
53+sync_V( this : ref FileDescriptor_obj)
54+{#>>
55+ # this routine has no meaning in the limbo world because there is
56+ # nothing to sync or flush. It may have meaning to each underlying
57+ # file system (device driver) but at the present there is no devtab
58+ # interface to the device driver for sync. As such, this routine is
59+ # a noop.
60+ jni->ThrowException("java.io.SyncFailedException", "sync not gauranteed");
61+}#<<
62+
63+initSystemFD_rFileDescriptor_I_rFileDescriptor( p0 : ref FileDescriptor_obj,p1 : int) : ref FileDescriptor_obj
64+{#>>
65+ p0.fd = sys->fildes(p1);
66+ return (p0);
67+}#<<
68+
69+
70+
71+
72+
java/pkg/java/io/FileDescriptor_L.m+16−0
@@ -0,0 +1,16 @@
1+# javal v1.3 generated file: edit with care
2+
3+FileDescriptor_L : module
4+{
5+ FileDescriptor_obj : adt
6+ {
7+ cl_mod : ClassModule;
8+ fd : ref Sys->FD;
9+ };
10+
11+ init : fn( jni_p : JNI );
12+ valid_Z : fn( this : ref FileDescriptor_obj) : int;
13+ sync_V : fn( this : ref FileDescriptor_obj);
14+ initSystemFD_rFileDescriptor_I_rFileDescriptor : fn( p0 : ref FileDescriptor_obj,p1 : int) : ref FileDescriptor_obj;
15+
16+};