[slf4j-dev] [JIRA] Updates for SLF4J-550: JPMS 下 java.lang.ClassLoader#getResource 工作差异
QOS.CH (JIRA)
noreply-jira at qos.ch
Thu May 26 20:12:00 CEST 2022
SLF4J / SLF4J-550
JPMS 下 java.lang.ClassLoader#getResource 工作差异
==============================
Here's what changed in this issue in the last few minutes.
This issue has been created
This issue is now assigned to you.
This issue has been deleted
==============================
Issue created
------------------------------
琉璃 created this issue on 26/May/22 7:57 PM
Summary: JSPM 下 java.lang.ClassLoader#getResource 工作差异
Issue Type: Story
Affects Versions: 2.0.0-alpha7
Assignee: SLF4J developers list
Attachments: 2022-05-27_01-55-40.jpg
Components: slf4j-simple
Created: 26/May/22 7:57 PM
Environment:
版本 Windows 11 专业版
版本 21H2
安装日期 2021-10-15
操作系统版本 22000.675
java 17 2021-09-14 LTS
Java(TM) SE Runtime Environment (build 17+35-LTS-2724)
Java HotSpot(TM) 64-Bit Server VM (build 17+35-LTS-2724, mixed mode, sharing)
Apache Maven 3.8.4 (9b656c72d54e5bacbed989b64718c159fe39b537)
Maven home: C:\usr\tool\apache-maven-3.8.4
Java version: 17, vendor: Oracle Corporation, runtime: C:\usr\lib\jdk-17
Default locale: zh_CN, platform encoding: GBK
OS name: "windows 10", version: "10.0", arch: "amd64", family: "windows"
<dependency>
<groupId>org.slf4j</groupId>
<artifactId>slf4j-api</artifactId>
<version>2.0.0-alpha7</version>
</dependency>
Priority: Major
Reporter: 琉璃
Description:
有如下简单测试代码:
There are the following simple test codes:
{code:java}
package cn.test.resources;
import java.net.URL;
public class Main {
public static void main(String[] args) {
URL resource = Main.class.getClassLoader().getResource("");
System.out.println(resource.getFile());
}
}
{code}
这是一个 maven 项目, 只有这一个文件, pom 文件仅包含 `slf4j-api` 的依赖.
如果不添加 `module-info.java` 文件, 在我的计算机上, 上述代码输出:
{color:#c1c7d0}/C:/test/testJpmsResource/target/classes/{color}
如果添加了 `module-info.java` 文件, 即使没有声明 `requires org.slf4j` 我会得到下面的结果:
{color:#c1c7d0}file:/C:/usr/data/maven/org/slf4j/slf4j-api/2.0.0-alpha7/slf4j-api-2.0.0-alpha7.jar!/META-INF/versions/9/{color}
This is a maven project. There is only one file. The POM file only contains the dependencies of 'slf4j API'
If you don't add ` module info Java file, on my computer, the above code output:
{color:#c1c7d0}/C:/test/testJpmsResource/target/classes/{color}
If you add ` module info Java file, even if it does not declare 'requires org Slf4j ` I will get the following results:
{color:#c1c7d0}file:/C:/usr/data/maven/org/slf4j/slf4j-api/2.0.0-alpha7/slf4j-api-2.0.0-alpha7.jar!/META-INF/versions/9/{color}
----
差异大概发生在 `jdk.internal.loader.BuiltinClassLoader#findMiscResource` , 我的疑问是 是什么造成这种差异? , slf4j 的 `META-INF/versions/*` 的文件为什么会在这里返回?
The difference probably occurs in `jdk.internal.loader.BuiltinClassLoader#findMiscResource`, my question is:
- What makes this difference?
- why does slf4j's' meta-inf / versions / * 'file return here?
==============================
Issue deleted
------------------------------
Ceki Gülcü has deleted this issue on 26/May/22 8:05 PM
==============================
This message was sent by Atlassian Jira (v8.8.0#808000-sha1:e2c7e59)
More information about the slf4j-dev
mailing list