<div dir="ltr"><div dir="ltr">On Fri, Jul 14, 2023 at 1:05 AM Jan Lahoda <<a href="mailto:jan.lahoda@oracle.com">jan.lahoda@oracle.com</a>> wrote:<br></div><div class="gmail_quote"><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex">I tried a <br>
simple testcase, where a use in module "use" uses an annotation from <br>
different module "lib", and the usages is from classfile:<br>
<br>
<a href="https://github.com/lahodaj/jdk/blob/e74368cb72790a399f3bb28c0dde2146d015757e/test/langtools/tools/javac/modules/AnnotationsAndMultipleModules.java" rel="noreferrer" target="_blank">https://github.com/lahodaj/jdk/blob/e74368cb72790a399f3bb28c0dde2146d015757e/test/langtools/tools/javac/modules/AnnotationsAndMultipleModules.java</a><br></blockquote><div><br></div><div>Would it matter if "different module" were the/an unnamed module? And if "use" were a patched module?</div><div> </div><div>In case it turns out to matter, the scenario is one that is commonly set up by Maven's JUnit test machinery unless you actively work against it: at test time, unit test code under src/test/java is automagically patched into (via --patch-module) your project's "main" module (M) (whose classes reside conventionally under src/main/java). The command line contains --module-path "/path/to/M", --add-reads M=ALL-UNNAMED, and --add-opens M/p=ALL-UNNAMED, and --add-modules M (if I've typed all that properly).  JUnit itself, though modular, is on the classpath. The annotation in my example (q.C) is actually org.junit.jupiter.api.Test, if it matters. The net effect is (not defending it, just noting) M's module-info does not have to explicitly read any JUnit module, but your project's JUnit-based unit test code can nevertheless "see" package-private methods etc. in M as if it were a proper member of M.</div><div><br></div><div>In this case, in such an environment, if you access @org.junit.jupiter.api.Test (annotating a method in your unit test under src/test/java, patched in to M), its type will be erroneous. Or so I am observing.</div><div><br></div><div>I'll see if I can put together a reproducer but this is not at all high priority for me. I'm also getting the strong sense here that this is somehow likely pilot error in some way, though I'm not sure on what input.</div><div><br></div><div>Thanks for your time,</div><div>Best,</div><div>Laird</div></div></div>