summaryrefslogtreecommitdiff
path: root/ojluni/src
AgeCommit message (Collapse)Author
2021-09-27Fix BigInteger.remainder check and BigInteger TODOsHEADlineage-18.1Hans Boehm
Restore the BigInteger.remainder fallback test to check for small results. Use RemainderKnuth if either the divisor or result is short, as was done before. Checking for a short dividend doesn't really make much sense, since that makes the result short as well. Failed BN context allocations used to just pass null to the next operation. Looking at the BN_mul implementation, it doesn't appear that ends well. Explicitly check for that case. Remove some potentially useful but unused methods from NativeBN. Bug: 163898786 Test: Build and boot AOSP Change-Id: I97a46199d8cf69acf29bcfc2f614c2205ff16262
2021-09-27Switch to OpenJDK 8 java/mathHans Boehm
The main goal here is performance by avoiding JNI and especially NativeAllocationRegistry overhead. We gain a factor of 10 or so on small BigInteger arithmetic. For large computations, we gain substantially in a few cases where OpenJDK seems to use better algorithms. AFAIK, with this version we never lose by integral factors relative to what we had before. A secondary goal is to clean out open BigInteger bugs. The base version is 8u252, which for this part of the tree is identical to June 15 2020 ToT. Note that this means we included the java.math part of https://hg.openjdk.java.net/jdk8u/jdk8u/jdk/rev/a5f5d7fd9be6 (29 Oct 2019) That appears to be a separable fix that makes no interface changes. I re-added @NonNull annotations. We also removed some code to write certain backwards-compatibility fields during serialization, since we never had those. This also adds a the <X>ValueExact Java 8 BigInteger methods that had not been previously supported. This removes a Harmony test for compatibility with the RI implementation that the RI implementation itself apparently fails. And, IMO, the observed behavior is better than what we previously tested for. Fixed a bunch of comment spelling errors. All of these have now been fixed in upstream ToT. Benchmarking showed that a straight move to the RI version slowed down large multiplications, divisions, and modular exponentiation enough to make it problematic. Thus I reintroduced NativeBN to allow those to fall back to boringssl, at least for sufficiently large inputs. It was moved to a hopefully more appropriate location. The fallback is tuned for 64 bits; for 32 bits it's probably much less useful; much of the boringssl performance advantage comes from 64-bit "digits". The boringssl fallbacks are not completely free, since we need extra conversions on each operation. But since we only do this for large asymptotically expensive computations, we see at mosts tens of percents regressions, which probably qualifies as "in the noise" here. If we find additional performance issues, we can add more boringssl fallbacks; the required code is now fairly straightforward. Unlike the old version, this no longer uses NativeAllocationRegistry or similar mechanisms at all. Native memory is only used on a short-term basis, with explicit deallocation. We no longer use boringssl for simple linear-time operations like addition. Microbenchmark results for the newly added benchmark, and for a close-to-final BigInteger version, listed as "combined": Msecs/iteration Digits: 5/10 50/100 500/1000 5000/10000 Inner product, 1000 terms, factors of larger indicated size: current 2.1 2.5 6.4 168 RI 0.11 0.66 11.0 486 combined 0.12 0.67 9.1 189 Harmonic series, uses smaller indicated size current 3.7 3.2 4.3 17.6 RI 0.16 0.34 1.4 14.3 combined 0.17 0.34 1.23 14.2 (1+1/100000)^100000, larger size current 0.07 0.073 0.33 15.8 RI 0.011 0.049 1.553 63.6 combined 0.011 0.049 0.48 13.6 Single modPow() call, smaller size current 0.005 0.011 1.1 583 RI 0.006 0.038 7.2 5580 combined 0.011 0.012 1.1 541 Single modInverse call, larger size current 0.003 0.014 0.375 27.8 RI 0.003 0.003 0.026 1.6 combined 0.002 0.002 0.008 0.4 Bug: 160641142 Bug: 136887041 Bug: 119491938 Bug: 28214673 Bug: 28251030 Bug: 2950143 Test: AOSP Boots. Ran some manual Calculator tests on Cuttlefish. Change-Id: Id577d99328013b1e3c389973dcb0195fa7f52b0b
2020-09-01Handle missing parent interfacesDaulet Zhanguzin
While this does not fix having inconsistent interfaces, at least we don't fail enumerating them. With this change we still return these children interfaces without parent set. Bug: 159277702 Test: atest CtsLibcoreTestCases:libcore.java.net.NetworkInterfaceTest Change-Id: Ibbe1f273683eb169a0e96425a2c21c5072bf19d7 Merged-In: Ibbe1f273683eb169a0e96425a2c21c5072bf19d7
2020-08-21Fix reading large file offsets on 32-bitDaulet Zhanguzin
No 32 bit device on hand to verify, but this fix has been verified by partner. Test: Treehugger Bug: 156027158 (cherry pick from aosp) Change-Id: Ia604e7aac6cdd1cb46d5f2bcdf7f96cb56349954 Merged-In: Ia604e7aac6cdd1cb46d5f2bcdf7f96cb56349954
2020-07-10DateFormatSymbols.getInstance(Locale.ROOT) behaves more closely toDaulet Zhanguzin
English locale for targetSdkVersion <= 29 In Android Q or before, when LocaleData class tries to load {@link Locale#ROOT} data, en_US_POSIX locale data is incorrectly loaded. The class used to pass "und" string as BCP47 language tag to our jni code, which then passes the string as as ICU Locale ID to ICU4C. ICU4C 63 or older version doesn't recognize "und" as a valid locale id, and fallback the default locale. The default locale is normally selected in the Locale picker in the Settings app by the user and set via frameworks. But this class statically cached the ROOT locale data before the default locale being set by framework. Thus, in Q or before, en_US_POSIX data is loaded. As https://unicode-org.atlassian.net/browse/ICU-20273, an upstream bug, is fixed, ICU version 64.1 resolved inconsistent behavior of "root", "und" and "" (empty) Locale ID which libcore previously relied on, and they are recognized correctly as {@link Locale#ROOT} since R. This ChangeId gated the change, and fallback to the old behavior by checking targetSdkVersion version. Bug: 159514442 Bug: 159047832 Test: atest CtsLibcoreTestCases Change-Id: I62207fcb104bbc5d1d970b57b13d8f8ecb1e1ba0 Merged-In: I62207fcb104bbc5d1d970b57b13d8f8ecb1e1ba0 (cherry picked from commit 7d61b511bd75e3b950fc3357e774eee5ac455776)
2020-04-23Make System.nanoTime and currentTimeMillis critical native.Pete Bentley
Completes https://r.android.com/1288752 Also switch to nativehelper/jni_macros.h rather than defining NATIVE_METHOD locally. Fixes: 154262976 Test: m && flashall Change-Id: I2542cde6a62e28bb59cf0f683c4cce6ae8b4d476 Merged-In: I2542cde6a62e28bb59cf0f683c4cce6ae8b4d476 (cherry picked from commit c5f1494e3f0cdf6333bd0ba26bfac68da62e52d4)
2020-04-23Make System.nanoTime and currentTimeMillis CriticalNative.Pete Bentley
These are commonly used and have trivial implementations that use no Java objects or exceptions. Bug: 154262976 Test: m && flashall (on Taimen) Change-Id: I4909fcd6f3af09a03ee6388ea58b92826b4bbfbc Merged-In: I4909fcd6f3af09a03ee6388ea58b92826b4bbfbc (cherry picked from commit b3d1a7e9d8b92b5d3295a995c10836b769fa2600)
2020-04-07ZipInputStream: Don't throw for data descriptors on STORed entries.Narayan Kamath
This isn't required by the ZIP spec, and is inconsistent with the behaviour of java.util.ZipFile. Test: atest ZipInputStreamTest Bug: 152027785 Change-Id: If9803e5dd48ba897cd0a24c54d47e0a439cf2998
2020-03-26Remove unused methods File{Input,Output}Stream.open().Pete Bentley
Also removes the related native code. These open() methods are no longer used due to https://r.android.com/725443 and are private with no unsupported app usage. Bug: 112107427 Test: atest CtsLibcoreTestCases Change-Id: I0e4ec21a0686eb151d2da2eb0c11def70921b3e9 Merged-In: I0e4ec21a0686eb151d2da2eb0c11def70921b3e9 (cherry picked from commit 0b1e40b2cd02c0c33e14326f9448e3690e790414)
2020-03-16Merge "Fix DatagramChannelImpl.setOption(IP_MULTICAST_IF, value) for ↵TreeHugger Robot
dual-stack." into rvc-dev
2020-03-16Fix DatagramChannelImpl.setOption(IP_MULTICAST_IF, value) for dual-stack.Jason Jeremy Iman
When setting multicast interface on IPv6 enabled interface, instead of just setting IPv6 (IPV6_MULTICAST_IF), we are also setting IPv4 (IP_MULTICAST_IF). This is done by changing the implementation of setInterface4 using "struct ip_mreqn" following: https://android.googlesource.com/platform/libcore/+/master/luni/src/main/native/libcore_io_Linux.cpp#2288 Bug: 144222142 Test: DatagramChannel dc = DatagramChannel.open(); dc.setOption(StandardSocketOptions.IP_MULTICAST_IF, iface); dc.send(...); sends datagram with the correct interface even if it is not a default interface. Tested on blueline and ARC++ atlas. Test: dc.setOption(StandardSocketOptions.IP_MULTICAST_IF, iface); will work on IPv4 and IPv6 only network interface; Tested on blueline and ARC++ atlas. Merged-Id: I696aae69c342f9a555fa87a59d170f35eb6ce2b4 Change-Id: I696aae69c342f9a555fa87a59d170f35eb6ce2b4 (cherry picked from commit 3984fafd3b8cefe9ed91dbe682bd0498a8714622)
2020-03-13Reland "libcore: Remove native calls in FileDescriptor <clinit>"Orion Hodson
This reverts commit Ie9fa5a25d5352f214a16e10d5bbbe45da9f3c486. Original commit message: Moves cloning of FileDescriptor in, out, and err descriptors into a ZygoteHook. This avoids the need to run JNI methods in FileDescriptor.<clinit> and enables native Core Platform API checking of FileDescriptor descriptor and ownerId fields. Changes in reland: Force UnixChannelFactory to fail initialization during AOT compilation. UnixChannelFactory is on the preloaded-classes-blacklist and the changes in the original CL unintentionally allowed it to be initialized. It used to be that FileDescriptor and UnixChannelFactory initialization failed in the same transaction due to the FileDescriptor clinit method making native calls (dup(s)). Bug: 144502743 Bug: 150680645 Test: art/test/run-test --host 001-HelloWorld Test: art/tools/run-libcore-tests.sh --mode=host --variant=X64 Test: atest -s <serial> -c \ CtsLibcoreTestCases:libcore.java.io.FileDescriptorTest Test: atest PreloadCheck Change-Id: I81e1af1d13ec81b3e51ce1d2f3c202f807d9f9bb Merged-In: I81e1af1d13ec81b3e51ce1d2f3c202f807d9f9bb (cherry picked from commit 32ea49e614fc79873148ae974df55b0d8ba15396)
2020-02-25Updates documentation mentioning all IP interfaces are available.Bram Bonné
As of https://r.android.com/1242747, IPv6-only interfaces are also available through NetworkInterface to non-system apps. This change updates the documentation to reflect that. Bug: 141455849 Test: atest NetworkInterfaceTest Change-Id: Ib2420256ba115830f34e37e5ce1bc8a5f6e13bef (cherry picked from aosp/1242748)
2020-02-20Merge changes I7410915a,Iede082f5 am: 25ed6783a1 am: a94ac660dd am: abdcc0cf45Automerger Merge Worker
Change-Id: I50062bf040b1e848c060703f655f5ad06925dd4c
2020-02-20Merge changes I7410915a,Iede082f5Nikita Iashchenko
* changes: Improve fast-path in SimpleDateFormat.matchString() Improve test coverage for SimpleDateFormat
2020-02-20Improve fast-path in SimpleDateFormat.matchString()Nikita Iashchenko
Bug: 119913354 Test: atest core-tests:libcore.java.text.SimpleDateFormatTest#testMatchStringSortedMap_treeMap Test: atest core-tests:libcore.java.text.SimpleDateFormatTest#testMatchStringSortedMap_treeMapWithCustomComparator Change-Id: I7410915a459095b365c33b6df63d2e7af3b135ba
2020-02-19Merge "Fix typo in change marker." am: 3006a46864 am: 2b20cf9ed8 am: f66b5a042cAutomerger Merge Worker
Change-Id: I18461e7dda22ac010c0ba95a6a196fdb47e0c494
2020-02-19Merge "Add markers for new Japanese Era related files" am: afb2cf1085 am: ↵Automerger Merge Worker
564f621ff4 am: 2d8086cb2e Change-Id: Icdb462887b24afe9e129f07466387c08bc58df88
2020-02-19Merge "Fix typo in change marker."Treehugger Robot
2020-02-19Add markers for new Japanese Era related filesNikita Iashchenko
CLs https://r.android.com/1237091 and https://r.android.com/940636 integrated two upstream OpenJDK commits to finalize support for new Japanese Era Reiwa: * http://hg.openjdk.java.net/jdk/jdk/rev/6a4abdb6749c 8174268: Declare a public field in JapaneseEra for the era starting May 2019 * http://hg.openjdk.java.net/jdk/jdk/rev/3d8934bf505a 8205432: Replace the placeholder Japanese era name This CL adds the appropriate change markers for the differences relative to the respective upstream revision (OpenJDK 8u121-b13 or 8u222, depending on the file). Bug: 149437171 Test: CtsLibcoreTestCases CtsLibcoreOjTestCases Change-Id: I182bc98a374c127b2e6cee41991427f4fe5b9b54
2020-02-18Fix typo in change marker.Tobias Thierer
After the fix, the change marker is consistent with line 125. Test: Treehugger Change-Id: Iff560cd4a45aa94428f1b077a40c774c5a259a12
2020-02-18Declare a public field for new Japanese Era ReiwaNikita Iashchenko
Integrate OpenJDK commit for new Japanese Era name: * 8174268: Declare a public field in JapaneseEra for the era starting May 2019 http://hg.openjdk.java.net/jdk/jdk/rev/6a4abdb6749c Bug: 149437171 Test: CtsLibcoreTestCases CtsLibcoreOjTestCases Merged-In: I3e84ed1d809376d2c646ceadc3421b5fb55982b5 Change-Id: I3e84ed1d809376d2c646ceadc3421b5fb55982b5
2020-02-18Declare a public field for new Japanese Era ReiwaNikita Iashchenko
Integrate OpenJDK commit for new Japanese Era name: * 8174268: Declare a public field in JapaneseEra for the era starting May 2019 http://hg.openjdk.java.net/jdk/jdk/rev/6a4abdb6749c Bug: 149437171 Test: CtsLibcoreTestCases CtsLibcoreOjTestCases Change-Id: I3e84ed1d809376d2c646ceadc3421b5fb55982b5
2020-02-13Merge "Updates documentation to match MAC address restrictions." am: ↵Automerger Merge Worker
515532b664 am: 88ed75935f am: 747d1aeef9 Change-Id: Ic2386d0956ae4757123ff2158851e767b97f8462
2020-02-13Merge "Updates documentation to match MAC address restrictions."Bram Bonné
2020-02-13Updates documentation to match MAC address restrictions.Bram Bonné
Non-system apps targeting the latest SDK will only be able to access network interfaces that have an IPv4 address set, without being able to access IPv6-only interfaces. This change updates the documentation to reflect that. In addition, the documentation now references Build.VERSION_CODES_R as the affected targetSdkVersion. Bug: 141455849 Test: atest NetworkInterfaceTest Change-Id: I9525fa527cc595a323ff3a000a98112bc3833fdd
2020-02-12Merge "Change j.l.r.Field to use ArtField index instead of dexFileIndex" am: ↵Automerger Merge Worker
648e017f1d am: 9377b0b784 am: d2a2384f1b Change-Id: I46282bc6b1f9016d107cded2e5d0590eeb134730
2020-02-11Change j.l.r.Field to use ArtField index instead of dexFileIndexAlex Light
Using the dexFileIndex to determine the ArtField a java.lang.reflect.Field object points to requires us to use a dex-cache and to update all existing Field objects if this index changes (for example due to class redefinition). This could be rather slow. This replaces the dex-file index with the index into the declaring class's SFields/IFields arrays where the specified ArtMethod is stored. Bug: 149236640 Test: ./test.py --host Change-Id: I3598909a770aff317011091f33707773f3928c56
2020-02-03Merge "Updates documentation to match MAC address restrictions." am: ↵Automerger Merge Worker
b3f2040d5b am: ef1c947fbf am: 34702a682b Change-Id: If6776dafb70ae9e93f79e282f4c1bf4b2318e929
2020-02-03Merge "Updates documentation to match MAC address restrictions."Bram Bonné
2020-02-02Merge "NetworkInterface: Clarify change marker." am: b338fcfdd8 am: ↵Automerger Merge Worker
07a9d9d08d am: baf22c314f Change-Id: Ia1654fa728da0ede20b5aa8cc4b6190b15d1358f
2020-02-02Merge "NetworkInterface: Clarify change marker."Treehugger Robot
2020-01-31Updates documentation to match MAC address restrictions.Bram Bonné
Non-system apps targeting the latest SDK will no longer have access to the MAC addresses of network interfaces. This change updates the documentation of NetworkInterface to reflect this. Bug: 141455849 Test: atest NetworkInterfaceTest Change-Id: I105bc74630bf4fdbdd03a8c753a0edbddb48dd9f
2020-01-31NetworkInterface: Clarify change marker.Tobias Thierer
The comment "specified to return null if no network interface" in NetworkInterface.java derives from upstream OpenJDK 8u121-b13. Upstream's getAll() method returns null rather than an array of length 0 in the case of no network interfaces. I suspect that the upstream comment refers to getAll() returning null, but because it appeared after an Android-changed marker, was not double-commented out, the null check that it referred to wasn't present, and the following line returned null, it appeared as if it referred to that. This CL adds commented-out upstream code and an extra comment layer to the "specified to return null" comment, to avoid this misunderstanding. Test: tools/upstream/upstream-diff java.net.NetworkInterface Change-Id: I64f8919f6a3cce53f332ae8f3062b82d9927cd08
2020-01-29Merge "Rename ZoneInfoDB -> ZoneInfoDb" am: 414bdcd5b5 am: a72c5f760b am: ↵Automerger Merge Worker
88a4ea30e2 Change-Id: I6aa15d8fb8e63416c2e26db4fbb69db2ad0d5a69
2020-01-29Merge "Rename ZoneInfoDB -> ZoneInfoDb"Treehugger Robot
2020-01-28Merge "Revert "Revert "Revert "Limit access to the device's fixed 802.11 MAC ↵Automerger Merge Worker
address."""" am: 0575d7bc9e am: b691cf0146 am: 73b2ff9e25 Change-Id: Ida7ae7d207c3bd1beb5cdf7679ac39bbe65c2fc1
2020-01-28Revert "Revert "Revert "Limit access to the device's fixed 802.11 MAC ↵Bram Bonné
address.""" This reverts commit fea6729e833593dcb8f8b919db6fa3a202deeb88. Reason for revert: Check is now performed at the level of getifaddrs() (on which NetworkInterface depends for information about MAC addresses). See https://r.android.com/1215280 for more information. Bug: 141455849 Test: atest NetworkInterfaceTest Change-Id: I6942f9cc7656b5c4f07e5cdeb8423ead94bcafe5
2020-01-28Rename ZoneInfoDB -> ZoneInfoDbNeil Fuller
Rename ZoneInfoDB -> ZoneInfoDb to conform with coding standards. Bug: 148086409 Test: treehugger Change-Id: I1054d129cc4d53587a187c32927311f7311754fe
2020-01-18Merge "Refine documentation of getNativeTid() function" am: 4fb43701bf am: ↵Automerger Merge Worker
e88049cc3b am: e4da80c040 Change-Id: Iaf947f40b918d14bc3c6d4b3835110d659ff1328
2020-01-18Merge "Refine documentation of getNativeTid() function"Treehugger Robot
2020-01-17Merge "Update misc java.util classes to OpenJDK 9+181 and immediately expose ↵Automerger Merge Worker
API" am: 7566262b49 am: 216f859e2c am: bc064c373f Change-Id: I60309d4fb0370a3965f5c29dc233c6abfa136df8
2020-01-17Merge "Use ThreadPrioritySetter to set thread priority" am: 94b823083d am: ↵Automerger Merge Worker
9058b6db15 am: e6469ae466 Change-Id: Ie7190b979cf92daeebb648005b17daa81a6d4e5d
2020-01-17Merge "Fix @link tags in @ChangeId javadocs." am: 079c329257 am: fe557fb780 ↵Automerger Merge Worker
am: a3ca7a5769 Change-Id: Ib34cbc1091e8d12e898a691cd02283dc42fb21b1
2020-01-17Merge "Update misc java.util classes to OpenJDK 9+181 and immediately expose ↵Treehugger Robot
API"
2020-01-17Update misc java.util classes to OpenJDK 9+181 and immediately expose APITobias Thierer
This covers - integration of all changes from OpenJDK 9+181 into java.util.{AbstractList,List,Map,Objects,Set}. - Map, List, Set gain static of() / ofEntries() factory methods. - Objects gains misc static checker methods. - When implementing RandomAccess, AbstractList.spliterator() as well as subList.spliterator() is now built on top of random-access List.get(int) rather than List.iterator(). - addition of various new files that are needed by those. - addition of Nullablity annotations for the new APIs. Changes to reference upstream versions -------------------------------------- While the other files were previously derived from OpenJDK 8u121-b13, Map.java was previously derived from OpenJDK 9b113+. After this CL, all of the touched files derive from OpenJDK 9+181 with no further changes waiting to be integrated; Android-changed and similar markers note where Android carries local patches. Notes on test coverage ---------------------- This CL adds test coverage for the new APIs/behavior. The test coverage for Set.of() duplicates a bunch of logic from the List.of() coverage. I experimented with ways to reuse code but that reduced clarity and I didn't want to spend a lot of effort on a major rearchitecture of the tests. AbstractListTest asserts that iterator() is not called while exercising basic existing Android spliterator, and checks the fail-fast behavior guaranteed by the documentation. Bug: 147483640 Test: atest CtsLibcoreTestCases:libcore.java.util.{Map,List,Set}OfTest Test: atest CtsLibcoreTestCases:libcore.java.util.{AbstractList,Objects}Test Test: atest CtsLibcoreTestCases Test: Checked how the added @implSpec appear in generated docs: they appear under headings "Implementation Requirements:". Change-Id: I362ec405b270ba00fe3176dc19f08943b7d350d5
2020-01-17Refine documentation of getNativeTid() functionRick Yiu
Add description for the meaning of return value 0 as well. Bug: 139521784 Test: compile Change-Id: I5dda70576630a2d7f82d052e6ab1c9c85f79749a
2020-01-17Merge "Use ThreadPrioritySetter to set thread priority"Rick Yiu
2020-01-17Merge "Fix @link tags in @ChangeId javadocs."Treehugger Robot
2020-01-17Fix @link tags in @ChangeId javadocs.Mathew Inwood
We will soon have developer facing docs generated from all @ChangeId constants. Make sure links in those docs work as expected. Bug: 144927670 Test: In follow-up CLs. Change-Id: I8d200246490d7f5eb73dd1c56a0c66262394d2eb