Fix strict-aliasing violations
GC triggering performance optimizations

Copy the correct starting heap size at process init.
Interfaces to set GC/managed heap parameters.

Change-Id: If0b1637291e77f9781ae6249c5d0257f659253ca
Finish fixing Zygote descriptor leakage problem

In order to prevent Zygote descriptors from leaking into the child
environment, they should be closed by the forked-off child process
before the child switches to the application UID.  These changes close
the descriptors via dup2(), substituting a descriptor open to
/dev/null in their place; this allows the Zygote Java code to close
the FileDescriptor objects cleanly.

This is a multi-project change: dalvik, art, libcore, frameworks/base,
and external/sepolicy are affected.  The CLs need to be approved
together, lest the build break or the software fail to boot.

Bug: 12114500
Change-Id: I8ea69de7b1cfbd811977a5629eb0af665f6dd66a
Add sample profiling interface to startMethodTracing.

Libcore side of this change. Also changed art and frameworks base.

Change-Id: Ie26982dfb09d4098708d701b5429fd09e710a25d
Revert "Finish fixing Zygote descriptor leakage problem"

This reverts commit 17321d4911d57a76d2a408619604f023e059e8b6.
Speed-up for apps that use Dagger on ART

This is more of a harm-free heuristic improvement than a fix.
It rearranges the algorithm for determining whether a Field
(or Constructor/Method) is annotated. A cheap check (does the
Field/Method/Constructor has any annotations at all?) is pushed
ahead of a more expensive one (If the annotation were to be
present, what would its type index be?). This happens to work
well in practice in sample apps because the cheap check often
fails, allowing the algorithm to terminate earlier.

The second change is to skip() the field information
rather than to read each field in turn when looking for Method
or Constructor annotation information.

The second change is not a hotspot but looks like an easy
optimization that avoids many small method calls and a for
loop for little additional complexity.

Change-Id: I2118d650f2f1db4e103384483684306e42809093
Improve URI.equals performance.

The main improvement is that we're vastly reducing
the amount of garbage this method creates.

Also, get rid of some incorrect checks and add a new
benchmark test case.

Before vs. After:

URI                            Equals     1540.1 =
URI EqualsWithHeavilyEscapedComponent 11921397.1 ==============================

URI                            Equals     1337.2 =
URI EqualsWithHeavilyEscapedComponent   588934.3 ==============================

Change-Id: I9ddb87b8267f0ac6a3ac85c2989cc0dd305ef6a1
Fix several decoder bugs.

- NativeConverter should report unterminated character
  sequences to managed code.
- CharsetDecoderIcu should report those errors correctly
  from flush()
- InputStreamReader should check the return value of
  flush() and not ignore it altogether.

bug: 11665359
bug: 10729779

Change-Id: Ic678a645a4ef2b3fe70e2c900c0cd393679f1037

Conflicts:
	harmony-tests/src/test/java/org/apache/harmony/tests/java/io/InputStreamReaderTest.java
CipherInputStream: increase buffers for speed

This increases speed of CipherInputStreamBenchmark from 606ms to 28.5ms.

Bug: 12246774
Change-Id: If61c0a055fe1b8e87909711b15d0441fcdbe46c7

Conflicts:
	luni/src/test/java/libcore/javax/crypto/CipherInputStreamTest.java
Fix CTS test failure under ART

