Skip to content

Commit

Permalink
Revert "Fix compatibility issue when building on JDK 17 but running o…
Browse files Browse the repository at this point in the history
…n JDK 8 (uber#779)"

This reverts commit 61abe56.
  • Loading branch information
msridhar committed Jul 19, 2023
1 parent d67871c commit cdcd062
Show file tree
Hide file tree
Showing 6 changed files with 3 additions and 27 deletions.
3 changes: 0 additions & 3 deletions .github/workflows/continuous-integration.yml
Original file line number Diff line number Diff line change
Expand Up @@ -16,9 +16,6 @@ jobs:
- os: ubuntu-latest
java: 11
epVersion: 2.4.0
- os: ubuntu-latest
java: 17
epVersion: 2.4.0
- os: macos-latest
java: 11
epVersion: 2.20.0
Expand Down
7 changes: 0 additions & 7 deletions nullaway/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -92,13 +92,6 @@ test {
// Accessed by Lombok tests
"--add-opens=jdk.compiler/com.sun.tools.javac.jvm=ALL-UNNAMED",
]
if (deps.versions.errorProneApi == "2.4.0" && JavaVersion.current() >= JavaVersion.VERSION_17) {
// This test does not pass on JDK 17 with Error Prone 2.4.0 due to a Mockito incompatibility. Skip it (the
// test passes with more recent Error Prone versions on JDK 17)
filter {
excludeTestsMatching "com.uber.nullaway.NullAwaySerializationTest.suggestNullableArgumentOnBytecodeNoFileInfo"
}
}
}

apply plugin: 'com.vanniktech.maven.publish'
Expand Down
12 changes: 0 additions & 12 deletions nullaway/src/main/java/com/uber/nullaway/NullabilityUtil.java
Original file line number Diff line number Diff line change
Expand Up @@ -176,18 +176,6 @@ public static TreePath findEnclosingMethodOrLambdaOrInitializer(TreePath path) {
return findEnclosingMethodOrLambdaOrInitializer(path, ImmutableSet.of());
}

/**
* A wrapper for {@link Symbol#getEnclosedElements} to avoid binary compatibility issues for
* covariant overrides in subtypes of {@link Symbol}.
*
* <p>Same as this ASTHelpers method in Error Prone:
* https://github.com/google/error-prone/blame/a1318e4b0da4347dff7508108835d77c470a7198/check_api/src/main/java/com/google/errorprone/util/ASTHelpers.java#L1148
* TODO: delete this method and switch to ASTHelpers once we can require Error Prone 2.20.0
*/
public static List<Symbol> getEnclosedElements(Symbol symbol) {
return symbol.getEnclosedElements();
}

/**
* NOTE: this method does not work for getting all annotations of parameters of methods from class
* files. For that case, use {@link #getAllAnnotationsForParameter(Symbol.MethodSymbol, int)}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -222,7 +222,7 @@ protected boolean validateAnnotationSyntax(
public static @Nullable VariableElement getInstanceFieldOfClass(
Symbol.ClassSymbol classSymbol, String name) {
Preconditions.checkNotNull(classSymbol);
for (Element member : NullabilityUtil.getEnclosedElements(classSymbol)) {
for (Element member : classSymbol.getEnclosedElements()) {
if (member.getKind().isField() && !member.getModifiers().contains(Modifier.STATIC)) {
if (member.getSimpleName().toString().equals(name)) {
return (VariableElement) member;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,6 @@
import com.sun.tools.javac.code.Type;
import com.sun.tools.javac.code.Types;
import com.uber.nullaway.NullAway;
import com.uber.nullaway.NullabilityUtil;
import com.uber.nullaway.Nullness;
import com.uber.nullaway.dataflow.AccessPath;
import com.uber.nullaway.dataflow.AccessPathNullnessPropagation;
Expand Down Expand Up @@ -143,7 +142,7 @@ private FieldAndGetterElements getFieldAndGetterForProperty(
Element getter = null;
String fieldName = decapitalize(capPropName);
String getterName = "get" + capPropName;
for (Symbol elem : NullabilityUtil.getEnclosedElements(symbol.owner)) {
for (Symbol elem : symbol.owner.getEnclosedElements()) {
if (elem.getKind().isField() && elem.getSimpleName().toString().equals(fieldName)) {
if (field != null) {
throw new RuntimeException("already found field " + fieldName);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,6 @@
import com.sun.tools.javac.code.Type;
import com.sun.tools.javac.code.Types;
import com.uber.nullaway.NullAway;
import com.uber.nullaway.NullabilityUtil;
import com.uber.nullaway.Nullness;
import com.uber.nullaway.dataflow.AccessPath;
import com.uber.nullaway.dataflow.AccessPathNullnessPropagation;
Expand Down Expand Up @@ -123,7 +122,7 @@ public ImmutableSet<String> onRegisterImmutableTypes() {
private Symbol.MethodSymbol getGetterForMetadataSubtype(
Symbol.ClassSymbol classSymbol, Types types) {
// Is there a better way than iteration?
for (Symbol elem : NullabilityUtil.getEnclosedElements(classSymbol)) {
for (Symbol elem : classSymbol.getEnclosedElements()) {
if (elem.getKind().equals(ElementKind.METHOD)) {
Symbol.MethodSymbol methodSymbol = (Symbol.MethodSymbol) elem;
if (grpcIsMetadataGetCall(methodSymbol, types)) {
Expand Down

0 comments on commit cdcd062

Please sign in to comment.