public inbox for java-prs@sourceware.org
help / color / mirror / Atom feed
* [Bug java/25389]  New: File(new URI("file:./")) -> java.lang.NullPointerException
@ 2005-12-13 11:20 caolanm at redhat dot com
  2005-12-13 11:46 ` [Bug java/25389] " mark at gcc dot gnu dot org
                   ` (10 more replies)
  0 siblings, 11 replies; 12+ messages in thread
From: caolanm at redhat dot com @ 2005-12-13 11:20 UTC (permalink / raw)
  To: java-prs

A regression in 4.1.0 which is not in 4.0.2, brings OOo java component
registration to its knees. Sample source inline

import java.net.URI;
import java.io.File;

class myfirstprog
{
        public static void main(String args[])
        {
           URI uriObject = null;
           try {
               uriObject = new URI("file:./");
           }
           catch (Exception e) {
           }
           System.err.println("urlObject is " + uriObject);
           File uriFile = null;
           uriFile = new File(uriObject);
           System.err.println("uriFile is " + uriFile);
        }

}

output from 4.1.0 is...
urlObject is file:./
Exception in thread "main" java.lang.NullPointerException
   <<No stacktrace available>>

output from 4.2.0 was...
urlObject is file:./
uriFile is .


-- 
           Summary: File(new URI("file:./")) ->
                    java.lang.NullPointerException
           Product: gcc
           Version: 4.1.0
            Status: UNCONFIRMED
          Severity: normal
          Priority: P3
         Component: java
        AssignedTo: unassigned at gcc dot gnu dot org
        ReportedBy: caolanm at redhat dot com


http://gcc.gnu.org/bugzilla/show_bug.cgi?id=25389


^ permalink raw reply	[flat|nested] 12+ messages in thread

* [Bug java/25389] File(new URI("file:./")) -> java.lang.NullPointerException
  2005-12-13 11:20 [Bug java/25389] New: File(new URI("file:./")) -> java.lang.NullPointerException caolanm at redhat dot com
@ 2005-12-13 11:46 ` mark at gcc dot gnu dot org
  2005-12-13 13:47 ` [Bug classpath/25389] " mark at gcc dot gnu dot org
                   ` (9 subsequent siblings)
  10 siblings, 0 replies; 12+ messages in thread
From: mark at gcc dot gnu dot org @ 2005-12-13 11:46 UTC (permalink / raw)
  To: java-prs



------- Comment #1 from mark at gcc dot gnu dot org  2005-12-13 11:46 -------
Confirmed. URI.getPath() may return null and we don't check for that in the
File(URI) constructor. A simple fix might be:

diff -u -r1.59 File.java
--- java/io/File.java   6 Nov 2005 20:28:00 -0000       1.59
+++ java/io/File.java   13 Dec 2005 11:37:26 -0000
@@ -406,7 +406,11 @@
     if (!uri.getScheme().equals("file"))
        throw new IllegalArgumentException("invalid uri protocol");

-    path = normalizePath(uri.getPath());
+    String name = uri.getPath();
+    if (name == null)
+      name = "";
+    
+    path = normalizePath(name);
   }

   /**


Note that java/io/File.java is not fully merged between classpath and libgcj.


-- 

mark at gcc dot gnu dot org changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
             Status|UNCONFIRMED                 |NEW
     Ever Confirmed|0                           |1
   Last reconfirmed|0000-00-00 00:00:00         |2005-12-13 11:46:25
               date|                            |


http://gcc.gnu.org/bugzilla/show_bug.cgi?id=25389


^ permalink raw reply	[flat|nested] 12+ messages in thread

* [Bug classpath/25389] File(new URI("file:./")) -> java.lang.NullPointerException
  2005-12-13 11:20 [Bug java/25389] New: File(new URI("file:./")) -> java.lang.NullPointerException caolanm at redhat dot com
  2005-12-13 11:46 ` [Bug java/25389] " mark at gcc dot gnu dot org
