--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/anonk.proj.patch Sat Aug 16 01:31:35 2008 -0700
@@ -0,0 +1,271 @@
+diff --git a/src/share/projects/AnonymousClass/build.xml b/src/share/projects/AnonymousClass/build.xml
+new file mode 100644
+--- /dev/null
++++ b/src/share/projects/AnonymousClass/build.xml
+@@ -0,0 +1,69 @@
++<?xml version="1.0" encoding="UTF-8"?>
++<!-- You may freely edit this file. See commented blocks below for -->
++<!-- some examples of how to customize the build. -->
++<!-- (If you delete it and reopen the project it will be recreated.) -->
++<project name="AnonymousClass" default="default" basedir=".">
++ <description>Builds, tests, and runs the project AnonymousClass.</description>
++ <import file="nbproject/build-impl.xml"/>
++ <!--
++
++ There exist several targets which are by default empty and which can be
++ used for execution of your tasks. These targets are usually executed
++ before and after some main targets. They are:
++
++ -pre-init: called before initialization of project properties
++ -post-init: called after initialization of project properties
++ -pre-compile: called before javac compilation
++ -post-compile: called after javac compilation
++ -pre-compile-single: called before javac compilation of single file
++ -post-compile-single: called after javac compilation of single file
++ -pre-compile-test: called before javac compilation of JUnit tests
++ -post-compile-test: called after javac compilation of JUnit tests
++ -pre-compile-test-single: called before javac compilation of single JUnit test
++ -post-compile-test-single: called after javac compilation of single JUunit test
++ -pre-jar: called before JAR building
++ -post-jar: called after JAR building
++ -post-clean: called after cleaning build products
++
++ (Targets beginning with '-' are not intended to be called on their own.)
++
++ Example of inserting an obfuscator after compilation could look like this:
++
++ <target name="-post-compile">
++ <obfuscate>
++ <fileset dir="${build.classes.dir}"/>
++ </obfuscate>
++ </target>
++
++ For list of available properties check the imported
++ nbproject/build-impl.xml file.
++
++
++ Another way to customize the build is by overriding existing main targets.
++ The targets of interest are:
++
++ -init-macrodef-javac: defines macro for javac compilation
++ -init-macrodef-junit: defines macro for junit execution
++ -init-macrodef-debug: defines macro for class debugging
++ -init-macrodef-java: defines macro for class execution
++ -do-jar-with-manifest: JAR building (if you are using a manifest)
++ -do-jar-without-manifest: JAR building (if you are not using a manifest)
++ run: execution of project
++ -javadoc-build: Javadoc generation
++ test-report: JUnit report generation
++
++ An example of overriding the target for project execution could look like this:
++
++ <target name="run" depends="AnonymousClass-impl.jar">
++ <exec dir="bin" executable="launcher.exe">
++ <arg file="${dist.jar}"/>
++ </exec>
++ </target>
++
++ Notice that the overridden target depends on the jar target and not only on
++ the compile target as the regular run target does. Again, for a list of available
++ properties which you can use, check the target you are overriding in the
++ nbproject/build-impl.xml file.
++
++ -->
++</project>
+diff --git a/src/share/projects/AnonymousClass/nbproject/project.properties b/src/share/projects/AnonymousClass/nbproject/project.properties
+new file mode 100644
+--- /dev/null
++++ b/src/share/projects/AnonymousClass/nbproject/project.properties
+@@ -0,0 +1,63 @@
++application.title=AnonymousClass
++application.vendor=jrose
++build.classes.dir=${build.dir}/classes
++build.classes.excludes=**/*.java,**/*.form
++# This directory is removed when the project is cleaned:
++build.dir=build
++build.generated.dir=${build.dir}/generated
++# Only compile against the classpath explicitly listed here:
++build.sysclasspath=ignore
++build.test.classes.dir=${build.dir}/test/classes
++build.test.results.dir=${build.dir}/test/results
++debug.classpath=\
++ ${run.classpath}
++debug.test.classpath=\
++ ${run.test.classpath}
++# This directory is removed when the project is cleaned:
++dist.dir=dist
++dist.jar=${dist.dir}/AnonymousClass.jar
++dist.javadoc.dir=${dist.dir}/javadoc
++excludes=
++includes=java/dyn/Anonymous*.java,java/dyn/*ConstantPool*.java,jdk/java/dyn/Anonymous*.java,sun/misc/Unsafe.java
++#includes=**
++jar.compress=false
++javac.classpath=
++# Space-separated list of extra javac options
++javac.compilerargs=
++javac.deprecation=false
++javac.source=1.5
++javac.target=1.5
++javac.test.classpath=\
++ ${javac.classpath}:\
++ ${build.classes.dir}:\
++ ${libs.junit_4.classpath}
++javadoc.additionalparam=
++javadoc.author=false
++javadoc.encoding=${source.encoding}
++javadoc.noindex=false
++javadoc.nonavbar=false
++javadoc.notree=false
++javadoc.private=false
++javadoc.splitindex=true
++javadoc.use=true
++javadoc.version=false
++javadoc.windowtitle=
++main.class=AnonymousTest
++meta.inf.dir=${src.dir}/META-INF
++platform.active=default_platform
++run.classpath=\
++ ${javac.classpath}:\
++ ${build.classes.dir}
++# Space-separated list of JVM arguments used when running the project
++# (you may also define separate properties like run-sys-prop.name=value instead of -Dname=value
++# or test-sys-prop.name=value to set system properties for unit tests):
++run.jvmargs=-Xbootclasspath/a:"${build.classes.dir}:${libs.junit.classpath}"
++run.test.classpath=\
++ ${javac.test.classpath}:\
++ ${build.test.classes.dir}
++source.encoding=UTF-8
++# One or both refs probably need fixing:
++file.reference.projects=${env.HOME}/Projects
++file.reference.davinci.sources.jdk=${file.reference.projects}/davinci/sources/jdk
++src.classes.dir=${file.reference.davinci.sources.jdk}/src/share/classes
++test.src.dir=test
+diff --git a/src/share/projects/AnonymousClass/nbproject/project.xml b/src/share/projects/AnonymousClass/nbproject/project.xml
+new file mode 100644
+--- /dev/null
++++ b/src/share/projects/AnonymousClass/nbproject/project.xml
+@@ -0,0 +1,16 @@
++<?xml version="1.0" encoding="UTF-8"?>
++<project xmlns="http://www.netbeans.org/ns/project/1">
++ <type>org.netbeans.modules.java.j2seproject</type>
++ <configuration>
++ <data xmlns="http://www.netbeans.org/ns/j2se-project/3">
++ <name>AnonymousClass</name>
++ <minimum-ant-version>1.6.5</minimum-ant-version>
++ <source-roots>
++ <root id="src.classes.dir" name="Source Packages"/>
++ </source-roots>
++ <test-roots>
++ <root id="test.src.dir"/>
++ </test-roots>
++ </data>
++ </configuration>
++</project>
+diff --git a/src/share/projects/AnonymousClass/test/jdk/java/dyn/AnonymousTest.java b/src/share/projects/AnonymousClass/test/jdk/java/dyn/AnonymousTest.java
+new file mode 100644
+--- /dev/null
++++ b/src/share/projects/AnonymousClass/test/jdk/java/dyn/AnonymousTest.java
+@@ -0,0 +1,103 @@
++package jdk.java.dyn;
++
++
++import java.dyn.AnonymousClassLoader;
++import java.dyn.ConstantPoolPatch;
++import java.dyn.ConstantPoolParser;
++import java.dyn.ConstantPoolVisitor;
++import java.dyn.InvalidConstantPoolFormatException;
++import java.io.IOException;
++import java.lang.reflect.InvocationTargetException;
++import org.junit.AfterClass;
++import org.junit.BeforeClass;
++import org.junit.Test;
++import static org.junit.Assert.*;
++
++public class AnonymousTest {
++
++ @BeforeClass
++ public static void setUpClass() throws Exception {
++ }
++
++ @AfterClass
++ public static void tearDownClass() throws Exception {
++ }
++
++ static class A {
++
++ public static void sayHello() {
++ System.out.println("hello");
++ }
++ }
++
++ @Test
++ public void testMain()
++ throws InvalidConstantPoolFormatException, IOException,
++ InstantiationException, IllegalAccessException,
++ InvocationTargetException, NoSuchMethodException
++ {
++ main();
++ }
++
++ public static void main(String... args)
++ throws InvalidConstantPoolFormatException, IOException,
++ InstantiationException, IllegalAccessException,
++ InvocationTargetException, NoSuchMethodException
++ {
++ ConstantPoolParser parser = new ConstantPoolParser(AnonymousTest.A.class);
++ final ConstantPoolPatch patch = parser.createPatch();
++ parser.parse(new ConstantPoolVisitor() {
++
++ void dump(int index, byte tag, Object value, Object... moreValues) {
++ for (Object value2 : moreValues) {
++ if (value2 instanceof Integer)
++ value = value + " [" + value2 + "]";
++ else
++ value = value + ";" + value2;
++ }
++ System.out.println(index + " " + tagName(tag) + ": " + value);
++ }
++
++ @Override
++ public void visitUTF8(int index, byte tag, String utf8) {
++ dump(index, tag, utf8);
++ }
++
++ @Override
++ public void visitConstantValue(int index, byte tag, Object value) {
++ assert(tag != CONSTANT_String);
++ dump(index, tag, value);
++ }
++
++ @Override
++ public void visitConstantString(int index, byte tag,
++ String value, int j) {
++ if (tag == CONSTANT_String && "hello".equals(value)) {
++ patch.putConstantValue(index, "welcome to hell");
++ }
++ dump(index, tag, value, j);
++ }
++
++ @Override
++ public void visitMemberRef(int index, byte tag,
++ String className, String memberName,
++ String signature,
++ int j, int k) {
++ dump(index, tag, className, memberName, signature, j, k);
++ }
++
++ @Override
++ public void visitDescriptor(int index, byte tag,
++ String memberName, String signature,
++ int j, int k) {
++ dump(index, tag, memberName, signature, j, k);
++ }
++ });
++
++ AnonymousClassLoader classloader = new AnonymousClassLoader(AnonymousTest.class);
++ Class<?> patchedClass = classloader.loadClass(patch);
++ Object o = patchedClass.newInstance();
++ patchedClass.getMethod("sayHello").invoke(o);
++ }
++
++}