JDK-6840246 : Lightweight implementation of String.split for simple use case
  • Type: Enhancement
  • Component: core-libs
  • Sub-Component: java.lang
  • Affected Version: 7
  • Priority: P3
  • Status: Resolved
  • Resolution: Fixed
  • OS: generic
  • CPU: generic
  • Submitted: 2009-05-12
  • Updated: 2010-04-02
  • Resolved: 2009-08-28
The Version table provides details related to the release that this issue/RFE will be addressed.

Unresolved : Release in which this issue/RFE will be addressed.
Resolved: Release in which this issue/RFE has been resolved.
Fixed : Release in which this issue/RFE has been fixed. The release containing this fix may be available for download as an Early Access Release or a General Availability Release.

To download the current JDK release, click here.
JDK 7
7 b71Fixed
Description
String.split(regex, limit) uses regex as the implementation and returns java.util.regex.Pattern.compile(regex).split(this, limit).

A simple use of String.split (e.g. the regex is just one character-delimiter) will need to initialize the regex engine and load many regex classes that is pretty heavy-weight.

Most of the String.split calls from the JRE implementation are the simple case e.g. regex parameter is "=", ":", ",", "\0", "\\|"

We can implement a lightweight version of String.split for these simple regex to avoid loading the regex engine.  Alternatively, if feasible, implement a lightweight version of the regex support so that String.replaceAll, String.replaceFirst, String.replace(CharSequence, CharSequence), and String.matches can take advantage of such optimization.

Comments
EVALUATION yes
13-08-2009