@ 2005-12-13 13:47 ` mark at gcc dot gnu dot org
  2005-12-13 20:07 ` tromey at gcc dot gnu dot org
                   ` (8 subsequent siblings)
  10 siblings, 0 replies; 12+ messages in thread
From: mark at gcc dot gnu dot org @ 2005-12-13 13:47 UTC (permalink / raw)
  To: java-prs



------- Comment #2 from mark at gcc dot gnu dot org  2005-12-13 13:47 -------
Added a test to mauve that exposes this bug:
gnu/testlet/java/io/File/newFileURI.java


-- 

mark at gcc dot gnu dot org changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
          Component|java                        |classpath
            Product|gcc                         |classpath
            Version|4.1.0                       |0.20


http://gcc.gnu.org/bugzilla/show_bug.cgi?id=25389


^ permalink raw reply	[flat|nested] 12+ messages in thread

* [Bug classpath/25389] File(new URI("file:./")) -> java.lang.NullPointerException
  2005-12-13 11:20 [Bug java/25389] New: File(new URI("file:./")) -> java.lang.NullPointerException caolanm at redhat dot com
  2005-12-13 11:46 ` [Bug java/25389] " mark at gcc dot gnu dot org
  2005-12-13 13:47 ` [Bug classpath/25389] " mark at gcc dot gnu dot org
@ 2005-12-13 20:07 ` tromey at gcc dot gnu dot org
  2005-12-13 22:01 ` mark at gcc dot gnu dot org
                   ` (7 subsequent siblings)
  10 siblings, 0 replies; 12+ messages in thread
From: tromey at gcc dot gnu dot org @ 2005-12-13 20:07 UTC (permalink / raw)
  To: java-prs



------- Comment #3 from tromey at gcc dot gnu dot org  2005-12-13 20:07 -------
with the JDK I get this output:

opsy. java myfirstprog
urlObject is file:./
Exception in thread "main" java.lang.IllegalArgumentException: URI is not
hierarchical
        at java.io.File.<init>(File.java:344)
        at myfirstprog.main(myfirstprog.java:16)


Strange.


-- 

tromey at gcc dot gnu dot org changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
                 CC|                            |tromey at gcc dot gnu dot
                   |                            |org


http://gcc.gnu.org/bugzilla/show_bug.cgi?id=25389


^ permalink raw reply	[flat|nested] 12+ messages in thread

* [Bug classpath/25389] File(new URI("file:./")) -> java.lang.NullPointerException
  2005-12-13 11:20 [Bug java/25389] New: File(new URI("file:./")) -> java.lang.NullPointerException caolanm at redhat dot com
                   ` (2 preceding siblings ...)
  2005-12-13 20:07 ` tromey at gcc dot gnu dot org
@ 2005-12-13 22:01 ` mark at gcc dot gnu dot org
  2005-12-14  0:51 ` tromey at gcc dot gnu dot org
                   ` (6 subsequent siblings)
  10 siblings, 0 replies; 12+ messages in thread
From: mark at gcc dot gnu dot org @ 2005-12-13 22:01 UTC (permalink / raw)
  To: java-prs



------- Comment #4 from mark at gcc dot gnu dot org  2005-12-13 22:01 -------
(In reply to comment #3)
> Exception in thread "main" java.lang.IllegalArgumentException: URI is not
> hierarchical
>         at java.io.File.<init>(File.java:344)
>         at myfirstprog.main(myfirstprog.java:16)

Interesting. That is a bit lame. But seems legal since the uri scheme isn't
followed by a double slash so it is indeed not hierarchical.

But since we are constructing such URLs/URIs ourselves (for example in the
SystemClassLoader) through new URL("file", "", -1, "./") it seems wise to
handle them explicitly in the File(URI) constructor.


-- 


http://gcc.gnu.org/bugzilla/show_bug.cgi?id=25389


^ permalink raw reply	[flat|nested] 12+ messages in thread

* [Bug classpath/25389] File(new URI("file:./")) -> java.lang.NullPointerException
  2005-12-13 11:20 [Bug java/25389] New: File(new URI("file:./")) -> java.lang.NullPointerException caolanm at redhat dot com
                   ` (4 preceding siblings ...)
  2005-12-14  0:51 ` tromey at gcc dot gnu dot org
@ 2005-12-14  0:51 ` tromey at gcc dot gnu dot org
  2005-12-14  8:35 ` caolanm at redhat dot com
                   ` (4 subsequent siblings)
  10 siblings, 0 replies; 12+ messages in thread
From: tromey at gcc dot gnu dot org @ 2005-12-14  0:51 UTC (permalink / raw)
  To: java-prs



------- Comment #5 from tromey at gcc dot gnu dot org  2005-12-14 00:51 -------
URLs are handled differently.
If you do new File("./").toURI() you will get a URI
with the absolute path name in it -- i.e., a
hierarchical one.  The same happens for
new File("./").toURL().toURI()

Caolan -- if we changed this to throw an IllegalArgumentException,
would that help?  I'm wondering how this code can work in OO.o.
Another way it could work is if there is variance between JDK versions
and you've only happened to try ones where it works somehow.


-- 


http://gcc.gnu.org/bugzilla/show_bug.cgi?id=25389


^ permalink raw reply	[flat|nested] 12+ messages in thread

