On Fri, 4 Apr 2014, Ilya Mizus wrote:

>> @@ -0,0 +1,12 @@
>> +diff -ru android-src.old/org/conscrypt/NativeCrypto.java android-src/org/conscrypt/NativeCrypto.java
>
> Of course we could do it, but why do you think it would be better?

Because I'd prefer to avoid patching the libcore code if possible.  The 
more patches we add, the harder it will be to update to more recent 
versions of libcore from the Google repository.

> 1. Patching Android sources is necessary anyway and it's a compile-time 
> activity

The only other patch I know of is the "ordinal->ordinal()" patch for 
Enum.java, and we should get rid of that and just change the code in 
android-libcore64.

> 2. Adding an extra check to a vital system function lowers down 
> performance and makes this function less readable.

I agree that it's a vital system function, but I disagree that it's 
performance-sensitive.  I've never heard of an application that spent most 
of its time calling Runtime.loadLibrary.

> Are you sure?

Yes.  Something simple, like this:

```
diff --git a/src/classpath-android.cpp b/src/classpath-android.cpp
index e3ad8a5..ab4602b 100644
--- a/src/classpath-android.cpp
+++ b/src/classpath-android.cpp
@@ -59,7 +59,11 @@ loadLibrary(Thread* t, object, uintptr_t* arguments)
    THREAD_RUNTIME_ARRAY(t, char, n, length + 1);
    stringChars(t, name, RUNTIME_ARRAY_BODY(n));

-  loadLibrary(t, "", RUNTIME_ARRAY_BODY(n), true, true);
+  // org_conscrypt_NativeCrypto.o is linked statically, so no need to
+  // load it from a dynamic library:
+  if (strcmp(RUNTIME_ARRAY_BODY(n), "conscrypt_jni")) {
+    loadLibrary(t, "", RUNTIME_ARRAY_BODY(n), true, true);
+  }
  }

  void JNICALL
```