Merge "SigAlgParams and other tests"
diff --git a/luni/src/main/java/java/util/regex/Matcher.java b/luni/src/main/java/java/util/regex/Matcher.java
index 162fe53..320e14c 100644
--- a/luni/src/main/java/java/util/regex/Matcher.java
+++ b/luni/src/main/java/java/util/regex/Matcher.java
@@ -31,7 +31,7 @@
* The address of the native peer.
* Uses of this must be manually synchronized to avoid native crashes.
*/
- private int address;
+ private long address;
/**
* Holds the input text.
@@ -656,16 +656,16 @@
}
}
- private static native void closeImpl(int addr);
- private static native boolean findImpl(int addr, String s, int startIndex, int[] offsets);
- private static native boolean findNextImpl(int addr, String s, int[] offsets);
- private static native int groupCountImpl(int addr);
- private static native boolean hitEndImpl(int addr);
- private static native boolean lookingAtImpl(int addr, String s, int[] offsets);
- private static native boolean matchesImpl(int addr, String s, int[] offsets);
- private static native int openImpl(int patternAddr);
- private static native boolean requireEndImpl(int addr);
- private static native void setInputImpl(int addr, String s, int start, int end);
- private static native void useAnchoringBoundsImpl(int addr, boolean value);
- private static native void useTransparentBoundsImpl(int addr, boolean value);
+ private static native void closeImpl(long addr);
+ private static native boolean findImpl(long addr, String s, int startIndex, int[] offsets);
+ private static native boolean findNextImpl(long addr, String s, int[] offsets);
+ private static native int groupCountImpl(long addr);
+ private static native boolean hitEndImpl(long addr);
+ private static native boolean lookingAtImpl(long addr, String s, int[] offsets);
+ private static native boolean matchesImpl(long addr, String s, int[] offsets);
+ private static native long openImpl(long patternAddr);
+ private static native boolean requireEndImpl(long addr);
+ private static native void setInputImpl(long addr, String s, int start, int end);
+ private static native void useAnchoringBoundsImpl(long addr, boolean value);
+ private static native void useTransparentBoundsImpl(long addr, boolean value);
}
diff --git a/luni/src/main/java/java/util/regex/Pattern.java b/luni/src/main/java/java/util/regex/Pattern.java
index cbd5965..44b749e 100644
--- a/luni/src/main/java/java/util/regex/Pattern.java
+++ b/luni/src/main/java/java/util/regex/Pattern.java
@@ -285,7 +285,7 @@
private final String pattern;
private final int flags;
- transient int address;
+ transient long address;
/**
* Returns a {@link Matcher} for this pattern applied to the given {@code input}.
@@ -452,6 +452,6 @@
compile();
}
- private static native void closeImpl(int addr);
- private static native int compileImpl(String regex, int flags);
+ private static native void closeImpl(long addr);
+ private static native long compileImpl(String regex, int flags);
}
diff --git a/luni/src/main/native/java_util_regex_Matcher.cpp b/luni/src/main/native/java_util_regex_Matcher.cpp
index 9b58301..2e5259e 100644
--- a/luni/src/main/native/java_util_regex_Matcher.cpp
+++ b/luni/src/main/native/java_util_regex_Matcher.cpp
@@ -30,7 +30,7 @@
// ICU documentation: http://icu-project.org/apiref/icu4c/classRegexMatcher.html
-static RegexMatcher* toRegexMatcher(jint address) {
+static RegexMatcher* toRegexMatcher(jlong address) {
return reinterpret_cast<RegexMatcher*>(static_cast<uintptr_t>(address));
}
@@ -42,7 +42,7 @@
*/
class MatcherAccessor {
public:
- MatcherAccessor(JNIEnv* env, jint address, jstring javaInput, bool reset) {
+ MatcherAccessor(JNIEnv* env, jlong address, jstring javaInput, bool reset) {
init(env, address);
mJavaInput = javaInput;
@@ -63,7 +63,7 @@
}
}
- MatcherAccessor(JNIEnv* env, jint address) {
+ MatcherAccessor(JNIEnv* env, jlong address) {
init(env, address);
}
@@ -96,7 +96,7 @@
}
private:
- void init(JNIEnv* env, jint address) {
+ void init(JNIEnv* env, jlong address) {
mEnv = env;
mJavaInput = NULL;
mMatcher = toRegexMatcher(address);
@@ -117,11 +117,11 @@
void operator=(const MatcherAccessor&);
};
-static void Matcher_closeImpl(JNIEnv*, jclass, jint address) {
+static void Matcher_closeImpl(JNIEnv*, jclass, jlong address) {
delete toRegexMatcher(address);
}
-static jint Matcher_findImpl(JNIEnv* env, jclass, jint addr, jstring javaText, jint startIndex, jintArray offsets) {
+static jint Matcher_findImpl(JNIEnv* env, jclass, jlong addr, jstring javaText, jint startIndex, jintArray offsets) {
MatcherAccessor matcher(env, addr, javaText, false);
UBool result = matcher->find(startIndex, matcher.status());
if (result) {
@@ -130,7 +130,7 @@
return result;
}
-static jint Matcher_findNextImpl(JNIEnv* env, jclass, jint addr, jstring javaText, jintArray offsets) {
+static jint Matcher_findNextImpl(JNIEnv* env, jclass, jlong addr, jstring javaText, jintArray offsets) {
MatcherAccessor matcher(env, addr, javaText, false);
if (matcher.status() != U_ZERO_ERROR) {
return -1;
@@ -142,17 +142,17 @@
return result;
}
-static jint Matcher_groupCountImpl(JNIEnv* env, jclass, jint addr) {
+static jint Matcher_groupCountImpl(JNIEnv* env, jclass, jlong addr) {
MatcherAccessor matcher(env, addr);
return matcher->groupCount();
}
-static jint Matcher_hitEndImpl(JNIEnv* env, jclass, jint addr) {
+static jint Matcher_hitEndImpl(JNIEnv* env, jclass, jlong addr) {
MatcherAccessor matcher(env, addr);
return matcher->hitEnd();
}
-static jint Matcher_lookingAtImpl(JNIEnv* env, jclass, jint addr, jstring javaText, jintArray offsets) {
+static jint Matcher_lookingAtImpl(JNIEnv* env, jclass, jlong addr, jstring javaText, jintArray offsets) {
MatcherAccessor matcher(env, addr, javaText, false);
UBool result = matcher->lookingAt(matcher.status());
if (result) {
@@ -161,7 +161,7 @@
return result;
}
-static jint Matcher_matchesImpl(JNIEnv* env, jclass, jint addr, jstring javaText, jintArray offsets) {
+static jint Matcher_matchesImpl(JNIEnv* env, jclass, jlong addr, jstring javaText, jintArray offsets) {
MatcherAccessor matcher(env, addr, javaText, false);
UBool result = matcher->matches(matcher.status());
if (result) {
@@ -170,47 +170,47 @@
return result;
}
-static jint Matcher_openImpl(JNIEnv* env, jclass, jint patternAddr) {
+static jlong Matcher_openImpl(JNIEnv* env, jclass, jlong patternAddr) {
RegexPattern* pattern = reinterpret_cast<RegexPattern*>(static_cast<uintptr_t>(patternAddr));
UErrorCode status = U_ZERO_ERROR;
RegexMatcher* result = pattern->matcher(status);
maybeThrowIcuException(env, "RegexPattern::matcher", status);
- return static_cast<jint>(reinterpret_cast<uintptr_t>(result));
+ return reinterpret_cast<uintptr_t>(result);
}
-static jint Matcher_requireEndImpl(JNIEnv* env, jclass, jint addr) {
+static jint Matcher_requireEndImpl(JNIEnv* env, jclass, jlong addr) {
MatcherAccessor matcher(env, addr);
return matcher->requireEnd();
}
-static void Matcher_setInputImpl(JNIEnv* env, jclass, jint addr, jstring javaText, jint start, jint end) {
+static void Matcher_setInputImpl(JNIEnv* env, jclass, jlong addr, jstring javaText, jint start, jint end) {
MatcherAccessor matcher(env, addr, javaText, true);
matcher->region(start, end, matcher.status());
}
-static void Matcher_useAnchoringBoundsImpl(JNIEnv* env, jclass, jint addr, jboolean value) {
+static void Matcher_useAnchoringBoundsImpl(JNIEnv* env, jclass, jlong addr, jboolean value) {
MatcherAccessor matcher(env, addr);
matcher->useAnchoringBounds(value);
}
-static void Matcher_useTransparentBoundsImpl(JNIEnv* env, jclass, jint addr, jboolean value) {
+static void Matcher_useTransparentBoundsImpl(JNIEnv* env, jclass, jlong addr, jboolean value) {
MatcherAccessor matcher(env, addr);
matcher->useTransparentBounds(value);
}
static JNINativeMethod gMethods[] = {
- NATIVE_METHOD(Matcher, closeImpl, "(I)V"),
- NATIVE_METHOD(Matcher, findImpl, "(ILjava/lang/String;I[I)Z"),
- NATIVE_METHOD(Matcher, findNextImpl, "(ILjava/lang/String;[I)Z"),
- NATIVE_METHOD(Matcher, groupCountImpl, "(I)I"),
- NATIVE_METHOD(Matcher, hitEndImpl, "(I)Z"),
- NATIVE_METHOD(Matcher, lookingAtImpl, "(ILjava/lang/String;[I)Z"),
- NATIVE_METHOD(Matcher, matchesImpl, "(ILjava/lang/String;[I)Z"),
- NATIVE_METHOD(Matcher, openImpl, "(I)I"),
- NATIVE_METHOD(Matcher, requireEndImpl, "(I)Z"),
- NATIVE_METHOD(Matcher, setInputImpl, "(ILjava/lang/String;II)V"),
- NATIVE_METHOD(Matcher, useAnchoringBoundsImpl, "(IZ)V"),
- NATIVE_METHOD(Matcher, useTransparentBoundsImpl, "(IZ)V"),
+ NATIVE_METHOD(Matcher, closeImpl, "(J)V"),
+ NATIVE_METHOD(Matcher, findImpl, "(JLjava/lang/String;I[I)Z"),
+ NATIVE_METHOD(Matcher, findNextImpl, "(JLjava/lang/String;[I)Z"),
+ NATIVE_METHOD(Matcher, groupCountImpl, "(J)I"),
+ NATIVE_METHOD(Matcher, hitEndImpl, "(J)Z"),
+ NATIVE_METHOD(Matcher, lookingAtImpl, "(JLjava/lang/String;[I)Z"),
+ NATIVE_METHOD(Matcher, matchesImpl, "(JLjava/lang/String;[I)Z"),
+ NATIVE_METHOD(Matcher, openImpl, "(J)J"),
+ NATIVE_METHOD(Matcher, requireEndImpl, "(J)Z"),
+ NATIVE_METHOD(Matcher, setInputImpl, "(JLjava/lang/String;II)V"),
+ NATIVE_METHOD(Matcher, useAnchoringBoundsImpl, "(JZ)V"),
+ NATIVE_METHOD(Matcher, useTransparentBoundsImpl, "(JZ)V"),
};
void register_java_util_regex_Matcher(JNIEnv* env) {
jniRegisterNativeMethods(env, "java/util/regex/Matcher", gMethods, NELEM(gMethods));
diff --git a/luni/src/main/native/java_util_regex_Pattern.cpp b/luni/src/main/native/java_util_regex_Pattern.cpp
index bd1f326..1a99d0a 100644
--- a/luni/src/main/native/java_util_regex_Pattern.cpp
+++ b/luni/src/main/native/java_util_regex_Pattern.cpp
@@ -27,7 +27,7 @@
// ICU documentation: http://icu-project.org/apiref/icu4c/classRegexPattern.html
-static RegexPattern* toRegexPattern(jint addr) {
+static RegexPattern* toRegexPattern(jlong addr) {
return reinterpret_cast<RegexPattern*>(static_cast<uintptr_t>(addr));
}
@@ -71,11 +71,11 @@
env->Throw(reinterpret_cast<jthrowable>(exception));
}
-static void Pattern_closeImpl(JNIEnv*, jclass, jint addr) {
+static void Pattern_closeImpl(JNIEnv*, jclass, jlong addr) {
delete toRegexPattern(addr);
}
-static jint Pattern_compileImpl(JNIEnv* env, jclass, jstring javaRegex, jint flags) {
+static jlong Pattern_compileImpl(JNIEnv* env, jclass, jstring javaRegex, jint flags) {
flags |= UREGEX_ERROR_ON_UNKNOWN_ESCAPES;
UErrorCode status = U_ZERO_ERROR;
@@ -91,12 +91,12 @@
if (!U_SUCCESS(status)) {
throwPatternSyntaxException(env, status, javaRegex, error);
}
- return static_cast<jint>(reinterpret_cast<uintptr_t>(result));
+ return static_cast<jlong>(reinterpret_cast<uintptr_t>(result));
}
static JNINativeMethod gMethods[] = {
- NATIVE_METHOD(Pattern, closeImpl, "(I)V"),
- NATIVE_METHOD(Pattern, compileImpl, "(Ljava/lang/String;I)I"),
+ NATIVE_METHOD(Pattern, closeImpl, "(J)V"),
+ NATIVE_METHOD(Pattern, compileImpl, "(Ljava/lang/String;I)J"),
};
void register_java_util_regex_Pattern(JNIEnv* env) {
jniRegisterNativeMethods(env, "java/util/regex/Pattern", gMethods, NELEM(gMethods));
diff --git a/luni/src/test/java/libcore/java/util/FormatterTest.java b/luni/src/test/java/libcore/java/util/FormatterTest.java
index 5c59807..596e946 100644
--- a/luni/src/test/java/libcore/java/util/FormatterTest.java
+++ b/luni/src/test/java/libcore/java/util/FormatterTest.java
@@ -130,4 +130,9 @@
output[i], result);
}
}
+
+ // https://code.google.com/p/android/issues/detail?id=42936
+ public void test42936() throws Exception {
+ assertEquals("0.00000000000000", String.format("%.15g",0.0d));
+ }
}
diff --git a/luni/src/test/java/libcore/java/util/regex/OldMatcherTest.java b/luni/src/test/java/libcore/java/util/regex/OldMatcherTest.java
index bd6109b..8d6e186 100644
--- a/luni/src/test/java/libcore/java/util/regex/OldMatcherTest.java
+++ b/luni/src/test/java/libcore/java/util/regex/OldMatcherTest.java
@@ -643,4 +643,12 @@
t.join();
}
}
+
+ // https://code.google.com/p/android/issues/detail?id=33040
+ public void test33040() throws Exception {
+ Pattern p = Pattern.compile("ma");
+ // replaceFirst resets the region; apparently, this was broken in Android 1.6.
+ String result = p.matcher("mama").region(2, 4).replaceFirst("mi");
+ assertEquals("mima", result);
+ }
}