Closed GoogleCodeExporter closed 8 years ago
also
12.08.2013 13:02:35 org.decojer.editor.eclipse.cfg.CfgViewer initGraph
WARNUNG: Cannot transform
'com.google.common.util.concurrent.Monitor.enterWhenUninterruptibly(Lcom/google/
common/util/concurrent/Monitor$Guard;JLjava/util/concurrent/TimeUnit;)Z (ops:
116, regs: 18)'!
java.lang.NullPointerException
at org.decojer.cavaj.transformers.TrControlFlowAnalysis.createLoopStruct(TrControlFlowAnalysis.java:193)
at org.decojer.cavaj.transformers.TrControlFlowAnalysis.transform(TrControlFlowAnalysis.java:534)
at org.decojer.cavaj.transformers.TrControlFlowAnalysis.transform(TrControlFlowAnalysis.java:65)
etc.
loop...try...finally...
public boolean enterWhenUninterruptibly(Guard guard, long time, TimeUnit unit) {
if (guard.monitor != this) {
throw new IllegalMonitorStateException();
}
final ReentrantLock lock = this.lock;
boolean reentrant = lock.isHeldByCurrentThread();
long startNanos = System.nanoTime();
long timeoutNanos = unit.toNanos(time);
long remainingNanos = timeoutNanos;
boolean interruptIgnored = false;
try {
while (true) {
try {
if (lock.tryLock(remainingNanos, TimeUnit.NANOSECONDS)) {
break;
} else {
return false;
}
} catch (InterruptedException ignored) {
interruptIgnored = true;
} finally {
remainingNanos = (timeoutNanos - (System.nanoTime() - startNanos));
}
}
boolean satisfied = false;
Original comment by andrePan...@gmail.com
on 12 Aug 2013 at 11:30
drain function is same...loop-try-fina
public static <E> int drainUninterruptibly(BlockingQueue<E> q, Collection<? super E> buffer,
int maxElements, long timeout, TimeUnit unit) {
Preconditions.checkNotNull(buffer);
long deadline = System.nanoTime() + unit.toNanos(timeout);
int added = 0;
boolean interrupted = false;
try {
while (added < maxElements) {
// we could rely solely on #poll, but #drainTo might be more efficient when there are
// multiple elements already available (e.g. LinkedBlockingQueue#drainTo locks only once)
added += q.drainTo(buffer, maxElements - added);
if (added < maxElements) { // not enough elements immediately available; will have to poll
E e; // written exactly once, by a successful (uninterrupted) invocation of #poll
while (true) {
try {
e = q.poll(deadline - System.nanoTime(), TimeUnit.NANOSECONDS);
break;
} catch (InterruptedException ex) {
interrupted = true; // note interruption and retry
}
}
if (e == null) {
break; // we already waited enough, and there are no more elements in sight
}
buffer.add(e);
added++;
}
}
} finally {
if (interrupted) {
Thread.currentThread().interrupt();
}
}
return added;
}
Original comment by andrePan...@gmail.com
on 12 Aug 2013 at 11:32
so we have to follow try-stuff in loop-findet or track this bottom-up
Original comment by andrePan...@gmail.com
on 12 Aug 2013 at 11:35
no exception for now
Original comment by andrePan...@gmail.com
on 3 Sep 2014 at 1:35
Original issue reported on code.google.com by
andrePan...@gmail.com
on 12 Aug 2013 at 10:52