* [Bug classpath/25389] File(new URI("file:./")) -> java.lang.NullPointerException
  2005-12-13 11:20 [Bug java/25389] New: File(new URI("file:./")) -> java.lang.NullPointerException caolanm at redhat dot com
                   ` (3 preceding siblings ...)
  2005-12-13 22:01 ` mark at gcc dot gnu dot org
@ 2005-12-14  0:51 ` tromey at gcc dot gnu dot org
  2005-12-14  0:51 ` tromey at gcc dot gnu dot org
                   ` (5 subsequent siblings)
  10 siblings, 0 replies; 12+ messages in thread
From: tromey at gcc dot gnu dot org @ 2005-12-14  0:51 UTC (permalink / raw)
  To: java-prs



------- Comment #6 from tromey at gcc dot gnu dot org  2005-12-14 00:51 -------
I'm handling this.


-- 

tromey at gcc dot gnu dot org changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
         AssignedTo|unassigned at gcc dot gnu   |tromey at gcc dot gnu dot
                   |dot org                     |org
             Status|NEW                         |ASSIGNED
   Last reconfirmed|2005-12-13 11:46:25         |2005-12-14 00:51:32
               date|                            |


http://gcc.gnu.org/bugzilla/show_bug.cgi?id=25389


^ permalink raw reply	[flat|nested] 12+ messages in thread

* [Bug classpath/25389] File(new URI("file:./")) -> java.lang.NullPointerException
  2005-12-13 11:20 [Bug java/25389] New: File(new URI("file:./")) -> java.lang.NullPointerException caolanm at redhat dot com
                   ` (5 preceding siblings ...)
  2005-12-14  0:51 ` tromey at gcc dot gnu dot org
@ 2005-12-14  8:35 ` caolanm at redhat dot com
  2005-12-14 18:35 ` tromey at gcc dot gnu dot org
                   ` (3 subsequent siblings)
  10 siblings, 0 replies; 12+ messages in thread
From: caolanm at redhat dot com @ 2005-12-14  8:35 UTC (permalink / raw)
  To: java-prs



------- Comment #7 from caolanm at redhat dot com  2005-12-14 08:35 -------
Throwing IllegalArgumentException should be fine. 


-- 


http://gcc.gnu.org/bugzilla/show_bug.cgi?id=25389


^ permalink raw reply	[flat|nested] 12+ messages in thread

* [Bug classpath/25389] File(new URI("file:./")) -> java.lang.NullPointerException
  2005-12-13 11:20 [Bug java/25389] New: File(new URI("file:./")) -> java.lang.NullPointerException caolanm at redhat dot com
                   ` (6 preceding siblings ...)
  2005-12-14  8:35 ` caolanm at redhat dot com
@ 2005-12-14 18:35 ` tromey at gcc dot gnu dot org
  2005-12-14 18:37 ` tromey at gcc dot gnu dot org
                   ` (2 subsequent siblings)
  10 siblings, 0 replies; 12+ messages in thread
From: tromey at gcc dot gnu dot org @ 2005-12-14 18:35 UTC (permalink / raw)
  To: java-prs



------- Comment #8 from tromey at gcc dot gnu dot org  2005-12-14 18:35 -------
Subject: Bug 25389

Author: tromey
Date: Wed Dec 14 18:35:37 2005
New Revision: 108527

URL: http://gcc.gnu.org/viewcvs?root=gcc&view=rev&rev=108527
Log:
        PR classpath/25389:
        * java/io/File.java (File): Throw IllegalArgumentException if URI is
        non-hierarchical.

Modified:
    branches/gcc-4_1-branch/libjava/ChangeLog
    branches/gcc-4_1-branch/libjava/java/io/File.java


-- 


http://gcc.gnu.org/bugzilla/show_bug.cgi?id=25389


^ permalink raw reply	[flat|nested] 12+ messages in thread

* [Bug classpath/25389] File(new URI("file:./")) -> java.lang.NullPointerException
  2005-12-13 11:20 [Bug java/25389] New: File(new URI("file:./")) -> java.lang.NullPointerException caolanm at redhat dot com
                   ` (8 preceding siblings ...)
  2005-12-14 18:37 ` tromey at gcc dot gnu dot org
@ 2005-12-14 18:37 ` tromey at gcc dot gnu dot org
  2005-12-14 21:28 ` cvs-commit at developer dot classpath dot org
  10 siblings, 0 replies; 12+ messages in thread
From: tromey at gcc dot gnu dot org @ 2005-12-14 18:37 UTC (permalink / raw)
  To: java-prs



------- Comment #10 from tromey at gcc dot gnu dot org  2005-12-14 18:37 -------
Fix in gcc 4.1, gcc trunk, and classpath cvs head.


-- 

tromey at gcc dot gnu dot org changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
             Status|ASSIGNED                    |RESOLVED
         Resolution|                            |FIXED
   Target Milestone|---                         |0.20


http://gcc.gnu.org/bugzilla/show_bug.cgi?id=25389


^ permalink raw reply	[flat|nested] 12+ messages in thread

* [Bug classpath/25389] File(new URI("file:./")) -> java.lang.NullPointerException
  2005-12-13 11:20 [Bug java/25389] New: File(new URI("file:./")) -> java.lang.NullPointerException caolanm at redhat dot com
                   ` (7 preceding siblings ...)
  2005-12-14 18:35 ` tromey at gcc dot gnu dot org
@ 2005-12-14 18:37 ` tromey at gcc dot gnu dot org
  2005-12-14 18:37 ` tromey at gcc dot gnu dot org
  2005-12-14 21:28 ` cvs-commit at developer dot classpath dot org
  10 siblings, 0 replies; 12+ messages in thread
