Details
-
Bug
-
Resolution: Fixed
-
P3
-
8, 11
-
b27
-
x86_64
-
windows_10
Backports
Issue | Fix Version | Assignee | Priority | Status | Resolution | Resolved In Build |
---|---|---|---|---|---|---|
JDK-8246446 | 13.0.4 | Jonathan Gibbons | P3 | Resolved | Fixed | b04 |
JDK-8236738 | 11.0.8-oracle | Adam Sotona | P3 | Resolved | Fixed | b01 |
JDK-8236713 | 11.0.7 | Jonathan Gibbons | P3 | Resolved | Fixed | b01 |
Description
Microsoft Windows [Version 10.0.17134.523]
openjdk version "13-ea" 2019-09-17
OpenJDK Runtime Environment (build 13-ea+6)
OpenJDK 64-Bit Server VM (build 13-ea+6, mixed mode, sharing)
A DESCRIPTION OF THE PROBLEM :
The Manifest Class-Path entry is specified as a relative URL.
https://docs.oracle.com/en/java/javase/11/docs/specs/jar/jar.html#class-path-attribute
But the JVM ClassLoader accepts all kinds of URLs:
- my%20dir/mylib.jar
- /C:/my%20dir/mylib.jar
- file:/C:/my%20dir/mylib.jar
- file:///C:/my%20dir/mylib.jar
The Java Compiler is treating the entries as Paths. And the behavior has changed since Java 9.
Behavior of javac 8:
- my%20dir/mylib.jar = ignored
- /C:/my%20dir/mylib.jar = ignored
- file:/C:/my%20dir/mylib.jar = ignored
Behavior of javac 9-13:
- my%20dir/mylib.jar = ignored
- /C:/my%20dir/mylib.jar = Illegal char <:> at index 2
- file:/C:/my%20dir/mylib.jar = Illegal char <:> at index 4
I expect that:
1. The Java Compiler treats the entries as URLs, according to spec.
2. The behavior of the JVM ClassLoader and the Java Compiler is equal
3. The behavior is backwards compatible
So the Java Compiler must accept all the URLs that the JVM ClassLoader also accepts nowadays.
Should be fixed in Java 11 and master.
REGRESSION : Last worked in version 8u192
STEPS TO FOLLOW TO REPRODUCE THE PROBLEM :
This windows batch file demonstrates the issue.
Change the Class-Path to any other URI to see the difference. (Double % is to escape)
=====================repro.bat=====================
echo public class Hello {> Hello.java
echo public static String hello() {>> Hello.java
echo return "hello";>> Hello.java
echo }>> Hello.java
echo }>> Hello.java
echo public class Main {> Main.java
echo public static void main(String[] args) {>> Main.java
echo System.out.println(Hello.hello());>> Main.java
echo }>> Main.java
echo }>> Main.java
javac Hello.java
mkdir "Program Libs"
jar -cf "Program Libs/hello.jar" Hello.class
del Hello.class
echo Class-Path: Program%%20Libs/hello.jar > manifest.mf
jar -cfm hellocp.jar manifest.mf
del manifest.mf
javac -cp "hellocp.jar" Main.java
rem This failed. Now I add the hello.jar directly to the classpath to be able to compile
pause
javac -cp "hellocp.jar;Program Libs/hello.jar" Main.java
java -cp hellocp.jar;. Main
EXPECTED VERSUS ACTUAL BEHAVIOR :
EXPECTED -
C:\javacbug>java -cp hellocp.jar;. Main
hello
ACTUAL -
C:\javacbug>javac -cp "hellocp.jar" Main.java
Main.java:3: error: cannot find symbol
System.out.println(Hello.hello());
^
symbol: variable Hello
location: class Main
1 error
C:\javacbug>javac -cp "hellocp.jar" Main.java
error: illegal argument for --class-path: Illegal char <:> at index 2: /C:/javacbug/Program%20Libs/hello.jar
C:\javacbug>javac -cp "hellocp.jar" Main.java
error: illegal argument for --class-path: Illegal char <:> at index 4: file:/C:/javacbug/Program%20Libs/hello.jar
FREQUENCY : always
Attachments
Issue Links
- backported by
-
JDK-8236713 Javac treats Manifest Class-Path entries as Paths instead of URLs
- Resolved
-
JDK-8236738 Javac treats Manifest Class-Path entries as Paths instead of URLs
- Resolved
-
JDK-8246446 Javac treats Manifest Class-Path entries as Paths instead of URLs
- Resolved
- duplicates
-
JDK-8232945 FSInfo#getJarClassPath does not comply with the JAR specification
- Closed
-
JDK-8224854 "error: illegal argument for --class-path: Illegal char <:> at index 2: /D:/a/b"
- Closed
-
JDK-8232925 FSInfo#getJarClassPath does not comply with the JAR specification
- Resolved
- relates to
-
JDK-8220742 %-encoding in JAR file Class-Path attribute
- Open
-
JDK-8235361 JAR Class-Path no longer accepts relative URLs encoding absolute Windows paths (e.g "/C:/...")
- Resolved
-
JDK-8217215 Enable checking/ignoring of non-conforming Class-Path entries
- Closed
-
JDK-8232925 FSInfo#getJarClassPath does not comply with the JAR specification
- Resolved
-
JDK-8211941 Enable checking/ignoring of non-conforming Class-Path entries
- Closed