RFR JDK-4880778
Greetings: Please consider the following modification of our classes for handling URLs. http://cr.openjdk.java.net/~jzavgren/4880778/webrev.01/ background See http://java.sun.com/j2se/1.4.2/docs/api/java/net/URL.html. The URL class is declared final yet has two protected methods: protected void set(String protocol, String host, int port, String file, String ref) protected void set(String protocol, String host, int port, String authority, String userInfo, String path, String query, String ref) Since the final class can't be subclassed these methods can't be accessed. They could be package protected instead. (i.e. no access specifier) Solution: 1.) I made the set method in the URL class package protected 2.) I edited the java doc documentation to eliminate reference to the set method in the URL class from the URLStreamHandler class 3.) I wrote a test program (URLTest.java) (at the end of this message) that attempts to call the set method from a URL object... When there is no package statement: //package java.net; the compilation fails java/net/URLTest.java:28: error: set(String,String,int,String,String,String,String,String) is not public in URL; cannot be accessed from outside package myURL.set(ftp, vpn.zavgren.com, 77, lugnut.txt, ,,,); ^ 1 error 4.) When there is a package statement in the source code: package java.net; the code compiles but it creates a run time error. jzavgren@ubuntuVM:~/code/java/URL$ java java.net.URLTest Exception in thread main java.lang.SecurityException: Prohibited package name: java.net at java.lang.ClassLoader.preDefineClass(ClassLoader.java:651) at java.lang.ClassLoader.defineClass(ClassLoader.java:785) at java.security.SecureClassLoader.defineClass(SecureClassLoader.java:142) at java.net.URLClassLoader.defineClass(URLClassLoader.java:442) at java.net.URLClassLoader.access$100(URLClassLoader.java:64) at java.net.URLClassLoader$1.run(URLClassLoader.java:354) at java.net.URLClassLoader$1.run(URLClassLoader.java:348) at java.security.AccessController.doPrivileged(Native Method) at java.net.URLClassLoader.findClass(URLClassLoader.java:347) at java.lang.ClassLoader.loadClass(ClassLoader.java:423) at sun.misc.Launcher$AppClassLoader.loadClass(Launcher.java:308) at java.lang.ClassLoader.loadClass(ClassLoader.java:356) at sun.launcher.LauncherHelper.checkAndLoadMain(LauncherHelper.java:491) - URLTest.java - package java.net; import java.net.*; import java.io.*; public class URLTest { public static void main (String[]args) { URL myURL=null; try { myURL = new URL (http, www.zavgren.com, 80, /index.html); } catch (MalformedURLException mfue) { System.err.println (mfue); } System.out.printf (The URL is: %s\n, myURL.toString ()); System.out.printf (The protocol is: %s\n, myURL.getProtocol()); System.out.printf (The external form is: %s\n, myURL.toExternalForm()); System.out.printf (Opening connection... \n); try { URLConnection uc = myURL.openConnection(); } catch (IOException io) { } myURL.set(ftp, vpn.zavgren.com, 77, lugnut.txt, ,,,); } }; Thanks! John
Re: RFR JDK-4880778
On 02/02/2013 14:39, John Zavgren wrote: Greetings: Please consider the following modification of our classes for handling URLs. http://cr.openjdk.java.net/~jzavgren/4880778/webrev.01/ This looks okay to me. For the URLStreamHandler setURL methods then an alternative to removing the statement would be just adjust the wording, say replace be able to call the set method on a URL to be able to use this method to set the values of the URL fields. Minor nit, but there are couple of alignment issues. In URL then the arguments spill onto 2 or 3 lines so they can be re-aligned. In URLStreamHandler it look slike the setURL method isn't quite lined up with the other methods (pre-dates your proposed changes). -Alan.
hg: jdk8/tl/jdk: 8007322: untangle ftp protocol from general networking URL tests
Changeset: ee83319029a5 Author:chegar Date: 2013-02-02 17:15 + URL: http://hg.openjdk.java.net/jdk8/tl/jdk/rev/ee83319029a5 8007322: untangle ftp protocol from general networking URL tests Reviewed-by: alanb ! test/java/net/URL/Constructor.java ! test/java/net/URL/HandlerLoop.java ! test/java/net/URL/Test.java ! test/java/net/URL/URIToURLTest.java - test/java/net/URL/abnormal_http_urls - test/java/net/URL/ftp_urls - test/java/net/URL/jar_urls - test/java/net/URL/normal_http_urls - test/java/net/URL/runconstructor.sh - test/java/net/URL/share_file_urls - test/java/net/URL/win32_file_urls ! test/java/net/URLConnection/RequestProperties.java ! test/java/net/URLConnection/RequestPropertyValues.java + test/sun/net/ftp/EncDec.doc + test/sun/net/ftp/MarkResetTest.java + test/sun/net/ftp/MarkResetTest.sh - test/sun/net/www/EncDec.doc - test/sun/net/www/MarkResetTest.java - test/sun/net/www/MarkResetTest.sh ! test/sun/net/www/http/HttpClient/ProxyTest.java
hg: jdk8/tl/jdk: 8007135: tools/launcher/VersionCheck.java failing with new tool jabswitch
Changeset: 25831e7009c4 Author:ksrini Date: 2013-02-02 12:08 -0800 URL: http://hg.openjdk.java.net/jdk8/tl/jdk/rev/25831e7009c4 8007135: tools/launcher/VersionCheck.java failing with new tool jabswitch Reviewed-by: ksrini, mduigou Contributed-by: ragini.pra...@oracle.com ! test/tools/launcher/VersionCheck.java
hg: jdk8/tl/langtools: 8005075: Pool.Method, and Pool.Variable redundant Symbol field should be removed
Changeset: 4cc73ec94686 Author:vromero Date: 2013-02-02 21:04 + URL: http://hg.openjdk.java.net/jdk8/tl/langtools/rev/4cc73ec94686 8005075: Pool.Method, and Pool.Variable redundant Symbol field should be removed Reviewed-by: jjg ! src/share/classes/com/sun/tools/javac/code/Symbol.java ! src/share/classes/com/sun/tools/javac/jvm/ClassWriter.java ! src/share/classes/com/sun/tools/javac/jvm/Pool.java
hg: jdk8/tl/langtools: 7199823: javac generates inner class that can't be verified
Changeset: a51a8dac0a2f Author:vromero Date: 2013-02-03 02:31 + URL: http://hg.openjdk.java.net/jdk8/tl/langtools/rev/a51a8dac0a2f 7199823: javac generates inner class that can't be verified Reviewed-by: jjg, mcimadamore ! src/share/classes/com/sun/tools/javac/comp/Lower.java + test/tools/javac/7199823/InnerClassCannotBeVerified.java