mirror of
https://github.com/corda/corda.git
synced 2025-06-15 13:48:14 +00:00
fix all the bugs
So there I was, planning to just fix one little bug: Thread.holdsLock and Thread.yield were missing for the Android class library. Easy enough, right? So, I added a test, got it passing, and figured I'd go ahead and run ci.sh with all three class libraries. Big mistake. Here's the stuff I found: * minor inconsistency in README.md about OpenSSL version * untested, broken Class.getEnclosingMethod (reported by Josh) * JNI test failed for tails=true Android build * Runtime.nativeExit missing for Android build * obsolete assertion in CallEvent broke tails=true Android build * obsolete superclass field offset padding broke bootimage=true Android build * runtime annotation parsing broke bootimage=true Android build (because we couldn't modify Addendum.annotationTable for classes in the heap image) * ci.sh tried building with both android=... and openjdk=..., which the makefile rightfully balked at Sorry this is all in a single commit; I didn't expect so many unrelated issues, and I'm too lazy to break them apart.
This commit is contained in:
@ -1,4 +1,10 @@
|
||||
public class Threads implements Runnable {
|
||||
public class Threads implements Runnable {
|
||||
private static boolean success = false;
|
||||
|
||||
private static void expect(boolean v) {
|
||||
if (! v) throw new RuntimeException();
|
||||
}
|
||||
|
||||
public static void main(String[] args) throws Exception {
|
||||
{ Threads test = new Threads();
|
||||
Thread thread = new Thread(test);
|
||||
@ -40,15 +46,24 @@ public class Threads implements Runnable {
|
||||
thread.join();
|
||||
}
|
||||
|
||||
System.out.println("finished");
|
||||
System.out.println("finished; success? " + success);
|
||||
|
||||
if (! success) {
|
||||
System.exit(-1);
|
||||
}
|
||||
}
|
||||
|
||||
public void run() {
|
||||
synchronized (this) {
|
||||
int i = 0;
|
||||
try {
|
||||
int i = 0;
|
||||
try {
|
||||
expect(! Thread.holdsLock(this));
|
||||
synchronized (this) {
|
||||
expect(Thread.holdsLock(this));
|
||||
|
||||
System.out.println("I'm running in a separate thread!");
|
||||
|
||||
Thread.yield(); // just to prove Thread.yield exists and is callable
|
||||
|
||||
final int arrayCount = 16;
|
||||
final int arraySize = 4;
|
||||
System.out.println("Allocating and discarding " + arrayCount +
|
||||
@ -57,14 +72,18 @@ public class Threads implements Runnable {
|
||||
byte[] array = new byte[arraySize * 1024 * 1024];
|
||||
}
|
||||
|
||||
long nap = 5;
|
||||
System.out.println("sleeping for " + nap + " seconds");
|
||||
Thread.sleep(nap * 1000);
|
||||
} catch (Throwable e) {
|
||||
System.err.println("caught something in second thread after " + i +
|
||||
" iterations");
|
||||
e.printStackTrace();
|
||||
} finally {
|
||||
long nap = 500;
|
||||
System.out.println("sleeping for " + nap + " milliseconds");
|
||||
Thread.sleep(nap);
|
||||
notifyAll();
|
||||
}
|
||||
success = true;
|
||||
} catch (Throwable e) {
|
||||
System.err.println("caught something in second thread after " + i +
|
||||
" iterations");
|
||||
e.printStackTrace();
|
||||
} finally {
|
||||
synchronized (this) {
|
||||
notifyAll();
|
||||
}
|
||||
}
|
||||
|
Reference in New Issue
Block a user