Merge "Cleanup taggedtests.txt"
diff --git a/dalvik/src/main/java/dalvik/system/DexPathList.java b/dalvik/src/main/java/dalvik/system/DexPathList.java
index 3088ca5..3d9ee3e 100644
--- a/dalvik/src/main/java/dalvik/system/DexPathList.java
+++ b/dalvik/src/main/java/dalvik/system/DexPathList.java
@@ -54,10 +54,14 @@
/** class definition context */
private final ClassLoader definingContext;
- /** list of dex/resource (class path) elements */
- private final Element[] pathElements;
+ /**
+ * List of dex/resource (class path) elements.
+ * Should be called pathElements, but the Facebook app uses reflection
+ * to modify 'dexElements' (http://b/7726934).
+ */
+ private final Element[] dexElements;
- /** list of native library directory elements */
+ /** List of native library directories. */
private final File[] nativeLibraryDirectories;
/**
@@ -99,12 +103,12 @@
}
this.definingContext = definingContext;
- this.pathElements = makeDexElements(splitDexPath(dexPath), optimizedDirectory);
+ this.dexElements = makeDexElements(splitDexPath(dexPath), optimizedDirectory);
this.nativeLibraryDirectories = splitLibraryPath(libraryPath);
}
@Override public String toString() {
- return "DexPathList[pathElements=" + Arrays.toString(pathElements) +
+ return "DexPathList[" + Arrays.toString(dexElements) +
",nativeLibraryDirectories=" + Arrays.toString(nativeLibraryDirectories) + "]";
}
@@ -302,7 +306,7 @@
* found in any of the dex files
*/
public Class findClass(String name) {
- for (Element element : pathElements) {
+ for (Element element : dexElements) {
DexFile dex = element.dexFile;
if (dex != null) {
@@ -325,7 +329,7 @@
* resource is not found in any of the zip/jar files
*/
public URL findResource(String name) {
- for (Element element : pathElements) {
+ for (Element element : dexElements) {
URL url = element.findResource(name);
if (url != null) {
return url;
@@ -343,7 +347,7 @@
public Enumeration<URL> findResources(String name) {
ArrayList<URL> result = new ArrayList<URL>();
- for (Element element : pathElements) {
+ for (Element element : dexElements) {
URL url = element.findResource(name);
if (url != null) {
result.add(url);
diff --git a/dalvik/src/main/java/dalvik/system/profiler/SamplingProfiler.java b/dalvik/src/main/java/dalvik/system/profiler/SamplingProfiler.java
index 0266103..744977c 100644
--- a/dalvik/src/main/java/dalvik/system/profiler/SamplingProfiler.java
+++ b/dalvik/src/main/java/dalvik/system/profiler/SamplingProfiler.java
@@ -74,7 +74,7 @@
/**
* A sampler is created every time profiling starts and cleared
- * everytime profiling stops because once a {@code TimerTask} is
+ * every time profiling stops because once a {@code TimerTask} is
* canceled it cannot be reused.
*/
private Sampler sampler;
@@ -94,7 +94,7 @@
* Real hprof output examples don't start the thread and trace
* identifiers at one but seem to start at these arbitrary
* constants. It certainly seems useful to have relatively unique
- * identifers when manual searching hprof output.
+ * identifiers when manual searching hprof output.
*/
private int nextThreadId = 200001;
private int nextStackTraceId = 300001;
@@ -146,9 +146,9 @@
*
* @param threadSet The thread set specifies which threads to
* sample. In a general purpose program, all threads typically
- * should be sample with a ThreadSet such as provied by {@link
- * #newThreadGroupTheadSet newThreadGroupTheadSet}. For a
- * benchmark a fixed set such as provied by {@link
+ * should be sample with a ThreadSet such as provided by {@link
+ * #newThreadGroupThreadSet newThreadGroupThreadSet}. For a
+ * benchmark a fixed set such as provided by {@link
* #newArrayThreadSet newArrayThreadSet} can reduce the overhead
* of profiling.
*/
@@ -188,7 +188,7 @@
/**
* Returns a ThreadSet for a fixed set of threads that will not
* vary at runtime. This has less overhead than a dynamically
- * calculated set, such as {@link #newThreadGroupTheadSet}, which has
+ * calculated set, such as {@link #newThreadGroupThreadSet}, which has
* to enumerate the threads each time profiler wants to collect
* samples.
*/
@@ -218,7 +218,7 @@
* threads found in the specified ThreadGroup and that
* ThreadGroup's children.
*/
- public static ThreadSet newThreadGroupTheadSet(ThreadGroup threadGroup) {
+ public static ThreadSet newThreadGroupThreadSet(ThreadGroup threadGroup) {
return new ThreadGroupThreadSet(threadGroup);
}
diff --git a/luni/src/main/java/org/apache/harmony/security/x509/Extensions.java b/luni/src/main/java/org/apache/harmony/security/x509/Extensions.java
index 1856777..9539054 100644
--- a/luni/src/main/java/org/apache/harmony/security/x509/Extensions.java
+++ b/luni/src/main/java/org/apache/harmony/security/x509/Extensions.java
@@ -26,6 +26,7 @@
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Collection;
+import java.util.Collections;
import java.util.HashMap;
import java.util.HashSet;
import java.util.List;
@@ -256,23 +257,7 @@
* null if does not.
*/
public Collection<List<?>> valueOfSubjectAlternativeName() throws IOException {
- Extension extension = getExtensionByOID("2.5.29.17");
- if (extension == null) {
- return null;
- }
-
- Collection<List<?>> collection = ((GeneralNames) GeneralNames.ASN1.decode(extension
- .getExtnValue())).getPairsList();
-
- /*
- * If the extension had any invalid entries, we may have an empty
- * collection at this point, so just return null.
- */
- if (collection.size() == 0) {
- return null;
- }
-
- return collection;
+ return decodeGeneralNames(getExtensionByOID("2.5.29.17"));
}
/**
@@ -291,11 +276,31 @@
* null if does not.
*/
public Collection<List<?>> valueOfIssuerAlternativeName() throws IOException {
- Extension extension = getExtensionByOID("2.5.29.18");
+ return decodeGeneralNames(getExtensionByOID("2.5.29.18"));
+ }
+
+ /**
+ * Given an X.509 extension that encodes GeneralNames, return it in the
+ * format expected by APIs.
+ */
+ private static Collection<List<?>> decodeGeneralNames(Extension extension)
+ throws IOException {
if (extension == null) {
return null;
}
- return ((GeneralNames) GeneralNames.ASN1.decode(extension.getExtnValue())).getPairsList();
+
+ Collection<List<?>> collection = ((GeneralNames) GeneralNames.ASN1.decode(extension
+ .getExtnValue())).getPairsList();
+
+ /*
+ * If the extension had any invalid entries, we may have an empty
+ * collection at this point, so just return null.
+ */
+ if (collection.size() == 0) {
+ return null;
+ }
+
+ return Collections.unmodifiableCollection(collection);
}
/**
diff --git a/luni/src/test/java/libcore/java/security/cert/X509CertificateTest.java b/luni/src/test/java/libcore/java/security/cert/X509CertificateTest.java
index 5e24dba..9e0e2f8 100644
--- a/luni/src/test/java/libcore/java/security/cert/X509CertificateTest.java
+++ b/luni/src/test/java/libcore/java/security/cert/X509CertificateTest.java
@@ -47,6 +47,7 @@
import java.security.cert.X509Certificate;
import java.security.spec.X509EncodedKeySpec;
import java.text.SimpleDateFormat;
+import java.util.ArrayList;
import java.util.Arrays;
import java.util.Calendar;
import java.util.Collection;
@@ -801,6 +802,15 @@
private void checkAlternativeNames(Collection<List<?>> col) {
assertNotNull(col);
+ /* Check to see that the Collection is unmodifiable. */
+ {
+ try {
+ col.add(new ArrayList<Object>());
+ fail("should be an unmodifiable list");
+ } catch (UnsupportedOperationException expected) {
+ }
+ }
+
/*
* There should be 9 types of alternative names in this test
* certificate.
@@ -808,6 +818,15 @@
boolean[] typesFound = new boolean[9];
for (List<?> item : col) {
+ /* Check to see that the List is unmodifiable. */
+ {
+ try {
+ item.remove(0);
+ fail("should be an unmodifiable list");
+ } catch (UnsupportedOperationException expected) {
+ }
+ }
+
assertTrue(item.get(0) instanceof Integer);
int type = (Integer) item.get(0);
typesFound[type] = true;
@@ -901,7 +920,21 @@
/* OID:1.2.3.4, UTF8:test1 */
final byte[] der = getOIDTestBytes();
- assertEquals(Arrays.toString(der), Arrays.toString((byte[]) item.get(1)));
+ final byte[] actual = (byte[]) item.get(1);
+ assertEquals(Arrays.toString(der), Arrays.toString(actual));
+
+ /* Make sure the byte[] array isn't modified by our test. */
+ {
+ actual[0] ^= (byte) 0xFF;
+ byte[] actual2 = (byte[]) c.getSubjectAlternativeNames().iterator().next().get(1);
+
+ if (!StandardNames.IS_RI) {
+ assertEquals(Arrays.toString(der), Arrays.toString(actual2));
+ } else {
+ /* RI is broken here. */
+ assertEquals(Arrays.toString(actual), Arrays.toString(actual2));
+ }
+ }
}
private void getSubjectAlternativeNames_Email(CertificateFactory f) throws Exception {
@@ -992,7 +1025,7 @@
private void getIssuerAlternativeNames(CertificateFactory f) throws Exception {
X509Certificate c = getCertificate(f, CERT_RSA);
- Collection<List<?>> col = c.getSubjectAlternativeNames();
+ Collection<List<?>> col = c.getIssuerAlternativeNames();
checkAlternativeNames(col);
}