System.java: (getenv0): New method.
2004-06-14 Andrew Haley <aph@redhat.com> * java/lang/System.java: (getenv0): New method. (getenv): Add security check. Do the right thing. * java/lang/natSystem.cc (getenv0): New method. From-SVN: r83107
This commit is contained in:
parent
50431bc428
commit
df94fa14b9
3 changed files with 37 additions and 7 deletions
|
@ -1,3 +1,9 @@
|
||||||
|
2004-06-14 Andrew Haley <aph@redhat.com>
|
||||||
|
|
||||||
|
* java/lang/System.java: (getenv0): New method.
|
||||||
|
(getenv): Add security check. Do the right thing.
|
||||||
|
* java/lang/natSystem.cc (getenv0): New method.
|
||||||
|
|
||||||
2004-06-12 Mark Wielaard <mark@klomp.org>
|
2004-06-12 Mark Wielaard <mark@klomp.org>
|
||||||
|
|
||||||
* javax/swing/RepaintManager.java
|
* javax/swing/RepaintManager.java
|
||||||
|
|
|
@ -454,18 +454,22 @@ public final class System
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* This used to get an environment variable, but following Sun's lead,
|
* Gets the value of an environment variable.
|
||||||
* it now throws an Error. Use <code>getProperty</code> instead.
|
|
||||||
*
|
*
|
||||||
* @param name the name of the environment variable
|
* @param name the name of the environment variable
|
||||||
* @return this does not return
|
* @return the string value of the variable
|
||||||
* @throws Error this is not supported
|
* @throws NullPointerException
|
||||||
* @deprecated use {@link #getProperty(String)}; getenv is not supported
|
* @throws SecurityException if permission is denied
|
||||||
|
* @since 1.5
|
||||||
*/
|
*/
|
||||||
public static String getenv(String name)
|
public static String getenv(String name)
|
||||||
{
|
{
|
||||||
throw new Error("getenv no longer supported, use properties instead: "
|
if (name == null)
|
||||||
+ name);
|
throw new NullPointerException();
|
||||||
|
SecurityManager sm = Runtime.securityManager; // Be thread-safe.
|
||||||
|
if (sm != null)
|
||||||
|
sm.checkPermission(new RuntimePermission("getenv."+name));
|
||||||
|
return getenv0(name);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -602,4 +606,11 @@ public final class System
|
||||||
* @see #setErr(PrintStream)
|
* @see #setErr(PrintStream)
|
||||||
*/
|
*/
|
||||||
private static native void setErr0(PrintStream err);
|
private static native void setErr0(PrintStream err);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Gets the value of an environment variable.
|
||||||
|
*
|
||||||
|
* @see #getenv(String)
|
||||||
|
*/
|
||||||
|
static native String getenv0(String name);
|
||||||
} // class System
|
} // class System
|
||||||
|
|
|
@ -142,3 +142,16 @@ java::lang::System::isWordsBigEndian (void)
|
||||||
u.lval = 1;
|
u.lval = 1;
|
||||||
return u.cval == 0;
|
return u.cval == 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
jstring
|
||||||
|
java::lang::System::getenv0 (jstring name)
|
||||||
|
{
|
||||||
|
jint len = _Jv_GetStringUTFLength (name);
|
||||||
|
char buf[len + 1];
|
||||||
|
jsize total = JvGetStringUTFRegion (name, 0, name->length(), buf);
|
||||||
|
buf[total] = '\0';
|
||||||
|
const char *value = ::getenv (buf);
|
||||||
|
if (value == NULL)
|
||||||
|
return NULL;
|
||||||
|
return JvNewStringLatin1 (value);
|
||||||
|
}
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue