< prev index next >
src/java.base/share/classes/com/sun/java/util/jar/pack/PropMap.java
Print this page
*** 27,36 ****
--- 27,38 ----
import java.io.IOException;
import java.io.InputStream;
import java.io.PrintStream;
import java.io.PrintWriter;
+ import java.security.AccessController;
+ import java.security.PrivilegedAction;
import java.util.ArrayList;
import java.util.Collection;
import java.util.Comparator;
import java.util.HashMap;
import java.util.List;
*** 60,75 ****
private static Map<String, String> defaultProps;
static {
Properties props = new Properties();
// Allow implementation selected via -Dpack.disable.native=true
props.put(Utils.DEBUG_DISABLE_NATIVE,
! String.valueOf(Boolean.getBoolean(Utils.DEBUG_DISABLE_NATIVE)));
// Set the DEBUG_VERBOSE from system
! props.put(Utils.DEBUG_VERBOSE,
! String.valueOf(Integer.getInteger(Utils.DEBUG_VERBOSE,0)));
// The segment size is unlimited
props.put(Pack200.Packer.SEGMENT_LIMIT, "-1");
// Preserve file ordering by default.
--- 62,82 ----
private static Map<String, String> defaultProps;
static {
Properties props = new Properties();
// Allow implementation selected via -Dpack.disable.native=true
+ String propValue = getPropertyValue(Utils.DEBUG_DISABLE_NATIVE, "false");
props.put(Utils.DEBUG_DISABLE_NATIVE,
! String.valueOf(Boolean.parseBoolean(propValue)));
// Set the DEBUG_VERBOSE from system
! int verbose = 0;
! try {
! verbose = Integer.decode(getPropertyValue(Utils.DEBUG_VERBOSE, "0"));
! } catch (NumberFormatException e) {
! }
! props.put(Utils.DEBUG_VERBOSE, String.valueOf(verbose));
// The segment size is unlimited
props.put(Pack200.Packer.SEGMENT_LIMIT, "-1");
// Preserve file ordering by default.
*** 85,105 ****
props.put(Pack200.Packer.UNKNOWN_ATTRIBUTE, Pack200.Packer.PASS);
// Pass through files with unrecognized format by default, also
// allow system property to be set
props.put(Utils.CLASS_FORMAT_ERROR,
! System.getProperty(Utils.CLASS_FORMAT_ERROR, Pack200.Packer.PASS));
// Default effort is 5, midway between 1 and 9.
props.put(Pack200.Packer.EFFORT, "5");
// Define certain attribute layouts by default.
// Do this after the previous props are put in place,
// to allow override if necessary.
String propFile = "intrinsic.properties";
! try (InputStream propStr = PackerImpl.class.getResourceAsStream(propFile)) {
if (propStr == null) {
throw new RuntimeException(propFile + " cannot be loaded");
}
props.load(propStr);
} catch (IOException ee) {
--- 92,114 ----
props.put(Pack200.Packer.UNKNOWN_ATTRIBUTE, Pack200.Packer.PASS);
// Pass through files with unrecognized format by default, also
// allow system property to be set
props.put(Utils.CLASS_FORMAT_ERROR,
! getPropertyValue(Utils.CLASS_FORMAT_ERROR, Pack200.Packer.PASS));
// Default effort is 5, midway between 1 and 9.
props.put(Pack200.Packer.EFFORT, "5");
// Define certain attribute layouts by default.
// Do this after the previous props are put in place,
// to allow override if necessary.
String propFile = "intrinsic.properties";
! PrivilegedAction<InputStream> pa =
! () -> PackerImpl.class.getResourceAsStream(propFile);
! try (InputStream propStr = AccessController.doPrivileged(pa)) {
if (propStr == null) {
throw new RuntimeException(propFile + " cannot be loaded");
}
props.load(propStr);
} catch (IOException ee) {
*** 117,126 ****
--- 126,141 ----
@SuppressWarnings({"unchecked", "rawtypes"})
HashMap<String, String> temp = new HashMap(props); // shrink to fit
defaultProps = temp;
}
+ private static String getPropertyValue(String key, String defaultValue) {
+ PrivilegedAction<String> pa = () -> System.getProperty(key);
+ String s = AccessController.doPrivileged(pa);
+ return s != null ? s : defaultValue;
+ }
+
PropMap() {
theMap.putAll(defaultProps);
}
// Return a view of this map which includes only properties
< prev index next >