Merge remote branch 'oss/master' into jdk7

Conflicts:
	makefile
This commit is contained in:
Joel Dice 2012-04-10 07:53:00 -06:00
commit 616c08fee9
4 changed files with 98 additions and 10 deletions

View File

@ -631,6 +631,36 @@ Java_java_lang_System_getProperty(JNIEnv* e, jclass, jstring name,
return r;
}
// System.getEnvironment() implementation
// TODO: For Win32, replace usage of deprecated _environ and add Unicode
// support (neither of which is likely to be of great importance).
#ifdef AVIAN_IOS
namespace {
const char* environ[] = { 0 };
}
#elif defined __APPLE__
# include <crt_externs.h>
# define environ (*_NSGetEnviron())
#else
extern char** environ;
#endif
extern "C" JNIEXPORT jobjectArray JNICALL
Java_java_lang_System_getEnvironment(JNIEnv* env, jclass) {
int length;
for (length = 0; environ[length] != 0; ++length) ;
jobjectArray stringArray =
env->NewObjectArray(length, env->FindClass("java/lang/String"),
env->NewStringUTF(""));
for (int i = 0; i < length; i++) {
jobject varString = env->NewStringUTF(environ[i]);
env->SetObjectArrayElement(stringArray, i, varString);
}
return stringArray;
}
extern "C" JNIEXPORT jlong JNICALL
Java_java_lang_System_currentTimeMillis(JNIEnv*, jclass)
{

View File

@ -0,0 +1,21 @@
/* Copyright (c) 2012, Avian Contributors
Permission to use, copy, modify, and/or distribute this software
for any purpose with or without fee is hereby granted, provided
that the above copyright notice and this permission notice appear
in all copies.
There is NO WARRANTY for this software. See license.txt for
details. */
package java.lang;
import java.security.BasicPermission;
public class RuntimePermission extends BasicPermission {
public RuntimePermission(String name) {
super(name);
}
}

View File

@ -17,12 +17,15 @@ import java.io.BufferedOutputStream;
import java.io.FileInputStream;
import java.io.FileOutputStream;
import java.io.FileDescriptor;
import java.util.Map;
import java.util.Hashtable;
import java.util.Properties;
public abstract class System {
private static final long NanoTimeBaseInMillis = currentTimeMillis();
private static Property properties;
private static Map<String, String> environment;
private static SecurityManager securityManager;
// static {
@ -145,4 +148,37 @@ public abstract class System {
this.next = next;
}
}
public static String getenv(String name) throws NullPointerException,
SecurityException {
if (getSecurityManager() != null) { // is this allowed?
getSecurityManager().
checkPermission(new RuntimePermission("getenv." + name));
}
return getenv().get(name);
}
public static Map<String, String> getenv() throws SecurityException {
if (getSecurityManager() != null) { // is this allowed?
getSecurityManager().checkPermission(new RuntimePermission("getenv.*"));
}
if (environment == null) { // build environment table
String[] vars = getEnvironment();
environment = new Hashtable<String, String>(vars.length);
for (String var : vars) { // parse name-value pairs
int equalsIndex = var.indexOf('=');
// null names and values are forbidden
if (equalsIndex != -1 && equalsIndex < var.length() - 1) {
environment.put(var.substring(0, equalsIndex),
var.substring(equalsIndex + 1));
}
}
}
return environment;
}
/** Returns the native process environment. */
private static native String[] getEnvironment();
}

View File

@ -329,17 +329,18 @@ ifeq ($(platform),darwin)
sdk-dir = $(developer-dir)/Platforms/iPhoneOS.platform/Developer/SDKs
ios-version := $(shell if test -d $(sdk-dir)/iPhoneOS5.1.sdk; then echo 5.1; \
elif test -d $(sdk-dir)/iPhoneOS5.0.sdk; then echo 5.0; \
elif test -d $(sdk-dir)/iPhoneOS4.3.sdk; then echo 4.3; \
elif test -d $(sdk-dir)/iPhoneOS4.2.sdk; then echo 4.2; \
else echo; fi)
ifeq ($(ios-version),)
x := $(error "couldn't find SDK for iOS version")
endif
ifeq ($(arch),arm)
ios-version := \
$(shell if test -d $(sdk-dir)/iPhoneOS5.1.sdk; then echo 5.1; \
elif test -d $(sdk-dir)/iPhoneOS5.0.sdk; then echo 5.0; \
elif test -d $(sdk-dir)/iPhoneOS4.3.sdk; then echo 4.3; \
elif test -d $(sdk-dir)/iPhoneOS4.2.sdk; then echo 4.2; \
else echo; fi)
ifeq ($(ios-version),)
x := $(error "couldn't find SDK for iOS version")
endif
ifeq ($(build-arch),powerpc)
converter-cflags += -DOPPOSITE_ENDIAN
endif