does nullmarking packages recurese?

31 views
Skip to first unread message

Caleb Cushing

unread,
Mar 4, 2024, 2:45:40 PMMar 4
to jspecify-discuss
so someone please correct me if I'm dumb here. A package, even with modules is just a "key", meaning in a  module.

given the 3 packages
com.myorg.lib
com.myorg.lib.api
com.myorg.lib.internal

from the current userguide

 > If applied to a module then its scope is all the code in the module. If applied to a package then its scope is all the code in the package.

export "com.myorg.lib"
export "com.myorg.lib.api"

are both required since it's not recursive (many tools make it so for classpath scanning but that's up to the tool). Obviously we don't want to export internal. Putting Nullmarked on this.  Since we put it on the module nullmarked also applies to com.myorg.lib.internal. If the consumers of the module aren't using JPMS is it still supposed to be respected by tools? I would assume so.

If I nullmark "com.myorg.lib" are `.api` and `.internal` also considered to be nullmarked? I feel like this could be a little clearer in the documentation.

Manu Sridharan

unread,
Mar 4, 2024, 5:35:20 PMMar 4
to Caleb Cushing, jspecify-discuss
Hi Caleb,

According to my understanding, if you write @NullMarked on a module, that applies to all code in that module.  I don’t think whether packages are exported or not makes any difference.  If you wanted to set just a couple of packages from a module as unmarked, you could write @NullUnmarked in the package-info.java files for just those packages.

If the consumers of the module aren't using JPMS is it still supposed to be respected by tools? I would assume so.

Yes, I believe the null-markedness of a module should still be respected by checking tools, even if client code isn’t using JPMS.

If I nullmark "com.myorg.lib" are `.api` and `.internal` also considered to be nullmarked? I feel like this could be a little clearer in the documentation.

The answer here is no: making the com.myorg.lib package @NullMarked does not make com.myorg.lib.internal @NullMarked (if I understood your question correctly).

I hope that helps!

Best,
Manu


--
You received this message because you are subscribed to the Google Groups "jspecify-discuss" group.
To unsubscribe from this group and stop receiving emails from it, send an email to jspecify-discu...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/jspecify-discuss/7a96938f-ec3e-4ebb-b81d-393a1280dffan%40googlegroups.com.

Caleb Cushing

unread,
Mar 4, 2024, 5:43:52 PMMar 4
to Manu Sridharan, jspecify-discuss
The answer here is no: making the com.myorg.lib package @NullMarked does not make com.myorg.lib.internal @NullMarked (if I understood your question correctly).

It does. I think it should be clearly documented that it does not recurse, given how prolific it is for tools that let you specify packages to recurse (e.g. spring/hibernate).
--

Manu Sridharan

unread,
Mar 4, 2024, 5:47:05 PMMar 4
to Caleb Cushing, jspecify-discuss
I agree with you.  Maybe it should even be mentioned briefly in the user guide.  This has come up before and it’s a common point of confusion.

Best,
Manu

Manu Sridharan

unread,
Mar 4, 2024, 5:50:44 PMMar 4
to Caleb Cushing, jspecify-discuss
Went ahead and opened https://github.com/jspecify/jspecify/pull/489 to get this somewhere in the user guide.

Best,
Manu

Chris Povirk

unread,
Mar 15, 2024, 12:04:45 PMMar 15
to Manu Sridharan, Caleb Cushing, jspecify-discuss
Thanks for the questions, and thanks, Manu, for already documenting one answer.

On the question of whether module-info helps in a non-modular world, I am more pessimistic than Manu. I've dumped some thoughts into a new issue so that we have a record of this for future planning. If anyone is up for performing some tests or providing other info, it would be welcome.
Reply all
Reply to author
Forward
0 new messages