harmony-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Senaka Fernando (JIRA)" <j...@apache.org>
Subject [jira] Commented: (HARMONY-1187) [classlib][text] unexpected MissingResourceException for new DecimalFormat("#######0.0000")
Date Sat, 19 Jul 2008 22:53:31 GMT

    [ https://issues.apache.org/jira/browse/HARMONY-1187?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=12615058#action_12615058
] 

Senaka Fernando commented on HARMONY-1187:
------------------------------------------

Hi all,

As of today I get (Linux system),

Uncaught exception in main:
java.lang.ClassCastException: MyURLConnection
	at java.net.URLClassLoader.createURLJarHandler(URLClassLoader.java:1035)
	at java.net.URLClassLoader.makeNewHandler(URLClassLoader.java:997)
	at java.net.URLClassLoader.getHandler(URLClassLoader.java:980)
	at java.net.URLClassLoader.findResourceImpl(URLClassLoader.java:964)
	at java.net.URLClassLoader$5.run(URLClassLoader.java:937)
	at java.net.URLClassLoader$5.run(URLClassLoader.java:1)
	at java.security.AccessController.doPrivilegedImpl(AccessController.java:171)
	at java.security.AccessController.doPrivileged(AccessController.java:64)
	at java.net.URLClassLoader.findResource(URLClassLoader.java:939)
	at java.lang.ClassLoader$BootstrapLoader.findResource(ClassLoader.java:777)
	at java.lang.ClassLoader.getResource(ClassLoader.java:209)
	at java.lang.ClassLoader.getResourceAsStream(ClassLoader.java:215)
	at com.ibm.icu.impl.ICUData.getStream(ICUData.java:70)
	at com.ibm.icu.impl.ICUData.getStream(ICUData.java:79)
	at com.ibm.icu.impl.ICUResourceBundleReader.getReader(ICUResourceBundleReader.java:190)
	at com.ibm.icu.impl.ICUResourceBundle.createBundle(ICUResourceBundle.java:843)
	at com.ibm.icu.impl.ICUResourceBundle.instantiateBundle(ICUResourceBundle.java:751)
	at com.ibm.icu.impl.ICUResourceBundle.getBundleInstance(ICUResourceBundle.java:719)
	at com.ibm.icu.util.UResourceBundle.getRootType(UResourceBundle.java:465)
	at com.ibm.icu.util.UResourceBundle.instantiateBundle(UResourceBundle.java:513)
	at com.ibm.icu.util.UResourceBundle.getBundleInstance(UResourceBundle.java:137)
	at com.ibm.icu.util.UResourceBundle.getBundleInstance(UResourceBundle.java:217)
	at com.ibm.icu.text.DecimalFormatSymbols.initialize(DecimalFormatSymbols.java:661)
	at com.ibm.icu.text.DecimalFormatSymbols.<init>(DecimalFormatSymbols.java:59)
	at java.text.DecimalFormat.<init>(DecimalFormat.java:80)
	at test.main(test.java:12)

I see that the issue is related to this portion of code in working_classlib/modules/luni/src/main/java/java/net/URLClassLoader.java

1034         try {
1035             URL jarURL = ((JarURLConnection) url
1036                     .openConnection()).getJarFileURL();
1037             JarURLConnection juc = (JarURLConnection) new URL(
1038                     "jar", "", //$NON-NLS-1$ //$NON-NLS-2$
1039                     jarURL.toExternalForm() + "!/").openConnection(); //$NON-NLS-1$
1040             JarFile jf = juc.getJarFile();
1041             URLJarHandler jarH = new URLJarHandler(url, jarURL, jf, prefixName);
1042             if (jarH.getIndex() == null) {
1043                 try {
1044                     Manifest manifest = jf.getManifest();
1045                     if (manifest != null) {
1046                         String classpath = manifest.getMainAttributes().getValue(
1047                                 Attributes.Name.CLASS_PATH);
1048                         if (classpath != null) {
1049                             searchList.addAll(0, getInternalURLs(url, classpath));
1050                         }
1051                     }
1052                 } catch (IOException e) {
1053                 }
1054             }
1055             return jarH;
1056         } catch (IOException e) {
1057         }

We are not checking the class type before we cast (line 1035). I believe that RI handles this
properly :)...

However if we are to use a modified version of test.java as,

=====================================================
import java.net.*;
import java.text.DecimalFormat;
import java.io.IOException;
import java.util.jar.JarFile;

