Browse Source

initial version

tags/initial_CPL
wisberg 21 years ago
parent
commit
144143c297
100 changed files with 12176 additions and 0 deletions
  1. 13
    0
      ajbrowser/.classpath
  2. 22
    0
      ajbrowser/.project
  3. 12
    0
      taskdefs/.classpath
  4. 20
    0
      taskdefs/.project
  5. 48
    0
      tests/ajcTestSuite.dtd
  6. 5250
    0
      tests/ajcTests.xml
  7. 248
    0
      tests/ajcTests10.xml
  8. 374
    0
      tests/ajcTestsAttic.xml
  9. 71
    0
      tests/ajcTestsBroken.xml
  10. 219
    0
      tests/ajcTestsFailing.xml
  11. 26
    0
      tests/ajde/examples/figures-cacm/Test_Figures_CACM.jpx
  12. 9
    0
      tests/ajde/examples/figures-cacm/figures/Display.java
  13. 15
    0
      tests/ajde/examples/figures-cacm/figures/DisplayUpdating.java
  14. 12
    0
      tests/ajde/examples/figures-cacm/figures/FactoryEnforcement.java
  15. 23
    0
      tests/ajde/examples/figures-cacm/figures/Figure.java
  16. 8
    0
      tests/ajde/examples/figures-cacm/figures/FigureElement.java
  17. 23
    0
      tests/ajde/examples/figures-cacm/figures/Line.java
  18. 17
    0
      tests/ajde/examples/figures-cacm/figures/Main.java
  19. 33
    0
      tests/ajde/examples/figures-cacm/figures/Point.java
  20. 13
    0
      tests/ajde/examples/figures-cacm/figures/PointBoundsChecking.java
  21. 13
    0
      tests/ajde/examples/figures-cacm/figures/SimpleTracing.java
  22. 25
    0
      tests/ajde/examples/figures-coverage/Test_Figures_Coverage.jpr
  23. 37
    0
      tests/ajde/examples/figures-coverage/Test_Figures_Coverage.jpx
  24. 4
    0
      tests/ajde/examples/figures-coverage/Trace.aj
  25. 3
    0
      tests/ajde/examples/figures-coverage/_JoinpointProbe.java
  26. 4
    0
      tests/ajde/examples/figures-coverage/editor/Editor.java
  27. 7
    0
      tests/ajde/examples/figures-coverage/figures/Debug.java
  28. 78
    0
      tests/ajde/examples/figures-coverage/figures/Figure.java
  29. 9
    0
      tests/ajde/examples/figures-coverage/figures/FigureElement.java
  30. 48
    0
      tests/ajde/examples/figures-coverage/figures/Main.java
  31. 4
    0
      tests/ajde/examples/figures-coverage/figures/Trace.aj
  32. 6
    0
      tests/ajde/examples/figures-coverage/figures/composites/Line.java
  33. 6
    0
      tests/ajde/examples/figures-coverage/figures/composites/Square.java
  34. 65
    0
      tests/ajde/examples/figures-coverage/figures/primitives/planar/Point.java
  35. 24
    0
      tests/ajde/examples/figures-coverage/figures/primitives/solid/SolidPoint.java
  36. 25
    0
      tests/ajde/examples/observer-gof/Test_Observer.jpx
  37. 12
    0
      tests/ajde/examples/observer-gof/clock/AnalogClock.java
  38. 5
    0
      tests/ajde/examples/observer-gof/clock/Clock.java
  39. 33
    0
      tests/ajde/examples/observer-gof/clock/ClockTimer.java
  40. 26
    0
      tests/ajde/examples/observer-gof/clock/DigitalClock.java
  41. 14
    0
      tests/ajde/examples/observer-gof/clock/Main.java
  42. 9
    0
      tests/ajde/examples/observer-gof/clock/MonitorObservation.java
  43. 23
    0
      tests/ajde/examples/observer/Test_Observer.jpx
  44. 21
    0
      tests/ajde/examples/observer/clock/AnalogueClock.java
  45. 23
    0
      tests/ajde/examples/observer/clock/ClockTimer.java
  46. 30
    0
      tests/ajde/examples/observer/clock/DigitalClock.java
  47. 15
    0
      tests/ajde/examples/observer/clock/Main.java
  48. 14
    0
      tests/ajde/examples/observer/clock/MonitorObservation.java
  49. 28
    0
      tests/ajde/examples/spacewar/Test_Spacewar.jpx
  50. 20
    0
      tests/ajde/examples/spacewar/coordination/Condition.java
  51. 20
    0
      tests/ajde/examples/spacewar/coordination/CoordinationAction.java
  52. 432
    0
      tests/ajde/examples/spacewar/coordination/Coordinator.java
  53. 16
    0
      tests/ajde/examples/spacewar/coordination/Exclusion.java
  54. 28
    0
      tests/ajde/examples/spacewar/coordination/MethodState.java
  55. 69
    0
      tests/ajde/examples/spacewar/coordination/Mutex.java
  56. 38
    0
      tests/ajde/examples/spacewar/coordination/Selfex.java
  57. 10
    0
      tests/ajde/examples/spacewar/coordination/TimeoutException.java
  58. 27
    0
      tests/ajde/examples/spacewar/spacewar/Bullet.java
  59. 199
    0
      tests/ajde/examples/spacewar/spacewar/Debug.java
  60. 146
    0
      tests/ajde/examples/spacewar/spacewar/Display.java
  61. 183
    0
      tests/ajde/examples/spacewar/spacewar/Display1.java
  62. 118
    0
      tests/ajde/examples/spacewar/spacewar/Display2.java
  63. 23
    0
      tests/ajde/examples/spacewar/spacewar/EnergyPacket.java
  64. 40
    0
      tests/ajde/examples/spacewar/spacewar/EnergyPacketProducer.java
  65. 15
    0
      tests/ajde/examples/spacewar/spacewar/EnsureShipIsAlive.java
  66. 172
    0
      tests/ajde/examples/spacewar/spacewar/Game.java
  67. 33
    0
      tests/ajde/examples/spacewar/spacewar/GameSynchronization.java
  68. 26
    0
      tests/ajde/examples/spacewar/spacewar/Pilot.java
  69. 101
    0
      tests/ajde/examples/spacewar/spacewar/Player.java
  70. 105
    0
      tests/ajde/examples/spacewar/spacewar/Registry.java
  71. 37
    0
      tests/ajde/examples/spacewar/spacewar/RegistrySynchronization.java
  72. 179
    0
      tests/ajde/examples/spacewar/spacewar/Robot.java
  73. 71
    0
      tests/ajde/examples/spacewar/spacewar/SWFrame.java
  74. 260
    0
      tests/ajde/examples/spacewar/spacewar/Ship.java
  75. 81
    0
      tests/ajde/examples/spacewar/spacewar/SpaceObject.java
  76. 32
    0
      tests/ajde/examples/spacewar/spacewar/Timer.java
  77. 291
    0
      tests/ajde/script.html
  78. 200
    0
      tests/ajdoc/JavadocCompareClassMode.java
  79. 64
    0
      tests/ajdoc/JavadocComparePackageMode.java
  80. 66
    0
      tests/ajdoc/RegressionComparePackageMode.java
  81. 35
    0
      tests/ajdoc/common/OutputComparator.java
  82. 119
    0
      tests/ajdoc/input/applesAspectJ/Apple.java
  83. 52
    0
      tests/ajdoc/input/applesAspectJ/AppleCrate.java
  84. 22
    0
      tests/ajdoc/input/applesAspectJ/BigRigAspect.java
  85. 44
    0
      tests/ajdoc/input/applesAspectJ/TransportAspect.java
  86. 114
    0
      tests/ajdoc/input/applesJava/Apple.java
  87. 52
    0
      tests/ajdoc/input/applesJava/AppleCrate.java
  88. 15
    0
      tests/ajdoc/input/applesJava/BigRigAspect.java
  89. 24
    0
      tests/ajdoc/input/applesJava/TransportAspect.java
  90. 16
    0
      tests/ajdoc/input/pkgExample/Class1.java
  91. 7
    0
      tests/ajdoc/input/pkgExample/aPack/Class2.java
  92. 7
    0
      tests/ajdoc/input/pkgExample/aPack/I1.java
  93. 12
    0
      tests/ajdoc/input/pkgExample/bPack/cPack/Class3.java
  94. 18
    0
      tests/ajdoc/package.html
  95. 406
    0
      tests/ant/etc/ajc.xml
  96. 201
    0
      tests/ant/etc/ajc2.xml
  97. 318
    0
      tests/ant/etc/ajclean.xml
  98. 545
    0
      tests/ant/etc/ajdoc.xml
  99. BIN
      tests/ant/filecompare/fileCompareTestDirs.zip
  100. 0
    0
      tests/ant/filecompare/makeTestDir.sh

+ 13
- 0
ajbrowser/.classpath View File

@@ -0,0 +1,13 @@
<?xml version="1.0" encoding="UTF-8"?>
<classpath>
<classpathentry kind="src" path="src"/>
<classpathentry kind="src" path="testsrc"/>
<classpathentry kind="var" path="JRE_LIB" rootpath="JRE_SRCROOT" sourcepath="JRE_SRC"/>
<classpathentry kind="src" path="/ajde"/>
<classpathentry kind="src" path="/util"/>
<classpathentry kind="lib" path="/lib/junit/junit.jar" sourcepath="/lib/junit/junit-src.jar"/>
<classpathentry kind="src" path="/bridge"/>
<classpathentry kind="src" path="/asm"/>
<classpathentry kind="src" path="/taskdefs"/>
<classpathentry kind="output" path="bin"/>
</classpath>

+ 22
- 0
ajbrowser/.project View File

@@ -0,0 +1,22 @@
<?xml version="1.0" encoding="UTF-8"?>
<projectDescription>
<name>ajbrowser</name>
<comment></comment>
<projects>
<project>ajde</project>
<project>asm</project>
<project>bridge</project>
<project>taskdefs</project>
<project>util</project>
</projects>
<buildSpec>
<buildCommand>
<name>org.eclipse.jdt.core.javabuilder</name>
<arguments>
</arguments>
</buildCommand>
</buildSpec>
<natures>
<nature>org.eclipse.jdt.core.javanature</nature>
</natures>
</projectDescription>

+ 12
- 0
taskdefs/.classpath View File

@@ -0,0 +1,12 @@
<?xml version="1.0" encoding="UTF-8"?>
<classpath>
<classpathentry kind="src" path="src"/>
<classpathentry kind="src" path="testsrc"/>
<classpathentry kind="var" path="JRE_LIB" rootpath="JRE_SRCROOT" sourcepath="JRE_SRC"/>
<classpathentry kind="lib" path="/lib/junit/junit.jar" sourcepath="/lib/junit/junit-src.jar"/>
<classpathentry kind="lib" path="/lib/ant/lib/ant.jar" sourcepath="/lib/ant/ant-src.zip"/>
<classpathentry kind="src" path="/bridge"/>
<classpathentry kind="src" path="/org.aspectj.ajdt.core"/>
<classpathentry kind="src" path="/util"/>
<classpathentry kind="output" path="bin"/>
</classpath>

+ 20
- 0
taskdefs/.project View File

@@ -0,0 +1,20 @@
<?xml version="1.0" encoding="UTF-8"?>
<projectDescription>
<name>taskdefs</name>
<comment></comment>
<projects>
<project>bridge</project>
<project>org.aspectj.ajdt.core</project>
<project>util</project>
</projects>
<buildSpec>
<buildCommand>
<name>org.eclipse.jdt.core.javabuilder</name>
<arguments>
</arguments>
</buildCommand>
</buildSpec>
<natures>
<nature>org.eclipse.jdt.core.javanature</nature>
</natures>
</projectDescription>

+ 48
- 0
tests/ajcTestSuite.dtd View File

