diff options
author | Andrew John Hughes <gnu_andrew@member.fsf.org> | 2008-03-17 00:14:33 +0000 |
---|---|---|
committer | Andrew John Hughes <gnu_andrew@member.fsf.org> | 2008-03-17 00:14:33 +0000 |
commit | de5e60dddb2e7298d7faa711e5d1a592d4d8de67 (patch) | |
tree | 114b5bc593b0d72183855b9a1a3ffbbfd08ff34e /gnu/java | |
parent | b2803df75b4687bc889f0ac81ab968f4434b990e (diff) | |
download | classpath-de5e60dddb2e7298d7faa711e5d1a592d4d8de67.tar.gz |
2008-03-17 Andrew John Hughes <gnu_andrew@member.fsf.org>
* gnu/java/lang/CPStringBuilder.java:
Replace reflection code with calls to
VMCPStringBuilder.
* vm/reference/gnu/java/lang/VMCPStringBuilder.java:
Default implementation of constructor call
using reflection.
Diffstat (limited to 'gnu/java')
-rw-r--r-- | gnu/java/lang/CPStringBuilder.java | 63 |
1 files changed, 2 insertions, 61 deletions
diff --git a/gnu/java/lang/CPStringBuilder.java b/gnu/java/lang/CPStringBuilder.java index 1d20308aa..64da224e2 100644 --- a/gnu/java/lang/CPStringBuilder.java +++ b/gnu/java/lang/CPStringBuilder.java @@ -38,9 +38,6 @@ exception statement from your version. */ package gnu.java.lang; -import java.lang.reflect.Constructor; -import java.lang.reflect.InvocationTargetException; - import java.io.Serializable; /** @@ -72,30 +69,10 @@ public final class CPStringBuilder char[] value; /** - * The package-private constructor for String objects without copying. - */ - private static final Constructor<String> cons; - - /** * The default capacity of a buffer. */ private static final int DEFAULT_CAPACITY = 16; - static - { - try - { - cons = String.class.getDeclaredConstructor(char[].class, Integer.TYPE, - Integer.TYPE, Boolean.TYPE); - cons.setAccessible(true); - } - catch (NoSuchMethodException e) - { - throw (Error) - new InternalError("Could not get no-copy String constructor").initCause(e); - } - } - /** * Create a new CPStringBuilder with default capacity 16. */ @@ -1102,25 +1079,7 @@ public final class CPStringBuilder throw new StringIndexOutOfBoundsException(); if (len == 0) return ""; - try - { - return cons.newInstance(value, beginIndex, len, true); - } - catch (InstantiationException e) - { - throw (Error) - new InternalError("Could not instantiate no-copy String constructor").initCause(e); - } - catch (IllegalAccessException e) - { - throw (Error) - new InternalError("Could not access no-copy String constructor").initCause(e); - } - catch (InvocationTargetException e) - { - throw (Error) - new InternalError("Error calling no-copy String constructor").initCause(e); - } + return VMCPStringBuilder.toString(value, beginIndex, len); } /** @@ -1133,25 +1092,7 @@ public final class CPStringBuilder */ public String toString() { - try - { - return cons.newInstance(value, 0, count, true); - } - catch (InstantiationException e) - { - throw (Error) - new InternalError("Could not instantiate no-copy String constructor").initCause(e); - } - catch (IllegalAccessException e) - { - throw (Error) - new InternalError("Could not access no-copy String constructor").initCause(e); - } - catch (InvocationTargetException e) - { - throw (Error) - new InternalError("Error calling no-copy String constructor").initCause(e); - } + return VMCPStringBuilder.toString(value, 0, count); } } |