This Bugzilla instance is a read-only archive of historic NetBeans bug reports. To report a bug in NetBeans please follow the project's instructions for reporting issues.

Bug 18012 - Working directory does not work
Summary: Working directory does not work
Status: CLOSED FIXED
Alias: None
Product: java
Classification: Unclassified
Component: Unsupported (show other bugs)
Version: 3.x
Hardware: PC Windows ME/2000
: P3 blocker (vote)
Assignee: Tomas Hurka
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2001-11-23 09:36 UTC by Jan Becicka
Modified: 2007-09-26 09:14 UTC (History)
4 users (show)

See Also:
Issue Type: DEFECT
Exception Reporter:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Jan Becicka 2001-11-23 09:36:57 UTC
[200111230645]
1. Set Tools | Options | Debugging and Execution | Execution Types | External 
Execution, expert tab, Working Directory to e.g. c:\temp
2. Try to execute this piece of code:
        java.io.File f = new java.io.File("");
        System.out.println(f.getAbsolutePath());
3. It prints $IDE_HOME/bin instead of c:\temp
Comment 1 Jan Becicka 2001-11-23 09:45:48 UTC
No workaround exists -> P2
Comment 2 tkellerer 2001-11-23 10:22:32 UTC
I had the same problem yesterday and it was caused by a mismatch in
the execution settings. Basically the executor for the class itself
(which was a default setting) did not exist (I think it read
JavaExternalExecutor) but the entry in the options window was labelled
External Execution. After changing the executor for the class in
question everything worked fine.
Comment 3 Jesse Glick 2001-11-23 12:36:46 UTC
Sounds to me like a bug in settings, not the compiler itself nor the
Java module. Just a guess. As I mentioned on nbusers, if you create an
executor with the correct cwd and assign it, all is well, so it is
probably ExecSupport getting some bogus object?
Comment 4 _ ttran 2001-11-27 10:22:55 UTC
Honza, please have a look
Comment 5 Jan Becicka 2001-11-27 12:47:27 UTC
[200111270100]
Jesse is right. There is some strange behavior of settings.
1. Set Working Directory for External Execution to c:\temp
2. execute
public class Main {
    public static void main (String args[]) {
       java.io.File f = new java.io.File("");
       System.out.println(f.getAbsolutePath());
    }
}
3. It prints $IDE_HOME/bin
4. set Executor of Main to Internal Execution and then back to 
External Execution.
5. execute Main again -> It prints c:\temp
Comment 6 Jan Chalupa 2001-11-27 13:01:54 UTC
Target milestone -> 3.3.1.
Comment 7 Jan Pokorsky 2001-11-27 19:18:39 UTC
I think the setting support is innocent at least in this case ;-)

The culprit is JavaSettings class. Because it doesn't initialize a 
value  for the property PROP_EXECUTOR. If SystemOption doesn't find 
any assigned value it uses getter method when writing data down. But 
getExecutor returns Executor instead of ServiceType.Handle as it is 
assigned to PROP_EXECUTOR. So if JavaSettings are deserialized wrong 
executor is used (not from ServiceType.Registery).

I would propose to add following method to JavaSettings:
protected void initialize() {
 super.initialize();
 putProperty(PROP_EXECUTOR, new ServiceType.Handle(getExecutor()), 
false);
}

Unhappily it seems it affects more system options (AntSettings,...). 
Here is some kind of general workaround: it should be sufficient to 
check and use if not null the property value again after calling given 
getter in SystemOption.writeExternal. It is common way to initialize 
value to default in getters.

Any opinion, objection?
Comment 8 Jesse Glick 2001-11-27 20:13:48 UTC
I object to the proposed workaround. What if a getter is written like
this?

Executor getFoo() {
   ST.H handle = getProp(PROP_FOO);
   if (handle != null) {
     return (Executor)handle.getServiceType();
   } else {
     return Executor.getDefault();
   }
}

The SCO property PROP_FOO will never be stored unless you call
setFoo(), getFoo() will not do it. So the workaround just defers the
problem to a smaller set of cases and makes the bug even harder to
guess the reason for.

It looks to me that JavaSettings is simply wrong and the bug is there.
SystemOption behavior is that the getter/setter will be used unless
the SCO prop exists and is not of the type given by the bean property.
Since JS initially leaves the SCO prop null, it is unable to guarantee
this and so its storage using SCO props is not guaranteed.
JS.initialize() should be fixed (according to the code snippet Jan
suggests) to store the proper default value as a handle, IMHO.
Comment 9 Tomas Hurka 2001-11-28 12:54:32 UTC
fixed in trunk, getter and setter for Executor and Debugger changed to
match getter and setter for Compiler property 

Checking in JavaSettings.java;
/cvs/java/src/org/netbeans/modules/java/settings/JavaSettings.java,v 
<--  JavaSettings.java
new revision: 1.48; previous revision: 1.47
done

Comment 10 Tomas Hurka 2001-11-29 09:53:50 UTC
fixed in release33 branch
Comment 11 Jan Becicka 2001-11-30 14:10:05 UTC
Verified in [200111300330]
Comment 12 Tomas Hurka 2001-12-06 08:55:17 UTC
Workaround exists. See above comment from Jan Becicka dated 2001-11-27
04:47 PST. Decreasing priority.
Comment 13 Jan Becicka 2002-01-09 09:38:25 UTC
[200201090331] Verified
Comment 14 Quality Engineering 2003-07-01 13:18:01 UTC
Resolved for 3.4.x or earlier, no new info since then -> closing.