diff options
author | Liam Miller-Cushon <cushon@google.com> | 2023-06-26 11:04:09 -0700 |
---|---|---|
committer | Javac Team <javac-team+copybara@google.com> | 2023-06-26 11:04:55 -0700 |
commit | 701bb990443345880777525234284d6fb5f28396 (patch) | |
tree | 83a29908af53ec870d3c26c4722e497c2b96b9aa | |
parent | ca998fa79096622e55610ee25547b117ef141023 (diff) | |
download | turbine-701bb990443345880777525234284d6fb5f28396.tar.gz |
Write `package-info`s even if the package info doesn't contain any annotations
Similar to javac's `-Xpkginfo:always`
PiperOrigin-RevId: 543487269
-rw-r--r-- | java/com/google/turbine/binder/CompUnitPreprocessor.java | 2 | ||||
-rw-r--r-- | javatests/com/google/turbine/lower/LowerIntegrationTest.java | 7 |
2 files changed, 7 insertions, 2 deletions
diff --git a/java/com/google/turbine/binder/CompUnitPreprocessor.java b/java/com/google/turbine/binder/CompUnitPreprocessor.java index 970dc4b..25ba48a 100644 --- a/java/com/google/turbine/binder/CompUnitPreprocessor.java +++ b/java/com/google/turbine/binder/CompUnitPreprocessor.java @@ -105,7 +105,7 @@ public final class CompUnitPreprocessor { // "While the file could technically contain the source code // for one or more package-private (default-access) classes, // it would be very bad form." -- JLS 7.4.1 - if (!unit.pkg().get().annos().isEmpty()) { + if (!unit.pkg().get().annos().isEmpty() || unit.decls().isEmpty()) { decls = Iterables.concat(decls, ImmutableList.of(packageInfoTree(unit.pkg().get()))); } } else { diff --git a/javatests/com/google/turbine/lower/LowerIntegrationTest.java b/javatests/com/google/turbine/lower/LowerIntegrationTest.java index 9026725..6c95d44 100644 --- a/javatests/com/google/turbine/lower/LowerIntegrationTest.java +++ b/javatests/com/google/turbine/lower/LowerIntegrationTest.java @@ -391,7 +391,12 @@ public class LowerIntegrationTest { int version = SOURCE_VERSION.getOrDefault(test, 8); assumeTrue(version <= Runtime.version().feature()); ImmutableList<String> javacopts = - ImmutableList.of("-source", String.valueOf(version), "-target", String.valueOf(version)); + ImmutableList.of( + "-source", + String.valueOf(version), + "-target", + String.valueOf(version), + "-Xpkginfo:always"); Map<String, byte[]> expected = IntegrationTestSupport.runJavac(input.sources, classpathJar, javacopts); |