Unable to call java.io.File.delete() method

RESOLVED INVALID

Status

Rhino
Core
RESOLVED INVALID
14 years ago
14 years ago

People

(Reporter: stephane.sr.riviere, Assigned: Norris Boyd)

Tracking

other
1.5R5
x86
Windows 2000

Details

(Reporter)

Description

14 years ago
User-Agent:       Mozilla/5.0 (Windows; U; Windows NT 5.0; en-US; rv:1.5) Gecko/20031007 Firebird/0.7
Build Identifier: Mozilla/5.0 (Windows; U; Windows NT 5.0; en-US; rv:1.5) Gecko/20031007 Firebird/0.7

I use Rhino in a standalone Java application, and the scripts mainly manipulate
Java objects.

It seems to be impossible to call the delete() methods on java.io.File objects.

Reproducible: Always

Steps to Reproduce:
1. Create a File object [ var photo = new java.io.File('/my/photo.jp'); ]
2. Try to delete it [ photo.delete(); ]
3. Compile & Run the script !

Actual Results:  
An Exception is thrown :

SyntaxError: missing name after . operator (<myScript>; line 815)
at org.mozilla.javascript.NativeGlobal.constructError(NativeGlobal.java:597)
at org.mozilla.javascript.TokenStream.reportSyntaxError(TokenStream.java:1324)
...

Expected Results:  
Compiled correctly and delete the file ?
(Reporter)

Comment 1

14 years ago
As I suspected, this is directly linked to the "delete" Javascript keyword.
I've found a workaround by using the array notation (I just use
photo['delete']()  instead of photo.delete() ) but this gives a less-readable
script.

So, is a fix possible or would it require too much work, compared to the use of
array notation ?
At least, this should be clearly indicated somewhere in the documentation.
(Assignee)

Comment 2

14 years ago
Your diagnosis and workaround are correct. This behavior is mandated by the ECMA
spec, so there's no fix possible.
Status: NEW → RESOLVED
Last Resolved: 14 years ago
Resolution: --- → INVALID

Comment 3

14 years ago
Trageting as resolved against 1.5R5
Target Milestone: --- → 1.5R5
You need to log in before you can comment on or make changes to this bug.