Merge mpr-2021-09-05
Change-Id: Iad097846dadd1a9951947dd2797c22c98b05efd2
diff --git a/ojluni/src/main/java/java/net/URI.java b/ojluni/src/main/java/java/net/URI.java
index ebba41b..6b97d56 100644
--- a/ojluni/src/main/java/java/net/URI.java
+++ b/ojluni/src/main/java/java/net/URI.java
@@ -581,6 +581,7 @@
* by the above deviations
*/
public URI(String str) throws URISyntaxException {
+ java.util.SeempLog.record_str(92, "s:"+str);
new Parser(str).parse(false);
}
diff --git a/ojluni/src/main/java/java/net/URL.java b/ojluni/src/main/java/java/net/URL.java
index 74dec92..c3f5b2e 100644
--- a/ojluni/src/main/java/java/net/URL.java
+++ b/ojluni/src/main/java/java/net/URL.java
@@ -1003,6 +1003,7 @@
* int, java.lang.String)
*/
public URLConnection openConnection() throws java.io.IOException {
+ java.util.SeempLog.record_str(91, "URL:"+query);
return handler.openConnection(this);
}
diff --git a/ojluni/src/main/java/java/util/SeempLog.java b/ojluni/src/main/java/java/util/SeempLog.java
new file mode 100644
index 0000000..f8a72d7
--- /dev/null
+++ b/ojluni/src/main/java/java/util/SeempLog.java
@@ -0,0 +1,91 @@
+/*
+ * Copyright (c) 2015, The Linux Foundation. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions are
+ * met:
+ * * Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * * Redistributions in binary form must reproduce the above
+ * copyright notice, this list of conditions and the following
+ * disclaimer in the documentation and/or other materials provided
+ * with the distribution.
+ * * Neither the name of The Linux Foundation nor the names of its
+ * contributors may be used to endorse or promote products derived
+ * from this software without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED "AS IS" AND ANY EXPRESS OR IMPLIED
+ * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
+ * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT
+ * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS
+ * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
+ * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
+ * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR
+ * BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
+ * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE
+ * OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN
+ * IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+package java.util;
+
+/*
+import com.android.internal.os.RuntimeInit;
+
+import java.io.PrintWriter;
+import java.io.StringWriter;
+import java.net.UnknownHostException;
+*/
+
+import java.lang.reflect.Method;
+import java.lang.reflect.InvocationTargetException;
+
+/**
+ *
+ * @hide
+ */
+public final class SeempLog {
+
+ private static Method seemp_record_method = null;
+ private static boolean seemp_record_method_looked_up = false;
+
+ private SeempLog() {
+ }
+
+ /**
+ * Send a log message to the seemp log.
+ * @param msg The message you would like logged.
+ */
+ public static int record_str(int api, String msg) {
+ if (seemp_record_method == null) {
+ if (!seemp_record_method_looked_up) {
+ try
+ {
+ Class c = Class.forName( "android.util.SeempLog" );
+ if (c!=null) {
+ seemp_record_method = c.getDeclaredMethod( "record_str", int.class, String.class );
+ }
+ } catch (ClassNotFoundException ex) {
+ seemp_record_method = null;
+ } catch (NoSuchMethodException ex) {
+ seemp_record_method = null;
+ }
+
+ }
+ seemp_record_method_looked_up = true;
+ }
+
+ if (seemp_record_method!=null) {
+ try {
+ return ( ( Integer )seemp_record_method.invoke( null, api, msg ) ).intValue();
+ } catch (IllegalAccessException ex) {
+ return 0;
+ } catch (InvocationTargetException ex) {
+ return 0;
+ }
+ }
+
+ return 0;// seemp_println_native("-1|" + msg);
+ }
+
+}
diff --git a/openjdk_java_files.bp b/openjdk_java_files.bp
index 7ba860c..c1ee4ac 100644
--- a/openjdk_java_files.bp
+++ b/openjdk_java_files.bp
@@ -1158,6 +1158,7 @@
"ojluni/src/main/java/java/util/RegularEnumSet.java",
"ojluni/src/main/java/java/util/ResourceBundle.java",
"ojluni/src/main/java/java/util/Scanner.java",
+ "ojluni/src/main/java/java/util/SeempLog.java",
"ojluni/src/main/java/java/util/ServiceConfigurationError.java",
"ojluni/src/main/java/java/util/ServiceLoader.java",
"ojluni/src/main/java/java/util/Set.java",
diff --git a/xml/src/main/java/com/android/org/kxml2/io/KXmlParser.java b/xml/src/main/java/com/android/org/kxml2/io/KXmlParser.java
index 3814e63..8dccf6c 100644
--- a/xml/src/main/java/com/android/org/kxml2/io/KXmlParser.java
+++ b/xml/src/main/java/com/android/org/kxml2/io/KXmlParser.java
@@ -157,6 +157,8 @@
private boolean isWhitespace;
private String namespace;
private String prefix;
+ private String foundPrefix = null;
+ private String foundName = null;
private String name;
private String text;
@@ -268,15 +270,21 @@
}
}
- int cut = name.indexOf(':');
+ if (foundPrefix != null && foundName != null) {
+ prefix = foundPrefix;
+ name = foundName;
+ }
+ else {
+ int cut = name.indexOf(':');
if (cut == 0) {
checkRelaxed("illegal tag name: " + name);
}
- if (cut != -1) {
- prefix = name.substring(0, cut);
- name = name.substring(cut + 1);
+ if (cut != -1) {
+ prefix = name.substring(0, cut);
+ name = name.substring(cut + 1);
+ }
}
this.namespace = getNamespace(prefix);
@@ -962,13 +970,19 @@
}
private void readEndTag() throws IOException, XmlPullParserException {
+ int sp = (depth - 1) * 4;
read('<');
read('/');
- name = readName(); // TODO: pass the expected name in as a hint?
+ if (depth == 0) {
+ name = readName();
+ }
+ else {
+ // Pass the expected name in as a hint.
+ name = readExpectedName(elementStack[sp + 3]);
+ }
skip();
read('>');
- int sp = (depth - 1) * 4;
if (depth == 0) {
checkRelaxed("read end tag " + name + " with no tags open");
@@ -1056,7 +1070,7 @@
if (!xmldecl) {
read('<');
}
- name = readName();
+ name = readName(true);
attributeCount = 0;
while (true) {
@@ -1430,7 +1444,12 @@
}
if (result == null) {
- return stringPool.get(buffer, start, position - start);
+ if (isWhitespace) {
+ return stringPool.get(buffer, start, position - start);
+ }
+ else {
+ return new String(buffer, start, position - start);
+ }
} else {
result.append(buffer, start, position - start);
return result.toString();
@@ -1526,13 +1545,44 @@
* Returns an element or attribute name. This is always non-empty for
* non-relaxed parsers.
*/
+ private String readExpectedName(String expected) throws IOException, XmlPullParserException {
+ int length = expected.length();
+ int end = position + length;
+ if (end < limit) {
+ // Fast path for normal case.
+ boolean match = true;
+ for (int i = 0; i < length; i++) {
+ if (buffer[position+i] != expected.charAt(i)) {
+ match = false;
+ break;
+ }
+ }
+ if (match) {
+ position += length;
+ return expected;
+ }
+ }
+ return readName();
+ }
+
private String readName() throws IOException, XmlPullParserException {
+ return readName(false);
+ }
+
+ /**
+ * Returns an element or attribute name. This is always non-empty for
+ * non-relaxed parsers. findPrefix should only be true for element names
+ */
+ private String readName(boolean findPrefix) throws IOException, XmlPullParserException {
if (position >= limit && !fillBuffer(1)) {
checkRelaxed("name expected");
return "";
}
int start = position;
+ int nameStart = -1;
+ foundPrefix = null;
+ foundName = null;
StringBuilder result = null;
// read the first character
@@ -1576,12 +1626,20 @@
|| c == ':'
|| c == '.'
|| c >= '\u00b7') { // TODO: check the XML spec
+ // Fast path for common case
+ if (c == ':' && findPrefix && foundPrefix == null) {
+ foundPrefix = stringPool.get(buffer, start, position - start);
+ nameStart = position+1;
+ }
position++;
continue;
}
// we encountered a non-name character. done!
if (result == null) {
+ if (foundPrefix != null && position != nameStart) {
+ foundName = stringPool.get(buffer, nameStart, position - nameStart);
+ }
return stringPool.get(buffer, start, position - start);
} else {
result.append(buffer, start, position - start);