hotswap.patch
author Thomas Wuerthinger (thomas.wuerthinger@gmx.at)
Wed Feb 03 10:43:04 2010 +0100 (6 days ago)
changeset 186 4f9420785686
parent 988800c1fd00fd
permissions -rw-r--r--
hotswap: New patch. Main changes are:
- Improved instance update performance (mark&compact modification, compressed storage of instance update information)
- Improved stability (increased own test suite, more tests of the standard class redefinition test suite passing)
- Correct handling of static fields: Values are copied from old class instead of reexecuting the static initializer of the new class.
- Introduction of mutator methods: On every changed instance the method $mutator() is executed if available.
- Rebiased to jdk7-b81
        1 diff -r 1999f5b12482 .hgignore
        2 --- a/.hgignore	Thu Jan 28 11:26:42 2010 -0800
        3 +++ b/.hgignore	Tue Feb 02 16:40:23 2010 +0100
        4 @@ -1,7 +1,21 @@
        5 -^build/
        6 -^dist/
        7 -/nbproject/private/
        8 -^src/share/tools/hsdis/build/
        9 -^src/share/tools/IdealGraphVisualizer/[a-zA-Z0-9]*/build/
       10 -^src/share/tools/IdealGraphVisualizer/build/
       11 -^src/share/tools/IdealGraphVisualizer/dist/
       12 +^build/
       13 +^work/
       14 +^java/
       15 +^dist/
       16 +^make/
       17 +build/
       18 +/nbproject/private/
       19 +^src/share/tools/hsdis/build/
       20 +private/
       21 +dist/
       22 +.pdf$
       23 +.toc$
       24 +.ps$
       25 +.dvi$
       26 +.aux$
       27 +.swp$
       28 +.bak$
       29 +hotspot.log$
       30 +^src/share/tools/IdealGraphVisualizer/[a-zA-Z0-9]*/build/
       31 +^src/share/tools/IdealGraphVisualizer/build/
       32 +^src/share/tools/IdealGraphVisualizer/dist/
       33 diff -r 1999f5b12482 build.cmd
       34 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
       35 +++ b/build.cmd	Tue Feb 02 16:40:23 2010 +0100
       36 @@ -0,0 +1,12 @@
       37 +set HotSpotMksHome=C:\Cygwin\bin
       38 +set path=%JAVA_HOME%;C:\Cygwin\bin
       39 +call "C:\Program Files\Microsoft Visual Studio .NET 2003\Common7\Tools\vsvars32.bat"
       40 +
       41 +set OrigPath=%cd%
       42 +cd make\windows
       43 +
       44 +call build.bat product compiler1 %OrigPath% %JAVA_HOME%
       45 +call build.bat fastdebug compiler1 %OrigPath% %JAVA_HOME%
       46 +
       47 +cd %OrigPath%
       48 +pause
       49 diff -r 1999f5b12482 create.cmd
       50 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
       51 +++ b/create.cmd	Tue Feb 02 16:40:23 2010 +0100
       52 @@ -0,0 +1,12 @@
       53 +set HotSpotMksHome=C:\Cygwin\bin
       54 +set path=%JAVA_HOME%\bin;C:\Cygwin\bin
       55 +call "C:\Program Files\Microsoft Visual Studio .NET 2003\Common7\Tools\vsvars32.bat"
       56 +
       57 +set OrigPath=%cd%
       58 +cd make\windows
       59 +
       60 +mkdir %OrigPath%\work
       61 +call create.bat %OrigPath% %OrigPath%\work %OrigPath%\java
       62 +
       63 +cd %OrigPath%
       64 +pause
       65 diff -r 1999f5b12482 hotswaptest/HotSwapTests/manifest.mf
       66 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
       67 +++ b/hotswaptest/HotSwapTests/manifest.mf	Tue Feb 02 16:40:23 2010 +0100
       68 @@ -0,0 +1,3 @@
       69 +Manifest-Version: 1.0
       70 +X-COMMENT: Main-Class will be added automatically by build
       71 +
       72 diff -r 1999f5b12482 hotswaptest/HotSwapTests/nbbuild.xml
       73 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
       74 +++ b/hotswaptest/HotSwapTests/nbbuild.xml	Tue Feb 02 16:40:23 2010 +0100
       75 @@ -0,0 +1,74 @@
       76 +<?xml version="1.0" encoding="UTF-8"?>
       77 +<!-- You may freely edit this file. See commented blocks below for -->
       78 +<!-- some examples of how to customize the build. -->
       79 +<!-- (If you delete it and reopen the project it will be recreated.) -->
       80 +<!-- By default, only the Clean and Build commands use this build script. -->
       81 +<!-- Commands such as Run, Debug, and Test only use this build script if -->
       82 +<!-- the Compile on Save feature is turned off for the project. -->
       83 +<!-- You can turn off the Compile on Save (or Deploy on Save) setting -->
       84 +<!-- in the project's Project Properties dialog box.-->
       85 +<project name="HotSwapTests" default="default" basedir=".">
       86 +    <description>Builds, tests, and runs the project HotSwapTests.</description>
       87 +    <import file="nbproject/build-impl.xml"/>
       88 +    <!--
       89 +
       90 +    There exist several targets which are by default empty and which can be 
       91 +    used for execution of your tasks. These targets are usually executed 
       92 +    before and after some main targets. They are: 
       93 +
       94 +      -pre-init:                 called before initialization of project properties
       95 +      -post-init:                called after initialization of project properties
       96 +      -pre-compile:              called before javac compilation
       97 +      -post-compile:             called after javac compilation
       98 +      -pre-compile-single:       called before javac compilation of single file
       99 +      -post-compile-single:      called after javac compilation of single file
      100 +      -pre-compile-test:         called before javac compilation of JUnit tests
      101 +      -post-compile-test:        called after javac compilation of JUnit tests
      102 +      -pre-compile-test-single:  called before javac compilation of single JUnit test
      103 +      -post-compile-test-single: called after javac compilation of single JUunit test
      104 +      -pre-jar:                  called before JAR building
      105 +      -post-jar:                 called after JAR building
      106 +      -post-clean:               called after cleaning build products
      107 +
      108 +    (Targets beginning with '-' are not intended to be called on their own.)
      109 +
      110 +    Example of inserting an obfuscator after compilation could look like this:
      111 +
      112 +        <target name="-post-compile">
      113 +            <obfuscate>
      114 +                <fileset dir="${build.classes.dir}"/>
      115 +            </obfuscate>
      116 +        </target>
      117 +
      118 +    For list of available properties check the imported 
      119 +    nbproject/build-impl.xml file. 
      120 +
      121 +
      122 +    Another way to customize the build is by overriding existing main targets.
      123 +    The targets of interest are: 
      124 +
      125 +      -init-macrodef-javac:     defines macro for javac compilation
      126 +      -init-macrodef-junit:     defines macro for junit execution
      127 +      -init-macrodef-debug:     defines macro for class debugging
      128 +      -init-macrodef-java:      defines macro for class execution
      129 +      -do-jar-with-manifest:    JAR building (if you are using a manifest)
      130 +      -do-jar-without-manifest: JAR building (if you are not using a manifest)
      131 +      run:                      execution of project 
      132 +      -javadoc-build:           Javadoc generation
      133 +      test-report:              JUnit report generation
      134 +
      135 +    An example of overriding the target for project execution could look like this:
      136 +
      137 +        <target name="run" depends="HotSwapTests-impl.jar">
      138 +            <exec dir="bin" executable="launcher.exe">
      139 +                <arg file="${dist.jar}"/>
      140 +            </exec>
      141 +        </target>
      142 +
      143 +    Notice that the overridden target depends on the jar target and not only on 
      144 +    the compile target as the regular run target does. Again, for a list of available 
      145 +    properties which you can use, check the target you are overriding in the
      146 +    nbproject/build-impl.xml file. 
      147 +
      148 +    -->
      149 +</project>
      150 diff -r 1999f5b12482 hotswaptest/HotSwapTests/nbproject/build-impl.xml
      151 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
      152 +++ b/hotswaptest/HotSwapTests/nbproject/build-impl.xml	Tue Feb 02 16:40:23 2010 +0100
      153 @@ -0,0 +1,808 @@
      154 +<?xml version="1.0" encoding="UTF-8"?>
      155 +<!--
      156 +*** GENERATED FROM project.xml - DO NOT EDIT  ***
      157 +***         EDIT ../build.xml INSTEAD         ***
      158 +
      159 +For the purpose of easier reading the script
      160 +is divided into following sections:
      161 +
      162 +  - initialization
      163 +  - compilation
      164 +  - jar
      165 +  - execution
      166 +  - debugging
      167 +  - javadoc
      168 +  - junit compilation
      169 +  - junit execution
      170 +  - junit debugging
      171 +  - applet
      172 +  - cleanup
      173 +
      174 +        -->
      175 +<project xmlns:j2seproject1="http://www.netbeans.org/ns/j2se-project/1" xmlns:j2seproject3="http://www.netbeans.org/ns/j2se-project/3" xmlns:jaxrpc="http://www.netbeans.org/ns/j2se-project/jax-rpc" basedir=".." default="default" name="HotSwapTests-impl">
      176 +    <fail message="Please build using Ant 1.7.1 or higher.">
      177 +        <condition>
      178 +            <not>
      179 +                <antversion atleast="1.7.1"/>
      180 +            </not>
      181 +        </condition>
      182 +    </fail>
      183 +    <target depends="test,jar,javadoc" description="Build and test whole project." name="default"/>
      184 +    <!-- 
      185 +                ======================
      186 +                INITIALIZATION SECTION 
      187 +                ======================
      188 +            -->
      189 +    <target name="-pre-init">
      190 +        <!-- Empty placeholder for easier customization. -->
      191 +        <!-- You can override this target in the ../build.xml file. -->
      192 +    </target>
      193 +    <target depends="-pre-init" name="-init-private">
      194 +        <property file="nbproject/private/config.properties"/>
      195 +        <property file="nbproject/private/configs/${config}.properties"/>
      196 +        <property file="nbproject/private/private.properties"/>
      197 +    </target>
      198 +    <target depends="-pre-init,-init-private" name="-init-user">
      199 +        <property file="${user.properties.file}"/>
      200 +        <!-- The two properties below are usually overridden -->
      201 +        <!-- by the active platform. Just a fallback. -->
      202 +        <property name="default.javac.source" value="1.4"/>
      203 +        <property name="default.javac.target" value="1.4"/>
      204 +    </target>
      205 +    <target depends="-pre-init,-init-private,-init-user" name="-init-project">
      206 +        <property file="nbproject/configs/${config}.properties"/>
      207 +        <property file="nbproject/project.properties"/>
      208 +    </target>
      209 +    <target depends="-pre-init,-init-private,-init-user,-init-project,-init-macrodef-property" name="-do-init">
      210 +        <available file="${manifest.file}" property="manifest.available"/>
      211 +        <condition property="main.class.available">
      212 +            <and>
      213 +                <isset property="main.class"/>
      214 +                <not>
      215 +                    <equals arg1="${main.class}" arg2="" trim="true"/>
      216 +                </not>
      217 +            </and>
      218 +        </condition>
      219 +        <condition property="manifest.available+main.class">
      220 +            <and>
      221 +                <isset property="manifest.available"/>
      222 +                <isset property="main.class.available"/>
      223 +            </and>
      224 +        </condition>
      225 +        <condition property="do.mkdist">
      226 +            <and>
      227 +                <isset property="libs.CopyLibs.classpath"/>
      228 +                <not>
      229 +                    <istrue value="${mkdist.disabled}"/>
      230 +                </not>
      231 +            </and>
      232 +        </condition>
      233 +        <condition property="manifest.available+main.class+mkdist.available">
      234 +            <and>
      235 +                <istrue value="${manifest.available+main.class}"/>
      236 +                <isset property="do.mkdist"/>
      237 +            </and>
      238 +        </condition>
      239 +        <condition property="manifest.available+mkdist.available">
      240 +            <and>
      241 +                <istrue value="${manifest.available}"/>
      242 +                <isset property="do.mkdist"/>
      243 +            </and>
      244 +        </condition>
      245 +        <condition property="manifest.available-mkdist.available">
      246 +            <or>
      247 +                <istrue value="${manifest.available}"/>
      248 +                <isset property="do.mkdist"/>
      249 +            </or>
      250 +        </condition>
      251 +        <condition property="manifest.available+main.class-mkdist.available">
      252 +            <or>
      253 +                <istrue value="${manifest.available+main.class}"/>
      254 +                <isset property="do.mkdist"/>
      255 +            </or>
      256 +        </condition>
      257 +        <condition property="have.tests">
      258 +            <or/>
      259 +        </condition>
      260 +        <condition property="have.sources">
      261 +            <or>
      262 +                <available file="${src.dir}"/>
      263 +            </or>
      264 +        </condition>
      265 +        <condition property="netbeans.home+have.tests">
      266 +            <and>
      267 +                <isset property="netbeans.home"/>
      268 +                <isset property="have.tests"/>
      269 +            </and>
      270 +        </condition>
      271 +        <condition property="no.javadoc.preview">
      272 +            <and>
      273 +                <isset property="javadoc.preview"/>
      274 +                <isfalse value="${javadoc.preview}"/>
      275 +            </and>
      276 +        </condition>
      277 +        <property name="run.jvmargs" value=""/>
      278 +        <property name="javac.compilerargs" value=""/>
      279 +        <property name="work.dir" value="${basedir}"/>
      280 +        <condition property="no.deps">
      281 +            <and>
      282 +                <istrue value="${no.dependencies}"/>
      283 +            </and>
      284 +        </condition>
      285 +        <property name="javac.debug" value="true"/>
      286 +        <property name="javadoc.preview" value="true"/>
      287 +        <property name="application.args" value=""/>
      288 +        <property name="source.encoding" value="${file.encoding}"/>
      289 +        <property name="runtime.encoding" value="${source.encoding}"/>
      290 +        <condition property="javadoc.encoding.used" value="${javadoc.encoding}">
      291 +            <and>
      292 +                <isset property="javadoc.encoding"/>
      293 +                <not>
      294 +                    <equals arg1="${javadoc.encoding}" arg2=""/>
      295 +                </not>
      296 +            </and>
      297 +        </condition>
      298 +        <property name="javadoc.encoding.used" value="${source.encoding}"/>
      299 +        <property name="includes" value="**"/>
      300 +        <property name="excludes" value=""/>
      301 +        <property name="do.depend" value="false"/>
      302 +        <condition property="do.depend.true">
      303 +            <istrue value="${do.depend}"/>
      304 +        </condition>
      305 +        <path id="endorsed.classpath.path" path="${endorsed.classpath}"/>
      306 +        <condition else="" property="endorsed.classpath.cmd.line.arg" value="-Xbootclasspath/p:'${toString:endorsed.classpath.path}'">
      307 +            <length length="0" string="${endorsed.classpath}" when="greater"/>
      308 +        </condition>
      309 +        <property name="javac.fork" value="false"/>
      310 +    </target>
      311 +    <target name="-post-init">
      312 +        <!-- Empty placeholder for easier customization. -->
      313 +        <!-- You can override this target in the ../build.xml file. -->
      314 +    </target>
      315 +    <target depends="-pre-init,-init-private,-init-user,-init-project,-do-init" name="-init-check">
      316 +        <fail unless="src.dir">Must set src.dir</fail>
      317 +        <fail unless="build.dir">Must set build.dir</fail>
      318 +        <fail unless="dist.dir">Must set dist.dir</fail>
      319 +        <fail unless="build.classes.dir">Must set build.classes.dir</fail>
      320 +        <fail unless="dist.javadoc.dir">Must set dist.javadoc.dir</fail>
      321 +        <fail unless="build.test.classes.dir">Must set build.test.classes.dir</fail>
      322 +        <fail unless="build.test.results.dir">Must set build.test.results.dir</fail>
      323 +        <fail unless="build.classes.excludes">Must set build.classes.excludes</fail>
      324 +        <fail unless="dist.jar">Must set dist.jar</fail>
      325 +    </target>
      326 +    <target name="-init-macrodef-property">
      327 +        <macrodef name="property" uri="http://www.netbeans.org/ns/j2se-project/1">
      328 +            <attribute name="name"/>
      329 +            <attribute name="value"/>
      330 +            <sequential>
      331 +                <property name="@{name}" value="${@{value}}"/>
      332 +            </sequential>
      333 +        </macrodef>
      334 +    </target>
      335 +    <target name="-init-macrodef-javac">
      336 +        <macrodef name="javac" uri="http://www.netbeans.org/ns/j2se-project/3">
      337 +            <attribute default="${src.dir}" name="srcdir"/>
      338 +            <attribute default="${build.classes.dir}" name="destdir"/>
      339 +            <attribute default="${javac.classpath}" name="classpath"/>
      340 +            <attribute default="${includes}" name="includes"/>
      341 +            <attribute default="${excludes}" name="excludes"/>
      342 +            <attribute default="${javac.debug}" name="debug"/>
      343 +            <attribute default="${empty.dir}" name="sourcepath"/>
      344 +            <attribute default="${empty.dir}" name="gensrcdir"/>
      345 +            <element name="customize" optional="true"/>
      346 +            <sequential>
      347 +                <property location="${build.dir}/empty" name="empty.dir"/>
      348 +                <mkdir dir="${empty.dir}"/>
      349 +                <javac debug="@{debug}" deprecation="${javac.deprecation}" destdir="@{destdir}" encoding="${source.encoding}" excludes="@{excludes}" fork="${javac.fork}" includeantruntime="false" includes="@{includes}" source="${javac.source}" sourcepath="@{sourcepath}" srcdir="@{srcdir}" target="${javac.target}" tempdir="${java.io.tmpdir}">
      350 +                    <src>
      351 +                        <dirset dir="@{gensrcdir}" erroronmissingdir="false">
      352 +                            <include name="*"/>
      353 +                        </dirset>
      354 +                    </src>
      355 +                    <classpath>
      356 +                        <path path="@{classpath}"/>
      357 +                    </classpath>
      358 +                    <compilerarg line="${endorsed.classpath.cmd.line.arg}"/>
      359 +                    <compilerarg line="${javac.compilerargs}"/>
      360 +                    <customize/>
      361 +                </javac>
      362 +            </sequential>
      363 +        </macrodef>
      364 +        <macrodef name="depend" uri="http://www.netbeans.org/ns/j2se-project/3">
      365 +            <attribute default="${src.dir}" name="srcdir"/>
      366 +            <attribute default="${build.classes.dir}" name="destdir"/>
      367 +            <attribute default="${javac.classpath}" name="classpath"/>
      368 +            <sequential>
      369 +                <depend cache="${build.dir}/depcache" destdir="@{destdir}" excludes="${excludes}" includes="${includes}" srcdir="@{srcdir}">
      370 +                    <classpath>
      371 +                        <path path="@{classpath}"/>
      372 +                    </classpath>
      373 +                </depend>
      374 +            </sequential>
      375 +        </macrodef>
      376 +        <macrodef name="force-recompile" uri="http://www.netbeans.org/ns/j2se-project/3">
      377 +            <attribute default="${build.classes.dir}" name="destdir"/>
      378 +            <sequential>
      379 +                <fail unless="javac.includes">Must set javac.includes</fail>
      380 +                <pathconvert pathsep="," property="javac.includes.binary">
      381 +                    <path>
      382 +                        <filelist dir="@{destdir}" files="${javac.includes}"/>
      383 +                    </path>
      384 +                    <globmapper from="*.java" to="*.class"/>
      385 +                </pathconvert>
      386 +                <delete>
      387 +                    <files includes="${javac.includes.binary}"/>
      388 +                </delete>
      389 +            </sequential>
      390 +        </macrodef>
      391 +    </target>
      392 +    <target name="-init-macrodef-junit">
      393 +        <macrodef name="junit" uri="http://www.netbeans.org/ns/j2se-project/3">
      394 +            <attribute default="${includes}" name="includes"/>
      395 +            <attribute default="${excludes}" name="excludes"/>
      396 +            <attribute default="**" name="testincludes"/>
      397 +            <sequential>
      398 +                <junit dir="${work.dir}" errorproperty="tests.failed" failureproperty="tests.failed" fork="true" showoutput="true" tempdir="${build.dir}">
      399 +                    <batchtest todir="${build.test.results.dir}"/>
      400 +                    <classpath>
      401 +                        <path path="${run.test.classpath}"/>
      402 +                    </classpath>
      403 +                    <syspropertyset>
      404 +                        <propertyref prefix="test-sys-prop."/>
      405 +                        <mapper from="test-sys-prop.*" to="*" type="glob"/>
      406 +                    </syspropertyset>
      407 +                    <formatter type="brief" usefile="false"/>
      408 +                    <formatter type="xml"/>
      409 +                    <jvmarg line="${endorsed.classpath.cmd.line.arg}"/>
      410 +                    <jvmarg line="${run.jvmargs}"/>
      411 +                </junit>
      412 +            </sequential>
      413 +        </macrodef>
      414 +    </target>
      415 +    <target depends="-init-debug-args" name="-init-macrodef-nbjpda">
      416 +        <macrodef name="nbjpdastart" uri="http://www.netbeans.org/ns/j2se-project/1">
      417 +            <attribute default="${main.class}" name="name"/>
      418 +            <attribute default="${debug.classpath}" name="classpath"/>
      419 +            <attribute default="" name="stopclassname"/>
      420 +            <sequential>
      421 +                <nbjpdastart addressproperty="jpda.address" name="@{name}" stopclassname="@{stopclassname}" transport="${debug-transport}">
      422 +                    <classpath>
      423 +                        <path path="@{classpath}"/>
      424 +                    </classpath>
      425 +                </nbjpdastart>
      426 +            </sequential>
      427 +        </macrodef>
      428 +        <macrodef name="nbjpdareload" uri="http://www.netbeans.org/ns/j2se-project/1">
      429 +            <attribute default="${build.classes.dir}" name="dir"/>
      430 +            <sequential>
      431 +                <nbjpdareload>
      432 +                    <fileset dir="@{dir}" includes="${fix.classes}">
      433 +                        <include name="${fix.includes}*.class"/>
      434 +                    </fileset>
      435 +                </nbjpdareload>
      436 +            </sequential>
      437 +        </macrodef>
      438 +    </target>
      439 +    <target name="-init-debug-args">
      440 +        <property name="version-output" value="java version &quot;${ant.java.version}"/>
      441 +        <condition property="have-jdk-older-than-1.4">
      442 +            <or>
      443 +                <contains string="${version-output}" substring="java version &quot;1.0"/>
      444 +                <contains string="${version-output}" substring="java version &quot;1.1"/>
      445 +                <contains string="${version-output}" substring="java version &quot;1.2"/>
      446 +                <contains string="${version-output}" substring="java version &quot;1.3"/>
      447 +            </or>
      448 +        </condition>
      449 +        <condition else="-Xdebug" property="debug-args-line" value="-Xdebug -Xnoagent -Djava.compiler=none">
      450 +            <istrue value="${have-jdk-older-than-1.4}"/>
      451 +        </condition>
      452 +        <condition else="dt_socket" property="debug-transport-by-os" value="dt_shmem">
      453 +            <os family="windows"/>
      454 +        </condition>
      455 +        <condition else="${debug-transport-by-os}" property="debug-transport" value="${debug.transport}">
      456 +            <isset property="debug.transport"/>
      457 +        </condition>
      458 +    </target>
      459 +    <target depends="-init-debug-args" name="-init-macrodef-debug">
      460 +        <macrodef name="debug" uri="http://www.netbeans.org/ns/j2se-project/3">
      461 +            <attribute default="${main.class}" name="classname"/>
      462 +            <attribute default="${debug.classpath}" name="classpath"/>
      463 +            <element name="customize" optional="true"/>
      464 +            <sequential>
      465 +                <java classname="@{classname}" dir="${work.dir}" fork="true">
      466 +                    <jvmarg line="${endorsed.classpath.cmd.line.arg}"/>
      467 +                    <jvmarg line="${debug-args-line}"/>
      468 +                    <jvmarg value="-Xrunjdwp:transport=${debug-transport},address=${jpda.address}"/>
      469 +                    <jvmarg value="-Dfile.encoding=${runtime.encoding}"/>
      470 +                    <redirector errorencoding="${runtime.encoding}" inputencoding="${runtime.encoding}" outputencoding="${runtime.encoding}"/>
      471 +                    <jvmarg line="${run.jvmargs}"/>
      472 +                    <classpath>
      473 +                        <path path="@{classpath}"/>
      474 +                    </classpath>
      475 +                    <syspropertyset>
      476 +                        <propertyref prefix="run-sys-prop."/>
      477 +                        <mapper from="run-sys-prop.*" to="*" type="glob"/>
      478 +                    </syspropertyset>
      479 +                    <customize/>
      480 +                </java>
      481 +            </sequential>
      482 +        </macrodef>
      483 +    </target>
      484 +    <target name="-init-macrodef-java">
      485 +        <macrodef name="java" uri="http://www.netbeans.org/ns/j2se-project/1">
      486 +            <attribute default="${main.class}" name="classname"/>
      487 +            <attribute default="${run.classpath}" name="classpath"/>
      488 +            <element name="customize" optional="true"/>
      489 +            <sequential>
      490 +                <java classname="@{classname}" dir="${work.dir}" fork="true">
      491 +                    <jvmarg line="${endorsed.classpath.cmd.line.arg}"/>
      492 +                    <jvmarg value="-Dfile.encoding=${runtime.encoding}"/>
      493 +                    <redirector errorencoding="${runtime.encoding}" inputencoding="${runtime.encoding}" outputencoding="${runtime.encoding}"/>
      494 +                    <jvmarg line="${run.jvmargs}"/>
      495 +                    <classpath>
      496 +                        <path path="@{classpath}"/>
      497 +                    </classpath>
      498 +                    <syspropertyset>
      499 +                        <propertyref prefix="run-sys-prop."/>
      500 +                        <mapper from="run-sys-prop.*" to="*" type="glob"/>
      501 +                    </syspropertyset>
      502 +                    <customize/>
      503 +                </java>
      504 +            </sequential>
      505 +        </macrodef>
      506 +    </target>
      507 +    <target name="-init-presetdef-jar">
      508 +        <presetdef name="jar" uri="http://www.netbeans.org/ns/j2se-project/1">
      509 +            <jar compress="${jar.compress}" jarfile="${dist.jar}">
      510 +                <j2seproject1:fileset dir="${build.classes.dir}"/>
      511 +            </jar>
      512 +        </presetdef>
      513 +    </target>
      514 +    <target depends="-pre-init,-init-private,-init-user,-init-project,-do-init,-post-init,-init-check,-init-macrodef-property,-init-macrodef-javac,-init-macrodef-junit,-init-macrodef-nbjpda,-init-macrodef-debug,-init-macrodef-java,-init-presetdef-jar" name="init"/>
      515 +    <!--
      516 +                ===================
      517 +                COMPILATION SECTION
      518 +                ===================
      519 +            -->
      520 +    <target name="-deps-jar-init" unless="built-jar.properties">
      521 +        <property location="${build.dir}/built-jar.properties" name="built-jar.properties"/>
      522 +        <delete file="${built-jar.properties}" quiet="true"/>
      523 +    </target>
      524 +    <target if="already.built.jar.${basedir}" name="-warn-already-built-jar">
      525 +        <echo level="warn" message="Cycle detected: HotSwapTests was already built"/>
      526 +    </target>
      527 +    <target depends="init,-deps-jar-init" name="deps-jar" unless="no.deps">
      528 +        <mkdir dir="${build.dir}"/>
      529 +        <touch file="${built-jar.properties}" verbose="false"/>
      530 +        <property file="${built-jar.properties}" prefix="already.built.jar."/>
      531 +        <antcall target="-warn-already-built-jar"/>
      532 +        <propertyfile file="${built-jar.properties}">
      533 +            <entry key="${basedir}" value=""/>
      534 +        </propertyfile>
      535 +        <antcall target="-maybe-call-dep">
      536 +            <param name="call.built.properties" value="${built-jar.properties}"/>
      537 +            <param location="${project.HotSwapTool}" name="call.subproject"/>
      538 +            <param location="${project.HotSwapTool}/build.xml" name="call.script"/>
      539 +            <param name="call.target" value="jar"/>
      540 +            <param name="transfer.built-jar.properties" value="${built-jar.properties}"/>
      541 +        </antcall>
      542 +    </target>
      543 +    <target depends="init,-check-automatic-build,-clean-after-automatic-build" name="-verify-automatic-build"/>
      544 +    <target depends="init" name="-check-automatic-build">
      545 +        <available file="${build.classes.dir}/.netbeans_automatic_build" property="netbeans.automatic.build"/>
      546 +    </target>
      547 +    <target depends="init" if="netbeans.automatic.build" name="-clean-after-automatic-build">
      548 +        <antcall target="clean"/>
      549 +    </target>
      550 +    <target depends="init,deps-jar" name="-pre-pre-compile">
      551 +        <mkdir dir="${build.classes.dir}"/>
      552 +    </target>
      553 +    <target name="-pre-compile">
      554 +        <!-- Empty placeholder for easier customization. -->
      555 +        <!-- You can override this target in the ../build.xml file. -->
      556 +    </target>
      557 +    <target if="do.depend.true" name="-compile-depend">
      558 +        <pathconvert property="build.generated.subdirs">
      559 +            <dirset dir="${build.generated.sources.dir}" erroronmissingdir="false">
      560 +                <include name="*"/>
      561 +            </dirset>
      562 +        </pathconvert>
      563 +        <j2seproject3:depend srcdir="${src.dir}:${build.generated.subdirs}"/>
      564 +    </target>
      565 +    <target depends="init,deps-jar,-pre-pre-compile,-pre-compile,-compile-depend" if="have.sources" name="-do-compile">
      566 +        <j2seproject3:javac gensrcdir="${build.generated.sources.dir}"/>
      567 +        <copy todir="${build.classes.dir}">
      568 +            <fileset dir="${src.dir}" excludes="${build.classes.excludes},${excludes}" includes="${includes}"/>
      569 +        </copy>
      570 +    </target>
      571 +    <target name="-post-compile">
      572 +        <!-- Empty placeholder for easier customization. -->
      573 +        <!-- You can override this target in the ../build.xml file. -->
      574 +    </target>
      575 +    <target depends="init,deps-jar,-verify-automatic-build,-pre-pre-compile,-pre-compile,-do-compile,-post-compile" description="Compile project." name="compile"/>
      576 +    <target name="-pre-compile-single">
      577 +        <!-- Empty placeholder for easier customization. -->
      578 +        <!-- You can override this target in the ../build.xml file. -->
      579 +    </target>
      580 +    <target depends="init,deps-jar,-pre-pre-compile" name="-do-compile-single">
      581 +        <fail unless="javac.includes">Must select some files in the IDE or set javac.includes</fail>
      582 +        <j2seproject3:force-recompile/>
      583 +        <j2seproject3:javac excludes="" gensrcdir="${build.generated.sources.dir}" includes="${javac.includes}" sourcepath="${src.dir}"/>
      584 +    </target>
      585 +    <target name="-post-compile-single">
      586 +        <!-- Empty placeholder for easier customization. -->
      587 +        <!-- You can override this target in the ../build.xml file. -->
      588 +    </target>
      589 +    <target depends="init,deps-jar,-verify-automatic-build,-pre-pre-compile,-pre-compile-single,-do-compile-single,-post-compile-single" name="compile-single"/>
      590 +    <!--
      591 +                ====================
      592 +                JAR BUILDING SECTION
      593 +                ====================
      594 +            -->
      595 +    <target depends="init" name="-pre-pre-jar">
      596 +        <dirname file="${dist.jar}" property="dist.jar.dir"/>
      597 +        <mkdir dir="${dist.jar.dir}"/>
      598 +    </target>
      599 +    <target name="-pre-jar">
      600 +        <!-- Empty placeholder for easier customization. -->
      601 +        <!-- You can override this target in the ../build.xml file. -->
      602 +    </target>
      603 +    <target depends="init,compile,-pre-pre-jar,-pre-jar" name="-do-jar-without-manifest" unless="manifest.available-mkdist.available">
      604 +        <j2seproject1:jar/>
      605 +    </target>
      606 +    <target depends="init,compile,-pre-pre-jar,-pre-jar" if="manifest.available" name="-do-jar-with-manifest" unless="manifest.available+main.class-mkdist.available">
      607 +        <j2seproject1:jar manifest="${manifest.file}"/>
      608 +    </target>
      609 +    <target depends="init,compile,-pre-pre-jar,-pre-jar" if="manifest.available+main.class" name="-do-jar-with-mainclass" unless="manifest.available+main.class+mkdist.available">
      610 +        <j2seproject1:jar manifest="${manifest.file}">
      611 +            <j2seproject1:manifest>
      612 +                <j2seproject1:attribute name="Main-Class" value="${main.class}"/>
      613 +            </j2seproject1:manifest>
      614 +        </j2seproject1:jar>
      615 +        <echo>To run this application from the command line without Ant, try:</echo>
      616 +        <property location="${build.classes.dir}" name="build.classes.dir.resolved"/>
      617 +        <property location="${dist.jar}" name="dist.jar.resolved"/>
      618 +        <pathconvert property="run.classpath.with.dist.jar">
      619 +            <path path="${run.classpath}"/>
      620 +            <map from="${build.classes.dir.resolved}" to="${dist.jar.resolved}"/>
      621 +        </pathconvert>
      622 +        <echo>java -cp "${run.classpath.with.dist.jar}" ${main.class}</echo>
      623 +    </target>
      624 +    <target depends="init,compile,-pre-pre-jar,-pre-jar" if="manifest.available+main.class+mkdist.available" name="-do-jar-with-libraries">
      625 +        <property location="${build.classes.dir}" name="build.classes.dir.resolved"/>
      626 +        <pathconvert property="run.classpath.without.build.classes.dir">
      627 +            <path path="${run.classpath}"/>
      628 +            <map from="${build.classes.dir.resolved}" to=""/>
      629 +        </pathconvert>
      630 +        <pathconvert pathsep=" " property="jar.classpath">
      631 +            <path path="${run.classpath.without.build.classes.dir}"/>
      632 +            <chainedmapper>
      633 +                <flattenmapper/>
      634 +                <globmapper from="*" to="lib/*"/>
      635 +            </chainedmapper>
      636 +        </pathconvert>
      637 +        <taskdef classname="org.netbeans.modules.java.j2seproject.copylibstask.CopyLibs" classpath="${libs.CopyLibs.classpath}" name="copylibs"/>
      638 +        <copylibs compress="${jar.compress}" jarfile="${dist.jar}" manifest="${manifest.file}" runtimeclasspath="${run.classpath.without.build.classes.dir}">
      639 +            <fileset dir="${build.classes.dir}"/>
      640 +            <manifest>
      641 +                <attribute name="Main-Class" value="${main.class}"/>
      642 +                <attribute name="Class-Path" value="${jar.classpath}"/>
      643 +            </manifest>
      644 +        </copylibs>
      645 +        <echo>To run this application from the command line without Ant, try:</echo>
      646 +        <property location="${dist.jar}" name="dist.jar.resolved"/>
      647 +        <echo>java -jar "${dist.jar.resolved}"</echo>
      648 +    </target>
      649 +    <target depends="init,compile,-pre-pre-jar,-pre-jar" if="manifest.available+mkdist.available" name="-do-jar-with-libraries-without-mainclass" unless="main.class.available">
      650 +        <property location="${build.classes.dir}" name="build.classes.dir.resolved"/>
      651 +        <pathconvert property="run.classpath.without.build.classes.dir">
      652 +            <path path="${run.classpath}"/>
      653 +            <map from="${build.classes.dir.resolved}" to=""/>
      654 +        </pathconvert>
      655 +        <pathconvert pathsep=" " property="jar.classpath">
      656 +            <path path="${run.classpath.without.build.classes.dir}"/>
      657 +            <chainedmapper>
      658 +                <flattenmapper/>
      659 +                <globmapper from="*" to="lib/*"/>
      660 +            </chainedmapper>
      661 +        </pathconvert>
      662 +        <taskdef classname="org.netbeans.modules.java.j2seproject.copylibstask.CopyLibs" classpath="${libs.CopyLibs.classpath}" name="copylibs"/>
      663 +        <copylibs compress="${jar.compress}" jarfile="${dist.jar}" manifest="${manifest.file}" runtimeclasspath="${run.classpath.without.build.classes.dir}">
      664 +            <fileset dir="${build.classes.dir}"/>
      665 +            <manifest>
      666 +                <attribute name="Class-Path" value="${jar.classpath}"/>
      667 +            </manifest>
      668 +        </copylibs>
      669 +    </target>
      670 +    <target depends="init,compile,-pre-pre-jar,-pre-jar" if="do.mkdist" name="-do-jar-with-libraries-without-manifest" unless="manifest.available">
      671 +        <property location="${build.classes.dir}" name="build.classes.dir.resolved"/>
      672 +        <pathconvert property="run.classpath.without.build.classes.dir">
      673 +            <path path="${run.classpath}"/>
      674 +            <map from="${build.classes.dir.resolved}" to=""/>
      675 +        </pathconvert>
      676 +        <pathconvert pathsep=" " property="jar.classpath">
      677 +            <path path="${run.classpath.without.build.classes.dir}"/>
      678 +            <chainedmapper>
      679 +                <flattenmapper/>
      680 +                <globmapper from="*" to="lib/*"/>
      681 +            </chainedmapper>
      682 +        </pathconvert>
      683 +        <taskdef classname="org.netbeans.modules.java.j2seproject.copylibstask.CopyLibs" classpath="${libs.CopyLibs.classpath}" name="copylibs"/>
      684 +        <copylibs compress="${jar.compress}" jarfile="${dist.jar}" runtimeclasspath="${run.classpath.without.build.classes.dir}">
      685 +            <fileset dir="${build.classes.dir}"/>
      686 +            <manifest>
      687 +                <attribute name="Class-Path" value="${jar.classpath}"/>
      688 +            </manifest>
      689 +        </copylibs>
      690 +    </target>
      691 +    <target name="-post-jar">
      692 +        <!-- Empty placeholder for easier customization. -->
      693 +        <!-- You can override this target in the ../build.xml file. -->
      694 +    </target>
      695 +    <target depends="init,compile,-pre-jar,-do-jar-with-manifest,-do-jar-without-manifest,-do-jar-with-mainclass,-do-jar-with-libraries,-do-jar-with-libraries-without-mainclass,-do-jar-with-libraries-without-manifest,-post-jar" description="Build JAR." name="jar"/>
      696 +    <!--
      697 +                =================
      698 +                EXECUTION SECTION
      699 +                =================
      700 +            -->
      701 +    <target depends="init,compile" description="Run a main class." name="run">
      702 +        <j2seproject1:java>
      703 +            <customize>
      704 +                <arg line="${application.args}"/>
      705 +            </customize>
      706 +        </j2seproject1:java>
      707 +    </target>
      708 +    <target name="-do-not-recompile">
      709 +        <property name="javac.includes.binary" value=""/>
      710 +    </target>
      711 +    <target depends="init,compile-single" name="run-single">
      712 +        <fail unless="run.class">Must select one file in the IDE or set run.class</fail>
      713 +        <j2seproject1:java classname="${run.class}"/>
      714 +    </target>
      715 +    <target depends="init,compile-test-single" name="run-test-with-main">
      716 +        <fail unless="run.class">Must select one file in the IDE or set run.class</fail>
      717 +        <j2seproject1:java classname="${run.class}" classpath="${run.test.classpath}"/>
      718 +    </target>
      719 +    <!--
      720 +                =================
      721 +                DEBUGGING SECTION
      722 +                =================
      723 +            -->
      724 +    <target depends="init" if="netbeans.home" name="-debug-start-debugger">
      725 +        <j2seproject1:nbjpdastart name="${debug.class}"/>
      726 +    </target>
      727 +    <target depends="init" if="netbeans.home" name="-debug-start-debugger-main-test">
      728 +        <j2seproject1:nbjpdastart classpath="${debug.test.classpath}" name="${debug.class}"/>
      729 +    </target>
      730 +    <target depends="init,compile" name="-debug-start-debuggee">
      731 +        <j2seproject3:debug>
      732 +            <customize>
      733 +                <arg line="${application.args}"/>
      734 +            </customize>
      735 +        </j2seproject3:debug>
      736 +    </target>
      737 +    <target depends="init,compile,-debug-start-debugger,-debug-start-debuggee" description="Debug project in IDE." if="netbeans.home" name="debug"/>
      738 +    <target depends="init" if="netbeans.home" name="-debug-start-debugger-stepinto">
      739 +        <j2seproject1:nbjpdastart stopclassname="${main.class}"/>
      740 +    </target>
      741 +    <target depends="init,compile,-debug-start-debugger-stepinto,-debug-start-debuggee" if="netbeans.home" name="debug-stepinto"/>
      742 +    <target depends="init,compile-single" if="netbeans.home" name="-debug-start-debuggee-single">
      743 +        <fail unless="debug.class">Must select one file in the IDE or set debug.class</fail>
      744 +        <j2seproject3:debug classname="${debug.class}"/>
      745 +    </target>
      746 +    <target depends="init,compile-single,-debug-start-debugger,-debug-start-debuggee-single" if="netbeans.home" name="debug-single"/>
      747 +    <target depends="init,compile-test-single" if="netbeans.home" name="-debug-start-debuggee-main-test">
      748 +        <fail unless="debug.class">Must select one file in the IDE or set debug.class</fail>
      749 +        <j2seproject3:debug classname="${debug.class}" classpath="${debug.test.classpath}"/>
      750 +    </target>
      751 +    <target depends="init,compile-test-single,-debug-start-debugger-main-test,-debug-start-debuggee-main-test" if="netbeans.home" name="debug-test-with-main"/>
      752 +    <target depends="init" name="-pre-debug-fix">
      753 +        <fail unless="fix.includes">Must set fix.includes</fail>
      754 +        <property name="javac.includes" value="${fix.includes}.java"/>
      755 +    </target>
      756 +    <target depends="init,-pre-debug-fix,compile-single" if="netbeans.home" name="-do-debug-fix">
      757 +        <j2seproject1:nbjpdareload/>
      758 +    </target>
      759 +    <target depends="init,-pre-debug-fix,-do-debug-fix" if="netbeans.home" name="debug-fix"/>
      760 +    <!--
      761 +                ===============
      762 +                JAVADOC SECTION
      763 +                ===============
      764 +            -->
      765 +    <target depends="init" name="-javadoc-build">
      766 +        <mkdir dir="${dist.javadoc.dir}"/>
      767 +        <javadoc additionalparam="${javadoc.additionalparam}" author="${javadoc.author}" charset="UTF-8" destdir="${dist.javadoc.dir}" docencoding="UTF-8" encoding="${javadoc.encoding.used}" failonerror="true" noindex="${javadoc.noindex}" nonavbar="${javadoc.nonavbar}" notree="${javadoc.notree}" private="${javadoc.private}" source="${javac.source}" splitindex="${javadoc.splitindex}" use="${javadoc.use}" useexternalfile="true" version="${javadoc.version}" windowtitle="${javadoc.windowtitle}">
      768 +            <classpath>
      769 +                <path path="${javac.classpath}"/>
      770 +            </classpath>
      771 +            <fileset dir="${src.dir}" excludes="${excludes}" includes="${includes}">
      772 +                <filename name="**/*.java"/>
      773 +            </fileset>
      774 +            <fileset dir="${build.generated.sources.dir}" erroronmissingdir="false">
      775 +                <include name="**/*.java"/>
      776 +            </fileset>
      777 +        </javadoc>
      778 +    </target>
      779 +    <target depends="init,-javadoc-build" if="netbeans.home" name="-javadoc-browse" unless="no.javadoc.preview">
      780 +        <nbbrowse file="${dist.javadoc.dir}/index.html"/>
      781 +    </target>
      782 +    <target depends="init,-javadoc-build,-javadoc-browse" description="Build Javadoc." name="javadoc"/>
      783 +    <!--
      784 +                =========================
      785 +                JUNIT COMPILATION SECTION
      786 +                =========================
      787 +            -->
      788 +    <target depends="init,compile" if="have.tests" name="-pre-pre-compile-test">
      789 +        <mkdir dir="${build.test.classes.dir}"/>
      790 +    </target>
      791 +    <target name="-pre-compile-test">
      792 +        <!-- Empty placeholder for easier customization. -->
      793 +        <!-- You can override this target in the ../build.xml file. -->
      794 +    </target>
      795 +    <target if="do.depend.true" name="-compile-test-depend">
      796 +        <j2seproject3:depend classpath="${javac.test.classpath}" destdir="${build.test.classes.dir}" srcdir=""/>
      797 +    </target>
      798 +    <target depends="init,compile,-pre-pre-compile-test,-pre-compile-test,-compile-test-depend" if="have.tests" name="-do-compile-test">
      799 +        <j2seproject3:javac classpath="${javac.test.classpath}" debug="true" destdir="${build.test.classes.dir}" srcdir=""/>
      800 +        <copy todir="${build.test.classes.dir}"/>
      801 +    </target>
      802 +    <target name="-post-compile-test">
      803 +        <!-- Empty placeholder for easier customization. -->
      804 +        <!-- You can override this target in the ../build.xml file. -->
      805 +    </target>
      806 +    <target depends="init,compile,-pre-pre-compile-test,-pre-compile-test,-do-compile-test,-post-compile-test" name="compile-test"/>
      807 +    <target name="-pre-compile-test-single">
      808 +        <!-- Empty placeholder for easier customization. -->
      809 +        <!-- You can override this target in the ../build.xml file. -->
      810 +    </target>
      811 +    <target depends="init,compile,-pre-pre-compile-test,-pre-compile-test-single" if="have.tests" name="-do-compile-test-single">
      812 +        <fail unless="javac.includes">Must select some files in the IDE or set javac.includes</fail>
      813 +        <j2seproject3:force-recompile destdir="${build.test.classes.dir}"/>
      814 +        <j2seproject3:javac classpath="${javac.test.classpath}" debug="true" destdir="${build.test.classes.dir}" excludes="" includes="${javac.includes}" sourcepath="" srcdir=""/>
      815 +        <copy todir="${build.test.classes.dir}"/>
      816 +    </target>
      817 +    <target name="-post-compile-test-single">
      818 +        <!-- Empty placeholder for easier customization. -->
      819 +        <!-- You can override this target in the ../build.xml file. -->
      820 +    </target>
      821 +    <target depends="init,compile,-pre-pre-compile-test,-pre-compile-test-single,-do-compile-test-single,-post-compile-test-single" name="compile-test-single"/>
      822 +    <!--
      823 +                =======================
      824 +                JUNIT EXECUTION SECTION
      825 +                =======================
      826 +            -->
      827 +    <target depends="init" if="have.tests" name="-pre-test-run">
      828 +        <mkdir dir="${build.test.results.dir}"/>
      829 +    </target>
      830 +    <target depends="init,compile-test,-pre-test-run" if="have.tests" name="-do-test-run">
      831 +        <j2seproject3:junit testincludes="**/*Test.java"/>
      832 +    </target>
      833 +    <target depends="init,compile-test,-pre-test-run,-do-test-run" if="have.tests" name="-post-test-run">
      834 +        <fail if="tests.failed" unless="ignore.failing.tests">Some tests failed; see details above.</fail>
      835 +    </target>
      836 +    <target depends="init" if="have.tests" name="test-report"/>
      837 +    <target depends="init" if="netbeans.home+have.tests" name="-test-browse"/>
      838 +    <target depends="init,compile-test,-pre-test-run,-do-test-run,test-report,-post-test-run,-test-browse" description="Run unit tests." name="test"/>
      839 +    <target depends="init" if="have.tests" name="-pre-test-run-single">
      840 +        <mkdir dir="${build.test.results.dir}"/>
      841 +    </target>
      842 +    <target depends="init,compile-test-single,-pre-test-run-single" if="have.tests" name="-do-test-run-single">
      843 +        <fail unless="test.includes">Must select some files in the IDE or set test.includes</fail>
      844 +        <j2seproject3:junit excludes="" includes="${test.includes}"/>
      845 +    </target>
      846 +    <target depends="init,compile-test-single,-pre-test-run-single,-do-test-run-single" if="have.tests" name="-post-test-run-single">
      847 +        <fail if="tests.failed" unless="ignore.failing.tests">Some tests failed; see details above.</fail>
      848 +    </target>
      849 +    <target depends="init,compile-test-single,-pre-test-run-single,-do-test-run-single,-post-test-run-single" description="Run single unit test." name="test-single"/>
      850 +    <!--
      851 +                =======================
      852 +                JUNIT DEBUGGING SECTION
      853 +                =======================
      854 +            -->
      855 +    <target depends="init,compile-test" if="have.tests" name="-debug-start-debuggee-test">
      856 +        <fail unless="test.class">Must select one file in the IDE or set test.class</fail>
      857 +        <property location="${build.test.results.dir}/TEST-${test.class}.xml" name="test.report.file"/>
      858 +        <delete file="${test.report.file}"/>
      859 +        <mkdir dir="${build.test.results.dir}"/>
      860 +        <j2seproject3:debug classname="org.apache.tools.ant.taskdefs.optional.junit.JUnitTestRunner" classpath="${ant.home}/lib/ant.jar:${ant.home}/lib/ant-junit.jar:${debug.test.classpath}">
      861 +            <customize>
      862 +                <syspropertyset>
      863 +                    <propertyref prefix="test-sys-prop."/>
      864 +                    <mapper from="test-sys-prop.*" to="*" type="glob"/>
      865 +                </syspropertyset>
      866 +                <arg value="${test.class}"/>
      867 +                <arg value="showoutput=true"/>
      868 +                <arg value="formatter=org.apache.tools.ant.taskdefs.optional.junit.BriefJUnitResultFormatter"/>
      869 +                <arg value="formatter=org.apache.tools.ant.taskdefs.optional.junit.XMLJUnitResultFormatter,${test.report.file}"/>
      870 +            </customize>
      871 +        </j2seproject3:debug>
      872 +    </target>
      873 +    <target depends="init,compile-test" if="netbeans.home+have.tests" name="-debug-start-debugger-test">
      874 +        <j2seproject1:nbjpdastart classpath="${debug.test.classpath}" name="${test.class}"/>
      875 +    </target>
      876 +    <target depends="init,compile-test-single,-debug-start-debugger-test,-debug-start-debuggee-test" name="debug-test"/>
      877 +    <target depends="init,-pre-debug-fix,compile-test-single" if="netbeans.home" name="-do-debug-fix-test">
      878 +        <j2seproject1:nbjpdareload dir="${build.test.classes.dir}"/>
      879 +    </target>
      880 +    <target depends="init,-pre-debug-fix,-do-debug-fix-test" if="netbeans.home" name="debug-fix-test"/>
      881 +    <!--
      882 +                =========================
      883 +                APPLET EXECUTION SECTION
      884 +                =========================
      885 +            -->
      886 +    <target depends="init,compile-single" name="run-applet">
      887 +        <fail unless="applet.url">Must select one file in the IDE or set applet.url</fail>
      888 +        <j2seproject1:java classname="sun.applet.AppletViewer">
      889 +            <customize>
      890 +                <arg value="${applet.url}"/>
      891 +            </customize>
      892 +        </j2seproject1:java>
      893 +    </target>
      894 +    <!--
      895 +                =========================
      896 +                APPLET DEBUGGING  SECTION
      897 +                =========================
      898 +            -->
      899 +    <target depends="init,compile-single" if="netbeans.home" name="-debug-start-debuggee-applet">
      900 +        <fail unless="applet.url">Must select one file in the IDE or set applet.url</fail>
      901 +        <j2seproject3:debug classname="sun.applet.AppletViewer">
      902 +            <customize>
      903 +                <arg value="${applet.url}"/>
      904 +            </customize>
      905 +        </j2seproject3:debug>
      906 +    </target>
      907 +    <target depends="init,compile-single,-debug-start-debugger,-debug-start-debuggee-applet" if="netbeans.home" name="debug-applet"/>
      908 +    <!--
      909 +                ===============
      910 +                CLEANUP SECTION
      911 +                ===============
      912 +            -->
      913 +    <target name="-deps-clean-init" unless="built-clean.properties">
      914 +        <property location="${build.dir}/built-clean.properties" name="built-clean.properties"/>
      915 +        <delete file="${built-clean.properties}" quiet="true"/>
      916 +    </target>
      917 +    <target if="already.built.clean.${basedir}" name="-warn-already-built-clean">
      918 +        <echo level="warn" message="Cycle detected: HotSwapTests was already built"/>
      919 +    </target>
      920 +    <target depends="init,-deps-clean-init" name="deps-clean" unless="no.deps">
      921 +        <mkdir dir="${build.dir}"/>
      922 +        <touch file="${built-clean.properties}" verbose="false"/>
      923 +        <property file="${built-clean.properties}" prefix="already.built.clean."/>
      924 +        <antcall target="-warn-already-built-clean"/>
      925 +        <propertyfile file="${built-clean.properties}">
      926 +            <entry key="${basedir}" value=""/>
      927 +        </propertyfile>
      928 +        <antcall target="-maybe-call-dep">
      929 +            <param name="call.built.properties" value="${built-clean.properties}"/>
      930 +            <param location="${project.HotSwapTool}" name="call.subproject"/>
      931 +            <param location="${project.HotSwapTool}/build.xml" name="call.script"/>
      932 +            <param name="call.target" value="clean"/>
      933 +            <param name="transfer.built-clean.properties" value="${built-clean.properties}"/>
      934 +        </antcall>
      935 +    </target>
      936 +    <target depends="init" name="-do-clean">
      937 +        <delete dir="${build.dir}"/>
      938 +        <delete dir="${dist.dir}" followsymlinks="false" includeemptydirs="true"/>
      939 +    </target>
      940 +    <target name="-post-clean">
      941 +        <!-- Empty placeholder for easier customization. -->
      942 +        <!-- You can override this target in the ../build.xml file. -->
      943 +    </target>
      944 +    <target depends="init,deps-clean,-do-clean,-post-clean" description="Clean build products." name="clean"/>
      945 +    <target name="-check-call-dep">
      946 +        <property file="${call.built.properties}" prefix="already.built."/>
      947 +        <condition property="should.call.dep">
      948 +            <not>
      949 +                <isset property="already.built.${call.subproject}"/>
      950 +            </not>
      951 +        </condition>
      952 +    </target>
      953 +    <target depends="-check-call-dep" if="should.call.dep" name="-maybe-call-dep">
      954 +        <ant antfile="${call.script}" inheritall="false" target="${call.target}">
      955 +            <propertyset>
      956 +                <propertyref prefix="transfer."/>
      957 +                <mapper from="transfer.*" to="*" type="glob"/>
      958 +            </propertyset>
      959 +        </ant>
      960 +    </target>
      961 +</project>
      962 diff -r 1999f5b12482 hotswaptest/HotSwapTests/nbproject/genfiles.properties
      963 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
      964 +++ b/hotswaptest/HotSwapTests/nbproject/genfiles.properties	Tue Feb 02 16:40:23 2010 +0100
      965 @@ -0,0 +1,8 @@
      966 +nbbuild.xml.data.CRC32=c8ab650e
      967 +nbbuild.xml.script.CRC32=2ea92a55
      968 +nbbuild.xml.stylesheet.CRC32=958a1d3e@1.32.1.45
      969 +# This file is used by a NetBeans-based IDE to track changes in generated files such as build-impl.xml.
      970 +# Do not edit this file. You may delete it but then the IDE will never regenerate such files for you.
      971 +nbproject/build-impl.xml.data.CRC32=c8ab650e
      972 +nbproject/build-impl.xml.script.CRC32=2e435115
      973 +nbproject/build-impl.xml.stylesheet.CRC32=576378a2@1.32.1.45
      974 diff -r 1999f5b12482 hotswaptest/HotSwapTests/nbproject/project.properties
      975 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
      976 +++ b/hotswaptest/HotSwapTests/nbproject/project.properties	Tue Feb 02 16:40:23 2010 +0100
      977 @@ -0,0 +1,68 @@
      978 +application.title=HotSwapTests
      979 +application.vendor=Thomas
      980 +build.classes.dir=${build.dir}/classes
      981 +build.classes.excludes=**/*.java,**/*.form
      982 +# This directory is removed when the project is cleaned:
      983 +build.dir=build
      984 +build.generated.dir=${build.dir}/generated
      985 +build.generated.sources.dir=${build.dir}/generated-sources
      986 +# Only compile against the classpath explicitly listed here:
      987 +build.sysclasspath=ignore
      988 +build.test.classes.dir=${build.dir}/test/classes
      989 +build.test.results.dir=${build.dir}/test/results
      990 +buildfile=nbbuild.xml
      991 +# Uncomment to specify the preferred debugger connection transport:
      992 +#debug.transport=dt_socket
      993 +debug.classpath=\
      994 +    ${run.classpath}
      995 +debug.test.classpath=\
      996 +    ${run.test.classpath}
      997 +# This directory is removed when the project is cleaned:
      998 +dist.dir=dist
      999 +dist.jar=${dist.dir}/HotSwapTests.jar
     1000 +dist.javadoc.dir=${dist.dir}/javadoc
     1001 +endorsed.classpath=
     1002 +excludes=
     1003 +file.reference.bcel-5.2.jar=..\\..\\..\\..\\Java\\bcel-5.2\\bcel-5.2.jar
     1004 +file.reference.HotSwapTests-src=src
     1005 +includes=**
     1006 +jar.compress=false
     1007 +javac.classpath=\
     1008 +    ${libs.junit_4.classpath}:\
     1009 +    ${reference.HotSwapTool.jar}
     1010 +# Space-separated list of extra javac options
     1011 +javac.compilerargs=
     1012 +javac.deprecation=false
     1013 +javac.source=1.6
     1014 +javac.target=1.6
     1015 +javac.test.classpath=\
     1016 +    ${javac.classpath}:\
     1017 +    ${build.classes.dir}:\
     1018 +    ${libs.junit.classpath}:\
     1019 +    ${libs.junit_4.classpath}
     1020 +javadoc.additionalparam=
     1021 +javadoc.author=false
     1022 +javadoc.encoding=${source.encoding}
     1023 +javadoc.noindex=false
     1024 +javadoc.nonavbar=false
     1025 +javadoc.notree=false
     1026 +javadoc.private=false
     1027 +javadoc.splitindex=true
     1028 +javadoc.use=true
     1029 +javadoc.version=false
     1030 +javadoc.windowtitle=
     1031 +jaxbwiz.endorsed.dirs="${netbeans.home}/../ide12/modules/ext/jaxb/api"
     1032 +main.class=at.ssw.hotswap.test.Main
     1033 +manifest.file=manifest.mf
     1034 +meta.inf.dir=${src.dir}/META-INF
     1035 +platform.active=default_platform
     1036 +project.HotSwapTool=../HotSwapTool
     1037 +reference.HotSwapTool.jar=${project.HotSwapTool}/dist/HotSwapTool.jar
     1038 +run.classpath=\
     1039 +    ${javac.classpath}:\
     1040 +    ${build.classes.dir}
     1041 +run.test.classpath=\
     1042 +    ${javac.test.classpath}:\
     1043 +    ${build.test.classes.dir}
     1044 +source.encoding=UTF-8
     1045 +src.dir=${file.reference.HotSwapTests-src}
     1046 diff -r 1999f5b12482 hotswaptest/HotSwapTests/nbproject/project.xml
     1047 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
     1048 +++ b/hotswaptest/HotSwapTests/nbproject/project.xml	Tue Feb 02 16:40:23 2010 +0100
     1049 @@ -0,0 +1,24 @@
     1050 +<?xml version="1.0" encoding="UTF-8"?>
     1051 +<project xmlns="http://www.netbeans.org/ns/project/1">
     1052 +    <type>org.netbeans.modules.java.j2seproject</type>
     1053 +    <configuration>
     1054 +        <data xmlns="http://www.netbeans.org/ns/j2se-project/3">
     1055 +            <name>HotSwapTests</name>
     1056 +            <minimum-ant-version>1.6.5</minimum-ant-version>
     1057 +            <source-roots>
     1058 +                <root id="src.dir"/>
     1059 +            </source-roots>
     1060 +            <test-roots/>
     1061 +        </data>
     1062 +        <references xmlns="http://www.netbeans.org/ns/ant-project-references/1">
     1063 +            <reference>
     1064 +                <foreign-project>HotSwapTool</foreign-project>
     1065 +                <artifact-type>jar</artifact-type>
     1066 +                <script>build.xml</script>
     1067 +                <target>jar</target>
     1068 +                <clean-target>clean</clean-target>
     1069 +                <id>jar</id>
     1070 +            </reference>
     1071 +        </references>
     1072 +    </configuration>
     1073 +</project>
     1074 diff -r 1999f5b12482 hotswaptest/HotSwapTests/src/at/ssw/hotswap/test/CompleteTestSuite.java
     1075 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
     1076 +++ b/hotswaptest/HotSwapTests/src/at/ssw/hotswap/test/CompleteTestSuite.java	Tue Feb 02 16:40:23 2010 +0100
     1077 @@ -0,0 +1,52 @@
     1078 +/*
     1079 + * Copyright 1997-2009 Sun Microsystems, Inc.  All Rights Reserved.
     1080 + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
     1081 + *
     1082 + * This code is free software; you can redistribute it and/or modify it
     1083 + * under the terms of the GNU General Public License version 2 only, as
     1084 + * published by the Free Software Foundation.
     1085 + *
     1086 + * This code is distributed in the hope that it will be useful, but WITHOUT
     1087 + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
     1088 + * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
     1089 + * version 2 for more details (a copy is included in the LICENSE file that
     1090 + * accompanied this code).
     1091 + *
     1092 + * You should have received a copy of the GNU General Public License version
     1093 + * 2 along with this work; if not, write to the Free Software Foundation,
     1094 + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
     1095 + *
     1096 + * Please contact Sun Microsystems, Inc., 4150 Network Circle, Santa Clara,
     1097 + * CA 95054 USA or visit www.sun.com if you need additional information or
     1098 + * have any questions.
     1099 + *
     1100 + */
     1101 +
     1102 +package at.ssw.hotswap.test;
     1103 +
     1104 +import org.junit.runner.RunWith;
     1105 +import org.junit.runners.Suite;
     1106 +
     1107 +import at.ssw.hotswap.test.body.BodyTestSuite;
     1108 +import at.ssw.hotswap.test.eval.EvalTestSuite;
     1109 +import at.ssw.hotswap.test.fields.FieldsTestSuite;
     1110 +import at.ssw.hotswap.test.methods.MethodsTestSuite;
     1111 +import at.ssw.hotswap.test.mutator.MutatorTestSuite;
     1112 +import at.ssw.hotswap.test.structural.StructuralTestSuite;
     1113 +
     1114 +/**
     1115 + * Summarizes all available test suites.
     1116 + * 
     1117 + * @author Thomas Wuerthinger
     1118 + */
     1119 +@RunWith(Suite.class)
     1120 +@Suite.SuiteClasses({
     1121 +    BodyTestSuite.class,
     1122 +    EvalTestSuite.class,
     1123 +    MethodsTestSuite.class,
     1124 +    FieldsTestSuite.class,
     1125 +    StructuralTestSuite.class,
     1126 +    MutatorTestSuite.class
     1127 +})
     1128 +public class CompleteTestSuite {
     1129 +}
     1130 diff -r 1999f5b12482 hotswaptest/HotSwapTests/src/at/ssw/hotswap/test/Main.java
     1131 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
     1132 +++ b/hotswaptest/HotSwapTests/src/at/ssw/hotswap/test/Main.java	Tue Feb 02 16:40:23 2010 +0100
     1133 @@ -0,0 +1,129 @@
     1134 +/*
     1135 + * Copyright 1997-2009 Sun Microsystems, Inc.  All Rights Reserved.
     1136 + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
     1137 + *
     1138 + * This code is free software; you can redistribute it and/or modify it
     1139 + * under the terms of the GNU General Public License version 2 only, as
     1140 + * published by the Free Software Foundation.
     1141 + *
     1142 + * This code is distributed in the hope that it will be useful, but WITHOUT
     1143 + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
     1144 + * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
     1145 + * version 2 for more details (a copy is included in the LICENSE file that
     1146 + * accompanied this code).
     1147 + *
     1148 + * You should have received a copy of the GNU General Public License version
     1149 + * 2 along with this work; if not, write to the Free Software Foundation,
     1150 + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
     1151 + *
     1152 + * Please contact Sun Microsystems, Inc., 4150 Network Circle, Santa Clara,
     1153 + * CA 95054 USA or visit www.sun.com if you need additional information or
     1154 + * have any questions.
     1155 + *
     1156 + */
     1157 +
     1158 +package at.ssw.hotswap.test;
     1159 +
     1160 +import org.junit.runner.Description;
     1161 +import org.junit.runner.JUnitCore;
     1162 +import org.junit.runner.Request;
     1163 +import org.junit.runner.manipulation.Filter;
     1164 +import org.junit.runner.notification.Failure;
     1165 +import org.junit.runner.notification.RunListener;
     1166 +
     1167 +/**
     1168 + * Main class for running class redefinition tests. Make sure that the execution directory is set such that this class file
     1169 + * can be reached via "at/ssw/hotswap/test/Main.class".
     1170 + * 
     1171 + * There are different levels of redefinition:
     1172 + * BodyTestSuite < MethodsTestSuite < FieldsTestSuite < StructuralTestSuite
     1173 + * 
     1174 + * Make sure that the application is started with a Java debug agent on port 4000. If you specify an argument, only tests
     1175 + * containing the specified string are executed.
     1176 + * 
     1177 + * Example usage:
     1178 + * <pre>java -Xdebug -Xrunjdwp:transport=dt_socket,server=y,address=4000,suspend=n at.ssw.hotswap.test.Main SimpleTest</pre>
     1179 + * 
     1180 + * @author Thomas Wuerthinger
     1181 + *
     1182 + */
     1183 +public class Main {
     1184 +
     1185 +    private static int failedCount;
     1186 +    private static int finishedCount;
     1187 +    private static String failureString = "";
     1188 +
     1189 +    public static void main(final String[] args) {
     1190 +        System.out.println("Running JUnit tests: ");
     1191 +
     1192 +        JUnitCore core = new JUnitCore();
     1193 +        core.addListener(runListener);
     1194 +
     1195 +        Request request = Request.classes(CompleteTestSuite.class);
     1196 +        
     1197 +        // Filter the request?
     1198 +        if (args.length == 1) {
     1199 +
     1200 +            System.out.println("Only run tests containing \"" + args[0] + "\"");
     1201 +
     1202 +            request = request.filterWith(new Filter() {
     1203 +
     1204 +                @Override
     1205 +                public String describe() {
     1206 +                    return "Filter";
     1207 +                }
     1208 +
     1209 +                @Override
     1210 +                public boolean shouldRun(Description d) {
     1211 +
     1212 +                    if (d.getDisplayName().contains(args[0])) {
     1213 +                        return true;
     1214 +                    }
     1215 +
     1216 +                    // explicitly check if any children want to run
     1217 +                    for (Description each : d.getChildren()) {
     1218 +                        if (shouldRun(each)) {
     1219 +                            return true;
     1220 +                        }
     1221 +                    }
     1222 +
     1223 +                    return false;
     1224 +                }
     1225 +            });
     1226 +        }
     1227 +
     1228 +        long startTime = System.currentTimeMillis();
     1229 +        core.run(request);
     1230 +        long time = System.currentTimeMillis() - startTime;
     1231 +
     1232 +        System.out.println("" + (finishedCount - failedCount) + " of " + finishedCount + " tests are OK!");
     1233 +        System.out.println("Time: " + ((double) time) / 1000);
     1234 +        if (failedCount == 0) {
     1235 +            System.out.println("ALL OK");
     1236 +        } else {
     1237 +            System.out.println(failedCount + " FAILURES: " + failureString);
     1238 +        }
     1239 +    }
     1240 +    private static RunListener runListener = new RunListener() {
     1241 +
     1242 +        @Override
     1243 +        public void testStarted(Description description) throws Exception {
     1244 +            System.out.println("============================================================");
     1245 +            System.out.println("Test started: " + description.getDisplayName());
     1246 +        }
     1247 +
     1248 +        @Override
     1249 +        public void testFailure(Failure failure) throws Exception {
     1250 +            System.out.println("Test failure: " + failure.getMessage());
     1251 +            failure.getException().printStackTrace();
     1252 +            failedCount++;
     1253 +            failureString += failure.getDescription().getDisplayName() + " ";
     1254 +        }
     1255 +
     1256 +        @Override
     1257 +        public void testFinished(Description description) throws Exception {
     1258 +            System.out.println("Test finished: " + description.getDisplayName());
     1259 +            finishedCount++;
     1260 +        }
     1261 +    };
     1262 +}
     1263 diff -r 1999f5b12482 hotswaptest/HotSwapTests/src/at/ssw/hotswap/test/TestUtil.java
     1264 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
     1265 +++ b/hotswaptest/HotSwapTests/src/at/ssw/hotswap/test/TestUtil.java	Tue Feb 02 16:40:23 2010 +0100
     1266 @@ -0,0 +1,50 @@
     1267 +/*
     1268 + * Copyright 1997-2009 Sun Microsystems, Inc.  All Rights Reserved.
     1269 + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
     1270 + *
     1271 + * This code is free software; you can redistribute it and/or modify it
     1272 + * under the terms of the GNU General Public License version 2 only, as
     1273 + * published by the Free Software Foundation.
     1274 + *
     1275 + * This code is distributed in the hope that it will be useful, but WITHOUT
     1276 + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
     1277 + * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
     1278 + * version 2 for more details (a copy is included in the LICENSE file that
     1279 + * accompanied this code).
     1280 + *
     1281 + * You should have received a copy of the GNU General Public License version
     1282 + * 2 along with this work; if not, write to the Free Software Foundation,
     1283 + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
     1284 + *
     1285 + * Please contact Sun Microsystems, Inc., 4150 Network Circle, Santa Clara,
     1286 + * CA 95054 USA or visit www.sun.com if you need additional information or
     1287 + * have any questions.
     1288 + *
     1289 + */
     1290 +
     1291 +package at.ssw.hotswap.test;
     1292 +
     1293 +import junit.framework.Assert;
     1294 +
     1295 +/**
     1296 + *
     1297 + * Utility methods for unit testing.
     1298 + *
     1299 + * @author Thomas Wuerthinger
     1300 + */
     1301 +public class TestUtil {
     1302 +
     1303 +    public static void assertException(Class exceptionClass, Runnable run) {
     1304 +
     1305 +        try {
     1306 +            run.run();
     1307 +        } catch(Throwable t) {
     1308 +            if (t.getClass().equals(exceptionClass)) {
     1309 +                return;
     1310 +            }
     1311 +            Assert.assertTrue("An exception of type " + t.getClass().getSimpleName() + " instead of " + exceptionClass.getSimpleName() + " has been thrown!", false);
     1312 +        }
     1313 +
     1314 +        Assert.assertTrue("No exception has been thrown!", false);
     1315 +    }
     1316 +}
     1317 diff -r 1999f5b12482 hotswaptest/HotSwapTests/src/at/ssw/hotswap/test/body/BodyTestSuite.java
     1318 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
     1319 +++ b/hotswaptest/HotSwapTests/src/at/ssw/hotswap/test/body/BodyTestSuite.java	Tue Feb 02 16:40:23 2010 +0100
     1320 @@ -0,0 +1,52 @@
     1321 +/*
     1322 + * Copyright 1997-2009 Sun Microsystems, Inc.  All Rights Reserved.
     1323 + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
     1324 + *
     1325 + * This code is free software; you can redistribute it and/or modify it
     1326 + * under the terms of the GNU General Public License version 2 only, as
     1327 + * published by the Free Software Foundation.
     1328 + *
     1329 + * This code is distributed in the hope that it will be useful, but WITHOUT
     1330 + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
     1331 + * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
     1332 + * version 2 for more details (a copy is included in the LICENSE file that
     1333 + * accompanied this code).
     1334 + *
     1335 + * You should have received a copy of the GNU General Public License version
     1336 + * 2 along with this work; if not, write to the Free Software Foundation,
     1337 + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
     1338 + *
     1339 + * Please contact Sun Microsystems, Inc., 4150 Network Circle, Santa Clara,
     1340 + * CA 95054 USA or visit www.sun.com if you need additional information or
     1341 + * have any questions.
     1342 + *
     1343 + */
     1344 +
     1345 +package at.ssw.hotswap.test.body;
     1346 +
     1347 +import org.junit.runner.RunWith;
     1348 +import org.junit.runners.Suite;
     1349 +
     1350 +/**
     1351 + * 
     1352 + * Class redefinition tests that swap only method bodies and change nothing else. This test cases should also
     1353 + * run with the current version of HotSpot.
     1354 + * 
     1355 + * @author Thomas Wuerthinger
     1356 + *
     1357 + */
     1358 +@RunWith(Suite.class)
     1359 +@Suite.SuiteClasses(
     1360 +{
     1361 +    StaticTest.class,
     1362 +    SimpleStaticTest.class,
     1363 +    MultipleThreadsTest.class,
     1364 +    OldActivationTest.class,
     1365 +    RefactorActiveMethodTest.class,
     1366 +    StressTest.class,
     1367 +    FacTest.class,
     1368 +    FibTest.class,
     1369 +    RedefinePrivateMethodTest.class
     1370 +})
     1371 +public class BodyTestSuite {
     1372 +}
     1373 diff -r 1999f5b12482 hotswaptest/HotSwapTests/src/at/ssw/hotswap/test/body/FacTest.java
     1374 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
     1375 +++ b/hotswaptest/HotSwapTests/src/at/ssw/hotswap/test/body/FacTest.java	Tue Feb 02 16:40:23 2010 +0100
     1376 @@ -0,0 +1,104 @@
     1377 +/*
     1378 + * Copyright 1997-2009 Sun Microsystems, Inc.  All Rights Reserved.
     1379 + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
     1380 + *
     1381 + * This code is free software; you can redistribute it and/or modify it
     1382 + * under the terms of the GNU General Public License version 2 only, as
     1383 + * published by the Free Software Foundation.
     1384 + *
     1385 + * This code is distributed in the hope that it will be useful, but WITHOUT
     1386 + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
     1387 + * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
     1388 + * version 2 for more details (a copy is included in the LICENSE file that
     1389 + * accompanied this code).
     1390 + *
     1391 + * You should have received a copy of the GNU General Public License version
     1392 + * 2 along with this work; if not, write to the Free Software Foundation,
     1393 + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
     1394 + *
     1395 + * Please contact Sun Microsystems, Inc., 4150 Network Circle, Santa Clara,
     1396 + * CA 95054 USA or visit www.sun.com if you need additional information or
     1397 + * have any questions.
     1398 + *
     1399 + */
     1400 +
     1401 +package at.ssw.hotswap.test.body;
     1402 +
     1403 +import static org.junit.Assert.*;
     1404 +
     1405 +import org.junit.Before;
     1406 +
     1407 +import org.junit.Test;
     1408 +
     1409 +import at.ssw.hotswap.HotSwapTool;
     1410 +
     1411 +/**
     1412 + * Recursive implementation of the factorial function using class redefinition.
     1413 + *
     1414 + * @author Thomas Wuerthinger
     1415 + */
     1416 +public class FacTest {
     1417 +
     1418 +    public static abstract class Base {
     1419 +
     1420 +        protected int calc() {
     1421 +            return calc(HotSwapTool.getCurrentVersion(FacTest.class));
     1422 +        }
     1423 +
     1424 +        public int calcAt(int version) {
     1425 +            HotSwapTool.toVersion(FacTest.class, version);
     1426 +            int result = calc();
     1427 +            HotSwapTool.toVersion(FacTest.class, 0);
     1428 +            return result;
     1429 +        }
     1430 +
     1431 +        protected int calc(int version) {
     1432 +            return calc();
     1433 +        }
     1434 +    }
     1435 +
     1436 +    public static class Factorial extends Base {
     1437 +
     1438 +        @Override
     1439 +        protected int calc(int n) {
     1440 +            return n * calcAt(n - 1);
     1441 +        }
     1442 +    }
     1443 +
     1444 +    public static class Factorial___1 extends Base {
     1445 +
     1446 +        @Override
     1447 +        protected int calc() {
     1448 +            return 1;
     1449 +        }
     1450 +    }
     1451 +
     1452 +    @Before
     1453 +    public void setUp() throws Exception {
     1454 +        HotSwapTool.toVersion(FacTest.class, 0);
     1455 +    }
     1456 +
     1457 +    @Test
     1458 +    public void testFac() {
     1459 +
     1460 +        assert HotSwapTool.getCurrentVersion(FacTest.class) == 0;
     1461 +        Factorial f = new Factorial();
     1462 +
     1463 +        assertEquals(1, f.calcAt(1));
     1464 +
     1465 +        assert HotSwapTool.getCurrentVersion(FacTest.class) == 0;
     1466 +        assertEquals(2, f.calcAt(2));
     1467 +
     1468 +        assert HotSwapTool.getCurrentVersion(FacTest.class) == 0;
     1469 +        assertEquals(6, f.calcAt(3));
     1470 +
     1471 +        assert HotSwapTool.getCurrentVersion(FacTest.class) == 0;
     1472 +        assertEquals(24, f.calcAt(4));
     1473 +
     1474 +        assert HotSwapTool.getCurrentVersion(FacTest.class) == 0;
     1475 +        assertEquals(120, f.calcAt(5));
     1476 +
     1477 +        assert HotSwapTool.getCurrentVersion(FacTest.class) == 0;
     1478 +        assertEquals(479001600, f.calcAt(12));
     1479 +    }
     1480 +}
     1481 diff -r 1999f5b12482 hotswaptest/HotSwapTests/src/at/ssw/hotswap/test/body/FibTest.java
     1482 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
     1483 +++ b/hotswaptest/HotSwapTests/src/at/ssw/hotswap/test/body/FibTest.java	Tue Feb 02 16:40:23 2010 +0100
     1484 @@ -0,0 +1,111 @@
     1485 +/*
     1486 + * Copyright 1997-2009 Sun Microsystems, Inc.  All Rights Reserved.
     1487 + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
     1488 + *
     1489 + * This code is free software; you can redistribute it and/or modify it
     1490 + * under the terms of the GNU General Public License version 2 only, as
     1491 + * published by the Free Software Foundation.
     1492 + *
     1493 + * This code is distributed in the hope that it will be useful, but WITHOUT
     1494 + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
     1495 + * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
     1496 + * version 2 for more details (a copy is included in the LICENSE file that
     1497 + * accompanied this code).
     1498 + *
     1499 + * You should have received a copy of the GNU General Public License version
     1500 + * 2 along with this work; if not, write to the Free Software Foundation,
     1501 + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
     1502 + *
     1503 + * Please contact Sun Microsystems, Inc., 4150 Network Circle, Santa Clara,
     1504 + * CA 95054 USA or visit www.sun.com if you need additional information or
     1505 + * have any questions.
     1506 + *
     1507 + */
     1508 +
     1509 +package at.ssw.hotswap.test.body;
     1510 +
     1511 +import static org.junit.Assert.*;
     1512 +
     1513 +import org.junit.Before;
     1514 +
     1515 +import org.junit.Test;
     1516 +
     1517 +import at.ssw.hotswap.HotSwapTool;
     1518 +
     1519 +/**
     1520 + * Recursive implementation of the fibonacci function using class redefinition.
     1521 + *
     1522 + * @author Thomas Wuerthinger
     1523 + */
     1524 +public class FibTest {
     1525 +
     1526 +    public static abstract class Base {
     1527 +
     1528 +        protected int calc() {
     1529 +            return calc(HotSwapTool.getCurrentVersion(FibTest.class));
     1530 +        }
     1531 +
     1532 +        public int calcAt(int version) {
     1533 +            HotSwapTool.toVersion(FibTest.class, version);
     1534 +            int result = calc();
     1535 +            HotSwapTool.toVersion(FibTest.class, 0);
     1536 +            return result;
     1537 +        }
     1538 +
     1539 +        protected int calc(int version) {
     1540 +            return calc();
     1541 +        }
     1542 +    }
     1543 +
     1544 +    public static class Fib extends Base {
     1545 +
     1546 +        @Override
     1547 +        protected int calc(int n) {
     1548 +            return calcAt(n - 1) + calcAt(n - 2);
     1549 +        }
     1550 +    }
     1551 +
     1552 +    public static class Fib___1 extends Base {
     1553 +
     1554 +        @Override
     1555 +        protected int calc() {
     1556 +            return 1;
     1557 +        }
     1558 +    }
     1559 +
     1560 +    public static class Fib___2 extends Base {
     1561 +
     1562 +        @Override
     1563 +        protected int calc() {
     1564 +            return 2;
     1565 +        }
     1566 +    }
     1567 +
     1568 +    @Before
     1569 +    public void setUp() throws Exception {
     1570 +        HotSwapTool.toVersion(FibTest.class, 0);
     1571 +    }
     1572 +
     1573 +    @Test
     1574 +    public void testFib() {
     1575 +
     1576 +        // 0 1 2 3 4 5
     1577 +        // 1 1 2 3 5 8
     1578 +        assert HotSwapTool.getCurrentVersion(FibTest.class) == 0;
     1579 +        Fib f = new Fib();
     1580 +
     1581 +        assertEquals(1, f.calcAt(1));
     1582 +
     1583 +        assert HotSwapTool.getCurrentVersion(FibTest.class) == 0;
     1584 +        assertEquals(2, f.calcAt(2));
     1585 +
     1586 +        assert HotSwapTool.getCurrentVersion(FibTest.class) == 0;
     1587 +        assertEquals(3, f.calcAt(3));
     1588 +
     1589 +        assert HotSwapTool.getCurrentVersion(FibTest.class) == 0;
     1590 +        assertEquals(5, f.calcAt(4));
     1591 +
     1592 +        assert HotSwapTool.getCurrentVersion(FibTest.class) == 0;
     1593 +        assertEquals(8, f.calcAt(5));
     1594 +    }
     1595 +}
     1596 diff -r 1999f5b12482 hotswaptest/HotSwapTests/src/at/ssw/hotswap/test/body/MultipleThreadsTest.java
     1597 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
     1598 +++ b/hotswaptest/HotSwapTests/src/at/ssw/hotswap/test/body/MultipleThreadsTest.java	Tue Feb 02 16:40:23 2010 +0100
     1599 @@ -0,0 +1,193 @@
     1600 +/*
     1601 + * Copyright 1997-2009 Sun Microsystems, Inc.  All Rights Reserved.
     1602 + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
     1603 + *
     1604 + * This code is free software; you can redistribute it and/or modify it
     1605 + * under the terms of the GNU General Public License version 2 only, as
     1606 + * published by the Free Software Foundation.
     1607 + *
     1608 + * This code is distributed in the hope that it will be useful, but WITHOUT
     1609 + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
     1610 + * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
     1611 + * version 2 for more details (a copy is included in the LICENSE file that
     1612 + * accompanied this code).
     1613 + *
     1614 + * You should have received a copy of the GNU General Public License version
     1615 + * 2 along with this work; if not, write to the Free Software Foundation,
     1616 + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
     1617 + *
     1618 + * Please contact Sun Microsystems, Inc., 4150 Network Circle, Santa Clara,
     1619 + * CA 95054 USA or visit www.sun.com if you need additional information or
     1620 + * have any questions.
     1621 + *
     1622 + */
     1623 +
     1624 +package at.ssw.hotswap.test.body;
     1625 +
     1626 +import static org.junit.Assert.*;
     1627 +
     1628 +import org.junit.Before;
     1629 +import org.junit.Test;
     1630 +
     1631 +import at.ssw.hotswap.HotSwapTool;
     1632 +import at.ssw.hotswap.test.methods.OverrideMethodTest;
     1633 +
     1634 +/**
     1635 + * Class for testing redefining methods of classes that extend the Thread class. In the test setup the run method
     1636 + * calls the doit method in a loop until this methods returns false.
     1637 + *
     1638 + * @author Thomas Wuerthinger
     1639 + */
     1640 +public class MultipleThreadsTest {
     1641 +
     1642 +    public static final int COUNT = 10;
     1643 +
     1644 +    // Version 0
     1645 +    public static class A extends Thread {
     1646 +
     1647 +        private int value;
     1648 +        private int value2;
     1649 +
     1650 +        @Override
     1651 +        public void run() {
     1652 +            while (doit()) {
     1653 +            }
     1654 +        }
     1655 +
     1656 +        public boolean doit() {
     1657 +            try {
     1658 +                Thread.sleep(1);
     1659 +            } catch (InterruptedException e) {
     1660 +            }
     1661 +
     1662 +            value++;
     1663 +            return true;
     1664 +        }
     1665 +
     1666 +        public int getValue() {
     1667 +            return value;
     1668 +        }
     1669 +
     1670 +        public int getValue2() {
     1671 +            return value2;
     1672 +        }
     1673 +    }
     1674 +
     1675 +    // Version 1
     1676 +    public static class A___1 extends Thread {
     1677 +
     1678 +        private int value;
     1679 +        private int value2;
     1680 +
     1681 +        @Override
     1682 +        public void run() {
     1683 +            while (doit()) {
     1684 +            }
     1685 +        }
     1686 +
     1687 +        public boolean doit() {
     1688 +            try {
     1689 +                Thread.sleep(1);
     1690 +            } catch (InterruptedException e) {
     1691 +            }
     1692 +
     1693 +            value2++;
     1694 +            return true;
     1695 +        }
     1696 +
     1697 +        public int getValue() {
     1698 +            return value;
     1699 +        }
     1700 +
     1701 +        public int getValue2() {
     1702 +            return value2;
     1703 +        }
     1704 +    }
     1705 +
     1706 +    // Version 2
     1707 +    public static class A___2 extends Thread {
     1708 +
     1709 +        private int value;
     1710 +        private int value2;
     1711 +
     1712 +        @Override
     1713 +        public void run() {
     1714 +            while (doit()) {
     1715 +            }
     1716 +        }
     1717 +
     1718 +        public boolean doit() {
     1719 +            return false;
     1720 +        }
     1721 +
     1722 +        public int getValue() {
     1723 +            return value;
     1724 +        }
     1725 +
     1726 +        public int getValue2() {
     1727 +            return value2;
     1728 +        }
     1729 +    }
     1730 +
     1731 +    @Before
     1732 +    public void setUp() throws Exception {
     1733 +        HotSwapTool.toVersion(MultipleThreadsTest.class, 0);
     1734 +    }
     1735 +
     1736 +    @Test
     1737 +    public void testOneThread() {
     1738 +        test(1);
     1739 +    }
     1740 +
     1741 +    @Test
     1742 +    public void testThreads() {
     1743 +        test(COUNT);
     1744 +    }
     1745 +
     1746 +    private void test(int count) {
     1747 +
     1748 +        assert HotSwapTool.getCurrentVersion(MultipleThreadsTest.class) == 0;
     1749 +
     1750 +        A[] arr = new A[count];
     1751 +        for (int i = 0; i < count; i++) {
     1752 +            arr[i] = new A();
     1753 +            arr[i].start();
     1754 +        }
     1755 +
     1756 +        try {
     1757 +            Thread.sleep(500);
     1758 +        } catch (InterruptedException e) {
     1759 +        }
     1760 +
     1761 +        for (int i = 0; i < count; i++) {
     1762 +            assertTrue(arr[i].getValue() > 0);
     1763 +        }
     1764 +
     1765 +        HotSwapTool.toVersion(MultipleThreadsTest.class, 1);
     1766 +
     1767 +        try {
     1768 +            Thread.sleep(500);
     1769 +        } catch (InterruptedException e) {
     1770 +        }
     1771 +
     1772 +        for (int i = 0; i < count; i++) {
     1773 +            assertTrue(arr[i].getValue2() > 0);
     1774 +        }
     1775 +
     1776 +        HotSwapTool.toVersion(MultipleThreadsTest.class, 2);
     1777 +
     1778 +        try {
     1779 +            Thread.sleep(500);
     1780 +        } catch (InterruptedException e) {
     1781 +        }
     1782 +
     1783 +
     1784 +        for (int i = 0; i < count; i++) {
     1785 +            assertFalse(arr[i].isAlive());
     1786 +        }
     1787 +
     1788 +        HotSwapTool.toVersion(OverrideMethodTest.class, 0);
     1789 +
     1790 +
     1791 +    }
     1792 +}
     1793 diff -r 1999f5b12482 hotswaptest/HotSwapTests/src/at/ssw/hotswap/test/body/OldActivationTest.java
     1794 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
     1795 +++ b/hotswaptest/HotSwapTests/src/at/ssw/hotswap/test/body/OldActivationTest.java	Tue Feb 02 16:40:23 2010 +0100
     1796 @@ -0,0 +1,158 @@
     1797 +/*
     1798 + * Copyright 1997-2009 Sun Microsystems, Inc.  All Rights Reserved.
     1799 + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
     1800 + *
     1801 + * This code is free software; you can redistribute it and/or modify it
     1802 + * under the terms of the GNU General Public License version 2 only, as
     1803 + * published by the Free Software Foundation.
     1804 + *
     1805 + * This code is distributed in the hope that it will be useful, but WITHOUT
     1806 + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
     1807 + * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
     1808 + * version 2 for more details (a copy is included in the LICENSE file that
     1809 + * accompanied this code).
     1810 + *
     1811 + * You should have received a copy of the GNU General Public License version
     1812 + * 2 along with this work; if not, write to the Free Software Foundation,
     1813 + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
     1814 + *
     1815 + * Please contact Sun Microsystems, Inc., 4150 Network Circle, Santa Clara,
     1816 + * CA 95054 USA or visit www.sun.com if you need additional information or
     1817 + * have any questions.
     1818 + *
     1819 + */
     1820 +
     1821 +package at.ssw.hotswap.test.body;
     1822 +
     1823 +import static org.junit.Assert.*;
     1824 +
     1825 +import org.junit.Before;
     1826 +import org.junit.Test;
     1827 +
     1828 +import at.ssw.hotswap.HotSwapTool;
     1829 +
     1830 +/**
     1831 + * Stress test for the number of old activations on the stack. In the test setup 10 different versions of the method A.value will be on the stack.
     1832 + *
     1833 + * @author Thomas Wuerthinger
     1834 + */
     1835 +public class OldActivationTest {
     1836 +
     1837 +    // Version 0
     1838 +    public static class A {
     1839 +
     1840 +        public int value() {
     1841 +            HotSwapTool.toVersion(OldActivationTest.class, 1);
     1842 +            return 1 + this.value();
     1843 +        }
     1844 +    }
     1845 +
     1846 +    // Version 1
     1847 +    public static class A___1 {
     1848 +
     1849 +        public int value() {
     1850 +            HotSwapTool.toVersion(OldActivationTest.class, 2);
     1851 +            return 2 + this.value();
     1852 +        }
     1853 +    }
     1854 +
     1855 +    // Version 2
     1856 +    public static class A___2 {
     1857 +
     1858 +        public int value() {
     1859 +            HotSwapTool.toVersion(OldActivationTest.class, 3);
     1860 +            return 3 + this.value();
     1861 +        }
     1862 +    }
     1863 +
     1864 +    // Version 3
     1865 +    public static class A___3 {
     1866 +
     1867 +        public int value() {
     1868 +            HotSwapTool.toVersion(OldActivationTest.class, 4);
     1869 +            return 4 + this.value();
     1870 +        }
     1871 +    }
     1872 +
     1873 +    // Version 4
     1874 +    public static class A___4 {
     1875 +
     1876 +        public int value() {
     1877 +            HotSwapTool.toVersion(OldActivationTest.class, 5);
     1878 +            return 5 + this.value();
     1879 +        }
     1880 +    }
     1881 +
     1882 +    // Version 5
     1883 +    public static class A___5 {
     1884 +
     1885 +        public int value() {
     1886 +            HotSwapTool.toVersion(OldActivationTest.class, 6);
     1887 +            return 6 + this.value();
     1888 +        }
     1889 +    }
     1890 +
     1891 +    // Version 6
     1892 +    public static class A___6 {
     1893 +
     1894 +        public int value() {
     1895 +            HotSwapTool.toVersion(OldActivationTest.class, 7);
     1896 +            return 7 + this.value();
     1897 +        }
     1898 +    }
     1899 +
     1900 +    // Version 7
     1901 +    public static class A___7 {
     1902 +
     1903 +        public int value() {
     1904 +            HotSwapTool.toVersion(OldActivationTest.class, 8);
     1905 +            return 8 + this.value();
     1906 +        }
     1907 +    }
     1908 +
     1909 +    // Version 8
     1910 +    public static class A___8 {
     1911 +
     1912 +        public int value() {
     1913 +            HotSwapTool.toVersion(OldActivationTest.class, 9);
     1914 +            return 9 + this.value();
     1915 +        }
     1916 +    }
     1917 +
     1918 +    // Version 9
     1919 +    public static class A___9 {
     1920 +
     1921 +        public int value() {
     1922 +            HotSwapTool.toVersion(OldActivationTest.class, 0);
     1923 +            return 10;
     1924 +        }
     1925 +    }
     1926 +
     1927 +    @Before
     1928 +    public void setUp() throws Exception {
     1929 +        HotSwapTool.toVersion(OldActivationTest.class, 0);
     1930 +    }
     1931 +
     1932 +    @Test
     1933 +    public void testOldActivationTest() {
     1934 +
     1935 +        assert HotSwapTool.getCurrentVersion(OldActivationTest.class) == 0;
     1936 +
     1937 +        A a = new A();
     1938 +
     1939 +        assertEquals(1 + 2 + 3 + 4 + 5 + 6 + 7 + 8 + 9 + 10, a.value());
     1940 +        assert HotSwapTool.getCurrentVersion(OldActivationTest.class) == 0;
     1941 +
     1942 +        HotSwapTool.toVersion(OldActivationTest.class, 1);
     1943 +        assertEquals(2 + 3 + 4 + 5 + 6 + 7 + 8 + 9 + 10, a.value());
     1944 +        assert HotSwapTool.getCurrentVersion(OldActivationTest.class) == 0;
     1945 +
     1946 +        HotSwapTool.toVersion(OldActivationTest.class, 8);
     1947 +        assertEquals(9 + 10, a.value());
     1948 +        assert HotSwapTool.getCurrentVersion(OldActivationTest.class) == 0;
     1949 +
     1950 +        HotSwapTool.toVersion(OldActivationTest.class, 4);
     1951 +        assertEquals(5 + 6 + 7 + 8 + 9 + 10, a.value());
     1952 +        assert HotSwapTool.getCurrentVersion(OldActivationTest.class) == 0;
     1953 +    }
     1954 +}
     1955 diff -r 1999f5b12482 hotswaptest/HotSwapTests/src/at/ssw/hotswap/test/body/RedefinePrivateMethodTest.java
     1956 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
     1957 +++ b/hotswaptest/HotSwapTests/src/at/ssw/hotswap/test/body/RedefinePrivateMethodTest.java	Tue Feb 02 16:40:23 2010 +0100
     1958 @@ -0,0 +1,96 @@
     1959 +/*
     1960 + * Copyright 1997-2009 Sun Microsystems, Inc.  All Rights Reserved.
     1961 + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
     1962 + *
     1963 + * This code is free software; you can redistribute it and/or modify it
     1964 + * under the terms of the GNU General Public License version 2 only, as
     1965 + * published by the Free Software Foundation.
     1966 + *
     1967 + * This code is distributed in the hope that it will be useful, but WITHOUT
     1968 + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
     1969 + * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
     1970 + * version 2 for more details (a copy is included in the LICENSE file that
     1971 + * accompanied this code).
     1972 + *
     1973 + * You should have received a copy of the GNU General Public License version
     1974 + * 2 along with this work; if not, write to the Free Software Foundation,
     1975 + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
     1976 + *
     1977 + * Please contact Sun Microsystems, Inc., 4150 Network Circle, Santa Clara,
     1978 + * CA 95054 USA or visit www.sun.com if you need additional information or
     1979 + * have any questions.
     1980 + *
     1981 + */
     1982 +
     1983 +package at.ssw.hotswap.test.body;
     1984 +
     1985 +import static org.junit.Assert.*;
     1986 +
     1987 +import org.junit.Before;
     1988 +import org.junit.Test;
     1989 +
     1990 +import at.ssw.hotswap.HotSwapTool;
     1991 +
     1992 +/**
     1993 + * Tests redefinition of a class such that old code still accesses a redefined private method.
     1994 + *
     1995 + * @author Thomas Wuerthinger
     1996 + */
     1997 +public class RedefinePrivateMethodTest {
     1998 +
     1999 +    // Version 0
     2000 +    public static class A {
     2001 +
     2002 +        public int foo() {
     2003 +            int result = bar();
     2004 +            HotSwapTool.toVersion(RedefinePrivateMethodTest.class, 1);
     2005 +            result += bar();
     2006 +            return result;
     2007 +        }
     2008 +
     2009 +        private int bar() {
     2010 +            return 1;
     2011 +        }
     2012 +    }
     2013 +
     2014 +    // Version 1
     2015 +    public static class A___1 {
     2016 +
     2017 +        public int foo() {
     2018 +            return -1;
     2019 +        }
     2020 +
     2021 +        private int bar() {
     2022 +            return 2;
     2023 +        }
     2024 +    }
     2025 +
     2026 +    @Before
     2027 +    public void setUp() throws Exception {
     2028 +        HotSwapTool.toVersion(RedefinePrivateMethodTest.class, 0);
     2029 +    }
     2030 +
     2031 +    @Test
     2032 +    public void testRedefinePrivateMethod() {
     2033 +
     2034 +        assert HotSwapTool.getCurrentVersion(RedefinePrivateMethodTest.class) == 0;
     2035 +
     2036 +        A a = new A();
     2037 +
     2038 +        assertEquals(3, a.foo());
     2039 +
     2040 +        assert HotSwapTool.getCurrentVersion(RedefinePrivateMethodTest.class) == 1;
     2041 +
     2042 +        assertEquals(-1, a.foo());
     2043 +
     2044 +        HotSwapTool.toVersion(RedefinePrivateMethodTest.class, 0);
     2045 +
     2046 +        assertEquals(3, a.foo());
     2047 +
     2048 +        assert HotSwapTool.getCurrentVersion(RedefinePrivateMethodTest.class) == 1;
     2049 +
     2050 +        assertEquals(-1, a.foo());
     2051 +
     2052 +        HotSwapTool.toVersion(RedefinePrivateMethodTest.class, 0);
     2053 +    }
     2054 +}
     2055 diff -r 1999f5b12482 hotswaptest/HotSwapTests/src/at/ssw/hotswap/test/body/RefactorActiveMethodTest.java
     2056 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
     2057 +++ b/hotswaptest/HotSwapTests/src/at/ssw/hotswap/test/body/RefactorActiveMethodTest.java	Tue Feb 02 16:40:23 2010 +0100
     2058 @@ -0,0 +1,96 @@
     2059 +/*
     2060 + * Copyright 1997-2009 Sun Microsystems, Inc.  All Rights Reserved.
     2061 + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
     2062 + *
     2063 + * This code is free software; you can redistribute it and/or modify it
     2064 + * under the terms of the GNU General Public License version 2 only, as
     2065 + * published by the Free Software Foundation.
     2066 + *
     2067 + * This code is distributed in the hope that it will be useful, but WITHOUT
     2068 + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
     2069 + * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
     2070 + * version 2 for more details (a copy is included in the LICENSE file that
     2071 + * accompanied this code).
     2072 + *
     2073 + * You should have received a copy of the GNU General Public License version
     2074 + * 2 along with this work; if not, write to the Free Software Foundation,
     2075 + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
     2076 + *
     2077 + * Please contact Sun Microsystems, Inc., 4150 Network Circle, Santa Clara,
     2078 + * CA 95054 USA or visit www.sun.com if you need additional information or
     2079 + * have any questions.
     2080 + *
     2081 + */
     2082 +
     2083 +package at.ssw.hotswap.test.body;
     2084 +
     2085 +import static org.junit.Assert.*;
     2086 +
     2087 +import org.junit.Before;
     2088 +import org.junit.Test;
     2089 +
     2090 +import at.ssw.hotswap.HotSwapTool;
     2091 +
     2092 +/**
     2093 + * @author Thomas Wuerthinger
     2094 + */
     2095 +public class RefactorActiveMethodTest {
     2096 +
     2097 +    // Version 0
     2098 +    public static class A {
     2099 +
     2100 +        public int value() {
     2101 +            HotSwapTool.toVersion(RefactorActiveMethodTest.class, 1);
     2102 +            return 5;
     2103 +        }
     2104 +
     2105 +        public int secondValue() {
     2106 +            return 1;
     2107 +        }
     2108 +    }
     2109 +
     2110 +    // Version 1
     2111 +    public static class A___1 {
     2112 +
     2113 +        public int value() {
     2114 +            return secondValue() * 2;
     2115 +        }
     2116 +
     2117 +        public int secondValue() {
     2118 +            return 2;
     2119 +        }
     2120 +    }
     2121 +
     2122 +    @Before
     2123 +    public void setUp() throws Exception {
     2124 +        HotSwapTool.toVersion(RefactorActiveMethodTest.class, 0);
     2125 +    }
     2126 +
     2127 +    @Test
     2128 +    public void testActiveMethodReplacement() {
     2129 +
     2130 +        assert HotSwapTool.getCurrentVersion(RefactorActiveMethodTest.class) == 0;
     2131 +
     2132 +        A a = new A();
     2133 +
     2134 +        assertEquals(5, a.value());
     2135 +
     2136 +        assert HotSwapTool.getCurrentVersion(RefactorActiveMethodTest.class) == 1;
     2137 +
     2138 +        assertEquals(2, a.secondValue());
     2139 +        assertEquals(4, a.value());
     2140 +        assertEquals(2, a.secondValue());
     2141 +
     2142 +        assert HotSwapTool.getCurrentVersion(RefactorActiveMethodTest.class) == 1;
     2143 +
     2144 +        HotSwapTool.toVersion(RefactorActiveMethodTest.class, 0);
     2145 +
     2146 +        assertEquals(1, a.secondValue());
     2147 +        assertEquals(5, a.value());
     2148 +        assertEquals(4, a.value());
     2149 +
     2150 +        HotSwapTool.toVersion(RefactorActiveMethodTest.class, 0);
     2151 +
     2152 +        assertEquals(1, a.secondValue());
     2153 +    }
     2154 +}
     2155 diff -r 1999f5b12482 hotswaptest/HotSwapTests/src/at/ssw/hotswap/test/body/SimpleStaticTest.java
     2156 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
     2157 +++ b/hotswaptest/HotSwapTests/src/at/ssw/hotswap/test/body/SimpleStaticTest.java	Tue Feb 02 16:40:23 2010 +0100
     2158 @@ -0,0 +1,137 @@
     2159 +/*
     2160 + * Copyright 1997-2009 Sun Microsystems, Inc.  All Rights Reserved.
     2161 + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
     2162 + *
     2163 + * This code is free software; you can redistribute it and/or modify it
     2164 + * under the terms of the GNU General Public License version 2 only, as
     2165 + * published by the Free Software Foundation.
     2166 + *
     2167 + * This code is distributed in the hope that it will be useful, but WITHOUT
     2168 + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
     2169 + * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
     2170 + * version 2 for more details (a copy is included in the LICENSE file that
     2171 + * accompanied this code).
     2172 + *
     2173 + * You should have received a copy of the GNU General Public License version
     2174 + * 2 along with this work; if not, write to the Free Software Foundation,
     2175 + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
     2176 + *
     2177 + * Please contact Sun Microsystems, Inc., 4150 Network Circle, Santa Clara,
     2178 + * CA 95054 USA or visit www.sun.com if you need additional information or
     2179 + * have any questions.
     2180 + *
     2181 + */
     2182 +
     2183 +package at.ssw.hotswap.test.body;
     2184 +
     2185 +import static org.junit.Assert.*;
     2186 +
     2187 +import org.junit.Before;
     2188 +import org.junit.Test;
     2189 +
     2190 +import at.ssw.hotswap.HotSwapTool;
     2191 +import at.ssw.hotswap.test.TestUtil;
     2192 +
     2193 +/**
     2194 + * @author Thomas Wuerthinger
     2195 + */
     2196 +public class SimpleStaticTest {
     2197 +
     2198 +    @Before
     2199 +    public void setUp() throws Exception {
     2200 +        HotSwapTool.toVersion(SimpleStaticTest.class, 0);
     2201 +        
     2202 +        // E and Helper must be loaded and initialized
     2203 +        E e = new E();
     2204 +        Helper h = new Helper();
     2205 +    }
     2206 +
     2207 +    // Version 0
     2208 +
     2209 +    public static class Helper {
     2210 +        public static int getIntegerField() {
     2211 +            return E___2.integerField;
     2212 +        }
     2213 +
     2214 +        public static void setIntegerField(int x) {
     2215 +            E___2.integerField = x;
     2216 +        }
     2217 +
     2218 +        public static int getFinalIntegerField() {
     2219 +            return E___2.finalIntegerField;
     2220 +        }
     2221 +    }
     2222 +
     2223 +    public static class Helper___1 {
     2224 +        public static int getIntegerField() {
     2225 +            return E___2.integerField;
     2226 +        }
     2227 +
     2228 +        public static void setIntegerField(int x) {
     2229 +            E___2.integerField = x;
     2230 +        }
     2231 +
     2232 +        public static int getFinalIntegerField() {
     2233 +            return E___2.finalIntegerField;
     2234 +        }
     2235 +    }
     2236 +
     2237 +    public static class E {
     2238 +    }
     2239 +
     2240 +    public static class E___1 {
     2241 +    }
     2242 +
     2243 +    // Version 1
     2244 +    public static class E___2 {
     2245 +        public static int integerField = 10;
     2246 +
     2247 +        // javac will generate "ConstantValue" attribute for this field!
     2248 +        public static final int finalIntegerField = 7;
     2249 +    }
     2250 +
     2251 +    @Test
     2252 +    public void testSimpleNewStaticField() {
     2253 +
     2254 +        assert HotSwapTool.getCurrentVersion(SimpleStaticTest.class) == 0;
     2255 +
     2256 +        HotSwapTool.toVersion(SimpleStaticTest.class, 1);
     2257 +
     2258 +        TestUtil.assertException(NoSuchFieldError.class, new Runnable(){
     2259 +            @Override
     2260 +            public void run() {
     2261 +                Helper.getIntegerField();
     2262 +            }
     2263 +        });
     2264 +
     2265 +        HotSwapTool.toVersion(SimpleStaticTest.class, 2);
     2266 +
     2267 +        assertEquals(0, Helper.getIntegerField());
     2268 +        assertEquals(7, Helper.getFinalIntegerField());
     2269 +        Helper.setIntegerField(1000);
     2270 +        assertEquals(1000, Helper.getIntegerField());
     2271 +
     2272 +        HotSwapTool.toVersion(SimpleStaticTest.class, 1);
     2273 +
     2274 +        TestUtil.assertException(NoSuchFieldError.class, new Runnable(){
     2275 +            @Override
     2276 +            public void run() {
     2277 +                Helper.getIntegerField();
     2278 +            }
     2279 +        });
     2280 +
     2281 +        HotSwapTool.toVersion(SimpleStaticTest.class, 2);
     2282 +
     2283 +        assertEquals(0, Helper.getIntegerField());
     2284 +        assertEquals(7, Helper.getFinalIntegerField());
     2285 +        
     2286 +        HotSwapTool.toVersion(SimpleStaticTest.class, 0);
     2287 +
     2288 +        TestUtil.assertException(NoSuchFieldError.class, new Runnable(){
     2289 +            @Override
     2290 +            public void run() {
     2291 +                Helper.getIntegerField();
     2292 +            }
     2293 +        });
     2294 +    }
     2295 +}
     2296 diff -r 1999f5b12482 hotswaptest/HotSwapTests/src/at/ssw/hotswap/test/body/StaticTest.java
     2297 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
     2298 +++ b/hotswaptest/HotSwapTests/src/at/ssw/hotswap/test/body/StaticTest.java	Tue Feb 02 16:40:23 2010 +0100
     2299 @@ -0,0 +1,264 @@
     2300 +/*
     2301 + * Copyright 1997-2009 Sun Microsystems, Inc.  All Rights Reserved.
     2302 + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
     2303 + *
     2304 + * This code is free software; you can redistribute it and/or modify it
     2305 + * under the terms of the GNU General Public License version 2 only, as
     2306 + * published by the Free Software Foundation.
     2307 + *
     2308 + * This code is distributed in the hope that it will be useful, but WITHOUT
     2309 + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
     2310 + * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
     2311 + * version 2 for more details (a copy is included in the LICENSE file that
     2312 + * accompanied this code).
     2313 + *
     2314 + * You should have received a copy of the GNU General Public License version
     2315 + * 2 along with this work; if not, write to the Free Software Foundation,
     2316 + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
     2317 + *
     2318 + * Please contact Sun Microsystems, Inc., 4150 Network Circle, Santa Clara,
     2319 + * CA 95054 USA or visit www.sun.com if you need additional information or
     2320 + * have any questions.
     2321 + *
     2322 + */
     2323 +
     2324 +package at.ssw.hotswap.test.body;
     2325 +
     2326 +import static org.junit.Assert.*;
     2327 +
     2328 +import org.junit.Before;
     2329 +import org.junit.Test;
     2330 +
     2331 +import at.ssw.hotswap.HotSwapTool;
     2332 +import java.util.ArrayList;
     2333 +import java.util.List;
     2334 +
     2335 +/**
     2336 + * @author Thomas Wuerthinger
     2337 + */
     2338 +public class StaticTest {
     2339 +
     2340 +    @Before
     2341 +    public void setUp() throws Exception {
     2342 +        HotSwapTool.toVersion(StaticTest.class, 0);
     2343 +        
     2344 +        // C and D must be loaded and initialized
     2345 +        C c = new C();
     2346 +        D d = new D();
     2347 +    }
     2348 +
     2349 +    // Version 0
     2350 +
     2351 +
     2352 +    public static class Helper {
     2353 +        public static int getAdditionalField() {
     2354 +            return D___5.additionalField;
     2355 +        }
     2356 +
     2357 +        public static void setAdditionalField(int x) {
     2358 +            D___5.additionalField = x;
     2359 +        }
     2360 +    }
     2361 +
     2362 +    public static class A {
     2363 +
     2364 +        public static int value() {
     2365 +            return 1;
     2366 +        }
     2367 +    }
     2368 +
     2369 +    public static class B {
     2370 +
     2371 +        public static int value() {
     2372 +            return 2;
     2373 +        }
     2374 +    }
     2375 +
     2376 +    public static class C {
     2377 +        static {
     2378 +            System.out.println("Static initializer of C");
     2379 +        }
     2380 +
     2381 +        public static int value = 5;
     2382 +    }
     2383 +
     2384 +    public static class D {
     2385 +        public static List objectField = new ArrayList();
     2386 +        public static int[] arrayField = new int[10];
     2387 +        public static int integerField = 5;
     2388 +        public static char characterField = 6;
     2389 +        public static short shortField = 7;
     2390 +        public static double doubleField = 1.0;
     2391 +        public static float floatField = 2.0f;
     2392 +        public static long longField = 8;
     2393 +        public static boolean booleanField = true;
     2394 +    }
     2395 +
     2396 +    // Version 1
     2397 +    public static class A___1 {
     2398 +
     2399 +        public static int value() {
     2400 +            return B.value() * 2;
     2401 +        }
     2402 +    }
     2403 +
     2404 +    // Version 2
     2405 +    public static class B___2 {
     2406 +
     2407 +        public static int value() {
     2408 +            return 3;
     2409 +        }
     2410 +    }
     2411 +
     2412 +    // Version 3
     2413 +    public static class A___3 {
     2414 +
     2415 +        public static int value() {
     2416 +            return 5;
     2417 +        }
     2418 +    }
     2419 +
     2420 +    public static class B___3 {
     2421 +
     2422 +        public static int value() {
     2423 +            return A.value() * 2;
     2424 +        }
     2425 +    }
     2426 +
     2427 +    // Version 4
     2428 +    public static class C___4 {
     2429 +
     2430 +        static {
     2431 +            System.out.println("Static initializer of C-4");
     2432 +        }
     2433 +
     2434 +        public static int value = 6;
     2435 +    }
     2436 +
     2437 +
     2438 +    public static class D___5 {
     2439 +        public static int additionalField;
     2440 +
     2441 +        public static List objectField;
     2442 +        public static long longField;
     2443 +        public static short shortField = 10;
     2444 +        public static float floatField;
     2445 +        public static int[] arrayField;
     2446 +        public static int integerField;
     2447 +        public static char characterField;
     2448 +        public static double doubleField;
     2449 +        public static boolean booleanField;
     2450 +    }
     2451 +
     2452 +    @Test
     2453 +    public void testBase() {
     2454 +
     2455 +        assert HotSwapTool.getCurrentVersion(StaticTest.class) == 0;
     2456 +
     2457 +
     2458 +        assertEquals(1, A.value());
     2459 +        assertEquals(2, B.value());
     2460 +
     2461 +        HotSwapTool.toVersion(StaticTest.class, 1);
     2462 +
     2463 +        assertEquals(4, A.value());
     2464 +        assertEquals(2, B.value());
     2465 +
     2466 +        HotSwapTool.toVersion(StaticTest.class, 2);
     2467 +
     2468 +        assertEquals(6, A.value());
     2469 +        assertEquals(3, B.value());
     2470 +
     2471 +        HotSwapTool.toVersion(StaticTest.class, 3);
     2472 +
     2473 +        assertEquals(5, A.value());
     2474 +        assertEquals(10, B.value());
     2475 +
     2476 +        HotSwapTool.toVersion(StaticTest.class, 0);
     2477 +
     2478 +        assertEquals(1, A.value());
     2479 +        assertEquals(2, B.value());
     2480 +    }
     2481 +
     2482 +    @Test
     2483 +    public void testStaticField() {
     2484 +
     2485 +        assert HotSwapTool.getCurrentVersion(StaticTest.class) == 0;
     2486 +        assertEquals(5, C.value);
     2487 +
     2488 +        HotSwapTool.toVersion(StaticTest.class, 4);
     2489 +        assertEquals(5, C.value);
     2490 +
     2491 +        HotSwapTool.toVersion(StaticTest.class, 0);
     2492 +        assertEquals(5, C.value);
     2493 +    }
     2494 +
     2495 +
     2496 +    @Test
     2497 +    public void testManyStaticFields() {
     2498 +
     2499 +        assert HotSwapTool.getCurrentVersion(StaticTest.class) == 0;
     2500 +        assertTrue(D.objectField != null);
     2501 +        assertTrue(D.arrayField != null);
     2502 +        assertEquals(5, D.integerField);
     2503 +        assertEquals(6, D.characterField);
     2504 +        assertEquals(7, D.shortField);
     2505 +        assertEquals(1.0, D.doubleField, 0.0);
     2506 +        assertEquals(2.0f, D.floatField, 0.0);
     2507 +        assertEquals(8, D.longField);
     2508 +        assertEquals(true, D.booleanField);
     2509 +
     2510 +        HotSwapTool.toVersion(StaticTest.class, 5);
     2511 +        assertTrue(D.objectField != null);
     2512 +        assertTrue(D.arrayField != null);
     2513 +        assertEquals(5, D.integerField);
     2514 +        assertEquals(6, D.characterField);
     2515 +        assertEquals(7, D.shortField);
     2516 +        assertEquals(1.0, D.doubleField, 0.0);
     2517 +        assertEquals(2.0f, D.floatField, 0.0);
     2518 +        assertEquals(8, D.longField);
     2519 +        assertEquals(true, D.booleanField);
     2520 +
     2521 +        assertEquals(0, Helper.getAdditionalField());
     2522 +        Helper.setAdditionalField(1000);
     2523 +        assertEquals(1000, Helper.getAdditionalField());
     2524 +
     2525 +
     2526 +        HotSwapTool.toVersion(StaticTest.class, 0);
     2527 +
     2528 +        assertTrue(D.objectField != null);
     2529 +        assertTrue(D.arrayField != null);
     2530 +        assertEquals(5, D.integerField);
     2531 +        assertEquals(6, D.characterField);
     2532 +        assertEquals(7, D.shortField);
     2533 +        assertEquals(1.0, D.doubleField, 0.0);
     2534 +        assertEquals(2.0f, D.floatField, 0.0);
     2535 +        assertEquals(8, D.longField);
     2536 +        assertEquals(true, D.booleanField);
     2537 +
     2538 +        HotSwapTool.toVersion(StaticTest.class, 5);
     2539 +        assertTrue(D.objectField != null);
     2540 +        assertTrue(D.arrayField != null);
     2541 +        assertEquals(5, D.integerField);
     2542 +        assertEquals(6, D.characterField);
     2543 +        assertEquals(7, D.shortField);
     2544 +        assertEquals(1.0, D.doubleField, 0.0);
     2545 +        assertEquals(2.0f, D.floatField, 0.0);
     2546 +        assertEquals(8, D.longField);
     2547 +        assertEquals(true, D.booleanField);
     2548 +
     2549 +        assertEquals(0, Helper.getAdditionalField());
     2550 +
     2551 +        HotSwapTool.toVersion(StaticTest.class, 0);
     2552 +        assertTrue(D.objectField != null);
     2553 +        assertTrue(D.arrayField != null);
     2554 +        assertEquals(5, D.integerField);
     2555 +        assertEquals(6, D.characterField);
     2556 +        assertEquals(7, D.shortField);
     2557 +        assertEquals(1.0, D.doubleField, 0.0);
     2558 +        assertEquals(2.0f, D.floatField, 0.0);
     2559 +        assertEquals(8, D.longField);
     2560 +        assertEquals(true, D.booleanField);
     2561 +
     2562 +    }
     2563 +}
     2564 diff -r 1999f5b12482 hotswaptest/HotSwapTests/src/at/ssw/hotswap/test/body/StressTest.java
     2565 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
     2566 +++ b/hotswaptest/HotSwapTests/src/at/ssw/hotswap/test/body/StressTest.java	Tue Feb 02 16:40:23 2010 +0100
     2567 @@ -0,0 +1,82 @@
     2568 +/*
     2569 + * Copyright 1997-2009 Sun Microsystems, Inc.  All Rights Reserved.
     2570 + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
     2571 + *
     2572 + * This code is free software; you can redistribute it and/or modify it
     2573 + * under the terms of the GNU General Public License version 2 only, as
     2574 + * published by the Free Software Foundation.
     2575 + *
     2576 + * This code is distributed in the hope that it will be useful, but WITHOUT
     2577 + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
     2578 + * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
     2579 + * version 2 for more details (a copy is included in the LICENSE file that
     2580 + * accompanied this code).
     2581 + *
     2582 + * You should have received a copy of the GNU General Public License version
     2583 + * 2 along with this work; if not, write to the Free Software Foundation,
     2584 + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
     2585 + *
     2586 + * Please contact Sun Microsystems, Inc., 4150 Network Circle, Santa Clara,
     2587 + * CA 95054 USA or visit www.sun.com if you need additional information or
     2588 + * have any questions.
     2589 + *
     2590 + */
     2591 +
     2592 +package at.ssw.hotswap.test.body;
     2593 +
     2594 +import static org.junit.Assert.*;
     2595 +
     2596 +import org.junit.Before;
     2597 +import org.junit.Test;
     2598 +
     2599 +import at.ssw.hotswap.HotSwapTool;
     2600 +
     2601 +/**
     2602 + * @author Thomas Wuerthinger
     2603 + */
     2604 +public class StressTest {
     2605 +
     2606 +    public final static int COUNT = 10;
     2607 +
     2608 +    // Version 0
     2609 +    public static class A {
     2610 +
     2611 +        public int value() {
     2612 +            return 1;
     2613 +        }
     2614 +    }
     2615 +
     2616 +    // Version 1
     2617 +    public static class A___1 {
     2618 +
     2619 +        public int value() {
     2620 +            return 2;
     2621 +        }
     2622 +    }
     2623 +
     2624 +    @Before
     2625 +    public void setUp() throws Exception {
     2626 +        HotSwapTool.toVersion(StressTest.class, 0);
     2627 +    }
     2628 +
     2629 +    @Test
     2630 +    public void testStressSwap() {
     2631 +
     2632 +        assert HotSwapTool.getCurrentVersion(StressTest.class) == 0;
     2633 +
     2634 +        A a = new A();
     2635 +
     2636 +        for (int i = 0; i < COUNT; i++) {
     2637 +
     2638 +            assertEquals(1, a.value());
     2639 +
     2640 +            HotSwapTool.toVersion(StressTest.class, 1);
     2641 +
     2642 +            assertEquals(2, a.value());
     2643 +
     2644 +            HotSwapTool.toVersion(StressTest.class, 0);
     2645 +        }
     2646 +
     2647 +        assertEquals(1, a.value());
     2648 +    }
     2649 +}
     2650 diff -r 1999f5b12482 hotswaptest/HotSwapTests/src/at/ssw/hotswap/test/eval/AddingInterfaceTest.java
     2651 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
     2652 +++ b/hotswaptest/HotSwapTests/src/at/ssw/hotswap/test/eval/AddingInterfaceTest.java	Tue Feb 02 16:40:23 2010 +0100
     2653 @@ -0,0 +1,117 @@
     2654 +/*
     2655 + * Copyright 1997-2009 Sun Microsystems, Inc.  All Rights Reserved.
     2656 + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
     2657 + *
     2658 + * This code is free software; you can redistribute it and/or modify it
     2659 + * under the terms of the GNU General Public License version 2 only, as
     2660 + * published by the Free Software Foundation.
     2661 + *
     2662 + * This code is distributed in the hope that it will be useful, but WITHOUT
     2663 + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
     2664 + * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
     2665 + * version 2 for more details (a copy is included in the LICENSE file that
     2666 + * accompanied this code).
     2667 + *
     2668 + * You should have received a copy of the GNU General Public License version
     2669 + * 2 along with this work; if not, write to the Free Software Foundation,
     2670 + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
     2671 + *
     2672 + * Please contact Sun Microsystems, Inc., 4150 Network Circle, Santa Clara,
     2673 + * CA 95054 USA or visit www.sun.com if you need additional information or
     2674 + * have any questions.
     2675 + *
     2676 + */
     2677 +
     2678 +package at.ssw.hotswap.test.eval;
     2679 +
     2680 +import at.ssw.hotswap.HotSwapTool;
     2681 +import java.util.ArrayList;
     2682 +import java.util.List;
     2683 +import org.junit.Before;
     2684 +import org.junit.Test;
     2685 +
     2686 +/**
     2687 + * Adds an implemented interface to a class and tests whether an instance of this class can then really be treated as an instance of the interface.
     2688 + * Additionally, performs performance measurements of a call to this interface compared to a proxy object.
     2689 + *
     2690 + * @author Thomas Wuerthinger
     2691 + */
     2692 +public class AddingInterfaceTest {
     2693 +
     2694 +    @Before
     2695 +    public void setUp() throws Exception {
     2696 +        HotSwapTool.toVersion(AddingInterfaceTest.class, 0);
     2697 +        assert HotSwapTool.getCurrentVersion(AddingInterfaceTest.class) == 0;
     2698 +    }
     2699 +
     2700 +    public static class A {
     2701 +
     2702 +        public int getValue() {
     2703 +            return 1;
     2704 +        }
     2705 +    }
     2706 +
     2707 +    public static interface I {
     2708 +
     2709 +        public int getValue();
     2710 +    }
     2711 +
     2712 +    public static class A___1 implements I {
     2713 +
     2714 +        public int getValue() {
     2715 +            return 1;
     2716 +        }
     2717 +    }
     2718 +
     2719 +    public static class Proxy implements I {
     2720 +
     2721 +        private A a;
     2722 +
     2723 +        public Proxy(A a) {
     2724 +            this.a = a;
     2725 +        }
     2726 +
     2727 +        public int getValue() {
     2728 +            return a.getValue();
     2729 +        }
     2730 +    }
     2731 +
     2732 +    @Test
     2733 +    public void testAddInterface() {
     2734 +
     2735 +        A a = new A();
     2736 +        Proxy p = new Proxy(a);
     2737 +
     2738 +        final int N = 100000;
     2739 +        final int Z = 1;
     2740 +
     2741 +
     2742 +
     2743 +        HotSwapTool.toVersion(AddingInterfaceTest.class, 1);
     2744 +        I i = (I) a;
     2745 +
     2746 +        long startTime = System.currentTimeMillis();
     2747 +        for (int j = 0; j < Z; j++) {
     2748 +            calculateSum(N, i);
     2749 +        }
     2750 +        long time = System.currentTimeMillis() - startTime;
     2751 +        System.out.println(time);
     2752 +
     2753 +        HotSwapTool.toVersion(AddingInterfaceTest.class, 0);
     2754 +
     2755 +        startTime = System.currentTimeMillis();
     2756 +        for (int j = 0; j < Z; j++) {
     2757 +            calculateSum(N, p);
     2758 +        }
     2759 +        time = System.currentTimeMillis() - startTime;
     2760 +        System.out.println(time);
     2761 +    }
     2762 +
     2763 +    public int calculateSum(int n, I i) {
     2764 +        int sum = 0;
     2765 +        for (int j = 0; j < n; j++) {
     2766 +            sum += i.getValue();
     2767 +        }
     2768 +        return sum;
     2769 +    }
     2770 +}
     2771 diff -r 1999f5b12482 hotswaptest/HotSwapTests/src/at/ssw/hotswap/test/eval/EvalTestSuite.java
     2772 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
     2773 +++ b/hotswaptest/HotSwapTests/src/at/ssw/hotswap/test/eval/EvalTestSuite.java	Tue Feb 02 16:40:23 2010 +0100
     2774 @@ -0,0 +1,43 @@
     2775 +/*
     2776 + * Copyright 1997-2009 Sun Microsystems, Inc.  All Rights Reserved.
     2777 + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
     2778 + *
     2779 + * This code is free software; you can redistribute it and/or modify it
     2780 + * under the terms of the GNU General Public License version 2 only, as
     2781 + * published by the Free Software Foundation.
     2782 + *
     2783 + * This code is distributed in the hope that it will be useful, but WITHOUT
     2784 + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
     2785 + * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
     2786 + * version 2 for more details (a copy is included in the LICENSE file that
     2787 + * accompanied this code).
     2788 + *
     2789 + * You should have received a copy of the GNU General Public License version
     2790 + * 2 along with this work; if not, write to the Free Software Foundation,
     2791 + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
     2792 + *
     2793 + * Please contact Sun Microsystems, Inc., 4150 Network Circle, Santa Clara,
     2794 + * CA 95054 USA or visit www.sun.com if you need additional information or
     2795 + * have any questions.
     2796 + *
     2797 + */
     2798 +
     2799 +package at.ssw.hotswap.test.eval;
     2800 +
     2801 +import org.junit.runner.RunWith;
     2802 +import org.junit.runners.Suite;
     2803 +
     2804 +/**
     2805 + * 
     2806 + * Tests used for evaluation purposes (especially performance measurements).
     2807 + * 
     2808 + * @author Thomas Wuerthinger
     2809 + *
     2810 + */
     2811 +@RunWith(Suite.class)
     2812 +@Suite.SuiteClasses({
     2813 +    FractionTest.class,
     2814 +    AddingInterfaceTest.class
     2815 +})
     2816 +public class EvalTestSuite {
     2817 +}
     2818 diff -r 1999f5b12482 hotswaptest/HotSwapTests/src/at/ssw/hotswap/test/eval/FractionTest.java
     2819 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
     2820 +++ b/hotswaptest/HotSwapTests/src/at/ssw/hotswap/test/eval/FractionTest.java	Tue Feb 02 16:40:23 2010 +0100
     2821 @@ -0,0 +1,232 @@
     2822 +/*
     2823 + * Copyright 1997-2009 Sun Microsystems, Inc.  All Rights Reserved.
     2824 + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
     2825 + *
     2826 + * This code is free software; you can redistribute it and/or modify it
     2827 + * under the terms of the GNU General Public License version 2 only, as
     2828 + * published by the Free Software Foundation.
     2829 + *
     2830 + * This code is distributed in the hope that it will be useful, but WITHOUT
     2831 + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
     2832 + * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
     2833 + * version 2 for more details (a copy is included in the LICENSE file that
     2834 + * accompanied this code).
     2835 + *
     2836 + * You should have received a copy of the GNU General Public License version
     2837 + * 2 along with this work; if not, write to the Free Software Foundation,
     2838 + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
     2839 + *
     2840 + * Please contact Sun Microsystems, Inc., 4150 Network Circle, Santa Clara,
     2841 + * CA 95054 USA or visit www.sun.com if you need additional information or
     2842 + * have any questions.
     2843 + *
     2844 + */
     2845 +
     2846 +package at.ssw.hotswap.test.eval;
     2847 +
     2848 +import java.lang.Runnable;
     2849 +import java.util.ArrayList;
     2850 +import java.util.List;
     2851 +import org.junit.Before;
     2852 +import org.junit.Test;
     2853 +
     2854 +import at.ssw.hotswap.HotSwapTool;
     2855 +
     2856 +/**
     2857 + * @author Thomas Wuerthinger
     2858 + */
     2859 +public class FractionTest {
     2860 +
     2861 +    @Before
     2862 +    public void setUp() throws Exception {
     2863 +        HotSwapTool.toVersion(FractionTest.class, 0);
     2864 +        assert HotSwapTool.getCurrentVersion(FractionTest.class) == 0;
     2865 +    }
     2866 +
     2867 +    // Version 0
     2868 +    public static class NoChange {
     2869 +
     2870 +        int i1;
     2871 +        int i2;
     2872 +        int i3;
     2873 +        Object o1;
     2874 +        Object o2;
     2875 +        Object o3;
     2876 +    }
     2877 +
     2878 +    public static class Change {
     2879 +
     2880 +        int i1;
     2881 +        int i2;
     2882 +        int i3;
     2883 +        Object o1;
     2884 +        Object o2;
     2885 +        Object o3;
     2886 +    }
     2887 +
     2888 +    // Version 1
     2889 +    public static class Change___1 {
     2890 +
     2891 +        int i1;
     2892 +        int i2;
     2893 +        int i3;
     2894 +        Object o1;
     2895 +        Object o2;
     2896 +        Object o3;
     2897 +        Object o4;
     2898 +    }
     2899 +
     2900 +    // Version 2
     2901 +    public static class Change___2 {
     2902 +
     2903 +        int i1;
     2904 +        int i2;
     2905 +        int i3;
     2906 +        Object o1;
     2907 +    }
     2908 +
     2909 +    // Version 3
     2910 +    public static class Change___3 {
     2911 +
     2912 +        int i3;
     2913 +        int i1;
     2914 +        int i2;
     2915 +        Object o3;
     2916 +        Object o1;
     2917 +        Object o2;
     2918 +    }
     2919 +
     2920 +    // Version 3
     2921 +    public static class Change___4 {
     2922 +
     2923 +        int i1;
     2924 +        int i2;
     2925 +        int i3;
     2926 +        Object o1;
     2927 +        Object o2;
     2928 +        Object o3;
     2929 +    }
     2930 +    private static List<Long> measurements = new ArrayList<Long>();
     2931 +    private final int BASE = 10;
     2932 +    private Object[] objects;
     2933 +
     2934 +    private void clear() {
     2935 +        objects = null;
     2936 +        System.gc();
     2937 +        System.gc();
     2938 +        HotSwapTool.toVersion(FractionTest.class, 0);
     2939 +        System.gc();
     2940 +        System.gc();
     2941 +
     2942 +    }
     2943 +
     2944 +    private void init(int count, int percent) {
     2945 +        objects = new Object[count];
     2946 +        int changed = 0;
     2947 +        int unchanged = 0;
     2948 +        for (int k = 0; k < count; k++) {
     2949 +            if ((count / BASE) * percent <= k/* && k >= 200000*/) {
     2950 +                objects[k] = new NoChange();
     2951 +                unchanged++;
     2952 +            } else {
     2953 +                objects[k] = new Change();
     2954 +                changed++;
     2955 +            }
     2956 +        }
     2957 +
     2958 +        System.gc();
     2959 +
     2960 +        System.out.println(changed + " changed objects allocated");
     2961 +    }
     2962 +
     2963 +    @Test
     2964 +    public void testBase() {
     2965 +
     2966 +        assert HotSwapTool.getCurrentVersion(FractionTest.class) == 0;
     2967 +
     2968 +        final int N = 1;
     2969 +        final int INC = 4;
     2970 +
     2971 +        int[] benchmarking = new int[]{40000};
     2972 +        int base = BASE;
     2973 +        int start = 0;
     2974 +
     2975 +        MicroBenchmark[] benchmarks = new MicroBenchmark[]{new GCMicroBenchmark(), new IncreaseMicroBenchmark(), new DecreaseMicroBenchmark(), new ReorderMicroBenchmark(), new NoRealChangeMicroBenchmark()};
     2976 +
     2977 +        clear();
     2978 +        for (int k = 0; k < N; k++) {
     2979 +            for (MicroBenchmark m : benchmarks) {
     2980 +                for (int i : benchmarking) {
     2981 +                    System.out.println(m.getClass().getName() + " with " + i + " objects");
     2982 +                    for (int j = start; j <= base; j += INC) {
     2983 +                        System.out.println(j);
     2984 +                        m.init(i);
     2985 +                        init(i, j);
     2986 +                        m.doit(i, measurements);
     2987 +                        clear();
     2988 +                    }
     2989 +                }
     2990 +            }
     2991 +        }
     2992 +
     2993 +        System.out.println("Results:");
     2994 +        for (long l : measurements) {
     2995 +            System.out.println(l);
     2996 +        }
     2997 +        measurements.clear();
     2998 +    }
     2999 +}
     3000 +
     3001 +abstract class MicroBenchmark {
     3002 +
     3003 +    public void init(int count) {
     3004 +    }
     3005 +
     3006 +    public abstract void doit(int count, List<Long> measurements);
     3007 +}
     3008 +
     3009 +class GCMicroBenchmark extends MicroBenchmark {
     3010 +
     3011 +    public void doit(int count, List<Long> measurements) {
     3012 +        long startTime = System.currentTimeMillis();
     3013 +        System.gc();
     3014 +        long curTime = System.currentTimeMillis() - startTime;
     3015 +        measurements.add(curTime);
     3016 +    }
     3017 +}
     3018 +
     3019 +class IncreaseMicroBenchmark extends MicroBenchmark {
     3020 +
     3021 +    public void doit(int count, List<Long> measurements) {
     3022 +        HotSwapTool.resetTimings();
     3023 +        HotSwapTool.toVersion(FractionTest.class, 1);
     3024 +        measurements.add(HotSwapTool.getTotalTime());
     3025 +    }
     3026 +}
     3027 +
     3028 +class DecreaseMicroBenchmark extends MicroBenchmark {
     3029 +
     3030 +    public void doit(int count, List<Long> measurements) {
     3031 +        HotSwapTool.resetTimings();
     3032 +        HotSwapTool.toVersion(FractionTest.class, 2);
     3033 +        measurements.add(HotSwapTool.getTotalTime());
     3034 +    }
     3035 +}
     3036 +
     3037 +class ReorderMicroBenchmark extends MicroBenchmark {
     3038 +
     3039 +    public void doit(int count, List<Long> measurements) {
     3040 +        HotSwapTool.resetTimings();
     3041 +        HotSwapTool.toVersion(FractionTest.class, 3);
     3042 +        measurements.add(HotSwapTool.getTotalTime());
     3043 +    }
     3044 +}
     3045 +
     3046 +class NoRealChangeMicroBenchmark extends MicroBenchmark {
     3047 +
     3048 +    public void doit(int count, List<Long> measurements) {
     3049 +        HotSwapTool.resetTimings();
     3050 +        HotSwapTool.toVersion(FractionTest.class, 4);
     3051 +        measurements.add(HotSwapTool.getTotalTime());
     3052 +    }
     3053 +}
     3054 diff -r 1999f5b12482 hotswaptest/HotSwapTests/src/at/ssw/hotswap/test/fields/AccessDeletedFieldTest.java
     3055 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
     3056 +++ b/hotswaptest/HotSwapTests/src/at/ssw/hotswap/test/fields/AccessDeletedFieldTest.java	Tue Feb 02 16:40:23 2010 +0100
     3057 @@ -0,0 +1,11