--- a/anonk.patch Sat Aug 16 00:27:35 2008 -0700
+++ b/anonk.patch Tue Aug 26 02:42:41 2008 -0700
@@ -677,7 +677,7 @@ new file mode 100644
new file mode 100644
--- /dev/null
+++ b/src/share/classes/java/dyn/ConstantPoolPatch.java
-@@ -0,0 +1,395 @@
+@@ -0,0 +1,453 @@
+/*
+ * Copyright 2008 Sun Microsystems, Inc. All Rights Reserved.
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
@@ -708,6 +708,7 @@ new file mode 100644
+import java.io.IOException;
+import java.io.OutputStream;
+import java.util.Arrays;
++import java.util.HashSet;
+import java.util.IdentityHashMap;
+import java.util.Map;
+
@@ -733,6 +734,29 @@ new file mode 100644
+ this.patchArray = new Object[outer.getLength()];
+ }
+
++ /** Create a {@link ConstantPoolParser} and
++ * a {@link ConstantPoolPatch} in one step.
++ * Equivalent to {@code new ConstantPoolParser(classFile).createPatch()}.
++ *
++ * @param classFile an array of bytes containing a class.
++ * @see #ConstantPoolParser(Class)
++ */
++ public ConstantPoolPatch(byte[] classFile) throws InvalidConstantPoolFormatException {
++ this(new ConstantPoolParser(classFile));
++ }
++
++ /** Create a {@link ConstantPoolParser} and
++ * a {@link ConstantPoolPatch} in one step.
++ * Equivalent to {@code new ConstantPoolParser(templateClass).createPatch()}.
++ *
++ * @param templateClass the class to parse.
++ * @see #ConstantPoolParser(Class)
++ */
++ public ConstantPoolPatch(Class<?> templateClass) throws IOException, InvalidConstantPoolFormatException {
++ this(new ConstantPoolParser(templateClass));
++ }
++
++
+ /** Creates a patch from an existing patch.
+ * All changes are copied from that patch.
+ * @param patch a patch
@@ -790,6 +814,40 @@ new file mode 100644
+ /** Produce the original constant pool as an array. */
+ public Object[] getOriginalCP() throws InvalidConstantPoolFormatException {
+ return getOriginalCP(0, patchArray.length, -1);
++ }
++
++ /** Walk the constant pool, applying patches using the given map.
++ *
++ * @param utf8Map Utf8 strings to modify, if encountered
++ * @param classMap Classes (or their names) to modify, if encountered
++ * @param constantMap Constant values to modify, if encountered
++ * @param deleteUsedEntries if true, delete map entries that are used
++ */
++ public void putPatches(final Map<String,String> utf8Map,
++ final Map<Object,Object> classMap,
++ final Map<Object,Object> constantMap,
++ boolean deleteUsedEntries) throws InvalidConstantPoolFormatException {
++ if (classMap != null || constantMap != null)
++ throw new UnsupportedOperationException("NYI: non-null classMap or constantMap");
++ final HashSet<String> usedUtf8Keys
++ = (!deleteUsedEntries ? null : new HashSet<String>());
++ outer.parse(new ConstantPoolVisitor() {
++
++ @Override
++ public void visitUTF8(int index, byte tag, String utf8) {
++ String orig = utf8;
++ Object oldPatch = patchArray[index];
++ if (oldPatch != null)
++ orig = (String) oldPatch;
++ String repl = utf8Map.get(orig);
++ if (repl != null) {
++ putUTF8(index, repl);
++ if (usedUtf8Keys != null) usedUtf8Keys.add(orig);
++ }
++ }
++ });
++ if (usedUtf8Keys != null)
++ utf8Map.keySet().removeAll(usedUtf8Keys);
+ }
+
+ Object[] getOriginalCP(final int startIndex,