summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorIan Rogers <irogers@google.com>2014-05-14 15:29:35 -0700
committerIan Rogers <irogers@google.com>2014-05-14 15:29:46 -0700
commit5d5d14fd97aa8d7adf00911a9b337b9a88da41cd (patch)
tree8f4253bf8ca06c31ef079c9413fa1ca1549a1e4c
parente3e2c471b2504335e99ed15975c3c5c9dfbf2795 (diff)
downloadbase-5d5d14fd97aa8d7adf00911a9b337b9a88da41cd.tar.gz
Move FLATTENED_PATTERN to inner class.
Avoid AOT compilation/initialization in ART failing due to regex.Pattern requiring native support. Bug: 14646037 Change-Id: I9d9c7fd9ed9fab7e21d37f9b31c00d037fc5a691
-rw-r--r--graphics/java/android/graphics/Rect.java16
1 files changed, 14 insertions, 2 deletions
diff --git a/graphics/java/android/graphics/Rect.java b/graphics/java/android/graphics/Rect.java
index 8b5609f9eb5d..437d2f485d44 100644
--- a/graphics/java/android/graphics/Rect.java
+++ b/graphics/java/android/graphics/Rect.java
@@ -36,9 +36,21 @@ public final class Rect implements Parcelable {
public int right;
public int bottom;
- private static final Pattern FLATTENED_PATTERN = Pattern.compile(
+ /**
+ * A helper class for flattened rectange pattern recognition. A separate
+ * class to avoid an initialization dependency on a regular expression
+ * causing Rect to not be initializable with an ahead-of-time compilation
+ * scheme.
+ */
+ private static final class UnflattenHelper {
+ private static final Pattern FLATTENED_PATTERN = Pattern.compile(
"(-?\\d+) (-?\\d+) (-?\\d+) (-?\\d+)");
+ static Matcher getMatcher(String str) {
+ return FLATTENED_PATTERN.matcher(str);
+ }
+ }
+
/**
* Create a new empty Rect. All coordinates are initialized to 0.
*/
@@ -152,7 +164,7 @@ public final class Rect implements Parcelable {
* or null if the string is not of that form.
*/
public static Rect unflattenFromString(String str) {
- Matcher matcher = FLATTENED_PATTERN.matcher(str);
+ Matcher matcher = UnflattenHelper.getMatcher(str);
if (!matcher.matches()) {
return null;
}