Uploaded image for project: 'JDK'
  1. JDK
  2. JDK-8285966

java.io.File.toURL doesn't tolerate file:\C:\dev\ which breaks xjc on Windows after CPU22_04

    XMLWordPrintable

Details

    • b06
    • generic
    • generic

    Description

      ADDITIONAL SYSTEM INFORMATION :
      Apache Maven 3.8.1 (05c21c65bdfed0f71a2f2ada8b84da59348c4c5d)
      Maven home: C:\Program Files\JetBrains\IntelliJ IDEA 2022.1\plugins\maven\lib\maven3
      Java version: 11.0.15, vendor: Eclipse Adoptium, runtime: C:\Program Files\Eclipse Adoptium\jdk-11.0.15.10-hotspot
      Default locale: de_DE, platform encoding: UTF-8
      OS name: "windows 10", version: "10.0", arch: "amd64", family: "windows"

      A DESCRIPTION OF THE PROBLEM :
      Maven cxf-xjc-plugin:3.3.1:xsdtojava generates URLs like this: "file:\C:\dev\m2repo\com\github\krasa\krasa-jaxb-tools\1.8\krasa-jaxb-tools-1.8.jar".
      Even if it is strange, it works in jdk-11.0.12.7-openj9 (Semeru) and also in jdk-11.0.14.1+1 (Eclipse Adoptium JDK).
      In 11.0.15 Releases jdk-11.0.15.10-openj9 (Semeru) and jdk-11.0.15.10-hotspot (Adoptium), it crashes:

      [INFO] Building jar: C:\Users\Dev28\AppData\Local\Temp\cxf-xjc-plugin6285953335413304004.jar
      [DEBUG] Exception in thread "main" com.sun.tools.xjc.BadCommandLineException: "file:\C:\dev\m2repo\com\github\krasa\krasa-jaxb-tools\1.8\krasa-jaxb-tools-1.8.jar" ist kein gültiger Dateiname: {1}
      [DEBUG] at com.sun.tools.xjc.Options.parseArgument(Options.java:515)
      [DEBUG] at com.sun.tools.xjc.Options.parseArguments(Options.java:827)
      [DEBUG] at org.apache.cxf.maven_plugin.XSDToJavaRunner.run(XSDToJavaRunner.java:170)
      [DEBUG] at org.apache.cxf.maven_plugin.XSDToJavaRunner.main(XSDToJavaRunner.java:360)
      [DEBUG] Caused by: java.net.MalformedURLException: Invalid file path
      [DEBUG] at java.base/java.io.File.toURL(File.java:695)
      [DEBUG] at com.sun.tools.xjc.Options.parseArgument(Options.java:512)
      [DEBUG] ... 3 more


      REGRESSION : Last worked in version 11

      STEPS TO FOLLOW TO REPRODUCE THE PROBLEM :
      Create the two files (content doesn't matter):
      src/main/resources/binding.xjb
      src/main/resources/data.xsd
      Create a pom.xml, that contains:

        <dependencies>
          <dependency>
            <groupId>javax.validation</groupId>
            <artifactId>validation-api</artifactId>
            <version>2.0.1.Final</version>
          </dependency>
          <dependency>
            <groupId>javax.xml.bind</groupId>
            <artifactId>jaxb-api</artifactId>
            <version>2.3.1</version>
          </dependency>
              <dependency>
                  <groupId>com.github.krasa</groupId>
                  <artifactId>krasa-jaxb-tools</artifactId>
                  <version>1.8</version>
                  <scope>test</scope>
              </dependency>
          </dependencies>
          <build>
              <plugins>
                  <plugin>
                      <groupId>org.apache.cxf</groupId>
                      <artifactId>cxf-xjc-plugin</artifactId>
                      <version>3.3.1</version>
                      <executions>
                          <execution>
                              <id>generate-sources</id>
                              <phase>process-resources</phase>
                              <goals>
                                  <goal>xsdtojava</goal>
                              </goals>
                              <configuration>
                                  <sourceRoot>${project.build.directory}/generated-sources</sourceRoot>
                                  <xsdOptions>
                                      <xsdOption>
                                          <extension>true</extension>
                                          <xsd>src/main/resources/data.xsd</xsd>
                                          <bindingFile>src/main/resources/binding.xjb</bindingFile>
                                          <packagename>com.example</packagename>
                                          <extensionArgs>
                                              <extensionArg>-XJsr303Annotations</extensionArg>
                                              <extensionArg>-XJsr303Annotations:targetNamespace=http://www.gdv-online.de/snetz/namespaces/KSN/release2003&lt;/extensionArg>
                                          </extensionArgs>
                                      </xsdOption>
                                  </xsdOptions>
                                  <extensions>
                                      <extension>com.github.krasa:krasa-jaxb-tools:1.8</extension>
                                  </extensions>
                              </configuration>
                          </execution>
                      </executions>
                  </plugin>
              </plugins>
          </build>

      EXPECTED VERSUS ACTUAL BEHAVIOR :
      EXPECTED -
      xjc tries to generate DTOs (but fails because of an invalid schema).
      ACTUAL -
      xjc doesn't even start and fails with an exception.

      ---------- BEGIN SOURCE ----------
      C:\dev>cd "C:\Program Files"

      C:\Program Files>"C:\Program Files\Eclipse Adoptium\jdk-11.0.14.1+1\bin\jshell.exe"
      | Welcome to JShell -- Version 11.0.14.1
      | For an introduction type: /help intro

      jshell> new File("file:\\C:\\dev\\temp.jar").toURL();
      $1 ==> file:/C:/Program Files/file:/C:/dev/temp.jar

      jshell>

      C:\Program Files>"C:\Program Files\Eclipse Adoptium\jdk-11.0.15.10-hotspot\bin\jshell.exe"
      | Welcome to JShell -- Version 11.0.15
      | For an introduction type: /help intro

      jshell> new File("file:\\C:\\dev\\temp.jar").toURL();
      | Exception java.net.MalformedURLException: Invalid file path
      | at File.toURL (File.java:695)
      | at (#1:1)

      jshell>
      ---------- END SOURCE ----------

      FREQUENCY : always


      Attachments

        Issue Links

          Activity

            People

              Unassigned Unassigned
              webbuggrp Webbug Group
              Votes:
              0 Vote for this issue
              Watchers:
              4 Start watching this issue

              Dates

                Created:
                Updated:
                Resolved: