Only merge classes if the subclass has at least same visibility
Change-Id: Ie2632feae38e94ac6203a5f20f35fa7985a78214
diff --git a/src/test/examples/classmerging/SimpleInterfaceAccessTest.java b/src/test/examples/classmerging/SimpleInterfaceAccessTest.java
index 04b5386..ce7bf14 100644
--- a/src/test/examples/classmerging/SimpleInterfaceAccessTest.java
+++ b/src/test/examples/classmerging/SimpleInterfaceAccessTest.java
@@ -8,9 +8,35 @@
public class SimpleInterfaceAccessTest {
public static void main(String[] args) {
- // It is not possible to merge the interface SimpleInterface into SimpleInterfaceImpl, since
- // this would lead to an illegal class access here.
- SimpleInterface obj = SimpleInterfaceImplRetriever.getSimpleInterfaceImpl();
- obj.foo();
+ // Without access modifications, it is not possible to merge the interface SimpleInterface into
+ // SimpleInterfaceImpl, since this would lead to an illegal class access here.
+ SimpleInterface x = SimpleInterfaceImplRetriever.getSimpleInterfaceImpl();
+ x.foo();
+
+ // Without access modifications, it is not possible to merge the interface OtherSimpleInterface
+ // into OtherSimpleInterfaceImpl, since this could lead to an illegal class access if another
+ // package references OtherSimpleInterface.
+ OtherSimpleInterface y = new OtherSimpleInterfaceImpl();
+ y.bar();
+ }
+
+ // Should only be merged into OtherSimpleInterfaceImpl if access modifications are allowed.
+ public interface SimpleInterface {
+
+ void foo();
+ }
+
+ // Should only be merged into OtherSimpleInterfaceImpl if access modifications are allowed.
+ public interface OtherSimpleInterface {
+
+ void bar();
+ }
+
+ private static class OtherSimpleInterfaceImpl implements OtherSimpleInterface {
+
+ @Override
+ public void bar() {
+ System.out.println("In bar on OtherSimpleInterfaceImpl");
+ }
}
}