public class test {
    public static void main(String[] args) {
        URL.setURLStreamHandlerFactory(new URLStreamHandlerFactory() {
            public URLStreamHandler createURLStreamHandler(String protocol) {
                return new MyURLStreamHandler();
            }
        });
        System.out.println("res = " + new DecimalFormat("#######0.0000"));
    }
}

class MyURLJarConnection extends JarURLConnection {
    public MyURLJarConnection(URL u) throws MalformedURLException {
        super(u);
    }
    public JarFile getJarFile() {
        <<<< INSERT LOGIC HERE >>>>
    }
    public void connect() {
    }
}

class MyURLStreamHandler extends URLStreamHandler {
    protected MyURLStreamHandler() {
        super();
    }

    protected URLConnection openConnection(URL u) throws IOException {
        return new MyURLJarConnection(u);
    }

    protected void parseURL(URL u, String spec, int start, int limit) {
        super.parseURL(u, spec, start, limit);
    }

    protected void setURL(URL u, String protocol, String host, int port, String authority,
String userInfo, String path, String query, String ref) {
        super.setURL(u, protocol, host, port, authority, userInfo, path, query, ref);
    }
}
=====================================================

we should be able to sort this. However, I still couldn't figure out the exact logic required.
Please also note that I have not included the deprecated "protected void setURL(URL u, String
protocol, String host, int port, String file, String ref)".

If you simply replace <<<< INSERT LOGIC HERE >>>> with "return null;"
the exception would change to,

java.lang.NullPointerException
	at java.net.URLClassLoader$URLJarHandler.<init>(URLClassLoader.java:315)
	at java.net.URLClassLoader.createURLJarHandler(URLClassLoader.java:1041)
	at java.net.URLClassLoader.makeNewHandler(URLClassLoader.java:997)
	at java.net.URLClassLoader.getHandler(URLClassLoader.java:980)
	at java.net.URLClassLoader.findResourceImpl(URLClassLoader.java:964)
	at java.net.URLClassLoader$5.run(URLClassLoader.java:937)
	at java.net.URLClassLoader$5.run(URLClassLoader.java:1)
	at java.security.AccessController.doPrivilegedImpl(AccessController.java:171)
	at java.security.AccessController.doPrivileged(AccessController.java:64)
	at java.net.URLClassLoader.findResource(URLClassLoader.java:939)
	at java.lang.ClassLoader$BootstrapLoader.findResource(ClassLoader.java:777)
	at java.lang.ClassLoader.getResource(ClassLoader.java:209)
	at java.lang.ClassLoader.getResourceAsStream(ClassLoader.java:215)
	at com.ibm.icu.impl.ICUData.getStream(ICUData.java:70)
	at com.ibm.icu.impl.ICUData.getStream(ICUData.java:79)
	at com.ibm.icu.impl.ICUResourceBundleReader.getReader(ICUResourceBundleReader.java:190)
	at com.ibm.icu.impl.ICUResourceBundle.createBundle(ICUResourceBundle.java:843)
	at com.ibm.icu.impl.ICUResourceBundle.instantiateBundle(ICUResourceBundle.java:751)
	at com.ibm.icu.impl.ICUResourceBundle.getBundleInstance(ICUResourceBundle.java:719)
	at com.ibm.icu.util.UResourceBundle.getRootType(UResourceBundle.java:465)
	at com.ibm.icu.util.UResourceBundle.instantiateBundle(UResourceBundle.java:513)
	at com.ibm.icu.util.UResourceBundle.getBundleInstance(UResourceBundle.java:137)
	at com.ibm.icu.util.UResourceBundle.getBundleInstance(UResourceBundle.java:217)
	at com.ibm.icu.text.DecimalFormatSymbols.initialize(DecimalFormatSymbols.java:661)
	at com.ibm.icu.text.DecimalFormatSymbols.<init>(DecimalFormatSymbols.java:59)
	at java.text.DecimalFormat.<init>(DecimalFormat.java:80)
	at test.main(test.java:12)

As you see it has now gone six lines further. Therefore, IMHO, I believe that the solution
to such a problem would be to adopt the default behavior if an exception occurs... WDYT?

Also, spark, this is not a non-bug situation :), there is a bug for certain at line 1035.

Regards,
Senaka

