Re: java.lang.String.replaceFirst from IBM VM throws NPE

2006-02-23 Thread Tim Ellison
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 ([EMAIL PROTECTED])
IBM Java technology centre, UK.


Re: java.lang.String.replaceFirst from IBM VM throws NPE

2006-02-22 Thread Oliver Deakin

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 [EMAIL PROTECTED] 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\binjava 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



Re: java.lang.String.replaceFirst from IBM VM throws NPE

2006-02-22 Thread Sergey Soldatov
Ah. My fault. Forgot that they're now using regex patterns as the
parameters.

On 2/22/06, Oliver Deakin [EMAIL PROTECTED] 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 [EMAIL PROTECTED] 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\binjava 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


java.lang.String.replaceFirst from IBM VM throws NPE

2006-02-21 Thread Alexey Petrenko
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\binjava 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


Re: java.lang.String.replaceFirst from IBM VM throws NPE

2006-02-21 Thread Oliver Deakin

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?



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\binjava 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



Re: java.lang.String.replaceFirst from IBM VM throws NPE

2006-02-21 Thread Alexey Petrenko
2006/2/21, Oliver Deakin [EMAIL PROTECTED]:
 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?
Yes, it will be great!

Thanks.

--
Alexey A. Petrenko
Intel Middleware Products Division


Re: java.lang.String.replaceFirst from IBM VM throws NPE

2006-02-21 Thread Geir Magnusson Jr



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\binjava 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