diff options
author | cushon <cushon@google.com> | 2018-02-05 11:47:14 -0800 |
---|---|---|
committer | Copybara-Service <copybara-piper@google.com> | 2018-02-05 11:49:04 -0800 |
commit | a3bdffe83b1f8401e019e4355be7f966a62d08d3 (patch) | |
tree | 9b8838685e464f99568a692d053e041af5f80853 /third_party/ijar/test/IjarTests.java | |
parent | 5be4dd62ee5d7bf3730ab2099829dc7f87ef2e94 (diff) |
Include module-info.class files in interface jars
instead of removing them, since builds that use modules need them to be
visible across compilation boundaries. Note that the module-infos don't
contain any implementation that needs to be removed, so ijar just copies
the entire file through.
PiperOrigin-RevId: 184562080
Diffstat (limited to 'third_party/ijar/test/IjarTests.java')
-rw-r--r-- | third_party/ijar/test/IjarTests.java | 22 |
1 files changed, 12 insertions, 10 deletions
diff --git a/third_party/ijar/test/IjarTests.java b/third_party/ijar/test/IjarTests.java index d9a3897cfa..4e0fb5d839 100644 --- a/third_party/ijar/test/IjarTests.java +++ b/third_party/ijar/test/IjarTests.java @@ -13,6 +13,7 @@ // limitations under the License. import static com.google.common.truth.Truth.assertThat; +import static java.nio.charset.StandardCharsets.UTF_8; import static org.junit.Assert.assertEquals; import static org.junit.Assert.assertFalse; import static org.junit.Assert.fail; @@ -20,14 +21,6 @@ import static org.junit.Assert.fail; import com.google.common.collect.ImmutableMap; import com.google.common.io.ByteStreams; import com.google.devtools.build.java.bazel.BazelJavaCompiler; - -import org.junit.Test; -import org.junit.runner.RunWith; -import org.junit.runners.JUnit4; -import org.objectweb.asm.ClassReader; -import org.objectweb.asm.ClassVisitor; -import org.objectweb.asm.Opcodes; - import java.io.File; import java.io.IOException; import java.util.Arrays; @@ -41,7 +34,6 @@ import java.util.jar.JarEntry; import java.util.jar.JarFile; import java.util.zip.ZipEntry; import java.util.zip.ZipFile; - import javax.annotation.processing.AbstractProcessor; import javax.annotation.processing.RoundEnvironment; import javax.lang.model.element.TypeElement; @@ -51,6 +43,12 @@ import javax.tools.JavaCompiler; import javax.tools.JavaFileObject; import javax.tools.StandardJavaFileManager; import javax.tools.StandardLocation; +import org.junit.Test; +import org.junit.runner.RunWith; +import org.junit.runners.JUnit4; +import org.objectweb.asm.ClassReader; +import org.objectweb.asm.ClassVisitor; +import org.objectweb.asm.Opcodes; /** * JUnit tests for ijar tool. @@ -270,6 +268,10 @@ public class IjarTests { @Test public void moduleInfo() throws Exception { Map<String, byte[]> lib = readJar("third_party/ijar/test/module_info-interface.jar"); - assertThat(lib.keySet()).containsExactly("java/lang/String.class"); + assertThat(lib.keySet()) + .containsExactly("java/lang/String.class", "module-info.class", "foo/module-info.class"); + // ijar passes module-infos through unmodified, so it doesn't care that these ones are bogus + assertThat(new String(lib.get("module-info.class"), UTF_8)).isEqualTo("hello"); + assertThat(new String(lib.get("foo/module-info.class"), UTF_8)).isEqualTo("goodbye"); } } |