Oliver Deakin wrote:
Hi Alexey,

ok, Ive recreated your problem using the latest snapshot and VME. Essentially the code at modules/kernel/src/main/java/java/lang/String.java is the same as that in the VME kernel.jar. 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?

Why wasn't it that way to start?

geir



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

Reply via email to