Skip to content

Commit

Permalink
WIP: JDK 11 compatibility
Browse files Browse the repository at this point in the history
(Self check fails on text blocks in `ErrorProneTestHelperSourceFormatTest`.)
  • Loading branch information
Stephan202 committed Sep 6, 2022
1 parent 2d8cbfd commit 7640841
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -248,7 +248,7 @@ private static Optional<String> getConstantSourceCode(
StringBuilder source = new StringBuilder();

for (ExpressionTree sourceLine : sourceLines) {
if (!source.isEmpty()) {
if (source.length() > 0) {
source.append('\n');
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,9 @@ private SourceCode() {}
*/
// XXX: Add tests!
public static boolean isTextBlockSupported(VisitorState state) {
return Target.instance(state.context).compareTo(Target.JDK1_15) >= 0;
// XXX: String comparison is for JDK 11 compatibility. Is there a better way?
return Target.instance(state.context).toString().compareTo("JDK1_15") >= 0;
// return Target.instance(state.context).compareTo(Target.JDK1_15) >= 0;
}

/**
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,8 @@
import com.google.errorprone.BugCheckerRefactoringTestHelper.TestMode;
import com.google.errorprone.CompilationTestHelper;
import org.junit.jupiter.api.Test;
import org.junit.jupiter.api.condition.DisabledForJreRange;
import org.junit.jupiter.api.condition.JRE;

final class ErrorProneTestHelperSourceFormatTest {
private final CompilationTestHelper compilationTestHelper =
Expand All @@ -19,6 +21,10 @@ final class ErrorProneTestHelperSourceFormatTest {
ErrorProneTestHelperSourceFormat.class, getClass())
.setArgs("-XepOpt:ErrorProneTestHelperSourceFormat:AvoidTextBlocks=true");

// XXX: Consider reducing the `@DisabledForJreRange(max = JRE.JAVA_14)` test scope by moving the
// text blocks to smaller test methods.

@DisabledForJreRange(max = JRE.JAVA_14)
@Test
void identification() {
compilationTestHelper
Expand Down Expand Up @@ -86,6 +92,7 @@ class B {}
.doTest();
}

@DisabledForJreRange(max = JRE.JAVA_14)
@Test
void identificationAvoidTextBlocks() {
avoidTextBlocksCompilationTestHelper
Expand Down

0 comments on commit 7640841

Please sign in to comment.