The Thread.interrupted() State from
SelectorTest.testInterrupted() was leaking into
SelectorTest.testManyWakeupCallsTriggerOnlyOneWakeup() causing
that test to fail when the CTS was run with the ART. Under
Dalvik the "interrupted" state was being reset, but it was
causing the test runner to run each subsequent test in its
own Dalvik instance (which probably slowed down the tests but
wasn't causing failures).

It is unclear why a Thread being in "interrupted" after a test
does not cause problems for ART in the same way it causes
problems for Dalvik.

Bug: 12905142
Change-Id: I677c1d46602d10e174ba3b6b8614529b5c902104
Fix Thread.sleep(0) of an interrupted thread

Bug: 12929305
Change-Id: I3061c3345c68de8bcf438e6935446b4f7cd76001

Conflicts:
	luni/src/test/java/libcore/java/lang/ThreadTest.java
Switch Random to use AtomicLong

This removes the synchronization from next() and replaces the seed with
an AtomicLong.

Change-Id: I4ed94e0290dad83ed7570a8e7fd906e025df4636
Improve detection of CloseGuard protected resource leakage

* Add CloseGuardMonitor to intercept and collate CloseGuard reports and if
  necessary throw an exception listing the resource leaks.
* Add ResourceLeakageDetector to abstract away the CloseGuardMonitor which will
  not work on RI.
* Add AbstractResourceLeakageDetectorTestCase as a base class for tests
  that need to detect resource leaks, in future this could be handled by
  modifications to Cts and Vogar test runners.
* Remove CloseGuardTester and its sole usage in ProcessBuilderTest.
* Remove CloseGuardGuard from within URLConnectionTest
* Change ZipFileTest, ZipInputStreamTest, ZipOutputStreamTest,
  ProcessBuilderTest, URLConnectionTest to use new mechanism, fix issues that
  are identified and do some cleanup/remove duplicated code.

Bug: https://code.google.com/p/android/issues/detail?id=66383
Change-Id: Id026dbb6bc66091a15f07329e6371cd0d1f32cf5

Conflicts:
	luni/src/test/java/libcore/java/util/zip/ZipFileTest.java
	luni/src/test/java/libcore/java/util/zip/ZipInputStreamTest.java
Support explicit + in Byte, Short, Integer, Long.

Bug: 5239391
Change-Id: I2b25228815d70d570d537db0ed9b5b759f25b5a3
Remove Zygote.fork

Currently unused, all callers use forkAndSpecialize.

Change-Id: I61df8ed88d7657da8280e044fe99517c47ce8dff
Change DecimalFormat.setRoundingMode() behavior to stay in spec

The serialization tests revealed that some DecimalFormat instances
could not be round-tripped. The reason is that the setRoundingMode()
method was setting a non-zero rounding increment, which cannot
be persisted, and also creates patterns that are outside of the
DecimalFormat spec.

Addressed the fact that ICU4C appears to support
RoundingMode.UNNECESSARY now by deleting special-case code.

Changed SerializationStressTest to use canonical DecimalFormat
patterns:

The ones chosen had a couple things that were not ideal:
1) Putting '-' in quotes causes ICU (for non-obvious reasons)
treat the negative pattern prefix as not being default. Default
in this case means "the positive prefix with a preceding '-'.
Removing the quotes meant it would recognize the pattern as
not needing everything after ;., so the pattern would be shrunk.
2) The positive pattern was also not one ICU could deal with
fully. ICU changed "#.#" to "#0.#" at parse time (which can be
corrected with a setMinimumIntegerDigits(0)). It's not clear why
ICU cannot deal with parsing "#.#" when it can produce it, but
there is a long comment in decimfmt.cc suggesting it is
intentional and to avoid format producing empty strings.

The pattern has been changed to one that ICU can handle and would
choose when the various serialized fields are read back. This is
necessary because NativeDecimalFormat compares the patterns and
not just the serialized fields. Leaving the pattern check part of
equals() means that two non-spec patterns will not be considered
equal(), which is important while Android allows non-spec patterns.
Restricting support in DecimalFormat to the documented subset of
characters is not worth the effort and may cause problems
elsewhere.

Change-Id: I2de588458b86619733c0dc1692d526f179059910
Bug: 11668227

Conflicts:
	expectations/knownfailures.txt
	harmony-tests/src/test/java/org/apache/harmony/tests/java/io/SerializationStressTest.java
	luni/src/main/java/java/text/DecimalFormat.java
Change result order of getDeclaredFields

ART reports declared fields in another order than Dalvik.
The method is java.lang.class.getDeclaredFields(). Its javadoc allows
any order but Dalvik reports static fields first followed by instance ones.

This patch makes ART to be compatible with Dalvik's order.

Change-Id: Id43acb8aca7ec264b2808f5ec773c930be93b030
Signed-off-by: Yevgeny Rouban <yevgeny.y.rouban@intel.com>
Disallow explicit signs in java.sql.Date#valueOf()

Bug: 5239391
Change-Id: I52bd621bd6ed46d1ae01abf1be25d1ac3c76d7e0
Fix UUID#parseString in the presence of explicit + signs.

Bug: 5239391

Change-Id: Iaa0bbd3a7f8a13c3e48abb1a7e7508e48615b11c
Disallow explicit signs in SocketHandler port parsing.

Bug: 5239391
Change-Id: Ifa6bc6b352c283e8f6913b4905a9541df7355915