harmony-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Tim Ellison <t.p.elli...@gmail.com>
Subject Re: java.lang.String.replaceFirst from IBM VM throws NPE
Date Thu, 23 Feb 2006 12:59:26 GMT
Geir Magnusson Jr wrote:
> 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?

String is somewhat special, and to be honest there is a good argument
for it being left in Kernel too.

To get good performance, the VM and JIT will have knowledge of the
layout of fundamental types like String.  If we leave String in Kernel
then each VM/JIT can 'control' the layout of String objects, but they
must also replicate the behavior of the String methods.

Given that there is a bunch of behavior on the String class, and that
there are internal dependencies between String and types like
StringBuffer, then for me the balance tips in favor of that being shared
code in LUNI.

Having String in LUNI does not prevent any particular VM having its own
implementation in Kernel, if it chooses to maintain it in sync and deal
with any internal dependencies that Harmony creates.

I'll be watching String very closely.  Class shape and initialization
dependencies are areas that will require a special 'golden ticket' to
modify.

Regards,
Tim

-- 

Tim Ellison (t.p.ellison@gmail.com)
IBM Java technology centre, UK.

Mime
View raw message