loading regular/directory resources via classloader
Robert Scholte
rfscholte at apache.org
Wed Jun 12 07:18:00 UTC 2024
Consider the following code:
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
public class Application {
private static final Logger logger =
LoggerFactory.getLogger(Application.class);
public static void main(String[] args) throws Exception {
logger.info("{}",
Application.class.getClassLoader().getResource("META-INF/micronaut/io.micron
aut.inject.BeanDefinitionReference") != null ); // directory
logger.info("{}",
Application.class.getClassLoader().getResource("META-INF/micronaut/io.micron
aut.inject.BeanDefinitionReference/io.micronaut.context.event.ApplicationEve
ntPublisherFactory") != null ); // empty file
logger.info("{}",
ClassLoader.getSystemResource("META-INF/micronaut/io.micronaut.inject.BeanDe
finitionReference") != null ); // directory
logger.info("{}",
ClassLoader.getSystemResource("META-INF/micronaut/io.micronaut.inject.BeanDe
finitionReference/io.micronaut.context.event.ApplicationEventPublisherFactor
y") != null ); // empty file
}
}
When running this using the classpath or modulepath I'll get true for every
line.
However, when creating the application with jlink, only regular resources
return true(i.e. the second and fourth log statement), the "directories"
return false.
Is this difference intended behavior?
Regards,
Robert
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <https://mail.openjdk.org/pipermail/jigsaw-dev/attachments/20240612/f3ae41d8/attachment.htm>
More information about the jigsaw-dev
mailing list