diff -r d891aa9e1b74 -r ae7be7852a99 jdk/src/share/classes/java/nio/charset/Charset-X-Coder.java.template --- a/jdk/src/share/classes/java/nio/charset/Charset-X-Coder.java.template Tue May 28 16:35:17 2013 +0100 +++ b/jdk/src/share/classes/java/nio/charset/Charset-X-Coder.java.template Tue May 28 10:42:52 2013 -0700 @@ -34,6 +34,7 @@ import java.nio.BufferUnderflowException; import java.lang.ref.WeakReference; import java.nio.charset.CoderMalfunctionError; // javadoc +import java.util.Arrays; /** @@ -244,7 +245,12 @@ * which is never null and is never empty */ public final $replType$ replacement() { +#if[decoder] return replacement; +#end[decoder] +#if[encoder] + return Arrays.copyOf(replacement, replacement.$replLength$); +#end[encoder] } /** @@ -280,12 +286,15 @@ throw new IllegalArgumentException("Empty replacement"); if (len > max$ItypesPerOtype$) throw new IllegalArgumentException("Replacement too long"); +#if[decoder] + this.replacement = newReplacement; +#end[decoder] #if[encoder] if (!isLegalReplacement(newReplacement)) throw new IllegalArgumentException("Illegal replacement"); + this.replacement = Arrays.copyOf(newReplacement, newReplacement.$replLength$); #end[encoder] - this.replacement = newReplacement; - implReplaceWith(newReplacement); + implReplaceWith(this.replacement); return this; }