harmony-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Sergey Soldatov" <sergey.solda...@gmail.com>
Subject Re: java.lang.String.replaceFirst from IBM VM throws NPE
Date Wed, 22 Feb 2006 11:55:05 GMT
Ah. My fault. Forgot that they're now using regex patterns as the
parameters.

On 2/22/06, Oliver Deakin <oliver.deakin@googlemail.com> wrote:
>
> Sergey Soldatov wrote:
> > But the way, how it affects the performance? java.lang.String is the
> most
> > used class and even such simple operations will cause loading of full
> regex
> > package.
> >
>
> Do you have another solution in mind that would avoid the regex package
> load?
>
> > On 2/21/06, Oliver Deakin <oliver.deakin@googlemail.com> wrote:
> >
> >> Hi Alexey,
> >>
> >>  Looking in there (these calls can also be seen if
> >> the test is run within a debugger), we see that the
> replaceFirst(String,
> >> String) implementation is:
> >>
> >> public String replaceFirst(String expr, String substitute) {
> >>    return Pattern.compile(expr).matcher(this).replaceFirst(substitute);
> >> }
> >>
> >> Unfortunately the implementation of Pattern at
> >> modules/regex/src/main/java/java/util/regex/Pattern.java is only a stub
> >> (as HARMONY-39 has not yet been accepted into the Harmony SVN
> >> repository) and as such just returns null. Thus when we try to
> >> dereference the return from Pattern.compile(expr) we receive a
> >> NullPointerException. Once the regex in HARMONY-39 is moved into SVN
> >> this should go away.
> >>
> >>
> >> As a sideline, I think we should be able to move String.java out of
> >> kernel entirely anyway. We already have an implementation at
> >> modules/kernel/src/main/java/java/lang/String.java, and the only VM
> >> specific code in String is the intern() method. This method could
> simply
> >> be redirected to call VM.intern(String), a class which is within
> kernel,
> >> and then String.java can be moved into LUNI. It also means that the VM
> >> writer(s) need not implement the rest of the String class
> unnecessarily.
> >> Sound good?
> >>
> >>
> >> Alexey Petrenko wrote:
> >>
> >>> We got problem with Harmony on IBM VM on Windows.
> >>> java.lang.String.replaceFirst throws NPE.
> >>>
> >>> Here is the testcase:
> >>> public class Test {
> >>>     public static void main(String args[]) {
> >>>         String xx = "test";
> >>>         xx = xx.replaceFirst("t","z");
> >>>     }
> >>> }
> >>>
> >>> Here is the stack trace:
> >>> C:\Work\Harmony\Sources\Harmony\deploy\jre\bin>java Test
> >>> Exception in thread "main" java.lang.NullPointerException
> >>>         at java.lang.String.replaceFirst(String.java:1642)
> >>>         at Test.main(Test.java:4)
> >>>
> >>> Since IBM VM is not an OpenSource I can not check java.lang.String for
> >>> the cause of this problem :(
> >>>
> >>> Can we ask IBM guys somehow to fix this issue?
> >>>
> >>> --
> >>> Alexey A. Petrenko
> >>> Intel Middleware Products Division
> >>>
> >>>
> >> --
> >> Oliver Deakin
> >> IBM United Kingdom Limited
> >>
> >>
> >>
> >
> >
> > --
> > Sergey Soldatov
> > Intel Middleware Products Division
> >
> >
>
> --
> Oliver Deakin
> IBM United Kingdom Limited
>
>


--
Sergey Soldatov
Intel Middleware Products Division

Mime
  • Unnamed multipart/alternative (inline, None, 0 bytes)
View raw message