diff --git a/test/jdk/java/nio/charset/Charset/AliasesCopy.java b/test/jdk/java/nio/charset/Charset/AliasesCopy.java index 1e7607b61230e..66ee830c5f6ff 100644 --- a/test/jdk/java/nio/charset/Charset/AliasesCopy.java +++ b/test/jdk/java/nio/charset/Charset/AliasesCopy.java @@ -33,27 +33,22 @@ import java.util.Set; import org.junit.jupiter.api.Test; - import static org.junit.jupiter.api.Assertions.assertIterableEquals; public class AliasesCopy { private static final Set ALIASES_SET = Set.of("foo-alias"); - private static final String[] MUTABLE_ALIASES = ALIASES_SET.toArray(String[]::new); + private static final String[] ALIASES_ARRAY = ALIASES_SET.toArray(String[]::new); @Test public void aliasesCopy() { - final FooCharset cs = new FooCharset(); - cs.changeAliasesAfterConstruction(); + final FooCharset cs = new FooCharset(ALIASES_ARRAY); + ALIASES_ARRAY[0] = "bar-alias"; assertIterableEquals(ALIASES_SET, cs.aliases()); } private static final class FooCharset extends Charset { - private FooCharset() { - super("foo", MUTABLE_ALIASES); - } - - private void changeAliasesAfterConstruction() { - MUTABLE_ALIASES[0] = "bar-alias"; + private FooCharset(String[] aliases) { + super("foo", aliases); } @Override