summaryrefslogtreecommitdiff
path: root/include/ScopedJavaUnicodeString.h
diff options
context:
space:
mode:
authorPaul Duffin <paulduffin@google.com>2018-05-24 14:31:43 +0100
committerPaul Duffin <paulduffin@google.com>2018-08-02 16:09:49 +0100
commit4e17ca1a1f05e1d9064ab964df5bf3ea0e167875 (patch)
treeaa19c6804e293a57b8f4e2a0f517f86a24ce8139 /include/ScopedJavaUnicodeString.h
parentcff96b90e8aefab2c825653e317e078118a62ef2 (diff)
Verify Thread against upstream OpenJDK 8u121-b13.
Did some minor reformatting to improve consistency with upstream. started field - Moved to be adjacent to the threadStatus field which it replaces, in part. Documented how the started field corresponds to Thread.State and threadStatus. threadStatus field - Replaced remaining usage with started and commented out completely. The threadStatus field is initialized to 0 by default and is never modified, even by native code. That means that the test: (threadStatus != 0 || started) is equivalent to: (false || started) which is: (started) blockedOn() - Kept patch to make this @hide public as it is used by java.nio.channels.spi.AbstractInterruptibleChannel sleep() - Kept improved parameter validation patch as it provides more meaningful error messages, will add them to list of patchs that we could potentially upstream. Kept remaining Android specific patch to implement sleep() in Java using a native helper method as it attempts nanosecond (as opposed to millisecond) accuracy and moving the implementation to make it purely native as it is upstream would be costly in terms of development time and risky for no real benefit. init(...) - The call to setName() was replaced with upstream code to explicitly check the name parameter and set the name field. It behaves exactly as the call to setName() would, even though setName() does more than just set the field. i.e. setName() * calls checkAccess() but that is a noop final method. * sets the name of the native thread if it is active, nativePeer != 0. However, nativePeer == 0 at the point setName() was called from the init() method. - Reorganized the initialization to make it as close to upstream as possible. <init>()/init2() methods - Kept Android specific constructor as it is used by the runtime when creating the adb connection thread. Similarly, the init2() method encapsulates functionality that is needed by both the standard and Android specific constructors. start() - Remove usage of threadStatus as it always evaluated to false. The threadStatus field is initialized to 0 by default and is never modified, even by native code. That means that the test: (threadStatus != 0 || started) is equivalent to: (false || started) or simply: (started) - Kept patches to change started from local variable to a field and to use the Android specific native method to create/start the thread. stop() - Changed it to simply throw an UnsupportedOperationException directly as that is what it previously did and it is no longer the same as upstream so we have to keep a patch anyway. Updated JavaDoc too. stop(Throwable) - Added synchronized keyword to match upstream as it makes no difference as the method should not be being called. interrupt() - Kept patch to rename upstream interrupt0() as nativeInterrupt(). Will investigate as part of the follow up bug whether this can be reverted. interrupted()/isInterrupted() - Kept patch but provided detailed explanation as to the difference from upstream. Will investigate as part of the follow up bug whether this can be reverted. destroy() - Kept patch to throw UOE instead of NoSuchMethodError. isAlive() - Kept patch to implement using pure Java. suspend()/resume() - Kept patches to throw UOE as upstream has been deprecated and method is deadlock-prone. setPriority() - Kept patches to throw more meaningful exception, to synchronize around setting the priority and to avoid calling the native method if the thread has not yet started. setName(String) - Added synchronized keyword and removed synchronized(this) block to match upstream. The moving of the checkAccess() and null check out of the synchronized block is not worth maintaining a patch. getThreadGroup() - Kept patch to correct behavior when the thread has been terminated but improved documentation. countStackFrames() - Kept patch to provide Java implementation, is less efficient than a native method but it is deprecated and it is unlikely anyone uses it. join() - Kept patch to sychronize on separate lock object rather than the current Thread. Could not find any clear explanation why this change was made. checkAccess()/getContextClassLoader()/setContextClassLoader()/ setDefaultUncaughtExceptionHandler() - Kept patches to comment out security code. getStackTrace() - Kept patch to implement in terms of VMStack. getAllStackTraces() - Restructured a little to more closely match upstream. getState() - Kept patch to use started instead of threadStatus. uncaughtExceptionPreHandler and methods - Kept patch as is used by platform. Kept the patch to support park/unpark. During this work some issues were found that require further work and investigation. These are recorded in b/80180276. Tested using: make checkbuild, flash and CtsLibcoreTestCases art/test/testrunner/run_build_test_target.py -j80 art-test The latter was needed because some art tests depend on implementation details of the Thread class, e.g. its allocated size, call stack for native methods currentThread() and getState(). Bug: 74379469 Test: As above Change-Id: Id9c9c37b764f13a1eb719521b05b8467a454d716
Diffstat (limited to 'include/ScopedJavaUnicodeString.h')
0 files changed, 0 insertions, 0 deletions