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

Fix Google-internal common.collect tests under an Android emulator. #6652

Closed
wants to merge 1 commit into from
Closed
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
Original file line number Diff line number Diff line change
Expand Up @@ -137,6 +137,7 @@ public Integer computeNext() {


@GwtIncompatible // weak references
@AndroidIncompatible // depends on details of GC
public void testFreesNextReference() {
Iterator<Object> itr =
new AbstractIterator<Object>() {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -479,4 +479,33 @@ public void testOverflowCondition() {
}
assertTrue(builder.build() instanceof SparseImmutableTable);
}

@GwtIncompatible // NullPointerTester
@Override
public void testNullPointerInstance() {
if (isAndroid()) {
/*
* NPT fails under the old versions of Android we test under because it performs reflection on
* ImmutableTable, which declares static methods that refer to Collector, which is unavailable
* under such versions.
*
* We use a runtime check here instead of @AndroidIncompatible: @AndroidIncompatible operates
* by stripping annotated methods entirely, and if we strip this method, then JUnit would just
* run the supermethod as usual.
*
* TODO: b/292578973: Use @AndroidIncompatible if we change our system to keep the methods in
* place but to have the test runner skip them. However, note that if we choose to *both*
* strip the methods *and* have the test runner not run them (for some unusual cases in which
* we don't run the stripping test for technical reasons), then we'd be back to the problem
* described above, since the supermethod is *not* annotated @AndroidIncompatible (since it
* works fine with the other Table implementations).
*/
return;
}
super.testNullPointerInstance();
}

private static boolean isAndroid() {
return System.getProperty("java.runtime.name", "").contains("Android");
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -463,4 +463,6 @@ final Object writeReplace() {
private void readObject(ObjectInputStream stream) throws InvalidObjectException {
throw new InvalidObjectException("Use SerializedForm");
}

private static final long serialVersionUID = 0xdecaf;
}
Original file line number Diff line number Diff line change
Expand Up @@ -137,6 +137,7 @@ public Integer computeNext() {


@GwtIncompatible // weak references
@AndroidIncompatible // depends on details of GC
public void testFreesNextReference() {
Iterator<Object> itr =
new AbstractIterator<Object>() {
Expand Down
29 changes: 29 additions & 0 deletions guava-tests/test/com/google/common/collect/ImmutableTableTest.java
Original file line number Diff line number Diff line change
Expand Up @@ -485,4 +485,33 @@ public void testOverflowCondition() {
}
assertTrue(builder.build() instanceof SparseImmutableTable);
}

@GwtIncompatible // NullPointerTester
@Override
public void testNullPointerInstance() {
if (isAndroid()) {
/*
* NPT fails under the old versions of Android we test under because it performs reflection on
* ImmutableTable, which declares static methods that refer to Collector, which is unavailable
* under such versions.
*
* We use a runtime check here instead of @AndroidIncompatible: @AndroidIncompatible operates
* by stripping annotated methods entirely, and if we strip this method, then JUnit would just
* run the supermethod as usual.
*
* TODO: b/292578973: Use @AndroidIncompatible if we change our system to keep the methods in
* place but to have the test runner skip them. However, note that if we choose to *both*
* strip the methods *and* have the test runner not run them (for some unusual cases in which
* we don't run the stripping test for technical reasons), then we'd be back to the problem
* described above, since the supermethod is *not* annotated @AndroidIncompatible (since it
* works fine with the other Table implementations).
*/
return;
}
super.testNullPointerInstance();
}

private static boolean isAndroid() {
return System.getProperty("java.runtime.name", "").contains("Android");
}
}
2 changes: 2 additions & 0 deletions guava/src/com/google/common/collect/ImmutableTable.java
Original file line number Diff line number Diff line change
Expand Up @@ -512,4 +512,6 @@ final Object writeReplace() {
private void readObject(ObjectInputStream stream) throws InvalidObjectException {
throw new InvalidObjectException("Use SerializedForm");
}

private static final long serialVersionUID = 0xcafebabe;
}