@@ -0,0 +1,48 @@
<!-- this defines a DOCTYPE for a suite of ajc tests -->
<!-- element-component mappings are in org.aspectj.testing.xml.AjcSpecXmlReader -->
<!-- element names are determined by the component XMLNAME static variable -->
<!ELEMENT suite (ajc-test+)>
<!ATTLIST suite suiteDir CDATA #IMPLIED >
<!ELEMENT ajc-test (compile, (compile | inc-compile | run)*)>
<!ATTLIST ajc-test title CDATA #REQUIRED >
<!ATTLIST ajc-test dir CDATA #REQUIRED >
<!ATTLIST ajc-test pr CDATA #IMPLIED >
<!ATTLIST ajc-test keywords CDATA #IMPLIED >
<!ATTLIST ajc-test comment CDATA #IMPLIED >
<!ELEMENT compile (dir-changes*,file*,message*)>
<!ATTLIST compile staging CDATA #IMPLIED >
<!ATTLIST compile files CDATA #IMPLIED >
<!ATTLIST compile argfiles CDATA #IMPLIED >
<!ATTLIST compile aspectpath CDATA #IMPLIED >
<!ATTLIST compile options CDATA #IMPLIED >
<!ELEMENT inc-compile (dir-changes*,message*)>
<!ATTLIST inc-compile tag CDATA #REQUIRED >
<!ELEMENT run (dir-changes*,message*)>
<!ATTLIST run class CDATA #REQUIRED >
<!ATTLIST run skipTester CDATA #IMPLIED >
<!ATTLIST run vm CDATA #IMPLIED >
<!ATTLIST run options CDATA #IMPLIED >
<!ELEMENT file (#PCDATA)>
<!ATTLIST file path CDATA #IMPLIED >
<!ELEMENT message (#PCDATA)>
<!ATTLIST message kind (error | warning | info | Xlint) #REQUIRED >
<!ATTLIST message line CDATA #REQUIRED >
<!ATTLIST message text CDATA #IMPLIED >
<!ATTLIST message file CDATA #IMPLIED >
<!ELEMENT dir-changes (#PCDATA)>
<!ATTLIST dir-changes dirToken (classes | run) #IMPLIED >
<!ATTLIST dir-changes defaultSuffix (.class) #IMPLIED >
<!ATTLIST dir-changes added CDATA #IMPLIED >
<!ATTLIST dir-changes removed CDATA #IMPLIED >
<!ATTLIST dir-changes updated CDATA #IMPLIED >
<!ATTLIST dir-changes unchanged CDATA #IMPLIED >
<!ATTLIST dir-changes expDir CDATA #IMPLIED >

+ 5250
- 0
tests/ajcTests.xml
File diff suppressed because it is too large
View File


+ 248
- 0
tests/ajcTests10.xml View File

@@ -0,0 +1,248 @@

<!DOCTYPE suite SYSTEM "../tests/ajcTestSuite.dtd">


<suite>
<ajc-test dir="jacks"
title="14.20-label-11 The break is interrupted by the try-finally"
keywords="from-stricttests">
<compile options="-strict" files="FinallyReturns.java">
<message kind="error" line="11"/>
</compile>
</ajc-test>

<ajc-test dir="jacks"
title="14.20-catch-14 The throw is interrupted by the inner finally"
keywords="from-stricttests">
<compile options="-strict" files="FinallyReturnsThrows.java">
<message kind="error" line="10"/>
</compile>
</ajc-test>

<ajc-test dir="jacks"
title="14.20-label-12 The break is interrupted by the try-finally"
keywords="from-stricttests">
<compile options="-strict" files="FinallyReturnsBreakInCatch.java">
<message kind="error" line="10"/>
</compile>
</ajc-test>
<!-- strict-only tests treated as 1.0 tests -->

<!-- ajc-only tests treated as 1.0 tests -->
<ajc-test dir="new" pr="567"
title="cyclic interface inheritance not detected if no classes implement the interfaces"
keywords="from-java,purejava,messages-vary">
<compile files="CyclicInterfaceInheritance.java"
options="!ajc">
<message kind="error" line="14"/>
</compile>
</ajc-test>

<ajc-test dir="new/packagePrefix" pr="574"
title="classes that are package prefixes are illegal"
keywords="from-java,purejava,messages-vary">
<compile files="p/prefix.java,p/prefix/SomeClass.java"
options="!ajc">
<message kind="error" line="3"/>
</compile>
</ajc-test>

<ajc-test dir="pureJava"
title="suggested by Jacks 15.28-qualified-namestr tests"
keywords="from-java,purejava,messages-vary">
<compile files="NonConstants.java"
options="!ajc">
<message kind="error" line="14"/>
<message kind="error" line="15"/>
<message kind="error" line="16"/>
</compile>
</ajc-test>

<ajc-test dir="new" pr="643" title="try without catch or finally"
keywords="from-java,purejava,message-vary">
<compile files="TryNoCatchCE.java"
options="!ajc">
<message kind="error" line="5"/>
</compile>
</ajc-test>

<ajc-test dir="new" pr="642" title="invalid floating-point constant"
keywords="from-java,purejava,messages-vary">
<compile files="ParsingFloatCE.java"
options="!ajc">
<message kind="error" line="5"/>
<message kind="error" line="6"/>
</compile>
</ajc-test>

<ajc-test dir="new/subaspects" pr="647"
title="concrete aspect unable to access abstract package-private method in parent for overriding"
keywords="from-java,purejava,messages-vary">
<compile files="parent/ParentMethodCE.java,child/ChildMethodCE.java"
options="!ajc">
<message kind="error" line="27"/>
</compile>
</ajc-test>

<ajc-test dir="new" pr="701"
title="CE for ambiguous type reference (two type declarations)"
keywords="from-java,purejava,messages-vary">
<compile files="AmbiguousClassReference3CE.java"
options="!ajc">
<message kind="error" line="9"/>
<message kind="error" line="10"/>
</compile>
</ajc-test>

<ajc-test dir="new" pr="701"
title="CE for ambiguous type reference (two inner types)"
keywords="from-java,purejava,messages-vary">
<compile files="AmbiguousClassReference4CE.java"
options="!ajc">
<message kind="error" line="9"/>
<message kind="error" line="10"/>
</compile>
</ajc-test>

<ajc-test dir="errors" title="Crashes when a cast of the form )int) appears"
keywords="from-errors,purejava,messages-vary">
<compile files="BadCast.java"
options="!ajc">
<message kind="error" line="9"/>
</compile>
</ajc-test>

<ajc-test dir="errors" title="Crashes when the closing brace is reversed"
keywords="from-errors,purejava,messages-vary">
<compile files="ClosingBrace.java"
options="!ajc">
<message kind="error" line="14"/>
</compile>
</ajc-test>

<ajc-test dir="errors" title="class and interface extension"
keywords="from-errors,purejava,messages-vary">
<compile files="BadExtension.java"
options="!ajc">
<message kind="error" line="9"/>
<message kind="error" line="16"/>
<message kind="error" line="17"/>
<message kind="error" line="18"/>
<message kind="error" line="19"/>
<message kind="error" line="21"/>
<message kind="error" line="35"/>
<message kind="error" line="38"/>
</compile>
</ajc-test>

<ajc-test dir="errors" title="illegal synchronized stmts"
keywords="from-errors,purejava,messages-vary">
<compile files="BadSynchronized.java"
options="!ajc">
<message kind="error" line="3"/>
<message kind="error" line="4"/>
<message kind="error" line="5"/>
<message kind="error" line="6"/>
</compile>
</ajc-test>

<ajc-test dir="new" pr="715" title="incrementing objects, arrays CE"
keywords="from-resolved_104,purejava,messages-vary">
<compile files="ArrayIncCE.java"
options="!ajc">
<message kind="error" line="15"/>
<message kind="error" line="16"/>
<message kind="error" line="17"/>
<message kind="error" line="18"/>
<message kind="error" line="19"/>
<message kind="error" line="20"/>
<message kind="error" line="21"/>
</compile>
</ajc-test>

<ajc-test dir="pureJava" pr="737"
title="should have circular inheritance errors (1)"
keywords="from-resolved_105,purejava,messages-vary">
<compile files="circle/Test1CF.java"
options="!ajc">
<message kind="error" line="7"/>
</compile>
</ajc-test>

<ajc-test dir="pureJava" pr="737"
title="should have circular inheritance errors (2)"
keywords="from-resolved_105,purejava,messages-vary">
<compile files="circle/Test2CF.java"
options="!ajc">
<message kind="error" line="6"/>
</compile>
</ajc-test>

<ajc-test dir="pureJava" title="try requires block JLS 14.19"
keywords="from-resolved_105,purejava,messages-vary">
<compile files="TryBlockRequiredCE.java"
options="!ajc">
<message kind="error" line="6"/>
<message kind="error" line="7"/>
<message kind="error" line="8"/>
</compile>
</ajc-test>

<ajc-test dir="pureJava" pr="722" title="loop expressions not declarations"
keywords="from-resolved_105,purejava,messages-vary">
<compile files="DeclarationsInLoopsCE.java"
options="!ajc">
<message kind="error" line="7"/>
<message kind="error" line="8"/>
<message kind="error" line="9"/>
</compile>
</ajc-test>

<ajc-test dir="ng"
title="array initializers can't have random commas"
keywords="from-resolved_105,purejava,messages-vary">
<compile files="ArrayInitError.java"
options="!ajc,^lenient">
<message kind="error" line="6"/>
<message kind="error" line="7"/>
</compile>
</ajc-test>

<ajc-test dir="ng"
title="array initializers can't have random commas"
keywords="from-resolved_105,purejava,messages-vary">
<compile files="ArrayInitError.java"
options="!ajc,!lenient">
<message kind="error" line="6"/>
</compile>
</ajc-test>

<ajc-test dir="ng"
title="try stmt must be block [parser, different lines from javac]"
keywords="from-resolved_105,purejava,messages-vary">
<compile files="NonBlockTryStmt.java"
options="!ajc">
<message kind="error" line="8"/>
<message kind="error" line="10"/>
<message kind="error" line="12"/>
<message kind="error" line="14"/>
</compile>
</ajc-test>

<ajc-test dir="pureJava"
title="initializers must be able to complete normally (found by jacks)"
keywords="from-resolved_105,purejava,messages-vary">
<compile files="InitializerFlowCf.java"
options="!ajc">
<message kind="error" line="1"/>
</compile>
</ajc-test>

<ajc-test dir="new" pr="884" keywords="v1.0"
title="declare constructor on interface subclasses" >
<compile options="!ajc" files="DeclareInterfaceConstructor.java"/>
<run class="DeclareInterfaceConstructor"/>
</ajc-test>

</suite>

+ 374
- 0
tests/ajcTestsAttic.xml View File

@@ -0,0 +1,374 @@

<!DOCTYPE suite SYSTEM "../tests/ajcTestSuite.dtd">


<suite>
<ajc-test dir="tom"
title="The classes which implement the conflict sets pattern from CPJ(2e). There should be no errors."
keywords="from-tomtests">
<compile files="Assertions.java,conflict_sets/*.java"/>
<run class="Main"/>
</ajc-test>

<ajc-test dir="tom"
title="The Classes which implement the Joint Actions protocols from CPJ(2e). There should be no errors."
keywords="from-tomtests">
<compile files="Assertions.java,joint_actions/*.java"/>
<run class="Main"/>
</ajc-test>

<ajc-test dir="tom" title="Subject/Observer Pattern. no errors"
keywords="from-tomtests">
<compile files="Assertions.java,subject_observer/*.java"/>
<run class="Main"/>
</ajc-test>

<ajc-test dir="tom" title="Method Confinement. no errors"
keywords="from-tomtests">
<compile files="Assertions.java,confinement/*.java"/>
<run class="Main"/>
</ajc-test>

<ajc-test dir="tom" title="Double Check policy. no errors"
keywords="from-tomtests">
<compile files="Assertions.java,double_check/*.java"/>
<run class="Main"/>
</ajc-test>

<ajc-test dir="tom" title="A Rollback strategy. no errors"
keywords="from-tomtests">
<compile files="Assertions.java,rollback/*.java"/>
<run class="Main"/>
</ajc-test>

<ajc-test dir="tom" title="An impl of the Futures pattern. no errors"
keywords="from-tomtests">
<compile files="Assertions.java,futures/*.java"/>
<run class="Main"/>
</ajc-test>

<ajc-test dir="tom" title="The Guards policy. no errors"
keywords="from-tomtests">
<compile files="Assertions.java,guards/*.java"/>
<run class="Main"/>
</ajc-test>

<ajc-test dir="tom" title="Using State Variables. no errors"
keywords="from-tomtests">
<compile files="Assertions.java,state_variables/*.java"/>
<run class="Main"/>
</ajc-test>

<ajc-test dir="tom" title="A guards example. no errors"
keywords="from-tomtests">
<compile files="Assertions.java,waiting_stack/*.java"/>
<run class="Main"/>
</ajc-test>

<ajc-test dir="tom" title="Demonstrates resource sharing. no errors"
keywords="from-tomtests">
<compile files="Assertions.java,printer_example/*.java"/>
<run class="Main"/>
</ajc-test>

<ajc-test dir="errors" title="Should fail because two aspects are public"
keywords="from-opentests">
<compile files="TwoPublics.java">
<message kind="error" line="1"/>
</compile>
</ajc-test>

<ajc-test dir="new" title="illegal forward reference using introduction"
keywords="from-opentests">
<compile files="IllegalForwardReference.java"/>
<run class="IllegalForwardReference"/>
</ajc-test>

<ajc-test dir="new" pr="396"
title="Not binding static inner interfaces. ( )" keywords="from-opentests">
<compile files="StaticInnerInterfaces_PR386.java"/>
<run class="StaticInnerInterfaces_PR386"/>
</ajc-test>

<ajc-test dir="new" pr="396"
title="Not binding non-static inner interfaces. ( )"
keywords="from-opentests">
<compile files="NonStaticInnerInterfaces_PR386.java"/>
<run class="NonStaticInnerInterfaces_PR386"/>
</ajc-test>

<ajc-test dir="errors" title="Ambiguous interface should produce error"
keywords="from-opentests">
<compile files="AmbiguousInterface.java">
<message kind="error" line="13"/>
</compile>
</ajc-test>

<ajc-test dir="errors"
title="Parser shouldn't accept 'const' as a variable name."
keywords="from-opentests">
<compile files="Const.java">
<message kind="error" line="9"/>
<message kind="error" line="10"/>
<message kind="error" line="15"/>
<message kind="error" line="19"/>
</compile>
</ajc-test>

<ajc-test dir="errors"
title="Parser shouldn't accept 'goto' as a variable name."
keywords="from-opentests">
<compile files="Goto.java">
<message kind="error" line="4"/>
<message kind="error" line="9"/>
<message kind="error" line="10"/>
<message kind="error" line="14"/>
</compile>
</ajc-test>

<ajc-test dir="errors"
title="Over-boundary base values cause compile-time errors"
keywords="from-opentests">
<compile files="BoundaryNums.java">
<message kind="error" line="22"/>
</compile>
</ajc-test>

<ajc-test dir="new"
title="creates two a.java files when two classes have the same name in different cases (will not fail)"
keywords="from-badtests">
<compile files="LowerAndUpper.java"/>
<run class="LowerAndUpper"/>
</ajc-test>

<ajc-test dir="new" pr="312"
title="don't make each object when there's no this (should take this out)"
keywords="from-badtests">
<compile files="EachObjectNoThis.java"/>
<run class="EachObjectNoThis"/>
</ajc-test>

<ajc-test dir="new" pr="652"
title="declare parent accepting interface for extension"
keywords="from-badtests">
<compile files="DeclareParentsNonsenseCE.java">
<message kind="error" line="4"/>
<message kind="error" line="6"/>
</compile>
</ajc-test>

<ajc-test dir="new" title="Using hasaspect. [eachobject] (still)"
keywords="from-08tests">
<compile files="HasAspect.java"/>
<run class="HasAspect"/>
</ajc-test>

<ajc-test dir="new"
title="(DESIGN QUESTION) aspects of eachobject and serialization (still)"
keywords="from-08tests">
<compile files="SerializedOf.java"/>
<run class="SerializedOf"/>
</ajc-test>

<ajc-test dir="new"
title="around advice interacting with checked exceptions, with callsto (still)"
keywords="from-08tests">
<compile files="AroundExceptions.java"/>
<run class="AroundExceptions"/>
</ajc-test>

<ajc-test dir="pureJava"
title="TriTestExprs interact with constant folding and name binding"
keywords="from-knownbugs">
<compile files="TriTestMethodLookup.java"/>
<run class="TriTestMethodLookup"/>
</ajc-test>

<ajc-test dir="pureJava"
title="Assignment to final fields w/initializers should _always_ be errors"
keywords="from-knownbugs">
<compile files="UnderIfFalse.java">
<message kind="error" line="11"/>
</compile>
</ajc-test>

<ajc-test dir="new"
title="FAILING errors in unwoven advice not detected at compile time"
keywords="from-knownbugs">
<compile files="UnwovenAdviceNotCheckedCE.java">
<message kind="error" line="13"/>
</compile>
</ajc-test>

<ajc-test dir="new/pr626" pr="626"
title="declared parent not defined in scope of target class declaration (CE in -usejavac only)"
keywords="from-knownbugs">
<compile options="-usejavac" files="a/Outer.java,b/Foo.java"/>
<run class="a.Outer"/>
</ajc-test>

<ajc-test dir="new" pr="694"
title="after returning advice on handler join points"
keywords="from-knownbugs">
<compile files="AfterReturningHandler.java"/>
<run class="AfterReturningHandler"/>
</ajc-test>

<ajc-test dir="new" pr="745"
title="stack overflow expected when advice recurses into itself"
keywords="from-knownbugs">
<compile files="AdviceOnAdviceRecursion.java"/>
<run class="AdviceOnAdviceRecursion"/>
</ajc-test>

<ajc-test dir="new" pr="755"
title="ajc dies on cflow into field init anon class"
keywords="from-knownbugs">
<compile files="CflowOfFieldInitAnonMethods.java"/>
<run class="CflowOfFieldInitAnonMethods"/>
</ajc-test>

<ajc-test dir="pureJava"
title="Losing information about initializers before checking their control flow"
keywords="from-knownbugs">
<compile files="InitializerFlowCf.java">
<message kind="error" line="2"/>
<message kind="error" line="4"/>
</compile>
</ajc-test>

<ajc-test dir="new"
title="the way we do privileged access for ++, etc, messes up floats"
keywords="from-knownbugs">
<compile files="FloatPrivilegedRoundoff.java"/>
<run class="FloatPrivilegedRoundoff"/>
</ajc-test>

<ajc-test dir="pureJava"
title="nested interface does not require new qualifier (7) [extra error message]"
keywords="from-knownbugs,purejava">
<compile files="InvalidNewQualifier7CE.java">
<message kind="error" line="7"/>
</compile>
</ajc-test>

<ajc-test dir="ng" title="interface inheritance should merge throws clauses"
keywords="from-knownbugs,purejava">
<compile files="ConflictingThrowsInheritance.java"/>
<run class="ConflictingThrowsInheritance"/>
</ajc-test>

<ajc-test dir="pureJava"
title="Locals inside other locals, ordering of processing, name-binding"
keywords="from-knownbugs">
<compile files="LocalInners3.java"/>
<run class="LocalInners3"/>
</ajc-test>

<ajc-test dir="new" pr="774"
title="interface self-reference in anonymous instance"
keywords="from-knownbugs">
<compile files="AnonymousSelfReference.java"/>
<run class="AnonymousSelfReference"/>
</ajc-test>

<ajc-test dir="new" pr="776"
title="self-reference from (aspect-declared) method-local class"
keywords="from-knownbugs">
<compile files="MethodSelfReference.java"/>
<run class="MethodSelfReference"/>
</ajc-test>

<ajc-test dir="new" title="declaring type in signature of anonymous class"
keywords="from-knownbugs">
<compile files="AnonymousClassName.java"/>
<run class="AnonymousClassName"/>
</ajc-test>

<ajc-test dir="new"
title="VM ClassFormatError on windows if nul used as class name (todo NOTOURBUG, so nul class not loaded in test) (will not fail)"
keywords="from-knownissues,purejava">
<compile files="NulIOException3.java"/>
<run class="NulIOException3"/>
</ajc-test>

<ajc-test dir="new" pr="602"
title="LIMITATION no deprecation warnings (regardless of -deprecation flag)"
keywords="from-knownissues,purejava">
<compile options="-deprecation" files="DeprecationWarning.java">
<message kind="warning" line="11"/>
</compile>
<run class="DeprecationWarning"/>
</ajc-test>

<ajc-test dir="new"
title="around, before, after advice on handler join points"
keywords="from-knownissues">
<compile files="AroundHandler.java"/>
<run class="AroundHandler"/>
</ajc-test>

<ajc-test dir="new"
title="compiler limitation on asserts when using -usejavac"
keywords="from-knownissues">
<compile options="-usejavac,-source,1.4" files="AssertInInnerIntro.java"/>
<run class="AssertInInnerIntro"/>
</ajc-test>

<ajc-test dir="new"
title="binding parameters in a ! pcd lexically is always an error"
keywords="from-knownissues">
<compile files="BindingInNotCf.java">
<message kind="error" line="9"/>
<message kind="error" line="11"/>
<message kind="error" line="13"/>
</compile>
</ajc-test>

<ajc-test dir="new" pr="704"
title="RFE mark generated static fields as transient"
keywords="from-knownissues">
<compile files="GeneratedStaticAsTransient.java"/>
<run class="GeneratedStaticAsTransient"/>
</ajc-test>

<ajc-test dir="new" pr="706"
title="compiling large concatenated string [bug also in javac]"
keywords="from-knownissues,purejava">
<compile files="LongStringAjc.java"/>
<run class="LongStringAjc"/>
</ajc-test>

<ajc-test dir="new"
title="rfe: SourceLocationImpl should implement toString as filename:column"
keywords="from-knownissues">
<compile files="SourceLocationToString.java"/>
<run class="SourceLocationToString"/>
</ajc-test>

<ajc-test dir="new" pr="740"
title="pointcut references with incorrect args should prompt compiler errors"
keywords="from-knownissues">
<compile files="PCDeclarationArgsCE.java">
<message kind="error" line="29"/>
<message kind="error" line="30"/>
<message kind="error" line="31"/>
<message kind="error" line="32"/>
<message kind="error" line="33"/>
<message kind="error" line="34"/>
<message kind="error" line="35"/>
<message kind="error" line="37"/>
<message kind="error" line="38"/>
<message kind="error" line="39"/>
<message kind="error" line="40"/>
<message kind="error" line="42"/>
<message kind="error" line="44"/>
<message kind="error" line="45"/>
<message kind="error" line="46"/>
<message kind="error" line="47"/>
<message kind="error" line="49"/>
<message kind="error" line="50"/>
<message kind="error" line="53"/>
</compile>
</ajc-test>
</suite>

+ 71
- 0
tests/ajcTestsBroken.xml View File

@@ -0,0 +1,71 @@

<!DOCTYPE suite SYSTEM "../tests/ajcTestSuite.dtd">


<suite>

<ajc-test dir="new" pr="223"
title="duplicate class names should be signalled by ajc, not javac"
keywords="from-errors,fail-commandLine"
comment="XXX harness does not handle per-file errors any more">
<compile files="DoubleClass1.java,DoubleClass2.java">
<message kind="error" line="3" text="DoubleClass1.java:3"/>
<message kind="error" line="3" text="DoubleClass2.java:3"/>
</compile>
</ajc-test>

<ajc-test dir="design/around" title="around and return types"
keywords="from-design,fail-commandLine">
<compile files="ReturnCastProceed.java,StackChecker.java"/>
<run class="ReturnCastProceed"/>
</ajc-test>
<ajc-test dir="new/privilegedAspects"
title="access to all members of class and inner class from unprivileged aspect"
keywords="from-resolved_10x,fail-commandLine">
<compile
files="driver/UnprivilegedAspect.java,util/Util.java,pack/DefaultTarget.java,pack/PublicTarget.java">
<message kind="error" line="32"/>
<message kind="error" line="33"/>
<message kind="error" line="34"/>
<message kind="error" line="37"/>
<message kind="error" line="38"/>
<message kind="error" line="39"/>
<message kind="error" line="41"/>
<message kind="error" line="42"/>
<message kind="error" line="43"/>
<message kind="error" line="54"/>
<message kind="error" line="55"/>
<message kind="error" line="56"/>
<message kind="error" line="60"/>
<message kind="error" line="61"/>
<message kind="error" line="62"/>
<message kind="error" line="64"/>
<message kind="error" line="65"/>
<message kind="error" line="66"/>
<message kind="error" line="76"/>
<message kind="error" line="77"/>
<message kind="error" line="78"/>
<message kind="error" line="79"/>
<message kind="error" line="80"/>
<message kind="error" line="81"/>
<message kind="error" line="82"/>
<message kind="error" line="83"/>
<message kind="error" line="84"/>
<message kind="error" line="85"/>
<message kind="error" line="86"/>
<message kind="error" line="87"/>
<message kind="error" line="88"/>
<message kind="error" line="96"/>
<message kind="error" line="98"/>
<message kind="error" line="99"/>
<message kind="error" line="100"/>
<message kind="error" line="101"/>
<message kind="error" line="102"/>
<message kind="error" line="103"/>
<message kind="error" line="103"/>
</compile>
</ajc-test>


</suite>

+ 219
- 0
tests/ajcTestsFailing.xml View File

@@ -0,0 +1,219 @@

<!DOCTYPE suite SYSTEM "../tests/ajcTestSuite.dtd">


<suite>
<ajc-test dir="new" pr="774"
title="interface self-reference in anonymous instance (correct test in knownbugs)"
keywords="tofix"
comment="correct behavior for 1.0 is good error message, see real test in knownbugs">
<compile files="AnonymousSelfReference.java">
<message kind="error" line="17"/>
</compile>
</ajc-test>

<ajc-test dir="new" pr="776"
title="self-reference from (aspect-declared) method-local class (correct test in knownbugs)"
keywords="tofix"
comment="correct behavior for 1.0 is good error message, see real test in knownbugs">
<compile files="MethodSelfReference.java">
<message kind="error" line="16"/>
</compile>
</ajc-test>

<ajc-test dir="ng"
title="parenthesized type name as qualifying expr is illegal (in j2sdk1.4.1beta)"
keywords="tofix">
<compile files="Parens1.java">
<message kind="error" line="3"/>
</compile>
</ajc-test>

<ajc-test dir="new" title="expect CE for unterminated declare error"
keywords="tofix">
<compile files="UnterminatedDeclareErrorCE.java">
<message kind="error" line="7"/>
</compile>
</ajc-test>

<ajc-test dir="new"
title="expect CE for declaration collision between subaspects instead of domination order"
keywords="tofix">
<compile files="DeclarationCollisionCE.java">
<message kind="error" line="28"/>
</compile>
</ajc-test>

<ajc-test dir="new"
title="subtype pattern in dominates should pick out aspect subtypes"
keywords="tofix">
<compile files="DominatesTypePattern.java"/>
<run class="DominatesTypePattern"/>
</ajc-test>

<ajc-test dir="ng"
title="long-standing bug in javac and ajc about non-verifiable try stmt"
keywords="tofix">
<compile files="TryVerification.java"/>
<run class="TryVerification"/>
</ajc-test>

<ajc-test dir="new"
title="unmatched type name in a declare parents should result in a warning in -Xlint mode"
keywords="tofix">
<compile options="-Xlint" files="MissingTypeInDeclareParents.java">
<message kind="warning" line="20"/>
</compile>
<run class="MissingTypeInDeclareParents"/>
</ajc-test>

<ajc-test dir="new" pr="804"
title="aspect static initializers should run before instance constructed"
keywords="tofix">
<compile files="AspectStaticInit.java"/>
<run class="AspectStaticInit"/>
</ajc-test>

<ajc-test dir="new" pr="827"
title="after returning advice on interface and implementation constructor"
keywords="tofix">
<compile files="AfterReturningConstructor.java"/>
<run class="AfterReturningConstructor"/>
</ajc-test>

<ajc-test dir="new" pr="832"
title="after throwing advice with non-throwable formal"
keywords="tofix">
<compile files="AfterThrowingNonThrowable.java"/>
<run class="AfterThrowingNonThrowable"/>
</ajc-test>

<ajc-test dir="new" pr="823"
title="declaring a private method on an inner interface"
keywords="tofix">
<compile files="PrivateMethodOnInnerInterface.java"/>
<run class="PrivateMethodOnInnerInterface"/>
</ajc-test>

<ajc-test dir="new" pr="829"
title="CE expected when declaring fields on arrays" keywords="tofix">
<compile files="ArrayFieldDeclarationCE.java">
<message kind="error" line="14"/>
</compile>
</ajc-test>

<ajc-test dir="new" pr="829" title="declare array field using postfix"
keywords="tofix">
<compile files="ArrayFieldDeclaration.java"/>
<run class="ArrayFieldDeclaration"/>
</ajc-test>

<ajc-test dir="new" pr="838"
title="checking around join point for advice return type - numeric"
keywords="tofix" comment="may need to fix error line when bug is fixed">
<compile files="AroundNumericCastCE.java">
<message kind="error" line="17"/>
</compile>
</ajc-test>

<ajc-test dir="new" pr="836" title="void around advice without proceed"
keywords="tofix">
<compile files="VoidAround.java"/>
<run class="VoidAround"/>
</ajc-test>

<ajc-test dir="new" pr="851"
title="prohibit declaring new aspect constructor with arguments">
<compile files="DeclareAspectConstructorCE.java">
<message kind="error" line="10"/>
</compile>
</ajc-test>

<ajc-test dir="new" pr="851"
title="prohibit declaring only aspect constructor with arguments">
<compile files="DeclareOnlyAspectConstructorCE.java">
<message kind="error" line="10"/>
</compile>
</ajc-test>

<ajc-test dir="new/PR852" pr="852"
title="declaring method on superclass and subclass">
<compile files="aspect/Aspect.java,target/SubClass.java,target/SuperClass.java">
<dir-changes added="target.SubClass,target.SuperClass"/>
</compile>
<run class="aspect.Aspect"/>
</ajc-test>

<ajc-test dir="new" pr="853"
title="declare class extends interface">
<compile files="DeclareClassExtendsInterface.java">
<message kind="error" line="10"/>
</compile>
</ajc-test>

<ajc-test dir="new" pr="853"
title="declare class implements class">
<compile files="DeclareClassImplementsClass.java">
<message kind="error" line="10"/>
</compile>
</ajc-test>

<ajc-test dir="new" pr="853"
title="declare interface implements interface">
<compile files="DeclareInterfaceImplementsInterface.java">
<message kind="error" line="10"/>
</compile>
</ajc-test>

<ajc-test dir="new/PR862" pr="862"
title="import any inner from interface implementor"
keywords="purejava">
<compile files="pack/ImportInnerFromInterfaceImplementor.java">
<dir-changes added="pack.ImportInnerFromInterfaceImplementor"/>
</compile>
<run class="pack.ImportInnerFromInterfaceImplementor"/>
</ajc-test>
<ajc-test dir="ng"
title="wrong scope for inner class creation expression">
<compile files="InnerClassCreate.java"/>
<run class="InnerClassCreate"/>
</ajc-test>

<ajc-test dir="ng"
title="definite unassignment versus try-finally">
<compile files="DefiniteUnassignmentTry.java"/>
<run class="DefiniteUnassignmentTry"/>
</ajc-test>

<ajc-test dir="ng"
title="definite assignment with constant subexpression in control-flow ops">
<compile files="DefiniteAssignmentControlFlow.java">
<dir-changes added="DefiniteAssignmentControlFlow"/>
</compile>
<run class="DefiniteAssignmentControlFlow"/>
</ajc-test>

<ajc-test dir="ng"
title="conversion from null">
<compile files="ConvertFromNull.java">
<message kind="error" line="8"/>
</compile>
</ajc-test>

<ajc-test dir="ng"
title="conflicting throws on inherited abstract methods">
<compile files="ConflictingThrows.java"/>
<run class="ConflictingThrows"/>
</ajc-test>

<ajc-test dir="new"
title="if and cflow arg binding">
<compile files="CflowBinding.java">
<message kind="error" line="13"/>
</compile>
</ajc-test>

</suite>

+ 26
- 0
tests/ajde/examples/figures-cacm/Test_Figures_CACM.jpx View File

@@ -0,0 +1,26 @@
<?xml version="1.0" encoding="UTF-8"?>
<!--JBuilder XML Project-->
<project>
<property category="runtime.0" name="RunnableType" value="com.borland.jbuilder.runtime.ApplicationRunner" />
<property category="runtime.0" name="application.class" value="figures.Main" />
<property category="sys" name="BackupPath" value="bak" />
<property category="sys" name="CheckStable" value="1" />
<property category="sys" name="Company" value="" />
<property category="sys" name="Copyright" value="Copyright (c) 2001" />
<property category="sys" name="Description" value="" />
<property category="sys" name="DocPath" value="." />
<property category="sys" name="ExcludeClassEnabled" value="0" />
<property category="sys" name="JDK" value="java 1.3.0_02" />
<property category="sys" name="LastTag" value="0" />
<property category="sys" name="Libraries" value="" />
<property category="sys" name="MakeStable" value="0" />
<property category="sys" name="OutPath" value="." />
<property category="sys" name="SourcePath" value="." />
<property category="sys" name="Title" value="" />
<property category="sys" name="Version" value="1.0" />
<property category="sys" name="WorkingDirectory" value="." />
<node type="Package" name="figures" />
<file path="Vanilla.lst" />
</project>

+ 9
- 0
tests/ajde/examples/figures-cacm/figures/Display.java View File

@@ -0,0 +1,9 @@

package figures;

class Display {

static void needsRepaint() { }

}


+ 15
- 0
tests/ajde/examples/figures-cacm/figures/DisplayUpdating.java View File

@@ -0,0 +1,15 @@

package figures;

aspect DisplayUpdating {

pointcut moves(): call(void FigureElement.moveBy(int, int)) ||
call(void Point.setX(int)) ||
call(void Point.setY(int)) ||
call(void Line.setP1(Point)) ||
call(void Line.setP2(Point));

after(): moves() {
Display.needsRepaint();
}
}

+ 12
- 0
tests/ajde/examples/figures-cacm/figures/FactoryEnforcement.java View File

@@ -0,0 +1,12 @@

package figures;

aspect FactoryEnforcement {

pointcut illegalNewFigElt(): call(FigureElement+.new(..)) &&
!withincode(* Figure.make*(..));

declare error: illegalNewFigElt():
"Illegal figure element constructor call.";

}

+ 23
- 0
tests/ajde/examples/figures-cacm/figures/Figure.java View File

@@ -0,0 +1,23 @@

package figures;

import java.util.List;
import java.util.LinkedList;


class Figure {

List elements = new LinkedList();

Point makePoint(int x, int y) {
Point p = new Point(x, y);
elements.add(p);
return p;
}

Line makeLine(Point p1, Point p2) {
Line l = new Line(p1, p2);
elements.add(l);
return l;
}
}

+ 8
- 0
tests/ajde/examples/figures-cacm/figures/FigureElement.java View File

@@ -0,0 +1,8 @@

package figures;

interface FigureElement {

public void moveBy(int dx, int dy);

}

+ 23
- 0
tests/ajde/examples/figures-cacm/figures/Line.java View File

@@ -0,0 +1,23 @@

package figures;

class Line {
private Point p1, p2;

Line(Point p1, Point p2) {
super();
this.p1 = p1;
this.p2 = p2;
}

Point getP1() { return p1; }
Point getP2() { return p2; }

void setP1(Point p1) { this.p1 = p1; }
void setP2(Point p2) { this.p2 = p2; }

void moveBy(int dx, int dy) {
getP1().moveBy(dx, dy);
getP2().moveBy(dx, dy);
}
}

+ 17
- 0
tests/ajde/examples/figures-cacm/figures/Main.java View File

@@ -0,0 +1,17 @@

package figures;

class Main {

public static void main(String [] args) {
System.out.println("> starting figures. . . " + 0);
// Figure fig = new Figure();
Point p1 = new Point(2, 2);
p1.setX(10);
p1.setX(20);
System.out.println("> p1.x: " + p1.getX());
// Point p2 = fig.makePoint(4, 4);
// System.out.println("> finished.");
}
}


+ 33
- 0
tests/ajde/examples/figures-cacm/figures/Point.java View File

@@ -0,0 +1,33 @@

package figures;

class Point {
private int x = 0, y = 0;

Point(int x, int y) {
super();
this.x = x;
this.y = y;
}

int getX() {
return x;
}

int getY() {
return y;
}

void setX(int x) {
this.x = x;
}

void setY(int y) {
this.y = y;
}

void moveBy(int dx, int dy) {
setX(getX() + dx);
setY(getY() + dy);
}
}

+ 13
- 0
tests/ajde/examples/figures-cacm/figures/PointBoundsChecking.java View File

@@ -0,0 +1,13 @@

package figures;

aspect PointBoundsChecking {

pointcut tracePoints(): call(void Point.setX(int)) ||
call(void Point.setY(int));

before(): tracePoints() {
System.out.println("Entering:" + thisJoinPoint);
}
}


+ 13
- 0
tests/ajde/examples/figures-cacm/figures/SimpleTracing.java View File

@@ -0,0 +1,13 @@

package figures;

aspect SimpleTracing {

pointcut tracePoints(): call(void Point.setX(int)) ||
call(void Point.setY(int));

before(): tracePoints() {
System.out.println("Entering:" + thisJoinPoint);
}
}


+ 25
- 0
tests/ajde/examples/figures-coverage/Test_Figures_Coverage.jpr View File

@@ -0,0 +1,25 @@
;JBuilder -- PROJECT FILE VERSION {2.00} - do not alter this line!
#0=Test_Figures_Coverage.jpr
#2=figures
#3=editor
sys[0].BackupPath=bak
sys[0].CheckStable=1
sys[0].Company=
sys[0].Copyright=Copyright (c) 2001
sys[0].DefaultPackage=test_figures_coverage
sys[0].Description=
sys[0].DocPath=doc
sys[0].ExcludeClassEnabled=0
sys[0].JDK=java 1.3.0-C
sys[0].LastTag=3
sys[0].Libraries=
sys[0].MakeStable=0
sys[0].OutPath=.
sys[0].SourcePath=.
sys[0].Title=
sys[0].Version=1.0
sys[0].WorkingDirectory=.
sys[2].Parent=0
sys[2].Type=Package
sys[3].Parent=0
sys[3].Type=Package

+ 37
- 0
tests/ajde/examples/figures-coverage/Test_Figures_Coverage.jpx View File

@@ -0,0 +1,37 @@
<?xml version="1.0" encoding="UTF-8"?>
<!--JBuilder XML Project-->
<project>
<property category="ajde" name="ajc.flags" value="-deprecation "/>
<property category="ajde" name="browser.associations" value="introduces on;uses pointcut;affects methods;affects method call sites;affects constructions;affects handlers;affects initializers;"/>
<property category="idl" name="ProcessIDL" value="false"/>
<property category="runtime.0" name="RunnableType" value="com.borland.jbuilder.runtime.ApplicationRunner"/>
<property category="runtime.0" name="application.class" value="figures.Main"/>
<property category="sys" name="AuthorLabel" value="@author"/>
<property category="sys" name="BackupPath" value="../temp"/>
<property category="sys" name="CheckStable" value="1"/>
<property category="sys" name="Company" value=""/>
<property category="sys" name="CompanyLabel" value="Company:"/>
<property category="sys" name="CompileOnRun" value="0"/>
<property category="sys" name="Copyright" value="Copyright (c) 2001"/>
<property category="sys" name="CopyrightLabel" value="Copyright:"/>
<property category="sys" name="Description" value=""/>
<property category="sys" name="DescriptionLabel" value="Description:"/>
<property category="sys" name="DocPath" value="."/>
<property category="sys" name="ExcludeClassEnabled" value="0"/>
<property category="sys" name="JDK" value="java 1.3.0_02"/>
<property category="sys" name="LastTag" value="0"/>
<property category="sys" name="Libraries" value=""/>
<property category="sys" name="MakeStable" value="0"/>
<property category="sys" name="OutPath" value="classes"/>
<property category="sys" name="SourcePath" value="."/>
<property category="sys" name="Title" value=""/>
<property category="sys" name="TitleLabel" value="Title:"/>
<property category="sys" name="Version" value="1.0"/>
<property category="sys" name="VersionLabel" value="@version"/>
<property category="sys" name="WorkingDirectory" value="../temp"/>
<property category="sys" name="enable.auto.packages" value="false"/>
<node name="figures" type="Package"/>
<file path="Probe.lst"/>
<file path="Test_Figures_Coverage.lst"/>
<file path="Trace.aj"/>
</project>

+ 4
- 0
tests/ajde/examples/figures-coverage/Trace.aj View File

@@ -0,0 +1,4 @@
aspect Trace {
}

+ 3
- 0
tests/ajde/examples/figures-coverage/_JoinpointProbe.java View File

@@ -0,0 +1,3 @@
aspect JoinpointProbe {
before(): null
{ } }

+ 4
- 0
tests/ajde/examples/figures-coverage/editor/Editor.java View File

@@ -0,0 +1,4 @@

package editor;

class Editor { }

+ 7
- 0
tests/ajde/examples/figures-coverage/figures/Debug.java View File

@@ -0,0 +1,7 @@

package figures;

aspect Debug {

}


+ 78
- 0
tests/ajde/examples/figures-coverage/figures/Figure.java View File

@@ -0,0 +1,78 @@

package figures;

//import figures.primitives.planar.Point;

aspect Figure {
//pointcut sendSuccess(): cflow(setX()) && !handler(Exception);

public String Point.getName() {
return Point.name;
}

public int Point.DEFAULT_X = 0;

public pointcut constructions(): call(Point.new(int, int)) || call(SolidPoint.new(int, int, int));

public pointcut moves(FigureElement fe): target(fe) &&
(call(String Point.getName()) ||
call(void FigureElement.incrXY(int, int)) ||
call(void Point.setX(int)) ||
call(void Point.setY(int)) ||
call(void SolidPoint.setZ(int)));

pointcut mainExecution(): execution(void main(*));
pointcut runtimeHandlers(): mainExecution() || handler(RuntimeException);
public pointcut mumble(): runtimeHandlers();

before(): constructions() {
System.out.println("> before construction, jp: " + thisJoinPoint.getSignature());
}

before(FigureElement fe): moves(fe) {
System.out.println("> about to move FigureElement at X-coord: ");
}

after(): initialization(Point.new(..)) || staticinitialization(Point) {
System.out.println("> Point initialized");
}

// should be around
after(): mumble() {
System.err.println(">> in after advice...");
//proceed();
}

after(FigureElement fe): target(fe) &&
(call(void FigureElement.incrXY(int, int)) ||
call(void Point.setX(int)) ||
call(void Point.setY(int)) ||
call(void SolidPoint.setZ(int))) {
System.out.println("> yo.");
}

after(FigureElement fe):
target(fe) &&
(call(void FigureElement.incrXY(int, int)) ||
call(void Line.setP1(Point)) ||
call(void Line.setP2(Point)) ||
call(void Point.setX(int)) ||
call(void Point.setY(int))) { }

declare parents: Point extends java.io.Serializable;

declare parents: Point implements java.util.Observable;

declare soft: Point: call(* *(..));
}

aspect Checks {
pointcut illegalNewFigElt(): call(FigureElement+.new(..)) &&
!withincode(* Main.main(..));

declare error: illegalNewFigElt():
"Illegal figure element constructor call.";

declare warning: illegalNewFigElt():
"Illegal figure element constructor call.";
}

+ 9
- 0
tests/ajde/examples/figures-coverage/figures/FigureElement.java View File

@@ -0,0 +1,9 @@

package figures;

public interface FigureElement extends Element {

public void incrXY(int dx, int dy);
}

interface Element { }

+ 48
- 0
tests/ajde/examples/figures-coverage/figures/Main.java View File

@@ -0,0 +1,48 @@

package figures;

import figures.primitives.planar.Point;
import figures.primitives.solid.SolidPoint;

class Main {

private static Point startPoint;

public static void main(String[] args) {
try {
System.out.println("> starting...");

startPoint = makeStartPoint();
//startPoint.setX(3); new Point(0, 0);
// SolidPoint sp1 = new SolidPoint(1, 3, 3);

// sp1.setZ(1);
// p1.incrXY(3, 3);
} catch (RuntimeException re) {
re.printStackTrace();
}
System.out.println("> finished.");
}

/** @deprecated use something else */
public static Point makeStartPoint() {
//return new Point(1, 2);
return null;
}

/** This should produce a deprecation warning with JDK > 1.2 */
static class TestGUI extends javax.swing.JFrame {
TestGUI() {
this.disable();
}
}

/** This should produce a porting-deprecation warning. */
//static pointcut mainExecution(): execution(void main(*));
}

privileged aspect Test {
before(Point p, int newval): target(p) && set(int Point.xx) && args(newval) {
System.err.println("> new value of x is: " + p.x + ", setting to: " + newval);
}
}

+ 4
- 0
tests/ajde/examples/figures-coverage/figures/Trace.aj View File

@@ -0,0 +1,4 @@
aspect Trace {
}

+ 6
- 0
tests/ajde/examples/figures-coverage/figures/composites/Line.java View File

@@ -0,0 +1,6 @@

package figures.composites;

class Line { }

class BoundedLine extends Line { }

+ 6
- 0
tests/ajde/examples/figures-coverage/figures/composites/Square.java View File

@@ -0,0 +1,6 @@

package figures.composites;

class Square {
private String name = "Square";
}

+ 65
- 0
tests/ajde/examples/figures-coverage/figures/primitives/planar/Point.java View File

@@ -0,0 +1,65 @@

package figures.primitives.planar;

import figures.*;
import java.util.Collection;

public class Point implements FigureElement {

static int xx = -1;
private int x;
private int y;
transient int currVal = 0;
public static String name;

int c; int b; int a;
{
x = 0;
y = 0;
}

static {
Point.name = "2-Dimensional Point";
}

public Point(int x, int y) {
this.x = x;
this.y = y;
}

int getCurrVal() {
return currVal;
}

/**
* @see Figure#moves
*/
public int getX() { return x; }

public int getY() { return y; }

public void setX(int x) { this.x = x; }

public void setY(int x) { this.y = x; }

public void incrXY(int dx, int dy) {
setX(getX() + dx);
setY(getY() + dy);
}
public void check(int dx, int dy)
throws ArithmeticException, PointBoundsException {
if (dx < 0 || dy < 0) throw new PointBoundsException();
}
}

class PointBoundsException extends Exception { }

class BoundedPoint extends Point {
public BoundedPoint(int x, int y) { super(x, y); }
}

class StrictlyBoundedPoint extends BoundedPoint {
public StrictlyBoundedPoint(int x, int y) { super(x, y); }
}



+ 24
- 0
tests/ajde/examples/figures-coverage/figures/primitives/solid/SolidPoint.java View File

@@ -0,0 +1,24 @@

package figures.primitives.solid;

import java.util.Collection;
import java.lang.String;
import figures.primitives.planar.*;

public class SolidPoint extends Point {
private int z;

public SolidPoint(int x, int y, int z) {
super(x, y);
this.z = z;
}

public int getZ() { return z; }

public void setZ(int z) { this.z = z; }

public void incrXY(int dx, int dy) {
super.incrXY(dx, dy);
setZ(getZ() + dx + dy);
}
}

+ 25
- 0
tests/ajde/examples/observer-gof/Test_Observer.jpx View File

@@ -0,0 +1,25 @@
<?xml version="1.0" encoding="UTF-8"?>
<!--JBuilder XML Project-->
<project>
<property category="runtime.0" name="application.class" value="" />
<property category="sys" name="BackupPath" value="bak" />
<property category="sys" name="CheckStable" value="1" />
<property category="sys" name="Company" value="" />
<property category="sys" name="Copyright" value="Copyright (c) 2001" />
<property category="sys" name="Description" value="" />
<property category="sys" name="DocPath" value="." />
<property category="sys" name="ExcludeClassEnabled" value="0" />
<property category="sys" name="JDK" value="java 1.3.0_02" />
<property category="sys" name="LastTag" value="0" />
<property category="sys" name="Libraries" value="" />
<property category="sys" name="MakeStable" value="0" />
<property category="sys" name="OutPath" value="." />
<property category="sys" name="SourcePath" value="." />
<property category="sys" name="Title" value="" />
<property category="sys" name="Version" value="1.0" />
<property category="sys" name="WorkingDirectory" value="." />
<node type="Package" name="clock" />
<file path="../figures-coverage/Test_Figures_Coverage.lst" />
</project>

+ 12
- 0
tests/ajde/examples/observer-gof/clock/AnalogClock.java View File

@@ -0,0 +1,12 @@

package clock;
public class AnalogClock implements Clock {
public AnalogClock(ClockTimer subject) {
super();
}
public void update(ClockTimer subject, Object args) {
}

public void draw() {
}
}

+ 5
- 0
tests/ajde/examples/observer-gof/clock/Clock.java View File

@@ -0,0 +1,5 @@

package clock;
interface Clock {
void update(ClockTimer subject, Object args);
}

+ 33
- 0
tests/ajde/examples/observer-gof/clock/ClockTimer.java View File

@@ -0,0 +1,33 @@

package clock;
import java.util.*;

public class ClockTimer extends Observable {
List observers;
public int getHour() {
return 0;
}

public int getMinute() {
return 0;
}

public int getSeconds() {
return 0;
}

public void addObserver(Object observer) {
this.observers.add(observer);
}

public void tick() {
this.notifyObservers();
}

public ClockTimer() {
super();
{
this.observers = new ArrayList();
}
}
}

+ 26
- 0
tests/ajde/examples/observer-gof/clock/DigitalClock.java View File

@@ -0,0 +1,26 @@

package clock;

public class DigitalClock implements Clock {
private ClockTimer subject;

public DigitalClock(ClockTimer subject) {
super();
this.subject = subject;
this.subject.addObserver(this);
}
public void removeObserver(Object observer) {
this.subject.observers.remove(observer);
}

public void update(ClockTimer subject, Object args) {
if (this.subject == subject) {
this.draw();
}
}

public void draw() {
int hour = this.subject.getHour();
int minute = this.subject.getMinute();
}
}

+ 14
- 0
tests/ajde/examples/observer-gof/clock/Main.java View File

@@ -0,0 +1,14 @@

package clock;

import java.util.Observer;
import java.util.Observable;

public class Main {

public static void main(String[] args) {
ClockTimer clockTimer = new ClockTimer();
DigitalClock digitalClock = new DigitalClock(clockTimer);
AnalogClock analogClock = new AnalogClock(clockTimer);
}
}

+ 9
- 0
tests/ajde/examples/observer-gof/clock/MonitorObservation.java View File

@@ -0,0 +1,9 @@
package clock;

aspect MonitorObservation {

before(): call(void Clock.update(..))
|| execution(void *.addObserver(..))
|| execution(void *.removeObserver(..)) {
}
}

+ 23
- 0
tests/ajde/examples/observer/Test_Observer.jpx View File

@@ -0,0 +1,23 @@
<?xml version="1.0" encoding="UTF-8"?>
<!--JBuilder XML Project-->
<project>
<property category="sys" name="BackupPath" value="bak" />
<property category="sys" name="CheckStable" value="1" />
<property category="sys" name="Company" value="" />
<property category="sys" name="Copyright" value="Copyright (c) 2001" />
<property category="sys" name="Description" value="" />
<property category="sys" name="DocPath" value="." />
<property category="sys" name="ExcludeClassEnabled" value="0" />
<property category="sys" name="JDK" value="java 1.3.0_02" />
<property category="sys" name="LastTag" value="0" />
<property category="sys" name="Libraries" value="" />
<property category="sys" name="MakeStable" value="0" />
<property category="sys" name="OutPath" value="." />
<property category="sys" name="SourcePath" value="." />
<property category="sys" name="Title" value="" />
<property category="sys" name="Version" value="1.0" />
<property category="sys" name="WorkingDirectory" value="." />
<node type="Package" name="clock" />
</project>

+ 21
- 0
tests/ajde/examples/observer/clock/AnalogueClock.java View File

@@ -0,0 +1,21 @@

package clock;

import java.util.Observer;
import java.util.Observable;

public class AnalogueClock implements Observer {

public AnalogueClock (ClockTimer subject) {

}

public void update(Observable theChangedSubject, Object args) {

}

public void draw() {

}
}


+ 23
- 0
tests/ajde/examples/observer/clock/ClockTimer.java View File

@@ -0,0 +1,23 @@

package clock;

import java.util.Observable;

public class ClockTimer extends Observable {

public void tick () {
notifyObservers();
}

public int getHour() {
return 0;
}

public int getMinute() {
return 0;
}

public int getSeconds() {
return 0;
}
}

+ 30
- 0
tests/ajde/examples/observer/clock/DigitalClock.java View File

@@ -0,0 +1,30 @@

package clock;

import java.util.Observer;
import java.util.Observable;

public class DigitalClock implements Observer {

private ClockTimer subject;

public DigitalClock (ClockTimer subject) {
this.subject = subject;
this.subject.addObserver(this);
}

public void removeObserver() {
subject.deleteObserver(this);
}

public void update(Observable theChangedSubject, Object args) {
if (theChangedSubject == subject) {
draw();
}
}

public void draw () {
int hour = subject.getHour();
int minute = subject.getMinute();
}
}

+ 15
- 0
tests/ajde/examples/observer/clock/Main.java View File

@@ -0,0 +1,15 @@
package clock;

import java.util.Observer;
import java.util.Observable;

public class Main {

public static void main(String[] args) {
System.err.println("> starting clock...");
ClockTimer clockTimer = new ClockTimer();
DigitalClock digitalClock = new DigitalClock(clockTimer);
AnalogueClock analogueClock = new AnalogueClock(clockTimer);
}
}


+ 14
- 0
tests/ajde/examples/observer/clock/MonitorObservation.java View File

@@ -0,0 +1,14 @@
package clock;

import java.util.Observer;
import java.util.Observable;

aspect MonitorObserveration {
before():
(call(void Observer.update(Observable, Object))
|| call(void Observable.addObserver(Observer))
|| call(void Observable.removeObserver(Observer))) {

}
}


+ 28
- 0
tests/ajde/examples/spacewar/Test_Spacewar.jpx View File

@@ -0,0 +1,28 @@
<?xml version="1.0" encoding="UTF-8"?>
<!--JBuilder XML Project-->
<project>
<property category="ajde" name="ajc.flags" value="" />
<property category="runtime.0" name="RunnableType" value="com.borland.jbuilder.runtime.ApplicationRunner" />
<property category="runtime.0" name="application.class" value="spacewar.Game" />
<property category="sys" name="BackupPath" value="bak" />
<property category="sys" name="CheckStable" value="1" />
<property category="sys" name="Company" value="" />
<property category="sys" name="Copyright" value="Copyright (c) 2001" />
<property category="sys" name="Description" value="" />
<property category="sys" name="DocPath" value="." />
<property category="sys" name="ExcludeClassEnabled" value="0" />
<property category="sys" name="JDK" value="java 1.3.0_02" />
<property category="sys" name="LastTag" value="0" />
<property category="sys" name="Libraries" value="" />
<property category="sys" name="MakeStable" value="0" />
<property category="sys" name="OutPath" value="." />
<property category="sys" name="SourcePath" value="." />
<property category="sys" name="Title" value="" />
<property category="sys" name="Version" value="1.0" />
<property category="sys" name="WorkingDirectory" value="." />
<node type="Package" name="coordination" />
<node type="Package" name="spacewar" />
<file path="Release.lst" />
</project>

+ 20
- 0
tests/ajde/examples/spacewar/coordination/Condition.java View File

@@ -0,0 +1,20 @@

package coordination;


/**
* Interface for pre-conditions that are passed to guardedEntry methods of
* Coordinator.
* Conditions should be passed as anonymous classes that simply implement
* the checkit method.
*
*/
public interface Condition {

/**
* This method is called automatically by Coordinator.guardedEntry(...)
* and it's called everytime the coordination state changes.
*/

public boolean checkit();
}

+ 20
- 0
tests/ajde/examples/spacewar/coordination/CoordinationAction.java View File

@@ -0,0 +1,20 @@

package coordination;


/**
* Interface for coordination actions that are passed to guardedEntry methods of
* Coordinator.
* Coordination actions should be passed as anonymous classes that simply
* implement the doit method.
*
*/
public interface CoordinationAction {
/**
* This method is called by Coordinator.guardedEntry(...) and
* Coordinator.guardedExit(...). Use it for changing coordination state
* upon entering and exiting methods.
*/

public void doit();
}

+ 432
- 0
tests/ajde/examples/spacewar/coordination/Coordinator.java View File

@@ -0,0 +1,432 @@

package coordination;

import java.util.*; //!!!

/**
* The Coordinator class provides the basic functionality for synchronizing
* and coordinating different threads upon entering and exiting methods.
* It can be used in two different ways:
* 1) by instantiating regular coordinator objects that are used by aspects; or
* 2) by extending it (sub-classing) with coordinator aspects.
* <P>
* Method invocations are the smallest units for defining critical sections
* and pre-conditions. The use of coordinators, either regular objects or aspect
* instances, should always end up by invoking guardedEntry(...) in a
* before weave and guardedExit(...) in an after weave for all methods that
* need coordination. guardedEntry and guardedExit are the methods that
* actually manage the synchronization and coordination constraints given
* by their parameters and by pre-existent exclusion markers.
* <P>
* The synchronization of threads for the execution of critical section
* methods in an object is done by marking those methods as self- and/or
* mutually-exclusive (addSelfex, addMutex).
* Just by itself, addSelfex("M") does not enforce the self-exclusion
* of method M - enforcement is done by invoking guardedEntry before
* M is executed. Similarly, addMutex(new String[] {"M1", "M2"}) does
* not enforce the mutual exclusion between methods M1 and M2.
* <P>
* A guardedEntry on a method that has been marked as self-exclusive
* ensures that the method is executed in the invoked object by only one thread
* at a time. A guardedEntry on a method that has been marked has mutually-
* exclusive with other methods ensures that the execution of that method
* by a thread in the invoked object temporarily blocks the execution by
* other threads of the methods that are in the same mutex set.
* <P>
* The coordination of threads, i.e. their explicit suspension and
* resumption, is done through the use of pre-conditions and coordination
* actions that are passed as parameters to guardedEntry and guardedExit
* with the form of anonymous classes.
*/
public abstract aspect Coordinator {
private Hashtable methods = null;
private Vector exclusions = null;
abstract protected pointcut synchronizationPoint();

public Coordinator() {
methods = new Hashtable();
exclusions = new Vector(5);
}

before (): synchronizationPoint() {
this.guardedEntry(thisJoinPointStaticPart.getSignature().getName());
}
after (): synchronizationPoint() {
this.guardedExit(thisJoinPointStaticPart.getSignature().getName());
}

/**
* Takes a multi-part method name (eg "BoundedBuffer.put")
* and marks that method as self-exclusive.
* No checks are made with respect to the existence of the method
* whose name is given.
*/
public synchronized void addSelfex(String methName) {
Selfex sex = new Selfex (methName);

// update db of all exclusions in this coordinator
exclusions.addElement(sex);

// update local info in method
Method aMeth = getOrSetMethod(methName);
aMeth.addExclusion(sex);
}

/**
* Takes a multi-part method name (e.g. "BoundedBuffer.put")
* and removes that method from the list of self-exclusive methods.
*/
public synchronized void removeSelfex(String methName) {
for (int i = 0; i < exclusions.size(); i++) {
Exclusion sex = (Exclusion)exclusions.elementAt(i);
if ((sex instanceof Selfex) &&
(((Selfex)sex).methodName.equals(methName))) {

// update db of all exclusions in this coordinator
exclusions.removeElementAt(i);

// update local info in method
Method aMeth = getOrSetMethod(methName);
aMeth.removeExclusion(sex);
}
}
}

/**
* Takes an array of multi-part method names and marks those
* methods as mutually exclusive.
* No checks are made with respect to the existence of the methods
* whose names are given.
*/
public synchronized void addMutex(String[] methNames) {
Mutex mux = new Mutex(methNames);

// update db of all exclusions in this coordinator
exclusions.addElement(mux);

// update local info in each method
for (int i = 0; i < methNames.length; i++) {
Method aMeth = getOrSetMethod(methNames[i]);
aMeth.addExclusion(mux);
}
}

/**
* Takes an array of multi-part method names that correspond
* to an existing mutex set and remove the mutual exclusion constraint.
* If the given mutex set does not exist, removeMutex does nothing.
*/
public synchronized void removeMutex(String[] methNames) {
for (int i = 0; i < exclusions.size(); i++) {
Exclusion mux = (Exclusion)exclusions.elementAt(i);
if (mux instanceof Mutex) {
boolean same = true;
for (int j = 0; j < methNames.length; j++)
if (!methNames[j].equals(((Mutex)mux).methodNames[j]))
same = false;
if (same) {
// update db of all exclusions in this coordinator
exclusions.removeElementAt(i);

// update local info in each method involved
for (int j = 0; j < methNames.length; j++) {
Method aMeth = getOrSetMethod(methNames[j]);
aMeth.removeExclusion(mux);
}
}
}
}
}

/**
* This method is the guard for enforcing all synchronization and
* coordination constraints of a given method, and it should be called
* just before the method is executed.
* In this form, only the method name is given. The only constraints
* checked are the exclusion constraints.
* If the method was previousely marked as selfex (through addSelfex),
* guardedEntry ensures that the method is executed only when no other
* thread is executing it.
* If the method was previousely marked as being in one or more mutex
* sets, guardedEntry ensures that the method is executed only when no other
* thread is executing any of the methods with which the give method is
* mutexed.
*/
public synchronized void guardedEntry(String methName) {
guardedEntry(methName, new Condition() {
public boolean checkit() {
return true;
}
}, null);
}

/**
* Just like guardedEntry(String methName), but the given method is executed
* only when the given condition is true.
* guardedEntry is the guard for enforcing all synchronization and
* coordination constraints of a given method, and it should be called
* just before the method is executed.
* In this form, the method name is given along with a condition.
* The constraints checked are the exclusion constraints and whether
* the given condition is true.
* If the method was previousely marked as selfex (through addSelfex),
* guardedEntry ensures that the method is executed only when no other
* thread is executing it.
* If the method was previousely marked as being in one or more mutex
* sets, guardedEntry ensures that the method is executed only when no other
* thread is executing any of the methods with which the give method is
* mutexed.
* If the condition is false, guardedEntry suspends the current thread.
* That thread remains suspended until the condition becomes true, in
* which case all constraints are rechecked before the method is executed.
* When all exclusion constraints are checked and the given condition is
* true, the given method is executed.
*/
public synchronized void guardedEntry(String methName, Condition condition) {
guardedEntry(methName, condition, null);
}

/**
* Just like guardedEntry(String methName), but with an additional
* coordination action that is executed before the given method is
* executed.
* guardedEntry is the guard for enforcing all synchronization and
* coordination constraints of a given method, and it should be called
* just before the method is executed.
* In this form, the method name is given along with a coordination action.
* The only constraints checked are the exclusion constraints.
* If the method was previousely marked as selfex (through addSelfex),
* guardedEntry ensures that the method is executed only when no other
* thread is executing it.
* If the method was previousely marked as being in one or more mutex
* sets, guardedEntry ensures that the method is executed only when no other
* thread is executing any of the methods with which the give method is
* mutexed.
* The given coordination action is executed just before the given method
* is executed.
*/
public synchronized void guardedEntry(String methName,
CoordinationAction action) {
guardedEntry(methName, new Condition() {
public boolean checkit() {
return true;
}
},
action);
}

/**
* Just like guardedEntry(String methName), but the given method is executed
* only when the given condition is true; the additional
* coordination action that is executed before the given method is
* executed.
* guardedEntry is the guard for enforcing all synchronization and
* coordination constraints of a given method, and it should be called
* just before the method is executed.
* In this form, the method name is given along with a condition and
* a coordination action.
* The constraints checked are the exclusion constraints and whether the
* given condition is true.
* If the method was previousely marked as selfex (through addSelfex),
* guardedEntry ensures that the method is executed only when no other
* thread is executing it.
* If the method was previousely marked as being in one or more mutex
* sets, guardedEntry ensures that the method is executed only when no other
* thread is executing any of the methods with which the give method is
* mutexed.
* If the condition is false, guardedEntry suspends the current thread.
* That thread remains suspended until the condition becomes true, in
* which case all constraints are rechecked before the method is executed.
* When all exclusion constraints are checked and the given condition is
* true, the given method is executed.
* The given coordination action is executed just before the given method
* is executed.
*/
public synchronized void guardedEntry(String methName,
Condition condition,
CoordinationAction action) {
Method aMeth = getOrSetMethod(methName);
boolean canGo = false;

// test pre-conditions for entering the method
while (!canGo) {
canGo = true;
for (int i = 0; i < aMeth.exes.size() && canGo; i++)
if (!((Exclusion)aMeth.exes.elementAt(i)).testExclusion(aMeth.name)) {
canGo = false;
}
if (canGo && !condition.checkit()) {
canGo = false;
}
if (!canGo)
try {
wait();
} catch (InterruptedException e) { }
}

// OK.
enterMethod(aMeth, action);
}

/**
* This method is similar to guardedEntry, but it takes
* an additional parameter - the milliseconds after which any suspension
* will abort with a timeout.
*/
public synchronized void guardedEntryWithTimeout(String methName,
long millis)
throws TimeoutException {
guardedEntryWithTimeout(methName, new Condition() {
public boolean checkit() {
return true;
}
}, null, millis);
}

/**
* This method is similar to guardedEntry, but it takes
* an additional parameter - the milliseconds after which any suspension
* will abort with a timeout.
*/
public synchronized void guardedEntryWithTimeout(String methName,
Condition condition,
long millis)
throws TimeoutException {
guardedEntryWithTimeout(methName, condition, null, millis);
}

/**
* This method is similar to guardedEntry, but it takes
* an additional parameter - the milliseconds after which any suspension
* will abort with a timeout.
*/
public synchronized void guardedEntryWithTimeout(String methName,
CoordinationAction action,
long millis)
throws TimeoutException {
guardedEntryWithTimeout(methName, new Condition() {
public boolean checkit() {
return true;
}
}, action, millis);
}

/**
* This method is similar to guardedEntry, but it takes
* an additional parameter - the milliseconds after which any suspension
* will abort with a timeout.
*/
public synchronized void guardedEntryWithTimeout(String methName,
Condition condition,
CoordinationAction action,
long millis)
throws TimeoutException {

Method aMeth = getOrSetMethod(methName);
boolean canGo = false;
long waitTime = millis;
long startTime = System.currentTimeMillis();

// test pre-conditions for entering the method
while (!canGo) {
canGo = true;
for (int i = 0; i < aMeth.exes.size() && canGo; i++)
if ((!((Exclusion)aMeth.exes.elementAt(i)).testExclusion(aMeth.name)) ||
(!condition.checkit())) {
canGo = false;
}
if (!canGo) {
try {
wait(waitTime);
} catch (InterruptedException e) {}

long now = System.currentTimeMillis();
long timeSoFar = now - startTime;
if (timeSoFar >= millis) // timeout!
throw new TimeoutException(timeSoFar);
else // adjust time
waitTime = millis - timeSoFar;
}
}

// OK.
enterMethod(aMeth, action);
}

/**
* This method provides the means for updating all synchronization and
* coordination state after the execution of a given method, and it should be
* called after the method is executed.
* In this form, only the method name is given.
* The synchronization state for self- and mutual-exclusion is
* automatically upadted.
*/
public synchronized void guardedExit(String methName) {
guardedExit(methName, null);
}

/**
* Just like guardedExit(String methName) but with an additional
* coordination action that is executed.
* guardedExit provides the means for updating all synchronization and
* coordination state after the execution of a given method, and it should be
* called after the method is executed.
* In this form, the method name is given along with a coordination action.
* The synchronization state for self- and mutual-exclusion is
* automatically upadted.
* The given coordination action is executed.
*/
public synchronized void guardedExit(String methName,
CoordinationAction action) {
Method aMeth = getOrSetMethod(methName);

for (int i = 0; i < aMeth.exes.size(); i++)
((Exclusion)aMeth.exes.elementAt(i)).exitExclusion(methName);
if (action != null) action.doit();
notifyAll();
}

private Method getOrSetMethod(String methName) {
Method aMeth = null;
if (!methods.containsKey(methName)) {
methods.put(methName, (aMeth = new Method(methName)));
}
else {
aMeth = (Method) methods.get(methName);
}
return aMeth;
}

private void enterMethod(Method aMeth, CoordinationAction action) {
for (int i = 0; i < aMeth.exes.size(); i++)
((Exclusion)aMeth.exes.elementAt(i)).enterExclusion(aMeth.name);

if (action != null) action.doit();
}



}

class Method {
String name;
Vector exes = new Vector(3);

Method(String n) {
name = n;
}

void addExclusion(Exclusion ex) {
exes.addElement(ex);
}

void removeExclusion(Exclusion ex) {
for (int i = 0; i < exes.size(); i++) {
if (exes.elementAt(i) == ex)
exes.removeElementAt(i);
}
}
}


+ 16
- 0
tests/ajde/examples/spacewar/coordination/Exclusion.java View File

@@ -0,0 +1,16 @@

package coordination;


interface Exclusion {

boolean testExclusion(String methodName);

void enterExclusion(String methodName);

void exitExclusion(String methodName);

// for debug !!!
void printNames();
}


+ 28
- 0
tests/ajde/examples/spacewar/coordination/MethodState.java View File

@@ -0,0 +1,28 @@

package coordination;

import java.util.Vector;
import java.util.Enumeration;


class MethodState {

Vector threads=new Vector();

void enterInThread (Thread t) {
threads.addElement(t);
}

void exitInThread(Thread t) {
threads.removeElement(t);
}

boolean hasOtherThreadThan(Thread t) {
Enumeration e = threads.elements();
while (e.hasMoreElements())
if (e.nextElement() != t)
return(true);
return (false);
}

}

+ 69
- 0
tests/ajde/examples/spacewar/coordination/Mutex.java View File

@@ -0,0 +1,69 @@

package coordination;

import java.lang.String;


class Mutex implements Exclusion {
String[] methodNames;
MethodState[] methodStates;

String prettyName;
Mutex (String[] _methodNames) {
methodNames = _methodNames;
methodStates = new MethodState[methodNames.length];
for (int i = 0; i < methodNames.length; i++) {
methodStates[i] = new MethodState();
}
}

private boolean isMethodIn (String _methodName) {
for (int i = 0; i < methodNames.length; i++) {
if (_methodName.equals(methodNames[i]))
return(true);
}
return(false);
}

private MethodState getMethodState (String _methodName) {
for (int i = 0; i < methodNames.length; i++) {
if (_methodName.equals(methodNames[i]))
return(methodStates[i]);
}
return(null);
}

public boolean testExclusion (String _methodName) {
Thread ct = Thread.currentThread();
//
// Loop through each of the other methods in this exclusion set, to be sure
// that no other thread is running them. Note that we have to be careful
// about selfex.
//
for (int i = 0; i < methodNames.length; i++) {
if (!_methodName.equals(methodNames[i])) {
if (methodStates[i].hasOtherThreadThan(ct))
return(false);
}
}
return (true);
}

public void enterExclusion (String _methodName) {
MethodState methodState = getMethodState(_methodName);
methodState.enterInThread(Thread.currentThread());
}

public void exitExclusion (String _methodName) {
MethodState methodState = getMethodState(_methodName);
methodState.exitInThread(Thread.currentThread());
}

public void printNames() {
System.out.print("Mutex names: ");
for (int i = 0; i < methodNames.length; i++)
System.out.print(methodNames[i] + " ");
System.out.println();
}
}

+ 38
- 0
tests/ajde/examples/spacewar/coordination/Selfex.java View File

@@ -0,0 +1,38 @@

package coordination;


import java.lang.String;

class Selfex implements Exclusion {
String methodName;
Thread thread;
int count = 0;

Selfex (String _methodName) {
methodName = _methodName;
}

public boolean testExclusion (String _methodName) {
if (count == 0)
return(true);
return (thread == Thread.currentThread());
}

public void enterExclusion (String _methodName) {
count++;
thread = Thread.currentThread(); // note that if count wasn't 0
// we aren't changing thread
}

public void exitExclusion (String _methodName) {
count--;
if (count == 0) // not stricly necessary, but...
thread = null;
}

public void printNames() {
System.out.println("Selfex name: " + methodName);
}

}

+ 10
- 0
tests/ajde/examples/spacewar/coordination/TimeoutException.java View File

@@ -0,0 +1,10 @@

package coordination;


public class TimeoutException extends Exception {
long time;
TimeoutException(long _time) {
time = _time;
}
}

+ 27
- 0
tests/ajde/examples/spacewar/spacewar/Bullet.java View File

@@ -0,0 +1,27 @@

package spacewar;

class Bullet extends SpaceObject {

static private final int SIZE = 3; //Can't be changed for now!!!
static private int LIFETIME = 50;

private int lifeLeft;

Bullet (Game theGame, double xP, double yP, double xV, double yV) {
super(theGame, xP, yP, xV, yV);
lifeLeft = LIFETIME;
}

int getSize() { return SIZE; }

void handleCollision(SpaceObject obj) {
die();
}

void clockTick() {
if (--lifeLeft == 0)
die();
super.clockTick();
}
}

+ 199
- 0
tests/ajde/examples/spacewar/spacewar/Debug.java View File

@@ -0,0 +1,199 @@

package spacewar;

import java.awt.Menu;
import java.awt.CheckboxMenuItem;
import java.awt.Frame;
import java.awt.TextArea;
import java.awt.Dimension;

/**
* This aspect specifies debugging information to be output to the
* information window.
*
* When the debug aspect is compiled in the Frame menu has several checkbox
* items that can be used to control the amount of tracing information
* displayed. (By default the first three are off, because they generate
* so much information.)
*
* There are two reasons to gather all this debugging code into an aspect
* like this:
*
* (1) It makes it easier to understand when it is all in one place.
*
* (2) It means that we can "plug and debug". We can enable/disable
* the debugging code simply by weaving or not weaving this
* aspect in.
*
* All in all, this is a lot better than the usual practice of writing
* complex debugging code and then deleting it when the bug is found,
* only to regret it a month later when a related bug surfaces. (Or even
* the same bug!)
*
* This file also defines a class InfoWin, which it uses to display all the
* debugging information.
*/
aspect Debug {

private static InfoWin infoWin = new InfoWin();

private static Menu menu = new Menu("Debug");

private static CheckboxMenuItem traceConstructors =
new CheckboxMenuItem("trace constructors", false);
private static CheckboxMenuItem traceInitializations =
new CheckboxMenuItem("trace initializations", false);
private static CheckboxMenuItem traceMethods =
new CheckboxMenuItem("trace methods", false);
private static CheckboxMenuItem traceClockTick =
new CheckboxMenuItem("trace clock tick", false);
private static CheckboxMenuItem traceRegistry =
new CheckboxMenuItem("trace registry", true);
private static CheckboxMenuItem traceFireCollideDamage =
new CheckboxMenuItem("trace fire, collide, damage", true);

after() returning (SWFrame frame): call(SWFrame+.new(..)) {
menu.add(traceConstructors);
menu.add(traceInitializations);
menu.add(traceMethods);
menu.add(traceClockTick);
menu.add(traceRegistry);
menu.add(traceFireCollideDamage);
frame.getMenuBar().add(menu);
}

/*
* all constructors
*/
pointcut allConstructorsCut():
call((spacewar.* && !(Debug+ || InfoWin+)).new(..));

before(): allConstructorsCut() {
if (traceConstructors.getState()) {
infoWin.println("begin constructing " + thisJoinPoint.getSignature());
}
}

after(): allConstructorsCut() {
if (traceConstructors.getState()) {
infoWin.println("done constructing " + thisJoinPoint.getSignature());
}
}

/*
* All dynamic initializations
*/
pointcut allInitializationsCut():
initialization((spacewar.* && !(Debug+ || InfoWin+)).new(..));

before(): allInitializationsCut() {
if (traceConstructors.getState()) {
infoWin.println("begin initializing " + thisJoinPoint.getSignature());
}
}
after(): allInitializationsCut() {
if (traceConstructors.getState()) {
infoWin.println("done initializing " + thisJoinPoint.getSignature());
}
}

/*
* all methods
*/
pointcut allMethodsCut():
execution(* (spacewar.* && !(Debug+ || InfoWin+)).*(..));

before(): allMethodsCut() {
if (traceMethods.getState()) {
infoWin.println("entering " + thisJoinPoint.getSignature());
}
}
after(): allMethodsCut() {
if (traceMethods.getState()) {
infoWin.println("exiting " + thisJoinPoint.getSignature());
}
}

/*
* clock ticks
*/
after(Object obj):
(target(obj) && (target(Game) ||
target(Registry) ||
target(SpaceObject)))
&& call(void clockTick()) {
if (traceClockTick.getState())
infoWin.println("ticking " + obj);
}

/*
* registry contents
*/
after(Registry registry):
target(registry) && (call(void register(..)) ||
call(void unregister(..))) {
if (traceRegistry.getState())
infoWin.println(registry.getTable().size() +
" space objects in the registry.");
}

/*
* fire, collide, damage
*/
after(): call(void Ship.fire()) {
if (traceFireCollideDamage.getState())
infoWin.println("firing");
}

after(Ship ship, SpaceObject obj):
call(void Ship.handleCollision(SpaceObject)) && target(ship) && args(obj) {
if (traceFireCollideDamage.getState())
infoWin.println(ship + " collides with " + obj);
}

after(Ship shipA, Ship shipB):
execution(void Ship.bounce(Ship, Ship)) && args(shipA, shipB) {
if (traceFireCollideDamage.getState())
infoWin.println(shipA + " bounces with " + shipB);
}

before(Ship ship, double amount):
call(void Ship.inflictDamage(double)) && target(ship) && args(amount) {
if (traceFireCollideDamage.getState())
if (amount > 0)
infoWin.println(ship + "gets " +
amount + " damage (" +
ship.getDamage() + ")");
}

}

class InfoWin {
private Frame frame;
private TextArea info;

InfoWin() {
frame = new Frame("debugging info for spacewar game");
info = new TextArea();
info.setEditable(false);

Dimension screenSize = frame.getToolkit().getScreenSize();
frame.setSize(250, 600);
frame.setLocation(screenSize.width - 250, 0);
frame.add(info);
frame.show();
frame.toFront();
}

void clear() {
info.setText("");
}

void println(String line) {
info.append(line + "\n");
}

void print(String line) {
info.append(line);
}
}

+ 146
- 0
tests/ajde/examples/spacewar/spacewar/Display.java View File

@@ -0,0 +1,146 @@

package spacewar;

import java.util.Vector;
import java.util.Enumeration;
import java.awt.Graphics;
import java.awt.Canvas;
import java.awt.Image;
import java.awt.event.KeyListener;

/**
* The display aspects capture the look and feel of the Game in modular
* pluggable units.
*
* The model is that constructing a concrete subclass of Display attaches that
* kind of display to the game. It will Display the game as it goes along.
* A game can have any number of displays. Any of the displays will accept
* keyboard input.
*
*/

class Display extends Canvas {

private static Vector DISPLAYS = new Vector(2);
private static Vector PLAYERS = new Vector(2);
private static Pilot pilot1, pilot2;

Game game;
SWFrame frame;
Image offImage;
Graphics offGraphics;

Game getGame() { return game; }
static Pilot getPilot1() { return pilot1; }
static Pilot getPilot2() { return pilot2; }

Display(Game g) {
super();
game = g;

frame = new SWFrame(game, this);
DISPLAYS.addElement(this);
}


void noticeSizeChange() {
initializeOffImage();
}

private void initializeOffImage () {
int w = getSize().width;
int h = getSize().height;
if ( w > 0 & h > 0) {
offImage = createImage(w, h);
offGraphics = offImage.getGraphics();
}
}

/*
* In our double buffering scheme, painting just means copying the buffer
* to the screen. The Display aspect draws into the buffer.
*/
public void paint(Graphics g) {
if (offImage != null)
g.drawImage(offImage, 0, 0, null);
}

public void update(Graphics g) {
/*
* There are 4 steps to this:
* - clear the double buffer
* - paint the objects into the double buffer
* - paint the status into the double buffer
* - paint the doublebuffer into the buffer
*/
offGraphics.setColor(getBackground());
offGraphics.fillRect(0, 0, getBounds().width, getBounds().height);
paintObjects(offGraphics);
paintStatus(offGraphics);
g.drawImage(offImage, 0, 0, null);
}

void paintObjects(Graphics g) { }
void paintStatus(Graphics g) {}

static aspect DisplayAspect {

after (String mode) returning (Game game): call(Game+.new(String)) && args(mode) {
new Display1(game);
// new Display2(game);

if ( mode.equals("1") ) {
pilot1 = game.newPlayer(1);
}
else if ( mode.equals("2") ) {
pilot1 = game.newPlayer(1);
pilot2 = game.newPlayer(2);
}
else if (mode. equals("demo")) {
pilot1 = game.newRobot(1);
pilot2 = game.newRobot(2);
} else {
game.error("Invalid mode: " + mode);
game.quit();
}
}


/*
* I'm not really sure this belongs here.
*
* Being here what it does is makes the Display aspect
* responsible for having the Players couple up to it. That's
* kind of nice, but its a bit incomplete, since Player is
* really part of the GUI, not part of the core Game.
*
* In a future re-factoring this will get worked out better.
* What will happen is that GUI will be an aspect that has the
* core GUI. Each of the different kinds of displays will be
* aspects that tie themselves in.
*/
after () returning (Player player): call(Player+.new(..)) {
Enumeration elements = DISPLAYS.elements();
while ( elements.hasMoreElements() ) {
Display display = (Display)elements.nextElement();
display.addKeyListener(player);
}
}

after() returning (Display display): call(Display+.new(..)) {
display.noticeSizeChange();
}

after(Display display) returning (): call(void setSize(..)) && target(display) {
display.noticeSizeChange();
}

after(): call(void Game.clockTick()) {
Enumeration elements = DISPLAYS.elements();
while ( elements.hasMoreElements() ) {
Display display = (Display)elements.nextElement();
display.repaint();
}
}
}
}

+ 183
- 0
tests/ajde/examples/spacewar/spacewar/Display1.java View File

@@ -0,0 +1,183 @@

package spacewar;


import java.util.Vector;
import java.util.Enumeration;
import java.awt.Graphics;
import java.awt.Color;
import java.util.Random;

/**
* This is the standard display aspect.
*/
class Display1 extends Display {
/*
* Here's the color scheme for the game. No other places in this file
* should say Color.xxx. Instead, that color should be given a symbolic
* name here.
*/
private static Color backgroundColor = Color.black;
private static Color player1ShipColor = Color.white;
private static Color player2ShipColor = Color.gray;
private static Color robotShipColor = new Color(0xa00000);
private static Color flameColor = Color.red;
private static Color shipExplosionColor = Color.red;
private static Color bulletColor = Color.green;
private static Color energyPacketOuterColor = Color.blue;
private static Color energyPacketInnerColor = new Color(0x7070FF);
private static Color statusLabelsColor = Color.white;
private static Color statusMeterBorderColor = Color.white;
private static Color energyStatusMeterColor = Color.blue;
private static Color damageStatusMeterColor = Color.red;


Display1(Game game) {
super(game);
frame.setLocation(20, 20);
}

void noticeSizeChange() {
super.noticeSizeChange();
setBackground(backgroundColor);
}

void paintObjects(Graphics g) {
SpaceObject[] objects = game.getRegistry().getObjects();
final int len = objects.length;
for (int i = 0; i < len; i++) {
objects[i].paint(g);
}
}

static aspect SpaceObjectPainting {

abstract private void SpaceObject.paint(Graphics g);

/*
* Ships are by far and away the most complex of the space Objects
* to paint. First off, we need to set the color when the ship
* is made.
*/
private Color Ship.color;

after(Pilot pilot) returning (Ship ship): call(Ship Game.newShip(Pilot)) && args(pilot) {
if (pilot.getNumber() == 1)
ship.color = player1ShipColor;
else if (pilot.getNumber() == 2)
ship.color = player2ShipColor;
else
ship.color = robotShipColor;
}

private void Ship.paint(Graphics g) {
final double PI = Math.PI;
int[] radius = {15, 12, -4, 12, -9, -15, -9};
double[] angle = {0, PI * 3/4, 0, -PI * 3/4, PI/8, 0, -PI/8};
int[] x;
int[] y;

Random random = new Random();

if (this.getDamage() >= this.MAX_DAMAGE) {
int lines = 20;
x = new int[lines];
y = new int[lines];
g.setColor(shipExplosionColor);
for (int i = 0; i < lines; i++) {
x[i] = (int)(this.getXPos()) + random.nextInt() % 20;
y[i] = (int)(this.getYPos()) + random.nextInt() % 20;
}
for (int i = 0; i < lines; i++)
g.drawLine(x[i], y[i], x[(i + 1) % lines], y[(i + 1) % lines]);
} else {
x = new int[7];
y = new int[7];

g.setColor(this.color);

radius[5] += random.nextInt() % 3;
// convert coordinates from polar to cartesian
for (int i = 0; i < 7; i++) {
x[i] = (int)
(this.getXPos() +
Math.cos(this.getOrientation() + angle[i]) * radius[i]);
y[i] = (int)
(this.getYPos() +
Math.sin(this.getOrientation() + angle[i]) * radius[i]);
}

// draw the body as a polygon
g.drawPolygon(x, y, 4);

// if the ship is accelerating, draw in a flame
if (this.getRAcc() != 0) {
g.setColor(flameColor);
g.drawLine(x[4], y[4], x[5], y[5]);
g.drawLine(x[5], y[5], x[6], y[6]);
}
}
}

/*
* Bullets
*/
private void Bullet.paint(Graphics g) {
g.setColor(bulletColor);
g.fillOval((int)this.getXPos() - 1,
(int)this.getYPos() - 1,
3,
3);
}

/*
* energy packets
*/
private void EnergyPacket.paint(Graphics g) {
g.setColor(energyPacketOuterColor);
g.fillOval((int)this.getXPos() - 5,
(int)this.getYPos() - 5,
10, 10);
g.setColor(energyPacketInnerColor);
g.fillOval((int)this.getXPos() - 2,
(int)this.getYPos() - 2,
3, 3);
}
}


void paintStatus(Graphics g) {
int left1 = 60;
int top1 = 0;

int left2 = 200;
int top2 = 0;

g.setColor(statusLabelsColor);
g.drawString("energy:", 5, top1 + 15);
g.drawString("damage:", 5, top1 + 30);

if (getPilot1() != null)
paintLevels(g, getPilot1().getShip(), top1, left1);
if (getPilot2() != null)
paintLevels(g, getPilot2().getShip(), top2, left2);
}

static void paintLevels(Graphics g, Ship ship, int top, int left) {
if (ship == null)
return;
else if (ship.isAlive()) {
g.setColor(statusMeterBorderColor);
g.drawRect(left, top + 6, 101, 10);
g.drawRect(left, top + 21, 101, 10);
g.setColor(energyStatusMeterColor);
g.fillRect(left + 1, top + 7, (int)(ship.getEnergyLevel()*100), 9);
g.setColor(damageStatusMeterColor);
g.fillRect(left + 1, top + 22, (int)(ship.getDamageLevel()*100), 9);
}
else {
g.setColor(damageStatusMeterColor);
g.drawString("Ship is destroyed", left+1, top+15);
}
}
}

+ 118
- 0
tests/ajde/examples/spacewar/spacewar/Display2.java View File

@@ -0,0 +1,118 @@

package spacewar;


import java.util.Vector;
import java.util.Enumeration;
import java.awt.Graphics;
import java.awt.Color;


/**
* This is the cheap Display aspect.
*/
class Display2 extends Display {

Display2(Game game) {
super(game);
frame.setLocation(540, 20);
}

void noticeSizeChange() {
super.noticeSizeChange();
setBackground(Color.darkGray);
}

void paintObjects(Graphics g) {
SpaceObject[] objects = game.getRegistry().getObjects();
final int len = objects.length;
for (int i = 0; i < len; i++) {
objects[i].paint(g);
}
}

static aspect SpaceObjectPainting {

abstract private void SpaceObject.paint(Graphics g);

/*
* Ships are by far and away the most complex of the space Objects
* to paint.
*/
private Color Ship.color;

after(Pilot pilot) returning (Ship ship): call(Ship Game.newShip(Pilot)) && args(pilot) {
if (pilot.getNumber() == 1)
ship.color = Color.white;
else if (pilot.getNumber() == 2)
ship.color = Color.gray;
else
ship.color = new Color(0xa00000);
}

private void Ship.paint(Graphics g) {
if (this.getDamage() < this.MAX_DAMAGE) {
double x = this.getXPos();
double y = this.getYPos();
double sinTheta = Math.sin(this.getOrientation());
double cosTheta = Math.cos(this.getOrientation());

g.setColor(color);
g.drawLine((int)(x + 8*cosTheta), (int)(y + 8*sinTheta),
(int)(x - 8*cosTheta), (int)(y - 8*sinTheta));

// if the ship is accelerating, draw thruster
if (this.getRAcc() != 0) {
g.setColor(Color.red);
g.fillOval((int)(x - 8*cosTheta), (int)(y - 8*sinTheta), 6, 6);
}
}
}

private void Bullet.paint(Graphics g) {
g.setColor(Color.green);
g.fillOval((int)this.getXPos() - 1,
(int)this.getYPos() - 1,
3,
3);
}

private void EnergyPacket.paint(Graphics g) {
g.setColor(Color.white);
g.fillOval((int)this.getXPos() - 5,
(int)this.getYPos() - 5,
10,
10);
}
}

void paintStatus(Graphics g) {
int left1 = 60;
int top1 = 0;

int left2 = 200;
int top2 = 0;

g.setColor(Color.white);
g.drawString("energy:", 5, top1 + 15);
g.drawString("damage:", 5, top1 + 30);

if (getPilot1() != null)
paintLevels(g, getPilot1().getShip(), top1, left1);
if (getPilot2() != null)
paintLevels(g, getPilot2().getShip(), top2, left2);
}

void paintLevels(Graphics g, Ship ship, int top, int left) {
if (ship == null)
return;
else if (ship.isAlive()) {
g.drawString(Float.toString(ship.getEnergyLevel()*100), left+1, top+15);
g.drawString(Float.toString(ship.getDamageLevel()*100), left+1, top+30);
}
else {
g.setColor(Color.red);
g.drawString("Ship is destroyed", left+1, top+15);
}
}
}

+ 23
- 0
tests/ajde/examples/spacewar/spacewar/EnergyPacket.java View File

@@ -0,0 +1,23 @@

package spacewar;


class EnergyPacket extends SpaceObject {

static private final int SIZE = 5; //Can't be changed for now!!!
int getSize() { return SIZE; }

private double energy;

double getEnergy() { return energy; }

EnergyPacket(Game theGame,
double xP, double yP, double xV, double yV, double e) {
super(theGame, xP, yP, xV, yV);
energy = e;
}

void handleCollision(SpaceObject obj) {
die();
}
}

+ 40
- 0
tests/ajde/examples/spacewar/spacewar/EnergyPacketProducer.java View File

@@ -0,0 +1,40 @@

package spacewar;


class EnergyPacketProducer extends Thread {
private final static int MIN = -20;
private final static int MAX = 80;
private final static int EXPECTEDINTERVAL = 15;

private Game game;

Game getGame() { return game; }

EnergyPacketProducer(Game theGame) {
super("EnergyPacketProducer");
game = theGame;
}

public void run() {
while(true) {
produceAPacket();
waitForABit();
}
}

void waitForABit() {
try { Thread.sleep((int)(Math.random() * EXPECTEDINTERVAL * 2000)); }
catch (InterruptedException e) {}
}

void produceAPacket() {
EnergyPacket pkt =
new EnergyPacket(game,
Math.random() * getGame().getWidth(),
Math.random() * getGame().getHeight(),
Math.random() * 2 - 1,
Math.random() * 2 - 1,
Math.random() * (MAX - MIN) + MIN);
}
}

+ 15
- 0
tests/ajde/examples/spacewar/spacewar/EnsureShipIsAlive.java View File

@@ -0,0 +1,15 @@

package spacewar;

/**
* This aspect makes sure that the ship is alive before performing any console
* commands.
*
*/
aspect EnsureShipIsAlive {
void around (Ship ship): Ship.helmCommandsCut(ship) {
if ( ship.isAlive() ) {
proceed(ship);
}
}
}

+ 172
- 0
tests/ajde/examples/spacewar/spacewar/Game.java View File

@@ -0,0 +1,172 @@

package spacewar;

import java.awt.Dimension;

/**
* The Game class is the root of the spacewar game. To start a spacewar
* game, you can either call the main method, or instantiate this class
* directly.
*
* Synchronization is done by the GameSynchronization aspect.
*/
public class Game extends Thread {

/**
* To run the game from top level, simply say Java Game, as usual. Passing
* an argument makes the game run in demo mode. Without an argument it runs
* in the normal player mode.
*/
public static void main(String[] args) {
if ( args.length == 0 )
new Game("1").run();
new Game(args[0]).run();
}


private Timer timer;
private EnergyPacketProducer ePP;

private Registry registry;
private Pilot pilot1, pilot2;

private Dimension screenSize = new Dimension(500, 500);

Registry getRegistry() { return registry; }
Pilot getPilot1() { return pilot1; }
Pilot getPilot2() { return pilot2; }

int getWidth() { return screenSize.width; }
int getHeight() { return screenSize.height; }

/**
* To run the game, simply instantiate this class. It runs in its own
* thread. You can instantiate multiple games at once. For the time being
* the only way to end the game is to exit from the Java VM.
*
* @param isDemo Controls whether the game runs in demo mode or not. True
* means it is a demo, false means it runs in normal 2 player mode.
*/
public Game(String mode) {
timer = new Timer(this);
ePP = new EnergyPacketProducer(this);
registry = new Registry(this);
}

public void run() {
timer.start();
ePP.start();

while(true) {
try {
newRobot(3);
Thread.sleep(15000);
}
catch (InterruptedException e) {}
}
}



/*
* These are the menu commands.
*/
void addRobot() {
newRobot(3);
}

void resetShips() {
Ship[] ships = registry.getShips();

for (int i = 0; i < ships.length; i++) {
Ship ship = ships[i];
Pilot pilot = ship.getPilot();
newShip(pilot);
}
}

void quit() {
System.exit(0);
}

void error(Object o) {
System.err.println(o);
}


/*
* These three methods are the ONLY ways to make a Player a Robot or a Ship.
* The structural invariant is that there should be no calls to new of one
* of these three classes outside these three methods.
*/
Player newPlayer(int number) {
Player player = new Player(this, number);
newShip(player);
return player;
}

Robot newRobot(int number) {
Robot robot = new Robot(this, number);
newShip(robot);
robot.start();
return robot;
}

Ship newShip(Pilot pilot) {
//
// If there is an old ship (we're doing a reset), then remove it from
// the registry.
//
Ship oldShip = pilot.getShip();
if (! (oldShip == null))
oldShip.die();

Ship newShip = new Ship(this,
Math.random() * getWidth(),
Math.random() * getHeight(),
Math.random() * Math.PI * 2);
pilot.setShip(newShip);
newShip.setPilot(pilot);

return newShip;
}

void clockTick() {
registry.clockTick();
handleCollisions();
}

// collision detection

void handleCollisions() {
SpaceObject[] objects = registry.getObjects();

SpaceObject objI, objJ;
for (int i = 0; i < objects.length; i++) {
objI = objects[i];
for (int j = i + 1; j < objects.length; j++) {
objJ = objects[j];
if (objI instanceof Bullet && objJ instanceof Bullet)
continue;
if (isCollision(objI, objJ)) {
if (objI instanceof Ship && objJ instanceof Ship)
Ship.bounce((Ship)(objI), (Ship)(objJ));
else {
objI.handleCollision(objJ);
objJ.handleCollision(objI);
}
}
}
}
}

/*
* Is the distance between the two centers less than the sum of the two
* radii. This is a cheap and dirty (i.e. wrong) implementation of this.
*/
static boolean isCollision(SpaceObject a, SpaceObject b) {
return (Math.abs(a.getXPos() - b.getXPos()) +
Math.abs(a.getYPos() - b.getYPos())) <
(a.getSize()/2 + b.getSize()/2);
}
}

+ 33
- 0
tests/ajde/examples/spacewar/spacewar/GameSynchronization.java View File

@@ -0,0 +1,33 @@

package spacewar;

import coordination.Coordinator;

/**
* This aspect ensures synchronized access to methods of the Game in the
* presence of several threads.
*
* It uses the Coordinator class, from the AspectJ coordination library.
* (This case is right on the borderline of being too simple to use the
* coordination library, but we use it anyways to keep the similarity
* with the RegistrySynchronizer.)
*
* It uses a per-Game coordination scheme, so there is one instance of
* this class for each instance of the Game class. When this class is
* constructed, it registers appropriate mutexes and selfexes using
* the behavior inherited from Coordinator.
*
* The coordination constraints for the Game are simple. We just need to
* make sure that newShip and handleCollisions are mutually exclusive. That
* ensures that they we can't destroy a ship that has just been replaced.
*/
aspect GameSynchronization extends Coordinator perthis(this(Game)) {

protected pointcut synchronizationPoint():
call(void Game.handleCollisions(..)) || call(Ship Game.newShip(..));

public GameSynchronization() {
addMutex(new String[] {"handleCollisions", "newShip"});
}

}

+ 26
- 0
tests/ajde/examples/spacewar/spacewar/Pilot.java View File

@@ -0,0 +1,26 @@

package spacewar;


/**
* Pilot is the abstract superclass of Player and Robot.
*
*/

abstract class Pilot {
private Game game;
private int number;
protected Ship ship = null;

Game getGame() { return game; }
int getNumber() { return number; }
Ship getShip() { return ship; }

void setShip(Ship s) { ship = s; }

Pilot (Game g, int n) {
super();
game = g;
number = n;
}
}

+ 101
- 0
tests/ajde/examples/spacewar/spacewar/Player.java View File

@@ -0,0 +1,101 @@

package spacewar;

import java.util.Enumeration;
import java.awt.event.KeyListener;
import java.awt.event.KeyEvent;

class Player extends Pilot implements KeyListener {

private KeyMapping keyMapping;

private int rotation_direction = Ship.STOP; // current rotation key
private boolean thrust_on = false; // current thrust

Player(Game theGame, int number) {
super(theGame,number);

if (getNumber() == 1)
keyMapping = KeyMapping.keyMapping1;
else if (getNumber() == 2)
keyMapping = KeyMapping.keyMapping2;

}

public void keyPressed(KeyEvent e) {
int keyCode = e.getKeyCode();
boolean consumed = true;

if (keyCode == keyMapping.fire) {
ship.fire();
}
else if (keyCode == keyMapping.thrust && !thrust_on) {
ship.thrust(true);
thrust_on = true;
}
else if (keyCode == keyMapping.right &&
rotation_direction != Ship.COUNTERCLOCKWISE) {
//start rotating clockwise unless already rotating in the
//opposite direction
rotation_direction = Ship.CLOCKWISE;
ship.rotate(Ship.CLOCKWISE);
}
else if (keyCode == keyMapping.left &&
rotation_direction != Ship.CLOCKWISE) {
//start rotating counterclockwise unless already rotating in the
//opposite direction
rotation_direction = Ship.COUNTERCLOCKWISE;
ship.rotate(Ship.COUNTERCLOCKWISE);
}
else {
consumed = false;
}

if (consumed) e.consume();
}

public void keyReleased(KeyEvent e) {
int keyCode = e.getKeyCode();

if (keyCode == keyMapping.thrust) {
ship.thrust(false); //engine off
thrust_on = false;
}
else if (keyCode == keyMapping.right &&
rotation_direction == Ship.CLOCKWISE
||
keyCode == keyMapping.left &&
rotation_direction == Ship.COUNTERCLOCKWISE) {
ship.rotate(Ship.STOP); //stop rotation
rotation_direction = Ship.STOP;
}
}

public void keyTyped(KeyEvent e) {
// have to implement this because it's in KeyListener
}
}

class KeyMapping {

static final KeyMapping keyMapping1 =
new KeyMapping(KeyEvent.VK_LEFT,
KeyEvent.VK_RIGHT,
KeyEvent.VK_UP,
KeyEvent.VK_SPACE);

static final KeyMapping keyMapping2 =
new KeyMapping(KeyEvent.VK_X,
KeyEvent.VK_V,
KeyEvent.VK_D,
KeyEvent.VK_ALT);

int left, right, thrust, fire;

KeyMapping(int k_left, int k_right, int k_thrust, int k_fire) {
left = k_left;
right = k_right;
thrust = k_thrust;
fire = k_fire;
}
}

+ 105
- 0
tests/ajde/examples/spacewar/spacewar/Registry.java View File

@@ -0,0 +1,105 @@

package spacewar;

import java.util.Vector;
import java.util.Hashtable;
import java.util.Enumeration;

/**
* The Registry keeps track of all the space objects that are floating around.
* It basically supports register, unregister and contents type operations.
*
* The synchronization is done by the RegistrySynchronization aspect.
*/

class Registry {

private Hashtable table;
private Game game;

Game getGame() { return game; }

Registry (Game theGame) {
game = theGame;
table = new Hashtable();
}


void register(SpaceObject object) {
table.put(object, object);
}

void unregister(SpaceObject object) {
table.remove(object);
}

/*
* It is an invariant of the design that only two points in SpaceObject
* should call register and unregister. This aspect enforces that.
*
* Unfortunately, in the current compiler, we get a static warning when
* there are no illegal calls that this advice has no targets. That will
* be fixed in a future release. For the time being the dummy method
* just below this fixes that.
*/
static aspect RegistrationProtection {
after() returning():
(call(void Registry.register(SpaceObject)) ||
call(void Registry.unregister(SpaceObject))) &&
!(within(SpaceObject) && (withincode(new(..)) ||
withincode(void die()))) {
throw new IllegalAccessError(
"This is an illegal call to " + thisJoinPoint + "\n" +
"Only the constructor and the die() on SpaceObject\n" +
"should call the primitive registry operations.");
}
}

void dummy() { // see comment above
register(getObjects()[0]);
unregister(getObjects()[0]);
}


SpaceObject[] getObjects() {
SpaceObject[] allObjects = new SpaceObject[table.size()];
Enumeration elements = table.elements();
for(int i = 0; elements.hasMoreElements(); i++) {
allObjects[i] = (SpaceObject)(elements.nextElement());
}
return allObjects;
}

Ship[] getShips() {
//
// First we have to put just the Ships into a vector, then we can put
// them into an array of exactly the right length.
//
Ship[] arrayOfShips;
Vector vectorOfShips = new Vector();
Enumeration elements = table.elements();
while (elements.hasMoreElements()) {
Object object = elements.nextElement();
if (object instanceof Ship) {
vectorOfShips.addElement(object);
}
}

arrayOfShips = new Ship[(vectorOfShips.size())];
vectorOfShips.copyInto(arrayOfShips);
return arrayOfShips;
}

Hashtable getTable() { return table; }

//
// The protocol for clockTick is that it automatically cascades.
//
void clockTick() {
Enumeration elements = table.elements();
while (elements.hasMoreElements()) {
((SpaceObject)elements.nextElement()).clockTick();
}
}
}


+ 37
- 0
tests/ajde/examples/spacewar/spacewar/RegistrySynchronization.java View File

@@ -0,0 +1,37 @@

package spacewar;

import coordination.Coordinator;


/**
* This aspect ensures synchronized access to methods of the Registry in
* the presence of several threads.
*
* It uses the Coordinator class, from the AspectJ coordination library.
*
* It uses a per-Registry coordination scheme, so there is one instance of
* this class for each instance of the Registry class. When this class is
* constructed, it registers appropriate mutexes and selfexes using the
* behavior inherited from Coordinator.
*
* The mutating methods (register and unregister) should be self-exclusive.
* Each reader method should be mutually exclusive with the mutating
* methods. But the readers can run concurrently. */
aspect RegistrySynchronization extends Coordinator perthis(this(Registry)) {

protected pointcut synchronizationPoint():
call(void Registry.register(..)) ||
call(void Registry.unregister(..)) ||
call(SpaceObject[] Registry.getObjects(..)) ||
call(Ship[] Registry.getShips(..));
public RegistrySynchronization() {
addSelfex("register");
addSelfex("unregister");

addMutex(new String[] {"register", "unregister", "getObjects"});
addMutex(new String[] {"register", "unregister", "getShips"});
}

}

+ 179
- 0
tests/ajde/examples/spacewar/spacewar/Robot.java View File

@@ -0,0 +1,179 @@
package spacewar;

import java.util.Random;

/**
* Robot is an automatic pilot that now has quite a bit of intelligence.
* So, beware !
*/
class Robot extends Pilot implements Runnable {

private static final int FIRE_INTERVAL = 60;
private static final int REBIRTH_DELAY = 900;

private final Random random = new Random();

private Thread runner;
private boolean runnable = true;

Robot(Game theGame, int number) {
super(theGame, number);
}

void start() {
if (runner == null) {
runner = new Thread(this);
runner.start();
}
}

void destroy() {
if (runner != null) {
runnable = false;
runner = null;
}
}


// A Robot tracks User-controlled ships and fires at them
public void run() {
Ship target = null;

while(runnable) {
// find target ship
do {
Ship[] potentials = getGame().getRegistry().getShips();
if(potentials.length != 0)
target = potentials[Math.abs(random.nextInt() % potentials.length)];
sleepForABit(25);
} while (target == ship);
// main loop
int currentRotation = Ship.STOP;
int time;
boolean currentlyAccelerating = false;
double dx, dy, angleA, angleB, theta, dtheta, d,
targetVel, a, b, c, targetXVel, targetYVel;

while(true) {
sleepForABit(FIRE_INTERVAL);

// if my ship is destroyed, give me a new one
if (!ship.isAlive()) {
sleepForABit(REBIRTH_DELAY);
getGame().newShip(this);
}

// find direction and distance from target to me
dx = ship.getXPos() - target.getXPos();
if (dx < - getGame().getWidth() / 2)
dx += getGame().getWidth();
if (dx > getGame().getWidth() / 2)
dx -= getGame().getWidth();
dy = ship.getYPos() - target.getYPos();
if (dy < - getGame().getHeight() / 2)
dy += getGame().getHeight();
if (dy > getGame().getHeight() / 2)
dy -= getGame().getHeight();
d = Math.sqrt(dx * dx + dy * dy);
angleA = Math.atan(dy / dx);
if (dx < 0)
angleA += Math.PI;

// find relative velocity and trajectory of target
targetXVel = target.getXVel() - ship.getXVel();
targetYVel = target.getYVel() - ship.getYVel();
targetVel = Math.sqrt(targetXVel * targetXVel +
targetYVel * targetYVel);
angleB = Math.atan(targetYVel / targetXVel);
if (targetXVel < 0)
angleB+=Math.PI;

// find angle between line to target and taget's direction of travel
theta = (angleA - angleB) % (2 * Math.PI);
if (theta < -Math.PI)
theta += 2 * Math.PI;
if (theta > Math.PI)
theta -= 2 * Math.PI;

// calculate time to bullet impact using law of cosines
a = targetVel * targetVel + Ship.BULLET_SPEED * Ship.BULLET_SPEED;
b = d * targetVel * Math.cos(theta);
c = - d * d;
time = (int)((-b + Math.sqrt(b * b - 4 * a * c)) / 2 / a);

// calculate angle and distance to bullet impact location
dx = targetXVel * time - dx;
dy = targetYVel * time - dy;
theta = Math.atan(dy / dx);
if(dx < 0)
theta += Math.PI;

// find desired change in rotation
dtheta = (theta - ship.getOrientation()) % (2 * Math.PI);
// find the shortest path to the desired orientation;
if(dtheta < - Math.PI)
dtheta += 2 * Math.PI;
if(dtheta > Math.PI)
dtheta -= 2 * Math.PI;

// turn if nessecary
if (dtheta > Ship.DEFAULT_ANGULAR_VELOCITY / 2) {
if (currentRotation != Ship.CLOCKWISE)
ship.rotate(currentRotation = Ship.CLOCKWISE);
}
else if (dtheta < -Ship.DEFAULT_ANGULAR_VELOCITY / 2) {
if (currentRotation != Ship.COUNTERCLOCKWISE)
ship.rotate(currentRotation = Ship.COUNTERCLOCKWISE);
} // otherwise, fire, maybe even a burst
else {
if(currentRotation != Ship.STOP)
ship.rotate(currentRotation = Ship.STOP);
if (random.nextInt() % 40 == 0) {
ship.fire();
}
}

// randomly accelerate
if (currentlyAccelerating && random.nextInt() % 2 == 0)
ship.thrust(currentlyAccelerating = false);
else {
if (ship.getXVel() == 0)
angleA = 0;
else
angleA = Math.atan(ship.getYVel() / ship.getXVel());

if (ship.getXVel() < 0)
angleA+=Math.PI;
angleB = (angleA - ship.getOrientation()) % (2 * Math.PI);
if (angleB < -Math.PI)
angleB += 2 * Math.PI;
if (angleB > Math.PI)
angleB -= 2 * Math.PI;
angleB = Math.abs(angleB);

// angleB now represents the angle between the ship's
// orientation and velocity vector. This will be used to
// determine the probably that the ship will thrust to
// prevent ships from accelerating too much in one direction
if (random.nextInt() % (int)(12 * (Math.PI - angleB) + 1) == 0)
ship.thrust(currentlyAccelerating = true);
}

// switch targets if current one has been destroyed
if (target.getDamage() == 100)
break;

// randomly switch targets
if (random.nextInt() % 4000 == 0)
break;
}
}
}

void sleepForABit (int time) {
try {
runner.sleep(time);
}
catch (InterruptedException e) {}
}
}

+ 71
- 0
tests/ajde/examples/spacewar/spacewar/SWFrame.java View File

@@ -0,0 +1,71 @@

package spacewar;

import java.awt.Frame;
import java.awt.Menu;
import java.awt.MenuBar;
import java.awt.MenuItem;
import java.awt.MenuShortcut;
import java.awt.Dimension;
import java.awt.Insets;

import java.awt.event.ActionListener;
import java.awt.event.ActionEvent;

class SWFrame extends Frame implements ActionListener {
private Game game;
private Display display;
private Menu menu;

Game getGame() { return game; }
Display getDisplay() { return display; }
Menu getMenu() { return menu; }

SWFrame(Game theGame, Display d) {
super("Space War!");

game = theGame;

display = d;
add(display);

// create menu
menu = new Menu("Game");
MenuItem item1 = new MenuItem("Add Robot", new MenuShortcut('a'));
MenuItem item2 = new MenuItem("Reset Ships", new MenuShortcut('r'));
MenuItem item3 = new MenuItem("Quit", new MenuShortcut('q'));
item1.setActionCommand("Add Robot");
item2.setActionCommand("Reset Ships");
item3.setActionCommand("Quit");
menu.add(item1);
menu.add(item2);
menu.add(item3);
menu.addActionListener(this);

setMenuBar(new MenuBar());
getMenuBar().add(menu);

Dimension screenSize = new Dimension(500, 500);
setSize(screenSize);
setVisible(true);
toFront();

Insets inset = getInsets();
int displayWidth = screenSize.width - inset.left - inset.right;
int displayHeight = screenSize.height - inset.top - inset.bottom;
display.setSize(displayWidth, displayHeight);
}

public void actionPerformed(ActionEvent e) {
String s = e.getActionCommand();
if (s.equals("Add Robot")) {
getGame().addRobot();
}
else if (s.equals("Reset Ships")) {
getGame().resetShips();
}
else if (s.equals("Quit")) {
getGame().quit();
}
}
}

+ 260
- 0
tests/ajde/examples/spacewar/spacewar/Ship.java View File

@@ -0,0 +1,260 @@

package spacewar;

class Ship extends SpaceObject {

pointcut helmCommandsCut(Ship ship):
target(ship) && ( call(void rotate(int)) ||
call(void thrust(boolean)) ||
call(void fire()) );


/**
* Energy and Damage are key values in the state of a ship. Energy is
* basically about fuel, and damage is about how bad a shape we are in.
*
* The energy related values are:
* MAX_ENERGY
* BULLET_ENERGY
* ACCELERATION_ENERGY_FACTOR
* energy
*
* The damage related values are:
* MAX_DAMAGE
* BULLET_DAMAGE
* COLLISION_DAMAGE_FACTOR
* damage
*
* Finally, REPAIR_RATE is the rate at which energy is consumed to fix
* damage.
*
*/
private static final int MAX_ENERGY = 100;
private static final int BULLET_ENERGY= 2;
private static final double ACCELERATION_COST_FACTOR = 0.05;

//XXX was private
static final int MAX_DAMAGE = 100;
private static final int BULLET_DAMAGE = 15;
private static final double COLLISION_DAMAGE_FACTOR = 0.1;

private static final double REPAIR_RATE = 0.08;


private static final int EXPLOSION_LENGTH = 10;

static final int BULLET_SPEED = 10;

static final int CLOCKWISE = 1;
static final int STOP = 0;
static final int COUNTERCLOCKWISE = (-1);

static final double DEFAULT_ANGULAR_VELOCITY = 0.2;
static final double DEFAULT_ACCELERATION = .4;

static private final int SIZE = 30; //Can't be changed for now!!!

private double energy; // range: 0 to MAX_ENERGY
private double damage; // range: 0 to MAX_DAMAGE
private double orientation; // in degrees
private double angularVel; // in ???
private double xAcc, yAcc, rAcc; //
private int countdown; // remaining explosion time

private Pilot pilot;

Ship(Game theGame, double xPos, double yPos, double orientation) {
super(theGame, xPos, yPos, 0, 0);
xAcc = 0;
yAcc = 0;
this.orientation = orientation;
angularVel = 0;

energy = MAX_ENERGY;
damage = 0;
countdown = EXPLOSION_LENGTH;
}


int getSize() { return SIZE; }

double getEnergy() { return energy; }
double getDamage() { return damage; }
double getOrientation() { return orientation; }
double getRAcc() { return rAcc; }

Pilot getPilot() { return pilot; }
void setPilot (Pilot p) { pilot = p; }

float getEnergyLevel() {
return (float)energy / (float)MAX_ENERGY;
}
float getDamageLevel() {
return (float)damage / (float)MAX_DAMAGE;
}

// returns false if energy is out, otherwise decrements energy by amount
// and returns true
boolean expendEnergy(double amount) {
if (amount <= energy) {
energy -= amount;
return true;
}
else
return false;
}

// increments damage by amount and handles the destruction of a ship if
// damage reaches MAX_DAMAGE.
void inflictDamage(double amount) {
if (amount < 0) // shouldn't happen
return;
damage = Math.min(MAX_DAMAGE, damage + amount);
if (damage == MAX_DAMAGE)
setIsAlive(false);
}

void repairDamage(double amount) {
if (amount < 0) // shouldn't happen
return;
if (damage == 0)
return;
damage = Math.max(0, damage - amount);
}

public void clockTick() {
if (! isAlive()) {
//
// If we aren't alive, but we are still in the registry, it means
// we are exploding. countdown counts the length of the explosion.
//
if (--countdown == 0)
die();
}
else {
if (angularVel != 0) {
orientation += angularVel;
xAcc = rAcc * Math.cos(orientation);
yAcc = rAcc * Math.sin(orientation);
}
setXVel(getXVel() + xAcc);
setYVel(getYVel() + yAcc);

//expend energy
if (!expendEnergy(rAcc * ACCELERATION_COST_FACTOR))
rAcc = xAcc = yAcc = 0;

// fix damage
if (energy > 10 && damage > REPAIR_RATE) {
expendEnergy(REPAIR_RATE);
repairDamage(REPAIR_RATE);
}
}
super.clockTick();
}

/**
* First check to make sure we have enough energy to accelerate. If
* we do, then go ahead and do so. Acceleration is in the direction
* we are already facing (i.e. orientation).
*/
void setAcceleration(double acc) {
if (acc * ACCELERATION_COST_FACTOR <= energy) {
rAcc = acc;
xAcc = rAcc * Math.cos(orientation);
yAcc = rAcc * Math.sin(orientation);
}
}

void setAngularVelocity(double omega) {
// changing direction of rotation takes energy
if (!expendEnergy(Math.abs(omega - angularVel) / 2))
return;
//sets amount of degree rotation per clock tick, in radians;
//clockwise is positive
angularVel = omega;
}

void rotate(int direction) {
setAngularVelocity(
direction == CLOCKWISE ? DEFAULT_ANGULAR_VELOCITY :
direction == COUNTERCLOCKWISE ? -DEFAULT_ANGULAR_VELOCITY :
0);
}

void thrust(boolean onOff) {
setAcceleration(onOff ? DEFAULT_ACCELERATION : 0);
}

void fire() {
// firing a shot takes energy
if (!expendEnergy(BULLET_ENERGY))
return;

//create a bullet object so it doesn't hit the ship that's firing it
double xV = getXVel() + BULLET_SPEED * (Math.cos(orientation));
double yV = getYVel() + BULLET_SPEED * (Math.sin(orientation));

// create the actual bullet
new Bullet(
getGame(),
(getXPos() + ((getSize()/2 + 2) * (Math.cos(orientation))) + xV),
(getYPos() + ((getSize()/2 + 2) * (Math.sin(orientation))) + yV),
xV,
yV);
}


void handleCollision(SpaceObject obj) {
if (obj instanceof Ship) {
// should never be called. ship - ship collisions are handled in
// Ship.bounce(Ship shipA, Ship shipB)
}
else if (obj instanceof Bullet) {
inflictDamage(BULLET_DAMAGE);
}
else if (obj instanceof EnergyPacket) {
double packetEnergy = ((EnergyPacket)obj).getEnergy();
energy = Math.max(0, Math.min(energy + packetEnergy, MAX_ENERGY));
}
else {
System.err.println("collision with UFO!");
}
}

static void bounce(Ship shipA, Ship shipB) {
double dx, dy, denominator,
xAccA, yAccA, xAccB, yAccB, damage,
xComp, yComp, dvx, dvy;

dx = Math.abs(shipA.getXPos() - shipB.getXPos());
dy = Math.abs(shipA.getYPos() - shipB.getYPos());
denominator = Math.sqrt(dx * dx + dy * dy);
xComp = dx / denominator;
yComp = dy / denominator;
xAccA = shipB.getXVel() * xComp + shipA.getXVel() * (1 - xComp) -
shipA.getXVel();
yAccA = shipB.getYVel() * yComp + shipA.getYVel() * (1 - yComp) -
shipA.getYVel();
xAccB = shipA.getXVel() * xComp + shipB.getXVel() * (1 - xComp) -
shipB.getXVel();
yAccB = shipA.getYVel() * yComp + shipB.getYVel() * (1 - yComp) -
shipB.getYVel();
shipA.accelerate(xAccA, yAccA);
shipB.accelerate(xAccB, yAccB);
dvx = shipA.getXVel() - shipB.getXVel();
dvy = shipA.getYVel() - shipA.getYVel();
damage = COLLISION_DAMAGE_FACTOR * (dvx * dvx + dvy * dvy);
shipA.inflictDamage(damage);
shipB.inflictDamage(damage);

// !!!
// !!! poopers! this does a local time warp. this has to be a
// !!! violation of the clockTick protocol
// !!!
while (Game.isCollision(shipA, shipB)) {
shipA.clockTick();
shipB.clockTick();
}
}
}

+ 81
- 0
tests/ajde/examples/spacewar/spacewar/SpaceObject.java View File

@@ -0,0 +1,81 @@

package spacewar;


/**
* SpaceObjects are objects that float around in space. They support the
* minimal SpaceObject protocol, having to do with position, velocity,
* size and liveness. They are constructed with game, position, velocity
* and size. When constructed, a spaceobject adds itself to the registry.
*
* When it dies, a spaceobject removes itself from the registry. But note
* that it doesn't decide when to die, subclasses do that.
*
* The display aspects actually draw the space object on the screen and say
* how much space it takes up there.
*/
abstract class SpaceObject {

private Game game;
private double xPos, yPos, oldXPos, oldYPos, xVel, yVel;
private boolean alive;

SpaceObject (Game theGame, double xP, double yP, double xV, double yV) {
game = theGame;
xPos = xP;
yPos = yP;
oldXPos = xP;
oldYPos = yP;
xVel = xV;
yVel = yV;

alive = true;
getGame().getRegistry().register(this);
}

Game getGame() { return game; }

double getXPos() { return xPos; }
double getYPos() { return yPos; }

double getOldXPos() { return oldXPos; }
double getOldYPos() { return oldYPos; }

double getXVel() { return xVel; }
double getYVel() { return yVel; }

void setXVel (double n) { xVel = n; }
void setYVel (double n) { yVel = n; }

boolean isAlive() { return alive; }
void setIsAlive(boolean n) { alive = n; }


/**
* Move 1 unit of time's worth of distance. I.e. increment xPos by xVel
* and yPos by yVel. If we move off an edge of the screen move us back
* in the opposite edge.
*/
void clockTick() {
oldXPos = xPos;
oldYPos = yPos;
xPos = (xPos + xVel) % getGame().getWidth();
if(xPos < 0)
xPos += getGame().getWidth();
yPos = (yPos + yVel) % getGame().getHeight();
if(yPos < 0)
yPos += getGame().getHeight();
}

void accelerate(double dXVel, double dYVel) {
xVel += dXVel;
yVel += dYVel;
}

void die() {
getGame().getRegistry().unregister(this);
}

abstract int getSize();
abstract void handleCollision(SpaceObject obj);
}

+ 32
- 0
tests/ajde/examples/spacewar/spacewar/Timer.java View File

@@ -0,0 +1,32 @@

package spacewar;


class Timer extends Thread {

private final static int TICK_PERIOD = 40; // time between ticks in millis

private Game game;

Game getGame() { return game; }

Timer (Game theGame) {
super("Timer");
game = theGame;
}

public void run() {
long t1, tdiff;
while (true) {
t1 = System.currentTimeMillis();
getGame().clockTick();
tdiff = System.currentTimeMillis() - t1;
if (tdiff < TICK_PERIOD) {
try {
sleep (Math.max(0 , TICK_PERIOD - tdiff));
}
catch (InterruptedException e) { }
}
}
}
}

+ 291
- 0
tests/ajde/script.html View File

@@ -0,0 +1,291 @@
<html>

<head>
<meta http-equiv="Content-Language" content="en-us">
<meta http-equiv="Content-Type" content="text/html; charset=windows-1252">
<meta name="GENERATOR" content="Microsoft FrontPage 5.0">
<meta name="ProgId" content="FrontPage.Editor.Document">
<title>AJDE Browser</title>
<STYLE TYPE="text/css">
<!--
/* FOR THE SDA PAGE */
/*
BODY {margin-top: 15px; margin-left: 15px; margin-right: 15px;}
*/

A:link {
color:#4756AC;
}
A:visited {
color:#60657B;
}
A:hover {
color:red
}
INPUT {font:12px "Courier New", sans-serif;}
H2 {
font:18px/18px Verdana, Arial, Helvetica, sans-serif;
color:black;
font-weight:bold;
margin-left: 10px;
line-height:110%;
}
H3 {
font:18px/18px Verdana, Arial, Helvetica, sans-serif;
color:black;
font-weight:bold;
margin-left: 10px;
line-height:110%;
}
H4 {
font:15px/16px Verdana, Arial, Helvetica, sans-serif;
color:black;
font-weight:bold;
margin-left: 10px;
line-height:140%;
}
P {
font:13px/13px Verdana, Arial, Helvetica, sans-serif;
margin-right: 10px;
margin-left: 10px;
line-height:130%;
}
.paragraph {
font:13px/13px Verdana, Arial, Helvetica, sans-serif;
margin-right: 10px;
margin-left: 10px;
line-height:130%;
}
.smallParagraph {
font:11px/11px Verdana, Arial, Helvetica, sans-serif;
margin-right: 10px;
margin-left: 10px;
line-height:130%;
}
LI {
font:13px/13px Verdana, Arial, Helvetica, sans-serif;
text-align:justify;
margin-right: 10px;
margin-left: 15px;
line-height:120%;
}
/*
UL {
font:13px/13px Verdana, Arial, Helvetica, sans-serif;
text-align:justify;
margin-right: 10px;
margin-left: 15px;
line-height:120%;
}*/
CODE {
font:11px/11px Courier New, Courier, sans-serif;
text-align:justify;
margin-right: 10px;
margin-left: 15px;
line-height:120%;
}
DL {
font:13px/13px Verdana, Arial, Helvetica, sans-serif;
text-align:justify;
margin-right: 10px;
margin-left: 15px;
line-height:120%;
}
.footer {
font:10px/10px Verdana, Arial, Helvetica, sans-serif;
color:#888888;
text-align:left
}
.figureTitle {
font:13px/13px Verdana, Arial, Helvetica, sans-serif;
text-align:justify;
text-align:center
}
.copyrightNotice {
font:10px/10px Verdana, Arial, Helvetica, sans-serif;
color:#999999;
line-height:110%;
}
.smallHeading {
font:13px/13px Verdana, Arial, Helvetica, sans-serif;
font-weight:bold;
line-height:110%;
}
.tinyHeading {
font:11px/11px Verdana, Arial, Helvetica, sans-serif;
font-weight:bold;
line-height:120%;
}
.newsText {
font:11px/11px Verdana, Arial, Helvetica, sans-serif;
line-height:130%;
}
.smallParagraph {
font:11px/11px Verdana, Arial, Helvetica, sans-serif;
line-height:130%;
}
.fancyHeading {
font:20px/20px Chantilly, Arial, Helvetica, sans-serif;
margin-right: 10px;
color:#6f7a92;
margin-left: 10px;
line-height:130%;
}
-->
</STYLE>
</head>

<BODY BGCOLOR="white">

<h3 align="center">AJDE Test Script</h3>

<p><b>AJBrowser Script</b></p>


<p>Steps 3-6 apply should be re-tested in JBuilder and Forte seperately. </p>


<ol>
<li>launch browser &amp; manipulate config file set<ul>
<li>with no config file passed as command line parameter: error message</li>
<li>open config file by browsing filesystem<ul>
<li>browse and add</li>
<li>close config</li>
<li>close config: silent fail</li>
<li>compile: error message</li>
</ul>
</li>
<li>with multiple config files passed as command line parameters<ul>
<li>a file specified by its full path</li>
<li>a file specified by its relative path</li>
<li>non &quot;.lst&quot; file: file not added to configs list</li>
<li>a file with an incorrect suffix: not added to list</li>
</ul>
</li>
</ul>
</li>
<li><font color="#000080">run</font><ul>
<li><font color="#000080">with no class selected: error dialog</font></li>
<li><font color="#000080">with a non-main class selected: error dialog</font></li>
<li><font color="#000080">with a correct main class selected</font></li>
</ul>
</li>
<li><font color="#000080">debug</font><ul>
<li><font color="#000080">with no class selected: error dialog</font></li>
<li><font color="#000080">with a non-main class selected: error dialog</font></li>
<li><font color="#000080">with a correct main class selected</font></li>
</ul>
</li>
<li>compile<ul>
<li>no config file present: error message</li>
<li>non-existing config file: error message</li>
<li>invalid config file: error dialog<ul>
<li><font color="#008080">incorrect entry: error message seeks to
corresponding line</font></li>
<li><font color="#008080">non-existing file: error message seeks to
corresponding line</font></li>
</ul>
</li>
<li>compile error-generating code: compiler error, failed build reported<ul>
<li>seek to compiler message</li>
<li>recompile: messages pane disappears</li>
</ul>
</li>
<li>compile warning-generating code: compiler warning, successful build
reported</li>
<li><font color="#008080">compile and generate compiler error: error message</font></li>
<li><font color="#008080">compile and generate OutOfMemoryError: error
message</font></li>
<li><font color="#008080">compile and abort: aborted build reported</font></li>
<li>compile valid code: successful build reported</li>
</ul>
</li>
<li>browse structure (expand this section)<ul>
<li>test modes<ul>
<li>global view</li>
<li>file view</li>
<li>split views</li>
</ul>
</li>
<li>expand/collapse tree levels using slider</li>
<li>close and re-launch browser: previously saved structure tree should be
present</li>
</ul>
</li>
<li><font color="#008080">edit &quot;.lst&quot; file</font><ul>
<li><font color="#008080">select for editing and verify integrity of package/file structure</font></li>
<li><font color="#008080">select/deselect nodes and save</font></li>
<li><font color="#008080">verify saves committed to disk</font></li>
<li><font color="#008080">break &quot;.lst&quot; file on disk: error dialog</font></li>
<li><font color="#008080">coverage: when compilation breaks</font></li>
<li><font color="#008080">coverage: when aspectjrt.jar not present on
classpath</font></li>
</ul>
</li>
<li>user preferences<ul>
<li>set options in &quot;Properties&quot; window</li>
<li>close and re-launch browser</li>
<li>verify properties<ul>
<li>Build Options<ul>
<li>non-standard options</li>
</ul>
</li>
</ul>
</li>
</ul>
</li>
<li>error handler<ul>
<li>verify that the error handler shows stack trace</li>
</ul>
</li>
</ol>


<p><b>AJDE/JBuilder</b></p>
<ol>
<li>launch<ul>
<li>AJDE startup message appears</li>
<li>no AJDE listeners are enabled until AJDE started (whitebox)</li>
</ul>
</li>
<li>make new project<ul>
<li>*any* combination of parameters to the new project wizard should work</li>
<li>add packages</li>
<li>add single files</li>
</ul>
</li>
<li>start AJDE</li>
<li>repeat AJBrowser tests</li>
<li>inline annotations<ul>
<li>line with a single annotation</li>
<li>line with multiple annotations</li>
</ul>
</li>
</ol>
<p><b>AJDE/Forte</b></p>
<ol>
<li>launch<ul>
<li>AJDE startup message appears</li>
<li>no AJDE listeners are enabled until AJDE started (whitebox)</li>
</ul>
</li>
<li>make new project<ul>
<li>*any* combination of parameters to the new project wizard should work</li>
<li>add packages</li>
<li>add single files</li>
</ul>
</li>
<li>start AJDE</li>
<li>repeat AJBrowser tests</li>
</ol>


</body>

</html>

+ 200
- 0
tests/ajdoc/JavadocCompareClassMode.java View File

@@ -0,0 +1,200 @@

import java.io.*;
import java.util.*;
import common.OutputComparator;
//import org.aspectj.testing.Tester;

public class JavadocCompareClassMode {

/** wait a minimum (of 1 second) for processes to complete */
static final int MIN_SECS = 1;
/** wait a maximum (of 4 hours) for processes to complete */
static final int MAX_SECS = 4*60*60;

static final String INPUT_FILES = "input/applesJava/*.java";
static final String FILE_1 = "Apple.html";
static final String FILE_2 = "AppleCrate.html";
static final String OUTPUT_DIR = "output";
static final String AJDOC_DIR = OUTPUT_DIR + File.separator + "ajdoc";
static final String JAVADOC_DIR = OUTPUT_DIR + File.separator + "javadoc";
static final String AJDOC_CALL = "java org.aspectj.tools.ajdoc.Main -d " + AJDOC_DIR + " " + INPUT_FILES;
static final String JAVADOC_CALL = "javadoc -package -d " + JAVADOC_DIR + " " + INPUT_FILES;

public static void main(String[] args) { test(System.out); }

public static boolean ensureDir(String dirPath, StringBuffer errSink) {
boolean result = false;
if (dirPath != null) {
try {
File dir = new File(dirPath);
if (!dir.exists()) {
dir.mkdir();
}
result = (dir.exists() && dir.isDirectory());
} catch (SecurityException e) {
if (null != errSink) {
errSink.append(e.getClass().getName());
errSink.append(" ensuring directory ");
errSink.append(dirPath);
errSink.append(": ");
errSink.append(e.getMessage());
}
}
}
return result;
} // ensureDir

/**
* This implements a basic three-step test:
* <UL>
* <LI>step 1: exec ajdoc as a command on INPUT_FILES
* <LI>step 2: exec javadoc in the same way
* <LI>step 3: find differences in files FILE_1 and FILE_2
* </UL>
*/
public static void test(PrintStream sink) {
OutputComparator outputComparator = new OutputComparator();
sink.println("> Setup directories");
StringBuffer errSink = new StringBuffer();
if (! ensureDir(OUTPUT_DIR, errSink)) {
sink.println("Error: " + errSink.toString());
return;
}
if (! ensureDir(AJDOC_DIR, errSink)) {
sink.println("Error: " + errSink.toString());
return;
}
if (! ensureDir(JAVADOC_DIR, errSink)) {
sink.println("Error: " + errSink.toString());
return;
}

String toolName = "> ajdoc";
sink.println(toolName + " running ");
int result = runCommand(AJDOC_CALL);
sink.println(toolName + " result " + result);

toolName = "> javadoc";
sink.println(toolName + " running ");
result = runCommand(JAVADOC_CALL);
sink.println(toolName + " result " + result);

toolName = "> compare";
sink.println(toolName + " running ");
String[] files = new String[] { FILE_1, FILE_2 };
Vector diffs = null;
result = -2;
for (int i = 0; i < files.length; i++) {
String file = files[i];
String ajdocFile = AJDOC_DIR + "/" + file;
String javadocFile = JAVADOC_DIR + "/" + file;
try {
diffs = outputComparator.compareFilesByLine(ajdocFile, javadocFile);
if (diffs == null) {
sink.println("No differences in file " + file);
result = 0;
} else {
result = diffs.size();
sink.println("Start of Differences in file " + FILE_1);
sink.println(diffs.toString());
sink.println("end of Differences in file " + FILE_1);
}
} catch (IOException e) {
sink.println("Exception comparing: " + file);
e.printStackTrace(sink);
result = -1;
}
}
sink.println(toolName + " result " + result);
}

/** write in to out */
static void writeStream(InputStream in, PrintStream out) {
if ((null == in) || (null == out)) {
return;
}
try {
BufferedReader lines = new BufferedReader(new InputStreamReader(in));
String line;
while (null != (line = lines.readLine())) {
out.println(line);
}
} catch (IOException e) {
e.printStackTrace(out);
}
}

/**
* Complete a running process, handling timeout and streams appropriately.
* @param process the Process to run
* @param secsToWait an int for the number of seconds to wait before timing out
* - use Integer.MAXVALUE to mean no timeout (otherwise,
* IllegalArgumentException unless (MIN_SECS <= secsToWait <= MAX_SECS))
* @param outSink the PrintStream sink for the process output stream
* (use null to ignore process output stream).
* @param errSink the PrintStream sink for the process error stream
* (use null to ignore process error stream).
* @returns Integer.MIN_VALUE if interrupted while waiting for process to complete,
* Integer.MAX_VALUE if timed out,
* or the int returned by <code>Process.waitFor()</code> otherwise.
* @throws IllegalArgumentException if any parms are null or invalid
*/
public static int completeProcess(final Process process, int secsToWait,
PrintStream outSink,
PrintStream errSink) {
if (null == process) throw new IllegalArgumentException("null process");
if ((Integer.MAX_VALUE != secsToWait)
&& ((MIN_SECS > secsToWait) || ((MAX_SECS < secsToWait)))) {
throw new IllegalArgumentException("invalid time: " + secsToWait);
}
// setup timeout
TimerTask task = null;
if (Integer.MAX_VALUE != secsToWait) {
Timer t = new Timer(true);
task = new TimerTask() {
public void run() {
process.destroy();
}
};
t.schedule(task, secsToWait*1000l);
}

// try to wait for the process
int status = Integer.MAX_VALUE;
try {
status = process.waitFor();
} catch (InterruptedException ie) {
status = Integer.MIN_VALUE; // ignore
}
finally {
if (null != task) task.cancel();
if (errSink != null) writeStream(process.getErrorStream(), errSink);
// misnamed API: the "input" stream is our input from the process output
if (outSink != null) writeStream(process.getInputStream(), outSink);
}
return status;
} // completeProcess

/**
* Run command, delegating process handling to runProcess.
* @param command the String passed to Runtime.exec
* @return the int returned from process.waitFor();
*/
public static int runCommand(String command) {
int result = -1;
try {
System.out.println("Running " + command);
Process process = Runtime.getRuntime().exec(command);
System.out.println("waiting for Result.." );
final int seconds = 60;
result = completeProcess(process, seconds, System.out, System.err);
System.out.println("Result: " + result + " for " + command);
} catch (Exception e) {
throw new RuntimeException("could not execute: " + command +
", " + e.getMessage() );
}
return result;
}
}

+ 64
- 0
tests/ajdoc/JavadocComparePackageMode.java View File

@@ -0,0 +1,64 @@

import java.io.IOException;
import java.util.Vector;
import common.OutputComparator;
import org.aspectj.testing.Tester;

public class JavadocComparePackageMode {

static final String INPUT_FILES = "-classpath input/pkgExample aPack bPack.cPack";
static final String FILE_1 = "aPack/Class2.html";
static final String FILE_2 = "bPack/cPack/Class3.html";
static final String AJDOC_DIR = "output/packageMode1";
static final String JAVADOC_DIR = "output/packageMode2";
static final String AJDOC_CALL = "java org.aspectj.tools.ajdoc.Main -d " + AJDOC_DIR + " " + INPUT_FILES;
static final String JAVADOC_CALL = "javadoc -package -d " + JAVADOC_DIR + " " + INPUT_FILES;

public static void main(String[] args) { test(); }

/**
* <UL>
* <LI>step 1: run ajdoc as a command
* <LI>step 2: run javadoc
* <LI>step 3: compare differences
* </UL>
*/
public static void test() {
OutputComparator outputComparator = new OutputComparator();
System.out.println("> running ajdoc");
runCommand(AJDOC_CALL);
System.out.println("> running javadoc");
runCommand(JAVADOC_CALL);
Vector diffs1 = null;
Vector diffs2 = null;
try {
diffs1 = outputComparator.compareFilesByLine(AJDOC_DIR + "/" + FILE_1,
JAVADOC_DIR + "/" + FILE_1);
diffs2 = outputComparator.compareFilesByLine(AJDOC_DIR + "/" + FILE_1,
JAVADOC_DIR + "/" + FILE_1);
}
catch (IOException ioe) {
System.out.println("Couldn't compare files: " + ioe.getMessage());
}
String result1 = "";
String result2 = "";
if (diffs1 != null) result1 = diffs1.toString();
if (diffs2 != null) result2 = diffs2.toString();
Tester.checkEqual(result1, "", "diffs from: " + FILE_1);
Tester.checkEqual(result2, "", "diffs from: " + FILE_2);
}

public static void runCommand(String command) {
try {
Runtime runtime = Runtime.getRuntime();
Process result = runtime.exec(command);
}
catch ( Exception ioe ) {
throw new RuntimeException("could not execute: " + command +
", " + ioe.getMessage() );
}
}
}

+ 66
- 0
tests/ajdoc/RegressionComparePackageMode.java View File

@@ -0,0 +1,66 @@

import java.io.IOException;
import java.util.Vector;
import common.OutputComparator;
import org.aspectj.testing.Tester;

public class RegressionComparePackageMode {
static final String CORRECT_RESULTS_DIR = "output/regression1";
static final String RUN_RESULTS_DIR = "output/regression2";
static final String[] FILES_TO_COMPARE = { "/bPack/cPack/Class3.html",
"/coordination/Coordinator.html",
"/spacewar/Ship.html",
"/spacewar/Debug.html" } ;
static final String[] AJDOC_ARGS = { "-d",
RUN_RESULTS_DIR,
"-sourcepath",
"input;input/pkgExample",
"spacewar",
"coordination",
"bPack.cPack" };


public static void main(String[] args) { test(); }

/**
* <UL>
* <LI>step 1: run ajdoc as a command
* <LI>step 2: run javadoc
* <LI>step 3: compare differences
* </UL>
*/
public static void test() {
OutputComparator outputComparator = new OutputComparator();
System.out.println("> running ajdoc");
org.aspectj.tools.ajdoc.Main.main( AJDOC_ARGS );
for ( int i = 0; i < FILES_TO_COMPARE.length; i++ ) {
Vector diffs = null;
try {
diffs = outputComparator.compareFilesByLine(CORRECT_RESULTS_DIR + FILES_TO_COMPARE[i],
RUN_RESULTS_DIR + FILES_TO_COMPARE[i]);
}
catch (IOException ioe) {
System.out.println("Couldn't compare files: " + ioe.getMessage());
}
String result = "";
if (diffs != null) result = diffs.toString();
Tester.checkEqual(result, "", "diffs from: " + FILES_TO_COMPARE[i]);
}
}

public static void runCommand(String command) {
try {
Runtime runtime = Runtime.getRuntime();
Process result = runtime.exec(command);
}
catch ( Exception ioe ) {
throw new RuntimeException("could not execute: " + command +
", " + ioe.getMessage() );
}
}
}

+ 35
- 0
tests/ajdoc/common/OutputComparator.java View File

@@ -0,0 +1,35 @@
package common;

import java.io.*;
import java.util.Vector;

public class OutputComparator
{
/**
* Ignores lines that contain "Generated by javadoc on".
*
* @return the lines that don't match in the two files as a Vector of Strings,
* or null if they are the same.
*/
public Vector compareFilesByLine(String file1, String file2) throws IOException {
Vector diffLines = new Vector();
BufferedReader reader1 = new BufferedReader(new FileReader(file1));
BufferedReader reader2 = new BufferedReader(new FileReader(file2));
String line1 = reader1.readLine();
String line2 = reader2.readLine();
while (line1 != null && line2 != null) {
if (!line1.trim().equals(line2.trim()) &&
line1.indexOf("Generated by javadoc on") == -1 ) {
diffLines.addElement(line1 + " != " + line2);
}
line1 = reader1.readLine();
line2 = reader2.readLine();
}
if (diffLines.size() == 0) {
return null;
}
else {
return diffLines;
}
}
}

+ 119
- 0
tests/ajdoc/input/applesAspectJ/Apple.java View File

@@ -0,0 +1,119 @@

import java.io.Serializable;
import java.io.IOException;

/**
* This class represents an apple that has the following two attributes
* <UL>
* <LI>a variety (i.e. "Macintosh" or "Granny Smith")
* <LI>a brusing factor represnting how badly bruised the apple is
* </UL>
*
* @author Mik Kersten
* @version $Version$
*/

public class Apple implements Serializable
{
private String variety = null;
private int bruising = 0;

/**
* Default constructor.
*
* @param newVariety the type of variety for this apple
*/
public Apple( String newVariety )
{
variety = newVariety;
}
/**
* This inner class represents apple seeds.
*/
public class AppleSeed {
private int weight = 0;
private SeedContents seedContents = null;
/**
* Crosscut Apple serialization methods.
*/
crosscut seedCrosscut(): Apple && void writeObject( java.io.ObjectOutputStream out );

/**
* This is how you get poison from the apple.
*/
public void getArsenic() {
System.out.println( ">> getting arsenic" );
}
/**
* Reperesents the contents of the seeds.
*/
public class SeedContents {
public String core = null;
public String shell = null;
}
}
/**
* Sets the bruising factor of the apple.
*
* @param bruiseFactor the new bruising factor
*/
public void bruise( int bruiseFactor )
{
bruising = bruising + bruiseFactor;
if ( bruising > 100 ) bruising = 100;
if ( bruising < 0 ) bruising = 0;
}
/**
* Returns the bruising factor.
*
* @return bruising the bruising factor associated with the apple
*/
public int getBruising()
{
return bruising;
}
/**
* Serializes the apple object.
*
* @param oos stream that the object is written to
*/
private void writeObject( java.io.ObjectOutputStream oos )
throws IOException
{
// TODO: implement
}
/**
* Reads in the apple object.
*
* @param ois stream that the object is read from
*/
private void readObject( java.io.ObjectInputStream ois )
throws IOException, ClassNotFoundException
{
// TODO: implement
}
}

/**
* Stub class to represent apple peeling.
*/
class ApplePealer
{
/**
* Stub for peeling the apple.
*/
public void peelApple() {
System.out.println( ">> peeling the apple..." );
}
}

+ 52
- 0
tests/ajdoc/input/applesAspectJ/AppleCrate.java View File

@@ -0,0 +1,52 @@

import java.io.Serializable;
import java.io.IOException;

/**
* This class represents an apple crate that is used for transporting apples.
* The apples are contained in an array of <CODE>Apple</CODE> objects.
*
* @author Mik Kersten
* @version $Version$
*
* @see Apple
*/

public class AppleCrate implements Serializable
{
Apple[] crateContents = null;

/**
* Default constructor.
*
* @param newCrateContents an array of <CODE>Apple</CODE> objects
*/
public AppleCrate( Apple[] newCrateContents )
{
crateContents = newCrateContents;
}

/**
* A crate is sellable if the apples are bruised 50% or less on average.
*
* @return <CODE>true</CODE> if the the apples can be sold
*/
public boolean isSellable()
{
int bruising = 0;
for ( int i = 0; i < crateContents.length; i++ )
{
bruising = bruising + crateContents[i].getBruising();
}
if ( (bruising/crateContents.length) > 50 )
{
return false;
}
else
{
return true;
}
}

}

+ 22
- 0
tests/ajdoc/input/applesAspectJ/BigRigAspect.java View File

@@ -0,0 +1,22 @@

/**
* This aspect represents upacking apples after an airplane trip.
*
* @author Mik Kersten
* @version $Version$
*/

public class BigRigAspect extends TransportAspect
{
/**
* Bruise apples with a bruising factor of 15 after unpacking.
*/
static advice unpackCrosscut() {
after {
bruise( 40 );
}
before {
bruise( 10 );
}
}
}

+ 44
- 0
tests/ajdoc/input/applesAspectJ/TransportAspect.java View File

@@ -0,0 +1,44 @@

/**
* This aspect crosscuts the process of shipping apples.
*
* @author Mik Kersten
* @version $Version$
*/

public class TransportAspect
{
private introduction AppleCrate
{
/**
* Represents the name of the given crate. Initialized to be
* a placeholder.
*/
private String crateName = "temp crate";
/**
* Bruises each apple in the crate according to the bruise facor. The bruise
* factor is an integer that is passed as a parameter.
*/
private void bruiser( int bruiseFactor )
{
for ( int i = 0; i < crateContents.length; i++ )
{
crateContents[i].bruise( bruiseFactor );
}
}
}
/**
* Crosscut <CODE>Apple</CODE> serialization methods. This can be used for bruising
* apples and doing other silly things when the apples are being packed.
*/
crosscut packCrosscut(): Apple && void writeObject( java.io.ObjectOutputStream out );

/**
* Crosscut <CODE>Apple</CODE> de-serialization methods. This can be used for doing
* silly things. It is to be used when the apples are unpacked.
*/
crosscut unpackCrosscut(): Apple && void readObject( java.io.ObjectInputStream in );
}

+ 114
- 0
tests/ajdoc/input/applesJava/Apple.java View File

@@ -0,0 +1,114 @@

import java.io.Serializable;
import java.io.IOException;

/**
* This class represents an apple that has the following two attributes
* <UL>
* <LI>a variety (i.e. "Macintosh" or "Granny Smith")
* <LI>a brusing factor represnting how badly bruised the apple is
* </UL>
*
* @author Mik Kersten
* @version $Version$
*/

public class Apple implements Serializable
{
private String variety = null;
private int bruising = 0;

/**
* Default constructor.
*
* @param newVariety the type of variety for this apple
*/
public Apple( String newVariety )
{
variety = newVariety;
}
/**
* This inner class represents apple seeds.
*/
public class AppleSeed {
private int weight = 0;
private SeedContents seedContents = null;
/**
* This is how you get poison from the apple.
*/
public void getArsenic() {
System.out.println( ">> getting arsenic" );
}
/**
* Reperesents the contents of the seeds.
*/
public class SeedContents {
public String core = null;
public String shell = null;
}
}
/**
* Sets the bruising factor of the apple.
*
* @param bruiseFactor the new bruising factor
*/
public void bruise( int bruiseFactor )
{
bruising = bruising + bruiseFactor;
if ( bruising > 100 ) bruising = 100;
if ( bruising < 0 ) bruising = 0;
}
/**
* Returns the bruising factor.
*
* @return bruising the bruising factor associated with the apple
*/
public int getBruising()
{
return bruising;
}
/**
* Serializes the apple object.
*
* @param oos stream that the object is written to
*/
private void writeObject( java.io.ObjectOutputStream oos )
throws IOException
{
// TODO: implement
}
/**
* Reads in the apple object.
*
* @param ois stream that the object is read from
*/
private void readObject( java.io.ObjectInputStream ois )
throws IOException, ClassNotFoundException
{
// TODO: implement
}
}

/**
* Stub class to represent apple peeling.
*/
class ApplePealer
{
/**
* Stub for peeling the apple.
*/
public void peelApple() {
System.out.println( ">> peeling the apple..." );
}
}

+ 52
- 0
tests/ajdoc/input/applesJava/AppleCrate.java View File

@@ -0,0 +1,52 @@

import java.io.Serializable;
import java.io.IOException;

/**
* This class represents an apple crate that is used for transporting apples.
* The apples are contained in an array of <CODE>Apple</CODE> objects.
*
* @author Mik Kersten
* @version $Version$
*
* @see Apple
*/

public class AppleCrate implements Serializable
{
Apple[] crateContents = null;

/**
* Default constructor.
*
* @param newCrateContents an array of <CODE>Apple</CODE> objects
*/
public AppleCrate( Apple[] newCrateContents )
{
crateContents = newCrateContents;
}

/**
* A crate is sellable if the apples are bruised 50% or less on average.
*
* @return <CODE>true</CODE> if the the apples can be sold
*/
public boolean isSellable()
{
int bruising = 0;
for ( int i = 0; i < crateContents.length; i++ )
{
bruising = bruising + crateContents[i].getBruising();
}
if ( (bruising/crateContents.length) > 50 )
{
return false;
}
else
{
return true;
}
}

}

+ 15
- 0
tests/ajdoc/input/applesJava/BigRigAspect.java View File

@@ -0,0 +1,15 @@

/**
* This aspect represents upacking apples after an airplane trip.
*
* @author Mik Kersten
* @version $Version$
*/

public class BigRigAspect extends TransportAspect
{
/**
* Default constructor
*/
public BigRigAspect() {}
}

+ 24
- 0
tests/ajdoc/input/applesJava/TransportAspect.java View File

@@ -0,0 +1,24 @@

/**
* This aspect crosscuts the process of shipping apples.
*
* @author Mik Kersten
* @version $Version$
*/

public class TransportAspect
{
private String crateName = "temp crate";
/**
* Bruises each apple in the crate according to the bruise facor. The bruise
* factor is an integer that is passed as a parameter.
*/
private void bruiser( int bruiseFactor )
{
for ( int i = 0; i < 5; i++ )
{
System.out.println( "bruising" );
}
}
}

+ 16
- 0
tests/ajdoc/input/pkgExample/Class1.java View File

@@ -0,0 +1,16 @@

import aPack.I1;

public class Class1 implements aPack.I1
{
public void method1() {
}
private void method2() {
}
}

class Class1A
{
static final String FOO = "foo";
}

+ 7
- 0
tests/ajdoc/input/pkgExample/aPack/Class2.java View File

@@ -0,0 +1,7 @@

package aPack;

class Class2
{
static final String BAR = "bar";
}

+ 7
- 0
tests/ajdoc/input/pkgExample/aPack/I1.java View File

@@ -0,0 +1,7 @@

package aPack;

public interface I1
{
public void method1();
}

+ 12
- 0
tests/ajdoc/input/pkgExample/bPack/cPack/Class3.java View File

@@ -0,0 +1,12 @@
package bPack.cPack;

public class Class3
{
/**
* Nothing doing.
*/
public void doNothingAtAll()
{
}
}

+ 18
- 0
tests/ajdoc/package.html View File

@@ -0,0 +1,18 @@
<html>
<body>
This is an incomplete attempt to write regression tests for ajdoc by
comparison with javadoc. It aims to run both tools against the
same pure-java sources and compare the output line-by-line, assuming
they should be the same where non-AspectJ elements are concerned.
<p>
It relies entirely on CLASSPATH and PATH being set correctly, and it
generates output directory in the current working directory.
<p>
General example of how to run:
<li>Compile the sources</li>
<li>Setup CLASSPATH, including compiled sources and JDK tools.jar (for javadoc)</li>
<li>Setup PATH, so that "java" invokes a 1.2 or later java vm </li>
<li>Invoke from the directory with input/ as a subdirectory:
<br><code>java JavadocCompareClassMode</code></li>
</body>
</html>

+ 406
- 0
tests/ant/etc/ajc.xml View File

@@ -0,0 +1,406 @@
<project name="ajc.test" basedir="." default="init">

<!-- caller should define compile.classpath and ajc.taskdef.classpath -->
<property file="${basedir}/local.properties"/>
<property name="ant.test.src.dir" value="../src" />

<target name="init">
<tstamp/>
<taskdef name="ajc" classname="org.aspectj.tools.ant.taskdefs.Ajc"
classpath="${ajc.taskdef.classpath}"/>
</target>

<target name="all" depends="init">
<antcall target="test1"/>
<antcall target="test2"/>
<antcall target="test3"/>
<antcall target="test4"/>
<antcall target="test4b"/>
<antcall target="test5"/>
<antcall target="test5b"/>
<antcall target="test6"/>
<antcall target="test8"/>
<antcall target="test9"/>
<antcall target="test10"/>
<antcall target="test11"/>
<antcall target="test12"/>
<antcall target="test13"/>
<antcall target="test14"/>
<!-- todo failures are killing the run at this time
<antcall target="fail1" />
<antcall target="fail2" />
<antcall target="fail3" />
-->
</target>

<target name="test1" depends="init">
<mkdir dir="${ant.test.classes}"/>
<ajc srcdir="${ant.test.src.dir}"
destdir="${ant.test.classes}"
includes="One.java"
classpath="${compile.classpath}"
/>

</target>

<target name="test2" depends="init">
<mkdir dir="${ant.test.classes}"/>
<ajc srcdir="${ant.test.src.dir}"
destdir="${ant.test.classes}"
includes="One.java,Two.java"
classpath="${compile.classpath}"
/>
</target>

<target name="test3" depends="init">
<mkdir dir="${ant.test.classes}"/>
<ajc srcdir="${ant.test.src.dir}"
destdir="${ant.test.classes}"
includes="*"
classpath="${compile.classpath}"
/>
</target>

<target name="test4" depends="init">
<mkdir dir="${ant.test.classes}"/>
<ajc srcdir="${ant.test.src.dir}"
destdir="${ant.test.classes}"
argfiles="${ant.test.src.dir}/files1.lst"
classpath="${compile.classpath}"
/>
</target>

<target name="test4b" depends="init">
<mkdir dir="${ant.test.classes}"/>
<ajc
destdir="${ant.test.classes}"
argfiles="${ant.test.src.dir}/files1.lst"
classpath="${compile.classpath}"
/>
</target>

<target name="test5" depends="init">
<mkdir dir="${ant.test.classes}"/>
<ajc srcdir="${ant.test.src.dir}"
destdir="${ant.test.classes}"
argfiles="${ant.test.src.dir}/files2.lst"
classpath="${compile.classpath}"
/>
</target>

<target name="test5b" depends="init">
<mkdir dir="${ant.test.classes}"/>
<ajc
destdir="${ant.test.classes}"
argfiles="${ant.test.src.dir}/files2.lst"
classpath="${compile.classpath}"
/>
</target>

<target name="test6" depends="init">
<mkdir dir="${ant.test.classes}"/>
<ajc srcdir="${ant.test.src.dir}"
destdir="${ant.test.classes}"
argfiles="${ant.test.src.dir}/files3.lst"
classpath="${compile.classpath}"
/>
</target>

<target name="test6b" depends="init">
<mkdir dir="${ant.test.classes}"/>
<ajc
destdir="${ant.test.classes}"
argfiles="${ant.test.src.dir}/files3.lst"
classpath="${compile.classpath}"
/>
</target>

<target name="test8" depends="init">
<mkdir dir="${ant.test.classes}"/>
<ajc srcdir="${ant.test.src.dir}"
destdir="${ant.test.classes}"
excludes="Two.java"
argfiles="${ant.test.src.dir}/files2.lst"
classpath="${compile.classpath}"
/>
</target>

<target name="test9" depends="init">
<mkdir dir="${ant.test.classes}"/>
<ajc srcdir="${ant.test.src.dir}"
destdir="${ant.test.classes}"
includes="One.java"
threads="1"
classpath="${compile.classpath}"
/>
</target>

<target name="test10" depends="init">
<mkdir dir="${ant.test.classes}"/>
<ajc srcdir="${ant.test.src.dir}"
destdir="${ant.test.classes}"
includes="One.java"
nocomments="yes"
classpath="${compile.classpath}"
/>
</target>

<target name="test11" depends="init">
<mkdir dir="${ant.test.classes}"/>
<ajc srcdir="${ant.test.src.dir}"
destdir="${ant.test.classes}"
includes="One.java"
nosymbols="yes"
classpath="${compile.classpath}"
/>
</target>

<target name="test12" depends="init">
<mkdir dir="${ant.test.classes}"/>
<ajc srcdir="${ant.test.src.dir}"
destdir="${ant.test.classes}"
includes="One.java"
preprocess="yes"
classpath="${compile.classpath}"
/>
</target>

<target name="test13" depends="init">
<mkdir dir="${ant.test.classes}"/>
<ajc srcdir="${ant.test.src.dir}"
destdir="${ant.test.classes}"
includes="One.java"
workingdir="ajworkingdir"
classpath="${compile.classpath}"
/>
</target>
<target name="test14" depends="init"
description="TestCase for PR#557 (NPE when logging if no optional destdir)">
<mkdir dir="${ant.test.classes}"/>
<ajc srcdir="${ant.test.src.dir}"
includes="One.java"
classpath="${compile.classpath}"
/>
</target>


<target name="fail1" depends="init">
<mkdir dir="${ant.test.classes}"/>
<ajc
destdir="${ant.test.classes}"
includes="One.java"
classpath="${compile.classpath}"
failonerror="no"
/>
</target>

<target name="fail2" depends="init">
<mkdir dir="${ant.test.classes}"/>
<ajc
destdir="${ant.test.classes}"
excludes="One.java"
classpath="${compile.classpath}"
failonerror="no"
/>
</target>

<target name="fail3" depends="init">
<mkdir dir="${ant.test.classes}"/>
<ajc
destdir="${ant.test.classes}"
includes="Two.java"
excludes="One.java"
classpath="${compile.classpath}"
/>
</target>

<!-- forked -->

<target name="test1_fork" depends="init">
<mkdir dir="${ant.test.classes}"/>
<ajc srcdir="${ant.test.src.dir}"
destdir="${ant.test.classes}"
includes="One.java"
fork="yes"
classpath="${compile.classpath}"
/>
</target>

<target name="test2_fork" depends="init">
<mkdir dir="${ant.test.classes}"/>
<ajc srcdir="${ant.test.src.dir}"
destdir="${ant.test.classes}"
includes="One.java,Two.java"
fork="yes"
classpath="${compile.classpath}"
/>
</target>

<target name="test3_fork" depends="init">
<mkdir dir="${ant.test.classes}"/>
<ajc srcdir="${ant.test.src.dir}"
destdir="${ant.test.classes}"
includes="*"
fork="yes"
classpath="${compile.classpath}"
/>
</target>

<target name="test4_fork" depends="init">
<mkdir dir="${ant.test.classes}"/>
<ajc srcdir="${ant.test.src.dir}"
destdir="${ant.test.classes}"
argfiles="${ant.test.src.dir}/files1.lst"
classpath="${compile.classpath}"
fork="yes"
/>
</target>

<target name="test4b_fork" depends="init">
<mkdir dir="${ant.test.classes}"/>
<ajc
destdir="${ant.test.classes}"
argfiles="${ant.test.src.dir}/files1.lst"
fork="yes"
classpath="${compile.classpath}"
/>
</target>

<target name="test5_fork" depends="init">
<mkdir dir="${ant.test.classes}"/>
<ajc srcdir="${ant.test.src.dir}"
destdir="${ant.test.classes}"
argfiles="${ant.test.src.dir}/files2.lst"
fork="yes"
classpath="${compile.classpath}"
/>
</target>

<target name="test5b_fork" depends="init">
<mkdir dir="${ant.test.classes}"/>
<ajc
destdir="${ant.test.classes}"
argfiles="${ant.test.src.dir}/files2.lst"
fork="yes"
classpath="${compile.classpath}"
/>
</target>

<target name="test6_fork" depends="init">
<mkdir dir="${ant.test.classes}"/>
<ajc srcdir="${ant.test.src.dir}"
destdir="${ant.test.classes}"
argfiles="${ant.test.src.dir}/files3.lst"
fork="yes"
classpath="${compile.classpath}"
/>
</target>

<target name="test6b_fork" depends="init">
<mkdir dir="${ant.test.classes}"/>
<ajc
destdir="${ant.test.classes}"
argfiles="${ant.test.src.dir}/files3.lst"
fork="yes"
classpath="${compile.classpath}"
/>
</target>

<target name="test8_fork" depends="init">
<mkdir dir="${ant.test.classes}"/>
<ajc srcdir="${ant.test.src.dir}"
destdir="${ant.test.classes}"
excludes="Two.java"
argfiles="${ant.test.src.dir}/files2.lst"
fork="yes"
classpath="${compile.classpath}"
/>
</target>

<target name="test9_fork" depends="init">
<mkdir dir="${ant.test.classes}"/>
<ajc srcdir="${ant.test.src.dir}"
destdir="${ant.test.classes}"
includes="One.java"
threads="1"
fork="yes"
classpath="${compile.classpath}"
/>
</target>

<target name="test10_fork" depends="init">
<mkdir dir="${ant.test.classes}"/>
<ajc srcdir="${ant.test.src.dir}"
destdir="${ant.test.classes}"
includes="One.java"
nocomments="yes"
fork="yes"
classpath="${compile.classpath}"
/>
</target>

<target name="test11_fork" depends="init">
<mkdir dir="${ant.test.classes}"/>
<ajc srcdir="${ant.test.src.dir}"
destdir="${ant.test.classes}"
includes="One.java"
nosymbols="yes"
fork="yes"
classpath="${compile.classpath}"
/>
</target>

<target name="test12_fork" depends="init">
<mkdir dir="${ant.test.classes}"/>
<ajc srcdir="${ant.test.src.dir}"
destdir="${ant.test.classes}"
includes="One.java"
preprocess="yes"
fork="yes"
classpath="${compile.classpath}"
/>
</target>

<target name="test13_fork" depends="init">
<mkdir dir="${ant.test.classes}"/>
<ajc srcdir="${ant.test.src.dir}"
destdir="${ant.test.classes}"
includes="One.java"
workingdir="ajworkingdir"
fork="yes"
classpath="${compile.classpath}"
/>
</target>

<target name="fail1_fork" depends="init">
<mkdir dir="${ant.test.classes}"/>
<ajc
destdir="${ant.test.classes}"
includes="One.java"
fork="yes"
classpath="${compile.classpath}"
/>
</target>

<target name="fail2_fork" depends="init">
<mkdir dir="${ant.test.classes}"/>
<ajc
destdir="${ant.test.classes}"
excludes="One.java"
fork="yes"
classpath="${compile.classpath}"
/>
</target>

<target name="fail3_fork" depends="init">
<mkdir dir="${ant.test.classes}"/>
<ajc
destdir="${ant.test.classes}"
includes="Two.java"
excludes="One.java"
fork="yes"
classpath="${compile.classpath}"
/>
</target>

</project>

+ 201
- 0
tests/ant/etc/ajc2.xml View File

@@ -0,0 +1,201 @@
<project name="ajc2.test" basedir="." default="init">

<property name="ant.test.src.dir" value="../src" />
<property name="ant.test.classes" value="test-classes"/>

<target name="init">
<tstamp/>
<taskdef name="ajc" classname="org.aspectj.tools.ant.taskdefs.Ajc2"
classpath="${ajc.taskdef.classpath}" />
</target>

<target name="all" depends="init">
<antcall target="test1"/>
<antcall target="test2"/>
<antcall target="test3"/>
<antcall target="test4"/>
<antcall target="test4b"/>
<antcall target="test5"/>
<antcall target="test5b"/>
<antcall target="test6"/>
<antcall target="test8"/>
<antcall target="test9"/>
<antcall target="test10"/>
<antcall target="test11"/>
<antcall target="test12"/>
<antcall target="test13"/>
<antcall target="fail1"/>
<antcall target="fail2"/>
<antcall target="fail3"/>
</target>

<target name="test1" depends="init">
<mkdir dir="${ant.test.classes}"/>
<ajc srcdir="${ant.test.src.dir}"
destdir="${ant.test.classes}"
includes="One.java"
classpath="${compile.classpath}"
/>
</target>

<target name="test2" depends="init">
<mkdir dir="${ant.test.classes}"/>
<ajc srcdir="${ant.test.src.dir}"
destdir="${ant.test.classes}"
includes="One.java,Two.java"
classpath="${compile.classpath}"
/>
</target>

<target name="test3" depends="init">
<mkdir dir="${ant.test.classes}"/>
<ajc srcdir="${ant.test.src.dir}"
destdir="${ant.test.classes}"
includes="*"
classpath="${compile.classpath}"
/>
</target>

<target name="test4" depends="init">
<mkdir dir="${ant.test.classes}"/>
<ajc srcdir="${ant.test.src.dir}"
destdir="${ant.test.classes}"
argfiles="${ant.test.src.dir}/files1.lst"
classpath="${compile.classpath}"
/>
</target>

<target name="test4b" depends="init">
<mkdir dir="${ant.test.classes}"/>
<ajc
destdir="${ant.test.classes}"
argfiles="${ant.test.src.dir}/files1.lst"
classpath="${compile.classpath}"
/>
</target>

<target name="test5" depends="init">
<mkdir dir="${ant.test.classes}"/>
<ajc srcdir="${ant.test.src.dir}"
destdir="${ant.test.classes}"
argfiles="${ant.test.src.dir}/files2.lst"
classpath="${compile.classpath}"
/>
</target>

<target name="test5b" depends="init">
<mkdir dir="${ant.test.classes}"/>
<ajc
destdir="${ant.test.classes}"
argfiles="${ant.test.src.dir}/files2.lst"
classpath="${compile.classpath}"
/>
</target>

<target name="test6" depends="init">
<mkdir dir="${ant.test.classes}"/>
<ajc srcdir="${ant.test.src.dir}"
destdir="${ant.test.classes}"
argfiles="${ant.test.src.dir}/files3.lst"
classpath="${compile.classpath}"
/>
</target>

<target name="test6b" depends="init">
<mkdir dir="${ant.test.classes}"/>
<ajc
destdir="${ant.test.classes}"
argfiles="${ant.test.src.dir}/files3.lst"
classpath="${compile.classpath}"
/>
</target>

<target name="test8" depends="init">
<mkdir dir="${ant.test.classes}"/>
<ajc srcdir="${ant.test.src.dir}"
destdir="${ant.test.classes}"
excludes="Two.java"
argfiles="${ant.test.src.dir}/files2.lst"
classpath="${compile.classpath}"
/>
</target>

<target name="test9" depends="init">
<mkdir dir="${ant.test.classes}"/>
<ajc srcdir="${ant.test.src.dir}"
destdir="${ant.test.classes}"
includes="One.java"
threads="1"
classpath="${compile.classpath}"
/>
</target>

<target name="test10" depends="init">
<mkdir dir="${ant.test.classes}"/>
<ajc srcdir="${ant.test.src.dir}"
destdir="${ant.test.classes}"
includes="One.java"
nocomments="yes"
classpath="${compile.classpath}"
/>
</target>

<target name="test11" depends="init">
<mkdir dir="${ant.test.classes}"/>
<ajc srcdir="${ant.test.src.dir}"
destdir="${ant.test.classes}"
includes="One.java"
nosymbols="yes"
classpath="${compile.classpath}"
/>
</target>

<target name="test12" depends="init">
<mkdir dir="${ant.test.classes}"/>
<ajc srcdir="${ant.test.src.dir}"
destdir="${ant.test.classes}"
includes="One.java"
preprocess="yes"
classpath="${compile.classpath}"
/>
</target>

<target name="test13" depends="init">
<mkdir dir="${ant.test.classes}"/>
<ajc srcdir="${ant.test.src.dir}"
destdir="${ant.test.classes}"
includes="One.java"
workingdir="ajworkingdir"
classpath="${compile.classpath}"
/>
</target>

<target name="fail1" depends="init">
<mkdir dir="${ant.test.classes}"/>
<ajc
destdir="${ant.test.classes}"
includes="One.java"
classpath="${compile.classpath}"
/>
</target>

<target name="fail2" depends="init">
<mkdir dir="${ant.test.classes}"/>
<ajc
destdir="${ant.test.classes}"
excludes="One.java"
classpath="${compile.classpath}"
/>
</target>

<target name="fail3" depends="init">
<mkdir dir="${ant.test.classes}"/>
<ajc
destdir="${ant.test.classes}"
includes="Two.java"
excludes="One.java"
classpath="${compile.classpath}"
/>
</target>

</project>

+ 318
- 0
tests/ant/etc/ajclean.xml View File

@@ -0,0 +1,318 @@
<project name="ajc.test" basedir="." default="init">

<property name="ant.test.sources" value="../src" />
<property name="ant.test.classes" value="test-classes"/>

<target name="init">
<tstamp/>
<taskdef name="ajc" classname="org.aspectj.tools.ant.taskdefs.Ajc"/>
<taskdef name="ajclean" classname="org.aspectj.tools.ant.taskdefs.Ajclean"/>
</target>

<target name="test1" depends="init">
<ajc srcdir="${ant.test.sources}"
destdir="${ant.test.classes}"
includes="One.java"
/>
<ajclean srcdir="${ant.test.sources}"
destdir="${ant.test.classes}"
includes="One.java"
/>
</target>

<target name="test2" depends="init">
<ajc srcdir="${ant.test.sources}"
destdir="${ant.test.classes}"
includes="One.java,Two.java"
/>
<ajclean srcdir="${ant.test.sources}"
destdir="${ant.test.classes}"
includes="One.java,Two.java"
/>
</target>

<target name="test3" depends="init">
<ajc srcdir="${ant.test.sources}"
destdir="${ant.test.classes}"
includes="*"
/>
<ajclean srcdir="${ant.test.sources}"
destdir="${ant.test.classes}"
includes="*"
/>
</target>

<target name="test4" depends="init">
<ajc srcdir="${ant.test.sources}"
destdir="${ant.test.classes}"
argfiles="${ant.test.sources}/files1.lst"
/>
<ajclean srcdir="${ant.test.sources}"
destdir="${ant.test.classes}"
argfiles="${ant.test.sources}/files1.lst"
/>
</target>

<target name="test4b" depends="init">
<ajc
destdir="${ant.test.classes}"
argfiles="${ant.test.sources}/files1.lst"
/>
<ajclean
destdir="${ant.test.classes}"
argfiles="${ant.test.sources}/files1.lst"
/>
</target>

<target name="test5" depends="init">
<ajc srcdir="${ant.test.sources}"
destdir="${ant.test.classes}"
argfiles="${ant.test.sources}/files2.lst"
/>
<ajclean srcdir="${ant.test.sources}"
destdir="${ant.test.classes}"
argfiles="${ant.test.sources}/files2.lst"
/>
</target>

<target name="test5b" depends="init">
<ajc
destdir="${ant.test.classes}"
argfiles="${ant.test.sources}/files2.lst"
/>
<ajclean
destdir="${ant.test.classes}"
argfiles="${ant.test.sources}/files2.lst"
/>
</target>

<target name="test6" depends="init">
<ajc srcdir="${ant.test.sources}"
destdir="${ant.test.classes}"
argfiles="${ant.test.sources}/files3.lst"
/>
<ajclean srcdir="${ant.test.sources}"
destdir="${ant.test.classes}"
argfiles="${ant.test.sources}/files3.lst"
/>
</target>

<target name="test6b" depends="init">
<ajc
destdir="${ant.test.classes}"
argfiles="${ant.test.sources}/files3.lst"
/>
<ajclean
destdir="${ant.test.classes}"
argfiles="${ant.test.sources}/files3.lst"
/>
</target>

<target name="test8" depends="init">
<ajc srcdir="${ant.test.sources}"
destdir="${ant.test.classes}"
excludes="Two.java"
argfiles="${ant.test.sources}/files2.lst"
/>
<ajclean srcdir="${ant.test.sources}"
destdir="${ant.test.classes}"
excludes="Two.java"
argfiles="${ant.test.sources}/files2.lst"
/>
</target>

<target name="test9" depends="init">
<ajc srcdir="${ant.test.sources}"
destdir="${ant.test.classes}"
includes="One.java"
threads="1"
/>
<ajclean srcdir="${ant.test.sources}"
destdir="${ant.test.classes}"
includes="One.java"
threads="1"
/>
</target>

<target name="test10" depends="init">
<ajc srcdir="${ant.test.sources}"
destdir="${ant.test.classes}"
includes="One.java"
nocomments="yes"
/>
<ajclean srcdir="${ant.test.sources}"
destdir="${ant.test.classes}"
includes="One.java"
nocomments="yes"
/>
</target>

<target name="test11" depends="init">
<ajc srcdir="${ant.test.sources}"
destdir="${ant.test.classes}"
includes="One.java"
nosymbols="yes"
/>
<ajclean srcdir="${ant.test.sources}"
destdir="${ant.test.classes}"
includes="One.java"
nosymbols="yes"
/>
</target>

<target name="test12" depends="init">
<ajc srcdir="${ant.test.sources}"
destdir="${ant.test.classes}"
includes="One.java"
preprocess="yes"
/>
<ajclean srcdir="${ant.test.sources}"
destdir="${ant.test.classes}"
includes="One.java"
preprocess="yes"
/>
</target>

<target name="test13" depends="init">
<ajc srcdir="${ant.test.sources}"
destdir="${ant.test.classes}"
includes="One.java"
workingdir="ajworkingdir"
/>
<ajclean srcdir="${ant.test.sources}"
destdir="${ant.test.classes}"
includes="One.java"
workingdir="ajworkingdir"
/>
</target>


<!-- Everything -->

<target name="test1star" depends="init">
<ajc srcdir="${ant.test.sources}"
destdir="${ant.test.classes}"
includes="One.java"
/>
<ajclean srcdir="${ant.test.sources}"/>
</target>

<target name="test2star" depends="init">
<ajc srcdir="${ant.test.sources}"
destdir="${ant.test.classes}"
includes="One.java,Two.java"
/>
<ajclean srcdir="${ant.test.sources}"/>
</target>

<target name="test3star" depends="init">
<ajc srcdir="${ant.test.sources}"
destdir="${ant.test.classes}"
includes="*"
/>
<ajclean srcdir="${ant.test.sources}"/>
</target>

<target name="test4star" depends="init">
<ajc srcdir="${ant.test.sources}"
destdir="${ant.test.classes}"
argfiles="${ant.test.sources}/files1.lst"
/>
<ajclean srcdir="${ant.test.sources}"/>
</target>

<target name="test4bstar" depends="init">
<ajc
destdir="${ant.test.classes}"
argfiles="${ant.test.sources}/files1.lst"
/>
<ajclean srcdir="${ant.test.sources}"/>
</target>

<target name="test5star" depends="init">
<ajc srcdir="${ant.test.sources}"
destdir="${ant.test.classes}"
argfiles="${ant.test.sources}/files2.lst"
/>
<ajclean srcdir="${ant.test.sources}"/>
</target>

<target name="test5bstar" depends="init">
<ajc
destdir="${ant.test.classes}"
argfiles="${ant.test.sources}/files2.lst"
/>
<ajclean srcdir="${ant.test.sources}"/>
</target>

<target name="test6star" depends="init">
<ajc srcdir="${ant.test.sources}"
destdir="${ant.test.classes}"
argfiles="${ant.test.sources}/files3.lst"
/>
<ajclean srcdir="${ant.test.sources}"/>
</target>

<target name="test6bstar" depends="init">
<ajc
destdir="${ant.test.classes}"
argfiles="${ant.test.sources}/files3.lst"
/>
<ajclean srcdir="${ant.test.sources}"/>
</target>

<target name="test8star" depends="init">
<ajc srcdir="${ant.test.sources}"
destdir="${ant.test.classes}"
excludes="Two.java"
argfiles="${ant.test.sources}/files2.lst"
/>
<ajclean srcdir="${ant.test.sources}"/>
</target>

<target name="test9star" depends="init">
<ajc srcdir="${ant.test.sources}"
destdir="${ant.test.classes}"
includes="One.java"
threads="1"
/>
<ajclean srcdir="${ant.test.sources}"/>
</target>

<target name="test10star" depends="init">
<ajc srcdir="${ant.test.sources}"
destdir="${ant.test.classes}"
includes="One.java"
nocomments="yes"
/>
<ajclean srcdir="${ant.test.sources}"/>
</target>

<target name="test11star" depends="init">
<ajc srcdir="${ant.test.sources}"
destdir="${ant.test.classes}"
includes="One.java"
nosymbols="yes"
/>
<ajclean srcdir="${ant.test.sources}"/>
</target>

<target name="test12star" depends="init">
<ajc srcdir="${ant.test.sources}"
destdir="${ant.test.classes}"
includes="One.java"
preprocess="yes"
/>
<ajclean srcdir="${ant.test.sources}"/>
</target>

<target name="test13star" depends="init">
<ajc srcdir="${ant.test.sources}"
destdir="${ant.test.classes}"
includes="One.java"
workingdir="ajworkingdir"
/>
<ajclean srcdir="${ant.test.sources}"/>
</target>

</project>

+ 545
- 0
tests/ant/etc/ajdoc.xml View File

@@ -0,0 +1,545 @@
<project name="ajdoc.test" basedir="." default="test">

<!-- this file defines ant.test.src.dir, ant.test.doc.dir todo remove local defs-->
<property file="${basedir}/local.properties"/>

<target name="init">
<tstamp/>
<taskdef name="ajdoc" classname="org.aspectj.tools.ant.taskdefs.Ajdoc"
classpath="${ajc.taskdef.classpath}" />
</target>

<!-- fail998 ,fail999 -->
<target name="test"
depends="test985
,test986
,test987
,test988
,test989
,test990
,test991
,test992
,test993
,test994
,test995
,test996
,test997
,test998
,test999
,test_author_no
,test_author_yes
,test_bottom
,test_doctitle
,test_footer
,test_header
,test_helpfile
,test_nodeprecated_no
,test_nodeprecated_yes
,test_nodeprecatedlist_no
,test_nodeprecatedlist_yes
,test_nohelp_no
,test_nohelp_yes
,test_noindex_no
,test_noindex_yes
,test_notree_no
,test_notree_yes
,test_package_no
,test_package_yes
,test_private_no
,test_private_yes
,test_protected_no
,test_protected_yes
,test_public_no
,test_public_yes
,test_splitindex_no
,test_splitindex_yes
,test_stylesheetfile
,test_use_no
,test_use_yes
,test_standard_no
,test_standard_yes
,test_windowtitle"/>

<target name="fail998" depends="init">
<mkdir dir="${ant.test.doc.dir}"/>
<ajdoc sourcepath="${ant.test.src.dir}"
sourcefiles="One.java"
classpath="${compile.classpath}"
/>
</target>

<target name="fail999" depends="init">
<mkdir dir="${ant.test.doc.dir}"/>
<ajdoc
destdir="${ant.test.doc.dir}"
sourcefiles="One.java"
classpath="${compile.classpath}"
/>
</target>

<target name="test_stylesheetfile" depends="init">
<mkdir dir="${ant.test.doc.dir}"/>
<ajdoc sourcepath="${ant.test.src.dir}"
destdir="${ant.test.doc.dir}"
sourcefiles="One.java"
stylesheetfile="${ant.test.src.dir}/mystylesheet.css"
classpath="${compile.classpath}"
/>
</target>

<target name="test_helpfile" depends="init">
<mkdir dir="${ant.test.doc.dir}"/>
<ajdoc sourcepath="${ant.test.src.dir}"
destdir="${ant.test.doc.dir}"
sourcefiles="One.java"
helpfile="${ant.test.src.dir}/myhelp.html"
classpath="${compile.classpath}"
/>
</target>

<target name="test_nodeprecatedlist_no" depends="init">
<mkdir dir="${ant.test.doc.dir}"/>
<ajdoc sourcepath="${ant.test.src.dir}"
destdir="${ant.test.doc.dir}"
sourcefiles="One.java"
nodeprecatedlist="no"
classpath="${compile.classpath}"
/>
</target>

<target name="test_nodeprecatedlist_yes" depends="init">
<mkdir dir="${ant.test.doc.dir}"/>
<ajdoc sourcepath="${ant.test.src.dir}"
destdir="${ant.test.doc.dir}"
sourcefiles="One.java"
nodeprecatedlist="yes"
classpath="${compile.classpath}"
/>
</target>

<target name="test_nodeprecated_no" depends="init">
<mkdir dir="${ant.test.doc.dir}"/>
<ajdoc sourcepath="${ant.test.src.dir}"
destdir="${ant.test.doc.dir}"
sourcefiles="One.java"
nodeprecated="no"
classpath="${compile.classpath}"
/>
</target>

<target name="test_nodeprecated_yes" depends="init">
<mkdir dir="${ant.test.doc.dir}"/>
<ajdoc sourcepath="${ant.test.src.dir}"
destdir="${ant.test.doc.dir}"
sourcefiles="One.java"
nodeprecated="yes"
classpath="${compile.classpath}"
/>
</target>

<target name="test_use_no" depends="init">
<mkdir dir="${ant.test.doc.dir}"/>
<ajdoc sourcepath="${ant.test.src.dir}"
destdir="${ant.test.doc.dir}"
sourcefiles="One.java"
use="no"
classpath="${compile.classpath}"
/>
</target>

<target name="test_use_yes" depends="init">
<mkdir dir="${ant.test.doc.dir}"/>
<ajdoc sourcepath="${ant.test.src.dir}"
destdir="${ant.test.doc.dir}"
sourcefiles="One.java"
use="yes"
classpath="${compile.classpath}"
/>
</target>

<target name="test_standard_yes" depends="init">
<mkdir dir="${ant.test.doc.dir}"/>
<ajdoc sourcepath="${ant.test.src.dir}"
destdir="${ant.test.doc.dir}"
sourcefiles="One.java"
standard="yes"
classpath="${compile.classpath}"
/>
</target>

<target name="test_standard_no" depends="init">
<mkdir dir="${ant.test.doc.dir}"/>
<ajdoc sourcepath="${ant.test.src.dir}"
destdir="${ant.test.doc.dir}"
sourcefiles="One.java"
standard="no"
classpath="${compile.classpath}"
/>
</target>

<target name="test_author_no" depends="init">
<mkdir dir="${ant.test.doc.dir}"/>
<ajdoc sourcepath="${ant.test.src.dir}"
destdir="${ant.test.doc.dir}"
sourcefiles="One.java"
author="no"
classpath="${compile.classpath}"
/>
</target>

<target name="test_author_yes" depends="init">
<mkdir dir="${ant.test.doc.dir}"/>
<ajdoc sourcepath="${ant.test.src.dir}"
destdir="${ant.test.doc.dir}"
sourcefiles="One.java"
author="yes"
classpath="${compile.classpath}"
/>
</target>

<target name="test_public_no" depends="init">
<mkdir dir="${ant.test.doc.dir}"/>
<ajdoc sourcepath="${ant.test.src.dir}"
destdir="${ant.test.doc.dir}"
sourcefiles="One.java"
public="no"
classpath="${compile.classpath}"
/>
</target>

<target name="test_public_yes" depends="init">
<mkdir dir="${ant.test.doc.dir}"/>
<ajdoc sourcepath="${ant.test.src.dir}"
destdir="${ant.test.doc.dir}"
sourcefiles="One.java"
public="yes"
classpath="${compile.classpath}"
/>
</target>

<target name="test_package_no" depends="init">
<mkdir dir="${ant.test.doc.dir}"/>
<ajdoc sourcepath="${ant.test.src.dir}"
destdir="${ant.test.doc.dir}"
sourcefiles="One.java"
package="no"
classpath="${compile.classpath}"
/>
</target>

<target name="test_package_yes" depends="init">
<mkdir dir="${ant.test.doc.dir}"/>
<ajdoc sourcepath="${ant.test.src.dir}"
destdir="${ant.test.doc.dir}"
sourcefiles="One.java"
package="yes"
classpath="${compile.classpath}"
/>
</target>

<target name="test_protected_no" depends="init">
<mkdir dir="${ant.test.doc.dir}"/>
<ajdoc sourcepath="${ant.test.src.dir}"
destdir="${ant.test.doc.dir}"
sourcefiles="One.java"
protected="no"
classpath="${compile.classpath}"
/>
</target>

<target name="test_protected_yes" depends="init">
<mkdir dir="${ant.test.doc.dir}"/>
<ajdoc sourcepath="${ant.test.src.dir}"
destdir="${ant.test.doc.dir}"
sourcefiles="One.java"
protected="yes"
classpath="${compile.classpath}"
/>
</target>

<target name="test_private_no" depends="init">
<mkdir dir="${ant.test.doc.dir}"/>
<ajdoc sourcepath="${ant.test.src.dir}"
destdir="${ant.test.doc.dir}"
sourcefiles="One.java"
private="no"
classpath="${compile.classpath}"
/>
</target>

<target name="test_private_yes" depends="init">
<mkdir dir="${ant.test.doc.dir}"/>
<ajdoc sourcepath="${ant.test.src.dir}"
destdir="${ant.test.doc.dir}"
sourcefiles="One.java"
private="yes"
classpath="${compile.classpath}"
/>
</target>

<target name="test_splitindex_no" depends="init">
<mkdir dir="${ant.test.doc.dir}"/>
<ajdoc sourcepath="${ant.test.src.dir}"
destdir="${ant.test.doc.dir}"
sourcefiles="One.java"
splitindex="no"
classpath="${compile.classpath}"
/>
</target>

<target name="test_splitindex_yes" depends="init">
<mkdir dir="${ant.test.doc.dir}"/>
<ajdoc sourcepath="${ant.test.src.dir}"
destdir="${ant.test.doc.dir}"
sourcefiles="One.java"
splitindex="yes"
classpath="${compile.classpath}"
/>
</target>

<target name="test_windowtitle" depends="init">
<mkdir dir="${ant.test.doc.dir}"/>
<ajdoc sourcepath="${ant.test.src.dir}"
destdir="${ant.test.doc.dir}"
sourcefiles="One.java"
windowtitle="Window Title"
classpath="${compile.classpath}"
/>
</target>

<target name="test_doctitle" depends="init">
<mkdir dir="${ant.test.doc.dir}"/>
<ajdoc sourcepath="${ant.test.src.dir}"
destdir="${ant.test.doc.dir}"
sourcefiles="One.java"
doctitle="&lt;H1&gt;Doc Title&lt;/H1&gt;"
classpath="${compile.classpath}"
/>
</target>

<target name="test_bottom" depends="init">
<mkdir dir="${ant.test.doc.dir}"/>
<ajdoc sourcepath="${ant.test.src.dir}"
destdir="${ant.test.doc.dir}"
sourcefiles="One.java"
bottom="&lt;H1&gt;Bottom&lt;/H1&gt;"
classpath="${compile.classpath}"
/>
</target>

<target name="test_footer" depends="init">
<mkdir dir="${ant.test.doc.dir}"/>
<ajdoc sourcepath="${ant.test.src.dir}"
destdir="${ant.test.doc.dir}"
sourcefiles="One.java"
footer="&lt;H1&gt;Footer&lt;/H1&gt;"
classpath="${compile.classpath}"
/>
</target>

<target name="test_header" depends="init">
<mkdir dir="${ant.test.doc.dir}"/>
<ajdoc sourcepath="${ant.test.src.dir}"
destdir="${ant.test.doc.dir}"
sourcefiles="One.java"
header="&lt;H1&gt;Header&lt;/H1&gt;"
classpath="${compile.classpath}"
/>
</target>

<target name="test_nohelp_no" depends="init">
<mkdir dir="${ant.test.doc.dir}"/>
<ajdoc sourcepath="${ant.test.src.dir}"
destdir="${ant.test.doc.dir}"
sourcefiles="One.java"
nohelp="no"
classpath="${compile.classpath}"
/>
</target>

<target name="test_nohelp_yes" depends="init">
<mkdir dir="${ant.test.doc.dir}"/>
<ajdoc sourcepath="${ant.test.src.dir}"
destdir="${ant.test.doc.dir}"
sourcefiles="One.java"
nohelp="yes"
classpath="${compile.classpath}"
/>
</target>

<target name="test_noindex_no" depends="init">
<mkdir dir="${ant.test.doc.dir}"/>
<ajdoc sourcepath="${ant.test.src.dir}"
destdir="${ant.test.doc.dir}"
sourcefiles="One.java"
noindex="no"
classpath="${compile.classpath}"
/>
</target>

<target name="test_noindex_yes" depends="init">
<mkdir dir="${ant.test.doc.dir}"/>
<ajdoc sourcepath="${ant.test.src.dir}"
destdir="${ant.test.doc.dir}"
sourcefiles="One.java"
noindex="yes"
classpath="${compile.classpath}"
/>
</target>

<target name="test_notree_no" depends="init">
<mkdir dir="${ant.test.doc.dir}"/>
<ajdoc sourcepath="${ant.test.src.dir}"
destdir="${ant.test.doc.dir}"
sourcefiles="One.java"
notree="no"
classpath="${compile.classpath}"
/>
</target>

<target name="test_notree_yes" depends="init">
<mkdir dir="${ant.test.doc.dir}"/>
<ajdoc sourcepath="${ant.test.src.dir}"
destdir="${ant.test.doc.dir}"
sourcefiles="One.java"
notree="yes"
classpath="${compile.classpath}"
/>
</target>

<target name="test985" depends="init">
<mkdir dir="${ant.test.doc.dir}"/>
<ajdoc sourcepath="${ant.test.src.dir}"
destdir="${ant.test.doc.dir}"
packagelist="${ant.test.src.dir}/pkgs4.lst"
classpath="${compile.classpath}"
/>
</target>

<target name="test986" depends="init">
<mkdir dir="${ant.test.doc.dir}"/>
<ajdoc sourcepath="${ant.test.src.dir}"
destdir="${ant.test.doc.dir}"
packagelist="${ant.test.src.dir}/pkgs3.lst"
classpath="${compile.classpath}"
/>
</target>

<target name="test987" depends="init">
<mkdir dir="${ant.test.doc.dir}"/>
<ajdoc sourcepath="${ant.test.src.dir}"
destdir="${ant.test.doc.dir}"
packagelist="${ant.test.src.dir}/pkgs2.lst"
classpath="${compile.classpath}"
/>
</target>

<target name="test988" depends="init">
<mkdir dir="${ant.test.doc.dir}"/>
<ajdoc sourcepath="${ant.test.src.dir}"
destdir="${ant.test.doc.dir}"
packagelist="${ant.test.src.dir}/pkgs1.lst"
classpath="${compile.classpath}"
/>
</target>

<target name="test989" depends="init">
<mkdir dir="${ant.test.doc.dir}"/>
<ajdoc sourcepath="${ant.test.src.dir}"
destdir="${ant.test.doc.dir}"
packagenames="p1.*,p2.*"
classpath="${compile.classpath}"
/>
</target>

<target name="test990" depends="init">
<mkdir dir="${ant.test.doc.dir}"/>
<ajdoc sourcepath="${ant.test.src.dir}"
destdir="${ant.test.doc.dir}"
packagenames="p1,p1.pp1,p2,p2.pp2"
classpath="${compile.classpath}"
/>
</target>

<target name="test991" depends="init">
<mkdir dir="${ant.test.doc.dir}"/>
<ajdoc sourcepath="${ant.test.src.dir}"
destdir="${ant.test.doc.dir}"
packagenames="p1,p1.pp1,p2"
classpath="${compile.classpath}"
/>
</target>

<target name="test992" depends="init">
<mkdir dir="${ant.test.doc.dir}"/>
<ajdoc sourcepath="${ant.test.src.dir}"
destdir="${ant.test.doc.dir}"
packagenames="p1,p2"
classpath="${compile.classpath}"
/>
</target>

<target name="test993" depends="init">
<mkdir dir="${ant.test.doc.dir}"/>
<ajdoc sourcepath="${ant.test.src.dir}"
destdir="${ant.test.doc.dir}"
packagenames="p1,p1.pp1"
classpath="${compile.classpath}"
/>
</target>

<target name="test994" depends="init">
<mkdir dir="${ant.test.doc.dir}"/>
<ajdoc sourcepath="${ant.test.src.dir}"
destdir="${ant.test.doc.dir}"
packagenames="p1.*"
classpath="${compile.classpath}"
/>
</target>

<target name="test995" depends="init">
<mkdir dir="${ant.test.doc.dir}"/>
<ajdoc sourcepath="${ant.test.src.dir}"
destdir="${ant.test.doc.dir}"
packagenames="p1"
classpath="${compile.classpath}"
/>
</target>

<target name="test996" depends="init">
<mkdir dir="${ant.test.doc.dir}"/>
<ajdoc sourcepath="${ant.test.src.dir}"
destdir="${ant.test.doc.dir}"
argfiles="${ant.test.src.dir}/files2.lst"
classpath="${compile.classpath}"
/>
</target>

<target name="test997" depends="init">
<mkdir dir="${ant.test.doc.dir}"/>
<ajdoc sourcepath="${ant.test.src.dir}"
destdir="${ant.test.doc.dir}"
argfiles="${ant.test.src.dir}/files1.lst"
classpath="${compile.classpath}"
/>
</target>

<target name="test998" depends="init">
<mkdir dir="${ant.test.doc.dir}"/>
<ajdoc sourcepath="${ant.test.src.dir}"
destdir="${ant.test.doc.dir}"
sourcefiles="One.java,Two.java"
classpath="${compile.classpath}"
/>
</target>

<target name="test999" depends="init">
<mkdir dir="${ant.test.doc.dir}"/>
<ajdoc sourcepath="${ant.test.src.dir}"
destdir="${ant.test.doc.dir}"
sourcefiles="One.java"
classpath="${compile.classpath}"
/>
</target>

</project>

BIN
tests/ant/filecompare/fileCompareTestDirs.zip View File


+ 0
- 0
tests/ant/filecompare/makeTestDir.sh View File


Some files were not shown because too many files changed in this diff

Loading…
Cancel
Save