code
stringlengths
11
173k
docstring
stringlengths
2
593k
func_name
stringlengths
2
189
language
stringclasses
1 value
repo
stringclasses
833 values
path
stringlengths
11
294
url
stringlengths
60
339
license
stringclasses
4 values
public void testSaturatedSubmitRunnable() { final CountDownLatch done = new CountDownLatch(1); final ThreadPoolExecutor p = new ThreadPoolExecutor(1, 1, LONG_DELAY_MS, MILLISECONDS, new ArrayBlockingQueue<Runnable>(1)); try (PoolCleaner cleaner = cleaner(p, done)) { Runnable task = new CheckedRunnable() { public void realRun() throws InterruptedException { await(done); }}; for (int i = 0; i < 2; ++i) p.submit(task); for (int i = 0; i < 2; ++i) { try { p.execute(task); shouldThrow(); } catch (RejectedExecutionException success) {} assertTrue(p.getTaskCount() <= 2); } } }
submit(runnable) throws RejectedExecutionException if saturated.
FailingThreadFactory::testSaturatedSubmitRunnable
java
google/j2objc
jre_emul/android/platform/libcore/jsr166-tests/src/test/java/jsr166/ThreadPoolExecutorTest.java
https://github.com/google/j2objc/blob/master/jre_emul/android/platform/libcore/jsr166-tests/src/test/java/jsr166/ThreadPoolExecutorTest.java
Apache-2.0
public void testSaturatedSubmitCallable() { final CountDownLatch done = new CountDownLatch(1); final ThreadPoolExecutor p = new ThreadPoolExecutor(1, 1, LONG_DELAY_MS, MILLISECONDS, new ArrayBlockingQueue<Runnable>(1)); try (PoolCleaner cleaner = cleaner(p, done)) { Runnable task = new CheckedRunnable() { public void realRun() throws InterruptedException { await(done); }}; for (int i = 0; i < 2; ++i) p.submit(Executors.callable(task)); for (int i = 0; i < 2; ++i) { try { p.execute(task); shouldThrow(); } catch (RejectedExecutionException success) {} assertTrue(p.getTaskCount() <= 2); } } }
submit(callable) throws RejectedExecutionException if saturated.
FailingThreadFactory::testSaturatedSubmitCallable
java
google/j2objc
jre_emul/android/platform/libcore/jsr166-tests/src/test/java/jsr166/ThreadPoolExecutorTest.java
https://github.com/google/j2objc/blob/master/jre_emul/android/platform/libcore/jsr166-tests/src/test/java/jsr166/ThreadPoolExecutorTest.java
Apache-2.0
public void testMaximumPoolSizeIllegalArgumentException() { final ThreadPoolExecutor p = new ThreadPoolExecutor(2, 3, LONG_DELAY_MS, MILLISECONDS, new ArrayBlockingQueue<Runnable>(10)); try (PoolCleaner cleaner = cleaner(p)) { try { p.setMaximumPoolSize(1); shouldThrow(); } catch (IllegalArgumentException success) {} } }
setMaximumPoolSize(int) throws IllegalArgumentException if given a value less the core pool size
FailingThreadFactory::testMaximumPoolSizeIllegalArgumentException
java
google/j2objc
jre_emul/android/platform/libcore/jsr166-tests/src/test/java/jsr166/ThreadPoolExecutorTest.java
https://github.com/google/j2objc/blob/master/jre_emul/android/platform/libcore/jsr166-tests/src/test/java/jsr166/ThreadPoolExecutorTest.java
Apache-2.0
public void testPoolSizeInvariants() { final ThreadPoolExecutor p = new ThreadPoolExecutor(1, 1, LONG_DELAY_MS, MILLISECONDS, new ArrayBlockingQueue<Runnable>(10)); try (PoolCleaner cleaner = cleaner(p)) { for (int s = 1; s < 5; s++) { p.setMaximumPoolSize(s); p.setCorePoolSize(s); try { p.setMaximumPoolSize(s - 1); shouldThrow(); } catch (IllegalArgumentException success) {} assertEquals(s, p.getCorePoolSize()); assertEquals(s, p.getMaximumPoolSize()); try { p.setCorePoolSize(s + 1); // Android-changed: changeset dfec9b5386ca028cc1468f3e2717120ab6274702 // disables this check for compatibility reason. // shouldThrow(); } catch (IllegalArgumentException success) {} // Android-changed: changeset dfec9b5386ca028cc1468f3e2717120ab6274702 // disables maximumpoolsize check for compatibility reason. // assertEquals(s, p.getCorePoolSize()); assertEquals(s + 1, p.getCorePoolSize()); assertEquals(s, p.getMaximumPoolSize()); } } }
Configuration changes that allow core pool size greater than max pool size result in IllegalArgumentException.
FailingThreadFactory::testPoolSizeInvariants
java
google/j2objc
jre_emul/android/platform/libcore/jsr166-tests/src/test/java/jsr166/ThreadPoolExecutorTest.java
https://github.com/google/j2objc/blob/master/jre_emul/android/platform/libcore/jsr166-tests/src/test/java/jsr166/ThreadPoolExecutorTest.java
Apache-2.0
public void testRejectedRecycledTask() throws InterruptedException { final int nTasks = 1000; final CountDownLatch done = new CountDownLatch(nTasks); final Runnable recycledTask = new Runnable() { public void run() { done.countDown(); }}; final ThreadPoolExecutor p = new ThreadPoolExecutor(1, 30, 60, SECONDS, new ArrayBlockingQueue(30)); try (PoolCleaner cleaner = cleaner(p)) { for (int i = 0; i < nTasks; ++i) { for (;;) { try { p.execute(recycledTask); break; } catch (RejectedExecutionException ignore) {} } } // enough time to run all tasks assertTrue(done.await(nTasks * SHORT_DELAY_MS, MILLISECONDS)); } }
execute allows the same task to be submitted multiple times, even if rejected
FailingThreadFactory::testRejectedRecycledTask
java
google/j2objc
jre_emul/android/platform/libcore/jsr166-tests/src/test/java/jsr166/ThreadPoolExecutorTest.java
https://github.com/google/j2objc/blob/master/jre_emul/android/platform/libcore/jsr166-tests/src/test/java/jsr166/ThreadPoolExecutorTest.java
Apache-2.0
public void testGet_cancelled() throws Exception { final CountDownLatch done = new CountDownLatch(1); final ExecutorService e = new ThreadPoolExecutor(1, 1, LONG_DELAY_MS, MILLISECONDS, new LinkedBlockingQueue<Runnable>()); try (PoolCleaner cleaner = cleaner(e, done)) { final CountDownLatch blockerStarted = new CountDownLatch(1); final List<Future<?>> futures = new ArrayList<>(); for (int i = 0; i < 2; i++) { Runnable r = new CheckedRunnable() { public void realRun() throws Throwable { blockerStarted.countDown(); assertTrue(done.await(2 * LONG_DELAY_MS, MILLISECONDS)); }}; futures.add(e.submit(r)); } await(blockerStarted); for (Future<?> future : futures) future.cancel(false); for (Future<?> future : futures) { try { future.get(); shouldThrow(); } catch (CancellationException success) {} try { future.get(LONG_DELAY_MS, MILLISECONDS); shouldThrow(); } catch (CancellationException success) {} assertTrue(future.isCancelled()); assertTrue(future.isDone()); } } }
get(cancelled task) throws CancellationException
FailingThreadFactory::testGet_cancelled
java
google/j2objc
jre_emul/android/platform/libcore/jsr166-tests/src/test/java/jsr166/ThreadPoolExecutorTest.java
https://github.com/google/j2objc/blob/master/jre_emul/android/platform/libcore/jsr166-tests/src/test/java/jsr166/ThreadPoolExecutorTest.java
Apache-2.0
public void testConstructor() { AtomicStampedReference ai = new AtomicStampedReference(one, 0); assertSame(one, ai.getReference()); assertEquals(0, ai.getStamp()); AtomicStampedReference a2 = new AtomicStampedReference(null, 1); assertNull(a2.getReference()); assertEquals(1, a2.getStamp()); }
constructor initializes to given reference and stamp
AtomicStampedReferenceTest::testConstructor
java
google/j2objc
jre_emul/android/platform/libcore/jsr166-tests/src/test/java/jsr166/AtomicStampedReferenceTest.java
https://github.com/google/j2objc/blob/master/jre_emul/android/platform/libcore/jsr166-tests/src/test/java/jsr166/AtomicStampedReferenceTest.java
Apache-2.0
public void testGetSet() { int[] mark = new int[1]; AtomicStampedReference ai = new AtomicStampedReference(one, 0); assertSame(one, ai.getReference()); assertEquals(0, ai.getStamp()); assertSame(one, ai.get(mark)); assertEquals(0, mark[0]); ai.set(two, 0); assertSame(two, ai.getReference()); assertEquals(0, ai.getStamp()); assertSame(two, ai.get(mark)); assertEquals(0, mark[0]); ai.set(one, 1); assertSame(one, ai.getReference()); assertEquals(1, ai.getStamp()); assertSame(one, ai.get(mark)); assertEquals(1, mark[0]); }
get returns the last values of reference and stamp set
AtomicStampedReferenceTest::testGetSet
java
google/j2objc
jre_emul/android/platform/libcore/jsr166-tests/src/test/java/jsr166/AtomicStampedReferenceTest.java
https://github.com/google/j2objc/blob/master/jre_emul/android/platform/libcore/jsr166-tests/src/test/java/jsr166/AtomicStampedReferenceTest.java
Apache-2.0
public void testAttemptStamp() { int[] mark = new int[1]; AtomicStampedReference ai = new AtomicStampedReference(one, 0); assertEquals(0, ai.getStamp()); assertTrue(ai.attemptStamp(one, 1)); assertEquals(1, ai.getStamp()); assertSame(one, ai.get(mark)); assertEquals(1, mark[0]); }
attemptStamp succeeds in single thread
AtomicStampedReferenceTest::testAttemptStamp
java
google/j2objc
jre_emul/android/platform/libcore/jsr166-tests/src/test/java/jsr166/AtomicStampedReferenceTest.java
https://github.com/google/j2objc/blob/master/jre_emul/android/platform/libcore/jsr166-tests/src/test/java/jsr166/AtomicStampedReferenceTest.java
Apache-2.0
public void testCompareAndSet() { int[] mark = new int[1]; AtomicStampedReference ai = new AtomicStampedReference(one, 0); assertSame(one, ai.get(mark)); assertEquals(0, ai.getStamp()); assertEquals(0, mark[0]); assertTrue(ai.compareAndSet(one, two, 0, 0)); assertSame(two, ai.get(mark)); assertEquals(0, mark[0]); assertTrue(ai.compareAndSet(two, m3, 0, 1)); assertSame(m3, ai.get(mark)); assertEquals(1, mark[0]); assertFalse(ai.compareAndSet(two, m3, 1, 1)); assertSame(m3, ai.get(mark)); assertEquals(1, mark[0]); }
compareAndSet succeeds in changing values if equal to expected reference and stamp else fails
AtomicStampedReferenceTest::testCompareAndSet
java
google/j2objc
jre_emul/android/platform/libcore/jsr166-tests/src/test/java/jsr166/AtomicStampedReferenceTest.java
https://github.com/google/j2objc/blob/master/jre_emul/android/platform/libcore/jsr166-tests/src/test/java/jsr166/AtomicStampedReferenceTest.java
Apache-2.0
public void testCompareAndSetInMultipleThreads2() throws Exception { final AtomicStampedReference ai = new AtomicStampedReference(one, 0); Thread t = new Thread(new CheckedRunnable() { public void realRun() { while (!ai.compareAndSet(one, one, 1, 2)) Thread.yield(); }}); t.start(); assertTrue(ai.compareAndSet(one, one, 0, 1)); t.join(LONG_DELAY_MS); assertFalse(t.isAlive()); assertSame(one, ai.getReference()); assertEquals(2, ai.getStamp()); }
compareAndSet in one thread enables another waiting for stamp value to succeed
AtomicStampedReferenceTest::testCompareAndSetInMultipleThreads2
java
google/j2objc
jre_emul/android/platform/libcore/jsr166-tests/src/test/java/jsr166/AtomicStampedReferenceTest.java
https://github.com/google/j2objc/blob/master/jre_emul/android/platform/libcore/jsr166-tests/src/test/java/jsr166/AtomicStampedReferenceTest.java
Apache-2.0
public void testConstructor2() { AtomicBoolean ai = new AtomicBoolean(); assertFalse(ai.get()); }
default constructed initializes to false
AtomicBooleanTest::testConstructor2
java
google/j2objc
jre_emul/android/platform/libcore/jsr166-tests/src/test/java/jsr166/AtomicBooleanTest.java
https://github.com/google/j2objc/blob/master/jre_emul/android/platform/libcore/jsr166-tests/src/test/java/jsr166/AtomicBooleanTest.java
Apache-2.0
public void testJoinIgnoresInterruptsOutsideForkJoinPool() { final SynchronousQueue<FibAction[]> sq = new SynchronousQueue<FibAction[]>(); RecursiveAction a = new CheckedRecursiveAction() { protected void realCompute() throws InterruptedException { FibAction[] fibActions = new FibAction[6]; for (int i = 0; i < fibActions.length; i++) fibActions[i] = new FibAction(8); fibActions[1].cancel(false); fibActions[2].completeExceptionally(new FJException()); fibActions[4].cancel(true); fibActions[5].completeExceptionally(new FJException()); for (int i = 0; i < fibActions.length; i++) fibActions[i].fork(); sq.put(fibActions); helpQuiesce(); }}; Runnable r = new CheckedRunnable() { public void realRun() throws InterruptedException { FibAction[] fibActions = sq.take(); FibAction f; final Thread myself = Thread.currentThread(); // test join() ------------ f = fibActions[0]; assertFalse(ForkJoinTask.inForkJoinPool()); myself.interrupt(); assertTrue(myself.isInterrupted()); assertNull(f.join()); assertTrue(Thread.interrupted()); assertEquals(21, f.result); checkCompletedNormally(f); f = fibActions[1]; myself.interrupt(); assertTrue(myself.isInterrupted()); try { f.join(); shouldThrow(); } catch (CancellationException success) { assertTrue(Thread.interrupted()); checkCancelled(f); } f = fibActions[2]; myself.interrupt(); assertTrue(myself.isInterrupted()); try { f.join(); shouldThrow(); } catch (FJException success) { assertTrue(Thread.interrupted()); checkCompletedAbnormally(f, success); } // test quietlyJoin() --------- f = fibActions[3]; myself.interrupt(); assertTrue(myself.isInterrupted()); f.quietlyJoin(); assertTrue(Thread.interrupted()); assertEquals(21, f.result); checkCompletedNormally(f); f = fibActions[4]; myself.interrupt(); assertTrue(myself.isInterrupted()); f.quietlyJoin(); assertTrue(Thread.interrupted()); checkCancelled(f); f = fibActions[5]; myself.interrupt(); assertTrue(myself.isInterrupted()); f.quietlyJoin(); assertTrue(Thread.interrupted()); assertTrue(f.getException() instanceof FJException); checkCompletedAbnormally(f, f.getException()); }}; Thread t; t = newStartedThread(r); testInvokeOnPool(mainPool(), a); awaitTermination(t); a.reinitialize(); t = newStartedThread(r); testInvokeOnPool(singletonPool(), a); awaitTermination(t); }
join/quietlyJoin of a forked task when not in ForkJoinPool succeeds in the presence of interrupts
FailingFibAction::testJoinIgnoresInterruptsOutsideForkJoinPool
java
google/j2objc
jre_emul/android/platform/libcore/jsr166-tests/src/test/java/jsr166/RecursiveActionTest.java
https://github.com/google/j2objc/blob/master/jre_emul/android/platform/libcore/jsr166-tests/src/test/java/jsr166/RecursiveActionTest.java
Apache-2.0
public void testWorkerGetPool() { final ForkJoinPool mainPool = mainPool(); RecursiveAction a = new CheckedRecursiveAction() { protected void realCompute() { ForkJoinWorkerThread w = (ForkJoinWorkerThread) Thread.currentThread(); assertSame(mainPool, w.getPool()); }}; testInvokeOnPool(mainPool, a); }
getPool of current thread in pool returns its pool
FailingFibAction::testWorkerGetPool
java
google/j2objc
jre_emul/android/platform/libcore/jsr166-tests/src/test/java/jsr166/RecursiveActionTest.java
https://github.com/google/j2objc/blob/master/jre_emul/android/platform/libcore/jsr166-tests/src/test/java/jsr166/RecursiveActionTest.java
Apache-2.0
public void testWorkerGetPoolIndex() { final ForkJoinPool mainPool = mainPool(); RecursiveAction a = new CheckedRecursiveAction() { protected void realCompute() { ForkJoinWorkerThread w = (ForkJoinWorkerThread) Thread.currentThread(); assertTrue(w.getPoolIndex() >= 0); // pool size can shrink after assigning index, so cannot check // assertTrue(w.getPoolIndex() < mainPool.getPoolSize()); }}; testInvokeOnPool(mainPool, a); }
getPoolIndex of current thread in pool returns 0 <= value < poolSize
FailingFibAction::testWorkerGetPoolIndex
java
google/j2objc
jre_emul/android/platform/libcore/jsr166-tests/src/test/java/jsr166/RecursiveActionTest.java
https://github.com/google/j2objc/blob/master/jre_emul/android/platform/libcore/jsr166-tests/src/test/java/jsr166/RecursiveActionTest.java
Apache-2.0
public void testSortTaskDemo() { ThreadLocalRandom rnd = ThreadLocalRandom.current(); long[] array = new long[1007]; for (int i = 0; i < array.length; i++) array[i] = rnd.nextLong(); long[] arrayClone = array.clone(); testInvokeOnPool(mainPool(), new SortTask(array)); Arrays.sort(arrayClone); assertTrue(Arrays.equals(array, arrayClone)); }
SortTask demo works as advertised
SortTask::testSortTaskDemo
java
google/j2objc
jre_emul/android/platform/libcore/jsr166-tests/src/test/java/jsr166/RecursiveActionTest.java
https://github.com/google/j2objc/blob/master/jre_emul/android/platform/libcore/jsr166-tests/src/test/java/jsr166/RecursiveActionTest.java
Apache-2.0
public void testPurge() throws InterruptedException { final ScheduledFuture[] tasks = new ScheduledFuture[5]; final Runnable releaser = new Runnable() { public void run() { for (ScheduledFuture task : tasks) if (task != null) task.cancel(true); }}; final ScheduledThreadPoolExecutor p = new ScheduledThreadPoolExecutor(1); try (PoolCleaner cleaner = cleaner(p, releaser)) { for (int i = 0; i < tasks.length; i++) tasks[i] = p.schedule(new SmallPossiblyInterruptedRunnable(), LONG_DELAY_MS, MILLISECONDS); int max = tasks.length; if (tasks[4].cancel(true)) --max; if (tasks[3].cancel(true)) --max; // There must eventually be an interference-free point at // which purge will not fail. (At worst, when queue is empty.) long startTime = System.nanoTime(); do { p.purge(); long count = p.getTaskCount(); if (count == max) return; } while (millisElapsedSince(startTime) < LONG_DELAY_MS); fail("Purge failed to remove cancelled tasks"); } }
purge eventually removes cancelled tasks from the queue
RunnableCounter::testPurge
java
google/j2objc
jre_emul/android/platform/libcore/jsr166-tests/src/test/java/jsr166/ScheduledExecutorTest.java
https://github.com/google/j2objc/blob/master/jre_emul/android/platform/libcore/jsr166-tests/src/test/java/jsr166/ScheduledExecutorTest.java
Apache-2.0
public void testScheduleWithFixedDelay_overflow() throws Exception { final CountDownLatch delayedDone = new CountDownLatch(1); final CountDownLatch immediateDone = new CountDownLatch(1); final ScheduledThreadPoolExecutor p = new ScheduledThreadPoolExecutor(1); try (PoolCleaner cleaner = cleaner(p)) { final Runnable immediate = new Runnable() { public void run() { immediateDone.countDown(); }}; final Runnable delayed = new Runnable() { public void run() { delayedDone.countDown(); p.submit(immediate); }}; p.scheduleWithFixedDelay(delayed, 0L, Long.MAX_VALUE, SECONDS); await(delayedDone); await(immediateDone); } }
A fixed delay task with overflowing period should not prevent a one-shot task from executing. https://bugs.openjdk.java.net/browse/JDK-8051859
RunnableCounter::testScheduleWithFixedDelay_overflow
java
google/j2objc
jre_emul/android/platform/libcore/jsr166-tests/src/test/java/jsr166/ScheduledExecutorTest.java
https://github.com/google/j2objc/blob/master/jre_emul/android/platform/libcore/jsr166-tests/src/test/java/jsr166/ScheduledExecutorTest.java
Apache-2.0
public void testNanoTime1() throws InterruptedException { long m1 = System.currentTimeMillis(); Thread.sleep(1); long n1 = System.nanoTime(); Thread.sleep(SHORT_DELAY_MS); long n2 = System.nanoTime(); Thread.sleep(1); long m2 = System.currentTimeMillis(); long millis = m2 - m1; long nanos = n2 - n1; assertTrue(nanos >= 0); long nanosAsMillis = nanos / 1000000; assertTrue(nanosAsMillis <= millis + MILLIS_ROUND); }
Nanos between readings of millis is no longer than millis (plus possible rounding). This shows only that nano timing not (much) worse than milli.
SystemTest::testNanoTime1
java
google/j2objc
jre_emul/android/platform/libcore/jsr166-tests/src/test/java/jsr166/SystemTest.java
https://github.com/google/j2objc/blob/master/jre_emul/android/platform/libcore/jsr166-tests/src/test/java/jsr166/SystemTest.java
Apache-2.0
public void testNanoTime2() throws InterruptedException { long n1 = System.nanoTime(); Thread.sleep(1); long m1 = System.currentTimeMillis(); Thread.sleep(SHORT_DELAY_MS); long m2 = System.currentTimeMillis(); Thread.sleep(1); long n2 = System.nanoTime(); long millis = m2 - m1; long nanos = n2 - n1; assertTrue(nanos >= 0); long nanosAsMillis = nanos / 1000000; assertTrue(millis <= nanosAsMillis + MILLIS_ROUND); }
Millis between readings of nanos is less than nanos, adjusting for rounding. This shows only that nano timing not (much) worse than milli.
SystemTest::testNanoTime2
java
google/j2objc
jre_emul/android/platform/libcore/jsr166-tests/src/test/java/jsr166/SystemTest.java
https://github.com/google/j2objc/blob/master/jre_emul/android/platform/libcore/jsr166-tests/src/test/java/jsr166/SystemTest.java
Apache-2.0
public void testOffer() { ConcurrentLinkedQueue q = new ConcurrentLinkedQueue(); assertTrue(q.offer(zero)); assertTrue(q.offer(one)); }
Offer returns true
ConcurrentLinkedQueueTest::testOffer
java
google/j2objc
jre_emul/android/platform/libcore/jsr166-tests/src/test/java/jsr166/ConcurrentLinkedQueueTest.java
https://github.com/google/j2objc/blob/master/jre_emul/android/platform/libcore/jsr166-tests/src/test/java/jsr166/ConcurrentLinkedQueueTest.java
Apache-2.0
public void testAdd() { ConcurrentLinkedQueue q = new ConcurrentLinkedQueue(); for (int i = 0; i < SIZE; ++i) { assertEquals(i, q.size()); assertTrue(q.add(new Integer(i))); } }
add returns true
ConcurrentLinkedQueueTest::testAdd
java
google/j2objc
jre_emul/android/platform/libcore/jsr166-tests/src/test/java/jsr166/ConcurrentLinkedQueueTest.java
https://github.com/google/j2objc/blob/master/jre_emul/android/platform/libcore/jsr166-tests/src/test/java/jsr166/ConcurrentLinkedQueueTest.java
Apache-2.0
public static ArrayList<String> testMethodNames(Class<?> testClass) { Method[] methods = testClass.getDeclaredMethods(); ArrayList<String> names = new ArrayList<String>(methods.length); for (Method method : methods) { if (method.getName().startsWith("test") && Modifier.isPublic(method.getModifiers()) // method.getParameterCount() requires jdk8+ && method.getParameterTypes().length == 0) { names.add(method.getName()); } } return names; }
Collects all JSR166 unit tests as one suite. // android-note: Removed because the CTS runner does a bad job of // public static Test suite() { // // Java7+ test classes // TestSuite suite = newTestSuite( // ForkJoinPoolTest.suite(), // ForkJoinTaskTest.suite(), // RecursiveActionTest.suite(), // RecursiveTaskTest.suite(), // LinkedTransferQueueTest.suite(), // PhaserTest.suite(), // ThreadLocalRandomTest.suite(), // AbstractExecutorServiceTest.suite(), // AbstractQueueTest.suite(), // AbstractQueuedSynchronizerTest.suite(), // AbstractQueuedLongSynchronizerTest.suite(), // ArrayBlockingQueueTest.suite(), // ArrayDequeTest.suite(), // AtomicBooleanTest.suite(), // AtomicIntegerArrayTest.suite(), // AtomicIntegerFieldUpdaterTest.suite(), // AtomicIntegerTest.suite(), // AtomicLongArrayTest.suite(), // AtomicLongFieldUpdaterTest.suite(), // AtomicLongTest.suite(), // AtomicMarkableReferenceTest.suite(), // AtomicReferenceArrayTest.suite(), // AtomicReferenceFieldUpdaterTest.suite(), // AtomicReferenceTest.suite(), // AtomicStampedReferenceTest.suite(), // ConcurrentHashMapTest.suite(), // ConcurrentLinkedDequeTest.suite(), // ConcurrentLinkedQueueTest.suite(), // ConcurrentSkipListMapTest.suite(), // ConcurrentSkipListSubMapTest.suite(), // ConcurrentSkipListSetTest.suite(), // ConcurrentSkipListSubSetTest.suite(), // CopyOnWriteArrayListTest.suite(), // CopyOnWriteArraySetTest.suite(), // CountDownLatchTest.suite(), // CyclicBarrierTest.suite(), // DelayQueueTest.suite(), // EntryTest.suite(), // ExchangerTest.suite(), // ExecutorsTest.suite(), // ExecutorCompletionServiceTest.suite(), // FutureTaskTest.suite(), // LinkedBlockingDequeTest.suite(), // LinkedBlockingQueueTest.suite(), // LinkedListTest.suite(), // LockSupportTest.suite(), // PriorityBlockingQueueTest.suite(), // PriorityQueueTest.suite(), // ReentrantLockTest.suite(), // ReentrantReadWriteLockTest.suite(), // ScheduledExecutorTest.suite(), // ScheduledExecutorSubclassTest.suite(), // SemaphoreTest.suite(), // SynchronousQueueTest.suite(), // SystemTest.suite(), // ThreadLocalTest.suite(), // ThreadPoolExecutorTest.suite(), // ThreadPoolExecutorSubclassTest.suite(), // ThreadTest.suite(), // TimeUnitTest.suite(), // TreeMapTest.suite(), // TreeSetTest.suite(), // TreeSubMapTest.suite(), // TreeSubSetTest.suite()); // // Java8+ test classes // if (atLeastJava8()) { // String[] java8TestClassNames = { // "Atomic8Test", // "CompletableFutureTest", // "ConcurrentHashMap8Test", // "CountedCompleterTest", // "DoubleAccumulatorTest", // "DoubleAdderTest", // "ForkJoinPool8Test", // "ForkJoinTask8Test", // "LongAccumulatorTest", // "LongAdderTest", // "SplittableRandomTest", // "StampedLockTest", // "SubmissionPublisherTest", // "ThreadLocalRandom8Test", // }; // addNamedTestClasses(suite, java8TestClassNames); // } // // Java9+ test classes // if (atLeastJava9()) { // String[] java9TestClassNames = { // // Currently empty, but expecting varhandle tests // }; // addNamedTestClasses(suite, java9TestClassNames); // } // return suite; // } /** Returns list of junit-style test method names in given class.
JSR166TestCase::testMethodNames
java
google/j2objc
jre_emul/android/platform/libcore/jsr166-tests/src/test/java/jsr166/JSR166TestCase.java
https://github.com/google/j2objc/blob/master/jre_emul/android/platform/libcore/jsr166-tests/src/test/java/jsr166/JSR166TestCase.java
Apache-2.0
public static synchronized void set(SocketTagger tagger) { if (tagger == null) { throw new NullPointerException("tagger == null"); } SocketTagger.tagger = tagger; }
Sets this process' socket tagger to {@code tagger}.
SocketTagger::set
java
google/j2objc
jre_emul/android/platform/libcore/dalvik/src/main/java/dalvik/system/SocketTagger.java
https://github.com/google/j2objc/blob/master/jre_emul/android/platform/libcore/dalvik/src/main/java/dalvik/system/SocketTagger.java
Apache-2.0
public static synchronized SocketTagger get() { return tagger; }
Returns this process socket tagger.
SocketTagger::get
java
google/j2objc
jre_emul/android/platform/libcore/dalvik/src/main/java/dalvik/system/SocketTagger.java
https://github.com/google/j2objc/blob/master/jre_emul/android/platform/libcore/dalvik/src/main/java/dalvik/system/SocketTagger.java
Apache-2.0
public static final Policy LAX_POLICY = new Policy() { public void onWriteToDisk() {} public void onReadFromDisk() {} public void onNetwork() {} public int getPolicyMask() { return 0; } };
The default, permissive policy that doesn't prevent any operations.
BlockGuardPolicyException::Policy
java
google/j2objc
jre_emul/android/platform/libcore/dalvik/src/main/java/dalvik/system/BlockGuard.java
https://github.com/google/j2objc/blob/master/jre_emul/android/platform/libcore/dalvik/src/main/java/dalvik/system/BlockGuard.java
Apache-2.0
public static Policy getThreadPolicy() { return threadPolicy.get(); }
Get the current thread's policy. @return the current thread's policy. Never returns null. Will return the LAX_POLICY instance if nothing else is set.
BlockGuardPolicyException::getThreadPolicy
java
google/j2objc
jre_emul/android/platform/libcore/dalvik/src/main/java/dalvik/system/BlockGuard.java
https://github.com/google/j2objc/blob/master/jre_emul/android/platform/libcore/dalvik/src/main/java/dalvik/system/BlockGuard.java
Apache-2.0
public static void setThreadPolicy(Policy policy) { if (policy == null) { throw new NullPointerException("policy == null"); } threadPolicy.set(policy); }
Sets the current thread's block guard policy. @param policy policy to set. May not be null. Use the public LAX_POLICY if you want to unset the active policy.
BlockGuardPolicyException::setThreadPolicy
java
google/j2objc
jre_emul/android/platform/libcore/dalvik/src/main/java/dalvik/system/BlockGuard.java
https://github.com/google/j2objc/blob/master/jre_emul/android/platform/libcore/dalvik/src/main/java/dalvik/system/BlockGuard.java
Apache-2.0
public static CloseGuard get() { if (!ENABLED) { return NOOP; } return new CloseGuard(); }
Returns a CloseGuard instance. If CloseGuard is enabled, {@code #open(String)} can be used to set up the instance to warn on failure to close. If CloseGuard is disabled, a non-null no-op instance is returned.
CloseGuard::get
java
google/j2objc
jre_emul/android/platform/libcore/dalvik/src/main/java/dalvik/system/CloseGuard.java
https://github.com/google/j2objc/blob/master/jre_emul/android/platform/libcore/dalvik/src/main/java/dalvik/system/CloseGuard.java
Apache-2.0
public static void setEnabled(boolean enabled) { ENABLED = enabled; }
Used to enable or disable CloseGuard. Note that CloseGuard only warns if it is enabled for both allocation and finalization.
CloseGuard::setEnabled
java
google/j2objc
jre_emul/android/platform/libcore/dalvik/src/main/java/dalvik/system/CloseGuard.java
https://github.com/google/j2objc/blob/master/jre_emul/android/platform/libcore/dalvik/src/main/java/dalvik/system/CloseGuard.java
Apache-2.0
public static boolean isEnabled() { return ENABLED; }
True if CloseGuard mechanism is enabled.
CloseGuard::isEnabled
java
google/j2objc
jre_emul/android/platform/libcore/dalvik/src/main/java/dalvik/system/CloseGuard.java
https://github.com/google/j2objc/blob/master/jre_emul/android/platform/libcore/dalvik/src/main/java/dalvik/system/CloseGuard.java
Apache-2.0
public static void setReporter(Reporter reporter) { if (reporter == null) { throw new NullPointerException("reporter == null"); } REPORTER = reporter; }
Used to replace default Reporter used to warn of CloseGuard violations. Must be non-null.
CloseGuard::setReporter
java
google/j2objc
jre_emul/android/platform/libcore/dalvik/src/main/java/dalvik/system/CloseGuard.java
https://github.com/google/j2objc/blob/master/jre_emul/android/platform/libcore/dalvik/src/main/java/dalvik/system/CloseGuard.java
Apache-2.0
public static Reporter getReporter() { return REPORTER; }
Returns non-null CloseGuard.Reporter.
CloseGuard::getReporter
java
google/j2objc
jre_emul/android/platform/libcore/dalvik/src/main/java/dalvik/system/CloseGuard.java
https://github.com/google/j2objc/blob/master/jre_emul/android/platform/libcore/dalvik/src/main/java/dalvik/system/CloseGuard.java
Apache-2.0
public static void setTracker(Tracker tracker) { if (tracker == null) { throw new NullPointerException("tracker == null"); } currentTracker = tracker; }
Sets the {@link Tracker} that is notified when resources are allocated and released. <p>This is only intended for use by {@code dalvik.system.CloseGuardSupport} class and so MUST NOT be used for any other purposes. @throws NullPointerException if tracker is null
CloseGuard::setTracker
java
google/j2objc
jre_emul/android/platform/libcore/dalvik/src/main/java/dalvik/system/CloseGuard.java
https://github.com/google/j2objc/blob/master/jre_emul/android/platform/libcore/dalvik/src/main/java/dalvik/system/CloseGuard.java
Apache-2.0
public void open(String closer) { // always perform the check for valid API usage... if (closer == null) { throw new NullPointerException("closer == null"); } // ...but avoid allocating an allocationSite if disabled if (this == NOOP || !ENABLED) { return; } String message = "Explicit termination method '" + closer + "' not called"; allocationSite = new Throwable(message); currentTracker.open(allocationSite); }
If CloseGuard is enabled, {@code open} initializes the instance with a warning that the caller should have explicitly called the {@code closer} method instead of relying on finalization. @param closer non-null name of explicit termination method @throws NullPointerException if closer is null, regardless of whether or not CloseGuard is enabled
CloseGuard::open
java
google/j2objc
jre_emul/android/platform/libcore/dalvik/src/main/java/dalvik/system/CloseGuard.java
https://github.com/google/j2objc/blob/master/jre_emul/android/platform/libcore/dalvik/src/main/java/dalvik/system/CloseGuard.java
Apache-2.0
public void close() { currentTracker.close(allocationSite); allocationSite = null; }
Marks this CloseGuard instance as closed to avoid warnings on finalization.
CloseGuard::close
java
google/j2objc
jre_emul/android/platform/libcore/dalvik/src/main/java/dalvik/system/CloseGuard.java
https://github.com/google/j2objc/blob/master/jre_emul/android/platform/libcore/dalvik/src/main/java/dalvik/system/CloseGuard.java
Apache-2.0
public void warnIfOpen() { if (allocationSite == null || !ENABLED) { return; } String message = ("A resource was acquired at attached stack trace but never released. " + "See java.io.Closeable for information on avoiding resource leaks."); REPORTER.report(message, allocationSite); }
If CloseGuard is enabled, logs a warning if the caller did not properly cleanup by calling an explicit close method before finalization. If CloseGuard is disabled, no action is performed.
CloseGuard::warnIfOpen
java
google/j2objc
jre_emul/android/platform/libcore/dalvik/src/main/java/dalvik/system/CloseGuard.java
https://github.com/google/j2objc/blob/master/jre_emul/android/platform/libcore/dalvik/src/main/java/dalvik/system/CloseGuard.java
Apache-2.0
public CloseGuardMonitor() { System.logI("Creating CloseGuard monitor"); // Save current reporter. closeGuardReporter = CloseGuard.getReporter(); // Override the reporter with our own which collates the allocation sites. CloseGuard.setReporter(new Reporter() { @Override public void report(String message, Throwable allocationSite) { // Ignore message as it's always the same. closeGuardAllocationSites.add(allocationSite); } }); }
Default constructor required for reflection.
CloseGuardMonitor::CloseGuardMonitor
java
google/j2objc
jre_emul/android/platform/libcore/dalvik/src/test/java/dalvik/system/CloseGuardMonitor.java
https://github.com/google/j2objc/blob/master/jre_emul/android/platform/libcore/dalvik/src/test/java/dalvik/system/CloseGuardMonitor.java
Apache-2.0
public static void assertAssignableFrom(Class<?> expected, Object actual) { assertAssignableFrom(expected, actual.getClass()); }
Asserts that the class {@code expected} is assignable from the object {@code actual}. This verifies {@code expected} is a parent class or a interface that {@code actual} implements.
MoreAsserts::assertAssignableFrom
java
google/j2objc
jre_emul/android/frameworks/base/tests-runner/src/android/test/MoreAsserts.java
https://github.com/google/j2objc/blob/master/jre_emul/android/frameworks/base/tests-runner/src/android/test/MoreAsserts.java
Apache-2.0
public static void assertAssignableFrom(Class<?> expected, Class<?> actual) { Assert.assertTrue( "Expected " + expected.getCanonicalName() + " to be assignable from actual class " + actual.getCanonicalName(), expected.isAssignableFrom(actual)); }
Asserts that class {@code expected} is assignable from the class {@code actual}. This verifies {@code expected} is a parent class or a interface that {@code actual} implements.
MoreAsserts::assertAssignableFrom
java
google/j2objc
jre_emul/android/frameworks/base/tests-runner/src/android/test/MoreAsserts.java
https://github.com/google/j2objc/blob/master/jre_emul/android/frameworks/base/tests-runner/src/android/test/MoreAsserts.java
Apache-2.0
public static void assertNotEqual( String message, Object unexpected, Object actual) { if (equal(unexpected, actual)) { failEqual(message, unexpected); } }
Asserts that {@code actual} is not equal {@code unexpected}, according to both {@code ==} and {@link Object#equals}.
MoreAsserts::assertNotEqual
java
google/j2objc
jre_emul/android/frameworks/base/tests-runner/src/android/test/MoreAsserts.java
https://github.com/google/j2objc/blob/master/jre_emul/android/frameworks/base/tests-runner/src/android/test/MoreAsserts.java
Apache-2.0
public static void assertNotEqual(Object unexpected, Object actual) { assertNotEqual(null, unexpected, actual); }
Variant of {@link #assertNotEqual(String,Object,Object)} using a generic message.
MoreAsserts::assertNotEqual
java
google/j2objc
jre_emul/android/frameworks/base/tests-runner/src/android/test/MoreAsserts.java
https://github.com/google/j2objc/blob/master/jre_emul/android/frameworks/base/tests-runner/src/android/test/MoreAsserts.java
Apache-2.0
public static void assertEquals( String message, byte[] expected, byte[] actual) { if (expected.length != actual.length) { failWrongLength(message, expected.length, actual.length); } for (int i = 0; i < expected.length; i++) { if (expected[i] != actual[i]) { failWrongElement(message, i, expected[i], actual[i]); } } }
Asserts that array {@code actual} is the same size and every element equals those in array {@code expected}. On failure, message indicates specific element mismatch.
MoreAsserts::assertEquals
java
google/j2objc
jre_emul/android/frameworks/base/tests-runner/src/android/test/MoreAsserts.java
https://github.com/google/j2objc/blob/master/jre_emul/android/frameworks/base/tests-runner/src/android/test/MoreAsserts.java
Apache-2.0
public static void assertEquals( String message, int[] expected, int[] actual) { if (expected.length != actual.length) { failWrongLength(message, expected.length, actual.length); } for (int i = 0; i < expected.length; i++) { if (expected[i] != actual[i]) { failWrongElement(message, i, expected[i], actual[i]); } } }
Asserts that array {@code actual} is the same size and every element equals those in array {@code expected}. On failure, message indicates first specific element mismatch.
MoreAsserts::assertEquals
java
google/j2objc
jre_emul/android/frameworks/base/tests-runner/src/android/test/MoreAsserts.java
https://github.com/google/j2objc/blob/master/jre_emul/android/frameworks/base/tests-runner/src/android/test/MoreAsserts.java
Apache-2.0
public static void assertEquals( String message, Object[] expected, Object[] actual) { if (expected.length != actual.length) { failWrongLength(message, expected.length, actual.length); } for (int i = 0; i < expected.length; i++) { Object exp = expected[i]; Object act = actual[i]; // The following borrowed from java.util.equals(Object[], Object[]). if (!((exp==null) ? act==null : exp.equals(act))) { failWrongElement(message, i, exp, act); } } }
Asserts that array {@code actual} is the same size and every element is the same as those in array {@code expected}. Note that this uses {@code equals()} instead of {@code ==} to compare the objects. {@code null} will be considered equal to {@code null} (unlike SQL). On failure, message indicates first specific element mismatch.
MoreAsserts::assertEquals
java
google/j2objc
jre_emul/android/frameworks/base/tests-runner/src/android/test/MoreAsserts.java
https://github.com/google/j2objc/blob/master/jre_emul/android/frameworks/base/tests-runner/src/android/test/MoreAsserts.java
Apache-2.0
public static void assertEquals(Object[] expected, Object[] actual) { assertEquals(null, expected, actual); }
Asserts that array {@code actual} is the same size and every element is the same as those in array {@code expected}. Note that this uses {@code ==} instead of {@code equals()} to compare the objects. On failure, message indicates first specific element mismatch.
MoreAsserts::assertEquals
java
google/j2objc
jre_emul/android/frameworks/base/tests-runner/src/android/test/MoreAsserts.java
https://github.com/google/j2objc/blob/master/jre_emul/android/frameworks/base/tests-runner/src/android/test/MoreAsserts.java
Apache-2.0
public static void assertEquals( String message, Set<? extends Object> expected, Set<? extends Object> actual) { Set<Object> onlyInExpected = new HashSet<Object>(expected); onlyInExpected.removeAll(actual); Set<Object> onlyInActual = new HashSet<Object>(actual); onlyInActual.removeAll(expected); if (onlyInExpected.size() != 0 || onlyInActual.size() != 0) { Set<Object> intersection = new HashSet<Object>(expected); intersection.retainAll(actual); failWithMessage( message, "Sets do not match.\nOnly in expected: " + onlyInExpected + "\nOnly in actual: " + onlyInActual + "\nIntersection: " + intersection); } }
Asserts that array {@code actual} is the same size and every element is the same as those in array {@code expected}. Note that this uses {@code ==} instead of {@code equals()} to compare the objects. On failure, message indicates first specific element mismatch. public static void assertEquals(Object[] expected, Object[] actual) { assertEquals(null, expected, actual); } /** Asserts that two sets contain the same elements.
MoreAsserts::assertEquals
java
google/j2objc
jre_emul/android/frameworks/base/tests-runner/src/android/test/MoreAsserts.java
https://github.com/google/j2objc/blob/master/jre_emul/android/frameworks/base/tests-runner/src/android/test/MoreAsserts.java
Apache-2.0
public static void assertEquals(Set<? extends Object> expected, Set<? extends Object> actual) { assertEquals(null, expected, actual); }
Asserts that array {@code actual} is the same size and every element is the same as those in array {@code expected}. Note that this uses {@code ==} instead of {@code equals()} to compare the objects. On failure, message indicates first specific element mismatch. public static void assertEquals(Object[] expected, Object[] actual) { assertEquals(null, expected, actual); } /** Asserts that two sets contain the same elements. public static void assertEquals( String message, Set<? extends Object> expected, Set<? extends Object> actual) { Set<Object> onlyInExpected = new HashSet<Object>(expected); onlyInExpected.removeAll(actual); Set<Object> onlyInActual = new HashSet<Object>(actual); onlyInActual.removeAll(expected); if (onlyInExpected.size() != 0 || onlyInActual.size() != 0) { Set<Object> intersection = new HashSet<Object>(expected); intersection.retainAll(actual); failWithMessage( message, "Sets do not match.\nOnly in expected: " + onlyInExpected + "\nOnly in actual: " + onlyInActual + "\nIntersection: " + intersection); } } /** Asserts that two sets contain the same elements.
MoreAsserts::assertEquals
java
google/j2objc
jre_emul/android/frameworks/base/tests-runner/src/android/test/MoreAsserts.java
https://github.com/google/j2objc/blob/master/jre_emul/android/frameworks/base/tests-runner/src/android/test/MoreAsserts.java
Apache-2.0
public static MatchResult assertMatchesRegex( String message, String expectedRegex, String actual) { if (actual == null) { failNotMatches(message, expectedRegex, actual); } Matcher matcher = getMatcher(expectedRegex, actual); if (!matcher.matches()) { failNotMatches(message, expectedRegex, actual); } return matcher; }
Asserts that {@code expectedRegex} exactly matches {@code actual} and fails with {@code message} if it does not. The MatchResult is returned in case the test needs access to any captured groups. Note that you can also use this for a literal string, by wrapping your expected string in {@link Pattern#quote}.
MoreAsserts::assertMatchesRegex
java
google/j2objc
jre_emul/android/frameworks/base/tests-runner/src/android/test/MoreAsserts.java
https://github.com/google/j2objc/blob/master/jre_emul/android/frameworks/base/tests-runner/src/android/test/MoreAsserts.java
Apache-2.0
public static MatchResult assertMatchesRegex( String expectedRegex, String actual) { return assertMatchesRegex(null, expectedRegex, actual); }
Variant of {@link #assertMatchesRegex(String,String,String)} using a generic message.
MoreAsserts::assertMatchesRegex
java
google/j2objc
jre_emul/android/frameworks/base/tests-runner/src/android/test/MoreAsserts.java
https://github.com/google/j2objc/blob/master/jre_emul/android/frameworks/base/tests-runner/src/android/test/MoreAsserts.java
Apache-2.0
public static MatchResult assertContainsRegex( String message, String expectedRegex, String actual) { if (actual == null) { failNotContains(message, expectedRegex, actual); } Matcher matcher = getMatcher(expectedRegex, actual); if (!matcher.find()) { failNotContains(message, expectedRegex, actual); } return matcher; }
Asserts that {@code expectedRegex} matches any substring of {@code actual} and fails with {@code message} if it does not. The Matcher is returned in case the test needs access to any captured groups. Note that you can also use this for a literal string, by wrapping your expected string in {@link Pattern#quote}.
MoreAsserts::assertContainsRegex
java
google/j2objc
jre_emul/android/frameworks/base/tests-runner/src/android/test/MoreAsserts.java
https://github.com/google/j2objc/blob/master/jre_emul/android/frameworks/base/tests-runner/src/android/test/MoreAsserts.java
Apache-2.0
public static MatchResult assertContainsRegex( String expectedRegex, String actual) { return assertContainsRegex(null, expectedRegex, actual); }
Variant of {@link #assertContainsRegex(String,String,String)} using a generic message.
MoreAsserts::assertContainsRegex
java
google/j2objc
jre_emul/android/frameworks/base/tests-runner/src/android/test/MoreAsserts.java
https://github.com/google/j2objc/blob/master/jre_emul/android/frameworks/base/tests-runner/src/android/test/MoreAsserts.java
Apache-2.0
public static void assertNotMatchesRegex( String message, String expectedRegex, String actual) { Matcher matcher = getMatcher(expectedRegex, actual); if (matcher.matches()) { failMatch(message, expectedRegex, actual); } }
Asserts that {@code expectedRegex} does not exactly match {@code actual}, and fails with {@code message} if it does. Note that you can also use this for a literal string, by wrapping your expected string in {@link Pattern#quote}.
MoreAsserts::assertNotMatchesRegex
java
google/j2objc
jre_emul/android/frameworks/base/tests-runner/src/android/test/MoreAsserts.java
https://github.com/google/j2objc/blob/master/jre_emul/android/frameworks/base/tests-runner/src/android/test/MoreAsserts.java
Apache-2.0
public static void assertNotMatchesRegex( String expectedRegex, String actual) { assertNotMatchesRegex(null, expectedRegex, actual); }
Variant of {@link #assertNotMatchesRegex(String,String,String)} using a generic message.
MoreAsserts::assertNotMatchesRegex
java
google/j2objc
jre_emul/android/frameworks/base/tests-runner/src/android/test/MoreAsserts.java
https://github.com/google/j2objc/blob/master/jre_emul/android/frameworks/base/tests-runner/src/android/test/MoreAsserts.java
Apache-2.0
public static void assertNotContainsRegex( String message, String expectedRegex, String actual) { Matcher matcher = getMatcher(expectedRegex, actual); if (matcher.find()) { failContains(message, expectedRegex, actual); } }
Asserts that {@code expectedRegex} does not match any substring of {@code actual}, and fails with {@code message} if it does. Note that you can also use this for a literal string, by wrapping your expected string in {@link Pattern#quote}.
MoreAsserts::assertNotContainsRegex
java
google/j2objc
jre_emul/android/frameworks/base/tests-runner/src/android/test/MoreAsserts.java
https://github.com/google/j2objc/blob/master/jre_emul/android/frameworks/base/tests-runner/src/android/test/MoreAsserts.java
Apache-2.0
public static void assertNotContainsRegex( String expectedRegex, String actual) { assertNotContainsRegex(null, expectedRegex, actual); }
Variant of {@link #assertNotContainsRegex(String,String,String)} using a generic message.
MoreAsserts::assertNotContainsRegex
java
google/j2objc
jre_emul/android/frameworks/base/tests-runner/src/android/test/MoreAsserts.java
https://github.com/google/j2objc/blob/master/jre_emul/android/frameworks/base/tests-runner/src/android/test/MoreAsserts.java
Apache-2.0
public static void assertContentsInOrder( String message, Iterable<?> actual, Object... expected) { ArrayList actualList = new ArrayList(); for (Object o : actual) { actualList.add(o); } Assert.assertEquals(message, Arrays.asList(expected), actualList); }
Asserts that {@code actual} contains precisely the elements {@code expected}, and in the same order.
MoreAsserts::assertContentsInOrder
java
google/j2objc
jre_emul/android/frameworks/base/tests-runner/src/android/test/MoreAsserts.java
https://github.com/google/j2objc/blob/master/jre_emul/android/frameworks/base/tests-runner/src/android/test/MoreAsserts.java
Apache-2.0
public static void assertContentsInOrder( Iterable<?> actual, Object... expected) { assertContentsInOrder((String) null, actual, expected); }
Variant of assertContentsInOrder(String, Iterable<?>, Object...) using a generic message.
MoreAsserts::assertContentsInOrder
java
google/j2objc
jre_emul/android/frameworks/base/tests-runner/src/android/test/MoreAsserts.java
https://github.com/google/j2objc/blob/master/jre_emul/android/frameworks/base/tests-runner/src/android/test/MoreAsserts.java
Apache-2.0
public static void assertContentsInAnyOrder(String message, Iterable<?> actual, Object... expected) { HashMap<Object, Object> expectedMap = new HashMap<Object, Object>(expected.length); for (Object expectedObj : expected) { expectedMap.put(expectedObj, expectedObj); } for (Object actualObj : actual) { if (expectedMap.remove(actualObj) == null) { failWithMessage(message, "Extra object in actual: (" + actualObj.toString() + ")"); } } if (expectedMap.size() > 0) { failWithMessage(message, "Extra objects in expected."); } }
Asserts that {@code actual} contains precisely the elements {@code expected}, but in any order.
MoreAsserts::assertContentsInAnyOrder
java
google/j2objc
jre_emul/android/frameworks/base/tests-runner/src/android/test/MoreAsserts.java
https://github.com/google/j2objc/blob/master/jre_emul/android/frameworks/base/tests-runner/src/android/test/MoreAsserts.java
Apache-2.0
public static void assertContentsInAnyOrder(Iterable<?> actual, Object... expected) { assertContentsInAnyOrder((String)null, actual, expected); }
Variant of assertContentsInAnyOrder(String, Iterable<?>, Object...) using a generic message.
MoreAsserts::assertContentsInAnyOrder
java
google/j2objc
jre_emul/android/frameworks/base/tests-runner/src/android/test/MoreAsserts.java
https://github.com/google/j2objc/blob/master/jre_emul/android/frameworks/base/tests-runner/src/android/test/MoreAsserts.java
Apache-2.0
public static void assertEmpty(String message, Iterable<?> iterable) { if (iterable.iterator().hasNext()) { failNotEmpty(message, iterable.toString()); } }
Asserts that {@code iterable} is empty.
MoreAsserts::assertEmpty
java
google/j2objc
jre_emul/android/frameworks/base/tests-runner/src/android/test/MoreAsserts.java
https://github.com/google/j2objc/blob/master/jre_emul/android/frameworks/base/tests-runner/src/android/test/MoreAsserts.java
Apache-2.0
public static void assertEmpty(Iterable<?> iterable) { assertEmpty(null, iterable); }
Variant of {@link #assertEmpty(String, Iterable)} using a generic message.
MoreAsserts::assertEmpty
java
google/j2objc
jre_emul/android/frameworks/base/tests-runner/src/android/test/MoreAsserts.java
https://github.com/google/j2objc/blob/master/jre_emul/android/frameworks/base/tests-runner/src/android/test/MoreAsserts.java
Apache-2.0
public static void assertEmpty(String message, Map<?,?> map) { if (!map.isEmpty()) { failNotEmpty(message, map.toString()); } }
Asserts that {@code map} is empty.
MoreAsserts::assertEmpty
java
google/j2objc
jre_emul/android/frameworks/base/tests-runner/src/android/test/MoreAsserts.java
https://github.com/google/j2objc/blob/master/jre_emul/android/frameworks/base/tests-runner/src/android/test/MoreAsserts.java
Apache-2.0
public static void assertEmpty(Map<?,?> map) { assertEmpty(null, map); }
Variant of {@link #assertEmpty(String, Map)} using a generic message.
MoreAsserts::assertEmpty
java
google/j2objc
jre_emul/android/frameworks/base/tests-runner/src/android/test/MoreAsserts.java
https://github.com/google/j2objc/blob/master/jre_emul/android/frameworks/base/tests-runner/src/android/test/MoreAsserts.java
Apache-2.0
public static void assertNotEmpty(String message, Iterable<?> iterable) { if (!iterable.iterator().hasNext()) { failEmpty(message); } }
Asserts that {@code iterable} is not empty.
MoreAsserts::assertNotEmpty
java
google/j2objc
jre_emul/android/frameworks/base/tests-runner/src/android/test/MoreAsserts.java
https://github.com/google/j2objc/blob/master/jre_emul/android/frameworks/base/tests-runner/src/android/test/MoreAsserts.java
Apache-2.0
public static void assertNotEmpty(Iterable<?> iterable) { assertNotEmpty(null, iterable); }
Variant of assertNotEmpty(String, Iterable<?>) using a generic message.
MoreAsserts::assertNotEmpty
java
google/j2objc
jre_emul/android/frameworks/base/tests-runner/src/android/test/MoreAsserts.java
https://github.com/google/j2objc/blob/master/jre_emul/android/frameworks/base/tests-runner/src/android/test/MoreAsserts.java
Apache-2.0
public static void assertNotEmpty(String message, Map<?,?> map) { if (map.isEmpty()) { failEmpty(message); } }
Asserts that {@code map} is not empty.
MoreAsserts::assertNotEmpty
java
google/j2objc
jre_emul/android/frameworks/base/tests-runner/src/android/test/MoreAsserts.java
https://github.com/google/j2objc/blob/master/jre_emul/android/frameworks/base/tests-runner/src/android/test/MoreAsserts.java
Apache-2.0
public static void assertNotEmpty(Map<?,?> map) { assertNotEmpty(null, map); }
Variant of {@link #assertNotEmpty(String, Map)} using a generic message.
MoreAsserts::assertNotEmpty
java
google/j2objc
jre_emul/android/frameworks/base/tests-runner/src/android/test/MoreAsserts.java
https://github.com/google/j2objc/blob/master/jre_emul/android/frameworks/base/tests-runner/src/android/test/MoreAsserts.java
Apache-2.0
public static void checkEqualsAndHashCodeMethods( String message, Object lhs, Object rhs, boolean expectedResult) { if ((lhs == null) && (rhs == null)) { Assert.assertTrue( "Your check is dubious...why would you expect null != null?", expectedResult); return; } if ((lhs == null) || (rhs == null)) { Assert.assertFalse( "Your check is dubious...why would you expect an object " + "to be equal to null?", expectedResult); } if (lhs != null) { Assert.assertEquals(message, expectedResult, lhs.equals(rhs)); } if (rhs != null) { Assert.assertEquals(message, expectedResult, rhs.equals(lhs)); } if (expectedResult) { String hashMessage = "hashCode() values for equal objects should be the same"; if (message != null) { hashMessage += ": " + message; } Assert.assertTrue(hashMessage, lhs.hashCode() == rhs.hashCode()); } }
Utility for testing equals() and hashCode() results at once. Tests that lhs.equals(rhs) matches expectedResult, as well as rhs.equals(lhs). Also tests that hashCode() return values are equal if expectedResult is true. (hashCode() is not tested if expectedResult is false, as unequal objects can have equal hashCodes.) @param lhs An Object for which equals() and hashCode() are to be tested. @param rhs As lhs. @param expectedResult True if the objects should compare equal, false if not.
MoreAsserts::checkEqualsAndHashCodeMethods
java
google/j2objc
jre_emul/android/frameworks/base/tests-runner/src/android/test/MoreAsserts.java
https://github.com/google/j2objc/blob/master/jre_emul/android/frameworks/base/tests-runner/src/android/test/MoreAsserts.java
Apache-2.0
public static void checkEqualsAndHashCodeMethods(Object lhs, Object rhs, boolean expectedResult) { checkEqualsAndHashCodeMethods((String) null, lhs, rhs, expectedResult); }
Variant of checkEqualsAndHashCodeMethods(String,Object,Object,boolean...)} using a generic message.
MoreAsserts::checkEqualsAndHashCodeMethods
java
google/j2objc
jre_emul/android/frameworks/base/tests-runner/src/android/test/MoreAsserts.java
https://github.com/google/j2objc/blob/master/jre_emul/android/frameworks/base/tests-runner/src/android/test/MoreAsserts.java
Apache-2.0
public long valueAt(int index) { return mValues[index]; }
Given an index in the range <code>0...size()-1</code>, returns the value from the <code>index</code>th key-value mapping that this SparseLongArray stores. <p>The values corresponding to indices in ascending order are guaranteed to be associated with keys in ascending order, e.g., <code>valueAt(0)</code> will return the value associated with the smallest key and <code>valueAt(size()-1)</code> will return the value associated with the largest key.</p>
SparseLongArray::valueAt
java
google/j2objc
jre_emul/android/frameworks/base/core/java/android/util/SparseLongArray.java
https://github.com/google/j2objc/blob/master/jre_emul/android/frameworks/base/core/java/android/util/SparseLongArray.java
Apache-2.0
public static int v(String tag, String msg) { return println_native(LOG_ID_MAIN, VERBOSE, tag, msg); }
Send a {@link #VERBOSE} log message. @param tag Used to identify the source of a log message. It usually identifies the class or activity where the log call occurs. @param msg The message you would like logged.
TerribleFailure::v
java
google/j2objc
jre_emul/android/frameworks/base/core/java/android/util/Log.java
https://github.com/google/j2objc/blob/master/jre_emul/android/frameworks/base/core/java/android/util/Log.java
Apache-2.0
public static int v(String tag, String msg, Throwable tr) { return println_native(LOG_ID_MAIN, VERBOSE, tag, msg + '\n' + getStackTraceString(tr)); }
Send a {@link #VERBOSE} log message and log the exception. @param tag Used to identify the source of a log message. It usually identifies the class or activity where the log call occurs. @param msg The message you would like logged. @param tr An exception to log
TerribleFailure::v
java
google/j2objc
jre_emul/android/frameworks/base/core/java/android/util/Log.java
https://github.com/google/j2objc/blob/master/jre_emul/android/frameworks/base/core/java/android/util/Log.java
Apache-2.0
public static int d(String tag, String msg) { return println_native(LOG_ID_MAIN, DEBUG, tag, msg); }
Send a {@link #DEBUG} log message. @param tag Used to identify the source of a log message. It usually identifies the class or activity where the log call occurs. @param msg The message you would like logged.
TerribleFailure::d
java
google/j2objc
jre_emul/android/frameworks/base/core/java/android/util/Log.java
https://github.com/google/j2objc/blob/master/jre_emul/android/frameworks/base/core/java/android/util/Log.java
Apache-2.0
public static int d(String tag, String msg, Throwable tr) { return println_native(LOG_ID_MAIN, DEBUG, tag, msg + '\n' + getStackTraceString(tr)); }
Send a {@link #DEBUG} log message and log the exception. @param tag Used to identify the source of a log message. It usually identifies the class or activity where the log call occurs. @param msg The message you would like logged. @param tr An exception to log
TerribleFailure::d
java
google/j2objc
jre_emul/android/frameworks/base/core/java/android/util/Log.java
https://github.com/google/j2objc/blob/master/jre_emul/android/frameworks/base/core/java/android/util/Log.java
Apache-2.0
public static int i(String tag, String msg) { return println_native(LOG_ID_MAIN, INFO, tag, msg); }
Send an {@link #INFO} log message. @param tag Used to identify the source of a log message. It usually identifies the class or activity where the log call occurs. @param msg The message you would like logged.
TerribleFailure::i
java
google/j2objc
jre_emul/android/frameworks/base/core/java/android/util/Log.java
https://github.com/google/j2objc/blob/master/jre_emul/android/frameworks/base/core/java/android/util/Log.java
Apache-2.0
public static int i(String tag, String msg, Throwable tr) { return println_native(LOG_ID_MAIN, INFO, tag, msg + '\n' + getStackTraceString(tr)); }
Send a {@link #INFO} log message and log the exception. @param tag Used to identify the source of a log message. It usually identifies the class or activity where the log call occurs. @param msg The message you would like logged. @param tr An exception to log
TerribleFailure::i
java
google/j2objc
jre_emul/android/frameworks/base/core/java/android/util/Log.java
https://github.com/google/j2objc/blob/master/jre_emul/android/frameworks/base/core/java/android/util/Log.java
Apache-2.0
public static int w(String tag, String msg) { return println_native(LOG_ID_MAIN, WARN, tag, msg); }
Send a {@link #WARN} log message. @param tag Used to identify the source of a log message. It usually identifies the class or activity where the log call occurs. @param msg The message you would like logged.
TerribleFailure::w
java
google/j2objc
jre_emul/android/frameworks/base/core/java/android/util/Log.java
https://github.com/google/j2objc/blob/master/jre_emul/android/frameworks/base/core/java/android/util/Log.java
Apache-2.0
public static int w(String tag, String msg, Throwable tr) { return println_native(LOG_ID_MAIN, WARN, tag, msg + '\n' + getStackTraceString(tr)); }
Send a {@link #WARN} log message and log the exception. @param tag Used to identify the source of a log message. It usually identifies the class or activity where the log call occurs. @param msg The message you would like logged. @param tr An exception to log
TerribleFailure::w
java
google/j2objc
jre_emul/android/frameworks/base/core/java/android/util/Log.java
https://github.com/google/j2objc/blob/master/jre_emul/android/frameworks/base/core/java/android/util/Log.java
Apache-2.0
public static boolean isLoggable(String tag, int level) { Integer minimumLevel = tagLevels.get(tag); if (minimumLevel != null) { return level > minimumLevel.intValue(); } return true; // Let java.util.logging filter it. }
Checks to see whether or not a log for the specified tag is loggable at the specified level. The default level of any tag is set to INFO. This means that any level above and including INFO will be logged. Before you make any calls to a logging method you should check to see if your tag should be logged. You can change the default level by setting a system property: 'setprop log.tag.&lt;YOUR_LOG_TAG> &lt;LEVEL>' Where level is either VERBOSE, DEBUG, INFO, WARN, ERROR, ASSERT, or SUPPRESS. SUPPRESS will turn off all logging for your tag. You can also create a local.prop file that with the following in it: 'log.tag.&lt;YOUR_LOG_TAG>=&lt;LEVEL>' and place that in /data/local.prop. @param tag The tag to check. @param level The level to check. @return Whether or not that this is allowed to be logged. @throws IllegalArgumentException is thrown if the tag.length() > 23.
TerribleFailure::isLoggable
java
google/j2objc
jre_emul/android/frameworks/base/core/java/android/util/Log.java
https://github.com/google/j2objc/blob/master/jre_emul/android/frameworks/base/core/java/android/util/Log.java
Apache-2.0
public static int w(String tag, Throwable tr) { return println_native(LOG_ID_MAIN, WARN, tag, getStackTraceString(tr)); }
Checks to see whether or not a log for the specified tag is loggable at the specified level. The default level of any tag is set to INFO. This means that any level above and including INFO will be logged. Before you make any calls to a logging method you should check to see if your tag should be logged. You can change the default level by setting a system property: 'setprop log.tag.&lt;YOUR_LOG_TAG> &lt;LEVEL>' Where level is either VERBOSE, DEBUG, INFO, WARN, ERROR, ASSERT, or SUPPRESS. SUPPRESS will turn off all logging for your tag. You can also create a local.prop file that with the following in it: 'log.tag.&lt;YOUR_LOG_TAG>=&lt;LEVEL>' and place that in /data/local.prop. @param tag The tag to check. @param level The level to check. @return Whether or not that this is allowed to be logged. @throws IllegalArgumentException is thrown if the tag.length() > 23. public static boolean isLoggable(String tag, int level) { Integer minimumLevel = tagLevels.get(tag); if (minimumLevel != null) { return level > minimumLevel.intValue(); } return true; // Let java.util.logging filter it. } /* Send a {@link #WARN} log message and log the exception. @param tag Used to identify the source of a log message. It usually identifies the class or activity where the log call occurs. @param tr An exception to log
TerribleFailure::w
java
google/j2objc
jre_emul/android/frameworks/base/core/java/android/util/Log.java
https://github.com/google/j2objc/blob/master/jre_emul/android/frameworks/base/core/java/android/util/Log.java
Apache-2.0
public static int e(String tag, String msg) { return println_native(LOG_ID_MAIN, ERROR, tag, msg); }
Send an {@link #ERROR} log message. @param tag Used to identify the source of a log message. It usually identifies the class or activity where the log call occurs. @param msg The message you would like logged.
TerribleFailure::e
java
google/j2objc
jre_emul/android/frameworks/base/core/java/android/util/Log.java
https://github.com/google/j2objc/blob/master/jre_emul/android/frameworks/base/core/java/android/util/Log.java
Apache-2.0
public static int e(String tag, String msg, Throwable tr) { return println_native(LOG_ID_MAIN, ERROR, tag, msg + '\n' + getStackTraceString(tr)); }
Send a {@link #ERROR} log message and log the exception. @param tag Used to identify the source of a log message. It usually identifies the class or activity where the log call occurs. @param msg The message you would like logged. @param tr An exception to log
TerribleFailure::e
java
google/j2objc
jre_emul/android/frameworks/base/core/java/android/util/Log.java
https://github.com/google/j2objc/blob/master/jre_emul/android/frameworks/base/core/java/android/util/Log.java
Apache-2.0
public static int wtf(String tag, String msg) { return wtf(LOG_ID_MAIN, tag, msg, null, false); }
What a Terrible Failure: Report a condition that should never happen. The error will always be logged at level ASSERT with the call stack. @param tag Used to identify the source of a log message. @param msg The message you would like logged.
TerribleFailure::wtf
java
google/j2objc
jre_emul/android/frameworks/base/core/java/android/util/Log.java
https://github.com/google/j2objc/blob/master/jre_emul/android/frameworks/base/core/java/android/util/Log.java
Apache-2.0
public static int wtfStack(String tag, String msg) { return wtf(LOG_ID_MAIN, tag, msg, null, true); }
Like {@link #wtf(String, String)}, but also writes to the log the full call stack. @hide
TerribleFailure::wtfStack
java
google/j2objc
jre_emul/android/frameworks/base/core/java/android/util/Log.java
https://github.com/google/j2objc/blob/master/jre_emul/android/frameworks/base/core/java/android/util/Log.java
Apache-2.0
public static int wtf(String tag, Throwable tr) { return wtf(LOG_ID_MAIN, tag, tr.getMessage(), tr, false); }
What a Terrible Failure: Report an exception that should never happen. Similar to {@link #wtf(String, String)}, with an exception to log. @param tag Used to identify the source of a log message. @param tr An exception to log.
TerribleFailure::wtf
java
google/j2objc
jre_emul/android/frameworks/base/core/java/android/util/Log.java
https://github.com/google/j2objc/blob/master/jre_emul/android/frameworks/base/core/java/android/util/Log.java
Apache-2.0
public static int wtf(String tag, String msg, Throwable tr) { return wtf(LOG_ID_MAIN, tag, msg, tr, false); }
What a Terrible Failure: Report an exception that should never happen. Similar to {@link #wtf(String, Throwable)}, with a message as well. @param tag Used to identify the source of a log message. @param msg The message you would like logged. @param tr An exception to log. May be null.
TerribleFailure::wtf
java
google/j2objc
jre_emul/android/frameworks/base/core/java/android/util/Log.java
https://github.com/google/j2objc/blob/master/jre_emul/android/frameworks/base/core/java/android/util/Log.java
Apache-2.0
public static TerribleFailureHandler setWtfHandler(TerribleFailureHandler handler) { if (handler == null) { throw new NullPointerException("handler == null"); } TerribleFailureHandler oldHandler = sWtfHandler; sWtfHandler = handler; return oldHandler; }
Sets the terrible failure handler, for testing. @return the old handler @hide
TerribleFailure::setWtfHandler
java
google/j2objc
jre_emul/android/frameworks/base/core/java/android/util/Log.java
https://github.com/google/j2objc/blob/master/jre_emul/android/frameworks/base/core/java/android/util/Log.java
Apache-2.0
public static String getStackTraceString(Throwable tr) { if (tr == null) { return ""; } // This is to reduce the amount of log spew that apps do in the non-error // condition of the network being unavailable. Throwable t = tr; while (t != null) { if (t instanceof UnknownHostException) { return ""; } t = t.getCause(); } StringWriter sw = new StringWriter(); PrintWriter pw = new PrintWriter(sw, false); tr.printStackTrace(pw); pw.flush(); return sw.toString(); }
Handy function to get a loggable stack trace from a Throwable @param tr An exception to log
TerribleFailure::getStackTraceString
java
google/j2objc
jre_emul/android/frameworks/base/core/java/android/util/Log.java
https://github.com/google/j2objc/blob/master/jre_emul/android/frameworks/base/core/java/android/util/Log.java
Apache-2.0
public static int println(int priority, String tag, String msg) { return println_native(LOG_ID_MAIN, priority, tag, msg); }
Low-level logging call. @param priority The priority/type of this log message @param tag Used to identify the source of a log message. It usually identifies the class or activity where the log call occurs. @param msg The message you would like logged. @return The number of bytes written.
TerribleFailure::println
java
google/j2objc
jre_emul/android/frameworks/base/core/java/android/util/Log.java
https://github.com/google/j2objc/blob/master/jre_emul/android/frameworks/base/core/java/android/util/Log.java
Apache-2.0
public void removeAt(int index) { if (mValues[index] != DELETED) { mValues[index] = DELETED; mGarbage = true; } }
Removes the mapping at the specified index.
SparseArray::removeAt
java
google/j2objc
jre_emul/android/frameworks/base/core/java/android/util/SparseArray.java
https://github.com/google/j2objc/blob/master/jre_emul/android/frameworks/base/core/java/android/util/SparseArray.java
Apache-2.0
public int indexOfValue(E value) { if (mGarbage) { gc(); } for (int i = 0; i < mSize; i++) if (mValues[i] == value) return i; return -1; }
Returns an index for which {@link #valueAt} would return the specified key, or a negative number if no keys map to the specified value. <p>Beware that this is a linear search, unlike lookups by key, and that multiple keys can map to the same value and this will find only one of them. <p>Note also that unlike most collections' {@code indexOf} methods, this method compares values using {@code ==} rather than {@code equals}.
SparseArray::indexOfValue
java
google/j2objc
jre_emul/android/frameworks/base/core/java/android/util/SparseArray.java
https://github.com/google/j2objc/blob/master/jre_emul/android/frameworks/base/core/java/android/util/SparseArray.java
Apache-2.0
public SparseBooleanArray() { this(10); }
Creates a new SparseBooleanArray containing no mappings.
SparseBooleanArray::SparseBooleanArray
java
google/j2objc
jre_emul/android/frameworks/base/core/java/android/util/SparseBooleanArray.java
https://github.com/google/j2objc/blob/master/jre_emul/android/frameworks/base/core/java/android/util/SparseBooleanArray.java
Apache-2.0
public SparseBooleanArray(int initialCapacity) { if (initialCapacity == 0) { mKeys = ContainerHelpers.EMPTY_INTS; mValues = ContainerHelpers.EMPTY_BOOLEANS; } else { initialCapacity = ArrayUtils.idealIntArraySize(initialCapacity); mKeys = new int[initialCapacity]; mValues = new boolean[initialCapacity]; } mSize = 0; }
Creates a new SparseBooleanArray containing no mappings that will not require any additional memory allocation to store the specified number of mappings. If you supply an initial capacity of 0, the sparse array will be initialized with a light-weight representation not requiring any additional array allocations.
SparseBooleanArray::SparseBooleanArray
java
google/j2objc
jre_emul/android/frameworks/base/core/java/android/util/SparseBooleanArray.java
https://github.com/google/j2objc/blob/master/jre_emul/android/frameworks/base/core/java/android/util/SparseBooleanArray.java
Apache-2.0
public boolean valueAt(int index) { return mValues[index]; }
Given an index in the range <code>0...size()-1</code>, returns the value from the <code>index</code>th key-value mapping that this SparseBooleanArray stores. <p>The values corresponding to indices in ascending order are guaranteed to be associated with keys in ascending order, e.g., <code>valueAt(0)</code> will return the value associated with the smallest key and <code>valueAt(size()-1)</code> will return the value associated with the largest key.</p>
SparseBooleanArray::valueAt
java
google/j2objc
jre_emul/android/frameworks/base/core/java/android/util/SparseBooleanArray.java
https://github.com/google/j2objc/blob/master/jre_emul/android/frameworks/base/core/java/android/util/SparseBooleanArray.java
Apache-2.0
public void resize(int maxSize) { if (maxSize <= 0) { throw new IllegalArgumentException("maxSize <= 0"); } synchronized (this) { this.maxSize = maxSize; } trimToSize(maxSize); }
Sets the size of the cache. @param maxSize The new maximum size. @hide
LruCache::resize
java
google/j2objc
jre_emul/android/frameworks/base/core/java/android/util/LruCache.java
https://github.com/google/j2objc/blob/master/jre_emul/android/frameworks/base/core/java/android/util/LruCache.java
Apache-2.0
protected void entryRemoved(boolean evicted, K key, V oldValue, V newValue) {}
Called for entries that have been evicted or removed. This method is invoked when a value is evicted to make space, removed by a call to {@link #remove}, or replaced by a call to {@link #put}. The default implementation does nothing. <p>The method is called without synchronization: other threads may access the cache while this method is executing. @param evicted true if the entry is being removed to make space, false if the removal was caused by a {@link #put} or {@link #remove}. @param newValue the new value for {@code key}, if it exists. If non-null, this removal was caused by a {@link #put}. Otherwise it was caused by an eviction or a {@link #remove}.
LruCache::entryRemoved
java
google/j2objc
jre_emul/android/frameworks/base/core/java/android/util/LruCache.java
https://github.com/google/j2objc/blob/master/jre_emul/android/frameworks/base/core/java/android/util/LruCache.java
Apache-2.0
public void getChars(int start, int end, char[] dest, int destoff) { checkRange("getChars", start, end); if (end <= mGapStart) { System.arraycopy(mText, start, dest, destoff, end - start); } else if (start >= mGapStart) { System.arraycopy(mText, start + mGapLength, dest, destoff, end - start); } else { System.arraycopy(mText, start, dest, destoff, mGapStart - start); System.arraycopy(mText, mGapStart + mGapLength, dest, destoff + (mGapStart - start), end - mGapStart); } }
Copy the specified range of chars from this buffer into the specified array, beginning at the specified offset.
for::getChars
java
google/j2objc
jre_emul/android/frameworks/base/core/java/android/text/SpannableStringBuilder.java
https://github.com/google/j2objc/blob/master/jre_emul/android/frameworks/base/core/java/android/text/SpannableStringBuilder.java
Apache-2.0
public String substring(int start, int end) { char[] buf = new char[end - start]; getChars(start, end, buf, 0); return new String(buf); }
Return a String containing a copy of the chars in this buffer, limited to the [start, end[ range. @hide
for::substring
java
google/j2objc
jre_emul/android/frameworks/base/core/java/android/text/SpannableStringBuilder.java
https://github.com/google/j2objc/blob/master/jre_emul/android/frameworks/base/core/java/android/text/SpannableStringBuilder.java
Apache-2.0
public static final void setSelection(Spannable text, int index) { setSelection(text, index, index); }
Move the cursor to offset <code>index</code>.
Selection::setSelection
java
google/j2objc
jre_emul/android/frameworks/base/core/java/android/text/Selection.java
https://github.com/google/j2objc/blob/master/jre_emul/android/frameworks/base/core/java/android/text/Selection.java
Apache-2.0