--- /dev/null
+public class File {
+ String path;
+
+ public File(String path) {
+ this.path=path;
+ }
+
+ String getPath() {
+ return path;
+ }
+
+ long length() {
+ return nativeLength(path.getBytes());
+ }
+
+ private static native long nativeLength(byte[] pathname);
+}
fd=nativeOpen(pathname.getBytes());
}
+ public FileInputStream(File path) {
+ fd=nativeOpen(path.getPath().getBytes());
+ }
+
private static native int nativeOpen(byte[] filename);
private static native int nativeRead(int fd, byte[] array, int numBytes);
private static native void nativeClose(int fd);
fd=nativeOpen(pathname.getBytes());
}
+ public FileOutputStream(File path) {
+ fd=nativeOpen(path.getPath().getBytes());
+ }
+
private static native int nativeOpen(byte[] filename);
private static native void nativeWrite(int fd, byte[] array);
private static native void nativeClose(int fd);
// private static final int DEFAULTSIZE=16;
public StringBuffer(String str) {
- value=new char[str.value+16];//16 is DEFAULTSIZE
+ value=new char[str.count+16];//16 is DEFAULTSIZE
count=str.count;
offset=0;
for(int i=0;i<count;i++)
public void checkTypeDescriptor(TypeDescriptor td) {
if (td.isPrimitive())
return; /* Done */
- if (td.isClass()) {
+ else if (td.isClass()) {
String name=td.toString();
ClassDescriptor field_cd=(ClassDescriptor)state.getClassSymbolTable().get(name);
if (field_cd==null)
case Operation.MOD:
// 5.6.2 Binary Numeric Promotion
//TODO unboxing of reference objects
- if (!ltd.isNumber()||!rtd.isNumber())
+ if (ltd.isArray()||rtd.isArray()||!ltd.isNumber()||!rtd.isNumber())
throw new Error("Error in "+on.printNode(0));
if (ltd.isDouble()||rtd.isDouble())
readSourceFile(state, ClassLibraryPrefix+"StringBuffer.java");
readSourceFile(state, ClassLibraryPrefix+"FileInputStream.java");
readSourceFile(state, ClassLibraryPrefix+"FileOutputStream.java");
+ readSourceFile(state, ClassLibraryPrefix+"File.java");
if (state.TASK) {
readSourceFile(state, ClassLibraryPrefix+"StartupObject.java");
readSourceFile(state, ClassLibraryPrefix+"Socket.java");
status=read(fd, string, toread);
return status;
}
+
+long long ___File______nativeLength_____AR_B(struct ArrayObject * ao) {
+ int length=ao->___length___;
+ char* filename= (((char *)& ao->___length___)+sizeof(int));
+ struct stat st;
+ stat(filename, &st);
+ return st.st_size;
+}
dotest virtualcalltest virtualcalltest.java
dotest IncTest IncTest.java
dotest CommandLineTest CommandLineTest.java hello hi
+dotest WriteFile WriteFile.java
+dotest ReadFile ReadFile.java
+dotest FileLength FileLength.java
--- /dev/null
+public class FileLength {
+ public static void main(String []str) {
+ String filename="testfile000";
+ File fi=new File(filename);
+ long length=fi.length();
+ String st=String.valueOf((int)length);
+ System.printString(st);
+ }
+
+}
--- /dev/null
+public class WriteFile {
+ public static void main(String []str) {
+ String filename="testfile000";
+ FileOutputStream fos=new FileOutputStream(filename);
+ String st=new String("adsasdasd");
+ fos.write(st.getBytes());
+ fos.close();
+ }
+
+}
--- /dev/null
+9
\ No newline at end of file
--- /dev/null
+adsasdasd
\ No newline at end of file