Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

core: allow Java 7 source and bytecode #4801

Merged
merged 1 commit into from
Aug 28, 2018
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 0 additions & 6 deletions core/build.gradle
Original file line number Diff line number Diff line change
@@ -1,11 +1,5 @@
description = 'gRPC: Core'

// Workaround:
// [Undefined reference (android-api-level-14-4.0_r4)] io.grpc.internal.(Rescheduler.java:87)
// >> Object java.util.Objects.requireNonNull(Object)
sourceCompatibility = 1.6
targetCompatibility = 1.6

dependencies {
compile project(':grpc-context'),
libraries.gson,
Expand Down
21 changes: 9 additions & 12 deletions core/src/main/java/io/grpc/internal/Rescheduler.java
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,7 @@ void reschedule(long delay, TimeUnit timeUnit) {
if (wakeUp != null) {
wakeUp.cancel(false);
}
wakeUp = scheduler.schedule(new FutureRunnable(this), delayNanos, TimeUnit.NANOSECONDS);
wakeUp = scheduler.schedule(new FutureRunnable(), delayNanos, TimeUnit.NANOSECONDS);
}
runAtNanos = newRunAtNanos;
}
Expand All @@ -74,17 +74,14 @@ void cancel(boolean permanent) {
}
}

private static final class FutureRunnable implements Runnable {

private final Rescheduler rescheduler;

FutureRunnable(Rescheduler rescheduler) {
this.rescheduler = rescheduler;
}

private final class FutureRunnable implements Runnable {
@Override
public void run() {
rescheduler.serializingExecutor.execute(rescheduler.new ChannelFutureRunnable());
Rescheduler.this.serializingExecutor.execute(new ChannelFutureRunnable());
}

private boolean isEnabled() {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Oh... Sorry, I missed that. A bit of a pain. Whatever.

return Rescheduler.this.enabled;
}
}

Expand All @@ -99,7 +96,7 @@ public void run() {
long now = nanoTime();
if (runAtNanos - now > 0) {
wakeUp = scheduler.schedule(
new FutureRunnable(Rescheduler.this), runAtNanos - now, TimeUnit.NANOSECONDS);
new FutureRunnable(), runAtNanos - now, TimeUnit.NANOSECONDS);
} else {
enabled = false;
wakeUp = null;
Expand All @@ -110,7 +107,7 @@ public void run() {

@VisibleForTesting
static boolean isEnabled(Runnable r) {
return ((FutureRunnable) r).rescheduler.enabled;
return ((FutureRunnable) r).isEnabled();
}

private long nanoTime() {
Expand Down