> [classlib][text] unexpected MissingResourceException for new DecimalFormat("#######0.0000")
> -------------------------------------------------------------------------------------------
>
>                 Key: HARMONY-1187
>                 URL: https://issues.apache.org/jira/browse/HARMONY-1187
>             Project: Harmony
>          Issue Type: Bug
>          Components: Classlib
>            Reporter: Vladimir Ivanov
>
> The method java.text.DecimalFormat("#######0.0000") throws MissingResourceException on
Harmony and works fine on RI.
> ================== test.java ============================
> import java.net.*;
> import java.text.DecimalFormat;
> import java.io.IOException;
> public class test  {
>     public static void main(String[] args) {
>         URL.setURLStreamHandlerFactory(new URLStreamHandlerFactory() {
>             public URLStreamHandler createURLStreamHandler(String protocol) {
>                 return new MyURLStreamHandler();
>             }
>         });
>         System.out.println("res = " + new DecimalFormat("#######0.0000"));
>     }
> }
> class MyURLConnection extends URLConnection {
>     public MyURLConnection(URL u) {
>         super(u);
>     }
>     public void connect() {
>     }
> }
> class MyURLStreamHandler extends URLStreamHandler {
>     protected MyURLStreamHandler() {
>         super();
>     }
>     protected URLConnection openConnection(URL u) throws IOException {
>         return new MyURLConnection(u);
>     }
>     protected void parseURL(URL u, String spec, int start, int limit) {
>         super.parseURL(u, spec, start, limit);
>     }
>     protected void setURL(URL u, String protocol, String host, int port, String file,
String ref) {
>         super.setURL(u, protocol, host, port, file, ref);
>     }
>     protected void setURL(URL u, String protocol, String host, int port, String authority,
String userInfo, String path, String query, String ref) {
>         super.setURL(u, protocol, host, port, authority, userInfo, path, query, ref);
>     }
> }
> =====================================================
> Output:
> C:\tmp\tmp17>C:\jrockit-jdk1.5.0-windows-ia32\bin\java.exe -cp . -showversion test