From: tromey at gcc dot gnu dot org @ 2005-12-14 18:37 UTC (permalink / raw)
  To: java-prs



------- Comment #9 from tromey at gcc dot gnu dot org  2005-12-14 18:36 -------
Subject: Bug 25389

Author: tromey
Date: Wed Dec 14 18:36:55 2005
New Revision: 108528

URL: http://gcc.gnu.org/viewcvs?root=gcc&view=rev&rev=108528
Log:
        PR classpath/25389:
        * java/io/File.java (File): Throw IllegalArgumentException if URI is
        non-hierarchical.

Modified:
    trunk/libjava/ChangeLog
    trunk/libjava/java/io/File.java


-- 


http://gcc.gnu.org/bugzilla/show_bug.cgi?id=25389


^ permalink raw reply	[flat|nested] 12+ messages in thread

* [Bug classpath/25389] File(new URI("file:./")) -> java.lang.NullPointerException
  2005-12-13 11:20 [Bug java/25389] New: File(new URI("file:./")) -> java.lang.NullPointerException caolanm at redhat dot com
                   ` (9 preceding siblings ...)
  2005-12-14 18:37 ` tromey at gcc dot gnu dot org
@ 2005-12-14 21:28 ` cvs-commit at developer dot classpath dot org
  10 siblings, 0 replies; 12+ messages in thread
From: cvs-commit at developer dot classpath dot org @ 2005-12-14 21:28 UTC (permalink / raw)
  To: java-prs



------- Comment #11 from cvs-commit at developer dot classpath dot org  2005-12-14 21:28 -------
Subject: Bug 25389

CVSROOT:        /cvsroot/classpath
Module name:    classpath
Branch:         
Changes by:     Tom Tromey <tromey@savannah.gnu.org>    05/12/14 17:32:35

Modified files:
        java/io        : File.java 
        .              : ChangeLog 

Log message:
        PR classpath/25389:
        * java/io/File.java (File): Throw IllegalArgumentException if URI is
        non-hierarchical.

CVSWeb URLs:
http://cvs.savannah.gnu.org/viewcvs/classpath/classpath/java/io/File.java.diff?tr1=1.59&tr2=1.60&r1=text&r2=text
http://cvs.savannah.gnu.org/viewcvs/classpath/classpath/ChangeLog.diff?tr1=1.5810&tr2=1.5811&r1=text&r2=text


-- 


http://gcc.gnu.org/bugzilla/show_bug.cgi?id=25389


^ permalink raw reply	[flat|nested] 12+ messages in thread

end of thread, other threads:[~2005-12-14 21:28 UTC | newest]

Thread overview: 12+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2005-12-13 11:20 [Bug java/25389] New: File(new URI("file:./")) -> java.lang.NullPointerException caolanm at redhat dot com
2005-12-13 11:46 ` [Bug java/25389] " mark at gcc dot gnu dot org
2005-12-13 13:47 ` [Bug classpath/25389] " mark at gcc dot gnu dot org
2005-12-13 20:07 ` tromey at gcc dot gnu dot org
2005-12-13 22:01 ` mark at gcc dot gnu dot org
2005-12-14  0:51 ` tromey at gcc dot gnu dot org
2005-12-14  0:51 ` tromey at gcc dot gnu dot org
2005-12-14  8:35 ` caolanm at redhat dot com
2005-12-14 18:35 ` tromey at gcc dot gnu dot org
2005-12-14 18:37 ` tromey at gcc dot gnu dot org
2005-12-14 18:37 ` tromey at gcc dot gnu dot org
2005-12-14 21:28 ` cvs-commit at developer dot classpath dot org

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).