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

Under Java 9 Java Web Start consumes the only URLStreamHandlerFactory slot

    XMLWordPrintable

Details

    • 9
    • b23
    • x86_64
    • linux_ubuntu

    Description

      FULL PRODUCT VERSION :
      java version "9-ea"
      Java(TM) SE Runtime Environment (build 9-ea+163)
      Java HotSpot(TM) 64-Bit Server VM (build 9-ea+163, mixed mode)


      ADDITIONAL OS VERSION INFORMATION :
      Linux ubuntu1204-XXXXXXX 3.5.0-45-generic #68~precise1-Ubuntu SMP Wed Dec 4 16:18:46 UTC 2013 x86_64 x86_64 x86_64 GNU/Linux


      EXTRA RELEVANT SYSTEM CONFIGURATION :
      Not related to OS.

      A DESCRIPTION OF THE PROBLEM :
      URL.setURLStreamHandlerFactory() permits only one call to set a factory. When a second call is made an exception is thrown with the message "factory already defined".

      Starting with Java 9, in Java Web Start (JNLP), this call is made before the application starts, prohibiting applications from using the facility. This does not happen in Java 8, nor does it happen when the application is launched directly with java on the command line.

      I have an application that runs fine in Java 8, that supplies its own URLStreamHandlerFactory. This application is blocked from working in Java 1.9 from a JNLP launch.



      REGRESSION. Last worked in version 8u121

      ADDITIONAL REGRESSION INFORMATION:
      It works in all Java 8 versions.

      STEPS TO FOLLOW TO REPRODUCE THE PROBLEM :
      1. Compile supplied source .
      2. put it in a jar (test.jar), and sign it.
      3. compose a JNLP like this (with appropriate substitution for the path):
      <?xml version="1.0" encoding="UTF-8"?>
      <jnlp spec="1.5+" codebase="file:///[local director without leading slash here]" href="test.jnlp" version="1.0" >
          <information>
              <title>Set a URLStreamHandler</title>
              <vendor>Test</vendor>
              <offline-allowed/>
          </information>
          <security>
              <all-permissions />
          </security>
          <resources>
              <java version="1.8+"/>
              <jar href="test.jar" main="true" download="lazy" />
          </resources>
          <application-desc main-class="com.test.URLFactoryMain"/>
      </jnlp>
      4. Change your security settings in the java control panel to include the uri used in the code base and href.
      5. Run with Java 8 "java -cp . com.test.URLFactoryMain" - success
      6. Run with Java 8, "javaws test.jnlp" - success
      7. Run with Java 9 "java -cp . com.test.URLFactoryMain" - success
      8. Run with Java 9, "javaws test.jnlp" - failure



      EXPECTED VERSUS ACTUAL BEHAVIOR :
      EXPECTED -
      When run with either Java 8 or Java 9, command line or with Java Web Start, it should run no exceptions.
      ACTUAL -
      When run with Java 9, using Java Web Start, it fires an exception with message "factory already defined".

      ERROR MESSAGES/STACK TRACES THAT OCCUR :
      #### Java Web Start Error:
      #### java.lang.Error: factory already defined

      java.lang.Error: factory already defined
      at java.base/java.net.URL.setURLStreamHandlerFactory(Unknown Source)

      REPRODUCIBILITY :
      This bug can be reproduced always.

      ---------- BEGIN SOURCE ----------
      package com.test;

      import java.net.URL;
      import java.net.URLStreamHandler;
      import java.net.URLStreamHandlerFactory;

      public class UrlFactoryMain {
      private static class TestURLHandlerFactory implements URLStreamHandlerFactory {
      @Override
      public URLStreamHandler createURLStreamHandler(String protocol) {
      return null;
      }
      }
      public static void main(String[] args) {
      URL.setURLStreamHandlerFactory(new TestURLHandlerFactory());
      }
      }
      ---------- END SOURCE ----------

      Attachments

        Issue Links

          Activity

            People

              herrick Andy Herrick (Inactive)
              webbuggrp Webbug Group
              Votes:
              0 Vote for this issue
              Watchers:
              6 Start watching this issue

              Dates

                Created:
                Updated:
                Resolved: