I have the follwing Java 9 module:
module com.example.a {
exports com.example.a;
}
With an exported type:
public class Api {
public static void foo(ImplDetail args) {}
}
And a non-exported type:
package com.example.b.internal;
public class ImplDetail {}
The exported type uses the non-exported type as a method parameter type in a public method. I'd have assumed that the compiler would reject such an inconsistent class configuration, as clients in other modules could not really invoke the foo()
method as they cannot instantiate the parameter type.
To my surprise, this module is compiled successfully by javac. I can see the special case of passing null
, still I'd consider such an API definition malformed and think it should not be supported, enforced by the compiler ideally.
What's the reasoning for not disallowing such case?