You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@harmony.apache.org by "Vladimir Ivanov (JIRA)" <ji...@apache.org> on 2006/12/15 12:31:21 UTC

[jira] Created: (HARMONY-2741) [drlvm][classlib] unexpected result for 'user.home' on windows in empty environment

[drlvm][classlib] unexpected result for 'user.home' on windows in empty environment
-----------------------------------------------------------------------------------

                 Key: HARMONY-2741
                 URL: http://issues.apache.org/jira/browse/HARMONY-2741
             Project: Harmony
          Issue Type: Bug
          Components: DRLVM
            Reporter: Vladimir Ivanov
            Priority: Minor


The DRLVM reports the incorrect 'user.home' variable (%SystemDrive% instead of drive) if vm was run in empty environment. Note RI works OK.

================ test.java ====================
import java.io.*;

public class test {
    
    public static volatile String cmdS = "java -version";

    void read(InputStream stream) {
        try {
            byte[] data = new byte[stream.available()];
            stream.read(data, 0, data.length);
            if (data.length > 0) {
                System.out.println(new String(data, 0, data.length));
            }
        } catch (IOException e) {
            e.printStackTrace();
        }
    }

    public void run(String[] args) {
        if (args != null && args.length > 0) {
            cmdS = "";
            for (int i = 0; i < args.length; i++) {
                cmdS = cmdS + args[i] + " ";
            }
        }
        System.out.println("Command to run:\n\t" + cmdS);
	String[] envp = {};
        try {
            Process proc = Runtime.getRuntime().exec(cmdS, envp);
            InputStream err = proc.getErrorStream();
            InputStream in = proc.getInputStream();
            int ec = Integer.MIN_VALUE;
            while (true) {
                try {
                    ec = proc.exitValue();
                    break;
                } catch (IllegalThreadStateException  e) {
                    try {
                        Thread.sleep(100);
                        read(in);
                        read(err);
                    } catch (InterruptedException e1) {
                        e1.printStackTrace();
                    }
                }
            }
            System.out.println("exit code is " + ec);
        } catch (Exception e) {
            e.printStackTrace();
        }
    }

    public static void main(String[] args) {
        new test().run(args);
    }
}

class tst {
    public static void main(String[] args) {

	System.out.println(System.getProperty("user.name"));
	System.out.println(System.getProperty("user.home"));
	System.out.println(System.getProperty("user.dir"));
    }
}
===========================================

Output:
C:\tmp\tmp17>C:\jdk1.5.0_08\bin\java.exe test C:\jdk1.5.0_08\bin\java.exe -cp . -showversion tst
Command to run:
        C:\jdk1.5.0_08\bin\java.exe -cp . -showversion tst
vivanov1
C:\Documents and Settings\vivanov1
C:\tmp\tmp17

java version "1.5.0_08"
Java(TM) 2 Runtime Environment, Standard Edition (build 1.5.0_08-b03)
Java HotSpot(TM) Client VM (build 1.5.0_08-b03, mixed mode)



exit code is 0

C:\tmp\tmp17>C:\jdk1.5.0_08\bin\java.exe test C:\harmony.top\drlvm\trunk\build\win_ia32_msvc_debug\deploy\jdk\jre\bin\java -cp . -showversion tst
Command to run:
        C:\harmony.top\drlvm\trunk\build\win_ia32_msvc_debug\deploy\jdk\jre\bin\java -cp . -showversion tst
Apache Harmony Launcher : (c) Copyright 1991, 2006 The Apache Software Foundation or its licensors, as applicable.

java version "1.5.0"
pre-alpha : not complete or compatible
svn = r487441, (Dec 15 2006), Windows/ia32/msvc 1310, debug build
http://incubator.apache.org/harmony

vivanov1

%SystemDrive%\Documents and Settings\vivanov1
C:\tmp\tmp17

exit code is 0

C:\tmp\tmp17>

-- 
This message is automatically generated by JIRA.
-
If you think it was sent incorrectly contact one of the administrators: http://issues.apache.org/jira/secure/Administrators.jspa
-
For more information on JIRA, see: http://www.atlassian.com/software/jira

        

[jira] Commented: (HARMONY-2741) [drlvm][classlib] unexpected result for 'user.home' on windows in empty environment

Posted by "Vladimir Ivanov (JIRA)" <ji...@apache.org>.
    [ https://issues.apache.org/jira/browse/HARMONY-2741?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel#action_12498092 ] 

Vladimir Ivanov commented on HARMONY-2741:
------------------------------------------

For me this bug is still reproduced:
------------------------------------------------------
C:\tmp\tmp17>C:\jdk1.5.0_08\bin\java.exe test C:\harmony.top\drlvm\trunk\build\win_ia32_msvc_debug\deploy\jdk\jre\bin\java -cp . -showversion tst
Command to run:
        C:\harmony.top\drlvm\trunk\build\win_ia32_msvc_debug\deploy\jdk\jre\bin\java -cp . -showversion tst
Apache Harmony Launcher : (c) Copyright 1991, 2006 The Apache Software Foundation or its licensors, as applicable.

java version "1.5.0"
pre-alpha : not complete or compatible
svn = r540806, (May 23 2007), Windows/ia32/msvc 1310, debug build
http://incubator.apache.org/harmony

vivanov1
%SystemDrive%\Documents and Settings\vivanov1
C:\tmp\tmp17

exit code is 0
------------------------------------------------------


> [drlvm][classlib] unexpected result for 'user.home' on windows in empty environment
> -----------------------------------------------------------------------------------
>
>                 Key: HARMONY-2741
>                 URL: https://issues.apache.org/jira/browse/HARMONY-2741
>             Project: Harmony
>          Issue Type: Bug
>          Components: DRLVM
>            Reporter: Vladimir Ivanov
>            Priority: Minor
>
> The DRLVM reports the incorrect 'user.home' variable (%SystemDrive% instead of drive) if vm was run in empty environment. Note RI works OK.
> ================ test.java ====================
> import java.io.*;
> public class test {
>     
>     public static volatile String cmdS = "java -version";
>     void read(InputStream stream) {
>         try {
>             byte[] data = new byte[stream.available()];
>             stream.read(data, 0, data.length);
>             if (data.length > 0) {
>                 System.out.println(new String(data, 0, data.length));
>             }
>         } catch (IOException e) {
>             e.printStackTrace();
>         }
>     }
>     public void run(String[] args) {
>         if (args != null && args.length > 0) {
>             cmdS = "";
>             for (int i = 0; i < args.length; i++) {
>                 cmdS = cmdS + args[i] + " ";
>             }
>         }
>         System.out.println("Command to run:\n\t" + cmdS);
> 	String[] envp = {};
>         try {
>             Process proc = Runtime.getRuntime().exec(cmdS, envp);
>             InputStream err = proc.getErrorStream();
>             InputStream in = proc.getInputStream();
>             int ec = Integer.MIN_VALUE;
>             while (true) {
>                 try {
>                     ec = proc.exitValue();
>                     break;
>                 } catch (IllegalThreadStateException  e) {
>                     try {
>                         Thread.sleep(100);
>                         read(in);
>                         read(err);
>                     } catch (InterruptedException e1) {
>                         e1.printStackTrace();
>                     }
>                 }
>             }
>             System.out.println("exit code is " + ec);
>         } catch (Exception e) {
>             e.printStackTrace();
>         }
>     }
>     public static void main(String[] args) {
>         new test().run(args);
>     }
> }
> class tst {
>     public static void main(String[] args) {
> 	System.out.println(System.getProperty("user.name"));
> 	System.out.println(System.getProperty("user.home"));
> 	System.out.println(System.getProperty("user.dir"));
>     }
> }
> ===========================================
> Output:
> C:\tmp\tmp17>C:\jdk1.5.0_08\bin\java.exe test C:\jdk1.5.0_08\bin\java.exe -cp . -showversion tst
> Command to run:
>         C:\jdk1.5.0_08\bin\java.exe -cp . -showversion tst
> vivanov1
> C:\Documents and Settings\vivanov1
> C:\tmp\tmp17
> java version "1.5.0_08"
> Java(TM) 2 Runtime Environment, Standard Edition (build 1.5.0_08-b03)
> Java HotSpot(TM) Client VM (build 1.5.0_08-b03, mixed mode)
> exit code is 0
> C:\tmp\tmp17>C:\jdk1.5.0_08\bin\java.exe test C:\harmony.top\drlvm\trunk\build\win_ia32_msvc_debug\deploy\jdk\jre\bin\java -cp . -showversion tst
> Command to run:
>         C:\harmony.top\drlvm\trunk\build\win_ia32_msvc_debug\deploy\jdk\jre\bin\java -cp . -showversion tst
> Apache Harmony Launcher : (c) Copyright 1991, 2006 The Apache Software Foundation or its licensors, as applicable.
> java version "1.5.0"
> pre-alpha : not complete or compatible
> svn = r487441, (Dec 15 2006), Windows/ia32/msvc 1310, debug build
> http://incubator.apache.org/harmony
> vivanov1
> %SystemDrive%\Documents and Settings\vivanov1
> C:\tmp\tmp17
> exit code is 0
> C:\tmp\tmp17>

-- 
This message is automatically generated by JIRA.
-
You can reply to this email to add a comment to the issue online.


[jira] Commented: (HARMONY-2741) [drlvm][classlib] unexpected result for 'user.home' on windows in empty environment

Posted by "Mikhail Markov (JIRA)" <ji...@apache.org>.
    [ https://issues.apache.org/jira/browse/HARMONY-2741?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel#action_12500851 ] 

Mikhail Markov commented on HARMONY-2741:
-----------------------------------------

Thanks, Vladimir for the clarification - i've succeeded to reproduce the problem and will provide my investigation soon!

> [drlvm][classlib] unexpected result for 'user.home' on windows in empty environment
> -----------------------------------------------------------------------------------
>
>                 Key: HARMONY-2741
>                 URL: https://issues.apache.org/jira/browse/HARMONY-2741
>             Project: Harmony
>          Issue Type: Bug
>          Components: DRLVM
>            Reporter: Vladimir Ivanov
>            Priority: Minor
>
> The DRLVM reports the incorrect 'user.home' variable (%SystemDrive% instead of drive) if vm was run in empty environment. Note RI works OK.
> ================ test.java ====================
> import java.io.*;
> public class test {
>     
>     public static volatile String cmdS = "java -version";
>     void read(InputStream stream) {
>         try {
>             byte[] data = new byte[stream.available()];
>             stream.read(data, 0, data.length);
>             if (data.length > 0) {
>                 System.out.println(new String(data, 0, data.length));
>             }
>         } catch (IOException e) {
>             e.printStackTrace();
>         }
>     }
>     public void run(String[] args) {
>         if (args != null && args.length > 0) {
>             cmdS = "";
>             for (int i = 0; i < args.length; i++) {
>                 cmdS = cmdS + args[i] + " ";
>             }
>         }
>         System.out.println("Command to run:\n\t" + cmdS);
> 	String[] envp = {};
>         try {
>             Process proc = Runtime.getRuntime().exec(cmdS, envp);
>             InputStream err = proc.getErrorStream();
>             InputStream in = proc.getInputStream();
>             int ec = Integer.MIN_VALUE;
>             while (true) {
>                 try {
>                     ec = proc.exitValue();
>                     break;
>                 } catch (IllegalThreadStateException  e) {
>                     try {
>                         Thread.sleep(100);
>                         read(in);
>                         read(err);
>                     } catch (InterruptedException e1) {
>                         e1.printStackTrace();
>                     }
>                 }
>             }
>             System.out.println("exit code is " + ec);
>         } catch (Exception e) {
>             e.printStackTrace();
>         }
>     }
>     public static void main(String[] args) {
>         new test().run(args);
>     }
> }
> class tst {
>     public static void main(String[] args) {
> 	System.out.println(System.getProperty("user.name"));
> 	System.out.println(System.getProperty("user.home"));
> 	System.out.println(System.getProperty("user.dir"));
>     }
> }
> ===========================================
> Output:
> C:\tmp\tmp17>C:\jdk1.5.0_08\bin\java.exe test C:\jdk1.5.0_08\bin\java.exe -cp . -showversion tst
> Command to run:
>         C:\jdk1.5.0_08\bin\java.exe -cp . -showversion tst
> vivanov1
> C:\Documents and Settings\vivanov1
> C:\tmp\tmp17
> java version "1.5.0_08"
> Java(TM) 2 Runtime Environment, Standard Edition (build 1.5.0_08-b03)
> Java HotSpot(TM) Client VM (build 1.5.0_08-b03, mixed mode)
> exit code is 0
> C:\tmp\tmp17>C:\jdk1.5.0_08\bin\java.exe test C:\harmony.top\drlvm\trunk\build\win_ia32_msvc_debug\deploy\jdk\jre\bin\java -cp . -showversion tst
> Command to run:
>         C:\harmony.top\drlvm\trunk\build\win_ia32_msvc_debug\deploy\jdk\jre\bin\java -cp . -showversion tst
> Apache Harmony Launcher : (c) Copyright 1991, 2006 The Apache Software Foundation or its licensors, as applicable.
> java version "1.5.0"
> pre-alpha : not complete or compatible
> svn = r487441, (Dec 15 2006), Windows/ia32/msvc 1310, debug build
> http://incubator.apache.org/harmony
> vivanov1
> %SystemDrive%\Documents and Settings\vivanov1
> C:\tmp\tmp17
> exit code is 0
> C:\tmp\tmp17>

-- 
This message is automatically generated by JIRA.
-
You can reply to this email to add a comment to the issue online.


[jira] Commented: (HARMONY-2741) [drlvm][classlib] unexpected result for 'user.home' on windows in empty environment

Posted by "Mikhail Markov (JIRA)" <ji...@apache.org>.
    [ https://issues.apache.org/jira/browse/HARMONY-2741?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel#action_12500408 ] 

Mikhail Markov commented on HARMONY-2741:
-----------------------------------------

Vladimir,
I also could not reproduce the bug on my WinXP (at least the specified testcase works for me).
Could you please check again? Thanks!

> [drlvm][classlib] unexpected result for 'user.home' on windows in empty environment
> -----------------------------------------------------------------------------------
>
>                 Key: HARMONY-2741
>                 URL: https://issues.apache.org/jira/browse/HARMONY-2741
>             Project: Harmony
>          Issue Type: Bug
>          Components: DRLVM
>            Reporter: Vladimir Ivanov
>            Priority: Minor
>
> The DRLVM reports the incorrect 'user.home' variable (%SystemDrive% instead of drive) if vm was run in empty environment. Note RI works OK.
> ================ test.java ====================
> import java.io.*;
> public class test {
>     
>     public static volatile String cmdS = "java -version";
>     void read(InputStream stream) {
>         try {
>             byte[] data = new byte[stream.available()];
>             stream.read(data, 0, data.length);
>             if (data.length > 0) {
>                 System.out.println(new String(data, 0, data.length));
>             }
>         } catch (IOException e) {
>             e.printStackTrace();
>         }
>     }
>     public void run(String[] args) {
>         if (args != null && args.length > 0) {
>             cmdS = "";
>             for (int i = 0; i < args.length; i++) {
>                 cmdS = cmdS + args[i] + " ";
>             }
>         }
>         System.out.println("Command to run:\n\t" + cmdS);
> 	String[] envp = {};
>         try {
>             Process proc = Runtime.getRuntime().exec(cmdS, envp);
>             InputStream err = proc.getErrorStream();
>             InputStream in = proc.getInputStream();
>             int ec = Integer.MIN_VALUE;
>             while (true) {
>                 try {
>                     ec = proc.exitValue();
>                     break;
>                 } catch (IllegalThreadStateException  e) {
>                     try {
>                         Thread.sleep(100);
>                         read(in);
>                         read(err);
>                     } catch (InterruptedException e1) {
>                         e1.printStackTrace();
>                     }
>                 }
>             }
>             System.out.println("exit code is " + ec);
>         } catch (Exception e) {
>             e.printStackTrace();
>         }
>     }
>     public static void main(String[] args) {
>         new test().run(args);
>     }
> }
> class tst {
>     public static void main(String[] args) {
> 	System.out.println(System.getProperty("user.name"));
> 	System.out.println(System.getProperty("user.home"));
> 	System.out.println(System.getProperty("user.dir"));
>     }
> }
> ===========================================
> Output:
> C:\tmp\tmp17>C:\jdk1.5.0_08\bin\java.exe test C:\jdk1.5.0_08\bin\java.exe -cp . -showversion tst
> Command to run:
>         C:\jdk1.5.0_08\bin\java.exe -cp . -showversion tst
> vivanov1
> C:\Documents and Settings\vivanov1
> C:\tmp\tmp17
> java version "1.5.0_08"
> Java(TM) 2 Runtime Environment, Standard Edition (build 1.5.0_08-b03)
> Java HotSpot(TM) Client VM (build 1.5.0_08-b03, mixed mode)
> exit code is 0
> C:\tmp\tmp17>C:\jdk1.5.0_08\bin\java.exe test C:\harmony.top\drlvm\trunk\build\win_ia32_msvc_debug\deploy\jdk\jre\bin\java -cp . -showversion tst
> Command to run:
>         C:\harmony.top\drlvm\trunk\build\win_ia32_msvc_debug\deploy\jdk\jre\bin\java -cp . -showversion tst
> Apache Harmony Launcher : (c) Copyright 1991, 2006 The Apache Software Foundation or its licensors, as applicable.
> java version "1.5.0"
> pre-alpha : not complete or compatible
> svn = r487441, (Dec 15 2006), Windows/ia32/msvc 1310, debug build
> http://incubator.apache.org/harmony
> vivanov1
> %SystemDrive%\Documents and Settings\vivanov1
> C:\tmp\tmp17
> exit code is 0
> C:\tmp\tmp17>

-- 
This message is automatically generated by JIRA.
-
You can reply to this email to add a comment to the issue online.


[jira] Commented: (HARMONY-2741) [drlvm][classlib] unexpected result for 'user.home' on windows in empty environment

Posted by "Vladimir Beliaev (JIRA)" <ji...@apache.org>.
    [ https://issues.apache.org/jira/browse/HARMONY-2741?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel#action_12497898 ] 

Vladimir Beliaev commented on HARMONY-2741:
-------------------------------------------

The bug is not reproducible for me:

~/test-H2741 $ java Test java -showversion tst
Command to run:
        java -showversion tst 
java version "1.5.0_08"
Java(TM) 2 Runtime Environment, Standard Edition (build 1.5.0_08-b03)
BEA JRockit(R) (build R27.1.0-109-73164-1.5.0_08-20061129-1428-windows-ia32, compiled mode)

vbeliaev
C:\Documents and Settings\vbeliaev
c:\users\vbeliaev\test-H2741

exit code is 0




~/test-H2741 $ ../trunk-debug-20070518/working_vm/build/deploy/jdk/jre/bin/java Test \
        ../trunk-debug-20070518/working_vm/build/deploy/jdk/jre/bin/java -showversion tst
Command to run:
        ../trunk-debug-20070518/working_vm/build/deploy/jdk/jre/bin/java -showversion tst 
Apache Harmony Launcher : (c) Copyright 1991, 2006 The Apache Software Foundation or its licensors, as applicable.

java version "1.5.0" 
pre-alpha : not complete or compatible
svn = r539322, (May 18 2007), Windows/ia32/msvc 1310, debug build
http://incubator.apache.org/harmony

vbeliaev
C:\Documents and Settings\vbeliaev
c:\users\vbeliaev\test-H2741

exit code is 0

=========
Vladimir, could you verify it & update enviromnment description for reproduction or Resolve this issue?

Thanks
Vladimir Beliaev


> [drlvm][classlib] unexpected result for 'user.home' on windows in empty environment
> -----------------------------------------------------------------------------------
>
>                 Key: HARMONY-2741
>                 URL: https://issues.apache.org/jira/browse/HARMONY-2741
>             Project: Harmony
>          Issue Type: Bug
>          Components: DRLVM
>            Reporter: Vladimir Ivanov
>            Priority: Minor
>
> The DRLVM reports the incorrect 'user.home' variable (%SystemDrive% instead of drive) if vm was run in empty environment. Note RI works OK.
> ================ test.java ====================
> import java.io.*;
> public class test {
>     
>     public static volatile String cmdS = "java -version";
>     void read(InputStream stream) {
>         try {
>             byte[] data = new byte[stream.available()];
>             stream.read(data, 0, data.length);
>             if (data.length > 0) {
>                 System.out.println(new String(data, 0, data.length));
>             }
>         } catch (IOException e) {
>             e.printStackTrace();
>         }
>     }
>     public void run(String[] args) {
>         if (args != null && args.length > 0) {
>             cmdS = "";
>             for (int i = 0; i < args.length; i++) {
>                 cmdS = cmdS + args[i] + " ";
>             }
>         }
>         System.out.println("Command to run:\n\t" + cmdS);
> 	String[] envp = {};
>         try {
>             Process proc = Runtime.getRuntime().exec(cmdS, envp);
>             InputStream err = proc.getErrorStream();
>             InputStream in = proc.getInputStream();
>             int ec = Integer.MIN_VALUE;
>             while (true) {
>                 try {
>                     ec = proc.exitValue();
>                     break;
>                 } catch (IllegalThreadStateException  e) {
>                     try {
>                         Thread.sleep(100);
>                         read(in);
>                         read(err);
>                     } catch (InterruptedException e1) {
>                         e1.printStackTrace();
>                     }
>                 }
>             }
>             System.out.println("exit code is " + ec);
>         } catch (Exception e) {
>             e.printStackTrace();
>         }
>     }
>     public static void main(String[] args) {
>         new test().run(args);
>     }
> }
> class tst {
>     public static void main(String[] args) {
> 	System.out.println(System.getProperty("user.name"));
> 	System.out.println(System.getProperty("user.home"));
> 	System.out.println(System.getProperty("user.dir"));
>     }
> }
> ===========================================
> Output:
> C:\tmp\tmp17>C:\jdk1.5.0_08\bin\java.exe test C:\jdk1.5.0_08\bin\java.exe -cp . -showversion tst
> Command to run:
>         C:\jdk1.5.0_08\bin\java.exe -cp . -showversion tst
> vivanov1
> C:\Documents and Settings\vivanov1
> C:\tmp\tmp17
> java version "1.5.0_08"
> Java(TM) 2 Runtime Environment, Standard Edition (build 1.5.0_08-b03)
> Java HotSpot(TM) Client VM (build 1.5.0_08-b03, mixed mode)
> exit code is 0
> C:\tmp\tmp17>C:\jdk1.5.0_08\bin\java.exe test C:\harmony.top\drlvm\trunk\build\win_ia32_msvc_debug\deploy\jdk\jre\bin\java -cp . -showversion tst
> Command to run:
>         C:\harmony.top\drlvm\trunk\build\win_ia32_msvc_debug\deploy\jdk\jre\bin\java -cp . -showversion tst
> Apache Harmony Launcher : (c) Copyright 1991, 2006 The Apache Software Foundation or its licensors, as applicable.
> java version "1.5.0"
> pre-alpha : not complete or compatible
> svn = r487441, (Dec 15 2006), Windows/ia32/msvc 1310, debug build
> http://incubator.apache.org/harmony
> vivanov1
> %SystemDrive%\Documents and Settings\vivanov1
> C:\tmp\tmp17
> exit code is 0
> C:\tmp\tmp17>

-- 
This message is automatically generated by JIRA.
-
You can reply to this email to add a comment to the issue online.


[jira] Updated: (HARMONY-2741) [drlvm][classlib] unexpected result for 'user.home' on windows in empty environment

Posted by "Mikhail Markov (JIRA)" <ji...@apache.org>.
     [ https://issues.apache.org/jira/browse/HARMONY-2741?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ]

Mikhail Markov updated HARMONY-2741:
------------------------------------

    Attachment: H-2741.patch

I've completed the investigation of the problem and here is the results:
When spawning a new process, RI clears all environment variables, and when GetUserProfileDirectory function returns the path it could not be expanded to the proper value (and contains %SystemDrive% requiring resolution).

I've found the link describing how RI determine this property: http://access1.sun.com/cgi-bin/rinfo2html?354930.faq
Also it seems that there are a lot of complaints about such behaviour. See http://bugs.sun.com/bugdatabase/view_bug.do?bug_id=4787931(also related bugs there).

I've tried to unify all approaches in the attached patch, which:
1) Tries to use GetUserProfileDirectory (it fails for me on empty environment)
2) Tries to use NetUserGetInfo (it fails for me too - returns an empty path)
3) Reading Desktop value from HKEY_CURRENT_USER\Software\Microsoft\Windows\CurrentVersion\Explorer\Shell Folders registry key and uses it's parent dir as user.home (this is the only approach that passes on empty environment on my WinXP)

Hope this will fully resolve the issue on other machines as well.

> [drlvm][classlib] unexpected result for 'user.home' on windows in empty environment
> -----------------------------------------------------------------------------------
>
>                 Key: HARMONY-2741
>                 URL: https://issues.apache.org/jira/browse/HARMONY-2741
>             Project: Harmony
>          Issue Type: Bug
>          Components: DRLVM
>            Reporter: Vladimir Ivanov
>            Priority: Minor
>         Attachments: H-2741.patch
>
>
> The DRLVM reports the incorrect 'user.home' variable (%SystemDrive% instead of drive) if vm was run in empty environment. Note RI works OK.
> ================ test.java ====================
> import java.io.*;
> public class test {
>     
>     public static volatile String cmdS = "java -version";
>     void read(InputStream stream) {
>         try {
>             byte[] data = new byte[stream.available()];
>             stream.read(data, 0, data.length);
>             if (data.length > 0) {
>                 System.out.println(new String(data, 0, data.length));
>             }
>         } catch (IOException e) {
>             e.printStackTrace();
>         }
>     }
>     public void run(String[] args) {
>         if (args != null && args.length > 0) {
>             cmdS = "";
>             for (int i = 0; i < args.length; i++) {
>                 cmdS = cmdS + args[i] + " ";
>             }
>         }
>         System.out.println("Command to run:\n\t" + cmdS);
> 	String[] envp = {};
>         try {
>             Process proc = Runtime.getRuntime().exec(cmdS, envp);
>             InputStream err = proc.getErrorStream();
>             InputStream in = proc.getInputStream();
>             int ec = Integer.MIN_VALUE;
>             while (true) {
>                 try {
>                     ec = proc.exitValue();
>                     break;
>                 } catch (IllegalThreadStateException  e) {
>                     try {
>                         Thread.sleep(100);
>                         read(in);
>                         read(err);
>                     } catch (InterruptedException e1) {
>                         e1.printStackTrace();
>                     }
>                 }
>             }
>             System.out.println("exit code is " + ec);
>         } catch (Exception e) {
>             e.printStackTrace();
>         }
>     }
>     public static void main(String[] args) {
>         new test().run(args);
>     }
> }
> class tst {
>     public static void main(String[] args) {
> 	System.out.println(System.getProperty("user.name"));
> 	System.out.println(System.getProperty("user.home"));
> 	System.out.println(System.getProperty("user.dir"));
>     }
> }
> ===========================================
> Output:
> C:\tmp\tmp17>C:\jdk1.5.0_08\bin\java.exe test C:\jdk1.5.0_08\bin\java.exe -cp . -showversion tst
> Command to run:
>         C:\jdk1.5.0_08\bin\java.exe -cp . -showversion tst
> vivanov1
> C:\Documents and Settings\vivanov1
> C:\tmp\tmp17
> java version "1.5.0_08"
> Java(TM) 2 Runtime Environment, Standard Edition (build 1.5.0_08-b03)
> Java HotSpot(TM) Client VM (build 1.5.0_08-b03, mixed mode)
> exit code is 0
> C:\tmp\tmp17>C:\jdk1.5.0_08\bin\java.exe test C:\harmony.top\drlvm\trunk\build\win_ia32_msvc_debug\deploy\jdk\jre\bin\java -cp . -showversion tst
> Command to run:
>         C:\harmony.top\drlvm\trunk\build\win_ia32_msvc_debug\deploy\jdk\jre\bin\java -cp . -showversion tst
> Apache Harmony Launcher : (c) Copyright 1991, 2006 The Apache Software Foundation or its licensors, as applicable.
> java version "1.5.0"
> pre-alpha : not complete or compatible
> svn = r487441, (Dec 15 2006), Windows/ia32/msvc 1310, debug build
> http://incubator.apache.org/harmony
> vivanov1
> %SystemDrive%\Documents and Settings\vivanov1
> C:\tmp\tmp17
> exit code is 0
> C:\tmp\tmp17>

-- 
This message is automatically generated by JIRA.
-
You can reply to this email to add a comment to the issue online.


[jira] Updated: (HARMONY-2741) [drlvm][port] unexpected result for 'user.home' on windows in empty environment

Posted by "Gregory Shimansky (JIRA)" <ji...@apache.org>.
     [ https://issues.apache.org/jira/browse/HARMONY-2741?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ]

Gregory Shimansky updated HARMONY-2741:
---------------------------------------

    Summary: [drlvm][port] unexpected result for 'user.home' on windows in empty environment  (was: [drlvm][classlib] unexpected result for 'user.home' on windows in empty environment)

I am renaming the bug to drlvm specific since the solution is purely specific to drlvm.

> [drlvm][port] unexpected result for 'user.home' on windows in empty environment
> -------------------------------------------------------------------------------
>
>                 Key: HARMONY-2741
>                 URL: https://issues.apache.org/jira/browse/HARMONY-2741
>             Project: Harmony
>          Issue Type: Bug
>          Components: DRLVM
>            Reporter: Vladimir Ivanov
>            Priority: Minor
>         Attachments: H-2741.patch
>
>
> The DRLVM reports the incorrect 'user.home' variable (%SystemDrive% instead of drive) if vm was run in empty environment. Note RI works OK.
> ================ test.java ====================
> import java.io.*;
> public class test {
>     
>     public static volatile String cmdS = "java -version";
>     void read(InputStream stream) {
>         try {
>             byte[] data = new byte[stream.available()];
>             stream.read(data, 0, data.length);
>             if (data.length > 0) {
>                 System.out.println(new String(data, 0, data.length));
>             }
>         } catch (IOException e) {
>             e.printStackTrace();
>         }
>     }
>     public void run(String[] args) {
>         if (args != null && args.length > 0) {
>             cmdS = "";
>             for (int i = 0; i < args.length; i++) {
>                 cmdS = cmdS + args[i] + " ";
>             }
>         }
>         System.out.println("Command to run:\n\t" + cmdS);
> 	String[] envp = {};
>         try {
>             Process proc = Runtime.getRuntime().exec(cmdS, envp);
>             InputStream err = proc.getErrorStream();
>             InputStream in = proc.getInputStream();
>             int ec = Integer.MIN_VALUE;
>             while (true) {
>                 try {
>                     ec = proc.exitValue();
>                     break;
>                 } catch (IllegalThreadStateException  e) {
>                     try {
>                         Thread.sleep(100);
>                         read(in);
>                         read(err);
>                     } catch (InterruptedException e1) {
>                         e1.printStackTrace();
>                     }
>                 }
>             }
>             System.out.println("exit code is " + ec);
>         } catch (Exception e) {
>             e.printStackTrace();
>         }
>     }
>     public static void main(String[] args) {
>         new test().run(args);
>     }
> }
> class tst {
>     public static void main(String[] args) {
> 	System.out.println(System.getProperty("user.name"));
> 	System.out.println(System.getProperty("user.home"));
> 	System.out.println(System.getProperty("user.dir"));
>     }
> }
> ===========================================
> Output:
> C:\tmp\tmp17>C:\jdk1.5.0_08\bin\java.exe test C:\jdk1.5.0_08\bin\java.exe -cp . -showversion tst
> Command to run:
>         C:\jdk1.5.0_08\bin\java.exe -cp . -showversion tst
> vivanov1
> C:\Documents and Settings\vivanov1
> C:\tmp\tmp17
> java version "1.5.0_08"
> Java(TM) 2 Runtime Environment, Standard Edition (build 1.5.0_08-b03)
> Java HotSpot(TM) Client VM (build 1.5.0_08-b03, mixed mode)
> exit code is 0
> C:\tmp\tmp17>C:\jdk1.5.0_08\bin\java.exe test C:\harmony.top\drlvm\trunk\build\win_ia32_msvc_debug\deploy\jdk\jre\bin\java -cp . -showversion tst
> Command to run:
>         C:\harmony.top\drlvm\trunk\build\win_ia32_msvc_debug\deploy\jdk\jre\bin\java -cp . -showversion tst
> Apache Harmony Launcher : (c) Copyright 1991, 2006 The Apache Software Foundation or its licensors, as applicable.
> java version "1.5.0"
> pre-alpha : not complete or compatible
> svn = r487441, (Dec 15 2006), Windows/ia32/msvc 1310, debug build
> http://incubator.apache.org/harmony
> vivanov1
> %SystemDrive%\Documents and Settings\vivanov1
> C:\tmp\tmp17
> exit code is 0
> C:\tmp\tmp17>

-- 
This message is automatically generated by JIRA.
-
You can reply to this email to add a comment to the issue online.


[jira] Commented: (HARMONY-2741) [drlvm][classlib] unexpected result for 'user.home' on windows in empty environment

Posted by "Vladimir Ivanov (JIRA)" <ji...@apache.org>.
    [ https://issues.apache.org/jira/browse/HARMONY-2741?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel#action_12500581 ] 

Vladimir Ivanov commented on HARMONY-2741:
------------------------------------------

Actually, it works for me too if ran Harmony from Harmony.
I ran RI from RI, Harmony from Harmony, Harmony from RI and RI from Harmony. Results are:

--------------------------------------------------------------------------------------------------------
1) RI from RI
>C:\jdk1.5.0_08\bin\java.exe test C:\jdk1.5.0_08\bin\java.exe -cp . -showversion tst
Command to run:
        C:\jdk1.5.0_08\bin\java.exe -cp . -showversion tst
vivanov1
C:\Documents and Settings\vivanov1
C:\tmp\tmp17

java version "1.5.0_08"
Java(TM) 2 Runtime Environment, Standard Edition (build 1.5.0_08-b03)
Java HotSpot(TM) Client VM (build 1.5.0_08-b03, mixed mode)


exit code is 0
--------------------------------------------------------------------------------------------------------
2) Harmony from Harmony
>C:\harmony.top\drlvm\trunk\build\win_ia32_msvc_debug\deploy\jdk\jre\bin\java test C:\harmony.top\drlvm\trunk\build\win_ia32_msvc_debug\deploy\jdk\jre\bin\java -cp . -showversion tst
Command to run:
        C:\harmony.top\drlvm\trunk\build\win_ia32_msvc_debug\deploy\jdk\jre\bin\java -cp . -showversion tst
Apache Harmony Launcher : (c) Copyright 1991, 2006 The Apache Software Foundation or its licensors, as applicable.

java version "1.5.0"
pre-alpha : not complete or compatible
svn = r543371, (Jun  1 2007), Windows/ia32/msvc 1310, debug build
http://harmony.apache.org

vivanov1
C:\Documents and Settings\vivanov1
C:\tmp\tmp17

exit code is 0
--------------------------------------------------------------------------------------------------------
3) Harmony from RI
>C:\jdk1.5.0_08\bin\java.exe test C:\harmony.top\drlvm\trunk\build\win_ia32_msvc_debug\deploy\jdk\jre\bin\java -cp . -showversion tst
Command to run:
        C:\harmony.top\drlvm\trunk\build\win_ia32_msvc_debug\deploy\jdk\jre\bin\java -cp . -showversion tst
Apache Harmony Launcher : (c) Copyright 1991, 2006 The Apache Software Foundation or its licensors, as applicable.

java version "1.5.0"
pre-alpha : not complete or compatible
svn = r543371, (Jun  1 2007), Windows/ia32/msvc 1310, debug build
http://harmony.apache.org

vivanov1
%SystemDrive%\Documents and Settings\vivanov1
C:\tmp\tmp17

exit code is 0
--------------------------------------------------------------------------------------------------------
4) RI from Harmony
>C:\harmony.top\drlvm\trunk\build\win_ia32_msvc_debug\deploy\jdk\jre\bin\java test C:\jdk1.5.0_08\bin\java.exe -cp . -showversion tst
Command to run:
        C:\jdk1.5.0_08\bin\java.exe -cp . -showversion tst
vivanov1
C:\Documents and Settings\vivanov1
C:\tmp\tmp17

java version "1.5.0_08"
Java(TM) 2 Runtime Environment, Standard Edition (build 1.5.0_08-b03)
Java HotSpot(TM) Client VM (build 1.5.0_08-b03, mixed mode)


exit code is 0


> [drlvm][classlib] unexpected result for 'user.home' on windows in empty environment
> -----------------------------------------------------------------------------------
>
>                 Key: HARMONY-2741
>                 URL: https://issues.apache.org/jira/browse/HARMONY-2741
>             Project: Harmony
>          Issue Type: Bug
>          Components: DRLVM
>            Reporter: Vladimir Ivanov
>            Priority: Minor
>
> The DRLVM reports the incorrect 'user.home' variable (%SystemDrive% instead of drive) if vm was run in empty environment. Note RI works OK.
> ================ test.java ====================
> import java.io.*;
> public class test {
>     
>     public static volatile String cmdS = "java -version";
>     void read(InputStream stream) {
>         try {
>             byte[] data = new byte[stream.available()];
>             stream.read(data, 0, data.length);
>             if (data.length > 0) {
>                 System.out.println(new String(data, 0, data.length));
>             }
>         } catch (IOException e) {
>             e.printStackTrace();
>         }
>     }
>     public void run(String[] args) {
>         if (args != null && args.length > 0) {
>             cmdS = "";
>             for (int i = 0; i < args.length; i++) {
>                 cmdS = cmdS + args[i] + " ";
>             }
>         }
>         System.out.println("Command to run:\n\t" + cmdS);
> 	String[] envp = {};
>         try {
>             Process proc = Runtime.getRuntime().exec(cmdS, envp);
>             InputStream err = proc.getErrorStream();
>             InputStream in = proc.getInputStream();
>             int ec = Integer.MIN_VALUE;
>             while (true) {
>                 try {
>                     ec = proc.exitValue();
>                     break;
>                 } catch (IllegalThreadStateException  e) {
>                     try {
>                         Thread.sleep(100);
>                         read(in);
>                         read(err);
>                     } catch (InterruptedException e1) {
>                         e1.printStackTrace();
>                     }
>                 }
>             }
>             System.out.println("exit code is " + ec);
>         } catch (Exception e) {
>             e.printStackTrace();
>         }
>     }
>     public static void main(String[] args) {
>         new test().run(args);
>     }
> }
> class tst {
>     public static void main(String[] args) {
> 	System.out.println(System.getProperty("user.name"));
> 	System.out.println(System.getProperty("user.home"));
> 	System.out.println(System.getProperty("user.dir"));
>     }
> }
> ===========================================
> Output:
> C:\tmp\tmp17>C:\jdk1.5.0_08\bin\java.exe test C:\jdk1.5.0_08\bin\java.exe -cp . -showversion tst
> Command to run:
>         C:\jdk1.5.0_08\bin\java.exe -cp . -showversion tst
> vivanov1
> C:\Documents and Settings\vivanov1
> C:\tmp\tmp17
> java version "1.5.0_08"
> Java(TM) 2 Runtime Environment, Standard Edition (build 1.5.0_08-b03)
> Java HotSpot(TM) Client VM (build 1.5.0_08-b03, mixed mode)
> exit code is 0
> C:\tmp\tmp17>C:\jdk1.5.0_08\bin\java.exe test C:\harmony.top\drlvm\trunk\build\win_ia32_msvc_debug\deploy\jdk\jre\bin\java -cp . -showversion tst
> Command to run:
>         C:\harmony.top\drlvm\trunk\build\win_ia32_msvc_debug\deploy\jdk\jre\bin\java -cp . -showversion tst
> Apache Harmony Launcher : (c) Copyright 1991, 2006 The Apache Software Foundation or its licensors, as applicable.
> java version "1.5.0"
> pre-alpha : not complete or compatible
> svn = r487441, (Dec 15 2006), Windows/ia32/msvc 1310, debug build
> http://incubator.apache.org/harmony
> vivanov1
> %SystemDrive%\Documents and Settings\vivanov1
> C:\tmp\tmp17
> exit code is 0
> C:\tmp\tmp17>

-- 
This message is automatically generated by JIRA.
-
You can reply to this email to add a comment to the issue online.