mirror of
https://github.com/haraldk/TwelveMonkeys.git
synced 2025-08-04 12:05:29 -04:00
Slightly "safer" property lookup, to avoid security exceptions in class init.
This commit is contained in:
parent
0b58e8fb40
commit
e2ea8b1cce
@ -84,11 +84,11 @@ public final class ColorSpaces {
|
|||||||
public static final int CS_GENERIC_CMYK = 5001;
|
public static final int CS_GENERIC_CMYK = 5001;
|
||||||
|
|
||||||
// Weak references to hold the color spaces while cached
|
// Weak references to hold the color spaces while cached
|
||||||
private static WeakReference<ICC_Profile> adobeRGB1998 = new WeakReference<ICC_Profile>(null);
|
private static WeakReference<ICC_Profile> adobeRGB1998 = new WeakReference<>(null);
|
||||||
private static WeakReference<ICC_Profile> genericCMYK = new WeakReference<ICC_Profile>(null);
|
private static WeakReference<ICC_Profile> genericCMYK = new WeakReference<>(null);
|
||||||
|
|
||||||
// Cache for the latest used color spaces
|
// Cache for the latest used color spaces
|
||||||
private static final Map<Key, ICC_ColorSpace> cache = new LRUHashMap<Key, ICC_ColorSpace>(10);
|
private static final Map<Key, ICC_ColorSpace> cache = new LRUHashMap<>(10);
|
||||||
|
|
||||||
private ColorSpaces() {}
|
private ColorSpaces() {}
|
||||||
|
|
||||||
@ -249,7 +249,7 @@ public final class ColorSpaces {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
adobeRGB1998 = new WeakReference<ICC_Profile>(profile);
|
adobeRGB1998 = new WeakReference<>(profile);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -272,7 +272,7 @@ public final class ColorSpaces {
|
|||||||
return CMYKColorSpace.getInstance();
|
return CMYKColorSpace.getInstance();
|
||||||
}
|
}
|
||||||
|
|
||||||
genericCMYK = new WeakReference<ICC_Profile>(profile);
|
genericCMYK = new WeakReference<>(profile);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -367,15 +367,18 @@ public final class ColorSpaces {
|
|||||||
}
|
}
|
||||||
|
|
||||||
private static class Profiles {
|
private static class Profiles {
|
||||||
private static final Properties PROFILES = loadProfiles(Platform.os());
|
private static final Properties PROFILES = loadProfiles();
|
||||||
|
|
||||||
private static Properties loadProfiles(final Platform.OperatingSystem os) {
|
private static Properties loadProfiles() {
|
||||||
Properties systemDefaults;
|
Properties systemDefaults;
|
||||||
|
|
||||||
try {
|
try {
|
||||||
systemDefaults = SystemUtil.loadProperties(ColorSpaces.class, "com/twelvemonkeys/imageio/color/icc_profiles_" + os.id());
|
systemDefaults = SystemUtil.loadProperties(
|
||||||
|
ColorSpaces.class,
|
||||||
|
"com/twelvemonkeys/imageio/color/icc_profiles_" + Platform.os().id()
|
||||||
|
);
|
||||||
}
|
}
|
||||||
catch (IOException ignore) {
|
catch (SecurityException | IOException ignore) {
|
||||||
System.err.printf(
|
System.err.printf(
|
||||||
"Warning: Could not load system default ICC profile locations from %s, will use bundled fallback profiles.\n",
|
"Warning: Could not load system default ICC profile locations from %s, will use bundled fallback profiles.\n",
|
||||||
ignore.getMessage()
|
ignore.getMessage()
|
||||||
@ -392,10 +395,14 @@ public final class ColorSpaces {
|
|||||||
Properties profiles = new Properties(systemDefaults);
|
Properties profiles = new Properties(systemDefaults);
|
||||||
|
|
||||||
try {
|
try {
|
||||||
Properties userOverrides = SystemUtil.loadProperties(ColorSpaces.class, "com/twelvemonkeys/imageio/color/icc_profiles");
|
Properties userOverrides = SystemUtil.loadProperties(
|
||||||
|
ColorSpaces.class,
|
||||||
|
"com/twelvemonkeys/imageio/color/icc_profiles"
|
||||||
|
);
|
||||||
profiles.putAll(userOverrides);
|
profiles.putAll(userOverrides);
|
||||||
}
|
}
|
||||||
catch (IOException ignore) {
|
catch (SecurityException | IOException ignore) {
|
||||||
|
// Most likely, this file won't be there
|
||||||
}
|
}
|
||||||
|
|
||||||
if (DEBUG) {
|
if (DEBUG) {
|
||||||
|
Loading…
x
Reference in New Issue
Block a user