History | Log In     View a printable version of the current page.  
Issue Details (XML | Word | Printable)

Key: GROOVY-975
Type: New Feature New Feature
Status: Closed Closed
Resolution: Fixed
Priority: Minor Minor
Assignee: Paul King
Reporter: Russel Winder
Votes: 0
Watchers: 0
Operations

If you were logged in you would be able to see more operations.
groovy

Provide size() on StringBuilder

Created: 20/Jul/05 05:00 AM   Updated: 08/Feb/08 01:26 AM
Component/s: None
Affects Version/s: None
Fix Version/s: 1.5.2

Time Tracking:
Not Specified


 Description  « Hide
GROOVY-920 resulted in size() being implemented for StringBuffer. size() should also be implemented for StringBuilder on JDK1.5+ platforms.

 All   Comments   Work Log   Change History      Sort Order: Ascending order - Click to sort in descending order
Antti Karanta - 24/Aug/06 12:06 AM
Similarly, leftShift should be added to StringBuilder. Now it is possible to do this w/ StringBuffer:
sb << "foo"
but not w/ StringBuilder.

Jochen Theodorou - 28/Aug/06 11:28 AM
the problem is that StringBuilder is not available on 1.4. As long as we want to be compatible with 1.4 we have to be carefull about using classes of 1.5 or later. Even if we are plitting DefaultGroovyMethods in methods for 1.5 and ones for 1.4, we still have the problem, that this would not compile on 1.4 then. We need to find a suitable mechanism for that first. Any suggestions are welcome

Russel Winder - 30/Aug/06 12:55 AM
The difficulty here is that not supporting classes such as StringBuilder in JDK 1.5 labels Groovy as a legacy product. People who use JDK 1.5 know that StrigBuilder is for normal use and StringBuffer is used only in multithreaded shared object cases because of the high overhead of synchronization.

The upshot of this is that we need a JDK 1.5 version of Groovy and a JDK 1.4 version of Groovy. Given the amount of String handling in Groovy, using StringBuilder rather than StringBuffer in Groovy would likely make things faster as well. But this is a guess.

In effect we need conditional compilation in Java as is available in C and C++ – this avoids the run-time overhead of making decisions at run time. Using CPP itself is probably not a good move. I don't know if Maven 2 supports this sort of compilation activity.


Paul King - 09/Jan/08 05:30 AM
Added in the new PluginDGM for Java 5+

Paul King - 08/Feb/08 01:26 AM
close off release 1.5.4