> java version "1.5.0"
> Java(TM) 2 Runtime Environment, Standard Edition (build 1.5.0-b64)
> BEA WebLogic JRockit(R) (build dra-38972-20041208-2001-win-ia32, R25.0.0-75, GC: System
optimized over throughput (initial strategy singleparpar))
> res = java.text.DecimalFormat@674dc
> C:\tmp\tmp17>C:\harmony\classlib1.5\deploy\jdk\jre\bin\java.exe -cp . -showversion
test 
> java version 1.5 (subset)
> (c) Copyright 1991, 2006 The Apache Software Foundation or its licensors, as applicable.
> Exception in thread "main" java.util.MissingResourceException: Could not find the bundle
com/ibm/icu/impl/data/icudt34b/en_US
> 	at com.ibm.icu.impl.ResourceBundleWrapper.getBundleInstance(ResourceBundleWrapper.java:17)
> 	at com.ibm.icu.util.UResourceBundle.instantiateBundle(UResourceBundle.java:511)
> 	at com.ibm.icu.util.UResourceBundle.getBundleInstance(UResourceBundle.java:127)
> 	at com.ibm.icu.util.UResourceBundle.getBundleInstance(UResourceBundle.java:18)
> 	at com.ibm.icu.util.UResourceBundle.getBundleInstance(UResourceBundle.java:195)
> 	at com.ibm.icu.text.DecimalFormatSymbols.initialize(DecimalFormatSymbols.java:555)
> 	at com.ibm.icu.text.DecimalFormatSymbols.<init>(DecimalFormatSymbols.java:58)
> 	at java.text.DecimalFormat.<init>(DecimalFormat.java:88)
> 	at java.text.DecimalFormat.<init>(DecimalFormat.java:70)
> 	at test.main(test.java:12)
> C:\tmp\tmp17>C:\harmony\drlvm1.5\build\win_ia32_msvc_debug\deploy\jre\bin\java -Dvm.assert_dialog=false
-cp . -showversion test 
> java version "1.5.0" 
> pre-alpha : not complete or compatible
> svn = r431487, (Aug 15 2006), Windows/ia32/msvc 1310, debug build
> http://incubator.apache.org/harmony
> java.lang.ClassCastException
> 	at java.net.URLClassLoader.findResourceImpl(URLClassLoader.java:708)
> 	at java.net.URLClassLoader$5.run(URLClassLoader.java:665)
> 	at java.net.URLClassLoader$5.run(URLClassLoader.java:664)
> 	at java.security.AccessController.doPrivilegedImpl()
> 	at java.security.AccessController.doPrivileged()
> 	at java.net.URLClassLoader.findResource(URLClassLoader.java:663)
> 	at java.lang.ClassLoader$BootstrapLoader.findResource()
> 	at java.lang.ClassLoader.getResource()
> 	at java.lang.ClassLoader.getResourceAsStream()
> 	at java.lang.ClassLoader.getSystemResourceAsStream()
> 	at java.util.ResourceBundle$1.run(ResourceBundle.java:277)
> 	at java.util.ResourceBundle$1.run(ResourceBundle.java:276)
> 	at java.security.AccessController.doPrivilegedImpl()
> 	at java.security.AccessController.doPrivileged()
> 	at java.util.ResourceBundle.handleGetBundle(ResourceBundle.java:275)
> 	at java.util.ResourceBundle.getBundleImpl(ResourceBundle.java:158)
> 	at java.util.ResourceBundle.getBundle(ResourceBundle.java:100)
> 	at java.util.Locale$3.run(Locale.java:732)
> 	at java.util.Locale$3.run(Locale.java:731)
> 	at java.security.AccessController.doPrivilegedImpl()
> 	at java.security.AccessController.doPrivileged()
> 	at java.util.Locale.getBundle(Locale.java:730)
> 	at java.util.Currency.getInstance(Currency.java:95)
> 	at java.text.DecimalFormatSymbols.<init>(DecimalFormatSymbols.java:72)
> 	at java.text.DecimalFormatSymbols.<init>(DecimalFormatSymbols.java:55)
> 	at java.text.DecimalFormat.<init>(DecimalFormat.java:70)
> 	at test.main(test.java:12)
> C:\tmp\tmp17>C:\harmony\drlvm1.5\build\win_ia32_msvc_release\deploy\jre\bin\java -Dvm.assert_dialog=false
-cp . -showversion test 
> java version "1.5.0" 
> pre-alpha : not complete or compatible
> svn = r431487, (Aug 15 2006), Windows/ia32/msvc 1310, release build
> http://incubator.apache.org/harmony
> java.lang.ClassCastException
> 	at java.net.URLClassLoader.findResourceImpl(URLClassLoader.java:708)
> 	at java.net.URLClassLoader$5.run(URLClassLoader.java:665)
> 	at java.net.URLClassLoader$5.run(URLClassLoader.java:664)
> 	at java.security.AccessController.doPrivilegedImpl()
> 	at java.security.AccessController.doPrivileged()
> 	at java.net.URLClassLoader.findResource(URLClassLoader.java:663)
> 	at java.lang.ClassLoader$BootstrapLoader.findResource()
> 	at java.lang.ClassLoader.getResource()
> 	at java.lang.ClassLoader.getResourceAsStream()
> 	at java.lang.ClassLoader.getSystemResourceAsStream()
> 	at java.util.ResourceBundle$1.run(ResourceBundle.java:277)
> 	at java.util.ResourceBundle$1.run(ResourceBundle.java:276)
> 	at java.security.AccessController.doPrivilegedImpl()
> 	at java.security.AccessController.doPrivileged()
> 	at java.util.ResourceBundle.handleGetBundle(ResourceBundle.java:275)
> 	at java.util.ResourceBundle.getBundleImpl(ResourceBundle.java:158)
> 	at java.util.ResourceBundle.getBundle(ResourceBundle.java:100)
> 	at java.util.Locale$3.run(Locale.java:732)
> 	at java.util.Locale$3.run(Locale.java:731)
> 	at java.security.AccessController.doPrivilegedImpl()
> 	at java.security.AccessController.doPrivileged()
> 	at java.util.Locale.getBundle(Locale.java:730)
> 	at java.util.Currency.getInstance(Currency.java:95)
> 	at java.text.DecimalFormatSymbols.<init>(DecimalFormatSymbols.java:72)
> 	at java.text.DecimalFormatSymbols.<init>(DecimalFormatSymbols.java:55)
> 	at java.text.DecimalFormat.<init>(DecimalFormat.java:70)
> 	at test.main(test.java:12)

-- 
This message is automatically generated by JIRA.
-
You can reply to this email to add a comment to the issue online.


Mime
View raw message