8185496: Improve performance of system properties initialization in initPhase1
8213424: VersionProps duplicate and skipped initialization Reviewed-by: mchung, redestad, dholmes
This commit is contained in:
parent
1b20a6781f
commit
29e742273e
src
hotspot/share/prims
java.base
share
classes
native/libjava
unix/native/libjava
windows/native/libjava
test/jdk/java
lang/System
util/concurrent/atomic
@ -364,6 +364,8 @@ JVM_ENTRY(jobject, JVM_InitProperties(JNIEnv *env, jobject properties))
|
||||
// System property list includes both user set via -D option and
|
||||
// jvm system specific properties.
|
||||
for (SystemProperty* p = Arguments::system_properties(); p != NULL; p = p->next()) {
|
||||
if (strcmp(p->key(), "sun.nio.MaxDirectMemorySize") == 0) // Can not be defined with -D
|
||||
continue;
|
||||
PUTPROP(props, p->key(), p->value());
|
||||
}
|
||||
|
||||
@ -371,14 +373,11 @@ JVM_ENTRY(jobject, JVM_InitProperties(JNIEnv *env, jobject properties))
|
||||
// to the sun.nio.MaxDirectMemorySize property.
|
||||
// Do this after setting user properties to prevent people
|
||||
// from setting the value with a -D option, as requested.
|
||||
{
|
||||
if (FLAG_IS_DEFAULT(MaxDirectMemorySize)) {
|
||||
PUTPROP(props, "sun.nio.MaxDirectMemorySize", "-1");
|
||||
} else {
|
||||
char as_chars[256];
|
||||
jio_snprintf(as_chars, sizeof(as_chars), JULONG_FORMAT, MaxDirectMemorySize);
|
||||
PUTPROP(props, "sun.nio.MaxDirectMemorySize", as_chars);
|
||||
}
|
||||
// Leave empty if not supplied
|
||||
if (!FLAG_IS_DEFAULT(MaxDirectMemorySize)) {
|
||||
char as_chars[256];
|
||||
jio_snprintf(as_chars, sizeof(as_chars), JULONG_FORMAT, MaxDirectMemorySize);
|
||||
PUTPROP(props, "sun.nio.MaxDirectMemorySize", as_chars);
|
||||
}
|
||||
|
||||
// JVM monitoring and management support
|
||||
|
@ -802,6 +802,7 @@ public final class System {
|
||||
if (props == null) {
|
||||
props = new Properties();
|
||||
initProperties(props);
|
||||
VersionProps.init(props);
|
||||
}
|
||||
System.props = props;
|
||||
}
|
||||
@ -1973,6 +1974,7 @@ public final class System {
|
||||
// be put into it directly.
|
||||
props = new Properties(84);
|
||||
initProperties(props); // initialized by the VM
|
||||
VersionProps.init(props);
|
||||
|
||||
// There are certain system configurations that may be controlled by
|
||||
// VM options such as the maximum amount of direct memory and
|
||||
@ -1992,7 +1994,6 @@ public final class System {
|
||||
|
||||
lineSeparator = props.getProperty("line.separator");
|
||||
StaticProperty.javaHome(); // Load StaticProperty to cache the property values
|
||||
VersionProps.init();
|
||||
|
||||
FileInputStream fdIn = new FileInputStream(FileDescriptor.in);
|
||||
FileOutputStream fdOut = new FileOutputStream(FileDescriptor.out);
|
||||
|
@ -29,6 +29,7 @@ import java.io.PrintStream;
|
||||
import java.util.Arrays;
|
||||
import java.util.List;
|
||||
import java.util.Optional;
|
||||
import java.util.Properties;
|
||||
|
||||
class VersionProps {
|
||||
|
||||
@ -69,17 +70,13 @@ class VersionProps {
|
||||
(VENDOR_VERSION_STRING.length() > 0
|
||||
? " " + VENDOR_VERSION_STRING : "");
|
||||
|
||||
static {
|
||||
init();
|
||||
}
|
||||
|
||||
public static void init() {
|
||||
System.setProperty("java.version", java_version);
|
||||
System.setProperty("java.version.date", java_version_date);
|
||||
System.setProperty("java.runtime.version", java_runtime_version);
|
||||
System.setProperty("java.runtime.name", java_runtime_name);
|
||||
public static void init(Properties props) {
|
||||
props.setProperty("java.version", java_version);
|
||||
props.setProperty("java.version.date", java_version_date);
|
||||
props.setProperty("java.runtime.version", java_runtime_version);
|
||||
props.setProperty("java.runtime.name", java_runtime_name);
|
||||
if (VENDOR_VERSION_STRING.length() > 0)
|
||||
System.setProperty("java.vendor.version", VENDOR_VERSION_STRING);
|
||||
props.setProperty("java.vendor.version", VENDOR_VERSION_STRING);
|
||||
}
|
||||
|
||||
private static int parseVersionNumber(String version, int prevIndex, int index) {
|
||||
|
@ -199,17 +199,16 @@ public class VM {
|
||||
// by the vm option -XX:MaxDirectMemorySize=<size>.
|
||||
// The maximum amount of allocatable direct buffer memory (in bytes)
|
||||
// from the system property sun.nio.MaxDirectMemorySize set by the VM.
|
||||
// If not set or set to -1, the max memory will be used
|
||||
// The system property will be removed.
|
||||
String s = (String)props.remove("sun.nio.MaxDirectMemorySize");
|
||||
if (s != null) {
|
||||
if (s.equals("-1")) {
|
||||
// -XX:MaxDirectMemorySize not given, take default
|
||||
directMemory = Runtime.getRuntime().maxMemory();
|
||||
} else {
|
||||
long l = Long.parseLong(s);
|
||||
if (l > -1)
|
||||
directMemory = l;
|
||||
}
|
||||
if (s == null || s.isEmpty() || s.equals("-1")) {
|
||||
// -XX:MaxDirectMemorySize not given, take default
|
||||
directMemory = Runtime.getRuntime().maxMemory();
|
||||
} else {
|
||||
long l = Long.parseLong(s);
|
||||
if (l > -1)
|
||||
directMemory = l;
|
||||
}
|
||||
|
||||
// Check if direct buffers should be page aligned
|
||||
|
@ -211,7 +211,6 @@ Java_java_lang_System_initProperties(JNIEnv *env, jclass cla, jobject props)
|
||||
PUTPROP(props, "java.specification.vendor",
|
||||
JAVA_SPECIFICATION_VENDOR);
|
||||
|
||||
PUTPROP(props, "java.version", VERSION_SHORT);
|
||||
PUTPROP(props, "java.vendor", VENDOR);
|
||||
PUTPROP(props, "java.vendor.url", VENDOR_URL);
|
||||
PUTPROP(props, "java.vendor.url.bug", VENDOR_URL_BUG);
|
||||
@ -255,8 +254,10 @@ Java_java_lang_System_initProperties(JNIEnv *env, jclass cla, jobject props)
|
||||
|
||||
/* unicode_encoding specifies the default endianness */
|
||||
PUTPROP(props, "sun.io.unicode.encoding", sprops->unicode_encoding);
|
||||
PUTPROP(props, "sun.cpu.isalist",
|
||||
(sprops->cpu_isalist ? sprops->cpu_isalist : ""));
|
||||
if (sprops->cpu_isalist != NULL) {
|
||||
// leave undefined if none
|
||||
PUTPROP(props, "sun.cpu.isalist", sprops->cpu_isalist);
|
||||
}
|
||||
PUTPROP(props, "sun.cpu.endian", sprops->cpu_endian);
|
||||
|
||||
|
||||
@ -330,8 +331,10 @@ Java_java_lang_System_initProperties(JNIEnv *env, jclass cla, jobject props)
|
||||
sprops->data_model);
|
||||
|
||||
/* patch level */
|
||||
PUTPROP(props, "sun.os.patch.level", \
|
||||
if (sprops->patch_level != NULL) {
|
||||
PUTPROP(props, "sun.os.patch.level", \
|
||||
sprops->patch_level);
|
||||
}
|
||||
|
||||
/* Java2D properties */
|
||||
/* Note: java.awt.graphicsenv is an implementation private property which
|
||||
@ -354,9 +357,6 @@ Java_java_lang_System_initProperties(JNIEnv *env, jclass cla, jobject props)
|
||||
|
||||
PUTPROP_ForPlatformNString(props, "user.name", sprops->user_name);
|
||||
PUTPROP_ForPlatformNString(props, "user.home", sprops->user_home);
|
||||
|
||||
PUTPROP(props, "user.timezone", sprops->timezone);
|
||||
|
||||
PUTPROP_ForPlatformNString(props, "user.dir", sprops->user_dir);
|
||||
|
||||
/* This is a sun. property as it is currently only set for Gnome and
|
||||
|
@ -56,23 +56,18 @@ typedef struct {
|
||||
nchar *user_name;
|
||||
nchar *user_home;
|
||||
|
||||
char *language;
|
||||
char *format_language;
|
||||
char *display_language;
|
||||
char *script;
|
||||
char *format_script;
|
||||
char *display_script;
|
||||
char *country;
|
||||
char *format_country;
|
||||
char *display_country;
|
||||
char *variant;
|
||||
char *format_variant;
|
||||
char *display_variant;
|
||||
char *encoding;
|
||||
char *sun_jnu_encoding;
|
||||
char *sun_stdout_encoding;
|
||||
char *sun_stderr_encoding;
|
||||
char *timezone;
|
||||
|
||||
char *printerJob;
|
||||
char *graphics_env;
|
||||
|
@ -399,7 +399,7 @@ GetJavaProperties(JNIEnv *env)
|
||||
#endif
|
||||
|
||||
/* patches/service packs installed */
|
||||
sprops.patch_level = "unknown";
|
||||
sprops.patch_level = NULL; // leave it undefined
|
||||
|
||||
/* Java 2D/AWT properties */
|
||||
#ifdef MACOSX
|
||||
@ -488,19 +488,15 @@ GetJavaProperties(JNIEnv *env)
|
||||
&(sprops.format_variant),
|
||||
&(sprops.encoding))) {
|
||||
ParseLocale(env, LC_MESSAGES,
|
||||
&(sprops.language),
|
||||
&(sprops.script),
|
||||
&(sprops.country),
|
||||
&(sprops.variant),
|
||||
&(sprops.display_language),
|
||||
&(sprops.display_script),
|
||||
&(sprops.display_country),
|
||||
&(sprops.display_variant),
|
||||
NULL);
|
||||
} else {
|
||||
sprops.language = "en";
|
||||
sprops.display_language = "en";
|
||||
sprops.encoding = "ISO8859-1";
|
||||
}
|
||||
sprops.display_language = sprops.language;
|
||||
sprops.display_script = sprops.script;
|
||||
sprops.display_country = sprops.country;
|
||||
sprops.display_variant = sprops.variant;
|
||||
|
||||
/* ParseLocale failed with OOME */
|
||||
JNU_CHECK_EXCEPTION_RETURN(env, NULL);
|
||||
@ -543,18 +539,12 @@ GetJavaProperties(JNIEnv *env)
|
||||
}
|
||||
}
|
||||
|
||||
/* User TIMEZONE */
|
||||
{
|
||||
/*
|
||||
* We defer setting up timezone until it's actually necessary.
|
||||
* Refer to TimeZone.getDefault(). However, the system
|
||||
* property is necessary to be able to be set by the command
|
||||
* line interface -D. Here temporarily set a null string to
|
||||
* timezone.
|
||||
*/
|
||||
tzset(); /* for compatibility */
|
||||
sprops.timezone = "";
|
||||
}
|
||||
/* User TIMEZONE
|
||||
* We defer setting up timezone until it's actually necessary.
|
||||
* Refer to TimeZone.getDefault(). The system property
|
||||
* is able to be set by the command line interface -Duser.timezone.
|
||||
*/
|
||||
tzset(); /* for compatibility */
|
||||
|
||||
/* Current directory */
|
||||
{
|
||||
|
@ -661,12 +661,6 @@ GetJavaProperties(JNIEnv* env)
|
||||
userDefaultUILang = userDefaultLCID;
|
||||
}
|
||||
|
||||
SetupI18nProps(userDefaultUILang,
|
||||
&sprops.language,
|
||||
&sprops.script,
|
||||
&sprops.country,
|
||||
&sprops.variant,
|
||||
&display_encoding);
|
||||
SetupI18nProps(userDefaultLCID,
|
||||
&sprops.format_language,
|
||||
&sprops.format_script,
|
||||
@ -710,17 +704,12 @@ GetJavaProperties(JNIEnv* env)
|
||||
}
|
||||
|
||||
sprops.unicode_encoding = "UnicodeLittle";
|
||||
/* User TIMEZONE */
|
||||
{
|
||||
/*
|
||||
* We defer setting up timezone until it's actually necessary.
|
||||
* Refer to TimeZone.getDefault(). However, the system
|
||||
* property is necessary to be able to be set by the command
|
||||
* line interface -D. Here temporarily set a null string to
|
||||
* timezone.
|
||||
*/
|
||||
sprops.timezone = "";
|
||||
}
|
||||
|
||||
/* User TIMEZONE
|
||||
* We defer setting up timezone until it's actually necessary.
|
||||
* Refer to TimeZone.getDefault(). The system property
|
||||
* is able to be set by the command line interface -Duser.timezone.
|
||||
*/
|
||||
|
||||
/* Current directory */
|
||||
{
|
||||
|
@ -1,60 +0,0 @@
|
||||
/*
|
||||
* Copyright (c) 2018, Oracle and/or its affiliates. All rights reserved.
|
||||
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
|
||||
*
|
||||
* This code is free software; you can redistribute it and/or modify it
|
||||
* under the terms of the GNU General Public License version 2 only, as
|
||||
* published by the Free Software Foundation.
|
||||
*
|
||||
* This code is distributed in the hope that it will be useful, but WITHOUT
|
||||
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
|
||||
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
|
||||
* version 2 for more details (a copy is included in the LICENSE file that
|
||||
* accompanied this code).
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License version
|
||||
* 2 along with this work; if not, write to the Free Software Foundation,
|
||||
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
|
||||
*
|
||||
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
|
||||
* or visit www.oracle.com if you need additional information or have any
|
||||
* questions.
|
||||
*/
|
||||
|
||||
/*
|
||||
* @test
|
||||
* @bug 4463345
|
||||
* @summary Simple test of System.clearProperty
|
||||
* @run main/othervm ClearProperty
|
||||
*/
|
||||
|
||||
public class ClearProperty {
|
||||
public static void main(String [] argv) throws Exception {
|
||||
clearTest();
|
||||
paramTest();
|
||||
}
|
||||
|
||||
static void clearTest() throws Exception {
|
||||
System.setProperty("blah", "blech");
|
||||
if (!System.getProperty("blah").equals("blech"))
|
||||
throw new RuntimeException("Clear test failed 1");
|
||||
System.clearProperty("blah");
|
||||
if (System.getProperty("blah") != null)
|
||||
throw new RuntimeException("Clear test failed 2");
|
||||
}
|
||||
|
||||
static void paramTest() throws Exception {
|
||||
try {
|
||||
System.clearProperty(null);
|
||||
throw new RuntimeException("Param test failed");
|
||||
} catch (NullPointerException npe) {
|
||||
// Correct result
|
||||
}
|
||||
try {
|
||||
System.clearProperty("");
|
||||
throw new RuntimeException("Param test failed");
|
||||
} catch (IllegalArgumentException iae) {
|
||||
// Correct result
|
||||
}
|
||||
}
|
||||
}
|
260
test/jdk/java/lang/System/PropertyTest.java
Normal file
260
test/jdk/java/lang/System/PropertyTest.java
Normal file
@ -0,0 +1,260 @@
|
||||
/*
|
||||
* Copyright (c) 2018, Oracle and/or its affiliates. All rights reserved.
|
||||
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
|
||||
*
|
||||
* This code is free software; you can redistribute it and/or modify it
|
||||
* under the terms of the GNU General Public License version 2 only, as
|
||||
* published by the Free Software Foundation.
|
||||
*
|
||||
* This code is distributed in the hope that it will be useful, but WITHOUT
|
||||
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
|
||||
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
|
||||
* version 2 for more details (a copy is included in the LICENSE file that
|
||||
* accompanied this code).
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License version
|
||||
* 2 along with this work; if not, write to the Free Software Foundation,
|
||||
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
|
||||
*
|
||||
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
|
||||
* or visit www.oracle.com if you need additional information or have any
|
||||
* questions.
|
||||
*/
|
||||
|
||||
import java.lang.System;
|
||||
import java.util.Arrays;
|
||||
import java.util.List;
|
||||
import java.util.Objects;
|
||||
import java.util.Properties;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
import org.testng.Assert;
|
||||
import org.testng.IMethodInstance;
|
||||
import org.testng.IMethodInterceptor;
|
||||
import org.testng.TestListenerAdapter;
|
||||
import org.testng.TestNG;
|
||||
import org.testng.annotations.BeforeTest;
|
||||
import org.testng.annotations.DataProvider;
|
||||
import org.testng.annotations.Test;
|
||||
|
||||
|
||||
/*
|
||||
* @test
|
||||
* @bug 4463345 4244670 8030781
|
||||
* @summary Simple test of System getProperty, setProperty, clearProperty,
|
||||
* getProperties, and setProperties
|
||||
* @run testng/othervm PropertyTest
|
||||
*/
|
||||
|
||||
@Test
|
||||
public class PropertyTest {
|
||||
|
||||
@DataProvider(name = "requiredProperties")
|
||||
static Object[][] requiredProperties() {
|
||||
return new Object[][]{
|
||||
{"java.version"},
|
||||
{"java.version.date"},
|
||||
{"java.vendor"},
|
||||
{"java.vendor.url"},
|
||||
{"java.home"},
|
||||
{"java.vm.specification.version"},
|
||||
{"java.vm.specification.vendor"},
|
||||
{"java.vm.specification.name"},
|
||||
{"java.vm.version"},
|
||||
{"java.vm.vendor"},
|
||||
{"java.vm.name"},
|
||||
{"java.specification.version"},
|
||||
{"java.specification.vendor"},
|
||||
{"java.specification.name"},
|
||||
{"java.class.version"},
|
||||
{"java.class.path"},
|
||||
{"java.library.path"},
|
||||
{"java.io.tmpdir"},
|
||||
{"os.arch"},
|
||||
{"os.version"},
|
||||
{"file.separator"},
|
||||
{"path.separator"},
|
||||
{"line.separator"},
|
||||
{"user.name"},
|
||||
{"user.home"},
|
||||
{"user.dir"},
|
||||
{"java.runtime.version"},
|
||||
{"java.runtime.name"},
|
||||
};
|
||||
}
|
||||
|
||||
@Test
|
||||
static void getTest() {
|
||||
System.setProperty("blah", "blech");
|
||||
Assert.assertEquals(System.getProperty("blah"), "blech");
|
||||
|
||||
try {
|
||||
System.getProperty(null);
|
||||
Assert.fail("Failed: expected NullPointerException");
|
||||
} catch (NullPointerException npe) {
|
||||
// Correct result
|
||||
}
|
||||
try {
|
||||
System.getProperty("");
|
||||
Assert.fail("Failed: expected IllegalArgumentException");
|
||||
} catch (IllegalArgumentException iae) {
|
||||
// Correct result
|
||||
}
|
||||
}
|
||||
|
||||
@Test
|
||||
static void clearTest() {
|
||||
System.setProperty("blah", "blech");
|
||||
Assert.assertEquals(System.getProperty("blah"), "blech");
|
||||
|
||||
System.clearProperty("blah");
|
||||
Assert.assertNull(System.getProperty("blah"));
|
||||
|
||||
try {
|
||||
System.clearProperty(null);
|
||||
Assert.fail("Failed: expected NullPointerException");
|
||||
} catch (NullPointerException npe) {
|
||||
// Correct result
|
||||
}
|
||||
try {
|
||||
System.clearProperty("");
|
||||
Assert.fail("Failed: expected IllegalArgumentException");
|
||||
} catch (IllegalArgumentException iae) {
|
||||
// Correct result
|
||||
}
|
||||
}
|
||||
|
||||
@Test
|
||||
static void setTest() {
|
||||
System.setProperty("blah", "blech");
|
||||
Assert.assertEquals(System.getProperty("blah"), "blech");
|
||||
|
||||
System.setProperty("blah", "");
|
||||
Assert.assertEquals(System.getProperty("blah"), "");
|
||||
|
||||
try {
|
||||
System.setProperty(null, null);
|
||||
Assert.fail("Failed: expected NullPointerException");
|
||||
} catch (NullPointerException npe) {
|
||||
// Correct result
|
||||
}
|
||||
|
||||
try {
|
||||
System.setProperty("blah", null);
|
||||
Assert.fail("Failed: expected NullPointerException");
|
||||
} catch (NullPointerException npe) {
|
||||
// Correct result
|
||||
}
|
||||
|
||||
try {
|
||||
System.setProperty(null, "blech");
|
||||
Assert.fail("Failed: expected NullPointerException");
|
||||
} catch (NullPointerException npe) {
|
||||
// Correct result
|
||||
}
|
||||
|
||||
try {
|
||||
System.setProperty("", "blech");
|
||||
Assert.fail("Failed: expected IllegalArgumentException");
|
||||
} catch (IllegalArgumentException iae) {
|
||||
// Correct result
|
||||
}
|
||||
try {
|
||||
System.setProperty("", "");
|
||||
Assert.fail("Failed: expected IllegalArgumentException");
|
||||
} catch (IllegalArgumentException iae) {
|
||||
// Correct result
|
||||
}
|
||||
}
|
||||
|
||||
@Test
|
||||
static void replaceSetProperties() {
|
||||
Properties oldProps = System.getProperties();
|
||||
Properties newProps = new Properties();
|
||||
oldProps.forEach( (k,v) -> newProps.put(k,v));
|
||||
System.setProperties(newProps);
|
||||
|
||||
Assert.assertSame(System.getProperties(), newProps,
|
||||
"getProperties not the same as setProperties");
|
||||
|
||||
final String KEY = "blah";
|
||||
final String VALUE = "blech";
|
||||
|
||||
// Set via Property instance; get via System methods
|
||||
newProps.setProperty(KEY, VALUE);
|
||||
Assert.assertEquals(System.getProperty(KEY), VALUE, KEY);
|
||||
|
||||
String s = (String)newProps.remove(KEY);
|
||||
Assert.assertEquals(s, VALUE);
|
||||
Assert.assertNull(System.getProperty(KEY), KEY);
|
||||
|
||||
// Set via System methods; Get via Property instance;
|
||||
System.setProperty(KEY, VALUE);
|
||||
Assert.assertEquals(newProps.getProperty(KEY), VALUE);
|
||||
|
||||
String t = System.clearProperty(KEY);
|
||||
Assert.assertEquals(t, VALUE, KEY);
|
||||
Assert.assertNull(newProps.getProperty(KEY), KEY);
|
||||
}
|
||||
|
||||
@Test
|
||||
static void setNullProperties() {
|
||||
Properties oldProps = System.getProperties();
|
||||
Properties savedProps = new Properties();
|
||||
oldProps.forEach((k,v) -> {
|
||||
if (v == null) {
|
||||
throw new RuntimeException("null value, key: " + k);
|
||||
}
|
||||
savedProps.put(k,v);
|
||||
});
|
||||
|
||||
// Re-initialize properties
|
||||
System.setProperties(null);
|
||||
|
||||
Properties newProps = System.getProperties();
|
||||
Object[][] propnames = requiredProperties();
|
||||
for (Object[] p : propnames) {
|
||||
String name = (String)p[0];
|
||||
Assert.assertEquals(System.getProperty(name), savedProps.getProperty(name), name);
|
||||
|
||||
Assert.assertEquals(newProps.getProperty(name), savedProps.getProperty(name), name);
|
||||
}
|
||||
}
|
||||
|
||||
// Verify all the required properties have values from System.getProperty and
|
||||
// System.getProperties()
|
||||
@Test(dataProvider = "requiredProperties")
|
||||
static void checkRequiredProperties(String name) {
|
||||
Assert.assertNotNull(System.getProperty(name), name);
|
||||
|
||||
Properties props = System.getProperties();
|
||||
Assert.assertNotNull(props.getProperty(name), name);
|
||||
}
|
||||
|
||||
@SuppressWarnings("raw_types")
|
||||
@Test(enabled=false)
|
||||
public static void main(String[] args) {
|
||||
TestListenerAdapter tla = new TestListenerAdapter();
|
||||
|
||||
Class<?>[] testclass = {PropertyTest.class};
|
||||
TestNG testng = new TestNG();
|
||||
testng.setTestClasses(testclass);
|
||||
testng.addListener(tla);
|
||||
if (args.length > 0) {
|
||||
IMethodInterceptor intercept = (m, c) -> {
|
||||
List<IMethodInstance> x = m.stream()
|
||||
.filter(m1 -> m1.getMethod().getMethodName().contains(args[0]))
|
||||
.collect(Collectors.toList());
|
||||
return x;
|
||||
};
|
||||
testng.setMethodInterceptor(intercept);
|
||||
}
|
||||
testng.run();
|
||||
tla.getPassedTests()
|
||||
.stream().forEach(t -> System.out.printf("Passed: %s%s%n", t.getName(),
|
||||
List.of(t.getParameters())));
|
||||
tla.getFailedTests()
|
||||
.stream().forEach(t -> System.out.printf("Failed: %s%s%n", t.getName(),
|
||||
List.of(t.getParameters())));
|
||||
}
|
||||
}
|
@ -1,44 +0,0 @@
|
||||
/*
|
||||
* Copyright (c) 2014, 2018, Oracle and/or its affiliates. All rights reserved.
|
||||
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
|
||||
*
|
||||
* This code is free software; you can redistribute it and/or modify it
|
||||
* under the terms of the GNU General Public License version 2 only, as
|
||||
* published by the Free Software Foundation.
|
||||
*
|
||||
* This code is distributed in the hope that it will be useful, but WITHOUT
|
||||
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
|
||||
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
|
||||
* version 2 for more details (a copy is included in the LICENSE file that
|
||||
* accompanied this code).
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License version
|
||||
* 2 along with this work; if not, write to the Free Software Foundation,
|
||||
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
|
||||
*
|
||||
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
|
||||
* or visit www.oracle.com if you need additional information or have any
|
||||
* questions.
|
||||
*/
|
||||
|
||||
/*
|
||||
* This class tests to see if the system property java.version is properly
|
||||
* reinitialized after setting System.setProperties(null).
|
||||
*
|
||||
* @test
|
||||
* @bug 4244670 8030781
|
||||
* @summary Test for System.setProperties(null).
|
||||
*/
|
||||
|
||||
public class SetPropertiesNull {
|
||||
|
||||
public static void main(String args[]) {
|
||||
final String version = System.getProperty("java.version");
|
||||
System.setProperties(null);
|
||||
final String newVersion = System.getProperty("java.version");
|
||||
if (!version.equals(newVersion)) {
|
||||
throw new RuntimeException("java.version differs: '" + version + "' '"
|
||||
+ newVersion + "'");
|
||||
}
|
||||
}
|
||||
}
|
@ -33,7 +33,8 @@ import java.lang.reflect.Field;
|
||||
|
||||
public class VMSupportsCS8 {
|
||||
public static void main(String[] args) throws Exception {
|
||||
if (System.getProperty("sun.cpu.isalist").matches
|
||||
String isalist = System.getProperty("sun.cpu.isalist");
|
||||
if (isalist != null && isalist.matches
|
||||
(".*\\b(sparcv9|pentium_pro|ia64|amd64).*")
|
||||
||
|
||||
System.getProperty("os.arch").matches
|
||||
|
Loading…
x
Reference in New Issue
Block a user