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

The constructors of URLPermission class do not behave as described in javadoc

    XMLWordPrintable

Details

    • Bug
    • Resolution: Fixed
    • P3
    • 8
    • 8
    • core-libs
    • b113
    • b117
    • generic
    • generic
    • Verified

    Backports

      Description

        Following two constructors did not throw "IllegalArgumentExceptions" when given invalid url.
        public URLPermission(String url, String actions)
        public URLPermission(String url)
        The behavior is not consistent with Javadoc descriptios:
            IllegalArgumentException - if url does not result in a valid URI
        -------------------------------------------------------------------------------------------------------------
        Ran test below with latest promoted binaries and test failed:

        import java.net.*;
        public class TestConstructor {
            public static void main(String args[]){
                String invalidURI="http:\\www.oracle.com";
                try{
                    URI u = URI.create(invalidURI);
                }catch(IllegalArgumentException e){
                    System.out.println(invalidURI+" is an invalid URI");
                }
                try{
                    URLPermission permission = new URLPermission(invalidURI);
                    System.out.println("test fail");
                }catch (IllegalArgumentException e){
                    System.out.println("test pass");
                }
            }
        }

        commands & results:
        -bash-4.1$ /java/re/jdk/8/promoted/latest/binaries/linux-amd64/bin/java -version
        java version "1.8.0-ea"
        Java(TM) SE Runtime Environment (build 1.8.0-ea-b114)
        Java HotSpot(TM) 64-Bit Server VM (build 25.0-b56, mixed mode)
        bash-4.1$ /java/re/jdk/8/promoted/latest/binaries/linux-amd64/bin/javac TestConstructor.java
        -bash-4.1$ /java/re/jdk/8/promoted/latest/binaries/linux-amd64/bin/java TestConstructor
        http:\www.oracle.com is an invalid URI
        test fail


        Attachments

          Issue Links

            Activity

              People

                michaelm Michael McMahon
                amjiang Amanda Jiang (Inactive)
                Votes:
                0 Vote for this issue
                Watchers:
                3 Start watching this issue

                Dates

                  Created:
                  Updated:
                  Resolved: