harmony-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Mikhail Markov (JIRA)" <j...@apache.org>
Subject [jira] Updated: (HARMONY-2741) [drlvm][classlib] unexpected result for 'user.home' on windows in empty environment
Date Sat, 02 Jun 2007 04:23:15 GMT

     [ 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.


Mime
View raw message