libgcj/2338: RandomAccessFile does not create the file if not found

pedro@vis.ethz.ch pedro@vis.ethz.ch
Wed Mar 21 06:06:00 GMT 2001


>Number:         2338
>Category:       libgcj
>Synopsis:       RandomAccessFile does not create the file if not found
>Confidential:   no
>Severity:       serious
>Priority:       medium
>Responsible:    unassigned
>State:          open
>Class:          sw-bug
>Submitter-Id:   net
>Arrival-Date:   Wed Mar 21 06:06:00 PST 2001
>Closed-Date:
>Last-Modified:
>Originator:     pedro@vis.ethz.ch
>Release:        gcc 3.0 latest snapshot
>Organization:
>Environment:
redhat linux 6.2 for i686
>Description:
java.io.RandomAccessFile creates/opens a file for reading 
and/or writing. 

it calls java.io.FileDescriptor(<filename>,<mode>) - where
mode is either FileDescriptor.READ or FileDescriptor.READ.

FileDescriptor passes these args to natFileDesciptorPosix.cc
who translates them for the posix "open" function, yet does
not add O_CREAT for the "rw" case as would be required by 
java.io.FileDeescriptor

open returns an error value which is translated to an 
IOException.
>How-To-Repeat:
compile and run the attached program it opens a 
java.io.RandomAccessFile (first arg) and tries to write to 
it. with gcj this crashes, with any other java it works.
>Fix:
added

   static final int CREATE = 16;

to java.io.Filedescriptor and or'ed it to the 
java.io.RandomAccessFile constructor for "rw". also added

     if (jflags & CREATE)
  	flags |= O_CREAT;

to natFileDescriptor.cc for the whole thing to actualy do 
something.
>Release-Note:
>Audit-Trail:
>Unformatted:
----gnatsweb-attachment----
Content-Type: application/octet-stream; name="RAFTest.java"
Content-Transfer-Encoding: base64
Content-Disposition: attachment; filename="RAFTest.java"

aW1wb3J0IGphdmEuaW8uRmlsZTsKaW1wb3J0IGphdmEuaW8uUmFuZG9tQWNjZXNzRmlsZTsKaW1w
b3J0IGphdmEuaW8uSU9FeGNlcHRpb247CgpjbGFzcyBSQUZUZXN0IHsKCglwdWJsaWMgc3RhdGlj
IHZvaWQgbWFpbiAoIFN0cmluZyBhcmdzW10gKSB7CgkKCQlSYW5kb21BY2Nlc3NGaWxlIHJhZiA9
IG51bGw7CgkJCgkJdHJ5IHsKCQkJcmFmID0gbmV3IFJhbmRvbUFjY2Vzc0ZpbGUoYXJnc1swXSwi
cnciKTsKCQkJfQoJCWNhdGNoICggSU9FeGNlcHRpb24gZSApIHsKCQkJU3lzdGVtLm91dC5wcmlu
dGxuKCJSQUZUZXN0Lk1haW46IGdvdCBJT0V4Y2VwdGlvbiBvbiBSQUYgaW5pdDoiKTsKCQkJU3lz
dGVtLm91dC5wcmludGxuKGUuZ2V0TWVzc2FnZSgpKTsKCQkJcmV0dXJuOwoJCQl9CgoJCXRyeSB7
CgkJCXJhZi53cml0ZUNoYXJzKCJyYWYtdGVzdC4uLlxuIik7CgkJCXJhZi5jbG9zZSgpOwoJCQl9
CgkJY2F0Y2ggKCBJT0V4Y2VwdGlvbiBlICkgewoJCQlTeXN0ZW0ub3V0LnByaW50bG4oIlJBRlRl
c3QuTWFpbjogZ290IElPRXhjZXB0aW9uIG9uIFJBRiBhY2Nlc3M6Iik7CgkJCVN5c3RlbS5vdXQu
cHJpbnRsbihlLmdldE1lc3NhZ2UoKSk7CgkJCXJldHVybjsKCQkJfQoKCQl9CgoJfQo=



More information about the Java-prs mailing list