Skip to content

Commit 1651bf6

Browse files
sormurascushon
authored andcommitted
Set supported Java source level to 9 (#178)
Fixes #176
1 parent fee1ed2 commit 1651bf6

File tree

3 files changed

+18
-0
lines changed

3 files changed

+18
-0
lines changed

core/src/main/java/com/google/googlejavaformat/java/Formatter.java

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -47,6 +47,7 @@
4747
import org.openjdk.javax.tools.SimpleJavaFileObject;
4848
import org.openjdk.javax.tools.StandardLocation;
4949
import org.openjdk.tools.javac.file.JavacFileManager;
50+
import org.openjdk.tools.javac.main.Option;
5051
import org.openjdk.tools.javac.parser.JavacParser;
5152
import org.openjdk.tools.javac.parser.ParserFactory;
5253
import org.openjdk.tools.javac.tree.JCTree.JCCompilationUnit;
@@ -135,6 +136,10 @@ static void format(
135136
DiagnosticCollector<JavaFileObject> diagnostics = new DiagnosticCollector<>();
136137
context.put(DiagnosticListener.class, diagnostics);
137138
Options.instance(context).put("allowStringFolding", "false");
139+
// TODO(cushon): this should default to the latest supported source level, remove this after
140+
// backing out
141+
// https://github.com/google/error-prone-javac/commit/c97f34ddd2308302587ce2de6d0c984836ea5b9f
142+
Options.instance(context).put(Option.SOURCE, "9");
138143
JCCompilationUnit unit;
139144
JavacFileManager fileManager = new JavacFileManager(context, true, UTF_8);
140145
try {
Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
interface
2+
InterfaceWithPrivateStaticMethod
3+
{
4+
private static void bar() { }
5+
default void foo() { bar(); }
6+
}
Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
interface InterfaceWithPrivateStaticMethod {
2+
private static void bar() {}
3+
4+
default void foo() {
5+
bar();
6+
}
7+
}

0 commit comments

Comments
 (0)