Fix the exception thrown by getDeclaredFields if the class is unavailable.

http://b/issue?id=2634005

Change-Id: I1ebad41a29c9527565efea539b8f2b31f117f370
Minor nio speedups (scalar operations only).

This patch speeds up nio scalar operations for all types larger than byte.
Basically just by trimming fat, pushing any byte-swapping down into Java,
and adding a boolean field to ByteOrder that basically caches the "do we
need byte swapping?" comparison.

For the worst case, byte-swapped doubles, this patch gives a 2x speedup.
At the other end of the spectrum, for native-order chars and shorts, this
patch gives a 20% speedup. Still, that's not bad for quite a reduction in
code.

Now I've tidied this up a bit, I have more of a plan. This is just the warmup.

Bug: 2935622

Change-Id: I3cfc4e61b12ea7a8f32fc497106ddc66474efe01

Conflicts:
	luni/src/main/java/java/nio/ByteOrder.java
Remove some dead cruft.

Change-Id: I968fe2dda543430fb0c38f6c5bde7c55b9f4c314
More consistent naming of the nio vector primitives.

Just name changes here.

Change-Id: I050b33ce836270435310041dd179ceaa98d789fa
Fix build.

Change-Id: I3c38b8db4ce674eb6eba6452a4c80ed3f1e6aeb6
Specialize on size rather than type in OSMemory.

I'm working towards intrinsics for this stuff, so I want to minimize the number
I have to support. There are 7 types (byte, char, double, float, int, long,
and short) but only 4 sizes (1, 2, 4, and 8 bytes).

I've also finally benchmarked whether the "inlined memcpy"s really gain us
anything, and they do, so I've rewritten the sole remaining caller of the
templates (long) to have its own inlined memcpy too.

Plus a final tranche of naming consistency.

Bug: 2935622
Change-Id: Ieffd9723d0479aec6179b888d1c3b3496032e57a
Remove the accessors hiding our IFileSystem and INetworkSystem.

These accessors aren't buying us anything, are costing us something, and have
encouraged caching of instances in fields all over the place. Lose all that
cruft.

I think we all agree that we want to merge IFileSystem and INetworkSystem at
some point, but I'll do that some other day.

Change-Id: I07696ec9650d0395ec31a71a74300e818a3fed91
Don't synchronize on non-final fields.

This fixes some Findbugs and IntelliJ warnings. See http://b/2099930

Change-Id: Icb0a92890657e7a56f339bc9bdd2d1b5ddfc663c

Conflicts:
	luni/src/main/java/org/apache/harmony/luni/net/PlainDatagramSocketImpl.java
	luni/src/main/java/org/apache/harmony/luni/net/PlainSocketImpl.java
Fixing warnings in ObjectInputStream, including possible null dereferences.

See http://b/issue?id=2099718

Change-Id: I74db9e216c0d2568823c313aeeb91fdef72ae00a
Fix classes that implement equals() but not hashCode().

See http://b/2099681

Change-Id: If358af98ccca44c544942b837c25e00e6553e916
Fixing a dead store in Finished.

See bug 2099918.

Change-Id: I12f0a53bc5aeacea3ba97820dcd6525e1bf23405
Fix racy socket.close() behaviour.

This is a follow up to enh's comments on https://android-git.corp.google.com/g/64034

Change-Id: I7ea3c15c164cf45380e1868dc4ef85b8a9417cbe
Make fields final where possible.

See http://b/issue?id=2099637

Change-Id: I2a237d876c7acbe629e69d5c31d05737908f4606
Kill ThreadLocalCache.

This has been a long time coming. The two public fields were only used when
writing a jar file manifest, which isn't a performance case. The class was
used very strangely in ObjectStreamClass; it seems to make more sense to just
inline the relevant code there.

Change-Id: I5c6fe307558038394a598a846f59098c77143d3a
Fix a findbugs bug where ZipEntry.clone() didn't call super.clone().

See http://b/2099615

Change-Id: Ib1347aa5e35c62501d9d59eccfdfed098559d552
Make DirectBuffer.getEffectiveAddress cheaper.

DirectBuffer.getEffectiveAddress is used to implement the JNI function
GetDirectBufferAddress. Currently it uses reference types unnecessarily,
and we have an object pool to reduce the cost of this. Switch to using
int instead.

I'll remove the pool in a later change.

Note that this change requires a corresponding change to the
GetDirectBufferAddress implementation in dalvik:
  https://android-git.corp.google.com/g/64328

Bug: 2935622
Change-Id: Ia0c20bd58c5355550f6af840feb08acff14fd4e9
Fix jtreg test failures when we weren't throwing on bad parameters.

See http://b/2224959

Change-Id: I9f572d08328dda280a77287a228072d33fcbea85
Kill PlatformAddressFactory, and remove/simplify some other code.

Now we create one PlatformAddress per direct byte buffer (or mapped byte
buffer), there's no need for object pooling.

Bug: 2935622
Change-Id: I84ef9d0b77774e1d2d80921b95b2f30383a0ab68

Conflicts:
	luni/src/main/native/org_apache_harmony_luni_platform_OSMemory.cpp
Change NIOAccess to consistently use the position field rather than the position() method.

This is safe (which is lucky, since we're accessing the field directly
elsewhere). position() is final and just "return position;".

Bug: 2535509
Change-Id: I5c1f569ab318cb0ddb44e887b75fdc21ac270944
Use finalizers to free direct buffers.

Also switch to a cheaper scheme for avoiding double-frees (which could only
happen if library code is broken; at the moment the only caller is the
iovec-style stuff). This halves the cost of direct buffer access, at the
unimportant cost of not throwing an exception if we try to access a buffer
we freed while we still had a reference to it.

Also use named constants for the sizes of primitive types.

Also kill BufferFactory.

Bug: 2935622
Change-Id: I6021ce7531f49d8cff7635d6d2cc54851bacaf69