| From d7fc8bd912b9e86caad962bd85a9ed8a705803fc Mon Sep 17 00:00:00 2001 |
| From: Aaron Madlon-Kay <aaron@madlon-kay.com> |
| Date: Thu, 24 Mar 2016 15:30:01 +0900 |
| Subject: [PATCH] Don't fail to initialize Constants due to SecurityException. |
| Detecting the bitness of the JRE attempts to access sun.arch.data.model, |
| which causes an AccessControlException when running under WebStart. |
| |
| --- |
| .../src/java/org/apache/lucene/util/Constants.java | 18 ++++++++++-------- |
| 1 file changed, 10 insertions(+), 8 deletions(-) |
| |
| diff --git a/lucene/core/src/java/org/apache/lucene/util/Constants.java b/lucene/core/src/java/org/apache/lucene/util/Constants.java |
| index 4a4b494..77882a6 100644 |
| --- a/lucene/core/src/java/org/apache/lucene/util/Constants.java |
| +++ b/lucene/core/src/java/org/apache/lucene/util/Constants.java |
| @@ -68,15 +68,17 @@ public final class Constants { |
| JVM_MINOR_VERSION = 0; |
| } |
| boolean is64Bit = false; |
| - final String x = System.getProperty("sun.arch.data.model"); |
| - if (x != null) { |
| - is64Bit = x.contains("64"); |
| - } else { |
| - if (OS_ARCH != null && OS_ARCH.contains("64")) { |
| - is64Bit = true; |
| - } else { |
| - is64Bit = false; |
| + String datamodel = null; |
| + try { |
| + datamodel = System.getProperty("sun.arch.data.model"); |
| + if (datamodel != null) { |
| + is64Bit = datamodel.contains("64"); |
| } |
| + } catch (SecurityException ex) {} |
| + if (datamodel == null && OS_ARCH != null && OS_ARCH.contains("64")) { |
| + is64Bit = true; |
| + } else { |
| + is64Bit = false; |
| } |
| JRE_IS_64BIT = is64Bit; |
| } |
| -- |
| 2.7.1 |
| |